@volter/editor 0.5.61 → 0.5.62
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/BUNDLED_NOTICES +6 -6
- package/dist/.vite/manifest.json +233 -233
- package/dist/assets/{AudioViewer-Cvu0tj6D.js → AudioViewer-_65u1JZP.js} +1 -1
- package/dist/assets/{EntityModelDocument-Cf9gBRJC.js → EntityModelDocument-B01ItUUL.js} +1 -1
- package/dist/assets/{EnvironmentAssetDocument-Ci98saEi.js → EnvironmentAssetDocument-Bi3xStlu.js} +1 -1
- package/dist/assets/{GameplaySessionTimeline-DE0985zy.js → GameplaySessionTimeline-DrwkiTxs.js} +1 -1
- package/dist/assets/{ImageViewer-BuCQ-r1c.js → ImageViewer-CxxsCkXk.js} +1 -1
- package/dist/assets/{InspectorObjectPreview-DbRdK5-k.js → InspectorObjectPreview-DHQ7UhMS.js} +1 -1
- package/dist/assets/{JsonAssetDocument-CXYQPool.js → JsonAssetDocument-4RfU5RS8.js} +1 -1
- package/dist/assets/{ModelAssetDocument-BcgmYF99.js → ModelAssetDocument-C0WYRlmP.js} +1 -1
- package/dist/assets/{NonThreeAuthoringBootstrap-B3pVzwGx.js → NonThreeAuthoringBootstrap-kBoH9ZCc.js} +2 -2
- package/dist/assets/{Object3DPreview-CqJ1UvnR.js → Object3DPreview-Df_6xVfz.js} +2 -2
- package/dist/assets/{OnlineAssetDetail-Buu6QoLM.js → OnlineAssetDetail-Bl-DFUDz.js} +2 -2
- package/dist/assets/{SourceAssetViewer-D8j4Gm0U.js → SourceAssetViewer-Dq5hik7X.js} +2 -2
- package/dist/assets/{StageHost-iPOh6V05.js → StageHost-CjZBoXiO.js} +4 -4
- package/dist/assets/{ToolObject3DPreview-CxH5xj1p.js → ToolObject3DPreview-DDdFF5Hq.js} +1 -1
- package/dist/assets/{TransientHint-CSkoVYzu.js → TransientHint-Cut0DwSC.js} +1 -1
- package/dist/assets/{VideoViewer-DoYvabkN.js → VideoViewer-DOhDskaJ.js} +1 -1
- package/dist/assets/{asset-editor-persistence-CTVs5At_.js → asset-editor-persistence-Cy4ncL8Y.js} +1 -1
- package/dist/assets/{blender-node-editor.document-BdG20dlg.js → blender-node-editor.document-DZX8R9UW.js} +1 -1
- package/dist/assets/blender-properties-tab-DO8ngdEa.js +3 -0
- package/dist/assets/{blender-runtime-host-DJTo5Z2R.js → blender-runtime-host-CZ0ICcqX.js} +1 -1
- package/dist/assets/{blender-runtime-skin-DqCggoJN.js → blender-runtime-skin-iZ5_55m6.js} +1 -1
- package/dist/assets/{blender-runtime.document-BXR1d_5l.js → blender-runtime.document-e6XwhZtK.js} +1 -1
- package/dist/assets/{blender-timeline.document-qm5K2lns.js → blender-timeline.document-Ct8EdSSf.js} +1 -1
- package/dist/assets/{blender-uv-editor.document-BQ8MMlkb.js → blender-uv-editor.document-DmstRCpx.js} +1 -1
- package/dist/assets/{blender-version.status-BmU30giy.js → blender-version.status-DAnsMAXI.js} +1 -1
- package/dist/assets/{blender.command-B4xyaB1J.js → blender.command-C7eRl9Wc.js} +1 -1
- package/dist/assets/{browserAll-CBGZHmKu.js → browserAll-DdupNJVI.js} +1 -1
- package/dist/assets/{edit-mode-authoring-B-iV5Tn-.js → edit-mode-authoring-D-tlcyhW.js} +1 -1
- package/dist/assets/{hosted-asset-materialization-CNQHav1a.js → hosted-asset-materialization-DrhYnKEA.js} +1 -1
- package/dist/assets/{index-07Amqch3.js → index-DGwLrPW2.js} +10 -10
- package/dist/assets/{models.finder-DP1XyYvb.js → models.finder-D4-OsuPY.js} +1 -1
- package/dist/assets/{product-CoUbepYo.js → product-1wO3CqY2.js} +1 -1
- package/dist/assets/{properties-bone-constraints.inspector-C6NScMEe.js → properties-bone-constraints.inspector-Tu4aGcUC.js} +1 -1
- package/dist/assets/{properties-bone.inspector-CoTNOjj5.js → properties-bone.inspector-BTw6Ydqp.js} +1 -1
- package/dist/assets/{properties-collection.inspector-B4eG6_bC.js → properties-collection.inspector-DS_MJGmP.js} +1 -1
- package/dist/assets/{properties-constraints.inspector-BRqfn0NX.js → properties-constraints.inspector-DDHQ3IsG.js} +1 -1
- package/dist/assets/{properties-data.inspector-BXbFeZPP.js → properties-data.inspector-CU_ptAXu.js} +1 -1
- package/dist/assets/{properties-material.inspector-BfeaO6aB.js → properties-material.inspector-K_490mzj.js} +1 -1
- package/dist/assets/{properties-modifiers.inspector-D3tPSaf2.js → properties-modifiers.inspector-C9W-DSy6.js} +1 -1
- package/dist/assets/{properties-object.inspector-B9ezybNI.js → properties-object.inspector-BSKPM6mE.js} +1 -1
- package/dist/assets/{properties-output.inspector-DjLEv1km.js → properties-output.inspector-BiCs3V_B.js} +1 -1
- package/dist/assets/{properties-particles.inspector-BbQjfMDe.js → properties-particles.inspector-xr6tE5xr.js} +1 -1
- package/dist/assets/{properties-physics.inspector-B6_1of6W.js → properties-physics.inspector-CM4hbWT8.js} +1 -1
- package/dist/assets/{properties-render.inspector-B6ZueVw2.js → properties-render.inspector-q33hbi-N.js} +1 -1
- package/dist/assets/{properties-scene.inspector-By9fe0v9.js → properties-scene.inspector-CsL8eJwX.js} +1 -1
- package/dist/assets/{properties-texture.inspector-j-S0H2GK.js → properties-texture.inspector-Cc1rNJN6.js} +1 -1
- package/dist/assets/{properties-view-layer.inspector-BEybCsjX.js → properties-view-layer.inspector-Clpi3vl_.js} +1 -1
- package/dist/assets/{properties-world.inspector-D1eAUjiB.js → properties-world.inspector-B8WhdUCj.js} +1 -1
- package/dist/assets/{react-story-board-p22CYS79.js → react-story-board-Dz4z1udM.js} +1 -1
- package/dist/assets/{react-three-rapier.esm-DyPu8PN-.js → react-three-rapier.esm-Cs9qhWCS.js} +1 -1
- package/dist/assets/{spark.module-DVeR0ywZ.js → spark.module-CjQpY2Op.js} +1 -1
- package/dist/assets/{stage-keyboard-BBkqzXlW.js → stage-keyboard-BqXYO1Lq.js} +1 -1
- package/dist/assets/{stage-overlay-set-C_8HSfRI.js → stage-overlay-set-Ca7_4aZA.js} +1 -1
- package/dist/assets/{stage-presence-markers-Dhy3vaSU.js → stage-presence-markers-A2CQsGTy.js} +1 -1
- package/dist/assets/{story-capture-BcOlOwLt.js → story-capture-t1kkknek.js} +1 -1
- package/dist/assets/{story-pixi-preview-D7WHysVb.js → story-pixi-preview-DxsuWuR0.js} +1 -1
- package/dist/assets/{story-three-preview-DLodiWJL.js → story-three-preview-Bz5tElwm.js} +2 -2
- package/dist/assets/{webworkerAll-B9OFnN4A.js → webworkerAll-6TTdOa6N.js} +1 -1
- package/dist/assets/{world-documents-BCg8BgpS.js → world-documents-DCnT6IOG.js} +1 -1
- package/dist-node/cli.js +7 -7
- package/package.json +7 -7
- package/dist/assets/blender-properties-tab-BAECyOA_.js +0 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/blender-node-editor.document-
|
|
2
|
-
import{r as Xe,R as fE}from"./index-DaQZGF7d.js";import{a as z}from"./jsx-runtime-DPjLkJKQ.js";import{r as vS}from"./index-CtzuWnCS.js";import{F as Mkr}from"./index-D2LwEE0L.js";import{a as Hqe}from"./client-DNXj_opT.js";import{d as vE,w as Mye,bJ as fkt,am as tz,Y as dkt,b5 as pkt,a0 as NA,by as Gqe,av as Lye,b2 as Lkr,al as jkr,aV as $P,z as Qqe,I as TR,i as hv,p as bE,aa as Kqe,ab as gX,aJ as oZ,aS as Bkr,aT as g9e,aU as _kt,aI as yX,bx as yI,a as mkt,b4 as $kr,aY as kq,x as SS,V as Tc,Q as G8,ay as qkr,aL as hkt,bz as zkr,bA as Ukr,a4 as jye,bB as Vkr,bC as Jkr,bD as gkt,L as zR,h as ihe,f as y9e,bE as Wkr,J as Hkr,aE as ykt,a9 as vFe,aD as Gkr,Z as vkt,b1 as fq,bt as she,b6 as bkt,aG as Akt,b7 as Skt,bF as xkt,aH as Yqe,aB as SP,k as Bye,b as bb,$ as $ye,aM as Qkr,aQ as Kkr,aN as wkt,bG as Ykr,bH as Ckt,bj as Xkr,a1 as oP,aO as M1t,bw as L1t,aP as j1t,_ as Zkr,bI as eIr,ap as xS,bl as Ekt,cd as tIr,ce as rIr,cf as Tkt,q as B1t,cg as $1t,ch as v9e,ci as b9e,cj as nIr,ck as iIr,cl as sIr,cm as oIr,cn as q1t,co as z1t,cp as A9e,cq as bFe,cr as M_e,cs as kkt,ct as Ikt,cu as S9e,O as MY,ac as LY,v as dq,j as Bp,H as QN,cv as Dkt,cw as Pkt,F as vX,K as aIr,y as cIr,cx as lIr,cy as uIr,cz as fIr,cA as dIr,G as pIr,bc as _Ir,bY as mIr,aW as u9,a$ as hIr,aX as gIr,bK as Nkt,a_ as yIr,b3 as vIr,be as bIr,as as Xqe,aC as U1t,bh as AIr,aA as SIr,cB as xIr,c6 as wIr,cC as CIr,cD as EIr,bf as TIr,bL as kIr,cE as IIr,W as V1t,cF as Okt}from"./three.module-BynznMJN.js";import{a as DIr,c as J1t,g as Fkt}from"./_commonjsHelpers-D6-XlEtG.js";const PIr="modulepreload",NIr=function(t){return"/"+t},W1t={},Xo=function(r,i,a){let l=Promise.resolve();if(i&&i.length>0){let _=function(S){return Promise.all(S.map(k=>Promise.resolve(k).then(w=>({status:"fulfilled",value:w}),w=>({status:"rejected",reason:w}))))};document.getElementsByTagName("link");const g=document.querySelector("meta[property=csp-nonce]"),b=g?.nonce||g?.getAttribute("nonce");l=_(i.map(S=>{if(S=NIr(S),S in W1t)return;W1t[S]=!0;const k=S.endsWith(".css"),w=k?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${S}"]${w}`))return;const N=document.createElement("link");if(N.rel=k?"stylesheet":PIr,k||(N.as="script"),N.crossOrigin="",N.href=S,b&&N.setAttribute("nonce",b),document.head.appendChild(N),k)return new Promise((P,j)=>{N.addEventListener("load",P),N.addEventListener("error",()=>j(new Error(`Unable to preload CSS for ${S}`)))})}))}function d(_){const g=new Event("vite:preloadError",{cancelable:!0});if(g.payload=_,window.dispatchEvent(g),!g.defaultPrevented)throw _}return l.then(_=>{for(const g of _||[])g.status==="rejected"&&d(g.reason);return r().catch(d)})},OIr=[{entryPath:"@volter/editor-blender/contributions/blender-node-editor.document.tsx",load:()=>Xo(()=>import("./blender-node-editor.document-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/blender-node-editor.document-DZX8R9UW.js","assets/jsx-runtime-DPjLkJKQ.js","assets/_commonjsHelpers-D6-XlEtG.js","assets/index-DaQZGF7d.js","assets/index-D_NuPfjr.js","assets/blender-runtime-host-CZ0ICcqX.js","assets/three.module-BynznMJN.js","assets/clip-planes-CnAI6DZn.js","assets/index-CtzuWnCS.js","assets/index-CinJrH5C.js","assets/index-D2LwEE0L.js","assets/client-DNXj_opT.js","assets/blender-timeline.document-Ct8EdSSf.js","assets/blender-runtime-skin-iZ5_55m6.js","assets/LineSegments2-vfeDUBfs.js","assets/blender-uv-editor.document-DmstRCpx.js","assets/blender-runtime.document-e6XwhZtK.js","assets/blender-version.status-DAnsMAXI.js","assets/blender.command-C7eRl9Wc.js","assets/blender.status-ujwGU6dU.js","assets/models.finder-D4-OsuPY.js","assets/properties-bone-constraints.inspector-Tu4aGcUC.js","assets/blender-properties-tab-DO8ngdEa.js","assets/properties-constraints.inspector-DDHQ3IsG.js","assets/properties-bone.inspector-BTw6Ydqp.js","assets/properties-collection.inspector-DS_MJGmP.js","assets/properties-data.inspector-CU_ptAXu.js","assets/properties-material.inspector-K_490mzj.js","assets/properties-modifiers.inspector-C9W-DSy6.js","assets/properties-object.inspector-BSKPM6mE.js","assets/properties-output.inspector-BiCs3V_B.js","assets/properties-particles.inspector-xr6tE5xr.js","assets/properties-physics.inspector-CM4hbWT8.js","assets/properties-render.inspector-q33hbi-N.js","assets/properties-scene.inspector-CsL8eJwX.js","assets/properties-texture.inspector-Cc1rNJN6.js","assets/properties-view-layer.inspector-Clpi3vl_.js","assets/properties-world.inspector-B8WhdUCj.js","assets/ToolObject3DPreview-DDdFF5Hq.js","assets/Object3DPreview-Df_6xVfz.js","assets/OrbitControls-BHxt84w6.js","assets/editor-presentation-activity-C7SNSmTd.js","assets/StageHost-CjZBoXiO.js","assets/viewport-pick-context-DkawXbEi.js","assets/GameplaySessionTimeline-DrwkiTxs.js","assets/spark.module-CjQpY2Op.js","assets/AudioViewer-_65u1JZP.js","assets/EntityModelDocument-B01ItUUL.js","assets/EnvironmentAssetDocument-Bi3xStlu.js","assets/fflate.module-DPuTF8aG.js","assets/asset-editor-persistence-Cy4ncL8Y.js","assets/ImageViewer-CxxsCkXk.js","assets/VideoViewer-DOhDskaJ.js","assets/JsonAssetDocument-4RfU5RS8.js","assets/ModelAssetDocument-C0WYRlmP.js","assets/OnlineAssetDetail-Bl-DFUDz.js","assets/SourceAssetViewer-Dq5hik7X.js","assets/world-documents-DCnT6IOG.js","assets/edit-mode-authoring-D-tlcyhW.js","assets/TransientHint-Cut0DwSC.js","assets/react-story-board-Dz4z1udM.js","assets/index-C5UECeSr.js","assets/index-Cl83EGRl.js","assets/BufferGeometryUtils-oP8-Ve4I.js","assets/events-156d8d12.esm-Dy_KXdhT.js","assets/react-18-DyywM-Z2.js","assets/browserAll-DdupNJVI.js","assets/webworkerAll-6TTdOa6N.js","assets/FBXLoader-DzWtiWYm.js","assets/OBJLoader-8SrBLZ7J.js","assets/MTLLoader-D8SKGOsv.js","assets/ColladaLoader-CyOCKXko.js","assets/STLLoader-U-3fQm8v.js","assets/PLYLoader-BXUWXVtV.js","assets/BVHLoader--2mLoe3e.js","assets/TDSLoader-BtiaQ4S3.js","assets/InspectorObjectPreview-DHQ7UhMS.js","assets/InspectorCanvasPreview-CLDhscy0.js","assets/hosted-asset-materialization-DrhYnKEA.js","assets/NonThreeAuthoringBootstrap-kBoH9ZCc.js","assets/story-pixi-preview-DxsuWuR0.js","assets/story-mount-turn-2IYGgHob.js","assets/story-three-preview-Bz5tElwm.js","assets/story-capture-t1kkknek.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as Xe,R as fE}from"./index-DaQZGF7d.js";import{a as z}from"./jsx-runtime-DPjLkJKQ.js";import{r as vS}from"./index-CtzuWnCS.js";import{F as Mkr}from"./index-D2LwEE0L.js";import{a as Hqe}from"./client-DNXj_opT.js";import{d as vE,w as Mye,bJ as fkt,am as tz,Y as dkt,b5 as pkt,a0 as NA,by as Gqe,av as Lye,b2 as Lkr,al as jkr,aV as $P,z as Qqe,I as TR,i as hv,p as bE,aa as Kqe,ab as gX,aJ as oZ,aS as Bkr,aT as g9e,aU as _kt,aI as yX,bx as yI,a as mkt,b4 as $kr,aY as kq,x as SS,V as Tc,Q as G8,ay as qkr,aL as hkt,bz as zkr,bA as Ukr,a4 as jye,bB as Vkr,bC as Jkr,bD as gkt,L as zR,h as ihe,f as y9e,bE as Wkr,J as Hkr,aE as ykt,a9 as vFe,aD as Gkr,Z as vkt,b1 as fq,bt as she,b6 as bkt,aG as Akt,b7 as Skt,bF as xkt,aH as Yqe,aB as SP,k as Bye,b as bb,$ as $ye,aM as Qkr,aQ as Kkr,aN as wkt,bG as Ykr,bH as Ckt,bj as Xkr,a1 as oP,aO as M1t,bw as L1t,aP as j1t,_ as Zkr,bI as eIr,ap as xS,bl as Ekt,cd as tIr,ce as rIr,cf as Tkt,q as B1t,cg as $1t,ch as v9e,ci as b9e,cj as nIr,ck as iIr,cl as sIr,cm as oIr,cn as q1t,co as z1t,cp as A9e,cq as bFe,cr as M_e,cs as kkt,ct as Ikt,cu as S9e,O as MY,ac as LY,v as dq,j as Bp,H as QN,cv as Dkt,cw as Pkt,F as vX,K as aIr,y as cIr,cx as lIr,cy as uIr,cz as fIr,cA as dIr,G as pIr,bc as _Ir,bY as mIr,aW as u9,a$ as hIr,aX as gIr,bK as Nkt,a_ as yIr,b3 as vIr,be as bIr,as as Xqe,aC as U1t,bh as AIr,aA as SIr,cB as xIr,c6 as wIr,cC as CIr,cD as EIr,bf as TIr,bL as kIr,cE as IIr,W as V1t,cF as Okt}from"./three.module-BynznMJN.js";import{a as DIr,c as J1t,g as Fkt}from"./_commonjsHelpers-D6-XlEtG.js";const PIr="modulepreload",NIr=function(t){return"/"+t},W1t={},Xo=function(r,i,a){let l=Promise.resolve();if(i&&i.length>0){let _=function(S){return Promise.all(S.map(k=>Promise.resolve(k).then(w=>({status:"fulfilled",value:w}),w=>({status:"rejected",reason:w}))))};document.getElementsByTagName("link");const g=document.querySelector("meta[property=csp-nonce]"),b=g?.nonce||g?.getAttribute("nonce");l=_(i.map(S=>{if(S=NIr(S),S in W1t)return;W1t[S]=!0;const k=S.endsWith(".css"),w=k?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${S}"]${w}`))return;const N=document.createElement("link");if(N.rel=k?"stylesheet":PIr,k||(N.as="script"),N.crossOrigin="",N.href=S,b&&N.setAttribute("nonce",b),document.head.appendChild(N),k)return new Promise((P,j)=>{N.addEventListener("load",P),N.addEventListener("error",()=>j(new Error(`Unable to preload CSS for ${S}`)))})}))}function d(_){const g=new Event("vite:preloadError",{cancelable:!0});if(g.payload=_,window.dispatchEvent(g),!g.defaultPrevented)throw _}return l.then(_=>{for(const g of _||[])g.status==="rejected"&&d(g.reason);return r().catch(d)})},OIr=[{entryPath:"@volter/editor-blender/contributions/blender-node-editor.document.tsx",load:()=>Xo(()=>import("./blender-node-editor.document-DZX8R9UW.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11]))},{entryPath:"@volter/editor-blender/contributions/blender-timeline.document.tsx",load:()=>Xo(()=>import("./blender-timeline.document-Ct8EdSSf.js"),__vite__mapDeps([12,1,2,13,14,6,5,7,3,4,8,9,10,11]))},{entryPath:"@volter/editor-blender/contributions/blender-uv-editor.document.tsx",load:()=>Xo(()=>import("./blender-uv-editor.document-DmstRCpx.js"),__vite__mapDeps([15,1,2,3,4,5,6,7,8,9,10,11]))},{entryPath:"@volter/editor-blender/contributions/blender-runtime.document.tsx",load:()=>Xo(()=>import("./blender-runtime.document-e6XwhZtK.js"),__vite__mapDeps([16,1,2,13,14,6,5,7,3,4,8,9,10,11]))},{entryPath:"@volter/editor-blender/contributions/blender-version.status.tsx",load:()=>Xo(()=>import("./blender-version.status-DAnsMAXI.js"),__vite__mapDeps([17,1,2,3,4,8,9,10,11,6]))},{entryPath:"@volter/editor-blender/contributions/blender.command.ts",load:()=>Xo(()=>import("./blender.command-C7eRl9Wc.js"),__vite__mapDeps([18,5,6,7,3,2,4,1,8,9,10,11]))},{entryPath:"@volter/editor-blender/contributions/blender.keymap.ts",load:()=>Xo(()=>import("./blender.keymap-GAQgeklK.js"),[])},{entryPath:"@volter/editor-blender/contributions/blender.status.tsx",load:()=>Xo(()=>import("./blender.status-ujwGU6dU.js"),__vite__mapDeps([19,1,2]))},{entryPath:"@volter/editor-blender/contributions/blender.style.ts",load:()=>Xo(()=>import("./blender.style-Dcem5f_T.js"),[])},{entryPath:"@volter/editor-blender/contributions/model.layout.ts",load:()=>Xo(()=>import("./model.layout-BJUEQYUI.js"),[])},{entryPath:"@volter/editor-blender/contributions/models.finder.ts",load:()=>Xo(()=>import("./models.finder-D4-OsuPY.js"),__vite__mapDeps([20,3,2,4,1,8,9,10,11,6]))},{entryPath:"@volter/editor-blender/contributions/properties-bone-constraints.inspector.tsx",load:()=>Xo(()=>import("./properties-bone-constraints.inspector-Tu4aGcUC.js"),__vite__mapDeps([21,22,1,2,5,6,7,3,4,23,8,9,10,11]))},{entryPath:"@volter/editor-blender/contributions/properties-bone.inspector.tsx",load:()=>Xo(()=>import("./properties-bone.inspector-BTw6Ydqp.js"),__vite__mapDeps([24,22,1,2,5,6,7,3,4,8,9,10,11]))},{entryPath:"@volter/editor-blender/contributions/properties-collection.inspector.tsx",load:()=>Xo(()=>import("./properties-collection.inspector-DS_MJGmP.js"),__vite__mapDeps([25,22,1,2,5,6,7,3,4,8,9,10,11]))},{entryPath:"@volter/editor-blender/contributions/properties-constraints.inspector.tsx",load:()=>Xo(()=>import("./properties-constraints.inspector-DDHQ3IsG.js"),__vite__mapDeps([23,22,1,2,5,6,7,3,4,8,9,10,11]))},{entryPath:"@volter/editor-blender/contributions/properties-data.inspector.tsx",load:()=>Xo(()=>import("./properties-data.inspector-CU_ptAXu.js"),__vite__mapDeps([26,22,1,2,5,6,7,3,4,8,9,10,11]))},{entryPath:"@volter/editor-blender/contributions/properties-material.inspector.tsx",load:()=>Xo(()=>import("./properties-material.inspector-K_490mzj.js"),__vite__mapDeps([27,22,1,2,5,6,7,3,4,8,9,10,11]))},{entryPath:"@volter/editor-blender/contributions/properties-modifiers.inspector.tsx",load:()=>Xo(()=>import("./properties-modifiers.inspector-C9W-DSy6.js"),__vite__mapDeps([28,22,1,2,5,6,7,3,4,8,9,10,11]))},{entryPath:"@volter/editor-blender/contributions/properties-object.inspector.tsx",load:()=>Xo(()=>import("./properties-object.inspector-BSKPM6mE.js"),__vite__mapDeps([29,22,1,2,5,6,7,3,4,8,9,10,11]))},{entryPath:"@volter/editor-blender/contributions/properties-output.inspector.tsx",load:()=>Xo(()=>import("./properties-output.inspector-BiCs3V_B.js"),__vite__mapDeps([30,22,1,2,5,6,7,3,4,8,9,10,11]))},{entryPath:"@volter/editor-blender/contributions/properties-particles.inspector.tsx",load:()=>Xo(()=>import("./properties-particles.inspector-xr6tE5xr.js"),__vite__mapDeps([31,22,1,2,5,6,7,3,4,8,9,10,11]))},{entryPath:"@volter/editor-blender/contributions/properties-physics.inspector.tsx",load:()=>Xo(()=>import("./properties-physics.inspector-CM4hbWT8.js"),__vite__mapDeps([32,22,1,2,5,6,7,3,4,8,9,10,11]))},{entryPath:"@volter/editor-blender/contributions/properties-render.inspector.tsx",load:()=>Xo(()=>import("./properties-render.inspector-q33hbi-N.js"),__vite__mapDeps([33,22,1,2,5,6,7,3,4,8,9,10,11]))},{entryPath:"@volter/editor-blender/contributions/properties-scene.inspector.tsx",load:()=>Xo(()=>import("./properties-scene.inspector-CsL8eJwX.js"),__vite__mapDeps([34,22,1,2,5,6,7,3,4,8,9,10,11]))},{entryPath:"@volter/editor-blender/contributions/properties-texture.inspector.tsx",load:()=>Xo(()=>import("./properties-texture.inspector-Cc1rNJN6.js"),__vite__mapDeps([35,22,1,2,5,6,7,3,4,8,9,10,11]))},{entryPath:"@volter/editor-blender/contributions/properties-view-layer.inspector.tsx",load:()=>Xo(()=>import("./properties-view-layer.inspector-Clpi3vl_.js"),__vite__mapDeps([36,22,1,2,5,6,7,3,4,8,9,10,11]))},{entryPath:"@volter/editor-blender/contributions/properties-world.inspector.tsx",load:()=>Xo(()=>import("./properties-world.inspector-B8WhdUCj.js"),__vite__mapDeps([37,22,1,2,5,6,7,3,4,8,9,10,11]))},{entryPath:"@volter/editor-blender/contributions/sculpt.layout.ts",load:()=>Xo(()=>import("./sculpt.layout-zJF55yCR.js"),[])},{entryPath:"@volter/editor-blender/contributions/shading.layout.ts",load:()=>Xo(()=>import("./shading.layout-DULYZV6M.js"),[])},{entryPath:"@volter/editor-blender/contributions/uv-editing.layout.ts",load:()=>Xo(()=>import("./uv-editing.layout-BEKHxmHw.js"),[])},{entryPath:"@volter/editor-blender/contributions/texture.layout.ts",load:()=>Xo(()=>import("./texture.layout-DASpHVht.js"),[])}];let jY=null;const x9e=new Set;function qye(){return jY}function FIr(t){if(jY!==null&&jY.id!==t.id)throw new Error(`Two products in one page: "${jY.id}" is already composed and "${t.id}" asked to be. A product is the running program; one page runs one.`);jY=t;for(const r of x9e)r()}function Rkt(t){return x9e.add(t),()=>x9e.delete(t)}/*!
|
|
3
3
|
* Font Awesome Free 7.2.0 by @fontawesome - https://fontawesome.com
|
|
4
4
|
* License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
|
|
5
5
|
* Copyright 2026 Fonticons, Inc.
|
|
@@ -41,7 +41,7 @@ import{r as Xe,R as fE}from"./index-DaQZGF7d.js";import{a as z}from"./jsx-runtim
|
|
|
41
41
|
|
|
42
42
|
`)}P.write("payload.value = newResult;"),P.write("return payload;");const ee=P.compile();return(xe,ue)=>ee(N,xe,ue)};let d;const _=aZ,g=!EIt.jitless,S=g&&C3r.value,k=r.catchall;let w;t._zod.parse=(N,P)=>{w??(w=a.value);const j=N.value;return _(j)?g&&S&&P?.async===!1&&P.jitless!==!0?(d||(d=l(r.shape)),N=d(N,P),k?UIt([],j,N,P,w,t):N):i(N,P):(N.issues.push({expected:"object",code:"invalid_type",input:j,inst:t}),N)}});function ubt(t,r,i,a){for(const d of t)if(d.issues.length===0)return r.value=d.value,r;const l=t.filter(d=>!_q(d));return l.length===1?(r.value=l[0].value,l[0]):(r.issues.push({code:"invalid_union",input:r.value,inst:i,errors:t.map(d=>d.issues.map(_=>E8(_,a,C8())))}),r)}const VIt=ys("$ZodUnion",(t,r)=>{H_.init(t,r),Vf(t._zod,"optin",()=>r.options.some(l=>l._zod.optin==="optional")?"optional":void 0),Vf(t._zod,"optout",()=>r.options.some(l=>l._zod.optout==="optional")?"optional":void 0),Vf(t._zod,"values",()=>{if(r.options.every(l=>l._zod.values))return new Set(r.options.flatMap(l=>Array.from(l._zod.values)))}),Vf(t._zod,"pattern",()=>{if(r.options.every(l=>l._zod.pattern)){const l=r.options.map(d=>d._zod.pattern);return new RegExp(`^(${l.map(d=>oze(d.source)).join("|")})$`)}});const i=r.options.length===1,a=r.options[0]._zod.run;t._zod.parse=(l,d)=>{if(i)return a(l,d);let _=!1;const g=[];for(const b of r.options){const S=b._zod.run({value:l.value,issues:[]},d);if(S instanceof Promise)g.push(S),_=!0;else{if(S.issues.length===0)return S;g.push(S)}}return _?Promise.all(g).then(b=>ubt(b,l,t,d)):ubt(g,l,t,d)}}),f4r=ys("$ZodDiscriminatedUnion",(t,r)=>{r.inclusive=!1,VIt.init(t,r);const i=t._zod.parse;Vf(t._zod,"propValues",()=>{const l={};for(const d of r.options){const _=d._zod.propValues;if(!_||Object.keys(_).length===0)throw new Error(`Invalid discriminated union option at index "${r.options.indexOf(d)}"`);for(const[g,b]of Object.entries(_)){l[g]||(l[g]=new Set);for(const S of b)l[g].add(S)}}return l});const a=Wye(()=>{const l=r.options,d=new Map;for(const _ of l){const g=_._zod.propValues?.[r.discriminator];if(!g||g.size===0)throw new Error(`Invalid discriminated union option at index "${r.options.indexOf(_)}"`);for(const b of g){if(d.has(b))throw new Error(`Duplicate discriminator value "${String(b)}"`);d.set(b,_)}}return d});t._zod.parse=(l,d)=>{const _=l.value;if(!aZ(_))return l.issues.push({code:"invalid_type",expected:"object",input:_,inst:t}),l;const g=a.value.get(_?.[r.discriminator]);return g?g._zod.run(l,d):r.unionFallback?i(l,d):(l.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:r.discriminator,input:_,path:[r.discriminator],inst:t}),l)}}),d4r=ys("$ZodIntersection",(t,r)=>{H_.init(t,r),t._zod.parse=(i,a)=>{const l=i.value,d=r.left._zod.run({value:l,issues:[]},a),_=r.right._zod.run({value:l,issues:[]},a);return d instanceof Promise||_ instanceof Promise?Promise.all([d,_]).then(([b,S])=>fbt(i,b,S)):fbt(i,d,_)}});function N9e(t,r){if(t===r)return{valid:!0,data:t};if(t instanceof Date&&r instanceof Date&&+t==+r)return{valid:!0,data:t};if(rz(t)&&rz(r)){const i=Object.keys(r),a=Object.keys(t).filter(d=>i.indexOf(d)!==-1),l={...t,...r};for(const d of a){const _=N9e(t[d],r[d]);if(!_.valid)return{valid:!1,mergeErrorPath:[d,..._.mergeErrorPath]};l[d]=_.data}return{valid:!0,data:l}}if(Array.isArray(t)&&Array.isArray(r)){if(t.length!==r.length)return{valid:!1,mergeErrorPath:[]};const i=[];for(let a=0;a<t.length;a++){const l=t[a],d=r[a],_=N9e(l,d);if(!_.valid)return{valid:!1,mergeErrorPath:[a,..._.mergeErrorPath]};i.push(_.data)}return{valid:!0,data:i}}return{valid:!1,mergeErrorPath:[]}}function fbt(t,r,i){const a=new Map;let l;for(const g of r.issues)if(g.code==="unrecognized_keys"){l??(l=g);for(const b of g.keys)a.has(b)||a.set(b,{}),a.get(b).l=!0}else t.issues.push(g);for(const g of i.issues)if(g.code==="unrecognized_keys")for(const b of g.keys)a.has(b)||a.set(b,{}),a.get(b).r=!0;else t.issues.push(g);const d=[...a].filter(([,g])=>g.l&&g.r).map(([g])=>g);if(d.length&&l&&t.issues.push({...l,keys:d}),_q(t))return t;const _=N9e(r.value,i.value);if(!_.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(_.mergeErrorPath)}`);return t.value=_.data,t}const p4r=ys("$ZodTuple",(t,r)=>{H_.init(t,r);const i=r.items;t._zod.parse=(a,l)=>{const d=a.value;if(!Array.isArray(d))return a.issues.push({input:d,inst:t,expected:"tuple",code:"invalid_type"}),a;a.value=[];const _=[],g=[...i].reverse().findIndex(k=>k._zod.optin!=="optional"),b=g===-1?0:i.length-g;if(!r.rest){const k=d.length>i.length,w=d.length<b-1;if(k||w)return a.issues.push({...k?{code:"too_big",maximum:i.length,inclusive:!0}:{code:"too_small",minimum:i.length},input:d,inst:t,origin:"array"}),a}let S=-1;for(const k of i){if(S++,S>=d.length&&S>=b)continue;const w=k._zod.run({value:d[S],issues:[]},l);w instanceof Promise?_.push(w.then(N=>kpe(N,a,S))):kpe(w,a,S)}if(r.rest){const k=d.slice(i.length);for(const w of k){S++;const N=r.rest._zod.run({value:w,issues:[]},l);N instanceof Promise?_.push(N.then(P=>kpe(P,a,S))):kpe(N,a,S)}}return _.length?Promise.all(_).then(()=>a):a}});function kpe(t,r,i){t.issues.length&&r.issues.push(...fR(i,t.issues)),r.value[i]=t.value}const _4r=ys("$ZodRecord",(t,r)=>{H_.init(t,r),t._zod.parse=(i,a)=>{const l=i.value;if(!rz(l))return i.issues.push({expected:"record",code:"invalid_type",input:l,inst:t}),i;const d=[],_=r.keyType._zod.values;if(_){i.value={};const g=new Set;for(const S of _)if(typeof S=="string"||typeof S=="number"||typeof S=="symbol"){g.add(typeof S=="number"?S.toString():S);const k=r.valueType._zod.run({value:l[S],issues:[]},a);k instanceof Promise?d.push(k.then(w=>{w.issues.length&&i.issues.push(...fR(S,w.issues)),i.value[S]=w.value})):(k.issues.length&&i.issues.push(...fR(S,k.issues)),i.value[S]=k.value)}let b;for(const S in l)g.has(S)||(b=b??[],b.push(S));b&&b.length>0&&i.issues.push({code:"unrecognized_keys",input:l,inst:t,keys:b})}else{i.value={};for(const g of Reflect.ownKeys(l)){if(g==="__proto__")continue;let b=r.keyType._zod.run({value:g,issues:[]},a);if(b instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof g=="string"&&MIt.test(g)&&b.issues.length){const w=r.keyType._zod.run({value:Number(g),issues:[]},a);if(w instanceof Promise)throw new Error("Async schemas not supported in object keys currently");w.issues.length===0&&(b=w)}if(b.issues.length){r.mode==="loose"?i.value[g]=l[g]:i.issues.push({code:"invalid_key",origin:"record",issues:b.issues.map(w=>E8(w,a,C8())),input:g,path:[g],inst:t});continue}const k=r.valueType._zod.run({value:l[g],issues:[]},a);k instanceof Promise?d.push(k.then(w=>{w.issues.length&&i.issues.push(...fR(g,w.issues)),i.value[b.value]=w.value})):(k.issues.length&&i.issues.push(...fR(g,k.issues)),i.value[b.value]=k.value)}}return d.length?Promise.all(d).then(()=>i):i}}),m4r=ys("$ZodEnum",(t,r)=>{H_.init(t,r);const i=TIt(r.entries),a=new Set(i);t._zod.values=a,t._zod.pattern=new RegExp(`^(${i.filter(l=>E3r.has(typeof l)).map(l=>typeof l=="string"?nz(l):l.toString()).join("|")})$`),t._zod.parse=(l,d)=>{const _=l.value;return a.has(_)||l.issues.push({code:"invalid_value",values:i,input:_,inst:t}),l}}),h4r=ys("$ZodLiteral",(t,r)=>{if(H_.init(t,r),r.values.length===0)throw new Error("Cannot create literal schema with no valid values");const i=new Set(r.values);t._zod.values=i,t._zod.pattern=new RegExp(`^(${r.values.map(a=>typeof a=="string"?nz(a):a?nz(a.toString()):String(a)).join("|")})$`),t._zod.parse=(a,l)=>{const d=a.value;return i.has(d)||a.issues.push({code:"invalid_value",values:r.values,input:d,inst:t}),a}}),g4r=ys("$ZodTransform",(t,r)=>{H_.init(t,r),t._zod.parse=(i,a)=>{if(a.direction==="backward")throw new CIt(t.constructor.name);const l=r.transform(i.value,i);if(a.async)return(l instanceof Promise?l:Promise.resolve(l)).then(_=>(i.value=_,i));if(l instanceof Promise)throw new Iq;return i.value=l,i}});function dbt(t,r){return t.issues.length&&r===void 0?{issues:[],value:void 0}:t}const JIt=ys("$ZodOptional",(t,r)=>{H_.init(t,r),t._zod.optin="optional",t._zod.optout="optional",Vf(t._zod,"values",()=>r.innerType._zod.values?new Set([...r.innerType._zod.values,void 0]):void 0),Vf(t._zod,"pattern",()=>{const i=r.innerType._zod.pattern;return i?new RegExp(`^(${oze(i.source)})?$`):void 0}),t._zod.parse=(i,a)=>{if(r.innerType._zod.optin==="optional"){const l=r.innerType._zod.run(i,a);return l instanceof Promise?l.then(d=>dbt(d,i.value)):dbt(l,i.value)}return i.value===void 0?i:r.innerType._zod.run(i,a)}}),y4r=ys("$ZodExactOptional",(t,r)=>{JIt.init(t,r),Vf(t._zod,"values",()=>r.innerType._zod.values),Vf(t._zod,"pattern",()=>r.innerType._zod.pattern),t._zod.parse=(i,a)=>r.innerType._zod.run(i,a)}),v4r=ys("$ZodNullable",(t,r)=>{H_.init(t,r),Vf(t._zod,"optin",()=>r.innerType._zod.optin),Vf(t._zod,"optout",()=>r.innerType._zod.optout),Vf(t._zod,"pattern",()=>{const i=r.innerType._zod.pattern;return i?new RegExp(`^(${oze(i.source)}|null)$`):void 0}),Vf(t._zod,"values",()=>r.innerType._zod.values?new Set([...r.innerType._zod.values,null]):void 0),t._zod.parse=(i,a)=>i.value===null?i:r.innerType._zod.run(i,a)}),b4r=ys("$ZodDefault",(t,r)=>{H_.init(t,r),t._zod.optin="optional",Vf(t._zod,"values",()=>r.innerType._zod.values),t._zod.parse=(i,a)=>{if(a.direction==="backward")return r.innerType._zod.run(i,a);if(i.value===void 0)return i.value=r.defaultValue,i;const l=r.innerType._zod.run(i,a);return l instanceof Promise?l.then(d=>pbt(d,r)):pbt(l,r)}});function pbt(t,r){return t.value===void 0&&(t.value=r.defaultValue),t}const A4r=ys("$ZodPrefault",(t,r)=>{H_.init(t,r),t._zod.optin="optional",Vf(t._zod,"values",()=>r.innerType._zod.values),t._zod.parse=(i,a)=>(a.direction==="backward"||i.value===void 0&&(i.value=r.defaultValue),r.innerType._zod.run(i,a))}),S4r=ys("$ZodNonOptional",(t,r)=>{H_.init(t,r),Vf(t._zod,"values",()=>{const i=r.innerType._zod.values;return i?new Set([...i].filter(a=>a!==void 0)):void 0}),t._zod.parse=(i,a)=>{const l=r.innerType._zod.run(i,a);return l instanceof Promise?l.then(d=>_bt(d,t)):_bt(l,t)}});function _bt(t,r){return!t.issues.length&&t.value===void 0&&t.issues.push({code:"invalid_type",expected:"nonoptional",input:t.value,inst:r}),t}const x4r=ys("$ZodCatch",(t,r)=>{H_.init(t,r),Vf(t._zod,"optin",()=>r.innerType._zod.optin),Vf(t._zod,"optout",()=>r.innerType._zod.optout),Vf(t._zod,"values",()=>r.innerType._zod.values),t._zod.parse=(i,a)=>{if(a.direction==="backward")return r.innerType._zod.run(i,a);const l=r.innerType._zod.run(i,a);return l instanceof Promise?l.then(d=>(i.value=d.value,d.issues.length&&(i.value=r.catchValue({...i,error:{issues:d.issues.map(_=>E8(_,a,C8()))},input:i.value}),i.issues=[]),i)):(i.value=l.value,l.issues.length&&(i.value=r.catchValue({...i,error:{issues:l.issues.map(d=>E8(d,a,C8()))},input:i.value}),i.issues=[]),i)}}),w4r=ys("$ZodPipe",(t,r)=>{H_.init(t,r),Vf(t._zod,"values",()=>r.in._zod.values),Vf(t._zod,"optin",()=>r.in._zod.optin),Vf(t._zod,"optout",()=>r.out._zod.optout),Vf(t._zod,"propValues",()=>r.in._zod.propValues),t._zod.parse=(i,a)=>{if(a.direction==="backward"){const d=r.out._zod.run(i,a);return d instanceof Promise?d.then(_=>Ipe(_,r.in,a)):Ipe(d,r.in,a)}const l=r.in._zod.run(i,a);return l instanceof Promise?l.then(d=>Ipe(d,r.out,a)):Ipe(l,r.out,a)}});function Ipe(t,r,i){return t.issues.length?(t.aborted=!0,t):r._zod.run({value:t.value,issues:t.issues},i)}const C4r=ys("$ZodReadonly",(t,r)=>{H_.init(t,r),Vf(t._zod,"propValues",()=>r.innerType._zod.propValues),Vf(t._zod,"values",()=>r.innerType._zod.values),Vf(t._zod,"optin",()=>r.innerType?._zod?.optin),Vf(t._zod,"optout",()=>r.innerType?._zod?.optout),t._zod.parse=(i,a)=>{if(a.direction==="backward")return r.innerType._zod.run(i,a);const l=r.innerType._zod.run(i,a);return l instanceof Promise?l.then(mbt):mbt(l)}});function mbt(t){return t.value=Object.freeze(t.value),t}const E4r=ys("$ZodLazy",(t,r)=>{H_.init(t,r),Vf(t._zod,"innerType",()=>r.getter()),Vf(t._zod,"pattern",()=>t._zod.innerType?._zod?.pattern),Vf(t._zod,"propValues",()=>t._zod.innerType?._zod?.propValues),Vf(t._zod,"optin",()=>t._zod.innerType?._zod?.optin??void 0),Vf(t._zod,"optout",()=>t._zod.innerType?._zod?.optout??void 0),t._zod.parse=(i,a)=>t._zod.innerType._zod.run(i,a)}),T4r=ys("$ZodCustom",(t,r)=>{LA.init(t,r),H_.init(t,r),t._zod.parse=(i,a)=>i,t._zod.check=i=>{const a=i.value,l=r.fn(a);if(l instanceof Promise)return l.then(d=>hbt(d,i,a,t));hbt(l,i,a,t)}});function hbt(t,r,i,a){if(!t){const l={code:"custom",input:i,inst:a,path:[...a._zod.def.path??[]],continue:!a._zod.def.abort};a._zod.def.params&&(l.params=a._zod.def.params),r.issues.push(cZ(l))}}var gbt;class k4r{constructor(){this._map=new WeakMap,this._idmap=new Map}add(r,...i){const a=i[0];return this._map.set(r,a),a&&typeof a=="object"&&"id"in a&&this._idmap.set(a.id,r),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(r){const i=this._map.get(r);return i&&typeof i=="object"&&"id"in i&&this._idmap.delete(i.id),this._map.delete(r),this}get(r){const i=r._zod.parent;if(i){const a={...this.get(i)??{}};delete a.id;const l={...a,...this._map.get(r)};return Object.keys(l).length?l:void 0}return this._map.get(r)}has(r){return this._map.has(r)}}function I4r(){return new k4r}(gbt=globalThis).__zod_globalRegistry??(gbt.__zod_globalRegistry=I4r());const qY=globalThis.__zod_globalRegistry;function D4r(t,r){return new t({type:"string",...kc(r)})}function P4r(t,r){return new t({type:"string",format:"email",check:"string_format",abort:!1,...kc(r)})}function ybt(t,r){return new t({type:"string",format:"guid",check:"string_format",abort:!1,...kc(r)})}function N4r(t,r){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,...kc(r)})}function O4r(t,r){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...kc(r)})}function F4r(t,r){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...kc(r)})}function R4r(t,r){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...kc(r)})}function M4r(t,r){return new t({type:"string",format:"url",check:"string_format",abort:!1,...kc(r)})}function L4r(t,r){return new t({type:"string",format:"emoji",check:"string_format",abort:!1,...kc(r)})}function j4r(t,r){return new t({type:"string",format:"nanoid",check:"string_format",abort:!1,...kc(r)})}function B4r(t,r){return new t({type:"string",format:"cuid",check:"string_format",abort:!1,...kc(r)})}function $4r(t,r){return new t({type:"string",format:"cuid2",check:"string_format",abort:!1,...kc(r)})}function q4r(t,r){return new t({type:"string",format:"ulid",check:"string_format",abort:!1,...kc(r)})}function z4r(t,r){return new t({type:"string",format:"xid",check:"string_format",abort:!1,...kc(r)})}function U4r(t,r){return new t({type:"string",format:"ksuid",check:"string_format",abort:!1,...kc(r)})}function V4r(t,r){return new t({type:"string",format:"ipv4",check:"string_format",abort:!1,...kc(r)})}function J4r(t,r){return new t({type:"string",format:"ipv6",check:"string_format",abort:!1,...kc(r)})}function W4r(t,r){return new t({type:"string",format:"cidrv4",check:"string_format",abort:!1,...kc(r)})}function H4r(t,r){return new t({type:"string",format:"cidrv6",check:"string_format",abort:!1,...kc(r)})}function G4r(t,r){return new t({type:"string",format:"base64",check:"string_format",abort:!1,...kc(r)})}function Q4r(t,r){return new t({type:"string",format:"base64url",check:"string_format",abort:!1,...kc(r)})}function K4r(t,r){return new t({type:"string",format:"e164",check:"string_format",abort:!1,...kc(r)})}function Y4r(t,r){return new t({type:"string",format:"jwt",check:"string_format",abort:!1,...kc(r)})}function X4r(t,r){return new t({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...kc(r)})}function Z4r(t,r){return new t({type:"string",format:"date",check:"string_format",...kc(r)})}function e6r(t,r){return new t({type:"string",format:"time",check:"string_format",precision:null,...kc(r)})}function t6r(t,r){return new t({type:"string",format:"duration",check:"string_format",...kc(r)})}function r6r(t,r){return new t({type:"number",checks:[],...kc(r)})}function n6r(t,r){return new t({type:"number",check:"number_format",abort:!1,format:"safeint",...kc(r)})}function i6r(t,r){return new t({type:"boolean",...kc(r)})}function s6r(t){return new t({type:"unknown"})}function o6r(t,r){return new t({type:"never",...kc(r)})}function vbt(t,r){return new jIt({check:"less_than",...kc(r),value:t,inclusive:!1})}function SFe(t,r){return new jIt({check:"less_than",...kc(r),value:t,inclusive:!0})}function bbt(t,r){return new BIt({check:"greater_than",...kc(r),value:t,inclusive:!1})}function xFe(t,r){return new BIt({check:"greater_than",...kc(r),value:t,inclusive:!0})}function Abt(t,r){return new vPr({check:"multiple_of",...kc(r),value:t})}function WIt(t,r){return new APr({check:"max_length",...kc(r),maximum:t})}function che(t,r){return new SPr({check:"min_length",...kc(r),minimum:t})}function HIt(t,r){return new xPr({check:"length_equals",...kc(r),length:t})}function a6r(t,r){return new wPr({check:"string_format",format:"regex",...kc(r),pattern:t})}function c6r(t){return new CPr({check:"string_format",format:"lowercase",...kc(t)})}function l6r(t){return new EPr({check:"string_format",format:"uppercase",...kc(t)})}function u6r(t,r){return new TPr({check:"string_format",format:"includes",...kc(r),includes:t})}function f6r(t,r){return new kPr({check:"string_format",format:"starts_with",...kc(r),prefix:t})}function d6r(t,r){return new IPr({check:"string_format",format:"ends_with",...kc(r),suffix:t})}function tU(t){return new DPr({check:"overwrite",tx:t})}function p6r(t){return tU(r=>r.normalize(t))}function _6r(){return tU(t=>t.trim())}function m6r(){return tU(t=>t.toLowerCase())}function h6r(){return tU(t=>t.toUpperCase())}function g6r(){return tU(t=>w3r(t))}function y6r(t,r,i){return new t({type:"array",element:r,...kc(i)})}function v6r(t,r,i){const a=kc(i);return a.abort??(a.abort=!0),new t({type:"custom",check:"custom",fn:r,...a})}function b6r(t,r,i){return new t({type:"custom",check:"custom",fn:r,...kc(i)})}function A6r(t){const r=S6r(i=>(i.addIssue=a=>{if(typeof a=="string")i.issues.push(cZ(a,i.value,r._zod.def));else{const l=a;l.fatal&&(l.continue=!1),l.code??(l.code="custom"),l.input??(l.input=i.value),l.inst??(l.inst=r),l.continue??(l.continue=!r._zod.def.abort),i.issues.push(cZ(l))}},t(i.value,i)));return r}function S6r(t,r){const i=new LA({check:"custom",...kc(r)});return i._zod.check=t,i}function lhe(t){let r=t?.target??"draft-2020-12";return r==="draft-4"&&(r="draft-04"),r==="draft-7"&&(r="draft-07"),{processors:t.processors??{},metadataRegistry:t?.metadata??qY,target:r,unrepresentable:t?.unrepresentable??"throw",override:t?.override??(()=>{}),io:t?.io??"output",counter:0,seen:new Map,cycles:t?.cycles??"ref",reused:t?.reused??"inline",external:t?.external??void 0}}function J_(t,r,i={path:[],schemaPath:[]}){var a;const l=t._zod.def,d=r.seen.get(t);if(d)return d.count++,i.schemaPath.includes(t)&&(d.cycle=i.path),d.schema;const _={schema:{},count:1,cycle:void 0,path:i.path};r.seen.set(t,_);const g=t._zod.toJSONSchema?.();if(g)_.schema=g;else{const k={...i,schemaPath:[...i.schemaPath,t],path:i.path};if(t._zod.processJSONSchema)t._zod.processJSONSchema(r,_.schema,k);else{const N=_.schema,P=r.processors[l.type];if(!P)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${l.type}`);P(t,r,N,k)}const w=t._zod.parent;w&&(_.ref||(_.ref=w),J_(w,r,k),r.seen.get(w).isParent=!0)}const b=r.metadataRegistry.get(t);return b&&Object.assign(_.schema,b),r.io==="input"&&mb(t)&&(delete _.schema.examples,delete _.schema.default),r.io==="input"&&_.schema._prefault&&((a=_.schema).default??(a.default=_.schema._prefault)),delete _.schema._prefault,r.seen.get(t).schema}function uhe(t,r){const i=t.seen.get(r);if(!i)throw new Error("Unprocessed schema. This is a bug in Zod.");const a=new Map;for(const _ of t.seen.entries()){const g=t.metadataRegistry.get(_[0])?.id;if(g){const b=a.get(g);if(b&&b!==_[0])throw new Error(`Duplicate schema id "${g}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);a.set(g,_[0])}}const l=_=>{const g=t.target==="draft-2020-12"?"$defs":"definitions";if(t.external){const w=t.external.registry.get(_[0])?.id,N=t.external.uri??(j=>j);if(w)return{ref:N(w)};const P=_[1].defId??_[1].schema.id??`schema${t.counter++}`;return _[1].defId=P,{defId:P,ref:`${N("__shared")}#/${g}/${P}`}}if(_[1]===i)return{ref:"#"};const S=`#/${g}/`,k=_[1].schema.id??`__schema${t.counter++}`;return{defId:k,ref:S+k}},d=_=>{if(_[1].schema.$ref)return;const g=_[1],{ref:b,defId:S}=l(_);g.def={...g.schema},S&&(g.defId=S);const k=g.schema;for(const w in k)delete k[w];k.$ref=b};if(t.cycles==="throw")for(const _ of t.seen.entries()){const g=_[1];if(g.cycle)throw new Error(`Cycle detected: #/${g.cycle?.join("/")}/<root>
|
|
43
43
|
|
|
44
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const _ of t.seen.entries()){const g=_[1];if(r===_[0]){d(_);continue}if(t.external){const S=t.external.registry.get(_[0])?.id;if(r!==_[0]&&S){d(_);continue}}if(t.metadataRegistry.get(_[0])?.id){d(_);continue}if(g.cycle){d(_);continue}if(g.count>1&&t.reused==="ref"){d(_);continue}}}function fhe(t,r){const i=t.seen.get(r);if(!i)throw new Error("Unprocessed schema. This is a bug in Zod.");const a=_=>{const g=t.seen.get(_);if(g.ref===null)return;const b=g.def??g.schema,S={...b},k=g.ref;if(g.ref=null,k){a(k);const N=t.seen.get(k),P=N.schema;if(P.$ref&&(t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0")?(b.allOf=b.allOf??[],b.allOf.push(P)):Object.assign(b,P),Object.assign(b,S),_._zod.parent===k)for(const J in b)J==="$ref"||J==="allOf"||J in S||delete b[J];if(P.$ref&&N.def)for(const J in b)J==="$ref"||J==="allOf"||J in N.def&&JSON.stringify(b[J])===JSON.stringify(N.def[J])&&delete b[J]}const w=_._zod.parent;if(w&&w!==k){a(w);const N=t.seen.get(w);if(N?.schema.$ref&&(b.$ref=N.schema.$ref,N.def))for(const P in b)P==="$ref"||P==="allOf"||P in N.def&&JSON.stringify(b[P])===JSON.stringify(N.def[P])&&delete b[P]}t.override({zodSchema:_,jsonSchema:b,path:g.path??[]})};for(const _ of[...t.seen.entries()].reverse())a(_[0]);const l={};if(t.target==="draft-2020-12"?l.$schema="https://json-schema.org/draft/2020-12/schema":t.target==="draft-07"?l.$schema="http://json-schema.org/draft-07/schema#":t.target==="draft-04"?l.$schema="http://json-schema.org/draft-04/schema#":t.target,t.external?.uri){const _=t.external.registry.get(r)?.id;if(!_)throw new Error("Schema is missing an `id` property");l.$id=t.external.uri(_)}Object.assign(l,i.def??i.schema);const d=t.external?.defs??{};for(const _ of t.seen.entries()){const g=_[1];g.def&&g.defId&&(d[g.defId]=g.def)}t.external||Object.keys(d).length>0&&(t.target==="draft-2020-12"?l.$defs=d:l.definitions=d);try{const _=JSON.parse(JSON.stringify(l));return Object.defineProperty(_,"~standard",{value:{...r["~standard"],jsonSchema:{input:dhe(r,"input",t.processors),output:dhe(r,"output",t.processors)}},enumerable:!1,writable:!1}),_}catch{throw new Error("Error converting schema to JSON.")}}function mb(t,r){const i=r??{seen:new Set};if(i.seen.has(t))return!1;i.seen.add(t);const a=t._zod.def;if(a.type==="transform")return!0;if(a.type==="array")return mb(a.element,i);if(a.type==="set")return mb(a.valueType,i);if(a.type==="lazy")return mb(a.getter(),i);if(a.type==="promise"||a.type==="optional"||a.type==="nonoptional"||a.type==="nullable"||a.type==="readonly"||a.type==="default"||a.type==="prefault")return mb(a.innerType,i);if(a.type==="intersection")return mb(a.left,i)||mb(a.right,i);if(a.type==="record"||a.type==="map")return mb(a.keyType,i)||mb(a.valueType,i);if(a.type==="pipe")return mb(a.in,i)||mb(a.out,i);if(a.type==="object"){for(const l in a.shape)if(mb(a.shape[l],i))return!0;return!1}if(a.type==="union"){for(const l of a.options)if(mb(l,i))return!0;return!1}if(a.type==="tuple"){for(const l of a.items)if(mb(l,i))return!0;return!!(a.rest&&mb(a.rest,i))}return!1}const x6r=(t,r={})=>i=>{const a=lhe({...i,processors:r});return J_(t,a),uhe(a,t),fhe(a,t)},dhe=(t,r,i={})=>a=>{const{libraryOptions:l,target:d}=a??{},_=lhe({...l??{},target:d,io:r,processors:i});return J_(t,_),uhe(_,t),fhe(_,t)},w6r={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},GIt=(t,r,i,a)=>{const l=i;l.type="string";const{minimum:d,maximum:_,format:g,patterns:b,contentEncoding:S}=t._zod.bag;if(typeof d=="number"&&(l.minLength=d),typeof _=="number"&&(l.maxLength=_),g&&(l.format=w6r[g]??g,l.format===""&&delete l.format,g==="time"&&delete l.format),S&&(l.contentEncoding=S),b&&b.size>0){const k=[...b];k.length===1?l.pattern=k[0].source:k.length>1&&(l.allOf=[...k.map(w=>({...r.target==="draft-07"||r.target==="draft-04"||r.target==="openapi-3.0"?{type:"string"}:{},pattern:w.source}))])}},QIt=(t,r,i,a)=>{const l=i,{minimum:d,maximum:_,format:g,multipleOf:b,exclusiveMaximum:S,exclusiveMinimum:k}=t._zod.bag;typeof g=="string"&&g.includes("int")?l.type="integer":l.type="number",typeof k=="number"&&(r.target==="draft-04"||r.target==="openapi-3.0"?(l.minimum=k,l.exclusiveMinimum=!0):l.exclusiveMinimum=k),typeof d=="number"&&(l.minimum=d,typeof k=="number"&&r.target!=="draft-04"&&(k>=d?delete l.minimum:delete l.exclusiveMinimum)),typeof S=="number"&&(r.target==="draft-04"||r.target==="openapi-3.0"?(l.maximum=S,l.exclusiveMaximum=!0):l.exclusiveMaximum=S),typeof _=="number"&&(l.maximum=_,typeof S=="number"&&r.target!=="draft-04"&&(S<=_?delete l.maximum:delete l.exclusiveMaximum)),typeof b=="number"&&(l.multipleOf=b)},KIt=(t,r,i,a)=>{i.type="boolean"},C6r=(t,r,i,a)=>{if(r.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema")},E6r=(t,r,i,a)=>{if(r.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema")},T6r=(t,r,i,a)=>{r.target==="openapi-3.0"?(i.type="string",i.nullable=!0,i.enum=[null]):i.type="null"},k6r=(t,r,i,a)=>{if(r.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema")},I6r=(t,r,i,a)=>{if(r.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema")},YIt=(t,r,i,a)=>{i.not={}},D6r=(t,r,i,a)=>{},XIt=(t,r,i,a)=>{},P6r=(t,r,i,a)=>{if(r.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema")},ZIt=(t,r,i,a)=>{const l=t._zod.def,d=TIt(l.entries);d.every(_=>typeof _=="number")&&(i.type="number"),d.every(_=>typeof _=="string")&&(i.type="string"),i.enum=d},eDt=(t,r,i,a)=>{const l=t._zod.def,d=[];for(const _ of l.values)if(_===void 0){if(r.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof _=="bigint"){if(r.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");d.push(Number(_))}else d.push(_);if(d.length!==0)if(d.length===1){const _=d[0];i.type=_===null?"null":typeof _,r.target==="draft-04"||r.target==="openapi-3.0"?i.enum=[_]:i.const=_}else d.every(_=>typeof _=="number")&&(i.type="number"),d.every(_=>typeof _=="string")&&(i.type="string"),d.every(_=>typeof _=="boolean")&&(i.type="boolean"),d.every(_=>_===null)&&(i.type="null"),i.enum=d},N6r=(t,r,i,a)=>{if(r.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema")},O6r=(t,r,i,a)=>{const l=i,d=t._zod.pattern;if(!d)throw new Error("Pattern not found in template literal");l.type="string",l.pattern=d.source},F6r=(t,r,i,a)=>{const l=i,d={type:"string",format:"binary",contentEncoding:"binary"},{minimum:_,maximum:g,mime:b}=t._zod.bag;_!==void 0&&(d.minLength=_),g!==void 0&&(d.maxLength=g),b?b.length===1?(d.contentMediaType=b[0],Object.assign(l,d)):(Object.assign(l,d),l.anyOf=b.map(S=>({contentMediaType:S}))):Object.assign(l,d)},R6r=(t,r,i,a)=>{i.type="boolean"},tDt=(t,r,i,a)=>{if(r.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},M6r=(t,r,i,a)=>{if(r.unrepresentable==="throw")throw new Error("Function types cannot be represented in JSON Schema")},rDt=(t,r,i,a)=>{if(r.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},L6r=(t,r,i,a)=>{if(r.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema")},j6r=(t,r,i,a)=>{if(r.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema")},nDt=(t,r,i,a)=>{const l=i,d=t._zod.def,{minimum:_,maximum:g}=t._zod.bag;typeof _=="number"&&(l.minItems=_),typeof g=="number"&&(l.maxItems=g),l.type="array",l.items=J_(d.element,r,{...a,path:[...a.path,"items"]})},iDt=(t,r,i,a)=>{const l=i,d=t._zod.def;l.type="object",l.properties={};const _=d.shape;for(const S in _)l.properties[S]=J_(_[S],r,{...a,path:[...a.path,"properties",S]});const g=new Set(Object.keys(_)),b=new Set([...g].filter(S=>{const k=d.shape[S]._zod;return r.io==="input"?k.optin===void 0:k.optout===void 0}));b.size>0&&(l.required=Array.from(b)),d.catchall?._zod.def.type==="never"?l.additionalProperties=!1:d.catchall?d.catchall&&(l.additionalProperties=J_(d.catchall,r,{...a,path:[...a.path,"additionalProperties"]})):r.io==="output"&&(l.additionalProperties=!1)},sDt=(t,r,i,a)=>{const l=t._zod.def,d=l.inclusive===!1,_=l.options.map((g,b)=>J_(g,r,{...a,path:[...a.path,d?"oneOf":"anyOf",b]}));d?i.oneOf=_:i.anyOf=_},oDt=(t,r,i,a)=>{const l=t._zod.def,d=J_(l.left,r,{...a,path:[...a.path,"allOf",0]}),_=J_(l.right,r,{...a,path:[...a.path,"allOf",1]}),g=S=>"allOf"in S&&Object.keys(S).length===1,b=[...g(d)?d.allOf:[d],...g(_)?_.allOf:[_]];i.allOf=b},aDt=(t,r,i,a)=>{const l=i,d=t._zod.def;l.type="array";const _=r.target==="draft-2020-12"?"prefixItems":"items",g=r.target==="draft-2020-12"||r.target==="openapi-3.0"?"items":"additionalItems",b=d.items.map((N,P)=>J_(N,r,{...a,path:[...a.path,_,P]})),S=d.rest?J_(d.rest,r,{...a,path:[...a.path,g,...r.target==="openapi-3.0"?[d.items.length]:[]]}):null;r.target==="draft-2020-12"?(l.prefixItems=b,S&&(l.items=S)):r.target==="openapi-3.0"?(l.items={anyOf:b},S&&l.items.anyOf.push(S),l.minItems=b.length,S||(l.maxItems=b.length)):(l.items=b,S&&(l.additionalItems=S));const{minimum:k,maximum:w}=t._zod.bag;typeof k=="number"&&(l.minItems=k),typeof w=="number"&&(l.maxItems=w)},cDt=(t,r,i,a)=>{const l=i,d=t._zod.def;l.type="object";const _=d.keyType,b=_._zod.bag?.patterns;if(d.mode==="loose"&&b&&b.size>0){const k=J_(d.valueType,r,{...a,path:[...a.path,"patternProperties","*"]});l.patternProperties={};for(const w of b)l.patternProperties[w.source]=k}else(r.target==="draft-07"||r.target==="draft-2020-12")&&(l.propertyNames=J_(d.keyType,r,{...a,path:[...a.path,"propertyNames"]})),l.additionalProperties=J_(d.valueType,r,{...a,path:[...a.path,"additionalProperties"]});const S=_._zod.values;if(S){const k=[...S].filter(w=>typeof w=="string"||typeof w=="number");k.length>0&&(l.required=k)}},lDt=(t,r,i,a)=>{const l=t._zod.def,d=J_(l.innerType,r,a),_=r.seen.get(t);r.target==="openapi-3.0"?(_.ref=l.innerType,i.nullable=!0):i.anyOf=[d,{type:"null"}]},uDt=(t,r,i,a)=>{const l=t._zod.def;J_(l.innerType,r,a);const d=r.seen.get(t);d.ref=l.innerType},fDt=(t,r,i,a)=>{const l=t._zod.def;J_(l.innerType,r,a);const d=r.seen.get(t);d.ref=l.innerType,i.default=JSON.parse(JSON.stringify(l.defaultValue))},dDt=(t,r,i,a)=>{const l=t._zod.def;J_(l.innerType,r,a);const d=r.seen.get(t);d.ref=l.innerType,r.io==="input"&&(i._prefault=JSON.parse(JSON.stringify(l.defaultValue)))},pDt=(t,r,i,a)=>{const l=t._zod.def;J_(l.innerType,r,a);const d=r.seen.get(t);d.ref=l.innerType;let _;try{_=l.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}i.default=_},_Dt=(t,r,i,a)=>{const l=t._zod.def,d=r.io==="input"?l.in._zod.def.type==="transform"?l.out:l.in:l.out;J_(d,r,a);const _=r.seen.get(t);_.ref=d},mDt=(t,r,i,a)=>{const l=t._zod.def;J_(l.innerType,r,a);const d=r.seen.get(t);d.ref=l.innerType,i.readOnly=!0},B6r=(t,r,i,a)=>{const l=t._zod.def;J_(l.innerType,r,a);const d=r.seen.get(t);d.ref=l.innerType},fze=(t,r,i,a)=>{const l=t._zod.def;J_(l.innerType,r,a);const d=r.seen.get(t);d.ref=l.innerType},hDt=(t,r,i,a)=>{const l=t._zod.innerType;J_(l,r,a);const d=r.seen.get(t);d.ref=l},Sbt={string:GIt,number:QIt,boolean:KIt,bigint:C6r,symbol:E6r,null:T6r,undefined:k6r,void:I6r,never:YIt,any:D6r,unknown:XIt,date:P6r,enum:ZIt,literal:eDt,nan:N6r,template_literal:O6r,file:F6r,success:R6r,custom:tDt,function:M6r,transform:rDt,map:L6r,set:j6r,array:nDt,object:iDt,union:sDt,intersection:oDt,tuple:aDt,record:cDt,nullable:lDt,nonoptional:uDt,default:fDt,prefault:dDt,catch:pDt,pipe:_Dt,readonly:mDt,promise:B6r,optional:fze,lazy:hDt};function $6r(t,r){if("_idmap"in t){const a=t,l=lhe({...r,processors:Sbt}),d={};for(const b of a._idmap.entries()){const[S,k]=b;J_(k,l)}const _={},g={registry:a,uri:r?.uri,defs:d};l.external=g;for(const b of a._idmap.entries()){const[S,k]=b;uhe(l,k),_[S]=fhe(l,k)}if(Object.keys(d).length>0){const b=l.target==="draft-2020-12"?"$defs":"definitions";_.__shared={[b]:d}}return{schemas:_}}const i=lhe({...r,processors:Sbt});return J_(t,i),uhe(i,t),fhe(i,t)}const q6r=ys("ZodISODateTime",(t,r)=>{VPr.init(t,r),gh.init(t,r)});function z6r(t){return X4r(q6r,t)}const U6r=ys("ZodISODate",(t,r)=>{JPr.init(t,r),gh.init(t,r)});function V6r(t){return Z4r(U6r,t)}const J6r=ys("ZodISOTime",(t,r)=>{WPr.init(t,r),gh.init(t,r)});function W6r(t){return e6r(J6r,t)}const H6r=ys("ZodISODuration",(t,r)=>{HPr.init(t,r),gh.init(t,r)});function G6r(t){return t6r(H6r,t)}const Q6r=(t,r)=>{PIt.init(t,r),t.name="ZodError",Object.defineProperties(t,{format:{value:i=>L3r(t,i)},flatten:{value:i=>M3r(t,i)},addIssue:{value:i=>{t.issues.push(i),t.message=JSON.stringify(t.issues,P9e,2)}},addIssues:{value:i=>{t.issues.push(...i),t.message=JSON.stringify(t.issues,P9e,2)}},isEmpty:{get(){return t.issues.length===0}}})},Dw=ys("ZodError",Q6r,{Parent:Error}),K6r=cze(Dw),Y6r=lze(Dw),X6r=Hye(Dw),Z6r=Gye(Dw),eNr=$3r(Dw),tNr=q3r(Dw),rNr=z3r(Dw),nNr=U3r(Dw),iNr=V3r(Dw),sNr=J3r(Dw),oNr=W3r(Dw),aNr=H3r(Dw),Cm=ys("ZodType",(t,r)=>(H_.init(t,r),Object.assign(t["~standard"],{jsonSchema:{input:dhe(t,"input"),output:dhe(t,"output")}}),t.toJSONSchema=x6r(t,{}),t.def=r,t.type=r.type,Object.defineProperty(t,"_def",{value:r}),t.check=(...i)=>t.clone(Q8(r,{checks:[...r.checks??[],...i.map(a=>typeof a=="function"?{_zod:{check:a,def:{check:"custom"},onattach:[]}}:a)]}),{parent:!0}),t.with=t.check,t.clone=(i,a)=>K8(t,i,a),t.brand=()=>t,t.register=((i,a)=>(i.add(t,a),t)),t.parse=(i,a)=>K6r(t,i,a,{callee:t.parse}),t.safeParse=(i,a)=>X6r(t,i,a),t.parseAsync=async(i,a)=>Y6r(t,i,a,{callee:t.parseAsync}),t.safeParseAsync=async(i,a)=>Z6r(t,i,a),t.spa=t.safeParseAsync,t.encode=(i,a)=>eNr(t,i,a),t.decode=(i,a)=>tNr(t,i,a),t.encodeAsync=async(i,a)=>rNr(t,i,a),t.decodeAsync=async(i,a)=>nNr(t,i,a),t.safeEncode=(i,a)=>iNr(t,i,a),t.safeDecode=(i,a)=>sNr(t,i,a),t.safeEncodeAsync=async(i,a)=>oNr(t,i,a),t.safeDecodeAsync=async(i,a)=>aNr(t,i,a),t.refine=(i,a)=>t.check(e8r(i,a)),t.superRefine=i=>t.check(t8r(i)),t.overwrite=i=>t.check(tU(i)),t.optional=()=>Tbt(t),t.exactOptional=()=>qNr(t),t.nullable=()=>kbt(t),t.nullish=()=>Tbt(kbt(t)),t.nonoptional=i=>HNr(t,i),t.array=()=>o_(t),t.or=i=>Aee([t,i]),t.and=i=>bDt(t,i),t.transform=i=>F9e(t,ADt(i)),t.default=i=>VNr(t,i),t.prefault=i=>WNr(t,i),t.catch=i=>QNr(t,i),t.pipe=i=>F9e(t,i),t.readonly=()=>XNr(t),t.describe=i=>{const a=t.clone();return qY.add(a,{description:i}),a},Object.defineProperty(t,"description",{get(){return qY.get(t)?.description},configurable:!0}),t.meta=(...i)=>{if(i.length===0)return qY.get(t);const a=t.clone();return qY.add(a,i[0]),a},t.isOptional=()=>t.safeParse(void 0).success,t.isNullable=()=>t.safeParse(null).success,t.apply=i=>i(t),t)),gDt=ys("_ZodString",(t,r)=>{uze.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(a,l,d)=>GIt(t,a,l);const i=t._zod.bag;t.format=i.format??null,t.minLength=i.minimum??null,t.maxLength=i.maximum??null,t.regex=(...a)=>t.check(a6r(...a)),t.includes=(...a)=>t.check(u6r(...a)),t.startsWith=(...a)=>t.check(f6r(...a)),t.endsWith=(...a)=>t.check(d6r(...a)),t.min=(...a)=>t.check(che(...a)),t.max=(...a)=>t.check(WIt(...a)),t.length=(...a)=>t.check(HIt(...a)),t.nonempty=(...a)=>t.check(che(1,...a)),t.lowercase=a=>t.check(c6r(a)),t.uppercase=a=>t.check(l6r(a)),t.trim=()=>t.check(_6r()),t.normalize=(...a)=>t.check(p6r(...a)),t.toLowerCase=()=>t.check(m6r()),t.toUpperCase=()=>t.check(h6r()),t.slugify=()=>t.check(g6r())}),cNr=ys("ZodString",(t,r)=>{uze.init(t,r),gDt.init(t,r),t.email=i=>t.check(P4r(lNr,i)),t.url=i=>t.check(M4r(uNr,i)),t.jwt=i=>t.check(Y4r(CNr,i)),t.emoji=i=>t.check(L4r(fNr,i)),t.guid=i=>t.check(ybt(xbt,i)),t.uuid=i=>t.check(N4r(Dpe,i)),t.uuidv4=i=>t.check(O4r(Dpe,i)),t.uuidv6=i=>t.check(F4r(Dpe,i)),t.uuidv7=i=>t.check(R4r(Dpe,i)),t.nanoid=i=>t.check(j4r(dNr,i)),t.guid=i=>t.check(ybt(xbt,i)),t.cuid=i=>t.check(B4r(pNr,i)),t.cuid2=i=>t.check($4r(_Nr,i)),t.ulid=i=>t.check(q4r(mNr,i)),t.base64=i=>t.check(G4r(SNr,i)),t.base64url=i=>t.check(Q4r(xNr,i)),t.xid=i=>t.check(z4r(hNr,i)),t.ksuid=i=>t.check(U4r(gNr,i)),t.ipv4=i=>t.check(V4r(yNr,i)),t.ipv6=i=>t.check(J4r(vNr,i)),t.cidrv4=i=>t.check(W4r(bNr,i)),t.cidrv6=i=>t.check(H4r(ANr,i)),t.e164=i=>t.check(K4r(wNr,i)),t.datetime=i=>t.check(z6r(i)),t.date=i=>t.check(V6r(i)),t.time=i=>t.check(W6r(i)),t.duration=i=>t.check(G6r(i))});function Ss(t){return D4r(cNr,t)}const gh=ys("ZodStringFormat",(t,r)=>{jm.init(t,r),gDt.init(t,r)}),lNr=ys("ZodEmail",(t,r)=>{RPr.init(t,r),gh.init(t,r)}),xbt=ys("ZodGUID",(t,r)=>{OPr.init(t,r),gh.init(t,r)}),Dpe=ys("ZodUUID",(t,r)=>{FPr.init(t,r),gh.init(t,r)}),uNr=ys("ZodURL",(t,r)=>{MPr.init(t,r),gh.init(t,r)}),fNr=ys("ZodEmoji",(t,r)=>{LPr.init(t,r),gh.init(t,r)}),dNr=ys("ZodNanoID",(t,r)=>{jPr.init(t,r),gh.init(t,r)}),pNr=ys("ZodCUID",(t,r)=>{BPr.init(t,r),gh.init(t,r)}),_Nr=ys("ZodCUID2",(t,r)=>{$Pr.init(t,r),gh.init(t,r)}),mNr=ys("ZodULID",(t,r)=>{qPr.init(t,r),gh.init(t,r)}),hNr=ys("ZodXID",(t,r)=>{zPr.init(t,r),gh.init(t,r)}),gNr=ys("ZodKSUID",(t,r)=>{UPr.init(t,r),gh.init(t,r)}),yNr=ys("ZodIPv4",(t,r)=>{GPr.init(t,r),gh.init(t,r)}),vNr=ys("ZodIPv6",(t,r)=>{QPr.init(t,r),gh.init(t,r)}),bNr=ys("ZodCIDRv4",(t,r)=>{KPr.init(t,r),gh.init(t,r)}),ANr=ys("ZodCIDRv6",(t,r)=>{YPr.init(t,r),gh.init(t,r)}),SNr=ys("ZodBase64",(t,r)=>{XPr.init(t,r),gh.init(t,r)}),xNr=ys("ZodBase64URL",(t,r)=>{e4r.init(t,r),gh.init(t,r)}),wNr=ys("ZodE164",(t,r)=>{t4r.init(t,r),gh.init(t,r)}),CNr=ys("ZodJWT",(t,r)=>{n4r.init(t,r),gh.init(t,r)}),yDt=ys("ZodNumber",(t,r)=>{qIt.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(a,l,d)=>QIt(t,a,l),t.gt=(a,l)=>t.check(bbt(a,l)),t.gte=(a,l)=>t.check(xFe(a,l)),t.min=(a,l)=>t.check(xFe(a,l)),t.lt=(a,l)=>t.check(vbt(a,l)),t.lte=(a,l)=>t.check(SFe(a,l)),t.max=(a,l)=>t.check(SFe(a,l)),t.int=a=>t.check(wbt(a)),t.safe=a=>t.check(wbt(a)),t.positive=a=>t.check(bbt(0,a)),t.nonnegative=a=>t.check(xFe(0,a)),t.negative=a=>t.check(vbt(0,a)),t.nonpositive=a=>t.check(SFe(0,a)),t.multipleOf=(a,l)=>t.check(Abt(a,l)),t.step=(a,l)=>t.check(Abt(a,l)),t.finite=()=>t;const i=t._zod.bag;t.minValue=Math.max(i.minimum??Number.NEGATIVE_INFINITY,i.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,t.maxValue=Math.min(i.maximum??Number.POSITIVE_INFINITY,i.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,t.isInt=(i.format??"").includes("int")||Number.isSafeInteger(i.multipleOf??.5),t.isFinite=!0,t.format=i.format??null});function Tu(t){return r6r(yDt,t)}const ENr=ys("ZodNumberFormat",(t,r)=>{i4r.init(t,r),yDt.init(t,r)});function wbt(t){return n6r(ENr,t)}const TNr=ys("ZodBoolean",(t,r)=>{s4r.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(i,a,l)=>KIt(t,i,a)});function gv(t){return i6r(TNr,t)}const kNr=ys("ZodUnknown",(t,r)=>{o4r.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(i,a,l)=>XIt()});function Cbt(){return s6r(kNr)}const INr=ys("ZodNever",(t,r)=>{a4r.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(i,a,l)=>YIt(t,i,a)});function DNr(t){return o6r(INr,t)}const PNr=ys("ZodArray",(t,r)=>{c4r.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(i,a,l)=>nDt(t,i,a,l),t.element=r.element,t.min=(i,a)=>t.check(che(i,a)),t.nonempty=i=>t.check(che(1,i)),t.max=(i,a)=>t.check(WIt(i,a)),t.length=(i,a)=>t.check(HIt(i,a)),t.unwrap=()=>t.element});function o_(t,r){return y6r(PNr,t,r)}const NNr=ys("ZodObject",(t,r)=>{u4r.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(i,a,l)=>iDt(t,i,a,l),Vf(t,"shape",()=>r.shape),t.keyof=()=>jd(Object.keys(t._zod.def.shape)),t.catchall=i=>t.clone({...t._zod.def,catchall:i}),t.passthrough=()=>t.clone({...t._zod.def,catchall:Cbt()}),t.loose=()=>t.clone({...t._zod.def,catchall:Cbt()}),t.strict=()=>t.clone({...t._zod.def,catchall:DNr()}),t.strip=()=>t.clone({...t._zod.def,catchall:void 0}),t.extend=i=>P3r(t,i),t.safeExtend=i=>N3r(t,i),t.merge=i=>O3r(t,i),t.pick=i=>I3r(t,i),t.omit=i=>D3r(t,i),t.partial=(...i)=>F3r(SDt,t,i[0]),t.required=(...i)=>R3r(xDt,t,i[0])});function Na(t,r){const i={type:"object",shape:t??{},...kc(r)};return new NNr(i)}const vDt=ys("ZodUnion",(t,r)=>{VIt.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(i,a,l)=>sDt(t,i,a,l),t.options=r.options});function Aee(t,r){return new vDt({type:"union",options:t,...kc(r)})}const ONr=ys("ZodDiscriminatedUnion",(t,r)=>{vDt.init(t,r),f4r.init(t,r)});function FNr(t,r,i){return new ONr({type:"union",options:r,discriminator:t,...kc(i)})}const RNr=ys("ZodIntersection",(t,r)=>{d4r.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(i,a,l)=>oDt(t,i,a,l)});function bDt(t,r){return new RNr({type:"intersection",left:t,right:r})}const MNr=ys("ZodTuple",(t,r)=>{p4r.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(i,a,l)=>aDt(t,i,a,l),t.rest=i=>t.clone({...t._zod.def,rest:i})});function Ebt(t,r,i){const a=r instanceof H_,l=a?i:r,d=a?r:null;return new MNr({type:"tuple",items:t,rest:d,...kc(l)})}const LNr=ys("ZodRecord",(t,r)=>{_4r.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(i,a,l)=>cDt(t,i,a,l),t.keyType=r.keyType,t.valueType=r.valueType});function UR(t,r,i){return new LNr({type:"record",keyType:t,valueType:r,...kc(i)})}const O9e=ys("ZodEnum",(t,r)=>{m4r.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(a,l,d)=>ZIt(t,a,l),t.enum=r.entries,t.options=Object.values(r.entries);const i=new Set(Object.keys(r.entries));t.extract=(a,l)=>{const d={};for(const _ of a)if(i.has(_))d[_]=r.entries[_];else throw new Error(`Key ${_} not found in enum`);return new O9e({...r,checks:[],...kc(l),entries:d})},t.exclude=(a,l)=>{const d={...r.entries};for(const _ of a)if(i.has(_))delete d[_];else throw new Error(`Key ${_} not found in enum`);return new O9e({...r,checks:[],...kc(l),entries:d})}});function jd(t,r){const i=Array.isArray(t)?Object.fromEntries(t.map(a=>[a,a])):t;return new O9e({type:"enum",entries:i,...kc(r)})}const jNr=ys("ZodLiteral",(t,r)=>{h4r.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(i,a,l)=>eDt(t,i,a),t.values=new Set(r.values),Object.defineProperty(t,"value",{get(){if(r.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return r.values[0]}})});function Ry(t,r){return new jNr({type:"literal",values:Array.isArray(t)?t:[t],...kc(r)})}const BNr=ys("ZodTransform",(t,r)=>{g4r.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(i,a,l)=>rDt(t,i),t._zod.parse=(i,a)=>{if(a.direction==="backward")throw new CIt(t.constructor.name);i.addIssue=d=>{if(typeof d=="string")i.issues.push(cZ(d,i.value,r));else{const _=d;_.fatal&&(_.continue=!1),_.code??(_.code="custom"),_.input??(_.input=i.value),_.inst??(_.inst=t),i.issues.push(cZ(_))}};const l=r.transform(i.value,i);return l instanceof Promise?l.then(d=>(i.value=d,i)):(i.value=l,i)}});function ADt(t){return new BNr({type:"transform",transform:t})}const SDt=ys("ZodOptional",(t,r)=>{JIt.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(i,a,l)=>fze(t,i,a,l),t.unwrap=()=>t._zod.def.innerType});function Tbt(t){return new SDt({type:"optional",innerType:t})}const $Nr=ys("ZodExactOptional",(t,r)=>{y4r.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(i,a,l)=>fze(t,i,a,l),t.unwrap=()=>t._zod.def.innerType});function qNr(t){return new $Nr({type:"optional",innerType:t})}const zNr=ys("ZodNullable",(t,r)=>{v4r.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(i,a,l)=>lDt(t,i,a,l),t.unwrap=()=>t._zod.def.innerType});function kbt(t){return new zNr({type:"nullable",innerType:t})}const UNr=ys("ZodDefault",(t,r)=>{b4r.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(i,a,l)=>fDt(t,i,a,l),t.unwrap=()=>t._zod.def.innerType,t.removeDefault=t.unwrap});function VNr(t,r){return new UNr({type:"default",innerType:t,get defaultValue(){return typeof r=="function"?r():IIt(r)}})}const JNr=ys("ZodPrefault",(t,r)=>{A4r.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(i,a,l)=>dDt(t,i,a,l),t.unwrap=()=>t._zod.def.innerType});function WNr(t,r){return new JNr({type:"prefault",innerType:t,get defaultValue(){return typeof r=="function"?r():IIt(r)}})}const xDt=ys("ZodNonOptional",(t,r)=>{S4r.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(i,a,l)=>uDt(t,i,a,l),t.unwrap=()=>t._zod.def.innerType});function HNr(t,r){return new xDt({type:"nonoptional",innerType:t,...kc(r)})}const GNr=ys("ZodCatch",(t,r)=>{x4r.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(i,a,l)=>pDt(t,i,a,l),t.unwrap=()=>t._zod.def.innerType,t.removeCatch=t.unwrap});function QNr(t,r){return new GNr({type:"catch",innerType:t,catchValue:typeof r=="function"?r:()=>r})}const KNr=ys("ZodPipe",(t,r)=>{w4r.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(i,a,l)=>_Dt(t,i,a,l),t.in=r.in,t.out=r.out});function F9e(t,r){return new KNr({type:"pipe",in:t,out:r})}const YNr=ys("ZodReadonly",(t,r)=>{C4r.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(i,a,l)=>mDt(t,i,a,l),t.unwrap=()=>t._zod.def.innerType});function XNr(t){return new YNr({type:"readonly",innerType:t})}const ZNr=ys("ZodLazy",(t,r)=>{E4r.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(i,a,l)=>hDt(t,i,a,l),t.unwrap=()=>t._zod.def.getter()});function hDn(t){return new ZNr({type:"lazy",getter:t})}const dze=ys("ZodCustom",(t,r)=>{T4r.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(i,a,l)=>tDt(t,i)});function IR(t,r){return v6r(dze,t??(()=>!0),r)}function e8r(t,r={}){return b6r(dze,t,r)}function t8r(t){return A6r(t)}function gDn(t,r={}){const i=new dze({type:"custom",check:"custom",fn:a=>a instanceof t,abort:!0,...kc(r)});return i._zod.bag.Class=t,i._zod.check=a=>{a.value instanceof t||a.issues.push({code:"invalid_type",expected:t.name,input:a.value,inst:i,path:[...i._zod.def.path??[]]})},i}function r8r(t,r){return F9e(ADt(t),r)}const Ibt={custom:"custom"},Dbt=jd(["mock","live"]),n8r=Na({id:Ss().min(1),name:Ss().min(1),status:jd(["free","trialing","active","past_due","cancelling"]),interval:jd(["month","year"]).optional(),renewsAt:Ss().datetime().optional(),endsAt:Ss().datetime().optional()}),i8r=Na({included:Tu().nonnegative(),purchased:Tu().nonnegative(),used:Tu().nonnegative(),reserved:Tu().nonnegative(),remaining:Tu().nonnegative(),resetsAt:Ss().datetime().optional(),purchasedExpiresAt:Ss().datetime().optional()}),s8r=Na({overageEnabled:gv(),monthlyLimitCredits:Tu().nonnegative(),alertThresholds:o_(Tu().min(1).max(100)).max(8),autoReload:Na({enabled:gv(),whenRemainingBelow:Tu().nonnegative(),reloadTo:Tu().positive(),monthlyLimitCredits:Tu().nonnegative()}).optional()}),o8r=Na({id:Ss().min(1),kind:jd(["threshold","auto_reload_succeeded","auto_reload_failed"]),message:Ss().min(1),createdAt:Ss().datetime(),readAt:Ss().datetime().optional()}),a8r=Na({id:Ss().min(1),email:Ss().email(),name:Ss().min(1).optional()}),c8r=Na({name:Ss().min(1),verified:gv(),enrollmentMode:jd(["manual_invitation","automatic_invitation","automatic_suggestion","enterprise_sso"])}),l8r=Na({id:Ss().min(1),name:Ss().min(1),slug:Ss().min(1).optional(),role:Ss().min(1),domains:o_(c8r).max(50)}),u8r=Na({id:Ss().min(1),occurredAt:Ss().datetime(),kind:jd(["inference","generation","workspace","storage","relay","deployment"]),provider:Ss().min(1),operation:Ss().optional(),credits:Tu().nonnegative(),state:jd(["reserved","settled","released"]),externalId:Ss().optional()});jd(["free","creator","max","ultra"]);const f8r=Na({plans:Na({free:Na({name:Ss().min(1),includedCredits:Tu().int().nonnegative(),monthlyPriceUsd:Tu().nonnegative().optional()}),creator:Na({name:Ss().min(1),includedCredits:Tu().int().nonnegative(),monthlyPriceUsd:Tu().nonnegative().optional()}),max:Na({name:Ss().min(1),includedCredits:Tu().int().nonnegative(),monthlyPriceUsd:Tu().nonnegative().optional()}),ultra:Na({name:Ss().min(1),includedCredits:Tu().int().nonnegative(),monthlyPriceUsd:Tu().nonnegative().optional()})}),creditPacks:UR(Ss().min(1),Na({name:Ss().min(1),credits:Tu().int().positive(),expiresInDays:Tu().int().positive().optional()}))}),d8r=FNr("authenticated",[Na({authenticated:Ry(!1),backend:Dbt}),Na({authenticated:Ry(!0),backend:Dbt,user:a8r,organizations:o_(l8r).max(100).optional(),plan:n8r,credits:i8r,spendPolicy:s8r,alerts:o_(o8r).max(100).optional(),entitlements:Na({generation:gv(),dailyJobs:Tu().int().positive().optional()})})]),p8r=jd(["auto","mock","managed","byok"]),wDt=jd(["fal","tripo","worldlabs","openrouter"]),_8r=Na({enabled:gv(),provider:Ry("openrouter"),model:Ss().trim().min(1).max(256)}),m8r=jd(["environment","system","session","none"]),h8r=Na({provider:wDt,label:Ss().min(1),environmentVariable:Ss().min(1),configured:gv(),source:m8r,editable:gv(),persistence:jd(["system","session"]),maskedKey:Ss().min(1).optional(),problem:Ss().min(1).optional()}),g8r=Na({provider:wDt,ok:Ry(!0),testedAt:Ss().datetime()});function y8r(t){return{routes:{mock:!0,managed:t.routes.managed,byok:t.routes.byok,byokProviders:[...t.routes.byokProviders]},preferredRoute:t.preferredRoute}}const Kye=bDt(d8r,Na({accountEnvironment:jd(["test-mock","development-twin","production"]),routes:Na({mock:Ry(!0),managed:gv(),byok:gv(),byokProviders:o_(Ss().min(1))}),preferredRoute:p8r,providerCredentials:o_(h8r),codingInference:_8r}));function v8r(t,r){return`${t}: this origin answered with its page fallback (${r||"no content-type"}) rather than JSON, so no editor server handled the request.`}function np(t,r){const i=t.headers.get("content-type")??"";if(!i.includes("application/json"))throw new Error(v8r(r,i))}function rU(t,r){if(!t.ok)throw new Error(`${r} (${t.status}).`);np(t,r)}async function Eg(t,r){return rU(t,r),await t.json()}const Pbt="vgai.collaboration.participant.v1",b8r="vgai.collaboration.remote-share.v1",R9e=globalThis.__VGAI_EDITOR_PRESENCE_BOOTSTRAP__;function A8r(){if(R9e?.participantId)return R9e.participantId;const t=globalThis.crypto?.randomUUID?.()??`participant-${Date.now()}`;try{const r=globalThis.localStorage?.getItem(Pbt);if(r)return r;globalThis.localStorage?.setItem(Pbt,t)}catch{}return t}const CDt=A8r(),pze=(()=>{try{return globalThis.localStorage?.getItem(b8r)==="1"}catch{return!1}})(),S8r=R9e?.displayName||"Local editor";let M9e=0;function EDt(t){Number.isInteger(t)&&t>=M9e&&(M9e=t)}function yw(){return{participantId:CDt,expectedRevision:M9e}}const x8r={authenticated:!1,backend:"mock",accountEnvironment:"test-mock",routes:{mock:!0,managed:!1,byok:!1,byokProviders:[]},preferredRoute:"auto",providerCredentials:[],codingInference:{enabled:!1,provider:"openrouter",model:"z-ai/glm-5.2"}};let iz=x8r,TDt=0,L9e=null;const j9e=new Set;function VR(t,r=null){if(!(L9e===r&&JSON.stringify(iz)===JSON.stringify(t))){iz=t,L9e=r,TDt++;for(const i of j9e)i()}}async function kDt(t,r){np(t,r);const i=await t.json();if(!t.ok)throw new Error(typeof i.error=="string"?String(i.error):`Account request failed (${t.status}).`);return Kye.parse(i)}async function IE(t,r,i){const a=await fetch(t,{method:r,...i===void 0?{}:{headers:{"Content-Type":"application/json"},body:JSON.stringify(i)}}),l=await kDt(a,`${r} ${t} failed`);return VR(l),l}function _ze(){return iz}function mze(){return y8r(iz)}function T8(){return TDt}function Ppe(){return L9e}function Yye(t){return j9e.add(t),()=>j9e.delete(t)}async function Nbt(){try{const t=await kDt(await fetch("/__editor/account"),"Account read failed");return VR(t),t}catch(t){throw VR(iz,t instanceof Error?t.message:String(t)),t}}const w8r=t=>IE("/__editor/account/mock-session","POST",{email:t}),C8r=t=>IE("/__editor/account/twin-session","POST",{email:t}),E8r=()=>IE("/__editor/account/session","DELETE"),T8r=t=>IE("/__editor/account/spend-policy","PUT",t),k8r=()=>IE("/__editor/account/alerts/read","POST"),I8r=t=>IE("/__editor/account/execution-route","PUT",{route:t}),D8r=t=>IE("/__editor/account/coding-inference","PUT",t);async function P8r(t){const r=await fetch("/__editor/account/coding-inference/quote",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});np(r,"Coding quote failed");const i=await r.json();if(!r.ok||typeof i.model!="string"||typeof i.promptTokens!="number"||typeof i.outputTokens!="number"||typeof i.providerAmountUsd!="number"||typeof i.estimatedCredits!="number")throw new Error(typeof i.error=="string"?i.error:"Coding quote failed.");return i}const N8r=(t,r)=>IE(`/__editor/account/provider-credentials/${encodeURIComponent(t)}`,"PUT",{key:r}),O8r=t=>IE(`/__editor/account/provider-credentials/${encodeURIComponent(t)}`,"DELETE");async function F8r(t){const r=await fetch(`/__editor/account/provider-credentials/${encodeURIComponent(t)}/test`,{method:"POST"});np(r,"Credential test failed");const i=await r.json();if(!r.ok)throw new Error(typeof i.error=="string"?i.error:`Credential test failed (${r.status}).`);return g8r.parse(i)}const Obt=t=>IE("/__editor/account/plan","PUT",{action:t});async function IDt(t,r){const i=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json","Idempotency-Key":crypto.randomUUID()},body:JSON.stringify(r)});np(i,"Checkout failed");const a=await i.json();if(!i.ok||!a.account)throw new Error(typeof a.error=="string"?a.error:"Checkout failed.");return VR(Kye.parse(a.account)),{...typeof a.checkoutUrl=="string"?{checkoutUrl:a.checkoutUrl}:{},mock:a.mock===!0}}const R8r=t=>IDt("/__editor/account/checkout",{plan:t}),M8r=t=>IDt("/__editor/account/credits",{packId:t});async function L8r(){const t=await fetch("/__editor/account/usage");np(t,"Usage failed");const r=await t.json();if(!t.ok)throw new Error(typeof r.error=="string"?r.error:"Usage failed.");return u8r.array().parse(r.entries??[])}async function j8r(){const t=await fetch("/__editor/account/catalog");np(t,"Catalog failed");const r=await t.json();if(!t.ok)throw new Error(typeof r.error=="string"?r.error:"Catalog failed.");return f8r.parse(r)}async function B8r(){const t=await fetch("/__editor/account/billing-portal",{method:"POST"});np(t,"Billing portal failed");const r=await t.json();if(!t.ok||typeof r.url!="string")throw new Error(typeof r.error=="string"?r.error:"Billing portal failed.");return{url:r.url,mock:r.mock===!0}}async function $8r(){const t=await fetch("/__editor/account/authorization-methods");np(t,"Sign-in methods are unavailable");const r=await t.json();if(!t.ok||r.browser!==!0||typeof r.device!="boolean")throw new Error(typeof r.error=="string"?r.error:"Sign-in methods are unavailable.");return{browser:!0,device:r.device}}async function q8r(){const t=await fetch("/__editor/account/browser-authorization",{method:"POST"});np(t,"Sign-in failed");const r=await t.json();if(!t.ok)throw new Error(typeof r.error=="string"?r.error:"Sign-in failed.");return r}async function z8r(t){const r=await fetch(`/__editor/account/browser-authorization/${encodeURIComponent(t)}`);np(r,"Sign-in failed");const i=await r.json();if(r.status===202)return!1;if(!r.ok||i.pending!==!1)throw new Error(typeof i.error=="string"?i.error:"Sign-in failed.");return VR(Kye.parse(i.account)),!0}async function U8r(){const t=await fetch("/__editor/account/device-authorization",{method:"POST"});np(t,"Sign-in failed");const r=await t.json();if(!t.ok)throw new Error(typeof r.error=="string"?r.error:"Sign-in failed.");return r}async function V8r(t){const r=await fetch(`/__editor/account/device-authorization/${encodeURIComponent(t)}`);np(r,"Sign-in failed");const i=await r.json();if(r.status===202)return!1;if(!r.ok||i.pending!==!1)throw new Error(typeof i.error=="string"?i.error:"Sign-in failed.");return VR(Kye.parse(i.account)),!0}function J8r(){if(pze)return()=>{};const t=new URLSearchParams(window.location.search).get("checkout_id");t?IE("/__editor/account/checkout/confirm","POST",{checkoutId:t}).then(()=>{const i=new URL(window.location.href);i.searchParams.delete("checkout"),i.searchParams.delete("checkout_id"),window.history.replaceState(null,"",`${i.pathname}${i.search}${i.hash}`)}).catch(i=>VR(iz,i instanceof Error?i.message:String(i))):Nbt().catch(()=>{});const r=window.setInterval(()=>void Nbt().catch(()=>{}),3e4);return()=>window.clearInterval(r)}const W8r={"source-prop":!0,"source-structure":!0,"construction-literal":!0,"physics-binding":!0,"data-record":!0,"live-only":!0},H8r=Object.keys(W8r),G8r={provenance:!0,selection:!0,transforms:!0,inspector:!0,assetSubject:!0,related:!0,instances:!0,structure:!0,persistence:!0,pickable:!0,rects:!0,boxEdit:!0,text:!0,colorSample:!0,stories:!0,truth:!0,spatialHandles:!0,assetDrop:!0,subscribe:!0},Q8r=Object.keys(G8r),phe={claim:0,shape:1,operation:2,effect:3,"round-trip":4};function K8r(t,r){return phe[t]>=phe[r]}function _he(t){const{seam:r,subject:i,epoch:a,required:l}=t;if(t.notApplicable!==void 0)return{seam:r,subject:i,epoch:a,required:l,state:"not-applicable",receipt:null,detail:t.notApplicable};let d=null;for(const _ of t.receipts)_.seam!==r||_.subject!==i||_.epoch!==a||(!d||phe[_.stage]>=phe[d.stage])&&(d=_);return d?d.outcome==="fail"?{seam:r,subject:i,epoch:a,required:l,state:"failed",receipt:d,detail:d.detail}:d.outcome==="absent"?{seam:r,subject:i,epoch:a,required:l,state:"absent",receipt:d,detail:d.detail}:K8r(d.stage,l)?{seam:r,subject:i,epoch:a,required:l,state:"verified",receipt:d,detail:d.detail}:{seam:r,subject:i,epoch:a,required:l,state:"unverified",receipt:d,detail:`${d.detail}; this proves ${d.stage}, but this seam requires ${l}`}:{seam:r,subject:i,epoch:a,required:l,state:"unverified",receipt:null,detail:`no current-epoch evidence has reached the required ${l} stage`}}class Y8r{#e=[];record(r){if(!r.seam||!r.subject||!r.epoch||!r.detail.trim())throw new Error("seam evidence requires non-empty seam, subject, epoch, and detail");this.#e.push(r)}receipts(r){return this.#e.filter(i=>(r?.subject===void 0||i.subject===r.subject)&&(r?.epoch===void 0||i.epoch===r.epoch))}verdict(r){return _he({...r,receipts:this.#e})}clearSubject(r){for(let i=this.#e.length-1;i>=0;i-=1)this.#e[i]?.subject===r&&this.#e.splice(i,1)}clear(){this.#e.length=0}}function jy(){return t=>t}function X8r(t){if(t.value===void 0)return{seam:t.seam,subject:t.subject,epoch:t.epoch,stage:"shape",outcome:t.optional?"absent":"fail",source:"shape-check",detail:t.optional?`${t.seam} is not exposed by this subject`:`${t.seam} is required by the contract but is absent`};const r=typeof t.value,i=t.kind==="function"?r==="function":r!=="function";return{seam:t.seam,subject:t.subject,epoch:t.epoch,stage:"shape",outcome:i?"pass":"fail",source:"shape-check",detail:i?`${t.seam} has the contract's ${t.kind} shape`:`${t.seam} is ${r}; the contract requires a ${t.kind}`}}function wFe(t){const r=[],i=t.value!==null&&(typeof t.value=="object"||typeof t.value=="function")?t.value:null,a=Object.entries(t.shape);for(const[l,d]of a){const _=`${t.prefix}.${l}`,g=i?.[l];r.push(X8r({seam:_,subject:t.subject,epoch:t.epoch,value:g,optional:d.optional,kind:d.kind}))}return r}function Fbt(t){const r=_he(t);if(r.state==="absent"||r.state==="failed"||!t.shape)return r;for(const[i,a]of Object.entries(t.shape)){const l=_he({seam:`${t.seam}.${i}`,subject:t.subject,epoch:t.epoch,required:a.required,receipts:t.receipts});if(!(a.optional&&l.state==="absent")){if(l.state==="failed"||l.state==="absent")return{...r,state:"failed",receipt:l.receipt,detail:`${t.seam} is malformed: ${l.detail}`};if(l.state!=="verified")return{...r,state:"unverified",detail:`${t.seam} has the required shape, but ${l.seam} is unverified: ${l.detail}`}}}return r}const Npe=jy()({capabilities:{optional:!1,kind:"value",required:"shape"},provenance:{optional:!0,kind:"value",required:"shape"},hierarchy:{optional:!1,kind:"value",required:"operation"},selection:{optional:!0,kind:"value",required:"effect"},transforms:{optional:!0,kind:"value",required:"effect"},inspector:{optional:!0,kind:"value",required:"effect"},assetSubject:{optional:!0,kind:"value",required:"operation"},related:{optional:!0,kind:"value",required:"operation"},instances:{optional:!0,kind:"value",required:"effect"},structure:{optional:!0,kind:"value",required:"round-trip"},persistence:{optional:!0,kind:"value",required:"round-trip"},pickable:{optional:!0,kind:"value",required:"operation"},rects:{optional:!0,kind:"value",required:"operation"},boxEdit:{optional:!0,kind:"value",required:"effect"},text:{optional:!0,kind:"value",required:"effect"},colorSample:{optional:!0,kind:"value",required:"operation"},stories:{optional:!0,kind:"value",required:"effect"},truth:{optional:!0,kind:"value",required:"operation"},spatialHandles:{optional:!0,kind:"value",required:"effect"},assetDrop:{optional:!0,kind:"value",required:"round-trip"},subscribe:{optional:!0,kind:"function",required:"effect"}}),Rbt=jy()({roots:{optional:!1,kind:"function",required:"operation"},node:{optional:!1,kind:"function",required:"operation"},crossSurfaceStructureSignature:{optional:!0,kind:"function",required:"operation"},object3D:{optional:!0,kind:"function",required:"operation"},idForObject3D:{optional:!0,kind:"function",required:"operation"}}),Z8r=jy()({get:{optional:!1,kind:"function",required:"operation"},set:{optional:!1,kind:"function",required:"effect"},resolve:{optional:!0,kind:"function",required:"operation"}}),eOr=jy()({dimensions:{optional:!0,kind:"function",required:"operation"},get:{optional:!1,kind:"function",required:"operation"},editability:{optional:!0,kind:"function",required:"operation"},beginEdit:{optional:!1,kind:"function",required:"effect"},apply:{optional:!1,kind:"function",required:"effect"},endEdit:{optional:!1,kind:"function",required:"effect"},remove:{optional:!0,kind:"function",required:"round-trip"},sourceCommit:{optional:!0,kind:"value",required:"round-trip"}}),tOr=jy()({properties:{optional:!1,kind:"function",required:"operation"},get:{optional:!1,kind:"function",required:"operation"},set:{optional:!1,kind:"function",required:"effect"},preview:{optional:!0,kind:"function",required:"effect"},editability:{optional:!0,kind:"function",required:"operation"},remove:{optional:!0,kind:"function",required:"round-trip"}}),rOr=jy()({get:{optional:!1,kind:"function",required:"operation"},entries:{optional:!0,kind:"function",required:"operation"}}),nOr=jy()({links:{optional:!1,kind:"function",required:"operation"}}),iOr=jy()({describe:{optional:!1,kind:"function",required:"operation"},openComponent:{optional:!0,kind:"function",required:"effect"},revert:{optional:!1,kind:"function",required:"round-trip"},applyToComponent:{optional:!1,kind:"function",required:"round-trip"}}),sOr=jy()({create:{optional:!1,kind:"function",required:"round-trip"},remove:{optional:!1,kind:"function",required:"round-trip"},duplicate:{optional:!1,kind:"function",required:"round-trip"},duplicateMany:{optional:!0,kind:"function",required:"round-trip"},reparent:{optional:!1,kind:"function",required:"round-trip"},reorder:{optional:!0,kind:"function",required:"round-trip"},creatableKinds:{optional:!0,kind:"function",required:"operation"},wrap:{optional:!0,kind:"function",required:"round-trip"},unwrap:{optional:!0,kind:"function",required:"round-trip"},group:{optional:!0,kind:"function",required:"round-trip"},ungroup:{optional:!0,kind:"function",required:"round-trip"},canUngroup:{optional:!0,kind:"function",required:"operation"},removeMany:{optional:!0,kind:"function",required:"round-trip"},copy:{optional:!0,kind:"function",required:"effect"},canCopy:{optional:!0,kind:"function",required:"operation"},cut:{optional:!0,kind:"function",required:"round-trip"},paste:{optional:!0,kind:"function",required:"round-trip"},canPaste:{optional:!0,kind:"function",required:"operation"}}),oOr=jy()({isDirty:{optional:!1,kind:"function",required:"operation"},lastError:{optional:!0,kind:"function",required:"operation"},save:{optional:!1,kind:"function",required:"round-trip"},destination:{optional:!1,kind:"value",required:"shape"},applyExternal:{optional:!0,kind:"function",required:"effect"}}),aOr=jy()({pick:{optional:!1,kind:"function",required:"operation"},candidates:{optional:!0,kind:"function",required:"operation"}}),cOr=jy()({storiesFor:{optional:!1,kind:"function",required:"operation"},active:{optional:!1,kind:"function",required:"operation"},apply:{optional:!1,kind:"function",required:"effect"},isolate:{optional:!0,kind:"function",required:"effect"},title:{optional:!0,kind:"value",required:"shape"},unavailable:{optional:!0,kind:"function",required:"operation"}}),lOr=jy()({accepts:{optional:!1,kind:"function",required:"operation"},drop:{optional:!1,kind:"function",required:"round-trip"}}),uOr=jy()({rect:{optional:!1,kind:"function",required:"operation"},contextRects:{optional:!0,kind:"function",required:"operation"},emptyContainers:{optional:!0,kind:"function",required:"operation"}}),fOr=jy()({begin:{optional:!1,kind:"function",required:"effect"},apply:{optional:!1,kind:"function",required:"effect"},end:{optional:!1,kind:"function",required:"effect"},gizmoOrigin:{optional:!0,kind:"function",required:"operation"},referencePoint:{optional:!0,kind:"function",required:"operation"}}),dOr=jy()({get:{optional:!1,kind:"function",required:"operation"},set:{optional:!1,kind:"function",required:"effect"}}),pOr=jy()({backgroundChainAt:{optional:!1,kind:"function",required:"operation"}}),_Or=jy()({resolve:{optional:!1,kind:"function",required:"operation"}}),mOr=jy()({layers:{optional:!1,kind:"function",required:"operation"},preview:{optional:!1,kind:"function",required:"effect"},commit:{optional:!1,kind:"function",required:"round-trip"}}),Mbt={selection:Z8r,transforms:eOr,inspector:tOr,assetSubject:rOr,related:nOr,instances:iOr,structure:sOr,persistence:oOr,pickable:aOr,rects:uOr,boxEdit:fOr,text:dOr,colorSample:pOr,stories:cOr,truth:_Or,spatialHandles:mOr,assetDrop:lOr},DDt=new Y8r;function hOr(t){DDt.record(t)}const Lbt=new WeakMap;let gOr=1;function yOr(t){const r=Lbt.get(t);if(r)return r;const i=`system-${gOr++}`;return Lbt.set(t,i),i}let p9={},hze=null,PDt=null;const mhe=new Set,hhe=new Set,B9e=new Set;let gze=0;function vOr(){for(const t of B9e)t()}function bOr(t){if(t!==FDt())for(const r of mhe)r()}function AOr(t,r){const i=MDt();if(!(t===RDt()&&r.length===i.length&&r.every((a,l)=>a===i[l]))){gze++;for(const a of hhe)a()}}const cI=new Map;let j_e=null;const $9e=new Set,NDt="";function lZ(){return j_e!==null&&cI.has(j_e)?j_e:cI.keys().next().value??null}function ODt(){for(const t of $9e)t()}function SOr(t){const r=lZ();if(j_e=t,r!==lZ()){ODt(),gze++;for(const i of mhe)i();for(const i of hhe)i()}}function xOr(t){return $9e.add(t),()=>$9e.delete(t)}function yze(){const t=lZ();return(t===null?void 0:cI.get(t))??p9}function wOr(t,r=NDt){const i=lZ(),a=FDt(),l=RDt(),d=MDt();cI.delete(r),p9=cI.values().next().value??{},bOr(a),AOr(l,d),vOr(),i!==lZ()&&ODt()}function COr(){for(const t of[...cI.keys()])wOr(null,t);SOr(null)}function EOr(t){return B9e.add(t),()=>B9e.delete(t)}function TOr(){return[...cI.keys()]}function jbt(t){const r=t.filter(l=>l!==NDt),i=t.length>r.length,a=r.map(l=>`"${l}"`);return i&&a.push("the unnamed default (address it with no id at all)"),a.join(", ")}class Bbt extends Error{instances;constructor(r,i){super(r),this.name="InstanceResolutionError",this.instances=i}}function kOr(t){const r=TOr();if(t!==void 0){const i=cI.get(t);if(i)return i;throw new Bbt(r.length===0?`no instance "${t}" — no game is mounted`:`no instance "${t}" — live: ${jbt(r)}`,r)}if(r.length===1)return cI.get(r[0]);if(r.length===0)return p9;throw new Bbt(`${r.length} instances are live (${jbt(r)}) — name one in your program (\`game.instance(id)\`, or \`await game.instances()\` for handles); refusing to guess`,r)}function IOr(){return p9.camera??null}function FDt(){return p9.networking??PDt??null}function DOr(){return yze().networking??PDt??null}function POr(t){return mhe.add(t),()=>mhe.delete(t)}function RDt(){return p9.audio??hze}function NOr(){return yze().audio??hze}function OOr(t){return hhe.add(t),()=>hhe.delete(t)}function FOr(){return gze}function MDt(){const t=new Set;for(const r of cI.values())r.audio&&t.add(r.audio);return t.size,[...t]}function ROr(){return p9.renderDebug??null}const $bt=new Set;function Xye(){return null}function Zye(t){$bt.add(t);const r=xOr(t);return()=>{$bt.delete(t),r()}}function k8(){const t=Xye();return t?`play:${t.instanceId}`:"stopped"}const bX=new Map,K$=new Map,B_e=new Map;let LDt=0;const q9e=new Set;function qbt(){LDt++;for(const t of q9e)t()}function yDn(t){return bX.set(t.documentId,t),qbt(),()=>{bX.get(t.documentId)===t&&(bX.delete(t.documentId),qbt())}}function Pw(t){return bX.get(t)??null}function vDn(t,r){return B_e.set(t,r),()=>{B_e.get(t)===r&&B_e.delete(t)}}async function MOr(t){await B_e.get(t)?.()}function LOr(t){K$.set(t,(K$.get(t)??0)+1);let r=!1;return()=>{if(r)return;r=!0;const i=(K$.get(t)??0)-1;i>0?K$.set(t,i):K$.delete(t)}}function jOr(t){return(K$.get(t)??0)>0}function BOr(){return[...bX.values()]}function e0e(t){return q9e.add(t),()=>q9e.delete(t)}function I8(){return LDt}function t0e(t,r){let i=!1,a=[];const l=()=>{i=!1;const _=a;a=[];for(let g=_.length-1;g>=0;g--)_[g]()};return{ensure(_){if(!i){i=!0;try{_(g=>a.push(g))}catch(g){throw l(),g}}},reset:l}}let W7=[],$Or=0,jDt=0;const z9e=new Set;function zbt(){jDt++;for(const t of z9e)t()}function BDt(t){return z9e.add(t),()=>{z9e.delete(t)}}function Ubt(){return jDt}function iP(t){if(W7.some(i=>i.contribution.id===t.id))throw new Error(`registerWorkspaceStatus: id "${t.id}" is already registered — status ids key status-bar slots, so they must be unique; unregister the previous contribution first.`);const r={contribution:t,seq:$Or++};return W7=[...W7,r],zbt(),()=>{W7.includes(r)&&(W7=W7.filter(i=>i!==r),zbt())}}function U9e(t){const r=i=>[...W7].filter(a=>(a.contribution.align??"left")===i).sort((a,l)=>(a.contribution.order??0)-(l.contribution.order??0)||a.seq-l.seq).map(a=>a.contribution);return t?r(t):[...r("left"),...r("right")]}let $_e=null,$Dt=0;const V9e=new Set;function Vbt(){$Dt++;for(const t of V9e)t()}function qDt(t){return V9e.add(t),()=>V9e.delete(t)}function J9e(){return $Dt}function vze(){return $_e}function qOr(t){const r=Symbol(t.documentId);return $_e={...t,token:r},Vbt(),()=>{$_e?.token===r&&($_e=null,Vbt())}}function zOr(){Xe.useSyncExternalStore(qDt,J9e);const t=vze();return t?.status?z.jsx("span",{className:"vgai-status-copy","data-testid":"status-asset-editor","data-status-tone":"muted",children:t.status}):null}const UOr=t0e();function VOr(){UOr.ensure(t=>{t(iP({id:"asset-editor-status",name:"Asset editor",align:"left",order:40,Content:zOr}))})}VOr();let Dq=null,zDt=0;const W9e=new Set;function Jbt(){zDt+=1;for(const t of W9e)t()}function JOr(t){return W9e.add(t),()=>{W9e.delete(t)}}function Wbt(){return zDt}function WOr(t,r){const i=Symbol(t);return Dq={documentId:t,readSubject:r,token:i},Jbt(),()=>{Dq?.token===i&&(Dq=null,Jbt())}}function H9e(){return Dq===null?null:{documentId:Dq.documentId,subject:Dq.readSubject()}}const D8=new Map,G9e=new Map;function UDt(){typeof window>"u"||window.parent===window||D8.size===0||window.parent.postMessage({type:"vgai:viewport-ready",documents:[...D8.keys()]},"*")}typeof window<"u"&&window.parent!==window&&window.addEventListener("message",t=>{t.source===window.parent&&t.data?.type==="vgai:request-viewport-ready"&&UDt()});let Wu=null,bze=null;function VDt(){if(typeof window>"u")return!1;const t=window.__VGAI_VIEWPORT_TIMINGS__;if(t===!0||t==="1")return!0;try{return new URLSearchParams(window.location.search).get("vgaiTimings")==="1"}catch{return!1}}function HOr(t,r,i){return{documentId:t,visibilityState:typeof document>"u"?"unavailable":document.visibilityState,startedAtMs:r,reactActiveAtMs:null,boardBuildStartedAtMs:null,boardReadyAtMs:null,constructStartedAtMs:null,viewportReadyAtMs:null,rafResumeAtMs:null,firstRenderStartedAtMs:null,workspaceSyncMs:0,revealScheduleMs:0,componentIndexMs:0,componentIndexBusyMs:0,componentIndexWaitMs:0,candidateCollectMs:0,storyMountTotalMs:0,boundsMs:0,layoutMs:0,assembleMs:0,webglContextMs:0,rendererMs:0,adapterSetupMs:0,iblBakeMs:0,dressingMs:0,editorViewportMs:0,framingMs:0,resizeBindMs:0,viewportBindMs:0,firstRenderMs:0,candidateCount:0,exhibitCount:0,skippedCount:0,modulesAlreadyLoaded:i.modulesAlreadyLoaded===!0,stories:[]}}function GOr(t){let r=0,i=0;for(const a of t)r+=Math.max(0,a.runtimeMs)+Math.max(0,a.fiberMs),i+=Math.max(0,a.loadMs)+Math.max(0,a.settleMs);return{busyMs:r,waitMs:i}}function QOr(t,r){const i=t.reactActiveAtMs===null?0:Math.max(0,t.reactActiveAtMs-t.startedAtMs),a=t.reactActiveAtMs??t.startedAtMs,l=t.boardBuildStartedAtMs,d=l===null?0:Math.max(0,l-a),_=t.boardReadyAtMs===null||t.constructStartedAtMs===null?0:Math.max(0,t.constructStartedAtMs-t.boardReadyAtMs),g=t.viewportReadyAtMs??t.rafResumeAtMs,b=t.firstRenderStartedAtMs??r,S=g===null?0:Math.max(0,b-g),k=g===null?Math.max(0,r-t.startedAtMs):Math.max(0,r-g),w=GOr(t.stories),N=t.boardBuildStartedAtMs===null?"switch-back":"first-open",j=KOr({workspaceSyncMs:i,revealScheduleMs:d,componentIndexMs:t.componentIndexMs,componentIndexBusyMs:t.componentIndexBusyMs,componentIndexWaitMs:t.componentIndexWaitMs,candidateCollectMs:t.candidateCollectMs,storyMountTotalMs:t.storyMountTotalMs,storyMountBusyMs:w.busyMs,storyMountWaitMs:w.waitMs,boundsMs:t.boundsMs,layoutMs:t.layoutMs,assembleMs:t.assembleMs,reactCommitMs:_,webglContextMs:t.webglContextMs,rendererMs:t.rendererMs,adapterSetupMs:t.adapterSetupMs,iblBakeMs:t.iblBakeMs,dressingMs:t.dressingMs,editorViewportMs:t.editorViewportMs,framingMs:t.framingMs,resizeBindMs:t.resizeBindMs,viewportBindMs:t.viewportBindMs,rafWaitMs:S,firstRenderMs:t.firstRenderMs}).reduce((X,G)=>X+G.ms,0),J=Math.max(0,r-t.startedAtMs);return{visibilityState:t.visibilityState,startedAtMs:t.startedAtMs,reactActiveAtMs:t.reactActiveAtMs,boardBuildStartedAtMs:t.boardBuildStartedAtMs,boardReadyAtMs:t.boardReadyAtMs,constructStartedAtMs:t.constructStartedAtMs,viewportReadyAtMs:t.viewportReadyAtMs,rafResumeAtMs:t.rafResumeAtMs,firstRenderStartedAtMs:t.firstRenderStartedAtMs,firstFrameAtMs:r,activationKind:N,workspaceSyncMs:i,revealScheduleMs:d,componentIndexMs:t.componentIndexMs,candidateCollectMs:t.candidateCollectMs,storyMountTotalMs:t.storyMountTotalMs,storyMountBusyMs:w.busyMs,storyMountWaitMs:w.waitMs,boundsMs:t.boundsMs,layoutMs:t.layoutMs,assembleMs:t.assembleMs,reactCommitMs:_,webglContextMs:t.webglContextMs,rendererMs:t.rendererMs,adapterSetupMs:t.adapterSetupMs,iblBakeMs:t.iblBakeMs,dressingMs:t.dressingMs,editorViewportMs:t.editorViewportMs,framingMs:t.framingMs,resizeBindMs:t.resizeBindMs,viewportBindMs:t.viewportBindMs,rafWaitMs:S,firstRenderMs:t.firstRenderMs,firstPaintMs:k,unattributedMs:Math.max(0,J-j),accountedMs:j,candidateCount:t.candidateCount,exhibitCount:t.exhibitCount,skippedCount:t.skippedCount,modulesAlreadyLoaded:t.modulesAlreadyLoaded,stories:t.stories,storyDiscovery:bze}}function TA(t,r){const i=Math.max(0,r);return{name:t,ms:i,busyMs:i,waitMs:0,kind:"cpu"}}function Ope(t,r){const i=Math.max(0,r);return{name:t,ms:i,busyMs:0,waitMs:i,kind:"idle"}}function Hbt(t,r,i,a){const l=Math.max(0,r);let d=Math.max(0,i),_=Math.max(0,a);if(d+_>l){const g=l/(d+_);d*=g,_*=g}else d+_<l&&(_+=l-d-_);return{name:t,ms:l,busyMs:d,waitMs:_,kind:"mixed"}}function KOr(t){return[Ope("workspace-sync",t.workspaceSyncMs),Ope("reveal-schedule",t.revealScheduleMs),Hbt("component-index",t.componentIndexMs,t.componentIndexBusyMs,t.componentIndexWaitMs>0||t.componentIndexMs===0?t.componentIndexWaitMs:t.componentIndexMs),TA("candidate-collect",t.candidateCollectMs),Hbt("story-mounts",t.storyMountTotalMs,t.storyMountBusyMs,t.storyMountWaitMs),TA("bounds",t.boundsMs),TA("layout",t.layoutMs),TA("assemble",t.assembleMs),Ope("react-commit (board→viewport)",t.reactCommitMs),TA("webgl-context",t.webglContextMs),TA("renderer",t.rendererMs),TA("adapter-setup",t.adapterSetupMs),TA("ibl-bake (three PMREM)",t.iblBakeMs),TA("dressing",t.dressingMs),TA("editor-viewport",t.editorViewportMs),TA("framing",t.framingMs),TA("resize-bind",t.resizeBindMs),TA("viewport-bind",t.viewportBindMs),Ope("raf-wait",t.rafWaitMs),TA("first-render",t.firstRenderMs)]}function bDn(t,r=Date.now()){const i=(G9e.get(t)??0)+1;G9e.set(t,i);const a={documentId:t,activation:i,firstFrameAtMs:r},l=Wu;if(l&&l.documentId===t){const d={...a,breakdown:QOr(l,r)};return Wu=null,D8.set(t,d),Qbt(),Gbt(),d}return D8.set(t,a),Qbt(),Gbt(),a}let Q9e=new Set;const K9e=new Set;function Gbt(){UDt();for(const t of K9e)t()}function YOr(t){return K9e.add(t),()=>K9e.delete(t)}function Qbt(){D8.size!==0&&JDt()}function JDt(){const t=Q9e;Q9e=new Set;for(const r of t)r()}let Kbt=!1;function XOr(){Kbt||typeof document>"u"||(Kbt=!0,document.addEventListener("visibilitychange",()=>{document.hidden&&JDt()}))}function r0e(){return D8.size>0||typeof document<"u"&&document.hidden?Promise.resolve():(XOr(),new Promise(t=>Q9e.add(t)))}function ZOr(){return[...D8.values()]}function e5r(t){VDt()&&(Wu=HOr(t,Date.now(),{}))}function ADn(t,r,i){if(!Wu)return;const a=Math.max(0,r);switch(t){case"component-index":Wu.componentIndexMs=a,Wu.componentIndexBusyMs=Math.max(0,0),Wu.componentIndexWaitMs=Math.max(0,a);break;case"candidate-collect":Wu.candidateCollectMs=a;break;case"story-mounts":Wu.storyMountTotalMs=a;break;case"bounds":Wu.boundsMs=a;break;case"layout":Wu.layoutMs=a;break;case"assemble":Wu.assembleMs=a;break;case"webgl-context":Wu.webglContextMs=a;break;case"renderer":Wu.rendererMs=a;break;case"adapter-setup":Wu.adapterSetupMs=a;break;case"ibl-bake":Wu.iblBakeMs=a;break;case"dressing":Wu.dressingMs=a;break;case"editor-viewport":Wu.editorViewportMs=a;break;case"framing":Wu.framingMs=a;break;case"resize-bind":Wu.resizeBindMs=a;break;case"viewport-bind":Wu.viewportBindMs=a;break;case"first-render":Wu.firstRenderMs=a;break}}function SDn(t){!Wu||Wu.documentId!==t||Wu.reactActiveAtMs===null&&(Wu.reactActiveAtMs=Date.now())}function xDn(t){!Wu||Wu.documentId!==t||Wu.rafResumeAtMs===null&&(Wu.rafResumeAtMs=Date.now())}function wDn(t){!Wu||Wu.documentId!==t||Wu.firstRenderStartedAtMs===null&&(Wu.firstRenderStartedAtMs=Date.now())}function CDn(){Wu&&(Wu.constructStartedAtMs=Date.now())}function EDn(){Wu&&(Wu.viewportReadyAtMs=Date.now())}function TDn(){return Wu?.documentId??null}function t5r(t){VDt()&&(bze=t)}function r5r(){D8.clear(),G9e.clear(),Wu=null,bze=null}const n5r=["scene","game","world","story","asset","behavior","generation","content-browser","project-tool","tool-contribution","document"];let V_=[],KN=null,OA=null,uZ=null,sz=null;function Ybt(t){queueMicrotask(()=>{sz===t&&V_.some(r=>r.descriptor.id===t)&&(sz=null,xb(t))})}let WDt=0;const Y9e=new Set,CFe=new Set,Aze=new Map,DR=new Map;function lI(){WDt++;for(const t of Y9e)t()}function Aw(t){return Y9e.add(t),()=>{Y9e.delete(t)}}function Sb(){return WDt}function FA(){return V_}function I_(){return OA}function X9e(){return uZ}function i5r(t,r){xb(t)&&uZ!==r&&(uZ=r,lI())}function AE(){return V_.find(t=>t.descriptor.id===OA)??null}function fZ(t){if(t===OA)return;t&&e5r(t);const r=V_.find(a=>a.descriptor.id===OA);OA=t,uZ=null,r?.descriptor.onDeactivate?.(r.descriptor.id);const i=V_.find(a=>a.descriptor.id===t);i?.descriptor.onActivate?.(i.descriptor.id)}function s5r(t,r,i,a){if(r){!i&&a&&KN===t&&(KN=null);return}i&&(KN&&Y8(KN),KN=t)}function qP(t,r={}){const i=sz===t.id,a=i||r.activate!==!1,l=V_.find(_=>_.descriptor.id===t.id);if(s5r(t.id,!!l,r.preview===!0,a),!l)return V_=[...V_,{descriptor:t,dirty:!1,title:t.title}],!t.area&&(a||OA===null)&&fZ(t.id),i&&Ybt(t.id),lI(),t.id;let d=!1;return(l.descriptor.Toolbar!==t.Toolbar||l.descriptor.Shelf!==t.Shelf||l.descriptor.Content!==t.Content)&&(V_=V_.map(_=>{if(_!==l)return _;const{Toolbar:g,Shelf:b,...S}=_.descriptor;return{..._,descriptor:{...S,Content:t.Content,...t.Toolbar?{Toolbar:t.Toolbar}:{},...t.Shelf?{Shelf:t.Shelf}:{}}}}),d=!0),a&&OA!==t.id&&(fZ(t.id),d=!0),d&&lI(),i&&Ybt(t.id),t.id}function xb(t){return V_.some(r=>r.descriptor.id===t)?(OA!==t&&(fZ(t),lI()),!0):!1}function o5r(t){if(xb(t)){sz=null;return}sz=t}function Y8(t,r={}){if(CFe.has(t))return!1;const i=V_.findIndex(l=>l.descriptor.id===t);if(i<0)return!1;const a=V_[i];if(a.dirty&&!r.discardDirty)return!1;CFe.add(t);try{if(OA===t){const d=i>0?V_[i-1]:V_[i+1]??null;fZ(d?d.descriptor.id:null)}return V_=V_.filter(d=>d.descriptor.id!==t),KN===t&&(KN=null),Aze.delete(t),DR.delete(t),a.descriptor.onDispose?.(t),lI(),!0}finally{CFe.delete(t)}}function HDt(){if(V_.length===0&&OA===null)return;const t=V_;fZ(null),V_=[],uZ=null,KN=null,Aze.clear(),DR.clear(),sz=null;for(const r of t)r.descriptor.onDispose?.(r.descriptor.id);lI()}function a5r(t,r){return V_.some(i=>i.descriptor.id===t)?(DR.set(t,r),lI(),()=>{DR.get(t)===r&&(DR.delete(t),lI())}):()=>{}}function kDn(t){DR.has(t)&&lI()}async function c5r(t){if(!V_.some(i=>i.descriptor.id===t))return null;const r=Aze.get(t);if(!r)return null;try{return await r()}catch{return!1}}function l5r(){return OA?c5r(OA):Promise.resolve(null)}function GDt(t,r){const i=V_.find(a=>a.descriptor.id===t);!i||i.title===r||(V_=V_.map(a=>a.descriptor.id===t?{...a,title:r}:a),lI())}function Sze(t){const r=V_.find(a=>a.descriptor.id===t),i=DR.get(t)??r?.descriptor.selection;if(!i)return null;try{return i()}catch{return null}}function n0e(){return OA?Sze(OA):null}const u5r={adapter:null,nodeId:null};function f5r(t){return JSON.stringify({id:t.id,title:t.title,hint:t.hint,kindLabel:t.kindLabel,note:t.note,sections:t.sections.map(r=>({id:r.id,title:r.title,order:r.order,description:r.description,defaultOpen:r.defaultOpen,testId:r.testId,keepMounted:r.keepMounted,railGroup:r.railGroup,bodyKind:r.body.kind})),quickActions:t.quickActions?.map(r=>({id:r.id,title:r.title,label:r.label,placement:r.placement,pressed:r.pressed,disabled:r.disabled}))})}function xze({documentId:t,active:r=!0,type:i,title:a,sections:l,status:d,selection:_}){Xe.useEffect(()=>{if(r)return qOr({documentId:t,title:a,type:i,...d?{status:d}:{}})},[r,t,d,a,i]);const g=Xe.useRef(_);g.current=_,Xe.useEffect(()=>{if(r)return a5r(t,()=>g.current?.()??u5r)},[r,t]);const b={id:t,title:a,kindLabel:i,...d?{note:{text:d,testId:"asset-editor-status"}}:{},sections:l??[]},S=Xe.useRef(b);S.current=b;const k=f5r(b);return Xe.useEffect(()=>{if(r)return WOr(t,()=>S.current)},[r,t,k]),null}function d5r({documentId:t,active:r=!0,type:i,title:a,sections:l,status:d,fill:_=!1,selection:g,children:b}){return z.jsxs("section",{className:"vgai-asset-editor","data-testid":`asset-editor:${i}`,"aria-label":`${a} Asset Editor`,children:[z.jsx(xze,{documentId:t,active:r,type:i,title:a,sections:l,status:d,selection:g}),z.jsx("main",{className:`vgai-asset-editor__viewport${_?" vgai-asset-editor__viewport--fill":""}`,children:b})]})}const p5r=Object.freeze(Object.defineProperty({__proto__:null,AssetEditorShell:d5r,AssetEditorSubject:xze},Symbol.toStringTag,{value:"Module"})),_5r=Xe.lazy(async()=>({default:(await Xo(()=>import("./ToolObject3DPreview-CxH5xj1p.js"),__vite__mapDeps([38,1,2,39,3,4,8,9,10,6,40,41,11]))).ToolObject3DPreview})),m5r=Xe.lazy(async()=>({default:(await Xo(()=>import("./StageHost-iPOh6V05.js").then(r=>r.c),__vite__mapDeps([42,1,2,3,4,8,9,6,10,7,40,14,43,41]))).ToolObject3DAuthoring}));function h5r(t){return z.jsx(Xe.Suspense,{fallback:z.jsx("div",{style:{minHeight:240},children:"Loading 3D preview…"}),children:z.jsx(_5r,{...t})})}function g5r(t){return Xe.useEffect(()=>LOr(t.documentId),[t.documentId]),z.jsx(Xe.Suspense,{fallback:z.jsx("div",{style:{minHeight:240},children:"Loading 3D authoring surface…"}),children:z.jsx(m5r,{...t})})}function y5r(t){return z.jsx(xze,{...t})}const wze=Object.freeze({AssetDocument:y5r,Object3DPreview:h5r,Object3DAuthoring:g5r}),Xbt=Object.freeze({id:"classic",shape:{small:"3px",medium:"6px",large:"8px",full:"9999px"},elevation:{small:"0 2px 8px rgba(0,0,0,0.6)",medium:"0 4px 12px rgba(0,0,0,0.5)",large:"0 8px 32px rgba(0,0,0,0.6)"}}),fh=Object.freeze({id:"glass",color:{surface:{shell:"#12161f",panel:"rgba(255,255,255,0.06)",chrome:"rgba(255,255,255,0.10)",raised:"rgba(255,255,255,0.16)",inset:"rgba(10,14,22,0.38)",overlay:"rgba(255,255,255,0.08)"},boundary:{default:"rgba(255,255,255,0.22)",strong:"rgba(255,255,255,0.38)"},neutralOverlay:{hover:"color-mix(in srgb, currentColor 10%, transparent)",active:"color-mix(in srgb, currentColor 16%, transparent)"},scrim:"rgba(8,12,20,0.35)"},shape:{small:"4px",medium:"8px",large:"14px",full:"9999px"},elevation:{small:"0 4px 14px -6px rgba(0,0,0,0.45)",medium:"0 8px 24px -10px rgba(0,0,0,0.5)",large:"0 20px 46px -16px rgba(0,0,0,0.55), 0 4px 14px -6px rgba(0,0,0,0.35)"},treatment:{backdropBlurPx:1,backdropSaturation:1.15,edgeSpecular:.7,specularAngleDeg:120,refractionBezelPx:56,refractionThickness:1.25,textShadowOpacity:.72,contentFrostBlurPx:24,ambientLiftOpacity:.07,adaptiveContent:!0,brightTextShadowOpacity:0,brightFrostBg:"rgba(255,255,255,0.3)"},reducedTransparency:{surface:{shell:"#12161f",panel:"#33373e",chrome:"#3d4047",raised:"#4b4e55",inset:"#23272f",overlay:"#383b43"},scrim:"rgba(8,12,20,0.5)"}}),v5r=["classic","glass"],b5r=Object.freeze([{id:"classic",title:"Classic",description:"Opaque editor surfaces with conventional bars and panels."},{id:"glass",title:"Glass",description:"Adaptive clear material with refraction, frost, and floating chrome."}]),Pq=new Map;let ghe=null;const yhe=new Set;function A5r(){return ghe??=[...b5r,...[...Pq.values()].map(({id:t,title:r,description:i})=>({id:t,title:r,description:i}))],ghe}function S5r(t){return yhe.add(t),()=>yhe.delete(t)}function x5r(t){if(i0e(t.id))throw new Error(`registerContributedMaterial: material "${t.id}" is already registered.`);Pq.set(t.id,t),ghe=null;for(const r of yhe)r();return()=>{if(Pq.get(t.id)===t){Pq.delete(t.id),ghe=null;for(const r of yhe)r()}}}function i0e(t){return typeof t=="string"&&(v5r.includes(t)||Pq.has(t))}function w5r(t,r,i=!1){if(r!=="glass"){const l=Pq.get(r);return{id:l?`${t.id}--${l.id}`:t.id,color:t.color,typography:t.typography,shape:l?.shape??Xbt.shape,elevation:l?.elevation??Xbt.elevation,...l?.density?{density:l.density}:{},appearance:{material:"classic",transparency:"standard"}}}return{id:`${t.id}--${i?"glass-reduced":"glass"}`,color:{surface:i?fh.reducedTransparency.surface:fh.color.surface,boundary:fh.color.boundary,content:t.color.content,accent:t.color.accent,semantic:t.color.semantic,neutralOverlay:fh.color.neutralOverlay,scrim:i?fh.reducedTransparency.scrim:fh.color.scrim},typography:t.typography,shape:fh.shape,elevation:fh.elevation,appearance:{material:"glass",transparency:i?"reduced":"standard"},...i?{}:{treatment:fh.treatment}}}const C5r={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch",baseline:"baseline"},E5r={start:"flex-start",center:"center",end:"flex-end",between:"space-between",around:"space-around",evenly:"space-evenly"};function Fpe(t){return t===0?"0px":t===void 0?void 0:`var(--vgai-space-${t})`}function QDt({gap:t,align:r,justify:i,padding:a,paddingX:l,paddingY:d,style:_}){return{gap:Fpe(t),alignItems:r?C5r[r]:void 0,justifyContent:i?E5r[i]:void 0,padding:Fpe(a),paddingInline:Fpe(l),paddingBlock:Fpe(d),..._}}function s0e(t,r){return r?`${t} ${r}`:t}function o0e({className:t,...r}){return z.jsx("div",{...r,className:s0e("vgai-stack",t),style:QDt(r)})}function Nq({className:t,...r}){return z.jsx("div",{...r,className:s0e("vgai-inline",t),style:QDt(r)})}function T5r({orientation:t="horizontal",className:r,...i}){return z.jsx("div",{...i,"aria-hidden":"true","data-orientation":t,className:s0e("vgai-divider",r)})}function k5r({children:t,className:r,...i}){return z.jsx(Nq,{...i,className:s0e("vgai-actions",r),gap:2,align:"center",children:t})}function KDt(t,r){return r?`${t} ${r}`:t}const Ru=Xe.forwardRef(function({as:r="span",variant:i="body",tone:a="primary",truncate:l=!1,selectable:d=!1,className:_,...g},b){const S=r;return z.jsx(S,{...g,ref:b,"data-variant":i,"data-tone":a,"data-truncate":l||void 0,"data-selectable":d||void 0,className:KDt("vgai-text",_)})});function q_e({className:t,...r}){return z.jsx("kbd",{...r,className:KDt("vgai-keycap",t)})}function Cze(t,r){return r?`${t} ${r}`:t}function Z9e({labelledBy:t,onDismiss:r,size:i="default",variant:a="default",className:l,...d}){const[_]=Xe.useState(()=>typeof document>"u"?null:document.querySelector(".vgai-editor-theme")),g=z.jsx("div",{className:"vgai-dialog-scrim","data-variant":a,onPointerDown:b=>{b.target===b.currentTarget&&r?.()},children:z.jsx("div",{...d,role:"dialog","aria-modal":"true","aria-labelledby":t,"data-size":i,"data-variant":a,className:Cze("vgai-dialog",l)})});return _?vS.createPortal(g,_):g}function eMe({titleId:t,title:r,description:i}){return z.jsxs(o0e,{className:"vgai-dialog-header",gap:2,children:[z.jsx(Ru,{id:t,as:"h2",variant:"heading",children:r}),i&&z.jsx(Ru,{as:"p",tone:"muted",children:i})]})}function YDt({className:t,...r}){return z.jsx(o0e,{...r,className:Cze("vgai-dialog-body",t)})}function tMe({children:t,className:r,...i}){return z.jsx(k5r,{...i,className:Cze("vgai-dialog-footer",r),children:t})}function XDt(t,r){return r?`${t} ${r}`:t}function I5r({className:t,...r}){return z.jsx("div",{...r,className:XDt("vgai-field-group",t)})}function z_e({label:t,htmlFor:r,hint:i,compact:a=!1,className:l,children:d,..._}){return z.jsxs("div",{..._,"data-compact":a||void 0,className:XDt("vgai-field-row",l),children:[z.jsx("label",{htmlFor:r,className:"vgai-field-label",children:t}),z.jsx("div",{className:"vgai-field-control",children:d}),i&&z.jsx("div",{className:"vgai-field-hint",children:i})]})}Xe.forwardRef(function({selected:r=!1,accent:i="bar",className:a,type:l="button",...d},_){return z.jsx("button",{...d,ref:_,type:l,"data-selected":r||void 0,"data-accent":i,className:a?`vgai-list-button ${a}`:"vgai-list-button"})});function D5r({tone:t="neutral",icon:r,title:i,description:a,action:l,compact:d=!1,className:_,...g}){const b=t==="error"?"alert":t==="loading"||t==="success"?"status":void 0;return z.jsxs("div",{...g,role:g.role??b,"data-tone":t,"data-compact":d||void 0,className:_?`vgai-state-surface ${_}`:"vgai-state-surface",children:[r&&z.jsx("div",{className:"vgai-state-surface-icon",children:r}),z.jsx("strong",{className:"vgai-state-surface-title",children:i}),a&&z.jsx("div",{className:"vgai-state-surface-description",children:a}),l&&z.jsx("div",{className:"vgai-state-surface-action",children:l})]})}function a0e(t,r){return r?`${t} ${r}`:t}function P5r({variant:t="panel",border:r=!1,scroll:i=!1,className:a,...l}){return z.jsx("div",{...l,"data-variant":t,"data-border":r||void 0,"data-scroll":i||void 0,className:a0e("vgai-surface",a)})}function N5r({tone:t="info",icon:r,actions:i,className:a,children:l,...d}){return z.jsxs("div",{...d,role:t==="error"?"alert":"status","data-tone":t,className:a0e("vgai-banner",a),children:[r&&z.jsx("span",{className:"vgai-banner-icon",children:r}),z.jsx("div",{className:"vgai-banner-content",children:l}),i&&z.jsx("div",{className:"vgai-banner-actions",children:i})]})}const Eze=Xe.forwardRef(function({className:r,...i},a){return z.jsx("div",{ref:a,...i,className:a0e("vgai-popover",r)})});function Zbt({position:t="inside",className:r,...i}){return z.jsx("div",{...i,"aria-hidden":"true","data-position":t,className:a0e("vgai-drop-indicator",r)})}function ZDt(t,r){return r?`${t} ${r}`:t}Xe.forwardRef(function({className:r,onKeyDown:i,...a},l){return z.jsx("div",{...a,ref:l,role:"tablist",className:ZDt("vgai-tabs",r),onKeyDown:d=>{if(i?.(d),d.defaultPrevented||!["ArrowLeft","ArrowRight","Home","End"].includes(d.key))return;const _=Array.from(d.currentTarget.querySelectorAll('[role="tab"]:not(:disabled)'));if(_.length===0)return;d.preventDefault();const g=_.indexOf(document.activeElement);(d.key==="Home"?_[0]:d.key==="End"?_.at(-1):d.key==="ArrowRight"?_[(g+1+_.length)%_.length]:_[(g-1+_.length)%_.length])?.focus()}})});Xe.forwardRef(function({selected:r=!1,dirty:i=!1,badge:a,className:l,type:d="button",tabIndex:_,children:g,...b},S){return z.jsxs("button",{...b,ref:S,type:d,role:"tab",tabIndex:_??(r?0:-1),"aria-selected":r,"data-selected":r||void 0,className:ZDt("vgai-tab",l),children:[i&&z.jsxs(z.Fragment,{children:[z.jsx("span",{className:"vgai-tab-dirty",title:"Unsaved","aria-hidden":"true"}),z.jsx("span",{className:"vgai-sr-only",children:"Unsaved"})]}),z.jsx("span",{className:"vgai-tab-label",children:g}),a!==void 0&&z.jsx("span",{className:"vgai-tab-badge",children:a})]})});function See(t,r){return r?`${t} ${r}`:t}const NP=Xe.forwardRef(function({label:r,compact:i=!1,selectionMode:a="independent",className:l,...d},_){return z.jsx("div",{...d,ref:_,role:"toolbar","aria-label":r,"data-compact":i||void 0,"data-selection-mode":a,className:See("vgai-toolbar",l)})});function eAt({className:t,...r}){return z.jsx("div",{...r,role:"group",className:See("vgai-toolbar-group",t)})}function tAt(t){return z.jsx("span",{...t,"aria-hidden":"true",className:See("vgai-toolbar-divider",t.className)})}function O5r({className:t,onPointerDownCapture:r,...i}){return z.jsx(NP,{...i,compact:!0,className:See("vgai-floating-toolbar vgai-glass-island",t),onPointerDownCapture:a=>{r?.(a),a.stopPropagation()}})}function Tze({className:t,...r}){return z.jsx("div",{...r,role:"group",className:See("vgai-split-button",t)})}function e3t(t,r){return r?`${t} ${r}`:t}Xe.forwardRef(function({label:r,className:i,...a},l){return z.jsx("div",{...a,ref:l,role:"tree","aria-label":r,className:e3t("vgai-tree",i)})});Xe.forwardRef(function({level:r=1,selected:i=!1,expanded:a,muted:l=!1,dragging:d=!1,leading:_,actions:g,className:b,children:S,style:k,...w},N){return z.jsxs("div",{...w,ref:N,role:"treeitem",tabIndex:w.tabIndex??-1,"aria-level":r,"aria-selected":i,...a===void 0?{}:{"aria-expanded":a},"data-selected":i||void 0,"data-muted":l||void 0,"data-dragging":d||void 0,className:e3t("vgai-tree-row",b),style:{paddingLeft:6+Math.max(0,r-1)*14,...k},children:[_&&z.jsx("span",{className:"vgai-tree-row-leading",children:_}),z.jsx("span",{className:"vgai-tree-row-label",children:S}),g&&z.jsx("span",{className:"vgai-tree-row-actions",children:g})]})});function t3t(t,r=8){const i=window.innerWidth,a=window.innerHeight,l=Math.max(r,i-t.width-r),d=Math.max(r,a-t.height-r);return{left:Math.min(Math.max(t.left,r),l),top:Math.min(Math.max(t.top,r),d)}}function c0e(t,r){return r?`${t} ${r}`:t}function rMe(t){return Array.from(t.querySelectorAll('[role="menuitem"]:not(:disabled), [role="menuitemradio"]:not(:disabled), [role="menuitemcheckbox"]:not(:disabled)'))}function F5r(t){rMe(t)[0]?.focus()}const OP=Xe.forwardRef(function({className:r,role:i="menu",autoFocusFirst:a=!1,dismissBoundaryRef:l,onDismiss:d,onKeyDown:_,...g},b){const S=Xe.useRef(null);return Xe.useImperativeHandle(b,()=>S.current),Xe.useEffect(()=>{a&&rMe(S.current)[0]?.focus()},[a]),Xe.useEffect(()=>{if(!d)return;const k=w=>{const N=w.target;!S.current?.contains(N)&&!l?.current?.contains(N)&&d("outside")};return document.addEventListener("pointerdown",k),()=>document.removeEventListener("pointerdown",k)},[l,d]),z.jsx("div",{...g,ref:S,role:i,className:c0e("vgai-menu",r),onKeyDown:k=>{if(_?.(k),k.defaultPrevented)return;if(k.key==="Escape"){k.preventDefault(),d?.("escape");return}if(!["ArrowDown","ArrowUp","Home","End"].includes(k.key))return;k.preventDefault();const w=rMe(k.currentTarget);if(w.length===0)return;const N=w.indexOf(document.activeElement);k.key==="Home"?w[0]?.focus():k.key==="End"?w.at(-1)?.focus():k.key==="ArrowDown"?w[(N+1+w.length)%w.length]?.focus():w[(N-1+w.length)%w.length]?.focus()}})}),Wa=Xe.forwardRef(function({className:r,type:i="button",role:a="menuitem",onClick:l,onSelect:d,..._},g){return z.jsx("button",{..._,ref:g,type:i,role:a,className:c0e("vgai-menu-item",r),onClick:b=>{l?.(b),b.defaultPrevented||d?.()}})});function Ny(t){return z.jsx("hr",{...t,className:c0e("vgai-menu-separator",t.className)})}const kze=Xe.forwardRef(function({className:r,type:i="button",...a},l){return z.jsx("button",{...a,ref:l,type:i,"aria-haspopup":a["aria-haspopup"]??"menu",className:c0e("vgai-menu-trigger",r)})});function vhe({children:t}){const r=Xe.useRef(null),[i,a]=Xe.useState(null),l=Xe.useId();return Xe.useLayoutEffect(()=>{a(r.current?.closest(".vgai-editor-theme")??null)},[]),z.jsxs(z.Fragment,{children:[z.jsx("span",{ref:r,"data-vgai-portal":l,style:{display:"none"}}),i?vS.createPortal(z.jsx("div",{"data-vgai-portal-content":l,style:{display:"contents"},children:t}),i):null]})}function JR({anchorRef:t,align:r="end",side:i="bottom",autoFocusFirst:a=!0,gap:l=4,clamp:d=!1,onDismiss:_,style:g,children:b,...S}){const[k,w]=Xe.useState(null),[N,P]=Xe.useState(null),j=Xe.useRef(null),J=Xe.useRef(!0),X=Xe.useRef(!1),G=Xe.useCallback(()=>{const xe=t.current;if(!xe||!k)return;const ue=xe.getBoundingClientRect(),fe=k.getBoundingClientRect(),de=i==="right"||i==="left"?{left:i==="right"?ue.right+l:ue.left-l-fe.width,top:ue.top}:{left:r==="end"?ue.right-fe.width:ue.left,top:i==="top"?ue.top-l-fe.height:ue.bottom+l},ge=d?t3t({...de,width:fe.width,height:fe.height}):de,qe=j.current;qe?.left===ge.left&&qe.top===ge.top||(j.current=ge,P(ge))},[r,t,d,l,k,i]);Xe.useLayoutEffect(()=>{const xe=t.current;if(!xe||!k)return;G();let ue=0;const fe=()=>{G(),ue=requestAnimationFrame(fe)};ue=requestAnimationFrame(fe),window.addEventListener("resize",G),document.addEventListener("scroll",G,!0);const se=typeof ResizeObserver>"u"?null:new ResizeObserver(G);return se?.observe(xe),se?.observe(k),()=>{const de=J.current&&k.contains(document.activeElement);window.removeEventListener("resize",G),document.removeEventListener("scroll",G,!0),cancelAnimationFrame(ue),se?.disconnect(),de&&queueMicrotask(()=>t.current?.focus())}},[t,k,G]),Xe.useLayoutEffect(()=>{!a||X.current||!k||!N||(X.current=!0,F5r(k))},[a,k,N]);const ee=xe=>{J.current=xe!=="outside",_(),xe==="escape"&&t.current?.focus()};return z.jsx(vhe,{children:z.jsx(OP,{...S,ref:w,dismissBoundaryRef:t,onDismiss:ee,style:{...g,position:"fixed",left:N?.left??0,top:N?.top??0,visibility:N?g?.visibility:"hidden"},children:b})})}function IDn({label:t,children:r,gap:i=0,...a}){const[l,d]=Xe.useState(!1),_=Xe.useRef(null),g=Xe.useId(),b=k=>k instanceof Element&&(_.current?.contains(k)===!0||k.closest(`[data-vgai-submenu="${g}"]`)!==null),S=k=>{b(k.relatedTarget)||d(!1)};return z.jsxs(z.Fragment,{children:[z.jsxs(Wa,{...a,ref:_,"aria-haspopup":"menu","aria-expanded":l,onPointerEnter:()=>d(!0),onPointerLeave:S,onClick:k=>{k.preventDefault(),d(!0)},onKeyDown:k=>{(k.key==="ArrowRight"||k.key==="Enter"||k.key===" ")&&(k.preventDefault(),d(!0)),k.key==="ArrowLeft"&&d(!1)},children:[z.jsx("span",{style:{flex:1},children:t}),z.jsx("span",{"aria-hidden":"true",style:{paddingInlineStart:"var(--vgai-space-4)"},children:"▸"})]}),l&&z.jsx(JR,{anchorRef:_,"data-vgai-submenu":g,side:"right",gap:i,clamp:!0,autoFocusFirst:!1,onDismiss:()=>d(!1),onPointerLeave:S,children:r})]})}const fo=Xe.forwardRef(function({variant:r="secondary",size:i="default",shape:a="default",className:l,type:d="button",..._},g){return z.jsx("button",{..._,ref:g,type:d,className:l?`vgai-btn ${l}`:"vgai-btn","data-variant":r,"data-size":i,"data-shape":a})}),rf=Xe.forwardRef(function({variant:r="ghost",visibleLabel:i,children:a,...l},d){return z.jsxs(fo,{...l,ref:d,variant:r,"data-icon":"true","data-label-placement":i===void 0?void 0:"below",children:[a,i!==void 0&&z.jsx("span",{className:"vgai-icon-button-label",children:i})]})}),VN={base:0,overlayLow:50,sticky:100,dropdown:1e3,toast:9999,modal:1e4},rY={0:"#1a1a1a",1:"#242424",2:"#2c2c2c",3:"#333333",inset:"#1e1e1e"},rAt={1:"#333333",2:"#444444"},Oq={1:"#c5c8ce",2:"#9aa0a6",3:"#90959c"},R5r="#579EFF",M5r="rgba(87,158,255,0.15)",EFe={1:"#f2f6fb",2:"#d3d9e0",3:"#aab0b7"},Ize="#d8dee9",Dze="rgba(216,222,233,0.18)",r3t="#FF6B6B",n3t="#e0a030",i3t="#4caf50",s3t="rgba(76,175,80,0.15)",o3t="rgba(255,107,107,0.15)",a3t="rgba(224,160,48,0.12)",c3t="rgba(255,107,107,0.06)",l3t="rgba(0,0,0,0.5)",u3t="#ff79c6",f3t="rgba(255,121,198,0.08)",d3t="#22b8d6",l0e='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',u0e='ui-monospace, "SF Mono", Monaco, "Cascadia Code", monospace',TFe={sm:"0 2px 8px rgba(0,0,0,0.6)",md:"0 4px 12px rgba(0,0,0,0.5)",lg:"0 8px 32px rgba(0,0,0,0.6)"},Pze={1:"var(--vgai-surface-panel)",inset:"var(--vgai-surface-inset)"},bhe={1:"var(--vgai-boundary-default)",2:"var(--vgai-boundary-strong)"},od={1:"var(--vgai-content-primary)",2:"var(--vgai-content-muted)",3:"var(--vgai-content-dim)"},nMe="var(--vgai-danger)",U_={1:2,2:4,3:6,4:8,5:10,6:12,8:16,10:20,12:24},p3t={commandBar:36,panelHeader:30,localToolbar:28,treeRow:24,treeIndent:14,statusBar:36,toolSize:34,toolWidth:38,toolGap:7,areaSeam:1,areaEmboss:0};function s_(t){return{control:{...L5r,...t.density?.control},font:{...B5r,...t.density?.font},icon:{...j5r,...t.density?.icon},chrome:{...p3t,...t.density?.chrome}}}const L5r={compact:20,default:24,comfortable:28},kFe={resting:1,active:2},j5r={xs:9,sm:10,md:12,lg:13,xl:14,"2xl":16},B5r={xs:9,sm:10,base:11,md:12,lg:13,xl:14,"2xl":16,heading:24},U_e={regular:400,semibold:600,bold:700},Rpe={tight:1,snug:1.2,normal:1.4,relaxed:1.5},nY={duration:{fast:140,base:180,slow:300},easing:{standard:"cubic-bezier(0.32, 0.72, 0.28, 1)",out:"ease-out"}},ZN={small:"3px",medium:"6px",large:"8px",full:"9999px"},dZ={sm:"var(--vgai-radius-sm)"},zY={xs:"var(--vgai-font-xs)",sm:"var(--vgai-font-sm)"},pv={1:"var(--vgai-space-1)",2:"var(--vgai-space-2)",3:"var(--vgai-space-3)",4:"var(--vgai-space-4)",5:"var(--vgai-space-5)",6:"var(--vgai-space-6)",8:"var(--vgai-space-8)",10:"var(--vgai-space-10)",12:"var(--vgai-space-12)"},nAt={normal:"var(--vgai-leading-normal)"},$5r=["outliner","properties"],oz={id:"graphite-dark",color:{surface:{shell:rY[0],panel:rY[1],chrome:rY[2],raised:rY[3],inset:rY.inset,overlay:"rgba(36,36,36,0.94)"},boundary:{default:rAt[1],strong:rAt[2]},content:{primary:Oq[1],muted:Oq[2],dim:Oq[3],onAccent:"#101820",onBright:{primary:"#1a2330",muted:"rgba(26,35,48,0.82)",dim:"rgba(26,35,48,0.74)"}},accent:{default:R5r,muted:M5r},semantic:{danger:r3t,dangerMuted:o3t,dangerFaint:c3t,warning:n3t,warningMuted:a3t,success:i3t,successMuted:s3t,dynamic:u3t,dynamicMuted:f3t,instance:d3t},neutralOverlay:{hover:"rgba(255,255,255,0.08)",active:"rgba(255,255,255,0.14)"},scrim:l3t},typography:{sans:l0e,mono:u0e},shape:{small:ZN.small,medium:ZN.medium,large:ZN.large,full:ZN.full},elevation:{small:TFe.sm,medium:TFe.md,large:TFe.lg}},q5r={...oz,id:"graphite-neutral",color:{...oz.color,content:{primary:EFe[1],muted:EFe[2],dim:EFe[3],onAccent:"#101820",onBright:{primary:"#1a2330",muted:"rgba(26,35,48,0.82)",dim:"rgba(26,35,48,0.74)"}},accent:{default:Ize,muted:Dze}}},z5r={id:"midnight-high-contrast",color:{surface:{shell:"#0b0f14",panel:"#111821",chrome:"#17212c",raised:"#223040",inset:"#080c11",overlay:"rgba(17,24,33,0.96)"},boundary:{default:"#34465a",strong:"#71869d"},content:{primary:"#f2f5f8",muted:"#bdc8d5",dim:"#8493a5",onAccent:"#071019",onBright:{primary:"#071019",muted:"rgba(7,16,25,0.82)",dim:"rgba(7,16,25,0.72)"}},accent:{default:"#65d1ff",muted:"rgba(101,209,255,0.18)"},semantic:{danger:"#ff7b86",dangerMuted:"rgba(255,123,134,0.18)",dangerFaint:"rgba(255,123,134,0.08)",warning:"#f3c969",warningMuted:"rgba(243,201,105,0.16)",success:"#62d394",successMuted:"rgba(98,211,148,0.18)",dynamic:"#e889ff",dynamicMuted:"rgba(232,137,255,0.12)",instance:"#a49bff"},neutralOverlay:{hover:"rgba(255,255,255,0.10)",active:"rgba(255,255,255,0.18)"},scrim:"rgba(0,0,0,0.68)"},typography:{sans:l0e,mono:u0e},shape:{small:"3px",medium:"6px",large:"8px",full:"9999px"},elevation:{small:"0 2px 8px rgba(0,0,0,0.72)",medium:"0 6px 18px rgba(0,0,0,0.68)",large:"0 12px 40px rgba(0,0,0,0.76)"}},iMe={id:"glass-dark",appearance:{material:"glass",transparency:"standard"},color:{surface:{shell:"rgba(26,26,26,0.88)",panel:"rgba(36,36,36,0.62)",chrome:"rgba(44,44,44,0.68)",raised:"rgba(51,51,51,0.74)",inset:"rgba(30,30,30,0.7)",overlay:"rgba(36,36,36,0.55)"},boundary:{default:"rgba(255,255,255,0.14)",strong:"rgba(255,255,255,0.24)"},content:{primary:Oq[1],muted:Oq[2],dim:Oq[3],onAccent:"#101820",onBright:{primary:"#1a2330",muted:"rgba(26,35,48,0.82)",dim:"rgba(26,35,48,0.74)"}},accent:{default:Ize,muted:Dze},semantic:{danger:r3t,dangerMuted:o3t,dangerFaint:c3t,warning:n3t,warningMuted:a3t,success:i3t,successMuted:s3t,dynamic:u3t,dynamicMuted:f3t,instance:d3t},neutralOverlay:{hover:"color-mix(in srgb, currentColor 9%, transparent)",active:"color-mix(in srgb, currentColor 14%, transparent)"},scrim:"rgba(0,0,0,0.35)"},typography:{sans:l0e,mono:u0e},shape:{small:ZN.small,medium:ZN.medium,large:ZN.large,full:ZN.full},elevation:{small:"0 4px 16px rgba(0,0,0,0.55)",medium:"0 8px 28px rgba(0,0,0,0.5)",large:"0 16px 48px rgba(0,0,0,0.55)"},treatment:{backdropBlurPx:14,backdropSaturation:1.3,backdropBrightness:.5,edgeSpecular:.6,specularAngleDeg:120,thickness:.5}},U5r=(()=>{const{treatment:t,...r}=iMe;return{...r,id:"glass-dark-lite",appearance:{material:"glass",transparency:"reduced"},color:{...iMe.color,surface:{shell:"#1a1a1a",panel:"#222222",chrome:"#292929",raised:"#303030",inset:"#1d1d1d",overlay:"#202020"},scrim:l3t}}})(),sMe={id:"liquid-glass",appearance:{material:"glass",transparency:"standard"},color:{surface:{shell:fh.color.surface.shell,panel:fh.color.surface.panel,chrome:fh.color.surface.chrome,raised:fh.color.surface.raised,inset:fh.color.surface.inset,overlay:fh.color.surface.overlay},boundary:fh.color.boundary,content:{primary:"#f2f6fb",muted:"rgba(242,246,251,0.85)",dim:"rgba(242,246,251,0.68)",onAccent:"#0b1526",onBright:{primary:"#1a2330",muted:"rgba(26,35,48,0.82)",dim:"rgba(26,35,48,0.74)"}},accent:{default:Ize,muted:Dze},semantic:{danger:"#ff7b86",dangerMuted:"rgba(255,123,134,0.22)",dangerFaint:"rgba(255,123,134,0.10)",warning:"#ffd35f",warningMuted:"rgba(255,211,95,0.18)",success:"#58e078",successMuted:"rgba(88,224,120,0.20)",dynamic:"#ff8fd8",dynamicMuted:"rgba(255,143,216,0.14)",instance:"#3ad2ea"},neutralOverlay:fh.color.neutralOverlay,scrim:fh.color.scrim},typography:{sans:l0e,mono:u0e},shape:fh.shape,elevation:fh.elevation,treatment:fh.treatment},V5r=(()=>{const{treatment:t,...r}=sMe;return{...r,id:"liquid-glass-lite",appearance:{material:"glass",transparency:"reduced"},color:{...sMe.color,surface:fh.reducedTransparency.surface,scrim:fh.reducedTransparency.scrim}}})(),_3t={"graphite-dark":oz,"graphite-neutral":q5r,"midnight-high-contrast":z5r,"glass-dark":iMe,"glass-dark-lite":U5r,"liquid-glass":sMe,"liquid-glass-lite":V5r};function J5r(t){return typeof t=="string"&&Object.hasOwn(_3t,t)}const Oo={surface:{shell:"var(--vgai-surface-shell)",panel:"var(--vgai-surface-panel)",raised:"var(--vgai-surface-raised)",inset:"var(--vgai-surface-inset)",overlay:"var(--vgai-surface-overlay)"},boundary:{default:"var(--vgai-boundary-default)",strong:"var(--vgai-boundary-strong)"},content:{primary:"var(--vgai-content-primary)",muted:"var(--vgai-content-muted)",dim:"var(--vgai-content-dim)",onAccent:"var(--vgai-content-on-accent)",active:"var(--vgai-content-active)",selected:"var(--vgai-content-selected)"},accent:{default:"var(--vgai-accent)",muted:"var(--vgai-accent-muted)"},selection:{background:"var(--vgai-selection-bg)"},semantic:{danger:"var(--vgai-danger)",dangerMuted:"var(--vgai-danger-muted)",warning:"var(--vgai-warn)",success:"var(--vgai-success)",successMuted:"var(--vgai-success-muted)",instance:"var(--vgai-instance)"},neutralOverlay:{active:"var(--vgai-neutral-active)"},typography:{sans:"var(--vgai-font-sans)",mono:"var(--vgai-font-mono)"},shape:{small:"var(--vgai-radius-sm)",medium:"var(--vgai-radius-md)"}};function W5r(t){const r=`<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1L5 5L9 1' stroke='${t}' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>`;return`url("data:image/svg+xml,${encodeURIComponent(r)}")`}function H5r(t){if(!t)return"none";const r=[];return t.backdropBlurPx&&r.push(`blur(${t.backdropBlurPx}px)`),t.backdropSaturation!==void 0&&t.backdropSaturation!==1&&r.push(`saturate(${t.backdropSaturation})`),t.backdropBrightness!==void 0&&t.backdropBrightness!==1&&r.push(`brightness(${t.backdropBrightness})`),r.length>0?r.join(" "):"none"}function iAt(t,r){return r?"transparent":`linear-gradient(var(${t}), var(${t})), linear-gradient(var(--vgai-surface-shell), var(--vgai-surface-shell))`}function sAt(t){const r=t?.contentFrostBlurPx??0;if(r<=0)return"none";const i=[`blur(${r}px)`];return t?.backdropSaturation!==void 0&&t.backdropSaturation!==1&&i.push(`saturate(${t.backdropSaturation})`),i.join(" ")}function oMe(t){return(t?.contentFrostBlurPx??0)>0?"rgba(255,255,255,0.10)":"transparent"}function G5r(t){return t?"color-mix(in srgb, currentColor 7%, transparent)":"var(--vgai-widget-field)"}function Q5r(t){return t?"color-mix(in srgb, currentColor 26%, transparent)":"var(--vgai-boundary-default)"}function K5r(t,r){const l=[r==="none"?"":r,t?"inset 0 1px 0 color-mix(in srgb, currentColor 14%, transparent), 0 5px 14px -12px color-mix(in srgb, currentColor 55%, transparent)":""].filter(Boolean);return l.length===0?"none":l.join(", ")}const Y5r=.6,X5r=.5;function Ahe(t,r){return`rgba(255,255,255,${Math.min(1,Number((t*r/Y5r).toFixed(3)))})`}function m3t(t){const r=t?.edgeSpecular??0;if(r<=0)return"none";const i=t?.specularAngleDeg??120,a=l=>Ahe(l,r);return`linear-gradient(${i}deg, ${a(.95)} 0%, ${a(.38)} 16%, ${a(.16)} 40%, ${a(.14)} 60%, ${a(.45)} 84%, ${a(.85)} 100%)`}function Z5r(t){const r=t?.edgeSpecular??0;if(r<=0)return"none";const i=t?.specularAngleDeg??120,a=l=>Ahe(l,r);return`linear-gradient(${i}deg, ${a(.16)} 0%, ${a(.05)} 24%, transparent 40%)`}function eFr(t){const r=t?.edgeSpecular??0,i=t?.thickness??0,a=[];if(r>0&&(a.push(`inset 0 1px 1px ${Ahe(.28,r)}`),a.push(`inset 0 -1px 1px ${Ahe(.1,r)}`)),i>0){const l=d=>`${Number((d*i/X5r).toFixed(1))}px`;a.push(`inset 0 ${l(12)} ${l(24)} ${l(-14)} rgba(255,255,255,0.35)`),a.push(`inset 0 ${l(-14)} ${l(28)} ${l(-18)} rgba(0,0,0,0.55)`),a.push(`0 ${l(18)} ${l(40)} ${l(-18)} rgba(0,0,0,0.55)`)}else a.push("var(--vgai-shadow-lg)");return a.join(", ")}function nU(t){return t.appearance?t.appearance.material==="glass":t.treatment!==void 0}function tFr(t){return nU(t)?"var(--vgai-surface-panel)":"color-mix(in srgb, var(--vgai-surface-panel) 90%, transparent)"}function rFr(t){return nU(t)?t.treatment?"var(--vgai-surface-backdrop-filter)":"none":"blur(8px)"}function nFr(t){return t?"17px":"var(--vgai-radius-md)"}function iFr(t){return t?"var(--vgai-boundary-default)":"var(--vgai-boundary-strong)"}function sFr(t){return t?"var(--vgai-shadow-lg)":"var(--vgai-shadow-sm)"}function oFr(t,r){const i=/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(t.color.accent.default);if(!i)return null;const[a,l,d]=[i[1],i[2],i[3]].map(_=>Number.parseInt(_,16));return`rgba(${a},${l},${d},${r})`}function f0e(t){return nU(t)}function aFr(t){return f0e(t)?"var(--vgai-neutral-active)":"var(--vgai-accent-muted)"}function cFr(t){const r=t.trim().toLowerCase();if(r.startsWith("#"))return r.length===5?r.endsWith("f"):r.length===9?r.endsWith("ff"):!0;const i=/^rgba?\(([^)]*)\)$/.exec(r)??/^hsla?\(([^)]*)\)$/.exec(r);if(i){const a=(i[1]??"").split(/[,/]/)[3];return a===void 0||Number.parseFloat(a)>=1}return r!=="transparent"&&!r.includes("transparent")}function lFr(t){return f0e(t)?"var(--vgai-content-primary)":cFr(t.color.accent.muted)?"var(--vgai-content-on-accent)":"var(--vgai-content-primary)"}function uFr(t){return f0e(t)?"color-mix(in srgb, currentColor 30%, transparent)":"var(--vgai-accent)"}function fFr(t){return f0e(t)?"color-mix(in srgb, currentColor 76%, transparent)":"var(--vgai-accent)"}function dFr(t){return t?"var(--vgai-radius-full)":"var(--vgai-radius-sm)"}function pFr(t){return!nU(t)||!t.treatment?"var(--vgai-accent)":oFr(t,.82)??"var(--vgai-accent)"}function _Fr(t){const r=t?.edgeSpecular??0;return r<=0?"none":m3t({...t,edgeSpecular:r*.4})}function mFr(t){const r=t?.ambientLiftOpacity??0;if(r<=0)return"none";const i=Number(r.toFixed(3)),a=Number((r*.35).toFixed(3));return`linear-gradient(165deg, rgba(255,255,255,${i}) 0%, rgba(255,255,255,${a}) 55%, rgba(255,255,255,0) 100%)`}function h3t(t){return t<=0?"none":`0 1px 2px rgba(0,0,0,${Number(t.toFixed(3))})`}function g3t(t){return h3t(t?.textShadowOpacity??0)}function hFr(t){return t.treatment?.adaptiveContent?{primary:t.color.content.onBright.primary,muted:t.color.content.onBright.muted,dim:t.color.content.onBright.dim,textShadow:h3t(t.treatment.brightTextShadowOpacity??0),frostBg:t.treatment.brightFrostBg??oMe(t.treatment)}:{primary:t.color.content.primary,muted:t.color.content.muted,dim:t.color.content.dim,textShadow:g3t(t.treatment),frostBg:oMe(t.treatment)}}function gFr(t){return t.treatment?t.treatment.adaptiveContent?"rgba(255,255,255,0.9)":vFr(t.color.surface.chrome,.9):t.color.surface.chrome}function yFr(t){return t.color.surface.panel}function vFr(t,r){const i=/^rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*([0-9.]+)\s*\)$/.exec(t);if(!i)return t;const a=Math.max(Number(i[4]),r);return`rgba(${i[1]},${i[2]},${i[3]},${a})`}function oAt(t){if(!t)return"none";const i=[`blur(${Math.max(16,t.contentFrostBlurPx??0)}px)`];return t.backdropSaturation!==void 0&&t.backdropSaturation!==1&&i.push(`saturate(${t.backdropSaturation})`),i.join(" ")}function bFr(t){return t.color.boundary.area??t.color.boundary.default}function AFr(t,r){return`color-mix(in srgb, ${t} 98.4%, ${r})`}function iY(t){return`color-mix(in srgb, var(--vgai-area-emboss-mix), ${t})`}function SFr(t){const r=s_(t).chrome.areaEmboss;return r>0?`#ffffff ${r}%`:"transparent 100%"}function xFr(t){const r=hFr(t),i=nU(t),a=t.color.widget?.regular??t.color.surface.raised,l=t.color.widget?.menu??t.color.surface.raised,d=t.color.widget?.field??t.color.surface.inset,_=t.color.widget?.emboss?`0 1px 0 ${t.color.widget.emboss}`:"none",g=S=>`color-mix(in srgb, ${S} 87.8%, ${t.color.content.primary})`,b=`color-mix(in srgb, ${t.color.surface.panel} 86.5%, ${t.color.surface.raised})`;return{"--vgai-surface-shell":t.color.surface.shell,"--vgai-surface-panel":t.color.surface.panel,"--vgai-surface-chrome":t.color.surface.chrome,"--vgai-surface-raised":t.color.surface.raised,"--vgai-surface-inset":t.color.surface.inset,"--vgai-surface-overlay":t.color.surface.overlay,"--vgai-surface-backdrop-filter":H5r(t.treatment),"--vgai-surface-sticky":iAt("--vgai-surface-chrome",i),"--vgai-surface-sticky-panel":iAt("--vgai-surface-panel",i),"--vgai-surface-sticky-backdrop-filter":"none","--vgai-surface-body-frost-filter":sAt(t.treatment),"--vgai-content-frost-filter":sAt(t.treatment),"--vgai-content-frost-bg":oMe(t.treatment),"--vgai-input-surface":G5r(i),"--vgai-input-border":Q5r(i),"--vgai-input-shadow":K5r(i,_),"--vgai-structural-divider":i?"transparent":t.color.boundary.default,"--vgai-card-specular-ring":m3t(t.treatment),"--vgai-card-specular-sheen":Z5r(t.treatment),"--vgai-card-specular-shadow":eFr(t.treatment),"--vgai-card-refraction-thickness":String(t.treatment?.refractionThickness??0),"--vgai-card-refraction-bezel":String(t.treatment?.refractionBezelPx??28),"--vgai-card-refraction-angle":String(t.treatment?.specularAngleDeg??120),"--vgai-ambient-lift":mFr(t.treatment),"--vgai-island-surface":tFr(t),"--vgai-island-backdrop-filter":rFr(t),"--vgai-island-radius":nFr(i),"--vgai-island-border-color":iFr(i),"--vgai-island-shadow":sFr(i),"--vgai-island-specular-ring":_Fr(t.treatment),"--vgai-selection-bg":aFr(t),"--vgai-content-on-selection":lFr(t),"--vgai-selection-border":uFr(t),"--vgai-selection-indicator":fFr(t),"--vgai-island-control-radius":dFr(i),"--vgai-island-primary-bg":pFr(t),"--vgai-content-text-shadow":g3t(t.treatment),"--vgai-content-primary-on-bright":r.primary,"--vgai-content-muted-on-bright":r.muted,"--vgai-content-dim-on-bright":r.dim,"--vgai-content-text-shadow-on-bright":r.textShadow,"--vgai-content-frost-bg-on-bright":r.frostBg,"--vgai-content-adaptive":t.treatment?.adaptiveContent?"1":"0","--vgai-glass-regular-bg":gFr(t),"--vgai-glass-regular-backdrop-filter":oAt(t.treatment),"--vgai-glass-regular-panel-bg":yFr(t),"--vgai-glass-regular-panel-backdrop-filter":oAt(t.treatment),"--vgai-glass-dark-frost-panel-bg":"rgba(5,8,13,0.74)","--vgai-glass-dark-frost-content-bg":"rgba(5,8,13,0.84)","--vgai-scrim-backdrop-filter":t.treatment?"blur(8px)":"none","--vgai-boundary-default":t.color.boundary.default,"--vgai-boundary-strong":t.color.boundary.strong,"--vgai-boundary-area":bFr(t),"--vgai-tree-indent-guide":t.color.boundary.indent??"transparent","--vgai-boundary-divider":t.color.boundary.divider??t.color.boundary.default,"--vgai-area-emboss-mix":SFr(t),"--vgai-area-emboss":iY(t.color.surface.panel),"--vgai-area-emboss-stage":iY(iY(t.color.viewport?.background??t.color.surface.panel)),"--vgai-area-emboss-stage-header":iY(iY(b)),"--vgai-content-primary":t.color.content.primary,"--vgai-content-muted":t.color.content.muted,"--vgai-content-dim":t.color.content.dim,"--vgai-content-on-accent":t.color.content.onAccent,"--vgai-content-menu":t.color.content.menu??t.color.content.primary,"--vgai-content-status":t.color.content.status??t.color.content.dim,"--vgai-content-placeholder":t.color.content.placeholder??t.color.content.dim,"--vgai-content-active":t.color.content.active??"","--vgai-content-selected":t.color.content.selected??t.color.content.active??"","--vgai-accent":t.color.accent.default,"--vgai-accent-muted":t.color.accent.muted,"--vgai-danger":t.color.semantic.danger,"--vgai-danger-muted":t.color.semantic.dangerMuted,"--vgai-danger-faint":t.color.semantic.dangerFaint,"--vgai-warn":t.color.semantic.warning,"--vgai-warn-muted":t.color.semantic.warningMuted,"--vgai-success":t.color.semantic.success,"--vgai-success-muted":t.color.semantic.successMuted,"--vgai-dynamic":t.color.semantic.dynamic,"--vgai-dynamic-muted":t.color.semantic.dynamicMuted,"--vgai-instance":t.color.semantic.instance,"--vgai-neutral-hover":t.color.neutralOverlay.hover,"--vgai-neutral-active":t.color.neutralOverlay.active,"--vgai-scrim":t.color.scrim,"--vgai-surface-section":`color-mix(in srgb, ${t.color.surface.panel} 64.9%, ${t.color.surface.raised})`,"--vgai-surface-section-edge":`color-mix(in srgb, ${t.color.surface.panel} 29.7%, ${t.color.surface.raised})`,"--vgai-surface-header":b,"--vgai-surface-row-alt":AFr(t.color.surface.panel,t.color.content.primary),"--vgai-tree-row-selected-bg":`color-mix(in srgb, ${t.color.accent.default} 42%, #000)`,"--vgai-tree-row-active-bg":`color-mix(in srgb, ${t.color.accent.default} 70%, #000)`,"--vgai-tree-row-active-border":"rgb(from var(--vgai-tree-row-active-bg) calc(r + 40) calc(g + 40) calc(b + 40))","--vgai-tree-active-name-underline":t.color.content.active?"none":"underline","--vgai-viewport-background":t.color.viewport?.background??"","--vgai-viewport-grid":t.color.viewport?.grid??"","--vgai-viewport-axis-x":t.color.viewport?.axisX??"","--vgai-viewport-axis-y":t.color.viewport?.axisY??"","--vgai-viewport-selection":t.color.viewport?.selection??"","--vgai-viewport-active":t.color.viewport?.active??"","--vgai-viewport-gizmo-size":t.density?.viewport?.gizmoSize===void 0?"":`${t.density.viewport.gizmoSize}`,"--vgai-viewport-shelf-tool":t.density?.viewport?.shelfTool??"","--vgai-viewport-up-axis":t.density?.viewport?.upAxis??"","--vgai-viewport-box-select":t.density?.viewport?.boxSelect??"","--vgai-widget-regular":a,"--vgai-widget-regular-hover":g(a),"--vgai-widget-menu":l,"--vgai-widget-menu-hover":g(l),"--vgai-widget-field":d,"--vgai-widget-emboss-shadow":_,"--vgai-category-object":t.color.category?.object??"currentColor","--vgai-category-modifier":t.color.category?.modifier??"currentColor","--vgai-category-material":t.color.category?.material??"currentColor","--vgai-category-tool":t.color.category?.tool??"currentColor","--vgai-category-operator":t.color.category?.operator??"currentColor","--vgai-category-data":t.color.category?.data??"currentColor","--vgai-category-scene":t.color.category?.scene??"currentColor","--vgai-category-collection":t.color.category?.collection??"currentColor","--vgai-region-outliner":t.color.region?.outliner??t.color.surface.panel,"--vgai-region-outliner-header":t.color.region?.outliner??t.color.surface.chrome,"--vgai-region-properties":t.color.region?.properties??t.color.surface.panel,"--vgai-region-properties-header":t.color.region?.properties??t.color.surface.chrome,"--vgai-font-sans":t.typography.sans,"--vgai-font-mono":t.typography.mono,"--vgai-radius-sm":t.shape.small,"--vgai-radius-md":t.shape.medium,"--vgai-radius-lg":t.shape.large,"--vgai-radius-full":t.shape.full,"--vgai-shadow-sm":t.elevation.small,"--vgai-shadow-md":t.elevation.medium,"--vgai-shadow-lg":t.elevation.large,"--vgai-focus-ring":`${kFe.active}px solid ${t.color.accent.default}`,"--vgai-select-chevron":W5r(t.color.content.muted),"--vgai-space-1":`${U_[1]}px`,"--vgai-space-2":`${U_[2]}px`,"--vgai-space-3":`${U_[3]}px`,"--vgai-space-4":`${U_[4]}px`,"--vgai-space-5":`${U_[5]}px`,"--vgai-space-6":`${U_[6]}px`,"--vgai-space-8":`${U_[8]}px`,"--vgai-space-10":`${U_[10]}px`,"--vgai-space-12":`${U_[12]}px`,"--vgai-command-bar-height":`${s_(t).chrome.commandBar}px`,"--vgai-panel-header-height":`${s_(t).chrome.panelHeader}px`,"--vgai-local-toolbar-height":`${s_(t).chrome.localToolbar}px`,"--vgai-tree-row-height":`${s_(t).chrome.treeRow}px`,"--vgai-tree-indent":`${s_(t).chrome.treeIndent}px`,"--vgai-status-bar-height":`${s_(t).chrome.statusBar}px`,"--vgai-tool-size":`${s_(t).chrome.toolSize}px`,"--vgai-tool-width":`${s_(t).chrome.toolWidth}px`,"--vgai-tool-gap":`${s_(t).chrome.toolGap}px`,"--vgai-area-seam-width":`${s_(t).chrome.areaSeam}px`,"--vgai-control-compact-height":`${s_(t).control.compact}px`,"--vgai-control-default-height":`${s_(t).control.default}px`,"--vgai-control-comfortable-height":`${s_(t).control.comfortable}px`,"--vgai-stroke-resting":`${kFe.resting}px`,"--vgai-stroke-active":`${kFe.active}px`,"--vgai-font-xs":`${s_(t).font.xs}px`,"--vgai-font-sm":`${s_(t).font.sm}px`,"--vgai-font-base":`${s_(t).font.base}px`,"--vgai-font-md":`${s_(t).font.md}px`,"--vgai-font-lg":`${s_(t).font.lg}px`,"--vgai-font-xl":`${s_(t).font.xl}px`,"--vgai-font-2xl":`${s_(t).font["2xl"]}px`,"--vgai-icon-xs":`${s_(t).icon.xs}px`,"--vgai-icon-sm":`${s_(t).icon.sm}px`,"--vgai-icon-md":`${s_(t).icon.md}px`,"--vgai-icon-lg":`${s_(t).icon.lg}px`,"--vgai-icon-xl":`${s_(t).icon.xl}px`,"--vgai-icon-2xl":`${s_(t).icon["2xl"]}px`,"--vgai-font-heading":`${s_(t).font.heading}px`,"--vgai-font-weight-regular":String(U_e.regular),"--vgai-font-weight-semibold":String(U_e.semibold),"--vgai-font-weight-bold":String(U_e.bold),"--vgai-leading-tight":String(Rpe.tight),"--vgai-leading-snug":String(Rpe.snug),"--vgai-leading-normal":String(Rpe.normal),"--vgai-leading-relaxed":String(Rpe.relaxed),"--vgai-duration-fast":`${nY.duration.fast}ms`,"--vgai-duration-base":`${nY.duration.base}ms`,"--vgai-duration-slow":`${nY.duration.slow}ms`,"--vgai-ease-standard":nY.easing.standard,"--vgai-ease-out":nY.easing.out,"--vgai-z-base":String(VN.base),"--vgai-z-overlay-low":String(VN.overlayLow),"--vgai-z-sticky":String(VN.sticky),"--vgai-z-dropdown":String(VN.dropdown),"--vgai-z-toast":String(VN.toast),"--vgai-z-modal":String(VN.modal)}}const aMe="vgai-editor-theme";function wFr(t,r=oz){t.classList.add(aMe),t.dataset.vgaiTheme=r.id,t.dataset.vgaiChrome=nU(r)?"islands":"bars";for(const[i,a]of Object.entries(xFr(r)))t.style.setProperty(i,a)}const y3t=Xe.createContext(null);function CFr(){return Xe.useContext(y3t)}function _9(t,r){return r?`${t} ${r}`:t}const k_=Xe.forwardRef(function({className:r,type:i="text",...a},l){return z.jsx("input",{...a,ref:l,type:i,className:_9("vgai-input",r)})}),bS=Xe.forwardRef(function({className:r,...i},a){return z.jsx("select",{...i,ref:a,className:_9("vgai-select",r)})}),Nze=Xe.forwardRef(function({className:r,...i},a){return z.jsx("textarea",{...i,ref:a,className:_9("vgai-input vgai-textarea",r)})}),SE=Xe.forwardRef(function({className:r,...i},a){return z.jsx("input",{...i,ref:a,type:"checkbox",className:_9("vgai-checkbox",r)})}),v3t=Xe.forwardRef(function({className:r,...i},a){return z.jsx("input",{...i,ref:a,type:"color",className:_9("vgai-color-swatch",r)})});Xe.forwardRef(function({className:r,...i},a){return z.jsx("input",{...i,ref:a,type:"file",className:_9("vgai-file-input",r)})});const DDn=Xe.forwardRef(function({className:r,...i},a){return z.jsx("input",{...i,ref:a,type:"range",className:_9("vgai-range",r)})}),Yk="default",AX=new Map;let pZ=Yk;const cMe=new Set;function lMe(){for(const t of cMe)t()}function xee(t){return typeof t=="string"&&(t===Yk||AX.has(t))}function EFr(t){if(xee(t.id))throw new Error(`registerContributedIconSet: icon set "${t.id}" is already registered.`);return AX.set(t.id,t),lMe(),()=>{AX.get(t.id)===t&&(AX.delete(t.id),lMe())}}function aAt(){return pZ}function V_e(t){const r=xee(t)?t:Yk;r!==pZ&&(pZ=r,lMe())}function b3t(t){return cMe.add(t),()=>cMe.delete(t)}function TFr(t){return pZ===Yk?null:AX.get(pZ)?.glyphs[t]??null}const cAt={xs:"var(--vgai-icon-xs)",sm:"var(--vgai-icon-sm)",md:"var(--vgai-icon-md)",lg:"var(--vgai-icon-lg)",xl:"var(--vgai-icon-xl)","2xl":"var(--vgai-icon-2xl)"},lAt={current:void 0,primary:Oo.content.primary,muted:Oo.content.muted,dim:Oo.content.dim,accent:Oo.accent.default,danger:Oo.semantic.danger};function So({icon:t,size:r="sm",tone:i="current",label:a,className:l,style:d,spin:_=!1,...g}){Xe.useSyncExternalStore(b3t,aAt,aAt);const b=TFr(t.iconName);if(b){const S=i!=="current",k=b.tone?`var(--vgai-category-${b.tone}, currentColor)`:void 0,w=S?lAt[i]:b.tonedPath?void 0:k,N=S?"currentColor":k??"currentColor";return z.jsxs("svg",{...g,viewBox:b.viewBox??"0 0 16 16","data-vgai-tone":S?void 0:b.tone,className:l,"aria-hidden":a?void 0:g["aria-hidden"]??"true","aria-label":a,role:a?"img":void 0,style:{width:"1.25em",height:"1em",overflow:"visible",verticalAlign:"-0.125em",fontSize:cAt[r],color:w,...d},children:[z.jsx("path",{d:b.path,fill:"currentColor"}),b.tonedPath?z.jsx("path",{d:b.tonedPath,fill:N}):null]})}return z.jsx(Mkr,{...g,icon:t,fixedWidth:!0,spin:_,className:l,"aria-hidden":a?void 0:g["aria-hidden"]??"true","aria-label":a,role:a?"img":void 0,style:{fontSize:cAt[r],color:lAt[i],...d}})}function A3t({direction:t,size:r="xs",tone:i="current",style:a}){return z.jsx(So,{icon:t==="right"?zkt:eIt,size:r,tone:i,...a?{style:a}:{}})}function aS(t,r){return{...r,iconName:t}}const yb={action:{close:eze,search:jkt},transport:{play:aDr,pause:EDr,stop:w9e},content:{project:qkt,folder:gee},status:{success:S8,warning:vee,error:Gkt},viewport:{zoomIn:zIr,zoomOut:BIr,pan:eDr,frame:$kt,projection:aS("viewport-projection",TDr)},modeling:{extrude:aS("mesh-extrude",Wkt),inset:aS("mesh-inset",wDr),bevel:aS("mesh-bevel",IDr),loopCut:aS("mesh-loop-cut",UIr),knife:aS("mesh-knife",yDr),smooth:aS("mesh-smooth",jIr),shrinkFatten:aS("mesh-shrink-fatten",Qkt),subdivide:aS("mesh-subdivide",cDr)},tool:{extension:yee,select:PDr,move:Kkt,rotate:Mkt,scale:aS("tool-scale",VIr),transform:aS("tool-transform",nDr)},panel:{outliner:aS("outliner",lIt),properties:aS("properties",Ykt)}};function SX({value:t,onChange:r,onChangeEnd:i,step:a=.1,precision:l=3,disabled:d=!1,label:_,labelColor:g,style:b,testId:S,title:k}){const[w,N]=Xe.useState(!1),[P,j]=Xe.useState(""),J=Xe.useRef({startX:0,startVal:0,dragging:!1,gesture:!1,lastVal:0}),X=Xe.useRef(null),G=CFr();Xe.useEffect(()=>{if(!w)return;const de=X.current;de&&(de.focus(),de.select())},[w]);const ee=t===null,xe=t??0,ue=ee?"—":Number.isFinite(xe)?xe.toFixed(l):0 .toFixed(l),fe=de=>{if(d)return;J.current={startX:de.clientX,startVal:xe,dragging:!1,gesture:!1,lastVal:xe};const ge=tt=>{const Ct=tt.clientX-J.current.startX;if(Math.abs(Ct)>3&&(J.current.dragging=!0),J.current.dragging){J.current.gesture||(J.current.gesture=!0,G?.begin());const Ot=J.current.startVal+Ct*a,vt=Math.round(Ot/a)*a;J.current.lastVal=vt,r(vt)}},qe=()=>{window.removeEventListener("pointermove",ge),window.removeEventListener("pointerup",qe),J.current.gesture&&G?.end(),J.current.dragging?i?.(J.current.lastVal):(N(!0),j(ee?"":ue))};window.addEventListener("pointermove",ge),window.addEventListener("pointerup",qe)},se=()=>{N(!1);const de=Number.parseFloat(P);Number.isFinite(de)&&(r(de),i?.(de))};return z.jsxs("div",{className:"vgai-number-input","data-testid":S,title:k,style:b,children:[_&&z.jsx("span",{className:"vgai-number-input-label",style:g?{color:g}:void 0,children:_}),w?z.jsx(k_,{ref:X,value:P,onChange:de=>j(de.target.value),onBlur:se,onKeyDown:de=>{de.key==="Enter"&&se(),de.key==="Escape"&&N(!1)},placeholder:ee?"—":void 0,className:"vgai-number-input-editor"}):z.jsx("div",{onPointerDown:fe,className:"vgai-number-input-scrub","data-mixed":ee||void 0,"data-disabled":d||void 0,children:ue})]})}const kFr={minHeight:"var(--vgai-panel-header-height)",padding:`0 ${U_[4]}px`,color:Oo.content.muted,fontSize:"var(--vgai-font-base)",fontWeight:U_e.semibold,textTransform:"uppercase",display:"flex",alignItems:"center",gap:U_[2],userSelect:"none"},IFr={...kFr,background:"var(--vgai-surface-sticky)",borderBottom:"1px solid var(--vgai-structural-divider)",flexShrink:0};function Oze({name:t,actions:r,onHeaderClick:i,hideHeader:a=!1,style:l,children:d,..._}){return z.jsxs("div",{..._,style:{display:"flex",flexDirection:"column",pointerEvents:"auto",...l},children:[!a&&z.jsxs("div",{role:i?"button":void 0,tabIndex:i?0:void 0,onClick:i,onKeyDown:i?g=>{g.key==="Enter"&&i()}:void 0,style:{...IFr,cursor:i?"pointer":void 0,pointerEvents:"auto"},children:[z.jsx("span",{style:{flexShrink:0},children:t}),r&&z.jsx("div",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:U_[3]},children:r})]}),d]})}function DFr({label:t,icon:r,description:i,actions:a,collapsible:l=!0,defaultOpen:d=!0,children:_}){const[g,b]=Xe.useState(d),S=z.jsxs("span",{className:"vgai-section-title",children:[z.jsx("span",{children:t}),i?z.jsx("small",{children:i}):null]});return z.jsxs("section",{className:"vgai-section",children:[z.jsxs("div",{className:"vgai-section-header",children:[l?z.jsxs("button",{type:"button",className:"vgai-section-trigger","aria-expanded":g,onClick:()=>b(!g),children:[z.jsx(A3t,{direction:g?"down":"right",style:{fontSize:"var(--vgai-section-disclosure-size, var(--vgai-icon-xs))"}}),r&&z.jsx(So,{icon:r,tone:"dim",className:"vgai-section-glyph"}),S]}):z.jsxs("div",{className:"vgai-section-trigger","data-vgai-static":!0,children:[r&&z.jsx(So,{icon:r,tone:"dim",className:"vgai-section-glyph"}),S]}),a?z.jsx("div",{className:"vgai-section-actions",children:a}):null]}),(g||!l)&&z.jsx("div",{className:"vgai-section-body",children:_})]})}const e8=8,t8=6;function PFr(t){return t==="top"?"bottom":t==="bottom"?"top":t==="left"?"right":"left"}function NFr(t,r,i){return t==="top"?r.top-i.height-t8>=e8:t==="bottom"?r.bottom+i.height+t8<=window.innerHeight-e8:t==="left"?r.left-i.width-t8>=e8:r.right+i.width+t8<=window.innerWidth-e8}function OFr(t,r,i){let a=r.left+(r.width-i.width)/2,l=r.top+(r.height-i.height)/2;return t==="top"?l=r.top-i.height-t8:t==="bottom"?l=r.bottom+t8:t==="left"?a=r.left-i.width-t8:a=r.right+t8,{left:Math.max(e8,Math.min(a,window.innerWidth-i.width-e8)),top:Math.max(e8,Math.min(l,window.innerHeight-i.height-e8)),ready:!0}}function ph({text:t,hotkey:r,children:i,position:a="bottom",delay:l=400}){const d=Xe.useId(),_=Xe.useRef(null),g=Xe.useRef(null),b=Xe.useRef(null),S=Xe.useRef(!1),k=Xe.useRef(!1),[w,N]=Xe.useState(!1),[P,j]=Xe.useState(null),[J,X]=Xe.useState({left:0,top:0,ready:!1});Xe.useLayoutEffect(()=>{j(_.current?.closest(".vgai-editor-theme")??null)},[]),Xe.useEffect(()=>()=>{b.current&&clearTimeout(b.current)},[]);const G=()=>{b.current&&clearTimeout(b.current),b.current=null,N(!1)},ee=()=>{!S.current&&!k.current&&G()},xe=fe=>{b.current&&clearTimeout(b.current),b.current=setTimeout(()=>{X(se=>({...se,ready:!1})),N(!0)},fe)};Xe.useLayoutEffect(()=>{if(!w)return;const fe=()=>{const se=_.current?.getBoundingClientRect(),de=g.current?.getBoundingClientRect();if(!se||!de)return;const ge=NFr(a,se,de)?a:PFr(a);X(OFr(ge,se,de))};return fe(),window.addEventListener("resize",fe),window.addEventListener("scroll",fe,!0),()=>{window.removeEventListener("resize",fe),window.removeEventListener("scroll",fe,!0)}},[r,a,t,w]);let ue=i;if(Xe.isValidElement(i)){const fe=[i.props["aria-describedby"],w?d:null].filter(Boolean).join(" ");ue=Xe.cloneElement(i,fe?{"aria-describedby":fe}:{})}return z.jsxs("span",{ref:_,className:"vgai-tooltip-anchor",onMouseEnter:()=>{S.current=!0,xe(l)},onMouseLeave:()=>{S.current=!1,ee()},onFocusCapture:()=>{k.current=!0,xe(0)},onBlurCapture:fe=>{fe.currentTarget.contains(fe.relatedTarget)||(k.current=!1,ee())},children:[ue,w&&P&&vS.createPortal(z.jsxs("div",{ref:g,id:d,role:"tooltip",className:"vgai-tooltip",style:{left:J.left,top:J.top,visibility:J.ready?"visible":"hidden"},children:[z.jsx("span",{children:t}),r&&z.jsx("kbd",{children:r})]}),P)]})}function FFr({value:t,onChange:r,onAxisChange:i,step:a=.1,disabled:l=!1,testIdPrefix:d}){const _=b=>d?`${d}-${b}`:void 0,g=b=>S=>{if(i)i(b,S);else{const k=[t[0]??0,t[1]??0,t[2]??0];k[b]=S,r(k)}};return z.jsxs("div",{style:{display:"flex",gap:4},children:[z.jsx(SX,{label:"X",labelColor:"#E06178",value:t[0],onChange:g(0),step:a,disabled:l,style:{flex:1},testId:_("x")}),z.jsx(SX,{label:"Y",labelColor:"#C2ED66",value:t[1],onChange:g(1),step:a,disabled:l,style:{flex:1},testId:_("y")}),z.jsx(SX,{label:"Z",labelColor:"#6BABF5",value:t[2],onChange:g(2),step:a,disabled:l,style:{flex:1},testId:_("z")})]})}const IFe={border:Oo.boundary.default,accent:Oo.accent.default,radiusSmall:Oo.shape.small,inputBg:Oo.surface.inset},RFr={fontSize:"var(--vgai-font-base)",fontWeight:600,color:Oo.content.muted,textTransform:"uppercase",letterSpacing:.4},MFr=72,DFe=22,uAt={width:DFe,height:DFe,flex:`0 0 ${DFe}px`,borderRadius:IFe.radiusSmall,border:`1px solid ${IFe.border}`,background:IFe.inputBg,objectFit:"cover",backgroundImage:"linear-gradient(45deg,rgba(128,128,128,.35) 25%,transparent 25%,transparent 75%,rgba(128,128,128,.35) 75%),linear-gradient(45deg,rgba(128,128,128,.35) 25%,transparent 25%,transparent 75%,rgba(128,128,128,.35) 75%)",backgroundSize:"8px 8px",backgroundPosition:"0 0, 4px 4px"};function LFr({value:t,onChange:r,options:i,previewUrlFor:a,disabled:l,note:d,testId:_}){const g=t&&!i.includes(t)?[t,...i]:i;return z.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:2,minWidth:0,flex:1},children:[z.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4,minWidth:0},children:[t?z.jsx("img",{src:a(t),alt:"",style:uAt,"data-testid":`${_}-thumb`}):z.jsx("span",{style:uAt,"aria-hidden":"true"}),z.jsxs(bS,{"data-testid":_,disabled:l,value:t,title:t||"No texture assigned",onChange:b=>r(b.target.value),style:{flex:1,minWidth:0},children:[z.jsx("option",{value:"",children:"—"}),g.map(b=>z.jsx("option",{value:b,children:b},b))]}),z.jsx(rf,{"data-testid":`${_}-clear`,"aria-label":"Clear this texture slot",title:"Clear this texture slot",disabled:l||!t,onClick:()=>r(""),children:z.jsx(So,{icon:eze})})]}),d&&z.jsx("span",{"data-testid":`${_}-note`,style:{fontSize:"var(--vgai-font-sm)",color:Oo.content.muted},children:d})]})}function uMe({value:t,onCommit:r,onKeyDown:i,onFocus:a,...l}){const[d,_]=Xe.useState(null),g=Xe.useRef(!1),b=()=>{!g.current&&d!==null&&d!==t&&r(d),g.current=!1,_(null)};return z.jsx(k_,{...l,value:d??t,onFocus:S=>{_(t),a?.(S)},onChange:S=>_(S.target.value),onBlur:b,onKeyDown:S=>{S.key==="Enter"&&S.target.blur(),S.key==="Escape"&&(g.current=!0,S.target.blur()),i?.(S)}})}const m9=1e4;async function xE(t,r=4e3){if(t())return!0;const i=performance.now();return new Promise(a=>{const l=()=>{t()?a(!0):performance.now()-i>=r?a(!1):setTimeout(l,25)};setTimeout(l,0)})}const xX=new Map,Fq=new Set,She=new Set,J_e=new Set;let S3t=0;function x3t(){S3t+=1;for(const t of[...Fq])t()}function jFr(t,r){return xX.set(t,r),x3t(),()=>{xX.get(t)===r&&xX.delete(t)}}function BFr(t){xX.has(t)&&x3t()}function $Fr(t){return Fq.add(t),()=>{Fq.delete(t)}}function fAt(){return S3t}function _Z(t){return xX.get(t)}function w3t(t,r=1e4){const i=_Z(t);return i!==void 0?Promise.resolve(i):new Promise(a=>{const l=()=>{const _=_Z(t);_!==void 0&&(clearTimeout(d),Fq.delete(l),a(_))},d=setTimeout(()=>{Fq.delete(l),a(void 0)},r);Fq.add(l)})}function C3t(t){She.add(t);for(const r of[...J_e])r();return()=>{She.delete(t)}}function E3t(t,r=1e4){return She.has(t)?Promise.resolve(!0):new Promise(i=>{const a=()=>{She.has(t)&&(clearTimeout(l),J_e.delete(a),i(!0))},l=setTimeout(()=>{J_e.delete(a),i(!1)},r);J_e.add(a)})}async function Fze(t){if(jOr(t)&&!await xE(()=>Pw(t)!==null,m9))throw new Error(`The requested Object3D view did not mount for document: ${t}`)}let fMe=null;const UY=new Map;let PR=[];function qFr(t){if(fMe=t,!t)return;const r=PR;PR=[];for(const i of r)T3t(t,i)}function T3t(t,r){UY.get(r.id)?.();const i=t.show(r),a=()=>{UY.get(r.id)===a&&(UY.delete(r.id),i(),r.onDismiss?.())};return UY.set(r.id,a),a}let zFr=0;function az(t){const r=t.id??`notification-${++zFr}`,i={...t,id:r};return fMe?T3t(fMe,i):(PR=[...PR.filter(a=>a.id!==r),i],()=>Rze(r))}function Rze(t){const r=UY.get(t);if(r){r();return}const i=PR.find(a=>a.id===t);i&&(PR=PR.filter(a=>a.id!==t),i.onDismiss?.())}let iI={sessions:[],selectedSessionId:null,selectedSession:null,cursorMs:0,liveEdgeMs:0,loading:!0,error:null},xhe=!0,Mpe=null,W_e=null,sY=null,H_e=!1;const VY=new Set;function UFr(t,r,i){const a=t[0]??null;return a!==null&&r.length>0&&!r.some(d=>d.id===a.id)?{sessionId:a.id,latestAppeared:!0}:i&&t.some(d=>d.id===i)?{sessionId:i,latestAppeared:!1}:{sessionId:a?.id??null,latestAppeared:!1}}function whe(t){iI=t;for(const r of VY)r()}async function VFr(){const t=await fetch("/__editor/gameplay-sessions");return(await Eg(t,"Could not load Gameplay Sessions")).sessions}async function JFr(t){return Eg(await fetch(`/__editor/gameplay-sessions/${encodeURIComponent(t)}`),"Could not load the selected Gameplay Session").then(r=>r.session)}async function WFr(){try{const t={sessions:await VFr()},r=UFr(t.sessions,iI.sessions,W_e),i=r.sessionId;r.latestAppeared&&(xhe=!0),W_e=i;const a=i?await JFr(i):null;if(W_e!==i){H_e=!0;return}const l=t.sessions.map(g=>g.id===a?.id?a:g),d=a?.durationMs??0,_=xhe?d:Math.min(iI.cursorMs,d);whe({sessions:l,selectedSessionId:i,selectedSession:a,cursorMs:_,liveEdgeMs:d,loading:!1,error:null})}catch(t){whe({...iI,loading:!1,error:t instanceof Error?t.message:String(t)})}}function mZ(){return sY?(H_e=!0,sY):(sY=WFr().finally(()=>{sY=null,H_e&&(H_e=!1,mZ())}),sY)}function HFr(t){return VY.add(t),VY.size===1&&(mZ(),Mpe=window.setInterval(()=>void mZ(),1e3)),()=>{VY.delete(t),VY.size===0&&Mpe!==null&&(window.clearInterval(Mpe),Mpe=null)}}function GFr(t){const r=iI.sessions.find(i=>i.id===t);r&&(W_e=r.id,xhe=!0,whe({...iI,selectedSessionId:r.id,selectedSession:r,cursorMs:r.durationMs,liveEdgeMs:r.durationMs}),mZ())}function QFr(t){const r=Math.max(0,Math.min(t,iI.liveEdgeMs));xhe=iI.liveEdgeMs-r<250,whe({...iI,cursorMs:r})}const k3t={getSnapshot:()=>iI,subscribe:HFr,select:GFr,seek:QFr,refresh:mZ};let KFr=null;const dAt=new Set,PDn={getSnapshot:()=>KFr,subscribe(t){return dAt.add(t),()=>dAt.delete(t)}};let G_e={phase:null,run:0},I3t=null;function YFr(t){I3t=t}function pAt(t){G_e=t;try{I3t?.(t)}catch{}}function D3t(t,r=Date.now()){return pAt({phase:t,at:r,run:G_e.run}),()=>{G_e.phase===t&&pAt({phase:null,at:Date.now(),run:G_e.run})}}const XFr=Xe.lazy(()=>Xo(()=>import("./GameplaySessionTimeline-DE0985zy.js"),__vite__mapDeps([44,1,2,3,4,8,9,10,11,6])).then(t=>({default:t.GameplaySessionTimeline})));class Mze extends Xe.Component{state={error:null};static getDerivedStateFromError(r){return{error:r}}componentDidCatch(r,i){console.error(`[tools] ${this.props.file} crashed while rendering:`,r,i.componentStack)}render(){return this.state.error?z.jsxs("div",{style:{padding:U_[6],fontSize:"var(--vgai-font-md)",color:Oo.semantic.danger,maxWidth:640},children:[z.jsxs("div",{style:{fontWeight:600,marginBottom:U_[2]},children:["Tool crashed: ",z.jsx("code",{children:this.props.file})]}),z.jsx("div",{style:{whiteSpace:"pre-wrap"},children:String(this.state.error)}),z.jsx("div",{style:{color:Oo.content.muted,marginTop:U_[3]},children:"The editor is fine — fix the tool file and save; it reloads in place."})]}):this.props.children}}function ZFr({contribution:t,Component:r,documentId:i,active:a,document:l,accountRevision:d,playKey:_}){const g=Xe.useRef(null),[b,S]=Xe.useState(null),k=Xe.useRef(null),w=Xe.useRef(null),N=Xe.useRef(t.file);N.current=t.file;const P=Xe.useRef(i);return P.current=i,Xe.useEffect(()=>{const j=g.current;if(!j)return;let J=!1;S(null);const X=(xe,ue)=>{if(J)return;const fe=xe instanceof Error?xe:new Error(String(xe));console.error(`[tools] ${N.current} crashed while rendering:`,fe,ue?.componentStack),S(fe),P.current&&C3t(P.current)},G=j.appendChild(document.createElement("div"));G.style.display="contents";const ee=Hqe.createRoot(G,{onUncaughtError:X});return k.current=ee,()=>{J=!0,k.current=null,w.current?.(),w.current=null,queueMicrotask(()=>{ee.unmount(),G.remove()})}},[]),Xe.useEffect(()=>{const j=k.current;if(!j)return;S(null);const J={contributionId:t.id,client:b0e(),surfaces:wze,account:mze(),work:ee=>{w.current?.(),w.current=ee===null?null:D3t(`building ${ee.replace(/^building /,"")}`)},notify:ee=>az({...ee,id:`contribution:${t.id}:${ee.title}`,...ee.tone==="warning"?{fades:!0}:{}}),...t.point==="workspace.analytics"?{gameplaySessions:k3t}:{play:Xye()},...i?{documentId:i,publishContext:ee=>jFr(i,ee)}:{},...a!==void 0?{active:a}:{},...l?{document:l}:{}},X=r??t.Component,G=Xe.createElement(X,{...J,...t.tool?{tool:t.tool}:{}});j.render(i?Xe.createElement(e7r,{documentId:i},G):G)},[d,a,t,r,i,l,_]),z.jsxs(z.Fragment,{children:[b?z.jsxs("div",{style:{padding:U_[6],color:Oo.semantic.danger},children:["Tool crashed: ",z.jsx("code",{children:t.file}),z.jsx("div",{style:{whiteSpace:"pre-wrap",marginTop:U_[2]},children:String(b)})]}):null,z.jsx("div",{ref:g,style:{minHeight:0,width:"100%"}})]})}function e7r({documentId:t,children:r}){return Xe.useEffect(()=>C3t(t),[t]),z.jsx(z.Fragment,{children:r})}function h9({contribution:t,Component:r,documentId:i,active:a,document:l}){const d=Xe.useSyncExternalStore(Yye,T8,T8),_=Xe.useSyncExternalStore(Zye,k8,k8),g=t.point==="workspace.analytics"?"gameplay-sessions":_;return z.jsxs("div",{"data-testid":`tool-panel-${t.id}`,style:{flex:1,minHeight:0,overflow:t.point==="workspace.analytics"?"visible":"auto",color:Oo.content.primary,display:"flex",flexDirection:"column"},children:[t.point==="workspace.analytics"?z.jsx(Xe.Suspense,{fallback:null,children:z.jsx(XFr,{})}):null,z.jsx(Mze,{file:t.file,children:z.jsx("div",{style:{flex:1,minHeight:0,overflow:"auto"},children:z.jsx(ZFr,{contribution:t,...r?{Component:r}:{},accountRevision:d,playKey:g,...i?{documentId:i}:{},...a!==void 0?{active:a}:{},...l?{document:l}:{}})})})]})}function t7r({id:t,title:r,file:i,tool:a,Component:l,adapter:d,nodeId:_}){Xe.useSyncExternalStore(Yye,T8,T8),Xe.useSyncExternalStore(Zye,k8,k8);const g=_?d.hierarchy.node(_):null;return z.jsx("div",{className:"vgai-inspector-tool-section","data-testid":`inspector-tool-${t}`,children:z.jsx(Mze,{file:i,children:z.jsx(S3r,{adapter:d,nodeId:_,children:z.jsx(l,{...a?{tool:a}:{},contributionId:t.slice(t.lastIndexOf(":")+1),client:b0e(),surfaces:wze,account:mze(),play:Xye(),node:g,nodeId:_,adapter:d})})})})}const r7r=Symbol("vgai.inspection.mixed");function dMe(t){return t===r7r}function Lze(t){return t.readonlyReason??"This field is read-only."}function jze(t){return"column"}function Bze(t,r){return t.quickActions.filter(i=>i.placement===r)}const pMe="preview",_At="transform",PFe="properties",P3t="stories";function mAt(t){return`group:${t}`}const N3t=100,n7r=1e3,hZ=2e3,O3t=3e3,i7r=4e3,s7r=5e3,o7r={nullSubjectId:null};function F3t(t){return"sections"in t}const Q_e=[];let R3t=0;const _Me=new Set;function hAt(){R3t++;for(const t of _Me)t()}function a7r(t){return _Me.add(t),()=>{_Me.delete(t)}}function gAt(){return R3t}function M3t(t){return Q_e.push(t),hAt(),()=>{const r=Q_e.indexOf(t);r>=0&&(Q_e.splice(r,1),hAt())}}function yAt(t,r,i=o7r){return Q_e.filter(a=>a.match(t,r,i))}function L3t(t){if(typeof t!="object"||t===null)return!1;const r=t.name;return r==="Canceled"||r==="CancellationError"||r==="AbortError"}const c7r=1e3;class l7r{_entries=[];_listeners=new Set;_nextId=0;_version=0;_notifyScheduled=!1;_sink=null;setSink(r){this._sink=r}counts={info:0,warn:0,error:0};log(r,i){this._push("info",r,i)}warn(r,i){this._push("warn",r,i)}error(r,i){this._push("error",r,i)}logStructured(r,i,a,l,d){this._push(r,i,a,l,d)}clear(){this._entries=[],this.counts={info:0,warn:0,error:0},this._notify()}getEntries(){return this._entries}subscribe=r=>(this._listeners.add(r),()=>this._listeners.delete(r));getSnapshot=()=>this._version;_push(r,i,a,l,d){const _=this._entries[this._entries.length-1];if(_&&_.level===r&&_.message===i&&_.source===a&&_.metadata?.instanceId===d?.instanceId){_.count++,_.timestamp=Date.now(),this._sink?.(_),this._notify();return}const g={id:this._nextId++,timestamp:Date.now(),level:r,message:i,count:1};if(a&&(g.source=a),l&&(g.subsystem=l),d&&(g.metadata=d),this._entries.push(g),this.counts[r]++,this._sink?.(g),this._entries.length>c7r){const b=this._entries.shift();this.counts[b.level]=Math.max(0,this.counts[b.level]-1)}this._notify()}_notify(){this._version++,!this._notifyScheduled&&(this._notifyScheduled=!0,queueMicrotask(()=>{this._notifyScheduled=!1;for(const r of this._listeners)r()}))}}const ua=new l7r;typeof window<"u"&&(window.__vgaiEditorConsole=ua);const vAt=1e3,bAt=4e3;function Rq(t){try{return String(t)}catch{return Object.prototype.toString.call(t)}}function u7r(t){if(typeof t!="object"||t===null)return Rq(t);const r=new WeakSet;let i;try{i=JSON.stringify(t,(a,l)=>typeof l!="object"||l===null?l:r.has(l)?"[Circular]":(r.add(l),l))}catch{i=void 0}return i===void 0?Rq(t):i.length>vAt?`${i.slice(0,vAt)}…`:i}function j3t(t){if(t.length===0)return"";const[r,...i]=t;if(typeof r!="string"||i.length===0)return t.map(Rq).join(" ");let a=0;const l=r.replace(/%([sdifoOjc%])/g,(_,g)=>{if(g==="%")return"%";if(a>=i.length)return _;const b=i[a++];switch(g){case"s":return typeof b=="string"?b:Rq(b);case"d":case"i":{if(typeof b=="symbol")return"NaN";if(typeof b=="bigint")return String(b);const S=Number(b);return Number.isFinite(S)?String(Math.trunc(S)):String(S)}case"f":return typeof b=="symbol"?"NaN":String(Number(b));case"c":return"";default:return u7r(b)}}),d=i.slice(a);return d.length===0?l:`${l} ${d.map(Rq).join(" ")}`}function f7r(t,r){const i=t[0];if(typeof i!="string"||!/^(Encountered two children with the same key|Each child in a list should have a unique|Maximum update depth exceeded|Cannot update a component)/.test(i))return r;try{const a=Xe.captureOwnerStack?.();return a?`${r}
|
|
44
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const _ of t.seen.entries()){const g=_[1];if(r===_[0]){d(_);continue}if(t.external){const S=t.external.registry.get(_[0])?.id;if(r!==_[0]&&S){d(_);continue}}if(t.metadataRegistry.get(_[0])?.id){d(_);continue}if(g.cycle){d(_);continue}if(g.count>1&&t.reused==="ref"){d(_);continue}}}function fhe(t,r){const i=t.seen.get(r);if(!i)throw new Error("Unprocessed schema. This is a bug in Zod.");const a=_=>{const g=t.seen.get(_);if(g.ref===null)return;const b=g.def??g.schema,S={...b},k=g.ref;if(g.ref=null,k){a(k);const N=t.seen.get(k),P=N.schema;if(P.$ref&&(t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0")?(b.allOf=b.allOf??[],b.allOf.push(P)):Object.assign(b,P),Object.assign(b,S),_._zod.parent===k)for(const J in b)J==="$ref"||J==="allOf"||J in S||delete b[J];if(P.$ref&&N.def)for(const J in b)J==="$ref"||J==="allOf"||J in N.def&&JSON.stringify(b[J])===JSON.stringify(N.def[J])&&delete b[J]}const w=_._zod.parent;if(w&&w!==k){a(w);const N=t.seen.get(w);if(N?.schema.$ref&&(b.$ref=N.schema.$ref,N.def))for(const P in b)P==="$ref"||P==="allOf"||P in N.def&&JSON.stringify(b[P])===JSON.stringify(N.def[P])&&delete b[P]}t.override({zodSchema:_,jsonSchema:b,path:g.path??[]})};for(const _ of[...t.seen.entries()].reverse())a(_[0]);const l={};if(t.target==="draft-2020-12"?l.$schema="https://json-schema.org/draft/2020-12/schema":t.target==="draft-07"?l.$schema="http://json-schema.org/draft-07/schema#":t.target==="draft-04"?l.$schema="http://json-schema.org/draft-04/schema#":t.target,t.external?.uri){const _=t.external.registry.get(r)?.id;if(!_)throw new Error("Schema is missing an `id` property");l.$id=t.external.uri(_)}Object.assign(l,i.def??i.schema);const d=t.external?.defs??{};for(const _ of t.seen.entries()){const g=_[1];g.def&&g.defId&&(d[g.defId]=g.def)}t.external||Object.keys(d).length>0&&(t.target==="draft-2020-12"?l.$defs=d:l.definitions=d);try{const _=JSON.parse(JSON.stringify(l));return Object.defineProperty(_,"~standard",{value:{...r["~standard"],jsonSchema:{input:dhe(r,"input",t.processors),output:dhe(r,"output",t.processors)}},enumerable:!1,writable:!1}),_}catch{throw new Error("Error converting schema to JSON.")}}function mb(t,r){const i=r??{seen:new Set};if(i.seen.has(t))return!1;i.seen.add(t);const a=t._zod.def;if(a.type==="transform")return!0;if(a.type==="array")return mb(a.element,i);if(a.type==="set")return mb(a.valueType,i);if(a.type==="lazy")return mb(a.getter(),i);if(a.type==="promise"||a.type==="optional"||a.type==="nonoptional"||a.type==="nullable"||a.type==="readonly"||a.type==="default"||a.type==="prefault")return mb(a.innerType,i);if(a.type==="intersection")return mb(a.left,i)||mb(a.right,i);if(a.type==="record"||a.type==="map")return mb(a.keyType,i)||mb(a.valueType,i);if(a.type==="pipe")return mb(a.in,i)||mb(a.out,i);if(a.type==="object"){for(const l in a.shape)if(mb(a.shape[l],i))return!0;return!1}if(a.type==="union"){for(const l of a.options)if(mb(l,i))return!0;return!1}if(a.type==="tuple"){for(const l of a.items)if(mb(l,i))return!0;return!!(a.rest&&mb(a.rest,i))}return!1}const x6r=(t,r={})=>i=>{const a=lhe({...i,processors:r});return J_(t,a),uhe(a,t),fhe(a,t)},dhe=(t,r,i={})=>a=>{const{libraryOptions:l,target:d}=a??{},_=lhe({...l??{},target:d,io:r,processors:i});return J_(t,_),uhe(_,t),fhe(_,t)},w6r={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},GIt=(t,r,i,a)=>{const l=i;l.type="string";const{minimum:d,maximum:_,format:g,patterns:b,contentEncoding:S}=t._zod.bag;if(typeof d=="number"&&(l.minLength=d),typeof _=="number"&&(l.maxLength=_),g&&(l.format=w6r[g]??g,l.format===""&&delete l.format,g==="time"&&delete l.format),S&&(l.contentEncoding=S),b&&b.size>0){const k=[...b];k.length===1?l.pattern=k[0].source:k.length>1&&(l.allOf=[...k.map(w=>({...r.target==="draft-07"||r.target==="draft-04"||r.target==="openapi-3.0"?{type:"string"}:{},pattern:w.source}))])}},QIt=(t,r,i,a)=>{const l=i,{minimum:d,maximum:_,format:g,multipleOf:b,exclusiveMaximum:S,exclusiveMinimum:k}=t._zod.bag;typeof g=="string"&&g.includes("int")?l.type="integer":l.type="number",typeof k=="number"&&(r.target==="draft-04"||r.target==="openapi-3.0"?(l.minimum=k,l.exclusiveMinimum=!0):l.exclusiveMinimum=k),typeof d=="number"&&(l.minimum=d,typeof k=="number"&&r.target!=="draft-04"&&(k>=d?delete l.minimum:delete l.exclusiveMinimum)),typeof S=="number"&&(r.target==="draft-04"||r.target==="openapi-3.0"?(l.maximum=S,l.exclusiveMaximum=!0):l.exclusiveMaximum=S),typeof _=="number"&&(l.maximum=_,typeof S=="number"&&r.target!=="draft-04"&&(S<=_?delete l.maximum:delete l.exclusiveMaximum)),typeof b=="number"&&(l.multipleOf=b)},KIt=(t,r,i,a)=>{i.type="boolean"},C6r=(t,r,i,a)=>{if(r.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema")},E6r=(t,r,i,a)=>{if(r.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema")},T6r=(t,r,i,a)=>{r.target==="openapi-3.0"?(i.type="string",i.nullable=!0,i.enum=[null]):i.type="null"},k6r=(t,r,i,a)=>{if(r.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema")},I6r=(t,r,i,a)=>{if(r.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema")},YIt=(t,r,i,a)=>{i.not={}},D6r=(t,r,i,a)=>{},XIt=(t,r,i,a)=>{},P6r=(t,r,i,a)=>{if(r.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema")},ZIt=(t,r,i,a)=>{const l=t._zod.def,d=TIt(l.entries);d.every(_=>typeof _=="number")&&(i.type="number"),d.every(_=>typeof _=="string")&&(i.type="string"),i.enum=d},eDt=(t,r,i,a)=>{const l=t._zod.def,d=[];for(const _ of l.values)if(_===void 0){if(r.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof _=="bigint"){if(r.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");d.push(Number(_))}else d.push(_);if(d.length!==0)if(d.length===1){const _=d[0];i.type=_===null?"null":typeof _,r.target==="draft-04"||r.target==="openapi-3.0"?i.enum=[_]:i.const=_}else d.every(_=>typeof _=="number")&&(i.type="number"),d.every(_=>typeof _=="string")&&(i.type="string"),d.every(_=>typeof _=="boolean")&&(i.type="boolean"),d.every(_=>_===null)&&(i.type="null"),i.enum=d},N6r=(t,r,i,a)=>{if(r.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema")},O6r=(t,r,i,a)=>{const l=i,d=t._zod.pattern;if(!d)throw new Error("Pattern not found in template literal");l.type="string",l.pattern=d.source},F6r=(t,r,i,a)=>{const l=i,d={type:"string",format:"binary",contentEncoding:"binary"},{minimum:_,maximum:g,mime:b}=t._zod.bag;_!==void 0&&(d.minLength=_),g!==void 0&&(d.maxLength=g),b?b.length===1?(d.contentMediaType=b[0],Object.assign(l,d)):(Object.assign(l,d),l.anyOf=b.map(S=>({contentMediaType:S}))):Object.assign(l,d)},R6r=(t,r,i,a)=>{i.type="boolean"},tDt=(t,r,i,a)=>{if(r.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},M6r=(t,r,i,a)=>{if(r.unrepresentable==="throw")throw new Error("Function types cannot be represented in JSON Schema")},rDt=(t,r,i,a)=>{if(r.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},L6r=(t,r,i,a)=>{if(r.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema")},j6r=(t,r,i,a)=>{if(r.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema")},nDt=(t,r,i,a)=>{const l=i,d=t._zod.def,{minimum:_,maximum:g}=t._zod.bag;typeof _=="number"&&(l.minItems=_),typeof g=="number"&&(l.maxItems=g),l.type="array",l.items=J_(d.element,r,{...a,path:[...a.path,"items"]})},iDt=(t,r,i,a)=>{const l=i,d=t._zod.def;l.type="object",l.properties={};const _=d.shape;for(const S in _)l.properties[S]=J_(_[S],r,{...a,path:[...a.path,"properties",S]});const g=new Set(Object.keys(_)),b=new Set([...g].filter(S=>{const k=d.shape[S]._zod;return r.io==="input"?k.optin===void 0:k.optout===void 0}));b.size>0&&(l.required=Array.from(b)),d.catchall?._zod.def.type==="never"?l.additionalProperties=!1:d.catchall?d.catchall&&(l.additionalProperties=J_(d.catchall,r,{...a,path:[...a.path,"additionalProperties"]})):r.io==="output"&&(l.additionalProperties=!1)},sDt=(t,r,i,a)=>{const l=t._zod.def,d=l.inclusive===!1,_=l.options.map((g,b)=>J_(g,r,{...a,path:[...a.path,d?"oneOf":"anyOf",b]}));d?i.oneOf=_:i.anyOf=_},oDt=(t,r,i,a)=>{const l=t._zod.def,d=J_(l.left,r,{...a,path:[...a.path,"allOf",0]}),_=J_(l.right,r,{...a,path:[...a.path,"allOf",1]}),g=S=>"allOf"in S&&Object.keys(S).length===1,b=[...g(d)?d.allOf:[d],...g(_)?_.allOf:[_]];i.allOf=b},aDt=(t,r,i,a)=>{const l=i,d=t._zod.def;l.type="array";const _=r.target==="draft-2020-12"?"prefixItems":"items",g=r.target==="draft-2020-12"||r.target==="openapi-3.0"?"items":"additionalItems",b=d.items.map((N,P)=>J_(N,r,{...a,path:[...a.path,_,P]})),S=d.rest?J_(d.rest,r,{...a,path:[...a.path,g,...r.target==="openapi-3.0"?[d.items.length]:[]]}):null;r.target==="draft-2020-12"?(l.prefixItems=b,S&&(l.items=S)):r.target==="openapi-3.0"?(l.items={anyOf:b},S&&l.items.anyOf.push(S),l.minItems=b.length,S||(l.maxItems=b.length)):(l.items=b,S&&(l.additionalItems=S));const{minimum:k,maximum:w}=t._zod.bag;typeof k=="number"&&(l.minItems=k),typeof w=="number"&&(l.maxItems=w)},cDt=(t,r,i,a)=>{const l=i,d=t._zod.def;l.type="object";const _=d.keyType,b=_._zod.bag?.patterns;if(d.mode==="loose"&&b&&b.size>0){const k=J_(d.valueType,r,{...a,path:[...a.path,"patternProperties","*"]});l.patternProperties={};for(const w of b)l.patternProperties[w.source]=k}else(r.target==="draft-07"||r.target==="draft-2020-12")&&(l.propertyNames=J_(d.keyType,r,{...a,path:[...a.path,"propertyNames"]})),l.additionalProperties=J_(d.valueType,r,{...a,path:[...a.path,"additionalProperties"]});const S=_._zod.values;if(S){const k=[...S].filter(w=>typeof w=="string"||typeof w=="number");k.length>0&&(l.required=k)}},lDt=(t,r,i,a)=>{const l=t._zod.def,d=J_(l.innerType,r,a),_=r.seen.get(t);r.target==="openapi-3.0"?(_.ref=l.innerType,i.nullable=!0):i.anyOf=[d,{type:"null"}]},uDt=(t,r,i,a)=>{const l=t._zod.def;J_(l.innerType,r,a);const d=r.seen.get(t);d.ref=l.innerType},fDt=(t,r,i,a)=>{const l=t._zod.def;J_(l.innerType,r,a);const d=r.seen.get(t);d.ref=l.innerType,i.default=JSON.parse(JSON.stringify(l.defaultValue))},dDt=(t,r,i,a)=>{const l=t._zod.def;J_(l.innerType,r,a);const d=r.seen.get(t);d.ref=l.innerType,r.io==="input"&&(i._prefault=JSON.parse(JSON.stringify(l.defaultValue)))},pDt=(t,r,i,a)=>{const l=t._zod.def;J_(l.innerType,r,a);const d=r.seen.get(t);d.ref=l.innerType;let _;try{_=l.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}i.default=_},_Dt=(t,r,i,a)=>{const l=t._zod.def,d=r.io==="input"?l.in._zod.def.type==="transform"?l.out:l.in:l.out;J_(d,r,a);const _=r.seen.get(t);_.ref=d},mDt=(t,r,i,a)=>{const l=t._zod.def;J_(l.innerType,r,a);const d=r.seen.get(t);d.ref=l.innerType,i.readOnly=!0},B6r=(t,r,i,a)=>{const l=t._zod.def;J_(l.innerType,r,a);const d=r.seen.get(t);d.ref=l.innerType},fze=(t,r,i,a)=>{const l=t._zod.def;J_(l.innerType,r,a);const d=r.seen.get(t);d.ref=l.innerType},hDt=(t,r,i,a)=>{const l=t._zod.innerType;J_(l,r,a);const d=r.seen.get(t);d.ref=l},Sbt={string:GIt,number:QIt,boolean:KIt,bigint:C6r,symbol:E6r,null:T6r,undefined:k6r,void:I6r,never:YIt,any:D6r,unknown:XIt,date:P6r,enum:ZIt,literal:eDt,nan:N6r,template_literal:O6r,file:F6r,success:R6r,custom:tDt,function:M6r,transform:rDt,map:L6r,set:j6r,array:nDt,object:iDt,union:sDt,intersection:oDt,tuple:aDt,record:cDt,nullable:lDt,nonoptional:uDt,default:fDt,prefault:dDt,catch:pDt,pipe:_Dt,readonly:mDt,promise:B6r,optional:fze,lazy:hDt};function $6r(t,r){if("_idmap"in t){const a=t,l=lhe({...r,processors:Sbt}),d={};for(const b of a._idmap.entries()){const[S,k]=b;J_(k,l)}const _={},g={registry:a,uri:r?.uri,defs:d};l.external=g;for(const b of a._idmap.entries()){const[S,k]=b;uhe(l,k),_[S]=fhe(l,k)}if(Object.keys(d).length>0){const b=l.target==="draft-2020-12"?"$defs":"definitions";_.__shared={[b]:d}}return{schemas:_}}const i=lhe({...r,processors:Sbt});return J_(t,i),uhe(i,t),fhe(i,t)}const q6r=ys("ZodISODateTime",(t,r)=>{VPr.init(t,r),gh.init(t,r)});function z6r(t){return X4r(q6r,t)}const U6r=ys("ZodISODate",(t,r)=>{JPr.init(t,r),gh.init(t,r)});function V6r(t){return Z4r(U6r,t)}const J6r=ys("ZodISOTime",(t,r)=>{WPr.init(t,r),gh.init(t,r)});function W6r(t){return e6r(J6r,t)}const H6r=ys("ZodISODuration",(t,r)=>{HPr.init(t,r),gh.init(t,r)});function G6r(t){return t6r(H6r,t)}const Q6r=(t,r)=>{PIt.init(t,r),t.name="ZodError",Object.defineProperties(t,{format:{value:i=>L3r(t,i)},flatten:{value:i=>M3r(t,i)},addIssue:{value:i=>{t.issues.push(i),t.message=JSON.stringify(t.issues,P9e,2)}},addIssues:{value:i=>{t.issues.push(...i),t.message=JSON.stringify(t.issues,P9e,2)}},isEmpty:{get(){return t.issues.length===0}}})},Dw=ys("ZodError",Q6r,{Parent:Error}),K6r=cze(Dw),Y6r=lze(Dw),X6r=Hye(Dw),Z6r=Gye(Dw),eNr=$3r(Dw),tNr=q3r(Dw),rNr=z3r(Dw),nNr=U3r(Dw),iNr=V3r(Dw),sNr=J3r(Dw),oNr=W3r(Dw),aNr=H3r(Dw),Cm=ys("ZodType",(t,r)=>(H_.init(t,r),Object.assign(t["~standard"],{jsonSchema:{input:dhe(t,"input"),output:dhe(t,"output")}}),t.toJSONSchema=x6r(t,{}),t.def=r,t.type=r.type,Object.defineProperty(t,"_def",{value:r}),t.check=(...i)=>t.clone(Q8(r,{checks:[...r.checks??[],...i.map(a=>typeof a=="function"?{_zod:{check:a,def:{check:"custom"},onattach:[]}}:a)]}),{parent:!0}),t.with=t.check,t.clone=(i,a)=>K8(t,i,a),t.brand=()=>t,t.register=((i,a)=>(i.add(t,a),t)),t.parse=(i,a)=>K6r(t,i,a,{callee:t.parse}),t.safeParse=(i,a)=>X6r(t,i,a),t.parseAsync=async(i,a)=>Y6r(t,i,a,{callee:t.parseAsync}),t.safeParseAsync=async(i,a)=>Z6r(t,i,a),t.spa=t.safeParseAsync,t.encode=(i,a)=>eNr(t,i,a),t.decode=(i,a)=>tNr(t,i,a),t.encodeAsync=async(i,a)=>rNr(t,i,a),t.decodeAsync=async(i,a)=>nNr(t,i,a),t.safeEncode=(i,a)=>iNr(t,i,a),t.safeDecode=(i,a)=>sNr(t,i,a),t.safeEncodeAsync=async(i,a)=>oNr(t,i,a),t.safeDecodeAsync=async(i,a)=>aNr(t,i,a),t.refine=(i,a)=>t.check(e8r(i,a)),t.superRefine=i=>t.check(t8r(i)),t.overwrite=i=>t.check(tU(i)),t.optional=()=>Tbt(t),t.exactOptional=()=>qNr(t),t.nullable=()=>kbt(t),t.nullish=()=>Tbt(kbt(t)),t.nonoptional=i=>HNr(t,i),t.array=()=>o_(t),t.or=i=>Aee([t,i]),t.and=i=>bDt(t,i),t.transform=i=>F9e(t,ADt(i)),t.default=i=>VNr(t,i),t.prefault=i=>WNr(t,i),t.catch=i=>QNr(t,i),t.pipe=i=>F9e(t,i),t.readonly=()=>XNr(t),t.describe=i=>{const a=t.clone();return qY.add(a,{description:i}),a},Object.defineProperty(t,"description",{get(){return qY.get(t)?.description},configurable:!0}),t.meta=(...i)=>{if(i.length===0)return qY.get(t);const a=t.clone();return qY.add(a,i[0]),a},t.isOptional=()=>t.safeParse(void 0).success,t.isNullable=()=>t.safeParse(null).success,t.apply=i=>i(t),t)),gDt=ys("_ZodString",(t,r)=>{uze.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(a,l,d)=>GIt(t,a,l);const i=t._zod.bag;t.format=i.format??null,t.minLength=i.minimum??null,t.maxLength=i.maximum??null,t.regex=(...a)=>t.check(a6r(...a)),t.includes=(...a)=>t.check(u6r(...a)),t.startsWith=(...a)=>t.check(f6r(...a)),t.endsWith=(...a)=>t.check(d6r(...a)),t.min=(...a)=>t.check(che(...a)),t.max=(...a)=>t.check(WIt(...a)),t.length=(...a)=>t.check(HIt(...a)),t.nonempty=(...a)=>t.check(che(1,...a)),t.lowercase=a=>t.check(c6r(a)),t.uppercase=a=>t.check(l6r(a)),t.trim=()=>t.check(_6r()),t.normalize=(...a)=>t.check(p6r(...a)),t.toLowerCase=()=>t.check(m6r()),t.toUpperCase=()=>t.check(h6r()),t.slugify=()=>t.check(g6r())}),cNr=ys("ZodString",(t,r)=>{uze.init(t,r),gDt.init(t,r),t.email=i=>t.check(P4r(lNr,i)),t.url=i=>t.check(M4r(uNr,i)),t.jwt=i=>t.check(Y4r(CNr,i)),t.emoji=i=>t.check(L4r(fNr,i)),t.guid=i=>t.check(ybt(xbt,i)),t.uuid=i=>t.check(N4r(Dpe,i)),t.uuidv4=i=>t.check(O4r(Dpe,i)),t.uuidv6=i=>t.check(F4r(Dpe,i)),t.uuidv7=i=>t.check(R4r(Dpe,i)),t.nanoid=i=>t.check(j4r(dNr,i)),t.guid=i=>t.check(ybt(xbt,i)),t.cuid=i=>t.check(B4r(pNr,i)),t.cuid2=i=>t.check($4r(_Nr,i)),t.ulid=i=>t.check(q4r(mNr,i)),t.base64=i=>t.check(G4r(SNr,i)),t.base64url=i=>t.check(Q4r(xNr,i)),t.xid=i=>t.check(z4r(hNr,i)),t.ksuid=i=>t.check(U4r(gNr,i)),t.ipv4=i=>t.check(V4r(yNr,i)),t.ipv6=i=>t.check(J4r(vNr,i)),t.cidrv4=i=>t.check(W4r(bNr,i)),t.cidrv6=i=>t.check(H4r(ANr,i)),t.e164=i=>t.check(K4r(wNr,i)),t.datetime=i=>t.check(z6r(i)),t.date=i=>t.check(V6r(i)),t.time=i=>t.check(W6r(i)),t.duration=i=>t.check(G6r(i))});function Ss(t){return D4r(cNr,t)}const gh=ys("ZodStringFormat",(t,r)=>{jm.init(t,r),gDt.init(t,r)}),lNr=ys("ZodEmail",(t,r)=>{RPr.init(t,r),gh.init(t,r)}),xbt=ys("ZodGUID",(t,r)=>{OPr.init(t,r),gh.init(t,r)}),Dpe=ys("ZodUUID",(t,r)=>{FPr.init(t,r),gh.init(t,r)}),uNr=ys("ZodURL",(t,r)=>{MPr.init(t,r),gh.init(t,r)}),fNr=ys("ZodEmoji",(t,r)=>{LPr.init(t,r),gh.init(t,r)}),dNr=ys("ZodNanoID",(t,r)=>{jPr.init(t,r),gh.init(t,r)}),pNr=ys("ZodCUID",(t,r)=>{BPr.init(t,r),gh.init(t,r)}),_Nr=ys("ZodCUID2",(t,r)=>{$Pr.init(t,r),gh.init(t,r)}),mNr=ys("ZodULID",(t,r)=>{qPr.init(t,r),gh.init(t,r)}),hNr=ys("ZodXID",(t,r)=>{zPr.init(t,r),gh.init(t,r)}),gNr=ys("ZodKSUID",(t,r)=>{UPr.init(t,r),gh.init(t,r)}),yNr=ys("ZodIPv4",(t,r)=>{GPr.init(t,r),gh.init(t,r)}),vNr=ys("ZodIPv6",(t,r)=>{QPr.init(t,r),gh.init(t,r)}),bNr=ys("ZodCIDRv4",(t,r)=>{KPr.init(t,r),gh.init(t,r)}),ANr=ys("ZodCIDRv6",(t,r)=>{YPr.init(t,r),gh.init(t,r)}),SNr=ys("ZodBase64",(t,r)=>{XPr.init(t,r),gh.init(t,r)}),xNr=ys("ZodBase64URL",(t,r)=>{e4r.init(t,r),gh.init(t,r)}),wNr=ys("ZodE164",(t,r)=>{t4r.init(t,r),gh.init(t,r)}),CNr=ys("ZodJWT",(t,r)=>{n4r.init(t,r),gh.init(t,r)}),yDt=ys("ZodNumber",(t,r)=>{qIt.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(a,l,d)=>QIt(t,a,l),t.gt=(a,l)=>t.check(bbt(a,l)),t.gte=(a,l)=>t.check(xFe(a,l)),t.min=(a,l)=>t.check(xFe(a,l)),t.lt=(a,l)=>t.check(vbt(a,l)),t.lte=(a,l)=>t.check(SFe(a,l)),t.max=(a,l)=>t.check(SFe(a,l)),t.int=a=>t.check(wbt(a)),t.safe=a=>t.check(wbt(a)),t.positive=a=>t.check(bbt(0,a)),t.nonnegative=a=>t.check(xFe(0,a)),t.negative=a=>t.check(vbt(0,a)),t.nonpositive=a=>t.check(SFe(0,a)),t.multipleOf=(a,l)=>t.check(Abt(a,l)),t.step=(a,l)=>t.check(Abt(a,l)),t.finite=()=>t;const i=t._zod.bag;t.minValue=Math.max(i.minimum??Number.NEGATIVE_INFINITY,i.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,t.maxValue=Math.min(i.maximum??Number.POSITIVE_INFINITY,i.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,t.isInt=(i.format??"").includes("int")||Number.isSafeInteger(i.multipleOf??.5),t.isFinite=!0,t.format=i.format??null});function Tu(t){return r6r(yDt,t)}const ENr=ys("ZodNumberFormat",(t,r)=>{i4r.init(t,r),yDt.init(t,r)});function wbt(t){return n6r(ENr,t)}const TNr=ys("ZodBoolean",(t,r)=>{s4r.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(i,a,l)=>KIt(t,i,a)});function gv(t){return i6r(TNr,t)}const kNr=ys("ZodUnknown",(t,r)=>{o4r.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(i,a,l)=>XIt()});function Cbt(){return s6r(kNr)}const INr=ys("ZodNever",(t,r)=>{a4r.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(i,a,l)=>YIt(t,i,a)});function DNr(t){return o6r(INr,t)}const PNr=ys("ZodArray",(t,r)=>{c4r.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(i,a,l)=>nDt(t,i,a,l),t.element=r.element,t.min=(i,a)=>t.check(che(i,a)),t.nonempty=i=>t.check(che(1,i)),t.max=(i,a)=>t.check(WIt(i,a)),t.length=(i,a)=>t.check(HIt(i,a)),t.unwrap=()=>t.element});function o_(t,r){return y6r(PNr,t,r)}const NNr=ys("ZodObject",(t,r)=>{u4r.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(i,a,l)=>iDt(t,i,a,l),Vf(t,"shape",()=>r.shape),t.keyof=()=>jd(Object.keys(t._zod.def.shape)),t.catchall=i=>t.clone({...t._zod.def,catchall:i}),t.passthrough=()=>t.clone({...t._zod.def,catchall:Cbt()}),t.loose=()=>t.clone({...t._zod.def,catchall:Cbt()}),t.strict=()=>t.clone({...t._zod.def,catchall:DNr()}),t.strip=()=>t.clone({...t._zod.def,catchall:void 0}),t.extend=i=>P3r(t,i),t.safeExtend=i=>N3r(t,i),t.merge=i=>O3r(t,i),t.pick=i=>I3r(t,i),t.omit=i=>D3r(t,i),t.partial=(...i)=>F3r(SDt,t,i[0]),t.required=(...i)=>R3r(xDt,t,i[0])});function Na(t,r){const i={type:"object",shape:t??{},...kc(r)};return new NNr(i)}const vDt=ys("ZodUnion",(t,r)=>{VIt.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(i,a,l)=>sDt(t,i,a,l),t.options=r.options});function Aee(t,r){return new vDt({type:"union",options:t,...kc(r)})}const ONr=ys("ZodDiscriminatedUnion",(t,r)=>{vDt.init(t,r),f4r.init(t,r)});function FNr(t,r,i){return new ONr({type:"union",options:r,discriminator:t,...kc(i)})}const RNr=ys("ZodIntersection",(t,r)=>{d4r.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(i,a,l)=>oDt(t,i,a,l)});function bDt(t,r){return new RNr({type:"intersection",left:t,right:r})}const MNr=ys("ZodTuple",(t,r)=>{p4r.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(i,a,l)=>aDt(t,i,a,l),t.rest=i=>t.clone({...t._zod.def,rest:i})});function Ebt(t,r,i){const a=r instanceof H_,l=a?i:r,d=a?r:null;return new MNr({type:"tuple",items:t,rest:d,...kc(l)})}const LNr=ys("ZodRecord",(t,r)=>{_4r.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(i,a,l)=>cDt(t,i,a,l),t.keyType=r.keyType,t.valueType=r.valueType});function UR(t,r,i){return new LNr({type:"record",keyType:t,valueType:r,...kc(i)})}const O9e=ys("ZodEnum",(t,r)=>{m4r.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(a,l,d)=>ZIt(t,a,l),t.enum=r.entries,t.options=Object.values(r.entries);const i=new Set(Object.keys(r.entries));t.extract=(a,l)=>{const d={};for(const _ of a)if(i.has(_))d[_]=r.entries[_];else throw new Error(`Key ${_} not found in enum`);return new O9e({...r,checks:[],...kc(l),entries:d})},t.exclude=(a,l)=>{const d={...r.entries};for(const _ of a)if(i.has(_))delete d[_];else throw new Error(`Key ${_} not found in enum`);return new O9e({...r,checks:[],...kc(l),entries:d})}});function jd(t,r){const i=Array.isArray(t)?Object.fromEntries(t.map(a=>[a,a])):t;return new O9e({type:"enum",entries:i,...kc(r)})}const jNr=ys("ZodLiteral",(t,r)=>{h4r.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(i,a,l)=>eDt(t,i,a),t.values=new Set(r.values),Object.defineProperty(t,"value",{get(){if(r.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return r.values[0]}})});function Ry(t,r){return new jNr({type:"literal",values:Array.isArray(t)?t:[t],...kc(r)})}const BNr=ys("ZodTransform",(t,r)=>{g4r.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(i,a,l)=>rDt(t,i),t._zod.parse=(i,a)=>{if(a.direction==="backward")throw new CIt(t.constructor.name);i.addIssue=d=>{if(typeof d=="string")i.issues.push(cZ(d,i.value,r));else{const _=d;_.fatal&&(_.continue=!1),_.code??(_.code="custom"),_.input??(_.input=i.value),_.inst??(_.inst=t),i.issues.push(cZ(_))}};const l=r.transform(i.value,i);return l instanceof Promise?l.then(d=>(i.value=d,i)):(i.value=l,i)}});function ADt(t){return new BNr({type:"transform",transform:t})}const SDt=ys("ZodOptional",(t,r)=>{JIt.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(i,a,l)=>fze(t,i,a,l),t.unwrap=()=>t._zod.def.innerType});function Tbt(t){return new SDt({type:"optional",innerType:t})}const $Nr=ys("ZodExactOptional",(t,r)=>{y4r.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(i,a,l)=>fze(t,i,a,l),t.unwrap=()=>t._zod.def.innerType});function qNr(t){return new $Nr({type:"optional",innerType:t})}const zNr=ys("ZodNullable",(t,r)=>{v4r.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(i,a,l)=>lDt(t,i,a,l),t.unwrap=()=>t._zod.def.innerType});function kbt(t){return new zNr({type:"nullable",innerType:t})}const UNr=ys("ZodDefault",(t,r)=>{b4r.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(i,a,l)=>fDt(t,i,a,l),t.unwrap=()=>t._zod.def.innerType,t.removeDefault=t.unwrap});function VNr(t,r){return new UNr({type:"default",innerType:t,get defaultValue(){return typeof r=="function"?r():IIt(r)}})}const JNr=ys("ZodPrefault",(t,r)=>{A4r.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(i,a,l)=>dDt(t,i,a,l),t.unwrap=()=>t._zod.def.innerType});function WNr(t,r){return new JNr({type:"prefault",innerType:t,get defaultValue(){return typeof r=="function"?r():IIt(r)}})}const xDt=ys("ZodNonOptional",(t,r)=>{S4r.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(i,a,l)=>uDt(t,i,a,l),t.unwrap=()=>t._zod.def.innerType});function HNr(t,r){return new xDt({type:"nonoptional",innerType:t,...kc(r)})}const GNr=ys("ZodCatch",(t,r)=>{x4r.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(i,a,l)=>pDt(t,i,a,l),t.unwrap=()=>t._zod.def.innerType,t.removeCatch=t.unwrap});function QNr(t,r){return new GNr({type:"catch",innerType:t,catchValue:typeof r=="function"?r:()=>r})}const KNr=ys("ZodPipe",(t,r)=>{w4r.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(i,a,l)=>_Dt(t,i,a,l),t.in=r.in,t.out=r.out});function F9e(t,r){return new KNr({type:"pipe",in:t,out:r})}const YNr=ys("ZodReadonly",(t,r)=>{C4r.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(i,a,l)=>mDt(t,i,a,l),t.unwrap=()=>t._zod.def.innerType});function XNr(t){return new YNr({type:"readonly",innerType:t})}const ZNr=ys("ZodLazy",(t,r)=>{E4r.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(i,a,l)=>hDt(t,i,a,l),t.unwrap=()=>t._zod.def.getter()});function hDn(t){return new ZNr({type:"lazy",getter:t})}const dze=ys("ZodCustom",(t,r)=>{T4r.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(i,a,l)=>tDt(t,i)});function IR(t,r){return v6r(dze,t??(()=>!0),r)}function e8r(t,r={}){return b6r(dze,t,r)}function t8r(t){return A6r(t)}function gDn(t,r={}){const i=new dze({type:"custom",check:"custom",fn:a=>a instanceof t,abort:!0,...kc(r)});return i._zod.bag.Class=t,i._zod.check=a=>{a.value instanceof t||a.issues.push({code:"invalid_type",expected:t.name,input:a.value,inst:i,path:[...i._zod.def.path??[]]})},i}function r8r(t,r){return F9e(ADt(t),r)}const Ibt={custom:"custom"},Dbt=jd(["mock","live"]),n8r=Na({id:Ss().min(1),name:Ss().min(1),status:jd(["free","trialing","active","past_due","cancelling"]),interval:jd(["month","year"]).optional(),renewsAt:Ss().datetime().optional(),endsAt:Ss().datetime().optional()}),i8r=Na({included:Tu().nonnegative(),purchased:Tu().nonnegative(),used:Tu().nonnegative(),reserved:Tu().nonnegative(),remaining:Tu().nonnegative(),resetsAt:Ss().datetime().optional(),purchasedExpiresAt:Ss().datetime().optional()}),s8r=Na({overageEnabled:gv(),monthlyLimitCredits:Tu().nonnegative(),alertThresholds:o_(Tu().min(1).max(100)).max(8),autoReload:Na({enabled:gv(),whenRemainingBelow:Tu().nonnegative(),reloadTo:Tu().positive(),monthlyLimitCredits:Tu().nonnegative()}).optional()}),o8r=Na({id:Ss().min(1),kind:jd(["threshold","auto_reload_succeeded","auto_reload_failed"]),message:Ss().min(1),createdAt:Ss().datetime(),readAt:Ss().datetime().optional()}),a8r=Na({id:Ss().min(1),email:Ss().email(),name:Ss().min(1).optional()}),c8r=Na({name:Ss().min(1),verified:gv(),enrollmentMode:jd(["manual_invitation","automatic_invitation","automatic_suggestion","enterprise_sso"])}),l8r=Na({id:Ss().min(1),name:Ss().min(1),slug:Ss().min(1).optional(),role:Ss().min(1),domains:o_(c8r).max(50)}),u8r=Na({id:Ss().min(1),occurredAt:Ss().datetime(),kind:jd(["inference","generation","workspace","storage","relay","deployment"]),provider:Ss().min(1),operation:Ss().optional(),credits:Tu().nonnegative(),state:jd(["reserved","settled","released"]),externalId:Ss().optional()});jd(["free","creator","max","ultra"]);const f8r=Na({plans:Na({free:Na({name:Ss().min(1),includedCredits:Tu().int().nonnegative(),monthlyPriceUsd:Tu().nonnegative().optional()}),creator:Na({name:Ss().min(1),includedCredits:Tu().int().nonnegative(),monthlyPriceUsd:Tu().nonnegative().optional()}),max:Na({name:Ss().min(1),includedCredits:Tu().int().nonnegative(),monthlyPriceUsd:Tu().nonnegative().optional()}),ultra:Na({name:Ss().min(1),includedCredits:Tu().int().nonnegative(),monthlyPriceUsd:Tu().nonnegative().optional()})}),creditPacks:UR(Ss().min(1),Na({name:Ss().min(1),credits:Tu().int().positive(),expiresInDays:Tu().int().positive().optional()}))}),d8r=FNr("authenticated",[Na({authenticated:Ry(!1),backend:Dbt}),Na({authenticated:Ry(!0),backend:Dbt,user:a8r,organizations:o_(l8r).max(100).optional(),plan:n8r,credits:i8r,spendPolicy:s8r,alerts:o_(o8r).max(100).optional(),entitlements:Na({generation:gv(),dailyJobs:Tu().int().positive().optional()})})]),p8r=jd(["auto","mock","managed","byok"]),wDt=jd(["fal","tripo","worldlabs","openrouter"]),_8r=Na({enabled:gv(),provider:Ry("openrouter"),model:Ss().trim().min(1).max(256)}),m8r=jd(["environment","system","session","none"]),h8r=Na({provider:wDt,label:Ss().min(1),environmentVariable:Ss().min(1),configured:gv(),source:m8r,editable:gv(),persistence:jd(["system","session"]),maskedKey:Ss().min(1).optional(),problem:Ss().min(1).optional()}),g8r=Na({provider:wDt,ok:Ry(!0),testedAt:Ss().datetime()});function y8r(t){return{routes:{mock:!0,managed:t.routes.managed,byok:t.routes.byok,byokProviders:[...t.routes.byokProviders]},preferredRoute:t.preferredRoute}}const Kye=bDt(d8r,Na({accountEnvironment:jd(["test-mock","development-twin","production"]),routes:Na({mock:Ry(!0),managed:gv(),byok:gv(),byokProviders:o_(Ss().min(1))}),preferredRoute:p8r,providerCredentials:o_(h8r),codingInference:_8r}));function v8r(t,r){return`${t}: this origin answered with its page fallback (${r||"no content-type"}) rather than JSON, so no editor server handled the request.`}function np(t,r){const i=t.headers.get("content-type")??"";if(!i.includes("application/json"))throw new Error(v8r(r,i))}function rU(t,r){if(!t.ok)throw new Error(`${r} (${t.status}).`);np(t,r)}async function Eg(t,r){return rU(t,r),await t.json()}const Pbt="vgai.collaboration.participant.v1",b8r="vgai.collaboration.remote-share.v1",R9e=globalThis.__VGAI_EDITOR_PRESENCE_BOOTSTRAP__;function A8r(){if(R9e?.participantId)return R9e.participantId;const t=globalThis.crypto?.randomUUID?.()??`participant-${Date.now()}`;try{const r=globalThis.localStorage?.getItem(Pbt);if(r)return r;globalThis.localStorage?.setItem(Pbt,t)}catch{}return t}const CDt=A8r(),pze=(()=>{try{return globalThis.localStorage?.getItem(b8r)==="1"}catch{return!1}})(),S8r=R9e?.displayName||"Local editor";let M9e=0;function EDt(t){Number.isInteger(t)&&t>=M9e&&(M9e=t)}function yw(){return{participantId:CDt,expectedRevision:M9e}}const x8r={authenticated:!1,backend:"mock",accountEnvironment:"test-mock",routes:{mock:!0,managed:!1,byok:!1,byokProviders:[]},preferredRoute:"auto",providerCredentials:[],codingInference:{enabled:!1,provider:"openrouter",model:"z-ai/glm-5.2"}};let iz=x8r,TDt=0,L9e=null;const j9e=new Set;function VR(t,r=null){if(!(L9e===r&&JSON.stringify(iz)===JSON.stringify(t))){iz=t,L9e=r,TDt++;for(const i of j9e)i()}}async function kDt(t,r){np(t,r);const i=await t.json();if(!t.ok)throw new Error(typeof i.error=="string"?String(i.error):`Account request failed (${t.status}).`);return Kye.parse(i)}async function IE(t,r,i){const a=await fetch(t,{method:r,...i===void 0?{}:{headers:{"Content-Type":"application/json"},body:JSON.stringify(i)}}),l=await kDt(a,`${r} ${t} failed`);return VR(l),l}function _ze(){return iz}function mze(){return y8r(iz)}function T8(){return TDt}function Ppe(){return L9e}function Yye(t){return j9e.add(t),()=>j9e.delete(t)}async function Nbt(){try{const t=await kDt(await fetch("/__editor/account"),"Account read failed");return VR(t),t}catch(t){throw VR(iz,t instanceof Error?t.message:String(t)),t}}const w8r=t=>IE("/__editor/account/mock-session","POST",{email:t}),C8r=t=>IE("/__editor/account/twin-session","POST",{email:t}),E8r=()=>IE("/__editor/account/session","DELETE"),T8r=t=>IE("/__editor/account/spend-policy","PUT",t),k8r=()=>IE("/__editor/account/alerts/read","POST"),I8r=t=>IE("/__editor/account/execution-route","PUT",{route:t}),D8r=t=>IE("/__editor/account/coding-inference","PUT",t);async function P8r(t){const r=await fetch("/__editor/account/coding-inference/quote",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});np(r,"Coding quote failed");const i=await r.json();if(!r.ok||typeof i.model!="string"||typeof i.promptTokens!="number"||typeof i.outputTokens!="number"||typeof i.providerAmountUsd!="number"||typeof i.estimatedCredits!="number")throw new Error(typeof i.error=="string"?i.error:"Coding quote failed.");return i}const N8r=(t,r)=>IE(`/__editor/account/provider-credentials/${encodeURIComponent(t)}`,"PUT",{key:r}),O8r=t=>IE(`/__editor/account/provider-credentials/${encodeURIComponent(t)}`,"DELETE");async function F8r(t){const r=await fetch(`/__editor/account/provider-credentials/${encodeURIComponent(t)}/test`,{method:"POST"});np(r,"Credential test failed");const i=await r.json();if(!r.ok)throw new Error(typeof i.error=="string"?i.error:`Credential test failed (${r.status}).`);return g8r.parse(i)}const Obt=t=>IE("/__editor/account/plan","PUT",{action:t});async function IDt(t,r){const i=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json","Idempotency-Key":crypto.randomUUID()},body:JSON.stringify(r)});np(i,"Checkout failed");const a=await i.json();if(!i.ok||!a.account)throw new Error(typeof a.error=="string"?a.error:"Checkout failed.");return VR(Kye.parse(a.account)),{...typeof a.checkoutUrl=="string"?{checkoutUrl:a.checkoutUrl}:{},mock:a.mock===!0}}const R8r=t=>IDt("/__editor/account/checkout",{plan:t}),M8r=t=>IDt("/__editor/account/credits",{packId:t});async function L8r(){const t=await fetch("/__editor/account/usage");np(t,"Usage failed");const r=await t.json();if(!t.ok)throw new Error(typeof r.error=="string"?r.error:"Usage failed.");return u8r.array().parse(r.entries??[])}async function j8r(){const t=await fetch("/__editor/account/catalog");np(t,"Catalog failed");const r=await t.json();if(!t.ok)throw new Error(typeof r.error=="string"?r.error:"Catalog failed.");return f8r.parse(r)}async function B8r(){const t=await fetch("/__editor/account/billing-portal",{method:"POST"});np(t,"Billing portal failed");const r=await t.json();if(!t.ok||typeof r.url!="string")throw new Error(typeof r.error=="string"?r.error:"Billing portal failed.");return{url:r.url,mock:r.mock===!0}}async function $8r(){const t=await fetch("/__editor/account/authorization-methods");np(t,"Sign-in methods are unavailable");const r=await t.json();if(!t.ok||r.browser!==!0||typeof r.device!="boolean")throw new Error(typeof r.error=="string"?r.error:"Sign-in methods are unavailable.");return{browser:!0,device:r.device}}async function q8r(){const t=await fetch("/__editor/account/browser-authorization",{method:"POST"});np(t,"Sign-in failed");const r=await t.json();if(!t.ok)throw new Error(typeof r.error=="string"?r.error:"Sign-in failed.");return r}async function z8r(t){const r=await fetch(`/__editor/account/browser-authorization/${encodeURIComponent(t)}`);np(r,"Sign-in failed");const i=await r.json();if(r.status===202)return!1;if(!r.ok||i.pending!==!1)throw new Error(typeof i.error=="string"?i.error:"Sign-in failed.");return VR(Kye.parse(i.account)),!0}async function U8r(){const t=await fetch("/__editor/account/device-authorization",{method:"POST"});np(t,"Sign-in failed");const r=await t.json();if(!t.ok)throw new Error(typeof r.error=="string"?r.error:"Sign-in failed.");return r}async function V8r(t){const r=await fetch(`/__editor/account/device-authorization/${encodeURIComponent(t)}`);np(r,"Sign-in failed");const i=await r.json();if(r.status===202)return!1;if(!r.ok||i.pending!==!1)throw new Error(typeof i.error=="string"?i.error:"Sign-in failed.");return VR(Kye.parse(i.account)),!0}function J8r(){if(pze)return()=>{};const t=new URLSearchParams(window.location.search).get("checkout_id");t?IE("/__editor/account/checkout/confirm","POST",{checkoutId:t}).then(()=>{const i=new URL(window.location.href);i.searchParams.delete("checkout"),i.searchParams.delete("checkout_id"),window.history.replaceState(null,"",`${i.pathname}${i.search}${i.hash}`)}).catch(i=>VR(iz,i instanceof Error?i.message:String(i))):Nbt().catch(()=>{});const r=window.setInterval(()=>void Nbt().catch(()=>{}),3e4);return()=>window.clearInterval(r)}const W8r={"source-prop":!0,"source-structure":!0,"construction-literal":!0,"physics-binding":!0,"data-record":!0,"live-only":!0},H8r=Object.keys(W8r),G8r={provenance:!0,selection:!0,transforms:!0,inspector:!0,assetSubject:!0,related:!0,instances:!0,structure:!0,persistence:!0,pickable:!0,rects:!0,boxEdit:!0,text:!0,colorSample:!0,stories:!0,truth:!0,spatialHandles:!0,assetDrop:!0,subscribe:!0},Q8r=Object.keys(G8r),phe={claim:0,shape:1,operation:2,effect:3,"round-trip":4};function K8r(t,r){return phe[t]>=phe[r]}function _he(t){const{seam:r,subject:i,epoch:a,required:l}=t;if(t.notApplicable!==void 0)return{seam:r,subject:i,epoch:a,required:l,state:"not-applicable",receipt:null,detail:t.notApplicable};let d=null;for(const _ of t.receipts)_.seam!==r||_.subject!==i||_.epoch!==a||(!d||phe[_.stage]>=phe[d.stage])&&(d=_);return d?d.outcome==="fail"?{seam:r,subject:i,epoch:a,required:l,state:"failed",receipt:d,detail:d.detail}:d.outcome==="absent"?{seam:r,subject:i,epoch:a,required:l,state:"absent",receipt:d,detail:d.detail}:K8r(d.stage,l)?{seam:r,subject:i,epoch:a,required:l,state:"verified",receipt:d,detail:d.detail}:{seam:r,subject:i,epoch:a,required:l,state:"unverified",receipt:d,detail:`${d.detail}; this proves ${d.stage}, but this seam requires ${l}`}:{seam:r,subject:i,epoch:a,required:l,state:"unverified",receipt:null,detail:`no current-epoch evidence has reached the required ${l} stage`}}class Y8r{#e=[];record(r){if(!r.seam||!r.subject||!r.epoch||!r.detail.trim())throw new Error("seam evidence requires non-empty seam, subject, epoch, and detail");this.#e.push(r)}receipts(r){return this.#e.filter(i=>(r?.subject===void 0||i.subject===r.subject)&&(r?.epoch===void 0||i.epoch===r.epoch))}verdict(r){return _he({...r,receipts:this.#e})}clearSubject(r){for(let i=this.#e.length-1;i>=0;i-=1)this.#e[i]?.subject===r&&this.#e.splice(i,1)}clear(){this.#e.length=0}}function jy(){return t=>t}function X8r(t){if(t.value===void 0)return{seam:t.seam,subject:t.subject,epoch:t.epoch,stage:"shape",outcome:t.optional?"absent":"fail",source:"shape-check",detail:t.optional?`${t.seam} is not exposed by this subject`:`${t.seam} is required by the contract but is absent`};const r=typeof t.value,i=t.kind==="function"?r==="function":r!=="function";return{seam:t.seam,subject:t.subject,epoch:t.epoch,stage:"shape",outcome:i?"pass":"fail",source:"shape-check",detail:i?`${t.seam} has the contract's ${t.kind} shape`:`${t.seam} is ${r}; the contract requires a ${t.kind}`}}function wFe(t){const r=[],i=t.value!==null&&(typeof t.value=="object"||typeof t.value=="function")?t.value:null,a=Object.entries(t.shape);for(const[l,d]of a){const _=`${t.prefix}.${l}`,g=i?.[l];r.push(X8r({seam:_,subject:t.subject,epoch:t.epoch,value:g,optional:d.optional,kind:d.kind}))}return r}function Fbt(t){const r=_he(t);if(r.state==="absent"||r.state==="failed"||!t.shape)return r;for(const[i,a]of Object.entries(t.shape)){const l=_he({seam:`${t.seam}.${i}`,subject:t.subject,epoch:t.epoch,required:a.required,receipts:t.receipts});if(!(a.optional&&l.state==="absent")){if(l.state==="failed"||l.state==="absent")return{...r,state:"failed",receipt:l.receipt,detail:`${t.seam} is malformed: ${l.detail}`};if(l.state!=="verified")return{...r,state:"unverified",detail:`${t.seam} has the required shape, but ${l.seam} is unverified: ${l.detail}`}}}return r}const Npe=jy()({capabilities:{optional:!1,kind:"value",required:"shape"},provenance:{optional:!0,kind:"value",required:"shape"},hierarchy:{optional:!1,kind:"value",required:"operation"},selection:{optional:!0,kind:"value",required:"effect"},transforms:{optional:!0,kind:"value",required:"effect"},inspector:{optional:!0,kind:"value",required:"effect"},assetSubject:{optional:!0,kind:"value",required:"operation"},related:{optional:!0,kind:"value",required:"operation"},instances:{optional:!0,kind:"value",required:"effect"},structure:{optional:!0,kind:"value",required:"round-trip"},persistence:{optional:!0,kind:"value",required:"round-trip"},pickable:{optional:!0,kind:"value",required:"operation"},rects:{optional:!0,kind:"value",required:"operation"},boxEdit:{optional:!0,kind:"value",required:"effect"},text:{optional:!0,kind:"value",required:"effect"},colorSample:{optional:!0,kind:"value",required:"operation"},stories:{optional:!0,kind:"value",required:"effect"},truth:{optional:!0,kind:"value",required:"operation"},spatialHandles:{optional:!0,kind:"value",required:"effect"},assetDrop:{optional:!0,kind:"value",required:"round-trip"},subscribe:{optional:!0,kind:"function",required:"effect"}}),Rbt=jy()({roots:{optional:!1,kind:"function",required:"operation"},node:{optional:!1,kind:"function",required:"operation"},crossSurfaceStructureSignature:{optional:!0,kind:"function",required:"operation"},object3D:{optional:!0,kind:"function",required:"operation"},idForObject3D:{optional:!0,kind:"function",required:"operation"}}),Z8r=jy()({get:{optional:!1,kind:"function",required:"operation"},set:{optional:!1,kind:"function",required:"effect"},resolve:{optional:!0,kind:"function",required:"operation"}}),eOr=jy()({dimensions:{optional:!0,kind:"function",required:"operation"},get:{optional:!1,kind:"function",required:"operation"},editability:{optional:!0,kind:"function",required:"operation"},beginEdit:{optional:!1,kind:"function",required:"effect"},apply:{optional:!1,kind:"function",required:"effect"},endEdit:{optional:!1,kind:"function",required:"effect"},remove:{optional:!0,kind:"function",required:"round-trip"},sourceCommit:{optional:!0,kind:"value",required:"round-trip"}}),tOr=jy()({properties:{optional:!1,kind:"function",required:"operation"},get:{optional:!1,kind:"function",required:"operation"},set:{optional:!1,kind:"function",required:"effect"},preview:{optional:!0,kind:"function",required:"effect"},editability:{optional:!0,kind:"function",required:"operation"},remove:{optional:!0,kind:"function",required:"round-trip"}}),rOr=jy()({get:{optional:!1,kind:"function",required:"operation"},entries:{optional:!0,kind:"function",required:"operation"}}),nOr=jy()({links:{optional:!1,kind:"function",required:"operation"}}),iOr=jy()({describe:{optional:!1,kind:"function",required:"operation"},openComponent:{optional:!0,kind:"function",required:"effect"},revert:{optional:!1,kind:"function",required:"round-trip"},applyToComponent:{optional:!1,kind:"function",required:"round-trip"}}),sOr=jy()({create:{optional:!1,kind:"function",required:"round-trip"},remove:{optional:!1,kind:"function",required:"round-trip"},duplicate:{optional:!1,kind:"function",required:"round-trip"},duplicateMany:{optional:!0,kind:"function",required:"round-trip"},reparent:{optional:!1,kind:"function",required:"round-trip"},reorder:{optional:!0,kind:"function",required:"round-trip"},creatableKinds:{optional:!0,kind:"function",required:"operation"},wrap:{optional:!0,kind:"function",required:"round-trip"},unwrap:{optional:!0,kind:"function",required:"round-trip"},group:{optional:!0,kind:"function",required:"round-trip"},ungroup:{optional:!0,kind:"function",required:"round-trip"},canUngroup:{optional:!0,kind:"function",required:"operation"},removeMany:{optional:!0,kind:"function",required:"round-trip"},copy:{optional:!0,kind:"function",required:"effect"},canCopy:{optional:!0,kind:"function",required:"operation"},cut:{optional:!0,kind:"function",required:"round-trip"},paste:{optional:!0,kind:"function",required:"round-trip"},canPaste:{optional:!0,kind:"function",required:"operation"}}),oOr=jy()({isDirty:{optional:!1,kind:"function",required:"operation"},lastError:{optional:!0,kind:"function",required:"operation"},save:{optional:!1,kind:"function",required:"round-trip"},destination:{optional:!1,kind:"value",required:"shape"},applyExternal:{optional:!0,kind:"function",required:"effect"}}),aOr=jy()({pick:{optional:!1,kind:"function",required:"operation"},candidates:{optional:!0,kind:"function",required:"operation"}}),cOr=jy()({storiesFor:{optional:!1,kind:"function",required:"operation"},active:{optional:!1,kind:"function",required:"operation"},apply:{optional:!1,kind:"function",required:"effect"},isolate:{optional:!0,kind:"function",required:"effect"},title:{optional:!0,kind:"value",required:"shape"},unavailable:{optional:!0,kind:"function",required:"operation"}}),lOr=jy()({accepts:{optional:!1,kind:"function",required:"operation"},drop:{optional:!1,kind:"function",required:"round-trip"}}),uOr=jy()({rect:{optional:!1,kind:"function",required:"operation"},contextRects:{optional:!0,kind:"function",required:"operation"},emptyContainers:{optional:!0,kind:"function",required:"operation"}}),fOr=jy()({begin:{optional:!1,kind:"function",required:"effect"},apply:{optional:!1,kind:"function",required:"effect"},end:{optional:!1,kind:"function",required:"effect"},gizmoOrigin:{optional:!0,kind:"function",required:"operation"},referencePoint:{optional:!0,kind:"function",required:"operation"}}),dOr=jy()({get:{optional:!1,kind:"function",required:"operation"},set:{optional:!1,kind:"function",required:"effect"}}),pOr=jy()({backgroundChainAt:{optional:!1,kind:"function",required:"operation"}}),_Or=jy()({resolve:{optional:!1,kind:"function",required:"operation"}}),mOr=jy()({layers:{optional:!1,kind:"function",required:"operation"},preview:{optional:!1,kind:"function",required:"effect"},commit:{optional:!1,kind:"function",required:"round-trip"}}),Mbt={selection:Z8r,transforms:eOr,inspector:tOr,assetSubject:rOr,related:nOr,instances:iOr,structure:sOr,persistence:oOr,pickable:aOr,rects:uOr,boxEdit:fOr,text:dOr,colorSample:pOr,stories:cOr,truth:_Or,spatialHandles:mOr,assetDrop:lOr},DDt=new Y8r;function hOr(t){DDt.record(t)}const Lbt=new WeakMap;let gOr=1;function yOr(t){const r=Lbt.get(t);if(r)return r;const i=`system-${gOr++}`;return Lbt.set(t,i),i}let p9={},hze=null,PDt=null;const mhe=new Set,hhe=new Set,B9e=new Set;let gze=0;function vOr(){for(const t of B9e)t()}function bOr(t){if(t!==FDt())for(const r of mhe)r()}function AOr(t,r){const i=MDt();if(!(t===RDt()&&r.length===i.length&&r.every((a,l)=>a===i[l]))){gze++;for(const a of hhe)a()}}const cI=new Map;let j_e=null;const $9e=new Set,NDt="";function lZ(){return j_e!==null&&cI.has(j_e)?j_e:cI.keys().next().value??null}function ODt(){for(const t of $9e)t()}function SOr(t){const r=lZ();if(j_e=t,r!==lZ()){ODt(),gze++;for(const i of mhe)i();for(const i of hhe)i()}}function xOr(t){return $9e.add(t),()=>$9e.delete(t)}function yze(){const t=lZ();return(t===null?void 0:cI.get(t))??p9}function wOr(t,r=NDt){const i=lZ(),a=FDt(),l=RDt(),d=MDt();cI.delete(r),p9=cI.values().next().value??{},bOr(a),AOr(l,d),vOr(),i!==lZ()&&ODt()}function COr(){for(const t of[...cI.keys()])wOr(null,t);SOr(null)}function EOr(t){return B9e.add(t),()=>B9e.delete(t)}function TOr(){return[...cI.keys()]}function jbt(t){const r=t.filter(l=>l!==NDt),i=t.length>r.length,a=r.map(l=>`"${l}"`);return i&&a.push("the unnamed default (address it with no id at all)"),a.join(", ")}class Bbt extends Error{instances;constructor(r,i){super(r),this.name="InstanceResolutionError",this.instances=i}}function kOr(t){const r=TOr();if(t!==void 0){const i=cI.get(t);if(i)return i;throw new Bbt(r.length===0?`no instance "${t}" — no game is mounted`:`no instance "${t}" — live: ${jbt(r)}`,r)}if(r.length===1)return cI.get(r[0]);if(r.length===0)return p9;throw new Bbt(`${r.length} instances are live (${jbt(r)}) — name one in your program (\`game.instance(id)\`, or \`await game.instances()\` for handles); refusing to guess`,r)}function IOr(){return p9.camera??null}function FDt(){return p9.networking??PDt??null}function DOr(){return yze().networking??PDt??null}function POr(t){return mhe.add(t),()=>mhe.delete(t)}function RDt(){return p9.audio??hze}function NOr(){return yze().audio??hze}function OOr(t){return hhe.add(t),()=>hhe.delete(t)}function FOr(){return gze}function MDt(){const t=new Set;for(const r of cI.values())r.audio&&t.add(r.audio);return t.size,[...t]}function ROr(){return p9.renderDebug??null}const $bt=new Set;function Xye(){return null}function Zye(t){$bt.add(t);const r=xOr(t);return()=>{$bt.delete(t),r()}}function k8(){const t=Xye();return t?`play:${t.instanceId}`:"stopped"}const bX=new Map,K$=new Map,B_e=new Map;let LDt=0;const q9e=new Set;function qbt(){LDt++;for(const t of q9e)t()}function yDn(t){return bX.set(t.documentId,t),qbt(),()=>{bX.get(t.documentId)===t&&(bX.delete(t.documentId),qbt())}}function Pw(t){return bX.get(t)??null}function vDn(t,r){return B_e.set(t,r),()=>{B_e.get(t)===r&&B_e.delete(t)}}async function MOr(t){await B_e.get(t)?.()}function LOr(t){K$.set(t,(K$.get(t)??0)+1);let r=!1;return()=>{if(r)return;r=!0;const i=(K$.get(t)??0)-1;i>0?K$.set(t,i):K$.delete(t)}}function jOr(t){return(K$.get(t)??0)>0}function BOr(){return[...bX.values()]}function e0e(t){return q9e.add(t),()=>q9e.delete(t)}function I8(){return LDt}function t0e(t,r){let i=!1,a=[];const l=()=>{i=!1;const _=a;a=[];for(let g=_.length-1;g>=0;g--)_[g]()};return{ensure(_){if(!i){i=!0;try{_(g=>a.push(g))}catch(g){throw l(),g}}},reset:l}}let W7=[],$Or=0,jDt=0;const z9e=new Set;function zbt(){jDt++;for(const t of z9e)t()}function BDt(t){return z9e.add(t),()=>{z9e.delete(t)}}function Ubt(){return jDt}function iP(t){if(W7.some(i=>i.contribution.id===t.id))throw new Error(`registerWorkspaceStatus: id "${t.id}" is already registered — status ids key status-bar slots, so they must be unique; unregister the previous contribution first.`);const r={contribution:t,seq:$Or++};return W7=[...W7,r],zbt(),()=>{W7.includes(r)&&(W7=W7.filter(i=>i!==r),zbt())}}function U9e(t){const r=i=>[...W7].filter(a=>(a.contribution.align??"left")===i).sort((a,l)=>(a.contribution.order??0)-(l.contribution.order??0)||a.seq-l.seq).map(a=>a.contribution);return t?r(t):[...r("left"),...r("right")]}let $_e=null,$Dt=0;const V9e=new Set;function Vbt(){$Dt++;for(const t of V9e)t()}function qDt(t){return V9e.add(t),()=>V9e.delete(t)}function J9e(){return $Dt}function vze(){return $_e}function qOr(t){const r=Symbol(t.documentId);return $_e={...t,token:r},Vbt(),()=>{$_e?.token===r&&($_e=null,Vbt())}}function zOr(){Xe.useSyncExternalStore(qDt,J9e);const t=vze();return t?.status?z.jsx("span",{className:"vgai-status-copy","data-testid":"status-asset-editor","data-status-tone":"muted",children:t.status}):null}const UOr=t0e();function VOr(){UOr.ensure(t=>{t(iP({id:"asset-editor-status",name:"Asset editor",align:"left",order:40,Content:zOr}))})}VOr();let Dq=null,zDt=0;const W9e=new Set;function Jbt(){zDt+=1;for(const t of W9e)t()}function JOr(t){return W9e.add(t),()=>{W9e.delete(t)}}function Wbt(){return zDt}function WOr(t,r){const i=Symbol(t);return Dq={documentId:t,readSubject:r,token:i},Jbt(),()=>{Dq?.token===i&&(Dq=null,Jbt())}}function H9e(){return Dq===null?null:{documentId:Dq.documentId,subject:Dq.readSubject()}}const D8=new Map,G9e=new Map;function UDt(){typeof window>"u"||window.parent===window||D8.size===0||window.parent.postMessage({type:"vgai:viewport-ready",documents:[...D8.keys()]},"*")}typeof window<"u"&&window.parent!==window&&window.addEventListener("message",t=>{t.source===window.parent&&t.data?.type==="vgai:request-viewport-ready"&&UDt()});let Wu=null,bze=null;function VDt(){if(typeof window>"u")return!1;const t=window.__VGAI_VIEWPORT_TIMINGS__;if(t===!0||t==="1")return!0;try{return new URLSearchParams(window.location.search).get("vgaiTimings")==="1"}catch{return!1}}function HOr(t,r,i){return{documentId:t,visibilityState:typeof document>"u"?"unavailable":document.visibilityState,startedAtMs:r,reactActiveAtMs:null,boardBuildStartedAtMs:null,boardReadyAtMs:null,constructStartedAtMs:null,viewportReadyAtMs:null,rafResumeAtMs:null,firstRenderStartedAtMs:null,workspaceSyncMs:0,revealScheduleMs:0,componentIndexMs:0,componentIndexBusyMs:0,componentIndexWaitMs:0,candidateCollectMs:0,storyMountTotalMs:0,boundsMs:0,layoutMs:0,assembleMs:0,webglContextMs:0,rendererMs:0,adapterSetupMs:0,iblBakeMs:0,dressingMs:0,editorViewportMs:0,framingMs:0,resizeBindMs:0,viewportBindMs:0,firstRenderMs:0,candidateCount:0,exhibitCount:0,skippedCount:0,modulesAlreadyLoaded:i.modulesAlreadyLoaded===!0,stories:[]}}function GOr(t){let r=0,i=0;for(const a of t)r+=Math.max(0,a.runtimeMs)+Math.max(0,a.fiberMs),i+=Math.max(0,a.loadMs)+Math.max(0,a.settleMs);return{busyMs:r,waitMs:i}}function QOr(t,r){const i=t.reactActiveAtMs===null?0:Math.max(0,t.reactActiveAtMs-t.startedAtMs),a=t.reactActiveAtMs??t.startedAtMs,l=t.boardBuildStartedAtMs,d=l===null?0:Math.max(0,l-a),_=t.boardReadyAtMs===null||t.constructStartedAtMs===null?0:Math.max(0,t.constructStartedAtMs-t.boardReadyAtMs),g=t.viewportReadyAtMs??t.rafResumeAtMs,b=t.firstRenderStartedAtMs??r,S=g===null?0:Math.max(0,b-g),k=g===null?Math.max(0,r-t.startedAtMs):Math.max(0,r-g),w=GOr(t.stories),N=t.boardBuildStartedAtMs===null?"switch-back":"first-open",j=KOr({workspaceSyncMs:i,revealScheduleMs:d,componentIndexMs:t.componentIndexMs,componentIndexBusyMs:t.componentIndexBusyMs,componentIndexWaitMs:t.componentIndexWaitMs,candidateCollectMs:t.candidateCollectMs,storyMountTotalMs:t.storyMountTotalMs,storyMountBusyMs:w.busyMs,storyMountWaitMs:w.waitMs,boundsMs:t.boundsMs,layoutMs:t.layoutMs,assembleMs:t.assembleMs,reactCommitMs:_,webglContextMs:t.webglContextMs,rendererMs:t.rendererMs,adapterSetupMs:t.adapterSetupMs,iblBakeMs:t.iblBakeMs,dressingMs:t.dressingMs,editorViewportMs:t.editorViewportMs,framingMs:t.framingMs,resizeBindMs:t.resizeBindMs,viewportBindMs:t.viewportBindMs,rafWaitMs:S,firstRenderMs:t.firstRenderMs}).reduce((X,G)=>X+G.ms,0),J=Math.max(0,r-t.startedAtMs);return{visibilityState:t.visibilityState,startedAtMs:t.startedAtMs,reactActiveAtMs:t.reactActiveAtMs,boardBuildStartedAtMs:t.boardBuildStartedAtMs,boardReadyAtMs:t.boardReadyAtMs,constructStartedAtMs:t.constructStartedAtMs,viewportReadyAtMs:t.viewportReadyAtMs,rafResumeAtMs:t.rafResumeAtMs,firstRenderStartedAtMs:t.firstRenderStartedAtMs,firstFrameAtMs:r,activationKind:N,workspaceSyncMs:i,revealScheduleMs:d,componentIndexMs:t.componentIndexMs,candidateCollectMs:t.candidateCollectMs,storyMountTotalMs:t.storyMountTotalMs,storyMountBusyMs:w.busyMs,storyMountWaitMs:w.waitMs,boundsMs:t.boundsMs,layoutMs:t.layoutMs,assembleMs:t.assembleMs,reactCommitMs:_,webglContextMs:t.webglContextMs,rendererMs:t.rendererMs,adapterSetupMs:t.adapterSetupMs,iblBakeMs:t.iblBakeMs,dressingMs:t.dressingMs,editorViewportMs:t.editorViewportMs,framingMs:t.framingMs,resizeBindMs:t.resizeBindMs,viewportBindMs:t.viewportBindMs,rafWaitMs:S,firstRenderMs:t.firstRenderMs,firstPaintMs:k,unattributedMs:Math.max(0,J-j),accountedMs:j,candidateCount:t.candidateCount,exhibitCount:t.exhibitCount,skippedCount:t.skippedCount,modulesAlreadyLoaded:t.modulesAlreadyLoaded,stories:t.stories,storyDiscovery:bze}}function TA(t,r){const i=Math.max(0,r);return{name:t,ms:i,busyMs:i,waitMs:0,kind:"cpu"}}function Ope(t,r){const i=Math.max(0,r);return{name:t,ms:i,busyMs:0,waitMs:i,kind:"idle"}}function Hbt(t,r,i,a){const l=Math.max(0,r);let d=Math.max(0,i),_=Math.max(0,a);if(d+_>l){const g=l/(d+_);d*=g,_*=g}else d+_<l&&(_+=l-d-_);return{name:t,ms:l,busyMs:d,waitMs:_,kind:"mixed"}}function KOr(t){return[Ope("workspace-sync",t.workspaceSyncMs),Ope("reveal-schedule",t.revealScheduleMs),Hbt("component-index",t.componentIndexMs,t.componentIndexBusyMs,t.componentIndexWaitMs>0||t.componentIndexMs===0?t.componentIndexWaitMs:t.componentIndexMs),TA("candidate-collect",t.candidateCollectMs),Hbt("story-mounts",t.storyMountTotalMs,t.storyMountBusyMs,t.storyMountWaitMs),TA("bounds",t.boundsMs),TA("layout",t.layoutMs),TA("assemble",t.assembleMs),Ope("react-commit (board→viewport)",t.reactCommitMs),TA("webgl-context",t.webglContextMs),TA("renderer",t.rendererMs),TA("adapter-setup",t.adapterSetupMs),TA("ibl-bake (three PMREM)",t.iblBakeMs),TA("dressing",t.dressingMs),TA("editor-viewport",t.editorViewportMs),TA("framing",t.framingMs),TA("resize-bind",t.resizeBindMs),TA("viewport-bind",t.viewportBindMs),Ope("raf-wait",t.rafWaitMs),TA("first-render",t.firstRenderMs)]}function bDn(t,r=Date.now()){const i=(G9e.get(t)??0)+1;G9e.set(t,i);const a={documentId:t,activation:i,firstFrameAtMs:r},l=Wu;if(l&&l.documentId===t){const d={...a,breakdown:QOr(l,r)};return Wu=null,D8.set(t,d),Qbt(),Gbt(),d}return D8.set(t,a),Qbt(),Gbt(),a}let Q9e=new Set;const K9e=new Set;function Gbt(){UDt();for(const t of K9e)t()}function YOr(t){return K9e.add(t),()=>K9e.delete(t)}function Qbt(){D8.size!==0&&JDt()}function JDt(){const t=Q9e;Q9e=new Set;for(const r of t)r()}let Kbt=!1;function XOr(){Kbt||typeof document>"u"||(Kbt=!0,document.addEventListener("visibilitychange",()=>{document.hidden&&JDt()}))}function r0e(){return D8.size>0||typeof document<"u"&&document.hidden?Promise.resolve():(XOr(),new Promise(t=>Q9e.add(t)))}function ZOr(){return[...D8.values()]}function e5r(t){VDt()&&(Wu=HOr(t,Date.now(),{}))}function ADn(t,r,i){if(!Wu)return;const a=Math.max(0,r);switch(t){case"component-index":Wu.componentIndexMs=a,Wu.componentIndexBusyMs=Math.max(0,0),Wu.componentIndexWaitMs=Math.max(0,a);break;case"candidate-collect":Wu.candidateCollectMs=a;break;case"story-mounts":Wu.storyMountTotalMs=a;break;case"bounds":Wu.boundsMs=a;break;case"layout":Wu.layoutMs=a;break;case"assemble":Wu.assembleMs=a;break;case"webgl-context":Wu.webglContextMs=a;break;case"renderer":Wu.rendererMs=a;break;case"adapter-setup":Wu.adapterSetupMs=a;break;case"ibl-bake":Wu.iblBakeMs=a;break;case"dressing":Wu.dressingMs=a;break;case"editor-viewport":Wu.editorViewportMs=a;break;case"framing":Wu.framingMs=a;break;case"resize-bind":Wu.resizeBindMs=a;break;case"viewport-bind":Wu.viewportBindMs=a;break;case"first-render":Wu.firstRenderMs=a;break}}function SDn(t){!Wu||Wu.documentId!==t||Wu.reactActiveAtMs===null&&(Wu.reactActiveAtMs=Date.now())}function xDn(t){!Wu||Wu.documentId!==t||Wu.rafResumeAtMs===null&&(Wu.rafResumeAtMs=Date.now())}function wDn(t){!Wu||Wu.documentId!==t||Wu.firstRenderStartedAtMs===null&&(Wu.firstRenderStartedAtMs=Date.now())}function CDn(){Wu&&(Wu.constructStartedAtMs=Date.now())}function EDn(){Wu&&(Wu.viewportReadyAtMs=Date.now())}function TDn(){return Wu?.documentId??null}function t5r(t){VDt()&&(bze=t)}function r5r(){D8.clear(),G9e.clear(),Wu=null,bze=null}const n5r=["scene","game","world","story","asset","behavior","generation","content-browser","project-tool","tool-contribution","document"];let V_=[],KN=null,OA=null,uZ=null,sz=null;function Ybt(t){queueMicrotask(()=>{sz===t&&V_.some(r=>r.descriptor.id===t)&&(sz=null,xb(t))})}let WDt=0;const Y9e=new Set,CFe=new Set,Aze=new Map,DR=new Map;function lI(){WDt++;for(const t of Y9e)t()}function Aw(t){return Y9e.add(t),()=>{Y9e.delete(t)}}function Sb(){return WDt}function FA(){return V_}function I_(){return OA}function X9e(){return uZ}function i5r(t,r){xb(t)&&uZ!==r&&(uZ=r,lI())}function AE(){return V_.find(t=>t.descriptor.id===OA)??null}function fZ(t){if(t===OA)return;t&&e5r(t);const r=V_.find(a=>a.descriptor.id===OA);OA=t,uZ=null,r?.descriptor.onDeactivate?.(r.descriptor.id);const i=V_.find(a=>a.descriptor.id===t);i?.descriptor.onActivate?.(i.descriptor.id)}function s5r(t,r,i,a){if(r){!i&&a&&KN===t&&(KN=null);return}i&&(KN&&Y8(KN),KN=t)}function qP(t,r={}){const i=sz===t.id,a=i||r.activate!==!1,l=V_.find(_=>_.descriptor.id===t.id);if(s5r(t.id,!!l,r.preview===!0,a),!l)return V_=[...V_,{descriptor:t,dirty:!1,title:t.title}],!t.area&&(a||OA===null)&&fZ(t.id),i&&Ybt(t.id),lI(),t.id;let d=!1;return(l.descriptor.Toolbar!==t.Toolbar||l.descriptor.Shelf!==t.Shelf||l.descriptor.Content!==t.Content)&&(V_=V_.map(_=>{if(_!==l)return _;const{Toolbar:g,Shelf:b,...S}=_.descriptor;return{..._,descriptor:{...S,Content:t.Content,...t.Toolbar?{Toolbar:t.Toolbar}:{},...t.Shelf?{Shelf:t.Shelf}:{}}}}),d=!0),a&&OA!==t.id&&(fZ(t.id),d=!0),d&&lI(),i&&Ybt(t.id),t.id}function xb(t){return V_.some(r=>r.descriptor.id===t)?(OA!==t&&(fZ(t),lI()),!0):!1}function o5r(t){if(xb(t)){sz=null;return}sz=t}function Y8(t,r={}){if(CFe.has(t))return!1;const i=V_.findIndex(l=>l.descriptor.id===t);if(i<0)return!1;const a=V_[i];if(a.dirty&&!r.discardDirty)return!1;CFe.add(t);try{if(OA===t){const d=i>0?V_[i-1]:V_[i+1]??null;fZ(d?d.descriptor.id:null)}return V_=V_.filter(d=>d.descriptor.id!==t),KN===t&&(KN=null),Aze.delete(t),DR.delete(t),a.descriptor.onDispose?.(t),lI(),!0}finally{CFe.delete(t)}}function HDt(){if(V_.length===0&&OA===null)return;const t=V_;fZ(null),V_=[],uZ=null,KN=null,Aze.clear(),DR.clear(),sz=null;for(const r of t)r.descriptor.onDispose?.(r.descriptor.id);lI()}function a5r(t,r){return V_.some(i=>i.descriptor.id===t)?(DR.set(t,r),lI(),()=>{DR.get(t)===r&&(DR.delete(t),lI())}):()=>{}}function kDn(t){DR.has(t)&&lI()}async function c5r(t){if(!V_.some(i=>i.descriptor.id===t))return null;const r=Aze.get(t);if(!r)return null;try{return await r()}catch{return!1}}function l5r(){return OA?c5r(OA):Promise.resolve(null)}function GDt(t,r){const i=V_.find(a=>a.descriptor.id===t);!i||i.title===r||(V_=V_.map(a=>a.descriptor.id===t?{...a,title:r}:a),lI())}function Sze(t){const r=V_.find(a=>a.descriptor.id===t),i=DR.get(t)??r?.descriptor.selection;if(!i)return null;try{return i()}catch{return null}}function n0e(){return OA?Sze(OA):null}const u5r={adapter:null,nodeId:null};function f5r(t){return JSON.stringify({id:t.id,title:t.title,hint:t.hint,kindLabel:t.kindLabel,note:t.note,sections:t.sections.map(r=>({id:r.id,title:r.title,order:r.order,description:r.description,defaultOpen:r.defaultOpen,testId:r.testId,keepMounted:r.keepMounted,railGroup:r.railGroup,bodyKind:r.body.kind})),quickActions:t.quickActions?.map(r=>({id:r.id,title:r.title,label:r.label,placement:r.placement,pressed:r.pressed,disabled:r.disabled}))})}function xze({documentId:t,active:r=!0,type:i,title:a,sections:l,status:d,selection:_}){Xe.useEffect(()=>{if(r)return qOr({documentId:t,title:a,type:i,...d?{status:d}:{}})},[r,t,d,a,i]);const g=Xe.useRef(_);g.current=_,Xe.useEffect(()=>{if(r)return a5r(t,()=>g.current?.()??u5r)},[r,t]);const b={id:t,title:a,kindLabel:i,...d?{note:{text:d,testId:"asset-editor-status"}}:{},sections:l??[]},S=Xe.useRef(b);S.current=b;const k=f5r(b);return Xe.useEffect(()=>{if(r)return WOr(t,()=>S.current)},[r,t,k]),null}function d5r({documentId:t,active:r=!0,type:i,title:a,sections:l,status:d,fill:_=!1,selection:g,children:b}){return z.jsxs("section",{className:"vgai-asset-editor","data-testid":`asset-editor:${i}`,"aria-label":`${a} Asset Editor`,children:[z.jsx(xze,{documentId:t,active:r,type:i,title:a,sections:l,status:d,selection:g}),z.jsx("main",{className:`vgai-asset-editor__viewport${_?" vgai-asset-editor__viewport--fill":""}`,children:b})]})}const p5r=Object.freeze(Object.defineProperty({__proto__:null,AssetEditorShell:d5r,AssetEditorSubject:xze},Symbol.toStringTag,{value:"Module"})),_5r=Xe.lazy(async()=>({default:(await Xo(()=>import("./ToolObject3DPreview-DDdFF5Hq.js"),__vite__mapDeps([38,1,2,39,3,4,8,9,10,6,40,41,11]))).ToolObject3DPreview})),m5r=Xe.lazy(async()=>({default:(await Xo(()=>import("./StageHost-CjZBoXiO.js").then(r=>r.c),__vite__mapDeps([42,1,2,3,4,8,9,6,10,7,40,14,43,41]))).ToolObject3DAuthoring}));function h5r(t){return z.jsx(Xe.Suspense,{fallback:z.jsx("div",{style:{minHeight:240},children:"Loading 3D preview…"}),children:z.jsx(_5r,{...t})})}function g5r(t){return Xe.useEffect(()=>LOr(t.documentId),[t.documentId]),z.jsx(Xe.Suspense,{fallback:z.jsx("div",{style:{minHeight:240},children:"Loading 3D authoring surface…"}),children:z.jsx(m5r,{...t})})}function y5r(t){return z.jsx(xze,{...t})}const wze=Object.freeze({AssetDocument:y5r,Object3DPreview:h5r,Object3DAuthoring:g5r}),Xbt=Object.freeze({id:"classic",shape:{small:"3px",medium:"6px",large:"8px",full:"9999px"},elevation:{small:"0 2px 8px rgba(0,0,0,0.6)",medium:"0 4px 12px rgba(0,0,0,0.5)",large:"0 8px 32px rgba(0,0,0,0.6)"}}),fh=Object.freeze({id:"glass",color:{surface:{shell:"#12161f",panel:"rgba(255,255,255,0.06)",chrome:"rgba(255,255,255,0.10)",raised:"rgba(255,255,255,0.16)",inset:"rgba(10,14,22,0.38)",overlay:"rgba(255,255,255,0.08)"},boundary:{default:"rgba(255,255,255,0.22)",strong:"rgba(255,255,255,0.38)"},neutralOverlay:{hover:"color-mix(in srgb, currentColor 10%, transparent)",active:"color-mix(in srgb, currentColor 16%, transparent)"},scrim:"rgba(8,12,20,0.35)"},shape:{small:"4px",medium:"8px",large:"14px",full:"9999px"},elevation:{small:"0 4px 14px -6px rgba(0,0,0,0.45)",medium:"0 8px 24px -10px rgba(0,0,0,0.5)",large:"0 20px 46px -16px rgba(0,0,0,0.55), 0 4px 14px -6px rgba(0,0,0,0.35)"},treatment:{backdropBlurPx:1,backdropSaturation:1.15,edgeSpecular:.7,specularAngleDeg:120,refractionBezelPx:56,refractionThickness:1.25,textShadowOpacity:.72,contentFrostBlurPx:24,ambientLiftOpacity:.07,adaptiveContent:!0,brightTextShadowOpacity:0,brightFrostBg:"rgba(255,255,255,0.3)"},reducedTransparency:{surface:{shell:"#12161f",panel:"#33373e",chrome:"#3d4047",raised:"#4b4e55",inset:"#23272f",overlay:"#383b43"},scrim:"rgba(8,12,20,0.5)"}}),v5r=["classic","glass"],b5r=Object.freeze([{id:"classic",title:"Classic",description:"Opaque editor surfaces with conventional bars and panels."},{id:"glass",title:"Glass",description:"Adaptive clear material with refraction, frost, and floating chrome."}]),Pq=new Map;let ghe=null;const yhe=new Set;function A5r(){return ghe??=[...b5r,...[...Pq.values()].map(({id:t,title:r,description:i})=>({id:t,title:r,description:i}))],ghe}function S5r(t){return yhe.add(t),()=>yhe.delete(t)}function x5r(t){if(i0e(t.id))throw new Error(`registerContributedMaterial: material "${t.id}" is already registered.`);Pq.set(t.id,t),ghe=null;for(const r of yhe)r();return()=>{if(Pq.get(t.id)===t){Pq.delete(t.id),ghe=null;for(const r of yhe)r()}}}function i0e(t){return typeof t=="string"&&(v5r.includes(t)||Pq.has(t))}function w5r(t,r,i=!1){if(r!=="glass"){const l=Pq.get(r);return{id:l?`${t.id}--${l.id}`:t.id,color:t.color,typography:t.typography,shape:l?.shape??Xbt.shape,elevation:l?.elevation??Xbt.elevation,...l?.density?{density:l.density}:{},appearance:{material:"classic",transparency:"standard"}}}return{id:`${t.id}--${i?"glass-reduced":"glass"}`,color:{surface:i?fh.reducedTransparency.surface:fh.color.surface,boundary:fh.color.boundary,content:t.color.content,accent:t.color.accent,semantic:t.color.semantic,neutralOverlay:fh.color.neutralOverlay,scrim:i?fh.reducedTransparency.scrim:fh.color.scrim},typography:t.typography,shape:fh.shape,elevation:fh.elevation,appearance:{material:"glass",transparency:i?"reduced":"standard"},...i?{}:{treatment:fh.treatment}}}const C5r={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch",baseline:"baseline"},E5r={start:"flex-start",center:"center",end:"flex-end",between:"space-between",around:"space-around",evenly:"space-evenly"};function Fpe(t){return t===0?"0px":t===void 0?void 0:`var(--vgai-space-${t})`}function QDt({gap:t,align:r,justify:i,padding:a,paddingX:l,paddingY:d,style:_}){return{gap:Fpe(t),alignItems:r?C5r[r]:void 0,justifyContent:i?E5r[i]:void 0,padding:Fpe(a),paddingInline:Fpe(l),paddingBlock:Fpe(d),..._}}function s0e(t,r){return r?`${t} ${r}`:t}function o0e({className:t,...r}){return z.jsx("div",{...r,className:s0e("vgai-stack",t),style:QDt(r)})}function Nq({className:t,...r}){return z.jsx("div",{...r,className:s0e("vgai-inline",t),style:QDt(r)})}function T5r({orientation:t="horizontal",className:r,...i}){return z.jsx("div",{...i,"aria-hidden":"true","data-orientation":t,className:s0e("vgai-divider",r)})}function k5r({children:t,className:r,...i}){return z.jsx(Nq,{...i,className:s0e("vgai-actions",r),gap:2,align:"center",children:t})}function KDt(t,r){return r?`${t} ${r}`:t}const Ru=Xe.forwardRef(function({as:r="span",variant:i="body",tone:a="primary",truncate:l=!1,selectable:d=!1,className:_,...g},b){const S=r;return z.jsx(S,{...g,ref:b,"data-variant":i,"data-tone":a,"data-truncate":l||void 0,"data-selectable":d||void 0,className:KDt("vgai-text",_)})});function q_e({className:t,...r}){return z.jsx("kbd",{...r,className:KDt("vgai-keycap",t)})}function Cze(t,r){return r?`${t} ${r}`:t}function Z9e({labelledBy:t,onDismiss:r,size:i="default",variant:a="default",className:l,...d}){const[_]=Xe.useState(()=>typeof document>"u"?null:document.querySelector(".vgai-editor-theme")),g=z.jsx("div",{className:"vgai-dialog-scrim","data-variant":a,onPointerDown:b=>{b.target===b.currentTarget&&r?.()},children:z.jsx("div",{...d,role:"dialog","aria-modal":"true","aria-labelledby":t,"data-size":i,"data-variant":a,className:Cze("vgai-dialog",l)})});return _?vS.createPortal(g,_):g}function eMe({titleId:t,title:r,description:i}){return z.jsxs(o0e,{className:"vgai-dialog-header",gap:2,children:[z.jsx(Ru,{id:t,as:"h2",variant:"heading",children:r}),i&&z.jsx(Ru,{as:"p",tone:"muted",children:i})]})}function YDt({className:t,...r}){return z.jsx(o0e,{...r,className:Cze("vgai-dialog-body",t)})}function tMe({children:t,className:r,...i}){return z.jsx(k5r,{...i,className:Cze("vgai-dialog-footer",r),children:t})}function XDt(t,r){return r?`${t} ${r}`:t}function I5r({className:t,...r}){return z.jsx("div",{...r,className:XDt("vgai-field-group",t)})}function z_e({label:t,htmlFor:r,hint:i,compact:a=!1,className:l,children:d,..._}){return z.jsxs("div",{..._,"data-compact":a||void 0,className:XDt("vgai-field-row",l),children:[z.jsx("label",{htmlFor:r,className:"vgai-field-label",children:t}),z.jsx("div",{className:"vgai-field-control",children:d}),i&&z.jsx("div",{className:"vgai-field-hint",children:i})]})}Xe.forwardRef(function({selected:r=!1,accent:i="bar",className:a,type:l="button",...d},_){return z.jsx("button",{...d,ref:_,type:l,"data-selected":r||void 0,"data-accent":i,className:a?`vgai-list-button ${a}`:"vgai-list-button"})});function D5r({tone:t="neutral",icon:r,title:i,description:a,action:l,compact:d=!1,className:_,...g}){const b=t==="error"?"alert":t==="loading"||t==="success"?"status":void 0;return z.jsxs("div",{...g,role:g.role??b,"data-tone":t,"data-compact":d||void 0,className:_?`vgai-state-surface ${_}`:"vgai-state-surface",children:[r&&z.jsx("div",{className:"vgai-state-surface-icon",children:r}),z.jsx("strong",{className:"vgai-state-surface-title",children:i}),a&&z.jsx("div",{className:"vgai-state-surface-description",children:a}),l&&z.jsx("div",{className:"vgai-state-surface-action",children:l})]})}function a0e(t,r){return r?`${t} ${r}`:t}function P5r({variant:t="panel",border:r=!1,scroll:i=!1,className:a,...l}){return z.jsx("div",{...l,"data-variant":t,"data-border":r||void 0,"data-scroll":i||void 0,className:a0e("vgai-surface",a)})}function N5r({tone:t="info",icon:r,actions:i,className:a,children:l,...d}){return z.jsxs("div",{...d,role:t==="error"?"alert":"status","data-tone":t,className:a0e("vgai-banner",a),children:[r&&z.jsx("span",{className:"vgai-banner-icon",children:r}),z.jsx("div",{className:"vgai-banner-content",children:l}),i&&z.jsx("div",{className:"vgai-banner-actions",children:i})]})}const Eze=Xe.forwardRef(function({className:r,...i},a){return z.jsx("div",{ref:a,...i,className:a0e("vgai-popover",r)})});function Zbt({position:t="inside",className:r,...i}){return z.jsx("div",{...i,"aria-hidden":"true","data-position":t,className:a0e("vgai-drop-indicator",r)})}function ZDt(t,r){return r?`${t} ${r}`:t}Xe.forwardRef(function({className:r,onKeyDown:i,...a},l){return z.jsx("div",{...a,ref:l,role:"tablist",className:ZDt("vgai-tabs",r),onKeyDown:d=>{if(i?.(d),d.defaultPrevented||!["ArrowLeft","ArrowRight","Home","End"].includes(d.key))return;const _=Array.from(d.currentTarget.querySelectorAll('[role="tab"]:not(:disabled)'));if(_.length===0)return;d.preventDefault();const g=_.indexOf(document.activeElement);(d.key==="Home"?_[0]:d.key==="End"?_.at(-1):d.key==="ArrowRight"?_[(g+1+_.length)%_.length]:_[(g-1+_.length)%_.length])?.focus()}})});Xe.forwardRef(function({selected:r=!1,dirty:i=!1,badge:a,className:l,type:d="button",tabIndex:_,children:g,...b},S){return z.jsxs("button",{...b,ref:S,type:d,role:"tab",tabIndex:_??(r?0:-1),"aria-selected":r,"data-selected":r||void 0,className:ZDt("vgai-tab",l),children:[i&&z.jsxs(z.Fragment,{children:[z.jsx("span",{className:"vgai-tab-dirty",title:"Unsaved","aria-hidden":"true"}),z.jsx("span",{className:"vgai-sr-only",children:"Unsaved"})]}),z.jsx("span",{className:"vgai-tab-label",children:g}),a!==void 0&&z.jsx("span",{className:"vgai-tab-badge",children:a})]})});function See(t,r){return r?`${t} ${r}`:t}const NP=Xe.forwardRef(function({label:r,compact:i=!1,selectionMode:a="independent",className:l,...d},_){return z.jsx("div",{...d,ref:_,role:"toolbar","aria-label":r,"data-compact":i||void 0,"data-selection-mode":a,className:See("vgai-toolbar",l)})});function eAt({className:t,...r}){return z.jsx("div",{...r,role:"group",className:See("vgai-toolbar-group",t)})}function tAt(t){return z.jsx("span",{...t,"aria-hidden":"true",className:See("vgai-toolbar-divider",t.className)})}function O5r({className:t,onPointerDownCapture:r,...i}){return z.jsx(NP,{...i,compact:!0,className:See("vgai-floating-toolbar vgai-glass-island",t),onPointerDownCapture:a=>{r?.(a),a.stopPropagation()}})}function Tze({className:t,...r}){return z.jsx("div",{...r,role:"group",className:See("vgai-split-button",t)})}function e3t(t,r){return r?`${t} ${r}`:t}Xe.forwardRef(function({label:r,className:i,...a},l){return z.jsx("div",{...a,ref:l,role:"tree","aria-label":r,className:e3t("vgai-tree",i)})});Xe.forwardRef(function({level:r=1,selected:i=!1,expanded:a,muted:l=!1,dragging:d=!1,leading:_,actions:g,className:b,children:S,style:k,...w},N){return z.jsxs("div",{...w,ref:N,role:"treeitem",tabIndex:w.tabIndex??-1,"aria-level":r,"aria-selected":i,...a===void 0?{}:{"aria-expanded":a},"data-selected":i||void 0,"data-muted":l||void 0,"data-dragging":d||void 0,className:e3t("vgai-tree-row",b),style:{paddingLeft:6+Math.max(0,r-1)*14,...k},children:[_&&z.jsx("span",{className:"vgai-tree-row-leading",children:_}),z.jsx("span",{className:"vgai-tree-row-label",children:S}),g&&z.jsx("span",{className:"vgai-tree-row-actions",children:g})]})});function t3t(t,r=8){const i=window.innerWidth,a=window.innerHeight,l=Math.max(r,i-t.width-r),d=Math.max(r,a-t.height-r);return{left:Math.min(Math.max(t.left,r),l),top:Math.min(Math.max(t.top,r),d)}}function c0e(t,r){return r?`${t} ${r}`:t}function rMe(t){return Array.from(t.querySelectorAll('[role="menuitem"]:not(:disabled), [role="menuitemradio"]:not(:disabled), [role="menuitemcheckbox"]:not(:disabled)'))}function F5r(t){rMe(t)[0]?.focus()}const OP=Xe.forwardRef(function({className:r,role:i="menu",autoFocusFirst:a=!1,dismissBoundaryRef:l,onDismiss:d,onKeyDown:_,...g},b){const S=Xe.useRef(null);return Xe.useImperativeHandle(b,()=>S.current),Xe.useEffect(()=>{a&&rMe(S.current)[0]?.focus()},[a]),Xe.useEffect(()=>{if(!d)return;const k=w=>{const N=w.target;!S.current?.contains(N)&&!l?.current?.contains(N)&&d("outside")};return document.addEventListener("pointerdown",k),()=>document.removeEventListener("pointerdown",k)},[l,d]),z.jsx("div",{...g,ref:S,role:i,className:c0e("vgai-menu",r),onKeyDown:k=>{if(_?.(k),k.defaultPrevented)return;if(k.key==="Escape"){k.preventDefault(),d?.("escape");return}if(!["ArrowDown","ArrowUp","Home","End"].includes(k.key))return;k.preventDefault();const w=rMe(k.currentTarget);if(w.length===0)return;const N=w.indexOf(document.activeElement);k.key==="Home"?w[0]?.focus():k.key==="End"?w.at(-1)?.focus():k.key==="ArrowDown"?w[(N+1+w.length)%w.length]?.focus():w[(N-1+w.length)%w.length]?.focus()}})}),Wa=Xe.forwardRef(function({className:r,type:i="button",role:a="menuitem",onClick:l,onSelect:d,..._},g){return z.jsx("button",{..._,ref:g,type:i,role:a,className:c0e("vgai-menu-item",r),onClick:b=>{l?.(b),b.defaultPrevented||d?.()}})});function Ny(t){return z.jsx("hr",{...t,className:c0e("vgai-menu-separator",t.className)})}const kze=Xe.forwardRef(function({className:r,type:i="button",...a},l){return z.jsx("button",{...a,ref:l,type:i,"aria-haspopup":a["aria-haspopup"]??"menu",className:c0e("vgai-menu-trigger",r)})});function vhe({children:t}){const r=Xe.useRef(null),[i,a]=Xe.useState(null),l=Xe.useId();return Xe.useLayoutEffect(()=>{a(r.current?.closest(".vgai-editor-theme")??null)},[]),z.jsxs(z.Fragment,{children:[z.jsx("span",{ref:r,"data-vgai-portal":l,style:{display:"none"}}),i?vS.createPortal(z.jsx("div",{"data-vgai-portal-content":l,style:{display:"contents"},children:t}),i):null]})}function JR({anchorRef:t,align:r="end",side:i="bottom",autoFocusFirst:a=!0,gap:l=4,clamp:d=!1,onDismiss:_,style:g,children:b,...S}){const[k,w]=Xe.useState(null),[N,P]=Xe.useState(null),j=Xe.useRef(null),J=Xe.useRef(!0),X=Xe.useRef(!1),G=Xe.useCallback(()=>{const xe=t.current;if(!xe||!k)return;const ue=xe.getBoundingClientRect(),fe=k.getBoundingClientRect(),de=i==="right"||i==="left"?{left:i==="right"?ue.right+l:ue.left-l-fe.width,top:ue.top}:{left:r==="end"?ue.right-fe.width:ue.left,top:i==="top"?ue.top-l-fe.height:ue.bottom+l},ge=d?t3t({...de,width:fe.width,height:fe.height}):de,qe=j.current;qe?.left===ge.left&&qe.top===ge.top||(j.current=ge,P(ge))},[r,t,d,l,k,i]);Xe.useLayoutEffect(()=>{const xe=t.current;if(!xe||!k)return;G();let ue=0;const fe=()=>{G(),ue=requestAnimationFrame(fe)};ue=requestAnimationFrame(fe),window.addEventListener("resize",G),document.addEventListener("scroll",G,!0);const se=typeof ResizeObserver>"u"?null:new ResizeObserver(G);return se?.observe(xe),se?.observe(k),()=>{const de=J.current&&k.contains(document.activeElement);window.removeEventListener("resize",G),document.removeEventListener("scroll",G,!0),cancelAnimationFrame(ue),se?.disconnect(),de&&queueMicrotask(()=>t.current?.focus())}},[t,k,G]),Xe.useLayoutEffect(()=>{!a||X.current||!k||!N||(X.current=!0,F5r(k))},[a,k,N]);const ee=xe=>{J.current=xe!=="outside",_(),xe==="escape"&&t.current?.focus()};return z.jsx(vhe,{children:z.jsx(OP,{...S,ref:w,dismissBoundaryRef:t,onDismiss:ee,style:{...g,position:"fixed",left:N?.left??0,top:N?.top??0,visibility:N?g?.visibility:"hidden"},children:b})})}function IDn({label:t,children:r,gap:i=0,...a}){const[l,d]=Xe.useState(!1),_=Xe.useRef(null),g=Xe.useId(),b=k=>k instanceof Element&&(_.current?.contains(k)===!0||k.closest(`[data-vgai-submenu="${g}"]`)!==null),S=k=>{b(k.relatedTarget)||d(!1)};return z.jsxs(z.Fragment,{children:[z.jsxs(Wa,{...a,ref:_,"aria-haspopup":"menu","aria-expanded":l,onPointerEnter:()=>d(!0),onPointerLeave:S,onClick:k=>{k.preventDefault(),d(!0)},onKeyDown:k=>{(k.key==="ArrowRight"||k.key==="Enter"||k.key===" ")&&(k.preventDefault(),d(!0)),k.key==="ArrowLeft"&&d(!1)},children:[z.jsx("span",{style:{flex:1},children:t}),z.jsx("span",{"aria-hidden":"true",style:{paddingInlineStart:"var(--vgai-space-4)"},children:"▸"})]}),l&&z.jsx(JR,{anchorRef:_,"data-vgai-submenu":g,side:"right",gap:i,clamp:!0,autoFocusFirst:!1,onDismiss:()=>d(!1),onPointerLeave:S,children:r})]})}const fo=Xe.forwardRef(function({variant:r="secondary",size:i="default",shape:a="default",className:l,type:d="button",..._},g){return z.jsx("button",{..._,ref:g,type:d,className:l?`vgai-btn ${l}`:"vgai-btn","data-variant":r,"data-size":i,"data-shape":a})}),rf=Xe.forwardRef(function({variant:r="ghost",visibleLabel:i,children:a,...l},d){return z.jsxs(fo,{...l,ref:d,variant:r,"data-icon":"true","data-label-placement":i===void 0?void 0:"below",children:[a,i!==void 0&&z.jsx("span",{className:"vgai-icon-button-label",children:i})]})}),VN={base:0,overlayLow:50,sticky:100,dropdown:1e3,toast:9999,modal:1e4},rY={0:"#1a1a1a",1:"#242424",2:"#2c2c2c",3:"#333333",inset:"#1e1e1e"},rAt={1:"#333333",2:"#444444"},Oq={1:"#c5c8ce",2:"#9aa0a6",3:"#90959c"},R5r="#579EFF",M5r="rgba(87,158,255,0.15)",EFe={1:"#f2f6fb",2:"#d3d9e0",3:"#aab0b7"},Ize="#d8dee9",Dze="rgba(216,222,233,0.18)",r3t="#FF6B6B",n3t="#e0a030",i3t="#4caf50",s3t="rgba(76,175,80,0.15)",o3t="rgba(255,107,107,0.15)",a3t="rgba(224,160,48,0.12)",c3t="rgba(255,107,107,0.06)",l3t="rgba(0,0,0,0.5)",u3t="#ff79c6",f3t="rgba(255,121,198,0.08)",d3t="#22b8d6",l0e='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',u0e='ui-monospace, "SF Mono", Monaco, "Cascadia Code", monospace',TFe={sm:"0 2px 8px rgba(0,0,0,0.6)",md:"0 4px 12px rgba(0,0,0,0.5)",lg:"0 8px 32px rgba(0,0,0,0.6)"},Pze={1:"var(--vgai-surface-panel)",inset:"var(--vgai-surface-inset)"},bhe={1:"var(--vgai-boundary-default)",2:"var(--vgai-boundary-strong)"},od={1:"var(--vgai-content-primary)",2:"var(--vgai-content-muted)",3:"var(--vgai-content-dim)"},nMe="var(--vgai-danger)",U_={1:2,2:4,3:6,4:8,5:10,6:12,8:16,10:20,12:24},p3t={commandBar:36,panelHeader:30,localToolbar:28,treeRow:24,treeIndent:14,statusBar:36,toolSize:34,toolWidth:38,toolGap:7,areaSeam:1,areaEmboss:0};function s_(t){return{control:{...L5r,...t.density?.control},font:{...B5r,...t.density?.font},icon:{...j5r,...t.density?.icon},chrome:{...p3t,...t.density?.chrome}}}const L5r={compact:20,default:24,comfortable:28},kFe={resting:1,active:2},j5r={xs:9,sm:10,md:12,lg:13,xl:14,"2xl":16},B5r={xs:9,sm:10,base:11,md:12,lg:13,xl:14,"2xl":16,heading:24},U_e={regular:400,semibold:600,bold:700},Rpe={tight:1,snug:1.2,normal:1.4,relaxed:1.5},nY={duration:{fast:140,base:180,slow:300},easing:{standard:"cubic-bezier(0.32, 0.72, 0.28, 1)",out:"ease-out"}},ZN={small:"3px",medium:"6px",large:"8px",full:"9999px"},dZ={sm:"var(--vgai-radius-sm)"},zY={xs:"var(--vgai-font-xs)",sm:"var(--vgai-font-sm)"},pv={1:"var(--vgai-space-1)",2:"var(--vgai-space-2)",3:"var(--vgai-space-3)",4:"var(--vgai-space-4)",5:"var(--vgai-space-5)",6:"var(--vgai-space-6)",8:"var(--vgai-space-8)",10:"var(--vgai-space-10)",12:"var(--vgai-space-12)"},nAt={normal:"var(--vgai-leading-normal)"},$5r=["outliner","properties"],oz={id:"graphite-dark",color:{surface:{shell:rY[0],panel:rY[1],chrome:rY[2],raised:rY[3],inset:rY.inset,overlay:"rgba(36,36,36,0.94)"},boundary:{default:rAt[1],strong:rAt[2]},content:{primary:Oq[1],muted:Oq[2],dim:Oq[3],onAccent:"#101820",onBright:{primary:"#1a2330",muted:"rgba(26,35,48,0.82)",dim:"rgba(26,35,48,0.74)"}},accent:{default:R5r,muted:M5r},semantic:{danger:r3t,dangerMuted:o3t,dangerFaint:c3t,warning:n3t,warningMuted:a3t,success:i3t,successMuted:s3t,dynamic:u3t,dynamicMuted:f3t,instance:d3t},neutralOverlay:{hover:"rgba(255,255,255,0.08)",active:"rgba(255,255,255,0.14)"},scrim:l3t},typography:{sans:l0e,mono:u0e},shape:{small:ZN.small,medium:ZN.medium,large:ZN.large,full:ZN.full},elevation:{small:TFe.sm,medium:TFe.md,large:TFe.lg}},q5r={...oz,id:"graphite-neutral",color:{...oz.color,content:{primary:EFe[1],muted:EFe[2],dim:EFe[3],onAccent:"#101820",onBright:{primary:"#1a2330",muted:"rgba(26,35,48,0.82)",dim:"rgba(26,35,48,0.74)"}},accent:{default:Ize,muted:Dze}}},z5r={id:"midnight-high-contrast",color:{surface:{shell:"#0b0f14",panel:"#111821",chrome:"#17212c",raised:"#223040",inset:"#080c11",overlay:"rgba(17,24,33,0.96)"},boundary:{default:"#34465a",strong:"#71869d"},content:{primary:"#f2f5f8",muted:"#bdc8d5",dim:"#8493a5",onAccent:"#071019",onBright:{primary:"#071019",muted:"rgba(7,16,25,0.82)",dim:"rgba(7,16,25,0.72)"}},accent:{default:"#65d1ff",muted:"rgba(101,209,255,0.18)"},semantic:{danger:"#ff7b86",dangerMuted:"rgba(255,123,134,0.18)",dangerFaint:"rgba(255,123,134,0.08)",warning:"#f3c969",warningMuted:"rgba(243,201,105,0.16)",success:"#62d394",successMuted:"rgba(98,211,148,0.18)",dynamic:"#e889ff",dynamicMuted:"rgba(232,137,255,0.12)",instance:"#a49bff"},neutralOverlay:{hover:"rgba(255,255,255,0.10)",active:"rgba(255,255,255,0.18)"},scrim:"rgba(0,0,0,0.68)"},typography:{sans:l0e,mono:u0e},shape:{small:"3px",medium:"6px",large:"8px",full:"9999px"},elevation:{small:"0 2px 8px rgba(0,0,0,0.72)",medium:"0 6px 18px rgba(0,0,0,0.68)",large:"0 12px 40px rgba(0,0,0,0.76)"}},iMe={id:"glass-dark",appearance:{material:"glass",transparency:"standard"},color:{surface:{shell:"rgba(26,26,26,0.88)",panel:"rgba(36,36,36,0.62)",chrome:"rgba(44,44,44,0.68)",raised:"rgba(51,51,51,0.74)",inset:"rgba(30,30,30,0.7)",overlay:"rgba(36,36,36,0.55)"},boundary:{default:"rgba(255,255,255,0.14)",strong:"rgba(255,255,255,0.24)"},content:{primary:Oq[1],muted:Oq[2],dim:Oq[3],onAccent:"#101820",onBright:{primary:"#1a2330",muted:"rgba(26,35,48,0.82)",dim:"rgba(26,35,48,0.74)"}},accent:{default:Ize,muted:Dze},semantic:{danger:r3t,dangerMuted:o3t,dangerFaint:c3t,warning:n3t,warningMuted:a3t,success:i3t,successMuted:s3t,dynamic:u3t,dynamicMuted:f3t,instance:d3t},neutralOverlay:{hover:"color-mix(in srgb, currentColor 9%, transparent)",active:"color-mix(in srgb, currentColor 14%, transparent)"},scrim:"rgba(0,0,0,0.35)"},typography:{sans:l0e,mono:u0e},shape:{small:ZN.small,medium:ZN.medium,large:ZN.large,full:ZN.full},elevation:{small:"0 4px 16px rgba(0,0,0,0.55)",medium:"0 8px 28px rgba(0,0,0,0.5)",large:"0 16px 48px rgba(0,0,0,0.55)"},treatment:{backdropBlurPx:14,backdropSaturation:1.3,backdropBrightness:.5,edgeSpecular:.6,specularAngleDeg:120,thickness:.5}},U5r=(()=>{const{treatment:t,...r}=iMe;return{...r,id:"glass-dark-lite",appearance:{material:"glass",transparency:"reduced"},color:{...iMe.color,surface:{shell:"#1a1a1a",panel:"#222222",chrome:"#292929",raised:"#303030",inset:"#1d1d1d",overlay:"#202020"},scrim:l3t}}})(),sMe={id:"liquid-glass",appearance:{material:"glass",transparency:"standard"},color:{surface:{shell:fh.color.surface.shell,panel:fh.color.surface.panel,chrome:fh.color.surface.chrome,raised:fh.color.surface.raised,inset:fh.color.surface.inset,overlay:fh.color.surface.overlay},boundary:fh.color.boundary,content:{primary:"#f2f6fb",muted:"rgba(242,246,251,0.85)",dim:"rgba(242,246,251,0.68)",onAccent:"#0b1526",onBright:{primary:"#1a2330",muted:"rgba(26,35,48,0.82)",dim:"rgba(26,35,48,0.74)"}},accent:{default:Ize,muted:Dze},semantic:{danger:"#ff7b86",dangerMuted:"rgba(255,123,134,0.22)",dangerFaint:"rgba(255,123,134,0.10)",warning:"#ffd35f",warningMuted:"rgba(255,211,95,0.18)",success:"#58e078",successMuted:"rgba(88,224,120,0.20)",dynamic:"#ff8fd8",dynamicMuted:"rgba(255,143,216,0.14)",instance:"#3ad2ea"},neutralOverlay:fh.color.neutralOverlay,scrim:fh.color.scrim},typography:{sans:l0e,mono:u0e},shape:fh.shape,elevation:fh.elevation,treatment:fh.treatment},V5r=(()=>{const{treatment:t,...r}=sMe;return{...r,id:"liquid-glass-lite",appearance:{material:"glass",transparency:"reduced"},color:{...sMe.color,surface:fh.reducedTransparency.surface,scrim:fh.reducedTransparency.scrim}}})(),_3t={"graphite-dark":oz,"graphite-neutral":q5r,"midnight-high-contrast":z5r,"glass-dark":iMe,"glass-dark-lite":U5r,"liquid-glass":sMe,"liquid-glass-lite":V5r};function J5r(t){return typeof t=="string"&&Object.hasOwn(_3t,t)}const Oo={surface:{shell:"var(--vgai-surface-shell)",panel:"var(--vgai-surface-panel)",raised:"var(--vgai-surface-raised)",inset:"var(--vgai-surface-inset)",overlay:"var(--vgai-surface-overlay)"},boundary:{default:"var(--vgai-boundary-default)",strong:"var(--vgai-boundary-strong)"},content:{primary:"var(--vgai-content-primary)",muted:"var(--vgai-content-muted)",dim:"var(--vgai-content-dim)",onAccent:"var(--vgai-content-on-accent)",active:"var(--vgai-content-active)",selected:"var(--vgai-content-selected)"},accent:{default:"var(--vgai-accent)",muted:"var(--vgai-accent-muted)"},selection:{background:"var(--vgai-selection-bg)"},semantic:{danger:"var(--vgai-danger)",dangerMuted:"var(--vgai-danger-muted)",warning:"var(--vgai-warn)",success:"var(--vgai-success)",successMuted:"var(--vgai-success-muted)",instance:"var(--vgai-instance)"},neutralOverlay:{active:"var(--vgai-neutral-active)"},typography:{sans:"var(--vgai-font-sans)",mono:"var(--vgai-font-mono)"},shape:{small:"var(--vgai-radius-sm)",medium:"var(--vgai-radius-md)"}};function W5r(t){const r=`<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1L5 5L9 1' stroke='${t}' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>`;return`url("data:image/svg+xml,${encodeURIComponent(r)}")`}function H5r(t){if(!t)return"none";const r=[];return t.backdropBlurPx&&r.push(`blur(${t.backdropBlurPx}px)`),t.backdropSaturation!==void 0&&t.backdropSaturation!==1&&r.push(`saturate(${t.backdropSaturation})`),t.backdropBrightness!==void 0&&t.backdropBrightness!==1&&r.push(`brightness(${t.backdropBrightness})`),r.length>0?r.join(" "):"none"}function iAt(t,r){return r?"transparent":`linear-gradient(var(${t}), var(${t})), linear-gradient(var(--vgai-surface-shell), var(--vgai-surface-shell))`}function sAt(t){const r=t?.contentFrostBlurPx??0;if(r<=0)return"none";const i=[`blur(${r}px)`];return t?.backdropSaturation!==void 0&&t.backdropSaturation!==1&&i.push(`saturate(${t.backdropSaturation})`),i.join(" ")}function oMe(t){return(t?.contentFrostBlurPx??0)>0?"rgba(255,255,255,0.10)":"transparent"}function G5r(t){return t?"color-mix(in srgb, currentColor 7%, transparent)":"var(--vgai-widget-field)"}function Q5r(t){return t?"color-mix(in srgb, currentColor 26%, transparent)":"var(--vgai-boundary-default)"}function K5r(t,r){const l=[r==="none"?"":r,t?"inset 0 1px 0 color-mix(in srgb, currentColor 14%, transparent), 0 5px 14px -12px color-mix(in srgb, currentColor 55%, transparent)":""].filter(Boolean);return l.length===0?"none":l.join(", ")}const Y5r=.6,X5r=.5;function Ahe(t,r){return`rgba(255,255,255,${Math.min(1,Number((t*r/Y5r).toFixed(3)))})`}function m3t(t){const r=t?.edgeSpecular??0;if(r<=0)return"none";const i=t?.specularAngleDeg??120,a=l=>Ahe(l,r);return`linear-gradient(${i}deg, ${a(.95)} 0%, ${a(.38)} 16%, ${a(.16)} 40%, ${a(.14)} 60%, ${a(.45)} 84%, ${a(.85)} 100%)`}function Z5r(t){const r=t?.edgeSpecular??0;if(r<=0)return"none";const i=t?.specularAngleDeg??120,a=l=>Ahe(l,r);return`linear-gradient(${i}deg, ${a(.16)} 0%, ${a(.05)} 24%, transparent 40%)`}function eFr(t){const r=t?.edgeSpecular??0,i=t?.thickness??0,a=[];if(r>0&&(a.push(`inset 0 1px 1px ${Ahe(.28,r)}`),a.push(`inset 0 -1px 1px ${Ahe(.1,r)}`)),i>0){const l=d=>`${Number((d*i/X5r).toFixed(1))}px`;a.push(`inset 0 ${l(12)} ${l(24)} ${l(-14)} rgba(255,255,255,0.35)`),a.push(`inset 0 ${l(-14)} ${l(28)} ${l(-18)} rgba(0,0,0,0.55)`),a.push(`0 ${l(18)} ${l(40)} ${l(-18)} rgba(0,0,0,0.55)`)}else a.push("var(--vgai-shadow-lg)");return a.join(", ")}function nU(t){return t.appearance?t.appearance.material==="glass":t.treatment!==void 0}function tFr(t){return nU(t)?"var(--vgai-surface-panel)":"color-mix(in srgb, var(--vgai-surface-panel) 90%, transparent)"}function rFr(t){return nU(t)?t.treatment?"var(--vgai-surface-backdrop-filter)":"none":"blur(8px)"}function nFr(t){return t?"17px":"var(--vgai-radius-md)"}function iFr(t){return t?"var(--vgai-boundary-default)":"var(--vgai-boundary-strong)"}function sFr(t){return t?"var(--vgai-shadow-lg)":"var(--vgai-shadow-sm)"}function oFr(t,r){const i=/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(t.color.accent.default);if(!i)return null;const[a,l,d]=[i[1],i[2],i[3]].map(_=>Number.parseInt(_,16));return`rgba(${a},${l},${d},${r})`}function f0e(t){return nU(t)}function aFr(t){return f0e(t)?"var(--vgai-neutral-active)":"var(--vgai-accent-muted)"}function cFr(t){const r=t.trim().toLowerCase();if(r.startsWith("#"))return r.length===5?r.endsWith("f"):r.length===9?r.endsWith("ff"):!0;const i=/^rgba?\(([^)]*)\)$/.exec(r)??/^hsla?\(([^)]*)\)$/.exec(r);if(i){const a=(i[1]??"").split(/[,/]/)[3];return a===void 0||Number.parseFloat(a)>=1}return r!=="transparent"&&!r.includes("transparent")}function lFr(t){return f0e(t)?"var(--vgai-content-primary)":cFr(t.color.accent.muted)?"var(--vgai-content-on-accent)":"var(--vgai-content-primary)"}function uFr(t){return f0e(t)?"color-mix(in srgb, currentColor 30%, transparent)":"var(--vgai-accent)"}function fFr(t){return f0e(t)?"color-mix(in srgb, currentColor 76%, transparent)":"var(--vgai-accent)"}function dFr(t){return t?"var(--vgai-radius-full)":"var(--vgai-radius-sm)"}function pFr(t){return!nU(t)||!t.treatment?"var(--vgai-accent)":oFr(t,.82)??"var(--vgai-accent)"}function _Fr(t){const r=t?.edgeSpecular??0;return r<=0?"none":m3t({...t,edgeSpecular:r*.4})}function mFr(t){const r=t?.ambientLiftOpacity??0;if(r<=0)return"none";const i=Number(r.toFixed(3)),a=Number((r*.35).toFixed(3));return`linear-gradient(165deg, rgba(255,255,255,${i}) 0%, rgba(255,255,255,${a}) 55%, rgba(255,255,255,0) 100%)`}function h3t(t){return t<=0?"none":`0 1px 2px rgba(0,0,0,${Number(t.toFixed(3))})`}function g3t(t){return h3t(t?.textShadowOpacity??0)}function hFr(t){return t.treatment?.adaptiveContent?{primary:t.color.content.onBright.primary,muted:t.color.content.onBright.muted,dim:t.color.content.onBright.dim,textShadow:h3t(t.treatment.brightTextShadowOpacity??0),frostBg:t.treatment.brightFrostBg??oMe(t.treatment)}:{primary:t.color.content.primary,muted:t.color.content.muted,dim:t.color.content.dim,textShadow:g3t(t.treatment),frostBg:oMe(t.treatment)}}function gFr(t){return t.treatment?t.treatment.adaptiveContent?"rgba(255,255,255,0.9)":vFr(t.color.surface.chrome,.9):t.color.surface.chrome}function yFr(t){return t.color.surface.panel}function vFr(t,r){const i=/^rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*([0-9.]+)\s*\)$/.exec(t);if(!i)return t;const a=Math.max(Number(i[4]),r);return`rgba(${i[1]},${i[2]},${i[3]},${a})`}function oAt(t){if(!t)return"none";const i=[`blur(${Math.max(16,t.contentFrostBlurPx??0)}px)`];return t.backdropSaturation!==void 0&&t.backdropSaturation!==1&&i.push(`saturate(${t.backdropSaturation})`),i.join(" ")}function bFr(t){return t.color.boundary.area??t.color.boundary.default}function AFr(t,r){return`color-mix(in srgb, ${t} 98.4%, ${r})`}function iY(t){return`color-mix(in srgb, var(--vgai-area-emboss-mix), ${t})`}function SFr(t){const r=s_(t).chrome.areaEmboss;return r>0?`#ffffff ${r}%`:"transparent 100%"}function xFr(t){const r=hFr(t),i=nU(t),a=t.color.widget?.regular??t.color.surface.raised,l=t.color.widget?.menu??t.color.surface.raised,d=t.color.widget?.field??t.color.surface.inset,_=t.color.widget?.emboss?`0 1px 0 ${t.color.widget.emboss}`:"none",g=S=>`color-mix(in srgb, ${S} 87.8%, ${t.color.content.primary})`,b=`color-mix(in srgb, ${t.color.surface.panel} 86.5%, ${t.color.surface.raised})`;return{"--vgai-surface-shell":t.color.surface.shell,"--vgai-surface-panel":t.color.surface.panel,"--vgai-surface-chrome":t.color.surface.chrome,"--vgai-surface-raised":t.color.surface.raised,"--vgai-surface-inset":t.color.surface.inset,"--vgai-surface-overlay":t.color.surface.overlay,"--vgai-surface-backdrop-filter":H5r(t.treatment),"--vgai-surface-sticky":iAt("--vgai-surface-chrome",i),"--vgai-surface-sticky-panel":iAt("--vgai-surface-panel",i),"--vgai-surface-sticky-backdrop-filter":"none","--vgai-surface-body-frost-filter":sAt(t.treatment),"--vgai-content-frost-filter":sAt(t.treatment),"--vgai-content-frost-bg":oMe(t.treatment),"--vgai-input-surface":G5r(i),"--vgai-input-border":Q5r(i),"--vgai-input-shadow":K5r(i,_),"--vgai-structural-divider":i?"transparent":t.color.boundary.default,"--vgai-card-specular-ring":m3t(t.treatment),"--vgai-card-specular-sheen":Z5r(t.treatment),"--vgai-card-specular-shadow":eFr(t.treatment),"--vgai-card-refraction-thickness":String(t.treatment?.refractionThickness??0),"--vgai-card-refraction-bezel":String(t.treatment?.refractionBezelPx??28),"--vgai-card-refraction-angle":String(t.treatment?.specularAngleDeg??120),"--vgai-ambient-lift":mFr(t.treatment),"--vgai-island-surface":tFr(t),"--vgai-island-backdrop-filter":rFr(t),"--vgai-island-radius":nFr(i),"--vgai-island-border-color":iFr(i),"--vgai-island-shadow":sFr(i),"--vgai-island-specular-ring":_Fr(t.treatment),"--vgai-selection-bg":aFr(t),"--vgai-content-on-selection":lFr(t),"--vgai-selection-border":uFr(t),"--vgai-selection-indicator":fFr(t),"--vgai-island-control-radius":dFr(i),"--vgai-island-primary-bg":pFr(t),"--vgai-content-text-shadow":g3t(t.treatment),"--vgai-content-primary-on-bright":r.primary,"--vgai-content-muted-on-bright":r.muted,"--vgai-content-dim-on-bright":r.dim,"--vgai-content-text-shadow-on-bright":r.textShadow,"--vgai-content-frost-bg-on-bright":r.frostBg,"--vgai-content-adaptive":t.treatment?.adaptiveContent?"1":"0","--vgai-glass-regular-bg":gFr(t),"--vgai-glass-regular-backdrop-filter":oAt(t.treatment),"--vgai-glass-regular-panel-bg":yFr(t),"--vgai-glass-regular-panel-backdrop-filter":oAt(t.treatment),"--vgai-glass-dark-frost-panel-bg":"rgba(5,8,13,0.74)","--vgai-glass-dark-frost-content-bg":"rgba(5,8,13,0.84)","--vgai-scrim-backdrop-filter":t.treatment?"blur(8px)":"none","--vgai-boundary-default":t.color.boundary.default,"--vgai-boundary-strong":t.color.boundary.strong,"--vgai-boundary-area":bFr(t),"--vgai-tree-indent-guide":t.color.boundary.indent??"transparent","--vgai-boundary-divider":t.color.boundary.divider??t.color.boundary.default,"--vgai-area-emboss-mix":SFr(t),"--vgai-area-emboss":iY(t.color.surface.panel),"--vgai-area-emboss-stage":iY(iY(t.color.viewport?.background??t.color.surface.panel)),"--vgai-area-emboss-stage-header":iY(iY(b)),"--vgai-content-primary":t.color.content.primary,"--vgai-content-muted":t.color.content.muted,"--vgai-content-dim":t.color.content.dim,"--vgai-content-on-accent":t.color.content.onAccent,"--vgai-content-menu":t.color.content.menu??t.color.content.primary,"--vgai-content-status":t.color.content.status??t.color.content.dim,"--vgai-content-placeholder":t.color.content.placeholder??t.color.content.dim,"--vgai-content-active":t.color.content.active??"","--vgai-content-selected":t.color.content.selected??t.color.content.active??"","--vgai-accent":t.color.accent.default,"--vgai-accent-muted":t.color.accent.muted,"--vgai-danger":t.color.semantic.danger,"--vgai-danger-muted":t.color.semantic.dangerMuted,"--vgai-danger-faint":t.color.semantic.dangerFaint,"--vgai-warn":t.color.semantic.warning,"--vgai-warn-muted":t.color.semantic.warningMuted,"--vgai-success":t.color.semantic.success,"--vgai-success-muted":t.color.semantic.successMuted,"--vgai-dynamic":t.color.semantic.dynamic,"--vgai-dynamic-muted":t.color.semantic.dynamicMuted,"--vgai-instance":t.color.semantic.instance,"--vgai-neutral-hover":t.color.neutralOverlay.hover,"--vgai-neutral-active":t.color.neutralOverlay.active,"--vgai-scrim":t.color.scrim,"--vgai-surface-section":`color-mix(in srgb, ${t.color.surface.panel} 64.9%, ${t.color.surface.raised})`,"--vgai-surface-section-edge":`color-mix(in srgb, ${t.color.surface.panel} 29.7%, ${t.color.surface.raised})`,"--vgai-surface-header":b,"--vgai-surface-row-alt":AFr(t.color.surface.panel,t.color.content.primary),"--vgai-tree-row-selected-bg":`color-mix(in srgb, ${t.color.accent.default} 42%, #000)`,"--vgai-tree-row-active-bg":`color-mix(in srgb, ${t.color.accent.default} 70%, #000)`,"--vgai-tree-row-active-border":"rgb(from var(--vgai-tree-row-active-bg) calc(r + 40) calc(g + 40) calc(b + 40))","--vgai-tree-active-name-underline":t.color.content.active?"none":"underline","--vgai-viewport-background":t.color.viewport?.background??"","--vgai-viewport-grid":t.color.viewport?.grid??"","--vgai-viewport-axis-x":t.color.viewport?.axisX??"","--vgai-viewport-axis-y":t.color.viewport?.axisY??"","--vgai-viewport-selection":t.color.viewport?.selection??"","--vgai-viewport-active":t.color.viewport?.active??"","--vgai-viewport-gizmo-size":t.density?.viewport?.gizmoSize===void 0?"":`${t.density.viewport.gizmoSize}`,"--vgai-viewport-shelf-tool":t.density?.viewport?.shelfTool??"","--vgai-viewport-up-axis":t.density?.viewport?.upAxis??"","--vgai-viewport-box-select":t.density?.viewport?.boxSelect??"","--vgai-widget-regular":a,"--vgai-widget-regular-hover":g(a),"--vgai-widget-menu":l,"--vgai-widget-menu-hover":g(l),"--vgai-widget-field":d,"--vgai-widget-emboss-shadow":_,"--vgai-category-object":t.color.category?.object??"currentColor","--vgai-category-modifier":t.color.category?.modifier??"currentColor","--vgai-category-material":t.color.category?.material??"currentColor","--vgai-category-tool":t.color.category?.tool??"currentColor","--vgai-category-operator":t.color.category?.operator??"currentColor","--vgai-category-data":t.color.category?.data??"currentColor","--vgai-category-scene":t.color.category?.scene??"currentColor","--vgai-category-collection":t.color.category?.collection??"currentColor","--vgai-region-outliner":t.color.region?.outliner??t.color.surface.panel,"--vgai-region-outliner-header":t.color.region?.outliner??t.color.surface.chrome,"--vgai-region-properties":t.color.region?.properties??t.color.surface.panel,"--vgai-region-properties-header":t.color.region?.properties??t.color.surface.chrome,"--vgai-font-sans":t.typography.sans,"--vgai-font-mono":t.typography.mono,"--vgai-radius-sm":t.shape.small,"--vgai-radius-md":t.shape.medium,"--vgai-radius-lg":t.shape.large,"--vgai-radius-full":t.shape.full,"--vgai-shadow-sm":t.elevation.small,"--vgai-shadow-md":t.elevation.medium,"--vgai-shadow-lg":t.elevation.large,"--vgai-focus-ring":`${kFe.active}px solid ${t.color.accent.default}`,"--vgai-select-chevron":W5r(t.color.content.muted),"--vgai-space-1":`${U_[1]}px`,"--vgai-space-2":`${U_[2]}px`,"--vgai-space-3":`${U_[3]}px`,"--vgai-space-4":`${U_[4]}px`,"--vgai-space-5":`${U_[5]}px`,"--vgai-space-6":`${U_[6]}px`,"--vgai-space-8":`${U_[8]}px`,"--vgai-space-10":`${U_[10]}px`,"--vgai-space-12":`${U_[12]}px`,"--vgai-command-bar-height":`${s_(t).chrome.commandBar}px`,"--vgai-panel-header-height":`${s_(t).chrome.panelHeader}px`,"--vgai-local-toolbar-height":`${s_(t).chrome.localToolbar}px`,"--vgai-tree-row-height":`${s_(t).chrome.treeRow}px`,"--vgai-tree-indent":`${s_(t).chrome.treeIndent}px`,"--vgai-status-bar-height":`${s_(t).chrome.statusBar}px`,"--vgai-tool-size":`${s_(t).chrome.toolSize}px`,"--vgai-tool-width":`${s_(t).chrome.toolWidth}px`,"--vgai-tool-gap":`${s_(t).chrome.toolGap}px`,"--vgai-area-seam-width":`${s_(t).chrome.areaSeam}px`,"--vgai-control-compact-height":`${s_(t).control.compact}px`,"--vgai-control-default-height":`${s_(t).control.default}px`,"--vgai-control-comfortable-height":`${s_(t).control.comfortable}px`,"--vgai-stroke-resting":`${kFe.resting}px`,"--vgai-stroke-active":`${kFe.active}px`,"--vgai-font-xs":`${s_(t).font.xs}px`,"--vgai-font-sm":`${s_(t).font.sm}px`,"--vgai-font-base":`${s_(t).font.base}px`,"--vgai-font-md":`${s_(t).font.md}px`,"--vgai-font-lg":`${s_(t).font.lg}px`,"--vgai-font-xl":`${s_(t).font.xl}px`,"--vgai-font-2xl":`${s_(t).font["2xl"]}px`,"--vgai-icon-xs":`${s_(t).icon.xs}px`,"--vgai-icon-sm":`${s_(t).icon.sm}px`,"--vgai-icon-md":`${s_(t).icon.md}px`,"--vgai-icon-lg":`${s_(t).icon.lg}px`,"--vgai-icon-xl":`${s_(t).icon.xl}px`,"--vgai-icon-2xl":`${s_(t).icon["2xl"]}px`,"--vgai-font-heading":`${s_(t).font.heading}px`,"--vgai-font-weight-regular":String(U_e.regular),"--vgai-font-weight-semibold":String(U_e.semibold),"--vgai-font-weight-bold":String(U_e.bold),"--vgai-leading-tight":String(Rpe.tight),"--vgai-leading-snug":String(Rpe.snug),"--vgai-leading-normal":String(Rpe.normal),"--vgai-leading-relaxed":String(Rpe.relaxed),"--vgai-duration-fast":`${nY.duration.fast}ms`,"--vgai-duration-base":`${nY.duration.base}ms`,"--vgai-duration-slow":`${nY.duration.slow}ms`,"--vgai-ease-standard":nY.easing.standard,"--vgai-ease-out":nY.easing.out,"--vgai-z-base":String(VN.base),"--vgai-z-overlay-low":String(VN.overlayLow),"--vgai-z-sticky":String(VN.sticky),"--vgai-z-dropdown":String(VN.dropdown),"--vgai-z-toast":String(VN.toast),"--vgai-z-modal":String(VN.modal)}}const aMe="vgai-editor-theme";function wFr(t,r=oz){t.classList.add(aMe),t.dataset.vgaiTheme=r.id,t.dataset.vgaiChrome=nU(r)?"islands":"bars";for(const[i,a]of Object.entries(xFr(r)))t.style.setProperty(i,a)}const y3t=Xe.createContext(null);function CFr(){return Xe.useContext(y3t)}function _9(t,r){return r?`${t} ${r}`:t}const k_=Xe.forwardRef(function({className:r,type:i="text",...a},l){return z.jsx("input",{...a,ref:l,type:i,className:_9("vgai-input",r)})}),bS=Xe.forwardRef(function({className:r,...i},a){return z.jsx("select",{...i,ref:a,className:_9("vgai-select",r)})}),Nze=Xe.forwardRef(function({className:r,...i},a){return z.jsx("textarea",{...i,ref:a,className:_9("vgai-input vgai-textarea",r)})}),SE=Xe.forwardRef(function({className:r,...i},a){return z.jsx("input",{...i,ref:a,type:"checkbox",className:_9("vgai-checkbox",r)})}),v3t=Xe.forwardRef(function({className:r,...i},a){return z.jsx("input",{...i,ref:a,type:"color",className:_9("vgai-color-swatch",r)})});Xe.forwardRef(function({className:r,...i},a){return z.jsx("input",{...i,ref:a,type:"file",className:_9("vgai-file-input",r)})});const DDn=Xe.forwardRef(function({className:r,...i},a){return z.jsx("input",{...i,ref:a,type:"range",className:_9("vgai-range",r)})}),Yk="default",AX=new Map;let pZ=Yk;const cMe=new Set;function lMe(){for(const t of cMe)t()}function xee(t){return typeof t=="string"&&(t===Yk||AX.has(t))}function EFr(t){if(xee(t.id))throw new Error(`registerContributedIconSet: icon set "${t.id}" is already registered.`);return AX.set(t.id,t),lMe(),()=>{AX.get(t.id)===t&&(AX.delete(t.id),lMe())}}function aAt(){return pZ}function V_e(t){const r=xee(t)?t:Yk;r!==pZ&&(pZ=r,lMe())}function b3t(t){return cMe.add(t),()=>cMe.delete(t)}function TFr(t){return pZ===Yk?null:AX.get(pZ)?.glyphs[t]??null}const cAt={xs:"var(--vgai-icon-xs)",sm:"var(--vgai-icon-sm)",md:"var(--vgai-icon-md)",lg:"var(--vgai-icon-lg)",xl:"var(--vgai-icon-xl)","2xl":"var(--vgai-icon-2xl)"},lAt={current:void 0,primary:Oo.content.primary,muted:Oo.content.muted,dim:Oo.content.dim,accent:Oo.accent.default,danger:Oo.semantic.danger};function So({icon:t,size:r="sm",tone:i="current",label:a,className:l,style:d,spin:_=!1,...g}){Xe.useSyncExternalStore(b3t,aAt,aAt);const b=TFr(t.iconName);if(b){const S=i!=="current",k=b.tone?`var(--vgai-category-${b.tone}, currentColor)`:void 0,w=S?lAt[i]:b.tonedPath?void 0:k,N=S?"currentColor":k??"currentColor";return z.jsxs("svg",{...g,viewBox:b.viewBox??"0 0 16 16","data-vgai-tone":S?void 0:b.tone,className:l,"aria-hidden":a?void 0:g["aria-hidden"]??"true","aria-label":a,role:a?"img":void 0,style:{width:"1.25em",height:"1em",overflow:"visible",verticalAlign:"-0.125em",fontSize:cAt[r],color:w,...d},children:[z.jsx("path",{d:b.path,fill:"currentColor"}),b.tonedPath?z.jsx("path",{d:b.tonedPath,fill:N}):null]})}return z.jsx(Mkr,{...g,icon:t,fixedWidth:!0,spin:_,className:l,"aria-hidden":a?void 0:g["aria-hidden"]??"true","aria-label":a,role:a?"img":void 0,style:{fontSize:cAt[r],color:lAt[i],...d}})}function A3t({direction:t,size:r="xs",tone:i="current",style:a}){return z.jsx(So,{icon:t==="right"?zkt:eIt,size:r,tone:i,...a?{style:a}:{}})}function aS(t,r){return{...r,iconName:t}}const yb={action:{close:eze,search:jkt},transport:{play:aDr,pause:EDr,stop:w9e},content:{project:qkt,folder:gee},status:{success:S8,warning:vee,error:Gkt},viewport:{zoomIn:zIr,zoomOut:BIr,pan:eDr,frame:$kt,projection:aS("viewport-projection",TDr)},modeling:{extrude:aS("mesh-extrude",Wkt),inset:aS("mesh-inset",wDr),bevel:aS("mesh-bevel",IDr),loopCut:aS("mesh-loop-cut",UIr),knife:aS("mesh-knife",yDr),smooth:aS("mesh-smooth",jIr),shrinkFatten:aS("mesh-shrink-fatten",Qkt),subdivide:aS("mesh-subdivide",cDr)},tool:{extension:yee,select:PDr,move:Kkt,rotate:Mkt,scale:aS("tool-scale",VIr),transform:aS("tool-transform",nDr)},panel:{outliner:aS("outliner",lIt),properties:aS("properties",Ykt)}};function SX({value:t,onChange:r,onChangeEnd:i,step:a=.1,precision:l=3,disabled:d=!1,label:_,labelColor:g,style:b,testId:S,title:k}){const[w,N]=Xe.useState(!1),[P,j]=Xe.useState(""),J=Xe.useRef({startX:0,startVal:0,dragging:!1,gesture:!1,lastVal:0}),X=Xe.useRef(null),G=CFr();Xe.useEffect(()=>{if(!w)return;const de=X.current;de&&(de.focus(),de.select())},[w]);const ee=t===null,xe=t??0,ue=ee?"—":Number.isFinite(xe)?xe.toFixed(l):0 .toFixed(l),fe=de=>{if(d)return;J.current={startX:de.clientX,startVal:xe,dragging:!1,gesture:!1,lastVal:xe};const ge=tt=>{const Ct=tt.clientX-J.current.startX;if(Math.abs(Ct)>3&&(J.current.dragging=!0),J.current.dragging){J.current.gesture||(J.current.gesture=!0,G?.begin());const Ot=J.current.startVal+Ct*a,vt=Math.round(Ot/a)*a;J.current.lastVal=vt,r(vt)}},qe=()=>{window.removeEventListener("pointermove",ge),window.removeEventListener("pointerup",qe),J.current.gesture&&G?.end(),J.current.dragging?i?.(J.current.lastVal):(N(!0),j(ee?"":ue))};window.addEventListener("pointermove",ge),window.addEventListener("pointerup",qe)},se=()=>{N(!1);const de=Number.parseFloat(P);Number.isFinite(de)&&(r(de),i?.(de))};return z.jsxs("div",{className:"vgai-number-input","data-testid":S,title:k,style:b,children:[_&&z.jsx("span",{className:"vgai-number-input-label",style:g?{color:g}:void 0,children:_}),w?z.jsx(k_,{ref:X,value:P,onChange:de=>j(de.target.value),onBlur:se,onKeyDown:de=>{de.key==="Enter"&&se(),de.key==="Escape"&&N(!1)},placeholder:ee?"—":void 0,className:"vgai-number-input-editor"}):z.jsx("div",{onPointerDown:fe,className:"vgai-number-input-scrub","data-mixed":ee||void 0,"data-disabled":d||void 0,children:ue})]})}const kFr={minHeight:"var(--vgai-panel-header-height)",padding:`0 ${U_[4]}px`,color:Oo.content.muted,fontSize:"var(--vgai-font-base)",fontWeight:U_e.semibold,textTransform:"uppercase",display:"flex",alignItems:"center",gap:U_[2],userSelect:"none"},IFr={...kFr,background:"var(--vgai-surface-sticky)",borderBottom:"1px solid var(--vgai-structural-divider)",flexShrink:0};function Oze({name:t,actions:r,onHeaderClick:i,hideHeader:a=!1,style:l,children:d,..._}){return z.jsxs("div",{..._,style:{display:"flex",flexDirection:"column",pointerEvents:"auto",...l},children:[!a&&z.jsxs("div",{role:i?"button":void 0,tabIndex:i?0:void 0,onClick:i,onKeyDown:i?g=>{g.key==="Enter"&&i()}:void 0,style:{...IFr,cursor:i?"pointer":void 0,pointerEvents:"auto"},children:[z.jsx("span",{style:{flexShrink:0},children:t}),r&&z.jsx("div",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:U_[3]},children:r})]}),d]})}function DFr({label:t,icon:r,description:i,actions:a,collapsible:l=!0,defaultOpen:d=!0,children:_}){const[g,b]=Xe.useState(d),S=z.jsxs("span",{className:"vgai-section-title",children:[z.jsx("span",{children:t}),i?z.jsx("small",{children:i}):null]});return z.jsxs("section",{className:"vgai-section",children:[z.jsxs("div",{className:"vgai-section-header",children:[l?z.jsxs("button",{type:"button",className:"vgai-section-trigger","aria-expanded":g,onClick:()=>b(!g),children:[z.jsx(A3t,{direction:g?"down":"right",style:{fontSize:"var(--vgai-section-disclosure-size, var(--vgai-icon-xs))"}}),r&&z.jsx(So,{icon:r,tone:"dim",className:"vgai-section-glyph"}),S]}):z.jsxs("div",{className:"vgai-section-trigger","data-vgai-static":!0,children:[r&&z.jsx(So,{icon:r,tone:"dim",className:"vgai-section-glyph"}),S]}),a?z.jsx("div",{className:"vgai-section-actions",children:a}):null]}),(g||!l)&&z.jsx("div",{className:"vgai-section-body",children:_})]})}const e8=8,t8=6;function PFr(t){return t==="top"?"bottom":t==="bottom"?"top":t==="left"?"right":"left"}function NFr(t,r,i){return t==="top"?r.top-i.height-t8>=e8:t==="bottom"?r.bottom+i.height+t8<=window.innerHeight-e8:t==="left"?r.left-i.width-t8>=e8:r.right+i.width+t8<=window.innerWidth-e8}function OFr(t,r,i){let a=r.left+(r.width-i.width)/2,l=r.top+(r.height-i.height)/2;return t==="top"?l=r.top-i.height-t8:t==="bottom"?l=r.bottom+t8:t==="left"?a=r.left-i.width-t8:a=r.right+t8,{left:Math.max(e8,Math.min(a,window.innerWidth-i.width-e8)),top:Math.max(e8,Math.min(l,window.innerHeight-i.height-e8)),ready:!0}}function ph({text:t,hotkey:r,children:i,position:a="bottom",delay:l=400}){const d=Xe.useId(),_=Xe.useRef(null),g=Xe.useRef(null),b=Xe.useRef(null),S=Xe.useRef(!1),k=Xe.useRef(!1),[w,N]=Xe.useState(!1),[P,j]=Xe.useState(null),[J,X]=Xe.useState({left:0,top:0,ready:!1});Xe.useLayoutEffect(()=>{j(_.current?.closest(".vgai-editor-theme")??null)},[]),Xe.useEffect(()=>()=>{b.current&&clearTimeout(b.current)},[]);const G=()=>{b.current&&clearTimeout(b.current),b.current=null,N(!1)},ee=()=>{!S.current&&!k.current&&G()},xe=fe=>{b.current&&clearTimeout(b.current),b.current=setTimeout(()=>{X(se=>({...se,ready:!1})),N(!0)},fe)};Xe.useLayoutEffect(()=>{if(!w)return;const fe=()=>{const se=_.current?.getBoundingClientRect(),de=g.current?.getBoundingClientRect();if(!se||!de)return;const ge=NFr(a,se,de)?a:PFr(a);X(OFr(ge,se,de))};return fe(),window.addEventListener("resize",fe),window.addEventListener("scroll",fe,!0),()=>{window.removeEventListener("resize",fe),window.removeEventListener("scroll",fe,!0)}},[r,a,t,w]);let ue=i;if(Xe.isValidElement(i)){const fe=[i.props["aria-describedby"],w?d:null].filter(Boolean).join(" ");ue=Xe.cloneElement(i,fe?{"aria-describedby":fe}:{})}return z.jsxs("span",{ref:_,className:"vgai-tooltip-anchor",onMouseEnter:()=>{S.current=!0,xe(l)},onMouseLeave:()=>{S.current=!1,ee()},onFocusCapture:()=>{k.current=!0,xe(0)},onBlurCapture:fe=>{fe.currentTarget.contains(fe.relatedTarget)||(k.current=!1,ee())},children:[ue,w&&P&&vS.createPortal(z.jsxs("div",{ref:g,id:d,role:"tooltip",className:"vgai-tooltip",style:{left:J.left,top:J.top,visibility:J.ready?"visible":"hidden"},children:[z.jsx("span",{children:t}),r&&z.jsx("kbd",{children:r})]}),P)]})}function FFr({value:t,onChange:r,onAxisChange:i,step:a=.1,disabled:l=!1,testIdPrefix:d}){const _=b=>d?`${d}-${b}`:void 0,g=b=>S=>{if(i)i(b,S);else{const k=[t[0]??0,t[1]??0,t[2]??0];k[b]=S,r(k)}};return z.jsxs("div",{style:{display:"flex",gap:4},children:[z.jsx(SX,{label:"X",labelColor:"#E06178",value:t[0],onChange:g(0),step:a,disabled:l,style:{flex:1},testId:_("x")}),z.jsx(SX,{label:"Y",labelColor:"#C2ED66",value:t[1],onChange:g(1),step:a,disabled:l,style:{flex:1},testId:_("y")}),z.jsx(SX,{label:"Z",labelColor:"#6BABF5",value:t[2],onChange:g(2),step:a,disabled:l,style:{flex:1},testId:_("z")})]})}const IFe={border:Oo.boundary.default,accent:Oo.accent.default,radiusSmall:Oo.shape.small,inputBg:Oo.surface.inset},RFr={fontSize:"var(--vgai-font-base)",fontWeight:600,color:Oo.content.muted,textTransform:"uppercase",letterSpacing:.4},MFr=72,DFe=22,uAt={width:DFe,height:DFe,flex:`0 0 ${DFe}px`,borderRadius:IFe.radiusSmall,border:`1px solid ${IFe.border}`,background:IFe.inputBg,objectFit:"cover",backgroundImage:"linear-gradient(45deg,rgba(128,128,128,.35) 25%,transparent 25%,transparent 75%,rgba(128,128,128,.35) 75%),linear-gradient(45deg,rgba(128,128,128,.35) 25%,transparent 25%,transparent 75%,rgba(128,128,128,.35) 75%)",backgroundSize:"8px 8px",backgroundPosition:"0 0, 4px 4px"};function LFr({value:t,onChange:r,options:i,previewUrlFor:a,disabled:l,note:d,testId:_}){const g=t&&!i.includes(t)?[t,...i]:i;return z.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:2,minWidth:0,flex:1},children:[z.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4,minWidth:0},children:[t?z.jsx("img",{src:a(t),alt:"",style:uAt,"data-testid":`${_}-thumb`}):z.jsx("span",{style:uAt,"aria-hidden":"true"}),z.jsxs(bS,{"data-testid":_,disabled:l,value:t,title:t||"No texture assigned",onChange:b=>r(b.target.value),style:{flex:1,minWidth:0},children:[z.jsx("option",{value:"",children:"—"}),g.map(b=>z.jsx("option",{value:b,children:b},b))]}),z.jsx(rf,{"data-testid":`${_}-clear`,"aria-label":"Clear this texture slot",title:"Clear this texture slot",disabled:l||!t,onClick:()=>r(""),children:z.jsx(So,{icon:eze})})]}),d&&z.jsx("span",{"data-testid":`${_}-note`,style:{fontSize:"var(--vgai-font-sm)",color:Oo.content.muted},children:d})]})}function uMe({value:t,onCommit:r,onKeyDown:i,onFocus:a,...l}){const[d,_]=Xe.useState(null),g=Xe.useRef(!1),b=()=>{!g.current&&d!==null&&d!==t&&r(d),g.current=!1,_(null)};return z.jsx(k_,{...l,value:d??t,onFocus:S=>{_(t),a?.(S)},onChange:S=>_(S.target.value),onBlur:b,onKeyDown:S=>{S.key==="Enter"&&S.target.blur(),S.key==="Escape"&&(g.current=!0,S.target.blur()),i?.(S)}})}const m9=1e4;async function xE(t,r=4e3){if(t())return!0;const i=performance.now();return new Promise(a=>{const l=()=>{t()?a(!0):performance.now()-i>=r?a(!1):setTimeout(l,25)};setTimeout(l,0)})}const xX=new Map,Fq=new Set,She=new Set,J_e=new Set;let S3t=0;function x3t(){S3t+=1;for(const t of[...Fq])t()}function jFr(t,r){return xX.set(t,r),x3t(),()=>{xX.get(t)===r&&xX.delete(t)}}function BFr(t){xX.has(t)&&x3t()}function $Fr(t){return Fq.add(t),()=>{Fq.delete(t)}}function fAt(){return S3t}function _Z(t){return xX.get(t)}function w3t(t,r=1e4){const i=_Z(t);return i!==void 0?Promise.resolve(i):new Promise(a=>{const l=()=>{const _=_Z(t);_!==void 0&&(clearTimeout(d),Fq.delete(l),a(_))},d=setTimeout(()=>{Fq.delete(l),a(void 0)},r);Fq.add(l)})}function C3t(t){She.add(t);for(const r of[...J_e])r();return()=>{She.delete(t)}}function E3t(t,r=1e4){return She.has(t)?Promise.resolve(!0):new Promise(i=>{const a=()=>{She.has(t)&&(clearTimeout(l),J_e.delete(a),i(!0))},l=setTimeout(()=>{J_e.delete(a),i(!1)},r);J_e.add(a)})}async function Fze(t){if(jOr(t)&&!await xE(()=>Pw(t)!==null,m9))throw new Error(`The requested Object3D view did not mount for document: ${t}`)}let fMe=null;const UY=new Map;let PR=[];function qFr(t){if(fMe=t,!t)return;const r=PR;PR=[];for(const i of r)T3t(t,i)}function T3t(t,r){UY.get(r.id)?.();const i=t.show(r),a=()=>{UY.get(r.id)===a&&(UY.delete(r.id),i(),r.onDismiss?.())};return UY.set(r.id,a),a}let zFr=0;function az(t){const r=t.id??`notification-${++zFr}`,i={...t,id:r};return fMe?T3t(fMe,i):(PR=[...PR.filter(a=>a.id!==r),i],()=>Rze(r))}function Rze(t){const r=UY.get(t);if(r){r();return}const i=PR.find(a=>a.id===t);i&&(PR=PR.filter(a=>a.id!==t),i.onDismiss?.())}let iI={sessions:[],selectedSessionId:null,selectedSession:null,cursorMs:0,liveEdgeMs:0,loading:!0,error:null},xhe=!0,Mpe=null,W_e=null,sY=null,H_e=!1;const VY=new Set;function UFr(t,r,i){const a=t[0]??null;return a!==null&&r.length>0&&!r.some(d=>d.id===a.id)?{sessionId:a.id,latestAppeared:!0}:i&&t.some(d=>d.id===i)?{sessionId:i,latestAppeared:!1}:{sessionId:a?.id??null,latestAppeared:!1}}function whe(t){iI=t;for(const r of VY)r()}async function VFr(){const t=await fetch("/__editor/gameplay-sessions");return(await Eg(t,"Could not load Gameplay Sessions")).sessions}async function JFr(t){return Eg(await fetch(`/__editor/gameplay-sessions/${encodeURIComponent(t)}`),"Could not load the selected Gameplay Session").then(r=>r.session)}async function WFr(){try{const t={sessions:await VFr()},r=UFr(t.sessions,iI.sessions,W_e),i=r.sessionId;r.latestAppeared&&(xhe=!0),W_e=i;const a=i?await JFr(i):null;if(W_e!==i){H_e=!0;return}const l=t.sessions.map(g=>g.id===a?.id?a:g),d=a?.durationMs??0,_=xhe?d:Math.min(iI.cursorMs,d);whe({sessions:l,selectedSessionId:i,selectedSession:a,cursorMs:_,liveEdgeMs:d,loading:!1,error:null})}catch(t){whe({...iI,loading:!1,error:t instanceof Error?t.message:String(t)})}}function mZ(){return sY?(H_e=!0,sY):(sY=WFr().finally(()=>{sY=null,H_e&&(H_e=!1,mZ())}),sY)}function HFr(t){return VY.add(t),VY.size===1&&(mZ(),Mpe=window.setInterval(()=>void mZ(),1e3)),()=>{VY.delete(t),VY.size===0&&Mpe!==null&&(window.clearInterval(Mpe),Mpe=null)}}function GFr(t){const r=iI.sessions.find(i=>i.id===t);r&&(W_e=r.id,xhe=!0,whe({...iI,selectedSessionId:r.id,selectedSession:r,cursorMs:r.durationMs,liveEdgeMs:r.durationMs}),mZ())}function QFr(t){const r=Math.max(0,Math.min(t,iI.liveEdgeMs));xhe=iI.liveEdgeMs-r<250,whe({...iI,cursorMs:r})}const k3t={getSnapshot:()=>iI,subscribe:HFr,select:GFr,seek:QFr,refresh:mZ};let KFr=null;const dAt=new Set,PDn={getSnapshot:()=>KFr,subscribe(t){return dAt.add(t),()=>dAt.delete(t)}};let G_e={phase:null,run:0},I3t=null;function YFr(t){I3t=t}function pAt(t){G_e=t;try{I3t?.(t)}catch{}}function D3t(t,r=Date.now()){return pAt({phase:t,at:r,run:G_e.run}),()=>{G_e.phase===t&&pAt({phase:null,at:Date.now(),run:G_e.run})}}const XFr=Xe.lazy(()=>Xo(()=>import("./GameplaySessionTimeline-DrwkiTxs.js"),__vite__mapDeps([44,1,2,3,4,8,9,10,11,6])).then(t=>({default:t.GameplaySessionTimeline})));class Mze extends Xe.Component{state={error:null};static getDerivedStateFromError(r){return{error:r}}componentDidCatch(r,i){console.error(`[tools] ${this.props.file} crashed while rendering:`,r,i.componentStack)}render(){return this.state.error?z.jsxs("div",{style:{padding:U_[6],fontSize:"var(--vgai-font-md)",color:Oo.semantic.danger,maxWidth:640},children:[z.jsxs("div",{style:{fontWeight:600,marginBottom:U_[2]},children:["Tool crashed: ",z.jsx("code",{children:this.props.file})]}),z.jsx("div",{style:{whiteSpace:"pre-wrap"},children:String(this.state.error)}),z.jsx("div",{style:{color:Oo.content.muted,marginTop:U_[3]},children:"The editor is fine — fix the tool file and save; it reloads in place."})]}):this.props.children}}function ZFr({contribution:t,Component:r,documentId:i,active:a,document:l,accountRevision:d,playKey:_}){const g=Xe.useRef(null),[b,S]=Xe.useState(null),k=Xe.useRef(null),w=Xe.useRef(null),N=Xe.useRef(t.file);N.current=t.file;const P=Xe.useRef(i);return P.current=i,Xe.useEffect(()=>{const j=g.current;if(!j)return;let J=!1;S(null);const X=(xe,ue)=>{if(J)return;const fe=xe instanceof Error?xe:new Error(String(xe));console.error(`[tools] ${N.current} crashed while rendering:`,fe,ue?.componentStack),S(fe),P.current&&C3t(P.current)},G=j.appendChild(document.createElement("div"));G.style.display="contents";const ee=Hqe.createRoot(G,{onUncaughtError:X});return k.current=ee,()=>{J=!0,k.current=null,w.current?.(),w.current=null,queueMicrotask(()=>{ee.unmount(),G.remove()})}},[]),Xe.useEffect(()=>{const j=k.current;if(!j)return;S(null);const J={contributionId:t.id,client:b0e(),surfaces:wze,account:mze(),work:ee=>{w.current?.(),w.current=ee===null?null:D3t(`building ${ee.replace(/^building /,"")}`)},notify:ee=>az({...ee,id:`contribution:${t.id}:${ee.title}`,...ee.tone==="warning"?{fades:!0}:{}}),...t.point==="workspace.analytics"?{gameplaySessions:k3t}:{play:Xye()},...i?{documentId:i,publishContext:ee=>jFr(i,ee)}:{},...a!==void 0?{active:a}:{},...l?{document:l}:{}},X=r??t.Component,G=Xe.createElement(X,{...J,...t.tool?{tool:t.tool}:{}});j.render(i?Xe.createElement(e7r,{documentId:i},G):G)},[d,a,t,r,i,l,_]),z.jsxs(z.Fragment,{children:[b?z.jsxs("div",{style:{padding:U_[6],color:Oo.semantic.danger},children:["Tool crashed: ",z.jsx("code",{children:t.file}),z.jsx("div",{style:{whiteSpace:"pre-wrap",marginTop:U_[2]},children:String(b)})]}):null,z.jsx("div",{ref:g,style:{minHeight:0,width:"100%"}})]})}function e7r({documentId:t,children:r}){return Xe.useEffect(()=>C3t(t),[t]),z.jsx(z.Fragment,{children:r})}function h9({contribution:t,Component:r,documentId:i,active:a,document:l}){const d=Xe.useSyncExternalStore(Yye,T8,T8),_=Xe.useSyncExternalStore(Zye,k8,k8),g=t.point==="workspace.analytics"?"gameplay-sessions":_;return z.jsxs("div",{"data-testid":`tool-panel-${t.id}`,style:{flex:1,minHeight:0,overflow:t.point==="workspace.analytics"?"visible":"auto",color:Oo.content.primary,display:"flex",flexDirection:"column"},children:[t.point==="workspace.analytics"?z.jsx(Xe.Suspense,{fallback:null,children:z.jsx(XFr,{})}):null,z.jsx(Mze,{file:t.file,children:z.jsx("div",{style:{flex:1,minHeight:0,overflow:"auto"},children:z.jsx(ZFr,{contribution:t,...r?{Component:r}:{},accountRevision:d,playKey:g,...i?{documentId:i}:{},...a!==void 0?{active:a}:{},...l?{document:l}:{}})})})]})}function t7r({id:t,title:r,file:i,tool:a,Component:l,adapter:d,nodeId:_}){Xe.useSyncExternalStore(Yye,T8,T8),Xe.useSyncExternalStore(Zye,k8,k8);const g=_?d.hierarchy.node(_):null;return z.jsx("div",{className:"vgai-inspector-tool-section","data-testid":`inspector-tool-${t}`,children:z.jsx(Mze,{file:i,children:z.jsx(S3r,{adapter:d,nodeId:_,children:z.jsx(l,{...a?{tool:a}:{},contributionId:t.slice(t.lastIndexOf(":")+1),client:b0e(),surfaces:wze,account:mze(),play:Xye(),node:g,nodeId:_,adapter:d})})})})}const r7r=Symbol("vgai.inspection.mixed");function dMe(t){return t===r7r}function Lze(t){return t.readonlyReason??"This field is read-only."}function jze(t){return"column"}function Bze(t,r){return t.quickActions.filter(i=>i.placement===r)}const pMe="preview",_At="transform",PFe="properties",P3t="stories";function mAt(t){return`group:${t}`}const N3t=100,n7r=1e3,hZ=2e3,O3t=3e3,i7r=4e3,s7r=5e3,o7r={nullSubjectId:null};function F3t(t){return"sections"in t}const Q_e=[];let R3t=0;const _Me=new Set;function hAt(){R3t++;for(const t of _Me)t()}function a7r(t){return _Me.add(t),()=>{_Me.delete(t)}}function gAt(){return R3t}function M3t(t){return Q_e.push(t),hAt(),()=>{const r=Q_e.indexOf(t);r>=0&&(Q_e.splice(r,1),hAt())}}function yAt(t,r,i=o7r){return Q_e.filter(a=>a.match(t,r,i))}function L3t(t){if(typeof t!="object"||t===null)return!1;const r=t.name;return r==="Canceled"||r==="CancellationError"||r==="AbortError"}const c7r=1e3;class l7r{_entries=[];_listeners=new Set;_nextId=0;_version=0;_notifyScheduled=!1;_sink=null;setSink(r){this._sink=r}counts={info:0,warn:0,error:0};log(r,i){this._push("info",r,i)}warn(r,i){this._push("warn",r,i)}error(r,i){this._push("error",r,i)}logStructured(r,i,a,l,d){this._push(r,i,a,l,d)}clear(){this._entries=[],this.counts={info:0,warn:0,error:0},this._notify()}getEntries(){return this._entries}subscribe=r=>(this._listeners.add(r),()=>this._listeners.delete(r));getSnapshot=()=>this._version;_push(r,i,a,l,d){const _=this._entries[this._entries.length-1];if(_&&_.level===r&&_.message===i&&_.source===a&&_.metadata?.instanceId===d?.instanceId){_.count++,_.timestamp=Date.now(),this._sink?.(_),this._notify();return}const g={id:this._nextId++,timestamp:Date.now(),level:r,message:i,count:1};if(a&&(g.source=a),l&&(g.subsystem=l),d&&(g.metadata=d),this._entries.push(g),this.counts[r]++,this._sink?.(g),this._entries.length>c7r){const b=this._entries.shift();this.counts[b.level]=Math.max(0,this.counts[b.level]-1)}this._notify()}_notify(){this._version++,!this._notifyScheduled&&(this._notifyScheduled=!0,queueMicrotask(()=>{this._notifyScheduled=!1;for(const r of this._listeners)r()}))}}const ua=new l7r;typeof window<"u"&&(window.__vgaiEditorConsole=ua);const vAt=1e3,bAt=4e3;function Rq(t){try{return String(t)}catch{return Object.prototype.toString.call(t)}}function u7r(t){if(typeof t!="object"||t===null)return Rq(t);const r=new WeakSet;let i;try{i=JSON.stringify(t,(a,l)=>typeof l!="object"||l===null?l:r.has(l)?"[Circular]":(r.add(l),l))}catch{i=void 0}return i===void 0?Rq(t):i.length>vAt?`${i.slice(0,vAt)}…`:i}function j3t(t){if(t.length===0)return"";const[r,...i]=t;if(typeof r!="string"||i.length===0)return t.map(Rq).join(" ");let a=0;const l=r.replace(/%([sdifoOjc%])/g,(_,g)=>{if(g==="%")return"%";if(a>=i.length)return _;const b=i[a++];switch(g){case"s":return typeof b=="string"?b:Rq(b);case"d":case"i":{if(typeof b=="symbol")return"NaN";if(typeof b=="bigint")return String(b);const S=Number(b);return Number.isFinite(S)?String(Math.trunc(S)):String(S)}case"f":return typeof b=="symbol"?"NaN":String(Number(b));case"c":return"";default:return u7r(b)}}),d=i.slice(a);return d.length===0?l:`${l} ${d.map(Rq).join(" ")}`}function f7r(t,r){const i=t[0];if(typeof i!="string"||!/^(Encountered two children with the same key|Each child in a list should have a unique|Maximum update depth exceeded|Cannot update a component)/.test(i))return r;try{const a=Xe.captureOwnerStack?.();return a?`${r}
|
|
45
45
|
Owner stack:${a}`:r}catch{return r}}function mMe(t,r={}){const i=t instanceof Error?`${t.name}: ${t.message}`:Rq(t),a=[r.source?`[${r.source}] ${i}`:i],l=r.componentStack?.trim();l&&a.push(`Component stack:
|
|
46
46
|
${l}`),t instanceof Error&&t.stack&&t.stack!==i&&a.push(`JavaScript stack:
|
|
47
47
|
${t.stack}`);const d=a.join(`
|
|
@@ -70,13 +70,13 @@ Fix: open the game folder through the SESSION — \`volter-editor edit <path-to-
|
|
|
70
70
|
Fix: open the project through the session (\`volter-editor edit <path>\`) and open the document inside it.`)}async function dE(t){const r=t.byteOffset===0&&t.byteLength===t.buffer.byteLength?t.buffer:t.slice().buffer,i=await crypto.subtle.digest("SHA-256",r);return[...new Uint8Array(i)].map(a=>a.toString(16).padStart(2,"0")).join("")}function Hhe(t){let r="";for(let a=0;a<t.byteLength;a+=32768)r+=String.fromCharCode(...t.subarray(a,a+32768));return btoa(r)}function P0e(){return typeof __VGAI_PROJECT_PATH__<"u"?__VGAI_PROJECT_PATH__:""}let Ghe=null;const XMr=new Set;function D4t(){return Ghe!==null}function M$(){return Ghe}function ZMr(t){if(Ghe!==t){Ghe=t;for(const r of XMr)r()}}const Qhe="/__editor";function xUe(t){return t.replace(/\\/g,"/").replace(/^\/+/,"").replace(/\/+$/,"")}function zpe(t){const r=xUe(t);if(!r||r.split("/").includes(".."))throw new Error(`projectFiles: "${t}" is not a project-relative path.`);return r}function eLr(t){const r=xUe(t);if(r.split("/").includes(".."))throw new Error(`projectFiles: "${t}" is not a project-relative directory.`);return r}function tLr(t){return new Error(`projectFiles.write("${t}"): the standalone editor has no general project-root write route, and this door does not invent one. Source files are written through \`/__ui-source/apply\` (\`ui-source/source-write-backend.ts\`), \`public/**\` through \`/__editor/save-file\`, \`.vgai/**\` through \`/__editor/vgai-file\`. Under the Code-OSS frame the workbench file service owns the whole folder and this refusal cannot occur.`)}async function rLr(t){const r=await fetch(`/@fs/${P0e()}/${t}`);if(!r.ok)throw new Error(`projectFiles.read "${t}": HTTP ${r.status}`);return r.text()}async function nLr(t){const r=await fetch(`/@fs/${P0e()}/${t}`);if(!r.ok)throw new Error(`projectFiles.readBytes "${t}": HTTP ${r.status}`);return new Uint8Array(await r.arrayBuffer())}async function iLr(t,r){if(t.startsWith("public/")){const i=typeof r=="string"?{path:t.slice(7),content:r,...yw()}:{path:t.slice(7),content:Hhe(r),encoding:"base64",...yw()},a=await fetch(`${Qhe}/save-file`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(np(a,`Write ${t} failed`),!a.ok)throw new Error(`projectFiles.write "${t}": HTTP ${a.status}`);return}if(t.startsWith(".vgai/")){const i=typeof r=="string"?{path:t,content:r,...yw()}:{path:t,content:Hhe(r),encoding:"base64",...yw()},a=await fetch(`${Qhe}/vgai-file`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(np(a,`Write ${t} failed`),!a.ok)throw new Error(`projectFiles.write "${t}": HTTP ${a.status}`);return}throw tLr(t)}async function sLr(t){try{const r=await fetch(`/@fs/${P0e()}/${t}`,{method:"HEAD"});return r.ok?!(r.headers.get("content-type")??"").toLowerCase().includes("text/html"):!1}catch{return!1}}async function oLr(t){if(!t.startsWith("public"))throw new Error(`projectFiles.list("${t}"): the standalone editor lists only \`public/**\` (\`/__editor/assets\`); source trees are listed by glob through \`/__editor/source-files\` (\`api/project-source.ts\`'s \`listProjectSourceFiles\`).`);const r=t==="public"?"":t.slice(7),i=await fetch(`${Qhe}/assets?${new URLSearchParams({dir:r})}`),{entries:a}=await Eg(i,`projectFiles.list "${t}" failed`);return a.map(l=>({name:l.name,path:r?`public/${r}/${l.name}`:`public/${l.name}`,type:l.type==="directory"?"dir":"file"}))}function aLr(t){const r=new EventSource(`${Qhe}/events`),i=a=>{try{const l=JSON.parse(a.data),d=l.path??l.file;if(!d)return;t({type:l.type??"update",path:xUe(d)})}catch{}};return r.addEventListener("message",i),()=>{r.removeEventListener("message",i),r.close()}}const Qg={frameOwned:D4t,async read(t){const r=zpe(t);return M$()?.read(r)??rLr(r)},async readBytes(t){const r=zpe(t),i=M$();return i?.readBytes?i.readBytes(r):nLr(r)},async write(t,r){const i=zpe(t),a=M$();return a?a.write(i,r):iLr(i,r)},async exists(t){const r=zpe(t);return M$()?.exists(r)??sLr(r)},async list(t){const r=eLr(t),i=M$();return i?.list?i.list(r):oLr(r)},watch(t){const r=M$();return r?.watch?r.watch(t):aLr(t)}},XFe={version:"vgai-thumbnail-v2"},cLr=Na({version:Ry(1),profile:Ss().min(1),generatedAt:Ss(),entries:UR(Ss(),Na({state:jd(["generated","upstream","fallback","unsupported","failed"]),path:Ss().optional(),profileVersion:Ss(),sourceHash:Ss().optional(),resultHash:Ss().optional(),issueCode:Ss().optional(),framing:Na({position:Ebt([Tu(),Tu(),Tu()]),target:Ebt([Tu(),Tu(),Tu()]),fov:Tu().positive().lt(180).optional()}).strict().optional()}).strict())}).strict(),Lq=".vgai/thumbnails.json";let ime=null;async function lLr(t){let r;try{r=await t.read(Lq)}catch{return{status:"absent"}}const i=r.trim();if(i===""||i.startsWith("<"))return{status:"absent"};let a;try{a=JSON.parse(i)}catch(d){return{status:"unreadable",reason:d instanceof Error?d.message:String(d)}}const l=cLr.safeParse(a);return l.success?{status:"ok",manifest:l.data}:{status:"unreadable",reason:l.error.issues.map(d=>d.message).join("; ")}}function wUe(){return ime||(ime=lLr(Qg).then(async t=>{if(t.status==="unreadable"){const{editorConsole:r}=await Xo(async()=>{const{editorConsole:i}=await Promise.resolve().then(()=>_7r);return{editorConsole:i}},void 0);r.error(`${Lq} is present but could not be read (${t.reason}). Thumbnail framing will not be saved until it is fixed or deleted; previews fall back to live renders.`,"asset-workflow")}return t})),ime}function P4t(){ime=null}class N4t{constructor(r,i=2){this.execute=r,this.concurrency=i}active=0;jobs=new Map;pending=[];request(r,i=0){let a=this.jobs.get(r);if(!a){let d,_;const g=new Promise((b,S)=>{d=b,_=S});a={key:r,priority:i,consumers:0,started:!1,resolve:d,reject:_,promise:g},this.jobs.set(r,a),this.pending.push(a)}a.consumers++,a.priority=Math.max(a.priority,i),this.pending.sort((d,_)=>_.priority-d.priority),this.pump();let l=!1;return{promise:a.promise,cancel:()=>{l||(l=!0,a.consumers--,!a.started&&a.consumers===0&&(this.pending=this.pending.filter(d=>d!==a),this.jobs.delete(a.key),a.reject(new DOMException("Thumbnail request cancelled","AbortError"))))}}}snapshot(){return{active:this.active,pending:this.pending.length,keys:this.jobs.size}}pump(){for(;this.active<this.concurrency;){const r=this.pending.shift();if(!r)return;r.consumers!==0&&(r.started=!0,this.active++,this.execute(r.key).then(r.resolve,r.reject).finally(()=>{this.active--,this.jobs.delete(r.key),this.pump()}))}}}let sme=null;function uLr(t){return sme=t,()=>{sme===t&&(sme=null)}}function fLr(){return sme}class O4t{constructor(r,i="public"){this.inner=r,this.root=i,this.id=`frame:${r.id}`}id;resolve(r){const i=r.replace(/\\/g,"/").replace(/^\/+/,"");return i?`${this.root}/${i}`:this.root}read(r){return Qg.read(this.resolve(r))}readBytes(r){return Qg.readBytes(this.resolve(r))}write(r,i){return Qg.write(this.resolve(r),i)}async writeIfAbsent(r,i){return await this.exists(r)?!1:(await this.write(r,i),!0)}list(r){return this.inner.list(r)}stat(r){return this.inner.stat(r)}exists(r){return Qg.exists(this.resolve(r))}mkdir(r){return this.inner.mkdir(r)}remove(r){return this.inner.remove(r)}watch(r){return this.inner.watch(r)}}const dLr=new Set;let ZFe=null;async function HR(t,r){const i=await t.json().catch(()=>null);if(t.status===409&&i?.code==="SOURCE_REVISION_CONFLICT"&&typeof i.conflictId=="string"&&Number.isInteger(i.expectedRevision)&&Number.isInteger(i.currentRevision)&&Array.isArray(i.conflicts)){ZFe={id:globalThis.crypto?.randomUUID?.()??`conflict-${Date.now()}`,conflictId:i.conflictId,label:r.label,expectedRevision:i.expectedRevision,currentRevision:i.currentRevision,conflicts:i.conflicts,attempted:{...r.attempted??{}},base:i.bases&&typeof i.bases=="object"&&!Array.isArray(i.bases)?{...i.bases}:{},...r.reapply?{reapply:r.reapply}:{}};for(const a of dLr)a(ZFe);throw new Error(`${r.label} conflicts with source revision ${ZFe.currentRevision}; inspect it before reapplying.`)}throw new Error(typeof i?.error=="string"?i.error:`${r.label} failed with HTTP ${t.status}.`)}function F4t(t){return t.split("/").filter(r=>r.length>0&&r!==".")}function uv(t){return F4t(t).join("/")}function pLr(t){const r=F4t(t),i=r.pop()??"";return[r.join("/"),i]}const Upe="/__editor";class _Lr{constructor(r){this.projectRoot=r}id="http";async read(r){const i=await fetch(`/@fs/${this.projectRoot}/public/${uv(r)}`);if(!i.ok)throw new Error(`HttpStorage.read '${uv(r)}': HTTP ${i.status}`);return i.text()}async readBytes(r){const i=await fetch(`/@fs/${this.projectRoot}/public/${uv(r)}`);if(!i.ok)throw new Error(`HttpStorage.readBytes '${uv(r)}': HTTP ${i.status}`);return new Uint8Array(await i.arrayBuffer())}async write(r,i){const a=typeof i=="string"?{path:uv(r),content:i,...yw()}:{path:uv(r),content:Hhe(i),encoding:"base64",...yw()},l=await fetch(`${Upe}/save-file`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});np(l,`Write ${uv(r)} failed`),l.ok||await HR(l,{label:`Write ${uv(r)}`,attempted:{[`public/${uv(r)}`]:typeof i=="string"?i:`[${i.byteLength} binary bytes]`},reapply:()=>this.write(r,i)})}async writeIfAbsent(r,i){return await this.exists(r)?!1:(await this.write(r,i),!0)}async list(r){const i=await fetch(`${Upe}/assets?${new URLSearchParams({dir:uv(r)})}`),{entries:a}=await Eg(i,`HttpStorage.list '${uv(r)}' failed`);return a.map(l=>{const d={name:l.name,path:uv(r?`${r}/${l.name}`:l.name),type:l.type==="directory"?"dir":"file",mtime:l.mtime};return l.type==="file"&&(d.size=l.size),d.mtime=l.mtime,d})}async stat(r){const[i,a]=pLr(r);if(!a)return{path:"",type:"dir",size:0,mtime:0};let l;try{l=await this.list(i)}catch{return null}const d=l.find(_=>_.name===a);return d?{path:d.path,type:d.type,size:d.size??0,mtime:d.mtime??0}:null}async exists(r){return await this.stat(r)!==null}async mkdir(r){}async remove(r){const i=await fetch(`${Upe}/save-file`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:uv(r),delete:!0,...yw()})});np(i,`Delete ${uv(r)} failed`),i.ok||await HR(i,{label:`Delete ${uv(r)}`,attempted:{[`public/${uv(r)}`]:null},reapply:()=>this.remove(r)})}watch(r){const i=new EventSource(`${Upe}/events`),a=l=>{try{const d=JSON.parse(l.data),_=d.path??d.file;if(!_)return;r({type:d.type??"update",path:uv(_)})}catch{}};return i.addEventListener("message",a),()=>{i.removeEventListener("message",a),i.close()}}}let mR=null,e7e=null;function mLr(){return mR&&!(mR instanceof O4t)?mR:(e7e||(e7e=new _Lr(P0e())),e7e)}function _z(){if(mR)return mR;const t=mLr();return mR=D4t()?new O4t(t):t,mR}function hLr(){return crypto.randomUUID()}function t7e(t){return`resource:${t}`}function r7e(t){return t.slice(t.lastIndexOf("/")+1)}function PA(t){if(t.includes("\0"))throw new Error("Resource path cannot contain a NUL byte.");const r=t.replaceAll("\\","/");if(r.startsWith("/")||/^[a-zA-Z][a-zA-Z\d+.-]*:/.test(r))throw new Error(`Resource path must be project-relative: "${t}".`);const i=[];for(const a of r.split("/"))if(!(a===""||a===".")){if(a===".."){if(i.length===0)throw new Error(`Resource path escapes the project root: "${t}".`);i.pop();continue}i.push(a)}if(i.length===0)throw new Error("Resource path cannot be empty.");return i.join("/")}function gLr(t,r){const i=t.trim();if(!i||i==="."||i===".."||i.includes("/")||i.includes("\\")||i.includes("\0"))throw new Error(`${r} must be one non-empty path segment.`);return i}class yLr{constructor(r=hLr){this.makeId=r}descriptors=new Map;keyByLocation=new Map;inactive=new Set;registerProject(r,i,a){const l=PA(i),d=`project://${l}`,_=this.existingAt(d,r);return _||this.add({key:t7e(this.makeId()),kind:r,scope:"project",displayName:a??r7e(l),location:d,sessionId:null})}registerDraft(r,i){const a=this.makeId();return this.add({key:t7e(a),kind:r,scope:"project",displayName:i,location:`draft://${a}`,sessionId:null})}registerSession(r,i,a,l){const d=gLr(i,"Session id"),_=PA(a),g=`session://${d}/${_}`,b=this.existingAt(g,r);return b||this.add({key:t7e(this.makeId()),kind:r,scope:"session",displayName:l??r7e(_),location:g,sessionId:d})}setProjectLocation(r,i,a){const l=this.requireActive(r);if(l.scope!=="project")throw new Error("A session resource cannot become a project file.");const d=PA(i),_=`project://${d}`,g=this.keyByLocation.get(_);if(g&&g!==r)throw new Error(`Another resource is already registered at "${_}".`);l.location&&this.keyByLocation.delete(l.location);const b={...l,displayName:a??r7e(d),location:_};return this.descriptors.set(r,b),this.keyByLocation.set(_,r),b}get(r){return this.descriptors.get(r)??null}getByLocation(r){const i=this.keyByLocation.get(r);return i?this.descriptors.get(i)??null:null}isActive(r){return this.descriptors.has(r)&&!this.inactive.has(r)}expireSession(r){const i=[];for(const a of this.descriptors.values())a.sessionId!==r||this.inactive.has(a.key)||(this.inactive.add(a.key),i.push(a.key));return i}expireResources(r){const i=[];for(const a of r){const l=this.descriptors.get(a);!l||this.inactive.has(a)||(this.inactive.add(a),l.location&&this.keyByLocation.get(l.location)===a&&this.keyByLocation.delete(l.location),i.push(a))}return i}clear(){this.descriptors.clear(),this.keyByLocation.clear(),this.inactive.clear()}add(r){if(this.descriptors.has(r.key))throw new Error(`Duplicate resource key "${r.key}".`);if(r.location&&this.keyByLocation.has(r.location))throw new Error(`Duplicate resource location "${r.location}".`);return this.descriptors.set(r.key,r),r.location&&this.keyByLocation.set(r.location,r.key),r}existingAt(r,i){const a=this.keyByLocation.get(r);if(!a)return null;const l=this.descriptors.get(a);if(l.kind!==i)throw new Error(`Resource "${r}" is already registered as ${l.kind}, not ${i}.`);if(this.inactive.has(a))throw new Error(`Resource "${r}" has expired.`);return l}requireActive(r){const i=this.descriptors.get(r);if(!i)throw new Error(`Unknown resource key "${r}".`);if(this.inactive.has(r))throw new Error(`Resource "${r}" has expired.`);return i}}const R4t=0,rLe=1;function MN(t,r=new Uint8Array){const i=new Uint8Array(r.byteLength+1);return i[0]=t?rLe:R4t,t&&i.set(r,1),i}function vLr(t){const r=t[0];if(r!==R4t&&r!==rLe)throw new Error("Invalid project-file snapshot.");return{exists:r===rLe,bytes:t.slice(1)}}async function n7e(t,r,i,a){const l=await t.exists(r),d=MN(l,l?await t.readBytes(r):void 0);return{revision:i,contentType:a,bytes:d,sha256:await dE(d)}}class o2t extends Error{constructor(r){super(`Project file "${r}" no longer matches the bytes loaded into this Asset Lab document. Reopen the document to review the newer file; the editor did not overwrite it.`),this.path=r,this.name="ProjectFileContentConflictError"}}class bLr{constructor(r,i){this.history=r,this.backend=i}files=new Map;listeners=new Set;write(r,i,a){const l=PA(r),d=typeof i=="string"?new TextEncoder().encode(i):Uint8Array.from(i),_=this.file(l,a.kind??"project-file",a.contentType??(typeof i=="string"?"text/plain":"application/octet-stream"));return this.history.transaction({label:a.label,resources:[_.descriptor.key],scope:"project"},async g=>(await g.write(_.descriptor.key,MN(!0,d),_.contentType),!0))}writeWithResources(r,i,a,l){const d=PA(r),_=typeof i=="string"?new TextEncoder().encode(i):Uint8Array.from(i),g=this.file(d,a.kind??"project-file",a.contentType??(typeof i=="string"?"text/plain":"application/octet-stream"));return this.history.transaction({label:a.label,resources:[g.descriptor.key,...l.map(b=>b.resource)],scope:"project"},async b=>{await b.write(g.descriptor.key,MN(!0,_),g.contentType);for(const S of l)await b.write(S.resource,S.bytes,S.contentType);return!0})}remove(r,i){const a=PA(r),l=this.file(a,i.kind??"project-file",i.contentType??"application/octet-stream");return this.history.transaction({label:i.label,resources:[l.descriptor.key],scope:"project"},async d=>(await d.write(l.descriptor.key,MN(!1),l.contentType),!0))}mutate(r,i){const a=r.map(_=>{const g=PA(_.path),b=_.contentType??"application/octet-stream";return{change:_,file:this.file(g,_.kind??"project-file",b),contentType:b}}),l=new Set(a.map(({file:_})=>_.descriptor.key));if(l.size!==a.length)throw new Error("A project-file mutation cannot write the same path twice.");const d=new Map(i.expected?.map(_=>[PA(_.path),_.sha256]));if(i.expected&&(d.size!==a.length||a.some(({change:_})=>!d.has(PA(_.path)))))throw new Error("A guarded project-file mutation must cover exactly the opened paths.");return this.history.transaction({label:i.label,resources:[...l],scope:"project"},async _=>{for(const{change:g,file:b,contentType:S}of a){const k=await _.read(b.descriptor.key),w=PA(g.path),N=d.get(w);if(N!==void 0&&k.sha256!==N)throw new o2t(w);const P=g.data===null?MN(!1):MN(!0,typeof g.data=="string"?new TextEncoder().encode(g.data):Uint8Array.from(g.data));await _.write(b.descriptor.key,P,S)}return!0})}async openMutationSession(r){let i=await this.fingerprintMutations(r);const a=new Map(r.map(d=>[PA(d.path),d.contentType??"application/octet-stream"])),l=async()=>{for(const d of i)if((await n7e(this.backend,d.path,0,a.get(d.path)??"application/octet-stream")).sha256!==d.sha256)throw new o2t(d.path)};return await l(),{assertUnchanged:l,mutate:async(d,_)=>{const g=await this.fingerprintMutations(d),b=await this.mutate(d,{..._,expected:i});i=g;for(const S of d)a.set(PA(S.path),S.contentType??"application/octet-stream");return b}}}subscribe(r,i){const a=PA(r),l=this.files.get(a);if(!l)throw new Error(`Project file "${a}" is not registered with history.`);return l.listeners.add(i),()=>l.listeners.delete(i)}subscribeAll(r){return this.listeners.add(r),()=>this.listeners.delete(r)}file(r,i,a){const l=this.files.get(r);if(l){if(l.descriptor.kind!==i)throw new Error(`Project file "${r}" is already registered as ${l.descriptor.kind}.`);return l.contentType=a,l}const d=this.history.registry.registerProject(i,r),_={descriptor:d,revision:0,contentType:a,listeners:new Set},g={descriptor:d,capture:()=>n7e(this.backend,r,_.revision,_.contentType),preflight:async b=>{const S=await n7e(this.backend,r,_.revision,_.contentType);return S.sha256===b.sha256?{ok:!0}:{ok:!1,reason:"content-conflict",actualRevision:_.revision,actualSha256:S.sha256}},restore:async b=>{const S=vLr(this.history.snapshots.read(b).bytes);S.exists?await this.backend.write(r,S.bytes):await this.backend.remove(r),_.revision++;for(const k of _.listeners)k();for(const k of this.listeners)k(r)},estimateBytes:b=>b.byteLength};return this.history.registerDriver(g),this.files.set(r,_),_}async fingerprintMutations(r){const i=new Set,a=[];for(const l of r){const d=PA(l.path);if(i.has(d))throw new Error("A project-file mutation cannot write the same path twice.");i.add(d);const _=l.data===null?MN(!1):MN(!0,typeof l.data=="string"?new TextEncoder().encode(l.data):Uint8Array.from(l.data));a.push({path:d,sha256:await dE(_)})}return a}}const a2t=new WeakMap;function CUe(t,r=_z(),i="public"){let a=a2t.get(t);a||(a=new Map,a2t.set(t,a));const l=a.get(i);if(l){if(l.backend!==r)throw new Error("The project storage backend changed without creating a new editor session.");return l.manager}const d=new bLr(t,r);return a.set(i,{backend:r,manager:d}),d}class ALr{constructor(r,i){this.id=r,this.endpoint=i}async readBytes(r){const i=await fetch(`${this.endpoint}?${new URLSearchParams({path:r})}`);if(!i.ok)throw new Error(`${this.id}.readBytes '${r}': HTTP ${i.status}`);return new Uint8Array(await i.arrayBuffer())}async write(r,i){const a=typeof i=="string"?i:new TextDecoder().decode(i),l=await fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:r,content:a,...yw()})});np(l,`${this.id} write ${r} failed`),l.ok||await HR(l,{label:`${this.id} write ${r}`,attempted:{[r]:a},reapply:()=>this.write(r,i)})}async exists(r){const i=await fetch(`${this.endpoint}?${new URLSearchParams({path:r})}`);if(i.status===404)return!1;if(!i.ok)throw new Error(`${this.id}.exists '${r}': HTTP ${i.status}`);return!0}async remove(r){const i=await fetch(this.endpoint,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:r,...yw()})});np(i,`${this.id} delete ${r} failed`),i.ok||await HR(i,{label:`${this.id} delete ${r}`,attempted:{[r]:null},reapply:()=>this.remove(r)})}}const SLr=new ALr("project-manifest-http","/__editor/manifest");class xLr{id="project-resource-http";endpoint="/__editor/project-resource";async readBytes(r){const i=await fetch(`${this.endpoint}?${new URLSearchParams({path:r})}`);if(!i.ok)throw new Error(`${this.id}.readBytes '${r}': HTTP ${i.status}`);return new Uint8Array(await i.arrayBuffer())}async write(r,i){const a=typeof i=="string"?new TextEncoder().encode(i):i,l=await fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:r,content:Hhe(a),encoding:"base64",...yw()})});np(l,`${this.id} write ${r} failed`),l.ok||await HR(l,{label:`${this.id} write ${r}`,attempted:{[r]:`[${a.byteLength} bytes]`},reapply:()=>this.write(r,i)})}async exists(r){const i=await fetch(`${this.endpoint}?${new URLSearchParams({path:r})}`);if(i.status===404)return!1;if(!i.ok)throw new Error(`${this.id}.exists '${r}': HTTP ${i.status}`);return!0}async remove(r){const i=await fetch(this.endpoint,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:r,...yw()})});np(i,`${this.id} delete ${r} failed`),i.ok||await HR(i,{label:`${this.id} delete ${r}`,attempted:{[r]:null},reapply:()=>this.remove(r)})}}const wLr=new xLr;function $Dn(){return SLr}function M4t(){return wLr}let CX=null,L4t=null;const mz=new Set,nLe=new Set,iLe=new Set;let wZ=[];function J3(){return CX!==null}function CLr(t){if(CX!==t){CX=t,CX||(wZ=[]);for(const r of mz)r()}}function dY(){return CX}function j4t(t){return mz.add(t),()=>mz.delete(t)}function ELr(){for(const t of mz)t()}function B4t(t){const r={...t,document:t.document===void 0?L4t?.()??null:t.document};wZ.push(r);for(const i of nLe)i(r);for(const i of mz)i()}function TLr(t){L4t=t}function kLr(){return wZ}function ILr(t){return nLe.add(t),()=>nLe.delete(t)}function DLr(t){const r=new Set(t);wZ=wZ.filter(i=>!i.resources.some(a=>r.has(a)));for(const i of iLe)i(t);for(const i of mz)i()}function PLr(t){return iLe.add(t),()=>iLe.delete(t)}class NLr{tails=new Map;run(r,i){return this.runMany([r],i)}async runMany(r,i){const a=[...new Set(r)].sort();if(a.length===0)return i();const l=a.map(S=>this.tails.get(S)??Promise.resolve()),d=Promise.all(l).then(()=>{});let _;const g=new Promise(S=>{_=S}),b=d.then(()=>g);for(const S of a)this.tails.set(S,b);await d;try{return await i()}finally{_();for(const S of a)this.tails.get(S)===b&&this.tails.delete(S)}}}function OLr(t,r){if(t.byteLength!==r.byteLength)return!1;for(let i=0;i<t.byteLength;i++)if(t[i]!==r[i])return!1;return!0}class FLr{blobs=new Map;retainedBytes=0;async put(r){if(!Number.isSafeInteger(r.revision)||r.revision<0)throw new Error("Snapshot revision must be a non-negative safe integer.");const i=Uint8Array.from(r.bytes),a=await dE(i),l=this.blobs.get(a);if(l){if(!OLr(l.bytes,i))throw new Error(`SHA-256 collision for ${a}.`);l.references++}else this.blobs.set(a,{bytes:i,references:1}),this.retainedBytes+=i.byteLength;return{revision:r.revision,contentType:r.contentType,sha256:a,blobKey:a,byteLength:i.byteLength}}retain(r){const i=this.requireBlob(r);i.references++}release(r){const i=this.requireBlob(r);i.references--,i.references===0&&(this.blobs.delete(r.blobKey),this.retainedBytes-=i.bytes.byteLength)}read(r){const i=this.requireBlob(r);return{revision:r.revision,contentType:r.contentType,bytes:Uint8Array.from(i.bytes),sha256:r.sha256}}has(r){const i=this.blobs.get(r.blobKey);return!!i&&i.bytes.byteLength===r.byteLength}get uniqueBlobCount(){return this.blobs.size}get uniqueByteLength(){return this.retainedBytes}get referenceCount(){let r=0;for(const i of this.blobs.values())r+=i.references;return r}clear(){this.blobs.clear(),this.retainedBytes=0}requireBlob(r){const i=this.blobs.get(r.blobKey);if(!i)throw new Error(`Snapshot blob "${r.blobKey}" is not retained.`);if(r.sha256!==r.blobKey||i.bytes.byteLength!==r.byteLength)throw new Error(`Snapshot reference "${r.blobKey}" does not match its retained blob.`);return i}}const RLr=2e3,MLr=64*1024*1024,LLr=16*1024*1024,jLr=.8,c2t="project://";class dv extends Error{constructor(r){super(r.message),this.historyError=r,this.name="HistoryOperationError"}}function BLr(){return crypto.randomUUID()}function $Lr(t){const i=(t instanceof Error?t.message:typeof t=="string"?t:null)?.trim();return i||null}function Gg(t,r,i,a){const l=$Lr(a),d=l&&!r.includes(l)?`${r} ${l.endsWith(".")?l:`${l}.`}`:r,_={code:t,message:d,resources:i};return a===void 0?_:{..._,cause:a}}function sLe(t){return`${(t/(1024*1024)).toFixed(1)} MB`}function qLr(t,r){return`${t} ${r}${t===1?"":"s"}`}function zLr(t,r,i,a){return t==="transactions"?`Undo history is near its step limit — ${r} of ${a.maxTransactions} steps in this editing session. Older steps will start dropping; raise maxTransactions to keep more.`:`Undo history is near its memory limit — ${sLe(i)} of ${sLe(a.maxBytes)} of in-memory snapshots, at only ${r} of ${a.maxTransactions} steps. Memory binds first here; raise maxBytes to keep more.`}function ULr(t,r,i){const a=t==="transactions"?`${i.maxTransactions}-step limit`:`${sLe(i.maxBytes)} memory limit`;return`Undo history dropped ${qLr(r,"older step")} to stay within its ${a}. Those edits can no longer be undone; saved files are unaffected.`}function l2t(t){const r=new Map;for(const a of t)r.set(a.before.blobKey,a.before.byteLength),r.set(a.after.blobKey,a.after.byteLength);let i=0;for(const a of r.values())i+=a;return i}class VLr{registry;snapshots;persistence;limits;drivers=new Map;listeners=new Set;commitListeners=new Set;makeId;now;entries=[];cursorValue=0;version=0;pendingExecutions=0;pendingProducers=0;activeTransaction=!1;disposeRequested=!1;disposeComplete=!1;blockedValue=!1;lastErrorValue=null;limitWarningValue=null;lastEvictionValue=null;droppedTotal=0;executionTail=Promise.resolve();publicSnapshot;unsubscribeOwner;constructor(r={}){if(this.registry=r.registry??new yLr,this.snapshots=r.snapshots??new FLr,this.persistence=r.persistence??new NLr,this.makeId=r.makeId??BLr,this.now=r.now??Date.now,this.limits={maxTransactions:r.limits?.maxTransactions??RLr,maxBytes:r.limits?.maxBytes??MLr,maxTransactionBytes:r.limits?.maxTransactionBytes??LLr},this.limits.maxTransactions<1||this.limits.maxBytes<1||this.limits.maxTransactionBytes<1||this.limits.maxTransactionBytes>this.limits.maxBytes)throw new Error("History limits must be positive.");this.publicSnapshot=this.buildSnapshot(),this.unsubscribeOwner=j4t(()=>this.notify())}subscribe=r=>this.disposeRequested?()=>{}:(this.listeners.add(r),()=>this.listeners.delete(r));getSnapshot=()=>{if(J3()){const r=this.buildSnapshot();(r.canUndo!==this.publicSnapshot.canUndo||r.canRedo!==this.publicSnapshot.canRedo||r.undoLabel!==this.publicSnapshot.undoLabel||r.redoLabel!==this.publicSnapshot.redoLabel)&&(this.publicSnapshot=r)}return this.publicSnapshot};subscribeCommits(r){return this.assertNotDisposed(),this.commitListeners.add(r),()=>this.commitListeners.delete(r)}reserveProducer(){this.assertNotDisposed(),this.pendingProducers++,this.notify();let r=!1;return()=>{r||(r=!0,this.pendingProducers--,this.finishDisposeIfIdle(),this.disposeComplete||this.notify())}}registerDriver(r){this.assertNotDisposed();const i=r.descriptor.key;if(!this.registry.get(i))throw new Error(`Driver resource "${i}" is not registered.`);if(this.drivers.has(i))throw new Error(`Resource "${i}" already has a driver.`);return this.drivers.set(i,r),()=>{this.drivers.get(i)===r&&this.drivers.delete(i)}}transaction(r,i){return this.validateOptions(r),this.activeTransaction?Promise.reject(new dv(Gg("busy","A history transaction cannot nest another transaction.",[]))):this.enqueue(()=>this.transactionNow(r,i))}async transactionNow(r,i){this.assertCanStartTransaction(),this.activeTransaction=!0,this.notify();const a=new Set(r.resources),l=new Map,d=async g=>{if(!a.has(g))throw new Error(`Transaction did not declare resource "${g}".`);const b=l.get(g);if(b)return b;const S=this.requireDriver(g);this.validateResourceScope(S,r);const k=await S.capture(),w=await this.storeCapturedSnapshot(k),N={driver:S,beforeSnapshot:k,before:w,afterBytes:Uint8Array.from(k.bytes),afterContentType:k.contentType,beforeOwned:!0};return l.set(g,N),N},_={read:async g=>{const b=await d(g);return{revision:b.beforeSnapshot.revision,contentType:b.afterContentType,bytes:Uint8Array.from(b.afterBytes),sha256:b.beforeSnapshot.sha256}},write:async(g,b,S)=>{const k=await d(g);k.afterBytes=Uint8Array.from(b),k.afterContentType=S??k.afterContentType},writeText:async(g,b,S="text/plain")=>{await _.write(g,new TextEncoder().encode(b),S)},writeJson:async(g,b)=>{await _.writeText(g,JSON.stringify(b,null,2),"application/json")}};try{const g=await i(_),b=await this.finishStaging(l);return b.length===0||await this.commitStagedTransaction(r,b),g}finally{for(const g of l.values())g.beforeOwned&&this.snapshots.release(g.before);this.activeTransaction=!1,this.finishDisposeIfIdle(),this.disposeComplete||this.notify()}}undo(){return J3()?Promise.resolve(this.delegateOrRefuse("undo")):this.enqueue(()=>this.undoNow())}redo(){return J3()?Promise.resolve(this.delegateOrRefuse("redo")):this.enqueue(()=>this.redoNow())}executeEntry(r,i){return this.enqueue(async()=>{const a=this.entries.find(l=>l.id===r);if(!a)return this.lastErrorValue=Gg("expired",`History entry "${r}" is no longer recorded, so it cannot be ${i}ne.`,[]),this.notify(),!1;if(a.status==="expired"){const l=Gg("expired",`“${a.label}” belongs to an expired session.`,[]);return a.error=l,this.lastErrorValue=l,this.notify(),!1}return this.executeExisting(a,i,!1)})}async delegateOrRefuse(r){const i=dY();if(i){if(!(r==="undo"?i.canUndo():i.canRedo()))return!1;try{return(r==="undo"?await i.undo():await i.redo())!==!1}finally{this.notify()}}return this.lastErrorValue=Gg("busy",`History ${r} belongs to the frame while the editor runs inside one, and the frame has not installed its undo yet.`,[]),this.notify(),!1}recordAppliedTransaction(r,i){if(this.assertCanRecordAppliedChange(),this.validateOptions(r),i.length===0)return Promise.resolve(!1);const a=new Set(r.resources);if(i.length!==a.size||i.some(l=>!a.has(l.resource)))return Promise.reject(new Error("Applied history changes must exactly match declared resources."));for(const l of i){const d=this.requireDriver(l.resource);this.validateResourceScope(d,r)}return this.enqueue(async()=>{this.assertCanRecordAppliedChange();const l=[];try{for(const d of i){const _=await this.snapshots.put({revision:0,contentType:d.contentType,bytes:d.beforeBytes}),g=await this.snapshots.put({revision:1,contentType:d.contentType,bytes:d.afterBytes});if(_.sha256===g.sha256){this.snapshots.release(_),this.snapshots.release(g);continue}l.push({resource:d.resource,before:_,after:g})}return l.length===0?!1:(this.appendAppliedTransaction(r,l),!0)}catch(d){throw this.releaseChanges(l),this.lastErrorValue=d instanceof dv?d.historyError:Gg("apply-failed",`Failed to journal “${r.label.trim()}”.`,i.map(_=>_.resource),d),this.notify(),d}})}assertCanRecordAppliedChange(){if(this.assertNotDisposed(),this.blockedValue)throw this.lastErrorValue?.code==="compensation-failed"?new dv(this.lastErrorValue):new dv(Gg("compensation-failed","History is blocked pending recovery.",[]))}reportAppliedChangeFailure(r,i,a){this.blockedValue||(this.lastErrorValue=Gg("apply-failed",`Failed to apply “${r.trim()}”; prior state was restored.`,i,a),this.notify())}blockForCompensationFailure(r,i,a){if(this.blockedValue&&this.lastErrorValue?.code==="compensation-failed")return new dv(this.lastErrorValue);const l=Gg("compensation-failed",`History recovery failed while applying “${r.trim()}”.`,i,a);return this.blockedValue=!0,this.lastErrorValue=l,this.notify(),new dv(l)}jumpTo(r){return!Number.isInteger(r)||r<0||r>this.entries.length?Promise.reject(new Error(`History cursor ${r} is out of range.`)):this.enqueue(async()=>{for(;this.cursorValue>r;)if(!await this.undoNow())return!1;for(;this.cursorValue<r;)if(!await this.redoNow())return!1;return!0})}expireSession(r){if(this.disposeRequested)return;const i=new Set(this.registry.expireSession(r));i.size!==0&&(this.entries=this.entries.map(a=>a.sessionId===r||a.changes.some(l=>i.has(l.resource))?{...a,status:"expired",error:null}:a),this.notify())}expireResources(r){if(this.disposeRequested)return;const i=new Set(this.registry.expireResources(r));i.size!==0&&(this.entries=this.entries.map(a=>a.changes.some(l=>i.has(l.resource))?{...a,status:"expired",error:null}:a),this.notify())}dispose(){this.disposeRequested||(this.disposeRequested=!0,this.unsubscribeOwner(),this.listeners.clear(),this.commitListeners.clear(),this.finishDisposeIfIdle())}finishDisposeIfIdle(){if(!(!this.disposeRequested||this.disposeComplete||this.activeTransaction||this.pendingExecutions>0||this.pendingProducers>0)){for(const r of this.entries)this.releaseChanges(r.changes);this.entries=[],this.cursorValue=0,this.drivers.clear(),this.registry.clear(),this.snapshots.clear(),this.blockedValue=!1,this.lastErrorValue=null,this.limitWarningValue=null,this.lastEvictionValue=null,this.droppedTotal=0,this.disposeComplete=!0,this.notify()}}async finishStaging(r){const i=[];try{for(const[a,l]of r){const d=await this.snapshots.put({revision:l.beforeSnapshot.revision+1,contentType:l.afterContentType,bytes:l.afterBytes});if(d.sha256===l.before.sha256){this.snapshots.release(d),this.snapshots.release(l.before),l.beforeOwned=!1;continue}i.push({resource:a,before:l.before,after:d}),l.beforeOwned=!1}return i}catch(a){throw this.releaseChanges(i),a}}async commitStagedTransaction(r,i){const a=l2t(i);if(a>this.limits.maxTransactionBytes)throw this.releaseChanges(i),new dv(Gg("history-limit",`Transaction requires ${a} bytes; the limit is ${this.limits.maxTransactionBytes}.`,i.map(d=>d.resource)));const l={id:this.makeId(),label:r.label.trim(),detail:r.detail?.trim()||null,timestamp:this.now(),scope:r.scope,sessionId:r.scope==="session"?r.sessionId:null,changes:i,byteSize:a,mergeKey:r.mergeKey?.trim()||null,status:"committed",error:null};try{this.assertCanRecordAppliedChange(),await this.persistence.runMany(i.map(d=>d.resource),async()=>{this.assertCanRecordAppliedChange(),await this.preflight(l,"redo"),await this.applyWithCompensation(l,"redo")})}catch(d){const _=d instanceof dv?d.historyError:Gg("apply-failed",`Failed to commit “${l.label}”.`,i.map(g=>g.resource),d);throw this.lastErrorValue=_,_.code==="compensation-failed"&&(this.blockedValue=!0),this.releaseChanges(i),this.notify(),d}this.truncateRedo(),this.entries.push(l),this.cursorValue=this.entries.length,this.blockedValue||(this.lastErrorValue=null),this.trimToLimits(),this.notify();for(const d of this.commitListeners)d(l);this.offerElement(l)}appendAppliedTransaction(r,i){const a=l2t(i);if(a>this.limits.maxTransactionBytes)throw this.releaseChanges(i),new dv(Gg("history-limit",`Transaction requires ${a} bytes; the limit is ${this.limits.maxTransactionBytes}.`,i.map(d=>d.resource)));const l={id:this.makeId(),label:r.label.trim(),detail:r.detail?.trim()||null,timestamp:this.now(),scope:r.scope,sessionId:r.scope==="session"?r.sessionId:null,changes:i,byteSize:a,mergeKey:r.mergeKey?.trim()||null,status:i.every(d=>this.registry.isActive(d.resource))?"committed":"expired",error:null};this.truncateRedo(),this.entries.push(l),this.cursorValue=this.entries.length,this.blockedValue||(this.lastErrorValue=null),this.trimToLimits(),this.notify();for(const d of this.commitListeners)d(l);this.offerElement(l)}offerElement(r){if(!J3())return;const i=[];for(const a of r.changes){const l=this.registry.get(a.resource)?.location;if(!l?.startsWith(c2t))continue;const d=l.slice(c2t.length);i.includes(d)||i.push(d)}B4t({id:r.id,label:r.label,resources:i,undo:()=>this.executeEntry(r.id,"undo"),redo:()=>this.executeEntry(r.id,"redo")})}async undoNow(){if(this.cursorValue===0||this.blockedValue)return!1;const r=this.entries[this.cursorValue-1];if(r.status==="expired"){const i=Gg("expired",`“${r.label}” belongs to an expired session.`,[]);return r.error=i,this.lastErrorValue=i,this.notify(),!1}return this.executeExisting(r,"undo")}async redoNow(){if(this.cursorValue>=this.entries.length||this.blockedValue)return!1;const r=this.entries[this.cursorValue];if(r.status==="expired"){const i=Gg("expired",`“${r.label}” belongs to an expired session.`,[]);return r.error=i,this.lastErrorValue=i,this.notify(),!1}return this.executeExisting(r,"redo")}async executeExisting(r,i,a=!0){const l=r.changes.map(d=>d.resource);try{return await this.persistence.runMany(l,async()=>{await this.preflight(r,i),r.status=i==="undo"?"undoing":"redoing",r.error=null,this.notify(),await this.applyWithCompensation(r,i)}),i==="undo"?(a&&this.cursorValue--,r.status="undone"):(a&&this.cursorValue++,r.status="committed"),r.error=null,this.lastErrorValue=null,this.notify(),!0}catch(d){const _=d instanceof dv?d.historyError:Gg("apply-failed",`Failed to ${i} “${r.label}”.`,l,d);return r.error=_,r.status=_.code==="compensation-failed"?"failed-partial":"failed",this.lastErrorValue=_,_.code==="compensation-failed"&&(this.blockedValue=!0),this.notify(),!1}}async preflight(r,i){for(const a of r.changes){if(!this.registry.isActive(a.resource))throw new dv(Gg("expired",`Resource "${a.resource}" is unavailable.`,[a.resource]));const l=i==="undo"?a.after:a.before,d=await this.requireDriver(a.resource).preflight(l);if(!d.ok)throw new dv(Gg(d.reason==="expired"?"expired":"conflict",`Resource "${a.resource}" no longer matches “${r.label}”.`,[a.resource]))}}async applyWithCompensation(r,i){const a=i==="undo"?[...r.changes].reverse():[...r.changes],l=[];try{for(const d of a){const _=i==="undo"?d.before:d.after;await this.requireDriver(d.resource).restore(_),l.push(d)}}catch(d){try{for(const _ of[...l].reverse()){const g=i==="undo"?_.after:_.before;await this.requireDriver(_.resource).restore(g)}}catch(_){throw new dv(Gg("compensation-failed",`History recovery failed while applying “${r.label}”.`,r.changes.map(g=>g.resource),{applyError:d,compensationError:_}))}throw new dv(Gg("apply-failed",`Failed to apply “${r.label}”; prior state was restored.`,r.changes.map(_=>_.resource),d))}}enqueue(r){if(this.disposeRequested)return Promise.reject(new Error("History service is disposed."));this.pendingExecutions++,this.notify();const i=()=>(this.assertNotDisposed(),r()),a=this.executionTail.then(i,i);return this.executionTail=a.then(()=>{},()=>{}),a.finally(()=>{this.pendingExecutions--,this.finishDisposeIfIdle(),this.disposeComplete||this.notify()})}async storeCapturedSnapshot(r){const i=await this.snapshots.put({revision:r.revision,contentType:r.contentType,bytes:r.bytes});if(i.sha256!==r.sha256)throw this.snapshots.release(i),new Error("Resource driver returned bytes that do not match its SHA-256.");return i}truncateRedo(){if(this.cursorValue!==this.entries.length){for(const r of this.entries.slice(this.cursorValue))this.releaseChanges(r.changes);this.entries=this.entries.slice(0,this.cursorValue)}}trimToLimits(){if(J3()){this.evaluateLimitWarning();return}let r=0,i=null;for(;this.entries.length>1;){const a=this.snapshots.uniqueByteLength>this.limits.maxBytes,l=this.entries.length>this.limits.maxTransactions;if(!a&&!l)break;i=a?"bytes":"transactions";const[d,..._]=this.entries;this.entries=_,this.releaseChanges(d.changes),this.cursorValue=Math.max(0,this.cursorValue-1),r++}r>0&&(this.droppedTotal+=r,this.lastEvictionValue={budget:i,droppedCount:r,totalDropped:this.droppedTotal,message:ULr(i,r,this.limits)}),this.evaluateLimitWarning()}evaluateLimitWarning(){const r=this.entries.length/this.limits.maxTransactions,i=this.snapshots.uniqueByteLength/this.limits.maxBytes;if(Math.max(r,i)<jLr){this.limitWarningValue=null;return}const a=i>r?"bytes":"transactions";if(this.limitWarningValue?.budget===a)return;const l=this.snapshots.uniqueByteLength;this.limitWarningValue={budget:a,used:a==="bytes"?l:this.entries.length,limit:a==="bytes"?this.limits.maxBytes:this.limits.maxTransactions,message:zLr(a,this.entries.length,l,this.limits)}}releaseChanges(r){for(const i of r)this.snapshots.has(i.before)&&this.snapshots.release(i.before),this.snapshots.has(i.after)&&this.snapshots.release(i.after)}requireDriver(r){const i=this.drivers.get(r);if(!i)throw new Error(`No history resource driver is registered for "${r}".`);return i}validateOptions(r){if(!r.label.trim())throw new Error("History transaction label cannot be empty.");if(r.resources.length===0)throw new Error("History transaction needs a resource.");if(new Set(r.resources).size!==r.resources.length)throw new Error("History transaction resources must be unique.");if(r.scope==="session"&&!r.sessionId?.trim())throw new Error("A session transaction requires a session id.");if(r.scope==="project"&&r.sessionId!==void 0)throw new Error("A project transaction cannot have a session id.")}assertCanStartTransaction(){if(this.assertNotDisposed(),this.blockedValue)throw new dv(Gg("compensation-failed","History is blocked pending recovery.",[]));if(this.activeTransaction)throw new dv(Gg("busy","Another history operation is already in progress.",[]))}assertNotDisposed(){if(this.disposeRequested)throw new Error("History service is disposed.")}validateResourceScope(r,i){const a=r.descriptor;if(a.scope!==i.scope)throw new Error(`Resource "${a.key}" does not match transaction scope.`);if(i.scope==="session"&&a.sessionId!==i.sessionId)throw new Error(`Resource "${a.key}" belongs to another session.`)}notify(){this.version++,this.publicSnapshot=this.buildSnapshot();for(const r of this.listeners)r()}buildSnapshot(){const r=this.cursorValue>0?this.entries[this.cursorValue-1]:null,i=this.cursorValue<this.entries.length?this.entries[this.cursorValue]:null,a=this.pendingExecutions===0&&this.pendingProducers===0&&!this.activeTransaction;return{version:this.version,transactions:this.entries.map(l=>({...l,changes:l.changes.map(d=>({...d}))})),cursor:this.cursorValue,busy:!a,blocked:this.blockedValue,canUndo:J3()?dY()?.canUndo()??!1:a&&!!r&&r.status!=="expired"&&!this.blockedValue,canRedo:J3()?dY()?.canRedo()??!1:a&&!!i&&i.status!=="expired"&&!this.blockedValue,undoLabel:J3()?dY()?.undoLabel?.()??null:r?.label??null,redoLabel:J3()?dY()?.redoLabel?.()??null:i?.label??null,uniqueSnapshotBytes:this.snapshots.uniqueByteLength,lastError:this.lastErrorValue,limitWarning:this.limitWarningValue,lastEviction:this.lastEvictionValue}}}const z7=new TextEncoder,JLr=new TextDecoder;class WLr{constructor(r,i){this.history=r,this.backend=i}resources=new Map;tail=Promise.resolve();commit(r,i){try{this.history.assertCanRecordAppliedChange()}catch(l){return Promise.reject(l)}const a=this.history.reserveProducer();return this.enqueue(()=>(this.history.assertCanRecordAppliedChange(),this.prepareAndCommit(r,i))).finally(a)}replaceSource(r,i,a){try{this.history.assertCanRecordAppliedChange()}catch(d){return Promise.reject(d)}const l=this.history.reserveProducer();return this.enqueue(async()=>{this.history.assertCanRecordAppliedChange();const d=await this.backend.readSource(i);if(d.source===a)return!1;const _=this.resource(i,d.resourcePath);return this.history.transaction({label:r,resources:[_.descriptor.key],scope:"project"},async g=>(await g.writeText(_.descriptor.key,a,"text/typescript"),!0))}).finally(l)}runGesture(r,i){try{this.history.assertCanRecordAppliedChange()}catch(l){return Promise.reject(l)}const a=this.history.reserveProducer();return this.enqueue(async()=>{this.history.assertCanRecordAppliedChange();const l={label:r,files:new Map,applyOrder:[]};try{const d=await i(this.scopedBackend(l));return await this.recordGesture(l),d}catch(d){try{await this.compensateGesture(l)}catch(_){throw this.history.blockForCompensationFailure(r,this.gestureResourceKeys(l),{operationError:d,compensationError:_})}throw d instanceof dv||this.history.reportAppliedChangeFailure(r,this.gestureResourceKeys(l),d),d}}).finally(a)}enqueue(r){const i=this.tail.then(r,r);return this.tail=i.then(()=>{},()=>{}),i}scopedBackend(r){const i=d=>this.applyInGesture(r,d),{runGesture:a,...l}=this.backend;return{...l,historyManaged:!0,writeStyle:(d,_,g)=>i({kind:"style",oid:d,prop:_,value:g}),removeStyle:(d,_)=>i({kind:"style",oid:d,prop:_,value:null}),writeCss:(d,_,g,b,S)=>i({kind:"css",file:d,selector:_,prop:g,value:b,...S!==void 0?{media:S}:{}}),writeText:(d,_)=>i({kind:"text",oid:d,text:_}),writeProp:(d,_,g,b)=>i({kind:"prop",oid:d,prop:_,value:g,...b?.addIfMissing?{addIfMissing:!0}:{},...b?.allowShapeUpgrade?{allowShapeUpgrade:!0}:{}}),removeProp:(d,_)=>i({kind:"prop",oid:d,prop:_,value:null}),writeComponentDefault:(d,_,g)=>i({kind:"component-default",oid:d,prop:_,value:g}),writeStruct:(d,_,g)=>i({kind:"struct",oid:d,op:_,...g}),writeStructMany:(d,_,g)=>i({kind:"struct-many",oids:d,op:_,...g})}}async recordGesture(r){const i=[...r.files.entries()].filter(([,a])=>a.beforeSha!==a.afterSha).map(([a,l])=>({resource:this.resource(a,l.resourcePath).descriptor.key,beforeBytes:z7.encode(l.before),afterBytes:z7.encode(l.after),contentType:"text/plain"}));i.length!==0&&await this.history.recordAppliedTransaction({label:r.label,resources:i.map(a=>a.resource),scope:"project"},i)}async prepareAndCommit(r,i){const a=await this.backend.prepare(i),l=this.response(a);if(!a.changed||!a.file||!a.resourcePath||a.newSource===void 0)return l;const d=this.resource(a.file,a.resourcePath);return await this.history.transaction({label:r,resources:[d.descriptor.key],scope:"project"},_=>_.writeText(d.descriptor.key,a.newSource,"text/plain")),l}async applyInGesture(r,i){const a=await this.backend.prepare(i),l=this.response(a);if(!a.changed||!a.file||!a.resourcePath||a.newSource===void 0||a.prevSource===void 0||a.prevSha===void 0)return l;const d=a.newSha??await dE(z7.encode(a.newSource)),_=r.files.get(a.file);_?(_.knownShas.add(a.prevSha),_.knownShas.add(d)):r.files.set(a.file,{resourcePath:a.resourcePath,before:a.prevSource,beforeSha:a.prevSha,after:a.prevSource,afterSha:a.prevSha,knownShas:new Set([a.prevSha,d])});const g=r.files.get(a.file);g.after=a.newSource,g.afterSha=d,r.applyOrder.push(a.file);const b=await this.backend.applySource(a.file,a.newSource,a.prevSha);if(!b.applied)throw new Error(b.error??`Failed to apply source file "${a.file}".`);return l}async compensateGesture(r){const i=new Set,a=[...r.applyOrder].reverse().filter(l=>i.has(l)?!1:(i.add(l),!0));for(const l of a){const d=r.files.get(l),_=await this.backend.readSource(l),g=await dE(z7.encode(_.source));if(_.sha!==g)throw new Error(`Source file "${l}" returned bytes that do not match its hash.`);if(g===d.beforeSha)continue;if(!d.knownShas.has(g))throw new Error(`Source file "${l}" changed outside the failed gesture.`);const b=await this.backend.applySource(l,d.before,g);if(!b.applied)throw new Error(b.error??`Failed to compensate source file "${l}".`);const S=await this.backend.readSource(l),k=await dE(z7.encode(S.source));if(S.sha!==k||k!==d.beforeSha)throw new Error(`Source file "${l}" compensated with the wrong hash.`)}}gestureResourceKeys(r){return[...r.files.entries()].map(([i,a])=>this.resource(i,a.resourcePath).descriptor.key)}response(r){return{changed:r.changed,...r.result,file:r.file,prevSource:r.prevSource,newSource:r.newSource,prevSha:r.prevSha,newSha:r.newSha}}sourceResourceKey(r,i){return this.resource(r,i).descriptor.key}resource(r,i){const a=this.resources.get(r);if(a)return a;const l=this.history.registry.registerProject("source",i),d={descriptor:l,expectedSha:null,binary:!1},_={descriptor:l,capture:async()=>{const g=await this.backend.readSource(r);return d.binary=g.bytes!==void 0,{revision:0,contentType:d.binary?"application/octet-stream":"text/plain",bytes:g.bytes??z7.encode(g.source),sha256:g.sha}},preflight:async g=>{const b=await this.backend.readSource(r);return d.expectedSha=b.sha,d.binary=b.bytes!==void 0,b.sha===g.sha256?{ok:!0}:{ok:!1,reason:"content-conflict",actualSha256:b.sha}},restore:async g=>{const b=d.expectedSha;if(d.expectedSha=null,!b)throw new Error(`Source resource "${r}" was not preflighted.`);const S=this.history.snapshots.read(g).bytes,k=d.binary?S:JLr.decode(S),w=await this.backend.applySource(r,k,b);if(!w.applied)throw new Error(w.error??`Failed to apply source file "${r}".`);if((w.sha??await dE(typeof k=="string"?z7.encode(k):k))!==g.sha256)throw new Error(`Source file "${r}" restored with the wrong hash.`)},estimateBytes:g=>g.byteLength};return this.history.registerDriver(_),this.resources.set(r,d),d}}const u2t=new WeakMap;function HLr(t,r){let i=u2t.get(r);i||(i=new WeakMap,u2t.set(r,i));const a=t.historyIdentity??t;let l=i.get(a);return l||(l=new WLr(r,t),i.set(a,l)),l}function GLr(t,r,i){return!t.readSource||!t.applySource?Promise.reject(new Error("This editor tier cannot write project source.")):HLr(t,r).replaceSource(i.label,i.file,i.source)}function QLr(t){if(t&&typeof t=="object"&&"revision"in t){const r=t.revision;typeof r=="number"&&EDt(r)}}async function hb(t,r){const i=yw(),a=r&&typeof r=="object"&&!Array.isArray(r)?{...r,...i}:r,l=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});if(l.ok===!1&&l.status===409){const _=r&&typeof r=="object"&&!Array.isArray(r)?r:{},g=typeof _.file=="string"?_.file:null,b=g&&typeof _.source=="string"?{[g]:_.source}:{};await HR(l,{label:`Source mutation ${t}`,attempted:b,reapply:()=>hb(t,r).then(()=>{})})}const d=await oLe(l,t);return QLr(d),d}async function oLe(t,r){np(t,`Source request ${r} failed`);let i;try{i=await t.json()}catch(a){throw t.ok!==!1?a:new Error(`Source request ${r} failed with HTTP ${t.status}.`,{cause:a})}if(t.ok===!1){const a=i&&typeof i=="object"?String(i.error??i.message??t.statusText):t.statusText;throw new Error(`Source request ${r} failed with HTTP ${t.status}${a?`: ${a}`:""}.`)}return i}const aLe=new Map;function f2t(t,r){const i=t.file??r;i&&t.resourcePath&&aLe.set(i,t.resourcePath)}async function KLr(t){const r=aLe.get(t);if(r)return r;const i=await hb("/__ui-source/read",{file:t});return aLe.set(t,i.resourcePath),i.resourcePath}async function YLr(t,r,i){const a=await KLr(t),l=typeof r=="string";let d;try{d=l?await dE(new TextEncoder().encode(await Qg.read(a))):await dE(await Qg.readBytes(a))}catch(g){return{applied:!1,error:`Could not read "${a}" to guard the write: ${String(g)}`}}return d!==i?{applied:!1,sha:d,error:"stale: the file changed since this undo/redo entry was recorded"}:(await Qg.write(a,r),{applied:!0,sha:l?await dE(new TextEncoder().encode(r)):await dE(r)})}function $4t(){return{historyIdentity:XLr,prepare:async t=>{const r=await hb("/__ui-source/prepare",t);return f2t(r),r},readSource:async t=>{const r=await hb("/__ui-source/read",{file:t});return f2t(r,t),r},applySource:(t,r,i)=>Qg.frameOwned()?YLr(t,r,i):hb("/__ui-source/apply",{file:t,source:r,ifMatchSha:i}),writeStyle:(t,r,i)=>hb("/__ui-source/write",{oid:t,prop:r,value:i}),removeStyle:(t,r)=>hb("/__ui-source/write",{oid:t,prop:r,value:null}),writeCss:(t,r,i,a,l)=>hb("/__ui-source/css",{file:t,selector:r,prop:i,value:a,...l!==void 0?{media:l}:{}}),writeText:(t,r)=>hb("/__ui-source/text",{oid:t,text:r}),writeProp:(t,r,i,a)=>hb("/__ui-source/prop",{oid:t,prop:r,value:i,...a?.addIfMissing?{addIfMissing:!0}:{},...a?.allowShapeUpgrade?{allowShapeUpgrade:!0}:{}}),removeProp:(t,r)=>hb("/__ui-source/prop",{oid:t,prop:r,value:null}),writeStruct:(t,r,i)=>hb("/__ui-source/struct",{oid:t,op:r,...i}),writeStructMany:(t,r,i)=>hb("/__ui-source/struct-many",{oids:t,op:r,...i}),forkComponent:(t,r,i)=>hb("/__ui-source/fork-component",{oid:t,definitionOid:r,...i?{name:i}:{}}),extractComponent:(t,r)=>hb("/__ui-source/extract-component",{oid:t,...r?{name:r}:{}}),index:async()=>{const t=await fetch("/__ui-source/index");return oLe(t,"/__ui-source/index")},componentProps:async(t,r)=>{const i=`/__ui-source/component-props?file=${encodeURIComponent(t)}&name=${encodeURIComponent(r.name)}`,a=await fetch(i);return(await oLe(a,"/__ui-source/component-props")).props??[]}}}const XLr={};let pY=null,cLe=null;function EUe(){if(!pY){const t=Promise.resolve().then(()=>fetch("/__editor/project")).then(r=>Eg(r,"`/__editor/project` did not answer the source-write probe")).then(r=>{const i={ui:!!r.sourceWrite,ingest:!!r.ingestSourceWrite};return cLe=i,i}).catch(()=>(pY===t&&(pY=null),{ui:!1,ingest:!1}));pY=t}return pY}function ZLr(){return EUe().then(t=>t.ui)}function ejr(){EUe()}function tjr(t){console.warn(`[vgai-editor] ${t} mounted before this session's source-write route was confirmed, so its edits are live-only. Remount the surface (reopen the project) to author against the game’s own source.`)}function rjr(t){return cLe===null?(EUe(),tjr(t),null):cLe}function njr(t){return rjr(t)?.ui?$4t():void 0}async function ijr(){return await ZLr()?$4t():void 0}async function d2t(t,r){if(t.resources.length===0)throw new Error("An Object3D document persistence binding must own at least one resource.");const i=[];for(const a of t.resources)i.push({path:a.path,data:await a.serialize(r),contentType:a.contentType??"application/octet-stream"});return i}function sjr(t){return t.resources.map(r=>r.path).join(" + ")}async function ojr(t){const{binding:r,document:i,history:a}=t,d=await CUe(a,t.backend??M4t(),"asset-lab-document").openMutationSession(await d2t(r,i));return{commit:(_,g)=>X9r({resolve:()=>({reaches:"writer",anchorKind:"data-record",destination:sjr(r),write:async()=>{await d.assertUnchanged();const b=await d2t(r,_),S=g?.trim()||r.label?.trim()||"Edit Asset Lab Document";return d.mutate(b,{label:S})}}),record:()=>{}})}}async function ajr(t,r){const i=await wUe();if(i.status==="unreadable")throw new Error(`${Lq} is present but could not be read (${i.reason}). Refusing to overwrite it — fix or delete the file, then try again.`);const a=i.status==="ok"?i.manifest:{version:1,profile:XFe.version,generatedAt:new Date().toISOString(),entries:{}},l=t.replace(/^\/+/,""),d=a.entries[l]??{state:"fallback",profileVersion:XFe.version,issueCode:"thumbnail.pending-regeneration"},_={...a,profile:XFe.version,generatedAt:new Date().toISOString(),entries:{...a.entries,[l]:{...d,framing:r}}},g=`${JSON.stringify(_,null,2)}
|
|
71
71
|
`,b=fLr();(b?await CUe(b,M4t(),"project-resources").write(Lq,g,{label:`${r?"Save":"Reset"} thumbnail framing ${t}`,kind:"project-file",contentType:"application/json"}):await Qg.write(Lq,g).then(()=>!0))&&P4t()}const cjr={openPersistence:t=>ojr(t),replaceSource:async(t,r)=>{const i=njr("The Asset Editor");if(!i)throw new Error("This editor tier cannot write project source.");return GLr(i,t,r)},saveThumbnailFraming:ajr};function q4t(t){return t.map((r,i)=>({entry:r,index:i})).sort((r,i)=>r.entry.zOrder-i.entry.zOrder||r.index-i.index).map(({entry:r})=>r)}const Sw="workspace:game",z4t="workspace:scene",ljr="workspace:canvas-scene",ujr="workspace:3d-components",fjr="workspace:2d-components",djr="workspace:ui-components",pjr=new Set([ljr,fjr,ujr,djr]),_jr={hidden:!1,interactive:!1,pickLock:!1},U4t=new Map;function N0e(t){return U4t.get(t)??_jr}function TUe(t,r){U4t.set(t,{...N0e(t),...r})}function zP(t){return N0e(t).hidden}function mjr(t,r){TUe(t,{hidden:r})}function hjr(t){mjr(t,!zP(t))}function V4t(t){return N0e(t).interactive}function gjr(t,r){TUe(t,{interactive:r})}function yjr(t){gjr(t,!V4t(t))}function O0e(t){return N0e(t).pickLock}function vjr(t,r){TUe(t,{pickLock:r})}function bjr(t){vjr(t,!O0e(t))}function Khe(t,r,i,a){const l=t.pickable?.pick(r,i)??null;return l?t.selection?.resolve?.(l,{intent:a,scopeId:yUe()})?.id??l:null}function p2t(t,r,i,a){const l=t.pickable?.candidates?.(r,i)??[],d=[],_=new Set;for(const g of l){const b=t.selection?.resolve?.(g,{intent:a,scopeId:yUe()})?.id??g;_.has(b)||(_.add(b),d.push(b))}return d}function Ajr(t,r,i,a={}){const l=a.intent??"normal",d=By(t);if(!(d instanceof Zh))return Khe(d,r,i,l);const _=d.childAdapters(),b=I_()===z4t?[]:_.filter(N=>N.kind!=="three"),S=_.filter(N=>N.kind==="three"),k=b.map(N=>({id:N.worldId,zOrder:N.zOrder,worldId:N.worldId,adapter:N.adapter})),w=[...q4t(k).reverse(),...S];for(const{worldId:N,adapter:P}of w){if(zP(N)||O0e(N))continue;const j=Khe(P,r,i,l);if(j)return j}return null}function qDn(t,r,i,a={}){const l=a.intent??"normal",d=a.adapter??By(t);if(!(d instanceof Zh)){const j=p2t(d,r,i,l),J=Khe(d,r,i,l);return j.length>0?j:J?[J]:[]}const _=d.childAdapters(),b=I_()===z4t?[]:_.filter(j=>j.kind!=="three"),S=_.filter(j=>j.kind==="three"),k=b.map(j=>({id:j.worldId,zOrder:j.zOrder,worldId:j.worldId,adapter:j.adapter})),w=[...q4t(k).reverse(),...S],N=[],P=new Set;for(const{worldId:j,adapter:J}of w){if(zP(j)||O0e(j))continue;const X=p2t(J,r,i,l),G=Khe(J,r,i,l);for(const ee of X.length>0?X:G?[G]:[])P.has(ee)||(P.add(ee),N.push(ee))}return N}function Sjr(t){return t==="three"||t==="canvas"||t==="dom"?t:null}function xjr(t){if(!(t instanceof Zh))return null;const r=AE()?.descriptor;if(!r)return null;const i=t.childAdapters();if(r.kind==="world"){const a=r.provenance?.rootId,l=a?i.find(_=>_.worldId===a):void 0,d=l?Sjr(l.kind):null;return l&&d?{adapter:l.adapter,surface:d}:null}if(r.kind==="scene"){const a=i.find(l=>l.kind==="three"&&l.adapter.capabilities.transform);return a?{adapter:t.projectedDocumentAdapter(a.worldId)??a.adapter,surface:"three"}:null}return null}function wm(t){const r=n0e(),i=By(t),a=xjr(i),l=AE()?.descriptor.kind;return{adapter:r?.adapter??a?.adapter??i,surface:l==="story"?"dom":a?.surface??null,documentSelection:r}}function J4t(t,r){const i=[...r];return i.length===0||i.some(a=>t.hierarchy.node(a)===null)?null:t.rects?{worldId:null,kind:"dom"}:i.every(a=>t.hierarchy.object3D?.(a)!=null)?{worldId:null,kind:"three"}:null}const _2t=new WeakMap,kUe={activeAuthoring(t){let r=_2t.get(t);return r||(r=QPt(t,"No authoring adapter"),_2t.set(t,r)),r},panelAuthoring(t){return kUe.activeAuthoring(t)},pick(){return null},toolOwner:J4t,toolOwnerPainted(){return!0},threeSurfaceShowing(t,r){return!r.rects&&typeof r.hierarchy.object3D=="function"},threeViewportRootId(){return null},applyRootHiddenVisibility(){},suppressRootEnvironment(){}};let ome=kUe;function wjr(t){if(ome!==t){if(ome!==kUe)throw new Error("A viewport authoring policy is already installed.");ome=t}}function zDn(){return ome}const IUe={editorHelperType:"editorHelperType",skeletonVisible:"skeletonVisible",skeletonEnabled:"skeletonEnabled",engineInternal:"engineInternal",editorHelper:"editorHelper",vgaiComponentRoot:"vgaiComponentRoot",vgaiBuiltInternal:"vgaiBuiltInternal"};function Yhe(t,r){return t?t.userData[IUe[r]]:void 0}function UDn(t,r,i){t.userData[IUe[r]]=i}const DUe={...IUe,entityId:"entityId",forward:"forward",tags:"tags",attributes:"attributes",navRole:"navRole",pivot:"pivot",splineCurve:"splineCurve",splineControlPoint:"splineControlPoint",_camera:"_camera",_particleSystem:"_particleSystem",gaussianSplat:"gaussianSplat",_animMixer:"_animMixer",_animClips:"_animClips",_availableClips:"_availableClips",_animationRuntime:"_animationRuntime",__sharedGeometry:"__sharedGeometry",__shadeOrig:"__shadeOrig",__shadeUnlit:"__shadeUnlit",__ingest:"__ingest",__ingestNextId:"__ingestNextId",authoringRoot:"authoringRoot",authoringInstance:"authoringInstance",authoringLabel:"authoringLabel",authoringComponent:"authoringComponent",authoringDocument:"authoringDocument",authoringHierarchyId:"authoringHierarchyId",authoringHierarchyParentId:"authoringHierarchyParentId",authoringHierarchyOrder:"authoringHierarchyOrder",editorIcon:"editorIcon",envObject:"envObject",constraints:"constraints",authoringSubject:"authoringSubject",reflectionProbe:"reflectionProbe",triggerVolume:"triggerVolume",vcDirIdx:"vcDirIdx"};function CE(t,r){return t?t.userData[DUe[r]]:void 0}function CZ(t,r,i){t.userData[DUe[r]]=i}function Z8(t,r){return t?t.userData[DUe[r]]!==void 0:!1}function F0e(t){const r=By(t);return r instanceof Zh?r.childAdapters().find(a=>a.kind==="three"&&a.adapter.capabilities.transform)?.worldId??null:null}function Cjr(t,r){if(r!==null&&zP(r))for(const a of t.values())a.visible=!1}const Ejr=new vE("#aaaaaa");function Tjr(t){t.background=Ejr,t.fog=null,t.environment=null,t.traverse(r=>{CE(r,"envObject")&&(r.visible=!1)})}function lLe(t){const r=By(t);if(!(r instanceof Zh))return!0;if(!r.childAdapters().some(l=>l.kind==="three"))return!1;const a=F0e(t);return a===null?!0:!zP(a)}function kjr(t,r){const i=t.childAdapters();let a=null;for(const l of r){const d=i.find(_=>t.groupNodeId(_.worldId)===l)??i.find(_=>t.ownerOf(l)===_.worldId);if(!d||a&&a.worldId!==d.worldId)return null;a=d}return a?{worldId:a.worldId,kind:a.kind,adapter:a.adapter}:null}function W4t(t,r){const i=[...r];if(i.length===0)return null;if(t instanceof Zh)return kjr(t,i);const a=J4t(t,i);return a?{...a,adapter:t}:null}function H4t(t,r){return!r||r.worldId!==null&&zP(r.worldId)?!1:r.kind!=="three"||r.worldId===null?!0:F0e(t)===r.worldId}const Ijr={activeAuthoring:t=>By(t),panelAuthoring:t=>wm(t).adapter,pick:(t,r,i,a)=>Ajr(t,r,i,{intent:a}),toolOwner:(t,r)=>W4t(t,r),toolOwnerPainted:(t,r)=>lLe(t)&&H4t(t,r),threeSurfaceShowing:(t,r)=>lLe(t)&&(r instanceof Zh?r.childAdapters().some(i=>i.kind==="three"):!r.rects&&typeof r.hierarchy.object3D=="function"),threeViewportRootId:t=>F0e(t),applyRootHiddenVisibility:Cjr,suppressRootEnvironment:Tjr};class Djr extends Mye{constructor(){super();const r=new fkt;r.deleteAttribute("uv");const i=new tz({side:dkt}),a=new tz,l=new pkt(16777215,900,28,2);l.position.set(.418,16.199,.3),this.add(l);const d=new NA(r,i);d.position.set(-.757,13.219,.717),d.scale.set(31.713,28.305,28.591),this.add(d);const _=new Gqe(r,a,6),g=new Lye;g.position.set(-10.906,2.009,1.846),g.rotation.set(0,-.195,0),g.scale.set(2.328,7.905,4.651),g.updateMatrix(),_.setMatrixAt(0,g.matrix),g.position.set(-5.607,-.754,-.758),g.rotation.set(0,.994,0),g.scale.set(1.97,1.534,3.955),g.updateMatrix(),_.setMatrixAt(1,g.matrix),g.position.set(6.167,.857,7.803),g.rotation.set(0,.561,0),g.scale.set(3.927,6.285,3.687),g.updateMatrix(),_.setMatrixAt(2,g.matrix),g.position.set(-2.017,.018,6.124),g.rotation.set(0,.333,0),g.scale.set(2.002,4.566,2.064),g.updateMatrix(),_.setMatrixAt(3,g.matrix),g.position.set(2.291,-.756,-2.621),g.rotation.set(0,-.286,0),g.scale.set(1.546,1.552,1.496),g.updateMatrix(),_.setMatrixAt(4,g.matrix),g.position.set(-2.193,-.369,-5.547),g.rotation.set(0,.516,0),g.scale.set(3.875,3.487,2.986),g.updateMatrix(),_.setMatrixAt(5,g.matrix),this.add(_);const b=new NA(r,L$(50));b.position.set(-16.116,14.37,8.208),b.scale.set(.1,2.428,2.739),this.add(b);const S=new NA(r,L$(50));S.position.set(-16.109,18.021,-8.207),S.scale.set(.1,2.425,2.751),this.add(S);const k=new NA(r,L$(17));k.position.set(14.904,12.198,-1.832),k.scale.set(.15,4.265,6.331),this.add(k);const w=new NA(r,L$(43));w.position.set(-.462,8.89,14.52),w.scale.set(4.38,5.441,.088),this.add(w);const N=new NA(r,L$(20));N.position.set(3.235,11.486,-12.541),N.scale.set(2.5,2,.1),this.add(N);const P=new NA(r,L$(100));P.position.set(0,20,0),P.scale.set(1,.1,1),this.add(P)}dispose(){const r=new Set;this.traverse(i=>{i.isMesh&&(r.add(i.geometry),r.add(i.material))});for(const i of r)i.dispose()}}function L$(t){return new Lkr({color:0,emissive:16777215,emissiveIntensity:t})}function G4t(t){const r=new jkr(t),i=new Djr;try{const a=r.fromScene(i,.04);return{texture:a.texture,dispose:()=>a.dispose()}}finally{i.dispose(),r.dispose()}}const Pjr=new WeakSet,Njr=8;let GY=0;function UP(t){Pjr.add(t),GY+=1;const r=t,i=r.dispose;if(typeof i=="function"){let a=!0;r.dispose=function(...d){return a&&(a=!1,GY-=1),i.apply(this,d)}}return GY>=Njr&&console.warn(`[host-renderers] ${GY} editor WebGL renderers are live at once. The browser evicts the OLDEST context past its limit, which is the main viewport — a white viewport and "too many active WebGL contexts" is this. Creating stack:`,new Error("renderer created here").stack),t}function Ojr(){return GY}const Fjr=2,oR=[],Xhe=new Set;function Rjr(){const t=document.createElement("canvas");t.style.width="100%",t.style.height="100%",t.style.display="block";const r=UP(new $P({canvas:t,antialias:!0,alpha:!0})),i={canvas:t,renderer:r,environment:null,pooled:!1,leased:!0,lost:!1};return Xhe.add(i),t.addEventListener("webglcontextlost",()=>{i.lost=!0;const a=oR.indexOf(i);a>=0&&oR.splice(a,1),i.leased||Q4t(i)}),i}function Q4t(t){Xhe.delete(t)&&(t.environment?.dispose(),t.environment=null,t.renderer.dispose(),t.renderer.forceContextLoss(),t.canvas.remove())}function Mjr(){return{active:[...Xhe].filter(t=>t.leased&&!t.lost).length,idle:[...Xhe].filter(t=>!t.leased&&!t.lost).length}}function VDn(){let t=oR.find(a=>!a.leased&&!a.lost);t||(t=Rjr(),oR.length<Fjr&&(t.pooled=!0,oR.push(t))),t.leased=!0;const r=t;let i=!1;return{canvas:r.canvas,renderer:r.renderer,environment(){return r.environment??=G4t(r.renderer),{texture:r.environment.texture,dispose:()=>{}}},release(a){if(!i){if(i=!0,r.leased=!1,r.canvas.remove(),a?.discard){r.lost=!0;const l=oR.indexOf(r);l>=0&&oR.splice(l,1)}if(!r.pooled||r.lost){Q4t(r);return}r.renderer.setScissorTest(!1),r.renderer.autoClear=!0,r.renderer.clear()}}}}const Ljr=["front","side"],K4t=1,jjr=.55,m2t=K4t/2,i7e=128,Bjr=[24,26,31],$jr=[235,137,52],qjr=[56,189,248],zjr=[236,240,238];function Ujr(t,r){if(t.length<r*4)throw new Error(`Silhouette mask expected ${r*4} RGBA bytes but received ${t.length}.`);const i=new Uint8Array(r);for(let a=0;a<r;a++){const l=a*4,d=t[l]>=i7e||t[l+1]>=i7e||t[l+2]>=i7e;i[a]=d?1:0}return i}function Vjr(t,r){if(t.length!==r.length)throw new Error(`Mask IoU requires equal-size masks (${t.length} vs ${r.length}).`);let i=0,a=0,l=0;for(let _=0;_<t.length;_++){const g=t[_]!==0,b=r[_]!==0;g&&a++,b&&l++,g&&b&&i++}const d=a+l-i;return{intersection:i,union:d,aCount:a,bCount:l,iou:d===0?0:i/d}}function Jjr(t,r){if(t.length!==r.length)throw new Error(`Overlay requires equal-size masks (${t.length} vs ${r.length}).`);const i=new Uint8ClampedArray(t.length*4);for(let a=0;a<t.length;a++){const l=t[a]!==0,d=r[a]!==0,_=l&&d?zjr:l?$jr:d?qjr:Bjr,g=a*4;i[g]=_[0],i[g+1]=_[1],i[g+2]=_[2],i[g+3]=255}return i}function ame(t){if(!Array.isArray(t)||t.length!==3)return null;const[r,i,a]=t;return typeof r!="number"||typeof i!="number"||typeof a!="number"||!Number.isFinite(r)||!Number.isFinite(i)||!Number.isFinite(a)||Math.hypot(r,a)<1e-6?null:[r,i,a]}function PUe(t){const[r,,i]=t;if(!Number.isFinite(r)||!Number.isFinite(i)||Math.hypot(r,i)<1e-6)throw new Error(`Cannot derive a facing from forward vector [${t.join(", ")}].`);return Math.atan2(r,i)}function Wjr(t,r,i=K4t){const a=r[1]-t[1];if(!Number.isFinite(a)||a<=0)throw new Error(`Compare normalization needs positive model height, got ${a}.`);const l=i/a,d=(t[0]+r[0])/2,_=(t[2]+r[2])/2;return{scale:l,position:[-d*l,-t[1]*l,-_*l]}}const NUe=31,JDn=30;function OUe(t){return(t.layers.mask&1<<NUe)!==0||!!Yhe(t,"editorHelper")||!!Yhe(t,"engineInternal")}function WDn(t){let r=t;for(;r;){if(OUe(r))return!0;r=r.parent}return!1}function Hjr(t){const r=Yhe(t,"vgaiComponentRoot");return typeof r=="string"&&r?r:void 0}function R0e(t){return Yhe(t,"vgaiBuiltInternal")===!0}var Gjr=(function(){var t="b9H79Tebbbe8Fv9Gbb9Gvuuuuueu9Giuuub9Geueu9Giuuueuikqbeeedddillviebeoweuec:q:Odkr;leDo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbeY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVbdE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbiL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtblK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949Wbol79IV9Rbrq;w8Wqdbk;esezu8Jjjjjbcj;eb9Rgv8Kjjjjbc9:hodnadcefal0mbcuhoaiRbbc:Ge9hmbavaialfgrad9Radz1jjjbhwcj;abad9Uc;WFbGgocjdaocjd6EhDaicefhocbhqdnindndndnaeaq9nmbaDaeaq9RaqaDfae6Egkcsfglcl4cifcd4hxalc9WGgmTmecbhPawcjdfhsaohzinaraz9Rax6mvarazaxfgo9RcK6mvczhlcbhHinalgic9WfgOawcj;cbffhldndndndndnazaOco4fRbbaHcoG4ciGPlbedibkal9cb83ibalcwf9cb83ibxikalaoRblaoRbbgOco4gAaAciSgAE86bbawcj;cbfaifglcGfaoclfaAfgARbbaOcl4ciGgCaCciSgCE86bbalcVfaAaCfgARbbaOcd4ciGgCaCciSgCE86bbalc7faAaCfgARbbaOciGgOaOciSgOE86bbalctfaAaOfgARbbaoRbegOco4gCaCciSgCE86bbalc91faAaCfgARbbaOcl4ciGgCaCciSgCE86bbalc4faAaCfgARbbaOcd4ciGgCaCciSgCE86bbalc93faAaCfgARbbaOciGgOaOciSgOE86bbalc94faAaOfgARbbaoRbdgOco4gCaCciSgCE86bbalc95faAaCfgARbbaOcl4ciGgCaCciSgCE86bbalc96faAaCfgARbbaOcd4ciGgCaCciSgCE86bbalc97faAaCfgARbbaOciGgOaOciSgOE86bbalc98faAaOfgORbbaoRbigoco4gAaAciSgAE86bbalc99faOaAfgORbbaocl4ciGgAaAciSgAE86bbalc9:faOaAfgORbbaocd4ciGgAaAciSgAE86bbalcufaOaAfglRbbaociGgoaociSgoE86bbalaofhoxdkalaoRbwaoRbbgOcl4gAaAcsSgAE86bbawcj;cbfaifglcGfaocwfaAfgARbbaOcsGgOaOcsSgOE86bbalcVfaAaOfgORbbaoRbegAcl4gCaCcsSgCE86bbalc7faOaCfgORbbaAcsGgAaAcsSgAE86bbalctfaOaAfgORbbaoRbdgAcl4gCaCcsSgCE86bbalc91faOaCfgORbbaAcsGgAaAcsSgAE86bbalc4faOaAfgORbbaoRbigAcl4gCaCcsSgCE86bbalc93faOaCfgORbbaAcsGgAaAcsSgAE86bbalc94faOaAfgORbbaoRblgAcl4gCaCcsSgCE86bbalc95faOaCfgORbbaAcsGgAaAcsSgAE86bbalc96faOaAfgORbbaoRbvgAcl4gCaCcsSgCE86bbalc97faOaCfgORbbaAcsGgAaAcsSgAE86bbalc98faOaAfgORbbaoRbogAcl4gCaCcsSgCE86bbalc99faOaCfgORbbaAcsGgAaAcsSgAE86bbalc9:faOaAfgORbbaoRbrgocl4gAaAcsSgAE86bbalcufaOaAfglRbbaocsGgoaocsSgoE86bbalaofhoxekalao8Pbb83bbalcwfaocwf8Pbb83bbaoczfhokdnaiam9pmbaHcdfhHaiczfhlarao9RcL0mekkaiam6mvaoTmvdnakTmbawaPfRbbhHawcj;cbfhlashiakhOinaialRbbgzce4cbazceG9R7aHfgH86bbaiadfhialcefhlaOcufgOmbkkascefhsaohzaPcefgPad9hmbxikkcbc99arao9Radcaadca0ESEhoxlkaoaxad2fhCdnakmbadhlinaoTmlarao9Rax6mlaoaxfhoalcufglmbkaChoxekcbhmawcjdfhAinarao9Rax6miawamfRbbhHawcj;cbfhlaAhiakhOinaialRbbgzce4cbazceG9R7aHfgH86bbaiadfhialcefhlaOcufgOmbkaAcefhAaoaxfhoamcefgmad9hmbkaChokabaqad2fawcjdfakad2z1jjjb8Aawawcjdfakcufad2fadz1jjjb8Aakaqfhqaombkc9:hoxekc9:hokavcj;ebf8Kjjjjbaok;cseHu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnaeci9UgrcHfal0mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgwce0mbavc;abfcFecjez:jjjjb8AavcUf9cu83ibavc8Wf9cu83ibavcyf9cu83ibavcaf9cu83ibavcKf9cu83ibavczf9cu83ibav9cu83iwav9cu83ibaialfc9WfhDaicefgqarfhidnaeTmbcmcsawceSEhkcbhxcbhmcbhPcbhwcbhlindnaiaD9nmbc9:hoxikdndnaqRbbgoc;Ve0mbavc;abfalaocu7gscl4fcsGcitfgzydlhrazydbhzdnaocsGgHak9pmbavawasfcsGcdtfydbaxaHEhoaHThsdndnadcd9hmbabaPcetfgHaz87ebaHclfao87ebaHcdfar87ebxekabaPcdtfgHazBdbaHcwfaoBdbaHclfarBdbkaxasfhxcdhHavawcdtfaoBdbawasfhwcehsalhOxdkdndnaHcsSmbaHc987aHamffcefhoxekaicefhoai8SbbgHcFeGhsdndnaHcu9mmbaohixekaicvfhiascFbGhscrhHdninao8SbbgOcFbGaHtasVhsaOcu9kmeaocefhoaHcrfgHc8J9hmbxdkkaocefhikasce4cbasceG9R7amfhokdndnadcd9hmbabaPcetfgHaz87ebaHclfao87ebaHcdfar87ebxekabaPcdtfgHazBdbaHcwfaoBdbaHclfarBdbkcdhHavawcdtfaoBdbcehsawcefhwalhOaohmxekdnaocpe0mbaxcefgHavawaDaocsGfRbbgocl49RcsGcdtfydbaocz6gzEhravawao9RcsGcdtfydbaHazfgAaocsGgHEhoaHThCdndnadcd9hmbabaPcetfgHax87ebaHclfao87ebaHcdfar87ebxekabaPcdtfgHaxBdbaHcwfaoBdbaHclfarBdbkcdhsavawcdtfaxBdbavawcefgwcsGcdtfarBdbcihHavc;abfalcitfgOaxBdlaOarBdbavawazfgwcsGcdtfaoBdbalcefcsGhOawaCfhwaxhzaAaCfhxxekaxcbaiRbbgOEgzaoc;:eSgHfhraOcsGhCaOcl4hAdndnaOcs0mbarcefhoxekarhoavawaA9RcsGcdtfydbhrkdndnaCmbaocefhxxekaohxavawaO9RcsGcdtfydbhokdndnaHTmbaicefhHxekaicdfhHai8SbegscFeGhzdnascu9kmbaicofhXazcFbGhzcrhidninaH8SbbgscFbGaitazVhzascu9kmeaHcefhHaicrfgic8J9hmbkaXhHxekaHcefhHkazce4cbazceG9R7amfgmhzkdndnaAcsSmbaHhsxekaHcefhsaH8SbbgicFeGhrdnaicu9kmbaHcvfhXarcFbGhrcrhidninas8SbbgHcFbGaitarVhraHcu9kmeascefhsaicrfgic8J9hmbkaXhsxekascefhskarce4cbarceG9R7amfgmhrkdndnaCcsSmbashixekascefhias8SbbgocFeGhHdnaocu9kmbascvfhXaHcFbGhHcrhodninai8SbbgscFbGaotaHVhHascu9kmeaicefhiaocrfgoc8J9hmbkaXhixekaicefhikaHce4cbaHceG9R7amfgmhokdndnadcd9hmbabaPcetfgHaz87ebaHclfao87ebaHcdfar87ebxekabaPcdtfgHazBdbaHcwfaoBdbaHclfarBdbkcdhsavawcdtfazBdbavawcefgwcsGcdtfarBdbcihHavc;abfalcitfgXazBdlaXarBdbavawaOcz6aAcsSVfgwcsGcdtfaoBdbawaCTaCcsSVfhwalcefcsGhOkaqcefhqavc;abfaOcitfgOarBdlaOaoBdbavc;abfalasfcsGcitfgraoBdlarazBdbawcsGhwalaHfcsGhlaPcifgPae6mbkkcbc99aiaDSEhokavc;aef8Kjjjjbaok:flevu8Jjjjjbcz9Rhvc9:hodnaecvfal0mbcuhoaiRbbc;:eGc;qe9hmbav9cb83iwaicefhraialfc98fhwdnaeTmbdnadcdSmbcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcdtfaic8Etc8F91aicd47avcwfaiceGcdtVgoydbfglBdbaoalBdbaDcefgDae9hmbxdkkcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcetfaic8Etc8F91aicd47avcwfaiceGcdtVgoydbfgl87ebaoalBdbaDcefgDae9hmbkkcbc99arawSEhokaok:Lvoeue99dud99eud99dndnadcl9hmbaeTmeindndnabcdfgd8Sbb:Yab8Sbbgi:Ygl:l:tabcefgv8Sbbgo:Ygr:l:tgwJbb;:9cawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai86bbdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad86bbdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad86bbabclfhbaecufgembxdkkaeTmbindndnabclfgd8Ueb:Yab8Uebgi:Ygl:l:tabcdfgv8Uebgo:Ygr:l:tgwJb;:FSawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai87ebdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad87ebdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad87ebabcwfhbaecufgembkkk;oiliui99iue99dnaeTmbcbhiabhlindndnJ;Zl81Zalcof8UebgvciV:Y:vgoal8Ueb:YNgrJb;:FSNJbbbZJbbb:;arJbbbb9GEMgw:lJbbb9p9DTmbaw:OhDxekcjjjj94hDkalclf8Uebhqalcdf8UebhkabaiavcefciGfcetfaD87ebdndnaoak:YNgwJb;:FSNJbbbZJbbb:;awJbbbb9GEMgx:lJbbb9p9DTmbax:OhDxekcjjjj94hDkabaiavciGfgkcd7cetfaD87ebdndnaoaq:YNgoJb;:FSNJbbbZJbbb:;aoJbbbb9GEMgx:lJbbb9p9DTmbax:OhDxekcjjjj94hDkabaiavcufciGfcetfaD87ebdndnJbbjZararN:tawawN:taoaoN:tgrJbbbbarJbbbb9GE:rJb;:FSNJbbbZMgr:lJbbb9p9DTmbar:Ohvxekcjjjj94hvkabakcetfav87ebalcwfhlaiclfhiaecufgembkkk9mbdnadcd4ae2gdTmbinababydbgecwtcw91:Yaece91cjjj98Gcjjj;8if::NUdbabclfhbadcufgdmbkkk9teiucbcbydj1jjbgeabcifc98GfgbBdj1jjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaik;LeeeudndnaeabVciGTmbabhixekdndnadcz9pmbabhixekabhiinaiaeydbBdbaiclfaeclfydbBdbaicwfaecwfydbBdbaicxfaecxfydbBdbaeczfheaiczfhiadc9Wfgdcs0mbkkadcl6mbinaiaeydbBdbaeclfheaiclfhiadc98fgdci0mbkkdnadTmbinaiaeRbb86bbaicefhiaecefheadcufgdmbkkabk;aeedudndnabciGTmbabhixekaecFeGc:b:c:ew2hldndnadcz9pmbabhixekabhiinaialBdbaicxfalBdbaicwfalBdbaiclfalBdbaiczfhiadc9Wfgdcs0mbkkadcl6mbinaialBdbaiclfhiadc98fgdci0mbkkdnadTmbinaiae86bbaicefhiadcufgdmbkkabkkkebcjwklzNbb",r="b9H79TebbbeKl9Gbb9Gvuuuuueu9Giuuub9Geueuikqbbebeedddilve9Weeeviebeoweuec:q:6dkr;leDo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbdY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVblE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtboK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbrL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949Wbwl79IV9RbDq:p9sqlbzik9:evu8Jjjjjbcz9Rhbcbheincbhdcbhiinabcwfadfaicjuaead4ceGglE86bbaialfhiadcefgdcw9hmbkaec:q:yjjbfai86bbaecitc:q1jjbfab8Piw83ibaecefgecjd9hmbkk:N8JlHud97euo978Jjjjjbcj;kb9Rgv8Kjjjjbc9:hodnadcefal0mbcuhoaiRbbc:Ge9hmbavaialfgrad9Rad;8qbbcj;abad9UhlaicefhodnaeTmbadTmbalc;WFbGglcjdalcjd6EhwcbhDinawaeaD9RaDawfae6Egqcsfglc9WGgkci2hxakcethmalcl4cifcd4hPabaDad2fhsakc;ab6hzcbhHincbhOaohAdndninaraA9RaP6meavcj;cbfaOak2fhCaAaPfhocbhidnazmbarao9Rc;Gb6mbcbhlinaCalfhidndndndndnaAalco4fRbbgXciGPlbedibkaipxbbbbbbbbbbbbbbbbpklbxikaiaopbblaopbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbaoclfaYpQbfaKc:q:yjjbfRbbfhoxdkaiaopbbwaopbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbaocwfaYpQbfaKc:q:yjjbfRbbfhoxekaiaopbbbpklbaoczfhokdndndndndnaXcd4ciGPlbedibkaipxbbbbbbbbbbbbbbbbpklzxikaiaopbblaopbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklzaoclfaYpQbfaKc:q:yjjbfRbbfhoxdkaiaopbbwaopbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklzaocwfaYpQbfaKc:q:yjjbfRbbfhoxekaiaopbbbpklzaoczfhokdndndndndnaXcl4ciGPlbedibkaipxbbbbbbbbbbbbbbbbpklaxikaiaopbblaopbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklaaoclfaYpQbfaKc:q:yjjbfRbbfhoxdkaiaopbbwaopbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklaaocwfaYpQbfaKc:q:yjjbfRbbfhoxekaiaopbbbpklaaoczfhokdndndndndnaXco4Plbedibkaipxbbbbbbbbbbbbbbbbpkl8WxikaiaopbblaopbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibaXc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spkl8WaoclfaYpQbfaXc:q:yjjbfRbbfhoxdkaiaopbbwaopbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibaXc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spkl8WaocwfaYpQbfaXc:q:yjjbfRbbfhoxekaiaopbbbpkl8Waoczfhokalc;abfhialcjefak0meaihlarao9Rc;Fb0mbkkdnaiak9pmbaici4hlinarao9RcK6miaCaifhXdndndndndnaAaico4fRbbalcoG4ciGPlbedibkaXpxbbbbbbbbbbbbbbbbpkbbxikaXaopbblaopbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spkbbaoclfaYpQbfaKc:q:yjjbfRbbfhoxdkaXaopbbwaopbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spkbbaocwfaYpQbfaKc:q:yjjbfRbbfhoxekaXaopbbbpkbbaoczfhokalcdfhlaiczfgiak6mbkkaoTmeaohAaOcefgOclSmdxbkkc9:hoxlkdnakTmbavcjdfaHfhiavaHfpbdbhYcbhXinaiavcj;cbfaXfglpblbgLcep9TaLpxeeeeeeeeeeeeeeeegQp9op9Hp9rgLalakfpblbg8Acep9Ta8AaQp9op9Hp9rg8ApmbzeHdOiAlCvXoQrLgEalamfpblbg3cep9Ta3aQp9op9Hp9rg3alaxfpblbg5cep9Ta5aQp9op9Hp9rg5pmbzeHdOiAlCvXoQrLg8EpmbezHdiOAlvCXorQLgQaQpmbedibedibedibediaYp9UgYp9AdbbaiadfglaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaladfglaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaladfglaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaladfglaYaEa8EpmwDKYqk8AExm35Ps8E8FgQaQpmbedibedibedibedip9UgYp9AdbbaladfglaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaladfglaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaladfglaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaladfglaYaLa8ApmwKDYq8AkEx3m5P8Es8FgLa3a5pmwKDYq8AkEx3m5P8Es8Fg8ApmbezHdiOAlvCXorQLgQaQpmbedibedibedibedip9UgYp9AdbbaladfglaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaladfglaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaladfglaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaladfglaYaLa8ApmwDKYqk8AExm35Ps8E8FgQaQpmbedibedibedibedip9UgYp9AdbbaladfglaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaladfglaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaladfglaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaladfhiaXczfgXak6mbkkaHclfgHad6mbkasavcjdfaqad2;8qbbavavcjdfaqcufad2fad;8qbbaqaDfgDae6mbkkcbc99arao9Radcaadca0ESEhokavcj;kbf8Kjjjjbaokwbz:bjjjbk::seHu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnaeci9UgrcHfal0mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgwce0mbavc;abfcFecje;8kbavcUf9cu83ibavc8Wf9cu83ibavcyf9cu83ibavcaf9cu83ibavcKf9cu83ibavczf9cu83ibav9cu83iwav9cu83ibaialfc9WfhDaicefgqarfhidnaeTmbcmcsawceSEhkcbhxcbhmcbhPcbhwcbhlindnaiaD9nmbc9:hoxikdndnaqRbbgoc;Ve0mbavc;abfalaocu7gscl4fcsGcitfgzydlhrazydbhzdnaocsGgHak9pmbavawasfcsGcdtfydbaxaHEhoaHThsdndnadcd9hmbabaPcetfgHaz87ebaHclfao87ebaHcdfar87ebxekabaPcdtfgHazBdbaHcwfaoBdbaHclfarBdbkaxasfhxcdhHavawcdtfaoBdbawasfhwcehsalhOxdkdndnaHcsSmbaHc987aHamffcefhoxekaicefhoai8SbbgHcFeGhsdndnaHcu9mmbaohixekaicvfhiascFbGhscrhHdninao8SbbgOcFbGaHtasVhsaOcu9kmeaocefhoaHcrfgHc8J9hmbxdkkaocefhikasce4cbasceG9R7amfhokdndnadcd9hmbabaPcetfgHaz87ebaHclfao87ebaHcdfar87ebxekabaPcdtfgHazBdbaHcwfaoBdbaHclfarBdbkcdhHavawcdtfaoBdbcehsawcefhwalhOaohmxekdnaocpe0mbaxcefgHavawaDaocsGfRbbgocl49RcsGcdtfydbaocz6gzEhravawao9RcsGcdtfydbaHazfgAaocsGgHEhoaHThCdndnadcd9hmbabaPcetfgHax87ebaHclfao87ebaHcdfar87ebxekabaPcdtfgHaxBdbaHcwfaoBdbaHclfarBdbkcdhsavawcdtfaxBdbavawcefgwcsGcdtfarBdbcihHavc;abfalcitfgOaxBdlaOarBdbavawazfgwcsGcdtfaoBdbalcefcsGhOawaCfhwaxhzaAaCfhxxekaxcbaiRbbgOEgzaoc;:eSgHfhraOcsGhCaOcl4hAdndnaOcs0mbarcefhoxekarhoavawaA9RcsGcdtfydbhrkdndnaCmbaocefhxxekaohxavawaO9RcsGcdtfydbhokdndnaHTmbaicefhHxekaicdfhHai8SbegscFeGhzdnascu9kmbaicofhXazcFbGhzcrhidninaH8SbbgscFbGaitazVhzascu9kmeaHcefhHaicrfgic8J9hmbkaXhHxekaHcefhHkazce4cbazceG9R7amfgmhzkdndnaAcsSmbaHhsxekaHcefhsaH8SbbgicFeGhrdnaicu9kmbaHcvfhXarcFbGhrcrhidninas8SbbgHcFbGaitarVhraHcu9kmeascefhsaicrfgic8J9hmbkaXhsxekascefhskarce4cbarceG9R7amfgmhrkdndnaCcsSmbashixekascefhias8SbbgocFeGhHdnaocu9kmbascvfhXaHcFbGhHcrhodninai8SbbgscFbGaotaHVhHascu9kmeaicefhiaocrfgoc8J9hmbkaXhixekaicefhikaHce4cbaHceG9R7amfgmhokdndnadcd9hmbabaPcetfgHaz87ebaHclfao87ebaHcdfar87ebxekabaPcdtfgHazBdbaHcwfaoBdbaHclfarBdbkcdhsavawcdtfazBdbavawcefgwcsGcdtfarBdbcihHavc;abfalcitfgXazBdlaXarBdbavawaOcz6aAcsSVfgwcsGcdtfaoBdbawaCTaCcsSVfhwalcefcsGhOkaqcefhqavc;abfaOcitfgOarBdlaOaoBdbavc;abfalasfcsGcitfgraoBdlarazBdbawcsGhwalaHfcsGhlaPcifgPae6mbkkcbc99aiaDSEhokavc;aef8Kjjjjbaok:flevu8Jjjjjbcz9Rhvc9:hodnaecvfal0mbcuhoaiRbbc;:eGc;qe9hmbav9cb83iwaicefhraialfc98fhwdnaeTmbdnadcdSmbcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcdtfaic8Etc8F91aicd47avcwfaiceGcdtVgoydbfglBdbaoalBdbaDcefgDae9hmbxdkkcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcetfaic8Etc8F91aicd47avcwfaiceGcdtVgoydbfgl87ebaoalBdbaDcefgDae9hmbkkcbc99arawSEhokaok:wPliuo97eue978Jjjjjbca9Rhiaec98Ghldndnadcl9hmbdnalTmbcbhvabhdinadadpbbbgocKp:RecKp:Sep;6egraocwp:RecKp:Sep;6earp;Geaoczp:RecKp:Sep;6egwp;Gep;Kep;LegDpxbbbbbbbbbbbbbbbbp:2egqarpxbbbjbbbjbbbjbbbjgkp9op9rp;Kegrpxbb;:9cbb;:9cbb;:9cbb;:9cararp;MeaDaDp;Meawaqawakp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFbbbFbbbFbbbFbbbp9oaopxbbbFbbbFbbbFbbbFp9op9qarawp;Meaqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaDawp;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpkbbadczfhdavclfgval6mbkkalaeSmeaipxbbbbbbbbbbbbbbbbgqpklbaiabalcdtfgdaeciGglcdtgv;8qbbdnalTmbaiaipblbgocKp:RecKp:Sep;6egraocwp:RecKp:Sep;6earp;Geaoczp:RecKp:Sep;6egwp;Gep;Kep;LegDaqp:2egqarpxbbbjbbbjbbbjbbbjgkp9op9rp;Kegrpxbb;:9cbb;:9cbb;:9cbb;:9cararp;MeaDaDp;Meawaqawakp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFbbbFbbbFbbbFbbbp9oaopxbbbFbbbFbbbFbbbFp9op9qarawp;Meaqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaDawp;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpklbkadaiav;8qbbskdnalTmbcbhvabhdinadczfgxaxpbbbgopxbbbbbbFFbbbbbbFFgkp9oadpbbbgDaopmbediwDqkzHOAKY8AEgwczp:Reczp:Sep;6egraDaopmlvorxmPsCXQL358E8FpxFubbFubbFubbFubbp9op;6eawczp:Sep;6egwp;Gearp;Gep;Kep;Legopxbbbbbbbbbbbbbbbbp:2egqarpxbbbjbbbjbbbjbbbjgmp9op9rp;Kegrpxb;:FSb;:FSb;:FSb;:FSararp;Meaoaop;Meawaqawamp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFFbbFFbbFFbbFFbbp9oaoawp;Meaqp;Keczp:Rep9qgoarawp;Meaqp;KepxFFbbFFbbFFbbFFbbp9ogrpmwDKYqk8AExm35Ps8E8Fp9qpkbbadaDakp9oaoarpmbezHdiOAlvCXorQLp9qpkbbadcafhdavclfgval6mbkkalaeSmbaiaeciGgvcitgdfcbcaad9R;8kbaiabalcitfglad;8qbbdnavTmbaiaipblzgopxbbbbbbFFbbbbbbFFgkp9oaipblbgDaopmbediwDqkzHOAKY8AEgwczp:Reczp:Sep;6egraDaopmlvorxmPsCXQL358E8FpxFubbFubbFubbFubbp9op;6eawczp:Sep;6egwp;Gearp;Gep;Kep;Legopxbbbbbbbbbbbbbbbbp:2egqarpxbbbjbbbjbbbjbbbjgmp9op9rp;Kegrpxb;:FSb;:FSb;:FSb;:FSararp;Meaoaop;Meawaqawamp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFFbbFFbbFFbbFFbbp9oaoawp;Meaqp;Keczp:Rep9qgoarawp;Meaqp;KepxFFbbFFbbFFbbFFbbp9ogrpmwDKYqk8AExm35Ps8E8Fp9qpklzaiaDakp9oaoarpmbezHdiOAlvCXorQLp9qpklbkalaiad;8qbbkk;4wllue97euv978Jjjjjbc8W9Rhidnaec98GglTmbcbhvabhoinaiaopbbbgraoczfgwpbbbgDpmlvorxmPsCXQL358E8Fgqczp:Segkclp:RepklbaopxbbjZbbjZbbjZbbjZpx;Zl81Z;Zl81Z;Zl81Z;Zl81Zakpxibbbibbbibbbibbbp9qp;6ep;NegkaraDpmbediwDqkzHOAKY8AEgrczp:Reczp:Sep;6ep;MegDaDp;Meakarczp:Sep;6ep;Megxaxp;Meakaqczp:Reczp:Sep;6ep;Megqaqp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jepxb;:FSb;:FSb;:FSb;:FSgkp;Mepxbbn0bbn0bbn0bbn0grp;KepxFFbbFFbbFFbbFFbbgmp9oaxakp;Mearp;Keczp:Rep9qgxaDakp;Mearp;Keamp9oaqakp;Mearp;Keczp:Rep9qgkpmbezHdiOAlvCXorQLgrp5baipblbpEb:T:j83ibaocwfarp5eaipblbpEe:T:j83ibawaxakpmwDKYqk8AExm35Ps8E8Fgkp5baipblbpEd:T:j83ibaocKfakp5eaipblbpEi:T:j83ibaocafhoavclfgval6mbkkdnalaeSmbaiaeciGgvcitgofcbcaao9R;8kbaiabalcitfgwao;8qbbdnavTmbaiaipblbgraipblzgDpmlvorxmPsCXQL358E8Fgqczp:Segkclp:RepklaaipxbbjZbbjZbbjZbbjZpx;Zl81Z;Zl81Z;Zl81Z;Zl81Zakpxibbbibbbibbbibbbp9qp;6ep;NegkaraDpmbediwDqkzHOAKY8AEgrczp:Reczp:Sep;6ep;MegDaDp;Meakarczp:Sep;6ep;Megxaxp;Meakaqczp:Reczp:Sep;6ep;Megqaqp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jepxb;:FSb;:FSb;:FSb;:FSgkp;Mepxbbn0bbn0bbn0bbn0grp;KepxFFbbFFbbFFbbFFbbgmp9oaxakp;Mearp;Keczp:Rep9qgxaDakp;Mearp;Keamp9oaqakp;Mearp;Keczp:Rep9qgkpmbezHdiOAlvCXorQLgrp5baipblapEb:T:j83ibaiarp5eaipblapEe:T:j83iwaiaxakpmwDKYqk8AExm35Ps8E8Fgkp5baipblapEd:T:j83izaiakp5eaipblapEi:T:j83iKkawaiao;8qbbkk:Pddiue978Jjjjjbc;ab9Rhidnadcd4ae2glc98GgvTmbcbheabhdinadadpbbbgocwp:Recwp:Sep;6eaocep:SepxbbjFbbjFbbjFbbjFp9opxbbjZbbjZbbjZbbjZp:Uep;Mepkbbadczfhdaeclfgeav6mbkkdnavalSmbaialciGgecdtgdVcbc;abad9R;8kbaiabavcdtfgvad;8qbbdnaeTmbaiaipblbgocwp:Recwp:Sep;6eaocep:SepxbbjFbbjFbbjFbbjFp9opxbbjZbbjZbbjZbbjZp:Uep;Mepklbkavaiad;8qbbkk9teiucbcbydj1jjbgeabcifc98GfgbBdj1jjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaikkkebcjwklz:Dbb",i=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]),a=new Uint8Array([32,0,65,2,1,106,34,33,3,128,11,4,13,64,6,253,10,7,15,116,127,5,8,12,40,16,19,54,20,9,27,255,113,17,42,67,24,23,146,148,18,14,22,45,70,69,56,114,101,21,25,63,75,136,108,28,118,29,73,115]);if(typeof WebAssembly!="object")return{supported:!1};var l=WebAssembly.validate(i)?g(r):g(t),d,_=WebAssembly.instantiate(l,{}).then(function(G){d=G.instance,d.exports.__wasm_call_ctors()});function g(G){for(var ee=new Uint8Array(G.length),xe=0;xe<G.length;++xe){var ue=G.charCodeAt(xe);ee[xe]=ue>96?ue-97:ue>64?ue-39:ue+4}for(var fe=0,xe=0;xe<G.length;++xe)ee[fe++]=ee[xe]<60?a[ee[xe]]:(ee[xe]-60)*64+ee[++xe];return ee.buffer.slice(0,fe)}function b(G,ee,xe,ue,fe,se,de){var ge=G.exports.sbrk,qe=ue+3&-4,tt=ge(qe*fe),Ct=ge(se.length),Ot=new Uint8Array(G.exports.memory.buffer);Ot.set(se,Ct);var vt=ee(tt,ue,fe,Ct,se.length);if(vt==0&&de&&de(tt,qe,fe),xe.set(Ot.subarray(tt,tt+ue*fe)),ge(tt-ge(0)),vt!=0)throw new Error("Malformed buffer data: "+vt)}var S={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},k={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"},w=[],N=0;function P(G){var ee={object:new Worker(G),pending:0,requests:{}};return ee.object.onmessage=function(xe){var ue=xe.data;ee.pending-=ue.count,ee.requests[ue.id][ue.action](ue.value),delete ee.requests[ue.id]},ee}function j(G){for(var ee="self.ready = WebAssembly.instantiate(new Uint8Array(["+new Uint8Array(l)+"]), {}).then(function(result) { result.instance.exports.__wasm_call_ctors(); return result.instance; });self.onmessage = "+X.name+";"+b.toString()+X.toString(),xe=new Blob([ee],{type:"text/javascript"}),ue=URL.createObjectURL(xe),fe=w.length;fe<G;++fe)w[fe]=P(ue);for(var fe=G;fe<w.length;++fe)w[fe].object.postMessage({});w.length=G,URL.revokeObjectURL(ue)}function J(G,ee,xe,ue,fe){for(var se=w[0],de=1;de<w.length;++de)w[de].pending<se.pending&&(se=w[de]);return new Promise(function(ge,qe){var tt=new Uint8Array(xe),Ct=++N;se.pending+=G,se.requests[Ct]={resolve:ge,reject:qe},se.object.postMessage({id:Ct,count:G,size:ee,source:tt,mode:ue,filter:fe},[tt.buffer])})}function X(G){var ee=G.data;if(!ee.id)return self.close();self.ready.then(function(xe){try{var ue=new Uint8Array(ee.count*ee.size);b(xe,xe.exports[ee.mode],ue,ee.count,ee.size,ee.source,xe.exports[ee.filter]),self.postMessage({id:ee.id,count:ee.count,action:"resolve",value:ue},[ue.buffer])}catch(fe){self.postMessage({id:ee.id,count:ee.count,action:"reject",value:fe})}})}return{ready:_,supported:!0,useWorkers:function(G){j(G)},decodeVertexBuffer:function(G,ee,xe,ue,fe){b(d,d.exports.meshopt_decodeVertexBuffer,G,ee,xe,ue,d.exports[S[fe]])},decodeIndexBuffer:function(G,ee,xe,ue){b(d,d.exports.meshopt_decodeIndexBuffer,G,ee,xe,ue)},decodeIndexSequence:function(G,ee,xe,ue){b(d,d.exports.meshopt_decodeIndexSequence,G,ee,xe,ue)},decodeGltfBuffer:function(G,ee,xe,ue,fe,se){b(d,d.exports[k[fe]],G,ee,xe,ue,d.exports[S[se]])},decodeGltfBufferAsync:function(G,ee,xe,ue,fe){return w.length>0?J(G,ee,xe,k[ue],S[fe]):_.then(function(){var se=new Uint8Array(G*ee);return b(d,d.exports[k[ue]],se,G,ee,xe,d.exports[S[fe]]),se})}}})();const s7e=new WeakMap;class Qjr extends Qqe{constructor(r){super(r),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(r){return this.decoderPath=r,this}setDecoderConfig(r){return this.decoderConfig=r,this}setWorkerLimit(r){return this.workerLimit=r,this}load(r,i,a,l){const d=new TR(this.manager);d.setPath(this.path),d.setResponseType("arraybuffer"),d.setRequestHeader(this.requestHeader),d.setWithCredentials(this.withCredentials),d.load(r,_=>{this.parse(_,i,l)},a,l)}parse(r,i,a=()=>{}){this.decodeDracoFile(r,i,null,null,hv,a).catch(a)}decodeDracoFile(r,i,a,l,d=bE,_=()=>{}){const g={attributeIDs:a||this.defaultAttributeIDs,attributeTypes:l||this.defaultAttributeTypes,useUniqueIDs:!!a,vertexColorSpace:d};return this.decodeGeometry(r,g).then(i).catch(_)}decodeGeometry(r,i){const a=JSON.stringify(i);if(s7e.has(r)){const b=s7e.get(r);if(b.key===a)return b.promise;if(r.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let l;const d=this.workerNextTaskID++,_=r.byteLength,g=this._getWorker(d,_).then(b=>(l=b,new Promise((S,k)=>{l._callbacks[d]={resolve:S,reject:k},l.postMessage({type:"decode",id:d,taskConfig:i,buffer:r},[r])}))).then(b=>this._createGeometry(b.geometry));return g.catch(()=>!0).then(()=>{l&&d&&this._releaseTask(l,d)}),s7e.set(r,{key:a,promise:g}),g}_createGeometry(r){const i=new Kqe;r.index&&i.setIndex(new gX(r.index.array,1));for(let a=0;a<r.attributes.length;a++){const l=r.attributes[a],d=l.name,_=l.array,g=l.itemSize,b=new gX(_,g);d==="color"&&(this._assignVertexColorSpace(b,l.vertexColorSpace),b.normalized=!(_ instanceof Float32Array)),i.setAttribute(d,b)}return i}_assignVertexColorSpace(r,i){if(i!==hv)return;const a=new vE;for(let l=0,d=r.count;l<d;l++)a.fromBufferAttribute(r,l),oZ.colorSpaceToWorking(a,hv),r.setXYZ(l,a.r,a.g,a.b)}_loadLibrary(r,i){const a=new TR(this.manager);return a.setPath(this.decoderPath),a.setResponseType(i),a.setWithCredentials(this.withCredentials),new Promise((l,d)=>{a.load(r,l,void 0,d)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const r=typeof WebAssembly!="object"||this.decoderConfig.type==="js",i=[];return r?i.push(this._loadLibrary("draco_decoder.js","text")):(i.push(this._loadLibrary("draco_wasm_wrapper.js","text")),i.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(i).then(a=>{const l=a[0];r||(this.decoderConfig.wasmBinary=a[1]);const d=Kjr.toString(),_=["/* draco decoder */",l,"","/* worker */",d.substring(d.indexOf("{")+1,d.lastIndexOf("}"))].join(`
|
|
72
72
|
`);this.workerSourceURL=URL.createObjectURL(new Blob([_]))}),this.decoderPending}_getWorker(r,i){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){const l=new Worker(this.workerSourceURL);l._callbacks={},l._taskCosts={},l._taskLoad=0,l.postMessage({type:"init",decoderConfig:this.decoderConfig}),l.onmessage=function(d){const _=d.data;switch(_.type){case"decode":l._callbacks[_.id].resolve(_);break;case"error":l._callbacks[_.id].reject(_);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+_.type+'"')}},this.workerPool.push(l)}else this.workerPool.sort(function(l,d){return l._taskLoad>d._taskLoad?-1:1});const a=this.workerPool[this.workerPool.length-1];return a._taskCosts[r]=i,a._taskLoad+=i,a})}_releaseTask(r,i){r._taskLoad-=r._taskCosts[i],delete r._callbacks[i],delete r._taskCosts[i]}debug(){console.log("Task load: ",this.workerPool.map(r=>r._taskLoad))}dispose(){for(let r=0;r<this.workerPool.length;++r)this.workerPool[r].terminate();return this.workerPool.length=0,this.workerSourceURL!==""&&URL.revokeObjectURL(this.workerSourceURL),this}}function Kjr(){let t,r;onmessage=function(_){const g=_.data;switch(g.type){case"init":t=g.decoderConfig,r=new Promise(function(k){t.onModuleLoaded=function(w){k({draco:w})},DracoDecoderModule(t)});break;case"decode":const b=g.buffer,S=g.taskConfig;r.then(k=>{const w=k.draco,N=new w.Decoder;try{const P=i(w,N,new Int8Array(b),S),j=P.attributes.map(J=>J.array.buffer);P.index&&j.push(P.index.array.buffer),self.postMessage({type:"decode",id:g.id,geometry:P},j)}catch(P){console.error(P),self.postMessage({type:"error",id:g.id,error:P.message})}finally{w.destroy(N)}});break}};function i(_,g,b,S){const k=S.attributeIDs,w=S.attributeTypes;let N,P;const j=g.GetEncodedGeometryType(b);if(j===_.TRIANGULAR_MESH)N=new _.Mesh,P=g.DecodeArrayToMesh(b,b.byteLength,N);else if(j===_.POINT_CLOUD)N=new _.PointCloud,P=g.DecodeArrayToPointCloud(b,b.byteLength,N);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!P.ok()||N.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+P.error_msg());const J={index:null,attributes:[]};for(const X in k){const G=self[w[X]];let ee,xe;if(S.useUniqueIDs)xe=k[X],ee=g.GetAttributeByUniqueId(N,xe);else{if(xe=g.GetAttributeId(N,_[k[X]]),xe===-1)continue;ee=g.GetAttribute(N,xe)}const ue=l(_,g,N,X,G,ee);X==="color"&&(ue.vertexColorSpace=S.vertexColorSpace),J.attributes.push(ue)}return j===_.TRIANGULAR_MESH&&(J.index=a(_,g,N)),_.destroy(N),J}function a(_,g,b){const k=b.num_faces()*3,w=k*4,N=_._malloc(w);g.GetTrianglesUInt32Array(b,w,N);const P=new Uint32Array(_.HEAPF32.buffer,N,k).slice();return _._free(N),{array:P,itemSize:1}}function l(_,g,b,S,k,w){const N=w.num_components(),j=b.num_points()*N,J=j*k.BYTES_PER_ELEMENT,X=d(_,k),G=_._malloc(J);g.GetAttributeDataArrayForAllPoints(b,w,X,J,G);const ee=new k(_.HEAPF32.buffer,G,j).slice();return _._free(G),{name:S,array:ee,itemSize:N}}function d(_,g){switch(g){case Float32Array:return _.DT_FLOAT32;case Int8Array:return _.DT_INT8;case Int16Array:return _.DT_INT16;case Int32Array:return _.DT_INT32;case Uint8Array:return _.DT_UINT8;case Uint16Array:return _.DT_UINT16;case Uint32Array:return _.DT_UINT32}}}function h2t(t,r){if(r===Bkr)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),t;if(r===g9e||r===_kt){let i=t.getIndex();if(i===null){const _=[],g=t.getAttribute("position");if(g!==void 0){for(let b=0;b<g.count;b++)_.push(b);t.setIndex(_),i=t.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),t}const a=i.count-2,l=[];if(r===g9e)for(let _=1;_<=a;_++)l.push(i.getX(0)),l.push(i.getX(_)),l.push(i.getX(_+1));else for(let _=0;_<a;_++)_%2===0?(l.push(i.getX(_)),l.push(i.getX(_+1)),l.push(i.getX(_+2))):(l.push(i.getX(_+2)),l.push(i.getX(_+1)),l.push(i.getX(_)));l.length/3!==a&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const d=t.clone();return d.setIndex(l),d.clearGroups(),d}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",r),t}class Yjr extends Qqe{constructor(r){super(r),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(i){return new rBr(i)}),this.register(function(i){return new nBr(i)}),this.register(function(i){return new dBr(i)}),this.register(function(i){return new pBr(i)}),this.register(function(i){return new _Br(i)}),this.register(function(i){return new sBr(i)}),this.register(function(i){return new oBr(i)}),this.register(function(i){return new aBr(i)}),this.register(function(i){return new cBr(i)}),this.register(function(i){return new tBr(i)}),this.register(function(i){return new lBr(i)}),this.register(function(i){return new iBr(i)}),this.register(function(i){return new fBr(i)}),this.register(function(i){return new uBr(i)}),this.register(function(i){return new Zjr(i)}),this.register(function(i){return new mBr(i)}),this.register(function(i){return new hBr(i)})}load(r,i,a,l){const d=this;let _;if(this.resourcePath!=="")_=this.resourcePath;else if(this.path!==""){const S=yX.extractUrlBase(r);_=yX.resolveURL(S,this.path)}else _=yX.extractUrlBase(r);this.manager.itemStart(r);const g=function(S){l?l(S):console.error(S),d.manager.itemError(r),d.manager.itemEnd(r)},b=new TR(this.manager);b.setPath(this.path),b.setResponseType("arraybuffer"),b.setRequestHeader(this.requestHeader),b.setWithCredentials(this.withCredentials),b.load(r,function(S){try{d.parse(S,_,function(k){i(k),d.manager.itemEnd(r)},g)}catch(k){g(k)}},a,g)}setDRACOLoader(r){return this.dracoLoader=r,this}setKTX2Loader(r){return this.ktx2Loader=r,this}setMeshoptDecoder(r){return this.meshoptDecoder=r,this}register(r){return this.pluginCallbacks.indexOf(r)===-1&&this.pluginCallbacks.push(r),this}unregister(r){return this.pluginCallbacks.indexOf(r)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(r),1),this}parse(r,i,a,l){let d;const _={},g={},b=new TextDecoder;if(typeof r=="string")d=JSON.parse(r);else if(r instanceof ArrayBuffer)if(b.decode(new Uint8Array(r,0,4))===Y4t){try{_[wf.KHR_BINARY_GLTF]=new gBr(r)}catch(w){l&&l(w);return}d=JSON.parse(_[wf.KHR_BINARY_GLTF].content)}else d=JSON.parse(b.decode(r));else d=r;if(d.asset===void 0||d.asset.version[0]<2){l&&l(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const S=new DBr(d,{path:i||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});S.fileLoader.setRequestHeader(this.requestHeader);for(let k=0;k<this.pluginCallbacks.length;k++){const w=this.pluginCallbacks[k](S);w.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),g[w.name]=w,_[w.name]=!0}if(d.extensionsUsed)for(let k=0;k<d.extensionsUsed.length;++k){const w=d.extensionsUsed[k],N=d.extensionsRequired||[];switch(w){case wf.KHR_MATERIALS_UNLIT:_[w]=new eBr;break;case wf.KHR_DRACO_MESH_COMPRESSION:_[w]=new yBr(d,this.dracoLoader);break;case wf.KHR_TEXTURE_TRANSFORM:_[w]=new vBr;break;case wf.KHR_MESH_QUANTIZATION:_[w]=new bBr;break;default:N.indexOf(w)>=0&&g[w]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+w+'".')}}S.setExtensions(_),S.setPlugins(g),S.parse(a,l)}parseAsync(r,i){const a=this;return new Promise(function(l,d){a.parse(r,i,l,d)})}}function Xjr(){let t={};return{get:function(r){return t[r]},add:function(r,i){t[r]=i},remove:function(r){delete t[r]},removeAll:function(){t={}}}}const wf={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class Zjr{constructor(r){this.parser=r,this.name=wf.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const r=this.parser,i=this.parser.json.nodes||[];for(let a=0,l=i.length;a<l;a++){const d=i[a];d.extensions&&d.extensions[this.name]&&d.extensions[this.name].light!==void 0&&r._addNodeRef(this.cache,d.extensions[this.name].light)}}_loadLight(r){const i=this.parser,a="light:"+r;let l=i.cache.get(a);if(l)return l;const d=i.json,b=((d.extensions&&d.extensions[this.name]||{}).lights||[])[r];let S;const k=new vE(16777215);b.color!==void 0&&k.setRGB(b.color[0],b.color[1],b.color[2],bE);const w=b.range!==void 0?b.range:0;switch(b.type){case"directional":S=new kq(k),S.target.position.set(0,0,-1),S.add(S.target);break;case"point":S=new pkt(k),S.distance=w;break;case"spot":S=new $kr(k),S.distance=w,b.spot=b.spot||{},b.spot.innerConeAngle=b.spot.innerConeAngle!==void 0?b.spot.innerConeAngle:0,b.spot.outerConeAngle=b.spot.outerConeAngle!==void 0?b.spot.outerConeAngle:Math.PI/4,S.angle=b.spot.outerConeAngle,S.penumbra=1-b.spot.innerConeAngle/b.spot.outerConeAngle,S.target.position.set(0,0,-1),S.add(S.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+b.type)}return S.position.set(0,0,0),Hk(S,b),b.intensity!==void 0&&(S.intensity=b.intensity),S.name=i.createUniqueName(b.name||"light_"+r),l=Promise.resolve(S),i.cache.add(a,l),l}getDependency(r,i){if(r==="light")return this._loadLight(i)}createNodeAttachment(r){const i=this,a=this.parser,d=a.json.nodes[r],g=(d.extensions&&d.extensions[this.name]||{}).light;return g===void 0?null:this._loadLight(g).then(function(b){return a._getNodeRef(i.cache,g,b)})}}class eBr{constructor(){this.name=wf.KHR_MATERIALS_UNLIT}getMaterialType(){return fq}extendParams(r,i,a){const l=[];r.color=new vE(1,1,1),r.opacity=1;const d=i.pbrMetallicRoughness;if(d){if(Array.isArray(d.baseColorFactor)){const _=d.baseColorFactor;r.color.setRGB(_[0],_[1],_[2],bE),r.opacity=_[3]}d.baseColorTexture!==void 0&&l.push(a.assignTexture(r,"map",d.baseColorTexture,hv))}return Promise.all(l)}}class tBr{constructor(r){this.parser=r,this.name=wf.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(r,i){const l=this.parser.json.materials[r];if(!l.extensions||!l.extensions[this.name])return Promise.resolve();const d=l.extensions[this.name].emissiveStrength;return d!==void 0&&(i.emissiveIntensity=d),Promise.resolve()}}class rBr{constructor(r){this.parser=r,this.name=wf.KHR_MATERIALS_CLEARCOAT}getMaterialType(r){const a=this.parser.json.materials[r];return!a.extensions||!a.extensions[this.name]?null:yI}extendMaterialParams(r,i){const a=this.parser,l=a.json.materials[r];if(!l.extensions||!l.extensions[this.name])return Promise.resolve();const d=[],_=l.extensions[this.name];if(_.clearcoatFactor!==void 0&&(i.clearcoat=_.clearcoatFactor),_.clearcoatTexture!==void 0&&d.push(a.assignTexture(i,"clearcoatMap",_.clearcoatTexture)),_.clearcoatRoughnessFactor!==void 0&&(i.clearcoatRoughness=_.clearcoatRoughnessFactor),_.clearcoatRoughnessTexture!==void 0&&d.push(a.assignTexture(i,"clearcoatRoughnessMap",_.clearcoatRoughnessTexture)),_.clearcoatNormalTexture!==void 0&&(d.push(a.assignTexture(i,"clearcoatNormalMap",_.clearcoatNormalTexture)),_.clearcoatNormalTexture.scale!==void 0)){const g=_.clearcoatNormalTexture.scale;i.clearcoatNormalScale=new mkt(g,g)}return Promise.all(d)}}class nBr{constructor(r){this.parser=r,this.name=wf.KHR_MATERIALS_DISPERSION}getMaterialType(r){const a=this.parser.json.materials[r];return!a.extensions||!a.extensions[this.name]?null:yI}extendMaterialParams(r,i){const l=this.parser.json.materials[r];if(!l.extensions||!l.extensions[this.name])return Promise.resolve();const d=l.extensions[this.name];return i.dispersion=d.dispersion!==void 0?d.dispersion:0,Promise.resolve()}}class iBr{constructor(r){this.parser=r,this.name=wf.KHR_MATERIALS_IRIDESCENCE}getMaterialType(r){const a=this.parser.json.materials[r];return!a.extensions||!a.extensions[this.name]?null:yI}extendMaterialParams(r,i){const a=this.parser,l=a.json.materials[r];if(!l.extensions||!l.extensions[this.name])return Promise.resolve();const d=[],_=l.extensions[this.name];return _.iridescenceFactor!==void 0&&(i.iridescence=_.iridescenceFactor),_.iridescenceTexture!==void 0&&d.push(a.assignTexture(i,"iridescenceMap",_.iridescenceTexture)),_.iridescenceIor!==void 0&&(i.iridescenceIOR=_.iridescenceIor),i.iridescenceThicknessRange===void 0&&(i.iridescenceThicknessRange=[100,400]),_.iridescenceThicknessMinimum!==void 0&&(i.iridescenceThicknessRange[0]=_.iridescenceThicknessMinimum),_.iridescenceThicknessMaximum!==void 0&&(i.iridescenceThicknessRange[1]=_.iridescenceThicknessMaximum),_.iridescenceThicknessTexture!==void 0&&d.push(a.assignTexture(i,"iridescenceThicknessMap",_.iridescenceThicknessTexture)),Promise.all(d)}}class sBr{constructor(r){this.parser=r,this.name=wf.KHR_MATERIALS_SHEEN}getMaterialType(r){const a=this.parser.json.materials[r];return!a.extensions||!a.extensions[this.name]?null:yI}extendMaterialParams(r,i){const a=this.parser,l=a.json.materials[r];if(!l.extensions||!l.extensions[this.name])return Promise.resolve();const d=[];i.sheenColor=new vE(0,0,0),i.sheenRoughness=0,i.sheen=1;const _=l.extensions[this.name];if(_.sheenColorFactor!==void 0){const g=_.sheenColorFactor;i.sheenColor.setRGB(g[0],g[1],g[2],bE)}return _.sheenRoughnessFactor!==void 0&&(i.sheenRoughness=_.sheenRoughnessFactor),_.sheenColorTexture!==void 0&&d.push(a.assignTexture(i,"sheenColorMap",_.sheenColorTexture,hv)),_.sheenRoughnessTexture!==void 0&&d.push(a.assignTexture(i,"sheenRoughnessMap",_.sheenRoughnessTexture)),Promise.all(d)}}class oBr{constructor(r){this.parser=r,this.name=wf.KHR_MATERIALS_TRANSMISSION}getMaterialType(r){const a=this.parser.json.materials[r];return!a.extensions||!a.extensions[this.name]?null:yI}extendMaterialParams(r,i){const a=this.parser,l=a.json.materials[r];if(!l.extensions||!l.extensions[this.name])return Promise.resolve();const d=[],_=l.extensions[this.name];return _.transmissionFactor!==void 0&&(i.transmission=_.transmissionFactor),_.transmissionTexture!==void 0&&d.push(a.assignTexture(i,"transmissionMap",_.transmissionTexture)),Promise.all(d)}}class aBr{constructor(r){this.parser=r,this.name=wf.KHR_MATERIALS_VOLUME}getMaterialType(r){const a=this.parser.json.materials[r];return!a.extensions||!a.extensions[this.name]?null:yI}extendMaterialParams(r,i){const a=this.parser,l=a.json.materials[r];if(!l.extensions||!l.extensions[this.name])return Promise.resolve();const d=[],_=l.extensions[this.name];i.thickness=_.thicknessFactor!==void 0?_.thicknessFactor:0,_.thicknessTexture!==void 0&&d.push(a.assignTexture(i,"thicknessMap",_.thicknessTexture)),i.attenuationDistance=_.attenuationDistance||1/0;const g=_.attenuationColor||[1,1,1];return i.attenuationColor=new vE().setRGB(g[0],g[1],g[2],bE),Promise.all(d)}}class cBr{constructor(r){this.parser=r,this.name=wf.KHR_MATERIALS_IOR}getMaterialType(r){const a=this.parser.json.materials[r];return!a.extensions||!a.extensions[this.name]?null:yI}extendMaterialParams(r,i){const l=this.parser.json.materials[r];if(!l.extensions||!l.extensions[this.name])return Promise.resolve();const d=l.extensions[this.name];return i.ior=d.ior!==void 0?d.ior:1.5,Promise.resolve()}}class lBr{constructor(r){this.parser=r,this.name=wf.KHR_MATERIALS_SPECULAR}getMaterialType(r){const a=this.parser.json.materials[r];return!a.extensions||!a.extensions[this.name]?null:yI}extendMaterialParams(r,i){const a=this.parser,l=a.json.materials[r];if(!l.extensions||!l.extensions[this.name])return Promise.resolve();const d=[],_=l.extensions[this.name];i.specularIntensity=_.specularFactor!==void 0?_.specularFactor:1,_.specularTexture!==void 0&&d.push(a.assignTexture(i,"specularIntensityMap",_.specularTexture));const g=_.specularColorFactor||[1,1,1];return i.specularColor=new vE().setRGB(g[0],g[1],g[2],bE),_.specularColorTexture!==void 0&&d.push(a.assignTexture(i,"specularColorMap",_.specularColorTexture,hv)),Promise.all(d)}}class uBr{constructor(r){this.parser=r,this.name=wf.EXT_MATERIALS_BUMP}getMaterialType(r){const a=this.parser.json.materials[r];return!a.extensions||!a.extensions[this.name]?null:yI}extendMaterialParams(r,i){const a=this.parser,l=a.json.materials[r];if(!l.extensions||!l.extensions[this.name])return Promise.resolve();const d=[],_=l.extensions[this.name];return i.bumpScale=_.bumpFactor!==void 0?_.bumpFactor:1,_.bumpTexture!==void 0&&d.push(a.assignTexture(i,"bumpMap",_.bumpTexture)),Promise.all(d)}}class fBr{constructor(r){this.parser=r,this.name=wf.KHR_MATERIALS_ANISOTROPY}getMaterialType(r){const a=this.parser.json.materials[r];return!a.extensions||!a.extensions[this.name]?null:yI}extendMaterialParams(r,i){const a=this.parser,l=a.json.materials[r];if(!l.extensions||!l.extensions[this.name])return Promise.resolve();const d=[],_=l.extensions[this.name];return _.anisotropyStrength!==void 0&&(i.anisotropy=_.anisotropyStrength),_.anisotropyRotation!==void 0&&(i.anisotropyRotation=_.anisotropyRotation),_.anisotropyTexture!==void 0&&d.push(a.assignTexture(i,"anisotropyMap",_.anisotropyTexture)),Promise.all(d)}}class dBr{constructor(r){this.parser=r,this.name=wf.KHR_TEXTURE_BASISU}loadTexture(r){const i=this.parser,a=i.json,l=a.textures[r];if(!l.extensions||!l.extensions[this.name])return null;const d=l.extensions[this.name],_=i.options.ktx2Loader;if(!_){if(a.extensionsRequired&&a.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return i.loadTextureImage(r,d.source,_)}}class pBr{constructor(r){this.parser=r,this.name=wf.EXT_TEXTURE_WEBP}loadTexture(r){const i=this.name,a=this.parser,l=a.json,d=l.textures[r];if(!d.extensions||!d.extensions[i])return null;const _=d.extensions[i],g=l.images[_.source];let b=a.textureLoader;if(g.uri){const S=a.options.manager.getHandler(g.uri);S!==null&&(b=S)}return a.loadTextureImage(r,_.source,b)}}class _Br{constructor(r){this.parser=r,this.name=wf.EXT_TEXTURE_AVIF}loadTexture(r){const i=this.name,a=this.parser,l=a.json,d=l.textures[r];if(!d.extensions||!d.extensions[i])return null;const _=d.extensions[i],g=l.images[_.source];let b=a.textureLoader;if(g.uri){const S=a.options.manager.getHandler(g.uri);S!==null&&(b=S)}return a.loadTextureImage(r,_.source,b)}}class mBr{constructor(r){this.name=wf.EXT_MESHOPT_COMPRESSION,this.parser=r}loadBufferView(r){const i=this.parser.json,a=i.bufferViews[r];if(a.extensions&&a.extensions[this.name]){const l=a.extensions[this.name],d=this.parser.getDependency("buffer",l.buffer),_=this.parser.options.meshoptDecoder;if(!_||!_.supported){if(i.extensionsRequired&&i.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return d.then(function(g){const b=l.byteOffset||0,S=l.byteLength||0,k=l.count,w=l.byteStride,N=new Uint8Array(g,b,S);return _.decodeGltfBufferAsync?_.decodeGltfBufferAsync(k,w,N,l.mode,l.filter).then(function(P){return P.buffer}):_.ready.then(function(){const P=new ArrayBuffer(k*w);return _.decodeGltfBuffer(new Uint8Array(P),k,w,N,l.mode,l.filter),P})})}else return null}}class hBr{constructor(r){this.name=wf.EXT_MESH_GPU_INSTANCING,this.parser=r}createNodeMesh(r){const i=this.parser.json,a=i.nodes[r];if(!a.extensions||!a.extensions[this.name]||a.mesh===void 0)return null;const l=i.meshes[a.mesh];for(const S of l.primitives)if(S.mode!==fw.TRIANGLES&&S.mode!==fw.TRIANGLE_STRIP&&S.mode!==fw.TRIANGLE_FAN&&S.mode!==void 0)return null;const _=a.extensions[this.name].attributes,g=[],b={};for(const S in _)g.push(this.parser.getDependency("accessor",_[S]).then(k=>(b[S]=k,b[S])));return g.length<1?null:(g.push(this.parser.createNodeMesh(r)),Promise.all(g).then(S=>{const k=S.pop(),w=k.isGroup?k.children:[k],N=S[0].count,P=[];for(const j of w){const J=new SS,X=new Tc,G=new G8,ee=new Tc(1,1,1),xe=new Gqe(j.geometry,j.material,N);for(let ue=0;ue<N;ue++)b.TRANSLATION&&X.fromBufferAttribute(b.TRANSLATION,ue),b.ROTATION&&G.fromBufferAttribute(b.ROTATION,ue),b.SCALE&&ee.fromBufferAttribute(b.SCALE,ue),xe.setMatrixAt(ue,J.compose(X,G,ee));for(const ue in b)if(ue==="_COLOR_0"){const fe=b[ue];xe.instanceColor=new qkr(fe.array,fe.itemSize,fe.normalized)}else ue!=="TRANSLATION"&&ue!=="ROTATION"&&ue!=="SCALE"&&j.geometry.setAttribute(ue,b[ue]);Lye.prototype.copy.call(xe,j),this.parser.assignFinalMaterial(xe),P.push(xe)}return k.isGroup?(k.clear(),k.add(...P),k):P[0]}))}}const Y4t="glTF",_Y=12,g2t={JSON:1313821514,BIN:5130562};class gBr{constructor(r){this.name=wf.KHR_BINARY_GLTF,this.content=null,this.body=null;const i=new DataView(r,0,_Y),a=new TextDecoder;if(this.header={magic:a.decode(new Uint8Array(r.slice(0,4))),version:i.getUint32(4,!0),length:i.getUint32(8,!0)},this.header.magic!==Y4t)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const l=this.header.length-_Y,d=new DataView(r,_Y);let _=0;for(;_<l;){const g=d.getUint32(_,!0);_+=4;const b=d.getUint32(_,!0);if(_+=4,b===g2t.JSON){const S=new Uint8Array(r,_Y+_,g);this.content=a.decode(S)}else if(b===g2t.BIN){const S=_Y+_;this.body=r.slice(S,S+g)}_+=g}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class yBr{constructor(r,i){if(!i)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=wf.KHR_DRACO_MESH_COMPRESSION,this.json=r,this.dracoLoader=i,this.dracoLoader.preload()}decodePrimitive(r,i){const a=this.json,l=this.dracoLoader,d=r.extensions[this.name].bufferView,_=r.extensions[this.name].attributes,g={},b={},S={};for(const k in _){const w=uLe[k]||k.toLowerCase();g[w]=_[k]}for(const k in r.attributes){const w=uLe[k]||k.toLowerCase();if(_[k]!==void 0){const N=a.accessors[r.attributes[k]],P=jq[N.componentType];S[w]=P.name,b[w]=N.normalized===!0}}return i.getDependency("bufferView",d).then(function(k){return new Promise(function(w,N){l.decodeDracoFile(k,function(P){for(const j in P.attributes){const J=P.attributes[j],X=b[j];X!==void 0&&(J.normalized=X)}w(P)},g,S,bE,N)})})}}class vBr{constructor(){this.name=wf.KHR_TEXTURE_TRANSFORM}extendTexture(r,i){return(i.texCoord===void 0||i.texCoord===r.channel)&&i.offset===void 0&&i.rotation===void 0&&i.scale===void 0||(r=r.clone(),i.texCoord!==void 0&&(r.channel=i.texCoord),i.offset!==void 0&&r.offset.fromArray(i.offset),i.rotation!==void 0&&(r.rotation=i.rotation),i.scale!==void 0&&r.repeat.fromArray(i.scale),r.needsUpdate=!0),r}}class bBr{constructor(){this.name=wf.KHR_MESH_QUANTIZATION}}class X4t extends eIr{constructor(r,i,a,l){super(r,i,a,l)}copySampleValue_(r){const i=this.resultBuffer,a=this.sampleValues,l=this.valueSize,d=r*l*3+l;for(let _=0;_!==l;_++)i[_]=a[d+_];return i}interpolate_(r,i,a,l){const d=this.resultBuffer,_=this.sampleValues,g=this.valueSize,b=g*2,S=g*3,k=l-i,w=(a-i)/k,N=w*w,P=N*w,j=r*S,J=j-S,X=-2*P+3*N,G=P-N,ee=1-X,xe=G-N+w;for(let ue=0;ue!==g;ue++){const fe=_[J+ue+g],se=_[J+ue+b]*k,de=_[j+ue+g],ge=_[j+ue]*k;d[ue]=ee*fe+xe*se+X*de+G*ge}return d}}const ABr=new G8;class SBr extends X4t{interpolate_(r,i,a,l){const d=super.interpolate_(r,i,a,l);return ABr.fromArray(d).normalize().toArray(d),d}}const fw={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},jq={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},y2t={9728:ihe,9729:zR,9984:gkt,9985:Jkr,9986:Vkr,9987:jye},v2t={33071:Hkr,33648:Wkr,10497:y9e},o7e={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},uLe={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},PN={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},xBr={CUBICSPLINE:void 0,LINEAR:Ckt,STEP:Ykr},a7e={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function wBr(t){return t.DefaultMaterial===void 0&&(t.DefaultMaterial=new tz({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:Zkr})),t.DefaultMaterial}function U7(t,r,i){for(const a in i.extensions)t[a]===void 0&&(r.userData.gltfExtensions=r.userData.gltfExtensions||{},r.userData.gltfExtensions[a]=i.extensions[a])}function Hk(t,r){r.extras!==void 0&&(typeof r.extras=="object"?Object.assign(t.userData,r.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+r.extras))}function CBr(t,r,i){let a=!1,l=!1,d=!1;for(let S=0,k=r.length;S<k;S++){const w=r[S];if(w.POSITION!==void 0&&(a=!0),w.NORMAL!==void 0&&(l=!0),w.COLOR_0!==void 0&&(d=!0),a&&l&&d)break}if(!a&&!l&&!d)return Promise.resolve(t);const _=[],g=[],b=[];for(let S=0,k=r.length;S<k;S++){const w=r[S];if(a){const N=w.POSITION!==void 0?i.getDependency("accessor",w.POSITION):t.attributes.position;_.push(N)}if(l){const N=w.NORMAL!==void 0?i.getDependency("accessor",w.NORMAL):t.attributes.normal;g.push(N)}if(d){const N=w.COLOR_0!==void 0?i.getDependency("accessor",w.COLOR_0):t.attributes.color;b.push(N)}}return Promise.all([Promise.all(_),Promise.all(g),Promise.all(b)]).then(function(S){const k=S[0],w=S[1],N=S[2];return a&&(t.morphAttributes.position=k),l&&(t.morphAttributes.normal=w),d&&(t.morphAttributes.color=N),t.morphTargetsRelative=!0,t})}function EBr(t,r){if(t.updateMorphTargets(),r.weights!==void 0)for(let i=0,a=r.weights.length;i<a;i++)t.morphTargetInfluences[i]=r.weights[i];if(r.extras&&Array.isArray(r.extras.targetNames)){const i=r.extras.targetNames;if(t.morphTargetInfluences.length===i.length){t.morphTargetDictionary={};for(let a=0,l=i.length;a<l;a++)t.morphTargetDictionary[i[a]]=a}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function TBr(t){let r;const i=t.extensions&&t.extensions[wf.KHR_DRACO_MESH_COMPRESSION];if(i?r="draco:"+i.bufferView+":"+i.indices+":"+c7e(i.attributes):r=t.indices+":"+c7e(t.attributes)+":"+t.mode,t.targets!==void 0)for(let a=0,l=t.targets.length;a<l;a++)r+=":"+c7e(t.targets[a]);return r}function c7e(t){let r="";const i=Object.keys(t).sort();for(let a=0,l=i.length;a<l;a++)r+=i[a]+":"+t[i[a]]+";";return r}function fLe(t){switch(t){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function kBr(t){return t.search(/\.jpe?g($|\?)/i)>0||t.search(/^data\:image\/jpeg/)===0?"image/jpeg":t.search(/\.webp($|\?)/i)>0||t.search(/^data\:image\/webp/)===0?"image/webp":t.search(/\.ktx2($|\?)/i)>0||t.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const IBr=new SS;class DBr{constructor(r={},i={}){this.json=r,this.extensions={},this.plugins={},this.options=i,this.cache=new Xjr,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let a=!1,l=-1,d=!1,_=-1;if(typeof navigator<"u"){const g=navigator.userAgent;a=/^((?!chrome|android).)*safari/i.test(g)===!0;const b=g.match(/Version\/(\d+)/);l=a&&b?parseInt(b[1],10):-1,d=g.indexOf("Firefox")>-1,_=d?g.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||a&&l<17||d&&_<98?this.textureLoader=new hkt(this.options.manager):this.textureLoader=new zkr(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new TR(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(r){this.extensions=r}setPlugins(r){this.plugins=r}parse(r,i){const a=this,l=this.json,d=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(_){return _._markDefs&&_._markDefs()}),Promise.all(this._invokeAll(function(_){return _.beforeRoot&&_.beforeRoot()})).then(function(){return Promise.all([a.getDependencies("scene"),a.getDependencies("animation"),a.getDependencies("camera")])}).then(function(_){const g={scene:_[0][l.scene||0],scenes:_[0],animations:_[1],cameras:_[2],asset:l.asset,parser:a,userData:{}};return U7(d,g,l),Hk(g,l),Promise.all(a._invokeAll(function(b){return b.afterRoot&&b.afterRoot(g)})).then(function(){for(const b of g.scenes)b.updateMatrixWorld();r(g)})}).catch(i)}_markDefs(){const r=this.json.nodes||[],i=this.json.skins||[],a=this.json.meshes||[];for(let l=0,d=i.length;l<d;l++){const _=i[l].joints;for(let g=0,b=_.length;g<b;g++)r[_[g]].isBone=!0}for(let l=0,d=r.length;l<d;l++){const _=r[l];_.mesh!==void 0&&(this._addNodeRef(this.meshCache,_.mesh),_.skin!==void 0&&(a[_.mesh].isSkinnedMesh=!0)),_.camera!==void 0&&this._addNodeRef(this.cameraCache,_.camera)}}_addNodeRef(r,i){i!==void 0&&(r.refs[i]===void 0&&(r.refs[i]=r.uses[i]=0),r.refs[i]++)}_getNodeRef(r,i,a){if(r.refs[i]<=1)return a;const l=a.clone(),d=(_,g)=>{const b=this.associations.get(_);b!=null&&this.associations.set(g,b);for(const[S,k]of _.children.entries())d(k,g.children[S])};return d(a,l),l.name+="_instance_"+r.uses[i]++,l}_invokeOne(r){const i=Object.values(this.plugins);i.push(this);for(let a=0;a<i.length;a++){const l=r(i[a]);if(l)return l}return null}_invokeAll(r){const i=Object.values(this.plugins);i.unshift(this);const a=[];for(let l=0;l<i.length;l++){const d=r(i[l]);d&&a.push(d)}return a}getDependency(r,i){const a=r+":"+i;let l=this.cache.get(a);if(!l){switch(r){case"scene":l=this.loadScene(i);break;case"node":l=this._invokeOne(function(d){return d.loadNode&&d.loadNode(i)});break;case"mesh":l=this._invokeOne(function(d){return d.loadMesh&&d.loadMesh(i)});break;case"accessor":l=this.loadAccessor(i);break;case"bufferView":l=this._invokeOne(function(d){return d.loadBufferView&&d.loadBufferView(i)});break;case"buffer":l=this.loadBuffer(i);break;case"material":l=this._invokeOne(function(d){return d.loadMaterial&&d.loadMaterial(i)});break;case"texture":l=this._invokeOne(function(d){return d.loadTexture&&d.loadTexture(i)});break;case"skin":l=this.loadSkin(i);break;case"animation":l=this._invokeOne(function(d){return d.loadAnimation&&d.loadAnimation(i)});break;case"camera":l=this.loadCamera(i);break;default:if(l=this._invokeOne(function(d){return d!=this&&d.getDependency&&d.getDependency(r,i)}),!l)throw new Error("Unknown type: "+r);break}this.cache.add(a,l)}return l}getDependencies(r){let i=this.cache.get(r);if(!i){const a=this,l=this.json[r+(r==="mesh"?"es":"s")]||[];i=Promise.all(l.map(function(d,_){return a.getDependency(r,_)})),this.cache.add(r,i)}return i}loadBuffer(r){const i=this.json.buffers[r],a=this.fileLoader;if(i.type&&i.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+i.type+" buffer type is not supported.");if(i.uri===void 0&&r===0)return Promise.resolve(this.extensions[wf.KHR_BINARY_GLTF].body);const l=this.options;return new Promise(function(d,_){a.load(yX.resolveURL(i.uri,l.path),d,void 0,function(){_(new Error('THREE.GLTFLoader: Failed to load buffer "'+i.uri+'".'))})})}loadBufferView(r){const i=this.json.bufferViews[r];return this.getDependency("buffer",i.buffer).then(function(a){const l=i.byteLength||0,d=i.byteOffset||0;return a.slice(d,d+l)})}loadAccessor(r){const i=this,a=this.json,l=this.json.accessors[r];if(l.bufferView===void 0&&l.sparse===void 0){const _=o7e[l.type],g=jq[l.componentType],b=l.normalized===!0,S=new g(l.count*_);return Promise.resolve(new gX(S,_,b))}const d=[];return l.bufferView!==void 0?d.push(this.getDependency("bufferView",l.bufferView)):d.push(null),l.sparse!==void 0&&(d.push(this.getDependency("bufferView",l.sparse.indices.bufferView)),d.push(this.getDependency("bufferView",l.sparse.values.bufferView))),Promise.all(d).then(function(_){const g=_[0],b=o7e[l.type],S=jq[l.componentType],k=S.BYTES_PER_ELEMENT,w=k*b,N=l.byteOffset||0,P=l.bufferView!==void 0?a.bufferViews[l.bufferView].byteStride:void 0,j=l.normalized===!0;let J,X;if(P&&P!==w){const G=Math.floor(N/P),ee="InterleavedBuffer:"+l.bufferView+":"+l.componentType+":"+G+":"+l.count;let xe=i.cache.get(ee);xe||(J=new S(g,G*P,l.count*P/k),xe=new Ukr(J,P/k),i.cache.add(ee,xe)),X=new Xkr(xe,b,N%P/k,j)}else g===null?J=new S(l.count*b):J=new S(g,N,l.count*b),X=new gX(J,b,j);if(l.sparse!==void 0){const G=o7e.SCALAR,ee=jq[l.sparse.indices.componentType],xe=l.sparse.indices.byteOffset||0,ue=l.sparse.values.byteOffset||0,fe=new ee(_[1],xe,l.sparse.count*G),se=new S(_[2],ue,l.sparse.count*b);g!==null&&(X=new gX(X.array.slice(),X.itemSize,X.normalized)),X.normalized=!1;for(let de=0,ge=fe.length;de<ge;de++){const qe=fe[de];if(X.setX(qe,se[de*b]),b>=2&&X.setY(qe,se[de*b+1]),b>=3&&X.setZ(qe,se[de*b+2]),b>=4&&X.setW(qe,se[de*b+3]),b>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}X.normalized=j}return X})}loadTexture(r){const i=this.json,a=this.options,d=i.textures[r].source,_=i.images[d];let g=this.textureLoader;if(_.uri){const b=a.manager.getHandler(_.uri);b!==null&&(g=b)}return this.loadTextureImage(r,d,g)}loadTextureImage(r,i,a){const l=this,d=this.json,_=d.textures[r],g=d.images[i],b=(g.uri||g.bufferView)+":"+_.sampler;if(this.textureCache[b])return this.textureCache[b];const S=this.loadImageSource(i,a).then(function(k){k.flipY=!1,k.name=_.name||g.name||"",k.name===""&&typeof g.uri=="string"&&g.uri.startsWith("data:image/")===!1&&(k.name=g.uri);const N=(d.samplers||{})[_.sampler]||{};return k.magFilter=y2t[N.magFilter]||zR,k.minFilter=y2t[N.minFilter]||jye,k.wrapS=v2t[N.wrapS]||y9e,k.wrapT=v2t[N.wrapT]||y9e,k.generateMipmaps=!k.isCompressedTexture&&k.minFilter!==ihe&&k.minFilter!==zR,l.associations.set(k,{textures:r}),k}).catch(function(){return null});return this.textureCache[b]=S,S}loadImageSource(r,i){const a=this,l=this.json,d=this.options;if(this.sourceCache[r]!==void 0)return this.sourceCache[r].then(w=>w.clone());const _=l.images[r],g=self.URL||self.webkitURL;let b=_.uri||"",S=!1;if(_.bufferView!==void 0)b=a.getDependency("bufferView",_.bufferView).then(function(w){S=!0;const N=new Blob([w],{type:_.mimeType});return b=g.createObjectURL(N),b});else if(_.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+r+" is missing URI and bufferView");const k=Promise.resolve(b).then(function(w){return new Promise(function(N,P){let j=N;i.isImageBitmapLoader===!0&&(j=function(J){const X=new oP(J);X.needsUpdate=!0,N(X)}),i.load(yX.resolveURL(w,d.path),j,void 0,P)})}).then(function(w){return S===!0&&g.revokeObjectURL(b),Hk(w,_),w.userData.mimeType=_.mimeType||kBr(_.uri),w}).catch(function(w){throw console.error("THREE.GLTFLoader: Couldn't load texture",b),w});return this.sourceCache[r]=k,k}assignTexture(r,i,a,l){const d=this;return this.getDependency("texture",a.index).then(function(_){if(!_)return null;if(a.texCoord!==void 0&&a.texCoord>0&&(_=_.clone(),_.channel=a.texCoord),d.extensions[wf.KHR_TEXTURE_TRANSFORM]){const g=a.extensions!==void 0?a.extensions[wf.KHR_TEXTURE_TRANSFORM]:void 0;if(g){const b=d.associations.get(_);_=d.extensions[wf.KHR_TEXTURE_TRANSFORM].extendTexture(_,g),d.associations.set(_,b)}}return l!==void 0&&(_.colorSpace=l),r[i]=_,_})}assignFinalMaterial(r){const i=r.geometry;let a=r.material;const l=i.attributes.tangent===void 0,d=i.attributes.color!==void 0,_=i.attributes.normal===void 0;if(r.isPoints){const g="PointsMaterial:"+a.uuid;let b=this.cache.get(g);b||(b=new ykt,vFe.prototype.copy.call(b,a),b.color.copy(a.color),b.map=a.map,b.sizeAttenuation=!1,this.cache.add(g,b)),a=b}else if(r.isLine){const g="LineBasicMaterial:"+a.uuid;let b=this.cache.get(g);b||(b=new Gkr,vFe.prototype.copy.call(b,a),b.color.copy(a.color),b.map=a.map,this.cache.add(g,b)),a=b}if(l||d||_){let g="ClonedMaterial:"+a.uuid+":";l&&(g+="derivative-tangents:"),d&&(g+="vertex-colors:"),_&&(g+="flat-shading:");let b=this.cache.get(g);b||(b=a.clone(),d&&(b.vertexColors=!0),_&&(b.flatShading=!0),l&&(b.normalScale&&(b.normalScale.y*=-1),b.clearcoatNormalScale&&(b.clearcoatNormalScale.y*=-1)),this.cache.add(g,b),this.associations.set(b,this.associations.get(a))),a=b}r.material=a}getMaterialType(){return tz}loadMaterial(r){const i=this,a=this.json,l=this.extensions,d=a.materials[r];let _;const g={},b=d.extensions||{},S=[];if(b[wf.KHR_MATERIALS_UNLIT]){const w=l[wf.KHR_MATERIALS_UNLIT];_=w.getMaterialType(),S.push(w.extendParams(g,d,i))}else{const w=d.pbrMetallicRoughness||{};if(g.color=new vE(1,1,1),g.opacity=1,Array.isArray(w.baseColorFactor)){const N=w.baseColorFactor;g.color.setRGB(N[0],N[1],N[2],bE),g.opacity=N[3]}w.baseColorTexture!==void 0&&S.push(i.assignTexture(g,"map",w.baseColorTexture,hv)),g.metalness=w.metallicFactor!==void 0?w.metallicFactor:1,g.roughness=w.roughnessFactor!==void 0?w.roughnessFactor:1,w.metallicRoughnessTexture!==void 0&&(S.push(i.assignTexture(g,"metalnessMap",w.metallicRoughnessTexture)),S.push(i.assignTexture(g,"roughnessMap",w.metallicRoughnessTexture))),_=this._invokeOne(function(N){return N.getMaterialType&&N.getMaterialType(r)}),S.push(Promise.all(this._invokeAll(function(N){return N.extendMaterialParams&&N.extendMaterialParams(r,g)})))}d.doubleSided===!0&&(g.side=vkt);const k=d.alphaMode||a7e.OPAQUE;if(k===a7e.BLEND?(g.transparent=!0,g.depthWrite=!1):(g.transparent=!1,k===a7e.MASK&&(g.alphaTest=d.alphaCutoff!==void 0?d.alphaCutoff:.5)),d.normalTexture!==void 0&&_!==fq&&(S.push(i.assignTexture(g,"normalMap",d.normalTexture)),g.normalScale=new mkt(1,1),d.normalTexture.scale!==void 0)){const w=d.normalTexture.scale;g.normalScale.set(w,w)}if(d.occlusionTexture!==void 0&&_!==fq&&(S.push(i.assignTexture(g,"aoMap",d.occlusionTexture)),d.occlusionTexture.strength!==void 0&&(g.aoMapIntensity=d.occlusionTexture.strength)),d.emissiveFactor!==void 0&&_!==fq){const w=d.emissiveFactor;g.emissive=new vE().setRGB(w[0],w[1],w[2],bE)}return d.emissiveTexture!==void 0&&_!==fq&&S.push(i.assignTexture(g,"emissiveMap",d.emissiveTexture,hv)),Promise.all(S).then(function(){const w=new _(g);return d.name&&(w.name=d.name),Hk(w,d),i.associations.set(w,{materials:r}),d.extensions&&U7(l,w,d),w})}createUniqueName(r){const i=she.sanitizeNodeName(r||"");return i in this.nodeNamesUsed?i+"_"+ ++this.nodeNamesUsed[i]:(this.nodeNamesUsed[i]=0,i)}loadGeometries(r){const i=this,a=this.extensions,l=this.primitiveCache;function d(g){return a[wf.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(g,i).then(function(b){return b2t(b,g,i)})}const _=[];for(let g=0,b=r.length;g<b;g++){const S=r[g],k=TBr(S),w=l[k];if(w)_.push(w.promise);else{let N;S.extensions&&S.extensions[wf.KHR_DRACO_MESH_COMPRESSION]?N=d(S):N=b2t(new Kqe,S,i),l[k]={primitive:S,promise:N},_.push(N)}}return Promise.all(_)}loadMesh(r){const i=this,a=this.json,l=this.extensions,d=a.meshes[r],_=d.primitives,g=[];for(let b=0,S=_.length;b<S;b++){const k=_[b].material===void 0?wBr(this.cache):this.getDependency("material",_[b].material);g.push(k)}return g.push(i.loadGeometries(_)),Promise.all(g).then(function(b){const S=b.slice(0,b.length-1),k=b[b.length-1],w=[];for(let P=0,j=k.length;P<j;P++){const J=k[P],X=_[P];let G;const ee=S[P];if(X.mode===fw.TRIANGLES||X.mode===fw.TRIANGLE_STRIP||X.mode===fw.TRIANGLE_FAN||X.mode===void 0)G=d.isSkinnedMesh===!0?new bkt(J,ee):new NA(J,ee),G.isSkinnedMesh===!0&&G.normalizeSkinWeights(),X.mode===fw.TRIANGLE_STRIP?G.geometry=h2t(G.geometry,_kt):X.mode===fw.TRIANGLE_FAN&&(G.geometry=h2t(G.geometry,g9e));else if(X.mode===fw.LINES)G=new Akt(J,ee);else if(X.mode===fw.LINE_STRIP)G=new Skt(J,ee);else if(X.mode===fw.LINE_LOOP)G=new xkt(J,ee);else if(X.mode===fw.POINTS)G=new Yqe(J,ee);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+X.mode);Object.keys(G.geometry.morphAttributes).length>0&&EBr(G,d),G.name=i.createUniqueName(d.name||"mesh_"+r),Hk(G,d),X.extensions&&U7(l,G,X),i.assignFinalMaterial(G),w.push(G)}for(let P=0,j=w.length;P<j;P++)i.associations.set(w[P],{meshes:r,primitives:P});if(w.length===1)return d.extensions&&U7(l,w[0],d),w[0];const N=new SP;d.extensions&&U7(l,N,d),i.associations.set(N,{meshes:r});for(let P=0,j=w.length;P<j;P++)N.add(w[P]);return N})}loadCamera(r){let i;const a=this.json.cameras[r],l=a[a.type];if(!l){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return a.type==="perspective"?i=new Bye(bb.radToDeg(l.yfov),l.aspectRatio||1,l.znear||1,l.zfar||2e6):a.type==="orthographic"&&(i=new $ye(-l.xmag,l.xmag,l.ymag,-l.ymag,l.znear,l.zfar)),a.name&&(i.name=this.createUniqueName(a.name)),Hk(i,a),Promise.resolve(i)}loadSkin(r){const i=this.json.skins[r],a=[];for(let l=0,d=i.joints.length;l<d;l++)a.push(this._loadNodeShallow(i.joints[l]));return i.inverseBindMatrices!==void 0?a.push(this.getDependency("accessor",i.inverseBindMatrices)):a.push(null),Promise.all(a).then(function(l){const d=l.pop(),_=l,g=[],b=[];for(let S=0,k=_.length;S<k;S++){const w=_[S];if(w){g.push(w);const N=new SS;d!==null&&N.fromArray(d.array,S*16),b.push(N)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',i.joints[S])}return new Qkr(g,b)})}loadAnimation(r){const i=this.json,a=this,l=i.animations[r],d=l.name?l.name:"animation_"+r,_=[],g=[],b=[],S=[],k=[];for(let w=0,N=l.channels.length;w<N;w++){const P=l.channels[w],j=l.samplers[P.sampler],J=P.target,X=J.node,G=l.parameters!==void 0?l.parameters[j.input]:j.input,ee=l.parameters!==void 0?l.parameters[j.output]:j.output;J.node!==void 0&&(_.push(this.getDependency("node",X)),g.push(this.getDependency("accessor",G)),b.push(this.getDependency("accessor",ee)),S.push(j),k.push(J))}return Promise.all([Promise.all(_),Promise.all(g),Promise.all(b),Promise.all(S),Promise.all(k)]).then(function(w){const N=w[0],P=w[1],j=w[2],J=w[3],X=w[4],G=[];for(let xe=0,ue=N.length;xe<ue;xe++){const fe=N[xe],se=P[xe],de=j[xe],ge=J[xe],qe=X[xe];if(fe===void 0)continue;fe.updateMatrix&&fe.updateMatrix();const tt=a._createAnimationTracks(fe,se,de,ge,qe);if(tt)for(let Ct=0;Ct<tt.length;Ct++)G.push(tt[Ct])}const ee=new Kkr(d,void 0,G);return Hk(ee,l),ee})}createNodeMesh(r){const i=this.json,a=this,l=i.nodes[r];return l.mesh===void 0?null:a.getDependency("mesh",l.mesh).then(function(d){const _=a._getNodeRef(a.meshCache,l.mesh,d);return l.weights!==void 0&&_.traverse(function(g){if(g.isMesh)for(let b=0,S=l.weights.length;b<S;b++)g.morphTargetInfluences[b]=l.weights[b]}),_})}loadNode(r){const i=this.json,a=this,l=i.nodes[r],d=a._loadNodeShallow(r),_=[],g=l.children||[];for(let S=0,k=g.length;S<k;S++)_.push(a.getDependency("node",g[S]));const b=l.skin===void 0?Promise.resolve(null):a.getDependency("skin",l.skin);return Promise.all([d,Promise.all(_),b]).then(function(S){const k=S[0],w=S[1],N=S[2];N!==null&&k.traverse(function(P){P.isSkinnedMesh&&P.bind(N,IBr)});for(let P=0,j=w.length;P<j;P++)k.add(w[P]);return k})}_loadNodeShallow(r){const i=this.json,a=this.extensions,l=this;if(this.nodeCache[r]!==void 0)return this.nodeCache[r];const d=i.nodes[r],_=d.name?l.createUniqueName(d.name):"",g=[],b=l._invokeOne(function(S){return S.createNodeMesh&&S.createNodeMesh(r)});return b&&g.push(b),d.camera!==void 0&&g.push(l.getDependency("camera",d.camera).then(function(S){return l._getNodeRef(l.cameraCache,d.camera,S)})),l._invokeAll(function(S){return S.createNodeAttachment&&S.createNodeAttachment(r)}).forEach(function(S){g.push(S)}),this.nodeCache[r]=Promise.all(g).then(function(S){let k;if(d.isBone===!0?k=new wkt:S.length>1?k=new SP:S.length===1?k=S[0]:k=new Lye,k!==S[0])for(let w=0,N=S.length;w<N;w++)k.add(S[w]);if(d.name&&(k.userData.name=d.name,k.name=_),Hk(k,d),d.extensions&&U7(a,k,d),d.matrix!==void 0){const w=new SS;w.fromArray(d.matrix),k.applyMatrix4(w)}else d.translation!==void 0&&k.position.fromArray(d.translation),d.rotation!==void 0&&k.quaternion.fromArray(d.rotation),d.scale!==void 0&&k.scale.fromArray(d.scale);if(!l.associations.has(k))l.associations.set(k,{});else if(d.mesh!==void 0&&l.meshCache.refs[d.mesh]>1){const w=l.associations.get(k);l.associations.set(k,{...w})}return l.associations.get(k).nodes=r,k}),this.nodeCache[r]}loadScene(r){const i=this.extensions,a=this.json.scenes[r],l=this,d=new SP;a.name&&(d.name=l.createUniqueName(a.name)),Hk(d,a),a.extensions&&U7(i,d,a);const _=a.nodes||[],g=[];for(let b=0,S=_.length;b<S;b++)g.push(l.getDependency("node",_[b]));return Promise.all(g).then(function(b){for(let k=0,w=b.length;k<w;k++)d.add(b[k]);const S=k=>{const w=new Map;for(const[N,P]of l.associations)(N instanceof vFe||N instanceof oP)&&w.set(N,P);return k.traverse(N=>{const P=l.associations.get(N);P!=null&&w.set(N,P)}),w};return l.associations=S(d),d})}_createAnimationTracks(r,i,a,l,d){const _=[],g=r.name?r.name:r.uuid,b=[];PN[d.path]===PN.weights?r.traverse(function(N){N.morphTargetInfluences&&b.push(N.name?N.name:N.uuid)}):b.push(g);let S;switch(PN[d.path]){case PN.weights:S=L1t;break;case PN.rotation:S=j1t;break;case PN.translation:case PN.scale:S=M1t;break;default:switch(a.itemSize){case 1:S=L1t;break;case 2:case 3:default:S=M1t;break}break}const k=l.interpolation!==void 0?xBr[l.interpolation]:Ckt,w=this._getArrayFromAccessor(a);for(let N=0,P=b.length;N<P;N++){const j=new S(b[N]+"."+PN[d.path],i.array,w,k);l.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(j),_.push(j)}return _}_getArrayFromAccessor(r){let i=r.array;if(r.normalized){const a=fLe(i.constructor),l=new Float32Array(i.length);for(let d=0,_=i.length;d<_;d++)l[d]=i[d]*a;i=l}return i}_createCubicSplineTrackInterpolant(r){r.createInterpolant=function(a){const l=this instanceof j1t?SBr:X4t;return new l(this.times,this.values,this.getValueSize()/3,a)},r.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function PBr(t,r,i){const a=r.attributes,l=new xS;if(a.POSITION!==void 0){const g=i.json.accessors[a.POSITION],b=g.min,S=g.max;if(b!==void 0&&S!==void 0){if(l.set(new Tc(b[0],b[1],b[2]),new Tc(S[0],S[1],S[2])),g.normalized){const k=fLe(jq[g.componentType]);l.min.multiplyScalar(k),l.max.multiplyScalar(k)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const d=r.targets;if(d!==void 0){const g=new Tc,b=new Tc;for(let S=0,k=d.length;S<k;S++){const w=d[S];if(w.POSITION!==void 0){const N=i.json.accessors[w.POSITION],P=N.min,j=N.max;if(P!==void 0&&j!==void 0){if(b.setX(Math.max(Math.abs(P[0]),Math.abs(j[0]))),b.setY(Math.max(Math.abs(P[1]),Math.abs(j[1]))),b.setZ(Math.max(Math.abs(P[2]),Math.abs(j[2]))),N.normalized){const J=fLe(jq[N.componentType]);b.multiplyScalar(J)}g.max(b)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}l.expandByVector(g)}t.boundingBox=l;const _=new Ekt;l.getCenter(_.center),_.radius=l.min.distanceTo(l.max)/2,t.boundingSphere=_}function b2t(t,r,i){const a=r.attributes,l=[];function d(_,g){return i.getDependency("accessor",_).then(function(b){t.setAttribute(g,b)})}for(const _ in a){const g=uLe[_]||_.toLowerCase();g in t.attributes||l.push(d(a[_],g))}if(r.indices!==void 0&&!t.index){const _=i.getDependency("accessor",r.indices).then(function(g){t.setIndex(g)});l.push(_)}return oZ.workingColorSpace!==bE&&"COLOR_0"in a&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${oZ.workingColorSpace}" not supported.`),Hk(t,r),PBr(t,r,i),Promise.all(l).then(function(){return r.targets!==void 0?CBr(t,r.targets,i):t})}class NBr{constructor(r=4){this.pool=r,this.queue=[],this.workers=[],this.workersResolve=[],this.workerStatus=0,this.workerCreator=null}_initWorker(r){if(!this.workers[r]){const i=this.workerCreator();i.addEventListener("message",this._onMessage.bind(this,r)),this.workers[r]=i}}_getIdleWorker(){for(let r=0;r<this.pool;r++)if(!(this.workerStatus&1<<r))return r;return-1}_onMessage(r,i){const a=this.workersResolve[r];if(a&&a(i),this.queue.length){const{resolve:l,msg:d,transfer:_}=this.queue.shift();this.workersResolve[r]=l,this.workers[r].postMessage(d,_)}else this.workerStatus^=1<<r}setWorkerCreator(r){this.workerCreator=r}setWorkerLimit(r){this.pool=r}postMessage(r,i){return new Promise(a=>{const l=this._getIdleWorker();l!==-1?(this._initWorker(l),this.workerStatus|=1<<l,this.workersResolve[l]=a,this.workers[l].postMessage(r,i)):this.queue.push({resolve:a,msg:r,transfer:i})})}dispose(){this.workers.forEach(r=>r.terminate()),this.workersResolve.length=0,this.workers.length=0,this.queue.length=0,this.workerStatus=0}}const OBr=0,A2t=2,FBr=1,S2t=2,RBr=0,MBr=1,LBr=10,jBr=0,Z4t=9,e6t=15,t6t=16,r6t=22,n6t=37,i6t=43,s6t=76,o6t=83,a6t=97,c6t=100,l6t=103,u6t=109,f6t=122,d6t=123,p6t=131,_6t=132,m6t=133,h6t=134,g6t=137,y6t=138,v6t=139,b6t=140,A6t=141,S6t=142,x6t=145,w6t=146,C6t=148,E6t=152,T6t=157,k6t=158,I6t=165,D6t=166,P6t=1000054e3,N6t=1000054001,O6t=1000054004,F6t=1000054005,FUe=1000066e3,R6t=1000066004;class mY{constructor(r,i,a,l){this._dataView=void 0,this._littleEndian=void 0,this._offset=void 0,this._dataView=new DataView(r.buffer,r.byteOffset+i,a),this._littleEndian=l,this._offset=0}_nextUint8(){const r=this._dataView.getUint8(this._offset);return this._offset+=1,r}_nextUint16(){const r=this._dataView.getUint16(this._offset,this._littleEndian);return this._offset+=2,r}_nextUint32(){const r=this._dataView.getUint32(this._offset,this._littleEndian);return this._offset+=4,r}_nextUint64(){const r=this._dataView.getUint32(this._offset,this._littleEndian)+4294967296*this._dataView.getUint32(this._offset+4,this._littleEndian);return this._offset+=8,r}_nextInt32(){const r=this._dataView.getInt32(this._offset,this._littleEndian);return this._offset+=4,r}_nextUint8Array(r){const i=new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+this._offset,r);return this._offset+=r,i}_skip(r){return this._offset+=r,this}_scan(r,i=0){const a=this._offset;let l=0;for(;this._dataView.getUint8(this._offset)!==i&&l<r;)l++,this._offset++;return l<r&&this._offset++,new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+a,l)}}const _b=[171,75,84,88,32,50,48,187,13,10,26,10];function x2t(t){return new TextDecoder().decode(t)}function BBr(t){const r=new Uint8Array(t.buffer,t.byteOffset,_b.length);if(r[0]!==_b[0]||r[1]!==_b[1]||r[2]!==_b[2]||r[3]!==_b[3]||r[4]!==_b[4]||r[5]!==_b[5]||r[6]!==_b[6]||r[7]!==_b[7]||r[8]!==_b[8]||r[9]!==_b[9]||r[10]!==_b[10]||r[11]!==_b[11])throw new Error("Missing KTX 2.0 identifier.");const i={vkFormat:0,typeSize:1,pixelWidth:0,pixelHeight:0,pixelDepth:0,layerCount:0,faceCount:1,levelCount:0,supercompressionScheme:0,levels:[],dataFormatDescriptor:[{vendorId:0,descriptorType:0,versionNumber:2,colorModel:0,colorPrimaries:1,transferFunction:2,flags:0,texelBlockDimension:[0,0,0,0],bytesPlane:[0,0,0,0,0,0,0,0],samples:[]}],keyValue:{},globalData:null},a=17*Uint32Array.BYTES_PER_ELEMENT,l=new mY(t,_b.length,a,!0);i.vkFormat=l._nextUint32(),i.typeSize=l._nextUint32(),i.pixelWidth=l._nextUint32(),i.pixelHeight=l._nextUint32(),i.pixelDepth=l._nextUint32(),i.layerCount=l._nextUint32(),i.faceCount=l._nextUint32(),i.levelCount=l._nextUint32(),i.supercompressionScheme=l._nextUint32();const d=l._nextUint32(),_=l._nextUint32(),g=l._nextUint32(),b=l._nextUint32(),S=l._nextUint64(),k=l._nextUint64(),w=3*Math.max(i.levelCount,1)*8,N=new mY(t,_b.length+a,w,!0);for(let on=0,gr=Math.max(i.levelCount,1);on<gr;on++)i.levels.push({levelData:new Uint8Array(t.buffer,t.byteOffset+N._nextUint64(),N._nextUint64()),uncompressedByteLength:N._nextUint64()});const P=new mY(t,d,_,!0);P._skip(4);const j=P._nextUint16(),J=P._nextUint16(),X=P._nextUint16(),G=P._nextUint16(),ee={vendorId:j,descriptorType:J,versionNumber:X,colorModel:P._nextUint8(),colorPrimaries:P._nextUint8(),transferFunction:P._nextUint8(),flags:P._nextUint8(),texelBlockDimension:[P._nextUint8(),P._nextUint8(),P._nextUint8(),P._nextUint8()],bytesPlane:[P._nextUint8(),P._nextUint8(),P._nextUint8(),P._nextUint8(),P._nextUint8(),P._nextUint8(),P._nextUint8(),P._nextUint8()],samples:[]},xe=(G/4-6)/4;for(let on=0;on<xe;on++){const gr={bitOffset:P._nextUint16(),bitLength:P._nextUint8(),channelType:P._nextUint8(),samplePosition:[P._nextUint8(),P._nextUint8(),P._nextUint8(),P._nextUint8()],sampleLower:Number.NEGATIVE_INFINITY,sampleUpper:Number.POSITIVE_INFINITY};64&gr.channelType?(gr.sampleLower=P._nextInt32(),gr.sampleUpper=P._nextInt32()):(gr.sampleLower=P._nextUint32(),gr.sampleUpper=P._nextUint32()),ee.samples[on]=gr}i.dataFormatDescriptor.length=0,i.dataFormatDescriptor.push(ee);const ue=new mY(t,g,b,!0);for(;ue._offset<b;){const on=ue._nextUint32(),gr=ue._scan(on),An=x2t(gr);if(i.keyValue[An]=ue._nextUint8Array(on-gr.byteLength-1),An.match(/^ktx/i)){const Rn=x2t(i.keyValue[An]);i.keyValue[An]=Rn.substring(0,Rn.lastIndexOf("\0"))}ue._skip(on%4?4-on%4:0)}if(k<=0)return i;const fe=new mY(t,S,k,!0),se=fe._nextUint16(),de=fe._nextUint16(),ge=fe._nextUint32(),qe=fe._nextUint32(),tt=fe._nextUint32(),Ct=fe._nextUint32(),Ot=[];for(let on=0,gr=Math.max(i.levelCount,1);on<gr;on++)Ot.push({imageFlags:fe._nextUint32(),rgbSliceByteOffset:fe._nextUint32(),rgbSliceByteLength:fe._nextUint32(),alphaSliceByteOffset:fe._nextUint32(),alphaSliceByteLength:fe._nextUint32()});const vt=S+fe._offset,Et=vt+ge,Tt=Et+qe,Le=Tt+tt,cr=new Uint8Array(t.buffer,t.byteOffset+vt,ge),Yt=new Uint8Array(t.buffer,t.byteOffset+Et,qe),Lr=new Uint8Array(t.buffer,t.byteOffset+Tt,tt),nn=new Uint8Array(t.buffer,t.byteOffset+Le,Ct);return i.globalData={endpointCount:se,selectorCount:de,imageDescs:Ot,endpointsData:cr,selectorsData:Yt,tablesData:Lr,extendedData:nn},i}let l7e,Y3,dLe;const u7e={env:{emscripten_notify_memory_growth:function(t){dLe=new Uint8Array(Y3.exports.memory.buffer)}}};let $Br=class{init(){return l7e||(l7e=typeof fetch<"u"?fetch("data:application/wasm;base64,"+w2t).then(r=>r.arrayBuffer()).then(r=>WebAssembly.instantiate(r,u7e)).then(this._init):WebAssembly.instantiate(Buffer.from(w2t,"base64"),u7e).then(this._init),l7e)}_init(r){Y3=r.instance,u7e.env.emscripten_notify_memory_growth(0)}decode(r,i=0){if(!Y3)throw new Error("ZSTDDecoder: Await .init() before decoding.");const a=r.byteLength,l=Y3.exports.malloc(a);dLe.set(r,l),i=i||Number(Y3.exports.ZSTD_findDecompressedSize(l,a));const d=Y3.exports.malloc(i),_=Y3.exports.ZSTD_decompress(d,i,l,a),g=dLe.slice(d,d+_);return Y3.exports.free(l),Y3.exports.free(d),g}};const w2t="AGFzbQEAAAABpQEVYAF/AX9gAn9/AGADf39/AX9gBX9/f39/AX9gAX8AYAJ/fwF/YAR/f39/AX9gA39/fwBgBn9/f39/fwF/YAd/f39/f39/AX9gAn9/AX5gAn5+AX5gAABgBX9/f39/AGAGf39/f39/AGAIf39/f39/f38AYAl/f39/f39/f38AYAABf2AIf39/f39/f38Bf2ANf39/f39/f39/f39/fwF/YAF/AX4CJwEDZW52H2Vtc2NyaXB0ZW5fbm90aWZ5X21lbW9yeV9ncm93dGgABANpaAEFAAAFAgEFCwACAQABAgIFBQcAAwABDgsBAQcAEhMHAAUBDAQEAAANBwQCAgYCBAgDAwMDBgEACQkHBgICAAYGAgQUBwYGAwIGAAMCAQgBBwUGCgoEEQAEBAEIAwgDBQgDEA8IAAcABAUBcAECAgUEAQCAAgYJAX8BQaCgwAILB2AHBm1lbW9yeQIABm1hbGxvYwAoBGZyZWUAJgxaU1REX2lzRXJyb3IAaBlaU1REX2ZpbmREZWNvbXByZXNzZWRTaXplAFQPWlNURF9kZWNvbXByZXNzAEoGX3N0YXJ0ACQJBwEAQQELASQKussBaA8AIAAgACgCBCABajYCBAsZACAAKAIAIAAoAgRBH3F0QQAgAWtBH3F2CwgAIABBiH9LC34BBH9BAyEBIAAoAgQiA0EgTQRAIAAoAggiASAAKAIQTwRAIAAQDQ8LIAAoAgwiAiABRgRAQQFBAiADQSBJGw8LIAAgASABIAJrIANBA3YiBCABIARrIAJJIgEbIgJrIgQ2AgggACADIAJBA3RrNgIEIAAgBCgAADYCAAsgAQsUAQF/IAAgARACIQIgACABEAEgAgv3AQECfyACRQRAIABCADcCACAAQQA2AhAgAEIANwIIQbh/DwsgACABNgIMIAAgAUEEajYCECACQQRPBEAgACABIAJqIgFBfGoiAzYCCCAAIAMoAAA2AgAgAUF/ai0AACIBBEAgAEEIIAEQFGs2AgQgAg8LIABBADYCBEF/DwsgACABNgIIIAAgAS0AACIDNgIAIAJBfmoiBEEBTQRAIARBAWtFBEAgACABLQACQRB0IANyIgM2AgALIAAgAS0AAUEIdCADajYCAAsgASACakF/ai0AACIBRQRAIABBADYCBEFsDwsgAEEoIAEQFCACQQN0ams2AgQgAgsWACAAIAEpAAA3AAAgACABKQAINwAICy8BAX8gAUECdEGgHWooAgAgACgCAEEgIAEgACgCBGprQR9xdnEhAiAAIAEQASACCyEAIAFCz9bTvtLHq9lCfiAAfEIfiUKHla+vmLbem55/fgsdAQF/IAAoAgggACgCDEYEfyAAKAIEQSBGBUEACwuCBAEDfyACQYDAAE8EQCAAIAEgAhBnIAAPCyAAIAJqIQMCQCAAIAFzQQNxRQRAAkAgAkEBSARAIAAhAgwBCyAAQQNxRQRAIAAhAgwBCyAAIQIDQCACIAEtAAA6AAAgAUEBaiEBIAJBAWoiAiADTw0BIAJBA3ENAAsLAkAgA0F8cSIEQcAASQ0AIAIgBEFAaiIFSw0AA0AgAiABKAIANgIAIAIgASgCBDYCBCACIAEoAgg2AgggAiABKAIMNgIMIAIgASgCEDYCECACIAEoAhQ2AhQgAiABKAIYNgIYIAIgASgCHDYCHCACIAEoAiA2AiAgAiABKAIkNgIkIAIgASgCKDYCKCACIAEoAiw2AiwgAiABKAIwNgIwIAIgASgCNDYCNCACIAEoAjg2AjggAiABKAI8NgI8IAFBQGshASACQUBrIgIgBU0NAAsLIAIgBE8NAQNAIAIgASgCADYCACABQQRqIQEgAkEEaiICIARJDQALDAELIANBBEkEQCAAIQIMAQsgA0F8aiIEIABJBEAgACECDAELIAAhAgNAIAIgAS0AADoAACACIAEtAAE6AAEgAiABLQACOgACIAIgAS0AAzoAAyABQQRqIQEgAkEEaiICIARNDQALCyACIANJBEADQCACIAEtAAA6AAAgAUEBaiEBIAJBAWoiAiADRw0ACwsgAAsMACAAIAEpAAA3AAALQQECfyAAKAIIIgEgACgCEEkEQEEDDwsgACAAKAIEIgJBB3E2AgQgACABIAJBA3ZrIgE2AgggACABKAAANgIAQQALDAAgACABKAIANgAAC/cCAQJ/AkAgACABRg0AAkAgASACaiAASwRAIAAgAmoiBCABSw0BCyAAIAEgAhALDwsgACABc0EDcSEDAkACQCAAIAFJBEAgAwRAIAAhAwwDCyAAQQNxRQRAIAAhAwwCCyAAIQMDQCACRQ0EIAMgAS0AADoAACABQQFqIQEgAkF/aiECIANBAWoiA0EDcQ0ACwwBCwJAIAMNACAEQQNxBEADQCACRQ0FIAAgAkF/aiICaiIDIAEgAmotAAA6AAAgA0EDcQ0ACwsgAkEDTQ0AA0AgACACQXxqIgJqIAEgAmooAgA2AgAgAkEDSw0ACwsgAkUNAgNAIAAgAkF/aiICaiABIAJqLQAAOgAAIAINAAsMAgsgAkEDTQ0AIAIhBANAIAMgASgCADYCACABQQRqIQEgA0EEaiEDIARBfGoiBEEDSw0ACyACQQNxIQILIAJFDQADQCADIAEtAAA6AAAgA0EBaiEDIAFBAWohASACQX9qIgINAAsLIAAL8wICAn8BfgJAIAJFDQAgACACaiIDQX9qIAE6AAAgACABOgAAIAJBA0kNACADQX5qIAE6AAAgACABOgABIANBfWogAToAACAAIAE6AAIgAkEHSQ0AIANBfGogAToAACAAIAE6AAMgAkEJSQ0AIABBACAAa0EDcSIEaiIDIAFB/wFxQYGChAhsIgE2AgAgAyACIARrQXxxIgRqIgJBfGogATYCACAEQQlJDQAgAyABNgIIIAMgATYCBCACQXhqIAE2AgAgAkF0aiABNgIAIARBGUkNACADIAE2AhggAyABNgIUIAMgATYCECADIAE2AgwgAkFwaiABNgIAIAJBbGogATYCACACQWhqIAE2AgAgAkFkaiABNgIAIAQgA0EEcUEYciIEayICQSBJDQAgAa0iBUIghiAFhCEFIAMgBGohAQNAIAEgBTcDGCABIAU3AxAgASAFNwMIIAEgBTcDACABQSBqIQEgAkFgaiICQR9LDQALCyAACy8BAn8gACgCBCAAKAIAQQJ0aiICLQACIQMgACACLwEAIAEgAi0AAxAIajYCACADCy8BAn8gACgCBCAAKAIAQQJ0aiICLQACIQMgACACLwEAIAEgAi0AAxAFajYCACADCx8AIAAgASACKAIEEAg2AgAgARAEGiAAIAJBCGo2AgQLCAAgAGdBH3MLugUBDX8jAEEQayIKJAACfyAEQQNNBEAgCkEANgIMIApBDGogAyAEEAsaIAAgASACIApBDGpBBBAVIgBBbCAAEAMbIAAgACAESxsMAQsgAEEAIAEoAgBBAXRBAmoQECENQVQgAygAACIGQQ9xIgBBCksNABogAiAAQQVqNgIAIAMgBGoiAkF8aiEMIAJBeWohDiACQXtqIRAgAEEGaiELQQQhBSAGQQR2IQRBICAAdCIAQQFyIQkgASgCACEPQQAhAiADIQYCQANAIAlBAkggAiAPS3JFBEAgAiEHAkAgCARAA0AgBEH//wNxQf//A0YEQCAHQRhqIQcgBiAQSQR/IAZBAmoiBigAACAFdgUgBUEQaiEFIARBEHYLIQQMAQsLA0AgBEEDcSIIQQNGBEAgBUECaiEFIARBAnYhBCAHQQNqIQcMAQsLIAcgCGoiByAPSw0EIAVBAmohBQNAIAIgB0kEQCANIAJBAXRqQQA7AQAgAkEBaiECDAELCyAGIA5LQQAgBiAFQQN1aiIHIAxLG0UEQCAHKAAAIAVBB3EiBXYhBAwCCyAEQQJ2IQQLIAYhBwsCfyALQX9qIAQgAEF/anEiBiAAQQF0QX9qIgggCWsiEUkNABogBCAIcSIEQQAgESAEIABIG2shBiALCyEIIA0gAkEBdGogBkF/aiIEOwEAIAlBASAGayAEIAZBAUgbayEJA0AgCSAASARAIABBAXUhACALQX9qIQsMAQsLAn8gByAOS0EAIAcgBSAIaiIFQQN1aiIGIAxLG0UEQCAFQQdxDAELIAUgDCIGIAdrQQN0awshBSACQQFqIQIgBEUhCCAGKAAAIAVBH3F2IQQMAQsLQWwgCUEBRyAFQSBKcg0BGiABIAJBf2o2AgAgBiAFQQdqQQN1aiADawwBC0FQCyEAIApBEGokACAACwkAQQFBBSAAGwsMACAAIAEoAAA2AAALqgMBCn8jAEHwAGsiCiQAIAJBAWohDiAAQQhqIQtBgIAEIAVBf2p0QRB1IQxBACECQQEhBkEBIAV0IglBf2oiDyEIA0AgAiAORkUEQAJAIAEgAkEBdCINai8BACIHQf//A0YEQCALIAhBA3RqIAI2AgQgCEF/aiEIQQEhBwwBCyAGQQAgDCAHQRB0QRB1ShshBgsgCiANaiAHOwEAIAJBAWohAgwBCwsgACAFNgIEIAAgBjYCACAJQQN2IAlBAXZqQQNqIQxBACEAQQAhBkEAIQIDQCAGIA5GBEADQAJAIAAgCUYNACAKIAsgAEEDdGoiASgCBCIGQQF0aiICIAIvAQAiAkEBajsBACABIAUgAhAUayIIOgADIAEgAiAIQf8BcXQgCWs7AQAgASAEIAZBAnQiAmooAgA6AAIgASACIANqKAIANgIEIABBAWohAAwBCwsFIAEgBkEBdGouAQAhDUEAIQcDQCAHIA1ORQRAIAsgAkEDdGogBjYCBANAIAIgDGogD3EiAiAISw0ACyAHQQFqIQcMAQsLIAZBAWohBgwBCwsgCkHwAGokAAsjAEIAIAEQCSAAhUKHla+vmLbem55/fkLj3MqV/M7y9YV/fAsQACAAQn43AwggACABNgIACyQBAX8gAARAIAEoAgQiAgRAIAEoAgggACACEQEADwsgABAmCwsfACAAIAEgAi8BABAINgIAIAEQBBogACACQQRqNgIEC0oBAX9BoCAoAgAiASAAaiIAQX9MBEBBiCBBMDYCAEF/DwsCQCAAPwBBEHRNDQAgABBmDQBBiCBBMDYCAEF/DwtBoCAgADYCACABC9cBAQh/Qbp/IQoCQCACKAIEIgggAigCACIJaiIOIAEgAGtLDQBBbCEKIAkgBCADKAIAIgtrSw0AIAAgCWoiBCACKAIIIgxrIQ0gACABQWBqIg8gCyAJQQAQKSADIAkgC2o2AgACQAJAIAwgBCAFa00EQCANIQUMAQsgDCAEIAZrSw0CIAcgDSAFayIAaiIBIAhqIAdNBEAgBCABIAgQDxoMAgsgBCABQQAgAGsQDyEBIAIgACAIaiIINgIEIAEgAGshBAsgBCAPIAUgCEEBECkLIA4hCgsgCgubAgEBfyMAQYABayINJAAgDSADNgJ8AkAgAkEDSwRAQX8hCQwBCwJAAkACQAJAIAJBAWsOAwADAgELIAZFBEBBuH8hCQwEC0FsIQkgBS0AACICIANLDQMgACAHIAJBAnQiAmooAgAgAiAIaigCABA7IAEgADYCAEEBIQkMAwsgASAJNgIAQQAhCQwCCyAKRQRAQWwhCQwCC0EAIQkgC0UgDEEZSHINAUEIIAR0QQhqIQBBACECA0AgAiAATw0CIAJBQGshAgwAAAsAC0FsIQkgDSANQfwAaiANQfgAaiAFIAYQFSICEAMNACANKAJ4IgMgBEsNACAAIA0gDSgCfCAHIAggAxAYIAEgADYCACACIQkLIA1BgAFqJAAgCQsLACAAIAEgAhALGgsQACAALwAAIAAtAAJBEHRyCy8AAn9BuH8gAUEISQ0AGkFyIAAoAAQiAEF3Sw0AGkG4fyAAQQhqIgAgACABSxsLCwkAIAAgATsAAAsDAAELigYBBX8gACAAKAIAIgVBfnE2AgBBACAAIAVBAXZqQYQgKAIAIgQgAEYbIQECQAJAIAAoAgQiAkUNACACKAIAIgNBAXENACACQQhqIgUgA0EBdkF4aiIDQQggA0EISxtnQR9zQQJ0QYAfaiIDKAIARgRAIAMgAigCDDYCAAsgAigCCCIDBEAgAyACKAIMNgIECyACKAIMIgMEQCADIAIoAgg2AgALIAIgAigCACAAKAIAQX5xajYCAEGEICEAAkACQCABRQ0AIAEgAjYCBCABKAIAIgNBAXENASADQQF2QXhqIgNBCCADQQhLG2dBH3NBAnRBgB9qIgMoAgAgAUEIakYEQCADIAEoAgw2AgALIAEoAggiAwRAIAMgASgCDDYCBAsgASgCDCIDBEAgAyABKAIINgIAQYQgKAIAIQQLIAIgAigCACABKAIAQX5xajYCACABIARGDQAgASABKAIAQQF2akEEaiEACyAAIAI2AgALIAIoAgBBAXZBeGoiAEEIIABBCEsbZ0Efc0ECdEGAH2oiASgCACEAIAEgBTYCACACIAA2AgwgAkEANgIIIABFDQEgACAFNgIADwsCQCABRQ0AIAEoAgAiAkEBcQ0AIAJBAXZBeGoiAkEIIAJBCEsbZ0Efc0ECdEGAH2oiAigCACABQQhqRgRAIAIgASgCDDYCAAsgASgCCCICBEAgAiABKAIMNgIECyABKAIMIgIEQCACIAEoAgg2AgBBhCAoAgAhBAsgACAAKAIAIAEoAgBBfnFqIgI2AgACQCABIARHBEAgASABKAIAQQF2aiAANgIEIAAoAgAhAgwBC0GEICAANgIACyACQQF2QXhqIgFBCCABQQhLG2dBH3NBAnRBgB9qIgIoAgAhASACIABBCGoiAjYCACAAIAE2AgwgAEEANgIIIAFFDQEgASACNgIADwsgBUEBdkF4aiIBQQggAUEISxtnQR9zQQJ0QYAfaiICKAIAIQEgAiAAQQhqIgI2AgAgACABNgIMIABBADYCCCABRQ0AIAEgAjYCAAsLDgAgAARAIABBeGoQJQsLgAIBA38CQCAAQQ9qQXhxQYQgKAIAKAIAQQF2ayICEB1Bf0YNAAJAQYQgKAIAIgAoAgAiAUEBcQ0AIAFBAXZBeGoiAUEIIAFBCEsbZ0Efc0ECdEGAH2oiASgCACAAQQhqRgRAIAEgACgCDDYCAAsgACgCCCIBBEAgASAAKAIMNgIECyAAKAIMIgFFDQAgASAAKAIINgIAC0EBIQEgACAAKAIAIAJBAXRqIgI2AgAgAkEBcQ0AIAJBAXZBeGoiAkEIIAJBCEsbZ0Efc0ECdEGAH2oiAygCACECIAMgAEEIaiIDNgIAIAAgAjYCDCAAQQA2AgggAkUNACACIAM2AgALIAELtwIBA38CQAJAIABBASAAGyICEDgiAA0AAkACQEGEICgCACIARQ0AIAAoAgAiA0EBcQ0AIAAgA0EBcjYCACADQQF2QXhqIgFBCCABQQhLG2dBH3NBAnRBgB9qIgEoAgAgAEEIakYEQCABIAAoAgw2AgALIAAoAggiAQRAIAEgACgCDDYCBAsgACgCDCIBBEAgASAAKAIINgIACyACECchAkEAIQFBhCAoAgAhACACDQEgACAAKAIAQX5xNgIAQQAPCyACQQ9qQXhxIgMQHSICQX9GDQIgAkEHakF4cSIAIAJHBEAgACACaxAdQX9GDQMLAkBBhCAoAgAiAUUEQEGAICAANgIADAELIAAgATYCBAtBhCAgADYCACAAIANBAXRBAXI2AgAMAQsgAEUNAQsgAEEIaiEBCyABC7kDAQJ/IAAgA2ohBQJAIANBB0wEQANAIAAgBU8NAiAAIAItAAA6AAAgAEEBaiEAIAJBAWohAgwAAAsACyAEQQFGBEACQCAAIAJrIgZBB00EQCAAIAItAAA6AAAgACACLQABOgABIAAgAi0AAjoAAiAAIAItAAM6AAMgAEEEaiACIAZBAnQiBkHAHmooAgBqIgIQFyACIAZB4B5qKAIAayECDAELIAAgAhAMCyACQQhqIQIgAEEIaiEACwJAAkACQAJAIAUgAU0EQCAAIANqIQEgBEEBRyAAIAJrQQ9Kcg0BA0AgACACEAwgAkEIaiECIABBCGoiACABSQ0ACwwFCyAAIAFLBEAgACEBDAQLIARBAUcgACACa0EPSnINASAAIQMgAiEEA0AgAyAEEAwgBEEIaiEEIANBCGoiAyABSQ0ACwwCCwNAIAAgAhAHIAJBEGohAiAAQRBqIgAgAUkNAAsMAwsgACEDIAIhBANAIAMgBBAHIARBEGohBCADQRBqIgMgAUkNAAsLIAIgASAAa2ohAgsDQCABIAVPDQEgASACLQAAOgAAIAFBAWohASACQQFqIQIMAAALAAsLQQECfyAAIAAoArjgASIDNgLE4AEgACgCvOABIQQgACABNgK84AEgACABIAJqNgK44AEgACABIAQgA2tqNgLA4AELpgEBAX8gACAAKALs4QEQFjYCyOABIABCADcD+OABIABCADcDuOABIABBwOABakIANwMAIABBqNAAaiIBQYyAgOAANgIAIABBADYCmOIBIABCADcDiOEBIABCAzcDgOEBIABBrNABakHgEikCADcCACAAQbTQAWpB6BIoAgA2AgAgACABNgIMIAAgAEGYIGo2AgggACAAQaAwajYCBCAAIABBEGo2AgALYQEBf0G4fyEDAkAgAUEDSQ0AIAIgABAhIgFBA3YiADYCCCACIAFBAXE2AgQgAiABQQF2QQNxIgM2AgACQCADQX9qIgFBAksNAAJAIAFBAWsOAgEAAgtBbA8LIAAhAwsgAwsMACAAIAEgAkEAEC4LiAQCA38CfiADEBYhBCAAQQBBKBAQIQAgBCACSwRAIAQPCyABRQRAQX8PCwJAAkAgA0EBRg0AIAEoAAAiBkGo6r5pRg0AQXYhAyAGQXBxQdDUtMIBRw0BQQghAyACQQhJDQEgAEEAQSgQECEAIAEoAAQhASAAQQE2AhQgACABrTcDAEEADwsgASACIAMQLyIDIAJLDQAgACADNgIYQXIhAyABIARqIgVBf2otAAAiAkEIcQ0AIAJBIHEiBkUEQEFwIQMgBS0AACIFQacBSw0BIAVBB3GtQgEgBUEDdkEKaq2GIgdCA4h+IAd8IQggBEEBaiEECyACQQZ2IQMgAkECdiEFAkAgAkEDcUF/aiICQQJLBEBBACECDAELAkACQAJAIAJBAWsOAgECAAsgASAEai0AACECIARBAWohBAwCCyABIARqLwAAIQIgBEECaiEEDAELIAEgBGooAAAhAiAEQQRqIQQLIAVBAXEhBQJ+AkACQAJAIANBf2oiA0ECTQRAIANBAWsOAgIDAQtCfyAGRQ0DGiABIARqMQAADAMLIAEgBGovAACtQoACfAwCCyABIARqKAAArQwBCyABIARqKQAACyEHIAAgBTYCICAAIAI2AhwgACAHNwMAQQAhAyAAQQA2AhQgACAHIAggBhsiBzcDCCAAIAdCgIAIIAdCgIAIVBs+AhALIAMLWwEBf0G4fyEDIAIQFiICIAFNBH8gACACakF/ai0AACIAQQNxQQJ0QaAeaigCACACaiAAQQZ2IgFBAnRBsB5qKAIAaiAAQSBxIgBFaiABRSAAQQV2cWoFQbh/CwsdACAAKAKQ4gEQWiAAQQA2AqDiASAAQgA3A5DiAQu1AwEFfyMAQZACayIKJABBuH8hBgJAIAVFDQAgBCwAACIIQf8BcSEHAkAgCEF/TARAIAdBgn9qQQF2IgggBU8NAkFsIQYgB0GBf2oiBUGAAk8NAiAEQQFqIQdBACEGA0AgBiAFTwRAIAUhBiAIIQcMAwUgACAGaiAHIAZBAXZqIgQtAABBBHY6AAAgACAGQQFyaiAELQAAQQ9xOgAAIAZBAmohBgwBCwAACwALIAcgBU8NASAAIARBAWogByAKEFMiBhADDQELIAYhBEEAIQYgAUEAQTQQECEJQQAhBQNAIAQgBkcEQCAAIAZqIggtAAAiAUELSwRAQWwhBgwDBSAJIAFBAnRqIgEgASgCAEEBajYCACAGQQFqIQZBASAILQAAdEEBdSAFaiEFDAILAAsLQWwhBiAFRQ0AIAUQFEEBaiIBQQxLDQAgAyABNgIAQQFBASABdCAFayIDEBQiAXQgA0cNACAAIARqIAFBAWoiADoAACAJIABBAnRqIgAgACgCAEEBajYCACAJKAIEIgBBAkkgAEEBcXINACACIARBAWo2AgAgB0EBaiEGCyAKQZACaiQAIAYLxhEBDH8jAEHwAGsiBSQAQWwhCwJAIANBCkkNACACLwAAIQogAi8AAiEJIAIvAAQhByAFQQhqIAQQDgJAIAMgByAJIApqakEGaiIMSQ0AIAUtAAohCCAFQdgAaiACQQZqIgIgChAGIgsQAw0BIAVBQGsgAiAKaiICIAkQBiILEAMNASAFQShqIAIgCWoiAiAHEAYiCxADDQEgBUEQaiACIAdqIAMgDGsQBiILEAMNASAAIAFqIg9BfWohECAEQQRqIQZBASELIAAgAUEDakECdiIDaiIMIANqIgIgA2oiDiEDIAIhBCAMIQcDQCALIAMgEElxBEAgACAGIAVB2ABqIAgQAkECdGoiCS8BADsAACAFQdgAaiAJLQACEAEgCS0AAyELIAcgBiAFQUBrIAgQAkECdGoiCS8BADsAACAFQUBrIAktAAIQASAJLQADIQogBCAGIAVBKGogCBACQQJ0aiIJLwEAOwAAIAVBKGogCS0AAhABIAktAAMhCSADIAYgBUEQaiAIEAJBAnRqIg0vAQA7AAAgBUEQaiANLQACEAEgDS0AAyENIAAgC2oiCyAGIAVB2ABqIAgQAkECdGoiAC8BADsAACAFQdgAaiAALQACEAEgAC0AAyEAIAcgCmoiCiAGIAVBQGsgCBACQQJ0aiIHLwEAOwAAIAVBQGsgBy0AAhABIActAAMhByAEIAlqIgkgBiAFQShqIAgQAkECdGoiBC8BADsAACAFQShqIAQtAAIQASAELQADIQQgAyANaiIDIAYgBUEQaiAIEAJBAnRqIg0vAQA7AAAgBUEQaiANLQACEAEgACALaiEAIAcgCmohByAEIAlqIQQgAyANLQADaiEDIAVB2ABqEA0gBUFAaxANciAFQShqEA1yIAVBEGoQDXJFIQsMAQsLIAQgDksgByACS3INAEFsIQsgACAMSw0BIAxBfWohCQNAQQAgACAJSSAFQdgAahAEGwRAIAAgBiAFQdgAaiAIEAJBAnRqIgovAQA7AAAgBUHYAGogCi0AAhABIAAgCi0AA2oiACAGIAVB2ABqIAgQAkECdGoiCi8BADsAACAFQdgAaiAKLQACEAEgACAKLQADaiEADAEFIAxBfmohCgNAIAVB2ABqEAQgACAKS3JFBEAgACAGIAVB2ABqIAgQAkECdGoiCS8BADsAACAFQdgAaiAJLQACEAEgACAJLQADaiEADAELCwNAIAAgCk0EQCAAIAYgBUHYAGogCBACQQJ0aiIJLwEAOwAAIAVB2ABqIAktAAIQASAAIAktAANqIQAMAQsLAkAgACAMTw0AIAAgBiAFQdgAaiAIEAIiAEECdGoiDC0AADoAACAMLQADQQFGBEAgBUHYAGogDC0AAhABDAELIAUoAlxBH0sNACAFQdgAaiAGIABBAnRqLQACEAEgBSgCXEEhSQ0AIAVBIDYCXAsgAkF9aiEMA0BBACAHIAxJIAVBQGsQBBsEQCAHIAYgBUFAayAIEAJBAnRqIgAvAQA7AAAgBUFAayAALQACEAEgByAALQADaiIAIAYgBUFAayAIEAJBAnRqIgcvAQA7AAAgBUFAayAHLQACEAEgACAHLQADaiEHDAEFIAJBfmohDANAIAVBQGsQBCAHIAxLckUEQCAHIAYgBUFAayAIEAJBAnRqIgAvAQA7AAAgBUFAayAALQACEAEgByAALQADaiEHDAELCwNAIAcgDE0EQCAHIAYgBUFAayAIEAJBAnRqIgAvAQA7AAAgBUFAayAALQACEAEgByAALQADaiEHDAELCwJAIAcgAk8NACAHIAYgBUFAayAIEAIiAEECdGoiAi0AADoAACACLQADQQFGBEAgBUFAayACLQACEAEMAQsgBSgCREEfSw0AIAVBQGsgBiAAQQJ0ai0AAhABIAUoAkRBIUkNACAFQSA2AkQLIA5BfWohAgNAQQAgBCACSSAFQShqEAQbBEAgBCAGIAVBKGogCBACQQJ0aiIALwEAOwAAIAVBKGogAC0AAhABIAQgAC0AA2oiACAGIAVBKGogCBACQQJ0aiIELwEAOwAAIAVBKGogBC0AAhABIAAgBC0AA2ohBAwBBSAOQX5qIQIDQCAFQShqEAQgBCACS3JFBEAgBCAGIAVBKGogCBACQQJ0aiIALwEAOwAAIAVBKGogAC0AAhABIAQgAC0AA2ohBAwBCwsDQCAEIAJNBEAgBCAGIAVBKGogCBACQQJ0aiIALwEAOwAAIAVBKGogAC0AAhABIAQgAC0AA2ohBAwBCwsCQCAEIA5PDQAgBCAGIAVBKGogCBACIgBBAnRqIgItAAA6AAAgAi0AA0EBRgRAIAVBKGogAi0AAhABDAELIAUoAixBH0sNACAFQShqIAYgAEECdGotAAIQASAFKAIsQSFJDQAgBUEgNgIsCwNAQQAgAyAQSSAFQRBqEAQbBEAgAyAGIAVBEGogCBACQQJ0aiIALwEAOwAAIAVBEGogAC0AAhABIAMgAC0AA2oiACAGIAVBEGogCBACQQJ0aiICLwEAOwAAIAVBEGogAi0AAhABIAAgAi0AA2ohAwwBBSAPQX5qIQIDQCAFQRBqEAQgAyACS3JFBEAgAyAGIAVBEGogCBACQQJ0aiIALwEAOwAAIAVBEGogAC0AAhABIAMgAC0AA2ohAwwBCwsDQCADIAJNBEAgAyAGIAVBEGogCBACQQJ0aiIALwEAOwAAIAVBEGogAC0AAhABIAMgAC0AA2ohAwwBCwsCQCADIA9PDQAgAyAGIAVBEGogCBACIgBBAnRqIgItAAA6AAAgAi0AA0EBRgRAIAVBEGogAi0AAhABDAELIAUoAhRBH0sNACAFQRBqIAYgAEECdGotAAIQASAFKAIUQSFJDQAgBUEgNgIUCyABQWwgBUHYAGoQCiAFQUBrEApxIAVBKGoQCnEgBUEQahAKcRshCwwJCwAACwALAAALAAsAAAsACwAACwALQWwhCwsgBUHwAGokACALC7UEAQ5/IwBBEGsiBiQAIAZBBGogABAOQVQhBQJAIARB3AtJDQAgBi0ABCEHIANB8ARqQQBB7AAQECEIIAdBDEsNACADQdwJaiIJIAggBkEIaiAGQQxqIAEgAhAxIhAQA0UEQCAGKAIMIgQgB0sNASADQdwFaiEPIANBpAVqIREgAEEEaiESIANBqAVqIQEgBCEFA0AgBSICQX9qIQUgCCACQQJ0aigCAEUNAAsgAkEBaiEOQQEhBQNAIAUgDk9FBEAgCCAFQQJ0IgtqKAIAIQwgASALaiAKNgIAIAVBAWohBSAKIAxqIQoMAQsLIAEgCjYCAEEAIQUgBigCCCELA0AgBSALRkUEQCABIAUgCWotAAAiDEECdGoiDSANKAIAIg1BAWo2AgAgDyANQQF0aiINIAw6AAEgDSAFOgAAIAVBAWohBQwBCwtBACEBIANBADYCqAUgBEF/cyAHaiEJQQEhBQNAIAUgDk9FBEAgCCAFQQJ0IgtqKAIAIQwgAyALaiABNgIAIAwgBSAJanQgAWohASAFQQFqIQUMAQsLIAcgBEEBaiIBIAJrIgRrQQFqIQgDQEEBIQUgBCAIT0UEQANAIAUgDk9FBEAgBUECdCIJIAMgBEE0bGpqIAMgCWooAgAgBHY2AgAgBUEBaiEFDAELCyAEQQFqIQQMAQsLIBIgByAPIAogESADIAIgARBkIAZBAToABSAGIAc6AAYgACAGKAIENgIACyAQIQULIAZBEGokACAFC8ENAQt/IwBB8ABrIgUkAEFsIQkCQCADQQpJDQAgAi8AACEKIAIvAAIhDCACLwAEIQYgBUEIaiAEEA4CQCADIAYgCiAMampBBmoiDUkNACAFLQAKIQcgBUHYAGogAkEGaiICIAoQBiIJEAMNASAFQUBrIAIgCmoiAiAMEAYiCRADDQEgBUEoaiACIAxqIgIgBhAGIgkQAw0BIAVBEGogAiAGaiADIA1rEAYiCRADDQEgACABaiIOQX1qIQ8gBEEEaiEGQQEhCSAAIAFBA2pBAnYiAmoiCiACaiIMIAJqIg0hAyAMIQQgCiECA0AgCSADIA9JcQRAIAYgBUHYAGogBxACQQF0aiIILQAAIQsgBUHYAGogCC0AARABIAAgCzoAACAGIAVBQGsgBxACQQF0aiIILQAAIQsgBUFAayAILQABEAEgAiALOgAAIAYgBUEoaiAHEAJBAXRqIggtAAAhCyAFQShqIAgtAAEQASAEIAs6AAAgBiAFQRBqIAcQAkEBdGoiCC0AACELIAVBEGogCC0AARABIAMgCzoAACAGIAVB2ABqIAcQAkEBdGoiCC0AACELIAVB2ABqIAgtAAEQASAAIAs6AAEgBiAFQUBrIAcQAkEBdGoiCC0AACELIAVBQGsgCC0AARABIAIgCzoAASAGIAVBKGogBxACQQF0aiIILQAAIQsgBUEoaiAILQABEAEgBCALOgABIAYgBUEQaiAHEAJBAXRqIggtAAAhCyAFQRBqIAgtAAEQASADIAs6AAEgA0ECaiEDIARBAmohBCACQQJqIQIgAEECaiEAIAkgBUHYAGoQDUVxIAVBQGsQDUVxIAVBKGoQDUVxIAVBEGoQDUVxIQkMAQsLIAQgDUsgAiAMS3INAEFsIQkgACAKSw0BIApBfWohCQNAIAVB2ABqEAQgACAJT3JFBEAgBiAFQdgAaiAHEAJBAXRqIggtAAAhCyAFQdgAaiAILQABEAEgACALOgAAIAYgBUHYAGogBxACQQF0aiIILQAAIQsgBUHYAGogCC0AARABIAAgCzoAASAAQQJqIQAMAQsLA0AgBUHYAGoQBCAAIApPckUEQCAGIAVB2ABqIAcQAkEBdGoiCS0AACEIIAVB2ABqIAktAAEQASAAIAg6AAAgAEEBaiEADAELCwNAIAAgCkkEQCAGIAVB2ABqIAcQAkEBdGoiCS0AACEIIAVB2ABqIAktAAEQASAAIAg6AAAgAEEBaiEADAELCyAMQX1qIQADQCAFQUBrEAQgAiAAT3JFBEAgBiAFQUBrIAcQAkEBdGoiCi0AACEJIAVBQGsgCi0AARABIAIgCToAACAGIAVBQGsgBxACQQF0aiIKLQAAIQkgBUFAayAKLQABEAEgAiAJOgABIAJBAmohAgwBCwsDQCAFQUBrEAQgAiAMT3JFBEAgBiAFQUBrIAcQAkEBdGoiAC0AACEKIAVBQGsgAC0AARABIAIgCjoAACACQQFqIQIMAQsLA0AgAiAMSQRAIAYgBUFAayAHEAJBAXRqIgAtAAAhCiAFQUBrIAAtAAEQASACIAo6AAAgAkEBaiECDAELCyANQX1qIQADQCAFQShqEAQgBCAAT3JFBEAgBiAFQShqIAcQAkEBdGoiAi0AACEKIAVBKGogAi0AARABIAQgCjoAACAGIAVBKGogBxACQQF0aiICLQAAIQogBUEoaiACLQABEAEgBCAKOgABIARBAmohBAwBCwsDQCAFQShqEAQgBCANT3JFBEAgBiAFQShqIAcQAkEBdGoiAC0AACECIAVBKGogAC0AARABIAQgAjoAACAEQQFqIQQMAQsLA0AgBCANSQRAIAYgBUEoaiAHEAJBAXRqIgAtAAAhAiAFQShqIAAtAAEQASAEIAI6AAAgBEEBaiEEDAELCwNAIAVBEGoQBCADIA9PckUEQCAGIAVBEGogBxACQQF0aiIALQAAIQIgBUEQaiAALQABEAEgAyACOgAAIAYgBUEQaiAHEAJBAXRqIgAtAAAhAiAFQRBqIAAtAAEQASADIAI6AAEgA0ECaiEDDAELCwNAIAVBEGoQBCADIA5PckUEQCAGIAVBEGogBxACQQF0aiIALQAAIQIgBUEQaiAALQABEAEgAyACOgAAIANBAWohAwwBCwsDQCADIA5JBEAgBiAFQRBqIAcQAkEBdGoiAC0AACECIAVBEGogAC0AARABIAMgAjoAACADQQFqIQMMAQsLIAFBbCAFQdgAahAKIAVBQGsQCnEgBUEoahAKcSAFQRBqEApxGyEJDAELQWwhCQsgBUHwAGokACAJC8oCAQR/IwBBIGsiBSQAIAUgBBAOIAUtAAIhByAFQQhqIAIgAxAGIgIQA0UEQCAEQQRqIQIgACABaiIDQX1qIQQDQCAFQQhqEAQgACAET3JFBEAgAiAFQQhqIAcQAkEBdGoiBi0AACEIIAVBCGogBi0AARABIAAgCDoAACACIAVBCGogBxACQQF0aiIGLQAAIQggBUEIaiAGLQABEAEgACAIOgABIABBAmohAAwBCwsDQCAFQQhqEAQgACADT3JFBEAgAiAFQQhqIAcQAkEBdGoiBC0AACEGIAVBCGogBC0AARABIAAgBjoAACAAQQFqIQAMAQsLA0AgACADT0UEQCACIAVBCGogBxACQQF0aiIELQAAIQYgBUEIaiAELQABEAEgACAGOgAAIABBAWohAAwBCwsgAUFsIAVBCGoQChshAgsgBUEgaiQAIAILtgMBCX8jAEEQayIGJAAgBkEANgIMIAZBADYCCEFUIQQCQAJAIANBQGsiDCADIAZBCGogBkEMaiABIAIQMSICEAMNACAGQQRqIAAQDiAGKAIMIgcgBi0ABEEBaksNASAAQQRqIQogBkEAOgAFIAYgBzoABiAAIAYoAgQ2AgAgB0EBaiEJQQEhBANAIAQgCUkEQCADIARBAnRqIgEoAgAhACABIAU2AgAgACAEQX9qdCAFaiEFIARBAWohBAwBCwsgB0EBaiEHQQAhBSAGKAIIIQkDQCAFIAlGDQEgAyAFIAxqLQAAIgRBAnRqIgBBASAEdEEBdSILIAAoAgAiAWoiADYCACAHIARrIQhBACEEAkAgC0EDTQRAA0AgBCALRg0CIAogASAEakEBdGoiACAIOgABIAAgBToAACAEQQFqIQQMAAALAAsDQCABIABPDQEgCiABQQF0aiIEIAg6AAEgBCAFOgAAIAQgCDoAAyAEIAU6AAIgBCAIOgAFIAQgBToABCAEIAg6AAcgBCAFOgAGIAFBBGohAQwAAAsACyAFQQFqIQUMAAALAAsgAiEECyAGQRBqJAAgBAutAQECfwJAQYQgKAIAIABHIAAoAgBBAXYiAyABa0F4aiICQXhxQQhHcgR/IAIFIAMQJ0UNASACQQhqC0EQSQ0AIAAgACgCACICQQFxIAAgAWpBD2pBeHEiASAAa0EBdHI2AgAgASAANgIEIAEgASgCAEEBcSAAIAJBAXZqIAFrIgJBAXRyNgIAQYQgIAEgAkH/////B3FqQQRqQYQgKAIAIABGGyABNgIAIAEQJQsLygIBBX8CQAJAAkAgAEEIIABBCEsbZ0EfcyAAaUEBR2oiAUEESSAAIAF2cg0AIAFBAnRB/B5qKAIAIgJFDQADQCACQXhqIgMoAgBBAXZBeGoiBSAATwRAIAIgBUEIIAVBCEsbZ0Efc0ECdEGAH2oiASgCAEYEQCABIAIoAgQ2AgALDAMLIARBHksNASAEQQFqIQQgAigCBCICDQALC0EAIQMgAUEgTw0BA0AgAUECdEGAH2ooAgAiAkUEQCABQR5LIQIgAUEBaiEBIAJFDQEMAwsLIAIgAkF4aiIDKAIAQQF2QXhqIgFBCCABQQhLG2dBH3NBAnRBgB9qIgEoAgBGBEAgASACKAIENgIACwsgAigCACIBBEAgASACKAIENgIECyACKAIEIgEEQCABIAIoAgA2AgALIAMgAygCAEEBcjYCACADIAAQNwsgAwvhCwINfwV+IwBB8ABrIgckACAHIAAoAvDhASIINgJcIAEgAmohDSAIIAAoAoDiAWohDwJAAkAgBUUEQCABIQQMAQsgACgCxOABIRAgACgCwOABIREgACgCvOABIQ4gAEEBNgKM4QFBACEIA0AgCEEDRwRAIAcgCEECdCICaiAAIAJqQazQAWooAgA2AkQgCEEBaiEIDAELC0FsIQwgB0EYaiADIAQQBhADDQEgB0EsaiAHQRhqIAAoAgAQEyAHQTRqIAdBGGogACgCCBATIAdBPGogB0EYaiAAKAIEEBMgDUFgaiESIAEhBEEAIQwDQCAHKAIwIAcoAixBA3RqKQIAIhRCEIinQf8BcSEIIAcoAkAgBygCPEEDdGopAgAiFUIQiKdB/wFxIQsgBygCOCAHKAI0QQN0aikCACIWQiCIpyEJIBVCIIghFyAUQiCIpyECAkAgFkIQiKdB/wFxIgNBAk8EQAJAIAZFIANBGUlyRQRAIAkgB0EYaiADQSAgBygCHGsiCiAKIANLGyIKEAUgAyAKayIDdGohCSAHQRhqEAQaIANFDQEgB0EYaiADEAUgCWohCQwBCyAHQRhqIAMQBSAJaiEJIAdBGGoQBBoLIAcpAkQhGCAHIAk2AkQgByAYNwNIDAELAkAgA0UEQCACBEAgBygCRCEJDAMLIAcoAkghCQwBCwJAAkAgB0EYakEBEAUgCSACRWpqIgNBA0YEQCAHKAJEQX9qIgMgA0VqIQkMAQsgA0ECdCAHaigCRCIJIAlFaiEJIANBAUYNAQsgByAHKAJINgJMCwsgByAHKAJENgJIIAcgCTYCRAsgF6chAyALBEAgB0EYaiALEAUgA2ohAwsgCCALakEUTwRAIAdBGGoQBBoLIAgEQCAHQRhqIAgQBSACaiECCyAHQRhqEAQaIAcgB0EYaiAUQhiIp0H/AXEQCCAUp0H//wNxajYCLCAHIAdBGGogFUIYiKdB/wFxEAggFadB//8DcWo2AjwgB0EYahAEGiAHIAdBGGogFkIYiKdB/wFxEAggFqdB//8DcWo2AjQgByACNgJgIAcoAlwhCiAHIAk2AmggByADNgJkAkACQAJAIAQgAiADaiILaiASSw0AIAIgCmoiEyAPSw0AIA0gBGsgC0Egak8NAQsgByAHKQNoNwMQIAcgBykDYDcDCCAEIA0gB0EIaiAHQdwAaiAPIA4gESAQEB4hCwwBCyACIARqIQggBCAKEAcgAkERTwRAIARBEGohAgNAIAIgCkEQaiIKEAcgAkEQaiICIAhJDQALCyAIIAlrIQIgByATNgJcIAkgCCAOa0sEQCAJIAggEWtLBEBBbCELDAILIBAgAiAOayICaiIKIANqIBBNBEAgCCAKIAMQDxoMAgsgCCAKQQAgAmsQDyEIIAcgAiADaiIDNgJkIAggAmshCCAOIQILIAlBEE8EQCADIAhqIQMDQCAIIAIQByACQRBqIQIgCEEQaiIIIANJDQALDAELAkAgCUEHTQRAIAggAi0AADoAACAIIAItAAE6AAEgCCACLQACOgACIAggAi0AAzoAAyAIQQRqIAIgCUECdCIDQcAeaigCAGoiAhAXIAIgA0HgHmooAgBrIQIgBygCZCEDDAELIAggAhAMCyADQQlJDQAgAyAIaiEDIAhBCGoiCCACQQhqIgJrQQ9MBEADQCAIIAIQDCACQQhqIQIgCEEIaiIIIANJDQAMAgALAAsDQCAIIAIQByACQRBqIQIgCEEQaiIIIANJDQALCyAHQRhqEAQaIAsgDCALEAMiAhshDCAEIAQgC2ogAhshBCAFQX9qIgUNAAsgDBADDQFBbCEMIAdBGGoQBEECSQ0BQQAhCANAIAhBA0cEQCAAIAhBAnQiAmpBrNABaiACIAdqKAJENgIAIAhBAWohCAwBCwsgBygCXCEIC0G6fyEMIA8gCGsiACANIARrSw0AIAQEfyAEIAggABALIABqBUEACyABayEMCyAHQfAAaiQAIAwLkRcCFn8FfiMAQdABayIHJAAgByAAKALw4QEiCDYCvAEgASACaiESIAggACgCgOIBaiETAkACQCAFRQRAIAEhAwwBCyAAKALE4AEhESAAKALA4AEhFSAAKAK84AEhDyAAQQE2AozhAUEAIQgDQCAIQQNHBEAgByAIQQJ0IgJqIAAgAmpBrNABaigCADYCVCAIQQFqIQgMAQsLIAcgETYCZCAHIA82AmAgByABIA9rNgJoQWwhECAHQShqIAMgBBAGEAMNASAFQQQgBUEESBshFyAHQTxqIAdBKGogACgCABATIAdBxABqIAdBKGogACgCCBATIAdBzABqIAdBKGogACgCBBATQQAhBCAHQeAAaiEMIAdB5ABqIQoDQCAHQShqEARBAksgBCAXTnJFBEAgBygCQCAHKAI8QQN0aikCACIdQhCIp0H/AXEhCyAHKAJQIAcoAkxBA3RqKQIAIh5CEIinQf8BcSEJIAcoAkggBygCREEDdGopAgAiH0IgiKchCCAeQiCIISAgHUIgiKchAgJAIB9CEIinQf8BcSIDQQJPBEACQCAGRSADQRlJckUEQCAIIAdBKGogA0EgIAcoAixrIg0gDSADSxsiDRAFIAMgDWsiA3RqIQggB0EoahAEGiADRQ0BIAdBKGogAxAFIAhqIQgMAQsgB0EoaiADEAUgCGohCCAHQShqEAQaCyAHKQJUISEgByAINgJUIAcgITcDWAwBCwJAIANFBEAgAgRAIAcoAlQhCAwDCyAHKAJYIQgMAQsCQAJAIAdBKGpBARAFIAggAkVqaiIDQQNGBEAgBygCVEF/aiIDIANFaiEIDAELIANBAnQgB2ooAlQiCCAIRWohCCADQQFGDQELIAcgBygCWDYCXAsLIAcgBygCVDYCWCAHIAg2AlQLICCnIQMgCQRAIAdBKGogCRAFIANqIQMLIAkgC2pBFE8EQCAHQShqEAQaCyALBEAgB0EoaiALEAUgAmohAgsgB0EoahAEGiAHIAcoAmggAmoiCSADajYCaCAKIAwgCCAJSxsoAgAhDSAHIAdBKGogHUIYiKdB/wFxEAggHadB//8DcWo2AjwgByAHQShqIB5CGIinQf8BcRAIIB6nQf//A3FqNgJMIAdBKGoQBBogB0EoaiAfQhiIp0H/AXEQCCEOIAdB8ABqIARBBHRqIgsgCSANaiAIazYCDCALIAg2AgggCyADNgIEIAsgAjYCACAHIA4gH6dB//8DcWo2AkQgBEEBaiEEDAELCyAEIBdIDQEgEkFgaiEYIAdB4ABqIRogB0HkAGohGyABIQMDQCAHQShqEARBAksgBCAFTnJFBEAgBygCQCAHKAI8QQN0aikCACIdQhCIp0H/AXEhCyAHKAJQIAcoAkxBA3RqKQIAIh5CEIinQf8BcSEIIAcoAkggBygCREEDdGopAgAiH0IgiKchCSAeQiCIISAgHUIgiKchDAJAIB9CEIinQf8BcSICQQJPBEACQCAGRSACQRlJckUEQCAJIAdBKGogAkEgIAcoAixrIgogCiACSxsiChAFIAIgCmsiAnRqIQkgB0EoahAEGiACRQ0BIAdBKGogAhAFIAlqIQkMAQsgB0EoaiACEAUgCWohCSAHQShqEAQaCyAHKQJUISEgByAJNgJUIAcgITcDWAwBCwJAIAJFBEAgDARAIAcoAlQhCQwDCyAHKAJYIQkMAQsCQAJAIAdBKGpBARAFIAkgDEVqaiICQQNGBEAgBygCVEF/aiICIAJFaiEJDAELIAJBAnQgB2ooAlQiCSAJRWohCSACQQFGDQELIAcgBygCWDYCXAsLIAcgBygCVDYCWCAHIAk2AlQLICCnIRQgCARAIAdBKGogCBAFIBRqIRQLIAggC2pBFE8EQCAHQShqEAQaCyALBEAgB0EoaiALEAUgDGohDAsgB0EoahAEGiAHIAcoAmggDGoiGSAUajYCaCAbIBogCSAZSxsoAgAhHCAHIAdBKGogHUIYiKdB/wFxEAggHadB//8DcWo2AjwgByAHQShqIB5CGIinQf8BcRAIIB6nQf//A3FqNgJMIAdBKGoQBBogByAHQShqIB9CGIinQf8BcRAIIB+nQf//A3FqNgJEIAcgB0HwAGogBEEDcUEEdGoiDSkDCCIdNwPIASAHIA0pAwAiHjcDwAECQAJAAkAgBygCvAEiDiAepyICaiIWIBNLDQAgAyAHKALEASIKIAJqIgtqIBhLDQAgEiADayALQSBqTw0BCyAHIAcpA8gBNwMQIAcgBykDwAE3AwggAyASIAdBCGogB0G8AWogEyAPIBUgERAeIQsMAQsgAiADaiEIIAMgDhAHIAJBEU8EQCADQRBqIQIDQCACIA5BEGoiDhAHIAJBEGoiAiAISQ0ACwsgCCAdpyIOayECIAcgFjYCvAEgDiAIIA9rSwRAIA4gCCAVa0sEQEFsIQsMAgsgESACIA9rIgJqIhYgCmogEU0EQCAIIBYgChAPGgwCCyAIIBZBACACaxAPIQggByACIApqIgo2AsQBIAggAmshCCAPIQILIA5BEE8EQCAIIApqIQoDQCAIIAIQByACQRBqIQIgCEEQaiIIIApJDQALDAELAkAgDkEHTQRAIAggAi0AADoAACAIIAItAAE6AAEgCCACLQACOgACIAggAi0AAzoAAyAIQQRqIAIgDkECdCIKQcAeaigCAGoiAhAXIAIgCkHgHmooAgBrIQIgBygCxAEhCgwBCyAIIAIQDAsgCkEJSQ0AIAggCmohCiAIQQhqIgggAkEIaiICa0EPTARAA0AgCCACEAwgAkEIaiECIAhBCGoiCCAKSQ0ADAIACwALA0AgCCACEAcgAkEQaiECIAhBEGoiCCAKSQ0ACwsgCxADBEAgCyEQDAQFIA0gDDYCACANIBkgHGogCWs2AgwgDSAJNgIIIA0gFDYCBCAEQQFqIQQgAyALaiEDDAILAAsLIAQgBUgNASAEIBdrIQtBACEEA0AgCyAFSARAIAcgB0HwAGogC0EDcUEEdGoiAikDCCIdNwPIASAHIAIpAwAiHjcDwAECQAJAAkAgBygCvAEiDCAepyICaiIKIBNLDQAgAyAHKALEASIJIAJqIhBqIBhLDQAgEiADayAQQSBqTw0BCyAHIAcpA8gBNwMgIAcgBykDwAE3AxggAyASIAdBGGogB0G8AWogEyAPIBUgERAeIRAMAQsgAiADaiEIIAMgDBAHIAJBEU8EQCADQRBqIQIDQCACIAxBEGoiDBAHIAJBEGoiAiAISQ0ACwsgCCAdpyIGayECIAcgCjYCvAEgBiAIIA9rSwRAIAYgCCAVa0sEQEFsIRAMAgsgESACIA9rIgJqIgwgCWogEU0EQCAIIAwgCRAPGgwCCyAIIAxBACACaxAPIQggByACIAlqIgk2AsQBIAggAmshCCAPIQILIAZBEE8EQCAIIAlqIQYDQCAIIAIQByACQRBqIQIgCEEQaiIIIAZJDQALDAELAkAgBkEHTQRAIAggAi0AADoAACAIIAItAAE6AAEgCCACLQACOgACIAggAi0AAzoAAyAIQQRqIAIgBkECdCIGQcAeaigCAGoiAhAXIAIgBkHgHmooAgBrIQIgBygCxAEhCQwBCyAIIAIQDAsgCUEJSQ0AIAggCWohBiAIQQhqIgggAkEIaiICa0EPTARAA0AgCCACEAwgAkEIaiECIAhBCGoiCCAGSQ0ADAIACwALA0AgCCACEAcgAkEQaiECIAhBEGoiCCAGSQ0ACwsgEBADDQMgC0EBaiELIAMgEGohAwwBCwsDQCAEQQNHBEAgACAEQQJ0IgJqQazQAWogAiAHaigCVDYCACAEQQFqIQQMAQsLIAcoArwBIQgLQbp/IRAgEyAIayIAIBIgA2tLDQAgAwR/IAMgCCAAEAsgAGoFQQALIAFrIRALIAdB0AFqJAAgEAslACAAQgA3AgAgAEEAOwEIIABBADoACyAAIAE2AgwgACACOgAKC7QFAQN/IwBBMGsiBCQAIABB/wFqIgVBfWohBgJAIAMvAQIEQCAEQRhqIAEgAhAGIgIQAw0BIARBEGogBEEYaiADEBwgBEEIaiAEQRhqIAMQHCAAIQMDQAJAIARBGGoQBCADIAZPckUEQCADIARBEGogBEEYahASOgAAIAMgBEEIaiAEQRhqEBI6AAEgBEEYahAERQ0BIANBAmohAwsgBUF+aiEFAn8DQEG6fyECIAMiASAFSw0FIAEgBEEQaiAEQRhqEBI6AAAgAUEBaiEDIARBGGoQBEEDRgRAQQIhAiAEQQhqDAILIAMgBUsNBSABIARBCGogBEEYahASOgABIAFBAmohA0EDIQIgBEEYahAEQQNHDQALIARBEGoLIQUgAyAFIARBGGoQEjoAACABIAJqIABrIQIMAwsgAyAEQRBqIARBGGoQEjoAAiADIARBCGogBEEYahASOgADIANBBGohAwwAAAsACyAEQRhqIAEgAhAGIgIQAw0AIARBEGogBEEYaiADEBwgBEEIaiAEQRhqIAMQHCAAIQMDQAJAIARBGGoQBCADIAZPckUEQCADIARBEGogBEEYahAROgAAIAMgBEEIaiAEQRhqEBE6AAEgBEEYahAERQ0BIANBAmohAwsgBUF+aiEFAn8DQEG6fyECIAMiASAFSw0EIAEgBEEQaiAEQRhqEBE6AAAgAUEBaiEDIARBGGoQBEEDRgRAQQIhAiAEQQhqDAILIAMgBUsNBCABIARBCGogBEEYahAROgABIAFBAmohA0EDIQIgBEEYahAEQQNHDQALIARBEGoLIQUgAyAFIARBGGoQEToAACABIAJqIABrIQIMAgsgAyAEQRBqIARBGGoQEToAAiADIARBCGogBEEYahAROgADIANBBGohAwwAAAsACyAEQTBqJAAgAgtpAQF/An8CQAJAIAJBB00NACABKAAAQbfIwuF+Rw0AIAAgASgABDYCmOIBQWIgAEEQaiABIAIQPiIDEAMNAhogAEKBgICAEDcDiOEBIAAgASADaiACIANrECoMAQsgACABIAIQKgtBAAsLrQMBBn8jAEGAAWsiAyQAQWIhCAJAIAJBCUkNACAAQZjQAGogAUEIaiIEIAJBeGogAEGY0AAQMyIFEAMiBg0AIANBHzYCfCADIANB/ABqIANB+ABqIAQgBCAFaiAGGyIEIAEgAmoiAiAEaxAVIgUQAw0AIAMoAnwiBkEfSw0AIAMoAngiB0EJTw0AIABBiCBqIAMgBkGAC0GADCAHEBggA0E0NgJ8IAMgA0H8AGogA0H4AGogBCAFaiIEIAIgBGsQFSIFEAMNACADKAJ8IgZBNEsNACADKAJ4IgdBCk8NACAAQZAwaiADIAZBgA1B4A4gBxAYIANBIzYCfCADIANB/ABqIANB+ABqIAQgBWoiBCACIARrEBUiBRADDQAgAygCfCIGQSNLDQAgAygCeCIHQQpPDQAgACADIAZBwBBB0BEgBxAYIAQgBWoiBEEMaiIFIAJLDQAgAiAFayEFQQAhAgNAIAJBA0cEQCAEKAAAIgZBf2ogBU8NAiAAIAJBAnRqQZzQAWogBjYCACACQQFqIQIgBEEEaiEEDAELCyAEIAFrIQgLIANBgAFqJAAgCAtGAQN/IABBCGohAyAAKAIEIQJBACEAA0AgACACdkUEQCABIAMgAEEDdGotAAJBFktqIQEgAEEBaiEADAELCyABQQggAmt0C4YDAQV/Qbh/IQcCQCADRQ0AIAItAAAiBEUEQCABQQA2AgBBAUG4fyADQQFGGw8LAn8gAkEBaiIFIARBGHRBGHUiBkF/Sg0AGiAGQX9GBEAgA0EDSA0CIAUvAABBgP4BaiEEIAJBA2oMAQsgA0ECSA0BIAItAAEgBEEIdHJBgIB+aiEEIAJBAmoLIQUgASAENgIAIAVBAWoiASACIANqIgNLDQBBbCEHIABBEGogACAFLQAAIgVBBnZBI0EJIAEgAyABa0HAEEHQEUHwEiAAKAKM4QEgACgCnOIBIAQQHyIGEAMiCA0AIABBmCBqIABBCGogBUEEdkEDcUEfQQggASABIAZqIAgbIgEgAyABa0GAC0GADEGAFyAAKAKM4QEgACgCnOIBIAQQHyIGEAMiCA0AIABBoDBqIABBBGogBUECdkEDcUE0QQkgASABIAZqIAgbIgEgAyABa0GADUHgDkGQGSAAKAKM4QEgACgCnOIBIAQQHyIAEAMNACAAIAFqIAJrIQcLIAcLrQMBCn8jAEGABGsiCCQAAn9BUiACQf8BSw0AGkFUIANBDEsNABogAkEBaiELIABBBGohCUGAgAQgA0F/anRBEHUhCkEAIQJBASEEQQEgA3QiB0F/aiIMIQUDQCACIAtGRQRAAkAgASACQQF0Ig1qLwEAIgZB//8DRgRAIAkgBUECdGogAjoAAiAFQX9qIQVBASEGDAELIARBACAKIAZBEHRBEHVKGyEECyAIIA1qIAY7AQAgAkEBaiECDAELCyAAIAQ7AQIgACADOwEAIAdBA3YgB0EBdmpBA2ohBkEAIQRBACECA0AgBCALRkUEQCABIARBAXRqLgEAIQpBACEAA0AgACAKTkUEQCAJIAJBAnRqIAQ6AAIDQCACIAZqIAxxIgIgBUsNAAsgAEEBaiEADAELCyAEQQFqIQQMAQsLQX8gAg0AGkEAIQIDfyACIAdGBH9BAAUgCCAJIAJBAnRqIgAtAAJBAXRqIgEgAS8BACIBQQFqOwEAIAAgAyABEBRrIgU6AAMgACABIAVB/wFxdCAHazsBACACQQFqIQIMAQsLCyEFIAhBgARqJAAgBQvjBgEIf0FsIQcCQCACQQNJDQACQAJAAkACQCABLQAAIgNBA3EiCUEBaw4DAwEAAgsgACgCiOEBDQBBYg8LIAJBBUkNAkEDIQYgASgAACEFAn8CQAJAIANBAnZBA3EiCEF+aiIEQQFNBEAgBEEBaw0BDAILIAVBDnZB/wdxIQQgBUEEdkH/B3EhAyAIRQwCCyAFQRJ2IQRBBCEGIAVBBHZB//8AcSEDQQAMAQsgBUEEdkH//w9xIgNBgIAISw0DIAEtAARBCnQgBUEWdnIhBEEFIQZBAAshBSAEIAZqIgogAksNAgJAIANBgQZJDQAgACgCnOIBRQ0AQQAhAgNAIAJBg4ABSw0BIAJBQGshAgwAAAsACwJ/IAlBA0YEQCABIAZqIQEgAEHw4gFqIQIgACgCDCEGIAUEQCACIAMgASAEIAYQXwwCCyACIAMgASAEIAYQXQwBCyAAQbjQAWohAiABIAZqIQEgAEHw4gFqIQYgAEGo0ABqIQggBQRAIAggBiADIAEgBCACEF4MAQsgCCAGIAMgASAEIAIQXAsQAw0CIAAgAzYCgOIBIABBATYCiOEBIAAgAEHw4gFqNgLw4QEgCUECRgRAIAAgAEGo0ABqNgIMCyAAIANqIgBBiOMBakIANwAAIABBgOMBakIANwAAIABB+OIBakIANwAAIABB8OIBakIANwAAIAoPCwJ/AkACQAJAIANBAnZBA3FBf2oiBEECSw0AIARBAWsOAgACAQtBASEEIANBA3YMAgtBAiEEIAEvAABBBHYMAQtBAyEEIAEQIUEEdgsiAyAEaiIFQSBqIAJLBEAgBSACSw0CIABB8OIBaiABIARqIAMQCyEBIAAgAzYCgOIBIAAgATYC8OEBIAEgA2oiAEIANwAYIABCADcAECAAQgA3AAggAEIANwAAIAUPCyAAIAM2AoDiASAAIAEgBGo2AvDhASAFDwsCfwJAAkACQCADQQJ2QQNxQX9qIgRBAksNACAEQQFrDgIAAgELQQEhByADQQN2DAILQQIhByABLwAAQQR2DAELIAJBBEkgARAhIgJBj4CAAUtyDQFBAyEHIAJBBHYLIQIgAEHw4gFqIAEgB2otAAAgAkEgahAQIQEgACACNgKA4gEgACABNgLw4QEgB0EBaiEHCyAHC0sAIABC+erQ0OfJoeThADcDICAAQgA3AxggAELP1tO+0ser2UI3AxAgAELW64Lu6v2J9eAANwMIIABCADcDACAAQShqQQBBKBAQGgviAgICfwV+IABBKGoiASAAKAJIaiECAn4gACkDACIDQiBaBEAgACkDECIEQgeJIAApAwgiBUIBiXwgACkDGCIGQgyJfCAAKQMgIgdCEol8IAUQGSAEEBkgBhAZIAcQGQwBCyAAKQMYQsXP2bLx5brqJ3wLIAN8IQMDQCABQQhqIgAgAk0EQEIAIAEpAAAQCSADhUIbiUKHla+vmLbem55/fkLj3MqV/M7y9YV/fCEDIAAhAQwBCwsCQCABQQRqIgAgAksEQCABIQAMAQsgASgAAK1Ch5Wvr5i23puef34gA4VCF4lCz9bTvtLHq9lCfkL5893xmfaZqxZ8IQMLA0AgACACSQRAIAAxAABCxc/ZsvHluuonfiADhUILiUKHla+vmLbem55/fiEDIABBAWohAAwBCwsgA0IhiCADhULP1tO+0ser2UJ+IgNCHYggA4VC+fPd8Zn2masWfiIDQiCIIAOFC+8CAgJ/BH4gACAAKQMAIAKtfDcDAAJAAkAgACgCSCIDIAJqIgRBH00EQCABRQ0BIAAgA2pBKGogASACECAgACgCSCACaiEEDAELIAEgAmohAgJ/IAMEQCAAQShqIgQgA2ogAUEgIANrECAgACAAKQMIIAQpAAAQCTcDCCAAIAApAxAgACkAMBAJNwMQIAAgACkDGCAAKQA4EAk3AxggACAAKQMgIABBQGspAAAQCTcDICAAKAJIIQMgAEEANgJIIAEgA2tBIGohAQsgAUEgaiACTQsEQCACQWBqIQMgACkDICEFIAApAxghBiAAKQMQIQcgACkDCCEIA0AgCCABKQAAEAkhCCAHIAEpAAgQCSEHIAYgASkAEBAJIQYgBSABKQAYEAkhBSABQSBqIgEgA00NAAsgACAFNwMgIAAgBjcDGCAAIAc3AxAgACAINwMICyABIAJPDQEgAEEoaiABIAIgAWsiBBAgCyAAIAQ2AkgLCy8BAX8gAEUEQEG2f0EAIAMbDwtBun8hBCADIAFNBH8gACACIAMQEBogAwVBun8LCy8BAX8gAEUEQEG2f0EAIAMbDwtBun8hBCADIAFNBH8gACACIAMQCxogAwVBun8LC6gCAQZ/IwBBEGsiByQAIABB2OABaikDAEKAgIAQViEIQbh/IQUCQCAEQf//B0sNACAAIAMgBBBCIgUQAyIGDQAgACgCnOIBIQkgACAHQQxqIAMgAyAFaiAGGyIKIARBACAFIAYbayIGEEAiAxADBEAgAyEFDAELIAcoAgwhBCABRQRAQbp/IQUgBEEASg0BCyAGIANrIQUgAyAKaiEDAkAgCQRAIABBADYCnOIBDAELAkACQAJAIARBBUgNACAAQdjgAWopAwBCgICACFgNAAwBCyAAQQA2ApziAQwBCyAAKAIIED8hBiAAQQA2ApziASAGQRRPDQELIAAgASACIAMgBSAEIAgQOSEFDAELIAAgASACIAMgBSAEIAgQOiEFCyAHQRBqJAAgBQtnACAAQdDgAWogASACIAAoAuzhARAuIgEQAwRAIAEPC0G4fyECAkAgAQ0AIABB7OABaigCACIBBEBBYCECIAAoApjiASABRw0BC0EAIQIgAEHw4AFqKAIARQ0AIABBkOEBahBDCyACCycBAX8QVyIERQRAQUAPCyAEIAAgASACIAMgBBBLEE8hACAEEFYgAAs/AQF/AkACQAJAIAAoAqDiAUEBaiIBQQJLDQAgAUEBaw4CAAECCyAAEDBBAA8LIABBADYCoOIBCyAAKAKU4gELvAMCB38BfiMAQRBrIgkkAEG4fyEGAkAgBCgCACIIQQVBCSAAKALs4QEiBRtJDQAgAygCACIHQQFBBSAFGyAFEC8iBRADBEAgBSEGDAELIAggBUEDakkNACAAIAcgBRBJIgYQAw0AIAEgAmohCiAAQZDhAWohCyAIIAVrIQIgBSAHaiEHIAEhBQNAIAcgAiAJECwiBhADDQEgAkF9aiICIAZJBEBBuH8hBgwCCyAJKAIAIghBAksEQEFsIQYMAgsgB0EDaiEHAn8CQAJAAkAgCEEBaw4CAgABCyAAIAUgCiAFayAHIAYQSAwCCyAFIAogBWsgByAGEEcMAQsgBSAKIAVrIActAAAgCSgCCBBGCyIIEAMEQCAIIQYMAgsgACgC8OABBEAgCyAFIAgQRQsgAiAGayECIAYgB2ohByAFIAhqIQUgCSgCBEUNAAsgACkD0OABIgxCf1IEQEFsIQYgDCAFIAFrrFINAQsgACgC8OABBEBBaiEGIAJBBEkNASALEEQhDCAHKAAAIAynRw0BIAdBBGohByACQXxqIQILIAMgBzYCACAEIAI2AgAgBSABayEGCyAJQRBqJAAgBgsuACAAECsCf0EAQQAQAw0AGiABRSACRXJFBEBBYiAAIAEgAhA9EAMNARoLQQALCzcAIAEEQCAAIAAoAsTgASABKAIEIAEoAghqRzYCnOIBCyAAECtBABADIAFFckUEQCAAIAEQWwsL0QIBB38jAEEQayIGJAAgBiAENgIIIAYgAzYCDCAFBEAgBSgCBCEKIAUoAgghCQsgASEIAkACQANAIAAoAuzhARAWIQsCQANAIAQgC0kNASADKAAAQXBxQdDUtMIBRgRAIAMgBBAiIgcQAw0EIAQgB2shBCADIAdqIQMMAQsLIAYgAzYCDCAGIAQ2AggCQCAFBEAgACAFEE5BACEHQQAQA0UNAQwFCyAAIAogCRBNIgcQAw0ECyAAIAgQUCAMQQFHQQAgACAIIAIgBkEMaiAGQQhqEEwiByIDa0EAIAMQAxtBCkdyRQRAQbh/IQcMBAsgBxADDQMgAiAHayECIAcgCGohCEEBIQwgBigCDCEDIAYoAgghBAwBCwsgBiADNgIMIAYgBDYCCEG4fyEHIAQNASAIIAFrIQcMAQsgBiADNgIMIAYgBDYCCAsgBkEQaiQAIAcLRgECfyABIAAoArjgASICRwRAIAAgAjYCxOABIAAgATYCuOABIAAoArzgASEDIAAgATYCvOABIAAgASADIAJrajYCwOABCwutAgIEfwF+IwBBQGoiBCQAAkACQCACQQhJDQAgASgAAEFwcUHQ1LTCAUcNACABIAIQIiEBIABCADcDCCAAQQA2AgQgACABNgIADAELIARBGGogASACEC0iAxADBEAgACADEBoMAQsgAwRAIABBuH8QGgwBCyACIAQoAjAiA2shAiABIANqIQMDQAJAIAAgAyACIARBCGoQLCIFEAMEfyAFBSACIAVBA2oiBU8NAUG4fwsQGgwCCyAGQQFqIQYgAiAFayECIAMgBWohAyAEKAIMRQ0ACyAEKAI4BEAgAkEDTQRAIABBuH8QGgwCCyADQQRqIQMLIAQoAighAiAEKQMYIQcgAEEANgIEIAAgAyABazYCACAAIAIgBmytIAcgB0J/URs3AwgLIARBQGskAAslAQF/IwBBEGsiAiQAIAIgACABEFEgAigCACEAIAJBEGokACAAC30BBH8jAEGQBGsiBCQAIARB/wE2AggCQCAEQRBqIARBCGogBEEMaiABIAIQFSIGEAMEQCAGIQUMAQtBVCEFIAQoAgwiB0EGSw0AIAMgBEEQaiAEKAIIIAcQQSIFEAMNACAAIAEgBmogAiAGayADEDwhBQsgBEGQBGokACAFC4cBAgJ/An5BABAWIQMCQANAIAEgA08EQAJAIAAoAABBcHFB0NS0wgFGBEAgACABECIiAhADRQ0BQn4PCyAAIAEQVSIEQn1WDQMgBCAFfCIFIARUIQJCfiEEIAINAyAAIAEQUiICEAMNAwsgASACayEBIAAgAmohAAwBCwtCfiAFIAEbIQQLIAQLPwIBfwF+IwBBMGsiAiQAAn5CfiACQQhqIAAgARAtDQAaQgAgAigCHEEBRg0AGiACKQMICyEDIAJBMGokACADC40BAQJ/IwBBMGsiASQAAkAgAEUNACAAKAKI4gENACABIABB/OEBaigCADYCKCABIAApAvThATcDICAAEDAgACgCqOIBIQIgASABKAIoNgIYIAEgASkDIDcDECACIAFBEGoQGyAAQQA2AqjiASABIAEoAig2AgggASABKQMgNwMAIAAgARAbCyABQTBqJAALKgECfyMAQRBrIgAkACAAQQA2AgggAEIANwMAIAAQWCEBIABBEGokACABC4cBAQN/IwBBEGsiAiQAAkAgACgCAEUgACgCBEVzDQAgAiAAKAIINgIIIAIgACkCADcDAAJ/IAIoAgAiAQRAIAIoAghBqOMJIAERBQAMAQtBqOMJECgLIgFFDQAgASAAKQIANwL04QEgAUH84QFqIAAoAgg2AgAgARBZIAEhAwsgAkEQaiQAIAMLywEBAn8jAEEgayIBJAAgAEGBgIDAADYCtOIBIABBADYCiOIBIABBADYC7OEBIABCADcDkOIBIABBADYCpOMJIABBADYC3OIBIABCADcCzOIBIABBADYCvOIBIABBADYCxOABIABCADcCnOIBIABBpOIBakIANwIAIABBrOIBakEANgIAIAFCADcCECABQgA3AhggASABKQMYNwMIIAEgASkDEDcDACABKAIIQQh2QQFxIQIgAEEANgLg4gEgACACNgKM4gEgAUEgaiQAC3YBA38jAEEwayIBJAAgAARAIAEgAEHE0AFqIgIoAgA2AiggASAAKQK80AE3AyAgACgCACEDIAEgAigCADYCGCABIAApArzQATcDECADIAFBEGoQGyABIAEoAig2AgggASABKQMgNwMAIAAgARAbCyABQTBqJAALzAEBAX8gACABKAK00AE2ApjiASAAIAEoAgQiAjYCwOABIAAgAjYCvOABIAAgAiABKAIIaiICNgK44AEgACACNgLE4AEgASgCuNABBEAgAEKBgICAEDcDiOEBIAAgAUGk0ABqNgIMIAAgAUGUIGo2AgggACABQZwwajYCBCAAIAFBDGo2AgAgAEGs0AFqIAFBqNABaigCADYCACAAQbDQAWogAUGs0AFqKAIANgIAIABBtNABaiABQbDQAWooAgA2AgAPCyAAQgA3A4jhAQs7ACACRQRAQbp/DwsgBEUEQEFsDwsgAiAEEGAEQCAAIAEgAiADIAQgBRBhDwsgACABIAIgAyAEIAUQZQtGAQF/IwBBEGsiBSQAIAVBCGogBBAOAn8gBS0ACQRAIAAgASACIAMgBBAyDAELIAAgASACIAMgBBA0CyEAIAVBEGokACAACzQAIAAgAyAEIAUQNiIFEAMEQCAFDwsgBSAESQR/IAEgAiADIAVqIAQgBWsgABA1BUG4fwsLRgEBfyMAQRBrIgUkACAFQQhqIAQQDgJ/IAUtAAkEQCAAIAEgAiADIAQQYgwBCyAAIAEgAiADIAQQNQshACAFQRBqJAAgAAtZAQF/QQ8hAiABIABJBEAgAUEEdCAAbiECCyAAQQh2IgEgAkEYbCIAQYwIaigCAGwgAEGICGooAgBqIgJBA3YgAmogAEGACGooAgAgAEGECGooAgAgAWxqSQs3ACAAIAMgBCAFQYAQEDMiBRADBEAgBQ8LIAUgBEkEfyABIAIgAyAFaiAEIAVrIAAQMgVBuH8LC78DAQN/IwBBIGsiBSQAIAVBCGogAiADEAYiAhADRQRAIAAgAWoiB0F9aiEGIAUgBBAOIARBBGohAiAFLQACIQMDQEEAIAAgBkkgBUEIahAEGwRAIAAgAiAFQQhqIAMQAkECdGoiBC8BADsAACAFQQhqIAQtAAIQASAAIAQtAANqIgQgAiAFQQhqIAMQAkECdGoiAC8BADsAACAFQQhqIAAtAAIQASAEIAAtAANqIQAMAQUgB0F+aiEEA0AgBUEIahAEIAAgBEtyRQRAIAAgAiAFQQhqIAMQAkECdGoiBi8BADsAACAFQQhqIAYtAAIQASAAIAYtAANqIQAMAQsLA0AgACAES0UEQCAAIAIgBUEIaiADEAJBAnRqIgYvAQA7AAAgBUEIaiAGLQACEAEgACAGLQADaiEADAELCwJAIAAgB08NACAAIAIgBUEIaiADEAIiA0ECdGoiAC0AADoAACAALQADQQFGBEAgBUEIaiAALQACEAEMAQsgBSgCDEEfSw0AIAVBCGogAiADQQJ0ai0AAhABIAUoAgxBIUkNACAFQSA2AgwLIAFBbCAFQQhqEAobIQILCwsgBUEgaiQAIAILkgIBBH8jAEFAaiIJJAAgCSADQTQQCyEDAkAgBEECSA0AIAMgBEECdGooAgAhCSADQTxqIAgQIyADQQE6AD8gAyACOgA+QQAhBCADKAI8IQoDQCAEIAlGDQEgACAEQQJ0aiAKNgEAIARBAWohBAwAAAsAC0EAIQkDQCAGIAlGRQRAIAMgBSAJQQF0aiIKLQABIgtBAnRqIgwoAgAhBCADQTxqIAotAABBCHQgCGpB//8DcRAjIANBAjoAPyADIAcgC2siCiACajoAPiAEQQEgASAKa3RqIQogAygCPCELA0AgACAEQQJ0aiALNgEAIARBAWoiBCAKSQ0ACyAMIAo2AgAgCUEBaiEJDAELCyADQUBrJAALowIBCX8jAEHQAGsiCSQAIAlBEGogBUE0EAsaIAcgBmshDyAHIAFrIRADQAJAIAMgCkcEQEEBIAEgByACIApBAXRqIgYtAAEiDGsiCGsiC3QhDSAGLQAAIQ4gCUEQaiAMQQJ0aiIMKAIAIQYgCyAPTwRAIAAgBkECdGogCyAIIAUgCEE0bGogCCAQaiIIQQEgCEEBShsiCCACIAQgCEECdGooAgAiCEEBdGogAyAIayAHIA4QYyAGIA1qIQgMAgsgCUEMaiAOECMgCUEBOgAPIAkgCDoADiAGIA1qIQggCSgCDCELA0AgBiAITw0CIAAgBkECdGogCzYBACAGQQFqIQYMAAALAAsgCUHQAGokAA8LIAwgCDYCACAKQQFqIQoMAAALAAs0ACAAIAMgBCAFEDYiBRADBEAgBQ8LIAUgBEkEfyABIAIgAyAFaiAEIAVrIAAQNAVBuH8LCyMAIAA/AEEQdGtB//8DakEQdkAAQX9GBEBBAA8LQQAQAEEBCzsBAX8gAgRAA0AgACABIAJBgCAgAkGAIEkbIgMQCyEAIAFBgCBqIQEgAEGAIGohACACIANrIgINAAsLCwYAIAAQAwsLqBUJAEGICAsNAQAAAAEAAAACAAAAAgBBoAgLswYBAAAAAQAAAAIAAAACAAAAJgAAAIIAAAAhBQAASgAAAGcIAAAmAAAAwAEAAIAAAABJBQAASgAAAL4IAAApAAAALAIAAIAAAABJBQAASgAAAL4IAAAvAAAAygIAAIAAAACKBQAASgAAAIQJAAA1AAAAcwMAAIAAAACdBQAASgAAAKAJAAA9AAAAgQMAAIAAAADrBQAASwAAAD4KAABEAAAAngMAAIAAAABNBgAASwAAAKoKAABLAAAAswMAAIAAAADBBgAATQAAAB8NAABNAAAAUwQAAIAAAAAjCAAAUQAAAKYPAABUAAAAmQQAAIAAAABLCQAAVwAAALESAABYAAAA2gQAAIAAAABvCQAAXQAAACMUAABUAAAARQUAAIAAAABUCgAAagAAAIwUAABqAAAArwUAAIAAAAB2CQAAfAAAAE4QAAB8AAAA0gIAAIAAAABjBwAAkQAAAJAHAACSAAAAAAAAAAEAAAABAAAABQAAAA0AAAAdAAAAPQAAAH0AAAD9AAAA/QEAAP0DAAD9BwAA/Q8AAP0fAAD9PwAA/X8AAP3/AAD9/wEA/f8DAP3/BwD9/w8A/f8fAP3/PwD9/38A/f//AP3//wH9//8D/f//B/3//w/9//8f/f//P/3//38AAAAAAQAAAAIAAAADAAAABAAAAAUAAAAGAAAABwAAAAgAAAAJAAAACgAAAAsAAAAMAAAADQAAAA4AAAAPAAAAEAAAABEAAAASAAAAEwAAABQAAAAVAAAAFgAAABcAAAAYAAAAGQAAABoAAAAbAAAAHAAAAB0AAAAeAAAAHwAAAAMAAAAEAAAABQAAAAYAAAAHAAAACAAAAAkAAAAKAAAACwAAAAwAAAANAAAADgAAAA8AAAAQAAAAEQAAABIAAAATAAAAFAAAABUAAAAWAAAAFwAAABgAAAAZAAAAGgAAABsAAAAcAAAAHQAAAB4AAAAfAAAAIAAAACEAAAAiAAAAIwAAACUAAAAnAAAAKQAAACsAAAAvAAAAMwAAADsAAABDAAAAUwAAAGMAAACDAAAAAwEAAAMCAAADBAAAAwgAAAMQAAADIAAAA0AAAAOAAAADAAEAQeAPC1EBAAAAAQAAAAEAAAABAAAAAgAAAAIAAAADAAAAAwAAAAQAAAAEAAAABQAAAAcAAAAIAAAACQAAAAoAAAALAAAADAAAAA0AAAAOAAAADwAAABAAQcQQC4sBAQAAAAIAAAADAAAABAAAAAUAAAAGAAAABwAAAAgAAAAJAAAACgAAAAsAAAAMAAAADQAAAA4AAAAPAAAAEAAAABIAAAAUAAAAFgAAABgAAAAcAAAAIAAAACgAAAAwAAAAQAAAAIAAAAAAAQAAAAIAAAAEAAAACAAAABAAAAAgAAAAQAAAAIAAAAAAAQBBkBIL5gQBAAAAAQAAAAEAAAABAAAAAgAAAAIAAAADAAAAAwAAAAQAAAAGAAAABwAAAAgAAAAJAAAACgAAAAsAAAAMAAAADQAAAA4AAAAPAAAAEAAAAAEAAAAEAAAACAAAAAAAAAABAAEBBgAAAAAAAAQAAAAAEAAABAAAAAAgAAAFAQAAAAAAAAUDAAAAAAAABQQAAAAAAAAFBgAAAAAAAAUHAAAAAAAABQkAAAAAAAAFCgAAAAAAAAUMAAAAAAAABg4AAAAAAAEFEAAAAAAAAQUUAAAAAAABBRYAAAAAAAIFHAAAAAAAAwUgAAAAAAAEBTAAAAAgAAYFQAAAAAAABwWAAAAAAAAIBgABAAAAAAoGAAQAAAAADAYAEAAAIAAABAAAAAAAAAAEAQAAAAAAAAUCAAAAIAAABQQAAAAAAAAFBQAAACAAAAUHAAAAAAAABQgAAAAgAAAFCgAAAAAAAAULAAAAAAAABg0AAAAgAAEFEAAAAAAAAQUSAAAAIAABBRYAAAAAAAIFGAAAACAAAwUgAAAAAAADBSgAAAAAAAYEQAAAABAABgRAAAAAIAAHBYAAAAAAAAkGAAIAAAAACwYACAAAMAAABAAAAAAQAAAEAQAAACAAAAUCAAAAIAAABQMAAAAgAAAFBQAAACAAAAUGAAAAIAAABQgAAAAgAAAFCQAAACAAAAULAAAAIAAABQwAAAAAAAAGDwAAACAAAQUSAAAAIAABBRQAAAAgAAIFGAAAACAAAgUcAAAAIAADBSgAAAAgAAQFMAAAAAAAEAYAAAEAAAAPBgCAAAAAAA4GAEAAAAAADQYAIABBgBcLhwIBAAEBBQAAAAAAAAUAAAAAAAAGBD0AAAAAAAkF/QEAAAAADwX9fwAAAAAVBf3/HwAAAAMFBQAAAAAABwR9AAAAAAAMBf0PAAAAABIF/f8DAAAAFwX9/38AAAAFBR0AAAAAAAgE/QAAAAAADgX9PwAAAAAUBf3/DwAAAAIFAQAAABAABwR9AAAAAAALBf0HAAAAABEF/f8BAAAAFgX9/z8AAAAEBQ0AAAAQAAgE/QAAAAAADQX9HwAAAAATBf3/BwAAAAEFAQAAABAABgQ9AAAAAAAKBf0DAAAAABAF/f8AAAAAHAX9//8PAAAbBf3//wcAABoF/f//AwAAGQX9//8BAAAYBf3//wBBkBkLhgQBAAEBBgAAAAAAAAYDAAAAAAAABAQAAAAgAAAFBQAAAAAAAAUGAAAAAAAABQgAAAAAAAAFCQAAAAAAAAULAAAAAAAABg0AAAAAAAAGEAAAAAAAAAYTAAAAAAAABhYAAAAAAAAGGQAAAAAAAAYcAAAAAAAABh8AAAAAAAAGIgAAAAAAAQYlAAAAAAABBikAAAAAAAIGLwAAAAAAAwY7AAAAAAAEBlMAAAAAAAcGgwAAAAAACQYDAgAAEAAABAQAAAAAAAAEBQAAACAAAAUGAAAAAAAABQcAAAAgAAAFCQAAAAAAAAUKAAAAAAAABgwAAAAAAAAGDwAAAAAAAAYSAAAAAAAABhUAAAAAAAAGGAAAAAAAAAYbAAAAAAAABh4AAAAAAAAGIQAAAAAAAQYjAAAAAAABBicAAAAAAAIGKwAAAAAAAwYzAAAAAAAEBkMAAAAAAAUGYwAAAAAACAYDAQAAIAAABAQAAAAwAAAEBAAAABAAAAQFAAAAIAAABQcAAAAgAAAFCAAAACAAAAUKAAAAIAAABQsAAAAAAAAGDgAAAAAAAAYRAAAAAAAABhQAAAAAAAAGFwAAAAAAAAYaAAAAAAAABh0AAAAAAAAGIAAAAAAAEAYDAAEAAAAPBgOAAAAAAA4GA0AAAAAADQYDIAAAAAAMBgMQAAAAAAsGAwgAAAAACgYDBABBpB0L2QEBAAAAAwAAAAcAAAAPAAAAHwAAAD8AAAB/AAAA/wAAAP8BAAD/AwAA/wcAAP8PAAD/HwAA/z8AAP9/AAD//wAA//8BAP//AwD//wcA//8PAP//HwD//z8A//9/AP///wD///8B////A////wf///8P////H////z////9/AAAAAAEAAAACAAAABAAAAAAAAAACAAAABAAAAAgAAAAAAAAAAQAAAAIAAAABAAAABAAAAAQAAAAEAAAABAAAAAgAAAAIAAAACAAAAAcAAAAIAAAACQAAAAoAAAALAEGgIAsDwBBQ",qBr="display-p3",zBr="display-p3-linear";({...oZ.spaces[hv]});const f7e=new WeakMap;let d7e=0,p7e;class gw extends Qqe{constructor(r){super(r),this.transcoderPath="",this.transcoderBinary=null,this.transcoderPending=null,this.workerPool=new NBr,this.workerSourceURL="",this.workerConfig=null,typeof MSC_TRANSCODER<"u"&&console.warn('THREE.KTX2Loader: Please update to latest "basis_transcoder". "msc_basis_transcoder" is no longer supported in three.js r125+.')}setTranscoderPath(r){return this.transcoderPath=r,this}setWorkerLimit(r){return this.workerPool.setWorkerLimit(r),this}async detectSupportAsync(r){return this.workerConfig={astcSupported:await r.hasFeatureAsync("texture-compression-astc"),astcHDRSupported:!1,etc1Supported:await r.hasFeatureAsync("texture-compression-etc2"),etc2Supported:await r.hasFeatureAsync("texture-compression-etc2"),dxtSupported:await r.hasFeatureAsync("texture-compression-bc"),bptcSupported:await r.hasFeatureAsync("texture-compression-bc"),pvrtcSupported:await r.hasFeatureAsync("texture-compression-pvrtc")},this}detectSupport(r){return r.isWebGPURenderer===!0?this.workerConfig={astcSupported:r.hasFeature("texture-compression-astc"),astcHDRSupported:!1,etc1Supported:r.hasFeature("texture-compression-etc2"),etc2Supported:r.hasFeature("texture-compression-etc2"),dxtSupported:r.hasFeature("texture-compression-bc"),bptcSupported:r.hasFeature("texture-compression-bc"),pvrtcSupported:r.hasFeature("texture-compression-pvrtc")}:this.workerConfig={astcSupported:r.extensions.has("WEBGL_compressed_texture_astc"),astcHDRSupported:r.extensions.has("WEBGL_compressed_texture_astc")&&r.extensions.get("WEBGL_compressed_texture_astc").getSupportedProfiles().includes("hdr"),etc1Supported:r.extensions.has("WEBGL_compressed_texture_etc1"),etc2Supported:r.extensions.has("WEBGL_compressed_texture_etc"),dxtSupported:r.extensions.has("WEBGL_compressed_texture_s3tc"),bptcSupported:r.extensions.has("EXT_texture_compression_bptc"),pvrtcSupported:r.extensions.has("WEBGL_compressed_texture_pvrtc")||r.extensions.has("WEBKIT_WEBGL_compressed_texture_pvrtc")},this}init(){if(!this.transcoderPending){const r=new TR(this.manager);r.setPath(this.transcoderPath),r.setWithCredentials(this.withCredentials);const i=r.loadAsync("basis_transcoder.js"),a=new TR(this.manager);a.setPath(this.transcoderPath),a.setResponseType("arraybuffer"),a.setWithCredentials(this.withCredentials);const l=a.loadAsync("basis_transcoder.wasm");this.transcoderPending=Promise.all([i,l]).then(([d,_])=>{const g=gw.BasisWorker.toString(),b=["/* constants */","let _EngineFormat = "+JSON.stringify(gw.EngineFormat),"let _EngineType = "+JSON.stringify(gw.EngineType),"let _TranscoderFormat = "+JSON.stringify(gw.TranscoderFormat),"let _BasisFormat = "+JSON.stringify(gw.BasisFormat),"/* basis_transcoder.js */",d,"/* worker */",g.substring(g.indexOf("{")+1,g.lastIndexOf("}"))].join(`
|
|
73
|
-
`);this.workerSourceURL=URL.createObjectURL(new Blob([b])),this.transcoderBinary=_,this.workerPool.setWorkerCreator(()=>{const S=new Worker(this.workerSourceURL),k=this.transcoderBinary.slice(0);return S.postMessage({type:"init",config:this.workerConfig,transcoderBinary:k},[k]),S})}),d7e>0&&console.warn("THREE.KTX2Loader: Multiple active KTX2 loaders may cause performance issues. Use a single KTX2Loader instance, or call .dispose() on old instances."),d7e++}return this.transcoderPending}load(r,i,a,l){if(this.workerConfig===null)throw new Error("THREE.KTX2Loader: Missing initialization with `.detectSupport( renderer )`.");const d=new TR(this.manager);d.setPath(this.path),d.setCrossOrigin(this.crossOrigin),d.setWithCredentials(this.withCredentials),d.setResponseType("arraybuffer"),d.load(r,_=>{this.parse(_,i,l)},a,l)}parse(r,i,a){if(this.workerConfig===null)throw new Error("THREE.KTX2Loader: Missing initialization with `.detectSupport( renderer )`.");if(f7e.has(r))return f7e.get(r).promise.then(i).catch(a);this._createTexture(r).then(l=>i?i(l):null).catch(a)}_createTextureFrom(r,i){const{type:a,error:l,data:{faces:d,width:_,height:g,format:b,type:S,dfdFlags:k}}=r;if(a==="error")return Promise.reject(l);let w;if(i.faceCount===6)w=new tIr(d,b,S);else{const N=d[0].mipmaps;w=i.layerCount>1?new rIr(N,_,g,i.layerCount,b,S):new Tkt(N,_,g,b,S)}return w.minFilter=d[0].mipmaps.length===1?zR:jye,w.magFilter=zR,w.generateMipmaps=!1,w.needsUpdate=!0,w.colorSpace=M6t(i),w.premultiplyAlpha=!!(k&FBr),w}async _createTexture(r,i={}){const a=BBr(new Uint8Array(r)),l=a.vkFormat===FUe&&a.dataFormatDescriptor[0].colorModel===167;if(!(a.vkFormat===jBr||l&&!this.workerConfig.astcHDRSupported))return VBr(a);const _=i,g=this.init().then(()=>this.workerPool.postMessage({type:"transcode",buffer:r,taskConfig:_},[r])).then(b=>this._createTextureFrom(b.data,a));return f7e.set(r,{promise:g}),g}dispose(){this.workerPool.dispose(),this.workerSourceURL&&URL.revokeObjectURL(this.workerSourceURL),d7e--}}gw.BasisFormat={ETC1S:0,UASTC:1,UASTC_HDR:2};gw.TranscoderFormat={ETC1:0,ETC2:1,BC1:2,BC3:3,BC4:4,BC5:5,BC7_M6_OPAQUE_ONLY:6,BC7_M5:7,PVRTC1_4_RGB:8,PVRTC1_4_RGBA:9,ASTC_4x4:10,ATC_RGB:11,ATC_RGBA_INTERPOLATED_ALPHA:12,RGBA32:13,RGB565:14,BGR565:15,RGBA4444:16,BC6H:22,RGB_HALF:24,RGBA_HALF:25};gw.EngineFormat={RGBAFormat:dq,RGBA_ASTC_4x4_Format:M_e,RGB_BPTC_UNSIGNED_Format:dIr,RGBA_BPTC_Format:b9e,RGBA_ETC2_EAC_Format:Ikt,RGBA_PVRTC_4BPPV1_Format:v9e,RGBA_S3TC_DXT5_Format:fIr,RGB_ETC1_Format:uIr,RGB_ETC2_Format:kkt,RGB_PVRTC_4BPPV1_Format:lIr,RGBA_S3TC_DXT1_Format:A9e};gw.EngineType={UnsignedByteType:Bp,HalfFloatType:QN,FloatType:vX};gw.BasisWorker=function(){let t,r,i;const a=_EngineFormat,l=_EngineType,d=_TranscoderFormat,_=_BasisFormat;self.addEventListener("message",function(j){const J=j.data;switch(J.type){case"init":t=J.config,g(J.transcoderBinary);break;case"transcode":r.then(()=>{try{const{faces:X,buffers:G,width:ee,height:xe,hasAlpha:ue,format:fe,type:se,dfdFlags:de}=b(J.buffer);self.postMessage({type:"transcode",id:J.id,data:{faces:X,width:ee,height:xe,hasAlpha:ue,format:fe,type:se,dfdFlags:de}},G)}catch(X){console.error(X),self.postMessage({type:"error",id:J.id,error:X.message})}});break}});function g(j){r=new Promise(J=>{i={wasmBinary:j,onRuntimeInitialized:J},BASIS(i)}).then(()=>{i.initializeBasis(),i.KTX2File===void 0&&console.warn("THREE.KTX2Loader: Please update Basis Universal transcoder.")})}function b(j){const J=new i.KTX2File(new Uint8Array(j));function X(){J.close(),J.delete()}if(!J.isValid())throw X(),new Error("THREE.KTX2Loader: Invalid or unsupported .ktx2 file");let G;if(J.isUASTC())G=_.UASTC;else if(J.isETC1S())G=_.ETC1S;else if(J.isHDR())G=_.UASTC_HDR;else throw new Error("THREE.KTX2Loader: Unknown Basis encoding");const ee=J.getWidth(),xe=J.getHeight(),ue=J.getLayers()||1,fe=J.getLevels(),se=J.getFaces(),de=J.getHasAlpha(),ge=J.getDFDFlags(),{transcoderFormat:qe,engineFormat:tt,engineType:Ct}=w(G,ee,xe,de);if(!ee||!xe||!fe)throw X(),new Error("THREE.KTX2Loader: Invalid texture");if(!J.startTranscoding())throw X(),new Error("THREE.KTX2Loader: .startTranscoding failed");const Ot=[],vt=[];for(let Et=0;Et<se;Et++){const Tt=[];for(let Le=0;Le<fe;Le++){const cr=[];let Yt,Lr;for(let on=0;on<ue;on++){const gr=J.getImageLevelInfo(Le,on,Et);Et===0&&Le===0&&on===0&&(gr.origWidth%4!==0||gr.origHeight%4!==0)&&console.warn("THREE.KTX2Loader: ETC1S and UASTC textures should use multiple-of-four dimensions."),fe>1?(Yt=gr.origWidth,Lr=gr.origHeight):(Yt=gr.width,Lr=gr.height);let An=new Uint8Array(J.getImageTranscodedSizeInBytes(Le,on,0,qe));const Rn=J.transcodeImage(An,Le,on,Et,qe,0,-1,-1);if(Ct===l.HalfFloatType&&(An=new Uint16Array(An.buffer,An.byteOffset,An.byteLength/Uint16Array.BYTES_PER_ELEMENT)),!Rn)throw X(),new Error("THREE.KTX2Loader: .transcodeImage failed.");cr.push(An)}const nn=P(cr);Tt.push({data:nn,width:Yt,height:Lr}),vt.push(nn.buffer)}Ot.push({mipmaps:Tt,width:ee,height:xe,format:tt,type:Ct})}return X(),{faces:Ot,buffers:vt,width:ee,height:xe,hasAlpha:de,dfdFlags:ge,format:tt,type:Ct}}const S=[{if:"astcSupported",basisFormat:[_.UASTC],transcoderFormat:[d.ASTC_4x4,d.ASTC_4x4],engineFormat:[a.RGBA_ASTC_4x4_Format,a.RGBA_ASTC_4x4_Format],engineType:[l.UnsignedByteType],priorityETC1S:1/0,priorityUASTC:1,needsPowerOfTwo:!1},{if:"bptcSupported",basisFormat:[_.ETC1S,_.UASTC],transcoderFormat:[d.BC7_M5,d.BC7_M5],engineFormat:[a.RGBA_BPTC_Format,a.RGBA_BPTC_Format],engineType:[l.UnsignedByteType],priorityETC1S:3,priorityUASTC:2,needsPowerOfTwo:!1},{if:"dxtSupported",basisFormat:[_.ETC1S,_.UASTC],transcoderFormat:[d.BC1,d.BC3],engineFormat:[a.RGBA_S3TC_DXT1_Format,a.RGBA_S3TC_DXT5_Format],engineType:[l.UnsignedByteType],priorityETC1S:4,priorityUASTC:5,needsPowerOfTwo:!1},{if:"etc2Supported",basisFormat:[_.ETC1S,_.UASTC],transcoderFormat:[d.ETC1,d.ETC2],engineFormat:[a.RGB_ETC2_Format,a.RGBA_ETC2_EAC_Format],engineType:[l.UnsignedByteType],priorityETC1S:1,priorityUASTC:3,needsPowerOfTwo:!1},{if:"etc1Supported",basisFormat:[_.ETC1S,_.UASTC],transcoderFormat:[d.ETC1],engineFormat:[a.RGB_ETC1_Format],engineType:[l.UnsignedByteType],priorityETC1S:2,priorityUASTC:4,needsPowerOfTwo:!1},{if:"pvrtcSupported",basisFormat:[_.ETC1S,_.UASTC],transcoderFormat:[d.PVRTC1_4_RGB,d.PVRTC1_4_RGBA],engineFormat:[a.RGB_PVRTC_4BPPV1_Format,a.RGBA_PVRTC_4BPPV1_Format],engineType:[l.UnsignedByteType],priorityETC1S:5,priorityUASTC:6,needsPowerOfTwo:!0},{if:"bptcSupported",basisFormat:[_.UASTC_HDR],transcoderFormat:[d.BC6H],engineFormat:[a.RGB_BPTC_UNSIGNED_Format],engineType:[l.HalfFloatType],priorityHDR:1,needsPowerOfTwo:!1},{basisFormat:[_.ETC1S,_.UASTC],transcoderFormat:[d.RGBA32,d.RGBA32],engineFormat:[a.RGBAFormat,a.RGBAFormat],engineType:[l.UnsignedByteType,l.UnsignedByteType],priorityETC1S:100,priorityUASTC:100,needsPowerOfTwo:!1},{basisFormat:[_.UASTC_HDR],transcoderFormat:[d.RGBA_HALF],engineFormat:[a.RGBAFormat],engineType:[l.HalfFloatType],priorityHDR:100,needsPowerOfTwo:!1}],k={[_.ETC1S]:S.filter(j=>j.basisFormat.includes(_.ETC1S)).sort((j,J)=>j.priorityUASTC-J.priorityUASTC),[_.UASTC]:S.filter(j=>j.basisFormat.includes(_.UASTC)).sort((j,J)=>j.priorityUASTC-J.priorityUASTC),[_.UASTC_HDR]:S.filter(j=>j.basisFormat.includes(_.UASTC_HDR)).sort((j,J)=>j.priorityHDR-J.priorityHDR)};function w(j,J,X,G){const ee=k[j];for(let xe=0;xe<ee.length;xe++){const ue=ee[xe];if(ue.if&&!t[ue.if]||!ue.basisFormat.includes(j)||G&&ue.transcoderFormat.length<2||ue.needsPowerOfTwo&&!(N(J)&&N(X)))continue;const fe=ue.transcoderFormat[G?1:0],se=ue.engineFormat[G?1:0],de=ue.engineType[0];return{transcoderFormat:fe,engineFormat:se,engineType:de}}throw new Error("THREE.KTX2Loader: Failed to identify transcoding target.")}function N(j){return j<=2?!0:(j&j-1)===0&&j!==0}function P(j){if(j.length===1)return j[0];let J=0;for(let ee=0;ee<j.length;ee++){const xe=j[ee];J+=xe.byteLength}const X=new Uint8Array(J);let G=0;for(let ee=0;ee<j.length;ee++){const xe=j[ee];X.set(xe,G),G+=xe.byteLength}return X}};const UBr=new Set([dq,S9e,LY,MY]),_7e={[u6t]:dq,[l6t]:LY,[c6t]:MY,[a6t]:dq,[o6t]:LY,[s6t]:MY,[i6t]:dq,[n6t]:dq,[r6t]:LY,[t6t]:LY,[e6t]:MY,[Z4t]:MY,[d6t]:S9e,[f6t]:S9e,[E6t]:Ikt,[C6t]:kkt,[FUe]:M_e,[k6t]:M_e,[T6t]:M_e,[R6t]:bFe,[D6t]:bFe,[I6t]:bFe,[h6t]:A9e,[m6t]:A9e,[_6t]:z1t,[p6t]:z1t,[y6t]:q1t,[g6t]:q1t,[b6t]:oIr,[v6t]:sIr,[S6t]:iIr,[A6t]:nIr,[w6t]:b9e,[x6t]:b9e,[F6t]:v9e,[N6t]:v9e,[O6t]:$1t,[P6t]:$1t},j$={[u6t]:vX,[l6t]:vX,[c6t]:vX,[a6t]:QN,[o6t]:QN,[s6t]:QN,[i6t]:Bp,[n6t]:Bp,[r6t]:Bp,[t6t]:Bp,[e6t]:Bp,[Z4t]:Bp,[d6t]:Pkt,[f6t]:Dkt,[E6t]:Bp,[C6t]:Bp,[FUe]:QN,[k6t]:Bp,[T6t]:Bp,[R6t]:QN,[D6t]:Bp,[I6t]:Bp,[h6t]:Bp,[m6t]:Bp,[_6t]:Bp,[p6t]:Bp,[y6t]:Bp,[g6t]:Bp,[b6t]:Bp,[v6t]:Bp,[S6t]:Bp,[A6t]:Bp,[w6t]:Bp,[x6t]:Bp,[F6t]:Bp,[N6t]:Bp,[O6t]:Bp,[P6t]:Bp};async function VBr(t){const{vkFormat:r}=t;if(_7e[r]===void 0)throw new Error("THREE.KTX2Loader: Unsupported vkFormat: "+r);j$[r]===void 0&&console.warn('THREE.KTX2Loader: Missing ".type" for vkFormat: '+r);let i;t.supercompressionScheme===A2t&&(p7e||(p7e=new Promise(async _=>{const g=new $Br;await g.init(),_(g)})),i=await p7e);const a=[];for(let _=0;_<t.levels.length;_++){const g=Math.max(1,t.pixelWidth>>_),b=Math.max(1,t.pixelHeight>>_),S=t.pixelDepth?Math.max(1,t.pixelDepth>>_):0,k=t.levels[_];let w;if(t.supercompressionScheme===OBr)w=k.levelData;else if(t.supercompressionScheme===A2t)w=i.decode(k.levelData,k.uncompressedByteLength);else throw new Error("THREE.KTX2Loader: Unsupported supercompressionScheme.");let N;j$[r]===vX?N=new Float32Array(w.buffer,w.byteOffset,w.byteLength/Float32Array.BYTES_PER_ELEMENT):j$[r]===QN?N=new Uint16Array(w.buffer,w.byteOffset,w.byteLength/Uint16Array.BYTES_PER_ELEMENT):j$[r]===Pkt||j$[r]===Dkt?N=new Uint32Array(w.buffer,w.byteOffset,w.byteLength/Uint32Array.BYTES_PER_ELEMENT):N=w,a.push({data:N,width:g,height:b,depth:S})}const l=t.levelCount===0||a.length>1;let d;if(UBr.has(_7e[r]))d=t.pixelDepth===0?new aIr(a[0].data,t.pixelWidth,t.pixelHeight):new cIr(a[0].data,t.pixelWidth,t.pixelHeight,t.pixelDepth),d.minFilter=l?gkt:ihe,d.magFilter=ihe,d.generateMipmaps=t.levelCount===0;else{if(t.pixelDepth>0)throw new Error("THREE.KTX2Loader: Unsupported pixelDepth.");d=new Tkt(a,t.pixelWidth,t.pixelHeight),d.minFilter=l?jye:zR,d.magFilter=zR}return d.mipmaps=a,d.type=j$[r],d.format=_7e[r],d.colorSpace=M6t(t),d.needsUpdate=!0,Promise.resolve(d)}function M6t(t){const r=t.dataFormatDescriptor[0];return r.colorPrimaries===MBr?r.transferFunction===S2t?hv:bE:r.colorPrimaries===LBr?r.transferFunction===S2t?qBr:zBr:r.colorPrimaries===RBr?B1t:(console.warn(`THREE.KTX2Loader: Unsupported color primaries, "${r.colorPrimaries}"`),B1t)}let JBr="/";function L6t(t){return t.startsWith("/")||t.startsWith("http")||t.startsWith("data:")||t.startsWith("blob:")?t:JBr+t}const Oee=new pIr;Oee.setURLModifier(L6t);new hkt(Oee);const j6t=new Qjr(Oee);j6t.setDecoderPath("/jsm/libs/draco/gltf/");const B6t=new gw(Oee);B6t.setTranscoderPath("/jsm/libs/basis/");const fU=new Yjr(Oee);fU.setDRACOLoader(j6t);fU.setKTX2Loader(B6t);fU.setMeshoptDecoder(Gjr);function Fee(t){return L6t(t)}const Vpe=new Map;async function $6t(t,r){let i=Vpe.get(t);!i&&r&&(i=Promise.resolve(r),Vpe.set(t,i)),i||(i=fetch(Fee(t)).then(async a=>{if(!a.ok)throw new Error(`Failed to load Gaussian splat: ${t} (${a.status} ${a.statusText})`);return new Uint8Array(await a.arrayBuffer())}),Vpe.set(t,i));try{const[{SplatMesh:a},l]=await Promise.all([Xo(()=>import("./spark.module-DVeR0ywZ.js"),__vite__mapDeps([45,6,3,2,4,1,8,9,10,11])),i]),d=new a({fileBytes:l,fileName:t,raycastable:!0});await d.initialized,CZ(d,"gaussianSplat",{src:t,numSplats:d.numSplats});const _=d.getBoundingBox();if(!_.isEmpty()){const g=_.getSize(new Tc).multiplyScalar(1.5),b=_.getCenter(new Tc),S=new NA(new fkt(g.x,g.y,g.z));S.name="__vgai_splat_bounds",S.position.copy(b),S.visible=!1,S.raycast=()=>{},CZ(S,"engineInternal",!0),d.add(S)}return d}catch(a){throw Vpe.delete(t),a}}const Zhe=1.2,q6t=.001;function pLe(t){const r=new Tc(Math.sin(t),0,Math.cos(t)),a=new Tc(0,1,0).clone().cross(r).normalize(),l=r.clone().cross(a).normalize();return{direction:r,right:a,up:l}}function z6t(){return{minRight:Number.POSITIVE_INFINITY,maxRight:Number.NEGATIVE_INFINITY,minUp:Number.POSITIVE_INFINITY,maxUp:Number.NEGATIVE_INFINITY,minDepth:Number.POSITIVE_INFINITY,maxDepth:Number.NEGATIVE_INFINITY}}function RUe(t){return t.maxRight<t.minRight}function WBr(t){t.minRight=Number.POSITIVE_INFINITY,t.maxRight=Number.NEGATIVE_INFINITY,t.minUp=Number.POSITIVE_INFINITY,t.maxUp=Number.NEGATIVE_INFINITY,t.minDepth=Number.POSITIVE_INFINITY,t.maxDepth=Number.NEGATIVE_INFINITY}function U6t(t,r,i){const a=r.dot(i.right),l=r.dot(i.up),d=r.dot(i.direction);a<t.minRight&&(t.minRight=a),a>t.maxRight&&(t.maxRight=a),l<t.minUp&&(t.minUp=l),l>t.maxUp&&(t.maxUp=l),d<t.minDepth&&(t.minDepth=d),d>t.maxDepth&&(t.maxDepth=d)}function HBr(t,r){if(RUe(t))throw new Error("Asset preview cannot frame an empty projected span.");return new Tc().addScaledVector(r.right,(t.minRight+t.maxRight)/2).addScaledVector(r.up,(t.minUp+t.maxUp)/2).addScaledVector(r.direction,(t.minDepth+t.maxDepth)/2)}function V6t(t,r,i,a=Zhe){const l=Math.max(r,t/i,q6t)*a;return{halfHeight:l,halfWidth:l*i}}function GBr(t,r,i=Zhe){if(RUe(t))throw new Error("Asset preview cannot frame an empty projected span.");return V6t((t.maxRight-t.minRight)/2,(t.maxUp-t.minUp)/2,r,i)}function QBr(t){if(t.length===0)throw new Error("Asset preview cannot union an empty set of frames.");let r=0,i=0;for(const a of t)r=Math.max(r,a.halfWidth),i=Math.max(i,a.halfHeight);return{halfWidth:r,halfHeight:i}}function KBr(t,r,i,a,l,d){const _=Math.max(a*l,q6t);let g=_,b=_;const S=new Tc;for(const k of t)S.copy(k).sub(r),g=Math.max(g,Math.abs(S.dot(i.right))+_),b=Math.max(b,Math.abs(S.dot(i.up))+_);return g=Math.max(g,b*d),b=Math.max(b,g/d),{halfWidth:g,halfHeight:b}}function YBr(t){if(t.length===0)throw new Error("Asset preview cannot centre a bone-zoom crop on zero anchors.");const r=new Tc;for(const i of t)r.add(i);return r.multiplyScalar(1/t.length)}function XBr(t,r){const i=t.position.dot(r.right),a=t.position.dot(r.up),l=t.position.dot(r.direction),d=t.zoom||1;return{minRight:i+t.left/d,maxRight:i+t.right/d,minUp:a+t.bottom/d,maxUp:a+t.top/d,minDepth:l-t.far,maxDepth:l-t.near}}function ZBr(t,r){return RUe(t)?!1:t.maxRight>=r.minRight&&t.minRight<=r.maxRight&&t.maxUp>=r.minUp&&t.minUp<=r.maxUp&&t.maxDepth>=r.minDepth&&t.minDepth<=r.maxDepth}function MUe(t,r,i,a,l){const d=new $ye(-i.halfWidth,i.halfWidth,i.halfHeight,-i.halfHeight,.01,l);return d.position.copy(t).addScaledVector(r.direction,a),d.up.copy(r.up),d.lookAt(t),d.updateProjectionMatrix(),d.updateMatrixWorld(!0),d}const e$r={F:["11111","10000","10000","11110","10000","10000","10000"],R:["11110","10001","10001","11110","10100","10010","10001"],O:["01110","10001","10001","10001","10001","10001","01110"],N:["10001","11001","11001","10101","10011","10011","10001"],T:["11111","00100","00100","00100","00100","00100","00100"],I:["11111","00100","00100","00100","00100","00100","11111"],G:["01110","10001","10000","10111","10001","10001","01110"],H:["10001","10001","10001","11111","10001","10001","10001"],P:["11110","10001","10001","11110","10000","10000","10000"],3:["11110","00001","00001","01110","00001","00001","11110"],"/":["00001","00010","00100","00100","01000","10000","10000"],4:["00010","00110","01010","10010","11111","00010","00010"],A:["01110","10001","10001","11111","10001","10001","10001"],B:["11110","10001","10001","11110","10001","10001","11110"],C:["01111","10000","10000","10000","10000","10000","01111"],D:["11110","10001","10001","10001","10001","10001","11110"],E:["11111","10000","10000","11110","10000","10000","11111"],K:["10001","10010","10100","11000","10100","10010","10001"],L:["10000","10000","10000","10000","10000","10000","11111"],M:["10001","11011","10101","10101","10001","10001","10001"],Q:["01110","10001","10001","10001","10101","10010","01101"],S:["01111","10000","10000","01110","00001","00001","11110"],U:["10001","10001","10001","10001","10001","10001","01110"],Z:["11111","00001","00010","00100","01000","10000","11111"],J:["00111","00010","00010","00010","00010","10010","01100"],V:["10001","10001","10001","10001","10001","01010","00100"],W:["10001","10001","10001","10101","10101","11011","10001"],X:["10001","10001","01010","00100","01010","10001","10001"],Y:["10001","10001","01010","00100","00100","00100","00100"],0:["01110","10001","10011","10101","11001","10001","01110"],1:["00100","01100","00100","00100","00100","00100","01110"],2:["01110","10001","00001","00010","00100","01000","11111"],5:["11111","10000","11110","00001","00001","10001","01110"],6:["00110","01000","10000","11110","10001","10001","01110"],7:["11111","00001","00010","00100","01000","01000","01000"],8:["01110","10001","10001","01110","10001","10001","01110"],9:["01110","10001","10001","01111","00001","00010","01100"],"-":["00000","00000","00000","11111","00000","00000","00000"],"+":["00000","00100","00100","11111","00100","00100","00000"],"<":["00010","00100","01000","10000","01000","00100","00010"],">":["01000","00100","00010","00001","00010","00100","01000"]};function J6t(t,r,i){const a=Math.max(1,Math.floor(Math.min(r,i)/128)),l=a*3;return{width:t.length*a*6-a+l*2,height:a*7+l*2}}function GR(t,r,i,a,l,d,_="normal"){const g=Math.max(1,Math.floor(Math.min(l,d)/128)),b=g*3,S=g*6,k=r.length*S-g+b*2,w=g*7+b*2;t.fillStyle=_==="warning"?"rgba(154, 24, 24, 0.92)":"rgba(0, 0, 0, 0.62)",t.fillRect(i,a,k,w),t.fillStyle="#ffffff";for(let N=0;N<r.length;N++){const P=e$r[r[N]];if(P)for(let j=0;j<P.length;j++)for(let J=0;J<P[j].length;J++)P[j][J]==="1"&&t.fillRect(i+b+N*S+J*g,a+b+j*g,g,g)}}const t$r=.45,W6t=.25,ege=new WeakMap;function Ree(t,r){let i=ege.get(r);i||(i=G4t(r),ege.set(r,i)),t.environment=i.texture,t.environmentIntensity=t$r}function M0e(t){const r=ege.get(t);r&&(ege.delete(t),r.dispose())}const EZ=["front","right","top","perspective"],C2t=24;function H6t(t){const r=t;return typeof r=="object"&&r!==null&&typeof r.bone=="string"&&r.bone.length>0&&(r.axis==="x"||r.axis==="y"||r.axis==="z")&&typeof r.radians=="number"&&Number.isFinite(r.radians)}function G6t(t){const r=t;return typeof r=="object"&&r!==null&&typeof r.morph=="string"&&r.morph.length>0&&typeof r.influence=="number"&&Number.isFinite(r.influence)}function Q6t(t){const r=t;return typeof r=="object"&&r!==null&&typeof r.bone=="string"&&r.bone.length>0&&(r.axis==="x"||r.axis==="y"||r.axis==="z")&&typeof r.meters=="number"&&Number.isFinite(r.meters)}function r$r(t){return H6t(t)||G6t(t)||Q6t(t)}function n$r(t,r){const i=t;if(typeof i!="object"||i===null||typeof i.label!="string"||!/^[a-z0-9][a-z0-9-]*$/i.test(i.label)||i.pose!==void 0&&(typeof i.pose!="string"||!r.has(i.pose)))return!1;if(i.view==="turntable")return typeof i.yaw=="number"&&Number.isFinite(i.yaw);if(i.view==="bone-zoom"){const a=i;return a.yaw!==void 0&&(typeof a.yaw!="number"||!Number.isFinite(a.yaw))?!1:Array.isArray(a.bones)&&a.bones.length>0&&a.bones.every(l=>typeof l=="string"&&l.length>0)&&typeof a.spanFraction=="number"&&Number.isFinite(a.spanFraction)&&a.spanFraction>0&&a.spanFraction<=2}return!1}function i$r(t){const r=b=>{throw new Error(`Asset preview shot-set definition is invalid: ${b}`)},i=t;(typeof i!="object"||i===null)&&r("expected an object.");const a=i;(typeof a.name!="string"||!/^[a-z0-9][a-z0-9-]*$/i.test(a.name))&&r("`name` must be a short alphanumeric/dash identifier."),a.requiredBones!==void 0&&(!Array.isArray(a.requiredBones)||a.requiredBones.some(b=>typeof b!="string"||b.length===0))&&r("`requiredBones` must be an array of non-empty bone names."),a.rigRequirementHint!==void 0&&typeof a.rigRequirementHint!="string"&&r("`rigRequirementHint` must be a string.");const l=a.poses??{};(typeof l!="object"||l===null||Array.isArray(l))&&r("`poses` must be an object of named pose-step lists.");for(const[b,S]of Object.entries(l))(!Array.isArray(S)||!S.every(r$r))&&r(`pose ${JSON.stringify(b)} must be an array of {bone, axis, radians} and/or {morph, influence}.`);const d=new Set(Object.keys(l));(!Array.isArray(a.shots)||a.shots.length===0||a.shots.length>C2t)&&r(`\`shots\` must list 1-${C2t} shots.`);const _=a.shots,g=new Set;for(const b of _){n$r(b,d)||r('every shot needs a label plus either {view:"turntable", yaw} or {view:"bone-zoom", bones, spanFraction, yaw?}, with every `yaw` a finite number of radians and `pose` naming a declared pose.');const{label:S}=b;g.has(S)&&r(`duplicate shot label ${JSON.stringify(S)}.`),g.add(S)}return a}const s$r=512,E2t=64,T2t=1024,dU=2106410,o$r=25e3,hR=64*1024*1024;function ww(t){const r=t??s$r;if(!Number.isInteger(r)||r<E2t||r>T2t)throw new Error(`Asset preview dimensions must be integers from ${E2t} to ${T2t}.`);return r}function AS(t){const r=t.toDataURL("image/png"),i=r.indexOf(",");return i>=0?r.slice(i+1):r}function GDn(t){const r=new Set;t.traverse(a=>r.add(a));let i=t;return t.traverse(a=>{const l=a;if(!(!l.isSkinnedMesh||!l.skeleton))for(const d of l.skeleton.bones){if(!d||r.has(d))continue;const _=new Set;for(let b=i;b;b=b.parent)_.add(b);let g=null;for(let b=d;b;b=b.parent)if(_.has(b)){g=b;break}g&&g!==i&&(i=g,i.traverse(b=>r.add(b)))}}),i}function hz(t){const r=new Set;t.traverse(_=>{r.add(_)});const i=c$r(t,r),a=l$r(t,i),l=a$r(t);a.matrix.copy(l),a.matrix.decompose(a.position,a.quaternion,a.scale),a.matrixAutoUpdate=!1,a.matrixWorld.copy(l),a.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,a.visible=!0;const d=[];a.traverse(_=>{_!==a&&_.userData.editorHelper&&d.push(_)});for(const _ of d)_.parent?.remove(_);return a}function a$r(t){const r=[];let i=t;for(;i;)r.push(i),i=i.parent;const a=r.findIndex(g=>!g.matrixWorldAutoUpdate),l=a>=0?r[a].matrixWorld.clone():new SS,d=new SS,_=a>=0?a-1:r.length-1;for(let g=_;g>=0;g--){const b=r[g];b.matrixAutoUpdate?d.compose(b.position,b.quaternion,b.scale):d.copy(b.matrix),l.multiply(d)}return l}function c$r(t,r){const i=new Map,a=new Map;let l=null;const d=()=>{if(l)return l;const _=new Map;for(const g of r){const b=g;if(!b.isBone||b.name==="")continue;const S=_.get(b.name);S?S.push(b):_.set(b.name,[b])}return l=_,_};if(t.traverse(_=>{const g=_;if(!g.isSkinnedMesh)return;const b=g.name||g.uuid;for(const S of g.skeleton.bones){if(S&&r.has(S)||S&&i.has(S))continue;const k=S?d().get(S.name)??[]:[];if(k.length===1){i.set(S,k[0]);continue}const w=S?.name||"(unnamed bone)";a.set(`${b} -> ${w}`,{mesh:b,bone:w,sameNamed:k.length})}}),a.size>0){const _=[...a.values()].map(({mesh:g,bone:b,sameNamed:S})=>S>1?`${g} -> ${b} (${S} bones inside the selection share that name — which one is meant is ambiguous)`:`${g} -> ${b} (no bone of that name inside the selection)`).join("; ");throw new Error(`Asset preview selection references bones outside its hierarchy that it cannot bind to: ${_}. Select the complete skeleton root — the node that owns both the skinned mesh and its bones.`)}return i}function l$r(t,r=new Map){const i=new Map,a=[],l=_=>{const g=u$r(_);i.set(_,g),f$r(_,g),_.isSkinnedMesh&&a.push([_,g]);const b=_;if(b.isLOD){const S=g,k=b.levels.filter(P=>P.object.visible),w=k.length===1?k[0]:b.levels[0];S.autoUpdate=!1;const N=new Set(b.levels.map(P=>P.object));for(const P of b.levels){if(m7e(P.object))continue;const j=l(P.object);j.visible=b.autoUpdate?P===w:P.object.visible,S.addLevel(j,P.distance,P.hysteresis)}for(const P of _.children)!N.has(P)&&!m7e(P)&&g.add(l(P))}else for(const S of _.children)m7e(S)||g.add(l(S));return g},d=l(t);for(const[_,g]of a){const b=_.skeleton.clone();b.bones=_.skeleton.bones.map(S=>{const k=i.get(r.get(S)??S);if(!k?.isBone)throw new Error(`Asset preview could not map skeleton bone: ${S.name||S.uuid}`);return k}),g.skeleton=b,g.bindMode=_.bindMode,g.bindMatrix.copy(_.bindMatrix),g.bindMatrixInverse.copy(_.bindMatrixInverse)}return d}function u$r(t){const r=t;if(r.isSkinnedMesh)return new bkt(r.geometry,r.material);const i=t;if(i.isInstancedMesh){const g=new Gqe(i.geometry,i.material,i.count);return g.instanceMatrix.copy(i.instanceMatrix),g.instanceColor=i.instanceColor?i.instanceColor.clone():null,g.morphTexture=i.morphTexture,g}const a=t;if(a.isMesh)return new NA(a.geometry,a.material);const l=t;if(t.isLineSegments)return new Akt(l.geometry,l.material);if(t.isLineLoop)return new xkt(l.geometry,l.material);if(l.isLine)return new Skt(l.geometry,l.material);const d=t;if(d.isPoints)return new Yqe(d.geometry,d.material);const _=t;return _.isSprite?new _Ir(_.material):t.isLOD?new mIr:t.isBone?new wkt:t.isGroup?new SP:new Lye}function f$r(t,r){r.name=t.name,r.up.copy(t.up),r.position.copy(t.position),r.quaternion.copy(t.quaternion),r.scale.copy(t.scale),r.matrix.copy(t.matrix),r.matrixWorld.copy(t.matrixWorld),r.matrixAutoUpdate=t.matrixAutoUpdate,r.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,r.visible=t.visible,r.castShadow=t.castShadow,r.receiveShadow=t.receiveShadow,r.frustumCulled=!1,r.renderOrder=t.renderOrder,r.layers.set(0),r.animations=[...t.animations];const i=t,a=r;i.morphTargetInfluences&&(i.morphTargetDictionary&&(a.morphTargetDictionary={...i.morphTargetDictionary}),a.morphTargetInfluences=[...i.morphTargetInfluences]);const l=t;l.isSprite&&r.center.copy(l.center)}function m7e(t){const r=1<<NUe;return!!(t.userData.editorHelper||t.userData.editorIcon||(t.layers.mask&r)!==0)}function pU(t){const r=new Set;t.traverse(i=>{const a=i;a.isSkinnedMesh&&r.add(a.skeleton);const l=i;if(l.isInstancedMesh){const d=l.morphTexture;l.morphTexture=null,l.dispose(),l.morphTexture=d}});for(const i of r)i.dispose()}function QDn(t){const r=t();let i;try{i=hz(r.root),i.animations=[...r.animations??r.root.animations]}catch(l){try{r.dispose()}catch(d){throw new AggregateError([l,d],"Object3D preview snapshot creation and source cleanup both failed.")}throw l}let a=!1;return{root:i,dispose(){if(a)return;a=!0;const l=[];try{pU(i)}catch(d){l.push(d)}try{r.dispose()}catch(d){l.push(d)}if(l.length===1)throw l[0];if(l.length>1)throw new AggregateError(l,"Object3D preview snapshot cleanup failed.")}}}function LP(t,r="front"){LUe(t);const i=d$r(t,r);if(i.isEmpty())throw new Error("Asset preview source has no renderable bounds.");const a=i.getCenter(new Tc),l=i.getSize(new Tc);return{center:a,size:l,radius:Math.max(l.length()/2,.001)}}function LUe(t){t.parent?.updateWorldMatrix(!0,!1),t.updateMatrixWorld(!0)}function d$r(t,r){const i=new xS;return jUe(t,L0e(r),r==="perspective",a=>i.expandByPoint(a)),i}function p$r(t,r){const i=r.map(()=>z6t());return r.length===0||(LUe(t),jUe(t,r[0],!1,a=>{for(let l=0;l<r.length;l++)U6t(i[l],a,r[l])})),i}function _$r(t,r){const i=r.map(()=>0);let a=0;if(r.length===0)return{framed:i,total:a};LUe(t);const l=r.map(()=>z6t());let d=-1;const _=()=>{if(!(d<0)){a++;for(let g=0;g<r.length;g++)ZBr(l[g],r[g].window)&&i[g]++,WBr(l[g])}};return jUe(t,r[0].basis,!1,(g,b)=>{b!==d&&(_(),d=b);for(let S=0;S<r.length;S++)U6t(l[S],g,r[S].basis)}),_(),{framed:i,total:a}}function jUe(t,r,i,a){const l=new xS,d=new Tc,_=new Tc,g=new SS;let b=0;const S=k=>{if(!k.visible||k!==t&&R0e(k))return;if(Z8(k,"gaussianSplat")){l.copy(k.getBoundingBox()).applyMatrix4(k.matrixWorld);const j=b++;for(const J of[l.min.x,l.max.x])for(const X of[l.min.y,l.max.y])for(const G of[l.min.z,l.max.z])a(d.set(J,X,G),j)}const w=k;if(w.isLOD&&w.levels.length>0){const j=new Set(w.levels.map(J=>J.object));for(const J of w.levels)S(J.object);for(const J of k.children)j.has(J)||S(J);return}const N=k;if(N.isSprite&&N.material.visible){if(i&&!N.material.sizeAttenuation)throw new Error("Asset preview cannot deterministically frame a perspective Sprite with sizeAttenuation disabled.");const j=new Tc().setFromMatrixPosition(N.matrixWorld),J=new Tc().setFromMatrixScale(N.matrixWorld),X=Math.cos(N.material.rotation),G=Math.sin(N.material.rotation),ee=b++;for(const xe of[-N.center.x,1-N.center.x])for(const ue of[-N.center.y,1-N.center.y]){const fe=xe*Math.abs(J.x),se=ue*Math.abs(J.y),de=X*fe-G*se,ge=G*fe+X*se;a(j.clone().addScaledVector(r.right,de).addScaledVector(r.up,ge),ee)}}const P=N.isSprite?void 0:k.geometry;if(P){const j=P.getAttribute("position");if(j){const J=m$r(k,P,j.count),X=h$r(k,J.length),G=Math.ceil(J.length/X),ee=k;if(ee.isInstancedMesh){const xe=new NA(ee.geometry,ee.material);for(let ue=0;ue<ee.count;ue++)ee.getMatrixAt(ue,g),ee.morphTexture&&ee.getMorphAt(ue,xe),J.forEach((fe,se)=>{xe.getVertexPosition(fe,_),_.applyMatrix4(g).applyMatrix4(ee.matrixWorld),a(_,b+Math.floor(se/X))}),b+=G}else{const xe=k;J.forEach((ue,fe)=>{xe.isMesh?xe.getVertexPosition(ue,_):y$r(k,P,ue,_),_.applyMatrix4(k.matrixWorld),a(_,b+Math.floor(fe/X))}),b+=G}}}for(const j of k.children)S(j)};S(t)}function m$r(t,r,i){const a=t.material;if(!a)return[];const l=r.index?.count??i,d=Math.max(0,r.drawRange.start),_=Math.min(l,Number.isFinite(r.drawRange.count)?d+r.drawRange.count:l),g=[];if(Array.isArray(a))for(const S of r.groups){const k=S.materialIndex??0;if(!a[k]?.visible)continue;const w=Math.max(d,S.start),N=Math.min(_,S.start+S.count);N>w&&g.push([w,N])}else a.visible&&_>d&&g.push([d,_]);const b=[];for(const[S,k]of g){const w=g$r(t,k-S);for(let N=S;N<S+w;N++)b.push(r.index?r.index.getX(N):N)}return b}function h$r(t,r){return t.isMesh?3:t.isLineSegments?2:t.isLine?Math.max(r,1):1}function g$r(t,r){return t.isMesh?r-r%3:t.isLineSegments?r-r%2:t.isLine?r>=2?r:0:r}function y$r(t,r,i,a){const l=r.getAttribute("position");a.fromBufferAttribute(l,i);const d=r.morphAttributes.position,_=t.morphTargetInfluences;if(!d||!_)return a;const g=a.clone(),b=new Tc,S=new Tc;for(let k=0;k<d.length;k++){const w=_[k]??0;w!==0&&(S.fromBufferAttribute(d[k],i),r.morphTargetsRelative||S.sub(g),b.addScaledVector(S,w))}return a.add(b)}function v$r(t,r,i){const{center:a,size:l,radius:d}=r;let _=l.x,g=l.y;const b=L0e(t),{direction:S,up:k}=b;t==="right"?_=l.z:t==="top"&&(_=l.x,g=l.z);const w=V6t(_/2,g/2,i);return MUe(a,{direction:S,right:b.right,up:k},w,d*3+1,d*10+10)}function tge(t,r,i,a){const l=new Bye(35,r,.01,t.radius*20+20),d=bb.degToRad(l.fov/2),_=Math.atan(Math.tan(d)*r),g=L0e("perspective"),b=i?.clone().normalize()??g.direction,S=Math.abs(b.y)>.999?new Tc(0,0,1):new Tc(0,1,0),k=i?S.clone().cross(b).normalize():g.right,w=i?b.clone().cross(k).normalize():g.up,N=t.size.clone().multiplyScalar(.5);let P=0;for(const j of[-1,1])for(const J of[-1,1])for(const X of[-1,1]){const G=new Tc(j*N.x,J*N.y,X*N.z),ee=G.dot(b);P=Math.max(P,ee+Math.abs(G.dot(k))*Zhe/Math.tan(_),ee+Math.abs(G.dot(w))*Zhe/Math.tan(d))}return l.position.copy(t.center).addScaledVector(b,Math.max(a??P,.01)),l.lookAt(t.center),l.updateProjectionMatrix(),l.updateMatrixWorld(!0),l}function L0e(t){const r=t==="front"?new Tc(0,0,1):t==="right"?new Tc(1,0,0):t==="top"?new Tc(0,1,0):new Tc(1,.72,1).normalize(),a=(t==="top"?new Tc(0,0,-1):new Tc(0,1,0)).clone().cross(r).normalize(),l=r.clone().cross(a).normalize();return{direction:r,right:a,up:l}}function BUe(t,r,i){return t==="perspective"?tge(r,i):v$r(t,r,i)}function k2t(t,r,i){return tge(t,r,i)}function K6t(t,r,i,a){const l=i.map(pLe),d=p$r(t,l),_=QBr(d.map(b=>GBr(b,a))),g=new Map;return i.forEach((b,S)=>{g.set(b,MUe(HBr(d[S],l[S]),l[S],_,r.radius*3+1,r.radius*10+10))}),g}function Y6t(t,r,i={}){const a=ww(i.width),l=ww(i.height),d=i.background??"neutral",_=hz(t);let g=null;try{const b=LP(_,"perspective"),S=TZ(_,b),k=UP(new $P({antialias:!0,alpha:!0,preserveDrawingBuffer:!0}));g=k,k.setPixelRatio(1),k.outputColorSpace=hv,k.toneMapping=u9,k.toneMappingExposure=1,k.setClearColor(dU,d==="transparent"?0:1),k.setSize(a,l,!1),Ree(S,k);const w=Math.atan2(r[0],r[2]),N=a/l,P=se=>new Tc(Math.sin(se),.72,Math.cos(se)).normalize(),j=[w,w+Math.PI,w-Math.PI/2,w+Math.PI/2],J=K6t(_,b,j,N),X=[{label:"front",camera:J.get(j[0])},{label:"back",camera:J.get(j[1])},{label:"left",camera:J.get(j[2])},{label:"right",camera:J.get(j[3])},{label:"quarter-left",camera:k2t(b,N,P(w-Math.PI/4))},{label:"quarter-right",camera:k2t(b,N,P(w+Math.PI/4))}],G=[],ee=2,xe=3,ue=document.createElement("canvas");ue.width=a*ee,ue.height=l*xe;const fe=ue.getContext("2d");if(!fe)throw new Error("Unable to create the source-review contact sheet.");return X.forEach(({label:se,camera:de},ge)=>{k.render(S,de),G.push({label:se,base64:AS(k.domElement),mimeType:"image/png"});const qe=ge%ee*a,tt=Math.floor(ge/ee)*l;fe.drawImage(k.domElement,qe,tt,a,l);const Ct=se==="quarter-left"?"3/4-L":se==="quarter-right"?"3/4-R":se.toUpperCase();GR(fe,Ct,qe,tt,a,l)}),{width:a,height:l,shots:G,contactSheet:{width:a*ee,height:l*xe,base64:AS(ue),mimeType:"image/png"}}}finally{g&&M0e(g),g?.dispose(),g?.forceContextLoss(),pU(_)}}function b$r(t,r,i,a,l){const d=YBr(t),_=KBr(t,d,r,i,a,l),g=i*3+1;return MUe(d,r,_,g,g+i*4+1)}function I2t(t,r){const i=new Map;t.traverse(_=>{const g=_;g.isBone&&_.name&&i.set(_.name,g)});const a=r.requiredBones??[],l=a.filter(_=>!i.has(_)),d=r.rigRequirementHint?` (${r.rigRequirementHint})`:"";if(a.length>0&&i.size===0)throw new Error(`Asset preview '--shots ${r.name}' requires a rigged GLB${d}, but this model has no skeleton at all. Required joints: ${a.join(", ")}.`);if(l.length>0)throw new Error(`Asset preview '--shots ${r.name}' requires joints this GLB's skeleton does not have${d}. Missing joint(s): ${l.join(", ")}.`);return i}function A$r(t,r,i){const a=i.filter(G6t);for(const l of i)if(H6t(l)){const d=r.get(l.bone);if(!d)continue;l.axis==="x"?d.rotateX(l.radians):l.axis==="y"?d.rotateY(l.radians):d.rotateZ(l.radians)}else if(Q6t(l)){const d=r.get(l.bone);if(!d)continue;l.axis==="x"?d.translateX(l.meters):l.axis==="y"?d.translateY(l.meters):d.translateZ(l.meters)}a.length!==0&&t.traverse(l=>{const d=l,_=d.morphTargetDictionary,g=d.morphTargetInfluences;if(!(!_||!g))for(const{morph:b,influence:S}of a){const k=_[b];k!==void 0&&(g[k]=S)}})}function rge(t){let r=null;return t.traverse(i=>{r||(r=ame(i.userData.forward))}),r??[0,0,1]}function _Le(t,r){const i=new SP;return i.rotation.y=PUe(r),i.add(t),i.updateMatrixWorld(!0),i}function TZ(t,r){const i=new Mye;i.add(t),i.add(new gIr(16777215,3489874,1.8*W6t));const a=new kq(16777215,2.2);a.position.copy(r.center).addScaledVector(new Tc(1,1.5,1),r.radius*3),i.add(a);const l=new kq(12572671,.8);l.position.copy(r.center).addScaledVector(new Tc(-1,.5,-.7),r.radius*2),i.add(l);const d=new kq(16773596,.45);return d.position.copy(r.center).addScaledVector(new Tc(.3,-1,.4),r.radius*2),i.add(d),i}let aR=null;function D2t(){const t=aR;aR=null,t&&(M0e(t),t.dispose(),t.forceContextLoss())}function S$r(){if(aR?.getContext().isContextLost()&&D2t(),!aR){const t=UP(new $P({antialias:!0,alpha:!0,preserveDrawingBuffer:!0}));aR=t,t.domElement.addEventListener("webglcontextlost",()=>{aR===t&&D2t()})}return aR}function j0e(t,r={}){let i=!1;if(t.traverse(g=>{Z8(g,"gaussianSplat")&&(i=!0)}),i)throw new Error("Gaussian-splat capture requires the async project-asset capture path so Spark can sort each view.");const a=ww(r.width),l=ww(r.height),d=r.background??"neutral",_=hz(t);try{const g=rge(t);r.pose&&w$r(_,r.pose);const b=_Le(_,g),S=$Ue(g),k=LP(b,"perspective"),w=TZ(b,k),N=S$r();if(N.setPixelRatio(1),N.outputColorSpace=hv,N.toneMapping=u9,N.toneMappingExposure=1,N.setClearColor(dU,d==="transparent"?0:1),Ree(w,N),r.camera)return C$r(N,w,tge(k,a/l,P2t(r.camera),r.camera.distance),a,l,r.camera,S);const P=new Map;for(const J of EZ)P.set(J,BUe(J,LP(b,J),a/l));const j=tge(k,a/l,P2t({azimuthDegrees:30,elevationDegrees:-60}));return Z6t(N,w,P,a,l,S,j)}finally{pU(_)}}function x$r(t,r,i){const a=X6t(r,i.yawDegrees);if(!a)return t;const l=document.createElement("canvas");l.width=t.width,l.height=t.height;const d=l.getContext("2d");if(!d)return t;d.drawImage(t,0,0);const _=J6t(a.text,t.width,t.height),g=a.edge==="left"?0:t.width-_.width;return GR(d,a.text,g,t.height-_.height,t.width,t.height),l}function $Ue(t){const r=PUe(t);return{forward:[t[0],t[1],t[2]],yawDegrees:Math.round(bb.radToDeg(r))}}function w$r(t,r){if(!Number.isFinite(r.timeSeconds)||r.timeSeconds<0)throw new Error(`Asset preview pose time must be a finite number of seconds >= 0, got ${r.timeSeconds}.`);const i=t.animations??[],a=i.find(d=>d.name===r.clip);if(!a){const d=i.map(_=>`'${_.name}'`).join(", ");throw new Error(`Asset preview pose clip '${r.clip}' not found on the subject. `+(d?`Its clips are: ${d}.`:"The subject carries no animation clips at all — clips live on the model root (GLB animations, or a builder module’s `root.animations`)."))}const l=new hIr(t);l.clipAction(a).play(),l.update(r.timeSeconds),t.updateMatrixWorld(!0)}function P2t(t){const r=bb.degToRad(t.azimuthDegrees),i=bb.degToRad(t.elevationDegrees);return new Tc(Math.sin(r)*Math.cos(i),Math.sin(i),Math.cos(r)*Math.cos(i)).normalize()}function C$r(t,r,i,a,l,d,_){t.setSize(a,l,!1),t.render(r,i);const g={view:"perspective",base64:AS(t.domElement),mimeType:"image/png"},b=document.createElement("canvas");b.width=a,b.height=l;const S=b.getContext("2d");if(!S)throw new Error("Unable to create the asset preview contact sheet.");S.drawImage(t.domElement,0,0,a,l);const k=`AZ ${Math.round(d.azimuthDegrees)} EL ${Math.round(d.elevationDegrees)}`+(d.distance===void 0?"":` D ${Math.round(d.distance)}`);return GR(S,k,0,0,a,l),{width:a,height:l,orientation:_,views:[g],contactSheet:{width:a,height:l,base64:AS(b),mimeType:"image/png"}}}function X6t(t,r){if(t==="perspective")return null;const i=bb.degToRad(r),a=L0e(t).right.applyAxisAngle(new Tc(0,1,0),-i),l=[["X",new Tc(1,0,0)],["Y",new Tc(0,1,0)],["Z",new Tc(0,0,1)]];for(const[d,_]of l){const g=a.dot(_);if(g>.99)return{text:`+${d}>`,edge:"right"};if(g<-.99)return{text:`<+${d}`,edge:"left"}}return{text:`YAW ${r}`,edge:"left"}}function Z6t(t,r,i,a,l,d,_){const g=[],b=_?[...EZ,"below"]:[...EZ],S=_?3:2,k=a*S,w=l*2,N=document.createElement("canvas");N.width=k,N.height=w;const P=N.getContext("2d");if(!P)throw new Error("Unable to create the asset preview contact sheet.");t.getClearAlpha()>0&&(P.fillStyle=`#${new vE(dU).getHexString()}`,P.fillRect(0,0,k,w)),t.setSize(a,l,!1),b.forEach((J,X)=>{const G=J==="below"?_:i.get(J);if(!G)return;t.render(r,G),g.push({view:J,base64:AS(J==="below"?t.domElement:x$r(t.domElement,J,d)),mimeType:"image/png"});const ee=X%S,xe=Math.floor(X/S),ue=ee*a,fe=xe*l;P.drawImage(t.domElement,ue,fe,a,l);const se=J==="perspective"?"3/4":J.toUpperCase();if(GR(P,se,ue,fe,a,l),J==="below")return;const de=X6t(J,d.yawDegrees);if(de){const ge=J6t(de.text,a,l),qe=de.edge==="left"?ue:ue+a-ge.width;GR(P,de.text,qe,fe+l-ge.height,a,l)}});const j={width:k,height:w,base64:AS(N),mimeType:"image/png"};return{width:a,height:l,orientation:d,views:g,contactSheet:j}}function E$r(t,r,i={}){let a=!1;if(t.traverse(S=>{Z8(S,"gaussianSplat")&&(a=!0)}),a)throw new Error("Gaussian-splat capture requires the async project-asset capture path so Spark can sort each view.");const l=ww(i.width),d=ww(i.height),_=i.background??"neutral",g=[];let b=null;try{r.traverse(w=>{w.visible&&OUe(w)&&(w.visible=!1,g.push(w))});const S=new Map;for(const w of EZ){const N=BUe(w,LP(t,w),l/d);N.layers.enableAll(),N.layers.disable(NUe),S.set(w,N)}const k=UP(new $P({antialias:!0,alpha:!0,preserveDrawingBuffer:!0}));return b=k,k.setPixelRatio(1),k.outputColorSpace=hv,k.toneMapping=u9,k.toneMappingExposure=1,k.setClearColor(dU,_==="transparent"?0:1),Z6t(k,r,S,l,d,$Ue([0,0,1]))}finally{for(const S of g)S.visible=!0;b?.dispose(),b?.forceContextLoss()}}function T$r(t,r,i){const a=t.pose===void 0?"":` under pose '${t.pose}'`,l=t.view==="bone-zoom"?`bone-zoom on ${t.bones.join(", ")} at yaw ${(t.yaw??0).toFixed(3)}`:`turntable at yaw ${t.yaw.toFixed(3)}`,d=t.view==="bone-zoom"?"Zoom anchors are read from the REST skeleton for every shot, so a pose that MOVES the anchor leaves the crop behind where the joint used to be: re-aim the shot (another joint or yaw), widen its spanFraction, or drop it.":"Check the shot yaw and the pose it renders under.";return{label:t.label,reason:"empty-frame",...t.view==="bone-zoom"?{bones:[...t.bones]}:{},...t.pose===void 0?{}:{pose:t.pose},message:`Asset preview '--shots ${r}' shot ${JSON.stringify(t.label)} (${l}${a}) framed NONE of the subject's ${i} rendered faces: the image is background only and proves nothing about the asset. ${d}`}}function k$r(t,r,i){const a=[],l=()=>{for(const d of a)pU(d);a.length=0};try{const d=hz(t);a.push(d);const _=I2t(d,r),g=rge(t),b=_Le(d,g),S=LP(b,"perspective"),k=TZ(b,S),w={subject:b,scene:k,framing:S},N=new Map;for(const ue of r.shots){if(ue.pose===void 0||N.has(ue.pose))continue;const fe=r.poses?.[ue.pose]??[],se=hz(t);a.push(se);const de=I2t(se,r);A$r(se,de,fe),se.updateMatrixWorld(!0);const ge=_Le(se,g),qe=LP(ge,"perspective");N.set(ue.pose,{subject:ge,scene:TZ(ge,qe),framing:qe})}const P=ue=>ue===void 0?w:N.get(ue),j=ue=>new Tc().setFromMatrixPosition(_.get(ue).matrixWorld),J=new Map;for(const ue of new Set(r.shots.filter(fe=>fe.view==="turntable").map(fe=>fe.pose??void 0))){const fe=P(ue),se=[...new Set(r.shots.filter(de=>de.view==="turntable"&&(de.pose??void 0)===ue).map(de=>de.yaw))];J.set(ue,K6t(fe.subject,fe.framing,se,i))}const X=r.shots.map(ue=>{const fe=P(ue.pose);if(ue.view==="turntable")return{label:ue.label,camera:J.get(ue.pose??void 0).get(ue.yaw),scene:fe.scene,stage:fe,basis:pLe(ue.yaw)};const se=ue.bones.find(ge=>!_.has(ge));if(se!==void 0)throw new Error(`Asset preview '--shots ${r.name}' shot ${JSON.stringify(ue.label)} zooms on a joint this GLB's skeleton does not have: ${se}. List it in the definition's requiredBones or fix the rig.`);const de=pLe(ue.yaw??0);return{label:ue.label,camera:b$r(ue.bones.map(j),de,S.radius,ue.spanFraction,i),scene:fe.scene,stage:fe,basis:de}}),G=[],ee=new Map,xe=new Map;X.forEach(({stage:ue},fe)=>{const se=xe.get(ue);se?se.push(fe):xe.set(ue,[fe])});for(const[ue,fe]of xe){const{framed:se,total:de}=_$r(ue.subject,fe.map(ge=>{const qe=X[ge];return{basis:qe.basis,window:XBr(qe.camera,qe.basis)}}));fe.forEach((ge,qe)=>{if(se[qe]!==0)return;const tt=T$r(r.shots[ge],r.name,de);ee.set(ge,tt),G.push(tt)})}return{shots:X.map(({label:ue,camera:fe,scene:se},de)=>{const ge=ee.get(de);return{label:ue,camera:fe,scene:se,...ge?{warning:ge}:{}}}),warnings:G,dispose:l}}catch(d){throw l(),d}}function qUe(t,r,i={}){const a=ww(i.width),l=ww(i.height),d=i.background??"neutral",_=k$r(t,r,a/l);let g=null;try{const b=UP(new $P({antialias:!0,alpha:!0,preserveDrawingBuffer:!0}));g=b,b.setPixelRatio(1),b.outputColorSpace=hv,b.toneMapping=u9,b.toneMappingExposure=1,b.setClearColor(dU,d==="transparent"?0:1),b.setSize(a,l,!1);for(const G of _.shots)Ree(G.scene,b);const S=[],k=2,w=Math.ceil(_.shots.length/k),N=a*k,P=l*w,j=document.createElement("canvas");j.width=N,j.height=P;const J=j.getContext("2d");if(!J)throw new Error("Unable to create the asset preview contact sheet.");_.shots.forEach(({label:G,camera:ee,scene:xe,warning:ue},fe)=>{b.render(xe,ee),S.push({label:G,base64:AS(b.domElement),mimeType:"image/png"});const se=fe%k,de=Math.floor(fe/k),ge=se*a,qe=de*l;J.drawImage(b.domElement,ge,qe,a,l),GR(J,ue?`${G.toUpperCase()} - EMPTY`:G.toUpperCase(),ge,qe,a,l,ue?"warning":"normal")});const X={width:N,height:P,base64:AS(j),mimeType:"image/png"};return{width:a,height:l,shots:S,warnings:_.warnings,contactSheet:X}}finally{g&&M0e(g),g?.dispose(),g?.forceContextLoss(),_.dispose()}}function I$r(t){const r=t.replace(/^\/?public(\/|$)/,"/");if(!r.startsWith("/")||r.startsWith("//")||r.includes("\\")||r.includes("?")||r.includes("#"))throw new Error("Model asset paths must be the served web path (project-root absolute, with public/ stripped): e.g. /models/generated/hero.glb");let i;try{i=decodeURIComponent(r)}catch{throw new Error("Asset Editor model path contains invalid URL encoding.")}if(i.split("/").some(d=>d==="."||d===".."))throw new Error("Asset Editor model paths cannot traverse outside the project root.");const a=globalThis.location?.origin??"http://localhost",l=new URL(r,a);if(l.origin!==a||!l.pathname.toLowerCase().match(/\.(?:glb|gltf|spz)$/))throw new Error("Asset Editor loads bounded, same-origin project .glb, .gltf, or .spz files only.");return l}async function eNt(t,r,i=hR){const a=await fetch(t,{signal:r});if(!a.ok)throw new Error(`Unable to load project model (${a.status} ${a.statusText}).`);const l=Number(a.headers.get("content-length"));if(Number.isFinite(l)&&l>i)throw new Error(`Asset Editor project models must be ${hR/1024/1024} MiB or less.`);if(!a.body){const k=await a.arrayBuffer();if(k.byteLength>i)throw new Error(`Asset Editor project models must be ${hR/1024/1024} MiB or less.`);return k}const d=a.body.getReader(),_=[];let g=0;try{for(;;){const{done:k,value:w}=await d.read();if(k)break;if(g+=w.byteLength,g>i)throw await d.cancel(),new Error(`Asset Editor project models must be ${hR/1024/1024} MiB or less.`);_.push(w)}}finally{d.releaseLock()}const b=new Uint8Array(g);let S=0;for(const k of _)b.set(k,S),S+=k.byteLength;return b.buffer}function N2t(t,r,i){return new Promise((a,l)=>{let d=!1;const _=b=>d?!1:(d=!0,i.removeEventListener("abort",g),b(),!0),g=()=>_(()=>l(i.reason));if(i.addEventListener("abort",g,{once:!0}),i.aborted){g();return}fU.parse(t,new URL(".",r).href,b=>{b.scene.animations=[...b.animations],_(()=>a(b.scene))||eO(b.scene)},b=>_(()=>l(b)))})}function D$r(t,r){if(t.includes("\\")||t.includes("?")||t.includes("#"))throw new Error("Asset Editor .gltf dependencies must be plain same-origin project paths.");const i=new URL(t,r);if(i.origin!==r.origin)throw new Error("Asset Editor .gltf dependencies must stay on the project origin.");return i}function P$r(t,r){if(typeof t.mimeType=="string")return t.mimeType;const i=r.pathname.split(".").pop()?.toLowerCase();return i==="png"?"image/png":i==="jpg"||i==="jpeg"?"image/jpeg":i==="webp"?"image/webp":"application/octet-stream"}async function N$r(t,r,i){let a;try{a=JSON.parse(new TextDecoder().decode(t))}catch{throw new Error("Asset Editor could not parse the project .gltf JSON document.")}const l=[...Array.isArray(a.buffers)?a.buffers:[],...Array.isArray(a.images)?a.images:[]];let d=t.byteLength;for(const _ of l){if(typeof _.uri!="string"||_.uri.startsWith("data:"))continue;const g=D$r(_.uri,r),b=await eNt(g,i,hR-d);d+=b.byteLength;const S=new Uint8Array(b);let k="";for(let w=0;w<S.length;w+=32768)k+=String.fromCharCode(...S.subarray(w,w+32768));_.uri=`data:${P$r(_,g)};base64,${btoa(k)}`}return JSON.stringify(a)}function zUe(t,r){let i;try{const a=atob(t);i=new Uint8Array(a.length);for(let l=0;l<a.length;l++)i[l]=a.charCodeAt(l)}catch{throw new Error(`${r} is not valid base64.`)}if(i.byteLength===0||i.byteLength>hR)throw new Error(`${r} must be non-empty and at most ${hR/1024/1024} MiB.`);return new Promise((a,l)=>{fU.parse(i.buffer,"",d=>{d.scene.animations=[...d.animations],a(d.scene)},d=>l(d instanceof Error?d:new Error(String(d))))})}async function O$r(t,r={}){const i=await zUe(t,"Asset preview GLB bytes");try{return j0e(i,r)}finally{eO(i)}}async function F$r(t,r,i={}){const a=await zUe(t,"Asset preview GLB bytes");try{return qUe(a,r,i)}finally{eO(a)}}async function R$r(t,r){const i=I$r(t),a=new AbortController,l=()=>a.abort(r?.reason);r?.aborted?l():r?.addEventListener("abort",l,{once:!0});const d=globalThis.setTimeout(()=>a.abort(new Error("Asset Editor project model load timed out after 25 seconds.")),o$r);try{const _=await eNt(i,a.signal);if(a.signal.throwIfAborted(),i.pathname.toLowerCase().endsWith(".spz"))return{root:await $6t(t,new Uint8Array(_)),sourceBytes:null};if(i.pathname.toLowerCase().endsWith(".glb")){const b=new Uint8Array(_.slice(0));return{root:await N2t(_,i,a.signal),sourceBytes:b}}const g=await N$r(_,i,a.signal);return{root:await N2t(g,i,a.signal),sourceBytes:null}}finally{globalThis.clearTimeout(d),r?.removeEventListener("abort",l)}}async function B0e(t,r){return(await R$r(t,r)).root}function eO(t){Z8(t,"gaussianSplat")&&t.dispose(),pU(t),t.traverse(r=>{const i=r;i.isInstancedMesh&&i.morphTexture?.dispose();const a=r;if(a.geometry?.dispose(),!a.material)return;const l=Array.isArray(a.material)?a.material:[a.material];for(const d of l){for(const _ of Object.values(d))_ instanceof oP&&_.dispose();d.dispose()}})}async function tNt(t,r={}){const i=await B0e(t);try{return Z8(i,"gaussianSplat")?await L$r(i,r):j0e(i,r)}finally{eO(i)}}async function M$r(t,r,i={}){const a=await B0e(t);try{return Y6t(a,r,i)}finally{eO(a)}}async function L$r(t,r){const i=ww(r.width),a=ww(r.height),l=r.background??"neutral",d=LP(t,"perspective"),_=TZ(t,d),g=UP(new $P({antialias:!1,alpha:!0,preserveDrawingBuffer:!0}));let b=null;try{const S=await Xo(()=>import("./spark.module-DVeR0ywZ.js"),__vite__mapDeps([45,6,3,2,4,1,8,9,10,11]));b=new S.SparkRenderer({renderer:g,autoUpdate:!1,enableLod:!1}),_.add(b),g.setPixelRatio(1),g.outputColorSpace=hv,g.toneMapping=u9,g.toneMappingExposure=1,g.setClearColor(dU,l==="transparent"?0:1),g.setSize(i,a,!1),Ree(_,g);const k=[],w=document.createElement("canvas");w.width=i*2,w.height=a*2;const N=w.getContext("2d");if(!N)throw new Error("Unable to create the asset preview contact sheet.");for(const[P,j]of EZ.entries()){const J=BUe(j,LP(t,j),i/a);await b.update({scene:_,camera:J}),g.render(_,J),k.push({view:j,base64:AS(g.domElement),mimeType:"image/png"});const X=P%2*i,G=Math.floor(P/2)*a;N.drawImage(g.domElement,X,G,i,a),GR(N,j==="perspective"?"3/4":j.toUpperCase(),X,G,i,a)}return{width:i,height:a,orientation:$Ue([0,0,1]),views:k,contactSheet:{width:i*2,height:a*2,base64:AS(w),mimeType:"image/png"}}}finally{b?.removeFromParent(),t.removeFromParent(),b?.dispose(),M0e(g),g.dispose(),g.forceContextLoss()}}async function j$r(t,r,i={}){const a=await B0e(t);try{return qUe(a,r,i)}finally{eO(a)}}const O2t=0,B$r=16777215,F2t=10;function $$r(t){return zUe(t,"Compare reference GLB")}function R2t(t,r){const i=hz(t),a=new SP;a.rotation.y=PUe(r),a.add(i);const l=new SP;l.add(a),l.updateWorldMatrix(!0,!0);const d=LP(l,"front"),_=[d.center.x-d.size.x/2,d.center.y-d.size.y/2,d.center.z-d.size.z/2],g=[d.center.x+d.size.x/2,d.center.y+d.size.y/2,d.center.z+d.size.z/2],b=Wjr(_,g);return l.scale.setScalar(b.scale),l.position.set(...b.position),l.updateWorldMatrix(!0,!0),{wrapper:l,dispose:()=>pU(i)}}function q$r(t,r){const i=jjr,a=i*r,l=new $ye(-a,a,i,-i,.01,F2t*4),d=t==="front"?new Tc(0,0,1):new Tc(1,0,0);return l.position.set(0,m2t,0).addScaledVector(d,F2t),l.up.set(0,1,0),l.lookAt(0,m2t,0),l.updateProjectionMatrix(),l.updateMatrixWorld(!0),l}function z$r(t,r,i={}){const a=ww(i.width),l=ww(i.height),d=a/l,_=[];let g=null;try{const b=R2t(t,rge(t));_.push(b.dispose);const S=R2t(r,i.refForward??rge(r));_.push(S.dispose);const k=new fq({color:B$r});_.push(()=>k.dispose());const w=fe=>{const se=new Mye;return se.background=new vE(O2t),se.overrideMaterial=k,se.add(fe),se},N=w(b.wrapper),P=w(S.wrapper),j=UP(new $P({antialias:!1,alpha:!1,preserveDrawingBuffer:!0}));g=j,j.setPixelRatio(1),j.toneMapping=Nkt,j.setClearColor(O2t,1),j.setSize(a,l,!1);const J=document.createElement("canvas");J.width=a,J.height=l;const X=J.getContext("2d");if(!X)throw new Error("Unable to create the compare readback canvas.");const G=(fe,se,de,ge)=>{j.render(fe,se),X.clearRect(0,0,a,l),X.drawImage(j.domElement,0,0);const qe=X.getImageData(0,0,a,l).data,tt=Ujr(qe,a*l);if(!tt.some(Ct=>Ct!==0))throw new Error(`Compare ${ge} view rendered an empty ${de} silhouette — nothing to score.`);return{image:{base64:AS(J),mimeType:"image/png"},mask:tt}},ee=document.createElement("canvas");ee.width=a,ee.height=l;const xe=ee.getContext("2d");if(!xe)throw new Error("Unable to create the compare overlay canvas.");const ue=[];for(const fe of Ljr){const se=q$r(fe,d),de=G(N,se,"asset",fe),ge=G(P,se,"reference",fe),qe=Vjr(de.mask,ge.mask);xe.putImageData(new ImageData(Jjr(de.mask,ge.mask),a,l),0,0),ue.push({view:fe,iou:qe.iou,overlay:{base64:AS(ee),mimeType:"image/png"},asset:de.image,ref:ge.image})}return{width:a,height:l,views:ue}}finally{g?.dispose(),g?.forceContextLoss();for(const b of _.reverse())b()}}async function U$r(t,r,i={}){const a=await B0e(t);try{return await rNt(a,r,i)}finally{eO(a)}}async function rNt(t,r,i={}){const a=await $$r(r);try{return z$r(t,a,i)}finally{eO(a)}}let u8=null,nNt=0;const mLe=new Set;function iNt(){nNt++;for(const t of mLe)t()}function $0e(t){return mLe.add(t),()=>{mLe.delete(t)}}function kZ(){return nNt}function q0e(){return u8}function YN(t){u8&&JSON.stringify(u8)===JSON.stringify(t)||(u8=t,iNt())}function pP(){u8!==null&&(u8=null,iNt())}function h7e(t){return[...t.selectedEntityIds].sort().join(`
|
|
73
|
+
`);this.workerSourceURL=URL.createObjectURL(new Blob([b])),this.transcoderBinary=_,this.workerPool.setWorkerCreator(()=>{const S=new Worker(this.workerSourceURL),k=this.transcoderBinary.slice(0);return S.postMessage({type:"init",config:this.workerConfig,transcoderBinary:k},[k]),S})}),d7e>0&&console.warn("THREE.KTX2Loader: Multiple active KTX2 loaders may cause performance issues. Use a single KTX2Loader instance, or call .dispose() on old instances."),d7e++}return this.transcoderPending}load(r,i,a,l){if(this.workerConfig===null)throw new Error("THREE.KTX2Loader: Missing initialization with `.detectSupport( renderer )`.");const d=new TR(this.manager);d.setPath(this.path),d.setCrossOrigin(this.crossOrigin),d.setWithCredentials(this.withCredentials),d.setResponseType("arraybuffer"),d.load(r,_=>{this.parse(_,i,l)},a,l)}parse(r,i,a){if(this.workerConfig===null)throw new Error("THREE.KTX2Loader: Missing initialization with `.detectSupport( renderer )`.");if(f7e.has(r))return f7e.get(r).promise.then(i).catch(a);this._createTexture(r).then(l=>i?i(l):null).catch(a)}_createTextureFrom(r,i){const{type:a,error:l,data:{faces:d,width:_,height:g,format:b,type:S,dfdFlags:k}}=r;if(a==="error")return Promise.reject(l);let w;if(i.faceCount===6)w=new tIr(d,b,S);else{const N=d[0].mipmaps;w=i.layerCount>1?new rIr(N,_,g,i.layerCount,b,S):new Tkt(N,_,g,b,S)}return w.minFilter=d[0].mipmaps.length===1?zR:jye,w.magFilter=zR,w.generateMipmaps=!1,w.needsUpdate=!0,w.colorSpace=M6t(i),w.premultiplyAlpha=!!(k&FBr),w}async _createTexture(r,i={}){const a=BBr(new Uint8Array(r)),l=a.vkFormat===FUe&&a.dataFormatDescriptor[0].colorModel===167;if(!(a.vkFormat===jBr||l&&!this.workerConfig.astcHDRSupported))return VBr(a);const _=i,g=this.init().then(()=>this.workerPool.postMessage({type:"transcode",buffer:r,taskConfig:_},[r])).then(b=>this._createTextureFrom(b.data,a));return f7e.set(r,{promise:g}),g}dispose(){this.workerPool.dispose(),this.workerSourceURL&&URL.revokeObjectURL(this.workerSourceURL),d7e--}}gw.BasisFormat={ETC1S:0,UASTC:1,UASTC_HDR:2};gw.TranscoderFormat={ETC1:0,ETC2:1,BC1:2,BC3:3,BC4:4,BC5:5,BC7_M6_OPAQUE_ONLY:6,BC7_M5:7,PVRTC1_4_RGB:8,PVRTC1_4_RGBA:9,ASTC_4x4:10,ATC_RGB:11,ATC_RGBA_INTERPOLATED_ALPHA:12,RGBA32:13,RGB565:14,BGR565:15,RGBA4444:16,BC6H:22,RGB_HALF:24,RGBA_HALF:25};gw.EngineFormat={RGBAFormat:dq,RGBA_ASTC_4x4_Format:M_e,RGB_BPTC_UNSIGNED_Format:dIr,RGBA_BPTC_Format:b9e,RGBA_ETC2_EAC_Format:Ikt,RGBA_PVRTC_4BPPV1_Format:v9e,RGBA_S3TC_DXT5_Format:fIr,RGB_ETC1_Format:uIr,RGB_ETC2_Format:kkt,RGB_PVRTC_4BPPV1_Format:lIr,RGBA_S3TC_DXT1_Format:A9e};gw.EngineType={UnsignedByteType:Bp,HalfFloatType:QN,FloatType:vX};gw.BasisWorker=function(){let t,r,i;const a=_EngineFormat,l=_EngineType,d=_TranscoderFormat,_=_BasisFormat;self.addEventListener("message",function(j){const J=j.data;switch(J.type){case"init":t=J.config,g(J.transcoderBinary);break;case"transcode":r.then(()=>{try{const{faces:X,buffers:G,width:ee,height:xe,hasAlpha:ue,format:fe,type:se,dfdFlags:de}=b(J.buffer);self.postMessage({type:"transcode",id:J.id,data:{faces:X,width:ee,height:xe,hasAlpha:ue,format:fe,type:se,dfdFlags:de}},G)}catch(X){console.error(X),self.postMessage({type:"error",id:J.id,error:X.message})}});break}});function g(j){r=new Promise(J=>{i={wasmBinary:j,onRuntimeInitialized:J},BASIS(i)}).then(()=>{i.initializeBasis(),i.KTX2File===void 0&&console.warn("THREE.KTX2Loader: Please update Basis Universal transcoder.")})}function b(j){const J=new i.KTX2File(new Uint8Array(j));function X(){J.close(),J.delete()}if(!J.isValid())throw X(),new Error("THREE.KTX2Loader: Invalid or unsupported .ktx2 file");let G;if(J.isUASTC())G=_.UASTC;else if(J.isETC1S())G=_.ETC1S;else if(J.isHDR())G=_.UASTC_HDR;else throw new Error("THREE.KTX2Loader: Unknown Basis encoding");const ee=J.getWidth(),xe=J.getHeight(),ue=J.getLayers()||1,fe=J.getLevels(),se=J.getFaces(),de=J.getHasAlpha(),ge=J.getDFDFlags(),{transcoderFormat:qe,engineFormat:tt,engineType:Ct}=w(G,ee,xe,de);if(!ee||!xe||!fe)throw X(),new Error("THREE.KTX2Loader: Invalid texture");if(!J.startTranscoding())throw X(),new Error("THREE.KTX2Loader: .startTranscoding failed");const Ot=[],vt=[];for(let Et=0;Et<se;Et++){const Tt=[];for(let Le=0;Le<fe;Le++){const cr=[];let Yt,Lr;for(let on=0;on<ue;on++){const gr=J.getImageLevelInfo(Le,on,Et);Et===0&&Le===0&&on===0&&(gr.origWidth%4!==0||gr.origHeight%4!==0)&&console.warn("THREE.KTX2Loader: ETC1S and UASTC textures should use multiple-of-four dimensions."),fe>1?(Yt=gr.origWidth,Lr=gr.origHeight):(Yt=gr.width,Lr=gr.height);let An=new Uint8Array(J.getImageTranscodedSizeInBytes(Le,on,0,qe));const Rn=J.transcodeImage(An,Le,on,Et,qe,0,-1,-1);if(Ct===l.HalfFloatType&&(An=new Uint16Array(An.buffer,An.byteOffset,An.byteLength/Uint16Array.BYTES_PER_ELEMENT)),!Rn)throw X(),new Error("THREE.KTX2Loader: .transcodeImage failed.");cr.push(An)}const nn=P(cr);Tt.push({data:nn,width:Yt,height:Lr}),vt.push(nn.buffer)}Ot.push({mipmaps:Tt,width:ee,height:xe,format:tt,type:Ct})}return X(),{faces:Ot,buffers:vt,width:ee,height:xe,hasAlpha:de,dfdFlags:ge,format:tt,type:Ct}}const S=[{if:"astcSupported",basisFormat:[_.UASTC],transcoderFormat:[d.ASTC_4x4,d.ASTC_4x4],engineFormat:[a.RGBA_ASTC_4x4_Format,a.RGBA_ASTC_4x4_Format],engineType:[l.UnsignedByteType],priorityETC1S:1/0,priorityUASTC:1,needsPowerOfTwo:!1},{if:"bptcSupported",basisFormat:[_.ETC1S,_.UASTC],transcoderFormat:[d.BC7_M5,d.BC7_M5],engineFormat:[a.RGBA_BPTC_Format,a.RGBA_BPTC_Format],engineType:[l.UnsignedByteType],priorityETC1S:3,priorityUASTC:2,needsPowerOfTwo:!1},{if:"dxtSupported",basisFormat:[_.ETC1S,_.UASTC],transcoderFormat:[d.BC1,d.BC3],engineFormat:[a.RGBA_S3TC_DXT1_Format,a.RGBA_S3TC_DXT5_Format],engineType:[l.UnsignedByteType],priorityETC1S:4,priorityUASTC:5,needsPowerOfTwo:!1},{if:"etc2Supported",basisFormat:[_.ETC1S,_.UASTC],transcoderFormat:[d.ETC1,d.ETC2],engineFormat:[a.RGB_ETC2_Format,a.RGBA_ETC2_EAC_Format],engineType:[l.UnsignedByteType],priorityETC1S:1,priorityUASTC:3,needsPowerOfTwo:!1},{if:"etc1Supported",basisFormat:[_.ETC1S,_.UASTC],transcoderFormat:[d.ETC1],engineFormat:[a.RGB_ETC1_Format],engineType:[l.UnsignedByteType],priorityETC1S:2,priorityUASTC:4,needsPowerOfTwo:!1},{if:"pvrtcSupported",basisFormat:[_.ETC1S,_.UASTC],transcoderFormat:[d.PVRTC1_4_RGB,d.PVRTC1_4_RGBA],engineFormat:[a.RGB_PVRTC_4BPPV1_Format,a.RGBA_PVRTC_4BPPV1_Format],engineType:[l.UnsignedByteType],priorityETC1S:5,priorityUASTC:6,needsPowerOfTwo:!0},{if:"bptcSupported",basisFormat:[_.UASTC_HDR],transcoderFormat:[d.BC6H],engineFormat:[a.RGB_BPTC_UNSIGNED_Format],engineType:[l.HalfFloatType],priorityHDR:1,needsPowerOfTwo:!1},{basisFormat:[_.ETC1S,_.UASTC],transcoderFormat:[d.RGBA32,d.RGBA32],engineFormat:[a.RGBAFormat,a.RGBAFormat],engineType:[l.UnsignedByteType,l.UnsignedByteType],priorityETC1S:100,priorityUASTC:100,needsPowerOfTwo:!1},{basisFormat:[_.UASTC_HDR],transcoderFormat:[d.RGBA_HALF],engineFormat:[a.RGBAFormat],engineType:[l.HalfFloatType],priorityHDR:100,needsPowerOfTwo:!1}],k={[_.ETC1S]:S.filter(j=>j.basisFormat.includes(_.ETC1S)).sort((j,J)=>j.priorityUASTC-J.priorityUASTC),[_.UASTC]:S.filter(j=>j.basisFormat.includes(_.UASTC)).sort((j,J)=>j.priorityUASTC-J.priorityUASTC),[_.UASTC_HDR]:S.filter(j=>j.basisFormat.includes(_.UASTC_HDR)).sort((j,J)=>j.priorityHDR-J.priorityHDR)};function w(j,J,X,G){const ee=k[j];for(let xe=0;xe<ee.length;xe++){const ue=ee[xe];if(ue.if&&!t[ue.if]||!ue.basisFormat.includes(j)||G&&ue.transcoderFormat.length<2||ue.needsPowerOfTwo&&!(N(J)&&N(X)))continue;const fe=ue.transcoderFormat[G?1:0],se=ue.engineFormat[G?1:0],de=ue.engineType[0];return{transcoderFormat:fe,engineFormat:se,engineType:de}}throw new Error("THREE.KTX2Loader: Failed to identify transcoding target.")}function N(j){return j<=2?!0:(j&j-1)===0&&j!==0}function P(j){if(j.length===1)return j[0];let J=0;for(let ee=0;ee<j.length;ee++){const xe=j[ee];J+=xe.byteLength}const X=new Uint8Array(J);let G=0;for(let ee=0;ee<j.length;ee++){const xe=j[ee];X.set(xe,G),G+=xe.byteLength}return X}};const UBr=new Set([dq,S9e,LY,MY]),_7e={[u6t]:dq,[l6t]:LY,[c6t]:MY,[a6t]:dq,[o6t]:LY,[s6t]:MY,[i6t]:dq,[n6t]:dq,[r6t]:LY,[t6t]:LY,[e6t]:MY,[Z4t]:MY,[d6t]:S9e,[f6t]:S9e,[E6t]:Ikt,[C6t]:kkt,[FUe]:M_e,[k6t]:M_e,[T6t]:M_e,[R6t]:bFe,[D6t]:bFe,[I6t]:bFe,[h6t]:A9e,[m6t]:A9e,[_6t]:z1t,[p6t]:z1t,[y6t]:q1t,[g6t]:q1t,[b6t]:oIr,[v6t]:sIr,[S6t]:iIr,[A6t]:nIr,[w6t]:b9e,[x6t]:b9e,[F6t]:v9e,[N6t]:v9e,[O6t]:$1t,[P6t]:$1t},j$={[u6t]:vX,[l6t]:vX,[c6t]:vX,[a6t]:QN,[o6t]:QN,[s6t]:QN,[i6t]:Bp,[n6t]:Bp,[r6t]:Bp,[t6t]:Bp,[e6t]:Bp,[Z4t]:Bp,[d6t]:Pkt,[f6t]:Dkt,[E6t]:Bp,[C6t]:Bp,[FUe]:QN,[k6t]:Bp,[T6t]:Bp,[R6t]:QN,[D6t]:Bp,[I6t]:Bp,[h6t]:Bp,[m6t]:Bp,[_6t]:Bp,[p6t]:Bp,[y6t]:Bp,[g6t]:Bp,[b6t]:Bp,[v6t]:Bp,[S6t]:Bp,[A6t]:Bp,[w6t]:Bp,[x6t]:Bp,[F6t]:Bp,[N6t]:Bp,[O6t]:Bp,[P6t]:Bp};async function VBr(t){const{vkFormat:r}=t;if(_7e[r]===void 0)throw new Error("THREE.KTX2Loader: Unsupported vkFormat: "+r);j$[r]===void 0&&console.warn('THREE.KTX2Loader: Missing ".type" for vkFormat: '+r);let i;t.supercompressionScheme===A2t&&(p7e||(p7e=new Promise(async _=>{const g=new $Br;await g.init(),_(g)})),i=await p7e);const a=[];for(let _=0;_<t.levels.length;_++){const g=Math.max(1,t.pixelWidth>>_),b=Math.max(1,t.pixelHeight>>_),S=t.pixelDepth?Math.max(1,t.pixelDepth>>_):0,k=t.levels[_];let w;if(t.supercompressionScheme===OBr)w=k.levelData;else if(t.supercompressionScheme===A2t)w=i.decode(k.levelData,k.uncompressedByteLength);else throw new Error("THREE.KTX2Loader: Unsupported supercompressionScheme.");let N;j$[r]===vX?N=new Float32Array(w.buffer,w.byteOffset,w.byteLength/Float32Array.BYTES_PER_ELEMENT):j$[r]===QN?N=new Uint16Array(w.buffer,w.byteOffset,w.byteLength/Uint16Array.BYTES_PER_ELEMENT):j$[r]===Pkt||j$[r]===Dkt?N=new Uint32Array(w.buffer,w.byteOffset,w.byteLength/Uint32Array.BYTES_PER_ELEMENT):N=w,a.push({data:N,width:g,height:b,depth:S})}const l=t.levelCount===0||a.length>1;let d;if(UBr.has(_7e[r]))d=t.pixelDepth===0?new aIr(a[0].data,t.pixelWidth,t.pixelHeight):new cIr(a[0].data,t.pixelWidth,t.pixelHeight,t.pixelDepth),d.minFilter=l?gkt:ihe,d.magFilter=ihe,d.generateMipmaps=t.levelCount===0;else{if(t.pixelDepth>0)throw new Error("THREE.KTX2Loader: Unsupported pixelDepth.");d=new Tkt(a,t.pixelWidth,t.pixelHeight),d.minFilter=l?jye:zR,d.magFilter=zR}return d.mipmaps=a,d.type=j$[r],d.format=_7e[r],d.colorSpace=M6t(t),d.needsUpdate=!0,Promise.resolve(d)}function M6t(t){const r=t.dataFormatDescriptor[0];return r.colorPrimaries===MBr?r.transferFunction===S2t?hv:bE:r.colorPrimaries===LBr?r.transferFunction===S2t?qBr:zBr:r.colorPrimaries===RBr?B1t:(console.warn(`THREE.KTX2Loader: Unsupported color primaries, "${r.colorPrimaries}"`),B1t)}let JBr="/";function L6t(t){return t.startsWith("/")||t.startsWith("http")||t.startsWith("data:")||t.startsWith("blob:")?t:JBr+t}const Oee=new pIr;Oee.setURLModifier(L6t);new hkt(Oee);const j6t=new Qjr(Oee);j6t.setDecoderPath("/jsm/libs/draco/gltf/");const B6t=new gw(Oee);B6t.setTranscoderPath("/jsm/libs/basis/");const fU=new Yjr(Oee);fU.setDRACOLoader(j6t);fU.setKTX2Loader(B6t);fU.setMeshoptDecoder(Gjr);function Fee(t){return L6t(t)}const Vpe=new Map;async function $6t(t,r){let i=Vpe.get(t);!i&&r&&(i=Promise.resolve(r),Vpe.set(t,i)),i||(i=fetch(Fee(t)).then(async a=>{if(!a.ok)throw new Error(`Failed to load Gaussian splat: ${t} (${a.status} ${a.statusText})`);return new Uint8Array(await a.arrayBuffer())}),Vpe.set(t,i));try{const[{SplatMesh:a},l]=await Promise.all([Xo(()=>import("./spark.module-CjQpY2Op.js"),__vite__mapDeps([45,6,3,2,4,1,8,9,10,11])),i]),d=new a({fileBytes:l,fileName:t,raycastable:!0});await d.initialized,CZ(d,"gaussianSplat",{src:t,numSplats:d.numSplats});const _=d.getBoundingBox();if(!_.isEmpty()){const g=_.getSize(new Tc).multiplyScalar(1.5),b=_.getCenter(new Tc),S=new NA(new fkt(g.x,g.y,g.z));S.name="__vgai_splat_bounds",S.position.copy(b),S.visible=!1,S.raycast=()=>{},CZ(S,"engineInternal",!0),d.add(S)}return d}catch(a){throw Vpe.delete(t),a}}const Zhe=1.2,q6t=.001;function pLe(t){const r=new Tc(Math.sin(t),0,Math.cos(t)),a=new Tc(0,1,0).clone().cross(r).normalize(),l=r.clone().cross(a).normalize();return{direction:r,right:a,up:l}}function z6t(){return{minRight:Number.POSITIVE_INFINITY,maxRight:Number.NEGATIVE_INFINITY,minUp:Number.POSITIVE_INFINITY,maxUp:Number.NEGATIVE_INFINITY,minDepth:Number.POSITIVE_INFINITY,maxDepth:Number.NEGATIVE_INFINITY}}function RUe(t){return t.maxRight<t.minRight}function WBr(t){t.minRight=Number.POSITIVE_INFINITY,t.maxRight=Number.NEGATIVE_INFINITY,t.minUp=Number.POSITIVE_INFINITY,t.maxUp=Number.NEGATIVE_INFINITY,t.minDepth=Number.POSITIVE_INFINITY,t.maxDepth=Number.NEGATIVE_INFINITY}function U6t(t,r,i){const a=r.dot(i.right),l=r.dot(i.up),d=r.dot(i.direction);a<t.minRight&&(t.minRight=a),a>t.maxRight&&(t.maxRight=a),l<t.minUp&&(t.minUp=l),l>t.maxUp&&(t.maxUp=l),d<t.minDepth&&(t.minDepth=d),d>t.maxDepth&&(t.maxDepth=d)}function HBr(t,r){if(RUe(t))throw new Error("Asset preview cannot frame an empty projected span.");return new Tc().addScaledVector(r.right,(t.minRight+t.maxRight)/2).addScaledVector(r.up,(t.minUp+t.maxUp)/2).addScaledVector(r.direction,(t.minDepth+t.maxDepth)/2)}function V6t(t,r,i,a=Zhe){const l=Math.max(r,t/i,q6t)*a;return{halfHeight:l,halfWidth:l*i}}function GBr(t,r,i=Zhe){if(RUe(t))throw new Error("Asset preview cannot frame an empty projected span.");return V6t((t.maxRight-t.minRight)/2,(t.maxUp-t.minUp)/2,r,i)}function QBr(t){if(t.length===0)throw new Error("Asset preview cannot union an empty set of frames.");let r=0,i=0;for(const a of t)r=Math.max(r,a.halfWidth),i=Math.max(i,a.halfHeight);return{halfWidth:r,halfHeight:i}}function KBr(t,r,i,a,l,d){const _=Math.max(a*l,q6t);let g=_,b=_;const S=new Tc;for(const k of t)S.copy(k).sub(r),g=Math.max(g,Math.abs(S.dot(i.right))+_),b=Math.max(b,Math.abs(S.dot(i.up))+_);return g=Math.max(g,b*d),b=Math.max(b,g/d),{halfWidth:g,halfHeight:b}}function YBr(t){if(t.length===0)throw new Error("Asset preview cannot centre a bone-zoom crop on zero anchors.");const r=new Tc;for(const i of t)r.add(i);return r.multiplyScalar(1/t.length)}function XBr(t,r){const i=t.position.dot(r.right),a=t.position.dot(r.up),l=t.position.dot(r.direction),d=t.zoom||1;return{minRight:i+t.left/d,maxRight:i+t.right/d,minUp:a+t.bottom/d,maxUp:a+t.top/d,minDepth:l-t.far,maxDepth:l-t.near}}function ZBr(t,r){return RUe(t)?!1:t.maxRight>=r.minRight&&t.minRight<=r.maxRight&&t.maxUp>=r.minUp&&t.minUp<=r.maxUp&&t.maxDepth>=r.minDepth&&t.minDepth<=r.maxDepth}function MUe(t,r,i,a,l){const d=new $ye(-i.halfWidth,i.halfWidth,i.halfHeight,-i.halfHeight,.01,l);return d.position.copy(t).addScaledVector(r.direction,a),d.up.copy(r.up),d.lookAt(t),d.updateProjectionMatrix(),d.updateMatrixWorld(!0),d}const e$r={F:["11111","10000","10000","11110","10000","10000","10000"],R:["11110","10001","10001","11110","10100","10010","10001"],O:["01110","10001","10001","10001","10001","10001","01110"],N:["10001","11001","11001","10101","10011","10011","10001"],T:["11111","00100","00100","00100","00100","00100","00100"],I:["11111","00100","00100","00100","00100","00100","11111"],G:["01110","10001","10000","10111","10001","10001","01110"],H:["10001","10001","10001","11111","10001","10001","10001"],P:["11110","10001","10001","11110","10000","10000","10000"],3:["11110","00001","00001","01110","00001","00001","11110"],"/":["00001","00010","00100","00100","01000","10000","10000"],4:["00010","00110","01010","10010","11111","00010","00010"],A:["01110","10001","10001","11111","10001","10001","10001"],B:["11110","10001","10001","11110","10001","10001","11110"],C:["01111","10000","10000","10000","10000","10000","01111"],D:["11110","10001","10001","10001","10001","10001","11110"],E:["11111","10000","10000","11110","10000","10000","11111"],K:["10001","10010","10100","11000","10100","10010","10001"],L:["10000","10000","10000","10000","10000","10000","11111"],M:["10001","11011","10101","10101","10001","10001","10001"],Q:["01110","10001","10001","10001","10101","10010","01101"],S:["01111","10000","10000","01110","00001","00001","11110"],U:["10001","10001","10001","10001","10001","10001","01110"],Z:["11111","00001","00010","00100","01000","10000","11111"],J:["00111","00010","00010","00010","00010","10010","01100"],V:["10001","10001","10001","10001","10001","01010","00100"],W:["10001","10001","10001","10101","10101","11011","10001"],X:["10001","10001","01010","00100","01010","10001","10001"],Y:["10001","10001","01010","00100","00100","00100","00100"],0:["01110","10001","10011","10101","11001","10001","01110"],1:["00100","01100","00100","00100","00100","00100","01110"],2:["01110","10001","00001","00010","00100","01000","11111"],5:["11111","10000","11110","00001","00001","10001","01110"],6:["00110","01000","10000","11110","10001","10001","01110"],7:["11111","00001","00010","00100","01000","01000","01000"],8:["01110","10001","10001","01110","10001","10001","01110"],9:["01110","10001","10001","01111","00001","00010","01100"],"-":["00000","00000","00000","11111","00000","00000","00000"],"+":["00000","00100","00100","11111","00100","00100","00000"],"<":["00010","00100","01000","10000","01000","00100","00010"],">":["01000","00100","00010","00001","00010","00100","01000"]};function J6t(t,r,i){const a=Math.max(1,Math.floor(Math.min(r,i)/128)),l=a*3;return{width:t.length*a*6-a+l*2,height:a*7+l*2}}function GR(t,r,i,a,l,d,_="normal"){const g=Math.max(1,Math.floor(Math.min(l,d)/128)),b=g*3,S=g*6,k=r.length*S-g+b*2,w=g*7+b*2;t.fillStyle=_==="warning"?"rgba(154, 24, 24, 0.92)":"rgba(0, 0, 0, 0.62)",t.fillRect(i,a,k,w),t.fillStyle="#ffffff";for(let N=0;N<r.length;N++){const P=e$r[r[N]];if(P)for(let j=0;j<P.length;j++)for(let J=0;J<P[j].length;J++)P[j][J]==="1"&&t.fillRect(i+b+N*S+J*g,a+b+j*g,g,g)}}const t$r=.45,W6t=.25,ege=new WeakMap;function Ree(t,r){let i=ege.get(r);i||(i=G4t(r),ege.set(r,i)),t.environment=i.texture,t.environmentIntensity=t$r}function M0e(t){const r=ege.get(t);r&&(ege.delete(t),r.dispose())}const EZ=["front","right","top","perspective"],C2t=24;function H6t(t){const r=t;return typeof r=="object"&&r!==null&&typeof r.bone=="string"&&r.bone.length>0&&(r.axis==="x"||r.axis==="y"||r.axis==="z")&&typeof r.radians=="number"&&Number.isFinite(r.radians)}function G6t(t){const r=t;return typeof r=="object"&&r!==null&&typeof r.morph=="string"&&r.morph.length>0&&typeof r.influence=="number"&&Number.isFinite(r.influence)}function Q6t(t){const r=t;return typeof r=="object"&&r!==null&&typeof r.bone=="string"&&r.bone.length>0&&(r.axis==="x"||r.axis==="y"||r.axis==="z")&&typeof r.meters=="number"&&Number.isFinite(r.meters)}function r$r(t){return H6t(t)||G6t(t)||Q6t(t)}function n$r(t,r){const i=t;if(typeof i!="object"||i===null||typeof i.label!="string"||!/^[a-z0-9][a-z0-9-]*$/i.test(i.label)||i.pose!==void 0&&(typeof i.pose!="string"||!r.has(i.pose)))return!1;if(i.view==="turntable")return typeof i.yaw=="number"&&Number.isFinite(i.yaw);if(i.view==="bone-zoom"){const a=i;return a.yaw!==void 0&&(typeof a.yaw!="number"||!Number.isFinite(a.yaw))?!1:Array.isArray(a.bones)&&a.bones.length>0&&a.bones.every(l=>typeof l=="string"&&l.length>0)&&typeof a.spanFraction=="number"&&Number.isFinite(a.spanFraction)&&a.spanFraction>0&&a.spanFraction<=2}return!1}function i$r(t){const r=b=>{throw new Error(`Asset preview shot-set definition is invalid: ${b}`)},i=t;(typeof i!="object"||i===null)&&r("expected an object.");const a=i;(typeof a.name!="string"||!/^[a-z0-9][a-z0-9-]*$/i.test(a.name))&&r("`name` must be a short alphanumeric/dash identifier."),a.requiredBones!==void 0&&(!Array.isArray(a.requiredBones)||a.requiredBones.some(b=>typeof b!="string"||b.length===0))&&r("`requiredBones` must be an array of non-empty bone names."),a.rigRequirementHint!==void 0&&typeof a.rigRequirementHint!="string"&&r("`rigRequirementHint` must be a string.");const l=a.poses??{};(typeof l!="object"||l===null||Array.isArray(l))&&r("`poses` must be an object of named pose-step lists.");for(const[b,S]of Object.entries(l))(!Array.isArray(S)||!S.every(r$r))&&r(`pose ${JSON.stringify(b)} must be an array of {bone, axis, radians} and/or {morph, influence}.`);const d=new Set(Object.keys(l));(!Array.isArray(a.shots)||a.shots.length===0||a.shots.length>C2t)&&r(`\`shots\` must list 1-${C2t} shots.`);const _=a.shots,g=new Set;for(const b of _){n$r(b,d)||r('every shot needs a label plus either {view:"turntable", yaw} or {view:"bone-zoom", bones, spanFraction, yaw?}, with every `yaw` a finite number of radians and `pose` naming a declared pose.');const{label:S}=b;g.has(S)&&r(`duplicate shot label ${JSON.stringify(S)}.`),g.add(S)}return a}const s$r=512,E2t=64,T2t=1024,dU=2106410,o$r=25e3,hR=64*1024*1024;function ww(t){const r=t??s$r;if(!Number.isInteger(r)||r<E2t||r>T2t)throw new Error(`Asset preview dimensions must be integers from ${E2t} to ${T2t}.`);return r}function AS(t){const r=t.toDataURL("image/png"),i=r.indexOf(",");return i>=0?r.slice(i+1):r}function GDn(t){const r=new Set;t.traverse(a=>r.add(a));let i=t;return t.traverse(a=>{const l=a;if(!(!l.isSkinnedMesh||!l.skeleton))for(const d of l.skeleton.bones){if(!d||r.has(d))continue;const _=new Set;for(let b=i;b;b=b.parent)_.add(b);let g=null;for(let b=d;b;b=b.parent)if(_.has(b)){g=b;break}g&&g!==i&&(i=g,i.traverse(b=>r.add(b)))}}),i}function hz(t){const r=new Set;t.traverse(_=>{r.add(_)});const i=c$r(t,r),a=l$r(t,i),l=a$r(t);a.matrix.copy(l),a.matrix.decompose(a.position,a.quaternion,a.scale),a.matrixAutoUpdate=!1,a.matrixWorld.copy(l),a.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,a.visible=!0;const d=[];a.traverse(_=>{_!==a&&_.userData.editorHelper&&d.push(_)});for(const _ of d)_.parent?.remove(_);return a}function a$r(t){const r=[];let i=t;for(;i;)r.push(i),i=i.parent;const a=r.findIndex(g=>!g.matrixWorldAutoUpdate),l=a>=0?r[a].matrixWorld.clone():new SS,d=new SS,_=a>=0?a-1:r.length-1;for(let g=_;g>=0;g--){const b=r[g];b.matrixAutoUpdate?d.compose(b.position,b.quaternion,b.scale):d.copy(b.matrix),l.multiply(d)}return l}function c$r(t,r){const i=new Map,a=new Map;let l=null;const d=()=>{if(l)return l;const _=new Map;for(const g of r){const b=g;if(!b.isBone||b.name==="")continue;const S=_.get(b.name);S?S.push(b):_.set(b.name,[b])}return l=_,_};if(t.traverse(_=>{const g=_;if(!g.isSkinnedMesh)return;const b=g.name||g.uuid;for(const S of g.skeleton.bones){if(S&&r.has(S)||S&&i.has(S))continue;const k=S?d().get(S.name)??[]:[];if(k.length===1){i.set(S,k[0]);continue}const w=S?.name||"(unnamed bone)";a.set(`${b} -> ${w}`,{mesh:b,bone:w,sameNamed:k.length})}}),a.size>0){const _=[...a.values()].map(({mesh:g,bone:b,sameNamed:S})=>S>1?`${g} -> ${b} (${S} bones inside the selection share that name — which one is meant is ambiguous)`:`${g} -> ${b} (no bone of that name inside the selection)`).join("; ");throw new Error(`Asset preview selection references bones outside its hierarchy that it cannot bind to: ${_}. Select the complete skeleton root — the node that owns both the skinned mesh and its bones.`)}return i}function l$r(t,r=new Map){const i=new Map,a=[],l=_=>{const g=u$r(_);i.set(_,g),f$r(_,g),_.isSkinnedMesh&&a.push([_,g]);const b=_;if(b.isLOD){const S=g,k=b.levels.filter(P=>P.object.visible),w=k.length===1?k[0]:b.levels[0];S.autoUpdate=!1;const N=new Set(b.levels.map(P=>P.object));for(const P of b.levels){if(m7e(P.object))continue;const j=l(P.object);j.visible=b.autoUpdate?P===w:P.object.visible,S.addLevel(j,P.distance,P.hysteresis)}for(const P of _.children)!N.has(P)&&!m7e(P)&&g.add(l(P))}else for(const S of _.children)m7e(S)||g.add(l(S));return g},d=l(t);for(const[_,g]of a){const b=_.skeleton.clone();b.bones=_.skeleton.bones.map(S=>{const k=i.get(r.get(S)??S);if(!k?.isBone)throw new Error(`Asset preview could not map skeleton bone: ${S.name||S.uuid}`);return k}),g.skeleton=b,g.bindMode=_.bindMode,g.bindMatrix.copy(_.bindMatrix),g.bindMatrixInverse.copy(_.bindMatrixInverse)}return d}function u$r(t){const r=t;if(r.isSkinnedMesh)return new bkt(r.geometry,r.material);const i=t;if(i.isInstancedMesh){const g=new Gqe(i.geometry,i.material,i.count);return g.instanceMatrix.copy(i.instanceMatrix),g.instanceColor=i.instanceColor?i.instanceColor.clone():null,g.morphTexture=i.morphTexture,g}const a=t;if(a.isMesh)return new NA(a.geometry,a.material);const l=t;if(t.isLineSegments)return new Akt(l.geometry,l.material);if(t.isLineLoop)return new xkt(l.geometry,l.material);if(l.isLine)return new Skt(l.geometry,l.material);const d=t;if(d.isPoints)return new Yqe(d.geometry,d.material);const _=t;return _.isSprite?new _Ir(_.material):t.isLOD?new mIr:t.isBone?new wkt:t.isGroup?new SP:new Lye}function f$r(t,r){r.name=t.name,r.up.copy(t.up),r.position.copy(t.position),r.quaternion.copy(t.quaternion),r.scale.copy(t.scale),r.matrix.copy(t.matrix),r.matrixWorld.copy(t.matrixWorld),r.matrixAutoUpdate=t.matrixAutoUpdate,r.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,r.visible=t.visible,r.castShadow=t.castShadow,r.receiveShadow=t.receiveShadow,r.frustumCulled=!1,r.renderOrder=t.renderOrder,r.layers.set(0),r.animations=[...t.animations];const i=t,a=r;i.morphTargetInfluences&&(i.morphTargetDictionary&&(a.morphTargetDictionary={...i.morphTargetDictionary}),a.morphTargetInfluences=[...i.morphTargetInfluences]);const l=t;l.isSprite&&r.center.copy(l.center)}function m7e(t){const r=1<<NUe;return!!(t.userData.editorHelper||t.userData.editorIcon||(t.layers.mask&r)!==0)}function pU(t){const r=new Set;t.traverse(i=>{const a=i;a.isSkinnedMesh&&r.add(a.skeleton);const l=i;if(l.isInstancedMesh){const d=l.morphTexture;l.morphTexture=null,l.dispose(),l.morphTexture=d}});for(const i of r)i.dispose()}function QDn(t){const r=t();let i;try{i=hz(r.root),i.animations=[...r.animations??r.root.animations]}catch(l){try{r.dispose()}catch(d){throw new AggregateError([l,d],"Object3D preview snapshot creation and source cleanup both failed.")}throw l}let a=!1;return{root:i,dispose(){if(a)return;a=!0;const l=[];try{pU(i)}catch(d){l.push(d)}try{r.dispose()}catch(d){l.push(d)}if(l.length===1)throw l[0];if(l.length>1)throw new AggregateError(l,"Object3D preview snapshot cleanup failed.")}}}function LP(t,r="front"){LUe(t);const i=d$r(t,r);if(i.isEmpty())throw new Error("Asset preview source has no renderable bounds.");const a=i.getCenter(new Tc),l=i.getSize(new Tc);return{center:a,size:l,radius:Math.max(l.length()/2,.001)}}function LUe(t){t.parent?.updateWorldMatrix(!0,!1),t.updateMatrixWorld(!0)}function d$r(t,r){const i=new xS;return jUe(t,L0e(r),r==="perspective",a=>i.expandByPoint(a)),i}function p$r(t,r){const i=r.map(()=>z6t());return r.length===0||(LUe(t),jUe(t,r[0],!1,a=>{for(let l=0;l<r.length;l++)U6t(i[l],a,r[l])})),i}function _$r(t,r){const i=r.map(()=>0);let a=0;if(r.length===0)return{framed:i,total:a};LUe(t);const l=r.map(()=>z6t());let d=-1;const _=()=>{if(!(d<0)){a++;for(let g=0;g<r.length;g++)ZBr(l[g],r[g].window)&&i[g]++,WBr(l[g])}};return jUe(t,r[0].basis,!1,(g,b)=>{b!==d&&(_(),d=b);for(let S=0;S<r.length;S++)U6t(l[S],g,r[S].basis)}),_(),{framed:i,total:a}}function jUe(t,r,i,a){const l=new xS,d=new Tc,_=new Tc,g=new SS;let b=0;const S=k=>{if(!k.visible||k!==t&&R0e(k))return;if(Z8(k,"gaussianSplat")){l.copy(k.getBoundingBox()).applyMatrix4(k.matrixWorld);const j=b++;for(const J of[l.min.x,l.max.x])for(const X of[l.min.y,l.max.y])for(const G of[l.min.z,l.max.z])a(d.set(J,X,G),j)}const w=k;if(w.isLOD&&w.levels.length>0){const j=new Set(w.levels.map(J=>J.object));for(const J of w.levels)S(J.object);for(const J of k.children)j.has(J)||S(J);return}const N=k;if(N.isSprite&&N.material.visible){if(i&&!N.material.sizeAttenuation)throw new Error("Asset preview cannot deterministically frame a perspective Sprite with sizeAttenuation disabled.");const j=new Tc().setFromMatrixPosition(N.matrixWorld),J=new Tc().setFromMatrixScale(N.matrixWorld),X=Math.cos(N.material.rotation),G=Math.sin(N.material.rotation),ee=b++;for(const xe of[-N.center.x,1-N.center.x])for(const ue of[-N.center.y,1-N.center.y]){const fe=xe*Math.abs(J.x),se=ue*Math.abs(J.y),de=X*fe-G*se,ge=G*fe+X*se;a(j.clone().addScaledVector(r.right,de).addScaledVector(r.up,ge),ee)}}const P=N.isSprite?void 0:k.geometry;if(P){const j=P.getAttribute("position");if(j){const J=m$r(k,P,j.count),X=h$r(k,J.length),G=Math.ceil(J.length/X),ee=k;if(ee.isInstancedMesh){const xe=new NA(ee.geometry,ee.material);for(let ue=0;ue<ee.count;ue++)ee.getMatrixAt(ue,g),ee.morphTexture&&ee.getMorphAt(ue,xe),J.forEach((fe,se)=>{xe.getVertexPosition(fe,_),_.applyMatrix4(g).applyMatrix4(ee.matrixWorld),a(_,b+Math.floor(se/X))}),b+=G}else{const xe=k;J.forEach((ue,fe)=>{xe.isMesh?xe.getVertexPosition(ue,_):y$r(k,P,ue,_),_.applyMatrix4(k.matrixWorld),a(_,b+Math.floor(fe/X))}),b+=G}}}for(const j of k.children)S(j)};S(t)}function m$r(t,r,i){const a=t.material;if(!a)return[];const l=r.index?.count??i,d=Math.max(0,r.drawRange.start),_=Math.min(l,Number.isFinite(r.drawRange.count)?d+r.drawRange.count:l),g=[];if(Array.isArray(a))for(const S of r.groups){const k=S.materialIndex??0;if(!a[k]?.visible)continue;const w=Math.max(d,S.start),N=Math.min(_,S.start+S.count);N>w&&g.push([w,N])}else a.visible&&_>d&&g.push([d,_]);const b=[];for(const[S,k]of g){const w=g$r(t,k-S);for(let N=S;N<S+w;N++)b.push(r.index?r.index.getX(N):N)}return b}function h$r(t,r){return t.isMesh?3:t.isLineSegments?2:t.isLine?Math.max(r,1):1}function g$r(t,r){return t.isMesh?r-r%3:t.isLineSegments?r-r%2:t.isLine?r>=2?r:0:r}function y$r(t,r,i,a){const l=r.getAttribute("position");a.fromBufferAttribute(l,i);const d=r.morphAttributes.position,_=t.morphTargetInfluences;if(!d||!_)return a;const g=a.clone(),b=new Tc,S=new Tc;for(let k=0;k<d.length;k++){const w=_[k]??0;w!==0&&(S.fromBufferAttribute(d[k],i),r.morphTargetsRelative||S.sub(g),b.addScaledVector(S,w))}return a.add(b)}function v$r(t,r,i){const{center:a,size:l,radius:d}=r;let _=l.x,g=l.y;const b=L0e(t),{direction:S,up:k}=b;t==="right"?_=l.z:t==="top"&&(_=l.x,g=l.z);const w=V6t(_/2,g/2,i);return MUe(a,{direction:S,right:b.right,up:k},w,d*3+1,d*10+10)}function tge(t,r,i,a){const l=new Bye(35,r,.01,t.radius*20+20),d=bb.degToRad(l.fov/2),_=Math.atan(Math.tan(d)*r),g=L0e("perspective"),b=i?.clone().normalize()??g.direction,S=Math.abs(b.y)>.999?new Tc(0,0,1):new Tc(0,1,0),k=i?S.clone().cross(b).normalize():g.right,w=i?b.clone().cross(k).normalize():g.up,N=t.size.clone().multiplyScalar(.5);let P=0;for(const j of[-1,1])for(const J of[-1,1])for(const X of[-1,1]){const G=new Tc(j*N.x,J*N.y,X*N.z),ee=G.dot(b);P=Math.max(P,ee+Math.abs(G.dot(k))*Zhe/Math.tan(_),ee+Math.abs(G.dot(w))*Zhe/Math.tan(d))}return l.position.copy(t.center).addScaledVector(b,Math.max(a??P,.01)),l.lookAt(t.center),l.updateProjectionMatrix(),l.updateMatrixWorld(!0),l}function L0e(t){const r=t==="front"?new Tc(0,0,1):t==="right"?new Tc(1,0,0):t==="top"?new Tc(0,1,0):new Tc(1,.72,1).normalize(),a=(t==="top"?new Tc(0,0,-1):new Tc(0,1,0)).clone().cross(r).normalize(),l=r.clone().cross(a).normalize();return{direction:r,right:a,up:l}}function BUe(t,r,i){return t==="perspective"?tge(r,i):v$r(t,r,i)}function k2t(t,r,i){return tge(t,r,i)}function K6t(t,r,i,a){const l=i.map(pLe),d=p$r(t,l),_=QBr(d.map(b=>GBr(b,a))),g=new Map;return i.forEach((b,S)=>{g.set(b,MUe(HBr(d[S],l[S]),l[S],_,r.radius*3+1,r.radius*10+10))}),g}function Y6t(t,r,i={}){const a=ww(i.width),l=ww(i.height),d=i.background??"neutral",_=hz(t);let g=null;try{const b=LP(_,"perspective"),S=TZ(_,b),k=UP(new $P({antialias:!0,alpha:!0,preserveDrawingBuffer:!0}));g=k,k.setPixelRatio(1),k.outputColorSpace=hv,k.toneMapping=u9,k.toneMappingExposure=1,k.setClearColor(dU,d==="transparent"?0:1),k.setSize(a,l,!1),Ree(S,k);const w=Math.atan2(r[0],r[2]),N=a/l,P=se=>new Tc(Math.sin(se),.72,Math.cos(se)).normalize(),j=[w,w+Math.PI,w-Math.PI/2,w+Math.PI/2],J=K6t(_,b,j,N),X=[{label:"front",camera:J.get(j[0])},{label:"back",camera:J.get(j[1])},{label:"left",camera:J.get(j[2])},{label:"right",camera:J.get(j[3])},{label:"quarter-left",camera:k2t(b,N,P(w-Math.PI/4))},{label:"quarter-right",camera:k2t(b,N,P(w+Math.PI/4))}],G=[],ee=2,xe=3,ue=document.createElement("canvas");ue.width=a*ee,ue.height=l*xe;const fe=ue.getContext("2d");if(!fe)throw new Error("Unable to create the source-review contact sheet.");return X.forEach(({label:se,camera:de},ge)=>{k.render(S,de),G.push({label:se,base64:AS(k.domElement),mimeType:"image/png"});const qe=ge%ee*a,tt=Math.floor(ge/ee)*l;fe.drawImage(k.domElement,qe,tt,a,l);const Ct=se==="quarter-left"?"3/4-L":se==="quarter-right"?"3/4-R":se.toUpperCase();GR(fe,Ct,qe,tt,a,l)}),{width:a,height:l,shots:G,contactSheet:{width:a*ee,height:l*xe,base64:AS(ue),mimeType:"image/png"}}}finally{g&&M0e(g),g?.dispose(),g?.forceContextLoss(),pU(_)}}function b$r(t,r,i,a,l){const d=YBr(t),_=KBr(t,d,r,i,a,l),g=i*3+1;return MUe(d,r,_,g,g+i*4+1)}function I2t(t,r){const i=new Map;t.traverse(_=>{const g=_;g.isBone&&_.name&&i.set(_.name,g)});const a=r.requiredBones??[],l=a.filter(_=>!i.has(_)),d=r.rigRequirementHint?` (${r.rigRequirementHint})`:"";if(a.length>0&&i.size===0)throw new Error(`Asset preview '--shots ${r.name}' requires a rigged GLB${d}, but this model has no skeleton at all. Required joints: ${a.join(", ")}.`);if(l.length>0)throw new Error(`Asset preview '--shots ${r.name}' requires joints this GLB's skeleton does not have${d}. Missing joint(s): ${l.join(", ")}.`);return i}function A$r(t,r,i){const a=i.filter(G6t);for(const l of i)if(H6t(l)){const d=r.get(l.bone);if(!d)continue;l.axis==="x"?d.rotateX(l.radians):l.axis==="y"?d.rotateY(l.radians):d.rotateZ(l.radians)}else if(Q6t(l)){const d=r.get(l.bone);if(!d)continue;l.axis==="x"?d.translateX(l.meters):l.axis==="y"?d.translateY(l.meters):d.translateZ(l.meters)}a.length!==0&&t.traverse(l=>{const d=l,_=d.morphTargetDictionary,g=d.morphTargetInfluences;if(!(!_||!g))for(const{morph:b,influence:S}of a){const k=_[b];k!==void 0&&(g[k]=S)}})}function rge(t){let r=null;return t.traverse(i=>{r||(r=ame(i.userData.forward))}),r??[0,0,1]}function _Le(t,r){const i=new SP;return i.rotation.y=PUe(r),i.add(t),i.updateMatrixWorld(!0),i}function TZ(t,r){const i=new Mye;i.add(t),i.add(new gIr(16777215,3489874,1.8*W6t));const a=new kq(16777215,2.2);a.position.copy(r.center).addScaledVector(new Tc(1,1.5,1),r.radius*3),i.add(a);const l=new kq(12572671,.8);l.position.copy(r.center).addScaledVector(new Tc(-1,.5,-.7),r.radius*2),i.add(l);const d=new kq(16773596,.45);return d.position.copy(r.center).addScaledVector(new Tc(.3,-1,.4),r.radius*2),i.add(d),i}let aR=null;function D2t(){const t=aR;aR=null,t&&(M0e(t),t.dispose(),t.forceContextLoss())}function S$r(){if(aR?.getContext().isContextLost()&&D2t(),!aR){const t=UP(new $P({antialias:!0,alpha:!0,preserveDrawingBuffer:!0}));aR=t,t.domElement.addEventListener("webglcontextlost",()=>{aR===t&&D2t()})}return aR}function j0e(t,r={}){let i=!1;if(t.traverse(g=>{Z8(g,"gaussianSplat")&&(i=!0)}),i)throw new Error("Gaussian-splat capture requires the async project-asset capture path so Spark can sort each view.");const a=ww(r.width),l=ww(r.height),d=r.background??"neutral",_=hz(t);try{const g=rge(t);r.pose&&w$r(_,r.pose);const b=_Le(_,g),S=$Ue(g),k=LP(b,"perspective"),w=TZ(b,k),N=S$r();if(N.setPixelRatio(1),N.outputColorSpace=hv,N.toneMapping=u9,N.toneMappingExposure=1,N.setClearColor(dU,d==="transparent"?0:1),Ree(w,N),r.camera)return C$r(N,w,tge(k,a/l,P2t(r.camera),r.camera.distance),a,l,r.camera,S);const P=new Map;for(const J of EZ)P.set(J,BUe(J,LP(b,J),a/l));const j=tge(k,a/l,P2t({azimuthDegrees:30,elevationDegrees:-60}));return Z6t(N,w,P,a,l,S,j)}finally{pU(_)}}function x$r(t,r,i){const a=X6t(r,i.yawDegrees);if(!a)return t;const l=document.createElement("canvas");l.width=t.width,l.height=t.height;const d=l.getContext("2d");if(!d)return t;d.drawImage(t,0,0);const _=J6t(a.text,t.width,t.height),g=a.edge==="left"?0:t.width-_.width;return GR(d,a.text,g,t.height-_.height,t.width,t.height),l}function $Ue(t){const r=PUe(t);return{forward:[t[0],t[1],t[2]],yawDegrees:Math.round(bb.radToDeg(r))}}function w$r(t,r){if(!Number.isFinite(r.timeSeconds)||r.timeSeconds<0)throw new Error(`Asset preview pose time must be a finite number of seconds >= 0, got ${r.timeSeconds}.`);const i=t.animations??[],a=i.find(d=>d.name===r.clip);if(!a){const d=i.map(_=>`'${_.name}'`).join(", ");throw new Error(`Asset preview pose clip '${r.clip}' not found on the subject. `+(d?`Its clips are: ${d}.`:"The subject carries no animation clips at all — clips live on the model root (GLB animations, or a builder module’s `root.animations`)."))}const l=new hIr(t);l.clipAction(a).play(),l.update(r.timeSeconds),t.updateMatrixWorld(!0)}function P2t(t){const r=bb.degToRad(t.azimuthDegrees),i=bb.degToRad(t.elevationDegrees);return new Tc(Math.sin(r)*Math.cos(i),Math.sin(i),Math.cos(r)*Math.cos(i)).normalize()}function C$r(t,r,i,a,l,d,_){t.setSize(a,l,!1),t.render(r,i);const g={view:"perspective",base64:AS(t.domElement),mimeType:"image/png"},b=document.createElement("canvas");b.width=a,b.height=l;const S=b.getContext("2d");if(!S)throw new Error("Unable to create the asset preview contact sheet.");S.drawImage(t.domElement,0,0,a,l);const k=`AZ ${Math.round(d.azimuthDegrees)} EL ${Math.round(d.elevationDegrees)}`+(d.distance===void 0?"":` D ${Math.round(d.distance)}`);return GR(S,k,0,0,a,l),{width:a,height:l,orientation:_,views:[g],contactSheet:{width:a,height:l,base64:AS(b),mimeType:"image/png"}}}function X6t(t,r){if(t==="perspective")return null;const i=bb.degToRad(r),a=L0e(t).right.applyAxisAngle(new Tc(0,1,0),-i),l=[["X",new Tc(1,0,0)],["Y",new Tc(0,1,0)],["Z",new Tc(0,0,1)]];for(const[d,_]of l){const g=a.dot(_);if(g>.99)return{text:`+${d}>`,edge:"right"};if(g<-.99)return{text:`<+${d}`,edge:"left"}}return{text:`YAW ${r}`,edge:"left"}}function Z6t(t,r,i,a,l,d,_){const g=[],b=_?[...EZ,"below"]:[...EZ],S=_?3:2,k=a*S,w=l*2,N=document.createElement("canvas");N.width=k,N.height=w;const P=N.getContext("2d");if(!P)throw new Error("Unable to create the asset preview contact sheet.");t.getClearAlpha()>0&&(P.fillStyle=`#${new vE(dU).getHexString()}`,P.fillRect(0,0,k,w)),t.setSize(a,l,!1),b.forEach((J,X)=>{const G=J==="below"?_:i.get(J);if(!G)return;t.render(r,G),g.push({view:J,base64:AS(J==="below"?t.domElement:x$r(t.domElement,J,d)),mimeType:"image/png"});const ee=X%S,xe=Math.floor(X/S),ue=ee*a,fe=xe*l;P.drawImage(t.domElement,ue,fe,a,l);const se=J==="perspective"?"3/4":J.toUpperCase();if(GR(P,se,ue,fe,a,l),J==="below")return;const de=X6t(J,d.yawDegrees);if(de){const ge=J6t(de.text,a,l),qe=de.edge==="left"?ue:ue+a-ge.width;GR(P,de.text,qe,fe+l-ge.height,a,l)}});const j={width:k,height:w,base64:AS(N),mimeType:"image/png"};return{width:a,height:l,orientation:d,views:g,contactSheet:j}}function E$r(t,r,i={}){let a=!1;if(t.traverse(S=>{Z8(S,"gaussianSplat")&&(a=!0)}),a)throw new Error("Gaussian-splat capture requires the async project-asset capture path so Spark can sort each view.");const l=ww(i.width),d=ww(i.height),_=i.background??"neutral",g=[];let b=null;try{r.traverse(w=>{w.visible&&OUe(w)&&(w.visible=!1,g.push(w))});const S=new Map;for(const w of EZ){const N=BUe(w,LP(t,w),l/d);N.layers.enableAll(),N.layers.disable(NUe),S.set(w,N)}const k=UP(new $P({antialias:!0,alpha:!0,preserveDrawingBuffer:!0}));return b=k,k.setPixelRatio(1),k.outputColorSpace=hv,k.toneMapping=u9,k.toneMappingExposure=1,k.setClearColor(dU,_==="transparent"?0:1),Z6t(k,r,S,l,d,$Ue([0,0,1]))}finally{for(const S of g)S.visible=!0;b?.dispose(),b?.forceContextLoss()}}function T$r(t,r,i){const a=t.pose===void 0?"":` under pose '${t.pose}'`,l=t.view==="bone-zoom"?`bone-zoom on ${t.bones.join(", ")} at yaw ${(t.yaw??0).toFixed(3)}`:`turntable at yaw ${t.yaw.toFixed(3)}`,d=t.view==="bone-zoom"?"Zoom anchors are read from the REST skeleton for every shot, so a pose that MOVES the anchor leaves the crop behind where the joint used to be: re-aim the shot (another joint or yaw), widen its spanFraction, or drop it.":"Check the shot yaw and the pose it renders under.";return{label:t.label,reason:"empty-frame",...t.view==="bone-zoom"?{bones:[...t.bones]}:{},...t.pose===void 0?{}:{pose:t.pose},message:`Asset preview '--shots ${r}' shot ${JSON.stringify(t.label)} (${l}${a}) framed NONE of the subject's ${i} rendered faces: the image is background only and proves nothing about the asset. ${d}`}}function k$r(t,r,i){const a=[],l=()=>{for(const d of a)pU(d);a.length=0};try{const d=hz(t);a.push(d);const _=I2t(d,r),g=rge(t),b=_Le(d,g),S=LP(b,"perspective"),k=TZ(b,S),w={subject:b,scene:k,framing:S},N=new Map;for(const ue of r.shots){if(ue.pose===void 0||N.has(ue.pose))continue;const fe=r.poses?.[ue.pose]??[],se=hz(t);a.push(se);const de=I2t(se,r);A$r(se,de,fe),se.updateMatrixWorld(!0);const ge=_Le(se,g),qe=LP(ge,"perspective");N.set(ue.pose,{subject:ge,scene:TZ(ge,qe),framing:qe})}const P=ue=>ue===void 0?w:N.get(ue),j=ue=>new Tc().setFromMatrixPosition(_.get(ue).matrixWorld),J=new Map;for(const ue of new Set(r.shots.filter(fe=>fe.view==="turntable").map(fe=>fe.pose??void 0))){const fe=P(ue),se=[...new Set(r.shots.filter(de=>de.view==="turntable"&&(de.pose??void 0)===ue).map(de=>de.yaw))];J.set(ue,K6t(fe.subject,fe.framing,se,i))}const X=r.shots.map(ue=>{const fe=P(ue.pose);if(ue.view==="turntable")return{label:ue.label,camera:J.get(ue.pose??void 0).get(ue.yaw),scene:fe.scene,stage:fe,basis:pLe(ue.yaw)};const se=ue.bones.find(ge=>!_.has(ge));if(se!==void 0)throw new Error(`Asset preview '--shots ${r.name}' shot ${JSON.stringify(ue.label)} zooms on a joint this GLB's skeleton does not have: ${se}. List it in the definition's requiredBones or fix the rig.`);const de=pLe(ue.yaw??0);return{label:ue.label,camera:b$r(ue.bones.map(j),de,S.radius,ue.spanFraction,i),scene:fe.scene,stage:fe,basis:de}}),G=[],ee=new Map,xe=new Map;X.forEach(({stage:ue},fe)=>{const se=xe.get(ue);se?se.push(fe):xe.set(ue,[fe])});for(const[ue,fe]of xe){const{framed:se,total:de}=_$r(ue.subject,fe.map(ge=>{const qe=X[ge];return{basis:qe.basis,window:XBr(qe.camera,qe.basis)}}));fe.forEach((ge,qe)=>{if(se[qe]!==0)return;const tt=T$r(r.shots[ge],r.name,de);ee.set(ge,tt),G.push(tt)})}return{shots:X.map(({label:ue,camera:fe,scene:se},de)=>{const ge=ee.get(de);return{label:ue,camera:fe,scene:se,...ge?{warning:ge}:{}}}),warnings:G,dispose:l}}catch(d){throw l(),d}}function qUe(t,r,i={}){const a=ww(i.width),l=ww(i.height),d=i.background??"neutral",_=k$r(t,r,a/l);let g=null;try{const b=UP(new $P({antialias:!0,alpha:!0,preserveDrawingBuffer:!0}));g=b,b.setPixelRatio(1),b.outputColorSpace=hv,b.toneMapping=u9,b.toneMappingExposure=1,b.setClearColor(dU,d==="transparent"?0:1),b.setSize(a,l,!1);for(const G of _.shots)Ree(G.scene,b);const S=[],k=2,w=Math.ceil(_.shots.length/k),N=a*k,P=l*w,j=document.createElement("canvas");j.width=N,j.height=P;const J=j.getContext("2d");if(!J)throw new Error("Unable to create the asset preview contact sheet.");_.shots.forEach(({label:G,camera:ee,scene:xe,warning:ue},fe)=>{b.render(xe,ee),S.push({label:G,base64:AS(b.domElement),mimeType:"image/png"});const se=fe%k,de=Math.floor(fe/k),ge=se*a,qe=de*l;J.drawImage(b.domElement,ge,qe,a,l),GR(J,ue?`${G.toUpperCase()} - EMPTY`:G.toUpperCase(),ge,qe,a,l,ue?"warning":"normal")});const X={width:N,height:P,base64:AS(j),mimeType:"image/png"};return{width:a,height:l,shots:S,warnings:_.warnings,contactSheet:X}}finally{g&&M0e(g),g?.dispose(),g?.forceContextLoss(),_.dispose()}}function I$r(t){const r=t.replace(/^\/?public(\/|$)/,"/");if(!r.startsWith("/")||r.startsWith("//")||r.includes("\\")||r.includes("?")||r.includes("#"))throw new Error("Model asset paths must be the served web path (project-root absolute, with public/ stripped): e.g. /models/generated/hero.glb");let i;try{i=decodeURIComponent(r)}catch{throw new Error("Asset Editor model path contains invalid URL encoding.")}if(i.split("/").some(d=>d==="."||d===".."))throw new Error("Asset Editor model paths cannot traverse outside the project root.");const a=globalThis.location?.origin??"http://localhost",l=new URL(r,a);if(l.origin!==a||!l.pathname.toLowerCase().match(/\.(?:glb|gltf|spz)$/))throw new Error("Asset Editor loads bounded, same-origin project .glb, .gltf, or .spz files only.");return l}async function eNt(t,r,i=hR){const a=await fetch(t,{signal:r});if(!a.ok)throw new Error(`Unable to load project model (${a.status} ${a.statusText}).`);const l=Number(a.headers.get("content-length"));if(Number.isFinite(l)&&l>i)throw new Error(`Asset Editor project models must be ${hR/1024/1024} MiB or less.`);if(!a.body){const k=await a.arrayBuffer();if(k.byteLength>i)throw new Error(`Asset Editor project models must be ${hR/1024/1024} MiB or less.`);return k}const d=a.body.getReader(),_=[];let g=0;try{for(;;){const{done:k,value:w}=await d.read();if(k)break;if(g+=w.byteLength,g>i)throw await d.cancel(),new Error(`Asset Editor project models must be ${hR/1024/1024} MiB or less.`);_.push(w)}}finally{d.releaseLock()}const b=new Uint8Array(g);let S=0;for(const k of _)b.set(k,S),S+=k.byteLength;return b.buffer}function N2t(t,r,i){return new Promise((a,l)=>{let d=!1;const _=b=>d?!1:(d=!0,i.removeEventListener("abort",g),b(),!0),g=()=>_(()=>l(i.reason));if(i.addEventListener("abort",g,{once:!0}),i.aborted){g();return}fU.parse(t,new URL(".",r).href,b=>{b.scene.animations=[...b.animations],_(()=>a(b.scene))||eO(b.scene)},b=>_(()=>l(b)))})}function D$r(t,r){if(t.includes("\\")||t.includes("?")||t.includes("#"))throw new Error("Asset Editor .gltf dependencies must be plain same-origin project paths.");const i=new URL(t,r);if(i.origin!==r.origin)throw new Error("Asset Editor .gltf dependencies must stay on the project origin.");return i}function P$r(t,r){if(typeof t.mimeType=="string")return t.mimeType;const i=r.pathname.split(".").pop()?.toLowerCase();return i==="png"?"image/png":i==="jpg"||i==="jpeg"?"image/jpeg":i==="webp"?"image/webp":"application/octet-stream"}async function N$r(t,r,i){let a;try{a=JSON.parse(new TextDecoder().decode(t))}catch{throw new Error("Asset Editor could not parse the project .gltf JSON document.")}const l=[...Array.isArray(a.buffers)?a.buffers:[],...Array.isArray(a.images)?a.images:[]];let d=t.byteLength;for(const _ of l){if(typeof _.uri!="string"||_.uri.startsWith("data:"))continue;const g=D$r(_.uri,r),b=await eNt(g,i,hR-d);d+=b.byteLength;const S=new Uint8Array(b);let k="";for(let w=0;w<S.length;w+=32768)k+=String.fromCharCode(...S.subarray(w,w+32768));_.uri=`data:${P$r(_,g)};base64,${btoa(k)}`}return JSON.stringify(a)}function zUe(t,r){let i;try{const a=atob(t);i=new Uint8Array(a.length);for(let l=0;l<a.length;l++)i[l]=a.charCodeAt(l)}catch{throw new Error(`${r} is not valid base64.`)}if(i.byteLength===0||i.byteLength>hR)throw new Error(`${r} must be non-empty and at most ${hR/1024/1024} MiB.`);return new Promise((a,l)=>{fU.parse(i.buffer,"",d=>{d.scene.animations=[...d.animations],a(d.scene)},d=>l(d instanceof Error?d:new Error(String(d))))})}async function O$r(t,r={}){const i=await zUe(t,"Asset preview GLB bytes");try{return j0e(i,r)}finally{eO(i)}}async function F$r(t,r,i={}){const a=await zUe(t,"Asset preview GLB bytes");try{return qUe(a,r,i)}finally{eO(a)}}async function R$r(t,r){const i=I$r(t),a=new AbortController,l=()=>a.abort(r?.reason);r?.aborted?l():r?.addEventListener("abort",l,{once:!0});const d=globalThis.setTimeout(()=>a.abort(new Error("Asset Editor project model load timed out after 25 seconds.")),o$r);try{const _=await eNt(i,a.signal);if(a.signal.throwIfAborted(),i.pathname.toLowerCase().endsWith(".spz"))return{root:await $6t(t,new Uint8Array(_)),sourceBytes:null};if(i.pathname.toLowerCase().endsWith(".glb")){const b=new Uint8Array(_.slice(0));return{root:await N2t(_,i,a.signal),sourceBytes:b}}const g=await N$r(_,i,a.signal);return{root:await N2t(g,i,a.signal),sourceBytes:null}}finally{globalThis.clearTimeout(d),r?.removeEventListener("abort",l)}}async function B0e(t,r){return(await R$r(t,r)).root}function eO(t){Z8(t,"gaussianSplat")&&t.dispose(),pU(t),t.traverse(r=>{const i=r;i.isInstancedMesh&&i.morphTexture?.dispose();const a=r;if(a.geometry?.dispose(),!a.material)return;const l=Array.isArray(a.material)?a.material:[a.material];for(const d of l){for(const _ of Object.values(d))_ instanceof oP&&_.dispose();d.dispose()}})}async function tNt(t,r={}){const i=await B0e(t);try{return Z8(i,"gaussianSplat")?await L$r(i,r):j0e(i,r)}finally{eO(i)}}async function M$r(t,r,i={}){const a=await B0e(t);try{return Y6t(a,r,i)}finally{eO(a)}}async function L$r(t,r){const i=ww(r.width),a=ww(r.height),l=r.background??"neutral",d=LP(t,"perspective"),_=TZ(t,d),g=UP(new $P({antialias:!1,alpha:!0,preserveDrawingBuffer:!0}));let b=null;try{const S=await Xo(()=>import("./spark.module-CjQpY2Op.js"),__vite__mapDeps([45,6,3,2,4,1,8,9,10,11]));b=new S.SparkRenderer({renderer:g,autoUpdate:!1,enableLod:!1}),_.add(b),g.setPixelRatio(1),g.outputColorSpace=hv,g.toneMapping=u9,g.toneMappingExposure=1,g.setClearColor(dU,l==="transparent"?0:1),g.setSize(i,a,!1),Ree(_,g);const k=[],w=document.createElement("canvas");w.width=i*2,w.height=a*2;const N=w.getContext("2d");if(!N)throw new Error("Unable to create the asset preview contact sheet.");for(const[P,j]of EZ.entries()){const J=BUe(j,LP(t,j),i/a);await b.update({scene:_,camera:J}),g.render(_,J),k.push({view:j,base64:AS(g.domElement),mimeType:"image/png"});const X=P%2*i,G=Math.floor(P/2)*a;N.drawImage(g.domElement,X,G,i,a),GR(N,j==="perspective"?"3/4":j.toUpperCase(),X,G,i,a)}return{width:i,height:a,orientation:$Ue([0,0,1]),views:k,contactSheet:{width:i*2,height:a*2,base64:AS(w),mimeType:"image/png"}}}finally{b?.removeFromParent(),t.removeFromParent(),b?.dispose(),M0e(g),g.dispose(),g.forceContextLoss()}}async function j$r(t,r,i={}){const a=await B0e(t);try{return qUe(a,r,i)}finally{eO(a)}}const O2t=0,B$r=16777215,F2t=10;function $$r(t){return zUe(t,"Compare reference GLB")}function R2t(t,r){const i=hz(t),a=new SP;a.rotation.y=PUe(r),a.add(i);const l=new SP;l.add(a),l.updateWorldMatrix(!0,!0);const d=LP(l,"front"),_=[d.center.x-d.size.x/2,d.center.y-d.size.y/2,d.center.z-d.size.z/2],g=[d.center.x+d.size.x/2,d.center.y+d.size.y/2,d.center.z+d.size.z/2],b=Wjr(_,g);return l.scale.setScalar(b.scale),l.position.set(...b.position),l.updateWorldMatrix(!0,!0),{wrapper:l,dispose:()=>pU(i)}}function q$r(t,r){const i=jjr,a=i*r,l=new $ye(-a,a,i,-i,.01,F2t*4),d=t==="front"?new Tc(0,0,1):new Tc(1,0,0);return l.position.set(0,m2t,0).addScaledVector(d,F2t),l.up.set(0,1,0),l.lookAt(0,m2t,0),l.updateProjectionMatrix(),l.updateMatrixWorld(!0),l}function z$r(t,r,i={}){const a=ww(i.width),l=ww(i.height),d=a/l,_=[];let g=null;try{const b=R2t(t,rge(t));_.push(b.dispose);const S=R2t(r,i.refForward??rge(r));_.push(S.dispose);const k=new fq({color:B$r});_.push(()=>k.dispose());const w=fe=>{const se=new Mye;return se.background=new vE(O2t),se.overrideMaterial=k,se.add(fe),se},N=w(b.wrapper),P=w(S.wrapper),j=UP(new $P({antialias:!1,alpha:!1,preserveDrawingBuffer:!0}));g=j,j.setPixelRatio(1),j.toneMapping=Nkt,j.setClearColor(O2t,1),j.setSize(a,l,!1);const J=document.createElement("canvas");J.width=a,J.height=l;const X=J.getContext("2d");if(!X)throw new Error("Unable to create the compare readback canvas.");const G=(fe,se,de,ge)=>{j.render(fe,se),X.clearRect(0,0,a,l),X.drawImage(j.domElement,0,0);const qe=X.getImageData(0,0,a,l).data,tt=Ujr(qe,a*l);if(!tt.some(Ct=>Ct!==0))throw new Error(`Compare ${ge} view rendered an empty ${de} silhouette — nothing to score.`);return{image:{base64:AS(J),mimeType:"image/png"},mask:tt}},ee=document.createElement("canvas");ee.width=a,ee.height=l;const xe=ee.getContext("2d");if(!xe)throw new Error("Unable to create the compare overlay canvas.");const ue=[];for(const fe of Ljr){const se=q$r(fe,d),de=G(N,se,"asset",fe),ge=G(P,se,"reference",fe),qe=Vjr(de.mask,ge.mask);xe.putImageData(new ImageData(Jjr(de.mask,ge.mask),a,l),0,0),ue.push({view:fe,iou:qe.iou,overlay:{base64:AS(ee),mimeType:"image/png"},asset:de.image,ref:ge.image})}return{width:a,height:l,views:ue}}finally{g?.dispose(),g?.forceContextLoss();for(const b of _.reverse())b()}}async function U$r(t,r,i={}){const a=await B0e(t);try{return await rNt(a,r,i)}finally{eO(a)}}async function rNt(t,r,i={}){const a=await $$r(r);try{return z$r(t,a,i)}finally{eO(a)}}let u8=null,nNt=0;const mLe=new Set;function iNt(){nNt++;for(const t of mLe)t()}function $0e(t){return mLe.add(t),()=>{mLe.delete(t)}}function kZ(){return nNt}function q0e(){return u8}function YN(t){u8&&JSON.stringify(u8)===JSON.stringify(t)||(u8=t,iNt())}function pP(){u8!==null&&(u8=null,iNt())}function h7e(t){return[...t.selectedEntityIds].sort().join(`
|
|
74
74
|
`)}function V$r(t){let r=h7e(t);const i=$0e(()=>{u8&&(r=h7e(t))}),a=t.subscribe(()=>{u8&&h7e(t)!==r&&pP()});return()=>{i(),a()}}const J$r=["glb","gltf","fbx","obj","dae","stl","ply","3ds"],W$r=["blend","usd","usda","usdc"],H$r=["png","jpg","jpeg","webp","gif","svg"],G$r=["hdr","exr"],Q$r=["mp3","ogg","wav","flac"],K$r=["mp4","webm"],Y$r=["cube"],X$r=["glsl","vert","frag"],Z$r=["txt","md","ts","tsx","js","jsx","css","html","mtl","csv","xml","yaml","yml"];function kA(t,r){return[t,{format:t,...r}]}const M2t={kind:"source",previewable:!0,importable:!0,runtimeReady:!1,placeable:!1,animated:!1,importStrategy:"convert-model",editor:"model"},hLe=new Map([...J$r.map(t=>kA(t,{...M2t,kind:t==="glb"||t==="gltf"?"model":"source",runtimeReady:t==="glb"||t==="gltf",placeable:t==="glb"||t==="gltf",importStrategy:t==="glb"||t==="gltf"?"copy-runtime":"convert-model"})),kA("spz",{kind:"model",previewable:!0,importable:!0,runtimeReady:!0,placeable:!0,animated:!1,importStrategy:"copy-runtime",editor:"model"}),kA("bvh",{kind:"source",previewable:!0,importable:!0,runtimeReady:!1,placeable:!1,animated:!0,importStrategy:"animation-source",editor:"model"}),...W$r.map(t=>kA(t,{...M2t,previewable:!1,editor:"source"})),...H$r.map(t=>kA(t,{kind:"image",previewable:!0,importable:!0,runtimeReady:!0,placeable:!1,animated:t==="gif",importStrategy:"copy-project",editor:"image"})),...G$r.map(t=>kA(t,{kind:"image",previewable:!0,importable:!0,runtimeReady:!0,placeable:!1,animated:!1,importStrategy:"copy-project",editor:"environment"})),...Q$r.map(t=>kA(t,{kind:"audio",previewable:!0,importable:!0,runtimeReady:!0,placeable:!1,animated:!1,importStrategy:"copy-project",editor:"audio"})),...K$r.map(t=>kA(t,{kind:"video",previewable:!0,importable:!0,runtimeReady:!1,placeable:!1,animated:!0,importStrategy:"copy-project",editor:"video"})),...Y$r.map(t=>kA(t,{kind:"source",previewable:!0,importable:!0,runtimeReady:!0,placeable:!1,animated:!1,importStrategy:"copy-project",editor:"source"})),...X$r.map(t=>kA(t,{kind:"source",previewable:!0,importable:!0,runtimeReady:!0,placeable:!1,animated:!1,importStrategy:"copy-project",editor:"source"})),...Z$r.map(t=>kA(t,{kind:"source",previewable:!0,importable:!0,runtimeReady:!1,placeable:!1,animated:!1,importStrategy:"copy-project",editor:"source"})),kA("inputmap.json",{kind:"json",previewable:!0,importable:!0,runtimeReady:!0,placeable:!1,animated:!1,importStrategy:"copy-project",editor:"data"}),kA("data.json",{kind:"json",previewable:!0,importable:!0,runtimeReady:!0,placeable:!1,animated:!1,importStrategy:"copy-project",editor:"data"}),kA("json",{kind:"json",previewable:!0,importable:!0,runtimeReady:!1,placeable:!1,animated:!1,importStrategy:"copy-project",editor:"data"})]),eqr={format:"unknown",kind:"unknown",previewable:!1,importable:!1,runtimeReady:!1,placeable:!1,animated:!1,importStrategy:"unsupported",editor:"none"};function tqr(t){const r=t.split(/[?#]/,1)[0].toLowerCase();for(const l of["inputmap.json","data.json"])if(r.endsWith(`.${l}`))return l;const i=r.lastIndexOf("."),a=i>=0?r.slice(i+1):"";return hLe.has(a)?a:a==="json"?"json":"unknown"}function wg(t){const r=hLe.get(t.toLowerCase());return r||(hLe.get(tqr(t))??eqr)}function Bq(t){switch(t.editor){case"model":return"model";case"image":return"image";case"environment":return"image";case"video":return"video";case"audio":return"audio";case"data":return"json";case"source":return"source";default:return null}}let _P=[];const gLe=new Set;function sNt(){for(const t of gLe)t()}function oNt(t){return gLe.add(t),()=>{gLe.delete(t)}}function KDn(t){const r=_P.findIndex(i=>i.worldId===t.worldId);if(r===-1)_P=[..._P,t];else{const i=[..._P];i[r]=t,_P=i}sNt()}function IZ(){return _P}function YDn(t){const r=_P.findIndex(i=>i.worldId===t);r!==-1&&(_P=_P.filter((i,a)=>a!==r),sNt())}function XDn(t){return t instanceof Error?t.message:String(t)}function tO(t){return wm(t).adapter}function z0e(t){const r=[];return uU(tO(t).hierarchy,i=>{r.push({id:i.id,name:i.label,childIds:[...i.childIds]})}),r}function rqr(t){let r=null;return uU(t.hierarchy,i=>{const a=i.secondaryLabel?.trim();if(!(i.role!=="document"||!a))return r=a,!1}),r}function nqr(t){return rqr(By(t))}function UUe(t){const r=By(t);return r.capabilities.persist?r.persistence?.destination??null:null}function aNt(t){const r=By(t).persistence;return r?.lastError?.()?"failed":r?.isDirty()?"unsaved":"saved"}function iqr(t){return By(t).persistence?.lastError?.()??null}function sqr(t){const r=tO(t),i=r.selection?.get()[0]??null;return i?r.truth?.resolve(i,"position").site??null:null}function oqr(t){const r=tO(t),i=r.selection?.get()[0]??null;return i?r.truth?.resolve(i,"position").writeAnchorKind??null:null}function VUe(t){return[...tO(t).selection?.get()??t.selectedEntityIds]}function JUe(t,r){const i=tO(t);k0(i,r)||t.selectMultiple([...r])}function cNt(t){JUe(t,z0e(t).map(r=>r.id))}async function lNt(t){await r4t(By(t),"the shell saved the active document")}function uNt(t,r){if(r===void 0)return;const i=r;return i===null||typeof i!="object"||typeof i.azimuthDegrees!="number"||!Number.isFinite(i.azimuthDegrees)||typeof i.elevationDegrees!="number"||!Number.isFinite(i.elevationDegrees)||i.elevationDegrees<-90||i.elevationDegrees>90||i.distance!==void 0&&(typeof i.distance!="number"||!Number.isFinite(i.distance)||i.distance<=0)?`${t} camera must be {azimuthDegrees, elevationDegrees in [-90, 90], distance? > 0 meters}.`:{azimuthDegrees:i.azimuthDegrees,elevationDegrees:i.elevationDegrees,...i.distance===void 0?{}:{distance:i.distance}}}function fNt(t,r){if(r===void 0)return;const i=r;return i===null||typeof i!="object"||typeof i.clip!="string"||i.clip.length===0||typeof i.timeSeconds!="number"||!Number.isFinite(i.timeSeconds)||i.timeSeconds<0?`${t} pose must be {clip: non-empty string, timeSeconds >= 0}.`:{clip:i.clip,timeSeconds:i.timeSeconds}}const yLe=new Set;function aqr(t){return yLe.add(t),()=>{yLe.delete(t)}}function cqr(t){for(const r of yLe)r(t)}function L2t(t){return/@[0-9.]+x\./i.test(t)?1:/\.webp\.json$/i.test(t)?2:/\.png\.json$/i.test(t)?3:0}function vLe(t){const r=t.lastIndexOf("/"),i=r<0?"":t.slice(0,r),l=(r<0?t:t.slice(r+1)).replace(/@[0-9.]+x/i,"").replace(/\.(png|webp|jpe?g)\.json$/i,"").replace(/\.json$/i,"");return i?`${i}/${l}`:l}function WUe(t){let r;try{r=JSON.parse(t)}catch{return null}if(!r||typeof r!="object")return null;const i=r,a=typeof i.meta?.image=="string"?hqr(i.meta.image):"",l=fqr(i.frames);return!a||l.length===0?null:{image:a,frames:l}}function U0e(t){const r=t.replace(/^\//,""),i=r.lastIndexOf("#");return i<0?{sheetPath:r,frameName:null}:{sheetPath:r.slice(0,i),frameName:r.slice(i+1)||null}}function lqr(t){const{sheetPath:r,frameName:i}=U0e(t);return i??r.split("/").pop()??t}function dNt(t){return`${t.replace(/^\//,"")}.json`}function uqr(t){const r=t.match(/\.[a-z0-9]+$/i)?.[0]??"",i=t.slice(0,t.length-r.length);return[t,`${i}.png`,`${i}.webp`,`${i}.jpg`,`${i}@0.5x${r}`,`${i}@0.5x.png`,`${i}@0.5x.webp`,`${i}@2x${r}`,`${i}@2x.png`,`${i}@2x.webp`]}function fqr(t){return!t||typeof t!="object"?[]:Array.isArray(t)?t.flatMap(r=>{if(!r||typeof r!="object")return[];const i=r,a=typeof i.filename=="string"?i.filename:"",l=j2t(i);return!a||!l?[]:[{name:B2t(a),...l}]}):Object.entries(t).flatMap(([r,i])=>{if(!i||typeof i!="object")return[];const a=j2t(i);return a?[{name:B2t(r),...a}]:[]})}function j2t(t){const r=dqr(t.frame);if(!r)return null;const i=pqr(t.sourceSize)??{width:r.width,height:r.height},a=_qr(t.spriteSourceSize);return{...r,rotated:t.rotated===!0,sourceWidth:i.width,sourceHeight:i.height,trimX:a?.x??0,trimY:a?.y??0}}function dqr(t){if(!t||typeof t!="object")return null;const r=t;return typeof r.x!="number"||typeof r.y!="number"||typeof r.w!="number"||typeof r.h!="number"?null:{x:r.x,y:r.y,width:r.w,height:r.h}}function pqr(t){if(!t||typeof t!="object")return null;const r=t;return typeof r.w!="number"||typeof r.h!="number"?null:{width:r.w,height:r.h}}function _qr(t){if(!t||typeof t!="object")return null;const r=t;return typeof r.x!="number"||typeof r.y!="number"?null:{x:r.x,y:r.y}}function mqr(t){return t.rotated?{x:t.x,y:t.y,width:t.height,height:t.width}:{x:t.x,y:t.y,width:t.width,height:t.height}}function hqr(t){const r=t.lastIndexOf("/");return r<0?t:t.slice(r+1)}function B2t(t){return t.replace(/\.(png|webp|jpe?g)$/i,"")}const gqr="http://www.w3.org/2000/svg";function yqr(t){const r=/<svg\b/i.exec(t);if(!r)return t;const i=t.indexOf(">",r.index);if(i<0)return t;const a=t.slice(r.index,i+1);if(/\sxmlns\s*=/.test(a))return t;const l=r.index+r[0].length;return`${t.slice(0,l)} xmlns="${gqr}"${t.slice(l)}`}function vqr(t){const r=t.mediaType==="image/svg+xml"?yqr(t.text):t.text;return`data:${t.mediaType};charset=utf-8,${encodeURIComponent(r)}`}const $2t="command-result-received";let Kk=null;const bLe=new Set;function pNt(){for(const t of[...bLe])t(Kk)}function Jpe(){return Kk}function _Nt(t,r=Date.now()){Kk!==null&&Kk.reason!=="server-gone"||Kk!==null&&Kk.reason===t||(Kk={reason:t,at:r},pNt())}function bqr(){Kk===null||Kk.reason!=="server-gone"||(Kk=null,pNt())}function HUe(t){return bLe.add(t),()=>{bLe.delete(t)}}function Aqr(t,r,i=Date.now()){const a=`${Math.max(0,Math.round((i-t.at)/1e3))}s ago`,l=t.reason==="taken-over"?`a DIFFERENT editor session took this port ${a}; this page yielded to it`:t.reason==="session-closed"?`this page's editor session was closed ${a}`:`this page's editor server stopped ${a}`;return`refused "${r}": this editor page is a TOMBSTONE — ${l}. Nothing it reports is live state and nothing it does is saved. Run \`volter-editor edit <project>\` to open the session again; that reuses the live server and its one tab.`}const Sqr=300;function mNt(t){window.close(),window.setTimeout(t,Sqr)}function xqr(t){try{window.focus();const r=JSON.parse(t.data);if(typeof r.url!="string")return;const i=new URL(r.url,window.location.href);i.origin===window.location.origin&&i.pathname+i.search!==window.location.pathname+window.location.search&&window.location.assign(i.href)}catch{}}function wqr(t,r){let i=null;try{const a=JSON.parse(r.data);typeof a.participantId=="string"&&(i=a.participantId)}catch{}mNt(()=>{const a=i?`?participantId=${encodeURIComponent(i)}`:"";window.location.replace(`${t}/tab-yielded${a}`)})}let q2t=!1;function Cqr(t,r){if(!(r.tabId===void 0||r.epoch===void 0))try{navigator.sendBeacon?.(`${t}/tab/close`,new Blob([JSON.stringify({tabId:r.tabId,epoch:r.epoch,persisted:!1,reason:"session-ended"})],{type:"application/json"}))}catch{}}function Eqr(t,r){q2t||(q2t=!0,_Nt("session-closed"),Cqr(t,r),mNt(()=>{document.title=C4t("Session ended"),document.body.innerHTML=`<style>
|
|
75
75
|
:root{color-scheme:dark;background:#101318;color:#e8edf3;font-family:Inter,ui-sans-serif,system-ui,sans-serif}
|
|
76
76
|
body{margin:0;min-height:100vh;display:grid;place-items:center;padding:24px;background:radial-gradient(circle at 50% 30%,#1c2a3a 0,#101318 52%,#0b0e13 100%)}
|
|
77
77
|
main{width:min(440px,100%);box-sizing:border-box;padding:34px;text-align:center;border:1px solid rgba(255,255,255,.1);border-radius:20px;background:rgba(23,28,35,.92);box-shadow:0 22px 60px rgba(0,0,0,.38)}
|
|
78
78
|
.brand-mark{width:68px;height:68px;margin:0 auto 20px}.brand-mark svg{display:block;width:100%;height:100%}h1{margin:0 0 10px;font-size:22px}p{margin:0;color:#aeb9c6;font-size:14px;line-height:1.6}
|
|
79
|
-
</style><main><div class="brand-mark">${DMr()}</div><h1>Session ended</h1><p>This editor session has ended. You can close this tab.</p></main>`}))}const nge=new Set;function Tqr(t){return nge.add(t),()=>{nge.delete(t)}}function kqr(){try{window.focus()}catch{}if(nge.size===0){window.location.reload();return}for(const t of[...nge])t()}function Iqr(t,r,i={}){t.addEventListener("tab-refocus",a=>xqr(a)),t.addEventListener("tab-yield",a=>wqr(r,a)),t.addEventListener("tab-close",()=>Eqr(r,i)),t.addEventListener("tab-adopt",()=>kqr())}const Gk="/__editor",Dqr=globalThis,Ad=Dqr.__VGAI_EDITOR_PRESENCE_BOOTSTRAP__,jP=Ad?.clientId??globalThis.crypto?.randomUUID?.()??`editor-${Date.now()}`,V0e=CDt,Pqr=S8r;function Nqr(t){Ad?.reportPhase?.(t)}function Oqr(t){Ad?.reportCensus?.(t)}function Fqr(){Ad?.stopHeartbeat?.();const t=pw;if(t!==null){pw=null,Y$=0,Ad?.source===t&&(Ad.source=null),gz===t&&(gz=null);try{t.close()}catch{}}}function Rqr(){const t=new URLSearchParams({clientId:jP,participantId:V0e,displayName:Pqr});return Ad?.tabId&&t.set("tabId",Ad.tabId),`${Gk}/events?${t}`}let pw=Ad?.source??null,Y$=Ad?.source&&Ad.pageOwned?1:0,gz=null;const hNt=new Set(["editor-command"]);function gNt(t,r){if(!Ad||Ad.source!==t)return;Ad.queueListeners=Ad.queueListeners.filter(({type:a,listener:l})=>r(a)?(t.removeEventListener(a,l),!1):!0);const i=Ad.pending.filter(a=>r(a.type));Ad.pending=Ad.pending.filter(a=>!r(a.type));for(const{type:a,data:l}of i)t.dispatchEvent(new MessageEvent(a,{data:l}))}function Mqr(t){gz!==t&&(gz=t,Iqr(t,Gk,{tabId:Ad?.tabId,epoch:Ad?.epoch}),gNt(t,r=>!hNt.has(r)))}function VP(){pw||(Ad?.source?(pw=Ad.source,Ad.pageOwned&&Y$++):(pw=new EventSource(Rqr()),Ad&&(Ad.source=pw)));const t=pw;Mqr(t),Y$++;const r=[];let i=!1;return{addEventListener(a,l){const d=l;t.addEventListener(a,d),r.push({type:a,listener:d}),hNt.has(a)&&gNt(t,_=>_===a)},removeEventListener(a,l){const d=l;t.removeEventListener(a,d);const _=r.findIndex(g=>g.type===a&&g.listener===d);_>=0&&r.splice(_,1)},close(){if(!i){i=!0;for(const{type:a,listener:l}of r)t.removeEventListener(a,l);r.length=0,Y$--,Y$<=0&&(t.close(),pw===t&&(pw=null),Ad?.source===t&&(Ad.source=null),gz===t&&(gz=null),Y$=0)}}}}function Lqr(){const t=pw??Ad?.source??null;if(!t)return"unknown";if(typeof t.connected=="boolean")return t.connected?"open":"closed";const r=t.readyState;return typeof r=="number"?r===1?"open":"closed":"unknown"}function jqr(){if(typeof EventSource>"u")return()=>{};const t=VP(),r=HUe(a=>{a!==null&&a.reason!=="server-gone"&&Fqr()}),i=$qr();return()=>{i(),r(),t.close()}}const Bqr=5;function $qr(){if(typeof window>"u")return()=>{};let t=0;const r=l=>{l===""||t>=Bqr||(t+=1,EX("console-entries",{entries:[{id:`boot-error:${t}`,severity:"error",message:`editor app failed to start: ${l}`,source:"runtime",occurrences:1}],_clientId:Ad?.clientId??"boot"}))},i=l=>{const d=l.error;r(d?.stack??`${l.message} (${l.filename??"?"}:${l.lineno??0})`)},a=l=>{const d=l.reason;L3t(d)||r(d instanceof Error?d.stack??d.message:`unhandled rejection: ${String(d)}`)};return window.addEventListener("error",i),window.addEventListener("unhandledrejection",a),()=>{window.removeEventListener("error",i),window.removeEventListener("unhandledrejection",a)}}const qqr=2e3,zqr={"command-received":`${Gk}/command-received`,"command-result":`${Gk}/command-result`,"command-listener":`${Gk}/command-listener`,"console-entries":`${Gk}/console-entries`,"console-resolved":`${Gk}/console-resolved`,"play-phase":`${Gk}/play-phase`,state:`${Gk}/state`,"tab-route":`${Gk}/tab/route`};async function EX(t,r){if(!(typeof fetch>"u"))try{await fetch(zqr[t],{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...r,...Ad?.controlLifecycle?{_controlLifecycle:Ad.controlLifecycle}:{}})})}catch{}}async function R8(t,r){(pw??Ad?.source??null)?.send?.(t,r)||await EX(t,r)}async function Uqr(t,r){const i=pw??Ad?.source??null;if(!i){await EX("command-result",r);return}let a;const l=new Promise(S=>{a=S}),d=S=>{const k=S.data;let w=k;if(typeof k=="string")try{w=JSON.parse(k)}catch{}w===t&&a()};i.addEventListener($2t,d);const _={...r,_awaitCallerReceipt:!0};i.send?.("command-result",_)||await EX("command-result",_);let g,b=!1;await Promise.race([l.then(()=>{b=!0}),new Promise(S=>{g=setTimeout(S,qqr)})]),g!==void 0&&clearTimeout(g),b||await EX("command-result",r),i.removeEventListener($2t,d)}function Vqr(t){R8("tab-route",{clientId:jP,participantId:V0e,route:t})}function GUe(t){return{ok:!1,reason:t instanceof Error?t.message:String(t)}}async function Jqr(t,r){try{const i=new URLSearchParams({root:t,dir:r}),a=await fetch(`${W_}/assets?${i}`,{cache:"no-store"});return{ok:!0,entries:(await Eg(a,`Could not list ${t}/${r} from ${W_}/assets`)).entries??[]}}catch(i){return GUe(i)}}async function J0e(t,r){if(t!=="public")return Jqr(t,r);try{return{ok:!0,entries:(await _z().list(r)).map(a=>({name:a.name,type:a.type==="dir"?"directory":"file",...a.size===void 0?{}:{size:a.size},...a.mtime===void 0?{}:{modifiedAt:a.mtime}}))}}catch(i){return GUe(i)}}async function yNt(){try{const t=await fetch(`${W_}/project-components`,{cache:"no-store"});return{ok:!0,entries:(await Eg(t,`Could not list project components from ${W_}/project-components`)).components??[]}}catch(t){return GUe(t)}}class z2t extends Error{constructor(r,i){super(i),this.code=r,this.name="AssetDeliveryError"}}function U2t(t){return{offline:"Network delivery is offline. SSD assets remain available.","quota-limited":"The remote provider quota is exhausted. Retry after the provider resets it.","license-blocked":"This delivery is blocked because its license terms are not accepted.",unavailable:"No healthy SSD, cloud, or remote delivery is available for this variant.","provider-error":"The remote provider could not return delivery metadata. Retry the request."}[t]}const Wqr=new Map,Hqr=new Set;function Gqr(t,r){return`${t}:${r}`}async function ZDn(t,r){return Qqr(t,r)}async function Qqr(t,r){const i=new URLSearchParams({source:t,id:r});let a;try{a=await fetch(`${W_}/asset-library/files?${i}`)}catch(d){throw new z2t("offline",d instanceof Error?d.message:U2t("offline"))}if(np(a,"Asset Library file lookup failed"),!a.ok){const d=await a.json().catch(()=>null),_=a.status===403?"license-blocked":a.status===429?"quota-limited":a.status===404?"unavailable":"provider-error";throw new z2t(_,d?.error??U2t(_))}return(await a.json()).files}async function e3n(t,r){const i=new URLSearchParams({source:t,id:r}),a=await fetch(`${W_}/asset-library/preview?${i}`);return np(a,"Could not resolve an asset preview"),a.ok?await a.json():null}async function t3n(t){const r=await fetch(`${W_}/asset-library/download`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...t,signal:void 0}),...t.signal?{signal:t.signal}:{}});np(r,"Could not download the asset");const i=await r.json();if(i.ok&&i.path){Wqr.set(Gqr(t.source,t.id),`/${i.path}`);for(const a of Hqr)a()}return i}async function r3n(t){const r=await fetch(`${W_}/asset-library/history/capture`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({assetPath:t})});np(r,"Asset history capture failed");const i=await r.json();if(!r.ok||!i.token)throw new Error(i.error??`Asset history capture failed (${r.status}).`);return i.token}async function n3n(t,r){const i=await fetch(`${W_}/asset-library/history/restore`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({assetPath:t,token:r})});if(np(i,"Asset history restore failed"),!i.ok){const a=await i.json().catch(()=>null);throw new Error(a?.error??`Asset history restore failed (${i.status}).`)}}function Kqr(t){if(!t||typeof t!="object")return null;const r=t;return r.apiVersion!==1||typeof r.engineVersion!="string"&&r.engineVersion!==null||typeof r.manifestVersion!="number"||typeof r.startedAt!="string"||!r.source||r.source.state!=="current"&&r.source.state!=="restart-required"||r.source.state==="restart-required"&&(typeof r.source.changedPath!="string"||typeof r.source.changedAt!="string")?null:r}async function Yqr(){let t;try{t=await fetch(`${W_}/compatibility`,{cache:"no-store"})}catch(r){throw i2t(r instanceof Error?r.message:String(r))}if(t.status>=500)throw i2t(`HTTP ${t.status}`);try{rU(t,`GET ${W_}/compatibility`)}catch{return null}try{return Kqr(await t.json())}catch{return null}}async function vNt(){const t=await Yqr();if(!t)throw zMr();return UMr(t),t}async function Xqr(){try{const t=await fetch(`${W_}/recent-projects`);return(await Eg(t,"Could not list recent projects")).projects}catch{return[]}}const V2t={reopenLastProject:!1};async function Zqr(){try{const t=await fetch(`${W_}/launcher-settings`),r=await Eg(t,"Could not read launcher settings");return{reopenLastProject:typeof r.reopenLastProject=="boolean"?r.reopenLastProject:V2t.reopenLastProject}}catch{return{...V2t}}}async function ALe(t){const r=await fetch(`${W_}/reveal`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:t})});rU(r,`Could not reveal ${t}`)}async function ezr(t){try{const r=await fetch(`${W_}/save-thumbnail`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dataUrl:t})});return rU(r,"Could not save the project thumbnail"),!0}catch{return!1}}async function bNt(){let t;try{const i=await fetch(`${W_}/project`);t=await Eg(i,`No answer from ${W_}/project`)}catch(i){return{status:"unknown",error:i instanceof Error?i.message:String(i)}}if(t.project)return{status:"project",project:t.project};const r=t.serving;return r&&typeof r.path=="string"?{status:"unreadable",path:r.path,error:typeof r.error=="string"?r.error:"unknown error"}:t.project===null?{status:"none"}:{status:"unknown",error:`Unrecognized ${W_}/project response`}}async function ige(t){try{const r=await fetch(Fee(t));if(r.ok)return await r.text()}catch{}return null}function tzr(t){return(t.headers.get("content-type")??"").toLowerCase().includes("text/html")}async function ANt(t){try{const r=await fetch(Fee(t),{method:"HEAD"});return r.ok?tzr(r)?"absent":"present":"absent"}catch{return"unreachable"}}async function rzr(t){return await ANt(t)==="present"}async function SNt(t,r={}){if(t.length===0)return[];const i=await fetch(`/__editor/source-files?${new URLSearchParams([...t.map(l=>["include",l]),...r.order==="mtime"?[["order","mtime"]]:[]])}`);return i.ok?(await i.json()).files??[]:[]}async function nzr(t=3e3){if(typeof fetch>"u")return{ok:!1};try{const r=await fetch(`${W_}/project`,{signal:AbortSignal.timeout(t)}),i=await Eg(r,"Editor lease poll failed");return{ok:!0,identity:{project:typeof i.project?.path=="string"?i.project.path:null,pid:typeof i.session?.pid=="number"?i.session.pid:null}}}catch{return{ok:!1}}}async function izr(){try{const t=await fetch(`${W_}/editor-state`);return await Eg(t,"Could not read editor state")}catch{return{}}}let J2t=!1;async function szr(t){try{const r=await fetch(`${W_}/editor-state`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});return rU(r,"Could not save editor state"),!0}catch(r){return J2t||(J2t=!0,console.error(r instanceof Error?r.message:String(r))),!1}}let QY=null,sge=null;async function xNt(){for(;QY;){const t=QY;QY=null,await R8("state",{...t,_clientId:jP})}sge=null,QY&&(sge=xNt())}function W2t(t){return QY=t,sge??=xNt(),sge}async function ozr(t){await R8("command-received",{_requestId:t,_clientId:jP})}async function Wpe(t){await R8("command-listener",{_clientId:jP,attached:t})}function azr(t){Nqr(t.phase),R8("play-phase",{_clientId:jP,...t})}async function H2t(t,r,i,a,l=!1){const d={_requestId:t,_clientId:jP,ok:r,error:i,data:a};l?await Uqr(t,d):await R8("command-result",d)}async function czr(){const t=await fetch(`${W_}/project`,{cache:"no-store"});if(np(t,"Could not read this session’s worktree identity"),!t.ok)return{branch:null,worktreeId:null};const r=await t.json().catch(()=>null);return{branch:typeof r?.session?.branch=="string"?r.session.branch:null,worktreeId:typeof r?.session?.worktreeId=="string"?r.session.worktreeId:null}}async function JP(t,r){const i=await fetch(`${W_}/worktrees${t}`,r);np(i,`Worktree operation ${t||"(list)"} failed`);const a=await i.json().catch(()=>null);if(!i.ok)throw new Error(typeof a?.error=="string"?a.error:`Worktree operation failed (${i.status}).`);return a??{}}function W0e(t){return{worktrees:Array.isArray(t.worktrees)?t.worktrees:[],branches:Array.isArray(t.branches)?t.branches:[],isolatedWorktrees:Array.isArray(t.isolatedWorktrees)?t.isolatedWorktrees:[]}}async function lzr(){const t=await JP("");return W0e(t)}async function uzr(t){return await JP("/open",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({worktreeId:t})})}async function G2t(t,r="HEAD"){return await JP("/create",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({branch:t,from:r})})}async function fzr(t){return JP("/delegate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}async function dzr(t){const r=await JP(`/isolated/${encodeURIComponent(t)}/logs`);return typeof r.logs=="string"?r.logs:""}async function pzr(t){const r=await JP("/isolated/export",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:t})});return W0e(r)}async function Q2t(t,r){const i=await JP("/isolated/stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:t,discard:r})});return W0e(i)}async function _zr(t){const r=await JP("/archive",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({worktreeId:t})});return W0e(r).worktrees}async function mzr(t,r){await JP("/stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({worktreeId:t,sessionId:r})})}let wNt=null;const hzr=new Set,SLe=new Set;function gzr(t){wNt=t;for(const r of hzr)r(t);for(const r of SLe)r()}function Qh(){return wNt}function Hpe(t){return SLe.add(t),()=>{SLe.delete(t)}}const _I="references",CNt=["public",_I],QUe=`/project-game-static/${_I}/`;function oge(t,r){return`${t}/${r}`}function H0e(t,r){return t===_I?`${QUe}${r}`:`/${r}`}function yzr(t){return t.startsWith(QUe)}function vzr(t){const r=t.startsWith("/")?t:`/${t}`;if(yzr(r))return oge(_I,r.slice(QUe.length));const i=t.startsWith("/")?t.slice(1):t;return i.startsWith("public/")?i:`public/${i}`}function ENt({assetPath:t,kind:r,sizeBytes:i}){return z.jsx(bzr,{assetPath:t,kind:r,sizeBytes:i},t)}function bzr({assetPath:t,kind:r,sizeBytes:i}){const a=t.split("#")[0],l=a.startsWith("/")||/^(?:data|blob|https?):/.test(a)?a:`/${a}`,d=vzr(a),[_,g]=Xe.useState(i),[b,S]=Xe.useState(null),[k,w]=Xe.useState(null);Xe.useEffect(()=>{if(i!==void 0){g(i);return}let X=!1;const[G,...ee]=d.split("/"),xe=ee.pop();return J0e(G,ee.join("/")).then(ue=>{!X&&ue.ok&&g(ue.entries.find(fe=>fe.name===xe)?.size)}),()=>{X=!0}},[d,i]),Xe.useEffect(()=>{if(S(null),w(null),r==="image"){const G=new Image;return G.onload=()=>S({width:G.naturalWidth,height:G.naturalHeight}),G.onerror=()=>w("Image properties could not be read."),G.src=l,()=>{G.onload=null,G.onerror=null}}const X=document.createElement(r);return X.preload="metadata",X.onloadedmetadata=()=>S({...Number.isFinite(X.duration)?{duration:X.duration}:{},...X instanceof HTMLVideoElement?{width:X.videoWidth,height:X.videoHeight}:{}}),X.onerror=()=>w("Media properties could not be read. The file may be missing or unsupported."),X.src=l,()=>{X.onloadedmetadata=null,X.onerror=null,X.removeAttribute("src"),X.load()}},[l,r]);const N=b?.width,P=b?.height,j=[];if(N&&P){let X=N,G=P;for(;G;)[X,G]=[G,X%G];j.push(["Dimensions",`${N} × ${P} px`],["Aspect ratio",`${N/X}:${P/X}`])}b?.duration!==void 0&&j.push(["Duration",`${Number(b.duration.toFixed(3))} s`]);const J=a.split("?")[0].match(/\.([^./]+)$/)?.[1];return J&&j.push(["Format",J.toUpperCase()]),_!==void 0&&j.push(["File size",_<1024?`${_} B`:`${(_/(_<1024*1024?1024:1024*1024)).toFixed(1)} ${_<1024*1024?"KB":"MB"}`]),j.push(["Location",d]),z.jsxs("div",{"data-testid":"media-properties",style:{padding:8,fontSize:12},children:[k?z.jsx("p",{role:"status",style:{color:od[2]},children:k}):!b&&z.jsx("p",{role:"status",style:{color:od[3]},children:"Reading media properties…"}),z.jsx("dl",{style:{margin:0,display:"grid",gridTemplateColumns:"auto minmax(0, 1fr)",gap:"10px 12px"},children:j.map(([X,G])=>z.jsxs("div",{style:{display:"contents"},children:[z.jsx("dt",{style:{color:od[3]},children:X}),z.jsx("dd",{style:{margin:0,color:od[1],overflowWrap:"anywhere"},children:G})]},X))})]})}const g7e=Xe.lazy(async()=>({default:(await Xo(()=>Promise.resolve().then(()=>p5r),void 0)).AssetEditorShell})),Azr=Xe.lazy(async()=>({default:(await Xo(()=>import("./AudioViewer-Cvu0tj6D.js"),__vite__mapDeps([46,1,2,3,4,8,9,10,11,6]))).AudioViewer})),Szr=Xe.lazy(async()=>({default:(await Xo(()=>import("./EntityModelDocument-Cf9gBRJC.js"),__vite__mapDeps([47,1,2,3,4,8,9,10,42,6,7,40,14,43,41,11]))).EntityModelDocument})),xzr=Xe.lazy(async()=>({default:(await Xo(()=>import("./EnvironmentAssetDocument-Ci98saEi.js"),__vite__mapDeps([48,1,2,3,4,8,9,10,6,40,49,50,11]))).EnvironmentAssetDocument})),wzr=Xe.lazy(async()=>({default:(await Xo(()=>import("./ImageViewer-BuCQ-r1c.js"),__vite__mapDeps([51,1,2,3,4,8,9,10,11,6]))).ImageViewer})),Czr=Xe.lazy(async()=>({default:(await Xo(()=>import("./VideoViewer-DoYvabkN.js"),__vite__mapDeps([52,1,2,3,4,8,9,10,11,6]))).VideoViewer})),Ezr=Xe.lazy(async()=>({default:(await Xo(()=>import("./JsonAssetDocument-CXYQPool.js").then(r=>r.a),__vite__mapDeps([53,1,2,3,4,8,9,10,42,6,7,40,14,43,41]))).JsonAssetDocument})),Tzr=Xe.lazy(async()=>({default:(await Xo(()=>import("./ModelAssetDocument-BcgmYF99.js"),__vite__mapDeps([54,1,2,3,4,8,9,10,42,6,7,40,14,43,41,11]))).ModelAssetDocument})),K2t=Xe.lazy(async()=>({default:(await Xo(()=>import("./OnlineAssetDetail-Buu6QoLM.js"),__vite__mapDeps([55,1,2,3,4,8,9,50,10,11,6]))).OnlineAssetDetail})),kzr=Xe.lazy(async()=>({default:(await Xo(()=>import("./SourceAssetViewer-D8j4Gm0U.js"),__vite__mapDeps([56,1,2,3,4,8,9,10,53,42,6,7,40,14,43,41,46,11,48,49,50,51,57,58,59,60,61,54]))).SourceAssetViewer})),gb=new Map,TNt=new Map,y7e=new Map;let kNt=0;const xLe=new Set;function OR(){kNt++;for(const t of xLe)t()}function Izr(t){return xLe.add(t),()=>{xLe.delete(t)}}function Dzr(){return kNt}function Pzr(t){return gb.get(t)}function INt(t){return gb.has(t)}function Nzr(t,r){const i=new Set([...Object.keys(t),...Object.keys(r)]);for(const a of i){const l=t[a],d=r[a];if(l!==d&&JSON.stringify(l)!==JSON.stringify(d))return!1}return!0}function KUe(t,r,i,a,l,d={}){typeof document<"u"&&document.activeElement instanceof HTMLElement&&y7e.set(r,document.activeElement);const _=gb.get(r);if(!_)gb.set(r,a),OR();else{const b={..._,...a};Nzr(_,b)||(gb.set(r,b),OR())}const g={id:r,title:i,kind:"asset",workspaceRole:"authored-subject",...l?{provenance:l}:{},Content:Bzr,closeable:!0,presentation:()=>{const b=gb.get(r);return b?b.entityId?{kind:"asset",entityId:b.entityId,assetKind:"model"}:!b.assetPath||b.online?null:{kind:"asset",path:b.assetPath,assetKind:b.kind}:null},persist:()=>{const b=gb.get(r);if(!(!b?.assetPath||b.online||b.entityId!==void 0))return{path:b.assetPath,assetKind:b.kind}},onActivate:()=>{t.setActiveViewportTab("edit"),(a.kind==="image"||a.kind==="video"||a.kind==="audio")&&pP()},onDispose:b=>{gb.delete(b)&&OR();const S=y7e.get(b);y7e.delete(b),S?.isConnected&&setTimeout(()=>S.focus(),0)}};return qP(g,d)}function f8(t,r,i,a={}){const l=lqr(r),{frameName:d}=U0e(r),_=TNt.get(Q7(r))??r;return KUe(t,_,l,d?{assetPath:r,kind:i,displayName:l}:{assetPath:r,kind:i},{sourcePath:r},a)}Iee({kind:"asset",owner:"asset-documents",restore:async({state:t,store:r})=>{const i=t,a=typeof i?.path=="string"?i.path:null,l=typeof i?.assetKind=="string"?i.assetKind:null;return!a||!l||!await rzr(a)?!1:(f8(r,a,l),!0)}});async function DNt(t,r){return xE(()=>{if(I_()!==t)return!1;const i=Sze(t);return i?r!=="model"||i.adapter!==null:!1},m9)}g9({id:"asset",owner:"asset-documents",open:(t,r)=>{if(r.entityId){const a=Qh();if(!a)return null;const l=PNt(a,r.entityId);if(!l)throw new Error(`Scene entity is not available: ${r.entityId}`);return l}const i=r.path;return i===void 0?null:f8(t,i,Y2t(r.assetKind,i))},ready:async(t,r)=>{const i=r.entityId?"model":Y2t(r.assetKind,r.path??"");if(!await DNt(t,i))throw new Error(`Asset document did not finish mounting its Inspector: ${t}`);await Fze(t)}});function Y2t(t,r){return t==="animation"?"source":t==="prefab"?"json":t??Ozr(r)}function Ozr(t){const r=t.slice(t.lastIndexOf(".")+1).toLowerCase();return r==="glb"||r==="gltf"?"model":["png","jpg","jpeg","webp","gif","svg"].includes(r)?"image":["mp3","ogg","wav","flac"].includes(r)?"audio":["glsl","vert","frag","ts","tsx","js","jsx","css","html","md","txt"].includes(r)?"source":"json"}function PNt(t,r){const i=t.objectMap.get(r);if(!i)return null;const a=i.name||r;return KUe(t,`asset-editor:entity:${r}`,a,{assetPath:"",kind:"model",entityId:r},{origin:`entity:${r}`})}function Fzr(t,r,i){const a=vqr(i);return KUe(t,`asset-editor:subject:${r}`,i.name,{assetPath:a,kind:i.kind,displayName:i.name,...i.sourcePath?{sourcePath:i.sourcePath}:{}},i.sourcePath?{sourcePath:i.sourcePath}:{origin:`entity:${r}`})}function Rzr(t,r){const i=gb.get(t);if(!i)return;const{online:a,...l}=i;gb.set(t,{...l,assetPath:r}),OR()}function Mzr(t,r){const i=gb.get(t);if(!i?.assetPath)return;const a=Q7(i.assetPath);if(r.type==="move"&&r.oldPath&&r.newPath&&a===Q7(r.oldPath)){const l=`/${Q7(r.newPath)}`;gb.set(t,{...i,assetPath:l}),TNt.set(Q7(l),t),GDt(t,l.split("/").pop()??l),OR()}else r.type==="delete"&&r.paths?.some(l=>Q7(l)===a)?(gb.set(t,{...i,unavailableReason:`The source ${i.assetPath} was deleted. Undo the deletion or close this editor.`}),OR()):r.type==="change"&&r.paths?.some(l=>Q7(l)===a)&&(gb.set(t,{...i,revision:(i.revision??0)+1}),OR())}function Lzr(t){return t.online?"online":wg(t.assetPath).editor==="environment"?"environment":t.kind==="json"?"json":["model","image","video","audio","source"].includes(t.kind)?t.kind:"unsupported"}function v7e(t){return{id:"source",title:"Source",icon:Xkt,order:hZ,body:{kind:"custom",render:()=>z.jsx("div",{style:{padding:4},children:t.sourcePath??t.assetPath})}}}function jzr({id:t,spec:r,active:i}){if(r.unavailableReason)return z.jsx(g7e,{documentId:t,active:i,type:r.kind,title:r.assetPath.split("/").pop()||"Deleted asset",status:"Source unavailable",children:z.jsx("div",{style:{padding:20,color:nMe},children:r.unavailableReason})});const a=Lzr(r);if(a==="online"&&r.online){const g=r.online;return z.jsx(g7e,{documentId:t,active:i,type:"online",title:g.name,sections:[{id:"online-asset",title:"Asset",icon:hDr,order:hZ,body:{kind:"custom",render:()=>z.jsx(K2t,{online:g,mode:"inspector",onResolved:b=>Rzr(t,b)})}}],status:`${g.type} · ${g.source}`,children:z.jsx(K2t,{online:g,mode:"preview"})})}const l=(r.displayName??r.assetPath.split("/").pop())||r.entityId||"Asset",d=`${t}:${r.revision??0}`;if(a==="model")return r.assetPath?z.jsx(Tzr,{documentId:t,assetPath:r.assetPath,displayName:l,active:i},d):r.entityId?z.jsx(Szr,{documentId:t,entityId:r.entityId,displayName:l,active:i},d):z.jsx("div",{style:{padding:20,color:nMe},children:"Model source is unavailable."});if(a==="environment")return z.jsx(xzr,{documentId:t,assetPath:r.assetPath,active:i},d);if(a==="source")return z.jsx(kzr,{documentId:t,assetPath:r.assetPath,active:i},d);if(a==="json")return z.jsx(Ezr,{documentId:t,assetPath:r.assetPath,displayName:l,active:i,sections:[v7e(r)],status:`json · ${r.sourcePath??r.displayName??r.assetPath}`},d);let _;switch(a){case"image":_=z.jsx(wzr,{assetPath:r.assetPath,...r.displayName?{displayName:r.displayName}:{}},d);break;case"video":_=z.jsx(Czr,{assetPath:r.assetPath},d);break;case"audio":_=z.jsx(Azr,{assetPath:r.assetPath},d);break;default:_=z.jsx("div",{style:{padding:16,color:od[2],fontSize:12},children:"No viewer available for this asset type."})}return z.jsx(g7e,{documentId:t,active:i,type:a,title:l,fill:a==="image"||a==="video",sections:a==="image"&&!r.assetPath.includes("#")||a==="video"||a==="audio"?[{id:"media-properties",title:"Properties",icon:Xkt,order:hZ,body:{kind:"custom",render:()=>z.jsx(ENt,{assetPath:r.assetPath,kind:a},d)}},...r.sourcePath?[v7e(r)]:[]]:[v7e(r)],status:`${a} · ${r.sourcePath??r.displayName??r.assetPath}`,children:_})}function Bzr({documentId:t,active:r}){Xe.useSyncExternalStore(Izr,Dzr),Xe.useEffect(()=>{const a=l=>{Mzr(t,l.detail)};return window.addEventListener("editor:asset-mutation",a),()=>window.removeEventListener("editor:asset-mutation",a)},[t]);const i=gb.get(t);return z.jsx("div",{"data-testid":`asset-document:${t}`,style:{flex:1,minHeight:0,overflow:"hidden",pointerEvents:"auto",background:Pze[1]},children:i?z.jsx(Xe.Suspense,{fallback:z.jsx("div",{style:{padding:16,color:od[2],fontSize:12},children:"Loading asset viewer…"}),children:z.jsx(jzr,{id:t,spec:i,active:r})}):z.jsx("div",{style:{padding:16,color:od[2],fontSize:12},children:"This asset document is no longer available."})})}function Q7(t){return t.split(/[?#]/,1)[0].replace(/^\/+/,"")}const $zr=["three","pixi","dom","babylon","phaser"],NNt=Object.freeze({up:"y",groundHeight:0}),ONt=Na({surface:jd(["three","canvas","dom"]).describe("An additional surface this root mounts, beside the manifest root’s own adapter"),include:o_(Ss().min(1)).min(1).describe("Project-relative globs (`**`, `*`, `?`) naming the source files that render on this additional surface")}).strict(),qzr=Na({up:jd(["y","z"]).describe("World axis pointing away from the ground"),groundHeight:Tu().describe("Ground offset along `up`, in world units")}).strict(),zzr=Na({id:Ss().min(1).describe("Manifest root id this region grades"),surface:jd(["three","canvas","dom"]).describe("Render surface the host hands this root"),substrate:jd($zr).describe("Native substrate serving this region, by name"),dialect:Ss().min(1).nullable().describe("Dialect writer serving this region, by name; null states outright that the host writes no source here (the region's truth is the game's own code)"),anchors:o_(jd(H8r)).describe("Anchor kinds this region’s writer serves"),basis:qzr.optional().describe("World basis (up axis + ground height); omit for the native +Y / 0 default"),include:o_(Ss().min(1)).min(1).optional().describe("Project-relative globs (`**`, `*`, `?`) naming source files this region owns, for files no root entry’s import closure reaches; a declared include wins over reach"),mounts:o_(ONt).min(1).optional().describe("Surfaces this root mounts BESIDE its own adapter, each with the files that render on them; with `surface`, the root’s full mounted surface set")}).strict(),Uzr=Aee([Ry("manifest-roots"),o_(zzr).min(1)]),Vzr=Na({include:o_(Ss().min(1)).min(1).optional().describe("Project-relative globs (`**`, `*`, `?`) naming source files this derived region owns, for files no root entry’s import closure reaches; a declared include wins over reach"),mounts:o_(ONt).min(1).optional().describe("Surfaces this root mounts BESIDE its own adapter, each with the files that render on them; with the derived region’s own surface, the root’s full mounted surface set")}).strict().refine(t=>t.include!==void 0||t.mounts!==void 0,{message:"regionIncludes entry declares neither `include` nor `mounts` — an empty overlay states nothing the derivation did not already say. Remove it, or name the files it owns."}),Jzr=UR(Ss().min(1),Vzr).describe("Per-region parameters for the `manifest-roots` rule, keyed by manifest root id: the `include` globs and `mounts` surfaces the mechanical derivation cannot produce");function FNt(t,r={}){return t.map(i=>({...Gzr(i),...Wzr(r[i.id])}))}function Wzr(t){return t?{...t.include?{include:t.include}:{},...t.mounts?{mounts:t.mounts}:{}}:{}}function Hzr(t,r){const i=new Set(t.map(a=>a.id));return Object.keys(r).filter(a=>!i.has(a))}function Gzr(t){const r=t.surface,i=t.adapter.type==="builtin",a=r==="canvas"?"pixi":r,l=NNt;return i?r==="dom"?{id:t.id,surface:r,substrate:a,dialect:"jsx",anchors:["source-prop","source-structure"],basis:l}:{id:t.id,surface:r,substrate:a,dialect:r==="three"?"r3f":"pixi-react",anchors:["source-prop","source-structure","construction-literal"],basis:l}:{id:t.id,surface:r,substrate:a,dialect:null,anchors:["live-only"],basis:l}}const age="exported-composition-regions",Qzr=Na({finder:Ss().min(1).describe("Registered finder name")}).passthrough(),Kzr=Aee([Na({kind:Ry("root-mount")}).strict(),Na({kind:Ry("entrypoint-selection"),selection:Ss().min(1),key:Ss().min(1),active:gv().optional()}).strict(),Na({kind:Ry("story"),storyId:Ss().min(1)}).strict(),Na({kind:Ry("game-contract"),sceneId:Ss().min(1)}).strict(),Na({kind:Ry("none"),reason:Ss().min(1)}).strict()]),X2t=Na({path:Ss().min(1),export:Ss().min(1).optional()}).strict(),Yzr=Na({id:Ss().min(1),label:Ss().min(1),kind:Ss().min(1),region:Ss().min(1).nullable(),authorable:gv(),reach:Kzr,source:X2t.optional(),isolationSetup:X2t.optional(),finder:Ss().min(1).optional()}).strict(),Xzr=Na({entries:o_(Yzr).optional(),find:o_(Qzr).optional(),default:Ss().min(1).optional()}).strict(),Zzr=["command","state"],eUr="observation.kind must be 'command' or 'state' — the two DebugAdapter faces a declaration projects onto. A SystemAdapters slot is declared through the game contract’s `systemAdapters` carrier, which validates it per-surface; declaring one here would be a second door onto the same slot with no rule for which wins.",tUr=Na({id:Ss().min(1),kind:jd(Zzr,{error:()=>eUr}),description:Ss().min(1).optional(),locus:jd(["client","server"]).optional(),answer:IR(t=>typeof t=="function",{message:"observation.answer must be a function evaluated against the mounted game"}).optional()}).strict().refine(t=>t.kind==="command"||t.locus===void 0,{path:["locus"],message:"observation.locus is valid only for a command declaration"}),rUr=Na({root:Ss().min(1),actions:IR(t=>typeof t=="function",{message:"input.actions must be a function returning the app-owned action vocabulary"}),set:IR(t=>typeof t=="function",{message:"input.set must be a function writing the app-owned input store"}),clear:IR(t=>typeof t=="function",{message:"input.clear must be a function releasing app-owned virtual actions"})}).strict(),nUr=Na({Layout:IR(t=>typeof t=="function","Layout must be an imported React component").optional(),style:IR(t=>typeof t=="object"&&t!==null&&typeof Reflect.get(t,"id")=="string","style must be an imported StyleContribution object").optional(),keymap:IR(t=>typeof t=="object"&&t!==null&&typeof Reflect.get(t,"id")=="string","keymap must be an imported KeymapContribution object").optional(),workspace:Ss().min(1).optional(),inspector:jd(["column","properties","card"]).optional(),playUtilities:o_(Ss().min(1)).optional()}).strict(),iUr="`regionIncludes` states parameters for the `manifest-roots` RULE, so it cannot be paired with an explicit `regions` list — that form is the full replacement, and each entry carries its own `include`/`mounts`. Move these globs onto the matching `regions[]` entry, or drop the list and let the derivation run.",sUr=Na({editor:nUr.optional(),regions:Uzr.optional(),regionIncludes:Jzr.optional(),documents:Xzr.optional(),observation:o_(tUr).optional(),input:rUr.optional()}).strict().refine(t=>t.regionIncludes===void 0||Object.keys(t.regionIncludes).length===0||!Array.isArray(t.regions),{message:iUr});function RNt(t={}){const r=sUr.safeParse(t);if(!r.success)throw new Error(`vgai.adapter.ts: invalid adapter definition — ${r.error.issues.map(i=>`${i.path.join(".")||"(root)"}: ${i.message}`).join("; ")}`);return Object.freeze({...t.editor?{editor:Object.freeze({...t.editor,...t.editor.playUtilities?{playUtilities:Object.freeze([...t.editor.playUtilities])}:{}})}:{},regions:t.regions??"manifest-roots",regionIncludes:Object.freeze({...t.regionIncludes??{}}),documents:Object.freeze({...t.documents??{}}),observation:Object.freeze([...t.observation??[]]),...t.input?{input:t.input}:{}})}function B$(t={}){return RNt({regions:"manifest-roots",...t.regionIncludes?{regionIncludes:t.regionIncludes}:{},documents:{...t.scenes?{entries:t.scenes}:{},find:[{finder:"scenesFromEntrypointSelection",regions:age},{finder:"prefabsFromStories"}]}})}function Z2t(t){if(t===null||typeof t!="object")throw new Error(`vgai.adapter.ts must default-export defineAdapter({…}) / nativeAdapter() — got ${t===null?"null":typeof t}`);return RNt(t)}const TX=new Map;function MNt(t){const r=t;return TX.set(t.name,r),()=>{TX.get(t.name)===r&&TX.delete(t.name)}}function LNt(t,r){const i=t??{},a=[];(typeof i.name!="string"||i.name.length===0)&&a.push("`name` must be a non-empty string");const l=i.schema;if((!l||typeof l.safeParse!="function")&&a.push("`schema` must be a Zod schema"),typeof i.run!="function"&&a.push("`run(selection, input)` must be a function"),a.length>0)throw new Error(`${r}: not a finder — ${a.join("; ")}`);return MNt(i)}function oUr(){return[...TX.keys()]}function aUr(t,r){const i=TX.get(t.finder);if(!i){const l=oUr();throw new Error(`Unknown finder ${JSON.stringify(t.finder)} — registered: ${l.length>0?l.map(d=>`"${d}"`).join(", "):"none"}`)}const a=i.schema.safeParse(t);if(!a.success)throw new Error(`Finder ${JSON.stringify(t.finder)}: ${a.error.issues.map(l=>`${l.path.join(".")||"(selection)"}: ${l.message}`).join("; ")}`);return i.run(a.data,r)}function eSt(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var b7e={exports:{}};const cUr={},lUr=Object.freeze(Object.defineProperty({__proto__:null,default:cUr},Symbol.toStringTag,{value:"Module"})),NN=DIr(lUr);var tSt;function uUr(){return tSt||(tSt=1,(function(t){var r={};/*! *****************************************************************************
|
|
79
|
+
</style><main><div class="brand-mark">${DMr()}</div><h1>Session ended</h1><p>This editor session has ended. You can close this tab.</p></main>`}))}const nge=new Set;function Tqr(t){return nge.add(t),()=>{nge.delete(t)}}function kqr(){try{window.focus()}catch{}if(nge.size===0){window.location.reload();return}for(const t of[...nge])t()}function Iqr(t,r,i={}){t.addEventListener("tab-refocus",a=>xqr(a)),t.addEventListener("tab-yield",a=>wqr(r,a)),t.addEventListener("tab-close",()=>Eqr(r,i)),t.addEventListener("tab-adopt",()=>kqr())}const Gk="/__editor",Dqr=globalThis,Ad=Dqr.__VGAI_EDITOR_PRESENCE_BOOTSTRAP__,jP=Ad?.clientId??globalThis.crypto?.randomUUID?.()??`editor-${Date.now()}`,V0e=CDt,Pqr=S8r;function Nqr(t){Ad?.reportPhase?.(t)}function Oqr(t){Ad?.reportCensus?.(t)}function Fqr(){Ad?.stopHeartbeat?.();const t=pw;if(t!==null){pw=null,Y$=0,Ad?.source===t&&(Ad.source=null),gz===t&&(gz=null);try{t.close()}catch{}}}function Rqr(){const t=new URLSearchParams({clientId:jP,participantId:V0e,displayName:Pqr});return Ad?.tabId&&t.set("tabId",Ad.tabId),`${Gk}/events?${t}`}let pw=Ad?.source??null,Y$=Ad?.source&&Ad.pageOwned?1:0,gz=null;const hNt=new Set(["editor-command"]);function gNt(t,r){if(!Ad||Ad.source!==t)return;Ad.queueListeners=Ad.queueListeners.filter(({type:a,listener:l})=>r(a)?(t.removeEventListener(a,l),!1):!0);const i=Ad.pending.filter(a=>r(a.type));Ad.pending=Ad.pending.filter(a=>!r(a.type));for(const{type:a,data:l}of i)t.dispatchEvent(new MessageEvent(a,{data:l}))}function Mqr(t){gz!==t&&(gz=t,Iqr(t,Gk,{tabId:Ad?.tabId,epoch:Ad?.epoch}),gNt(t,r=>!hNt.has(r)))}function VP(){pw||(Ad?.source?(pw=Ad.source,Ad.pageOwned&&Y$++):(pw=new EventSource(Rqr()),Ad&&(Ad.source=pw)));const t=pw;Mqr(t),Y$++;const r=[];let i=!1;return{addEventListener(a,l){const d=l;t.addEventListener(a,d),r.push({type:a,listener:d}),hNt.has(a)&&gNt(t,_=>_===a)},removeEventListener(a,l){const d=l;t.removeEventListener(a,d);const _=r.findIndex(g=>g.type===a&&g.listener===d);_>=0&&r.splice(_,1)},close(){if(!i){i=!0;for(const{type:a,listener:l}of r)t.removeEventListener(a,l);r.length=0,Y$--,Y$<=0&&(t.close(),pw===t&&(pw=null),Ad?.source===t&&(Ad.source=null),gz===t&&(gz=null),Y$=0)}}}}function Lqr(){const t=pw??Ad?.source??null;if(!t)return"unknown";if(typeof t.connected=="boolean")return t.connected?"open":"closed";const r=t.readyState;return typeof r=="number"?r===1?"open":"closed":"unknown"}function jqr(){if(typeof EventSource>"u")return()=>{};const t=VP(),r=HUe(a=>{a!==null&&a.reason!=="server-gone"&&Fqr()}),i=$qr();return()=>{i(),r(),t.close()}}const Bqr=5;function $qr(){if(typeof window>"u")return()=>{};let t=0;const r=l=>{l===""||t>=Bqr||(t+=1,EX("console-entries",{entries:[{id:`boot-error:${t}`,severity:"error",message:`editor app failed to start: ${l}`,source:"runtime",occurrences:1}],_clientId:Ad?.clientId??"boot"}))},i=l=>{const d=l.error;r(d?.stack??`${l.message} (${l.filename??"?"}:${l.lineno??0})`)},a=l=>{const d=l.reason;L3t(d)||r(d instanceof Error?d.stack??d.message:`unhandled rejection: ${String(d)}`)};return window.addEventListener("error",i),window.addEventListener("unhandledrejection",a),()=>{window.removeEventListener("error",i),window.removeEventListener("unhandledrejection",a)}}const qqr=2e3,zqr={"command-received":`${Gk}/command-received`,"command-result":`${Gk}/command-result`,"command-listener":`${Gk}/command-listener`,"console-entries":`${Gk}/console-entries`,"console-resolved":`${Gk}/console-resolved`,"play-phase":`${Gk}/play-phase`,state:`${Gk}/state`,"tab-route":`${Gk}/tab/route`};async function EX(t,r){if(!(typeof fetch>"u"))try{await fetch(zqr[t],{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...r,...Ad?.controlLifecycle?{_controlLifecycle:Ad.controlLifecycle}:{}})})}catch{}}async function R8(t,r){(pw??Ad?.source??null)?.send?.(t,r)||await EX(t,r)}async function Uqr(t,r){const i=pw??Ad?.source??null;if(!i){await EX("command-result",r);return}let a;const l=new Promise(S=>{a=S}),d=S=>{const k=S.data;let w=k;if(typeof k=="string")try{w=JSON.parse(k)}catch{}w===t&&a()};i.addEventListener($2t,d);const _={...r,_awaitCallerReceipt:!0};i.send?.("command-result",_)||await EX("command-result",_);let g,b=!1;await Promise.race([l.then(()=>{b=!0}),new Promise(S=>{g=setTimeout(S,qqr)})]),g!==void 0&&clearTimeout(g),b||await EX("command-result",r),i.removeEventListener($2t,d)}function Vqr(t){R8("tab-route",{clientId:jP,participantId:V0e,route:t})}function GUe(t){return{ok:!1,reason:t instanceof Error?t.message:String(t)}}async function Jqr(t,r){try{const i=new URLSearchParams({root:t,dir:r}),a=await fetch(`${W_}/assets?${i}`,{cache:"no-store"});return{ok:!0,entries:(await Eg(a,`Could not list ${t}/${r} from ${W_}/assets`)).entries??[]}}catch(i){return GUe(i)}}async function J0e(t,r){if(t!=="public")return Jqr(t,r);try{return{ok:!0,entries:(await _z().list(r)).map(a=>({name:a.name,type:a.type==="dir"?"directory":"file",...a.size===void 0?{}:{size:a.size},...a.mtime===void 0?{}:{modifiedAt:a.mtime}}))}}catch(i){return GUe(i)}}async function yNt(){try{const t=await fetch(`${W_}/project-components`,{cache:"no-store"});return{ok:!0,entries:(await Eg(t,`Could not list project components from ${W_}/project-components`)).components??[]}}catch(t){return GUe(t)}}class z2t extends Error{constructor(r,i){super(i),this.code=r,this.name="AssetDeliveryError"}}function U2t(t){return{offline:"Network delivery is offline. SSD assets remain available.","quota-limited":"The remote provider quota is exhausted. Retry after the provider resets it.","license-blocked":"This delivery is blocked because its license terms are not accepted.",unavailable:"No healthy SSD, cloud, or remote delivery is available for this variant.","provider-error":"The remote provider could not return delivery metadata. Retry the request."}[t]}const Wqr=new Map,Hqr=new Set;function Gqr(t,r){return`${t}:${r}`}async function ZDn(t,r){return Qqr(t,r)}async function Qqr(t,r){const i=new URLSearchParams({source:t,id:r});let a;try{a=await fetch(`${W_}/asset-library/files?${i}`)}catch(d){throw new z2t("offline",d instanceof Error?d.message:U2t("offline"))}if(np(a,"Asset Library file lookup failed"),!a.ok){const d=await a.json().catch(()=>null),_=a.status===403?"license-blocked":a.status===429?"quota-limited":a.status===404?"unavailable":"provider-error";throw new z2t(_,d?.error??U2t(_))}return(await a.json()).files}async function e3n(t,r){const i=new URLSearchParams({source:t,id:r}),a=await fetch(`${W_}/asset-library/preview?${i}`);return np(a,"Could not resolve an asset preview"),a.ok?await a.json():null}async function t3n(t){const r=await fetch(`${W_}/asset-library/download`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...t,signal:void 0}),...t.signal?{signal:t.signal}:{}});np(r,"Could not download the asset");const i=await r.json();if(i.ok&&i.path){Wqr.set(Gqr(t.source,t.id),`/${i.path}`);for(const a of Hqr)a()}return i}async function r3n(t){const r=await fetch(`${W_}/asset-library/history/capture`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({assetPath:t})});np(r,"Asset history capture failed");const i=await r.json();if(!r.ok||!i.token)throw new Error(i.error??`Asset history capture failed (${r.status}).`);return i.token}async function n3n(t,r){const i=await fetch(`${W_}/asset-library/history/restore`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({assetPath:t,token:r})});if(np(i,"Asset history restore failed"),!i.ok){const a=await i.json().catch(()=>null);throw new Error(a?.error??`Asset history restore failed (${i.status}).`)}}function Kqr(t){if(!t||typeof t!="object")return null;const r=t;return r.apiVersion!==1||typeof r.engineVersion!="string"&&r.engineVersion!==null||typeof r.manifestVersion!="number"||typeof r.startedAt!="string"||!r.source||r.source.state!=="current"&&r.source.state!=="restart-required"||r.source.state==="restart-required"&&(typeof r.source.changedPath!="string"||typeof r.source.changedAt!="string")?null:r}async function Yqr(){let t;try{t=await fetch(`${W_}/compatibility`,{cache:"no-store"})}catch(r){throw i2t(r instanceof Error?r.message:String(r))}if(t.status>=500)throw i2t(`HTTP ${t.status}`);try{rU(t,`GET ${W_}/compatibility`)}catch{return null}try{return Kqr(await t.json())}catch{return null}}async function vNt(){const t=await Yqr();if(!t)throw zMr();return UMr(t),t}async function Xqr(){try{const t=await fetch(`${W_}/recent-projects`);return(await Eg(t,"Could not list recent projects")).projects}catch{return[]}}const V2t={reopenLastProject:!1};async function Zqr(){try{const t=await fetch(`${W_}/launcher-settings`),r=await Eg(t,"Could not read launcher settings");return{reopenLastProject:typeof r.reopenLastProject=="boolean"?r.reopenLastProject:V2t.reopenLastProject}}catch{return{...V2t}}}async function ALe(t){const r=await fetch(`${W_}/reveal`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:t})});rU(r,`Could not reveal ${t}`)}async function ezr(t){try{const r=await fetch(`${W_}/save-thumbnail`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dataUrl:t})});return rU(r,"Could not save the project thumbnail"),!0}catch{return!1}}async function bNt(){let t;try{const i=await fetch(`${W_}/project`);t=await Eg(i,`No answer from ${W_}/project`)}catch(i){return{status:"unknown",error:i instanceof Error?i.message:String(i)}}if(t.project)return{status:"project",project:t.project};const r=t.serving;return r&&typeof r.path=="string"?{status:"unreadable",path:r.path,error:typeof r.error=="string"?r.error:"unknown error"}:t.project===null?{status:"none"}:{status:"unknown",error:`Unrecognized ${W_}/project response`}}async function ige(t){try{const r=await fetch(Fee(t));if(r.ok)return await r.text()}catch{}return null}function tzr(t){return(t.headers.get("content-type")??"").toLowerCase().includes("text/html")}async function ANt(t){try{const r=await fetch(Fee(t),{method:"HEAD"});return r.ok?tzr(r)?"absent":"present":"absent"}catch{return"unreachable"}}async function rzr(t){return await ANt(t)==="present"}async function SNt(t,r={}){if(t.length===0)return[];const i=await fetch(`/__editor/source-files?${new URLSearchParams([...t.map(l=>["include",l]),...r.order==="mtime"?[["order","mtime"]]:[]])}`);return i.ok?(await i.json()).files??[]:[]}async function nzr(t=3e3){if(typeof fetch>"u")return{ok:!1};try{const r=await fetch(`${W_}/project`,{signal:AbortSignal.timeout(t)}),i=await Eg(r,"Editor lease poll failed");return{ok:!0,identity:{project:typeof i.project?.path=="string"?i.project.path:null,pid:typeof i.session?.pid=="number"?i.session.pid:null}}}catch{return{ok:!1}}}async function izr(){try{const t=await fetch(`${W_}/editor-state`);return await Eg(t,"Could not read editor state")}catch{return{}}}let J2t=!1;async function szr(t){try{const r=await fetch(`${W_}/editor-state`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});return rU(r,"Could not save editor state"),!0}catch(r){return J2t||(J2t=!0,console.error(r instanceof Error?r.message:String(r))),!1}}let QY=null,sge=null;async function xNt(){for(;QY;){const t=QY;QY=null,await R8("state",{...t,_clientId:jP})}sge=null,QY&&(sge=xNt())}function W2t(t){return QY=t,sge??=xNt(),sge}async function ozr(t){await R8("command-received",{_requestId:t,_clientId:jP})}async function Wpe(t){await R8("command-listener",{_clientId:jP,attached:t})}function azr(t){Nqr(t.phase),R8("play-phase",{_clientId:jP,...t})}async function H2t(t,r,i,a,l=!1){const d={_requestId:t,_clientId:jP,ok:r,error:i,data:a};l?await Uqr(t,d):await R8("command-result",d)}async function czr(){const t=await fetch(`${W_}/project`,{cache:"no-store"});if(np(t,"Could not read this session’s worktree identity"),!t.ok)return{branch:null,worktreeId:null};const r=await t.json().catch(()=>null);return{branch:typeof r?.session?.branch=="string"?r.session.branch:null,worktreeId:typeof r?.session?.worktreeId=="string"?r.session.worktreeId:null}}async function JP(t,r){const i=await fetch(`${W_}/worktrees${t}`,r);np(i,`Worktree operation ${t||"(list)"} failed`);const a=await i.json().catch(()=>null);if(!i.ok)throw new Error(typeof a?.error=="string"?a.error:`Worktree operation failed (${i.status}).`);return a??{}}function W0e(t){return{worktrees:Array.isArray(t.worktrees)?t.worktrees:[],branches:Array.isArray(t.branches)?t.branches:[],isolatedWorktrees:Array.isArray(t.isolatedWorktrees)?t.isolatedWorktrees:[]}}async function lzr(){const t=await JP("");return W0e(t)}async function uzr(t){return await JP("/open",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({worktreeId:t})})}async function G2t(t,r="HEAD"){return await JP("/create",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({branch:t,from:r})})}async function fzr(t){return JP("/delegate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}async function dzr(t){const r=await JP(`/isolated/${encodeURIComponent(t)}/logs`);return typeof r.logs=="string"?r.logs:""}async function pzr(t){const r=await JP("/isolated/export",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:t})});return W0e(r)}async function Q2t(t,r){const i=await JP("/isolated/stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:t,discard:r})});return W0e(i)}async function _zr(t){const r=await JP("/archive",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({worktreeId:t})});return W0e(r).worktrees}async function mzr(t,r){await JP("/stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({worktreeId:t,sessionId:r})})}let wNt=null;const hzr=new Set,SLe=new Set;function gzr(t){wNt=t;for(const r of hzr)r(t);for(const r of SLe)r()}function Qh(){return wNt}function Hpe(t){return SLe.add(t),()=>{SLe.delete(t)}}const _I="references",CNt=["public",_I],QUe=`/project-game-static/${_I}/`;function oge(t,r){return`${t}/${r}`}function H0e(t,r){return t===_I?`${QUe}${r}`:`/${r}`}function yzr(t){return t.startsWith(QUe)}function vzr(t){const r=t.startsWith("/")?t:`/${t}`;if(yzr(r))return oge(_I,r.slice(QUe.length));const i=t.startsWith("/")?t.slice(1):t;return i.startsWith("public/")?i:`public/${i}`}function ENt({assetPath:t,kind:r,sizeBytes:i}){return z.jsx(bzr,{assetPath:t,kind:r,sizeBytes:i},t)}function bzr({assetPath:t,kind:r,sizeBytes:i}){const a=t.split("#")[0],l=a.startsWith("/")||/^(?:data|blob|https?):/.test(a)?a:`/${a}`,d=vzr(a),[_,g]=Xe.useState(i),[b,S]=Xe.useState(null),[k,w]=Xe.useState(null);Xe.useEffect(()=>{if(i!==void 0){g(i);return}let X=!1;const[G,...ee]=d.split("/"),xe=ee.pop();return J0e(G,ee.join("/")).then(ue=>{!X&&ue.ok&&g(ue.entries.find(fe=>fe.name===xe)?.size)}),()=>{X=!0}},[d,i]),Xe.useEffect(()=>{if(S(null),w(null),r==="image"){const G=new Image;return G.onload=()=>S({width:G.naturalWidth,height:G.naturalHeight}),G.onerror=()=>w("Image properties could not be read."),G.src=l,()=>{G.onload=null,G.onerror=null}}const X=document.createElement(r);return X.preload="metadata",X.onloadedmetadata=()=>S({...Number.isFinite(X.duration)?{duration:X.duration}:{},...X instanceof HTMLVideoElement?{width:X.videoWidth,height:X.videoHeight}:{}}),X.onerror=()=>w("Media properties could not be read. The file may be missing or unsupported."),X.src=l,()=>{X.onloadedmetadata=null,X.onerror=null,X.removeAttribute("src"),X.load()}},[l,r]);const N=b?.width,P=b?.height,j=[];if(N&&P){let X=N,G=P;for(;G;)[X,G]=[G,X%G];j.push(["Dimensions",`${N} × ${P} px`],["Aspect ratio",`${N/X}:${P/X}`])}b?.duration!==void 0&&j.push(["Duration",`${Number(b.duration.toFixed(3))} s`]);const J=a.split("?")[0].match(/\.([^./]+)$/)?.[1];return J&&j.push(["Format",J.toUpperCase()]),_!==void 0&&j.push(["File size",_<1024?`${_} B`:`${(_/(_<1024*1024?1024:1024*1024)).toFixed(1)} ${_<1024*1024?"KB":"MB"}`]),j.push(["Location",d]),z.jsxs("div",{"data-testid":"media-properties",style:{padding:8,fontSize:12},children:[k?z.jsx("p",{role:"status",style:{color:od[2]},children:k}):!b&&z.jsx("p",{role:"status",style:{color:od[3]},children:"Reading media properties…"}),z.jsx("dl",{style:{margin:0,display:"grid",gridTemplateColumns:"auto minmax(0, 1fr)",gap:"10px 12px"},children:j.map(([X,G])=>z.jsxs("div",{style:{display:"contents"},children:[z.jsx("dt",{style:{color:od[3]},children:X}),z.jsx("dd",{style:{margin:0,color:od[1],overflowWrap:"anywhere"},children:G})]},X))})]})}const g7e=Xe.lazy(async()=>({default:(await Xo(()=>Promise.resolve().then(()=>p5r),void 0)).AssetEditorShell})),Azr=Xe.lazy(async()=>({default:(await Xo(()=>import("./AudioViewer-_65u1JZP.js"),__vite__mapDeps([46,1,2,3,4,8,9,10,11,6]))).AudioViewer})),Szr=Xe.lazy(async()=>({default:(await Xo(()=>import("./EntityModelDocument-B01ItUUL.js"),__vite__mapDeps([47,1,2,3,4,8,9,10,42,6,7,40,14,43,41,11]))).EntityModelDocument})),xzr=Xe.lazy(async()=>({default:(await Xo(()=>import("./EnvironmentAssetDocument-Bi3xStlu.js"),__vite__mapDeps([48,1,2,3,4,8,9,10,6,40,49,50,11]))).EnvironmentAssetDocument})),wzr=Xe.lazy(async()=>({default:(await Xo(()=>import("./ImageViewer-CxxsCkXk.js"),__vite__mapDeps([51,1,2,3,4,8,9,10,11,6]))).ImageViewer})),Czr=Xe.lazy(async()=>({default:(await Xo(()=>import("./VideoViewer-DOhDskaJ.js"),__vite__mapDeps([52,1,2,3,4,8,9,10,11,6]))).VideoViewer})),Ezr=Xe.lazy(async()=>({default:(await Xo(()=>import("./JsonAssetDocument-4RfU5RS8.js").then(r=>r.a),__vite__mapDeps([53,1,2,3,4,8,9,10,42,6,7,40,14,43,41]))).JsonAssetDocument})),Tzr=Xe.lazy(async()=>({default:(await Xo(()=>import("./ModelAssetDocument-C0WYRlmP.js"),__vite__mapDeps([54,1,2,3,4,8,9,10,42,6,7,40,14,43,41,11]))).ModelAssetDocument})),K2t=Xe.lazy(async()=>({default:(await Xo(()=>import("./OnlineAssetDetail-Bl-DFUDz.js"),__vite__mapDeps([55,1,2,3,4,8,9,50,10,11,6]))).OnlineAssetDetail})),kzr=Xe.lazy(async()=>({default:(await Xo(()=>import("./SourceAssetViewer-Dq5hik7X.js"),__vite__mapDeps([56,1,2,3,4,8,9,10,53,42,6,7,40,14,43,41,46,11,48,49,50,51,57,58,59,60,61,54]))).SourceAssetViewer})),gb=new Map,TNt=new Map,y7e=new Map;let kNt=0;const xLe=new Set;function OR(){kNt++;for(const t of xLe)t()}function Izr(t){return xLe.add(t),()=>{xLe.delete(t)}}function Dzr(){return kNt}function Pzr(t){return gb.get(t)}function INt(t){return gb.has(t)}function Nzr(t,r){const i=new Set([...Object.keys(t),...Object.keys(r)]);for(const a of i){const l=t[a],d=r[a];if(l!==d&&JSON.stringify(l)!==JSON.stringify(d))return!1}return!0}function KUe(t,r,i,a,l,d={}){typeof document<"u"&&document.activeElement instanceof HTMLElement&&y7e.set(r,document.activeElement);const _=gb.get(r);if(!_)gb.set(r,a),OR();else{const b={..._,...a};Nzr(_,b)||(gb.set(r,b),OR())}const g={id:r,title:i,kind:"asset",workspaceRole:"authored-subject",...l?{provenance:l}:{},Content:Bzr,closeable:!0,presentation:()=>{const b=gb.get(r);return b?b.entityId?{kind:"asset",entityId:b.entityId,assetKind:"model"}:!b.assetPath||b.online?null:{kind:"asset",path:b.assetPath,assetKind:b.kind}:null},persist:()=>{const b=gb.get(r);if(!(!b?.assetPath||b.online||b.entityId!==void 0))return{path:b.assetPath,assetKind:b.kind}},onActivate:()=>{t.setActiveViewportTab("edit"),(a.kind==="image"||a.kind==="video"||a.kind==="audio")&&pP()},onDispose:b=>{gb.delete(b)&&OR();const S=y7e.get(b);y7e.delete(b),S?.isConnected&&setTimeout(()=>S.focus(),0)}};return qP(g,d)}function f8(t,r,i,a={}){const l=lqr(r),{frameName:d}=U0e(r),_=TNt.get(Q7(r))??r;return KUe(t,_,l,d?{assetPath:r,kind:i,displayName:l}:{assetPath:r,kind:i},{sourcePath:r},a)}Iee({kind:"asset",owner:"asset-documents",restore:async({state:t,store:r})=>{const i=t,a=typeof i?.path=="string"?i.path:null,l=typeof i?.assetKind=="string"?i.assetKind:null;return!a||!l||!await rzr(a)?!1:(f8(r,a,l),!0)}});async function DNt(t,r){return xE(()=>{if(I_()!==t)return!1;const i=Sze(t);return i?r!=="model"||i.adapter!==null:!1},m9)}g9({id:"asset",owner:"asset-documents",open:(t,r)=>{if(r.entityId){const a=Qh();if(!a)return null;const l=PNt(a,r.entityId);if(!l)throw new Error(`Scene entity is not available: ${r.entityId}`);return l}const i=r.path;return i===void 0?null:f8(t,i,Y2t(r.assetKind,i))},ready:async(t,r)=>{const i=r.entityId?"model":Y2t(r.assetKind,r.path??"");if(!await DNt(t,i))throw new Error(`Asset document did not finish mounting its Inspector: ${t}`);await Fze(t)}});function Y2t(t,r){return t==="animation"?"source":t==="prefab"?"json":t??Ozr(r)}function Ozr(t){const r=t.slice(t.lastIndexOf(".")+1).toLowerCase();return r==="glb"||r==="gltf"?"model":["png","jpg","jpeg","webp","gif","svg"].includes(r)?"image":["mp3","ogg","wav","flac"].includes(r)?"audio":["glsl","vert","frag","ts","tsx","js","jsx","css","html","md","txt"].includes(r)?"source":"json"}function PNt(t,r){const i=t.objectMap.get(r);if(!i)return null;const a=i.name||r;return KUe(t,`asset-editor:entity:${r}`,a,{assetPath:"",kind:"model",entityId:r},{origin:`entity:${r}`})}function Fzr(t,r,i){const a=vqr(i);return KUe(t,`asset-editor:subject:${r}`,i.name,{assetPath:a,kind:i.kind,displayName:i.name,...i.sourcePath?{sourcePath:i.sourcePath}:{}},i.sourcePath?{sourcePath:i.sourcePath}:{origin:`entity:${r}`})}function Rzr(t,r){const i=gb.get(t);if(!i)return;const{online:a,...l}=i;gb.set(t,{...l,assetPath:r}),OR()}function Mzr(t,r){const i=gb.get(t);if(!i?.assetPath)return;const a=Q7(i.assetPath);if(r.type==="move"&&r.oldPath&&r.newPath&&a===Q7(r.oldPath)){const l=`/${Q7(r.newPath)}`;gb.set(t,{...i,assetPath:l}),TNt.set(Q7(l),t),GDt(t,l.split("/").pop()??l),OR()}else r.type==="delete"&&r.paths?.some(l=>Q7(l)===a)?(gb.set(t,{...i,unavailableReason:`The source ${i.assetPath} was deleted. Undo the deletion or close this editor.`}),OR()):r.type==="change"&&r.paths?.some(l=>Q7(l)===a)&&(gb.set(t,{...i,revision:(i.revision??0)+1}),OR())}function Lzr(t){return t.online?"online":wg(t.assetPath).editor==="environment"?"environment":t.kind==="json"?"json":["model","image","video","audio","source"].includes(t.kind)?t.kind:"unsupported"}function v7e(t){return{id:"source",title:"Source",icon:Xkt,order:hZ,body:{kind:"custom",render:()=>z.jsx("div",{style:{padding:4},children:t.sourcePath??t.assetPath})}}}function jzr({id:t,spec:r,active:i}){if(r.unavailableReason)return z.jsx(g7e,{documentId:t,active:i,type:r.kind,title:r.assetPath.split("/").pop()||"Deleted asset",status:"Source unavailable",children:z.jsx("div",{style:{padding:20,color:nMe},children:r.unavailableReason})});const a=Lzr(r);if(a==="online"&&r.online){const g=r.online;return z.jsx(g7e,{documentId:t,active:i,type:"online",title:g.name,sections:[{id:"online-asset",title:"Asset",icon:hDr,order:hZ,body:{kind:"custom",render:()=>z.jsx(K2t,{online:g,mode:"inspector",onResolved:b=>Rzr(t,b)})}}],status:`${g.type} · ${g.source}`,children:z.jsx(K2t,{online:g,mode:"preview"})})}const l=(r.displayName??r.assetPath.split("/").pop())||r.entityId||"Asset",d=`${t}:${r.revision??0}`;if(a==="model")return r.assetPath?z.jsx(Tzr,{documentId:t,assetPath:r.assetPath,displayName:l,active:i},d):r.entityId?z.jsx(Szr,{documentId:t,entityId:r.entityId,displayName:l,active:i},d):z.jsx("div",{style:{padding:20,color:nMe},children:"Model source is unavailable."});if(a==="environment")return z.jsx(xzr,{documentId:t,assetPath:r.assetPath,active:i},d);if(a==="source")return z.jsx(kzr,{documentId:t,assetPath:r.assetPath,active:i},d);if(a==="json")return z.jsx(Ezr,{documentId:t,assetPath:r.assetPath,displayName:l,active:i,sections:[v7e(r)],status:`json · ${r.sourcePath??r.displayName??r.assetPath}`},d);let _;switch(a){case"image":_=z.jsx(wzr,{assetPath:r.assetPath,...r.displayName?{displayName:r.displayName}:{}},d);break;case"video":_=z.jsx(Czr,{assetPath:r.assetPath},d);break;case"audio":_=z.jsx(Azr,{assetPath:r.assetPath},d);break;default:_=z.jsx("div",{style:{padding:16,color:od[2],fontSize:12},children:"No viewer available for this asset type."})}return z.jsx(g7e,{documentId:t,active:i,type:a,title:l,fill:a==="image"||a==="video",sections:a==="image"&&!r.assetPath.includes("#")||a==="video"||a==="audio"?[{id:"media-properties",title:"Properties",icon:Xkt,order:hZ,body:{kind:"custom",render:()=>z.jsx(ENt,{assetPath:r.assetPath,kind:a},d)}},...r.sourcePath?[v7e(r)]:[]]:[v7e(r)],status:`${a} · ${r.sourcePath??r.displayName??r.assetPath}`,children:_})}function Bzr({documentId:t,active:r}){Xe.useSyncExternalStore(Izr,Dzr),Xe.useEffect(()=>{const a=l=>{Mzr(t,l.detail)};return window.addEventListener("editor:asset-mutation",a),()=>window.removeEventListener("editor:asset-mutation",a)},[t]);const i=gb.get(t);return z.jsx("div",{"data-testid":`asset-document:${t}`,style:{flex:1,minHeight:0,overflow:"hidden",pointerEvents:"auto",background:Pze[1]},children:i?z.jsx(Xe.Suspense,{fallback:z.jsx("div",{style:{padding:16,color:od[2],fontSize:12},children:"Loading asset viewer…"}),children:z.jsx(jzr,{id:t,spec:i,active:r})}):z.jsx("div",{style:{padding:16,color:od[2],fontSize:12},children:"This asset document is no longer available."})})}function Q7(t){return t.split(/[?#]/,1)[0].replace(/^\/+/,"")}const $zr=["three","pixi","dom","babylon","phaser"],NNt=Object.freeze({up:"y",groundHeight:0}),ONt=Na({surface:jd(["three","canvas","dom"]).describe("An additional surface this root mounts, beside the manifest root’s own adapter"),include:o_(Ss().min(1)).min(1).describe("Project-relative globs (`**`, `*`, `?`) naming the source files that render on this additional surface")}).strict(),qzr=Na({up:jd(["y","z"]).describe("World axis pointing away from the ground"),groundHeight:Tu().describe("Ground offset along `up`, in world units")}).strict(),zzr=Na({id:Ss().min(1).describe("Manifest root id this region grades"),surface:jd(["three","canvas","dom"]).describe("Render surface the host hands this root"),substrate:jd($zr).describe("Native substrate serving this region, by name"),dialect:Ss().min(1).nullable().describe("Dialect writer serving this region, by name; null states outright that the host writes no source here (the region's truth is the game's own code)"),anchors:o_(jd(H8r)).describe("Anchor kinds this region’s writer serves"),basis:qzr.optional().describe("World basis (up axis + ground height); omit for the native +Y / 0 default"),include:o_(Ss().min(1)).min(1).optional().describe("Project-relative globs (`**`, `*`, `?`) naming source files this region owns, for files no root entry’s import closure reaches; a declared include wins over reach"),mounts:o_(ONt).min(1).optional().describe("Surfaces this root mounts BESIDE its own adapter, each with the files that render on them; with `surface`, the root’s full mounted surface set")}).strict(),Uzr=Aee([Ry("manifest-roots"),o_(zzr).min(1)]),Vzr=Na({include:o_(Ss().min(1)).min(1).optional().describe("Project-relative globs (`**`, `*`, `?`) naming source files this derived region owns, for files no root entry’s import closure reaches; a declared include wins over reach"),mounts:o_(ONt).min(1).optional().describe("Surfaces this root mounts BESIDE its own adapter, each with the files that render on them; with the derived region’s own surface, the root’s full mounted surface set")}).strict().refine(t=>t.include!==void 0||t.mounts!==void 0,{message:"regionIncludes entry declares neither `include` nor `mounts` — an empty overlay states nothing the derivation did not already say. Remove it, or name the files it owns."}),Jzr=UR(Ss().min(1),Vzr).describe("Per-region parameters for the `manifest-roots` rule, keyed by manifest root id: the `include` globs and `mounts` surfaces the mechanical derivation cannot produce");function FNt(t,r={}){return t.map(i=>({...Gzr(i),...Wzr(r[i.id])}))}function Wzr(t){return t?{...t.include?{include:t.include}:{},...t.mounts?{mounts:t.mounts}:{}}:{}}function Hzr(t,r){const i=new Set(t.map(a=>a.id));return Object.keys(r).filter(a=>!i.has(a))}function Gzr(t){const r=t.surface,i=t.adapter.type==="builtin",a=r==="canvas"?"pixi":r,l=NNt;return i?r==="dom"?{id:t.id,surface:r,substrate:a,dialect:"jsx",anchors:["source-prop","source-structure"],basis:l}:{id:t.id,surface:r,substrate:a,dialect:r==="three"?"r3f":"pixi-react",anchors:["source-prop","source-structure","construction-literal"],basis:l}:{id:t.id,surface:r,substrate:a,dialect:null,anchors:["live-only"],basis:l}}const age="exported-composition-regions",Qzr=Na({finder:Ss().min(1).describe("Registered finder name")}).passthrough(),Kzr=Aee([Na({kind:Ry("root-mount")}).strict(),Na({kind:Ry("entrypoint-selection"),selection:Ss().min(1),key:Ss().min(1),active:gv().optional()}).strict(),Na({kind:Ry("story"),storyId:Ss().min(1)}).strict(),Na({kind:Ry("game-contract"),sceneId:Ss().min(1)}).strict(),Na({kind:Ry("none"),reason:Ss().min(1)}).strict()]),X2t=Na({path:Ss().min(1),export:Ss().min(1).optional()}).strict(),Yzr=Na({id:Ss().min(1),label:Ss().min(1),kind:Ss().min(1),region:Ss().min(1).nullable(),authorable:gv(),reach:Kzr,source:X2t.optional(),isolationSetup:X2t.optional(),finder:Ss().min(1).optional()}).strict(),Xzr=Na({entries:o_(Yzr).optional(),find:o_(Qzr).optional(),default:Ss().min(1).optional()}).strict(),Zzr=["command","state"],eUr="observation.kind must be 'command' or 'state' — the two DebugAdapter faces a declaration projects onto. A SystemAdapters slot is declared through the game contract’s `systemAdapters` carrier, which validates it per-surface; declaring one here would be a second door onto the same slot with no rule for which wins.",tUr=Na({id:Ss().min(1),kind:jd(Zzr,{error:()=>eUr}),description:Ss().min(1).optional(),locus:jd(["client","server"]).optional(),answer:IR(t=>typeof t=="function",{message:"observation.answer must be a function evaluated against the mounted game"}).optional()}).strict().refine(t=>t.kind==="command"||t.locus===void 0,{path:["locus"],message:"observation.locus is valid only for a command declaration"}),rUr=Na({root:Ss().min(1),actions:IR(t=>typeof t=="function",{message:"input.actions must be a function returning the app-owned action vocabulary"}),set:IR(t=>typeof t=="function",{message:"input.set must be a function writing the app-owned input store"}),clear:IR(t=>typeof t=="function",{message:"input.clear must be a function releasing app-owned virtual actions"})}).strict(),nUr=Na({Layout:IR(t=>typeof t=="function","Layout must be an imported React component").optional(),style:IR(t=>typeof t=="object"&&t!==null&&typeof Reflect.get(t,"id")=="string","style must be an imported StyleContribution object").optional(),keymap:IR(t=>typeof t=="object"&&t!==null&&typeof Reflect.get(t,"id")=="string","keymap must be an imported KeymapContribution object").optional(),workspace:Ss().min(1).optional(),inspector:jd(["column","properties","card"]).optional(),playUtilities:o_(Ss().min(1)).optional()}).strict(),iUr="`regionIncludes` states parameters for the `manifest-roots` RULE, so it cannot be paired with an explicit `regions` list — that form is the full replacement, and each entry carries its own `include`/`mounts`. Move these globs onto the matching `regions[]` entry, or drop the list and let the derivation run.",sUr=Na({editor:nUr.optional(),regions:Uzr.optional(),regionIncludes:Jzr.optional(),documents:Xzr.optional(),observation:o_(tUr).optional(),input:rUr.optional()}).strict().refine(t=>t.regionIncludes===void 0||Object.keys(t.regionIncludes).length===0||!Array.isArray(t.regions),{message:iUr});function RNt(t={}){const r=sUr.safeParse(t);if(!r.success)throw new Error(`vgai.adapter.ts: invalid adapter definition — ${r.error.issues.map(i=>`${i.path.join(".")||"(root)"}: ${i.message}`).join("; ")}`);return Object.freeze({...t.editor?{editor:Object.freeze({...t.editor,...t.editor.playUtilities?{playUtilities:Object.freeze([...t.editor.playUtilities])}:{}})}:{},regions:t.regions??"manifest-roots",regionIncludes:Object.freeze({...t.regionIncludes??{}}),documents:Object.freeze({...t.documents??{}}),observation:Object.freeze([...t.observation??[]]),...t.input?{input:t.input}:{}})}function B$(t={}){return RNt({regions:"manifest-roots",...t.regionIncludes?{regionIncludes:t.regionIncludes}:{},documents:{...t.scenes?{entries:t.scenes}:{},find:[{finder:"scenesFromEntrypointSelection",regions:age},{finder:"prefabsFromStories"}]}})}function Z2t(t){if(t===null||typeof t!="object")throw new Error(`vgai.adapter.ts must default-export defineAdapter({…}) / nativeAdapter() — got ${t===null?"null":typeof t}`);return RNt(t)}const TX=new Map;function MNt(t){const r=t;return TX.set(t.name,r),()=>{TX.get(t.name)===r&&TX.delete(t.name)}}function LNt(t,r){const i=t??{},a=[];(typeof i.name!="string"||i.name.length===0)&&a.push("`name` must be a non-empty string");const l=i.schema;if((!l||typeof l.safeParse!="function")&&a.push("`schema` must be a Zod schema"),typeof i.run!="function"&&a.push("`run(selection, input)` must be a function"),a.length>0)throw new Error(`${r}: not a finder — ${a.join("; ")}`);return MNt(i)}function oUr(){return[...TX.keys()]}function aUr(t,r){const i=TX.get(t.finder);if(!i){const l=oUr();throw new Error(`Unknown finder ${JSON.stringify(t.finder)} — registered: ${l.length>0?l.map(d=>`"${d}"`).join(", "):"none"}`)}const a=i.schema.safeParse(t);if(!a.success)throw new Error(`Finder ${JSON.stringify(t.finder)}: ${a.error.issues.map(l=>`${l.path.join(".")||"(selection)"}: ${l.message}`).join("; ")}`);return i.run(a.data,r)}function eSt(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var b7e={exports:{}};const cUr={},lUr=Object.freeze(Object.defineProperty({__proto__:null,default:cUr},Symbol.toStringTag,{value:"Module"})),NN=DIr(lUr);var tSt;function uUr(){return tSt||(tSt=1,(function(t){var r={};/*! *****************************************************************************
|
|
80
80
|
Copyright (c) Microsoft Corporation. All rights reserved.
|
|
81
81
|
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
82
82
|
this file except in compliance with the License. You may obtain a copy of the
|
|
@@ -1596,11 +1596,11 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1596
1596
|
`).replace(/function\s+noRefCheck\(\)\s*\{\}/g,"() => {}")},R_n={skip:0,showFunctions:!1,enableBeautify:!0,showDefaultProps:!1},M_n=t=>{let r=t?.parameters.docs?.source,i=t?.parameters.__isArgsStory;return r?.type===o$e.DYNAMIC?!1:!i||r?.code||r?.type===o$e.CODE},L_n=t=>t.type?.displayName==="MDXCreateElement"&&!!t.props?.mdxType,xWt=t=>{if(!L_n(t))return t;let{mdxType:r,originalType:i,children:a,...l}=t.props,d=[];return a&&(d=(Array.isArray(a)?a:[a]).map(xWt)),Xe.createElement(i,l,...d)},wWt=(t,r)=>{let i=RUt(void 0),a=t(),l=M_n(r),d={...R_n,...r?.parameters.jsx||{}},_=r.originalStoryFn(r.args,r);return q8(()=>{if(l)return;let g=xWt(_),b=F_n(g,d);b&&i.current!==b&&(MVt(b,r),i.current=b)}),a},j_n=(t,r)=>{let i=r.findIndex(l=>l.originalFn===wWt),a=i===-1?r:[...r.splice(i,1),...r];return LVt(t,a)},B_n=[wWt],$_n={docs:{story:{inline:!0}}},{window:sCt}=ia;sCt&&(sCt.STORYBOOK_ENV="react");function q_n(t){return cVt(CWt),uVt(t)}var CWt=i9([UVt,lWt,{renderToCanvas:async(t,r)=>{if(t.storyContext.testingLibraryRender==null)return WVt(t,r);let{storyContext:{context:i,unboundStoryFn:a,testingLibraryRender:l}}=t,{unmount:d}=l(Xe.createElement(a,{...i}),{container:i.canvasElement});return d}}]);function z_n(t,r,i,a){return RGe(t,r,i,globalThis.globalProjectAnnotations??CWt,a)}function U_n(t,r){return fVt(t,r,z_n)}let xY=null;function V_n(){if(!xY){const t=Promise.resolve().then(()=>fetch("/__editor/project")).then(r=>Eg(r,"`/__editor/project` did not answer")).then(r=>!!r.project?.packaged).catch(r=>{throw xY===t&&(xY=null),new Error(`This editor session's runtime is unknown — \`/__editor/project\` did not answer, so which module graph a world mounts in (this shell’s, or the project’s) cannot be decided and nothing was mounted on a guess. This is a fault in the editor host, not in the game. The answer is not latched: retry the mount (reopen the project) and the question is asked again. (${r instanceof Error?r.message:String(r)})`,{cause:r})});xY=t}return xY}const J_n={packaged:!1,composeStories:U_n,setProjectAnnotations:q_n,createRoot:Hqe.createRoot,flushSync:vS.flushSync};let bRe=null;async function W_n(){let t;try{t=await import(bMr)}catch(r){throw new Error(`The story runtime failed to load from the project module graph — is \`@storybook/react\` installed in the project? (${String(r instanceof Error?r.message:r)})`)}for(const r of["composeStories","setProjectAnnotations","createRoot","flushSync"])if(typeof t[r]!="function")throw new Error(`The packaged story runtime did not export ${r} as a function — see vite-plugin-module-doorways.ts.`);return{packaged:!0,composeStories:t.composeStories,setProjectAnnotations:t.setProjectAnnotations,createRoot:t.createRoot,flushSync:t.flushSync}}async function EWt(){return await V_n()?(bRe||(bRe=W_n()),bRe):J_n}let oCt=null;function TWt(t){return oCt??=EWt().then(r=>{r.setProjectAnnotations(t??[])}),oCt}function H_n(t){if(!t||typeof t!="function"&&typeof t!="object")return;const r=t.displayName;return typeof r=="string"?r:typeof t=="function"&&t.name?t.name:void 0}async function G_n(t,r){const i=r??{};if(i.default===null||typeof i.default!="object")return{ok:!1,error:`[stories] ${t} has no default export — every CSF file exports \`export default { title, component, ... } satisfies Meta<...>\` (see the template example: src/ui/Button.stories.tsx). Skipped.`};let a;try{a=(await EWt()).composeStories(i)}catch(S){return{ok:!1,error:`[stories] ${t} failed to compose — ${String(S instanceof Error?S.message:S)}`}}const l=i.default,d=typeof l.title=="string"?l.title:void 0,_=H_n(l.component),g=S=>S.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[-_]+/g," ").trim(),b=Object.entries(a).filter(S=>typeof S[1]=="function").map(([S,k])=>{const w=k,N=i[S],P=N&&typeof N=="object"?N:null,j=l.globals&&typeof l.globals=="object"?l.globals:null,J=P?.globals&&typeof P.globals=="object"?P.globals:null,X=P?.name;return{name:S,id:typeof w.id=="string"?w.id:S,label:typeof X=="string"?X:g(typeof w.storyName=="string"?w.storyName:S),...d?{title:d}:{},..._?{componentName:_}:{},tags:Array.isArray(w.tags)?w.tags.filter(G=>typeof G=="string"):[],parameters:w.parameters&&typeof w.parameters=="object"?w.parameters:{},globals:w.globals&&typeof w.globals=="object"?{...w.globals}:{},viewportLocked:Object.hasOwn(j??{},"viewport")||Object.hasOwn(J??{},"viewport"),args:w.args&&typeof w.args=="object"?{...w.args}:{},Component:k}});return b.length===0?{ok:!1,error:`[stories] ${t} exports no named stories — a CSF file needs at least one named export alongside the default Meta export (see src/ui/Button.stories.tsx). Skipped.`}:{ok:!0,stories:b}}let kWt=[];function aQe(){return kWt}function Q_n(t){kWt=t}function K_n(t){let r="",i=0;for(;i<t.length;){const a=t[i];if(a==="*"){if(t[i+1]==="*"){r+=t[i+2]==="/"?"(?:.*/)?":".*",i+=t[i+2]==="/"?3:2;continue}r+="[^/]*",i+=1;continue}if(a==="?"){r+="[^/]",i+=1;continue}r+=a.replace(/[.+^${}()|[\]\\]/g,"\\$&"),i+=1}return new RegExp(`^${r}$`)}function aCt(t){return t.replaceAll("\\","/").replace(/^\.\//,"").replace(/^\//,"")}function cCt(t,r){const i=aCt(t);return r.some(a=>K_n(aCt(a)).test(i))}function Y_n(t,r){if(t===void 0)return;const i=[];for(const a of r){a.include!==void 0&&cCt(t,a.include)&&i.push({surface:a.surface,regionId:a.id});for(const l of a.mounts??[])cCt(t,l.include)&&i.push({surface:l.surface,regionId:a.id})}return i.length===1?i[0]:void 0}function X_n(t,r,i){const a=new Set([t]),l=new Set;let d=[t];for(let _=0;_<64&&d.length>0;_++){const g=[];for(const b of d)for(const S of r(b)??[]){if(!S||a.has(S))continue;a.add(S);const k=i(S);k?l.add(k.surface):g.push(S)}d=g}return l}function Z_n(t){const r=t.regions??[],i=Y_n(t.projectRelative,r);if(i)return{surface:i.surface,regionId:i.regionId,via:"declared-include",reached:[]};const a=t.regionOfEntry(t.file);if(a)return{surface:a.surface,regionId:a.id,via:"root-entry",reached:[]};const l=t.importersOf?[...X_n(t.file,t.importersOf,t.regionOfEntry)]:[];return l.length===1?{surface:l[0],via:"import-graph",reached:l}:{via:"ambiguous",reached:l,ambiguity:l.length>1?"differing-surfaces":"unreached"}}function tee(t){return t.replaceAll("\\","/").replace(/^\.\//,"").replace(/^\//,"")}function emn(t){const r=new Map;for(const i of t)i.entry&&r.set(tee(i.entry),i);return i=>r.get(tee(i))}function tmn(t,r){const i=tee(t);return Z_n({file:i,projectRelative:i,regions:r,regionOfEntry:emn(r)})}function rmn(t){return t==="three"||t==="canvas"||t==="dom"?t:void 0}function nmn(t){if(t.via==="declared-include")return"declared-include";if(t.via==="root-entry")return"root-entry"}function cQe(t){const r=t.regions??[],i=t.modulePath?tee(t.modulePath):"";if(!i)return{via:"undeclared",reason:"story has no module path"};const a=tmn(i,r),l=rmn(a.surface),d=nmn(a);return l&&d?{medium:l,via:d}:{via:"undeclared",reason:`${i} is not named by a region include/mount and is not a manifest root entry`}}const A$e=new Set;function imn(t,r){const i=tee(t);A$e.has(i)||(A$e.add(i),console.warn(`[story-media] ${i} has no declared medium`+(r?` — ${r}`:"")+". It is not a candidate on any board. Declare it via `vgai.adapter.ts` regionIncludes or a manifest root entry."))}function smn(){A$e.clear()}const omn=/\.stories\.[jt]sx?$/i;function ARe(t){const{root:r,groups:i}=Qcn(t,{rootSeparator:"|",groupSeparator:"/"});return[...r?[r]:[],...i].map(a=>a.trim()).filter(Boolean)}function amn(t){const r=t.replaceAll("\\","/").replace(/^\.\//,""),i=r.lastIndexOf("/src/");return{directory:r.startsWith("src/")?"src":i>=0?r.slice(0,i+4):r.slice(0,Math.max(0,r.lastIndexOf("/"))),files:"**/*.stories.@(js|jsx|mjs|ts|tsx)",titlePrefix:"",importPathMatcher:omn}}function IWt(t){const r=t.modulePath.replaceAll("\\","/").replace(/^\.\//,""),i=t.title&&ARe(t.title).length>0?t.title:void 0,a=pun(r,amn(r),i),l=a?ARe(a):i?ARe(i):[r];return{segments:l.slice(0,-1),leaf:l.at(-1)??t.modulePath}}function cmn(t){return[...t.segments,t.leaf].join("/")}async function DWt(){try{const t=await fetch("/__editor/story-files"),r=await Eg(t,"Scanning this project for stories failed");return Array.isArray(r.regions)&&Q_n(r.regions),r}catch(t){t instanceof Error?t.message:String(t);return}}async function PWt(t){if(!t)return[];const r=await DWt();return r?r.files.map(({path:i})=>({modulePath:i,load:()=>Xo(()=>import(`/@fs/${t.rootPath}/${i}?t=${Date.now()}`),[])})):[]}async function NWt(t){if(!t)return;const i=(await DWt())?.previewModulePath;if(i)try{return await Xo(()=>import(`/@fs/${t.rootPath}/${i}?t=${Date.now()}`),[])}catch{return}}let v8=[],Wz=!1,ree=0,lCt=null;const fX=new Map,pye=new Set;function OWt(){const t=hh();lCt!==t&&(lCt=t,ree++,fX.clear(),_ye([],!1))}function Q1e(){return v8}function lmn(){return Wz}function K1e(t){return pye.add(t),()=>pye.delete(t)}function umn(){return Wz?Promise.resolve():new Promise(t=>{const r=K1e(()=>{Wz&&(r(),t())})})}function fmn(t){const r=t.parameters.vgai;return r&&typeof r=="object"?r:null}function MPn(){const t=[];for(const l of v8)if(l.ok)for(const d of l.stories)t.push({...d,modulePath:l.modulePath});const r=t.map(l=>{const d=l.parameters.options;return d&&typeof d=="object"?d.storySort:void 0}).find(l=>l!==void 0);if(!r)return t;const i=new Map(t.map(l=>[l.id,l])),a=t.map(l=>({type:"story",id:l.id,name:l.label,title:l.title??cmn(IWt({modulePath:l.modulePath})),importPath:l.modulePath,tags:[...l.tags??[]]}));return hun(a,r,[...new Set(t.map(l=>l.modulePath))]).map(l=>i.get(l.id)).filter(l=>l!==void 0)}function FWt(t){const r=fmn(t);return r?r.default===!0?!0:typeof r.defaultStory=="string"&&r.defaultStory===t.name:!1}function uCt(t){const r=t.replaceAll("\\","/").replace(/^\.\//,""),i=r.lastIndexOf("/");return i>=0?r.slice(0,i):""}function dmn(t,r,i){const a=RWt(t,r,i);return a.find(FWt)??a[0]??null}function RWt(t,r,i){const a=[];for(const d of t)if(d.ok)for(const _ of d.stories)_.componentName===r&&a.push({..._,modulePath:d.modulePath});if(a.length===0)return[];const l=i?a.filter(d=>uCt(d.modulePath)===uCt(i)):[];return l.length>0?l:a}function pmn(t,r){return RWt(v8,t,r)}function _ye(t,r){v8=t,Wz=r;for(const i of pye)i()}async function S$e({modulePath:t,load:r}){const i=Date.now();let a;try{a=await r()}catch(g){return{result:{modulePath:t,ok:!1,error:`[stories] failed to load ${t} — ${String(g instanceof Error?g.message:g)}`},loadMs:Date.now()-i,composeMs:0}}const l=Date.now()-i,d=Date.now(),_=await G_n(t,a);return{result:_.ok?{modulePath:t,ok:!0,stories:_.stories}:{modulePath:t,ok:!1,error:_.error},loadMs:l,composeMs:Date.now()-d}}function _mn(t,r){OWt();const i=hh(),a=`${i}
|
|
1597
1597
|
${r}`,l=fX.get(a);if(l)return l;const d=mmn(t,i,r).finally(()=>{fX.get(a)===d&&fX.delete(a)});return fX.set(a,d),d}async function mmn(t,r,i){for(;hh()===r;){const a=v8.find(w=>w.modulePath===i);if(a?.ok)return;const l=ree,d=()=>hh()===r&&l===ree,_=await NWt(t);if(!d()||(await TWt(_),!d()))continue;const g=await PWt(t);if(!d())continue;const b=g.find(w=>w.modulePath===i);if(!b)throw new Error(`Story module not found: ${i}`);const{result:S}=await S$e(b);if(!d())continue;const k=v8.find(w=>w.modulePath===i);if(k&&k!==a){if(!k.ok)throw new Error(k.error);return}if(_ye([...v8.filter(w=>w.modulePath!==i),S],Wz),!S.ok)throw new Error(S.error);return}throw new Error(`Project changed while opening story: ${i}`)}async function hmn(){await Promise.race([r0e(),new Promise(t=>setTimeout(t,5e3))]),await new Promise(t=>{const r=globalThis.requestIdleCallback;if(typeof r=="function"){r(()=>t(),{timeout:2e3});return}setTimeout(t,0)})}async function gmn(t,r,i={}){OWt();const a=++ree,l=hh(),d=()=>a===ree&&l===hh(),_=async Ot=>{if(!i.changedPaths)return Promise.all(Ot.map(S$e));const vt=[];for(const Et of Ot)if(vt.push(await S$e(Et)),await new Promise(Tt=>setTimeout(Tt,16)),!d())break;return vt};Wz=!1;for(const Ot of pye)Ot();const g=Date.now(),b=Date.now(),S=await NWt(t);if(!d())return;const k=Date.now()-b,w=Date.now();if(await TWt(S),!d())return;const N=Date.now()-w,P=Date.now(),j=await PWt(t);if(!d())return;const J=Date.now()-P,X=aQe(),G=i.deferUndeclared?j.filter(({modulePath:Ot})=>cQe({modulePath:Ot,regions:X}).via==="undeclared"):[],ee=new Set(G.map(({modulePath:Ot})=>Ot)),xe=j.filter(({modulePath:Ot})=>!ee.has(Ot)),ue=Date.now(),fe=await _(xe),se=Date.now()-ue,de=fe.map(({result:Ot})=>Ot);if(!d())return;const ge=new Map([...v8.filter(({modulePath:Ot})=>ee.has(Ot)),...de].map(Ot=>[Ot.modulePath,Ot]));if(_ye(j.map(({modulePath:Ot})=>ge.get(Ot)).filter(Ot=>Ot!==void 0),G.length===0),t5r({ms:Date.now()-g,completedAtMs:Date.now(),moduleCount:de.length,storyCount:de.reduce((Ot,vt)=>Ot+(vt.ok?vt.stories.length:0),0),previewAnnotationsMs:k,runtimeAnnotationsMs:N,fileScanMs:J,moduleLoadAndComposeMs:se,modules:fe.map(({result:Ot,loadMs:vt,composeMs:Et})=>({modulePath:Ot.modulePath,loadMs:vt,composeMs:Et,ok:Ot.ok}))}),G.length===0||(await hmn(),!d()))return;const qe=(await _(G)).map(({result:Ot})=>Ot);if(!d())return;const tt=new Map([...de,...qe].map(Ot=>[Ot.modulePath,Ot])),Ct=j.map(({modulePath:Ot})=>tt.get(Ot)).filter(Ot=>Ot!==void 0);_ye(Ct,!0)}function ymn(){const t=[];for(const r of Q1e())if(r.ok)for(const i of r.stories)t.push({modulePath:r.modulePath,storyId:i.id,label:i.label,...i.componentName===void 0?{}:{componentName:i.componentName},isDefault:FWt(i)});return t}const vmn={name:"prefabsFromStories",schema:Na({finder:Ry("prefabsFromStories")}).strict(),run(t,r){return oVr(t,{stories:ymn(),...r.components===void 0?{}:{components:r.components}})}},Hq="vgai.adapter.ts";let WX=null,x$e=null,lQe="__unscoped__",HX=null,MWt=0;const nee=new Set;function v1(){return lQe===hh()?WX:null}function uQe(){const t=()=>!ad()||!!v1();return t()?Promise.resolve():new Promise(r=>{const i=YP(()=>{t()&&(i(),r())})})}async function bmn(){for(await(await Xo(async()=>{const{projectBootstrapSettled:r}=await Promise.resolve().then(()=>BGt);return{projectBootstrapSettled:r}},void 0)).projectBootstrapSettled(),await O8(),await Gq();HX;)await HX;const t=v1();if(!t||t.documentsPending)throw new Error("The project document table could not finish loading; inspect the project diagnostics.");return t.scenes}function YP(t){return nee.add(t),()=>nee.delete(t)}function Fme(t,r=[],i=void 0,a=null){lQe=hh(),WX=t,x$e=a,b7r(a?.editor),KUr(t?.regions??[]);for(const l of nee)l();U7r()}function Amn(t){return{id:t.id,kind:t.kind,answered:t.answer!==void 0}}function Smn(t){const{Layout:r,...i}=t;return{...i,...r?{layout:r.displayName??r.name??"Project layout"}:{}}}async function xmn(t){return await import(`${JNt(t,Hq)}?t=${Date.now()}`)}function wmn(t,r){return t.find(i=>i.surface===r)?.id??null}function Cmn(t){const r=new Set(t.map(i=>i.path));return(i,a)=>nVr(i,a,r)}function Emn(t){const r=NUr(t);return r.length===1?r[0].id:null}const Tmn={entrypoints:[],components:[]};async function kmn(t,r,i){const a=[];for(const S of kX(t))S.entry&&a.push({regionId:S.id,path:S.entry,source:await ige(S.entry)});let l=[];const d=await yNt().catch(S=>({ok:!1,reason:S instanceof Error?S.message:String(S)}));d.ok?l=d.entries.map(S=>({name:S.name,path:S.path,region:wmn(r,S.surface)})):ua.warn(`Component index unavailable, so prefabs resolve without source paths: ${d.reason}`,"project");const _=new Set;for(const S of i.documents.find??[])for(const k of S.include??[])_.add(k);const g=[],b=[];if(_.size>0){const S=await SNt([..._],{order:"mtime"}).catch(()=>[]);for(const k of S){b.push(k);const w=await ige(k);w!==null&&!w.includes("\0")&&g.push({path:k,source:w})}}return{entrypoints:a,components:l,sources:g,files:b,resolveModule:Cmn(l)}}function Imn(t,r){const i=[...t.documents.entries??[]],a=[],l=[];let d=0;for(const g of t.documents.find??[]){let b;try{b=kUr(g,r)}catch(S){a.push(`finder ${JSON.stringify(g.finder)}: ${S instanceof Error?S.message:String(S)}`),d+=1;continue}i.push(...b.entries),a.push(...b.notes),b.default!==void 0&&l.push(b.default)}y9("model")!==void 0&&!i.some(g=>g.kind==="model")&&i.push({id:"blender:runtime",label:"Model",kind:"model",region:null,authorable:!0,reach:{kind:"root-mount"}});const _=l.length===1?l[0]:null;return{table:{entries:i,default:t.documents.default??_},notes:a,unresolved:d}}const LWt=[];function fCt(t){for(const r of LWt){const i=r.modulePathFor(t);if(i!==null)return{source:r,modulePath:i}}return null}function dCt(t){return t!==null&&typeof t=="object"&&"default"in t?t.default:t}function V$(t,r){if(t.kind==="present")try{return{definition:Z2t(dCt(t.module)),source:"project",modulePath:Hq,error:null}}catch(a){return{definition:B$(),source:"native",modulePath:null,error:`${Hq} did not load — ${iee(a)}`}}if(t.kind==="broken")return{definition:B$(),source:"native",modulePath:null,error:`${Hq} did not load — ${t.error}`};const i=t.kind==="unreachable"?t.error:null;if(r.kind==="present")try{return{definition:Z2t(dCt(r.module)),source:"registry",modulePath:r.path,error:i}}catch(a){return{definition:B$(),source:"native",modulePath:null,error:`${r.path} did not load — ${iee(a)}`}}return r.kind==="broken"?{definition:B$(),source:"native",modulePath:null,error:`${r.path} did not load — ${r.error}`}:r.kind==="unanswered"?{definition:B$(),source:"native",modulePath:null,error:`vgai.project.json declares the ingest root \`${r.rootId}\`, and no registered adapter-definition source holds a declaration for it (${r.sources} source${r.sources===1?"":"s"} registered). The lane that owns a vendored game's declaration is \`@vgai/game\`, which registers through its \`ingest.service.ts\` contribution — so either this product does not compose that package, or its contribution pass did not load it. The declared native default is standing in, which means this game's own scene table is NOT what the editor is showing.`}:{definition:B$(),source:"native",modulePath:null,error:i}}function Dmn(t,r,i){const{definition:a,source:l,modulePath:d,error:_}=r,g=a.regions==="manifest-roots"?FNt(kX(t),a.regionIncludes):[...a.regions],b=Hzr(kX(t),a.regionIncludes),{table:S,notes:k,unresolved:w}=Imn(a,i);return{source:l,modulePath:d,regions:g,scenes:S,documentsPending:w>0,...a.editor?{editor:Smn(a.editor)}:{},observation:a.observation.map(Amn),notes:b.length>0?[...k,`adapter: regionIncludes names ${b.map(N=>`\`${N}\``).join(", ")}, which no root in vgai.project.json declares (roots: ${kX(t).map(N=>`\`${N.id}\``).join(", ")}) — those globs were merged onto nothing.`]:k,error:_}}async function Pmn(t,r){const i=Emn(r),a=await ANt(Hq);if(a==="present")try{const _=await xmn(t.rootPath);return V$({kind:"present",module:_},{kind:"absent"})}catch(_){return V$({kind:"broken",error:iee(_)},{kind:"absent"})}const l=a==="unreachable"?{kind:"unreachable",error:`${Hq} could not be probed — the project's file routes did not answer, so whether this project owns an adapter is UNKNOWN.`}:{kind:"absent"};if(i===null)return V$(l,{kind:"absent"});let d=fCt(i);if(d===null&&(await Nmn(i),d=fCt(i)),d===null){const _=V$(l,{kind:"unanswered",rootId:i,sources:LWt.length});return _.error&&ua.warn(_.error,"ingest"),_}try{const _=await d.source.importModule(i);return V$(l,{kind:"present",module:_,path:d.modulePath})}catch(_){return V$(l,{kind:"broken",path:d.modulePath,error:iee(_)})}}let pCt=null,u_e=null,w$e=null;function _Ct(){return w$e}function Nmn(t){const r=hh();if(pCt!==r&&(pCt=r,u_e=null),!u_e){w$e=`Loading the ingest lane — this project declares the unmodified-game root “${t}”, whose adapter declaration a package supplies.`;for(const i of nee)i();u_e=O8().catch(()=>{}).finally(()=>{w$e=null;for(const i of nee)i()})}return u_e}let SRe=[],C$e="";function Omn(){const t=lUe(),r=t.map(i=>i.entryPath).join("|");if(!(r===C$e&&t.every(i=>Rme.has(i.module)))){for(const i of SRe)i();SRe=[],Rme=new WeakSet;for(const{entryPath:i,module:a}of t)try{SRe.push(LNt(a?.finder,i)),Rme.add(a)}catch(l){ua.error(l instanceof Error?l.message:String(l),"project")}C$e=r}}let Rme=new WeakSet;LNt(vmn,"packages/editor/src/stories/prefabs-finder.ts");jA(()=>{const t=lUe();(t.map(i=>i.entryPath).join("|")!==C$e||!t.every(i=>Rme.has(i.module)))&&ad()&&Gq()});J7r(()=>WX&&!WX.documentsPending?[...new Set(WX.scenes.entries.map(t=>t.kind))]:null);function Gq(){const t=Fmn(++MWt,ad());return HX=t,t.then(()=>{HX===t&&(HX=null)}),t}async function Fmn(t,r){const i=()=>t===MWt&&ad()===r;if(!r){Fme(null);return}let a;try{a=await QUr()}catch(b){if(!i())return;Fme({source:"native",modulePath:null,regions:[],scenes:{entries:[],default:null},observation:[],notes:[],documentsPending:!1,error:`adapter: the project's manifest did not load, so no region could be derived — ${iee(b)}`});return}if(!i())return;const l=await Pmn(r,a);if(!i())return;Omn();const d=l.definition.regions==="manifest-roots"?FNt(kX(a),l.definition.regionIncludes):[...l.definition.regions],_=(l.definition.documents.find??[]).length>0?await kmn(a,d,l.definition):Tmn;if(!i())return;const g=Dmn(a,l,_);Fme(g,l.definition.observation,l.definition.input,l.source==="native"?null:l.definition)}function iee(t){return t instanceof Error?t.message:String(t)}function Rmn(t){if(!x$e)return!0;const r=x$e.documents.find??[];for(const i of r)for(const a of i.include??[])if(Mmn(a).test(t))return!0;return!1}function Mmn(t){const r="__DEEP__",i=t.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*\*\//g,r).replace(/\*/g,"[^/]*").split(r).join("(?:.*/)?");return new RegExp(`^${i}$`)}function Lmn(){Gq();const t=XNt(),r=Iw(()=>{lQe!==hh()&&Fme(null),Gq()}),i=LUr(a=>{(a===""||Rmn(a))&&Gq()});return()=>{t(),r(),i()}}const jmn="scene:";function mCt(t){return`${jmn}${t}`}function wY(t){const{kind:r}=t.reach;return r==="game-contract"||r==="root-mount"||r==="entrypoint-selection"?{liveReach:r}:{}}function jWt(t){if(!t.authorable)return{kind:"no-document",...wY(t),reason:`"${t.id}" is declared TRAVERSAL (boot/loading choreography), not an authorable composition, so it has no Edit document.`};switch(t.reach.kind){case"none":return{kind:"no-document",...wY(t),reason:t.reach.reason};case"root-mount":return t.region===null?{kind:"no-document",...wY(t),reason:`"${t.id}" is reached by mounting a region, but the entry names no region, so there is no standing document it could be.`}:{kind:"root-document",regionId:t.region,title:t.label};case"entrypoint-selection":return t.reach.active===!0&&t.region!==null?{kind:"root-document",regionId:t.region,title:t.label}:t.source?{kind:"isolation-document",documentId:mCt(t.id),title:t.label,regionId:t.region,source:t.source,...t.isolationSetup?{isolationSetup:t.isolationSetup}:{}}:{kind:"no-document",...wY(t),reason:`"${t.id}" is selected at the entrypoint's \`${t.reach.selection}\` slot, but the finder could not resolve the module it names, so there is nothing to mount in isolation.`};case"game-contract":return t.source?{kind:"isolation-document",documentId:mCt(t.id),title:t.label,regionId:t.region,source:t.source,...t.isolationSetup?{isolationSetup:t.isolationSetup}:{},contractSceneId:t.reach.sceneId}:{kind:"no-document",...wY(t),reason:`"${t.id}" is reached only through the running game's own navigation (its scenes contract calls it "${t.reach.sceneId}"), and the entry names no source module, so there is no Edit document — open it while the game is running.`};case"story":return{kind:"story-document",title:t.label,storyId:t.reach.storyId}}}function Bmn(t){const r=[];for(const i of t.entries){if(i.kind!=="scene")continue;const a=jWt(i);a.kind!=="no-document"&&r.push({entry:i,plan:a,isDefault:t.default===i.id})}return r}let mE=[];const E$e=new Set,see=new Map;let fQe=!1,dQe=!1,T$e=!1;function $mn(t,r=!0){see.set(t,r),mye()}const pQe=()=>{for(const t of E$e)t()},_Qe=()=>mE;function qmn(t){return E$e.add(t),()=>{E$e.delete(t)}}function s9(t,r=!0){const i=mE.find(a=>a.descriptor.id===t);return i?(qP({...i.descriptor,closeable:!0,persist:()=>({availableDocumentId:t})},{activate:r}),!0):!1}function mye(){for(const[t,r]of see)s9(t,r)&&see.delete(t);if(fQe&&!dQe&&!T$e){const t=mE.find(r=>r.default);t&&(T$e=!0,s9(t.descriptor.id))}}function LPn(t,r){const i=mE.find(l=>l.descriptor.id===t.id);if(i?.descriptor.Content===t.Content&&i?.descriptor.title===t.title&&i.descriptor.provenance?.sourcePath===t.provenance?.sourcePath&&i.descriptor.provenance?.rootId===t.provenance?.rootId&&i.descriptor.Toolbar===t.Toolbar&&i.descriptor.Shelf===t.Shelf&&i.descriptor.preview===t.preview&&i.default===(r.default??!1)&&i.category===r.category&&i.rootId===r.rootId)return t.id;const a={descriptor:t,category:r.category,default:r.default??!1,rootId:r.rootId};return mE=i?mE.map(l=>l.descriptor.id===t.id?a:l):[...mE,a],pQe(),mye(),t.id}function jPn(t){mE.some(r=>r.descriptor.id===t)&&(mE=mE.filter(r=>r.descriptor.id!==t),Y8(t,{discardDirty:!0}),pQe())}for(const t of n5r)Iee({kind:t,owner:"workspace-available-documents",restore:({state:r,active:i})=>{const a=r?.availableDocumentId;return typeof a!="string"?!1:(see.set(a,i),mye(),!0)},beginRestore:({hasDocumentsToRestore:r})=>{fQe=!0,dQe=r,mye()}});function zmn(){mE=[],see.clear(),fQe=!1,dQe=!1,T$e=!1,pQe()}const Mme=new Map;function BPn(t,r){return Mme.set(t,r),()=>{Mme.get(t)===r&&Mme.delete(t)}}function mQe(t){return Mme.get(t)??_Qe().find(r=>r.rootId===t)?.descriptor.id??null}function k$e(t){const r=mQe(t);return r?s9(r)||xb(r):!1}const Lme=new Map;function $Pn(t,r){return Lme.set(t,r),()=>{Lme.get(t)===r&&Lme.delete(t)}}function hCt(t){return Lme.get(t)?.()??null}const I$e=new Set;function qPn(t){return I$e.add(t),()=>{I$e.delete(t)}}function gCt(t){for(const r of I$e){const i=r(t);if(i!==null)return i}return null}const Umn="document:";function hQe(t){return`${Umn}${t}`}const oee=new Map;function Vmn(t){return oee.get(t)?.entry}function Jmn(t){return{id:t.id,kind:t.kind,label:t.label,...t.source?{source:{path:t.source.path,...t.source.export?{export:t.source.export}:{}}}:{}}}function BWt(t){const r=t.source?.path;if(!r)return"source";const i=wg(r).kind;return i==="model"||i==="image"||i==="video"||i==="audio"||i==="json"?i:"source"}function D$e(t){return y9(t)!==void 0}function U8(t,r,i={}){const a=y9(r.kind);if(!a)return!1;const l=hQe(r.id);return oee.set(l,{entry:r,props:Jmn(r)}),qP({id:l,title:r.label,kind:"document",workspaceRole:"authored-subject",provenance:{...r.source?{sourcePath:r.source.path}:{},origin:a.file},Content:ehn,...a.Toolbar?{Toolbar:Xmn}:{},...a.Shelf?{Shelf:Zmn}:{},presentation:()=>({kind:"document",id:r.id}),persist:()=>({entryId:r.id}),onDispose:d=>{oee.delete(d)},...t?{onActivate:()=>t.setActiveViewportTab("edit")}:{}},i),!0}g9({id:"document",owner:"kind-documents",open:(t,r)=>{const i=xRe(r.id);return!i||!D$e(i.kind)?null:U8(t,i)?hQe(i.id):null},settle:async t=>{await xE(()=>xRe(t.id)!==void 0,2e4);const i=xRe(t.id);if(!i)throw new Error(`The project's document table lists no document: ${t.id}`);if(!await xE(()=>D$e(i.kind),2e4))throw new Error(`No editor is registered for documents of kind '${i.kind}' (${t.id})`)},ready:async t=>{await E3t(t),await Fze(t)}});function xRe(t){return v1()?.scenes.entries.find(r=>r.id===t)}function Wmn(t,r,i={}){if(U8(t,r,i))return;const a=jA(()=>{U8(t,r,i)&&a()})}function Hmn(t){return jA(()=>{const r=new Set(FA().map(i=>i.descriptor.id));for(const[i,{entry:a}]of oee)r.has(i)&&y9(a.kind)&&U8(t,a,{activate:!1})})}function Gmn(t,r){const i=()=>{const l=v1();if(!l)return!1;const d=l.scenes.entries.find(_=>_.id===t);return d?(r(d),!0):!1};if(i())return;const a=YP(()=>{i()&&a()})}function Qmn(t){const r=t.entries.filter(a=>a.kind!=="scene"&&a.kind!=="prefab"&&a.source!==void 0),i=r.find(a=>a.id===t.default);return i||(r[0]??null)}let yCt=null,hye=null;function Kmn(t,r){yCt?.();let i=r?new Set(r):null;const a=()=>{const l=v1();if(!l||l.documentsPending)return;const d=new Set(l.scenes.entries.map(g=>g.id));if(i===null){i=d,hye=d;return}const _=[...l.scenes.entries].reverse().find(g=>!i?.has(g.id)&&g.kind!=="scene"&&g.kind!=="prefab"&&g.source&&D$e(g.kind));i=d,hye=d,_?.source&&U8(t,_,{activate:!0,preview:!0})&&YN({path:`/${_.source.path}`,name:_.label,kind:"source",capabilities:wg(_.source.path),origin:"project",health:"healthy",selectionCount:1})};a(),yCt=YP(a)}function Ymn(t){const r=()=>{const a=v1();if(!a||a.documentsPending)return!1;if(FA().some(d=>!d.descriptor.area))return!0;const l=Qmn(a.scenes);if(l?.source){const d=`/${l.source.path}`;U8(t,l)||f8(t,d,BWt(l)),YN({path:d,name:l.label,kind:"source",capabilities:wg(l.source.path),origin:"project",health:"healthy",selectionCount:1})}return!0};if(r())return;const i=YP(()=>{r()&&i()})}Iee({kind:"document",owner:"kind-documents",restore:({state:t,active:r,store:i})=>{const a=t,l=typeof a?.entryId=="string"?a.entryId:null;return l?(Gmn(l,d=>{Wmn(i,d,{activate:r})}),!0):!1},persistKindState:()=>hye?{seen:[...hye]}:void 0,beginRestore:({state:t,hasDocumentsToRestore:r,store:i})=>{const a=t,l=Array.isArray(a?.seen)?a.seen.filter(d=>typeof d=="string"):void 0;r||Ymn(i),Kmn(i,l)}});function gQe(t){Xe.useSyncExternalStore(jA,dI);const r=oee.get(t)?.props;return{entry:r,contribution:r?y9(r.kind):void 0}}function Xmn({documentId:t,active:r}){const{entry:i,contribution:a}=gQe(t);return!i||!a?.Toolbar?null:z.jsx(h9,{contribution:a,Component:a.Toolbar,documentId:t,active:r,document:i},`${a.id}:${a.version}:toolbar:${t}`)}function Zmn({documentId:t,active:r}){const{entry:i,contribution:a}=gQe(t);return!i||!a?.Shelf?null:z.jsx(h9,{contribution:a,Component:a.Shelf,documentId:t,active:r,document:i},`${a.id}:${a.version}:shelf:${t}`)}function ehn({documentId:t,active:r}){const{entry:i,contribution:a}=gQe(t);return!i||!a?z.jsx("div",{style:{padding:12,fontSize:12,color:Oo.content.muted,pointerEvents:"auto"},children:"No editor is registered for this document's kind — close this document."}):z.jsx(h9,{contribution:a,documentId:t,active:r,document:i},`${a.id}:${a.version}:${t}`)}function thn(t,r){if(r)for(const i of Bmn(r)){if(i.plan.kind!=="root-document")continue;const a=mQe(i.plan.regionId);a&&GDt(a,i.plan.title)}}function rhn(t){const r=()=>thn(t,v1()?.scenes??null);return r(),YP(r)}const nhn=15e3;async function ihn(t,r){const i=()=>v1()?.scenes.entries.some(a=>a.id===r)??!1;return i()||await new Promise(a=>{let l=!1;const d=()=>{l||(l=!0,clearTimeout(_),g(),a())},_=setTimeout(d,nhn),g=YP(()=>{i()&&d()});i()&&d()}),$Wt(t,r)}function $Wt(t,r){const i=v1();if(!i)return{ok:!1,code:"SCENE_TABLE_UNAVAILABLE",error:"open: the project adapter has not loaded yet, so there is no scene table to open."};const a=i.scenes.entries.find(d=>d.id===r);if(!a){const d=i.scenes.entries.map(_=>_.id);return{ok:!1,code:"SCENE_NOT_FOUND",error:`open: "${r}" is not in the adapter's scene table. Known ids: ${d.length>0?d.join(", "):"(the table is empty)"}.`,known:d}}if(a.kind!=="scene"&&a.kind!=="prefab"&&U8(t,a,{activate:!0}))return{ok:!0,documentId:hQe(a.id),title:a.label};const l=jWt(a);switch(l.kind){case"no-document":return l.liveReach!==void 0?{ok:!1,code:"SCENE_NAVIGATION_NOT_RUNNING",error:`open: ${l.reason} No game is running in this session.`}:{ok:!1,code:"SCENE_NOT_OPENABLE",error:`open: "${r}" has no Edit document — ${l.reason}`};case"root-document":{const d=mQe(l.regionId);return d?(s9(d)||xb(d),{ok:!0,documentId:d,title:l.title}):{ok:!1,code:"SCENE_DOCUMENT_NOT_MOUNTED",error:`open: "${r}" is region "${l.regionId}"'s own document, and no document is mounted for that region in this session.`}}case"isolation-document":{const d=FP("scene",t,{entry:a,activate:!0});return d?{ok:!0,documentId:d,title:l.title}:{ok:!1,code:"SCENE_NOT_OPENABLE",error:`No installed scene editor can open "${r}".`}}case"story-document":{const d=FP("story",t,{storyId:l.storyId,title:l.title});return d===null?{ok:!1,code:"SCENE_DOCUMENT_NOT_MOUNTED",error:`open: "${r}" is reached by story "${l.storyId}", and nothing in this editor opened it — either this project's story registry does not hold that id, or its module declares no medium (declare it via \`vgai.adapter.ts\` regionIncludes or a manifest root entry). The session console names which.`}:{ok:!0,documentId:d,title:l.title}}}}const P$e="data-vgai-game-styles";function zPn(t){t.setAttribute(P$e,"")}const shn={installed:!1,sources:[],note:null},vCt="data-vgai-scoped-game-css";let wRe=null,qWt=null;function ohn(){return qWt}function ahn(){return typeof globalThis.CSSScopeRule=="function"}async function UPn(t){if(wRe?.projectRoot===t)return wRe.state;const r=chn(t);return wRe={projectRoot:t,state:r},r}async function chn(t){return await lhn(t)}async function lhn(t){let r;try{const d=await fetch("/__editor/scoped-game-css");r=await Eg(d,"Could not read the project scoped game CSS")}catch{return shn}const i=typeof r.css=="string"?r.css:"",a=Array.isArray(r.sources)?r.sources:[],l=typeof r.note=="string"?r.note:null;if(i.length===0)return{installed:!1,sources:a,note:l};if(!ahn()){const d="unstyled — this browser has no CSS `@scope`, so the game stylesheet cannot be contained to the game. Loading it anyway would restyle the editor.";return ua.warn(`[scoped-game-css] ${d}`,"authoring"),{installed:!1,sources:a,note:d}}return uhn(t,i),{installed:!0,sources:a,note:l}}function uhn(t,r){const i=document.head.querySelector(`style[${vCt}]`),a=i instanceof HTMLStyleElement?i:document.createElement("style");a.setAttribute(vCt,t),a.textContent=r,a.isConnected||document.head.appendChild(a),qWt=r}const fhn='[data-vgai-root-surface="true"]';function Y1e(t){return t.matches(fhn)||t.closest('[data-vgai-canvas-scene="true"]')!==null}function CRe(t,r){try{const i=t.createElement("canvas"),a=r,l=r instanceof HTMLVideoElement?r:null;i.width=Math.max(1,Math.round(Number(l?.videoWidth||a.naturalWidth||r.width)||0)),i.height=Math.max(1,Math.round(Number(l?.videoHeight||a.naturalHeight||r.height)||0));const d=i.getContext("2d");return d?(d.drawImage(r,0,0),i.toDataURL("image/png")):null}catch{return null}}function dhn(t){const r=new Set,i=a=>{if(r.has(a))return"";r.add(a);try{return Array.from(a.cssRules).map(l=>{const d=l.styleSheet;return d?i(d):l.cssText}).join(`
|
|
1598
1598
|
`)}catch{return""}};return Array.from(t.styleSheets,i).filter(Boolean).join(`
|
|
1599
|
-
`)}function phn(t,r){const i=t.ownerDocument.defaultView?.getComputedStyle(t);if(i){for(const a of Array.from(i)){if(!a.startsWith("--"))continue;const l=i.getPropertyValue(a);l&&r.style.setProperty(a,l)}for(const a of["color","color-scheme","font-family","font-size","font-weight","line-height","text-shadow"]){const l=i.getPropertyValue(a);l&&r.style.setProperty(a,l)}}}function yQe(t){const i=t.ownerDocument.defaultView?.getComputedStyle(t)?.backgroundColor;if(!i||i==="transparent")return null;const a=/^rgba?\([^)]*,\s*([\d.]+)\s*\)$/.exec(i)?.[1];return a!==void 0&&Number(a)===0?null:i}function zWt(t){const r=[],i=new Set;for(const a of Array.from(t.querySelectorAll("canvas"))){if(!Y1e(a))continue;const l=[];for(let d=a.parentElement;d&&(d===t||t.contains(d))&&(l.unshift(d),d!==t);d=d.parentElement);for(const d of[...l,..._hn(t,a)])i.has(d)||(i.add(d),r.push(d))}return r}function _hn(t,r){const i=t.ownerDocument,a=r.getBoundingClientRect();if(a.width<=0||a.height<=0||typeof i.elementsFromPoint!="function")return[];const l=new Set,d=[[a.left+a.width/2,a.top+a.height/2],[a.left+a.width*.1,a.top+a.height*.1],[a.left+a.width*.9,a.top+a.height*.1],[a.left+a.width*.1,a.top+a.height*.9],[a.left+a.width*.9,a.top+a.height*.9]];for(const[_,g]of d){const b=i.elementsFromPoint(_,g),S=b.indexOf(r);if(!(S<0))for(const k of b.slice(S+1))mhn(k,t)&&l.add(k)}return Array.from(l).reverse()}function mhn(t,r){return t instanceof HTMLElement&&(t===r||r.contains(t))&&yQe(t)!==null}function UWt(t){const r=[];for(let i=t.parentElement;i;i=i.parentElement)r.unshift(i);return r}function hhn(t,r){const i="select, input, textarea",a=_=>[..._.matches(i)?[_]:[],...Array.from(_.querySelectorAll(i))],l=a(t),d=a(r);l.forEach((_,g)=>{const b=d[g];if(b){if(_ instanceof HTMLSelectElement&&b instanceof HTMLSelectElement){const S=Array.from(_.options);Array.from(b.options).forEach((k,w)=>{S[w]?.selected?k.setAttribute("selected",""):k.removeAttribute("selected")});return}if(_ instanceof HTMLInputElement&&b instanceof HTMLInputElement){_.type==="checkbox"||_.type==="radio"?_.checked?b.setAttribute("checked",""):b.removeAttribute("checked"):b.setAttribute("value",_.value);return}_ instanceof HTMLTextAreaElement&&b instanceof HTMLTextAreaElement&&(b.textContent=_.value)}})}function ghn(t,r){const i=[t,...Array.from(t.querySelectorAll("*"))],a=[r,...Array.from(r.querySelectorAll("*"))];i.forEach((l,d)=>{const _=l.scrollTop,g=l.scrollLeft;if(_===0&&g===0)return;const b=a[d];if(!(b instanceof HTMLElement))return;const S=b.firstElementChild;if(!(S instanceof HTMLElement))return;b.style.overflow="hidden";const k=getComputedStyle(l.firstElementChild??l),w=Number.parseFloat(k.marginTop)||0,N=Number.parseFloat(k.marginLeft)||0;_!==0&&(S.style.marginTop=`${w-_}px`),g!==0&&(S.style.marginLeft=`${N-g}px`)})}function yhn(t,r,i){if(!i?.size)return;const a=[t,...Array.from(t.querySelectorAll("*"))],l=[r,...Array.from(r.querySelectorAll("*"))];a.forEach((d,_)=>{if(!i.has(d))return;const g=l[_];g instanceof HTMLElement&&(g.style.background="transparent")})}function VWt(t,r,i,a){const l=Array.from(t.children).filter(J=>J.tagName.toLowerCase()!=="canvas");if(l.length===0)return null;const d=a?.includeDocumentStyles===!0,_=d?t.cloneNode(!1):t.ownerDocument.createElement("div");_.style.position="relative",_.style.inset="auto",_.style.width=`${r}px`,_.style.height=`${i}px`,_.style.margin="0",_.style.transform="none",d?phn(t,_):_.style.background="transparent";const g=a?.transparentBackdrops;if(g?.has(t)&&(_.style.background="transparent"),t.closest(`[${P$e}]`)&&_.setAttribute(P$e,""),d){const J=dhn(t.ownerDocument);if(J){const X=t.ownerDocument.createElement("style");X.textContent=J,_.appendChild(X)}}const b=t.ownerDocument.createElement("style");b.textContent="*,*::before,*::after{animation:none!important;transition:none!important;caret-color:transparent!important;backdrop-filter:none!important;-webkit-backdrop-filter:none!important;}",_.appendChild(b);const S=ohn();if(S){const J=t.ownerDocument.createElement("style");J.textContent=S,_.appendChild(J)}for(const J of l){const X=J.cloneNode(!0);yhn(J,X,g),hhn(J,X),ghn(J,X);const G=[...J instanceof HTMLImageElement?[J]:[],...Array.from(J.querySelectorAll("img"))];[...X instanceof HTMLImageElement?[X]:[],...Array.from(X.querySelectorAll("img"))].forEach((se,de)=>{const ge=G[de];if(!ge?.complete||ge.naturalWidth<=0||ge.naturalHeight<=0)return;const qe=ge.currentSrc||ge.src,tt=a?.snapshots?.imgs.get(ge),Ct=tt&&tt.src===qe?tt.url:CRe(t.ownerDocument,ge);(!tt||tt.src!==qe)&&a?.snapshots?.imgs.set(ge,{src:qe,url:Ct}),Ct&&se.setAttribute("src",Ct)});const xe=[...J instanceof HTMLVideoElement?[J]:[],...Array.from(J.querySelectorAll("video"))];[...X instanceof HTMLVideoElement?[X]:[],...Array.from(X.querySelectorAll("video"))].forEach((se,de)=>{const ge=xe[de];if(!ge||ge.readyState<2||ge.videoWidth<=0)return;const qe=CRe(t.ownerDocument,ge);if(!qe)return;const tt=t.ownerDocument.createElement("img");tt.setAttribute("src",qe),tt.setAttribute("style",se.getAttribute("style")??""),se.replaceWith(tt)});const fe=Array.from(J.querySelectorAll("canvas"));Array.from(X.querySelectorAll("canvas")).forEach((se,de)=>{const ge=fe[de];if(ge&&Y1e(ge)){se.remove();return}const qe=ge?a?.canvasPixels?.get(ge):void 0,tt=qe?CRe(t.ownerDocument,qe):null;if(!tt){se.remove();return}const Ct=t.ownerDocument.createElement("img");Ct.setAttribute("src",tt),Ct.setAttribute("style",`${se.getAttribute("style")??""}`);for(const Ot of Array.from(se.attributes))Ct.setAttribute(Ot.name,Ot.value);se.replaceWith(Ct)}),_.appendChild(X)}const k=new XMLSerializer().serializeToString(_),w=a?.rasterSize?.width??r,N=a?.rasterSize?.height??i,P=w===r&&N===i?"":` viewBox="0 0 ${r} ${i}"`;return{svg:`<svg xmlns="http://www.w3.org/2000/svg" width="${w}" height="${N}"${P}><foreignObject width="100%" height="100%">${k}</foreignObject></svg>`,overlayCount:l.length}}const vhn={canvas:"canvas layer","dom-overlay":"DOM overlay layer","composite-output":"composite output"};class s8 extends Error{layer;constructor(r,i){const a=typeof i=="object"&&i!==null&&"message"in i&&typeof i.message=="string"?i.message:String(i);super(`${vhn[r]} capture failed — ${a}`),this.name="CaptureLayerError",this.layer=r}}function gye(t,r){return r instanceof s8?r:new s8(t,r)}const nP=32,bhn=24,vQe=.9;function JWt(t,r){return[t[r*4]??0,t[r*4+1]??0,t[r*4+2]??0]}function Ahn(t,r){const i=new Map;for(let d=0;d<r;d++){const[_,g,b]=JWt(t,d),S=_>>5<<10|g>>5<<5|b>>5,k=i.get(S)??{n:0,r:0,g:0,b:0};k.n+=1,k.r+=_,k.g+=g,k.b+=b,i.set(S,k)}let a={n:1,r:0,g:0,b:0},l=0;for(const d of i.values())d.n/r>=.01&&(l+=1),d.n>a.n&&(a=d);return{mean:[Math.round(a.r/a.n),Math.round(a.g/a.n),Math.round(a.b/a.n)],distinctRegions:l}}function Shn(t,r,i){let a=0;for(let l=0;l<r;l++){const d=JWt(t,l);Math.max(Math.abs(d[0]-i[0]),Math.abs(d[1]-i[1]),Math.abs(d[2]-i[2]))<=bhn&&(a+=1)}return a}function WWt(t,r,i=vQe){const{mean:a,distinctRegions:l}=Ahn(t,r),d=Math.round(Shn(t,r,a)/r*1e3)/1e3,_=`#${a.map(S=>S.toString(16).padStart(2,"0")).join("")}`,g=d>=i,b=`this capture is ~${Math.round(d*100)}% one flat surface (${_}) — likely a wall, an empty view, or a buried camera; it is weak evidence.`;return{dominantFraction:d,dominantColor:_,distinctRegions:l,degenerate:g,...g?{warning:b}:{}}}function N$e(t,r,i=vQe){try{const a=r.createElement("canvas");a.width=nP,a.height=nP;const l=a.getContext("2d");if(!l)return null;l.drawImage(t,0,0,nP,nP);const d=l.getImageData(0,0,nP,nP);return WWt(d.data,nP*nP,i)}catch{return null}}async function HWt(t,r=350){if(typeof t.getAnimations!="function")return;const i=t.getAnimations({subtree:!0}).filter(a=>{const l=a.effect?.getComputedTiming().endTime;return typeof l=="number"&&Number.isFinite(l)});i.length!==0&&await Promise.race([Promise.allSettled(i.map(a=>a.finished)),new Promise(a=>setTimeout(a,r))])}async function aee(t,r=75){const i=t.ownerDocument.defaultView?.requestAnimationFrame.bind(t.ownerDocument.defaultView);i&&await new Promise(a=>{let l=!1;const d=()=>{l||(l=!0,clearTimeout(_),a())},_=setTimeout(d,r);i(()=>i(d))})}async function GWt(t,r){return await aee(t),(r?.presentsOnCanvas??t.querySelectorAll("canvas").length>0)||await new Promise(a=>setTimeout(a,650)),await HWt(t),await aee(t),O$e(t,2,r??{})}const QWt=.03;function KWt(t,r){if(r<=0)return 0;let i=0;for(let a=3;a<t.length;a+=4)t[a]===0&&(i+=1);return i/r}function YWt(t,r,i=.08){if(r<=0)return!1;let a=0;for(let l=0;l<t.length;l+=4)t[l]<=8&&t[l+1]<=8&&t[l+2]<=8&&t[l+3]>=250&&(a+=1);return a/r>i}function xhn(t,r,i,a){let l;try{l=t.getImageData(0,0,r,i)}catch{return{kind:"ok"}}const d=r*i,_=KWt(l.data,d),g=_>QWt;return a>0&&(g||YWt(l.data,d))?{kind:"retry"}:g?{kind:"blank",transparentFraction:_}:{kind:"ok"}}function whn(t,r,i){let a;try{a=t.getImageData(0,0,r,i)}catch{return{left:0,top:0,right:r,bottom:i}}let l=r,d=i,_=-1,g=-1;const b=a.data;for(let S=0;S<i;S+=1){const k=S*r*4;for(let w=0;w<r;w+=1)b[k+w*4+3]!==0&&(w<l&&(l=w),w>_&&(_=w),S<d&&(d=S),S>g&&(g=S))}return _<0?null:{left:l,top:d,right:_+1,bottom:g+1}}async function O$e(t,r,i){const a=t.ownerDocument.createElement("canvas"),l=await XWt(t,a,i),d=a.width,_=a.height,g=a.getContext("2d");if(!g)throw new s8("composite-output","no 2d canvas context");if(l.canvases===0&&l.domOverlays>0&&i?.cropToContent===!0){const w=whn(g,d,_);if(w===null){if(i.allowTransparent)return{base64:a.toDataURL("image/png").split(",")[1],mimeType:"image/png",layers:l};if(r>0)return await new Promise(de=>setTimeout(de,300)),await aee(t),O$e(t,r-1,i);throw new s8("dom-overlay","the composite is ~100% fully transparent after two repaints — nothing in it painted a backdrop, so the PNG would read as a flat black frame. This subject's background is painted by an element OUTSIDE what is being photographed (a detached clone carries no ancestors), or its own DOM never mounted.")}const N=16,P=Math.max(0,w.left-N),j=Math.max(0,w.top-N),J=Math.min(d,w.right+N),X=Math.min(_,w.bottom+N),G=t.ownerDocument.createElement("canvas");G.width=Math.max(1,J-P),G.height=Math.max(1,X-j);const ee=G.getContext("2d");if(!ee)throw new s8("composite-output","no 2d canvas context");const xe=getComputedStyle(t).backgroundColor;xe&&xe!=="transparent"&&xe!=="rgba(0, 0, 0, 0)"&&(ee.fillStyle=xe,ee.fillRect(0,0,G.width,G.height)),ee.drawImage(a,P,j,G.width,G.height,0,0,G.width,G.height);const ue=N$e(G,t.ownerDocument);let fe;try{fe=G.toDataURL("image/png")}catch(de){throw gye("composite-output",de)}const se=fe.indexOf(",");return{base64:se>=0?fe.slice(se+1):fe,mimeType:"image/png",layers:l,...ue?{flatness:ue}:{}}}if(l.canvases===0&&l.domOverlays>0&&!i.allowTransparent){const w=xhn(g,d,_,r);if(w.kind==="retry")return await new Promise(N=>setTimeout(N,300)),await aee(t),O$e(t,r-1,i);if(w.kind==="blank")throw new s8("dom-overlay",`the composite is ~${Math.round(w.transparentFraction*100)}% fully transparent after two repaints — nothing in it painted a backdrop, so the PNG would read as a flat black frame. This subject's background is painted by an element OUTSIDE what is being photographed (a detached clone carries no ancestors), or its own DOM never mounted.`)}const b=N$e(a,t.ownerDocument);let S;try{S=a.toDataURL("image/png")}catch(w){throw gye("composite-output",w)}const k=S.indexOf(",");return{base64:k>=0?S.slice(k+1):S,mimeType:"image/png",layers:l,...b?{flatness:b}:{}}}function bCt(t,r,i,a=1,l=1){for(const d of r){const _=yQe(d);if(!_)continue;const g=d.getBoundingClientRect();t.fillStyle=_,t.fillRect((g.left-i.left)*a,(g.top-i.top)*l,g.width*a,g.height*l)}}async function XWt(t,r,i){const a=t.getBoundingClientRect(),l=Math.max(1,Math.round(i?.size?.width??a.width)),d=Math.max(1,Math.round(i?.size?.height??a.height)),_=i?.size?l/a.width:1,g=i?.size?d/a.height:1;r.width!==l&&(r.width=l),r.height!==d&&(r.height=d);const b=r.getContext("2d");if(!b)throw new s8("composite-output","no 2d canvas context");if(b.clearRect(0,0,l,d),i?.cropToContent!==!0){const J=getComputedStyle(t).backgroundColor;J&&J!=="transparent"&&J!=="rgba(0, 0, 0, 0)"&&(b.fillStyle=J,b.fillRect(0,0,l,d))}i?.includeDocumentStyles&&bCt(b,UWt(t),a,_,g);const k=Array.from(t.querySelectorAll("canvas")).some(J=>!Y1e(J))?null:i?.overlayCache?.take(t,l,d),w=k?.backdrops??zWt(t);bCt(b,w,a,_,g);const N=Array.from(t.querySelectorAll("canvas")).filter(J=>{const X=J.getBoundingClientRect();return J.width>0&&J.height>0&&X.width>0&&X.height>0}),P=new Map;for(const J of N)try{const X=J.getBoundingClientRect(),G=await i?.canvasFrame?.(J)??J;P.set(J,G),b.drawImage(G,(X.left-a.left)*_,(X.top-a.top)*g,X.width*_,X.height*g)}catch(X){throw gye("canvas",X)}let j=0;try{if(k)k.image&&b.drawImage(k.image,0,0,l,d),j=k.overlayCount;else{const J=performance.now(),X=VWt(t,l/_,d/g,{includeDocumentStyles:i?.includeDocumentStyles,canvasPixels:P,transparentBackdrops:new Set(w),snapshots:i?.snapshots,rasterSize:{width:l,height:d}});if(X){const G=new Image;G.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(X.svg)}`,await G.decode(),b.drawImage(G,0,0,l,d),j=X.overlayCount,i?.overlayCache?.store(t,l,d,{image:G,overlayCount:X.overlayCount,backdrops:w},performance.now()-J)}else i?.overlayCache?.store(t,l,d,{image:null,overlayCount:0,backdrops:w},performance.now()-J)}}catch(J){throw gye("dom-overlay",J)}return{canvases:N.length,domOverlays:j}}const Chn=Object.freeze(Object.defineProperty({__proto__:null,CaptureLayerError:s8,FLATNESS_GRID:nP,FLATNESS_WARN_AT:vQe,TRANSPARENT_PIXEL_LIMIT:QWt,ancestorBackdrops:UWt,buildOverlaySvg:VWt,capturePlayComposite:GWt,drawPlayCompositeFrame:XWt,hasExcessNearBlackPixels:YWt,isRootCanvas:Y1e,measureFlatness:WWt,opaqueBackgroundColor:yQe,rootSurfaceBackdrops:zWt,sampleFlatness:N$e,transparentPixelFraction:KWt,waitForFiniteMotion:HWt,waitForPaint:aee},Symbol.toStringTag,{value:"Module"}));function ACt(t,r,i){const a=l=>"x"in l?{x:l.x,y:l.y,z:l.z}:{x:l[0],y:l[1],z:l[2]};return{position:a(t),target:a(r),...i?{fov:i}:{}}}function ute(t){const r=AE(),i=r?.descriptor.presentation?.()??void 0,a=r?Pw(r.descriptor.id):null,l=n0e(),d=a?a.selection():l?.adapter?.selection?.get()??(r?.descriptor.id==="workspace:scene"?[...t.selectedEntityIds]:[]);let _;if(a){const b=a.cameraPose(),S=a.presentation();_={camera:ACt(b.position,b.target,b.fov),diagnostic:S.skeleton?"skeleton":S.mode,grid:S.grid}}else if(r?.descriptor.id==="workspace:scene"&&t.cameraPose){const b=t.cameraPose;_={camera:ACt(b.position,b.target,b.fov),diagnostic:t.shadingMode,grid:t.showGrid}}const g=sPt();return{version:1,workspace:wS(),...Bhe()===null?{}:{style:Bhe()},keymap:uI(),...i?{document:i}:{},...d.length>0?{selection:{ids:[...d]}}:{},..._?{viewport:_}:{},...g?{panel:g}:{}}}function Ehn(t){return _It(ute(t),window.location.href)}var Ab=(t=>(t.Application="application",t.WebGLPipes="webgl-pipes",t.WebGLPipesAdaptor="webgl-pipes-adaptor",t.WebGLSystem="webgl-system",t.WebGPUPipes="webgpu-pipes",t.WebGPUPipesAdaptor="webgpu-pipes-adaptor",t.WebGPUSystem="webgpu-system",t.CanvasSystem="canvas-system",t.CanvasPipesAdaptor="canvas-pipes-adaptor",t.CanvasPipes="canvas-pipes",t.Asset="asset",t.LoadParser="load-parser",t.ResolveParser="resolve-parser",t.CacheParser="cache-parser",t.DetectionParser="detection-parser",t.MaskEffect="mask-effect",t.BlendMode="blend-mode",t.TextureSource="texture-source",t.TextureUploaderWebGL="texture-uploader-webgl",t.TextureUploaderWebGPU="texture-uploader-webgpu",t.Environment="environment",t.ShapeBuilder="shape-builder",t.Batcher="batcher",t))(Ab||{});const F$e=t=>{if(typeof t=="function"||typeof t=="object"&&t.extension){if(!t.extension)throw new Error("Extension class must have an extension object");t={...typeof t.extension!="object"?{type:t.extension}:t.extension,ref:t}}if(typeof t=="object")t={...t};else throw new Error("Invalid extension type");return typeof t.type=="string"&&(t.type=[t.type]),t},f_e=(t,r)=>F$e(t).priority??r,k9={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...t){return t.map(F$e).forEach(r=>{r.type.forEach(i=>this._removeHandlers[i]?.(r))}),this},add(...t){return t.map(F$e).forEach(r=>{r.type.forEach(i=>{const a=this._addHandlers,l=this._queue;a[i]?a[i]?.(r):(l[i]=l[i]||[],l[i]?.push(r))})}),this},handle(t,r,i){const a=this._addHandlers,l=this._removeHandlers;if(a[t]||l[t])throw new Error(`Extension type ${t} already has a handler`);a[t]=r,l[t]=i;const d=this._queue;return d[t]&&(d[t]?.forEach(_=>r(_)),delete d[t]),this},handleByMap(t,r){return this.handle(t,i=>{i.name&&(r[i.name]=i.ref)},i=>{i.name&&delete r[i.name]})},handleByNamedList(t,r,i=-1){return this.handle(t,a=>{r.findIndex(d=>d.name===a.name)>=0||(r.push({name:a.name,value:a.ref}),r.sort((d,_)=>f_e(_.value,i)-f_e(d.value,i)))},a=>{const l=r.findIndex(d=>d.name===a.name);l!==-1&&r.splice(l,1)})},handleByList(t,r,i=-1){return this.handle(t,a=>{r.includes(a.ref)||(r.push(a.ref),r.sort((l,d)=>f_e(d,i)-f_e(l,i)))},a=>{const l=r.indexOf(a.ref);l!==-1&&r.splice(l,1)})},mixin(t,...r){for(const i of r)Object.defineProperties(t.prototype,Object.getOwnPropertyDescriptors(i))}},Thn={extension:{type:Ab.Environment,name:"browser",priority:-1},test:()=>!0,load:async()=>{await Xo(()=>import("./browserAll-CBGZHmKu.js"),__vite__mapDeps([66,67,3,2,4,1,8,9,10,11,6]))}},khn={extension:{type:Ab.Environment,name:"webworker",priority:0},test:()=>typeof self<"u"&&self.WorkerGlobalScope!==void 0,load:async()=>{await Xo(()=>import("./webworkerAll-B9OFnN4A.js"),__vite__mapDeps([67,3,2,4,1,8,9,10,11,6]))}};class _1{constructor(r,i,a){this._x=i||0,this._y=a||0,this._observer=r}clone(r){return new _1(r??this._observer,this._x,this._y)}set(r=0,i=r){return(this._x!==r||this._y!==i)&&(this._x=r,this._y=i,this._observer._onUpdate(this)),this}copyFrom(r){return(this._x!==r.x||this._y!==r.y)&&(this._x=r.x,this._y=r.y,this._observer._onUpdate(this)),this}copyTo(r){return r.set(this._x,this._y),r}equals(r){return r.x===this._x&&r.y===this._y}toString(){return`[pixi.js/math:ObservablePoint x=${this._x} y=${this._y} scope=${this._observer}]`}get x(){return this._x}set x(r){this._x!==r&&(this._x=r,this._observer._onUpdate(this))}get y(){return this._y}set y(r){this._y!==r&&(this._y=r,this._observer._onUpdate(this))}}var ERe={exports:{}},SCt;function Ihn(){return SCt||(SCt=1,(function(t){var r=Object.prototype.hasOwnProperty,i="~";function a(){}Object.create&&(a.prototype=Object.create(null),new a().__proto__||(i=!1));function l(b,S,k){this.fn=b,this.context=S,this.once=k||!1}function d(b,S,k,w,N){if(typeof k!="function")throw new TypeError("The listener must be a function");var P=new l(k,w||b,N),j=i?i+S:S;return b._events[j]?b._events[j].fn?b._events[j]=[b._events[j],P]:b._events[j].push(P):(b._events[j]=P,b._eventsCount++),b}function _(b,S){--b._eventsCount===0?b._events=new a:delete b._events[S]}function g(){this._events=new a,this._eventsCount=0}g.prototype.eventNames=function(){var S=[],k,w;if(this._eventsCount===0)return S;for(w in k=this._events)r.call(k,w)&&S.push(i?w.slice(1):w);return Object.getOwnPropertySymbols?S.concat(Object.getOwnPropertySymbols(k)):S},g.prototype.listeners=function(S){var k=i?i+S:S,w=this._events[k];if(!w)return[];if(w.fn)return[w.fn];for(var N=0,P=w.length,j=new Array(P);N<P;N++)j[N]=w[N].fn;return j},g.prototype.listenerCount=function(S){var k=i?i+S:S,w=this._events[k];return w?w.fn?1:w.length:0},g.prototype.emit=function(S,k,w,N,P,j){var J=i?i+S:S;if(!this._events[J])return!1;var X=this._events[J],G=arguments.length,ee,xe;if(X.fn){switch(X.once&&this.removeListener(S,X.fn,void 0,!0),G){case 1:return X.fn.call(X.context),!0;case 2:return X.fn.call(X.context,k),!0;case 3:return X.fn.call(X.context,k,w),!0;case 4:return X.fn.call(X.context,k,w,N),!0;case 5:return X.fn.call(X.context,k,w,N,P),!0;case 6:return X.fn.call(X.context,k,w,N,P,j),!0}for(xe=1,ee=new Array(G-1);xe<G;xe++)ee[xe-1]=arguments[xe];X.fn.apply(X.context,ee)}else{var ue=X.length,fe;for(xe=0;xe<ue;xe++)switch(X[xe].once&&this.removeListener(S,X[xe].fn,void 0,!0),G){case 1:X[xe].fn.call(X[xe].context);break;case 2:X[xe].fn.call(X[xe].context,k);break;case 3:X[xe].fn.call(X[xe].context,k,w);break;case 4:X[xe].fn.call(X[xe].context,k,w,N);break;default:if(!ee)for(fe=1,ee=new Array(G-1);fe<G;fe++)ee[fe-1]=arguments[fe];X[xe].fn.apply(X[xe].context,ee)}}return!0},g.prototype.on=function(S,k,w){return d(this,S,k,w,!1)},g.prototype.once=function(S,k,w){return d(this,S,k,w,!0)},g.prototype.removeListener=function(S,k,w,N){var P=i?i+S:S;if(!this._events[P])return this;if(!k)return _(this,P),this;var j=this._events[P];if(j.fn)j.fn===k&&(!N||j.once)&&(!w||j.context===w)&&_(this,P);else{for(var J=0,X=[],G=j.length;J<G;J++)(j[J].fn!==k||N&&!j[J].once||w&&j[J].context!==w)&&X.push(j[J]);X.length?this._events[P]=X.length===1?X[0]:X:_(this,P)}return this},g.prototype.removeAllListeners=function(S){var k;return S?(k=i?i+S:S,this._events[k]&&_(this,k)):(this._events=new a,this._eventsCount=0),this},g.prototype.off=g.prototype.removeListener,g.prototype.addListener=g.prototype.on,g.prefixed=i,g.EventEmitter=g,t.exports=g})(ERe)),ERe.exports}var Dhn=Ihn();const X1e=Fkt(Dhn),Phn=Math.PI*2,Nhn=180/Math.PI,Ohn=Math.PI/180;class rI{constructor(r=0,i=0){this.x=0,this.y=0,this.x=r,this.y=i}clone(){return new rI(this.x,this.y)}copyFrom(r){return this.set(r.x,r.y),this}copyTo(r){return r.set(this.x,this.y),r}equals(r){return r.x===this.x&&r.y===this.y}set(r=0,i=r){return this.x=r,this.y=i,this}toString(){return`[pixi.js/math:Point x=${this.x} y=${this.y}]`}static get shared(){return TRe.x=0,TRe.y=0,TRe}}const TRe=new rI;class Lm{constructor(r=1,i=0,a=0,l=1,d=0,_=0){this.array=null,this.a=r,this.b=i,this.c=a,this.d=l,this.tx=d,this.ty=_}fromArray(r){this.a=r[0],this.b=r[1],this.c=r[3],this.d=r[4],this.tx=r[2],this.ty=r[5]}set(r,i,a,l,d,_){return this.a=r,this.b=i,this.c=a,this.d=l,this.tx=d,this.ty=_,this}toArray(r,i){this.array||(this.array=new Float32Array(9));const a=i||this.array;return r?(a[0]=this.a,a[1]=this.b,a[2]=0,a[3]=this.c,a[4]=this.d,a[5]=0,a[6]=this.tx,a[7]=this.ty,a[8]=1):(a[0]=this.a,a[1]=this.c,a[2]=this.tx,a[3]=this.b,a[4]=this.d,a[5]=this.ty,a[6]=0,a[7]=0,a[8]=1),a}apply(r,i){i=i||new rI;const a=r.x,l=r.y;return i.x=this.a*a+this.c*l+this.tx,i.y=this.b*a+this.d*l+this.ty,i}applyInverse(r,i){i=i||new rI;const a=this.a,l=this.b,d=this.c,_=this.d,g=this.tx,b=this.ty,S=1/(a*_+d*-l),k=r.x,w=r.y;return i.x=_*S*k+-d*S*w+(b*d-g*_)*S,i.y=a*S*w+-l*S*k+(-b*a+g*l)*S,i}translate(r,i){return this.tx+=r,this.ty+=i,this}scale(r,i){return this.a*=r,this.d*=i,this.c*=r,this.b*=i,this.tx*=r,this.ty*=i,this}rotate(r){const i=Math.cos(r),a=Math.sin(r),l=this.a,d=this.c,_=this.tx;return this.a=l*i-this.b*a,this.b=l*a+this.b*i,this.c=d*i-this.d*a,this.d=d*a+this.d*i,this.tx=_*i-this.ty*a,this.ty=_*a+this.ty*i,this}append(r){const i=this.a,a=this.b,l=this.c,d=this.d;return this.a=r.a*i+r.b*l,this.b=r.a*a+r.b*d,this.c=r.c*i+r.d*l,this.d=r.c*a+r.d*d,this.tx=r.tx*i+r.ty*l+this.tx,this.ty=r.tx*a+r.ty*d+this.ty,this}appendFrom(r,i){const a=r.a,l=r.b,d=r.c,_=r.d,g=r.tx,b=r.ty,S=i.a,k=i.b,w=i.c,N=i.d;return this.a=a*S+l*w,this.b=a*k+l*N,this.c=d*S+_*w,this.d=d*k+_*N,this.tx=g*S+b*w+i.tx,this.ty=g*k+b*N+i.ty,this}setTransform(r,i,a,l,d,_,g,b,S){return this.a=Math.cos(g+S)*d,this.b=Math.sin(g+S)*d,this.c=-Math.sin(g-b)*_,this.d=Math.cos(g-b)*_,this.tx=r-(a*this.a+l*this.c),this.ty=i-(a*this.b+l*this.d),this}prepend(r){const i=this.tx;if(r.a!==1||r.b!==0||r.c!==0||r.d!==1){const a=this.a,l=this.c;this.a=a*r.a+this.b*r.c,this.b=a*r.b+this.b*r.d,this.c=l*r.a+this.d*r.c,this.d=l*r.b+this.d*r.d}return this.tx=i*r.a+this.ty*r.c+r.tx,this.ty=i*r.b+this.ty*r.d+r.ty,this}decompose(r){const i=this.a,a=this.b,l=this.c,d=this.d,_=r.pivot,g=-Math.atan2(-l,d),b=Math.atan2(a,i),S=Math.abs(g+b);return S<1e-5||Math.abs(Phn-S)<1e-5?(r.rotation=b,r.skew.x=r.skew.y=0):(r.rotation=0,r.skew.x=g,r.skew.y=b),r.scale.x=Math.sqrt(i*i+a*a),r.scale.y=Math.sqrt(l*l+d*d),r.position.x=this.tx+(_.x*i+_.y*l),r.position.y=this.ty+(_.x*a+_.y*d),r}invert(){const r=this.a,i=this.b,a=this.c,l=this.d,d=this.tx,_=r*l-i*a;return this.a=l/_,this.b=-i/_,this.c=-a/_,this.d=r/_,this.tx=(a*this.ty-l*d)/_,this.ty=-(r*this.ty-i*d)/_,this}isIdentity(){return this.a===1&&this.b===0&&this.c===0&&this.d===1&&this.tx===0&&this.ty===0}identity(){return this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this}clone(){const r=new Lm;return r.a=this.a,r.b=this.b,r.c=this.c,r.d=this.d,r.tx=this.tx,r.ty=this.ty,r}copyTo(r){return r.a=this.a,r.b=this.b,r.c=this.c,r.d=this.d,r.tx=this.tx,r.ty=this.ty,r}copyFrom(r){return this.a=r.a,this.b=r.b,this.c=r.c,this.d=r.d,this.tx=r.tx,this.ty=r.ty,this}equals(r){return r.a===this.a&&r.b===this.b&&r.c===this.c&&r.d===this.d&&r.tx===this.tx&&r.ty===this.ty}toString(){return`[pixi.js:Matrix a=${this.a} b=${this.b} c=${this.c} d=${this.d} tx=${this.tx} ty=${this.ty}]`}static get IDENTITY(){return Rhn.identity()}static get shared(){return Fhn.identity()}}const Fhn=new Lm,Rhn=new Lm,Z7=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],eR=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],tR=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],rR=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],R$e=[],ZWt=[],d_e=Math.sign;function Mhn(){for(let t=0;t<16;t++){const r=[];R$e.push(r);for(let i=0;i<16;i++){const a=d_e(Z7[t]*Z7[i]+tR[t]*eR[i]),l=d_e(eR[t]*Z7[i]+rR[t]*eR[i]),d=d_e(Z7[t]*tR[i]+tR[t]*rR[i]),_=d_e(eR[t]*tR[i]+rR[t]*rR[i]);for(let g=0;g<16;g++)if(Z7[g]===a&&eR[g]===l&&tR[g]===d&&rR[g]===_){r.push(g);break}}}for(let t=0;t<16;t++){const r=new Lm;r.set(Z7[t],eR[t],tR[t],rR[t],0,0),ZWt.push(r)}}Mhn();const T_={E:0,SE:1,S:2,SW:3,W:4,NW:5,N:6,NE:7,MIRROR_VERTICAL:8,MAIN_DIAGONAL:10,MIRROR_HORIZONTAL:12,REVERSE_DIAGONAL:14,uX:t=>Z7[t],uY:t=>eR[t],vX:t=>tR[t],vY:t=>rR[t],inv:t=>t&8?t&15:-t&7,add:(t,r)=>R$e[t][r],sub:(t,r)=>R$e[t][T_.inv(r)],rotate180:t=>t^4,isVertical:t=>(t&3)===2,byDirection:(t,r)=>Math.abs(t)*2<=Math.abs(r)?r>=0?T_.S:T_.N:Math.abs(r)*2<=Math.abs(t)?t>0?T_.E:T_.W:r>0?t>0?T_.SE:T_.SW:t>0?T_.NE:T_.NW,matrixAppendRotationInv:(t,r,i=0,a=0,l=0,d=0)=>{const _=ZWt[T_.inv(r)],g=_.a,b=_.b,S=_.c,k=_.d,w=i-Math.min(0,g*l,S*d,g*l+S*d),N=a-Math.min(0,b*l,k*d,b*l+k*d),P=t.a,j=t.b,J=t.c,X=t.d;t.a=g*P+b*J,t.b=g*j+b*X,t.c=S*P+k*J,t.d=S*j+k*X,t.tx=w*P+N*J+t.tx,t.ty=w*j+N*X+t.ty},transformRectCoords:(t,r,i,a)=>{const{x:l,y:d,width:_,height:g}=t,{x:b,y:S,width:k,height:w}=r;return i===T_.E?(a.set(l+b,d+S,_,g),a):i===T_.S?a.set(k-d-g+b,l+S,g,_):i===T_.W?a.set(k-l-_+b,w-d-g+S,_,g):i===T_.N?a.set(d+b,w-l-_+S,g,_):a.set(l+b,d+S,_,g)}},p_e=[new rI,new rI,new rI,new rI];class nI{constructor(r=0,i=0,a=0,l=0){this.type="rectangle",this.x=Number(r),this.y=Number(i),this.width=Number(a),this.height=Number(l)}get left(){return this.x}get right(){return this.x+this.width}get top(){return this.y}get bottom(){return this.y+this.height}isEmpty(){return this.left===this.right||this.top===this.bottom}static get EMPTY(){return new nI(0,0,0,0)}clone(){return new nI(this.x,this.y,this.width,this.height)}copyFromBounds(r){return this.x=r.minX,this.y=r.minY,this.width=r.maxX-r.minX,this.height=r.maxY-r.minY,this}copyFrom(r){return this.x=r.x,this.y=r.y,this.width=r.width,this.height=r.height,this}copyTo(r){return r.copyFrom(this),r}contains(r,i){return this.width<=0||this.height<=0?!1:r>=this.x&&r<this.x+this.width&&i>=this.y&&i<this.y+this.height}strokeContains(r,i,a,l=.5){const{width:d,height:_}=this;if(d<=0||_<=0)return!1;const g=this.x,b=this.y,S=a*(1-l),k=a-S,w=g-S,N=g+d+S,P=b-S,j=b+_+S,J=g+k,X=g+d-k,G=b+k,ee=b+_-k;return r>=w&&r<=N&&i>=P&&i<=j&&!(r>J&&r<X&&i>G&&i<ee)}intersects(r,i){if(!i){const ge=this.x<r.x?r.x:this.x;if((this.right>r.right?r.right:this.right)<=ge)return!1;const tt=this.y<r.y?r.y:this.y;return(this.bottom>r.bottom?r.bottom:this.bottom)>tt}const a=this.left,l=this.right,d=this.top,_=this.bottom;if(l<=a||_<=d)return!1;const g=p_e[0].set(r.left,r.top),b=p_e[1].set(r.left,r.bottom),S=p_e[2].set(r.right,r.top),k=p_e[3].set(r.right,r.bottom);if(S.x<=g.x||b.y<=g.y)return!1;const w=Math.sign(i.a*i.d-i.b*i.c);if(w===0||(i.apply(g,g),i.apply(b,b),i.apply(S,S),i.apply(k,k),Math.max(g.x,b.x,S.x,k.x)<=a||Math.min(g.x,b.x,S.x,k.x)>=l||Math.max(g.y,b.y,S.y,k.y)<=d||Math.min(g.y,b.y,S.y,k.y)>=_))return!1;const N=w*(b.y-g.y),P=w*(g.x-b.x),j=N*a+P*d,J=N*l+P*d,X=N*a+P*_,G=N*l+P*_;if(Math.max(j,J,X,G)<=N*g.x+P*g.y||Math.min(j,J,X,G)>=N*k.x+P*k.y)return!1;const ee=w*(g.y-S.y),xe=w*(S.x-g.x),ue=ee*a+xe*d,fe=ee*l+xe*d,se=ee*a+xe*_,de=ee*l+xe*_;return!(Math.max(ue,fe,se,de)<=ee*g.x+xe*g.y||Math.min(ue,fe,se,de)>=ee*k.x+xe*k.y)}pad(r=0,i=r){return this.x-=r,this.y-=i,this.width+=r*2,this.height+=i*2,this}fit(r){const i=Math.max(this.x,r.x),a=Math.min(this.x+this.width,r.x+r.width),l=Math.max(this.y,r.y),d=Math.min(this.y+this.height,r.y+r.height);return this.x=i,this.width=Math.max(a-i,0),this.y=l,this.height=Math.max(d-l,0),this}ceil(r=1,i=.001){const a=Math.ceil((this.x+this.width-i)*r)/r,l=Math.ceil((this.y+this.height-i)*r)/r;return this.x=Math.floor((this.x+i)*r)/r,this.y=Math.floor((this.y+i)*r)/r,this.width=a-this.x,this.height=l-this.y,this}scale(r,i=r){return this.x*=r,this.y*=i,this.width*=r,this.height*=i,this}enlarge(r){const i=Math.min(this.x,r.x),a=Math.max(this.x+this.width,r.x+r.width),l=Math.min(this.y,r.y),d=Math.max(this.y+this.height,r.y+r.height);return this.x=i,this.width=a-i,this.y=l,this.height=d-l,this}getBounds(r){return r||(r=new nI),r.copyFrom(this),r}containsRect(r){if(this.width<=0||this.height<=0)return!1;const i=r.x,a=r.y,l=r.x+r.width,d=r.y+r.height;return i>=this.x&&i<this.x+this.width&&a>=this.y&&a<this.y+this.height&&l>=this.x&&l<this.x+this.width&&d>=this.y&&d<this.y+this.height}set(r,i,a,l){return this.x=r,this.y=i,this.width=a,this.height=l,this}toString(){return`[pixi.js/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`}}const kRe={default:-1};function o8(t="default"){return kRe[t]===void 0&&(kRe[t]=-1),++kRe[t]}const xCt=new Set,Hz="8.0.0",wq={quiet:!1,noColor:!1},hI=((t,r,i=3)=>{if(wq.quiet||xCt.has(r))return;let a=new Error().stack;const l=`${r}
|
|
1599
|
+
`)}function phn(t,r){const i=t.ownerDocument.defaultView?.getComputedStyle(t);if(i){for(const a of Array.from(i)){if(!a.startsWith("--"))continue;const l=i.getPropertyValue(a);l&&r.style.setProperty(a,l)}for(const a of["color","color-scheme","font-family","font-size","font-weight","line-height","text-shadow"]){const l=i.getPropertyValue(a);l&&r.style.setProperty(a,l)}}}function yQe(t){const i=t.ownerDocument.defaultView?.getComputedStyle(t)?.backgroundColor;if(!i||i==="transparent")return null;const a=/^rgba?\([^)]*,\s*([\d.]+)\s*\)$/.exec(i)?.[1];return a!==void 0&&Number(a)===0?null:i}function zWt(t){const r=[],i=new Set;for(const a of Array.from(t.querySelectorAll("canvas"))){if(!Y1e(a))continue;const l=[];for(let d=a.parentElement;d&&(d===t||t.contains(d))&&(l.unshift(d),d!==t);d=d.parentElement);for(const d of[...l,..._hn(t,a)])i.has(d)||(i.add(d),r.push(d))}return r}function _hn(t,r){const i=t.ownerDocument,a=r.getBoundingClientRect();if(a.width<=0||a.height<=0||typeof i.elementsFromPoint!="function")return[];const l=new Set,d=[[a.left+a.width/2,a.top+a.height/2],[a.left+a.width*.1,a.top+a.height*.1],[a.left+a.width*.9,a.top+a.height*.1],[a.left+a.width*.1,a.top+a.height*.9],[a.left+a.width*.9,a.top+a.height*.9]];for(const[_,g]of d){const b=i.elementsFromPoint(_,g),S=b.indexOf(r);if(!(S<0))for(const k of b.slice(S+1))mhn(k,t)&&l.add(k)}return Array.from(l).reverse()}function mhn(t,r){return t instanceof HTMLElement&&(t===r||r.contains(t))&&yQe(t)!==null}function UWt(t){const r=[];for(let i=t.parentElement;i;i=i.parentElement)r.unshift(i);return r}function hhn(t,r){const i="select, input, textarea",a=_=>[..._.matches(i)?[_]:[],...Array.from(_.querySelectorAll(i))],l=a(t),d=a(r);l.forEach((_,g)=>{const b=d[g];if(b){if(_ instanceof HTMLSelectElement&&b instanceof HTMLSelectElement){const S=Array.from(_.options);Array.from(b.options).forEach((k,w)=>{S[w]?.selected?k.setAttribute("selected",""):k.removeAttribute("selected")});return}if(_ instanceof HTMLInputElement&&b instanceof HTMLInputElement){_.type==="checkbox"||_.type==="radio"?_.checked?b.setAttribute("checked",""):b.removeAttribute("checked"):b.setAttribute("value",_.value);return}_ instanceof HTMLTextAreaElement&&b instanceof HTMLTextAreaElement&&(b.textContent=_.value)}})}function ghn(t,r){const i=[t,...Array.from(t.querySelectorAll("*"))],a=[r,...Array.from(r.querySelectorAll("*"))];i.forEach((l,d)=>{const _=l.scrollTop,g=l.scrollLeft;if(_===0&&g===0)return;const b=a[d];if(!(b instanceof HTMLElement))return;const S=b.firstElementChild;if(!(S instanceof HTMLElement))return;b.style.overflow="hidden";const k=getComputedStyle(l.firstElementChild??l),w=Number.parseFloat(k.marginTop)||0,N=Number.parseFloat(k.marginLeft)||0;_!==0&&(S.style.marginTop=`${w-_}px`),g!==0&&(S.style.marginLeft=`${N-g}px`)})}function yhn(t,r,i){if(!i?.size)return;const a=[t,...Array.from(t.querySelectorAll("*"))],l=[r,...Array.from(r.querySelectorAll("*"))];a.forEach((d,_)=>{if(!i.has(d))return;const g=l[_];g instanceof HTMLElement&&(g.style.background="transparent")})}function VWt(t,r,i,a){const l=Array.from(t.children).filter(J=>J.tagName.toLowerCase()!=="canvas");if(l.length===0)return null;const d=a?.includeDocumentStyles===!0,_=d?t.cloneNode(!1):t.ownerDocument.createElement("div");_.style.position="relative",_.style.inset="auto",_.style.width=`${r}px`,_.style.height=`${i}px`,_.style.margin="0",_.style.transform="none",d?phn(t,_):_.style.background="transparent";const g=a?.transparentBackdrops;if(g?.has(t)&&(_.style.background="transparent"),t.closest(`[${P$e}]`)&&_.setAttribute(P$e,""),d){const J=dhn(t.ownerDocument);if(J){const X=t.ownerDocument.createElement("style");X.textContent=J,_.appendChild(X)}}const b=t.ownerDocument.createElement("style");b.textContent="*,*::before,*::after{animation:none!important;transition:none!important;caret-color:transparent!important;backdrop-filter:none!important;-webkit-backdrop-filter:none!important;}",_.appendChild(b);const S=ohn();if(S){const J=t.ownerDocument.createElement("style");J.textContent=S,_.appendChild(J)}for(const J of l){const X=J.cloneNode(!0);yhn(J,X,g),hhn(J,X),ghn(J,X);const G=[...J instanceof HTMLImageElement?[J]:[],...Array.from(J.querySelectorAll("img"))];[...X instanceof HTMLImageElement?[X]:[],...Array.from(X.querySelectorAll("img"))].forEach((se,de)=>{const ge=G[de];if(!ge?.complete||ge.naturalWidth<=0||ge.naturalHeight<=0)return;const qe=ge.currentSrc||ge.src,tt=a?.snapshots?.imgs.get(ge),Ct=tt&&tt.src===qe?tt.url:CRe(t.ownerDocument,ge);(!tt||tt.src!==qe)&&a?.snapshots?.imgs.set(ge,{src:qe,url:Ct}),Ct&&se.setAttribute("src",Ct)});const xe=[...J instanceof HTMLVideoElement?[J]:[],...Array.from(J.querySelectorAll("video"))];[...X instanceof HTMLVideoElement?[X]:[],...Array.from(X.querySelectorAll("video"))].forEach((se,de)=>{const ge=xe[de];if(!ge||ge.readyState<2||ge.videoWidth<=0)return;const qe=CRe(t.ownerDocument,ge);if(!qe)return;const tt=t.ownerDocument.createElement("img");tt.setAttribute("src",qe),tt.setAttribute("style",se.getAttribute("style")??""),se.replaceWith(tt)});const fe=Array.from(J.querySelectorAll("canvas"));Array.from(X.querySelectorAll("canvas")).forEach((se,de)=>{const ge=fe[de];if(ge&&Y1e(ge)){se.remove();return}const qe=ge?a?.canvasPixels?.get(ge):void 0,tt=qe?CRe(t.ownerDocument,qe):null;if(!tt){se.remove();return}const Ct=t.ownerDocument.createElement("img");Ct.setAttribute("src",tt),Ct.setAttribute("style",`${se.getAttribute("style")??""}`);for(const Ot of Array.from(se.attributes))Ct.setAttribute(Ot.name,Ot.value);se.replaceWith(Ct)}),_.appendChild(X)}const k=new XMLSerializer().serializeToString(_),w=a?.rasterSize?.width??r,N=a?.rasterSize?.height??i,P=w===r&&N===i?"":` viewBox="0 0 ${r} ${i}"`;return{svg:`<svg xmlns="http://www.w3.org/2000/svg" width="${w}" height="${N}"${P}><foreignObject width="100%" height="100%">${k}</foreignObject></svg>`,overlayCount:l.length}}const vhn={canvas:"canvas layer","dom-overlay":"DOM overlay layer","composite-output":"composite output"};class s8 extends Error{layer;constructor(r,i){const a=typeof i=="object"&&i!==null&&"message"in i&&typeof i.message=="string"?i.message:String(i);super(`${vhn[r]} capture failed — ${a}`),this.name="CaptureLayerError",this.layer=r}}function gye(t,r){return r instanceof s8?r:new s8(t,r)}const nP=32,bhn=24,vQe=.9;function JWt(t,r){return[t[r*4]??0,t[r*4+1]??0,t[r*4+2]??0]}function Ahn(t,r){const i=new Map;for(let d=0;d<r;d++){const[_,g,b]=JWt(t,d),S=_>>5<<10|g>>5<<5|b>>5,k=i.get(S)??{n:0,r:0,g:0,b:0};k.n+=1,k.r+=_,k.g+=g,k.b+=b,i.set(S,k)}let a={n:1,r:0,g:0,b:0},l=0;for(const d of i.values())d.n/r>=.01&&(l+=1),d.n>a.n&&(a=d);return{mean:[Math.round(a.r/a.n),Math.round(a.g/a.n),Math.round(a.b/a.n)],distinctRegions:l}}function Shn(t,r,i){let a=0;for(let l=0;l<r;l++){const d=JWt(t,l);Math.max(Math.abs(d[0]-i[0]),Math.abs(d[1]-i[1]),Math.abs(d[2]-i[2]))<=bhn&&(a+=1)}return a}function WWt(t,r,i=vQe){const{mean:a,distinctRegions:l}=Ahn(t,r),d=Math.round(Shn(t,r,a)/r*1e3)/1e3,_=`#${a.map(S=>S.toString(16).padStart(2,"0")).join("")}`,g=d>=i,b=`this capture is ~${Math.round(d*100)}% one flat surface (${_}) — likely a wall, an empty view, or a buried camera; it is weak evidence.`;return{dominantFraction:d,dominantColor:_,distinctRegions:l,degenerate:g,...g?{warning:b}:{}}}function N$e(t,r,i=vQe){try{const a=r.createElement("canvas");a.width=nP,a.height=nP;const l=a.getContext("2d");if(!l)return null;l.drawImage(t,0,0,nP,nP);const d=l.getImageData(0,0,nP,nP);return WWt(d.data,nP*nP,i)}catch{return null}}async function HWt(t,r=350){if(typeof t.getAnimations!="function")return;const i=t.getAnimations({subtree:!0}).filter(a=>{const l=a.effect?.getComputedTiming().endTime;return typeof l=="number"&&Number.isFinite(l)});i.length!==0&&await Promise.race([Promise.allSettled(i.map(a=>a.finished)),new Promise(a=>setTimeout(a,r))])}async function aee(t,r=75){const i=t.ownerDocument.defaultView?.requestAnimationFrame.bind(t.ownerDocument.defaultView);i&&await new Promise(a=>{let l=!1;const d=()=>{l||(l=!0,clearTimeout(_),a())},_=setTimeout(d,r);i(()=>i(d))})}async function GWt(t,r){return await aee(t),(r?.presentsOnCanvas??t.querySelectorAll("canvas").length>0)||await new Promise(a=>setTimeout(a,650)),await HWt(t),await aee(t),O$e(t,2,r??{})}const QWt=.03;function KWt(t,r){if(r<=0)return 0;let i=0;for(let a=3;a<t.length;a+=4)t[a]===0&&(i+=1);return i/r}function YWt(t,r,i=.08){if(r<=0)return!1;let a=0;for(let l=0;l<t.length;l+=4)t[l]<=8&&t[l+1]<=8&&t[l+2]<=8&&t[l+3]>=250&&(a+=1);return a/r>i}function xhn(t,r,i,a){let l;try{l=t.getImageData(0,0,r,i)}catch{return{kind:"ok"}}const d=r*i,_=KWt(l.data,d),g=_>QWt;return a>0&&(g||YWt(l.data,d))?{kind:"retry"}:g?{kind:"blank",transparentFraction:_}:{kind:"ok"}}function whn(t,r,i){let a;try{a=t.getImageData(0,0,r,i)}catch{return{left:0,top:0,right:r,bottom:i}}let l=r,d=i,_=-1,g=-1;const b=a.data;for(let S=0;S<i;S+=1){const k=S*r*4;for(let w=0;w<r;w+=1)b[k+w*4+3]!==0&&(w<l&&(l=w),w>_&&(_=w),S<d&&(d=S),S>g&&(g=S))}return _<0?null:{left:l,top:d,right:_+1,bottom:g+1}}async function O$e(t,r,i){const a=t.ownerDocument.createElement("canvas"),l=await XWt(t,a,i),d=a.width,_=a.height,g=a.getContext("2d");if(!g)throw new s8("composite-output","no 2d canvas context");if(l.canvases===0&&l.domOverlays>0&&i?.cropToContent===!0){const w=whn(g,d,_);if(w===null){if(i.allowTransparent)return{base64:a.toDataURL("image/png").split(",")[1],mimeType:"image/png",layers:l};if(r>0)return await new Promise(de=>setTimeout(de,300)),await aee(t),O$e(t,r-1,i);throw new s8("dom-overlay","the composite is ~100% fully transparent after two repaints — nothing in it painted a backdrop, so the PNG would read as a flat black frame. This subject's background is painted by an element OUTSIDE what is being photographed (a detached clone carries no ancestors), or its own DOM never mounted.")}const N=16,P=Math.max(0,w.left-N),j=Math.max(0,w.top-N),J=Math.min(d,w.right+N),X=Math.min(_,w.bottom+N),G=t.ownerDocument.createElement("canvas");G.width=Math.max(1,J-P),G.height=Math.max(1,X-j);const ee=G.getContext("2d");if(!ee)throw new s8("composite-output","no 2d canvas context");const xe=getComputedStyle(t).backgroundColor;xe&&xe!=="transparent"&&xe!=="rgba(0, 0, 0, 0)"&&(ee.fillStyle=xe,ee.fillRect(0,0,G.width,G.height)),ee.drawImage(a,P,j,G.width,G.height,0,0,G.width,G.height);const ue=N$e(G,t.ownerDocument);let fe;try{fe=G.toDataURL("image/png")}catch(de){throw gye("composite-output",de)}const se=fe.indexOf(",");return{base64:se>=0?fe.slice(se+1):fe,mimeType:"image/png",layers:l,...ue?{flatness:ue}:{}}}if(l.canvases===0&&l.domOverlays>0&&!i.allowTransparent){const w=xhn(g,d,_,r);if(w.kind==="retry")return await new Promise(N=>setTimeout(N,300)),await aee(t),O$e(t,r-1,i);if(w.kind==="blank")throw new s8("dom-overlay",`the composite is ~${Math.round(w.transparentFraction*100)}% fully transparent after two repaints — nothing in it painted a backdrop, so the PNG would read as a flat black frame. This subject's background is painted by an element OUTSIDE what is being photographed (a detached clone carries no ancestors), or its own DOM never mounted.`)}const b=N$e(a,t.ownerDocument);let S;try{S=a.toDataURL("image/png")}catch(w){throw gye("composite-output",w)}const k=S.indexOf(",");return{base64:k>=0?S.slice(k+1):S,mimeType:"image/png",layers:l,...b?{flatness:b}:{}}}function bCt(t,r,i,a=1,l=1){for(const d of r){const _=yQe(d);if(!_)continue;const g=d.getBoundingClientRect();t.fillStyle=_,t.fillRect((g.left-i.left)*a,(g.top-i.top)*l,g.width*a,g.height*l)}}async function XWt(t,r,i){const a=t.getBoundingClientRect(),l=Math.max(1,Math.round(i?.size?.width??a.width)),d=Math.max(1,Math.round(i?.size?.height??a.height)),_=i?.size?l/a.width:1,g=i?.size?d/a.height:1;r.width!==l&&(r.width=l),r.height!==d&&(r.height=d);const b=r.getContext("2d");if(!b)throw new s8("composite-output","no 2d canvas context");if(b.clearRect(0,0,l,d),i?.cropToContent!==!0){const J=getComputedStyle(t).backgroundColor;J&&J!=="transparent"&&J!=="rgba(0, 0, 0, 0)"&&(b.fillStyle=J,b.fillRect(0,0,l,d))}i?.includeDocumentStyles&&bCt(b,UWt(t),a,_,g);const k=Array.from(t.querySelectorAll("canvas")).some(J=>!Y1e(J))?null:i?.overlayCache?.take(t,l,d),w=k?.backdrops??zWt(t);bCt(b,w,a,_,g);const N=Array.from(t.querySelectorAll("canvas")).filter(J=>{const X=J.getBoundingClientRect();return J.width>0&&J.height>0&&X.width>0&&X.height>0}),P=new Map;for(const J of N)try{const X=J.getBoundingClientRect(),G=await i?.canvasFrame?.(J)??J;P.set(J,G),b.drawImage(G,(X.left-a.left)*_,(X.top-a.top)*g,X.width*_,X.height*g)}catch(X){throw gye("canvas",X)}let j=0;try{if(k)k.image&&b.drawImage(k.image,0,0,l,d),j=k.overlayCount;else{const J=performance.now(),X=VWt(t,l/_,d/g,{includeDocumentStyles:i?.includeDocumentStyles,canvasPixels:P,transparentBackdrops:new Set(w),snapshots:i?.snapshots,rasterSize:{width:l,height:d}});if(X){const G=new Image;G.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(X.svg)}`,await G.decode(),b.drawImage(G,0,0,l,d),j=X.overlayCount,i?.overlayCache?.store(t,l,d,{image:G,overlayCount:X.overlayCount,backdrops:w},performance.now()-J)}else i?.overlayCache?.store(t,l,d,{image:null,overlayCount:0,backdrops:w},performance.now()-J)}}catch(J){throw gye("dom-overlay",J)}return{canvases:N.length,domOverlays:j}}const Chn=Object.freeze(Object.defineProperty({__proto__:null,CaptureLayerError:s8,FLATNESS_GRID:nP,FLATNESS_WARN_AT:vQe,TRANSPARENT_PIXEL_LIMIT:QWt,ancestorBackdrops:UWt,buildOverlaySvg:VWt,capturePlayComposite:GWt,drawPlayCompositeFrame:XWt,hasExcessNearBlackPixels:YWt,isRootCanvas:Y1e,measureFlatness:WWt,opaqueBackgroundColor:yQe,rootSurfaceBackdrops:zWt,sampleFlatness:N$e,transparentPixelFraction:KWt,waitForFiniteMotion:HWt,waitForPaint:aee},Symbol.toStringTag,{value:"Module"}));function ACt(t,r,i){const a=l=>"x"in l?{x:l.x,y:l.y,z:l.z}:{x:l[0],y:l[1],z:l[2]};return{position:a(t),target:a(r),...i?{fov:i}:{}}}function ute(t){const r=AE(),i=r?.descriptor.presentation?.()??void 0,a=r?Pw(r.descriptor.id):null,l=n0e(),d=a?a.selection():l?.adapter?.selection?.get()??(r?.descriptor.id==="workspace:scene"?[...t.selectedEntityIds]:[]);let _;if(a){const b=a.cameraPose(),S=a.presentation();_={camera:ACt(b.position,b.target,b.fov),diagnostic:S.skeleton?"skeleton":S.mode,grid:S.grid}}else if(r?.descriptor.id==="workspace:scene"&&t.cameraPose){const b=t.cameraPose;_={camera:ACt(b.position,b.target,b.fov),diagnostic:t.shadingMode,grid:t.showGrid}}const g=sPt();return{version:1,workspace:wS(),...Bhe()===null?{}:{style:Bhe()},keymap:uI(),...i?{document:i}:{},...d.length>0?{selection:{ids:[...d]}}:{},..._?{viewport:_}:{},...g?{panel:g}:{}}}function Ehn(t){return _It(ute(t),window.location.href)}var Ab=(t=>(t.Application="application",t.WebGLPipes="webgl-pipes",t.WebGLPipesAdaptor="webgl-pipes-adaptor",t.WebGLSystem="webgl-system",t.WebGPUPipes="webgpu-pipes",t.WebGPUPipesAdaptor="webgpu-pipes-adaptor",t.WebGPUSystem="webgpu-system",t.CanvasSystem="canvas-system",t.CanvasPipesAdaptor="canvas-pipes-adaptor",t.CanvasPipes="canvas-pipes",t.Asset="asset",t.LoadParser="load-parser",t.ResolveParser="resolve-parser",t.CacheParser="cache-parser",t.DetectionParser="detection-parser",t.MaskEffect="mask-effect",t.BlendMode="blend-mode",t.TextureSource="texture-source",t.TextureUploaderWebGL="texture-uploader-webgl",t.TextureUploaderWebGPU="texture-uploader-webgpu",t.Environment="environment",t.ShapeBuilder="shape-builder",t.Batcher="batcher",t))(Ab||{});const F$e=t=>{if(typeof t=="function"||typeof t=="object"&&t.extension){if(!t.extension)throw new Error("Extension class must have an extension object");t={...typeof t.extension!="object"?{type:t.extension}:t.extension,ref:t}}if(typeof t=="object")t={...t};else throw new Error("Invalid extension type");return typeof t.type=="string"&&(t.type=[t.type]),t},f_e=(t,r)=>F$e(t).priority??r,k9={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...t){return t.map(F$e).forEach(r=>{r.type.forEach(i=>this._removeHandlers[i]?.(r))}),this},add(...t){return t.map(F$e).forEach(r=>{r.type.forEach(i=>{const a=this._addHandlers,l=this._queue;a[i]?a[i]?.(r):(l[i]=l[i]||[],l[i]?.push(r))})}),this},handle(t,r,i){const a=this._addHandlers,l=this._removeHandlers;if(a[t]||l[t])throw new Error(`Extension type ${t} already has a handler`);a[t]=r,l[t]=i;const d=this._queue;return d[t]&&(d[t]?.forEach(_=>r(_)),delete d[t]),this},handleByMap(t,r){return this.handle(t,i=>{i.name&&(r[i.name]=i.ref)},i=>{i.name&&delete r[i.name]})},handleByNamedList(t,r,i=-1){return this.handle(t,a=>{r.findIndex(d=>d.name===a.name)>=0||(r.push({name:a.name,value:a.ref}),r.sort((d,_)=>f_e(_.value,i)-f_e(d.value,i)))},a=>{const l=r.findIndex(d=>d.name===a.name);l!==-1&&r.splice(l,1)})},handleByList(t,r,i=-1){return this.handle(t,a=>{r.includes(a.ref)||(r.push(a.ref),r.sort((l,d)=>f_e(d,i)-f_e(l,i)))},a=>{const l=r.indexOf(a.ref);l!==-1&&r.splice(l,1)})},mixin(t,...r){for(const i of r)Object.defineProperties(t.prototype,Object.getOwnPropertyDescriptors(i))}},Thn={extension:{type:Ab.Environment,name:"browser",priority:-1},test:()=>!0,load:async()=>{await Xo(()=>import("./browserAll-DdupNJVI.js"),__vite__mapDeps([66,67,3,2,4,1,8,9,10,11,6]))}},khn={extension:{type:Ab.Environment,name:"webworker",priority:0},test:()=>typeof self<"u"&&self.WorkerGlobalScope!==void 0,load:async()=>{await Xo(()=>import("./webworkerAll-6TTdOa6N.js"),__vite__mapDeps([67,3,2,4,1,8,9,10,11,6]))}};class _1{constructor(r,i,a){this._x=i||0,this._y=a||0,this._observer=r}clone(r){return new _1(r??this._observer,this._x,this._y)}set(r=0,i=r){return(this._x!==r||this._y!==i)&&(this._x=r,this._y=i,this._observer._onUpdate(this)),this}copyFrom(r){return(this._x!==r.x||this._y!==r.y)&&(this._x=r.x,this._y=r.y,this._observer._onUpdate(this)),this}copyTo(r){return r.set(this._x,this._y),r}equals(r){return r.x===this._x&&r.y===this._y}toString(){return`[pixi.js/math:ObservablePoint x=${this._x} y=${this._y} scope=${this._observer}]`}get x(){return this._x}set x(r){this._x!==r&&(this._x=r,this._observer._onUpdate(this))}get y(){return this._y}set y(r){this._y!==r&&(this._y=r,this._observer._onUpdate(this))}}var ERe={exports:{}},SCt;function Ihn(){return SCt||(SCt=1,(function(t){var r=Object.prototype.hasOwnProperty,i="~";function a(){}Object.create&&(a.prototype=Object.create(null),new a().__proto__||(i=!1));function l(b,S,k){this.fn=b,this.context=S,this.once=k||!1}function d(b,S,k,w,N){if(typeof k!="function")throw new TypeError("The listener must be a function");var P=new l(k,w||b,N),j=i?i+S:S;return b._events[j]?b._events[j].fn?b._events[j]=[b._events[j],P]:b._events[j].push(P):(b._events[j]=P,b._eventsCount++),b}function _(b,S){--b._eventsCount===0?b._events=new a:delete b._events[S]}function g(){this._events=new a,this._eventsCount=0}g.prototype.eventNames=function(){var S=[],k,w;if(this._eventsCount===0)return S;for(w in k=this._events)r.call(k,w)&&S.push(i?w.slice(1):w);return Object.getOwnPropertySymbols?S.concat(Object.getOwnPropertySymbols(k)):S},g.prototype.listeners=function(S){var k=i?i+S:S,w=this._events[k];if(!w)return[];if(w.fn)return[w.fn];for(var N=0,P=w.length,j=new Array(P);N<P;N++)j[N]=w[N].fn;return j},g.prototype.listenerCount=function(S){var k=i?i+S:S,w=this._events[k];return w?w.fn?1:w.length:0},g.prototype.emit=function(S,k,w,N,P,j){var J=i?i+S:S;if(!this._events[J])return!1;var X=this._events[J],G=arguments.length,ee,xe;if(X.fn){switch(X.once&&this.removeListener(S,X.fn,void 0,!0),G){case 1:return X.fn.call(X.context),!0;case 2:return X.fn.call(X.context,k),!0;case 3:return X.fn.call(X.context,k,w),!0;case 4:return X.fn.call(X.context,k,w,N),!0;case 5:return X.fn.call(X.context,k,w,N,P),!0;case 6:return X.fn.call(X.context,k,w,N,P,j),!0}for(xe=1,ee=new Array(G-1);xe<G;xe++)ee[xe-1]=arguments[xe];X.fn.apply(X.context,ee)}else{var ue=X.length,fe;for(xe=0;xe<ue;xe++)switch(X[xe].once&&this.removeListener(S,X[xe].fn,void 0,!0),G){case 1:X[xe].fn.call(X[xe].context);break;case 2:X[xe].fn.call(X[xe].context,k);break;case 3:X[xe].fn.call(X[xe].context,k,w);break;case 4:X[xe].fn.call(X[xe].context,k,w,N);break;default:if(!ee)for(fe=1,ee=new Array(G-1);fe<G;fe++)ee[fe-1]=arguments[fe];X[xe].fn.apply(X[xe].context,ee)}}return!0},g.prototype.on=function(S,k,w){return d(this,S,k,w,!1)},g.prototype.once=function(S,k,w){return d(this,S,k,w,!0)},g.prototype.removeListener=function(S,k,w,N){var P=i?i+S:S;if(!this._events[P])return this;if(!k)return _(this,P),this;var j=this._events[P];if(j.fn)j.fn===k&&(!N||j.once)&&(!w||j.context===w)&&_(this,P);else{for(var J=0,X=[],G=j.length;J<G;J++)(j[J].fn!==k||N&&!j[J].once||w&&j[J].context!==w)&&X.push(j[J]);X.length?this._events[P]=X.length===1?X[0]:X:_(this,P)}return this},g.prototype.removeAllListeners=function(S){var k;return S?(k=i?i+S:S,this._events[k]&&_(this,k)):(this._events=new a,this._eventsCount=0),this},g.prototype.off=g.prototype.removeListener,g.prototype.addListener=g.prototype.on,g.prefixed=i,g.EventEmitter=g,t.exports=g})(ERe)),ERe.exports}var Dhn=Ihn();const X1e=Fkt(Dhn),Phn=Math.PI*2,Nhn=180/Math.PI,Ohn=Math.PI/180;class rI{constructor(r=0,i=0){this.x=0,this.y=0,this.x=r,this.y=i}clone(){return new rI(this.x,this.y)}copyFrom(r){return this.set(r.x,r.y),this}copyTo(r){return r.set(this.x,this.y),r}equals(r){return r.x===this.x&&r.y===this.y}set(r=0,i=r){return this.x=r,this.y=i,this}toString(){return`[pixi.js/math:Point x=${this.x} y=${this.y}]`}static get shared(){return TRe.x=0,TRe.y=0,TRe}}const TRe=new rI;class Lm{constructor(r=1,i=0,a=0,l=1,d=0,_=0){this.array=null,this.a=r,this.b=i,this.c=a,this.d=l,this.tx=d,this.ty=_}fromArray(r){this.a=r[0],this.b=r[1],this.c=r[3],this.d=r[4],this.tx=r[2],this.ty=r[5]}set(r,i,a,l,d,_){return this.a=r,this.b=i,this.c=a,this.d=l,this.tx=d,this.ty=_,this}toArray(r,i){this.array||(this.array=new Float32Array(9));const a=i||this.array;return r?(a[0]=this.a,a[1]=this.b,a[2]=0,a[3]=this.c,a[4]=this.d,a[5]=0,a[6]=this.tx,a[7]=this.ty,a[8]=1):(a[0]=this.a,a[1]=this.c,a[2]=this.tx,a[3]=this.b,a[4]=this.d,a[5]=this.ty,a[6]=0,a[7]=0,a[8]=1),a}apply(r,i){i=i||new rI;const a=r.x,l=r.y;return i.x=this.a*a+this.c*l+this.tx,i.y=this.b*a+this.d*l+this.ty,i}applyInverse(r,i){i=i||new rI;const a=this.a,l=this.b,d=this.c,_=this.d,g=this.tx,b=this.ty,S=1/(a*_+d*-l),k=r.x,w=r.y;return i.x=_*S*k+-d*S*w+(b*d-g*_)*S,i.y=a*S*w+-l*S*k+(-b*a+g*l)*S,i}translate(r,i){return this.tx+=r,this.ty+=i,this}scale(r,i){return this.a*=r,this.d*=i,this.c*=r,this.b*=i,this.tx*=r,this.ty*=i,this}rotate(r){const i=Math.cos(r),a=Math.sin(r),l=this.a,d=this.c,_=this.tx;return this.a=l*i-this.b*a,this.b=l*a+this.b*i,this.c=d*i-this.d*a,this.d=d*a+this.d*i,this.tx=_*i-this.ty*a,this.ty=_*a+this.ty*i,this}append(r){const i=this.a,a=this.b,l=this.c,d=this.d;return this.a=r.a*i+r.b*l,this.b=r.a*a+r.b*d,this.c=r.c*i+r.d*l,this.d=r.c*a+r.d*d,this.tx=r.tx*i+r.ty*l+this.tx,this.ty=r.tx*a+r.ty*d+this.ty,this}appendFrom(r,i){const a=r.a,l=r.b,d=r.c,_=r.d,g=r.tx,b=r.ty,S=i.a,k=i.b,w=i.c,N=i.d;return this.a=a*S+l*w,this.b=a*k+l*N,this.c=d*S+_*w,this.d=d*k+_*N,this.tx=g*S+b*w+i.tx,this.ty=g*k+b*N+i.ty,this}setTransform(r,i,a,l,d,_,g,b,S){return this.a=Math.cos(g+S)*d,this.b=Math.sin(g+S)*d,this.c=-Math.sin(g-b)*_,this.d=Math.cos(g-b)*_,this.tx=r-(a*this.a+l*this.c),this.ty=i-(a*this.b+l*this.d),this}prepend(r){const i=this.tx;if(r.a!==1||r.b!==0||r.c!==0||r.d!==1){const a=this.a,l=this.c;this.a=a*r.a+this.b*r.c,this.b=a*r.b+this.b*r.d,this.c=l*r.a+this.d*r.c,this.d=l*r.b+this.d*r.d}return this.tx=i*r.a+this.ty*r.c+r.tx,this.ty=i*r.b+this.ty*r.d+r.ty,this}decompose(r){const i=this.a,a=this.b,l=this.c,d=this.d,_=r.pivot,g=-Math.atan2(-l,d),b=Math.atan2(a,i),S=Math.abs(g+b);return S<1e-5||Math.abs(Phn-S)<1e-5?(r.rotation=b,r.skew.x=r.skew.y=0):(r.rotation=0,r.skew.x=g,r.skew.y=b),r.scale.x=Math.sqrt(i*i+a*a),r.scale.y=Math.sqrt(l*l+d*d),r.position.x=this.tx+(_.x*i+_.y*l),r.position.y=this.ty+(_.x*a+_.y*d),r}invert(){const r=this.a,i=this.b,a=this.c,l=this.d,d=this.tx,_=r*l-i*a;return this.a=l/_,this.b=-i/_,this.c=-a/_,this.d=r/_,this.tx=(a*this.ty-l*d)/_,this.ty=-(r*this.ty-i*d)/_,this}isIdentity(){return this.a===1&&this.b===0&&this.c===0&&this.d===1&&this.tx===0&&this.ty===0}identity(){return this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this}clone(){const r=new Lm;return r.a=this.a,r.b=this.b,r.c=this.c,r.d=this.d,r.tx=this.tx,r.ty=this.ty,r}copyTo(r){return r.a=this.a,r.b=this.b,r.c=this.c,r.d=this.d,r.tx=this.tx,r.ty=this.ty,r}copyFrom(r){return this.a=r.a,this.b=r.b,this.c=r.c,this.d=r.d,this.tx=r.tx,this.ty=r.ty,this}equals(r){return r.a===this.a&&r.b===this.b&&r.c===this.c&&r.d===this.d&&r.tx===this.tx&&r.ty===this.ty}toString(){return`[pixi.js:Matrix a=${this.a} b=${this.b} c=${this.c} d=${this.d} tx=${this.tx} ty=${this.ty}]`}static get IDENTITY(){return Rhn.identity()}static get shared(){return Fhn.identity()}}const Fhn=new Lm,Rhn=new Lm,Z7=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],eR=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],tR=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],rR=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],R$e=[],ZWt=[],d_e=Math.sign;function Mhn(){for(let t=0;t<16;t++){const r=[];R$e.push(r);for(let i=0;i<16;i++){const a=d_e(Z7[t]*Z7[i]+tR[t]*eR[i]),l=d_e(eR[t]*Z7[i]+rR[t]*eR[i]),d=d_e(Z7[t]*tR[i]+tR[t]*rR[i]),_=d_e(eR[t]*tR[i]+rR[t]*rR[i]);for(let g=0;g<16;g++)if(Z7[g]===a&&eR[g]===l&&tR[g]===d&&rR[g]===_){r.push(g);break}}}for(let t=0;t<16;t++){const r=new Lm;r.set(Z7[t],eR[t],tR[t],rR[t],0,0),ZWt.push(r)}}Mhn();const T_={E:0,SE:1,S:2,SW:3,W:4,NW:5,N:6,NE:7,MIRROR_VERTICAL:8,MAIN_DIAGONAL:10,MIRROR_HORIZONTAL:12,REVERSE_DIAGONAL:14,uX:t=>Z7[t],uY:t=>eR[t],vX:t=>tR[t],vY:t=>rR[t],inv:t=>t&8?t&15:-t&7,add:(t,r)=>R$e[t][r],sub:(t,r)=>R$e[t][T_.inv(r)],rotate180:t=>t^4,isVertical:t=>(t&3)===2,byDirection:(t,r)=>Math.abs(t)*2<=Math.abs(r)?r>=0?T_.S:T_.N:Math.abs(r)*2<=Math.abs(t)?t>0?T_.E:T_.W:r>0?t>0?T_.SE:T_.SW:t>0?T_.NE:T_.NW,matrixAppendRotationInv:(t,r,i=0,a=0,l=0,d=0)=>{const _=ZWt[T_.inv(r)],g=_.a,b=_.b,S=_.c,k=_.d,w=i-Math.min(0,g*l,S*d,g*l+S*d),N=a-Math.min(0,b*l,k*d,b*l+k*d),P=t.a,j=t.b,J=t.c,X=t.d;t.a=g*P+b*J,t.b=g*j+b*X,t.c=S*P+k*J,t.d=S*j+k*X,t.tx=w*P+N*J+t.tx,t.ty=w*j+N*X+t.ty},transformRectCoords:(t,r,i,a)=>{const{x:l,y:d,width:_,height:g}=t,{x:b,y:S,width:k,height:w}=r;return i===T_.E?(a.set(l+b,d+S,_,g),a):i===T_.S?a.set(k-d-g+b,l+S,g,_):i===T_.W?a.set(k-l-_+b,w-d-g+S,_,g):i===T_.N?a.set(d+b,w-l-_+S,g,_):a.set(l+b,d+S,_,g)}},p_e=[new rI,new rI,new rI,new rI];class nI{constructor(r=0,i=0,a=0,l=0){this.type="rectangle",this.x=Number(r),this.y=Number(i),this.width=Number(a),this.height=Number(l)}get left(){return this.x}get right(){return this.x+this.width}get top(){return this.y}get bottom(){return this.y+this.height}isEmpty(){return this.left===this.right||this.top===this.bottom}static get EMPTY(){return new nI(0,0,0,0)}clone(){return new nI(this.x,this.y,this.width,this.height)}copyFromBounds(r){return this.x=r.minX,this.y=r.minY,this.width=r.maxX-r.minX,this.height=r.maxY-r.minY,this}copyFrom(r){return this.x=r.x,this.y=r.y,this.width=r.width,this.height=r.height,this}copyTo(r){return r.copyFrom(this),r}contains(r,i){return this.width<=0||this.height<=0?!1:r>=this.x&&r<this.x+this.width&&i>=this.y&&i<this.y+this.height}strokeContains(r,i,a,l=.5){const{width:d,height:_}=this;if(d<=0||_<=0)return!1;const g=this.x,b=this.y,S=a*(1-l),k=a-S,w=g-S,N=g+d+S,P=b-S,j=b+_+S,J=g+k,X=g+d-k,G=b+k,ee=b+_-k;return r>=w&&r<=N&&i>=P&&i<=j&&!(r>J&&r<X&&i>G&&i<ee)}intersects(r,i){if(!i){const ge=this.x<r.x?r.x:this.x;if((this.right>r.right?r.right:this.right)<=ge)return!1;const tt=this.y<r.y?r.y:this.y;return(this.bottom>r.bottom?r.bottom:this.bottom)>tt}const a=this.left,l=this.right,d=this.top,_=this.bottom;if(l<=a||_<=d)return!1;const g=p_e[0].set(r.left,r.top),b=p_e[1].set(r.left,r.bottom),S=p_e[2].set(r.right,r.top),k=p_e[3].set(r.right,r.bottom);if(S.x<=g.x||b.y<=g.y)return!1;const w=Math.sign(i.a*i.d-i.b*i.c);if(w===0||(i.apply(g,g),i.apply(b,b),i.apply(S,S),i.apply(k,k),Math.max(g.x,b.x,S.x,k.x)<=a||Math.min(g.x,b.x,S.x,k.x)>=l||Math.max(g.y,b.y,S.y,k.y)<=d||Math.min(g.y,b.y,S.y,k.y)>=_))return!1;const N=w*(b.y-g.y),P=w*(g.x-b.x),j=N*a+P*d,J=N*l+P*d,X=N*a+P*_,G=N*l+P*_;if(Math.max(j,J,X,G)<=N*g.x+P*g.y||Math.min(j,J,X,G)>=N*k.x+P*k.y)return!1;const ee=w*(g.y-S.y),xe=w*(S.x-g.x),ue=ee*a+xe*d,fe=ee*l+xe*d,se=ee*a+xe*_,de=ee*l+xe*_;return!(Math.max(ue,fe,se,de)<=ee*g.x+xe*g.y||Math.min(ue,fe,se,de)>=ee*k.x+xe*k.y)}pad(r=0,i=r){return this.x-=r,this.y-=i,this.width+=r*2,this.height+=i*2,this}fit(r){const i=Math.max(this.x,r.x),a=Math.min(this.x+this.width,r.x+r.width),l=Math.max(this.y,r.y),d=Math.min(this.y+this.height,r.y+r.height);return this.x=i,this.width=Math.max(a-i,0),this.y=l,this.height=Math.max(d-l,0),this}ceil(r=1,i=.001){const a=Math.ceil((this.x+this.width-i)*r)/r,l=Math.ceil((this.y+this.height-i)*r)/r;return this.x=Math.floor((this.x+i)*r)/r,this.y=Math.floor((this.y+i)*r)/r,this.width=a-this.x,this.height=l-this.y,this}scale(r,i=r){return this.x*=r,this.y*=i,this.width*=r,this.height*=i,this}enlarge(r){const i=Math.min(this.x,r.x),a=Math.max(this.x+this.width,r.x+r.width),l=Math.min(this.y,r.y),d=Math.max(this.y+this.height,r.y+r.height);return this.x=i,this.width=a-i,this.y=l,this.height=d-l,this}getBounds(r){return r||(r=new nI),r.copyFrom(this),r}containsRect(r){if(this.width<=0||this.height<=0)return!1;const i=r.x,a=r.y,l=r.x+r.width,d=r.y+r.height;return i>=this.x&&i<this.x+this.width&&a>=this.y&&a<this.y+this.height&&l>=this.x&&l<this.x+this.width&&d>=this.y&&d<this.y+this.height}set(r,i,a,l){return this.x=r,this.y=i,this.width=a,this.height=l,this}toString(){return`[pixi.js/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`}}const kRe={default:-1};function o8(t="default"){return kRe[t]===void 0&&(kRe[t]=-1),++kRe[t]}const xCt=new Set,Hz="8.0.0",wq={quiet:!1,noColor:!1},hI=((t,r,i=3)=>{if(wq.quiet||xCt.has(r))return;let a=new Error().stack;const l=`${r}
|
|
1600
1600
|
Deprecated since v${t}`,d=typeof console.groupCollapsed=="function"&&!wq.noColor;typeof a>"u"?console.warn("PixiJS Deprecation Warning: ",l):(a=a.split(`
|
|
1601
1601
|
`).splice(i).join(`
|
|
1602
1602
|
`),d?(console.groupCollapsed("%cPixiJS Deprecation Warning: %c%s","color:#614108;background:#fffbe6","font-weight:normal;color:#614108;background:#fffbe6",l),console.warn(a),console.groupEnd()):(console.warn("PixiJS Deprecation Warning: ",l),console.warn(a))),xCt.add(r)});Object.defineProperties(hI,{quiet:{get:()=>wq.quiet,set:t=>{wq.quiet=t},enumerable:!0,configurable:!1},noColor:{get:()=>wq.noColor,set:t=>{wq.noColor=t},enumerable:!0,configurable:!1}});const eHt=()=>{};function wCt(t){return t+=t===0?1:0,--t,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t+1}function CCt(t){return!(t&t-1)&&!!t}function Lhn(t){const r={};for(const i in t)t[i]!==void 0&&(r[i]=t[i]);return r}const ECt=Object.create(null);function jhn(t){const r=ECt[t];return r===void 0&&(ECt[t]=o8("resource")),r}const tHt=class rHt extends X1e{constructor(r={}){super(),this._resourceType="textureSampler",this._touched=0,this._maxAnisotropy=1,this.destroyed=!1,r={...rHt.defaultOptions,...r},this.addressMode=r.addressMode,this.addressModeU=r.addressModeU??this.addressModeU,this.addressModeV=r.addressModeV??this.addressModeV,this.addressModeW=r.addressModeW??this.addressModeW,this.scaleMode=r.scaleMode,this.magFilter=r.magFilter??this.magFilter,this.minFilter=r.minFilter??this.minFilter,this.mipmapFilter=r.mipmapFilter??this.mipmapFilter,this.lodMinClamp=r.lodMinClamp,this.lodMaxClamp=r.lodMaxClamp,this.compare=r.compare,this.maxAnisotropy=r.maxAnisotropy??1}set addressMode(r){this.addressModeU=r,this.addressModeV=r,this.addressModeW=r}get addressMode(){return this.addressModeU}set wrapMode(r){hI(Hz,"TextureStyle.wrapMode is now TextureStyle.addressMode"),this.addressMode=r}get wrapMode(){return this.addressMode}set scaleMode(r){this.magFilter=r,this.minFilter=r,this.mipmapFilter=r}get scaleMode(){return this.magFilter}set maxAnisotropy(r){this._maxAnisotropy=Math.min(r,16),this._maxAnisotropy>1&&(this.scaleMode="linear")}get maxAnisotropy(){return this._maxAnisotropy}get _resourceId(){return this._sharedResourceId||this._generateResourceId()}update(){this._sharedResourceId=null,this.emit("change",this)}_generateResourceId(){const r=`${this.addressModeU}-${this.addressModeV}-${this.addressModeW}-${this.magFilter}-${this.minFilter}-${this.mipmapFilter}-${this.lodMinClamp}-${this.lodMaxClamp}-${this.compare}-${this._maxAnisotropy}`;return this._sharedResourceId=jhn(r),this._resourceId}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this.removeAllListeners()}};tHt.defaultOptions={addressMode:"clamp-to-edge",scaleMode:"linear"};let nHt=tHt;const iHt=class sHt extends X1e{constructor(r={}){super(),this.options=r,this._gpuData=Object.create(null),this._gcLastUsed=-1,this.uid=o8("textureSource"),this._resourceType="textureSource",this._resourceId=o8("resource"),this.uploadMethodId="unknown",this._resolution=1,this.pixelWidth=1,this.pixelHeight=1,this.width=1,this.height=1,this.sampleCount=1,this.mipLevelCount=1,this.autoGenerateMipmaps=!1,this.format="rgba8unorm",this.dimension="2d",this.viewDimension="2d",this.arrayLayerCount=1,this.antialias=!1,this.transient=!1,this._touched=0,this._batchTick=-1,this._textureBindLocation=-1,r={...sHt.defaultOptions,...r},this.label=r.label??"",this.resource=r.resource,this.autoGarbageCollect=r.autoGarbageCollect,this._resolution=r.resolution,r.width?this.pixelWidth=r.width*this._resolution:this.pixelWidth=this.resource?this.resourceWidth??1:1,r.height?this.pixelHeight=r.height*this._resolution:this.pixelHeight=this.resource?this.resourceHeight??1:1,this.width=this.pixelWidth/this._resolution,this.height=this.pixelHeight/this._resolution,this.format=r.format,this.dimension=r.dimensions,this.viewDimension=r.viewDimension??r.dimensions,this.arrayLayerCount=r.arrayLayerCount,this.mipLevelCount=r.mipLevelCount,this.autoGenerateMipmaps=r.autoGenerateMipmaps,this.sampleCount=r.sampleCount,this.antialias=r.antialias,this.transient=r.transient??!1,this.alphaMode=r.alphaMode,this.style=new nHt(Lhn(r)),this.destroyed=!1,this._refreshPOT()}get source(){return this}get style(){return this._style}set style(r){this.style!==r&&(this._style?.off("change",this._onStyleChange,this),this._style=r,this._style?.on("change",this._onStyleChange,this),this._onStyleChange())}set maxAnisotropy(r){this._style.maxAnisotropy=r}get maxAnisotropy(){return this._style.maxAnisotropy}get addressMode(){return this._style.addressMode}set addressMode(r){this._style.addressMode=r}get repeatMode(){return this._style.addressMode}set repeatMode(r){this._style.addressMode=r}get magFilter(){return this._style.magFilter}set magFilter(r){this._style.magFilter=r}get minFilter(){return this._style.minFilter}set minFilter(r){this._style.minFilter=r}get mipmapFilter(){return this._style.mipmapFilter}set mipmapFilter(r){this._style.mipmapFilter=r}get lodMinClamp(){return this._style.lodMinClamp}set lodMinClamp(r){this._style.lodMinClamp=r}get lodMaxClamp(){return this._style.lodMaxClamp}set lodMaxClamp(r){this._style.lodMaxClamp=r}_onStyleChange(){this.emit("styleChange",this)}update(){if(this.resource){const r=this._resolution;if(this.resize(this.resourceWidth/r,this.resourceHeight/r))return}this.emit("update",this)}destroy(){this.destroyed=!0,this.unload(),this.emit("destroy",this),this._style&&(this._style.destroy(),this._style=null),this.uploadMethodId=null,this.resource=null,this.removeAllListeners()}unload(){this._resourceId=o8("resource"),this.emit("change",this),this.emit("unload",this);for(const r in this._gpuData)this._gpuData[r]?.destroy?.();this._gpuData=Object.create(null)}get resourceWidth(){const{resource:r}=this;return r.naturalWidth||r.videoWidth||r.displayWidth||r.width}get resourceHeight(){const{resource:r}=this;return r.naturalHeight||r.videoHeight||r.displayHeight||r.height}get resolution(){return this._resolution}set resolution(r){this._resolution!==r&&(this._resolution=r,this.width=this.pixelWidth/r,this.height=this.pixelHeight/r)}resize(r,i,a){a||(a=this._resolution),r||(r=this.width),i||(i=this.height);const l=Math.round(r*a),d=Math.round(i*a);return this.width=l/a,this.height=d/a,this._resolution=a,this.pixelWidth===l&&this.pixelHeight===d?!1:(this._refreshPOT(),this.pixelWidth=l,this.pixelHeight=d,this.emit("resize",this),this._resourceId=o8("resource"),this.emit("change",this),!0)}updateMipmaps(){this.autoGenerateMipmaps&&this.mipLevelCount>1&&this.emit("updateMipmaps",this)}set wrapMode(r){this._style.wrapMode=r}get wrapMode(){return this._style.wrapMode}set scaleMode(r){this._style.scaleMode=r}get scaleMode(){return this._style.scaleMode}_refreshPOT(){this.isPowerOfTwo=CCt(this.pixelWidth)&&CCt(this.pixelHeight)}static test(r){throw new Error("Unimplemented")}};iHt.defaultOptions={resolution:1,format:"bgra8unorm",alphaMode:"premultiply-alpha-on-upload",dimensions:"2d",viewDimension:"2d",arrayLayerCount:1,mipLevelCount:1,autoGenerateMipmaps:!1,sampleCount:1,antialias:!1,autoGarbageCollect:!1};let FE=iHt;class bQe extends FE{constructor(r){const i=r.resource||new Float32Array(r.width*r.height*4);let a=r.format;a||(i instanceof Float32Array?a="rgba32float":i instanceof Int32Array||i instanceof Uint32Array?a="rgba32uint":i instanceof Int16Array||i instanceof Uint16Array?a="rgba16uint":(i instanceof Int8Array,a="bgra8unorm")),super({...r,resource:i,format:a}),this.uploadMethodId="buffer"}static test(r){return r instanceof Int8Array||r instanceof Uint8Array||r instanceof Uint8ClampedArray||r instanceof Int16Array||r instanceof Uint16Array||r instanceof Int32Array||r instanceof Uint32Array||r instanceof Float32Array}}bQe.extension=Ab.TextureSource;const TCt=new Lm;class Bhn{constructor(r,i){this.mapCoord=new Lm,this.uClampFrame=new Float32Array(4),this.uClampOffset=new Float32Array(2),this._updateID=0,this.clampOffset=0,typeof i>"u"?this.clampMargin=r.width<10?0:.5:this.clampMargin=i,this.isSimple=!1,this.texture=r}get texture(){return this._texture}set texture(r){this._texture!==r&&(this._texture?.removeListener("update",this.update,this),this._texture=r,this._texture.addListener("update",this.update,this)),this.update()}multiplyUvs(r,i){i===void 0&&(i=r);const a=this.mapCoord;for(let l=0;l<r.length;l+=2){const d=r[l],_=r[l+1];i[l]=d*a.a+_*a.c+a.tx,i[l+1]=d*a.b+_*a.d+a.ty}return i}update(){const r=this._texture;this._updateID++;const i=r.uvs;this.mapCoord.set(i.x1-i.x0,i.y1-i.y0,i.x3-i.x0,i.y3-i.y0,i.x0,i.y0);const a=r.orig,l=r.trim;l&&(TCt.set(a.width/l.width,0,0,a.height/l.height,-l.x/l.width,-l.y/l.height),this.mapCoord.append(TCt));const d=r.source,_=this.uClampFrame,g=this.clampMargin/d._resolution,b=this.clampOffset/d._resolution;return _[0]=(r.frame.x+g+b)/d.width,_[1]=(r.frame.y+g+b)/d.height,_[2]=(r.frame.x+r.frame.width-g+b)/d.width,_[3]=(r.frame.y+r.frame.height-g+b)/d.height,this.uClampOffset[0]=this.clampOffset/d.pixelWidth,this.uClampOffset[1]=this.clampOffset/d.pixelHeight,this.isSimple=r.frame.width===d.width&&r.frame.height===d.height&&r.rotate===0,!0}}class Fy extends X1e{constructor({source:r,label:i,frame:a,orig:l,trim:d,defaultAnchor:_,defaultBorders:g,rotate:b,dynamic:S}={}){if(super(),this.uid=o8("texture"),this.uvs={x0:0,y0:0,x1:0,y1:0,x2:0,y2:0,x3:0,y3:0},this.frame=new nI,this.noFrame=!1,this.dynamic=!1,this.isTexture=!0,this.label=i,this.source=r?.source??new FE,this.noFrame=!a,a)this.frame.copyFrom(a);else{const{width:k,height:w}=this._source;this.frame.width=k,this.frame.height=w}this.orig=l||this.frame,this.trim=d,this.rotate=b??0,this.defaultAnchor=_,this.defaultBorders=g,this.destroyed=!1,this.dynamic=S||!1,this.updateUvs()}set source(r){this._source&&this._source.off("resize",this.update,this),this._source=r,r.on("resize",this.update,this),this.emit("update",this)}get source(){return this._source}get textureMatrix(){return this._textureMatrix||(this._textureMatrix=new Bhn(this)),this._textureMatrix}get width(){return this.orig.width}get height(){return this.orig.height}updateUvs(){const{uvs:r,frame:i}=this,{width:a,height:l}=this._source,d=i.x/a,_=i.y/l,g=i.width/a,b=i.height/l;let S=this.rotate;if(S){const k=g/2,w=b/2,N=d+k,P=_+w;S=T_.add(S,T_.NW),r.x0=N+k*T_.uX(S),r.y0=P+w*T_.uY(S),S=T_.add(S,2),r.x1=N+k*T_.uX(S),r.y1=P+w*T_.uY(S),S=T_.add(S,2),r.x2=N+k*T_.uX(S),r.y2=P+w*T_.uY(S),S=T_.add(S,2),r.x3=N+k*T_.uX(S),r.y3=P+w*T_.uY(S)}else r.x0=d,r.y0=_,r.x1=d+g,r.y1=_,r.x2=d+g,r.y2=_+b,r.x3=d,r.y3=_+b}destroy(r=!1){this._source&&(this._source.off("resize",this.update,this),r&&(this._source.destroy(),this._source=null)),this._textureMatrix=null,this.destroyed=!0,this.emit("destroy",this),this.removeAllListeners()}update(){this.noFrame&&(this.frame.width=this._source.width,this.frame.height=this._source.height),this.updateUvs(),this.emit("update",this)}get baseTexture(){return hI(Hz,"Texture.baseTexture is now Texture.source"),this._source}}Fy.EMPTY=new Fy({label:"EMPTY",source:new FE({label:"EMPTY"})});Fy.EMPTY.destroy=eHt;Fy.WHITE=new Fy({source:new bQe({resource:new Uint8Array([255,255,255,255]),width:1,height:1,alphaMode:"premultiply-alpha-on-upload",label:"WHITE"}),label:"WHITE"});Fy.WHITE.destroy=eHt;function $hn(t,r,i){const{width:a,height:l}=i.orig,d=i.trim;if(d){const _=d.width,g=d.height;t.minX=d.x-r._x*a,t.maxX=t.minX+_,t.minY=d.y-r._y*l,t.maxY=t.minY+g}else t.minX=-r._x*a,t.maxX=t.minX+a,t.minY=-r._y*l,t.maxY=t.minY+l}const kCt=new Lm;class V8{constructor(r=1/0,i=1/0,a=-1/0,l=-1/0){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=kCt,this.minX=r,this.minY=i,this.maxX=a,this.maxY=l}isEmpty(){return this.minX>this.maxX||this.minY>this.maxY}get rectangle(){this._rectangle||(this._rectangle=new nI);const r=this._rectangle;return this.minX>this.maxX||this.minY>this.maxY?(r.x=0,r.y=0,r.width=0,r.height=0):r.copyFromBounds(this),r}clear(){return this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=kCt,this}set(r,i,a,l){this.minX=r,this.minY=i,this.maxX=a,this.maxY=l}addFrame(r,i,a,l,d){d||(d=this.matrix);const _=d.a,g=d.b,b=d.c,S=d.d,k=d.tx,w=d.ty;let N=this.minX,P=this.minY,j=this.maxX,J=this.maxY,X=_*r+b*i+k,G=g*r+S*i+w;X<N&&(N=X),G<P&&(P=G),X>j&&(j=X),G>J&&(J=G),X=_*a+b*i+k,G=g*a+S*i+w,X<N&&(N=X),G<P&&(P=G),X>j&&(j=X),G>J&&(J=G),X=_*r+b*l+k,G=g*r+S*l+w,X<N&&(N=X),G<P&&(P=G),X>j&&(j=X),G>J&&(J=G),X=_*a+b*l+k,G=g*a+S*l+w,X<N&&(N=X),G<P&&(P=G),X>j&&(j=X),G>J&&(J=G),this.minX=N,this.minY=P,this.maxX=j,this.maxY=J}addRect(r,i){this.addFrame(r.x,r.y,r.x+r.width,r.y+r.height,i)}addBounds(r,i){this.addFrame(r.minX,r.minY,r.maxX,r.maxY,i)}addBoundsMask(r){this.minX=this.minX>r.minX?this.minX:r.minX,this.minY=this.minY>r.minY?this.minY:r.minY,this.maxX=this.maxX<r.maxX?this.maxX:r.maxX,this.maxY=this.maxY<r.maxY?this.maxY:r.maxY}applyMatrix(r){const i=this.minX,a=this.minY,l=this.maxX,d=this.maxY,{a:_,b:g,c:b,d:S,tx:k,ty:w}=r;let N=_*i+b*a+k,P=g*i+S*a+w;this.minX=N,this.minY=P,this.maxX=N,this.maxY=P,N=_*l+b*a+k,P=g*l+S*a+w,this.minX=N<this.minX?N:this.minX,this.minY=P<this.minY?P:this.minY,this.maxX=N>this.maxX?N:this.maxX,this.maxY=P>this.maxY?P:this.maxY,N=_*i+b*d+k,P=g*i+S*d+w,this.minX=N<this.minX?N:this.minX,this.minY=P<this.minY?P:this.minY,this.maxX=N>this.maxX?N:this.maxX,this.maxY=P>this.maxY?P:this.maxY,N=_*l+b*d+k,P=g*l+S*d+w,this.minX=N<this.minX?N:this.minX,this.minY=P<this.minY?P:this.minY,this.maxX=N>this.maxX?N:this.maxX,this.maxY=P>this.maxY?P:this.maxY}fit(r){return this.minX<r.left&&(this.minX=r.left),this.maxX>r.right&&(this.maxX=r.right),this.minY<r.top&&(this.minY=r.top),this.maxY>r.bottom&&(this.maxY=r.bottom),this}fitBounds(r,i,a,l){return this.minX<r&&(this.minX=r),this.maxX>i&&(this.maxX=i),this.minY<a&&(this.minY=a),this.maxY>l&&(this.maxY=l),this}pad(r,i=r){return this.minX-=r,this.maxX+=r,this.minY-=i,this.maxY+=i,this}ceil(){return this.minX=Math.floor(this.minX),this.minY=Math.floor(this.minY),this.maxX=Math.ceil(this.maxX),this.maxY=Math.ceil(this.maxY),this}clone(){return new V8(this.minX,this.minY,this.maxX,this.maxY)}scale(r,i=r){return this.minX*=r,this.minY*=i,this.maxX*=r,this.maxY*=i,this}get x(){return this.minX}set x(r){const i=this.maxX-this.minX;this.minX=r,this.maxX=r+i}get y(){return this.minY}set y(r){const i=this.maxY-this.minY;this.minY=r,this.maxY=r+i}get width(){return this.maxX-this.minX}set width(r){this.maxX=this.minX+r}get height(){return this.maxY-this.minY}set height(r){this.maxY=this.minY+r}get left(){return this.minX}get right(){return this.maxX}get top(){return this.minY}get bottom(){return this.maxY}get isPositive(){return this.maxX-this.minX>0&&this.maxY-this.minY>0}get isValid(){return this.minX+this.minY!==1/0}addVertexData(r,i,a,l){let d=this.minX,_=this.minY,g=this.maxX,b=this.maxY;l||(l=this.matrix);const S=l.a,k=l.b,w=l.c,N=l.d,P=l.tx,j=l.ty;for(let J=i;J<a;J+=2){const X=r[J],G=r[J+1],ee=S*X+w*G+P,xe=k*X+N*G+j;d=ee<d?ee:d,_=xe<_?xe:_,g=ee>g?ee:g,b=xe>b?xe:b}this.minX=d,this.minY=_,this.maxX=g,this.maxY=b}containsPoint(r,i){return this.minX<=r&&this.minY<=i&&this.maxX>=r&&this.maxY>=i}toString(){return`[pixi.js:Bounds minX=${this.minX} minY=${this.minY} maxX=${this.maxX} maxY=${this.maxY} width=${this.width} height=${this.height}]`}copyFrom(r){return this.minX=r.minX,this.minY=r.minY,this.maxX=r.maxX,this.maxY=r.maxY,this}}var qhn={grad:.9,turn:360,rad:360/(2*Math.PI)},Q3=function(t){return typeof t=="string"?t.length>0:typeof t=="number"},T0=function(t,r,i){return r===void 0&&(r=0),i===void 0&&(i=Math.pow(10,r)),Math.round(i*t)/i+0},vw=function(t,r,i){return r===void 0&&(r=0),i===void 0&&(i=1),t>i?i:t>r?t:r},oHt=function(t){return(t=isFinite(t)?t%360:0)>0?t:t+360},ICt=function(t){return{r:vw(t.r,0,255),g:vw(t.g,0,255),b:vw(t.b,0,255),a:vw(t.a)}},IRe=function(t){return{r:T0(t.r),g:T0(t.g),b:T0(t.b),a:T0(t.a,3)}},zhn=/^#([0-9a-f]{3,8})$/i,__e=function(t){var r=t.toString(16);return r.length<2?"0"+r:r},aHt=function(t){var r=t.r,i=t.g,a=t.b,l=t.a,d=Math.max(r,i,a),_=d-Math.min(r,i,a),g=_?d===r?(i-a)/_:d===i?2+(a-r)/_:4+(r-i)/_:0;return{h:60*(g<0?g+6:g),s:d?_/d*100:0,v:d/255*100,a:l}},cHt=function(t){var r=t.h,i=t.s,a=t.v,l=t.a;r=r/360*6,i/=100,a/=100;var d=Math.floor(r),_=a*(1-i),g=a*(1-(r-d)*i),b=a*(1-(1-r+d)*i),S=d%6;return{r:255*[a,g,_,_,b,a][S],g:255*[b,a,a,g,_,_][S],b:255*[_,_,b,a,a,g][S],a:l}},DCt=function(t){return{h:oHt(t.h),s:vw(t.s,0,100),l:vw(t.l,0,100),a:vw(t.a)}},PCt=function(t){return{h:T0(t.h),s:T0(t.s),l:T0(t.l),a:T0(t.a,3)}},NCt=function(t){return cHt((i=(r=t).s,{h:r.h,s:(i*=((a=r.l)<50?a:100-a)/100)>0?2*i/(a+i)*100:0,v:a+i,a:r.a}));var r,i,a},GX=function(t){return{h:(r=aHt(t)).h,s:(l=(200-(i=r.s))*(a=r.v)/100)>0&&l<200?i*a/100/(l<=100?l:200-l)*100:0,l:l/2,a:r.a};var r,i,a,l},Uhn=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Vhn=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Jhn=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Whn=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,M$e={string:[[function(t){var r=zhn.exec(t);return r?(t=r[1]).length<=4?{r:parseInt(t[0]+t[0],16),g:parseInt(t[1]+t[1],16),b:parseInt(t[2]+t[2],16),a:t.length===4?T0(parseInt(t[3]+t[3],16)/255,2):1}:t.length===6||t.length===8?{r:parseInt(t.substr(0,2),16),g:parseInt(t.substr(2,2),16),b:parseInt(t.substr(4,2),16),a:t.length===8?T0(parseInt(t.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(t){var r=Jhn.exec(t)||Whn.exec(t);return r?r[2]!==r[4]||r[4]!==r[6]?null:ICt({r:Number(r[1])/(r[2]?100/255:1),g:Number(r[3])/(r[4]?100/255:1),b:Number(r[5])/(r[6]?100/255:1),a:r[7]===void 0?1:Number(r[7])/(r[8]?100:1)}):null},"rgb"],[function(t){var r=Uhn.exec(t)||Vhn.exec(t);if(!r)return null;var i,a,l=DCt({h:(i=r[1],a=r[2],a===void 0&&(a="deg"),Number(i)*(qhn[a]||1)),s:Number(r[3]),l:Number(r[4]),a:r[5]===void 0?1:Number(r[5])/(r[6]?100:1)});return NCt(l)},"hsl"]],object:[[function(t){var r=t.r,i=t.g,a=t.b,l=t.a,d=l===void 0?1:l;return Q3(r)&&Q3(i)&&Q3(a)?ICt({r:Number(r),g:Number(i),b:Number(a),a:Number(d)}):null},"rgb"],[function(t){var r=t.h,i=t.s,a=t.l,l=t.a,d=l===void 0?1:l;if(!Q3(r)||!Q3(i)||!Q3(a))return null;var _=DCt({h:Number(r),s:Number(i),l:Number(a),a:Number(d)});return NCt(_)},"hsl"],[function(t){var r=t.h,i=t.s,a=t.v,l=t.a,d=l===void 0?1:l;if(!Q3(r)||!Q3(i)||!Q3(a))return null;var _=(function(g){return{h:oHt(g.h),s:vw(g.s,0,100),v:vw(g.v,0,100),a:vw(g.a)}})({h:Number(r),s:Number(i),v:Number(a),a:Number(d)});return cHt(_)},"hsv"]]},OCt=function(t,r){for(var i=0;i<r.length;i++){var a=r[i][0](t);if(a)return[a,r[i][1]]}return[null,void 0]},Hhn=function(t){return typeof t=="string"?OCt(t.trim(),M$e.string):typeof t=="object"&&t!==null?OCt(t,M$e.object):[null,void 0]},DRe=function(t,r){var i=GX(t);return{h:i.h,s:vw(i.s+100*r,0,100),l:i.l,a:i.a}},PRe=function(t){return(299*t.r+587*t.g+114*t.b)/1e3/255},FCt=function(t,r){var i=GX(t);return{h:i.h,s:i.s,l:vw(i.l+100*r,0,100),a:i.a}},L$e=(function(){function t(r){this.parsed=Hhn(r)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return t.prototype.isValid=function(){return this.parsed!==null},t.prototype.brightness=function(){return T0(PRe(this.rgba),2)},t.prototype.isDark=function(){return PRe(this.rgba)<.5},t.prototype.isLight=function(){return PRe(this.rgba)>=.5},t.prototype.toHex=function(){return r=IRe(this.rgba),i=r.r,a=r.g,l=r.b,_=(d=r.a)<1?__e(T0(255*d)):"","#"+__e(i)+__e(a)+__e(l)+_;var r,i,a,l,d,_},t.prototype.toRgb=function(){return IRe(this.rgba)},t.prototype.toRgbString=function(){return r=IRe(this.rgba),i=r.r,a=r.g,l=r.b,(d=r.a)<1?"rgba("+i+", "+a+", "+l+", "+d+")":"rgb("+i+", "+a+", "+l+")";var r,i,a,l,d},t.prototype.toHsl=function(){return PCt(GX(this.rgba))},t.prototype.toHslString=function(){return r=PCt(GX(this.rgba)),i=r.h,a=r.s,l=r.l,(d=r.a)<1?"hsla("+i+", "+a+"%, "+l+"%, "+d+")":"hsl("+i+", "+a+"%, "+l+"%)";var r,i,a,l,d},t.prototype.toHsv=function(){return r=aHt(this.rgba),{h:T0(r.h),s:T0(r.s),v:T0(r.v),a:T0(r.a,3)};var r},t.prototype.invert=function(){return Wk({r:255-(r=this.rgba).r,g:255-r.g,b:255-r.b,a:r.a});var r},t.prototype.saturate=function(r){return r===void 0&&(r=.1),Wk(DRe(this.rgba,r))},t.prototype.desaturate=function(r){return r===void 0&&(r=.1),Wk(DRe(this.rgba,-r))},t.prototype.grayscale=function(){return Wk(DRe(this.rgba,-1))},t.prototype.lighten=function(r){return r===void 0&&(r=.1),Wk(FCt(this.rgba,r))},t.prototype.darken=function(r){return r===void 0&&(r=.1),Wk(FCt(this.rgba,-r))},t.prototype.rotate=function(r){return r===void 0&&(r=15),this.hue(this.hue()+r)},t.prototype.alpha=function(r){return typeof r=="number"?Wk({r:(i=this.rgba).r,g:i.g,b:i.b,a:r}):T0(this.rgba.a,3);var i},t.prototype.hue=function(r){var i=GX(this.rgba);return typeof r=="number"?Wk({h:r,s:i.s,l:i.l,a:i.a}):T0(i.h)},t.prototype.isEqual=function(r){return this.toHex()===Wk(r).toHex()},t})(),Wk=function(t){return t instanceof L$e?t:new L$e(t)},RCt=[],Ghn=function(t){t.forEach(function(r){RCt.indexOf(r)<0&&(r(L$e,M$e),RCt.push(r))})};function Qhn(t,r){var i={white:"#ffffff",bisque:"#ffe4c4",blue:"#0000ff",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",antiquewhite:"#faebd7",aqua:"#00ffff",azure:"#f0ffff",whitesmoke:"#f5f5f5",papayawhip:"#ffefd5",plum:"#dda0dd",blanchedalmond:"#ffebcd",black:"#000000",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",cornsilk:"#fff8dc",cornflowerblue:"#6495ed",burlywood:"#deb887",aquamarine:"#7fffd4",beige:"#f5f5dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkkhaki:"#bdb76b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",peachpuff:"#ffdab9",darkmagenta:"#8b008b",darkred:"#8b0000",darkorchid:"#9932cc",darkorange:"#ff8c00",darkslateblue:"#483d8b",gray:"#808080",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",deeppink:"#ff1493",deepskyblue:"#00bfff",wheat:"#f5deb3",firebrick:"#b22222",floralwhite:"#fffaf0",ghostwhite:"#f8f8ff",darkviolet:"#9400d3",magenta:"#ff00ff",green:"#008000",dodgerblue:"#1e90ff",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",blueviolet:"#8a2be2",forestgreen:"#228b22",lawngreen:"#7cfc00",indianred:"#cd5c5c",indigo:"#4b0082",fuchsia:"#ff00ff",brown:"#a52a2a",maroon:"#800000",mediumblue:"#0000cd",lightcoral:"#f08080",darkturquoise:"#00ced1",lightcyan:"#e0ffff",ivory:"#fffff0",lightyellow:"#ffffe0",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",linen:"#faf0e6",mediumaquamarine:"#66cdaa",lemonchiffon:"#fffacd",lime:"#00ff00",khaki:"#f0e68c",mediumseagreen:"#3cb371",limegreen:"#32cd32",mediumspringgreen:"#00fa9a",lightskyblue:"#87cefa",lightblue:"#add8e6",midnightblue:"#191970",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",mintcream:"#f5fffa",lightslategray:"#778899",lightslategrey:"#778899",navajowhite:"#ffdead",navy:"#000080",mediumvioletred:"#c71585",powderblue:"#b0e0e6",palegoldenrod:"#eee8aa",oldlace:"#fdf5e6",paleturquoise:"#afeeee",mediumturquoise:"#48d1cc",mediumorchid:"#ba55d3",rebeccapurple:"#663399",lightsteelblue:"#b0c4de",mediumslateblue:"#7b68ee",thistle:"#d8bfd8",tan:"#d2b48c",orchid:"#da70d6",mediumpurple:"#9370db",purple:"#800080",pink:"#ffc0cb",skyblue:"#87ceeb",springgreen:"#00ff7f",palegreen:"#98fb98",red:"#ff0000",yellow:"#ffff00",slateblue:"#6a5acd",lavenderblush:"#fff0f5",peru:"#cd853f",palevioletred:"#db7093",violet:"#ee82ee",teal:"#008080",slategray:"#708090",slategrey:"#708090",aliceblue:"#f0f8ff",darkseagreen:"#8fbc8f",darkolivegreen:"#556b2f",greenyellow:"#adff2f",seagreen:"#2e8b57",seashell:"#fff5ee",tomato:"#ff6347",silver:"#c0c0c0",sienna:"#a0522d",lavender:"#e6e6fa",lightgreen:"#90ee90",orange:"#ffa500",orangered:"#ff4500",steelblue:"#4682b4",royalblue:"#4169e1",turquoise:"#40e0d0",yellowgreen:"#9acd32",salmon:"#fa8072",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},a={};for(var l in i)a[i[l]]=l;var d={};t.prototype.toName=function(_){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var g,b,S=a[this.toHex()];if(S)return S;if(_?.closest){var k=this.toRgb(),w=1/0,N="black";if(!d.length)for(var P in i)d[P]=new t(i[P]).toRgb();for(var j in i){var J=(g=k,b=d[j],Math.pow(g.r-b.r,2)+Math.pow(g.g-b.g,2)+Math.pow(g.b-b.b,2));J<w&&(w=J,N=j)}return N}},r.string.push([function(_){var g=_.toLowerCase(),b=g==="transparent"?"#0000":i[g];return b?new t(b).toRgb():null},"name"])}Ghn([Qhn]);const Gz=class dX{constructor(r=16777215){this._value=null,this._components=new Float32Array(4),this._components.fill(1),this._int=16777215,this.value=r}get red(){return this._components[0]}get green(){return this._components[1]}get blue(){return this._components[2]}get alpha(){return this._components[3]}setValue(r){return this.value=r,this}set value(r){if(r instanceof dX)this._value=this._cloneSource(r._value),this._int=r._int,this._components.set(r._components);else{if(r===null)throw new Error("Cannot set Color#value to null");(this._value===null||!this._isSourceEqual(this._value,r))&&(this._value=this._cloneSource(r),this._normalize(this._value))}}get value(){return this._value}_cloneSource(r){return typeof r=="string"||typeof r=="number"||r instanceof Number||r===null?r:Array.isArray(r)||ArrayBuffer.isView(r)?r.slice(0):typeof r=="object"&&r!==null?{...r}:r}_isSourceEqual(r,i){const a=typeof r;if(a!==typeof i)return!1;if(a==="number"||a==="string"||r instanceof Number)return r===i;if(Array.isArray(r)&&Array.isArray(i)||ArrayBuffer.isView(r)&&ArrayBuffer.isView(i))return r.length!==i.length?!1:r.every((d,_)=>d===i[_]);if(r!==null&&i!==null){const d=Object.keys(r),_=Object.keys(i);return d.length!==_.length?!1:d.every(g=>r[g]===i[g])}return r===i}toRgba(){const[r,i,a,l]=this._components;return{r,g:i,b:a,a:l}}toRgb(){const[r,i,a]=this._components;return{r,g:i,b:a}}toRgbaString(){const[r,i,a]=this.toUint8RgbArray();return`rgba(${r},${i},${a},${this.alpha})`}toUint8RgbArray(r){const[i,a,l]=this._components;return this._arrayRgb||(this._arrayRgb=[]),r||(r=this._arrayRgb),r[0]=Math.round(i*255),r[1]=Math.round(a*255),r[2]=Math.round(l*255),r}toArray(r){this._arrayRgba||(this._arrayRgba=[]),r||(r=this._arrayRgba);const[i,a,l,d]=this._components;return r[0]=i,r[1]=a,r[2]=l,r[3]=d,r}toRgbArray(r){this._arrayRgb||(this._arrayRgb=[]),r||(r=this._arrayRgb);const[i,a,l]=this._components;return r[0]=i,r[1]=a,r[2]=l,r}toNumber(){return this._int}toBgrNumber(){const[r,i,a]=this.toUint8RgbArray();return(a<<16)+(i<<8)+r}toLittleEndianNumber(){const r=this._int;return(r>>16)+(r&65280)+((r&255)<<16)}multiply(r){const[i,a,l,d]=dX._temp.setValue(r)._components;return this._components[0]*=i,this._components[1]*=a,this._components[2]*=l,this._components[3]*=d,this._refreshInt(),this._value=null,this}premultiply(r,i=!0){return i&&(this._components[0]*=r,this._components[1]*=r,this._components[2]*=r),this._components[3]=r,this._refreshInt(),this._value=null,this}toPremultiplied(r,i=!0){if(r===1)return(255<<24)+this._int;if(r===0)return i?0:this._int;let a=this._int>>16&255,l=this._int>>8&255,d=this._int&255;return i&&(a=a*r+.5|0,l=l*r+.5|0,d=d*r+.5|0),(r*255<<24)+(a<<16)+(l<<8)+d}toHex(){const r=this._int.toString(16);return`#${"000000".substring(0,6-r.length)+r}`}toHexa(){const i=Math.round(this._components[3]*255).toString(16);return this.toHex()+"00".substring(0,2-i.length)+i}setAlpha(r){return this._components[3]=this._clamp(r),this._value=null,this}_normalize(r){let i,a,l,d;if((typeof r=="number"||r instanceof Number)&&r>=0&&r<=16777215){const _=r;i=(_>>16&255)/255,a=(_>>8&255)/255,l=(_&255)/255,d=1}else if((Array.isArray(r)||r instanceof Float32Array)&&r.length>=3&&r.length<=4)r=this._clamp(r),[i,a,l,d=1]=r;else if((r instanceof Uint8Array||r instanceof Uint8ClampedArray)&&r.length>=3&&r.length<=4)r=this._clamp(r,0,255),[i,a,l,d=255]=r,i/=255,a/=255,l/=255,d/=255;else if(typeof r=="string"||typeof r=="object"){if(typeof r=="string"){const g=dX.HEX_PATTERN.exec(r);g&&(r=`#${g[2]}`)}const _=Wk(r);_.isValid()&&({r:i,g:a,b:l,a:d}=_.rgba,i/=255,a/=255,l/=255)}if(i!==void 0)this._components[0]=i,this._components[1]=a,this._components[2]=l,this._components[3]=d,this._refreshInt();else throw new Error(`Unable to convert color ${r}`)}_refreshInt(){this._clamp(this._components);const[r,i,a]=this._components;this._int=(r*255<<16)+(i*255<<8)+(a*255|0)}_clamp(r,i=0,a=1){return typeof r=="number"?Math.min(Math.max(r,i),a):(r.forEach((l,d)=>{r[d]=Math.min(Math.max(l,i),a)}),r)}static isColorLike(r){return typeof r=="number"||typeof r=="string"||r instanceof Number||r instanceof dX||Array.isArray(r)||r instanceof Uint8Array||r instanceof Uint8ClampedArray||r instanceof Float32Array||r.r!==void 0&&r.g!==void 0&&r.b!==void 0||r.r!==void 0&&r.g!==void 0&&r.b!==void 0&&r.a!==void 0||r.h!==void 0&&r.s!==void 0&&r.l!==void 0||r.h!==void 0&&r.s!==void 0&&r.l!==void 0&&r.a!==void 0||r.h!==void 0&&r.s!==void 0&&r.v!==void 0||r.h!==void 0&&r.s!==void 0&&r.v!==void 0&&r.a!==void 0}};Gz.shared=new Gz;Gz._temp=new Gz;Gz.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let Khn=Gz;const Yhn={cullArea:null,cullable:!1,cullableChildren:!0};let NRe=0;const MCt=500;function b8(...t){NRe!==MCt&&(NRe++,NRe===MCt?console.warn("PixiJS Warning: too many warnings, no more warnings will be reported to the console by PixiJS."):console.warn("PixiJS Warning: ",...t))}const lHt={_registeredResources:new Set,register(t){this._registeredResources.add(t)},unregister(t){this._registeredResources.delete(t)},release(){this._registeredResources.forEach(t=>t.clear())},get registeredCount(){return this._registeredResources.size},isRegistered(t){return this._registeredResources.has(t)},reset(){this._registeredResources.clear()}};class Xhn{constructor(r,i){this._pool=[],this._count=0,this._index=0,this._classType=r,i&&this.prepopulate(i)}prepopulate(r){for(let i=0;i<r;i++)this._pool[this._index++]=new this._classType;this._count+=r}get(r){let i;return this._index>0?i=this._pool[--this._index]:(i=new this._classType,this._count++),i.init?.(r),i}return(r){r.reset?.(),this._pool[this._index++]=r}get totalSize(){return this._count}get totalFree(){return this._index}get totalUsed(){return this._count-this._index}clear(){if(this._pool.length>0&&this._pool[0].destroy)for(let r=0;r<this._index;r++)this._pool[r].destroy();this._pool.length=0,this._count=0,this._index=0}}class Zhn{constructor(){this._poolsByClass=new Map}prepopulate(r,i){this.getPool(r).prepopulate(i)}get(r,i){return this.getPool(r).get(i)}return(r){this.getPool(r.constructor).return(r)}getPool(r){return this._poolsByClass.has(r)||this._poolsByClass.set(r,new Xhn(r)),this._poolsByClass.get(r)}stats(){const r={};return this._poolsByClass.forEach(i=>{const a=r[i._classType.name]?i._classType.name+i._classType.ID:i._classType.name;r[a]={free:i.totalFree,used:i.totalUsed,size:i.totalSize}}),r}clear(){this._poolsByClass.forEach(r=>r.clear()),this._poolsByClass.clear()}}const o9=new Zhn;lHt.register(o9);const egn={get isCachedAsTexture(){return!!this.renderGroup?.isCachedAsTexture},cacheAsTexture(t){typeof t=="boolean"&&t===!1?this.disableRenderGroup():(this.enableRenderGroup(),this.renderGroup.enableCacheAsTexture(t===!0?{}:t))},updateCacheTexture(){this.renderGroup?.updateCacheTexture()},get cacheAsBitmap(){return this.isCachedAsTexture},set cacheAsBitmap(t){hI("v8.6.0","cacheAsBitmap is deprecated, use cacheAsTexture instead."),this.cacheAsTexture(t)}};function tgn(t,r,i){const a=t.length;let l;if(r>=a||i===0)return;i=r+i>a?a-r:i;const d=a-i;for(l=r;l<d;++l)t[l]=t[l+i];t.length=d}const rgn={allowChildren:!0,removeChildren(t=0,r){const i=r??this.children.length,a=i-t,l=[];if(a>0&&a<=i){for(let _=i-1;_>=t;_--){const g=this.children[_];g&&(l.push(g),g.parent=null)}tgn(this.children,t,i);const d=this.renderGroup||this.parentRenderGroup;d&&d.removeChildren(l);for(let _=0;_<l.length;++_){const g=l[_];g.parentRenderLayer?.detach(g),this.emit("childRemoved",g,this,_),l[_].emit("removed",this)}return l.length>0&&this._didViewChangeTick++,l}else if(a===0&&this.children.length===0)return l;throw new RangeError("removeChildren: numeric values are outside the acceptable range.")},removeChildAt(t){const r=this.getChildAt(t);return this.removeChild(r)},getChildAt(t){if(t<0||t>=this.children.length)throw new Error(`getChildAt: Index (${t}) does not exist.`);return this.children[t]},setChildIndex(t,r){if(r<0||r>=this.children.length)throw new Error(`The index ${r} supplied is out of bounds ${this.children.length}`);this.getChildIndex(t),this.addChildAt(t,r)},getChildIndex(t){const r=this.children.indexOf(t);if(r===-1)throw new Error("The supplied Container must be a child of the caller");return r},addChildAt(t,r){this.allowChildren||hI(Hz,"addChildAt: Only Containers will be allowed to add children in v8.0.0");const{children:i}=this;if(r<0||r>i.length)throw new Error(`${t}addChildAt: The index ${r} supplied is out of bounds ${i.length}`);const a=t.parent===this;if(t.parent){const d=t.parent.children.indexOf(t);if(a){if(d===r)return t;t.parent.children.splice(d,1)}else t.removeFromParent()}r===i.length?i.push(t):i.splice(r,0,t),t.parent=this,t.didChange=!0,t._updateFlags=15;const l=this.renderGroup||this.parentRenderGroup;return l&&l.addChild(t),this.sortableChildren&&(this.sortDirty=!0),a||(this.emit("childAdded",t,this,r),t.emit("added",this)),t},swapChildren(t,r){if(t===r)return;const i=this.getChildIndex(t),a=this.getChildIndex(r);this.children[i]=r,this.children[a]=t;const l=this.renderGroup||this.parentRenderGroup;l&&(l.structureDidChange=!0),this._didContainerChangeTick++},removeFromParent(){this.parent?.removeChild(this)},reparentChild(...t){return t.length===1?this.reparentChildAt(t[0],this.children.length):(t.forEach(r=>this.reparentChildAt(r,this.children.length)),t[0])},reparentChildAt(t,r){if(t.parent===this)return this.setChildIndex(t,r),t;const i=t.worldTransform.clone();t.removeFromParent(),this.addChildAt(t,r);const a=this.worldTransform.clone();return a.invert(),i.prepend(a),t.setFromMatrix(i),t},replaceChild(t,r){t.updateLocalTransform(),this.addChildAt(r,this.getChildIndex(t)),r.setFromMatrix(t.localTransform),r.updateLocalTransform(),this.removeChild(t)}},ngn={collectRenderables(t,r,i){this.parentRenderLayer&&this.parentRenderLayer!==i||this.globalDisplayStatus<7||!this.includeInBuild||(this.sortableChildren&&this.sortChildren(),this.isSimple?this.collectRenderablesSimple(t,r,i):this.renderGroup?r.renderPipes.renderGroup.addRenderGroup(this.renderGroup,t):this.collectRenderablesWithEffects(t,r,i))},collectRenderablesSimple(t,r,i){const a=this.children,l=a.length;for(let d=0;d<l;d++)a[d].collectRenderables(t,r,i)},collectRenderablesWithEffects(t,r,i){const{renderPipes:a}=r;for(let l=0;l<this.effects.length;l++){const d=this.effects[l];a[d.pipe].push(d,this,t)}this.collectRenderablesSimple(t,r,i);for(let l=this.effects.length-1;l>=0;l--){const d=this.effects[l];a[d.pipe].pop(d,this,t)}}};class LCt{constructor(){this.pipe="filter",this.priority=1}destroy(){for(let r=0;r<this.filters.length;r++)this.filters[r].destroy();this.filters=null,this.filterArea=null}}class ign{constructor(){this._effectClasses=[],this._tests=[],this._initialized=!1}init(){this._initialized||(this._initialized=!0,this._effectClasses.forEach(r=>{this.add({test:r.test,maskClass:r})}))}add(r){this._tests.push(r)}getMaskEffect(r){this._initialized||this.init();for(let i=0;i<this._tests.length;i++){const a=this._tests[i];if(a.test(r))return o9.get(a.maskClass,r)}return r}returnMaskEffect(r){o9.return(r)}}const j$e=new ign;k9.handleByList(Ab.MaskEffect,j$e._effectClasses);const sgn={_maskEffect:null,_maskOptions:{inverse:!1,channel:"red"},_filterEffect:null,effects:[],_markStructureAsChanged(){const t=this.renderGroup||this.parentRenderGroup;t&&(t.structureDidChange=!0)},addEffect(t){this.effects.indexOf(t)===-1&&(this.effects.push(t),this.effects.sort((i,a)=>i.priority-a.priority),this._markStructureAsChanged(),this._updateIsSimple())},removeEffect(t){const r=this.effects.indexOf(t);r!==-1&&(this.effects.splice(r,1),this._markStructureAsChanged(),this._updateIsSimple())},set mask(t){const r=this._maskEffect;r?.mask!==t&&(r&&(this.removeEffect(r),j$e.returnMaskEffect(r),this._maskEffect=null),t!=null&&(this._maskEffect=j$e.getMaskEffect(t),this.addEffect(this._maskEffect)))},get mask(){return this._maskEffect?.mask},setMask(t){this._maskOptions={...this._maskOptions,...t},t.mask&&(this.mask=t.mask),this._markStructureAsChanged()},set filters(t){!Array.isArray(t)&&t&&(t=[t]);const r=this._filterEffect||(this._filterEffect=new LCt);t=t;const i=t?.length>0,a=r.filters?.length>0,l=i!==a;t=Array.isArray(t)?t.slice(0):t,r.filters=Object.freeze(t),l&&(i?this.addEffect(r):(this.removeEffect(r),r.filters=t??null))},get filters(){return this._filterEffect?.filters},set filterArea(t){this._filterEffect||(this._filterEffect=new LCt),this._filterEffect.filterArea=t},get filterArea(){return this._filterEffect?.filterArea}},ogn={label:null,get name(){return hI(Hz,"Container.name property has been removed, use Container.label instead"),this.label},set name(t){hI(Hz,"Container.name property has been removed, use Container.label instead"),this.label=t},getChildByName(t,r=!1){return this.getChildByLabel(t,r)},getChildByLabel(t,r=!1){const i=this.children;for(let a=0;a<i.length;a++){const l=i[a];if(l.label===t||t instanceof RegExp&&t.test(l.label))return l}if(r)for(let a=0;a<i.length;a++){const d=i[a].getChildByLabel(t,!0);if(d)return d}return null},getChildrenByLabel(t,r=!1,i=[]){const a=this.children;for(let l=0;l<a.length;l++){const d=a[l];(d.label===t||t instanceof RegExp&&t.test(d.label))&&i.push(d)}if(r)for(let l=0;l<a.length;l++)a[l].getChildrenByLabel(t,!0,i);return i}},vb=o9.getPool(Lm),kP=o9.getPool(V8),agn=new Lm,cgn={getFastGlobalBounds(t,r){r||(r=new V8),r.clear(),this._getGlobalBoundsRecursive(!!t,r,this.parentRenderLayer),r.isValid||r.set(0,0,0,0);const i=this.renderGroup||this.parentRenderGroup;return r.applyMatrix(i.worldTransform),r},_getGlobalBoundsRecursive(t,r,i){let a=r;if(t&&this.parentRenderLayer&&this.parentRenderLayer!==i||this.localDisplayStatus!==7||!this.measurable)return;const l=!!this.effects.length;if((this.renderGroup||l)&&(a=kP.get().clear()),this.boundsArea)r.addRect(this.boundsArea,this.worldTransform);else{if(this.renderPipeId){const _=this.bounds;a.addFrame(_.minX,_.minY,_.maxX,_.maxY,this.groupTransform)}const d=this.children;for(let _=0;_<d.length;_++)d[_]._getGlobalBoundsRecursive(t,a,i)}if(l){let d=!1;const _=this.renderGroup||this.parentRenderGroup;for(let g=0;g<this.effects.length;g++)this.effects[g].addBounds&&(d||(d=!0,a.applyMatrix(_.worldTransform)),this.effects[g].addBounds(a,!0));d&&a.applyMatrix(_.worldTransform.copyTo(agn).invert()),r.addBounds(a),kP.return(a)}else this.renderGroup&&(r.addBounds(a,this.relativeGroupTransform),kP.return(a))}};function uHt(t,r,i){i.clear();let a,l;return t.parent?r?a=t.parent.worldTransform:(l=vb.get().identity(),a=AQe(t,l)):a=Lm.IDENTITY,fHt(t,i,a,r),l&&vb.return(l),i.isValid||i.set(0,0,0,0),i}function fHt(t,r,i,a){if(!t.visible||!t.measurable)return;let l;a?l=t.worldTransform:(t.updateLocalTransform(),l=vb.get(),l.appendFrom(t.localTransform,i));const d=r,_=!!t.effects.length;if(_&&(r=kP.get().clear()),t.boundsArea)r.addRect(t.boundsArea,l);else{const g=t.bounds;g&&!g.isEmpty()&&(r.matrix=l,r.addBounds(g));for(let b=0;b<t.children.length;b++)fHt(t.children[b],r,l,a)}if(_){for(let g=0;g<t.effects.length;g++)t.effects[g].addBounds?.(r);d.addBounds(r,Lm.IDENTITY),kP.return(r)}a||vb.return(l)}function AQe(t,r){const i=t.parent;return i&&(AQe(i,r),i.updateLocalTransform(),r.append(i.localTransform)),r}function lgn(t,r){if(t===16777215||!r)return r;if(r===16777215||!t)return t;const i=t>>16&255,a=t>>8&255,l=t&255,d=r>>16&255,_=r>>8&255,g=r&255,b=i*d/255|0,S=a*_/255|0,k=l*g/255|0;return(b<<16)+(S<<8)+k}const jCt=16777215;function BCt(t,r){return t===jCt?r:r===jCt?t:lgn(t,r)}function jme(t){return((t&255)<<16)+(t&65280)+(t>>16&255)}const ugn={getGlobalAlpha(t){if(t)return this.renderGroup?this.renderGroup.worldAlpha:this.parentRenderGroup?this.parentRenderGroup.worldAlpha*this.alpha:this.alpha;let r=this.alpha,i=this.parent;for(;i;)r*=i.alpha,i=i.parent;return r},getGlobalTransform(t=new Lm,r){if(r)return t.copyFrom(this.worldTransform);this.updateLocalTransform();const i=AQe(this,vb.get().identity());return t.appendFrom(this.localTransform,i),vb.return(i),t},getGlobalTint(t){if(t)return this.renderGroup?jme(this.renderGroup.worldColor):this.parentRenderGroup?jme(BCt(this.localColor,this.parentRenderGroup.worldColor)):this.tint;let r=this.localColor,i=this.parent;for(;i;)r=BCt(r,i.localColor),i=i.parent;return jme(r)}};function dHt(t,r,i){return r.clear(),i||(i=Lm.IDENTITY),pHt(t,r,i,t,!0),r.isValid||r.set(0,0,0,0),r}function pHt(t,r,i,a,l){let d;if(l)d=vb.get(),d=i.copyTo(d);else{if(!t.visible||!t.measurable)return;t.updateLocalTransform();const b=t.localTransform;d=vb.get(),d.appendFrom(b,i)}const _=r,g=!!t.effects.length;if(g&&(r=kP.get().clear()),t.boundsArea)r.addRect(t.boundsArea,d);else{t.renderPipeId&&(r.matrix=d,r.addBounds(t.bounds));const b=t.children;for(let S=0;S<b.length;S++)pHt(b[S],r,d,a,!1)}if(g){for(let b=0;b<t.effects.length;b++)t.effects[b].addLocalBounds?.(r,a);_.addBounds(r,Lm.IDENTITY),kP.return(r)}vb.return(d)}function _Ht(t,r){const i=t.children;for(let a=0;a<i.length;a++){const l=i[a],d=l.uid,_=(l._didViewChangeTick&65535)<<16|l._didContainerChangeTick&65535,g=r.index;(r.data[g]!==d||r.data[g+1]!==_)&&(r.data[r.index]=d,r.data[r.index+1]=_,r.didChange=!0),r.index=g+2,l.children.length&&_Ht(l,r)}return r.didChange}const fgn=new Lm,dgn={_localBoundsCacheId:-1,_localBoundsCacheData:null,_setWidth(t,r){const i=Math.sign(this.scale.x)||1;r!==0?this.scale.x=t/r*i:this.scale.x=i},_setHeight(t,r){const i=Math.sign(this.scale.y)||1;r!==0?this.scale.y=t/r*i:this.scale.y=i},getLocalBounds(){this._localBoundsCacheData||(this._localBoundsCacheData={data:[],index:1,didChange:!1,localBounds:new V8});const t=this._localBoundsCacheData;return t.index=1,t.didChange=!1,t.data[0]!==this._didViewChangeTick&&(t.didChange=!0,t.data[0]=this._didViewChangeTick),_Ht(this,t),t.didChange&&dHt(this,t.localBounds,fgn),t.localBounds},getBounds(t,r){return uHt(this,t,r||new V8)}},pgn={_onRender:null,set onRender(t){const r=this.renderGroup||this.parentRenderGroup;if(!t){this._onRender&&r?.removeOnRender(this),this._onRender=null;return}this._onRender||r?.addOnRender(this),this._onRender=t},get onRender(){return this._onRender}},_gn={_zIndex:0,sortDirty:!1,sortableChildren:!1,get zIndex(){return this._zIndex},set zIndex(t){this._zIndex!==t&&(this._zIndex=t,this.depthOfChildModified())},depthOfChildModified(){this.parent&&(this.parent.sortableChildren=!0,this.parent.sortDirty=!0),this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0)},sortChildren(){this.sortDirty&&(this.sortDirty=!1,this.children.sort(mgn))}};function mgn(t,r){return t._zIndex-r._zIndex}const hgn={getGlobalPosition(t=new rI,r=!1){return this.parent?this.parent.toGlobal(this._position,t,r):(t.x=this._position.x,t.y=this._position.y),t},toGlobal(t,r,i=!1){const a=this.getGlobalTransform(vb.get(),i);return r=a.apply(t,r),vb.return(a),r},toLocal(t,r,i,a){r&&(t=r.toGlobal(t,i,a));const l=this.getGlobalTransform(vb.get(),a);return i=l.applyInverse(t,i),vb.return(l),i}};class ggn{constructor(){this.uid=o8("instructionSet"),this.instructions=[],this.instructionSize=0,this.renderables=[],this.gcTick=0}reset(){this.instructionSize=0}destroy(){this.instructions.length=0,this.renderables.length=0,this.renderPipes=null,this.gcTick=0}add(r){this.instructions[this.instructionSize++]=r}log(){this.instructions.length=this.instructionSize,console.table(this.instructions,["type","action"])}}let ygn=0;class vgn{constructor(r){this._poolKeyHash=Object.create(null),this._texturePool={},this.textureOptions=r||{},this.enableFullScreen=!1,this.textureStyle=new nHt(this.textureOptions)}createTexture(r,i,a,l){const d=new FE({...this.textureOptions,width:r,height:i,resolution:1,antialias:a,autoGarbageCollect:!1,autoGenerateMipmaps:l});return new Fy({source:d,label:`texturePool_${ygn++}`})}getOptimalTexture(r,i,a=1,l,d=!1){let _=Math.ceil(r*a-1e-6),g=Math.ceil(i*a-1e-6);_=wCt(_),g=wCt(g);const b=l?1:0,S=d?1:0,k=(_<<17)+(g<<2)+(S<<1)+b;this._texturePool[k]||(this._texturePool[k]=[]);let w=this._texturePool[k].pop();return w||(w=this.createTexture(_,g,l,d)),w.source._resolution=a,w.source.width=_/a,w.source.height=g/a,w.source.pixelWidth=_,w.source.pixelHeight=g,w.frame.x=0,w.frame.y=0,w.frame.width=r,w.frame.height=i,w.updateUvs(),this._poolKeyHash[w.uid]=k,w}getSameSizeTexture(r,i=!1){const a=r.source;return this.getOptimalTexture(r.width,r.height,a._resolution,i)}returnTexture(r,i=!1){const a=this._poolKeyHash[r.uid];i&&(r.source.style=this.textureStyle),this._texturePool[a].push(r)}clear(r){if(r=r!==!1,r)for(const i in this._texturePool){const a=this._texturePool[i];if(a)for(let l=0;l<a.length;l++)a[l].destroy(!0)}this._texturePool={}}}const mHt=new vgn;lHt.register(mHt);class bgn{constructor(){this.renderPipeId="renderGroup",this.root=null,this.canBundle=!1,this.renderGroupParent=null,this.renderGroupChildren=[],this.worldTransform=new Lm,this.worldColorAlpha=4294967295,this.worldColor=16777215,this.worldAlpha=1,this.childrenToUpdate=Object.create(null),this.updateTick=0,this.gcTick=0,this.childrenRenderablesToUpdate={list:[],index:0},this.structureDidChange=!0,this.instructionSet=new ggn,this._onRenderContainers=[],this.textureNeedsUpdate=!0,this.isCachedAsTexture=!1,this._matrixDirty=7}init(r){this.root=r,r._onRender&&this.addOnRender(r),r.didChange=!0;const i=r.children;for(let a=0;a<i.length;a++){const l=i[a];l._updateFlags=15,this.addChild(l)}}enableCacheAsTexture(r={}){this.textureOptions=r,this.isCachedAsTexture=!0,this.textureNeedsUpdate=!0}disableCacheAsTexture(){this.isCachedAsTexture=!1,this.texture&&(mHt.returnTexture(this.texture,!0),this.texture=null)}updateCacheTexture(){this.textureNeedsUpdate=!0;const r=this._parentCacheAsTextureRenderGroup;r&&!r.textureNeedsUpdate&&r.updateCacheTexture()}reset(){this.renderGroupChildren.length=0;for(const r in this.childrenToUpdate){const i=this.childrenToUpdate[r];i.list.fill(null),i.index=0}this.childrenRenderablesToUpdate.index=0,this.childrenRenderablesToUpdate.list.fill(null),this.root=null,this.updateTick=0,this.structureDidChange=!0,this._onRenderContainers.length=0,this.renderGroupParent=null,this.disableCacheAsTexture()}get localTransform(){return this.root.localTransform}addRenderGroupChild(r){r.renderGroupParent&&r.renderGroupParent._removeRenderGroupChild(r),r.renderGroupParent=this,this.renderGroupChildren.push(r)}_removeRenderGroupChild(r){const i=this.renderGroupChildren.indexOf(r);i>-1&&this.renderGroupChildren.splice(i,1),r.renderGroupParent=null}addChild(r){if(this.structureDidChange=!0,r.parentRenderGroup=this,r.updateTick=-1,r.parent===this.root?r.relativeRenderGroupDepth=1:r.relativeRenderGroupDepth=r.parent.relativeRenderGroupDepth+1,r.didChange=!0,this.onChildUpdate(r),r.renderGroup){this.addRenderGroupChild(r.renderGroup);return}r._onRender&&this.addOnRender(r);const i=r.children;for(let a=0;a<i.length;a++)this.addChild(i[a])}removeChild(r){if(this.structureDidChange=!0,r._onRender&&(r.renderGroup||this.removeOnRender(r)),r.parentRenderGroup=null,r.renderGroup){this._removeRenderGroupChild(r.renderGroup);return}const i=r.children;for(let a=0;a<i.length;a++)this.removeChild(i[a])}removeChildren(r){for(let i=0;i<r.length;i++)this.removeChild(r[i])}onChildUpdate(r){let i=this.childrenToUpdate[r.relativeRenderGroupDepth];i||(i=this.childrenToUpdate[r.relativeRenderGroupDepth]={index:0,list:[]}),i.list[i.index++]=r}updateRenderable(r){r.globalDisplayStatus<7||(this.instructionSet.renderPipes[r.renderPipeId].updateRenderable(r),r.didViewUpdate=!1)}onChildViewUpdate(r){this.childrenRenderablesToUpdate.list[this.childrenRenderablesToUpdate.index++]=r}get isRenderable(){return this.root.localDisplayStatus===7&&this.worldAlpha>0}addOnRender(r){this._onRenderContainers.push(r)}removeOnRender(r){this._onRenderContainers.splice(this._onRenderContainers.indexOf(r),1)}runOnRender(r){for(let i=0;i<this._onRenderContainers.length;i++)this._onRenderContainers[i]._onRender(r)}destroy(){this.disableCacheAsTexture(),this.renderGroupParent=null,this.root=null,this.childrenRenderablesToUpdate=null,this.childrenToUpdate=null,this.renderGroupChildren=null,this._onRenderContainers=null,this.instructionSet=null}getChildren(r=[]){const i=this.root.children;for(let a=0;a<i.length;a++)this._getChildren(i[a],r);return r}_getChildren(r,i=[]){if(i.push(r),r.renderGroup)return i;const a=r.children;for(let l=0;l<a.length;l++)this._getChildren(a[l],i);return i}invalidateMatrices(){this._matrixDirty=7}get inverseWorldTransform(){return(this._matrixDirty&1)===0?this._inverseWorldTransform:(this._matrixDirty&=-2,this._inverseWorldTransform||(this._inverseWorldTransform=new Lm),this._inverseWorldTransform.copyFrom(this.worldTransform).invert())}get textureOffsetInverseTransform(){return(this._matrixDirty&2)===0?this._textureOffsetInverseTransform:(this._matrixDirty&=-3,this._textureOffsetInverseTransform||(this._textureOffsetInverseTransform=new Lm),this._textureOffsetInverseTransform.copyFrom(this.inverseWorldTransform).translate(-this._textureBounds.x,-this._textureBounds.y))}get inverseParentTextureTransform(){if((this._matrixDirty&4)===0)return this._inverseParentTextureTransform;this._matrixDirty&=-5;const r=this._parentCacheAsTextureRenderGroup;return r?(this._inverseParentTextureTransform||(this._inverseParentTextureTransform=new Lm),this._inverseParentTextureTransform.copyFrom(this.worldTransform).prepend(r.inverseWorldTransform).translate(-r._textureBounds.x,-r._textureBounds.y)):this.worldTransform}get cacheToLocalTransform(){return this.isCachedAsTexture?this.textureOffsetInverseTransform:this._parentCacheAsTextureRenderGroup?this._parentCacheAsTextureRenderGroup.textureOffsetInverseTransform:null}}function Agn(t,r,i={}){for(const a in r)!i[a]&&r[a]!==void 0&&(t[a]=r[a])}const ORe=new _1(null),m_e=new _1(null),FRe=new _1(null,1,1),h_e=new _1(null),$Ct=1,Sgn=2,RRe=4;class fte extends X1e{constructor(r={}){super(),this.uid=o8("renderable"),this._updateFlags=15,this.renderGroup=null,this.parentRenderGroup=null,this.parentRenderGroupIndex=0,this.didChange=!1,this.didViewUpdate=!1,this.relativeRenderGroupDepth=0,this.children=[],this.parent=null,this.includeInBuild=!0,this.measurable=!0,this.isSimple=!0,this.parentRenderLayer=null,this.updateTick=-1,this.localTransform=new Lm,this.relativeGroupTransform=new Lm,this.groupTransform=this.relativeGroupTransform,this.destroyed=!1,this._position=new _1(this,0,0),this._scale=FRe,this._pivot=m_e,this._origin=h_e,this._skew=ORe,this._cx=1,this._sx=0,this._cy=0,this._sy=1,this._rotation=0,this.localColor=16777215,this.localAlpha=1,this.groupAlpha=1,this.groupColor=16777215,this.groupColorAlpha=4294967295,this.localBlendMode="inherit",this.groupBlendMode="normal",this.localDisplayStatus=7,this.globalDisplayStatus=7,this._didContainerChangeTick=0,this._didViewChangeTick=0,this._didLocalTransformChangeId=-1,this.effects=[],Agn(this,r,{children:!0,parent:!0,effects:!0}),r.children?.forEach(i=>this.addChild(i)),r.parent?.addChild(this)}static mixin(r){hI("8.8.0","Container.mixin is deprecated, please use extensions.mixin instead."),k9.mixin(fte,r)}set _didChangeId(r){this._didViewChangeTick=r>>12&4095,this._didContainerChangeTick=r&4095}get _didChangeId(){return this._didContainerChangeTick&4095|(this._didViewChangeTick&4095)<<12}addChild(...r){if(this.allowChildren||hI(Hz,"addChild: Only Containers will be allowed to add children in v8.0.0"),r.length>1){for(let l=0;l<r.length;l++)this.addChild(r[l]);return r[0]}const i=r[0],a=this.renderGroup||this.parentRenderGroup;return i.parent===this?(this.children.splice(this.children.indexOf(i),1),this.children.push(i),a&&(a.structureDidChange=!0),i):(i.parent&&i.parent.removeChild(i),this.children.push(i),this.sortableChildren&&(this.sortDirty=!0),i.parent=this,i.didChange=!0,i._updateFlags=15,a&&a.addChild(i),this.emit("childAdded",i,this,this.children.length-1),i.emit("added",this),this._didViewChangeTick++,i._zIndex!==0&&i.depthOfChildModified(),i)}removeChild(...r){if(r.length>1){for(let l=0;l<r.length;l++)this.removeChild(r[l]);return r[0]}const i=r[0],a=this.children.indexOf(i);return a>-1&&(this._didViewChangeTick++,this.children.splice(a,1),this.renderGroup?this.renderGroup.removeChild(i):this.parentRenderGroup&&this.parentRenderGroup.removeChild(i),i.parentRenderLayer&&i.parentRenderLayer.detach(i),i.parent=null,this.emit("childRemoved",i,this,a),i.emit("removed",this)),i}_onUpdate(r){r&&r===this._skew&&this._updateSkew(),this._didContainerChangeTick++,!this.didChange&&(this.didChange=!0,this.parentRenderGroup&&this.parentRenderGroup.onChildUpdate(this))}set isRenderGroup(r){!!this.renderGroup!==r&&(r?this.enableRenderGroup():this.disableRenderGroup())}get isRenderGroup(){return!!this.renderGroup}enableRenderGroup(){if(this.renderGroup)return;const r=this.parentRenderGroup;r?.removeChild(this),this.renderGroup=o9.get(bgn,this),this.groupTransform=Lm.IDENTITY,r?.addChild(this),this._updateIsSimple()}disableRenderGroup(){if(!this.renderGroup)return;const r=this.parentRenderGroup;r?.removeChild(this),o9.return(this.renderGroup),this.renderGroup=null,this.groupTransform=this.relativeGroupTransform,r?.addChild(this),this._updateIsSimple()}_updateIsSimple(){this.isSimple=!this.renderGroup&&this.effects.length===0}get worldTransform(){return this._worldTransform||(this._worldTransform=new Lm),this.renderGroup?this._worldTransform.copyFrom(this.renderGroup.worldTransform):this.parentRenderGroup&&this._worldTransform.appendFrom(this.relativeGroupTransform,this.parentRenderGroup.worldTransform),this._worldTransform}get x(){return this._position.x}set x(r){this._position.x=r}get y(){return this._position.y}set y(r){this._position.y=r}get position(){return this._position}set position(r){this._position.copyFrom(r)}get rotation(){return this._rotation}set rotation(r){this._rotation!==r&&(this._rotation=r,this._onUpdate(this._skew))}get angle(){return this.rotation*Nhn}set angle(r){this.rotation=r*Ohn}get pivot(){return this._pivot===m_e&&(this._pivot=new _1(this,0,0)),this._pivot}set pivot(r){this._pivot===m_e&&(this._pivot=new _1(this,0,0),this._origin!==h_e&&b8("Setting both a pivot and origin on a Container is not recommended. This can lead to unexpected behavior if not handled carefully.")),typeof r=="number"?this._pivot.set(r):this._pivot.copyFrom(r)}get skew(){return this._skew===ORe&&(this._skew=new _1(this,0,0)),this._skew}set skew(r){this._skew===ORe&&(this._skew=new _1(this,0,0)),this._skew.copyFrom(r)}get scale(){return this._scale===FRe&&(this._scale=new _1(this,1,1)),this._scale}set scale(r){this._scale===FRe&&(this._scale=new _1(this,0,0)),typeof r=="string"&&(r=parseFloat(r)),typeof r=="number"?this._scale.set(r):this._scale.copyFrom(r)}get origin(){return this._origin===h_e&&(this._origin=new _1(this,0,0)),this._origin}set origin(r){this._origin===h_e&&(this._origin=new _1(this,0,0),this._pivot!==m_e&&b8("Setting both a pivot and origin on a Container is not recommended. This can lead to unexpected behavior if not handled carefully.")),typeof r=="number"?this._origin.set(r):this._origin.copyFrom(r)}get width(){return Math.abs(this.scale.x*this.getLocalBounds().width)}set width(r){const i=this.getLocalBounds().width;this._setWidth(r,i)}get height(){return Math.abs(this.scale.y*this.getLocalBounds().height)}set height(r){const i=this.getLocalBounds().height;this._setHeight(r,i)}getSize(r){r||(r={});const i=this.getLocalBounds();return r.width=Math.abs(this.scale.x*i.width),r.height=Math.abs(this.scale.y*i.height),r}setSize(r,i){const a=this.getLocalBounds();typeof r=="object"?(i=r.height??r.width,r=r.width):i??(i=r),r!==void 0&&this._setWidth(r,a.width),i!==void 0&&this._setHeight(i,a.height)}_updateSkew(){const r=this._rotation,i=this._skew;this._cx=Math.cos(r+i._y),this._sx=Math.sin(r+i._y),this._cy=-Math.sin(r-i._x),this._sy=Math.cos(r-i._x)}updateTransform(r){return this.position.set(typeof r.x=="number"?r.x:this.position.x,typeof r.y=="number"?r.y:this.position.y),this.scale.set(typeof r.scaleX=="number"?r.scaleX:this.scale.x,typeof r.scaleY=="number"?r.scaleY:this.scale.y),this.rotation=typeof r.rotation=="number"?r.rotation:this.rotation,this.skew.set(typeof r.skewX=="number"?r.skewX:this.skew.x,typeof r.skewY=="number"?r.skewY:this.skew.y),this.pivot.set(typeof r.pivotX=="number"?r.pivotX:this.pivot.x,typeof r.pivotY=="number"?r.pivotY:this.pivot.y),this.origin.set(typeof r.originX=="number"?r.originX:this.origin.x,typeof r.originY=="number"?r.originY:this.origin.y),this}setFromMatrix(r){r.decompose(this)}updateLocalTransform(){const r=this._didContainerChangeTick;if(this._didLocalTransformChangeId===r)return;this._didLocalTransformChangeId=r;const i=this.localTransform,a=this._scale,l=this._pivot,d=this._origin,_=this._position,g=a._x,b=a._y,S=l._x,k=l._y,w=-d._x,N=-d._y;i.a=this._cx*g,i.b=this._sx*g,i.c=this._cy*b,i.d=this._sy*b,i.tx=_._x-(S*i.a+k*i.c)+(w*i.a+N*i.c)-w,i.ty=_._y-(S*i.b+k*i.d)+(w*i.b+N*i.d)-N}set alpha(r){r!==this.localAlpha&&(this.localAlpha=r,this._updateFlags|=$Ct,this._onUpdate())}get alpha(){return this.localAlpha}set tint(r){const a=Khn.shared.setValue(r??16777215).toBgrNumber();a!==this.localColor&&(this.localColor=a,this._updateFlags|=$Ct,this._onUpdate())}get tint(){return jme(this.localColor)}set blendMode(r){this.localBlendMode!==r&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=Sgn,this.localBlendMode=r,this._onUpdate())}get blendMode(){return this.localBlendMode}get visible(){return!!(this.localDisplayStatus&2)}set visible(r){const i=r?2:0;(this.localDisplayStatus&2)!==i&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=RRe,this.localDisplayStatus^=2,this._onUpdate(),this.emit("visibleChanged",r))}get culled(){return!(this.localDisplayStatus&4)}set culled(r){const i=r?0:4;(this.localDisplayStatus&4)!==i&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=RRe,this.localDisplayStatus^=4,this._onUpdate())}get renderable(){return!!(this.localDisplayStatus&1)}set renderable(r){const i=r?1:0;(this.localDisplayStatus&1)!==i&&(this._updateFlags|=RRe,this.localDisplayStatus^=1,this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._onUpdate())}get isRenderable(){return this.localDisplayStatus===7&&this.groupAlpha>0}destroy(r=!1){if(this.destroyed)return;this.destroyed=!0;let i;if(this.children.length&&(i=this.removeChildren(0,this.children.length)),this.removeFromParent(),this.parent=null,this._maskEffect=null,this._filterEffect=null,this.effects=null,this._position=null,this._scale=null,this._pivot=null,this._origin=null,this._skew=null,this.emit("destroyed",this),this.removeAllListeners(),(typeof r=="boolean"?r:r?.children)&&i)for(let l=0;l<i.length;++l)i[l].destroy(r);this.renderGroup?.destroy(),this.renderGroup=null}}k9.mixin(fte,rgn,cgn,hgn,pgn,dgn,sgn,ogn,_gn,Yhn,egn,ugn,ngn);class xgn extends fte{constructor(r){super(r),this.canBundle=!0,this.allowChildren=!1,this._roundPixels=0,this._lastUsed=-1,this._gpuData=Object.create(null),this.autoGarbageCollect=!0,this._gcLastUsed=-1,this._bounds=new V8(0,1,0,0),this._boundsDirty=!0,this.autoGarbageCollect=r.autoGarbageCollect??!0}get bounds(){return this._boundsDirty?(this.updateBounds(),this._boundsDirty=!1,this._bounds):this._bounds}get roundPixels(){return!!this._roundPixels}set roundPixels(r){this._roundPixels=r?1:0}containsPoint(r){const i=this.bounds,{x:a,y:l}=r;return a>=i.minX&&a<=i.maxX&&l>=i.minY&&l<=i.maxY}onViewUpdate(){if(this._didViewChangeTick++,this._boundsDirty=!0,this.didViewUpdate)return;this.didViewUpdate=!0;const r=this.renderGroup||this.parentRenderGroup;r&&r.onChildViewUpdate(this)}unload(){this.emit("unload",this);for(const r in this._gpuData)this._gpuData[r]?.destroy();this._gpuData=Object.create(null),this.onViewUpdate()}destroy(r){this.unload(),super.destroy(r),this._bounds=null}collectRenderablesSimple(r,i,a){const{renderPipes:l}=i;l.blendMode.pushBlendMode(this,this.groupBlendMode,r);const _=l[this.renderPipeId];_?.addRenderable&&_.addRenderable(this,r),this.didViewUpdate=!1;const g=this.children,b=g.length;for(let S=0;S<b;S++)g[S].collectRenderables(r,i,a);l.blendMode.popBlendMode(r)}}class cee extends xgn{constructor(r=Fy.EMPTY){r instanceof Fy&&(r={texture:r});const{texture:i=Fy.EMPTY,anchor:a,roundPixels:l,width:d,height:_,...g}=r;super({label:"Sprite",...g}),this.renderPipeId="sprite",this.batched=!0,this._visualBounds={minX:0,maxX:1,minY:0,maxY:0},this._anchor=new _1({_onUpdate:()=>{this.onViewUpdate()}}),a?this.anchor=a:i.defaultAnchor&&(this.anchor=i.defaultAnchor),this.texture=i,this.allowChildren=!1,this.roundPixels=l??!1,d!==void 0&&(this.width=d),_!==void 0&&(this.height=_)}static from(r,i=!1){return r instanceof Fy?new cee(r):new cee(Fy.from(r,i))}set texture(r){r||(r=Fy.EMPTY);const i=this._texture;i!==r&&(i&&i.dynamic&&i.off("update",this.onViewUpdate,this),r.dynamic&&r.on("update",this.onViewUpdate,this),this._texture=r,this._width&&this._setWidth(this._width,this._texture.orig.width),this._height&&this._setHeight(this._height,this._texture.orig.height),this.onViewUpdate())}get texture(){return this._texture}get visualBounds(){return $hn(this._visualBounds,this._anchor,this._texture),this._visualBounds}get sourceBounds(){return hI("8.6.1","Sprite.sourceBounds is deprecated, use visualBounds instead."),this.visualBounds}updateBounds(){const r=this._anchor,i=this._texture,a=this._bounds,{width:l,height:d}=i.orig;a.minX=-r._x*l,a.maxX=a.minX+l,a.minY=-r._y*d,a.maxY=a.minY+d}destroy(r=!1){if(super.destroy(r),typeof r=="boolean"?r:r?.texture){const a=typeof r=="boolean"?r:r?.textureSource;this._texture.destroy(a)}this._texture=null,this._visualBounds=null,this._bounds=null,this._anchor=null}get anchor(){return this._anchor}set anchor(r){typeof r=="number"?this._anchor.set(r):this._anchor.copyFrom(r)}get width(){return Math.abs(this.scale.x)*this._texture.orig.width}set width(r){this._setWidth(r,this._texture.orig.width),this._width=r}get height(){return Math.abs(this.scale.y)*this._texture.orig.height}set height(r){this._setHeight(r,this._texture.orig.height),this._height=r}getSize(r){return r||(r={}),r.width=Math.abs(this.scale.x)*this._texture.orig.width,r.height=Math.abs(this.scale.y)*this._texture.orig.height,r}setSize(r,i){typeof r=="object"?(i=r.height??r.width,r=r.width):i??(i=r),r!==void 0&&this._setWidth(r,this._texture.orig.width),i!==void 0&&this._setHeight(i,this._texture.orig.height)}}const wgn=new V8;function hHt(t,r,i){const a=wgn;t.measurable=!0,uHt(t,i,a),r.addBoundsMask(a),t.measurable=!1}function gHt(t,r,i){const a=kP.get();t.measurable=!0;const l=vb.get().identity(),d=yHt(t,i,l);dHt(t,a,d),t.measurable=!1,r.addBoundsMask(a),vb.return(l),kP.return(a)}function yHt(t,r,i){return t?(t!==r&&(yHt(t.parent,r,i),t.updateLocalTransform(),i.append(t.localTransform)),i):(b8("Mask bounds, renderable is not inside the root container"),i)}class vHt{constructor(r){this.priority=0,this.inverse=!1,this.channel="red",this.pipe="alphaMask",r?.mask&&this.init(r.mask)}init(r){this.mask=r,this.renderMaskToTexture=!(r instanceof cee),this.mask.renderable=this.renderMaskToTexture,this.mask.includeInBuild=!this.renderMaskToTexture,this.mask.measurable=!1}reset(){this.mask!==null&&(this.mask.measurable=!0,this.mask=null)}addBounds(r,i){this.inverse||hHt(this.mask,r,i)}addLocalBounds(r,i){gHt(this.mask,r,i)}containsPoint(r,i){const a=this.mask;return i(a,r)}destroy(){this.reset()}static test(r){return r instanceof cee}}vHt.extension=Ab.MaskEffect;class bHt{constructor(r){this.priority=0,this.pipe="colorMask",r?.mask&&this.init(r.mask)}init(r){this.mask=r}destroy(){}static test(r){return typeof r=="number"}}bHt.extension=Ab.MaskEffect;class AHt{constructor(r){this.priority=0,this.pipe="stencilMask",r?.mask&&this.init(r.mask)}init(r){this.mask=r,this.mask.includeInBuild=!1,this.mask.measurable=!1}reset(){this.mask!==null&&(this.mask.measurable=!0,this.mask.includeInBuild=!0,this.mask=null)}addBounds(r,i){hHt(this.mask,r,i)}addLocalBounds(r,i){gHt(this.mask,r,i)}containsPoint(r,i){const a=this.mask;return i(a,r)}destroy(){this.reset()}static test(r){return r instanceof fte}}AHt.extension=Ab.MaskEffect;const Cgn={createCanvas:(t,r)=>{const i=document.createElement("canvas");return i.width=t,i.height=r,i},createImage:()=>new Image,getCanvasRenderingContext2D:()=>CanvasRenderingContext2D,getWebGLRenderingContext:()=>WebGLRenderingContext,getNavigator:()=>navigator,getBaseUrl:()=>document.baseURI??window.location.href,getFontFaceSet:()=>document.fonts,fetch:(t,r)=>fetch(t,r),parseXML:t=>new DOMParser().parseFromString(t,"text/xml")};let qCt=Cgn;const SQe={get(){return qCt},set(t){qCt=t}};class SHt extends FE{constructor(r){r.resource||(r.resource=SQe.get().createCanvas()),r.width||(r.width=r.resource.width,r.autoDensity||(r.width/=r.resolution)),r.height||(r.height=r.resource.height,r.autoDensity||(r.height/=r.resolution)),super(r),this.uploadMethodId="image",this.autoDensity=r.autoDensity,this.resizeCanvas(),this.transparent=!!r.transparent}resizeCanvas(){this.autoDensity&&"style"in this.resource&&(this.resource.style.width=`${this.width}px`,this.resource.style.height=`${this.height}px`),(this.resource.width!==this.pixelWidth||this.resource.height!==this.pixelHeight)&&(this.resource.width=this.pixelWidth,this.resource.height=this.pixelHeight)}resize(r=this.width,i=this.height,a=this._resolution){const l=super.resize(r,i,a);return l&&this.resizeCanvas(),l}static test(r){return globalThis.HTMLCanvasElement&&r instanceof HTMLCanvasElement||globalThis.OffscreenCanvas&&r instanceof OffscreenCanvas}get context2D(){return this._context2D||(this._context2D=this.resource.getContext("2d"))}}SHt.extension=Ab.TextureSource;class xHt extends FE{constructor(r){super(r),this.uploadMethodId="image",this.autoGarbageCollect=!0}static test(r){return globalThis.HTMLImageElement&&r instanceof HTMLImageElement||typeof ImageBitmap<"u"&&r instanceof ImageBitmap||globalThis.VideoFrame&&r instanceof VideoFrame}}xHt.extension=Ab.TextureSource;var B$e=(t=>(t[t.INTERACTION=50]="INTERACTION",t[t.HIGH=25]="HIGH",t[t.NORMAL=0]="NORMAL",t[t.LOW=-25]="LOW",t[t.UTILITY=-50]="UTILITY",t))(B$e||{});class MRe{constructor(r,i=null,a=0,l=!1){this.next=null,this.previous=null,this._destroyed=!1,this._fn=r,this._context=i,this.priority=a,this._once=l}match(r,i=null){return this._fn===r&&this._context===i}emit(r){this._fn&&(this._context?this._fn.call(this._context,r):this._fn(r));const i=this.next;return this._once&&this.destroy(!0),this._destroyed&&(this.next=null),i}connect(r){this.previous=r,r.next&&(r.next.previous=this),this.next=r.next,r.next=this}destroy(r=!1){this._destroyed=!0,this._fn=null,this._context=null,this.previous&&(this.previous.next=this.next),this.next&&(this.next.previous=this.previous);const i=this.next;return this.next=r?null:i,this.previous=null,i}}const wHt=class pS{constructor(){this.autoStart=!1,this.deltaTime=1,this.lastTime=-1,this.speed=1,this.started=!1,this._requestId=null,this._maxElapsedMS=100,this._minElapsedMS=0,this._protected=!1,this._lastFrame=-1,this._head=new MRe(null,null,1/0),this.deltaMS=1/pS.targetFPMS,this.elapsedMS=1/pS.targetFPMS,this._tick=r=>{this._requestId=null,this.started&&(this.update(r),this.started&&this._requestId===null&&this._head.next&&(this._requestId=requestAnimationFrame(this._tick)))}}_requestIfNeeded(){this._requestId===null&&this._head.next&&(this.lastTime=performance.now(),this._lastFrame=this.lastTime,this._requestId=requestAnimationFrame(this._tick))}_cancelIfNeeded(){this._requestId!==null&&(cancelAnimationFrame(this._requestId),this._requestId=null)}_startIfPossible(){this.started?this._requestIfNeeded():this.autoStart&&this.start()}add(r,i,a=B$e.NORMAL){return this._addListener(new MRe(r,i,a))}addOnce(r,i,a=B$e.NORMAL){return this._addListener(new MRe(r,i,a,!0))}_addListener(r){let i=this._head.next,a=this._head;if(!i)r.connect(a);else{for(;i;){if(r.priority>i.priority){r.connect(a);break}a=i,i=i.next}r.previous||r.connect(a)}return this._startIfPossible(),this}remove(r,i){let a=this._head.next;for(;a;)a.match(r,i)?a=a.destroy():a=a.next;return this._head.next||this._cancelIfNeeded(),this}get count(){if(!this._head)return 0;let r=0,i=this._head;for(;i=i.next;)r++;return r}start(){this.started||(this.started=!0,this._requestIfNeeded())}stop(){this.started&&(this.started=!1,this._cancelIfNeeded())}destroy(){if(!this._protected){this.stop();let r=this._head.next;for(;r;)r=r.destroy(!0);this._head.destroy(),this._head=null}}update(r=performance.now()){let i;if(r>this.lastTime){if(i=this.elapsedMS=r-this.lastTime,i>this._maxElapsedMS&&(i=this._maxElapsedMS),i*=this.speed,this._minElapsedMS){const d=r-this._lastFrame|0;if(d<this._minElapsedMS)return;this._lastFrame=r-d%this._minElapsedMS}this.deltaMS=i,this.deltaTime=this.deltaMS*pS.targetFPMS;const a=this._head;let l=a.next;for(;l;)l=l.emit(this);a.next||this._cancelIfNeeded()}else this.deltaTime=this.deltaMS=this.elapsedMS=0;this.lastTime=r}get FPS(){return 1e3/this.elapsedMS}get minFPS(){return 1e3/this._maxElapsedMS}set minFPS(r){const i=Math.min(Math.max(0,r)/1e3,pS.targetFPMS);this._maxElapsedMS=1/i,this._minElapsedMS&&r>this.maxFPS&&(this.maxFPS=r)}get maxFPS(){return this._minElapsedMS?Math.round(1e3/this._minElapsedMS):0}set maxFPS(r){r===0?this._minElapsedMS=0:(r<this.minFPS&&(this.minFPS=r),this._minElapsedMS=1/(r/1e3))}static get shared(){if(!pS._shared){const r=pS._shared=new pS;r.autoStart=!0,r._protected=!0}return pS._shared}static get system(){if(!pS._system){const r=pS._system=new pS;r.autoStart=!0,r._protected=!0}return pS._system}};wHt.targetFPMS=.06;let g_e=wHt,LRe;async function Egn(){return LRe??(LRe=(async()=>{const r=SQe.get().createCanvas(1,1).getContext("webgl");if(!r)return"premultiply-alpha-on-upload";const i=await new Promise(_=>{const g=document.createElement("video");g.onloadeddata=()=>_(g),g.onerror=()=>_(null),g.autoplay=!1,g.crossOrigin="anonymous",g.preload="auto",g.src="data:video/webm;base64,GkXfo59ChoEBQveBAULygQRC84EIQoKEd2VibUKHgQJChYECGFOAZwEAAAAAAAHTEU2bdLpNu4tTq4QVSalmU6yBoU27i1OrhBZUrmtTrIHGTbuMU6uEElTDZ1OsggEXTbuMU6uEHFO7a1OsggG97AEAAAAAAABZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVSalmoCrXsYMPQkBNgIRMYXZmV0GETGF2ZkSJiEBEAAAAAAAAFlSua8yuAQAAAAAAAEPXgQFzxYgAAAAAAAAAAZyBACK1nIN1bmSIgQCGhVZfVlA5g4EBI+ODhAJiWgDglLCBArqBApqBAlPAgQFVsIRVuYEBElTDZ9Vzc9JjwItjxYgAAAAAAAAAAWfInEWjh0VOQ09ERVJEh49MYXZjIGxpYnZweC12cDlnyKJFo4hEVVJBVElPTkSHlDAwOjAwOjAwLjA0MDAwMDAwMAAAH0O2dcfngQCgwqGggQAAAIJJg0IAABAAFgA4JBwYSgAAICAAEb///4r+AAB1oZ2mm+6BAaWWgkmDQgAAEAAWADgkHBhKAAAgIABIQBxTu2uRu4+zgQC3iveBAfGCAXHwgQM=",g.load()});if(!i)return"premultiply-alpha-on-upload";const a=r.createTexture();r.bindTexture(r.TEXTURE_2D,a);const l=r.createFramebuffer();r.bindFramebuffer(r.FRAMEBUFFER,l),r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,a,0),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),r.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,r.NONE),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,i);const d=new Uint8Array(4);return r.readPixels(0,0,1,1,r.RGBA,r.UNSIGNED_BYTE,d),r.deleteFramebuffer(l),r.deleteTexture(a),r.getExtension("WEBGL_lose_context")?.loseContext(),d[0]<=d[3]?"premultiplied-alpha":"premultiply-alpha-on-upload"})()),LRe}const Z1e=class CHt extends FE{constructor(r){super(r),this.isReady=!1,this.uploadMethodId="video",r={...CHt.defaultOptions,...r},this._autoUpdate=!0,this._isConnectedToTicker=!1,this._updateFPS=r.updateFPS||0,this._msToNextUpdate=0,this.autoPlay=r.autoPlay!==!1,this.alphaMode=r.alphaMode??"premultiply-alpha-on-upload",this._videoFrameRequestCallback=this._videoFrameRequestCallback.bind(this),this._videoFrameRequestCallbackHandle=null,this._load=null,this._resolve=null,this._reject=null,this._onCanPlay=this._onCanPlay.bind(this),this._onCanPlayThrough=this._onCanPlayThrough.bind(this),this._onError=this._onError.bind(this),this._onPlayStart=this._onPlayStart.bind(this),this._onPlayStop=this._onPlayStop.bind(this),this._onSeeked=this._onSeeked.bind(this),this._onLoadedMetadata=this._onLoadedMetadata.bind(this),r.autoLoad!==!1&&this.load()}updateFrame(){if(!this.destroyed){if(this._updateFPS){const r=g_e.shared.elapsedMS*this.resource.playbackRate;this._msToNextUpdate=Math.floor(this._msToNextUpdate-r)}(!this._updateFPS||this._msToNextUpdate<=0)&&(this._msToNextUpdate=this._updateFPS?Math.floor(1e3/this._updateFPS):0),this.isValid&&this.update()}}_videoFrameRequestCallback(){this.updateFrame(),this.destroyed?this._videoFrameRequestCallbackHandle=null:this._videoFrameRequestCallbackHandle=this.resource.requestVideoFrameCallback(this._videoFrameRequestCallback)}get isValid(){return!!this.resource.videoWidth&&!!this.resource.videoHeight}async load(){if(this._load)return this._load;const r=this.resource,i=this.options;return(r.readyState===r.HAVE_ENOUGH_DATA||r.readyState===r.HAVE_FUTURE_DATA)&&r.width&&r.height&&(r.complete=!0),r.addEventListener("play",this._onPlayStart),r.addEventListener("pause",this._onPlayStop),r.addEventListener("seeked",this._onSeeked),this._isSourceReady()?this._mediaReady():(i.preload||r.addEventListener("canplay",this._onCanPlay),r.addEventListener("canplaythrough",this._onCanPlayThrough),r.addEventListener("error",this._onError,!0)),this.isValid||r.addEventListener("loadedmetadata",this._onLoadedMetadata),this.alphaMode=await Egn(),this._load=new Promise((a,l)=>{this.isValid?a(this):(this._resolve=a,this._reject=l,i.preloadTimeoutMs!==void 0&&(this._preloadTimeout=setTimeout(()=>{this._onError(new ErrorEvent(`Preload exceeded timeout of ${i.preloadTimeoutMs}ms`))})),r.load())}),this._load}_onError(r){this.resource.removeEventListener("error",this._onError,!0),this.emit("error",r),this._reject&&(this._reject(r),this._reject=null,this._resolve=null)}_isSourcePlaying(){const r=this.resource;return!r.paused&&!r.ended}_isSourceReady(){return this.resource.readyState>2}_onPlayStart(){this._configureAutoUpdate()}_onPlayStop(){this._configureAutoUpdate()}_onSeeked(){this._autoUpdate&&!this._isSourcePlaying()&&(this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0)}_onLoadedMetadata(){this.isValid&&this._mediaReady()}_onCanPlay(){this.resource.removeEventListener("canplay",this._onCanPlay),this._mediaReady()}_onCanPlayThrough(){this.resource.removeEventListener("canplaythrough",this._onCanPlayThrough),this._preloadTimeout&&(clearTimeout(this._preloadTimeout),this._preloadTimeout=void 0),this._mediaReady()}_mediaReady(){const r=this.resource;this.isValid&&(this.isReady=!0,this.resize(r.videoWidth,r.videoHeight)),this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0,this._resolve&&this.isValid&&(this._resolve(this),this._resolve=null,this._reject=null),this._isSourcePlaying()?this._onPlayStart():this.autoPlay&&this.resource.play()}destroy(){this._configureAutoUpdate();const r=this.resource;r&&(r.removeEventListener("play",this._onPlayStart),r.removeEventListener("pause",this._onPlayStop),r.removeEventListener("seeked",this._onSeeked),r.removeEventListener("canplay",this._onCanPlay),r.removeEventListener("canplaythrough",this._onCanPlayThrough),r.removeEventListener("loadedmetadata",this._onLoadedMetadata),r.removeEventListener("error",this._onError,!0),r.pause(),r.src="",r.load()),super.destroy()}get autoUpdate(){return this._autoUpdate}set autoUpdate(r){r!==this._autoUpdate&&(this._autoUpdate=r,this._configureAutoUpdate())}get updateFPS(){return this._updateFPS}set updateFPS(r){r!==this._updateFPS&&(this._updateFPS=r,this._configureAutoUpdate())}_configureAutoUpdate(){this._autoUpdate&&this._isSourcePlaying()?!this._updateFPS&&this.resource.requestVideoFrameCallback?(this._isConnectedToTicker&&(g_e.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0),this._videoFrameRequestCallbackHandle===null&&(this._videoFrameRequestCallbackHandle=this.resource.requestVideoFrameCallback(this._videoFrameRequestCallback))):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker||(g_e.shared.add(this.updateFrame,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(g_e.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(r){return globalThis.HTMLVideoElement&&r instanceof HTMLVideoElement}};Z1e.extension=Ab.TextureSource;Z1e.defaultOptions={...FE.defaultOptions,autoLoad:!0,autoPlay:!0,updateFPS:0,crossorigin:!0,loop:!1,muted:!0,playsinline:!0,preload:!1};Z1e.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let Tgn=Z1e;const cq=(t,r,i=!1)=>(Array.isArray(t)||(t=[t]),r?t.map(a=>typeof a=="string"||i?r(a):a):t);class kgn{constructor(){this._parsers=[],this._cache=new Map,this._cacheMap=new Map}reset(){this._cacheMap.clear(),this._cache.clear()}has(r){return this._cache.has(r)}get(r){const i=this._cache.get(r);return i||b8(`[Assets] Asset id ${r} was not found in the Cache`),i}set(r,i){const a=cq(r);let l;for(let b=0;b<this.parsers.length;b++){const S=this.parsers[b];if(S.test(i)){l=S.getCacheableAssets(a,i);break}}const d=new Map(Object.entries(l||{}));l||a.forEach(b=>{d.set(b,i)});const _=[...d.keys()],g={cacheKeys:_,keys:a};a.forEach(b=>{this._cacheMap.set(b,g)}),_.forEach(b=>{const S=l?l[b]:i;this._cache.has(b)&&this._cache.get(b)!==S&&b8("[Cache] already has key:",b),this._cache.set(b,d.get(b))})}remove(r){if(!this._cacheMap.has(r)){b8(`[Assets] Asset id ${r} was not found in the Cache`);return}const i=this._cacheMap.get(r);i.cacheKeys.forEach(l=>{this._cache.delete(l)}),i.keys.forEach(l=>{this._cacheMap.delete(l)})}get parsers(){return this._parsers}}const lq=new kgn,$$e=[];k9.handleByList(Ab.TextureSource,$$e);function EHt(t={}){const r=t&&t.resource,i=r?t.resource:t,a=r?t:{resource:t};for(let l=0;l<$$e.length;l++){const d=$$e[l];if(d.test(i))return new d(a)}throw new Error(`Could not find a source type for resource: ${a.resource}`)}function Ign(t={},r=!1){const i=t&&t.resource,a=i?t.resource:t,l=i?t:{resource:t};if(!r&&lq.has(a))return lq.get(a);const d=new Fy({source:EHt(l)});return d.on("destroy",()=>{lq.has(a)&&lq.remove(a)}),r||lq.set(a,d),d}function Dgn(t,r=!1){return typeof t=="string"?lq.get(t):t instanceof FE?new Fy({source:t}):Ign(t,r)}Fy.from=Dgn;FE.from=EHt;k9.add(vHt,bHt,AHt,Tgn,xHt,SHt,bQe);var THt=(t=>(t[t.Low=0]="Low",t[t.Normal=1]="Normal",t[t.High=2]="High",t))(THt||{});function oE(t){if(typeof t!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(t)}`)}function CY(t){return t.split("?")[0].split("#")[0]}function Pgn(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ngn(t,r,i){return t.replace(new RegExp(Pgn(r),"g"),i)}function Ogn(t,r){let i="",a=0,l=-1,d=0,_=-1;for(let g=0;g<=t.length;++g){if(g<t.length)_=t.charCodeAt(g);else{if(_===47)break;_=47}if(_===47){if(!(l===g-1||d===1))if(l!==g-1&&d===2){if(i.length<2||a!==2||i.charCodeAt(i.length-1)!==46||i.charCodeAt(i.length-2)!==46){if(i.length>2){const b=i.lastIndexOf("/");if(b!==i.length-1){b===-1?(i="",a=0):(i=i.slice(0,b),a=i.length-1-i.lastIndexOf("/")),l=g,d=0;continue}}else if(i.length===2||i.length===1){i="",a=0,l=g,d=0;continue}}}else i.length>0?i+=`/${t.slice(l+1,g)}`:i=t.slice(l+1,g),a=g-l-1;l=g,d=0}else _===46&&d!==-1?++d:d=-1}return i}const lee={toPosix(t){return Ngn(t,"\\","/")},isUrl(t){return/^https?:/.test(this.toPosix(t))},isDataUrl(t){return/^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}()_|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s<>]*?)$/i.test(t)},isBlobUrl(t){return t.startsWith("blob:")},hasProtocol(t){return/^[^/:]+:/.test(this.toPosix(t))},getProtocol(t){oE(t),t=this.toPosix(t);const r=/^file:\/\/\//.exec(t);if(r)return r[0];const i=/^[^/:]+:\/{0,2}/.exec(t);return i?i[0]:""},toAbsolute(t,r,i){if(oE(t),this.isDataUrl(t)||this.isBlobUrl(t))return t;const a=CY(this.toPosix(r??SQe.get().getBaseUrl())),l=CY(this.toPosix(i??this.rootname(a)));return t=this.toPosix(t),t.startsWith("/")?lee.join(l,t.slice(1)):this.isAbsolute(t)?t:this.join(a,t)},normalize(t){if(oE(t),t.length===0)return".";if(this.isDataUrl(t)||this.isBlobUrl(t))return t;t=this.toPosix(t);let r="";const i=t.startsWith("/");this.hasProtocol(t)&&(r=this.rootname(t),t=t.slice(r.length));const a=t.endsWith("/");return t=Ogn(t),t.length>0&&a&&(t+="/"),i?`/${t}`:r+t},isAbsolute(t){return oE(t),t=this.toPosix(t),this.hasProtocol(t)?!0:t.startsWith("/")},join(...t){if(t.length===0)return".";let r;for(let i=0;i<t.length;++i){const a=t[i];if(oE(a),a.length>0)if(r===void 0)r=a;else{const l=t[i-1]??"";this.joinExtensions.includes(this.extname(l).toLowerCase())?r+=`/../${a}`:r+=`/${a}`}}return r===void 0?".":this.normalize(r)},dirname(t){if(oE(t),t.length===0)return".";t=this.toPosix(t);let r=t.charCodeAt(0);const i=r===47;let a=-1,l=!0;const d=this.getProtocol(t),_=t;t=t.slice(d.length);for(let g=t.length-1;g>=1;--g)if(r=t.charCodeAt(g),r===47){if(!l){a=g;break}}else l=!1;return a===-1?i?"/":this.isUrl(_)?d+t:d:i&&a===1?"//":d+t.slice(0,a)},rootname(t){oE(t),t=this.toPosix(t);let r="";if(t.startsWith("/")?r="/":r=this.getProtocol(t),this.isUrl(t)){const i=t.indexOf("/",r.length);i!==-1?r=t.slice(0,i):r=t,r.endsWith("/")||(r+="/")}return r},basename(t,r){oE(t),r&&oE(r),t=CY(this.toPosix(t));let i=0,a=-1,l=!0,d;if(r!==void 0&&r.length>0&&r.length<=t.length){if(r.length===t.length&&r===t)return"";let _=r.length-1,g=-1;for(d=t.length-1;d>=0;--d){const b=t.charCodeAt(d);if(b===47){if(!l){i=d+1;break}}else g===-1&&(l=!1,g=d+1),_>=0&&(b===r.charCodeAt(_)?--_===-1&&(a=d):(_=-1,a=g))}return i===a?a=g:a===-1&&(a=t.length),t.slice(i,a)}for(d=t.length-1;d>=0;--d)if(t.charCodeAt(d)===47){if(!l){i=d+1;break}}else a===-1&&(l=!1,a=d+1);return a===-1?"":t.slice(i,a)},extname(t){oE(t),t=CY(this.toPosix(t));let r=-1,i=0,a=-1,l=!0,d=0;for(let _=t.length-1;_>=0;--_){const g=t.charCodeAt(_);if(g===47){if(!l){i=_+1;break}continue}a===-1&&(l=!1,a=_+1),g===46?r===-1?r=_:d!==1&&(d=1):r!==-1&&(d=-1)}return r===-1||a===-1||d===0||d===1&&r===a-1&&r===i+1?"":t.slice(r,a)},parse(t){oE(t);const r={root:"",dir:"",base:"",ext:"",name:""};if(t.length===0)return r;t=CY(this.toPosix(t));let i=t.charCodeAt(0);const a=this.isAbsolute(t);let l;r.root=this.rootname(t),a||this.hasProtocol(t)?l=1:l=0;let d=-1,_=0,g=-1,b=!0,S=t.length-1,k=0;for(;S>=l;--S){if(i=t.charCodeAt(S),i===47){if(!b){_=S+1;break}continue}g===-1&&(b=!1,g=S+1),i===46?d===-1?d=S:k!==1&&(k=1):d!==-1&&(k=-1)}return d===-1||g===-1||k===0||k===1&&d===g-1&&d===_+1?g!==-1&&(_===0&&a?r.base=r.name=t.slice(1,g):r.base=r.name=t.slice(_,g)):(_===0&&a?(r.name=t.slice(1,d),r.base=t.slice(1,g)):(r.name=t.slice(_,d),r.base=t.slice(_,g)),r.ext=t.slice(d,g)),r.dir=this.dirname(t),r},sep:"/",delimiter:":",joinExtensions:[".html"]};function kHt(t,r,i,a,l){const d=r[i];for(let _=0;_<d.length;_++){const g=d[_];i<r.length-1?kHt(t.replace(a[i],g),r,i+1,a,l):l.push(t.replace(a[i],g))}}function Fgn(t){const r=/\{(.*?)\}/g,i=t.match(r),a=[];if(i){const l=[];i.forEach(d=>{const _=d.substring(1,d.length-1).split(",");l.push(_)}),kHt(t,l,0,i,a)}else a.push(t);return a}const zCt=t=>!Array.isArray(t);class IHt{constructor(){this._defaultBundleIdentifierOptions={connector:"-",createBundleAssetId:(r,i)=>`${r}${this._bundleIdConnector}${i}`,extractAssetIdFromBundle:(r,i)=>i.replace(`${r}${this._bundleIdConnector}`,"")},this._bundleIdConnector=this._defaultBundleIdentifierOptions.connector,this._createBundleAssetId=this._defaultBundleIdentifierOptions.createBundleAssetId,this._extractAssetIdFromBundle=this._defaultBundleIdentifierOptions.extractAssetIdFromBundle,this._assetMap={},this._preferredOrder=[],this._parsers=[],this._resolverHash={},this._bundles={}}setBundleIdentifier(r){if(this._bundleIdConnector=r.connector??this._bundleIdConnector,this._createBundleAssetId=r.createBundleAssetId??this._createBundleAssetId,this._extractAssetIdFromBundle=r.extractAssetIdFromBundle??this._extractAssetIdFromBundle,this._extractAssetIdFromBundle("foo",this._createBundleAssetId("foo","bar"))!=="bar")throw new Error("[Resolver] GenerateBundleAssetId are not working correctly")}prefer(...r){r.forEach(i=>{this._preferredOrder.push(i),i.priority||(i.priority=Object.keys(i.params))}),this._resolverHash={}}set basePath(r){this._basePath=r}get basePath(){return this._basePath}set rootPath(r){this._rootPath=r}get rootPath(){return this._rootPath}get parsers(){return this._parsers}reset(){this.setBundleIdentifier(this._defaultBundleIdentifierOptions),this._assetMap={},this._preferredOrder=[],this._resolverHash={},this._rootPath=null,this._basePath=null,this._manifest=null,this._bundles={},this._defaultSearchParams=null}setDefaultSearchParams(r){if(typeof r=="string")this._defaultSearchParams=r;else{const i=r;this._defaultSearchParams=Object.keys(i).map(a=>`${encodeURIComponent(a)}=${encodeURIComponent(i[a])}`).join("&")}}getAlias(r){const{alias:i,src:a}=r;return cq(i||a,d=>typeof d=="string"?d:Array.isArray(d)?d.map(_=>_?.src??_):d?.src?d.src:d,!0)}removeAlias(r,i){this._assetMap[r]&&(i&&i!==this._resolverHash[r]||(delete this._resolverHash[r],delete this._assetMap[r]))}addManifest(r){this._manifest&&b8("[Resolver] Manifest already exists, this will be overwritten"),this._manifest=r,r.bundles.forEach(i=>{this.addBundle(i.name,i.assets)})}addBundle(r,i){const a=[];let l=i;Array.isArray(i)||(l=Object.entries(i).map(([d,_])=>typeof _=="string"||Array.isArray(_)?{alias:d,src:_}:{alias:d,..._})),l.forEach(d=>{const _=d.src,g=d.alias;let b;if(typeof g=="string"){const S=this._createBundleAssetId(r,g);a.push(S),b=[g,S]}else{const S=g.map(k=>this._createBundleAssetId(r,k));a.push(...S),b=[...g,...S]}this.add({...d,alias:b,src:_})}),this._bundles[r]=a}add(r){const i=[];Array.isArray(r)?i.push(...r):i.push(r);let a;a=d=>{this.hasKey(d)&&b8(`[Resolver] already has key: ${d} overwriting`)},cq(i).forEach(d=>{const{src:_}=d;let{data:g,format:b,loadParser:S,parser:k}=d;const w=cq(_).map(J=>typeof J=="string"?Fgn(J):Array.isArray(J)?J:[J]),N=this.getAlias(d);Array.isArray(N)?N.forEach(a):a(N);const P=[],j=J=>{const X=this._parsers.find(G=>G.test(J));return{src:J,...X?.parse(J)}};w.forEach(J=>{J.forEach(X=>{let G={};if(typeof X!="object"?G=j(X):(g=X.data??g,b=X.format??b,(X.loadParser||X.parser)&&(S=X.loadParser??S,k=X.parser??k),G={...j(X.src),...X}),!N)throw new Error(`[Resolver] alias is undefined for this asset: ${G.src}`);G=this._buildResolvedAsset(G,{aliases:N,data:g,format:b,loadParser:S,parser:k,progressSize:d.progressSize}),P.push(G)})}),N.forEach(J=>{this._assetMap[J]=P})})}resolveBundle(r){const i=zCt(r);r=cq(r);const a={};return r.forEach(l=>{const d=this._bundles[l];if(d){const _=this.resolve(d),g={};for(const b in _){const S=_[b];g[this._extractAssetIdFromBundle(l,b)]=S}a[l]=g}}),i?a[r[0]]:a}resolveUrl(r){const i=this.resolve(r);if(typeof r!="string"){const a={};for(const l in i)a[l]=i[l].src;return a}return i.src}resolve(r){const i=zCt(r);r=cq(r);const a={};return r.forEach(l=>{if(!this._resolverHash[l])if(this._assetMap[l]){let d=this._assetMap[l];const _=this._getPreferredOrder(d);_?.priority.forEach(g=>{_.params[g].forEach(b=>{const S=d.filter(k=>k[g]?k[g]===b:!1);S.length&&(d=S)})}),this._resolverHash[l]=d[0]}else this._resolverHash[l]=this._buildResolvedAsset({alias:[l],src:l},{});a[l]=this._resolverHash[l]}),i?a[r[0]]:a}hasKey(r){return!!this._assetMap[r]}hasBundle(r){return!!this._bundles[r]}_getPreferredOrder(r){for(let i=0;i<r.length;i++){const a=r[i],l=this._preferredOrder.find(d=>d.params.format.includes(a.format));if(l)return l}return this._preferredOrder[0]}_appendDefaultSearchParams(r){if(!this._defaultSearchParams)return r;const i=/\?/.test(r)?"&":"?";return`${r}${i}${this._defaultSearchParams}`}_buildResolvedAsset(r,i){const{aliases:a,data:l,loadParser:d,parser:_,format:g,progressSize:b}=i;return(this._basePath||this._rootPath)&&(r.src=lee.toAbsolute(r.src,this._basePath,this._rootPath)),r.alias=a??r.alias??[r.src],r.src=this._appendDefaultSearchParams(r.src),r.data={...l||{},...r.data},r.loadParser=d??r.loadParser,r.parser=_??r.parser,r.format=g??r.format??Rgn(r.src),b!==void 0&&(r.progressSize=b),r}}IHt.RETINA_PREFIX=/@([0-9\.]+)x/;function Rgn(t){return t.split(".").pop().split("?").shift().split("#").shift()}const UCt=(t,r)=>{const i=r.split("?")[1];return i&&(t+=`?${i}`),t},DHt=class pX{constructor(r,i){this.linkedSheets=[];let a=r;r?.source instanceof FE&&(a={texture:r,data:i});const{texture:l,data:d,cachePrefix:_=""}=a;this.cachePrefix=_,this._texture=l instanceof Fy?l:null,this.textureSource=l.source,this.textures={},this.animations={},this.data=d;const g=parseFloat(d.meta.scale);g?(this.resolution=g,l.source.resolution=this.resolution):this.resolution=l.source._resolution,this._frames=this.data.frames,this._frameKeys=Object.keys(this._frames),this._batchIndex=0,this._callback=null}parse(){return new Promise(r=>{this._callback=r,this._batchIndex=0,this._frameKeys.length<=pX.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}parseSync(){return this._processFrames(0,!0),this._processAnimations(),this.textures}_processFrames(r,i=!1){let a=r;const l=i?1/0:pX.BATCH_SIZE;for(;a-r<l&&a<this._frameKeys.length;){const d=this._frameKeys[a],_=this._frames[d],g=_.frame;if(g){let b=null,S=null;const k=_.trimmed!==!1&&_.sourceSize?_.sourceSize:_.frame,w=new nI(0,0,Math.floor(k.w)/this.resolution,Math.floor(k.h)/this.resolution);_.rotated?b=new nI(Math.floor(g.x)/this.resolution,Math.floor(g.y)/this.resolution,Math.floor(g.h)/this.resolution,Math.floor(g.w)/this.resolution):b=new nI(Math.floor(g.x)/this.resolution,Math.floor(g.y)/this.resolution,Math.floor(g.w)/this.resolution,Math.floor(g.h)/this.resolution),_.trimmed!==!1&&_.spriteSourceSize&&(S=new nI(Math.floor(_.spriteSourceSize.x)/this.resolution,Math.floor(_.spriteSourceSize.y)/this.resolution,Math.floor(g.w)/this.resolution,Math.floor(g.h)/this.resolution)),this.textures[d]=new Fy({source:this.textureSource,frame:b,orig:w,trim:S,rotate:_.rotated?2:0,defaultAnchor:_.anchor,defaultBorders:_.borders,label:d.toString()})}a++}}_processAnimations(){const r=this.data.animations||{};for(const i in r){this.animations[i]=[];for(let a=0;a<r[i].length;a++){const l=r[i][a];this.animations[i].push(this.textures[l])}}}_parseComplete(){const r=this._callback;this._callback=null,this._batchIndex=0,r.call(this,this.textures)}_nextBatch(){this._processFrames(this._batchIndex*pX.BATCH_SIZE),this._batchIndex++,setTimeout(()=>{this._batchIndex*pX.BATCH_SIZE<this._frameKeys.length?this._nextBatch():(this._processAnimations(),this._parseComplete())},0)}destroy(r=!1){for(const i in this.textures)this.textures[i].destroy();this._frames=null,this._frameKeys=null,this.data=null,this.textures=null,r&&(this._texture?.destroy(),this.textureSource.destroy()),this._texture=null,this.textureSource=null,this.linkedSheets=[]}};DHt.BATCH_SIZE=1e3;let VCt=DHt;const Mgn=["jpg","png","jpeg","avif","webp","basis","etc2","bc7","bc6h","bc5","bc4","bc3","bc2","bc1","eac","astc"];function PHt(t,r,i){const a={};if(t.forEach(l=>{a[l]=r}),Object.keys(r.textures).forEach(l=>{a[`${r.cachePrefix}${l}`]=r.textures[l]}),!i){const l=lee.dirname(t[0]);r.linkedSheets.forEach((d,_)=>{const g=PHt([`${l}/${r.data.meta.related_multi_packs[_]}`],d,!0);Object.assign(a,g)})}return a}const Lgn={extension:Ab.Asset,cache:{test:t=>t instanceof VCt,getCacheableAssets:(t,r)=>PHt(t,r,!1)},resolver:{extension:{type:Ab.ResolveParser,name:"resolveSpritesheet"},test:t=>{const i=t.split("?")[0].split("."),a=i.pop(),l=i.pop();return a==="json"&&Mgn.includes(l)},parse:t=>{const r=t.split(".");return{resolution:parseFloat(IHt.RETINA_PREFIX.exec(t)?.[1]??"1"),format:r[r.length-2],src:t}}},loader:{name:"spritesheetLoader",id:"spritesheet",extension:{type:Ab.LoadParser,priority:THt.Normal,name:"spritesheetLoader"},async testParse(t,r){return lee.extname(r.src).toLowerCase()===".json"&&!!t.frames},async parse(t,r,i){const{texture:a,imageFilename:l,textureOptions:d,cachePrefix:_}=r?.data??{};let g=lee.dirname(r.src);g&&g.lastIndexOf("/")!==g.length-1&&(g+="/");let b;if(a instanceof Fy)b=a;else{const w=UCt(g+(l??t.meta.image),r.src);b=(await i.load([{src:w,data:d}]))[w]}const S=new VCt({texture:b.source,data:t,cachePrefix:_});await S.parse();const k=t?.meta?.related_multi_packs;if(Array.isArray(k)){const w=[];for(const P of k){if(typeof P!="string")continue;let j=g+P;r.data?.ignoreMultiPack||(j=UCt(j,r.src),w.push(i.load({src:j,data:{textureOptions:d,ignoreMultiPack:!0}})))}const N=await Promise.all(w);S.linkedSheets=N,N.forEach(P=>{P.linkedSheets=[S].concat(S.linkedSheets.filter(j=>j!==P))})}return S},async unload(t,r,i){await i.unload(t.textureSource._sourceOrigin),t.destroy(!1)}}};k9.add(Lgn);k9.add(Thn,khn);function jgn(t){return async r=>{const i=t.find(l=>l.canvas===r);if(!i?.renderer)return null;const a=i.renderer.background;return i.renderer.extract.canvas({target:i.stage,frame:i.screen,...a.alpha>0?{clearColor:a.color}:{}})}}const Bgn=new Set,$gn=new Map;function qgn(t){const r=$gn.get(t);return r?r():jgn([...Bgn])(t)}async function VPn(t){const r=[],i=globalThis.__PIXI_APP_INIT__;globalThis.__PIXI_APP_INIT__=(a,l)=>{const d=a;d.stage&&d.ticker&&r.push(a),i?.(a,l)};try{return await t(r)}finally{globalThis.__PIXI_APP_INIT__=i}}let XN=[],zgn=0,NHt=0;const q$e=new Set;function z$e(){NHt++;for(const t of q$e)t()}function OHt(){z$e()}function U$e(){return Cb()}function xQe(){let t=null;for(const{session:r}of XN){const i=r.startedAt?.()??null;i!==null&&(!t||i>t.startedAt)&&(t={startedAt:i,endedAt:r.endedAt?.()??null})}return t}function FHt(){for(const{session:t}of XN){const r=t.restartRequired?.()??null;if(r!==null)return r}return null}function RHt(){(Cb().find(i=>(i.restartRequired?.()??null)!==null)??Cb().find(i=>i.mounted()&&i.restart))?.restart?.()}function wQe(){for(const t of Cb()){if(!t.mounted())continue;const r=t.frameCanvas?.()??null;if(r)return r}return null}function CQe(t){for(const r of Cb())if(!(!r.mounted()||!r.snapshotFrame)&&r.frameCanvas?.()===t)return r.snapshotFrame();return null}function EQe(t){for(const r of Cb()){if(!r.mounted()||!r.command)continue;const i=r.command(t);if(i)return i}return null}function TQe(){for(const t of Cb()){if(!t.mounted())continue;const r=t.scenes?.()??null;if(r&&typeof r.goToScene=="function")return r}return null}function ebe(){for(const t of Cb()){if(!t.mounted())continue;const r=t.surface?.()??null;if(r)return r}return null}function kQe(){for(const t of Cb()){if(!t.mounted())continue;const r=t.coverage?.()??null;if(r)return r}return null}function IQe(){for(const t of Cb()){if(!t.mounted())continue;const r=t.authoringRefusal?.()??null;if(r!==null)return r}return null}function MHt(t){return Cb().find(i=>i.mounted()&&i.remount)?.remount?.(t)??null}function LHt(t){if(XN.some(i=>i.session.id===t.id))throw new Error(`live session "${t.id}" is already registered.`);const r={session:t,seq:zgn++};return XN=[...XN,r],z$e(),()=>{XN=XN.filter(i=>i!==r),z$e()}}function Cb(){return[...XN].sort((t,r)=>(t.session.priority??0)-(r.session.priority??0)||t.seq-r.seq).map(t=>t.session)}function DQe(){return Cb().some(t=>t.mounted())}function tbe(){return Cb().some(t=>t.playing())}function PQe(){for(const t of Cb())t.stop()}function jHt(t){for(const r of Cb()){const i=r.instanceContainer(t);if(i)return i}return null}function NQe(t){return q$e.add(t),()=>q$e.delete(t)}function BHt(){return NHt}const Ugn=Object.freeze(Object.defineProperty({__proto__:null,anyLiveSessionMounted:DQe,anyLiveSessionPlaying:tbe,dispatchLiveCommand:EQe,liveAuthoringRefusal:IQe,liveCoverage:kQe,liveFrameCanvas:wQe,liveInstanceContainer:jHt,liveRestartRequired:FHt,liveRunWindow:xQe,liveScenes:TQe,liveSessions:U$e,liveSessionsVersion:BHt,liveSurface:ebe,notifyLiveSessionsChanged:OHt,registerLiveSession:LHt,remountLiveSelection:MHt,restartLiveSession:RHt,snapshotLiveFrame:CQe,stopAllLiveSessions:PQe,subscribeLiveSessions:NQe},Symbol.toStringTag,{value:"Module"}));async function V$e(t){const r=CQe(t);return r||qgn(t)}const Vgn=Object.freeze(Object.defineProperty({__proto__:null,liveCanvasFrame:V$e},Symbol.toStringTag,{value:"Module"})),JCt="editor-chrome-root";async function WCt(t){const r=new Image;return r.src=t,await r.decode(),r}function Jgn(t,r){return async i=>{const a={width:Math.max(1,Math.round(i.clientWidth*r)),height:Math.max(1,Math.round(i.clientHeight*r))};if(t.viewportCanvas()===i){const l=await V$e(i);if(l)return l;const d=t.captureViewportImage(a);return d?WCt(d):null}for(const l of BOr()){if(l.renderer.domElement!==i)continue;const d=await l.requestPresentedFrame();if(d)return d;const _=l.captureImage(a);return _?WCt(_):null}return V$e(i)}}async function Wgn(t,r){const i=document.getElementById(JCt);if(!i)throw new Error(`The editor chrome root (#${JCt}) is not mounted, so there is no editor page to photograph.`);const a=r?.scale??window.devicePixelRatio??1,l=i.getBoundingClientRect(),d={width:Math.max(1,Math.round(l.width*a)),height:Math.max(1,Math.round(l.height*a))};return{...await GWt(i,{canvasFrame:Jgn(t,a),includeDocumentStyles:!0,size:d}),view:ute(t),size:d,scale:a}}function rbe(){return tbe()}const yye=new Set;function Hgn(t,r){const i={collect:t,reusableKeys:r?.reusableKeys??[]};return yye.add(i),()=>{yye.delete(i)}}function Ggn(t=null){const r={};for(const i of yye)Object.assign(r,i.collect(t));return r}function Qgn(){const t=[];for(const r of yye)t.push(...r.reusableKeys);return t}function dte(t,r,i){return t.hierarchy.object3D?.(i)??r.get(i)??null}function $Ht(t){const r=CE(t,"entityId");return typeof r=="string"&&r?r:void 0}function qHt(t){return $Ht(t)!==void 0}function JPn(t){let r=t??null;for(;r&&!qHt(r);)r=r.parent;return r}function WPn(t,r){CZ(t,"entityId",r)}let QX=null;const a8=[];function Kgn(t){if(QX=t,a8.length!==0)for(const r of a8.splice(0,a8.length))r.resolve(t)}function Ygn(){return new Promise((t,r)=>{a8.push({resolve:t,reject:r})})}function Xgn(t){QX===t&&(QX=null,a8.length!==0&&queueMicrotask(()=>{if(!(QX!==null||a8.length===0))for(const r of a8.splice(0,a8.length))r.reject(new Error("the hierarchy panel (GameHierarchy) unmounted before it published the mutated row tree, so the mutation cannot be acknowledged against a rendered tree. Open the Hierarchy panel in the workspace dock and retry."))}))}function HCt(){return QX}function Zgn(t,r){const i=[],a=[];for(const l of t.rows){const d=eyn(l,t);for(;a.length>l.depth;)a.pop();const _=a.length>0?a[a.length-1]:void 0;if(_===void 0)i.push(d);else{const g=_.children;g===void 0?_.children=[d]:g.push(d)}a.push(d)}return{rowCount:t.rows.length,window:{start:t.window.start,end:t.window.end},...t.searchTerm?{search:t.searchTerm}:{},...t.scopeId?{scopeId:t.scopeId}:{},playState:r.playState,activeViewportTab:r.activeViewportTab,roots:i}}function eyn(t,r){const{node:i}=t;return t.more?{id:i.id,label:`… ${t.more.hidden} more`,depth:t.depth,childCount:0,internalChildCount:0,expandable:!1,more:{hidden:t.more.hidden}}:{id:i.id,label:i.label,...i.typeLabel===void 0?{}:{typeLabel:i.typeLabel},...i.role===void 0?{}:{role:i.role},depth:t.depth,childCount:i.childIds.length,internalChildCount:r.foldedInternalCount(i.id),expandable:t.hasChildren,...t.hasChildren?{expanded:r.isExpanded(t)}:{},...r.isInternal(i.id)?{internal:!0}:{},...r.isComponentRoot(i.id)?{componentRoot:!0}:{}}}let tyn=[];function ryn(){return tyn}const J$e=new Set;let EY=null;function nyn(t){return J$e.add(t),()=>{J$e.delete(t)}}function iyn(){return EY||(EY=Promise.all([...J$e].map(t=>Promise.resolve().then(t))).then(()=>{}).finally(()=>{EY=null}),EY)}const Bme=new Map;let zHt=0;const W$e=new Set;function GCt(){zHt++;for(const t of[...W$e])t()}function HPn(t,r){const i={store:r};return Bme.set(t,i),GCt(),()=>{Bme.get(t)===i&&(Bme.delete(t),GCt())}}function uee(t){return t===null?null:Bme.get(t)?.store??null}function UHt(t){return W$e.add(t),()=>{W$e.delete(t)}}function vye(){return zHt}const syn={count:0,surface:null,visible:!1};function oyn(t){return t==="three"||t==="canvas"||t==="dom"?t:null}function QCt(t){switch(t){case"scene":case"world":return{kind:"composition"};case"story":return{kind:"story"};case"asset":return{kind:"artifact"};case"document":return{kind:"data"};default:return{kind:"unknown"}}}function ayn(t){if(t===null)return{kind:"unknown"};const r=FA().find(l=>l.descriptor.id===t);if(!r)return{kind:"unknown"};const i=r.descriptor.presentation?.()??null,a=QCt(i?.kind);return a.kind!=="unknown"?a:QCt(r.descriptor.kind)}function cyn(t){return t instanceof Zh?t.childAdapters().some(r=>r.kind==="three"):!t.rects&&typeof t.hierarchy.object3D=="function"}function VHt(t,r,i,a){const l=By(t),d=lLe(t)&&cyn(l)?"three":null,_=t.playState,g=t.selectedEntityIds.size;if(g===0)return{documentId:r,chrome:a,subject:i,surface:d,selection:syn,play:_};const b=W4t(l,t.selectedEntityIds);return{documentId:r,chrome:a,subject:i,surface:d,selection:{count:g,surface:oyn(b?.kind),visible:H4t(t,b)},play:_}}function JHt(t,r,i="document"){const a=ayn(r),l=Pw(r);if(l===null)return VHt(t,r,a,i);const d=l.selection().length;return{documentId:r,chrome:i,subject:a,surface:"three",selection:{count:d,surface:d>0?"three":null,visible:!0},play:t.playState}}function lyn(t){const r=I_();return r!==null?JHt(t,r):VHt(t,null,{kind:"unknown"},"document")}function bP(t){return uee(I_())??t}function uyn(t){return t.surface!=="three"?!1:t.selection.count===0?!0:t.selection.surface==="three"&&t.selection.visible}function fyn(t){return uyn(t)?hIt(t.documentId)===null?"gizmo":"modal":"none"}function GPn(t){return t.surface==="three"&&t.selection.count>0&&t.selection.surface==="three"&&t.selection.visible}function WHt(t){return t.chrome==="embedded"||t.subject.kind==="story"||t.subject.kind==="artifact"}function QPn(t,r){return WHt(t)?!0:t.subject.kind==="data"&&!r}function KPn(t){return t.chrome==="document"&&WHt(t)}const dyn=500;function KCt(t){const r=globalThis,i=r.requestIdleCallback;if(typeof i=="function"){const l=i.call(globalThis,t,{timeout:dyn});return()=>r.cancelIdleCallback?.call(globalThis,l)}const a=setTimeout(t,0);return()=>clearTimeout(a)}const pyn=1,IP=[];function H$e(t){const r=IP.indexOf(t);r>=0&&IP.splice(r,1),t.renderer.dispose(),t.renderer.forceContextLoss(),t.canvas.remove()}function _yn(t,r){const i=document.createElement("canvas");i.style.width="100%",i.style.height="100%",i.style.display="block",i.width=Math.max(1,t),i.height=Math.max(1,r);const a={canvas:i,renderer:UP(new $P({canvas:i,antialias:!0,alpha:!0})),leased:!0,lost:!1,onContextLost:null};return i.addEventListener("webglcontextlost",()=>{a.lost=!0,a.onContextLost?.();const l=IP.indexOf(a);l>=0&&IP.splice(l,1),a.leased||H$e(a)}),IP.push(a),a}function myn(t){const{renderer:r}=t;r.setRenderTarget(null),r.setScissorTest(!1),r.setViewport(0,0,Math.max(1,t.canvas.width),Math.max(1,t.canvas.height)),r.setScissor(0,0,Math.max(1,t.canvas.width),Math.max(1,t.canvas.height)),r.autoClear=!0,r.autoClearColor=!0,r.autoClearDepth=!0,r.autoClearStencil=!0,r.sortObjects=!0,r.localClippingEnabled=!1,r.clippingPlanes=[],r.shadowMap.enabled=!1,r.shadowMap.autoUpdate=!0,r.toneMapping=Nkt,r.toneMappingExposure=1,r.outputColorSpace=hv,r.xr.enabled=!1,r.setAnimationLoop(null),r.setClearColor(0,0),r.clear(!0,!0,!0),r.info.reset()}function YPn(t,r,i){let a=IP.find(_=>!_.leased&&!_.lost);a||(a=_yn(t,r)),a.leased=!0,a.onContextLost=i??null;const l=a;let d=!1;return{canvas:l.canvas,renderer:l.renderer,release(){if(d)return;if(d=!0,l.leased=!1,l.onContextLost=null,l.canvas.remove(),l.lost){H$e(l);return}myn(l);const _=IP.filter(g=>!g.leased&&!g.lost);for(const g of _.slice(pyn))H$e(g)}}}function hyn(){return{active:IP.filter(t=>t.leased&&!t.lost).length,idle:IP.filter(t=>!t.leased&&!t.lost).length}}const gyn=["three","canvas","dom"];function YCt(t){return t.provenance?.source==="boundary"}function yyn(t){return gyn.includes(t)?t:null}function vyn(){const t=n0e(),r=AE()?.descriptor.provenance?.rootId,i=r?v1()?.regions.find(_=>_.id===r):void 0,a=t?.adapter&&r&&i?{worldId:r,surface:i.surface,adapter:t.adapter}:null,l=XPt();if(!l)return a?[a]:[];if(l instanceof Zh){const _=l.childAdapters().filter(g=>g.role==="world"&&!YCt(g.adapter)).map(g=>({worldId:g.worldId,surface:yyn(g.kind),adapter:g.adapter}));return a?[a,..._.filter(g=>g.worldId!==r)]:_}if(YCt(l))return a?[a]:[];const d={worldId:"root",surface:ebe(),adapter:l};return a?[a,d]:[d]}const $me=new Map,byn=new Set;function XCt(){for(const t of byn)t()}function XPn(t){return $me.set(t.id,t),XCt(),()=>{$me.get(t.id)===t&&($me.delete(t.id),XCt())}}function Ayn(){return[...$me.values()]}function OQe(t){return t.length===0?void 0:t.some(i=>i.hiddenBy===null)?null:[...t].sort((i,a)=>a.area-i.area)[0]?.hiddenBy??null}function Syn(t){return t.filter(r=>r.hiddenBy!==null).sort((r,i)=>i.area-r.area).map(r=>`${r.label} (${r.hiddenBy}, ${r.inlineHiding===null?"from an ancestor or a stylesheet":r.failsafeEligible?"its own inline style, unowned":"its own inline style, by a declared owner"}, ${Math.round(r.area)}px²)`)}function HHt(t){return t.filter(r=>r.failsafeEligible&&r.inlineHiding!==null)}function xyn(t){return t.some(r=>r.hiddenBy!==null)?HHt(t).length>0:null}const wyn=4e3;function Cyn(t){const r=t.deadlineMs??wyn;if(t.framesProduced<=0)return{fire:!1};if(t.hiddenForMs===null||t.hiddenForMs<r)return{fire:!1};if(OQe(t.canvases)===null)return{fire:!1};const i=[...HHt(t.canvases)].sort((a,l)=>l.area-a.area)[0];return i?{fire:!0,target:i,ledger:`canvas reveal FAILSAFE FIRED — the "${i.label}" canvas was still hidden by its own inline ${i.inlineHiding} (${i.hiddenBy}) ${Math.round(t.hiddenForMs/1e3)}s after frames started arriving, so the editor cleared that style to put the picture on screen. THIS IS A DEFECT, not a feature: the mount path that hid this canvas never ran its own reveal, and the failsafe fires ONCE — a second mount in this state stays blank. Report it upstream with the mount that owns this canvas.`}:{fire:!1}}const qme=new Map;function ZPn(t){return qme.set(t.id,t),()=>{qme.get(t.id)===t&&qme.delete(t.id)}}function Eyn(){return[...qme.values()]}const jRe=10,y_e=5e3;function Tyn(t){if(t.mode!=="edit")return{status:"ok",detail:"not in Edit mode — the invariant does not apply while playing"};if(t.loops===null)return{status:"unmeasured",detail:"nothing enumerated this session’s game loops",fix:"the session vitals collector must report a loop fact per live runtime (play, ingest, module)"};const r=t.designTimeSurfaces,i=[...t.loops.filter(g=>g.running).map(g=>g.name),...(r??[]).filter(g=>g.advanced===!0&&g.transportAdvanced!==!0).map(g=>`${g.label} (design-time surface)`)],a=(r??[]).filter(g=>g.advanced===!0&&g.transportAdvanced===!0);if(i.length>0)return{status:"violation",detail:`Edit mode, but content time is advancing in ${i.length} place(s): ${i.join(", ")}`,cause:`content time is advancing while the editor is in Edit: ${[...i].sort().join(", ")}`,missing:"authoring is happening on top of moving content: the thing under the gizmo moves while you edit it, a pose you are reading is a frame of an animation rather than what the source says, and every other instrument reports a still editor",fix:"one time policy at the shared viewport stack — presentation (orbit, turntable, dressing) keeps running while CONTENT time (mixers, useFrame, simulation) is held at design time"};const l=(r??[]).filter(g=>g.advanced===null),d=t.loops.map(g=>g.name).join(", ");if(r===null)return{status:"unmeasured",detail:`${t.loops.length} enumerated loop(s) stopped (${d}), but nothing enumerated this session's design-time surfaces`,fix:"the session vitals collector must enumerate the Object3DDocumentViewport stack’s live sessions"};if(l.length>0)return{status:"unmeasured",detail:`${t.loops.length} enumerated loop(s) stopped (${d}), and ${r.length-l.length} design-time surface(s) still — but ${l.length} publish no content clock: `+l.map(g=>`${g.label} (${g.unavailable??"no reason given"})`).join(", "),fix:"each design-time surface host must publish its own content clock (`Object3DDocumentSession.contentClock`) so this row can speak for it"};const _=a.length===0?"":`; ${a.length} advancing under an engaged transport (${a.map(g=>g.label).join(", ")})`;return{status:"ok",detail:`Edit is static — ${t.loops.length} enumerated loop(s) stopped (${d}), and ${r.length} design-time surface(s) hold their content time${_}`}}function kyn(t){return t.presentedThreeRoots===null?{status:"unmeasured",detail:"nothing enumerated which three roots this session presents",fix:"the session vitals collector must read the mounted roots off the active authoring surface"}:t.presentedThreeRoots.length<=1?{status:"ok",detail:`the scene presents ${t.presentedThreeRoots.length} three root(s)`}:{status:"violation",detail:`the scene presents ${t.presentedThreeRoots.length} three roots at once: ${t.presentedThreeRoots.join(", ")}`,cause:`the scene presents more than one three root: ${[...t.presentedThreeRoots].sort().join(", ")}`,missing:"a scene has ONE root by the authoring ontology — scenes swap inside it. Two presented at once means selection, framing and the gizmo are working over a tree no single document owns",fix:"declare one three root and swap SCENES inside it (ARCHITECTURE-CORE §Roots); a second world belongs behind its own document"}}function Iyn(t){return t.canvasHiddenBy===void 0?{status:"unmeasured",detail:"no canvas was found to measure",fix:"the session vitals collector must enumerate this session’s canvases before this can be checked"}:t.framesProduced===null?{status:"unmeasured",detail:"nothing sampled whether frames are being produced",fix:"the session vitals collector must run its frame sampler before this can be checked"}:t.canvasHiddenBy===null?{status:"ok",detail:"this session presents a revealed canvas"}:t.framesProduced===0?{status:"ok",detail:`every canvas is hidden (largest: ${t.canvasHiddenBy}) and nothing is drawing — not the failsafe's case`}:t.canvasHidesItself===!1?{status:"ok",detail:`every canvas is hidden but none is hiding ITSELF — the workspace is showing a non-canvas document, which is what the user opened: ${(t.hiddenCanvases??[]).join("; ")}`}:{status:"violation",detail:`${t.framesProduced} frame(s) produced in ${t.sampleWindowMs??0}ms while every canvas is hidden and one hides ITSELF: ${(t.hiddenCanvases??[]).join("; ")}`,cause:`frames are being produced while every canvas is hidden and one hides itself (${t.canvasHiddenBy})`,missing:"the session is burning frames onto a surface nobody can see — the user is looking at an empty viewport while every instrument reports a healthy, rendering session",fix:"reveal the canvas as soon as it produces frames — the bounded failsafe in `coverage/canvas-reveal.ts` does it for inline hiding on the canvas itself and says so loudly; hiding from an ancestor or a stylesheet is its owner’s to undo"}}function Dyn(t){return t.directManipulationExpected===!1?{status:"ok",detail:"browser automation is rendering evidence — no person is waiting on direct manipulation"}:t.tabVisible?t.fps===null?{status:"unmeasured",detail:t.fpsUnavailable??"no frame-rate sample exists",fix:"the session vitals collector must sample frame cadence while the tab is visible"}:t.fps>=jRe?{status:"ok",detail:`visible tab rendering at ${t.fps.toFixed(1)}fps`}:{status:"violation",detail:`visible tab rendering at ${t.fps.toFixed(1)}fps, below the ${jRe}fps floor`,cause:`the visible tab is rendering below the ${jRe}fps floor`,missing:"the editor has stopped being a direct-manipulation tool: a drag, a click and a keystroke all land seconds after the user made them",fix:"find the cost with the Profiler’s Overview (long-animation-frame attribution) — main-thread saturation and GPU/compositor cost are separate hunts"}:{status:"ok",detail:"the tab is hidden — a hidden tab is not owed a frame rate"}}function Pyn(t){return t.play===null?{status:"ok",detail:"nothing is playing — the invariant does not apply"}:t.tabVisible?t.play.framesDrawn===null?{status:"unmeasured",detail:t.play.framesUnavailable??"the play session reports no frame count, so nothing can say whether it drew",fix:"the play session’s render loop must expose a frame count (its profiler source carries one only while telemetry is enabled)"}:t.play.framesDrawn>0?{status:"ok",detail:`play has drawn ${t.play.framesDrawn} frame(s)`}:t.play.startedMsAgo<y_e?{status:"ok",detail:`play started ${t.play.startedMsAgo}ms ago and has not drawn yet — inside the ${y_e}ms deadline`}:{status:"violation",detail:`play started ${t.play.startedMsAgo}ms ago and has drawn no frame (deadline ${y_e}ms)`,cause:`play started and no frame has drawn within the ${y_e}ms deadline`,missing:"the user pressed ▶ and the game is not running: the viewport shows whatever was there before, and every other instrument reports a live play session",fix:"find why the run loop never rendered — the console’s own errors from the play session are the first read"}:{status:"ok",detail:"the tab is hidden — the engine hidden-pauses the loop, so no frame is owed"}}const GHt={"edit-mode-static":Tyn,"single-root-scene":kyn,"canvas-revealed":Iyn,"visible-tab-fps-floor":Dyn,"play-drew-a-frame":Pyn},Nyn=Object.keys(GHt);function Oyn(t){return Nyn.map(r=>({id:r,...GHt[r](t)}))}function Fyn(t){if(t.status!=="violation")return null;const r=[`invariant "${t.id}" VIOLATED — ${t.cause??t.id}`];return t.missing&&r.push(` cost: ${t.missing}`),t.fix&&r.push(` fix: ${t.fix}`),r.join(`
|
|
1603
|
-
`)}const G$e=new Set;function Ryn(t){return G$e.add(t),()=>{G$e.delete(t)}}function Myn(){for(const t of[...G$e])try{t()}catch(r){ua.error(`a session-sample subscriber threw: ${String(r)}`,"invariant")}}const Lyn=5e3;let hw={frames:0,since:0},KX=null,Qq=null,$R=null;const YX=new Map;function jyn(t){const r=window.getComputedStyle(t);if(r.display==="none")return"display: none";if(r.visibility==="hidden")return"visibility: hidden";if(Number.parseFloat(r.opacity||"1")===0)return"opacity: 0";const i=t.getBoundingClientRect();return i.width<=0||i.height<=0?"zero-size box":null}const Byn="editor-canvas";function $yn(t){const r=t.style;return r.display==="none"?"display":r.visibility==="hidden"?"visibility":r.opacity!==""&&Number.parseFloat(r.opacity)===0?"opacity":null}function QHt(){return[...document.querySelectorAll("canvas")].map((r,i)=>{const a=r.getAttribute("data-testid"),l=r.getBoundingClientRect();return{label:a??(r.className||`canvas #${i}`),area:Math.max(0,l.width)*Math.max(0,l.height),hiddenBy:jyn(r),inlineHiding:$yn(r),failsafeEligible:a!==Byn}})}function qyn(){const t=Ayn();if(t.length===0)return{framesDrawn:null,framesUnavailable:"no render loop registered a performance source, so nothing counts this session’s frames"};let r=null;for(const i of t){const l=i.profiler.getSnapshot().frames.at(-1);l&&(r=Math.max(r??0,l.id))}return r===null?{framesDrawn:null,framesUnavailable:"the registered render loop records no frames (its profiler has neither profiling nor telemetry enabled)"}:{framesDrawn:r,framesUnavailable:null}}const nR=new Map,TY=new Map;function zyn(){const t=Eyn(),r=new Set,i=t.map(a=>{const{id:l,label:d}=a;r.add(l);let _=null;try{_=a.transportAdvances?.()??null}catch{_=null}const g=TY.get(l);_===null?TY.delete(l):TY.set(l,_);const b=_===null||g===void 0?{}:{transportAdvanced:_!==g};let S;try{S=a.contentClock()}catch(N){return nR.delete(l),{id:l,label:d,advanced:null,unavailable:`its content clock threw: ${String(N)}`,...b}}if(S===null)return nR.delete(l),{id:l,label:d,advanced:null,unavailable:"its content clock is temporarily unavailable",...b};const k=S,w=nR.get(l);return nR.set(l,k),w===void 0?{id:l,label:d,advanced:null,unavailable:"first reading — nothing to compare it against yet",...b}:{id:l,label:d,advanced:k!==w,...b}});for(const a of[...nR.keys()])r.has(a)||nR.delete(a);for(const a of[...TY.keys()])r.has(a)||TY.delete(a);return i}function Uyn(t=Date.now()){const r=rbe(),i=hw.since===0?0:t-hw.since,a=hw.frames,l=i>0&&a>0?a*1e3/i:null,d=r?{startedMsAgo:$R===null?0:t-$R,...qyn()}:null;return{mode:r?"play":"edit",loops:[...U$e().map(_=>({name:`${_.id} session`,running:_.mounted()})),...U$e().map(_=>({name:`${_.id} playing`,running:_.playing()}))],designTimeSurfaces:zyn(),presentedThreeRoots:XPt()?vyn().filter(_=>_.surface==="three").map(_=>_.worldId):null,...(()=>{const _=QHt();return{canvasHiddenBy:OQe(_),canvasHidesItself:xyn(_),hiddenCanvases:Syn(_)}})(),framesProduced:hw.since===0?null:a,sampleWindowMs:hw.since===0?null:i,tabVisible:!document.hidden,directManipulationExpected:navigator.webdriver!==!0,fps:l,fpsUnavailable:l===null?hw.since===0?"the frame sampler has not opened a window yet":"no frame was produced in the sample window":null,play:d}}function KHt(){return Oyn(Uyn())}let Cq=null;const ZCt=new WeakSet;function Vyn(t,r){const i=OQe(t);if(i==null){Cq=null;return}if(Cq===null){Cq=r;return}const a=Cyn({canvases:t,framesProduced:hw.frames,hiddenForMs:r-Cq});if(!a.fire)return;const l=[...document.querySelectorAll("canvas")].find(d=>(d.getAttribute("data-testid")??d.className)===a.target.label);!l||ZCt.has(l)||(ZCt.add(l),a.target.inlineHiding==="display"&&l.style.removeProperty("display"),a.target.inlineHiding==="visibility"&&l.style.removeProperty("visibility"),a.target.inlineHiding==="opacity"&&l.style.removeProperty("opacity"),ua.error(a.ledger,"invariant"))}function Jyn(){const t=KHt();for(const r of t){const i=Fyn(r);if(!i){YX.delete(r.id);continue}if(r.id==="visible-tab-fps-floor"){const a=(YX.get(r.id)??0)+1;if(YX.set(r.id,a),a<3)continue}ua.warn(i,"invariant")}return t}function Wyn(){if(Qq!==null)return eEt;hw={frames:0,since:Date.now()};const t=()=>{hw.frames++,KX=requestAnimationFrame(t)};return KX=requestAnimationFrame(t),Qq=setInterval(()=>{const r=rbe();r&&$R===null&&($R=Date.now()),r||($R=null),Myn(),Vyn(QHt(),Date.now()),Jyn(),hw={frames:0,since:Date.now()}},Lyn),eEt}function Hyn(){hw={frames:0,since:Qq===null?0:Date.now()},$R=null,Cq=null,YX.clear(),nR.clear()}function eEt(){KX!==null&&cancelAnimationFrame(KX),Qq!==null&&clearInterval(Qq),KX=null,Qq=null,hw={frames:0,since:0},$R=null,Cq=null,YX.clear()}let Q$e=null;function Gyn(t){Q$e=t}function FQe(){return Q$e?(Q$e(),!0):!1}let RQe=[];const K$e=new Set;function tEt(t){RQe=t;for(const r of K$e)r()}function Qyn(){return RQe}function Kyn(t){return K$e.add(t),()=>K$e.delete(t)}function Yyn(t){const r=RQe.find(i=>i.id===t);return r?(r.run(),!0):!1}let Y$e=null;function Xyn(t){Y$e=t}const Zyn=/^vgai\.([^.]+)\.(.+)$/;async function e0n(t,r){if(Y$e)return await Y$e(t,r);const i=Zyn.exec(t);if(!i)throw new Error(`No command "${t}". Without the Code-OSS frame there is no command service, so the only commands this editor answers are a view's own verbs, spelled vgai.<view>.<verb> (for example vgai.blender-node-view.view-all).`);const{invokeViewVerb:a}=await Xo(async()=>{const{invokeViewVerb:l}=await Promise.resolve().then(()=>kMr);return{invokeViewVerb:l}},void 0);return a(i[1],i[2],r)}function YHt(t){return Array.from(document.querySelectorAll("[data-workspace-document-id]")).find(r=>r.dataset.workspaceDocumentId===t&&(X9e()===null||r.dataset.workspaceViewId===X9e()))??null}const X$e=["document","header","shelf","rail","outliner","content"],t0n={rail:{part:"properties",view:"vgai.properties",title:"Properties"},outliner:{part:"outliner",view:"vgai.outliner",title:"Outliner"},content:{part:"content",view:"vgai.content",title:"Content"}},r0n={header:{prefix:"document-header",title:"header strip"},shelf:{prefix:"document-shelf",title:"tool shelf"}};function MQe(t){const r=[t.container];for(let i=0;i<r.length;i++)for(const a of r[i].querySelectorAll("[data-vgai-portal]")){const l=a.dataset.vgaiPortal;if(l===void 0)continue;const d=document.querySelector(`[data-vgai-portal-content="${CSS.escape(l)}"]`);d&&!r.includes(d)&&r.push(d)}return r}function n0n(t){return document.querySelector(`[data-vgai-part="${t}"]`)}function i0n(t){const r=t==="rail"||t==="outliner"||t==="content"?t0n[t]:null;if(r){const i=n0n(r.part);if(!i)throw new Error(`The ${r.title} view (${r.view}) is not open, so scope '${t}' has nothing to reach. Open it from the workbench (View: Open View…) and retry — this door reads and drives what is on screen, and reports its absence rather than an empty match list.`);return{container:i,name:t,id:r.view,title:r.title}}return s0n(t)}function s0n(t){const r=AE();if(!r)throw new Error(`No active editor document, so scope '${t}' has nothing to reach. The editor's own views are still readable: scope 'outliner', scope 'rail', and scope 'content'.`);const i=I_()??r.descriptor.id;if(i===Sw)throw new Error("The Game document is out of this door's scope: drive and read a game through its own doors — `game.commands()`/`game.command(n)`/`game.state(n)`, or `page(step)` during play — never through synthetic DOM gestures. The editor's own views around it stay readable while a game is active: scope 'outliner' and scope 'rail'.");const a=YHt(i);if(!a)throw new Error(`The active document's surface is not mounted: ${i} (${r.title}). Present it first (\`editor.present\`) and retry.`);const l=a.closest(".vgai-dock-document")??a;if(t==="document")return{container:l,name:t,id:i,title:r.title};const d=r0n[t],_=l.querySelector(`[data-testid="${d.prefix}:${i}"]`);if(!_)throw new Error(`The active document "${r.title}" (${i}) draws no ${d.title}, so scope '${t}' has nothing to reach. Its whole box is scope 'document'.`);return{container:_,name:t,id:i,title:`${r.title} — ${d.title}`}}function rEt(t,r){return new Error(`Out of scope: ${r}. This step ran in scope '${t.name}' — "${t.title}" (${t.id}) — and reaches ONLY inside it. The other surfaces are named, not walked to: ${X$e.filter(i=>i!==t.name).map(i=>`'${i}'`).join(", ")} (pass \`{ scope }\`). The rest of the page is deliberately unreachable.`)}const nEt=400,iEt="rgb(1, 2, 3)",o0n="rgba(0, 0, 0, 0)";function a0n(t,r){const i=getComputedStyle(t).getPropertyValue(r).trim();if(i==="")return"";const l=t.ownerDocument.createElement("span");l.style.position="absolute",l.style.pointerEvents="none",l.style.visibility="hidden",l.style.backgroundColor=iEt,t.appendChild(l);try{l.style.backgroundColor=`var(${r})`;const d=getComputedStyle(l).backgroundColor.trim();return d===iEt||d===o0n?i:d}finally{l.remove()}}function c0n(t,r){const i=getComputedStyle(t),a={};for(const l of r)a[l]=l.startsWith("--")?a0n(t,l):i.getPropertyValue(l0n(l)).trim();return a}function l0n(t){return t.includes("-")?t:t.replace(/[A-Z]/g,r=>`-${r.toLowerCase()}`)}function sEt(t,r,i){const a=t,l={};for(const S of Array.from(t.attributes))l[S.name]=S.value;const d=a.getBoundingClientRect(),_=t.value,g=t.checked,b=(a.innerText||t.textContent||"").trim();return{index:r,tag:t.tagName.toLowerCase(),text:b.length>nEt?`${b.slice(0,nEt)}…`:b,attributes:l,rect:{x:d.x,y:d.y,width:d.width,height:d.height},...typeof _=="string"?{value:_}:{},...typeof g=="boolean"?{checked:g}:{},...a.hasAttribute("disabled")?{disabled:!0}:{},...i&&i.length>0?{styles:c0n(a,i)}:{}}}function zme(t,r,i){const a=ZHt(t,r),l=a[i];if(!l)throw rEt(t,`${JSON.stringify(r)} matched ${a.length} element(s), so index ${i} does not exist`);if(!MQe(t).some(d=>d.contains(l)))throw rEt(t,`${JSON.stringify(r)} resolved outside the document's container`);return l}function u0n(t){const r=t.getBoundingClientRect();return{bubbles:!0,cancelable:!0,composed:!0,view:window,clientX:r.x+r.width/2,clientY:r.y+r.height/2,button:0,buttons:1}}function f0n(t,r=1){const i=u0n(t),a=Math.max(1,Math.round(r));XHt(t,()=>{for(let l=1;l<=a;l++){const d={...i,detail:l},_={...i,buttons:0,detail:l};t.dispatchEvent(new PointerEvent("pointerdown",{...d,pointerType:"mouse"})),t.dispatchEvent(new MouseEvent("mousedown",d)),t.focus(),t.dispatchEvent(new PointerEvent("pointerup",{..._,pointerType:"mouse"})),t.dispatchEvent(new MouseEvent("mouseup",_)),t.dispatchEvent(new MouseEvent("click",_))}a>=2&&t.dispatchEvent(new MouseEvent("dblclick",{...i,buttons:0,detail:a}))})}function d0n(t,r,i,a){const l=t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement?t:null;if(!l)throw new Error(`Cannot type into a <${t.tagName.toLowerCase()}>: this verb drives a text field. Click the control that opens one first (the Outliner's rename is a double click — \`click(selector, { clicks: 2 })\`), then \`type\` into the field it puts up.`);const d=t instanceof HTMLTextAreaElement?HTMLTextAreaElement.prototype:HTMLInputElement.prototype,_=Object.getOwnPropertyDescriptor(d,"value")?.set,g=S=>{_?_.call(l,S):l.value=S};l.focus();let b=l.value;i&&b!==""&&(l.select?.(),b="",g(b),l.dispatchEvent(new InputEvent("input",{bubbles:!0,composed:!0,inputType:"deleteContentBackward"})));for(const S of[...r]){const k={key:S,bubbles:!0,cancelable:!0,composed:!0};l.dispatchEvent(new KeyboardEvent("keydown",k)),b+=S,g(b),l.dispatchEvent(new InputEvent("input",{bubbles:!0,composed:!0,inputType:"insertText",data:S})),l.dispatchEvent(new KeyboardEvent("keyup",k))}if(a){const S={key:"Enter",code:"Enter",bubbles:!0,cancelable:!0,composed:!0};l.dispatchEvent(new KeyboardEvent("keydown",S)),l.dispatchEvent(new KeyboardEvent("keyup",S))}}function XHt(t,r){const i=Element.prototype,a=i.setPointerCapture,l=i.releasePointerCapture;i.setPointerCapture=()=>{},i.releasePointerCapture=()=>{};try{r()}finally{i.setPointerCapture=a,i.releasePointerCapture=l}}function p0n(t,r,i,a,l={},d=[]){const _=t.getBoundingClientRect(),g=(S,k)=>({bubbles:!0,cancelable:!0,composed:!0,view:window,clientX:_.x+_.width*S,clientY:_.y+_.height*k,button:0,buttons:1,altKey:l.altKey??!1,ctrlKey:l.ctrlKey??!1,metaKey:l.metaKey??!1,shiftKey:l.shiftKey??!1}),b=g(r[0],r[1]);XHt(t,()=>{t.dispatchEvent(new PointerEvent("pointermove",{...b,button:-1,buttons:0,pointerType:"mouse"})),t.dispatchEvent(new MouseEvent("mousemove",{...b,buttons:0})),t.dispatchEvent(new PointerEvent("pointerdown",{...b,pointerType:"mouse"})),t.dispatchEvent(new MouseEvent("mousedown",b)),t.focus();const S=Math.max(1,Math.round(a)),k=[r,...d,i];for(let N=0;N+1<k.length;N++){const P=k[N],j=k[N+1];for(let J=1;J<=S;J++){const X=J/S,G=g(P[0]+(j[0]-P[0])*X,P[1]+(j[1]-P[1])*X);t.dispatchEvent(new PointerEvent("pointermove",{...G,button:-1,pointerType:"mouse"})),t.dispatchEvent(new MouseEvent("mousemove",G))}}const w={...g(i[0],i[1]),buttons:0};t.dispatchEvent(new PointerEvent("pointerup",{...w,pointerType:"mouse"})),t.dispatchEvent(new MouseEvent("mouseup",w)),r[0]===i[0]&&r[1]===i[1]&&t.dispatchEvent(new MouseEvent("click",w))})}function _0n(t,r){if(r)return r;const i=document.activeElement;return i instanceof HTMLElement&&MQe(t).some(a=>a.contains(i))?i:t.container}function ZHt(t,r){try{return MQe(t).flatMap(i=>Array.from(i.querySelectorAll(r)))}catch(i){throw new Error(`Invalid selector ${JSON.stringify(r)}: ${String(i)}`)}}function BRe(t,r){const i=r.selector===void 0?null:zme(t,r.selector,r.index??0);return _0n(t,i)}function m0n(t){return{key:t.key,code:t.code??t.key,bubbles:!0,cancelable:!0,composed:!0,...t.ctrlKey?{ctrlKey:!0}:{},...t.metaKey?{metaKey:!0}:{},...t.shiftKey?{shiftKey:!0}:{},...t.altKey?{altKey:!0}:{}}}function h0n(t,r){const i=[...t.options].map(l=>l.value);if(!i.includes(r))throw new Error(`No option with value ${JSON.stringify(r)} on this <select> — it offers ${i.map(l=>JSON.stringify(l)).join(", ")||"(no options)"}. The value is the option's \`value\`, not its label; \`query\` reports both.`);const a=Object.getOwnPropertyDescriptor(HTMLSelectElement.prototype,"value")?.set;a?a.call(t,r):t.value=r,t.dispatchEvent(new Event("input",{bubbles:!0,composed:!0})),t.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}const $Re=["query","click","drag","key","paste","select","type"];function g0n(t){const r=t?.action;if(!$Re.includes(r))throw new Error(`Unknown document-probe action ${JSON.stringify(r)}. This door has exactly ${$Re.length} verbs: ${$Re.join(", ")} (\`editor.document.*\`).`);const i=t.scope??"document";if(!X$e.includes(i))throw new Error(`Unknown scope ${JSON.stringify(i)}. This door addresses exactly these surfaces: ${X$e.map(a=>`'${a}'`).join(", ")}.`);return i0n(i)}async function y0n(t){const r=g0n(t),i={name:r.name,id:r.id,title:r.title},a=l=>({scope:i,matched:1,elements:[sEt(l,0)]});switch(t.action){case"query":{const l=ZHt(r,t.selector);return{scope:i,matched:l.length,elements:l.slice(0,t.limit??25).map((d,_)=>sEt(d,_,t.styles))}}case"click":{const l=zme(r,t.selector,t.index??0);return f0n(l,t.clicks??1),a(l)}case"type":{const l=BRe(r,t);return d0n(l,t.text,t.replace??!0,t.enter??!0),a(l)}case"drag":{const l=zme(r,t.selector,t.index??0);return p0n(l,t.from,t.to,t.steps??8,{...t.altKey===void 0?{}:{altKey:t.altKey},...t.ctrlKey===void 0?{}:{ctrlKey:t.ctrlKey},...t.metaKey===void 0?{}:{metaKey:t.metaKey},...t.shiftKey===void 0?{}:{shiftKey:t.shiftKey}},t.via??[]),a(l)}case"key":{const l=BRe(r,t),d=m0n(t);return l.dispatchEvent(new KeyboardEvent("keydown",d)),l.dispatchEvent(new KeyboardEvent("keyup",d)),a(l)}case"select":{const l=zme(r,t.selector,t.index??0);if(!(l instanceof HTMLSelectElement))throw new Error(`${JSON.stringify(t.selector)} resolved a <${l.tagName.toLowerCase()}>, not a <select>. This verb sets a dropdown's value; a button or a checkbox takes \`click\`.`);return h0n(l,t.value),a(l)}case"paste":{const l=BRe(r,t),d=new DataTransfer;return d.setData("text/plain",t.text),l.dispatchEvent(new ClipboardEvent("paste",{bubbles:!0,cancelable:!0,composed:!0,clipboardData:d})),a(l)}}}const LQe=[{kind:"agent",title:"Conversations",hotkeyScope:"workspace",selectableText:!0,icon:"users"},{kind:"project-work",title:"Project work",hotkeyScope:"workspace",selectableText:!0,icon:"list"},{kind:"hierarchy",title:"Hierarchy",hotkeyScope:"hierarchy",selectableText:!1,region:"outliner",icon:"outliner"},{kind:"assets",title:"Content",hotkeyScope:"asset-browser",selectableText:!1,icon:"folder-open"},{kind:"asset-library",title:"Asset Library",hotkeyScope:"asset-browser",selectableText:!1,icon:"cubes-stacked"},{kind:"inspector",title:"Inspector",hotkeyScope:"inspector",selectableText:!1,region:"properties",icon:"properties"}];async function v0n(t){const{liveCanvasFrame:r}=await Xo(async()=>{const{liveCanvasFrame:i}=await Promise.resolve().then(()=>Vgn);return{liveCanvasFrame:i}},void 0);return r(t)}async function b0n(...t){const{capturePlayComposite:r}=await Xo(async()=>{const{capturePlayComposite:i}=await Promise.resolve().then(()=>Chn);return{capturePlayComposite:i}},void 0);return r(...t)}async function oEt(){return Xo(()=>Promise.resolve().then(()=>JPt),void 0)}async function A0n(){return Xo(()=>Promise.resolve().then(()=>t2n),void 0)}const S0n=new Set(["solid","clay","unlit","wireframe","normals","overdraw"]);function x0n(t,r=5e3){return gE().some(i=>i.id===t)?Promise.resolve():new Promise(i=>{let a=0,l=()=>{};const d=()=>{clearTimeout(a),l(),i()};l=g0e(()=>{gE().some(_=>_.id===t)&&d()}),gE().some(_=>_.id===t)?d():a=window.setTimeout(d,r)})}async function w0n(t){if(t){if(!gE().some(r=>r.id===t)){const r=t.startsWith(ohe);if(r&&(await(await oEt()).refreshProjectToolContributions(),await x0n(t)),!gE().some(i=>i.id===t)){const i=gE().map(l=>l.id),a=r?(await oEt()).contributionFailureHint(t.slice(ohe.length)):"";throw new Error(`Utility is not registered: ${t}.`+a+` Registered utilities: ${i.length>0?i.join(", "):"(none)"}. A project contributes one by exporting a \`workspace.utility\` tool contribution; its view id is \`tool:<contribution-id>\`.`)}}hE(t)}}async function eGt(t){const r=LQe.map(a=>a.kind),i=r.find(a=>a===t);if(!i)throw new Error(`"${t}" is not a panel of this editor. Panels: ${r.join(", ")}.`);if(Hze(i),!await xE(()=>sPt()===i))throw new Error(`The ${i} panel is not in this workspace's layout, so it could not be focused. Panels: ${r.join(", ")}.`);return i}function C0n(t,r){return xb("workspace:scene"),"workspace:scene"}async function E0n(t){let r=!1;if(await xE(()=>(r=k$e(t.id),r||hCt(t.id)!==null),m9),r)return I_();const i=hCt(t.id);throw i?new Error(i):new Error(`World document is not registered: ${t.id}`)}async function T0n(t,r){const i=_=>_.filter(g=>g.id===r||g.label===r);let a=[];if(!await xE(()=>{const _=Sze(t)?.adapter?.stories;if(!_)return!1;a=_.storiesFor("");const g=i(a);return g.length===1?(_.apply(g[0].id,g[0].id),!0):a.length>0},m9))throw new Error(`The board mounted no stories provider within the wait window; story ${JSON.stringify(r)} was not applied.`);const d=i(a);if(d.length!==1)throw new Error(d.length===0?`No story matches ${JSON.stringify(r)}. This board's stories: ${a.map(_=>_.label).join(", ")||"(none)"}.`:`${JSON.stringify(r)} is ambiguous (${d.length} stories match) — use the story id: ${d.map(_=>_.id).join(" | ")}`)}async function k0n(t,r){const i=await y0e(r.kind,t,r);if(i!==null)return i;let a=!1;if(await xE(()=>(a=xb(r.id),a||gCt(r.id)!==null),m9),a)return r.story!==void 0&&await T0n(r.id,r.story),r.id;const l=gCt(r.id);throw l?new Error(l):new Error(`Workspace document is not available: ${r.id}`)}async function I0n(t,r){const i=await y0e(r.kind,t,r);if(i===null){const{kind:a,...l}=r,d=pRr();throw new Error(`Nothing in this editor can open a '${a}' document (${JSON.stringify(l)}). Either no package registered an opener for that view address, or the subject does not exist. Registered view addresses: ${d.length>0?d.join(", "):"(none)"}.`)}return i}function D0n(t){const r=H7r();return r===null?"":r.includes(t)?`"${t}" is a kind in this project's document table, not an address — a document opens in the editor registered for its KIND, so address it as { kind: "document", id: "<that table entry's id>" }.`:r.length===0?"":`This project's document table holds ${r.map(i=>`"${i}"`).join(", ")}; each opens as { kind: "document", id: "<the table entry's id>" }.`}async function P0n(t,r){if(!r)return I_();if(!UDr(r.kind))throw new Error(`present-view does not know the document kind "${String(r.kind)}". An EditorView addresses a document by one of: ${dIt.join(", ")}. `+D0n(String(r.kind)));switch(r.kind){case"scene":return C0n();case"world":return E0n(r);case"asset":case"tool":case"document":case"story":case"project-tool":case"generation":return I0n(t,r);case"workspace":return k0n(t,r)}}function N0n(t){const r=t.indexOf(",");return{base64:r>=0?t.slice(r+1):t,mimeType:"image/png"}}const aEt=YHt;function O0n(t,r,i){if(!i?.degenerate)return null;const a=wQe();return!a||!r.contains(a)?null:`This door photographs the "${t}" document, which for a live three ingest holds the GAME'S own canvas — created without \`preserveDrawingBuffer\`, so its pixels can only be read from inside the game's own render pass. This game did not draw inside that window (a render-on-demand world sitting idle, or a loop the Edit-tab input gate has frozen), so the frame came back BLANK (${i.warning??"essentially one flat colour"}) — a PNG that reads as a real image. The editor's own renderer is drawing this same world in the Scene viewport (the mount adopts the captured scene), so capture \`workspace:scene\` instead — or drive the game until it renders and ask again.`}async function F0n(t,r){const i=AE();if(!i)throw new Error("No active editor document to capture.");const{descriptor:a,title:l}=i,d=ute(t),_={id:a.id,title:l,kind:a.kind,...a.provenance?.sourcePath?{sourcePath:a.provenance.sourcePath}:{},...a.provenance?.rootId?{rootId:a.provenance.rootId}:{}},g=Pw(a.id);if(g){const w=g.captureImage(r);if(!w)throw new Error(`Object3D document could not be captured: ${a.id}`);return{...N0n(w),document:_,view:d,source:"object3d-document"}}const b=a.id===Sw?jHt()??aEt(a.id):aEt(a.id);if(!b)throw new Error(`Active document surface is not mounted: ${a.id}`);const S=await b0n(b,{canvasFrame:v0n,includeDocumentStyles:a.id!==Sw}),k=O0n(a.id,b,S.flatness);if(k)throw new Error(k);return{base64:S.base64,mimeType:S.mimeType,document:_,view:d,source:a.id===Sw?"game-composite":a.id==="workspace:scene"?"scene-viewport":"document-composite",layers:S.layers,...S.flatness?{flatness:S.flatness}:{}}}function R0n(t){return t?Pw(t):null}function M0n(t,r,i){i!==void 0&&(r?r.setGrid(i):t.showGrid!==i&&t.toggleGrid())}function L0n(t,r,i,a){i&&(r?(r.setSkeleton(i==="skeleton"),r.setBounds(i==="bounds"),i==="skeleton"||i==="bounds"?r.setMode("solid"):r.setMode(i)):S0n.has(i)?t.setShadingMode(i):a.push(`Diagnostic ${i} is unavailable for this document.`))}function j0n(t,r,i,a){if(i){if(typeof i!="string"){r?r.setCameraPose(i.position,i.target,i.fov):t.setCameraPose(i.position,i.target,i.fov);return}r&&i==="perspective"?(r.setProjection("perspective"),r.frame()):r&&i!=="perspective"?r.setViewPreset(i):i!=="isometric"?t.setViewPreset(i):a.push("Isometric camera is unavailable for this document.")}}function B0n(t,r,i,a){i.selection?.focus||i.viewport?.frame==="selection"?r&&!r.frameSelection()?a.push("The requested selection could not be framed."):r||t.focusOnSelection():i.viewport?.frame==="document"&&(r?r.frame():a.push("Document framing is unavailable for this document."))}function $0n(t,r,i,a){i.selection&&(r?r.select(i.selection.ids):t.selectMultiple(i.selection.ids)),M0n(t,r,i.viewport?.grid),L0n(t,r,i.viewport?.diagnostic,a),j0n(t,r,i.viewport?.camera,a),B0n(t,r,i,a)}async function bye(t,r,i={}){if(r?.version!==1)throw new Error("present-view requires EditorView version 1.");const a=Object.keys(r).filter(k=>!Y1t.includes(k));if(a.length>0)throw new Error(`present-view does not know ${a.map(k=>`"${k}"`).join(", ")}. An EditorView carries: ${Y1t.join(", ")}. A document's own address (kind, and the fields that kind reads) goes under "document".`);const l=ute(t);if(r.style!==void 0){const k=lU().map(w=>w.id);if(!k.includes(r.style))throw new Error(`present-view requires a style of ${k.join(", ")}, got ${String(r.style)}.`);nUe(r.style)}if(r.workspace!==void 0){if(!SZ(r.workspace))throw new Error(`present-view requires a workspace of ${Yze().join(", ")}, got ${String(r.workspace)}.`);if(wS()!==r.workspace){const k=vPt();CS(r.workspace),await Promise.race([k,new Promise(w=>setTimeout(w,3e3))])}}const d=[];r.keymap!==void 0&&r.keymap!==uI()&&d.push(`Keymap "${r.keymap}" was not applied — a view reports the keymap, it does not set it. This project is on "${uI()}" (its adapter's declaration, or its own settings).`);const _=await P0n(t,r.document);await w0n(r.utility);const g=R0n(_);if(g&&_&&await MOr(_),!g&&r.selection?.ids.length&&(r.document?.kind==="scene"||r.document?.kind==="world")){const k=r.selection.ids;if(!await xE(()=>k.every(N=>By(t).hierarchy.node(N)!==null),m9))throw new Error(`Shared view selection is not available: ${k.join(", ")}`)}_&&I_()!==_&&xb(_),$0n(t,g,r,d),r.panel!==void 0&&await eGt(r.panel);const b=_It(r,window.location.href);i.updateUrl!==!1&&window.history.replaceState(window.history.state,"",b);const S={view:r,url:b,warnings:d};return(i.origin??"agent")==="agent"&&(await A0n()).showEditorPresentationNotice({presented:S,previousView:l}),S}const Aye=new Map;let tGt=0;const Z$e=new Set;function rGt(){tGt+=1;for(const t of Z$e)t()}function q0n(t,r,i){const a=Aye.get(t);a&&a.assetPath===r&&a.actions.length===i.length&&a.actions.every((l,d)=>l===i[d])||(Aye.set(t,{assetPath:r,actions:i}),rGt())}function z0n(t){Aye.delete(t)&&rGt()}function U0n(t){const r=[];for(const i of Aye.values())i.assetPath===t&&r.push(...i.actions);return r}function V0n(t){return Z$e.add(t),()=>Z$e.delete(t)}function cEt(){return tGt}const J0n=[],lEt=new Set;let W0n=0;function H0n(t){for(const r of J0n)if(r.match(t))return r;return null}function G0n(t){return lEt.add(t),()=>{lEt.delete(t)}}function uEt(){return W0n}const z_={open:{id:"project-asset.open",shortcut:"Enter"},rename:{id:"project-asset.rename",shortcut:"F2"},move:{id:"project-asset.move",shortcut:null},duplicate:{id:"project-asset.duplicate",shortcut:"Mod+D"},delete:{id:"project-asset.delete",shortcut:"Delete"},copyPath:{id:"project-asset.copy-path",shortcut:"Mod+Shift+C"},reveal:{id:"project-asset.reveal",shortcut:null},refresh:{id:"project-asset.refresh",shortcut:"Mod+R"},import:{id:"project-asset.import",shortcut:null},createFolder:{id:"project-asset.create-folder",shortcut:"Mod+Shift+N"}};function nGt(t){return`vgai:project-content:v1:${t}`}const fP=[],eqe=new Set,kY=new Map;let iGt=0;function qRe(){iGt++;for(const t of eqe)t()}function Q0n(t){const r=fP.findIndex(i=>i.owner===t.owner&&i.id===t.id);if(r>=0){const[i]=fP.splice(r,1);i&&(kY.get(i)?.(),kY.delete(i))}return fP.push(t),fP.sort((i,a)=>(i.order??0)-(a.order??0)),kY.set(t,t.subscribe(qRe)),qRe(),()=>{const i=fP.indexOf(t);i<0||(fP.splice(i,1),kY.get(t)?.(),kY.delete(t),qRe())}}const K0n=[];function Y0n(){return fP.length===0?K0n:fP}function sGt(t){return eqe.add(t),()=>{eqe.delete(t)}}function Sye(){return iGt}function oGt(t){for(const r of fP){const i=r.entries({components:[t],surface:null})[0];if(i)return{source:r,entry:i}}return null}function X0n(){const t=q0e();return t?{path:t.path,name:t.name,kind:t.kind,origin:t.origin??"project",...t.sourcePath?{sourcePath:t.sourcePath}:{}}:null}function Z0n(t,r){return Xe.useEffect(()=>()=>z0n(t),[t]),Xe.useCallback(i=>{r!==null&&q0n(t,r,i)},[t,r])}function evn({id:t,title:r,file:i,tool:a,Component:l}){Xe.useSyncExternalStore($0e,kZ),Xe.useSyncExternalStore(Yye,T8,T8),Xe.useSyncExternalStore(Zye,k8,k8);const d=X0n(),_=Z0n(t,d?.path??null),g=Xe.useRef(null),b=Xe.useCallback(k=>{g.current?.(),g.current=k===null?null:D3t(`building ${k.replace(/^building /,"")}`)},[]);Xe.useEffect(()=>()=>g.current?.(),[]);const S=Xe.useCallback(k=>az({...k,id:`contribution:${t}:${k.title}`,...k.tone==="warning"?{fades:!0}:{}}),[t]);return z.jsxs("div",{"data-testid":`asset-inspector-tool-${t}`,style:{padding:8,borderTop:"1px solid var(--vgai-structural-divider)",marginTop:4},children:[z.jsxs("div",{style:{...RFr,marginBottom:4},children:[z.jsx(So,{icon:yb.tool.extension,tone:"muted",style:{marginRight:4}}),r]}),z.jsx(Mze,{file:i,children:z.jsx(l,{...a?{tool:a}:{},contributionId:t.slice(t.lastIndexOf(":")+1),client:b0e(),surfaces:wze,account:mze(),play:Xye(),asset:d,setActions:_,notify:S,work:b})})]})}function tvn(t,r){if(r<=0)return[];if(t.length===0)return Array.from({length:r},()=>0);const i=new Array(r),a=t.length/r;let l=0;for(let d=0;d<r;d++){const _=Math.floor(d*a),g=Math.max(_+1,Math.floor((d+1)*a));let b=0;for(let S=_;S<g;S++)b=Math.max(b,Math.abs(t[S]??0));i[d]=b,l=Math.max(l,b)}return l<=1e-8?i.fill(0):i.map(d=>d/l)}const aGt=32,tqe=new Set,fEt=new Map,dEt=new Map;let qR=null,XX=null,cGt=0,rqe=0,Kq=0,J8=0,pEt=!1,AP={url:null,progress:0,playing:!1};function rvn(){for(const t of tqe)t()}function Qz(t){AP.url===t.url&&AP.playing===t.playing&&Math.abs(AP.progress-t.progress)<.002||(AP=t,rvn())}function jQe(){return qR??=new AudioContext,qR}function nvn(){if(pEt||typeof window>"u")return;pEt=!0;const t=()=>{if(!qR)return;const r=AP.url,i=J8;qR.resume().then(()=>{r&&i===J8&&!XX&&qR?.state==="running"&&fGt(r,i)})};window.addEventListener("pointerdown",t,{capture:!0}),window.addEventListener("keydown",t,{capture:!0})}function BQe(){if(Kq&&typeof cancelAnimationFrame=="function"&&cancelAnimationFrame(Kq),Kq=0,!XX)return;const t=XX;XX=null,t.onended=null;try{t.stop()}catch{}t.disconnect()}function lGt(){if(Kq=0,!AP.playing||!qR||rqe<=0)return;const t=Math.min(1,(qR.currentTime-cGt)/rqe);Qz({url:AP.url,progress:t,playing:t<1}),t<1&&typeof requestAnimationFrame=="function"&&(Kq=requestAnimationFrame(lGt))}function ivn(t,r,i){if(i!==J8)return;BQe();const a=jQe(),l=a.createBufferSource(),d=a.createGain();d.gain.value=1,l.buffer=t,l.connect(d),d.connect(a.destination),l.onended=()=>{i===J8&&Qz({url:r,progress:1,playing:!1})},l.start(),XX=l,cGt=a.currentTime,rqe=t.duration,Qz({url:r,progress:0,playing:!0}),typeof requestAnimationFrame=="function"&&(Kq=requestAnimationFrame(lGt))}async function uGt(t){const r=fEt.get(t);if(r)return r;const i=(async()=>{const a=await fetch(t);if(!a.ok)throw new Error(`Audio preview could not read ${t}.`);const l=await a.arrayBuffer();return jQe().decodeAudioData(l.slice(0))})().catch(()=>null);return fEt.set(t,i),i}async function fGt(t,r){nvn();const i=await uGt(t);if(r!==J8)return;if(!i){Qz({url:t,progress:0,playing:!1});return}const a=jQe();a.state==="suspended"&&(await a.resume(),r!==J8)||a.state==="running"&&ivn(i,t,r)}function svn(t){return tqe.add(t),()=>tqe.delete(t)}function ovn(){return AP}function avn(t){const r=++J8;BQe(),Qz({url:t,progress:0,playing:!0}),fGt(t,r)}function cvn(t){t&&AP.url!==t||(J8+=1,BQe(),Qz({url:null,progress:0,playing:!1}))}function lvn(t,r=aGt){const i=`${t}#${r}`,a=dEt.get(i);if(a)return a;const l=uGt(t).then(d=>d?tvn(d.getChannelData(0),r):Array.from({length:r},()=>0));return dEt.set(i,l),l}const _Et=16,uvn=3e3,fvn=500;function e4n(t,r){return r-t>=fvn}function t4n(t){let r=!1;return t.traverse(i=>{!r&&Z8(i,"gaussianSplat")&&(r=!0)}),r}function dvn(t){t.autoUpdate=!1,t.sortDirty=!1,t.updateTimeoutId!==-1&&(clearTimeout(t.updateTimeoutId),t.updateTimeoutId=-1),t.sortTimeoutId!==-1&&(clearTimeout(t.sortTimeoutId),t.sortTimeoutId=-1);let r=uvn;const i=()=>{if(t.sorting){r>0?(r-=_Et,setTimeout(i,_Et)):console.warn("SparkRenderer did not become idle; skipped worker termination.");return}t.dispose()};i()}const v_e=128;let Ume=null;const pvn=new Set(["glb","gltf","fbx","obj","dae","stl","ply","spz","bvh","3ds"]);function $Qe(t){const r=t.split(/[?#]/,1)[0].toLowerCase(),i=r.slice(r.lastIndexOf(".")+1);return pvn.has(i)?i:void 0}class _vn{renderer;scene;camera;cache=new Map;pending=new Map;sparkRenderer=null;constructor(){const r=document.createElement("canvas");r.width=v_e,r.height=v_e,this.renderer=UP(new $P({canvas:r,alpha:!0,antialias:!0,preserveDrawingBuffer:!0})),this.renderer.setSize(v_e,v_e),this.renderer.setPixelRatio(1),this.renderer.outputColorSpace=hv,this.renderer.toneMapping=u9,this.renderer.toneMappingExposure=1,this.scene=new Mye,Ree(this.scene,this.renderer),this.scene.add(new vIr(16777215,.8*W6t));const i=new kq(16777215,1.5);i.position.set(3,5,4),this.scene.add(i);const a=new kq(16772829,.4);a.position.set(-3,-1,2),this.scene.add(a),this.camera=new Bye(35,1,.01,1e3)}async render(r){const i=typeof r=="string"?{url:r}:r,a=i.format??$Qe(i.url);if(!a)throw new Error(`No thumbnail loader for ${i.url}`);const l={...i,format:a},d=JSON.stringify(l),_=this.cache.get(d);if(_)return _;const g=this.pending.get(d);if(g)return g;const b=this._render(l);this.pending.set(d,b);try{const S=await b;return this.cache.set(d,S),S}finally{this.pending.delete(d)}}async _render(r){const i=yvn(await gvn(r));if(this.scene.add(i),r.format==="spz"&&!this.sparkRenderer){const{SparkRenderer:w}=await Xo(async()=>{const{SparkRenderer:N}=await import("./spark.module-DVeR0ywZ.js");return{SparkRenderer:N}},__vite__mapDeps([45,6,3,2,4,1,8,9,10,11]));this.sparkRenderer=new w({renderer:this.renderer,enableLod:!1}),this.scene.add(this.sparkRenderer)}const a=hvn(i);if(a.isEmpty())throw this.scene.remove(i),new Error("Model contains no previewable geometry.");const l=a.getCenter(new Tc),d=a.getBoundingSphere(new Ekt),_=this.camera.fov*Math.PI/180,g=Math.max(d.radius,1e-4)/Math.sin(_/2)*1.18,b=new Tc(.65,.45,.65).normalize();this.camera.position.set(l.x+g*b.x,l.y+g*b.y,l.z+g*b.z),this.camera.lookAt(l),this.camera.near=g*.01,this.camera.far=g*20,this.camera.updateProjectionMatrix(),r.background==="neutral"?this.renderer.setClearColor(2106410,1):this.renderer.setClearColor(0,0),this.renderer.clear(),this.renderer.render(this.scene,this.camera);const S=mvn(this.renderer.domElement,r.background==="neutral"),k=r.output==="webp"?S.toDataURL("image/webp",.86):S.toDataURL("image/png");return this.scene.remove(i),i.traverse(w=>{Z8(w,"gaussianSplat")&&w.dispose();const N=w;if(N.geometry&&N.geometry.dispose(),N.material){const P=Array.isArray(N.material)?N.material:[N.material];for(const j of P)"map"in j&&j.map instanceof oP&&j.map.dispose(),"normalMap"in j&&j.normalMap instanceof oP&&j.normalMap.dispose(),"emissiveMap"in j&&j.emissiveMap instanceof oP&&j.emissiveMap.dispose(),"aoMap"in j&&j.aoMap instanceof oP&&j.aoMap.dispose(),"roughnessMap"in j&&j.roughnessMap instanceof oP&&j.roughnessMap.dispose(),"metalnessMap"in j&&j.metalnessMap instanceof oP&&j.metalnessMap.dispose(),j.dispose()}}),k}dispose(){this.sparkRenderer&&(this.scene.remove(this.sparkRenderer),dvn(this.sparkRenderer),this.sparkRenderer=null),this.renderer.dispose(),this.renderer.forceContextLoss(),this.cache.clear(),Ume=null}}function mvn(t,r){const i=document.createElement("canvas");i.width=t.width,i.height=t.height;const a=i.getContext("2d",{willReadFrequently:!0});if(!a)return t;a.drawImage(t,0,0);const l=a.getImageData(0,0,i.width,i.height),d=new Uint8Array(i.width*i.height);let _=0;for(let w=0;w<d.length;w++){const N=w*4;(r?Math.abs(l.data[N]-32)>3||Math.abs(l.data[N+1]-36)>3||Math.abs(l.data[N+2]-42)>3:l.data[N+3]>8)&&(d[w]=1,_++)}const g=_/d.length;if(g<1e-4)return i;const b=new Uint8ClampedArray(l.data);if(r)for(let w=0;w<d.length;w++){if(!d[w])continue;const N=w*4,P=b[N]*.2126+b[N+1]*.7152+b[N+2]*.0722;if(P>=88)continue;const j=88-P;l.data[N]=Math.min(255,b[N]+j),l.data[N+1]=Math.min(255,b[N+1]+j),l.data[N+2]=Math.min(255,b[N+2]+j)}const S=g<.004?2:g<.02?1:0;let k=d;for(let w=0;w<S;w++){const N=k.slice(),P=new Uint8ClampedArray(l.data);for(let j=1;j<i.height-1;j++)for(let J=1;J<i.width-1;J++){const X=j*i.width+J;if(k[X])continue;const G=[X-1,X+1,X-i.width,X+i.width].find(ue=>k[ue]);if(G===void 0)continue;const ee=X*4,xe=G*4;l.data.set(P.subarray(xe,xe+4),ee),N[X]=1}k=N}return a.putImageData(l,0,0),i}function hvn(t){t.updateWorldMatrix(!0,!0);const r=new xS,i=new xS;return t.traverseVisible(a=>{if(Z8(a,"gaussianSplat")){i.copy(a.getBoundingBox()).applyMatrix4(a.matrixWorld),r.union(i);return}const l=a;l.geometry&&(l.geometry.boundingBox||l.geometry.computeBoundingBox(),l.geometry.boundingBox&&(i.copy(l.geometry.boundingBox).applyMatrix4(a.matrixWorld),r.union(i)))}),r}async function gvn(t){switch(t.format){case"glb":case"gltf":{const r=await fU.loadAsync(t.url);return r.scene.animations=[...r.animations],r.scene}case"fbx":{const{FBXLoader:r}=await Xo(async()=>{const{FBXLoader:i}=await import("./FBXLoader-DzWtiWYm.js");return{FBXLoader:i}},__vite__mapDeps([68,6,49]));return new r().loadAsync(t.url)}case"obj":{const{OBJLoader:r}=await Xo(async()=>{const{OBJLoader:l}=await import("./OBJLoader-8SrBLZ7J.js");return{OBJLoader:l}},__vite__mapDeps([69,6])),i=t.materialUrl??await Avn(t.url),a=new r;if(i){const{MTLLoader:l}=await Xo(async()=>{const{MTLLoader:_}=await import("./MTLLoader-D8SKGOsv.js");return{MTLLoader:_}},__vite__mapDeps([70,6])),d=await new l().loadAsync(i);d.preload(),a.setMaterials(d)}return a.loadAsync(t.url)}case"dae":{const{ColladaLoader:r}=await Xo(async()=>{const{ColladaLoader:l}=await import("./ColladaLoader-CyOCKXko.js");return{ColladaLoader:l}},__vite__mapDeps([71,6])),i=await new r().loadAsync(t.url),a=i.animations;return a&&(i.scene.animations=[...a]),i.scene}case"stl":{const{STLLoader:r}=await Xo(async()=>{const{STLLoader:a}=await import("./STLLoader-U-3fQm8v.js");return{STLLoader:a}},__vite__mapDeps([72,6])),i=await new r().loadAsync(t.url);return new NA(i,new tz({color:7710680,roughness:.75}))}case"ply":{const{PLYLoader:r}=await Xo(async()=>{const{PLYLoader:l}=await import("./PLYLoader-BXUWXVtV.js");return{PLYLoader:l}},__vite__mapDeps([73,6])),i=await new r().loadAsync(t.url);if(i.index||i.hasAttribute("normal"))return i.hasAttribute("normal")||i.computeVertexNormals(),new NA(i,new tz({color:i.hasAttribute("color")?16777215:12112027,vertexColors:i.hasAttribute("color"),roughness:.8,side:vkt}));i.computeBoundingBox();const a=i.boundingBox?.getSize(new Tc).length()??1;return new Yqe(i,new ykt({color:i.hasAttribute("color")?16777215:12112027,vertexColors:i.hasAttribute("color"),size:Math.max(a/220,1e-4),sizeAttenuation:!0}))}case"spz":return $6t(t.url);case"bvh":{const{BVHLoader:r}=await Xo(async()=>{const{BVHLoader:d}=await import("./BVHLoader--2mLoe3e.js");return{BVHLoader:d}},__vite__mapDeps([74,6])),i=await new r().loadAsync(t.url),a=i.skeleton.bones[0];if(!a)throw new Error("BVH contains no skeleton root.");const l=new SP;return l.animations=[i.clip],l.add(a),l}case"3ds":{const{TDSLoader:r}=await Xo(async()=>{const{TDSLoader:i}=await import("./TDSLoader-BtiaQ4S3.js");return{TDSLoader:i}},__vite__mapDeps([75,6]));return new r().loadAsync(t.url)}}}function yvn(t){if(vvn(t))return t;t.updateWorldMatrix(!0,!0);const r=new yIr(t),i=r.geometry.getAttribute("position");if(!i||i.count===0)return r.dispose(),t;r.name="Asset Editor skeleton preview",r.frustumCulled=!1;const a=new SP;return a.name=t.name,a.animations=[...t.animations],a.add(t,r),a.updateWorldMatrix(!0,!0),r.updateMatrixWorld(!0),a}function vvn(t){let r=!1;return t.traverseVisible(i=>{!r&&bvn(i)&&(r=!0)}),r}function bvn(t){const r=t;if(r.isSprite)return r.material.visible;const i=t,a=t,l=t;if(!i.isMesh&&!a.isLine&&!l.isPoints)return!1;const d=t,_=t;if(_.isInstancedMesh&&_.count===0)return!1;const g=Array.isArray(d.material)?d.material:[d.material];if(g.length===0||g.every(S=>!S?.visible))return!1;const b=d.geometry?.getAttribute("position");return!!(b&&b.count>0&&d.geometry.drawRange.count!==0)}async function Avn(t){const r=t.split(/[?#]/,1)[0],i=`${r.slice(0,r.lastIndexOf("."))}.mtl`;try{return(await fetch(i,{method:"HEAD"})).ok?i:void 0}catch{return}}function Svn(){return Ume||(Ume=new _vn),Ume}const qQe={folder:"var(--vgai-asset-icon-folder)",model:"var(--vgai-asset-icon-model)",prefab:"var(--vgai-asset-icon-prefab)",component:"var(--vgai-asset-icon-component)",audio:"var(--vgai-asset-icon-audio)",image:"var(--vgai-asset-icon-image)",video:"var(--vgai-asset-icon-video)",json:"var(--vgai-asset-icon-json)",unknown:"var(--vgai-asset-icon-unknown)",source:"var(--vgai-asset-icon-source)"},xvn={folder:gee,model:dDr,prefab:yee,component:Jkt,audio:iIt,image:KIr,video:uDr,json:oIt,unknown:rDr,source:uIt};function DP({kind:t,size:r=24}){return z.jsx(So,{icon:xvn[t],style:{fontSize:r,color:qQe[t]}})}const wvn=100,Cvn=50,Evn=new N4t(t=>{const r=$Qe(t);return r?Svn().render({url:t,format:r,background:"neutral",output:"webp"}):Promise.reject(new Error(`No model preview loader for ${t}.`))},2);function dGt(t,r){const[i,a]=Xe.useState(null),[l,d]=Xe.useState(!1),[_,g]=Xe.useState(null),[b,S]=Xe.useState(!1);Xe.useEffect(()=>{a(null),d(!1),g(null),S(!1)},[t]),Xe.useEffect(()=>{let w=!1,N=null;return wUe().then(P=>{if(w)return;const j=P.status==="ok"?P.manifest.entries[t.replace(/^\/+/,"")]:void 0;if(!b&&j?.path&&(j.state==="generated"||j.state==="upstream")){g(j.path.startsWith("/")?j.path:`/${j.path}`);return}return N=Evn.request(t,r),N.promise}).then(P=>{!w&&P&&a(P)}).catch(()=>{w||d(!0)}),()=>{w=!0,N?.cancel()}},[b,r,t]);const k=Xe.useCallback(()=>{g(null),S(!0)},[]);return{src:_??i,fromManifest:_!==null,failed:l,rejectManifest:k}}function pGt({url:t}){const r=dGt(t,wvn);return r.failed?z.jsx(DP,{kind:"model"}):r.fromManifest&&r.src?z.jsx("img",{src:r.src,alt:"cached model preview",onError:r.rejectManifest,style:{width:"100%",height:"100%",objectFit:"contain"}}):r.src?z.jsx("img",{src:r.src,alt:"model preview",style:{width:"100%",height:"100%",objectFit:"contain"}}):z.jsx("div",{style:{width:28,height:28,margin:"0 auto",display:"flex",alignItems:"center",justifyContent:"center"},children:z.jsx("div",{className:"vgai-anim-spin",style:{width:16,height:16,border:`2px solid ${bhe[2]}`,borderTopColor:qQe.model,borderRadius:"50%"}})})}function Tvn({url:t,name:r}){const[i,a]=Xe.useState(()=>Array.from({length:aGt},()=>.15)),l=Xe.useSyncExternalStore(svn,ovn);Xe.useEffect(()=>{let g=!1;return lvn(t).then(b=>{g||a(b)}),()=>{g=!0}},[t]);const d=l.url===t,_=d?l.progress:0;return z.jsx("div",{role:"img","aria-label":`${r} waveform preview`,style:{display:"flex",alignItems:"center",gap:1,width:"86%",height:"62%"},children:i.map((g,b)=>{const S=b/i.length<=_;return z.jsx("i",{style:{flex:1,height:`${12+g*88}%`,background:"var(--vgai-asset-icon-audio)",opacity:d&&S?1:.28,borderRadius:1}},b)})})}function a9({kind:t,name:r,variant:i="tile"}){const a=qQe[t],l=i==="cell";return t==="audio"?z.jsxs("svg",{role:"img","aria-label":`${r} waveform preview`,viewBox:"0 0 64 48",width:l?"78%":52,height:l?"78%":44,children:[z.jsx("rect",{width:"64",height:"48",rx:"4",fill:"var(--vgai-bg-inset)"}),Array.from({length:16},(d,_)=>z.jsx("rect",{x:_*4+1,y:24-_*13%18/2,width:"2",height:_*13%18+3,fill:a},_))]}):z.jsxs("svg",{role:"img","aria-label":`${r} ${t} preview`,viewBox:"0 0 52 48",width:l?"66%":48,height:l?"72%":44,children:[z.jsx("rect",{x:"5",y:"3",width:"42",height:"42",rx:"4",fill:"var(--vgai-bg-inset)",stroke:a}),z.jsx("path",{d:"M13 15h26M13 23h18M13 31h22",stroke:a,strokeWidth:"3",strokeLinecap:"round"})]})}function _Gt(t,r,i,a){if(t<=0||r<=0||i<=0||a<=0)return 1;const l=t<=i?Math.floor(i/t):0,d=r<=a?Math.floor(a/r):0,_=Math.min(l,d);return _>=1?_:1/Math.max(Math.ceil(t/i),Math.ceil(r/a))}function r4n(t,r,i,a,l){return t==="fit"?_Gt(r,i,a,l):t}function kvn(t,r,i){const a=Math.max(1,i.sourceWidth??i.width),l=Math.max(1,i.sourceHeight??i.height);t.width=a,t.height=l;const d=t.getContext("2d");if(!d)return;d.imageSmoothingEnabled=!1,d.clearRect(0,0,a,l);const _=mqr(i);if(i.rotated){d.save(),d.translate(i.trimX,i.trimY+_.width),d.rotate(-Math.PI/2),d.drawImage(r,_.x,_.y,_.width,_.height,0,0,_.width,_.height),d.restore();return}d.drawImage(r,_.x,_.y,_.width,_.height,i.trimX,i.trimY,_.width,_.height)}function mGt({sheetUrl:t,frame:r,scale:i,maxEdge:a}){const l=Xe.useRef(null),d=Math.max(1,r.sourceWidth??r.width),_=Math.max(1,r.sourceHeight??r.height),g=a!=null?_Gt(d,_,a,a):i??1,b=Math.max(1,Math.round(d*g)),S=Math.max(1,Math.round(_*g));return Xe.useEffect(()=>{const k=l.current;if(!k)return;const w=new Image;let N=!1;return w.onload=()=>{N||kvn(k,w,r)},w.src=t,()=>{N=!0}},[r,t]),z.jsx("canvas",{ref:l,width:d,height:_,"aria-hidden":!0,style:{width:b,height:S,imageRendering:"pixelated",display:"block"}})}const hGt={fontSize:11,color:od[3],marginBottom:2},Ivn={fontSize:11,color:od[1],wordBreak:"break-all"};function zRe({asset:t}){Xe.useSyncExternalStore(jA,dI,dI);const r={path:t.path,name:t.name,kind:t.kind,origin:t.origin??"project",...t.sourcePath?{sourcePath:t.sourcePath}:{}};return RPt().map(i=>{let a=!1;try{a=i.match(r)}catch(l){console.error(`[tool contributions] ${i.file}'s asset match() threw.`,l)}return a?z.jsx(evn,{id:i.id,title:i.title,file:i.file,tool:i.tool,Component:i.Component},`${i.id}:${i.version}`):null})}function mEt(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function Gh({label:t,value:r}){return z.jsxs("div",{children:[z.jsx("div",{style:hGt,children:t}),z.jsx("div",{style:Ivn,children:r})]})}function Dvn({asset:t}){const r=t.capabilities?.editor==="environment";Xe.useSyncExternalStore(sGt,Sye,Sye);const i=t.componentPreview,a=i?oGt({name:t.name,path:i.sourcePath,surface:i.surface}):null;return z.jsx("div",{"data-testid":"inspector-asset-preview",style:{position:"absolute",inset:0,background:Pze.inset,display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden"},children:a?z.jsx(a.source.Thumbnail,{entry:a.entry,previewRevision:0}):r?z.jsx(a9,{kind:"image",name:t.name,variant:"cell"}):t.kind==="image"?z.jsx(Nvn,{path:t.path,name:t.name}):t.kind==="video"?z.jsx(Pvn,{path:t.path}):t.kind==="model"?z.jsx(pGt,{url:t.path}):z.jsx(a9,{kind:t.kind,name:t.name,variant:"cell"})})}function Pvn({path:t}){return z.jsx("video",{src:t,muted:!0,preload:"metadata",style:{width:"100%",height:"100%",objectFit:"contain"}})}function Nvn({path:t,name:r}){const{sheetPath:i,frameName:a}=U0e(t),[l,d]=Xe.useState(null);return Xe.useEffect(()=>{if(!a){d(null);return}let _=!1;return fetch(`/${dNt(i)}`).then(g=>g.ok?g.text():null).then(g=>{if(_||!g)return;const b=WUe(g);d(b?.frames.find(S=>S.name===a)??null)}).catch(()=>{_||d(null)}),()=>{_=!0}},[a,i]),l?z.jsx(mGt,{sheetUrl:`/${i}`,frame:l,maxEdge:96}):z.jsx("img",{src:t.split("#")[0],alt:r,style:{width:"100%",height:"100%",objectFit:"contain"}})}function Ovn({asset:t}){const[r,i]=Xe.useState(null),{sheetPath:a,frameName:l}=U0e(t.path);return Xe.useEffect(()=>{if(i(null),t.kind!=="image"||t.capabilities?.editor==="environment")return;let d=!1;if(l)return fetch(`/${dNt(a)}`).then(g=>g.ok?g.text():null).then(g=>{if(d||!g)return;const b=WUe(g)?.frames.find(S=>S.name===l);b&&i({w:b.sourceWidth,h:b.sourceHeight})}).catch(()=>{}),()=>{d=!0};const _=new Image;return _.onload=()=>{d||i({w:_.naturalWidth,h:_.naturalHeight})},_.src=t.path.split("#")[0]??t.path,()=>{d=!0}},[t.capabilities?.editor,t.kind,t.path,l,a]),r?z.jsx(Gh,{label:"Dimensions",value:`${r.w} × ${r.h}`}):null}function Fvn(){Xe.useSyncExternalStore(G0n,uEt,uEt);const t=q0e();if(!t)return null;const r=H0n(t),i=t.name.includes(".")?t.name.split(".").pop()??"":"";return r?z.jsxs("div",{"data-testid":"inspector-asset-selection",style:{pointerEvents:"auto",borderBottom:`1px solid ${bhe[1]}`,display:"flex",flexDirection:"column",gap:6},children:[z.jsx(r.View,{asset:t}),z.jsx(zRe,{asset:t})]}):(t.selectionCount??1)===1&&(t.kind==="image"&&!t.path.includes("#")&&t.capabilities?.editor!=="environment"||t.kind==="video"||t.kind==="audio")?z.jsxs(z.Fragment,{children:[z.jsx(ENt,{assetPath:t.path,kind:t.kind,sizeBytes:t.sizeBytes}),z.jsxs("div",{style:{padding:"0 8px",display:"grid",gap:6},children:[t.health&&t.health!=="healthy"&&z.jsx(Gh,{label:"Health",value:t.health}),!!t.healthCodes?.length&&z.jsx(Gh,{label:"Issues",value:t.healthCodes.join(", ")}),t.sourcePath&&z.jsx(Gh,{label:"Imported from",value:t.sourcePath}),!!t.dependencies?.length&&z.jsx(Gh,{label:"Dependencies",value:t.dependencies.join(", ")}),!!t.references?.length&&z.jsx(Gh,{label:"References",value:t.references.map(a=>`${a.ownerPath} ${a.jsonPath}`).join(", ")})]}),z.jsx(zRe,{asset:t})]}):z.jsxs("div",{"data-testid":"inspector-asset-selection",style:{pointerEvents:"auto",padding:8,borderBottom:`1px solid ${bhe[1]}`,display:"flex",flexDirection:"column",gap:6},children:[z.jsx(Ovn,{asset:t}),z.jsx("div",{style:{...hGt,marginBottom:0,textTransform:"uppercase"},children:"Asset"}),z.jsx("div",{style:{fontWeight:600,fontSize:12,color:od[1],wordBreak:"break-all"},children:t.name}),z.jsx(Gh,{label:"Path",value:t.path}),t.componentPreview&&z.jsx(Gh,{label:"Surface",value:t.componentPreview.surface==="canvas"?"2D / Pixi":t.componentPreview.surface==="three"?"3D / Three":t.componentPreview.surface}),t.selectionCount&&t.selectionCount>1&&z.jsxs(z.Fragment,{children:[z.jsx(Gh,{label:"Selection",value:`${t.selectionCount} assets`}),t.selectionTotalBytes!==void 0&&z.jsx(Gh,{label:"Total size",value:mEt(t.selectionTotalBytes)}),t.selectionFormats&&z.jsx(Gh,{label:"Formats",value:t.selectionFormats.join(", ")})]}),i&&z.jsx(Gh,{label:"Format",value:i.toUpperCase()}),t.sizeBytes!==void 0&&z.jsx(Gh,{label:"Size",value:mEt(t.sizeBytes)}),t.capabilities&&z.jsxs(z.Fragment,{children:[z.jsx(Gh,{label:"Runtime readiness",value:t.capabilities.runtimeReady?"Runtime-ready":"Import or conversion required"}),z.jsx(Gh,{label:"Preview",value:t.capabilities.previewable?"Available":"Unsupported"}),z.jsx(Gh,{label:"Placement",value:t.capabilities.placeable?"Placeable":"Not placeable"}),z.jsx(Gh,{label:"Editor",value:Bq(t.capabilities)??"No editor"})]}),t.health&&z.jsx(Gh,{label:"Health",value:t.health}),t.healthCodes&&z.jsx(Gh,{label:"Issues",value:t.healthCodes.join(", ")}),t.dependencies&&z.jsx(Gh,{label:"Dependencies",value:t.dependencies.join(", ")||"None"}),t.references&&z.jsx(Gh,{label:"References",value:t.references.map(a=>`${a.ownerPath} ${a.jsonPath}`).join(", ")||"None"}),t.sourcePath&&z.jsx(Gh,{label:"Imported from",value:t.sourcePath}),!t.componentPreview&&z.jsxs("div",{style:{display:"flex",gap:6},children:[z.jsx(fo,{type:"button","data-command-id":z_.open.id,onClick:()=>window.dispatchEvent(new CustomEvent("editor:open-project-asset",{detail:{path:t.path}})),children:"Open"}),t.selectionCount&&t.selectionCount>1&&z.jsxs(z.Fragment,{children:[z.jsx(fo,{type:"button","data-command-id":z_.move.id,onClick:()=>window.dispatchEvent(new CustomEvent("editor:project-asset-command",{detail:{id:z_.move.id}})),children:"Move selected"}),z.jsx(fo,{type:"button","data-command-id":z_.delete.id,onClick:()=>window.dispatchEvent(new CustomEvent("editor:project-asset-command",{detail:{id:z_.delete.id}})),children:"Delete selected"})]})]}),z.jsx("div",{style:{fontSize:10,color:od[3]},children:"Double-click (or press Enter) in the asset browser to open the full viewer."}),z.jsx(zRe,{asset:t})]})}function Rvn(t){return U0n(t).map(r=>({id:r.id,title:r.title,...r.label===void 0?{}:{label:r.label},placement:"identity",...r.disabled===void 0?{}:{disabled:r.disabled},run:r.run}))}function Mvn(){const t=q0e();if(t===null)return null;const r=n0e();return r&&(r.adapter!==null||r.nodeId!==null)?null:{quickActions:Rvn(t.path),id:`asset:${t.path}`,title:t.name,kindLabel:t.online?`${t.kind} · ${t.online.source}`:t.kind,note:{text:t.sourcePath??t.path,testId:"inspector-asset-path"},sections:[{id:pMe,title:"Preview",icon:BY,order:N3t,body:{kind:"preview",render:()=>z.jsx(Dvn,{asset:t})}},{id:"asset-selection",title:"Asset",icon:bee,order:hZ,body:{kind:"custom",render:()=>z.jsx(Fvn,{})},keepMounted:!0}]}}const Lvn={loop:"Loop control","contract.root":"DOM root","contract.lifecycle.start":"Cold start","contract.lifecycle.pause":"Pause / resume",persistence:"Source persistence",systems:"Commands and state"};function jvn(t){const r=Lvn[t];if(r)return r;const[i,a]=t.split("."),l=(a??t).replace(/([a-z])([A-Z])/g,"$1 $2").toLowerCase(),d=l.charAt(0).toUpperCase()+l.slice(1);return i==="system"?`${d} adapter`:d}const Bvn={ok:fDr,gap:Gkt,na:DDr,info:bee},$vn={ok:Oo.semantic.success,gap:Oo.semantic.warning,na:Oo.content.dim,info:Oo.content.dim};function qvn({row:t}){return z.jsxs("div",{"data-testid":`ingest-coverage-row-${t.seam}`,"data-status":t.status,style:{display:"grid",gridTemplateColumns:"16px minmax(0, 1fr)",gap:7,padding:"8px 10px",borderTop:"1px solid var(--vgai-structural-divider)"},children:[z.jsx("span",{style:{color:$vn[t.status],paddingTop:1},children:z.jsx(So,{icon:Bvn[t.status]})}),z.jsxs("div",{style:{minWidth:0},children:[z.jsx("div",{style:{color:Oo.content.primary,fontWeight:600},children:jvn(t.seam)}),z.jsx("div",{style:{marginTop:2,color:Oo.content.muted,lineHeight:1.4,overflowWrap:"anywhere"},children:t.detail}),t.missing&&z.jsxs("div",{style:{marginTop:6,color:Oo.content.muted,lineHeight:1.4},children:[z.jsx("strong",{style:{color:Oo.semantic.warning},children:"Missing:"})," ",t.missing]}),t.fix&&z.jsxs("div",{style:{marginTop:4,color:Oo.content.dim,lineHeight:1.4},children:[z.jsx("strong",{children:"Fix:"})," ",t.fix]})]})]})}function zvn({report:t}){const{summary:r}=t;return z.jsxs("div",{"data-testid":"ingest-coverage-report",style:{fontSize:"var(--vgai-font-base)"},children:[z.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:8,padding:"7px 10px 9px",color:Oo.content.muted},children:[z.jsxs("span",{style:{color:r.gaps>0?Oo.semantic.warning:Oo.semantic.success},children:[r.gaps," ",r.gaps===1?"gap":"gaps"]}),z.jsxs("span",{children:[r.ok," integrated"]}),z.jsxs("span",{children:[r.na," not applicable"]}),z.jsxs("span",{children:[r.info," informational"]})]}),t.rows.map(i=>z.jsx(qvn,{row:i},i.seam))]})}function Uvn(t){return{id:"ingest-coverage",title:"Ingest coverage",icon:_Dr,order:9e3,description:`${t.summary.gaps} gap${t.summary.gaps===1?"":"s"}`,defaultOpen:!0,testId:"ingest-coverage-section",body:{kind:"custom",render:()=>z.jsx(zvn,{report:t}),data:{summary:t.summary,rows:t.rows}}}}function Vvn(t,r,i){if(t)return t.nodeId;const a=[...r].at(-1);if(a)return a;const l=i.selection?.get().at(-1)??null;if(l===null)return null;const d=i.hierarchy.roots();return d.length===1&&d[0]?.id===l?null:l}const gGt="vgai-inspector-presentation-v2";function yGt(){try{return typeof window>"u"?null:window.localStorage}catch{return null}}function Jvn(t){return t==="card"||t==="column"||t==="properties"}function Wvn(){const t=yGt()?.getItem(gGt);if(!t)return{};try{const r=JSON.parse(t);if(!r||typeof r!="object")return{};const i={};for(const[a,l]of Object.entries(r))Jvn(l)&&(i[a]=l);return i}catch{return{}}}let ZX=null,vGt=0;const nqe=new Set;function bGt(){return ZX===null&&(ZX=Wvn()),ZX}function iqe(t){return bGt()[t]??null}function AGt(t,r){if(iqe(t)!==r){ZX={...bGt(),[t]:r},vGt++;try{yGt()?.setItem(gGt,JSON.stringify(ZX))}catch{}for(const i of nqe)i()}}function Hvn(t){return nqe.add(t),()=>{nqe.delete(t)}}function hEt(){return vGt}function Gvn(t,r,i=null){return r??i??t}function SGt(t){return t.sections.map(r=>({id:r.id,title:r.title,icon:r.icon,...r.railGroup===void 0?{}:{railGroup:r.railGroup},...r.railDefault===void 0?{}:{railDefault:r.railDefault}}))}function sqe(t){return t==="three"||t==="canvas"||t==="dom"?t:null}function Qvn(t,r){const i=r.selectedEntityId;if(i===null)return null;const a=t.childAdapters(),l=a.find(d=>d.worldId===t.ownerOf(i))??a.find(d=>t.groupNodeId(d.worldId)===i);return l?sqe(l.kind):null}function Kvn(t){const r=vze();if(r!==null&&r.documentId===I_())return"asset-lab";const{adapter:i,surface:a}=wm(t);if(a)return a;if(i instanceof Zh){const l=i.childAdapters(),d=l.length===1?sqe(l[0]?.kind??""):null;if(d)return d;const _=Qvn(i,t);if(_)return _}return sqe(ebe()??"")??"three"}function zQe(t,r){r(t);for(const i of t.children)R0e(i)||zQe(i,r)}const URe=new xS;function xGt(t){return Number.isFinite(t.min.x)&&Number.isFinite(t.min.y)&&Number.isFinite(t.min.z)&&Number.isFinite(t.max.x)&&Number.isFinite(t.max.y)&&Number.isFinite(t.max.z)}const gEt=new SS,VRe=new xS;function Yvn(t,r,i){for(let a=0;a<r.count;a++)r.getMatrixAt(a,gEt),VRe.copy(i).applyMatrix4(gEt).applyMatrix4(r.matrixWorld),xGt(VRe)&&t.union(VRe)}function wGt(t,r){const i=r.geometry;if(!i)return;const a=Xvn(r,i);if(a){if(r.isInstancedMesh){Yvn(t,r,a);return}URe.copy(a).applyMatrix4(r.matrixWorld),xGt(URe)&&t.union(URe)}}function Xvn(t,r){const i=t;return t.isSkinnedMesh?(r.boundingBox===null&&r.computeBoundingBox(),r.boundingBox):i.boundingBox!==void 0&&!t.isInstancedMesh?(i.boundingBox===null&&i.computeBoundingBox?.(),i.boundingBox??null):(r.boundingBox===null&&r.computeBoundingBox(),r.boundingBox)}function Zvn(t,r){return zQe(r,i=>{i.updateWorldMatrix(!1,!1),wGt(t,i)}),t}const b_e=new xS;function CGt(t){const r=t.material;return r?Array.isArray(r)?r:[r]:[]}function e1n(t){const r=CGt(t);return r.length>0&&r.every(i=>i.depthWrite===!1)}function t1n(t){const r=CGt(t);return r.length>0&&r.every(i=>i.side===dkt)}function r1n(t,r=[]){return zQe(t,i=>{i.updateWorldMatrix(!1,!1),b_e.makeEmpty(),wGt(b_e,i),!b_e.isEmpty()&&r.push({box:b_e.clone(),overlay:e1n(i),enclosure:t1n(i)})}),r}function n4n(t,r=[]){for(const i of r1n(t))r.push(i.box);return r}function EGt(t,r=new xS){return r.makeEmpty(),Zvn(r,t)}class i4n extends bIr{entityObject;constructor(r,i){super(new xS,i),this.entityObject=r,this.update()}update(){EGt(this.entityObject,this.box)}}function n1n({stories:t,activeStoryId:r,onApplyStory:i,isolation:a,unavailableReason:l}){return z.jsxs("div",{style:{padding:"4px 0"},children:[t.length>0?z.jsxs(bS,{"data-testid":"ingest-stories-select",value:r,onChange:d=>{const _=d.target.value;i(_===""?null:_)},style:{width:"100%"},children:[z.jsx("option",{value:"",children:"(none)"}),t.map(d=>z.jsx("option",{value:d.id,children:d.label},d.id))]}):z.jsx("div",{"data-testid":"ingest-stories-none",style:{fontSize:"var(--vgai-font-base)",color:Oo.content.dim,fontStyle:"italic"},children:l??"No stories — this root has no associated portable CSF previews."}),a&&z.jsx(fo,{"data-testid":"catalog-isolate",onClick:a.toggle,variant:a.isolated?"primary":"secondary","aria-pressed":a.isolated,style:{marginTop:6,width:"100%"},children:a.isolated?"Exit isolation":"Isolate"})]})}function UQe(t){const r=new G8(...t);r.lengthSq()<Number.EPSILON?r.identity():r.normalize();const i=new Xqe().setFromQuaternion(r,"XYZ");return[bb.radToDeg(i.x),bb.radToDeg(i.y),bb.radToDeg(i.z)]}function i1n(t,r,i){if(i.length!==3||i.some(l=>!Number.isFinite(l)))throw new Error(`transform.${r} expects three finite numbers.`);const a={position:[...t.position],rotation:[...t.rotation],scale:[...t.scale]};if(r==="rotation"){const l=new G8().setFromEuler(new Xqe(bb.degToRad(i[0]),bb.degToRad(i[1]),bb.degToRad(i[2]),"XYZ"));return{...a,rotation:[l.x,l.y,l.z,l.w]}}return{...a,[r]:[i[0],i[1],i[2]]}}function s1n(t,r,i){const a=UQe(t.rotation);a[r]=i;const l=new G8().setFromEuler(new Xqe(bb.degToRad(a[0]),bb.degToRad(a[1]),bb.degToRad(a[2]),"XYZ"));return{position:[...t.position],rotation:[l.x,l.y,l.z,l.w],scale:[...t.scale]}}const o1n={x:"#e0726d",y:"#83bd66",z:"#6390dd"};function JRe({axes:t,label:r,values:i,testidPrefix:a,step:l,precision:d,onBegin:_,onPreview:g,onCommit:b,readOnly:S,readOnlyReason:k}){const[w,N]=Xe.useState(null),P=Xe.useRef(!1);return z.jsx(z_e,{label:r,style:{padding:"4px 8px"},children:t.map(({axis:j,name:J})=>z.jsx(SX,{testId:`${a}-${J}`,label:J,labelColor:o1n[J],title:k,disabled:S,step:l,precision:d,value:w?.axis===j?w.value:Number.isFinite(i[j])?i[j]:0,style:{flex:1,minWidth:0},onChange:X=>{P.current||(P.current=!0,_?.()),N({axis:j,value:X}),g?.(j,X)},onChangeEnd:X=>{P.current=!1,N(null),b(j,X)}},J))})}function a1n({dimensions:t="3d",transform:r,readOnly:i=!1,channelEditability:a,note:l,onBegin:d,onPreview:_,onCommit:g}){const b=[{axis:0,name:"x"},{axis:1,name:"y"}],S=[...b,{axis:2,name:"z"}],k=(J,X,G)=>{const ee={position:[...r.position],rotation:[...r.rotation],scale:[...r.scale]};return ee[X][J]=G,ee},w=(J,X)=>(G,ee)=>{Number.isFinite(ee)&&X?.(k(G,J,ee))},N=J=>(X,G)=>{Number.isFinite(G)&&J?.(s1n(r,X,G))},P=J=>{const X=a?.[J],G=i||X?.writable===!1;return X?.reason?{readOnly:G,readOnlyReason:X.reason}:{readOnly:G}},j=[...new Set(["position","rotation","scale"].map(J=>P(J)).filter(J=>J.readOnly&&J.readOnlyReason).map(J=>J.readOnlyReason))];return z.jsxs(I5r,{children:[z.jsx(JRe,{axes:t==="2d"?b:S,label:"Position",testidPrefix:"ingest-position",values:r.position,step:.1,precision:3,...P("position"),onBegin:d,onPreview:_&&w("position",_),onCommit:w("position",g)}),z.jsx(JRe,{axes:t==="2d"?[{axis:2,name:"z"}]:S,label:t==="2d"?"Rotation (degrees)":"Rotation",testidPrefix:"ingest-rotation",values:UQe(r.rotation),step:1,precision:1,...P("rotation"),onBegin:d,onPreview:_&&N(_),onCommit:N(g)}),z.jsx(JRe,{axes:t==="2d"?b:S,label:"Scale",testidPrefix:"ingest-scale",values:r.scale,step:.01,precision:3,...P("scale"),onBegin:d,onPreview:_&&w("scale",_),onCommit:w("scale",g)}),j.map(J=>z.jsx(Ru,{"data-testid":"inspector-transform-readonly-reason",variant:"caption",tone:"muted",style:{display:"block",padding:"4px 8px",overflowWrap:"anywhere"},children:J},J)),l&&z.jsx(Ru,{"data-testid":"inspector-transform-note",variant:"caption",tone:"muted",style:{display:"block",padding:"4px 8px",overflowWrap:"anywhere"},children:l})]})}function nbe(t){const[r,i]=Xe.useState(null);return Xe.useEffect(()=>{let a=0;const l=requestAnimationFrame(()=>{a=requestAnimationFrame(()=>i(t))});return()=>{cancelAnimationFrame(l),cancelAnimationFrame(a)}},[t]),r===t}const c1n=Xe.lazy(()=>Xo(()=>import("./InspectorObjectPreview-DbRdK5-k.js"),__vite__mapDeps([76,1,2,47,3,4,8,9,10,42,6,7,40,14,43,41,11])).then(t=>({default:t.InspectorObjectPreview}))),l1n=Xe.lazy(()=>Xo(()=>import("./InspectorCanvasPreview-CLDhscy0.js"),__vite__mapDeps([77,1,2,3,4])).then(t=>({default:t.InspectorCanvasPreview})));function u1n({object:t,displayName:r,previewKey:i,actions:a,mode:l="section"}){const d=l==="thumbnail",_=nbe(i);return z.jsxs("div",{"data-testid":d?"inspection-preview-thumbnail":"inspection-preview",style:d?{position:"absolute",inset:0,overflow:"hidden"}:{position:"relative",width:"calc(100% - 24px)",aspectRatio:"1 / 1",flexShrink:0,margin:12,overflow:"hidden",border:"1px solid var(--vgai-structural-divider)",borderRadius:"var(--dv-group-border-radius, 8px)"},children:[_&&z.jsx(Xe.Suspense,{fallback:null,children:z.jsx(c1n,{previewKey:i,object:t,displayName:r,fill:!0})}),!d&&a.map(g=>z.jsx(fo,{"data-testid":g.id,size:"compact",disabled:g.disabled,title:g.title,onClick:g.run,style:{position:"absolute",right:8,bottom:8},children:g.label},g.id))]})}function f1n({source:t,entry:r,previewKey:i,actions:a,mode:l="section"}){const d=l==="thumbnail",_=nbe(i);return z.jsxs("div",{"data-testid":d?"inspection-preview-thumbnail":"inspection-preview",style:d?{position:"absolute",inset:0,overflow:"hidden"}:{position:"relative",width:"calc(100% - 24px)",aspectRatio:"1 / 1",flexShrink:0,margin:12,overflow:"hidden",border:"1px solid var(--vgai-structural-divider)",borderRadius:"var(--dv-group-border-radius, 8px)"},children:[_&&z.jsx("div",{style:{position:"absolute",inset:0,overflow:"hidden",background:"var(--vgai-bg-inset)"},children:z.jsx(t.Thumbnail,{entry:r,previewRevision:0,width:d?96:256,height:d?96:256})}),!d&&a.map(g=>z.jsx(fo,{"data-testid":g.id,size:"compact",disabled:g.disabled,title:g.title,onClick:g.run,style:{position:"absolute",right:8,bottom:8},children:g.label},g.id))]})}function d1n({capture:t,previewKey:r,actions:i,mode:a="section"}){const l=a==="thumbnail",d=nbe(r);return z.jsxs("div",{"data-testid":l?"inspection-preview-thumbnail":"inspection-preview",style:l?{position:"absolute",inset:0,overflow:"hidden"}:{position:"relative",width:"calc(100% - 24px)",aspectRatio:"1 / 1",flexShrink:0,margin:12,overflow:"hidden",border:"1px solid var(--vgai-structural-divider)",borderRadius:"var(--dv-group-border-radius, 8px)"},children:[d&&z.jsx(Xe.Suspense,{fallback:null,children:z.jsx(l1n,{capture:t,previewKey:r,size:l?96:256})}),!l&&i.map(_=>z.jsx(fo,{"data-testid":_.id,size:"compact",disabled:_.disabled,title:_.title,onClick:_.run,style:{position:"absolute",right:8,bottom:8},children:_.label},_.id))]})}function p1n(t){return t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function _1n(t){const r=[],i=[],a=new Map;for(const l of t)l.group?(a.has(l.group)||(a.set(l.group,[]),i.push(l.group)),a.get(l.group).push(l)):r.push(l);return{ungrouped:r,groups:i.map(l=>({name:l,groupId:p1n(l),properties:a.get(l)}))}}function m1n(t,r){if(!t.transforms)return null;const i=t.transforms.dimensions?.(r);return i!==void 0?i:t.hierarchy.object3D===void 0||t.hierarchy.object3D(r)!==null?"3d":null}const h1n=1e-4,g1n="World-anchored — content is placed in world space by the game each frame; moving this container offsets future placements away from their source.";function TGt(t){if(!t)return 0;const r=t;if(r.isInstancedMesh!==!0)return 0;const i=r.count;return typeof i=="number"&&i>0?i:0}function y1n(t){const r=t.elements;for(let i=0;i<16;i++){const a=i%5===0?1:0,l=r[i];if(!Number.isFinite(l)||Math.abs(l-a)>h1n)return!1}return!0}const yEt=new xS,vEt=new Tc;function v1n(t,r){const i=TGt(t);if(i===0)return null;const a=b1n(t,r);return{units:i,detail:kGt(i),worldAnchored:a,note:a?g1n:null}}function b1n(t,r){if(!r||r.isEmpty()||!y1n(t.matrixWorld))return!1;const i=t.geometry;return i.boundingBox===null&&i.computeBoundingBox(),i.boundingBox?(yEt.copy(i.boundingBox),r.getCenter(vEt),!yEt.containsPoint(vEt)):!1}function A1n(t){const r=TGt(t);return r===0?null:kGt(r)}function kGt(t){return`${t} instanced unit${t===1?"":"s"}`}const S1n=14,x1n=[[/physic|rigid|collid/i,mDr],[/material/i,LIr],[/light/i,Vkt],[/camera/i,zye],[/audio|sound|music/i,iIt],[/player|character|humanoid|person/i,pDr],[/anim|state|machine/i,YIr]];function w1n(t){for(const[r,i]of x1n)if(r.test(t))return i;return yee}function C1n(t){return r=>Xe.createElement(u1n,{object:t.object,displayName:t.displayName,previewKey:t.previewKey,actions:t.actions,...r?{mode:r}:{}})}function E1n(t){return r=>Xe.createElement(f1n,{source:t.picture.source,entry:t.picture.entry,previewKey:t.previewKey,actions:t.actions,...r?{mode:r}:{}})}function T1n(t){return r=>Xe.createElement(d1n,{capture:t.capture,previewKey:t.previewKey,actions:t.actions,...r?{mode:r}:{}})}function k1n(t){return t.object?.isCamera?null:t.object?C1n({object:t.object,displayName:t.displayName,previewKey:t.previewKey,actions:t.actions}):t.canvasCapture?T1n({capture:t.canvasCapture,previewKey:t.previewKey,actions:t.actions}):t.picture?E1n({picture:t.picture,previewKey:t.previewKey,actions:t.actions}):null}function WRe(t){const r=t.slice(10);if(r!=="position"&&r!=="rotation"&&r!=="scale")throw new Error(`The Transform section has no ${JSON.stringify(t)}.`);return r}const I1n={position:[0,0,0],rotation:[0,0,0,1],scale:[1,1,1]};function D1n(t,r,i,a){if(F3t(t))return t.sections(a,r);const l=t.Section;return[{id:t.id,title:t.title,icon:typeof t.icon=="function"?t.icon(a,r):t.icon,order:t.order,...t.railGroup===void 0?{}:{railGroup:t.railGroup},...t.railDefault===void 0?{}:{railDefault:t.railDefault},body:{kind:"custom",render:()=>Xe.createElement(l,{adapter:r,nodeId:i})}}]}function IGt(t,r,i,a){const l=new Set,d=new Map,_=[];for(const g of t){const b=D1n(g,r,i,a).filter(k=>!l.has(k.id)),S=(F3t(g)?g.claims??[]:[]).filter(k=>!l.has(k));if(!(b.length===0&&S.length===0)){for(const k of b)l.add(k.id),d.set(k.id,g.owner);for(const k of S)l.add(k);_.push(...b)}}return{sections:_,claimed:l,owners:d}}function DGt(t,r,i){return i===void 0?[...t]:t.filter(a=>r.get(a.id)===i.owner||i.builtins.includes(a.id))}function oqe(t){const{adapter:r,nullSubject:i}=t,{sections:a,claimed:l,owners:d}=IGt(r?t.contributions??[]:[],r,null,null),_=DGt([...(i?.sections??[]).filter(g=>!l.has(g.id)),...a].sort((g,b)=>g.order-b.order),d,t.rail);return{id:i?.id??"nothing-selected",title:i?.title??"Nothing selected",identity:i?.kindLabel?{rename:{readOnly:!0,set:()=>{}},kindLabel:i.kindLabel,...i.note?{note:i.note}:{}}:null,...i?.hint?{hint:i.hint}:{},presentation:{preferred:jze(t.surface)},quickActions:i?.quickActions??[],related:[],sections:_}}function P1n(t,r,i){if(t.body.kind!=="custom"||t.body.editable)return t;const a=i.get(t.id);return!a||a.length===0?t:{...t,body:{...t.body,editable:{fields:a,io:r}}}}function N1n(t){const{adapter:r,nodeId:i,node:a,contributions:l,onEdit:d}=t;if(i===null)return oqe({nullSubject:t.nullSubject??null,surface:t.surface,contributions:l,adapter:r,rail:t.rail});const{sections:_,claimed:g,owners:b}=IGt(l,r,i,a),S={get:cr=>r.inspector?.get(i,cr),...r.inspector?.preview?{preview:(cr,Yt)=>{r.inspector?.preview?.(i,cr,Yt)}}:{},set:(cr,Yt)=>{if(!r.inspector)return;const Lr=n4t(r,i,cr,Yt);return d(),Lr},...r.inspector?.remove?{remove:cr=>{const Yt=G9r(r,i,cr);return d(),Yt}}:{}},k=r.inspector?.properties(i)??[],w=k.find(cr=>cr.path==="name"),{ungrouped:N,groups:P}=_1n(k.filter(cr=>cr.path!=="name")),j=N.find(cr=>cr.path==="visible"&&cr.type==="boolean"),J=j?N.filter(cr=>cr!==j):N,X=[...w&&w.readonly!==!0?[w]:[],...j?[j]:[]],G=[];if(j){const cr=S.get(j.path)!==!1,Yt=cr?"Visible — click to hide":"Hidden — click to show";G.push({id:"inspector-visibility-toggle",title:Yt,icon:cr?Zqe:tze,placement:"identity",pressed:!cr,disabled:j.readonly===!0,run:async()=>{await S.set(j.path,!cr)}})}t.assetDocument&&G.push({id:"open-asset-editor",title:"Open in Asset Editor",label:"Open in Asset Editor",placement:"preview",run:t.assetDocument.open}),r.transforms?.sourceCommit?.availability(i)?.available&&G.push({id:"commit-live-transform-source",title:"Commit this live transform to its authored source literal",label:"Commit transform to source",icon:Wkt,placement:"identity",run:async()=>{await t4t(r,i),d()}});const ue=new Map;ue.set(PFe,J);for(const cr of P)ue.set(mAt(cr.groupId),cr.properties);const fe=[],se=r.truth?.resolve(i,"position").site??null,de=t.previewObject,ge=a?.typeLabel??a?.label??i,qe=t.surface==="canvas"&&de===null&&t.stories?oGt({name:ge,path:se?.anchored===!0?se.file:"",surface:"canvas"}):null,tt=G.filter(cr=>cr.placement==="preview"),Ct=k1n({object:de,canvasCapture:t.canvasPreview,picture:qe,displayName:a?.label??i,previewKey:i,actions:tt});!g.has(pMe)&&Ct!==null&&fe.push({id:pMe,title:"Preview",icon:f9,order:N3t,body:{kind:"preview",render:Ct}});const Ot=m1n(r,i);if(!g.has(_At)&&Ot!==null){const cr=r.transforms?.get(i)??I1n,Yt=de?v1n(de,EGt(de)):null,Lr=Object.fromEntries(["position","rotation","scale"].map(on=>[on,r.transforms?.editability?.(i,on)??{writable:r.capabilities.transform}])),nn={position:[...cr.position],rotation:UQe(cr.rotation),scale:[...cr.scale]};fe.push({id:_At,title:"Transform",icon:Kkt,order:n7r,body:{kind:"custom",data:{...nn,editability:Lr,...Yt?{instanced:Yt}:{}},editable:{fields:["position","rotation","scale"].map(on=>{const gr=!r.capabilities.transform||!Lr[on].writable;return{path:`transform.${on}`,label:on[0].toUpperCase()+on.slice(1),type:"vec3",value:nn[on],readonly:gr,...!gr&&r.transforms?.remove&&Lr[on].removable===!0?{resettable:!0}:{}}}),io:{get:on=>nn[WRe(on)],set:(on,gr)=>{if(!r.transforms)return;const An=i1n(cr,WRe(on),gr);XMe(r,i),rme(r,i,An);const Rn=ZMe(r,i);return d(),Rn},...r.transforms?.remove?{remove:on=>{const gr=e4t(r,i,WRe(on));return d(),gr}}:{}}},render:()=>Xe.createElement(a1n,{dimensions:Ot,transform:cr,readOnly:!r.capabilities.transform,channelEditability:Lr,...Yt?.note?{note:Yt.note}:{},onBegin:()=>{XMe(r,i)},onPreview:on=>{rme(r,i,on)},onCommit:on=>{rme(r,i,on),ZMe(r,i),d()}})}})}g.has(PFe)||(J.length>0&&fe.push({id:PFe,title:"Properties",icon:Ykt,order:hZ,defaultOpen:!0,body:{kind:"fields",fields:J,io:S}}),P.forEach((cr,Yt)=>{const Lr=cr.properties.filter(nn=>!nn.defaulted).length;fe.push({id:mAt(cr.groupId),title:cr.name,icon:w1n(cr.name),order:O3t+Yt,description:Lr>0?`${Lr} set of ${cr.properties.length}`:`${cr.properties.length} properties`,defaultOpen:Lr>0&&cr.properties.length<=S1n,testId:`ingest-group-${cr.groupId}`,body:{kind:"fields",fields:cr.properties,io:S}})}));const vt=t.stories;!g.has(P3t)&&vt&&fe.push(O1n(vt)),fe.push(..._.map(cr=>P1n(cr,S,ue))),fe.sort((cr,Yt)=>cr.order-Yt.order);const Et=DGt(fe,b,t.rail),Tt=d4t(r,i),Le=p4t(r);return{id:i,title:a?.label??"",identity:{rename:{readOnly:w===void 0||w.readonly===!0,set:cr=>S.set("name",cr)},kindLabel:`${a?.typeLabel??a?.kind??""}${Tt?` · ${Tt.label}`:""}`,...a?.kind?{kind:a.kind}:{},...Le?{document:{path:Le,...Tt?.detail?{title:Tt.detail}:{}}}:{},note:se?.anchored?{text:`${se.kind==="data"?"Level data":"Source"} · ${se.display}`,title:se.kind==="data"?`Placed by record ${se.record} of ${se.file}, the game's own level data`:`Constructed by a \`new\` expression at ${se.file} line ${se.line}, column ${se.col}`,testId:"inspector-creation-site"}:void 0},presentation:{preferred:jze(t.surface)},...X.length>0?{editable:{fields:X,io:S}}:{},...t.alsoSelected?{alsoSelected:t.alsoSelected}:{},quickActions:G,related:r.related?.links(i)??[],sections:Et}}function O1n(t){return{id:P3t,title:t.title??"Stories",icon:cIt,order:i7r,body:{kind:"custom",render:()=>Xe.createElement(n1n,{stories:t.stories,activeStoryId:t.activeStoryId,onApplyStory:t.onApplyStory,isolation:t.isolation,unavailableReason:t.unavailableReason??null})}}}const F1n=["project-tool","tool-contribution"];function R1n(t){const{activeDocumentKind:r,documentSelection:i}=t;return r===null||!F1n.includes(r)?!1:i===null}function bEt(t){const{subject:r,surface:i,available:a,override:l,workspaceDefault:d=null}=t,_=r.presentation.preferred??jze(),g=Gvn(_,l,d);return{subject:r,surface:i,presentation:g,available:a,card:a&&g==="card",column:g!=="card"}}const M1n="game",L1n=3,j1n=Object.freeze({none:!0});function B1n(t){const r=Object.getPrototypeOf(t);return r===Object.prototype||r===null}function fee(t,r=0){if(t===null)return null;const i=typeof t;if(i==="string"||i==="boolean")return t;if(i==="number")return Number.isFinite(t)?t===0?0:t:{kind:"opaque",type:"number"};if(i!=="object")return{kind:"opaque",type:i};if(r>=L1n)return{kind:"opaque",type:AEt(t)};if(Array.isArray(t))return t.map(d=>fee(d,r+1));const a=t;if(!B1n(a))return{kind:"opaque",type:AEt(a)};const l={};for(const[d,_]of Object.entries(a))_!==void 0&&(l[d]=fee(_,r+1));return l}function AEt(t){return t.constructor?.name??"object"}function SEt(t,r){let i;try{i=r.get(t.path)}catch{i=void 0}return{path:t.path,label:t.label,type:t.type,...dMe(i)?{mixed:!0}:{},...!dMe(i)&&i!==void 0?{value:fee(i)}:{},...t.defaulted!==void 0?{defaulted:t.defaulted}:{},...t.readonly!==void 0?{readonly:t.readonly}:{},...t.readonly?{readonlyReason:Lze(t)}:{},...t.resettable!==void 0?{resettable:t.resettable}:{},...t.revertsTo!==void 0?{revertsTo:t.revertsTo}:{},...t.group!==void 0?{group:t.group}:{},...t.options!==void 0?{options:t.options.map(a=>fee(a))}:{}}}function xEt(t){const r={};for(const[i,a]of Object.entries(t))a!==void 0&&(r[i]=fee(a));return r}function $1n(t){const r=t.body;if(r.kind==="fields")return{kind:"fields",fields:r.fields.map(i=>SEt(i,r.io))};if(r.kind==="custom"&&r.data!==void 0&&r.editable===void 0)return{kind:"custom",id:t.id,title:t.title,data:xEt(r.data)};if(r.kind==="custom"&&r.editable!==void 0){const i=r.editable;return{kind:"fields",fields:i.fields.map(a=>SEt(a,i.io)),...r.data!==void 0?{data:xEt(r.data)}:{}}}return{kind:r.kind,id:t.id,title:t.title}}function q1n(t){return{id:t.id,title:t.title,order:t.order,...t.description!==void 0?{description:t.description}:{},body:$1n(t)}}function z1n(t,r){return{id:t.id,title:t.title,...t.identity?.kindLabel?{kindLabel:t.identity.kindLabel}:{},...t.identity?.note?{note:t.identity.note.text}:{},...t.hint?{hint:t.hint}:{},...t.alsoSelected?{alsoSelected:t.alsoSelected}:{},presentation:{preferred:t.presentation.preferred,...r?{resolved:r.presentation,surface:r.surface}:{}},quickActions:t.quickActions.map(i=>({id:i.id,title:i.title,...i.label!==void 0?{label:i.label}:{},...i.pressed!==void 0?{pressed:i.pressed}:{},...i.disabled!==void 0?{disabled:i.disabled}:{}})),related:t.related.map(({id:i,title:a})=>({id:i,title:a})),sections:t.sections.map(q1n)}}const wEt=new WeakMap;function U1n(t){const r=wEt.get(t);if(r)return r;const i=async a=>t.captureImage(a);return wEt.set(t,i),i}function V1n(t){return typeof t.previewImage=="function"}function J1n(t,r,i){if(!r)return null;if(i==="asset-lab"){const l=I_(),d=l?Pw(l):null;return d?U1n(d):null}let a=t;if(t instanceof Zh){const l=t.ownerOf(r);a=t.childAdapters().find(d=>d.worldId===l)?.adapter??t}return V1n(a)?l=>a.previewImage(r,l,l):null}function W1n(){const t=I_();if(t===null)return null;const r=Vmn(t);if(r===void 0)return null;const i=y9(r.kind);return i===void 0||i.inspectorRail!=="owned"?null:{rail:{owner:i.owner,builtins:i.inspectorBuiltins??[]}}}function H1n(t){const{store:r,adapter:i,documentSelection:a,surface:l}=t,d=Mvn();if(d!==null)return{subject:oqe({nullSubject:d,surface:l}),available:!0};const _=Vvn(a,r.selectedEntityIds,i),g=_?i.hierarchy.node(_):null;if(_!==null&&g===null)return{subject:oqe({nullSubject:null,surface:l}),available:!1};const b=()=>r.notifyIngestEdit(),S=_?null:vMr({adapter:i,surface:l,store:r,onEdit:b}),k=_?g?yAt(g,i):[]:yAt(null,i,{nullSubjectId:S?.id??null});return{subject:N1n({adapter:i,nodeId:_,node:g,surface:l,contributions:k,..._?{}:{nullSubject:S},previewObject:(_===null||l==="asset-lab"?null:dte(i,r.objectMap,_))??null,canvasPreview:J1n(i,_,l),assetDocument:_&&r.objectMap.has(_)?{open:()=>PNt(r,_)}:null,stories:_Mr(i,g,_),...W1n()??{},...a===null&&_!==null&&r.selectedEntityIds.size>1?{alsoSelected:r.selectedEntityIds.size-1}:{},onEdit:b}),available:_!==null||S!==null||k.length>0}}function ibe(t){const r=Kvn(t),{adapter:i,documentSelection:a}=wm(t),l=H1n({store:t,adapter:i,documentSelection:a,surface:r}),{subject:d}=l,_=l.available&&(d.id!==M1n||d.sections.length>0)&&!R1n({activeDocumentKind:AE()?.descriptor.kind??null,documentSelection:a}),g=I_()===Sw?kQe():null;if(g){const b=Uvn(g),S=_?{...d,sections:[...d.sections.filter(k=>k.id!==b.id),b].sort((k,w)=>k.order-w.order)}:{id:`ingest:${g.summary.worldId}`,title:"Ingested game",identity:null,hint:"This mount exposes no editable scene subject. Coverage below says exactly which editor seams it did earn.",presentation:d.presentation,quickActions:[],related:[],sections:[b]};return bEt({subject:S,surface:r,available:!0,override:iqe(r),workspaceDefault:wP().inspector??null})}return bEt({subject:d,surface:r,available:_,override:iqe(r),workspaceDefault:wP().inspector??null})}function sbe(t){const{subject:r,surface:i,presentation:a,available:l}=ibe(t);return l?z1n(r,{surface:i,presentation:a}):j1n}async function G1n(t,r){const{subject:i,available:a}=ibe(t);if(!a)throw new Error("No Inspector subject is active.");const l=i.quickActions.filter(_=>_.id===r);if(l.length!==1){const _=i.quickActions.map(g=>g.id);throw new Error(l.length===0?`Inspector action ${JSON.stringify(r)} is not available. `+(_.length>0?`Available actions: ${_.join(", ")}.`:"This subject exposes no actions."):`Inspector action id ${JSON.stringify(r)} is ambiguous (${l.length} matches).`)}const d=l[0];if(!d||d.disabled)throw new Error(`Inspector action ${JSON.stringify(r)} is disabled.`);return await d.run(),sbe(t)}function Q1n(t,r){const i=a=>{throw new Error(`Inspector field ${JSON.stringify(t.path)} expects ${a}.`)};if(t.type==="number"&&(typeof r!="number"||!Number.isFinite(r))&&i("a finite number"),t.type==="boolean"&&typeof r!="boolean"&&i("a boolean"),(t.type==="string"||t.type==="color"||t.type==="asset"||t.type==="enum")&&typeof r!="string"&&i("a string"),t.type==="vec3"&&(!Array.isArray(r)||r.length!==3||r.some(a=>typeof a!="number"||!Number.isFinite(a)))&&i("three finite numbers"),t.type==="enum"&&t.options&&!t.options.includes(r))throw new Error(`Inspector field ${JSON.stringify(t.path)} accepts: ${t.options.map(String).join(", ")}.`)}async function K1n(t,r,i){const a=PGt(t,r);Q1n(a.field,i);const l=await a.io.set(r,i)??Vhe;return{subject:sbe(t),write:l}}function PGt(t,r){const{subject:i,available:a}=ibe(t);if(!a)throw new Error("No Inspector subject is active.");const l=(i.editable?.fields??[]).filter(b=>b.path===r).map(b=>({field:b,io:i.editable.io})),d=i.sections.flatMap(b=>{const S=b.body,k=S.kind==="fields"?{fields:S.fields,io:S.io}:S.kind==="custom"?S.editable:void 0;return k?k.fields.filter(w=>w.path===r).map(w=>({field:w,io:k.io})):[]}),_=[...l,...d];if(_.length===0)throw new Error(`The active Inspector has no field at ${JSON.stringify(r)}.`);if(_.length>1)throw new Error(`The active Inspector exposes ${JSON.stringify(r)} more than once.`);const g=_[0];if(g.field.readonly)throw new Error(`Inspector field ${JSON.stringify(r)} is read-only: ${Lze(g.field)}`);return g}class aqe extends Error{constructor(r){super(r),this.name="InspectionRemovalUnavailableError"}}async function Y1n(t,r){const i=PGt(t,r);if(i.field.resettable!==!0)throw new aqe(`Inspector field ${JSON.stringify(r)} does not declare itself removable (\`resettable\`), so this lane has no way to express the property's absence. Write a value with \`set-inspection-field\` instead — and note that doing so cannot restore byte-absence for a property an edit ADDED.`);if(!i.io.remove)throw new aqe(`The Inspector io that owns ${JSON.stringify(r)} implements no removal door, so the property's authored override cannot be dropped through this editor. The dialect writer that owns this source edit owns removal too; until it does, an edit/revert round trip over this lane is unverifiable at byte level.`);const a=await i.io.remove(r)??Vhe;return{subject:sbe(t),write:a}}let X1n=[];const CEt=new Set;function s4n(t){return CEt.add(t),()=>CEt.delete(t)}function NGt(){return X1n}function Z1n(){const t=NGt();if(t.length===0)return null;const r=t.filter(i=>i.source==="measured");return r.length===0?null:`${r.length} of ${t.length} root(s) have NO readiness declaration (${r.map(i=>i.rootId).join(", ")}) — the host is measuring instead. A self-booting game states it with \`window.vgaiGame.ready\`.`}function ebn(t){return t.liveMounted?t.livePlaying?t.storePlayState==="paused"?"paused":"playing":"paused":"stopped"}async function tbn(t,r){switch(t.reach.kind){case"game-contract":{const i=r.scenes();if(!i)return{ok:!1,code:"SCENE_CONTRACT_UNAVAILABLE",error:`open: "${t.id}" is reached through the running game's own scenes contract, and the game running in this session publishes none (\`window.vgaiGame.scenes\`).`};const a=i.goToScene(t.reach.sceneId);if(!a.ok)return{ok:!1,code:"SCENE_NOT_IN_CONTRACT",error:`open: "${t.id}" — ${a.error}`,known:a.known};const l=await a.settled;return l.error!==void 0?{ok:!1,code:"SCENE_SWITCH_FAILED",error:`open: "${t.id}" — the game's own navigation failed: ${l.error}`}:(r.activateGameDocument(),{ok:!0,documentId:r.gameDocumentId,title:t.label,scene:{requested:l.requested,current:l.current}})}case"root-mount":return r.activateGameDocument()?{ok:!0,documentId:r.gameDocumentId,title:t.label}:{ok:!1,code:"SCENE_DOCUMENT_NOT_MOUNTED",error:`open: "${t.id}" is the running game itself, and no game document is open in this session.`};case"entrypoint-selection":{const i=r.remountSelection,a=t.region;if(!i||a===null)return{ok:!1,code:"SCENE_NOT_OPENABLE_LIVE",error:`open: "${t.id}" sits at the entrypoint's \`${t.reach.selection}\` swap slot, and this session has no live remount for a native swap-slot scene — a running game cannot be sent there in place. Stop the game and open it as a document instead.`};const l=await i({selection:t.reach.selection,key:t.reach.key,regionId:a});return l.ok?(r.activateGameDocument(),{ok:!0,documentId:r.gameDocumentId,title:t.label,scene:{requested:t.reach.key,current:t.reach.key},restart:!0}):{ok:!1,code:"SCENE_SWITCH_FAILED",error:`open: "${t.id}" — remount at \`${t.reach.selection}["${t.reach.key}"]\` failed: ${l.error}`}}case"story":case"none":return null}}const xye="console";function rbn(t){let r=IZ().length>0;const i=oNt(()=>{const d=IZ().length>0;d&&!r&&wP().drawer!=="hidden"&&hE(xye),r=d});let a=t.getSnapshot().lastError!==null;const l=t.subscribe(()=>{const d=t.getSnapshot().lastError,_=d!==null;_&&!a&&(ua.error(`Source write rolled back: ${d.message} (${d.code})`,"history"),wP().drawer!=="hidden"&&hE(xye)),a=_});return()=>{i(),l()}}function obe(){Z7r(xye)}function abe(){hE(xye)}const nbn=new Map;function ibn(){return[...nbn].map(([t,r])=>({rootId:t,source:r.source,sceneId:r.sceneId,cameraId:r.cameraId,alternates:[...r.alternates],...r.alternates.length>0?{ambiguity:`"${t}" rendered ${r.alternates.length} other world(s) after the one the editor adopted (${r.source}: ${r.sceneId}). The adopted world is unchanged; if the editor is showing the wrong scene, one of these is it: `+r.alternates.map(i=>`${i.sceneId}${i.sameRenderer?"":" (a SECOND renderer)"}`).join(", ")}:{}}))}const sbn=new Set(["state","stateAll","providers","commands","events","snapshot"]);function obn(t){if(t.type!=="bridge-call")return[];const r=t.method;if(typeof r!="string"||!sbn.has(r))return[];const i=t.instance;try{const a=kOr(i).debug;if(a===void 0)return[];const l=[yOr(a),i??""].join(":"),d=(g,b="")=>[l,g,b].join(":");if(r==="snapshot")return[d("snapshot"),d("state","time"),d("stateAll"),d("events")];const _=r==="state"?String(t.callArgs?.[0]):"";return[d(r,_)]}catch{return[]}}function abn(t,r,i){const a=obn(t),l=r&&a.length>0&&a.every(d=>i.has(d));if(r)for(const d of a)i.add(d);return{derived:l?"none":r&&a.length>0?"always":v3r(t.type)??g3r(t.type),playFullReport:r&&!l&&a.length>0?"explicit":r&&t.type==="bridge-call"&&t.method==="invoke"?"if-content-changed":"none"}}function cbn(t,r,i,a){return t==="none"?!1:!(t==="if-content-changed"&&r==="none"&&i===a)}function EEt(t,r){const i=tO(t);return i.hierarchy.node(r)!==null||dte(i,t.objectMap,r)!==null?null:`select: no entity with id "${r}" — neither the active authoring adapter's hierarchy nor the live object index owns it, so there is nothing to select. Read the ids that exist with editor.hierarchy() (the rows the panel is rendering) or editor.status().entities.`}function HRe(t,r,i){const a=lw();if(a){a.select(r);return}const l=t.applySelectionBeforePresentation(r);i?.deferPresentation?i.deferPresentation(l):setTimeout(l,0)}function lbn(t){const r=bP(t).cameraPose;if(r)return{position:{x:r.position.x,y:r.position.y,z:r.position.z},target:{x:r.target.x,y:r.target.y,z:r.target.z},fov:r.fov}}function ubn(){return typeof document>"u"?null:{visibility:document.visibilityState,focused:document.hasFocus(),reportedAt:Date.now()}}const fbn=["entities","entityCount","ontologyInvariants"];function dbn(t){const r={...t};for(const i of fbn)delete r[i];for(const i of Qgn())delete r[i];return{...r,_statePatch:!0}}function TEt(t,r=null){const i=IZ(),a=I_(),l=a?Pw(a)?.presentation():void 0,d=VUe(t),_=k3t.getSnapshot(),g=r?.entities??z0e(t);return{playState:ebn({storePlayState:t.playState,liveMounted:DQe(),livePlaying:tbe()}),mountFailures:i.map(b=>({...b})),moduleSplits:ryn().map(b=>({path:b.path,urls:[...b.urls]})),adapter:v1(),readiness:NGt().map(b=>({...b})),readinessWarning:Z1n(),worldAdoption:ibn().map(b=>({...b})),presence:ubn(),pageErrors:pbn(),consoleErrors:_bn(),sessionErrors:mbn(),sessionWarnings:hbn(),rendererResources:{hostLive:Ojr(),interactive:hyn(),inspectorPreview:Mjr()},ontologyInvariants:r?.ontologyInvariants??KHt().map(b=>({...b})),...Ggn(r),selectedEntityId:d[0]??null,selectedEntityIds:d,selectedCreationSite:sqr(t),selectedWriteAnchorKind:oqr(t),activeViewportTab:t.activeViewportTab,activeDocumentId:a,activeUtilityId:Y7r(),gameplaySession:{selectedSessionId:_.selectedSessionId,latestSessionId:_.sessions[0]?.id??null,selectedStatus:_.selectedSession?.status??null,cursorMs:_.cursorMs,liveEdgeMs:_.liveEdgeMs},openDocumentIds:FA().map(b=>b.descriptor.id),activeTabKey:(()=>{const b=I_();return b&&INt(b)?b:"__inspector__"})(),showGrid:l?.grid??t.showGrid,showHelpers:bP(t).showHelpers,showStats:bP(t).showStats,shadingMode:l?.mode??t.shadingMode,helperVisibility:{...bP(t).helperVisibility,...l?{bounds:l.bounds,skeletons:l.skeleton}:{}},transformMode:bP(t).transformMode,transformSpace:t.transformSpace,snapEnabled:t.snapEnabled,entityCount:g.length,savePath:UUe(t),saveState:aNt(t),camera:lbn(t),entities:g,viewportActivationTimings:ZOr()}}function OGt(t,r){const i=r instanceof Error?r.message:String(r),a=`editor command "${String(t.type)}" threw: ${i}`;return console.error(a,r),{ok:!1,error:a}}function kEt(t){const r=t.size,i=t.width,a=t.height;if(i!==void 0||a!==void 0){if(r!=null)return{error:`${String(t.type)}: pass "size" (a square) OR "width"+"height" (a shaped frame), never both.`};const d=(b,S)=>typeof S!="number"||!Number.isInteger(S)?`${String(t.type)}: "${b}" must be a whole number — got ${typeof S} ${JSON.stringify(S)??String(S)}.`:S<IEt||S>J$?`${String(t.type)}: "${b}" must be ${IEt}-${J$} — ${DEt}`:S,_=d("width",i);if(typeof _=="string")return{error:_};const g=d("height",a);return typeof g=="string"?{error:g}:_*g>J$*J$?{error:`${String(t.type)}: ${_}x${g} is ${_*g} pixels, past the ${J$}x${J$} total — ${DEt}`}:{size:{width:_,height:g}}}return r==null?{}:typeof r!="number"||!Number.isFinite(r)||r<1?{error:`${String(t.type)}: "size" must be a finite number >= 1 — got ${typeof r} ${JSON.stringify(r)??String(r)}.`}:{size:r}}const IEt=64,J$=1024,DEt="the editor's own ceiling: the pixels cross the relay as base64 JSON, and 1024 is where even incompressible RGBA still fits its 50 MB request limit. For more picture, take more views, not bigger ones.";function lw(){const t=I_();return t?Pw(t):null}function VQe(t){const r=xQe();return!r||t<r.startedAt?!1:r.endedAt===null||t<=r.endedAt}function pbn(){return ua.getEntries().filter(t=>t.level==="error"&&t.source==="runtime"&&VQe(t.timestamp)).slice(-100).map(t=>t.count>1?`${t.message} (×${t.count})`:t.message)}const PEt=200;function _bn(){return JQe(ua.getEntries().filter(t=>t.level==="error"&&t.source!=="runtime"&&VQe(t.timestamp)))}function JQe(t){const r=t.reduce((a,l)=>a+l.count,0),i=t.slice(-3).map(a=>{const l=a.source?`[${a.source}] `:"",d=a.count>1?` (×${a.count})`:"",_=a.message.length>PEt?`${a.message.slice(0,PEt)}…`:a.message;return`${l}${_}${d}`});return{count:r,recent:i}}function mbn(){return JQe(ua.getEntries().filter(t=>t.level==="error"&&!VQe(t.timestamp)))}function hbn(){return JQe(ua.getEntries().filter(t=>t.level==="warn"))}async function gbn(t){const r=t.src;if(typeof r!="string")return{ok:!1,error:`document-script requires a string "src" (the step's toString())`};const i=I_();if(!i)return{ok:!1,error:"document-script: no document is active",data:{code:"DOCUMENT_SCRIPT_UNAVAILABLE"}};await w3t(i);const a=_Z(i);if(I_()!==i)return{ok:!1,error:"document-script: the active document changed while its context was loading",data:{code:"DOCUMENT_SCRIPT_UNAVAILABLE",documentId:i}};if(a===void 0)return{ok:!1,error:`document-script: the active document (${i}) publishes no context to run against — a document opts in through its \`publishContext\` prop (the mesh document publishes its session).`,data:{code:"DOCUMENT_SCRIPT_UNAVAILABLE",documentId:i}};let l;try{l=new Function("ctx","info",`return (${r})(ctx, info)`)}catch(d){return{ok:!1,error:`document-script: failed to reconstruct the step function from source — ${d instanceof Error?d.message:String(d)}`,data:{code:"DOCUMENT_SCRIPT_ERROR"}}}try{const d=await l(a,{documentId:i});return{ok:!0,data:{result:d===void 0?null:d}}}catch(d){return{ok:!1,error:`document-script: step threw — ${d instanceof Error?d.message:String(d)}`,data:{code:"DOCUMENT_SCRIPT_ERROR"}}}}async function ybn(t,r){const i=r.assetPath,a=r.entityId,l=r.glbBase64;if(+(typeof i=="string")+ +(typeof a=="string")+ +(typeof l=="string")!==1)return{ok:!1,error:"capture-asset-preview requires exactly one of assetPath, entityId or glbBase64."};const _=r.width,g=r.height,b=r.background,S=r.shots,k=r.shotSet,w=r.forward,N=r.compare,P=r.stage,j=r.camera,J=r.pose;if(_!==void 0&&typeof _!="number"||g!==void 0&&typeof g!="number"||b!==void 0&&b!=="neutral"&&b!=="transparent"||S!==void 0&&S!=="source")return{ok:!1,error:"Invalid asset preview dimensions, background, or shots mode."};if(P!==void 0&&P!=="lab"&&P!=="scene")return{ok:!1,error:`capture-asset-preview stage must be "lab" or "scene", got ${String(P)}.`};if(k!==void 0&&S!==void 0)return{ok:!1,error:"capture-asset-preview cannot combine a shotSet definition with a shots mode."};const X=uNt("capture-asset-preview",j);if(typeof X=="string")return{ok:!1,error:X};const G=fNt("capture-asset-preview",J);if(typeof G=="string")return{ok:!1,error:G};if((X||G)&&(S!==void 0||k!==void 0||N!==void 0||P==="scene"))return{ok:!1,error:'capture-asset-preview cannot combine camera/pose with a shots mode, a shotSet definition, compare, or stage "scene" — those legs stage their own cameras and poses.'};let ee;if(k!==void 0)try{ee=i$r(k)}catch(se){return{ok:!1,error:se instanceof Error?se.message:String(se)}}const xe=ame(w);if(S==="source"&&xe===null)return{ok:!1,error:"capture-asset-preview --shots source requires a non-degenerate forward [x,y,z]."};if(N!==void 0){if(S!==void 0||ee!==void 0)return{ok:!1,error:"capture-asset-preview cannot combine compare with shots."};if(typeof N!="object"||N===null||typeof N.glbBase64!="string"||N.forward!==void 0&&ame(N.forward)===null)return{ok:!1,error:"capture-asset-preview compare requires { glbBase64: string, forward?: [x, y, z] } with a non-degenerate ground-plane forward."}}if(typeof l=="string"){if(S!==void 0||N!==void 0)return{ok:!1,error:"capture-asset-preview cannot combine glbBase64 with a named shots mode or compare."};if(P==="scene")return{ok:!1,error:'capture-asset-preview stage "scene" photographs a live scene entity — glbBase64 bytes stand nowhere in the scene.'}}const ue=P==="scene"?t.scene:null;if(P==="scene"){if(typeof a!="string")return{ok:!1,error:'capture-asset-preview stage "scene" photographs a live scene entity — pass entityId, not assetPath.'};if(S!==void 0||ee!==void 0||N!==void 0)return{ok:!1,error:'capture-asset-preview cannot combine stage "scene" with a shots mode, a shotSet definition or compare.'};if(!ue)return{ok:!1,error:'capture-asset-preview stage "scene" requires a bound viewport scene; none is bound yet.'}}const fe=typeof a=="string"?dte(tO(t),t.objectMap,a):null;if(typeof a=="string"&&!fe)return{ok:!1,error:`Entity not found: ${a}`};try{const se={...typeof _=="number"?{width:_}:{},...typeof g=="number"?{height:g}:{},...b?{background:b}:{},...X?{camera:X}:{},...G?{pose:G}:{}};if(N!==void 0){const ge=N,qe=ame(ge.forward),tt={...typeof _=="number"?{width:_}:{},...typeof g=="number"?{height:g}:{},...qe?{refForward:qe}:{}};return{ok:!0,data:{...typeof i=="string"?await U$r(i,ge.glbBase64,tt):await rNt(fe,ge.glbBase64,tt)}}}return ee!==void 0?{ok:!0,data:{...typeof l=="string"?await F$r(l,ee,se):typeof i=="string"?await j$r(i,ee,se):qUe(fe,ee,se)}}:S==="source"?{ok:!0,data:{...typeof i=="string"?await M$r(i,xe,se):Y6t(fe,xe,se)}}:ue?{ok:!0,data:{...E$r(fe,ue,se)}}:typeof l=="string"?{ok:!0,data:{...await O$r(l,se)}}:{ok:!0,data:{...typeof i=="string"?await tNt(i,se):j0e(fe,se)}}}catch(se){return{ok:!1,error:se instanceof Error?se.message:String(se)}}}async function vbn(t,r,i){cqr(r.type);const a=EQe(r);if(a)return a;if(r.type==="play"||r.type==="restart"){const _=IZ();if(_.length>0)return{ok:!1,error:`this project's ${_.length===1?"root":"roots"} did not mount, so there is nothing to ${r.type==="play"?"play":"restart"}: `+_.map(g=>`"${g.worldId}" (${g.identity}) — ${g.message}`).join("; ")}}const l=await y3r(r.type);if(l)try{const _=await l.handle(r);return{ok:_.ok,..._.error!==void 0?{error:_.error}:{},..._.data!==void 0?{data:_.data}:{}}}catch(_){return OGt(r,_)}if(!Jye(r.type))return{ok:!1,error:`unknown command type "${r.type}" — not one of the editor's own, and no package this project declares contributes it (or the editor page predates this CLI)`,data:{code:"UNKNOWN_COMMAND_TYPE"}};const d=r.type;switch(d){case"session-prepare-close":return await iyn(),{ok:!0};case"select":{const _=r.id??null;if(_!==null){const g=EEt(t,_);if(g)return{ok:!1,error:g}}HRe(t,_?[_]:[],i);break}case"select-multiple":{const _=r.ids;for(const g of _){const b=EEt(t,g);if(b)return{ok:!1,error:b}}HRe(t,_,i);break}case"select-all":{HRe(t,z0e(t).map(_=>_.id),i);break}case"focus-entity":lw()?.frameIds([r.id])||t.focusOnEntity(r.id);break;case"frame-entity":{const _=r.id;if(typeof _!="string"||_.length===0)return{ok:!1,error:'frame-entity requires a string "id" (the entity to frame).'};const g=lw();if(g){if(!g.frameIds([_]))return{ok:!1,error:`Entity not found: ${_}`,data:{code:"ENTITY_NOT_FOUND"}};break}const b=tO(t);if(b.hierarchy.node(_)!==null&&b.rects){t.focusOnEntity(_);break}if(!dte(b,t.objectMap,_))return{ok:!1,error:`Entity not found: ${_}`,data:{code:"ENTITY_NOT_FOUND"}};t.focusOnEntity(_);break}case"focus-selection":lw()?.frameSelection()||t.focusOnSelection();break;case"view-preset":{const _=r.preset,g=["top","front","right","perspective"];if(typeof _!="string"||!g.includes(_))return{ok:!1,error:`view-preset requires one of ${g.join(", ")}, got ${_===void 0?"nothing":JSON.stringify(_)}.`};const b=_,S=lw();S?S.setViewPreset(b==="perspective"?"isometric":b):t.setViewPreset(b);break}case"set-camera":{const _=r.position,g=r.target,b=r.fov;if(!_||!g||typeof _.x!="number"||typeof _.y!="number"||typeof _.z!="number"||typeof g.x!="number"||typeof g.y!="number"||typeof g.z!="number")return{ok:!1,error:"set-camera requires numeric {x,y,z} position and target."};const S=lw();S?S.setCameraPose(_,g,b):t.setCameraPose(_,g,b);break}case"document-orbit":case"document-turntable":{const _=lw();if(!_)return{ok:!1,error:`${r.type} needs an Object3D document open and active (a model, a live module, an entity model). Open one with \`editor.openAsset(<path>)\` first.`,data:{code:"NO_ACTIVE_OBJECT3D_DOCUMENT"}};const g=r.type==="document-orbit"?r.duration:r.seconds;return g!==void 0&&(typeof g!="number"||!(g>=0&&g<=60))?{ok:!1,error:`${r.type}: the move's length must be a number of seconds in 0..60.`}:{ok:!0,data:{...r.type==="document-orbit"?await _.orbit({...typeof r.azimuth=="number"?{azimuth:r.azimuth}:{},...typeof r.elevation=="number"?{elevation:r.elevation}:{},...typeof g=="number"?{duration:g}:{}}):await _.turntable({...typeof g=="number"?{seconds:g}:{},...typeof r.revolutions=="number"?{revolutions:r.revolutions}:{}})}}}case"document-frame":{const _=lw();if(!_)return{ok:!1,error:"document-frame needs an Object3D document open and active. For the Scene viewport use `frame-entity`/`focus-selection`.",data:{code:"NO_ACTIVE_OBJECT3D_DOCUMENT"}};const g=r.fit;return g!==void 0&&(typeof g!="number"||!(g>=.1&&g<=10))?{ok:!1,error:'document-frame: "fit" must be a number in 0.1..10.'}:_.frame(typeof g=="number"?g:1)?{ok:!0,data:{..._.cameraPose()}}:{ok:!1,error:"Nothing to frame: the document subject has no measurable bounds.",data:{code:"EMPTY_FRAME_BOUNDS"}}}case"viewport-tab":{const _=r.tab,g={scene:"edit",game:"play"};if(typeof _=="string"&&g[_])return{ok:!1,error:`viewport-tab: "${_}" was REMOVED — the viewport tabs are Edit · Play. Fix: use "${g[_]}".`};if(_!=="edit"&&_!=="play")return{ok:!1,error:`viewport-tab requires "edit" or "play", got ${String(_)}.`};t.setActiveViewportTab(_);break}case"show-panel":try{const _=r.panel;return typeof _!="string"||_.trim()===""?{ok:!1,error:'show-panel requires a non-empty "panel".'}:{ok:!0,data:{panel:await eGt(_)}}}catch(_){return{ok:!1,error:_ instanceof Error?_.message:String(_)}}case"active-tab":{const _=r.key;if(_!=="__inspector__"&&!xb(_)){const g=FA().map(b=>b.descriptor.id);return{ok:!1,error:`No open workspace document with id "${_}" — nothing was activated. `+(g.length>0?`Open documents: ${g.join(", ")}.`:"No documents are open in this workspace.")}}break}case"select-asset":{const _=r.path;if(typeof _!="string"||_.trim()==="")return{ok:!1,error:'select-asset requires a non-empty "path".'};const g=_.replace(/^\/+/,""),b=g.split("/").pop()??g,S=wg(b);YN({path:_,name:b,kind:Bq(S)??"unknown",capabilities:S,origin:"project"});break}case"open-asset-tab":{const _=r.kind,g=f8(t,r.path,_);if(!await DNt(g,_))return{ok:!1,error:`Asset document did not finish mounting its Inspector: ${g}`};break}case"close-asset-tab":{const _=r.key;INt(_)&&Y8(_);break}case"toggle-command-palette":FQe();break;case"toggle-console":obe();break;case"page-reload":return setTimeout(()=>{window.location.reload()},0),{ok:!0,data:{scheduled:!0}};case"set-workspace":{const _=r.workspace;if(!SZ(_))return{ok:!1,error:`set-workspace requires one of ${Yze().join(", ")}, got ${String(_)}.`};if(wS()===_)return{ok:!0,data:{workspace:_,applied:!0}};const g=vPt().then(()=>!0);CS(_);const b=await Promise.race([g,new Promise(S=>setTimeout(()=>S(!1),3e3))]);return{ok:!0,data:{workspace:_,applied:b}}}case"set-style":{const _=r.style,g=lU().map(S=>S.id);if(typeof _!="string"||!g.includes(_))return{ok:!1,error:`set-style requires one of ${g.join(", ")}, got ${String(_)}.`};nUe(_);const b=Bhe();return b!==_?{ok:!1,error:`set-style applied "${_}" but the editor is wearing ${b===null?"a custom mix of axes":`"${b}"`}.`,data:{style:b}}:{ok:!0,data:{style:_}}}case"set-appearance":{const _=r.material;return _===void 0?{ok:!1,error:"set-appearance needs a `material` to set."}:i0e(_)?(CPt(_),{ok:!0,data:{material:fz(),style:Bhe()}}):{ok:!1,error:`set-appearance material must be one of ${A5r().map(b=>b.id).join(", ")}, got ${String(_)}.`}}case"present-view":try{return{ok:!0,data:{...await bye(t,r.view)}}}catch(_){return{ok:!1,error:_ instanceof Error?_.message:String(_)}}case"current-view":return{ok:!0,data:{view:ute(t)}};case"inspect":return{ok:!0,data:{subject:sbe(t)}};case"run-inspection-action":try{const _=r.actionId;if(typeof _!="string"||_.trim()==="")throw new Error("run-inspection-action requires a non-empty actionId.");return{ok:!0,data:{subject:await G1n(t,_)}}}catch(_){return{ok:!1,error:_ instanceof Error?_.message:String(_)}}case"run-command":try{const _=r.commandId;if(typeof _!="string"||_.trim()==="")throw new Error("run-command requires a non-empty commandId.");const g=await e0n(_,r.args);return{ok:!0,data:{result:g===void 0?null:g}}}catch(_){return{ok:!1,error:_ instanceof Error?_.message:String(_)}}case"hierarchy":{const _=HCt();return _===null?{ok:!1,error:"the hierarchy panel (GameHierarchy) is not mounted — no row tree is rendered, so there is nothing to report. Open the Hierarchy panel in the workspace dock and retry."}:{ok:!0,data:{hierarchy:Zgn(_,{playState:t.playState,activeViewportTab:t.activeViewportTab})}}}case"expand-hierarchy-all":case"collapse-hierarchy-all":{const _=r.type==="expand-hierarchy-all",g=HCt();if(g===null)return{ok:!1,error:`the hierarchy panel (GameHierarchy) is not mounted — no row tree is rendered, so there is nothing to ${_?"expand":"collapse"}. Open the Hierarchy panel in the workspace dock and retry.`};const b=Ygn();_?g.expandAll():g.collapseAll();try{await b}catch(S){return{ok:!1,error:S instanceof Error?S.message:String(S)}}return{ok:!0,data:{}}}case"undo":case"redo":{const _=i?.history;if(!_)return{ok:!1,error:`${String(r.type)}: this editor has no history session attached, so there is nothing to undo.`};const g=r.type==="undo"?await _.undo():await _.redo(),b=_.getSnapshot();return{ok:!0,data:{moved:g,canUndo:b.canUndo,canRedo:b.canRedo,undoLabel:b.undoLabel,redoLabel:b.redoLabel}}}case"set-inspection-field":try{const _=r.path;if(typeof _!="string"||_.trim()==="")throw new Error("set-inspection-field requires a non-empty field path.");const g=await K1n(t,_,r.value);return{ok:!0,data:{subject:g.subject,write:g.write}}}catch(_){return{ok:!1,error:_ instanceof Error?_.message:String(_)}}case"remove-inspection-field":try{const _=r.path;if(typeof _!="string"||_.trim()==="")throw new Error("remove-inspection-field requires a non-empty field path.");const g=await Y1n(t,_);return{ok:!0,data:{subject:g.subject,write:g.write}}}catch(_){return _ instanceof aqe?{ok:!1,error:_.message,data:{code:"REMOVAL_UNAVAILABLE"}}:{ok:!1,error:_ instanceof Error?_.message:String(_)}}case"structure-op":try{const _=String(r.op??""),g=wm(t).adapter,b=VUe(t),S=Array.isArray(r.ids)?r.ids.filter(j=>typeof j=="string"):typeof r.id=="string"&&r.id.trim()!==""?[r.id]:b,k=S[0],w=()=>{if(!k)throw new Error(`structure-op "${_}" needs an id or a selected row.`);return k},N=j=>typeof r[j]=="string"&&r[j].trim()!==""?r[j]:void 0,P=g.structure;if(!P)return{ok:!1,error:"structure-op: the active authoring adapter exposes no structure provider."};switch(_){case"create":{const j=N("kind");if(!j)return{ok:!1,error:'structure-op "create" needs a `kind`.'};const J=A0e(g,j,N("parentId"));return{ok:!0,data:{id:J.id,write:await J.ack}}}case"delete":return{ok:!0,data:{write:S.length>1&&P.removeMany?await _Ue(g,S):await Uhe(g,w())}};case"duplicate":{if(S.length>1&&P.duplicateMany)return{ok:!0,data:{write:await o4t(g,S)}};const j=S0e(g,w());return{ok:!0,data:{id:j.id,write:await j.ack}}}case"reparent":{const j=N("parentId")??null;return{ok:!0,data:{write:await NR(g,w(),j)}}}case"reorder":{if(!P.reorder)return{ok:!1,error:"structure-op: this adapter has no `reorder`."};const j=N("beforeSiblingId")??null;return{ok:!0,data:{write:await mUe(g,w(),j)}}}case"wrap":return P.wrap?{ok:!0,data:{write:await x0e(g,w(),N("tag"))}}:{ok:!1,error:"structure-op: this adapter has no `wrap`."};case"unwrap":return P.unwrap?{ok:!0,data:{write:await w0e(g,w())}}:{ok:!1,error:"structure-op: this adapter has no `unwrap`."};case"group":{if(!P.group)return{ok:!1,error:"structure-op: this adapter has no `group`."};const j=C0e(g,S);return{ok:!0,data:{id:j.id,write:await j.ack}}}case"ungroup":{if(!P.ungroup)return{ok:!1,error:"structure-op: this adapter has no `ungroup`."};const j=hUe(g,w());return{ok:!0,data:{ids:j.ids,write:await j.ack}}}case"copy":return P.copy?{ok:!0,data:{copied:await E0e(g,S)}}:{ok:!1,error:"structure-op: this adapter has no `copy`."};case"cut":{if(!P.cut)return{ok:!1,error:"structure-op: this adapter has no `cut`."};const j=await T0e(g,S);return j===!1?{ok:!1,error:'structure-op "cut" was refused by the adapter.'}:{ok:!0,data:{write:j}}}case"paste":{if(!P.paste)return{ok:!1,error:"structure-op: this adapter has no `paste`."};const j=N("parentId")??(k?g.hierarchy.node(k)?.parentId??null:null),J=await k0e(g,j);return J===!1?{ok:!1,error:'structure-op "paste" was refused by the adapter.'}:{ok:!0,data:{write:J}}}default:return{ok:!1,error:`structure-op: unknown op ${JSON.stringify(_)}. Known ops: create, delete, duplicate, reparent, reorder, wrap, unwrap, group, ungroup, copy, cut, paste.`}}}catch(_){return{ok:!1,error:_ instanceof Error?_.message:String(_)}}case"document-probe":try{return{ok:!0,data:{...await y0n(r.step)}}}catch(_){return{ok:!1,error:_ instanceof Error?_.message:String(_)}}case"capture-active-document":{const _=kEt(r);if("error"in _)return{ok:!1,error:_.error};try{return r.view&&await bye(t,r.view),{ok:!0,data:{...await F0n(t,_.size)}}}catch(g){return{ok:!1,error:g instanceof Error?g.message:String(g)}}}case"capture-editor-chrome":{const _=r.scale;if(_!==void 0&&(typeof _!="number"||!(_>0)||_>4))return{ok:!1,error:`capture-editor-chrome: "scale" must be a number greater than 0 and no more than 4 (output pixels per CSS pixel; the frame crosses the relay as base64 PNG). It defaults to the page's own devicePixelRatio.`};try{return{ok:!0,data:{...await Wgn(t,_===void 0?void 0:{scale:_})}}}catch(g){return{ok:!1,error:g instanceof Error?g.message:String(g)}}}case"capture-viewport":{const _=kEt(r);if("error"in _)return{ok:!1,error:_.error};const g=t.captureViewportImage(_.size);if(!g)return{ok:!1,error:"This door photographs the editor's own three.js Scene viewport, and nothing has bound one (no renderer/scene/camera). A canvas-surface world (a first-party canvas root, or a PixiJS/Phaser/Babylon ingest) never binds it — it draws on its own canvas in the Game document. Capture that through `capture-active-document` (`editor.captureActiveDocument()`) or the running game through `bridge-screenshot` (`vgai screenshot`)."};const b=g.indexOf(",");return{ok:!0,data:{base64:b>=0?g.slice(b+1):g,mimeType:"image/png"}}}case"capture-asset-preview":return ybn(t,r);case"document-table":{const _=v1();return _?{ok:!0,data:{default:_.scenes.default??null,entries:_.scenes.entries,pending:_.documentsPending===!0}}:{ok:!1,error:"The project adapter has not resolved yet — no document table to list.",data:{code:"SCENE_TABLE_UNAVAILABLE"}}}case"open":{const _=r.id;if(typeof _!="string"||_.trim()==="")return{ok:!1,error:"open requires a non-empty scene-table entry id."};const g=rbe(),b=g?v1()?.scenes.entries.find(N=>N.id===_):void 0,S=g?async N=>await MHt(N)??{ok:!1,error:"No running lane can remount with a selection."}:void 0,w=(b?await tbn(b,{scenes:TQe,activateGameDocument:()=>xb(Sw),gameDocumentId:Sw,...S?{remountSelection:S}:{}}):null)??await ihn(t,_);return w.ok?{ok:!0,data:{documentId:w.documentId,title:w.title,..."scene"in w&&w.scene?{scene:w.scene}:{},..."restart"in w&&w.restart?{restart:!0}:{}}}:{ok:!1,error:w.error,data:{code:w.code,...w.known===void 0?{}:{known:[...w.known]}}}}case"set-grid":{const _=lw();_?_.setGrid(r.enabled):t.showGrid!==r.enabled&&t.toggleGrid();break}case"set-helpers":{const _=bP(t);_.showHelpers!==r.enabled&&_.toggleHelpers();break}case"set-stats":{const _=bP(t);_.showStats!==r.enabled&&_.toggleStats();break}case"set-shading-mode":lw()?lw()?.setMode(r.mode):t.setShadingMode(r.mode);break;case"set-helper-type":{const _=bP(t),g=r.helperType,b=lw();if(b&&g==="bounds"){b.setBounds(r.enabled);break}if(b&&g==="skeletons"){b.setSkeleton(r.enabled);break}_.helperVisibility[g]!==r.enabled&&_.toggleHelperType(g);break}case"set-transform-mode":t.setTransformMode(r.mode);break;case"set-transform-space":t.setTransformSpace(r.space);break;case"set-snap":t.snapEnabled!==r.enabled&&t.toggleSnap();break;case"document-script":return gbn(r);default:return{ok:!1,error:`unknown command type "${String(d)}" — editor page predates this CLI`,data:{code:"UNKNOWN_COMMAND_TYPE"}}}return{ok:!0}}function bbn(t,r){const i=VP();let a=null,l=-1;const d=new Set;let _=!1,g=null,b=null,S=null;const k=()=>{Jpe()===null&&(a=TEt(t),l=t.contentVersion,W2t(a))};let w=null;const N=()=>{g!==null&&(clearTimeout(g),g=null),w?.(),w=null},P=()=>{b=null,S!==null&&clearTimeout(S),S=null},j=()=>{P(),_=!0,N(),g=setTimeout(()=>{g=null,w=KCt(()=>{w=null,_=!1,k()})},250)},J=cr=>{if(t.contentVersion!==cr){j();return}P(),b=cr,S=setTimeout(P,1e3)},X=()=>rbe()&&t.playState==="playing",G=cr=>{(cr!==null||b!==null&&t.contentVersion!==b||_&&t.contentVersion!==l)&&j()},ee=(cr,Yt,Lr)=>X()?(cbn(Lr,cr,t.contentVersion,l)&&(cr==="explicit"?j():cr==="if-content-changed"?J(Yt??t.contentVersion):G(Yt)),!0):!1,xe=(cr="always",Yt="none",Lr=null)=>{if(Jpe()!==null)return;if(a===null){k();return}const nn=TEt(t,a);a=nn,W2t(dbn(nn)),cr!=="none"&&(ee(Yt,Lr,cr)||(N(),P(),_=!1,!(cr==="if-content-changed"&&t.contentVersion===l)&&w===null&&(w=KCt(()=>{w=null,k()}))))};let ue=!1,fe=!1,se=t.playState;const de=cr=>{cr&&(fe=!0),!ue&&(ue=!0,queueMicrotask(()=>{ue=!1;const Yt=fe;fe=!1;const Lr=se!==t.playState;se=t.playState,xe(Yt?"always":"if-content-changed",Lr&&t.playState==="playing"?"explicit":"none")}))},ge=()=>de(!1),qe=()=>de(!0),tt=t.subscribe(ge),Ct=NQe(qe),Ot=YP(qe),vt=YOr(qe);k(),Wpe(!0),YFr(azr),i.addEventListener("open",()=>{xe("if-content-changed"),Wpe(Jpe()===null)});const Et=HUe(cr=>{Wpe(cr===null)});i.addEventListener("editor-command",cr=>{try{const Yt=JSON.parse(cr.data),Lr=Yt._requestId,nn=t.contentVersion,on=Jpe();if(on!==null){const An=Aqr(on,String(Yt.type));Lr&&H2t(Lr,!1,An);return}Lr&&ozr(Lr);let gr;vbn(t,Yt,{deferPresentation:An=>{gr=An},...r?{history:r}:{}}).catch(An=>OGt(Yt,An)).then(An=>{if(Lr){const ln=H2t(Lr,An.ok,An.error,An.data,gr!==void 0);if(gr){const Mn=()=>window.setTimeout(gr,0);ln.then(Mn,Mn)}}else gr&&window.setTimeout(gr,0);const Rn=abn(Yt,An.ok,d);xe(Rn.derived,Rn.playFullReport,nn)})}catch{}}),i.addEventListener("project-changed",()=>{window.location.reload()});const Tt=()=>xe();document.addEventListener("visibilitychange",Tt),window.addEventListener("focus",Tt),window.addEventListener("blur",Tt);const Le=()=>setTimeout(Tt,0);return window.addEventListener("error",Le),window.addEventListener("unhandledrejection",Le),()=>{Wpe(!1),w?.(),w=null,g!==null&&clearTimeout(g),g=null,P(),Et(),tt(),Ct(),Ot(),vt(),document.removeEventListener("visibilitychange",Tt),window.removeEventListener("focus",Tt),window.removeEventListener("blur",Tt),window.removeEventListener("error",Le),window.removeEventListener("unhandledrejection",Le),i.close()}}function Abn(t,r,i){return Xe.createContext(i)}const XP=Abn(void 0,"EditorContext",null);function Sbn({runtime:t,children:r}){const i=Xe.useMemo(()=>({begin:()=>{},end:()=>{}}),[]);return z.jsx(XP.Provider,{value:t,children:z.jsx(y3t.Provider,{value:i,children:z.jsx(Xe.Suspense,{children:r})})})}function D0(){const t=Xe.useContext(XP);if(!t)throw new Error("useEditorStore must be used within <EditorProvider>");return t.store}function o4n(){const t=Xe.useContext(XP);if(!t)throw new Error("useEditorStats must be used within <EditorProvider>");return t.stats}function xbn(){const t=Xe.useContext(XP);if(!t)throw new Error("useEditorInit must be used within <EditorProvider>");return t.initPromise}function FGt(){const t=Xe.useContext(XP);if(!t)throw new Error("useHistoryService must be used within <EditorProvider>");return t.session.history}function wbn(){return Xe.useContext(XP)?.session.history??null}function a4n(){return Xe.useContext(XP)?.store??null}function c4n(){return Xe.useContext(XP)?.stats??null}function cbe(){const t=Xe.useContext(XP);if(!t)throw new Error("useHistoryCommands must be used within <EditorProvider>");return t.session.historyCommands}function RGt(){const t=cbe();return Xe.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getSnapshot)}class Cbn{constructor(){this.isPass=!0,this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1}setSize(){}render(){console.error("THREE.Pass: .render() must be implemented in derived pass.")}dispose(){}}const Ebn=new $ye(-1,1,1,-1,0,1);class Tbn extends Kqe{constructor(){super(),this.setAttribute("position",new U1t([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new U1t([0,2,0,0,2,0],2))}}const kbn=new Tbn;class Ibn{constructor(r){this._mesh=new NA(kbn,r)}dispose(){this._mesh.geometry.dispose()}render(r){r.render(this._mesh,Ebn)}get material(){return this._mesh.material}set material(r){this._mesh.material=r}}const A_e={name:"OutputShader",uniforms:{tDiffuse:{value:null},toneMappingExposure:{value:1}},vertexShader:`
|
|
1603
|
+
`)}const G$e=new Set;function Ryn(t){return G$e.add(t),()=>{G$e.delete(t)}}function Myn(){for(const t of[...G$e])try{t()}catch(r){ua.error(`a session-sample subscriber threw: ${String(r)}`,"invariant")}}const Lyn=5e3;let hw={frames:0,since:0},KX=null,Qq=null,$R=null;const YX=new Map;function jyn(t){const r=window.getComputedStyle(t);if(r.display==="none")return"display: none";if(r.visibility==="hidden")return"visibility: hidden";if(Number.parseFloat(r.opacity||"1")===0)return"opacity: 0";const i=t.getBoundingClientRect();return i.width<=0||i.height<=0?"zero-size box":null}const Byn="editor-canvas";function $yn(t){const r=t.style;return r.display==="none"?"display":r.visibility==="hidden"?"visibility":r.opacity!==""&&Number.parseFloat(r.opacity)===0?"opacity":null}function QHt(){return[...document.querySelectorAll("canvas")].map((r,i)=>{const a=r.getAttribute("data-testid"),l=r.getBoundingClientRect();return{label:a??(r.className||`canvas #${i}`),area:Math.max(0,l.width)*Math.max(0,l.height),hiddenBy:jyn(r),inlineHiding:$yn(r),failsafeEligible:a!==Byn}})}function qyn(){const t=Ayn();if(t.length===0)return{framesDrawn:null,framesUnavailable:"no render loop registered a performance source, so nothing counts this session’s frames"};let r=null;for(const i of t){const l=i.profiler.getSnapshot().frames.at(-1);l&&(r=Math.max(r??0,l.id))}return r===null?{framesDrawn:null,framesUnavailable:"the registered render loop records no frames (its profiler has neither profiling nor telemetry enabled)"}:{framesDrawn:r,framesUnavailable:null}}const nR=new Map,TY=new Map;function zyn(){const t=Eyn(),r=new Set,i=t.map(a=>{const{id:l,label:d}=a;r.add(l);let _=null;try{_=a.transportAdvances?.()??null}catch{_=null}const g=TY.get(l);_===null?TY.delete(l):TY.set(l,_);const b=_===null||g===void 0?{}:{transportAdvanced:_!==g};let S;try{S=a.contentClock()}catch(N){return nR.delete(l),{id:l,label:d,advanced:null,unavailable:`its content clock threw: ${String(N)}`,...b}}if(S===null)return nR.delete(l),{id:l,label:d,advanced:null,unavailable:"its content clock is temporarily unavailable",...b};const k=S,w=nR.get(l);return nR.set(l,k),w===void 0?{id:l,label:d,advanced:null,unavailable:"first reading — nothing to compare it against yet",...b}:{id:l,label:d,advanced:k!==w,...b}});for(const a of[...nR.keys()])r.has(a)||nR.delete(a);for(const a of[...TY.keys()])r.has(a)||TY.delete(a);return i}function Uyn(t=Date.now()){const r=rbe(),i=hw.since===0?0:t-hw.since,a=hw.frames,l=i>0&&a>0?a*1e3/i:null,d=r?{startedMsAgo:$R===null?0:t-$R,...qyn()}:null;return{mode:r?"play":"edit",loops:[...U$e().map(_=>({name:`${_.id} session`,running:_.mounted()})),...U$e().map(_=>({name:`${_.id} playing`,running:_.playing()}))],designTimeSurfaces:zyn(),presentedThreeRoots:XPt()?vyn().filter(_=>_.surface==="three").map(_=>_.worldId):null,...(()=>{const _=QHt();return{canvasHiddenBy:OQe(_),canvasHidesItself:xyn(_),hiddenCanvases:Syn(_)}})(),framesProduced:hw.since===0?null:a,sampleWindowMs:hw.since===0?null:i,tabVisible:!document.hidden,directManipulationExpected:navigator.webdriver!==!0,fps:l,fpsUnavailable:l===null?hw.since===0?"the frame sampler has not opened a window yet":"no frame was produced in the sample window":null,play:d}}function KHt(){return Oyn(Uyn())}let Cq=null;const ZCt=new WeakSet;function Vyn(t,r){const i=OQe(t);if(i==null){Cq=null;return}if(Cq===null){Cq=r;return}const a=Cyn({canvases:t,framesProduced:hw.frames,hiddenForMs:r-Cq});if(!a.fire)return;const l=[...document.querySelectorAll("canvas")].find(d=>(d.getAttribute("data-testid")??d.className)===a.target.label);!l||ZCt.has(l)||(ZCt.add(l),a.target.inlineHiding==="display"&&l.style.removeProperty("display"),a.target.inlineHiding==="visibility"&&l.style.removeProperty("visibility"),a.target.inlineHiding==="opacity"&&l.style.removeProperty("opacity"),ua.error(a.ledger,"invariant"))}function Jyn(){const t=KHt();for(const r of t){const i=Fyn(r);if(!i){YX.delete(r.id);continue}if(r.id==="visible-tab-fps-floor"){const a=(YX.get(r.id)??0)+1;if(YX.set(r.id,a),a<3)continue}ua.warn(i,"invariant")}return t}function Wyn(){if(Qq!==null)return eEt;hw={frames:0,since:Date.now()};const t=()=>{hw.frames++,KX=requestAnimationFrame(t)};return KX=requestAnimationFrame(t),Qq=setInterval(()=>{const r=rbe();r&&$R===null&&($R=Date.now()),r||($R=null),Myn(),Vyn(QHt(),Date.now()),Jyn(),hw={frames:0,since:Date.now()}},Lyn),eEt}function Hyn(){hw={frames:0,since:Qq===null?0:Date.now()},$R=null,Cq=null,YX.clear(),nR.clear()}function eEt(){KX!==null&&cancelAnimationFrame(KX),Qq!==null&&clearInterval(Qq),KX=null,Qq=null,hw={frames:0,since:0},$R=null,Cq=null,YX.clear()}let Q$e=null;function Gyn(t){Q$e=t}function FQe(){return Q$e?(Q$e(),!0):!1}let RQe=[];const K$e=new Set;function tEt(t){RQe=t;for(const r of K$e)r()}function Qyn(){return RQe}function Kyn(t){return K$e.add(t),()=>K$e.delete(t)}function Yyn(t){const r=RQe.find(i=>i.id===t);return r?(r.run(),!0):!1}let Y$e=null;function Xyn(t){Y$e=t}const Zyn=/^vgai\.([^.]+)\.(.+)$/;async function e0n(t,r){if(Y$e)return await Y$e(t,r);const i=Zyn.exec(t);if(!i)throw new Error(`No command "${t}". Without the Code-OSS frame there is no command service, so the only commands this editor answers are a view's own verbs, spelled vgai.<view>.<verb> (for example vgai.blender-node-view.view-all).`);const{invokeViewVerb:a}=await Xo(async()=>{const{invokeViewVerb:l}=await Promise.resolve().then(()=>kMr);return{invokeViewVerb:l}},void 0);return a(i[1],i[2],r)}function YHt(t){return Array.from(document.querySelectorAll("[data-workspace-document-id]")).find(r=>r.dataset.workspaceDocumentId===t&&(X9e()===null||r.dataset.workspaceViewId===X9e()))??null}const X$e=["document","header","shelf","rail","outliner","content"],t0n={rail:{part:"properties",view:"vgai.properties",title:"Properties"},outliner:{part:"outliner",view:"vgai.outliner",title:"Outliner"},content:{part:"content",view:"vgai.content",title:"Content"}},r0n={header:{prefix:"document-header",title:"header strip"},shelf:{prefix:"document-shelf",title:"tool shelf"}};function MQe(t){const r=[t.container];for(let i=0;i<r.length;i++)for(const a of r[i].querySelectorAll("[data-vgai-portal]")){const l=a.dataset.vgaiPortal;if(l===void 0)continue;const d=document.querySelector(`[data-vgai-portal-content="${CSS.escape(l)}"]`);d&&!r.includes(d)&&r.push(d)}return r}function n0n(t){return document.querySelector(`[data-vgai-part="${t}"]`)}function i0n(t){const r=t==="rail"||t==="outliner"||t==="content"?t0n[t]:null;if(r){const i=n0n(r.part);if(!i)throw new Error(`The ${r.title} view (${r.view}) is not open, so scope '${t}' has nothing to reach. Open it from the workbench (View: Open View…) and retry — this door reads and drives what is on screen, and reports its absence rather than an empty match list.`);return{container:i,name:t,id:r.view,title:r.title}}return s0n(t)}function s0n(t){const r=AE();if(!r)throw new Error(`No active editor document, so scope '${t}' has nothing to reach. The editor's own views are still readable: scope 'outliner', scope 'rail', and scope 'content'.`);const i=I_()??r.descriptor.id;if(i===Sw)throw new Error("The Game document is out of this door's scope: drive and read a game through its own doors — `game.commands()`/`game.command(n)`/`game.state(n)`, or `page(step)` during play — never through synthetic DOM gestures. The editor's own views around it stay readable while a game is active: scope 'outliner' and scope 'rail'.");const a=YHt(i);if(!a)throw new Error(`The active document's surface is not mounted: ${i} (${r.title}). Present it first (\`editor.present\`) and retry.`);const l=a.closest(".vgai-dock-document")??a;if(t==="document")return{container:l,name:t,id:i,title:r.title};const d=r0n[t],_=l.querySelector(`[data-testid="${d.prefix}:${i}"]`);if(!_)throw new Error(`The active document "${r.title}" (${i}) draws no ${d.title}, so scope '${t}' has nothing to reach. Its whole box is scope 'document'.`);return{container:_,name:t,id:i,title:`${r.title} — ${d.title}`}}function rEt(t,r){return new Error(`Out of scope: ${r}. This step ran in scope '${t.name}' — "${t.title}" (${t.id}) — and reaches ONLY inside it. The other surfaces are named, not walked to: ${X$e.filter(i=>i!==t.name).map(i=>`'${i}'`).join(", ")} (pass \`{ scope }\`). The rest of the page is deliberately unreachable.`)}const nEt=400,iEt="rgb(1, 2, 3)",o0n="rgba(0, 0, 0, 0)";function a0n(t,r){const i=getComputedStyle(t).getPropertyValue(r).trim();if(i==="")return"";const l=t.ownerDocument.createElement("span");l.style.position="absolute",l.style.pointerEvents="none",l.style.visibility="hidden",l.style.backgroundColor=iEt,t.appendChild(l);try{l.style.backgroundColor=`var(${r})`;const d=getComputedStyle(l).backgroundColor.trim();return d===iEt||d===o0n?i:d}finally{l.remove()}}function c0n(t,r){const i=getComputedStyle(t),a={};for(const l of r)a[l]=l.startsWith("--")?a0n(t,l):i.getPropertyValue(l0n(l)).trim();return a}function l0n(t){return t.includes("-")?t:t.replace(/[A-Z]/g,r=>`-${r.toLowerCase()}`)}function sEt(t,r,i){const a=t,l={};for(const S of Array.from(t.attributes))l[S.name]=S.value;const d=a.getBoundingClientRect(),_=t.value,g=t.checked,b=(a.innerText||t.textContent||"").trim();return{index:r,tag:t.tagName.toLowerCase(),text:b.length>nEt?`${b.slice(0,nEt)}…`:b,attributes:l,rect:{x:d.x,y:d.y,width:d.width,height:d.height},...typeof _=="string"?{value:_}:{},...typeof g=="boolean"?{checked:g}:{},...a.hasAttribute("disabled")?{disabled:!0}:{},...i&&i.length>0?{styles:c0n(a,i)}:{}}}function zme(t,r,i){const a=ZHt(t,r),l=a[i];if(!l)throw rEt(t,`${JSON.stringify(r)} matched ${a.length} element(s), so index ${i} does not exist`);if(!MQe(t).some(d=>d.contains(l)))throw rEt(t,`${JSON.stringify(r)} resolved outside the document's container`);return l}function u0n(t){const r=t.getBoundingClientRect();return{bubbles:!0,cancelable:!0,composed:!0,view:window,clientX:r.x+r.width/2,clientY:r.y+r.height/2,button:0,buttons:1}}function f0n(t,r=1){const i=u0n(t),a=Math.max(1,Math.round(r));XHt(t,()=>{for(let l=1;l<=a;l++){const d={...i,detail:l},_={...i,buttons:0,detail:l};t.dispatchEvent(new PointerEvent("pointerdown",{...d,pointerType:"mouse"})),t.dispatchEvent(new MouseEvent("mousedown",d)),t.focus(),t.dispatchEvent(new PointerEvent("pointerup",{..._,pointerType:"mouse"})),t.dispatchEvent(new MouseEvent("mouseup",_)),t.dispatchEvent(new MouseEvent("click",_))}a>=2&&t.dispatchEvent(new MouseEvent("dblclick",{...i,buttons:0,detail:a}))})}function d0n(t,r,i,a){const l=t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement?t:null;if(!l)throw new Error(`Cannot type into a <${t.tagName.toLowerCase()}>: this verb drives a text field. Click the control that opens one first (the Outliner's rename is a double click — \`click(selector, { clicks: 2 })\`), then \`type\` into the field it puts up.`);const d=t instanceof HTMLTextAreaElement?HTMLTextAreaElement.prototype:HTMLInputElement.prototype,_=Object.getOwnPropertyDescriptor(d,"value")?.set,g=S=>{_?_.call(l,S):l.value=S};l.focus();let b=l.value;i&&b!==""&&(l.select?.(),b="",g(b),l.dispatchEvent(new InputEvent("input",{bubbles:!0,composed:!0,inputType:"deleteContentBackward"})));for(const S of[...r]){const k={key:S,bubbles:!0,cancelable:!0,composed:!0};l.dispatchEvent(new KeyboardEvent("keydown",k)),b+=S,g(b),l.dispatchEvent(new InputEvent("input",{bubbles:!0,composed:!0,inputType:"insertText",data:S})),l.dispatchEvent(new KeyboardEvent("keyup",k))}if(a){const S={key:"Enter",code:"Enter",bubbles:!0,cancelable:!0,composed:!0};l.dispatchEvent(new KeyboardEvent("keydown",S)),l.dispatchEvent(new KeyboardEvent("keyup",S))}}function XHt(t,r){const i=Element.prototype,a=i.setPointerCapture,l=i.releasePointerCapture;i.setPointerCapture=()=>{},i.releasePointerCapture=()=>{};try{r()}finally{i.setPointerCapture=a,i.releasePointerCapture=l}}function p0n(t,r,i,a,l={},d=[]){const _=t.getBoundingClientRect(),g=(S,k)=>({bubbles:!0,cancelable:!0,composed:!0,view:window,clientX:_.x+_.width*S,clientY:_.y+_.height*k,button:0,buttons:1,altKey:l.altKey??!1,ctrlKey:l.ctrlKey??!1,metaKey:l.metaKey??!1,shiftKey:l.shiftKey??!1}),b=g(r[0],r[1]);XHt(t,()=>{t.dispatchEvent(new PointerEvent("pointermove",{...b,button:-1,buttons:0,pointerType:"mouse"})),t.dispatchEvent(new MouseEvent("mousemove",{...b,buttons:0})),t.dispatchEvent(new PointerEvent("pointerdown",{...b,pointerType:"mouse"})),t.dispatchEvent(new MouseEvent("mousedown",b)),t.focus();const S=Math.max(1,Math.round(a)),k=[r,...d,i];for(let N=0;N+1<k.length;N++){const P=k[N],j=k[N+1];for(let J=1;J<=S;J++){const X=J/S,G=g(P[0]+(j[0]-P[0])*X,P[1]+(j[1]-P[1])*X);t.dispatchEvent(new PointerEvent("pointermove",{...G,button:-1,pointerType:"mouse"})),t.dispatchEvent(new MouseEvent("mousemove",G))}}const w={...g(i[0],i[1]),buttons:0};t.dispatchEvent(new PointerEvent("pointerup",{...w,pointerType:"mouse"})),t.dispatchEvent(new MouseEvent("mouseup",w)),r[0]===i[0]&&r[1]===i[1]&&t.dispatchEvent(new MouseEvent("click",w))})}function _0n(t,r){if(r)return r;const i=document.activeElement;return i instanceof HTMLElement&&MQe(t).some(a=>a.contains(i))?i:t.container}function ZHt(t,r){try{return MQe(t).flatMap(i=>Array.from(i.querySelectorAll(r)))}catch(i){throw new Error(`Invalid selector ${JSON.stringify(r)}: ${String(i)}`)}}function BRe(t,r){const i=r.selector===void 0?null:zme(t,r.selector,r.index??0);return _0n(t,i)}function m0n(t){return{key:t.key,code:t.code??t.key,bubbles:!0,cancelable:!0,composed:!0,...t.ctrlKey?{ctrlKey:!0}:{},...t.metaKey?{metaKey:!0}:{},...t.shiftKey?{shiftKey:!0}:{},...t.altKey?{altKey:!0}:{}}}function h0n(t,r){const i=[...t.options].map(l=>l.value);if(!i.includes(r))throw new Error(`No option with value ${JSON.stringify(r)} on this <select> — it offers ${i.map(l=>JSON.stringify(l)).join(", ")||"(no options)"}. The value is the option's \`value\`, not its label; \`query\` reports both.`);const a=Object.getOwnPropertyDescriptor(HTMLSelectElement.prototype,"value")?.set;a?a.call(t,r):t.value=r,t.dispatchEvent(new Event("input",{bubbles:!0,composed:!0})),t.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}const $Re=["query","click","drag","key","paste","select","type"];function g0n(t){const r=t?.action;if(!$Re.includes(r))throw new Error(`Unknown document-probe action ${JSON.stringify(r)}. This door has exactly ${$Re.length} verbs: ${$Re.join(", ")} (\`editor.document.*\`).`);const i=t.scope??"document";if(!X$e.includes(i))throw new Error(`Unknown scope ${JSON.stringify(i)}. This door addresses exactly these surfaces: ${X$e.map(a=>`'${a}'`).join(", ")}.`);return i0n(i)}async function y0n(t){const r=g0n(t),i={name:r.name,id:r.id,title:r.title},a=l=>({scope:i,matched:1,elements:[sEt(l,0)]});switch(t.action){case"query":{const l=ZHt(r,t.selector);return{scope:i,matched:l.length,elements:l.slice(0,t.limit??25).map((d,_)=>sEt(d,_,t.styles))}}case"click":{const l=zme(r,t.selector,t.index??0);return f0n(l,t.clicks??1),a(l)}case"type":{const l=BRe(r,t);return d0n(l,t.text,t.replace??!0,t.enter??!0),a(l)}case"drag":{const l=zme(r,t.selector,t.index??0);return p0n(l,t.from,t.to,t.steps??8,{...t.altKey===void 0?{}:{altKey:t.altKey},...t.ctrlKey===void 0?{}:{ctrlKey:t.ctrlKey},...t.metaKey===void 0?{}:{metaKey:t.metaKey},...t.shiftKey===void 0?{}:{shiftKey:t.shiftKey}},t.via??[]),a(l)}case"key":{const l=BRe(r,t),d=m0n(t);return l.dispatchEvent(new KeyboardEvent("keydown",d)),l.dispatchEvent(new KeyboardEvent("keyup",d)),a(l)}case"select":{const l=zme(r,t.selector,t.index??0);if(!(l instanceof HTMLSelectElement))throw new Error(`${JSON.stringify(t.selector)} resolved a <${l.tagName.toLowerCase()}>, not a <select>. This verb sets a dropdown's value; a button or a checkbox takes \`click\`.`);return h0n(l,t.value),a(l)}case"paste":{const l=BRe(r,t),d=new DataTransfer;return d.setData("text/plain",t.text),l.dispatchEvent(new ClipboardEvent("paste",{bubbles:!0,cancelable:!0,composed:!0,clipboardData:d})),a(l)}}}const LQe=[{kind:"agent",title:"Conversations",hotkeyScope:"workspace",selectableText:!0,icon:"users"},{kind:"project-work",title:"Project work",hotkeyScope:"workspace",selectableText:!0,icon:"list"},{kind:"hierarchy",title:"Hierarchy",hotkeyScope:"hierarchy",selectableText:!1,region:"outliner",icon:"outliner"},{kind:"assets",title:"Content",hotkeyScope:"asset-browser",selectableText:!1,icon:"folder-open"},{kind:"asset-library",title:"Asset Library",hotkeyScope:"asset-browser",selectableText:!1,icon:"cubes-stacked"},{kind:"inspector",title:"Inspector",hotkeyScope:"inspector",selectableText:!1,region:"properties",icon:"properties"}];async function v0n(t){const{liveCanvasFrame:r}=await Xo(async()=>{const{liveCanvasFrame:i}=await Promise.resolve().then(()=>Vgn);return{liveCanvasFrame:i}},void 0);return r(t)}async function b0n(...t){const{capturePlayComposite:r}=await Xo(async()=>{const{capturePlayComposite:i}=await Promise.resolve().then(()=>Chn);return{capturePlayComposite:i}},void 0);return r(...t)}async function oEt(){return Xo(()=>Promise.resolve().then(()=>JPt),void 0)}async function A0n(){return Xo(()=>Promise.resolve().then(()=>t2n),void 0)}const S0n=new Set(["solid","clay","unlit","wireframe","normals","overdraw"]);function x0n(t,r=5e3){return gE().some(i=>i.id===t)?Promise.resolve():new Promise(i=>{let a=0,l=()=>{};const d=()=>{clearTimeout(a),l(),i()};l=g0e(()=>{gE().some(_=>_.id===t)&&d()}),gE().some(_=>_.id===t)?d():a=window.setTimeout(d,r)})}async function w0n(t){if(t){if(!gE().some(r=>r.id===t)){const r=t.startsWith(ohe);if(r&&(await(await oEt()).refreshProjectToolContributions(),await x0n(t)),!gE().some(i=>i.id===t)){const i=gE().map(l=>l.id),a=r?(await oEt()).contributionFailureHint(t.slice(ohe.length)):"";throw new Error(`Utility is not registered: ${t}.`+a+` Registered utilities: ${i.length>0?i.join(", "):"(none)"}. A project contributes one by exporting a \`workspace.utility\` tool contribution; its view id is \`tool:<contribution-id>\`.`)}}hE(t)}}async function eGt(t){const r=LQe.map(a=>a.kind),i=r.find(a=>a===t);if(!i)throw new Error(`"${t}" is not a panel of this editor. Panels: ${r.join(", ")}.`);if(Hze(i),!await xE(()=>sPt()===i))throw new Error(`The ${i} panel is not in this workspace's layout, so it could not be focused. Panels: ${r.join(", ")}.`);return i}function C0n(t,r){return xb("workspace:scene"),"workspace:scene"}async function E0n(t){let r=!1;if(await xE(()=>(r=k$e(t.id),r||hCt(t.id)!==null),m9),r)return I_();const i=hCt(t.id);throw i?new Error(i):new Error(`World document is not registered: ${t.id}`)}async function T0n(t,r){const i=_=>_.filter(g=>g.id===r||g.label===r);let a=[];if(!await xE(()=>{const _=Sze(t)?.adapter?.stories;if(!_)return!1;a=_.storiesFor("");const g=i(a);return g.length===1?(_.apply(g[0].id,g[0].id),!0):a.length>0},m9))throw new Error(`The board mounted no stories provider within the wait window; story ${JSON.stringify(r)} was not applied.`);const d=i(a);if(d.length!==1)throw new Error(d.length===0?`No story matches ${JSON.stringify(r)}. This board's stories: ${a.map(_=>_.label).join(", ")||"(none)"}.`:`${JSON.stringify(r)} is ambiguous (${d.length} stories match) — use the story id: ${d.map(_=>_.id).join(" | ")}`)}async function k0n(t,r){const i=await y0e(r.kind,t,r);if(i!==null)return i;let a=!1;if(await xE(()=>(a=xb(r.id),a||gCt(r.id)!==null),m9),a)return r.story!==void 0&&await T0n(r.id,r.story),r.id;const l=gCt(r.id);throw l?new Error(l):new Error(`Workspace document is not available: ${r.id}`)}async function I0n(t,r){const i=await y0e(r.kind,t,r);if(i===null){const{kind:a,...l}=r,d=pRr();throw new Error(`Nothing in this editor can open a '${a}' document (${JSON.stringify(l)}). Either no package registered an opener for that view address, or the subject does not exist. Registered view addresses: ${d.length>0?d.join(", "):"(none)"}.`)}return i}function D0n(t){const r=H7r();return r===null?"":r.includes(t)?`"${t}" is a kind in this project's document table, not an address — a document opens in the editor registered for its KIND, so address it as { kind: "document", id: "<that table entry's id>" }.`:r.length===0?"":`This project's document table holds ${r.map(i=>`"${i}"`).join(", ")}; each opens as { kind: "document", id: "<the table entry's id>" }.`}async function P0n(t,r){if(!r)return I_();if(!UDr(r.kind))throw new Error(`present-view does not know the document kind "${String(r.kind)}". An EditorView addresses a document by one of: ${dIt.join(", ")}. `+D0n(String(r.kind)));switch(r.kind){case"scene":return C0n();case"world":return E0n(r);case"asset":case"tool":case"document":case"story":case"project-tool":case"generation":return I0n(t,r);case"workspace":return k0n(t,r)}}function N0n(t){const r=t.indexOf(",");return{base64:r>=0?t.slice(r+1):t,mimeType:"image/png"}}const aEt=YHt;function O0n(t,r,i){if(!i?.degenerate)return null;const a=wQe();return!a||!r.contains(a)?null:`This door photographs the "${t}" document, which for a live three ingest holds the GAME'S own canvas — created without \`preserveDrawingBuffer\`, so its pixels can only be read from inside the game's own render pass. This game did not draw inside that window (a render-on-demand world sitting idle, or a loop the Edit-tab input gate has frozen), so the frame came back BLANK (${i.warning??"essentially one flat colour"}) — a PNG that reads as a real image. The editor's own renderer is drawing this same world in the Scene viewport (the mount adopts the captured scene), so capture \`workspace:scene\` instead — or drive the game until it renders and ask again.`}async function F0n(t,r){const i=AE();if(!i)throw new Error("No active editor document to capture.");const{descriptor:a,title:l}=i,d=ute(t),_={id:a.id,title:l,kind:a.kind,...a.provenance?.sourcePath?{sourcePath:a.provenance.sourcePath}:{},...a.provenance?.rootId?{rootId:a.provenance.rootId}:{}},g=Pw(a.id);if(g){const w=g.captureImage(r);if(!w)throw new Error(`Object3D document could not be captured: ${a.id}`);return{...N0n(w),document:_,view:d,source:"object3d-document"}}const b=a.id===Sw?jHt()??aEt(a.id):aEt(a.id);if(!b)throw new Error(`Active document surface is not mounted: ${a.id}`);const S=await b0n(b,{canvasFrame:v0n,includeDocumentStyles:a.id!==Sw}),k=O0n(a.id,b,S.flatness);if(k)throw new Error(k);return{base64:S.base64,mimeType:S.mimeType,document:_,view:d,source:a.id===Sw?"game-composite":a.id==="workspace:scene"?"scene-viewport":"document-composite",layers:S.layers,...S.flatness?{flatness:S.flatness}:{}}}function R0n(t){return t?Pw(t):null}function M0n(t,r,i){i!==void 0&&(r?r.setGrid(i):t.showGrid!==i&&t.toggleGrid())}function L0n(t,r,i,a){i&&(r?(r.setSkeleton(i==="skeleton"),r.setBounds(i==="bounds"),i==="skeleton"||i==="bounds"?r.setMode("solid"):r.setMode(i)):S0n.has(i)?t.setShadingMode(i):a.push(`Diagnostic ${i} is unavailable for this document.`))}function j0n(t,r,i,a){if(i){if(typeof i!="string"){r?r.setCameraPose(i.position,i.target,i.fov):t.setCameraPose(i.position,i.target,i.fov);return}r&&i==="perspective"?(r.setProjection("perspective"),r.frame()):r&&i!=="perspective"?r.setViewPreset(i):i!=="isometric"?t.setViewPreset(i):a.push("Isometric camera is unavailable for this document.")}}function B0n(t,r,i,a){i.selection?.focus||i.viewport?.frame==="selection"?r&&!r.frameSelection()?a.push("The requested selection could not be framed."):r||t.focusOnSelection():i.viewport?.frame==="document"&&(r?r.frame():a.push("Document framing is unavailable for this document."))}function $0n(t,r,i,a){i.selection&&(r?r.select(i.selection.ids):t.selectMultiple(i.selection.ids)),M0n(t,r,i.viewport?.grid),L0n(t,r,i.viewport?.diagnostic,a),j0n(t,r,i.viewport?.camera,a),B0n(t,r,i,a)}async function bye(t,r,i={}){if(r?.version!==1)throw new Error("present-view requires EditorView version 1.");const a=Object.keys(r).filter(k=>!Y1t.includes(k));if(a.length>0)throw new Error(`present-view does not know ${a.map(k=>`"${k}"`).join(", ")}. An EditorView carries: ${Y1t.join(", ")}. A document's own address (kind, and the fields that kind reads) goes under "document".`);const l=ute(t);if(r.style!==void 0){const k=lU().map(w=>w.id);if(!k.includes(r.style))throw new Error(`present-view requires a style of ${k.join(", ")}, got ${String(r.style)}.`);nUe(r.style)}if(r.workspace!==void 0){if(!SZ(r.workspace))throw new Error(`present-view requires a workspace of ${Yze().join(", ")}, got ${String(r.workspace)}.`);if(wS()!==r.workspace){const k=vPt();CS(r.workspace),await Promise.race([k,new Promise(w=>setTimeout(w,3e3))])}}const d=[];r.keymap!==void 0&&r.keymap!==uI()&&d.push(`Keymap "${r.keymap}" was not applied — a view reports the keymap, it does not set it. This project is on "${uI()}" (its adapter's declaration, or its own settings).`);const _=await P0n(t,r.document);await w0n(r.utility);const g=R0n(_);if(g&&_&&await MOr(_),!g&&r.selection?.ids.length&&(r.document?.kind==="scene"||r.document?.kind==="world")){const k=r.selection.ids;if(!await xE(()=>k.every(N=>By(t).hierarchy.node(N)!==null),m9))throw new Error(`Shared view selection is not available: ${k.join(", ")}`)}_&&I_()!==_&&xb(_),$0n(t,g,r,d),r.panel!==void 0&&await eGt(r.panel);const b=_It(r,window.location.href);i.updateUrl!==!1&&window.history.replaceState(window.history.state,"",b);const S={view:r,url:b,warnings:d};return(i.origin??"agent")==="agent"&&(await A0n()).showEditorPresentationNotice({presented:S,previousView:l}),S}const Aye=new Map;let tGt=0;const Z$e=new Set;function rGt(){tGt+=1;for(const t of Z$e)t()}function q0n(t,r,i){const a=Aye.get(t);a&&a.assetPath===r&&a.actions.length===i.length&&a.actions.every((l,d)=>l===i[d])||(Aye.set(t,{assetPath:r,actions:i}),rGt())}function z0n(t){Aye.delete(t)&&rGt()}function U0n(t){const r=[];for(const i of Aye.values())i.assetPath===t&&r.push(...i.actions);return r}function V0n(t){return Z$e.add(t),()=>Z$e.delete(t)}function cEt(){return tGt}const J0n=[],lEt=new Set;let W0n=0;function H0n(t){for(const r of J0n)if(r.match(t))return r;return null}function G0n(t){return lEt.add(t),()=>{lEt.delete(t)}}function uEt(){return W0n}const z_={open:{id:"project-asset.open",shortcut:"Enter"},rename:{id:"project-asset.rename",shortcut:"F2"},move:{id:"project-asset.move",shortcut:null},duplicate:{id:"project-asset.duplicate",shortcut:"Mod+D"},delete:{id:"project-asset.delete",shortcut:"Delete"},copyPath:{id:"project-asset.copy-path",shortcut:"Mod+Shift+C"},reveal:{id:"project-asset.reveal",shortcut:null},refresh:{id:"project-asset.refresh",shortcut:"Mod+R"},import:{id:"project-asset.import",shortcut:null},createFolder:{id:"project-asset.create-folder",shortcut:"Mod+Shift+N"}};function nGt(t){return`vgai:project-content:v1:${t}`}const fP=[],eqe=new Set,kY=new Map;let iGt=0;function qRe(){iGt++;for(const t of eqe)t()}function Q0n(t){const r=fP.findIndex(i=>i.owner===t.owner&&i.id===t.id);if(r>=0){const[i]=fP.splice(r,1);i&&(kY.get(i)?.(),kY.delete(i))}return fP.push(t),fP.sort((i,a)=>(i.order??0)-(a.order??0)),kY.set(t,t.subscribe(qRe)),qRe(),()=>{const i=fP.indexOf(t);i<0||(fP.splice(i,1),kY.get(t)?.(),kY.delete(t),qRe())}}const K0n=[];function Y0n(){return fP.length===0?K0n:fP}function sGt(t){return eqe.add(t),()=>{eqe.delete(t)}}function Sye(){return iGt}function oGt(t){for(const r of fP){const i=r.entries({components:[t],surface:null})[0];if(i)return{source:r,entry:i}}return null}function X0n(){const t=q0e();return t?{path:t.path,name:t.name,kind:t.kind,origin:t.origin??"project",...t.sourcePath?{sourcePath:t.sourcePath}:{}}:null}function Z0n(t,r){return Xe.useEffect(()=>()=>z0n(t),[t]),Xe.useCallback(i=>{r!==null&&q0n(t,r,i)},[t,r])}function evn({id:t,title:r,file:i,tool:a,Component:l}){Xe.useSyncExternalStore($0e,kZ),Xe.useSyncExternalStore(Yye,T8,T8),Xe.useSyncExternalStore(Zye,k8,k8);const d=X0n(),_=Z0n(t,d?.path??null),g=Xe.useRef(null),b=Xe.useCallback(k=>{g.current?.(),g.current=k===null?null:D3t(`building ${k.replace(/^building /,"")}`)},[]);Xe.useEffect(()=>()=>g.current?.(),[]);const S=Xe.useCallback(k=>az({...k,id:`contribution:${t}:${k.title}`,...k.tone==="warning"?{fades:!0}:{}}),[t]);return z.jsxs("div",{"data-testid":`asset-inspector-tool-${t}`,style:{padding:8,borderTop:"1px solid var(--vgai-structural-divider)",marginTop:4},children:[z.jsxs("div",{style:{...RFr,marginBottom:4},children:[z.jsx(So,{icon:yb.tool.extension,tone:"muted",style:{marginRight:4}}),r]}),z.jsx(Mze,{file:i,children:z.jsx(l,{...a?{tool:a}:{},contributionId:t.slice(t.lastIndexOf(":")+1),client:b0e(),surfaces:wze,account:mze(),play:Xye(),asset:d,setActions:_,notify:S,work:b})})]})}function tvn(t,r){if(r<=0)return[];if(t.length===0)return Array.from({length:r},()=>0);const i=new Array(r),a=t.length/r;let l=0;for(let d=0;d<r;d++){const _=Math.floor(d*a),g=Math.max(_+1,Math.floor((d+1)*a));let b=0;for(let S=_;S<g;S++)b=Math.max(b,Math.abs(t[S]??0));i[d]=b,l=Math.max(l,b)}return l<=1e-8?i.fill(0):i.map(d=>d/l)}const aGt=32,tqe=new Set,fEt=new Map,dEt=new Map;let qR=null,XX=null,cGt=0,rqe=0,Kq=0,J8=0,pEt=!1,AP={url:null,progress:0,playing:!1};function rvn(){for(const t of tqe)t()}function Qz(t){AP.url===t.url&&AP.playing===t.playing&&Math.abs(AP.progress-t.progress)<.002||(AP=t,rvn())}function jQe(){return qR??=new AudioContext,qR}function nvn(){if(pEt||typeof window>"u")return;pEt=!0;const t=()=>{if(!qR)return;const r=AP.url,i=J8;qR.resume().then(()=>{r&&i===J8&&!XX&&qR?.state==="running"&&fGt(r,i)})};window.addEventListener("pointerdown",t,{capture:!0}),window.addEventListener("keydown",t,{capture:!0})}function BQe(){if(Kq&&typeof cancelAnimationFrame=="function"&&cancelAnimationFrame(Kq),Kq=0,!XX)return;const t=XX;XX=null,t.onended=null;try{t.stop()}catch{}t.disconnect()}function lGt(){if(Kq=0,!AP.playing||!qR||rqe<=0)return;const t=Math.min(1,(qR.currentTime-cGt)/rqe);Qz({url:AP.url,progress:t,playing:t<1}),t<1&&typeof requestAnimationFrame=="function"&&(Kq=requestAnimationFrame(lGt))}function ivn(t,r,i){if(i!==J8)return;BQe();const a=jQe(),l=a.createBufferSource(),d=a.createGain();d.gain.value=1,l.buffer=t,l.connect(d),d.connect(a.destination),l.onended=()=>{i===J8&&Qz({url:r,progress:1,playing:!1})},l.start(),XX=l,cGt=a.currentTime,rqe=t.duration,Qz({url:r,progress:0,playing:!0}),typeof requestAnimationFrame=="function"&&(Kq=requestAnimationFrame(lGt))}async function uGt(t){const r=fEt.get(t);if(r)return r;const i=(async()=>{const a=await fetch(t);if(!a.ok)throw new Error(`Audio preview could not read ${t}.`);const l=await a.arrayBuffer();return jQe().decodeAudioData(l.slice(0))})().catch(()=>null);return fEt.set(t,i),i}async function fGt(t,r){nvn();const i=await uGt(t);if(r!==J8)return;if(!i){Qz({url:t,progress:0,playing:!1});return}const a=jQe();a.state==="suspended"&&(await a.resume(),r!==J8)||a.state==="running"&&ivn(i,t,r)}function svn(t){return tqe.add(t),()=>tqe.delete(t)}function ovn(){return AP}function avn(t){const r=++J8;BQe(),Qz({url:t,progress:0,playing:!0}),fGt(t,r)}function cvn(t){t&&AP.url!==t||(J8+=1,BQe(),Qz({url:null,progress:0,playing:!1}))}function lvn(t,r=aGt){const i=`${t}#${r}`,a=dEt.get(i);if(a)return a;const l=uGt(t).then(d=>d?tvn(d.getChannelData(0),r):Array.from({length:r},()=>0));return dEt.set(i,l),l}const _Et=16,uvn=3e3,fvn=500;function e4n(t,r){return r-t>=fvn}function t4n(t){let r=!1;return t.traverse(i=>{!r&&Z8(i,"gaussianSplat")&&(r=!0)}),r}function dvn(t){t.autoUpdate=!1,t.sortDirty=!1,t.updateTimeoutId!==-1&&(clearTimeout(t.updateTimeoutId),t.updateTimeoutId=-1),t.sortTimeoutId!==-1&&(clearTimeout(t.sortTimeoutId),t.sortTimeoutId=-1);let r=uvn;const i=()=>{if(t.sorting){r>0?(r-=_Et,setTimeout(i,_Et)):console.warn("SparkRenderer did not become idle; skipped worker termination.");return}t.dispose()};i()}const v_e=128;let Ume=null;const pvn=new Set(["glb","gltf","fbx","obj","dae","stl","ply","spz","bvh","3ds"]);function $Qe(t){const r=t.split(/[?#]/,1)[0].toLowerCase(),i=r.slice(r.lastIndexOf(".")+1);return pvn.has(i)?i:void 0}class _vn{renderer;scene;camera;cache=new Map;pending=new Map;sparkRenderer=null;constructor(){const r=document.createElement("canvas");r.width=v_e,r.height=v_e,this.renderer=UP(new $P({canvas:r,alpha:!0,antialias:!0,preserveDrawingBuffer:!0})),this.renderer.setSize(v_e,v_e),this.renderer.setPixelRatio(1),this.renderer.outputColorSpace=hv,this.renderer.toneMapping=u9,this.renderer.toneMappingExposure=1,this.scene=new Mye,Ree(this.scene,this.renderer),this.scene.add(new vIr(16777215,.8*W6t));const i=new kq(16777215,1.5);i.position.set(3,5,4),this.scene.add(i);const a=new kq(16772829,.4);a.position.set(-3,-1,2),this.scene.add(a),this.camera=new Bye(35,1,.01,1e3)}async render(r){const i=typeof r=="string"?{url:r}:r,a=i.format??$Qe(i.url);if(!a)throw new Error(`No thumbnail loader for ${i.url}`);const l={...i,format:a},d=JSON.stringify(l),_=this.cache.get(d);if(_)return _;const g=this.pending.get(d);if(g)return g;const b=this._render(l);this.pending.set(d,b);try{const S=await b;return this.cache.set(d,S),S}finally{this.pending.delete(d)}}async _render(r){const i=yvn(await gvn(r));if(this.scene.add(i),r.format==="spz"&&!this.sparkRenderer){const{SparkRenderer:w}=await Xo(async()=>{const{SparkRenderer:N}=await import("./spark.module-CjQpY2Op.js");return{SparkRenderer:N}},__vite__mapDeps([45,6,3,2,4,1,8,9,10,11]));this.sparkRenderer=new w({renderer:this.renderer,enableLod:!1}),this.scene.add(this.sparkRenderer)}const a=hvn(i);if(a.isEmpty())throw this.scene.remove(i),new Error("Model contains no previewable geometry.");const l=a.getCenter(new Tc),d=a.getBoundingSphere(new Ekt),_=this.camera.fov*Math.PI/180,g=Math.max(d.radius,1e-4)/Math.sin(_/2)*1.18,b=new Tc(.65,.45,.65).normalize();this.camera.position.set(l.x+g*b.x,l.y+g*b.y,l.z+g*b.z),this.camera.lookAt(l),this.camera.near=g*.01,this.camera.far=g*20,this.camera.updateProjectionMatrix(),r.background==="neutral"?this.renderer.setClearColor(2106410,1):this.renderer.setClearColor(0,0),this.renderer.clear(),this.renderer.render(this.scene,this.camera);const S=mvn(this.renderer.domElement,r.background==="neutral"),k=r.output==="webp"?S.toDataURL("image/webp",.86):S.toDataURL("image/png");return this.scene.remove(i),i.traverse(w=>{Z8(w,"gaussianSplat")&&w.dispose();const N=w;if(N.geometry&&N.geometry.dispose(),N.material){const P=Array.isArray(N.material)?N.material:[N.material];for(const j of P)"map"in j&&j.map instanceof oP&&j.map.dispose(),"normalMap"in j&&j.normalMap instanceof oP&&j.normalMap.dispose(),"emissiveMap"in j&&j.emissiveMap instanceof oP&&j.emissiveMap.dispose(),"aoMap"in j&&j.aoMap instanceof oP&&j.aoMap.dispose(),"roughnessMap"in j&&j.roughnessMap instanceof oP&&j.roughnessMap.dispose(),"metalnessMap"in j&&j.metalnessMap instanceof oP&&j.metalnessMap.dispose(),j.dispose()}}),k}dispose(){this.sparkRenderer&&(this.scene.remove(this.sparkRenderer),dvn(this.sparkRenderer),this.sparkRenderer=null),this.renderer.dispose(),this.renderer.forceContextLoss(),this.cache.clear(),Ume=null}}function mvn(t,r){const i=document.createElement("canvas");i.width=t.width,i.height=t.height;const a=i.getContext("2d",{willReadFrequently:!0});if(!a)return t;a.drawImage(t,0,0);const l=a.getImageData(0,0,i.width,i.height),d=new Uint8Array(i.width*i.height);let _=0;for(let w=0;w<d.length;w++){const N=w*4;(r?Math.abs(l.data[N]-32)>3||Math.abs(l.data[N+1]-36)>3||Math.abs(l.data[N+2]-42)>3:l.data[N+3]>8)&&(d[w]=1,_++)}const g=_/d.length;if(g<1e-4)return i;const b=new Uint8ClampedArray(l.data);if(r)for(let w=0;w<d.length;w++){if(!d[w])continue;const N=w*4,P=b[N]*.2126+b[N+1]*.7152+b[N+2]*.0722;if(P>=88)continue;const j=88-P;l.data[N]=Math.min(255,b[N]+j),l.data[N+1]=Math.min(255,b[N+1]+j),l.data[N+2]=Math.min(255,b[N+2]+j)}const S=g<.004?2:g<.02?1:0;let k=d;for(let w=0;w<S;w++){const N=k.slice(),P=new Uint8ClampedArray(l.data);for(let j=1;j<i.height-1;j++)for(let J=1;J<i.width-1;J++){const X=j*i.width+J;if(k[X])continue;const G=[X-1,X+1,X-i.width,X+i.width].find(ue=>k[ue]);if(G===void 0)continue;const ee=X*4,xe=G*4;l.data.set(P.subarray(xe,xe+4),ee),N[X]=1}k=N}return a.putImageData(l,0,0),i}function hvn(t){t.updateWorldMatrix(!0,!0);const r=new xS,i=new xS;return t.traverseVisible(a=>{if(Z8(a,"gaussianSplat")){i.copy(a.getBoundingBox()).applyMatrix4(a.matrixWorld),r.union(i);return}const l=a;l.geometry&&(l.geometry.boundingBox||l.geometry.computeBoundingBox(),l.geometry.boundingBox&&(i.copy(l.geometry.boundingBox).applyMatrix4(a.matrixWorld),r.union(i)))}),r}async function gvn(t){switch(t.format){case"glb":case"gltf":{const r=await fU.loadAsync(t.url);return r.scene.animations=[...r.animations],r.scene}case"fbx":{const{FBXLoader:r}=await Xo(async()=>{const{FBXLoader:i}=await import("./FBXLoader-DzWtiWYm.js");return{FBXLoader:i}},__vite__mapDeps([68,6,49]));return new r().loadAsync(t.url)}case"obj":{const{OBJLoader:r}=await Xo(async()=>{const{OBJLoader:l}=await import("./OBJLoader-8SrBLZ7J.js");return{OBJLoader:l}},__vite__mapDeps([69,6])),i=t.materialUrl??await Avn(t.url),a=new r;if(i){const{MTLLoader:l}=await Xo(async()=>{const{MTLLoader:_}=await import("./MTLLoader-D8SKGOsv.js");return{MTLLoader:_}},__vite__mapDeps([70,6])),d=await new l().loadAsync(i);d.preload(),a.setMaterials(d)}return a.loadAsync(t.url)}case"dae":{const{ColladaLoader:r}=await Xo(async()=>{const{ColladaLoader:l}=await import("./ColladaLoader-CyOCKXko.js");return{ColladaLoader:l}},__vite__mapDeps([71,6])),i=await new r().loadAsync(t.url),a=i.animations;return a&&(i.scene.animations=[...a]),i.scene}case"stl":{const{STLLoader:r}=await Xo(async()=>{const{STLLoader:a}=await import("./STLLoader-U-3fQm8v.js");return{STLLoader:a}},__vite__mapDeps([72,6])),i=await new r().loadAsync(t.url);return new NA(i,new tz({color:7710680,roughness:.75}))}case"ply":{const{PLYLoader:r}=await Xo(async()=>{const{PLYLoader:l}=await import("./PLYLoader-BXUWXVtV.js");return{PLYLoader:l}},__vite__mapDeps([73,6])),i=await new r().loadAsync(t.url);if(i.index||i.hasAttribute("normal"))return i.hasAttribute("normal")||i.computeVertexNormals(),new NA(i,new tz({color:i.hasAttribute("color")?16777215:12112027,vertexColors:i.hasAttribute("color"),roughness:.8,side:vkt}));i.computeBoundingBox();const a=i.boundingBox?.getSize(new Tc).length()??1;return new Yqe(i,new ykt({color:i.hasAttribute("color")?16777215:12112027,vertexColors:i.hasAttribute("color"),size:Math.max(a/220,1e-4),sizeAttenuation:!0}))}case"spz":return $6t(t.url);case"bvh":{const{BVHLoader:r}=await Xo(async()=>{const{BVHLoader:d}=await import("./BVHLoader--2mLoe3e.js");return{BVHLoader:d}},__vite__mapDeps([74,6])),i=await new r().loadAsync(t.url),a=i.skeleton.bones[0];if(!a)throw new Error("BVH contains no skeleton root.");const l=new SP;return l.animations=[i.clip],l.add(a),l}case"3ds":{const{TDSLoader:r}=await Xo(async()=>{const{TDSLoader:i}=await import("./TDSLoader-BtiaQ4S3.js");return{TDSLoader:i}},__vite__mapDeps([75,6]));return new r().loadAsync(t.url)}}}function yvn(t){if(vvn(t))return t;t.updateWorldMatrix(!0,!0);const r=new yIr(t),i=r.geometry.getAttribute("position");if(!i||i.count===0)return r.dispose(),t;r.name="Asset Editor skeleton preview",r.frustumCulled=!1;const a=new SP;return a.name=t.name,a.animations=[...t.animations],a.add(t,r),a.updateWorldMatrix(!0,!0),r.updateMatrixWorld(!0),a}function vvn(t){let r=!1;return t.traverseVisible(i=>{!r&&bvn(i)&&(r=!0)}),r}function bvn(t){const r=t;if(r.isSprite)return r.material.visible;const i=t,a=t,l=t;if(!i.isMesh&&!a.isLine&&!l.isPoints)return!1;const d=t,_=t;if(_.isInstancedMesh&&_.count===0)return!1;const g=Array.isArray(d.material)?d.material:[d.material];if(g.length===0||g.every(S=>!S?.visible))return!1;const b=d.geometry?.getAttribute("position");return!!(b&&b.count>0&&d.geometry.drawRange.count!==0)}async function Avn(t){const r=t.split(/[?#]/,1)[0],i=`${r.slice(0,r.lastIndexOf("."))}.mtl`;try{return(await fetch(i,{method:"HEAD"})).ok?i:void 0}catch{return}}function Svn(){return Ume||(Ume=new _vn),Ume}const qQe={folder:"var(--vgai-asset-icon-folder)",model:"var(--vgai-asset-icon-model)",prefab:"var(--vgai-asset-icon-prefab)",component:"var(--vgai-asset-icon-component)",audio:"var(--vgai-asset-icon-audio)",image:"var(--vgai-asset-icon-image)",video:"var(--vgai-asset-icon-video)",json:"var(--vgai-asset-icon-json)",unknown:"var(--vgai-asset-icon-unknown)",source:"var(--vgai-asset-icon-source)"},xvn={folder:gee,model:dDr,prefab:yee,component:Jkt,audio:iIt,image:KIr,video:uDr,json:oIt,unknown:rDr,source:uIt};function DP({kind:t,size:r=24}){return z.jsx(So,{icon:xvn[t],style:{fontSize:r,color:qQe[t]}})}const wvn=100,Cvn=50,Evn=new N4t(t=>{const r=$Qe(t);return r?Svn().render({url:t,format:r,background:"neutral",output:"webp"}):Promise.reject(new Error(`No model preview loader for ${t}.`))},2);function dGt(t,r){const[i,a]=Xe.useState(null),[l,d]=Xe.useState(!1),[_,g]=Xe.useState(null),[b,S]=Xe.useState(!1);Xe.useEffect(()=>{a(null),d(!1),g(null),S(!1)},[t]),Xe.useEffect(()=>{let w=!1,N=null;return wUe().then(P=>{if(w)return;const j=P.status==="ok"?P.manifest.entries[t.replace(/^\/+/,"")]:void 0;if(!b&&j?.path&&(j.state==="generated"||j.state==="upstream")){g(j.path.startsWith("/")?j.path:`/${j.path}`);return}return N=Evn.request(t,r),N.promise}).then(P=>{!w&&P&&a(P)}).catch(()=>{w||d(!0)}),()=>{w=!0,N?.cancel()}},[b,r,t]);const k=Xe.useCallback(()=>{g(null),S(!0)},[]);return{src:_??i,fromManifest:_!==null,failed:l,rejectManifest:k}}function pGt({url:t}){const r=dGt(t,wvn);return r.failed?z.jsx(DP,{kind:"model"}):r.fromManifest&&r.src?z.jsx("img",{src:r.src,alt:"cached model preview",onError:r.rejectManifest,style:{width:"100%",height:"100%",objectFit:"contain"}}):r.src?z.jsx("img",{src:r.src,alt:"model preview",style:{width:"100%",height:"100%",objectFit:"contain"}}):z.jsx("div",{style:{width:28,height:28,margin:"0 auto",display:"flex",alignItems:"center",justifyContent:"center"},children:z.jsx("div",{className:"vgai-anim-spin",style:{width:16,height:16,border:`2px solid ${bhe[2]}`,borderTopColor:qQe.model,borderRadius:"50%"}})})}function Tvn({url:t,name:r}){const[i,a]=Xe.useState(()=>Array.from({length:aGt},()=>.15)),l=Xe.useSyncExternalStore(svn,ovn);Xe.useEffect(()=>{let g=!1;return lvn(t).then(b=>{g||a(b)}),()=>{g=!0}},[t]);const d=l.url===t,_=d?l.progress:0;return z.jsx("div",{role:"img","aria-label":`${r} waveform preview`,style:{display:"flex",alignItems:"center",gap:1,width:"86%",height:"62%"},children:i.map((g,b)=>{const S=b/i.length<=_;return z.jsx("i",{style:{flex:1,height:`${12+g*88}%`,background:"var(--vgai-asset-icon-audio)",opacity:d&&S?1:.28,borderRadius:1}},b)})})}function a9({kind:t,name:r,variant:i="tile"}){const a=qQe[t],l=i==="cell";return t==="audio"?z.jsxs("svg",{role:"img","aria-label":`${r} waveform preview`,viewBox:"0 0 64 48",width:l?"78%":52,height:l?"78%":44,children:[z.jsx("rect",{width:"64",height:"48",rx:"4",fill:"var(--vgai-bg-inset)"}),Array.from({length:16},(d,_)=>z.jsx("rect",{x:_*4+1,y:24-_*13%18/2,width:"2",height:_*13%18+3,fill:a},_))]}):z.jsxs("svg",{role:"img","aria-label":`${r} ${t} preview`,viewBox:"0 0 52 48",width:l?"66%":48,height:l?"72%":44,children:[z.jsx("rect",{x:"5",y:"3",width:"42",height:"42",rx:"4",fill:"var(--vgai-bg-inset)",stroke:a}),z.jsx("path",{d:"M13 15h26M13 23h18M13 31h22",stroke:a,strokeWidth:"3",strokeLinecap:"round"})]})}function _Gt(t,r,i,a){if(t<=0||r<=0||i<=0||a<=0)return 1;const l=t<=i?Math.floor(i/t):0,d=r<=a?Math.floor(a/r):0,_=Math.min(l,d);return _>=1?_:1/Math.max(Math.ceil(t/i),Math.ceil(r/a))}function r4n(t,r,i,a,l){return t==="fit"?_Gt(r,i,a,l):t}function kvn(t,r,i){const a=Math.max(1,i.sourceWidth??i.width),l=Math.max(1,i.sourceHeight??i.height);t.width=a,t.height=l;const d=t.getContext("2d");if(!d)return;d.imageSmoothingEnabled=!1,d.clearRect(0,0,a,l);const _=mqr(i);if(i.rotated){d.save(),d.translate(i.trimX,i.trimY+_.width),d.rotate(-Math.PI/2),d.drawImage(r,_.x,_.y,_.width,_.height,0,0,_.width,_.height),d.restore();return}d.drawImage(r,_.x,_.y,_.width,_.height,i.trimX,i.trimY,_.width,_.height)}function mGt({sheetUrl:t,frame:r,scale:i,maxEdge:a}){const l=Xe.useRef(null),d=Math.max(1,r.sourceWidth??r.width),_=Math.max(1,r.sourceHeight??r.height),g=a!=null?_Gt(d,_,a,a):i??1,b=Math.max(1,Math.round(d*g)),S=Math.max(1,Math.round(_*g));return Xe.useEffect(()=>{const k=l.current;if(!k)return;const w=new Image;let N=!1;return w.onload=()=>{N||kvn(k,w,r)},w.src=t,()=>{N=!0}},[r,t]),z.jsx("canvas",{ref:l,width:d,height:_,"aria-hidden":!0,style:{width:b,height:S,imageRendering:"pixelated",display:"block"}})}const hGt={fontSize:11,color:od[3],marginBottom:2},Ivn={fontSize:11,color:od[1],wordBreak:"break-all"};function zRe({asset:t}){Xe.useSyncExternalStore(jA,dI,dI);const r={path:t.path,name:t.name,kind:t.kind,origin:t.origin??"project",...t.sourcePath?{sourcePath:t.sourcePath}:{}};return RPt().map(i=>{let a=!1;try{a=i.match(r)}catch(l){console.error(`[tool contributions] ${i.file}'s asset match() threw.`,l)}return a?z.jsx(evn,{id:i.id,title:i.title,file:i.file,tool:i.tool,Component:i.Component},`${i.id}:${i.version}`):null})}function mEt(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function Gh({label:t,value:r}){return z.jsxs("div",{children:[z.jsx("div",{style:hGt,children:t}),z.jsx("div",{style:Ivn,children:r})]})}function Dvn({asset:t}){const r=t.capabilities?.editor==="environment";Xe.useSyncExternalStore(sGt,Sye,Sye);const i=t.componentPreview,a=i?oGt({name:t.name,path:i.sourcePath,surface:i.surface}):null;return z.jsx("div",{"data-testid":"inspector-asset-preview",style:{position:"absolute",inset:0,background:Pze.inset,display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden"},children:a?z.jsx(a.source.Thumbnail,{entry:a.entry,previewRevision:0}):r?z.jsx(a9,{kind:"image",name:t.name,variant:"cell"}):t.kind==="image"?z.jsx(Nvn,{path:t.path,name:t.name}):t.kind==="video"?z.jsx(Pvn,{path:t.path}):t.kind==="model"?z.jsx(pGt,{url:t.path}):z.jsx(a9,{kind:t.kind,name:t.name,variant:"cell"})})}function Pvn({path:t}){return z.jsx("video",{src:t,muted:!0,preload:"metadata",style:{width:"100%",height:"100%",objectFit:"contain"}})}function Nvn({path:t,name:r}){const{sheetPath:i,frameName:a}=U0e(t),[l,d]=Xe.useState(null);return Xe.useEffect(()=>{if(!a){d(null);return}let _=!1;return fetch(`/${dNt(i)}`).then(g=>g.ok?g.text():null).then(g=>{if(_||!g)return;const b=WUe(g);d(b?.frames.find(S=>S.name===a)??null)}).catch(()=>{_||d(null)}),()=>{_=!0}},[a,i]),l?z.jsx(mGt,{sheetUrl:`/${i}`,frame:l,maxEdge:96}):z.jsx("img",{src:t.split("#")[0],alt:r,style:{width:"100%",height:"100%",objectFit:"contain"}})}function Ovn({asset:t}){const[r,i]=Xe.useState(null),{sheetPath:a,frameName:l}=U0e(t.path);return Xe.useEffect(()=>{if(i(null),t.kind!=="image"||t.capabilities?.editor==="environment")return;let d=!1;if(l)return fetch(`/${dNt(a)}`).then(g=>g.ok?g.text():null).then(g=>{if(d||!g)return;const b=WUe(g)?.frames.find(S=>S.name===l);b&&i({w:b.sourceWidth,h:b.sourceHeight})}).catch(()=>{}),()=>{d=!0};const _=new Image;return _.onload=()=>{d||i({w:_.naturalWidth,h:_.naturalHeight})},_.src=t.path.split("#")[0]??t.path,()=>{d=!0}},[t.capabilities?.editor,t.kind,t.path,l,a]),r?z.jsx(Gh,{label:"Dimensions",value:`${r.w} × ${r.h}`}):null}function Fvn(){Xe.useSyncExternalStore(G0n,uEt,uEt);const t=q0e();if(!t)return null;const r=H0n(t),i=t.name.includes(".")?t.name.split(".").pop()??"":"";return r?z.jsxs("div",{"data-testid":"inspector-asset-selection",style:{pointerEvents:"auto",borderBottom:`1px solid ${bhe[1]}`,display:"flex",flexDirection:"column",gap:6},children:[z.jsx(r.View,{asset:t}),z.jsx(zRe,{asset:t})]}):(t.selectionCount??1)===1&&(t.kind==="image"&&!t.path.includes("#")&&t.capabilities?.editor!=="environment"||t.kind==="video"||t.kind==="audio")?z.jsxs(z.Fragment,{children:[z.jsx(ENt,{assetPath:t.path,kind:t.kind,sizeBytes:t.sizeBytes}),z.jsxs("div",{style:{padding:"0 8px",display:"grid",gap:6},children:[t.health&&t.health!=="healthy"&&z.jsx(Gh,{label:"Health",value:t.health}),!!t.healthCodes?.length&&z.jsx(Gh,{label:"Issues",value:t.healthCodes.join(", ")}),t.sourcePath&&z.jsx(Gh,{label:"Imported from",value:t.sourcePath}),!!t.dependencies?.length&&z.jsx(Gh,{label:"Dependencies",value:t.dependencies.join(", ")}),!!t.references?.length&&z.jsx(Gh,{label:"References",value:t.references.map(a=>`${a.ownerPath} ${a.jsonPath}`).join(", ")})]}),z.jsx(zRe,{asset:t})]}):z.jsxs("div",{"data-testid":"inspector-asset-selection",style:{pointerEvents:"auto",padding:8,borderBottom:`1px solid ${bhe[1]}`,display:"flex",flexDirection:"column",gap:6},children:[z.jsx(Ovn,{asset:t}),z.jsx("div",{style:{...hGt,marginBottom:0,textTransform:"uppercase"},children:"Asset"}),z.jsx("div",{style:{fontWeight:600,fontSize:12,color:od[1],wordBreak:"break-all"},children:t.name}),z.jsx(Gh,{label:"Path",value:t.path}),t.componentPreview&&z.jsx(Gh,{label:"Surface",value:t.componentPreview.surface==="canvas"?"2D / Pixi":t.componentPreview.surface==="three"?"3D / Three":t.componentPreview.surface}),t.selectionCount&&t.selectionCount>1&&z.jsxs(z.Fragment,{children:[z.jsx(Gh,{label:"Selection",value:`${t.selectionCount} assets`}),t.selectionTotalBytes!==void 0&&z.jsx(Gh,{label:"Total size",value:mEt(t.selectionTotalBytes)}),t.selectionFormats&&z.jsx(Gh,{label:"Formats",value:t.selectionFormats.join(", ")})]}),i&&z.jsx(Gh,{label:"Format",value:i.toUpperCase()}),t.sizeBytes!==void 0&&z.jsx(Gh,{label:"Size",value:mEt(t.sizeBytes)}),t.capabilities&&z.jsxs(z.Fragment,{children:[z.jsx(Gh,{label:"Runtime readiness",value:t.capabilities.runtimeReady?"Runtime-ready":"Import or conversion required"}),z.jsx(Gh,{label:"Preview",value:t.capabilities.previewable?"Available":"Unsupported"}),z.jsx(Gh,{label:"Placement",value:t.capabilities.placeable?"Placeable":"Not placeable"}),z.jsx(Gh,{label:"Editor",value:Bq(t.capabilities)??"No editor"})]}),t.health&&z.jsx(Gh,{label:"Health",value:t.health}),t.healthCodes&&z.jsx(Gh,{label:"Issues",value:t.healthCodes.join(", ")}),t.dependencies&&z.jsx(Gh,{label:"Dependencies",value:t.dependencies.join(", ")||"None"}),t.references&&z.jsx(Gh,{label:"References",value:t.references.map(a=>`${a.ownerPath} ${a.jsonPath}`).join(", ")||"None"}),t.sourcePath&&z.jsx(Gh,{label:"Imported from",value:t.sourcePath}),!t.componentPreview&&z.jsxs("div",{style:{display:"flex",gap:6},children:[z.jsx(fo,{type:"button","data-command-id":z_.open.id,onClick:()=>window.dispatchEvent(new CustomEvent("editor:open-project-asset",{detail:{path:t.path}})),children:"Open"}),t.selectionCount&&t.selectionCount>1&&z.jsxs(z.Fragment,{children:[z.jsx(fo,{type:"button","data-command-id":z_.move.id,onClick:()=>window.dispatchEvent(new CustomEvent("editor:project-asset-command",{detail:{id:z_.move.id}})),children:"Move selected"}),z.jsx(fo,{type:"button","data-command-id":z_.delete.id,onClick:()=>window.dispatchEvent(new CustomEvent("editor:project-asset-command",{detail:{id:z_.delete.id}})),children:"Delete selected"})]})]}),z.jsx("div",{style:{fontSize:10,color:od[3]},children:"Double-click (or press Enter) in the asset browser to open the full viewer."}),z.jsx(zRe,{asset:t})]})}function Rvn(t){return U0n(t).map(r=>({id:r.id,title:r.title,...r.label===void 0?{}:{label:r.label},placement:"identity",...r.disabled===void 0?{}:{disabled:r.disabled},run:r.run}))}function Mvn(){const t=q0e();if(t===null)return null;const r=n0e();return r&&(r.adapter!==null||r.nodeId!==null)?null:{quickActions:Rvn(t.path),id:`asset:${t.path}`,title:t.name,kindLabel:t.online?`${t.kind} · ${t.online.source}`:t.kind,note:{text:t.sourcePath??t.path,testId:"inspector-asset-path"},sections:[{id:pMe,title:"Preview",icon:BY,order:N3t,body:{kind:"preview",render:()=>z.jsx(Dvn,{asset:t})}},{id:"asset-selection",title:"Asset",icon:bee,order:hZ,body:{kind:"custom",render:()=>z.jsx(Fvn,{})},keepMounted:!0}]}}const Lvn={loop:"Loop control","contract.root":"DOM root","contract.lifecycle.start":"Cold start","contract.lifecycle.pause":"Pause / resume",persistence:"Source persistence",systems:"Commands and state"};function jvn(t){const r=Lvn[t];if(r)return r;const[i,a]=t.split("."),l=(a??t).replace(/([a-z])([A-Z])/g,"$1 $2").toLowerCase(),d=l.charAt(0).toUpperCase()+l.slice(1);return i==="system"?`${d} adapter`:d}const Bvn={ok:fDr,gap:Gkt,na:DDr,info:bee},$vn={ok:Oo.semantic.success,gap:Oo.semantic.warning,na:Oo.content.dim,info:Oo.content.dim};function qvn({row:t}){return z.jsxs("div",{"data-testid":`ingest-coverage-row-${t.seam}`,"data-status":t.status,style:{display:"grid",gridTemplateColumns:"16px minmax(0, 1fr)",gap:7,padding:"8px 10px",borderTop:"1px solid var(--vgai-structural-divider)"},children:[z.jsx("span",{style:{color:$vn[t.status],paddingTop:1},children:z.jsx(So,{icon:Bvn[t.status]})}),z.jsxs("div",{style:{minWidth:0},children:[z.jsx("div",{style:{color:Oo.content.primary,fontWeight:600},children:jvn(t.seam)}),z.jsx("div",{style:{marginTop:2,color:Oo.content.muted,lineHeight:1.4,overflowWrap:"anywhere"},children:t.detail}),t.missing&&z.jsxs("div",{style:{marginTop:6,color:Oo.content.muted,lineHeight:1.4},children:[z.jsx("strong",{style:{color:Oo.semantic.warning},children:"Missing:"})," ",t.missing]}),t.fix&&z.jsxs("div",{style:{marginTop:4,color:Oo.content.dim,lineHeight:1.4},children:[z.jsx("strong",{children:"Fix:"})," ",t.fix]})]})]})}function zvn({report:t}){const{summary:r}=t;return z.jsxs("div",{"data-testid":"ingest-coverage-report",style:{fontSize:"var(--vgai-font-base)"},children:[z.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:8,padding:"7px 10px 9px",color:Oo.content.muted},children:[z.jsxs("span",{style:{color:r.gaps>0?Oo.semantic.warning:Oo.semantic.success},children:[r.gaps," ",r.gaps===1?"gap":"gaps"]}),z.jsxs("span",{children:[r.ok," integrated"]}),z.jsxs("span",{children:[r.na," not applicable"]}),z.jsxs("span",{children:[r.info," informational"]})]}),t.rows.map(i=>z.jsx(qvn,{row:i},i.seam))]})}function Uvn(t){return{id:"ingest-coverage",title:"Ingest coverage",icon:_Dr,order:9e3,description:`${t.summary.gaps} gap${t.summary.gaps===1?"":"s"}`,defaultOpen:!0,testId:"ingest-coverage-section",body:{kind:"custom",render:()=>z.jsx(zvn,{report:t}),data:{summary:t.summary,rows:t.rows}}}}function Vvn(t,r,i){if(t)return t.nodeId;const a=[...r].at(-1);if(a)return a;const l=i.selection?.get().at(-1)??null;if(l===null)return null;const d=i.hierarchy.roots();return d.length===1&&d[0]?.id===l?null:l}const gGt="vgai-inspector-presentation-v2";function yGt(){try{return typeof window>"u"?null:window.localStorage}catch{return null}}function Jvn(t){return t==="card"||t==="column"||t==="properties"}function Wvn(){const t=yGt()?.getItem(gGt);if(!t)return{};try{const r=JSON.parse(t);if(!r||typeof r!="object")return{};const i={};for(const[a,l]of Object.entries(r))Jvn(l)&&(i[a]=l);return i}catch{return{}}}let ZX=null,vGt=0;const nqe=new Set;function bGt(){return ZX===null&&(ZX=Wvn()),ZX}function iqe(t){return bGt()[t]??null}function AGt(t,r){if(iqe(t)!==r){ZX={...bGt(),[t]:r},vGt++;try{yGt()?.setItem(gGt,JSON.stringify(ZX))}catch{}for(const i of nqe)i()}}function Hvn(t){return nqe.add(t),()=>{nqe.delete(t)}}function hEt(){return vGt}function Gvn(t,r,i=null){return r??i??t}function SGt(t){return t.sections.map(r=>({id:r.id,title:r.title,icon:r.icon,...r.railGroup===void 0?{}:{railGroup:r.railGroup},...r.railDefault===void 0?{}:{railDefault:r.railDefault}}))}function sqe(t){return t==="three"||t==="canvas"||t==="dom"?t:null}function Qvn(t,r){const i=r.selectedEntityId;if(i===null)return null;const a=t.childAdapters(),l=a.find(d=>d.worldId===t.ownerOf(i))??a.find(d=>t.groupNodeId(d.worldId)===i);return l?sqe(l.kind):null}function Kvn(t){const r=vze();if(r!==null&&r.documentId===I_())return"asset-lab";const{adapter:i,surface:a}=wm(t);if(a)return a;if(i instanceof Zh){const l=i.childAdapters(),d=l.length===1?sqe(l[0]?.kind??""):null;if(d)return d;const _=Qvn(i,t);if(_)return _}return sqe(ebe()??"")??"three"}function zQe(t,r){r(t);for(const i of t.children)R0e(i)||zQe(i,r)}const URe=new xS;function xGt(t){return Number.isFinite(t.min.x)&&Number.isFinite(t.min.y)&&Number.isFinite(t.min.z)&&Number.isFinite(t.max.x)&&Number.isFinite(t.max.y)&&Number.isFinite(t.max.z)}const gEt=new SS,VRe=new xS;function Yvn(t,r,i){for(let a=0;a<r.count;a++)r.getMatrixAt(a,gEt),VRe.copy(i).applyMatrix4(gEt).applyMatrix4(r.matrixWorld),xGt(VRe)&&t.union(VRe)}function wGt(t,r){const i=r.geometry;if(!i)return;const a=Xvn(r,i);if(a){if(r.isInstancedMesh){Yvn(t,r,a);return}URe.copy(a).applyMatrix4(r.matrixWorld),xGt(URe)&&t.union(URe)}}function Xvn(t,r){const i=t;return t.isSkinnedMesh?(r.boundingBox===null&&r.computeBoundingBox(),r.boundingBox):i.boundingBox!==void 0&&!t.isInstancedMesh?(i.boundingBox===null&&i.computeBoundingBox?.(),i.boundingBox??null):(r.boundingBox===null&&r.computeBoundingBox(),r.boundingBox)}function Zvn(t,r){return zQe(r,i=>{i.updateWorldMatrix(!1,!1),wGt(t,i)}),t}const b_e=new xS;function CGt(t){const r=t.material;return r?Array.isArray(r)?r:[r]:[]}function e1n(t){const r=CGt(t);return r.length>0&&r.every(i=>i.depthWrite===!1)}function t1n(t){const r=CGt(t);return r.length>0&&r.every(i=>i.side===dkt)}function r1n(t,r=[]){return zQe(t,i=>{i.updateWorldMatrix(!1,!1),b_e.makeEmpty(),wGt(b_e,i),!b_e.isEmpty()&&r.push({box:b_e.clone(),overlay:e1n(i),enclosure:t1n(i)})}),r}function n4n(t,r=[]){for(const i of r1n(t))r.push(i.box);return r}function EGt(t,r=new xS){return r.makeEmpty(),Zvn(r,t)}class i4n extends bIr{entityObject;constructor(r,i){super(new xS,i),this.entityObject=r,this.update()}update(){EGt(this.entityObject,this.box)}}function n1n({stories:t,activeStoryId:r,onApplyStory:i,isolation:a,unavailableReason:l}){return z.jsxs("div",{style:{padding:"4px 0"},children:[t.length>0?z.jsxs(bS,{"data-testid":"ingest-stories-select",value:r,onChange:d=>{const _=d.target.value;i(_===""?null:_)},style:{width:"100%"},children:[z.jsx("option",{value:"",children:"(none)"}),t.map(d=>z.jsx("option",{value:d.id,children:d.label},d.id))]}):z.jsx("div",{"data-testid":"ingest-stories-none",style:{fontSize:"var(--vgai-font-base)",color:Oo.content.dim,fontStyle:"italic"},children:l??"No stories — this root has no associated portable CSF previews."}),a&&z.jsx(fo,{"data-testid":"catalog-isolate",onClick:a.toggle,variant:a.isolated?"primary":"secondary","aria-pressed":a.isolated,style:{marginTop:6,width:"100%"},children:a.isolated?"Exit isolation":"Isolate"})]})}function UQe(t){const r=new G8(...t);r.lengthSq()<Number.EPSILON?r.identity():r.normalize();const i=new Xqe().setFromQuaternion(r,"XYZ");return[bb.radToDeg(i.x),bb.radToDeg(i.y),bb.radToDeg(i.z)]}function i1n(t,r,i){if(i.length!==3||i.some(l=>!Number.isFinite(l)))throw new Error(`transform.${r} expects three finite numbers.`);const a={position:[...t.position],rotation:[...t.rotation],scale:[...t.scale]};if(r==="rotation"){const l=new G8().setFromEuler(new Xqe(bb.degToRad(i[0]),bb.degToRad(i[1]),bb.degToRad(i[2]),"XYZ"));return{...a,rotation:[l.x,l.y,l.z,l.w]}}return{...a,[r]:[i[0],i[1],i[2]]}}function s1n(t,r,i){const a=UQe(t.rotation);a[r]=i;const l=new G8().setFromEuler(new Xqe(bb.degToRad(a[0]),bb.degToRad(a[1]),bb.degToRad(a[2]),"XYZ"));return{position:[...t.position],rotation:[l.x,l.y,l.z,l.w],scale:[...t.scale]}}const o1n={x:"#e0726d",y:"#83bd66",z:"#6390dd"};function JRe({axes:t,label:r,values:i,testidPrefix:a,step:l,precision:d,onBegin:_,onPreview:g,onCommit:b,readOnly:S,readOnlyReason:k}){const[w,N]=Xe.useState(null),P=Xe.useRef(!1);return z.jsx(z_e,{label:r,style:{padding:"4px 8px"},children:t.map(({axis:j,name:J})=>z.jsx(SX,{testId:`${a}-${J}`,label:J,labelColor:o1n[J],title:k,disabled:S,step:l,precision:d,value:w?.axis===j?w.value:Number.isFinite(i[j])?i[j]:0,style:{flex:1,minWidth:0},onChange:X=>{P.current||(P.current=!0,_?.()),N({axis:j,value:X}),g?.(j,X)},onChangeEnd:X=>{P.current=!1,N(null),b(j,X)}},J))})}function a1n({dimensions:t="3d",transform:r,readOnly:i=!1,channelEditability:a,note:l,onBegin:d,onPreview:_,onCommit:g}){const b=[{axis:0,name:"x"},{axis:1,name:"y"}],S=[...b,{axis:2,name:"z"}],k=(J,X,G)=>{const ee={position:[...r.position],rotation:[...r.rotation],scale:[...r.scale]};return ee[X][J]=G,ee},w=(J,X)=>(G,ee)=>{Number.isFinite(ee)&&X?.(k(G,J,ee))},N=J=>(X,G)=>{Number.isFinite(G)&&J?.(s1n(r,X,G))},P=J=>{const X=a?.[J],G=i||X?.writable===!1;return X?.reason?{readOnly:G,readOnlyReason:X.reason}:{readOnly:G}},j=[...new Set(["position","rotation","scale"].map(J=>P(J)).filter(J=>J.readOnly&&J.readOnlyReason).map(J=>J.readOnlyReason))];return z.jsxs(I5r,{children:[z.jsx(JRe,{axes:t==="2d"?b:S,label:"Position",testidPrefix:"ingest-position",values:r.position,step:.1,precision:3,...P("position"),onBegin:d,onPreview:_&&w("position",_),onCommit:w("position",g)}),z.jsx(JRe,{axes:t==="2d"?[{axis:2,name:"z"}]:S,label:t==="2d"?"Rotation (degrees)":"Rotation",testidPrefix:"ingest-rotation",values:UQe(r.rotation),step:1,precision:1,...P("rotation"),onBegin:d,onPreview:_&&N(_),onCommit:N(g)}),z.jsx(JRe,{axes:t==="2d"?b:S,label:"Scale",testidPrefix:"ingest-scale",values:r.scale,step:.01,precision:3,...P("scale"),onBegin:d,onPreview:_&&w("scale",_),onCommit:w("scale",g)}),j.map(J=>z.jsx(Ru,{"data-testid":"inspector-transform-readonly-reason",variant:"caption",tone:"muted",style:{display:"block",padding:"4px 8px",overflowWrap:"anywhere"},children:J},J)),l&&z.jsx(Ru,{"data-testid":"inspector-transform-note",variant:"caption",tone:"muted",style:{display:"block",padding:"4px 8px",overflowWrap:"anywhere"},children:l})]})}function nbe(t){const[r,i]=Xe.useState(null);return Xe.useEffect(()=>{let a=0;const l=requestAnimationFrame(()=>{a=requestAnimationFrame(()=>i(t))});return()=>{cancelAnimationFrame(l),cancelAnimationFrame(a)}},[t]),r===t}const c1n=Xe.lazy(()=>Xo(()=>import("./InspectorObjectPreview-DHQ7UhMS.js"),__vite__mapDeps([76,1,2,47,3,4,8,9,10,42,6,7,40,14,43,41,11])).then(t=>({default:t.InspectorObjectPreview}))),l1n=Xe.lazy(()=>Xo(()=>import("./InspectorCanvasPreview-CLDhscy0.js"),__vite__mapDeps([77,1,2,3,4])).then(t=>({default:t.InspectorCanvasPreview})));function u1n({object:t,displayName:r,previewKey:i,actions:a,mode:l="section"}){const d=l==="thumbnail",_=nbe(i);return z.jsxs("div",{"data-testid":d?"inspection-preview-thumbnail":"inspection-preview",style:d?{position:"absolute",inset:0,overflow:"hidden"}:{position:"relative",width:"calc(100% - 24px)",aspectRatio:"1 / 1",flexShrink:0,margin:12,overflow:"hidden",border:"1px solid var(--vgai-structural-divider)",borderRadius:"var(--dv-group-border-radius, 8px)"},children:[_&&z.jsx(Xe.Suspense,{fallback:null,children:z.jsx(c1n,{previewKey:i,object:t,displayName:r,fill:!0})}),!d&&a.map(g=>z.jsx(fo,{"data-testid":g.id,size:"compact",disabled:g.disabled,title:g.title,onClick:g.run,style:{position:"absolute",right:8,bottom:8},children:g.label},g.id))]})}function f1n({source:t,entry:r,previewKey:i,actions:a,mode:l="section"}){const d=l==="thumbnail",_=nbe(i);return z.jsxs("div",{"data-testid":d?"inspection-preview-thumbnail":"inspection-preview",style:d?{position:"absolute",inset:0,overflow:"hidden"}:{position:"relative",width:"calc(100% - 24px)",aspectRatio:"1 / 1",flexShrink:0,margin:12,overflow:"hidden",border:"1px solid var(--vgai-structural-divider)",borderRadius:"var(--dv-group-border-radius, 8px)"},children:[_&&z.jsx("div",{style:{position:"absolute",inset:0,overflow:"hidden",background:"var(--vgai-bg-inset)"},children:z.jsx(t.Thumbnail,{entry:r,previewRevision:0,width:d?96:256,height:d?96:256})}),!d&&a.map(g=>z.jsx(fo,{"data-testid":g.id,size:"compact",disabled:g.disabled,title:g.title,onClick:g.run,style:{position:"absolute",right:8,bottom:8},children:g.label},g.id))]})}function d1n({capture:t,previewKey:r,actions:i,mode:a="section"}){const l=a==="thumbnail",d=nbe(r);return z.jsxs("div",{"data-testid":l?"inspection-preview-thumbnail":"inspection-preview",style:l?{position:"absolute",inset:0,overflow:"hidden"}:{position:"relative",width:"calc(100% - 24px)",aspectRatio:"1 / 1",flexShrink:0,margin:12,overflow:"hidden",border:"1px solid var(--vgai-structural-divider)",borderRadius:"var(--dv-group-border-radius, 8px)"},children:[d&&z.jsx(Xe.Suspense,{fallback:null,children:z.jsx(l1n,{capture:t,previewKey:r,size:l?96:256})}),!l&&i.map(_=>z.jsx(fo,{"data-testid":_.id,size:"compact",disabled:_.disabled,title:_.title,onClick:_.run,style:{position:"absolute",right:8,bottom:8},children:_.label},_.id))]})}function p1n(t){return t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function _1n(t){const r=[],i=[],a=new Map;for(const l of t)l.group?(a.has(l.group)||(a.set(l.group,[]),i.push(l.group)),a.get(l.group).push(l)):r.push(l);return{ungrouped:r,groups:i.map(l=>({name:l,groupId:p1n(l),properties:a.get(l)}))}}function m1n(t,r){if(!t.transforms)return null;const i=t.transforms.dimensions?.(r);return i!==void 0?i:t.hierarchy.object3D===void 0||t.hierarchy.object3D(r)!==null?"3d":null}const h1n=1e-4,g1n="World-anchored — content is placed in world space by the game each frame; moving this container offsets future placements away from their source.";function TGt(t){if(!t)return 0;const r=t;if(r.isInstancedMesh!==!0)return 0;const i=r.count;return typeof i=="number"&&i>0?i:0}function y1n(t){const r=t.elements;for(let i=0;i<16;i++){const a=i%5===0?1:0,l=r[i];if(!Number.isFinite(l)||Math.abs(l-a)>h1n)return!1}return!0}const yEt=new xS,vEt=new Tc;function v1n(t,r){const i=TGt(t);if(i===0)return null;const a=b1n(t,r);return{units:i,detail:kGt(i),worldAnchored:a,note:a?g1n:null}}function b1n(t,r){if(!r||r.isEmpty()||!y1n(t.matrixWorld))return!1;const i=t.geometry;return i.boundingBox===null&&i.computeBoundingBox(),i.boundingBox?(yEt.copy(i.boundingBox),r.getCenter(vEt),!yEt.containsPoint(vEt)):!1}function A1n(t){const r=TGt(t);return r===0?null:kGt(r)}function kGt(t){return`${t} instanced unit${t===1?"":"s"}`}const S1n=14,x1n=[[/physic|rigid|collid/i,mDr],[/material/i,LIr],[/light/i,Vkt],[/camera/i,zye],[/audio|sound|music/i,iIt],[/player|character|humanoid|person/i,pDr],[/anim|state|machine/i,YIr]];function w1n(t){for(const[r,i]of x1n)if(r.test(t))return i;return yee}function C1n(t){return r=>Xe.createElement(u1n,{object:t.object,displayName:t.displayName,previewKey:t.previewKey,actions:t.actions,...r?{mode:r}:{}})}function E1n(t){return r=>Xe.createElement(f1n,{source:t.picture.source,entry:t.picture.entry,previewKey:t.previewKey,actions:t.actions,...r?{mode:r}:{}})}function T1n(t){return r=>Xe.createElement(d1n,{capture:t.capture,previewKey:t.previewKey,actions:t.actions,...r?{mode:r}:{}})}function k1n(t){return t.object?.isCamera?null:t.object?C1n({object:t.object,displayName:t.displayName,previewKey:t.previewKey,actions:t.actions}):t.canvasCapture?T1n({capture:t.canvasCapture,previewKey:t.previewKey,actions:t.actions}):t.picture?E1n({picture:t.picture,previewKey:t.previewKey,actions:t.actions}):null}function WRe(t){const r=t.slice(10);if(r!=="position"&&r!=="rotation"&&r!=="scale")throw new Error(`The Transform section has no ${JSON.stringify(t)}.`);return r}const I1n={position:[0,0,0],rotation:[0,0,0,1],scale:[1,1,1]};function D1n(t,r,i,a){if(F3t(t))return t.sections(a,r);const l=t.Section;return[{id:t.id,title:t.title,icon:typeof t.icon=="function"?t.icon(a,r):t.icon,order:t.order,...t.railGroup===void 0?{}:{railGroup:t.railGroup},...t.railDefault===void 0?{}:{railDefault:t.railDefault},body:{kind:"custom",render:()=>Xe.createElement(l,{adapter:r,nodeId:i})}}]}function IGt(t,r,i,a){const l=new Set,d=new Map,_=[];for(const g of t){const b=D1n(g,r,i,a).filter(k=>!l.has(k.id)),S=(F3t(g)?g.claims??[]:[]).filter(k=>!l.has(k));if(!(b.length===0&&S.length===0)){for(const k of b)l.add(k.id),d.set(k.id,g.owner);for(const k of S)l.add(k);_.push(...b)}}return{sections:_,claimed:l,owners:d}}function DGt(t,r,i){return i===void 0?[...t]:t.filter(a=>r.get(a.id)===i.owner||i.builtins.includes(a.id))}function oqe(t){const{adapter:r,nullSubject:i}=t,{sections:a,claimed:l,owners:d}=IGt(r?t.contributions??[]:[],r,null,null),_=DGt([...(i?.sections??[]).filter(g=>!l.has(g.id)),...a].sort((g,b)=>g.order-b.order),d,t.rail);return{id:i?.id??"nothing-selected",title:i?.title??"Nothing selected",identity:i?.kindLabel?{rename:{readOnly:!0,set:()=>{}},kindLabel:i.kindLabel,...i.note?{note:i.note}:{}}:null,...i?.hint?{hint:i.hint}:{},presentation:{preferred:jze(t.surface)},quickActions:i?.quickActions??[],related:[],sections:_}}function P1n(t,r,i){if(t.body.kind!=="custom"||t.body.editable)return t;const a=i.get(t.id);return!a||a.length===0?t:{...t,body:{...t.body,editable:{fields:a,io:r}}}}function N1n(t){const{adapter:r,nodeId:i,node:a,contributions:l,onEdit:d}=t;if(i===null)return oqe({nullSubject:t.nullSubject??null,surface:t.surface,contributions:l,adapter:r,rail:t.rail});const{sections:_,claimed:g,owners:b}=IGt(l,r,i,a),S={get:cr=>r.inspector?.get(i,cr),...r.inspector?.preview?{preview:(cr,Yt)=>{r.inspector?.preview?.(i,cr,Yt)}}:{},set:(cr,Yt)=>{if(!r.inspector)return;const Lr=n4t(r,i,cr,Yt);return d(),Lr},...r.inspector?.remove?{remove:cr=>{const Yt=G9r(r,i,cr);return d(),Yt}}:{}},k=r.inspector?.properties(i)??[],w=k.find(cr=>cr.path==="name"),{ungrouped:N,groups:P}=_1n(k.filter(cr=>cr.path!=="name")),j=N.find(cr=>cr.path==="visible"&&cr.type==="boolean"),J=j?N.filter(cr=>cr!==j):N,X=[...w&&w.readonly!==!0?[w]:[],...j?[j]:[]],G=[];if(j){const cr=S.get(j.path)!==!1,Yt=cr?"Visible — click to hide":"Hidden — click to show";G.push({id:"inspector-visibility-toggle",title:Yt,icon:cr?Zqe:tze,placement:"identity",pressed:!cr,disabled:j.readonly===!0,run:async()=>{await S.set(j.path,!cr)}})}t.assetDocument&&G.push({id:"open-asset-editor",title:"Open in Asset Editor",label:"Open in Asset Editor",placement:"preview",run:t.assetDocument.open}),r.transforms?.sourceCommit?.availability(i)?.available&&G.push({id:"commit-live-transform-source",title:"Commit this live transform to its authored source literal",label:"Commit transform to source",icon:Wkt,placement:"identity",run:async()=>{await t4t(r,i),d()}});const ue=new Map;ue.set(PFe,J);for(const cr of P)ue.set(mAt(cr.groupId),cr.properties);const fe=[],se=r.truth?.resolve(i,"position").site??null,de=t.previewObject,ge=a?.typeLabel??a?.label??i,qe=t.surface==="canvas"&&de===null&&t.stories?oGt({name:ge,path:se?.anchored===!0?se.file:"",surface:"canvas"}):null,tt=G.filter(cr=>cr.placement==="preview"),Ct=k1n({object:de,canvasCapture:t.canvasPreview,picture:qe,displayName:a?.label??i,previewKey:i,actions:tt});!g.has(pMe)&&Ct!==null&&fe.push({id:pMe,title:"Preview",icon:f9,order:N3t,body:{kind:"preview",render:Ct}});const Ot=m1n(r,i);if(!g.has(_At)&&Ot!==null){const cr=r.transforms?.get(i)??I1n,Yt=de?v1n(de,EGt(de)):null,Lr=Object.fromEntries(["position","rotation","scale"].map(on=>[on,r.transforms?.editability?.(i,on)??{writable:r.capabilities.transform}])),nn={position:[...cr.position],rotation:UQe(cr.rotation),scale:[...cr.scale]};fe.push({id:_At,title:"Transform",icon:Kkt,order:n7r,body:{kind:"custom",data:{...nn,editability:Lr,...Yt?{instanced:Yt}:{}},editable:{fields:["position","rotation","scale"].map(on=>{const gr=!r.capabilities.transform||!Lr[on].writable;return{path:`transform.${on}`,label:on[0].toUpperCase()+on.slice(1),type:"vec3",value:nn[on],readonly:gr,...!gr&&r.transforms?.remove&&Lr[on].removable===!0?{resettable:!0}:{}}}),io:{get:on=>nn[WRe(on)],set:(on,gr)=>{if(!r.transforms)return;const An=i1n(cr,WRe(on),gr);XMe(r,i),rme(r,i,An);const Rn=ZMe(r,i);return d(),Rn},...r.transforms?.remove?{remove:on=>{const gr=e4t(r,i,WRe(on));return d(),gr}}:{}}},render:()=>Xe.createElement(a1n,{dimensions:Ot,transform:cr,readOnly:!r.capabilities.transform,channelEditability:Lr,...Yt?.note?{note:Yt.note}:{},onBegin:()=>{XMe(r,i)},onPreview:on=>{rme(r,i,on)},onCommit:on=>{rme(r,i,on),ZMe(r,i),d()}})}})}g.has(PFe)||(J.length>0&&fe.push({id:PFe,title:"Properties",icon:Ykt,order:hZ,defaultOpen:!0,body:{kind:"fields",fields:J,io:S}}),P.forEach((cr,Yt)=>{const Lr=cr.properties.filter(nn=>!nn.defaulted).length;fe.push({id:mAt(cr.groupId),title:cr.name,icon:w1n(cr.name),order:O3t+Yt,description:Lr>0?`${Lr} set of ${cr.properties.length}`:`${cr.properties.length} properties`,defaultOpen:Lr>0&&cr.properties.length<=S1n,testId:`ingest-group-${cr.groupId}`,body:{kind:"fields",fields:cr.properties,io:S}})}));const vt=t.stories;!g.has(P3t)&&vt&&fe.push(O1n(vt)),fe.push(..._.map(cr=>P1n(cr,S,ue))),fe.sort((cr,Yt)=>cr.order-Yt.order);const Et=DGt(fe,b,t.rail),Tt=d4t(r,i),Le=p4t(r);return{id:i,title:a?.label??"",identity:{rename:{readOnly:w===void 0||w.readonly===!0,set:cr=>S.set("name",cr)},kindLabel:`${a?.typeLabel??a?.kind??""}${Tt?` · ${Tt.label}`:""}`,...a?.kind?{kind:a.kind}:{},...Le?{document:{path:Le,...Tt?.detail?{title:Tt.detail}:{}}}:{},note:se?.anchored?{text:`${se.kind==="data"?"Level data":"Source"} · ${se.display}`,title:se.kind==="data"?`Placed by record ${se.record} of ${se.file}, the game's own level data`:`Constructed by a \`new\` expression at ${se.file} line ${se.line}, column ${se.col}`,testId:"inspector-creation-site"}:void 0},presentation:{preferred:jze(t.surface)},...X.length>0?{editable:{fields:X,io:S}}:{},...t.alsoSelected?{alsoSelected:t.alsoSelected}:{},quickActions:G,related:r.related?.links(i)??[],sections:Et}}function O1n(t){return{id:P3t,title:t.title??"Stories",icon:cIt,order:i7r,body:{kind:"custom",render:()=>Xe.createElement(n1n,{stories:t.stories,activeStoryId:t.activeStoryId,onApplyStory:t.onApplyStory,isolation:t.isolation,unavailableReason:t.unavailableReason??null})}}}const F1n=["project-tool","tool-contribution"];function R1n(t){const{activeDocumentKind:r,documentSelection:i}=t;return r===null||!F1n.includes(r)?!1:i===null}function bEt(t){const{subject:r,surface:i,available:a,override:l,workspaceDefault:d=null}=t,_=r.presentation.preferred??jze(),g=Gvn(_,l,d);return{subject:r,surface:i,presentation:g,available:a,card:a&&g==="card",column:g!=="card"}}const M1n="game",L1n=3,j1n=Object.freeze({none:!0});function B1n(t){const r=Object.getPrototypeOf(t);return r===Object.prototype||r===null}function fee(t,r=0){if(t===null)return null;const i=typeof t;if(i==="string"||i==="boolean")return t;if(i==="number")return Number.isFinite(t)?t===0?0:t:{kind:"opaque",type:"number"};if(i!=="object")return{kind:"opaque",type:i};if(r>=L1n)return{kind:"opaque",type:AEt(t)};if(Array.isArray(t))return t.map(d=>fee(d,r+1));const a=t;if(!B1n(a))return{kind:"opaque",type:AEt(a)};const l={};for(const[d,_]of Object.entries(a))_!==void 0&&(l[d]=fee(_,r+1));return l}function AEt(t){return t.constructor?.name??"object"}function SEt(t,r){let i;try{i=r.get(t.path)}catch{i=void 0}return{path:t.path,label:t.label,type:t.type,...dMe(i)?{mixed:!0}:{},...!dMe(i)&&i!==void 0?{value:fee(i)}:{},...t.defaulted!==void 0?{defaulted:t.defaulted}:{},...t.readonly!==void 0?{readonly:t.readonly}:{},...t.readonly?{readonlyReason:Lze(t)}:{},...t.resettable!==void 0?{resettable:t.resettable}:{},...t.revertsTo!==void 0?{revertsTo:t.revertsTo}:{},...t.group!==void 0?{group:t.group}:{},...t.options!==void 0?{options:t.options.map(a=>fee(a))}:{}}}function xEt(t){const r={};for(const[i,a]of Object.entries(t))a!==void 0&&(r[i]=fee(a));return r}function $1n(t){const r=t.body;if(r.kind==="fields")return{kind:"fields",fields:r.fields.map(i=>SEt(i,r.io))};if(r.kind==="custom"&&r.data!==void 0&&r.editable===void 0)return{kind:"custom",id:t.id,title:t.title,data:xEt(r.data)};if(r.kind==="custom"&&r.editable!==void 0){const i=r.editable;return{kind:"fields",fields:i.fields.map(a=>SEt(a,i.io)),...r.data!==void 0?{data:xEt(r.data)}:{}}}return{kind:r.kind,id:t.id,title:t.title}}function q1n(t){return{id:t.id,title:t.title,order:t.order,...t.description!==void 0?{description:t.description}:{},body:$1n(t)}}function z1n(t,r){return{id:t.id,title:t.title,...t.identity?.kindLabel?{kindLabel:t.identity.kindLabel}:{},...t.identity?.note?{note:t.identity.note.text}:{},...t.hint?{hint:t.hint}:{},...t.alsoSelected?{alsoSelected:t.alsoSelected}:{},presentation:{preferred:t.presentation.preferred,...r?{resolved:r.presentation,surface:r.surface}:{}},quickActions:t.quickActions.map(i=>({id:i.id,title:i.title,...i.label!==void 0?{label:i.label}:{},...i.pressed!==void 0?{pressed:i.pressed}:{},...i.disabled!==void 0?{disabled:i.disabled}:{}})),related:t.related.map(({id:i,title:a})=>({id:i,title:a})),sections:t.sections.map(q1n)}}const wEt=new WeakMap;function U1n(t){const r=wEt.get(t);if(r)return r;const i=async a=>t.captureImage(a);return wEt.set(t,i),i}function V1n(t){return typeof t.previewImage=="function"}function J1n(t,r,i){if(!r)return null;if(i==="asset-lab"){const l=I_(),d=l?Pw(l):null;return d?U1n(d):null}let a=t;if(t instanceof Zh){const l=t.ownerOf(r);a=t.childAdapters().find(d=>d.worldId===l)?.adapter??t}return V1n(a)?l=>a.previewImage(r,l,l):null}function W1n(){const t=I_();if(t===null)return null;const r=Vmn(t);if(r===void 0)return null;const i=y9(r.kind);return i===void 0||i.inspectorRail!=="owned"?null:{rail:{owner:i.owner,builtins:i.inspectorBuiltins??[]}}}function H1n(t){const{store:r,adapter:i,documentSelection:a,surface:l}=t,d=Mvn();if(d!==null)return{subject:oqe({nullSubject:d,surface:l}),available:!0};const _=Vvn(a,r.selectedEntityIds,i),g=_?i.hierarchy.node(_):null;if(_!==null&&g===null)return{subject:oqe({nullSubject:null,surface:l}),available:!1};const b=()=>r.notifyIngestEdit(),S=_?null:vMr({adapter:i,surface:l,store:r,onEdit:b}),k=_?g?yAt(g,i):[]:yAt(null,i,{nullSubjectId:S?.id??null});return{subject:N1n({adapter:i,nodeId:_,node:g,surface:l,contributions:k,..._?{}:{nullSubject:S},previewObject:(_===null||l==="asset-lab"?null:dte(i,r.objectMap,_))??null,canvasPreview:J1n(i,_,l),assetDocument:_&&r.objectMap.has(_)?{open:()=>PNt(r,_)}:null,stories:_Mr(i,g,_),...W1n()??{},...a===null&&_!==null&&r.selectedEntityIds.size>1?{alsoSelected:r.selectedEntityIds.size-1}:{},onEdit:b}),available:_!==null||S!==null||k.length>0}}function ibe(t){const r=Kvn(t),{adapter:i,documentSelection:a}=wm(t),l=H1n({store:t,adapter:i,documentSelection:a,surface:r}),{subject:d}=l,_=l.available&&(d.id!==M1n||d.sections.length>0)&&!R1n({activeDocumentKind:AE()?.descriptor.kind??null,documentSelection:a}),g=I_()===Sw?kQe():null;if(g){const b=Uvn(g),S=_?{...d,sections:[...d.sections.filter(k=>k.id!==b.id),b].sort((k,w)=>k.order-w.order)}:{id:`ingest:${g.summary.worldId}`,title:"Ingested game",identity:null,hint:"This mount exposes no editable scene subject. Coverage below says exactly which editor seams it did earn.",presentation:d.presentation,quickActions:[],related:[],sections:[b]};return bEt({subject:S,surface:r,available:!0,override:iqe(r),workspaceDefault:wP().inspector??null})}return bEt({subject:d,surface:r,available:_,override:iqe(r),workspaceDefault:wP().inspector??null})}function sbe(t){const{subject:r,surface:i,presentation:a,available:l}=ibe(t);return l?z1n(r,{surface:i,presentation:a}):j1n}async function G1n(t,r){const{subject:i,available:a}=ibe(t);if(!a)throw new Error("No Inspector subject is active.");const l=i.quickActions.filter(_=>_.id===r);if(l.length!==1){const _=i.quickActions.map(g=>g.id);throw new Error(l.length===0?`Inspector action ${JSON.stringify(r)} is not available. `+(_.length>0?`Available actions: ${_.join(", ")}.`:"This subject exposes no actions."):`Inspector action id ${JSON.stringify(r)} is ambiguous (${l.length} matches).`)}const d=l[0];if(!d||d.disabled)throw new Error(`Inspector action ${JSON.stringify(r)} is disabled.`);return await d.run(),sbe(t)}function Q1n(t,r){const i=a=>{throw new Error(`Inspector field ${JSON.stringify(t.path)} expects ${a}.`)};if(t.type==="number"&&(typeof r!="number"||!Number.isFinite(r))&&i("a finite number"),t.type==="boolean"&&typeof r!="boolean"&&i("a boolean"),(t.type==="string"||t.type==="color"||t.type==="asset"||t.type==="enum")&&typeof r!="string"&&i("a string"),t.type==="vec3"&&(!Array.isArray(r)||r.length!==3||r.some(a=>typeof a!="number"||!Number.isFinite(a)))&&i("three finite numbers"),t.type==="enum"&&t.options&&!t.options.includes(r))throw new Error(`Inspector field ${JSON.stringify(t.path)} accepts: ${t.options.map(String).join(", ")}.`)}async function K1n(t,r,i){const a=PGt(t,r);Q1n(a.field,i);const l=await a.io.set(r,i)??Vhe;return{subject:sbe(t),write:l}}function PGt(t,r){const{subject:i,available:a}=ibe(t);if(!a)throw new Error("No Inspector subject is active.");const l=(i.editable?.fields??[]).filter(b=>b.path===r).map(b=>({field:b,io:i.editable.io})),d=i.sections.flatMap(b=>{const S=b.body,k=S.kind==="fields"?{fields:S.fields,io:S.io}:S.kind==="custom"?S.editable:void 0;return k?k.fields.filter(w=>w.path===r).map(w=>({field:w,io:k.io})):[]}),_=[...l,...d];if(_.length===0)throw new Error(`The active Inspector has no field at ${JSON.stringify(r)}.`);if(_.length>1)throw new Error(`The active Inspector exposes ${JSON.stringify(r)} more than once.`);const g=_[0];if(g.field.readonly)throw new Error(`Inspector field ${JSON.stringify(r)} is read-only: ${Lze(g.field)}`);return g}class aqe extends Error{constructor(r){super(r),this.name="InspectionRemovalUnavailableError"}}async function Y1n(t,r){const i=PGt(t,r);if(i.field.resettable!==!0)throw new aqe(`Inspector field ${JSON.stringify(r)} does not declare itself removable (\`resettable\`), so this lane has no way to express the property's absence. Write a value with \`set-inspection-field\` instead — and note that doing so cannot restore byte-absence for a property an edit ADDED.`);if(!i.io.remove)throw new aqe(`The Inspector io that owns ${JSON.stringify(r)} implements no removal door, so the property's authored override cannot be dropped through this editor. The dialect writer that owns this source edit owns removal too; until it does, an edit/revert round trip over this lane is unverifiable at byte level.`);const a=await i.io.remove(r)??Vhe;return{subject:sbe(t),write:a}}let X1n=[];const CEt=new Set;function s4n(t){return CEt.add(t),()=>CEt.delete(t)}function NGt(){return X1n}function Z1n(){const t=NGt();if(t.length===0)return null;const r=t.filter(i=>i.source==="measured");return r.length===0?null:`${r.length} of ${t.length} root(s) have NO readiness declaration (${r.map(i=>i.rootId).join(", ")}) — the host is measuring instead. A self-booting game states it with \`window.vgaiGame.ready\`.`}function ebn(t){return t.liveMounted?t.livePlaying?t.storePlayState==="paused"?"paused":"playing":"paused":"stopped"}async function tbn(t,r){switch(t.reach.kind){case"game-contract":{const i=r.scenes();if(!i)return{ok:!1,code:"SCENE_CONTRACT_UNAVAILABLE",error:`open: "${t.id}" is reached through the running game's own scenes contract, and the game running in this session publishes none (\`window.vgaiGame.scenes\`).`};const a=i.goToScene(t.reach.sceneId);if(!a.ok)return{ok:!1,code:"SCENE_NOT_IN_CONTRACT",error:`open: "${t.id}" — ${a.error}`,known:a.known};const l=await a.settled;return l.error!==void 0?{ok:!1,code:"SCENE_SWITCH_FAILED",error:`open: "${t.id}" — the game's own navigation failed: ${l.error}`}:(r.activateGameDocument(),{ok:!0,documentId:r.gameDocumentId,title:t.label,scene:{requested:l.requested,current:l.current}})}case"root-mount":return r.activateGameDocument()?{ok:!0,documentId:r.gameDocumentId,title:t.label}:{ok:!1,code:"SCENE_DOCUMENT_NOT_MOUNTED",error:`open: "${t.id}" is the running game itself, and no game document is open in this session.`};case"entrypoint-selection":{const i=r.remountSelection,a=t.region;if(!i||a===null)return{ok:!1,code:"SCENE_NOT_OPENABLE_LIVE",error:`open: "${t.id}" sits at the entrypoint's \`${t.reach.selection}\` swap slot, and this session has no live remount for a native swap-slot scene — a running game cannot be sent there in place. Stop the game and open it as a document instead.`};const l=await i({selection:t.reach.selection,key:t.reach.key,regionId:a});return l.ok?(r.activateGameDocument(),{ok:!0,documentId:r.gameDocumentId,title:t.label,scene:{requested:t.reach.key,current:t.reach.key},restart:!0}):{ok:!1,code:"SCENE_SWITCH_FAILED",error:`open: "${t.id}" — remount at \`${t.reach.selection}["${t.reach.key}"]\` failed: ${l.error}`}}case"story":case"none":return null}}const xye="console";function rbn(t){let r=IZ().length>0;const i=oNt(()=>{const d=IZ().length>0;d&&!r&&wP().drawer!=="hidden"&&hE(xye),r=d});let a=t.getSnapshot().lastError!==null;const l=t.subscribe(()=>{const d=t.getSnapshot().lastError,_=d!==null;_&&!a&&(ua.error(`Source write rolled back: ${d.message} (${d.code})`,"history"),wP().drawer!=="hidden"&&hE(xye)),a=_});return()=>{i(),l()}}function obe(){Z7r(xye)}function abe(){hE(xye)}const nbn=new Map;function ibn(){return[...nbn].map(([t,r])=>({rootId:t,source:r.source,sceneId:r.sceneId,cameraId:r.cameraId,alternates:[...r.alternates],...r.alternates.length>0?{ambiguity:`"${t}" rendered ${r.alternates.length} other world(s) after the one the editor adopted (${r.source}: ${r.sceneId}). The adopted world is unchanged; if the editor is showing the wrong scene, one of these is it: `+r.alternates.map(i=>`${i.sceneId}${i.sameRenderer?"":" (a SECOND renderer)"}`).join(", ")}:{}}))}const sbn=new Set(["state","stateAll","providers","commands","events","snapshot"]);function obn(t){if(t.type!=="bridge-call")return[];const r=t.method;if(typeof r!="string"||!sbn.has(r))return[];const i=t.instance;try{const a=kOr(i).debug;if(a===void 0)return[];const l=[yOr(a),i??""].join(":"),d=(g,b="")=>[l,g,b].join(":");if(r==="snapshot")return[d("snapshot"),d("state","time"),d("stateAll"),d("events")];const _=r==="state"?String(t.callArgs?.[0]):"";return[d(r,_)]}catch{return[]}}function abn(t,r,i){const a=obn(t),l=r&&a.length>0&&a.every(d=>i.has(d));if(r)for(const d of a)i.add(d);return{derived:l?"none":r&&a.length>0?"always":v3r(t.type)??g3r(t.type),playFullReport:r&&!l&&a.length>0?"explicit":r&&t.type==="bridge-call"&&t.method==="invoke"?"if-content-changed":"none"}}function cbn(t,r,i,a){return t==="none"?!1:!(t==="if-content-changed"&&r==="none"&&i===a)}function EEt(t,r){const i=tO(t);return i.hierarchy.node(r)!==null||dte(i,t.objectMap,r)!==null?null:`select: no entity with id "${r}" — neither the active authoring adapter's hierarchy nor the live object index owns it, so there is nothing to select. Read the ids that exist with editor.hierarchy() (the rows the panel is rendering) or editor.status().entities.`}function HRe(t,r,i){const a=lw();if(a){a.select(r);return}const l=t.applySelectionBeforePresentation(r);i?.deferPresentation?i.deferPresentation(l):setTimeout(l,0)}function lbn(t){const r=bP(t).cameraPose;if(r)return{position:{x:r.position.x,y:r.position.y,z:r.position.z},target:{x:r.target.x,y:r.target.y,z:r.target.z},fov:r.fov}}function ubn(){return typeof document>"u"?null:{visibility:document.visibilityState,focused:document.hasFocus(),reportedAt:Date.now()}}const fbn=["entities","entityCount","ontologyInvariants"];function dbn(t){const r={...t};for(const i of fbn)delete r[i];for(const i of Qgn())delete r[i];return{...r,_statePatch:!0}}function TEt(t,r=null){const i=IZ(),a=I_(),l=a?Pw(a)?.presentation():void 0,d=VUe(t),_=k3t.getSnapshot(),g=r?.entities??z0e(t);return{playState:ebn({storePlayState:t.playState,liveMounted:DQe(),livePlaying:tbe()}),mountFailures:i.map(b=>({...b})),moduleSplits:ryn().map(b=>({path:b.path,urls:[...b.urls]})),adapter:v1(),readiness:NGt().map(b=>({...b})),readinessWarning:Z1n(),worldAdoption:ibn().map(b=>({...b})),presence:ubn(),pageErrors:pbn(),consoleErrors:_bn(),sessionErrors:mbn(),sessionWarnings:hbn(),rendererResources:{hostLive:Ojr(),interactive:hyn(),inspectorPreview:Mjr()},ontologyInvariants:r?.ontologyInvariants??KHt().map(b=>({...b})),...Ggn(r),selectedEntityId:d[0]??null,selectedEntityIds:d,selectedCreationSite:sqr(t),selectedWriteAnchorKind:oqr(t),activeViewportTab:t.activeViewportTab,activeDocumentId:a,activeUtilityId:Y7r(),gameplaySession:{selectedSessionId:_.selectedSessionId,latestSessionId:_.sessions[0]?.id??null,selectedStatus:_.selectedSession?.status??null,cursorMs:_.cursorMs,liveEdgeMs:_.liveEdgeMs},openDocumentIds:FA().map(b=>b.descriptor.id),activeTabKey:(()=>{const b=I_();return b&&INt(b)?b:"__inspector__"})(),showGrid:l?.grid??t.showGrid,showHelpers:bP(t).showHelpers,showStats:bP(t).showStats,shadingMode:l?.mode??t.shadingMode,helperVisibility:{...bP(t).helperVisibility,...l?{bounds:l.bounds,skeletons:l.skeleton}:{}},transformMode:bP(t).transformMode,transformSpace:t.transformSpace,snapEnabled:t.snapEnabled,entityCount:g.length,savePath:UUe(t),saveState:aNt(t),camera:lbn(t),entities:g,viewportActivationTimings:ZOr()}}function OGt(t,r){const i=r instanceof Error?r.message:String(r),a=`editor command "${String(t.type)}" threw: ${i}`;return console.error(a,r),{ok:!1,error:a}}function kEt(t){const r=t.size,i=t.width,a=t.height;if(i!==void 0||a!==void 0){if(r!=null)return{error:`${String(t.type)}: pass "size" (a square) OR "width"+"height" (a shaped frame), never both.`};const d=(b,S)=>typeof S!="number"||!Number.isInteger(S)?`${String(t.type)}: "${b}" must be a whole number — got ${typeof S} ${JSON.stringify(S)??String(S)}.`:S<IEt||S>J$?`${String(t.type)}: "${b}" must be ${IEt}-${J$} — ${DEt}`:S,_=d("width",i);if(typeof _=="string")return{error:_};const g=d("height",a);return typeof g=="string"?{error:g}:_*g>J$*J$?{error:`${String(t.type)}: ${_}x${g} is ${_*g} pixels, past the ${J$}x${J$} total — ${DEt}`}:{size:{width:_,height:g}}}return r==null?{}:typeof r!="number"||!Number.isFinite(r)||r<1?{error:`${String(t.type)}: "size" must be a finite number >= 1 — got ${typeof r} ${JSON.stringify(r)??String(r)}.`}:{size:r}}const IEt=64,J$=1024,DEt="the editor's own ceiling: the pixels cross the relay as base64 JSON, and 1024 is where even incompressible RGBA still fits its 50 MB request limit. For more picture, take more views, not bigger ones.";function lw(){const t=I_();return t?Pw(t):null}function VQe(t){const r=xQe();return!r||t<r.startedAt?!1:r.endedAt===null||t<=r.endedAt}function pbn(){return ua.getEntries().filter(t=>t.level==="error"&&t.source==="runtime"&&VQe(t.timestamp)).slice(-100).map(t=>t.count>1?`${t.message} (×${t.count})`:t.message)}const PEt=200;function _bn(){return JQe(ua.getEntries().filter(t=>t.level==="error"&&t.source!=="runtime"&&VQe(t.timestamp)))}function JQe(t){const r=t.reduce((a,l)=>a+l.count,0),i=t.slice(-3).map(a=>{const l=a.source?`[${a.source}] `:"",d=a.count>1?` (×${a.count})`:"",_=a.message.length>PEt?`${a.message.slice(0,PEt)}…`:a.message;return`${l}${_}${d}`});return{count:r,recent:i}}function mbn(){return JQe(ua.getEntries().filter(t=>t.level==="error"&&!VQe(t.timestamp)))}function hbn(){return JQe(ua.getEntries().filter(t=>t.level==="warn"))}async function gbn(t){const r=t.src;if(typeof r!="string")return{ok:!1,error:`document-script requires a string "src" (the step's toString())`};const i=I_();if(!i)return{ok:!1,error:"document-script: no document is active",data:{code:"DOCUMENT_SCRIPT_UNAVAILABLE"}};await w3t(i);const a=_Z(i);if(I_()!==i)return{ok:!1,error:"document-script: the active document changed while its context was loading",data:{code:"DOCUMENT_SCRIPT_UNAVAILABLE",documentId:i}};if(a===void 0)return{ok:!1,error:`document-script: the active document (${i}) publishes no context to run against — a document opts in through its \`publishContext\` prop (the mesh document publishes its session).`,data:{code:"DOCUMENT_SCRIPT_UNAVAILABLE",documentId:i}};let l;try{l=new Function("ctx","info",`return (${r})(ctx, info)`)}catch(d){return{ok:!1,error:`document-script: failed to reconstruct the step function from source — ${d instanceof Error?d.message:String(d)}`,data:{code:"DOCUMENT_SCRIPT_ERROR"}}}try{const d=await l(a,{documentId:i});return{ok:!0,data:{result:d===void 0?null:d}}}catch(d){return{ok:!1,error:`document-script: step threw — ${d instanceof Error?d.message:String(d)}`,data:{code:"DOCUMENT_SCRIPT_ERROR"}}}}async function ybn(t,r){const i=r.assetPath,a=r.entityId,l=r.glbBase64;if(+(typeof i=="string")+ +(typeof a=="string")+ +(typeof l=="string")!==1)return{ok:!1,error:"capture-asset-preview requires exactly one of assetPath, entityId or glbBase64."};const _=r.width,g=r.height,b=r.background,S=r.shots,k=r.shotSet,w=r.forward,N=r.compare,P=r.stage,j=r.camera,J=r.pose;if(_!==void 0&&typeof _!="number"||g!==void 0&&typeof g!="number"||b!==void 0&&b!=="neutral"&&b!=="transparent"||S!==void 0&&S!=="source")return{ok:!1,error:"Invalid asset preview dimensions, background, or shots mode."};if(P!==void 0&&P!=="lab"&&P!=="scene")return{ok:!1,error:`capture-asset-preview stage must be "lab" or "scene", got ${String(P)}.`};if(k!==void 0&&S!==void 0)return{ok:!1,error:"capture-asset-preview cannot combine a shotSet definition with a shots mode."};const X=uNt("capture-asset-preview",j);if(typeof X=="string")return{ok:!1,error:X};const G=fNt("capture-asset-preview",J);if(typeof G=="string")return{ok:!1,error:G};if((X||G)&&(S!==void 0||k!==void 0||N!==void 0||P==="scene"))return{ok:!1,error:'capture-asset-preview cannot combine camera/pose with a shots mode, a shotSet definition, compare, or stage "scene" — those legs stage their own cameras and poses.'};let ee;if(k!==void 0)try{ee=i$r(k)}catch(se){return{ok:!1,error:se instanceof Error?se.message:String(se)}}const xe=ame(w);if(S==="source"&&xe===null)return{ok:!1,error:"capture-asset-preview --shots source requires a non-degenerate forward [x,y,z]."};if(N!==void 0){if(S!==void 0||ee!==void 0)return{ok:!1,error:"capture-asset-preview cannot combine compare with shots."};if(typeof N!="object"||N===null||typeof N.glbBase64!="string"||N.forward!==void 0&&ame(N.forward)===null)return{ok:!1,error:"capture-asset-preview compare requires { glbBase64: string, forward?: [x, y, z] } with a non-degenerate ground-plane forward."}}if(typeof l=="string"){if(S!==void 0||N!==void 0)return{ok:!1,error:"capture-asset-preview cannot combine glbBase64 with a named shots mode or compare."};if(P==="scene")return{ok:!1,error:'capture-asset-preview stage "scene" photographs a live scene entity — glbBase64 bytes stand nowhere in the scene.'}}const ue=P==="scene"?t.scene:null;if(P==="scene"){if(typeof a!="string")return{ok:!1,error:'capture-asset-preview stage "scene" photographs a live scene entity — pass entityId, not assetPath.'};if(S!==void 0||ee!==void 0||N!==void 0)return{ok:!1,error:'capture-asset-preview cannot combine stage "scene" with a shots mode, a shotSet definition or compare.'};if(!ue)return{ok:!1,error:'capture-asset-preview stage "scene" requires a bound viewport scene; none is bound yet.'}}const fe=typeof a=="string"?dte(tO(t),t.objectMap,a):null;if(typeof a=="string"&&!fe)return{ok:!1,error:`Entity not found: ${a}`};try{const se={...typeof _=="number"?{width:_}:{},...typeof g=="number"?{height:g}:{},...b?{background:b}:{},...X?{camera:X}:{},...G?{pose:G}:{}};if(N!==void 0){const ge=N,qe=ame(ge.forward),tt={...typeof _=="number"?{width:_}:{},...typeof g=="number"?{height:g}:{},...qe?{refForward:qe}:{}};return{ok:!0,data:{...typeof i=="string"?await U$r(i,ge.glbBase64,tt):await rNt(fe,ge.glbBase64,tt)}}}return ee!==void 0?{ok:!0,data:{...typeof l=="string"?await F$r(l,ee,se):typeof i=="string"?await j$r(i,ee,se):qUe(fe,ee,se)}}:S==="source"?{ok:!0,data:{...typeof i=="string"?await M$r(i,xe,se):Y6t(fe,xe,se)}}:ue?{ok:!0,data:{...E$r(fe,ue,se)}}:typeof l=="string"?{ok:!0,data:{...await O$r(l,se)}}:{ok:!0,data:{...typeof i=="string"?await tNt(i,se):j0e(fe,se)}}}catch(se){return{ok:!1,error:se instanceof Error?se.message:String(se)}}}async function vbn(t,r,i){cqr(r.type);const a=EQe(r);if(a)return a;if(r.type==="play"||r.type==="restart"){const _=IZ();if(_.length>0)return{ok:!1,error:`this project's ${_.length===1?"root":"roots"} did not mount, so there is nothing to ${r.type==="play"?"play":"restart"}: `+_.map(g=>`"${g.worldId}" (${g.identity}) — ${g.message}`).join("; ")}}const l=await y3r(r.type);if(l)try{const _=await l.handle(r);return{ok:_.ok,..._.error!==void 0?{error:_.error}:{},..._.data!==void 0?{data:_.data}:{}}}catch(_){return OGt(r,_)}if(!Jye(r.type))return{ok:!1,error:`unknown command type "${r.type}" — not one of the editor's own, and no package this project declares contributes it (or the editor page predates this CLI)`,data:{code:"UNKNOWN_COMMAND_TYPE"}};const d=r.type;switch(d){case"session-prepare-close":return await iyn(),{ok:!0};case"select":{const _=r.id??null;if(_!==null){const g=EEt(t,_);if(g)return{ok:!1,error:g}}HRe(t,_?[_]:[],i);break}case"select-multiple":{const _=r.ids;for(const g of _){const b=EEt(t,g);if(b)return{ok:!1,error:b}}HRe(t,_,i);break}case"select-all":{HRe(t,z0e(t).map(_=>_.id),i);break}case"focus-entity":lw()?.frameIds([r.id])||t.focusOnEntity(r.id);break;case"frame-entity":{const _=r.id;if(typeof _!="string"||_.length===0)return{ok:!1,error:'frame-entity requires a string "id" (the entity to frame).'};const g=lw();if(g){if(!g.frameIds([_]))return{ok:!1,error:`Entity not found: ${_}`,data:{code:"ENTITY_NOT_FOUND"}};break}const b=tO(t);if(b.hierarchy.node(_)!==null&&b.rects){t.focusOnEntity(_);break}if(!dte(b,t.objectMap,_))return{ok:!1,error:`Entity not found: ${_}`,data:{code:"ENTITY_NOT_FOUND"}};t.focusOnEntity(_);break}case"focus-selection":lw()?.frameSelection()||t.focusOnSelection();break;case"view-preset":{const _=r.preset,g=["top","front","right","perspective"];if(typeof _!="string"||!g.includes(_))return{ok:!1,error:`view-preset requires one of ${g.join(", ")}, got ${_===void 0?"nothing":JSON.stringify(_)}.`};const b=_,S=lw();S?S.setViewPreset(b==="perspective"?"isometric":b):t.setViewPreset(b);break}case"set-camera":{const _=r.position,g=r.target,b=r.fov;if(!_||!g||typeof _.x!="number"||typeof _.y!="number"||typeof _.z!="number"||typeof g.x!="number"||typeof g.y!="number"||typeof g.z!="number")return{ok:!1,error:"set-camera requires numeric {x,y,z} position and target."};const S=lw();S?S.setCameraPose(_,g,b):t.setCameraPose(_,g,b);break}case"document-orbit":case"document-turntable":{const _=lw();if(!_)return{ok:!1,error:`${r.type} needs an Object3D document open and active (a model, a live module, an entity model). Open one with \`editor.openAsset(<path>)\` first.`,data:{code:"NO_ACTIVE_OBJECT3D_DOCUMENT"}};const g=r.type==="document-orbit"?r.duration:r.seconds;return g!==void 0&&(typeof g!="number"||!(g>=0&&g<=60))?{ok:!1,error:`${r.type}: the move's length must be a number of seconds in 0..60.`}:{ok:!0,data:{...r.type==="document-orbit"?await _.orbit({...typeof r.azimuth=="number"?{azimuth:r.azimuth}:{},...typeof r.elevation=="number"?{elevation:r.elevation}:{},...typeof g=="number"?{duration:g}:{}}):await _.turntable({...typeof g=="number"?{seconds:g}:{},...typeof r.revolutions=="number"?{revolutions:r.revolutions}:{}})}}}case"document-frame":{const _=lw();if(!_)return{ok:!1,error:"document-frame needs an Object3D document open and active. For the Scene viewport use `frame-entity`/`focus-selection`.",data:{code:"NO_ACTIVE_OBJECT3D_DOCUMENT"}};const g=r.fit;return g!==void 0&&(typeof g!="number"||!(g>=.1&&g<=10))?{ok:!1,error:'document-frame: "fit" must be a number in 0.1..10.'}:_.frame(typeof g=="number"?g:1)?{ok:!0,data:{..._.cameraPose()}}:{ok:!1,error:"Nothing to frame: the document subject has no measurable bounds.",data:{code:"EMPTY_FRAME_BOUNDS"}}}case"viewport-tab":{const _=r.tab,g={scene:"edit",game:"play"};if(typeof _=="string"&&g[_])return{ok:!1,error:`viewport-tab: "${_}" was REMOVED — the viewport tabs are Edit · Play. Fix: use "${g[_]}".`};if(_!=="edit"&&_!=="play")return{ok:!1,error:`viewport-tab requires "edit" or "play", got ${String(_)}.`};t.setActiveViewportTab(_);break}case"show-panel":try{const _=r.panel;return typeof _!="string"||_.trim()===""?{ok:!1,error:'show-panel requires a non-empty "panel".'}:{ok:!0,data:{panel:await eGt(_)}}}catch(_){return{ok:!1,error:_ instanceof Error?_.message:String(_)}}case"active-tab":{const _=r.key;if(_!=="__inspector__"&&!xb(_)){const g=FA().map(b=>b.descriptor.id);return{ok:!1,error:`No open workspace document with id "${_}" — nothing was activated. `+(g.length>0?`Open documents: ${g.join(", ")}.`:"No documents are open in this workspace.")}}break}case"select-asset":{const _=r.path;if(typeof _!="string"||_.trim()==="")return{ok:!1,error:'select-asset requires a non-empty "path".'};const g=_.replace(/^\/+/,""),b=g.split("/").pop()??g,S=wg(b);YN({path:_,name:b,kind:Bq(S)??"unknown",capabilities:S,origin:"project"});break}case"open-asset-tab":{const _=r.kind,g=f8(t,r.path,_);if(!await DNt(g,_))return{ok:!1,error:`Asset document did not finish mounting its Inspector: ${g}`};break}case"close-asset-tab":{const _=r.key;INt(_)&&Y8(_);break}case"toggle-command-palette":FQe();break;case"toggle-console":obe();break;case"page-reload":return setTimeout(()=>{window.location.reload()},0),{ok:!0,data:{scheduled:!0}};case"set-workspace":{const _=r.workspace;if(!SZ(_))return{ok:!1,error:`set-workspace requires one of ${Yze().join(", ")}, got ${String(_)}.`};if(wS()===_)return{ok:!0,data:{workspace:_,applied:!0}};const g=vPt().then(()=>!0);CS(_);const b=await Promise.race([g,new Promise(S=>setTimeout(()=>S(!1),3e3))]);return{ok:!0,data:{workspace:_,applied:b}}}case"set-style":{const _=r.style,g=lU().map(S=>S.id);if(typeof _!="string"||!g.includes(_))return{ok:!1,error:`set-style requires one of ${g.join(", ")}, got ${String(_)}.`};nUe(_);const b=Bhe();return b!==_?{ok:!1,error:`set-style applied "${_}" but the editor is wearing ${b===null?"a custom mix of axes":`"${b}"`}.`,data:{style:b}}:{ok:!0,data:{style:_}}}case"set-appearance":{const _=r.material;return _===void 0?{ok:!1,error:"set-appearance needs a `material` to set."}:i0e(_)?(CPt(_),{ok:!0,data:{material:fz(),style:Bhe()}}):{ok:!1,error:`set-appearance material must be one of ${A5r().map(b=>b.id).join(", ")}, got ${String(_)}.`}}case"present-view":try{return{ok:!0,data:{...await bye(t,r.view)}}}catch(_){return{ok:!1,error:_ instanceof Error?_.message:String(_)}}case"current-view":return{ok:!0,data:{view:ute(t)}};case"inspect":return{ok:!0,data:{subject:sbe(t)}};case"run-inspection-action":try{const _=r.actionId;if(typeof _!="string"||_.trim()==="")throw new Error("run-inspection-action requires a non-empty actionId.");return{ok:!0,data:{subject:await G1n(t,_)}}}catch(_){return{ok:!1,error:_ instanceof Error?_.message:String(_)}}case"run-command":try{const _=r.commandId;if(typeof _!="string"||_.trim()==="")throw new Error("run-command requires a non-empty commandId.");const g=await e0n(_,r.args);return{ok:!0,data:{result:g===void 0?null:g}}}catch(_){return{ok:!1,error:_ instanceof Error?_.message:String(_)}}case"hierarchy":{const _=HCt();return _===null?{ok:!1,error:"the hierarchy panel (GameHierarchy) is not mounted — no row tree is rendered, so there is nothing to report. Open the Hierarchy panel in the workspace dock and retry."}:{ok:!0,data:{hierarchy:Zgn(_,{playState:t.playState,activeViewportTab:t.activeViewportTab})}}}case"expand-hierarchy-all":case"collapse-hierarchy-all":{const _=r.type==="expand-hierarchy-all",g=HCt();if(g===null)return{ok:!1,error:`the hierarchy panel (GameHierarchy) is not mounted — no row tree is rendered, so there is nothing to ${_?"expand":"collapse"}. Open the Hierarchy panel in the workspace dock and retry.`};const b=Ygn();_?g.expandAll():g.collapseAll();try{await b}catch(S){return{ok:!1,error:S instanceof Error?S.message:String(S)}}return{ok:!0,data:{}}}case"undo":case"redo":{const _=i?.history;if(!_)return{ok:!1,error:`${String(r.type)}: this editor has no history session attached, so there is nothing to undo.`};const g=r.type==="undo"?await _.undo():await _.redo(),b=_.getSnapshot();return{ok:!0,data:{moved:g,canUndo:b.canUndo,canRedo:b.canRedo,undoLabel:b.undoLabel,redoLabel:b.redoLabel}}}case"set-inspection-field":try{const _=r.path;if(typeof _!="string"||_.trim()==="")throw new Error("set-inspection-field requires a non-empty field path.");const g=await K1n(t,_,r.value);return{ok:!0,data:{subject:g.subject,write:g.write}}}catch(_){return{ok:!1,error:_ instanceof Error?_.message:String(_)}}case"remove-inspection-field":try{const _=r.path;if(typeof _!="string"||_.trim()==="")throw new Error("remove-inspection-field requires a non-empty field path.");const g=await Y1n(t,_);return{ok:!0,data:{subject:g.subject,write:g.write}}}catch(_){return _ instanceof aqe?{ok:!1,error:_.message,data:{code:"REMOVAL_UNAVAILABLE"}}:{ok:!1,error:_ instanceof Error?_.message:String(_)}}case"structure-op":try{const _=String(r.op??""),g=wm(t).adapter,b=VUe(t),S=Array.isArray(r.ids)?r.ids.filter(j=>typeof j=="string"):typeof r.id=="string"&&r.id.trim()!==""?[r.id]:b,k=S[0],w=()=>{if(!k)throw new Error(`structure-op "${_}" needs an id or a selected row.`);return k},N=j=>typeof r[j]=="string"&&r[j].trim()!==""?r[j]:void 0,P=g.structure;if(!P)return{ok:!1,error:"structure-op: the active authoring adapter exposes no structure provider."};switch(_){case"create":{const j=N("kind");if(!j)return{ok:!1,error:'structure-op "create" needs a `kind`.'};const J=A0e(g,j,N("parentId"));return{ok:!0,data:{id:J.id,write:await J.ack}}}case"delete":return{ok:!0,data:{write:S.length>1&&P.removeMany?await _Ue(g,S):await Uhe(g,w())}};case"duplicate":{if(S.length>1&&P.duplicateMany)return{ok:!0,data:{write:await o4t(g,S)}};const j=S0e(g,w());return{ok:!0,data:{id:j.id,write:await j.ack}}}case"reparent":{const j=N("parentId")??null;return{ok:!0,data:{write:await NR(g,w(),j)}}}case"reorder":{if(!P.reorder)return{ok:!1,error:"structure-op: this adapter has no `reorder`."};const j=N("beforeSiblingId")??null;return{ok:!0,data:{write:await mUe(g,w(),j)}}}case"wrap":return P.wrap?{ok:!0,data:{write:await x0e(g,w(),N("tag"))}}:{ok:!1,error:"structure-op: this adapter has no `wrap`."};case"unwrap":return P.unwrap?{ok:!0,data:{write:await w0e(g,w())}}:{ok:!1,error:"structure-op: this adapter has no `unwrap`."};case"group":{if(!P.group)return{ok:!1,error:"structure-op: this adapter has no `group`."};const j=C0e(g,S);return{ok:!0,data:{id:j.id,write:await j.ack}}}case"ungroup":{if(!P.ungroup)return{ok:!1,error:"structure-op: this adapter has no `ungroup`."};const j=hUe(g,w());return{ok:!0,data:{ids:j.ids,write:await j.ack}}}case"copy":return P.copy?{ok:!0,data:{copied:await E0e(g,S)}}:{ok:!1,error:"structure-op: this adapter has no `copy`."};case"cut":{if(!P.cut)return{ok:!1,error:"structure-op: this adapter has no `cut`."};const j=await T0e(g,S);return j===!1?{ok:!1,error:'structure-op "cut" was refused by the adapter.'}:{ok:!0,data:{write:j}}}case"paste":{if(!P.paste)return{ok:!1,error:"structure-op: this adapter has no `paste`."};const j=N("parentId")??(k?g.hierarchy.node(k)?.parentId??null:null),J=await k0e(g,j);return J===!1?{ok:!1,error:'structure-op "paste" was refused by the adapter.'}:{ok:!0,data:{write:J}}}default:return{ok:!1,error:`structure-op: unknown op ${JSON.stringify(_)}. Known ops: create, delete, duplicate, reparent, reorder, wrap, unwrap, group, ungroup, copy, cut, paste.`}}}catch(_){return{ok:!1,error:_ instanceof Error?_.message:String(_)}}case"document-probe":try{return{ok:!0,data:{...await y0n(r.step)}}}catch(_){return{ok:!1,error:_ instanceof Error?_.message:String(_)}}case"capture-active-document":{const _=kEt(r);if("error"in _)return{ok:!1,error:_.error};try{return r.view&&await bye(t,r.view),{ok:!0,data:{...await F0n(t,_.size)}}}catch(g){return{ok:!1,error:g instanceof Error?g.message:String(g)}}}case"capture-editor-chrome":{const _=r.scale;if(_!==void 0&&(typeof _!="number"||!(_>0)||_>4))return{ok:!1,error:`capture-editor-chrome: "scale" must be a number greater than 0 and no more than 4 (output pixels per CSS pixel; the frame crosses the relay as base64 PNG). It defaults to the page's own devicePixelRatio.`};try{return{ok:!0,data:{...await Wgn(t,_===void 0?void 0:{scale:_})}}}catch(g){return{ok:!1,error:g instanceof Error?g.message:String(g)}}}case"capture-viewport":{const _=kEt(r);if("error"in _)return{ok:!1,error:_.error};const g=t.captureViewportImage(_.size);if(!g)return{ok:!1,error:"This door photographs the editor's own three.js Scene viewport, and nothing has bound one (no renderer/scene/camera). A canvas-surface world (a first-party canvas root, or a PixiJS/Phaser/Babylon ingest) never binds it — it draws on its own canvas in the Game document. Capture that through `capture-active-document` (`editor.captureActiveDocument()`) or the running game through `bridge-screenshot` (`vgai screenshot`)."};const b=g.indexOf(",");return{ok:!0,data:{base64:b>=0?g.slice(b+1):g,mimeType:"image/png"}}}case"capture-asset-preview":return ybn(t,r);case"document-table":{const _=v1();return _?{ok:!0,data:{default:_.scenes.default??null,entries:_.scenes.entries,pending:_.documentsPending===!0}}:{ok:!1,error:"The project adapter has not resolved yet — no document table to list.",data:{code:"SCENE_TABLE_UNAVAILABLE"}}}case"open":{const _=r.id;if(typeof _!="string"||_.trim()==="")return{ok:!1,error:"open requires a non-empty scene-table entry id."};const g=rbe(),b=g?v1()?.scenes.entries.find(N=>N.id===_):void 0,S=g?async N=>await MHt(N)??{ok:!1,error:"No running lane can remount with a selection."}:void 0,w=(b?await tbn(b,{scenes:TQe,activateGameDocument:()=>xb(Sw),gameDocumentId:Sw,...S?{remountSelection:S}:{}}):null)??await ihn(t,_);return w.ok?{ok:!0,data:{documentId:w.documentId,title:w.title,..."scene"in w&&w.scene?{scene:w.scene}:{},..."restart"in w&&w.restart?{restart:!0}:{}}}:{ok:!1,error:w.error,data:{code:w.code,...w.known===void 0?{}:{known:[...w.known]}}}}case"set-grid":{const _=lw();_?_.setGrid(r.enabled):t.showGrid!==r.enabled&&t.toggleGrid();break}case"set-helpers":{const _=bP(t);_.showHelpers!==r.enabled&&_.toggleHelpers();break}case"set-stats":{const _=bP(t);_.showStats!==r.enabled&&_.toggleStats();break}case"set-shading-mode":lw()?lw()?.setMode(r.mode):t.setShadingMode(r.mode);break;case"set-helper-type":{const _=bP(t),g=r.helperType,b=lw();if(b&&g==="bounds"){b.setBounds(r.enabled);break}if(b&&g==="skeletons"){b.setSkeleton(r.enabled);break}_.helperVisibility[g]!==r.enabled&&_.toggleHelperType(g);break}case"set-transform-mode":t.setTransformMode(r.mode);break;case"set-transform-space":t.setTransformSpace(r.space);break;case"set-snap":t.snapEnabled!==r.enabled&&t.toggleSnap();break;case"document-script":return gbn(r);default:return{ok:!1,error:`unknown command type "${String(d)}" — editor page predates this CLI`,data:{code:"UNKNOWN_COMMAND_TYPE"}}}return{ok:!0}}function bbn(t,r){const i=VP();let a=null,l=-1;const d=new Set;let _=!1,g=null,b=null,S=null;const k=()=>{Jpe()===null&&(a=TEt(t),l=t.contentVersion,W2t(a))};let w=null;const N=()=>{g!==null&&(clearTimeout(g),g=null),w?.(),w=null},P=()=>{b=null,S!==null&&clearTimeout(S),S=null},j=()=>{P(),_=!0,N(),g=setTimeout(()=>{g=null,w=KCt(()=>{w=null,_=!1,k()})},250)},J=cr=>{if(t.contentVersion!==cr){j();return}P(),b=cr,S=setTimeout(P,1e3)},X=()=>rbe()&&t.playState==="playing",G=cr=>{(cr!==null||b!==null&&t.contentVersion!==b||_&&t.contentVersion!==l)&&j()},ee=(cr,Yt,Lr)=>X()?(cbn(Lr,cr,t.contentVersion,l)&&(cr==="explicit"?j():cr==="if-content-changed"?J(Yt??t.contentVersion):G(Yt)),!0):!1,xe=(cr="always",Yt="none",Lr=null)=>{if(Jpe()!==null)return;if(a===null){k();return}const nn=TEt(t,a);a=nn,W2t(dbn(nn)),cr!=="none"&&(ee(Yt,Lr,cr)||(N(),P(),_=!1,!(cr==="if-content-changed"&&t.contentVersion===l)&&w===null&&(w=KCt(()=>{w=null,k()}))))};let ue=!1,fe=!1,se=t.playState;const de=cr=>{cr&&(fe=!0),!ue&&(ue=!0,queueMicrotask(()=>{ue=!1;const Yt=fe;fe=!1;const Lr=se!==t.playState;se=t.playState,xe(Yt?"always":"if-content-changed",Lr&&t.playState==="playing"?"explicit":"none")}))},ge=()=>de(!1),qe=()=>de(!0),tt=t.subscribe(ge),Ct=NQe(qe),Ot=YP(qe),vt=YOr(qe);k(),Wpe(!0),YFr(azr),i.addEventListener("open",()=>{xe("if-content-changed"),Wpe(Jpe()===null)});const Et=HUe(cr=>{Wpe(cr===null)});i.addEventListener("editor-command",cr=>{try{const Yt=JSON.parse(cr.data),Lr=Yt._requestId,nn=t.contentVersion,on=Jpe();if(on!==null){const An=Aqr(on,String(Yt.type));Lr&&H2t(Lr,!1,An);return}Lr&&ozr(Lr);let gr;vbn(t,Yt,{deferPresentation:An=>{gr=An},...r?{history:r}:{}}).catch(An=>OGt(Yt,An)).then(An=>{if(Lr){const ln=H2t(Lr,An.ok,An.error,An.data,gr!==void 0);if(gr){const Mn=()=>window.setTimeout(gr,0);ln.then(Mn,Mn)}}else gr&&window.setTimeout(gr,0);const Rn=abn(Yt,An.ok,d);xe(Rn.derived,Rn.playFullReport,nn)})}catch{}}),i.addEventListener("project-changed",()=>{window.location.reload()});const Tt=()=>xe();document.addEventListener("visibilitychange",Tt),window.addEventListener("focus",Tt),window.addEventListener("blur",Tt);const Le=()=>setTimeout(Tt,0);return window.addEventListener("error",Le),window.addEventListener("unhandledrejection",Le),()=>{Wpe(!1),w?.(),w=null,g!==null&&clearTimeout(g),g=null,P(),Et(),tt(),Ct(),Ot(),vt(),document.removeEventListener("visibilitychange",Tt),window.removeEventListener("focus",Tt),window.removeEventListener("blur",Tt),window.removeEventListener("error",Le),window.removeEventListener("unhandledrejection",Le),i.close()}}function Abn(t,r,i){return Xe.createContext(i)}const XP=Abn(void 0,"EditorContext",null);function Sbn({runtime:t,children:r}){const i=Xe.useMemo(()=>({begin:()=>{},end:()=>{}}),[]);return z.jsx(XP.Provider,{value:t,children:z.jsx(y3t.Provider,{value:i,children:z.jsx(Xe.Suspense,{children:r})})})}function D0(){const t=Xe.useContext(XP);if(!t)throw new Error("useEditorStore must be used within <EditorProvider>");return t.store}function o4n(){const t=Xe.useContext(XP);if(!t)throw new Error("useEditorStats must be used within <EditorProvider>");return t.stats}function xbn(){const t=Xe.useContext(XP);if(!t)throw new Error("useEditorInit must be used within <EditorProvider>");return t.initPromise}function FGt(){const t=Xe.useContext(XP);if(!t)throw new Error("useHistoryService must be used within <EditorProvider>");return t.session.history}function wbn(){return Xe.useContext(XP)?.session.history??null}function a4n(){return Xe.useContext(XP)?.store??null}function c4n(){return Xe.useContext(XP)?.stats??null}function cbe(){const t=Xe.useContext(XP);if(!t)throw new Error("useHistoryCommands must be used within <EditorProvider>");return t.session.historyCommands}function RGt(){const t=cbe();return Xe.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getSnapshot)}class Cbn{constructor(){this.isPass=!0,this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1}setSize(){}render(){console.error("THREE.Pass: .render() must be implemented in derived pass.")}dispose(){}}const Ebn=new $ye(-1,1,1,-1,0,1);class Tbn extends Kqe{constructor(){super(),this.setAttribute("position",new U1t([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new U1t([0,2,0,0,2,0],2))}}const kbn=new Tbn;class Ibn{constructor(r){this._mesh=new NA(kbn,r)}dispose(){this._mesh.geometry.dispose()}render(r){r.render(this._mesh,Ebn)}get material(){return this._mesh.material}set material(r){this._mesh.material=r}}const A_e={name:"OutputShader",uniforms:{tDiffuse:{value:null},toneMappingExposure:{value:1}},vertexShader:`
|
|
1604
1604
|
precision highp float;
|
|
1605
1605
|
|
|
1606
1606
|
uniform mat4 modelViewMatrix;
|
|
@@ -1678,9 +1678,9 @@ uniform bool unassociateAlpha;`).replace("gl_FragColor = texture2D( tDiffuse, vU
|
|
|
1678
1678
|
}`)),NEt.value=t,W$}function Nbn(t,r=qHt){if(t.isLOD)return t;const i=[...t.children];for(;i.length>0;){const a=i.pop();if(!r(a)){if(a.isLOD)return a;i.push(...a.children)}}return null}const Obn=1e20,Fbn=2e20;function Rbn(t,r){const i=t.fog;if(!i){r();return}const a=i.isFog?i:null,l=i.isFogExp2?i:null,d=a?.near,_=a?.far,g=l?.density;a&&(a.near=Obn,a.far=Fbn),l&&(l.density=0);try{r()}finally{a&&d!==void 0&&_!==void 0&&(a.near=d,a.far=_),l&&g!==void 0&&(l.density=g)}}const Mbn=256;function Lbn(t,r){return t==="selection"&&r==="selection"?"selection":"content"}class Eq{_scene=null;_adoptionStack=[];_objectMap=new Map;_renderer=null;_camera=null;_batchedRenderer=null;_lastThumbnailTime=0;_lastEditorStateSaveTime=0;_orbitTarget=null;_viewportSelections={edit:new Set,play:new Set};_transformMode="combined";_transformSpace="world";_snapEnabled=!1;_snapValues={translate:1,rotate:15,scale:.25};_snapToSurface=!1;_preserveChildrenTransform=!1;_pivotMode="active-element";_gizmoAnchor="auto";_showGrid=!0;_showHelpers=!0;_helperVisibility={bounds:!1,lights:!0,cameras:!0,colliders:!0,joints:!0,particles:!0,lod:!0,audio:!0,splines:!0,navmesh:!0,constraints:!0,reflectionProbes:!0,triggerVolumes:!0,skeletons:!1,weights:!1};_gizmoEpoch=0;_objectMapParentChangedAt=new Map;_objectMapFullChangeEpoch=0;_objectMapMembershipChangedAt=new Map;_objectMapMembershipFullChangeEpoch=0;_objectMapMembershipHistoryFloor=0;_showStats=!1;_shadingMode="solid";_history=null;_statePersistence=null;_playState="stopped";_playEditRegime=null;_activeViewportTab="edit";_vertexSnapActive=!1;_listeners=new Set;_viewportActionListeners=new Set;_deferredNotifyTimer=null;_deferredNotifyScope="content";_version=0;_shellVersion=0;_composerVersion=0;_contentVersion=0;_hierarchyRowFacetVersion=0;bindScene(r,i,a,l){this._scene=r,this._renderer=i??null,this._batchedRenderer=a??null,l&&(this._camera=l)}setOrbitTarget(r){this._orbitTarget=r}setViewportCamera(r){this._camera=r}subscribe=r=>(this._listeners.add(r),()=>this._listeners.delete(r));getSnapshot=()=>this._version;getShellSnapshot=()=>this._shellVersion;get contentVersion(){return this._contentVersion}get hierarchyRowFacetVersion(){return this._hierarchyRowFacetVersion}get projectHistory(){return this._history}_notify(r="content",i="shell",a=r!=="selection"){this._deferredNotifyTimer!==null&&(clearTimeout(this._deferredNotifyTimer),this._deferredNotifyTimer=null),this._beforeNotify(),this._version++,i==="shell"&&this._shellVersion++,r!=="selection"&&this._contentVersion++,a&&this._hierarchyRowFacetVersion++;for(const l of this._listeners)l()}_notifyDeferred(r="content"){if(this._deferredNotifyTimer!==null){this._deferredNotifyScope=Lbn(this._deferredNotifyScope,r);return}this._deferredNotifyScope=r,this._deferredNotifyTimer=setTimeout(()=>{this._deferredNotifyTimer=null;const i=this._deferredNotifyScope;this._deferredNotifyScope="content",this._notify(i)},0)}attachHistory(r){if(this._history!==r){if(this._history)throw new Error("EditorStore is already attached to project history.");this._history=r,this._onHistoryAttached()}}attachStatePersistence(r){if(this._statePersistence!==r){if(this._statePersistence)throw new Error("EditorStore is already attached to a state persistence.");this._statePersistence=r}}onViewportAction=r=>(this._viewportActionListeners.add(r),()=>this._viewportActionListeners.delete(r));_emitViewportAction(r){for(const i of this._viewportActionListeners)i(r)}focusOnEntity(r){this._emitViewportAction({type:"focus-entity",id:r})}focusOnSelection(){this._emitViewportAction({type:"focus-selection"})}focusOnScene(r){this._emitViewportAction({type:"focus-scene",...r?{gameCamera:r}:{}})}setViewPreset(r){this._emitViewportAction({type:"set-view-preset",preset:r})}setCameraPose(r,i,a){this._emitViewportAction({type:"set-camera-pose",position:r,target:i,...a!==void 0?{fov:a}:{}})}get cameraPose(){if(!this._camera)return null;const r=this._camera.fov;return{position:this._camera.position.clone(),target:this._orbitTarget?this._orbitTarget.clone():new Tc,fov:typeof r=="number"?r:0}}get objectMap(){return this._objectMap}get scene(){return this._scene}get composerVersion(){return this._composerVersion}get selectedEntityId(){const r=this._viewportSelections[this._activeViewportTab];return r.size===0?null:[...r].at(-1)}get selectedEntityIds(){return this._viewportSelections[this._activeViewportTab]}get transformMode(){return this._transformMode}get transformSpace(){return this._transformSpace}get snapEnabled(){return this._snapEnabled}get snapValues(){return this._snapValues}get snapToSurface(){return this._snapToSurface}get preserveChildrenTransform(){return this._preserveChildrenTransform}get pivotMode(){return this._pivotMode}get gizmoAnchor(){return this._gizmoAnchor}get canUndo(){return this._history?.getSnapshot().canUndo??!1}get canRedo(){return this._history?.getSnapshot().canRedo??!1}get showGrid(){return this._showGrid}get showHelpers(){return this._showHelpers}get helperVisibility(){return this._helperVisibility}get gizmoEpoch(){return this._gizmoEpoch}ingestObjectMapChangesSince(r){if(r<0||r>this._gizmoEpoch||r<this._objectMapFullChangeEpoch)return null;const i=new Set;for(const[a,l]of this._objectMapParentChangedAt)l>r&&i.add(a);return{epoch:this._gizmoEpoch,changedParentIds:i}}ingestObjectMapMembershipChangesSince(r){if(r<0||r>this._gizmoEpoch||r<this._objectMapMembershipFullChangeEpoch||r<this._objectMapMembershipHistoryFloor)return null;const i=new Set;for(const[a,l]of this._objectMapMembershipChangedAt)l>r&&i.add(a);return{epoch:this._gizmoEpoch,changedIds:i}}isSkeletonVisible(r){return!!CE(this._objectMap.get(r),"skeletonVisible")}setSkeletonVisible(r,i){const a=this._objectMap.get(r);a&&(CZ(a,"skeletonVisible",i),a.traverse(l=>{CE(l,"editorHelperType")==="skeletons"&&(CZ(l,"skeletonEnabled",i),l.visible=i||this._helperVisibility.skeletons)}),this._notify())}get showStats(){return this._showStats}get shadingMode(){return this._shadingMode}notifyIngestEdit(){this._notify()}notifyIngestObjectMapEdit(r){if(this._gizmoEpoch++,r===void 0||r.rootsChanged)this._objectMapFullChangeEpoch=this._gizmoEpoch,this._objectMapParentChangedAt.clear();else for(const a of r.changedParentIds)this._objectMapParentChangedAt.set(a,this._gizmoEpoch);if(r?.addedIds===void 0||r.removedIds===void 0)this._objectMapMembershipFullChangeEpoch=this._gizmoEpoch,this._objectMapMembershipChangedAt.clear();else{for(const l of r.addedIds)this._objectMapMembershipChangedAt.set(l,this._gizmoEpoch);for(const l of r.removedIds)this._objectMapMembershipChangedAt.set(l,this._gizmoEpoch);const a=Math.max(0,this._gizmoEpoch-Mbn);if(a>this._objectMapMembershipHistoryFloor){this._objectMapMembershipHistoryFloor=a;for(const[l,d]of this._objectMapMembershipChangedAt)d<=a&&this._objectMapMembershipChangedAt.delete(l)}}const i=r===void 0||r.rootsChanged||[...r.addedIds??[],...r.removedIds??[]].some(a=>this.selectedEntityIds.has(a));this._notify("content",i?"shell":"object-map",!1)}_ecsSyncTransform=null;setEcsSyncTransform(r){this._ecsSyncTransform=r}enterPlayScene(r,i,a){if(!this._scene)return;this._adoptionStack.push({scene:this._scene,objectMap:this._objectMap,extras:this._captureAdoptionExtras(),selection:new Set(this.selectedEntityIds),imageConfig:this._adoptedImageConfig}),this._scene=r,this._applyAdoptedImageConfig(i);const l=a?new Map(a):(()=>{const d=new Map,_=g=>{if(OUe(g))return;const b=$Ht(g);b!==void 0&&d.set(b,g);for(const S of g.children)_(S)};for(const g of r.children)_(g);return d})();this._objectMap=l,this._viewportSelections[this._activeViewportTab]=new Set([...this.selectedEntityIds].filter(d=>l.has(d))),this._lodForcedLevels.clear(),this._composerVersion++,this._notify()}exitPlayScene(){const r=this._adoptionStack.pop();r&&(this._scene=r.scene,this._objectMap=r.objectMap,this._applyAdoptedImageConfig(r.imageConfig),this._restoreAdoptionExtras(r.extras),this._viewportSelections[this._activeViewportTab]=new Set(r.selection),this._composerVersion++,this._notify())}releaseAdoptedScene(r){if(this._scene===r){this.exitPlayScene();return}const i=this._adoptionStack.findIndex(a=>a.scene===r);i!==-1&&this._adoptionStack.splice(i,1)}_adoptedImageConfig;get adoptedImageConfig(){return this._adoptedImageConfig}_applyAdoptedImageConfig(r){r!==this._adoptedImageConfig&&(this._adoptedImageConfig=r,this._composerVersion++)}get isAdoptedSceneActive(){return this._adoptionStack.length>0}get playState(){return this._playState}_blockedDuringPlay(r){return this._playState==="stopped"?!1:(console.warn(`EditorStore: "${r}" is disabled during play mode — stop the game first.`),!0)}setPlayState(r){const i=this._playState!=="stopped";this._playState=r,r==="playing"&&this._activeViewportTab==="edit"&&(this._activeViewportTab="play"),r==="stopped"&&(this._activeViewportTab="edit",i&&this._onPlayStopped()),this._notify()}get playEditRegime(){return this._playEditRegime}setPlayEditRegime(r){this._playEditRegime=r,this._notify()}get activeViewportTab(){return this._activeViewportTab}setActiveViewportTab(r){r!==this._activeViewportTab&&(this._activeViewportTab=r,this._notify())}get vertexSnapActive(){return this._vertexSnapActive}setVertexSnapActive(r){this._vertexSnapActive=r,this._notify()}select(r,i="immediate"){const a=this._viewportSelections[this._activeViewportTab];a.clear(),r&&a.add(r),i==="deferred"?this._notifyDeferred("selection"):this._notify("selection")}selectMultiple(r,i="immediate"){this._viewportSelections[this._activeViewportTab]=new Set(r),i==="deferred"?this._notifyDeferred("selection"):this._notify("selection")}applySelectionBeforePresentation(r){this._viewportSelections[this._activeViewportTab]=new Set(r);let i=!1;return()=>{i||(i=!0,this._notify("selection"))}}addToSelection(r){this._viewportSelections[this._activeViewportTab].add(r),this._notify("selection")}toggleSelection(r){const i=this._viewportSelections[this._activeViewportTab];i.has(r)?i.delete(r):i.add(r),this._notify("selection")}static THUMBNAIL_INTERVAL_MS=6e4;static THUMBNAIL_SIZE=256;_renderViewportImage(r,i){if(!this._renderer||!this._scene||!this._camera)return null;const a=typeof r=="number"?r:r.width,l=typeof r=="number"?r:r.height;if(!Number.isFinite(a)||a<1||!Number.isFinite(l)||l<1)return null;const d=a*2,_=l*2,g=this._renderer,b=new V1t(d,_,{type:QN}),S=new V1t(d,_),k=g.getRenderTarget(),w=g.getPixelRatio(),N=this._camera,P=N.layers.mask,j=N instanceof Bye?N:null,J=j?.aspect;i?N.layers.enableAll():(N.layers.disableAll(),N.layers.enable(0));try{j&&(j.aspect=a/l,j.updateProjectionMatrix()),g.setPixelRatio(1),g.setRenderTarget(b),Rbn(this._scene,()=>g.render(this._scene,N)),Pbn().render(g,S,b,0,!1)}finally{g.setRenderTarget(k),g.setPixelRatio(w),N.layers.mask=P,j&&J!==void 0&&(j.aspect=J,j.updateProjectionMatrix())}const X=d*4,G=new Uint8Array(X*_);g.readRenderTargetPixels(S,0,0,d,_,G),S.dispose(),b.dispose();const ee=document.createElement("canvas");ee.width=d,ee.height=_;const xe=ee.getContext("2d"),ue=xe.createImageData(d,_);for(let de=0;de<_;de++){const ge=(_-1-de)*X,qe=de*X;ue.data.set(G.subarray(ge,ge+X),qe)}xe.putImageData(ue,0,0);const fe=document.createElement("canvas");return fe.width=a,fe.height=l,fe.getContext("2d").drawImage(ee,0,0,a,l),fe.toDataURL("image/png")}_captureThumbnail(){const r=Date.now();if(r-this._lastThumbnailTime<Eq.THUMBNAIL_INTERVAL_MS)return;this._lastThumbnailTime=r;const i=this._renderViewportImage(Eq.THUMBNAIL_SIZE,!1);i&&this._statePersistence?.saveThumbnail?.(i)}captureViewportImage(r=Eq.THUMBNAIL_SIZE){return this._renderViewportImage(r,!0)}viewportCanvas(){return this._renderer?.domElement??null}static EDITOR_STATE_INTERVAL_MS=6e4;_saveEditorStateIfDue(){if(!this._statePersistence)return;const r=Date.now();if(r-this._lastEditorStateSaveTime<Eq.EDITOR_STATE_INTERVAL_MS)return;this._lastEditorStateSaveTime=r;const i={transformMode:this._transformMode,transformSpace:this._transformSpace,snapEnabled:this._snapEnabled,snapValues:this._snapValues,preserveChildrenTransform:this._preserveChildrenTransform,pivotMode:this._pivotMode,gizmoAnchor:this._gizmoAnchor,showGrid:this._showGrid,showHelpers:this._showHelpers,helperVisibility:{...this._helperVisibility},showStats:this._showStats,shadingMode:this._shadingMode};if(Object.assign(i,this._editorStateExtras()),this._camera){const a=this._camera;i.camera={position:a.position.toArray(),target:this._orbitTarget?this._orbitTarget.toArray():[0,0,0]}}this._statePersistence.save(i)}_lodForcedLevels=new Map;get lodForcedLevels(){return this._lodForcedLevels}getLodForcedLevel(r){return this._lodForcedLevels.get(r)??null}setLodForcedLevel(r,i){if(i===null){this._lodForcedLevels.delete(r);const a=this._objectMap.get(r),l=new Set(this._objectMap.values()),d=a?Nbn(a,_=>l.has(_)):null;d&&(d.autoUpdate=!0)}else this._lodForcedLevels.set(r,i);this._notify()}setTransformMode(r){this._transformMode=r,this._notify()}setTransformSpace(r){this._transformSpace=r,this._notify()}toggleSnap(){this._snapEnabled=!this._snapEnabled,this._notify()}setSnapValues(r){this._snapValues={...this._snapValues,...r},this._notify()}toggleSnapToSurface(){this._snapToSurface=!this._snapToSurface,this._notify()}togglePreserveChildrenTransform(){this._preserveChildrenTransform=!this._preserveChildrenTransform,this._notify()}snapSelectionToFloor(){this._emitViewportAction({type:"snap-selection-to-floor"})}setPivotMode(r){this._pivotMode=r,this._notify()}setGizmoAnchor(r){this._gizmoAnchor=r,this._notify()}toggleGrid(){this._showGrid=!this._showGrid,this._notify()}toggleHelpers(){this._showHelpers=!this._showHelpers,this._notify()}toggleHelperType(r){this._helperVisibility[r]=!this._helperVisibility[r],this._helperVisibility[r]&&(this._showHelpers=!0),this._notify()}toggleStats(){this._showStats=!this._showStats,this._notify()}setShadingMode(r){this._shadingMode=r,this._notify()}_beforeNotify(){}_onHistoryAttached(){}_captureAdoptionExtras(){}_restoreAdoptionExtras(r){}_onPlayStopped(){}_editorStateExtras(){return{}}}class jbn{constructor(r){this.history=r,this.snapshot=this.buildSnapshot(),this.unsubscribeHistory=r.subscribe(this.notify)}tail=Promise.resolve();listeners=new Set;pending=0;version=0;disposed=!1;idleWaiters=new Set;unsubscribeHistory;snapshot;subscribe=r=>this.disposed?()=>{}:(this.listeners.add(r),()=>this.listeners.delete(r));getSnapshot=()=>this.snapshot;undo(){return this.enqueue(async()=>(await this.waitForServiceIdle(),this.assertNotDisposed(),this.history.undo()))}redo(){return this.enqueue(async()=>(await this.waitForServiceIdle(),this.assertNotDisposed(),this.history.redo()))}jumpTo(r){return this.enqueue(async()=>(await this.waitForServiceIdle(),this.assertNotDisposed(),this.history.jumpTo(r)))}get canUndo(){return this.snapshot.canUndo}get canRedo(){return this.snapshot.canRedo}dispose(){if(this.disposed)return;this.disposed=!0,this.unsubscribeHistory();const r=new Error("History commands are disposed.");for(const i of this.idleWaiters)i.unsubscribe(),i.reject(r);this.idleWaiters.clear(),this.listeners.clear(),this.notify()}enqueue(r){if(this.disposed)return Promise.reject(new Error("History commands are disposed."));this.pending++,this.notify();const i=()=>{if(this.disposed)throw new Error("History commands are disposed.");return r()},a=this.tail.then(i,i);return this.tail=a.then(()=>{},()=>{}),a.finally(()=>{this.pending--,this.notify()})}assertNotDisposed(){if(this.disposed)throw new Error("History commands are disposed.")}waitForServiceIdle(){return this.disposed?Promise.reject(new Error("History commands are disposed.")):this.history.getSnapshot().busy?new Promise((r,i)=>{const a={unsubscribe:()=>{},reject:i},l=()=>{a.unsubscribe(),this.idleWaiters.delete(a)};a.unsubscribe=this.history.subscribe(()=>{this.history.getSnapshot().busy||(l(),r())}),this.idleWaiters.add(a)}):Promise.resolve()}notify=()=>{this.version++,this.snapshot=this.buildSnapshot();for(const r of this.listeners)r()};buildSnapshot(){const r=this.history.getSnapshot(),i=this.pending>0||r.busy;return{version:this.version,busy:i,canUndo:!this.disposed&&!i&&r.canUndo,canRedo:!this.disposed&&!i&&r.canRedo,undoLabel:r.undoLabel,redoLabel:r.redoLabel}}}function Bbn(t){let r=t.getSnapshot().limitWarning,i=t.getSnapshot().lastEviction;return t.subscribe(()=>{const{limitWarning:a,lastEviction:l}=t.getSnapshot();a!==r&&(r=a,a&&(My(a.message),ua.warn(a.message,"history"))),l!==i&&(i=l,l&&ua.warn(l.message,"history"))})}class $bn{constructor(r,i={}){this.projectIdentity=r,this.history=new VLr(i),this.historyCommands=new jbn(this.history),this.releaseLimitNotices=Bbn(this.history)}history;historyCommands;releaseLimitNotices;dispose(){this.releaseLimitNotices(),this.historyCommands.dispose(),this.history.dispose()}}function qbn(){return MGt}let MGt=Promise.resolve();function LGt(){const t=zbn();return MGt=t.then(()=>{},()=>{}),t}async function zbn(){await jGt()}async function jGt(){const t=ad();if(t){ua.log(`Opened project: ${t.config.name}`,"project");return}try{const r=await KNt();r&&ua.log(`Opened project: ${r.config.name}`,"project")}catch{}}const BGt=Object.freeze(Object.defineProperty({__proto__:null,bootstrapProject:LGt,initProject:jGt,projectBootstrapSettled:qbn},Symbol.toStringTag,{value:"Module"}));function GRe(t){return Promise.reject(new Error(`This editor tier cannot ${t}.`))}const $Gt={openPersistence:()=>GRe("persist Asset Lab documents"),replaceSource:()=>GRe("write project source"),saveThumbnailFraming:()=>GRe("write project thumbnail framing")};let Vme=$Gt;function Ubn(t){if(Vme!==t){if(Vme!==$Gt)throw new Error("An Object3D document write policy is already installed.");Vme=t}}function qGt(){return Vme}function Vbn(){let t=0;const r=async()=>{const a=++t,l=ad();if(l)try{const d=await bNt();if(d.status!=="project"||d.project.path!==l.rootPath)return;const _=d.project.config;if(a!==t||ad()!==l)return;ize({...l,config:_})}catch(d){a===t&&ad()===l&&console.error("[project] Could not refresh project declarations:",d)}},i=MUr(()=>void r());return()=>{t++,i()}}const Jbn=400;let Jme=null,IY=null,Kz={},cqe=!1,Yq=null;function zGt(){return hh()}function lbe(){const t=zGt();return Jme===t?Promise.resolve():IY?IY.then(()=>lbe()):(IY=Promise.all([izr(),Q3t()]).then(([r])=>{Kz=r&&typeof r=="object"?{...r}:{},Jme=t}).catch(()=>{Kz={},Jme=t}).finally(()=>{IY=null}),IY)}function pte(){return Jme===zGt()}function WQe(t){if(pte())return Kz[t]}function UGt(){Yq!==null&&(clearTimeout(Yq),Yq=null),cqe&&(cqe=!1,szr(Kz))}function ube(t,r){const i=()=>{Kz={...Kz,[t]:r},cqe=!0,Yq!==null&&clearTimeout(Yq),Yq=setTimeout(UGt,Jbn)};pte()?i():lbe().then(i)}function Wbn(){UGt()}Iw(()=>{ad()&&lbe()});typeof window<"u"&&window.addEventListener("pagehide",Wbn);function Hbn(){return f3r(()=>{PQe(),J9r(null),COr(),Hyn(),r5r(),HDt(),zmn(),pP()})}async function Gbn(){typeof performance<"u"&&performance.getEntriesByType("navigation").length>0&&await Promise.race([r0e(),new Promise(r=>setTimeout(r,5e3))]),await O8()}function Qbn(){Gbn();const t=Iw(()=>void O8()),r=WNt(()=>void O8());return()=>{t(),r()}}const Kbn={tools:[],contributions:[],loadErrors:[]};let VGt=Kbn,JGt=0;const lqe=new Set;function OEt(t){VGt=t,JGt++;for(const r of lqe)r()}function Yz(){return VGt}function Ybn(){return JGt}function WGt(t){return lqe.add(t),()=>lqe.delete(t)}async function eZ(){try{const t=await fetch("/__editor/project-tools"),r=await Eg(t,"Catalog request failed");return OEt(r),r}catch(t){const r={tools:[],contributions:[],loadErrors:[{sourcePath:"package.json#vgai.tools",message:t instanceof Error?t.message:String(t)}]};return OEt(r),r}}async function Xbn(t,r,i={}){const a=await fetch("/__editor/project-tools/run",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:t,input:r,confirm:i.confirm===!0})}),l=await Eg(a,`Running the project tool ${JSON.stringify(t)} failed`);if(!l||typeof l!="object"||typeof l.ok!="boolean")throw new Error(`Tool request returned an invalid response (${a.status}).`);return l}function Zbn(){eZ();const t=Iw(()=>void eZ()),r=WNt(()=>void eZ());return()=>{t(),r()}}let HGt=null;function eAn(t){HGt=t,t!==null&&tAn()}const FEt=128;let _X=[],tZ=null,GGt=0,QRe=!1;function tAn(){if(QRe)return()=>{};if(typeof PerformanceObserver>"u")return()=>{};let t;try{t=new PerformanceObserver(r=>{for(const i of r.getEntries()){const a=i.duration;(tZ===null||a>tZ)&&(tZ=a),a>=100&&(GGt+=1),_X.push({start:i.startTime,duration:a}),_X.length>FEt&&(_X=_X.slice(-FEt))}}),t.observe({type:"longtask",buffered:!0})}catch{return()=>{}}return QRe=!0,()=>{t.disconnect(),QRe=!1}}function rAn(t=performance.now()){const r=HGt;if(r===null)return null;const i=r(),a=i.lastCallWindow;let l=null;if(a!==null){const d=a.end??t;for(const _ of _X)_.start+_.duration<a.start||_.start>d||(l===null||_.duration>l)&&(l=_.duration)}return{inFlightMs:i.inFlightMs,lastCallMs:i.lastCallMs,maxCallMs:i.maxCallMs,callsOver5s:i.callsOver5s,callsOver30s:i.callsOver30s,longestTaskMs:tZ===null?null:Math.round(tZ),tasksOver100ms:GGt,lastCallLongestTaskMs:l===null?null:Math.round(l),wasmMemoryMB:i.wasmMemoryMB}}function REt(t){return!("unavailable"in t)}function nAn(t=globalThis.performance){const r=t?.memory;return!r||typeof r.usedJSHeapSize!="number"||typeof r.totalJSHeapSize!="number"?{unavailable:"performance.memory is unavailable — it is a non-standard Chromium-only API, not exposed by this browser."}:{usedBytes:r.usedJSHeapSize,totalBytes:r.totalJSHeapSize,limitBytes:typeof r.jsHeapSizeLimit=="number"?r.jsHeapSizeLimit:null}}const iAn=5e3,sAn=4,oAn=1024*1024;function KRe(t){return Math.round(t/oAn*100)/100}function aAn(t){const r=t.heap(),i=t.canvases(),a=t.rendererCounts(),l=t.blender?.()??null;let d=0;for(const _ of i)d+=_.width*_.height*sAn;return{heapUsedMB:REt(r)?KRe(r.usedBytes):null,heapLimitMB:REt(r)&&r.limitBytes!==null?KRe(r.limitBytes):null,mountEpochs:t.mountEpochs(),canvases:i.length,canvasMB:KRe(d),...l===null?{}:{blender:l},...a===null?{}:{textures:a.textures,geometries:a.geometries,...a.programs===null?{}:{programs:a.programs}}}}function cAn(t){const r=new Set;for(const i of t)try{const a=new URL(i.name,"http://vgai.invalid").searchParams.get(DUr);a!==null&&a.length>0&&r.add(a)}catch{}return r.size}function lAn(){return{heap:()=>nAn(),mountEpochs:()=>cAn(performance.getEntriesByType("resource")),canvases:()=>[...document.querySelectorAll("canvas")],rendererCounts:()=>ROr()?.memorySnapshot?.().counts??null,blender:()=>rAn()}}let QGt=null;function l4n(){return QGt}function uAn(t){const r=t.sources??lAn(),i=t.hidden??(()=>document.visibilityState==="hidden"),a=()=>{if(i())return;const d=aAn(r);QGt=d,t.report(d)};a();const l=setInterval(a,t.intervalMs??iAn);return()=>clearInterval(l)}const fAn=dAn("SERVER_STATE_PERSISTENCE",()=>({save:t=>ube("view",t),saveThumbnail:ezr}));function dAn(t,r){return r()}function pAn({children:t}){const r=Xe.useRef(null);r.current||(r.current=new Eq,gzr(r.current));const i=Xe.useRef(null);if(!i.current){const _=ad();i.current=new $bn(_?.rootPath??"unknown-project")}r.current.attachHistory(i.current.history),wjr(Ijr),Ubn(cjr),r.current.attachStatePersistence(fAn);const a=Xe.useRef(null);a.current||(a.current={fps:0,frameTime:0,drawCalls:0,triangles:0,cameraPosition:{x:0,y:0,z:0},cameraTarget:{x:0,y:0,z:0}});const l=Xe.useRef(null);l.current||(l.current=LGt()),Xe.useEffect(()=>bbn(r.current,i.current.historyCommands),[]),Xe.useEffect(()=>Qbn(),[]),Xe.useEffect(()=>Zbn(),[]),Xe.useEffect(()=>Lmn(),[]),Xe.useEffect(()=>Vbn(),[]),Xe.useEffect(()=>Hbn(),[]),Xe.useEffect(()=>rhn(r.current),[]),Xe.useEffect(()=>uAn({report:Oqr}),[]);const d=Xe.useRef(!1);return Xe.useEffect(()=>{d.current=!0;const _=i.current;return()=>{d.current=!1,queueMicrotask(()=>{d.current||_.dispose()})}},[]),z.jsx(Sbn,{runtime:{store:r.current,stats:a.current,initPromise:l.current,session:i.current},children:t})}const wye={x:0,y:0,zoom:1};function u4n(t=wye){let r=t;const i=new Set,a=()=>{for(const l of i)l()};return{get:()=>r,setView:(l,d,_)=>{const g=Math.min(4,Math.max(.1,_));r.x===l&&r.y===d&&r.zoom===g||(r={x:l,y:d,zoom:g},a())},setPan:(l,d)=>{const _=r.zoom;r.x===l&&r.y===d||(r={x:l,y:d,zoom:_},a())},setZoom:l=>{const d=Math.min(4,Math.max(.1,l));r.zoom!==d&&(r={x:r.x,y:r.y,zoom:d},a())},reset:()=>{r.x===0&&r.y===0&&r.zoom===1||(r=wye,a())},subscribe:l=>(i.add(l),()=>i.delete(l))}}let bw=wye;const uqe=new Set,f4n={get:()=>_An(),setView:(t,r,i)=>HQe(t,r,i),setPan:(t,r)=>mAn(t,r),setZoom:t=>hAn(t),reset:()=>YGt(),subscribe:t=>gAn(t)};function KGt(){for(const t of uqe)t()}function _An(){return bw}function HQe(t,r,i){const a=Math.min(4,Math.max(.1,i));bw.x===t&&bw.y===r&&bw.zoom===a||(bw={x:t,y:r,zoom:a},KGt())}function mAn(t,r){HQe(t,r,bw.zoom)}function hAn(t){HQe(bw.x,bw.y,t)}function YGt(){bw.x===0&&bw.y===0&&bw.zoom===1||(bw=wye,KGt())}function gAn(t){return uqe.add(t),()=>uqe.delete(t)}function d4n(t){if(!(t.x===0&&t.y===0&&t.zoom===1))return t.zoom===1?`translate(${t.x}px, ${t.y}px)`:t.x===0&&t.y===0?`scale(${t.zoom})`:`translate(${t.x}px, ${t.y}px) scale(${t.zoom})`}function yAn(t){if(typeof t=="number")return t;if(typeof t!="string"||t==="")return;const r=Number.parseFloat(t);return Number.isNaN(r)?void 0:r}const MEt=8,W8=8,p4n=[{pos:"nw",cursor:"nwse-resize"},{pos:"n",cursor:"ns-resize"},{pos:"ne",cursor:"nesw-resize"},{pos:"w",cursor:"ew-resize"},{pos:"e",cursor:"ew-resize"},{pos:"sw",cursor:"nesw-resize"},{pos:"s",cursor:"ns-resize"},{pos:"se",cursor:"nwse-resize"}];function _4n(t,r){const i=t.x+t.width/2,a=t.y+t.height/2;switch(r){case"nw":return{x:t.x,y:t.y};case"n":return{x:i,y:t.y};case"ne":return{x:t.x+t.width,y:t.y};case"w":return{x:t.x,y:a};case"e":return{x:t.x+t.width,y:a};case"sw":return{x:t.x,y:t.y+t.height};case"s":return{x:i,y:t.y+t.height};case"se":return{x:t.x+t.width,y:t.y+t.height}}}function gI(t,r){return r?Math.round(t):Math.round(t/MEt)*MEt}function XGt(t,r,i,a,l){let d=Math.max(W8,gI(r.width+t,i)),_=null;return a.length&&(_=fbe(r.x+d,a,l),_&&(d=Math.max(W8,_.edge-r.x))),{value:d,match:_}}function ZGt(t,r,i,a,l){const d=r.x+r.width;let _=Math.max(W8,gI(r.width-t,i)),g=null;return a.length&&(g=fbe(d-_,a,l),g&&(_=Math.max(W8,d-g.edge))),{value:_,eastEdge:d,match:g}}function eQt(t,r,i,a,l){let d=Math.max(W8,gI(r.height+t,i)),_=null;return a.length&&(_=fbe(r.y+d,a,l),_&&(d=Math.max(W8,_.edge-r.y))),{value:d,match:_}}function tQt(t,r,i,a,l){const d=r.y+r.height;let _=Math.max(W8,gI(r.height-t,i)),g=null;return a.length&&(g=fbe(d-_,a,l),g&&(_=Math.max(W8,d-g.edge))),{value:_,southEdge:d,match:g}}function vAn(t,r,i,a,l,d,_){if(t==="e"||t==="ne"||t==="se")return{width:XGt(r,i,l,d,_).value};if(t==="w"||t==="nw"||t==="sw"){const{value:g,eastEdge:b}=ZGt(r,i,l,d,_);return a?{width:g,x:b-g}:{width:g}}return{}}function bAn(t,r,i,a,l,d,_){if(t==="s"||t==="sw"||t==="se")return{height:eQt(r,i,l,d,_).value};if(t==="n"||t==="nw"||t==="ne"){const{value:g,southEdge:b}=tQt(r,i,l,d,_);return a?{height:g,y:b-g}:{height:g}}return{}}function m4n(t,r,i,a,l,d,_,g=c9){const b=!d&&_?_te(_):null,S=b?mte(b):[],k=b?hte(b):[];return{...vAn(t,r,a,l,d,S,g),...bAn(t,i,a,l,d,k,g)}}const c9=4;function _te(t){return{paddingBox:t.paddingBox??{x:0,y:0,width:0,height:0},siblingRects:(t.siblings??[]).filter(r=>r.width>0&&r.height>0),guideX:t.guideEdges?.x??[],guideY:t.guideEdges?.y??[]}}function mte(t){const r=[{edge:t.paddingBox.x,rect:t.paddingBox},{edge:t.paddingBox.x+t.paddingBox.width,rect:t.paddingBox}];for(const i of t.siblingRects)r.push({edge:i.x,rect:i}),r.push({edge:i.x+i.width,rect:i});for(const i of t.guideX??[])r.push({edge:i,rect:{x:i,y:-1e5,width:0,height:2e5}});return r}function hte(t){const r=[{edge:t.paddingBox.y,rect:t.paddingBox},{edge:t.paddingBox.y+t.paddingBox.height,rect:t.paddingBox}];for(const i of t.siblingRects)r.push({edge:i.y,rect:i}),r.push({edge:i.y+i.height,rect:i});for(const i of t.guideY??[])r.push({edge:i,rect:{x:-1e5,y:i,width:2e5,height:0}});return r}function Xz(t,r,i,a){let l=t,d=a,_=null;for(const g of i){const b=Math.abs(t-g.edge);b<=d&&(d=b,l=g.edge,_=g);const S=Math.abs(t+r-g.edge);S<=d&&(d=S,l=g.edge-r,_=g)}return{value:l,match:_}}function fbe(t,r,i){let a=null,l=i;for(const d of r){const _=Math.abs(t-d.edge);_<=l&&(l=_,a=d)}return a}function h4n(t,r,i,a,l){let d=gI(i.x+t,a),_=gI(i.y+r,a);if(!a&&l){const g=_te(l);d=Xz(d,i.width,mte(g),c9).value,_=Xz(_,i.height,hte(g),c9).value}return{x:d,y:_}}function g4n(t,r,i,a,l,d=c9){if(i)return{guides:[],position:t};let _=null,g=d;for(const X of l?.snapPoints??[]){const G=Math.hypot(t.x-X.x,t.y-X.y);G<=g&&(g=G,_=X)}if(_)return{guides:dee({x:_.x,y:_.y,width:0,height:0},{edge:_.x,rect:r},{edge:_.y,rect:r}),position:_};if(l?.bounded)return{guides:[],position:t};const b=gI(t.x,!1),S=gI(t.y,!1),k=[r,a?.parent,a?.paddingBox,...a?.siblings??[]].filter(X=>!!X&&X.width>0&&X.height>0);let w=null,N=null,P=d,j=d;for(const X of k){for(const G of[X.x,X.x+X.width/2,X.x+X.width]){const ee=Math.abs(b-G);ee<=P&&(P=ee,w={edge:G,rect:X})}for(const G of[X.y,X.y+X.height/2,X.y+X.height]){const ee=Math.abs(S-G);ee<=j&&(j=ee,N={edge:G,rect:X})}}const J={x:w?.edge??b,y:N?.edge??S};return{guides:dee({x:J.x,y:J.y,width:0,height:0},w,N),position:J}}function dee(t,r,i){const a=[];return r&&a.push({orientation:"vertical",at:r.edge,start:Math.min(t.y,r.rect.y),end:Math.max(t.y+t.height,r.rect.y+r.rect.height)}),i&&a.push({orientation:"horizontal",at:i.edge,start:Math.min(t.x,i.rect.x),end:Math.max(t.x+t.width,i.rect.x+i.rect.width)}),a}function y4n(t,r,i,a,l,d=c9){if(a||!l)return[];const _=gI(i.x+t,!1),g=gI(i.y+r,!1),b=_te(l),S=Xz(_,i.width,mte(b),d).match,k=Xz(g,i.height,hte(b),d).match,w={x:_,y:g,width:i.width,height:i.height};return dee(w,S,k)}function v4n(t,r,i,a,l="both",d=!1,_=c9,g={}){if(d||!a&&!g.x?.length&&!g.y?.length)return{position:t,guides:[]};const b={x:i.x+t.x-r.x,y:i.y+t.y-r.y,width:i.width,height:i.height},S=a?_te(a):null,k=S?mte(S):[],w=S?hte(S):[];for(const J of g.x??[])k.push({edge:J,rect:{x:J,y:b.y,width:0,height:b.height}});for(const J of g.y??[])w.push({edge:J,rect:{x:b.x,y:J,width:b.width,height:0}});const N=l==="y"?{value:b.x,match:null}:Xz(b.x,b.width,k,_),P=l==="x"?{value:b.y,match:null}:Xz(b.y,b.height,w,_),j={...b,x:N.value,y:P.value};return{position:{x:t.x+j.x-b.x,y:t.y+j.y-b.y},guides:dee(j,N.match,P.match)}}function b4n(t,r,i,a,l,d,_=c9){if(l||!d)return[];const g=t==="e"||t==="ne"||t==="se",b=t==="w"||t==="nw"||t==="sw",S=t==="s"||t==="sw"||t==="se",k=t==="n"||t==="nw"||t==="ne",w=_te(d),N=mte(w),P=hte(w);let j=null;g?j=XGt(r,a,!1,N,_).match:b&&(j=ZGt(r,a,!1,N,_).match);let J=null;return S?J=eQt(i,a,!1,P,_).match:k&&(J=tQt(i,a,!1,P,_).match),dee(a,j,J)}function A4n(t,r,i,a,l=15){const d=k=>k*180/Math.PI,_=d(Math.atan2(r.y-t.y,r.x-t.x)),b=d(Math.atan2(i.y-t.y,i.x-t.x))-_;return{rotate:a?b:Math.round(b/l)*l}}function I9(t,r){if(t instanceof Zh){const i=t.ownerOf(r);return i?t.childAdapters().find(a=>a.worldId===i)?.adapter??null:null}return t}const LEt=new WeakMap;function AAn(t){const r=t.boxEdit;if(!r)return null;const i=LEt.get(t);if(i?.provider===r)return i.recorded;const a={begin:l=>Kg({adapter:t,seam:"editor.boxEdit.begin",stage:"effect",detail:`the world overlay began a box edit for ${l}`,run:()=>r.begin(l)}),apply:(l,d)=>Kg({adapter:t,seam:"editor.boxEdit.apply",stage:"effect",detail:`the world overlay applied a ${Object.keys(d).join(", ")} box patch to ${l}`,run:()=>r.apply(l,d)}),end:l=>Kg({adapter:t,seam:"editor.boxEdit.end",stage:"effect",detail:`the world overlay ended a box edit for ${l}`,run:()=>r.end(l)}),...r.gizmoOrigin?{gizmoOrigin:l=>Kg({adapter:t,seam:"editor.boxEdit.gizmoOrigin",stage:"operation",detail:`the world overlay read the native gizmo origin for ${l}`,run:()=>r.gizmoOrigin?.(l)??null})}:{},...r.referencePoint?{referencePoint:l=>Kg({adapter:t,seam:"editor.boxEdit.referencePoint",stage:"operation",detail:`the world overlay read the native reference point for ${l}`,run:()=>r.referencePoint?.(l)??null})}:{}};return LEt.set(t,{provider:r,recorded:a}),a}function SAn(t,r){return I9(t,r)?.rects?.rect(r)??null}function xAn(t,r){const i=I9(t,r);return i?AAn(i):null}function S4n(t,r){return I9(t,r)?.rects?.contextRects?.(r)}function x4n(t,r){return I9(t,r)?.structure??null}function w4n(t,r){return I9(t,r)?.text??null}function C4n(t,r){return I9(t,r)?.colorSample??null}function E4n(t,r){const i=I9(t,r);return i?.rects?K9r(i):null}function T4n(t){const r=t instanceof Zh?t.childAdapters():[{worldId:"",adapter:t}],i=[];for(const{worldId:a,adapter:l}of r)l.rects?.emptyContainers&&(a&&zP(a)||i.push(...l.rects.emptyContainers()));return i}function wAn(t,r){const i=a=>{const l=t.inspector?.get(r,`style.${a}`);return yAn(l)??0};return{paddingTop:i("paddingTop"),paddingRight:i("paddingRight"),paddingBottom:i("paddingBottom"),paddingLeft:i("paddingLeft"),marginTop:i("marginTop"),marginRight:i("marginRight"),marginBottom:i("marginBottom"),marginLeft:i("marginLeft")}}const CAn=4;function k4n(t,r){const i=w=>w>0?w:CAn,a=i(r.paddingTop),l=i(r.paddingRight),d=i(r.paddingBottom),_=i(r.paddingLeft),g=i(r.marginTop),b=i(r.marginRight),S=i(r.marginBottom),k=i(r.marginLeft);return[{side:"paddingTop",kind:"padding",x:t.x,y:t.y,width:t.width,height:a,cursor:"ns-resize",labelX:t.x+t.width/2,labelY:t.y+a/2,value:r.paddingTop,isZero:r.paddingTop===0},{side:"paddingBottom",kind:"padding",x:t.x,y:t.y+t.height-d,width:t.width,height:d,cursor:"ns-resize",labelX:t.x+t.width/2,labelY:t.y+t.height-d/2,value:r.paddingBottom,isZero:r.paddingBottom===0},{side:"paddingLeft",kind:"padding",x:t.x,y:t.y,width:_,height:t.height,cursor:"ew-resize",labelX:t.x+_/2,labelY:t.y+t.height/2,value:r.paddingLeft,isZero:r.paddingLeft===0},{side:"paddingRight",kind:"padding",x:t.x+t.width-l,y:t.y,width:l,height:t.height,cursor:"ew-resize",labelX:t.x+t.width-l/2,labelY:t.y+t.height/2,value:r.paddingRight,isZero:r.paddingRight===0},{side:"marginTop",kind:"margin",x:t.x,y:t.y-g,width:t.width,height:g,cursor:"ns-resize",labelX:t.x+t.width/2,labelY:t.y-g/2,value:r.marginTop,isZero:r.marginTop===0},{side:"marginBottom",kind:"margin",x:t.x,y:t.y+t.height,width:t.width,height:S,cursor:"ns-resize",labelX:t.x+t.width/2,labelY:t.y+t.height+S/2,value:r.marginBottom,isZero:r.marginBottom===0},{side:"marginLeft",kind:"margin",x:t.x-k,y:t.y,width:k,height:t.height,cursor:"ew-resize",labelX:t.x-k/2,labelY:t.y+t.height/2,value:r.marginLeft,isZero:r.marginLeft===0},{side:"marginRight",kind:"margin",x:t.x+t.width,y:t.y,width:b,height:t.height,cursor:"ew-resize",labelX:t.x+t.width+b/2,labelY:t.y+t.height/2,value:r.marginRight,isZero:r.marginRight===0}]}function EAn(t,r,i){switch(t){case"paddingTop":return i;case"paddingBottom":return-i;case"paddingLeft":return r;case"paddingRight":return-r;case"marginTop":return-i;case"marginBottom":return i;case"marginLeft":return-r;case"marginRight":return r}}function I4n(t,r,i,a){const l=EAn(t,r,i),d=Math.max(0,Math.round(a+l));return{[t]:d}}function D4n(t,r,i){return{x:t.x+r,y:t.y+i,width:t.width,height:t.height}}const YRe=3;function J7(t,r){return r==="x"?t.x+t.width/2:t.y+t.height/2}function TAn(t,r,i){if(r===0){const d=t[0].rect;return i?d.x:d.y}if(r===t.length){const d=t[t.length-1].rect;return i?d.x+d.width:d.y+d.height}const a=t[r-1].rect,l=t[r].rect;return i?(a.x+a.width+l.x)/2:(a.y+a.height+l.y)/2}function kAn(t,r,i){const a=Math.min(...t.map(_=>i?_.rect.y:_.rect.x)),l=Math.max(...t.map(_=>i?_.rect.y+_.rect.height:_.rect.x+_.rect.width)),d=YRe/2;return i?{x:r-d,y:a,width:YRe,height:l-a}:{x:a,y:r-d,width:l-a,height:YRe}}function P4n(t,r){if(t.length===0)return null;const i=Math.max(...t.map(N=>J7(N.rect,"x")))-Math.min(...t.map(N=>J7(N.rect,"x"))),a=Math.max(...t.map(N=>J7(N.rect,"y")))-Math.min(...t.map(N=>J7(N.rect,"y"))),l=i>=a,d=l?"x":"y",_=[...t].sort((N,P)=>J7(N.rect,d)-J7(P.rect,d)),g=l?r.x:r.y;let b=0;for(;b<_.length&&J7(_[b].rect,d)<g;)b++;const S=b<_.length?_[b].id:null,k=TAn(_,b,l),w=kAn(_,k,l);return{beforeSiblingId:S,index:b,marker:w}}function N4n(t,r){const i=t.hierarchy.node(r);if(!i)return null;if(i.parentId){const a=t.hierarchy.node(i.parentId);return a?a.childIds:null}return t.hierarchy.roots().map(a=>a.id)}function O4n(t,r){const i=t.x,a=t.x+t.width,l=t.y,d=t.y+t.height,_=r.x,g=r.x+r.width,b=r.y,S=r.y+r.height,k=[];let w=null;if(a<=_?w={x1:a,x2:_}:g<=i&&(w={x1:g,x2:i}),w){const P=Math.max(l,b),j=Math.min(d,S),J=j>P?(P+j)/2:((l+d)/2+(b+S)/2)/2;k.push({orientation:"horizontal",x1:w.x1,y1:J,x2:w.x2,y2:J,distance:Math.round(w.x2-w.x1),labelX:(w.x1+w.x2)/2,labelY:J})}let N=null;if(d<=b?N={y1:d,y2:b}:S<=l&&(N={y1:S,y2:l}),N){const P=Math.max(i,_),j=Math.min(a,g),J=j>P?(P+j)/2:((i+a)/2+(_+g)/2)/2;k.push({orientation:"vertical",x1:J,y1:N.y1,x2:J,y2:N.y2,distance:Math.round(N.y2-N.y1),labelX:J,labelY:(N.y1+N.y2)/2})}return k}function XRe(t,r,i){const a=t?.get(r,i);return typeof a=="string"&&a.length>0?a:null}function F4n(t,r){const i=XRe(t.inspector,r,"style.position");let a=null;const l=t.hierarchy.node(r)?.parentId??null;if(l){const d=XRe(t.inspector,l,"style.display");d==="flex"||d==="inline-flex"?a=`flex ${(XRe(t.inspector,l,"style.flexDirection")??"row").startsWith("column")?"col":"row"}`:d==="grid"||d==="inline-grid"?a="grid":d&&(a=d)}return{position:i,parentLayout:a}}function R4n(t,r){if(t.length<2)return[];const i=t.map(k=>k.rect),a=Math.min(...i.map(k=>k.x)),l=Math.max(...i.map(k=>k.x+k.width)),d=Math.min(...i.map(k=>k.y)),_=Math.max(...i.map(k=>k.y+k.height)),g=(a+l)/2,b=(d+_)/2,S=[];for(const{id:k,rect:w}of t)switch(r){case"left":S.push({id:k,x:a});break;case"hcenter":S.push({id:k,x:g-w.width/2});break;case"right":S.push({id:k,x:l-w.width});break;case"top":S.push({id:k,y:d});break;case"vcenter":S.push({id:k,y:b-w.height/2});break;case"bottom":S.push({id:k,y:_-w.height});break}return S}function M4n(t,r){if(t.length<3)return[];const i=r==="horizontal",a=[...t].sort((w,N)=>i?w.rect.x-N.rect.x:w.rect.y-N.rect.y),l=a[0],d=a[a.length-1],_=i?d.rect.x+d.rect.width-l.rect.x:d.rect.y+d.rect.height-l.rect.y,g=a.reduce((w,N)=>w+(i?N.rect.width:N.rect.height),0),b=(_-g)/(a.length-1);let S=i?l.rect.x:l.rect.y;const k=[];for(const w of a)k.push(i?{id:w.id,x:S}:{id:w.id,y:S}),S+=(i?w.rect.width:w.rect.height)+b;return k}function L4n(t){if(t.length===0)return null;const r=Math.min(...t.map(d=>d.x)),i=Math.min(...t.map(d=>d.y)),a=Math.max(...t.map(d=>d.x+d.width)),l=Math.max(...t.map(d=>d.y+d.height));return{x:r,y:i,width:a-r,height:l-i}}function IAn(t,r,i,a,l){const d={};return i?(t!==0&&(d.x=a.x+t),r!==0&&(d.y=a.y+r),d):(t!==0&&(d.marginLeft=l.left+t),r!==0&&(d.marginTop=l.top+r),d)}let jEt=!1;const rQt=new Set(["viewport","hierarchy","inspector","asset-browser","workspace","global"]);let nQt="viewport";const iQt="editorActiveHotkeyScope";function DAn(){const t=document.documentElement.dataset[iQt];return t&&rQt.has(t)?t:nQt}function H8(t){nQt=t,document.documentElement.dataset[iQt]=t}const PAn="data-editor-app-undo";function BEt(t){return t instanceof Element&&t.closest(`[${PAn}]`)!==null}function fqe(t){return t instanceof Element?t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement||t instanceof HTMLElement&&t.isContentEditable?!0:!!t.closest('[contenteditable]:not([contenteditable="false"])'):!1}function NAn(t){for(const r of t.composedPath()){if(!(r instanceof HTMLElement)||t.type==="focusin"&&r.hasAttribute("data-editor-hotkey-fallback"))continue;const i=r.dataset.editorHotkeyScope;if(i&&rQt.has(i))return i}return null}function $Et(t){const r=NAn(t);r&&H8(r)}const ZRe=[];function qEt(t){return ZRe.push(...t),()=>{for(const r of t){const i=ZRe.indexOf(r);i>=0&&ZRe.splice(i,1)}}}function sQt(){jEt||(window.addEventListener("pointerdown",$Et,!0),window.addEventListener("focusin",$Et,!0),jEt=!0)}const rZ=new Map;let oQt=0;const dqe=new Set;function zEt(){oQt++;for(const t of dqe)t()}function OAn(t){return rZ.set(t.id,t),zEt(),()=>{rZ.get(t.id)===t&&(rZ.delete(t.id),zEt())}}function FAn(){return[...rZ.values()]}function RAn(){return oQt}function MAn(t){return dqe.add(t),()=>dqe.delete(t)}function LAn(t){const r=rZ.get(t);return!r||r.enabled&&!r.enabled()?!1:(r.run(),!0)}const jAn=["position","rotation","scale"];function BAn(t){const r=t.role==="component"&&!!t.typeLabel;return{label:t.label,typeSuffix:r?t.typeLabel:null}}const GQe={locked:!1};function aQt(t){let r;for(const i of jAn){const a=t(i);if(!a||a.writable)return GQe;i==="position"&&(r=a.reason)}return r===void 0?{locked:!0}:{locked:!0,reason:r}}class $An{entries=new Map;source=null;version=Number.NaN;computed=0;get computeCount(){return this.computed}summaryFor(r,i,a){(this.source!==r||this.version!==i)&&(this.entries.clear(),this.source=r,this.version=i);const l=this.entries.get(a);if(l)return l;this.computed++;const d=r.transforms?.editability,_=d?aQt(g=>d(a,g)):GQe;return this.entries.set(a,_),_}}const qAn={draggable:!0,renamable:!0,writable:!0,searchable:!0},zAn={draggable:!1,renamable:!1,writable:!0,searchable:!0},UAn={draggable:!1,renamable:!1,writable:!1,searchable:!1};function QQe(t){return t.internal?UAn:t.structural?zAn:qAn}function VAn(t){return!t||t.length===0?null:{count:t.length,tooltip:t.map(r=>r.message).join(`
|
|
1679
1679
|
`),codes:t.map(r=>r.code)}}class JAn{entries=new Map;source=null;version=Number.NaN;computed=0;get computeCount(){return this.computed}badgeFor(r,i,a){(this.source!==r||this.version!==i)&&(this.entries.clear(),this.source=r,this.version=i);const l=this.entries.get(a);if(l!==void 0)return l;this.computed++;const d=r.diagnosticsFor?VAn(r.diagnosticsFor(a)):null;return this.entries.set(a,d),d}}function yS(t,r){if(t.setTransformMode(r),r==="select")return;const i=[...t.selectedEntityIds];if(i.length===0)return;const a=By(t).transforms?.editability;if(!a)return;let l;for(const d of i){const _=aQt(g=>a(d,g));if(!_.locked)return;l??=_.reason}l&&My(l)}const cw=["viewport","hierarchy","inspector"];function H$(){return(globalThis.getSelection?.()?.toString()??"").length===0}function ZP(t){return VUe(t)}async function KQe(t){const r=ZP(t);r.length!==0&&await E0e(wm(t).adapter,r)}async function YQe(t){const r=ZP(t);r.length!==0&&await T0e(wm(t).adapter,r)}async function XQe(t){const r=wm(t).adapter,i=ZP(t)[0],a=i?r.hierarchy.node(i)?.parentId??null:null;await k0e(r,a)}let UEt=Promise.resolve();function dbe(t){const r=UEt.then(()=>WAn(t));return UEt=r.then(()=>{},()=>{}),r}async function WAn(t){const r=ZP(t);if(r.length===0)return;const i=wm(t).adapter,a=i.structure;if(!a)return;const l=r.length===1?i.hierarchy.node(r[0])?.label??"selection":`${r.length} objects`;if(My(`Duplicating ${l}…`),a.duplicateMany){const d=await o4t(i,r);if(d&&!d.persisted){My(d.destination);return}}else for(const d of r){const _=await S0e(i,d).ack;if(_&&!_.persisted){My(_.destination);return}}My(`Duplicated ${l}`)}async function pbe(t){const r=ZP(t);if(r.length===0)return;const i=wm(t).adapter,a=i.structure;if(a)if(a.removeMany)await _Ue(i,r);else{const l=new Map(ZPt(i).map((_,g)=>[_,g])),d=[...r].sort((_,g)=>(l.get(g)??-1)-(l.get(_)??-1));for(const _ of d)await Uhe(i,_)}}async function HAn(t){const r=ZP(t);if(r.length===0)return;const i=wm(t).adapter;if(i.structure?.wrap)for(const l of r)await x0e(i,l)}async function GAn(t){const r=ZP(t);if(r.length===0)return;const i=wm(t).adapter;if(i.structure?.unwrap)for(const l of r)await w0e(i,l)}async function QAn(t){const r=ZP(t);if(r.length===0)return;const i=wm(t).adapter;i.structure?.group&&await C0e(i,r).ack}function FN(t,r,i){const a=ZP(t);if(a.length===0)return;const l=wm(t).adapter;for(const d of a){const _=xAn(l,d);if(!_)continue;const g=SAn(l,d);if(!g)continue;const b=l.inspector?.get(d,"style.position"),S=b==="absolute"||b==="fixed",k=wAn(l,d),w=IAn(r,i,S,g,{left:k.marginLeft,top:k.marginTop});Object.keys(w).length!==0&&(_.begin(d),_.apply(d,w),_.end(d))}}function KAn(t){const r=Array.isArray(t)?t:[t];return r.includes("global")?"global":r.length===1&&r[0]==="viewport"?"stage":"panel"}let Wme=null;function Eu(t,r){const{frameEnabled:i,...a}=r;return Wme?.push(OAn({id:t,run:l=>a.action(l??new KeyboardEvent("keydown")),scope:KAn(a.scope),...i?{enabled:i}:{}})),Jze(t).map(l=>({...a,...l}))}function cQt(t){const r=()=>{const _=[],g=Wme;Wme=_;try{return{rows:t(),actions:_}}finally{Wme=g}};let i=r(),a=qEt(i.rows);const l=()=>{a();for(const _ of i.actions)_()},d=oU(()=>{l(),i=r(),a=qEt(i.rows)});return()=>{d(),l()}}function YAn(t,r){const i=()=>{const d=r.getSnapshot().undoLabel;r.undo().then(_=>{_&&d&&My(`Undid ${d}`)})},a=()=>{const d=r.getSnapshot().redoLabel;r.redo().then(_=>{_&&d&&My(`Redid ${d}`)})},l=cQt(()=>[...Eu("edit.redo",{scope:"global",allowInEditable:!0,when:d=>!fqe(d.target)||BEt(d.target),action:a}),...Eu("edit.undo",{scope:"global",allowInEditable:!0,when:d=>!fqe(d.target)||BEt(d.target),action:i}),...Eu("edit.copy",{scope:cw,when:H$,frameEnabled:H$,action:()=>void KQe(t)}),...Eu("edit.cut",{scope:cw,when:H$,frameEnabled:H$,action:()=>void YQe(t)}),...Eu("edit.paste",{scope:cw,when:H$,frameEnabled:H$,action:()=>void XQe(t)}),...Eu("edit.duplicate",{scope:cw,action:()=>void dbe(t)}),...Eu("edit.group",{scope:cw,action:()=>void QAn(t)}),...Eu("edit.wrap",{scope:cw,action:()=>HAn(t)}),...Eu("edit.unwrap",{scope:cw,action:()=>GAn(t)}),...Eu("edit.nudgeUp",{scope:"viewport",action:()=>FN(t,0,-1)}),...Eu("edit.nudgeUpCoarse",{scope:"viewport",action:()=>FN(t,0,-10)}),...Eu("edit.nudgeDown",{scope:"viewport",action:()=>FN(t,0,1)}),...Eu("edit.nudgeDownCoarse",{scope:"viewport",action:()=>FN(t,0,10)}),...Eu("edit.nudgeLeft",{scope:"viewport",action:()=>FN(t,-1,0)}),...Eu("edit.nudgeLeftCoarse",{scope:"viewport",action:()=>FN(t,-10,0)}),...Eu("edit.nudgeRight",{scope:"viewport",action:()=>FN(t,1,0)}),...Eu("edit.nudgeRightCoarse",{scope:"viewport",action:()=>FN(t,10,0)}),...Eu("edit.selectAll",{scope:cw,action:()=>{const d=wm(t).adapter;k0(d,ZPt(d))}}),...Eu("edit.deselectAll",{scope:cw,action:()=>k0(wm(t).adapter,[])}),...Eu("edit.save",{scope:"global",allowInEditable:!0,action:()=>{l5r().then(d=>{d===null&&lNt(t)})}}),...Eu("view.resetPan",{scope:"viewport",action:()=>YGt()}),...Eu("edit.enterScope",{scope:cw,when:()=>t.playState==="stopped",frameEnabled:()=>t.playState==="stopped",action:()=>{sMr(wm(t).adapter)}}),...Eu("edit.delete",{scope:cw,action:()=>void pbe(t)}),...Eu("edit.exitScopeOrDeselect",{scope:cw,when:()=>yUe()!==null||t.playState==="stopped",frameEnabled:()=>!0,action:()=>{const d=wm(t).adapter;if(!iMr(d)){if(t.playState!=="stopped"){PQe();return}t.select(null)}}}),...Eu("view.commandPalette",{scope:"global",action:()=>{FQe()||ua.warn(`The command palette has not handed over its opener yet — run "Volter Editor: Open Workspace" first, or press the workbench's own Show All Commands.`)}}),...Eu("view.toggleConsole",{scope:"global",action:()=>obe()}),...Eu("view.focusMode",{scope:"global",action:()=>Gze()}),...Eu("workspace.cycleNext",{scope:"global",action:()=>{Ohe(1)}}),...Eu("workspace.cyclePrevious",{scope:"global",action:()=>{Ohe(-1)}})]);return sQt(),l}function j4n(t,r,i){const a=cQt(()=>[...Eu("transform.select",{scope:"viewport",action:()=>{r.isFlying||yS(t,"select")}}),...Eu("transform.combined",{scope:"viewport",action:()=>{r.isFlying||yS(t,"combined")}}),...Eu("transform.translate",{scope:"viewport",action:()=>{r.isFlying||yS(t,"translate")}}),...Eu("transform.rotate",{scope:"viewport",action:()=>{r.isFlying||yS(t,"rotate")}}),...Eu("transform.scale",{scope:"viewport",action:()=>{r.isFlying||yS(t,"scale")}}),...Eu("viewport.toggleSnap",{scope:"viewport",action:()=>{t.toggleSnap();const{translate:b,rotate:S,scale:k}=t.snapValues,w=`${ep("viewport.toggleSnap")??""} toggles; hold Ctrl while dragging to snap once`;My(t.snapEnabled?`Snap on — ${b} units, ${S}°, ×${k} (${w})`:`Snap off (${w})`)}}),...Eu("viewport.frameSelection",{scope:"viewport",action:()=>t.focusOnSelection()}),...Eu("viewport.cyclePivot",{scope:"viewport",action:()=>{const b=["active-element","median-point","individual-origins"],S=b.indexOf(t.pivotMode);t.setPivotMode(b[(S+1)%b.length])}}),...Eu("view.top",{scope:"viewport",action:()=>r.setViewPreset("top")}),...Eu("view.front",{scope:"viewport",action:()=>r.setViewPreset("front")}),...Eu("view.right",{scope:"viewport",action:()=>r.setViewPreset("right")}),...Eu("view.perspective",{scope:"viewport",action:()=>r.setViewPreset("perspective")}),...Eu("viewport.snapToFloor",{scope:"viewport",action:()=>r.snapSelectionToFloor()})]),l=()=>H8("viewport");i.addEventListener("pointerdown",l),sQt();const d=b=>Jze("viewport.vertexSnapHold").some(S=>S.key===b.key.toLowerCase()),_=b=>{if(d(b)&&!b.metaKey&&!b.ctrlKey&&!b.repeat){if(DAn()!=="viewport"||b.target instanceof HTMLInputElement||b.target instanceof HTMLTextAreaElement)return;t.setVertexSnapActive(!0),r.activateVertexSnap()}},g=b=>{d(b)&&!b.metaKey&&!b.ctrlKey&&(t.setVertexSnapActive(!1),r.deactivateVertexSnap())};return window.addEventListener("keydown",_),window.addEventListener("keyup",g),()=>{a(),i.removeEventListener("pointerdown",l),window.removeEventListener("keydown",_),window.removeEventListener("keyup",g)}}function ZQe(){eRr("undo-history")}function XAn(){const t=()=>ZQe();return window.addEventListener("editor:show-history-tab",t),()=>window.removeEventListener("editor:show-history-tab",t)}let pqe=null,lQt=0;const _qe=new Set;function eKe(t){if(pqe!==t){pqe=t,lQt++;for(const r of _qe)r()}}function uQt(){return pqe}function ZAn(t){eKe(t)}function fQt(){eKe(null)}function dQt(t){return _qe.add(t),()=>_qe.delete(t)}function mqe(){return lQt}function e2n(){eKe(null)}const t2n=Object.freeze(Object.defineProperty({__proto__:null,__resetEditorPresentationNoticeForTest:e2n,clearEditorPresentationNotice:fQt,editorPresentationNotice:uQt,editorPresentationNoticeVersion:mqe,showEditorPresentationNotice:ZAn,subscribeEditorPresentationNotice:dQt},Symbol.toStringTag,{value:"Module"})),VEt="agent-presented-view";function r2n(){const t=D0();Xe.useSyncExternalStore(dQt,mqe,mqe);const r=uQt();return Xe.useEffect(()=>{if(!r){Rze(VEt);return}az({id:VEt,tone:"info",title:"Agent presented this view.",...r.presented.warnings.length>0?{detail:r.presented.warnings.join(" ")}:{},onDismiss:fQt,actions:[{label:"Copy Link",keeps:!0,run:()=>{Promise.resolve().then(()=>navigator.clipboard.writeText(r.presented.url)).catch(()=>{ua.warn("Could not copy the view link to the clipboard.","editor")})}},{label:"Return",primary:!0,run:()=>{bye(t,r.previousView,{origin:"return"}).catch(i=>{ua.error(`Could not return to the previous editor view: ${i instanceof Error?i.message:String(i)}`,"editor")})}}]})},[r,t]),null}const n2n=4e3;let nZ=null,Hme=null,Cye=null,pee=!1,Gme=null,JEt=!1;const Eye=new Set,i2n=()=>null;function pQt(){const t=nZ;if(!t)return null;const r=Hme;return{id:Sw,title:"Game",kind:"game",workspaceRole:"authored-subject",Content:r?.Content??i2n,...r?.Toolbar?{Toolbar:r.Toolbar}:{},closeable:!1,presentation:()=>({kind:"workspace",id:Sw}),onActivate:()=>t.onActivate()}}function s2n(t){return nZ=t,()=>{nZ===t&&(tKe(),nZ=null)}}function o2n(t){if(Hme=t,_be()){const r=pQt();r&&qP(r,{activate:!1})}return()=>{Hme===t&&(Hme=null)}}function _be(){return FA().some(t=>t.descriptor.id===Sw)}function a2n(){return Cye}function c2n(t){Cye=t,pee=!0;for(const r of[...Eye])r();Eye.clear()}function l2n(t){Cye===t&&(Cye=null,pee=!1)}async function u2n(t=n2n){const r=pQt();return r?(_be()?xb(r.id):(Gme=I_(),qP(r)),pee?!0:new Promise(i=>{const a=()=>{clearTimeout(l),i(!0)},l=setTimeout(()=>{Eye.delete(a),i(pee)},t);Eye.add(a)})):!1}function tKe(){if(!nZ||!_be()){Gme=null;return}const t=Gme;Gme=null,pee=!1,Y8(Sw,{discardDirty:!0}),t&&xb(t)}function f2n(t){JEt&&!t&&tKe(),JEt=t}function d2n(t){Xe.useEffect(()=>{const r=s2n({onActivate:()=>t.setActiveViewportTab("play")}),i=()=>f2n(t.playState!=="stopped");i();const a=t.subscribe(i);return()=>{a(),r(),HDt()}},[t])}const _ee={console:{id:"console",title:"Console"},lightExplorer:{id:"light-explorer",title:"Light Explorer"}},p2n={storyActions:{id:"story-actions",title:"Actions"},storyInteractions:{id:"story-interactions",title:"Interactions"},storyAccessibility:{id:"story-accessibility",title:"Accessibility"},generations:{id:"generations",title:"Generations"}};[...Object.values(_ee),...Object.values(p2n)];const _2n={info:Oo.content.primary,warn:Oo.semantic.warning,error:Oo.semantic.danger},WEt={scene:"#78dce8",physics:"#ff6188",animation:"#a9dc76",network:"#fc9867",audio:"#ab9df2",ai:"#ffd866",input:"#78dce8",core:Oo.content.primary},HEt={info:bee,warn:tIt,error:Ukt};function m2n(){const t=D0();Xe.useSyncExternalStore(ua.subscribe,ua.getSnapshot);const[r,i]=Xe.useState(""),[a,l]=Xe.useState("all"),[d,_]=Xe.useState({info:!0,warn:!0,error:!0}),g=Xe.useRef(null),[b,S]=Xe.useState(!0),k=ua.getEntries(),w=new Map;for(const ee of k){const xe=ee.metadata?.instanceId;if(typeof xe!="string"||xe.length===0)continue;const ue=ee.metadata?.instanceName;w.set(xe,typeof ue=="string"&&ue.length>0?ue:`Instance ${xe}`)}const N=k.filter(ee=>!(!d[ee.level]||a!=="all"&&ee.metadata?.instanceId!==a||r&&!ee.message.toLowerCase().includes(r.toLowerCase())));Xe.useEffect(()=>{b&&g.current&&(g.current.scrollTop=g.current.scrollHeight)},[k.length,b]);const P=()=>{if(!g.current)return;const{scrollTop:ee,scrollHeight:xe,clientHeight:ue}=g.current;S(xe-ee-ue<20)},j=ee=>{_(xe=>({...xe,[ee]:!xe[ee]}))},J=ee=>{const xe=new Date(ee);return`${xe.getHours().toString().padStart(2,"0")}:${xe.getMinutes().toString().padStart(2,"0")}:${xe.getSeconds().toString().padStart(2,"0")}`},X=ee=>{k0(By(t),[ee]),t.focusOnEntity(ee)},G=ua.counts;return z.jsxs(P5r,{className:"vgai-console",children:[z.jsxs(NP,{label:"Console filters",compact:!0,children:[z.jsx(rf,{"aria-label":"Clear console",size:"compact",onClick:()=>ua.clear(),title:"Clear console",children:z.jsx(So,{icon:Bkt,size:"xs"})}),z.jsx(tAt,{}),z.jsxs(bS,{"aria-label":"Filter console by game instance",title:"Show messages from all game instances or one inspected instance",value:a,onChange:ee=>l(ee.target.value),style:{width:"auto",minWidth:74,height:24,fontSize:11},children:[z.jsx("option",{value:"all",children:"All instances"}),[...w].map(([ee,xe])=>z.jsx("option",{value:ee,children:xe},ee))]}),z.jsx(tAt,{}),["info","warn","error"].map(ee=>z.jsxs(fo,{variant:"ghost",size:"compact","aria-label":`Toggle ${ee} messages`,"aria-pressed":d[ee],"data-console-level":ee,onClick:()=>j(ee),children:[z.jsx(So,{icon:HEt[ee],size:"xs"}),G[ee]]},ee)),z.jsx(k_,{placeholder:"Filter...",value:r,onChange:ee=>i(ee.target.value),className:"vgai-console-filter"})]}),z.jsxs("div",{ref:g,onScroll:P,className:"vgai-console-list vgai-selectable-text",children:[N.length===0&&z.jsx("div",{className:"vgai-console-empty",children:"No messages"}),N.map(ee=>{const xe=ee.metadata?.entityId!=null?String(ee.metadata.entityId):null,ue=(xe?t.objectMap.get(xe)?.name:null)||xe,fe=typeof ee.metadata?.instanceId=="string"?ee.metadata.instanceId:null,se=typeof ee.metadata?.instanceName=="string"?ee.metadata.instanceName:fe?`Instance ${fe}`:null;return z.jsxs("div",{className:"vgai-console-row","data-level":ee.level,style:{color:_2n[ee.level]},children:[z.jsx("span",{style:{color:Oo.content.dim,marginRight:6,flexShrink:0},children:J(ee.timestamp)}),z.jsx(So,{icon:HEt[ee.level],style:{fontSize:9,marginTop:4,marginRight:6,flexShrink:0}}),se&&z.jsx("span",{title:fe?`Runtime instance ${fe}`:void 0,style:{background:Oo.accent.muted,color:Oo.accent.default,borderRadius:Oo.shape.small,padding:"0 4px",fontSize:10,marginRight:6,flexShrink:0},children:se}),ee.subsystem&&z.jsx("span",{style:{background:`${WEt[ee.subsystem]??Oo.content.muted}22`,color:WEt[ee.subsystem]??Oo.content.muted,borderRadius:Oo.shape.small,padding:"0 4px",fontSize:10,marginRight:6,flexShrink:0},children:ee.subsystem}),z.jsxs("span",{style:{flex:1,wordBreak:"break-word"},children:[ee.message,xe&&z.jsxs("span",{onClick:()=>X(xe),style:{background:Oo.semantic.successMuted,color:Oo.semantic.success,borderRadius:Oo.shape.small,padding:"0 5px",fontSize:10,marginLeft:6,cursor:"pointer",pointerEvents:"auto",display:"inline-flex",alignItems:"center",gap:3},title:`Select and focus "${ue}"`,children:[z.jsx(So,{icon:f9,style:{fontSize:8}}),ue]}),ee.source&&z.jsxs("span",{style:{color:Oo.content.dim,marginLeft:6},children:["[",ee.source,"]"]})]}),ee.count>1&&z.jsx("span",{className:"vgai-console-count",children:ee.count})]},ee.id)})]})]})}const h2n={enabled:"visible",color:"light.color",intensity:"light.intensity",range:"light.distance",shadows:"shadow.cast"};function _Qt(t){const r=[],i=t;return uU(t.hierarchy,a=>{a.kind==="light"&&r.push(a)},{extraChildren:a=>i.internalChildren?.(a)}),r}function B4n(t){return _Qt(t).length}function mQt(t,r){return t.find(i=>i.path===h2n[r])??null}function DY(t,r,i,a,l){const d=mQt(i,a);if(!d||!t.inspector)return{supported:!1,writable:!1,value:null};let _;try{_=t.inspector.get(r,d.path)}catch{_=void 0}return{supported:!0,writable:d.readonly!==!0,value:l(_)?_:null}}const GEt=t=>typeof t=="boolean",g2n=t=>typeof t=="string",QEt=t=>typeof t=="number"&&Number.isFinite(t);function y2n(t){return _Qt(t).map(r=>{let i=[];try{i=t.inspector?.properties(r.id)??[]}catch{}const a=t.hierarchy.object3D?.(r.id)?.type;return{id:r.id,name:r.label,type:r.typeLabel??a??"Light",enabled:DY(t,r.id,i,"enabled",GEt),color:DY(t,r.id,i,"color",g2n),intensity:DY(t,r.id,i,"intensity",QEt),range:DY(t,r.id,i,"range",QEt),shadows:DY(t,r.id,i,"shadows",GEt)}})}function v2n(t,r,i,a){if(!t.inspector)return 0;let l=0;for(const d of r){let _=null;try{_=mQt(t.inspector.properties(d),i)}catch{continue}!_||_.readonly||(n4t(t,d,_.path,a),l++)}return l}function b2n(t,r){return t===null&&r===null?0:t===null?1:r===null?-1:typeof t=="string"&&typeof r=="string"?t.localeCompare(r,void 0,{numeric:!0,sensitivity:"base"}):Number(t)-Number(r)}function KEt(t,r){return r==="name"||r==="type"?t[r]:t[r].value}function PY({label:t,sortKey:r,activeKey:i,direction:a,onSort:l}){const d=r===i;return z.jsxs(fo,{type:"button",variant:"ghost",size:"compact",className:"vgai-light-explorer-sort","aria-label":`Sort lights by ${t}`,onClick:()=>l(r),children:[t,d?z.jsx(So,{icon:a==="ascending"?iDr:aIt,size:"xs"}):null]})}function mbe(){return z.jsx("span",{className:"vgai-light-explorer-unavailable",children:"—"})}function A2n({row:t,edit:r}){return t.enabled.supported?z.jsx(SE,{"aria-label":`${t.enabled.value?"Disable":"Enable"} ${t.name}`,checked:t.enabled.value??!1,disabled:!t.enabled.writable,onChange:i=>r("enabled",i.target.checked)}):z.jsx(mbe,{})}function S2n({row:t,edit:r}){return!t.color.supported||!t.color.value?z.jsx(mbe,{}):z.jsxs("div",{className:"vgai-light-explorer-color",children:[z.jsx(v3t,{"aria-label":`Color for ${t.name}`,value:t.color.value,disabled:!t.color.writable,onChange:i=>r("color",i.target.value)}),z.jsx("span",{children:t.color.value})]})}function YEt({row:t,field:r,step:i,edit:a}){const l=t[r];return l.supported?z.jsx(SX,{value:l.value,disabled:!l.writable,precision:2,step:i,onChange:d=>a(r,d)}):z.jsx(mbe,{})}function x2n({row:t,edit:r}){return t.shadows.supported?z.jsx(SE,{"aria-label":`Toggle shadows for ${t.name}`,checked:t.shadows.value??!1,disabled:!t.shadows.writable,onChange:i=>r("shadows",i.target.checked)}):z.jsx(mbe,{})}function w2n({row:t,adapter:r,visibleRows:i,selected:a,selectionAnchor:l,edit:d}){const _=(g,b)=>d(t,g,b);return z.jsxs("tr",{"data-selected":a.has(t.id)||void 0,children:[z.jsx("td",{children:z.jsx(A2n,{row:t,edit:_})}),z.jsx("td",{children:z.jsx(fo,{type:"button",variant:"ghost",size:"compact",className:"vgai-light-explorer-name","aria-pressed":a.has(t.id),onClick:g=>{E2n(r,i,t.id,l.current,g.shiftKey,g.metaKey||g.ctrlKey),g.shiftKey||(l.current=t.id)},children:t.name})}),z.jsx("td",{className:"vgai-light-explorer-type",children:t.type}),z.jsx("td",{children:z.jsx(S2n,{row:t,edit:_})}),z.jsx("td",{children:z.jsx(YEt,{row:t,field:"intensity",step:.1,edit:_})}),z.jsx("td",{children:z.jsx(YEt,{row:t,field:"range",step:.5,edit:_})}),z.jsx("td",{children:z.jsx(x2n,{row:t,edit:_})})]})}function C2n(t,r,i){if(!r.has(t.id))return[t.id];const a=i.filter(l=>r.has(l.id));return a.length>1?a.map(l=>l.id):[t.id]}function E2n(t,r,i,a,l,d){if(!t.selection)return;const _=t.selection.get();if(l&&a){const g=r.findIndex(S=>S.id===a),b=r.findIndex(S=>S.id===i);if(g>=0&&b>=0){const S=r.slice(Math.min(g,b),Math.max(g,b)+1).map(k=>k.id);k0(t,d?[...new Set([..._,...S])]:S,{intent:"exact"});return}}if(d){k0(t,_.includes(i)?_.filter(g=>g!==i):[..._,i],{intent:"exact"});return}k0(t,[i],{intent:"exact"})}function T2n(){const t=D0();Xe.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getSnapshot),Xe.useSyncExternalStore(Aw,Sb,Sb),Xe.useSyncExternalStore(Nee,MP,MP);const{adapter:r}=wm(t),[,i]=Xe.useReducer(ue=>ue+1,0);Xe.useEffect(()=>r.subscribe?.(i),[r]);const[a,l]=Xe.useState(""),[d,_]=Xe.useState("all"),[g,b]=Xe.useState("name"),[S,k]=Xe.useState("ascending"),w=Xe.useRef(null),N=y2n(r),P=Xe.useMemo(()=>[...new Set(N.map(ue=>ue.type))].sort((ue,fe)=>ue.localeCompare(fe)),[N]),j=a.trim().toLocaleLowerCase(),J=N.filter(ue=>(d==="all"||ue.type===d)&&(!j||ue.name.toLocaleLowerCase().includes(j)||ue.type.toLocaleLowerCase().includes(j))).sort((ue,fe)=>{const se=b2n(KEt(ue,g),KEt(fe,g));return S==="ascending"?se:-se}),X=new Set(r.selection?.get()??[]),G=N.filter(ue=>X.has(ue.id)).length,ee=ue=>{ue===g?k(fe=>fe==="ascending"?"descending":"ascending"):(b(ue),k("ascending"))},xe=(ue,fe,se)=>{const de=C2n(ue,X,J);v2n(r,de,fe,se)>0&&t.notifyIngestEdit()};return z.jsxs("section",{className:"vgai-light-explorer","aria-label":"Light Explorer",children:[z.jsxs("div",{className:"vgai-light-explorer-toolbar",children:[z.jsx(k_,{"aria-label":"Search lights",placeholder:"Search lights…",value:a,onChange:ue=>l(ue.target.value)}),z.jsxs(bS,{"aria-label":"Filter lights by type",value:d,onChange:ue=>_(ue.target.value),children:[z.jsx("option",{value:"all",children:"All types"}),P.map(ue=>z.jsx("option",{value:ue,children:ue},ue))]}),z.jsxs("span",{className:"vgai-light-explorer-summary",children:[N.length," ",N.length===1?"light":"lights",G>0?` · ${G} selected`:""]})]}),N.length===0?z.jsx("div",{className:"vgai-light-explorer-empty",children:"The active document does not expose any lights."}):z.jsxs("div",{className:"vgai-light-explorer-scroll",children:[z.jsxs("table",{className:"vgai-light-explorer-table",children:[z.jsx("thead",{children:z.jsxs("tr",{children:[z.jsx("th",{className:"vgai-light-explorer-check-column",scope:"col",children:"On"}),z.jsx("th",{scope:"col",children:z.jsx(PY,{label:"Name",sortKey:"name",activeKey:g,direction:S,onSort:ee})}),z.jsx("th",{scope:"col",children:z.jsx(PY,{label:"Type",sortKey:"type",activeKey:g,direction:S,onSort:ee})}),z.jsx("th",{scope:"col",children:"Color"}),z.jsx("th",{scope:"col",children:z.jsx(PY,{label:"Intensity",sortKey:"intensity",activeKey:g,direction:S,onSort:ee})}),z.jsx("th",{scope:"col",children:z.jsx(PY,{label:"Range",sortKey:"range",activeKey:g,direction:S,onSort:ee})}),z.jsx("th",{scope:"col",children:z.jsx(PY,{label:"Shadows",sortKey:"shadows",activeKey:g,direction:S,onSort:ee})})]})}),z.jsx("tbody",{children:J.map(ue=>z.jsx(w2n,{row:ue,adapter:r,visibleRows:J,selected:X,selectionAnchor:w,edit:xe},ue.id))})]}),J.length===0?z.jsx("div",{className:"vgai-light-explorer-empty",children:"No lights match the current filters."}):null]})]})}const k2n=t0e();function I2n(){const{error:t,warn:r}=ua.counts;return t>0?{count:t+r,severity:"error"}:r>0?{count:r,severity:"warn"}:null}function D2n(){k2n.ensure(t=>{t(DMe({..._ee.console,order:-100,Content:m2n,badge:I2n,subscribeBadge:ua.subscribe,badgeSnapshot:ua.getSnapshot,visibleByDefault:!1,closeable:!0})),t(DMe({..._ee.lightExplorer,order:21,Content:T2n,visibleByDefault:!1,closeable:!0}))})}const P2n=5742335;function hQt(t,r,i){return t<<16|r<<8|i}function XEt(t){const r=/^#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.exec(t.trim())?.[1];if(r){const l=r.length===3?[...r].map(d=>`${d}${d}`).join(""):r;return Number.parseInt(l.slice(0,6),16)}const i=/^rgba?\(\s*(\d+(?:\.\d+)?)\s*(?:,\s*|\s+)(\d+(?:\.\d+)?)\s*(?:,\s*|\s+)(\d+(?:\.\d+)?)/i.exec(t.trim());if(!i)return null;const a=i.slice(1,4).map(l=>Math.round(Number(l)));return a.some(l=>l<0||l>255)?null:hQt(a[0],a[1],a[2])}function gQt(t){const r=XEt(t);if(r!==null||typeof document>"u")return r;if(typeof CSS<"u"&&!CSS.supports("color",t))return null;const i=document.createElement("canvas").getContext("2d");return i?(i.fillStyle="#010203",i.fillStyle=t,XEt(String(i.fillStyle))):null}function D9(t){return typeof document>"u"?null:t?.closest(`.${aMe}`)??document.querySelector(`.${aMe}`)}function N2n(t){const r=Math.round((t>>16&255)*.42),i=Math.round((t>>8&255)*.42),a=Math.round((t&255)*.42);return hQt(r,i,a)}function l9(t,r){return t&&typeof getComputedStyle<"u"?getComputedStyle(t).getPropertyValue(r).trim():""}function $4n(t){const r=D9(t),i=l9(r,"--vgai-viewport-selection")||l9(r,"--vgai-accent"),a=gQt(i||oz.color.accent.default)??P2n;return{visible:a,hidden:N2n(a)}}function q4n(t){return O2n(t).background!==null}function O2n(t){const r=D9(t),i=a=>{const l=l9(r,a);return l?gQt(l):null};return{background:i("--vgai-viewport-background"),grid:i("--vgai-viewport-grid"),axisX:i("--vgai-viewport-axis-x"),axisY:i("--vgai-viewport-axis-y"),active:i("--vgai-viewport-active")}}function z4n(t){const r=l9(D9(t),"--vgai-viewport-gizmo-size");if(!r)return null;const i=Number.parseFloat(r);return Number.isFinite(i)&&i>0?i:null}function F2n(t){const r=l9(D9(t),"--vgai-viewport-shelf-tool");return r==="select"||r==="transform"?r:null}function U4n(t){const r=l9(D9(t),"--vgai-viewport-up-axis");return r==="y"||r==="z"?r:null}function V4n(t){const r=l9(D9(t),"--vgai-viewport-box-select");return r==="contain"||r==="touch"?r:null}function J4n(t,r){r();const i=D9(t);if(!i||typeof MutationObserver>"u")return()=>{};const a=new MutationObserver(r);return a.observe(i,{attributes:!0,attributeFilter:["style"]}),()=>a.disconnect()}function W4n(t,r){return r.skinnedMeshes>0?"skinned":r.uniqueBones>0?"rigged":t.clips>0?"animated":"static"}const R2n=["map","alphaMap","aoMap","bumpMap","displacementMap","emissiveMap","envMap","lightMap","metalnessMap","normalMap","roughnessMap","specularMap"];function M2n(t){if(!("color"in t))return null;const r=t.color;return r?.isColor===!0?`#${r.getHexString()}`:null}function L2n(t){let r=0;for(const i of Object.values(t.attributes)){const a=i.array;for(let l=0;l<a.length;l++)Number.isFinite(Number(a[l]))||r++}return r}function ZEt(t){if(!t)return null;const r=new xS,i=new Tc;for(let a=0;a<t.count;a++)i.set(t.getX(a),t.getY(a),t.getZ(a)),Number.isFinite(i.x)&&Number.isFinite(i.y)&&Number.isFinite(i.z)&&r.expandByPoint(i);return r.isEmpty()?null:r}function j2n(t){const r=ZEt(t.getAttribute("position"));if(!r)return null;for(const i of t.morphAttributes.position??[]){const a=ZEt(i);a&&(t.morphTargetsRelative?(r.expandByPoint(new Tc().addVectors(r.min,a.min)),r.expandByPoint(new Tc().addVectors(r.max,a.max))):r.union(a))}return r}function eTt(t){return t.matrixAutoUpdate?new SS().compose(t.position,t.quaternion,t.scale):t.matrix.clone()}function B2n(t,r,i){if(CE(r,"editorHelper")||r.isSkeletonHelper)return;const a=r;if(!a.isMesh&&!a.isLine&&!a.isPoints||!a.geometry)return;const l=j2n(a.geometry);if(!l)return;const d=r;if(!d.isInstancedMesh){t.union(l.clone().applyMatrix4(i));return}const _=new SS;for(let g=0;g<d.count;g++)d.getMatrixAt(g,_),t.union(l.clone().applyMatrix4(new SS().multiplyMatrices(i,_)))}function $2n(t){const r=new xS,i=[];for(let d=t.parent;d;d=d.parent)i.push(d);const a=new SS;for(let d=i.length-1;d>=0;d--)a.multiply(eTt(i[d]));const l=(d,_)=>{const g=new SS().multiplyMatrices(_,eTt(d));B2n(r,d,g);for(const b of d.children)l(b,g)};return l(t,a),r.isEmpty()?null:r}function H4n(t){const r=new Set,i=new Set,a=new Map,l=new Map,d=new Map,_=new Set,g=[],b=[];let S=0,k=0,w=0,N=0,P=0,j=0,J=0,X=0,G=0,ee=0,xe=0,ue=0,fe=0,se=0,de=0;t.traverse(tt=>{if(CE(tt,"editorHelper")||tt.isSkeletonHelper)return;S++;let Ct=0;for(let Le=tt.parent;Le&&Le!==t.parent;Le=Le.parent)Ct++;b.push({id:tt.uuid,name:tt.name||tt.type,type:tt.type,depth:Ct}),tt.isBone&&j++,tt.isLOD&&(se++,de+=tt.levels.length);const Ot=tt,vt=tt;if(!vt.isMesh&&!vt.isLine&&!vt.isPoints)return;k++,Ot.isInstancedMesh&&xe++,Ot.isSkinnedMesh&&ue++;const Et=Ot.geometry;if(Et){fe+=L2n(Et);const Le=Et.getAttribute("position");N+=Le?.count??0,P+=Et.index?Math.floor(Et.index.count/3):Math.floor((Le?.count??0)/3),w+=Math.max(Et.groups.length,1),J+=Et.morphAttributes.position?.length??0,Et.index?(G++,X+=Et.index.array.byteLength):ee++;for(const[cr,Yt]of Object.entries(Et.attributes)){X+=Yt.array.byteLength;const Lr=d.get(cr)??{itemSize:Yt.itemSize,meshes:0};Lr.meshes++,d.set(cr,Lr),/^uv\d*$/.test(cr)&&_.add(cr)}}const Tt=Array.isArray(Ot.material)?Ot.material:Ot.material?[Ot.material]:[];for(const Le of Tt){r.add(Le);const cr=l.get(Le)??new Set;cr.add(tt),l.set(Le,cr);const Yt=a.get(Le)??[];for(const Lr of R2n){const nn=Le[Lr];if(nn?.isTexture!==!0)continue;i.add(nn),Yt.includes(Lr)||Yt.push(Lr);const on=nn.image;g.some(gr=>gr.materialId===Le.uuid&&gr.slot===Lr)||g.push({materialId:Le.uuid,materialName:Le.name||Le.type,slot:Lr,textureName:nn.name||nn.source.data?.src||"Texture",width:on?.width??null,height:on?.height??null,format:nn.format,colorSpace:nn.colorSpace||"none"})}a.set(Le,Yt)}});for(const tt of i){const Ct=tt.image;X+=(Ct?.width??0)*(Ct?.height??0)*4}const qe=$2n(t)?.getSize(new Tc)??null;return{nodes:S,meshes:k,primitives:w,vertices:N,triangles:P,materials:r.size,textures:i.size,bones:j,clips:t.animations.length,morphTargets:J,memoryBytes:X,bounds:qe?{x:qe.x,y:qe.y,z:qe.z}:null,geometry:{attributes:[...d.entries()].map(([tt,Ct])=>({name:tt,itemSize:Ct.itemSize,meshCount:Ct.meshes})).sort((tt,Ct)=>tt.name.localeCompare(Ct.name)),uvChannels:[..._].sort(),indexedMeshes:G,nonIndexedMeshes:ee,instancedMeshes:xe,skinnedMeshes:ue,nonFiniteAttributeValues:fe,lodGroups:se,lodLevels:de},animationClips:t.animations.map((tt,Ct)=>{const Ot=new Set;let vt=0;for(const Et of tt.tracks){vt+=Et.times.length;const Tt=she.parseTrackName(Et.name);Tt.nodeName&&Ot.add(Tt.nodeName)}return{id:`${Ct}:${tt.uuid}`,name:tt.name||`Clip ${Ct+1}`,duration:tt.duration,tracks:tt.tracks.length,keyframes:vt,targets:[...Ot].sort(),rootMotion:H2n(tt).length>1}}),hierarchy:b,materialNames:[...r].map(tt=>tt.name||tt.type),textureNames:[...i].map(tt=>tt.name||tt.source.data?.src||"Texture"),materialSlots:[...r].map(tt=>({id:tt.uuid,name:tt.name||tt.type,type:tt.type,textureSlots:a.get(tt)??[],usageCount:l.get(tt)?.size??0,meshNames:[...l.get(tt)??[]].map(Ct=>Ct.name||Ct.type).sort(),color:M2n(tt),transparent:tt.transparent})),textureBindings:g}}function q2n(t){const r=t.geometry.getAttribute("skinIndex"),i=t.geometry.getAttribute("skinWeight");if(!r||!i)return{weightedVertices:0,nonNormalizedVertices:0,zeroWeightVertices:0,invalidJointIndices:0};const a=Math.min(r.count,i.count);let l=0,d=0,_=0;for(let g=0;g<a;g++){const b=[i.getX(g),i.getY(g),i.getZ(g),i.getW(g)],S=[r.getX(g),r.getY(g),r.getZ(g),r.getW(g)],k=b.reduce((w,N)=>w+N,0);k<=1e-6?d++:Math.abs(k-1)>.001&&l++,_+=b.filter((w,N)=>w>1e-6&&(S[N]<0||S[N]>=t.skeleton.bones.length)).length}return{weightedVertices:a,nonNormalizedVertices:l,zeroWeightVertices:d,invalidJointIndices:_}}function z2n(t){let r=0;for(const i of t.times)Number.isFinite(i)||r++;for(const i of t.values)Number.isFinite(i)||r++;return r}function U2n(t,r){const i=she.parseTrackName(r.name).nodeName;return i&&!she.findNode(t,i)?i:null}function V2n(t){let r=0;const i=new Set;for(const a of t.animations)for(const l of a.tracks){r+=z2n(l);const d=U2n(t,l);d&&i.add(d)}return{nonFiniteValues:r,unresolvedTargets:i}}function G4n(t){const r=new Set,i=new Set,a=new Set;let l=0,d=0,_=0,g=0,b=0,S=0;const k=new Set,w=new Set,N=new Set;t.traverse(G=>{r.add(G);const ee=G;ee.isBone&&a.add(ee)}),t.traverse(G=>{const ee=G;if(!ee.isSkinnedMesh)return;l++,N.add(ee.bindMode),i.add(ee.skeleton),ee.skeleton.bones.length!==ee.skeleton.boneInverses.length&&S++;for(const ue of ee.skeleton.bones)a.add(ue),r.has(ue)||k.add(ue);const xe=q2n(ee);d+=xe.weightedVertices,_+=xe.nonNormalizedVertices,g+=xe.zeroWeightVertices,b+=xe.invalidJointIndices});const P=V2n(t);for(const G of a)(!G.parent?.isBone||!a.has(G.parent))&&w.add(G.name||G.uuid);const j=P.nonFiniteValues,J=P.unresolvedTargets,X=_===0&&g===0&&b===0&&S===0&&k.size===0&&j===0&&J.size===0;return{kind:l>0?"skinned":a.size>0?"rigid":"none",skinnedMeshes:l,skeletons:i.size,uniqueBones:a.size,weightedVertices:d,nonNormalizedVertices:_,zeroWeightVertices:g,invalidJointIndices:b,inverseBindMismatches:S,externalBones:k.size,nonFiniteAnimationValues:j,unresolvedTrackTargets:[...J].sort(),rootBones:[...w].sort(),bindModes:[...N].sort(),valid:X}}function Q4n(t){const r=t.clone().normalize();for(const i of["front","back","left","right","top","bottom"])if(J2n(i).angleTo(r)<.0087)return`${i[0]?.toUpperCase()}${i.slice(1)}`;return null}function J2n(t){const r={front:[0,0,1],back:[0,0,-1],left:[-1,0,0],right:[1,0,0],top:[0,1,0],bottom:[0,-1,0],isometric:[1,.72,1]};return new Tc(...r[t]).normalize()}function W2n(t){let r=!1,i=!1,a=!1,l=!1;return t.traverse(d=>{const _=d;r||=!!_.geometry?.getAttribute("uv"),i||=!!_.geometry?.getAttribute("color"),a||=!!(d.isBone||_.isSkinnedMesh),l||=d.isLOD===!0}),[{mode:"lit",available:!0},{mode:"unlit",available:!0},{mode:"wireframe",available:!0},{mode:"normals",available:!0},{mode:"uv",available:r,...r?{}:{reason:"No UV channel"}},{mode:"vertex-colors",available:i,...i?{}:{reason:"No vertex colors"}},{mode:"bounds",available:!0},{mode:"skeleton",available:a,...a?{}:{reason:"No skeleton"}},{mode:"collision",available:!1,reason:"No collision metadata"},{mode:"lod",available:l,...l?{}:{reason:"No LOD groups"}}]}function H2n(t){const r=t.tracks.filter(l=>l.ValueTypeName==="vector"&&l.name.toLowerCase().endsWith(".position")),i=r.find(l=>/(^|[./])(root|hips|armature)[./]/i.test(l.name))??r[0];if(!i||i.values.length<6)return[];const a=[];for(let l=0;l+2<i.values.length;l+=3)a.push(new Tc(i.values[l],i.values[l+1],i.values[l+2]));return a}const aI=new Map,hqe=new Map;function yQt(t){let r=hqe.get(t);return r||(r={frameListeners:new Set,helpers:new Map},hqe.set(t,r)),r}const gqe=new Set,yqe=new Set;function hbe(){for(const r of aI.values())if(r.presenting)return r;const t=I_();if(t!==null){const r=aI.get(t);if(r)return r}return aI.values().next().value??null}let Qme=null;function tTt(){Qme=null;const t=bQt();for(const r of yqe)r(t)}function G2n(t,r){const i=yQt(t);return{documentId:t,rig:()=>aI.get(t)?.rig??r,setHelper:(a,l)=>{i.helpers.set(a,l),aI.get(t)?.setHelper(a,l)},onFrame:a=>(i.frameListeners.add(a),()=>{i.frameListeners.delete(a)})}}function K4n(t,r,i,a){const l=yQt(a.documentId),d={documentId:a.documentId,rig:t,present:r,setHelper:i,frameListeners:l.frameListeners,helpers:l.helpers,presenting:!1};aI.set(a.documentId,d);for(const[_,g]of d.helpers)i(_,g);return tTt(),()=>{aI.get(a.documentId)===d&&(aI.delete(a.documentId),tTt())}}function Q2n(t,r){const i=hbe();i&&(i.helpers.set(t,r),i.setHelper(t,r))}function gte(){return hbe()?.rig??null}function K2n(t){const r=hbe();if(!r)return null;const i=r.present(t);if(!i)return null;r.presenting=!0;let a=!1;return{worldId:i.worldId,dispose:()=>{a||(a=!0,r.presenting=!1),i.dispose()}}}function vQt(t){return gqe.add(t),()=>{gqe.delete(t)}}function bQt(){return Qme||(Qme=[...aI.values()].map(t=>G2n(t.documentId,t.rig))),Qme}function Y2n(t){const r=hqe.get(t);return r?[...r.helpers].filter(([,i])=>i!==null).map(([i])=>i):[]}function X2n(t){return yqe.add(t),()=>{yqe.delete(t)}}function Y4n(t,r){const i=aI.get(t);if(i){for(const a of i.frameListeners)a(r);if(hbe()===i)for(const a of gqe)a(r)}}function Z2n(){return z.jsxs("svg",{viewBox:"0 0 16 16",className:"vgai-viewport-overlays-glyph","aria-hidden":"true",focusable:"false",children:[z.jsx("path",{d:"M5.24 4.51 A5.3 5.3 0 1 1 11.89 11.16 A5.85 5.85 0 0 0 5.24 4.51 Z",fill:"currentColor"}),z.jsx("circle",{cx:"6.1",cy:"10.3",r:"4.4",fill:"none",stroke:"currentColor",strokeWidth:"1.1"})]})}function eSn({label:t="Overlays",choices:r,master:i,glyph:a}){const[l,d]=Xe.useState(!1),_=Xe.useRef(null),g=r.some(w=>w.enabled),b=i?.enabled??g,S=a??z.jsx(So,{icon:b?Zqe:tze,size:"md"});Xe.useEffect(()=>{if(!l)return;const w=N=>{_.current&&!_.current.contains(N.target)&&d(!1)};return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[l]);const k=l?z.jsxs(OP,{className:"vgai-helpers-menu",onDismiss:()=>d(!1),children:[i?z.jsxs(z.Fragment,{children:[z.jsxs(Wa,{role:"menuitemcheckbox","aria-checked":i.enabled,onSelect:i.onToggle,children:[z.jsx("span",{className:"vgai-menu-check",children:i.enabled&&z.jsx(So,{icon:S8,size:"xs"})}),"Show ",t]}),z.jsx(Ny,{})]}):null,r.map(w=>z.jsxs(Wa,{role:"menuitemcheckbox","aria-checked":w.enabled,disabled:w.disabled,onSelect:w.onToggle,children:[z.jsx("span",{className:"vgai-menu-check",children:w.enabled&&z.jsx(So,{icon:S8,size:"xs"})}),w.label]},w.id))]}):null;return z.jsxs("div",{ref:_,className:"vgai-viewport-popover-anchor",children:[i?z.jsxs(Tze,{children:[z.jsx(ph,{text:`${t}: ${b?"On":"Off"}`,children:z.jsx(rf,{"aria-label":`Toggle ${t.toLowerCase()}`,"aria-pressed":b,size:"comfortable",onClick:i.onToggle,children:S})}),z.jsx(rf,{"aria-label":`Choose ${t.toLowerCase()}`,"aria-expanded":l,size:"comfortable",onClick:()=>d(!l),children:z.jsx(So,{icon:x8,size:"xs"})})]}):z.jsx(ph,{text:`${t}: ${b?"On":"Off"}`,children:z.jsx(rf,{"aria-label":`Choose ${t.toLowerCase()}`,"aria-expanded":l,"aria-pressed":b,size:"comfortable",onClick:()=>d(!l),children:S})}),k]})}const AQt=[{mode:"solid",label:"Material",description:"Authored materials and lighting"},{mode:"clay",label:"Solid",description:"Neutral flat-shaded geometry"},{mode:"unlit",label:"Unlit",description:"Base color without scene lighting"},{mode:"wireframe",label:"Wireframe",description:"Renderable triangle edges"},{mode:"matcap",label:"Matcap",description:"Neutral clay sphere — form without color"},{mode:"normals",label:"Normals",description:"Surface-normal direction colors"},{mode:"overdraw",label:"Overdraw",description:"Additive overlap visualization"}],tSn=[{mode:"wireframe",glyph:"wireframe",label:"Wireframe"},{mode:"clay",glyph:"sphere",label:"Solid"},{mode:"solid",glyph:"preview",label:"Material"}];function rSn({glyph:t}){return z.jsxs("svg",{viewBox:"0 0 16 16",className:"vgai-viewport-shading-glyph","aria-hidden":"true",focusable:"false",children:[t==="sphere"?z.jsx("circle",{cx:"8",cy:"8",r:"7.3",fill:"currentColor"}):z.jsx("circle",{cx:"8",cy:"8",r:"7.3",fill:"none",stroke:"currentColor",strokeWidth:"1.05"}),t==="wireframe"?z.jsxs("g",{stroke:"currentColor",strokeWidth:"1.05",children:[z.jsx("line",{x1:"1.7",y1:"5.4",x2:"14.3",y2:"5.4"}),z.jsx("line",{x1:"1.7",y1:"10.6",x2:"14.3",y2:"10.6"}),z.jsx("line",{x1:"5.4",y1:"1.7",x2:"5.4",y2:"14.3"})]}):null,t==="preview"?z.jsx("path",{d:"M7.73 1.23 L7.73 10.43 L1.22 8.04 A6.78 6.78 0 0 1 7.73 1.23 Z",fill:"currentColor"}):null]})}function SQt({mode:t,onChange:r,choices:i,disabled:a=!1,segments:l,children:d}){const[_,g]=Xe.useState(!1),b=Xe.useRef(null),S=i.find(w=>w.mode===t)??i[0];if(!S)return null;const k=_&&!a?z.jsxs(JR,{id:"vgai-viewport-shading-menu",anchorRef:b,"aria-label":"Viewport shading modes",onDismiss:()=>g(!1),style:{minWidth:230},children:[i.map(w=>z.jsxs(Wa,{role:"menuitemradio","aria-checked":w.mode===t,onSelect:()=>{r(w.mode),g(!1)},style:{display:"grid",gridTemplateColumns:"14px 1fr",gap:7},children:[z.jsx("span",{style:{opacity:w.mode===t?1:0},children:z.jsx(So,{icon:S8,size:"xs"})}),z.jsxs("span",{children:[z.jsx("span",{style:{display:"block"},children:w.label}),z.jsx("span",{style:{display:"block",color:Oo.content.dim,fontSize:10},children:w.description})]})]},w.mode)),d?z.jsxs(z.Fragment,{children:[z.jsx(Ny,{}),z.jsx("div",{className:"vgai-viewport-shading-options",children:d})]}):null]}):null;return l?z.jsxs("div",{className:"vgai-viewport-popover-anchor",children:[z.jsxs("span",{className:"vgai-viewport-shading-segments",role:"group","aria-label":"Viewport shading",children:[l.map(w=>z.jsx(ph,{text:`Viewport shading: ${w.label}`,children:z.jsx(rf,{size:"compact",shape:"segment",variant:"secondary","aria-pressed":w.mode===t,"aria-label":`Viewport shading: ${w.label}`,disabled:a,onClick:()=>r(w.mode),children:z.jsx(rSn,{glyph:w.glyph})})},w.mode)),z.jsx(ph,{text:"Shading options",children:z.jsx(rf,{ref:b,size:"compact",shape:"segment",variant:"secondary","aria-label":"Shading options","aria-haspopup":"menu","aria-expanded":_,"aria-controls":_?"vgai-viewport-shading-menu":void 0,disabled:a,onClick:()=>g(w=>!w),children:z.jsx(So,{icon:x8,size:"xs"})})})]}),k]}):z.jsxs("div",{style:{position:"relative"},children:[z.jsx(ph,{text:`Viewport shading: ${S.label}`,children:z.jsxs(fo,{ref:b,type:"button",size:"compact",variant:"secondary","aria-label":`Viewport shading: ${S.label}`,"aria-haspopup":"menu","aria-expanded":_,"aria-controls":_?"vgai-viewport-shading-menu":void 0,disabled:a,onClick:()=>g(w=>!w),style:{display:"inline-flex",alignItems:"center",gap:5,minWidth:66},children:[z.jsx("span",{children:S.label}),z.jsx(So,{icon:x8,size:"xs"})]})}),k]})}function X4n({mode:t,onChange:r,disabled:i=!1}){return z.jsx(SQt,{mode:t,onChange:r,choices:AQt,disabled:i})}const rTt=()=>()=>{},S_e=()=>0,nSn=[{key:"skeletons",label:"Bones"},{key:"weights",label:"Weights"}];function iSn({documentId:t,assetPath:r}){Xe.useSyncExternalStore(e0e,I8,I8);const i=Pw(t);Xe.useSyncExternalStore(Uye,w8,w8),Xe.useSyncExternalStore(i?.subscribe??rTt,i?.getSnapshot??S_e,i?.getSnapshot??S_e),Xe.useSyncExternalStore(UHt,vye,vye);const a=uee(t);Xe.useSyncExternalStore(a?.subscribe??rTt,a?.getSnapshot??S_e,a?.getSnapshot??S_e);const l=Y2n(t),[d,_]=Xe.useState(null),[g,b]=Xe.useState(null),[S,k]=Xe.useState(!1),[w,N]=Xe.useState(!1),P=Xe.useRef(null),j=Xe.useRef(null);if(!i)return null;const J=i.presentation(),X=new Set(W2n(i.root).filter(fe=>fe.available).map(fe=>fe.mode)),G=[...AQt,...X.has("uv")?[{mode:"uv",label:"UV",description:"UV coordinates as surface color"}]:[],...X.has("vertex-colors")?[{mode:"vertex-colors",label:"Vertex colors",description:"Authored color attributes without textures"}]:[]],ee=async fe=>{if(r){b(null);try{await qGt().saveThumbnailFraming(r,fe?void 0:i.cameraPose())}catch(se){b(se instanceof Error?se.message:String(se))}}},xe=async()=>{b(null);try{const fe={background:J.background},se=r?.toLowerCase().endsWith(".spz")?await tNt(r,fe):j0e(i.root,fe);_(`data:image/png;base64,${se.contactSheet.base64}`)}catch(fe){b(fe instanceof Error?fe.message:String(fe))}},ue=i.selection().length>0?"Frame selection":"Frame all";return z.jsxs("div",{className:"vgai-model-document-header",children:[z.jsxs(NP,{compact:!0,label:"Viewport view controls",className:"vgai-model-viewport-toolbar vgai-model-viewport-toolbar--view",children:[z.jsx(ph,{text:ue,children:z.jsx(rf,{"aria-label":ue,onClick:()=>i.frame(),children:z.jsx(So,{icon:$kt,size:"md"})})}),z.jsxs("div",{className:"vgai-viewport-popover-anchor",children:[z.jsx(ph,{text:"Camera orientation and projection",children:z.jsxs(fo,{ref:P,type:"button",size:"compact",variant:"secondary","aria-label":`Camera view: ${J.projection}`,"aria-haspopup":"menu","aria-expanded":S,onClick:()=>k(fe=>!fe),className:"vgai-model-toolbar-labelled-control",children:[z.jsx(So,{icon:f9,size:"sm"}),z.jsx("span",{children:J.projection==="perspective"?"Perspective":"Orthographic"}),z.jsx(So,{icon:x8,size:"xs"})]})}),S&&z.jsxs(JR,{anchorRef:P,align:"start",clamp:!0,"aria-label":"Camera view",onDismiss:()=>k(!1),style:{minWidth:210},children:[["front","right","top","isometric"].map(fe=>z.jsx(Wa,{onSelect:()=>{i.setViewPreset(fe),k(!1)},children:fe==="isometric"?"Perspective 3/4":`${fe[0]?.toUpperCase()}${fe.slice(1)} view`},fe)),z.jsx(Ny,{}),["perspective","orthographic"].map(fe=>z.jsxs(Wa,{role:"menuitemradio","aria-checked":J.projection===fe,onSelect:()=>{i.setProjection(fe),k(!1)},children:[z.jsx("span",{className:"vgai-menu-check",children:J.projection===fe&&z.jsx(So,{icon:S8,size:"xs"})}),fe==="perspective"?"Perspective":"Orthographic"]},fe))]})]}),X.has("skeleton")?z.jsx(ph,{text:`Rig: ${J.skeleton?"Visible":"Hidden"}`,children:z.jsx(rf,{"aria-label":"Toggle rig overlay","aria-pressed":J.skeleton,onClick:()=>i.setSkeleton(!J.skeleton),children:z.jsx(So,{icon:JIr,size:"md"})})}):null,vIt("object3d-document").map(({id:fe,Component:se})=>z.jsx(se,{documentId:t},fe))]}),z.jsxs(NP,{compact:!0,label:"Viewport preview controls",className:"vgai-model-viewport-toolbar vgai-model-viewport-toolbar--preview",children:[z.jsx(SQt,{mode:J.mode,onChange:fe=>i.setMode(fe),choices:G,segments:tSn,children:i.lightingAvailable()?z.jsxs(z.Fragment,{children:[z.jsxs("label",{children:[z.jsx("span",{children:"Lighting"}),z.jsxs(bS,{"aria-label":"Lighting preset",value:J.lighting,onChange:fe=>i.setLighting(fe.target.value),children:[z.jsx("option",{value:"studio",children:"Studio"}),z.jsx("option",{value:"outdoor",children:"Outdoor"}),z.jsx("option",{value:"flat",children:"Flat"})]})]}),z.jsxs("label",{children:[z.jsx("span",{children:"Exposure"}),z.jsx(k_,{"aria-label":"Preview exposure",type:"range",min:"0.2",max:"2",step:"0.1",value:J.exposure,onChange:fe=>i.setExposure(Number(fe.target.value))}),z.jsx(Ru,{as:"span",variant:"caption",children:J.exposure.toFixed(1)})]})]}):null}),z.jsx(eSn,{glyph:z.jsx(Z2n,{}),choices:[{id:"grid",label:"Grid",enabled:J.grid,onToggle:()=>i.setGrid(!J.grid)},{id:"bounds",label:"Bounds",enabled:J.bounds,onToggle:()=>i.setBounds(!J.bounds)},...a===null?[]:nSn.filter(fe=>l.includes(fe.key)).map(fe=>({id:fe.key,label:fe.label,enabled:a.helperVisibility[fe.key],onToggle:()=>a.toggleHelperType(fe.key)}))]}),z.jsxs("div",{className:"vgai-viewport-popover-anchor",children:[z.jsx(ph,{text:"Asset preview actions",children:z.jsx(rf,{ref:j,"aria-label":"Asset preview actions","aria-haspopup":"menu","aria-expanded":w,onClick:()=>N(fe=>!fe),children:z.jsx(So,{icon:Lkt,size:"md"})})}),w&&z.jsxs(JR,{anchorRef:j,clamp:!0,"aria-label":"Asset preview actions",onDismiss:()=>N(!1),style:{minWidth:210},children:[z.jsxs(Wa,{onSelect:()=>{N(!1),xe()},children:[z.jsx(So,{icon:zye,size:"sm"}),"Capture preview"]}),r?z.jsxs(z.Fragment,{children:[z.jsx(Wa,{onSelect:()=>{N(!1),ee(!1)},children:"Save thumbnail framing"}),z.jsx(Wa,{onSelect:()=>{N(!1),ee(!0)},children:"Reset thumbnail framing"})]}):null,z.jsx(Ny,{}),z.jsxs(Wa,{onSelect:()=>{i.resetPresentation(),N(!1)},children:[z.jsx(So,{icon:rIt,size:"sm"}),"Reset viewport settings"]})]})]})]}),d?z.jsxs(Eze,{className:"vgai-model-capture-preview",children:[z.jsxs("div",{children:[z.jsx(Ru,{as:"strong",variant:"label",children:"Deterministic views"}),z.jsx(fo,{type:"button",variant:"ghost",onClick:()=>_(null),children:"Close"})]}),z.jsx("img",{src:d,alt:"Front, right, top, and three-quarter model preview"})]}):null,g?z.jsx(N5r,{className:"vgai-model-toolbar-error",tone:"error",children:g}):null]})}function sSn({documentId:t,runtime:r=!1,island:i=!1,assetPath:a,transformControls:l,children:d}){Xe.useSyncExternalStore(e0e,I8,I8);const _=Xe.useSyncExternalStore(kee,N8,N8),g=Pw(t);return!d&&!g&&!l||!r&&_.includes("header:hidden")?null:z.jsxs("div",{className:i?"vgai-dock-document-toolbar vgai-chrome-island vgai-glass-island":"vgai-dock-document-toolbar","data-runtime-toolbar":r||void 0,"data-island-scale":"compact","data-testid":`document-header:${t}`,children:[d?z.jsx("div",{className:"vgai-dock-document-toolbar-own",children:d}):null,l,g?z.jsx(iSn,{documentId:t,...a&&!a.startsWith("online:")?{assetPath:a}:{}}):null]})}function oSn({documentId:t,children:r}){const i=Xe.useSyncExternalStore(kee,N8,N8);return!r||i.includes("shelf:hidden")?null:z.jsx("div",{className:"vgai-dock-document-shelf","data-testid":`document-shelf:${t}`,role:"toolbar","aria-orientation":"vertical","aria-label":"Document tools",children:r})}function e9e({active:t,onArm:r,faIcon:i,action:a,label:l}){return z.jsx(ph,{text:l,hotkey:ep(a),children:z.jsx(rf,{"aria-label":l,"aria-pressed":t,shape:"segment",size:"comfortable",onClick:r,children:z.jsx(So,{icon:i,size:"md"})})})}function xQt({store:t,dimensions:r="3d",size:i="comfortable",variant:a="ghost"}){const[l,d]=Xe.useState(!1),_=Xe.useRef(null);return Xe.useEffect(()=>{if(!l)return;const g=b=>{_.current&&!_.current.contains(b.target)&&d(!1)};return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[l]),z.jsxs("div",{ref:_,className:"vgai-viewport-popover-anchor",children:[z.jsxs(Tze,{children:[z.jsx(ph,{text:"Toggle Snap",hotkey:ep("viewport.toggleSnap"),children:z.jsx(rf,{"aria-label":"Toggle snap","aria-pressed":t.snapEnabled,variant:a,size:i,onClick:()=>t.toggleSnap(),children:z.jsx(So,{icon:oDr,size:"md"})})}),z.jsx(ph,{text:"Snap Settings",children:z.jsx(rf,{"aria-label":"Snap settings","aria-haspopup":"dialog","aria-expanded":l,variant:a,size:i,onClick:()=>d(!l),children:z.jsx(So,{icon:x8,size:"xs"})})})]}),l&&z.jsx(Eze,{className:"vgai-snap-popover",children:z.jsxs(o0e,{gap:2,children:[z.jsx(Ru,{variant:"caption",tone:"muted",children:"Translate"}),z.jsx(k_,{type:"number",value:t.snapValues.translate,step:.25,min:.01,onChange:g=>t.setSnapValues({translate:Number(g.target.value)||1})}),z.jsx(Ru,{variant:"caption",tone:"muted",children:"Rotate (deg)"}),z.jsx(k_,{type:"number",value:t.snapValues.rotate,step:5,min:1,onChange:g=>t.setSnapValues({rotate:Number(g.target.value)||15})}),z.jsx(Ru,{variant:"caption",tone:"muted",children:"Scale"}),z.jsx(k_,{type:"number",value:t.snapValues.scale,step:.05,min:.01,onChange:g=>t.setSnapValues({scale:Number(g.target.value)||.25})}),r==="3d"&&z.jsxs(z.Fragment,{children:[z.jsxs(Nq,{gap:2,align:"center",onClick:()=>t.toggleSnapToSurface(),children:[z.jsx(SE,{checked:t.snapToSurface,readOnly:!0}),z.jsx(Ru,{children:"Snap to Surface"})]}),z.jsxs(Ru,{variant:"caption",tone:"dim",children:["Hold ",z.jsx(q_e,{children:"Ctrl"})," while dragging to snap once ·"," ",z.jsx(q_e,{children:ep("viewport.toggleSnap")})," toggles"]}),z.jsxs(Ru,{variant:"caption",tone:"dim",children:["Hold ",z.jsx(q_e,{children:ep("viewport.vertexSnapHold")})," during translate for vertex snap"]})]})]})})]})}const aSn={"active-element":"Active Element","median-point":"Median Point","individual-origins":"Individual Origins"};function cSn({store:t}){const r=["active-element","median-point","individual-origins"],i=`Pivot: ${aSn[t.pivotMode]}`;return z.jsx(ph,{text:i,hotkey:ep("viewport.cyclePivot"),children:z.jsx(rf,{"aria-label":i,"aria-pressed":t.pivotMode!=="active-element",variant:"secondary",onClick:()=>{const a=r.indexOf(t.pivotMode);t.setPivotMode(r[(a+1)%r.length])},children:z.jsx(So,{icon:nIt,size:"md"})})})}const lSn={auto:"Auto",pivot:"Pivot",center:"Center"};function uSn({store:t}){const r=["auto","pivot","center"],i=`Anchor: ${lSn[t.gizmoAnchor]}`;return z.jsx(ph,{text:i,children:z.jsx(rf,{"aria-label":i,"aria-pressed":t.gizmoAnchor!=="auto",variant:"secondary",onClick:()=>{const a=r.indexOf(t.gizmoAnchor);t.setGizmoAnchor(r[(a+1)%r.length])},children:z.jsx(So,{icon:t.gizmoAnchor==="center"?rze:tDr,size:"md"})})})}function fSn({store:t}){const[r,i]=Xe.useState(!1),a=Xe.useRef(null);return Xe.useEffect(()=>{if(!r)return;const l=d=>{a.current?.contains(d.target)||i(!1)};return document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)},[r]),z.jsxs("div",{ref:a,className:"vgai-viewport-popover-anchor",children:[z.jsx(ph,{text:"Transform options",children:z.jsx(rf,{"aria-label":"Transform options","aria-haspopup":"dialog","aria-expanded":r,variant:"secondary",onClick:()=>i(l=>!l),children:z.jsx(So,{icon:aIt,size:"md"})})}),r?z.jsx(Eze,{style:{minWidth:240},children:z.jsxs(o0e,{gap:3,children:[z.jsxs(fo,{size:"compact",variant:"ghost",onClick:()=>{t.snapSelectionToFloor(),i(!1)},children:["Snap Selection to Floor ",z.jsx(q_e,{children:ep("viewport.snapToFloor")})]}),z.jsxs(Nq,{gap:2,align:"center",onClick:()=>t.togglePreserveChildrenTransform(),style:{cursor:"pointer"},children:[z.jsx(SE,{checked:t.preserveChildrenTransform,readOnly:!0}),z.jsx(Ru,{children:"Preserve Children Transform"})]}),z.jsx(Ru,{variant:"caption",tone:"dim",children:"Keep source-writable children fixed in world space while their parent moves."})]})}):null]})}function dSn({store:t}){const[r,i]=Xe.useState(!1),a=Xe.useRef(null),l=t.transformSpace==="world"?"Global":"Local";return z.jsxs("div",{className:"vgai-viewport-popover-anchor",children:[z.jsx(ph,{text:`Transform orientation: ${l}`,children:z.jsxs(fo,{ref:a,type:"button",size:"compact",variant:"secondary","aria-label":`Transform orientation: ${l}`,"aria-haspopup":"menu","aria-expanded":r,onClick:()=>i(d=>!d),className:"vgai-transform-orientation-trigger",children:[z.jsx(So,{icon:t.transformSpace==="world"?ADr:f9,size:"sm"}),z.jsx("span",{children:l}),z.jsx(So,{icon:x8,size:"xs"})]})}),r&&z.jsx(JR,{anchorRef:a,align:"start",clamp:!0,"aria-label":"Transform orientation",onDismiss:()=>i(!1),children:["world","local"].map(d=>z.jsxs(Wa,{role:"menuitemradio","aria-checked":t.transformSpace===d,onSelect:()=>{t.setTransformSpace(d),i(!1)},children:[z.jsx("span",{className:"vgai-menu-check",children:t.transformSpace===d&&z.jsx(So,{icon:S8,size:"xs"})}),d==="world"?"Global":"Local"]},d))})]})}function pSn({store:t}={}){const r=D0(),i=t??r;return Xe.useSyncExternalStore(i.subscribe,i.getShellSnapshot??i.getSnapshot),Xe.useSyncExternalStore(oU,uI,uI),z.jsxs(NP,{compact:!0,label:"Transform controls","data-testid":"transform-header-controls",className:"vgai-transform-header-controls",children:[z.jsx(dSn,{store:i}),z.jsxs(Tze,{children:[z.jsx(cSn,{store:i}),z.jsx(uSn,{store:i})]}),z.jsx(xQt,{store:i,size:"default",variant:"secondary"}),z.jsx(fSn,{store:i})]})}const _Sn=()=>()=>{},nTt=()=>null;function mSn({dimensions:t="3d",door:r,store:i}={}){const a=D0(),l=i??a;Xe.useSyncExternalStore(l.subscribe,l.getShellSnapshot??l.getSnapshot),Xe.useSyncExternalStore(oU,uI,uI);const d=Xe.useSyncExternalStore(r?.subscribe??_Sn,r?.armed??nTt,r?.armed??nTt),_=[{mode:"translate",faIcon:yb.tool.move,action:"transform.translate",label:"Move"},{mode:"rotate",faIcon:yb.tool.rotate,action:"transform.rotate",label:"Rotate"},{mode:"scale",faIcon:yb.tool.scale,action:"transform.scale",label:"Scale"}];return z.jsxs(O5r,{label:"Transform tools","data-testid":t==="2d"?"canvas-2d-toolstrip":"threejs-toolstrip",className:"vgai-viewport-toolbar vgai-viewport-toolbar-left",children:[r?null:z.jsx(e9e,{faIcon:yb.tool.select,action:"transform.select",label:"Select",active:l.transformMode==="select",onArm:()=>yS(l,"select")}),_.map(g=>z.jsx(e9e,{faIcon:g.faIcon,action:g.action,label:g.label,active:r?d===g.mode:l.transformMode===g.mode,onArm:()=>r?r.begin(g.mode):yS(l,g.mode)},g.mode)),r?null:z.jsx(e9e,{faIcon:yb.tool.transform,action:"transform.combined",label:"Transform (all handles)",active:l.transformMode==="combined",onArm:()=>yS(l,"combined")}),t==="2d"?z.jsx(xQt,{store:l,dimensions:"2d"}):null]})}const iTt=new WeakSet;function hSn(t){t===null||iTt.has(t)||(iTt.add(t),F2n()==="select"&&t.setTransformMode("select"))}function gSn(t){return t==="game"||t==="scene"||t==="world"?"world":"resource"}function wQt({viewId:t,descriptor:r,active:i,backdrop:a=!1,chrome:l=!0}){const d=r.Content,_=r.Toolbar,g=r.Shelf,b=gSn(r.kind),S=D0();Xe.useSyncExternalStore(S.subscribe,S.getShellSnapshot??S.getSnapshot),Xe.useSyncExternalStore(Nee,MP,MP),Xe.useSyncExternalStore(e0e,I8,I8),Xe.useSyncExternalStore(i3r,rbt,rbt),Xe.useSyncExternalStore(UHt,vye,vye);const k=i&&r.kind!=="game"?fyn(JHt(S,r.id)):"none",w=k==="modal"?hIt(r.id):null,N=uee(r.id)??S,P=uee(r.id);return Xe.useEffect(()=>{k==="gizmo"&&hSn(P)},[k,P]),z.jsxs("div",{className:"vgai-dock-document","data-testid":`workspace-doc:${r.id}`,"data-editor-hotkey-scope":b==="world"?"viewport":"workspace","data-vgai-document-family":b,children:[l&&z.jsx(sSn,{documentId:r.id,runtime:r.kind==="game",island:a&&b==="world",assetPath:Pzr(r.id)?.assetPath,transformControls:k==="gizmo"?z.jsx(pSn,{store:N}):null,children:_?z.jsx(_,{documentId:r.id,active:i}):null}),z.jsxs("div",{className:"vgai-dock-document-content","data-workspace-document-id":r.id,"data-workspace-view-id":t,children:[z.jsx(d,{documentId:r.id,...t?{viewId:t}:{},active:i}),l&&z.jsx(oSn,{documentId:r.id,children:k!=="none"||g?z.jsxs(z.Fragment,{children:[k==="none"?null:z.jsx(mSn,{store:N,...w?{door:w}:{}}),g?z.jsx(g,{documentId:r.id,active:i}):null]}):null})]})]})}const x_e=new Map;function ySn(t,r){const i=hh();let a=x_e.get(t);(!a||a.project!==i)&&(a={project:i,count:0,created:r},x_e.set(t,a)),a.count++;const l=a;return()=>{x_e.get(t)!==l||--l.count>0||(x_e.delete(t),l.created&&hh()===l.project&&Y8(t))}}function vSn({document:t,chrome:r=!0,active:i=!0,onReady:a}){const l=D0(),[d,_]=Xe.useState(null),[g,b]=Xe.useState(null),S=JSON.stringify(t),k=Xe.useRef(a);k.current=a;const w=Xe.useRef(null);Xe.useSyncExternalStore(Aw,Sb,Sb);const N=Xe.useSyncExternalStore(e0e,I8,I8);Xe.useEffect(()=>{let j=!1,J;const X=hh(),G=()=>!j&&hh()===X,ee=JSON.parse(S);return _(null),b(null),(async()=>{if(await uQe(),!G())return;const xe=new Set(FA().map(fe=>fe.descriptor.id)),ue=ee.kind==="asset"?f8(l,ee.path,ee.assetKind??"source",{activate:i}):ee.kind==="workspace"?xe.has(ee.id)?ee.id:null:await y0e(ee.kind,l,{...ee,activate:i});if(G()){if(!ue)throw new Error("The requested layout document is unavailable.");J=ySn(ue,!xe.has(ue)),_(ue)}})().catch(xe=>{G()&&b(xe instanceof Error?xe.message:String(xe))}),()=>{j=!0,J?.()}},[l,S]),Xe.useEffect(()=>{!d||!i||xb(d)},[d,i]),Xe.useEffect(()=>{if(!d)return;const j=Pw(d);if(!(!j||w.current===j)){w.current=j;try{k.current?.({select(J){const X=[];if(j.root.traverse(G=>{if(G.name===J){const ee=j.idForObject(G);ee&&X.push(ee)}}),X.length!==1)throw new Error(`Expected one object named "${J}"; found ${X.length}.`);j.select(X)},transform(J){j.viewport.setTransformMode(J)},frame(){j.frame()}})}catch(J){b(J instanceof Error?J.message:String(J))}}},[d,N]);const P=d?FA().find(j=>j.descriptor.id===d):void 0;return z.jsx("div",{style:{position:"relative",flex:1,minWidth:0,minHeight:0,height:"100%",overflow:"hidden"},children:g?z.jsx("div",{role:"alert",children:g}):P?z.jsx(wQt,{descriptor:P.descriptor,active:i,chrome:r}):z.jsx("div",{role:"status",children:"Opening document…"})})}function bSn(){return z.jsxs(xMr,{children:[z.jsx(wMr,{}),z.jsx(EMr,{}),z.jsx(CMr,{})]})}function ASn(){const t=D0();Xe.useSyncExternalStore(t.subscribe,t.getShellSnapshot??t.getSnapshot);const r=Xe.useSyncExternalStore(d0e,yZ,yZ),[i,a]=Xe.useState(!1),l=Xe.useSyncExternalStore(YP,_Ct,_Ct);if(Xe.useEffect(()=>{let _=!1;return uQe().then(()=>{_||a(!0)}),()=>{_=!0}},[]),!i)return z.jsx("div",{role:"status",children:l??"Loading project layout…"});const d=r.Layout??bSn;return z.jsx(d,{playing:t.playState!=="stopped",paused:t.playState==="paused"})}let SSn=!0;const xSn=new Set;function wSn(){for(const t of xSn)t()}function rKe(){return{preview:null,previewPinned:!1,view:null,guidesVisible:SSn}}function CSn(){const t=rKe();return t.view?.subject??t.preview}function ESn(){const t=rKe(),r=t.preview;r&&(t.previewPinned||r.id,wSn())}function TSn(){}function nKe({size:t=64,animation:r="assemble"}){const i=r==="static"?"":`vgai-logo--${r}`;return z.jsx("svg",{width:t,height:t,viewBox:wX.viewBox,"aria-hidden":"true",focusable:"false","data-testid":"vgai-logo",style:{display:"block",overflow:"visible",filter:"drop-shadow(0 5px 7px #0000003d)"},children:z.jsx("g",{className:i,transform:wX.transform,children:z.jsx("g",{className:"vgai-logo-idle",children:wX.pieces.map(a=>z.jsx("path",{className:`vgai-logo-${a.id}`,d:a.path,fill:"#F3F4F6"},a.id))})})})}const vqe="account";function CQt(){return qP({id:vqe,title:"Account",kind:"tool-contribution",workspaceRole:"workspace-task",provenance:{origin:"Volter account"},Content:PSn,closeable:!0,presentation:()=>({kind:"workspace",id:vqe})})}g9({id:"workspace",owner:"account-documents",open:(t,r)=>r.id===vqe?CQt():null});function kSn(t){return t.source==="environment"?`Environment · ${t.environmentVariable}`:t.source==="system"?"Secure system storage":t.source==="session"?t.configured?"Session only":"Session storage":"Not configured"}function Tq({children:t}){return z.jsxs("div",{className:"vgai-account-infostrip",children:[z.jsx(So,{icon:bee,className:"vgai-account-infostrip-icon","aria-hidden":"true"}),z.jsx("span",{children:t})]})}function ISn({provider:t,busy:r,run:i,editing:a,removing:l,onEdit:d,onStopEditing:_,onRemoveIntent:g}){const[b,S]=Xe.useState("");return z.jsxs("div",{className:"vgai-account-provider","data-configured":t.configured,children:[z.jsx("span",{className:"vgai-account-provider-monogram","aria-hidden":"true",children:t.label.slice(0,1)}),z.jsxs("div",{className:"vgai-account-provider-main",children:[z.jsxs("div",{className:"vgai-account-provider-name",children:[z.jsx("strong",{children:t.label}),t.configured&&z.jsxs(z.Fragment,{children:[z.jsx("span",{className:"vgai-account-provider-dot","aria-hidden":"true"}),z.jsx("span",{className:"vgai-account-provider-key",children:t.maskedKey})]})]}),z.jsx("span",{className:"vgai-account-provider-source",children:kSn(t)}),t.source==="session"&&t.configured&&z.jsx("span",{className:"vgai-account-provider-warning",children:"No system credential manager is available. This key will be forgotten when the editor stops."}),t.problem&&z.jsx("span",{className:"vgai-account-provider-warning",role:"alert",children:t.problem}),t.source==="environment"&&z.jsxs("span",{className:"vgai-account-provider-source",children:["Restart the editor after changing ",t.environmentVariable,"."]})]}),a?z.jsxs("form",{className:"vgai-account-provider-form",onSubmit:k=>{k.preventDefault(),i(async()=>{await N8r(t.provider,b),S(""),_()},`${t.label} credential saved.`)},children:[z.jsxs("label",{className:"vgai-field",children:[z.jsxs("span",{className:"vgai-field-label",children:[t.label," API key"]}),z.jsx(k_,{autoComplete:"off",autoFocus:!0,type:"password",value:b,onChange:k=>S(k.target.value)})]}),z.jsxs("div",{className:"vgai-account-provider-form-actions",children:[z.jsx(fo,{type:"submit",variant:"primary",disabled:r||b.trim()==="",children:"Save key"}),z.jsx(fo,{type:"button",variant:"ghost",disabled:r,onClick:()=>{S(""),_()},children:"Cancel"})]})]}):z.jsxs("div",{className:"vgai-account-provider-actions",children:[t.configured&&z.jsx(fo,{size:"compact",disabled:r,onClick:()=>void i(()=>F8r(t.provider),`${t.label} credential is valid.`),children:"Test"}),t.editable&&z.jsx(fo,{size:"compact",variant:t.configured?"ghost":"secondary",disabled:r,onClick:()=>{S(""),d()},children:t.configured?"Replace":"Add key"}),t.editable&&t.configured&&!l&&z.jsx(fo,{size:"compact",variant:"ghost",disabled:r,onClick:()=>g(t.provider),children:"Remove"}),l&&z.jsxs(z.Fragment,{children:[z.jsx(fo,{size:"compact",variant:"danger",disabled:r,onClick:()=>void i(async()=>{await O8r(t.provider),g(null)},`${t.label} credential removed.`),children:"Confirm remove"}),z.jsx(fo,{size:"compact",variant:"ghost",disabled:r,onClick:()=>g(null),children:"Cancel"})]})]})]})}function sTt({busy:t,run:r}){const i=_ze(),[a,l]=Xe.useState(null),[d,_]=Xe.useState(null),g=i.providerCredentials.filter(b=>b.configured).length;return z.jsxs("section",{className:"vgai-account-card vgai-provider-connections",children:[z.jsxs("div",{className:"vgai-account-providers-header",children:[z.jsxs("div",{children:[z.jsx("h3",{className:"vgai-account-card-title",children:"Provider connections"}),z.jsx("p",{className:"vgai-account-card-sub",children:"Keys live in this computer's credential manager — never in project files or the editor UI."})]}),z.jsxs("span",{className:"vgai-status-dot","data-state":g>0?"on":"off",children:[g," connected"]})]}),z.jsx("div",{className:"vgai-account-provider-list",children:i.providerCredentials.map(b=>z.jsx(ISn,{provider:b,busy:t,run:r,editing:a===b.provider,removing:d===b.provider,onEdit:()=>{_(null),l(b.provider)},onStopEditing:()=>l(null),onRemoveIntent:_},b.provider))})]})}function oTt({busy:t,run:r}){const i=_ze(),a=i.codingInference,[l,d]=Xe.useState(a.model),[_,g]=Xe.useState(null),[b,S]=Xe.useState(null);Xe.useEffect(()=>d(a.model),[a.model]),Xe.useEffect(()=>{g(null),S(null)},[l,i.preferredRoute]);const k=w=>r(()=>D8r({...a,...w,model:(w.model??a.model).trim()}),"Coding inference settings saved.");return z.jsxs("section",{className:"vgai-account-card",children:[z.jsx("h3",{className:"vgai-account-card-title",children:"Coding inference"}),z.jsxs("p",{className:"vgai-account-card-sub",children:["Coding agents run on the login you already did — ",z.jsx("code",{children:"codex login"}),", Claude's device login, ",z.jsx("code",{children:"grok login"})," — and Volter Editor injects nothing into them. Turn this on only for a harness you have no subscription for: it routes that harness through OpenRouter on this account's managed credits or your own key, and it takes effect only while Preferred route above is Managed or BYOK. Existing sessions keep the route they launched with."]}),z.jsxs("label",{className:"vgai-account-switch-row",children:[z.jsx(SE,{checked:a.enabled,disabled:t,onChange:w=>void k({enabled:w.target.checked})}),z.jsxs("span",{className:"vgai-account-switch-copy",children:[z.jsx("strong",{children:"Use OpenRouter for coding agents"}),z.jsx("small",{children:"Codex, Claude Code, OpenCode and Pi are configured per spawned process. Grok takes no provider configuration and always runs on its own device login."})]})]}),z.jsxs("label",{className:"vgai-field",children:[z.jsx("span",{className:"vgai-field-label",children:"Managed coding model"}),z.jsxs(bS,{value:l,disabled:t,onChange:w=>{const N=w.target.value;d(N),N!==a.model&&k({model:N})},children:[!["z-ai/glm-5.2","moonshotai/kimi-k3"].includes(l)&&z.jsxs("option",{value:l,children:[l," · custom"]}),z.jsx("option",{value:"z-ai/glm-5.2",children:"GLM-5.2 · managed default"}),z.jsx("option",{value:"moonshotai/kimi-k3",children:"Kimi K3 · higher-cost option"})]})]}),i.preferredRoute==="managed"?z.jsxs("div",{className:"vgai-account-card-footer",children:[z.jsx(fo,{size:"compact",disabled:t,onClick:()=>{S(null),P8r({model:l,promptTokens:1e5,outputTokens:2e4}).then(g).catch(w=>S(w instanceof Error?w.message:String(w)))},children:"Preflight typical coding session"}),_&&z.jsxs("span",{className:"vgai-account-help",children:["Estimate: ",_.estimatedCredits.toLocaleString()," Volter credits ($",_.providerAmountUsd.toFixed(4)," provider cost) for 100k input + 20k output tokens."]}),b&&z.jsx("span",{className:"vgai-account-provider-warning",role:"alert",children:b})]}):i.preferredRoute==="byok"?z.jsx(Tq,{children:"BYOK coding charges OpenRouter directly and consumes zero Volter credits."}):null,z.jsxs(Tq,{children:["Active account route: ",i.preferredRoute,". BYOK requires the OpenRouter connection below; managed uses the Volter balance."]})]})}function DSn({plan:t}){const r=t.status.replace("_"," "),i=t.status==="active"||r.toLowerCase()===t.name.trim().toLowerCase();return z.jsxs("span",{className:"vgai-account-plan-chips",children:[z.jsxs("span",{className:"vgai-chip","data-tone":"accent",children:[t.name," plan"]}),!i&&z.jsx("span",{className:"vgai-chip","data-tone":t.status==="cancelling"?"warn":void 0,children:r}),(t.renewsAt||t.endsAt)&&z.jsxs("span",{className:"vgai-chip",children:[t.endsAt?"Access ends":"Renews"," ",new Date(t.endsAt??t.renewsAt).toLocaleDateString()]})]})}function PSn(){Xe.useSyncExternalStore(Yye,T8,T8);const t=_ze(),[r,i]=Xe.useState("builder@example.test"),[a,l]=Xe.useState([]),[d,_]=Xe.useState(null),[g,b]=Xe.useState("creator"),[S,k]=Xe.useState(""),[w,N]=Xe.useState(!1),[P,j]=Xe.useState(null),[J,X]=Xe.useState(null),[G,ee]=Xe.useState(null),[xe,ue]=Xe.useState(!1);Xe.useEffect(()=>{if(t.authenticated||t.backend!=="live"||t.accountEnvironment==="development-twin"){ue(!1);return}$8r().then(Ot=>ue(Ot.device)).catch(()=>ue(!1))},[t.authenticated,t.backend]),Xe.useEffect(()=>{if(!G)return;const Ot=()=>{z8r(G.authorizationId).then(Et=>{Et&&ee(null)}).catch(Et=>{j(Et instanceof Error?Et.message:String(Et)),ee(null)})};Ot();const vt=window.setInterval(Ot,1e3);return()=>window.clearInterval(vt)},[G]),Xe.useEffect(()=>{if(!J)return;const Ot=()=>{V8r(J.deviceCode).then(Et=>{Et&&X(null)}).catch(Et=>{j(Et instanceof Error?Et.message:String(Et)),X(null)})},vt=window.setInterval(Ot,Math.max(1,J.intervalSeconds)*1e3);return()=>window.clearInterval(vt)},[J]),Xe.useEffect(()=>{if(!t.authenticated){l([]);return}L8r().then(l).catch(()=>l([]))},[t.authenticated,t.authenticated?t.user.id:"signed-out",t.authenticated?t.credits.used:0]),Xe.useEffect(()=>{if(!t.authenticated){_(null);return}j8r().then(Ot=>{_(Ot);const vt=["creator","max","ultra"].find(Et=>Et!==t.plan.id);b(vt??"creator"),k(Object.keys(Ot.creditPacks)[0]??"")}).catch(()=>_(null))},[t.authenticated,t.authenticated?t.user.id:"signed-out"]);const fe=async(Ot,vt)=>{N(!0),j(null);try{await Ot(),vt&&j(vt)}catch(Et){j(Et instanceof Error?Et.message:String(Et))}finally{N(!1)}};if(!t.authenticated)return z.jsx("div",{className:"vgai-account","data-testid":"account-document",children:z.jsxs("div",{className:"vgai-account-signin-stack",children:[z.jsxs("div",{className:"vgai-account-signin-hero",children:[z.jsx("span",{className:"vgai-account-signin-mark","aria-hidden":"true",children:z.jsx(nKe,{size:52,animation:"static"})}),z.jsx("h1",{className:"vgai-account-signin-title",children:"Sign in to Volter Editor"})]}),t.accountEnvironment==="development-twin"?z.jsxs("form",{className:"vgai-account-card vgai-account-signin-card",onSubmit:Ot=>{Ot.preventDefault(),fe(()=>C8r(r),"Signed in through the local Clerk Twin.")},children:[z.jsxs("label",{className:"vgai-field",children:[z.jsx("span",{className:"vgai-field-label",children:"Development email"}),z.jsx(k_,{value:r,type:"email",onChange:Ot=>i(Ot.target.value)})]}),z.jsx(fo,{type:"submit",variant:"primary",disabled:w||!r.includes("@"),children:w?"Signing in…":"Use Clerk Twin account"}),z.jsx(Tq,{children:"Local Clerk and Polar twins — fake identity and checkout, with the real Volter account and credit boundaries."})]}):t.backend==="live"?z.jsxs("section",{className:"vgai-account-card vgai-account-signin-card",children:[z.jsx(fo,{variant:"primary",disabled:w||J!==null||G!==null,onClick:()=>void fe(async()=>{const Ot=await q8r();ee(Ot),window.open(Ot.authorizationUrl,"_blank","noopener,noreferrer")}),children:G?"Waiting for browser sign-in…":"Continue in browser"}),xe&&z.jsx(fo,{variant:"ghost",disabled:w||J!==null||G!==null,onClick:()=>void fe(async()=>{const Ot=await U8r();X(Ot),window.open(Ot.verificationUri,"_blank","noopener,noreferrer")}),children:"Use a device code instead"}),J&&z.jsxs("div",{className:"vgai-account-device-code",children:[z.jsx("strong",{children:J.userCode}),z.jsx("span",{children:"Complete authorization in the browser. This editor polls without receiving your password."})]}),z.jsx(Tq,{children:"Authorization happens in your browser — this editor never sees your password."})]}):z.jsxs("form",{className:"vgai-account-card vgai-account-signin-card",onSubmit:Ot=>{Ot.preventDefault(),fe(()=>w8r(r),"Signed in to the zero-charge local account.")},children:[z.jsxs("label",{className:"vgai-field",children:[z.jsx("span",{className:"vgai-field-label",children:"Email"}),z.jsx(k_,{value:r,type:"email",onChange:Ot=>i(Ot.target.value)})]}),z.jsx(fo,{type:"submit",variant:"primary",disabled:w||!r.includes("@"),children:w?"Signing in…":"Use local mock account"}),z.jsx(Tq,{children:"Local mock — no payment, network identity, or provider request."})]}),z.jsxs("ul",{className:"vgai-account-signin-points",children:[z.jsx("li",{children:"Every paid generation shows its route and estimate first"}),z.jsx("li",{children:"Spend controls and hard limits are on by default"}),z.jsx("li",{children:"Provider keys stay in your system credential manager"})]}),z.jsx(oTt,{busy:w,run:fe}),z.jsx(sTt,{busy:w,run:fe}),(P||Ppe())&&z.jsx("div",{className:"vgai-account-status",role:"status",children:P??Ppe()})]})});const se=t.credits.included+t.credits.purchased,de=se===0?0:Math.min(100,t.credits.used/se*100),ge=se===0?0:Math.max(0,Math.min(100-de,t.credits.reserved/se*100)),qe=se>0&&t.credits.used>se,tt=t.backend==="mock"||t.entitlements.generation,Ct=Ot=>T8r({...t.spendPolicy,...Ot});return z.jsxs("div",{className:"vgai-account","data-testid":"account-document",children:[z.jsx("h1",{className:"vgai-sr-only",children:"Account"}),z.jsxs("div",{className:"vgai-account-stack",children:[z.jsxs("header",{className:"vgai-account-identity",children:[z.jsx("span",{className:"vgai-account-avatar","aria-hidden":"true",children:t.user.email.slice(0,1)}),z.jsxs("div",{className:"vgai-account-identity-main",children:[z.jsxs("div",{className:"vgai-account-identity-row",children:[z.jsx("h2",{className:"vgai-account-identity-email",children:t.user.email}),z.jsx(DSn,{plan:t.plan})]}),z.jsx("p",{className:"vgai-account-identity-note",children:t.accountEnvironment==="development-twin"?"Clerk + Polar Twin development account":t.backend==="mock"?"Isolated test account":"Volter account"})]}),z.jsx(fo,{variant:"ghost",className:"vgai-account-signout",disabled:w,onClick:()=>void fe(E8r),children:"Sign out"})]}),z.jsxs("section",{className:"vgai-account-card",children:[z.jsxs("div",{className:"vgai-account-card-head",children:[z.jsx("h3",{className:"vgai-account-card-title",children:"Credits"}),t.plan.id!=="free"&&t.plan.status==="cancelling"&&z.jsx(fo,{size:"compact",disabled:w,onClick:()=>void fe(()=>Obt("resume")),children:"Resume subscription"})]}),!tt&&z.jsx(Tq,{children:"This account has not been admitted to Volter managed services. Signing up or paying does not grant provider access; contact the Volter team for admission."}),d&&z.jsxs("div",{className:"vgai-account-card-footer",children:[z.jsxs("label",{className:"vgai-field",children:[z.jsx("span",{className:"vgai-field-label",children:"Subscription tier"}),z.jsx(bS,{value:g,disabled:w||!tt,onChange:Ot=>b(Ot.target.value),children:Object.keys(d.plans).map(Ot=>{const vt=d.plans[Ot],Et=vt.monthlyPriceUsd;return z.jsxs("option",{value:Ot,disabled:Ot==="free",children:[vt.name,Et!==void 0?` · $${Et}/month`:""," ·"," ",vt.includedCredits.toLocaleString()," credits",Ot===t.plan.id?" · current":""]},Ot)})})]}),z.jsxs(fo,{variant:"primary",size:"compact",disabled:w||!tt||g===t.plan.id||g==="free",onClick:()=>void fe(async()=>{const Ot=await R8r(g);Ot.checkoutUrl?window.open(Ot.checkoutUrl,"_blank","noopener,noreferrer"):j(Ot.mock?`Mock ${d.plans[g].name} upgrade completed. No payment occurred.`:`Subscription changed to ${d.plans[g].name}.`)}),children:["Choose ",d.plans[g].name]})]}),z.jsxs("div",{className:"vgai-account-credit-figure",children:[z.jsx("span",{className:"vgai-account-credit-number",children:t.credits.remaining.toLocaleString()}),z.jsx("span",{className:"vgai-account-credit-unit",children:"credits remaining"})]}),z.jsxs("div",{className:"vgai-meter",role:"progressbar","aria-label":"Credits used","aria-valuenow":Math.round(de),"aria-valuemin":0,"aria-valuemax":100,"data-state":qe?"over":void 0,children:[z.jsx("span",{className:"vgai-meter-fill",style:{width:`${de}%`}}),ge>0&&z.jsx("span",{className:"vgai-meter-fill","data-part":"reserved",style:{left:`${de}%`,width:`${ge}%`}})]}),z.jsxs("p",{className:"vgai-account-cycle-line",children:[t.credits.used.toLocaleString()," of ",se.toLocaleString()," used this cycle",t.credits.resetsAt&&z.jsxs(z.Fragment,{children:[" · resets ",new Date(t.credits.resetsAt).toLocaleDateString()]}),qe&&z.jsx("span",{className:"vgai-account-cycle-over",children:" · over allowance"})]}),z.jsxs("div",{className:"vgai-account-legend","data-state":qe?"over":void 0,children:[z.jsxs("span",{className:"vgai-account-legend-item","data-part":"included",children:[z.jsx("span",{className:"vgai-account-legend-dot","aria-hidden":"true"}),t.credits.included.toLocaleString()," included"]}),z.jsxs("span",{className:"vgai-account-legend-item","data-part":"used",children:[z.jsx("span",{className:"vgai-account-legend-dot","aria-hidden":"true"}),t.credits.used.toLocaleString()," used"]}),z.jsxs("span",{className:"vgai-account-legend-item","data-part":"reserved",children:[z.jsx("span",{className:"vgai-account-legend-dot","aria-hidden":"true"}),t.credits.reserved.toLocaleString()," reserved"]}),z.jsxs("span",{className:"vgai-account-legend-item","data-part":"purchased",children:[z.jsx("span",{className:"vgai-account-legend-dot","aria-hidden":"true"}),t.credits.purchased.toLocaleString()," purchased"]})]}),t.credits.purchasedExpiresAt&&z.jsxs("p",{className:"vgai-account-help vgai-account-expiry",children:["Purchased credits expire"," ",new Date(t.credits.purchasedExpiresAt).toLocaleDateString(),"."]}),z.jsxs("div",{className:"vgai-account-card-footer",children:[d&&S&&d.creditPacks[S]&&z.jsxs(z.Fragment,{children:[z.jsx(bS,{"aria-label":"Credit pack",value:S,disabled:w||!tt,onChange:Ot=>k(Ot.target.value),children:Object.entries(d.creditPacks).map(([Ot,vt])=>z.jsxs("option",{value:Ot,children:[vt.name," · ",vt.credits.toLocaleString()," credits"]},Ot))}),z.jsx(fo,{size:"compact",disabled:w||!tt,onClick:()=>void fe(async()=>{const Ot=d.creditPacks[S],vt=await M8r(S);vt.checkoutUrl?window.open(vt.checkoutUrl,"_blank","noopener,noreferrer"):j(`Added ${Ot?.credits.toLocaleString()??""} mock credits. No payment occurred.`)}),children:"Buy credits"})]}),z.jsx(fo,{size:"compact",variant:"ghost",disabled:w,onClick:()=>void fe(async()=>{const Ot=await B8r();Ot.mock?j("Mock billing portal: no payment page was opened."):window.open(Ot.url,"_blank","noopener,noreferrer")}),children:"Billing and invoices"}),t.plan.id!=="free"&&t.plan.status==="active"&&z.jsx(fo,{size:"compact",variant:"ghost",className:"vgai-account-quiet-danger",disabled:w,onClick:()=>void fe(()=>Obt("cancel")),children:"Cancel at renewal"})]})]}),z.jsxs("section",{className:"vgai-account-card",children:[z.jsx("h3",{className:"vgai-account-card-title",children:"Generation routing"}),z.jsx("p",{className:"vgai-account-card-sub",children:"Billing preference for AI usage. Provider libraries apply it automatically; requests show the resolved account and cost before submission."}),z.jsxs("label",{className:"vgai-field",children:[z.jsx("span",{className:"vgai-field-label",children:"Preferred route"}),z.jsxs(bS,{value:t.preferredRoute,onChange:Ot=>void fe(()=>I8r(Ot.target.value)),children:[t.accountEnvironment==="test-mock"&&z.jsx("option",{value:"mock",children:"Mock · free and local"}),z.jsx("option",{value:"auto",children:"Automatic · saved key or Volter account"}),z.jsxs("option",{value:"managed",disabled:!t.routes.managed,children:["Managed · Volter credits",t.routes.managed?"":" (unavailable)"]}),z.jsxs("option",{value:"byok",disabled:!t.routes.byok,children:["BYOK · provider dollars",t.routes.byok?"":" (no key found)"]})]})]})]}),z.jsx(oTt,{busy:w,run:fe}),z.jsx(sTt,{busy:w,run:fe}),(t.alerts?.length??0)>0&&z.jsxs("section",{className:"vgai-account-card",children:[z.jsxs("div",{className:"vgai-account-card-head",children:[z.jsx("h3",{className:"vgai-account-card-title",children:"Account alerts"}),t.alerts?.some(Ot=>!Ot.readAt)&&z.jsx(fo,{size:"compact",variant:"ghost",disabled:w,onClick:()=>void fe(k8r),children:"Mark read"})]}),z.jsx("div",{className:"vgai-account-usage",children:t.alerts?.map(Ot=>z.jsxs("div",{className:"vgai-account-usage-row",children:[z.jsxs("span",{children:[z.jsx("strong",{children:Ot.readAt?"Notice":"New"}),z.jsx("small",{children:Ot.message})]}),z.jsx("span",{children:new Date(Ot.createdAt).toLocaleDateString()})]},Ot.id))})]}),z.jsxs("section",{className:"vgai-account-card",children:[z.jsx("h3",{className:"vgai-account-card-title",children:"Spend controls"}),z.jsxs("p",{className:"vgai-account-card-sub",children:["Alerts at ",t.spendPolicy.alertThresholds.join("%, "),"% of the available allowance."]}),z.jsxs("label",{className:"vgai-account-switch-row",children:[z.jsx(SE,{checked:t.spendPolicy.overageEnabled,onChange:Ot=>void fe(()=>Ct({overageEnabled:Ot.target.checked,monthlyLimitCredits:Ot.target.checked&&t.spendPolicy.monthlyLimitCredits===0?1e3:t.spendPolicy.monthlyLimitCredits}))}),z.jsxs("span",{className:"vgai-account-switch-copy",children:[z.jsx("strong",{children:"Allow paid overage"}),z.jsx("small",{children:"Off by default. Managed requests stop before provider submission."})]})]}),z.jsx("div",{className:"vgai-account-limit-field",children:z.jsxs("label",{className:"vgai-field",children:[z.jsx("span",{className:"vgai-field-label",children:"Monthly overage hard limit"}),z.jsxs("span",{className:"vgai-account-input-suffix",children:[z.jsx(k_,{type:"number",min:0,defaultValue:t.spendPolicy.monthlyLimitCredits,disabled:!t.spendPolicy.overageEnabled,onBlur:Ot=>void fe(()=>Ct({monthlyLimitCredits:Number(Ot.target.value)}))},t.spendPolicy.monthlyLimitCredits),z.jsx("span",{className:"vgai-account-suffix","aria-hidden":"true",children:"credits"})]})]})}),z.jsxs("label",{className:"vgai-account-switch-row",children:[z.jsx(SE,{checked:t.spendPolicy.autoReload?.enabled===!0,onChange:Ot=>void fe(()=>Ct({autoReload:{enabled:Ot.target.checked,whenRemainingBelow:t.spendPolicy.autoReload?.whenRemainingBelow??100,reloadTo:t.spendPolicy.autoReload?.reloadTo??500,monthlyLimitCredits:t.spendPolicy.autoReload?.monthlyLimitCredits??2e3}}))}),z.jsxs("span",{className:"vgai-account-switch-copy",children:[z.jsx("strong",{children:"Automatically reload credits"}),z.jsx("small",{children:"Optional, independently capped, and never enabled by checkout."})]})]}),t.spendPolicy.autoReload?.enabled&&z.jsxs("div",{className:"vgai-account-policy-fields",children:[z.jsxs("label",{className:"vgai-field",children:[z.jsx("span",{className:"vgai-field-label",children:"Reload below"}),z.jsxs("span",{className:"vgai-account-input-suffix",children:[z.jsx(k_,{type:"number",min:0,defaultValue:t.spendPolicy.autoReload.whenRemainingBelow,onBlur:Ot=>void fe(()=>Ct({autoReload:{...t.spendPolicy.autoReload,whenRemainingBelow:Number(Ot.target.value)}}))},t.spendPolicy.autoReload.whenRemainingBelow),z.jsx("span",{className:"vgai-account-suffix","aria-hidden":"true",children:"credits"})]})]}),z.jsxs("label",{className:"vgai-field",children:[z.jsx("span",{className:"vgai-field-label",children:"Reload balance to"}),z.jsxs("span",{className:"vgai-account-input-suffix",children:[z.jsx(k_,{type:"number",min:1,defaultValue:t.spendPolicy.autoReload.reloadTo,onBlur:Ot=>void fe(()=>Ct({autoReload:{...t.spendPolicy.autoReload,reloadTo:Number(Ot.target.value)}}))},t.spendPolicy.autoReload.reloadTo),z.jsx("span",{className:"vgai-account-suffix","aria-hidden":"true",children:"credits"})]})]}),z.jsxs("label",{className:"vgai-field",children:[z.jsx("span",{className:"vgai-field-label",children:"Monthly reload cap"}),z.jsxs("span",{className:"vgai-account-input-suffix",children:[z.jsx(k_,{type:"number",min:0,defaultValue:t.spendPolicy.autoReload.monthlyLimitCredits,onBlur:Ot=>void fe(()=>Ct({autoReload:{...t.spendPolicy.autoReload,monthlyLimitCredits:Number(Ot.target.value)}}))},t.spendPolicy.autoReload.monthlyLimitCredits),z.jsx("span",{className:"vgai-account-suffix","aria-hidden":"true",children:"credits"})]})]})]})]}),z.jsxs("section",{className:"vgai-account-card",children:[z.jsx("h3",{className:"vgai-account-card-title",children:"Current-cycle usage"}),a.length===0?z.jsx("p",{className:"vgai-account-help",children:"No managed credit usage has been settled in this account."}):z.jsx("div",{className:"vgai-account-usage",children:a.map(Ot=>z.jsxs("div",{className:"vgai-account-usage-row",children:[z.jsxs("span",{children:[Ot.kind," · ",Ot.provider," · ",Ot.operation??"managed operation"]}),z.jsxs("strong",{children:[Ot.credits.toLocaleString()," credits"]})]},Ot.id))})]}),(P||Ppe())&&z.jsx("div",{className:"vgai-account-status",role:"status",children:P??Ppe()})]})]})}function NSn(t,r,i){const l=navigator.platform.includes("Mac")?"⌘":"Ctrl+",d=rKe(),_=CSn(),g=By(t),b=[...t.selectedEntityIds],S=b[0],k=S?g.hierarchy.node(S)?.parentId??null:null,w=b.length>0&&!!g.structure?.copy&&(g.structure.canCopy?.(b)??!0),N=w&&!!g.structure?.cut,P=!!g.structure?.paste&&(g.structure.canPaste?.(k)??!0),j=[...N?[{id:"editor.cut",label:"Cut",category:"action",shortcut:ep("edit.cut"),execute:()=>YQe(t)}]:[],...w?[{id:"editor.copy",label:"Copy",category:"action",shortcut:ep("edit.copy"),execute:()=>KQe(t)}]:[],...P?[{id:"editor.paste",label:"Paste",category:"action",shortcut:ep("edit.paste"),execute:()=>XQe(t)}]:[]],J=d.view?[{id:"camera.exitView",label:"Exit Camera View",category:"action",execute:TSn}]:_?[{id:"camera.viewThrough",label:`View Through ${_.name}`,category:"action",execute:()=>void 0},..._.canAuthorPose?[{id:"camera.pilot",label:`Pilot ${_.name}`,category:"action",execute:()=>void 0},{id:"camera.alignToView",label:`Align ${_.name} to Current View`,category:"action",execute:()=>void 0}]:[],{id:"camera.pinPreview",label:d.previewPinned?"Unpin Camera Preview":"Pin Camera Preview",category:"action",execute:ESn}]:[];return[{id:"account.open",label:"Account and Provider Connections",category:"action",execute:()=>{CQt()}},{id:"editor.undo",label:i?.undoLabel?`Undo ${i.undoLabel}`:"Undo",category:"action",shortcut:ep("edit.undo"),execute:async()=>{await r.undo()}},{id:"editor.redo",label:i?.redoLabel?`Redo ${i.redoLabel}`:"Redo",category:"action",shortcut:ep("edit.redo"),execute:async()=>{await r.redo()}},...j,{id:"editor.duplicate",label:"Duplicate",category:"action",shortcut:ep("edit.duplicate"),execute:()=>dbe(t)},{id:"editor.delete",label:"Delete Selected",category:"action",shortcut:ep("edit.delete"),execute:()=>pbe(t)},{id:"editor.select-all",label:"Select All",category:"action",shortcut:ep("edit.selectAll"),execute:()=>cNt(t)},{id:"editor.deselect",label:"Deselect All",category:"action",shortcut:ep("edit.deselectAll")??ep("edit.exitScopeOrDeselect"),execute:()=>JUe(t,[])},{id:"mode.select",label:"Select Tool (no gizmo)",category:"action",shortcut:ep("transform.select"),execute:()=>yS(t,"select")},{id:"mode.combined",label:"Transform Mode (all handles)",category:"action",shortcut:ep("transform.combined"),execute:()=>yS(t,"combined")},{id:"mode.translate",label:"Translate Mode",category:"action",shortcut:ep("transform.translate"),execute:()=>yS(t,"translate")},{id:"mode.rotate",label:"Rotate Mode",category:"action",shortcut:ep("transform.rotate"),execute:()=>yS(t,"rotate")},{id:"mode.scale",label:"Scale Mode",category:"action",shortcut:ep("transform.scale"),execute:()=>yS(t,"scale")},{id:"mode.world",label:"World Space",category:"action",execute:()=>t.setTransformSpace("world")},{id:"mode.local",label:"Local Space",category:"action",execute:()=>t.setTransformSpace("local")},{id:"toggle.grid",label:"Toggle Grid",category:"action",execute:()=>t.toggleGrid()},{id:"toggle.helpers",label:"Toggle Helpers",category:"action",execute:()=>t.toggleHelpers()},{id:"toggle.stats",label:"Toggle Stats Overlay",category:"action",execute:()=>t.toggleStats()},{id:"toggle.snap",label:"Toggle Snap",category:"action",execute:()=>t.toggleSnap()},{id:"toggle.surface-snap",label:"Toggle Surface Snap",category:"action",execute:()=>t.toggleSnapToSurface()},{id:"shading.solid",label:"Material Shading",category:"action",execute:()=>t.setShadingMode("solid")},{id:"shading.clay",label:"Solid Shading",category:"action",execute:()=>t.setShadingMode("clay")},{id:"shading.wireframe",label:"Wireframe Shading",category:"action",execute:()=>t.setShadingMode("wireframe")},{id:"shading.unlit",label:"Unlit Shading",category:"action",execute:()=>t.setShadingMode("unlit")},{id:"shading.normals",label:"Normal Shading",category:"action",execute:()=>t.setShadingMode("normals")},{id:"shading.overdraw",label:"Overdraw Shading",category:"action",execute:()=>t.setShadingMode("overdraw")},{id:"view.top",label:"Top View",category:"action",shortcut:ep("view.top"),execute:()=>t.setViewPreset("top")},{id:"view.front",label:"Front View",category:"action",shortcut:ep("view.front"),execute:()=>t.setViewPreset("front")},{id:"view.right",label:"Right View",category:"action",shortcut:ep("view.right"),execute:()=>t.setViewPreset("right")},{id:"view.perspective",label:"Perspective View",category:"action",shortcut:ep("view.perspective"),execute:()=>t.setViewPreset("perspective")},{id:"focus.selected",label:"Focus Selected",category:"action",shortcut:ep("viewport.frameSelection"),execute:()=>t.focusOnSelection()},...J,{id:"toggle.console",label:"Toggle Console",category:"action",shortcut:ep("view.toggleConsole"),execute:()=>{obe()}},{id:"view.focusMode",label:"Toggle Focus Mode",category:"action",shortcut:ep("view.focusMode"),execute:()=>{Gze()}},...X8().map(X=>({id:`workspace.${X.id}`,label:`Workspace: ${X.title}`,category:"action",execute:()=>{CP(X.id)&&CS(X.id)}})),{id:"workspace.cycleNext",label:"Next Workspace",category:"action",shortcut:ep("workspace.cycleNext"),execute:()=>{Ohe(1)}},{id:"workspace.cyclePrevious",label:"Previous Workspace",category:"action",shortcut:ep("workspace.cyclePrevious"),execute:()=>{Ohe(-1)}},...Y3t().map(X=>({id:`keymap.${X.id}`,label:`Keymap: ${X.title}`,category:"action",execute:()=>{M7r(X.id)}})),...lU().map(X=>({id:`view.workspaceStyle.${X.id}`,label:`Workspace Style: ${X.title}`,category:"action",execute:()=>{nUe(X.id)}})),{id:"view.undoHistory",label:"Undo History",category:"action",execute:()=>{ZQe()}},{id:"view.lightExplorer",label:"Open Light Explorer",category:"action",execute:()=>hE(_ee.lightExplorer.id)},...Object.values(z_).filter(X=>X.id!==z_.open.id).map(X=>({id:X.id,label:`${X.id.replace("project-asset.","").split("-").map(G=>G[0]?.toUpperCase()+G.slice(1)).join(" ")} Project Asset`,category:"asset",...X.shortcut?{shortcut:X.shortcut.replace("Mod",l)}:{},execute:()=>{window.dispatchEvent(new CustomEvent("editor:project-asset-command",{detail:{id:X.id}}))}})),{id:"view.asset-library",label:"Asset Library",category:"action",execute:()=>{Hze("asset-library")}}]}function OSn(t){return z0e(t).filter(r=>r.id!==KMe).map(r=>({id:`entity:${r.id}`,label:r.name,category:"entity",execute:()=>{JUe(t,[r.id]),t.focusOnEntity(r.id)}}))}function FSn(){return _Qe().filter(t=>t.category==="canvas").map(({descriptor:t})=>({id:`board:${t.id}`,label:`Open ${t.title}`,category:"action",execute:()=>void s9(t.id)}))}function A8(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}function Tye(t){const r=t.type;if(typeof r=="string")return r;if(Array.isArray(r))return r.find(i=>i!=="null")}function EQt(t){const r=A8(t);if("default"in r)return structuredClone(r.default);const i=Tye(r);if(i==="object"||r.properties){const a={};for(const[l,d]of Object.entries(A8(r.properties))){const _=A8(d);("default"in _||Array.isArray(r.required)&&r.required.includes(l))&&(a[l]=EQt(_))}return a}return i==="array"?[]:i==="boolean"?!1:i==="number"||i==="integer"?Number(r.minimum??0):""}function bqe(t){return t.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[-_]/g," ").replace(/^./,r=>r.toUpperCase())}function RSn({name:t,schema:r,value:i,required:a,onChange:l}){const d=Tye(r),_=typeof r.description=="string"?r.description:null,g=Array.isArray(r.enum)?r.enum:null,b=`tool-field:${t}`;if(d==="boolean")return z.jsxs("label",{style:{...NY,gridTemplateColumns:"18px minmax(0, 1fr)"},children:[z.jsx(SE,{id:b,checked:i===!0,onChange:k=>l(k.target.checked)}),z.jsxs("span",{children:[z.jsx("span",{style:aTt,children:bqe(t)}),_&&z.jsx("span",{style:uR,children:_})]})]});const S=z.jsxs("span",{style:aTt,children:[bqe(t)," ",!a&&z.jsx("span",{style:LSn,children:"optional"})]});return g?z.jsxs("label",{style:NY,htmlFor:b,children:[S,z.jsxs(bS,{id:b,value:String(i??""),onChange:k=>l(k.target.value),style:w_e,children:[!a&&z.jsx("option",{value:"",children:"Not set"}),g.map(k=>z.jsx("option",{value:String(k),children:String(k)},String(k)))]}),_&&z.jsx("span",{style:uR,children:_})]}):d==="number"||d==="integer"?z.jsxs("label",{style:NY,htmlFor:b,children:[S,z.jsx(k_,{id:b,type:"number",value:typeof i=="number"?i:"",min:typeof r.minimum=="number"?r.minimum:void 0,max:typeof r.maximum=="number"?r.maximum:void 0,step:d==="integer"?1:"any",onChange:k=>l(k.target.value===""?void 0:Number(k.target.value)),style:w_e}),_&&z.jsx("span",{style:uR,children:_})]}):d==="array"&&Tye(A8(r.items))==="string"?z.jsxs("label",{style:NY,htmlFor:b,children:[S,z.jsx(k_,{id:b,value:Array.isArray(i)?i.join(", "):"",onChange:k=>l(k.target.value.split(",").map(w=>w.trim()).filter(Boolean)),placeholder:"Comma-separated values",style:w_e}),_&&z.jsx("span",{style:uR,children:_})]}):z.jsxs("label",{style:NY,htmlFor:b,children:[S,z.jsx(k_,{id:b,value:typeof i=="string"?i:"",onChange:k=>l(k.target.value||(a?"":void 0)),style:w_e}),_&&z.jsx("span",{style:uR,children:_})]})}function TQt({schema:t,value:r,onChange:i,path:a=""}){const l=A8(t.properties),d=new Set(Array.isArray(t.required)?t.required:[]);return z.jsx("div",{style:{display:"grid",gap:14},children:Object.entries(l).map(([_,g])=>{const b=A8(g),S=Tye(b),k=w=>{const N={...r};w===void 0?delete N[_]:N[_]=w,i(N)};return S==="object"||b.properties?z.jsxs("fieldset",{style:jSn,children:[z.jsx("legend",{style:BSn,children:bqe(_)}),typeof b.description=="string"&&z.jsx("p",{style:{...uR,marginTop:0},children:b.description}),z.jsx(TQt,{schema:b,value:A8(r[_]),onChange:k,path:a?`${a}.${_}`:_})]},_):z.jsx(RSn,{name:a?`${a}.${_}`:_,schema:b,value:r[_],required:d.has(_),onChange:k},_)})})}function MSn({schema:t,value:r,onChange:i}){const a=A8(t);return a.properties?z.jsx(TQt,{schema:a,value:r,onChange:i}):z.jsx("div",{style:uR,children:"This schema has no form-compatible fields."})}const NY={display:"grid",gap:5},aTt={color:od[1],fontWeight:600,fontSize:"var(--vgai-font-sm)"},LSn={color:od[3],fontWeight:400,marginLeft:5},uR={display:"block",color:od[2],fontSize:"var(--vgai-font-sm)",lineHeight:1.4},w_e={boxSizing:"border-box",width:"100%"},jSn={margin:0,padding:14,border:"1px solid var(--vgai-boundary-default)",borderRadius:"var(--vgai-radius-md)"},BSn={padding:"0 6px",color:od[1],fontWeight:600},kye="project-tools",Aqe="project-tool:";function $Sn(t){return`${Aqe}${t}`}function gbe(t){qP({id:kye,title:"Project Tools",kind:"project-tool",workspaceRole:"workspace-reference",Content:kQt,closeable:!0,presentation:()=>({kind:"workspace",id:kye}),persist:()=>({catalog:!0}),onActivate:()=>t.setActiveViewportTab("edit")})}function ybe(t,r){const i=Yz().tools.find(l=>l.name===r);if(!i)return!1;const a=wE().filter(l=>l.tool?.name===r);return a.length===1?fI(t,a[0].id):(qP({id:$Sn(r),title:i.summary||i.name,kind:"project-tool",workspaceRole:"workspace-reference",provenance:{sourcePath:i.sourcePath,origin:i.name},Content:kQt,closeable:!0,presentation:()=>({kind:"project-tool",name:r}),persist:()=>({name:r}),...t?{onActivate:()=>t.setActiveViewportTab("edit")}:{}}),!0)}g9({id:"workspace",owner:"project-tool-documents",open:(t,r)=>r.id!==kye?null:(gbe(t),kye)});g9({id:"project-tool",owner:"project-tool-documents",open:(t,r)=>ybe(t,r.name)?I_():null,settle:async t=>{if(await eZ().catch(()=>{}),!await xE(()=>Yz().tools.some(r=>r.name===t.name)))throw new Error(`Project tool is not registered: ${t.name}`)}});Iee({kind:"project-tool",owner:"project-tool-documents",prepare:()=>eZ().then(()=>{},()=>{}),restore:({state:t,store:r})=>{const i=t;return i?.catalog===!0?(gbe(r),!0):typeof i?.name=="string"&&ybe(r,i.name)}});function qSn(t){return[{id:"project-tools:open",label:"Open Project Tools",category:"action",execute:()=>gbe(t)},...Yz().tools.map(r=>({id:`project-tool:${r.name}`,label:`Run: ${r.summary||r.name}`,category:"action",execute:()=>void ybe(t,r.name)}))]}function cTt({value:t}){return z.jsx("pre",{style:JSn,children:JSON.stringify(t,null,2)})}function kQt({documentId:t}){Xe.useSyncExternalStore(WGt,Ybn),Xe.useSyncExternalStore(jA,dI);const r=Yz(),i=t.startsWith(Aqe)?t.slice(Aqe.length):null,a=i?r.tools.find(l=>l.name===i):null;return i?a?z.jsx(zSn,{tool:a},a.name):z.jsx("div",{style:Sqe,children:"This tool is no longer available."}):z.jsxs("div",{style:Sqe,"data-testid":"project-tools-catalog",children:[z.jsx("h2",{style:IQt,children:"Project Tools"}),z.jsxs("p",{style:{...xqe,margin:"0 0 18px",maxWidth:720,lineHeight:1.5},children:["Explicitly registered in ",z.jsx("code",{children:"package.json#vgai.tools"}),". Each tool is an ordinary project function; a registration may pair it with optional editor contributions."]}),z.jsx("div",{style:{display:"grid",gap:8},children:r.tools.map(l=>z.jsxs(fo,{variant:"ghost",className:"vgai-project-tool-card",onClick:()=>ybe(null,l.name),"data-testid":`project-command-card:${l.name}`,children:[z.jsxs("span",{style:DQt,children:[z.jsx("strong",{style:{color:od[1],fontWeight:600},children:l.summary}),z.jsx("span",{style:PQt,children:"Open"})]}),z.jsx("code",{style:{color:od[2],fontSize:"var(--vgai-font-sm)"},children:l.name}),z.jsx("span",{style:USn,children:z.jsxs("span",{children:[l.host," · ",l.permission.risk," · ",l.sourcePath]})})]},l.name))}),r.tools.length===0&&r.loadErrors.length===0&&z.jsx("div",{style:xqe,children:"No project tools registered."}),r.loadErrors.map(l=>z.jsxs("div",{style:Iye,children:[l.sourcePath,": ",l.message]},`${l.sourcePath}:${l.message}`)),cUe().map(l=>z.jsxs("div",{style:Iye,children:[l.entryPath,": ",l.error]},`${l.entryPath}:${l.error}`))]})}function zSn({tool:t}){const r=wE().filter(J=>J.tool?.name===t.name),i=EQt(t.inputSchema),[a,l]=Xe.useState(i&&typeof i=="object"&&!Array.isArray(i)?i:{}),[d,_]=Xe.useState(()=>JSON.stringify(a,null,2)),[g,b]=Xe.useState(null),[S,k]=Xe.useState(!1),[w,N]=Xe.useState(null),P=t.host==="node",j=async()=>{if(t.permission.risk==="read"||window.confirm(`${t.permission.summary}
|
|
1680
1680
|
|
|
1681
|
-
Run ${t.name}?`)){k(!0);try{b(await Xbn(t.name,a,{confirm:!0}))}catch(X){b({ok:!1,error:{code:"REQUEST_FAILED",message:String(X)}})}finally{k(!1)}}};return z.jsxs("div",{style:Sqe,"data-testid":`project-tool:${t.name}`,children:[z.jsx("h2",{style:IQt,children:t.summary}),z.jsx("code",{style:{color:od[2]},children:t.name}),z.jsx("p",{style:{color:od[2]},children:t.description}),z.jsxs("div",{style:xqe,children:[t.host," · ",t.permission.risk," · ",t.sourcePath]}),r.length>0&&z.jsxs("section",{style:{marginTop:18,maxWidth:760},children:[z.jsx("h3",{style:{margin:"0 0 8px",fontSize:13},children:"Presentations"}),z.jsx("div",{style:{display:"grid",gap:8},children:r.map(J=>z.jsx(fo,{variant:"ghost",className:"vgai-project-tool-card",onClick:()=>fI(null,J.id),children:z.jsxs("span",{style:DQt,children:[z.jsx("strong",{style:{color:od[1],fontWeight:600},children:J.title}),z.jsx("span",{style:PQt,children:"Open"})]})},J.id))})]}),!P&&z.jsx("div",{style:Iye,children:"This runner supports Node-hosted tools. Import the underlying function directly in browser or runtime code."}),z.jsxs("details",{open:r.length===0,style:{marginTop:18,maxWidth:760},children:[z.jsx("summary",{style:{cursor:"pointer",color:od[2],fontSize:12},children:r.length>0?"Advanced · invoke native schema":"Input"}),z.jsx("section",{style:{marginTop:12},children:z.jsx(MSn,{schema:t.inputSchema,value:a,onChange:J=>{l(J),_(JSON.stringify(J,null,2)),N(null)}})}),w&&z.jsx("div",{style:Iye,children:w}),z.jsx(fo,{variant:"primary",disabled:!P||S||w!==null,"aria-busy":S,onClick:()=>void j(),style:{marginTop:16},children:S?"Running…":"Run tool"}),z.jsxs("details",{style:{marginTop:16},children:[z.jsx("summary",{style:t9e,children:"Advanced JSON"}),z.jsx(Nze,{id:`tool-input:${t.name}`,value:d,onChange:J=>{const X=J.target.value;_(X);try{const G=JSON.parse(X);if(!G||typeof G!="object"||Array.isArray(G))throw new Error("Input must be a JSON object.");l(G),N(null)}catch(G){N(G instanceof Error?G.message:String(G))}},rows:10,"data-variant":"code",style:VSn}),z.jsxs("details",{children:[z.jsx("summary",{style:t9e,children:"Input schema"}),z.jsx(cTt,{value:t.inputSchema})]})]})]}),g!==null&&z.jsxs("section",{children:[z.jsx("div",{style:t9e,children:"Result"}),z.jsx(cTt,{value:g})]})]})}const Sqe={width:"100%",maxWidth:960,margin:"0 auto",padding:24,boxSizing:"border-box",overflow:"auto",pointerEvents:"auto",color:od[1],fontSize:"var(--vgai-font-base)"},IQt={margin:"0 0 6px",fontSize:20},xqe={color:od[2],fontSize:"var(--vgai-font-sm)"},t9e={display:"block",margin:"14px 0 6px",color:od[1]},DQt={display:"flex",width:"100%",alignItems:"center",justifyContent:"space-between",gap:12},PQt={color:od[2],fontSize:"var(--vgai-font-sm)",fontWeight:500},USn={display:"flex",width:"100%",minWidth:0,alignItems:"center",justifyContent:"space-between",gap:12,color:od[2],fontSize:"var(--vgai-font-sm)"},Iye={marginTop:10,color:nMe,whiteSpace:"pre-wrap"},VSn={width:"100%",boxSizing:"border-box",resize:"vertical"},JSn={overflow:"auto",padding:10,background:Pze.inset,border:`1px solid ${bhe[1]}`,borderRadius:dZ.sm,color:od[2]};function WSn(t,r,i){const a=NSn(t,r,i),l=[...qSn(t),...FSn(),...mRr(t)],d=OSn(t),_=bIt().map(g=>({id:g.id,label:g.label,category:"action",execute:g.execute}));return[...a,...l,..._,...d]}function HSn(t){return t.map(r=>`${r.id}\0${r.label}`).join("")}function GSn(){const t=D0(),r=cbe(),i=RGt(),a=Xe.useSyncExternalStore(Uye,w8,w8),l=Xe.useSyncExternalStore(t.subscribe,t.getShellSnapshot??t.getSnapshot),d=Xe.useSyncExternalStore(TPt,Lhe,Lhe),_=Xe.useSyncExternalStore(oU,Che,Che),g=Xe.useMemo(()=>WSn(t,r,i),[t,r,i,a,l,d,_]),b=Xe.useRef(null);return Xe.useEffect(()=>{const S=HSn(g);S!==b.current&&(b.current=S,tEt(g.map(k=>({id:k.id,label:k.label,category:k.category,run:k.execute}))))},[g]),Xe.useEffect(()=>()=>{b.current=null,tEt([])},[]),null}let NQt=[];const wqe=new Set;function QSn(t){return wqe.add(t),()=>wqe.delete(t)}function KSn(){return NQt}function YSn(){for(const t of wqe)t()}function XSn(t){return`Starter asset "${t.key}" (pack "${t.pack}") did not materialize into ${t.dest}: ${t.reason} Nothing was written for it — features that read that file degrade (a missing clips GLB leaves the character standing without locomotion clips). Use Retry once the cause is fixed.`}function ZSn(t){const r=t.failed.map(i=>({key:i.entry.key,dest:i.entry.dest,pack:i.entry.pack,reason:i.reason}));for(const i of r)ua.error(XSn(i),"assets");NQt=r,YSn()}async function exn(t){try{const{materializeDeclaredAssetPacks:r}=await Xo(async()=>{const{materializeDeclaredAssetPacks:a}=await import("./hosted-asset-materialization-
|
|
1681
|
+
Run ${t.name}?`)){k(!0);try{b(await Xbn(t.name,a,{confirm:!0}))}catch(X){b({ok:!1,error:{code:"REQUEST_FAILED",message:String(X)}})}finally{k(!1)}}};return z.jsxs("div",{style:Sqe,"data-testid":`project-tool:${t.name}`,children:[z.jsx("h2",{style:IQt,children:t.summary}),z.jsx("code",{style:{color:od[2]},children:t.name}),z.jsx("p",{style:{color:od[2]},children:t.description}),z.jsxs("div",{style:xqe,children:[t.host," · ",t.permission.risk," · ",t.sourcePath]}),r.length>0&&z.jsxs("section",{style:{marginTop:18,maxWidth:760},children:[z.jsx("h3",{style:{margin:"0 0 8px",fontSize:13},children:"Presentations"}),z.jsx("div",{style:{display:"grid",gap:8},children:r.map(J=>z.jsx(fo,{variant:"ghost",className:"vgai-project-tool-card",onClick:()=>fI(null,J.id),children:z.jsxs("span",{style:DQt,children:[z.jsx("strong",{style:{color:od[1],fontWeight:600},children:J.title}),z.jsx("span",{style:PQt,children:"Open"})]})},J.id))})]}),!P&&z.jsx("div",{style:Iye,children:"This runner supports Node-hosted tools. Import the underlying function directly in browser or runtime code."}),z.jsxs("details",{open:r.length===0,style:{marginTop:18,maxWidth:760},children:[z.jsx("summary",{style:{cursor:"pointer",color:od[2],fontSize:12},children:r.length>0?"Advanced · invoke native schema":"Input"}),z.jsx("section",{style:{marginTop:12},children:z.jsx(MSn,{schema:t.inputSchema,value:a,onChange:J=>{l(J),_(JSON.stringify(J,null,2)),N(null)}})}),w&&z.jsx("div",{style:Iye,children:w}),z.jsx(fo,{variant:"primary",disabled:!P||S||w!==null,"aria-busy":S,onClick:()=>void j(),style:{marginTop:16},children:S?"Running…":"Run tool"}),z.jsxs("details",{style:{marginTop:16},children:[z.jsx("summary",{style:t9e,children:"Advanced JSON"}),z.jsx(Nze,{id:`tool-input:${t.name}`,value:d,onChange:J=>{const X=J.target.value;_(X);try{const G=JSON.parse(X);if(!G||typeof G!="object"||Array.isArray(G))throw new Error("Input must be a JSON object.");l(G),N(null)}catch(G){N(G instanceof Error?G.message:String(G))}},rows:10,"data-variant":"code",style:VSn}),z.jsxs("details",{children:[z.jsx("summary",{style:t9e,children:"Input schema"}),z.jsx(cTt,{value:t.inputSchema})]})]})]}),g!==null&&z.jsxs("section",{children:[z.jsx("div",{style:t9e,children:"Result"}),z.jsx(cTt,{value:g})]})]})}const Sqe={width:"100%",maxWidth:960,margin:"0 auto",padding:24,boxSizing:"border-box",overflow:"auto",pointerEvents:"auto",color:od[1],fontSize:"var(--vgai-font-base)"},IQt={margin:"0 0 6px",fontSize:20},xqe={color:od[2],fontSize:"var(--vgai-font-sm)"},t9e={display:"block",margin:"14px 0 6px",color:od[1]},DQt={display:"flex",width:"100%",alignItems:"center",justifyContent:"space-between",gap:12},PQt={color:od[2],fontSize:"var(--vgai-font-sm)",fontWeight:500},USn={display:"flex",width:"100%",minWidth:0,alignItems:"center",justifyContent:"space-between",gap:12,color:od[2],fontSize:"var(--vgai-font-sm)"},Iye={marginTop:10,color:nMe,whiteSpace:"pre-wrap"},VSn={width:"100%",boxSizing:"border-box",resize:"vertical"},JSn={overflow:"auto",padding:10,background:Pze.inset,border:`1px solid ${bhe[1]}`,borderRadius:dZ.sm,color:od[2]};function WSn(t,r,i){const a=NSn(t,r,i),l=[...qSn(t),...FSn(),...mRr(t)],d=OSn(t),_=bIt().map(g=>({id:g.id,label:g.label,category:"action",execute:g.execute}));return[...a,...l,..._,...d]}function HSn(t){return t.map(r=>`${r.id}\0${r.label}`).join("")}function GSn(){const t=D0(),r=cbe(),i=RGt(),a=Xe.useSyncExternalStore(Uye,w8,w8),l=Xe.useSyncExternalStore(t.subscribe,t.getShellSnapshot??t.getSnapshot),d=Xe.useSyncExternalStore(TPt,Lhe,Lhe),_=Xe.useSyncExternalStore(oU,Che,Che),g=Xe.useMemo(()=>WSn(t,r,i),[t,r,i,a,l,d,_]),b=Xe.useRef(null);return Xe.useEffect(()=>{const S=HSn(g);S!==b.current&&(b.current=S,tEt(g.map(k=>({id:k.id,label:k.label,category:k.category,run:k.execute}))))},[g]),Xe.useEffect(()=>()=>{b.current=null,tEt([])},[]),null}let NQt=[];const wqe=new Set;function QSn(t){return wqe.add(t),()=>wqe.delete(t)}function KSn(){return NQt}function YSn(){for(const t of wqe)t()}function XSn(t){return`Starter asset "${t.key}" (pack "${t.pack}") did not materialize into ${t.dest}: ${t.reason} Nothing was written for it — features that read that file degrade (a missing clips GLB leaves the character standing without locomotion clips). Use Retry once the cause is fixed.`}function ZSn(t){const r=t.failed.map(i=>({key:i.entry.key,dest:i.entry.dest,pack:i.entry.pack,reason:i.reason}));for(const i of r)ua.error(XSn(i),"assets");NQt=r,YSn()}async function exn(t){try{const{materializeDeclaredAssetPacks:r}=await Xo(async()=>{const{materializeDeclaredAssetPacks:a}=await import("./hosted-asset-materialization-DrhYnKEA.js");return{materializeDeclaredAssetPacks:a}},__vite__mapDeps([78,3,2,4,1,8,9,10,11,6])),i=await r(t);ZSn(i)}catch(r){ua.error(`Retrying asset materialization failed before any entry was attempted: ${r instanceof Error?r.message:String(r)}`,"assets")}}let OQt={kind:"quiet"},FQt=0;const Cqe=new Set;function txn(){return OQt}function rxn(t){OQt=t,FQt+=1;for(const r of Cqe)r()}function nxn(t){return Cqe.add(t),()=>Cqe.delete(t)}function lTt(){return FQt}const ixn=()=>()=>{},uTt=()=>null;function sxn(){const t=D0(),r=wbn();Xe.useSyncExternalStore(t.subscribe,t.getShellSnapshot??t.getSnapshot),Xe.useSyncExternalStore(r?.subscribe??ixn,r?.getSnapshot??uTt,r?.getSnapshot??uTt);const i=aNt(t);if(i==="saved")return null;const a=UUe(t),l=i==="failed",d=l?iqr(t):null,_=l?{label:"Save failed",title:d?`Save failed: ${d} — click to open Console`:"Save failed — click to open Console"}:{label:"Unsaved",title:"Unsaved changes — click to save (Cmd/Ctrl+S)"},g=a?`${_.title} — ${a}`:_.title;return z.jsxs(fo,{type:"button","data-testid":"save-status","data-save-state":i,variant:"ghost",size:"compact",className:"vgai-save-status",onClick:()=>l?abe():void lNt(t),title:g,children:[z.jsx("span",{className:"vgai-save-status-dot"}),_.label]})}function oxn(){Xe.useSyncExternalStore(ua.subscribe,ua.getSnapshot);const t=ua.counts,r=[{id:"info",icon:bee,label:"message",count:t.info},{id:"warn",icon:tIt,label:"warning",count:t.warn},{id:"error",icon:Ukt,label:"error",count:t.error}];return z.jsx("span",{className:"vgai-console-status-counts","data-testid":"status-console-counts",children:r.map(i=>z.jsxs(fo,{type:"button",variant:"ghost",size:"compact",className:"vgai-status-action vgai-console-status-count","data-testid":`status-console-${i.id}`,"data-console-level":i.id,"data-has-count":i.count>0?!0:void 0,"data-has-errors":i.id==="error"&&i.count>0?!0:void 0,onClick:()=>abe(),title:`${i.count} console ${i.label}${i.count===1?"":"s"} — open Console`,children:[z.jsx(So,{icon:i.icon,size:"xs"}),i.count]},i.id))})}function axn(t){return[...t.map(i=>`"${i.worldId}" (${i.kind} / ${i.identity}) — ${i.message}`),"See the Console for the full trace."].join(`
|
|
1682
1682
|
`)}function cxn(){const t=Xe.useSyncExternalStore(oNt,IZ);return t.length===0?null:z.jsx(fo,{type:"button",variant:"ghost",size:"compact",className:"vgai-status-action","data-testid":"status-mount-failure","data-status-tone":"danger",onClick:()=>abe(),title:axn(t),children:t.length===1?"1 world failed to mount":`${t.length} worlds failed to mount`})}function lxn(t){return[...t.map(i=>`${i.dest} — ${i.reason}`),"Nothing was written for them, so features that read those files degrade.","See the Console (subsystem `assets`) for the full lines."].join(`
|
|
1683
|
-
`)}function uxn(){const t=Xe.useSyncExternalStore(QSn,KSn),[r,i]=Xe.useState(!1),a=Xe.useCallback(()=>{i(!0),exn(_z()).finally(()=>i(!1))},[]);return t.length===0?null:z.jsxs(z.Fragment,{children:[z.jsx(fo,{type:"button",variant:"ghost",size:"compact",className:"vgai-status-action","data-testid":"status-asset-materialization","data-status-tone":"danger",onClick:()=>abe(),title:lxn(t),children:t.length===1?"1 starter asset did not download":`${t.length} starter assets did not download`}),z.jsx(fo,{type:"button",variant:"ghost",size:"compact",className:"vgai-status-action","data-testid":"status-asset-materialization-retry",disabled:r,onClick:a,children:r?"Retrying…":"Retry"})]})}function fxn(){const t=z7r(),r=D0();if(Xe.useSyncExternalStore(r.subscribe,r.getShellSnapshot??r.getSnapshot),!t)return null;const i=r.playState,a={stopped:{label:"Play stopped",tone:void 0},playing:{label:"Playing",tone:"success"},paused:{label:"Paused",tone:"warning"}}[i];return z.jsx("span",{className:"vgai-status-copy","data-testid":"status-play-state","data-play-state":i,"data-status-tone":a.tone,children:a.label})}function dxn(){Xe.useSyncExternalStore(nxn,lTt,lTt);const t=txn();if(t.kind==="quiet")return null;const r=t.kind==="void"?"error":"warning",i=t.kind==="void"?t.reason==="taken-over"?"Editor yielded":"Editor disconnected":t.subject==="busy"?"Editor slow":"Editor stale";return z.jsxs(fo,{type:"button",variant:"ghost",size:"compact",className:"vgai-status-action","data-testid":"status-editor-lease","data-lease-state":t.kind,"data-tone":r,onClick:()=>window.location.reload(),title:t.kind==="void"&&t.reloadOffered?"The editor is served here again — reload":"The editor server is not answering — reload once it is served here again",children:[z.jsx(So,{icon:r==="error"?yb.status.error:yb.status.warning})," ",i]})}function pxn(){Xe.useSyncExternalStore(g0e,lRr);const t=gE().filter(r=>r.section==="project");return t.length===0?null:z.jsx(z.Fragment,{children:t.map(r=>z.jsx(fo,{type:"button",variant:"ghost",size:"compact",className:"vgai-status-action","data-testid":`status-project-utility-${r.id}`,onClick:()=>hE(r.id),title:`Open the ${r.title} drawer tab (this project's own face)`,children:r.title},r.id))})}const _xn=t0e();function mxn(){_xn.ensure(t=>{t(iP({id:"editor-lease",name:"Editor server",align:"left",order:-90,Content:dxn})),t(iP({id:"save-status",name:"Save state",align:"left",order:0,Content:sxn})),t(iP({id:"console-counts",name:"Console errors and warnings",align:"left",order:10,Content:oxn})),t(iP({id:"mount-failure",name:"Mount failure",align:"left",order:5,Content:cxn})),t(iP({id:"asset-materialization",name:"Asset materialization",align:"left",order:15,Content:uxn})),t(iP({id:"play-state",name:"Play state",align:"left",order:20,Content:fxn})),t(iP({id:"project-utilities",name:"Project utilities",align:"left",order:25,Content:pxn}))})}const hxn=Xe.lazy(async()=>({default:(await Xo(()=>import("./NonThreeAuthoringBootstrap-B3pVzwGx.js"),__vite__mapDeps([79,3,2,4,58,1,8,9,10,11,6]))).ProjectAuthoringBootstrap}));function gxn(){const t=D0(),r=FGt(),i=cbe();return Xe.use(xbn()),Xe.useSyncExternalStore(t.subscribe,t.getShellSnapshot??t.getSnapshot),d2n(t),Xe.useEffect(()=>mxn(),[]),Xe.useEffect(()=>D2n(),[]),Xe.useEffect(()=>rbn(r),[r]),Xe.useEffect(()=>XAn(),[]),Xe.useEffect(()=>_Rr(t),[t]),Xe.useEffect(()=>Hmn(t),[t]),Xe.useEffect(()=>uLr(r),[r]),Xe.useEffect(()=>YAn(t,i),[t,i]),Xe.useEffect(()=>V$r(t),[t]),Xe.useEffect(()=>RUr(()=>window.dispatchEvent(new CustomEvent("editor:assets-changed")),a=>window.dispatchEvent(new CustomEvent("editor:assets-changed",{detail:a}))),[]),z.jsxs(z.Fragment,{children:[z.jsx(Xe.Suspense,{fallback:null,children:z.jsx(hxn,{store:t})}),z.jsx(ASn,{}),z.jsx(r2n,{}),z.jsx(GSn,{})]})}const yxn=3,vxn=1e4,bxn=4e3;function Axn(t){return{bootIdentity:null,lastIdentity:null,consecutiveFailures:0,unbackedFailures:0,darkSince:t}}function fTt(t,r,i,a){if(!r.ok){const l=i==="open";return{...t,lastIdentity:null,consecutiveFailures:t.consecutiveFailures+1,unbackedFailures:l?0:t.unbackedFailures+1,darkSince:l?a:t.darkSince}}return{bootIdentity:t.bootIdentity??r.identity,lastIdentity:r.identity,consecutiveFailures:0,unbackedFailures:0,darkSince:a}}function Sxn(t,r){return{bootIdentity:t.bootIdentity,lastIdentity:null,consecutiveFailures:0,unbackedFailures:0,darkSince:r}}function RQt(t,r){return!(t.project!==null&&r.project!==null&&t.project!==r.project||t.pid!==null&&r.pid!==null&&t.pid!==r.pid)}function xxn(t){const{consecutiveFailures:r,unbackedFailures:i,failureThreshold:a,darkForMs:l,minDarkWindowMs:d,bootIdentity:_,lastIdentity:g}=t;return _&&g&&!RQt(_,g)?{status:"void",reason:"taken-over"}:r>=a?i>=a&&l>=d?{status:"void",reason:"server-gone"}:{status:"degraded",reason:null}:{status:"live",reason:null}}function wxn(t,r){return!t?.project||!r.project?!1:r.project===t.project}function Cxn(t,r){if(!r.ok)return"none";const i=r.identity;return t&&t.pid!==null&&i.pid===t.pid&&RQt(t,i)?"resume":wxn(t,i)?"reload":t?.project?"none":"offer-reload"}const Dye="vgai.editor.orphaned-tab.v1";function Exn(t){if(!t)return null;let r;try{r=JSON.parse(t)}catch{return null}if(typeof r!="object"||r===null)return null;const i=r;if(typeof i.at!="number"||!Number.isFinite(i.at)||i.reason!=="server-gone")return null;const a=typeof i.project=="string"?i.project:null;return{at:i.at,reason:i.reason,project:a}}function Txn(t){return JSON.stringify(t)}function kxn(t,r){const i=Math.max(0,Math.round((r-t.at)/1e3)),a=i<90?`${i}s ago`:i<5400?`${Math.round(i/60)}m ago`:`${Math.round(i/3600)}h ago`,l=t.project?` on ${t.project}`:"";return`A previous editor window at this address lost its server ${a}${l} and was left orphaned. If that window is still open it is a stale snapshot — nothing in it is saved and every click in it hangs on retries. Close it; this window is the live one.`}const Ixn=720*60*1e3;function Dxn(t,r){const i=r-t.at;return i>=0&&i<=Ixn}function iKe(){try{return typeof localStorage>"u"?null:localStorage}catch{return null}}function Pxn(t,r=iKe()){try{r?.setItem(Dye,Txn(t))}catch{}}function Nxn(t=iKe()){if(!t)return null;try{const r=Exn(t.getItem(Dye));return t.removeItem(Dye),r}catch{return null}}function Oxn(t=iKe()){try{t?.removeItem(Dye)}catch{}}function Fxn(t){return t?t.split(/[\\/]/).filter(Boolean).at(-1)??null:null}async function Rxn(){try{const{stopAllLiveSessions:t}=await Xo(async()=>{const{stopAllLiveSessions:r}=await Promise.resolve().then(()=>Ugn);return{stopAllLiveSessions:r}},void 0);t()}catch{}}function Mxn(){const[t,r]=Xe.useState({kind:"quiet"}),i=Xe.useRef(Axn(Date.now())),a=Xe.useRef(null),l=Xe.useRef(!1);return Xe.useEffect(()=>{let d=!1,_=null;const g=()=>{_!==null&&(clearInterval(_),_=null)},b=async X=>{a.current=X,_Nt(X),X==="taken-over"&&g(),X==="server-gone"&&Pxn({at:Date.now(),reason:"server-gone",project:i.current.bootIdentity?.project??null}),r(l.current?{kind:"degraded",subject:"stale"}:{kind:"void",reason:X,reloadOffered:!1}),await Rxn()},S=(X,G,ee)=>{switch(Cxn(i.current.bootIdentity,X)){case"resume":{a.current=null,bqr(),Oxn(),i.current=fTt(i.current,X,G,ee),r({kind:"quiet"});return}case"reload":if(l.current)return;window.location.reload();return;case"offer-reload":r(xe=>xe.kind==="void"&&!xe.reloadOffered?{...xe,reloadOffered:!0}:xe);return;default:return}},k=async()=>{const X=await nzr(),G=Lqr(),ee=Date.now();if(d)return;if(a.current!==null){S(X,G,ee);return}i.current=fTt(i.current,X,G,ee);const xe=xxn({consecutiveFailures:i.current.consecutiveFailures,unbackedFailures:i.current.unbackedFailures,failureThreshold:yxn,darkForMs:ee-i.current.darkSince,minDarkWindowMs:vxn,bootIdentity:i.current.bootIdentity,lastIdentity:i.current.lastIdentity});if(xe.status==="void"&&xe.reason!==null){await b(xe.reason);return}r(xe.status==="degraded"?{kind:"degraded",subject:"busy"}:{kind:"quiet"})};let w=!1;const N=()=>{w||d||(w=!0,k().finally(()=>{w=!1}))},P=()=>{d||(a.current===null&&(i.current=Sxn(i.current,Date.now())),N())},j=()=>{document.visibilityState==="visible"&&P()};document.addEventListener("visibilitychange",j),window.addEventListener("pageshow",P);let J=null;try{const X=VP();X.addEventListener("error",N),X.addEventListener("open",N),J=X}catch{}return _=setInterval(N,bxn),()=>{d=!0,g(),document.removeEventListener("visibilitychange",j),window.removeEventListener("pageshow",P),J?.close()}},[]),Xe.useEffect(()=>{rxn(t);const d=Fxn(i.current.bootIdentity?.project??null),_=()=>{l.current=!0,r({kind:"degraded",subject:"stale"})};if(t.kind==="quiet"){Rze(r9e);return}if(t.kind==="degraded"){az({id:r9e,tone:"warning",sticky:!0,...t.subject==="busy"?{title:"Editor server is slow to answer.",detail:"Still connected — this window keeps working, and this clears itself when the server catches up."}:{title:"This window's editor server has stopped.",detail:"You chose to keep reading it — nothing here saves, and it will not reconnect on its own. Reload once the editor is served here again.",actions:[{label:"Reload",primary:!0,run:()=>window.location.reload()}]}});return}az({id:r9e,tone:"error",sticky:!0,title:"Editor disconnected.",detail:t.reason==="taken-over"?`${d?`${d}'s`:"This project's"} editor is now running in another window. This one has yielded.`:`This window's editor server has stopped — nothing here is saved, and a running game has left its room. Reopen with \`volter-editor edit ${d??"<project>"}\`${d?`, or leave this window open: it reloads by itself when ${d}'s editor is served here again.`:"."}`,onDismiss:()=>{l.current||_()},actions:[...t.reloadOffered?[{label:"Reload",primary:!0,run:()=>window.location.reload()}]:[],{label:"Close window",run:()=>window.close()},{label:"Continue anyway",run:_}]})},[t]),null}const r9e="editor-lease",Lxn="0.5.61",jxn={version:Lxn},Bxn="0.5.61",$xn={version:Bxn},MQt=$xn.version,qxn=jxn.version;function zxn({error:t,onDismiss:r,onRetry:i,startup:a=!1}){const l=t.recovery&&"command"in t.recovery?t.recovery.command:null,[d,_]=Xe.useState(!1);return Xe.useEffect(()=>{if(!d)return;const g=window.setTimeout(()=>_(!1),1600);return()=>window.clearTimeout(g)},[d]),z.jsxs("div",{role:"alert",className:"vgai-error-card vgai-shell-rise",children:[z.jsx("div",{className:"vgai-error-card-icon","aria-hidden":"true",children:z.jsx(So,{icon:vee})}),z.jsxs("div",{className:"vgai-error-card-body",children:[a?z.jsx("h1",{className:"vgai-error-card-title",children:t.recovery?.title??"Couldn’t open this project"}):t.recovery&&z.jsx("div",{className:"vgai-error-card-title",children:t.recovery.title}),t.recovery&&z.jsx("p",{className:"vgai-error-card-guidance",children:t.recovery.guidance}),z.jsx("div",{className:"vgai-error-card-message","data-testid":a?"project-startup-error-details":void 0,children:t.message}),l&&z.jsxs("div",{children:[a&&z.jsx("div",{className:"vgai-error-card-recovery-label",children:"RUN FROM THE PROJECT FOLDER"}),z.jsxs("div",{className:"vgai-error-card-command",children:[z.jsx("code",{"data-testid":a?"project-startup-recovery-command":"project-screen-recovery-command",children:l}),z.jsxs(fo,{type:"button",variant:"secondary",size:"compact",onClick:()=>{navigator.clipboard?.writeText(l),_(!0)},children:[z.jsx(So,{icon:d?S8:sIt,"aria-hidden":"true"}),d?"Copied":"Copy"]})]})]}),z.jsxs("div",{className:"vgai-error-card-actions",children:[i&&z.jsx(fo,{type:"button",variant:"primary",className:"vgai-shell-cta","data-testid":"retry-project-detection",onClick:i,children:"Retry"}),r&&z.jsx(fo,{type:"button",variant:"ghost",className:"vgai-shell-cta","aria-label":"Dismiss error",onClick:r,children:"Dismiss"})]})]})]})}function Eqe({error:t,report:r,onRetry:i}){return z.jsx("div",{className:"vgai-shell","data-testid":"project-detection-error",children:z.jsxs("div",{className:"vgai-shell-container","data-view":"startup-error",children:[z.jsx("header",{className:"vgai-shell-header",children:z.jsxs("span",{className:"vgai-shell-brand-static",children:[z.jsx("span",{className:"vgai-shell-brand-mark","aria-hidden":"true",children:z.jsx(nKe,{size:30,animation:"static"})}),z.jsx("span",{className:"vgai-shell-wordmark",children:pz.name})]})}),z.jsx(zxn,{error:t,onRetry:i,startup:!0}),r?.projectPath&&z.jsx("div",{className:"vgai-shell-notice","data-testid":"project-startup-serving",children:z.jsxs("span",{children:["This editor server is serving"," ",z.jsx("code",{"data-testid":"project-startup-serving-path",children:r.projectPath})," — the project exists; the editor could not read it. Fix the file it names above and press Retry."]})}),z.jsx("footer",{className:"vgai-shell-footer",children:z.jsxs("span",{className:"vgai-chip","data-variant":"tag",children:["Editor v",MQt," · Engine v",qxn]})})]})})}function Uxn({wait:t}={}){return z.jsx("main",{role:"status","aria-live":"polite","aria-label":"Opening project","data-testid":"startup-loading-screen",className:"vgai-splash",children:z.jsxs("div",{className:"vgai-splash-stack",children:[z.jsx("div",{"aria-hidden":"true",className:"vgai-splash-logo",children:z.jsx(nKe,{size:72,animation:"loading"})}),z.jsx("div",{className:"vgai-splash-title",children:pz.name}),z.jsx("div",{"aria-hidden":"true",className:"vgai-splash-progress"}),t?z.jsxs(z.Fragment,{children:[z.jsx("div",{className:"vgai-splash-status","data-testid":"startup-wait-status",children:`Asking the server which project it serves — ${t.seconds}s`}),z.jsx("div",{className:"vgai-splash-note",children:"Still trying. The first boot of a fresh checkout can take a while, so this keeps asking until the server answers."}),t.detail?z.jsxs("div",{className:"vgai-splash-note",children:["Last attempt: ",t.detail]}):null]}):z.jsx("div",{className:"vgai-splash-status",children:"Opening project…"})]})})}class Vxn extends Xe.Component{state={error:null};static getDerivedStateFromError(r){return{error:r}}componentDidCatch(r,i){ua.error(`Editor chrome crashed while the command listener stayed attached: ${r.message}
|
|
1683
|
+
`)}function uxn(){const t=Xe.useSyncExternalStore(QSn,KSn),[r,i]=Xe.useState(!1),a=Xe.useCallback(()=>{i(!0),exn(_z()).finally(()=>i(!1))},[]);return t.length===0?null:z.jsxs(z.Fragment,{children:[z.jsx(fo,{type:"button",variant:"ghost",size:"compact",className:"vgai-status-action","data-testid":"status-asset-materialization","data-status-tone":"danger",onClick:()=>abe(),title:lxn(t),children:t.length===1?"1 starter asset did not download":`${t.length} starter assets did not download`}),z.jsx(fo,{type:"button",variant:"ghost",size:"compact",className:"vgai-status-action","data-testid":"status-asset-materialization-retry",disabled:r,onClick:a,children:r?"Retrying…":"Retry"})]})}function fxn(){const t=z7r(),r=D0();if(Xe.useSyncExternalStore(r.subscribe,r.getShellSnapshot??r.getSnapshot),!t)return null;const i=r.playState,a={stopped:{label:"Play stopped",tone:void 0},playing:{label:"Playing",tone:"success"},paused:{label:"Paused",tone:"warning"}}[i];return z.jsx("span",{className:"vgai-status-copy","data-testid":"status-play-state","data-play-state":i,"data-status-tone":a.tone,children:a.label})}function dxn(){Xe.useSyncExternalStore(nxn,lTt,lTt);const t=txn();if(t.kind==="quiet")return null;const r=t.kind==="void"?"error":"warning",i=t.kind==="void"?t.reason==="taken-over"?"Editor yielded":"Editor disconnected":t.subject==="busy"?"Editor slow":"Editor stale";return z.jsxs(fo,{type:"button",variant:"ghost",size:"compact",className:"vgai-status-action","data-testid":"status-editor-lease","data-lease-state":t.kind,"data-tone":r,onClick:()=>window.location.reload(),title:t.kind==="void"&&t.reloadOffered?"The editor is served here again — reload":"The editor server is not answering — reload once it is served here again",children:[z.jsx(So,{icon:r==="error"?yb.status.error:yb.status.warning})," ",i]})}function pxn(){Xe.useSyncExternalStore(g0e,lRr);const t=gE().filter(r=>r.section==="project");return t.length===0?null:z.jsx(z.Fragment,{children:t.map(r=>z.jsx(fo,{type:"button",variant:"ghost",size:"compact",className:"vgai-status-action","data-testid":`status-project-utility-${r.id}`,onClick:()=>hE(r.id),title:`Open the ${r.title} drawer tab (this project's own face)`,children:r.title},r.id))})}const _xn=t0e();function mxn(){_xn.ensure(t=>{t(iP({id:"editor-lease",name:"Editor server",align:"left",order:-90,Content:dxn})),t(iP({id:"save-status",name:"Save state",align:"left",order:0,Content:sxn})),t(iP({id:"console-counts",name:"Console errors and warnings",align:"left",order:10,Content:oxn})),t(iP({id:"mount-failure",name:"Mount failure",align:"left",order:5,Content:cxn})),t(iP({id:"asset-materialization",name:"Asset materialization",align:"left",order:15,Content:uxn})),t(iP({id:"play-state",name:"Play state",align:"left",order:20,Content:fxn})),t(iP({id:"project-utilities",name:"Project utilities",align:"left",order:25,Content:pxn}))})}const hxn=Xe.lazy(async()=>({default:(await Xo(()=>import("./NonThreeAuthoringBootstrap-kBoH9ZCc.js"),__vite__mapDeps([79,3,2,4,58,1,8,9,10,11,6]))).ProjectAuthoringBootstrap}));function gxn(){const t=D0(),r=FGt(),i=cbe();return Xe.use(xbn()),Xe.useSyncExternalStore(t.subscribe,t.getShellSnapshot??t.getSnapshot),d2n(t),Xe.useEffect(()=>mxn(),[]),Xe.useEffect(()=>D2n(),[]),Xe.useEffect(()=>rbn(r),[r]),Xe.useEffect(()=>XAn(),[]),Xe.useEffect(()=>_Rr(t),[t]),Xe.useEffect(()=>Hmn(t),[t]),Xe.useEffect(()=>uLr(r),[r]),Xe.useEffect(()=>YAn(t,i),[t,i]),Xe.useEffect(()=>V$r(t),[t]),Xe.useEffect(()=>RUr(()=>window.dispatchEvent(new CustomEvent("editor:assets-changed")),a=>window.dispatchEvent(new CustomEvent("editor:assets-changed",{detail:a}))),[]),z.jsxs(z.Fragment,{children:[z.jsx(Xe.Suspense,{fallback:null,children:z.jsx(hxn,{store:t})}),z.jsx(ASn,{}),z.jsx(r2n,{}),z.jsx(GSn,{})]})}const yxn=3,vxn=1e4,bxn=4e3;function Axn(t){return{bootIdentity:null,lastIdentity:null,consecutiveFailures:0,unbackedFailures:0,darkSince:t}}function fTt(t,r,i,a){if(!r.ok){const l=i==="open";return{...t,lastIdentity:null,consecutiveFailures:t.consecutiveFailures+1,unbackedFailures:l?0:t.unbackedFailures+1,darkSince:l?a:t.darkSince}}return{bootIdentity:t.bootIdentity??r.identity,lastIdentity:r.identity,consecutiveFailures:0,unbackedFailures:0,darkSince:a}}function Sxn(t,r){return{bootIdentity:t.bootIdentity,lastIdentity:null,consecutiveFailures:0,unbackedFailures:0,darkSince:r}}function RQt(t,r){return!(t.project!==null&&r.project!==null&&t.project!==r.project||t.pid!==null&&r.pid!==null&&t.pid!==r.pid)}function xxn(t){const{consecutiveFailures:r,unbackedFailures:i,failureThreshold:a,darkForMs:l,minDarkWindowMs:d,bootIdentity:_,lastIdentity:g}=t;return _&&g&&!RQt(_,g)?{status:"void",reason:"taken-over"}:r>=a?i>=a&&l>=d?{status:"void",reason:"server-gone"}:{status:"degraded",reason:null}:{status:"live",reason:null}}function wxn(t,r){return!t?.project||!r.project?!1:r.project===t.project}function Cxn(t,r){if(!r.ok)return"none";const i=r.identity;return t&&t.pid!==null&&i.pid===t.pid&&RQt(t,i)?"resume":wxn(t,i)?"reload":t?.project?"none":"offer-reload"}const Dye="vgai.editor.orphaned-tab.v1";function Exn(t){if(!t)return null;let r;try{r=JSON.parse(t)}catch{return null}if(typeof r!="object"||r===null)return null;const i=r;if(typeof i.at!="number"||!Number.isFinite(i.at)||i.reason!=="server-gone")return null;const a=typeof i.project=="string"?i.project:null;return{at:i.at,reason:i.reason,project:a}}function Txn(t){return JSON.stringify(t)}function kxn(t,r){const i=Math.max(0,Math.round((r-t.at)/1e3)),a=i<90?`${i}s ago`:i<5400?`${Math.round(i/60)}m ago`:`${Math.round(i/3600)}h ago`,l=t.project?` on ${t.project}`:"";return`A previous editor window at this address lost its server ${a}${l} and was left orphaned. If that window is still open it is a stale snapshot — nothing in it is saved and every click in it hangs on retries. Close it; this window is the live one.`}const Ixn=720*60*1e3;function Dxn(t,r){const i=r-t.at;return i>=0&&i<=Ixn}function iKe(){try{return typeof localStorage>"u"?null:localStorage}catch{return null}}function Pxn(t,r=iKe()){try{r?.setItem(Dye,Txn(t))}catch{}}function Nxn(t=iKe()){if(!t)return null;try{const r=Exn(t.getItem(Dye));return t.removeItem(Dye),r}catch{return null}}function Oxn(t=iKe()){try{t?.removeItem(Dye)}catch{}}function Fxn(t){return t?t.split(/[\\/]/).filter(Boolean).at(-1)??null:null}async function Rxn(){try{const{stopAllLiveSessions:t}=await Xo(async()=>{const{stopAllLiveSessions:r}=await Promise.resolve().then(()=>Ugn);return{stopAllLiveSessions:r}},void 0);t()}catch{}}function Mxn(){const[t,r]=Xe.useState({kind:"quiet"}),i=Xe.useRef(Axn(Date.now())),a=Xe.useRef(null),l=Xe.useRef(!1);return Xe.useEffect(()=>{let d=!1,_=null;const g=()=>{_!==null&&(clearInterval(_),_=null)},b=async X=>{a.current=X,_Nt(X),X==="taken-over"&&g(),X==="server-gone"&&Pxn({at:Date.now(),reason:"server-gone",project:i.current.bootIdentity?.project??null}),r(l.current?{kind:"degraded",subject:"stale"}:{kind:"void",reason:X,reloadOffered:!1}),await Rxn()},S=(X,G,ee)=>{switch(Cxn(i.current.bootIdentity,X)){case"resume":{a.current=null,bqr(),Oxn(),i.current=fTt(i.current,X,G,ee),r({kind:"quiet"});return}case"reload":if(l.current)return;window.location.reload();return;case"offer-reload":r(xe=>xe.kind==="void"&&!xe.reloadOffered?{...xe,reloadOffered:!0}:xe);return;default:return}},k=async()=>{const X=await nzr(),G=Lqr(),ee=Date.now();if(d)return;if(a.current!==null){S(X,G,ee);return}i.current=fTt(i.current,X,G,ee);const xe=xxn({consecutiveFailures:i.current.consecutiveFailures,unbackedFailures:i.current.unbackedFailures,failureThreshold:yxn,darkForMs:ee-i.current.darkSince,minDarkWindowMs:vxn,bootIdentity:i.current.bootIdentity,lastIdentity:i.current.lastIdentity});if(xe.status==="void"&&xe.reason!==null){await b(xe.reason);return}r(xe.status==="degraded"?{kind:"degraded",subject:"busy"}:{kind:"quiet"})};let w=!1;const N=()=>{w||d||(w=!0,k().finally(()=>{w=!1}))},P=()=>{d||(a.current===null&&(i.current=Sxn(i.current,Date.now())),N())},j=()=>{document.visibilityState==="visible"&&P()};document.addEventListener("visibilitychange",j),window.addEventListener("pageshow",P);let J=null;try{const X=VP();X.addEventListener("error",N),X.addEventListener("open",N),J=X}catch{}return _=setInterval(N,bxn),()=>{d=!0,g(),document.removeEventListener("visibilitychange",j),window.removeEventListener("pageshow",P),J?.close()}},[]),Xe.useEffect(()=>{rxn(t);const d=Fxn(i.current.bootIdentity?.project??null),_=()=>{l.current=!0,r({kind:"degraded",subject:"stale"})};if(t.kind==="quiet"){Rze(r9e);return}if(t.kind==="degraded"){az({id:r9e,tone:"warning",sticky:!0,...t.subject==="busy"?{title:"Editor server is slow to answer.",detail:"Still connected — this window keeps working, and this clears itself when the server catches up."}:{title:"This window's editor server has stopped.",detail:"You chose to keep reading it — nothing here saves, and it will not reconnect on its own. Reload once the editor is served here again.",actions:[{label:"Reload",primary:!0,run:()=>window.location.reload()}]}});return}az({id:r9e,tone:"error",sticky:!0,title:"Editor disconnected.",detail:t.reason==="taken-over"?`${d?`${d}'s`:"This project's"} editor is now running in another window. This one has yielded.`:`This window's editor server has stopped — nothing here is saved, and a running game has left its room. Reopen with \`volter-editor edit ${d??"<project>"}\`${d?`, or leave this window open: it reloads by itself when ${d}'s editor is served here again.`:"."}`,onDismiss:()=>{l.current||_()},actions:[...t.reloadOffered?[{label:"Reload",primary:!0,run:()=>window.location.reload()}]:[],{label:"Close window",run:()=>window.close()},{label:"Continue anyway",run:_}]})},[t]),null}const r9e="editor-lease",Lxn="0.5.62",jxn={version:Lxn},Bxn="0.5.62",$xn={version:Bxn},MQt=$xn.version,qxn=jxn.version;function zxn({error:t,onDismiss:r,onRetry:i,startup:a=!1}){const l=t.recovery&&"command"in t.recovery?t.recovery.command:null,[d,_]=Xe.useState(!1);return Xe.useEffect(()=>{if(!d)return;const g=window.setTimeout(()=>_(!1),1600);return()=>window.clearTimeout(g)},[d]),z.jsxs("div",{role:"alert",className:"vgai-error-card vgai-shell-rise",children:[z.jsx("div",{className:"vgai-error-card-icon","aria-hidden":"true",children:z.jsx(So,{icon:vee})}),z.jsxs("div",{className:"vgai-error-card-body",children:[a?z.jsx("h1",{className:"vgai-error-card-title",children:t.recovery?.title??"Couldn’t open this project"}):t.recovery&&z.jsx("div",{className:"vgai-error-card-title",children:t.recovery.title}),t.recovery&&z.jsx("p",{className:"vgai-error-card-guidance",children:t.recovery.guidance}),z.jsx("div",{className:"vgai-error-card-message","data-testid":a?"project-startup-error-details":void 0,children:t.message}),l&&z.jsxs("div",{children:[a&&z.jsx("div",{className:"vgai-error-card-recovery-label",children:"RUN FROM THE PROJECT FOLDER"}),z.jsxs("div",{className:"vgai-error-card-command",children:[z.jsx("code",{"data-testid":a?"project-startup-recovery-command":"project-screen-recovery-command",children:l}),z.jsxs(fo,{type:"button",variant:"secondary",size:"compact",onClick:()=>{navigator.clipboard?.writeText(l),_(!0)},children:[z.jsx(So,{icon:d?S8:sIt,"aria-hidden":"true"}),d?"Copied":"Copy"]})]})]}),z.jsxs("div",{className:"vgai-error-card-actions",children:[i&&z.jsx(fo,{type:"button",variant:"primary",className:"vgai-shell-cta","data-testid":"retry-project-detection",onClick:i,children:"Retry"}),r&&z.jsx(fo,{type:"button",variant:"ghost",className:"vgai-shell-cta","aria-label":"Dismiss error",onClick:r,children:"Dismiss"})]})]})]})}function Eqe({error:t,report:r,onRetry:i}){return z.jsx("div",{className:"vgai-shell","data-testid":"project-detection-error",children:z.jsxs("div",{className:"vgai-shell-container","data-view":"startup-error",children:[z.jsx("header",{className:"vgai-shell-header",children:z.jsxs("span",{className:"vgai-shell-brand-static",children:[z.jsx("span",{className:"vgai-shell-brand-mark","aria-hidden":"true",children:z.jsx(nKe,{size:30,animation:"static"})}),z.jsx("span",{className:"vgai-shell-wordmark",children:pz.name})]})}),z.jsx(zxn,{error:t,onRetry:i,startup:!0}),r?.projectPath&&z.jsx("div",{className:"vgai-shell-notice","data-testid":"project-startup-serving",children:z.jsxs("span",{children:["This editor server is serving"," ",z.jsx("code",{"data-testid":"project-startup-serving-path",children:r.projectPath})," — the project exists; the editor could not read it. Fix the file it names above and press Retry."]})}),z.jsx("footer",{className:"vgai-shell-footer",children:z.jsxs("span",{className:"vgai-chip","data-variant":"tag",children:["Editor v",MQt," · Engine v",qxn]})})]})})}function Uxn({wait:t}={}){return z.jsx("main",{role:"status","aria-live":"polite","aria-label":"Opening project","data-testid":"startup-loading-screen",className:"vgai-splash",children:z.jsxs("div",{className:"vgai-splash-stack",children:[z.jsx("div",{"aria-hidden":"true",className:"vgai-splash-logo",children:z.jsx(nKe,{size:72,animation:"loading"})}),z.jsx("div",{className:"vgai-splash-title",children:pz.name}),z.jsx("div",{"aria-hidden":"true",className:"vgai-splash-progress"}),t?z.jsxs(z.Fragment,{children:[z.jsx("div",{className:"vgai-splash-status","data-testid":"startup-wait-status",children:`Asking the server which project it serves — ${t.seconds}s`}),z.jsx("div",{className:"vgai-splash-note",children:"Still trying. The first boot of a fresh checkout can take a while, so this keeps asking until the server answers."}),t.detail?z.jsxs("div",{className:"vgai-splash-note",children:["Last attempt: ",t.detail]}):null]}):z.jsx("div",{className:"vgai-splash-status",children:"Opening project…"})]})})}class Vxn extends Xe.Component{state={error:null};static getDerivedStateFromError(r){return{error:r}}componentDidCatch(r,i){ua.error(`Editor chrome crashed while the command listener stayed attached: ${r.message}
|
|
1684
1684
|
${i.componentStack??""}`,"editor")}render(){return this.state.error?z.jsx(Eqe,{error:{message:`The editor surface crashed: ${this.state.error.message}`},onRetry:()=>this.setState({error:null})}):this.props.children}}function C_e({children:t}){return z.jsxs(z.Fragment,{children:[t,z.jsx(Mxn,{})]})}function Jxn(t){const r=t instanceof Error?t.message:String(t);return t instanceof pI?{status:"error",message:r,recovery:t.recovery}:t instanceof SUe?{status:"error",message:r,report:t.report}:{status:"error",message:r}}const Wxn=8e3;function Hxn(t=tVr,r=Wxn){return new Promise((i,a)=>{const l=window.setTimeout(()=>{a(new I4t(r))},r);t().then(d=>{window.clearTimeout(l),i(d)},d=>{window.clearTimeout(l),a(d)})})}const Gxn=3;function Qxn(){const[t,r]=Xe.useState({status:"detecting",waitingSince:null}),[i,a]=Xe.useState(0);Xe.useEffect(()=>J8r(),[]),Xe.useEffect(()=>jqr(),[]),Xe.useEffect(()=>Tqr(()=>a(b=>b+1)),[]),Xe.useEffect(()=>{let b=!1,S,k=0;const w=Date.now();r({status:"detecting",waitingSince:null});const N=()=>{Hxn().then(P=>{b||r(P?{status:"ready",project:P}:{status:"no-project"})},P=>{if(b)return;k+=1;const j=QMr(P,k);if(j.kind==="terminal"){const X=Jxn(P),G=X.recovery&&"command"in X.recovery?X.recovery.command:null;ua.error(`Startup failed: ${X.message}${G?` Run: ${G}`:""}`,"editor"),r(X);return}const J=P instanceof Error?P.message:String(P);k===Gxn&&ua.error(`Project detection has failed ${k} times and is still retrying: ${J}`,"editor"),r({status:"detecting",waitingSince:w,lastError:J}),S=window.setTimeout(N,j.delayMs)})};return N(),()=>{b=!0,S!==void 0&&window.clearTimeout(S)}},[i]);const l=t.status==="detecting"?t.waitingSince:null,[d,_]=Xe.useState(0);Xe.useEffect(()=>{if(l===null){_(0);return}const b=()=>_(Math.max(0,Math.round((Date.now()-l)/1e3)));b();const S=window.setInterval(b,1e3);return()=>window.clearInterval(S)},[l]),Xe.useEffect(()=>{t.status!=="detecting"&&Vqr(t.status==="ready"?"project":"no-project")},[t.status]);const g=t.status==="ready"?t.project.config.name:t.status==="error"?"Couldn't open project":null;return Xe.useEffect(()=>{document.title=C4t(g)},[g]),t.status==="detecting"?z.jsx(C_e,{children:z.jsx(Uxn,{wait:t.waitingSince===null?void 0:{seconds:d,detail:t.lastError}})}):t.status==="no-project"?z.jsx(C_e,{children:z.jsx(Eqe,{error:{message:"This window has no vgai project open. A session serves one project: open a folder that carries a vgai.project.json, or start one from a terminal — `volter-editor edit <folder>`."},onRetry:()=>a(b=>b+1)})}):t.status==="error"?z.jsx(C_e,{children:z.jsx(Eqe,{error:{message:t.message,...t.recovery?{recovery:t.recovery}:{}},report:t.report,onRetry:()=>a(b=>b+1)})}):z.jsx(C_e,{children:z.jsx(pAn,{children:z.jsx(Vxn,{children:z.jsx(gxn,{})})})})}function sKe(t){Xe.useSyncExternalStore(t.subscribe,t.getShellSnapshot,t.getShellSnapshot),Xe.useSyncExternalStore(Aw,Sb,Sb),Xe.useSyncExternalStore(Nee,MP,MP),Xe.useSyncExternalStore(Zye,k8,k8),Xe.useSyncExternalStore(Hvn,hEt,hEt),Xe.useSyncExternalStore(kee,khe,khe),Xe.useSyncExternalStore(a7r,gAt,gAt),Xe.useSyncExternalStore(V0n,cEt,cEt),Xe.useSyncExternalStore($0e,kZ,kZ),Xe.useSyncExternalStore(qDt,J9e,J9e),Xe.useSyncExternalStore(JOr,Wbt,Wbt),Xe.useSyncExternalStore($Fr,fAt,fAt);const[,r]=Xe.useReducer(l=>l+1,0),{adapter:i}=wm(t),a=Xe.useRef({broad:t.getSnapshot(),shell:t.getShellSnapshot()});return a.current={broad:t.getSnapshot(),shell:t.getShellSnapshot()},Xe.useEffect(()=>{const l=i.subscribe;if(l)return Kg({adapter:i,seam:"editor.subscribe",stage:"effect",detail:"the active Inspector subscribed to adapter-owned changes",run:()=>l.call(i,()=>{const d=a.current,_={broad:t.getSnapshot(),shell:t.getShellSnapshot()};a.current=_,_.broad===d.broad&&_.shell===d.shell&&r()})})},[i,t]),ibe(t)}let zN=null,LQt=0;const Tqe=new Set;function Kxn(){return zN}function dTt(){return LQt}function Yxn(t){return Tqe.add(t),()=>Tqe.delete(t)}function pTt(t){if(!(zN===t||zN!==null&&t!==null&&zN.x===t.x&&zN.y===t.y&&zN.width===t.width&&zN.height===t.height)){zN=t,LQt+=1;for(const i of Tqe)i()}}function Xxn(t,r,i){const a=Math.min(r.maxWidth,Math.max(r.minSize,t.width-r.margin*2)),l=Math.min(r.maxHeight,Math.max(r.minSize,t.height-r.margin*2)),d=t.x+r.margin,_=t.x+t.width-a-r.margin,g=t.y+r.margin,b=t.y+t.height-l-r.margin,S=t.x+t.width-i.right-a,k=t.y+t.height-i.bottom-l;return{width:a,height:l,left:Math.min(Math.max(S,d),Math.max(_,d)),top:Math.min(Math.max(k,g),Math.max(b,g))}}const jQt=Xe.createContext(null);function Zxn({actions:t,children:r}){return z.jsx(jQt.Provider,{value:t,children:r})}function ewn(){return Xe.useContext(jQt)}function RE(t,r){return{...r,iconName:t}}const twn=RE("outliner-object",f9),rwn=RE("outliner-light",Vkt),nwn=RE("outliner-camera",zye),iwn=RE("outliner-audio",gDr),n9e=RE("outliner-data",GIr),_Tt=RE("outliner-mesh",f9),swn={three:twn,react:Jkt,canvas:fIt,scene:cIt,mesh:_Tt,"skinned-mesh":_Tt,"mesh-data":n9e,"three-source":n9e,"model-asset":n9e,light:rwn,camera:nwn,audio:iwn,"reflection-probe":rze,group:E9e,object:Hkt,component:yee,img:BY,a:ZIr,ul:L_e,ol:L_e,li:L_e,button:C9e,sprite:BY,animatedsprite:Zkt,nineslicesprite:BY,tilingsprite:BY,text:vDr,graphics:C9e,container:E9e},own=RE("outliner-render-on",zye),awn=RE("outliner-render-off",WIr),cwn=RE("outliner-exclude-on",HIr),lwn=RE("outliner-exclude-off",C9e),uwn=/^blender-[a-z0-9-]+$/;function iZ(t,r=Hkt){const i=swn[t];return i||(uwn.test(t)?RE(t,r):r)}const fwn=new Set(["mesh-data","blender-material-data","blender-shapekey-data","blender-texture-data","blender-image-data"]),dwn=["blender-outliner-data-","blender-light-","blender-lightprobe-"];function BQt(t){return t===void 0?!1:fwn.has(t)?!0:dwn.some(r=>t.startsWith(r))}function mTt(t){return t.revertsTo===void 0?`Revert ${t.label} to default`:`Revert ${t.label} to ${t.revertsTo}`}function pwn({value:t,onCommit:r,onPreview:i,...a}){const[l,d]=Xe.useState(null),_=Xe.useRef(null),g=Xe.useRef(null),b=Xe.useRef({draft:l,onCommit:r});return b.current={draft:l,onCommit:r},Xe.useEffect(()=>{const S=_.current;if(!S)return;const k=()=>{const{draft:w,onCommit:N}=b.current,P=w??S.value;P&&P!==g.current&&N(P),g.current=null,d(null)};return S.addEventListener("change",k),()=>S.removeEventListener("change",k)},[]),z.jsx(v3t,{...a,ref:_,value:l??t,onChange:S=>{g.current===null&&(g.current=t),d(S.target.value),i?.(S.target.value)}})}async function $Qt(t,r=CNt){const i=await Promise.all(r.map(a=>_wn(t,a)));return{assets:i.flatMap(a=>a.assets),failedListings:i.flatMap(a=>a.failedListings)}}async function _wn(t,r){const i=[""],a=[],l=[];let d=0;for(;i.length>0&&d<512;){const _=i.splice(0,8),g=await Promise.all(_.map(b=>t(r,b)));d+=_.length,g.forEach((b,S)=>{const k=_[S];if(!b.ok){l.push(`${r}/${k}: ${b.reason}`);return}for(const w of b.entries){const N=k?`${k}/${w.name}`:w.name;w.type==="directory"?i.push(N):a.push({path:N,root:r,entry:w})}})}return{assets:a,failedListings:l}}async function mwn(t,r){const i=t.filter(g=>g.root==="public"),a=hwn(i),l=(await Promise.all(a.map(async g=>{const b=await r(g.path);if(!b)return null;const S=WUe(b);return S?{sidecar:g,parsed:S}:null}))).flatMap(g=>g?[g]:[]),d=new Set;for(const{sidecar:g,parsed:b}of l){d.add(g.path);const S=hTt(g.path);for(const k of uqr(b.image))d.add(S?`${S}/${k}`:k);for(const k of i)vLe(k.path)===vLe(g.path)&&d.add(k.path)}const _=l.flatMap(({sidecar:g,parsed:b})=>{const S=hTt(g.path),k=S?`${S}/${b.image}`:b.image;return b.frames.map(w=>({path:`${k}#${w.name}`,root:g.root,entry:{name:`${w.name}.png`,type:"file",...g.entry.size===void 0?{}:{size:g.entry.size},...g.entry.modifiedAt===void 0?{}:{modifiedAt:g.entry.modifiedAt}},spritesheet:{sheetPath:k,x:w.x,y:w.y,width:w.width,height:w.height,rotated:w.rotated,sourceWidth:w.sourceWidth,sourceHeight:w.sourceHeight,trimX:w.trimX,trimY:w.trimY}}))});return[...t.filter(g=>g.root!=="public"||!d.has(g.path)),..._]}function hwn(t){const r=new Map;for(const i of t){if(!/\.json$/i.test(i.path))continue;const a=vLe(i.path),l=r.get(a);(!l||L2t(i.path)>L2t(l.path))&&r.set(a,i)}return[...r.values()]}function hTt(t){const r=t.lastIndexOf("/");return r<0?"":t.slice(0,r)}function qQt(t){const r=wg(t).kind;return r==="model"||r==="image"||r==="video"||r==="audio"?r:"other"}function gwn(t){const r=wg(t.entry.name);return r.placeable&&r.runtimeReady?10:r.kind==="model"&&r.runtimeReady?15:r.kind==="prefab"?25:r.runtimeReady&&(r.kind==="image"||r.kind==="audio")?30:r.runtimeReady?40:r.importable?70:90}function ywn(t){return(t.surface==="three"?0:t.surface==="canvas"?10:t.surface==="dom"?20:30)+(t.exported?0:4)}const vwn=1e4,bwn={paths:[],failures:[]};let OY=null;async function Awn(){const t=await $Qt(J0e,["public"]);return{paths:t.assets.filter(r=>qQt(r.entry.name)==="image").map(r=>r.path).sort((r,i)=>r.localeCompare(i)),failures:t.failedListings}}function Swn(){const t=Date.now();return(!OY||t-OY.at>vwn)&&(OY={at:t,scan:Awn().catch(r=>(OY=null,{paths:[],failures:[r instanceof Error?r.message:String(r)]}))}),OY.scan}function xwn(t){const[r,i]=Xe.useState(bwn);return Xe.useEffect(()=>{let a=!0;return Swn().then(l=>{a&&i(l)}),()=>{a=!1}},[t]),r}const wwn={width:64},gTt={width:MFr,fontSize:"var(--vgai-font-md)",color:Oo.content.muted};function UN(t){return`ingest-prop-${t.replace(/\./g,"-")}`}function Cwn({field:t,io:r,value:i}){const{paths:a,failures:l}=xwn(!0),[d,_]=Xe.useState(null),g=k=>{_(null),Promise.resolve(r.set(t.path,k===""?null:k)).then(w=>{_(w&&!w.persisted?{forValue:k,text:`Not saved — ${w.destination}. See the editor console for the mechanism.`}:null)})},b=d?.forValue===i?d.text:void 0,S=l.length>0?`${l.length} folder(s) under public/ could not be read — this list may be incomplete.`:void 0;return z.jsx(LFr,{testId:UN(t.path),value:i,options:a,previewUrlFor:k=>`/${k}`,disabled:t.readonly,note:b??S,onChange:g})}function Ewn({field:t,io:r}){const i=t,a=r.get(i.path),l=dMe(a)?void 0:a,d=i.defaulted===!0&&l===void 0,_=i.readonly?Lze(i):void 0,g=i.resettable?z.jsx(rf,{"data-testid":`ingest-revert-${i.path.replace(/\./g,"-")}`,"aria-label":mTt(i),title:mTt(i),onClick:()=>r.remove?.(i.path),children:z.jsx(So,{icon:rIt})}):null;return i.type==="boolean"?z.jsxs("label",{title:_,style:{display:"flex",gap:6,alignItems:"center",padding:"6px 8px",fontSize:"var(--vgai-font-md)"},children:[z.jsx(SE,{"data-testid":UN(i.path),checked:!!l,ref:b=>{b&&(b.indeterminate=d)},disabled:i.readonly,onChange:b=>r.set(i.path,b.target.checked)}),z.jsx("span",{style:i.defaulted?{color:Oo.content.dim}:void 0,children:i.label}),g]}):z.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"6px 8px"},children:[z.jsx("span",{style:i.defaulted?{...gTt,color:Oo.content.dim}:gTt,title:_??(i.defaulted?`${i.label} — default (not set here)`:i.label),children:i.label}),i.type==="color"?z.jsx(pwn,{"data-testid":i.path==="material.color"?"ingest-color":UN(i.path),value:l??"#ffffff",disabled:i.readonly,onCommit:b=>r.set(i.path,b),onPreview:b=>r.preview?.(i.path,b)}):i.type==="number"?z.jsx(uMe,{type:"number","data-testid":UN(i.path),disabled:i.readonly,value:typeof l=="number"?String(Math.round(l*1e3)/1e3):"",placeholder:d?"—":void 0,onCommit:b=>{const S=Number.parseFloat(b);Number.isFinite(S)&&r.set(i.path,S)},style:wwn}):i.type==="enum"?z.jsxs(bS,{"data-testid":UN(i.path),disabled:i.readonly,value:String(l??""),onChange:b=>{const S=i.options?.find(k=>String(k)===b.target.value)??b.target.value;r.set(i.path,S)},style:{width:120},children:[d&&z.jsx("option",{value:"",children:"—"}),(i.options??[]).map(b=>z.jsx("option",{value:String(b),children:String(b)},String(b)))]}):i.type==="vec3"?z.jsx("div",{style:{width:190},children:z.jsx(FFr,{value:Array.isArray(l)&&l.length===3?[Number(l[0]),Number(l[1]),Number(l[2])]:[null,null,null],disabled:!!i.readonly,testIdPrefix:UN(i.path),onChange:b=>r.set(i.path,b)})}):i.type==="asset"?z.jsx(Cwn,{field:i,io:r,value:typeof l=="string"?l:""}):i.type==="json"?z.jsx(Nze,{"data-testid":UN(i.path),"data-variant":"code",disabled:i.readonly,defaultValue:d?"":JSON.stringify(l??null),placeholder:d?"—":void 0,onBlur:b=>{try{r.set(i.path,JSON.parse(b.target.value))}catch{}},style:{width:160}},`${i.path}:${JSON.stringify(l??null)}`):z.jsx(uMe,{type:"text","data-testid":UN(i.path),readOnly:i.readonly,value:String(l??""),placeholder:d?"—":void 0,onCommit:b=>r.set(i.path,b),style:{width:120}}),g]})}function Twn({fields:t,io:r}){return z.jsx(z.Fragment,{children:t.map(i=>z.jsx(Ewn,{field:i,io:r},i.path))})}function kqe(t){return t.body.kind==="fields"?z.jsx(Twn,{fields:t.body.fields,io:t.body.io}):t.body.render()}function oKe({action:t}){return z.jsx(rf,{"data-testid":t.id,"aria-label":t.title,title:t.title,"aria-pressed":t.pressed,disabled:t.disabled,onClick:t.run,children:t.icon&&z.jsx(So,{icon:t.icon})})}function aKe(t){return t.related.find(r=>r.id.startsWith("definition:"))??null}function kwn(t){return t.related.filter(r=>!r.id.startsWith("creation-site:")&&!r.id.startsWith("definition:"))}function cKe({link:t}){return z.jsxs(fo,{variant:"secondary",size:"compact","data-testid":"inspector-open-definition",title:t.title,onClick:t.open,style:{display:"inline-flex",alignItems:"center",gap:4,flexShrink:0},children:[z.jsx(So,{icon:CDr}),z.jsx("span",{style:{maxWidth:120,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.title})]})}function zQt({subject:t}){const r=kwn(t);return r.length===0?null:z.jsx("div",{"data-testid":"inspector-related-subjects",style:{display:"flex",flexWrap:"wrap",gap:4,padding:"6px 8px"},children:r.map(i=>z.jsx(fo,{variant:"ghost",onClick:i.open,title:i.title,children:i.title},i.id))})}function UQt({subject:t,onJump:r}){const i=SGt(t);return i.length<5||new Set(i.map(a=>a.icon)).size<3?null:z.jsx("div",{className:"vgai-inspector-icon-strip",role:"toolbar","aria-label":"Sections","data-testid":"inspector-section-strip",children:i.map(a=>z.jsx(rf,{size:"compact","data-testid":`section-icon-${a.id}`,"aria-label":a.title,title:a.title,onClick:()=>r(a.id),children:z.jsx(So,{icon:a.icon})},a.id))})}function Iwn({render:t,glyph:r,subjectKey:i}){const a=nbe(i)?t:null;return a?z.jsx("div",{"aria-hidden":"true",style:{position:"absolute",inset:0,pointerEvents:"none"},children:a("thumbnail")}):z.jsx(So,{icon:r})}function lKe({subject:t}){const r=t.identity;if(!r)return null;const i=[r.kindLabel,r.note?.text].filter(Boolean).join(" — ");return r.rename.readOnly?z.jsx("div",{"data-testid":"ingest-name","data-readonly":"true",...i?{title:i}:{},style:{flex:1,minWidth:0,fontSize:"var(--vgai-font-md)",fontWeight:600,color:Oo.content.primary,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:t.title}):z.jsx(uMe,{"data-testid":"ingest-name","aria-label":"Name",value:t.title,onCommit:a=>{a.trim()!==""&&r.rename.set(a)},"data-emphasis":"strong",...i?{title:i}:{},style:{flex:1,minWidth:0}})}function VQt({subject:t}){const r=t.identity;if(!r)return z.jsxs("div",{style:{padding:12},children:[z.jsx("div",{style:{fontSize:"var(--vgai-font-md)",fontWeight:600},children:t.title}),t.hint&&z.jsx("div",{"data-testid":"inspector-subject-hint",style:{marginTop:4,fontSize:"var(--vgai-font-base)",color:Oo.content.dim},children:t.hint})]});const i=aKe(t);return z.jsxs("div",{className:"vgai-inspector-identity",style:{padding:`${pv[1]} ${pv[4]}`,borderBottom:"1px solid var(--vgai-structural-divider)"},children:[z.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[z.jsx(lKe,{subject:t}),r.kindLabel&&z.jsx("span",{"data-testid":"inspector-kind-label",style:{fontSize:"var(--vgai-font-base)",color:Oo.content.dim,whiteSpace:"nowrap"},children:r.kindLabel}),Bze(t,"identity").map(a=>z.jsx(oKe,{action:a},a.id)),i&&z.jsx(cKe,{link:i})]}),r.document&&z.jsx("div",{"data-testid":"inspector-document-path","data-document-path":r.document.path,...r.document.title?{title:r.document.title}:{},style:{marginTop:pv[1],fontSize:"var(--vgai-font-base)",color:Oo.content.muted,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",direction:"rtl",textAlign:"left"},children:z.jsx("bdi",{children:r.document.path})}),t.alsoSelected?z.jsx("div",{"data-testid":"inspector-also-selected",style:{marginTop:6,fontSize:"var(--vgai-font-base)",color:Oo.content.dim},children:`${t.alsoSelected+1} selected — fields edit this one, the gizmo moves all`}):null,r.note?.text&&z.jsx("div",{"data-testid":"inspector-subject-note",style:{marginTop:6,fontSize:"var(--vgai-font-base)",color:Oo.content.dim},children:r.note.text})]})}function Dwn({subject:t}){const r=t.identity;if(!r)return z.jsx(VQt,{subject:t});const i=aKe(t),a=r.kind?iZ(r.kind,Pye(t)):Pye(t),l=t.title||r.kindLabel||"",d=[r.kindLabel,r.document?.path,r.document?.title].filter(Boolean).join(" — ");return z.jsxs("div",{className:"vgai-inspector-identity","data-vgai-identity-layout":"properties",children:[z.jsxs("div",{className:"vgai-inspector-breadcrumb",children:[z.jsx(So,{icon:a,tone:"primary"}),z.jsx("span",{className:"vgai-inspector-breadcrumb-chain","data-testid":"inspector-document-path",...r.document?{"data-document-path":r.document.path}:{},...d?{title:d}:{},children:z.jsx("bdi",{children:l})}),Bze(t,"identity").map(_=>z.jsx(oKe,{action:_},_.id))]}),z.jsxs("div",{className:"vgai-inspector-datablock",children:[z.jsx("span",{className:"vgai-inspector-datablock-kind","data-testid":"inspector-kind-label",...r.kindLabel?{title:r.kindLabel}:{},children:z.jsx(So,{icon:a,tone:"primary"})}),z.jsx(lKe,{subject:t}),i&&z.jsx(cKe,{link:i})]}),t.alsoSelected?z.jsx("div",{"data-testid":"inspector-also-selected",style:{marginTop:pv[3],fontSize:"var(--vgai-font-base)",color:Oo.content.dim},children:`${t.alsoSelected+1} selected — fields edit this one, the gizmo moves all`}):null,r.note?.text&&z.jsx("div",{"data-testid":"inspector-subject-note",style:{marginTop:pv[3],fontSize:"var(--vgai-font-base)",color:Oo.content.dim},children:r.note.text})]})}function Pwn({section:t}){return z.jsx("div",{"data-testid":t.testId,"data-inspector-section":t.id,children:z.jsx(DFr,{label:t.title,icon:t.icon,description:t.description,collapsible:!0,defaultOpen:t.defaultOpen??!0,children:kqe(t)})})}function Nwn({subject:t}){const r=Xe.useRef(null),i=a=>{r.current?.querySelector(`[data-inspector-section="${a}"]`)?.scrollIntoView({block:"nearest",behavior:"smooth"})};return z.jsxs("div",{style:{pointerEvents:"auto"},children:[z.jsx(VQt,{subject:t}),z.jsx(UQt,{subject:t,onJump:i}),z.jsx(zQt,{subject:t}),z.jsx("div",{ref:r,children:t.sections.map(a=>z.jsx(Xe.Fragment,{children:z.jsx(Pwn,{section:a})},a.id))})]})}const E_e=new Map;let yTt=null;function Own({subject:t}){const r=SGt(t),i=E_e.get(t.id)??yTt,[a,l]=Xe.useState(null),d=(a&&r.some(b=>b.id===a)?a:null)??(i&&r.some(b=>b.id===i)?i:null)??r.find(b=>b.railDefault)?.id??r[0]?.id??null,_=t.sections.find(b=>b.id===d)??null,g=b=>{l(b),E_e.size>200&&E_e.clear(),E_e.set(t.id,b),yTt=b};return z.jsx("div",{className:"vgai-inspector-properties-fill",style:{pointerEvents:"auto"},children:z.jsxs("div",{className:"vgai-inspector-properties","data-testid":"inspector-properties",children:[z.jsx("div",{className:"vgai-inspector-properties-rail",role:"tablist","aria-orientation":"vertical","aria-label":"Sections",children:r.map((b,S)=>z.jsxs(Xe.Fragment,{children:[S>0&&b.railGroup!==r[S-1]?.railGroup?z.jsx("div",{className:"vgai-inspector-properties-rail-separator","data-testid":"properties-tab-separator",role:"presentation"}):null,z.jsx(rf,{size:"compact",role:"tab","aria-selected":b.id===d,"data-testid":`properties-tab-${b.id}`,"aria-label":b.title,title:b.title,onClick:()=>g(b.id),children:z.jsx(So,{icon:b.icon,size:"xl"})})]},b.id))}),z.jsxs("div",{className:"vgai-inspector-properties-body",role:"tabpanel",children:[z.jsx(Dwn,{subject:t}),z.jsx(zQt,{subject:t}),_?z.jsx("div",{"data-testid":_.testId,"data-inspector-section":_.id,children:kqe(_)}):null,t.sections.filter(b=>b.keepMounted&&b.id!==d).map(b=>z.jsx("div",{"data-inspector-section":b.id,"data-inspector-section-hidden":"true",style:{display:"none"},children:kqe(b)},b.id))]})]})})}function Pye(t){return t.sections[0]?.icon??f9}function Fwn({subject:t,surface:r}){const i=ewn(),a=t.sections.find(b=>b.body.kind==="preview"),l=a?.body.kind==="preview"?a.body:null,d=aKe(t),_=r?()=>AGt(r,"column"):null,g=t.identity!==null;return z.jsxs("div",{className:"vgai-mini-inspector","data-testid":"inspector-panel","data-vgai-inspector-presentation":"card",onPointerDown:()=>H8("inspector"),children:[i&&z.jsx(rf,{size:"compact",className:"vgai-mini-inspector-minimize","data-testid":"inspector-minimize","aria-label":"Minimize inspector",title:"Minimize inspector",onClick:i.minimize,children:z.jsx(So,{icon:qIr})}),z.jsx("div",{className:"vgai-mini-inspector-preview","data-testid":"inspector-mini-preview",..._?{role:"button",tabIndex:0,"aria-label":`Expand inspector for ${t.title}`,title:`Expand inspector for ${t.title}`,onClick:_,onKeyDown:b=>{(b.key===" "||b.key==="Enter")&&(b.preventDefault(),_())}}:{},children:z.jsx(Iwn,{render:l?l.render:null,glyph:Pye(t),subjectKey:t.id})}),g?z.jsxs("div",{className:"vgai-mini-inspector-identity",children:[z.jsx(lKe,{subject:t}),Bze(t,"identity").map(b=>z.jsx(oKe,{action:b},b.id))]}):z.jsx("div",{className:"vgai-mini-inspector-identity",children:z.jsx("div",{style:{flex:1,minWidth:0,fontSize:"var(--vgai-font-md)",fontWeight:600},children:t.title})}),z.jsx(UQt,{subject:t,onJump:()=>_?.()}),d&&z.jsx("div",{className:"vgai-mini-inspector-actions",children:z.jsx(cKe,{link:d})})]})}function Rwn({subject:t,onExpand:r,onClear:i}){const a=t.sections.find(d=>d.body.kind==="preview"),l=a?.body.kind==="preview"?a.body:null;return z.jsxs("div",{className:"vgai-inspector-pill","data-testid":"inspector-pill",children:[z.jsxs("div",{role:"button",tabIndex:0,className:"vgai-inspector-pill-open","aria-label":`Expand inspector for ${t.title}`,title:`Expand inspector for ${t.title}`,onClick:r,onKeyDown:d=>{(d.key===" "||d.key==="Enter")&&(d.preventDefault(),r())},children:[z.jsx("span",{className:"vgai-inspector-pill-thumb","aria-hidden":"true",children:l?l.render("thumbnail"):z.jsx(So,{icon:Pye(t)})}),z.jsx("span",{className:"vgai-inspector-pill-name",children:t.title})]}),i&&z.jsx(rf,{"data-testid":"inspector-fab-clear-selection","aria-label":"Clear selection",title:"Clear selection",onClick:i,children:z.jsx(So,{icon:eze})})]})}const T_e=new Map;function vTt({subject:t,presentation:r,surface:i}){const a=t.id,l=Xe.useCallback(d=>{d&&(d.scrollTop=T_e.get(a)??0)},[a]);return r==="card"?z.jsx(Fwn,{subject:t,...i?{surface:i}:{}}):z.jsx(Oze,{name:"Inspector",hideHeader:!0,className:"vgai-content-frost","data-testid":"inspector-panel","data-vgai-inspector-presentation":r,onPointerDown:()=>H8("inspector"),style:{overflowY:"auto"},ref:l,onScroll:d=>{T_e.size>200&&T_e.clear(),T_e.set(a,d.currentTarget.scrollTop)},children:r==="properties"?z.jsx(Own,{subject:t}):z.jsx(Nwn,{subject:t})})}const Mwn=250;let JQt=0,FY=null;const Kme=new Set;function Lwn(){JQt++;for(const t of Kme)t()}function WQt(t){return Kme.add(t),FY===null&&(FY=setInterval(Lwn,Mwn)),()=>{Kme.delete(t),Kme.size===0&&FY!==null&&(clearInterval(FY),FY=null)}}function jwn(){return JQt}function HQt(t){return Xe.useSyncExternalStore(WQt,t,t)}function Bwn({presentation:t,surface:r}){const i=IQe(),a=z.jsx("div",{"data-testid":"no-authoring-note",style:{padding:12,color:Oo.semantic.warning,fontSize:"var(--vgai-font-md)",lineHeight:1.5},children:i!==null?z.jsxs(z.Fragment,{children:[z.jsx("strong",{children:"Nothing to author."})," ",i]}):z.jsxs(z.Fragment,{children:[z.jsx("strong",{children:"Nothing to author."})," This root's adapter publishes no inspector surface, so there is nothing here to describe or edit. The root is still hosted, sized, and disposed; play it in the Game tab."]})}),l=r?z.jsx("div",{style:{display:"flex",justifyContent:"flex-end",padding:"2px 4px"},children:z.jsx(rf,{size:"compact","data-testid":"inspector-expand","aria-label":"Expand inspector to side panel",title:"Expand inspector to side panel",onClick:()=>AGt(r,"column"),children:z.jsx(So,{icon:Qkt})})}):null;return t==="card"?z.jsxs("div",{className:"vgai-mini-inspector","data-testid":"inspector-panel","data-vgai-inspector-presentation":"card",onPointerDown:()=>H8("inspector"),children:[l,a]}):z.jsx(Oze,{name:"Inspector (nothing to author)",hideHeader:!0,className:"vgai-content-frost","data-testid":"inspector-panel",onPointerDown:()=>H8("inspector"),children:a})}function uKe(){const t=D0();HQt(()=>IOr());const r=sKe(t),{adapter:i}=wm(t);return r.available?i.capabilities.inspectorFields?z.jsx(vTt,{subject:r.subject,presentation:r.presentation,surface:r.surface}):r.subject.identity!==null||r.subject.sections.length>0?z.jsx(vTt,{subject:r.subject,presentation:r.presentation,surface:r.surface}):cz()?z.jsx(Bwn,{presentation:r.presentation,surface:r.surface}):null:null}const GQt=260,QQt=360,mee=16,$wn=200,KQt=220,Iqe=54,qwn=52,zwn={maxWidth:GQt,maxHeight:QQt,minSize:$wn,margin:mee},Uwn={right:mee,bottom:mee},Vwn={maxWidth:KQt,maxHeight:Iqe,minSize:Iqe,margin:mee};function Jwn(t,r,i){return Xxn(t,i?Vwn:zwn,r)}function Wwn(){const t=D0();Xe.useSyncExternalStore(t.subscribe,t.getShellSnapshot),Xe.useSyncExternalStore(Aw,Sb,Sb),Xe.useSyncExternalStore($0e,kZ,kZ),Xe.useSyncExternalStore(Yxn,dTt,dTt);const r=Kxn(),[i,a]=Xe.useState(!1),{subject:l}=sKe(t),d=Xe.useCallback(()=>{pP();const{adapter:g}=wm(t);k0(g,[])||t.select(null)},[t]),_=r?Jwn(r,Uwn,i):null;return z.jsx("div",{style:{position:"absolute",..._?{left:_.left,top:_.top,width:_.width,height:_.height}:{right:mee,bottom:qwn,width:i?KQt:GQt,height:i?Iqe:QQt},display:"flex",alignItems:"flex-end",zIndex:VN.sticky,pointerEvents:"none"},children:z.jsx("div",{"data-testid":"compact-inspector-card",style:{display:"flex",width:"100%",...i?{height:"100%"}:{maxHeight:"100%"},borderRadius:i?999:"var(--dv-group-border-radius, 8px)",overflow:i?"hidden":"clip",border:"var(--dv-floating-border, 1px solid var(--vgai-border-2))",boxShadow:"var(--dv-floating-box-shadow, var(--vgai-shadow-lg))",background:"var(--dv-group-view-background-color, var(--vgai-bg-1))",pointerEvents:"auto"},children:i?z.jsx(Rwn,{subject:l,onExpand:()=>a(!1),onClear:d}):z.jsx(Zxn,{actions:{minimize:()=>a(!0)},children:z.jsx(uKe,{})})})})}let Hwn=1;const bTt=new WeakMap;function Gwn(t){if(!t)return 0;const r=bTt.get(t);if(r!==void 0)return r;const i=Hwn++;return bTt.set(t,i),i}const Qwn="/__editor/collaboration",ATt=["participants","presence","messages","revisions","audit","team-test"];let c8=null;const Dqe=new Set,Kwn=new Set;let STt=0;function k_e(t){c8=t,EDt(t.revision);for(const r of Dqe)r(t);if(t.revision>STt){STt=t.revision;for(const r of Kwn)r(t.revision)}}async function Pqe(t,r){const i=await fetch(`${Qwn}${t}`,r);if(i.status!==204&&np(i,`Collaboration request ${t} failed`),!i.ok){const a=await i.json().catch(()=>null);throw new Error(typeof a?.error=="string"?a.error:"Collaboration request failed.")}return i.status===204?void 0:await i.json()}function Ywn(){return c8}let I_e=null,D_e=0;function Xwn(){if(D_e++,!I_e){const r=VP(),i=_=>{try{k_e(JSON.parse(_.data))}catch{}};let a=!1;const l=()=>{a||(a=!0,Pqe("").then(k_e).catch(()=>{}).finally(()=>{a=!1}))},d=_=>{try{const g=JSON.parse(_.data);if(!c8||g.sequence<=c8.sequence)return;if(g.channel!=="presence"){l();return}const b=g.payload;if(typeof b.participantId!="string"||!b.presence)return;k_e({...c8,sequence:g.sequence,participants:c8.participants.map(S=>S.participantId===b.participantId?{...S,presence:b.presence}:S)})}catch{}};r.addEventListener("collaboration-snapshot",i);for(const _ of ATt)r.addEventListener(`collaboration-${_}`,d);Pqe("").then(k_e).catch(()=>{}),I_e=()=>{r.removeEventListener("collaboration-snapshot",i);for(const _ of ATt)r.removeEventListener(`collaboration-${_}`,d);r.close()}}let t=!1;return()=>{t||(t=!0,D_e--,D_e<=0&&(D_e=0,I_e?.(),I_e=null))}}function Zwn(t){Dqe.add(t),c8&&t(c8);const r=Xwn();return()=>{Dqe.delete(t),r()}}async function Z4n(t){await Pqe("/presence",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({participantId:V0e,presence:t})})}const xTt=500,YQt=()=>{};function eCn(t,r){if(r===YQt)return{hierarchy:t.hierarchy,isComponentRoot:()=>!1,isBuiltInternal:()=>!1,...t.hasInternals?{hasInternals:S=>t.hasInternals(S)}:{},...t.internalChildren?{internalChildren:S=>t.internalChildren(S)}:{}};const i=new Map,a=S=>{const k=i.get(S);if(k!==void 0)return k;const w=[];let N=S,P=!1,j=0;for(;N!==null&&j++<xTt;){const J=i.get(N);if(J!==void 0){P=J;break}w.push(N);const X=r(N);if(X?.componentRoot!==void 0)break;if(X?.builtInternal===!0){P=!0;break}if(X?.authoredEntity===!0)break;N=t.hierarchy.node(N)?.parentId??null}for(const J of w)i.set(J,P);return P},l=S=>r(S)?.componentRoot!==void 0,d=(S,k=0)=>{if(k>xTt)return[];const w=[];for(const N of S.childIds){if(!a(N)){w.push(N);continue}const P=t.hierarchy.node(N);P&&w.push(...d(P,k+1))}return w},_=S=>S.childIds.filter(k=>a(k)),g=S=>{if(!S)return null;const k=r(S.id)?.componentRoot,w=d(S),N=w.length===S.childIds.length&&w.every((P,j)=>P===S.childIds[j]);return k===void 0&&N?S:{...S,...k===void 0?{}:{role:"component",typeLabel:k},...N?{}:{childIds:w}}};return{hierarchy:{roots:()=>t.hierarchy.roots().flatMap(S=>a(S.id)?d(S).flatMap(k=>{const w=g(t.hierarchy.node(k));return w?[{...w,parentId:S.parentId}]:[]}):[g(S)]),node:S=>g(t.hierarchy.node(S))},isComponentRoot:l,isBuiltInternal:a,hasInternals:S=>{if(t.hasInternals?.(S)===!0)return!0;const k=t.hierarchy.node(S);return k?_(k).length>0:!1},internalChildren:S=>{const k=t.internalChildren?.(S),w=t.hierarchy.node(S),N=w?_(w).flatMap(P=>{const j=g(t.hierarchy.node(P));return j?[{...j,parentId:S}]:[]}):[];return k===void 0?N.length>0?N:void 0:[...k,...N]}}}function tCn(t,r,i){for(const a of r)a.more||i(a.node.id)&&t.set(a.node.id,!1);return t}function rCn(t,r){for(const i of t.childAdapters())if(t.groupNodeId(i.worldId)===r)return i.worldId;return t.ownerOf(r)}function nCn(t,r,i){if(!(t instanceof Zh))return!0;const a=rCn(t,i);return a===null?!1:r.every(l=>t.ownerOf(l)===a)}const iCn="This world's structure comes from its own source, which the editor can't rewrite here — reparenting is not wired for it.",sCn="That row is part of a component instance's own output, not authored content. Drop onto the instance itself to place relative to it.";function wTt(t){return t.hasStructureWritePath?t.targetIsInternal?sCn:null:iCn}const XQt="hierarchyExpansion",Zz=new Map;let CTt=!1;function fKe(){if(CTt||!pte())return;CTt=!0;const t=WQe(XQt)??{};for(const[r,i]of Object.entries(t))Zz.set(r,new Map(Object.entries(i)))}function ZQt(){const t={};for(const[r,i]of Zz)t[r]=Object.fromEntries(i);ube(XQt,t)}function oCn(t,r){return fKe(),Zz.get(t)?.get(r)}function ETt(t,r){fKe();let i=Zz.get(t);i||(i=new Map,Zz.set(t,i));for(const[a,l]of r)i.set(a,l);ZQt()}function aCn(t){fKe(),Zz.delete(t),ZQt()}let Nye=null;const Nqe=new Set;function cCn(){return Nye}function lCn(t){return Nqe.add(t),()=>{Nqe.delete(t)}}function eKt(t){if(Nye!==t){Nye=t;for(const r of Nqe)r()}}function uCn(t){Nye===t&&eKt(null)}const fCn=500,TTt=new Set,dCn=new Set;function pCn(t,r=dCn){if(typeof t.internalChildren!="function"||r.size===0)return{hierarchy:t.hierarchy,isInternal:()=>!1,revealRootIds:TTt,internalIds:TTt};const i=new Map,a=new Map,l=new Set,d=(g,b)=>{if(b>fCn||i.has(g))return;const S=t.internalChildren(g)??[];if(S.length!==0){i.set(g,S.map(k=>k.id));for(const k of S)a.has(k.id)||(a.set(k.id,k),d(k.id,b+1))}};for(const g of r)d(g,0),i.has(g)&&l.add(g);const _=g=>{if(!g)return null;const b=i.get(g.id);return b?{...g,childIds:[...g.childIds,...b]}:g};return{hierarchy:{roots:()=>t.hierarchy.roots().map(g=>_(g)),node:g=>_(a.get(g)??t.hierarchy.node(g))},isInternal:g=>a.has(g),revealRootIds:l,internalIds:new Set(a.keys())}}function _Cn(t,r){for(const i of r.internalIds)t.set(i,!1);for(const i of r.revealRootIds)t.set(i,!0);return t}function mCn(t){return tKt(t)!==void 0}function hCn(t){const r=CE(t,"authoringInstance");return typeof r=="string"&&r?r:void 0}function gCn(t){const r=t?.userData?.oid;return typeof r=="string"&&r?r:void 0}function tKt(t){const r=hCn(t);if(r!==void 0)return CE(t?.parent,"authoringInstance")===r?void 0:r}function yCn(t){const r=t?.__vgaiOid;return typeof r=="string"&&r?r:void 0}function e6n(t,r){return r===0?t:`${t}#${r}`}function t6n(t){return tKt(t)??yCn(t)??gCn(t)}function vCn(t){const r=Hjr(t);if(r||R0e(t)||CE(t,"authoringRoot")===!0||!mCn(t))return r;const i=CE(t,"authoringComponent");return typeof i=="string"&&i?i:void 0}function bCn(t){const r=t.object3D;if(typeof r!="function")return YQt;const i=new Map;return a=>{if(i.has(a))return i.get(a);const l=r.call(t,a),d=l?{componentRoot:vCn(l),authoredEntity:CE(l,"authoringRoot")===!0,builtInternal:R0e(l)}:void 0;return i.set(a,d),d}}const Oye=20,ACn="__more__:",rKt=500;function SCn(t,r,i){return t?Math.max(Oye,r.get(i)??Oye):Number.POSITIVE_INFINITY}function xCn(t,r,i,a,l){return{node:{id:`${ACn}${t}`,label:"",kind:"object",parentId:i,childIds:[]},depth:r,pathKey:`${t}/__more__`,hasChildren:!1,hiddenByCollapse:a,more:{parentPathKey:t,hidden:l}}}function kTt(t,r,i=new Map,a=!1){const l=[],d=new Set,_=(g,b,S,k)=>{if(d.has(g.id)||b>rKt)return;d.add(g.id);const w=g.childIds.length>0;l.push({node:g,depth:b,pathKey:S,hasChildren:w,hiddenByCollapse:k});const N=r.has(S);if(a&&N)return;const P=k||N,j=Math.min(g.childIds.length,SCn(a,i,S));for(let J=0;J<j;J++){const X=t.node(g.childIds[J]);X&&_(X,b+1,`${S}.${J}`,P)}a&&g.childIds.length>j&&l.push(xCn(S,b+1,g.id,P,g.childIds.length-j))};return t.roots().forEach((g,b)=>{_(g,0,`r${b}`,!1)}),l}function wCn(t,r,i){if(i.size===0)return r;const a=new Map;for(let b=0;b<r.length;b+=1){const S=r[b];S.more||a.set(S.node.id,b)}const l=[];for(const b of i){const S=a.get(b),k=t.node(b);if(S===void 0||k===null)continue;const w=r[S];let N=S+1;for(;N<r.length&&r[N].depth>w.depth;)N+=1;l.push({start:S,end:N,row:w,node:k})}if(l.length===0)return null;l.sort((b,S)=>b.start-S.start);const d=[];for(const b of l){const S=d.at(-1);S&&b.start<S.end||d.push(b)}for(const b of i){const S=a.get(b);if(S!==void 0&&!d.some(({start:k,end:w})=>S>=k&&S<w))return null}const _=b=>{const S=[],k=new Set;let w=!0;const N=(P,j,J)=>{if(w){if(k.has(P.id)||j>rKt){w=!1;return}k.add(P.id),S.push({node:P,depth:j,pathKey:J,hasChildren:P.childIds.length>0,hiddenByCollapse:!1});for(let X=0;X<P.childIds.length;X+=1){const G=t.node(P.childIds[X]);G&&N(G,j+1,`${J}.${String(X)}`)}}};return N(b.node,b.row.depth,b.row.pathKey),w?S:null},g=[...r];for(let b=d.length-1;b>=0;b-=1){const S=d[b],k=_(S);if(k===null)return null;g.splice(S.start,S.end-S.start,...k)}return g}function ITt(t){return`${t.pathKey}:${t.node.id}`}function CCn(t,r,i,a,l){const d=Math.max(0,Math.floor(r/a)-l),_=Math.ceil(i/a)+l*2,g=Math.min(t,d+_);return{start:d,end:g}}function ECn(t,r){if(t.length!==r.length)return!1;for(let i=0;i<t.length;i+=1)if(!Object.is(t[i],r[i]))return!1;return!0}class i9e{#e=null;#t;computeCount=0;get current(){return this.#t}read(r,i){if(this.#e!==null&&ECn(this.#e,r))return this.#t;const a=i(this.#t);return this.#e=r,this.#t=a,this.computeCount+=1,a}}class TCn{#e=new i9e;#t=new i9e;#i=new i9e;#n;#r=Number.NEGATIVE_INFINITY;structural(r,i){const[a,l]=r;if(a===this.#n&&typeof l=="number"&&l<this.#r&&this.#e.current!==void 0)return this.#e.current;const d=this.#e.read(r,i);return a!==this.#n&&(this.#n=a,this.#r=Number.NEGATIVE_INFINITY),typeof l=="number"&&(this.#r=Math.max(this.#r,l)),d}collapsed(r,i){return this.#t.read(r,i)}browse(r,i){return this.#i.read(r,i)}get counts(){return{structural:this.#e.computeCount,collapsed:this.#t.computeCount,browse:this.#i.computeCount}}}function kCn(t){const r=new Map,i=new Map;for(const a of t){if(a.more)continue;r.set(a.pathKey,a.node.id);const l=i.get(a.node.id);l?l.push(a.pathKey):i.set(a.node.id,[a.pathKey])}return{nodeIdByPathKey:r,pathKeysByNodeId:i}}function dKe(t){const r=t.split("."),i=[];for(let a=1;a<r.length;a++)i.push(r.slice(0,a).join("."));return i}function DTt(t,r){const i=new Set;for(const a of r)for(const l of t.pathKeysByNodeId.get(a)??[])for(const d of dKe(l)){const _=t.nodeIdByPathKey.get(d);_&&i.add(_)}return i}function ICn(t,r){const i=new Map;for(const a of r)for(const l of t.pathKeysByNodeId.get(a)??[]){const d=l.split(".");let _=d[0];for(let g=1;g<d.length;g++){const b=Number(d[g]);Number.isFinite(b)&&i.set(_,Math.max(i.get(_)??0,b+1)),_=`${_}.${d[g]}`}}return i}function DCn(t){return t.size===0?"":[...t].sort((r,i)=>r[0]<i[0]?-1:r[0]>i[0]?1:0).map(([r,i])=>`${r}=${String(i)}`).join(",")}const s9e="application/x-editor-asset",o9e="application/x-hierarchy-reorder";function a9e(t){const i=t?.querySelector(".vgai-tree-row")?.getBoundingClientRect().height??0;if(i>0)return Math.round(i);const a=t?Number.parseFloat(getComputedStyle(t).getPropertyValue("--vgai-tree-row-height")):Number.NaN;return Number.isFinite(a)&&a>0?a:p3t.treeRow}const mX="var(--vgai-tree-indent)";function Yme(t){return`calc(${mX} * ${t})`}const PTt=5;function PCn(t,r,i){const a=[];for(let l=0;l<t;l++)a.push({column:l,starts:r===l,ends:i<=l});return a}const NCn=[],OCn=6,FCn=8,RCn=2400;function MCn(t){const r=new Map,i=l=>{const d=l.childIds.flatMap(_=>{const g=t.node(_);return g?.role==="document"&&g.secondaryLabel?g.childIds:[_]});return d.length===l.childIds.length&&d.every((_,g)=>_===l.childIds[g])?null:d},a=l=>{let d=r.get(l.id);return d===void 0&&(d=i(l),r.set(l.id,d)),d===null?l:{...l,childIds:d}};return{...t,roots:()=>{const l=t.roots();return l.length===1&&l[0]?.role==="document"?l[0].childIds.map(d=>t.node(d)).filter(d=>d!==null).map(a):l.map(a)},node:l=>{const d=t.node(l);return d?a(d):null}}}const LCn=300,jCn=new Map,BCn={folder:gee,document:oIt,story:Zkt,component:yee,instance:E9e,boundary:vee};function $Cn(t){return t.role==="root"?iZ(t.kind,fIt):t.role==="entity"||t.role==="element"?iZ(t.kind):(t.role?BCn[t.role]:void 0)??iZ(t.kind)}const nKt=new Set(["folder","root","document","story","boundary"]);function qCn(t,r,i){let a=t,l=0;for(;a&&l++<1e3;){if(r.includes(a))return!0;a=i.hierarchy.node(a)?.parentId??null}return!1}function zCn(t,r){return r===null?t.hierarchy.roots().map(i=>i.id):t.hierarchy.node(r)?.childIds??[]}function pKe(t,r){if(!(t instanceof Zh))return null;for(const i of t.childAdapters())if(t.groupNodeId(i.worldId)===r){const a=t.inspector?.get(r,"zOrder");return{zOrder:typeof a=="number"?a:i.zOrder,worldId:i.worldId,role:i.role,kind:i.kind,provenance:i.adapter.provenance??null}}return null}function Xme(t,r){return pKe(t,r)!==null}function _Ke(t,r){return t instanceof Zh&&t.isOrganizationNode(r)}function iKt(t,r){if(!(t instanceof Zh))return t;const i=t.ownerOf(r);return t.childAdapters().find(a=>a.worldId===i)?.adapter??t}function NTt(t,r){return r===void 0?t.structure!==void 0:iKt(t,r).structure!==void 0}function UCn(t,r,i){return Xme(t,r)||_Ke(t,r)||i!==void 0&&nKt.has(i)}function VCn(t,r){const i=new Map,a=[],l=[],d=new Map;for(const _ of t)_.more||d.set(_.node.id,_.node.kind);for(const _ of t){if(_.more)continue;const g=_.depth===0?0:a[_.depth-1]??0,b=_.depth===0?null:l[_.depth-1],S=UCn(r,_.node.id,_.node.role),k=g+(S?0:1);a[_.depth]=k,a.length=_.depth+1,l[_.depth]=_.node,l.length=_.depth+1;const w=_.node.childIds.length>0&&_.node.childIds.every(N=>BQt(d.get(N)));i.set(_.node.id,_.node.defaultExpanded??(!w&&(S||k<=1||b?.childIds.length===1)))}return i}function JCn(t,r,i){const a=new Set;for(const l of t)if(!(l.more||!QQe({structural:!1,internal:i(l.node.id)}).searchable)&&l.node.label.toLowerCase().includes(r)){a.add(l.pathKey);for(const d of dKe(l.pathKey))a.add(d)}return a}function WCn(t,r){const i=new Map(t);for(const[a,l]of r)i.set(a,Math.max(i.get(a)??0,l));return i}function HCn({value:t,onChange:r}){const i=Xe.useRef(null);return z.jsxs("div",{style:{position:"relative",display:"flex",alignItems:"center",flex:`0 1 var(${QCn}, ${GCn}px)`,minWidth:KCn},children:[z.jsx(So,{icon:jkt,"aria-hidden":"true",style:{position:"absolute",left:YCn,pointerEvents:"none",color:"var(--vgai-text-1)",fontSize:"var(--vgai-icon-lg)"}}),z.jsx(k_,{ref:i,type:"text","data-testid":"ingest-search",placeholder:"Search",className:"vgai-input",value:t,onChange:a=>r(a.target.value),onKeyDown:a=>{a.key==="Escape"&&(a.stopPropagation(),t!==""?r(""):i.current?.blur())},style:{flex:1,minWidth:0,paddingLeft:`var(${ZCn}, ${XCn}px)`,paddingRight:eEn}})]})}const GCn=64,QCn="--vgai-hierarchy-search-basis",KCn=56,YCn=2,XCn=21,ZCn="--vgai-hierarchy-search-text-inset",eEn=2;function tEn({onCollapseAll:t,onResetExpansion:r,onExpandAll:i}){const[a,l]=Xe.useState(!1),d=Xe.useRef(null);return z.jsxs("div",{ref:d,style:{position:"relative",flexShrink:0},children:[z.jsx(rf,{title:"View","aria-label":"View","aria-haspopup":"menu","aria-expanded":a,"data-testid":"hierarchy-view-menu",onClick:()=>l(_=>!_),variant:"secondary",size:"compact",children:z.jsx(So,{icon:eIt,"aria-hidden":"true",style:{fontSize:"var(--vgai-icon-xs)"}})}),a&&z.jsxs(OP,{autoFocusFirst:!0,dismissBoundaryRef:d,onDismiss:()=>l(!1),style:{position:"absolute",top:"100%",right:0,marginTop:U_[2],minWidth:170},children:[z.jsx(Wa,{"data-testid":"hierarchy-collapse-all",onSelect:()=>{t(),l(!1)},children:"Collapse All"}),z.jsx(Wa,{"data-testid":"hierarchy-reset-expansion",onSelect:()=>{r(),l(!1)},children:"Reset Openness"}),z.jsx(Wa,{"data-testid":"hierarchy-expand-all",onSelect:()=>{i(),l(!1)},children:"Expand All"})]})]})}function rEn({slot:t,search:r,setSearch:i,adapter:a,createTargetId:l,onCollapseAll:d,onResetExpansion:_,onExpandAll:g}){const b=z.jsxs(z.Fragment,{children:[z.jsx(HCn,{value:r,onChange:i}),z.jsx(tEn,{onCollapseAll:d,onResetExpansion:_,onExpandAll:g}),z.jsx(iEn,{adapter:a,parentId:l})]});return t?vS.createPortal(z.jsx("div",{"data-testid":"hierarchy-header-controls",style:{display:"flex",alignItems:"center",gap:pv[1],height:"100%",minWidth:0},children:b}),t):z.jsx(NP,{label:"Hierarchy controls",compact:!0,style:{gap:pv[2]},children:b})}function nEn({state:t,adapter:r,store:i,isGroupNode:a,isInternal:l,onRename:d,onClose:_}){const g=Xe.useRef(null),[b,S]=Xe.useState({left:t.x,top:t.y});Xe.useLayoutEffect(()=>{const Yt=g.current;if(!Yt)return;const Lr=Yt.getBoundingClientRect();S(t3t({top:t.y,left:t.x,width:Lr.width,height:Lr.height}))},[t.x,t.y]);const[k,w]=Xe.useState(!1),N=Xe.useRef(!1);Xe.useEffect(()=>{k&&(N.current=!1)},[k]),Xe.useEffect(()=>{const Yt=nn=>{g.current&&!g.current.contains(nn.target)&&_()},Lr=nn=>{nn.key==="Escape"&&_()};return document.addEventListener("mousedown",Yt),document.addEventListener("keydown",Lr),()=>{document.removeEventListener("mousedown",Yt),document.removeEventListener("keydown",Lr)}},[_]);const P=r.hierarchy.node(t.nodeId);if(!P)return null;const j=r.structure?.creatableKinds?.(t.nodeId)??[],X=iKt(r,t.nodeId).structure,G=!!X,ee=r.inspector?.get(t.nodeId,"name")!==void 0,xe=r.inspector?.get(t.nodeId,"locked")!==void 0,ue=r.inspector?.get(t.nodeId,"locked")===!0,fe=r.inspector?.get(t.nodeId,"visible")!==void 0,se=r.inspector?.get(t.nodeId,"visible")!==!1,de=r.inspector?.editability?.(t.nodeId,"locked"),ge=r.inspector?.editability?.(t.nodeId,"visible"),qe=xe&&(de?.writable??!0),tt=fe&&(ge?.writable??!0),Ct=[...bP(i).selectedEntityIds],Ot=Ct.includes(t.nodeId)?Ct:[t.nodeId],vt=fMr(d4t(r,t.nodeId)),Et=X?.copy?"Copy needs source-addressable entities from one world.":vt,Tt=X?.paste?"Copy or cut a source-addressable entity in this world first.":vt,Le=[],cr=QQe({structural:a,internal:l});if(l&&P.parentId!==null&&Le.push({label:"Select Parent",testId:"hierarchy-context-menu-select-parent",action:()=>{k0(r,[P.parentId]),_()}}),!a&&cr.writable){Le.push({label:"Rename",testId:"hierarchy-context-menu-rename",...ee?{}:{disabledReason:vt},action:()=>{d(t.nodeId),_()}}),Le.push({label:"Cut",testId:"hierarchy-context-menu-cut",...X?.cut&&(r.structure?.canCopy?.(Ot)??!0)?{}:{disabledReason:Et},action:()=>{T0e(r,Ot),_()}}),Le.push({label:"Copy",testId:"hierarchy-context-menu-copy",...X?.copy&&(r.structure?.canCopy?.(Ot)??!0)?{}:{disabledReason:Et},action:()=>{E0e(r,Ot),_()}}),Le.push({label:"Paste",testId:"hierarchy-context-menu-paste",...X?.paste&&(r.structure?.canPaste?.(P.parentId)??!0)?{}:{disabledReason:Tt},action:()=>{k0e(r,P.parentId),_()}}),Le.push({label:"Duplicate",testId:"hierarchy-context-menu-duplicate",...G?{}:{disabledReason:vt},action:()=>{Ct.length>1&&Ct.includes(t.nodeId)?dbe(i):S0e(r,t.nodeId).ack,_()}}),X?.group&&Ct.length>1&&Ct.includes(t.nodeId)&&Le.push({label:"Group Selection",testId:"hierarchy-context-menu-group",action:()=>{C0e(r,Ct).ack,_()}}),X?.ungroup&&X.canUngroup?.(t.nodeId)&&Le.push({label:"Ungroup",testId:"hierarchy-context-menu-ungroup",action:()=>{hUe(r,t.nodeId).ack,_()}}),X?.wrap&&Le.push({label:"Wrap",testId:"hierarchy-context-menu-wrap",action:()=>{x0e(r,t.nodeId),_()}}),X?.unwrap&&Le.push({label:"Unwrap",testId:"hierarchy-context-menu-unwrap",action:()=>{w0e(r,t.nodeId),_()}}),P.parentId!==null&&Le.push({label:"Select Parent",testId:"hierarchy-context-menu-select-parent",action:()=>{k0(r,[P.parentId]),_()}}),Le.push({label:fe&&!se?"Show":"Hide",...tt?{}:{disabledReason:ge?.reason??vt},action:()=>{r.inspector.set(t.nodeId,"visible",!se),i.notifyIngestEdit(),_()}}),Le.push({label:ue?"Unlock":"Lock",...qe?{}:{disabledReason:de?.reason??vt},action:()=>{r.inspector.set(t.nodeId,"locked",!ue),i.notifyIngestEdit(),_()}});for(const Yt of D9r({nodeId:t.nodeId,store:i}))Le.push({label:Yt.label,...Yt.color!==void 0?{color:Yt.color}:{},action:()=>{Yt.action(),_()}});Le.push({label:"Delete",testId:"hierarchy-context-menu-delete",color:Oo.semantic.danger,...G?{}:{disabledReason:vt},action:()=>{Ct.length>1&&Ct.includes(t.nodeId)?pbe(i):r.structure.remove(t.nodeId),_()}})}return z.jsx(vhe,{children:z.jsxs(OP,{ref:g,"data-testid":"ingest-context-menu",style:{position:"fixed",left:b.left,top:b.top,minWidth:150,maxWidth:260,fontSize:"var(--vgai-font-base)"},children:[!a&&cr.writable&&j.length>0&&z.jsxs("div",{children:[z.jsxs(Wa,{"data-testid":"hierarchy-context-menu-create",onSelect:()=>w(Yt=>!Yt),style:{justifyContent:"space-between",gap:U_[4]},children:[z.jsx("span",{children:"Create"}),z.jsx(A3t,{direction:"right",tone:"dim"})]}),k&&j.map(Yt=>z.jsx(Wa,{"data-testid":`hierarchy-context-menu-create-${Yt.kind}`,onSelect:()=>{N.current||(N.current=!0,A0e(r,Yt.kind,t.nodeId).ack,_())},style:{paddingLeft:pv[12]},children:Yt.label},Yt.kind))]}),Le.map(Yt=>Yt.disabledReason!==void 0?z.jsx(Wa,{"data-testid":Yt.testId,"aria-disabled":"true",title:Yt.disabledReason,style:{cursor:"not-allowed",color:Oo.content.dim,opacity:.7},children:Yt.label},Yt.label):z.jsx(Wa,{"data-testid":Yt.testId,onSelect:Yt.action,style:Yt.color!==void 0?{color:Yt.color}:void 0,children:Yt.label},Yt.label)),l&&z.jsx("div",{"data-testid":"hierarchy-context-menu-internal-note",style:{padding:`${U_[4]}px ${U_[6]}px`,color:Oo.content.dim,maxWidth:240,lineHeight:nAt.normal},children:r.transforms?.editability?.(t.nodeId,"position")?.reason??"This rendered part has no authored source identity."}),!G&&!l&&z.jsxs("div",{style:{padding:`${U_[4]}px ${U_[6]}px`,color:Oo.semantic.warning,maxWidth:240,lineHeight:nAt.normal},children:[z.jsx("strong",{children:"Create / Delete / Reparent — not available."})," This game owns its own scene graph, so structural authoring isn't reapplicable. You can edit transform / material / visibility, or capture a subtree into the first-party editable format."]})]})})}function iEn({adapter:t,parentId:r}){const[i,a]=Xe.useState(!1),l=Xe.useRef(null),d=Xe.useRef(!1),_=t.structure?.creatableKinds?.(r)??[],g=r?t.hierarchy.node(r)?.label:null;return Xe.useEffect(()=>{if(!i)return;d.current=!1;const b=k=>{l.current&&!l.current.contains(k.target)&&a(!1)},S=k=>{k.key==="Escape"&&a(!1)};return document.addEventListener("mousedown",b),document.addEventListener("keydown",S),()=>{document.removeEventListener("mousedown",b),document.removeEventListener("keydown",S)}},[i]),_.length===0?null:z.jsxs("div",{ref:l,style:{position:"relative",flexShrink:0},children:[z.jsxs(fo,{title:g?`Add to ${g}`:"Add","aria-label":g?`Add to ${g}`:"Add","aria-expanded":i,"data-testid":"hierarchy-add-menu",onClick:()=>a(!i),variant:i?"primary":"secondary",size:"compact",children:[z.jsx(So,{icon:xDr,style:{fontSize:"var(--vgai-font-sm)"}})," ",z.jsx(So,{icon:x8,style:{fontSize:"var(--vgai-font-xs)"}})]}),i&&z.jsx(OP,{style:{position:"absolute",top:"100%",right:0,marginTop:U_[2],minWidth:130,maxHeight:"min(480px, 70vh)",overflowY:"auto"},children:_.map(b=>z.jsx(Wa,{"data-testid":`hierarchy-add-${b.kind}`,onSelect:()=>{d.current||(d.current=!0,A0e(t,b.kind,r??void 0).ack,a(!1))},children:b.label},b.kind))})]})}function sEn({row:t,onReveal:r}){const i=t.more.hidden;return z.jsxs(fo,{type:"button",variant:"ghost",className:"vgai-hierarchy-more","data-testid":"ingest-row-more",onClick:()=>r(t.more.parentPathKey),style:{paddingLeft:Yme(t.depth+1)},children:["… ",i," more"]})}function OTt(t,r){if(!r)return t;const i=t.toLowerCase(),a=r.toLowerCase(),l=[];let d=0,_=i.indexOf(a,d);if(_<0)return t;let g=0;for(;_>=0;)_>d&&l.push(t.slice(d,_)),l.push(z.jsx("mark",{"data-testid":"ingest-row-search-highlight",style:{background:Oo.semantic.warning,color:Oo.surface.shell,borderRadius:Oo.shape.small},children:t.slice(_,_+a.length)},g++)),d=_+a.length,_=i.indexOf(a,d);return d<t.length&&l.push(t.slice(d)),l}function sKt(t,r){return t.length===r.length&&t.every((i,a)=>i===r[a])}function oEn(t,r){const i=t.node,a=r.node;return t.depth===r.depth&&t.pathKey===r.pathKey&&t.hasChildren===r.hasChildren&&t.hiddenByCollapse===r.hiddenByCollapse&&t.more?.parentPathKey===r.more?.parentPathKey&&t.more?.hidden===r.more?.hidden&&i.id===a.id&&i.label===a.label&&i.role===a.role&&i.secondaryLabel===a.secondaryLabel&&i.kind===a.kind&&i.typeLabel===a.typeLabel&&i.parentId===a.parentId&&sKt(i.childIds,a.childIds)&&i.crossSurfaceId===a.crossSurfaceId&&i.crossSurfaceParentId===a.crossSurfaceParentId&&i.crossSurfaceOrder===a.crossSurfaceOrder&&i.crossSurfaceGroupLabel===a.crossSurfaceGroupLabel}function aEn(t,r){return oEn(t.row,r.row)&&t.adapter===r.adapter&&t.store===r.store&&t.isSelected===r.isSelected&&t.isSelectionActive===r.isSelectionActive&&t.isEditing===r.isEditing&&t.isCollapsed===r.isCollapsed&&t.dropZone===r.dropZone&&t.isDragged===r.isDragged&&t.rowIndex===r.rowIndex&&t.prevDepth===r.prevDepth&&t.nextDepth===r.nextDepth&&t.isInternal===r.isInternal&&t.searchTerm===r.searchTerm&&t.lockCache===r.lockCache&&t.warningCache===r.warningCache&&t.editabilityVersion===r.editabilityVersion&&t.adapterVersion===r.adapterVersion&&t.threeRootId===r.threeRootId&&t.onToggleOpen===r.onToggleOpen&&t.onStartEditing===r.onStartEditing&&t.onContextMenu===r.onContextMenu&&t.onDragStart===r.onDragStart&&t.onClick===r.onClick&&t.onEnterScope===r.onEnterScope&&t.typeSuffixShown===r.typeSuffixShown&&t.instanceRuleShown===r.instanceRuleShown&&t.restrictionColumns===r.restrictionColumns&&t.excludeColumnShown===r.excludeColumnShown&&sKt(t.remoteSelectionColors,r.remoteSelectionColors)}const cEn=Xe.memo(function({row:r,adapter:i,store:a,isSelected:l,isSelectionActive:d,isEditing:_,isCollapsed:g,dropZone:b,isDragged:S,rowIndex:k,prevDepth:w,nextDepth:N,isInternal:P,searchTerm:j,lockCache:J,warningCache:X,editabilityVersion:G,adapterVersion:ee,onToggleOpen:xe,onStartEditing:ue,threeRootId:fe,onContextMenu:se,onDragStart:de,onClick:ge,onEnterScope:qe,remoteSelectionColors:tt,typeSuffixShown:Ct,instanceRuleShown:Ot,restrictionColumns:vt,excludeColumnShown:Et}){const{node:Tt,depth:Le,hasChildren:cr}=r,Yt=pKe(i,Tt.id),Lr=Yt!==null,nn=_Ke(i,Tt.id),on=Lr||nn||Tt.role!==void 0&&nKt.has(Tt.role),gr=QQe({structural:on,internal:P}),An=on?void 0:i.inspector?.get(Tt.id,"locked"),Rn=on?void 0:i.inspector?.get(Tt.id,"name"),ln=!on&&i.inspector?.get(Tt.id,"visible")!==void 0,Mn=on?void 0:i.inspector?.editability?.(Tt.id,"locked"),Is=on?void 0:i.inspector?.editability?.(Tt.id,"visible"),Zs=on?void 0:i.inspector?.get(Tt.id,"renderVisible"),Zc=Zs!==void 0,vl=Zs!==!1,gn=on?void 0:i.inspector?.editability?.(Tt.id,"renderVisible"),_t=Zc&&(gn?.writable??!0),_o=on?void 0:i.inspector?.get(Tt.id,"exclude"),Nr=_o!==void 0,ko=_o===!0,Sa=on?void 0:i.inspector?.editability?.(Tt.id,"exclude"),_c=Nr&&(Sa?.writable??!0),Yl=Yt?zP(Yt.worldId):!1,ol=Yt?V4t(Yt.worldId):!1,Sd=Yt?O0e(Yt.worldId):!1,Qu=Lr?!Yl:i.inspector?.get(Tt.id,"visible")!==!1,vu=An!==void 0,$l=An===!0,el=vu&&(Mn?.writable??!0),gc=ln&&(Is?.writable??!0),Cf=Rn!==void 0,Qr=BAn(Tt),Cl=on?0:i.instances?.describe(Tt.id)?.overrides.length??0,ku=on?GQe:J.summaryFor(i,G,Tt.id),xi=on?null:X.badgeFor(i,G,Tt.id),Iu=on?null:A1n(dte(i,a.objectMap,Tt.id)),Xl=g&&cr?Tt.childIds.slice(0,OCn).map(oa=>i.hierarchy.node(oa)).filter(oa=>oa!==null&&BQt(oa.kind)):[];return z.jsxs("div",{className:"vgai-tree-row","data-entity-name":on?void 0:Tt.label,"data-testid":"ingest-row","data-ingest-name":Tt.label,"data-node-role":Tt.role,"data-depth":Le,"data-selected":l?"true":void 0,"data-selection-active":d?"true":void 0,"data-remotely-selected":tt.length>0?"true":void 0,"data-dragging":S?"true":void 0,"data-row-alt":k%2===1?"true":void 0,"data-internal":P?"true":void 0,"data-muted":P||ko||!on&&!Qu?"true":void 0,draggable:gr.draggable,onDragStart:oa=>de(oa,Tt.id),onClick:oa=>{if(Yt?.role==="world"&&k$e(Yt.worldId),Tt.role==="story"){const aa=i instanceof Zh?i.ownerOf(Tt.id):null;aa&&k$e(aa),i.stories?.apply(Tt.id,Tt.id)}ge(oa,Tt.id)},onDoubleClick:()=>{Tt.role==="story"?FP("story",a,{storyId:Tt.id}):Tt.role==="component"||Tt.role==="instance"||Tt.role==="boundary"?qe(Tt.id):gr.renamable&&Cf&&ue(Tt.id)},onContextMenu:oa=>{oa.preventDefault(),se(oa,Tt.id)},style:{position:"relative",paddingLeft:Yme(Le),paddingRight:pv[2],gap:pv[2],cursor:"pointer",outline:b==="child"?`1px dashed ${Oo.accent.default}`:"none",whiteSpace:"nowrap",overflow:"hidden",fontSize:"var(--vgai-font-base)"},children:[b==="before"&&z.jsx(Zbt,{position:"before",style:{left:Yme(Le)}}),b==="after"&&z.jsx(Zbt,{position:"after",style:{left:Yme(Le)}}),PCn(Le,w,N).map(oa=>z.jsx("span",{className:"vgai-tree-indent-guide","aria-hidden":"true",style:{left:`calc(${mX} * ${oa.column+.5} - 0.5px)`,top:oa.starts?PTt:0,bottom:oa.ends?PTt:0}},oa.column)),cr?z.jsx(rf,{type:"button",variant:"ghost",size:"compact","aria-label":g?`Expand ${Tt.label}`:`Collapse ${Tt.label}`,"aria-expanded":!g,"data-testid":"ingest-row-caret",onClick:oa=>{oa.stopPropagation(),xe(r,oa.altKey)},title:"Expand/collapse (Option/Alt-click applies to the branch)",className:"vgai-tree-caret",children:z.jsx(So,{icon:g?RIr:x8,"aria-hidden":"true"})}):z.jsx("span",{"data-testid":"ingest-row-caret","aria-hidden":"true",style:{width:mX,flexShrink:0}}),tt.length>0&&z.jsx("span",{className:"vgai-tree-remote-selection",role:"img",title:`Selected by ${tt.length} collaborator${tt.length===1?"":"s"}`,"aria-label":"Selected by a collaborator",children:tt.slice(0,3).map(oa=>z.jsx("span",{style:{background:oa},"aria-hidden":"true"},oa))}),Yt?.role==="world"&&Yt.worldId===fe&&z.jsx("span",{"data-testid":"world-focus-radio","data-world-focused":"true",title:"Live Three world — shown in the viewport",style:{fontSize:"var(--vgai-font-xs)",opacity:.8,flexShrink:0},children:z.jsx(So,{icon:rze,"aria-hidden":"true"})}),z.jsx("span",{className:"vgai-tree-type-glyph",title:Tt.role?`${Tt.role}: ${Tt.kind}`:Tt.kind,style:{width:"var(--vgai-icon-md)",fontSize:"var(--vgai-icon-sm)",flexShrink:0,textAlign:"center"},children:z.jsx(So,{icon:$Cn(Tt),"aria-hidden":"true"})}),_?z.jsx(k_,{autoFocus:!0,defaultValue:Tt.label,onBlur:oa=>{i.inspector.set(Tt.id,"name",oa.currentTarget.value),a.notifyIngestEdit(),ue("")},onKeyDown:oa=>{oa.key==="Enter"&&(i.inspector.set(Tt.id,"name",oa.currentTarget.value),a.notifyIngestEdit(),ue("")),oa.key==="Escape"&&ue("")},onClick:oa=>oa.stopPropagation(),"data-variant":"tree-edit",style:{flex:1,minWidth:0}}):z.jsxs("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis"},children:[Qr.typeSuffix?z.jsxs("span",{"data-testid":"hierarchy-instance-label",...Ct?{}:{title:`Component instance of <${Qr.typeSuffix}>`},style:{textDecorationLine:Ot?l?"var(--vgai-tree-active-name-underline)":"underline":"none",textDecorationStyle:"dotted",textDecorationColor:Oo.semantic.instance,textUnderlineOffset:"3px",...l?{color:d?Oo.content.active:Oo.content.selected}:{}},children:[OTt(Tt.label,j),!Ct&&Cl>0?"*":""]}):z.jsx("span",{"data-testid":"hierarchy-plain-label",style:l?{color:d?Oo.content.active:Oo.content.selected}:void 0,children:OTt(Tt.label,j)}),Xl.map(oa=>z.jsx("span",{className:"vgai-tree-datablock","data-active":d?"true":void 0,title:`${oa.kind}: ${oa.label}`,children:z.jsx(So,{icon:iZ(oa.kind),"aria-hidden":"true"})},oa.id)),Qr.typeSuffix&&Ct&&z.jsxs("span",{"data-testid":"hierarchy-instance-type","data-type-label":Qr.typeSuffix,title:`Component instance of <${Qr.typeSuffix}>`,style:{marginLeft:pv[2],fontSize:"var(--vgai-font-sm)",color:Oo.content.dim},children:["·",Qr.typeSuffix,Cl>0?"*":""]}),Tt.secondaryLabel&&z.jsx("span",{style:{marginLeft:pv[3],fontSize:"var(--vgai-font-sm)",opacity:.5},children:Tt.secondaryLabel}),Iu&&z.jsx("span",{"data-testid":"hierarchy-instanced-units",style:{marginLeft:pv[3],fontSize:"var(--vgai-font-sm)",opacity:.5},children:Iu}),Yt?.role==="world"&&Yt.zOrder!==0&&z.jsxs("span",{title:`Z order: ${Yt.zOrder}`,style:{marginLeft:pv[3],fontSize:"var(--vgai-font-sm)",opacity:.6},children:["Z ",Yt.zOrder]}),Yt?.provenance&&z.jsx("span",{"data-testid":"world-provenance","data-provenance":Yt.provenance.source,title:Yt.provenance.detail,style:{marginLeft:pv[3],fontSize:"var(--vgai-font-xs)",padding:`0 ${U_[2]}px`,borderRadius:Oo.shape.small,border:`1px solid ${Oo.boundary.strong}`,color:Oo.content.muted,verticalAlign:"middle"},children:Yt.provenance.label})]}),xi&&z.jsx("span",{"data-testid":"hierarchy-row-warning","data-warning-codes":xi.codes.join(","),"data-warning-count":xi.count,role:"img",title:xi.tooltip,"aria-label":`${Tt.label}: ${xi.tooltip}`,style:{fontSize:"var(--vgai-font-sm)",color:Oo.semantic.warning,flexShrink:0},children:z.jsx(So,{icon:vee,"aria-hidden":"true"})}),ku.locked&&ku.reason&&z.jsx("span",{"data-testid":"hierarchy-transform-lock",role:"img",title:ku.reason,"aria-label":`${Tt.label}: ${ku.reason}`,style:{fontSize:"var(--vgai-font-sm)",color:Oo.content.dim,flexShrink:0},children:z.jsx(So,{icon:H1t,"aria-hidden":"true"})}),vt==="select+viewport"&&vu&&gr.writable&&z.jsx(rf,{type:"button",variant:"ghost",size:"compact","data-testid":"ingest-row-lock",disabled:!el,title:el?$l?"Unlock":"Lock":Mn?.reason||"Locked","aria-label":$l?`Unlock ${Tt.label}`:`Lock ${Tt.label}`,"aria-pressed":$l,onClick:oa=>{oa.stopPropagation(),i.inspector.set(Tt.id,"locked",!$l),a.notifyIngestEdit()},children:z.jsx(So,{icon:$l?H1t:lDr,"aria-hidden":"true"})}),Et&&(Nr&&gr.writable?z.jsx(rf,{type:"button",variant:"ghost",size:"compact","data-testid":"ingest-row-exclude",disabled:!_c,title:_c?ko?"Include in view layer":"Exclude from view layer":Sa?.reason||"Exclusion is read-only","aria-label":ko?`Include ${Tt.label} in the view layer`:`Exclude ${Tt.label} from the view layer`,"aria-checked":!ko,role:"checkbox",onClick:oa=>{oa.stopPropagation(),i.inspector.set(Tt.id,"exclude",!ko),a.notifyIngestEdit()},children:z.jsx(So,{icon:ko?lwn:cwn,"aria-hidden":"true"})}):z.jsx("span",{"aria-hidden":"true",style:{width:mX,flexShrink:0}})),(ln||Lr)&&gr.writable&&z.jsx(rf,{type:"button",variant:"ghost",size:"compact","data-testid":"ingest-row-visibility",disabled:!Lr&&!gc,title:Lr||gc?Qu?"Hide":"Show":Is?.reason||"Visibility is read-only","aria-label":Qu?`Hide ${Tt.label}`:`Show ${Tt.label}`,"aria-pressed":!Qu,onClick:oa=>{oa.stopPropagation(),Yt?(hjr(Yt.worldId),a.notifyIngestEdit()):(i.inspector.set(Tt.id,"visible",!Qu),a.notifyIngestEdit())},children:z.jsx(So,{icon:Qu?Zqe:tze,"aria-hidden":"true"})}),vt==="viewport+render"&&(Zc&&gr.writable?z.jsx(rf,{type:"button",variant:"ghost",size:"compact","data-testid":"ingest-row-render-visibility",disabled:!_t,title:_t?vl?"Disable in renders":"Enable in renders":gn?.reason||"Render visibility is read-only","aria-label":vl?`Disable ${Tt.label} in renders`:`Enable ${Tt.label} in renders`,"aria-pressed":!vl,onClick:oa=>{oa.stopPropagation(),i.inspector.set(Tt.id,"renderVisible",!vl),a.notifyIngestEdit()},children:z.jsx(So,{icon:vl?own:awn,"aria-hidden":"true"})}):z.jsx("span",{"aria-hidden":"true",style:{width:mX,flexShrink:0}})),Yt&&z.jsx(rf,{type:"button",variant:"ghost",size:"compact","data-testid":"world-interactive-toggle",title:ol?"Interactive (layer forwards pointer events)":"Not interactive (layer is pointer-events:none)","aria-label":`Forward pointer events to ${Tt.label}`,"aria-pressed":ol,onClick:oa=>{oa.stopPropagation(),yjr(Yt.worldId),a.notifyIngestEdit()},children:z.jsx(So,{icon:ODr,"aria-hidden":"true"})}),Yt&&z.jsx(rf,{type:"button",variant:"ghost",size:"compact","data-testid":"world-picklock-toggle",title:Sd?"Pick-locked (skipped by topmost-layer picking)":"Not pick-locked","aria-label":`Exclude ${Tt.label} from viewport picking`,"aria-pressed":Sd,onClick:oa=>{oa.stopPropagation(),bjr(Yt.worldId),a.notifyIngestEdit()},children:z.jsx(So,{icon:nIt,"aria-hidden":"true"})})]})},aEn);function lEn({store:t,adapter:r}){Xe.useSyncExternalStore(t.subscribe,t.getSnapshot);const i=Xe.useDeferredValue(t.contentVersion);Xe.useSyncExternalStore(rMr,nMr),Xe.useSyncExternalStore(kee,N8,N8);const a=wP().hierarchyTypeSuffix!=="hidden",l=wP().hierarchyInstanceRule!=="hidden",d=wP().hierarchyRestrictions??"select+viewport",[_,g]=Xe.useReducer(Xi=>Xi+1,0),b=Xe.useRef(t.getSnapshot());b.current=t.getSnapshot();const[S,k]=Xe.useState(Ywn());Xe.useEffect(()=>r.subscribe?.(()=>{b.current=t.getSnapshot(),g()}),[r,t]),Xe.useEffect(()=>Zwn(k),[]);const w=Xe.useMemo(()=>{const Xi=new Map;for(const Qn of S?.participants??[])if(Qn.participantId!==V0e)for(const Eo of Qn.presence.selection){const lc=Xi.get(Eo)??[];lc.includes(Qn.color)||lc.push(Qn.color),Xi.set(Eo,lc)}return Xi},[S]),N=Xe.useRef(new $An),P=Xe.useRef(new JAn),j=t.hierarchyRowFacetVersion,J=F0e(t),[X,G]=Xe.useState(""),ee=Xe.useSyncExternalStore(lCn,cCn,()=>null),[xe,ue]=Xe.useState(null),[fe,se]=Xe.useState(null),[de,ge]=Xe.useState(null),[qe,tt]=Xe.useState(!1),[Ct,Ot]=Xe.useState(null),vt=Xe.useRef(null),[Et,Tt]=Xe.useState(0),Le=Xe.useRef(null),cr=Xe.useSyncExternalStore(wPt,BAt,BAt).includes("outliner")?"outliner":void 0,Yt=Xe.useRef(new Map),Lr=Xe.useRef(new Map),nn=Xe.useRef(new TCn),on=Xe.useRef(0),gr=Xe.useRef(null),An=Xe.useRef(null),Rn=Xe.useRef(null),ln=Xe.useRef(null),[,Mn]=Xe.useReducer(Xi=>Xi+1,0),Is=X.trim().toLowerCase(),Zs=ad()?.rootPath??"__unscoped__",Zc=r.selection?.get()??[],vl=Zc.length===1?Zc[0]:null,gn=[...Zc].sort().join("\0"),_t=Xe.useMemo(()=>new Set(gn===""?[]:gn.split("\0")),[gn]),_o=Zc.at(-1)??null,Nr=I0e(r),ko=Nr.at(-1)??null,Sa=Xe.useRef("");Xe.useEffect(()=>{if(gn===""||Sa.current===gn)return;const Xi=Le.current,Qn=Xi?.querySelector('[data-selected="true"]');if(!Xi||!Qn)return;const Eo=Xi.getBoundingClientRect(),lc=Qn.getBoundingClientRect();(lc.top<Eo.top||lc.bottom>Eo.bottom)&&Qn.scrollIntoView({block:"nearest"}),Sa.current=gn}),gr.current!==Zs&&(Lr.current.clear(),gr.current=Zs,An.current=null);const _c=nn.current,Yl=[r,i,_],ol=_c.structural(Yl,Xi=>{const Qn=eCn(r,bCn(r.hierarchy)),Eo=pCn(Qn),lc=MCn(Eo.hierarchy),sf=t.gizmoEpoch,Zl=Xi?i-Xi.contentVersion:0,Ku=Xi?sf-Xi.objectMapEpoch:0,eu=Xi?.adapter===r&&i===t.contentVersion&&Zl>0&&Zl===Ku?t.ingestObjectMapChangesSince(Xi.objectMapEpoch):null,Bt=(Xi&&eu?wCn(lc,Xi.structuralRows,eu.changedParentIds):null)??kTt(lc,new Set),zr=_Cn(tCn(VCn(Bt,r),Bt,Gt=>Qn.isComponentRoot(Gt)),Eo);return{adapter:r,contentVersion:i,objectMapEpoch:sf,marked:Qn,internals:Eo,hierarchyView:lc,structuralRows:Bt,defaultExpansion:zr,index:kCn(Bt)}}),{marked:Sd,internals:Qu,hierarchyView:vu,structuralRows:$l,defaultExpansion:el}=ol,gc=Xi=>Lr.current.get(Xi)??oCn(Zs,Xi)??el.get(Xi)??!0,Cf=An.current;if(Cf?.adapter!==r||Cf.selection!==gn){for(const Qn of DTt(ol.index,_t))gc(Qn)||(Lr.current.set(Qn,!0),on.current+=1);[..._t].every(Qn=>ol.index.pathKeysByNodeId.has(Qn))&&(An.current={adapter:r,selection:gn})}const Qr=Xi=>gc(Xi.node.id),Cl=Is.length===0&&(W9r()||t.playState!=="stopped"),ku=WCn(Yt.current,Cl?ICn(ol.index,_t):jCn),xi=nn.current.collapsed([ol,on.current,Zs,ko],()=>{const Xi=ko?$l.find(Eo=>!Eo.more&&Eo.node.id===ko)??null:null,Qn=new Set($l.filter(Eo=>!Eo.more&&Eo.hasChildren&&!Qr(Eo)).map(Eo=>Eo.pathKey));if(Xi){Qn.delete(Xi.pathKey);for(const Eo of dKe(Xi.pathKey))Qn.delete(Eo)}return{scopeRow:Xi,effectiveCollapsedPaths:Qn}}),{scopeRow:Iu,effectiveCollapsedPaths:Xl}=xi,oa=nn.current.browse([ol,xi,Is,Cl,Cl?DCn(ku):""],()=>{const Xi=kTt(vu,Xl,ku,Cl),Qn=Is?JCn($l,Is,Qu.isInternal):null,Eo=Qn?$l.filter(Zl=>Qn.has(Zl.pathKey)):Xi,sf=(Iu?Eo.filter(Zl=>Zl.pathKey.startsWith(`${Iu.pathKey}.`)).map(Zl=>({...Zl,depth:Math.max(0,Zl.depth-Iu.depth-1)})):Eo).filter(Zl=>{if(Xme(r,Zl.node.id))return!0;let Ku=Zl.node.parentId;for(;Ku;){const eu=pKe(r,Ku);if(eu&&zP(eu.worldId))return!1;Ku=vu.node(Ku)?.parentId??null}return!0});return{rows:Is?sf:sf.filter(Zl=>!Zl.hiddenByCollapse)}}),{rows:aa}=oa,Ef=Xe.useMemo(()=>aa.some(Xi=>r.inspector?.get(Xi.node.id,"exclude")!==void 0),[aa,r,_,i]);Xe.useEffect(()=>{Tt(0),Le.current&&(Le.current.scrollTop=0)},[Is]);const Tg=Le.current?.clientHeight||RCn,xp=a9e(Le.current),{start:ca,end:Tf}=aa.length>LCn?CCn(aa.length,Et,Tg,xp,FCn):{start:0,end:aa.length},qo=aa.slice(ca,Tf),eg=ca*xp,ac=(aa.length-Tf)*xp,Qo=Xe.useCallback(Xi=>{const Qn=$l.filter(Eo=>Eo.hasChildren).map(Eo=>[Eo.node.id,Xi]);for(const[Eo,lc]of Qn)Lr.current.set(Eo,lc);ETt(Zs,Qn),on.current+=1,Mn()},[Zs,$l]),kf={rows:aa,window:{start:ca,end:Tf},searchTerm:Is||null,scopeId:ko,isExpanded:Qr,isInternal:Xi=>Qu.isInternal(Xi),isComponentRoot:Xi=>Sd.isComponentRoot(Xi),foldedInternalCount:Xi=>Sd.internalChildren?.(Xi)?.length??0,expandAll:()=>Qo(!0),collapseAll:()=>Qo(!1)};Xe.useEffect(()=>(Kgn(kf),()=>Xgn(kf)),[kf]);const Ze=Xe.useRef({adapter:r,rows:aa,selectedIds:_t,structuralRows:$l,isExpanded:Qr,projectIdentity:Zs});Ze.current={adapter:r,rows:aa,selectedIds:_t,structuralRows:$l,isExpanded:Qr,projectIdentity:Zs};const $t=Xe.useCallback((Xi,Qn)=>{const Eo=Ze.current,lc=!Eo.isExpanded(Xi),sf=[[Xi.node.id,lc]];if(Qn){const Zl=`${Xi.pathKey}.`;for(const Ku of Eo.structuralRows)Ku.hasChildren&&Ku.pathKey.startsWith(Zl)&&sf.push([Ku.node.id,lc])}for(const[Zl,Ku]of sf)Lr.current.set(Zl,Ku);ETt(Eo.projectIdentity,sf),on.current+=1,Mn()},[]),Rt=Xe.useCallback(()=>{Lr.current.clear();for(const Xi of DTt(ol.index,_t))Lr.current.set(Xi,!0);aCn(Zs),on.current+=1,Mn()},[Zs,gn,ol]),ft=Xe.useCallback(Xi=>{const Qn=Yt.current;Qn.set(Xi,(Qn.get(Xi)??Oye)+Oye),on.current+=1,Mn()},[]),Tr=Xe.useCallback(Xi=>{aMr(r,Xi)},[r,t]);Xe.useEffect(()=>{if(!gn){ln.current=null;return}const Xi=ln.current;if(Xi?.adapter===r&&Xi.selection===gn)return;ln.current={adapter:r,selection:gn};const Qn=aa.findIndex(Ku=>_t.has(Ku.node.id)),Eo=Le.current;if(Qn<0||!Eo)return;const lc=a9e(Eo),sf=Qn*lc,Zl=sf+lc;sf<Eo.scrollTop?Eo.scrollTop=sf:Zl>Eo.scrollTop+Eo.clientHeight&&(Eo.scrollTop=Math.max(0,Zl-Eo.clientHeight)),Tt(Eo.scrollTop)},[r,aa,_t,gn]);const ti=Xe.useCallback((Xi,Qn)=>{const Eo=Ze.current;if(Eo.adapter.selection){if(Xi.metaKey||Xi.ctrlKey){const lc=new Set(Eo.selectedIds);lc.has(Qn)?lc.delete(Qn):lc.add(Qn),k0(Eo.adapter,[...lc])}else if(Xi.shiftKey&&Rn.current){const lc=Eo.rows.findIndex(Zl=>Zl.node.id===Rn.current),sf=Eo.rows.findIndex(Zl=>Zl.node.id===Qn);if(lc>=0&&sf>=0){const Zl=Math.min(lc,sf),Ku=Math.max(lc,sf),eu=Eo.rows.slice(Zl,Ku+1).filter(ze=>!ze.more).map(ze=>ze.node.id);k0(Eo.adapter,eu)}}else k0(Eo.adapter,[Qn]);Rn.current=Qn}},[]),Gi=Xe.useCallback((Xi,Qn)=>{const Eo=Ze.current.selectedIds,lc=Eo.has(Qn)?[...Eo]:[Qn];Ot(lc),Xi.dataTransfer.effectAllowed="move",Xi.dataTransfer.setData(o9e,JSON.stringify(lc)),Xi.dataTransfer.setData("text/plain",Qn)},[]),Ni=Xe.useCallback((Xi,Qn)=>{ue({x:Xi.clientX,y:Xi.clientY,nodeId:Qn})},[]),jo=Xe.useCallback(Xi=>{const Qn=Xi.dataTransfer.types.includes(o9e),Eo=Xi.dataTransfer.types.includes(s9e);if(!Qn&&!Eo)return;Xi.preventDefault(),Xi.dataTransfer.dropEffect=Qn?"move":"copy",vt.current=null;const lc=Le.current.getBoundingClientRect(),sf=Le.current.scrollTop,Zl=Xi.clientY-lc.top+sf,Ku=a9e(Le.current),eu=Math.floor(Zl/Ku);if(eu>=aa.length){ge(null),tt(!0),Qn&&Ct&&(vt.current=wTt({hasStructureWritePath:NTt(r,Ct[0]),targetIsInternal:!1}));return}tt(!1);const ze=eu>=0?aa[eu]:void 0;if(!ze||ze.more){ge(null);return}const Bt=wTt({hasStructureWritePath:Qn?NTt(r,ze.node.id):!0,targetIsInternal:Qu.isInternal(ze.node.id)});if(Bt!==null){vt.current=Bt,ge(null);return}const zr=Zl-eu*Ku;let Gt;if(zr<Ku*.25?Gt="before":zr>Ku*.75?Gt="after":Gt="child",Qn&&Ct){const qr=ze.node.id;if(Ct.includes(qr)||qCn(qr,Ct,r))return;if(!nCn(r,Ct,qr)){ge(null);return}}if(Xme(r,ze.node.id)&&Gt!=="child"&&(Gt="child"),(ze.node.role==="document"||ze.node.role==="story")&&(Gt="child"),ze.node.role==="folder"||ze.node.role==="boundary"){ge(null);return}ge({nodeId:ze.node.id,zone:Gt})},[aa,Ct,r,Qu]),yc=Xe.useCallback(()=>{ge(null),tt(!1),Ot(null),vt.current=null},[]),cd=Xe.useCallback(Xi=>{Xi.preventDefault(),Xi.stopPropagation();const Qn=de,Eo=qe,lc=vt.current;if(ge(null),tt(!1),Ot(null),vt.current=null,lc!==null){My(lc);return}const sf=r.structure,Zl=Xi.dataTransfer.getData(o9e);if(Zl&&sf){const eu=JSON.parse(Zl);if(Eo){for(const ns of eu)NR(r,ns,null);return}if(!Qn)return;const ze=aa.find(ns=>ns.node.id===Qn.nodeId);if(!ze)return;const Bt=ze.node.id;if(Qn.zone==="child"){for(const ns of eu)NR(r,ns,Bt);return}const zr=ze.node.parentId,Gt=zCn(r,zr).filter(ns=>!eu.includes(ns)),qr=Gt.indexOf(Bt),Ai=Qn.zone==="before"?Bt:qr>=0?Gt[qr+1]??null:null;for(const ns of eu)(r.hierarchy.node(ns)?.parentId??null)!==zr&&NR(r,ns,zr??null),mUe(r,ns,Ai);return}const Ku=Xi.dataTransfer.getData(s9e);if(Ku&&r.assetDrop)try{const eu=JSON.parse(Ku);if(eu.kind==="scene")return;const ze={item:eu.component??{kind:"file",name:eu.name??eu.path.split("/").pop()??eu.path}};if(Eo){r.assetDrop.accepts("",eu.path,ze)&&eLe(r,"",eu.path,ze);return}if(!Qn)return;const Bt=aa.find(Gt=>Gt.node.id===Qn.nodeId);if(!Bt)return;const zr=Bt.node.id;r.assetDrop.accepts(zr,eu.path,ze)&&eLe(r,zr,eu.path,ze)}catch{}},[de,qe,aa,r]),nf=p4t(r)??"Untitled";return z.jsxs(Oze,{name:null,hideHeader:!0,onPointerDown:()=>H8("hierarchy"),onDragOver:Xi=>{Xi.dataTransfer.types.includes(s9e)&&(Xi.preventDefault(),Xi.dataTransfer.dropEffect="copy")},style:{flex:1,minWidth:0,minHeight:0,borderRight:`1px solid ${Oo.boundary.default}`},children:[z.jsx("span",{"data-testid":"scene-name","data-scene":nf,style:{display:"none"},children:nf}),z.jsx(rEn,{slot:ee,search:X,setSearch:G,adapter:r,createTargetId:vl,onCollapseAll:()=>Qo(!1),onResetExpansion:Rt,onExpandAll:()=>Qo(!0)}),ko&&z.jsxs("nav",{"data-testid":"selection-scope-breadcrumb","aria-label":"Selection scope",style:{display:"flex",alignItems:"center",gap:3,minHeight:26,padding:`0 ${U_[2]}px`,borderBottom:`1px solid ${Oo.boundary.default}`,overflow:"hidden",flexShrink:0},children:[z.jsx(fo,{variant:"ghost",size:"compact","data-testid":"selection-scope-root",onClick:()=>ZAt(r,null),children:"Game"}),Nr.map((Xi,Qn)=>{const Eo=r.hierarchy.node(Xi);if(!Eo)return null;const lc=Qn===Nr.length-1;return z.jsxs("span",{style:{display:"flex",alignItems:"center",minWidth:0},children:[z.jsx("span",{"aria-hidden":"true",style:{color:Oo.content.muted},children:"/"}),z.jsx(fo,{variant:"ghost",size:"compact","data-testid":"selection-scope-crumb","data-scope-current":lc?"true":void 0,"aria-current":lc?"location":void 0,onClick:()=>ZAt(r,Xi),style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis"},children:Eo.label})]},Xi)})]}),z.jsxs("div",{ref:Le,"data-testid":"ingest-hierarchy",className:"vgai-content-frost vgai-tree-body","data-vgai-region":cr,style:{flex:1,minHeight:0,overflow:"auto",position:"relative",pointerEvents:"auto"},onDragOver:jo,onDrop:cd,onDragEnd:yc,onScroll:Xi=>Tt(Xi.currentTarget.scrollTop),onDragLeave:Xi=>{Le.current?.contains(Xi.relatedTarget)||(ge(null),tt(!1))},children:[z.jsx("div",{"data-testid":"game-hierarchy-spacer-top",style:{height:eg}}),qo.map((Xi,Qn)=>Xi.more?z.jsx(sEn,{row:Xi,onReveal:ft},ITt(Xi)):z.jsx(cEn,{row:Xi,rowIndex:ca+Qn,prevDepth:aa[ca+Qn-1]?.depth??-1,nextDepth:aa[ca+Qn+1]?.depth??-1,adapter:r,store:t,isSelected:_t.has(Xi.node.id),isSelectionActive:_o===Xi.node.id,isEditing:fe===Xi.node.id,isCollapsed:Is?!1:Xl.has(Xi.pathKey),dropZone:de&&de.nodeId===Xi.node.id?de.zone:null,isDragged:Ct?.includes(Xi.node.id)??!1,isInternal:Qu.isInternal(Xi.node.id),threeRootId:J,searchTerm:Is,lockCache:N.current,warningCache:P.current,editabilityVersion:j,adapterVersion:_,onToggleOpen:$t,onStartEditing:se,onContextMenu:Ni,onDragStart:Gi,onClick:ti,onEnterScope:Tr,typeSuffixShown:a,instanceRuleShown:l,restrictionColumns:d,excludeColumnShown:Ef,remoteSelectionColors:w.get(Xi.node.id)??NCn},ITt(Xi))),z.jsx("div",{"data-testid":"game-hierarchy-spacer-bottom",style:{height:ac}}),z.jsx("div",{style:{minHeight:40}}),qe&&z.jsx("div",{style:{position:"absolute",left:0,right:0,top:aa.length*xp,height:2,background:Oo.accent.default,pointerEvents:"none",zIndex:VN.overlayLow}})]}),xe&&(()=>{const Xi=vu.node(xe.nodeId),Qn=Xi?Xme(r,Xi.id)||_Ke(r,Xi.id):!1;return z.jsx(nEn,{state:xe,adapter:r,store:t,isGroupNode:Qn,isInternal:Qu.isInternal(xe.nodeId),onRename:se,onClose:()=>ue(null)})})()]})}function oKt(){const t=D0(),[,r]=Xe.useReducer(a=>a+1,0);Xe.useSyncExternalStore(Aw,Sb),Xe.useSyncExternalStore(Nee,MP);const{adapter:i}=wm(t);return Xe.useEffect(()=>i.subscribe?.(r),[i]),z.jsx(lEn,{store:t,adapter:i},Gwn(i))}const vbe="https://vgai-learn.pages.dev/",uEn=`${vbe}quick-starts/`,fEn=`${vbe}manual/`,FTt=`${vbe}reference/`;function aKt(t){const r=/^(\d+)\.(\d+)(?:[.+-]|$)/.exec(t?.trim()??"");if(!r)return null;const i=`${Number(r[1])}.${Number(r[2])}`;return i==="0.0"?null:i}function dEn(t){const r=aKt(t);return r===null?FTt:`${FTt}${r}/`}function P_e(t){window.open(t,"_blank","noopener,noreferrer")}function pEn(){const t=D0(),r=By(t),i=r.structure,a=[...t.selectedEntityIds],l=a[0],d=l?r.hierarchy.node(l)?.parentId??null:null,_=cbe(),g=RGt(),b=Xe.useSyncExternalStore(jA,WMe,WMe);Xe.useSyncExternalStore(mPt,Phe,Phe),Xe.useSyncExternalStore(oU,Che,Che),Xe.useSyncExternalStore(TPt,Lhe,Lhe),Xe.useSyncExternalStore(Uye,w8,w8);const S=se=>{const de=AIt(se);return de.length===0?null:z.jsxs(z.Fragment,{children:[z.jsx(Ny,{}),de.map(ge=>z.jsx(Wa,{...ge.testId?{"data-testid":ge.testId}:{},disabled:ge.disabled?.({})??!1,onSelect:ue(()=>void ge.execute({})),children:typeof ge.label=="function"?ge.label():ge.label},ge.id))]})},k=Xe.useSyncExternalStore(WGt,Yz,Yz),w=Xe.useSyncExternalStore(yPt,wS,wS),P=Xe.useSyncExternalStore(Iw,ad,ad)?.config.engine.version??null,j=aKt(P),[J,X]=Xe.useState(null);HQt(()=>J?h3r():"");const G=Xe.useRef(null),ee=Xe.useRef({}),xe=se=>ee.current[se]??={current:null};Xe.useEffect(()=>{if(!J)return;const se=de=>{G.current?.contains(de.target)||X(null)};return document.addEventListener("pointerdown",se),()=>document.removeEventListener("pointerdown",se)},[J]);const ue=se=>()=>{X(null),se()},fe={edit:z.jsxs(z.Fragment,{children:[z.jsx(Wa,{disabled:g.busy||!g.canUndo,onSelect:ue(()=>_.undo()),children:g.undoLabel?`Undo ${g.undoLabel}`:"Undo"}),z.jsx(Wa,{disabled:g.busy||!g.canRedo,onSelect:ue(()=>_.redo()),children:g.redoLabel?`Redo ${g.redoLabel}`:"Redo"}),z.jsx(Ny,{}),z.jsx(Wa,{onSelect:ue(ZQe),children:"Undo History…"}),z.jsx(Ny,{}),z.jsx(Wa,{disabled:a.length===0||!i?.cut||!(i.canCopy?.(a)??!0),onSelect:ue(()=>YQe(t)),children:"Cut"}),z.jsx(Wa,{disabled:a.length===0||!i?.copy||!(i.canCopy?.(a)??!0),onSelect:ue(()=>KQe(t)),children:"Copy"}),z.jsx(Wa,{disabled:!i?.paste||!(i.canPaste?.(d)??!0),onSelect:ue(()=>XQe(t)),children:"Paste"}),z.jsx(Ny,{}),z.jsx(Wa,{disabled:t.selectedEntityIds.size===0,onSelect:ue(()=>void dbe(t)),children:"Duplicate"}),z.jsx(Wa,{disabled:t.selectedEntityIds.size===0,onSelect:ue(()=>void pbe(t)),children:"Delete"}),z.jsx(Ny,{}),z.jsx(Wa,{onSelect:ue(()=>cNt(t)),children:"Select All"}),z.jsx(Wa,{disabled:t.selectedEntityIds.size===0,onSelect:ue(()=>t.select(null)),children:"Deselect All"})]}),view:z.jsxs(z.Fragment,{children:[z.jsx(Wa,{onSelect:ue(()=>FQe()),children:"Command Palette…"}),z.jsx(Wa,{onSelect:ue(async()=>{const se=Ehn(t);try{await navigator.clipboard.writeText(se),ua.log("Copied a link to the current editor view.","editor")}catch(de){ua.error(`Could not copy the editor view link: ${de instanceof Error?de.message:String(de)}`,"editor")}}),children:"Copy View Link"}),z.jsx(Ny,{}),z.jsx(Wa,{onSelect:ue(Gze),children:"Toggle Focus Mode"}),S("view")]}),window:z.jsxs(z.Fragment,{children:[X8().filter(se=>CP(se.id)).map(se=>z.jsxs(Wa,{role:"menuitemradio","aria-checked":w===se.id,"data-testid":`workspace-${se.id}`,title:se.description,onSelect:ue(()=>CS(se.id)),children:[z.jsx(So,{icon:yb.status.success,style:{opacity:w===se.id?1:0}}),"Workspace: ",se.title]},se.id)),z.jsx(Ny,{}),z.jsx(Wa,{onSelect:ue(obe),children:"Console"}),z.jsx(Wa,{onSelect:ue(()=>hE(_ee.lightExplorer.id)),children:"Light Explorer"}),z.jsx(Wa,{onSelect:ue(()=>Hze("asset-library")),children:"Asset Library"}),z.jsx(Wa,{onSelect:ue(()=>hE("generations")),children:"Generations"}),S("window")]}),debug:z.jsx(z.Fragment,{children:S("debug")}),tools:z.jsxs(z.Fragment,{children:[z.jsxs(Wa,{onSelect:ue(()=>gbe(t)),children:["Project Tools…",k.tools.length>0?` (${k.tools.length})`:""]}),z.jsx(Ny,{}),b.length?b.map(se=>z.jsx(Wa,{onSelect:ue(()=>{se.point==="workspace.document"?fI(t,se.id):hE(`tool:${se.id}`)}),children:se.title},se.id)):z.jsx(Wa,{disabled:!0,children:"No custom project tools"}),S("tools")]}),help:z.jsxs(z.Fragment,{children:[z.jsx(Wa,{"data-testid":"help-learn-home",onSelect:ue(()=>P_e(vbe)),children:"vgai Learn"}),z.jsx(Wa,{"data-testid":"help-quick-starts",onSelect:ue(()=>P_e(uEn)),children:"Quick-starts"}),z.jsx(Wa,{"data-testid":"help-manual",onSelect:ue(()=>P_e(fEn)),children:"Manual"}),z.jsx(Ny,{}),z.jsx(Wa,{"data-testid":"help-reference",title:j?`API/schema reference pinned to this project's engine (v${P})`:"API/schema reference (no engine version pin available)",onSelect:ue(()=>P_e(dEn(P))),children:j?`Reference for v${P}`:"Reference"}),S("help")]})};return z.jsx("div",{ref:G,style:{display:"flex",alignItems:"stretch",marginLeft:"var(--vgai-space-2)"},children:["edit","view","window","debug","tools","help"].map(se=>z.jsxs("div",{ref:xe(se),style:{position:"relative"},children:[z.jsx(kze,{"data-testid":`app-menu-${se}`,"aria-haspopup":"menu","aria-expanded":J===se,onClick:()=>X(de=>de===se?null:se),onKeyDown:de=>{de.key==="ArrowDown"&&(de.preventDefault(),X(se))},onPointerEnter:()=>{J&&X(se)},style:{textTransform:"capitalize"},children:se}),J===se&&z.jsx(JR,{anchorRef:xe(se),dismissBoundaryRef:xe(se),align:"start",gap:0,clamp:!0,autoFocusFirst:!0,onDismiss:()=>{const de=G.current?.querySelector(`[data-testid="app-menu-${se}"]`);X(null),requestAnimationFrame(()=>de?.focus())},style:{minWidth:190},children:fe[se]})]},se))})}const _En=new Map,RTt=new Set;let mEn=0;function hEn(t){return _En.get(t)??gEn}const gEn=[];function yEn(t){return RTt.add(t),()=>RTt.delete(t)}function MTt(){return mEn}function Zme({slot:t}){return Xe.useSyncExternalStore(yEn,MTt,MTt),z.jsx(z.Fragment,{children:hEn(t).map(r=>z.jsx(r.Content,{},r.owner))})}const vEn=[],LTt=new Set;let bEn=0;async function AEn(t){const r=new Set,i=[];for(const a of vEn){let l;try{l=await a.harnesses(t)}catch{continue}for(const d of l)r.has(d.id)||(r.add(d.id),i.push(d))}return i}function SEn(t){return LTt.add(t),()=>{LTt.delete(t)}}function jTt(){return bEn}async function wI(t,r){const i=await fetch(`/__editor/share-control${t}`,{...r,headers:{...r?.body?{"Content-Type":"application/json"}:{},...r?.headers}});if(i.status!==204&&np(i,`Git request ${t} failed`),!i.ok){const a=await i.json().catch(()=>null);throw new Error(typeof a?.error=="string"?a.error:`Git request failed (${i.status}).`)}return i.status===204?void 0:await i.json()}async function xEn(){const t=await fetch("/__editor/git/status");return Eg(t,"Git status failed")}function wEn(t){return wI("/git/checkpoint",{method:"POST",body:JSON.stringify(t)})}function CEn(t){return wI("/git/publish",{method:"POST",...t?{signal:t}:{}})}function BTt(t){return wI("/git/stage",{method:"POST",body:JSON.stringify(t)})}function EEn(t){return wI("/git/fetch",{method:"POST",...t?{signal:t}:{}})}function TEn(t){return wI("/git/update",{method:"POST",...t?{signal:t}:{}})}function $Tt(t){return wI("/git/rebase",{method:"POST",body:JSON.stringify({action:t})})}function kEn(){return wI("/git/readiness",{method:"POST"})}function IEn(t){return wI("/git/pull-request",{method:"POST",body:JSON.stringify(t)})}function DEn(){return wI("/git/pull-request/status")}function PEn(t){return wI("/git/pull-request/merge",{method:"POST",...t?{signal:t}:{}})}function NEn(){const[t,r]=Xe.useState(null),[i,a]=Xe.useState(!1),[l,d]=Xe.useState(null),[_,g]=Xe.useState([]),[b,S]=Xe.useState(""),[k,w]=Xe.useState(null),[N,P]=Xe.useState(null),[j,J]=Xe.useState(null),[X,G]=Xe.useState(!1),ee=Xe.useRef(null);Xe.useEffect(()=>{xEn().then(de=>{d(de),g(de.changed.map(ge=>ge.path))}).catch(de=>r(String(de)))},[]);const xe=de=>{d(de),g(ge=>ge.filter(qe=>de.changed.some(tt=>tt.path===qe)))},ue=async(de,ge,qe)=>{const tt=new AbortController;ee.current=tt,P(qe??null),a(!0),r(null),w(null);try{xe(await de(tt.signal)),w(ge)}catch(Ct){r(Ct instanceof Error?Ct.message:String(Ct))}finally{ee.current===tt&&(ee.current=null),P(null),a(!1)}},fe=de=>{J(null),IEn({title:de}).then(ge=>{xe(ge.status),w(`Pull request: ${ge.url}`)}).catch(ge=>r(String(ge)))},se=()=>{G(!1);const de=new AbortController;ee.current=de,P("Merging pull request"),a(!0),PEn(de.signal).then(ge=>w(`Merged pull request: ${ge.url}`)).catch(ge=>r(String(ge))).finally(()=>{ee.current===de&&(ee.current=null),P(null),a(!1)})};return z.jsxs("section",{className:"vgai-worktree-version-control",children:[t&&z.jsx("div",{style:{color:Oo.semantic.danger,fontSize:zY.sm,marginBottom:5},children:t}),l?.available?z.jsxs("details",{style:{marginTop:pv[4]},children:[z.jsxs("summary",{style:{cursor:"pointer",fontSize:zY.sm},children:["Git · ",l.branch??"detached"," ·"," ",l.dirty?`${l.changed.length} changed`:"clean",l.baseAhead!==null&&l.baseBehind!==null?` · base +${l.baseAhead}/-${l.baseBehind}`:"",l.ahead!==null&&l.behind!==null?` · remote +${l.ahead}/-${l.behind}`:""]}),z.jsxs("div",{style:{display:"grid",gap:5,marginTop:5,fontSize:zY.sm},children:[z.jsxs("span",{style:{color:Oo.content.dim},children:[l.repositoryId.slice(0,20)," · ",l.worktreeId.slice(0,20)]}),l.changed.map(de=>{const ge=l.hunks.filter(qe=>qe.path===de.path);return z.jsxs("div",{style:{display:"grid",gap:3},children:[z.jsxs("div",{style:{display:"flex",gap:5,alignItems:"center"},children:[z.jsx(SE,{"aria-label":`Include ${de.path} in checkpoint`,checked:_.includes(de.path),onChange:qe=>g(tt=>qe.target.checked?[...tt,de.path]:tt.filter(Ct=>Ct!==de.path))}),z.jsxs("code",{style:{minWidth:0,flex:1},children:[de.index,de.worktree," ",de.path]}),z.jsx(fo,{type:"button",size:"compact",variant:"ghost",disabled:i,onClick:()=>void ue(()=>BTt({path:de.path,staged:de.index!==" "&&de.index!=="?"}),de.index!==" "&&de.index!=="?"?`Unstaged ${de.path}.`:`Staged ${de.path}.`),children:de.index!==" "&&de.index!=="?"?"Unstage file":"Stage file"})]}),ge.map(qe=>z.jsxs("div",{style:{display:"flex",gap:5,paddingLeft:22,alignItems:"center"},children:[z.jsxs("code",{style:{minWidth:0,flex:1,color:Oo.content.dim},children:[qe.header," · +",qe.additions,"/-",qe.deletions]}),z.jsx(fo,{type:"button",size:"compact",variant:"ghost",disabled:i,onClick:()=>void ue(()=>BTt({path:qe.path,hunkId:qe.id,staged:qe.staged}),qe.staged?"Hunk unstaged.":"Hunk staged."),children:qe.staged?"Unstage hunk":"Stage hunk"})]},qe.id))]},de.path)}),l.rebaseInProgress&&z.jsxs("div",{role:"alert",style:{display:"grid",gap:5,color:Oo.semantic.warning},children:[z.jsxs("span",{children:["Rebase paused",l.conflicts.length>0?` · conflicts: ${l.conflicts.join(", ")}`:""]}),z.jsxs("span",{style:{display:"flex",gap:5},children:[z.jsx(fo,{type:"button",size:"compact",variant:"outline",disabled:i||l.conflicts.length>0,onClick:()=>void ue(()=>$Tt("continue"),"Rebase continued."),children:"Continue rebase"}),z.jsx(fo,{type:"button",size:"compact",variant:"ghost",disabled:i,onClick:()=>void ue(()=>$Tt("abort"),"Rebase aborted."),children:"Abort rebase"})]})]}),l.dirty&&z.jsxs("div",{style:{display:"flex",gap:5},children:[z.jsx(k_,{"aria-label":"Git checkpoint message",placeholder:"Checkpoint message",value:b,onChange:de=>S(de.target.value),style:{minWidth:0,flex:1}}),z.jsx(fo,{type:"button",size:"compact",variant:"outline",disabled:i||!b.trim()||_.length===0,onClick:()=>void ue(()=>wEn({paths:_,message:b}),"Selected paths checkpointed with verified account attribution.").then(()=>S("")),children:"Checkpoint"})]}),z.jsxs("div",{style:{display:"flex",gap:5,flexWrap:"wrap"},children:[z.jsx(fo,{type:"button",size:"compact",variant:"outline",disabled:i||!l.remoteUrl,onClick:()=>void ue(EEn,"Remote refs fetched and pruned.","Fetching"),children:"Fetch"}),z.jsx(fo,{type:"button",size:"compact",variant:"outline",disabled:i||l.dirty||!l.remoteUrl,onClick:()=>void ue(CEn,"Branch published.","Publishing"),children:"Publish"}),z.jsx(fo,{type:"button",size:"compact",variant:"outline",disabled:i||l.dirty||!l.baseRef,onClick:()=>void ue(TEn,"Branch rebased onto its base.","Fetching and rebasing"),children:"Update from base"}),z.jsx(fo,{type:"button",size:"compact",variant:"outline",disabled:i,onClick:()=>void kEn().then(de=>{xe(de.status),w(de.ready?"Merge-ready; no merge was performed.":de.reasons.join(" "))}).catch(de=>r(String(de))),children:"Check merge readiness"}),l.github&&l.upstream&&z.jsxs(z.Fragment,{children:[z.jsx(fo,{type:"button",size:"compact",variant:"outline",disabled:i,onClick:()=>J(b||l.branch||"Volter Editor changes"),children:"Create PR"}),z.jsx(fo,{type:"button",size:"compact",variant:"ghost",disabled:i,onClick:()=>void DEn().then(de=>w(de.available?`PR ${de.state??"open"} · ${de.mergeState??"status unknown"} · checks ${de.checks?.passed??0} passed/${de.checks?.pending??0} pending/${de.checks?.failed??0} failed${de.reviewDecision?` · review ${de.reviewDecision}`:""}${de.url?` · ${de.url}`:""}`:de.reason??"No pull request found.")).catch(de=>r(String(de))),children:"PR status"}),z.jsx(fo,{type:"button",size:"compact",variant:"outline",disabled:i||l.dirty||l.rebaseInProgress,onClick:()=>G(!0),children:"Merge PR…"})]})]}),N&&z.jsxs("div",{role:"status",style:{display:"flex",gap:5,alignItems:"center"},children:[z.jsxs("span",{children:[N,"…"]}),z.jsx(fo,{type:"button",size:"compact",variant:"ghost",onClick:()=>ee.current?.abort(),children:"Cancel"})]}),l.history.length>0&&z.jsxs("details",{children:[z.jsx("summary",{style:{cursor:"pointer",color:Oo.content.dim},children:"Recent history"}),z.jsx("div",{style:{display:"grid",gap:3,paddingTop:pv[2]},children:l.history.map(de=>z.jsxs("span",{title:`${de.author} · ${de.authoredAt}`,children:[z.jsx("code",{children:de.shortSha})," · ",de.subject]},de.sha))})]}),k&&z.jsx("span",{style:{color:Oo.semantic.success},children:k})]})]}):z.jsx("span",{style:{color:Oo.content.dim,fontSize:zY.sm},children:"Loading version control…"}),j!==null&&z.jsxs(Z9e,{labelledBy:"vgai-pull-request-title-heading",onDismiss:()=>J(null),children:[z.jsx(eMe,{titleId:"vgai-pull-request-title-heading",title:"Create pull request",description:`Opens a pull request for ${l?.branch??"this branch"} on its remote.`}),z.jsx(YDt,{children:z.jsx(k_,{"aria-label":"Pull request title",autoFocus:!0,value:j,onChange:de=>J(de.target.value),onKeyDown:de=>{de.key!=="Enter"||!j.trim()||(de.preventDefault(),fe(j.trim()))}})}),z.jsxs(tMe,{children:[z.jsx(fo,{type:"button",variant:"ghost",onClick:()=>J(null),children:"Cancel"}),z.jsx(fo,{type:"button",variant:"primary",disabled:!j.trim(),onClick:()=>fe(j.trim()),children:"Create pull request"})]})]}),X&&z.jsxs(Z9e,{labelledBy:"vgai-merge-pr-heading",onDismiss:()=>G(!1),children:[z.jsx(eMe,{titleId:"vgai-merge-pr-heading",title:"Merge pull request",description:`Merging the pull request for ${l?.branch??"this branch"} changes the remote repository.`}),z.jsxs(tMe,{children:[z.jsx(fo,{type:"button",variant:"ghost",onClick:()=>G(!1),children:"Cancel"}),z.jsx(fo,{type:"button",variant:"primary",onClick:se,children:"Merge pull request"})]})]})]})}const OEn={worktrees:[],branches:[],isolatedWorktrees:[]};function FEn(t){return`agent/${t.toLocaleLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"").slice(0,42)||"task"}`}function REn({currentLabel:t,onDone:r,onError:i}){const[a,l]=Xe.useState(""),[d,_]=Xe.useState("agent/task"),[g,b]=Xe.useState(!1),[S,k]=Xe.useState("worktree"),[w,N]=Xe.useState([]),[P,j]=Xe.useState(""),[J,X]=Xe.useState(!1),G=Xe.useSyncExternalStore(SEn,jTt,jTt);return Xe.useEffect(()=>{let ee=!0;return AEn(S).then(xe=>{ee&&(N(xe),j(ue=>xe.some(fe=>fe.id===ue)?ue:xe[0]?.id??""))}),()=>{ee=!1}},[S,G]),z.jsxs("div",{className:"vgai-worktree-delegate",role:"group","aria-label":"Delegate task",children:[z.jsx(Ru,{as:"div",variant:"label",children:"Delegate task"}),z.jsx(Nze,{"aria-label":"Task for the agent",placeholder:"Describe a bounded task…",value:a,onChange:ee=>{const xe=ee.target.value;l(xe),g||_(FEn(xe))}}),z.jsxs("label",{children:[z.jsx("span",{children:"Harness"}),z.jsxs(bS,{value:P,onChange:ee=>j(ee.target.value),children:[w.length===0&&z.jsx("option",{value:"",children:"No harness ready"}),w.map(ee=>z.jsx("option",{value:ee.id,children:ee.label},ee.id))]})]}),z.jsxs("label",{children:[z.jsx("span",{children:"Isolation"}),z.jsxs(bS,{value:S,onChange:ee=>{k(ee.target.value)},children:[z.jsx("option",{value:"worktree",children:"New worktree (recommended)"}),z.jsx("option",{value:"container",children:"Bounded container (untrusted code)"}),z.jsx("option",{value:"current",children:"Current worktree (shared files)"})]})]}),S!=="current"&&z.jsxs("label",{children:[z.jsx("span",{children:"Branch"}),z.jsx(k_,{"aria-label":"Delegated branch",value:d,onChange:ee=>{b(!0),_(ee.target.value)}})]}),z.jsx(Ru,{as:"div",variant:"caption",tone:"dim",children:S==="worktree"?`Creates a sibling checkout from ${t}, opens its editor, and starts the agent there.`:S==="container"?"Creates a credential-empty, resource-bounded Docker worktree. You authenticate the harness inside its temporary home.":"The agent edits the files in this live worktree alongside you."}),z.jsx(fo,{type:"button",variant:"primary",size:"compact",disabled:J||!a.trim()||!P||S!=="current"&&!d.trim(),onClick:()=>{X(!0),fzr({task:a.trim(),harness:P,isolation:S,...S!=="current"?{branch:d.trim(),from:"HEAD"}:{}}).then(r).catch(ee=>i(ee instanceof Error?ee.message:String(ee))).finally(()=>X(!1))},children:J?"Delegating…":"Delegate"})]})}function MEn(t){return t.replace(/[\\/]$/,"").split(/[\\/]/).at(-1)??t}function LEn(t){const r=t.current?["Current worktree"]:[MEn(t.root)];t.sessions.length>0&&r.push("editor running"),t.dirty?r.push("uncommitted changes"):r.push("clean"),t.ahead&&r.push(`${t.ahead} ahead`),t.behind&&r.push(`${t.behind} behind`);const i=mKe(t);if(i.length===1){const a=i[0];r.push(a.kind==="agent"?`${a.displayName} ${a.status}${a.changeCount>0?` · ${a.changeCount} changes`:""}`:`${a.displayName} here`)}else i.length>1&&r.push(`${i.length} collaborators here`);return r.join(" · ")}function mKe(t){const r=new Map;for(const i of t.sessions)for(const a of i.presence?.participants??[]){const l=r.get(a.participantId);(!l||Date.parse(l.lastSeenAt)<Date.parse(a.lastSeenAt))&&r.set(a.participantId,a)}return[...r.values()].sort((i,a)=>{const l={"needs-input":0,active:1,idle:2,done:3};return l[i.status]-l[a.status]||i.displayName.localeCompare(a.displayName)})}function jEn(t){return t.kind==="agent"?"AI":t.displayName.split(/\s+/).slice(0,2).map(r=>r[0]?.toLocaleUpperCase()??"").join("")}function qTt({worktree:t}){const r=mKe(t);if(r.length===0)return null;const i=r.slice(0,3);return z.jsxs("span",{className:"vgai-worktree-presence",role:"img","aria-label":r.map(a=>`${a.displayName}, ${a.status}`).join("; "),children:[i.map(a=>z.jsx("span",{className:"vgai-worktree-avatar","data-kind":a.kind,"data-status":a.status,style:{"--vgai-participant-color":a.color},title:`${a.displayName} · ${a.kind} · ${a.status}`,"aria-hidden":"true",children:jEn(a)},a.participantId)),r.length>i.length&&z.jsxs("span",{className:"vgai-worktree-avatar vgai-worktree-avatar-more","aria-hidden":"true",children:["+",r.length-i.length]})]})}const BEn={healthy:"ready",starting:"starting",unhealthy:"running, editor not responding",stopped:"stopped","docker-unavailable":"unknown — Docker not reachable"};function $En(t){const r=BEn[t.health]??t.health,i=`${t.limits.cpus} CPU · ${t.limits.memory} RAM · ${t.limits.workspace} workspace`;return`${r} · ${i} · allowlisted egress${t.exportedAt?" · exported":" · not exported"}`}function c9e(t,...r){const i=t.trim().toLocaleLowerCase();return!i||r.some(a=>a?.toLocaleLowerCase().includes(i))}function zTt(t,r){return[+!t.current,Math.min(...mKe(t).map(i=>i.status==="needs-input"?0:i.status==="active"?1:i.status==="idle"?2:3)),+(t.branch===null),+(t.sessions.length===0),+!t.dirty,-(t.branch?r.get(t.branch)??0:0)]}function qEn(t){return(r,i)=>{const a=zTt(r,t),l=zTt(i,t);return a.reduce((_,g,b)=>_||g-(l[b]??0),0)||(r.branch??r.root).localeCompare(i.branch??i.root)}}function zEn(){const[t,r]=Xe.useState(OEn),[i,a]=Xe.useState({branch:null,worktreeId:null}),[l,d]=Xe.useState(!1),[_,g]=Xe.useState(null),[b,S]=Xe.useState(null),k=Xe.useCallback(async(N=!1)=>{N||d(!0);try{r(await lzr()),S(null)}catch(P){S(P instanceof Error?P.message:String(P))}finally{N||d(!1)}},[]);return Xe.useEffect(()=>{if(pze)return;let N=!0;return czr().then(P=>{N&&a(P)}).catch(()=>{}),()=>{N=!1}},[]),{state:t,sessionIdentity:i,loading:l,busy:_,error:b,setError:S,refresh:k,run:async(N,P,j)=>{g(N),S(null);try{await P(),j()}catch(J){S(J instanceof Error?J.message:String(J))}finally{g(null)}}}}function UEn(){const t=Xe.useRef(null),[r,i]=Xe.useState(!1),[a,l]=Xe.useState(""),[d,_]=Xe.useState(!1),[g,b]=Xe.useState(null),{state:S,sessionIdentity:k,loading:w,busy:N,error:P,setError:j,refresh:J,run:X}=zEn();if(Xe.useEffect(()=>{r&&J()},[r,J]),pze)return null;const G=S.worktrees.find(Le=>Le.current),ee=G?.branch??k.branch??(S.worktrees.length>0||k.worktreeId?"detached":"Branches"),xe=ee!=="Branches",ue=new Map(S.branches.map(Le=>[Le.name,Le.updatedAt])),se=[...S.worktrees].sort(qEn(ue)).filter(Le=>c9e(a,Le.branch,Le.root)),de=S.branches.filter(Le=>!Le.worktreeId&&c9e(a,Le.name)),ge=S.isolatedWorktrees.filter(Le=>c9e(a,Le.branch,Le.id)),qe=se.slice(0,a.trim()?30:10),tt=de.slice(0,a.trim()?50:20),Ct=se.length-qe.length,Ot=de.length-tt.length,vt=a.trim(),Et=S.branches.some(Le=>Le.name===vt),Tt=se.length>0||de.length>0||ge.length>0;return z.jsxs("div",{className:"vgai-worktree-switcher",children:[z.jsxs(kze,{ref:t,className:"vgai-worktree-trigger","aria-label":xe?`Branches and worktrees, current branch ${ee}${G?.dirty?", uncommitted changes":""}`:"Branches and worktrees","aria-expanded":r,title:xe?`Branches and worktrees — ${ee}${G?.dirty?" (uncommitted changes)":""}`:"Branches and worktrees",onClick:()=>{i(Le=>!Le),r||l("")},onKeyDown:Le=>{Le.key==="ArrowDown"&&(Le.preventDefault(),i(!0))},children:[z.jsx(So,{icon:MIr}),G?.dirty&&z.jsx("span",{className:"vgai-worktree-dirty-dot","aria-hidden":"true"}),G&&z.jsx(qTt,{worktree:G})]}),r&&z.jsxs(JR,{anchorRef:t,align:"start",clamp:!0,autoFocusFirst:!1,className:"vgai-worktree-menu","aria-label":"Branches and worktrees",onDismiss:()=>i(!1),children:[z.jsxs("div",{className:"vgai-worktree-search",children:[z.jsx(k_,{autoFocus:!0,"aria-label":"Find a branch",placeholder:"Find a branch…",value:a,disabled:N!==null||w,onChange:Le=>l(Le.target.value)}),z.jsx(fo,{variant:"ghost",size:"compact","aria-label":"Refresh branches and worktrees",title:"Refresh",disabled:N!==null,onClick:()=>void X("refresh",J,()=>{}),children:z.jsx(So,{icon:Mkt})})]}),z.jsx(Ny,{}),z.jsxs("div",{className:"vgai-worktree-results",children:[w&&S.worktrees.length===0&&z.jsx(Ru,{as:"div",variant:"caption",tone:"dim",className:"vgai-worktree-empty",children:"Loading branches…"}),ge.length>0&&z.jsxs("section",{"aria-label":"Isolated worktrees",children:[z.jsx(Ru,{as:"div",variant:"caption",tone:"dim",className:"vgai-worktree-section-label",children:"Isolated"}),ge.map(Le=>z.jsxs("div",{className:"vgai-worktree-row-shell",children:[z.jsxs(Wa,{className:"vgai-worktree-menu-item",disabled:Le.health!=="healthy"||N!==null,title:`Open isolated editor on port ${Le.editorPort}. Egress: ${Le.egressHosts.join(", ")}`,onSelect:()=>{window.open(`http://127.0.0.1:${Le.editorPort}/`,"_blank","noopener,noreferrer")},children:[z.jsx("span",{className:"vgai-worktree-row-icon",children:z.jsx(So,{icon:bDr})}),z.jsxs("span",{className:"vgai-worktree-row-copy",children:[z.jsx("span",{className:"vgai-worktree-row-title",children:Le.branch}),z.jsx("span",{className:"vgai-worktree-row-detail",children:$En(Le)})]})]}),z.jsx(fo,{type:"button",size:"compact",variant:"ghost","aria-label":`Copy agent attach command for ${Le.branch}`,title:"Copy agent attach command",disabled:N!==null,onClick:()=>{navigator.clipboard?.writeText(`vgai isolate agent ${Le.id} codex`),b("Attach command copied. Authentication stays inside the container.")},children:z.jsx(So,{icon:XIr})}),z.jsx(fo,{type:"button",size:"compact",variant:"ghost","aria-label":`Show logs for ${Le.branch}`,title:"Show startup logs",disabled:N!==null,onClick:()=>{dzr(Le.id).then(cr=>b(cr||"No container logs yet.")).catch(cr=>j(cr instanceof Error?cr.message:String(cr)))},children:z.jsx(So,{icon:sIt})}),z.jsx(fo,{type:"button",size:"compact",variant:"ghost","aria-label":`Export ${Le.branch}`,title:"Export committed branch before teardown",disabled:N!==null,onClick:()=>void X(`export:${Le.id}`,()=>pzr(Le.id),()=>{b("Isolated branch exported as a Git bundle."),J(!0)}),children:z.jsx(So,{icon:kDr})}),z.jsx(fo,{type:"button",size:"compact",variant:"ghost","aria-label":`Stop ${Le.branch}`,title:"Stop after a current export",disabled:N!==null,onClick:()=>void X(`stop-isolated:${Le.id}`,()=>Q2t(Le.id,!1),()=>i(!1)),children:z.jsx(So,{icon:w9e})}),z.jsx(fo,{type:"button",size:"compact",variant:"ghost","aria-label":`Discard ${Le.branch}`,title:"Discard container and all unexported work",disabled:N!==null,onClick:()=>{window.confirm(`Discard ${Le.branch}? Unexported commits and files cannot be recovered.`)&&X(`discard-isolated:${Le.id}`,()=>Q2t(Le.id,!0),()=>i(!1))},children:z.jsx(So,{icon:Bkt})})]},Le.id))]}),qe.length>0&&z.jsxs("section",{"aria-label":"Worktrees",children:[z.jsx(Ru,{as:"div",variant:"caption",tone:"dim",className:"vgai-worktree-section-label",children:"Worktrees"}),qe.map(Le=>{const cr=Le.branch??"Detached HEAD";return z.jsxs("div",{className:"vgai-worktree-row-shell",children:[z.jsxs(Wa,{className:"vgai-worktree-menu-item","data-current":Le.current||void 0,disabled:Le.current||!Le.project||N!==null,"aria-current":Le.current?"true":void 0,title:Le.root,onSelect:()=>void X(Le.worktreeId,()=>uzr(Le.worktreeId),()=>i(!1)),children:[z.jsx("span",{className:"vgai-worktree-row-icon",children:Le.current&&z.jsx(So,{icon:S8})}),z.jsxs("span",{className:"vgai-worktree-row-copy",children:[z.jsxs("span",{className:"vgai-worktree-row-title",children:[cr,Le.dirty&&z.jsx("span",{className:"vgai-worktree-dirty-dot","aria-hidden":"true"})]}),z.jsx("span",{className:"vgai-worktree-row-detail",children:N===Le.worktreeId?"Opening…":LEn(Le)})]}),z.jsx(qTt,{worktree:Le})]}),!Le.current&&Le.sessions[0]?.sessionId&&z.jsx(fo,{type:"button",size:"compact",variant:"ghost","aria-label":`Stop editor for ${cr}`,title:"Stop editor session",disabled:N!==null,onClick:()=>void X(`stop:${Le.worktreeId}`,()=>mzr(Le.worktreeId,Le.sessions[0].sessionId),()=>i(!1)),children:z.jsx(So,{icon:w9e})}),!Le.current&&Le.sessions.length===0&&!Le.dirty&&z.jsx(fo,{type:"button",size:"compact",variant:"ghost","aria-label":`Archive worktree ${cr}`,title:"Archive clean worktree",disabled:N!==null,onClick:()=>void X(`archive:${Le.worktreeId}`,()=>_zr(Le.worktreeId),()=>i(!1)),children:z.jsx(So,{icon:uIt})})]},Le.worktreeId)}),Ct>0&&z.jsxs(Ru,{as:"div",variant:"caption",tone:"dim",className:"vgai-worktree-more",children:[Ct," more worktrees — search to narrow"]})]}),tt.length>0&&z.jsxs("section",{"aria-label":"Local branches",children:[z.jsx(Ru,{as:"div",variant:"caption",tone:"dim",className:"vgai-worktree-section-label",children:"Local branches"}),tt.map(Le=>z.jsxs(Wa,{className:"vgai-worktree-menu-item",disabled:N!==null,onSelect:()=>void X(Le.name,()=>G2t(Le.name),()=>i(!1)),children:[z.jsx("span",{className:"vgai-worktree-row-icon"}),z.jsxs("span",{className:"vgai-worktree-row-copy",children:[z.jsx("span",{className:"vgai-worktree-row-title",children:Le.name}),z.jsx("span",{className:"vgai-worktree-row-detail",children:N===Le.name?"Creating worktree…":"Open in a new worktree"})]})]},Le.name)),Ot>0&&z.jsxs(Ru,{as:"div",variant:"caption",tone:"dim",className:"vgai-worktree-more",children:[Ot," more ",vt?"matches":"branches"," — search to narrow"]})]}),!w&&!Tt&&!vt&&z.jsx(Ru,{as:"div",variant:"caption",tone:"dim",className:"vgai-worktree-empty",children:"No branches found."})]}),vt&&!Et&&!w&&z.jsxs(z.Fragment,{children:[z.jsx(Ny,{}),z.jsxs(Wa,{className:"vgai-worktree-create-command",disabled:N!==null,onSelect:()=>void X("create",()=>G2t(vt),()=>i(!1)),children:[z.jsx("span",{className:"vgai-worktree-row-icon",children:"+"}),z.jsxs("span",{className:"vgai-worktree-row-copy",children:[z.jsxs("span",{className:"vgai-worktree-row-title",children:["Create branch “",vt,"”"]}),z.jsx("span",{className:"vgai-worktree-row-detail",children:N==="create"?"Creating worktree…":`From ${ee}, in a new worktree`})]})]})]}),!vt&&z.jsxs(z.Fragment,{children:[z.jsx(Ny,{}),d?z.jsx(REn,{currentLabel:ee,onDone:Le=>{if(Le.isolation==="container"){const cr=typeof Le.command=="string"?Le.command:null,Yt=typeof Le.task=="string"?Le.task:null;b([typeof Le.message=="string"?Le.message:null,cr?`Attach: ${cr}`:null,Yt?`Task: ${Yt}`:null].filter(Boolean).join(`
|
|
1685
1685
|
`)),_(!1),J(!0);return}_(!1),i(!1),J(!0)},onError:j}):z.jsx(fo,{type:"button",variant:"ghost",size:"compact",className:"vgai-worktree-delegate-open",onClick:()=>_(!0),children:"Delegate to agent…"}),z.jsx(Ny,{}),z.jsx(NEn,{})]}),P&&z.jsx(Ru,{as:"div",variant:"caption",tone:"danger",role:"alert",className:"vgai-worktree-error",children:P}),g&&z.jsx(Ru,{as:"div",variant:"caption",role:"status",className:"vgai-worktree-notice",children:g})]})]})}function VEn({transport:t}){const[,r]=Xe.useReducer(w=>w+1,0);Xe.useEffect(()=>Iw(r),[]);const[i,a]=Xe.useState(!1),l=Xe.useRef(null),d=ad(),_=d?.config.name??"No Project",g=d?.config.version??null,b=d?.config.engine.version??null,S=d?.config.manifestVersion??null,k=d?.rootPath??"";return Xe.useEffect(()=>{if(!i)return;const w=N=>{l.current&&!l.current.contains(N.target)&&a(!1)};return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[i]),z.jsxs("header",{className:"vgai-project-header",children:[qye()?.nativeMenus?z.jsx("div",{className:"vgai-project-header-left"}):z.jsxs("div",{ref:l,className:"vgai-project-header-left",children:[z.jsxs("div",{className:"vgai-project-header-cluster vgai-chrome-island vgai-glass-island",children:[z.jsxs(kze,{"data-testid":"project-menu-trigger","aria-label":`${_} project menu`,title:k?`${_} — ${k}`:_,onClick:()=>a(w=>!w),onKeyDown:w=>{w.key==="ArrowDown"&&(w.preventDefault(),a(!0))},className:"vgai-project-trigger",children:[z.jsx(So,{icon:yb.content.project}),z.jsx(Ru,{"data-testid":"project-name","data-project":_,"data-project-version":g??void 0,variant:"label",className:"vgai-sr-only",children:_})]}),z.jsx(UEn,{}),z.jsx(Nq,{onPointerDown:()=>a(!1),className:"vgai-project-app-menus",children:z.jsx(pEn,{})})]}),z.jsx(JEn,{}),i&&z.jsxs(OP,{autoFocusFirst:!0,onDismiss:()=>{const w=l.current?.querySelector('[data-testid="project-menu-trigger"]');a(!1),requestAnimationFrame(()=>w?.focus())},className:"vgai-project-menu",children:[z.jsx(Ru,{"data-testid":"project-menu-name",title:_,variant:"label",truncate:!0,className:"vgai-project-menu-name",children:_}),k&&z.jsx(Ru,{"data-testid":"project-menu-path",title:k,variant:"caption",tone:"dim",selectable:!0,truncate:!0,className:"vgai-project-path",children:k}),g&&b&&S!==null&&z.jsxs(z.Fragment,{children:[k&&z.jsx(Ny,{}),z.jsxs("div",{"data-testid":"project-version-summary",className:"vgai-project-versions",children:[z.jsx("span",{children:"Editor"}),z.jsxs(Ru,{variant:"code",tone:"muted",children:["v",MQt]}),z.jsx("span",{children:"Project"}),z.jsxs(Ru,{variant:"code",tone:"muted",children:["v",g]}),z.jsx("span",{children:"Engine"}),z.jsxs(Ru,{variant:"code",tone:"muted",children:["v",b]}),z.jsx("span",{children:"Format"}),z.jsxs(Ru,{variant:"code",tone:"muted",children:["v",S]})]}),z.jsx(Ny,{})]}),k&&z.jsx(Wa,{onSelect:()=>{a(!1),ALe(k)},children:"Show in Finder"}),z.jsx(Wa,{"data-testid":"project-menu-history",onSelect:()=>{a(!1),window.dispatchEvent(new CustomEvent("editor:show-history-tab"))},children:"Undo History…"})]})]}),z.jsx(Nq,{"data-testid":"header-transport",className:"vgai-project-transport vgai-chrome-island vgai-glass-island",align:"center",children:t??z.jsx(WEn,{})}),z.jsx(Nq,{className:"vgai-project-header-right",justify:"end",align:"center",children:z.jsx(Zme,{slot:"header-trailing"})})]})}function JEn(){Xe.useSyncExternalStore(kee,khe,khe),Xe.useSyncExternalStore(mPt,Phe,Phe);const t=Xe.useSyncExternalStore(yPt,wS,wS);if(wP().workspaceTabs!=="shown")return null;const r=X8().filter(i=>CP(i.id));return z.jsxs(z.Fragment,{children:[z.jsx(T5r,{orientation:"vertical",className:"vgai-project-menu-rule"}),z.jsx("div",{role:"tablist","aria-label":"Workspaces","data-testid":"workspace-tabs",className:"vgai-workspace-tabs",children:r.map(i=>z.jsx("button",{type:"button",role:"tab","aria-selected":i.id===t,title:i.description,className:"vgai-workspace-tab",onClick:()=>CS(i.id),children:i.title},i.id))})]})}function WEn(){Xe.useSyncExternalStore(Uye,w8,w8);const t=vIt();return t.length===0?null:z.jsx(z.Fragment,{children:t.map(({id:r,Component:i})=>z.jsx(i,{documentId:""},r))})}function HEn({utility:t,testId:r}){const i=t.Content;return z.jsx("div",{className:"vgai-dock-panel vgai-regular-panel-portal","data-testid":r??`bottom-panel-utility-${t.id}`,"data-editor-hotkey-scope":"workspace","data-vgai-noselect":"true",children:z.jsx(i,{})})}function GEn(t,r){return window.confirm(r)}const QEn=4,KEn=4,YEn=24,XEn=4,ZEn=3,eTn=new Set(["model","image"]),tTn=new Set(["glb","gltf","fbx","obj","dae","stl","ply","spz","bvh","3ds"]);function rTn(t){const r=t.lastIndexOf(".");return r>0&&tTn.has(t.slice(r+1).toLowerCase())}const nTn=new Set(["audio","video","prefab","json"]);function cKt(t){let r=0;const i=[];return async a=>{r>=t&&await new Promise(l=>i.push(l)),r++;try{return await a()}finally{r--,i.shift()?.()}}}function hKe(t){return t.replace(/^(?:\.\/|\/)+/,"").replace(/\/+$/,"")}function iTn(t,r){const i=t?r.slice(t.length+1):r;return i.split("/",1)[0]??i}function UTt(t,r){return t.tier-r.tier||t.depth-r.depth||t.seq-r.seq}function sTn(t,r,i,a){for(const l of t){if(r.length>=a)break;i.has(l.subtree)||(i.add(l.subtree),r.push(l))}for(const l of t){if(r.length>=a)break;r.includes(l)||r.push(l)}}function oTn(t,r){const i=[...t].sort(UTt),a=[],l=new Set;for(const d of[1,2]){const _=i.filter(g=>g.tier===d);sTn(_,a,l,r)}return a.sort(UTt),a.map(({path:d,name:_,kind:g})=>({path:d,name:_,kind:g}))}function aTn(t){return eTn.has(t)?1:nTn.has(t)?2:0}function cTn(t,r,i,a){for(const l of i){if(l.name.startsWith("."))continue;const d=r.dir?`${r.dir}/${l.name}`:l.name;if(l.type==="directory"){r.depth+1>t.maxDepth?t.truncated=!0:a.push({dir:d,depth:r.depth+1});continue}t.totalAssets++;const _=rTn(l.name)?"model":wg(l.name).kind,g=aTn(_);g!==0&&t.candidates.push({path:d,name:l.name,kind:_,tier:g,depth:r.depth,seq:t.seq++,subtree:iTn(t.base,d)})}}async function lTn(t,r,i={}){const a=i.listAssets??J0e,l=i.maxItems??QEn,d=i.maxListings??YEn,_=cKt(i.listConcurrency??XEn),g=hKe(r),b={base:g,maxDepth:i.maxDepth??KEn,candidates:[],totalAssets:0,truncated:!1,failedListings:0,seq:0};let S=0,k=[{dir:g,depth:0}];for(;k.length>0;){const w=Math.max(0,d-S),N=k.slice(0,w);N.length<k.length&&(b.truncated=!0),S+=N.length;const P=await Promise.all(N.map(J=>_(()=>a(t,J.dir)))),j=[];for(const[J,X]of N.entries()){const G=P[J];if(!G||!G.ok){b.failedListings+=1;continue}cTn(b,X,G.entries,j)}k=j}return{items:oTn(b.candidates,l),totalAssets:b.totalAssets,scannedAll:!b.truncated&&b.failedListings===0,failedListings:b.failedListings}}const lKt="\0",wR=new Map,uTn=cKt(ZEn);function fTn(t,r,i){const a=`${t}${lKt}${hKe(r)}`,l=wR.get(a);if(l)return l;const d=uTn(()=>lTn(t,r,i));wR.set(a,d);const _=()=>{wR.get(a)===d&&wR.delete(a)};return d.then(g=>{(g.failedListings>0||g.items.length===0&&g.totalAssets===0)&&_()},_),d}function dTn(t,r){return t===r||t===""||r===""||t.startsWith(`${r}/`)||r.startsWith(`${t}/`)}function VTt(t){if(t===void 0){wR.clear();return}const r=hKe(t);for(const i of[...wR.keys()]){const a=i.slice(i.indexOf(lKt)+1);dTn(a,r)&&wR.delete(i)}}function Oqe(t,r="$"){return typeof t=="string"?[{path:r,value:t}]:Array.isArray(t)?t.flatMap((i,a)=>Oqe(i,`${r}[${a}]`)):!t||typeof t!="object"?[]:Object.entries(t).flatMap(([i,a])=>Oqe(a,`${r}.${i}`))}function pTn(t,r){if(!r||!t.toLowerCase().endsWith(".gltf"))return[];try{const i=JSON.parse(r),a=t.includes("/")?t.slice(0,t.lastIndexOf("/")+1):"";return[...i.buffers??[],...i.images??[]].flatMap(l=>l.uri&&!l.uri.startsWith("data:")?[`${a}${l.uri}`]:[])}catch{return[]}}function _Tn(t){const r=new Map(t.files.map(S=>[S.path.replace(/^\//,""),S])),i=t.assetPath.replace(/^\//,""),a=r.get(i),l=new Set,d=wg(i);if(a||l.add("missing-file"),d.importable?d.runtimeReady||l.add("source-only"):l.add("unsupported-format"),a?.text&&d.kind==="json")try{JSON.parse(a.text)}catch{l.add("invalid-metadata")}const _=pTn(i,a?.text);_.some(S=>!r.has(S))&&l.add("missing-dependency");const g=[];for(const S of t.files)if(!(!S.text||!/\.json$/i.test(S.path)))try{for(const k of Oqe(JSON.parse(S.text))){const w=k.value.replace(/^\//,"");w===i?g.push({ownerPath:S.path,jsonPath:k.path,assetPath:i}):w.startsWith("assets/")&&!r.has(w)&&l.add("broken-asset-reference")}}catch{}l.size===0&&l.add("healthy");const b=new Set(["missing-file","missing-dependency","invalid-metadata","broken-asset-reference"]);return{health:{status:[...l].some(S=>b.has(S))?"error":l.has("healthy")?"healthy":"warning",codes:[...l]},dependencies:_,references:g}}async function uKt(t,r=""){const i=await t.list(r),a=[];for(const l of i){const d=r?`${r}/${l.name}`:l.name;l.type==="dir"?a.push(...await uKt(t,d)):/\.json$|\.gltf$/i.test(d)?a.push({path:d,text:await t.read(d)}):a.push({path:d})}return a}async function mTn(t,r){return _Tn({assetPath:r,files:await uKt(t)})}function N_e(t){typeof window>"u"||(window.dispatchEvent(new CustomEvent("editor:asset-mutation",{detail:t})),window.dispatchEvent(new CustomEvent("editor:assets-changed")))}function K3(t){const r=t.replace(/^\/+/,"").replace(/\\/g,"/").replace(/\/{2,}/g,"/");if(!r||r==="."||r.split("/").some(i=>!i||i===".."))throw new Error(`Invalid project asset path: ${t}`);return r}async function l9e(t,r){for(const i of r)if(await t.exists(i))throw new Error(`An asset already exists at ${i}.`)}async function hTn(t,r){const i=CUe(r.history,r.backend);switch(t.type){case"create-folder":{const a=K3(t.path),l=`${a}/.vgai-folder`;if(await r.backend.exists(a))throw new Error(`Folder already exists: ${a}.`);return i.write(l,"",{label:`Create folder ${a}`})}case"duplicate":{const a=K3(t.source),l=K3(t.destination);await l9e(r.backend,[l]);const d=await r.backend.readBytes(a);return i.write(l,d,{label:`Duplicate ${a}`})}case"move":{const a=K3(t.source),l=K3(t.destination);await l9e(r.backend,[l]);const d=await r.backend.readBytes(a),_=new Map([[l,d],[a,null]]),g=await i.mutate([..._].map(([b,S])=>({path:b,data:S})),{label:`Move ${a}`});return g&&N_e({type:"move",oldPath:a,newPath:l}),g}case"move-many":{const a=t.moves.map(S=>({source:K3(S.source),destination:K3(S.destination)}));if(a.length===0)return!1;const l=new Set(a.map(S=>S.source)),d=a.map(S=>S.destination);if(new Set(d).size!==d.length)throw new Error("Batch move destinations must be unique.");for(const S of d)if(!l.has(S)&&await r.backend.exists(S))throw new Error(`An asset already exists at ${S}.`);const _=await Promise.all(a.map(async S=>({...S,bytes:await r.backend.readBytes(S.source)}))),g=new Map;for(const{destination:S,bytes:k}of _)g.set(S,k);for(const{source:S}of _)d.includes(S)||g.set(S,null);const b=await i.mutate([...g].map(([S,k])=>({path:S,data:k})),{label:`Move ${a.length} assets`});if(b)for(const S of a)N_e({type:"move",oldPath:S.source,newPath:S.destination});return b}case"delete":{const a=[...new Set(t.paths.map(K3))],l=await i.mutate(a.map(d=>({path:d,data:null})),{label:`Delete ${a.length} asset${a.length===1?"":"s"}`});return l&&N_e({type:"delete",paths:a}),l}case"import":{const a=t.files.map(d=>({path:K3(d.path),data:d.bytes}));await l9e(r.backend,a.map(d=>d.path));const l=await i.mutate(a,{label:`Import ${a.length} asset${a.length===1?"":"s"}`});return l&&N_e({type:"change",paths:a.map(d=>d.path)}),l}}}const gTn=320,yTn=180,vTn="document-preview-v4",hX=new Map,bTn=new N4t(async t=>{const r=hX.get(t);if(await new Promise(i=>{typeof requestIdleCallback=="function"?requestIdleCallback(()=>i(),{timeout:1e3}):setTimeout(i,0)}),[...r.consumers].every(i=>i.aborted))throw new DOMException("Preview demand was cancelled.","AbortError");return r.run()},1);let sZ=null,JTt,u9e=null;const RY=new Set;async function fKt(t){const r=_z();let i;try{i=await r.list(t)}catch{return[]}const a=[];for(const l of i)l.type==="dir"?a.push(...await fKt(l.path)):a.push(`${l.path}:${l.size??0}:${l.mtime??0}`);return a}async function ATn(){const t=ad()?.rootPath;return JTt!==t&&(JTt=t,sZ=null),sZ??=Promise.all([SNt([YUe,"vgai.adapter.ts",".storybook/**/*","src/**/*.ts","src/**/*.tsx","src/**/*.js","src/**/*.jsx","src/**/*.mjs","src/**/*.cjs","src/**/*.json","src/**/*.css"]).then(async r=>Promise.all(r.map(async i=>`${i}:${await ige(i)??""}`))),fKt("")]).then(([r,i])=>dKt([...r,...i].sort().join(`
|
|
1686
1686
|
`))),sZ}function STn(t){return RY.add(t),u9e??=Qg.watch(r=>{if(r.path===Lq){P4t();for(const i of RY)i();return}if(!(!/^(src|public|\.storybook)\//.test(r.path)&&r.path!==YUe&&r.path!=="vgai.adapter.ts")){sZ=null;for(const i of RY)i()}}),()=>{RY.delete(t),RY.size===0&&(u9e?.(),u9e=null,sZ=null)}}async function xTn(t,r,i){r.throwIfAborted();let a=hX.get(t);a||(a={run:i,consumers:new Set},hX.set(t,a)),a.consumers.add(r);const l=bTn.request(t,1);r.addEventListener("abort",l.cancel,{once:!0});try{return await l.promise}finally{r.removeEventListener("abort",l.cancel),a.consumers.delete(r),a.consumers.size===0&&hX.get(t)===a&&hX.delete(t)}}async function dKt(t){const r=new TextEncoder().encode(t),i=await crypto.subtle.digest("SHA-256",r);return[...new Uint8Array(i)].map(a=>a.toString(16).padStart(2,"0")).join("")}function wTn(t){const r=/^data:([^;,]+);base64,(.*)$/s.exec(t);if(!r)throw new Error("Document preview owner returned an invalid image data URL.");const i=atob(r[2]),a=new Uint8Array(i.length);for(let l=0;l<i.length;l++)a[l]=i.charCodeAt(l);return{mime:r[1],bytes:a}}function WTt(t,r="image/png"){const i=new Uint8Array(t.byteLength);return i.set(t),URL.createObjectURL(new Blob([i.buffer],{type:r}))}async function CTn(t){const r=await wUe();if(r.status!=="ok")return;const i=r.manifest.entries[`document:${t}`]?.framing;return i?{position:{x:i.position[0],y:i.position[1],z:i.position[2]},target:{x:i.target[0],y:i.target[1],z:i.target[2]},...i.fov===void 0?{}:{fov:i.fov}}:void 0}async function ETn(t,r,i,a){const l=ad()?.rootPath??"no-project",d=await CTn(t),_=JSON.stringify({projectId:l,documentId:t,recipe:vTn,revision:r.revision(),dependencies:await ATn(),camera:d});a.throwIfAborted();const g=await dKt(_),b=`.vgai/cache/document-previews/${g}.png`;if(i===0&&await Qg.exists(b))return WTt(await Qg.readBytes(b));const S=await xTn(g,a,()=>r.capture({width:gTn,height:yTn,...d?{camera:d}:{}}));a.throwIfAborted();const k=wTn(S);return await Qg.write(b,k.bytes),WTt(k.bytes,k.mime)}function TTn({documentId:t,source:r,previewRevision:i}){const[a,l]=Xe.useState(null),[d,_]=Xe.useState(null),[g,b]=Xe.useState(0),[S,k]=Xe.useState(0),[w,N]=Xe.useState(!0),[P,j]=Xe.useState(!1),J=Xe.useRef(null),X=Xe.useRef(null),G=Xe.useRef(null),ee=Xe.useRef({previewRevision:i,retry:S});return Xe.useEffect(()=>{let xe=null;const ue=()=>{X.current?.abort(),N(!0),xe&&clearTimeout(xe),xe=setTimeout(()=>b(de=>de+1),750)},fe=r.subscribe(ue),se=STn(ue);return()=>{xe&&clearTimeout(xe),fe(),se()}},[r]),Xe.useEffect(()=>()=>{G.current?.startsWith("blob:")&&URL.revokeObjectURL(G.current)},[]),Xe.useEffect(()=>{const xe=J.current;if(!xe)return;const ue=new IntersectionObserver(([fe])=>j(fe?.isIntersecting??!1));return ue.observe(xe),()=>ue.disconnect()},[]),Xe.useEffect(()=>{if(!P)return;const xe=new AbortController;X.current=xe;const ue=ee.current.previewRevision!==i||ee.current.retry!==S?1:0;return _(null),N(!0),ETn(t,r,ue,xe.signal).then(fe=>{if(xe.signal.aborted){URL.revokeObjectURL(fe);return}G.current&&URL.revokeObjectURL(G.current),ee.current={previewRevision:i,retry:S},G.current=fe,l(fe),N(!1)}).catch(fe=>{xe.signal.aborted||(_(fe instanceof Error?fe.message:String(fe)),N(!1))}),()=>xe.abort()},[t,i,S,r,g,P]),z.jsxs("div",{ref:J,style:{width:"100%",height:"100%",position:"relative",display:"grid",placeItems:"center"},children:[a&&z.jsx("img",{src:a,alt:`${t} preview`,style:{width:"100%",height:"100%",objectFit:"contain"}}),d?z.jsx("button",{type:"button",title:d,onClick:xe=>{xe.stopPropagation(),k(ue=>ue+1)},style:{position:"absolute",bottom:0,border:0,background:"var(--vscode-editor-background)",color:od[3],pointerEvents:"auto"},children:"Preview unavailable · Retry"}):w?z.jsx("span",{role:"status",style:{position:"absolute",bottom:0,background:"var(--vscode-editor-background)",color:od[3],fontSize:zY.xs},children:a?"Refreshing preview…":"Loading preview…"}):null]})}function pKt(t,r){return H0e(t,r.path)}function kTn({root:t,item:r}){const[i,a]=Xe.useState(!1);return i?z.jsx(DP,{kind:"image",size:14}):z.jsx("img",{src:pKt(t,r),alt:r.name,loading:"lazy",onError:()=>a(!0)})}function ITn({root:t,item:r}){const i=dGt(pKt(t,r),Cvn);return i.failed?z.jsx(DP,{kind:"model",size:14}):i.src?z.jsx("img",{src:i.src,alt:r.name,"data-fit":"contain",onError:i.fromManifest?i.rejectManifest:void 0}):null}function DTn({root:t,item:r}){return wg(r.name).editor==="environment"?z.jsx(a9,{kind:"image",name:r.name,variant:"cell"}):r.kind==="image"?z.jsx(kTn,{root:t,item:r}):r.kind==="model"?z.jsx(ITn,{root:t,item:r}):z.jsx(a9,{kind:r.kind,name:r.name,variant:"cell"})}function PTn({root:t,folderPath:r,revision:i}){const[a,l]=Xe.useState(null);if(Xe.useEffect(()=>{l(null)},[t,r]),Xe.useEffect(()=>{let _=!1;return fTn(t,r).then(g=>{_||l(g)},()=>{_||l("failed")}),()=>{_=!0}},[t,r,i]),a===null||a==="failed")return z.jsx(DP,{kind:"folder"});if(a.totalAssets===0)return z.jsx("div",{className:"vgai-folder-preview","data-testid":"folder-preview-empty","aria-hidden":"true",children:z.jsxs("div",{className:"vgai-folder-preview__empty",children:[z.jsx(So,{icon:qkt,className:"vgai-folder-preview__empty-glyph"}),z.jsx("span",{className:"vgai-folder-preview__empty-caption",children:"Empty"})]})});const d=a.scannedAll?`${a.totalAssets}`:`${a.totalAssets}+`;return a.items.length===0?z.jsxs("div",{className:"vgai-folder-preview","data-testid":"folder-preview-plain","aria-hidden":"true",children:[z.jsx("div",{className:"vgai-folder-preview__fallback",children:z.jsx(DP,{kind:"folder"})}),z.jsx("span",{className:"vgai-folder-preview__count",children:d})]}):z.jsxs("div",{className:"vgai-folder-preview","data-testid":"folder-preview","aria-hidden":"true",children:[z.jsx("div",{className:"vgai-folder-preview__grid","data-count":a.items.length,children:a.items.map(_=>z.jsx("div",{className:"vgai-folder-preview__cell",children:z.jsx(DTn,{root:t,item:_})},_.path))}),z.jsx("span",{className:"vgai-folder-preview__chip",children:z.jsx(So,{icon:gee})}),z.jsx("span",{className:"vgai-folder-preview__count",children:d})]})}function Fqe(t){return t.type==="directory"?"folder":wg(t.name).kind}function NTn(t,r,i){return H0e(t,r?`${r}/${i}`:i)}function OTn(t,r,i){return r?`/${r}/${i}`:`/${i}`}function FTn(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function Rqe(t){const r=wg(t);return r.importable?r.runtimeReady?"healthy":"source-only":"unsupported"}const RTn=640,HTt={scope:"content",root:"public",currentPath:"",viewMode:"grid",sort:"relevance",filter:"all",density:96,expanded:["public"],treeVisibility:"auto",facets:["component"]};function MTn(){try{const t=ad()?.rootPath??"__unscoped__",r=JSON.parse(localStorage.getItem(nGt(t))??"{}"),i=r.viewMode,a=r.treeVisibility,l=r.scope,d=r.root;return{...HTt,...r,root:d===_I?_I:"public",currentPath:r.currentPath??"",scope:l==="files"?"files":"content",viewMode:l==="files"&&i==="list"?"list":"grid",treeVisibility:a==="shown"||a==="hidden"?a:"auto",facets:Array.isArray(r.facets)&&r.facets.length>0?[r.facets[0]]:["component"]}}catch{return HTt}}const LTn={listAssets:J0e,listProjectComponents:yNt},f9e="Reference material is not part of the built game — it stays in the project's references/ folder and is never exported. Copy the file into public/ to use it in the game; edit or remove it where it lives.",jTn=new Set(["component","scene","canvas","model","image","video","audio","other"]);function BTn(t){const r=t.charAt(0).toUpperCase()+t.slice(1);return r.endsWith("s")?r:`${r}s`}async function GTt(t,r){if(!r&&I_()!==t)throw new Error("Open this scene as the active document before using its current view.");const i=uee(t)?.cameraPose;if(!r&&!i)throw new Error("The active scene has no ready 3D authoring view to save.");await qGt().saveThumbnailFraming(`document:${t}`,r?void 0:{position:i.position.toArray(),target:i.target.toArray(),fov:i.fov})}function $Tn(t){return t.component.surface==="three"?"3d":t.component.surface==="canvas"?"2d":"ui"}function qTn(t){const r={"3d":"3D","2d":"2D",ui:"UI"};return["3d","2d","ui"].flatMap(i=>{const a=t.filter(l=>l.source==="component"&&$Tn(l)===i);return a.length>0?[{id:`prefabs-${i}`,label:r[i],headingLevel:"category",entries:a}]:[]})}function zTn(t,r,i){return r==="files"?[{id:"files",label:null,headingLevel:null,entries:[...t]}]:i.length===1&&i[0]==="component"?qTn(t):t.length>0?[{id:"content",label:null,headingLevel:null,entries:[...t]}]:[]}function _Kt(t){return t.source==="available"?t.available.category:t.source==="component"?t.component.contentKind??"component":t.source==="document"?t.document.kind:qQt(t.name)}function UTn(t){return t.source==="component"?t.component.contentKind??"component":t.source==="available"||t.source==="document"?"source":Fqe(t.entry)}function CR(t){const r=t.lastIndexOf("/");return r<0?"":t.slice(0,r)}function VTn(t,r){if(t.source==="component"||t.source==="document"||t.source==="available")return;const{entry:i}=t,{currentRoot:a,currentPath:l,navigate:d,openAsset:_}=r;if(i.type==="directory"){d(a,l?`${l}/${i.name}`:i.name);return}const g=wg(i.name),b=Bq(g);if(b){if(t.spritesheet){const S=t.path.includes("#")?t.path.slice(t.path.lastIndexOf("#")+1):i.name.replace(/\.png$/i,"");_(`/${t.spritesheet.sheetPath}#${S}`,b);return}_(NTn(t.root,l,i.name),b)}}function mKt(t){return t.source==="component"?`Component · line ${t.component.line}`:t.source==="available"?t.path||t.available.descriptor.title:t.source==="document"?`${t.document.kind} · ${t.path}`:t.entry.type!=="file"?"Folder":t.entry.size===void 0?"Size unknown":FTn(t.entry.size)}function JTn(t){if(t.source==="component")return`${t.name}
|
|
@@ -1688,4 +1688,4 @@ ${t.path}:${t.component.line}`;if(t.source==="available")return`${t.name}
|
|
|
1688
1688
|
${t.path}`;if(t.source==="document")return`${t.name}
|
|
1689
1689
|
${t.path}`;const r=mKt(t);return r?`${t.name}
|
|
1690
1690
|
${r}`:t.name}function WTn(t,r,i){if(t.source==="component"||t.source==="document"||t.source==="available"||r==="all"||t.entry.type==="directory")return!0;const a=wg(t.name),l=i?`${i}/${t.name}`:t.name;return{"runtime-ready":a.runtimeReady,"source-only":a.importable&&!a.runtimeReady,unsupported:!a.importable,imported:l.startsWith("asset-library/local/"),generated:l.startsWith(".generated/")}[r]}function Xq(t,r){return t.name.localeCompare(r.name)||t.path.localeCompare(r.path)}function QTt(t){return t.source==="asset"?gwn({path:t.path,root:t.root,entry:t.entry}):t.source==="available"||t.source==="document"?10:ywn(t.component)-100}function HTn(t,r){const i=QTt(t),a=QTt(r);return i!==a?i-a:t.source!==r.source?t.source==="component"?-1:1:(t.source==="component"&&r.source==="component"||t.source!=="asset"||r.source!=="asset",Xq(t,r))}function KTt(t,r){return t===void 0?r===void 0?0:1:r===void 0?-1:r-t}function GTn(t,r,i){if(t.entry.type!==r.entry.type)return t.entry.type==="directory"?-1:1;if(i==="size"&&t.entry.size!==r.entry.size)return KTt(t.entry.size,r.entry.size);if(i==="modified"&&t.entry.modifiedAt!==r.entry.modifiedAt)return KTt(t.entry.modifiedAt,r.entry.modifiedAt);if(i==="type"){const a=Fqe(t.entry).localeCompare(Fqe(r.entry));if(a!==0)return a}if(i==="health"){const a=Rqe(t.name).localeCompare(Rqe(r.name));if(a!==0)return a}return Xq(t,r)}function QTn(t,r,i){return i==="relevance"?HTn(t,r):i==="name"?Xq(t,r):t.source!==r.source?t.source==="component"?-1:1:t.source!=="asset"||r.source!=="asset"?Xq(t,r):GTn(t,r,i)}function KTn(t,r){if(r.query&&!`${t.name} ${t.path}`.toLowerCase().includes(r.query))return!1;if(r.scope==="content"&&r.facets.length>0){const i=_Kt(t);return r.facets.includes(i)}return r.scope==="content"||WTn(t,r.filter,r.shownPath)}const YTn={width:"100%",minWidth:0,padding:0,textAlign:"center",display:"flex",flexDirection:"column",alignItems:"center",gap:3},XTn={width:"100%",minWidth:0,minHeight:28,padding:"3px 6px",textAlign:"left",display:"flex",flexDirection:"row",alignItems:"center",gap:7};function ZTn(t){const r=new Map;if(!t.assetSubject)return r;const i=t.assetSubject.entries?.()??H9r(t.hierarchy).flatMap(a=>{const l=t.assetSubject?.get(a.id);return l?[{id:a.id,subject:l}]:[]});for(const{id:a,subject:l}of i){const d=l.sourcePath?.replaceAll("\\","/").replace(/^\.\//,"")??"",_=d.lastIndexOf("/src/"),g=_>=0?d.slice(_+1):d;r.set(`${g}:${l.name}`,{id:a,subject:l})}return r}const ekn=()=>()=>{},tkn=()=>0;function rkn({sheetUrl:t,frame:r}){return z.jsx(mGt,{sheetUrl:t,frame:{name:"",x:r.x,y:r.y,width:r.width,height:r.height,rotated:r.rotated,sourceWidth:r.sourceWidth,sourceHeight:r.sourceHeight,trimX:r.trimX,trimY:r.trimY},maxEdge:48})}function nkn({item:t,kind:r,assetUrl:i,grid:a,folderPath:l,previewRevision:d}){const _=i;if(r==="folder")return a?z.jsx(PTn,{root:t.source==="asset"?t.root:"public",folderPath:l,revision:d}):z.jsx(DP,{kind:"folder",size:15});if(r==="audio"&&i)return z.jsx(Tvn,{url:_,name:t.name});if(!a)return z.jsx(DP,{kind:r,size:15});if(t.source==="available"&&t.available.descriptor.preview)return z.jsx(TTn,{documentId:t.available.descriptor.id,source:t.available.descriptor.preview,previewRevision:d});if(t.source==="component"){const{Thumbnail:g}=t.contentSource;return z.jsx(g,{entry:t.contentEntry,previewRevision:d})}return wg(t.name).editor==="environment"?z.jsx(a9,{kind:"image",name:t.name}):r==="image"?t.source==="asset"&&t.spritesheet?z.jsx(rkn,{sheetUrl:`/${t.spritesheet.sheetPath}`,frame:t.spritesheet}):z.jsx("img",{src:_,alt:t.name,style:{maxWidth:48,maxHeight:48,objectFit:"contain",borderRadius:dZ.sm}}):r==="video"&&_?z.jsx("video",{src:`${_}#t=0.1`,muted:!0,playsInline:!0,preload:"metadata",style:{maxWidth:48,maxHeight:48,objectFit:"contain",borderRadius:dZ.sm}}):r==="model"||$Qe(i)?z.jsx(pGt,{url:i}):["prefab","json"].includes(r)?z.jsx(a9,{kind:r,name:t.name}):z.jsx(DP,{kind:r})}function ikn({item:t,selected:r,onDragStart:i,onSelect:a,onOpen:l,onContextMenu:d,viewMode:_,previewRevision:g,showPath:b}){const S=UTn(t),k=t.source==="asset"?t.entry:null,w=k?.type==="file"?wg(k.name):null,N=t.source==="asset"?H0e(t.root,t.path):"",P=t.path,j=JTn(t),J=k?k.type==="directory"||w?.placeable?w?.placeable?"grab":"pointer":"default":"pointer",X=mKt(t),G=t.source==="component"?t.path:t.source==="asset"?oge(t.root,CR(t.path)).replace(/\/$/,""):CR(t.path)||"public",ee=b?`${G} · ${X}`:X,xe=_!=="list";return z.jsxs("div",{className:"vgai-selectable vgai-project-asset-entry","data-selected":r||void 0,"data-view":_,role:"option","aria-selected":r,tabIndex:0,draggable:t.source==="component"||t.source==="asset"&&k?.type==="file"&&w?.placeable===!0||t.source==="asset"&&t.spritesheet!==void 0||t.source==="asset"&&t.root===_I&&k?.type==="file",onPointerEnter:()=>{S==="audio"&&N&&avn(N)},onPointerLeave:()=>{S==="audio"&&N&&cvn(N)},onDragStart:ue=>i(ue,t),onDragEnd:$9r,onClick:ue=>a(t,ue),onDoubleClick:()=>l(t),onContextMenu:ue=>d(ue,t),onKeyDown:ue=>{if(ue.key==="ContextMenu"||ue.shiftKey&&ue.key==="F10"){ue.preventDefault();const fe=ue.currentTarget.getBoundingClientRect();ue.currentTarget.dispatchEvent(new MouseEvent("contextmenu",{bubbles:!0,cancelable:!0,clientX:fe.left,clientY:fe.bottom}))}else ue.key==="Enter"?l(t):ue.key===" "&&(a(t,ue),ue.preventDefault())},title:j,style:{...xe?YTn:XTn,borderRadius:dZ.sm,cursor:J,userSelect:"none"},children:[z.jsxs("div",{className:"vgai-project-asset-entry__preview","data-testid":"asset-entry-preview",style:{...xe?{width:"100%",aspectRatio:t.source==="available"&&t.available.descriptor.preview?"16 / 9":"1 / 1",margin:"0 auto"}:{width:18,height:18,margin:0},display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",borderRadius:dZ.sm,pointerEvents:"none",position:"relative"},children:[z.jsx(nkn,{item:t,kind:S,assetUrl:N,grid:xe,folderPath:P,previewRevision:g}),xe&&z.jsx("span",{className:"vgai-project-asset-entry__kind","data-testid":"asset-entry-kind",title:`${S} asset`,children:z.jsx(DP,{kind:S,size:11})})]}),z.jsx("div",{"data-testid":"asset-entry-name",style:{...xe?{fontSize:10,lineHeight:"13px",minHeight:26,display:"-webkit-box",WebkitBoxOrient:"vertical",WebkitLineClamp:2}:{fontSize:11,lineHeight:"18px",flex:1},overflow:"hidden",textOverflow:"ellipsis",whiteSpace:xe?"normal":"nowrap",color:od[1],minWidth:0},children:t.name}),!xe&&z.jsx("div",{role:"listbox","aria-label":"Project assets","aria-multiselectable":"true",style:{maxWidth:"45%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:od[3],fontSize:10},children:ee})]})}function skn({scope:t,facets:r,availableFacets:i,currentPath:a,currentRoot:l,searchOpen:d,searchQuery:_,viewMode:g,density:b,treeVisible:S,onScopeChange:k,onFacetToggle:w,onFacetsClear:N,onNavigate:P,onSearchOpenChange:j,onSearchQueryChange:J,onViewModeChange:X,onDensityChange:G,onTreeVisibilityToggle:ee,onCreateFolder:xe,onImport:ue,onDelete:fe,deleteDisabled:se,onRefresh:de,generationTools:ge,onGenerate:qe}){const tt=Xe.useRef(null),Ct=Xe.useRef(!0),Ot=Xe.useRef(null),[vt,Et]=Xe.useState(!1),Tt=a?a.split("/"):[],Le=CR(a),cr=l===_I?"References":"Files",Yt=()=>{J(""),j(!1)};return Xe.useEffect(()=>{if(!vt)return;const Lr=nn=>{tt.current?.contains(nn.target)||Et(!1)};return document.addEventListener("pointerdown",Lr),()=>document.removeEventListener("pointerdown",Lr)},[vt]),Xe.useLayoutEffect(()=>{const Lr=Ot.current;if(!Lr)return;const nn=()=>{Lr.scrollLeft=Lr.scrollWidth};Ct.current=!0,nn();const on=()=>{Ct.current=Lr.scrollWidth-Lr.clientWidth-Lr.scrollLeft<=1};Lr.addEventListener("scroll",on,{passive:!0});const gr=typeof ResizeObserver>"u"?null:new ResizeObserver(()=>{Ct.current&&nn()});return gr?.observe(Lr),()=>{Lr.removeEventListener("scroll",on),gr?.disconnect()}},[a,d]),z.jsxs("div",{className:"vgai-project-assets-toolbar",children:[z.jsxs(NP,{label:"Content display",compact:!0,className:"vgai-project-assets-toolbar__row",children:[z.jsxs(eAt,{children:[z.jsx(ph,{text:"Content grid",position:"top",children:z.jsx(rf,{"aria-label":"Content grid","data-testid":"content-scope-content","aria-pressed":t==="content",onClick:()=>{t!=="content"&&k("content"),X("grid")},children:z.jsx(So,{icon:NDr})})}),z.jsx(ph,{text:"Browse grid",position:"top",children:z.jsx(rf,{"aria-label":"Browse grid","data-testid":"content-scope-files","aria-pressed":t==="files"&&g==="grid",onClick:()=>{t!=="files"&&k("files"),X("grid")},children:z.jsx(So,{icon:$Ir})})}),z.jsx(ph,{text:"Browse list",position:"top",children:z.jsx(rf,{"aria-label":"Browse list","data-testid":"asset-view-list","aria-pressed":t==="files"&&g==="list",onClick:()=>{t!=="files"&&k("files"),X("list")},children:z.jsx(So,{icon:L_e})})})]}),z.jsx("span",{style:{flex:1}}),d?z.jsx(k_,{type:"text","data-testid":"asset-search-input","aria-label":"Search content",placeholder:"Search content...",value:_,onChange:Lr=>J(Lr.target.value),onKeyDown:Lr=>{Lr.key==="Escape"&&Yt()},className:"vgai-input",autoFocus:!0,style:{flex:"0 1 160px",minWidth:60}}):null,z.jsx(ph,{text:d?"Close search":"Search",position:"top",children:z.jsx(rf,{"data-testid":d?"asset-search-close":"asset-search-toggle","aria-label":d?"Close search":"Search content",onClick:()=>{d?Yt():j(!0)},children:z.jsx(So,{icon:d?yb.action.close:yb.action.search})})})]}),z.jsxs(NP,{label:t==="content"?"Content types":"Folder navigation",compact:!0,className:"vgai-project-assets-toolbar__row",children:[t==="files"&&z.jsxs(z.Fragment,{children:[z.jsx(ph,{text:S?"Hide folders":"Show folders",position:"top",children:z.jsx(rf,{"data-testid":"asset-tree-toggle","aria-label":S?"Hide folder tree":"Show folder tree","aria-controls":"project-asset-tree","aria-expanded":S,onClick:ee,children:z.jsx(So,{icon:lIt})})}),z.jsx(ph,{text:"Back",position:"top",children:z.jsx(rf,{"data-testid":"asset-back","aria-label":"Back",disabled:!a,onClick:()=>P(l,Le),children:z.jsx(So,{icon:SDr})})}),z.jsxs("nav",{ref:Ot,"data-testid":"asset-breadcrumb","aria-label":"Asset location",style:{flex:1,display:"flex",alignItems:"center",gap:2,fontSize:12,minWidth:0,overflowX:"auto",overflowY:"hidden",whiteSpace:"nowrap"},children:[a?z.jsx(fo,{type:"button",variant:"ghost",size:"compact",onClick:()=>P(l,""),style:{flexShrink:0},children:cr}):z.jsx("span",{"aria-current":"location",style:{color:od[1]},children:cr}),Tt.map((Lr,nn)=>{const on=Tt.slice(0,nn+1).join("/"),gr=nn===Tt.length-1;return z.jsxs("span",{style:{display:"flex",alignItems:"center",gap:2,flexShrink:0},children:[z.jsx("span",{style:{color:od[3]},children:"/"}),gr?z.jsx("span",{"aria-current":"location",title:Lr,style:{color:od[1]},children:Lr}):z.jsx(fo,{type:"button",variant:"ghost",size:"compact",onClick:()=>P(l,on),children:Lr})]},on)})]})]}),t==="content"&&z.jsxs(eAt,{className:"vgai-content-filter-inline","aria-label":"Content types",children:[d&&z.jsx(fo,{variant:"ghost",size:"compact",className:"vgai-content-filter-chip","data-testid":"content-filter-all","aria-pressed":r.length===0,onClick:N,children:"All"}),[...[["component","Prefabs"],["scene","Scenes"],["canvas","Canvases"],["model","Models"],["image","Images"],["video","Videos"],["audio","Audio"],["other","Other"]].filter(([Lr])=>i.has(Lr)),...[...i].filter(Lr=>!jTn.has(Lr)).sort().map(Lr=>[Lr,BTn(Lr)])].map(([Lr,nn])=>z.jsx(fo,{variant:"ghost",size:"compact",className:"vgai-content-filter-chip","data-testid":`content-filter-${Lr}`,"aria-pressed":r.includes(Lr),onClick:()=>w(Lr),children:nn},Lr))]}),z.jsxs("div",{ref:tt,className:"vgai-project-assets-toolbar__more",children:[z.jsx(ph,{text:"More asset actions",position:"top",children:z.jsx(rf,{"aria-label":"More asset actions","aria-expanded":vt,"aria-haspopup":"menu",onClick:()=>Et(Lr=>!Lr),children:z.jsx(So,{icon:Lkt})})}),vt&&z.jsxs(OP,{autoFocusFirst:!0,className:"vgai-project-assets-toolbar__menu",onDismiss:()=>Et(!1),children:[z.jsx(Wa,{"data-command-id":z_.import.id,onSelect:()=>{Et(!1),ue()},children:"Import files…"}),z.jsx(Wa,{"data-command-id":z_.createFolder.id,onSelect:()=>{Et(!1),xe()},children:"New folder"}),ge.length>0&&z.jsxs(z.Fragment,{children:[z.jsx("hr",{className:"vgai-menu-separator"}),z.jsx(Wa,{onSelect:()=>{Et(!1),qe()},children:"Create asset…"})]}),z.jsx(Wa,{onSelect:()=>{Et(!1),G(b<=96?132:88)},children:b<=96?"Larger thumbnails":"Smaller thumbnails"}),z.jsx(Wa,{disabled:se,"data-command-id":z_.delete.id,onSelect:()=>{Et(!1),fe()},children:"Delete selected"}),z.jsx(Wa,{onSelect:()=>{Et(!1),de()},children:"Refresh"})]})]})]})]})}function okn(t){const[r,i]=Xe.useState(new Map);Xe.useEffect(()=>{i(new Map)},[t.revision]),Xe.useEffect(()=>{for(const l of t.expanded){if(r.has(l))continue;const d=CNt.find(g=>l===g||l.startsWith(`${g}/`));if(!d)continue;const _=l===d?"":l.slice(`${d}/`.length);t.loadAssets(d,_).then(g=>{g.ok&&i(b=>{const S=new Map(b);return S.set(l,g.entries.filter(k=>k.type==="directory").map(k=>k.name)),S})})}},[r,t.expanded,t.loadAssets]);const a=(l,d,_)=>{const g=d?`${l}/${d}`:l,b=t.expanded.has(g),S=d.split("/").pop()||l;return z.jsxs("div",{children:[z.jsxs("div",{className:"vgai-asset-tree-row",style:{paddingLeft:6+_*14},children:[z.jsx(rf,{className:"vgai-asset-tree-toggle","aria-label":`${b?"Collapse":"Expand"} ${S}`,"aria-expanded":b,onClick:()=>t.onExpanded(g),children:z.jsx(So,{icon:zkt,style:{transform:b?"rotate(90deg)":void 0}})}),z.jsxs(fo,{variant:"ghost",size:"compact",className:"vgai-asset-tree-target","aria-current":t.currentRoot===l&&t.currentPath===d?"page":void 0,onClick:()=>t.onNavigate(l,d),children:[z.jsx(So,{icon:gee}),S]})]}),b&&r.get(g)?.map(k=>a(l,d?`${d}/${k}`:k,_+1))]},g)};return z.jsxs("aside",{id:"project-asset-tree",className:"vgai-asset-tree","aria-label":"Project asset sources",hidden:t.hidden,children:[z.jsx("div",{className:"vgai-asset-facet-title",children:"Project"}),a("public","",0),z.jsx(fo,{variant:"ghost",size:"compact",className:"vgai-asset-tree-target",onClick:()=>t.onNavigate("public","asset-library/local"),children:"Imported"}),z.jsx(fo,{variant:"ghost",size:"compact",className:"vgai-asset-tree-target",onClick:()=>t.onNavigate("public",".generated"),children:"Generated"}),z.jsx("div",{className:"vgai-asset-facet-title",children:"References"}),a(_I,"",0)]})}function akn(t){const r=Xe.useRef(null),[i,a]=Xe.useState(t),[l,d]=Xe.useState(!0);Xe.useLayoutEffect(()=>{const b=r.current;if(!b)return;const S=w=>{w>0&&d(w>=RTn)};if(S(b.getBoundingClientRect().width),typeof ResizeObserver>"u")return;const k=new ResizeObserver(([w])=>{w&&S(w.contentRect.width)});return k.observe(b),()=>k.disconnect()},[]);const _=i==="shown"||i==="auto"&&l,g=Xe.useCallback(()=>{a(_?"hidden":"shown")},[_]);return{browserRef:r,treeVisibility:i,treeVisible:_,toggleTreeVisibility:g}}function ckn({services:t=LTn}){const r=D0(),i=typeof r.subscribe=="function"?r.subscribe:ekn,a=typeof r.getSnapshot=="function"?r.getSnapshot:tkn,l=typeof r.getShellSnapshot=="function"?r.getShellSnapshot:a,d=Xe.useSyncExternalStore(i,l,l),_=Xe.useSyncExternalStore(Nee,MP,MP),g=Xe.useSyncExternalStore(Aw,Sb,Sb),b=Xe.useRef(r);b.current=r;const S=FGt(),k=Xe.useSyncExternalStore(jA,dI,dI),w=Xe.useSyncExternalStore(sGt,Sye,Sye),N=k.filter(Gt=>Gt.point==="workspace.document"&&Gt.tool?.generation?.role==="submit"),P=Xe.useMemo(MTn,[]),[j,J]=Xe.useState(P.root),[X,G]=Xe.useState(P.scope),[ee,xe]=Xe.useState(P.facets),[ue,fe]=Xe.useState(P.currentPath),[se,de]=Xe.useState(P.viewMode),[ge,qe]=Xe.useState(P.scope==="content"?"relevance":"name"),[tt,Ct]=Xe.useState("all"),[Ot,vt]=Xe.useState(P.density),{browserRef:Et,treeVisibility:Tt,treeVisible:Le,toggleTreeVisibility:cr}=akn(P.treeVisibility),[Yt,Lr]=Xe.useState(!1),[nn,on]=Xe.useState({path:P.currentPath,entries:[]}),[gr,An]=Xe.useState([]),[Rn,ln]=Xe.useState([]),Mn=Xe.useSyncExternalStore(qmn,_Qe),Is=Xe.useSyncExternalStore(YP,v1,v1),[Zs,Zc]=Xe.useState(!1),[vl,gn]=Xe.useState([]),[_t,_o]=Xe.useState(new Set(P.expanded)),[Nr,ko]=Xe.useState(0),[Sa,_c]=Xe.useState(0),[Yl,ol]=Xe.useState(""),[Sd,Qu]=Xe.useState(new Set),[vu,$l]=Xe.useState(null),[el,gc]=Xe.useState(null),[Cf,Qr]=Xe.useState(""),Cl=Xe.useCallback(Gt=>{Qr(Gt.initial),gc(Gt)},[]),[ku,xi]=Xe.useState(!1),[Iu,Xl]=Xe.useState(null),[oa,aa]=Xe.useState(null),Ef=Xe.useRef(null),Tg=Xe.useRef(new Map),xp=Xe.useRef("");Xe.useEffect(()=>{const Gt=ad()?.rootPath??"__unscoped__";localStorage.setItem(nGt(Gt),JSON.stringify({scope:X,root:j,facets:ee,currentPath:ue,viewMode:se,sort:ge,filter:tt,density:Ot,expanded:[..._t],treeVisibility:Tt}))},[ue,j,Ot,_t,ee,tt,X,ge,Tt,se]);const ca=Xe.useCallback(async(Gt,qr)=>{const Ai=`${Gt}:${qr}`;xp.current=Ai;const ns=(Fc,Wf)=>{xp.current===Ai&&on({path:qr,entries:Fc,...Wf===void 0?{}:{failure:Wf}})},vc=Tg.current.get(Ai);if(vc){ns(vc);return}try{const Fc=await t.listAssets(Gt,qr);if(!Fc.ok){ns([],Fc.reason);return}Tg.current.set(Ai,Fc.entries),ns(Fc.entries)}catch(Fc){ns([],Fc instanceof Error?Fc.message:String(Fc))}},[t]);Xe.useEffect(()=>{ca(j,ue)},[j,ue,ca]);const Tf=Xe.useCallback(async()=>{Zc(!0);try{const[Gt,qr]=await Promise.all([$Qt(t.listAssets),t.listProjectComponents()]),Ai=await mwn(Gt.assets,async ns=>{try{const vc=await fetch(`/${ns}`);return vc.ok?await vc.text():null}catch{return null}});An(Ai),ln(qr.ok?qr.entries:[]),gn([...Gt.failedListings,...qr.ok?[]:[`component index: ${qr.reason}`]])}catch(Gt){An([]),ln([]),gn([Gt instanceof Error?Gt.message:String(Gt)])}finally{Zc(!1)}},[t]);Xe.useEffect(()=>{X==="content"&&Tf()},[Tf,X]);const qo=Xe.useCallback((Gt,qr)=>{J(Gt),fe(qr),Qu(new Set),Xl(null),pP(),ol(""),Lr(!1)},[]),eg=Xe.useCallback(Gt=>{G(Gt),qe(Gt==="content"?"relevance":"name"),Ct("all"),Qu(new Set),Xl(null),pP()},[]),ac=Xe.useCallback(Gt=>{xe([Gt])},[]),Qo=Xe.useCallback(Gt=>{Lr(Gt),Gt||xe(qr=>qr.length>0?qr:["component"])},[]),kf=nn.path,Ze=Xe.useMemo(()=>ZTn(wm(b.current).adapter),[_,d,g]),$t=Xe.useMemo(()=>wm(b.current).surface,[_,d,g]),Rt=Xe.useMemo(()=>{if(X==="content"){const Gt=new Map(Rn.map(ns=>[`${ns.path}:${ns.name}`,ns])),qr=Y0n().flatMap(ns=>ns.entries({components:Rn,surface:$t}).flatMap(vc=>{const Fc=Gt.get(`${vc.component.path}:${vc.component.name}`);if(!Fc)return[];const Wf=`${Fc.path.replace(/^\.\//,"")}:${Fc.name}`,Js=Ze.get(Wf);return[{source:"component",key:`component:${ns.id}:${vc.id}`,name:Fc.name,path:Fc.path,component:Fc,contentSource:ns,contentEntry:vc,...Js?{authoringAsset:Js}:{}}]})),Ai=(Is?.scenes.entries??[]).flatMap(ns=>ns.kind==="prefab"?[]:ns.kind==="scene"&&Mn.some(vc=>(vc.category==="scene"||vc.category==="canvas")&&!!ns.source?.path&&vc.descriptor.provenance?.sourcePath?.replace(/^\.\//,"")===ns.source.path.replace(/^\.\//,""))?[]:ns.kind!=="scene"&&!ns.source?[]:[{source:"document",key:`document:${ns.id}`,name:ns.label,path:ns.source?.path??"",document:ns}]);return[...qr,...Ai,...Mn.map(ns=>({source:"available",key:`available:${ns.descriptor.id}`,name:ns.descriptor.title,path:ns.descriptor.provenance?.sourcePath??"",available:ns})),...gr.map(({path:ns,root:vc,entry:Fc,spritesheet:Wf})=>({source:"asset",key:`asset:${vc}:${ns}`,name:Fc.name,path:ns,root:vc,entry:Fc,...Wf?{spritesheet:Wf}:{}}))]}return nn.entries.map(Gt=>{const qr=nn.path?`${nn.path}/${Gt.name}`:Gt.name;return{source:"asset",key:`asset:${j}:${qr}`,name:Gt.name,path:qr,root:j,entry:Gt}})},[$t,Is,Mn,Ze,Rn,gr,w,j,nn,X]),ft=X==="content"?vl[0]??null:nn.failure??null,Tr=Xe.useMemo(()=>{const Gt=Yl.toLowerCase(),qr=Rt.filter(ns=>KTn(ns,{query:Gt,scope:X,facets:ee,filter:tt,shownPath:kf})),Ai=X==="files"&&ge==="relevance"?"name":ge;return[...qr].sort((ns,vc)=>QTn(ns,vc,Ai))},[Rt,ee,kf,tt,X,Yl,ge]),ti=Xe.useMemo(()=>{const Gt=new Set;for(const qr of Rt)Gt.add(_Kt(qr));return Gt},[Rt]),Gi=Xe.useMemo(()=>zTn(Tr,X,ee),[ee,Tr,X]),Ni=Xe.useCallback((Gt,qr)=>{if(qr.source==="component"){const Js={path:qr.path,kind:"component",name:qr.name,component:{kind:"component",name:qr.component.name,sourcePath:qr.component.path,exportKind:qr.component.defaultExport?"default":"named",surface:qr.component.surface}};Gt.dataTransfer.setData("text/plain",qr.name),Gt.dataTransfer.setData("application/x-editor-asset",JSON.stringify(Js));return}if(qr.source==="document"||qr.source==="available"){if("dataTransfer"in Gt){Gt.dataTransfer.setData("text/plain",qr.path);return}return}const{entry:Ai}=qr,ns=wg(Ai.name);if(qr.root===_I){Gt.preventDefault(),My(`${Ai.name} is reference material. ${f9e}`);return}if(qr.spritesheet){Gt.preventDefault(),My(`${Ai.name} is one frame of the ${qr.spritesheet.sheetPath.split("/").pop()??"sprite sheet"} sprite sheet — it is placed through the Prefab that animates it, not on its own. Drop a Prefab, or a standalone image file.`);return}if(Ai.type!=="file"||!ns.placeable){Gt.preventDefault();return}const vc=Bq(ns);if(!vc)return;const Wf={path:OTn(j,CR(qr.path),Ai.name),kind:vc,name:Ai.name};Gt.dataTransfer.setData("text/plain",Ai.name),Gt.dataTransfer.setData("application/x-editor-asset",JSON.stringify(Wf))},[j]),jo=Xe.useCallback((Gt,qr)=>{let Ai=new Set;if(qr.shiftKey&&Iu){const Bd=Tr.findIndex(yh=>yh.key===Iu),no=Tr.findIndex(yh=>yh.key===Gt.key);if(Bd>=0&&no>=0){const[yh,Qi]=Bd<no?[Bd,no]:[no,Bd];Ai=new Set(Tr.slice(yh,Qi+1).map(pa=>pa.key))}}else qr.metaKey||qr.ctrlKey?(Ai=new Set(Sd),Ai.has(Gt.key)?Ai.delete(Gt.key):Ai.add(Gt.key),Xl(Gt.key)):(Ai.add(Gt.key),Xl(Gt.key));if(Qu(Ai),Gt.source==="component"){if(Gt.component.contentKind==="image"&&Gt.authoringAsset){YN({path:Gt.authoringAsset.subject.sourcePath??Gt.path,name:Gt.name,kind:"image",capabilities:wg("svg"),health:"healthy",selectionCount:Ai.size});return}YN({path:Gt.path,name:Gt.name,kind:"component",health:"healthy",selectionCount:Ai.size,componentPreview:{surface:Gt.component.surface,sourcePath:Gt.component.path}});return}if(Gt.source==="document"||Gt.source==="available"){YN({path:`/${Gt.path}`,name:Gt.name,kind:"source",capabilities:wg(Gt.name),origin:"project",health:"healthy",selectionCount:Ai.size});return}const{entry:ns}=Gt;if(ns.type==="directory"){pP();return}const vc=wg(ns.name),Fc=Bq(vc)??"unknown",Wf=H0e(Gt.root,Gt.path);if(YN({path:Wf,name:ns.name,kind:Fc,...ns.size===void 0?{}:{sizeBytes:ns.size},capabilities:vc,health:Rqe(ns.name),selectionCount:Ai.size,...Gt.path.startsWith("asset-library/local")?{sourcePath:"Asset Library provenance metadata"}:{}}),Gt.root!=="public")return;const Js=Gt.path;mTn(_z(),Js).then(Bd=>{const no=Wf;q0e()?.path===no&&YN({path:no,name:ns.name,kind:Fc,...ns.size===void 0?{}:{sizeBytes:ns.size},capabilities:vc,health:Bd.health.status==="healthy"?"healthy":vc.runtimeReady?"unsupported":"source-only",healthCodes:Bd.health.codes,dependencies:Bd.dependencies,references:Bd.references,selectionCount:Ai.size})}).catch(()=>{})},[Tr,Sd,Iu]),yc=Xe.useCallback(Gt=>{if(Gt.source==="component"){if(Gt.authoringAsset){Fzr(r,Gt.authoringAsset.id,Gt.authoringAsset.subject);return}Gt.contentSource.open(r,Gt.contentEntry,Gt.name);return}if(Gt.source==="available"){s9(Gt.available.descriptor.id);return}if(Gt.source==="document"){if(Gt.document.kind==="scene"){const qr=$Wt(r,Gt.document.id);qr.ok||ua.error(qr.error,"scene");return}U8(r,Gt.document)||f8(r,`/${Gt.path}`,BWt(Gt.document));return}VTn(Gt,{currentRoot:j,currentPath:Gt.source==="asset"?CR(Gt.path):"",navigate:qo,openAsset:(qr,Ai)=>f8(r,qr,Ai)})},[j,qo,r]),cd=Xe.useCallback(Gt=>{if(ko(qr=>qr+1),Tg.current.clear(),Gt?.length)for(const qr of Gt)VTt(qr);else VTt();_c(qr=>qr+1),ca(j,ue),X==="content"&&Tf()},[j,ue,Tf,ca,X]);Xe.useEffect(()=>{const Gt=qr=>cd(qr.detail?.paths);return window.addEventListener("editor:assets-changed",Gt),()=>window.removeEventListener("editor:assets-changed",Gt)},[cd]),Xe.useEffect(()=>{const Gt=qr=>{const Ai=qr.detail?.path;if(!Ai)return;const ns=wg(Ai),vc=Bq(ns);vc&&f8(r,Ai,vc)};return window.addEventListener("editor:open-project-asset",Gt),()=>window.removeEventListener("editor:open-project-asset",Gt)},[r]);const nf=Xe.useMemo(()=>Rt.filter(Gt=>Sd.has(Gt.key)),[Rt,Sd]),Xi=Xe.useMemo(()=>nf.flatMap(Gt=>Gt.source==="asset"&&Gt.entry.type==="file"&&Gt.root==="public"?[Gt.path]:[]),[nf]),Qn=Xe.useMemo(()=>nf.flatMap(Gt=>Gt.source==="asset"&&Gt.entry.type==="file"?[oge(Gt.root,Gt.path)]:[]),[nf]);Xe.useEffect(()=>{const Gt=new Set(Rt.map(qr=>qr.key));Qu(qr=>{const Ai=new Set([...qr].filter(ns=>Gt.has(ns)));return qr.size>0&&Ai.size===0&&(Xl(null),pP()),Ai.size===qr.size?qr:Ai})},[Rt]);const Eo=Xe.useCallback(async Gt=>{await hTn(Gt,{backend:_z(),history:S}),Tg.current.clear(),j==="public"&&await ca(j,ue),X==="content"&&await Tf()},[ue,j,Tf,ca,S,X]),lc=Xe.useCallback(async()=>{Xi.length!==0&&GEn("delete",`Delete ${Xi.length} selected asset(s)? This is undoable.`)&&(await Eo({type:"delete",paths:Xi}),Qu(new Set),Xl(null),pP())},[Eo,Xi]),sf=Xe.useCallback(()=>{Xi.length!==0&&Cl({title:`Move ${Xi.length} selected to folder`,initial:ue,confirmLabel:"Move",run:async Gt=>{const qr=Gt.replace(/^\/+|\/+$/g,"");$l(null);try{await Eo({type:"move-many",moves:Xi.map(Ai=>({source:Ai,destination:qr?`${qr}/${Ai.split("/").pop()}`:Ai.split("/").pop()}))})}catch(Ai){$l(Ai instanceof Error?Ai.message:String(Ai))}}})},[Cl,ue,Eo,Xi]),Zl=Xe.useCallback(()=>{j==="public"&&Cl({title:"New folder name",initial:"",confirmLabel:"Create",run:async Gt=>{Gt&&await Eo({type:"create-folder",path:ue?`${ue}/${Gt}`:Gt})}})},[Cl,ue,j,Eo]),Ku=Xe.useCallback(async Gt=>{if(!Gt||Gt.length===0)return;const qr=X==="content"||j!=="public"?"":ue,Ai=await Promise.all([...Gt].map(async ns=>({path:qr?`${qr}/${ns.name}`:ns.name,bytes:new Uint8Array(await ns.arrayBuffer())})));$l(null);try{await Eo({type:"import",files:Ai})}catch(ns){$l(`Could not import ${Ai.length===1?Ai[0]?.path:`${Ai.length} files`}: ${ns instanceof Error?ns.message:String(ns)}`);return}X==="content"&&eg("files"),qo("public",qr),My(Ai.length===1?`Imported ${Ai[0]?.path}`:`Imported ${Ai.length} files`)},[eg,ue,j,Eo,qo,X]),eu=Xe.useCallback(Gt=>{if(!(Gt.source!=="asset"||Gt.entry.type!=="file")){if(Gt.root!=="public"){My(`${Gt.name} is reference material. ${f9e}`);return}Cl({title:`Rename ${Gt.name}`,initial:Gt.name,confirmLabel:"Rename",run:async qr=>{if(!qr||qr===Gt.name)return;const Ai=Gt.path,ns=CR(Gt.path),vc=ns?`${ns}/${qr}`:qr;await Eo({type:"move",source:Ai,destination:vc})}})}},[Cl,Eo]),ze=Xe.useCallback(async Gt=>{if(Gt.source!=="asset"||Gt.entry.type!=="file")return;if(Gt.root!=="public"){My(`${Gt.name} is reference material. ${f9e}`);return}const qr=Gt.name.lastIndexOf("."),Ai=qr>0?`${Gt.name.slice(0,qr)} copy${Gt.name.slice(qr)}`:`${Gt.name} copy`,ns=Gt.path,vc=CR(Gt.path),Fc=vc?`${vc}/${Ai}`:Ai;await Eo({type:"duplicate",source:ns,destination:Fc})},[Eo]),Bt=Xe.useCallback(Gt=>{_o(qr=>{const Ai=new Set(qr);return Ai.has(Gt)?Ai.delete(Gt):Ai.add(Gt),Ai})},[]);Xe.useEffect(()=>{const Gt=qr=>{const Ai=qr.detail?.id,ns=nf[0];Ai===z_.refresh.id?cd():Ai===z_.import.id?Ef.current?.click():Ai===z_.createFolder.id?Zl():Ai===z_.move.id?sf():Ai===z_.delete.id?lc():Ai===z_.rename.id&&ns?eu(ns):Ai===z_.duplicate.id&&ns?ze(ns):Ai===z_.copyPath.id&&Qn[0]?navigator.clipboard.writeText(Qn[0]):Ai===z_.reveal.id&&Qn[0]&&ALe(Qn[0])};return window.addEventListener("editor:project-asset-command",Gt),()=>window.removeEventListener("editor:project-asset-command",Gt)},[Zl,ue,lc,ze,sf,cd,eu,nf,Qn]);const zr=oa?.item.source==="available"&&oa.item.available.descriptor.preview?oa.item:null;return z.jsxs("div",{ref:Et,className:"vgai-asset-browser","data-tree-visible":X==="files"&&Le,onPointerDown:()=>H8("asset-browser"),onKeyDown:Gt=>{if(!fqe(Gt.target)){if(Gt.key==="Delete"||Gt.key==="Backspace")lc(),Gt.preventDefault();else if((Gt.metaKey||Gt.ctrlKey)&&Gt.key.toLowerCase()==="d"){const qr=nf[0];qr&&ze(qr),Gt.preventDefault()}else if(Gt.key==="F2"){const qr=nf[0];qr&&eu(qr),Gt.preventDefault()}}},onDragOver:Gt=>{j!=="public"||!Gt.dataTransfer.types.includes("Files")||(Gt.preventDefault(),Gt.dataTransfer.dropEffect="copy",ku||xi(!0))},onDragLeave:Gt=>{Gt.currentTarget.contains(Gt.relatedTarget)||xi(!1)},onDrop:Gt=>{j!=="public"||!Gt.dataTransfer.types.includes("Files")||(Gt.preventDefault(),xi(!1),Ku(Gt.dataTransfer.files))},style:{display:"flex",flex:1,minHeight:0,position:"relative",...ku?{outline:`2px dashed ${Oo.accent.default}`,outlineOffset:-2}:{}},children:[z.jsx(okn,{currentRoot:j,currentPath:ue,expanded:_t,hidden:X!=="files"||!Le,revision:Nr,loadAssets:t.listAssets,onExpanded:Bt,onNavigate:qo}),z.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",minWidth:0,minHeight:0},children:[z.jsx(k_,{ref:Ef,type:"file",multiple:!0,"aria-label":"Import project assets",hidden:!0,onChange:Gt=>{Ku(Gt.target.files),Gt.currentTarget.value=""}}),z.jsx(skn,{availableFacets:ti,scope:X,facets:ee,currentPath:ue,currentRoot:j,searchOpen:Yt,searchQuery:Yl,viewMode:se,density:Ot,treeVisible:Le,onScopeChange:eg,onFacetToggle:ac,onFacetsClear:()=>xe([]),onNavigate:qo,onSearchOpenChange:Qo,onSearchQueryChange:ol,onViewModeChange:de,onDensityChange:vt,onTreeVisibilityToggle:cr,onCreateFolder:()=>void Zl(),onImport:()=>Ef.current?.click(),onDelete:()=>void lc(),deleteDisabled:Xi.length===0,onRefresh:cd,generationTools:N,onGenerate:()=>{FP("generation",r,{kind:"generation",id:"create"})}}),vu&&z.jsx("div",{role:"alert",className:"vgai-asset-operation-error",children:vu}),el&&z.jsxs("form",{className:"vgai-asset-inline-prompt",style:{display:"flex",alignItems:"center",gap:6,padding:"6px 8px"},onSubmit:Gt=>{Gt.preventDefault();const qr=el;gc(null),qr.run(Cf.trim())},children:[z.jsx("span",{style:{fontSize:12},children:el.title}),z.jsx(k_,{autoFocus:!0,"aria-label":el.title,value:Cf,onChange:Gt=>Qr(Gt.target.value),onKeyDown:Gt=>{Gt.key==="Escape"&&gc(null)}}),z.jsx(fo,{type:"submit",size:"compact",children:el.confirmLabel}),z.jsx(fo,{type:"button",variant:"ghost",size:"compact",onClick:()=>gc(null),children:"Cancel"})]}),Xi.length>0&&z.jsxs(NP,{label:"Selected asset actions",compact:!0,children:[z.jsxs("span",{children:[Xi.length," selected"]}),z.jsx(fo,{variant:"ghost",size:"compact",onClick:()=>void sf(),children:"Move selected"}),z.jsx(fo,{variant:"ghost",size:"compact","aria-label":"Delete selected assets",onClick:()=>void lc(),children:"Delete"})]}),z.jsxs("div",{className:"vgai-project-assets-results","data-view":se,"data-testid":"project-asset-results",role:"listbox","aria-label":X==="content"?"Project content":"Project files","aria-multiselectable":"true",style:{flex:1,overflowY:"auto",padding:8,display:se==="list"?"flex":"grid",gridTemplateColumns:se==="grid"?`repeat(auto-fill, minmax(${Math.round(Ot*.75)}px, 1fr))`:void 0,gridAutoRows:se==="list"?void 0:"min-content",flexDirection:se==="list"?"column":void 0,gap:se==="list"?1:6,alignContent:"start"},children:[Gi.map(Gt=>z.jsxs("div",{role:"group","aria-label":Gt.label??void 0,className:"vgai-content-result-section",children:[Gt.label&&z.jsx("div",{role:"presentation",className:"vgai-content-section-heading","data-level":Gt.headingLevel??void 0,"data-testid":`content-section-${Gt.id}`,children:z.jsx("span",{children:Gt.label})}),Gt.entries.map(qr=>z.jsx(ikn,{item:qr,selected:Sd.has(qr.key),onDragStart:Ni,onSelect:jo,onOpen:yc,onContextMenu:(Ai,ns)=>{Ai.preventDefault(),ns.source!=="component"&&(Sd.has(ns.key)||jo(ns,Ai),aa({x:Ai.clientX,y:Ai.clientY,item:ns}))},viewMode:se,previewRevision:Sa,showPath:X==="content"},qr.key))]},Gt.id)),Tr.length===0&&z.jsx(D5r,{compact:!0,style:{gridColumn:"1 / -1"},icon:z.jsx(So,{icon:ft?yb.status.warning:Yl?yb.action.search:yb.content.folder}),title:Zs?"Finding project content…":ft?"Listing failed":Yl?"No matching content":X==="content"?"No content in this type":"Empty folder",description:Zs?"Scanning components and assets across the project.":ft?`Listing failed: ${ft}`:Yl?"Try a broader search or another content type.":X==="content"?"Choose another type or import an asset.":"Add files to this folder to see them here."})]})]}),zr&&oa&&z.jsx(vhe,{children:z.jsxs(OP,{autoFocusFirst:!0,className:"vgai-asset-context-menu",style:{left:oa.x,top:oa.y},onDismiss:()=>aa(null),children:[z.jsxs(Wa,{type:"button",role:"menuitem",onClick:()=>{yc(zr),aa(null)},children:["Open ",z.jsx("kbd",{children:"Enter"})]}),zr.available.category==="scene"&&z.jsxs(z.Fragment,{children:[z.jsx(Wa,{type:"button",role:"menuitem",onClick:()=>{const Gt=zr.available.descriptor.id;aa(null),GTt(Gt,!1).then(()=>_c(qr=>qr+1)).catch(qr=>$l(qr instanceof Error?qr.message:String(qr)))},children:"Use current view for preview"}),z.jsx(Wa,{type:"button",role:"menuitem",onClick:()=>{const Gt=zr.available.descriptor.id;aa(null),GTt(Gt,!0).then(()=>_c(qr=>qr+1)).catch(qr=>$l(qr instanceof Error?qr.message:String(qr)))},children:"Reset preview view"})]}),z.jsx(Wa,{type:"button",role:"menuitem",onClick:()=>{aa(null),_c(Gt=>Gt+1)},children:"Refresh preview"})]})}),oa&&oa.item.source==="asset"&&z.jsx(vhe,{children:z.jsxs(OP,{autoFocusFirst:!0,className:"vgai-asset-context-menu",style:{left:oa.x,top:oa.y},onDismiss:()=>aa(null),children:[z.jsxs(Wa,{type:"button",role:"menuitem","data-command-id":z_.open.id,onClick:()=>{yc(oa.item),aa(null)},children:["Open ",z.jsx("kbd",{children:"Enter"})]}),z.jsxs(Wa,{type:"button",role:"menuitem","data-command-id":z_.rename.id,onClick:()=>{eu(oa.item),aa(null)},children:["Rename ",z.jsx("kbd",{children:"F2"})]}),z.jsxs(Wa,{type:"button",role:"menuitem","data-command-id":z_.duplicate.id,onClick:()=>{ze(oa.item),aa(null)},children:["Duplicate ",z.jsx("kbd",{children:"⌘D"})]}),z.jsx(Wa,{type:"button",role:"menuitem","data-command-id":z_.move.id,disabled:Xi.length===0,title:Xi.length?"Move selected assets":"Select a file to move",onClick:()=>{sf(),aa(null)},children:"Move selected…"}),z.jsx(Wa,{type:"button",role:"menuitem","data-command-id":z_.copyPath.id,disabled:!Qn[0],onClick:()=>{Qn[0]&&navigator.clipboard.writeText(Qn[0]),aa(null)},children:"Copy path"}),AIt("asset").map(Gt=>{const qr=oa.item.source==="asset"&&oa.item.entry.type==="file",Ai=oa.item.source==="asset"?{assetPath:oge(oa.item.root,oa.item.path)}:{};return z.jsx(Wa,{type:"button",role:"menuitem","data-testid":Gt.testId,disabled:!qr||(Gt.disabled?.(Ai)??!1),onClick:()=>{Gt.execute(Ai),aa(null)},children:typeof Gt.label=="function"?Gt.label():Gt.label},Gt.id)}),z.jsx(Wa,{type:"button",role:"menuitem","data-command-id":z_.reveal.id,disabled:!Qn[0],onClick:()=>{Qn[0]&&ALe(Qn[0]),aa(null)},children:"Reveal in Finder"}),z.jsxs(Wa,{type:"button",role:"menuitem","data-command-id":z_.delete.id,disabled:Xi.length===0,onClick:()=>{lc(),aa(null)},children:["Delete ",z.jsx("kbd",{children:"⌫"})]})]})})]})}const lkn={agent:()=>z.jsx(Zme,{slot:"panel:agent"}),"project-work":()=>z.jsx(Zme,{slot:"panel:project-work"}),hierarchy:oKt,assets:({dependencies:t})=>z.jsx(ckn,{services:t?.assets}),"asset-library":()=>z.jsx(Zme,{slot:"panel:asset-library"}),inspector:uKe};class ukn extends Xe.Component{state={error:null};static getDerivedStateFromError(r){return{error:r}}componentDidCatch(r,i){ua.error(`The ${this.props.title} panel crashed and was taken down alone (the rest of the editor stays up; Retry in the panel remounts it): ${r.message}
|
|
1691
|
-
${i.componentStack??""}`,"editor")}render(){return this.state.error?z.jsxs("div",{role:"alert","data-testid":"static-panel-crashed",style:{padding:12,display:"grid",gap:8,alignContent:"start"},children:[z.jsxs("strong",{children:[this.props.title," crashed."]}),z.jsx("span",{style:{opacity:.8,wordBreak:"break-word"},children:this.state.error.message}),z.jsx("div",{children:z.jsx(fo,{type:"button",variant:"outline",size:"compact",onClick:()=>this.setState({error:null}),children:"Retry"})})]}):this.props.children}}const fkn=LQe.map(t=>{const r=lkn[t.kind],i=a=>z.jsx(ukn,{title:t.title,children:z.jsx(r,{...a})});return i.displayName=`StaticPanel(${t.kind})`,{...t,Content:i}});function dkn(t){return fkn.find(r=>r.kind===t)}function pkn({kind:t,dependencies:r}){const{Content:i}=dkn(t);return z.jsx(i,{dependencies:r})}const _kn=250;function mkn(){const t=B3t(),r=hkn();return()=>{r(),t()}}function hkn(){const t=new Map;let r=null,i=!1;function a(){const _=[],g=new Set;for(const b of ua.getEntries()){if(g.add(b.id),b.level!=="error"&&b.level!=="warn")continue;const S=t.get(b.id)??0;b.count<=S||(t.set(b.id,b.count),_.push({severity:b.level,message:b.message,source:b.source??null,occurrences:b.count-S}))}for(const b of[...t.keys()])g.has(b)||t.delete(b);return _}function l(){if(r=null,i)return;const _=a();_.length!==0&&R8("console-entries",{entries:_,_clientId:jP})}const d=ua.subscribe(()=>{i||r!==null||(r=setTimeout(l,_kn))});return R8("console-entries",{entries:[],_clientId:jP}),l(),()=>{i=!0,r!==null&&clearTimeout(r),d()}}const RN={INPUT:"input",PRE_PHYSICS:"prePhysics",PHYSICS:"physics",POST_PHYSICS:"postPhysics",GAME_LOGIC:"gameLogic",ANIMATION:"animation",PRE_RENDER:"preRender",RENDER:"render"},O_e=[RN.INPUT,RN.PRE_PHYSICS,RN.PHYSICS,RN.POST_PHYSICS,RN.GAME_LOGIC,RN.ANIMATION,RN.PRE_RENDER,RN.RENDER],Fye=1e-9,hKt=1e5;function gkn(t,r,i){const a=i.end-i.start,l=i.loop&&a>Fye,d=[];let _=t,g=r,b=!1,S=0;for(;;){const k=i.end-_;if(!l||g<=k+Fye){const w=Math.min(_+g,i.end);d.push({from:_,to:w,direction:"forward"}),_=w;break}if(d.push({from:_,to:i.end,direction:"forward"}),g-=k,_=i.start,b=!0,S++,S>hKt){const w=i.start+g%a;d.push({from:_,to:w,direction:"forward"}),_=w;break}}return{pos:_,intervals:d,looped:b}}function ykn(t,r,i){const a=i.end-i.start,l=i.loop&&a>Fye,d=[];let _=t,g=r,b=!1,S=0;for(;;){const k=_-i.start;if(!l||g<=k+Fye){const w=Math.max(_-g,i.start);d.push({from:_,to:w,direction:"reverse"}),_=w;break}if(d.push({from:_,to:i.start,direction:"reverse"}),g-=k,_=i.end,b=!0,S++,S>hKt){const w=i.end-g%a;d.push({from:_,to:w,direction:"reverse"}),_=w;break}}return{pos:_,intervals:d,looped:b}}function YTt(t,r){return t<r.start?r.start:t>r.end?r.end:t}class vkn{_previousTime;_currentTime;_range;_timeScale;_playDirection="forward";_lastCrossingDirection="forward";_playbackState="stopped";_evaluators=[];_registrationCounter=0;constructor(r={}){const i=r.start??0,a=r.end??Math.max(i,1);if(a<i)throw new Error(`[AnimationClock] range end (${a}) must be >= start (${i})`);const l=r.timeScale??1;if(!Number.isFinite(l)||l<0)throw new Error(`[AnimationClock] timeScale must be a finite number >= 0, got ${l}`);this._range={start:i,end:a,loop:r.loop??!1},this._timeScale=l,this._previousTime=i,this._currentTime=i}get time(){return this._currentTime}get previousTime(){return this._previousTime}get direction(){return this._playbackState==="playing"?this._playDirection:"paused"}get playbackState(){return this._playbackState}get timeScale(){return this._timeScale}set timeScale(r){if(!Number.isFinite(r)||r<0)throw new Error(`[AnimationClock] timeScale must be a finite number >= 0, got ${r}`);this._timeScale=r}get range(){return this._range}setRange(r){const i=r.start??this._range.start,a=r.end??this._range.end,l=r.loop??this._range.loop;if(a<i)throw new Error(`[AnimationClock] range end (${a}) must be >= start (${i})`);this._range={start:i,end:a,loop:l};const d=YTt(this._currentTime,this._range);d!==this._currentTime&&this.seek(d)}play(r){r&&(this._playDirection=r),this._playbackState="playing"}pause(){this._playbackState="paused"}stop(){this._playbackState="stopped"}seek(r){const i=YTt(r,this._range);if(i===this._currentTime)return this.emit(this._currentTime,this._currentTime,[{from:i,to:i,direction:this._lastCrossingDirection}],!1,this._lastCrossingDirection);const a=i>this._currentTime?"forward":"reverse",l=this._currentTime;return this._previousTime=l,this._currentTime=i,this._lastCrossingDirection=a,this.emit(l,i,[{from:l,to:i,direction:a}],!1,a)}seekFrame(r,i){if(!Number.isFinite(i)||i<=0)throw new Error(`[AnimationClock] seekFrame fps must be a finite number > 0, got ${i}`);return this.seek(this._range.start+r/i)}advance(r){if(this._playbackState!=="playing")return null;if(!Number.isFinite(r))throw new Error(`[AnimationClock] advance(dt) requires a finite dt, got ${r}`);const i=Math.abs(r)*this._timeScale,a=this._currentTime;if(i===0)return this.emit(a,a,[],!1,this._playDirection);const l=this._playDirection==="forward"?gkn(a,i,this._range):ykn(a,i,this._range);return this._previousTime=a,this._currentTime=l.pos,this._lastCrossingDirection=this._playDirection,this.emit(a,l.pos,l.intervals,l.looped,this._playDirection)}subscribe(r,i){if(!O_e.includes(r))throw new Error(`[AnimationClock] unknown phase "${r}". Valid: ${O_e.join(", ")}`);const a={phase:r,order:this._registrationCounter++,fn:i};return this._evaluators.push(a),{dispose:()=>{const l=this._evaluators.indexOf(a);l!==-1&&this._evaluators.splice(l,1)}}}emit(r,i,a,l,d){const _={previousTime:r,currentTime:i,direction:d,timeScale:this._timeScale,looped:l,intervals:a};if(this._evaluators.length>0){const g=[...this._evaluators].sort((b,S)=>{const k=O_e.indexOf(b.phase),w=O_e.indexOf(S.phase);return k!==w?k-w:b.order-S.order});for(const b of g)try{b.fn(_)}catch(S){console.error(`[AnimationClock] evaluator in phase "${b.phase}" threw:`,S)}}return _}}const F_e={start:0,end:0,fps:30},bkn=150;class r6n{constructor(r){this.store=r,this.stopStoreWatch=r.subscribe(()=>this.notify())}clock=new vkn;subjects=[];activeId=null;listeners=new Set;settleListeners=new Set;settleTimer=null;disposed=!1;cachedSnapshot=null;stopStoreWatch;attach(r){return this.subjects.push(r),this.activeId===null?this.setActiveSubject(r.id):this.notify(),()=>{const i=this.subjects.indexOf(r);if(i<0)return;if(this.subjects.splice(i,1),this.activeId!==r.id){this.notify();return}this.activeId=null;const a=this.subjects[0];a?this.setActiveSubject(a.id):(this.clock.setRange({start:F_e.start,end:F_e.end,loop:!1}),this.notify())}}setActiveSubject(r){const i=this.subjects.find(l=>l.id===r);if(!i)return;this.activeId=r;const a=i.range();this.clock.setRange({start:a.start,end:a.end}),this.applyTime(this.clock.time),this.notify()}get active(){return this.subjects.find(r=>r.id===this.activeId)??null}fps(){return this.active?.range().fps??F_e.fps}get driver(){return this.store.playState==="stopped"?"editor":"world"}assertEditorDrives(){if(this.driver==="world")throw new Error("transport: the world is driving time (Play); pause the game to scrub")}play(r="forward"){this.assertEditorDrives(),this.active&&(this.cancelSettle(),this.clock.play(r),this.notify())}pause(){this.assertEditorDrives(),this.clock.pause(),this.cancelSettle(),this.settle(),this.notify()}stop(){this.assertEditorDrives(),this.clock.pause(),this.cancelSettle(),this.applyTime(this.clock.seek(this.clock.range.start).currentTime),this.clock.stop(),this.settle(),this.notify()}seek(r){this.assertEditorDrives(),this.applyTime(this.clock.seek(r).currentTime),this.clock.playbackState!=="playing"&&this.scheduleSettle(),this.notify()}seekFrame(r){this.seek(r/this.fps())}setLoop(r){this.clock.setRange({loop:r}),this.notify()}setTimeScale(r){this.clock.timeScale=r,this.notify()}tick(r){if(this.disposed||this.driver==="world"||this.clock.playbackState!=="playing")return 0;const i=this.clock.time,a=this.clock.advance(r);return a?(this.applyTime(a.currentTime),this.notify(),a.looped?Math.abs(r)*this.clock.timeScale:a.currentTime-i):0}applyTime(r){const i=this.active;i&&i.seek(r);for(const a of this.subjects)a!==i&&a.seek(r)}onSettled(r){return this.settleListeners.add(r),()=>{this.settleListeners.delete(r)}}scheduleSettle(){this.cancelSettle(),this.settleTimer=setTimeout(()=>{this.settleTimer=null,this.settle()},bkn)}cancelSettle(){this.settleTimer!==null&&(clearTimeout(this.settleTimer),this.settleTimer=null)}settle(){if(this.disposed)return;const r=this.clock.time;for(const i of[...this.settleListeners])i(r)}snapshot(){const r=this.cachedSnapshot;if(r)return r;const i=this.active?.range()??F_e,a={time:this.clock.time,range:{start:this.clock.range.start,end:this.clock.range.end,fps:i.fps,loop:this.clock.range.loop},playbackState:this.clock.playbackState,timeScale:this.clock.timeScale,activeSubject:this.activeId,subjects:this.subjects.map(l=>({id:l.id,label:l.label})),driver:this.driver};return this.cachedSnapshot=a,a}activeClips(){const i=this.active?.clips?.();return i&&i.length>1?i:null}setActiveClip(r){this.assertEditorDrives(),this.active?.setClip?.(r);const i=this.active?.range();i&&this.clock.setRange({start:i.start,end:i.end}),this.applyTime(this.clock.time),this.notify()}subscribe(r){return this.listeners.add(r),()=>{this.listeners.delete(r)}}notify(){this.cachedSnapshot=null;for(const r of[...this.listeners])r()}dispose(){this.disposed=!0,this.stopStoreWatch(),this.cancelSettle(),this.clock.stop(),this.subjects.length=0,this.activeId=null,this.listeners.clear(),this.settleListeners.clear()}}const ehe=new Map,Mqe=new Set;function XTt(){for(const t of[...Mqe])t()}function n6n(t,r){return ehe.set(t,r),XTt(),()=>{ehe.get(t)===r&&(ehe.delete(t),XTt())}}function Akn(t){return t===null?null:ehe.get(t)??null}function Skn(t){return Mqe.add(t),()=>{Mqe.delete(t)}}const gKt="__vgaiWorkspacePersistenceSuppressed";function yKt(){return globalThis}function vKt(t){yKt()[gKt]=t}function xkn(){return yKt()[gKt]===!0}function bKt(){return(_0e()?.immersivePlay??!1)&&!P8().play?.keepPanelsVisible}function wkn(t){return Math.min(1600,Math.max(800,900+t*25))}function Ckn(t){return t<.5?4*t*t*t:1-(-2*t+2)**3/2}function AKt(t,r,i=new Tc(0,1,0)){const a=new Tc().subVectors(r,t),l=a.length();if(l<1e-6)return[t.clone(),t.clone(),r.clone(),r.clone()];const d=Math.min(l*.18,6),_=new Tc().crossVectors(a,i);_.lengthSq()>1e-9?_.normalize().multiplyScalar(Math.min(l*.08,2.5)):_.set(0,0,0);const g=i.clone().normalize().multiplyScalar(d),b=t.clone().addScaledVector(a,.3).add(g).add(_),S=r.clone().addScaledVector(a,-.3).addScaledVector(g,.6).addScaledVector(_,.5);return[t.clone(),b,S,r.clone()]}const SKt={phase:"idle",flightDone:!1,gameReady:!1};function Ekn(t,r){const i=t.flightDone||r==="flight-done",a=t.gameReady||r==="game-ready";return i&&a?{phase:"crossfade",flightDone:i,gameReady:a}:i?{phase:"holding",flightDone:i,gameReady:a}:{...t,flightDone:i,gameReady:a}}function Tkn(t,r){if(r==="stop")return SKt;switch(t.phase){case"idle":return r==="start"?{phase:"entering",flightDone:!1,gameReady:!1}:r==="start-reduced"?{phase:"playing",flightDone:!0,gameReady:!0}:t;case"entering":return Ekn(t,r);case"holding":return r==="game-ready"?{...t,phase:"crossfade",gameReady:!0}:t;case"crossfade":return r==="crossfade-done"?{...t,phase:"playing"}:t;case"playing":return t}}const kkn=450,Ikn=220,xKt=250;function Dkn(t){t.style.setProperty("--vgai-play-dissolve-duration",`${kkn}ms`),t.style.setProperty("--vgai-play-materialize-duration",`${Ikn}ms`),t.style.setProperty("--vgai-play-crossfade-duration",`${xKt}ms`)}let PP=null;function Pkn(t){return PP=t,typeof document<"u"&&Dkn(document.documentElement),()=>{PP===t&&(PP=null)}}function wKt(){return typeof window<"u"&&(window.matchMedia?.("(prefers-reduced-motion: reduce)").matches??!1)}const Nkn=1<<31;function Okn(t){return(t.layers.mask&Nkn)!==0||/gizmo/i.test(t.name)}function CKt(t){if(Okn(t))return null;if(t.isCamera)return t;for(const r of t.children){const i=CKt(r);if(i)return i}return null}function Fkn(t,r,i){const a=new Tc,l=new G8;return r.getWorldPosition(a),r.getWorldQuaternion(l),{entityId:t,position:a.toArray(),quaternion:l.toArray(),fov:i}}function Rkn(t){for(const[r,i]of t.objectMap){const a=CKt(i);if(!a)continue;const l=a;return Fkn(r,a,l.isPerspectiveCamera?l.fov:60)}return null}let kE=null;function Mkn(){return kE?.state.phase??"idle"}const the=new Set;function EKt(){if(the.size===0)return;const t=[...the];the.clear();for(const r of t)r()}function Lkn(t){if(!kE||kE.state.phase==="playing"){t();return}the.add(t)}function jkn(t,r,i){const a=setTimeout(()=>{t.timeouts.delete(a),i()},r);t.timeouts.add(a)}function Bkn(t){t.curve=new Okt(AKt(t.startPos,t.endPos))}function Zq(t){const r=kE;if(!r)return;const i=r.state,a=Tkn(i,t);a!==i&&(r.state=a,a.phase==="crossfade"&&i.phase!=="crossfade"&&(PP?.root.classList.add("vgai-play-crossfade"),jkn(r,xKt+30,()=>Zq("crossfade-done"))),a.phase==="playing"&&i.phase!=="playing"&&(PP?.root.classList.remove("vgai-play-flight","vgai-play-crossfade"),$kn(),EKt()))}function $kn(){const t=gte(),r=kE;if(!t||!r?.flight)return;const i=t.camera,a=new Tc(0,0,-1).applyQuaternion(i.quaternion),l=r.cameraSnapshot?Math.max(1,r.cameraSnapshot.position.distanceTo(r.cameraSnapshot.target)):5;t.orbit.target.copy(i.position).addScaledVector(a,l),t.orbit.enabled=!0}function qkn(){const t=bKt(),r=Qh();zkn(t&&r?Rkn(r):null,{immersive:t})}function zkn(t,r){if(kE&&gKe(),!r.immersive)return;const i=wKt();vKt(!0);const a={state:SKt,reducedMotion:i,flight:null,cameraSnapshot:null,getLiveCamera:null,timeouts:new Set};if(kE=a,PP?.hideChrome(!i),i){Zq("start-reduced");return}Zq("start");const l=gte();if(!t||!l){Zq("flight-done");return}a.cameraSnapshot={position:l.camera.position.clone(),target:l.orbit.target.clone(),fov:l.camera.fov};const d=l.camera.position.clone(),_=new Tc().fromArray(t.position),g={startPos:d,startQuat:l.camera.quaternion.clone(),startFov:l.camera.fov,endPos:_,endQuat:new G8().fromArray(t.quaternion),endFov:t.fov,curve:new Okt(AKt(d,_)),startedAt:performance.now(),durationMs:wkn(d.distanceTo(_)),landed:!1};a.flight=g,l.orbit.enabled=!1,PP?.root.classList.add("vgai-play-flight")}function Ukn(t,r){(!t||!r)&&gKe()}function Vkn(t){const r=kE;r&&(r.getLiveCamera=t??null,Zq("game-ready"))}const d9e=new Tc,ZTt=new G8;vQt(Jkn);function Jkn(){const t=kE,r=gte(),i=t?.flight;if(!t||!r||!i)return;const a=t.state.phase;if(a!=="entering"&&a!=="holding"&&a!=="crossfade")return;const l=t.getLiveCamera?.()??null;if(l){l.getWorldPosition(d9e),l.getWorldQuaternion(ZTt),d9e.distanceToSquared(i.endPos)>1e-8&&(i.endPos.copy(d9e),Bkn(i)),i.endQuat.copy(ZTt);const b=l.fov;typeof b=="number"&&(i.endFov=b)}const d=r.camera;if(i.landed){d.position.copy(i.endPos),d.quaternion.copy(i.endQuat),d.fov!==i.endFov&&(d.fov=i.endFov,d.updateProjectionMatrix());return}const _=Math.min(1,(performance.now()-i.startedAt)/i.durationMs),g=Ckn(_);d.position.copy(i.curve.getPoint(g)),d.quaternion.slerpQuaternions(i.startQuat,i.endQuat,g),d.fov=i.startFov+(i.endFov-i.startFov)*g,d.updateProjectionMatrix(),_>=1&&(i.landed=!0,Zq("flight-done"))}function gKe(){const t=kE;if(!t)return;kE=null;for(const i of t.timeouts)clearTimeout(i);t.timeouts.clear(),EKt(),PP?.root.classList.remove("vgai-play-flight","vgai-play-crossfade");const r=gte();if(r&&t.cameraSnapshot){const i=t.cameraSnapshot;r.camera.position.copy(i.position),r.orbit.target.copy(i.target),r.camera.lookAt(i.target),r.camera.fov!==i.fov&&(r.camera.fov=i.fov,r.camera.updateProjectionMatrix()),r.orbit.enabled=!0,r.orbit.update()}else r&&t.flight&&(r.orbit.enabled=!0);PP?.showChrome(!wKt()),vKt(!1)}const Lqe=new Set;let TKt=null;function kKt(){return ad()?.rootPath??null}function Wkn(t){Lqe.add(t);const r=kKt();return r!==null&&TKt===r&&t(),()=>{Lqe.delete(t)}}async function i6n(){TKt=kKt();for(const t of[...Lqe])await t()}function Hkn(){const t=I_();if(t===null)return null;const r=_Z(t);if(typeof r!="object"||r===null)return null;const i=r.stageMode;if(typeof i!="function")return null;const a=i.call(r);return typeof a=="string"?a:null}const Gkn=new Map;let jqe=null;function Qkn(t){jqe=t}function ekt(){if(!jqe)throw new Error("The workbench Output service is not connected.");return jqe}function Kkn(){TLr(I_),AMr({output:{write:(...t)=>ekt().write(...t),show:t=>ekt().show(t)},console:{log:(t,r)=>ua.log(t,r),warn:(t,r)=>ua.warn(t,r),error:(t,r)=>ua.error(t,r)},live:{register:LHt,mounted:DQe,playing:tbe,runWindow:xQe,restartRequired:FHt,restart:RHt,subscribe:NQe,version:BHt,notifyChanged:OHt,snapshotFrame:CQe,frameCanvas:wQe,authoringRefusal:IQe,dispatch:EQe,scenes:TQe,surface:ebe,coverage:kQe},viewport:{rig:gte,presentRoots:K2n,onFrame:vQt,setHelper:Q2n,stages:bQt,onStages:X2n,transition:{begin:qkn,ready:Vkn,end:gKe,onSettled:Lkn,phase:Mkn}},hierarchy:{object:t=>Qh()?.objectMap.get(t)??null,objects:()=>Qh()?.objectMap??Gkn,subscribe:t=>{const r=Hpe(t),i=Qh()?.subscribe(t);return()=>{r(),i?.()}},version:()=>{const t=Qh();return t?.getShellSnapshot?.()??t?.getSnapshot()??0}},session:{reportFacet:Hgn,onSample:Ryn,onCommandDispatched:aqr,playState:()=>Qh()?.playState??"stopped",playEditRegime:()=>Qh()?.playEditRegime??null,subscribe:t=>{const r=Hpe(t),i=Qh()?.subscribe(t);return()=>{r(),i?.()}},version:()=>{const t=Qh();return t?.getShellSnapshot?.()??t?.getSnapshot()??0},open:()=>Qh()!==null,onEnded:t=>HUe(r=>{r!==null&&t()}),onBeforeClose:nyn,reportWorkerCallMeter:eAn},project:{documentTable:bmn,mounts:cz,engineVersion:()=>ad()?.config.engine.version??null,subscribe:Iw,onReady:Wkn},notify:t=>az(t),systems:{inspected:yze,subscribe:EOr,inspectedNetworking:DOr,subscribeNetworking:POr,inspectedAudio:()=>NOr()??null,subscribeAudio:OOr,audioVersion:FOr},availability:{subscribe:WQt,version:jwn},workspace:{showUtility:hE,openContributedDocument:t=>fI(null,t),open:async t=>await y0e(t.kind,Qh()??{setActiveViewportTab:()=>{}},t)!==null,liveDocument:{id:Sw,register:o2n,acquire:u2n,release:tKe,open:_be,container:a2n,setContainer:c2n,releaseContainer:l2n}},documents:{activeId:I_,active:()=>{const t=AE();return t?{id:t.descriptor.id,kind:t.descriptor.kind,title:t.title}:null},subscribe:Aw,version:Sb,context:_Z,waitForContext:w3t,contextChanged:BFr},transport:{for:t=>Akn(t),subscribe:Skn},projectLocalState:{ready:pte,read:WQe,write:ube,projectRootPath:()=>ad()?.rootPath??null},history:{record:B4t,setDelegate:CLr,onElement:ILr,invalidate:DLr,onInvalidated:PLr,changed:ELr,elements:kLr,focusedResource:()=>{const t=AE();if(!t)return null;const r=t.descriptor.provenance?.sourcePath;if(r)return r;const i=Qh();return i?nqr(i)??UUe(i):null},undo:()=>Qh()?.projectHistory?.undo()??Promise.resolve(!1),redo:()=>Qh()?.projectHistory?.redo()??Promise.resolve(!1),canUndo:()=>Qh()?.projectHistory?.getSnapshot().canUndo??!1,canRedo:()=>Qh()?.projectHistory?.getSnapshot().canRedo??!1,undoLabel:()=>Qh()?.projectHistory?.getSnapshot().undoLabel??null,redoLabel:()=>Qh()?.projectHistory?.getSnapshot().redoLabel??null,subscribe:t=>{const r=j4t(t),i=Hpe(t),a=Qh()?.projectHistory?.subscribe(t),l=Aw(t);return()=>{r(),i(),a?.(),l()}}},files:{setProvider:ZMr,read:t=>Qg.read(t),readBytes:t=>Qg.readBytes(t),write:(t,r)=>Qg.write(t,r),exists:t=>Qg.exists(t),list:t=>Qg.list(t),watch:t=>Qg.watch(t)},settings:{setProvider:A7r,get:T7r,set:I7r,inspect:K3t,subscribe:t=>{const r=H3t(t),i=Eee(t);return()=>{r(),i()}}},keyboard:{actions:()=>FAn().map(({id:t,scope:r})=>({id:t,scope:r})),keymaps:()=>Y3t().map(({id:t,title:r})=>({id:t,title:r,chords:nPt(t)})),activeKeymap:uI,invoke:t=>LAn(t),subscribe:t=>{const r=MAn(t),i=oU(t),a=Hpe(t),l=Qh()?.subscribe(t),d=Aw(t);return()=>{r(),i(),a(),l?.(),d()}},version:()=>RAn()+Sb(),stage:()=>{const t=Qh();return t?{surface:lyn(t).surface,mode:Hkn()}:{surface:null,mode:null}}}})}let Ykn=0,hee=null;const Bqe=new Set;function tkt(t){const r={generation:++Ykn,promise:t,active:!0};hee=r;for(const i of Bqe)i(r);return Bqe.clear(),r}function Xkn(){const t=hee;return t?.active?Promise.resolve(t):new Promise(r=>Bqe.add(r))}async function yKe(){for(;;){const t=await Xkn();if(await t.promise,hee===t&&t.active)return}}const IKt=15,Zkn=300,eIn=1e4,DKt="workspace";function tIn(){const t=WQe(DKt);return!t||t.version!==IKt?null:t}function rIn(t){ube(DKt,t)}function nIn(t){const{descriptor:r}=t;if(!r.persist)return null;let i;try{i=r.persist({id:r.id,title:t.title})}catch{return null}return i==null?null:{kind:r.kind,id:r.id,state:i}}function iIn(){const t={};let r=!1;for(const i of dPt()){if(!i.persistKindState)continue;let a;try{a=i.persistKindState()}catch{continue}a!=null&&(t[i.kind]=a,r=!0)}return r?t:void 0}function sIn(){const t=[];for(const i of FA()){const a=nIn(i);a&&t.push(a)}const r=iIn();return{version:IKt,workspace:wS(),documents:{open:t,activeId:I_(),...r?{kinds:r}:{}}}}async function oIn(t,r,i){for(const a of fPt(r.kind))try{if(await a.restore({id:r.id,state:r.state,active:r.id===i,store:t}))return!0}catch{}return!1}function rkt(t){return t?s9(t)?!0:pjr.has(t)?($mn(t),o5r(t),!0):xb(t):!1}function aIn(t,r){const i=r?.kinds??{},a=(r?.open.length??0)>0;for(const l of dPt())if(l.beginRestore)try{l.beginRestore({state:i[l.kind],hasDocumentsToRestore:a,store:t})}catch{}}function cIn(t){const r=new Set;for(const i of t)for(const a of fPt(i.kind))a.prepare&&r.add(a.prepare);return Promise.all([...r].map(i=>i().catch(()=>{})))}async function lIn(t,r){const i=r?.documents;if(aIn(t,i),!i||i.open.length===0){rkt(i?.activeId??null);return}await cIn(i.open);for(const a of i.open)await oIn(t,a,i.activeId);rkt(i.activeId)}function PKt(t){if(!pte()||ad()&&!v1()){let J=!1,X=null,G=()=>{};const ee=new Promise(ue=>{G=ue}),xe=tkt(ee);return Promise.all([lbe(),uQe()]).then(()=>{if(J){G();return}X=PKt(t),xe.active=!1,yKe().finally(G)}),()=>{J=!0,X?.()}}const r=tIn();r?.workspace&&SZ(r.workspace)&&CP(r.workspace)?CS(r.workspace):CS(uz(),{provisional:!0});let i=!1,a=null;const l=[],d=()=>{a!==null&&(clearTimeout(a),a=null),!(xkn()||t.playState!==void 0&&t.playState!=="stopped")&&rIn(sIn())},_=()=>{a!==null&&clearTimeout(a),a=setTimeout(d,Zkn)},g=()=>d();let b=null;const S=typeof window<"u"&&mIt(window.location.href)!==null,k=S||!(r?.documents?.open.length??0)?Promise.resolve():O8().catch(()=>{}),w=k.then(()=>S?void 0:lIn(t,r)).catch(()=>{}),N=new Promise(J=>{k.then(()=>{i||(b=setTimeout(()=>{J()},eIn))})}),P=Promise.race([w,N]).then(()=>{b!==null&&clearTimeout(b),!i&&(l.push(Aw(_)),window.addEventListener("pagehide",g))}),j=tkt(P);return()=>{i=!0,j.active=!1,hee===j&&(hee=null),b!==null&&clearTimeout(b);for(const J of l)J();window.removeEventListener("pagehide",g),a!==null&&d()}}function uIn(t){Xe.useEffect(()=>{const r=mIt(window.location.href);if(!r)return;let i=!1;const a=hh(),l=()=>!i&&hh()===a;return yKe().then(()=>{if(l())return bye(t,r,{updateUrl:!1,origin:"link"})}).catch(d=>{ua.error(`Could not restore shared editor view: ${d instanceof Error?d.message:String(d)}`,"editor")}),()=>{i=!0}},[t])}const nkt="vgai:stale-chunk-reload";function fIn(){typeof window>"u"||window.addEventListener("vite:preloadError",t=>{let r=0;try{r=Number(sessionStorage.getItem(nkt)??0)}catch{}if(!(Date.now()-r<6e4)){try{sessionStorage.setItem(nkt,String(Date.now()))}catch{}t.preventDefault(),window.location.reload()}})}const G$=[];function dIn(t){const r=G$.findIndex(i=>i.owner===t.owner&&i.id===t.id);return r>=0&&G$.splice(r,1),G$.push(t),G$.sort((i,a)=>(i.order??0)-(a.order??0)),()=>{const i=G$.indexOf(t);i>=0&&G$.splice(i,1)}}function pIn(t,r){const i=[];for(const a of Object.keys(r).sort())i.push(`${a}=${_In(r[a])}`);return`${t}|${i.join("&")}`}function _In(t){if(typeof t=="function")return"fn";if(typeof t=="symbol")return"symbol";if(t===void 0)return"undefined";try{return JSON.stringify(t)??"undefined"}catch{return`[${typeof t}]`}}const Rye=new Map,R_e=new Map,ikt=new WeakMap;let skt=Promise.resolve(),okt=null,mIn=1;function hIn(){return typeof WebGLRenderingContext<"u"&&typeof navigator<"u"&&!navigator.userAgent.toLowerCase().includes("jsdom")}async function gIn(){await Promise.race([r0e(),new Promise(t=>setTimeout(t,5e3))]),await Promise.race([new Promise(t=>requestAnimationFrame(()=>requestAnimationFrame(()=>t()))),new Promise(t=>setTimeout(t,250))]),await new Promise(t=>setTimeout(t,750)),await new Promise(t=>{const r=globalThis.requestIdleCallback;if(typeof r=="function"){r(()=>t(),{timeout:2e3});return}setTimeout(t,0)})}function yIn(){return okt??=gIn(),okt}function vIn(t){const r=ikt.get(t);if(r!==void 0)return r;const i=mIn++;return ikt.set(t,i),i}function bIn(t,r,i,a){const l=Rye.get(t);if(l)return Promise.resolve(l);const d=R_e.get(t);if(d)return d;const _=skt.then(async()=>{await yIn();const g=i.parameters.layout,b=g==="fullscreen"||g==="padded"||g==="centered"?g:"padded",S={...a,props:i.args,layout:b};if(r==="canvas"){const{capturePixiStoryThumbnail:w}=await Xo(async()=>{const{capturePixiStoryThumbnail:N}=await import("./story-pixi-preview-D7WHysVb.js");return{capturePixiStoryThumbnail:N}},__vite__mapDeps([80,3,2,4,81,1,8,9,10,11,6]));return w(i.Component,S)}const{captureStoryComponentThumbnail:k}=await Xo(async()=>{const{captureStoryComponentThumbnail:w}=await import("./story-three-preview-DLodiWJL.js");return{captureStoryComponentThumbnail:w}},__vite__mapDeps([82,3,2,4,81,6,64,11,9,1,8,10]));return k(i.Component,S)});return skt=_.then(()=>{},()=>{}),R_e.set(t,_),_.then(g=>{Rye.set(t,g),R_e.delete(t)},()=>R_e.delete(t)),_}function AIn({component:t,story:r,previewRevision:i,width:a=128,height:l=96}){const d=r.Component,_=`${t.surface}:${t.path}:${pIn(r.id,r.args)}:${vIn(d)}:${i}:${a}x${l}`,[g,b]=Xe.useState(()=>Rye.get(_)),[S,k]=Xe.useState(!1);return Xe.useEffect(()=>{let w=!1;if(k(!1),b(Rye.get(_)),!!hIn())return bIn(_,t.surface,r,{width:a,height:l}).then(N=>{w||b(N)},()=>{w||k(!0)}),()=>{w=!0}},[t.surface,l,_,r,a]),g?z.jsx("img",{src:g,alt:`${t.name} preview`,className:"vgai-component-thumbnail"}):z.jsx("span",{className:"vgai-component-thumbnail-fallback","data-component-preview":S?"failed":"capturing-story",children:z.jsx(a9,{kind:"component",name:t.name})})}const bbe="story:three",Abe="story:isolated",SIn="story:docs";function xIn(t,r){return t.surface==="dom"?!1:r===null||t.surface===r}function wIn({entry:t,previewRevision:r,width:i,height:a}){const l=t.detail;return z.jsx(AIn,{component:t.component,story:l,previewRevision:r,...i===void 0?{}:{width:i},...a===void 0?{}:{height:a}})}const CIn="story",EIn={id:CIn,owner:"./component-content-source",entries(t){const r=Q1e(),i=[];for(const a of t.components){if(!xIn(a,t.surface))continue;const l=dmn(r,a.name,a.path);l&&i.push({id:`${a.path}:${a.name}`,component:a,detail:l})}return i},subscribe:K1e,Thumbnail:wIn,open(t,r,i){const a=r.detail,l=r.component.surface==="three";FP(l?bbe:Abe,t,l?{modulePath:a.modulePath,storyName:a.name,title:i}:{modulePath:a.modulePath,storyName:a.name})}};function akt(t){return pmn(t.name,t.sourcePath)}const TIn={id:"portable-csf",owner:"./component-states",statesFor:(t,r)=>r.surface==="dom"?[]:akt(t).map(i=>({id:i.id,label:i.label})),apply:(t,r,i)=>{const a=akt(t).find(l=>l.id===r);if(a){if(i.surface==="three"){FP(bbe,i.store,{modulePath:a.modulePath,storyName:a.name,title:a.label});return}if(i.surface==="canvas"){FP(Abe,i.store,{modulePath:a.modulePath,storyName:a.name});return}ua.warn(`[portable-csf] no story document is registered for the "${i.surface}" surface, so state "${r}" of "${t.name}" could not be opened.`,"authoring")}}};function kIn(){let t=0,r=!1;const i=g=>{const b=++t;smn(),r0e().then(()=>{if(!(r||b!==t))return gmn(ad(),void 0,{deferUndeclared:!0,...g?{changedPaths:g}:{}})})};i();let a=null;const l=XNt(),d=Iw(()=>i()),_=jUr(i);return()=>{r=!0,t+=1,a!==null&&clearTimeout(a),l(),d(),_()}}const NKt="story",p9e=new Set,_9e=new Set;function IIn(t){const r=IWt({modulePath:t.modulePath,title:t.title}).leaf;return r===t.label?r:`${r} · ${t.label}`}function m9e(t){for(const r of Q1e())if(r.ok){for(const i of r.stories)if(t.storyId===void 0?r.modulePath===t.modulePath&&i.name===t.storyName:i.id===t.storyId)return{modulePath:r.modulePath,storyName:i.name,title:t.title??IIn({modulePath:r.modulePath,title:i.title,label:i.label})}}return null}function DIn(t,r,i){const a={modulePath:i.modulePath,storyName:i.storyName,title:i.title,...r.activate===void 0?{}:{activate:r.activate}};if(r.mode==="docs")return FP(SIn,t,a);const l=cQe({modulePath:i.modulePath,regions:aQe()});return l.medium===void 0?(imn(i.modulePath,l.reason),null):FP(l.medium==="three"?bbe:Abe,t,a)}function ckt(t){ua.warn(`No composed portable story carries the id ${JSON.stringify(t)}, so nothing opened it.`,"editor")}function PIn(){return g9({id:NKt,owner:"./story-opener",open:(t,r)=>{const i=m9e(r);return i?DIn(t,r,i):(r.modulePath?p9e.add(r.modulePath):r.storyId!==void 0&&(_9e.add(r.storyId),lmn()&&ckt(r.storyId)),null)},settle:async()=>{await ijr();const t=[...p9e],r=[..._9e];if(p9e.clear(),_9e.clear(),await Promise.all(t.map(i=>_mn(ad(),i))),r.length!==0){await umn();for(const i of r)m9e({storyId:i})||ckt(i)}},ready:async(t,r)=>{if(r.mode==="docs")return;const i=m9e(r);if(!(!i||cQe({modulePath:i.modulePath,regions:aQe()}).medium!=="three")&&!await xE(()=>Pw(t)!==null,m9))throw new Error(`The requested Object3D view did not mount for document: ${t}`)}})}const NIn={actions:()=>{if(!NAt(Abe)&&!NAt(bbe))return[];const t=[];for(const r of Q1e()){if(!r.ok)continue;const i=r.modulePath.split("/").pop()??r.modulePath;for(const a of r.stories)t.push({id:`story:${a.id}`,label:`Open Story: ${a.name} — ${i}`,execute:()=>void fv().workspace.open({kind:NKt,modulePath:r.modulePath,storyName:a.name,title:a.name})})}return t},subscribe:t=>K1e(t)},OIn="packages/editor/src/stories/story-capture-command.ts",uq="capture-story-variants";async function FIn(t){if(document.visibilityState==="hidden")return{ok:!1,error:"story capture needs a PRESENTING tab — the editor tab is hidden, so the browser suspends the frames a story mount must paint. Bring the editor tab to the foreground (or unminimize its window) and re-run."};const r=t.modulePath;if(typeof r!="string"||r==="")return{ok:!1,error:`${uq} requires a project-relative modulePath.`};const i=t.story;if(i!==void 0&&typeof i!="string")return{ok:!1,error:`${uq} story must be a CSF export name.`};const a=(l,d,_)=>{if(l===void 0)return d;if(typeof l!="number"||!Number.isInteger(l)||l<64||l>1024)throw new Error(`${uq} ${_} must be an integer from 64 to 1024.`);return l};try{const l=await(async()=>{try{const w=await ige("vgai.project.json");if(!w)return null;const N=JSON.parse(w),P=N.resolution?.width,j=N.resolution?.height;return typeof P!="number"||typeof j!="number"||P<64||j<64||P>4096||j>4096?null:{width:Math.min(1024,Math.round(P)),height:Math.min(1024,Math.round(j))}}catch{return null}})(),d=a(t.width,l?.width??960,"width"),_=a(t.height,l?.height??540,"height"),g=uNt(uq,t.camera);if(typeof g=="string")return{ok:!1,error:g};const b=fNt(uq,t.pose);if(typeof b=="string")return{ok:!1,error:b};const{captureProjectStoryVariants:S}=await Xo(async()=>{const{captureProjectStoryVariants:w}=await import("./story-capture-BcOlOwLt.js");return{captureProjectStoryVariants:w}},__vite__mapDeps([83,60,1,2,3,4,8,9,10,80,81,11,6,82,64]));return{ok:!0,data:{...await S(ad(),{modulePath:r,...i===void 0?{}:{story:i},width:d,height:_,...g?{camera:g}:{},...b?{pose:b}:{}})}}}catch(l){return{ok:!1,error:l instanceof Error?l.message:String(l)}}}const RIn={[uq]:{timeoutMs:12e4,derivedRefresh:"if-content-changed",handle:FIn}};function MIn(){const t=Q0n(EIn),r=dIn(TIn),i=PIn(),a=SIt(NIn),l=wIt(OIn,RIn),d=kIn(),_=K1e(()=>{Gq()});return()=>{_(),d(),l(),a(),i(),r(),t()}}let h9e=null;const LIn=new Set;function jIn(t){return h9e=t,$qe(),()=>{h9e===t&&(h9e=null,$qe())}}function $qe(){for(const t of LIn)t()}let Mm=null,OKt=0;const qqe=new Set;function BIn(t){return qqe.add(t),()=>qqe.delete(t)}function lkt(){return OKt}function $In(t,r){if(Mm){if(r===null){if(Mm[t]?.isConnected)return}else if(Mm[t]===r)return;if(r===null&&(t==="outliner"||t==="properties"||t==="content")){const i={...Mm};delete i[t],Mm=i}else r!==null&&(Mm={...Mm,[t]:r});r!==null&&FKt(t,r),OKt+=1;for(const i of qqe)i()}}function FKt(t,r){r.dataset.vgaiPart=t}const ez=new Map;let RKt=0;const zqe=new Set;function qIn(t,r){if(r){if(!ez.delete(t.id))return}else{const i=ez.get(t.id);if(i?.element===t.element&&i.documentId===t.documentId)return;ez.set(t.id,{...t})}RKt+=1;for(const i of[...zqe])i()}function zIn(t){return zqe.add(t),()=>{zqe.delete(t)}}function ukt(){return RKt}function ER({children:t,row:r=!1,center:i=!1}){return z.jsx("div",{className:"vgai-editor-shell vgai-part",onWheel:a=>a.stopPropagation(),"data-editor-hotkey-scope":"workspace","data-editor-hotkey-fallback":!0,style:{display:"flex",flexDirection:r?"row":"column",justifyContent:i?"center":void 0,width:"100%",height:"100%",minHeight:0,minWidth:0,position:"relative",fontFamily:"var(--vgai-font-sans)",fontSize:"var(--vgai-font-base)",color:"var(--vgai-content-primary)"},children:t})}function UIn({children:t}){return z.jsx(z.Fragment,{children:t})}function VIn(){return Mm?vS.createPortal(z.jsx(ER,{center:!0,children:z.jsx(VEn,{})}),Mm.header):null}function JIn(){return null}function WIn(){const t=Xe.useRef(null);return Xe.useEffect(()=>{const r=t.current;if(r)return eKt(r),()=>uCn(r)},[]),z.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",minHeight:0},children:[z.jsx("div",{ref:t,className:"vgai-vscode-outliner-header"}),z.jsx("div",{style:{flex:1,minHeight:0,display:"flex",flexDirection:"column"},children:z.jsx(oKt,{})})]})}const rhe=new Map,Uqe=new Set;let Vqe=0;function HIn(t,r){if(r){if(rhe.get(t)===r)return;rhe.set(t,r)}else if(!rhe.delete(t))return;Vqe++;for(const i of Uqe)i()}const nhe=new Map,Jqe=new Set;let Wqe=0;function GIn(t,r){if(r){if(nhe.get(t)===r)return;nhe.set(t,r)}else if(!nhe.delete(t))return;Wqe++;for(const i of Jqe)i()}function QIn(){return Xe.useSyncExternalStore(BDt,Ubt,Ubt),Xe.useSyncExternalStore(t=>(Jqe.add(t),()=>Jqe.delete(t)),()=>Wqe,()=>Wqe),z.jsx(z.Fragment,{children:[...U9e("left"),...U9e("right")].map(t=>{const r=nhe.get(t.id);if(!r)return null;const i=t.Content;return z.jsx(Xe.Fragment,{children:vS.createPortal(z.jsx(i,{}),r)},t.id)})})}function KIn(){return Xe.useSyncExternalStore(g0e,PAt,PAt),Xe.useSyncExternalStore(t=>(Uqe.add(t),()=>Uqe.delete(t)),()=>Vqe,()=>Vqe),z.jsx(z.Fragment,{children:gE().map(t=>{const r=rhe.get(t.id);return r?z.jsx(Xe.Fragment,{children:vS.createPortal(z.jsx(ER,{children:z.jsx(HEn,{utility:t})}),r)},t.id):null})})}function YIn({descriptor:t,viewId:r,slot:i,parking:a,visible:l,inspector:d}){const[_]=Xe.useState(()=>document.createElement("div"));return Xe.useLayoutEffect(()=>{_.className="vgai-vscode-document-slot",_.dataset.vgaiDocument=t.id,_.dataset.vgaiArea=t.area??"",_.style.cssText=`display:${l?"flex":"none"};flex-direction:column;width:100%;height:100%;min-width:0;min-height:0;position:relative;`},[_,t.id,t.area,l]),Xe.useLayoutEffect(()=>((i??a).appendChild(_),()=>_.remove()),[_,i,a]),vS.createPortal(z.jsxs(ER,{children:[z.jsx(wQt,{descriptor:t,viewId:r,active:l,chrome:!t.area}),d&&z.jsx(Wwn,{})]}),_)}let MKt=!0;function XIn({arrangement:t,immersivePlay:r}){const i=D0();uIn(i);const a=sKe(i);Xe.useLayoutEffect(()=>{MKt=a.column},[a.column]);const l=ez.get(X9e()??"")?.element??Mm?.center;Xe.useLayoutEffect(()=>{if(!l)return;const k=()=>pTt({x:0,y:0,width:l.clientWidth,height:l.clientHeight}),w=new ResizeObserver(k);return w.observe(l),k(),()=>{w.disconnect(),pTt(null)}},[l]),Xe.useSyncExternalStore(i.subscribe,i.getShellSnapshot??i.getSnapshot),Xe.useSyncExternalStore(Aw,Sb,Sb),Xe.useSyncExternalStore(zIn,ukt,ukt),Xe.useSyncExternalStore(BIn,lkt,lkt),Xe.useLayoutEffect(()=>{const k=Q7r({...t?{arrangement:t}:{},...r===void 0?{}:{immersivePlay:r},playUtilities:[]});return t&&CS(t.id),ERr(),k},[t,r]);const d=i.playState!=="stopped",_=Xe.useSyncExternalStore(Eee,P8).play?.keepPanelsVisible;if(Xe.useEffect(()=>{Ukn(d,bKt())},[d,r,_]),Xe.useEffect(()=>PKt(i),[i]),!Mm)return null;const g=Mm.center,b=FA(),S=AE()??b[0]??null;return globalThis.__vgaiBridge={documents:b.map(k=>k.descriptor.id),active:S?.descriptor.id??null,workspace:t?.id??null,areas:b.flatMap(k=>k.descriptor.area?[{id:k.descriptor.id,area:k.descriptor.area}]:[]),slots:[...ez.values()].map(({id:k,documentId:w,element:N})=>({id:k,documentId:w,visible:!!N}))},z.jsxs(z.Fragment,{children:[[...ez.values()].map(k=>{const w=b.find(N=>N.descriptor.id===k.documentId)?.descriptor;return w?z.jsx(YIn,{descriptor:w,viewId:k.id,slot:k.element??void 0,parking:g,visible:!!k.element,inspector:a.card&&w.id===S?.descriptor.id},k.id):null}),b.length===0&&vS.createPortal(z.jsx(ER,{children:z.jsx("div",{className:"vgai-vscode-empty",children:"No document open"})}),Mm.center),Mm.outliner&&vS.createPortal(z.jsx(ER,{children:z.jsx(WIn,{})}),Mm.outliner),Mm.properties&&a.column&&vS.createPortal(z.jsx(ER,{children:z.jsx(uKe,{})}),Mm.properties),Mm.content&&vS.createPortal(z.jsx(ER,{children:z.jsx(pkn,{kind:"assets"})}),Mm.content),z.jsx(KIn,{}),z.jsx(QIn,{})]})}async function ZIn(t){Mm=t;for(const[G,ee]of Object.entries(t))ee&&FKt(G,ee);t.chromeRoot.id="editor-chrome-root",SMr({Frame:UIn,Header:VIn,Footer:JIn,Workspace:XIn,Document:vSn}),mkn(),Wyn();const r=Nxn();r&&Dxn(r,Date.now())&&ua.warn(kxn(r,Date.now()),"editor"),fIn(),ejr(),Kkn(),MIn(),await Promise.all([Q3t(),XRr()]),p9r(t.chromeRoot),t.chromeRoot.classList.toggle("vgai-native-menus",qye()?.nativeMenus===!0);const i=document.createElement("div");i.id="editor-root",i.className="vgai-part",i.style.cssText="position:absolute;inset:0;pointer-events:none;z-index:10;",t.chromeRoot.appendChild(i),Hqe.createRoot(i).render(z.jsx(Qxn,{}));const a={activeKeymap:()=>fv().keyboard.activeKeymap(),invoke:G=>fv().keyboard.invoke(G),subscribe:G=>fv().keyboard.subscribe(G),facts:()=>{const G=fv(),ee=G.keyboard.stage();return{surface:ee.surface,mode:ee.mode,documentKind:G.documents.active()?.kind??null,play:G.session.playState()}},report:(G,ee)=>{const xe=fv();G==="error"?xe.console.error(ee,"editor"):xe.console.warn(ee,"editor")}},l={whenRestored:yKe,activeSource:()=>{const G=fv().documents.active();if(!G)return null;const ee=G.kind==="model"&&G.id.startsWith("model:")?G.id.slice(6):"";return{kind:G.kind,path:ee}},list:()=>FA().map(G=>{const ee=G.descriptor.area?vRr().find(xe=>xe.id===G.descriptor.area):void 0;return{id:G.descriptor.id,title:G.title,...ee?{area:{id:ee.id,place:ee.place,ratio:ee.ratio}}:{}}}),activeId:()=>AE()?.descriptor.id??null,subscribe:G=>{const ee=Aw(G),xe=bRr(G);return()=>{ee(),xe()}},activate:(G,ee)=>{ee?i5r(G,ee):xb(G)},close:G=>{if(Y8(G))return;const ee=FA().find(xe=>xe.descriptor.id===G);ee&&a.report("warn",`“${ee.title}” has unsaved changes, so it stayed open. Save it (⌘S) and close it again.`)},setView:(G,ee)=>qIn(G,ee)},d={elements:()=>fv().history.elements(),onElement:G=>fv().history.onElement(G),onInvalidated:G=>fv().history.onInvalidated(G),changed:()=>fv().history.changed(),focusedResource:()=>fv().history.focusedResource(),focusedDocument:()=>{const G=fv().documents.active();return G?{id:G.id,label:G.title}:null},setDelegate:G=>fv().history.setDelegate(G),report:a.report},_={setProvider:G=>fv().files.setProvider(G),report:a.report},g={setProvider:G=>fv().settings.setProvider(G),adapterValues:()=>[...x7r()],workbenchValues:()=>{const G=Mm?.chromeRoot;if(!G)return[];const ee=getComputedStyle(G).getPropertyValue("--vgai-command-bar-height").trim(),xe=Number.parseFloat(ee);return!Number.isFinite(xe)||xe<=0?[]:[["window.titleBarHeight",Math.round(xe)]]},lookId:()=>cU(),notify:G=>{fv().notify(G)},subscribe:G=>{const ee=d0e(G),xe=wPt(G);return()=>{ee(),xe()}},report:a.report},b={list:()=>Qyn().map(G=>({id:G.id,label:G.label,category:G.category})),invoke:G=>Yyn(G),subscribe:G=>Kyn(G),setPaletteOpener:G=>Gyn(G),setCommandExecutor:G=>Xyn(G),report:a.report},S={setDelegate:G=>qFr(G?{show:G}:null)},k={list:()=>S4t().map(G=>({view:G.view,title:G.title,verbs:G.verbs.map(ee=>({id:ee.id,...ee.title?{title:ee.title}:{}}))})),invoke:(G,ee,xe)=>w4t(G,ee,xe),subscribe:G=>x4t(G)},w={list:()=>gE().map((G,ee)=>({id:G.id,title:G.title,order:G.order??ee})),subscribe:G=>g0e(G),offerBody:(G,ee)=>HIn(G,ee)};let N=!0,P=null,j=null;jIn(()=>N);const J={setActiveStaticPanel:G=>TAt(LQe.find(ee=>ee.kind===G)?.kind??null),focusCompactInspector:()=>{if(MKt)return!1;const G=Mm?.center.querySelector('[data-testid="compact-inspector-card"]');return G?(G.tabIndex=-1,G.focus(),TAt("inspector"),!0):!1},setPaneActive:G=>{N!==G&&(N=G,$qe())},setImmersive:G=>{P?.(),P=null,!(!G||!Mm)&&(P=Pkn({root:Mm.chromeRoot,hideChrome:()=>G.enter(),showChrome:()=>G.exit()}))},setDockCommands:G=>{j?.(),j=null,G&&(j=X7r({showUtility:ee=>G.showUtility(ee),toggleUtility:ee=>G.toggleUtility(ee),ensureUtility:ee=>G.ensureUtility(ee),closeUtility:ee=>G.closeUtility(ee),showStaticPanel:ee=>G.showStaticPanel(ee),setFocus:ee=>G.setFocus(ee),toggleFocus:()=>G.toggleFocus(),captureUtilities:ee=>{for(const xe of ee)G.showUtility(xe);return()=>{for(const xe of ee)G.closeUtility(xe)}},showAuxiliary:()=>J.report("warn","Undo history has no panel under the VS Code frame: the stack is the workbench's own (U4), reached through Edit → Undo/Redo and the Timeline.")}))},report:(G,ee)=>a.report(G,ee)};return{host:i,keyboard:a,documents:l,history:d,files:_,commands:b,notifications:S,views:k,utilities:w,output:{setProvider:Qkn},settings:g,status:{list:()=>["left","right"].flatMap(G=>U9e(G).map((ee,xe)=>({id:ee.id,title:ee.name,align:G,order:ee.order??xe}))),subscribe:G=>BDt(G),offerBody:(G,ee)=>GIn(G,ee)},game:J,offerPart:$In}}function eDn(t){const r=Object.keys(t.packages);return FIr({id:t.id,packages:r,look:t.look,workspace:t.workspace,nativeMenus:t.nativeMenus}),NPt(r.flatMap(i=>t.packages[i]??[])),{mountVgai:ZIn}}const{mountVgai:s6n}=eDn({id:"editor",packages:{"@volter/editor-blender":OIr},look:"blender",workspace:"model"});export{ZDn as $,yvn as A,fo as B,SE as C,eO as D,NDn as E,ODn as F,VN as G,U_ as H,Ibn as I,j4n as J,ZPn as K,QDn as L,B0e as M,Z8 as N,LP as O,k2t as P,dvn as Q,DDn as R,DFr as S,Ru as T,i6n as U,_Qe as V,FA as W,$mn as X,I_ as Y,ua as Z,Xo as _,o_ as a,NWt as a$,z2t as a0,U2t as a1,e3n as a2,My as a3,So as a4,pDn as a5,bS as a6,S8 as a7,mDn as a8,EWt as a9,W9r as aA,MDn as aB,XPt as aC,hZ as aD,_Dn as aE,s7r as aF,Ykt as aG,d5r as aH,SX as aI,V_n as aJ,BDn as aK,j0e as aL,VDt as aM,W_ as aN,GWt as aO,k3t as aP,PDn as aQ,zY as aR,zPn as aS,UPn as aT,IWt as aU,cmn as aV,umn as aW,MPn as aX,cQe as aY,PWt as aZ,TWt as a_,VPn as aa,Z4n as ab,EGt as ac,Ywn as ad,V0e as ae,aMe as af,oz as ag,TMr as ah,NP as ai,Wa as aj,IDn as ak,Ny as al,kze as am,JR as an,o3n as ao,kX as ap,FDn as aq,c3n as ar,Zh as as,RDn as at,J9r as au,$Dn as av,yw as aw,np as ax,HR as ay,ad as az,GDn as b,b8 as b$,G_n as b0,GR as b1,jgn as b2,aQe as b3,Fee as b4,P5r as b5,oU as b6,uI as b7,ep as b8,o4n as b9,UR as bA,uv as bB,CFr as bC,k_ as bD,v3t as bE,i3n as bF,LOr as bG,vDn as bH,XNt as bI,u3n as bJ,s3n as bK,kDn as bL,l3n as bM,jIr as bN,ige as bO,Jkt as bP,vee as bQ,wg as bR,VDn as bS,Pbn as bT,w4t as bU,g_e as bV,B$e as bW,rI as bX,tgn as bY,Ab as bZ,X1e as b_,Nq as ba,l4n as bb,ph as bc,rf as bd,x8 as be,zye as bf,Eze as bg,o0e as bh,Aw as bi,Sb as bj,Nee as bk,MP as bl,e0e as bm,I8 as bn,wm as bo,Pw as bp,O5r as bq,TDr as br,X4n as bs,eSn as bt,B4n as bu,Vkt as bv,hE as bw,_ee as bx,JHt as by,GPn as bz,hz as c,mUe as c$,k9 as c0,fte as c1,gv as c2,jd as c3,Tu as c4,Ebt as c5,hDn as c6,Aee as c7,Cbt as c8,gDn as c9,R4n as cA,tAt as cB,uDn as cC,UIr as cD,M4n as cE,xAn as cF,Nze as cG,By as cH,Ajr as cI,qDn as cJ,w4n as cK,eLe as cL,SAn as cM,m1n as cN,S4n as cO,m4n as cP,b4n as cQ,v4n as cR,c9 as cS,h4n as cT,D4n as cU,y4n as cV,g4n as cW,A4n as cX,I4n as cY,C4n as cZ,P4n as c_,FNr as ca,IR as cb,YGt as cc,q4t as cd,jA as ce,gAn as cf,YDn as cg,XDn as ch,KDn as ci,zP as cj,V4t as ck,d4n as cl,_An as cm,f4n as cn,IFe as co,ZPt as cp,mSn as cq,$kt as cr,BIr as cs,zIr as ct,HQe as cu,Mkt as cv,L4n as cw,lDn as cx,dDn as cy,fDn as cz,pU as d,a3n as d$,k0 as d0,E4n as d1,T4n as d2,p4n as d3,_4n as d4,x4n as d5,N4n as d6,DQe as d7,k4n as d8,wAn as d9,CZ as dA,NUe as dB,WDn as dC,JDn as dD,zDn as dE,J4n as dF,$4n as dG,O2n as dH,z4n as dI,U4n as dJ,V4n as dK,dte as dL,$Ht as dM,i4n as dN,K9r as dO,Zvn as dP,n4n as dQ,TGt as dR,v1n as dS,Nbn as dT,e4n as dU,t4n as dV,XMe as dW,rme as dX,ZMe as dY,jDn as dZ,LDn as d_,O4n as da,F4n as db,vhe as dc,OP as dd,D5r as de,Y8 as df,z4t as dg,BPn as dh,qPn as di,ljr as dj,Sw as dk,xb as dl,jPn as dm,LPn as dn,$Pn as dp,u4n as dq,s4n as dr,NGt as ds,oNt as dt,IZ as du,a5r as dv,W4t as dw,Gwn as dx,H8 as dy,bDn as dz,fv as e,UDn as e0,OUe as e1,J2n as e2,JPn as e3,WPn as e4,t6n as e5,e6n as e6,H4n as e7,G4n as e8,W4n as e9,qGt as eA,SDn as eB,xDn as eC,SQe as eD,o8 as eE,V8 as eF,Khn as eG,T_ as eH,wCt as eI,lHt as eJ,Lm as eK,mHt as eL,Fy as eM,s6n as eN,yb as ea,q4n as eb,Q4n as ec,pv as ed,a4n as ee,QPn as ef,KPn as eg,WHt as eh,c4n as ei,Qh as ej,Eq as ek,CDn as el,HPn as em,n6n as en,G4t as eo,Y4n as ep,TDn as eq,wDn as er,ADn as es,bP as et,K4n as eu,yDn as ev,XPn as ew,EDn as ex,r6n as ey,YPn as ez,t3n as f,CE as g,CUe as h,r3n as i,dE as j,U0e as k,Ry as l,dNt as m,r4n as n,Na as o,WUe as p,od as q,n3n as r,Ss as s,Oo as t,D0 as u,mGt as v,fLr as w,$Qe as x,R$r as y,gvn as z};
|
|
1691
|
+
${i.componentStack??""}`,"editor")}render(){return this.state.error?z.jsxs("div",{role:"alert","data-testid":"static-panel-crashed",style:{padding:12,display:"grid",gap:8,alignContent:"start"},children:[z.jsxs("strong",{children:[this.props.title," crashed."]}),z.jsx("span",{style:{opacity:.8,wordBreak:"break-word"},children:this.state.error.message}),z.jsx("div",{children:z.jsx(fo,{type:"button",variant:"outline",size:"compact",onClick:()=>this.setState({error:null}),children:"Retry"})})]}):this.props.children}}const fkn=LQe.map(t=>{const r=lkn[t.kind],i=a=>z.jsx(ukn,{title:t.title,children:z.jsx(r,{...a})});return i.displayName=`StaticPanel(${t.kind})`,{...t,Content:i}});function dkn(t){return fkn.find(r=>r.kind===t)}function pkn({kind:t,dependencies:r}){const{Content:i}=dkn(t);return z.jsx(i,{dependencies:r})}const _kn=250;function mkn(){const t=B3t(),r=hkn();return()=>{r(),t()}}function hkn(){const t=new Map;let r=null,i=!1;function a(){const _=[],g=new Set;for(const b of ua.getEntries()){if(g.add(b.id),b.level!=="error"&&b.level!=="warn")continue;const S=t.get(b.id)??0;b.count<=S||(t.set(b.id,b.count),_.push({severity:b.level,message:b.message,source:b.source??null,occurrences:b.count-S}))}for(const b of[...t.keys()])g.has(b)||t.delete(b);return _}function l(){if(r=null,i)return;const _=a();_.length!==0&&R8("console-entries",{entries:_,_clientId:jP})}const d=ua.subscribe(()=>{i||r!==null||(r=setTimeout(l,_kn))});return R8("console-entries",{entries:[],_clientId:jP}),l(),()=>{i=!0,r!==null&&clearTimeout(r),d()}}const RN={INPUT:"input",PRE_PHYSICS:"prePhysics",PHYSICS:"physics",POST_PHYSICS:"postPhysics",GAME_LOGIC:"gameLogic",ANIMATION:"animation",PRE_RENDER:"preRender",RENDER:"render"},O_e=[RN.INPUT,RN.PRE_PHYSICS,RN.PHYSICS,RN.POST_PHYSICS,RN.GAME_LOGIC,RN.ANIMATION,RN.PRE_RENDER,RN.RENDER],Fye=1e-9,hKt=1e5;function gkn(t,r,i){const a=i.end-i.start,l=i.loop&&a>Fye,d=[];let _=t,g=r,b=!1,S=0;for(;;){const k=i.end-_;if(!l||g<=k+Fye){const w=Math.min(_+g,i.end);d.push({from:_,to:w,direction:"forward"}),_=w;break}if(d.push({from:_,to:i.end,direction:"forward"}),g-=k,_=i.start,b=!0,S++,S>hKt){const w=i.start+g%a;d.push({from:_,to:w,direction:"forward"}),_=w;break}}return{pos:_,intervals:d,looped:b}}function ykn(t,r,i){const a=i.end-i.start,l=i.loop&&a>Fye,d=[];let _=t,g=r,b=!1,S=0;for(;;){const k=_-i.start;if(!l||g<=k+Fye){const w=Math.max(_-g,i.start);d.push({from:_,to:w,direction:"reverse"}),_=w;break}if(d.push({from:_,to:i.start,direction:"reverse"}),g-=k,_=i.end,b=!0,S++,S>hKt){const w=i.end-g%a;d.push({from:_,to:w,direction:"reverse"}),_=w;break}}return{pos:_,intervals:d,looped:b}}function YTt(t,r){return t<r.start?r.start:t>r.end?r.end:t}class vkn{_previousTime;_currentTime;_range;_timeScale;_playDirection="forward";_lastCrossingDirection="forward";_playbackState="stopped";_evaluators=[];_registrationCounter=0;constructor(r={}){const i=r.start??0,a=r.end??Math.max(i,1);if(a<i)throw new Error(`[AnimationClock] range end (${a}) must be >= start (${i})`);const l=r.timeScale??1;if(!Number.isFinite(l)||l<0)throw new Error(`[AnimationClock] timeScale must be a finite number >= 0, got ${l}`);this._range={start:i,end:a,loop:r.loop??!1},this._timeScale=l,this._previousTime=i,this._currentTime=i}get time(){return this._currentTime}get previousTime(){return this._previousTime}get direction(){return this._playbackState==="playing"?this._playDirection:"paused"}get playbackState(){return this._playbackState}get timeScale(){return this._timeScale}set timeScale(r){if(!Number.isFinite(r)||r<0)throw new Error(`[AnimationClock] timeScale must be a finite number >= 0, got ${r}`);this._timeScale=r}get range(){return this._range}setRange(r){const i=r.start??this._range.start,a=r.end??this._range.end,l=r.loop??this._range.loop;if(a<i)throw new Error(`[AnimationClock] range end (${a}) must be >= start (${i})`);this._range={start:i,end:a,loop:l};const d=YTt(this._currentTime,this._range);d!==this._currentTime&&this.seek(d)}play(r){r&&(this._playDirection=r),this._playbackState="playing"}pause(){this._playbackState="paused"}stop(){this._playbackState="stopped"}seek(r){const i=YTt(r,this._range);if(i===this._currentTime)return this.emit(this._currentTime,this._currentTime,[{from:i,to:i,direction:this._lastCrossingDirection}],!1,this._lastCrossingDirection);const a=i>this._currentTime?"forward":"reverse",l=this._currentTime;return this._previousTime=l,this._currentTime=i,this._lastCrossingDirection=a,this.emit(l,i,[{from:l,to:i,direction:a}],!1,a)}seekFrame(r,i){if(!Number.isFinite(i)||i<=0)throw new Error(`[AnimationClock] seekFrame fps must be a finite number > 0, got ${i}`);return this.seek(this._range.start+r/i)}advance(r){if(this._playbackState!=="playing")return null;if(!Number.isFinite(r))throw new Error(`[AnimationClock] advance(dt) requires a finite dt, got ${r}`);const i=Math.abs(r)*this._timeScale,a=this._currentTime;if(i===0)return this.emit(a,a,[],!1,this._playDirection);const l=this._playDirection==="forward"?gkn(a,i,this._range):ykn(a,i,this._range);return this._previousTime=a,this._currentTime=l.pos,this._lastCrossingDirection=this._playDirection,this.emit(a,l.pos,l.intervals,l.looped,this._playDirection)}subscribe(r,i){if(!O_e.includes(r))throw new Error(`[AnimationClock] unknown phase "${r}". Valid: ${O_e.join(", ")}`);const a={phase:r,order:this._registrationCounter++,fn:i};return this._evaluators.push(a),{dispose:()=>{const l=this._evaluators.indexOf(a);l!==-1&&this._evaluators.splice(l,1)}}}emit(r,i,a,l,d){const _={previousTime:r,currentTime:i,direction:d,timeScale:this._timeScale,looped:l,intervals:a};if(this._evaluators.length>0){const g=[...this._evaluators].sort((b,S)=>{const k=O_e.indexOf(b.phase),w=O_e.indexOf(S.phase);return k!==w?k-w:b.order-S.order});for(const b of g)try{b.fn(_)}catch(S){console.error(`[AnimationClock] evaluator in phase "${b.phase}" threw:`,S)}}return _}}const F_e={start:0,end:0,fps:30},bkn=150;class r6n{constructor(r){this.store=r,this.stopStoreWatch=r.subscribe(()=>this.notify())}clock=new vkn;subjects=[];activeId=null;listeners=new Set;settleListeners=new Set;settleTimer=null;disposed=!1;cachedSnapshot=null;stopStoreWatch;attach(r){return this.subjects.push(r),this.activeId===null?this.setActiveSubject(r.id):this.notify(),()=>{const i=this.subjects.indexOf(r);if(i<0)return;if(this.subjects.splice(i,1),this.activeId!==r.id){this.notify();return}this.activeId=null;const a=this.subjects[0];a?this.setActiveSubject(a.id):(this.clock.setRange({start:F_e.start,end:F_e.end,loop:!1}),this.notify())}}setActiveSubject(r){const i=this.subjects.find(l=>l.id===r);if(!i)return;this.activeId=r;const a=i.range();this.clock.setRange({start:a.start,end:a.end}),this.applyTime(this.clock.time),this.notify()}get active(){return this.subjects.find(r=>r.id===this.activeId)??null}fps(){return this.active?.range().fps??F_e.fps}get driver(){return this.store.playState==="stopped"?"editor":"world"}assertEditorDrives(){if(this.driver==="world")throw new Error("transport: the world is driving time (Play); pause the game to scrub")}play(r="forward"){this.assertEditorDrives(),this.active&&(this.cancelSettle(),this.clock.play(r),this.notify())}pause(){this.assertEditorDrives(),this.clock.pause(),this.cancelSettle(),this.settle(),this.notify()}stop(){this.assertEditorDrives(),this.clock.pause(),this.cancelSettle(),this.applyTime(this.clock.seek(this.clock.range.start).currentTime),this.clock.stop(),this.settle(),this.notify()}seek(r){this.assertEditorDrives(),this.applyTime(this.clock.seek(r).currentTime),this.clock.playbackState!=="playing"&&this.scheduleSettle(),this.notify()}seekFrame(r){this.seek(r/this.fps())}setLoop(r){this.clock.setRange({loop:r}),this.notify()}setTimeScale(r){this.clock.timeScale=r,this.notify()}tick(r){if(this.disposed||this.driver==="world"||this.clock.playbackState!=="playing")return 0;const i=this.clock.time,a=this.clock.advance(r);return a?(this.applyTime(a.currentTime),this.notify(),a.looped?Math.abs(r)*this.clock.timeScale:a.currentTime-i):0}applyTime(r){const i=this.active;i&&i.seek(r);for(const a of this.subjects)a!==i&&a.seek(r)}onSettled(r){return this.settleListeners.add(r),()=>{this.settleListeners.delete(r)}}scheduleSettle(){this.cancelSettle(),this.settleTimer=setTimeout(()=>{this.settleTimer=null,this.settle()},bkn)}cancelSettle(){this.settleTimer!==null&&(clearTimeout(this.settleTimer),this.settleTimer=null)}settle(){if(this.disposed)return;const r=this.clock.time;for(const i of[...this.settleListeners])i(r)}snapshot(){const r=this.cachedSnapshot;if(r)return r;const i=this.active?.range()??F_e,a={time:this.clock.time,range:{start:this.clock.range.start,end:this.clock.range.end,fps:i.fps,loop:this.clock.range.loop},playbackState:this.clock.playbackState,timeScale:this.clock.timeScale,activeSubject:this.activeId,subjects:this.subjects.map(l=>({id:l.id,label:l.label})),driver:this.driver};return this.cachedSnapshot=a,a}activeClips(){const i=this.active?.clips?.();return i&&i.length>1?i:null}setActiveClip(r){this.assertEditorDrives(),this.active?.setClip?.(r);const i=this.active?.range();i&&this.clock.setRange({start:i.start,end:i.end}),this.applyTime(this.clock.time),this.notify()}subscribe(r){return this.listeners.add(r),()=>{this.listeners.delete(r)}}notify(){this.cachedSnapshot=null;for(const r of[...this.listeners])r()}dispose(){this.disposed=!0,this.stopStoreWatch(),this.cancelSettle(),this.clock.stop(),this.subjects.length=0,this.activeId=null,this.listeners.clear(),this.settleListeners.clear()}}const ehe=new Map,Mqe=new Set;function XTt(){for(const t of[...Mqe])t()}function n6n(t,r){return ehe.set(t,r),XTt(),()=>{ehe.get(t)===r&&(ehe.delete(t),XTt())}}function Akn(t){return t===null?null:ehe.get(t)??null}function Skn(t){return Mqe.add(t),()=>{Mqe.delete(t)}}const gKt="__vgaiWorkspacePersistenceSuppressed";function yKt(){return globalThis}function vKt(t){yKt()[gKt]=t}function xkn(){return yKt()[gKt]===!0}function bKt(){return(_0e()?.immersivePlay??!1)&&!P8().play?.keepPanelsVisible}function wkn(t){return Math.min(1600,Math.max(800,900+t*25))}function Ckn(t){return t<.5?4*t*t*t:1-(-2*t+2)**3/2}function AKt(t,r,i=new Tc(0,1,0)){const a=new Tc().subVectors(r,t),l=a.length();if(l<1e-6)return[t.clone(),t.clone(),r.clone(),r.clone()];const d=Math.min(l*.18,6),_=new Tc().crossVectors(a,i);_.lengthSq()>1e-9?_.normalize().multiplyScalar(Math.min(l*.08,2.5)):_.set(0,0,0);const g=i.clone().normalize().multiplyScalar(d),b=t.clone().addScaledVector(a,.3).add(g).add(_),S=r.clone().addScaledVector(a,-.3).addScaledVector(g,.6).addScaledVector(_,.5);return[t.clone(),b,S,r.clone()]}const SKt={phase:"idle",flightDone:!1,gameReady:!1};function Ekn(t,r){const i=t.flightDone||r==="flight-done",a=t.gameReady||r==="game-ready";return i&&a?{phase:"crossfade",flightDone:i,gameReady:a}:i?{phase:"holding",flightDone:i,gameReady:a}:{...t,flightDone:i,gameReady:a}}function Tkn(t,r){if(r==="stop")return SKt;switch(t.phase){case"idle":return r==="start"?{phase:"entering",flightDone:!1,gameReady:!1}:r==="start-reduced"?{phase:"playing",flightDone:!0,gameReady:!0}:t;case"entering":return Ekn(t,r);case"holding":return r==="game-ready"?{...t,phase:"crossfade",gameReady:!0}:t;case"crossfade":return r==="crossfade-done"?{...t,phase:"playing"}:t;case"playing":return t}}const kkn=450,Ikn=220,xKt=250;function Dkn(t){t.style.setProperty("--vgai-play-dissolve-duration",`${kkn}ms`),t.style.setProperty("--vgai-play-materialize-duration",`${Ikn}ms`),t.style.setProperty("--vgai-play-crossfade-duration",`${xKt}ms`)}let PP=null;function Pkn(t){return PP=t,typeof document<"u"&&Dkn(document.documentElement),()=>{PP===t&&(PP=null)}}function wKt(){return typeof window<"u"&&(window.matchMedia?.("(prefers-reduced-motion: reduce)").matches??!1)}const Nkn=1<<31;function Okn(t){return(t.layers.mask&Nkn)!==0||/gizmo/i.test(t.name)}function CKt(t){if(Okn(t))return null;if(t.isCamera)return t;for(const r of t.children){const i=CKt(r);if(i)return i}return null}function Fkn(t,r,i){const a=new Tc,l=new G8;return r.getWorldPosition(a),r.getWorldQuaternion(l),{entityId:t,position:a.toArray(),quaternion:l.toArray(),fov:i}}function Rkn(t){for(const[r,i]of t.objectMap){const a=CKt(i);if(!a)continue;const l=a;return Fkn(r,a,l.isPerspectiveCamera?l.fov:60)}return null}let kE=null;function Mkn(){return kE?.state.phase??"idle"}const the=new Set;function EKt(){if(the.size===0)return;const t=[...the];the.clear();for(const r of t)r()}function Lkn(t){if(!kE||kE.state.phase==="playing"){t();return}the.add(t)}function jkn(t,r,i){const a=setTimeout(()=>{t.timeouts.delete(a),i()},r);t.timeouts.add(a)}function Bkn(t){t.curve=new Okt(AKt(t.startPos,t.endPos))}function Zq(t){const r=kE;if(!r)return;const i=r.state,a=Tkn(i,t);a!==i&&(r.state=a,a.phase==="crossfade"&&i.phase!=="crossfade"&&(PP?.root.classList.add("vgai-play-crossfade"),jkn(r,xKt+30,()=>Zq("crossfade-done"))),a.phase==="playing"&&i.phase!=="playing"&&(PP?.root.classList.remove("vgai-play-flight","vgai-play-crossfade"),$kn(),EKt()))}function $kn(){const t=gte(),r=kE;if(!t||!r?.flight)return;const i=t.camera,a=new Tc(0,0,-1).applyQuaternion(i.quaternion),l=r.cameraSnapshot?Math.max(1,r.cameraSnapshot.position.distanceTo(r.cameraSnapshot.target)):5;t.orbit.target.copy(i.position).addScaledVector(a,l),t.orbit.enabled=!0}function qkn(){const t=bKt(),r=Qh();zkn(t&&r?Rkn(r):null,{immersive:t})}function zkn(t,r){if(kE&&gKe(),!r.immersive)return;const i=wKt();vKt(!0);const a={state:SKt,reducedMotion:i,flight:null,cameraSnapshot:null,getLiveCamera:null,timeouts:new Set};if(kE=a,PP?.hideChrome(!i),i){Zq("start-reduced");return}Zq("start");const l=gte();if(!t||!l){Zq("flight-done");return}a.cameraSnapshot={position:l.camera.position.clone(),target:l.orbit.target.clone(),fov:l.camera.fov};const d=l.camera.position.clone(),_=new Tc().fromArray(t.position),g={startPos:d,startQuat:l.camera.quaternion.clone(),startFov:l.camera.fov,endPos:_,endQuat:new G8().fromArray(t.quaternion),endFov:t.fov,curve:new Okt(AKt(d,_)),startedAt:performance.now(),durationMs:wkn(d.distanceTo(_)),landed:!1};a.flight=g,l.orbit.enabled=!1,PP?.root.classList.add("vgai-play-flight")}function Ukn(t,r){(!t||!r)&&gKe()}function Vkn(t){const r=kE;r&&(r.getLiveCamera=t??null,Zq("game-ready"))}const d9e=new Tc,ZTt=new G8;vQt(Jkn);function Jkn(){const t=kE,r=gte(),i=t?.flight;if(!t||!r||!i)return;const a=t.state.phase;if(a!=="entering"&&a!=="holding"&&a!=="crossfade")return;const l=t.getLiveCamera?.()??null;if(l){l.getWorldPosition(d9e),l.getWorldQuaternion(ZTt),d9e.distanceToSquared(i.endPos)>1e-8&&(i.endPos.copy(d9e),Bkn(i)),i.endQuat.copy(ZTt);const b=l.fov;typeof b=="number"&&(i.endFov=b)}const d=r.camera;if(i.landed){d.position.copy(i.endPos),d.quaternion.copy(i.endQuat),d.fov!==i.endFov&&(d.fov=i.endFov,d.updateProjectionMatrix());return}const _=Math.min(1,(performance.now()-i.startedAt)/i.durationMs),g=Ckn(_);d.position.copy(i.curve.getPoint(g)),d.quaternion.slerpQuaternions(i.startQuat,i.endQuat,g),d.fov=i.startFov+(i.endFov-i.startFov)*g,d.updateProjectionMatrix(),_>=1&&(i.landed=!0,Zq("flight-done"))}function gKe(){const t=kE;if(!t)return;kE=null;for(const i of t.timeouts)clearTimeout(i);t.timeouts.clear(),EKt(),PP?.root.classList.remove("vgai-play-flight","vgai-play-crossfade");const r=gte();if(r&&t.cameraSnapshot){const i=t.cameraSnapshot;r.camera.position.copy(i.position),r.orbit.target.copy(i.target),r.camera.lookAt(i.target),r.camera.fov!==i.fov&&(r.camera.fov=i.fov,r.camera.updateProjectionMatrix()),r.orbit.enabled=!0,r.orbit.update()}else r&&t.flight&&(r.orbit.enabled=!0);PP?.showChrome(!wKt()),vKt(!1)}const Lqe=new Set;let TKt=null;function kKt(){return ad()?.rootPath??null}function Wkn(t){Lqe.add(t);const r=kKt();return r!==null&&TKt===r&&t(),()=>{Lqe.delete(t)}}async function i6n(){TKt=kKt();for(const t of[...Lqe])await t()}function Hkn(){const t=I_();if(t===null)return null;const r=_Z(t);if(typeof r!="object"||r===null)return null;const i=r.stageMode;if(typeof i!="function")return null;const a=i.call(r);return typeof a=="string"?a:null}const Gkn=new Map;let jqe=null;function Qkn(t){jqe=t}function ekt(){if(!jqe)throw new Error("The workbench Output service is not connected.");return jqe}function Kkn(){TLr(I_),AMr({output:{write:(...t)=>ekt().write(...t),show:t=>ekt().show(t)},console:{log:(t,r)=>ua.log(t,r),warn:(t,r)=>ua.warn(t,r),error:(t,r)=>ua.error(t,r)},live:{register:LHt,mounted:DQe,playing:tbe,runWindow:xQe,restartRequired:FHt,restart:RHt,subscribe:NQe,version:BHt,notifyChanged:OHt,snapshotFrame:CQe,frameCanvas:wQe,authoringRefusal:IQe,dispatch:EQe,scenes:TQe,surface:ebe,coverage:kQe},viewport:{rig:gte,presentRoots:K2n,onFrame:vQt,setHelper:Q2n,stages:bQt,onStages:X2n,transition:{begin:qkn,ready:Vkn,end:gKe,onSettled:Lkn,phase:Mkn}},hierarchy:{object:t=>Qh()?.objectMap.get(t)??null,objects:()=>Qh()?.objectMap??Gkn,subscribe:t=>{const r=Hpe(t),i=Qh()?.subscribe(t);return()=>{r(),i?.()}},version:()=>{const t=Qh();return t?.getShellSnapshot?.()??t?.getSnapshot()??0}},session:{reportFacet:Hgn,onSample:Ryn,onCommandDispatched:aqr,playState:()=>Qh()?.playState??"stopped",playEditRegime:()=>Qh()?.playEditRegime??null,subscribe:t=>{const r=Hpe(t),i=Qh()?.subscribe(t);return()=>{r(),i?.()}},version:()=>{const t=Qh();return t?.getShellSnapshot?.()??t?.getSnapshot()??0},open:()=>Qh()!==null,onEnded:t=>HUe(r=>{r!==null&&t()}),onBeforeClose:nyn,reportWorkerCallMeter:eAn},project:{documentTable:bmn,mounts:cz,engineVersion:()=>ad()?.config.engine.version??null,subscribe:Iw,onReady:Wkn},notify:t=>az(t),systems:{inspected:yze,subscribe:EOr,inspectedNetworking:DOr,subscribeNetworking:POr,inspectedAudio:()=>NOr()??null,subscribeAudio:OOr,audioVersion:FOr},availability:{subscribe:WQt,version:jwn},workspace:{showUtility:hE,openContributedDocument:t=>fI(null,t),open:async t=>await y0e(t.kind,Qh()??{setActiveViewportTab:()=>{}},t)!==null,liveDocument:{id:Sw,register:o2n,acquire:u2n,release:tKe,open:_be,container:a2n,setContainer:c2n,releaseContainer:l2n}},documents:{activeId:I_,active:()=>{const t=AE();return t?{id:t.descriptor.id,kind:t.descriptor.kind,title:t.title}:null},subscribe:Aw,version:Sb,context:_Z,waitForContext:w3t,contextChanged:BFr},transport:{for:t=>Akn(t),subscribe:Skn},projectLocalState:{ready:pte,read:WQe,write:ube,projectRootPath:()=>ad()?.rootPath??null},history:{record:B4t,setDelegate:CLr,onElement:ILr,invalidate:DLr,onInvalidated:PLr,changed:ELr,elements:kLr,focusedResource:()=>{const t=AE();if(!t)return null;const r=t.descriptor.provenance?.sourcePath;if(r)return r;const i=Qh();return i?nqr(i)??UUe(i):null},undo:()=>Qh()?.projectHistory?.undo()??Promise.resolve(!1),redo:()=>Qh()?.projectHistory?.redo()??Promise.resolve(!1),canUndo:()=>Qh()?.projectHistory?.getSnapshot().canUndo??!1,canRedo:()=>Qh()?.projectHistory?.getSnapshot().canRedo??!1,undoLabel:()=>Qh()?.projectHistory?.getSnapshot().undoLabel??null,redoLabel:()=>Qh()?.projectHistory?.getSnapshot().redoLabel??null,subscribe:t=>{const r=j4t(t),i=Hpe(t),a=Qh()?.projectHistory?.subscribe(t),l=Aw(t);return()=>{r(),i(),a?.(),l()}}},files:{setProvider:ZMr,read:t=>Qg.read(t),readBytes:t=>Qg.readBytes(t),write:(t,r)=>Qg.write(t,r),exists:t=>Qg.exists(t),list:t=>Qg.list(t),watch:t=>Qg.watch(t)},settings:{setProvider:A7r,get:T7r,set:I7r,inspect:K3t,subscribe:t=>{const r=H3t(t),i=Eee(t);return()=>{r(),i()}}},keyboard:{actions:()=>FAn().map(({id:t,scope:r})=>({id:t,scope:r})),keymaps:()=>Y3t().map(({id:t,title:r})=>({id:t,title:r,chords:nPt(t)})),activeKeymap:uI,invoke:t=>LAn(t),subscribe:t=>{const r=MAn(t),i=oU(t),a=Hpe(t),l=Qh()?.subscribe(t),d=Aw(t);return()=>{r(),i(),a(),l?.(),d()}},version:()=>RAn()+Sb(),stage:()=>{const t=Qh();return t?{surface:lyn(t).surface,mode:Hkn()}:{surface:null,mode:null}}}})}let Ykn=0,hee=null;const Bqe=new Set;function tkt(t){const r={generation:++Ykn,promise:t,active:!0};hee=r;for(const i of Bqe)i(r);return Bqe.clear(),r}function Xkn(){const t=hee;return t?.active?Promise.resolve(t):new Promise(r=>Bqe.add(r))}async function yKe(){for(;;){const t=await Xkn();if(await t.promise,hee===t&&t.active)return}}const IKt=15,Zkn=300,eIn=1e4,DKt="workspace";function tIn(){const t=WQe(DKt);return!t||t.version!==IKt?null:t}function rIn(t){ube(DKt,t)}function nIn(t){const{descriptor:r}=t;if(!r.persist)return null;let i;try{i=r.persist({id:r.id,title:t.title})}catch{return null}return i==null?null:{kind:r.kind,id:r.id,state:i}}function iIn(){const t={};let r=!1;for(const i of dPt()){if(!i.persistKindState)continue;let a;try{a=i.persistKindState()}catch{continue}a!=null&&(t[i.kind]=a,r=!0)}return r?t:void 0}function sIn(){const t=[];for(const i of FA()){const a=nIn(i);a&&t.push(a)}const r=iIn();return{version:IKt,workspace:wS(),documents:{open:t,activeId:I_(),...r?{kinds:r}:{}}}}async function oIn(t,r,i){for(const a of fPt(r.kind))try{if(await a.restore({id:r.id,state:r.state,active:r.id===i,store:t}))return!0}catch{}return!1}function rkt(t){return t?s9(t)?!0:pjr.has(t)?($mn(t),o5r(t),!0):xb(t):!1}function aIn(t,r){const i=r?.kinds??{},a=(r?.open.length??0)>0;for(const l of dPt())if(l.beginRestore)try{l.beginRestore({state:i[l.kind],hasDocumentsToRestore:a,store:t})}catch{}}function cIn(t){const r=new Set;for(const i of t)for(const a of fPt(i.kind))a.prepare&&r.add(a.prepare);return Promise.all([...r].map(i=>i().catch(()=>{})))}async function lIn(t,r){const i=r?.documents;if(aIn(t,i),!i||i.open.length===0){rkt(i?.activeId??null);return}await cIn(i.open);for(const a of i.open)await oIn(t,a,i.activeId);rkt(i.activeId)}function PKt(t){if(!pte()||ad()&&!v1()){let J=!1,X=null,G=()=>{};const ee=new Promise(ue=>{G=ue}),xe=tkt(ee);return Promise.all([lbe(),uQe()]).then(()=>{if(J){G();return}X=PKt(t),xe.active=!1,yKe().finally(G)}),()=>{J=!0,X?.()}}const r=tIn();r?.workspace&&SZ(r.workspace)&&CP(r.workspace)?CS(r.workspace):CS(uz(),{provisional:!0});let i=!1,a=null;const l=[],d=()=>{a!==null&&(clearTimeout(a),a=null),!(xkn()||t.playState!==void 0&&t.playState!=="stopped")&&rIn(sIn())},_=()=>{a!==null&&clearTimeout(a),a=setTimeout(d,Zkn)},g=()=>d();let b=null;const S=typeof window<"u"&&mIt(window.location.href)!==null,k=S||!(r?.documents?.open.length??0)?Promise.resolve():O8().catch(()=>{}),w=k.then(()=>S?void 0:lIn(t,r)).catch(()=>{}),N=new Promise(J=>{k.then(()=>{i||(b=setTimeout(()=>{J()},eIn))})}),P=Promise.race([w,N]).then(()=>{b!==null&&clearTimeout(b),!i&&(l.push(Aw(_)),window.addEventListener("pagehide",g))}),j=tkt(P);return()=>{i=!0,j.active=!1,hee===j&&(hee=null),b!==null&&clearTimeout(b);for(const J of l)J();window.removeEventListener("pagehide",g),a!==null&&d()}}function uIn(t){Xe.useEffect(()=>{const r=mIt(window.location.href);if(!r)return;let i=!1;const a=hh(),l=()=>!i&&hh()===a;return yKe().then(()=>{if(l())return bye(t,r,{updateUrl:!1,origin:"link"})}).catch(d=>{ua.error(`Could not restore shared editor view: ${d instanceof Error?d.message:String(d)}`,"editor")}),()=>{i=!0}},[t])}const nkt="vgai:stale-chunk-reload";function fIn(){typeof window>"u"||window.addEventListener("vite:preloadError",t=>{let r=0;try{r=Number(sessionStorage.getItem(nkt)??0)}catch{}if(!(Date.now()-r<6e4)){try{sessionStorage.setItem(nkt,String(Date.now()))}catch{}t.preventDefault(),window.location.reload()}})}const G$=[];function dIn(t){const r=G$.findIndex(i=>i.owner===t.owner&&i.id===t.id);return r>=0&&G$.splice(r,1),G$.push(t),G$.sort((i,a)=>(i.order??0)-(a.order??0)),()=>{const i=G$.indexOf(t);i>=0&&G$.splice(i,1)}}function pIn(t,r){const i=[];for(const a of Object.keys(r).sort())i.push(`${a}=${_In(r[a])}`);return`${t}|${i.join("&")}`}function _In(t){if(typeof t=="function")return"fn";if(typeof t=="symbol")return"symbol";if(t===void 0)return"undefined";try{return JSON.stringify(t)??"undefined"}catch{return`[${typeof t}]`}}const Rye=new Map,R_e=new Map,ikt=new WeakMap;let skt=Promise.resolve(),okt=null,mIn=1;function hIn(){return typeof WebGLRenderingContext<"u"&&typeof navigator<"u"&&!navigator.userAgent.toLowerCase().includes("jsdom")}async function gIn(){await Promise.race([r0e(),new Promise(t=>setTimeout(t,5e3))]),await Promise.race([new Promise(t=>requestAnimationFrame(()=>requestAnimationFrame(()=>t()))),new Promise(t=>setTimeout(t,250))]),await new Promise(t=>setTimeout(t,750)),await new Promise(t=>{const r=globalThis.requestIdleCallback;if(typeof r=="function"){r(()=>t(),{timeout:2e3});return}setTimeout(t,0)})}function yIn(){return okt??=gIn(),okt}function vIn(t){const r=ikt.get(t);if(r!==void 0)return r;const i=mIn++;return ikt.set(t,i),i}function bIn(t,r,i,a){const l=Rye.get(t);if(l)return Promise.resolve(l);const d=R_e.get(t);if(d)return d;const _=skt.then(async()=>{await yIn();const g=i.parameters.layout,b=g==="fullscreen"||g==="padded"||g==="centered"?g:"padded",S={...a,props:i.args,layout:b};if(r==="canvas"){const{capturePixiStoryThumbnail:w}=await Xo(async()=>{const{capturePixiStoryThumbnail:N}=await import("./story-pixi-preview-DxsuWuR0.js");return{capturePixiStoryThumbnail:N}},__vite__mapDeps([80,3,2,4,81,1,8,9,10,11,6]));return w(i.Component,S)}const{captureStoryComponentThumbnail:k}=await Xo(async()=>{const{captureStoryComponentThumbnail:w}=await import("./story-three-preview-Bz5tElwm.js");return{captureStoryComponentThumbnail:w}},__vite__mapDeps([82,3,2,4,81,6,64,11,9,1,8,10]));return k(i.Component,S)});return skt=_.then(()=>{},()=>{}),R_e.set(t,_),_.then(g=>{Rye.set(t,g),R_e.delete(t)},()=>R_e.delete(t)),_}function AIn({component:t,story:r,previewRevision:i,width:a=128,height:l=96}){const d=r.Component,_=`${t.surface}:${t.path}:${pIn(r.id,r.args)}:${vIn(d)}:${i}:${a}x${l}`,[g,b]=Xe.useState(()=>Rye.get(_)),[S,k]=Xe.useState(!1);return Xe.useEffect(()=>{let w=!1;if(k(!1),b(Rye.get(_)),!!hIn())return bIn(_,t.surface,r,{width:a,height:l}).then(N=>{w||b(N)},()=>{w||k(!0)}),()=>{w=!0}},[t.surface,l,_,r,a]),g?z.jsx("img",{src:g,alt:`${t.name} preview`,className:"vgai-component-thumbnail"}):z.jsx("span",{className:"vgai-component-thumbnail-fallback","data-component-preview":S?"failed":"capturing-story",children:z.jsx(a9,{kind:"component",name:t.name})})}const bbe="story:three",Abe="story:isolated",SIn="story:docs";function xIn(t,r){return t.surface==="dom"?!1:r===null||t.surface===r}function wIn({entry:t,previewRevision:r,width:i,height:a}){const l=t.detail;return z.jsx(AIn,{component:t.component,story:l,previewRevision:r,...i===void 0?{}:{width:i},...a===void 0?{}:{height:a}})}const CIn="story",EIn={id:CIn,owner:"./component-content-source",entries(t){const r=Q1e(),i=[];for(const a of t.components){if(!xIn(a,t.surface))continue;const l=dmn(r,a.name,a.path);l&&i.push({id:`${a.path}:${a.name}`,component:a,detail:l})}return i},subscribe:K1e,Thumbnail:wIn,open(t,r,i){const a=r.detail,l=r.component.surface==="three";FP(l?bbe:Abe,t,l?{modulePath:a.modulePath,storyName:a.name,title:i}:{modulePath:a.modulePath,storyName:a.name})}};function akt(t){return pmn(t.name,t.sourcePath)}const TIn={id:"portable-csf",owner:"./component-states",statesFor:(t,r)=>r.surface==="dom"?[]:akt(t).map(i=>({id:i.id,label:i.label})),apply:(t,r,i)=>{const a=akt(t).find(l=>l.id===r);if(a){if(i.surface==="three"){FP(bbe,i.store,{modulePath:a.modulePath,storyName:a.name,title:a.label});return}if(i.surface==="canvas"){FP(Abe,i.store,{modulePath:a.modulePath,storyName:a.name});return}ua.warn(`[portable-csf] no story document is registered for the "${i.surface}" surface, so state "${r}" of "${t.name}" could not be opened.`,"authoring")}}};function kIn(){let t=0,r=!1;const i=g=>{const b=++t;smn(),r0e().then(()=>{if(!(r||b!==t))return gmn(ad(),void 0,{deferUndeclared:!0,...g?{changedPaths:g}:{}})})};i();let a=null;const l=XNt(),d=Iw(()=>i()),_=jUr(i);return()=>{r=!0,t+=1,a!==null&&clearTimeout(a),l(),d(),_()}}const NKt="story",p9e=new Set,_9e=new Set;function IIn(t){const r=IWt({modulePath:t.modulePath,title:t.title}).leaf;return r===t.label?r:`${r} · ${t.label}`}function m9e(t){for(const r of Q1e())if(r.ok){for(const i of r.stories)if(t.storyId===void 0?r.modulePath===t.modulePath&&i.name===t.storyName:i.id===t.storyId)return{modulePath:r.modulePath,storyName:i.name,title:t.title??IIn({modulePath:r.modulePath,title:i.title,label:i.label})}}return null}function DIn(t,r,i){const a={modulePath:i.modulePath,storyName:i.storyName,title:i.title,...r.activate===void 0?{}:{activate:r.activate}};if(r.mode==="docs")return FP(SIn,t,a);const l=cQe({modulePath:i.modulePath,regions:aQe()});return l.medium===void 0?(imn(i.modulePath,l.reason),null):FP(l.medium==="three"?bbe:Abe,t,a)}function ckt(t){ua.warn(`No composed portable story carries the id ${JSON.stringify(t)}, so nothing opened it.`,"editor")}function PIn(){return g9({id:NKt,owner:"./story-opener",open:(t,r)=>{const i=m9e(r);return i?DIn(t,r,i):(r.modulePath?p9e.add(r.modulePath):r.storyId!==void 0&&(_9e.add(r.storyId),lmn()&&ckt(r.storyId)),null)},settle:async()=>{await ijr();const t=[...p9e],r=[..._9e];if(p9e.clear(),_9e.clear(),await Promise.all(t.map(i=>_mn(ad(),i))),r.length!==0){await umn();for(const i of r)m9e({storyId:i})||ckt(i)}},ready:async(t,r)=>{if(r.mode==="docs")return;const i=m9e(r);if(!(!i||cQe({modulePath:i.modulePath,regions:aQe()}).medium!=="three")&&!await xE(()=>Pw(t)!==null,m9))throw new Error(`The requested Object3D view did not mount for document: ${t}`)}})}const NIn={actions:()=>{if(!NAt(Abe)&&!NAt(bbe))return[];const t=[];for(const r of Q1e()){if(!r.ok)continue;const i=r.modulePath.split("/").pop()??r.modulePath;for(const a of r.stories)t.push({id:`story:${a.id}`,label:`Open Story: ${a.name} — ${i}`,execute:()=>void fv().workspace.open({kind:NKt,modulePath:r.modulePath,storyName:a.name,title:a.name})})}return t},subscribe:t=>K1e(t)},OIn="packages/editor/src/stories/story-capture-command.ts",uq="capture-story-variants";async function FIn(t){if(document.visibilityState==="hidden")return{ok:!1,error:"story capture needs a PRESENTING tab — the editor tab is hidden, so the browser suspends the frames a story mount must paint. Bring the editor tab to the foreground (or unminimize its window) and re-run."};const r=t.modulePath;if(typeof r!="string"||r==="")return{ok:!1,error:`${uq} requires a project-relative modulePath.`};const i=t.story;if(i!==void 0&&typeof i!="string")return{ok:!1,error:`${uq} story must be a CSF export name.`};const a=(l,d,_)=>{if(l===void 0)return d;if(typeof l!="number"||!Number.isInteger(l)||l<64||l>1024)throw new Error(`${uq} ${_} must be an integer from 64 to 1024.`);return l};try{const l=await(async()=>{try{const w=await ige("vgai.project.json");if(!w)return null;const N=JSON.parse(w),P=N.resolution?.width,j=N.resolution?.height;return typeof P!="number"||typeof j!="number"||P<64||j<64||P>4096||j>4096?null:{width:Math.min(1024,Math.round(P)),height:Math.min(1024,Math.round(j))}}catch{return null}})(),d=a(t.width,l?.width??960,"width"),_=a(t.height,l?.height??540,"height"),g=uNt(uq,t.camera);if(typeof g=="string")return{ok:!1,error:g};const b=fNt(uq,t.pose);if(typeof b=="string")return{ok:!1,error:b};const{captureProjectStoryVariants:S}=await Xo(async()=>{const{captureProjectStoryVariants:w}=await import("./story-capture-t1kkknek.js");return{captureProjectStoryVariants:w}},__vite__mapDeps([83,60,1,2,3,4,8,9,10,80,81,11,6,82,64]));return{ok:!0,data:{...await S(ad(),{modulePath:r,...i===void 0?{}:{story:i},width:d,height:_,...g?{camera:g}:{},...b?{pose:b}:{}})}}}catch(l){return{ok:!1,error:l instanceof Error?l.message:String(l)}}}const RIn={[uq]:{timeoutMs:12e4,derivedRefresh:"if-content-changed",handle:FIn}};function MIn(){const t=Q0n(EIn),r=dIn(TIn),i=PIn(),a=SIt(NIn),l=wIt(OIn,RIn),d=kIn(),_=K1e(()=>{Gq()});return()=>{_(),d(),l(),a(),i(),r(),t()}}let h9e=null;const LIn=new Set;function jIn(t){return h9e=t,$qe(),()=>{h9e===t&&(h9e=null,$qe())}}function $qe(){for(const t of LIn)t()}let Mm=null,OKt=0;const qqe=new Set;function BIn(t){return qqe.add(t),()=>qqe.delete(t)}function lkt(){return OKt}function $In(t,r){if(Mm){if(r===null){if(Mm[t]?.isConnected)return}else if(Mm[t]===r)return;if(r===null&&(t==="outliner"||t==="properties"||t==="content")){const i={...Mm};delete i[t],Mm=i}else r!==null&&(Mm={...Mm,[t]:r});r!==null&&FKt(t,r),OKt+=1;for(const i of qqe)i()}}function FKt(t,r){r.dataset.vgaiPart=t}const ez=new Map;let RKt=0;const zqe=new Set;function qIn(t,r){if(r){if(!ez.delete(t.id))return}else{const i=ez.get(t.id);if(i?.element===t.element&&i.documentId===t.documentId)return;ez.set(t.id,{...t})}RKt+=1;for(const i of[...zqe])i()}function zIn(t){return zqe.add(t),()=>{zqe.delete(t)}}function ukt(){return RKt}function ER({children:t,row:r=!1,center:i=!1}){return z.jsx("div",{className:"vgai-editor-shell vgai-part",onWheel:a=>a.stopPropagation(),"data-editor-hotkey-scope":"workspace","data-editor-hotkey-fallback":!0,style:{display:"flex",flexDirection:r?"row":"column",justifyContent:i?"center":void 0,width:"100%",height:"100%",minHeight:0,minWidth:0,position:"relative",fontFamily:"var(--vgai-font-sans)",fontSize:"var(--vgai-font-base)",color:"var(--vgai-content-primary)"},children:t})}function UIn({children:t}){return z.jsx(z.Fragment,{children:t})}function VIn(){return Mm?vS.createPortal(z.jsx(ER,{center:!0,children:z.jsx(VEn,{})}),Mm.header):null}function JIn(){return null}function WIn(){const t=Xe.useRef(null);return Xe.useEffect(()=>{const r=t.current;if(r)return eKt(r),()=>uCn(r)},[]),z.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",minHeight:0},children:[z.jsx("div",{ref:t,className:"vgai-vscode-outliner-header"}),z.jsx("div",{style:{flex:1,minHeight:0,display:"flex",flexDirection:"column"},children:z.jsx(oKt,{})})]})}const rhe=new Map,Uqe=new Set;let Vqe=0;function HIn(t,r){if(r){if(rhe.get(t)===r)return;rhe.set(t,r)}else if(!rhe.delete(t))return;Vqe++;for(const i of Uqe)i()}const nhe=new Map,Jqe=new Set;let Wqe=0;function GIn(t,r){if(r){if(nhe.get(t)===r)return;nhe.set(t,r)}else if(!nhe.delete(t))return;Wqe++;for(const i of Jqe)i()}function QIn(){return Xe.useSyncExternalStore(BDt,Ubt,Ubt),Xe.useSyncExternalStore(t=>(Jqe.add(t),()=>Jqe.delete(t)),()=>Wqe,()=>Wqe),z.jsx(z.Fragment,{children:[...U9e("left"),...U9e("right")].map(t=>{const r=nhe.get(t.id);if(!r)return null;const i=t.Content;return z.jsx(Xe.Fragment,{children:vS.createPortal(z.jsx(i,{}),r)},t.id)})})}function KIn(){return Xe.useSyncExternalStore(g0e,PAt,PAt),Xe.useSyncExternalStore(t=>(Uqe.add(t),()=>Uqe.delete(t)),()=>Vqe,()=>Vqe),z.jsx(z.Fragment,{children:gE().map(t=>{const r=rhe.get(t.id);return r?z.jsx(Xe.Fragment,{children:vS.createPortal(z.jsx(ER,{children:z.jsx(HEn,{utility:t})}),r)},t.id):null})})}function YIn({descriptor:t,viewId:r,slot:i,parking:a,visible:l,inspector:d}){const[_]=Xe.useState(()=>document.createElement("div"));return Xe.useLayoutEffect(()=>{_.className="vgai-vscode-document-slot",_.dataset.vgaiDocument=t.id,_.dataset.vgaiArea=t.area??"",_.style.cssText=`display:${l?"flex":"none"};flex-direction:column;width:100%;height:100%;min-width:0;min-height:0;position:relative;`},[_,t.id,t.area,l]),Xe.useLayoutEffect(()=>((i??a).appendChild(_),()=>_.remove()),[_,i,a]),vS.createPortal(z.jsxs(ER,{children:[z.jsx(wQt,{descriptor:t,viewId:r,active:l,chrome:!t.area}),d&&z.jsx(Wwn,{})]}),_)}let MKt=!0;function XIn({arrangement:t,immersivePlay:r}){const i=D0();uIn(i);const a=sKe(i);Xe.useLayoutEffect(()=>{MKt=a.column},[a.column]);const l=ez.get(X9e()??"")?.element??Mm?.center;Xe.useLayoutEffect(()=>{if(!l)return;const k=()=>pTt({x:0,y:0,width:l.clientWidth,height:l.clientHeight}),w=new ResizeObserver(k);return w.observe(l),k(),()=>{w.disconnect(),pTt(null)}},[l]),Xe.useSyncExternalStore(i.subscribe,i.getShellSnapshot??i.getSnapshot),Xe.useSyncExternalStore(Aw,Sb,Sb),Xe.useSyncExternalStore(zIn,ukt,ukt),Xe.useSyncExternalStore(BIn,lkt,lkt),Xe.useLayoutEffect(()=>{const k=Q7r({...t?{arrangement:t}:{},...r===void 0?{}:{immersivePlay:r},playUtilities:[]});return t&&CS(t.id),ERr(),k},[t,r]);const d=i.playState!=="stopped",_=Xe.useSyncExternalStore(Eee,P8).play?.keepPanelsVisible;if(Xe.useEffect(()=>{Ukn(d,bKt())},[d,r,_]),Xe.useEffect(()=>PKt(i),[i]),!Mm)return null;const g=Mm.center,b=FA(),S=AE()??b[0]??null;return globalThis.__vgaiBridge={documents:b.map(k=>k.descriptor.id),active:S?.descriptor.id??null,workspace:t?.id??null,areas:b.flatMap(k=>k.descriptor.area?[{id:k.descriptor.id,area:k.descriptor.area}]:[]),slots:[...ez.values()].map(({id:k,documentId:w,element:N})=>({id:k,documentId:w,visible:!!N}))},z.jsxs(z.Fragment,{children:[[...ez.values()].map(k=>{const w=b.find(N=>N.descriptor.id===k.documentId)?.descriptor;return w?z.jsx(YIn,{descriptor:w,viewId:k.id,slot:k.element??void 0,parking:g,visible:!!k.element,inspector:a.card&&w.id===S?.descriptor.id},k.id):null}),b.length===0&&vS.createPortal(z.jsx(ER,{children:z.jsx("div",{className:"vgai-vscode-empty",children:"No document open"})}),Mm.center),Mm.outliner&&vS.createPortal(z.jsx(ER,{children:z.jsx(WIn,{})}),Mm.outliner),Mm.properties&&a.column&&vS.createPortal(z.jsx(ER,{children:z.jsx(uKe,{})}),Mm.properties),Mm.content&&vS.createPortal(z.jsx(ER,{children:z.jsx(pkn,{kind:"assets"})}),Mm.content),z.jsx(KIn,{}),z.jsx(QIn,{})]})}async function ZIn(t){Mm=t;for(const[G,ee]of Object.entries(t))ee&&FKt(G,ee);t.chromeRoot.id="editor-chrome-root",SMr({Frame:UIn,Header:VIn,Footer:JIn,Workspace:XIn,Document:vSn}),mkn(),Wyn();const r=Nxn();r&&Dxn(r,Date.now())&&ua.warn(kxn(r,Date.now()),"editor"),fIn(),ejr(),Kkn(),MIn(),await Promise.all([Q3t(),XRr()]),p9r(t.chromeRoot),t.chromeRoot.classList.toggle("vgai-native-menus",qye()?.nativeMenus===!0);const i=document.createElement("div");i.id="editor-root",i.className="vgai-part",i.style.cssText="position:absolute;inset:0;pointer-events:none;z-index:10;",t.chromeRoot.appendChild(i),Hqe.createRoot(i).render(z.jsx(Qxn,{}));const a={activeKeymap:()=>fv().keyboard.activeKeymap(),invoke:G=>fv().keyboard.invoke(G),subscribe:G=>fv().keyboard.subscribe(G),facts:()=>{const G=fv(),ee=G.keyboard.stage();return{surface:ee.surface,mode:ee.mode,documentKind:G.documents.active()?.kind??null,play:G.session.playState()}},report:(G,ee)=>{const xe=fv();G==="error"?xe.console.error(ee,"editor"):xe.console.warn(ee,"editor")}},l={whenRestored:yKe,activeSource:()=>{const G=fv().documents.active();if(!G)return null;const ee=G.kind==="model"&&G.id.startsWith("model:")?G.id.slice(6):"";return{kind:G.kind,path:ee}},list:()=>FA().map(G=>{const ee=G.descriptor.area?vRr().find(xe=>xe.id===G.descriptor.area):void 0;return{id:G.descriptor.id,title:G.title,...ee?{area:{id:ee.id,place:ee.place,ratio:ee.ratio}}:{}}}),activeId:()=>AE()?.descriptor.id??null,subscribe:G=>{const ee=Aw(G),xe=bRr(G);return()=>{ee(),xe()}},activate:(G,ee)=>{ee?i5r(G,ee):xb(G)},close:G=>{if(Y8(G))return;const ee=FA().find(xe=>xe.descriptor.id===G);ee&&a.report("warn",`“${ee.title}” has unsaved changes, so it stayed open. Save it (⌘S) and close it again.`)},setView:(G,ee)=>qIn(G,ee)},d={elements:()=>fv().history.elements(),onElement:G=>fv().history.onElement(G),onInvalidated:G=>fv().history.onInvalidated(G),changed:()=>fv().history.changed(),focusedResource:()=>fv().history.focusedResource(),focusedDocument:()=>{const G=fv().documents.active();return G?{id:G.id,label:G.title}:null},setDelegate:G=>fv().history.setDelegate(G),report:a.report},_={setProvider:G=>fv().files.setProvider(G),report:a.report},g={setProvider:G=>fv().settings.setProvider(G),adapterValues:()=>[...x7r()],workbenchValues:()=>{const G=Mm?.chromeRoot;if(!G)return[];const ee=getComputedStyle(G).getPropertyValue("--vgai-command-bar-height").trim(),xe=Number.parseFloat(ee);return!Number.isFinite(xe)||xe<=0?[]:[["window.titleBarHeight",Math.round(xe)]]},lookId:()=>cU(),notify:G=>{fv().notify(G)},subscribe:G=>{const ee=d0e(G),xe=wPt(G);return()=>{ee(),xe()}},report:a.report},b={list:()=>Qyn().map(G=>({id:G.id,label:G.label,category:G.category})),invoke:G=>Yyn(G),subscribe:G=>Kyn(G),setPaletteOpener:G=>Gyn(G),setCommandExecutor:G=>Xyn(G),report:a.report},S={setDelegate:G=>qFr(G?{show:G}:null)},k={list:()=>S4t().map(G=>({view:G.view,title:G.title,verbs:G.verbs.map(ee=>({id:ee.id,...ee.title?{title:ee.title}:{}}))})),invoke:(G,ee,xe)=>w4t(G,ee,xe),subscribe:G=>x4t(G)},w={list:()=>gE().map((G,ee)=>({id:G.id,title:G.title,order:G.order??ee})),subscribe:G=>g0e(G),offerBody:(G,ee)=>HIn(G,ee)};let N=!0,P=null,j=null;jIn(()=>N);const J={setActiveStaticPanel:G=>TAt(LQe.find(ee=>ee.kind===G)?.kind??null),focusCompactInspector:()=>{if(MKt)return!1;const G=Mm?.center.querySelector('[data-testid="compact-inspector-card"]');return G?(G.tabIndex=-1,G.focus(),TAt("inspector"),!0):!1},setPaneActive:G=>{N!==G&&(N=G,$qe())},setImmersive:G=>{P?.(),P=null,!(!G||!Mm)&&(P=Pkn({root:Mm.chromeRoot,hideChrome:()=>G.enter(),showChrome:()=>G.exit()}))},setDockCommands:G=>{j?.(),j=null,G&&(j=X7r({showUtility:ee=>G.showUtility(ee),toggleUtility:ee=>G.toggleUtility(ee),ensureUtility:ee=>G.ensureUtility(ee),closeUtility:ee=>G.closeUtility(ee),showStaticPanel:ee=>G.showStaticPanel(ee),setFocus:ee=>G.setFocus(ee),toggleFocus:()=>G.toggleFocus(),captureUtilities:ee=>{for(const xe of ee)G.showUtility(xe);return()=>{for(const xe of ee)G.closeUtility(xe)}},showAuxiliary:()=>J.report("warn","Undo history has no panel under the VS Code frame: the stack is the workbench's own (U4), reached through Edit → Undo/Redo and the Timeline.")}))},report:(G,ee)=>a.report(G,ee)};return{host:i,keyboard:a,documents:l,history:d,files:_,commands:b,notifications:S,views:k,utilities:w,output:{setProvider:Qkn},settings:g,status:{list:()=>["left","right"].flatMap(G=>U9e(G).map((ee,xe)=>({id:ee.id,title:ee.name,align:G,order:ee.order??xe}))),subscribe:G=>BDt(G),offerBody:(G,ee)=>GIn(G,ee)},game:J,offerPart:$In}}function eDn(t){const r=Object.keys(t.packages);return FIr({id:t.id,packages:r,look:t.look,workspace:t.workspace,nativeMenus:t.nativeMenus}),NPt(r.flatMap(i=>t.packages[i]??[])),{mountVgai:ZIn}}const{mountVgai:s6n}=eDn({id:"editor",packages:{"@volter/editor-blender":OIr},look:"blender",workspace:"model"});export{ZDn as $,yvn as A,fo as B,SE as C,eO as D,NDn as E,ODn as F,VN as G,U_ as H,Ibn as I,j4n as J,ZPn as K,QDn as L,B0e as M,Z8 as N,LP as O,k2t as P,dvn as Q,DDn as R,DFr as S,Ru as T,i6n as U,_Qe as V,FA as W,$mn as X,I_ as Y,ua as Z,Xo as _,o_ as a,NWt as a$,z2t as a0,U2t as a1,e3n as a2,My as a3,So as a4,pDn as a5,bS as a6,S8 as a7,mDn as a8,EWt as a9,W9r as aA,MDn as aB,XPt as aC,hZ as aD,_Dn as aE,s7r as aF,Ykt as aG,d5r as aH,SX as aI,V_n as aJ,BDn as aK,j0e as aL,VDt as aM,W_ as aN,GWt as aO,k3t as aP,PDn as aQ,zY as aR,zPn as aS,UPn as aT,IWt as aU,cmn as aV,umn as aW,MPn as aX,cQe as aY,PWt as aZ,TWt as a_,VPn as aa,Z4n as ab,EGt as ac,Ywn as ad,V0e as ae,aMe as af,oz as ag,TMr as ah,NP as ai,Wa as aj,IDn as ak,Ny as al,kze as am,JR as an,o3n as ao,kX as ap,FDn as aq,c3n as ar,Zh as as,RDn as at,J9r as au,$Dn as av,yw as aw,np as ax,HR as ay,ad as az,GDn as b,b8 as b$,G_n as b0,GR as b1,jgn as b2,aQe as b3,Fee as b4,P5r as b5,oU as b6,uI as b7,ep as b8,o4n as b9,UR as bA,uv as bB,CFr as bC,k_ as bD,v3t as bE,i3n as bF,LOr as bG,vDn as bH,XNt as bI,u3n as bJ,s3n as bK,kDn as bL,l3n as bM,jIr as bN,ige as bO,Jkt as bP,vee as bQ,wg as bR,VDn as bS,Pbn as bT,w4t as bU,g_e as bV,B$e as bW,rI as bX,tgn as bY,Ab as bZ,X1e as b_,Nq as ba,l4n as bb,ph as bc,rf as bd,x8 as be,zye as bf,Eze as bg,o0e as bh,Aw as bi,Sb as bj,Nee as bk,MP as bl,e0e as bm,I8 as bn,wm as bo,Pw as bp,O5r as bq,TDr as br,X4n as bs,eSn as bt,B4n as bu,Vkt as bv,hE as bw,_ee as bx,JHt as by,GPn as bz,hz as c,mUe as c$,k9 as c0,fte as c1,gv as c2,jd as c3,Tu as c4,Ebt as c5,hDn as c6,Aee as c7,Cbt as c8,gDn as c9,R4n as cA,tAt as cB,uDn as cC,UIr as cD,M4n as cE,xAn as cF,Nze as cG,By as cH,Ajr as cI,qDn as cJ,w4n as cK,eLe as cL,SAn as cM,m1n as cN,S4n as cO,m4n as cP,b4n as cQ,v4n as cR,c9 as cS,h4n as cT,D4n as cU,y4n as cV,g4n as cW,A4n as cX,I4n as cY,C4n as cZ,P4n as c_,FNr as ca,IR as cb,YGt as cc,q4t as cd,jA as ce,gAn as cf,YDn as cg,XDn as ch,KDn as ci,zP as cj,V4t as ck,d4n as cl,_An as cm,f4n as cn,IFe as co,ZPt as cp,mSn as cq,$kt as cr,BIr as cs,zIr as ct,HQe as cu,Mkt as cv,L4n as cw,lDn as cx,dDn as cy,fDn as cz,pU as d,a3n as d$,k0 as d0,E4n as d1,T4n as d2,p4n as d3,_4n as d4,x4n as d5,N4n as d6,DQe as d7,k4n as d8,wAn as d9,CZ as dA,NUe as dB,WDn as dC,JDn as dD,zDn as dE,J4n as dF,$4n as dG,O2n as dH,z4n as dI,U4n as dJ,V4n as dK,dte as dL,$Ht as dM,i4n as dN,K9r as dO,Zvn as dP,n4n as dQ,TGt as dR,v1n as dS,Nbn as dT,e4n as dU,t4n as dV,XMe as dW,rme as dX,ZMe as dY,jDn as dZ,LDn as d_,O4n as da,F4n as db,vhe as dc,OP as dd,D5r as de,Y8 as df,z4t as dg,BPn as dh,qPn as di,ljr as dj,Sw as dk,xb as dl,jPn as dm,LPn as dn,$Pn as dp,u4n as dq,s4n as dr,NGt as ds,oNt as dt,IZ as du,a5r as dv,W4t as dw,Gwn as dx,H8 as dy,bDn as dz,fv as e,UDn as e0,OUe as e1,J2n as e2,JPn as e3,WPn as e4,t6n as e5,e6n as e6,H4n as e7,G4n as e8,W4n as e9,qGt as eA,SDn as eB,xDn as eC,SQe as eD,o8 as eE,V8 as eF,Khn as eG,T_ as eH,wCt as eI,lHt as eJ,Lm as eK,mHt as eL,Fy as eM,s6n as eN,yb as ea,q4n as eb,Q4n as ec,pv as ed,a4n as ee,QPn as ef,KPn as eg,WHt as eh,c4n as ei,Qh as ej,Eq as ek,CDn as el,HPn as em,n6n as en,G4t as eo,Y4n as ep,TDn as eq,wDn as er,ADn as es,bP as et,K4n as eu,yDn as ev,XPn as ew,EDn as ex,r6n as ey,YPn as ez,t3n as f,CE as g,CUe as h,r3n as i,dE as j,U0e as k,Ry as l,dNt as m,r4n as n,Na as o,WUe as p,od as q,n3n as r,Ss as s,Oo as t,D0 as u,mGt as v,fLr as w,$Qe as x,R$r as y,gvn as z};
|