@volter/editor 0.5.59 → 0.5.60
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 +206 -232
- package/dist/assets/{AudioViewer-C5C4xeUl.js → AudioViewer-C9JP7n49.js} +1 -1
- package/dist/assets/{EntityModelDocument-DyhU8umO.js → EntityModelDocument-SFgsuX4_.js} +1 -1
- package/dist/assets/{EnvironmentAssetDocument-D_VZ2iFj.js → EnvironmentAssetDocument-DEqKuki2.js} +1 -1
- package/dist/assets/{GameplaySessionTimeline-kIIuhFBI.js → GameplaySessionTimeline-BtEPIu2F.js} +1 -1
- package/dist/assets/{ImageViewer-Crv-yzT_.js → ImageViewer-CyIXlQTG.js} +1 -1
- package/dist/assets/{InspectorObjectPreview-CO-GVXfu.js → InspectorObjectPreview-MDmTPFBT.js} +1 -1
- package/dist/assets/{JsonAssetDocument-Dtg2QwPN.js → JsonAssetDocument-Zyv_CDpC.js} +1 -1
- package/dist/assets/{ModelAssetDocument-BpZ8SZXe.js → ModelAssetDocument-BKdnWaJL.js} +1 -1
- package/dist/assets/{NonThreeAuthoringBootstrap-0nm5Hl3v.js → NonThreeAuthoringBootstrap-ab96Xbnn.js} +2 -2
- package/dist/assets/{Object3DPreview-dHzSO5Ym.js → Object3DPreview-ChopdNF4.js} +2 -2
- package/dist/assets/{OnlineAssetDetail-DAdWXnmZ.js → OnlineAssetDetail-B_l8XkeE.js} +2 -2
- package/dist/assets/{SourceAssetViewer-D3m0wF8T.js → SourceAssetViewer-zpxF5DOe.js} +2 -2
- package/dist/assets/{StageHost-DD_m8W0k.js → StageHost-B4P-uvV9.js} +4 -4
- package/dist/assets/{ToolObject3DPreview-CWdklUZ1.js → ToolObject3DPreview-DGcT5dDK.js} +1 -1
- package/dist/assets/{TransientHint-aFFUtbSY.js → TransientHint-9_u15mth.js} +1 -1
- package/dist/assets/{VideoViewer-BhH8aSzx.js → VideoViewer-3I_zUWEC.js} +1 -1
- package/dist/assets/{asset-editor-persistence-D5wYXQEL.js → asset-editor-persistence-B6Yg7dTC.js} +1 -1
- package/dist/assets/{blender-node-editor.document-D-hrVHmR.js → blender-node-editor.document-DGn6U6Kf.js} +1 -1
- package/dist/assets/blender-properties-tab-DkE9ensL.js +3 -0
- package/dist/assets/blender-runtime-host-JKPuUKtZ.js +4 -0
- package/dist/assets/{blender-runtime-skin-AJdtKKnf.js → blender-runtime-skin-BFLh4nHG.js} +1 -1
- package/dist/assets/{blender-runtime.document-JlYY0bb7.js → blender-runtime.document-C60VEa1_.js} +3 -3
- package/dist/assets/{blender-timeline.document-5UN8V20F.js → blender-timeline.document-D9BOYb0q.js} +1 -1
- package/dist/assets/{blender-uv-editor.document-maFJQzgA.js → blender-uv-editor.document-BK2pP2sR.js} +1 -1
- package/dist/assets/{blender-version.status-CukRH8K3.js → blender-version.status-ZqfW0upF.js} +1 -1
- package/dist/assets/{blender.command-CY6QiXxp.js → blender.command-BLtAEuIZ.js} +1 -1
- package/dist/assets/{browserAll-BQIn-DRw.js → browserAll-DTuU4PmC.js} +1 -1
- package/dist/assets/{edit-mode-authoring-CWTeROGv.js → edit-mode-authoring-DBEoND0w.js} +1 -1
- package/dist/assets/{hosted-asset-materialization-DcthzsYS.js → hosted-asset-materialization-6HtWQ0od.js} +1 -1
- package/dist/assets/{index-DmtPt6RQ.js → index-DuB3wHKD.js} +12 -12
- package/dist/assets/{models.finder-CrDJ41Cp.js → models.finder-Bs46IncP.js} +1 -1
- package/dist/assets/{product-CqAh01LU.js → product-FSoI1WhZ.js} +1 -1
- package/dist/assets/properties-bone-constraints.inspector-QML_-0yQ.js +1 -0
- package/dist/assets/properties-bone.inspector-DSDyP6-P.js +1 -0
- package/dist/assets/properties-collection.inspector-jic5mzgz.js +1 -0
- package/dist/assets/properties-constraints.inspector-TLHv00p7.js +1 -0
- package/dist/assets/properties-data.inspector-BJBPl88V.js +1 -0
- package/dist/assets/properties-material.inspector-xxWuVjrx.js +1 -0
- package/dist/assets/properties-modifiers.inspector-CWjdmu_J.js +1 -0
- package/dist/assets/properties-object.inspector-D15l44Tq.js +1 -0
- package/dist/assets/properties-output.inspector-DVuGGSBb.js +1 -0
- package/dist/assets/properties-particles.inspector-B94x32Ez.js +1 -0
- package/dist/assets/properties-physics.inspector-9EYMjwFP.js +1 -0
- package/dist/assets/properties-render.inspector-8yA_8luD.js +1 -0
- package/dist/assets/properties-scene.inspector-WM7qZhJ4.js +1 -0
- package/dist/assets/properties-texture.inspector-Cno5lCIz.js +1 -0
- package/dist/assets/properties-view-layer.inspector--PX0c9h6.js +1 -0
- package/dist/assets/properties-world.inspector-C3EuydM_.js +1 -0
- package/dist/assets/{react-story-board-CnCZAhn6.js → react-story-board-d_OfX68Z.js} +1 -1
- package/dist/assets/{react-three-rapier.esm-DsJqtzy_.js → react-three-rapier.esm-Ch_Gf2qR.js} +1 -1
- package/dist/assets/{spark.module-uQlq--TY.js → spark.module-B_-x7Z29.js} +1 -1
- package/dist/assets/{stage-keyboard-DzZMNYAr.js → stage-keyboard-C9wzGFxu.js} +1 -1
- package/dist/assets/{stage-overlay-set-D6OOz1L9.js → stage-overlay-set-D7J-N5eX.js} +1 -1
- package/dist/assets/{stage-presence-markers-BUaSzKCv.js → stage-presence-markers-DvbNl1W4.js} +1 -1
- package/dist/assets/{story-capture-C2ExQiuI.js → story-capture-D0H-H2_b.js} +1 -1
- package/dist/assets/{story-pixi-preview-C6n-a2_M.js → story-pixi-preview-Cafk1Xbk.js} +1 -1
- package/dist/assets/{story-three-preview-BazrPMDu.js → story-three-preview-ByMTQc8w.js} +2 -2
- package/dist/assets/{webworkerAll-FJN9IDir.js → webworkerAll-CS1yjkoi.js} +1 -1
- package/dist/assets/{world-documents-B6usBw3s.js → world-documents-CWiw361z.js} +1 -1
- package/dist-node/cli.js +7 -7
- package/package.json +7 -7
- package/dist/assets/blender-outliner-model-FscHWpfW.js +0 -1
- package/dist/assets/blender-properties-tab-Czi3_yYZ.js +0 -3
- package/dist/assets/blender-runtime-host-C3rVDyG8.js +0 -4
- package/dist/assets/properties-bone-constraints.inspector-BPN6BRJV.js +0 -1
- package/dist/assets/properties-bone.inspector-C4xD61mX.js +0 -1
- package/dist/assets/properties-collection.inspector-BTps8t6G.js +0 -1
- package/dist/assets/properties-constraints.inspector-BVvP6esW.js +0 -1
- package/dist/assets/properties-data.inspector-CKKO8DVT.js +0 -1
- package/dist/assets/properties-material.inspector-BGfT8kHT.js +0 -1
- package/dist/assets/properties-modifiers.inspector-DJRANpOY.js +0 -1
- package/dist/assets/properties-object.inspector-CgVfWmw2.js +0 -1
- package/dist/assets/properties-output.inspector-CBl5xEMZ.js +0 -1
- package/dist/assets/properties-particles.inspector-CxVZ09ZY.js +0 -1
- package/dist/assets/properties-physics.inspector-DmG3i3vY.js +0 -1
- package/dist/assets/properties-render.inspector-TCoPfEn0.js +0 -1
- package/dist/assets/properties-scene.inspector-BjsTOBiY.js +0 -1
- package/dist/assets/properties-texture.inspector-D1X9iyVV.js +0 -1
- package/dist/assets/properties-view-layer.inspector-dXTVxzzk.js +0 -1
- package/dist/assets/properties-world.inspector-CRxJK930.js +0 -1
|
@@ -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 Dkr}from"./index-D2LwEE0L.js";import{a as Vqe}from"./client-DNXj_opT.js";import{d as vE,w as Rye,bJ as lkt,am as ez,Y as ukt,b5 as fkt,a0 as NA,by as Jqe,av as Mye,b2 as Pkr,al as Nkr,aV as $P,z as Wqe,I as ER,i as hv,p as bE,aa as Hqe,ab as hX,aJ as sZ,aS as Okr,aT as m9e,aU as dkt,aI as gX,bx as yI,a as pkt,b4 as Fkr,aY as kq,x as SS,V as Tc,Q as H8,ay as Rkr,aL as _kt,bz as Mkr,bA as Lkr,a4 as Lye,bB as jkr,bC as Bkr,bD as mkt,L as qR,h as nhe,f as h9e,bE as $kr,J as qkr,aE as hkt,a9 as gFe,aD as zkr,Z as gkt,b1 as fq,bt as ihe,b6 as ykt,aG as vkt,b7 as bkt,bF as Akt,aH as Gqe,aB as SP,k as jye,b as vb,$ as Bye,aM as Ukr,aQ as Vkr,aN as Skt,bG as Jkr,bH as xkt,bj as Wkr,a1 as oP,aO as F1t,bw as R1t,aP as M1t,_ as Hkr,bI as Gkr,ap as xS,bl as wkt,cd as Qkr,ce as Kkr,cf as Ckt,q as L1t,cg as j1t,ch as g9e,ci as y9e,cj as Ykr,ck as Xkr,cl as Zkr,cm as eIr,cn as B1t,co as $1t,cp as v9e,cq as yFe,cr as R_e,cs as Ekt,ct as Tkt,cu as b9e,O as RY,ac as MY,v as dq,j as Bp,H as QN,cv as kkt,cw as Ikt,F as yX,K as tIr,y as rIr,cx as nIr,cy as iIr,cz as sIr,cA as oIr,G as aIr,bc as cIr,bY as lIr,aW as u9,a$ as uIr,aX as fIr,bK as Dkt,a_ as dIr,b3 as pIr,be as _Ir,as as Qqe,aC as q1t,bh as mIr,aA as hIr,cB as gIr,c6 as yIr,cC as vIr,cD as bIr,bf as AIr,bL as SIr,cE as xIr,W as z1t,cF as Pkt}from"./three.module-BynznMJN.js";import{a as wIr,c as U1t,g as Nkt}from"./_commonjsHelpers-D6-XlEtG.js";const CIr="modulepreload",EIr=function(t){return"/"+t},V1t={},la=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=EIr(S),S in V1t)return;V1t[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":CIr,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)})},TIr=[{entryPath:"@volter/editor-blender/contributions/blender-node-editor.document.tsx",load:()=>la(()=>import("./blender-node-editor.document-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/blender-node-editor.document-DGn6U6Kf.js","assets/jsx-runtime-DPjLkJKQ.js","assets/_commonjsHelpers-D6-XlEtG.js","assets/index-DaQZGF7d.js","assets/index-D_NuPfjr.js","assets/blender-runtime-host-JKPuUKtZ.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-D9BOYb0q.js","assets/blender-runtime-skin-BFLh4nHG.js","assets/LineSegments2-vfeDUBfs.js","assets/blender-uv-editor.document-BK2pP2sR.js","assets/blender-runtime.document-C60VEa1_.js","assets/blender-version.status-ZqfW0upF.js","assets/blender.command-BLtAEuIZ.js","assets/blender.status-ujwGU6dU.js","assets/models.finder-Bs46IncP.js","assets/properties-bone-constraints.inspector-QML_-0yQ.js","assets/blender-properties-tab-DkE9ensL.js","assets/properties-constraints.inspector-TLHv00p7.js","assets/properties-bone.inspector-DSDyP6-P.js","assets/properties-collection.inspector-jic5mzgz.js","assets/properties-data.inspector-BJBPl88V.js","assets/properties-material.inspector-xxWuVjrx.js","assets/properties-modifiers.inspector-CWjdmu_J.js","assets/properties-object.inspector-D15l44Tq.js","assets/properties-output.inspector-DVuGGSBb.js","assets/properties-particles.inspector-B94x32Ez.js","assets/properties-physics.inspector-9EYMjwFP.js","assets/properties-render.inspector-8yA_8luD.js","assets/properties-scene.inspector-WM7qZhJ4.js","assets/properties-texture.inspector-Cno5lCIz.js","assets/properties-view-layer.inspector--PX0c9h6.js","assets/properties-world.inspector-C3EuydM_.js","assets/ToolObject3DPreview-DGcT5dDK.js","assets/Object3DPreview-ChopdNF4.js","assets/OrbitControls-BHxt84w6.js","assets/editor-presentation-activity-C7SNSmTd.js","assets/StageHost-B4P-uvV9.js","assets/viewport-pick-context-DkawXbEi.js","assets/GameplaySessionTimeline-BtEPIu2F.js","assets/spark.module-B_-x7Z29.js","assets/AudioViewer-C9JP7n49.js","assets/EntityModelDocument-SFgsuX4_.js","assets/EnvironmentAssetDocument-DEqKuki2.js","assets/fflate.module-DPuTF8aG.js","assets/asset-editor-persistence-B6Yg7dTC.js","assets/ImageViewer-CyIXlQTG.js","assets/VideoViewer-3I_zUWEC.js","assets/JsonAssetDocument-Zyv_CDpC.js","assets/ModelAssetDocument-BKdnWaJL.js","assets/OnlineAssetDetail-B_l8XkeE.js","assets/SourceAssetViewer-zpxF5DOe.js","assets/world-documents-CWiw361z.js","assets/edit-mode-authoring-DBEoND0w.js","assets/TransientHint-9_u15mth.js","assets/react-story-board-d_OfX68Z.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-DTuU4PmC.js","assets/webworkerAll-CS1yjkoi.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-MDmTPFBT.js","assets/InspectorCanvasPreview-CLDhscy0.js","assets/hosted-asset-materialization-6HtWQ0od.js","assets/NonThreeAuthoringBootstrap-ab96Xbnn.js","assets/story-pixi-preview-Cafk1Xbk.js","assets/story-mount-turn-2IYGgHob.js","assets/story-three-preview-ByMTQc8w.js","assets/story-capture-D0H-H2_b.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 Dkr}from"./index-D2LwEE0L.js";import{a as Vqe}from"./client-DNXj_opT.js";import{d as vE,w as Rye,bJ as lkt,am as ez,Y as ukt,b5 as fkt,a0 as NA,by as Jqe,av as Mye,b2 as Pkr,al as Nkr,aV as $P,z as Wqe,I as ER,i as hv,p as bE,aa as Hqe,ab as hX,aJ as sZ,aS as Okr,aT as m9e,aU as dkt,aI as gX,bx as yI,a as pkt,b4 as Fkr,aY as kq,x as SS,V as Tc,Q as H8,ay as Rkr,aL as _kt,bz as Mkr,bA as Lkr,a4 as Lye,bB as jkr,bC as Bkr,bD as mkt,L as qR,h as nhe,f as h9e,bE as $kr,J as qkr,aE as hkt,a9 as gFe,aD as zkr,Z as gkt,b1 as fq,bt as ihe,b6 as ykt,aG as vkt,b7 as bkt,bF as Akt,aH as Gqe,aB as SP,k as jye,b as vb,$ as Bye,aM as Ukr,aQ as Vkr,aN as Skt,bG as Jkr,bH as xkt,bj as Wkr,a1 as oP,aO as F1t,bw as R1t,aP as M1t,_ as Hkr,bI as Gkr,ap as xS,bl as wkt,cd as Qkr,ce as Kkr,cf as Ckt,q as L1t,cg as j1t,ch as g9e,ci as y9e,cj as Ykr,ck as Xkr,cl as Zkr,cm as eIr,cn as B1t,co as $1t,cp as v9e,cq as yFe,cr as R_e,cs as Ekt,ct as Tkt,cu as b9e,O as RY,ac as MY,v as dq,j as Bp,H as QN,cv as kkt,cw as Ikt,F as yX,K as tIr,y as rIr,cx as nIr,cy as iIr,cz as sIr,cA as oIr,G as aIr,bc as cIr,bY as lIr,aW as u9,a$ as uIr,aX as fIr,bK as Dkt,a_ as dIr,b3 as pIr,be as _Ir,as as Qqe,aC as q1t,bh as mIr,aA as hIr,cB as gIr,c6 as yIr,cC as vIr,cD as bIr,bf as AIr,bL as SIr,cE as xIr,W as z1t,cF as Pkt}from"./three.module-BynznMJN.js";import{a as wIr,c as U1t,g as Nkt}from"./_commonjsHelpers-D6-XlEtG.js";const CIr="modulepreload",EIr=function(t){return"/"+t},V1t={},la=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=EIr(S),S in V1t)return;V1t[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":CIr,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)})},TIr=[{entryPath:"@volter/editor-blender/contributions/blender-node-editor.document.tsx",load:()=>la(()=>import("./blender-node-editor.document-DGn6U6Kf.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:()=>la(()=>import("./blender-timeline.document-D9BOYb0q.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:()=>la(()=>import("./blender-uv-editor.document-BK2pP2sR.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:()=>la(()=>import("./blender-runtime.document-C60VEa1_.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:()=>la(()=>import("./blender-version.status-ZqfW0upF.js"),__vite__mapDeps([17,1,2,3,4,8,9,10,11,6]))},{entryPath:"@volter/editor-blender/contributions/blender.command.ts",load:()=>la(()=>import("./blender.command-BLtAEuIZ.js"),__vite__mapDeps([18,5,6,7,3,2,4,1,8,9,10,11]))},{entryPath:"@volter/editor-blender/contributions/blender.keymap.ts",load:()=>la(()=>import("./blender.keymap-GAQgeklK.js"),[])},{entryPath:"@volter/editor-blender/contributions/blender.status.tsx",load:()=>la(()=>import("./blender.status-ujwGU6dU.js"),__vite__mapDeps([19,1,2]))},{entryPath:"@volter/editor-blender/contributions/blender.style.ts",load:()=>la(()=>import("./blender.style-Dcem5f_T.js"),[])},{entryPath:"@volter/editor-blender/contributions/model.layout.ts",load:()=>la(()=>import("./model.layout-BJUEQYUI.js"),[])},{entryPath:"@volter/editor-blender/contributions/models.finder.ts",load:()=>la(()=>import("./models.finder-Bs46IncP.js"),__vite__mapDeps([20,3,2,4,1,8,9,10,11,6]))},{entryPath:"@volter/editor-blender/contributions/properties-bone-constraints.inspector.tsx",load:()=>la(()=>import("./properties-bone-constraints.inspector-QML_-0yQ.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:()=>la(()=>import("./properties-bone.inspector-DSDyP6-P.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:()=>la(()=>import("./properties-collection.inspector-jic5mzgz.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:()=>la(()=>import("./properties-constraints.inspector-TLHv00p7.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:()=>la(()=>import("./properties-data.inspector-BJBPl88V.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:()=>la(()=>import("./properties-material.inspector-xxWuVjrx.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:()=>la(()=>import("./properties-modifiers.inspector-CWjdmu_J.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:()=>la(()=>import("./properties-object.inspector-D15l44Tq.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:()=>la(()=>import("./properties-output.inspector-DVuGGSBb.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:()=>la(()=>import("./properties-particles.inspector-B94x32Ez.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:()=>la(()=>import("./properties-physics.inspector-9EYMjwFP.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:()=>la(()=>import("./properties-render.inspector-8yA_8luD.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:()=>la(()=>import("./properties-scene.inspector-WM7qZhJ4.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:()=>la(()=>import("./properties-texture.inspector-Cno5lCIz.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:()=>la(()=>import("./properties-view-layer.inspector--PX0c9h6.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:()=>la(()=>import("./properties-world.inspector-C3EuydM_.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:()=>la(()=>import("./sculpt.layout-zJF55yCR.js"),[])},{entryPath:"@volter/editor-blender/contributions/shading.layout.ts",load:()=>la(()=>import("./shading.layout-DULYZV6M.js"),[])},{entryPath:"@volter/editor-blender/contributions/uv-editing.layout.ts",load:()=>la(()=>import("./uv-editing.layout-BEKHxmHw.js"),[])},{entryPath:"@volter/editor-blender/contributions/texture.layout.ts",load:()=>la(()=>import("./texture.layout-DASpHVht.js"),[])}];let LY=null;const A9e=new Set;function $ye(){return LY}function kIr(t){if(LY!==null&&LY.id!==t.id)throw new Error(`Two products in one page: "${LY.id}" is already composed and "${t.id}" asked to be. A product is the running program; one page runs one.`);LY=t;for(const r of A9e)r()}function Okt(t){return A9e.add(t),()=>A9e.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 _=oZ,g=!CIt.jitless,S=g&&y3r.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?zIt([],j,N,P,w,t):N):i(N,P):(N.issues.push({expected:"object",code:"invalid_type",input:j,inst:t}),N)}});function cbt(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 UIt=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=>ize(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=>cbt(b,l,t,d)):cbt(g,l,t,d)}}),i4r=ys("$ZodDiscriminatedUnion",(t,r)=>{r.inclusive=!1,UIt.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=Vye(()=>{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(!oZ(_))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)}}),s4r=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])=>lbt(i,b,S)):lbt(i,d,_)}});function I9e(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(tz(t)&&tz(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 _=I9e(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],_=I9e(l,d);if(!_.valid)return{valid:!1,mergeErrorPath:[a,..._.mergeErrorPath]};i.push(_.data)}return{valid:!0,data:i}}return{valid:!1,mergeErrorPath:[]}}function lbt(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 _=I9e(r.value,i.value);if(!_.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(_.mergeErrorPath)}`);return t.value=_.data,t}const o4r=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=>Tpe(N,a,S))):Tpe(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=>Tpe(P,a,S))):Tpe(N,a,S)}}return _.length?Promise.all(_).then(()=>a):a}});function Tpe(t,r,i){t.issues.length&&r.issues.push(...uR(i,t.issues)),r.value[i]=t.value}const a4r=ys("$ZodRecord",(t,r)=>{H_.init(t,r),t._zod.parse=(i,a)=>{const l=i.value;if(!tz(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(...uR(S,w.issues)),i.value[S]=w.value})):(k.issues.length&&i.issues.push(...uR(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"&&RIt.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(...uR(g,w.issues)),i.value[b.value]=w.value})):(k.issues.length&&i.issues.push(...uR(g,k.issues)),i.value[b.value]=k.value)}}return d.length?Promise.all(d).then(()=>i):i}}),c4r=ys("$ZodEnum",(t,r)=>{H_.init(t,r);const i=EIt(r.entries),a=new Set(i);t._zod.values=a,t._zod.pattern=new RegExp(`^(${i.filter(l=>v3r.has(typeof l)).map(l=>typeof l=="string"?rz(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}}),l4r=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"?rz(a):a?rz(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}}),u4r=ys("$ZodTransform",(t,r)=>{H_.init(t,r),t._zod.parse=(i,a)=>{if(a.direction==="backward")throw new wIt(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 ubt(t,r){return t.issues.length&&r===void 0?{issues:[],value:void 0}:t}const VIt=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(`^(${ize(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=>ubt(d,i.value)):ubt(l,i.value)}return i.value===void 0?i:r.innerType._zod.run(i,a)}}),f4r=ys("$ZodExactOptional",(t,r)=>{VIt.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)}),d4r=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(`^(${ize(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)}),p4r=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=>fbt(d,r)):fbt(l,r)}});function fbt(t,r){return t.value===void 0&&(t.value=r.defaultValue),t}const _4r=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))}),m4r=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=>dbt(d,t)):dbt(l,t)}});function dbt(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 h4r=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)}}),g4r=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(_=>kpe(_,r.in,a)):kpe(d,r.in,a)}const l=r.in._zod.run(i,a);return l instanceof Promise?l.then(d=>kpe(d,r.out,a)):kpe(l,r.out,a)}});function kpe(t,r,i){return t.issues.length?(t.aborted=!0,t):r._zod.run({value:t.value,issues:t.issues},i)}const y4r=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(pbt):pbt(l)}});function pbt(t){return t.value=Object.freeze(t.value),t}const v4r=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)}),b4r=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=>_bt(d,i,a,t));_bt(l,i,a,t)}});function _bt(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(aZ(l))}}var mbt;class A4r{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 S4r(){return new A4r}(mbt=globalThis).__zod_globalRegistry??(mbt.__zod_globalRegistry=S4r());const $Y=globalThis.__zod_globalRegistry;function x4r(t,r){return new t({type:"string",...kc(r)})}function w4r(t,r){return new t({type:"string",format:"email",check:"string_format",abort:!1,...kc(r)})}function hbt(t,r){return new t({type:"string",format:"guid",check:"string_format",abort:!1,...kc(r)})}function C4r(t,r){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,...kc(r)})}function E4r(t,r){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...kc(r)})}function T4r(t,r){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...kc(r)})}function k4r(t,r){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...kc(r)})}function I4r(t,r){return new t({type:"string",format:"url",check:"string_format",abort:!1,...kc(r)})}function D4r(t,r){return new t({type:"string",format:"emoji",check:"string_format",abort:!1,...kc(r)})}function P4r(t,r){return new t({type:"string",format:"nanoid",check:"string_format",abort:!1,...kc(r)})}function N4r(t,r){return new t({type:"string",format:"cuid",check:"string_format",abort:!1,...kc(r)})}function O4r(t,r){return new t({type:"string",format:"cuid2",check:"string_format",abort:!1,...kc(r)})}function F4r(t,r){return new t({type:"string",format:"ulid",check:"string_format",abort:!1,...kc(r)})}function R4r(t,r){return new t({type:"string",format:"xid",check:"string_format",abort:!1,...kc(r)})}function M4r(t,r){return new t({type:"string",format:"ksuid",check:"string_format",abort:!1,...kc(r)})}function L4r(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 B4r(t,r){return new t({type:"string",format:"cidrv4",check:"string_format",abort:!1,...kc(r)})}function $4r(t,r){return new t({type:"string",format:"cidrv6",check:"string_format",abort:!1,...kc(r)})}function q4r(t,r){return new t({type:"string",format:"base64",check:"string_format",abort:!1,...kc(r)})}function z4r(t,r){return new t({type:"string",format:"base64url",check:"string_format",abort:!1,...kc(r)})}function U4r(t,r){return new t({type:"string",format:"e164",check:"string_format",abort:!1,...kc(r)})}function V4r(t,r){return new t({type:"string",format:"jwt",check:"string_format",abort:!1,...kc(r)})}function J4r(t,r){return new t({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...kc(r)})}function W4r(t,r){return new t({type:"string",format:"date",check:"string_format",...kc(r)})}function H4r(t,r){return new t({type:"string",format:"time",check:"string_format",precision:null,...kc(r)})}function G4r(t,r){return new t({type:"string",format:"duration",check:"string_format",...kc(r)})}function Q4r(t,r){return new t({type:"number",checks:[],...kc(r)})}function K4r(t,r){return new t({type:"number",check:"number_format",abort:!1,format:"safeint",...kc(r)})}function Y4r(t,r){return new t({type:"boolean",...kc(r)})}function X4r(t){return new t({type:"unknown"})}function Z4r(t,r){return new t({type:"never",...kc(r)})}function gbt(t,r){return new LIt({check:"less_than",...kc(r),value:t,inclusive:!1})}function bFe(t,r){return new LIt({check:"less_than",...kc(r),value:t,inclusive:!0})}function ybt(t,r){return new jIt({check:"greater_than",...kc(r),value:t,inclusive:!1})}function AFe(t,r){return new jIt({check:"greater_than",...kc(r),value:t,inclusive:!0})}function vbt(t,r){return new dPr({check:"multiple_of",...kc(r),value:t})}function JIt(t,r){return new _Pr({check:"max_length",...kc(r),maximum:t})}function ahe(t,r){return new mPr({check:"min_length",...kc(r),minimum:t})}function WIt(t,r){return new hPr({check:"length_equals",...kc(r),length:t})}function e6r(t,r){return new gPr({check:"string_format",format:"regex",...kc(r),pattern:t})}function t6r(t){return new yPr({check:"string_format",format:"lowercase",...kc(t)})}function r6r(t){return new vPr({check:"string_format",format:"uppercase",...kc(t)})}function n6r(t,r){return new bPr({check:"string_format",format:"includes",...kc(r),includes:t})}function i6r(t,r){return new APr({check:"string_format",format:"starts_with",...kc(r),prefix:t})}function s6r(t,r){return new SPr({check:"string_format",format:"ends_with",...kc(r),suffix:t})}function eU(t){return new xPr({check:"overwrite",tx:t})}function o6r(t){return eU(r=>r.normalize(t))}function a6r(){return eU(t=>t.trim())}function c6r(){return eU(t=>t.toLowerCase())}function l6r(){return eU(t=>t.toUpperCase())}function u6r(){return eU(t=>g3r(t))}function f6r(t,r,i){return new t({type:"array",element:r,...kc(i)})}function d6r(t,r,i){const a=kc(i);return a.abort??(a.abort=!0),new t({type:"custom",check:"custom",fn:r,...a})}function p6r(t,r,i){return new t({type:"custom",check:"custom",fn:r,...kc(i)})}function _6r(t){const r=m6r(i=>(i.addIssue=a=>{if(typeof a=="string")i.issues.push(aZ(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(aZ(l))}},t(i.value,i)));return r}function m6r(t,r){const i=new LA({check:"custom",...kc(r)});return i._zod.check=t,i}function che(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??$Y,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"&&_b(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 lhe(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 uhe(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:fhe(r,"input",t.processors),output:fhe(r,"output",t.processors)}},enumerable:!1,writable:!1}),_}catch{throw new Error("Error converting schema to JSON.")}}function _b(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 _b(a.element,i);if(a.type==="set")return _b(a.valueType,i);if(a.type==="lazy")return _b(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 _b(a.innerType,i);if(a.type==="intersection")return _b(a.left,i)||_b(a.right,i);if(a.type==="record"||a.type==="map")return _b(a.keyType,i)||_b(a.valueType,i);if(a.type==="pipe")return _b(a.in,i)||_b(a.out,i);if(a.type==="object"){for(const l in a.shape)if(_b(a.shape[l],i))return!0;return!1}if(a.type==="union"){for(const l of a.options)if(_b(l,i))return!0;return!1}if(a.type==="tuple"){for(const l of a.items)if(_b(l,i))return!0;return!!(a.rest&&_b(a.rest,i))}return!1}const h6r=(t,r={})=>i=>{const a=che({...i,processors:r});return J_(t,a),lhe(a,t),uhe(a,t)},fhe=(t,r,i={})=>a=>{const{libraryOptions:l,target:d}=a??{},_=che({...l??{},target:d,io:r,processors:i});return J_(t,_),lhe(_,t),uhe(_,t)},g6r={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},HIt=(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=g6r[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}))])}},GIt=(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)},QIt=(t,r,i,a)=>{i.type="boolean"},y6r=(t,r,i,a)=>{if(r.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema")},v6r=(t,r,i,a)=>{if(r.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema")},b6r=(t,r,i,a)=>{r.target==="openapi-3.0"?(i.type="string",i.nullable=!0,i.enum=[null]):i.type="null"},A6r=(t,r,i,a)=>{if(r.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema")},S6r=(t,r,i,a)=>{if(r.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema")},KIt=(t,r,i,a)=>{i.not={}},x6r=(t,r,i,a)=>{},YIt=(t,r,i,a)=>{},w6r=(t,r,i,a)=>{if(r.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema")},XIt=(t,r,i,a)=>{const l=t._zod.def,d=EIt(l.entries);d.every(_=>typeof _=="number")&&(i.type="number"),d.every(_=>typeof _=="string")&&(i.type="string"),i.enum=d},ZIt=(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},C6r=(t,r,i,a)=>{if(r.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema")},E6r=(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},T6r=(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)},k6r=(t,r,i,a)=>{i.type="boolean"},eDt=(t,r,i,a)=>{if(r.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},I6r=(t,r,i,a)=>{if(r.unrepresentable==="throw")throw new Error("Function types cannot be represented in JSON Schema")},tDt=(t,r,i,a)=>{if(r.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},D6r=(t,r,i,a)=>{if(r.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema")},P6r=(t,r,i,a)=>{if(r.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema")},rDt=(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"]})},nDt=(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)},iDt=(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=_},sDt=(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},oDt=(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)},aDt=(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)}},cDt=(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"}]},lDt=(t,r,i,a)=>{const l=t._zod.def;J_(l.innerType,r,a);const d=r.seen.get(t);d.ref=l.innerType},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,i.default=JSON.parse(JSON.stringify(l.defaultValue))},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,r.io==="input"&&(i._prefault=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;let _;try{_=l.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}i.default=_},pDt=(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},_Dt=(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},N6r=(t,r,i,a)=>{const l=t._zod.def;J_(l.innerType,r,a);const d=r.seen.get(t);d.ref=l.innerType},lze=(t,r,i,a)=>{const l=t._zod.def;J_(l.innerType,r,a);const d=r.seen.get(t);d.ref=l.innerType},mDt=(t,r,i,a)=>{const l=t._zod.innerType;J_(l,r,a);const d=r.seen.get(t);d.ref=l},bbt={string:HIt,number:GIt,boolean:QIt,bigint:y6r,symbol:v6r,null:b6r,undefined:A6r,void:S6r,never:KIt,any:x6r,unknown:YIt,date:w6r,enum:XIt,literal:ZIt,nan:C6r,template_literal:E6r,file:T6r,success:k6r,custom:eDt,function:I6r,transform:tDt,map:D6r,set:P6r,array:rDt,object:nDt,union:iDt,intersection:sDt,tuple:oDt,record:aDt,nullable:cDt,nonoptional:lDt,default:uDt,prefault:fDt,catch:dDt,pipe:pDt,readonly:_Dt,promise:N6r,optional:lze,lazy:mDt};function O6r(t,r){if("_idmap"in t){const a=t,l=che({...r,processors:bbt}),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;lhe(l,k),_[S]=uhe(l,k)}if(Object.keys(d).length>0){const b=l.target==="draft-2020-12"?"$defs":"definitions";_.__shared={[b]:d}}return{schemas:_}}const i=che({...r,processors:bbt});return J_(t,i),lhe(i,t),uhe(i,t)}const F6r=ys("ZodISODateTime",(t,r)=>{LPr.init(t,r),gh.init(t,r)});function R6r(t){return J4r(F6r,t)}const M6r=ys("ZodISODate",(t,r)=>{jPr.init(t,r),gh.init(t,r)});function L6r(t){return W4r(M6r,t)}const j6r=ys("ZodISOTime",(t,r)=>{BPr.init(t,r),gh.init(t,r)});function B6r(t){return H4r(j6r,t)}const $6r=ys("ZodISODuration",(t,r)=>{$Pr.init(t,r),gh.init(t,r)});function q6r(t){return G4r($6r,t)}const z6r=(t,r)=>{DIt.init(t,r),t.name="ZodError",Object.defineProperties(t,{format:{value:i=>D3r(t,i)},flatten:{value:i=>I3r(t,i)},addIssue:{value:i=>{t.issues.push(i),t.message=JSON.stringify(t.issues,k9e,2)}},addIssues:{value:i=>{t.issues.push(...i),t.message=JSON.stringify(t.issues,k9e,2)}},isEmpty:{get(){return t.issues.length===0}}})},Dw=ys("ZodError",z6r,{Parent:Error}),U6r=oze(Dw),V6r=aze(Dw),J6r=Jye(Dw),W6r=Wye(Dw),H6r=O3r(Dw),G6r=F3r(Dw),Q6r=R3r(Dw),K6r=M3r(Dw),Y6r=L3r(Dw),X6r=j3r(Dw),Z6r=B3r(Dw),eNr=$3r(Dw),Cm=ys("ZodType",(t,r)=>(H_.init(t,r),Object.assign(t["~standard"],{jsonSchema:{input:fhe(t,"input"),output:fhe(t,"output")}}),t.toJSONSchema=h6r(t,{}),t.def=r,t.type=r.type,Object.defineProperty(t,"_def",{value:r}),t.check=(...i)=>t.clone(G8(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)=>Q8(t,i,a),t.brand=()=>t,t.register=((i,a)=>(i.add(t,a),t)),t.parse=(i,a)=>U6r(t,i,a,{callee:t.parse}),t.safeParse=(i,a)=>J6r(t,i,a),t.parseAsync=async(i,a)=>V6r(t,i,a,{callee:t.parseAsync}),t.safeParseAsync=async(i,a)=>W6r(t,i,a),t.spa=t.safeParseAsync,t.encode=(i,a)=>H6r(t,i,a),t.decode=(i,a)=>G6r(t,i,a),t.encodeAsync=async(i,a)=>Q6r(t,i,a),t.decodeAsync=async(i,a)=>K6r(t,i,a),t.safeEncode=(i,a)=>Y6r(t,i,a),t.safeDecode=(i,a)=>X6r(t,i,a),t.safeEncodeAsync=async(i,a)=>Z6r(t,i,a),t.safeDecodeAsync=async(i,a)=>eNr(t,i,a),t.refine=(i,a)=>t.check(HNr(i,a)),t.superRefine=i=>t.check(GNr(i)),t.overwrite=i=>t.check(eU(i)),t.optional=()=>Cbt(t),t.exactOptional=()=>FNr(t),t.nullable=()=>Ebt(t),t.nullish=()=>Cbt(Ebt(t)),t.nonoptional=i=>$Nr(t,i),t.array=()=>o_(t),t.or=i=>bee([t,i]),t.and=i=>vDt(t,i),t.transform=i=>P9e(t,bDt(i)),t.default=i=>LNr(t,i),t.prefault=i=>BNr(t,i),t.catch=i=>zNr(t,i),t.pipe=i=>P9e(t,i),t.readonly=()=>JNr(t),t.describe=i=>{const a=t.clone();return $Y.add(a,{description:i}),a},Object.defineProperty(t,"description",{get(){return $Y.get(t)?.description},configurable:!0}),t.meta=(...i)=>{if(i.length===0)return $Y.get(t);const a=t.clone();return $Y.add(a,i[0]),a},t.isOptional=()=>t.safeParse(void 0).success,t.isNullable=()=>t.safeParse(null).success,t.apply=i=>i(t),t)),hDt=ys("_ZodString",(t,r)=>{cze.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(a,l,d)=>HIt(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(e6r(...a)),t.includes=(...a)=>t.check(n6r(...a)),t.startsWith=(...a)=>t.check(i6r(...a)),t.endsWith=(...a)=>t.check(s6r(...a)),t.min=(...a)=>t.check(ahe(...a)),t.max=(...a)=>t.check(JIt(...a)),t.length=(...a)=>t.check(WIt(...a)),t.nonempty=(...a)=>t.check(ahe(1,...a)),t.lowercase=a=>t.check(t6r(a)),t.uppercase=a=>t.check(r6r(a)),t.trim=()=>t.check(a6r()),t.normalize=(...a)=>t.check(o6r(...a)),t.toLowerCase=()=>t.check(c6r()),t.toUpperCase=()=>t.check(l6r()),t.slugify=()=>t.check(u6r())}),tNr=ys("ZodString",(t,r)=>{cze.init(t,r),hDt.init(t,r),t.email=i=>t.check(w4r(rNr,i)),t.url=i=>t.check(I4r(nNr,i)),t.jwt=i=>t.check(V4r(yNr,i)),t.emoji=i=>t.check(D4r(iNr,i)),t.guid=i=>t.check(hbt(Abt,i)),t.uuid=i=>t.check(C4r(Ipe,i)),t.uuidv4=i=>t.check(E4r(Ipe,i)),t.uuidv6=i=>t.check(T4r(Ipe,i)),t.uuidv7=i=>t.check(k4r(Ipe,i)),t.nanoid=i=>t.check(P4r(sNr,i)),t.guid=i=>t.check(hbt(Abt,i)),t.cuid=i=>t.check(N4r(oNr,i)),t.cuid2=i=>t.check(O4r(aNr,i)),t.ulid=i=>t.check(F4r(cNr,i)),t.base64=i=>t.check(q4r(mNr,i)),t.base64url=i=>t.check(z4r(hNr,i)),t.xid=i=>t.check(R4r(lNr,i)),t.ksuid=i=>t.check(M4r(uNr,i)),t.ipv4=i=>t.check(L4r(fNr,i)),t.ipv6=i=>t.check(j4r(dNr,i)),t.cidrv4=i=>t.check(B4r(pNr,i)),t.cidrv6=i=>t.check($4r(_Nr,i)),t.e164=i=>t.check(U4r(gNr,i)),t.datetime=i=>t.check(R6r(i)),t.date=i=>t.check(L6r(i)),t.time=i=>t.check(B6r(i)),t.duration=i=>t.check(q6r(i))});function Ss(t){return x4r(tNr,t)}const gh=ys("ZodStringFormat",(t,r)=>{jm.init(t,r),hDt.init(t,r)}),rNr=ys("ZodEmail",(t,r)=>{kPr.init(t,r),gh.init(t,r)}),Abt=ys("ZodGUID",(t,r)=>{EPr.init(t,r),gh.init(t,r)}),Ipe=ys("ZodUUID",(t,r)=>{TPr.init(t,r),gh.init(t,r)}),nNr=ys("ZodURL",(t,r)=>{IPr.init(t,r),gh.init(t,r)}),iNr=ys("ZodEmoji",(t,r)=>{DPr.init(t,r),gh.init(t,r)}),sNr=ys("ZodNanoID",(t,r)=>{PPr.init(t,r),gh.init(t,r)}),oNr=ys("ZodCUID",(t,r)=>{NPr.init(t,r),gh.init(t,r)}),aNr=ys("ZodCUID2",(t,r)=>{OPr.init(t,r),gh.init(t,r)}),cNr=ys("ZodULID",(t,r)=>{FPr.init(t,r),gh.init(t,r)}),lNr=ys("ZodXID",(t,r)=>{RPr.init(t,r),gh.init(t,r)}),uNr=ys("ZodKSUID",(t,r)=>{MPr.init(t,r),gh.init(t,r)}),fNr=ys("ZodIPv4",(t,r)=>{qPr.init(t,r),gh.init(t,r)}),dNr=ys("ZodIPv6",(t,r)=>{zPr.init(t,r),gh.init(t,r)}),pNr=ys("ZodCIDRv4",(t,r)=>{UPr.init(t,r),gh.init(t,r)}),_Nr=ys("ZodCIDRv6",(t,r)=>{VPr.init(t,r),gh.init(t,r)}),mNr=ys("ZodBase64",(t,r)=>{JPr.init(t,r),gh.init(t,r)}),hNr=ys("ZodBase64URL",(t,r)=>{HPr.init(t,r),gh.init(t,r)}),gNr=ys("ZodE164",(t,r)=>{GPr.init(t,r),gh.init(t,r)}),yNr=ys("ZodJWT",(t,r)=>{KPr.init(t,r),gh.init(t,r)}),gDt=ys("ZodNumber",(t,r)=>{$It.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(a,l,d)=>GIt(t,a,l),t.gt=(a,l)=>t.check(ybt(a,l)),t.gte=(a,l)=>t.check(AFe(a,l)),t.min=(a,l)=>t.check(AFe(a,l)),t.lt=(a,l)=>t.check(gbt(a,l)),t.lte=(a,l)=>t.check(bFe(a,l)),t.max=(a,l)=>t.check(bFe(a,l)),t.int=a=>t.check(Sbt(a)),t.safe=a=>t.check(Sbt(a)),t.positive=a=>t.check(ybt(0,a)),t.nonnegative=a=>t.check(AFe(0,a)),t.negative=a=>t.check(gbt(0,a)),t.nonpositive=a=>t.check(bFe(0,a)),t.multipleOf=(a,l)=>t.check(vbt(a,l)),t.step=(a,l)=>t.check(vbt(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 Q4r(gDt,t)}const vNr=ys("ZodNumberFormat",(t,r)=>{YPr.init(t,r),gDt.init(t,r)});function Sbt(t){return K4r(vNr,t)}const bNr=ys("ZodBoolean",(t,r)=>{XPr.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(i,a,l)=>QIt(t,i,a)});function gv(t){return Y4r(bNr,t)}const ANr=ys("ZodUnknown",(t,r)=>{ZPr.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(i,a,l)=>YIt()});function xbt(){return X4r(ANr)}const SNr=ys("ZodNever",(t,r)=>{e4r.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(i,a,l)=>KIt(t,i,a)});function xNr(t){return Z4r(SNr,t)}const wNr=ys("ZodArray",(t,r)=>{t4r.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(i,a,l)=>rDt(t,i,a,l),t.element=r.element,t.min=(i,a)=>t.check(ahe(i,a)),t.nonempty=i=>t.check(ahe(1,i)),t.max=(i,a)=>t.check(JIt(i,a)),t.length=(i,a)=>t.check(WIt(i,a)),t.unwrap=()=>t.element});function o_(t,r){return f6r(wNr,t,r)}const CNr=ys("ZodObject",(t,r)=>{n4r.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(i,a,l)=>nDt(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:xbt()}),t.loose=()=>t.clone({...t._zod.def,catchall:xbt()}),t.strict=()=>t.clone({...t._zod.def,catchall:xNr()}),t.strip=()=>t.clone({...t._zod.def,catchall:void 0}),t.extend=i=>w3r(t,i),t.safeExtend=i=>C3r(t,i),t.merge=i=>E3r(t,i),t.pick=i=>S3r(t,i),t.omit=i=>x3r(t,i),t.partial=(...i)=>T3r(ADt,t,i[0]),t.required=(...i)=>k3r(SDt,t,i[0])});function Na(t,r){const i={type:"object",shape:t??{},...kc(r)};return new CNr(i)}const yDt=ys("ZodUnion",(t,r)=>{UIt.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(i,a,l)=>iDt(t,i,a,l),t.options=r.options});function bee(t,r){return new yDt({type:"union",options:t,...kc(r)})}const ENr=ys("ZodDiscriminatedUnion",(t,r)=>{yDt.init(t,r),i4r.init(t,r)});function TNr(t,r,i){return new ENr({type:"union",options:r,discriminator:t,...kc(i)})}const kNr=ys("ZodIntersection",(t,r)=>{s4r.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(i,a,l)=>sDt(t,i,a,l)});function vDt(t,r){return new kNr({type:"intersection",left:t,right:r})}const INr=ys("ZodTuple",(t,r)=>{o4r.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(i,a,l)=>oDt(t,i,a,l),t.rest=i=>t.clone({...t._zod.def,rest:i})});function wbt(t,r,i){const a=r instanceof H_,l=a?i:r,d=a?r:null;return new INr({type:"tuple",items:t,rest:d,...kc(l)})}const DNr=ys("ZodRecord",(t,r)=>{a4r.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(i,a,l)=>aDt(t,i,a,l),t.keyType=r.keyType,t.valueType=r.valueType});function zR(t,r,i){return new DNr({type:"record",keyType:t,valueType:r,...kc(i)})}const D9e=ys("ZodEnum",(t,r)=>{c4r.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(a,l,d)=>XIt(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 D9e({...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 D9e({...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 D9e({type:"enum",entries:i,...kc(r)})}const PNr=ys("ZodLiteral",(t,r)=>{l4r.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(i,a,l)=>ZIt(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 PNr({type:"literal",values:Array.isArray(t)?t:[t],...kc(r)})}const NNr=ys("ZodTransform",(t,r)=>{u4r.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(i,a,l)=>tDt(t,i),t._zod.parse=(i,a)=>{if(a.direction==="backward")throw new wIt(t.constructor.name);i.addIssue=d=>{if(typeof d=="string")i.issues.push(aZ(d,i.value,r));else{const _=d;_.fatal&&(_.continue=!1),_.code??(_.code="custom"),_.input??(_.input=i.value),_.inst??(_.inst=t),i.issues.push(aZ(_))}};const l=r.transform(i.value,i);return l instanceof Promise?l.then(d=>(i.value=d,i)):(i.value=l,i)}});function bDt(t){return new NNr({type:"transform",transform:t})}const ADt=ys("ZodOptional",(t,r)=>{VIt.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(i,a,l)=>lze(t,i,a,l),t.unwrap=()=>t._zod.def.innerType});function Cbt(t){return new ADt({type:"optional",innerType:t})}const ONr=ys("ZodExactOptional",(t,r)=>{f4r.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(i,a,l)=>lze(t,i,a,l),t.unwrap=()=>t._zod.def.innerType});function FNr(t){return new ONr({type:"optional",innerType:t})}const RNr=ys("ZodNullable",(t,r)=>{d4r.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(i,a,l)=>cDt(t,i,a,l),t.unwrap=()=>t._zod.def.innerType});function Ebt(t){return new RNr({type:"nullable",innerType:t})}const MNr=ys("ZodDefault",(t,r)=>{p4r.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(i,a,l)=>uDt(t,i,a,l),t.unwrap=()=>t._zod.def.innerType,t.removeDefault=t.unwrap});function LNr(t,r){return new MNr({type:"default",innerType:t,get defaultValue(){return typeof r=="function"?r():kIt(r)}})}const jNr=ys("ZodPrefault",(t,r)=>{_4r.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(i,a,l)=>fDt(t,i,a,l),t.unwrap=()=>t._zod.def.innerType});function BNr(t,r){return new jNr({type:"prefault",innerType:t,get defaultValue(){return typeof r=="function"?r():kIt(r)}})}const SDt=ys("ZodNonOptional",(t,r)=>{m4r.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 $Nr(t,r){return new SDt({type:"nonoptional",innerType:t,...kc(r)})}const qNr=ys("ZodCatch",(t,r)=>{h4r.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(i,a,l)=>dDt(t,i,a,l),t.unwrap=()=>t._zod.def.innerType,t.removeCatch=t.unwrap});function zNr(t,r){return new qNr({type:"catch",innerType:t,catchValue:typeof r=="function"?r:()=>r})}const UNr=ys("ZodPipe",(t,r)=>{g4r.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(i,a,l)=>pDt(t,i,a,l),t.in=r.in,t.out=r.out});function P9e(t,r){return new UNr({type:"pipe",in:t,out:r})}const VNr=ys("ZodReadonly",(t,r)=>{y4r.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(i,a,l)=>_Dt(t,i,a,l),t.unwrap=()=>t._zod.def.innerType});function JNr(t){return new VNr({type:"readonly",innerType:t})}const WNr=ys("ZodLazy",(t,r)=>{v4r.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(i,a,l)=>mDt(t,i,a,l),t.unwrap=()=>t._zod.def.getter()});function uDn(t){return new WNr({type:"lazy",getter:t})}const uze=ys("ZodCustom",(t,r)=>{b4r.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(i,a,l)=>eDt(t,i)});function kR(t,r){return d6r(uze,t??(()=>!0),r)}function HNr(t,r={}){return p6r(uze,t,r)}function GNr(t){return _6r(t)}function fDn(t,r={}){const i=new uze({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 QNr(t,r){return P9e(bDt(t),r)}const Tbt={custom:"custom"},kbt=jd(["mock","live"]),KNr=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()}),YNr=Na({included:Tu().nonnegative(),purchased:Tu().nonnegative(),used:Tu().nonnegative(),reserved:Tu().nonnegative(),remaining:Tu().nonnegative(),resetsAt:Ss().datetime().optional(),purchasedExpiresAt:Ss().datetime().optional()}),XNr=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()}),ZNr=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()}),e8r=Na({id:Ss().min(1),email:Ss().email(),name:Ss().min(1).optional()}),t8r=Na({name:Ss().min(1),verified:gv(),enrollmentMode:jd(["manual_invitation","automatic_invitation","automatic_suggestion","enterprise_sso"])}),r8r=Na({id:Ss().min(1),name:Ss().min(1),slug:Ss().min(1).optional(),role:Ss().min(1),domains:o_(t8r).max(50)}),n8r=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 i8r=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:zR(Ss().min(1),Na({name:Ss().min(1),credits:Tu().int().positive(),expiresInDays:Tu().int().positive().optional()}))}),s8r=TNr("authenticated",[Na({authenticated:Ry(!1),backend:kbt}),Na({authenticated:Ry(!0),backend:kbt,user:e8r,organizations:o_(r8r).max(100).optional(),plan:KNr,credits:YNr,spendPolicy:XNr,alerts:o_(ZNr).max(100).optional(),entitlements:Na({generation:gv(),dailyJobs:Tu().int().positive().optional()})})]),o8r=jd(["auto","mock","managed","byok"]),xDt=jd(["fal","tripo","worldlabs","openrouter"]),a8r=Na({enabled:gv(),provider:Ry("openrouter"),model:Ss().trim().min(1).max(256)}),c8r=jd(["environment","system","session","none"]),l8r=Na({provider:xDt,label:Ss().min(1),environmentVariable:Ss().min(1),configured:gv(),source:c8r,editable:gv(),persistence:jd(["system","session"]),maskedKey:Ss().min(1).optional(),problem:Ss().min(1).optional()}),u8r=Na({provider:xDt,ok:Ry(!0),testedAt:Ss().datetime()});function f8r(t){return{routes:{mock:!0,managed:t.routes.managed,byok:t.routes.byok,byokProviders:[...t.routes.byokProviders]},preferredRoute:t.preferredRoute}}const Gye=vDt(s8r,Na({accountEnvironment:jd(["test-mock","development-twin","production"]),routes:Na({mock:Ry(!0),managed:gv(),byok:gv(),byokProviders:o_(Ss().min(1))}),preferredRoute:o8r,providerCredentials:o_(l8r),codingInference:a8r}));function d8r(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(d8r(r,i))}function tU(t,r){if(!t.ok)throw new Error(`${r} (${t.status}).`);np(t,r)}async function Eg(t,r){return tU(t,r),await t.json()}const Ibt="vgai.collaboration.participant.v1",p8r="vgai.collaboration.remote-share.v1",N9e=globalThis.__VGAI_EDITOR_PRESENCE_BOOTSTRAP__;function _8r(){if(N9e?.participantId)return N9e.participantId;const t=globalThis.crypto?.randomUUID?.()??`participant-${Date.now()}`;try{const r=globalThis.localStorage?.getItem(Ibt);if(r)return r;globalThis.localStorage?.setItem(Ibt,t)}catch{}return t}const wDt=_8r(),fze=(()=>{try{return globalThis.localStorage?.getItem(p8r)==="1"}catch{return!1}})(),m8r=N9e?.displayName||"Local editor";let O9e=0;function CDt(t){Number.isInteger(t)&&t>=O9e&&(O9e=t)}function yw(){return{participantId:wDt,expectedRevision:O9e}}const h8r={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 nz=h8r,EDt=0,F9e=null;const R9e=new Set;function UR(t,r=null){if(!(F9e===r&&JSON.stringify(nz)===JSON.stringify(t))){nz=t,F9e=r,EDt++;for(const i of R9e)i()}}async function TDt(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 Gye.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 TDt(a,`${r} ${t} failed`);return UR(l),l}function dze(){return nz}function pze(){return f8r(nz)}function T8(){return EDt}function Dpe(){return F9e}function Qye(t){return R9e.add(t),()=>R9e.delete(t)}async function Dbt(){try{const t=await TDt(await fetch("/__editor/account"),"Account read failed");return UR(t),t}catch(t){throw UR(nz,t instanceof Error?t.message:String(t)),t}}const g8r=t=>IE("/__editor/account/mock-session","POST",{email:t}),y8r=t=>IE("/__editor/account/twin-session","POST",{email:t}),v8r=()=>IE("/__editor/account/session","DELETE"),b8r=t=>IE("/__editor/account/spend-policy","PUT",t),A8r=()=>IE("/__editor/account/alerts/read","POST"),S8r=t=>IE("/__editor/account/execution-route","PUT",{route:t}),x8r=t=>IE("/__editor/account/coding-inference","PUT",t);async function w8r(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 C8r=(t,r)=>IE(`/__editor/account/provider-credentials/${encodeURIComponent(t)}`,"PUT",{key:r}),E8r=t=>IE(`/__editor/account/provider-credentials/${encodeURIComponent(t)}`,"DELETE");async function T8r(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 u8r.parse(i)}const Pbt=t=>IE("/__editor/account/plan","PUT",{action:t});async function kDt(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 UR(Gye.parse(a.account)),{...typeof a.checkoutUrl=="string"?{checkoutUrl:a.checkoutUrl}:{},mock:a.mock===!0}}const k8r=t=>kDt("/__editor/account/checkout",{plan:t}),I8r=t=>kDt("/__editor/account/credits",{packId:t});async function D8r(){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 n8r.array().parse(r.entries??[])}async function P8r(){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 i8r.parse(r)}async function N8r(){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 O8r(){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 F8r(){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 R8r(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 UR(Gye.parse(i.account)),!0}async function M8r(){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 L8r(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 UR(Gye.parse(i.account)),!0}function j8r(){if(fze)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=>UR(nz,i instanceof Error?i.message:String(i))):Dbt().catch(()=>{});const r=window.setInterval(()=>void Dbt().catch(()=>{}),3e4);return()=>window.clearInterval(r)}const B8r={"source-prop":!0,"source-structure":!0,"construction-literal":!0,"physics-binding":!0,"data-record":!0,"live-only":!0},$8r=Object.keys(B8r),q8r={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},z8r=Object.keys(q8r),dhe={claim:0,shape:1,operation:2,effect:3,"round-trip":4};function U8r(t,r){return dhe[t]>=dhe[r]}function phe(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||dhe[_.stage]>=dhe[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}:U8r(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 V8r{#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 phe({...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 J8r(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 SFe(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(J8r({seam:_,subject:t.subject,epoch:t.epoch,value:g,optional:d.optional,kind:d.kind}))}return r}function Nbt(t){const r=phe(t);if(r.state==="absent"||r.state==="failed"||!t.shape)return r;for(const[i,a]of Object.entries(t.shape)){const l=phe({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 Ppe=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"}}),Obt=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"}}),W8r=jy()({get:{optional:!1,kind:"function",required:"operation"},set:{optional:!1,kind:"function",required:"effect"},resolve:{optional:!0,kind:"function",required:"operation"}}),H8r=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"}}),G8r=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"}}),Q8r=jy()({get:{optional:!1,kind:"function",required:"operation"},entries:{optional:!0,kind:"function",required:"operation"}}),K8r=jy()({links:{optional:!1,kind:"function",required:"operation"}}),Y8r=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"}}),X8r=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"}}),Z8r=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"}}),eOr=jy()({pick:{optional:!1,kind:"function",required:"operation"},candidates:{optional:!0,kind:"function",required:"operation"}}),tOr=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"}}),rOr=jy()({accepts:{optional:!1,kind:"function",required:"operation"},drop:{optional:!1,kind:"function",required:"round-trip"}}),nOr=jy()({rect:{optional:!1,kind:"function",required:"operation"},contextRects:{optional:!0,kind:"function",required:"operation"},emptyContainers:{optional:!0,kind:"function",required:"operation"}}),iOr=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"}}),sOr=jy()({get:{optional:!1,kind:"function",required:"operation"},set:{optional:!1,kind:"function",required:"effect"}}),oOr=jy()({backgroundChainAt:{optional:!1,kind:"function",required:"operation"}}),aOr=jy()({resolve:{optional:!1,kind:"function",required:"operation"}}),cOr=jy()({layers:{optional:!1,kind:"function",required:"operation"},preview:{optional:!1,kind:"function",required:"effect"},commit:{optional:!1,kind:"function",required:"round-trip"}}),Fbt={selection:W8r,transforms:H8r,inspector:G8r,assetSubject:Q8r,related:K8r,instances:Y8r,structure:X8r,persistence:Z8r,pickable:eOr,rects:nOr,boxEdit:iOr,text:sOr,colorSample:oOr,stories:tOr,truth:aOr,spatialHandles:cOr,assetDrop:rOr},IDt=new V8r;function lOr(t){IDt.record(t)}const Rbt=new WeakMap;let uOr=1;function fOr(t){const r=Rbt.get(t);if(r)return r;const i=`system-${uOr++}`;return Rbt.set(t,i),i}let p9={},_ze=null,DDt=null;const _he=new Set,mhe=new Set,M9e=new Set;let mze=0;function dOr(){for(const t of M9e)t()}function pOr(t){if(t!==ODt())for(const r of _he)r()}function _Or(t,r){const i=RDt();if(!(t===FDt()&&r.length===i.length&&r.every((a,l)=>a===i[l]))){mze++;for(const a of mhe)a()}}const cI=new Map;let L_e=null;const L9e=new Set,PDt="";function cZ(){return L_e!==null&&cI.has(L_e)?L_e:cI.keys().next().value??null}function NDt(){for(const t of L9e)t()}function mOr(t){const r=cZ();if(L_e=t,r!==cZ()){NDt(),mze++;for(const i of _he)i();for(const i of mhe)i()}}function hOr(t){return L9e.add(t),()=>L9e.delete(t)}function hze(){const t=cZ();return(t===null?void 0:cI.get(t))??p9}function gOr(t,r=PDt){const i=cZ(),a=ODt(),l=FDt(),d=RDt();cI.delete(r),p9=cI.values().next().value??{},pOr(a),_Or(l,d),dOr(),i!==cZ()&&NDt()}function yOr(){for(const t of[...cI.keys()])gOr(null,t);mOr(null)}function vOr(t){return M9e.add(t),()=>M9e.delete(t)}function bOr(){return[...cI.keys()]}function Mbt(t){const r=t.filter(l=>l!==PDt),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 Lbt extends Error{instances;constructor(r,i){super(r),this.name="InstanceResolutionError",this.instances=i}}function AOr(t){const r=bOr();if(t!==void 0){const i=cI.get(t);if(i)return i;throw new Lbt(r.length===0?`no instance "${t}" — no game is mounted`:`no instance "${t}" — live: ${Mbt(r)}`,r)}if(r.length===1)return cI.get(r[0]);if(r.length===0)return p9;throw new Lbt(`${r.length} instances are live (${Mbt(r)}) — name one in your program (\`game.instance(id)\`, or \`await game.instances()\` for handles); refusing to guess`,r)}function SOr(){return p9.camera??null}function ODt(){return p9.networking??DDt??null}function xOr(){return hze().networking??DDt??null}function wOr(t){return _he.add(t),()=>_he.delete(t)}function FDt(){return p9.audio??_ze}function COr(){return hze().audio??_ze}function EOr(t){return mhe.add(t),()=>mhe.delete(t)}function TOr(){return mze}function RDt(){const t=new Set;for(const r of cI.values())r.audio&&t.add(r.audio);return t.size,[...t]}function kOr(){return p9.renderDebug??null}const jbt=new Set;function Kye(){return null}function Yye(t){jbt.add(t);const r=hOr(t);return()=>{jbt.delete(t),r()}}function k8(){const t=Kye();return t?`play:${t.instanceId}`:"stopped"}const vX=new Map,K$=new Map,j_e=new Map;let MDt=0;const j9e=new Set;function Bbt(){MDt++;for(const t of j9e)t()}function dDn(t){return vX.set(t.documentId,t),Bbt(),()=>{vX.get(t.documentId)===t&&(vX.delete(t.documentId),Bbt())}}function Pw(t){return vX.get(t)??null}function pDn(t,r){return j_e.set(t,r),()=>{j_e.get(t)===r&&j_e.delete(t)}}async function IOr(t){await j_e.get(t)?.()}function DOr(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 POr(t){return(K$.get(t)??0)>0}function NOr(){return[...vX.values()]}function Xye(t){return j9e.add(t),()=>j9e.delete(t)}function I8(){return MDt}function Zye(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 J7=[],OOr=0,LDt=0;const B9e=new Set;function $bt(){LDt++;for(const t of B9e)t()}function jDt(t){return B9e.add(t),()=>{B9e.delete(t)}}function qbt(){return LDt}function iP(t){if(J7.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:OOr++};return J7=[...J7,r],$bt(),()=>{J7.includes(r)&&(J7=J7.filter(i=>i!==r),$bt())}}function $9e(t){const r=i=>[...J7].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 B_e=null,BDt=0;const q9e=new Set;function zbt(){BDt++;for(const t of q9e)t()}function $Dt(t){return q9e.add(t),()=>q9e.delete(t)}function z9e(){return BDt}function gze(){return B_e}function FOr(t){const r=Symbol(t.documentId);return B_e={...t,token:r},zbt(),()=>{B_e?.token===r&&(B_e=null,zbt())}}function ROr(){Xe.useSyncExternalStore($Dt,z9e);const t=gze();return t?.status?z.jsx("span",{className:"vgai-status-copy","data-testid":"status-asset-editor","data-status-tone":"muted",children:t.status}):null}const MOr=Zye();function LOr(){MOr.ensure(t=>{t(iP({id:"asset-editor-status",name:"Asset editor",align:"left",order:40,Content:ROr}))})}LOr();let Dq=null,qDt=0;const U9e=new Set;function Ubt(){qDt+=1;for(const t of U9e)t()}function jOr(t){return U9e.add(t),()=>{U9e.delete(t)}}function Vbt(){return qDt}function BOr(t,r){const i=Symbol(t);return Dq={documentId:t,readSubject:r,token:i},Ubt(),()=>{Dq?.token===i&&(Dq=null,Ubt())}}function V9e(){return Dq===null?null:{documentId:Dq.documentId,subject:Dq.readSubject()}}const D8=new Map,J9e=new Map;function zDt(){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"&&zDt()});let Wu=null,yze=null;function UDt(){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 $Or(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 qOr(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 zOr(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=qOr(t.stories),N=t.boardBuildStartedAtMs===null?"switch-back":"first-open",j=UOr({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:yze}}function TA(t,r){const i=Math.max(0,r);return{name:t,ms:i,busyMs:i,waitMs:0,kind:"cpu"}}function Npe(t,r){const i=Math.max(0,r);return{name:t,ms:i,busyMs:0,waitMs:i,kind:"idle"}}function Jbt(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 UOr(t){return[Npe("workspace-sync",t.workspaceSyncMs),Npe("reveal-schedule",t.revealScheduleMs),Jbt("component-index",t.componentIndexMs,t.componentIndexBusyMs,t.componentIndexWaitMs>0||t.componentIndexMs===0?t.componentIndexWaitMs:t.componentIndexMs),TA("candidate-collect",t.candidateCollectMs),Jbt("story-mounts",t.storyMountTotalMs,t.storyMountBusyMs,t.storyMountWaitMs),TA("bounds",t.boundsMs),TA("layout",t.layoutMs),TA("assemble",t.assembleMs),Npe("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),Npe("raf-wait",t.rafWaitMs),TA("first-render",t.firstRenderMs)]}function _Dn(t,r=Date.now()){const i=(J9e.get(t)??0)+1;J9e.set(t,i);const a={documentId:t,activation:i,firstFrameAtMs:r},l=Wu;if(l&&l.documentId===t){const d={...a,breakdown:zOr(l,r)};return Wu=null,D8.set(t,d),Hbt(),Wbt(),d}return D8.set(t,a),Hbt(),Wbt(),a}let W9e=new Set;const H9e=new Set;function Wbt(){zDt();for(const t of H9e)t()}function VOr(t){return H9e.add(t),()=>H9e.delete(t)}function Hbt(){D8.size!==0&&VDt()}function VDt(){const t=W9e;W9e=new Set;for(const r of t)r()}let Gbt=!1;function JOr(){Gbt||typeof document>"u"||(Gbt=!0,document.addEventListener("visibilitychange",()=>{document.hidden&&VDt()}))}function e0e(){return D8.size>0||typeof document<"u"&&document.hidden?Promise.resolve():(JOr(),new Promise(t=>W9e.add(t)))}function WOr(){return[...D8.values()]}function HOr(t){UDt()&&(Wu=$Or(t,Date.now(),{}))}function mDn(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 hDn(t){!Wu||Wu.documentId!==t||Wu.reactActiveAtMs===null&&(Wu.reactActiveAtMs=Date.now())}function gDn(t){!Wu||Wu.documentId!==t||Wu.rafResumeAtMs===null&&(Wu.rafResumeAtMs=Date.now())}function yDn(t){!Wu||Wu.documentId!==t||Wu.firstRenderStartedAtMs===null&&(Wu.firstRenderStartedAtMs=Date.now())}function vDn(){Wu&&(Wu.constructStartedAtMs=Date.now())}function bDn(){Wu&&(Wu.viewportReadyAtMs=Date.now())}function ADn(){return Wu?.documentId??null}function GOr(t){UDt()&&(yze=t)}function QOr(){D8.clear(),J9e.clear(),Wu=null,yze=null}const KOr=["scene","game","world","story","asset","behavior","generation","content-browser","project-tool","tool-contribution","document"];let V_=[],KN=null,OA=null,lZ=null,iz=null;function Qbt(t){queueMicrotask(()=>{iz===t&&V_.some(r=>r.descriptor.id===t)&&(iz=null,Sb(t))})}let JDt=0;const G9e=new Set,xFe=new Set,vze=new Map,IR=new Map;function lI(){JDt++;for(const t of G9e)t()}function Aw(t){return G9e.add(t),()=>{G9e.delete(t)}}function Ab(){return JDt}function FA(){return V_}function I_(){return OA}function Q9e(){return lZ}function YOr(t,r){Sb(t)&&lZ!==r&&(lZ=r,lI())}function AE(){return V_.find(t=>t.descriptor.id===OA)??null}function uZ(t){if(t===OA)return;t&&HOr(t);const r=V_.find(a=>a.descriptor.id===OA);OA=t,lZ=null,r?.descriptor.onDeactivate?.(r.descriptor.id);const i=V_.find(a=>a.descriptor.id===t);i?.descriptor.onActivate?.(i.descriptor.id)}function XOr(t,r,i,a){if(r){!i&&a&&KN===t&&(KN=null);return}i&&(KN&&K8(KN),KN=t)}function qP(t,r={}){const i=iz===t.id,a=i||r.activate!==!1,l=V_.find(_=>_.descriptor.id===t.id);if(XOr(t.id,!!l,r.preview===!0,a),!l)return V_=[...V_,{descriptor:t,dirty:!1,title:t.title}],!t.area&&(a||OA===null)&&uZ(t.id),i&&Qbt(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&&(uZ(t.id),d=!0),d&&lI(),i&&Qbt(t.id),t.id}function Sb(t){return V_.some(r=>r.descriptor.id===t)?(OA!==t&&(uZ(t),lI()),!0):!1}function ZOr(t){if(Sb(t)){iz=null;return}iz=t}function K8(t,r={}){if(xFe.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;xFe.add(t);try{if(OA===t){const d=i>0?V_[i-1]:V_[i+1]??null;uZ(d?d.descriptor.id:null)}return V_=V_.filter(d=>d.descriptor.id!==t),KN===t&&(KN=null),vze.delete(t),IR.delete(t),a.descriptor.onDispose?.(t),lI(),!0}finally{xFe.delete(t)}}function WDt(){if(V_.length===0&&OA===null)return;const t=V_;uZ(null),V_=[],lZ=null,KN=null,vze.clear(),IR.clear(),iz=null;for(const r of t)r.descriptor.onDispose?.(r.descriptor.id);lI()}function e5r(t,r){return V_.some(i=>i.descriptor.id===t)?(IR.set(t,r),lI(),()=>{IR.get(t)===r&&(IR.delete(t),lI())}):()=>{}}function SDn(t){IR.has(t)&&lI()}async function t5r(t){if(!V_.some(i=>i.descriptor.id===t))return null;const r=vze.get(t);if(!r)return null;try{return await r()}catch{return!1}}function r5r(){return OA?t5r(OA):Promise.resolve(null)}function HDt(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 bze(t){const r=V_.find(a=>a.descriptor.id===t),i=IR.get(t)??r?.descriptor.selection;if(!i)return null;try{return i()}catch{return null}}function t0e(){return OA?bze(OA):null}const n5r={adapter:null,nodeId:null};function i5r(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 Aze({documentId:t,active:r=!0,type:i,title:a,sections:l,status:d,selection:_}){Xe.useEffect(()=>{if(r)return FOr({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 e5r(t,()=>g.current?.()??n5r)},[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=i5r(b);return Xe.useEffect(()=>{if(r)return BOr(t,()=>S.current)},[r,t,k]),null}function s5r({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(Aze,{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 o5r=Object.freeze(Object.defineProperty({__proto__:null,AssetEditorShell:s5r,AssetEditorSubject:Aze},Symbol.toStringTag,{value:"Module"})),a5r=Xe.lazy(async()=>({default:(await la(()=>import("./ToolObject3DPreview-CWdklUZ1.js"),__vite__mapDeps([39,1,2,40,3,4,8,9,10,6,41,42,11]))).ToolObject3DPreview})),c5r=Xe.lazy(async()=>({default:(await la(()=>import("./StageHost-DD_m8W0k.js").then(r=>r.c),__vite__mapDeps([43,1,2,3,4,8,9,6,10,7,41,14,44,42]))).ToolObject3DAuthoring}));function l5r(t){return z.jsx(Xe.Suspense,{fallback:z.jsx("div",{style:{minHeight:240},children:"Loading 3D preview…"}),children:z.jsx(a5r,{...t})})}function u5r(t){return Xe.useEffect(()=>DOr(t.documentId),[t.documentId]),z.jsx(Xe.Suspense,{fallback:z.jsx("div",{style:{minHeight:240},children:"Loading 3D authoring surface…"}),children:z.jsx(c5r,{...t})})}function f5r(t){return z.jsx(Aze,{...t})}const Sze=Object.freeze({AssetDocument:f5r,Object3DPreview:l5r,Object3DAuthoring:u5r}),Kbt=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)"}}),d5r=["classic","glass"],p5r=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 hhe=null;const ghe=new Set;function _5r(){return hhe??=[...p5r,...[...Pq.values()].map(({id:t,title:r,description:i})=>({id:t,title:r,description:i}))],hhe}function m5r(t){return ghe.add(t),()=>ghe.delete(t)}function h5r(t){if(r0e(t.id))throw new Error(`registerContributedMaterial: material "${t.id}" is already registered.`);Pq.set(t.id,t),hhe=null;for(const r of ghe)r();return()=>{if(Pq.get(t.id)===t){Pq.delete(t.id),hhe=null;for(const r of ghe)r()}}}function r0e(t){return typeof t=="string"&&(d5r.includes(t)||Pq.has(t))}function g5r(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??Kbt.shape,elevation:l?.elevation??Kbt.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 y5r={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch",baseline:"baseline"},v5r={start:"flex-start",center:"center",end:"flex-end",between:"space-between",around:"space-around",evenly:"space-evenly"};function Ope(t){return t===0?"0px":t===void 0?void 0:`var(--vgai-space-${t})`}function GDt({gap:t,align:r,justify:i,padding:a,paddingX:l,paddingY:d,style:_}){return{gap:Ope(t),alignItems:r?y5r[r]:void 0,justifyContent:i?v5r[i]:void 0,padding:Ope(a),paddingInline:Ope(l),paddingBlock:Ope(d),..._}}function n0e(t,r){return r?`${t} ${r}`:t}function i0e({className:t,...r}){return z.jsx("div",{...r,className:n0e("vgai-stack",t),style:GDt(r)})}function Nq({className:t,...r}){return z.jsx("div",{...r,className:n0e("vgai-inline",t),style:GDt(r)})}function b5r({orientation:t="horizontal",className:r,...i}){return z.jsx("div",{...i,"aria-hidden":"true","data-orientation":t,className:n0e("vgai-divider",r)})}function A5r({children:t,className:r,...i}){return z.jsx(Nq,{...i,className:n0e("vgai-actions",r),gap:2,align:"center",children:t})}function QDt(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:QDt("vgai-text",_)})});function $_e({className:t,...r}){return z.jsx("kbd",{...r,className:QDt("vgai-keycap",t)})}function xze(t,r){return r?`${t} ${r}`:t}function K9e({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:xze("vgai-dialog",l)})});return _?vS.createPortal(g,_):g}function Y9e({titleId:t,title:r,description:i}){return z.jsxs(i0e,{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 KDt({className:t,...r}){return z.jsx(i0e,{...r,className:xze("vgai-dialog-body",t)})}function X9e({children:t,className:r,...i}){return z.jsx(A5r,{...i,className:xze("vgai-dialog-footer",r),children:t})}function YDt(t,r){return r?`${t} ${r}`:t}function S5r({className:t,...r}){return z.jsx("div",{...r,className:YDt("vgai-field-group",t)})}function q_e({label:t,htmlFor:r,hint:i,compact:a=!1,className:l,children:d,..._}){return z.jsxs("div",{..._,"data-compact":a||void 0,className:YDt("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 x5r({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 s0e(t,r){return r?`${t} ${r}`:t}function w5r({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:s0e("vgai-surface",a)})}function C5r({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:s0e("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 wze=Xe.forwardRef(function({className:r,...i},a){return z.jsx("div",{ref:a,...i,className:s0e("vgai-popover",r)})});function Ybt({position:t="inside",className:r,...i}){return z.jsx("div",{...i,"aria-hidden":"true","data-position":t,className:s0e("vgai-drop-indicator",r)})}function XDt(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:XDt("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:XDt("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 Aee(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:Aee("vgai-toolbar",l)})});function Xbt({className:t,...r}){return z.jsx("div",{...r,role:"group",className:Aee("vgai-toolbar-group",t)})}function Zbt(t){return z.jsx("span",{...t,"aria-hidden":"true",className:Aee("vgai-toolbar-divider",t.className)})}function E5r({className:t,onPointerDownCapture:r,...i}){return z.jsx(NP,{...i,compact:!0,className:Aee("vgai-floating-toolbar vgai-glass-island",t),onPointerDownCapture:a=>{r?.(a),a.stopPropagation()}})}function Cze({className:t,...r}){return z.jsx("div",{...r,role:"group",className:Aee("vgai-split-button",t)})}function ZDt(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:ZDt("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:ZDt("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 e3t(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 o0e(t,r){return r?`${t} ${r}`:t}function Z9e(t){return Array.from(t.querySelectorAll('[role="menuitem"]:not(:disabled), [role="menuitemradio"]:not(:disabled), [role="menuitemcheckbox"]:not(:disabled)'))}function T5r(t){Z9e(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&&Z9e(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:o0e("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=Z9e(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:o0e("vgai-menu-item",r),onClick:b=>{l?.(b),b.defaultPrevented||d?.()}})});function Ny(t){return z.jsx("hr",{...t,className:o0e("vgai-menu-separator",t.className)})}const Eze=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:o0e("vgai-menu-trigger",r)})});function yhe({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 VR({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?e3t({...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,T5r(k))},[a,k,N]);const ee=xe=>{J.current=xe!=="outside",_(),xe==="escape"&&t.current?.focus()};return z.jsx(yhe,{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 xDn({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(VR,{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},tY={0:"#1a1a1a",1:"#242424",2:"#2c2c2c",3:"#333333",inset:"#1e1e1e"},eAt={1:"#333333",2:"#444444"},Oq={1:"#c5c8ce",2:"#9aa0a6",3:"#90959c"},k5r="#579EFF",I5r="rgba(87,158,255,0.15)",wFe={1:"#f2f6fb",2:"#d3d9e0",3:"#aab0b7"},Tze="#d8dee9",kze="rgba(216,222,233,0.18)",t3t="#FF6B6B",r3t="#e0a030",n3t="#4caf50",i3t="rgba(76,175,80,0.15)",s3t="rgba(255,107,107,0.15)",o3t="rgba(224,160,48,0.12)",a3t="rgba(255,107,107,0.06)",c3t="rgba(0,0,0,0.5)",l3t="#ff79c6",u3t="rgba(255,121,198,0.08)",f3t="#22b8d6",a0e='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',c0e='ui-monospace, "SF Mono", Monaco, "Cascadia Code", monospace',CFe={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)"},Ize={1:"var(--vgai-surface-panel)",inset:"var(--vgai-surface-inset)"},vhe={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)"},eMe="var(--vgai-danger)",U_={1:2,2:4,3:6,4:8,5:10,6:12,8:16,10:20,12:24},d3t={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:{...D5r,...t.density?.control},font:{...N5r,...t.density?.font},icon:{...P5r,...t.density?.icon},chrome:{...d3t,...t.density?.chrome}}}const D5r={compact:20,default:24,comfortable:28},EFe={resting:1,active:2},P5r={xs:9,sm:10,md:12,lg:13,xl:14,"2xl":16},N5r={xs:9,sm:10,base:11,md:12,lg:13,xl:14,"2xl":16,heading:24},z_e={regular:400,semibold:600,bold:700},Fpe={tight:1,snug:1.2,normal:1.4,relaxed:1.5},rY={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"},fZ={sm:"var(--vgai-radius-sm)"},qY={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)"},tAt={normal:"var(--vgai-leading-normal)"},O5r=["outliner","properties"],sz={id:"graphite-dark",color:{surface:{shell:tY[0],panel:tY[1],chrome:tY[2],raised:tY[3],inset:tY.inset,overlay:"rgba(36,36,36,0.94)"},boundary:{default:eAt[1],strong:eAt[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:k5r,muted:I5r},semantic:{danger:t3t,dangerMuted:s3t,dangerFaint:a3t,warning:r3t,warningMuted:o3t,success:n3t,successMuted:i3t,dynamic:l3t,dynamicMuted:u3t,instance:f3t},neutralOverlay:{hover:"rgba(255,255,255,0.08)",active:"rgba(255,255,255,0.14)"},scrim:c3t},typography:{sans:a0e,mono:c0e},shape:{small:ZN.small,medium:ZN.medium,large:ZN.large,full:ZN.full},elevation:{small:CFe.sm,medium:CFe.md,large:CFe.lg}},F5r={...sz,id:"graphite-neutral",color:{...sz.color,content:{primary:wFe[1],muted:wFe[2],dim:wFe[3],onAccent:"#101820",onBright:{primary:"#1a2330",muted:"rgba(26,35,48,0.82)",dim:"rgba(26,35,48,0.74)"}},accent:{default:Tze,muted:kze}}},R5r={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:a0e,mono:c0e},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)"}},tMe={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:Tze,muted:kze},semantic:{danger:t3t,dangerMuted:s3t,dangerFaint:a3t,warning:r3t,warningMuted:o3t,success:n3t,successMuted:i3t,dynamic:l3t,dynamicMuted:u3t,instance:f3t},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:a0e,mono:c0e},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}},M5r=(()=>{const{treatment:t,...r}=tMe;return{...r,id:"glass-dark-lite",appearance:{material:"glass",transparency:"reduced"},color:{...tMe.color,surface:{shell:"#1a1a1a",panel:"#222222",chrome:"#292929",raised:"#303030",inset:"#1d1d1d",overlay:"#202020"},scrim:c3t}}})(),rMe={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:Tze,muted:kze},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:a0e,mono:c0e},shape:fh.shape,elevation:fh.elevation,treatment:fh.treatment},L5r=(()=>{const{treatment:t,...r}=rMe;return{...r,id:"liquid-glass-lite",appearance:{material:"glass",transparency:"reduced"},color:{...rMe.color,surface:fh.reducedTransparency.surface,scrim:fh.reducedTransparency.scrim}}})(),p3t={"graphite-dark":sz,"graphite-neutral":F5r,"midnight-high-contrast":R5r,"glass-dark":tMe,"glass-dark-lite":M5r,"liquid-glass":rMe,"liquid-glass-lite":L5r};function j5r(t){return typeof t=="string"&&Object.hasOwn(p3t,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 B5r(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 $5r(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 rAt(t,r){return r?"transparent":`linear-gradient(var(${t}), var(${t})), linear-gradient(var(--vgai-surface-shell), var(--vgai-surface-shell))`}function nAt(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 nMe(t){return(t?.contentFrostBlurPx??0)>0?"rgba(255,255,255,0.10)":"transparent"}function q5r(t){return t?"color-mix(in srgb, currentColor 7%, transparent)":"var(--vgai-widget-field)"}function z5r(t){return t?"color-mix(in srgb, currentColor 26%, transparent)":"var(--vgai-boundary-default)"}function U5r(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 V5r=.6,J5r=.5;function bhe(t,r){return`rgba(255,255,255,${Math.min(1,Number((t*r/V5r).toFixed(3)))})`}function _3t(t){const r=t?.edgeSpecular??0;if(r<=0)return"none";const i=t?.specularAngleDeg??120,a=l=>bhe(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 W5r(t){const r=t?.edgeSpecular??0;if(r<=0)return"none";const i=t?.specularAngleDeg??120,a=l=>bhe(l,r);return`linear-gradient(${i}deg, ${a(.16)} 0%, ${a(.05)} 24%, transparent 40%)`}function H5r(t){const r=t?.edgeSpecular??0,i=t?.thickness??0,a=[];if(r>0&&(a.push(`inset 0 1px 1px ${bhe(.28,r)}`),a.push(`inset 0 -1px 1px ${bhe(.1,r)}`)),i>0){const l=d=>`${Number((d*i/J5r).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 rU(t){return t.appearance?t.appearance.material==="glass":t.treatment!==void 0}function G5r(t){return rU(t)?"var(--vgai-surface-panel)":"color-mix(in srgb, var(--vgai-surface-panel) 90%, transparent)"}function Q5r(t){return rU(t)?t.treatment?"var(--vgai-surface-backdrop-filter)":"none":"blur(8px)"}function K5r(t){return t?"17px":"var(--vgai-radius-md)"}function Y5r(t){return t?"var(--vgai-boundary-default)":"var(--vgai-boundary-strong)"}function X5r(t){return t?"var(--vgai-shadow-lg)":"var(--vgai-shadow-sm)"}function Z5r(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 l0e(t){return rU(t)}function eFr(t){return l0e(t)?"var(--vgai-neutral-active)":"var(--vgai-accent-muted)"}function tFr(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 rFr(t){return l0e(t)?"var(--vgai-content-primary)":tFr(t.color.accent.muted)?"var(--vgai-content-on-accent)":"var(--vgai-content-primary)"}function nFr(t){return l0e(t)?"color-mix(in srgb, currentColor 30%, transparent)":"var(--vgai-accent)"}function iFr(t){return l0e(t)?"color-mix(in srgb, currentColor 76%, transparent)":"var(--vgai-accent)"}function sFr(t){return t?"var(--vgai-radius-full)":"var(--vgai-radius-sm)"}function oFr(t){return!rU(t)||!t.treatment?"var(--vgai-accent)":Z5r(t,.82)??"var(--vgai-accent)"}function aFr(t){const r=t?.edgeSpecular??0;return r<=0?"none":_3t({...t,edgeSpecular:r*.4})}function cFr(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 m3t(t){return t<=0?"none":`0 1px 2px rgba(0,0,0,${Number(t.toFixed(3))})`}function h3t(t){return m3t(t?.textShadowOpacity??0)}function lFr(t){return t.treatment?.adaptiveContent?{primary:t.color.content.onBright.primary,muted:t.color.content.onBright.muted,dim:t.color.content.onBright.dim,textShadow:m3t(t.treatment.brightTextShadowOpacity??0),frostBg:t.treatment.brightFrostBg??nMe(t.treatment)}:{primary:t.color.content.primary,muted:t.color.content.muted,dim:t.color.content.dim,textShadow:h3t(t.treatment),frostBg:nMe(t.treatment)}}function uFr(t){return t.treatment?t.treatment.adaptiveContent?"rgba(255,255,255,0.9)":dFr(t.color.surface.chrome,.9):t.color.surface.chrome}function fFr(t){return t.color.surface.panel}function dFr(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 iAt(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 pFr(t){return t.color.boundary.area??t.color.boundary.default}function _Fr(t,r){return`color-mix(in srgb, ${t} 98.4%, ${r})`}function nY(t){return`color-mix(in srgb, var(--vgai-area-emboss-mix), ${t})`}function mFr(t){const r=s_(t).chrome.areaEmboss;return r>0?`#ffffff ${r}%`:"transparent 100%"}function hFr(t){const r=lFr(t),i=rU(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":$5r(t.treatment),"--vgai-surface-sticky":rAt("--vgai-surface-chrome",i),"--vgai-surface-sticky-panel":rAt("--vgai-surface-panel",i),"--vgai-surface-sticky-backdrop-filter":"none","--vgai-surface-body-frost-filter":nAt(t.treatment),"--vgai-content-frost-filter":nAt(t.treatment),"--vgai-content-frost-bg":nMe(t.treatment),"--vgai-input-surface":q5r(i),"--vgai-input-border":z5r(i),"--vgai-input-shadow":U5r(i,_),"--vgai-structural-divider":i?"transparent":t.color.boundary.default,"--vgai-card-specular-ring":_3t(t.treatment),"--vgai-card-specular-sheen":W5r(t.treatment),"--vgai-card-specular-shadow":H5r(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":cFr(t.treatment),"--vgai-island-surface":G5r(t),"--vgai-island-backdrop-filter":Q5r(t),"--vgai-island-radius":K5r(i),"--vgai-island-border-color":Y5r(i),"--vgai-island-shadow":X5r(i),"--vgai-island-specular-ring":aFr(t.treatment),"--vgai-selection-bg":eFr(t),"--vgai-content-on-selection":rFr(t),"--vgai-selection-border":nFr(t),"--vgai-selection-indicator":iFr(t),"--vgai-island-control-radius":sFr(i),"--vgai-island-primary-bg":oFr(t),"--vgai-content-text-shadow":h3t(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":uFr(t),"--vgai-glass-regular-backdrop-filter":iAt(t.treatment),"--vgai-glass-regular-panel-bg":fFr(t),"--vgai-glass-regular-panel-backdrop-filter":iAt(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":pFr(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":mFr(t),"--vgai-area-emboss":nY(t.color.surface.panel),"--vgai-area-emboss-stage":nY(nY(t.color.viewport?.background??t.color.surface.panel)),"--vgai-area-emboss-stage-header":nY(nY(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":_Fr(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":`${EFe.active}px solid ${t.color.accent.default}`,"--vgai-select-chevron":B5r(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":`${EFe.resting}px`,"--vgai-stroke-active":`${EFe.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(z_e.regular),"--vgai-font-weight-semibold":String(z_e.semibold),"--vgai-font-weight-bold":String(z_e.bold),"--vgai-leading-tight":String(Fpe.tight),"--vgai-leading-snug":String(Fpe.snug),"--vgai-leading-normal":String(Fpe.normal),"--vgai-leading-relaxed":String(Fpe.relaxed),"--vgai-duration-fast":`${rY.duration.fast}ms`,"--vgai-duration-base":`${rY.duration.base}ms`,"--vgai-duration-slow":`${rY.duration.slow}ms`,"--vgai-ease-standard":rY.easing.standard,"--vgai-ease-out":rY.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 iMe="vgai-editor-theme";function gFr(t,r=sz){t.classList.add(iMe),t.dataset.vgaiTheme=r.id,t.dataset.vgaiChrome=rU(r)?"islands":"bars";for(const[i,a]of Object.entries(hFr(r)))t.style.setProperty(i,a)}const g3t=Xe.createContext(null);function yFr(){return Xe.useContext(g3t)}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)})}),Dze=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)})}),y3t=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 wDn=Xe.forwardRef(function({className:r,...i},a){return z.jsx("input",{...i,ref:a,type:"range",className:_9("vgai-range",r)})}),Yk="default",bX=new Map;let dZ=Yk;const sMe=new Set;function oMe(){for(const t of sMe)t()}function See(t){return typeof t=="string"&&(t===Yk||bX.has(t))}function vFr(t){if(See(t.id))throw new Error(`registerContributedIconSet: icon set "${t.id}" is already registered.`);return bX.set(t.id,t),oMe(),()=>{bX.get(t.id)===t&&(bX.delete(t.id),oMe())}}function sAt(){return dZ}function U_e(t){const r=See(t)?t:Yk;r!==dZ&&(dZ=r,oMe())}function v3t(t){return sMe.add(t),()=>sMe.delete(t)}function bFr(t){return dZ===Yk?null:bX.get(dZ)?.glyphs[t]??null}const oAt={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)"},aAt={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(v3t,sAt,sAt);const b=bFr(t.iconName);if(b){const S=i!=="current",k=b.tone?`var(--vgai-category-${b.tone}, currentColor)`:void 0,w=S?aAt[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:oAt[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(Dkr,{...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:oAt[r],color:aAt[i],...d}})}function b3t({direction:t,size:r="xs",tone:i="current",style:a}){return z.jsx(So,{icon:t==="right"?$kt:Xkt,size:r,tone:i,...a?{style:a}:{}})}function aS(t,r){return{...r,iconName:t}}const gb={action:{close:Yqe,search:Mkt},transport:{play:tDr,pause:bDr,stop:S9e},content:{project:Bkt,folder:hee},status:{success:S8,warning:yee,error:Wkt},viewport:{zoomIn:MIr,zoomOut:OIr,pan:GIr,frame:jkt,projection:aS("viewport-projection",ADr)},modeling:{extrude:aS("mesh-extrude",Vkt),inset:aS("mesh-inset",yDr),bevel:aS("mesh-bevel",xDr),loopCut:aS("mesh-loop-cut",LIr),knife:aS("mesh-knife",dDr),smooth:aS("mesh-smooth",NIr),shrinkFatten:aS("mesh-shrink-fatten",Hkt),subdivide:aS("mesh-subdivide",rDr)},tool:{extension:gee,select:CDr,move:Gkt,rotate:Fkt,scale:aS("tool-scale",jIr),transform:aS("tool-transform",YIr)},panel:{outliner:aS("outliner",aIt),properties:aS("properties",Qkt)}};function AX({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=yFr();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 AFr={minHeight:"var(--vgai-panel-header-height)",padding:`0 ${U_[4]}px`,color:Oo.content.muted,fontSize:"var(--vgai-font-base)",fontWeight:z_e.semibold,textTransform:"uppercase",display:"flex",alignItems:"center",gap:U_[2],userSelect:"none"},SFr={...AFr,background:"var(--vgai-surface-sticky)",borderBottom:"1px solid var(--vgai-structural-divider)",flexShrink:0};function Pze({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:{...SFr,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 xFr({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(b3t,{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 wFr(t){return t==="top"?"bottom":t==="bottom"?"top":t==="left"?"right":"left"}function CFr(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 EFr(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=CFr(a,se,de)?a:wFr(a);X(EFr(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 TFr({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(AX,{label:"X",labelColor:"#E06178",value:t[0],onChange:g(0),step:a,disabled:l,style:{flex:1},testId:_("x")}),z.jsx(AX,{label:"Y",labelColor:"#C2ED66",value:t[1],onChange:g(1),step:a,disabled:l,style:{flex:1},testId:_("y")}),z.jsx(AX,{label:"Z",labelColor:"#6BABF5",value:t[2],onChange:g(2),step:a,disabled:l,style:{flex:1},testId:_("z")})]})}const TFe={border:Oo.boundary.default,accent:Oo.accent.default,radiusSmall:Oo.shape.small,inputBg:Oo.surface.inset},kFr={fontSize:"var(--vgai-font-base)",fontWeight:600,color:Oo.content.muted,textTransform:"uppercase",letterSpacing:.4},IFr=72,kFe=22,cAt={width:kFe,height:kFe,flex:`0 0 ${kFe}px`,borderRadius:TFe.radiusSmall,border:`1px solid ${TFe.border}`,background:TFe.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 DFr({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:cAt,"data-testid":`${_}-thumb`}):z.jsx("span",{style:cAt,"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:Yqe})})]}),d&&z.jsx("span",{"data-testid":`${_}-note`,style:{fontSize:"var(--vgai-font-sm)",color:Oo.content.muted},children:d})]})}function aMe({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 SX=new Map,Fq=new Set,Ahe=new Set,V_e=new Set;let A3t=0;function S3t(){A3t+=1;for(const t of[...Fq])t()}function PFr(t,r){return SX.set(t,r),S3t(),()=>{SX.get(t)===r&&SX.delete(t)}}function NFr(t){SX.has(t)&&S3t()}function OFr(t){return Fq.add(t),()=>{Fq.delete(t)}}function lAt(){return A3t}function pZ(t){return SX.get(t)}function x3t(t,r=1e4){const i=pZ(t);return i!==void 0?Promise.resolve(i):new Promise(a=>{const l=()=>{const _=pZ(t);_!==void 0&&(clearTimeout(d),Fq.delete(l),a(_))},d=setTimeout(()=>{Fq.delete(l),a(void 0)},r);Fq.add(l)})}function w3t(t){Ahe.add(t);for(const r of[...V_e])r();return()=>{Ahe.delete(t)}}function C3t(t,r=1e4){return Ahe.has(t)?Promise.resolve(!0):new Promise(i=>{const a=()=>{Ahe.has(t)&&(clearTimeout(l),V_e.delete(a),i(!0))},l=setTimeout(()=>{V_e.delete(a),i(!1)},r);V_e.add(a)})}async function Nze(t){if(POr(t)&&!await xE(()=>Pw(t)!==null,m9))throw new Error(`The requested Object3D view did not mount for document: ${t}`)}let cMe=null;const zY=new Map;let DR=[];function FFr(t){if(cMe=t,!t)return;const r=DR;DR=[];for(const i of r)E3t(t,i)}function E3t(t,r){zY.get(r.id)?.();const i=t.show(r),a=()=>{zY.get(r.id)===a&&(zY.delete(r.id),i(),r.onDismiss?.())};return zY.set(r.id,a),a}let RFr=0;function oz(t){const r=t.id??`notification-${++RFr}`,i={...t,id:r};return cMe?E3t(cMe,i):(DR=[...DR.filter(a=>a.id!==r),i],()=>Oze(r))}function Oze(t){const r=zY.get(t);if(r){r();return}const i=DR.find(a=>a.id===t);i&&(DR=DR.filter(a=>a.id!==t),i.onDismiss?.())}let iI={sessions:[],selectedSessionId:null,selectedSession:null,cursorMs:0,liveEdgeMs:0,loading:!0,error:null},She=!0,Rpe=null,J_e=null,iY=null,W_e=!1;const UY=new Set;function MFr(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 xhe(t){iI=t;for(const r of UY)r()}async function LFr(){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 BFr(){try{const t={sessions:await LFr()},r=MFr(t.sessions,iI.sessions,J_e),i=r.sessionId;r.latestAppeared&&(She=!0),J_e=i;const a=i?await jFr(i):null;if(J_e!==i){W_e=!0;return}const l=t.sessions.map(g=>g.id===a?.id?a:g),d=a?.durationMs??0,_=She?d:Math.min(iI.cursorMs,d);xhe({sessions:l,selectedSessionId:i,selectedSession:a,cursorMs:_,liveEdgeMs:d,loading:!1,error:null})}catch(t){xhe({...iI,loading:!1,error:t instanceof Error?t.message:String(t)})}}function _Z(){return iY?(W_e=!0,iY):(iY=BFr().finally(()=>{iY=null,W_e&&(W_e=!1,_Z())}),iY)}function $Fr(t){return UY.add(t),UY.size===1&&(_Z(),Rpe=window.setInterval(()=>void _Z(),1e3)),()=>{UY.delete(t),UY.size===0&&Rpe!==null&&(window.clearInterval(Rpe),Rpe=null)}}function qFr(t){const r=iI.sessions.find(i=>i.id===t);r&&(J_e=r.id,She=!0,xhe({...iI,selectedSessionId:r.id,selectedSession:r,cursorMs:r.durationMs,liveEdgeMs:r.durationMs}),_Z())}function zFr(t){const r=Math.max(0,Math.min(t,iI.liveEdgeMs));She=iI.liveEdgeMs-r<250,xhe({...iI,cursorMs:r})}const T3t={getSnapshot:()=>iI,subscribe:$Fr,select:qFr,seek:zFr,refresh:_Z};let UFr=null;const uAt=new Set,CDn={getSnapshot:()=>UFr,subscribe(t){return uAt.add(t),()=>uAt.delete(t)}};let H_e={phase:null,run:0},k3t=null;function VFr(t){k3t=t}function fAt(t){H_e=t;try{k3t?.(t)}catch{}}function I3t(t,r=Date.now()){return fAt({phase:t,at:r,run:H_e.run}),()=>{H_e.phase===t&&fAt({phase:null,at:Date.now(),run:H_e.run})}}const JFr=Xe.lazy(()=>la(()=>import("./GameplaySessionTimeline-kIIuhFBI.js"),__vite__mapDeps([45,1,2,3,4,8,9,10,11,6])).then(t=>({default:t.GameplaySessionTimeline})));class Fze 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 WFr({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&&w3t(P.current)},G=j.appendChild(document.createElement("div"));G.style.display="contents";const ee=Vqe.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:y0e(),surfaces:Sze,account:pze(),work:ee=>{w.current?.(),w.current=ee===null?null:I3t(`building ${ee.replace(/^building /,"")}`)},notify:ee=>oz({...ee,id:`contribution:${t.id}:${ee.title}`,...ee.tone==="warning"?{fades:!0}:{}}),...t.point==="workspace.analytics"?{gameplaySessions:T3t}:{play:Kye()},...i?{documentId:i,publishContext:ee=>PFr(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(HFr,{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 HFr({documentId:t,children:r}){return Xe.useEffect(()=>w3t(t),[t]),z.jsx(z.Fragment,{children:r})}function h9({contribution:t,Component:r,documentId:i,active:a,document:l}){const d=Xe.useSyncExternalStore(Qye,T8,T8),_=Xe.useSyncExternalStore(Yye,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(JFr,{})}):null,z.jsx(Fze,{file:t.file,children:z.jsx("div",{style:{flex:1,minHeight:0,overflow:"auto"},children:z.jsx(WFr,{contribution:t,...r?{Component:r}:{},accountRevision:d,playKey:g,...i?{documentId:i}:{},...a!==void 0?{active:a}:{},...l?{document:l}:{}})})})]})}function GFr({id:t,title:r,file:i,tool:a,Component:l,adapter:d,nodeId:_}){Xe.useSyncExternalStore(Qye,T8,T8),Xe.useSyncExternalStore(Yye,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(Fze,{file:i,children:z.jsx(m3r,{adapter:d,nodeId:_,children:z.jsx(l,{...a?{tool:a}:{},contributionId:t.slice(t.lastIndexOf(":")+1),client:y0e(),surfaces:Sze,account:pze(),play:Kye(),node:g,nodeId:_,adapter:d})})})})}const QFr=Symbol("vgai.inspection.mixed");function lMe(t){return t===QFr}function Rze(t){return t.readonlyReason??"This field is read-only."}function Mze(t){return"column"}function Lze(t,r){return t.quickActions.filter(i=>i.placement===r)}const uMe="preview",dAt="transform",IFe="properties",D3t="stories";function pAt(t){return`group:${t}`}const P3t=100,KFr=1e3,mZ=2e3,N3t=3e3,YFr=4e3,XFr=5e3,ZFr={nullSubjectId:null};function O3t(t){return"sections"in t}const G_e=[];let F3t=0;const fMe=new Set;function _At(){F3t++;for(const t of fMe)t()}function e7r(t){return fMe.add(t),()=>{fMe.delete(t)}}function mAt(){return F3t}function R3t(t){return G_e.push(t),_At(),()=>{const r=G_e.indexOf(t);r>=0&&(G_e.splice(r,1),_At())}}function hAt(t,r,i=ZFr){return G_e.filter(a=>a.match(t,r,i))}function M3t(t){if(typeof t!="object"||t===null)return!1;const r=t.name;return r==="Canceled"||r==="CancellationError"||r==="AbortError"}const t7r=1e3;class r7r{_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>t7r){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 r7r;typeof window<"u"&&(window.__vgaiEditorConsole=ua);const gAt=1e3,yAt=4e3;function Rq(t){try{return String(t)}catch{return Object.prototype.toString.call(t)}}function n7r(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>gAt?`${i.slice(0,gAt)}…`:i}function L3t(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 n7r(b)}}),d=i.slice(a);return d.length===0?l:`${l} ${d.map(Rq).join(" ")}`}function i7r(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 uhe(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:fhe(r,"input",t.processors),output:fhe(r,"output",t.processors)}},enumerable:!1,writable:!1}),_}catch{throw new Error("Error converting schema to JSON.")}}function _b(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 _b(a.element,i);if(a.type==="set")return _b(a.valueType,i);if(a.type==="lazy")return _b(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 _b(a.innerType,i);if(a.type==="intersection")return _b(a.left,i)||_b(a.right,i);if(a.type==="record"||a.type==="map")return _b(a.keyType,i)||_b(a.valueType,i);if(a.type==="pipe")return _b(a.in,i)||_b(a.out,i);if(a.type==="object"){for(const l in a.shape)if(_b(a.shape[l],i))return!0;return!1}if(a.type==="union"){for(const l of a.options)if(_b(l,i))return!0;return!1}if(a.type==="tuple"){for(const l of a.items)if(_b(l,i))return!0;return!!(a.rest&&_b(a.rest,i))}return!1}const h6r=(t,r={})=>i=>{const a=che({...i,processors:r});return J_(t,a),lhe(a,t),uhe(a,t)},fhe=(t,r,i={})=>a=>{const{libraryOptions:l,target:d}=a??{},_=che({...l??{},target:d,io:r,processors:i});return J_(t,_),lhe(_,t),uhe(_,t)},g6r={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},HIt=(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=g6r[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}))])}},GIt=(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)},QIt=(t,r,i,a)=>{i.type="boolean"},y6r=(t,r,i,a)=>{if(r.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema")},v6r=(t,r,i,a)=>{if(r.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema")},b6r=(t,r,i,a)=>{r.target==="openapi-3.0"?(i.type="string",i.nullable=!0,i.enum=[null]):i.type="null"},A6r=(t,r,i,a)=>{if(r.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema")},S6r=(t,r,i,a)=>{if(r.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema")},KIt=(t,r,i,a)=>{i.not={}},x6r=(t,r,i,a)=>{},YIt=(t,r,i,a)=>{},w6r=(t,r,i,a)=>{if(r.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema")},XIt=(t,r,i,a)=>{const l=t._zod.def,d=EIt(l.entries);d.every(_=>typeof _=="number")&&(i.type="number"),d.every(_=>typeof _=="string")&&(i.type="string"),i.enum=d},ZIt=(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},C6r=(t,r,i,a)=>{if(r.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema")},E6r=(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},T6r=(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)},k6r=(t,r,i,a)=>{i.type="boolean"},eDt=(t,r,i,a)=>{if(r.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},I6r=(t,r,i,a)=>{if(r.unrepresentable==="throw")throw new Error("Function types cannot be represented in JSON Schema")},tDt=(t,r,i,a)=>{if(r.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},D6r=(t,r,i,a)=>{if(r.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema")},P6r=(t,r,i,a)=>{if(r.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema")},rDt=(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"]})},nDt=(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)},iDt=(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=_},sDt=(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},oDt=(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)},aDt=(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)}},cDt=(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"}]},lDt=(t,r,i,a)=>{const l=t._zod.def;J_(l.innerType,r,a);const d=r.seen.get(t);d.ref=l.innerType},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,i.default=JSON.parse(JSON.stringify(l.defaultValue))},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,r.io==="input"&&(i._prefault=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;let _;try{_=l.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}i.default=_},pDt=(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},_Dt=(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},N6r=(t,r,i,a)=>{const l=t._zod.def;J_(l.innerType,r,a);const d=r.seen.get(t);d.ref=l.innerType},lze=(t,r,i,a)=>{const l=t._zod.def;J_(l.innerType,r,a);const d=r.seen.get(t);d.ref=l.innerType},mDt=(t,r,i,a)=>{const l=t._zod.innerType;J_(l,r,a);const d=r.seen.get(t);d.ref=l},bbt={string:HIt,number:GIt,boolean:QIt,bigint:y6r,symbol:v6r,null:b6r,undefined:A6r,void:S6r,never:KIt,any:x6r,unknown:YIt,date:w6r,enum:XIt,literal:ZIt,nan:C6r,template_literal:E6r,file:T6r,success:k6r,custom:eDt,function:I6r,transform:tDt,map:D6r,set:P6r,array:rDt,object:nDt,union:iDt,intersection:sDt,tuple:oDt,record:aDt,nullable:cDt,nonoptional:lDt,default:uDt,prefault:fDt,catch:dDt,pipe:pDt,readonly:_Dt,promise:N6r,optional:lze,lazy:mDt};function O6r(t,r){if("_idmap"in t){const a=t,l=che({...r,processors:bbt}),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;lhe(l,k),_[S]=uhe(l,k)}if(Object.keys(d).length>0){const b=l.target==="draft-2020-12"?"$defs":"definitions";_.__shared={[b]:d}}return{schemas:_}}const i=che({...r,processors:bbt});return J_(t,i),lhe(i,t),uhe(i,t)}const F6r=ys("ZodISODateTime",(t,r)=>{LPr.init(t,r),gh.init(t,r)});function R6r(t){return J4r(F6r,t)}const M6r=ys("ZodISODate",(t,r)=>{jPr.init(t,r),gh.init(t,r)});function L6r(t){return W4r(M6r,t)}const j6r=ys("ZodISOTime",(t,r)=>{BPr.init(t,r),gh.init(t,r)});function B6r(t){return H4r(j6r,t)}const $6r=ys("ZodISODuration",(t,r)=>{$Pr.init(t,r),gh.init(t,r)});function q6r(t){return G4r($6r,t)}const z6r=(t,r)=>{DIt.init(t,r),t.name="ZodError",Object.defineProperties(t,{format:{value:i=>D3r(t,i)},flatten:{value:i=>I3r(t,i)},addIssue:{value:i=>{t.issues.push(i),t.message=JSON.stringify(t.issues,k9e,2)}},addIssues:{value:i=>{t.issues.push(...i),t.message=JSON.stringify(t.issues,k9e,2)}},isEmpty:{get(){return t.issues.length===0}}})},Dw=ys("ZodError",z6r,{Parent:Error}),U6r=oze(Dw),V6r=aze(Dw),J6r=Jye(Dw),W6r=Wye(Dw),H6r=O3r(Dw),G6r=F3r(Dw),Q6r=R3r(Dw),K6r=M3r(Dw),Y6r=L3r(Dw),X6r=j3r(Dw),Z6r=B3r(Dw),eNr=$3r(Dw),Cm=ys("ZodType",(t,r)=>(H_.init(t,r),Object.assign(t["~standard"],{jsonSchema:{input:fhe(t,"input"),output:fhe(t,"output")}}),t.toJSONSchema=h6r(t,{}),t.def=r,t.type=r.type,Object.defineProperty(t,"_def",{value:r}),t.check=(...i)=>t.clone(G8(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)=>Q8(t,i,a),t.brand=()=>t,t.register=((i,a)=>(i.add(t,a),t)),t.parse=(i,a)=>U6r(t,i,a,{callee:t.parse}),t.safeParse=(i,a)=>J6r(t,i,a),t.parseAsync=async(i,a)=>V6r(t,i,a,{callee:t.parseAsync}),t.safeParseAsync=async(i,a)=>W6r(t,i,a),t.spa=t.safeParseAsync,t.encode=(i,a)=>H6r(t,i,a),t.decode=(i,a)=>G6r(t,i,a),t.encodeAsync=async(i,a)=>Q6r(t,i,a),t.decodeAsync=async(i,a)=>K6r(t,i,a),t.safeEncode=(i,a)=>Y6r(t,i,a),t.safeDecode=(i,a)=>X6r(t,i,a),t.safeEncodeAsync=async(i,a)=>Z6r(t,i,a),t.safeDecodeAsync=async(i,a)=>eNr(t,i,a),t.refine=(i,a)=>t.check(HNr(i,a)),t.superRefine=i=>t.check(GNr(i)),t.overwrite=i=>t.check(eU(i)),t.optional=()=>Cbt(t),t.exactOptional=()=>FNr(t),t.nullable=()=>Ebt(t),t.nullish=()=>Cbt(Ebt(t)),t.nonoptional=i=>$Nr(t,i),t.array=()=>o_(t),t.or=i=>bee([t,i]),t.and=i=>vDt(t,i),t.transform=i=>P9e(t,bDt(i)),t.default=i=>LNr(t,i),t.prefault=i=>BNr(t,i),t.catch=i=>zNr(t,i),t.pipe=i=>P9e(t,i),t.readonly=()=>JNr(t),t.describe=i=>{const a=t.clone();return $Y.add(a,{description:i}),a},Object.defineProperty(t,"description",{get(){return $Y.get(t)?.description},configurable:!0}),t.meta=(...i)=>{if(i.length===0)return $Y.get(t);const a=t.clone();return $Y.add(a,i[0]),a},t.isOptional=()=>t.safeParse(void 0).success,t.isNullable=()=>t.safeParse(null).success,t.apply=i=>i(t),t)),hDt=ys("_ZodString",(t,r)=>{cze.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(a,l,d)=>HIt(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(e6r(...a)),t.includes=(...a)=>t.check(n6r(...a)),t.startsWith=(...a)=>t.check(i6r(...a)),t.endsWith=(...a)=>t.check(s6r(...a)),t.min=(...a)=>t.check(ahe(...a)),t.max=(...a)=>t.check(JIt(...a)),t.length=(...a)=>t.check(WIt(...a)),t.nonempty=(...a)=>t.check(ahe(1,...a)),t.lowercase=a=>t.check(t6r(a)),t.uppercase=a=>t.check(r6r(a)),t.trim=()=>t.check(a6r()),t.normalize=(...a)=>t.check(o6r(...a)),t.toLowerCase=()=>t.check(c6r()),t.toUpperCase=()=>t.check(l6r()),t.slugify=()=>t.check(u6r())}),tNr=ys("ZodString",(t,r)=>{cze.init(t,r),hDt.init(t,r),t.email=i=>t.check(w4r(rNr,i)),t.url=i=>t.check(I4r(nNr,i)),t.jwt=i=>t.check(V4r(yNr,i)),t.emoji=i=>t.check(D4r(iNr,i)),t.guid=i=>t.check(hbt(Abt,i)),t.uuid=i=>t.check(C4r(Ipe,i)),t.uuidv4=i=>t.check(E4r(Ipe,i)),t.uuidv6=i=>t.check(T4r(Ipe,i)),t.uuidv7=i=>t.check(k4r(Ipe,i)),t.nanoid=i=>t.check(P4r(sNr,i)),t.guid=i=>t.check(hbt(Abt,i)),t.cuid=i=>t.check(N4r(oNr,i)),t.cuid2=i=>t.check(O4r(aNr,i)),t.ulid=i=>t.check(F4r(cNr,i)),t.base64=i=>t.check(q4r(mNr,i)),t.base64url=i=>t.check(z4r(hNr,i)),t.xid=i=>t.check(R4r(lNr,i)),t.ksuid=i=>t.check(M4r(uNr,i)),t.ipv4=i=>t.check(L4r(fNr,i)),t.ipv6=i=>t.check(j4r(dNr,i)),t.cidrv4=i=>t.check(B4r(pNr,i)),t.cidrv6=i=>t.check($4r(_Nr,i)),t.e164=i=>t.check(U4r(gNr,i)),t.datetime=i=>t.check(R6r(i)),t.date=i=>t.check(L6r(i)),t.time=i=>t.check(B6r(i)),t.duration=i=>t.check(q6r(i))});function Ss(t){return x4r(tNr,t)}const gh=ys("ZodStringFormat",(t,r)=>{jm.init(t,r),hDt.init(t,r)}),rNr=ys("ZodEmail",(t,r)=>{kPr.init(t,r),gh.init(t,r)}),Abt=ys("ZodGUID",(t,r)=>{EPr.init(t,r),gh.init(t,r)}),Ipe=ys("ZodUUID",(t,r)=>{TPr.init(t,r),gh.init(t,r)}),nNr=ys("ZodURL",(t,r)=>{IPr.init(t,r),gh.init(t,r)}),iNr=ys("ZodEmoji",(t,r)=>{DPr.init(t,r),gh.init(t,r)}),sNr=ys("ZodNanoID",(t,r)=>{PPr.init(t,r),gh.init(t,r)}),oNr=ys("ZodCUID",(t,r)=>{NPr.init(t,r),gh.init(t,r)}),aNr=ys("ZodCUID2",(t,r)=>{OPr.init(t,r),gh.init(t,r)}),cNr=ys("ZodULID",(t,r)=>{FPr.init(t,r),gh.init(t,r)}),lNr=ys("ZodXID",(t,r)=>{RPr.init(t,r),gh.init(t,r)}),uNr=ys("ZodKSUID",(t,r)=>{MPr.init(t,r),gh.init(t,r)}),fNr=ys("ZodIPv4",(t,r)=>{qPr.init(t,r),gh.init(t,r)}),dNr=ys("ZodIPv6",(t,r)=>{zPr.init(t,r),gh.init(t,r)}),pNr=ys("ZodCIDRv4",(t,r)=>{UPr.init(t,r),gh.init(t,r)}),_Nr=ys("ZodCIDRv6",(t,r)=>{VPr.init(t,r),gh.init(t,r)}),mNr=ys("ZodBase64",(t,r)=>{JPr.init(t,r),gh.init(t,r)}),hNr=ys("ZodBase64URL",(t,r)=>{HPr.init(t,r),gh.init(t,r)}),gNr=ys("ZodE164",(t,r)=>{GPr.init(t,r),gh.init(t,r)}),yNr=ys("ZodJWT",(t,r)=>{KPr.init(t,r),gh.init(t,r)}),gDt=ys("ZodNumber",(t,r)=>{$It.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(a,l,d)=>GIt(t,a,l),t.gt=(a,l)=>t.check(ybt(a,l)),t.gte=(a,l)=>t.check(AFe(a,l)),t.min=(a,l)=>t.check(AFe(a,l)),t.lt=(a,l)=>t.check(gbt(a,l)),t.lte=(a,l)=>t.check(bFe(a,l)),t.max=(a,l)=>t.check(bFe(a,l)),t.int=a=>t.check(Sbt(a)),t.safe=a=>t.check(Sbt(a)),t.positive=a=>t.check(ybt(0,a)),t.nonnegative=a=>t.check(AFe(0,a)),t.negative=a=>t.check(gbt(0,a)),t.nonpositive=a=>t.check(bFe(0,a)),t.multipleOf=(a,l)=>t.check(vbt(a,l)),t.step=(a,l)=>t.check(vbt(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 Q4r(gDt,t)}const vNr=ys("ZodNumberFormat",(t,r)=>{YPr.init(t,r),gDt.init(t,r)});function Sbt(t){return K4r(vNr,t)}const bNr=ys("ZodBoolean",(t,r)=>{XPr.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(i,a,l)=>QIt(t,i,a)});function gv(t){return Y4r(bNr,t)}const ANr=ys("ZodUnknown",(t,r)=>{ZPr.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(i,a,l)=>YIt()});function xbt(){return X4r(ANr)}const SNr=ys("ZodNever",(t,r)=>{e4r.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(i,a,l)=>KIt(t,i,a)});function xNr(t){return Z4r(SNr,t)}const wNr=ys("ZodArray",(t,r)=>{t4r.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(i,a,l)=>rDt(t,i,a,l),t.element=r.element,t.min=(i,a)=>t.check(ahe(i,a)),t.nonempty=i=>t.check(ahe(1,i)),t.max=(i,a)=>t.check(JIt(i,a)),t.length=(i,a)=>t.check(WIt(i,a)),t.unwrap=()=>t.element});function o_(t,r){return f6r(wNr,t,r)}const CNr=ys("ZodObject",(t,r)=>{n4r.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(i,a,l)=>nDt(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:xbt()}),t.loose=()=>t.clone({...t._zod.def,catchall:xbt()}),t.strict=()=>t.clone({...t._zod.def,catchall:xNr()}),t.strip=()=>t.clone({...t._zod.def,catchall:void 0}),t.extend=i=>w3r(t,i),t.safeExtend=i=>C3r(t,i),t.merge=i=>E3r(t,i),t.pick=i=>S3r(t,i),t.omit=i=>x3r(t,i),t.partial=(...i)=>T3r(ADt,t,i[0]),t.required=(...i)=>k3r(SDt,t,i[0])});function Na(t,r){const i={type:"object",shape:t??{},...kc(r)};return new CNr(i)}const yDt=ys("ZodUnion",(t,r)=>{UIt.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(i,a,l)=>iDt(t,i,a,l),t.options=r.options});function bee(t,r){return new yDt({type:"union",options:t,...kc(r)})}const ENr=ys("ZodDiscriminatedUnion",(t,r)=>{yDt.init(t,r),i4r.init(t,r)});function TNr(t,r,i){return new ENr({type:"union",options:r,discriminator:t,...kc(i)})}const kNr=ys("ZodIntersection",(t,r)=>{s4r.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(i,a,l)=>sDt(t,i,a,l)});function vDt(t,r){return new kNr({type:"intersection",left:t,right:r})}const INr=ys("ZodTuple",(t,r)=>{o4r.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(i,a,l)=>oDt(t,i,a,l),t.rest=i=>t.clone({...t._zod.def,rest:i})});function wbt(t,r,i){const a=r instanceof H_,l=a?i:r,d=a?r:null;return new INr({type:"tuple",items:t,rest:d,...kc(l)})}const DNr=ys("ZodRecord",(t,r)=>{a4r.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(i,a,l)=>aDt(t,i,a,l),t.keyType=r.keyType,t.valueType=r.valueType});function zR(t,r,i){return new DNr({type:"record",keyType:t,valueType:r,...kc(i)})}const D9e=ys("ZodEnum",(t,r)=>{c4r.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(a,l,d)=>XIt(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 D9e({...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 D9e({...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 D9e({type:"enum",entries:i,...kc(r)})}const PNr=ys("ZodLiteral",(t,r)=>{l4r.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(i,a,l)=>ZIt(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 PNr({type:"literal",values:Array.isArray(t)?t:[t],...kc(r)})}const NNr=ys("ZodTransform",(t,r)=>{u4r.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(i,a,l)=>tDt(t,i),t._zod.parse=(i,a)=>{if(a.direction==="backward")throw new wIt(t.constructor.name);i.addIssue=d=>{if(typeof d=="string")i.issues.push(aZ(d,i.value,r));else{const _=d;_.fatal&&(_.continue=!1),_.code??(_.code="custom"),_.input??(_.input=i.value),_.inst??(_.inst=t),i.issues.push(aZ(_))}};const l=r.transform(i.value,i);return l instanceof Promise?l.then(d=>(i.value=d,i)):(i.value=l,i)}});function bDt(t){return new NNr({type:"transform",transform:t})}const ADt=ys("ZodOptional",(t,r)=>{VIt.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(i,a,l)=>lze(t,i,a,l),t.unwrap=()=>t._zod.def.innerType});function Cbt(t){return new ADt({type:"optional",innerType:t})}const ONr=ys("ZodExactOptional",(t,r)=>{f4r.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(i,a,l)=>lze(t,i,a,l),t.unwrap=()=>t._zod.def.innerType});function FNr(t){return new ONr({type:"optional",innerType:t})}const RNr=ys("ZodNullable",(t,r)=>{d4r.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(i,a,l)=>cDt(t,i,a,l),t.unwrap=()=>t._zod.def.innerType});function Ebt(t){return new RNr({type:"nullable",innerType:t})}const MNr=ys("ZodDefault",(t,r)=>{p4r.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(i,a,l)=>uDt(t,i,a,l),t.unwrap=()=>t._zod.def.innerType,t.removeDefault=t.unwrap});function LNr(t,r){return new MNr({type:"default",innerType:t,get defaultValue(){return typeof r=="function"?r():kIt(r)}})}const jNr=ys("ZodPrefault",(t,r)=>{_4r.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(i,a,l)=>fDt(t,i,a,l),t.unwrap=()=>t._zod.def.innerType});function BNr(t,r){return new jNr({type:"prefault",innerType:t,get defaultValue(){return typeof r=="function"?r():kIt(r)}})}const SDt=ys("ZodNonOptional",(t,r)=>{m4r.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 $Nr(t,r){return new SDt({type:"nonoptional",innerType:t,...kc(r)})}const qNr=ys("ZodCatch",(t,r)=>{h4r.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(i,a,l)=>dDt(t,i,a,l),t.unwrap=()=>t._zod.def.innerType,t.removeCatch=t.unwrap});function zNr(t,r){return new qNr({type:"catch",innerType:t,catchValue:typeof r=="function"?r:()=>r})}const UNr=ys("ZodPipe",(t,r)=>{g4r.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(i,a,l)=>pDt(t,i,a,l),t.in=r.in,t.out=r.out});function P9e(t,r){return new UNr({type:"pipe",in:t,out:r})}const VNr=ys("ZodReadonly",(t,r)=>{y4r.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(i,a,l)=>_Dt(t,i,a,l),t.unwrap=()=>t._zod.def.innerType});function JNr(t){return new VNr({type:"readonly",innerType:t})}const WNr=ys("ZodLazy",(t,r)=>{v4r.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(i,a,l)=>mDt(t,i,a,l),t.unwrap=()=>t._zod.def.getter()});function uDn(t){return new WNr({type:"lazy",getter:t})}const uze=ys("ZodCustom",(t,r)=>{b4r.init(t,r),Cm.init(t,r),t._zod.processJSONSchema=(i,a,l)=>eDt(t,i)});function kR(t,r){return d6r(uze,t??(()=>!0),r)}function HNr(t,r={}){return p6r(uze,t,r)}function GNr(t){return _6r(t)}function fDn(t,r={}){const i=new uze({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 QNr(t,r){return P9e(bDt(t),r)}const Tbt={custom:"custom"},kbt=jd(["mock","live"]),KNr=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()}),YNr=Na({included:Tu().nonnegative(),purchased:Tu().nonnegative(),used:Tu().nonnegative(),reserved:Tu().nonnegative(),remaining:Tu().nonnegative(),resetsAt:Ss().datetime().optional(),purchasedExpiresAt:Ss().datetime().optional()}),XNr=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()}),ZNr=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()}),e8r=Na({id:Ss().min(1),email:Ss().email(),name:Ss().min(1).optional()}),t8r=Na({name:Ss().min(1),verified:gv(),enrollmentMode:jd(["manual_invitation","automatic_invitation","automatic_suggestion","enterprise_sso"])}),r8r=Na({id:Ss().min(1),name:Ss().min(1),slug:Ss().min(1).optional(),role:Ss().min(1),domains:o_(t8r).max(50)}),n8r=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 i8r=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:zR(Ss().min(1),Na({name:Ss().min(1),credits:Tu().int().positive(),expiresInDays:Tu().int().positive().optional()}))}),s8r=TNr("authenticated",[Na({authenticated:Ry(!1),backend:kbt}),Na({authenticated:Ry(!0),backend:kbt,user:e8r,organizations:o_(r8r).max(100).optional(),plan:KNr,credits:YNr,spendPolicy:XNr,alerts:o_(ZNr).max(100).optional(),entitlements:Na({generation:gv(),dailyJobs:Tu().int().positive().optional()})})]),o8r=jd(["auto","mock","managed","byok"]),xDt=jd(["fal","tripo","worldlabs","openrouter"]),a8r=Na({enabled:gv(),provider:Ry("openrouter"),model:Ss().trim().min(1).max(256)}),c8r=jd(["environment","system","session","none"]),l8r=Na({provider:xDt,label:Ss().min(1),environmentVariable:Ss().min(1),configured:gv(),source:c8r,editable:gv(),persistence:jd(["system","session"]),maskedKey:Ss().min(1).optional(),problem:Ss().min(1).optional()}),u8r=Na({provider:xDt,ok:Ry(!0),testedAt:Ss().datetime()});function f8r(t){return{routes:{mock:!0,managed:t.routes.managed,byok:t.routes.byok,byokProviders:[...t.routes.byokProviders]},preferredRoute:t.preferredRoute}}const Gye=vDt(s8r,Na({accountEnvironment:jd(["test-mock","development-twin","production"]),routes:Na({mock:Ry(!0),managed:gv(),byok:gv(),byokProviders:o_(Ss().min(1))}),preferredRoute:o8r,providerCredentials:o_(l8r),codingInference:a8r}));function d8r(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(d8r(r,i))}function tU(t,r){if(!t.ok)throw new Error(`${r} (${t.status}).`);np(t,r)}async function Eg(t,r){return tU(t,r),await t.json()}const Ibt="vgai.collaboration.participant.v1",p8r="vgai.collaboration.remote-share.v1",N9e=globalThis.__VGAI_EDITOR_PRESENCE_BOOTSTRAP__;function _8r(){if(N9e?.participantId)return N9e.participantId;const t=globalThis.crypto?.randomUUID?.()??`participant-${Date.now()}`;try{const r=globalThis.localStorage?.getItem(Ibt);if(r)return r;globalThis.localStorage?.setItem(Ibt,t)}catch{}return t}const wDt=_8r(),fze=(()=>{try{return globalThis.localStorage?.getItem(p8r)==="1"}catch{return!1}})(),m8r=N9e?.displayName||"Local editor";let O9e=0;function CDt(t){Number.isInteger(t)&&t>=O9e&&(O9e=t)}function yw(){return{participantId:wDt,expectedRevision:O9e}}const h8r={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 nz=h8r,EDt=0,F9e=null;const R9e=new Set;function UR(t,r=null){if(!(F9e===r&&JSON.stringify(nz)===JSON.stringify(t))){nz=t,F9e=r,EDt++;for(const i of R9e)i()}}async function TDt(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 Gye.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 TDt(a,`${r} ${t} failed`);return UR(l),l}function dze(){return nz}function pze(){return f8r(nz)}function T8(){return EDt}function Dpe(){return F9e}function Qye(t){return R9e.add(t),()=>R9e.delete(t)}async function Dbt(){try{const t=await TDt(await fetch("/__editor/account"),"Account read failed");return UR(t),t}catch(t){throw UR(nz,t instanceof Error?t.message:String(t)),t}}const g8r=t=>IE("/__editor/account/mock-session","POST",{email:t}),y8r=t=>IE("/__editor/account/twin-session","POST",{email:t}),v8r=()=>IE("/__editor/account/session","DELETE"),b8r=t=>IE("/__editor/account/spend-policy","PUT",t),A8r=()=>IE("/__editor/account/alerts/read","POST"),S8r=t=>IE("/__editor/account/execution-route","PUT",{route:t}),x8r=t=>IE("/__editor/account/coding-inference","PUT",t);async function w8r(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 C8r=(t,r)=>IE(`/__editor/account/provider-credentials/${encodeURIComponent(t)}`,"PUT",{key:r}),E8r=t=>IE(`/__editor/account/provider-credentials/${encodeURIComponent(t)}`,"DELETE");async function T8r(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 u8r.parse(i)}const Pbt=t=>IE("/__editor/account/plan","PUT",{action:t});async function kDt(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 UR(Gye.parse(a.account)),{...typeof a.checkoutUrl=="string"?{checkoutUrl:a.checkoutUrl}:{},mock:a.mock===!0}}const k8r=t=>kDt("/__editor/account/checkout",{plan:t}),I8r=t=>kDt("/__editor/account/credits",{packId:t});async function D8r(){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 n8r.array().parse(r.entries??[])}async function P8r(){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 i8r.parse(r)}async function N8r(){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 O8r(){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 F8r(){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 R8r(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 UR(Gye.parse(i.account)),!0}async function M8r(){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 L8r(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 UR(Gye.parse(i.account)),!0}function j8r(){if(fze)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=>UR(nz,i instanceof Error?i.message:String(i))):Dbt().catch(()=>{});const r=window.setInterval(()=>void Dbt().catch(()=>{}),3e4);return()=>window.clearInterval(r)}const B8r={"source-prop":!0,"source-structure":!0,"construction-literal":!0,"physics-binding":!0,"data-record":!0,"live-only":!0},$8r=Object.keys(B8r),q8r={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},z8r=Object.keys(q8r),dhe={claim:0,shape:1,operation:2,effect:3,"round-trip":4};function U8r(t,r){return dhe[t]>=dhe[r]}function phe(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||dhe[_.stage]>=dhe[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}:U8r(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 V8r{#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 phe({...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 J8r(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 SFe(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(J8r({seam:_,subject:t.subject,epoch:t.epoch,value:g,optional:d.optional,kind:d.kind}))}return r}function Nbt(t){const r=phe(t);if(r.state==="absent"||r.state==="failed"||!t.shape)return r;for(const[i,a]of Object.entries(t.shape)){const l=phe({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 Ppe=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"}}),Obt=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"}}),W8r=jy()({get:{optional:!1,kind:"function",required:"operation"},set:{optional:!1,kind:"function",required:"effect"},resolve:{optional:!0,kind:"function",required:"operation"}}),H8r=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"}}),G8r=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"}}),Q8r=jy()({get:{optional:!1,kind:"function",required:"operation"},entries:{optional:!0,kind:"function",required:"operation"}}),K8r=jy()({links:{optional:!1,kind:"function",required:"operation"}}),Y8r=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"}}),X8r=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"}}),Z8r=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"}}),eOr=jy()({pick:{optional:!1,kind:"function",required:"operation"},candidates:{optional:!0,kind:"function",required:"operation"}}),tOr=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"}}),rOr=jy()({accepts:{optional:!1,kind:"function",required:"operation"},drop:{optional:!1,kind:"function",required:"round-trip"}}),nOr=jy()({rect:{optional:!1,kind:"function",required:"operation"},contextRects:{optional:!0,kind:"function",required:"operation"},emptyContainers:{optional:!0,kind:"function",required:"operation"}}),iOr=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"}}),sOr=jy()({get:{optional:!1,kind:"function",required:"operation"},set:{optional:!1,kind:"function",required:"effect"}}),oOr=jy()({backgroundChainAt:{optional:!1,kind:"function",required:"operation"}}),aOr=jy()({resolve:{optional:!1,kind:"function",required:"operation"}}),cOr=jy()({layers:{optional:!1,kind:"function",required:"operation"},preview:{optional:!1,kind:"function",required:"effect"},commit:{optional:!1,kind:"function",required:"round-trip"}}),Fbt={selection:W8r,transforms:H8r,inspector:G8r,assetSubject:Q8r,related:K8r,instances:Y8r,structure:X8r,persistence:Z8r,pickable:eOr,rects:nOr,boxEdit:iOr,text:sOr,colorSample:oOr,stories:tOr,truth:aOr,spatialHandles:cOr,assetDrop:rOr},IDt=new V8r;function lOr(t){IDt.record(t)}const Rbt=new WeakMap;let uOr=1;function fOr(t){const r=Rbt.get(t);if(r)return r;const i=`system-${uOr++}`;return Rbt.set(t,i),i}let p9={},_ze=null,DDt=null;const _he=new Set,mhe=new Set,M9e=new Set;let mze=0;function dOr(){for(const t of M9e)t()}function pOr(t){if(t!==ODt())for(const r of _he)r()}function _Or(t,r){const i=RDt();if(!(t===FDt()&&r.length===i.length&&r.every((a,l)=>a===i[l]))){mze++;for(const a of mhe)a()}}const cI=new Map;let L_e=null;const L9e=new Set,PDt="";function cZ(){return L_e!==null&&cI.has(L_e)?L_e:cI.keys().next().value??null}function NDt(){for(const t of L9e)t()}function mOr(t){const r=cZ();if(L_e=t,r!==cZ()){NDt(),mze++;for(const i of _he)i();for(const i of mhe)i()}}function hOr(t){return L9e.add(t),()=>L9e.delete(t)}function hze(){const t=cZ();return(t===null?void 0:cI.get(t))??p9}function gOr(t,r=PDt){const i=cZ(),a=ODt(),l=FDt(),d=RDt();cI.delete(r),p9=cI.values().next().value??{},pOr(a),_Or(l,d),dOr(),i!==cZ()&&NDt()}function yOr(){for(const t of[...cI.keys()])gOr(null,t);mOr(null)}function vOr(t){return M9e.add(t),()=>M9e.delete(t)}function bOr(){return[...cI.keys()]}function Mbt(t){const r=t.filter(l=>l!==PDt),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 Lbt extends Error{instances;constructor(r,i){super(r),this.name="InstanceResolutionError",this.instances=i}}function AOr(t){const r=bOr();if(t!==void 0){const i=cI.get(t);if(i)return i;throw new Lbt(r.length===0?`no instance "${t}" — no game is mounted`:`no instance "${t}" — live: ${Mbt(r)}`,r)}if(r.length===1)return cI.get(r[0]);if(r.length===0)return p9;throw new Lbt(`${r.length} instances are live (${Mbt(r)}) — name one in your program (\`game.instance(id)\`, or \`await game.instances()\` for handles); refusing to guess`,r)}function SOr(){return p9.camera??null}function ODt(){return p9.networking??DDt??null}function xOr(){return hze().networking??DDt??null}function wOr(t){return _he.add(t),()=>_he.delete(t)}function FDt(){return p9.audio??_ze}function COr(){return hze().audio??_ze}function EOr(t){return mhe.add(t),()=>mhe.delete(t)}function TOr(){return mze}function RDt(){const t=new Set;for(const r of cI.values())r.audio&&t.add(r.audio);return t.size,[...t]}function kOr(){return p9.renderDebug??null}const jbt=new Set;function Kye(){return null}function Yye(t){jbt.add(t);const r=hOr(t);return()=>{jbt.delete(t),r()}}function k8(){const t=Kye();return t?`play:${t.instanceId}`:"stopped"}const vX=new Map,K$=new Map,j_e=new Map;let MDt=0;const j9e=new Set;function Bbt(){MDt++;for(const t of j9e)t()}function dDn(t){return vX.set(t.documentId,t),Bbt(),()=>{vX.get(t.documentId)===t&&(vX.delete(t.documentId),Bbt())}}function Pw(t){return vX.get(t)??null}function pDn(t,r){return j_e.set(t,r),()=>{j_e.get(t)===r&&j_e.delete(t)}}async function IOr(t){await j_e.get(t)?.()}function DOr(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 POr(t){return(K$.get(t)??0)>0}function NOr(){return[...vX.values()]}function Xye(t){return j9e.add(t),()=>j9e.delete(t)}function I8(){return MDt}function Zye(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 J7=[],OOr=0,LDt=0;const B9e=new Set;function $bt(){LDt++;for(const t of B9e)t()}function jDt(t){return B9e.add(t),()=>{B9e.delete(t)}}function qbt(){return LDt}function iP(t){if(J7.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:OOr++};return J7=[...J7,r],$bt(),()=>{J7.includes(r)&&(J7=J7.filter(i=>i!==r),$bt())}}function $9e(t){const r=i=>[...J7].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 B_e=null,BDt=0;const q9e=new Set;function zbt(){BDt++;for(const t of q9e)t()}function $Dt(t){return q9e.add(t),()=>q9e.delete(t)}function z9e(){return BDt}function gze(){return B_e}function FOr(t){const r=Symbol(t.documentId);return B_e={...t,token:r},zbt(),()=>{B_e?.token===r&&(B_e=null,zbt())}}function ROr(){Xe.useSyncExternalStore($Dt,z9e);const t=gze();return t?.status?z.jsx("span",{className:"vgai-status-copy","data-testid":"status-asset-editor","data-status-tone":"muted",children:t.status}):null}const MOr=Zye();function LOr(){MOr.ensure(t=>{t(iP({id:"asset-editor-status",name:"Asset editor",align:"left",order:40,Content:ROr}))})}LOr();let Dq=null,qDt=0;const U9e=new Set;function Ubt(){qDt+=1;for(const t of U9e)t()}function jOr(t){return U9e.add(t),()=>{U9e.delete(t)}}function Vbt(){return qDt}function BOr(t,r){const i=Symbol(t);return Dq={documentId:t,readSubject:r,token:i},Ubt(),()=>{Dq?.token===i&&(Dq=null,Ubt())}}function V9e(){return Dq===null?null:{documentId:Dq.documentId,subject:Dq.readSubject()}}const D8=new Map,J9e=new Map;function zDt(){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"&&zDt()});let Wu=null,yze=null;function UDt(){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 $Or(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 qOr(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 zOr(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=qOr(t.stories),N=t.boardBuildStartedAtMs===null?"switch-back":"first-open",j=UOr({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:yze}}function TA(t,r){const i=Math.max(0,r);return{name:t,ms:i,busyMs:i,waitMs:0,kind:"cpu"}}function Npe(t,r){const i=Math.max(0,r);return{name:t,ms:i,busyMs:0,waitMs:i,kind:"idle"}}function Jbt(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 UOr(t){return[Npe("workspace-sync",t.workspaceSyncMs),Npe("reveal-schedule",t.revealScheduleMs),Jbt("component-index",t.componentIndexMs,t.componentIndexBusyMs,t.componentIndexWaitMs>0||t.componentIndexMs===0?t.componentIndexWaitMs:t.componentIndexMs),TA("candidate-collect",t.candidateCollectMs),Jbt("story-mounts",t.storyMountTotalMs,t.storyMountBusyMs,t.storyMountWaitMs),TA("bounds",t.boundsMs),TA("layout",t.layoutMs),TA("assemble",t.assembleMs),Npe("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),Npe("raf-wait",t.rafWaitMs),TA("first-render",t.firstRenderMs)]}function _Dn(t,r=Date.now()){const i=(J9e.get(t)??0)+1;J9e.set(t,i);const a={documentId:t,activation:i,firstFrameAtMs:r},l=Wu;if(l&&l.documentId===t){const d={...a,breakdown:zOr(l,r)};return Wu=null,D8.set(t,d),Hbt(),Wbt(),d}return D8.set(t,a),Hbt(),Wbt(),a}let W9e=new Set;const H9e=new Set;function Wbt(){zDt();for(const t of H9e)t()}function VOr(t){return H9e.add(t),()=>H9e.delete(t)}function Hbt(){D8.size!==0&&VDt()}function VDt(){const t=W9e;W9e=new Set;for(const r of t)r()}let Gbt=!1;function JOr(){Gbt||typeof document>"u"||(Gbt=!0,document.addEventListener("visibilitychange",()=>{document.hidden&&VDt()}))}function e0e(){return D8.size>0||typeof document<"u"&&document.hidden?Promise.resolve():(JOr(),new Promise(t=>W9e.add(t)))}function WOr(){return[...D8.values()]}function HOr(t){UDt()&&(Wu=$Or(t,Date.now(),{}))}function mDn(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 hDn(t){!Wu||Wu.documentId!==t||Wu.reactActiveAtMs===null&&(Wu.reactActiveAtMs=Date.now())}function gDn(t){!Wu||Wu.documentId!==t||Wu.rafResumeAtMs===null&&(Wu.rafResumeAtMs=Date.now())}function yDn(t){!Wu||Wu.documentId!==t||Wu.firstRenderStartedAtMs===null&&(Wu.firstRenderStartedAtMs=Date.now())}function vDn(){Wu&&(Wu.constructStartedAtMs=Date.now())}function bDn(){Wu&&(Wu.viewportReadyAtMs=Date.now())}function ADn(){return Wu?.documentId??null}function GOr(t){UDt()&&(yze=t)}function QOr(){D8.clear(),J9e.clear(),Wu=null,yze=null}const KOr=["scene","game","world","story","asset","behavior","generation","content-browser","project-tool","tool-contribution","document"];let V_=[],KN=null,OA=null,lZ=null,iz=null;function Qbt(t){queueMicrotask(()=>{iz===t&&V_.some(r=>r.descriptor.id===t)&&(iz=null,Sb(t))})}let JDt=0;const G9e=new Set,xFe=new Set,vze=new Map,IR=new Map;function lI(){JDt++;for(const t of G9e)t()}function Aw(t){return G9e.add(t),()=>{G9e.delete(t)}}function Ab(){return JDt}function FA(){return V_}function I_(){return OA}function Q9e(){return lZ}function YOr(t,r){Sb(t)&&lZ!==r&&(lZ=r,lI())}function AE(){return V_.find(t=>t.descriptor.id===OA)??null}function uZ(t){if(t===OA)return;t&&HOr(t);const r=V_.find(a=>a.descriptor.id===OA);OA=t,lZ=null,r?.descriptor.onDeactivate?.(r.descriptor.id);const i=V_.find(a=>a.descriptor.id===t);i?.descriptor.onActivate?.(i.descriptor.id)}function XOr(t,r,i,a){if(r){!i&&a&&KN===t&&(KN=null);return}i&&(KN&&K8(KN),KN=t)}function qP(t,r={}){const i=iz===t.id,a=i||r.activate!==!1,l=V_.find(_=>_.descriptor.id===t.id);if(XOr(t.id,!!l,r.preview===!0,a),!l)return V_=[...V_,{descriptor:t,dirty:!1,title:t.title}],!t.area&&(a||OA===null)&&uZ(t.id),i&&Qbt(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&&(uZ(t.id),d=!0),d&&lI(),i&&Qbt(t.id),t.id}function Sb(t){return V_.some(r=>r.descriptor.id===t)?(OA!==t&&(uZ(t),lI()),!0):!1}function ZOr(t){if(Sb(t)){iz=null;return}iz=t}function K8(t,r={}){if(xFe.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;xFe.add(t);try{if(OA===t){const d=i>0?V_[i-1]:V_[i+1]??null;uZ(d?d.descriptor.id:null)}return V_=V_.filter(d=>d.descriptor.id!==t),KN===t&&(KN=null),vze.delete(t),IR.delete(t),a.descriptor.onDispose?.(t),lI(),!0}finally{xFe.delete(t)}}function WDt(){if(V_.length===0&&OA===null)return;const t=V_;uZ(null),V_=[],lZ=null,KN=null,vze.clear(),IR.clear(),iz=null;for(const r of t)r.descriptor.onDispose?.(r.descriptor.id);lI()}function e5r(t,r){return V_.some(i=>i.descriptor.id===t)?(IR.set(t,r),lI(),()=>{IR.get(t)===r&&(IR.delete(t),lI())}):()=>{}}function SDn(t){IR.has(t)&&lI()}async function t5r(t){if(!V_.some(i=>i.descriptor.id===t))return null;const r=vze.get(t);if(!r)return null;try{return await r()}catch{return!1}}function r5r(){return OA?t5r(OA):Promise.resolve(null)}function HDt(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 bze(t){const r=V_.find(a=>a.descriptor.id===t),i=IR.get(t)??r?.descriptor.selection;if(!i)return null;try{return i()}catch{return null}}function t0e(){return OA?bze(OA):null}const n5r={adapter:null,nodeId:null};function i5r(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 Aze({documentId:t,active:r=!0,type:i,title:a,sections:l,status:d,selection:_}){Xe.useEffect(()=>{if(r)return FOr({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 e5r(t,()=>g.current?.()??n5r)},[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=i5r(b);return Xe.useEffect(()=>{if(r)return BOr(t,()=>S.current)},[r,t,k]),null}function s5r({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(Aze,{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 o5r=Object.freeze(Object.defineProperty({__proto__:null,AssetEditorShell:s5r,AssetEditorSubject:Aze},Symbol.toStringTag,{value:"Module"})),a5r=Xe.lazy(async()=>({default:(await la(()=>import("./ToolObject3DPreview-DGcT5dDK.js"),__vite__mapDeps([38,1,2,39,3,4,8,9,10,6,40,41,11]))).ToolObject3DPreview})),c5r=Xe.lazy(async()=>({default:(await la(()=>import("./StageHost-B4P-uvV9.js").then(r=>r.c),__vite__mapDeps([42,1,2,3,4,8,9,6,10,7,40,14,43,41]))).ToolObject3DAuthoring}));function l5r(t){return z.jsx(Xe.Suspense,{fallback:z.jsx("div",{style:{minHeight:240},children:"Loading 3D preview…"}),children:z.jsx(a5r,{...t})})}function u5r(t){return Xe.useEffect(()=>DOr(t.documentId),[t.documentId]),z.jsx(Xe.Suspense,{fallback:z.jsx("div",{style:{minHeight:240},children:"Loading 3D authoring surface…"}),children:z.jsx(c5r,{...t})})}function f5r(t){return z.jsx(Aze,{...t})}const Sze=Object.freeze({AssetDocument:f5r,Object3DPreview:l5r,Object3DAuthoring:u5r}),Kbt=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)"}}),d5r=["classic","glass"],p5r=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 hhe=null;const ghe=new Set;function _5r(){return hhe??=[...p5r,...[...Pq.values()].map(({id:t,title:r,description:i})=>({id:t,title:r,description:i}))],hhe}function m5r(t){return ghe.add(t),()=>ghe.delete(t)}function h5r(t){if(r0e(t.id))throw new Error(`registerContributedMaterial: material "${t.id}" is already registered.`);Pq.set(t.id,t),hhe=null;for(const r of ghe)r();return()=>{if(Pq.get(t.id)===t){Pq.delete(t.id),hhe=null;for(const r of ghe)r()}}}function r0e(t){return typeof t=="string"&&(d5r.includes(t)||Pq.has(t))}function g5r(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??Kbt.shape,elevation:l?.elevation??Kbt.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 y5r={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch",baseline:"baseline"},v5r={start:"flex-start",center:"center",end:"flex-end",between:"space-between",around:"space-around",evenly:"space-evenly"};function Ope(t){return t===0?"0px":t===void 0?void 0:`var(--vgai-space-${t})`}function GDt({gap:t,align:r,justify:i,padding:a,paddingX:l,paddingY:d,style:_}){return{gap:Ope(t),alignItems:r?y5r[r]:void 0,justifyContent:i?v5r[i]:void 0,padding:Ope(a),paddingInline:Ope(l),paddingBlock:Ope(d),..._}}function n0e(t,r){return r?`${t} ${r}`:t}function i0e({className:t,...r}){return z.jsx("div",{...r,className:n0e("vgai-stack",t),style:GDt(r)})}function Nq({className:t,...r}){return z.jsx("div",{...r,className:n0e("vgai-inline",t),style:GDt(r)})}function b5r({orientation:t="horizontal",className:r,...i}){return z.jsx("div",{...i,"aria-hidden":"true","data-orientation":t,className:n0e("vgai-divider",r)})}function A5r({children:t,className:r,...i}){return z.jsx(Nq,{...i,className:n0e("vgai-actions",r),gap:2,align:"center",children:t})}function QDt(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:QDt("vgai-text",_)})});function $_e({className:t,...r}){return z.jsx("kbd",{...r,className:QDt("vgai-keycap",t)})}function xze(t,r){return r?`${t} ${r}`:t}function K9e({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:xze("vgai-dialog",l)})});return _?vS.createPortal(g,_):g}function Y9e({titleId:t,title:r,description:i}){return z.jsxs(i0e,{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 KDt({className:t,...r}){return z.jsx(i0e,{...r,className:xze("vgai-dialog-body",t)})}function X9e({children:t,className:r,...i}){return z.jsx(A5r,{...i,className:xze("vgai-dialog-footer",r),children:t})}function YDt(t,r){return r?`${t} ${r}`:t}function S5r({className:t,...r}){return z.jsx("div",{...r,className:YDt("vgai-field-group",t)})}function q_e({label:t,htmlFor:r,hint:i,compact:a=!1,className:l,children:d,..._}){return z.jsxs("div",{..._,"data-compact":a||void 0,className:YDt("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 x5r({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 s0e(t,r){return r?`${t} ${r}`:t}function w5r({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:s0e("vgai-surface",a)})}function C5r({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:s0e("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 wze=Xe.forwardRef(function({className:r,...i},a){return z.jsx("div",{ref:a,...i,className:s0e("vgai-popover",r)})});function Ybt({position:t="inside",className:r,...i}){return z.jsx("div",{...i,"aria-hidden":"true","data-position":t,className:s0e("vgai-drop-indicator",r)})}function XDt(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:XDt("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:XDt("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 Aee(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:Aee("vgai-toolbar",l)})});function Xbt({className:t,...r}){return z.jsx("div",{...r,role:"group",className:Aee("vgai-toolbar-group",t)})}function Zbt(t){return z.jsx("span",{...t,"aria-hidden":"true",className:Aee("vgai-toolbar-divider",t.className)})}function E5r({className:t,onPointerDownCapture:r,...i}){return z.jsx(NP,{...i,compact:!0,className:Aee("vgai-floating-toolbar vgai-glass-island",t),onPointerDownCapture:a=>{r?.(a),a.stopPropagation()}})}function Cze({className:t,...r}){return z.jsx("div",{...r,role:"group",className:Aee("vgai-split-button",t)})}function ZDt(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:ZDt("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:ZDt("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 e3t(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 o0e(t,r){return r?`${t} ${r}`:t}function Z9e(t){return Array.from(t.querySelectorAll('[role="menuitem"]:not(:disabled), [role="menuitemradio"]:not(:disabled), [role="menuitemcheckbox"]:not(:disabled)'))}function T5r(t){Z9e(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&&Z9e(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:o0e("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=Z9e(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:o0e("vgai-menu-item",r),onClick:b=>{l?.(b),b.defaultPrevented||d?.()}})});function Ny(t){return z.jsx("hr",{...t,className:o0e("vgai-menu-separator",t.className)})}const Eze=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:o0e("vgai-menu-trigger",r)})});function yhe({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 VR({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?e3t({...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,T5r(k))},[a,k,N]);const ee=xe=>{J.current=xe!=="outside",_(),xe==="escape"&&t.current?.focus()};return z.jsx(yhe,{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 xDn({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(VR,{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},tY={0:"#1a1a1a",1:"#242424",2:"#2c2c2c",3:"#333333",inset:"#1e1e1e"},eAt={1:"#333333",2:"#444444"},Oq={1:"#c5c8ce",2:"#9aa0a6",3:"#90959c"},k5r="#579EFF",I5r="rgba(87,158,255,0.15)",wFe={1:"#f2f6fb",2:"#d3d9e0",3:"#aab0b7"},Tze="#d8dee9",kze="rgba(216,222,233,0.18)",t3t="#FF6B6B",r3t="#e0a030",n3t="#4caf50",i3t="rgba(76,175,80,0.15)",s3t="rgba(255,107,107,0.15)",o3t="rgba(224,160,48,0.12)",a3t="rgba(255,107,107,0.06)",c3t="rgba(0,0,0,0.5)",l3t="#ff79c6",u3t="rgba(255,121,198,0.08)",f3t="#22b8d6",a0e='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',c0e='ui-monospace, "SF Mono", Monaco, "Cascadia Code", monospace',CFe={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)"},Ize={1:"var(--vgai-surface-panel)",inset:"var(--vgai-surface-inset)"},vhe={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)"},eMe="var(--vgai-danger)",U_={1:2,2:4,3:6,4:8,5:10,6:12,8:16,10:20,12:24},d3t={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:{...D5r,...t.density?.control},font:{...N5r,...t.density?.font},icon:{...P5r,...t.density?.icon},chrome:{...d3t,...t.density?.chrome}}}const D5r={compact:20,default:24,comfortable:28},EFe={resting:1,active:2},P5r={xs:9,sm:10,md:12,lg:13,xl:14,"2xl":16},N5r={xs:9,sm:10,base:11,md:12,lg:13,xl:14,"2xl":16,heading:24},z_e={regular:400,semibold:600,bold:700},Fpe={tight:1,snug:1.2,normal:1.4,relaxed:1.5},rY={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"},fZ={sm:"var(--vgai-radius-sm)"},qY={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)"},tAt={normal:"var(--vgai-leading-normal)"},O5r=["outliner","properties"],sz={id:"graphite-dark",color:{surface:{shell:tY[0],panel:tY[1],chrome:tY[2],raised:tY[3],inset:tY.inset,overlay:"rgba(36,36,36,0.94)"},boundary:{default:eAt[1],strong:eAt[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:k5r,muted:I5r},semantic:{danger:t3t,dangerMuted:s3t,dangerFaint:a3t,warning:r3t,warningMuted:o3t,success:n3t,successMuted:i3t,dynamic:l3t,dynamicMuted:u3t,instance:f3t},neutralOverlay:{hover:"rgba(255,255,255,0.08)",active:"rgba(255,255,255,0.14)"},scrim:c3t},typography:{sans:a0e,mono:c0e},shape:{small:ZN.small,medium:ZN.medium,large:ZN.large,full:ZN.full},elevation:{small:CFe.sm,medium:CFe.md,large:CFe.lg}},F5r={...sz,id:"graphite-neutral",color:{...sz.color,content:{primary:wFe[1],muted:wFe[2],dim:wFe[3],onAccent:"#101820",onBright:{primary:"#1a2330",muted:"rgba(26,35,48,0.82)",dim:"rgba(26,35,48,0.74)"}},accent:{default:Tze,muted:kze}}},R5r={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:a0e,mono:c0e},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)"}},tMe={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:Tze,muted:kze},semantic:{danger:t3t,dangerMuted:s3t,dangerFaint:a3t,warning:r3t,warningMuted:o3t,success:n3t,successMuted:i3t,dynamic:l3t,dynamicMuted:u3t,instance:f3t},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:a0e,mono:c0e},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}},M5r=(()=>{const{treatment:t,...r}=tMe;return{...r,id:"glass-dark-lite",appearance:{material:"glass",transparency:"reduced"},color:{...tMe.color,surface:{shell:"#1a1a1a",panel:"#222222",chrome:"#292929",raised:"#303030",inset:"#1d1d1d",overlay:"#202020"},scrim:c3t}}})(),rMe={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:Tze,muted:kze},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:a0e,mono:c0e},shape:fh.shape,elevation:fh.elevation,treatment:fh.treatment},L5r=(()=>{const{treatment:t,...r}=rMe;return{...r,id:"liquid-glass-lite",appearance:{material:"glass",transparency:"reduced"},color:{...rMe.color,surface:fh.reducedTransparency.surface,scrim:fh.reducedTransparency.scrim}}})(),p3t={"graphite-dark":sz,"graphite-neutral":F5r,"midnight-high-contrast":R5r,"glass-dark":tMe,"glass-dark-lite":M5r,"liquid-glass":rMe,"liquid-glass-lite":L5r};function j5r(t){return typeof t=="string"&&Object.hasOwn(p3t,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 B5r(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 $5r(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 rAt(t,r){return r?"transparent":`linear-gradient(var(${t}), var(${t})), linear-gradient(var(--vgai-surface-shell), var(--vgai-surface-shell))`}function nAt(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 nMe(t){return(t?.contentFrostBlurPx??0)>0?"rgba(255,255,255,0.10)":"transparent"}function q5r(t){return t?"color-mix(in srgb, currentColor 7%, transparent)":"var(--vgai-widget-field)"}function z5r(t){return t?"color-mix(in srgb, currentColor 26%, transparent)":"var(--vgai-boundary-default)"}function U5r(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 V5r=.6,J5r=.5;function bhe(t,r){return`rgba(255,255,255,${Math.min(1,Number((t*r/V5r).toFixed(3)))})`}function _3t(t){const r=t?.edgeSpecular??0;if(r<=0)return"none";const i=t?.specularAngleDeg??120,a=l=>bhe(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 W5r(t){const r=t?.edgeSpecular??0;if(r<=0)return"none";const i=t?.specularAngleDeg??120,a=l=>bhe(l,r);return`linear-gradient(${i}deg, ${a(.16)} 0%, ${a(.05)} 24%, transparent 40%)`}function H5r(t){const r=t?.edgeSpecular??0,i=t?.thickness??0,a=[];if(r>0&&(a.push(`inset 0 1px 1px ${bhe(.28,r)}`),a.push(`inset 0 -1px 1px ${bhe(.1,r)}`)),i>0){const l=d=>`${Number((d*i/J5r).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 rU(t){return t.appearance?t.appearance.material==="glass":t.treatment!==void 0}function G5r(t){return rU(t)?"var(--vgai-surface-panel)":"color-mix(in srgb, var(--vgai-surface-panel) 90%, transparent)"}function Q5r(t){return rU(t)?t.treatment?"var(--vgai-surface-backdrop-filter)":"none":"blur(8px)"}function K5r(t){return t?"17px":"var(--vgai-radius-md)"}function Y5r(t){return t?"var(--vgai-boundary-default)":"var(--vgai-boundary-strong)"}function X5r(t){return t?"var(--vgai-shadow-lg)":"var(--vgai-shadow-sm)"}function Z5r(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 l0e(t){return rU(t)}function eFr(t){return l0e(t)?"var(--vgai-neutral-active)":"var(--vgai-accent-muted)"}function tFr(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 rFr(t){return l0e(t)?"var(--vgai-content-primary)":tFr(t.color.accent.muted)?"var(--vgai-content-on-accent)":"var(--vgai-content-primary)"}function nFr(t){return l0e(t)?"color-mix(in srgb, currentColor 30%, transparent)":"var(--vgai-accent)"}function iFr(t){return l0e(t)?"color-mix(in srgb, currentColor 76%, transparent)":"var(--vgai-accent)"}function sFr(t){return t?"var(--vgai-radius-full)":"var(--vgai-radius-sm)"}function oFr(t){return!rU(t)||!t.treatment?"var(--vgai-accent)":Z5r(t,.82)??"var(--vgai-accent)"}function aFr(t){const r=t?.edgeSpecular??0;return r<=0?"none":_3t({...t,edgeSpecular:r*.4})}function cFr(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 m3t(t){return t<=0?"none":`0 1px 2px rgba(0,0,0,${Number(t.toFixed(3))})`}function h3t(t){return m3t(t?.textShadowOpacity??0)}function lFr(t){return t.treatment?.adaptiveContent?{primary:t.color.content.onBright.primary,muted:t.color.content.onBright.muted,dim:t.color.content.onBright.dim,textShadow:m3t(t.treatment.brightTextShadowOpacity??0),frostBg:t.treatment.brightFrostBg??nMe(t.treatment)}:{primary:t.color.content.primary,muted:t.color.content.muted,dim:t.color.content.dim,textShadow:h3t(t.treatment),frostBg:nMe(t.treatment)}}function uFr(t){return t.treatment?t.treatment.adaptiveContent?"rgba(255,255,255,0.9)":dFr(t.color.surface.chrome,.9):t.color.surface.chrome}function fFr(t){return t.color.surface.panel}function dFr(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 iAt(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 pFr(t){return t.color.boundary.area??t.color.boundary.default}function _Fr(t,r){return`color-mix(in srgb, ${t} 98.4%, ${r})`}function nY(t){return`color-mix(in srgb, var(--vgai-area-emboss-mix), ${t})`}function mFr(t){const r=s_(t).chrome.areaEmboss;return r>0?`#ffffff ${r}%`:"transparent 100%"}function hFr(t){const r=lFr(t),i=rU(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":$5r(t.treatment),"--vgai-surface-sticky":rAt("--vgai-surface-chrome",i),"--vgai-surface-sticky-panel":rAt("--vgai-surface-panel",i),"--vgai-surface-sticky-backdrop-filter":"none","--vgai-surface-body-frost-filter":nAt(t.treatment),"--vgai-content-frost-filter":nAt(t.treatment),"--vgai-content-frost-bg":nMe(t.treatment),"--vgai-input-surface":q5r(i),"--vgai-input-border":z5r(i),"--vgai-input-shadow":U5r(i,_),"--vgai-structural-divider":i?"transparent":t.color.boundary.default,"--vgai-card-specular-ring":_3t(t.treatment),"--vgai-card-specular-sheen":W5r(t.treatment),"--vgai-card-specular-shadow":H5r(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":cFr(t.treatment),"--vgai-island-surface":G5r(t),"--vgai-island-backdrop-filter":Q5r(t),"--vgai-island-radius":K5r(i),"--vgai-island-border-color":Y5r(i),"--vgai-island-shadow":X5r(i),"--vgai-island-specular-ring":aFr(t.treatment),"--vgai-selection-bg":eFr(t),"--vgai-content-on-selection":rFr(t),"--vgai-selection-border":nFr(t),"--vgai-selection-indicator":iFr(t),"--vgai-island-control-radius":sFr(i),"--vgai-island-primary-bg":oFr(t),"--vgai-content-text-shadow":h3t(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":uFr(t),"--vgai-glass-regular-backdrop-filter":iAt(t.treatment),"--vgai-glass-regular-panel-bg":fFr(t),"--vgai-glass-regular-panel-backdrop-filter":iAt(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":pFr(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":mFr(t),"--vgai-area-emboss":nY(t.color.surface.panel),"--vgai-area-emboss-stage":nY(nY(t.color.viewport?.background??t.color.surface.panel)),"--vgai-area-emboss-stage-header":nY(nY(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":_Fr(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":`${EFe.active}px solid ${t.color.accent.default}`,"--vgai-select-chevron":B5r(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":`${EFe.resting}px`,"--vgai-stroke-active":`${EFe.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(z_e.regular),"--vgai-font-weight-semibold":String(z_e.semibold),"--vgai-font-weight-bold":String(z_e.bold),"--vgai-leading-tight":String(Fpe.tight),"--vgai-leading-snug":String(Fpe.snug),"--vgai-leading-normal":String(Fpe.normal),"--vgai-leading-relaxed":String(Fpe.relaxed),"--vgai-duration-fast":`${rY.duration.fast}ms`,"--vgai-duration-base":`${rY.duration.base}ms`,"--vgai-duration-slow":`${rY.duration.slow}ms`,"--vgai-ease-standard":rY.easing.standard,"--vgai-ease-out":rY.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 iMe="vgai-editor-theme";function gFr(t,r=sz){t.classList.add(iMe),t.dataset.vgaiTheme=r.id,t.dataset.vgaiChrome=rU(r)?"islands":"bars";for(const[i,a]of Object.entries(hFr(r)))t.style.setProperty(i,a)}const g3t=Xe.createContext(null);function yFr(){return Xe.useContext(g3t)}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)})}),Dze=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)})}),y3t=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 wDn=Xe.forwardRef(function({className:r,...i},a){return z.jsx("input",{...i,ref:a,type:"range",className:_9("vgai-range",r)})}),Yk="default",bX=new Map;let dZ=Yk;const sMe=new Set;function oMe(){for(const t of sMe)t()}function See(t){return typeof t=="string"&&(t===Yk||bX.has(t))}function vFr(t){if(See(t.id))throw new Error(`registerContributedIconSet: icon set "${t.id}" is already registered.`);return bX.set(t.id,t),oMe(),()=>{bX.get(t.id)===t&&(bX.delete(t.id),oMe())}}function sAt(){return dZ}function U_e(t){const r=See(t)?t:Yk;r!==dZ&&(dZ=r,oMe())}function v3t(t){return sMe.add(t),()=>sMe.delete(t)}function bFr(t){return dZ===Yk?null:bX.get(dZ)?.glyphs[t]??null}const oAt={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)"},aAt={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(v3t,sAt,sAt);const b=bFr(t.iconName);if(b){const S=i!=="current",k=b.tone?`var(--vgai-category-${b.tone}, currentColor)`:void 0,w=S?aAt[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:oAt[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(Dkr,{...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:oAt[r],color:aAt[i],...d}})}function b3t({direction:t,size:r="xs",tone:i="current",style:a}){return z.jsx(So,{icon:t==="right"?$kt:Xkt,size:r,tone:i,...a?{style:a}:{}})}function aS(t,r){return{...r,iconName:t}}const gb={action:{close:Yqe,search:Mkt},transport:{play:tDr,pause:bDr,stop:S9e},content:{project:Bkt,folder:hee},status:{success:S8,warning:yee,error:Wkt},viewport:{zoomIn:MIr,zoomOut:OIr,pan:GIr,frame:jkt,projection:aS("viewport-projection",ADr)},modeling:{extrude:aS("mesh-extrude",Vkt),inset:aS("mesh-inset",yDr),bevel:aS("mesh-bevel",xDr),loopCut:aS("mesh-loop-cut",LIr),knife:aS("mesh-knife",dDr),smooth:aS("mesh-smooth",NIr),shrinkFatten:aS("mesh-shrink-fatten",Hkt),subdivide:aS("mesh-subdivide",rDr)},tool:{extension:gee,select:CDr,move:Gkt,rotate:Fkt,scale:aS("tool-scale",jIr),transform:aS("tool-transform",YIr)},panel:{outliner:aS("outliner",aIt),properties:aS("properties",Qkt)}};function AX({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=yFr();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 AFr={minHeight:"var(--vgai-panel-header-height)",padding:`0 ${U_[4]}px`,color:Oo.content.muted,fontSize:"var(--vgai-font-base)",fontWeight:z_e.semibold,textTransform:"uppercase",display:"flex",alignItems:"center",gap:U_[2],userSelect:"none"},SFr={...AFr,background:"var(--vgai-surface-sticky)",borderBottom:"1px solid var(--vgai-structural-divider)",flexShrink:0};function Pze({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:{...SFr,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 xFr({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(b3t,{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 wFr(t){return t==="top"?"bottom":t==="bottom"?"top":t==="left"?"right":"left"}function CFr(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 EFr(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=CFr(a,se,de)?a:wFr(a);X(EFr(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 TFr({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(AX,{label:"X",labelColor:"#E06178",value:t[0],onChange:g(0),step:a,disabled:l,style:{flex:1},testId:_("x")}),z.jsx(AX,{label:"Y",labelColor:"#C2ED66",value:t[1],onChange:g(1),step:a,disabled:l,style:{flex:1},testId:_("y")}),z.jsx(AX,{label:"Z",labelColor:"#6BABF5",value:t[2],onChange:g(2),step:a,disabled:l,style:{flex:1},testId:_("z")})]})}const TFe={border:Oo.boundary.default,accent:Oo.accent.default,radiusSmall:Oo.shape.small,inputBg:Oo.surface.inset},kFr={fontSize:"var(--vgai-font-base)",fontWeight:600,color:Oo.content.muted,textTransform:"uppercase",letterSpacing:.4},IFr=72,kFe=22,cAt={width:kFe,height:kFe,flex:`0 0 ${kFe}px`,borderRadius:TFe.radiusSmall,border:`1px solid ${TFe.border}`,background:TFe.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 DFr({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:cAt,"data-testid":`${_}-thumb`}):z.jsx("span",{style:cAt,"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:Yqe})})]}),d&&z.jsx("span",{"data-testid":`${_}-note`,style:{fontSize:"var(--vgai-font-sm)",color:Oo.content.muted},children:d})]})}function aMe({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 SX=new Map,Fq=new Set,Ahe=new Set,V_e=new Set;let A3t=0;function S3t(){A3t+=1;for(const t of[...Fq])t()}function PFr(t,r){return SX.set(t,r),S3t(),()=>{SX.get(t)===r&&SX.delete(t)}}function NFr(t){SX.has(t)&&S3t()}function OFr(t){return Fq.add(t),()=>{Fq.delete(t)}}function lAt(){return A3t}function pZ(t){return SX.get(t)}function x3t(t,r=1e4){const i=pZ(t);return i!==void 0?Promise.resolve(i):new Promise(a=>{const l=()=>{const _=pZ(t);_!==void 0&&(clearTimeout(d),Fq.delete(l),a(_))},d=setTimeout(()=>{Fq.delete(l),a(void 0)},r);Fq.add(l)})}function w3t(t){Ahe.add(t);for(const r of[...V_e])r();return()=>{Ahe.delete(t)}}function C3t(t,r=1e4){return Ahe.has(t)?Promise.resolve(!0):new Promise(i=>{const a=()=>{Ahe.has(t)&&(clearTimeout(l),V_e.delete(a),i(!0))},l=setTimeout(()=>{V_e.delete(a),i(!1)},r);V_e.add(a)})}async function Nze(t){if(POr(t)&&!await xE(()=>Pw(t)!==null,m9))throw new Error(`The requested Object3D view did not mount for document: ${t}`)}let cMe=null;const zY=new Map;let DR=[];function FFr(t){if(cMe=t,!t)return;const r=DR;DR=[];for(const i of r)E3t(t,i)}function E3t(t,r){zY.get(r.id)?.();const i=t.show(r),a=()=>{zY.get(r.id)===a&&(zY.delete(r.id),i(),r.onDismiss?.())};return zY.set(r.id,a),a}let RFr=0;function oz(t){const r=t.id??`notification-${++RFr}`,i={...t,id:r};return cMe?E3t(cMe,i):(DR=[...DR.filter(a=>a.id!==r),i],()=>Oze(r))}function Oze(t){const r=zY.get(t);if(r){r();return}const i=DR.find(a=>a.id===t);i&&(DR=DR.filter(a=>a.id!==t),i.onDismiss?.())}let iI={sessions:[],selectedSessionId:null,selectedSession:null,cursorMs:0,liveEdgeMs:0,loading:!0,error:null},She=!0,Rpe=null,J_e=null,iY=null,W_e=!1;const UY=new Set;function MFr(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 xhe(t){iI=t;for(const r of UY)r()}async function LFr(){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 BFr(){try{const t={sessions:await LFr()},r=MFr(t.sessions,iI.sessions,J_e),i=r.sessionId;r.latestAppeared&&(She=!0),J_e=i;const a=i?await jFr(i):null;if(J_e!==i){W_e=!0;return}const l=t.sessions.map(g=>g.id===a?.id?a:g),d=a?.durationMs??0,_=She?d:Math.min(iI.cursorMs,d);xhe({sessions:l,selectedSessionId:i,selectedSession:a,cursorMs:_,liveEdgeMs:d,loading:!1,error:null})}catch(t){xhe({...iI,loading:!1,error:t instanceof Error?t.message:String(t)})}}function _Z(){return iY?(W_e=!0,iY):(iY=BFr().finally(()=>{iY=null,W_e&&(W_e=!1,_Z())}),iY)}function $Fr(t){return UY.add(t),UY.size===1&&(_Z(),Rpe=window.setInterval(()=>void _Z(),1e3)),()=>{UY.delete(t),UY.size===0&&Rpe!==null&&(window.clearInterval(Rpe),Rpe=null)}}function qFr(t){const r=iI.sessions.find(i=>i.id===t);r&&(J_e=r.id,She=!0,xhe({...iI,selectedSessionId:r.id,selectedSession:r,cursorMs:r.durationMs,liveEdgeMs:r.durationMs}),_Z())}function zFr(t){const r=Math.max(0,Math.min(t,iI.liveEdgeMs));She=iI.liveEdgeMs-r<250,xhe({...iI,cursorMs:r})}const T3t={getSnapshot:()=>iI,subscribe:$Fr,select:qFr,seek:zFr,refresh:_Z};let UFr=null;const uAt=new Set,CDn={getSnapshot:()=>UFr,subscribe(t){return uAt.add(t),()=>uAt.delete(t)}};let H_e={phase:null,run:0},k3t=null;function VFr(t){k3t=t}function fAt(t){H_e=t;try{k3t?.(t)}catch{}}function I3t(t,r=Date.now()){return fAt({phase:t,at:r,run:H_e.run}),()=>{H_e.phase===t&&fAt({phase:null,at:Date.now(),run:H_e.run})}}const JFr=Xe.lazy(()=>la(()=>import("./GameplaySessionTimeline-BtEPIu2F.js"),__vite__mapDeps([44,1,2,3,4,8,9,10,11,6])).then(t=>({default:t.GameplaySessionTimeline})));class Fze 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 WFr({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&&w3t(P.current)},G=j.appendChild(document.createElement("div"));G.style.display="contents";const ee=Vqe.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:y0e(),surfaces:Sze,account:pze(),work:ee=>{w.current?.(),w.current=ee===null?null:I3t(`building ${ee.replace(/^building /,"")}`)},notify:ee=>oz({...ee,id:`contribution:${t.id}:${ee.title}`,...ee.tone==="warning"?{fades:!0}:{}}),...t.point==="workspace.analytics"?{gameplaySessions:T3t}:{play:Kye()},...i?{documentId:i,publishContext:ee=>PFr(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(HFr,{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 HFr({documentId:t,children:r}){return Xe.useEffect(()=>w3t(t),[t]),z.jsx(z.Fragment,{children:r})}function h9({contribution:t,Component:r,documentId:i,active:a,document:l}){const d=Xe.useSyncExternalStore(Qye,T8,T8),_=Xe.useSyncExternalStore(Yye,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(JFr,{})}):null,z.jsx(Fze,{file:t.file,children:z.jsx("div",{style:{flex:1,minHeight:0,overflow:"auto"},children:z.jsx(WFr,{contribution:t,...r?{Component:r}:{},accountRevision:d,playKey:g,...i?{documentId:i}:{},...a!==void 0?{active:a}:{},...l?{document:l}:{}})})})]})}function GFr({id:t,title:r,file:i,tool:a,Component:l,adapter:d,nodeId:_}){Xe.useSyncExternalStore(Qye,T8,T8),Xe.useSyncExternalStore(Yye,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(Fze,{file:i,children:z.jsx(m3r,{adapter:d,nodeId:_,children:z.jsx(l,{...a?{tool:a}:{},contributionId:t.slice(t.lastIndexOf(":")+1),client:y0e(),surfaces:Sze,account:pze(),play:Kye(),node:g,nodeId:_,adapter:d})})})})}const QFr=Symbol("vgai.inspection.mixed");function lMe(t){return t===QFr}function Rze(t){return t.readonlyReason??"This field is read-only."}function Mze(t){return"column"}function Lze(t,r){return t.quickActions.filter(i=>i.placement===r)}const uMe="preview",dAt="transform",IFe="properties",D3t="stories";function pAt(t){return`group:${t}`}const P3t=100,KFr=1e3,mZ=2e3,N3t=3e3,YFr=4e3,XFr=5e3,ZFr={nullSubjectId:null};function O3t(t){return"sections"in t}const G_e=[];let F3t=0;const fMe=new Set;function _At(){F3t++;for(const t of fMe)t()}function e7r(t){return fMe.add(t),()=>{fMe.delete(t)}}function mAt(){return F3t}function R3t(t){return G_e.push(t),_At(),()=>{const r=G_e.indexOf(t);r>=0&&(G_e.splice(r,1),_At())}}function hAt(t,r,i=ZFr){return G_e.filter(a=>a.match(t,r,i))}function M3t(t){if(typeof t!="object"||t===null)return!1;const r=t.name;return r==="Canceled"||r==="CancellationError"||r==="AbortError"}const t7r=1e3;class r7r{_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>t7r){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 r7r;typeof window<"u"&&(window.__vgaiEditorConsole=ua);const gAt=1e3,yAt=4e3;function Rq(t){try{return String(t)}catch{return Object.prototype.toString.call(t)}}function n7r(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>gAt?`${i.slice(0,gAt)}…`:i}function L3t(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 n7r(b)}}),d=i.slice(a);return d.length===0?l:`${l} ${d.map(Rq).join(" ")}`}function i7r(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 dMe(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 Whe(t){let r="";for(let a=0;a<t.byteLength;a+=32768)r+=String.fromCharCode(...t.subarray(a,a+32768));return btoa(r)}function I0e(){return typeof __VGAI_PROJECT_PATH__<"u"?__VGAI_PROJECT_PATH__:""}let Hhe=null;const WMr=new Set;function k4t(){return Hhe!==null}function M$(){return Hhe}function HMr(t){if(Hhe!==t){Hhe=t;for(const r of WMr)r()}}const Ghe="/__editor";function AUe(t){return t.replace(/\\/g,"/").replace(/^\/+/,"").replace(/\/+$/,"")}function qpe(t){const r=AUe(t);if(!r||r.split("/").includes(".."))throw new Error(`projectFiles: "${t}" is not a project-relative path.`);return r}function GMr(t){const r=AUe(t);if(r.split("/").includes(".."))throw new Error(`projectFiles: "${t}" is not a project-relative directory.`);return r}function QMr(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 KMr(t){const r=await fetch(`/@fs/${I0e()}/${t}`);if(!r.ok)throw new Error(`projectFiles.read "${t}": HTTP ${r.status}`);return r.text()}async function YMr(t){const r=await fetch(`/@fs/${I0e()}/${t}`);if(!r.ok)throw new Error(`projectFiles.readBytes "${t}": HTTP ${r.status}`);return new Uint8Array(await r.arrayBuffer())}async function XMr(t,r){if(t.startsWith("public/")){const i=typeof r=="string"?{path:t.slice(7),content:r,...yw()}:{path:t.slice(7),content:Whe(r),encoding:"base64",...yw()},a=await fetch(`${Ghe}/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:Whe(r),encoding:"base64",...yw()},a=await fetch(`${Ghe}/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 QMr(t)}async function ZMr(t){try{const r=await fetch(`/@fs/${I0e()}/${t}`,{method:"HEAD"});return r.ok?!(r.headers.get("content-type")??"").toLowerCase().includes("text/html"):!1}catch{return!1}}async function eLr(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(`${Ghe}/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 tLr(t){const r=new EventSource(`${Ghe}/events`),i=a=>{try{const l=JSON.parse(a.data),d=l.path??l.file;if(!d)return;t({type:l.type??"update",path:AUe(d)})}catch{}};return r.addEventListener("message",i),()=>{r.removeEventListener("message",i),r.close()}}const Qg={frameOwned:k4t,async read(t){const r=qpe(t);return M$()?.read(r)??KMr(r)},async readBytes(t){const r=qpe(t),i=M$();return i?.readBytes?i.readBytes(r):YMr(r)},async write(t,r){const i=qpe(t),a=M$();return a?a.write(i,r):XMr(i,r)},async exists(t){const r=qpe(t);return M$()?.exists(r)??ZMr(r)},async list(t){const r=GMr(t),i=M$();return i?.list?i.list(r):eLr(r)},watch(t){const r=M$();return r?.watch?r.watch(t):tLr(t)}},KFe={version:"vgai-thumbnail-v2"},rLr=Na({version:Ry(1),profile:Ss().min(1),generatedAt:Ss(),entries:zR(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:wbt([Tu(),Tu(),Tu()]),target:wbt([Tu(),Tu(),Tu()]),fov:Tu().positive().lt(180).optional()}).strict().optional()}).strict())}).strict(),Lq=".vgai/thumbnails.json";let nme=null;async function nLr(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=rLr.safeParse(a);return l.success?{status:"ok",manifest:l.data}:{status:"unreadable",reason:l.error.issues.map(d=>d.message).join("; ")}}function SUe(){return nme||(nme=nLr(Qg).then(async t=>{if(t.status==="unreadable"){const{editorConsole:r}=await la(async()=>{const{editorConsole:i}=await Promise.resolve().then(()=>a7r);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})),nme}function I4t(){nme=null}class D4t{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 ime=null;function iLr(t){return ime=t,()=>{ime===t&&(ime=null)}}function sLr(){return ime}class P4t{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 oLr=new Set;let YFe=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)){YFe={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 oLr)a(YFe);throw new Error(`${r.label} conflicts with source revision ${YFe.currentRevision}; inspect it before reapplying.`)}throw new Error(typeof i?.error=="string"?i.error:`${r.label} failed with HTTP ${t.status}.`)}function N4t(t){return t.split("/").filter(r=>r.length>0&&r!==".")}function uv(t){return N4t(t).join("/")}function aLr(t){const r=N4t(t),i=r.pop()??"";return[r.join("/"),i]}const zpe="/__editor";class cLr{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:Whe(i),encoding:"base64",...yw()},l=await fetch(`${zpe}/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(`${zpe}/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]=aLr(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(`${zpe}/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(`${zpe}/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 _R=null,XFe=null;function lLr(){return _R&&!(_R instanceof P4t)?_R:(XFe||(XFe=new cLr(I0e())),XFe)}function pz(){if(_R)return _R;const t=lLr();return _R=k4t()?new P4t(t):t,_R}function uLr(){return crypto.randomUUID()}function ZFe(t){return`resource:${t}`}function e7e(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 fLr(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 dLr{constructor(r=uLr){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:ZFe(this.makeId()),kind:r,scope:"project",displayName:a??e7e(l),location:d,sessionId:null})}registerDraft(r,i){const a=this.makeId();return this.add({key:ZFe(a),kind:r,scope:"project",displayName:i,location:`draft://${a}`,sessionId:null})}registerSession(r,i,a,l){const d=fLr(i,"Session id"),_=PA(a),g=`session://${d}/${_}`,b=this.existingAt(g,r);return b||this.add({key:ZFe(this.makeId()),kind:r,scope:"session",displayName:l??e7e(_),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??e7e(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 O4t=0,ZMe=1;function MN(t,r=new Uint8Array){const i=new Uint8Array(r.byteLength+1);return i[0]=t?ZMe:O4t,t&&i.set(r,1),i}function pLr(t){const r=t[0];if(r!==O4t&&r!==ZMe)throw new Error("Invalid project-file snapshot.");return{exists:r===ZMe,bytes:t.slice(1)}}async function t7e(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 i2t 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 _Lr{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 i2t(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 t7e(this.backend,d.path,0,a.get(d.path)??"application/octet-stream")).sha256!==d.sha256)throw new i2t(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:()=>t7e(this.backend,r,_.revision,_.contentType),preflight:async b=>{const S=await t7e(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=pLr(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 s2t=new WeakMap;function xUe(t,r=pz(),i="public"){let a=s2t.get(t);a||(a=new Map,s2t.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 _Lr(t,r);return a.set(i,{backend:r,manager:d}),d}class mLr{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 hLr=new mLr("project-manifest-http","/__editor/manifest");class gLr{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:Whe(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 yLr=new gLr;function FDn(){return hLr}function F4t(){return yLr}let wX=null,R4t=null;const _z=new Set,eLe=new Set,tLe=new Set;let xZ=[];function J3(){return wX!==null}function vLr(t){if(wX!==t){wX=t,wX||(xZ=[]);for(const r of _z)r()}}function fY(){return wX}function M4t(t){return _z.add(t),()=>_z.delete(t)}function bLr(){for(const t of _z)t()}function L4t(t){const r={...t,document:t.document===void 0?R4t?.()??null:t.document};xZ.push(r);for(const i of eLe)i(r);for(const i of _z)i()}function ALr(t){R4t=t}function SLr(){return xZ}function xLr(t){return eLe.add(t),()=>eLe.delete(t)}function wLr(t){const r=new Set(t);xZ=xZ.filter(i=>!i.resources.some(a=>r.has(a)));for(const i of tLe)i(t);for(const i of _z)i()}function CLr(t){return tLe.add(t),()=>tLe.delete(t)}class ELr{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 TLr(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 kLr{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(!TLr(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 ILr=2e3,DLr=64*1024*1024,PLr=16*1024*1024,NLr=.8,o2t="project://";class dv extends Error{constructor(r){super(r.message),this.historyError=r,this.name="HistoryOperationError"}}function OLr(){return crypto.randomUUID()}function FLr(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=FLr(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 rLe(t){return`${(t/(1024*1024)).toFixed(1)} MB`}function RLr(t,r){return`${t} ${r}${t===1?"":"s"}`}function MLr(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 — ${rLe(i)} of ${rLe(a.maxBytes)} of in-memory snapshots, at only ${r} of ${a.maxTransactions} steps. Memory binds first here; raise maxBytes to keep more.`}function LLr(t,r,i){const a=t==="transactions"?`${i.maxTransactions}-step limit`:`${rLe(i.maxBytes)} memory limit`;return`Undo history dropped ${RLr(r,"older step")} to stay within its ${a}. Those edits can no longer be undone; saved files are unaffected.`}function a2t(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 jLr{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 dLr,this.snapshots=r.snapshots??new kLr,this.persistence=r.persistence??new ELr,this.makeId=r.makeId??OLr,this.now=r.now??Date.now,this.limits={maxTransactions:r.limits?.maxTransactions??ILr,maxBytes:r.limits?.maxBytes??DLr,maxTransactionBytes:r.limits?.maxTransactionBytes??PLr},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=M4t(()=>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=fY();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=a2t(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=a2t(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(o2t))continue;const d=l.slice(o2t.length);i.includes(d)||i.push(d)}L4t({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:LLr(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)<NLr){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:MLr(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()?fY()?.canUndo()??!1:a&&!!r&&r.status!=="expired"&&!this.blockedValue,canRedo:J3()?fY()?.canRedo()??!1:a&&!!i&&i.status!=="expired"&&!this.blockedValue,undoLabel:J3()?fY()?.undoLabel?.()??null:r?.label??null,redoLabel:J3()?fY()?.redoLabel?.()??null:i?.label??null,uniqueSnapshotBytes:this.snapshots.uniqueByteLength,lastError:this.lastErrorValue,limitWarning:this.limitWarningValue,lastEviction:this.lastEvictionValue}}}const q7=new TextEncoder,BLr=new TextDecoder;class $Lr{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:q7.encode(l.before),afterBytes:q7.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(q7.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(q7.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(q7.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??q7.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:BLr.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"?q7.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 c2t=new WeakMap;function qLr(t,r){let i=c2t.get(r);i||(i=new WeakMap,c2t.set(r,i));const a=t.historyIdentity??t;let l=i.get(a);return l||(l=new $Lr(r,t),i.set(a,l)),l}function zLr(t,r,i){return!t.readSource||!t.applySource?Promise.reject(new Error("This editor tier cannot write project source.")):qLr(t,r).replaceSource(i.label,i.file,i.source)}function ULr(t){if(t&&typeof t=="object"&&"revision"in t){const r=t.revision;typeof r=="number"&&CDt(r)}}async function mb(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:()=>mb(t,r).then(()=>{})})}const d=await nLe(l,t);return ULr(d),d}async function nLe(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 iLe=new Map;function l2t(t,r){const i=t.file??r;i&&t.resourcePath&&iLe.set(i,t.resourcePath)}async function VLr(t){const r=iLe.get(t);if(r)return r;const i=await mb("/__ui-source/read",{file:t});return iLe.set(t,i.resourcePath),i.resourcePath}async function JLr(t,r,i){const a=await VLr(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 j4t(){return{historyIdentity:WLr,prepare:async t=>{const r=await mb("/__ui-source/prepare",t);return l2t(r),r},readSource:async t=>{const r=await mb("/__ui-source/read",{file:t});return l2t(r,t),r},applySource:(t,r,i)=>Qg.frameOwned()?JLr(t,r,i):mb("/__ui-source/apply",{file:t,source:r,ifMatchSha:i}),writeStyle:(t,r,i)=>mb("/__ui-source/write",{oid:t,prop:r,value:i}),removeStyle:(t,r)=>mb("/__ui-source/write",{oid:t,prop:r,value:null}),writeCss:(t,r,i,a,l)=>mb("/__ui-source/css",{file:t,selector:r,prop:i,value:a,...l!==void 0?{media:l}:{}}),writeText:(t,r)=>mb("/__ui-source/text",{oid:t,text:r}),writeProp:(t,r,i,a)=>mb("/__ui-source/prop",{oid:t,prop:r,value:i,...a?.addIfMissing?{addIfMissing:!0}:{},...a?.allowShapeUpgrade?{allowShapeUpgrade:!0}:{}}),removeProp:(t,r)=>mb("/__ui-source/prop",{oid:t,prop:r,value:null}),writeStruct:(t,r,i)=>mb("/__ui-source/struct",{oid:t,op:r,...i}),writeStructMany:(t,r,i)=>mb("/__ui-source/struct-many",{oids:t,op:r,...i}),forkComponent:(t,r,i)=>mb("/__ui-source/fork-component",{oid:t,definitionOid:r,...i?{name:i}:{}}),extractComponent:(t,r)=>mb("/__ui-source/extract-component",{oid:t,...r?{name:r}:{}}),index:async()=>{const t=await fetch("/__ui-source/index");return nLe(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 nLe(a,"/__ui-source/component-props")).props??[]}}}const WLr={};let dY=null,sLe=null;function wUe(){if(!dY){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 sLe=i,i}).catch(()=>(dY===t&&(dY=null),{ui:!1,ingest:!1}));dY=t}return dY}function HLr(){return wUe().then(t=>t.ui)}function GLr(){wUe()}function QLr(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 KLr(t){return sLe===null?(wUe(),QLr(t),null):sLe}function YLr(t){return KLr(t)?.ui?j4t():void 0}async function XLr(){return await HLr()?j4t():void 0}async function u2t(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 ZLr(t){return t.resources.map(r=>r.path).join(" + ")}async function ejr(t){const{binding:r,document:i,history:a}=t,d=await xUe(a,t.backend??F4t(),"asset-lab-document").openMutationSession(await u2t(r,i));return{commit:(_,g)=>W9r({resolve:()=>({reaches:"writer",anchorKind:"data-record",destination:ZLr(r),write:async()=>{await d.assertUnchanged();const b=await u2t(r,_),S=g?.trim()||r.label?.trim()||"Edit Asset Lab Document";return d.mutate(b,{label:S})}}),record:()=>{}})}}async function tjr(t,r){const i=await SUe();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:KFe.version,generatedAt:new Date().toISOString(),entries:{}},l=t.replace(/^\/+/,""),d=a.entries[l]??{state:"fallback",profileVersion:KFe.version,issueCode:"thumbnail.pending-regeneration"},_={...a,profile:KFe.version,generatedAt:new Date().toISOString(),entries:{...a.entries,[l]:{...d,framing:r}}},g=`${JSON.stringify(_,null,2)}
|
|
71
71
|
`,b=sLr();(b?await xUe(b,F4t(),"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))&&I4t()}const rjr={openPersistence:t=>ejr(t),replaceSource:async(t,r)=>{const i=YLr("The Asset Editor");if(!i)throw new Error("This editor tier cannot write project source.");return zLr(i,t,r)},saveThumbnailFraming:tjr};function B4t(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",$4t="workspace:scene",njr="workspace:canvas-scene",ijr="workspace:3d-components",sjr="workspace:2d-components",ojr="workspace:ui-components",ajr=new Set([njr,sjr,ijr,ojr]),cjr={hidden:!1,interactive:!1,pickLock:!1},q4t=new Map;function D0e(t){return q4t.get(t)??cjr}function CUe(t,r){q4t.set(t,{...D0e(t),...r})}function zP(t){return D0e(t).hidden}function ljr(t,r){CUe(t,{hidden:r})}function ujr(t){ljr(t,!zP(t))}function z4t(t){return D0e(t).interactive}function fjr(t,r){CUe(t,{interactive:r})}function djr(t){fjr(t,!z4t(t))}function P0e(t){return D0e(t).pickLock}function pjr(t,r){CUe(t,{pickLock:r})}function _jr(t){pjr(t,!P0e(t))}function Qhe(t,r,i,a){const l=t.pickable?.pick(r,i)??null;return l?t.selection?.resolve?.(l,{intent:a,scopeId:hUe()})?.id??l:null}function f2t(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:hUe()})?.id??g;_.has(b)||(_.add(b),d.push(b))}return d}function mjr(t,r,i,a={}){const l=a.intent??"normal",d=By(t);if(!(d instanceof Zh))return Qhe(d,r,i,l);const _=d.childAdapters(),b=I_()===$4t?[]:_.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=[...B4t(k).reverse(),...S];for(const{worldId:N,adapter:P}of w){if(zP(N)||P0e(N))continue;const j=Qhe(P,r,i,l);if(j)return j}return null}function RDn(t,r,i,a={}){const l=a.intent??"normal",d=a.adapter??By(t);if(!(d instanceof Zh)){const j=f2t(d,r,i,l),J=Qhe(d,r,i,l);return j.length>0?j:J?[J]:[]}const _=d.childAdapters(),b=I_()===$4t?[]:_.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=[...B4t(k).reverse(),...S],N=[],P=new Set;for(const{worldId:j,adapter:J}of w){if(zP(j)||P0e(j))continue;const X=f2t(J,r,i,l),G=Qhe(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 hjr(t){return t==="three"||t==="canvas"||t==="dom"?t:null}function gjr(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?hjr(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=t0e(),i=By(t),a=gjr(i),l=AE()?.descriptor.kind;return{adapter:r?.adapter??a?.adapter??i,surface:l==="story"?"dom":a?.surface??null,documentSelection:r}}function U4t(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 d2t=new WeakMap,EUe={activeAuthoring(t){let r=d2t.get(t);return r||(r=HPt(t,"No authoring adapter"),d2t.set(t,r)),r},panelAuthoring(t){return EUe.activeAuthoring(t)},pick(){return null},toolOwner:U4t,toolOwnerPainted(){return!0},threeSurfaceShowing(t,r){return!r.rects&&typeof r.hierarchy.object3D=="function"},threeViewportRootId(){return null},applyRootHiddenVisibility(){},suppressRootEnvironment(){}};let sme=EUe;function yjr(t){if(sme!==t){if(sme!==EUe)throw new Error("A viewport authoring policy is already installed.");sme=t}}function MDn(){return sme}const TUe={editorHelperType:"editorHelperType",skeletonVisible:"skeletonVisible",skeletonEnabled:"skeletonEnabled",engineInternal:"engineInternal",editorHelper:"editorHelper",vgaiComponentRoot:"vgaiComponentRoot",vgaiBuiltInternal:"vgaiBuiltInternal"};function Khe(t,r){return t?t.userData[TUe[r]]:void 0}function LDn(t,r,i){t.userData[TUe[r]]=i}const kUe={...TUe,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[kUe[r]]:void 0}function wZ(t,r,i){t.userData[kUe[r]]=i}function X8(t,r){return t?t.userData[kUe[r]]!==void 0:!1}function N0e(t){const r=By(t);return r instanceof Zh?r.childAdapters().find(a=>a.kind==="three"&&a.adapter.capabilities.transform)?.worldId??null:null}function vjr(t,r){if(r!==null&&zP(r))for(const a of t.values())a.visible=!1}const bjr=new vE("#aaaaaa");function Ajr(t){t.background=bjr,t.fog=null,t.environment=null,t.traverse(r=>{CE(r,"envObject")&&(r.visible=!1)})}function oLe(t){const r=By(t);if(!(r instanceof Zh))return!0;if(!r.childAdapters().some(l=>l.kind==="three"))return!1;const a=N0e(t);return a===null?!0:!zP(a)}function Sjr(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 V4t(t,r){const i=[...r];if(i.length===0)return null;if(t instanceof Zh)return Sjr(t,i);const a=U4t(t,i);return a?{...a,adapter:t}:null}function J4t(t,r){return!r||r.worldId!==null&&zP(r.worldId)?!1:r.kind!=="three"||r.worldId===null?!0:N0e(t)===r.worldId}const xjr={activeAuthoring:t=>By(t),panelAuthoring:t=>wm(t).adapter,pick:(t,r,i,a)=>mjr(t,r,i,{intent:a}),toolOwner:(t,r)=>V4t(t,r),toolOwnerPainted:(t,r)=>oLe(t)&&J4t(t,r),threeSurfaceShowing:(t,r)=>oLe(t)&&(r instanceof Zh?r.childAdapters().some(i=>i.kind==="three"):!r.rects&&typeof r.hierarchy.object3D=="function"),threeViewportRootId:t=>N0e(t),applyRootHiddenVisibility:vjr,suppressRootEnvironment:Ajr};class wjr extends Rye{constructor(){super();const r=new lkt;r.deleteAttribute("uv");const i=new ez({side:ukt}),a=new ez,l=new fkt(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 Jqe(r,a,6),g=new Mye;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 Pkr({color:0,emissive:16777215,emissiveIntensity:t})}function W4t(t){const r=new Nkr(t),i=new wjr;try{const a=r.fromScene(i,.04);return{texture:a.texture,dispose:()=>a.dispose()}}finally{i.dispose(),r.dispose()}}const Cjr=new WeakSet,Ejr=8;let HY=0;function UP(t){Cjr.add(t),HY+=1;const r=t,i=r.dispose;if(typeof i=="function"){let a=!0;r.dispose=function(...d){return a&&(a=!1,HY-=1),i.apply(this,d)}}return HY>=Ejr&&console.warn(`[host-renderers] ${HY} 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 Tjr(){return HY}const kjr=2,sR=[],Yhe=new Set;function Ijr(){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 Yhe.add(i),t.addEventListener("webglcontextlost",()=>{i.lost=!0;const a=sR.indexOf(i);a>=0&&sR.splice(a,1),i.leased||H4t(i)}),i}function H4t(t){Yhe.delete(t)&&(t.environment?.dispose(),t.environment=null,t.renderer.dispose(),t.renderer.forceContextLoss(),t.canvas.remove())}function Djr(){return{active:[...Yhe].filter(t=>t.leased&&!t.lost).length,idle:[...Yhe].filter(t=>!t.leased&&!t.lost).length}}function jDn(){let t=sR.find(a=>!a.leased&&!a.lost);t||(t=Ijr(),sR.length<kjr&&(t.pooled=!0,sR.push(t))),t.leased=!0;const r=t;let i=!1;return{canvas:r.canvas,renderer:r.renderer,environment(){return r.environment??=W4t(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=sR.indexOf(r);l>=0&&sR.splice(l,1)}if(!r.pooled||r.lost){H4t(r);return}r.renderer.setScissorTest(!1),r.renderer.autoClear=!0,r.renderer.clear()}}}}const Pjr=["front","side"],G4t=1,Njr=.55,p2t=G4t/2,r7e=128,Ojr=[24,26,31],Fjr=[235,137,52],Rjr=[56,189,248],Mjr=[236,240,238];function Ljr(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]>=r7e||t[l+1]>=r7e||t[l+2]>=r7e;i[a]=d?1:0}return i}function jjr(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 Bjr(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?Mjr:l?Fjr:d?Rjr:Ojr,g=a*4;i[g]=_[0],i[g+1]=_[1],i[g+2]=_[2],i[g+3]=255}return i}function ome(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 IUe(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 $jr(t,r,i=G4t){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 DUe=31,BDn=30;function PUe(t){return(t.layers.mask&1<<DUe)!==0||!!Khe(t,"editorHelper")||!!Khe(t,"engineInternal")}function $Dn(t){let r=t;for(;r;){if(PUe(r))return!0;r=r.parent}return!1}function qjr(t){const r=Khe(t,"vgaiComponentRoot");return typeof r=="string"&&r?r:void 0}function O0e(t){return Khe(t,"vgaiBuiltInternal")===!0}var zjr=(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 n7e=new WeakMap;class Ujr extends Wqe{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 ER(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(n7e.has(r)){const b=n7e.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)}),n7e.set(r,{key:a,promise:g}),g}_createGeometry(r){const i=new Hqe;r.index&&i.setIndex(new hX(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 hX(_,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),sZ.colorSpaceToWorking(a,hv),r.setXYZ(l,a.r,a.g,a.b)}_loadLibrary(r,i){const a=new ER(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=Vjr.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 Vjr(){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 _2t(t,r){if(r===Okr)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),t;if(r===m9e||r===dkt){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===m9e)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 Jjr extends Wqe{constructor(r){super(r),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(i){return new Kjr(i)}),this.register(function(i){return new Yjr(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 Zjr(i)}),this.register(function(i){return new eBr(i)}),this.register(function(i){return new tBr(i)}),this.register(function(i){return new rBr(i)}),this.register(function(i){return new Qjr(i)}),this.register(function(i){return new nBr(i)}),this.register(function(i){return new Xjr(i)}),this.register(function(i){return new sBr(i)}),this.register(function(i){return new iBr(i)}),this.register(function(i){return new Hjr(i)}),this.register(function(i){return new lBr(i)}),this.register(function(i){return new uBr(i)})}load(r,i,a,l){const d=this;let _;if(this.resourcePath!=="")_=this.resourcePath;else if(this.path!==""){const S=gX.extractUrlBase(r);_=gX.resolveURL(S,this.path)}else _=gX.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 ER(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))===Q4t){try{_[wf.KHR_BINARY_GLTF]=new fBr(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 wBr(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 Gjr;break;case wf.KHR_DRACO_MESH_COMPRESSION:_[w]=new dBr(d,this.dracoLoader);break;case wf.KHR_TEXTURE_TRANSFORM:_[w]=new pBr;break;case wf.KHR_MESH_QUANTIZATION:_[w]=new _Br;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 Wjr(){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 Hjr{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 fkt(k),S.distance=w;break;case"spot":S=new Fkr(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 Gjr{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 Qjr{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 Kjr{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 pkt(g,g)}return Promise.all(d)}}class Yjr{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 Xjr{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 Zjr{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 eBr{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 tBr{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 rBr{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 nBr{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 iBr{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 sBr{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 oBr{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 aBr{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 cBr{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 lBr{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 uBr{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 H8,ee=new Tc(1,1,1),xe=new Jqe(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 Rkr(fe.array,fe.itemSize,fe.normalized)}else ue!=="TRANSLATION"&&ue!=="ROTATION"&&ue!=="SCALE"&&j.geometry.setAttribute(ue,b[ue]);Mye.prototype.copy.call(xe,j),this.parser.assignFinalMaterial(xe),P.push(xe)}return k.isGroup?(k.clear(),k.add(...P),k):P[0]}))}}const Q4t="glTF",pY=12,m2t={JSON:1313821514,BIN:5130562};class fBr{constructor(r){this.name=wf.KHR_BINARY_GLTF,this.content=null,this.body=null;const i=new DataView(r,0,pY),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!==Q4t)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-pY,d=new DataView(r,pY);let _=0;for(;_<l;){const g=d.getUint32(_,!0);_+=4;const b=d.getUint32(_,!0);if(_+=4,b===m2t.JSON){const S=new Uint8Array(r,pY+_,g);this.content=a.decode(S)}else if(b===m2t.BIN){const S=pY+_;this.body=r.slice(S,S+g)}_+=g}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class dBr{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=aLe[k]||k.toLowerCase();g[w]=_[k]}for(const k in r.attributes){const w=aLe[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 pBr{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 _Br{constructor(){this.name=wf.KHR_MESH_QUANTIZATION}}class K4t extends Gkr{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 mBr=new H8;class hBr extends K4t{interpolate_(r,i,a,l){const d=super.interpolate_(r,i,a,l);return mBr.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},h2t={9728:nhe,9729:qR,9984:mkt,9985:Bkr,9986:jkr,9987:Lye},g2t={33071:qkr,33648:$kr,10497:h9e},i7e={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},aLe={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"},gBr={CUBICSPLINE:void 0,LINEAR:xkt,STEP:Jkr},s7e={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function yBr(t){return t.DefaultMaterial===void 0&&(t.DefaultMaterial=new ez({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:Hkr})),t.DefaultMaterial}function z7(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 vBr(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 bBr(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 ABr(t){let r;const i=t.extensions&&t.extensions[wf.KHR_DRACO_MESH_COMPRESSION];if(i?r="draco:"+i.bufferView+":"+i.indices+":"+o7e(i.attributes):r=t.indices+":"+o7e(t.attributes)+":"+t.mode,t.targets!==void 0)for(let a=0,l=t.targets.length;a<l;a++)r+=":"+o7e(t.targets[a]);return r}function o7e(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 cLe(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 SBr(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 xBr=new SS;class wBr{constructor(r={},i={}){this.json=r,this.extensions={},this.plugins={},this.options=i,this.cache=new Wjr,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 _kt(this.options.manager):this.textureLoader=new Mkr(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new ER(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 z7(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(gX.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 _=i7e[l.type],g=jq[l.componentType],b=l.normalized===!0,S=new g(l.count*_);return Promise.resolve(new hX(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=i7e[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 Lkr(J,P/k),i.cache.add(ee,xe)),X=new Wkr(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 hX(J,b,j);if(l.sparse!==void 0){const G=i7e.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 hX(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=h2t[N.magFilter]||qR,k.minFilter=h2t[N.minFilter]||Lye,k.wrapS=g2t[N.wrapS]||h9e,k.wrapT=g2t[N.wrapT]||h9e,k.generateMipmaps=!k.isCompressedTexture&&k.minFilter!==nhe&&k.minFilter!==qR,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(gX.resolveURL(w,d.path),j,void 0,P)})}).then(function(w){return S===!0&&g.revokeObjectURL(b),Hk(w,_),w.userData.mimeType=_.mimeType||SBr(_.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 hkt,gFe.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 zkr,gFe.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 ez}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=gkt);const k=d.alphaMode||s7e.OPAQUE;if(k===s7e.BLEND?(g.transparent=!0,g.depthWrite=!1):(g.transparent=!1,k===s7e.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 pkt(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&&z7(l,w,d),w})}createUniqueName(r){const i=ihe.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 y2t(b,g,i)})}const _=[];for(let g=0,b=r.length;g<b;g++){const S=r[g],k=ABr(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=y2t(new Hqe,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?yBr(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 ykt(J,ee):new NA(J,ee),G.isSkinnedMesh===!0&&G.normalizeSkinWeights(),X.mode===fw.TRIANGLE_STRIP?G.geometry=_2t(G.geometry,dkt):X.mode===fw.TRIANGLE_FAN&&(G.geometry=_2t(G.geometry,m9e));else if(X.mode===fw.LINES)G=new vkt(J,ee);else if(X.mode===fw.LINE_STRIP)G=new bkt(J,ee);else if(X.mode===fw.LINE_LOOP)G=new Akt(J,ee);else if(X.mode===fw.POINTS)G=new Gqe(J,ee);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+X.mode);Object.keys(G.geometry.morphAttributes).length>0&&bBr(G,d),G.name=i.createUniqueName(d.name||"mesh_"+r),Hk(G,d),X.extensions&&z7(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&&z7(l,w[0],d),w[0];const N=new SP;d.extensions&&z7(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 jye(vb.radToDeg(l.yfov),l.aspectRatio||1,l.znear||1,l.zfar||2e6):a.type==="orthographic"&&(i=new Bye(-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 Ukr(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 Vkr(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,xBr)});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 Skt:S.length>1?k=new SP:S.length===1?k=S[0]:k=new Mye,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&&z7(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&&z7(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 gFe||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=R1t;break;case PN.rotation:S=M1t;break;case PN.translation:case PN.scale:S=F1t;break;default:switch(a.itemSize){case 1:S=R1t;break;case 2:case 3:default:S=F1t;break}break}const k=l.interpolation!==void 0?gBr[l.interpolation]:xkt,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=cLe(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 M1t?hBr:K4t;return new l(this.times,this.values,this.getValueSize()/3,a)},r.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function CBr(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=cLe(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=cLe(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 wkt;l.getCenter(_.center),_.radius=l.min.distanceTo(l.max)/2,t.boundingSphere=_}function y2t(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=aLe[_]||_.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 sZ.workingColorSpace!==bE&&"COLOR_0"in a&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${sZ.workingColorSpace}" not supported.`),Hk(t,r),CBr(t,r,i),Promise.all(l).then(function(){return r.targets!==void 0?vBr(t,r.targets,i):t})}class EBr{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 TBr=0,v2t=2,kBr=1,b2t=2,IBr=0,DBr=1,PBr=10,NBr=0,Y4t=9,X4t=15,Z4t=16,e6t=22,t6t=37,r6t=43,n6t=76,i6t=83,s6t=97,o6t=100,a6t=103,c6t=109,l6t=122,u6t=123,f6t=131,d6t=132,p6t=133,_6t=134,m6t=137,h6t=138,g6t=139,y6t=140,v6t=141,b6t=142,A6t=145,S6t=146,x6t=148,w6t=152,C6t=157,E6t=158,T6t=165,k6t=166,I6t=1000054e3,D6t=1000054001,P6t=1000054004,N6t=1000054005,NUe=1000066e3,O6t=1000066004;class _Y{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 pb=[171,75,84,88,32,50,48,187,13,10,26,10];function A2t(t){return new TextDecoder().decode(t)}function OBr(t){const r=new Uint8Array(t.buffer,t.byteOffset,pb.length);if(r[0]!==pb[0]||r[1]!==pb[1]||r[2]!==pb[2]||r[3]!==pb[3]||r[4]!==pb[4]||r[5]!==pb[5]||r[6]!==pb[6]||r[7]!==pb[7]||r[8]!==pb[8]||r[9]!==pb[9]||r[10]!==pb[10]||r[11]!==pb[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 _Y(t,pb.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 _Y(t,pb.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 _Y(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 _Y(t,g,b,!0);for(;ue._offset<b;){const on=ue._nextUint32(),gr=ue._scan(on),An=A2t(gr);if(i.keyValue[An]=ue._nextUint8Array(on-gr.byteLength-1),An.match(/^ktx/i)){const Rn=A2t(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 _Y(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 a7e,Y3,lLe;const c7e={env:{emscripten_notify_memory_growth:function(t){lLe=new Uint8Array(Y3.exports.memory.buffer)}}};let FBr=class{init(){return a7e||(a7e=typeof fetch<"u"?fetch("data:application/wasm;base64,"+S2t).then(r=>r.arrayBuffer()).then(r=>WebAssembly.instantiate(r,c7e)).then(this._init):WebAssembly.instantiate(Buffer.from(S2t,"base64"),c7e).then(this._init),a7e)}_init(r){Y3=r.instance,c7e.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);lLe.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=lLe.slice(d,d+_);return Y3.exports.free(l),Y3.exports.free(d),g}};const S2t="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",RBr="display-p3",MBr="display-p3-linear";({...sZ.spaces[hv]});const l7e=new WeakMap;let u7e=0,f7e;class gw extends Wqe{constructor(r){super(r),this.transcoderPath="",this.transcoderBinary=null,this.transcoderPending=null,this.workerPool=new EBr,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 ER(this.manager);r.setPath(this.transcoderPath),r.setWithCredentials(this.withCredentials);const i=r.loadAsync("basis_transcoder.js"),a=new ER(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})}),u7e>0&&console.warn("THREE.KTX2Loader: Multiple active KTX2 loaders may cause performance issues. Use a single KTX2Loader instance, or call .dispose() on old instances."),u7e++}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 ER(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(l7e.has(r))return l7e.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 Qkr(d,b,S);else{const N=d[0].mipmaps;w=i.layerCount>1?new Kkr(N,_,g,i.layerCount,b,S):new Ckt(N,_,g,b,S)}return w.minFilter=d[0].mipmaps.length===1?qR:Lye,w.magFilter=qR,w.generateMipmaps=!1,w.needsUpdate=!0,w.colorSpace=F6t(i),w.premultiplyAlpha=!!(k&kBr),w}async _createTexture(r,i={}){const a=OBr(new Uint8Array(r)),l=a.vkFormat===NUe&&a.dataFormatDescriptor[0].colorModel===167;if(!(a.vkFormat===NBr||l&&!this.workerConfig.astcHDRSupported))return jBr(a);const _=i,g=this.init().then(()=>this.workerPool.postMessage({type:"transcode",buffer:r,taskConfig:_},[r])).then(b=>this._createTextureFrom(b.data,a));return l7e.set(r,{promise:g}),g}dispose(){this.workerPool.dispose(),this.workerSourceURL&&URL.revokeObjectURL(this.workerSourceURL),u7e--}}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:R_e,RGB_BPTC_UNSIGNED_Format:oIr,RGBA_BPTC_Format:y9e,RGBA_ETC2_EAC_Format:Tkt,RGBA_PVRTC_4BPPV1_Format:g9e,RGBA_S3TC_DXT5_Format:sIr,RGB_ETC1_Format:iIr,RGB_ETC2_Format:Ekt,RGB_PVRTC_4BPPV1_Format:nIr,RGBA_S3TC_DXT1_Format:v9e};gw.EngineType={UnsignedByteType:Bp,HalfFloatType:QN,FloatType:yX};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 LBr=new Set([dq,b9e,MY,RY]),d7e={[c6t]:dq,[a6t]:MY,[o6t]:RY,[s6t]:dq,[i6t]:MY,[n6t]:RY,[r6t]:dq,[t6t]:dq,[e6t]:MY,[Z4t]:MY,[X4t]:RY,[Y4t]:RY,[u6t]:b9e,[l6t]:b9e,[w6t]:Tkt,[x6t]:Ekt,[NUe]:R_e,[E6t]:R_e,[C6t]:R_e,[O6t]:yFe,[k6t]:yFe,[T6t]:yFe,[_6t]:v9e,[p6t]:v9e,[d6t]:$1t,[f6t]:$1t,[h6t]:B1t,[m6t]:B1t,[y6t]:eIr,[g6t]:Zkr,[b6t]:Xkr,[v6t]:Ykr,[S6t]:y9e,[A6t]:y9e,[N6t]:g9e,[D6t]:g9e,[P6t]:j1t,[I6t]:j1t},j$={[c6t]:yX,[a6t]:yX,[o6t]:yX,[s6t]:QN,[i6t]:QN,[n6t]:QN,[r6t]:Bp,[t6t]:Bp,[e6t]:Bp,[Z4t]:Bp,[X4t]:Bp,[Y4t]:Bp,[u6t]:Ikt,[l6t]:kkt,[w6t]:Bp,[x6t]:Bp,[NUe]:QN,[E6t]:Bp,[C6t]:Bp,[O6t]:QN,[k6t]:Bp,[T6t]:Bp,[_6t]:Bp,[p6t]:Bp,[d6t]:Bp,[f6t]:Bp,[h6t]:Bp,[m6t]:Bp,[y6t]:Bp,[g6t]:Bp,[b6t]:Bp,[v6t]:Bp,[S6t]:Bp,[A6t]:Bp,[N6t]:Bp,[D6t]:Bp,[P6t]:Bp,[I6t]:Bp};async function jBr(t){const{vkFormat:r}=t;if(d7e[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===v2t&&(f7e||(f7e=new Promise(async _=>{const g=new FBr;await g.init(),_(g)})),i=await f7e);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===TBr)w=k.levelData;else if(t.supercompressionScheme===v2t)w=i.decode(k.levelData,k.uncompressedByteLength);else throw new Error("THREE.KTX2Loader: Unsupported supercompressionScheme.");let N;j$[r]===yX?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]===Ikt||j$[r]===kkt?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(LBr.has(d7e[r]))d=t.pixelDepth===0?new tIr(a[0].data,t.pixelWidth,t.pixelHeight):new rIr(a[0].data,t.pixelWidth,t.pixelHeight,t.pixelDepth),d.minFilter=l?mkt:nhe,d.magFilter=nhe,d.generateMipmaps=t.levelCount===0;else{if(t.pixelDepth>0)throw new Error("THREE.KTX2Loader: Unsupported pixelDepth.");d=new Ckt(a,t.pixelWidth,t.pixelHeight),d.minFilter=l?Lye:qR,d.magFilter=qR}return d.mipmaps=a,d.type=j$[r],d.format=d7e[r],d.colorSpace=F6t(t),d.needsUpdate=!0,Promise.resolve(d)}function F6t(t){const r=t.dataFormatDescriptor[0];return r.colorPrimaries===DBr?r.transferFunction===b2t?hv:bE:r.colorPrimaries===PBr?r.transferFunction===b2t?RBr:MBr:r.colorPrimaries===IBr?L1t:(console.warn(`THREE.KTX2Loader: Unsupported color primaries, "${r.colorPrimaries}"`),L1t)}let BBr="/";function R6t(t){return t.startsWith("/")||t.startsWith("http")||t.startsWith("data:")||t.startsWith("blob:")?t:BBr+t}const Nee=new aIr;Nee.setURLModifier(R6t);new _kt(Nee);const M6t=new Ujr(Nee);M6t.setDecoderPath("/jsm/libs/draco/gltf/");const L6t=new gw(Nee);L6t.setTranscoderPath("/jsm/libs/basis/");const uU=new Jjr(Nee);uU.setDRACOLoader(M6t);uU.setKTX2Loader(L6t);uU.setMeshoptDecoder(zjr);function Oee(t){return R6t(t)}const Upe=new Map;async function j6t(t,r){let i=Upe.get(t);!i&&r&&(i=Promise.resolve(r),Upe.set(t,i)),i||(i=fetch(Oee(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())}),Upe.set(t,i));try{const[{SplatMesh:a},l]=await Promise.all([la(()=>import("./spark.module-uQlq--TY.js"),__vite__mapDeps([46,6,3,2,4,1,8,9,10,11])),i]),d=new a({fileBytes:l,fileName:t,raycastable:!0});await d.initialized,wZ(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 lkt(g.x,g.y,g.z));S.name="__vgai_splat_bounds",S.position.copy(b),S.visible=!1,S.raycast=()=>{},wZ(S,"engineInternal",!0),d.add(S)}return d}catch(a){throw Upe.delete(t),a}}const Xhe=1.2,B6t=.001;function uLe(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 $6t(){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 OUe(t){return t.maxRight<t.minRight}function $Br(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 q6t(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 qBr(t,r){if(OUe(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 z6t(t,r,i,a=Xhe){const l=Math.max(r,t/i,B6t)*a;return{halfHeight:l,halfWidth:l*i}}function zBr(t,r,i=Xhe){if(OUe(t))throw new Error("Asset preview cannot frame an empty projected span.");return z6t((t.maxRight-t.minRight)/2,(t.maxUp-t.minUp)/2,r,i)}function UBr(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 VBr(t,r,i,a,l,d){const _=Math.max(a*l,B6t);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 JBr(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 WBr(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 HBr(t,r){return OUe(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 FUe(t,r,i,a,l){const d=new Bye(-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 GBr={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 U6t(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=GBr[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 QBr=.45,V6t=.25,Zhe=new WeakMap;function Fee(t,r){let i=Zhe.get(r);i||(i=W4t(r),Zhe.set(r,i)),t.environment=i.texture,t.environmentIntensity=QBr}function F0e(t){const r=Zhe.get(t);r&&(Zhe.delete(t),r.dispose())}const CZ=["front","right","top","perspective"],x2t=24;function J6t(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 W6t(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 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.meters=="number"&&Number.isFinite(r.meters)}function KBr(t){return J6t(t)||W6t(t)||H6t(t)}function YBr(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 XBr(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(KBr))&&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>x2t)&&r(`\`shots\` must list 1-${x2t} shots.`);const _=a.shots,g=new Set;for(const b of _){YBr(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 ZBr=512,w2t=64,C2t=1024,fU=2106410,e$r=25e3,mR=64*1024*1024;function ww(t){const r=t??ZBr;if(!Number.isInteger(r)||r<w2t||r>C2t)throw new Error(`Asset preview dimensions must be integers from ${w2t} to ${C2t}.`);return r}function AS(t){const r=t.toDataURL("image/png"),i=r.indexOf(",");return i>=0?r.slice(i+1):r}function zDn(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 mz(t){const r=new Set;t.traverse(_=>{r.add(_)});const i=r$r(t,r),a=n$r(t,i),l=t$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 t$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 r$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 n$r(t,r=new Map){const i=new Map,a=[],l=_=>{const g=i$r(_);i.set(_,g),s$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(p7e(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)&&!p7e(P)&&g.add(l(P))}else for(const S of _.children)p7e(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 i$r(t){const r=t;if(r.isSkinnedMesh)return new ykt(r.geometry,r.material);const i=t;if(i.isInstancedMesh){const g=new Jqe(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 vkt(l.geometry,l.material);if(t.isLineLoop)return new Akt(l.geometry,l.material);if(l.isLine)return new bkt(l.geometry,l.material);const d=t;if(d.isPoints)return new Gqe(d.geometry,d.material);const _=t;return _.isSprite?new cIr(_.material):t.isLOD?new lIr:t.isBone?new Skt:t.isGroup?new SP:new Mye}function s$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 p7e(t){const r=1<<DUe;return!!(t.userData.editorHelper||t.userData.editorIcon||(t.layers.mask&r)!==0)}function dU(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 UDn(t){const r=t();let i;try{i=mz(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{dU(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"){RUe(t);const i=o$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 RUe(t){t.parent?.updateWorldMatrix(!0,!1),t.updateMatrixWorld(!0)}function o$r(t,r){const i=new xS;return MUe(t,R0e(r),r==="perspective",a=>i.expandByPoint(a)),i}function a$r(t,r){const i=r.map(()=>$6t());return r.length===0||(RUe(t),MUe(t,r[0],!1,a=>{for(let l=0;l<r.length;l++)q6t(i[l],a,r[l])})),i}function c$r(t,r){const i=r.map(()=>0);let a=0;if(r.length===0)return{framed:i,total:a};RUe(t);const l=r.map(()=>$6t());let d=-1;const _=()=>{if(!(d<0)){a++;for(let g=0;g<r.length;g++)HBr(l[g],r[g].window)&&i[g]++,$Br(l[g])}};return MUe(t,r[0].basis,!1,(g,b)=>{b!==d&&(_(),d=b);for(let S=0;S<r.length;S++)q6t(l[S],g,r[S].basis)}),_(),{framed:i,total:a}}function MUe(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&&O0e(k))return;if(X8(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=l$r(k,P,j.count),X=u$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,_):d$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 l$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=f$r(t,k-S);for(let N=S;N<S+w;N++)b.push(r.index?r.index.getX(N):N)}return b}function u$r(t,r){return t.isMesh?3:t.isLineSegments?2:t.isLine?Math.max(r,1):1}function f$r(t,r){return t.isMesh?r-r%3:t.isLineSegments?r-r%2:t.isLine?r>=2?r:0:r}function d$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 p$r(t,r,i){const{center:a,size:l,radius:d}=r;let _=l.x,g=l.y;const b=R0e(t),{direction:S,up:k}=b;t==="right"?_=l.z:t==="top"&&(_=l.x,g=l.z);const w=z6t(_/2,g/2,i);return FUe(a,{direction:S,right:b.right,up:k},w,d*3+1,d*10+10)}function ege(t,r,i,a){const l=new jye(35,r,.01,t.radius*20+20),d=vb.degToRad(l.fov/2),_=Math.atan(Math.tan(d)*r),g=R0e("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))*Xhe/Math.tan(_),ee+Math.abs(G.dot(w))*Xhe/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 R0e(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 LUe(t,r,i){return t==="perspective"?ege(r,i):p$r(t,r,i)}function E2t(t,r,i){return ege(t,r,i)}function G6t(t,r,i,a){const l=i.map(uLe),d=a$r(t,l),_=UBr(d.map(b=>zBr(b,a))),g=new Map;return i.forEach((b,S)=>{g.set(b,FUe(qBr(d[S],l[S]),l[S],_,r.radius*3+1,r.radius*10+10))}),g}function Q6t(t,r,i={}){const a=ww(i.width),l=ww(i.height),d=i.background??"neutral",_=mz(t);let g=null;try{const b=LP(_,"perspective"),S=EZ(_,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(fU,d==="transparent"?0:1),k.setSize(a,l,!1),Fee(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=G6t(_,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:E2t(b,N,P(w-Math.PI/4))},{label:"quarter-right",camera:E2t(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&&F0e(g),g?.dispose(),g?.forceContextLoss(),dU(_)}}function _$r(t,r,i,a,l){const d=JBr(t),_=VBr(t,d,r,i,a,l),g=i*3+1;return FUe(d,r,_,g,g+i*4+1)}function T2t(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 m$r(t,r,i){const a=i.filter(W6t);for(const l of i)if(J6t(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(H6t(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 tge(t){let r=null;return t.traverse(i=>{r||(r=ome(i.userData.forward))}),r??[0,0,1]}function fLe(t,r){const i=new SP;return i.rotation.y=IUe(r),i.add(t),i.updateMatrixWorld(!0),i}function EZ(t,r){const i=new Rye;i.add(t),i.add(new fIr(16777215,3489874,1.8*V6t));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 oR=null;function k2t(){const t=oR;oR=null,t&&(F0e(t),t.dispose(),t.forceContextLoss())}function h$r(){if(oR?.getContext().isContextLost()&&k2t(),!oR){const t=UP(new $P({antialias:!0,alpha:!0,preserveDrawingBuffer:!0}));oR=t,t.domElement.addEventListener("webglcontextlost",()=>{oR===t&&k2t()})}return oR}function M0e(t,r={}){let i=!1;if(t.traverse(g=>{X8(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",_=mz(t);try{const g=tge(t);r.pose&&y$r(_,r.pose);const b=fLe(_,g),S=jUe(g),k=LP(b,"perspective"),w=EZ(b,k),N=h$r();if(N.setPixelRatio(1),N.outputColorSpace=hv,N.toneMapping=u9,N.toneMappingExposure=1,N.setClearColor(fU,d==="transparent"?0:1),Fee(w,N),r.camera)return v$r(N,w,ege(k,a/l,I2t(r.camera),r.camera.distance),a,l,r.camera,S);const P=new Map;for(const J of CZ)P.set(J,LUe(J,LP(b,J),a/l));const j=ege(k,a/l,I2t({azimuthDegrees:30,elevationDegrees:-60}));return Y6t(N,w,P,a,l,S,j)}finally{dU(_)}}function g$r(t,r,i){const a=K6t(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 _=U6t(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 jUe(t){const r=IUe(t);return{forward:[t[0],t[1],t[2]],yawDegrees:Math.round(vb.radToDeg(r))}}function y$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 uIr(t);l.clipAction(a).play(),l.update(r.timeSeconds),t.updateMatrixWorld(!0)}function I2t(t){const r=vb.degToRad(t.azimuthDegrees),i=vb.degToRad(t.elevationDegrees);return new Tc(Math.sin(r)*Math.cos(i),Math.sin(i),Math.cos(r)*Math.cos(i)).normalize()}function v$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 K6t(t,r){if(t==="perspective")return null;const i=vb.degToRad(r),a=R0e(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 Y6t(t,r,i,a,l,d,_){const g=[],b=_?[...CZ,"below"]:[...CZ],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(fU).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:g$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=K6t(J,d.yawDegrees);if(de){const ge=U6t(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 b$r(t,r,i={}){let a=!1;if(t.traverse(S=>{X8(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&&PUe(w)&&(w.visible=!1,g.push(w))});const S=new Map;for(const w of CZ){const N=LUe(w,LP(t,w),l/d);N.layers.enableAll(),N.layers.disable(DUe),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(fU,_==="transparent"?0:1),Y6t(k,r,S,l,d,jUe([0,0,1]))}finally{for(const S of g)S.visible=!0;b?.dispose(),b?.forceContextLoss()}}function A$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 S$r(t,r,i){const a=[],l=()=>{for(const d of a)dU(d);a.length=0};try{const d=mz(t);a.push(d);const _=T2t(d,r),g=tge(t),b=fLe(d,g),S=LP(b,"perspective"),k=EZ(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=mz(t);a.push(se);const de=T2t(se,r);m$r(se,de,fe),se.updateMatrixWorld(!0);const ge=fLe(se,g),qe=LP(ge,"perspective");N.set(ue.pose,{subject:ge,scene:EZ(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,G6t(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:uLe(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=uLe(ue.yaw??0);return{label:ue.label,camera:_$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}=c$r(ue.subject,fe.map(ge=>{const qe=X[ge];return{basis:qe.basis,window:WBr(qe.camera,qe.basis)}}));fe.forEach((ge,qe)=>{if(se[qe]!==0)return;const tt=A$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 BUe(t,r,i={}){const a=ww(i.width),l=ww(i.height),d=i.background??"neutral",_=S$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(fU,d==="transparent"?0:1),b.setSize(a,l,!1);for(const G of _.shots)Fee(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&&F0e(g),g?.dispose(),g?.forceContextLoss(),_.dispose()}}function x$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 X6t(t,r,i=mR){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 ${mR/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 ${mR/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 ${mR/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 D2t(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}uU.parse(t,new URL(".",r).href,b=>{b.scene.animations=[...b.animations],_(()=>a(b.scene))||Z8(b.scene)},b=>_(()=>l(b)))})}function w$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 C$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 E$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=w$r(_.uri,r),b=await X6t(g,i,mR-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:${C$r(_,g)};base64,${btoa(k)}`}return JSON.stringify(a)}function $Ue(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>mR)throw new Error(`${r} must be non-empty and at most ${mR/1024/1024} MiB.`);return new Promise((a,l)=>{uU.parse(i.buffer,"",d=>{d.scene.animations=[...d.animations],a(d.scene)},d=>l(d instanceof Error?d:new Error(String(d))))})}async function T$r(t,r={}){const i=await $Ue(t,"Asset preview GLB bytes");try{return M0e(i,r)}finally{Z8(i)}}async function k$r(t,r,i={}){const a=await $Ue(t,"Asset preview GLB bytes");try{return BUe(a,r,i)}finally{Z8(a)}}async function I$r(t,r){const i=x$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.")),e$r);try{const _=await X6t(i,a.signal);if(a.signal.throwIfAborted(),i.pathname.toLowerCase().endsWith(".spz"))return{root:await j6t(t,new Uint8Array(_)),sourceBytes:null};if(i.pathname.toLowerCase().endsWith(".glb")){const b=new Uint8Array(_.slice(0));return{root:await D2t(_,i,a.signal),sourceBytes:b}}const g=await E$r(_,i,a.signal);return{root:await D2t(g,i,a.signal),sourceBytes:null}}finally{globalThis.clearTimeout(d),r?.removeEventListener("abort",l)}}async function L0e(t,r){return(await I$r(t,r)).root}function Z8(t){X8(t,"gaussianSplat")&&t.dispose(),dU(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 Z6t(t,r={}){const i=await L0e(t);try{return X8(i,"gaussianSplat")?await P$r(i,r):M0e(i,r)}finally{Z8(i)}}async function D$r(t,r,i={}){const a=await L0e(t);try{return Q6t(a,r,i)}finally{Z8(a)}}async function P$r(t,r){const i=ww(r.width),a=ww(r.height),l=r.background??"neutral",d=LP(t,"perspective"),_=EZ(t,d),g=UP(new $P({antialias:!1,alpha:!0,preserveDrawingBuffer:!0}));let b=null;try{const S=await la(()=>import("./spark.module-uQlq--TY.js"),__vite__mapDeps([46,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(fU,l==="transparent"?0:1),g.setSize(i,a,!1),Fee(_,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 CZ.entries()){const J=LUe(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:jUe([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(),F0e(g),g.dispose(),g.forceContextLoss()}}async function N$r(t,r,i={}){const a=await L0e(t);try{return BUe(a,r,i)}finally{Z8(a)}}const P2t=0,O$r=16777215,N2t=10;function F$r(t){return $Ue(t,"Compare reference GLB")}function O2t(t,r){const i=mz(t),a=new SP;a.rotation.y=IUe(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=$jr(_,g);return l.scale.setScalar(b.scale),l.position.set(...b.position),l.updateWorldMatrix(!0,!0),{wrapper:l,dispose:()=>dU(i)}}function R$r(t,r){const i=Njr,a=i*r,l=new Bye(-a,a,i,-i,.01,N2t*4),d=t==="front"?new Tc(0,0,1):new Tc(1,0,0);return l.position.set(0,p2t,0).addScaledVector(d,N2t),l.up.set(0,1,0),l.lookAt(0,p2t,0),l.updateProjectionMatrix(),l.updateMatrixWorld(!0),l}function M$r(t,r,i={}){const a=ww(i.width),l=ww(i.height),d=a/l,_=[];let g=null;try{const b=O2t(t,tge(t));_.push(b.dispose);const S=O2t(r,i.refForward??tge(r));_.push(S.dispose);const k=new fq({color:O$r});_.push(()=>k.dispose());const w=fe=>{const se=new Rye;return se.background=new vE(P2t),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=Dkt,j.setClearColor(P2t,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=Ljr(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 Pjr){const se=R$r(fe,d),de=G(N,se,"asset",fe),ge=G(P,se,"reference",fe),qe=jjr(de.mask,ge.mask);xe.putImageData(new ImageData(Bjr(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 L$r(t,r,i={}){const a=await L0e(t);try{return await eNt(a,r,i)}finally{Z8(a)}}async function eNt(t,r,i={}){const a=await F$r(r);try{return M$r(t,a,i)}finally{Z8(a)}}let u8=null,tNt=0;const dLe=new Set;function rNt(){tNt++;for(const t of dLe)t()}function j0e(t){return dLe.add(t),()=>{dLe.delete(t)}}function TZ(){return tNt}function B0e(){return u8}function YN(t){u8&&JSON.stringify(u8)===JSON.stringify(t)||(u8=t,rNt())}function pP(){u8!==null&&(u8=null,rNt())}function _7e(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})}),u7e>0&&console.warn("THREE.KTX2Loader: Multiple active KTX2 loaders may cause performance issues. Use a single KTX2Loader instance, or call .dispose() on old instances."),u7e++}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 ER(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(l7e.has(r))return l7e.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 Qkr(d,b,S);else{const N=d[0].mipmaps;w=i.layerCount>1?new Kkr(N,_,g,i.layerCount,b,S):new Ckt(N,_,g,b,S)}return w.minFilter=d[0].mipmaps.length===1?qR:Lye,w.magFilter=qR,w.generateMipmaps=!1,w.needsUpdate=!0,w.colorSpace=F6t(i),w.premultiplyAlpha=!!(k&kBr),w}async _createTexture(r,i={}){const a=OBr(new Uint8Array(r)),l=a.vkFormat===NUe&&a.dataFormatDescriptor[0].colorModel===167;if(!(a.vkFormat===NBr||l&&!this.workerConfig.astcHDRSupported))return jBr(a);const _=i,g=this.init().then(()=>this.workerPool.postMessage({type:"transcode",buffer:r,taskConfig:_},[r])).then(b=>this._createTextureFrom(b.data,a));return l7e.set(r,{promise:g}),g}dispose(){this.workerPool.dispose(),this.workerSourceURL&&URL.revokeObjectURL(this.workerSourceURL),u7e--}}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:R_e,RGB_BPTC_UNSIGNED_Format:oIr,RGBA_BPTC_Format:y9e,RGBA_ETC2_EAC_Format:Tkt,RGBA_PVRTC_4BPPV1_Format:g9e,RGBA_S3TC_DXT5_Format:sIr,RGB_ETC1_Format:iIr,RGB_ETC2_Format:Ekt,RGB_PVRTC_4BPPV1_Format:nIr,RGBA_S3TC_DXT1_Format:v9e};gw.EngineType={UnsignedByteType:Bp,HalfFloatType:QN,FloatType:yX};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 LBr=new Set([dq,b9e,MY,RY]),d7e={[c6t]:dq,[a6t]:MY,[o6t]:RY,[s6t]:dq,[i6t]:MY,[n6t]:RY,[r6t]:dq,[t6t]:dq,[e6t]:MY,[Z4t]:MY,[X4t]:RY,[Y4t]:RY,[u6t]:b9e,[l6t]:b9e,[w6t]:Tkt,[x6t]:Ekt,[NUe]:R_e,[E6t]:R_e,[C6t]:R_e,[O6t]:yFe,[k6t]:yFe,[T6t]:yFe,[_6t]:v9e,[p6t]:v9e,[d6t]:$1t,[f6t]:$1t,[h6t]:B1t,[m6t]:B1t,[y6t]:eIr,[g6t]:Zkr,[b6t]:Xkr,[v6t]:Ykr,[S6t]:y9e,[A6t]:y9e,[N6t]:g9e,[D6t]:g9e,[P6t]:j1t,[I6t]:j1t},j$={[c6t]:yX,[a6t]:yX,[o6t]:yX,[s6t]:QN,[i6t]:QN,[n6t]:QN,[r6t]:Bp,[t6t]:Bp,[e6t]:Bp,[Z4t]:Bp,[X4t]:Bp,[Y4t]:Bp,[u6t]:Ikt,[l6t]:kkt,[w6t]:Bp,[x6t]:Bp,[NUe]:QN,[E6t]:Bp,[C6t]:Bp,[O6t]:QN,[k6t]:Bp,[T6t]:Bp,[_6t]:Bp,[p6t]:Bp,[d6t]:Bp,[f6t]:Bp,[h6t]:Bp,[m6t]:Bp,[y6t]:Bp,[g6t]:Bp,[b6t]:Bp,[v6t]:Bp,[S6t]:Bp,[A6t]:Bp,[N6t]:Bp,[D6t]:Bp,[P6t]:Bp,[I6t]:Bp};async function jBr(t){const{vkFormat:r}=t;if(d7e[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===v2t&&(f7e||(f7e=new Promise(async _=>{const g=new FBr;await g.init(),_(g)})),i=await f7e);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===TBr)w=k.levelData;else if(t.supercompressionScheme===v2t)w=i.decode(k.levelData,k.uncompressedByteLength);else throw new Error("THREE.KTX2Loader: Unsupported supercompressionScheme.");let N;j$[r]===yX?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]===Ikt||j$[r]===kkt?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(LBr.has(d7e[r]))d=t.pixelDepth===0?new tIr(a[0].data,t.pixelWidth,t.pixelHeight):new rIr(a[0].data,t.pixelWidth,t.pixelHeight,t.pixelDepth),d.minFilter=l?mkt:nhe,d.magFilter=nhe,d.generateMipmaps=t.levelCount===0;else{if(t.pixelDepth>0)throw new Error("THREE.KTX2Loader: Unsupported pixelDepth.");d=new Ckt(a,t.pixelWidth,t.pixelHeight),d.minFilter=l?Lye:qR,d.magFilter=qR}return d.mipmaps=a,d.type=j$[r],d.format=d7e[r],d.colorSpace=F6t(t),d.needsUpdate=!0,Promise.resolve(d)}function F6t(t){const r=t.dataFormatDescriptor[0];return r.colorPrimaries===DBr?r.transferFunction===b2t?hv:bE:r.colorPrimaries===PBr?r.transferFunction===b2t?RBr:MBr:r.colorPrimaries===IBr?L1t:(console.warn(`THREE.KTX2Loader: Unsupported color primaries, "${r.colorPrimaries}"`),L1t)}let BBr="/";function R6t(t){return t.startsWith("/")||t.startsWith("http")||t.startsWith("data:")||t.startsWith("blob:")?t:BBr+t}const Nee=new aIr;Nee.setURLModifier(R6t);new _kt(Nee);const M6t=new Ujr(Nee);M6t.setDecoderPath("/jsm/libs/draco/gltf/");const L6t=new gw(Nee);L6t.setTranscoderPath("/jsm/libs/basis/");const uU=new Jjr(Nee);uU.setDRACOLoader(M6t);uU.setKTX2Loader(L6t);uU.setMeshoptDecoder(zjr);function Oee(t){return R6t(t)}const Upe=new Map;async function j6t(t,r){let i=Upe.get(t);!i&&r&&(i=Promise.resolve(r),Upe.set(t,i)),i||(i=fetch(Oee(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())}),Upe.set(t,i));try{const[{SplatMesh:a},l]=await Promise.all([la(()=>import("./spark.module-B_-x7Z29.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,wZ(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 lkt(g.x,g.y,g.z));S.name="__vgai_splat_bounds",S.position.copy(b),S.visible=!1,S.raycast=()=>{},wZ(S,"engineInternal",!0),d.add(S)}return d}catch(a){throw Upe.delete(t),a}}const Xhe=1.2,B6t=.001;function uLe(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 $6t(){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 OUe(t){return t.maxRight<t.minRight}function $Br(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 q6t(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 qBr(t,r){if(OUe(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 z6t(t,r,i,a=Xhe){const l=Math.max(r,t/i,B6t)*a;return{halfHeight:l,halfWidth:l*i}}function zBr(t,r,i=Xhe){if(OUe(t))throw new Error("Asset preview cannot frame an empty projected span.");return z6t((t.maxRight-t.minRight)/2,(t.maxUp-t.minUp)/2,r,i)}function UBr(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 VBr(t,r,i,a,l,d){const _=Math.max(a*l,B6t);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 JBr(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 WBr(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 HBr(t,r){return OUe(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 FUe(t,r,i,a,l){const d=new Bye(-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 GBr={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 U6t(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=GBr[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 QBr=.45,V6t=.25,Zhe=new WeakMap;function Fee(t,r){let i=Zhe.get(r);i||(i=W4t(r),Zhe.set(r,i)),t.environment=i.texture,t.environmentIntensity=QBr}function F0e(t){const r=Zhe.get(t);r&&(Zhe.delete(t),r.dispose())}const CZ=["front","right","top","perspective"],x2t=24;function J6t(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 W6t(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 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.meters=="number"&&Number.isFinite(r.meters)}function KBr(t){return J6t(t)||W6t(t)||H6t(t)}function YBr(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 XBr(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(KBr))&&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>x2t)&&r(`\`shots\` must list 1-${x2t} shots.`);const _=a.shots,g=new Set;for(const b of _){YBr(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 ZBr=512,w2t=64,C2t=1024,fU=2106410,e$r=25e3,mR=64*1024*1024;function ww(t){const r=t??ZBr;if(!Number.isInteger(r)||r<w2t||r>C2t)throw new Error(`Asset preview dimensions must be integers from ${w2t} to ${C2t}.`);return r}function AS(t){const r=t.toDataURL("image/png"),i=r.indexOf(",");return i>=0?r.slice(i+1):r}function zDn(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 mz(t){const r=new Set;t.traverse(_=>{r.add(_)});const i=r$r(t,r),a=n$r(t,i),l=t$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 t$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 r$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 n$r(t,r=new Map){const i=new Map,a=[],l=_=>{const g=i$r(_);i.set(_,g),s$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(p7e(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)&&!p7e(P)&&g.add(l(P))}else for(const S of _.children)p7e(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 i$r(t){const r=t;if(r.isSkinnedMesh)return new ykt(r.geometry,r.material);const i=t;if(i.isInstancedMesh){const g=new Jqe(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 vkt(l.geometry,l.material);if(t.isLineLoop)return new Akt(l.geometry,l.material);if(l.isLine)return new bkt(l.geometry,l.material);const d=t;if(d.isPoints)return new Gqe(d.geometry,d.material);const _=t;return _.isSprite?new cIr(_.material):t.isLOD?new lIr:t.isBone?new Skt:t.isGroup?new SP:new Mye}function s$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 p7e(t){const r=1<<DUe;return!!(t.userData.editorHelper||t.userData.editorIcon||(t.layers.mask&r)!==0)}function dU(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 UDn(t){const r=t();let i;try{i=mz(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{dU(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"){RUe(t);const i=o$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 RUe(t){t.parent?.updateWorldMatrix(!0,!1),t.updateMatrixWorld(!0)}function o$r(t,r){const i=new xS;return MUe(t,R0e(r),r==="perspective",a=>i.expandByPoint(a)),i}function a$r(t,r){const i=r.map(()=>$6t());return r.length===0||(RUe(t),MUe(t,r[0],!1,a=>{for(let l=0;l<r.length;l++)q6t(i[l],a,r[l])})),i}function c$r(t,r){const i=r.map(()=>0);let a=0;if(r.length===0)return{framed:i,total:a};RUe(t);const l=r.map(()=>$6t());let d=-1;const _=()=>{if(!(d<0)){a++;for(let g=0;g<r.length;g++)HBr(l[g],r[g].window)&&i[g]++,$Br(l[g])}};return MUe(t,r[0].basis,!1,(g,b)=>{b!==d&&(_(),d=b);for(let S=0;S<r.length;S++)q6t(l[S],g,r[S].basis)}),_(),{framed:i,total:a}}function MUe(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&&O0e(k))return;if(X8(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=l$r(k,P,j.count),X=u$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,_):d$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 l$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=f$r(t,k-S);for(let N=S;N<S+w;N++)b.push(r.index?r.index.getX(N):N)}return b}function u$r(t,r){return t.isMesh?3:t.isLineSegments?2:t.isLine?Math.max(r,1):1}function f$r(t,r){return t.isMesh?r-r%3:t.isLineSegments?r-r%2:t.isLine?r>=2?r:0:r}function d$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 p$r(t,r,i){const{center:a,size:l,radius:d}=r;let _=l.x,g=l.y;const b=R0e(t),{direction:S,up:k}=b;t==="right"?_=l.z:t==="top"&&(_=l.x,g=l.z);const w=z6t(_/2,g/2,i);return FUe(a,{direction:S,right:b.right,up:k},w,d*3+1,d*10+10)}function ege(t,r,i,a){const l=new jye(35,r,.01,t.radius*20+20),d=vb.degToRad(l.fov/2),_=Math.atan(Math.tan(d)*r),g=R0e("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))*Xhe/Math.tan(_),ee+Math.abs(G.dot(w))*Xhe/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 R0e(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 LUe(t,r,i){return t==="perspective"?ege(r,i):p$r(t,r,i)}function E2t(t,r,i){return ege(t,r,i)}function G6t(t,r,i,a){const l=i.map(uLe),d=a$r(t,l),_=UBr(d.map(b=>zBr(b,a))),g=new Map;return i.forEach((b,S)=>{g.set(b,FUe(qBr(d[S],l[S]),l[S],_,r.radius*3+1,r.radius*10+10))}),g}function Q6t(t,r,i={}){const a=ww(i.width),l=ww(i.height),d=i.background??"neutral",_=mz(t);let g=null;try{const b=LP(_,"perspective"),S=EZ(_,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(fU,d==="transparent"?0:1),k.setSize(a,l,!1),Fee(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=G6t(_,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:E2t(b,N,P(w-Math.PI/4))},{label:"quarter-right",camera:E2t(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&&F0e(g),g?.dispose(),g?.forceContextLoss(),dU(_)}}function _$r(t,r,i,a,l){const d=JBr(t),_=VBr(t,d,r,i,a,l),g=i*3+1;return FUe(d,r,_,g,g+i*4+1)}function T2t(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 m$r(t,r,i){const a=i.filter(W6t);for(const l of i)if(J6t(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(H6t(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 tge(t){let r=null;return t.traverse(i=>{r||(r=ome(i.userData.forward))}),r??[0,0,1]}function fLe(t,r){const i=new SP;return i.rotation.y=IUe(r),i.add(t),i.updateMatrixWorld(!0),i}function EZ(t,r){const i=new Rye;i.add(t),i.add(new fIr(16777215,3489874,1.8*V6t));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 oR=null;function k2t(){const t=oR;oR=null,t&&(F0e(t),t.dispose(),t.forceContextLoss())}function h$r(){if(oR?.getContext().isContextLost()&&k2t(),!oR){const t=UP(new $P({antialias:!0,alpha:!0,preserveDrawingBuffer:!0}));oR=t,t.domElement.addEventListener("webglcontextlost",()=>{oR===t&&k2t()})}return oR}function M0e(t,r={}){let i=!1;if(t.traverse(g=>{X8(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",_=mz(t);try{const g=tge(t);r.pose&&y$r(_,r.pose);const b=fLe(_,g),S=jUe(g),k=LP(b,"perspective"),w=EZ(b,k),N=h$r();if(N.setPixelRatio(1),N.outputColorSpace=hv,N.toneMapping=u9,N.toneMappingExposure=1,N.setClearColor(fU,d==="transparent"?0:1),Fee(w,N),r.camera)return v$r(N,w,ege(k,a/l,I2t(r.camera),r.camera.distance),a,l,r.camera,S);const P=new Map;for(const J of CZ)P.set(J,LUe(J,LP(b,J),a/l));const j=ege(k,a/l,I2t({azimuthDegrees:30,elevationDegrees:-60}));return Y6t(N,w,P,a,l,S,j)}finally{dU(_)}}function g$r(t,r,i){const a=K6t(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 _=U6t(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 jUe(t){const r=IUe(t);return{forward:[t[0],t[1],t[2]],yawDegrees:Math.round(vb.radToDeg(r))}}function y$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 uIr(t);l.clipAction(a).play(),l.update(r.timeSeconds),t.updateMatrixWorld(!0)}function I2t(t){const r=vb.degToRad(t.azimuthDegrees),i=vb.degToRad(t.elevationDegrees);return new Tc(Math.sin(r)*Math.cos(i),Math.sin(i),Math.cos(r)*Math.cos(i)).normalize()}function v$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 K6t(t,r){if(t==="perspective")return null;const i=vb.degToRad(r),a=R0e(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 Y6t(t,r,i,a,l,d,_){const g=[],b=_?[...CZ,"below"]:[...CZ],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(fU).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:g$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=K6t(J,d.yawDegrees);if(de){const ge=U6t(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 b$r(t,r,i={}){let a=!1;if(t.traverse(S=>{X8(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&&PUe(w)&&(w.visible=!1,g.push(w))});const S=new Map;for(const w of CZ){const N=LUe(w,LP(t,w),l/d);N.layers.enableAll(),N.layers.disable(DUe),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(fU,_==="transparent"?0:1),Y6t(k,r,S,l,d,jUe([0,0,1]))}finally{for(const S of g)S.visible=!0;b?.dispose(),b?.forceContextLoss()}}function A$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 S$r(t,r,i){const a=[],l=()=>{for(const d of a)dU(d);a.length=0};try{const d=mz(t);a.push(d);const _=T2t(d,r),g=tge(t),b=fLe(d,g),S=LP(b,"perspective"),k=EZ(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=mz(t);a.push(se);const de=T2t(se,r);m$r(se,de,fe),se.updateMatrixWorld(!0);const ge=fLe(se,g),qe=LP(ge,"perspective");N.set(ue.pose,{subject:ge,scene:EZ(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,G6t(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:uLe(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=uLe(ue.yaw??0);return{label:ue.label,camera:_$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}=c$r(ue.subject,fe.map(ge=>{const qe=X[ge];return{basis:qe.basis,window:WBr(qe.camera,qe.basis)}}));fe.forEach((ge,qe)=>{if(se[qe]!==0)return;const tt=A$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 BUe(t,r,i={}){const a=ww(i.width),l=ww(i.height),d=i.background??"neutral",_=S$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(fU,d==="transparent"?0:1),b.setSize(a,l,!1);for(const G of _.shots)Fee(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&&F0e(g),g?.dispose(),g?.forceContextLoss(),_.dispose()}}function x$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 X6t(t,r,i=mR){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 ${mR/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 ${mR/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 ${mR/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 D2t(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}uU.parse(t,new URL(".",r).href,b=>{b.scene.animations=[...b.animations],_(()=>a(b.scene))||Z8(b.scene)},b=>_(()=>l(b)))})}function w$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 C$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 E$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=w$r(_.uri,r),b=await X6t(g,i,mR-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:${C$r(_,g)};base64,${btoa(k)}`}return JSON.stringify(a)}function $Ue(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>mR)throw new Error(`${r} must be non-empty and at most ${mR/1024/1024} MiB.`);return new Promise((a,l)=>{uU.parse(i.buffer,"",d=>{d.scene.animations=[...d.animations],a(d.scene)},d=>l(d instanceof Error?d:new Error(String(d))))})}async function T$r(t,r={}){const i=await $Ue(t,"Asset preview GLB bytes");try{return M0e(i,r)}finally{Z8(i)}}async function k$r(t,r,i={}){const a=await $Ue(t,"Asset preview GLB bytes");try{return BUe(a,r,i)}finally{Z8(a)}}async function I$r(t,r){const i=x$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.")),e$r);try{const _=await X6t(i,a.signal);if(a.signal.throwIfAborted(),i.pathname.toLowerCase().endsWith(".spz"))return{root:await j6t(t,new Uint8Array(_)),sourceBytes:null};if(i.pathname.toLowerCase().endsWith(".glb")){const b=new Uint8Array(_.slice(0));return{root:await D2t(_,i,a.signal),sourceBytes:b}}const g=await E$r(_,i,a.signal);return{root:await D2t(g,i,a.signal),sourceBytes:null}}finally{globalThis.clearTimeout(d),r?.removeEventListener("abort",l)}}async function L0e(t,r){return(await I$r(t,r)).root}function Z8(t){X8(t,"gaussianSplat")&&t.dispose(),dU(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 Z6t(t,r={}){const i=await L0e(t);try{return X8(i,"gaussianSplat")?await P$r(i,r):M0e(i,r)}finally{Z8(i)}}async function D$r(t,r,i={}){const a=await L0e(t);try{return Q6t(a,r,i)}finally{Z8(a)}}async function P$r(t,r){const i=ww(r.width),a=ww(r.height),l=r.background??"neutral",d=LP(t,"perspective"),_=EZ(t,d),g=UP(new $P({antialias:!1,alpha:!0,preserveDrawingBuffer:!0}));let b=null;try{const S=await la(()=>import("./spark.module-B_-x7Z29.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(fU,l==="transparent"?0:1),g.setSize(i,a,!1),Fee(_,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 CZ.entries()){const J=LUe(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:jUe([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(),F0e(g),g.dispose(),g.forceContextLoss()}}async function N$r(t,r,i={}){const a=await L0e(t);try{return BUe(a,r,i)}finally{Z8(a)}}const P2t=0,O$r=16777215,N2t=10;function F$r(t){return $Ue(t,"Compare reference GLB")}function O2t(t,r){const i=mz(t),a=new SP;a.rotation.y=IUe(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=$jr(_,g);return l.scale.setScalar(b.scale),l.position.set(...b.position),l.updateWorldMatrix(!0,!0),{wrapper:l,dispose:()=>dU(i)}}function R$r(t,r){const i=Njr,a=i*r,l=new Bye(-a,a,i,-i,.01,N2t*4),d=t==="front"?new Tc(0,0,1):new Tc(1,0,0);return l.position.set(0,p2t,0).addScaledVector(d,N2t),l.up.set(0,1,0),l.lookAt(0,p2t,0),l.updateProjectionMatrix(),l.updateMatrixWorld(!0),l}function M$r(t,r,i={}){const a=ww(i.width),l=ww(i.height),d=a/l,_=[];let g=null;try{const b=O2t(t,tge(t));_.push(b.dispose);const S=O2t(r,i.refForward??tge(r));_.push(S.dispose);const k=new fq({color:O$r});_.push(()=>k.dispose());const w=fe=>{const se=new Rye;return se.background=new vE(P2t),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=Dkt,j.setClearColor(P2t,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=Ljr(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 Pjr){const se=R$r(fe,d),de=G(N,se,"asset",fe),ge=G(P,se,"reference",fe),qe=jjr(de.mask,ge.mask);xe.putImageData(new ImageData(Bjr(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 L$r(t,r,i={}){const a=await L0e(t);try{return await eNt(a,r,i)}finally{Z8(a)}}async function eNt(t,r,i={}){const a=await F$r(r);try{return M$r(t,a,i)}finally{Z8(a)}}let u8=null,tNt=0;const dLe=new Set;function rNt(){tNt++;for(const t of dLe)t()}function j0e(t){return dLe.add(t),()=>{dLe.delete(t)}}function TZ(){return tNt}function B0e(){return u8}function YN(t){u8&&JSON.stringify(u8)===JSON.stringify(t)||(u8=t,rNt())}function pP(){u8!==null&&(u8=null,rNt())}function _7e(t){return[...t.selectedEntityIds].sort().join(`
|
|
74
74
|
`)}function j$r(t){let r=_7e(t);const i=j0e(()=>{u8&&(r=_7e(t))}),a=t.subscribe(()=>{u8&&_7e(t)!==r&&pP()});return()=>{i(),a()}}const B$r=["glb","gltf","fbx","obj","dae","stl","ply","3ds"],$$r=["blend","usd","usda","usdc"],q$r=["png","jpg","jpeg","webp","gif","svg"],z$r=["hdr","exr"],U$r=["mp3","ogg","wav","flac"],V$r=["mp4","webm"],J$r=["cube"],W$r=["glsl","vert","frag"],H$r=["txt","md","ts","tsx","js","jsx","css","html","mtl","csv","xml","yaml","yml"];function kA(t,r){return[t,{format:t,...r}]}const F2t={kind:"source",previewable:!0,importable:!0,runtimeReady:!1,placeable:!1,animated:!1,importStrategy:"convert-model",editor:"model"},pLe=new Map([...B$r.map(t=>kA(t,{...F2t,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"}),...$$r.map(t=>kA(t,{...F2t,previewable:!1,editor:"source"})),...q$r.map(t=>kA(t,{kind:"image",previewable:!0,importable:!0,runtimeReady:!0,placeable:!1,animated:t==="gif",importStrategy:"copy-project",editor:"image"})),...z$r.map(t=>kA(t,{kind:"image",previewable:!0,importable:!0,runtimeReady:!0,placeable:!1,animated:!1,importStrategy:"copy-project",editor:"environment"})),...U$r.map(t=>kA(t,{kind:"audio",previewable:!0,importable:!0,runtimeReady:!0,placeable:!1,animated:!1,importStrategy:"copy-project",editor:"audio"})),...V$r.map(t=>kA(t,{kind:"video",previewable:!0,importable:!0,runtimeReady:!1,placeable:!1,animated:!0,importStrategy:"copy-project",editor:"video"})),...J$r.map(t=>kA(t,{kind:"source",previewable:!0,importable:!0,runtimeReady:!0,placeable:!1,animated:!1,importStrategy:"copy-project",editor:"source"})),...W$r.map(t=>kA(t,{kind:"source",previewable:!0,importable:!0,runtimeReady:!0,placeable:!1,animated:!1,importStrategy:"copy-project",editor:"source"})),...H$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"})]),G$r={format:"unknown",kind:"unknown",previewable:!1,importable:!1,runtimeReady:!1,placeable:!1,animated:!1,importStrategy:"unsupported",editor:"none"};function Q$r(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 pLe.has(a)?a:a==="json"?"json":"unknown"}function wg(t){const r=pLe.get(t.toLowerCase());return r||(pLe.get(Q$r(t))??G$r)}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 _Le=new Set;function nNt(){for(const t of _Le)t()}function iNt(t){return _Le.add(t),()=>{_Le.delete(t)}}function VDn(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}nNt()}function kZ(){return _P}function JDn(t){const r=_P.findIndex(i=>i.worldId===t);r!==-1&&(_P=_P.filter((i,a)=>a!==r),nNt())}function WDn(t){return t instanceof Error?t.message:String(t)}function eO(t){return wm(t).adapter}function $0e(t){const r=[];return lU(eO(t).hierarchy,i=>{r.push({id:i.id,name:i.label,childIds:[...i.childIds]})}),r}function K$r(t){let r=null;return lU(t.hierarchy,i=>{const a=i.secondaryLabel?.trim();if(!(i.role!=="document"||!a))return r=a,!1}),r}function Y$r(t){return K$r(By(t))}function qUe(t){const r=By(t);return r.capabilities.persist?r.persistence?.destination??null:null}function sNt(t){const r=By(t).persistence;return r?.lastError?.()?"failed":r?.isDirty()?"unsaved":"saved"}function X$r(t){return By(t).persistence?.lastError?.()??null}function Z$r(t){const r=eO(t),i=r.selection?.get()[0]??null;return i?r.truth?.resolve(i,"position").site??null:null}function eqr(t){const r=eO(t),i=r.selection?.get()[0]??null;return i?r.truth?.resolve(i,"position").writeAnchorKind??null:null}function zUe(t){return[...eO(t).selection?.get()??t.selectedEntityIds]}function UUe(t,r){const i=eO(t);k0(i,r)||t.selectMultiple([...r])}function oNt(t){UUe(t,$0e(t).map(r=>r.id))}async function aNt(t){await e4t(By(t),"the shell saved the active document")}function cNt(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 lNt(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 mLe=new Set;function tqr(t){return mLe.add(t),()=>{mLe.delete(t)}}function rqr(t){for(const r of mLe)r(t)}function R2t(t){return/@[0-9.]+x\./i.test(t)?1:/\.webp\.json$/i.test(t)?2:/\.png\.json$/i.test(t)?3:0}function hLe(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 VUe(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"?uqr(i.meta.image):"",l=sqr(i.frames);return!a||l.length===0?null:{image:a,frames:l}}function q0e(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 nqr(t){const{sheetPath:r,frameName:i}=q0e(t);return i??r.split("/").pop()??t}function uNt(t){return`${t.replace(/^\//,"")}.json`}function iqr(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 sqr(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=M2t(i);return!a||!l?[]:[{name:L2t(a),...l}]}):Object.entries(t).flatMap(([r,i])=>{if(!i||typeof i!="object")return[];const a=M2t(i);return a?[{name:L2t(r),...a}]:[]})}function M2t(t){const r=oqr(t.frame);if(!r)return null;const i=aqr(t.sourceSize)??{width:r.width,height:r.height},a=cqr(t.spriteSourceSize);return{...r,rotated:t.rotated===!0,sourceWidth:i.width,sourceHeight:i.height,trimX:a?.x??0,trimY:a?.y??0}}function oqr(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 aqr(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 cqr(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 lqr(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 uqr(t){const r=t.lastIndexOf("/");return r<0?t:t.slice(r+1)}function L2t(t){return t.replace(/\.(png|webp|jpe?g)$/i,"")}const fqr="http://www.w3.org/2000/svg";function dqr(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="${fqr}"${t.slice(l)}`}function pqr(t){const r=t.mediaType==="image/svg+xml"?dqr(t.text):t.text;return`data:${t.mediaType};charset=utf-8,${encodeURIComponent(r)}`}const j2t="command-result-received";let Kk=null;const gLe=new Set;function fNt(){for(const t of[...gLe])t(Kk)}function Vpe(){return Kk}function dNt(t,r=Date.now()){Kk!==null&&Kk.reason!=="server-gone"||Kk!==null&&Kk.reason===t||(Kk={reason:t,at:r},fNt())}function _qr(){Kk===null||Kk.reason!=="server-gone"||(Kk=null,fNt())}function JUe(t){return gLe.add(t),()=>{gLe.delete(t)}}function mqr(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 hqr=300;function pNt(t){window.close(),window.setTimeout(t,hqr)}function gqr(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 yqr(t,r){let i=null;try{const a=JSON.parse(r.data);typeof a.participantId=="string"&&(i=a.participantId)}catch{}pNt(()=>{const a=i?`?participantId=${encodeURIComponent(i)}`:"";window.location.replace(`${t}/tab-yielded${a}`)})}let B2t=!1;function vqr(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 bqr(t,r){B2t||(B2t=!0,dNt("session-closed"),vqr(t,r),pNt(()=>{document.title=x4t("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">${wMr()}</div><h1>Session ended</h1><p>This editor session has ended. You can close this tab.</p></main>`}))}const rge=new Set;function Aqr(t){return rge.add(t),()=>{rge.delete(t)}}function Sqr(){try{window.focus()}catch{}if(rge.size===0){window.location.reload();return}for(const t of[...rge])t()}function xqr(t,r,i={}){t.addEventListener("tab-refocus",a=>gqr(a)),t.addEventListener("tab-yield",a=>yqr(r,a)),t.addEventListener("tab-close",()=>bqr(r,i)),t.addEventListener("tab-adopt",()=>Sqr())}const Gk="/__editor",wqr=globalThis,Ad=wqr.__VGAI_EDITOR_PRESENCE_BOOTSTRAP__,jP=Ad?.clientId??globalThis.crypto?.randomUUID?.()??`editor-${Date.now()}`,z0e=wDt,Cqr=m8r;function Eqr(t){Ad?.reportPhase?.(t)}function Tqr(t){Ad?.reportCensus?.(t)}function kqr(){Ad?.stopHeartbeat?.();const t=pw;if(t!==null){pw=null,Y$=0,Ad?.source===t&&(Ad.source=null),hz===t&&(hz=null);try{t.close()}catch{}}}function Iqr(){const t=new URLSearchParams({clientId:jP,participantId:z0e,displayName:Cqr});return Ad?.tabId&&t.set("tabId",Ad.tabId),`${Gk}/events?${t}`}let pw=Ad?.source??null,Y$=Ad?.source&&Ad.pageOwned?1:0,hz=null;const _Nt=new Set(["editor-command"]);function mNt(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 Dqr(t){hz!==t&&(hz=t,xqr(t,Gk,{tabId:Ad?.tabId,epoch:Ad?.epoch}),mNt(t,r=>!_Nt.has(r)))}function VP(){pw||(Ad?.source?(pw=Ad.source,Ad.pageOwned&&Y$++):(pw=new EventSource(Iqr()),Ad&&(Ad.source=pw)));const t=pw;Dqr(t),Y$++;const r=[];let i=!1;return{addEventListener(a,l){const d=l;t.addEventListener(a,d),r.push({type:a,listener:d}),_Nt.has(a)&&mNt(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),hz===t&&(hz=null),Y$=0)}}}}function Pqr(){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 Nqr(){if(typeof EventSource>"u")return()=>{};const t=VP(),r=JUe(a=>{a!==null&&a.reason!=="server-gone"&&kqr()}),i=Fqr();return()=>{i(),r(),t.close()}}const Oqr=5;function Fqr(){if(typeof window>"u")return()=>{};let t=0;const r=l=>{l===""||t>=Oqr||(t+=1,CX("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;M3t(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 Rqr=2e3,Mqr={"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 CX(t,r){if(!(typeof fetch>"u"))try{await fetch(Mqr[t],{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...r,...Ad?.controlLifecycle?{_controlLifecycle:Ad.controlLifecycle}:{}})})}catch{}}async function F8(t,r){(pw??Ad?.source??null)?.send?.(t,r)||await CX(t,r)}async function Lqr(t,r){const i=pw??Ad?.source??null;if(!i){await CX("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(j2t,d);const _={...r,_awaitCallerReceipt:!0};i.send?.("command-result",_)||await CX("command-result",_);let g,b=!1;await Promise.race([l.then(()=>{b=!0}),new Promise(S=>{g=setTimeout(S,Rqr)})]),g!==void 0&&clearTimeout(g),b||await CX("command-result",r),i.removeEventListener(j2t,d)}function jqr(t){F8("tab-route",{clientId:jP,participantId:z0e,route:t})}function WUe(t){return{ok:!1,reason:t instanceof Error?t.message:String(t)}}async function Bqr(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 WUe(i)}}async function U0e(t,r){if(t!=="public")return Bqr(t,r);try{return{ok:!0,entries:(await pz().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 WUe(i)}}async function hNt(){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 WUe(t)}}class $2t extends Error{constructor(r,i){super(i),this.code=r,this.name="AssetDeliveryError"}}function q2t(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 $qr=new Map,qqr=new Set;function zqr(t,r){return`${t}:${r}`}async function HDn(t,r){return Uqr(t,r)}async function Uqr(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 $2t("offline",d instanceof Error?d.message:q2t("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 $2t(_,d?.error??q2t(_))}return(await a.json()).files}async function GDn(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 QDn(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){$qr.set(zqr(t.source,t.id),`/${i.path}`);for(const a of qqr)a()}return i}async function KDn(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 YDn(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 Vqr(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 Jqr(){let t;try{t=await fetch(`${W_}/compatibility`,{cache:"no-store"})}catch(r){throw r2t(r instanceof Error?r.message:String(r))}if(t.status>=500)throw r2t(`HTTP ${t.status}`);try{tU(t,`GET ${W_}/compatibility`)}catch{return null}try{return Vqr(await t.json())}catch{return null}}async function gNt(){const t=await Jqr();if(!t)throw MMr();return LMr(t),t}async function Wqr(){try{const t=await fetch(`${W_}/recent-projects`);return(await Eg(t,"Could not list recent projects")).projects}catch{return[]}}const z2t={reopenLastProject:!1};async function Hqr(){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:z2t.reopenLastProject}}catch{return{...z2t}}}async function yLe(t){const r=await fetch(`${W_}/reveal`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:t})});tU(r,`Could not reveal ${t}`)}async function Gqr(t){try{const r=await fetch(`${W_}/save-thumbnail`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dataUrl:t})});return tU(r,"Could not save the project thumbnail"),!0}catch{return!1}}async function yNt(){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 nge(t){try{const r=await fetch(Oee(t));if(r.ok)return await r.text()}catch{}return null}function Qqr(t){return(t.headers.get("content-type")??"").toLowerCase().includes("text/html")}async function vNt(t){try{const r=await fetch(Oee(t),{method:"HEAD"});return r.ok?Qqr(r)?"absent":"present":"absent"}catch{return"unreachable"}}async function Kqr(t){return await vNt(t)==="present"}async function bNt(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 Yqr(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 Xqr(){try{const t=await fetch(`${W_}/editor-state`);return await Eg(t,"Could not read editor state")}catch{return{}}}let U2t=!1;async function Zqr(t){try{const r=await fetch(`${W_}/editor-state`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});return tU(r,"Could not save editor state"),!0}catch(r){return U2t||(U2t=!0,console.error(r instanceof Error?r.message:String(r))),!1}}let GY=null,ige=null;async function ANt(){for(;GY;){const t=GY;GY=null,await F8("state",{...t,_clientId:jP})}ige=null,GY&&(ige=ANt())}function V2t(t){return GY=t,ige??=ANt(),ige}async function ezr(t){await F8("command-received",{_requestId:t,_clientId:jP})}async function Jpe(t){await F8("command-listener",{_clientId:jP,attached:t})}function tzr(t){Eqr(t.phase),F8("play-phase",{_clientId:jP,...t})}async function J2t(t,r,i,a,l=!1){const d={_requestId:t,_clientId:jP,ok:r,error:i,data:a};l?await Lqr(t,d):await F8("command-result",d)}async function rzr(){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 V0e(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 nzr(){const t=await JP("");return V0e(t)}async function izr(t){return await JP("/open",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({worktreeId:t})})}async function W2t(t,r="HEAD"){return await JP("/create",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({branch:t,from:r})})}async function szr(t){return JP("/delegate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}async function ozr(t){const r=await JP(`/isolated/${encodeURIComponent(t)}/logs`);return typeof r.logs=="string"?r.logs:""}async function azr(t){const r=await JP("/isolated/export",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:t})});return V0e(r)}async function H2t(t,r){const i=await JP("/isolated/stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:t,discard:r})});return V0e(i)}async function czr(t){const r=await JP("/archive",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({worktreeId:t})});return V0e(r).worktrees}async function lzr(t,r){await JP("/stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({worktreeId:t,sessionId:r})})}let SNt=null;const uzr=new Set,vLe=new Set;function fzr(t){SNt=t;for(const r of uzr)r(t);for(const r of vLe)r()}function Qh(){return SNt}function Wpe(t){return vLe.add(t),()=>{vLe.delete(t)}}const _I="references",xNt=["public",_I],HUe=`/project-game-static/${_I}/`;function sge(t,r){return`${t}/${r}`}function J0e(t,r){return t===_I?`${HUe}${r}`:`/${r}`}function dzr(t){return t.startsWith(HUe)}function pzr(t){const r=t.startsWith("/")?t:`/${t}`;if(dzr(r))return sge(_I,r.slice(HUe.length));const i=t.startsWith("/")?t.slice(1):t;return i.startsWith("public/")?i:`public/${i}`}function wNt({assetPath:t,kind:r,sizeBytes:i}){return z.jsx(_zr,{assetPath:t,kind:r,sizeBytes:i},t)}function _zr({assetPath:t,kind:r,sizeBytes:i}){const a=t.split("#")[0],l=a.startsWith("/")||/^(?:data|blob|https?):/.test(a)?a:`/${a}`,d=pzr(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 U0e(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 m7e=Xe.lazy(async()=>({default:(await la(()=>Promise.resolve().then(()=>o5r),void 0)).AssetEditorShell})),mzr=Xe.lazy(async()=>({default:(await la(()=>import("./AudioViewer-C5C4xeUl.js"),__vite__mapDeps([47,1,2,3,4,8,9,10,11,6]))).AudioViewer})),hzr=Xe.lazy(async()=>({default:(await la(()=>import("./EntityModelDocument-DyhU8umO.js"),__vite__mapDeps([48,1,2,3,4,8,9,10,43,6,7,41,14,44,42,11]))).EntityModelDocument})),gzr=Xe.lazy(async()=>({default:(await la(()=>import("./EnvironmentAssetDocument-D_VZ2iFj.js"),__vite__mapDeps([49,1,2,3,4,8,9,10,6,41,50,51,11]))).EnvironmentAssetDocument})),yzr=Xe.lazy(async()=>({default:(await la(()=>import("./ImageViewer-Crv-yzT_.js"),__vite__mapDeps([52,1,2,3,4,8,9,10,11,6]))).ImageViewer})),vzr=Xe.lazy(async()=>({default:(await la(()=>import("./VideoViewer-BhH8aSzx.js"),__vite__mapDeps([53,1,2,3,4,8,9,10,11,6]))).VideoViewer})),bzr=Xe.lazy(async()=>({default:(await la(()=>import("./JsonAssetDocument-Dtg2QwPN.js").then(r=>r.a),__vite__mapDeps([54,1,2,3,4,8,9,10,43,6,7,41,14,44,42]))).JsonAssetDocument})),Azr=Xe.lazy(async()=>({default:(await la(()=>import("./ModelAssetDocument-BpZ8SZXe.js"),__vite__mapDeps([55,1,2,3,4,8,9,10,43,6,7,41,14,44,42,11]))).ModelAssetDocument})),G2t=Xe.lazy(async()=>({default:(await la(()=>import("./OnlineAssetDetail-DAdWXnmZ.js"),__vite__mapDeps([56,1,2,3,4,8,9,51,10,11,6]))).OnlineAssetDetail})),Szr=Xe.lazy(async()=>({default:(await la(()=>import("./SourceAssetViewer-D3m0wF8T.js"),__vite__mapDeps([57,1,2,3,4,8,9,10,54,43,6,7,41,14,44,42,47,11,49,50,51,52,58,59,60,61,62,55]))).SourceAssetViewer})),hb=new Map,CNt=new Map,h7e=new Map;let ENt=0;const bLe=new Set;function NR(){ENt++;for(const t of bLe)t()}function xzr(t){return bLe.add(t),()=>{bLe.delete(t)}}function wzr(){return ENt}function Czr(t){return hb.get(t)}function TNt(t){return hb.has(t)}function Ezr(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 GUe(t,r,i,a,l,d={}){typeof document<"u"&&document.activeElement instanceof HTMLElement&&h7e.set(r,document.activeElement);const _=hb.get(r);if(!_)hb.set(r,a),NR();else{const b={..._,...a};Ezr(_,b)||(hb.set(r,b),NR())}const g={id:r,title:i,kind:"asset",workspaceRole:"authored-subject",...l?{provenance:l}:{},Content:Ozr,closeable:!0,presentation:()=>{const b=hb.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=hb.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=>{hb.delete(b)&&NR();const S=h7e.get(b);h7e.delete(b),S?.isConnected&&setTimeout(()=>S.focus(),0)}};return qP(g,d)}function f8(t,r,i,a={}){const l=nqr(r),{frameName:d}=q0e(r),_=CNt.get(G7(r))??r;return GUe(t,_,l,d?{assetPath:r,kind:i,displayName:l}:{assetPath:r,kind:i},{sourcePath:r},a)}kee({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 Kqr(a)?!1:(f8(r,a,l),!0)}});async function kNt(t,r){return xE(()=>{if(I_()!==t)return!1;const i=bze(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=INt(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,Q2t(r.assetKind,i))},ready:async(t,r)=>{const i=r.entityId?"model":Q2t(r.assetKind,r.path??"");if(!await kNt(t,i))throw new Error(`Asset document did not finish mounting its Inspector: ${t}`);await Nze(t)}});function Q2t(t,r){return t==="animation"?"source":t==="prefab"?"json":t??Tzr(r)}function Tzr(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 INt(t,r){const i=t.objectMap.get(r);if(!i)return null;const a=i.name||r;return GUe(t,`asset-editor:entity:${r}`,a,{assetPath:"",kind:"model",entityId:r},{origin:`entity:${r}`})}function kzr(t,r,i){const a=pqr(i);return GUe(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 Izr(t,r){const i=hb.get(t);if(!i)return;const{online:a,...l}=i;hb.set(t,{...l,assetPath:r}),NR()}function Dzr(t,r){const i=hb.get(t);if(!i?.assetPath)return;const a=G7(i.assetPath);if(r.type==="move"&&r.oldPath&&r.newPath&&a===G7(r.oldPath)){const l=`/${G7(r.newPath)}`;hb.set(t,{...i,assetPath:l}),CNt.set(G7(l),t),HDt(t,l.split("/").pop()??l),NR()}else r.type==="delete"&&r.paths?.some(l=>G7(l)===a)?(hb.set(t,{...i,unavailableReason:`The source ${i.assetPath} was deleted. Undo the deletion or close this editor.`}),NR()):r.type==="change"&&r.paths?.some(l=>G7(l)===a)&&(hb.set(t,{...i,revision:(i.revision??0)+1}),NR())}function Pzr(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 g7e(t){return{id:"source",title:"Source",icon:Kkt,order:mZ,body:{kind:"custom",render:()=>z.jsx("div",{style:{padding:4},children:t.sourcePath??t.assetPath})}}}function Nzr({id:t,spec:r,active:i}){if(r.unavailableReason)return z.jsx(m7e,{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:eMe},children:r.unavailableReason})});const a=Pzr(r);if(a==="online"&&r.online){const g=r.online;return z.jsx(m7e,{documentId:t,active:i,type:"online",title:g.name,sections:[{id:"online-asset",title:"Asset",icon:uDr,order:mZ,body:{kind:"custom",render:()=>z.jsx(G2t,{online:g,mode:"inspector",onResolved:b=>Izr(t,b)})}}],status:`${g.type} · ${g.source}`,children:z.jsx(G2t,{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(Azr,{documentId:t,assetPath:r.assetPath,displayName:l,active:i},d):r.entityId?z.jsx(hzr,{documentId:t,entityId:r.entityId,displayName:l,active:i},d):z.jsx("div",{style:{padding:20,color:eMe},children:"Model source is unavailable."});if(a==="environment")return z.jsx(gzr,{documentId:t,assetPath:r.assetPath,active:i},d);if(a==="source")return z.jsx(Szr,{documentId:t,assetPath:r.assetPath,active:i},d);if(a==="json")return z.jsx(bzr,{documentId:t,assetPath:r.assetPath,displayName:l,active:i,sections:[g7e(r)],status:`json · ${r.sourcePath??r.displayName??r.assetPath}`},d);let _;switch(a){case"image":_=z.jsx(yzr,{assetPath:r.assetPath,...r.displayName?{displayName:r.displayName}:{}},d);break;case"video":_=z.jsx(vzr,{assetPath:r.assetPath},d);break;case"audio":_=z.jsx(mzr,{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(m7e,{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:Kkt,order:mZ,body:{kind:"custom",render:()=>z.jsx(wNt,{assetPath:r.assetPath,kind:a},d)}},...r.sourcePath?[g7e(r)]:[]]:[g7e(r)],status:`${a} · ${r.sourcePath??r.displayName??r.assetPath}`,children:_})}function Ozr({documentId:t,active:r}){Xe.useSyncExternalStore(xzr,wzr),Xe.useEffect(()=>{const a=l=>{Dzr(t,l.detail)};return window.addEventListener("editor:asset-mutation",a),()=>window.removeEventListener("editor:asset-mutation",a)},[t]);const i=hb.get(t);return z.jsx("div",{"data-testid":`asset-document:${t}`,style:{flex:1,minHeight:0,overflow:"hidden",pointerEvents:"auto",background:Ize[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(Nzr,{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 G7(t){return t.split(/[?#]/,1)[0].replace(/^\/+/,"")}const Fzr=["three","pixi","dom","babylon","phaser"],DNt=Object.freeze({up:"y",groundHeight:0}),PNt=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(),Rzr=Na({up:jd(["y","z"]).describe("World axis pointing away from the ground"),groundHeight:Tu().describe("Ground offset along `up`, in world units")}).strict(),Mzr=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(Fzr).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($8r)).describe("Anchor kinds this region’s writer serves"),basis:Rzr.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_(PNt).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(),Lzr=bee([Ry("manifest-roots"),o_(Mzr).min(1)]),jzr=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_(PNt).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."}),Bzr=zR(Ss().min(1),jzr).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 NNt(t,r={}){return t.map(i=>({...zzr(i),...$zr(r[i.id])}))}function $zr(t){return t?{...t.include?{include:t.include}:{},...t.mounts?{mounts:t.mounts}:{}}:{}}function qzr(t,r){const i=new Set(t.map(a=>a.id));return Object.keys(r).filter(a=>!i.has(a))}function zzr(t){const r=t.surface,i=t.adapter.type==="builtin",a=r==="canvas"?"pixi":r,l=DNt;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 oge="exported-composition-regions",Uzr=Na({finder:Ss().min(1).describe("Registered finder name")}).passthrough(),Vzr=bee([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()]),K2t=Na({path:Ss().min(1),export:Ss().min(1).optional()}).strict(),Jzr=Na({id:Ss().min(1),label:Ss().min(1),kind:Ss().min(1),region:Ss().min(1).nullable(),authorable:gv(),reach:Vzr,source:K2t.optional(),isolationSetup:K2t.optional(),finder:Ss().min(1).optional()}).strict(),Wzr=Na({entries:o_(Jzr).optional(),find:o_(Uzr).optional(),default:Ss().min(1).optional()}).strict(),Hzr=["command","state"],Gzr="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.",Qzr=Na({id:Ss().min(1),kind:jd(Hzr,{error:()=>Gzr}),description:Ss().min(1).optional(),locus:jd(["client","server"]).optional(),answer:kR(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"}),Kzr=Na({root:Ss().min(1),actions:kR(t=>typeof t=="function",{message:"input.actions must be a function returning the app-owned action vocabulary"}),set:kR(t=>typeof t=="function",{message:"input.set must be a function writing the app-owned input store"}),clear:kR(t=>typeof t=="function",{message:"input.clear must be a function releasing app-owned virtual actions"})}).strict(),Yzr=Na({Layout:kR(t=>typeof t=="function","Layout must be an imported React component").optional(),style:kR(t=>typeof t=="object"&&t!==null&&typeof Reflect.get(t,"id")=="string","style must be an imported StyleContribution object").optional(),keymap:kR(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(),Xzr="`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.",Zzr=Na({editor:Yzr.optional(),regions:Lzr.optional(),regionIncludes:Bzr.optional(),documents:Wzr.optional(),observation:o_(Qzr).optional(),input:Kzr.optional()}).strict().refine(t=>t.regionIncludes===void 0||Object.keys(t.regionIncludes).length===0||!Array.isArray(t.regions),{message:Xzr});function ONt(t={}){const r=Zzr.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 ONt({regions:"manifest-roots",...t.regionIncludes?{regionIncludes:t.regionIncludes}:{},documents:{...t.scenes?{entries:t.scenes}:{},find:[{finder:"scenesFromEntrypointSelection",regions:oge},{finder:"prefabsFromStories"}]}})}function Y2t(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 ONt(t)}const EX=new Map;function FNt(t){const r=t;return EX.set(t.name,r),()=>{EX.get(t.name)===r&&EX.delete(t.name)}}function RNt(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 FNt(i)}function eUr(){return[...EX.keys()]}function tUr(t,r){const i=EX.get(t.finder);if(!i){const l=eUr();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 X2t(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 y7e={exports:{}};const rUr={},nUr=Object.freeze(Object.defineProperty({__proto__:null,default:rUr},Symbol.toStringTag,{value:"Module"})),NN=wIr(nUr);var Z2t;function iUr(){return Z2t||(Z2t=1,(function(t){var r={};/*! *****************************************************************************
|
|
79
|
+
</style><main><div class="brand-mark">${wMr()}</div><h1>Session ended</h1><p>This editor session has ended. You can close this tab.</p></main>`}))}const rge=new Set;function Aqr(t){return rge.add(t),()=>{rge.delete(t)}}function Sqr(){try{window.focus()}catch{}if(rge.size===0){window.location.reload();return}for(const t of[...rge])t()}function xqr(t,r,i={}){t.addEventListener("tab-refocus",a=>gqr(a)),t.addEventListener("tab-yield",a=>yqr(r,a)),t.addEventListener("tab-close",()=>bqr(r,i)),t.addEventListener("tab-adopt",()=>Sqr())}const Gk="/__editor",wqr=globalThis,Ad=wqr.__VGAI_EDITOR_PRESENCE_BOOTSTRAP__,jP=Ad?.clientId??globalThis.crypto?.randomUUID?.()??`editor-${Date.now()}`,z0e=wDt,Cqr=m8r;function Eqr(t){Ad?.reportPhase?.(t)}function Tqr(t){Ad?.reportCensus?.(t)}function kqr(){Ad?.stopHeartbeat?.();const t=pw;if(t!==null){pw=null,Y$=0,Ad?.source===t&&(Ad.source=null),hz===t&&(hz=null);try{t.close()}catch{}}}function Iqr(){const t=new URLSearchParams({clientId:jP,participantId:z0e,displayName:Cqr});return Ad?.tabId&&t.set("tabId",Ad.tabId),`${Gk}/events?${t}`}let pw=Ad?.source??null,Y$=Ad?.source&&Ad.pageOwned?1:0,hz=null;const _Nt=new Set(["editor-command"]);function mNt(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 Dqr(t){hz!==t&&(hz=t,xqr(t,Gk,{tabId:Ad?.tabId,epoch:Ad?.epoch}),mNt(t,r=>!_Nt.has(r)))}function VP(){pw||(Ad?.source?(pw=Ad.source,Ad.pageOwned&&Y$++):(pw=new EventSource(Iqr()),Ad&&(Ad.source=pw)));const t=pw;Dqr(t),Y$++;const r=[];let i=!1;return{addEventListener(a,l){const d=l;t.addEventListener(a,d),r.push({type:a,listener:d}),_Nt.has(a)&&mNt(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),hz===t&&(hz=null),Y$=0)}}}}function Pqr(){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 Nqr(){if(typeof EventSource>"u")return()=>{};const t=VP(),r=JUe(a=>{a!==null&&a.reason!=="server-gone"&&kqr()}),i=Fqr();return()=>{i(),r(),t.close()}}const Oqr=5;function Fqr(){if(typeof window>"u")return()=>{};let t=0;const r=l=>{l===""||t>=Oqr||(t+=1,CX("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;M3t(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 Rqr=2e3,Mqr={"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 CX(t,r){if(!(typeof fetch>"u"))try{await fetch(Mqr[t],{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...r,...Ad?.controlLifecycle?{_controlLifecycle:Ad.controlLifecycle}:{}})})}catch{}}async function F8(t,r){(pw??Ad?.source??null)?.send?.(t,r)||await CX(t,r)}async function Lqr(t,r){const i=pw??Ad?.source??null;if(!i){await CX("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(j2t,d);const _={...r,_awaitCallerReceipt:!0};i.send?.("command-result",_)||await CX("command-result",_);let g,b=!1;await Promise.race([l.then(()=>{b=!0}),new Promise(S=>{g=setTimeout(S,Rqr)})]),g!==void 0&&clearTimeout(g),b||await CX("command-result",r),i.removeEventListener(j2t,d)}function jqr(t){F8("tab-route",{clientId:jP,participantId:z0e,route:t})}function WUe(t){return{ok:!1,reason:t instanceof Error?t.message:String(t)}}async function Bqr(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 WUe(i)}}async function U0e(t,r){if(t!=="public")return Bqr(t,r);try{return{ok:!0,entries:(await pz().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 WUe(i)}}async function hNt(){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 WUe(t)}}class $2t extends Error{constructor(r,i){super(i),this.code=r,this.name="AssetDeliveryError"}}function q2t(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 $qr=new Map,qqr=new Set;function zqr(t,r){return`${t}:${r}`}async function HDn(t,r){return Uqr(t,r)}async function Uqr(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 $2t("offline",d instanceof Error?d.message:q2t("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 $2t(_,d?.error??q2t(_))}return(await a.json()).files}async function GDn(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 QDn(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){$qr.set(zqr(t.source,t.id),`/${i.path}`);for(const a of qqr)a()}return i}async function KDn(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 YDn(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 Vqr(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 Jqr(){let t;try{t=await fetch(`${W_}/compatibility`,{cache:"no-store"})}catch(r){throw r2t(r instanceof Error?r.message:String(r))}if(t.status>=500)throw r2t(`HTTP ${t.status}`);try{tU(t,`GET ${W_}/compatibility`)}catch{return null}try{return Vqr(await t.json())}catch{return null}}async function gNt(){const t=await Jqr();if(!t)throw MMr();return LMr(t),t}async function Wqr(){try{const t=await fetch(`${W_}/recent-projects`);return(await Eg(t,"Could not list recent projects")).projects}catch{return[]}}const z2t={reopenLastProject:!1};async function Hqr(){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:z2t.reopenLastProject}}catch{return{...z2t}}}async function yLe(t){const r=await fetch(`${W_}/reveal`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:t})});tU(r,`Could not reveal ${t}`)}async function Gqr(t){try{const r=await fetch(`${W_}/save-thumbnail`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dataUrl:t})});return tU(r,"Could not save the project thumbnail"),!0}catch{return!1}}async function yNt(){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 nge(t){try{const r=await fetch(Oee(t));if(r.ok)return await r.text()}catch{}return null}function Qqr(t){return(t.headers.get("content-type")??"").toLowerCase().includes("text/html")}async function vNt(t){try{const r=await fetch(Oee(t),{method:"HEAD"});return r.ok?Qqr(r)?"absent":"present":"absent"}catch{return"unreachable"}}async function Kqr(t){return await vNt(t)==="present"}async function bNt(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 Yqr(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 Xqr(){try{const t=await fetch(`${W_}/editor-state`);return await Eg(t,"Could not read editor state")}catch{return{}}}let U2t=!1;async function Zqr(t){try{const r=await fetch(`${W_}/editor-state`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});return tU(r,"Could not save editor state"),!0}catch(r){return U2t||(U2t=!0,console.error(r instanceof Error?r.message:String(r))),!1}}let GY=null,ige=null;async function ANt(){for(;GY;){const t=GY;GY=null,await F8("state",{...t,_clientId:jP})}ige=null,GY&&(ige=ANt())}function V2t(t){return GY=t,ige??=ANt(),ige}async function ezr(t){await F8("command-received",{_requestId:t,_clientId:jP})}async function Jpe(t){await F8("command-listener",{_clientId:jP,attached:t})}function tzr(t){Eqr(t.phase),F8("play-phase",{_clientId:jP,...t})}async function J2t(t,r,i,a,l=!1){const d={_requestId:t,_clientId:jP,ok:r,error:i,data:a};l?await Lqr(t,d):await F8("command-result",d)}async function rzr(){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 V0e(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 nzr(){const t=await JP("");return V0e(t)}async function izr(t){return await JP("/open",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({worktreeId:t})})}async function W2t(t,r="HEAD"){return await JP("/create",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({branch:t,from:r})})}async function szr(t){return JP("/delegate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}async function ozr(t){const r=await JP(`/isolated/${encodeURIComponent(t)}/logs`);return typeof r.logs=="string"?r.logs:""}async function azr(t){const r=await JP("/isolated/export",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:t})});return V0e(r)}async function H2t(t,r){const i=await JP("/isolated/stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:t,discard:r})});return V0e(i)}async function czr(t){const r=await JP("/archive",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({worktreeId:t})});return V0e(r).worktrees}async function lzr(t,r){await JP("/stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({worktreeId:t,sessionId:r})})}let SNt=null;const uzr=new Set,vLe=new Set;function fzr(t){SNt=t;for(const r of uzr)r(t);for(const r of vLe)r()}function Qh(){return SNt}function Wpe(t){return vLe.add(t),()=>{vLe.delete(t)}}const _I="references",xNt=["public",_I],HUe=`/project-game-static/${_I}/`;function sge(t,r){return`${t}/${r}`}function J0e(t,r){return t===_I?`${HUe}${r}`:`/${r}`}function dzr(t){return t.startsWith(HUe)}function pzr(t){const r=t.startsWith("/")?t:`/${t}`;if(dzr(r))return sge(_I,r.slice(HUe.length));const i=t.startsWith("/")?t.slice(1):t;return i.startsWith("public/")?i:`public/${i}`}function wNt({assetPath:t,kind:r,sizeBytes:i}){return z.jsx(_zr,{assetPath:t,kind:r,sizeBytes:i},t)}function _zr({assetPath:t,kind:r,sizeBytes:i}){const a=t.split("#")[0],l=a.startsWith("/")||/^(?:data|blob|https?):/.test(a)?a:`/${a}`,d=pzr(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 U0e(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 m7e=Xe.lazy(async()=>({default:(await la(()=>Promise.resolve().then(()=>o5r),void 0)).AssetEditorShell})),mzr=Xe.lazy(async()=>({default:(await la(()=>import("./AudioViewer-C9JP7n49.js"),__vite__mapDeps([46,1,2,3,4,8,9,10,11,6]))).AudioViewer})),hzr=Xe.lazy(async()=>({default:(await la(()=>import("./EntityModelDocument-SFgsuX4_.js"),__vite__mapDeps([47,1,2,3,4,8,9,10,42,6,7,40,14,43,41,11]))).EntityModelDocument})),gzr=Xe.lazy(async()=>({default:(await la(()=>import("./EnvironmentAssetDocument-DEqKuki2.js"),__vite__mapDeps([48,1,2,3,4,8,9,10,6,40,49,50,11]))).EnvironmentAssetDocument})),yzr=Xe.lazy(async()=>({default:(await la(()=>import("./ImageViewer-CyIXlQTG.js"),__vite__mapDeps([51,1,2,3,4,8,9,10,11,6]))).ImageViewer})),vzr=Xe.lazy(async()=>({default:(await la(()=>import("./VideoViewer-3I_zUWEC.js"),__vite__mapDeps([52,1,2,3,4,8,9,10,11,6]))).VideoViewer})),bzr=Xe.lazy(async()=>({default:(await la(()=>import("./JsonAssetDocument-Zyv_CDpC.js").then(r=>r.a),__vite__mapDeps([53,1,2,3,4,8,9,10,42,6,7,40,14,43,41]))).JsonAssetDocument})),Azr=Xe.lazy(async()=>({default:(await la(()=>import("./ModelAssetDocument-BKdnWaJL.js"),__vite__mapDeps([54,1,2,3,4,8,9,10,42,6,7,40,14,43,41,11]))).ModelAssetDocument})),G2t=Xe.lazy(async()=>({default:(await la(()=>import("./OnlineAssetDetail-B_l8XkeE.js"),__vite__mapDeps([55,1,2,3,4,8,9,50,10,11,6]))).OnlineAssetDetail})),Szr=Xe.lazy(async()=>({default:(await la(()=>import("./SourceAssetViewer-zpxF5DOe.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})),hb=new Map,CNt=new Map,h7e=new Map;let ENt=0;const bLe=new Set;function NR(){ENt++;for(const t of bLe)t()}function xzr(t){return bLe.add(t),()=>{bLe.delete(t)}}function wzr(){return ENt}function Czr(t){return hb.get(t)}function TNt(t){return hb.has(t)}function Ezr(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 GUe(t,r,i,a,l,d={}){typeof document<"u"&&document.activeElement instanceof HTMLElement&&h7e.set(r,document.activeElement);const _=hb.get(r);if(!_)hb.set(r,a),NR();else{const b={..._,...a};Ezr(_,b)||(hb.set(r,b),NR())}const g={id:r,title:i,kind:"asset",workspaceRole:"authored-subject",...l?{provenance:l}:{},Content:Ozr,closeable:!0,presentation:()=>{const b=hb.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=hb.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=>{hb.delete(b)&&NR();const S=h7e.get(b);h7e.delete(b),S?.isConnected&&setTimeout(()=>S.focus(),0)}};return qP(g,d)}function f8(t,r,i,a={}){const l=nqr(r),{frameName:d}=q0e(r),_=CNt.get(G7(r))??r;return GUe(t,_,l,d?{assetPath:r,kind:i,displayName:l}:{assetPath:r,kind:i},{sourcePath:r},a)}kee({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 Kqr(a)?!1:(f8(r,a,l),!0)}});async function kNt(t,r){return xE(()=>{if(I_()!==t)return!1;const i=bze(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=INt(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,Q2t(r.assetKind,i))},ready:async(t,r)=>{const i=r.entityId?"model":Q2t(r.assetKind,r.path??"");if(!await kNt(t,i))throw new Error(`Asset document did not finish mounting its Inspector: ${t}`);await Nze(t)}});function Q2t(t,r){return t==="animation"?"source":t==="prefab"?"json":t??Tzr(r)}function Tzr(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 INt(t,r){const i=t.objectMap.get(r);if(!i)return null;const a=i.name||r;return GUe(t,`asset-editor:entity:${r}`,a,{assetPath:"",kind:"model",entityId:r},{origin:`entity:${r}`})}function kzr(t,r,i){const a=pqr(i);return GUe(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 Izr(t,r){const i=hb.get(t);if(!i)return;const{online:a,...l}=i;hb.set(t,{...l,assetPath:r}),NR()}function Dzr(t,r){const i=hb.get(t);if(!i?.assetPath)return;const a=G7(i.assetPath);if(r.type==="move"&&r.oldPath&&r.newPath&&a===G7(r.oldPath)){const l=`/${G7(r.newPath)}`;hb.set(t,{...i,assetPath:l}),CNt.set(G7(l),t),HDt(t,l.split("/").pop()??l),NR()}else r.type==="delete"&&r.paths?.some(l=>G7(l)===a)?(hb.set(t,{...i,unavailableReason:`The source ${i.assetPath} was deleted. Undo the deletion or close this editor.`}),NR()):r.type==="change"&&r.paths?.some(l=>G7(l)===a)&&(hb.set(t,{...i,revision:(i.revision??0)+1}),NR())}function Pzr(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 g7e(t){return{id:"source",title:"Source",icon:Kkt,order:mZ,body:{kind:"custom",render:()=>z.jsx("div",{style:{padding:4},children:t.sourcePath??t.assetPath})}}}function Nzr({id:t,spec:r,active:i}){if(r.unavailableReason)return z.jsx(m7e,{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:eMe},children:r.unavailableReason})});const a=Pzr(r);if(a==="online"&&r.online){const g=r.online;return z.jsx(m7e,{documentId:t,active:i,type:"online",title:g.name,sections:[{id:"online-asset",title:"Asset",icon:uDr,order:mZ,body:{kind:"custom",render:()=>z.jsx(G2t,{online:g,mode:"inspector",onResolved:b=>Izr(t,b)})}}],status:`${g.type} · ${g.source}`,children:z.jsx(G2t,{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(Azr,{documentId:t,assetPath:r.assetPath,displayName:l,active:i},d):r.entityId?z.jsx(hzr,{documentId:t,entityId:r.entityId,displayName:l,active:i},d):z.jsx("div",{style:{padding:20,color:eMe},children:"Model source is unavailable."});if(a==="environment")return z.jsx(gzr,{documentId:t,assetPath:r.assetPath,active:i},d);if(a==="source")return z.jsx(Szr,{documentId:t,assetPath:r.assetPath,active:i},d);if(a==="json")return z.jsx(bzr,{documentId:t,assetPath:r.assetPath,displayName:l,active:i,sections:[g7e(r)],status:`json · ${r.sourcePath??r.displayName??r.assetPath}`},d);let _;switch(a){case"image":_=z.jsx(yzr,{assetPath:r.assetPath,...r.displayName?{displayName:r.displayName}:{}},d);break;case"video":_=z.jsx(vzr,{assetPath:r.assetPath},d);break;case"audio":_=z.jsx(mzr,{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(m7e,{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:Kkt,order:mZ,body:{kind:"custom",render:()=>z.jsx(wNt,{assetPath:r.assetPath,kind:a},d)}},...r.sourcePath?[g7e(r)]:[]]:[g7e(r)],status:`${a} · ${r.sourcePath??r.displayName??r.assetPath}`,children:_})}function Ozr({documentId:t,active:r}){Xe.useSyncExternalStore(xzr,wzr),Xe.useEffect(()=>{const a=l=>{Dzr(t,l.detail)};return window.addEventListener("editor:asset-mutation",a),()=>window.removeEventListener("editor:asset-mutation",a)},[t]);const i=hb.get(t);return z.jsx("div",{"data-testid":`asset-document:${t}`,style:{flex:1,minHeight:0,overflow:"hidden",pointerEvents:"auto",background:Ize[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(Nzr,{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 G7(t){return t.split(/[?#]/,1)[0].replace(/^\/+/,"")}const Fzr=["three","pixi","dom","babylon","phaser"],DNt=Object.freeze({up:"y",groundHeight:0}),PNt=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(),Rzr=Na({up:jd(["y","z"]).describe("World axis pointing away from the ground"),groundHeight:Tu().describe("Ground offset along `up`, in world units")}).strict(),Mzr=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(Fzr).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($8r)).describe("Anchor kinds this region’s writer serves"),basis:Rzr.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_(PNt).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(),Lzr=bee([Ry("manifest-roots"),o_(Mzr).min(1)]),jzr=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_(PNt).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."}),Bzr=zR(Ss().min(1),jzr).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 NNt(t,r={}){return t.map(i=>({...zzr(i),...$zr(r[i.id])}))}function $zr(t){return t?{...t.include?{include:t.include}:{},...t.mounts?{mounts:t.mounts}:{}}:{}}function qzr(t,r){const i=new Set(t.map(a=>a.id));return Object.keys(r).filter(a=>!i.has(a))}function zzr(t){const r=t.surface,i=t.adapter.type==="builtin",a=r==="canvas"?"pixi":r,l=DNt;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 oge="exported-composition-regions",Uzr=Na({finder:Ss().min(1).describe("Registered finder name")}).passthrough(),Vzr=bee([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()]),K2t=Na({path:Ss().min(1),export:Ss().min(1).optional()}).strict(),Jzr=Na({id:Ss().min(1),label:Ss().min(1),kind:Ss().min(1),region:Ss().min(1).nullable(),authorable:gv(),reach:Vzr,source:K2t.optional(),isolationSetup:K2t.optional(),finder:Ss().min(1).optional()}).strict(),Wzr=Na({entries:o_(Jzr).optional(),find:o_(Uzr).optional(),default:Ss().min(1).optional()}).strict(),Hzr=["command","state"],Gzr="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.",Qzr=Na({id:Ss().min(1),kind:jd(Hzr,{error:()=>Gzr}),description:Ss().min(1).optional(),locus:jd(["client","server"]).optional(),answer:kR(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"}),Kzr=Na({root:Ss().min(1),actions:kR(t=>typeof t=="function",{message:"input.actions must be a function returning the app-owned action vocabulary"}),set:kR(t=>typeof t=="function",{message:"input.set must be a function writing the app-owned input store"}),clear:kR(t=>typeof t=="function",{message:"input.clear must be a function releasing app-owned virtual actions"})}).strict(),Yzr=Na({Layout:kR(t=>typeof t=="function","Layout must be an imported React component").optional(),style:kR(t=>typeof t=="object"&&t!==null&&typeof Reflect.get(t,"id")=="string","style must be an imported StyleContribution object").optional(),keymap:kR(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(),Xzr="`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.",Zzr=Na({editor:Yzr.optional(),regions:Lzr.optional(),regionIncludes:Bzr.optional(),documents:Wzr.optional(),observation:o_(Qzr).optional(),input:Kzr.optional()}).strict().refine(t=>t.regionIncludes===void 0||Object.keys(t.regionIncludes).length===0||!Array.isArray(t.regions),{message:Xzr});function ONt(t={}){const r=Zzr.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 ONt({regions:"manifest-roots",...t.regionIncludes?{regionIncludes:t.regionIncludes}:{},documents:{...t.scenes?{entries:t.scenes}:{},find:[{finder:"scenesFromEntrypointSelection",regions:oge},{finder:"prefabsFromStories"}]}})}function Y2t(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 ONt(t)}const EX=new Map;function FNt(t){const r=t;return EX.set(t.name,r),()=>{EX.get(t.name)===r&&EX.delete(t.name)}}function RNt(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 FNt(i)}function eUr(){return[...EX.keys()]}function tUr(t,r){const i=EX.get(t.finder);if(!i){const l=eUr();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 X2t(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 y7e={exports:{}};const rUr={},nUr=Object.freeze(Object.defineProperty({__proto__:null,default:rUr},Symbol.toStringTag,{value:"Module"})),NN=wIr(nUr);var Z2t;function iUr(){return Z2t||(Z2t=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
|
|
@@ -521,7 +521,7 @@ Project '${v.projectName}' (${WF[v.projectKind]}) ${p}
|
|
|
521
521
|
`,p++};this.projectService.externalProjects.forEach(m),this.projectService.configuredProjects.forEach(m),this.projectService.inferredProjects.forEach(m)}}this.logger.msg(u,"Err")}send(n){if(n.type==="event"&&!this.canUseEvents){this.logger.hasLevel(3)&&this.logger.info(`Session does not support events: ignored event: ${ux(n)}`);return}this.writeMessage(n)}writeMessage(n){const o=wNe(n,this.logger,this.byteLength,this.host.newLine);this.host.write(o)}event(n,o){this.send(CNe(o,n))}doOutput(n,o,c,u,p,m){const v={seq:0,type:"response",command:o,request_seq:c,success:u,performanceData:p&&M_t(p)};if(u){let y;if(Js(n))v.body=n,y=n.metadata,delete n.metadata;else if(typeof n=="object")if(n.metadata){const{metadata:T,...E}=n;v.body=E,y=T}else v.body=n;else v.body=n;y&&(v.metadata=y)}else U.assert(n===void 0);m&&(v.message=m),this.send(v)}semanticCheck(n,o){var c,u;const p=Vc();(c=yi)==null||c.push(yi.Phase.Session,"semanticCheck",{file:n,configFilePath:o.canonicalConfigFilePath});const m=C_t(o,n)?Ff:o.getLanguageService().getSemanticDiagnostics(n).filter(v=>!!v.file);this.sendDiagnosticsEvent(n,o,m,"semanticDiag",p),(u=yi)==null||u.pop()}syntacticCheck(n,o){var c,u;const p=Vc();(c=yi)==null||c.push(yi.Phase.Session,"syntacticCheck",{file:n,configFilePath:o.canonicalConfigFilePath}),this.sendDiagnosticsEvent(n,o,o.getLanguageService().getSyntacticDiagnostics(n),"syntaxDiag",p),(u=yi)==null||u.pop()}suggestionCheck(n,o){var c,u;const p=Vc();(c=yi)==null||c.push(yi.Phase.Session,"suggestionCheck",{file:n,configFilePath:o.canonicalConfigFilePath}),this.sendDiagnosticsEvent(n,o,o.getLanguageService().getSuggestionDiagnostics(n),"suggestionDiag",p),(u=yi)==null||u.pop()}regionSemanticCheck(n,o,c){var u,p,m;const v=Vc();(u=yi)==null||u.push(yi.Phase.Session,"regionSemanticCheck",{file:n,configFilePath:o.canonicalConfigFilePath});let y;if(!this.shouldDoRegionCheck(n)||!(y=o.getLanguageService().getRegionSemanticDiagnostics(n,c))){(p=yi)==null||p.pop();return}this.sendDiagnosticsEvent(n,o,y.diagnostics,"regionSemanticDiag",v,y.spans),(m=yi)==null||m.pop()}shouldDoRegionCheck(n){var o;const c=(o=this.projectService.getScriptInfoForNormalizedPath(n))==null?void 0:o.textStorage.getLineInfo().getLineCount();return!!(c&&c>=this.regionDiagLineCountThreshold)}sendDiagnosticsEvent(n,o,c,u,p,m){try{const v=U.checkDefined(o.getScriptInfo(n)),y=Vc()-p,T={file:n,diagnostics:c.map(E=>E_t(n,o,E)),spans:m?.map(E=>p0(E,v))};this.event(T,u),this.addDiagnosticsPerformanceData(n,u,y)}catch(v){this.logError(v,u)}}updateErrorCheck(n,o,c,u=!0){if(o.length===0)return;U.assert(!this.suppressDiagnosticEvents);const p=this.changeSeq,m=Math.min(c,200);let v=0;const y=()=>{if(v++,o.length>v)return n.delay("checkOne",m,E)},T=(I,R)=>{if(this.semanticCheck(I,R),this.changeSeq===p){if(this.getPreferences(I).disableSuggestions)return y();n.immediate("suggestionCheck",()=>{this.suggestionCheck(I,R),y()})}},E=()=>{if(this.changeSeq!==p)return;let I,R=o[v];if(no(R)?R=this.toPendingErrorCheck(R):"ranges"in R&&(I=R.ranges,R=this.toPendingErrorCheck(R.file)),!R)return y();const{fileName:M,project:$}=R;if(_g($),!!$.containsFile(M,u)&&(this.syntacticCheck(M,$),this.changeSeq===p)){if($.projectService.serverMode!==0)return y();if(I)return n.immediate("regionSemanticCheck",()=>{const V=this.projectService.getScriptInfoForNormalizedPath(M);V&&this.regionSemanticCheck(M,$,I.map(H=>this.getRange({file:M,...H},V))),this.changeSeq===p&&n.immediate("semanticCheck",()=>T(M,$))});n.immediate("semanticCheck",()=>T(M,$))}};o.length>v&&this.changeSeq===p&&n.delay("checkOne",c,E)}cleanProjects(n,o){if(o){this.logger.info(`cleaning ${n}`);for(const c of o)c.getLanguageService(!1).cleanupSemanticCache(),c.cleanupProgram()}}cleanup(){this.cleanProjects("inferred projects",this.projectService.inferredProjects),this.cleanProjects("configured projects",Qn(this.projectService.configuredProjects.values())),this.cleanProjects("external projects",this.projectService.externalProjects),this.host.gc&&(this.logger.info("host.gc()"),this.host.gc())}getEncodedSyntacticClassifications(n){const{file:o,languageService:c}=this.getFileAndLanguageServiceForSyntacticOperation(n);return c.getEncodedSyntacticClassifications(o,n)}getEncodedSemanticClassifications(n){const{file:o,project:c}=this.getFileAndProject(n),u=n.format==="2020"?"2020":"original";return c.getLanguageService().getEncodedSemanticClassifications(o,n,u)}getProject(n){return n===void 0?void 0:this.projectService.findProject(n)}getConfigFileAndProject(n){const o=this.getProject(n.projectFileName),c=Bc(n.file);return{configFile:o&&o.hasConfigFile(c)?c:void 0,project:o}}getConfigFileDiagnostics(n,o,c){const u=o.getAllProjectErrors(),p=o.getLanguageService().getCompilerOptionsDiagnostics(),m=vt(Nr(u,p),v=>!!v.file&&v.file.fileName===n);return c?this.convertToDiagnosticsWithLinePositionFromDiagnosticFile(m):Le(m,v=>PB(v,!1))}convertToDiagnosticsWithLinePositionFromDiagnosticFile(n){return n.map(o=>({message:c0(o.messageText,this.host.newLine),start:o.start,length:o.length,category:LE(o),code:o.code,source:o.source,startLocation:o.file&&J6(ma(o.file,o.start)),endLocation:o.file&&J6(ma(o.file,o.start+o.length)),reportsUnnecessary:o.reportsUnnecessary,reportsDeprecated:o.reportsDeprecated,relatedInformation:Le(o.relatedInformation,_fe)}))}getCompilerOptionsDiagnostics(n){const o=this.getProject(n.projectFileName);return this.convertToDiagnosticsWithLinePosition(vt(o.getLanguageService().getCompilerOptionsDiagnostics(),c=>!c.file),void 0)}convertToDiagnosticsWithLinePosition(n,o){return n.map(c=>({message:c0(c.messageText,this.host.newLine),start:c.start,length:c.length,category:LE(c),code:c.code,source:c.source,startLocation:o&&o.positionToLineOffset(c.start),endLocation:o&&o.positionToLineOffset(c.start+c.length),reportsUnnecessary:c.reportsUnnecessary,reportsDeprecated:c.reportsDeprecated,relatedInformation:Le(c.relatedInformation,_fe)}))}getDiagnosticsWorker(n,o,c,u){const{project:p,file:m}=this.getFileAndProject(n);if(o&&C_t(p,m))return Ff;const v=p.getScriptInfoForNormalizedPath(m),y=c(p,m);return u?this.convertToDiagnosticsWithLinePosition(y,v):y.map(T=>E_t(m,p,T))}getDefinition(n,o){const{file:c,project:u}=this.getFileAndProject(n),p=this.getPositionInFile(n,c),m=this.mapDefinitionInfoLocations(u.getLanguageService().getDefinitionAtPosition(c,p)||Ff,u);return o?this.mapDefinitionInfo(m,u):m.map(ame.mapToOriginalLocation)}mapDefinitionInfoLocations(n,o){return n.map(c=>{const u=O_t(c,o);return u?{...u,containerKind:c.containerKind,containerName:c.containerName,kind:c.kind,name:c.name,failedAliasResolution:c.failedAliasResolution,...c.unverified&&{unverified:c.unverified}}:c})}getDefinitionAndBoundSpan(n,o){const{file:c,project:u}=this.getFileAndProject(n),p=this.getPositionInFile(n,c),m=U.checkDefined(u.getScriptInfo(c)),v=u.getLanguageService().getDefinitionAndBoundSpan(c,p);if(!v||!v.definitions)return{definitions:Ff,textSpan:void 0};const y=this.mapDefinitionInfoLocations(v.definitions,u),{textSpan:T}=v;return o?{definitions:this.mapDefinitionInfo(y,u),textSpan:p0(T,m)}:{definitions:y.map(ame.mapToOriginalLocation),textSpan:T}}findSourceDefinition(n){var o;const{file:c,project:u}=this.getFileAndProject(n),p=this.getPositionInFile(n,c),m=u.getLanguageService().getDefinitionAtPosition(c,p);let v=this.mapDefinitionInfoLocations(m||Ff,u).slice();if(this.projectService.serverMode===0&&(!_t(v,M=>Bc(M.fileName)!==c&&!M.isAmbient)||_t(v,M=>!!M.failedAliasResolution))){const M=Wf(K=>K.textSpan.start,kce(this.host.useCaseSensitiveFileNames));v?.forEach(K=>M.add(K));const $=u.getNoDtsResolutionProject(c),V=$.getLanguageService(),H=(o=V.getDefinitionAtPosition(c,p,!0,!1))==null?void 0:o.filter(K=>Bc(K.fileName)!==c);if(_t(H))for(const K of H){if(K.unverified){const te=I(K,u.getLanguageService().getProgram(),V.getProgram());if(_t(te)){for(const Z of te)M.add(Z);continue}}M.add(K)}else{const K=v.filter(te=>Bc(te.fileName)!==c&&te.isAmbient);for(const te of _t(K)?K:E()){const Z=T(te.fileName,c,$);if(!Z)continue;const ie=this.projectService.getOrCreateScriptInfoNotOpenedByClient(Z,$.currentDirectory,$.directoryStructureHost,!1);if(!ie)continue;$.containsScriptInfo(ie)||($.addRoot(ie),$.updateGraph());const ae=V.getProgram(),_e=U.checkDefined(ae.getSourceFile(Z));for(const be of R(te.name,_e,ae))M.add(be)}}v=Qn(M.values())}return v=v.filter(M=>!M.isAmbient&&!M.failedAliasResolution),this.mapDefinitionInfo(v,u);function T(M,$,V){var H,K,te;const Z=qJ(M);if(Z&&M.lastIndexOf(Uv)===Z.topLevelNodeModulesIndex){const ie=M.substring(0,Z.packageRootIndex),ae=(H=u.getModuleResolutionCache())==null?void 0:H.getPackageJsonInfoCache(),_e=u.getCompilationSettings(),be=X5(yo(ie,u.getCurrentDirectory()),Y5(ae,u,_e));if(!be)return;const pe=Kse(be,{moduleResolution:2},u,u.getModuleResolutionCache()),Be=M.substring(Z.topLevelPackageNameIndex+1,Z.packageRootIndex),Ee=Z5(tj(Be)),me=u.toPath(M);if(pe&&_t(pe,Oe=>u.toPath(Oe)===me))return(K=V.resolutionCache.resolveSingleModuleNameWithoutWatching(Ee,$).resolvedModule)==null?void 0:K.resolvedFileName;{const Oe=M.substring(Z.packageRootIndex+1),Ne=`${Ee}/${kp(Oe)}`;return(te=V.resolutionCache.resolveSingleModuleNameWithoutWatching(Ne,$).resolvedModule)==null?void 0:te.resolvedFileName}}}function E(){const M=u.getLanguageService(),$=M.getProgram(),V=h_($.getSourceFile(c),p);return(bc(V)||gt(V))&&cl(V.parent)&&Ixe(V,H=>{var K;if(H===V)return;const te=(K=M.getDefinitionAtPosition(c,H.getStart(),!0,!1))==null?void 0:K.filter(Z=>Bc(Z.fileName)!==c&&Z.isAmbient).map(Z=>({fileName:Z.fileName,name:wh(V)}));if(_t(te))return te})||Ff}function I(M,$,V){var H;const K=V.getSourceFile(M.fileName);if(!K)return;const te=h_($.getSourceFile(c),p),Z=$.getTypeChecker().getSymbolAtLocation(te),ie=Z&&bl(Z,277);if(!ie)return;const ae=((H=ie.propertyName)==null?void 0:H.text)||ie.name.text;return R(ae,K,V)}function R(M,$,V){const H=ul.Core.getTopMostDeclarationNamesInFile(M,$);return ln(H,K=>{const te=V.getTypeChecker().getSymbolAtLocation(K),Z=QO(K);if(te&&Z)return $6.createDefinitionInfo(Z,V.getTypeChecker(),te,Z,!0)})}}getEmitOutput(n){const{file:o,project:c}=this.getFileAndProject(n);if(!c.shouldEmitFile(c.getScriptInfo(o)))return{emitSkipped:!0,outputFiles:[],diagnostics:[]};const u=c.getLanguageService().getEmitOutput(o);return n.richResponse?{...u,diagnostics:n.includeLinePosition?this.convertToDiagnosticsWithLinePositionFromDiagnosticFile(u.diagnostics):u.diagnostics.map(p=>PB(p,!0))}:u}mapJSDocTagInfo(n,o,c){return n?n.map(u=>{var p;return{...u,text:c?this.mapDisplayParts(u.text,o):(p=u.text)==null?void 0:p.map(m=>m.text).join("")}}):[]}mapDisplayParts(n,o){return n?n.map(c=>c.kind!=="linkName"?c:{...c,target:this.toFileSpan(c.target.fileName,c.target.textSpan,o)}):[]}mapSignatureHelpItems(n,o,c){return n.map(u=>({...u,documentation:this.mapDisplayParts(u.documentation,o),parameters:u.parameters.map(p=>({...p,documentation:this.mapDisplayParts(p.documentation,o)})),tags:this.mapJSDocTagInfo(u.tags,o,c)}))}mapDefinitionInfo(n,o){return n.map(c=>({...this.toFileSpanWithContext(c.fileName,c.textSpan,c.contextSpan,o),...c.unverified&&{unverified:c.unverified}}))}static mapToOriginalLocation(n){return n.originalFileName?(U.assert(n.originalTextSpan!==void 0,"originalTextSpan should be present if originalFileName is"),{...n,fileName:n.originalFileName,textSpan:n.originalTextSpan,targetFileName:n.fileName,targetTextSpan:n.textSpan,contextSpan:n.originalContextSpan,targetContextSpan:n.contextSpan}):n}toFileSpan(n,o,c){const u=c.getLanguageService(),p=u.toLineColumnOffset(n,o.start),m=u.toLineColumnOffset(n,zl(o));return{file:n,start:{line:p.line+1,offset:p.character+1},end:{line:m.line+1,offset:m.character+1}}}toFileSpanWithContext(n,o,c,u){const p=this.toFileSpan(n,o,u),m=c&&this.toFileSpan(n,c,u);return m?{...p,contextStart:m.start,contextEnd:m.end}:p}getTypeDefinition(n){const{file:o,project:c}=this.getFileAndProject(n),u=this.getPositionInFile(n,o),p=this.mapDefinitionInfoLocations(c.getLanguageService().getTypeDefinitionAtPosition(o,u)||Ff,c);return this.mapDefinitionInfo(p,c)}mapImplementationLocations(n,o){return n.map(c=>{const u=O_t(c,o);return u?{...u,kind:c.kind,displayParts:c.displayParts}:c})}getImplementation(n,o){const{file:c,project:u}=this.getFileAndProject(n),p=this.getPositionInFile(n,c),m=this.mapImplementationLocations(u.getLanguageService().getImplementationAtPosition(c,p)||Ff,u);return o?m.map(({fileName:v,textSpan:y,contextSpan:T})=>this.toFileSpanWithContext(v,y,T,u)):m.map(ame.mapToOriginalLocation)}getSyntacticDiagnosticsSync(n){const{configFile:o}=this.getConfigFileAndProject(n);return o?Ff:this.getDiagnosticsWorker(n,!1,(c,u)=>c.getLanguageService().getSyntacticDiagnostics(u),!!n.includeLinePosition)}getSemanticDiagnosticsSync(n){const{configFile:o,project:c}=this.getConfigFileAndProject(n);return o?this.getConfigFileDiagnostics(o,c,!!n.includeLinePosition):this.getDiagnosticsWorker(n,!0,(u,p)=>u.getLanguageService().getSemanticDiagnostics(p).filter(m=>!!m.file),!!n.includeLinePosition)}getSuggestionDiagnosticsSync(n){const{configFile:o}=this.getConfigFileAndProject(n);return o?Ff:this.getDiagnosticsWorker(n,!0,(c,u)=>c.getLanguageService().getSuggestionDiagnostics(u),!!n.includeLinePosition)}getJsxClosingTag(n){const{file:o,languageService:c}=this.getFileAndLanguageServiceForSyntacticOperation(n),u=this.getPositionInFile(n,o),p=c.getJsxClosingTagAtPosition(o,u);return p===void 0?void 0:{newText:p.newText,caretOffset:0}}getLinkedEditingRange(n){const{file:o,languageService:c}=this.getFileAndLanguageServiceForSyntacticOperation(n),u=this.getPositionInFile(n,o),p=c.getLinkedEditingRangeAtPosition(o,u),m=this.projectService.getScriptInfoForNormalizedPath(o);if(!(m===void 0||p===void 0))return Myr(p,m)}getDocumentHighlights(n,o){const{file:c,project:u}=this.getFileAndProject(n),p=this.getPositionInFile(n,c),m=u.getLanguageService().getDocumentHighlights(c,p,n.filesToSearch);return m?o?m.map(({fileName:v,highlightSpans:y})=>{const T=u.getScriptInfo(v);return{file:v,highlightSpans:y.map(({textSpan:E,kind:I,contextSpan:R})=>({...TNe(E,R,T),kind:I}))}}):m:Ff}provideInlayHints(n){const{file:o,project:c}=this.getFileAndProject(n),u=this.projectService.getScriptInfoForNormalizedPath(o);return c.getLanguageService().provideInlayHints(o,n,this.getPreferences(o)).map(m=>{const{position:v,displayParts:y}=m;return{...m,position:u.positionToLineOffset(v),displayParts:y?.map(({text:T,span:E,file:I})=>{if(E){U.assertIsDefined(I,"Target file should be defined together with its span.");const R=this.projectService.getScriptInfo(I);return{text:T,span:{start:R.positionToLineOffset(E.start),end:R.positionToLineOffset(E.start+E.length),file:I}}}else return{text:T}})}})}mapCode(n){var o;const c=this.getHostFormatOptions(),u=this.getHostPreferences(),{file:p,languageService:m}=this.getFileAndLanguageServiceForSyntacticOperation(n),v=this.projectService.getScriptInfoForNormalizedPath(p),y=(o=n.mapping.focusLocations)==null?void 0:o.map(E=>E.map(I=>{const R=v.lineOffsetToPosition(I.start.line,I.start.offset),M=v.lineOffsetToPosition(I.end.line,I.end.offset);return{start:R,length:M-R}})),T=m.mapCode(p,n.mapping.contents,y,c,u);return this.mapTextChangesToCodeEdits(T)}getCopilotRelatedInfo(){return{relatedFiles:[]}}setCompilerOptionsForInferredProjects(n){this.projectService.setCompilerOptionsForInferredProjects(n.options,n.projectRootPath)}getProjectInfo(n){return this.getProjectInfoWorker(n.file,n.projectFileName,n.needFileNameList,n.needDefaultConfiguredProjectInfo,!1)}getProjectInfoWorker(n,o,c,u,p){const{project:m}=this.getFileAndProjectWorker(n,o);return _g(m),{configFileName:m.getProjectName(),languageServiceDisabled:!m.languageServiceEnabled,fileNames:c?m.getFileNames(!1,p):void 0,configuredProjectInfo:u?this.getDefaultConfiguredProjectInfo(n):void 0}}getDefaultConfiguredProjectInfo(n){var o;const c=this.projectService.getScriptInfo(n);if(!c)return;const u=this.projectService.findDefaultConfiguredProjectWorker(c,3);if(!u)return;let p,m;return u.seenProjects.forEach((v,y)=>{y!==u.defaultProject&&(v!==3?(p??(p=[])).push(Bc(y.getConfigFilePath())):(m??(m=[])).push(Bc(y.getConfigFilePath())))}),(o=u.seenConfigs)==null||o.forEach(v=>(p??(p=[])).push(v)),{notMatchedByConfig:p,notInProject:m,defaultProject:u.defaultProject&&Bc(u.defaultProject.getConfigFilePath())}}getRenameInfo(n){const{file:o,project:c}=this.getFileAndProject(n),u=this.getPositionInFile(n,o),p=this.getPreferences(o);return c.getLanguageService().getRenameInfo(o,u,p)}getProjects(n,o,c){let u,p;if(n.projectFileName){const m=this.getProject(n.projectFileName);m&&(u=[m])}else{const m=o?this.projectService.getScriptInfoEnsuringProjectsUptoDate(n.file):this.projectService.getScriptInfo(n.file);if(m)o||this.projectService.ensureDefaultProjectForFile(m);else return c?Ff:(this.projectService.logErrorForScriptInfoNotFound(n.file),q1.ThrowNoProject());u=m.containingProjects,p=this.projectService.getSymlinkedProjects(m)}return u=vt(u,m=>m.languageServiceEnabled&&!m.isOrphan()),!c&&(!u||!u.length)&&!p?(this.projectService.logErrorForScriptInfoNotFound(n.file??n.projectFileName),q1.ThrowNoProject()):p?{projects:u,symLinkedProjects:p}:u}getDefaultProject(n){if(n.projectFileName){const c=this.getProject(n.projectFileName);if(c)return c;if(!n.file)return q1.ThrowNoProject()}return this.projectService.getScriptInfo(n.file).getDefaultProject()}getRenameLocations(n,o){const c=Bc(n.file),u=this.getPositionInFile(n,c),p=this.getProjects(n),m=this.getDefaultProject(n),v=this.getPreferences(c),y=this.mapRenameInfo(m.getLanguageService().getRenameInfo(c,u,v),U.checkDefined(this.projectService.getScriptInfo(c)));if(!y.canRename)return o?{info:y,locs:[]}:[];const T=Dyr(p,m,{fileName:n.file,pos:u},!!n.findInStrings,!!n.findInComments,v,this.host.useCaseSensitiveFileNames);return o?{info:y,locs:this.toSpanGroups(T)}:T}mapRenameInfo(n,o){if(n.canRename){const{canRename:c,fileToRename:u,displayName:p,fullDisplayName:m,kind:v,kindModifiers:y,triggerSpan:T}=n;return{canRename:c,fileToRename:u,displayName:p,fullDisplayName:m,kind:v,kindModifiers:y,triggerSpan:p0(T,o)}}else return n}toSpanGroups(n){const o=new Map;for(const{fileName:c,textSpan:u,contextSpan:p,originalContextSpan:m,originalTextSpan:v,originalFileName:y,...T}of n){let E=o.get(c);E||o.set(c,E={file:c,locs:[]});const I=U.checkDefined(this.projectService.getScriptInfo(c));E.locs.push({...TNe(u,p,I),...T})}return Qn(o.values())}getReferences(n,o){const c=Bc(n.file),u=this.getProjects(n),p=this.getPositionInFile(n,c),m=Pyr(u,this.getDefaultProject(n),{fileName:n.file,pos:p},this.host.useCaseSensitiveFileNames,this.logger);if(!o)return m;const v=this.getPreferences(c),y=this.getDefaultProject(n),T=y.getScriptInfoForNormalizedPath(c),E=y.getLanguageService().getQuickInfoAtPosition(c,p),I=E?tB(E.displayParts):"",R=E&&E.textSpan,M=R?T.positionToLineOffset(R.start).offset:0,$=R?T.getSnapshot().getText(R.start,zl(R)):"";return{refs:nn(m,H=>H.references.map(K=>j_t(this.projectService,K,v))),symbolName:$,symbolStartOffset:M,symbolDisplayString:I}}getFileReferences(n,o){const c=this.getProjects(n),u=Bc(n.file),p=this.getPreferences(u),m={fileName:u,pos:0},v=ENe(c,this.getDefaultProject(n),m,m,D_t,E=>(this.logger.info(`Finding references to file ${u} in project ${E.getProjectName()}`),E.getLanguageService().getFileReferences(u)));let y;if(Js(v))y=v;else{y=[];const E=mfe(this.host.useCaseSensitiveFileNames);v.forEach(I=>{for(const R of I)E.has(R)||(y.push(R),E.add(R))})}return o?{refs:y.map(E=>j_t(this.projectService,E,p)),symbolName:`"${n.file}"`}:y}openClientFile(n,o,c,u){this.projectService.openClientFileWithNormalizedPath(n,o,c,!1,u)}getPosition(n,o){return n.position!==void 0?n.position:o.lineOffsetToPosition(n.line,n.offset)}getPositionInFile(n,o){const c=this.projectService.getScriptInfoForNormalizedPath(o);return this.getPosition(n,c)}getFileAndProject(n){return this.getFileAndProjectWorker(n.file,n.projectFileName)}getFileAndLanguageServiceForSyntacticOperation(n){const{file:o,project:c}=this.getFileAndProject(n);return{file:o,languageService:c.getLanguageService(!1)}}getFileAndProjectWorker(n,o){const c=Bc(n),u=this.getProject(o)||this.projectService.ensureDefaultProjectForFile(c);return{file:c,project:u}}getOutliningSpans(n,o){const{file:c,languageService:u}=this.getFileAndLanguageServiceForSyntacticOperation(n),p=u.getOutliningSpans(c);if(o){const m=this.projectService.getScriptInfoForNormalizedPath(c);return p.map(v=>({textSpan:p0(v.textSpan,m),hintSpan:p0(v.hintSpan,m),bannerText:v.bannerText,autoCollapse:v.autoCollapse,kind:v.kind}))}else return p}getTodoComments(n){const{file:o,project:c}=this.getFileAndProject(n);return c.getLanguageService().getTodoComments(o,n.descriptors)}getDocCommentTemplate(n){const{file:o,languageService:c}=this.getFileAndLanguageServiceForSyntacticOperation(n),u=this.getPositionInFile(n,o);return c.getDocCommentTemplateAtPosition(o,u,this.getPreferences(o),this.getFormatOptions(o))}getSpanOfEnclosingComment(n){const{file:o,languageService:c}=this.getFileAndLanguageServiceForSyntacticOperation(n),u=n.onlyMultiLine,p=this.getPositionInFile(n,o);return c.getSpanOfEnclosingComment(o,p,u)}getIndentation(n){const{file:o,languageService:c}=this.getFileAndLanguageServiceForSyntacticOperation(n),u=this.getPositionInFile(n,o),p=n.options?V6(n.options):this.getFormatOptions(o),m=c.getIndentationAtPosition(o,u,p);return{position:u,indentation:m}}getBreakpointStatement(n){const{file:o,languageService:c}=this.getFileAndLanguageServiceForSyntacticOperation(n),u=this.getPositionInFile(n,o);return c.getBreakpointStatementAtPosition(o,u)}getNameOrDottedNameSpan(n){const{file:o,languageService:c}=this.getFileAndLanguageServiceForSyntacticOperation(n),u=this.getPositionInFile(n,o);return c.getNameOrDottedNameSpan(o,u,u)}isValidBraceCompletion(n){const{file:o,languageService:c}=this.getFileAndLanguageServiceForSyntacticOperation(n),u=this.getPositionInFile(n,o);return c.isValidBraceCompletionAtPosition(o,u,n.openingBrace.charCodeAt(0))}getQuickInfoWorker(n,o){const{file:c,project:u}=this.getFileAndProject(n),p=this.projectService.getScriptInfoForNormalizedPath(c),m=this.getPreferences(c),v=u.getLanguageService().getQuickInfoAtPosition(c,this.getPosition(n,p),m.maximumHoverLength,n.verbosityLevel);if(!v)return;const y=!!m.displayPartsForJSDoc;if(o){const T=tB(v.displayParts);return{kind:v.kind,kindModifiers:v.kindModifiers,start:p.positionToLineOffset(v.textSpan.start),end:p.positionToLineOffset(zl(v.textSpan)),displayString:T,documentation:y?this.mapDisplayParts(v.documentation,u):tB(v.documentation),tags:this.mapJSDocTagInfo(v.tags,u,y),canIncreaseVerbosityLevel:v.canIncreaseVerbosityLevel}}else return y?v:{...v,tags:this.mapJSDocTagInfo(v.tags,u,!1)}}getFormattingEditsForRange(n){const{file:o,languageService:c}=this.getFileAndLanguageServiceForSyntacticOperation(n),u=this.projectService.getScriptInfoForNormalizedPath(o),p=u.lineOffsetToPosition(n.line,n.offset),m=u.lineOffsetToPosition(n.endLine,n.endOffset),v=c.getFormattingEditsForRange(o,p,m,this.getFormatOptions(o));if(v)return v.map(y=>this.convertTextChangeToCodeEdit(y,u))}getFormattingEditsForRangeFull(n){const{file:o,languageService:c}=this.getFileAndLanguageServiceForSyntacticOperation(n),u=n.options?V6(n.options):this.getFormatOptions(o);return c.getFormattingEditsForRange(o,n.position,n.endPosition,u)}getFormattingEditsForDocumentFull(n){const{file:o,languageService:c}=this.getFileAndLanguageServiceForSyntacticOperation(n),u=n.options?V6(n.options):this.getFormatOptions(o);return c.getFormattingEditsForDocument(o,u)}getFormattingEditsAfterKeystrokeFull(n){const{file:o,languageService:c}=this.getFileAndLanguageServiceForSyntacticOperation(n),u=n.options?V6(n.options):this.getFormatOptions(o);return c.getFormattingEditsAfterKeystroke(o,n.position,n.key,u)}getFormattingEditsAfterKeystroke(n){const{file:o,languageService:c}=this.getFileAndLanguageServiceForSyntacticOperation(n),u=this.projectService.getScriptInfoForNormalizedPath(o),p=u.lineOffsetToPosition(n.line,n.offset),m=this.getFormatOptions(o),v=c.getFormattingEditsAfterKeystroke(o,p,n.key,m);if(n.key===`
|
|
522
522
|
`&&(!v||v.length===0||Tyr(v,p))){const{lineText:y,absolutePosition:T}=u.textStorage.getAbsolutePositionAndLineText(n.line);if(y&&y.search("\\S")<0){const E=c.getIndentationAtPosition(o,p,m);let I=0,R,M;for(R=0,M=y.length;R<M;R++)if(y.charAt(R)===" ")I++;else if(y.charAt(R)===" ")I+=m.tabSize;else break;if(E!==I){const $=T+R;v.push({span:Du(T,$),newText:ff.getIndentationString(E,m)})}}}if(v)return v.map(y=>({start:u.positionToLineOffset(y.span.start),end:u.positionToLineOffset(zl(y.span)),newText:y.newText?y.newText:""}))}getCompletions(n,o){const{file:c,project:u}=this.getFileAndProject(n),p=this.projectService.getScriptInfoForNormalizedPath(c),m=this.getPosition(n,p),v=u.getLanguageService().getCompletionsAtPosition(c,m,{...cNe(this.getPreferences(c)),triggerCharacter:n.triggerCharacter,triggerKind:n.triggerKind,includeExternalModuleExports:n.includeExternalModuleExports,includeInsertTextCompletions:n.includeInsertTextCompletions},u.projectService.getFormatCodeOptions(c));if(v===void 0)return;if(o==="completions-full")return v;const y=n.prefix||"",T=ln(v.entries,I=>{if(v.isMemberCompletion||co(I.name.toLowerCase(),y.toLowerCase())){const R=I.replacementSpan?p0(I.replacementSpan,p):void 0;return{...I,replacementSpan:R,hasAction:I.hasAction||void 0,symbol:void 0}}});return o==="completions"?(v.metadata&&(T.metadata=v.metadata),T):{...v,optionalReplacementSpan:v.optionalReplacementSpan&&p0(v.optionalReplacementSpan,p),entries:T}}getCompletionEntryDetails(n,o){const{file:c,project:u}=this.getFileAndProject(n),p=this.projectService.getScriptInfoForNormalizedPath(c),m=this.getPosition(n,p),v=u.projectService.getFormatCodeOptions(c),y=!!this.getPreferences(c).displayPartsForJSDoc,T=ln(n.entryNames,E=>{const{name:I,source:R,data:M}=typeof E=="string"?{name:E,source:void 0,data:void 0}:E;return u.getLanguageService().getCompletionEntryDetails(c,m,I,v,R,this.getPreferences(c),M?pa(M,qyr):void 0)});return o?y?T:T.map(E=>({...E,tags:this.mapJSDocTagInfo(E.tags,u,!1)})):T.map(E=>({...E,codeActions:Le(E.codeActions,I=>this.mapCodeAction(I)),documentation:this.mapDisplayParts(E.documentation,u),tags:this.mapJSDocTagInfo(E.tags,u,y)}))}getCompileOnSaveAffectedFileList(n){const o=this.getProjects(n,!0,!0),c=this.projectService.getScriptInfo(n.file);return c?Iyr(c,u=>this.projectService.getScriptInfoForPath(u),o,(u,p)=>{if(!u.compileOnSaveEnabled||!u.languageServiceEnabled||u.isOrphan())return;const m=u.getCompilationSettings();if(!(m.noEmit||Qf(p.fileName)&&!Eyr(m)))return{projectFileName:u.getProjectName(),fileNames:u.getCompileOnSaveAffectedFileList(p),projectUsesOutFile:!!m.outFile}}):Ff}emitFile(n){const{file:o,project:c}=this.getFileAndProject(n);if(c||q1.ThrowNoProject(),!c.languageServiceEnabled)return n.richResponse?{emitSkipped:!0,diagnostics:[]}:!1;const u=c.getScriptInfo(o),{emitSkipped:p,diagnostics:m}=c.emitFile(u,(v,y,T)=>this.host.writeFile(v,y,T));return n.richResponse?{emitSkipped:p,diagnostics:n.includeLinePosition?this.convertToDiagnosticsWithLinePositionFromDiagnosticFile(m):m.map(v=>PB(v,!0))}:!p}getSignatureHelpItems(n,o){const{file:c,project:u}=this.getFileAndProject(n),p=this.projectService.getScriptInfoForNormalizedPath(c),m=this.getPosition(n,p),v=u.getLanguageService().getSignatureHelpItems(c,m,n),y=!!this.getPreferences(c).displayPartsForJSDoc;if(v&&o){const T=v.applicableSpan;return{...v,applicableSpan:{start:p.positionToLineOffset(T.start),end:p.positionToLineOffset(T.start+T.length)},items:this.mapSignatureHelpItems(v.items,u,y)}}else return y||!v?v:{...v,items:v.items.map(T=>({...T,tags:this.mapJSDocTagInfo(T.tags,u,!1)}))}}toPendingErrorCheck(n){const o=Bc(n),c=this.projectService.tryGetDefaultProjectForFile(o);return c&&{fileName:o,project:c}}getDiagnostics(n,o,c){this.suppressDiagnosticEvents||c.length>0&&this.updateErrorCheck(n,c,o)}change(n){const o=this.projectService.getScriptInfo(n.file);U.assert(!!o),o.textStorage.switchToScriptVersionCache();const c=o.lineOffsetToPosition(n.line,n.offset),u=o.lineOffsetToPosition(n.endLine,n.endOffset);c>=0&&(this.changeSeq++,this.projectService.applyChangesToFile(o,Zc({span:{start:c,length:u-c},newText:n.insertString})))}reload(n){const o=Bc(n.file),c=n.tmpfile===void 0?void 0:Bc(n.tmpfile),u=this.projectService.getScriptInfoForNormalizedPath(o);u&&(this.changeSeq++,u.reloadFromFile(c))}saveToTmp(n,o){const c=this.projectService.getScriptInfo(n);c&&c.saveTo(o)}closeClientFile(n){if(!n)return;const o=xa(n);this.projectService.closeClientFile(o)}mapLocationNavigationBarItems(n,o){return Le(n,c=>({text:c.text,kind:c.kind,kindModifiers:c.kindModifiers,spans:c.spans.map(u=>p0(u,o)),childItems:this.mapLocationNavigationBarItems(c.childItems,o),indent:c.indent}))}getNavigationBarItems(n,o){const{file:c,languageService:u}=this.getFileAndLanguageServiceForSyntacticOperation(n),p=u.getNavigationBarItems(c);return p?o?this.mapLocationNavigationBarItems(p,this.projectService.getScriptInfoForNormalizedPath(c)):p:void 0}toLocationNavigationTree(n,o){return{text:n.text,kind:n.kind,kindModifiers:n.kindModifiers,spans:n.spans.map(c=>p0(c,o)),nameSpan:n.nameSpan&&p0(n.nameSpan,o),childItems:Le(n.childItems,c=>this.toLocationNavigationTree(c,o))}}getNavigationTree(n,o){const{file:c,languageService:u}=this.getFileAndLanguageServiceForSyntacticOperation(n),p=u.getNavigationTree(c);return p?o?this.toLocationNavigationTree(p,this.projectService.getScriptInfoForNormalizedPath(c)):p:void 0}getNavigateToItems(n,o){const c=this.getFullNavigateToItems(n);return o?nn(c,({project:u,navigateToItems:p})=>p.map(m=>{const v=u.getScriptInfo(m.fileName),y={name:m.name,kind:m.kind,kindModifiers:m.kindModifiers,isCaseSensitive:m.isCaseSensitive,matchKind:m.matchKind,file:m.fileName,start:v.positionToLineOffset(m.textSpan.start),end:v.positionToLineOffset(zl(m.textSpan))};return m.kindModifiers&&m.kindModifiers!==""&&(y.kindModifiers=m.kindModifiers),m.containerName&&m.containerName.length>0&&(y.containerName=m.containerName),m.containerKind&&m.containerKind.length>0&&(y.containerKind=m.containerKind),y})):nn(c,({navigateToItems:u})=>u)}getFullNavigateToItems(n){const{currentFileOnly:o,searchValue:c,maxResultCount:u,projectFileName:p}=n;if(o){U.assertIsDefined(n.file);const{file:R,project:M}=this.getFileAndProject(n);return[{project:M,navigateToItems:M.getLanguageService().getNavigateToItems(c,u,R)}]}const m=this.getHostPreferences(),v=[],y=new Map;if(!n.file&&!p)this.projectService.loadAncestorProjectTree(),this.projectService.forEachEnabledProject(R=>T(R));else{const R=this.getProjects(n);I_t(R,void 0,M=>T(M))}return v;function T(R){const M=R.getLanguageService().getNavigateToItems(c,u,void 0,R.isNonTsProject(),m.excludeLibrarySymbolsInNavTo),$=vt(M,V=>E(V)&&!hfe(HF(V),R));$.length&&v.push({project:R,navigateToItems:$})}function E(R){const M=R.name;if(!y.has(M))return y.set(M,[R]),!0;const $=y.get(M);for(const V of $)if(I(V,R))return!1;return $.push(R),!0}function I(R,M){return R===M?!0:!R||!M?!1:R.containerKind===M.containerKind&&R.containerName===M.containerName&&R.fileName===M.fileName&&R.isCaseSensitive===M.isCaseSensitive&&R.kind===M.kind&&R.kindModifiers===M.kindModifiers&&R.matchKind===M.matchKind&&R.name===M.name&&R.textSpan.start===M.textSpan.start&&R.textSpan.length===M.textSpan.length}}getSupportedCodeFixes(n){if(!n)return Ole();if(n.file){const{file:c,project:u}=this.getFileAndProject(n);return u.getLanguageService().getSupportedCodeFixes(c)}const o=this.getProject(n.projectFileName);return o||q1.ThrowNoProject(),o.getLanguageService().getSupportedCodeFixes()}isLocation(n){return n.line!==void 0}extractPositionOrRange(n,o){let c,u;return this.isLocation(n)?c=p(n):u=this.getRange(n,o),U.checkDefined(c===void 0?u:c);function p(m){return m.position!==void 0?m.position:o.lineOffsetToPosition(m.line,m.offset)}}getRange(n,o){const{startPosition:c,endPosition:u}=this.getStartAndEndPosition(n,o);return{pos:c,end:u}}getApplicableRefactors(n){const{file:o,project:c}=this.getFileAndProject(n),u=c.getScriptInfoForNormalizedPath(o);return c.getLanguageService().getApplicableRefactors(o,this.extractPositionOrRange(n,u),this.getPreferences(o),n.triggerReason,n.kind,n.includeInteractiveActions).map(m=>({...m,actions:m.actions.map(v=>({...v,range:v.range?{start:J6({line:v.range.start.line,character:v.range.start.offset}),end:J6({line:v.range.end.line,character:v.range.end.offset})}:void 0}))}))}getEditsForRefactor(n,o){const{file:c,project:u}=this.getFileAndProject(n),p=u.getScriptInfoForNormalizedPath(c),m=u.getLanguageService().getEditsForRefactor(c,this.getFormatOptions(c),this.extractPositionOrRange(n,p),n.refactor,n.action,this.getPreferences(c),n.interactiveRefactorArguments);if(m===void 0)return{edits:[]};if(o){const{renameFilename:v,renameLocation:y,edits:T}=m;let E;if(v!==void 0&&y!==void 0){const I=u.getScriptInfoForNormalizedPath(Bc(v));E=kNe($D(I.getSnapshot()),v,y,T)}return{renameLocation:E,renameFilename:v,edits:this.mapTextChangesToCodeEdits(T),notApplicableReason:m.notApplicableReason}}return m}getMoveToRefactoringFileSuggestions(n){const{file:o,project:c}=this.getFileAndProject(n),u=c.getScriptInfoForNormalizedPath(o);return c.getLanguageService().getMoveToRefactoringFileSuggestions(o,this.extractPositionOrRange(n,u),this.getPreferences(o))}preparePasteEdits(n){const{file:o,project:c}=this.getFileAndProject(n);return c.getLanguageService().preparePasteEditsForFile(o,n.copiedTextSpan.map(u=>this.getRange({file:o,startLine:u.start.line,startOffset:u.start.offset,endLine:u.end.line,endOffset:u.end.offset},this.projectService.getScriptInfoForNormalizedPath(o))))}getPasteEdits(n){const{file:o,project:c}=this.getFileAndProject(n);if(JF(o))return;const u=n.copiedFrom?{file:n.copiedFrom.file,range:n.copiedFrom.spans.map(m=>this.getRange({file:n.copiedFrom.file,startLine:m.start.line,startOffset:m.start.offset,endLine:m.end.line,endOffset:m.end.offset},c.getScriptInfoForNormalizedPath(Bc(n.copiedFrom.file))))}:void 0,p=c.getLanguageService().getPasteEdits({targetFile:o,pastedText:n.pastedText,pasteLocations:n.pasteLocations.map(m=>this.getRange({file:o,startLine:m.start.line,startOffset:m.start.offset,endLine:m.end.line,endOffset:m.end.offset},c.getScriptInfoForNormalizedPath(o))),copiedFrom:u,preferences:this.getPreferences(o)},this.getFormatOptions(o));return p&&this.mapPasteEditsAction(p)}organizeImports(n,o){U.assert(n.scope.type==="file");const{file:c,project:u}=this.getFileAndProject(n.scope.args),p=u.getLanguageService().organizeImports({fileName:c,mode:n.mode??(n.skipDestructiveCodeActions?"SortAndCombine":void 0),type:"file"},this.getFormatOptions(c),this.getPreferences(c));return o?this.mapTextChangesToCodeEdits(p):p}getEditsForFileRename(n,o){const c=Bc(n.oldFilePath),u=Bc(n.newFilePath),p=this.getHostFormatOptions(),m=this.getHostPreferences(),v=new Set,y=[];return this.projectService.loadAncestorProjectTree(),this.projectService.forEachEnabledProject(T=>{const E=T.getLanguageService().getEditsForFileRename(c,u,p,m),I=[];for(const R of E)v.has(R.fileName)||(y.push(R),I.push(R.fileName));for(const R of I)v.add(R)}),o?y.map(T=>this.mapTextChangeToCodeEdit(T)):y}getCodeFixes(n,o){const{file:c,project:u}=this.getFileAndProject(n),p=u.getScriptInfoForNormalizedPath(c),{startPosition:m,endPosition:v}=this.getStartAndEndPosition(n,p);let y;try{y=u.getLanguageService().getCodeFixesAtPosition(c,m,v,n.errorCodes,this.getFormatOptions(c),this.getPreferences(c))}catch(T){const E=T instanceof Error?T:new Error(T),I=u.getLanguageService(),R=[...I.getSyntacticDiagnostics(c),...I.getSemanticDiagnostics(c),...I.getSuggestionDiagnostics(c)].filter($=>J9(m,v-m,$.start,$.length)).map($=>$.code),M=n.errorCodes.find($=>!R.includes($));throw M!==void 0&&(E.message+=`
|
|
523
523
|
Additional information: BADCLIENT: Bad error code, ${M} not found in range ${m}..${v} (found: ${R.join(", ")})`),E}return o?y.map(T=>this.mapCodeFixAction(T)):y}getCombinedCodeFix({scope:n,fixId:o},c){U.assert(n.type==="file");const{file:u,project:p}=this.getFileAndProject(n.args),m=p.getLanguageService().getCombinedCodeFix({type:"file",fileName:u},o,this.getFormatOptions(u),this.getPreferences(u));return c?{changes:this.mapTextChangesToCodeEdits(m.changes),commands:m.commands}:m}applyCodeActionCommand(n){const o=n.command;for(const c of Bd(o)){const{file:u,project:p}=this.getFileAndProject(c);p.getLanguageService().applyCodeActionCommand(c,this.getFormatOptions(u)).then(m=>{},m=>{})}return{}}getStartAndEndPosition(n,o){let c,u;return n.startPosition!==void 0?c=n.startPosition:(c=o.lineOffsetToPosition(n.startLine,n.startOffset),n.startPosition=c),n.endPosition!==void 0?u=n.endPosition:(u=o.lineOffsetToPosition(n.endLine,n.endOffset),n.endPosition=u),{startPosition:c,endPosition:u}}mapCodeAction({description:n,changes:o,commands:c}){return{description:n,changes:this.mapTextChangesToCodeEdits(o),commands:c}}mapCodeFixAction({fixName:n,description:o,changes:c,commands:u,fixId:p,fixAllDescription:m}){return{fixName:n,description:o,changes:this.mapTextChangesToCodeEdits(c),commands:u,fixId:p,fixAllDescription:m}}mapPasteEditsAction({edits:n,fixId:o}){return{edits:this.mapTextChangesToCodeEdits(n),fixId:o}}mapTextChangesToCodeEdits(n){return n.map(o=>this.mapTextChangeToCodeEdit(o))}mapTextChangeToCodeEdit(n){const o=this.projectService.getScriptInfoOrConfig(n.fileName);return!!n.isNewFile==!!o&&(o||this.projectService.logErrorForScriptInfoNotFound(n.fileName),U.fail("Expected isNewFile for (only) new files. "+JSON.stringify({isNewFile:!!n.isNewFile,hasScriptInfo:!!o}))),o?{fileName:n.fileName,textChanges:n.textChanges.map(c=>Ryr(c,o))}:jyr(n)}convertTextChangeToCodeEdit(n,o){return{start:o.positionToLineOffset(n.span.start),end:o.positionToLineOffset(n.span.start+n.span.length),newText:n.newText?n.newText:""}}getBraceMatching(n,o){const{file:c,languageService:u}=this.getFileAndLanguageServiceForSyntacticOperation(n),p=this.projectService.getScriptInfoForNormalizedPath(c),m=this.getPosition(n,p),v=u.getBraceMatchingAtPosition(c,m);return v?o?v.map(y=>p0(y,p)):v:void 0}getDiagnosticsForProject(n,o,c){if(this.suppressDiagnosticEvents)return;const{fileNames:u,languageServiceDisabled:p}=this.getProjectInfoWorker(c,void 0,!0,void 0,!0);if(p)return;const m=u.filter(V=>!V.includes("lib.d.ts"));if(m.length===0)return;const v=[],y=[],T=[],E=[],I=Bc(c),R=this.projectService.ensureDefaultProjectForFile(I);for(const V of m)this.getCanonicalFileName(V)===this.getCanonicalFileName(c)?v.push(V):this.projectService.getScriptInfo(V).isScriptOpen()?y.push(V):Qf(V)?E.push(V):T.push(V);const $=[...v,...y,...T,...E].map(V=>({fileName:V,project:R}));this.updateErrorCheck(n,$,o,!1)}configurePlugin(n){this.projectService.configurePlugin(n)}getSmartSelectionRange(n,o){const{locations:c}=n,{file:u,languageService:p}=this.getFileAndLanguageServiceForSyntacticOperation(n),m=U.checkDefined(this.projectService.getScriptInfo(u));return Le(c,v=>{const y=this.getPosition(v,m),T=p.getSmartSelectionRange(u,y);return o?this.mapSelectionRange(T,m):T})}toggleLineComment(n,o){const{file:c,languageService:u}=this.getFileAndLanguageServiceForSyntacticOperation(n),p=this.projectService.getScriptInfo(c),m=this.getRange(n,p),v=u.toggleLineComment(c,m);if(o){const y=this.projectService.getScriptInfoForNormalizedPath(c);return v.map(T=>this.convertTextChangeToCodeEdit(T,y))}return v}toggleMultilineComment(n,o){const{file:c,languageService:u}=this.getFileAndLanguageServiceForSyntacticOperation(n),p=this.projectService.getScriptInfoForNormalizedPath(c),m=this.getRange(n,p),v=u.toggleMultilineComment(c,m);if(o){const y=this.projectService.getScriptInfoForNormalizedPath(c);return v.map(T=>this.convertTextChangeToCodeEdit(T,y))}return v}commentSelection(n,o){const{file:c,languageService:u}=this.getFileAndLanguageServiceForSyntacticOperation(n),p=this.projectService.getScriptInfoForNormalizedPath(c),m=this.getRange(n,p),v=u.commentSelection(c,m);if(o){const y=this.projectService.getScriptInfoForNormalizedPath(c);return v.map(T=>this.convertTextChangeToCodeEdit(T,y))}return v}uncommentSelection(n,o){const{file:c,languageService:u}=this.getFileAndLanguageServiceForSyntacticOperation(n),p=this.projectService.getScriptInfoForNormalizedPath(c),m=this.getRange(n,p),v=u.uncommentSelection(c,m);if(o){const y=this.projectService.getScriptInfoForNormalizedPath(c);return v.map(T=>this.convertTextChangeToCodeEdit(T,y))}return v}mapSelectionRange(n,o){const c={textSpan:p0(n.textSpan,o)};return n.parent&&(c.parent=this.mapSelectionRange(n.parent,o)),c}getScriptInfoFromProjectService(n){const o=Bc(n),c=this.projectService.getScriptInfoForNormalizedPath(o);return c||(this.projectService.logErrorForScriptInfoNotFound(o),q1.ThrowNoProject())}toProtocolCallHierarchyItem(n){const o=this.getScriptInfoFromProjectService(n.file);return{name:n.name,kind:n.kind,kindModifiers:n.kindModifiers,file:n.file,containerName:n.containerName,span:p0(n.span,o),selectionSpan:p0(n.selectionSpan,o)}}toProtocolCallHierarchyIncomingCall(n){const o=this.getScriptInfoFromProjectService(n.from.file);return{from:this.toProtocolCallHierarchyItem(n.from),fromSpans:n.fromSpans.map(c=>p0(c,o))}}toProtocolCallHierarchyOutgoingCall(n,o){return{to:this.toProtocolCallHierarchyItem(n.to),fromSpans:n.fromSpans.map(c=>p0(c,o))}}prepareCallHierarchy(n){const{file:o,project:c}=this.getFileAndProject(n),u=this.projectService.getScriptInfoForNormalizedPath(o);if(u){const p=this.getPosition(n,u),m=c.getLanguageService().prepareCallHierarchy(o,p);return m&&Uce(m,v=>this.toProtocolCallHierarchyItem(v))}}provideCallHierarchyIncomingCalls(n){const{file:o,project:c}=this.getFileAndProject(n),u=this.getScriptInfoFromProjectService(o);return c.getLanguageService().provideCallHierarchyIncomingCalls(o,this.getPosition(n,u)).map(m=>this.toProtocolCallHierarchyIncomingCall(m))}provideCallHierarchyOutgoingCalls(n){const{file:o,project:c}=this.getFileAndProject(n),u=this.getScriptInfoFromProjectService(o);return c.getLanguageService().provideCallHierarchyOutgoingCalls(o,this.getPosition(n,u)).map(m=>this.toProtocolCallHierarchyOutgoingCall(m,u))}getCanonicalFileName(n){const o=this.host.useCaseSensitiveFileNames?n:BA(n);return xa(o)}exit(){}notRequired(n){return n&&this.doOutput(void 0,n.command,n.seq,!0,this.performanceData),{responseRequired:!1,performanceData:this.performanceData}}requiredResponse(n){return{response:n,responseRequired:!0,performanceData:this.performanceData}}addProtocolHandler(n,o){if(this.handlers.has(n))throw new Error(`Protocol handler already exists for command "${n}"`);this.handlers.set(n,o)}setCurrentRequest(n){U.assert(this.currentRequestId===void 0),this.currentRequestId=n,this.cancellationToken.setRequest(n)}resetCurrentRequest(n){U.assert(this.currentRequestId===n),this.currentRequestId=void 0,this.cancellationToken.resetRequest(n)}executeWithRequestId(n,o,c){const u=this.performanceData;try{return this.performanceData=c,this.setCurrentRequest(n),o()}finally{this.resetCurrentRequest(n),this.performanceData=u}}executeCommand(n){const o=this.handlers.get(n.command);if(o){const c=this.executeWithRequestId(n.seq,()=>o(n),void 0);return this.projectService.enableRequestedPlugins(),c}else return this.logger.msg(`Unrecognized JSON command:${ux(n)}`,"Err"),this.doOutput(void 0,"unknown",n.seq,!1,void 0,`Unrecognized JSON command: ${n.command}`),{responseRequired:!1}}onMessage(n){var o,c,u,p,m,v,y;this.gcTimer.scheduleCollect();let T;const E=this.performanceData;this.logger.hasLevel(2)&&(T=this.hrtime(),this.logger.hasLevel(3)&&this.logger.info(`request:${gF(this.toStringMessage(n))}`));let I,R;try{I=this.parseMessage(n),R=I.arguments&&I.arguments.file?I.arguments:void 0,(o=yi)==null||o.instant(yi.Phase.Session,"request",{seq:I.seq,command:I.command}),(c=yi)==null||c.push(yi.Phase.Session,"executeCommand",{seq:I.seq,command:I.command},!0);const{response:M,responseRequired:$,performanceData:V}=this.executeCommand(I);if((u=yi)==null||u.pop(),this.logger.hasLevel(2)){const H=Cyr(this.hrtime(T)).toFixed(4);$?this.logger.perftrc(`${I.seq}::${I.command}: elapsed time (in milliseconds) ${H}`):this.logger.perftrc(`${I.seq}::${I.command}: async elapsed time (in milliseconds) ${H}`)}(p=yi)==null||p.instant(yi.Phase.Session,"response",{seq:I.seq,command:I.command,success:!!M}),M?this.doOutput(M,I.command,I.seq,!0,V):$&&this.doOutput(void 0,I.command,I.seq,!1,V,"No content available.")}catch(M){if((m=yi)==null||m.popAll(),M instanceof pO){(v=yi)==null||v.instant(yi.Phase.Session,"commandCanceled",{seq:I?.seq,command:I?.command}),this.doOutput({canceled:!0},I.command,I.seq,!0,this.performanceData);return}this.logErrorWorker(M,this.toStringMessage(n),R),(y=yi)==null||y.instant(yi.Phase.Session,"commandError",{seq:I?.seq,command:I?.command,message:M.message}),this.doOutput(void 0,I?I.command:"unknown",I?I.seq:0,!1,this.performanceData,"Error processing request. "+M.message+`
|
|
524
|
-
`+M.stack)}finally{this.performanceData=E}}parseMessage(n){return JSON.parse(n)}toStringMessage(n){return n}getFormatOptions(n){return this.projectService.getFormatCodeOptions(n)}getPreferences(n){return this.projectService.getPreferences(n)}getHostFormatOptions(){return this.projectService.getHostFormatCodeOptions()}getHostPreferences(){return this.projectService.getHostPreferences()}};function M_t(e){const n=e.diagnosticsDuration&&Qn(e.diagnosticsDuration,([o,c])=>({...c,file:o}));return{...e,diagnosticsDuration:n}}function p0(e,n){return{start:n.positionToLineOffset(e.start),end:n.positionToLineOffset(zl(e))}}function TNe(e,n,o){const c=p0(e,o),u=n&&p0(n,o);return u?{...c,contextStart:u.start,contextEnd:u.end}:c}function Ryr(e,n){return{start:L_t(n,e.span.start),end:L_t(n,zl(e.span)),newText:e.newText}}function L_t(e,n){return bNe(e)?Lyr(e.getLineAndCharacterOfPosition(n)):e.positionToLineOffset(n)}function Myr(e,n){const o=e.ranges.map(c=>({start:n.positionToLineOffset(c.start),end:n.positionToLineOffset(c.start+c.length)}));return e.wordPattern?{ranges:o,wordPattern:e.wordPattern}:{ranges:o}}function Lyr(e){return{line:e.line+1,offset:e.character+1}}function jyr(e){U.assert(e.textChanges.length===1);const n=qo(e.textChanges);return U.assert(n.span.start===0&&n.span.length===0),{fileName:e.fileName,textChanges:[{start:{line:0,offset:0},end:{line:0,offset:0},newText:n.newText}]}}function kNe(e,n,o,c){const u=Byr(e,n,c),{line:p,character:m}=o4(PI(u),o);return{line:p+1,offset:m+1}}function Byr(e,n,o){for(const{fileName:c,textChanges:u}of o)if(c===n)for(let p=u.length-1;p>=0;p--){const{newText:m,span:{start:v,length:y}}=u[p];e=e.slice(0,v)+m+e.slice(v+y)}return e}function j_t(e,{fileName:n,textSpan:o,contextSpan:c,isWriteAccess:u,isDefinition:p},{disableLineTextInReferences:m}){const v=U.checkDefined(e.getScriptInfo(n)),y=TNe(o,c,v),T=m?void 0:$yr(v,y);return{file:n,...y,lineText:T,isWriteAccess:u,isDefinition:p}}function $yr(e,n){const o=e.lineToTextSpan(n.start.line-1);return e.getSnapshot().getText(o.start,zl(o)).replace(/\r|\n/g,"")}function qyr(e){return e===void 0||e&&typeof e=="object"&&typeof e.exportName=="string"&&(e.fileName===void 0||typeof e.fileName=="string")&&(e.ambientModuleName===void 0||typeof e.ambientModuleName=="string"&&(e.isPackageJsonImport===void 0||typeof e.isPackageJsonImport=="boolean"))}var W6=4,INe=(e=>(e[e.PreStart=0]="PreStart",e[e.Start=1]="Start",e[e.Entire=2]="Entire",e[e.Mid=3]="Mid",e[e.End=4]="End",e[e.PostEnd=5]="PostEnd",e))(INe||{}),zyr=class{constructor(){this.goSubtree=!0,this.lineIndex=new NB,this.endBranch=[],this.state=2,this.initialText="",this.trailingText="",this.lineIndex.root=new H6,this.startPath=[this.lineIndex.root],this.stack=[this.lineIndex.root]}get done(){return!1}insertLines(e,n){n&&(this.trailingText=""),e?e=this.initialText+e+this.trailingText:e=this.initialText+this.trailingText;const c=NB.linesFromText(e).lines;c.length>1&&c[c.length-1]===""&&c.pop();let u,p;for(let v=this.endBranch.length-1;v>=0;v--)this.endBranch[v].updateCounts(),this.endBranch[v].charCount()===0&&(p=this.endBranch[v],v>0?u=this.endBranch[v-1]:u=this.branchNode);p&&u.remove(p);const m=this.startPath[this.startPath.length-1];if(c.length>0)if(m.text=c[0],c.length>1){let v=new Array(c.length-1),y=m;for(let I=1;I<c.length;I++)v[I-1]=new wQ(c[I]);let T=this.startPath.length-2;for(;T>=0;){const I=this.startPath[T];v=I.insertAt(y,v),T--,y=I}let E=v.length;for(;E>0;){const I=new H6;I.add(this.lineIndex.root),v=I.insertAt(this.lineIndex.root,v),E=v.length,this.lineIndex.root=I}this.lineIndex.root.updateCounts()}else for(let v=this.startPath.length-2;v>=0;v--)this.startPath[v].updateCounts();else{this.startPath[this.startPath.length-2].remove(m);for(let y=this.startPath.length-2;y>=0;y--)this.startPath[y].updateCounts()}return this.lineIndex}post(e,n,o){o===this.lineCollectionAtBranch&&(this.state=4),this.stack.pop()}pre(e,n,o,c,u){const p=this.stack[this.stack.length-1];this.state===2&&u===1&&(this.state=1,this.branchNode=p,this.lineCollectionAtBranch=o);let m;function v(y){return y.isLeaf()?new wQ(""):new H6}switch(u){case 0:this.goSubtree=!1,this.state!==4&&p.add(o);break;case 1:this.state===4?this.goSubtree=!1:(m=v(o),p.add(m),this.startPath.push(m));break;case 2:this.state!==4?(m=v(o),p.add(m),this.startPath.push(m)):o.isLeaf()||(m=v(o),p.add(m),this.endBranch.push(m));break;case 3:this.goSubtree=!1;break;case 4:this.state!==4?this.goSubtree=!1:o.isLeaf()||(m=v(o),p.add(m),this.endBranch.push(m));break;case 5:this.goSubtree=!1,this.state!==1&&p.add(o);break}this.goSubtree&&this.stack.push(m)}leaf(e,n,o){this.state===1?this.initialText=o.text.substring(0,e):this.state===2?(this.initialText=o.text.substring(0,e),this.trailingText=o.text.substring(e+n)):this.trailingText=o.text.substring(e+n)}},Uyr=class{constructor(e,n,o){this.pos=e,this.deleteLen=n,this.insertedText=o}getTextChangeRange(){return W9(wd(this.pos,this.deleteLen),this.insertedText?this.insertedText.length:0)}},gfe=class $k{constructor(){this.changes=[],this.versions=new Array($k.maxVersions),this.minVersion=0,this.currentVersion=0}versionToIndex(n){if(!(n<this.minVersion||n>this.currentVersion))return n%$k.maxVersions}currentVersionToIndex(){return this.currentVersion%$k.maxVersions}edit(n,o,c){this.changes.push(new Uyr(n,o,c)),(this.changes.length>$k.changeNumberThreshold||o>$k.changeLengthThreshold||c&&c.length>$k.changeLengthThreshold)&&this.getSnapshot()}getSnapshot(){return this._getSnapshot()}_getSnapshot(){let n=this.versions[this.currentVersionToIndex()];if(this.changes.length>0){let o=n.index;for(const c of this.changes)o=o.edit(c.pos,c.deleteLen,c.insertedText);n=new B_t(this.currentVersion+1,this,o,this.changes),this.currentVersion=n.version,this.versions[this.currentVersionToIndex()]=n,this.changes=[],this.currentVersion-this.minVersion>=$k.maxVersions&&(this.minVersion=this.currentVersion-$k.maxVersions+1)}return n}getSnapshotVersion(){return this._getSnapshot().version}getAbsolutePositionAndLineText(n){return this._getSnapshot().index.lineNumberToInfo(n)}lineOffsetToPosition(n,o){return this._getSnapshot().index.absolutePositionOfStartOfLine(n)+(o-1)}positionToLineOffset(n){return this._getSnapshot().index.positionToLineOffset(n)}lineToTextSpan(n){const o=this._getSnapshot().index,{lineText:c,absolutePosition:u}=o.lineNumberToInfo(n+1),p=c!==void 0?c.length:o.absolutePositionOfStartOfLine(n+2)-u;return wd(u,p)}getTextChangesBetweenVersions(n,o){if(n<o)if(n>=this.minVersion){const c=[];for(let u=n+1;u<=o;u++){const p=this.versions[this.versionToIndex(u)];for(const m of p.changesSincePreviousVersion)c.push(m.getTextChangeRange())}return d2e(c)}else return;else return KU}getLineCount(){return this._getSnapshot().index.getLineCount()}static fromString(n){const o=new $k,c=new B_t(0,o,new NB);o.versions[o.currentVersion]=c;const u=NB.linesFromText(n);return c.index.load(u.lines),o}};gfe.changeNumberThreshold=8,gfe.changeLengthThreshold=256,gfe.maxVersions=8;var yfe=gfe,B_t=class qNt{constructor(n,o,c,u=Ff){this.version=n,this.cache=o,this.index=c,this.changesSincePreviousVersion=u}getText(n,o){return this.index.getText(n,o-n)}getLength(){return this.index.getLength()}getChangeRange(n){if(n instanceof qNt&&this.cache===n.cache)return this.version<=n.version?KU:this.cache.getTextChangesBetweenVersions(n.version,this.version)}},NB=class wLe{constructor(){this.checkEdits=!1}absolutePositionOfStartOfLine(n){return this.lineNumberToInfo(n).absolutePosition}positionToLineOffset(n){const{oneBasedLine:o,zeroBasedColumn:c}=this.root.charOffsetToLineInfo(1,n);return{line:o,offset:c+1}}positionToColumnAndLineText(n){return this.root.charOffsetToLineInfo(1,n)}getLineCount(){return this.root.lineCount()}lineNumberToInfo(n){const o=this.getLineCount();if(n<=o){const{position:c,leaf:u}=this.root.lineNumberToInfo(n,0);return{absolutePosition:c,lineText:u&&u.text}}else return{absolutePosition:this.root.charCount(),lineText:void 0}}load(n){if(n.length>0){const o=[];for(let c=0;c<n.length;c++)o[c]=new wQ(n[c]);this.root=wLe.buildTreeFromBottom(o)}else this.root=new H6}walk(n,o,c){this.root.walk(n,o,c)}getText(n,o){let c="";return o>0&&n<this.root.charCount()&&this.walk(n,o,{goSubtree:!0,done:!1,leaf:(u,p,m)=>{c=c.concat(m.text.substring(u,u+p))}}),c}getLength(){return this.root.charCount()}every(n,o,c){c||(c=this.root.charCount());const u={goSubtree:!0,done:!1,leaf(p,m,v){n(v,p,m)||(this.done=!0)}};return this.walk(o,c-o,u),!u.done}edit(n,o,c){if(this.root.charCount()===0)return U.assert(o===0),c!==void 0?(this.load(wLe.linesFromText(c).lines),this):void 0;{let u;if(this.checkEdits){const v=this.getText(0,this.root.charCount());u=v.slice(0,n)+c+v.slice(n+o)}const p=new zyr;let m=!1;if(n>=this.root.charCount()){n=this.root.charCount()-1;const v=this.getText(n,1);c?c=v+c:c=v,o=0,m=!0}else if(o>0){const v=n+o,{zeroBasedColumn:y,lineText:T}=this.positionToColumnAndLineText(v);y===0&&(o+=T.length,c=c?c+T:T)}if(this.root.walk(n,o,p),p.insertLines(c,m),this.checkEdits){const v=p.lineIndex.getText(0,p.lineIndex.getLength());U.assert(u===v,"buffer edit mismatch")}return p.lineIndex}}static buildTreeFromBottom(n){if(n.length<W6)return new H6(n);const o=new Array(Math.ceil(n.length/W6));let c=0;for(let u=0;u<o.length;u++){const p=Math.min(c+W6,n.length);o[u]=new H6(n.slice(c,p)),c=p}return this.buildTreeFromBottom(o)}static linesFromText(n){const o=PI(n);if(o.length===0)return{lines:[],lineMap:o};const c=new Array(o.length),u=o.length-1;for(let m=0;m<u;m++)c[m]=n.substring(o[m],o[m+1]);const p=n.substring(o[u]);return p.length>0?c[u]=p:c.pop(),{lines:c,lineMap:o}}},H6=class CLe{constructor(n=[]){this.children=n,this.totalChars=0,this.totalLines=0,n.length&&this.updateCounts()}isLeaf(){return!1}updateCounts(){this.totalChars=0,this.totalLines=0;for(const n of this.children)this.totalChars+=n.charCount(),this.totalLines+=n.lineCount()}execWalk(n,o,c,u,p){return c.pre&&c.pre(n,o,this.children[u],this,p),c.goSubtree?(this.children[u].walk(n,o,c),c.post&&c.post(n,o,this.children[u],this,p)):c.goSubtree=!0,c.done}skipChild(n,o,c,u,p){u.pre&&!u.done&&(u.pre(n,o,this.children[c],this,p),u.goSubtree=!0)}walk(n,o,c){if(this.children.length===0)return;let u=0,p=this.children[u].charCount(),m=n;for(;m>=p;)this.skipChild(m,o,u,c,0),m-=p,u++,p=this.children[u].charCount();if(m+o<=p){if(this.execWalk(m,o,c,u,2))return}else{if(this.execWalk(m,p-m,c,u,1))return;let v=o-(p-m);for(u++,p=this.children[u].charCount();v>p;){if(this.execWalk(0,p,c,u,3))return;v-=p,u++,p=this.children[u].charCount()}if(v>0&&this.execWalk(0,v,c,u,4))return}if(c.pre){const v=this.children.length;if(u<v-1)for(let y=u+1;y<v;y++)this.skipChild(0,0,y,c,5)}}charOffsetToLineInfo(n,o){if(this.children.length===0)return{oneBasedLine:n,zeroBasedColumn:o,lineText:void 0};for(const p of this.children){if(p.charCount()>o)return p.isLeaf()?{oneBasedLine:n,zeroBasedColumn:o,lineText:p.text}:p.charOffsetToLineInfo(n,o);o-=p.charCount(),n+=p.lineCount()}const c=this.lineCount();if(c===0)return{oneBasedLine:1,zeroBasedColumn:0,lineText:void 0};const u=U.checkDefined(this.lineNumberToInfo(c,0).leaf);return{oneBasedLine:c,zeroBasedColumn:u.charCount(),lineText:void 0}}lineNumberToInfo(n,o){for(const c of this.children){const u=c.lineCount();if(u>=n)return c.isLeaf()?{position:o,leaf:c}:c.lineNumberToInfo(n,o);n-=u,o+=c.charCount()}return{position:o,leaf:void 0}}splitAfter(n){let o;const c=this.children.length;n++;const u=n;if(n<c){for(o=new CLe;n<c;)o.add(this.children[n]),n++;o.updateCounts()}return this.children.length=u,o}remove(n){const o=this.findChildIndex(n),c=this.children.length;if(o<c-1)for(let u=o;u<c-1;u++)this.children[u]=this.children[u+1];this.children.pop()}findChildIndex(n){const o=this.children.indexOf(n);return U.assert(o!==-1),o}insertAt(n,o){let c=this.findChildIndex(n);const u=this.children.length,p=o.length;if(u<W6&&c===u-1&&p===1)return this.add(o[0]),this.updateCounts(),[];{const m=this.splitAfter(c);let v=0;for(c++;c<W6&&v<p;)this.children[c]=o[v],c++,v++;let y=[],T=0;if(v<p){T=Math.ceil((p-v)/W6),y=new Array(T);let E=0;for(let R=0;R<T;R++)y[R]=new CLe;let I=y[0];for(;v<p;)I.add(o[v]),v++,I.children.length===W6&&(E++,I=y[E]);for(let R=y.length-1;R>=0;R--)y[R].children.length===0&&y.pop()}m&&y.push(m),this.updateCounts();for(let E=0;E<T;E++)y[E].updateCounts();return y}}add(n){this.children.push(n),U.assert(this.children.length<=W6)}charCount(){return this.totalChars}lineCount(){return this.totalLines}},wQ=class{constructor(e){this.text=e}isLeaf(){return!0}walk(e,n,o){o.leaf(e,n,this)}charCount(){return this.text.length}lineCount(){return 1}},$_t=class zNt{constructor(n,o,c,u,p,m){this.telemetryEnabled=n,this.logger=o,this.host=c,this.globalTypingsCacheLocation=u,this.event=p,this.maxActiveRequestCount=m,this.activeRequestCount=0,this.requestQueue=Fc(),this.requestMap=new Map,this.requestedRegistry=!1,this.packageInstallId=0}isKnownTypesPackageName(n){var o;return C2.validatePackageName(n)!==C2.NameValidationResult.Ok?!1:(this.requestedRegistry||(this.requestedRegistry=!0,this.installer.send({kind:"typesRegistry"})),!!((o=this.typesRegistryCache)!=null&&o.has(n)))}installPackage(n){this.packageInstallId++;const o={kind:"installPackage",...n,id:this.packageInstallId},c=new Promise((u,p)=>{(this.packageInstalledPromise??(this.packageInstalledPromise=new Map)).set(this.packageInstallId,{resolve:u,reject:p})});return this.installer.send(o),c}attach(n){this.projectService=n,this.installer=this.createInstallerProcess()}onProjectClosed(n){this.installer.send({projectName:n.getProjectName(),kind:"closeProject"})}enqueueInstallTypingsRequest(n,o,c){const u=M6e(n,o,c);this.logger.hasLevel(3)&&this.logger.info(`TIAdapter:: Scheduling throttled operation:${ux(u)}`),this.activeRequestCount<this.maxActiveRequestCount?this.scheduleRequest(u):(this.logger.hasLevel(3)&&this.logger.info(`TIAdapter:: Deferring request for: ${u.projectName}`),this.requestQueue.enqueue(u),this.requestMap.set(u.projectName,u))}handleMessage(n){var o,c;switch(this.logger.hasLevel(3)&&this.logger.info(`TIAdapter:: Received response:${ux(n)}`),n.kind){case zae:this.typesRegistryCache=new Map(Object.entries(n.typesRegistry));break;case UH:{const u=(o=this.packageInstalledPromise)==null?void 0:o.get(n.id);U.assertIsDefined(u,"Should find the promise for package install"),(c=this.packageInstalledPromise)==null||c.delete(n.id),n.success?u.resolve({successMessage:n.message}):u.reject(n.message),this.projectService.updateTypingsForProject(n),this.event(n,"setTypings");break}case zke:{const u={message:n.message};this.event(u,"typesInstallerInitializationFailed");break}case Uae:{const u={eventId:n.eventId,packages:n.packagesToInstall};this.event(u,"beginInstallTypes");break}case Vae:{if(this.telemetryEnabled){const m={telemetryEventName:"typingsInstalled",payload:{installedPackages:n.packagesToInstall.join(","),installSuccess:n.installSuccess,typingsInstallerVersion:n.typingsInstallerVersion}};this.event(m,"telemetry")}const u={eventId:n.eventId,packages:n.packagesToInstall,success:n.installSuccess};this.event(u,"endInstallTypes");break}case zH:{this.projectService.updateTypingsForProject(n);break}case qH:{for(this.activeRequestCount>0?this.activeRequestCount--:U.fail("TIAdapter:: Received too many responses");!this.requestQueue.isEmpty();){const u=this.requestQueue.dequeue();if(this.requestMap.get(u.projectName)===u){this.requestMap.delete(u.projectName),this.scheduleRequest(u);break}this.logger.hasLevel(3)&&this.logger.info(`TIAdapter:: Skipping defunct request for: ${u.projectName}`)}this.projectService.updateTypingsForProject(n),this.event(n,"setTypings");break}case Tj:this.projectService.watchTypingLocations(n);break}}scheduleRequest(n){this.logger.hasLevel(3)&&this.logger.info(`TIAdapter:: Scheduling request for: ${n.projectName}`),this.activeRequestCount++,this.host.setTimeout(()=>{this.logger.hasLevel(3)&&this.logger.info(`TIAdapter:: Sending request:${ux(n)}`),this.installer.send(n)},zNt.requestDelayMillis,`${n.projectName}::${n.kind}`)}};$_t.requestDelayMillis=100;var q_t=$_t,z_t={};d(z_t,{ActionInvalidate:()=>zH,ActionPackageInstalled:()=>UH,ActionSet:()=>qH,ActionWatchTypingLocations:()=>Tj,Arguments:()=>Jae,AutoImportProviderProject:()=>nNe,AuxiliaryProject:()=>tNe,CharRangeSection:()=>INe,CloseFileWatcherEvent:()=>ofe,CommandNames:()=>T_t,ConfigFileDiagEvent:()=>tfe,ConfiguredProject:()=>iNe,ConfiguredProjectLoadKind:()=>uNe,CreateDirectoryWatcherEvent:()=>sfe,CreateFileWatcherEvent:()=>ife,Errors:()=>q1,EventBeginInstallTypes:()=>Uae,EventEndInstallTypes:()=>Vae,EventInitializationFailed:()=>zke,EventTypesRegistry:()=>zae,ExternalProject:()=>Que,GcTimer:()=>U6e,InferredProject:()=>eNe,LargeFileReferencedEvent:()=>efe,LineIndex:()=>NB,LineLeaf:()=>wQ,LineNode:()=>H6,LogLevel:()=>F6e,Msg:()=>R6e,OpenFileInfoTelemetryEvent:()=>sNe,Project:()=>e3,ProjectInfoTelemetryEvent:()=>nfe,ProjectKind:()=>WF,ProjectLanguageServiceStateEvent:()=>rfe,ProjectLoadingFinishEvent:()=>Zue,ProjectLoadingStartEvent:()=>Xue,ProjectService:()=>vNe,ProjectsUpdatedInBackgroundEvent:()=>AQ,ScriptInfo:()=>H6e,ScriptVersionCache:()=>yfe,Session:()=>R_t,TextStorage:()=>W6e,ThrottledOperations:()=>z6e,TypingsInstallerAdapter:()=>q_t,allFilesAreJsOrDts:()=>Y6e,allRootFilesAreJsOrDts:()=>K6e,asNormalizedPath:()=>Zpt,convertCompilerOptions:()=>SQ,convertFormatOptions:()=>V6,convertScriptKindName:()=>cfe,convertTypeAcquisition:()=>aNe,convertUserPreferences:()=>cNe,convertWatchOptions:()=>DB,countEachFileTypes:()=>EB,createInstallTypingsRequest:()=>M6e,createModuleSpecifierCache:()=>SNe,createNormalizedPathMap:()=>e_t,createPackageJsonCache:()=>xNe,createSortedArray:()=>q6e,emptyArray:()=>Ff,findArgument:()=>ent,formatDiagnosticToProtocol:()=>PB,formatMessage:()=>wNe,getBaseConfigFileName:()=>Gue,getDetailWatchInfo:()=>dfe,getLocationInNewDocument:()=>kNe,hasArgument:()=>Zrt,hasNoTypeScriptSource:()=>X6e,indent:()=>gF,isBackgroundProject:()=>kB,isConfigFile:()=>bNe,isConfiguredProject:()=>Yb,isDynamicFileName:()=>JF,isExternalProject:()=>TB,isInferredProject:()=>U6,isInferredProjectName:()=>L6e,isProjectDeferredClose:()=>IB,makeAutoImportProviderProjectName:()=>B6e,makeAuxiliaryProjectName:()=>$6e,makeInferredProjectName:()=>j6e,maxFileSize:()=>Yue,maxProgramSizeForNonTsFiles:()=>Kue,normalizedPathToPath:()=>z6,nowString:()=>tnt,nullCancellationToken:()=>w_t,nullTypingsInstaller:()=>xQ,protocol:()=>V6e,scriptInfoIsContainedByBackgroundProject:()=>G6e,scriptInfoIsContainedByDeferredClosedProject:()=>Q6e,stringifyIndented:()=>ux,toEvent:()=>CNe,toNormalizedPath:()=>Bc,tryConvertScriptKindName:()=>afe,typingsInstaller:()=>O6e,updateProjectIfDirty:()=>_g}),typeof console<"u"&&(U.loggingHost={log(e,n){switch(e){case 1:return console.error(n);case 2:return console.warn(n);case 3:return console.log(n);case 4:return console.log(n)}}})})({get exports(){return i},set exports(a){i=a,t.exports&&(t.exports=a)}})})(y7e)),y7e.exports}var sUr=iUr();const Sp=Nkt(sUr);function oUr(t,r){for(const i of t.statements)if(Sp.isVariableStatement(i))for(const a of i.declarationList.declarations){if(!Sp.isIdentifier(a.name)||a.name.text!==r)continue;const l=a.initializer;if(l&&Sp.isObjectLiteralExpression(l))return l}}function aUr(t){const r=t.name;if(r&&(Sp.isIdentifier(r)||Sp.isStringLiteral(r)))return r.text}function cUr(t,r){const i=new Set;let a=!1;const l=d=>{Sp.isElementAccessExpression(d)&&Sp.isIdentifier(d.expression)&&d.expression.text===r&&(Sp.isIdentifier(d.argumentExpression)?i.add(d.argumentExpression.text):a=!0),Sp.forEachChild(d,l)};if(Sp.forEachChild(t,l),!(i.size===0&&!a))return i.size!==1||a?null:[...i][0]}function lUr(t){return(t.replaceAll("\\","/").split("/").pop()??t).replace(/\.[jt]sx?$/,"")}function uUr(t,r){return Sp.createSourceFile(t,r,Sp.ScriptTarget.Latest,!0,Sp.ScriptKind.TSX)}function fUr(t){for(const r of t.statements){if(Sp.isExportAssignment(r)&&!r.isExportEquals){const l=r.expression;if(Sp.isIdentifier(l))return l.text;continue}if((Sp.canHaveModifiers(r)?Sp.getModifiers(r):void 0)?.some(l=>l.kind===Sp.SyntaxKind.DefaultKeyword)&&(Sp.isFunctionDeclaration(r)||Sp.isClassDeclaration(r)))return r.name?.text}}function dUr(t,r,i){t.name&&i.set(t.name.text,{specifier:r});const a=t.namedBindings;if(!(!a||!Sp.isNamedImports(a)))for(const l of a.elements)i.set(l.name.text,{specifier:r,exported:(l.propertyName??l.name).text})}function pUr(t){const r=new Map;for(const i of t.statements)!Sp.isImportDeclaration(i)||!i.importClause||Sp.isStringLiteral(i.moduleSpecifier)&&dUr(i.importClause,i.moduleSpecifier.text,r);return r}function _Ur(t,r){for(const i of t.statements)if(Sp.isVariableStatement(i)&&(i.declarationList.flags&Sp.NodeFlags.Const)!==0)for(const a of i.declarationList.declarations){if(!Sp.isIdentifier(a.name)||a.name.text!==r)continue;const l=a.initializer;return l&&Sp.isStringLiteral(l)?l.text:void 0}}function mUr(t,r,i,a,l){const d=cUr(r,i);if(d===void 0){l.push(`scenesFromEntrypointSelection: ${t.path} never indexes \`${i}\`, so which of its compositions the entrypoint mounts is not stated in the source and no entry is settled as the active one.`);return}if(d===null){l.push(`scenesFromEntrypointSelection: ${t.path} indexes \`${i}\` with something other than one single identifier, so the key it mounts cannot be read statically.`);return}const _=_Ur(r,d);if(_===void 0){l.push(`scenesFromEntrypointSelection: ${t.path} indexes \`${i}\` with \`${d}\`, which is not a module-level \`const\` bound to a string literal, so the key it mounts cannot be read statically.`);return}if(!a.includes(_)){l.push(`scenesFromEntrypointSelection: ${t.path} mounts \`${i}\` under "${_}", which is not a key of that table. The entrypoint and its own selection table disagree.`);return}return _}function hUr(t){if(Sp.isShorthandPropertyAssignment(t))return t.name.text;if(Sp.isPropertyAssignment(t)&&Sp.isIdentifier(t.initializer))return t.initializer.text}function gUr(t,r,i){if(!t||!i)return;const a=i(t.specifier,r);if(a)return t.exported===void 0?{path:a}:{path:a,export:t.exported}}function yUr(t,r,i){if(t.regions===oge)return[...r];const a=[];for(const l of t.regions){const d=r.find(_=>_.regionId===l);d?a.push(d):i.push(`scenesFromEntrypointSelection: region "${l}" is selected but the project declares no root with that id and an entry.`)}return a}function vUr(t,r){return{id:t.regionId,label:fUr(r)??lUr(t.path),kind:"scene",region:t.regionId,authorable:!0,reach:{kind:"root-mount"},source:{path:t.path},finder:"scenesFromEntrypointSelection"}}function bUr(t,r,i,a,l){const d=oUr(r,i);if(!d)return l.push(`scenesFromEntrypointSelection: ${t.path} declares no module-level \`const ${i} = { … }\` selection table. Nothing is assumed in its place — fix the adapter’s \`selection\` or the entrypoint.`),{entries:[],active:void 0};const _=pUr(r),g=[],b=[];for(const w of d.properties){const N=aUr(w);if(N===void 0){l.push(`scenesFromEntrypointSelection: ${t.path}'s \`${i}\` has an entry whose key is computed, so it cannot be named statically.`);continue}const P=hUr(w);g.push(N),b.push({key:N,label:P??N,source:gUr(P?_.get(P):void 0,t.path,a)})}const S=mUr(t,r,i,g,l);return{entries:b.map(({key:w,label:N,source:P})=>({id:w,label:N,kind:"scene",region:t.regionId,authorable:!0,reach:{kind:"entrypoint-selection",selection:i,key:w,...w===S?{active:!0}:{}},...P?{source:P}:{},finder:"scenesFromEntrypointSelection"})),active:S}}function AUr(t,r){const i=[],a=[],l=[];for(const _ of yUr(t,r.entrypoints,i)){if(_.source===null){i.push(`scenesFromEntrypointSelection: could not read ${_.path} (region "${_.regionId}"), so its scenes are unknown — not empty.`);continue}const g=uUr(_.path,_.source);if(t.selection===void 0){a.push(vUr(_,g));continue}const b=bUr(_,g,t.selection,r.resolveModule,i);a.push(...b.entries),b.active!==void 0&&l.push(b.active)}const d=l.length===1?l[0]:a.length===1?a[0]?.id:void 0;return d!==void 0?{entries:a,default:d,notes:i}:{entries:a,notes:i}}function SUr(t,r){return tUr(t,r)}const xUr=Na({finder:Ry("scenesFromEntrypointSelection"),regions:bee([o_(Ss().min(1)).min(1),Ry(oge)]).describe("Region ids whose entrypoints carry the selection, or the rule form"),selection:Ss().min(1).optional().describe("Identifier of the entrypoint's module-level scene selection table; omit for a single-composition entrypoint")}).strict().refine(t=>t.selection===void 0||Array.isArray(t.regions),{message:`scenesFromEntrypointSelection: \`selection\` names an identifier in ONE entrypoint’s source, so it cannot be paired with the \`${oge}\` rule — name the region explicitly (\`regions: ["<rootId>"]\`).`});FNt({name:"scenesFromEntrypointSelection",schema:xUr,run:AUr});function UNt(t,r){const i=t.endsWith("/")?t.slice(0,-1):t,a=r.startsWith("/")?r.slice(1):r;return i.startsWith("/")?`/@fs${i}/${a}`:`/@fs/${i}/${a}`}const wUr="vgai-mount";function XDn(t,r,i){return`${UNt(t,r)}?vgai-live-module=${i}`}let v7e=Date.now();function ZDn(){return v7e=Math.max(v7e+1,Date.now()),v7e}function TX(t){return t.roots}function CUr(t,r){return t.roots.some(i=>i.surface===r)}function EUr(t){return t.roots.filter(r=>r.adapter.type==="ingest")}async function TUr(t){if(!t.length)return;const{useGLTF:r,useTexture:i}=await la(async()=>{const{useGLTF:a,useTexture:l}=await import("./index-Cl83EGRl.js");return{useGLTF:a,useTexture:l}},__vite__mapDeps([63,3,2,4,6,64,65,11,9,1]));for(const a of t)r.clear(a),i.clear(a)}function kUr(t){typeof window>"u"||!t.some(r=>/\.(glb|gltf|png|jpe?g|webp|avif)$/i.test(r))||window.dispatchEvent(new CustomEvent("editor:asset-loaders-changed"))}function IUr(t,r=()=>{}){const i=VP();return i.addEventListener("asset-moved",a=>{try{const l=JSON.parse(a.data);t(l)}catch{}}),i.addEventListener("assets-changed",async a=>{let l;try{l=JSON.parse(a.data)}catch{l={}}const d=l.paths?.map(_=>`/${_.replace(/^\/?public\//,"").replace(/^\//,"")}`)??[];await TUr(d),kUr(d),r(l)}),()=>i.close()}function VNt(t){const r=VP();return r.addEventListener("tool-files-changed",()=>t()),()=>r.close()}function DUr(t){const r=VP();return r.addEventListener("project-declarations-changed",t),()=>r.close()}function PUr(t){const r=VP();return r.addEventListener("source-files-changed",i=>{let a="";try{a=String(JSON.parse(i.data).path??"")}catch{}t(a)}),()=>r.close()}function NUr(t){const r=VP();return r.addEventListener("story-files-changed",()=>t()),()=>r.close()}const QUe="vgai.project.json",$q=new Map;function KUe(t){const r=t;return $q.set(t.kind,r),()=>{$q.get(t.kind)===r&&$q.delete(t.kind)}}function OUr(){return[...$q.keys()]}function FUr(t){return $q.get(t)}const eSt="play";KUe({kind:"process",role:"run",describe:"A process beside the host: an entry module, a port, readiness",schema:Na({id:Ss().min(1).describe("Configuration id"),kind:Ry("process"),entry:Ss().min(1).describe("Project-relative entry module"),command:Ss().min(1).optional().describe("Shell command that starts it; `npx tsx <entry>` when omitted"),port:Tu().int().min(1).max(65535).optional().describe("Port it listens on"),cwd:Ss().min(1).optional().describe("Project-relative working directory"),env:zR(Ss(),Ss()).optional().describe("Environment for the process"),ready:Na({http:Ss().min(1).optional().describe("HTTP path answering 2xx when up")}).strict().optional().describe("Readiness beyond the port accepting connections")}).strict()});KUe({kind:"compound",role:"run",describe:"Several configurations started together; `play` names the host mount",schema:Na({id:Ss().min(1).describe("Configuration id"),kind:Ry("compound"),run:o_(Ss().min(1)).min(1).describe("Configuration ids, `play` included"),instances:Tu().int().min(1).optional().describe("Instances of the host mount to run against the rest")}).strict()});KUe({kind:"bundle",role:"build",describe:"The project's web bundle: its build script, then dist/ packaged as the artifact",schema:Na({id:Ss().min(1).describe("Configuration id"),kind:Ry("bundle"),script:Ss().min(1).optional().describe("package.json script that builds (`build`)"),args:o_(Ss()).optional().describe("Arguments passed after `--`")}).strict()});function RUr(t){const r=[],i=new Set;for(const a of t){i.has(a.id)&&r.push(`configurations: duplicate id "${a.id}"`),i.add(a.id);const l=$q.get(a.kind);if(!l){r.push(`configurations "${a.id}": unknown kind "${a.kind}" — registered: ${OUr().map(_=>`"${_}"`).join(", ")}`);continue}const d=l.schema.safeParse(a);if(!d.success)for(const _ of d.error.issues)r.push(`configurations "${a.id}" (${a.kind}): ${_.path.join(".")||"(declaration)"}: ${_.message}`)}for(const a of t){if(a.kind!=="compound")continue;const l=a.run??[];for(const d of l)d!==eSt&&!i.has(d)&&r.push(`configurations "${a.id}": member "${d}" is not a declared configuration (or "${eSt}")`)}return r}const MUr=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z-.]+)?(?:\+[0-9A-Za-z-.]+)?$/;function LUr(t){return typeof t=="object"&&"module"in t}function jUr(t){const{adapter:r}=t;if(typeof r=="string"&&!t.entry)throw new Error(`Game manifest: root "${t.id}" uses the '${r}' adapter but declares no \`entry\` — a built-in adapter root is authored as an entry module.`);if(typeof r=="object"&&"ingest"in r&&!t.entry)throw new Error(`Game manifest: root "${t.id}" is an { ingest } root but declares no \`entry\` — the game's own entry module is what the host imports.`)}function BUr(t){const{adapter:r}=t;if(typeof r=="string")return{type:"builtin",identity:r,surface:r};if(LUr(r))return{type:"module",identity:"module",module:r.module,surface:r.surface};const i=r.surface==="three"?"ingest-three":r.surface==="canvas"?"ingest-pixi":"ingest-react",a=r.ingest;return{type:"ingest",identity:i,surface:r.surface,contractShim:a.contractShim,dataWriter:a.dataWriter,assets:a.assets,domStubs:a.domStubs,captureTimeoutMs:a.captureTimeoutMs}}function $Ur(t){if(!MUr.test(t))throw new Error(`Game manifest: engine.version "${t}" is not a valid exact semver string (e.g. "0.1.0") — §1.5 requires an exact identity pin, not a range.`)}function qUr(t){jUr(t);const r=BUr(t);return{id:t.id,surface:r.surface,description:t.description,adapter:r,entry:t.entry,world:t.world===void 0?void 0:{entry:t.world.entry,export:t.world.export},zOrder:t.zOrder,pausable:t.pausable,loop:t.loop}}function JNt(t,r={}){const i=OMr.safeParse(t);if(!i.success){const S=i.error.issues.find(k=>k.message.startsWith("Game manifest: duplicate root id")||k.message.startsWith("Game manifest: a project has at most one"));throw S?new Error(S.message):i.error}const a=i.data;$Ur(a.engine.version);const l=a.roots.map((S,k)=>({root:qUr(S),index:k}));l.sort((S,k)=>S.root.zOrder-k.root.zOrder||S.index-k.index);const d=l.map(({root:S})=>S),_=a.configurations??[],g=[],b=RUr(_).filter(S=>{if(r.configurationKinds!=="defer")return!0;const k=/^configurations "([^"]+)": unknown kind/.exec(S);return k?(g.push(k[1]),!1):!0});if(b.length>0)throw new Error(`Game manifest: ${b.join(`
|
|
524
|
+
`+M.stack)}finally{this.performanceData=E}}parseMessage(n){return JSON.parse(n)}toStringMessage(n){return n}getFormatOptions(n){return this.projectService.getFormatCodeOptions(n)}getPreferences(n){return this.projectService.getPreferences(n)}getHostFormatOptions(){return this.projectService.getHostFormatCodeOptions()}getHostPreferences(){return this.projectService.getHostPreferences()}};function M_t(e){const n=e.diagnosticsDuration&&Qn(e.diagnosticsDuration,([o,c])=>({...c,file:o}));return{...e,diagnosticsDuration:n}}function p0(e,n){return{start:n.positionToLineOffset(e.start),end:n.positionToLineOffset(zl(e))}}function TNe(e,n,o){const c=p0(e,o),u=n&&p0(n,o);return u?{...c,contextStart:u.start,contextEnd:u.end}:c}function Ryr(e,n){return{start:L_t(n,e.span.start),end:L_t(n,zl(e.span)),newText:e.newText}}function L_t(e,n){return bNe(e)?Lyr(e.getLineAndCharacterOfPosition(n)):e.positionToLineOffset(n)}function Myr(e,n){const o=e.ranges.map(c=>({start:n.positionToLineOffset(c.start),end:n.positionToLineOffset(c.start+c.length)}));return e.wordPattern?{ranges:o,wordPattern:e.wordPattern}:{ranges:o}}function Lyr(e){return{line:e.line+1,offset:e.character+1}}function jyr(e){U.assert(e.textChanges.length===1);const n=qo(e.textChanges);return U.assert(n.span.start===0&&n.span.length===0),{fileName:e.fileName,textChanges:[{start:{line:0,offset:0},end:{line:0,offset:0},newText:n.newText}]}}function kNe(e,n,o,c){const u=Byr(e,n,c),{line:p,character:m}=o4(PI(u),o);return{line:p+1,offset:m+1}}function Byr(e,n,o){for(const{fileName:c,textChanges:u}of o)if(c===n)for(let p=u.length-1;p>=0;p--){const{newText:m,span:{start:v,length:y}}=u[p];e=e.slice(0,v)+m+e.slice(v+y)}return e}function j_t(e,{fileName:n,textSpan:o,contextSpan:c,isWriteAccess:u,isDefinition:p},{disableLineTextInReferences:m}){const v=U.checkDefined(e.getScriptInfo(n)),y=TNe(o,c,v),T=m?void 0:$yr(v,y);return{file:n,...y,lineText:T,isWriteAccess:u,isDefinition:p}}function $yr(e,n){const o=e.lineToTextSpan(n.start.line-1);return e.getSnapshot().getText(o.start,zl(o)).replace(/\r|\n/g,"")}function qyr(e){return e===void 0||e&&typeof e=="object"&&typeof e.exportName=="string"&&(e.fileName===void 0||typeof e.fileName=="string")&&(e.ambientModuleName===void 0||typeof e.ambientModuleName=="string"&&(e.isPackageJsonImport===void 0||typeof e.isPackageJsonImport=="boolean"))}var W6=4,INe=(e=>(e[e.PreStart=0]="PreStart",e[e.Start=1]="Start",e[e.Entire=2]="Entire",e[e.Mid=3]="Mid",e[e.End=4]="End",e[e.PostEnd=5]="PostEnd",e))(INe||{}),zyr=class{constructor(){this.goSubtree=!0,this.lineIndex=new NB,this.endBranch=[],this.state=2,this.initialText="",this.trailingText="",this.lineIndex.root=new H6,this.startPath=[this.lineIndex.root],this.stack=[this.lineIndex.root]}get done(){return!1}insertLines(e,n){n&&(this.trailingText=""),e?e=this.initialText+e+this.trailingText:e=this.initialText+this.trailingText;const c=NB.linesFromText(e).lines;c.length>1&&c[c.length-1]===""&&c.pop();let u,p;for(let v=this.endBranch.length-1;v>=0;v--)this.endBranch[v].updateCounts(),this.endBranch[v].charCount()===0&&(p=this.endBranch[v],v>0?u=this.endBranch[v-1]:u=this.branchNode);p&&u.remove(p);const m=this.startPath[this.startPath.length-1];if(c.length>0)if(m.text=c[0],c.length>1){let v=new Array(c.length-1),y=m;for(let I=1;I<c.length;I++)v[I-1]=new wQ(c[I]);let T=this.startPath.length-2;for(;T>=0;){const I=this.startPath[T];v=I.insertAt(y,v),T--,y=I}let E=v.length;for(;E>0;){const I=new H6;I.add(this.lineIndex.root),v=I.insertAt(this.lineIndex.root,v),E=v.length,this.lineIndex.root=I}this.lineIndex.root.updateCounts()}else for(let v=this.startPath.length-2;v>=0;v--)this.startPath[v].updateCounts();else{this.startPath[this.startPath.length-2].remove(m);for(let y=this.startPath.length-2;y>=0;y--)this.startPath[y].updateCounts()}return this.lineIndex}post(e,n,o){o===this.lineCollectionAtBranch&&(this.state=4),this.stack.pop()}pre(e,n,o,c,u){const p=this.stack[this.stack.length-1];this.state===2&&u===1&&(this.state=1,this.branchNode=p,this.lineCollectionAtBranch=o);let m;function v(y){return y.isLeaf()?new wQ(""):new H6}switch(u){case 0:this.goSubtree=!1,this.state!==4&&p.add(o);break;case 1:this.state===4?this.goSubtree=!1:(m=v(o),p.add(m),this.startPath.push(m));break;case 2:this.state!==4?(m=v(o),p.add(m),this.startPath.push(m)):o.isLeaf()||(m=v(o),p.add(m),this.endBranch.push(m));break;case 3:this.goSubtree=!1;break;case 4:this.state!==4?this.goSubtree=!1:o.isLeaf()||(m=v(o),p.add(m),this.endBranch.push(m));break;case 5:this.goSubtree=!1,this.state!==1&&p.add(o);break}this.goSubtree&&this.stack.push(m)}leaf(e,n,o){this.state===1?this.initialText=o.text.substring(0,e):this.state===2?(this.initialText=o.text.substring(0,e),this.trailingText=o.text.substring(e+n)):this.trailingText=o.text.substring(e+n)}},Uyr=class{constructor(e,n,o){this.pos=e,this.deleteLen=n,this.insertedText=o}getTextChangeRange(){return W9(wd(this.pos,this.deleteLen),this.insertedText?this.insertedText.length:0)}},gfe=class $k{constructor(){this.changes=[],this.versions=new Array($k.maxVersions),this.minVersion=0,this.currentVersion=0}versionToIndex(n){if(!(n<this.minVersion||n>this.currentVersion))return n%$k.maxVersions}currentVersionToIndex(){return this.currentVersion%$k.maxVersions}edit(n,o,c){this.changes.push(new Uyr(n,o,c)),(this.changes.length>$k.changeNumberThreshold||o>$k.changeLengthThreshold||c&&c.length>$k.changeLengthThreshold)&&this.getSnapshot()}getSnapshot(){return this._getSnapshot()}_getSnapshot(){let n=this.versions[this.currentVersionToIndex()];if(this.changes.length>0){let o=n.index;for(const c of this.changes)o=o.edit(c.pos,c.deleteLen,c.insertedText);n=new B_t(this.currentVersion+1,this,o,this.changes),this.currentVersion=n.version,this.versions[this.currentVersionToIndex()]=n,this.changes=[],this.currentVersion-this.minVersion>=$k.maxVersions&&(this.minVersion=this.currentVersion-$k.maxVersions+1)}return n}getSnapshotVersion(){return this._getSnapshot().version}getAbsolutePositionAndLineText(n){return this._getSnapshot().index.lineNumberToInfo(n)}lineOffsetToPosition(n,o){return this._getSnapshot().index.absolutePositionOfStartOfLine(n)+(o-1)}positionToLineOffset(n){return this._getSnapshot().index.positionToLineOffset(n)}lineToTextSpan(n){const o=this._getSnapshot().index,{lineText:c,absolutePosition:u}=o.lineNumberToInfo(n+1),p=c!==void 0?c.length:o.absolutePositionOfStartOfLine(n+2)-u;return wd(u,p)}getTextChangesBetweenVersions(n,o){if(n<o)if(n>=this.minVersion){const c=[];for(let u=n+1;u<=o;u++){const p=this.versions[this.versionToIndex(u)];for(const m of p.changesSincePreviousVersion)c.push(m.getTextChangeRange())}return d2e(c)}else return;else return KU}getLineCount(){return this._getSnapshot().index.getLineCount()}static fromString(n){const o=new $k,c=new B_t(0,o,new NB);o.versions[o.currentVersion]=c;const u=NB.linesFromText(n);return c.index.load(u.lines),o}};gfe.changeNumberThreshold=8,gfe.changeLengthThreshold=256,gfe.maxVersions=8;var yfe=gfe,B_t=class qNt{constructor(n,o,c,u=Ff){this.version=n,this.cache=o,this.index=c,this.changesSincePreviousVersion=u}getText(n,o){return this.index.getText(n,o-n)}getLength(){return this.index.getLength()}getChangeRange(n){if(n instanceof qNt&&this.cache===n.cache)return this.version<=n.version?KU:this.cache.getTextChangesBetweenVersions(n.version,this.version)}},NB=class wLe{constructor(){this.checkEdits=!1}absolutePositionOfStartOfLine(n){return this.lineNumberToInfo(n).absolutePosition}positionToLineOffset(n){const{oneBasedLine:o,zeroBasedColumn:c}=this.root.charOffsetToLineInfo(1,n);return{line:o,offset:c+1}}positionToColumnAndLineText(n){return this.root.charOffsetToLineInfo(1,n)}getLineCount(){return this.root.lineCount()}lineNumberToInfo(n){const o=this.getLineCount();if(n<=o){const{position:c,leaf:u}=this.root.lineNumberToInfo(n,0);return{absolutePosition:c,lineText:u&&u.text}}else return{absolutePosition:this.root.charCount(),lineText:void 0}}load(n){if(n.length>0){const o=[];for(let c=0;c<n.length;c++)o[c]=new wQ(n[c]);this.root=wLe.buildTreeFromBottom(o)}else this.root=new H6}walk(n,o,c){this.root.walk(n,o,c)}getText(n,o){let c="";return o>0&&n<this.root.charCount()&&this.walk(n,o,{goSubtree:!0,done:!1,leaf:(u,p,m)=>{c=c.concat(m.text.substring(u,u+p))}}),c}getLength(){return this.root.charCount()}every(n,o,c){c||(c=this.root.charCount());const u={goSubtree:!0,done:!1,leaf(p,m,v){n(v,p,m)||(this.done=!0)}};return this.walk(o,c-o,u),!u.done}edit(n,o,c){if(this.root.charCount()===0)return U.assert(o===0),c!==void 0?(this.load(wLe.linesFromText(c).lines),this):void 0;{let u;if(this.checkEdits){const v=this.getText(0,this.root.charCount());u=v.slice(0,n)+c+v.slice(n+o)}const p=new zyr;let m=!1;if(n>=this.root.charCount()){n=this.root.charCount()-1;const v=this.getText(n,1);c?c=v+c:c=v,o=0,m=!0}else if(o>0){const v=n+o,{zeroBasedColumn:y,lineText:T}=this.positionToColumnAndLineText(v);y===0&&(o+=T.length,c=c?c+T:T)}if(this.root.walk(n,o,p),p.insertLines(c,m),this.checkEdits){const v=p.lineIndex.getText(0,p.lineIndex.getLength());U.assert(u===v,"buffer edit mismatch")}return p.lineIndex}}static buildTreeFromBottom(n){if(n.length<W6)return new H6(n);const o=new Array(Math.ceil(n.length/W6));let c=0;for(let u=0;u<o.length;u++){const p=Math.min(c+W6,n.length);o[u]=new H6(n.slice(c,p)),c=p}return this.buildTreeFromBottom(o)}static linesFromText(n){const o=PI(n);if(o.length===0)return{lines:[],lineMap:o};const c=new Array(o.length),u=o.length-1;for(let m=0;m<u;m++)c[m]=n.substring(o[m],o[m+1]);const p=n.substring(o[u]);return p.length>0?c[u]=p:c.pop(),{lines:c,lineMap:o}}},H6=class CLe{constructor(n=[]){this.children=n,this.totalChars=0,this.totalLines=0,n.length&&this.updateCounts()}isLeaf(){return!1}updateCounts(){this.totalChars=0,this.totalLines=0;for(const n of this.children)this.totalChars+=n.charCount(),this.totalLines+=n.lineCount()}execWalk(n,o,c,u,p){return c.pre&&c.pre(n,o,this.children[u],this,p),c.goSubtree?(this.children[u].walk(n,o,c),c.post&&c.post(n,o,this.children[u],this,p)):c.goSubtree=!0,c.done}skipChild(n,o,c,u,p){u.pre&&!u.done&&(u.pre(n,o,this.children[c],this,p),u.goSubtree=!0)}walk(n,o,c){if(this.children.length===0)return;let u=0,p=this.children[u].charCount(),m=n;for(;m>=p;)this.skipChild(m,o,u,c,0),m-=p,u++,p=this.children[u].charCount();if(m+o<=p){if(this.execWalk(m,o,c,u,2))return}else{if(this.execWalk(m,p-m,c,u,1))return;let v=o-(p-m);for(u++,p=this.children[u].charCount();v>p;){if(this.execWalk(0,p,c,u,3))return;v-=p,u++,p=this.children[u].charCount()}if(v>0&&this.execWalk(0,v,c,u,4))return}if(c.pre){const v=this.children.length;if(u<v-1)for(let y=u+1;y<v;y++)this.skipChild(0,0,y,c,5)}}charOffsetToLineInfo(n,o){if(this.children.length===0)return{oneBasedLine:n,zeroBasedColumn:o,lineText:void 0};for(const p of this.children){if(p.charCount()>o)return p.isLeaf()?{oneBasedLine:n,zeroBasedColumn:o,lineText:p.text}:p.charOffsetToLineInfo(n,o);o-=p.charCount(),n+=p.lineCount()}const c=this.lineCount();if(c===0)return{oneBasedLine:1,zeroBasedColumn:0,lineText:void 0};const u=U.checkDefined(this.lineNumberToInfo(c,0).leaf);return{oneBasedLine:c,zeroBasedColumn:u.charCount(),lineText:void 0}}lineNumberToInfo(n,o){for(const c of this.children){const u=c.lineCount();if(u>=n)return c.isLeaf()?{position:o,leaf:c}:c.lineNumberToInfo(n,o);n-=u,o+=c.charCount()}return{position:o,leaf:void 0}}splitAfter(n){let o;const c=this.children.length;n++;const u=n;if(n<c){for(o=new CLe;n<c;)o.add(this.children[n]),n++;o.updateCounts()}return this.children.length=u,o}remove(n){const o=this.findChildIndex(n),c=this.children.length;if(o<c-1)for(let u=o;u<c-1;u++)this.children[u]=this.children[u+1];this.children.pop()}findChildIndex(n){const o=this.children.indexOf(n);return U.assert(o!==-1),o}insertAt(n,o){let c=this.findChildIndex(n);const u=this.children.length,p=o.length;if(u<W6&&c===u-1&&p===1)return this.add(o[0]),this.updateCounts(),[];{const m=this.splitAfter(c);let v=0;for(c++;c<W6&&v<p;)this.children[c]=o[v],c++,v++;let y=[],T=0;if(v<p){T=Math.ceil((p-v)/W6),y=new Array(T);let E=0;for(let R=0;R<T;R++)y[R]=new CLe;let I=y[0];for(;v<p;)I.add(o[v]),v++,I.children.length===W6&&(E++,I=y[E]);for(let R=y.length-1;R>=0;R--)y[R].children.length===0&&y.pop()}m&&y.push(m),this.updateCounts();for(let E=0;E<T;E++)y[E].updateCounts();return y}}add(n){this.children.push(n),U.assert(this.children.length<=W6)}charCount(){return this.totalChars}lineCount(){return this.totalLines}},wQ=class{constructor(e){this.text=e}isLeaf(){return!0}walk(e,n,o){o.leaf(e,n,this)}charCount(){return this.text.length}lineCount(){return 1}},$_t=class zNt{constructor(n,o,c,u,p,m){this.telemetryEnabled=n,this.logger=o,this.host=c,this.globalTypingsCacheLocation=u,this.event=p,this.maxActiveRequestCount=m,this.activeRequestCount=0,this.requestQueue=Fc(),this.requestMap=new Map,this.requestedRegistry=!1,this.packageInstallId=0}isKnownTypesPackageName(n){var o;return C2.validatePackageName(n)!==C2.NameValidationResult.Ok?!1:(this.requestedRegistry||(this.requestedRegistry=!0,this.installer.send({kind:"typesRegistry"})),!!((o=this.typesRegistryCache)!=null&&o.has(n)))}installPackage(n){this.packageInstallId++;const o={kind:"installPackage",...n,id:this.packageInstallId},c=new Promise((u,p)=>{(this.packageInstalledPromise??(this.packageInstalledPromise=new Map)).set(this.packageInstallId,{resolve:u,reject:p})});return this.installer.send(o),c}attach(n){this.projectService=n,this.installer=this.createInstallerProcess()}onProjectClosed(n){this.installer.send({projectName:n.getProjectName(),kind:"closeProject"})}enqueueInstallTypingsRequest(n,o,c){const u=M6e(n,o,c);this.logger.hasLevel(3)&&this.logger.info(`TIAdapter:: Scheduling throttled operation:${ux(u)}`),this.activeRequestCount<this.maxActiveRequestCount?this.scheduleRequest(u):(this.logger.hasLevel(3)&&this.logger.info(`TIAdapter:: Deferring request for: ${u.projectName}`),this.requestQueue.enqueue(u),this.requestMap.set(u.projectName,u))}handleMessage(n){var o,c;switch(this.logger.hasLevel(3)&&this.logger.info(`TIAdapter:: Received response:${ux(n)}`),n.kind){case zae:this.typesRegistryCache=new Map(Object.entries(n.typesRegistry));break;case UH:{const u=(o=this.packageInstalledPromise)==null?void 0:o.get(n.id);U.assertIsDefined(u,"Should find the promise for package install"),(c=this.packageInstalledPromise)==null||c.delete(n.id),n.success?u.resolve({successMessage:n.message}):u.reject(n.message),this.projectService.updateTypingsForProject(n),this.event(n,"setTypings");break}case zke:{const u={message:n.message};this.event(u,"typesInstallerInitializationFailed");break}case Uae:{const u={eventId:n.eventId,packages:n.packagesToInstall};this.event(u,"beginInstallTypes");break}case Vae:{if(this.telemetryEnabled){const m={telemetryEventName:"typingsInstalled",payload:{installedPackages:n.packagesToInstall.join(","),installSuccess:n.installSuccess,typingsInstallerVersion:n.typingsInstallerVersion}};this.event(m,"telemetry")}const u={eventId:n.eventId,packages:n.packagesToInstall,success:n.installSuccess};this.event(u,"endInstallTypes");break}case zH:{this.projectService.updateTypingsForProject(n);break}case qH:{for(this.activeRequestCount>0?this.activeRequestCount--:U.fail("TIAdapter:: Received too many responses");!this.requestQueue.isEmpty();){const u=this.requestQueue.dequeue();if(this.requestMap.get(u.projectName)===u){this.requestMap.delete(u.projectName),this.scheduleRequest(u);break}this.logger.hasLevel(3)&&this.logger.info(`TIAdapter:: Skipping defunct request for: ${u.projectName}`)}this.projectService.updateTypingsForProject(n),this.event(n,"setTypings");break}case Tj:this.projectService.watchTypingLocations(n);break}}scheduleRequest(n){this.logger.hasLevel(3)&&this.logger.info(`TIAdapter:: Scheduling request for: ${n.projectName}`),this.activeRequestCount++,this.host.setTimeout(()=>{this.logger.hasLevel(3)&&this.logger.info(`TIAdapter:: Sending request:${ux(n)}`),this.installer.send(n)},zNt.requestDelayMillis,`${n.projectName}::${n.kind}`)}};$_t.requestDelayMillis=100;var q_t=$_t,z_t={};d(z_t,{ActionInvalidate:()=>zH,ActionPackageInstalled:()=>UH,ActionSet:()=>qH,ActionWatchTypingLocations:()=>Tj,Arguments:()=>Jae,AutoImportProviderProject:()=>nNe,AuxiliaryProject:()=>tNe,CharRangeSection:()=>INe,CloseFileWatcherEvent:()=>ofe,CommandNames:()=>T_t,ConfigFileDiagEvent:()=>tfe,ConfiguredProject:()=>iNe,ConfiguredProjectLoadKind:()=>uNe,CreateDirectoryWatcherEvent:()=>sfe,CreateFileWatcherEvent:()=>ife,Errors:()=>q1,EventBeginInstallTypes:()=>Uae,EventEndInstallTypes:()=>Vae,EventInitializationFailed:()=>zke,EventTypesRegistry:()=>zae,ExternalProject:()=>Que,GcTimer:()=>U6e,InferredProject:()=>eNe,LargeFileReferencedEvent:()=>efe,LineIndex:()=>NB,LineLeaf:()=>wQ,LineNode:()=>H6,LogLevel:()=>F6e,Msg:()=>R6e,OpenFileInfoTelemetryEvent:()=>sNe,Project:()=>e3,ProjectInfoTelemetryEvent:()=>nfe,ProjectKind:()=>WF,ProjectLanguageServiceStateEvent:()=>rfe,ProjectLoadingFinishEvent:()=>Zue,ProjectLoadingStartEvent:()=>Xue,ProjectService:()=>vNe,ProjectsUpdatedInBackgroundEvent:()=>AQ,ScriptInfo:()=>H6e,ScriptVersionCache:()=>yfe,Session:()=>R_t,TextStorage:()=>W6e,ThrottledOperations:()=>z6e,TypingsInstallerAdapter:()=>q_t,allFilesAreJsOrDts:()=>Y6e,allRootFilesAreJsOrDts:()=>K6e,asNormalizedPath:()=>Zpt,convertCompilerOptions:()=>SQ,convertFormatOptions:()=>V6,convertScriptKindName:()=>cfe,convertTypeAcquisition:()=>aNe,convertUserPreferences:()=>cNe,convertWatchOptions:()=>DB,countEachFileTypes:()=>EB,createInstallTypingsRequest:()=>M6e,createModuleSpecifierCache:()=>SNe,createNormalizedPathMap:()=>e_t,createPackageJsonCache:()=>xNe,createSortedArray:()=>q6e,emptyArray:()=>Ff,findArgument:()=>ent,formatDiagnosticToProtocol:()=>PB,formatMessage:()=>wNe,getBaseConfigFileName:()=>Gue,getDetailWatchInfo:()=>dfe,getLocationInNewDocument:()=>kNe,hasArgument:()=>Zrt,hasNoTypeScriptSource:()=>X6e,indent:()=>gF,isBackgroundProject:()=>kB,isConfigFile:()=>bNe,isConfiguredProject:()=>Yb,isDynamicFileName:()=>JF,isExternalProject:()=>TB,isInferredProject:()=>U6,isInferredProjectName:()=>L6e,isProjectDeferredClose:()=>IB,makeAutoImportProviderProjectName:()=>B6e,makeAuxiliaryProjectName:()=>$6e,makeInferredProjectName:()=>j6e,maxFileSize:()=>Yue,maxProgramSizeForNonTsFiles:()=>Kue,normalizedPathToPath:()=>z6,nowString:()=>tnt,nullCancellationToken:()=>w_t,nullTypingsInstaller:()=>xQ,protocol:()=>V6e,scriptInfoIsContainedByBackgroundProject:()=>G6e,scriptInfoIsContainedByDeferredClosedProject:()=>Q6e,stringifyIndented:()=>ux,toEvent:()=>CNe,toNormalizedPath:()=>Bc,tryConvertScriptKindName:()=>afe,typingsInstaller:()=>O6e,updateProjectIfDirty:()=>_g}),typeof console<"u"&&(U.loggingHost={log(e,n){switch(e){case 1:return console.error(n);case 2:return console.warn(n);case 3:return console.log(n);case 4:return console.log(n)}}})})({get exports(){return i},set exports(a){i=a,t.exports&&(t.exports=a)}})})(y7e)),y7e.exports}var sUr=iUr();const Sp=Nkt(sUr);function oUr(t,r){for(const i of t.statements)if(Sp.isVariableStatement(i))for(const a of i.declarationList.declarations){if(!Sp.isIdentifier(a.name)||a.name.text!==r)continue;const l=a.initializer;if(l&&Sp.isObjectLiteralExpression(l))return l}}function aUr(t){const r=t.name;if(r&&(Sp.isIdentifier(r)||Sp.isStringLiteral(r)))return r.text}function cUr(t,r){const i=new Set;let a=!1;const l=d=>{Sp.isElementAccessExpression(d)&&Sp.isIdentifier(d.expression)&&d.expression.text===r&&(Sp.isIdentifier(d.argumentExpression)?i.add(d.argumentExpression.text):a=!0),Sp.forEachChild(d,l)};if(Sp.forEachChild(t,l),!(i.size===0&&!a))return i.size!==1||a?null:[...i][0]}function lUr(t){return(t.replaceAll("\\","/").split("/").pop()??t).replace(/\.[jt]sx?$/,"")}function uUr(t,r){return Sp.createSourceFile(t,r,Sp.ScriptTarget.Latest,!0,Sp.ScriptKind.TSX)}function fUr(t){for(const r of t.statements){if(Sp.isExportAssignment(r)&&!r.isExportEquals){const l=r.expression;if(Sp.isIdentifier(l))return l.text;continue}if((Sp.canHaveModifiers(r)?Sp.getModifiers(r):void 0)?.some(l=>l.kind===Sp.SyntaxKind.DefaultKeyword)&&(Sp.isFunctionDeclaration(r)||Sp.isClassDeclaration(r)))return r.name?.text}}function dUr(t,r,i){t.name&&i.set(t.name.text,{specifier:r});const a=t.namedBindings;if(!(!a||!Sp.isNamedImports(a)))for(const l of a.elements)i.set(l.name.text,{specifier:r,exported:(l.propertyName??l.name).text})}function pUr(t){const r=new Map;for(const i of t.statements)!Sp.isImportDeclaration(i)||!i.importClause||Sp.isStringLiteral(i.moduleSpecifier)&&dUr(i.importClause,i.moduleSpecifier.text,r);return r}function _Ur(t,r){for(const i of t.statements)if(Sp.isVariableStatement(i)&&(i.declarationList.flags&Sp.NodeFlags.Const)!==0)for(const a of i.declarationList.declarations){if(!Sp.isIdentifier(a.name)||a.name.text!==r)continue;const l=a.initializer;return l&&Sp.isStringLiteral(l)?l.text:void 0}}function mUr(t,r,i,a,l){const d=cUr(r,i);if(d===void 0){l.push(`scenesFromEntrypointSelection: ${t.path} never indexes \`${i}\`, so which of its compositions the entrypoint mounts is not stated in the source and no entry is settled as the active one.`);return}if(d===null){l.push(`scenesFromEntrypointSelection: ${t.path} indexes \`${i}\` with something other than one single identifier, so the key it mounts cannot be read statically.`);return}const _=_Ur(r,d);if(_===void 0){l.push(`scenesFromEntrypointSelection: ${t.path} indexes \`${i}\` with \`${d}\`, which is not a module-level \`const\` bound to a string literal, so the key it mounts cannot be read statically.`);return}if(!a.includes(_)){l.push(`scenesFromEntrypointSelection: ${t.path} mounts \`${i}\` under "${_}", which is not a key of that table. The entrypoint and its own selection table disagree.`);return}return _}function hUr(t){if(Sp.isShorthandPropertyAssignment(t))return t.name.text;if(Sp.isPropertyAssignment(t)&&Sp.isIdentifier(t.initializer))return t.initializer.text}function gUr(t,r,i){if(!t||!i)return;const a=i(t.specifier,r);if(a)return t.exported===void 0?{path:a}:{path:a,export:t.exported}}function yUr(t,r,i){if(t.regions===oge)return[...r];const a=[];for(const l of t.regions){const d=r.find(_=>_.regionId===l);d?a.push(d):i.push(`scenesFromEntrypointSelection: region "${l}" is selected but the project declares no root with that id and an entry.`)}return a}function vUr(t,r){return{id:t.regionId,label:fUr(r)??lUr(t.path),kind:"scene",region:t.regionId,authorable:!0,reach:{kind:"root-mount"},source:{path:t.path},finder:"scenesFromEntrypointSelection"}}function bUr(t,r,i,a,l){const d=oUr(r,i);if(!d)return l.push(`scenesFromEntrypointSelection: ${t.path} declares no module-level \`const ${i} = { … }\` selection table. Nothing is assumed in its place — fix the adapter’s \`selection\` or the entrypoint.`),{entries:[],active:void 0};const _=pUr(r),g=[],b=[];for(const w of d.properties){const N=aUr(w);if(N===void 0){l.push(`scenesFromEntrypointSelection: ${t.path}'s \`${i}\` has an entry whose key is computed, so it cannot be named statically.`);continue}const P=hUr(w);g.push(N),b.push({key:N,label:P??N,source:gUr(P?_.get(P):void 0,t.path,a)})}const S=mUr(t,r,i,g,l);return{entries:b.map(({key:w,label:N,source:P})=>({id:w,label:N,kind:"scene",region:t.regionId,authorable:!0,reach:{kind:"entrypoint-selection",selection:i,key:w,...w===S?{active:!0}:{}},...P?{source:P}:{},finder:"scenesFromEntrypointSelection"})),active:S}}function AUr(t,r){const i=[],a=[],l=[];for(const _ of yUr(t,r.entrypoints,i)){if(_.source===null){i.push(`scenesFromEntrypointSelection: could not read ${_.path} (region "${_.regionId}"), so its scenes are unknown — not empty.`);continue}const g=uUr(_.path,_.source);if(t.selection===void 0){a.push(vUr(_,g));continue}const b=bUr(_,g,t.selection,r.resolveModule,i);a.push(...b.entries),b.active!==void 0&&l.push(b.active)}const d=l.length===1?l[0]:a.length===1?a[0]?.id:void 0;return d!==void 0?{entries:a,default:d,notes:i}:{entries:a,notes:i}}function SUr(t,r){return tUr(t,r)}const xUr=Na({finder:Ry("scenesFromEntrypointSelection"),regions:bee([o_(Ss().min(1)).min(1),Ry(oge)]).describe("Region ids whose entrypoints carry the selection, or the rule form"),selection:Ss().min(1).optional().describe("Identifier of the entrypoint's module-level scene selection table; omit for a single-composition entrypoint")}).strict().refine(t=>t.selection===void 0||Array.isArray(t.regions),{message:`scenesFromEntrypointSelection: \`selection\` names an identifier in ONE entrypoint’s source, so it cannot be paired with the \`${oge}\` rule — name the region explicitly (\`regions: ["<rootId>"]\`).`});FNt({name:"scenesFromEntrypointSelection",schema:xUr,run:AUr});function UNt(t,r){const i=t.endsWith("/")?t.slice(0,-1):t,a=r.startsWith("/")?r.slice(1):r;return i.startsWith("/")?`/@fs${i}/${a}`:`/@fs/${i}/${a}`}const wUr="vgai-mount";function XDn(t,r,i){return`${UNt(t,r)}?vgai-live-module=${i}`}let v7e=Date.now();function ZDn(){return v7e=Math.max(v7e+1,Date.now()),v7e}function TX(t){return t.roots}function CUr(t,r){return t.roots.some(i=>i.surface===r)}function EUr(t){return t.roots.filter(r=>r.adapter.type==="ingest")}async function TUr(t){if(!t.length)return;const{useGLTF:r,useTexture:i}=await la(async()=>{const{useGLTF:a,useTexture:l}=await import("./index-Cl83EGRl.js");return{useGLTF:a,useTexture:l}},__vite__mapDeps([62,3,2,4,6,63,64,11,9,1]));for(const a of t)r.clear(a),i.clear(a)}function kUr(t){typeof window>"u"||!t.some(r=>/\.(glb|gltf|png|jpe?g|webp|avif)$/i.test(r))||window.dispatchEvent(new CustomEvent("editor:asset-loaders-changed"))}function IUr(t,r=()=>{}){const i=VP();return i.addEventListener("asset-moved",a=>{try{const l=JSON.parse(a.data);t(l)}catch{}}),i.addEventListener("assets-changed",async a=>{let l;try{l=JSON.parse(a.data)}catch{l={}}const d=l.paths?.map(_=>`/${_.replace(/^\/?public\//,"").replace(/^\//,"")}`)??[];await TUr(d),kUr(d),r(l)}),()=>i.close()}function VNt(t){const r=VP();return r.addEventListener("tool-files-changed",()=>t()),()=>r.close()}function DUr(t){const r=VP();return r.addEventListener("project-declarations-changed",t),()=>r.close()}function PUr(t){const r=VP();return r.addEventListener("source-files-changed",i=>{let a="";try{a=String(JSON.parse(i.data).path??"")}catch{}t(a)}),()=>r.close()}function NUr(t){const r=VP();return r.addEventListener("story-files-changed",()=>t()),()=>r.close()}const QUe="vgai.project.json",$q=new Map;function KUe(t){const r=t;return $q.set(t.kind,r),()=>{$q.get(t.kind)===r&&$q.delete(t.kind)}}function OUr(){return[...$q.keys()]}function FUr(t){return $q.get(t)}const eSt="play";KUe({kind:"process",role:"run",describe:"A process beside the host: an entry module, a port, readiness",schema:Na({id:Ss().min(1).describe("Configuration id"),kind:Ry("process"),entry:Ss().min(1).describe("Project-relative entry module"),command:Ss().min(1).optional().describe("Shell command that starts it; `npx tsx <entry>` when omitted"),port:Tu().int().min(1).max(65535).optional().describe("Port it listens on"),cwd:Ss().min(1).optional().describe("Project-relative working directory"),env:zR(Ss(),Ss()).optional().describe("Environment for the process"),ready:Na({http:Ss().min(1).optional().describe("HTTP path answering 2xx when up")}).strict().optional().describe("Readiness beyond the port accepting connections")}).strict()});KUe({kind:"compound",role:"run",describe:"Several configurations started together; `play` names the host mount",schema:Na({id:Ss().min(1).describe("Configuration id"),kind:Ry("compound"),run:o_(Ss().min(1)).min(1).describe("Configuration ids, `play` included"),instances:Tu().int().min(1).optional().describe("Instances of the host mount to run against the rest")}).strict()});KUe({kind:"bundle",role:"build",describe:"The project's web bundle: its build script, then dist/ packaged as the artifact",schema:Na({id:Ss().min(1).describe("Configuration id"),kind:Ry("bundle"),script:Ss().min(1).optional().describe("package.json script that builds (`build`)"),args:o_(Ss()).optional().describe("Arguments passed after `--`")}).strict()});function RUr(t){const r=[],i=new Set;for(const a of t){i.has(a.id)&&r.push(`configurations: duplicate id "${a.id}"`),i.add(a.id);const l=$q.get(a.kind);if(!l){r.push(`configurations "${a.id}": unknown kind "${a.kind}" — registered: ${OUr().map(_=>`"${_}"`).join(", ")}`);continue}const d=l.schema.safeParse(a);if(!d.success)for(const _ of d.error.issues)r.push(`configurations "${a.id}" (${a.kind}): ${_.path.join(".")||"(declaration)"}: ${_.message}`)}for(const a of t){if(a.kind!=="compound")continue;const l=a.run??[];for(const d of l)d!==eSt&&!i.has(d)&&r.push(`configurations "${a.id}": member "${d}" is not a declared configuration (or "${eSt}")`)}return r}const MUr=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z-.]+)?(?:\+[0-9A-Za-z-.]+)?$/;function LUr(t){return typeof t=="object"&&"module"in t}function jUr(t){const{adapter:r}=t;if(typeof r=="string"&&!t.entry)throw new Error(`Game manifest: root "${t.id}" uses the '${r}' adapter but declares no \`entry\` — a built-in adapter root is authored as an entry module.`);if(typeof r=="object"&&"ingest"in r&&!t.entry)throw new Error(`Game manifest: root "${t.id}" is an { ingest } root but declares no \`entry\` — the game's own entry module is what the host imports.`)}function BUr(t){const{adapter:r}=t;if(typeof r=="string")return{type:"builtin",identity:r,surface:r};if(LUr(r))return{type:"module",identity:"module",module:r.module,surface:r.surface};const i=r.surface==="three"?"ingest-three":r.surface==="canvas"?"ingest-pixi":"ingest-react",a=r.ingest;return{type:"ingest",identity:i,surface:r.surface,contractShim:a.contractShim,dataWriter:a.dataWriter,assets:a.assets,domStubs:a.domStubs,captureTimeoutMs:a.captureTimeoutMs}}function $Ur(t){if(!MUr.test(t))throw new Error(`Game manifest: engine.version "${t}" is not a valid exact semver string (e.g. "0.1.0") — §1.5 requires an exact identity pin, not a range.`)}function qUr(t){jUr(t);const r=BUr(t);return{id:t.id,surface:r.surface,description:t.description,adapter:r,entry:t.entry,world:t.world===void 0?void 0:{entry:t.world.entry,export:t.world.export},zOrder:t.zOrder,pausable:t.pausable,loop:t.loop}}function JNt(t,r={}){const i=OMr.safeParse(t);if(!i.success){const S=i.error.issues.find(k=>k.message.startsWith("Game manifest: duplicate root id")||k.message.startsWith("Game manifest: a project has at most one"));throw S?new Error(S.message):i.error}const a=i.data;$Ur(a.engine.version);const l=a.roots.map((S,k)=>({root:qUr(S),index:k}));l.sort((S,k)=>S.root.zOrder-k.root.zOrder||S.index-k.index);const d=l.map(({root:S})=>S),_=a.configurations??[],g=[],b=RUr(_).filter(S=>{if(r.configurationKinds!=="defer")return!0;const k=/^configurations "([^"]+)": unknown kind/.exec(S);return k?(g.push(k[1]),!1):!0});if(b.length>0)throw new Error(`Game manifest: ${b.join(`
|
|
525
525
|
`)}`);for(const S of _)!FUr(S.kind)&&!g.includes(S.id)&&g.push(S.id);return{manifestVersion:a.manifestVersion,name:a.name,appId:a.appId,version:a.version,engine:{version:a.engine.version},roots:d,configurations:_,deferredConfigurationKinds:g,resolution:a.resolution,rendering:a.rendering,authoring:a.authoring,debug:a.debug,determinism:a.determinism,budget:a.budget,learn:a.learn}}const zUr="ManifestAbsentError";function tSt(t){const r=new Error(`${t} declares no ${QUe}`);return r.name=zUr,r}async function UUr(){const t=Oee("/vgai.project.json"),r=await fetch(t);if(r.status===404)throw tSt(t);if(!r.ok)throw new Error(`Failed to load ${t}: ${r.status} ${r.statusText}`);const i=await r.text();if(/^\s*</.test(i))throw tSt(t);try{return JNt(JSON.parse(i),{configurationKinds:"defer"})}catch(a){throw new Error(`Failed to load ${t}: ${a instanceof Error?a.message:String(a)}`)}}async function e3n(){const t=Oee("/vgai.project.json"),r=await fetch(t);if(!r.ok)return null;const i=await r.text();if(/^\s*</.test(i))return null;try{return JSON.parse(i)}catch(a){throw new Error(`${t} is not valid JSON: ${a instanceof Error?a.message:String(a)}`)}}let WNt=[];function VUr(t){WNt=t}function t3n(t){return WNt.find(r=>r.surface===t)?.basis??DNt}function kX(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)?t:null}function HNt(t){const r=kX(t);if(!r)return;const i=kX(r.rootLabels),a=i?Object.entries(i).flatMap(([b,S])=>{const k=b.trim(),w=typeof S=="string"?S.trim():"";return k&&w?[[k,w]]:[]}):[],l=a.length>0?Object.fromEntries(a):void 0,d=new Set,_=Array.isArray(r.groups)?r.groups.flatMap(b=>{const S=kX(b),k=typeof S?.id=="string"?S.id.trim():"",w=typeof S?.label=="string"?S.label.trim():"",N=Array.isArray(S?.roots)?S.roots.flatMap(P=>{const j=typeof P=="string"?P.trim():"";return j?[j]:[]}):[];return!k||!w||N.length===0||d.has(k)?[]:(d.add(k),[{id:k,label:w,roots:[...new Set(N)]}])}):[],g=_.length>0?_:void 0;if(!(!l&&!g))return{...l?{rootLabels:l}:{},...g?{groups:g}:{}}}function r3n(t){const r=kX(kX(t)?.authoring);return HNt(r?.hierarchy)}function JUr(t){const r=t&&typeof t=="object"&&Array.isArray(t.issues)?t.issues:null;return r?r.map(i=>{if(!i||typeof i!="object")return String(i);const a=i,l=Array.isArray(a.path)&&a.path.map(String).join(".")||"(root)",d=typeof a.message=="string"?a.message:"Invalid manifest value";return`${l}: ${d}`}).join(`
|
|
526
526
|
`):t instanceof Error?t.message:String(t)}async function WUr(t){const r=await gNt(),i=await fetch("/vgai.project.json");if(!i.ok)throw new Error(`Could not open project at ${t}.
|
|
527
527
|
Failed to load vgai.project.json: ${i.status} ${i.statusText}`);let a;try{a=await i.json()}catch(_){throw new Error(`Could not open project at ${t}.
|
|
@@ -1541,7 +1541,7 @@ ${xe.description}`)},"showError"),showException:Cr(xe=>{throw xe},"showException
|
|
|
1541
1541
|
The possible options are: ${Object.keys(G7e).join(", ")}, none.
|
|
1542
1542
|
`)}showMode(r){clearTimeout(this.preparingTimeout),Object.keys(PVt).forEach(i=>{i===r?d1.body.classList.add(H7e[i]):d1.body.classList.remove(H7e[i])})}showErrorDisplay({message:r="",stack:i=""}){let a=r,l=i,d=r.split(`
|
|
1543
1543
|
`);d.length>1&&([a]=d,l=d.slice(1).join(`
|
|
1544
|
-
`).replace(/^\n/,"")),d1.getElementById("error-message").innerHTML=Awt.toHtml(a),d1.getElementById("error-stack").innerHTML=Awt.toHtml(l),this.showMode("ERROR")}showNoPreview(){this.testing||(this.showMode("NOPREVIEW"),this.storyRoot()?.setAttribute("hidden","true"),this.docsRoot()?.setAttribute("hidden","true"))}showPreparingStory({immediate:r=!1}={}){clearTimeout(this.preparingTimeout),r?this.showMode("PREPARING_STORY"):this.preparingTimeout=setTimeout(()=>this.showMode("PREPARING_STORY"),bwt)}showPreparingDocs({immediate:r=!1}={}){clearTimeout(this.preparingTimeout),r?this.showMode("PREPARING_DOCS"):this.preparingTimeout=setTimeout(()=>this.showMode("PREPARING_DOCS"),bwt)}showMain(){this.showMode("MAIN")}showDocs(){this.storyRoot().setAttribute("hidden","true"),this.docsRoot().removeAttribute("hidden")}showStory(){this.docsRoot().setAttribute("hidden","true"),this.storyRoot().removeAttribute("hidden")}showStoryDuringRender(){d1.body.classList.add(H7e.MAIN)}};Cr(NVt,"WebView");var Eun=NVt,Tun=class extends hun{constructor(r,i){super(r,i,new xun,new Eun),this.importFn=r,this.getProjectAnnotations=i,na.__STORYBOOK_PREVIEW__=this}};Cr(Tun,"PreviewWeb");var{document:LR}=na,kun=["application/javascript","application/ecmascript","application/x-ecmascript","application/x-javascript","text/ecmascript","text/javascript","text/javascript1.0","text/javascript1.1","text/javascript1.2","text/javascript1.3","text/javascript1.4","text/javascript1.5","text/jscript","text/livescript","text/x-ecmascript","text/x-javascript","module"],Iun="script",Swt="scripts-root";function KBe(){let t=LR.createEvent("Event");t.initEvent("DOMContentLoaded",!0,!0),LR.dispatchEvent(t)}Cr(KBe,"simulateDOMContentLoaded");function OVt(t,r,i){let a=LR.createElement("script");a.type=t.type==="module"?"module":"text/javascript",t.src?(a.onload=r,a.onerror=r,a.src=t.src):a.textContent=t.innerText,i?i.appendChild(a):LR.head.appendChild(a),t.parentNode.removeChild(t),t.src||r()}Cr(OVt,"insertScript");function FGe(t,r,i=0){t[i](()=>{i++,i===t.length?r():FGe(t,r,i)})}Cr(FGe,"insertScriptsSequentially");function Dun(t){let r=LR.getElementById(Swt);r?r.innerHTML="":(r=LR.createElement("div"),r.id=Swt,LR.body.appendChild(r));let i=Array.from(t.querySelectorAll(Iun));if(i.length){let a=[];i.forEach(l=>{let d=l.getAttribute("type");(!d||kun.includes(d))&&a.push(_=>OVt(l,_,r))}),a.length&&FGe(a,KBe,void 0)}else KBe()}Cr(Dun,"simulatePageLoad");var Pun="storybook/docs",Nun=`${Pun}/snippet-rendered`;async function FVt(t,r){let i=r.parameters?.docs?.source?.transform,{id:a,unmappedArgs:l}=r,d=i&&t?i?.(t,r):t,_=d?await d:void 0;EE.getChannel().emit(Nun,{id:a,source:_,args:l})}Cr(FVt,"emitTransformCode");var RVt=(t,r)=>CGe(i=>fE.createElement(t,i),r),Oun=Object.create,F1e=Object.defineProperty,Fun=Object.getOwnPropertyDescriptor,RGe=Object.getOwnPropertyNames,Run=Object.getPrototypeOf,Mun=Object.prototype.hasOwnProperty,Lun=(t,r)=>function(){return t&&(r=(0,t[RGe(t)[0]])(t=0)),r},Ua=(t,r)=>function(){return r||(0,t[RGe(t)[0]])((r={exports:{}}).exports,r),r.exports},R1e=(t,r)=>{for(var i in r)F1e(t,i,{get:r[i],enumerable:!0})},MVt=(t,r,i,a)=>{if(r&&typeof r=="object"||typeof r=="function")for(let l of RGe(r))!Mun.call(t,l)&&l!==i&&F1e(t,l,{get:()=>r[l],enumerable:!(a=Fun(r,l))||a.enumerable});return t},TU=(t,r,i)=>(i=t!=null?Oun(Run(t)):{},MVt(!t||!t.__esModule?F1e(i,"default",{value:t,enumerable:!0}):i,t)),xwt=t=>MVt(F1e({},"__esModule",{value:!0}),t),Q7e={},M1e=Ua({"../../node_modules/semver/internal/constants.js"(t,r){var i="2.0.0",a=Number.MAX_SAFE_INTEGER||9007199254740991,l=16,d=250,_=["major","premajor","minor","preminor","patch","prepatch","prerelease"];r.exports={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:l,MAX_SAFE_BUILD_LENGTH:d,MAX_SAFE_INTEGER:a,RELEASE_TYPES:_,SEMVER_SPEC_VERSION:i,FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}}}),L1e=Ua({"../../node_modules/semver/internal/debug.js"(t,r){var i=typeof process=="object"&&Q7e&&Q7e.NODE_DEBUG&&/\bsemver\b/i.test(Q7e.NODE_DEBUG)?(...a)=>console.error("SEMVER",...a):()=>{};r.exports=i}}),ite=Ua({"../../node_modules/semver/internal/re.js"(t,r){var{MAX_SAFE_COMPONENT_LENGTH:i,MAX_SAFE_BUILD_LENGTH:a,MAX_LENGTH:l}=M1e(),d=L1e();t=r.exports={};var _=t.re=[],g=t.safeRe=[],b=t.src=[],S=t.safeSrc=[],k=t.t={},w=0,N="[a-zA-Z0-9-]",P=[["\\s",1],["\\d",l],[N,a]],j=X=>{for(let[G,ee]of P)X=X.split(`${G}*`).join(`${G}{0,${ee}}`).split(`${G}+`).join(`${G}{1,${ee}}`);return X},J=(X,G,ee)=>{let xe=j(G),ue=w++;d(X,ue,G),k[X]=ue,b[ue]=G,S[ue]=xe,_[ue]=new RegExp(G,ee?"g":void 0),g[ue]=new RegExp(xe,ee?"g":void 0)};J("NUMERICIDENTIFIER","0|[1-9]\\d*"),J("NUMERICIDENTIFIERLOOSE","\\d+"),J("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${N}*`),J("MAINVERSION",`(${b[k.NUMERICIDENTIFIER]})\\.(${b[k.NUMERICIDENTIFIER]})\\.(${b[k.NUMERICIDENTIFIER]})`),J("MAINVERSIONLOOSE",`(${b[k.NUMERICIDENTIFIERLOOSE]})\\.(${b[k.NUMERICIDENTIFIERLOOSE]})\\.(${b[k.NUMERICIDENTIFIERLOOSE]})`),J("PRERELEASEIDENTIFIER",`(?:${b[k.NONNUMERICIDENTIFIER]}|${b[k.NUMERICIDENTIFIER]})`),J("PRERELEASEIDENTIFIERLOOSE",`(?:${b[k.NONNUMERICIDENTIFIER]}|${b[k.NUMERICIDENTIFIERLOOSE]})`),J("PRERELEASE",`(?:-(${b[k.PRERELEASEIDENTIFIER]}(?:\\.${b[k.PRERELEASEIDENTIFIER]})*))`),J("PRERELEASELOOSE",`(?:-?(${b[k.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${b[k.PRERELEASEIDENTIFIERLOOSE]})*))`),J("BUILDIDENTIFIER",`${N}+`),J("BUILD",`(?:\\+(${b[k.BUILDIDENTIFIER]}(?:\\.${b[k.BUILDIDENTIFIER]})*))`),J("FULLPLAIN",`v?${b[k.MAINVERSION]}${b[k.PRERELEASE]}?${b[k.BUILD]}?`),J("FULL",`^${b[k.FULLPLAIN]}$`),J("LOOSEPLAIN",`[v=\\s]*${b[k.MAINVERSIONLOOSE]}${b[k.PRERELEASELOOSE]}?${b[k.BUILD]}?`),J("LOOSE",`^${b[k.LOOSEPLAIN]}$`),J("GTLT","((?:<|>)?=?)"),J("XRANGEIDENTIFIERLOOSE",`${b[k.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),J("XRANGEIDENTIFIER",`${b[k.NUMERICIDENTIFIER]}|x|X|\\*`),J("XRANGEPLAIN",`[v=\\s]*(${b[k.XRANGEIDENTIFIER]})(?:\\.(${b[k.XRANGEIDENTIFIER]})(?:\\.(${b[k.XRANGEIDENTIFIER]})(?:${b[k.PRERELEASE]})?${b[k.BUILD]}?)?)?`),J("XRANGEPLAINLOOSE",`[v=\\s]*(${b[k.XRANGEIDENTIFIERLOOSE]})(?:\\.(${b[k.XRANGEIDENTIFIERLOOSE]})(?:\\.(${b[k.XRANGEIDENTIFIERLOOSE]})(?:${b[k.PRERELEASELOOSE]})?${b[k.BUILD]}?)?)?`),J("XRANGE",`^${b[k.GTLT]}\\s*${b[k.XRANGEPLAIN]}$`),J("XRANGELOOSE",`^${b[k.GTLT]}\\s*${b[k.XRANGEPLAINLOOSE]}$`),J("COERCEPLAIN",`(^|[^\\d])(\\d{1,${i}})(?:\\.(\\d{1,${i}}))?(?:\\.(\\d{1,${i}}))?`),J("COERCE",`${b[k.COERCEPLAIN]}(?:$|[^\\d])`),J("COERCEFULL",b[k.COERCEPLAIN]+`(?:${b[k.PRERELEASE]})?(?:${b[k.BUILD]})?(?:$|[^\\d])`),J("COERCERTL",b[k.COERCE],!0),J("COERCERTLFULL",b[k.COERCEFULL],!0),J("LONETILDE","(?:~>?)"),J("TILDETRIM",`(\\s*)${b[k.LONETILDE]}\\s+`,!0),t.tildeTrimReplace="$1~",J("TILDE",`^${b[k.LONETILDE]}${b[k.XRANGEPLAIN]}$`),J("TILDELOOSE",`^${b[k.LONETILDE]}${b[k.XRANGEPLAINLOOSE]}$`),J("LONECARET","(?:\\^)"),J("CARETTRIM",`(\\s*)${b[k.LONECARET]}\\s+`,!0),t.caretTrimReplace="$1^",J("CARET",`^${b[k.LONECARET]}${b[k.XRANGEPLAIN]}$`),J("CARETLOOSE",`^${b[k.LONECARET]}${b[k.XRANGEPLAINLOOSE]}$`),J("COMPARATORLOOSE",`^${b[k.GTLT]}\\s*(${b[k.LOOSEPLAIN]})$|^$`),J("COMPARATOR",`^${b[k.GTLT]}\\s*(${b[k.FULLPLAIN]})$|^$`),J("COMPARATORTRIM",`(\\s*)${b[k.GTLT]}\\s*(${b[k.LOOSEPLAIN]}|${b[k.XRANGEPLAIN]})`,!0),t.comparatorTrimReplace="$1$2$3",J("HYPHENRANGE",`^\\s*(${b[k.XRANGEPLAIN]})\\s+-\\s+(${b[k.XRANGEPLAIN]})\\s*$`),J("HYPHENRANGELOOSE",`^\\s*(${b[k.XRANGEPLAINLOOSE]})\\s+-\\s+(${b[k.XRANGEPLAINLOOSE]})\\s*$`),J("STAR","(<|>)?=?\\s*\\*"),J("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$"),J("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")}}),MGe=Ua({"../../node_modules/semver/internal/parse-options.js"(t,r){var i=Object.freeze({loose:!0}),a=Object.freeze({}),l=d=>d?typeof d!="object"?i:d:a;r.exports=l}}),LVt=Ua({"../../node_modules/semver/internal/identifiers.js"(t,r){var i=/^[0-9]+$/,a=(d,_)=>{let g=i.test(d),b=i.test(_);return g&&b&&(d=+d,_=+_),d===_?0:g&&!b?-1:b&&!g?1:d<_?-1:1},l=(d,_)=>a(_,d);r.exports={compareIdentifiers:a,rcompareIdentifiers:l}}}),Eb=Ua({"../../node_modules/semver/classes/semver.js"(t,r){var i=L1e(),{MAX_LENGTH:a,MAX_SAFE_INTEGER:l}=M1e(),{safeRe:d,t:_}=ite(),g=MGe(),{compareIdentifiers:b}=LVt(),S=class Jk{constructor(w,N){if(N=g(N),w instanceof Jk){if(w.loose===!!N.loose&&w.includePrerelease===!!N.includePrerelease)return w;w=w.version}else if(typeof w!="string")throw new TypeError(`Invalid version. Must be a string. Got type "${typeof w}".`);if(w.length>a)throw new TypeError(`version is longer than ${a} characters`);i("SemVer",w,N),this.options=N,this.loose=!!N.loose,this.includePrerelease=!!N.includePrerelease;let P=w.trim().match(N.loose?d[_.LOOSE]:d[_.FULL]);if(!P)throw new TypeError(`Invalid Version: ${w}`);if(this.raw=w,this.major=+P[1],this.minor=+P[2],this.patch=+P[3],this.major>l||this.major<0)throw new TypeError("Invalid major version");if(this.minor>l||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>l||this.patch<0)throw new TypeError("Invalid patch version");P[4]?this.prerelease=P[4].split(".").map(j=>{if(/^[0-9]+$/.test(j)){let J=+j;if(J>=0&&J<l)return J}return j}):this.prerelease=[],this.build=P[5]?P[5].split("."):[],this.format()}format(){return this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length&&(this.version+=`-${this.prerelease.join(".")}`),this.version}toString(){return this.version}compare(w){if(i("SemVer.compare",this.version,this.options,w),!(w instanceof Jk)){if(typeof w=="string"&&w===this.version)return 0;w=new Jk(w,this.options)}return w.version===this.version?0:this.compareMain(w)||this.comparePre(w)}compareMain(w){return w instanceof Jk||(w=new Jk(w,this.options)),b(this.major,w.major)||b(this.minor,w.minor)||b(this.patch,w.patch)}comparePre(w){if(w instanceof Jk||(w=new Jk(w,this.options)),this.prerelease.length&&!w.prerelease.length)return-1;if(!this.prerelease.length&&w.prerelease.length)return 1;if(!this.prerelease.length&&!w.prerelease.length)return 0;let N=0;do{let P=this.prerelease[N],j=w.prerelease[N];if(i("prerelease compare",N,P,j),P===void 0&&j===void 0)return 0;if(j===void 0)return 1;if(P===void 0)return-1;if(P!==j)return b(P,j)}while(++N)}compareBuild(w){w instanceof Jk||(w=new Jk(w,this.options));let N=0;do{let P=this.build[N],j=w.build[N];if(i("build compare",N,P,j),P===void 0&&j===void 0)return 0;if(j===void 0)return 1;if(P===void 0)return-1;if(P!==j)return b(P,j)}while(++N)}inc(w,N,P){if(w.startsWith("pre")){if(!N&&P===!1)throw new Error("invalid increment argument: identifier is empty");if(N){let j=`-${N}`.match(this.options.loose?d[_.PRERELEASELOOSE]:d[_.PRERELEASE]);if(!j||j[1]!==N)throw new Error(`invalid identifier: ${N}`)}}switch(w){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",N,P);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",N,P);break;case"prepatch":this.prerelease.length=0,this.inc("patch",N,P),this.inc("pre",N,P);break;case"prerelease":this.prerelease.length===0&&this.inc("patch",N,P),this.inc("pre",N,P);break;case"release":if(this.prerelease.length===0)throw new Error(`version ${this.raw} is not a prerelease`);this.prerelease.length=0;break;case"major":(this.minor!==0||this.patch!==0||this.prerelease.length===0)&&this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":(this.patch!==0||this.prerelease.length===0)&&this.minor++,this.patch=0,this.prerelease=[];break;case"patch":this.prerelease.length===0&&this.patch++,this.prerelease=[];break;case"pre":{let j=Number(P)?1:0;if(this.prerelease.length===0)this.prerelease=[j];else{let J=this.prerelease.length;for(;--J>=0;)typeof this.prerelease[J]=="number"&&(this.prerelease[J]++,J=-2);if(J===-1){if(N===this.prerelease.join(".")&&P===!1)throw new Error("invalid increment argument: identifier already exists");this.prerelease.push(j)}}if(N){let J=[N,j];P===!1&&(J=[N]),b(this.prerelease[0],N)===0?isNaN(this.prerelease[1])&&(this.prerelease=J):this.prerelease=J}break}default:throw new Error(`invalid increment argument: ${w}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(".")}`),this}};r.exports=S}}),kU=Ua({"../../node_modules/semver/functions/parse.js"(t,r){var i=Eb(),a=(l,d,_=!1)=>{if(l instanceof i)return l;try{return new i(l,d)}catch(g){if(!_)return null;throw g}};r.exports=a}}),jun=Ua({"../../node_modules/semver/functions/valid.js"(t,r){var i=kU(),a=(l,d)=>{let _=i(l,d);return _?_.version:null};r.exports=a}}),Bun=Ua({"../../node_modules/semver/functions/clean.js"(t,r){var i=kU(),a=(l,d)=>{let _=i(l.trim().replace(/^[=v]+/,""),d);return _?_.version:null};r.exports=a}}),$un=Ua({"../../node_modules/semver/functions/inc.js"(t,r){var i=Eb(),a=(l,d,_,g,b)=>{typeof _=="string"&&(b=g,g=_,_=void 0);try{return new i(l instanceof i?l.version:l,_).inc(d,g,b).version}catch{return null}};r.exports=a}}),qun=Ua({"../../node_modules/semver/functions/diff.js"(t,r){var i=kU(),a=(l,d)=>{let _=i(l,null,!0),g=i(d,null,!0),b=_.compare(g);if(b===0)return null;let S=b>0,k=S?_:g,w=S?g:_,N=!!k.prerelease.length;if(w.prerelease.length&&!N){if(!w.patch&&!w.minor)return"major";if(w.compareMain(k)===0)return w.minor&&!w.patch?"minor":"patch"}let P=N?"pre":"";return _.major!==g.major?P+"major":_.minor!==g.minor?P+"minor":_.patch!==g.patch?P+"patch":"prerelease"};r.exports=a}}),zun=Ua({"../../node_modules/semver/functions/major.js"(t,r){var i=Eb(),a=(l,d)=>new i(l,d).major;r.exports=a}}),Uun=Ua({"../../node_modules/semver/functions/minor.js"(t,r){var i=Eb(),a=(l,d)=>new i(l,d).minor;r.exports=a}}),Vun=Ua({"../../node_modules/semver/functions/patch.js"(t,r){var i=Eb(),a=(l,d)=>new i(l,d).patch;r.exports=a}}),Jun=Ua({"../../node_modules/semver/functions/prerelease.js"(t,r){var i=kU(),a=(l,d)=>{let _=i(l,d);return _&&_.prerelease.length?_.prerelease:null};r.exports=a}}),NE=Ua({"../../node_modules/semver/functions/compare.js"(t,r){var i=Eb(),a=(l,d,_)=>new i(l,_).compare(new i(d,_));r.exports=a}}),Wun=Ua({"../../node_modules/semver/functions/rcompare.js"(t,r){var i=NE(),a=(l,d,_)=>i(d,l,_);r.exports=a}}),Hun=Ua({"../../node_modules/semver/functions/compare-loose.js"(t,r){var i=NE(),a=(l,d)=>i(l,d,!0);r.exports=a}}),LGe=Ua({"../../node_modules/semver/functions/compare-build.js"(t,r){var i=Eb(),a=(l,d,_)=>{let g=new i(l,_),b=new i(d,_);return g.compare(b)||g.compareBuild(b)};r.exports=a}}),Gun=Ua({"../../node_modules/semver/functions/sort.js"(t,r){var i=LGe(),a=(l,d)=>l.sort((_,g)=>i(_,g,d));r.exports=a}}),Qun=Ua({"../../node_modules/semver/functions/rsort.js"(t,r){var i=LGe(),a=(l,d)=>l.sort((_,g)=>i(g,_,d));r.exports=a}}),j1e=Ua({"../../node_modules/semver/functions/gt.js"(t,r){var i=NE(),a=(l,d,_)=>i(l,d,_)>0;r.exports=a}}),jGe=Ua({"../../node_modules/semver/functions/lt.js"(t,r){var i=NE(),a=(l,d,_)=>i(l,d,_)<0;r.exports=a}}),jVt=Ua({"../../node_modules/semver/functions/eq.js"(t,r){var i=NE(),a=(l,d,_)=>i(l,d,_)===0;r.exports=a}}),BVt=Ua({"../../node_modules/semver/functions/neq.js"(t,r){var i=NE(),a=(l,d,_)=>i(l,d,_)!==0;r.exports=a}}),BGe=Ua({"../../node_modules/semver/functions/gte.js"(t,r){var i=NE(),a=(l,d,_)=>i(l,d,_)>=0;r.exports=a}}),$Ge=Ua({"../../node_modules/semver/functions/lte.js"(t,r){var i=NE(),a=(l,d,_)=>i(l,d,_)<=0;r.exports=a}}),$Vt=Ua({"../../node_modules/semver/functions/cmp.js"(t,r){var i=jVt(),a=BVt(),l=j1e(),d=BGe(),_=jGe(),g=$Ge(),b=(S,k,w,N)=>{switch(k){case"===":return typeof S=="object"&&(S=S.version),typeof w=="object"&&(w=w.version),S===w;case"!==":return typeof S=="object"&&(S=S.version),typeof w=="object"&&(w=w.version),S!==w;case"":case"=":case"==":return i(S,w,N);case"!=":return a(S,w,N);case">":return l(S,w,N);case">=":return d(S,w,N);case"<":return _(S,w,N);case"<=":return g(S,w,N);default:throw new TypeError(`Invalid operator: ${k}`)}};r.exports=b}}),Kun=Ua({"../../node_modules/semver/functions/coerce.js"(t,r){var i=Eb(),a=kU(),{safeRe:l,t:d}=ite(),_=(g,b)=>{if(g instanceof i)return g;if(typeof g=="number"&&(g=String(g)),typeof g!="string")return null;b=b||{};let S=null;if(!b.rtl)S=g.match(b.includePrerelease?l[d.COERCEFULL]:l[d.COERCE]);else{let J=b.includePrerelease?l[d.COERCERTLFULL]:l[d.COERCERTL],X;for(;(X=J.exec(g))&&(!S||S.index+S[0].length!==g.length);)(!S||X.index+X[0].length!==S.index+S[0].length)&&(S=X),J.lastIndex=X.index+X[1].length+X[2].length;J.lastIndex=-1}if(S===null)return null;let k=S[2],w=S[3]||"0",N=S[4]||"0",P=b.includePrerelease&&S[5]?`-${S[5]}`:"",j=b.includePrerelease&&S[6]?`+${S[6]}`:"";return a(`${k}.${w}.${N}${P}${j}`,b)};r.exports=_}}),Yun=Ua({"../../node_modules/semver/internal/lrucache.js"(t,r){var i=class{constructor(){this.max=1e3,this.map=new Map}get(a){let l=this.map.get(a);if(l!==void 0)return this.map.delete(a),this.map.set(a,l),l}delete(a){return this.map.delete(a)}set(a,l){if(!this.delete(a)&&l!==void 0){if(this.map.size>=this.max){let d=this.map.keys().next().value;this.delete(d)}this.map.set(a,l)}return this}};r.exports=i}}),OE=Ua({"../../node_modules/semver/classes/range.js"(t,r){var i=/\s+/g,a=class Tme{constructor(cr,Yt){if(Yt=_(Yt),cr instanceof Tme)return cr.loose===!!Yt.loose&&cr.includePrerelease===!!Yt.includePrerelease?cr:new Tme(cr.raw,Yt);if(cr instanceof g)return this.raw=cr.value,this.set=[[cr]],this.formatted=void 0,this;if(this.options=Yt,this.loose=!!Yt.loose,this.includePrerelease=!!Yt.includePrerelease,this.raw=cr.trim().replace(i," "),this.set=this.raw.split("||").map(Lr=>this.parseRange(Lr.trim())).filter(Lr=>Lr.length),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){let Lr=this.set[0];if(this.set=this.set.filter(nn=>!G(nn[0])),this.set.length===0)this.set=[Lr];else if(this.set.length>1){for(let nn of this.set)if(nn.length===1&&ee(nn[0])){this.set=[nn];break}}}this.formatted=void 0}get range(){if(this.formatted===void 0){this.formatted="";for(let cr=0;cr<this.set.length;cr++){cr>0&&(this.formatted+="||");let Yt=this.set[cr];for(let Lr=0;Lr<Yt.length;Lr++)Lr>0&&(this.formatted+=" "),this.formatted+=Yt[Lr].toString().trim()}}return this.formatted}format(){return this.range}toString(){return this.range}parseRange(cr){let Yt=((this.options.includePrerelease&&J)|(this.options.loose&&X))+":"+cr,Lr=d.get(Yt);if(Lr)return Lr;let nn=this.options.loose,on=nn?k[w.HYPHENRANGELOOSE]:k[w.HYPHENRANGE];cr=cr.replace(on,Et(this.options.includePrerelease)),b("hyphen replace",cr),cr=cr.replace(k[w.COMPARATORTRIM],N),b("comparator trim",cr),cr=cr.replace(k[w.TILDETRIM],P),b("tilde trim",cr),cr=cr.replace(k[w.CARETTRIM],j),b("caret trim",cr);let gr=cr.split(" ").map(Mn=>ue(Mn,this.options)).join(" ").split(/\s+/).map(Mn=>vt(Mn,this.options));nn&&(gr=gr.filter(Mn=>(b("loose invalid filter",Mn,this.options),!!Mn.match(k[w.COMPARATORLOOSE])))),b("range list",gr);let An=new Map,Rn=gr.map(Mn=>new g(Mn,this.options));for(let Mn of Rn){if(G(Mn))return[Mn];An.set(Mn.value,Mn)}An.size>1&&An.has("")&&An.delete("");let ln=[...An.values()];return d.set(Yt,ln),ln}intersects(cr,Yt){if(!(cr instanceof Tme))throw new TypeError("a Range is required");return this.set.some(Lr=>xe(Lr,Yt)&&cr.set.some(nn=>xe(nn,Yt)&&Lr.every(on=>nn.every(gr=>on.intersects(gr,Yt)))))}test(cr){if(!cr)return!1;if(typeof cr=="string")try{cr=new S(cr,this.options)}catch{return!1}for(let Yt=0;Yt<this.set.length;Yt++)if(Tt(this.set[Yt],cr,this.options))return!0;return!1}};r.exports=a;var l=Yun(),d=new l,_=MGe(),g=B1e(),b=L1e(),S=Eb(),{safeRe:k,t:w,comparatorTrimReplace:N,tildeTrimReplace:P,caretTrimReplace:j}=ite(),{FLAG_INCLUDE_PRERELEASE:J,FLAG_LOOSE:X}=M1e(),G=Le=>Le.value==="<0.0.0-0",ee=Le=>Le.value==="",xe=(Le,cr)=>{let Yt=!0,Lr=Le.slice(),nn=Lr.pop();for(;Yt&&Lr.length;)Yt=Lr.every(on=>nn.intersects(on,cr)),nn=Lr.pop();return Yt},ue=(Le,cr)=>(b("comp",Le,cr),Le=ge(Le,cr),b("caret",Le),Le=se(Le,cr),b("tildes",Le),Le=tt(Le,cr),b("xrange",Le),Le=Ot(Le,cr),b("stars",Le),Le),fe=Le=>!Le||Le.toLowerCase()==="x"||Le==="*",se=(Le,cr)=>Le.trim().split(/\s+/).map(Yt=>de(Yt,cr)).join(" "),de=(Le,cr)=>{let Yt=cr.loose?k[w.TILDELOOSE]:k[w.TILDE];return Le.replace(Yt,(Lr,nn,on,gr,An)=>{b("tilde",Le,Lr,nn,on,gr,An);let Rn;return fe(nn)?Rn="":fe(on)?Rn=`>=${nn}.0.0 <${+nn+1}.0.0-0`:fe(gr)?Rn=`>=${nn}.${on}.0 <${nn}.${+on+1}.0-0`:An?(b("replaceTilde pr",An),Rn=`>=${nn}.${on}.${gr}-${An} <${nn}.${+on+1}.0-0`):Rn=`>=${nn}.${on}.${gr} <${nn}.${+on+1}.0-0`,b("tilde return",Rn),Rn})},ge=(Le,cr)=>Le.trim().split(/\s+/).map(Yt=>qe(Yt,cr)).join(" "),qe=(Le,cr)=>{b("caret",Le,cr);let Yt=cr.loose?k[w.CARETLOOSE]:k[w.CARET],Lr=cr.includePrerelease?"-0":"";return Le.replace(Yt,(nn,on,gr,An,Rn)=>{b("caret",Le,nn,on,gr,An,Rn);let ln;return fe(on)?ln="":fe(gr)?ln=`>=${on}.0.0${Lr} <${+on+1}.0.0-0`:fe(An)?on==="0"?ln=`>=${on}.${gr}.0${Lr} <${on}.${+gr+1}.0-0`:ln=`>=${on}.${gr}.0${Lr} <${+on+1}.0.0-0`:Rn?(b("replaceCaret pr",Rn),on==="0"?gr==="0"?ln=`>=${on}.${gr}.${An}-${Rn} <${on}.${gr}.${+An+1}-0`:ln=`>=${on}.${gr}.${An}-${Rn} <${on}.${+gr+1}.0-0`:ln=`>=${on}.${gr}.${An}-${Rn} <${+on+1}.0.0-0`):(b("no pr"),on==="0"?gr==="0"?ln=`>=${on}.${gr}.${An}${Lr} <${on}.${gr}.${+An+1}-0`:ln=`>=${on}.${gr}.${An}${Lr} <${on}.${+gr+1}.0-0`:ln=`>=${on}.${gr}.${An} <${+on+1}.0.0-0`),b("caret return",ln),ln})},tt=(Le,cr)=>(b("replaceXRanges",Le,cr),Le.split(/\s+/).map(Yt=>Ct(Yt,cr)).join(" ")),Ct=(Le,cr)=>{Le=Le.trim();let Yt=cr.loose?k[w.XRANGELOOSE]:k[w.XRANGE];return Le.replace(Yt,(Lr,nn,on,gr,An,Rn)=>{b("xRange",Le,Lr,nn,on,gr,An,Rn);let ln=fe(on),Mn=ln||fe(gr),Is=Mn||fe(An),Zs=Is;return nn==="="&&Zs&&(nn=""),Rn=cr.includePrerelease?"-0":"",ln?nn===">"||nn==="<"?Lr="<0.0.0-0":Lr="*":nn&&Zs?(Mn&&(gr=0),An=0,nn===">"?(nn=">=",Mn?(on=+on+1,gr=0,An=0):(gr=+gr+1,An=0)):nn==="<="&&(nn="<",Mn?on=+on+1:gr=+gr+1),nn==="<"&&(Rn="-0"),Lr=`${nn+on}.${gr}.${An}${Rn}`):Mn?Lr=`>=${on}.0.0${Rn} <${+on+1}.0.0-0`:Is&&(Lr=`>=${on}.${gr}.0${Rn} <${on}.${+gr+1}.0-0`),b("xRange return",Lr),Lr})},Ot=(Le,cr)=>(b("replaceStars",Le,cr),Le.trim().replace(k[w.STAR],"")),vt=(Le,cr)=>(b("replaceGTE0",Le,cr),Le.trim().replace(k[cr.includePrerelease?w.GTE0PRE:w.GTE0],"")),Et=Le=>(cr,Yt,Lr,nn,on,gr,An,Rn,ln,Mn,Is,Zs)=>(fe(Lr)?Yt="":fe(nn)?Yt=`>=${Lr}.0.0${Le?"-0":""}`:fe(on)?Yt=`>=${Lr}.${nn}.0${Le?"-0":""}`:gr?Yt=`>=${Yt}`:Yt=`>=${Yt}${Le?"-0":""}`,fe(ln)?Rn="":fe(Mn)?Rn=`<${+ln+1}.0.0-0`:fe(Is)?Rn=`<${ln}.${+Mn+1}.0-0`:Zs?Rn=`<=${ln}.${Mn}.${Is}-${Zs}`:Le?Rn=`<${ln}.${Mn}.${+Is+1}-0`:Rn=`<=${Rn}`,`${Yt} ${Rn}`.trim()),Tt=(Le,cr,Yt)=>{for(let Lr=0;Lr<Le.length;Lr++)if(!Le[Lr].test(cr))return!1;if(cr.prerelease.length&&!Yt.includePrerelease){for(let Lr=0;Lr<Le.length;Lr++)if(b(Le[Lr].semver),Le[Lr].semver!==g.ANY&&Le[Lr].semver.prerelease.length>0){let nn=Le[Lr].semver;if(nn.major===cr.major&&nn.minor===cr.minor&&nn.patch===cr.patch)return!0}return!1}return!0}}}),B1e=Ua({"../../node_modules/semver/classes/comparator.js"(t,r){var i=Symbol("SemVer ANY"),a=class YBe{static get ANY(){return i}constructor(N,P){if(P=l(P),N instanceof YBe){if(N.loose===!!P.loose)return N;N=N.value}N=N.trim().split(/\s+/).join(" "),b("comparator",N,P),this.options=P,this.loose=!!P.loose,this.parse(N),this.semver===i?this.value="":this.value=this.operator+this.semver.version,b("comp",this)}parse(N){let P=this.options.loose?d[_.COMPARATORLOOSE]:d[_.COMPARATOR],j=N.match(P);if(!j)throw new TypeError(`Invalid comparator: ${N}`);this.operator=j[1]!==void 0?j[1]:"",this.operator==="="&&(this.operator=""),j[2]?this.semver=new S(j[2],this.options.loose):this.semver=i}toString(){return this.value}test(N){if(b("Comparator.test",N,this.options.loose),this.semver===i||N===i)return!0;if(typeof N=="string")try{N=new S(N,this.options)}catch{return!1}return g(N,this.operator,this.semver,this.options)}intersects(N,P){if(!(N instanceof YBe))throw new TypeError("a Comparator is required");return this.operator===""?this.value===""?!0:new k(N.value,P).test(this.value):N.operator===""?N.value===""?!0:new k(this.value,P).test(N.semver):(P=l(P),P.includePrerelease&&(this.value==="<0.0.0-0"||N.value==="<0.0.0-0")||!P.includePrerelease&&(this.value.startsWith("<0.0.0")||N.value.startsWith("<0.0.0"))?!1:!!(this.operator.startsWith(">")&&N.operator.startsWith(">")||this.operator.startsWith("<")&&N.operator.startsWith("<")||this.semver.version===N.semver.version&&this.operator.includes("=")&&N.operator.includes("=")||g(this.semver,"<",N.semver,P)&&this.operator.startsWith(">")&&N.operator.startsWith("<")||g(this.semver,">",N.semver,P)&&this.operator.startsWith("<")&&N.operator.startsWith(">")))}};r.exports=a;var l=MGe(),{safeRe:d,t:_}=ite(),g=$Vt(),b=L1e(),S=Eb(),k=OE()}}),$1e=Ua({"../../node_modules/semver/functions/satisfies.js"(t,r){var i=OE(),a=(l,d,_)=>{try{d=new i(d,_)}catch{return!1}return d.test(l)};r.exports=a}}),Xun=Ua({"../../node_modules/semver/ranges/to-comparators.js"(t,r){var i=OE(),a=(l,d)=>new i(l,d).set.map(_=>_.map(g=>g.value).join(" ").trim().split(" "));r.exports=a}}),Zun=Ua({"../../node_modules/semver/ranges/max-satisfying.js"(t,r){var i=Eb(),a=OE(),l=(d,_,g)=>{let b=null,S=null,k=null;try{k=new a(_,g)}catch{return null}return d.forEach(w=>{k.test(w)&&(!b||S.compare(w)===-1)&&(b=w,S=new i(b,g))}),b};r.exports=l}}),efn=Ua({"../../node_modules/semver/ranges/min-satisfying.js"(t,r){var i=Eb(),a=OE(),l=(d,_,g)=>{let b=null,S=null,k=null;try{k=new a(_,g)}catch{return null}return d.forEach(w=>{k.test(w)&&(!b||S.compare(w)===1)&&(b=w,S=new i(b,g))}),b};r.exports=l}}),tfn=Ua({"../../node_modules/semver/ranges/min-version.js"(t,r){var i=Eb(),a=OE(),l=j1e(),d=(_,g)=>{_=new a(_,g);let b=new i("0.0.0");if(_.test(b)||(b=new i("0.0.0-0"),_.test(b)))return b;b=null;for(let S=0;S<_.set.length;++S){let k=_.set[S],w=null;k.forEach(N=>{let P=new i(N.semver.version);switch(N.operator){case">":P.prerelease.length===0?P.patch++:P.prerelease.push(0),P.raw=P.format();case"":case">=":(!w||l(P,w))&&(w=P);break;case"<":case"<=":break;default:throw new Error(`Unexpected operation: ${N.operator}`)}}),w&&(!b||l(b,w))&&(b=w)}return b&&_.test(b)?b:null};r.exports=d}}),rfn=Ua({"../../node_modules/semver/ranges/valid.js"(t,r){var i=OE(),a=(l,d)=>{try{return new i(l,d).range||"*"}catch{return null}};r.exports=a}}),qGe=Ua({"../../node_modules/semver/ranges/outside.js"(t,r){var i=Eb(),a=B1e(),{ANY:l}=a,d=OE(),_=$1e(),g=j1e(),b=jGe(),S=$Ge(),k=BGe(),w=(N,P,j,J)=>{N=new i(N,J),P=new d(P,J);let X,G,ee,xe,ue;switch(j){case">":X=g,G=S,ee=b,xe=">",ue=">=";break;case"<":X=b,G=k,ee=g,xe="<",ue="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"')}if(_(N,P,J))return!1;for(let fe=0;fe<P.set.length;++fe){let se=P.set[fe],de=null,ge=null;if(se.forEach(qe=>{qe.semver===l&&(qe=new a(">=0.0.0")),de=de||qe,ge=ge||qe,X(qe.semver,de.semver,J)?de=qe:ee(qe.semver,ge.semver,J)&&(ge=qe)}),de.operator===xe||de.operator===ue||(!ge.operator||ge.operator===xe)&&G(N,ge.semver)||ge.operator===ue&&ee(N,ge.semver))return!1}return!0};r.exports=w}}),nfn=Ua({"../../node_modules/semver/ranges/gtr.js"(t,r){var i=qGe(),a=(l,d,_)=>i(l,d,">",_);r.exports=a}}),ifn=Ua({"../../node_modules/semver/ranges/ltr.js"(t,r){var i=qGe(),a=(l,d,_)=>i(l,d,"<",_);r.exports=a}}),sfn=Ua({"../../node_modules/semver/ranges/intersects.js"(t,r){var i=OE(),a=(l,d,_)=>(l=new i(l,_),d=new i(d,_),l.intersects(d,_));r.exports=a}}),ofn=Ua({"../../node_modules/semver/ranges/simplify.js"(t,r){var i=$1e(),a=NE();r.exports=(l,d,_)=>{let g=[],b=null,S=null,k=l.sort((j,J)=>a(j,J,_));for(let j of k)i(j,d,_)?(S=j,b||(b=j)):(S&&g.push([b,S]),S=null,b=null);b&&g.push([b,null]);let w=[];for(let[j,J]of g)j===J?w.push(j):!J&&j===k[0]?w.push("*"):J?j===k[0]?w.push(`<=${J}`):w.push(`${j} - ${J}`):w.push(`>=${j}`);let N=w.join(" || "),P=typeof d.raw=="string"?d.raw:String(d);return N.length<P.length?N:d}}}),afn=Ua({"../../node_modules/semver/ranges/subset.js"(t,r){var i=OE(),a=B1e(),{ANY:l}=a,d=$1e(),_=NE(),g=(P,j,J={})=>{if(P===j)return!0;P=new i(P,J),j=new i(j,J);let X=!1;e:for(let G of P.set){for(let ee of j.set){let xe=k(G,ee,J);if(X=X||xe!==null,xe)continue e}if(X)return!1}return!0},b=[new a(">=0.0.0-0")],S=[new a(">=0.0.0")],k=(P,j,J)=>{if(P===j)return!0;if(P.length===1&&P[0].semver===l){if(j.length===1&&j[0].semver===l)return!0;J.includePrerelease?P=b:P=S}if(j.length===1&&j[0].semver===l){if(J.includePrerelease)return!0;j=S}let X=new Set,G,ee;for(let tt of P)tt.operator===">"||tt.operator===">="?G=w(G,tt,J):tt.operator==="<"||tt.operator==="<="?ee=N(ee,tt,J):X.add(tt.semver);if(X.size>1)return null;let xe;if(G&&ee&&(xe=_(G.semver,ee.semver,J),xe>0||xe===0&&(G.operator!==">="||ee.operator!=="<=")))return null;for(let tt of X){if(G&&!d(tt,String(G),J)||ee&&!d(tt,String(ee),J))return null;for(let Ct of j)if(!d(tt,String(Ct),J))return!1;return!0}let ue,fe,se,de,ge=ee&&!J.includePrerelease&&ee.semver.prerelease.length?ee.semver:!1,qe=G&&!J.includePrerelease&&G.semver.prerelease.length?G.semver:!1;ge&&ge.prerelease.length===1&&ee.operator==="<"&&ge.prerelease[0]===0&&(ge=!1);for(let tt of j){if(de=de||tt.operator===">"||tt.operator===">=",se=se||tt.operator==="<"||tt.operator==="<=",G){if(qe&&tt.semver.prerelease&&tt.semver.prerelease.length&&tt.semver.major===qe.major&&tt.semver.minor===qe.minor&&tt.semver.patch===qe.patch&&(qe=!1),tt.operator===">"||tt.operator===">="){if(ue=w(G,tt,J),ue===tt&&ue!==G)return!1}else if(G.operator===">="&&!d(G.semver,String(tt),J))return!1}if(ee){if(ge&&tt.semver.prerelease&&tt.semver.prerelease.length&&tt.semver.major===ge.major&&tt.semver.minor===ge.minor&&tt.semver.patch===ge.patch&&(ge=!1),tt.operator==="<"||tt.operator==="<="){if(fe=N(ee,tt,J),fe===tt&&fe!==ee)return!1}else if(ee.operator==="<="&&!d(ee.semver,String(tt),J))return!1}if(!tt.operator&&(ee||G)&&xe!==0)return!1}return!(G&&se&&!ee&&xe!==0||ee&&de&&!G&&xe!==0||qe||ge)},w=(P,j,J)=>{if(!P)return j;let X=_(P.semver,j.semver,J);return X>0?P:X<0||j.operator===">"&&P.operator===">="?j:P},N=(P,j,J)=>{if(!P)return j;let X=_(P.semver,j.semver,J);return X<0?P:X>0||j.operator==="<"&&P.operator==="<="?j:P};r.exports=g}}),cfn=Ua({"../../node_modules/semver/index.js"(t,r){var i=ite(),a=M1e(),l=Eb(),d=LVt(),_=kU(),g=jun(),b=Bun(),S=$un(),k=qun(),w=zun(),N=Uun(),P=Vun(),j=Jun(),J=NE(),X=Wun(),G=Hun(),ee=LGe(),xe=Gun(),ue=Qun(),fe=j1e(),se=jGe(),de=jVt(),ge=BVt(),qe=BGe(),tt=$Ge(),Ct=$Vt(),Ot=Kun(),vt=B1e(),Et=OE(),Tt=$1e(),Le=Xun(),cr=Zun(),Yt=efn(),Lr=tfn(),nn=rfn(),on=qGe(),gr=nfn(),An=ifn(),Rn=sfn(),ln=ofn(),Mn=afn();r.exports={parse:_,valid:g,clean:b,inc:S,diff:k,major:w,minor:N,patch:P,prerelease:j,compare:J,rcompare:X,compareLoose:G,compareBuild:ee,sort:xe,rsort:ue,gt:fe,lt:se,eq:de,neq:ge,gte:qe,lte:tt,cmp:Ct,coerce:Ot,Comparator:vt,Range:Et,satisfies:Tt,toComparators:Le,maxSatisfying:cr,minSatisfying:Yt,minVersion:Lr,validRange:nn,outside:on,gtr:gr,ltr:An,intersects:Rn,simplifyRange:ln,subset:Mn,SemVer:l,re:i.re,src:i.src,tokens:i.t,SEMVER_SPEC_VERSION:a.SEMVER_SPEC_VERSION,RELEASE_TYPES:a.RELEASE_TYPES,compareIdentifiers:d.compareIdentifiers,rcompareIdentifiers:d.rcompareIdentifiers}}}),qVt={};R1e(qVt,{applyDecorators:()=>RVt,beforeAll:()=>hfn,decorators:()=>_fn,mount:()=>pfn,parameters:()=>mfn,render:()=>ufn,renderToCanvas:()=>VVt});var wwt=TU(cfn());function Cwt(t){globalThis.IS_REACT_ACT_ENVIRONMENT=t}function lfn(){return globalThis.IS_REACT_ACT_ENVIRONMENT}var zVt=async({disableAct:t=!1}={})=>r=>r(),ufn=(t,r)=>{let{id:i,component:a}=r;if(!a)throw new Error(`Unable to render story ${i} as the component annotation is missing from the default export`);return fE.createElement(a,{...t})},{FRAMEWORK_OPTIONS:ffn}=na,dfn=class extends Xe.Component{constructor(){super(...arguments),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidMount(){let{hasError:t}=this.state,{showMain:r}=this.props;t||r()}componentDidCatch(t){let{showException:r}=this.props;r(t)}render(){let{hasError:t}=this.state,{children:r}=this.props;return t?null:r}},Ewt=ffn?.strictMode?Xe.StrictMode:Xe.Fragment,XBe=[],K7e=!1,UVt=async()=>{if(K7e||XBe.length===0)return;K7e=!0;let t=XBe.shift();t&&await t(),K7e=!1,UVt()};async function VVt({storyContext:t,unboundStoryFn:r,showMain:i,showException:a,forceRemount:l},d){let{renderElement:_,unmountElement:g}=await la(async()=>{const{renderElement:N,unmountElement:P}=await import("./react-18-DyywM-Z2.js");return{renderElement:N,unmountElement:P}},__vite__mapDeps([66,3,2,4,11,9])),b=r,S=t.parameters.__isPortableStory?fE.createElement(b,{...t}):fE.createElement(dfn,{key:t.id,showMain:i,showException:a},fE.createElement(b,{...t})),k=Ewt?fE.createElement(Ewt,null,S):S;l&&g(d);let w=await zVt({disableAct:t.viewMode==="docs"});return await new Promise(async(N,P)=>{XBe.push(async()=>{try{await w(async()=>{await _(k,d,t?.parameters?.react?.rootOptions)}),N()}catch(j){P(j)}}),UVt()}),async()=>{await w(()=>{g(d)})}}var pfn=t=>async r=>(r!=null&&(t.originalStoryFn=()=>r),await t.renderToCanvas(),t.canvas),_fn=[(t,r)=>{if(!r.parameters?.react?.rsc)return t();let i=wwt.default.major(Xe.version),a=wwt.default.minor(Xe.version);if(i<18||i===18&&a<3)throw new Error("React Server Components require React >= 18.3");return Xe.createElement(Xe.Suspense,null,t())}],mfn={renderer:"react"},hfn=async()=>{try{let{configure:t}=await la(async()=>{const{configure:i}=await Promise.resolve().then(()=>gan);return{configure:i}},void 0),r=await zVt();t({unstable_advanceTimersWrapper:i=>r(i),asyncWrapper:async i=>{let a=lfn();Cwt(!1);try{let l=await i();return await new Promise(d=>{setTimeout(()=>{d()},0),gfn()&&jest.advanceTimersByTime(0)}),l}finally{Cwt(a)}},eventWrapper:i=>{let a;return r(()=>(a=i(),a)),a}})}catch{}};function gfn(){return typeof jest<"u"&&jest!==null?setTimeout._isMockFunction===!0||Object.prototype.hasOwnProperty.call(setTimeout,"clock"):!1}var yfn=Ua({"../../node_modules/@base2/pretty-print-object/dist/index.js"(t){var r=t&&t.__assign||function(){return r=Object.assign||function(b){for(var S,k=1,w=arguments.length;k<w;k++){S=arguments[k];for(var N in S)Object.prototype.hasOwnProperty.call(S,N)&&(b[N]=S[N])}return b},r.apply(this,arguments)},i=t&&t.__spreadArrays||function(){for(var b=0,S=0,k=arguments.length;S<k;S++)b+=arguments[S].length;for(var w=Array(b),N=0,S=0;S<k;S++)for(var P=arguments[S],j=0,J=P.length;j<J;j++,N++)w[N]=P[j];return w};Object.defineProperty(t,"__esModule",{value:!0});var a=[];function l(b){var S=typeof b;return b!==null&&(S==="object"||S==="function")}function d(b){return Object.prototype.toString.call(b)==="[object RegExp]"}function _(b){return Object.getOwnPropertySymbols(b).filter(function(S){return Object.prototype.propertyIsEnumerable.call(b,S)})}function g(b,S,k){k===void 0&&(k="");var w={indent:" ",singleQuotes:!0},N=r(r({},w),S),P;N.inlineCharacterLimit===void 0?P={newLine:`
|
|
1544
|
+
`).replace(/^\n/,"")),d1.getElementById("error-message").innerHTML=Awt.toHtml(a),d1.getElementById("error-stack").innerHTML=Awt.toHtml(l),this.showMode("ERROR")}showNoPreview(){this.testing||(this.showMode("NOPREVIEW"),this.storyRoot()?.setAttribute("hidden","true"),this.docsRoot()?.setAttribute("hidden","true"))}showPreparingStory({immediate:r=!1}={}){clearTimeout(this.preparingTimeout),r?this.showMode("PREPARING_STORY"):this.preparingTimeout=setTimeout(()=>this.showMode("PREPARING_STORY"),bwt)}showPreparingDocs({immediate:r=!1}={}){clearTimeout(this.preparingTimeout),r?this.showMode("PREPARING_DOCS"):this.preparingTimeout=setTimeout(()=>this.showMode("PREPARING_DOCS"),bwt)}showMain(){this.showMode("MAIN")}showDocs(){this.storyRoot().setAttribute("hidden","true"),this.docsRoot().removeAttribute("hidden")}showStory(){this.docsRoot().setAttribute("hidden","true"),this.storyRoot().removeAttribute("hidden")}showStoryDuringRender(){d1.body.classList.add(H7e.MAIN)}};Cr(NVt,"WebView");var Eun=NVt,Tun=class extends hun{constructor(r,i){super(r,i,new xun,new Eun),this.importFn=r,this.getProjectAnnotations=i,na.__STORYBOOK_PREVIEW__=this}};Cr(Tun,"PreviewWeb");var{document:LR}=na,kun=["application/javascript","application/ecmascript","application/x-ecmascript","application/x-javascript","text/ecmascript","text/javascript","text/javascript1.0","text/javascript1.1","text/javascript1.2","text/javascript1.3","text/javascript1.4","text/javascript1.5","text/jscript","text/livescript","text/x-ecmascript","text/x-javascript","module"],Iun="script",Swt="scripts-root";function KBe(){let t=LR.createEvent("Event");t.initEvent("DOMContentLoaded",!0,!0),LR.dispatchEvent(t)}Cr(KBe,"simulateDOMContentLoaded");function OVt(t,r,i){let a=LR.createElement("script");a.type=t.type==="module"?"module":"text/javascript",t.src?(a.onload=r,a.onerror=r,a.src=t.src):a.textContent=t.innerText,i?i.appendChild(a):LR.head.appendChild(a),t.parentNode.removeChild(t),t.src||r()}Cr(OVt,"insertScript");function FGe(t,r,i=0){t[i](()=>{i++,i===t.length?r():FGe(t,r,i)})}Cr(FGe,"insertScriptsSequentially");function Dun(t){let r=LR.getElementById(Swt);r?r.innerHTML="":(r=LR.createElement("div"),r.id=Swt,LR.body.appendChild(r));let i=Array.from(t.querySelectorAll(Iun));if(i.length){let a=[];i.forEach(l=>{let d=l.getAttribute("type");(!d||kun.includes(d))&&a.push(_=>OVt(l,_,r))}),a.length&&FGe(a,KBe,void 0)}else KBe()}Cr(Dun,"simulatePageLoad");var Pun="storybook/docs",Nun=`${Pun}/snippet-rendered`;async function FVt(t,r){let i=r.parameters?.docs?.source?.transform,{id:a,unmappedArgs:l}=r,d=i&&t?i?.(t,r):t,_=d?await d:void 0;EE.getChannel().emit(Nun,{id:a,source:_,args:l})}Cr(FVt,"emitTransformCode");var RVt=(t,r)=>CGe(i=>fE.createElement(t,i),r),Oun=Object.create,F1e=Object.defineProperty,Fun=Object.getOwnPropertyDescriptor,RGe=Object.getOwnPropertyNames,Run=Object.getPrototypeOf,Mun=Object.prototype.hasOwnProperty,Lun=(t,r)=>function(){return t&&(r=(0,t[RGe(t)[0]])(t=0)),r},Ua=(t,r)=>function(){return r||(0,t[RGe(t)[0]])((r={exports:{}}).exports,r),r.exports},R1e=(t,r)=>{for(var i in r)F1e(t,i,{get:r[i],enumerable:!0})},MVt=(t,r,i,a)=>{if(r&&typeof r=="object"||typeof r=="function")for(let l of RGe(r))!Mun.call(t,l)&&l!==i&&F1e(t,l,{get:()=>r[l],enumerable:!(a=Fun(r,l))||a.enumerable});return t},TU=(t,r,i)=>(i=t!=null?Oun(Run(t)):{},MVt(!t||!t.__esModule?F1e(i,"default",{value:t,enumerable:!0}):i,t)),xwt=t=>MVt(F1e({},"__esModule",{value:!0}),t),Q7e={},M1e=Ua({"../../node_modules/semver/internal/constants.js"(t,r){var i="2.0.0",a=Number.MAX_SAFE_INTEGER||9007199254740991,l=16,d=250,_=["major","premajor","minor","preminor","patch","prepatch","prerelease"];r.exports={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:l,MAX_SAFE_BUILD_LENGTH:d,MAX_SAFE_INTEGER:a,RELEASE_TYPES:_,SEMVER_SPEC_VERSION:i,FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}}}),L1e=Ua({"../../node_modules/semver/internal/debug.js"(t,r){var i=typeof process=="object"&&Q7e&&Q7e.NODE_DEBUG&&/\bsemver\b/i.test(Q7e.NODE_DEBUG)?(...a)=>console.error("SEMVER",...a):()=>{};r.exports=i}}),ite=Ua({"../../node_modules/semver/internal/re.js"(t,r){var{MAX_SAFE_COMPONENT_LENGTH:i,MAX_SAFE_BUILD_LENGTH:a,MAX_LENGTH:l}=M1e(),d=L1e();t=r.exports={};var _=t.re=[],g=t.safeRe=[],b=t.src=[],S=t.safeSrc=[],k=t.t={},w=0,N="[a-zA-Z0-9-]",P=[["\\s",1],["\\d",l],[N,a]],j=X=>{for(let[G,ee]of P)X=X.split(`${G}*`).join(`${G}{0,${ee}}`).split(`${G}+`).join(`${G}{1,${ee}}`);return X},J=(X,G,ee)=>{let xe=j(G),ue=w++;d(X,ue,G),k[X]=ue,b[ue]=G,S[ue]=xe,_[ue]=new RegExp(G,ee?"g":void 0),g[ue]=new RegExp(xe,ee?"g":void 0)};J("NUMERICIDENTIFIER","0|[1-9]\\d*"),J("NUMERICIDENTIFIERLOOSE","\\d+"),J("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${N}*`),J("MAINVERSION",`(${b[k.NUMERICIDENTIFIER]})\\.(${b[k.NUMERICIDENTIFIER]})\\.(${b[k.NUMERICIDENTIFIER]})`),J("MAINVERSIONLOOSE",`(${b[k.NUMERICIDENTIFIERLOOSE]})\\.(${b[k.NUMERICIDENTIFIERLOOSE]})\\.(${b[k.NUMERICIDENTIFIERLOOSE]})`),J("PRERELEASEIDENTIFIER",`(?:${b[k.NONNUMERICIDENTIFIER]}|${b[k.NUMERICIDENTIFIER]})`),J("PRERELEASEIDENTIFIERLOOSE",`(?:${b[k.NONNUMERICIDENTIFIER]}|${b[k.NUMERICIDENTIFIERLOOSE]})`),J("PRERELEASE",`(?:-(${b[k.PRERELEASEIDENTIFIER]}(?:\\.${b[k.PRERELEASEIDENTIFIER]})*))`),J("PRERELEASELOOSE",`(?:-?(${b[k.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${b[k.PRERELEASEIDENTIFIERLOOSE]})*))`),J("BUILDIDENTIFIER",`${N}+`),J("BUILD",`(?:\\+(${b[k.BUILDIDENTIFIER]}(?:\\.${b[k.BUILDIDENTIFIER]})*))`),J("FULLPLAIN",`v?${b[k.MAINVERSION]}${b[k.PRERELEASE]}?${b[k.BUILD]}?`),J("FULL",`^${b[k.FULLPLAIN]}$`),J("LOOSEPLAIN",`[v=\\s]*${b[k.MAINVERSIONLOOSE]}${b[k.PRERELEASELOOSE]}?${b[k.BUILD]}?`),J("LOOSE",`^${b[k.LOOSEPLAIN]}$`),J("GTLT","((?:<|>)?=?)"),J("XRANGEIDENTIFIERLOOSE",`${b[k.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),J("XRANGEIDENTIFIER",`${b[k.NUMERICIDENTIFIER]}|x|X|\\*`),J("XRANGEPLAIN",`[v=\\s]*(${b[k.XRANGEIDENTIFIER]})(?:\\.(${b[k.XRANGEIDENTIFIER]})(?:\\.(${b[k.XRANGEIDENTIFIER]})(?:${b[k.PRERELEASE]})?${b[k.BUILD]}?)?)?`),J("XRANGEPLAINLOOSE",`[v=\\s]*(${b[k.XRANGEIDENTIFIERLOOSE]})(?:\\.(${b[k.XRANGEIDENTIFIERLOOSE]})(?:\\.(${b[k.XRANGEIDENTIFIERLOOSE]})(?:${b[k.PRERELEASELOOSE]})?${b[k.BUILD]}?)?)?`),J("XRANGE",`^${b[k.GTLT]}\\s*${b[k.XRANGEPLAIN]}$`),J("XRANGELOOSE",`^${b[k.GTLT]}\\s*${b[k.XRANGEPLAINLOOSE]}$`),J("COERCEPLAIN",`(^|[^\\d])(\\d{1,${i}})(?:\\.(\\d{1,${i}}))?(?:\\.(\\d{1,${i}}))?`),J("COERCE",`${b[k.COERCEPLAIN]}(?:$|[^\\d])`),J("COERCEFULL",b[k.COERCEPLAIN]+`(?:${b[k.PRERELEASE]})?(?:${b[k.BUILD]})?(?:$|[^\\d])`),J("COERCERTL",b[k.COERCE],!0),J("COERCERTLFULL",b[k.COERCEFULL],!0),J("LONETILDE","(?:~>?)"),J("TILDETRIM",`(\\s*)${b[k.LONETILDE]}\\s+`,!0),t.tildeTrimReplace="$1~",J("TILDE",`^${b[k.LONETILDE]}${b[k.XRANGEPLAIN]}$`),J("TILDELOOSE",`^${b[k.LONETILDE]}${b[k.XRANGEPLAINLOOSE]}$`),J("LONECARET","(?:\\^)"),J("CARETTRIM",`(\\s*)${b[k.LONECARET]}\\s+`,!0),t.caretTrimReplace="$1^",J("CARET",`^${b[k.LONECARET]}${b[k.XRANGEPLAIN]}$`),J("CARETLOOSE",`^${b[k.LONECARET]}${b[k.XRANGEPLAINLOOSE]}$`),J("COMPARATORLOOSE",`^${b[k.GTLT]}\\s*(${b[k.LOOSEPLAIN]})$|^$`),J("COMPARATOR",`^${b[k.GTLT]}\\s*(${b[k.FULLPLAIN]})$|^$`),J("COMPARATORTRIM",`(\\s*)${b[k.GTLT]}\\s*(${b[k.LOOSEPLAIN]}|${b[k.XRANGEPLAIN]})`,!0),t.comparatorTrimReplace="$1$2$3",J("HYPHENRANGE",`^\\s*(${b[k.XRANGEPLAIN]})\\s+-\\s+(${b[k.XRANGEPLAIN]})\\s*$`),J("HYPHENRANGELOOSE",`^\\s*(${b[k.XRANGEPLAINLOOSE]})\\s+-\\s+(${b[k.XRANGEPLAINLOOSE]})\\s*$`),J("STAR","(<|>)?=?\\s*\\*"),J("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$"),J("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")}}),MGe=Ua({"../../node_modules/semver/internal/parse-options.js"(t,r){var i=Object.freeze({loose:!0}),a=Object.freeze({}),l=d=>d?typeof d!="object"?i:d:a;r.exports=l}}),LVt=Ua({"../../node_modules/semver/internal/identifiers.js"(t,r){var i=/^[0-9]+$/,a=(d,_)=>{let g=i.test(d),b=i.test(_);return g&&b&&(d=+d,_=+_),d===_?0:g&&!b?-1:b&&!g?1:d<_?-1:1},l=(d,_)=>a(_,d);r.exports={compareIdentifiers:a,rcompareIdentifiers:l}}}),Eb=Ua({"../../node_modules/semver/classes/semver.js"(t,r){var i=L1e(),{MAX_LENGTH:a,MAX_SAFE_INTEGER:l}=M1e(),{safeRe:d,t:_}=ite(),g=MGe(),{compareIdentifiers:b}=LVt(),S=class Jk{constructor(w,N){if(N=g(N),w instanceof Jk){if(w.loose===!!N.loose&&w.includePrerelease===!!N.includePrerelease)return w;w=w.version}else if(typeof w!="string")throw new TypeError(`Invalid version. Must be a string. Got type "${typeof w}".`);if(w.length>a)throw new TypeError(`version is longer than ${a} characters`);i("SemVer",w,N),this.options=N,this.loose=!!N.loose,this.includePrerelease=!!N.includePrerelease;let P=w.trim().match(N.loose?d[_.LOOSE]:d[_.FULL]);if(!P)throw new TypeError(`Invalid Version: ${w}`);if(this.raw=w,this.major=+P[1],this.minor=+P[2],this.patch=+P[3],this.major>l||this.major<0)throw new TypeError("Invalid major version");if(this.minor>l||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>l||this.patch<0)throw new TypeError("Invalid patch version");P[4]?this.prerelease=P[4].split(".").map(j=>{if(/^[0-9]+$/.test(j)){let J=+j;if(J>=0&&J<l)return J}return j}):this.prerelease=[],this.build=P[5]?P[5].split("."):[],this.format()}format(){return this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length&&(this.version+=`-${this.prerelease.join(".")}`),this.version}toString(){return this.version}compare(w){if(i("SemVer.compare",this.version,this.options,w),!(w instanceof Jk)){if(typeof w=="string"&&w===this.version)return 0;w=new Jk(w,this.options)}return w.version===this.version?0:this.compareMain(w)||this.comparePre(w)}compareMain(w){return w instanceof Jk||(w=new Jk(w,this.options)),b(this.major,w.major)||b(this.minor,w.minor)||b(this.patch,w.patch)}comparePre(w){if(w instanceof Jk||(w=new Jk(w,this.options)),this.prerelease.length&&!w.prerelease.length)return-1;if(!this.prerelease.length&&w.prerelease.length)return 1;if(!this.prerelease.length&&!w.prerelease.length)return 0;let N=0;do{let P=this.prerelease[N],j=w.prerelease[N];if(i("prerelease compare",N,P,j),P===void 0&&j===void 0)return 0;if(j===void 0)return 1;if(P===void 0)return-1;if(P!==j)return b(P,j)}while(++N)}compareBuild(w){w instanceof Jk||(w=new Jk(w,this.options));let N=0;do{let P=this.build[N],j=w.build[N];if(i("build compare",N,P,j),P===void 0&&j===void 0)return 0;if(j===void 0)return 1;if(P===void 0)return-1;if(P!==j)return b(P,j)}while(++N)}inc(w,N,P){if(w.startsWith("pre")){if(!N&&P===!1)throw new Error("invalid increment argument: identifier is empty");if(N){let j=`-${N}`.match(this.options.loose?d[_.PRERELEASELOOSE]:d[_.PRERELEASE]);if(!j||j[1]!==N)throw new Error(`invalid identifier: ${N}`)}}switch(w){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",N,P);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",N,P);break;case"prepatch":this.prerelease.length=0,this.inc("patch",N,P),this.inc("pre",N,P);break;case"prerelease":this.prerelease.length===0&&this.inc("patch",N,P),this.inc("pre",N,P);break;case"release":if(this.prerelease.length===0)throw new Error(`version ${this.raw} is not a prerelease`);this.prerelease.length=0;break;case"major":(this.minor!==0||this.patch!==0||this.prerelease.length===0)&&this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":(this.patch!==0||this.prerelease.length===0)&&this.minor++,this.patch=0,this.prerelease=[];break;case"patch":this.prerelease.length===0&&this.patch++,this.prerelease=[];break;case"pre":{let j=Number(P)?1:0;if(this.prerelease.length===0)this.prerelease=[j];else{let J=this.prerelease.length;for(;--J>=0;)typeof this.prerelease[J]=="number"&&(this.prerelease[J]++,J=-2);if(J===-1){if(N===this.prerelease.join(".")&&P===!1)throw new Error("invalid increment argument: identifier already exists");this.prerelease.push(j)}}if(N){let J=[N,j];P===!1&&(J=[N]),b(this.prerelease[0],N)===0?isNaN(this.prerelease[1])&&(this.prerelease=J):this.prerelease=J}break}default:throw new Error(`invalid increment argument: ${w}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(".")}`),this}};r.exports=S}}),kU=Ua({"../../node_modules/semver/functions/parse.js"(t,r){var i=Eb(),a=(l,d,_=!1)=>{if(l instanceof i)return l;try{return new i(l,d)}catch(g){if(!_)return null;throw g}};r.exports=a}}),jun=Ua({"../../node_modules/semver/functions/valid.js"(t,r){var i=kU(),a=(l,d)=>{let _=i(l,d);return _?_.version:null};r.exports=a}}),Bun=Ua({"../../node_modules/semver/functions/clean.js"(t,r){var i=kU(),a=(l,d)=>{let _=i(l.trim().replace(/^[=v]+/,""),d);return _?_.version:null};r.exports=a}}),$un=Ua({"../../node_modules/semver/functions/inc.js"(t,r){var i=Eb(),a=(l,d,_,g,b)=>{typeof _=="string"&&(b=g,g=_,_=void 0);try{return new i(l instanceof i?l.version:l,_).inc(d,g,b).version}catch{return null}};r.exports=a}}),qun=Ua({"../../node_modules/semver/functions/diff.js"(t,r){var i=kU(),a=(l,d)=>{let _=i(l,null,!0),g=i(d,null,!0),b=_.compare(g);if(b===0)return null;let S=b>0,k=S?_:g,w=S?g:_,N=!!k.prerelease.length;if(w.prerelease.length&&!N){if(!w.patch&&!w.minor)return"major";if(w.compareMain(k)===0)return w.minor&&!w.patch?"minor":"patch"}let P=N?"pre":"";return _.major!==g.major?P+"major":_.minor!==g.minor?P+"minor":_.patch!==g.patch?P+"patch":"prerelease"};r.exports=a}}),zun=Ua({"../../node_modules/semver/functions/major.js"(t,r){var i=Eb(),a=(l,d)=>new i(l,d).major;r.exports=a}}),Uun=Ua({"../../node_modules/semver/functions/minor.js"(t,r){var i=Eb(),a=(l,d)=>new i(l,d).minor;r.exports=a}}),Vun=Ua({"../../node_modules/semver/functions/patch.js"(t,r){var i=Eb(),a=(l,d)=>new i(l,d).patch;r.exports=a}}),Jun=Ua({"../../node_modules/semver/functions/prerelease.js"(t,r){var i=kU(),a=(l,d)=>{let _=i(l,d);return _&&_.prerelease.length?_.prerelease:null};r.exports=a}}),NE=Ua({"../../node_modules/semver/functions/compare.js"(t,r){var i=Eb(),a=(l,d,_)=>new i(l,_).compare(new i(d,_));r.exports=a}}),Wun=Ua({"../../node_modules/semver/functions/rcompare.js"(t,r){var i=NE(),a=(l,d,_)=>i(d,l,_);r.exports=a}}),Hun=Ua({"../../node_modules/semver/functions/compare-loose.js"(t,r){var i=NE(),a=(l,d)=>i(l,d,!0);r.exports=a}}),LGe=Ua({"../../node_modules/semver/functions/compare-build.js"(t,r){var i=Eb(),a=(l,d,_)=>{let g=new i(l,_),b=new i(d,_);return g.compare(b)||g.compareBuild(b)};r.exports=a}}),Gun=Ua({"../../node_modules/semver/functions/sort.js"(t,r){var i=LGe(),a=(l,d)=>l.sort((_,g)=>i(_,g,d));r.exports=a}}),Qun=Ua({"../../node_modules/semver/functions/rsort.js"(t,r){var i=LGe(),a=(l,d)=>l.sort((_,g)=>i(g,_,d));r.exports=a}}),j1e=Ua({"../../node_modules/semver/functions/gt.js"(t,r){var i=NE(),a=(l,d,_)=>i(l,d,_)>0;r.exports=a}}),jGe=Ua({"../../node_modules/semver/functions/lt.js"(t,r){var i=NE(),a=(l,d,_)=>i(l,d,_)<0;r.exports=a}}),jVt=Ua({"../../node_modules/semver/functions/eq.js"(t,r){var i=NE(),a=(l,d,_)=>i(l,d,_)===0;r.exports=a}}),BVt=Ua({"../../node_modules/semver/functions/neq.js"(t,r){var i=NE(),a=(l,d,_)=>i(l,d,_)!==0;r.exports=a}}),BGe=Ua({"../../node_modules/semver/functions/gte.js"(t,r){var i=NE(),a=(l,d,_)=>i(l,d,_)>=0;r.exports=a}}),$Ge=Ua({"../../node_modules/semver/functions/lte.js"(t,r){var i=NE(),a=(l,d,_)=>i(l,d,_)<=0;r.exports=a}}),$Vt=Ua({"../../node_modules/semver/functions/cmp.js"(t,r){var i=jVt(),a=BVt(),l=j1e(),d=BGe(),_=jGe(),g=$Ge(),b=(S,k,w,N)=>{switch(k){case"===":return typeof S=="object"&&(S=S.version),typeof w=="object"&&(w=w.version),S===w;case"!==":return typeof S=="object"&&(S=S.version),typeof w=="object"&&(w=w.version),S!==w;case"":case"=":case"==":return i(S,w,N);case"!=":return a(S,w,N);case">":return l(S,w,N);case">=":return d(S,w,N);case"<":return _(S,w,N);case"<=":return g(S,w,N);default:throw new TypeError(`Invalid operator: ${k}`)}};r.exports=b}}),Kun=Ua({"../../node_modules/semver/functions/coerce.js"(t,r){var i=Eb(),a=kU(),{safeRe:l,t:d}=ite(),_=(g,b)=>{if(g instanceof i)return g;if(typeof g=="number"&&(g=String(g)),typeof g!="string")return null;b=b||{};let S=null;if(!b.rtl)S=g.match(b.includePrerelease?l[d.COERCEFULL]:l[d.COERCE]);else{let J=b.includePrerelease?l[d.COERCERTLFULL]:l[d.COERCERTL],X;for(;(X=J.exec(g))&&(!S||S.index+S[0].length!==g.length);)(!S||X.index+X[0].length!==S.index+S[0].length)&&(S=X),J.lastIndex=X.index+X[1].length+X[2].length;J.lastIndex=-1}if(S===null)return null;let k=S[2],w=S[3]||"0",N=S[4]||"0",P=b.includePrerelease&&S[5]?`-${S[5]}`:"",j=b.includePrerelease&&S[6]?`+${S[6]}`:"";return a(`${k}.${w}.${N}${P}${j}`,b)};r.exports=_}}),Yun=Ua({"../../node_modules/semver/internal/lrucache.js"(t,r){var i=class{constructor(){this.max=1e3,this.map=new Map}get(a){let l=this.map.get(a);if(l!==void 0)return this.map.delete(a),this.map.set(a,l),l}delete(a){return this.map.delete(a)}set(a,l){if(!this.delete(a)&&l!==void 0){if(this.map.size>=this.max){let d=this.map.keys().next().value;this.delete(d)}this.map.set(a,l)}return this}};r.exports=i}}),OE=Ua({"../../node_modules/semver/classes/range.js"(t,r){var i=/\s+/g,a=class Tme{constructor(cr,Yt){if(Yt=_(Yt),cr instanceof Tme)return cr.loose===!!Yt.loose&&cr.includePrerelease===!!Yt.includePrerelease?cr:new Tme(cr.raw,Yt);if(cr instanceof g)return this.raw=cr.value,this.set=[[cr]],this.formatted=void 0,this;if(this.options=Yt,this.loose=!!Yt.loose,this.includePrerelease=!!Yt.includePrerelease,this.raw=cr.trim().replace(i," "),this.set=this.raw.split("||").map(Lr=>this.parseRange(Lr.trim())).filter(Lr=>Lr.length),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){let Lr=this.set[0];if(this.set=this.set.filter(nn=>!G(nn[0])),this.set.length===0)this.set=[Lr];else if(this.set.length>1){for(let nn of this.set)if(nn.length===1&&ee(nn[0])){this.set=[nn];break}}}this.formatted=void 0}get range(){if(this.formatted===void 0){this.formatted="";for(let cr=0;cr<this.set.length;cr++){cr>0&&(this.formatted+="||");let Yt=this.set[cr];for(let Lr=0;Lr<Yt.length;Lr++)Lr>0&&(this.formatted+=" "),this.formatted+=Yt[Lr].toString().trim()}}return this.formatted}format(){return this.range}toString(){return this.range}parseRange(cr){let Yt=((this.options.includePrerelease&&J)|(this.options.loose&&X))+":"+cr,Lr=d.get(Yt);if(Lr)return Lr;let nn=this.options.loose,on=nn?k[w.HYPHENRANGELOOSE]:k[w.HYPHENRANGE];cr=cr.replace(on,Et(this.options.includePrerelease)),b("hyphen replace",cr),cr=cr.replace(k[w.COMPARATORTRIM],N),b("comparator trim",cr),cr=cr.replace(k[w.TILDETRIM],P),b("tilde trim",cr),cr=cr.replace(k[w.CARETTRIM],j),b("caret trim",cr);let gr=cr.split(" ").map(Mn=>ue(Mn,this.options)).join(" ").split(/\s+/).map(Mn=>vt(Mn,this.options));nn&&(gr=gr.filter(Mn=>(b("loose invalid filter",Mn,this.options),!!Mn.match(k[w.COMPARATORLOOSE])))),b("range list",gr);let An=new Map,Rn=gr.map(Mn=>new g(Mn,this.options));for(let Mn of Rn){if(G(Mn))return[Mn];An.set(Mn.value,Mn)}An.size>1&&An.has("")&&An.delete("");let ln=[...An.values()];return d.set(Yt,ln),ln}intersects(cr,Yt){if(!(cr instanceof Tme))throw new TypeError("a Range is required");return this.set.some(Lr=>xe(Lr,Yt)&&cr.set.some(nn=>xe(nn,Yt)&&Lr.every(on=>nn.every(gr=>on.intersects(gr,Yt)))))}test(cr){if(!cr)return!1;if(typeof cr=="string")try{cr=new S(cr,this.options)}catch{return!1}for(let Yt=0;Yt<this.set.length;Yt++)if(Tt(this.set[Yt],cr,this.options))return!0;return!1}};r.exports=a;var l=Yun(),d=new l,_=MGe(),g=B1e(),b=L1e(),S=Eb(),{safeRe:k,t:w,comparatorTrimReplace:N,tildeTrimReplace:P,caretTrimReplace:j}=ite(),{FLAG_INCLUDE_PRERELEASE:J,FLAG_LOOSE:X}=M1e(),G=Le=>Le.value==="<0.0.0-0",ee=Le=>Le.value==="",xe=(Le,cr)=>{let Yt=!0,Lr=Le.slice(),nn=Lr.pop();for(;Yt&&Lr.length;)Yt=Lr.every(on=>nn.intersects(on,cr)),nn=Lr.pop();return Yt},ue=(Le,cr)=>(b("comp",Le,cr),Le=ge(Le,cr),b("caret",Le),Le=se(Le,cr),b("tildes",Le),Le=tt(Le,cr),b("xrange",Le),Le=Ot(Le,cr),b("stars",Le),Le),fe=Le=>!Le||Le.toLowerCase()==="x"||Le==="*",se=(Le,cr)=>Le.trim().split(/\s+/).map(Yt=>de(Yt,cr)).join(" "),de=(Le,cr)=>{let Yt=cr.loose?k[w.TILDELOOSE]:k[w.TILDE];return Le.replace(Yt,(Lr,nn,on,gr,An)=>{b("tilde",Le,Lr,nn,on,gr,An);let Rn;return fe(nn)?Rn="":fe(on)?Rn=`>=${nn}.0.0 <${+nn+1}.0.0-0`:fe(gr)?Rn=`>=${nn}.${on}.0 <${nn}.${+on+1}.0-0`:An?(b("replaceTilde pr",An),Rn=`>=${nn}.${on}.${gr}-${An} <${nn}.${+on+1}.0-0`):Rn=`>=${nn}.${on}.${gr} <${nn}.${+on+1}.0-0`,b("tilde return",Rn),Rn})},ge=(Le,cr)=>Le.trim().split(/\s+/).map(Yt=>qe(Yt,cr)).join(" "),qe=(Le,cr)=>{b("caret",Le,cr);let Yt=cr.loose?k[w.CARETLOOSE]:k[w.CARET],Lr=cr.includePrerelease?"-0":"";return Le.replace(Yt,(nn,on,gr,An,Rn)=>{b("caret",Le,nn,on,gr,An,Rn);let ln;return fe(on)?ln="":fe(gr)?ln=`>=${on}.0.0${Lr} <${+on+1}.0.0-0`:fe(An)?on==="0"?ln=`>=${on}.${gr}.0${Lr} <${on}.${+gr+1}.0-0`:ln=`>=${on}.${gr}.0${Lr} <${+on+1}.0.0-0`:Rn?(b("replaceCaret pr",Rn),on==="0"?gr==="0"?ln=`>=${on}.${gr}.${An}-${Rn} <${on}.${gr}.${+An+1}-0`:ln=`>=${on}.${gr}.${An}-${Rn} <${on}.${+gr+1}.0-0`:ln=`>=${on}.${gr}.${An}-${Rn} <${+on+1}.0.0-0`):(b("no pr"),on==="0"?gr==="0"?ln=`>=${on}.${gr}.${An}${Lr} <${on}.${gr}.${+An+1}-0`:ln=`>=${on}.${gr}.${An}${Lr} <${on}.${+gr+1}.0-0`:ln=`>=${on}.${gr}.${An} <${+on+1}.0.0-0`),b("caret return",ln),ln})},tt=(Le,cr)=>(b("replaceXRanges",Le,cr),Le.split(/\s+/).map(Yt=>Ct(Yt,cr)).join(" ")),Ct=(Le,cr)=>{Le=Le.trim();let Yt=cr.loose?k[w.XRANGELOOSE]:k[w.XRANGE];return Le.replace(Yt,(Lr,nn,on,gr,An,Rn)=>{b("xRange",Le,Lr,nn,on,gr,An,Rn);let ln=fe(on),Mn=ln||fe(gr),Is=Mn||fe(An),Zs=Is;return nn==="="&&Zs&&(nn=""),Rn=cr.includePrerelease?"-0":"",ln?nn===">"||nn==="<"?Lr="<0.0.0-0":Lr="*":nn&&Zs?(Mn&&(gr=0),An=0,nn===">"?(nn=">=",Mn?(on=+on+1,gr=0,An=0):(gr=+gr+1,An=0)):nn==="<="&&(nn="<",Mn?on=+on+1:gr=+gr+1),nn==="<"&&(Rn="-0"),Lr=`${nn+on}.${gr}.${An}${Rn}`):Mn?Lr=`>=${on}.0.0${Rn} <${+on+1}.0.0-0`:Is&&(Lr=`>=${on}.${gr}.0${Rn} <${on}.${+gr+1}.0-0`),b("xRange return",Lr),Lr})},Ot=(Le,cr)=>(b("replaceStars",Le,cr),Le.trim().replace(k[w.STAR],"")),vt=(Le,cr)=>(b("replaceGTE0",Le,cr),Le.trim().replace(k[cr.includePrerelease?w.GTE0PRE:w.GTE0],"")),Et=Le=>(cr,Yt,Lr,nn,on,gr,An,Rn,ln,Mn,Is,Zs)=>(fe(Lr)?Yt="":fe(nn)?Yt=`>=${Lr}.0.0${Le?"-0":""}`:fe(on)?Yt=`>=${Lr}.${nn}.0${Le?"-0":""}`:gr?Yt=`>=${Yt}`:Yt=`>=${Yt}${Le?"-0":""}`,fe(ln)?Rn="":fe(Mn)?Rn=`<${+ln+1}.0.0-0`:fe(Is)?Rn=`<${ln}.${+Mn+1}.0-0`:Zs?Rn=`<=${ln}.${Mn}.${Is}-${Zs}`:Le?Rn=`<${ln}.${Mn}.${+Is+1}-0`:Rn=`<=${Rn}`,`${Yt} ${Rn}`.trim()),Tt=(Le,cr,Yt)=>{for(let Lr=0;Lr<Le.length;Lr++)if(!Le[Lr].test(cr))return!1;if(cr.prerelease.length&&!Yt.includePrerelease){for(let Lr=0;Lr<Le.length;Lr++)if(b(Le[Lr].semver),Le[Lr].semver!==g.ANY&&Le[Lr].semver.prerelease.length>0){let nn=Le[Lr].semver;if(nn.major===cr.major&&nn.minor===cr.minor&&nn.patch===cr.patch)return!0}return!1}return!0}}}),B1e=Ua({"../../node_modules/semver/classes/comparator.js"(t,r){var i=Symbol("SemVer ANY"),a=class YBe{static get ANY(){return i}constructor(N,P){if(P=l(P),N instanceof YBe){if(N.loose===!!P.loose)return N;N=N.value}N=N.trim().split(/\s+/).join(" "),b("comparator",N,P),this.options=P,this.loose=!!P.loose,this.parse(N),this.semver===i?this.value="":this.value=this.operator+this.semver.version,b("comp",this)}parse(N){let P=this.options.loose?d[_.COMPARATORLOOSE]:d[_.COMPARATOR],j=N.match(P);if(!j)throw new TypeError(`Invalid comparator: ${N}`);this.operator=j[1]!==void 0?j[1]:"",this.operator==="="&&(this.operator=""),j[2]?this.semver=new S(j[2],this.options.loose):this.semver=i}toString(){return this.value}test(N){if(b("Comparator.test",N,this.options.loose),this.semver===i||N===i)return!0;if(typeof N=="string")try{N=new S(N,this.options)}catch{return!1}return g(N,this.operator,this.semver,this.options)}intersects(N,P){if(!(N instanceof YBe))throw new TypeError("a Comparator is required");return this.operator===""?this.value===""?!0:new k(N.value,P).test(this.value):N.operator===""?N.value===""?!0:new k(this.value,P).test(N.semver):(P=l(P),P.includePrerelease&&(this.value==="<0.0.0-0"||N.value==="<0.0.0-0")||!P.includePrerelease&&(this.value.startsWith("<0.0.0")||N.value.startsWith("<0.0.0"))?!1:!!(this.operator.startsWith(">")&&N.operator.startsWith(">")||this.operator.startsWith("<")&&N.operator.startsWith("<")||this.semver.version===N.semver.version&&this.operator.includes("=")&&N.operator.includes("=")||g(this.semver,"<",N.semver,P)&&this.operator.startsWith(">")&&N.operator.startsWith("<")||g(this.semver,">",N.semver,P)&&this.operator.startsWith("<")&&N.operator.startsWith(">")))}};r.exports=a;var l=MGe(),{safeRe:d,t:_}=ite(),g=$Vt(),b=L1e(),S=Eb(),k=OE()}}),$1e=Ua({"../../node_modules/semver/functions/satisfies.js"(t,r){var i=OE(),a=(l,d,_)=>{try{d=new i(d,_)}catch{return!1}return d.test(l)};r.exports=a}}),Xun=Ua({"../../node_modules/semver/ranges/to-comparators.js"(t,r){var i=OE(),a=(l,d)=>new i(l,d).set.map(_=>_.map(g=>g.value).join(" ").trim().split(" "));r.exports=a}}),Zun=Ua({"../../node_modules/semver/ranges/max-satisfying.js"(t,r){var i=Eb(),a=OE(),l=(d,_,g)=>{let b=null,S=null,k=null;try{k=new a(_,g)}catch{return null}return d.forEach(w=>{k.test(w)&&(!b||S.compare(w)===-1)&&(b=w,S=new i(b,g))}),b};r.exports=l}}),efn=Ua({"../../node_modules/semver/ranges/min-satisfying.js"(t,r){var i=Eb(),a=OE(),l=(d,_,g)=>{let b=null,S=null,k=null;try{k=new a(_,g)}catch{return null}return d.forEach(w=>{k.test(w)&&(!b||S.compare(w)===1)&&(b=w,S=new i(b,g))}),b};r.exports=l}}),tfn=Ua({"../../node_modules/semver/ranges/min-version.js"(t,r){var i=Eb(),a=OE(),l=j1e(),d=(_,g)=>{_=new a(_,g);let b=new i("0.0.0");if(_.test(b)||(b=new i("0.0.0-0"),_.test(b)))return b;b=null;for(let S=0;S<_.set.length;++S){let k=_.set[S],w=null;k.forEach(N=>{let P=new i(N.semver.version);switch(N.operator){case">":P.prerelease.length===0?P.patch++:P.prerelease.push(0),P.raw=P.format();case"":case">=":(!w||l(P,w))&&(w=P);break;case"<":case"<=":break;default:throw new Error(`Unexpected operation: ${N.operator}`)}}),w&&(!b||l(b,w))&&(b=w)}return b&&_.test(b)?b:null};r.exports=d}}),rfn=Ua({"../../node_modules/semver/ranges/valid.js"(t,r){var i=OE(),a=(l,d)=>{try{return new i(l,d).range||"*"}catch{return null}};r.exports=a}}),qGe=Ua({"../../node_modules/semver/ranges/outside.js"(t,r){var i=Eb(),a=B1e(),{ANY:l}=a,d=OE(),_=$1e(),g=j1e(),b=jGe(),S=$Ge(),k=BGe(),w=(N,P,j,J)=>{N=new i(N,J),P=new d(P,J);let X,G,ee,xe,ue;switch(j){case">":X=g,G=S,ee=b,xe=">",ue=">=";break;case"<":X=b,G=k,ee=g,xe="<",ue="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"')}if(_(N,P,J))return!1;for(let fe=0;fe<P.set.length;++fe){let se=P.set[fe],de=null,ge=null;if(se.forEach(qe=>{qe.semver===l&&(qe=new a(">=0.0.0")),de=de||qe,ge=ge||qe,X(qe.semver,de.semver,J)?de=qe:ee(qe.semver,ge.semver,J)&&(ge=qe)}),de.operator===xe||de.operator===ue||(!ge.operator||ge.operator===xe)&&G(N,ge.semver)||ge.operator===ue&&ee(N,ge.semver))return!1}return!0};r.exports=w}}),nfn=Ua({"../../node_modules/semver/ranges/gtr.js"(t,r){var i=qGe(),a=(l,d,_)=>i(l,d,">",_);r.exports=a}}),ifn=Ua({"../../node_modules/semver/ranges/ltr.js"(t,r){var i=qGe(),a=(l,d,_)=>i(l,d,"<",_);r.exports=a}}),sfn=Ua({"../../node_modules/semver/ranges/intersects.js"(t,r){var i=OE(),a=(l,d,_)=>(l=new i(l,_),d=new i(d,_),l.intersects(d,_));r.exports=a}}),ofn=Ua({"../../node_modules/semver/ranges/simplify.js"(t,r){var i=$1e(),a=NE();r.exports=(l,d,_)=>{let g=[],b=null,S=null,k=l.sort((j,J)=>a(j,J,_));for(let j of k)i(j,d,_)?(S=j,b||(b=j)):(S&&g.push([b,S]),S=null,b=null);b&&g.push([b,null]);let w=[];for(let[j,J]of g)j===J?w.push(j):!J&&j===k[0]?w.push("*"):J?j===k[0]?w.push(`<=${J}`):w.push(`${j} - ${J}`):w.push(`>=${j}`);let N=w.join(" || "),P=typeof d.raw=="string"?d.raw:String(d);return N.length<P.length?N:d}}}),afn=Ua({"../../node_modules/semver/ranges/subset.js"(t,r){var i=OE(),a=B1e(),{ANY:l}=a,d=$1e(),_=NE(),g=(P,j,J={})=>{if(P===j)return!0;P=new i(P,J),j=new i(j,J);let X=!1;e:for(let G of P.set){for(let ee of j.set){let xe=k(G,ee,J);if(X=X||xe!==null,xe)continue e}if(X)return!1}return!0},b=[new a(">=0.0.0-0")],S=[new a(">=0.0.0")],k=(P,j,J)=>{if(P===j)return!0;if(P.length===1&&P[0].semver===l){if(j.length===1&&j[0].semver===l)return!0;J.includePrerelease?P=b:P=S}if(j.length===1&&j[0].semver===l){if(J.includePrerelease)return!0;j=S}let X=new Set,G,ee;for(let tt of P)tt.operator===">"||tt.operator===">="?G=w(G,tt,J):tt.operator==="<"||tt.operator==="<="?ee=N(ee,tt,J):X.add(tt.semver);if(X.size>1)return null;let xe;if(G&&ee&&(xe=_(G.semver,ee.semver,J),xe>0||xe===0&&(G.operator!==">="||ee.operator!=="<=")))return null;for(let tt of X){if(G&&!d(tt,String(G),J)||ee&&!d(tt,String(ee),J))return null;for(let Ct of j)if(!d(tt,String(Ct),J))return!1;return!0}let ue,fe,se,de,ge=ee&&!J.includePrerelease&&ee.semver.prerelease.length?ee.semver:!1,qe=G&&!J.includePrerelease&&G.semver.prerelease.length?G.semver:!1;ge&&ge.prerelease.length===1&&ee.operator==="<"&&ge.prerelease[0]===0&&(ge=!1);for(let tt of j){if(de=de||tt.operator===">"||tt.operator===">=",se=se||tt.operator==="<"||tt.operator==="<=",G){if(qe&&tt.semver.prerelease&&tt.semver.prerelease.length&&tt.semver.major===qe.major&&tt.semver.minor===qe.minor&&tt.semver.patch===qe.patch&&(qe=!1),tt.operator===">"||tt.operator===">="){if(ue=w(G,tt,J),ue===tt&&ue!==G)return!1}else if(G.operator===">="&&!d(G.semver,String(tt),J))return!1}if(ee){if(ge&&tt.semver.prerelease&&tt.semver.prerelease.length&&tt.semver.major===ge.major&&tt.semver.minor===ge.minor&&tt.semver.patch===ge.patch&&(ge=!1),tt.operator==="<"||tt.operator==="<="){if(fe=N(ee,tt,J),fe===tt&&fe!==ee)return!1}else if(ee.operator==="<="&&!d(ee.semver,String(tt),J))return!1}if(!tt.operator&&(ee||G)&&xe!==0)return!1}return!(G&&se&&!ee&&xe!==0||ee&&de&&!G&&xe!==0||qe||ge)},w=(P,j,J)=>{if(!P)return j;let X=_(P.semver,j.semver,J);return X>0?P:X<0||j.operator===">"&&P.operator===">="?j:P},N=(P,j,J)=>{if(!P)return j;let X=_(P.semver,j.semver,J);return X<0?P:X>0||j.operator==="<"&&P.operator==="<="?j:P};r.exports=g}}),cfn=Ua({"../../node_modules/semver/index.js"(t,r){var i=ite(),a=M1e(),l=Eb(),d=LVt(),_=kU(),g=jun(),b=Bun(),S=$un(),k=qun(),w=zun(),N=Uun(),P=Vun(),j=Jun(),J=NE(),X=Wun(),G=Hun(),ee=LGe(),xe=Gun(),ue=Qun(),fe=j1e(),se=jGe(),de=jVt(),ge=BVt(),qe=BGe(),tt=$Ge(),Ct=$Vt(),Ot=Kun(),vt=B1e(),Et=OE(),Tt=$1e(),Le=Xun(),cr=Zun(),Yt=efn(),Lr=tfn(),nn=rfn(),on=qGe(),gr=nfn(),An=ifn(),Rn=sfn(),ln=ofn(),Mn=afn();r.exports={parse:_,valid:g,clean:b,inc:S,diff:k,major:w,minor:N,patch:P,prerelease:j,compare:J,rcompare:X,compareLoose:G,compareBuild:ee,sort:xe,rsort:ue,gt:fe,lt:se,eq:de,neq:ge,gte:qe,lte:tt,cmp:Ct,coerce:Ot,Comparator:vt,Range:Et,satisfies:Tt,toComparators:Le,maxSatisfying:cr,minSatisfying:Yt,minVersion:Lr,validRange:nn,outside:on,gtr:gr,ltr:An,intersects:Rn,simplifyRange:ln,subset:Mn,SemVer:l,re:i.re,src:i.src,tokens:i.t,SEMVER_SPEC_VERSION:a.SEMVER_SPEC_VERSION,RELEASE_TYPES:a.RELEASE_TYPES,compareIdentifiers:d.compareIdentifiers,rcompareIdentifiers:d.rcompareIdentifiers}}}),qVt={};R1e(qVt,{applyDecorators:()=>RVt,beforeAll:()=>hfn,decorators:()=>_fn,mount:()=>pfn,parameters:()=>mfn,render:()=>ufn,renderToCanvas:()=>VVt});var wwt=TU(cfn());function Cwt(t){globalThis.IS_REACT_ACT_ENVIRONMENT=t}function lfn(){return globalThis.IS_REACT_ACT_ENVIRONMENT}var zVt=async({disableAct:t=!1}={})=>r=>r(),ufn=(t,r)=>{let{id:i,component:a}=r;if(!a)throw new Error(`Unable to render story ${i} as the component annotation is missing from the default export`);return fE.createElement(a,{...t})},{FRAMEWORK_OPTIONS:ffn}=na,dfn=class extends Xe.Component{constructor(){super(...arguments),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidMount(){let{hasError:t}=this.state,{showMain:r}=this.props;t||r()}componentDidCatch(t){let{showException:r}=this.props;r(t)}render(){let{hasError:t}=this.state,{children:r}=this.props;return t?null:r}},Ewt=ffn?.strictMode?Xe.StrictMode:Xe.Fragment,XBe=[],K7e=!1,UVt=async()=>{if(K7e||XBe.length===0)return;K7e=!0;let t=XBe.shift();t&&await t(),K7e=!1,UVt()};async function VVt({storyContext:t,unboundStoryFn:r,showMain:i,showException:a,forceRemount:l},d){let{renderElement:_,unmountElement:g}=await la(async()=>{const{renderElement:N,unmountElement:P}=await import("./react-18-DyywM-Z2.js");return{renderElement:N,unmountElement:P}},__vite__mapDeps([65,3,2,4,11,9])),b=r,S=t.parameters.__isPortableStory?fE.createElement(b,{...t}):fE.createElement(dfn,{key:t.id,showMain:i,showException:a},fE.createElement(b,{...t})),k=Ewt?fE.createElement(Ewt,null,S):S;l&&g(d);let w=await zVt({disableAct:t.viewMode==="docs"});return await new Promise(async(N,P)=>{XBe.push(async()=>{try{await w(async()=>{await _(k,d,t?.parameters?.react?.rootOptions)}),N()}catch(j){P(j)}}),UVt()}),async()=>{await w(()=>{g(d)})}}var pfn=t=>async r=>(r!=null&&(t.originalStoryFn=()=>r),await t.renderToCanvas(),t.canvas),_fn=[(t,r)=>{if(!r.parameters?.react?.rsc)return t();let i=wwt.default.major(Xe.version),a=wwt.default.minor(Xe.version);if(i<18||i===18&&a<3)throw new Error("React Server Components require React >= 18.3");return Xe.createElement(Xe.Suspense,null,t())}],mfn={renderer:"react"},hfn=async()=>{try{let{configure:t}=await la(async()=>{const{configure:i}=await Promise.resolve().then(()=>gan);return{configure:i}},void 0),r=await zVt();t({unstable_advanceTimersWrapper:i=>r(i),asyncWrapper:async i=>{let a=lfn();Cwt(!1);try{let l=await i();return await new Promise(d=>{setTimeout(()=>{d()},0),gfn()&&jest.advanceTimersByTime(0)}),l}finally{Cwt(a)}},eventWrapper:i=>{let a;return r(()=>(a=i(),a)),a}})}catch{}};function gfn(){return typeof jest<"u"&&jest!==null?setTimeout._isMockFunction===!0||Object.prototype.hasOwnProperty.call(setTimeout,"clock"):!1}var yfn=Ua({"../../node_modules/@base2/pretty-print-object/dist/index.js"(t){var r=t&&t.__assign||function(){return r=Object.assign||function(b){for(var S,k=1,w=arguments.length;k<w;k++){S=arguments[k];for(var N in S)Object.prototype.hasOwnProperty.call(S,N)&&(b[N]=S[N])}return b},r.apply(this,arguments)},i=t&&t.__spreadArrays||function(){for(var b=0,S=0,k=arguments.length;S<k;S++)b+=arguments[S].length;for(var w=Array(b),N=0,S=0;S<k;S++)for(var P=arguments[S],j=0,J=P.length;j<J;j++,N++)w[N]=P[j];return w};Object.defineProperty(t,"__esModule",{value:!0});var a=[];function l(b){var S=typeof b;return b!==null&&(S==="object"||S==="function")}function d(b){return Object.prototype.toString.call(b)==="[object RegExp]"}function _(b){return Object.getOwnPropertySymbols(b).filter(function(S){return Object.prototype.propertyIsEnumerable.call(b,S)})}function g(b,S,k){k===void 0&&(k="");var w={indent:" ",singleQuotes:!0},N=r(r({},w),S),P;N.inlineCharacterLimit===void 0?P={newLine:`
|
|
1545
1545
|
`,newLineOrSpace:`
|
|
1546
1546
|
`,pad:k,indent:k+N.indent}:P={newLine:"@@__PRETTY_PRINT_NEW_LINE__@@",newLineOrSpace:"@@__PRETTY_PRINT_NEW_LINE_OR_SPACE__@@",pad:"@@__PRETTY_PRINT_PAD__@@",indent:"@@__PRETTY_PRINT_INDENT__@@"};var j=function(G){if(N.inlineCharacterLimit===void 0)return G;var ee=G.replace(new RegExp(P.newLine,"g"),"").replace(new RegExp(P.newLineOrSpace,"g")," ").replace(new RegExp(P.pad+"|"+P.indent,"g"),"");return ee.length<=N.inlineCharacterLimit?ee:G.replace(new RegExp(P.newLine+"|"+P.newLineOrSpace,"g"),`
|
|
1547
1547
|
`).replace(new RegExp(P.pad,"g"),k).replace(new RegExp(P.indent,"g"),k+N.indent)};if(a.indexOf(b)!==-1)return'"[Circular]"';if(b==null||typeof b=="number"||typeof b=="boolean"||typeof b=="function"||typeof b=="symbol"||d(b))return String(b);if(b instanceof Date)return"new Date('"+b.toISOString()+"')";if(Array.isArray(b)){if(b.length===0)return"[]";a.push(b);var J="["+P.newLine+b.map(function(G,ee){var xe=b.length-1===ee?P.newLine:","+P.newLineOrSpace,ue=g(G,N,k+N.indent);return N.transform&&(ue=N.transform(b,ee,ue)),P.indent+ue+xe}).join("")+P.pad+"]";return a.pop(),j(J)}if(l(b)){var X=i(Object.keys(b),_(b));if(N.filter&&(X=X.filter(function(ee){return N.filter&&N.filter(b,ee)})),X.length===0)return"{}";a.push(b);var J="{"+P.newLine+X.map(function(ee,xe){var ue=X.length-1===xe?P.newLine:","+P.newLineOrSpace,fe=typeof ee=="symbol",se=!fe&&/^[a-z$_][a-z$_0-9]*$/i.test(ee.toString()),de=fe||se?ee:g(ee,N),ge=g(b[ee],N,k+N.indent);return N.transform&&(ge=N.transform(b,ee,ge)),P.indent+String(de)+": "+ge+ue}).join("")+P.pad+"}";return a.pop(),j(J)}return b=String(b).replace(/[\r\n]/g,function(G){return G===`
|
|
@@ -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,"() => {}")},I_n={skip:0,showFunctions:!1,enableBeautify:!0,showDefaultProps:!1},D_n=t=>{let r=t?.parameters.docs?.source,i=t?.parameters.__isArgsStory;return r?.type===n$e.DYNAMIC?!1:!i||r?.code||r?.type===n$e.CODE},P_n=t=>t.type?.displayName==="MDXCreateElement"&&!!t.props?.mdxType,AWt=t=>{if(!P_n(t))return t;let{mdxType:r,originalType:i,children:a,...l}=t.props,d=[];return a&&(d=(Array.isArray(a)?a:[a]).map(AWt)),Xe.createElement(i,l,...d)},SWt=(t,r)=>{let i=OUt(void 0),a=t(),l=D_n(r),d={...I_n,...r?.parameters.jsx||{}},_=r.originalStoryFn(r.args,r);return $8(()=>{if(l)return;let g=AWt(_),b=k_n(g,d);b&&i.current!==b&&(FVt(b,r),i.current=b)}),a},N_n=(t,r)=>{let i=r.findIndex(l=>l.originalFn===SWt),a=i===-1?r:[...r.splice(i,1),...r];return RVt(t,a)},O_n=[SWt],F_n={docs:{story:{inline:!0}}},{window:nCt}=na;nCt&&(nCt.STORYBOOK_ENV="react");function R_n(t){return oVt(xWt),cVt(t)}var xWt=i9([qVt,aWt,{renderToCanvas:async(t,r)=>{if(t.storyContext.testingLibraryRender==null)return VVt(t,r);let{storyContext:{context:i,unboundStoryFn:a,testingLibraryRender:l}}=t,{unmount:d}=l(Xe.createElement(a,{...i}),{container:i.canvasElement});return d}}]);function M_n(t,r,i,a){return OGe(t,r,i,globalThis.globalProjectAnnotations??xWt,a)}function L_n(t,r){return lVt(t,r,M_n)}let SY=null;function j_n(){if(!SY){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 SY===t&&(SY=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})});SY=t}return SY}const B_n={packaged:!1,composeStories:L_n,setProjectAnnotations:R_n,createRoot:Vqe.createRoot,flushSync:vS.flushSync};let yRe=null;async function $_n(){let t;try{t=await import(_Mr)}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 wWt(){return await j_n()?(yRe||(yRe=$_n()),yRe):B_n}let iCt=null;function CWt(t){return iCt??=wWt().then(r=>{r.setProjectAnnotations(t??[])}),iCt}function q_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 z_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 wWt()).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,_=q_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 EWt=[];function sQe(){return EWt}function U_n(t){EWt=t}function V_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 sCt(t){return t.replaceAll("\\","/").replace(/^\.\//,"").replace(/^\//,"")}function oCt(t,r){const i=sCt(t);return r.some(a=>V_n(sCt(a)).test(i))}function J_n(t,r){if(t===void 0)return;const i=[];for(const a of r){a.include!==void 0&&oCt(t,a.include)&&i.push({surface:a.surface,regionId:a.id});for(const l of a.mounts??[])oCt(t,l.include)&&i.push({surface:l.surface,regionId:a.id})}return i.length===1?i[0]:void 0}function W_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 H_n(t){const r=t.regions??[],i=J_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?[...W_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 eee(t){return t.replaceAll("\\","/").replace(/^\.\//,"").replace(/^\//,"")}function G_n(t){const r=new Map;for(const i of t)i.entry&&r.set(eee(i.entry),i);return i=>r.get(eee(i))}function Q_n(t,r){const i=eee(t);return H_n({file:i,projectRelative:i,regions:r,regionOfEntry:G_n(r)})}function K_n(t){return t==="three"||t==="canvas"||t==="dom"?t:void 0}function Y_n(t){if(t.via==="declared-include")return"declared-include";if(t.via==="root-entry")return"root-entry"}function oQe(t){const r=t.regions??[],i=t.modulePath?eee(t.modulePath):"";if(!i)return{via:"undeclared",reason:"story has no module path"};const a=Q_n(i,r),l=K_n(a.surface),d=Y_n(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 y$e=new Set;function X_n(t,r){const i=eee(t);y$e.has(i)||(y$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 Z_n(){y$e.clear()}const emn=/\.stories\.[jt]sx?$/i;function vRe(t){const{root:r,groups:i}=Ucn(t,{rootSeparator:"|",groupSeparator:"/"});return[...r?[r]:[],...i].map(a=>a.trim()).filter(Boolean)}function tmn(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:emn}}function TWt(t){const r=t.modulePath.replaceAll("\\","/").replace(/^\.\//,""),i=t.title&&vRe(t.title).length>0?t.title:void 0,a=aun(r,tmn(r),i),l=a?vRe(a):i?vRe(i):[r];return{segments:l.slice(0,-1),leaf:l.at(-1)??t.modulePath}}function rmn(t){return[...t.segments,t.leaf].join("/")}async function kWt(){try{const t=await fetch("/__editor/story-files"),r=await Eg(t,"Scanning this project for stories failed");return Array.isArray(r.regions)&&U_n(r.regions),r}catch(t){t instanceof Error?t.message:String(t);return}}async function IWt(t){if(!t)return[];const r=await kWt();return r?r.files.map(({path:i})=>({modulePath:i,load:()=>la(()=>import(`/@fs/${t.rootPath}/${i}?t=${Date.now()}`),[])})):[]}async function DWt(t){if(!t)return;const i=(await kWt())?.previewModulePath;if(i)try{return await la(()=>import(`/@fs/${t.rootPath}/${i}?t=${Date.now()}`),[])}catch{return}}let v8=[],Jz=!1,tee=0,aCt=null;const uX=new Map,dye=new Set;function PWt(){const t=hh();aCt!==t&&(aCt=t,tee++,uX.clear(),pye([],!1))}function H1e(){return v8}function nmn(){return Jz}function G1e(t){return dye.add(t),()=>dye.delete(t)}function imn(){return Jz?Promise.resolve():new Promise(t=>{const r=G1e(()=>{Jz&&(r(),t())})})}function smn(t){const r=t.parameters.vgai;return r&&typeof r=="object"?r:null}function DPn(){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??rmn(TWt({modulePath:l.modulePath})),importPath:l.modulePath,tags:[...l.tags??[]]}));return uun(a,r,[...new Set(t.map(l=>l.modulePath))]).map(l=>i.get(l.id)).filter(l=>l!==void 0)}function NWt(t){const r=smn(t);return r?r.default===!0?!0:typeof r.defaultStory=="string"&&r.defaultStory===t.name:!1}function cCt(t){const r=t.replaceAll("\\","/").replace(/^\.\//,""),i=r.lastIndexOf("/");return i>=0?r.slice(0,i):""}function omn(t,r,i){const a=OWt(t,r,i);return a.find(NWt)??a[0]??null}function OWt(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=>cCt(d.modulePath)===cCt(i)):[];return l.length>0?l:a}function amn(t,r){return OWt(v8,t,r)}function pye(t,r){v8=t,Jz=r;for(const i of dye)i()}async function v$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 z_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 cmn(t,r){PWt();const i=hh(),a=`${i}
|
|
1597
1597
|
${r}`,l=uX.get(a);if(l)return l;const d=lmn(t,i,r).finally(()=>{uX.get(a)===d&&uX.delete(a)});return uX.set(a,d),d}async function lmn(t,r,i){for(;hh()===r;){const a=v8.find(w=>w.modulePath===i);if(a?.ok)return;const l=tee,d=()=>hh()===r&&l===tee,_=await DWt(t);if(!d()||(await CWt(_),!d()))continue;const g=await IWt(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 v$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(pye([...v8.filter(w=>w.modulePath!==i),S],Jz),!S.ok)throw new Error(S.error);return}throw new Error(`Project changed while opening story: ${i}`)}async function umn(){await Promise.race([e0e(),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 fmn(t,r,i={}){PWt();const a=++tee,l=hh(),d=()=>a===tee&&l===hh(),_=async Ot=>{if(!i.changedPaths)return Promise.all(Ot.map(v$e));const vt=[];for(const Et of Ot)if(vt.push(await v$e(Et)),await new Promise(Tt=>setTimeout(Tt,16)),!d())break;return vt};Jz=!1;for(const Ot of dye)Ot();const g=Date.now(),b=Date.now(),S=await DWt(t);if(!d())return;const k=Date.now()-b,w=Date.now();if(await CWt(S),!d())return;const N=Date.now()-w,P=Date.now(),j=await IWt(t);if(!d())return;const J=Date.now()-P,X=sQe(),G=i.deferUndeclared?j.filter(({modulePath:Ot})=>oQe({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(pye(j.map(({modulePath:Ot})=>ge.get(Ot)).filter(Ot=>Ot!==void 0),G.length===0),GOr({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 umn(),!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);pye(Ct,!0)}function dmn(){const t=[];for(const r of H1e())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:NWt(i)});return t}const pmn={name:"prefabsFromStories",schema:Na({finder:Ry("prefabsFromStories")}).strict(),run(t,r){return eVr(t,{stories:dmn(),...r.components===void 0?{}:{components:r.components}})}},Hq="vgai.adapter.ts";let JX=null,b$e=null,aQe="__unscoped__",FWt=0;const ree=new Set;function wb(){return aQe===hh()?JX:null}function cQe(){const t=()=>!ad()||!!wb();return t()?Promise.resolve():new Promise(r=>{const i=YP(()=>{t()&&(i(),r())})})}function YP(t){return ree.add(t),()=>ree.delete(t)}function Ome(t,r=[],i=void 0,a=null){aQe=hh(),JX=t,b$e=a,p7r(a?.editor),VUr(t?.regions??[]);for(const l of ree)l();M7r()}function _mn(t){return{id:t.id,kind:t.kind,answered:t.answer!==void 0}}function mmn(t){const{Layout:r,...i}=t;return{...i,...r?{layout:r.displayName??r.name??"Project layout"}:{}}}async function hmn(t){return await import(`${UNt(t,Hq)}?t=${Date.now()}`)}function gmn(t,r){return t.find(i=>i.surface===r)?.id??null}function ymn(t){const r=new Set(t.map(i=>i.path));return(i,a)=>YUr(i,a,r)}function vmn(t){const r=EUr(t);return r.length===1?r[0].id:null}const bmn={entrypoints:[],components:[]};async function Amn(t,r,i){const a=[];for(const S of TX(t))S.entry&&a.push({regionId:S.id,path:S.entry,source:await nge(S.entry)});let l=[];const d=await hNt().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:gmn(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 bNt([..._],{order:"mtime"}).catch(()=>[]);for(const k of S){b.push(k);const w=await nge(k);w!==null&&!w.includes("\0")&&g.push({path:k,source:w})}}return{entrypoints:a,components:l,sources:g,files:b,resolveModule:ymn(l)}}function Smn(t,r){const i=[...t.documents.entries??[]],a=[],l=[];let d=0;for(const g of t.documents.find??[]){let b;try{b=SUr(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 RWt=[];function lCt(t){for(const r of RWt){const i=r.modulePathFor(t);if(i!==null)return{source:r,modulePath:i}}return null}function uCt(t){return t!==null&&typeof t=="object"&&"default"in t?t.default:t}function V$(t,r){if(t.kind==="present")try{return{definition:Y2t(uCt(t.module)),source:"project",modulePath:Hq,error:null}}catch(a){return{definition:B$(),source:"native",modulePath:null,error:`${Hq} did not load — ${nee(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:Y2t(uCt(r.module)),source:"registry",modulePath:r.path,error:i}}catch(a){return{definition:B$(),source:"native",modulePath:null,error:`${r.path} did not load — ${nee(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 xmn(t,r,i){const{definition:a,source:l,modulePath:d,error:_}=r,g=a.regions==="manifest-roots"?NNt(TX(t),a.regionIncludes):[...a.regions],b=qzr(TX(t),a.regionIncludes),{table:S,notes:k,unresolved:w}=Smn(a,i);return{source:l,modulePath:d,regions:g,scenes:S,documentsPending:w>0,...a.editor?{editor:mmn(a.editor)}:{},observation:a.observation.map(_mn),notes:b.length>0?[...k,`adapter: regionIncludes names ${b.map(N=>`\`${N}\``).join(", ")}, which no root in vgai.project.json declares (roots: ${TX(t).map(N=>`\`${N.id}\``).join(", ")}) — those globs were merged onto nothing.`]:k,error:_}}async function wmn(t,r){const i=vmn(r),a=await vNt(Hq);if(a==="present")try{const _=await hmn(t.rootPath);return V$({kind:"present",module:_},{kind:"absent"})}catch(_){return V$({kind:"broken",error:nee(_)},{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=lCt(i);if(d===null&&(await Cmn(i),d=lCt(i)),d===null){const _=V$(l,{kind:"unanswered",rootId:i,sources:RWt.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:nee(_)})}}let fCt=null,l_e=null,A$e=null;function dCt(){return A$e}function Cmn(t){const r=hh();if(fCt!==r&&(fCt=r,l_e=null),!l_e){A$e=`Loading the ingest lane — this project declares the unmodified-game root “${t}”, whose adapter declaration a package supplies.`;for(const i of ree)i();l_e=WR().catch(()=>{}).finally(()=>{A$e=null;for(const i of ree)i()})}return l_e}let bRe=[],S$e="";function Emn(){const t=aUe(),r=t.map(i=>i.entryPath).join("|");if(!(r===S$e&&t.every(i=>Fme.has(i.module)))){for(const i of bRe)i();bRe=[],Fme=new WeakSet;for(const{entryPath:i,module:a}of t)try{bRe.push(RNt(a?.finder,i)),Fme.add(a)}catch(l){ua.error(l instanceof Error?l.message:String(l),"project")}S$e=r}}let Fme=new WeakSet;RNt(pmn,"packages/editor/src/stories/prefabs-finder.ts");jA(()=>{const t=aUe();(t.map(i=>i.entryPath).join("|")!==S$e||!t.every(i=>Fme.has(i.module)))&&ad()&&WX()});j7r(()=>JX&&!JX.documentsPending?[...new Set(JX.scenes.entries.map(t=>t.kind))]:null);function WX(){const t=Tmn(++FWt,ad());return t.then(()=>{}),t}async function Tmn(t,r){const i=()=>t===FWt&&ad()===r;if(!r){Ome(null);return}let a;try{a=await UUr()}catch(b){if(!i())return;Ome({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 — ${nee(b)}`});return}if(!i())return;const l=await wmn(r,a);if(!i())return;Emn();const d=l.definition.regions==="manifest-roots"?NNt(TX(a),l.definition.regionIncludes):[...l.definition.regions],_=(l.definition.documents.find??[]).length>0?await Amn(a,d,l.definition):bmn;if(!i())return;const g=xmn(a,l,_);Ome(g,l.definition.observation,l.definition.input,l.source==="native"?null:l.definition)}function nee(t){return t instanceof Error?t.message:String(t)}function kmn(t){if(!b$e)return!0;const r=b$e.documents.find??[];for(const i of r)for(const a of i.include??[])if(Imn(a).test(t))return!0;return!1}function Imn(t){const r="__DEEP__",i=t.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*\*\//g,r).replace(/\*/g,"[^/]*").split(r).join("(?:.*/)?");return new RegExp(`^${i}$`)}function Dmn(){WX();const t=KNt(),r=Iw(()=>{aQe!==hh()&&Ome(null),WX()}),i=PUr(a=>{(a===""||kmn(a))&&WX()});return()=>{t(),r(),i()}}const Pmn="scene:";function pCt(t){return`${Pmn}${t}`}function xY(t){const{kind:r}=t.reach;return r==="game-contract"||r==="root-mount"||r==="entrypoint-selection"?{liveReach:r}:{}}function MWt(t){if(!t.authorable)return{kind:"no-document",...xY(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",...xY(t),reason:t.reach.reason};case"root-mount":return t.region===null?{kind:"no-document",...xY(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:pCt(t.id),title:t.label,regionId:t.region,source:t.source,...t.isolationSetup?{isolationSetup:t.isolationSetup}:{}}:{kind:"no-document",...xY(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:pCt(t.id),title:t.label,regionId:t.region,source:t.source,...t.isolationSetup?{isolationSetup:t.isolationSetup}:{},contractSceneId:t.reach.sceneId}:{kind:"no-document",...xY(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 Nmn(t){const r=[];for(const i of t.entries){if(i.kind!=="scene")continue;const a=MWt(i);a.kind!=="no-document"&&r.push({entry:i,plan:a,isDefault:t.default===i.id})}return r}let mE=[];const x$e=new Set,iee=new Map;let lQe=!1,uQe=!1,w$e=!1;function Omn(t,r=!0){iee.set(t,r),_ye()}const fQe=()=>{for(const t of x$e)t()},dQe=()=>mE;function Fmn(t){return x$e.add(t),()=>{x$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 _ye(){for(const[t,r]of iee)s9(t,r)&&iee.delete(t);if(lQe&&!uQe&&!w$e){const t=mE.find(r=>r.default);t&&(w$e=!0,s9(t.descriptor.id))}}function PPn(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],fQe(),_ye(),t.id}function NPn(t){mE.some(r=>r.descriptor.id===t)&&(mE=mE.filter(r=>r.descriptor.id!==t),K8(t,{discardDirty:!0}),fQe())}for(const t of KOr)kee({kind:t,owner:"workspace-available-documents",restore:({state:r,active:i})=>{const a=r?.availableDocumentId;return typeof a!="string"?!1:(iee.set(a,i),_ye(),!0)},beginRestore:({hasDocumentsToRestore:r})=>{lQe=!0,uQe=r,_ye()}});function Rmn(){mE=[],iee.clear(),lQe=!1,uQe=!1,w$e=!1,fQe()}const Rme=new Map;function OPn(t,r){return Rme.set(t,r),()=>{Rme.get(t)===r&&Rme.delete(t)}}function pQe(t){return Rme.get(t)??dQe().find(r=>r.rootId===t)?.descriptor.id??null}function C$e(t){const r=pQe(t);return r?s9(r)||Sb(r):!1}const Mme=new Map;function FPn(t,r){return Mme.set(t,r),()=>{Mme.get(t)===r&&Mme.delete(t)}}function _Ct(t){return Mme.get(t)?.()??null}const E$e=new Set;function RPn(t){return E$e.add(t),()=>{E$e.delete(t)}}function mCt(t){for(const r of E$e){const i=r(t);if(i!==null)return i}return null}const Mmn="document:";function _Qe(t){return`${Mmn}${t}`}const see=new Map;function Lmn(t){return see.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 LWt(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 T$e(t){return y9(t)!==void 0}function z8(t,r,i={}){const a=y9(r.kind);if(!a)return!1;const l=_Qe(r.id);return see.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:Hmn,...a.Toolbar?{Toolbar:Jmn}:{},...a.Shelf?{Shelf:Wmn}:{},presentation:()=>({kind:"document",id:r.id}),persist:()=>({entryId:r.id}),onDispose:d=>{see.delete(d)},...t?{onActivate:()=>t.setActiveViewportTab("edit")}:{}},i),!0}g9({id:"document",owner:"kind-documents",open:(t,r)=>{const i=ARe(r.id);return!i||!T$e(i.kind)?null:z8(t,i)?_Qe(i.id):null},settle:async t=>{await xE(()=>ARe(t.id)!==void 0,2e4);const i=ARe(t.id);if(!i)throw new Error(`The project's document table lists no document: ${t.id}`);if(!await xE(()=>T$e(i.kind),2e4))throw new Error(`No editor is registered for documents of kind '${i.kind}' (${t.id})`)},ready:async t=>{await C3t(t),await Nze(t)}});function ARe(t){return wb()?.scenes.entries.find(r=>r.id===t)}function Bmn(t,r,i={}){if(z8(t,r,i))return;const a=jA(()=>{z8(t,r,i)&&a()})}function $mn(t){return jA(()=>{const r=new Set(FA().map(i=>i.descriptor.id));for(const[i,{entry:a}]of see)r.has(i)&&y9(a.kind)&&z8(t,a,{activate:!1})})}function qmn(t,r){const i=()=>{const l=wb();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 zmn(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 hCt=null,mye=null;function Umn(t,r){hCt?.();let i=r?new Set(r):null;const a=()=>{const l=wb();if(!l||l.documentsPending)return;const d=new Set(l.scenes.entries.map(g=>g.id));if(i===null){i=d,mye=d;return}const _=[...l.scenes.entries].reverse().find(g=>!i?.has(g.id)&&g.kind!=="scene"&&g.kind!=="prefab"&&g.source&&T$e(g.kind));i=d,mye=d,_?.source&&z8(t,_,{activate:!0,preview:!0})&&YN({path:`/${_.source.path}`,name:_.label,kind:"source",capabilities:wg(_.source.path),origin:"project",health:"healthy",selectionCount:1})};a(),hCt=YP(a)}function Vmn(t){const r=()=>{const a=wb();if(!a||a.documentsPending)return!1;if(FA().some(d=>!d.descriptor.area))return!0;const l=zmn(a.scenes);if(l?.source){const d=`/${l.source.path}`;z8(t,l)||f8(t,d,LWt(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()})}kee({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?(qmn(l,d=>{Bmn(i,d,{activate:r})}),!0):!1},persistKindState:()=>mye?{seen:[...mye]}: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||Vmn(i),Umn(i,l)}});function mQe(t){Xe.useSyncExternalStore(jA,dI);const r=see.get(t)?.props;return{entry:r,contribution:r?y9(r.kind):void 0}}function Jmn({documentId:t,active:r}){const{entry:i,contribution:a}=mQe(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 Wmn({documentId:t,active:r}){const{entry:i,contribution:a}=mQe(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 Hmn({documentId:t,active:r}){const{entry:i,contribution:a}=mQe(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 Gmn(t,r){if(r)for(const i of Nmn(r)){if(i.plan.kind!=="root-document")continue;const a=pQe(i.plan.regionId);a&&HDt(a,i.plan.title)}}function Qmn(t){const r=()=>Gmn(t,wb()?.scenes??null);return r(),YP(r)}const Kmn=15e3;async function Ymn(t,r){const i=()=>wb()?.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,Kmn),g=YP(()=>{i()&&d()});i()&&d()}),jWt(t,r)}function jWt(t,r){const i=wb();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"&&z8(t,a,{activate:!0}))return{ok:!0,documentId:_Qe(a.id),title:a.label};const l=MWt(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=pQe(l.regionId);return d?(s9(d)||Sb(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 k$e="data-vgai-game-styles";function MPn(t){t.setAttribute(k$e,"")}const Xmn={installed:!1,sources:[],note:null},gCt="data-vgai-scoped-game-css";let SRe=null,BWt=null;function Zmn(){return BWt}function ehn(){return typeof globalThis.CSSScopeRule=="function"}async function LPn(t){if(SRe?.projectRoot===t)return SRe.state;const r=thn(t);return SRe={projectRoot:t,state:r},r}async function thn(t){return await rhn(t)}async function rhn(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 Xmn}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(!ehn()){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 nhn(t,i),{installed:!0,sources:a,note:l}}function nhn(t,r){const i=document.head.querySelector(`style[${gCt}]`),a=i instanceof HTMLStyleElement?i:document.createElement("style");a.setAttribute(gCt,t),a.textContent=r,a.isConnected||document.head.appendChild(a),BWt=r}const ihn='[data-vgai-root-surface="true"]';function Q1e(t){return t.matches(ihn)||t.closest('[data-vgai-canvas-scene="true"]')!==null}function xRe(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 shn(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 ohn(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 hQe(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 $Wt(t){const r=[],i=new Set;for(const a of Array.from(t.querySelectorAll("canvas"))){if(!Q1e(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,...ahn(t,a)])i.has(d)||(i.add(d),r.push(d))}return r}function ahn(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))chn(k,t)&&l.add(k)}return Array.from(l).reverse()}function chn(t,r){return t instanceof HTMLElement&&(t===r||r.contains(t))&&hQe(t)!==null}function qWt(t){const r=[];for(let i=t.parentElement;i;i=i.parentElement)r.unshift(i);return r}function lhn(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 uhn(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 fhn(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 zWt(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?ohn(t,_):_.style.background="transparent";const g=a?.transparentBackdrops;if(g?.has(t)&&(_.style.background="transparent"),t.closest(`[${k$e}]`)&&_.setAttribute(k$e,""),d){const J=shn(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=Zmn();if(S){const J=t.ownerDocument.createElement("style");J.textContent=S,_.appendChild(J)}for(const J of l){const X=J.cloneNode(!0);fhn(J,X,g),lhn(J,X),uhn(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:xRe(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=xRe(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&&Q1e(ge)){se.remove();return}const qe=ge?a?.canvasPixels?.get(ge):void 0,tt=qe?xRe(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 dhn={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(`${dhn[r]} capture failed — ${a}`),this.name="CaptureLayerError",this.layer=r}}function hye(t,r){return r instanceof s8?r:new s8(t,r)}const nP=32,phn=24,gQe=.9;function UWt(t,r){return[t[r*4]??0,t[r*4+1]??0,t[r*4+2]??0]}function _hn(t,r){const i=new Map;for(let d=0;d<r;d++){const[_,g,b]=UWt(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 mhn(t,r,i){let a=0;for(let l=0;l<r;l++){const d=UWt(t,l);Math.max(Math.abs(d[0]-i[0]),Math.abs(d[1]-i[1]),Math.abs(d[2]-i[2]))<=phn&&(a+=1)}return a}function VWt(t,r,i=gQe){const{mean:a,distinctRegions:l}=_hn(t,r),d=Math.round(mhn(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 I$e(t,r,i=gQe){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 VWt(d.data,nP*nP,i)}catch{return null}}async function JWt(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 oee(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 WWt(t,r){return await oee(t),(r?.presentsOnCanvas??t.querySelectorAll("canvas").length>0)||await new Promise(a=>setTimeout(a,650)),await JWt(t),await oee(t),D$e(t,2,r??{})}const HWt=.03;function GWt(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 QWt(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 hhn(t,r,i,a){let l;try{l=t.getImageData(0,0,r,i)}catch{return{kind:"ok"}}const d=r*i,_=GWt(l.data,d),g=_>HWt;return a>0&&(g||QWt(l.data,d))?{kind:"retry"}:g?{kind:"blank",transparentFraction:_}:{kind:"ok"}}function ghn(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 D$e(t,r,i){const a=t.ownerDocument.createElement("canvas"),l=await KWt(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=ghn(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 oee(t),D$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=I$e(G,t.ownerDocument);let fe;try{fe=G.toDataURL("image/png")}catch(de){throw hye("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=hhn(g,d,_,r);if(w.kind==="retry")return await new Promise(N=>setTimeout(N,300)),await oee(t),D$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=I$e(a,t.ownerDocument);let S;try{S=a.toDataURL("image/png")}catch(w){throw hye("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 yCt(t,r,i,a=1,l=1){for(const d of r){const _=hQe(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 KWt(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&&yCt(b,qWt(t),a,_,g);const k=Array.from(t.querySelectorAll("canvas")).some(J=>!Q1e(J))?null:i?.overlayCache?.take(t,l,d),w=k?.backdrops??$Wt(t);yCt(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 hye("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=zWt(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 hye("dom-overlay",J)}return{canvases:N.length,domOverlays:j}}const yhn=Object.freeze(Object.defineProperty({__proto__:null,CaptureLayerError:s8,FLATNESS_GRID:nP,FLATNESS_WARN_AT:gQe,TRANSPARENT_PIXEL_LIMIT:HWt,ancestorBackdrops:qWt,buildOverlaySvg:zWt,capturePlayComposite:WWt,drawPlayCompositeFrame:KWt,hasExcessNearBlackPixels:QWt,isRootCanvas:Q1e,measureFlatness:VWt,opaqueBackgroundColor:hQe,rootSurfaceBackdrops:$Wt,sampleFlatness:I$e,transparentPixelFraction:GWt,waitForFiniteMotion:JWt,waitForPaint:oee},Symbol.toStringTag,{value:"Module"}));function vCt(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 lte(t){const r=AE(),i=r?.descriptor.presentation?.()??void 0,a=r?Pw(r.descriptor.id):null,l=t0e(),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:vCt(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:vCt(b.position,b.target,b.fov),diagnostic:t.shadingMode,grid:t.showGrid}}const g=iPt();return{version:1,workspace:wS(),...jhe()===null?{}:{style:jhe()},keymap:uI(),...i?{document:i}:{},...d.length>0?{selection:{ids:[...d]}}:{},..._?{viewport:_}:{},...g?{panel:g}:{}}}function vhn(t){return dIt(lte(t),window.location.href)}var bb=(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))(bb||{});const P$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},u_e=(t,r)=>P$e(t).priority??r,k9={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...t){return t.map(P$e).forEach(r=>{r.type.forEach(i=>this._removeHandlers[i]?.(r))}),this},add(...t){return t.map(P$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,_)=>u_e(_.value,i)-u_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)=>u_e(d,i)-u_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))}},bhn={extension:{type:bb.Environment,name:"browser",priority:-1},test:()=>!0,load:async()=>{await la(()=>import("./browserAll-BQIn-DRw.js"),__vite__mapDeps([67,68,3,2,4,1,8,9,10,11,6]))}},Ahn={extension:{type:bb.Environment,name:"webworker",priority:0},test:()=>typeof self<"u"&&self.WorkerGlobalScope!==void 0,load:async()=>{await la(()=>import("./webworkerAll-FJN9IDir.js"),__vite__mapDeps([68,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 wRe={exports:{}},bCt;function Shn(){return bCt||(bCt=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})(wRe)),wRe.exports}var xhn=Shn();const K1e=Nkt(xhn),whn=Math.PI*2,Chn=180/Math.PI,Ehn=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 CRe.x=0,CRe.y=0,CRe}}const CRe=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(whn-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 khn.identity()}static get shared(){return Thn.identity()}}const Thn=new Lm,khn=new Lm,X7=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],Z7=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],eR=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],tR=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],N$e=[],YWt=[],f_e=Math.sign;function Ihn(){for(let t=0;t<16;t++){const r=[];N$e.push(r);for(let i=0;i<16;i++){const a=f_e(X7[t]*X7[i]+eR[t]*Z7[i]),l=f_e(Z7[t]*X7[i]+tR[t]*Z7[i]),d=f_e(X7[t]*eR[i]+eR[t]*tR[i]),_=f_e(Z7[t]*eR[i]+tR[t]*tR[i]);for(let g=0;g<16;g++)if(X7[g]===a&&Z7[g]===l&&eR[g]===d&&tR[g]===_){r.push(g);break}}}for(let t=0;t<16;t++){const r=new Lm;r.set(X7[t],Z7[t],eR[t],tR[t],0,0),YWt.push(r)}}Ihn();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=>X7[t],uY:t=>Z7[t],vX:t=>eR[t],vY:t=>tR[t],inv:t=>t&8?t&15:-t&7,add:(t,r)=>N$e[t][r],sub:(t,r)=>N$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 _=YWt[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)}},d_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=d_e[0].set(r.left,r.top),b=d_e[1].set(r.left,r.bottom),S=d_e[2].set(r.right,r.top),k=d_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 ERe={default:-1};function o8(t="default"){return ERe[t]===void 0&&(ERe[t]=-1),++ERe[t]}const ACt=new Set,Wz="8.0.0",wq={quiet:!1,noColor:!1},hI=((t,r,i=3)=>{if(wq.quiet||ACt.has(r))return;let a=new Error().stack;const l=`${r}
|
|
1599
|
+
`)}function ohn(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 hQe(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 $Wt(t){const r=[],i=new Set;for(const a of Array.from(t.querySelectorAll("canvas"))){if(!Q1e(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,...ahn(t,a)])i.has(d)||(i.add(d),r.push(d))}return r}function ahn(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))chn(k,t)&&l.add(k)}return Array.from(l).reverse()}function chn(t,r){return t instanceof HTMLElement&&(t===r||r.contains(t))&&hQe(t)!==null}function qWt(t){const r=[];for(let i=t.parentElement;i;i=i.parentElement)r.unshift(i);return r}function lhn(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 uhn(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 fhn(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 zWt(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?ohn(t,_):_.style.background="transparent";const g=a?.transparentBackdrops;if(g?.has(t)&&(_.style.background="transparent"),t.closest(`[${k$e}]`)&&_.setAttribute(k$e,""),d){const J=shn(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=Zmn();if(S){const J=t.ownerDocument.createElement("style");J.textContent=S,_.appendChild(J)}for(const J of l){const X=J.cloneNode(!0);fhn(J,X,g),lhn(J,X),uhn(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:xRe(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=xRe(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&&Q1e(ge)){se.remove();return}const qe=ge?a?.canvasPixels?.get(ge):void 0,tt=qe?xRe(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 dhn={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(`${dhn[r]} capture failed — ${a}`),this.name="CaptureLayerError",this.layer=r}}function hye(t,r){return r instanceof s8?r:new s8(t,r)}const nP=32,phn=24,gQe=.9;function UWt(t,r){return[t[r*4]??0,t[r*4+1]??0,t[r*4+2]??0]}function _hn(t,r){const i=new Map;for(let d=0;d<r;d++){const[_,g,b]=UWt(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 mhn(t,r,i){let a=0;for(let l=0;l<r;l++){const d=UWt(t,l);Math.max(Math.abs(d[0]-i[0]),Math.abs(d[1]-i[1]),Math.abs(d[2]-i[2]))<=phn&&(a+=1)}return a}function VWt(t,r,i=gQe){const{mean:a,distinctRegions:l}=_hn(t,r),d=Math.round(mhn(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 I$e(t,r,i=gQe){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 VWt(d.data,nP*nP,i)}catch{return null}}async function JWt(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 oee(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 WWt(t,r){return await oee(t),(r?.presentsOnCanvas??t.querySelectorAll("canvas").length>0)||await new Promise(a=>setTimeout(a,650)),await JWt(t),await oee(t),D$e(t,2,r??{})}const HWt=.03;function GWt(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 QWt(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 hhn(t,r,i,a){let l;try{l=t.getImageData(0,0,r,i)}catch{return{kind:"ok"}}const d=r*i,_=GWt(l.data,d),g=_>HWt;return a>0&&(g||QWt(l.data,d))?{kind:"retry"}:g?{kind:"blank",transparentFraction:_}:{kind:"ok"}}function ghn(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 D$e(t,r,i){const a=t.ownerDocument.createElement("canvas"),l=await KWt(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=ghn(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 oee(t),D$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=I$e(G,t.ownerDocument);let fe;try{fe=G.toDataURL("image/png")}catch(de){throw hye("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=hhn(g,d,_,r);if(w.kind==="retry")return await new Promise(N=>setTimeout(N,300)),await oee(t),D$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=I$e(a,t.ownerDocument);let S;try{S=a.toDataURL("image/png")}catch(w){throw hye("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 yCt(t,r,i,a=1,l=1){for(const d of r){const _=hQe(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 KWt(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&&yCt(b,qWt(t),a,_,g);const k=Array.from(t.querySelectorAll("canvas")).some(J=>!Q1e(J))?null:i?.overlayCache?.take(t,l,d),w=k?.backdrops??$Wt(t);yCt(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 hye("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=zWt(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 hye("dom-overlay",J)}return{canvases:N.length,domOverlays:j}}const yhn=Object.freeze(Object.defineProperty({__proto__:null,CaptureLayerError:s8,FLATNESS_GRID:nP,FLATNESS_WARN_AT:gQe,TRANSPARENT_PIXEL_LIMIT:HWt,ancestorBackdrops:qWt,buildOverlaySvg:zWt,capturePlayComposite:WWt,drawPlayCompositeFrame:KWt,hasExcessNearBlackPixels:QWt,isRootCanvas:Q1e,measureFlatness:VWt,opaqueBackgroundColor:hQe,rootSurfaceBackdrops:$Wt,sampleFlatness:I$e,transparentPixelFraction:GWt,waitForFiniteMotion:JWt,waitForPaint:oee},Symbol.toStringTag,{value:"Module"}));function vCt(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 lte(t){const r=AE(),i=r?.descriptor.presentation?.()??void 0,a=r?Pw(r.descriptor.id):null,l=t0e(),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:vCt(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:vCt(b.position,b.target,b.fov),diagnostic:t.shadingMode,grid:t.showGrid}}const g=iPt();return{version:1,workspace:wS(),...jhe()===null?{}:{style:jhe()},keymap:uI(),...i?{document:i}:{},...d.length>0?{selection:{ids:[...d]}}:{},..._?{viewport:_}:{},...g?{panel:g}:{}}}function vhn(t){return dIt(lte(t),window.location.href)}var bb=(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))(bb||{});const P$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},u_e=(t,r)=>P$e(t).priority??r,k9={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...t){return t.map(P$e).forEach(r=>{r.type.forEach(i=>this._removeHandlers[i]?.(r))}),this},add(...t){return t.map(P$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,_)=>u_e(_.value,i)-u_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)=>u_e(d,i)-u_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))}},bhn={extension:{type:bb.Environment,name:"browser",priority:-1},test:()=>!0,load:async()=>{await la(()=>import("./browserAll-DTuU4PmC.js"),__vite__mapDeps([66,67,3,2,4,1,8,9,10,11,6]))}},Ahn={extension:{type:bb.Environment,name:"webworker",priority:0},test:()=>typeof self<"u"&&self.WorkerGlobalScope!==void 0,load:async()=>{await la(()=>import("./webworkerAll-CS1yjkoi.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 wRe={exports:{}},bCt;function Shn(){return bCt||(bCt=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})(wRe)),wRe.exports}var xhn=Shn();const K1e=Nkt(xhn),whn=Math.PI*2,Chn=180/Math.PI,Ehn=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 CRe.x=0,CRe.y=0,CRe}}const CRe=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(whn-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 khn.identity()}static get shared(){return Thn.identity()}}const Thn=new Lm,khn=new Lm,X7=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],Z7=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],eR=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],tR=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],N$e=[],YWt=[],f_e=Math.sign;function Ihn(){for(let t=0;t<16;t++){const r=[];N$e.push(r);for(let i=0;i<16;i++){const a=f_e(X7[t]*X7[i]+eR[t]*Z7[i]),l=f_e(Z7[t]*X7[i]+tR[t]*Z7[i]),d=f_e(X7[t]*eR[i]+eR[t]*tR[i]),_=f_e(Z7[t]*eR[i]+tR[t]*tR[i]);for(let g=0;g<16;g++)if(X7[g]===a&&Z7[g]===l&&eR[g]===d&&tR[g]===_){r.push(g);break}}}for(let t=0;t<16;t++){const r=new Lm;r.set(X7[t],Z7[t],eR[t],tR[t],0,0),YWt.push(r)}}Ihn();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=>X7[t],uY:t=>Z7[t],vX:t=>eR[t],vY:t=>tR[t],inv:t=>t&8?t&15:-t&7,add:(t,r)=>N$e[t][r],sub:(t,r)=>N$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 _=YWt[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)}},d_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=d_e[0].set(r.left,r.top),b=d_e[1].set(r.left,r.bottom),S=d_e[2].set(r.right,r.top),k=d_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 ERe={default:-1};function o8(t="default"){return ERe[t]===void 0&&(ERe[t]=-1),++ERe[t]}const ACt=new Set,Wz="8.0.0",wq={quiet:!1,noColor:!1},hI=((t,r,i=3)=>{if(wq.quiet||ACt.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))),ACt.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 XWt=()=>{};function SCt(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 xCt(t){return!(t&t-1)&&!!t}function Dhn(t){const r={};for(const i in t)t[i]!==void 0&&(r[i]=t[i]);return r}const wCt=Object.create(null);function Phn(t){const r=wCt[t];return r===void 0&&(wCt[t]=o8("resource")),r}const ZWt=class eHt extends K1e{constructor(r={}){super(),this._resourceType="textureSampler",this._touched=0,this._maxAnisotropy=1,this.destroyed=!1,r={...eHt.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(Wz,"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=Phn(r),this._resourceId}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this.removeAllListeners()}};ZWt.defaultOptions={addressMode:"clamp-to-edge",scaleMode:"linear"};let tHt=ZWt;const rHt=class nHt extends K1e{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={...nHt.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 tHt(Dhn(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=xCt(this.pixelWidth)&&xCt(this.pixelHeight)}static test(r){throw new Error("Unimplemented")}};rHt.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=rHt;class yQe 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}}yQe.extension=bb.TextureSource;const CCt=new Lm;class Nhn{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&&(CCt.set(a.width/l.width,0,0,a.height/l.height,-l.x/l.width,-l.y/l.height),this.mapCoord.append(CCt));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 K1e{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 Nhn(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(Wz,"Texture.baseTexture is now Texture.source"),this._source}}Fy.EMPTY=new Fy({label:"EMPTY",source:new FE({label:"EMPTY"})});Fy.EMPTY.destroy=XWt;Fy.WHITE=new Fy({source:new yQe({resource:new Uint8Array([255,255,255,255]),width:1,height:1,alphaMode:"premultiply-alpha-on-upload",label:"WHITE"}),label:"WHITE"});Fy.WHITE.destroy=XWt;function Ohn(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 ECt=new Lm;class U8{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=ECt,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=ECt,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 U8(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 Fhn={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},iHt=function(t){return(t=isFinite(t)?t%360:0)>0?t:t+360},TCt=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)}},TRe=function(t){return{r:T0(t.r),g:T0(t.g),b:T0(t.b),a:T0(t.a,3)}},Rhn=/^#([0-9a-f]{3,8})$/i,p_e=function(t){var r=t.toString(16);return r.length<2?"0"+r:r},sHt=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}},oHt=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}},kCt=function(t){return{h:iHt(t.h),s:vw(t.s,0,100),l:vw(t.l,0,100),a:vw(t.a)}},ICt=function(t){return{h:T0(t.h),s:T0(t.s),l:T0(t.l),a:T0(t.a,3)}},DCt=function(t){return oHt((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},HX=function(t){return{h:(r=sHt(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},Mhn=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Lhn=/^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,Bhn=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,O$e={string:[[function(t){var r=Rhn.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)||Bhn.exec(t);return r?r[2]!==r[4]||r[4]!==r[6]?null:TCt({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=Mhn.exec(t)||Lhn.exec(t);if(!r)return null;var i,a,l=kCt({h:(i=r[1],a=r[2],a===void 0&&(a="deg"),Number(i)*(Fhn[a]||1)),s:Number(r[3]),l:Number(r[4]),a:r[5]===void 0?1:Number(r[5])/(r[6]?100:1)});return DCt(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)?TCt({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 _=kCt({h:Number(r),s:Number(i),l:Number(a),a:Number(d)});return DCt(_)},"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:iHt(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 oHt(_)},"hsv"]]},PCt=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]},$hn=function(t){return typeof t=="string"?PCt(t.trim(),O$e.string):typeof t=="object"&&t!==null?PCt(t,O$e.object):[null,void 0]},kRe=function(t,r){var i=HX(t);return{h:i.h,s:vw(i.s+100*r,0,100),l:i.l,a:i.a}},IRe=function(t){return(299*t.r+587*t.g+114*t.b)/1e3/255},NCt=function(t,r){var i=HX(t);return{h:i.h,s:i.s,l:vw(i.l+100*r,0,100),a:i.a}},F$e=(function(){function t(r){this.parsed=$hn(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(IRe(this.rgba),2)},t.prototype.isDark=function(){return IRe(this.rgba)<.5},t.prototype.isLight=function(){return IRe(this.rgba)>=.5},t.prototype.toHex=function(){return r=TRe(this.rgba),i=r.r,a=r.g,l=r.b,_=(d=r.a)<1?p_e(T0(255*d)):"","#"+p_e(i)+p_e(a)+p_e(l)+_;var r,i,a,l,d,_},t.prototype.toRgb=function(){return TRe(this.rgba)},t.prototype.toRgbString=function(){return r=TRe(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 ICt(HX(this.rgba))},t.prototype.toHslString=function(){return r=ICt(HX(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=sHt(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(kRe(this.rgba,r))},t.prototype.desaturate=function(r){return r===void 0&&(r=.1),Wk(kRe(this.rgba,-r))},t.prototype.grayscale=function(){return Wk(kRe(this.rgba,-1))},t.prototype.lighten=function(r){return r===void 0&&(r=.1),Wk(NCt(this.rgba,r))},t.prototype.darken=function(r){return r===void 0&&(r=.1),Wk(NCt(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=HX(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 F$e?t:new F$e(t)},OCt=[],qhn=function(t){t.forEach(function(r){OCt.indexOf(r)<0&&(r(F$e,O$e),OCt.push(r))})};function zhn(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"])}qhn([zhn]);const Hz=class fX{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 fX)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]=fX._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=fX.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 fX||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}};Hz.shared=new Hz;Hz._temp=new Hz;Hz.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let Uhn=Hz;const Vhn={cullArea:null,cullable:!1,cullableChildren:!0};let DRe=0;const FCt=500;function b8(...t){DRe!==FCt&&(DRe++,DRe===FCt?console.warn("PixiJS Warning: too many warnings, no more warnings will be reported to the console by PixiJS."):console.warn("PixiJS Warning: ",...t))}const aHt={_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 Jhn{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 Whn{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 Jhn(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 Whn;aHt.register(o9);const Hhn={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 Ghn(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 Qhn={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)}Ghn(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(Wz,"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)}},Khn={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 RCt{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 Yhn{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 R$e=new Yhn;k9.handleByList(bb.MaskEffect,R$e._effectClasses);const Xhn={_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),R$e.returnMaskEffect(r),this._maskEffect=null),t!=null&&(this._maskEffect=R$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 RCt);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 RCt),this._filterEffect.filterArea=t},get filterArea(){return this._filterEffect?.filterArea}},Zhn={label:null,get name(){return hI(Wz,"Container.name property has been removed, use Container.label instead"),this.label},set name(t){hI(Wz,"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}},yb=o9.getPool(Lm),kP=o9.getPool(U8),egn=new Lm,tgn={getFastGlobalBounds(t,r){r||(r=new U8),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(egn).invert()),r.addBounds(a),kP.return(a)}else this.renderGroup&&(r.addBounds(a,this.relativeGroupTransform),kP.return(a))}};function cHt(t,r,i){i.clear();let a,l;return t.parent?r?a=t.parent.worldTransform:(l=yb.get().identity(),a=vQe(t,l)):a=Lm.IDENTITY,lHt(t,i,a,r),l&&yb.return(l),i.isValid||i.set(0,0,0,0),i}function lHt(t,r,i,a){if(!t.visible||!t.measurable)return;let l;a?l=t.worldTransform:(t.updateLocalTransform(),l=yb.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++)lHt(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||yb.return(l)}function vQe(t,r){const i=t.parent;return i&&(vQe(i,r),i.updateLocalTransform(),r.append(i.localTransform)),r}function rgn(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 MCt=16777215;function LCt(t,r){return t===MCt?r:r===MCt?t:rgn(t,r)}function Lme(t){return((t&255)<<16)+(t&65280)+(t>>16&255)}const ngn={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=vQe(this,yb.get().identity());return t.appendFrom(this.localTransform,i),yb.return(i),t},getGlobalTint(t){if(t)return this.renderGroup?Lme(this.renderGroup.worldColor):this.parentRenderGroup?Lme(LCt(this.localColor,this.parentRenderGroup.worldColor)):this.tint;let r=this.localColor,i=this.parent;for(;i;)r=LCt(r,i.localColor),i=i.parent;return Lme(r)}};function uHt(t,r,i){return r.clear(),i||(i=Lm.IDENTITY),fHt(t,r,i,t,!0),r.isValid||r.set(0,0,0,0),r}function fHt(t,r,i,a,l){let d;if(l)d=yb.get(),d=i.copyTo(d);else{if(!t.visible||!t.measurable)return;t.updateLocalTransform();const b=t.localTransform;d=yb.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++)fHt(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)}yb.return(d)}function dHt(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&&dHt(l,r)}return r.didChange}const ign=new Lm,sgn={_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 U8});const t=this._localBoundsCacheData;return t.index=1,t.didChange=!1,t.data[0]!==this._didViewChangeTick&&(t.didChange=!0,t.data[0]=this._didViewChangeTick),dHt(this,t),t.didChange&&uHt(this,t.localBounds,ign),t.localBounds},getBounds(t,r){return cHt(this,t,r||new U8)}},ogn={_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}},agn={_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(cgn))}};function cgn(t,r){return t._zIndex-r._zIndex}const lgn={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(yb.get(),i);return r=a.apply(t,r),yb.return(a),r},toLocal(t,r,i,a){r&&(t=r.toGlobal(t,i,a));const l=this.getGlobalTransform(yb.get(),a);return i=l.applyInverse(t,i),yb.return(l),i}};class ugn{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 fgn=0;class dgn{constructor(r){this._poolKeyHash=Object.create(null),this._texturePool={},this.textureOptions=r||{},this.enableFullScreen=!1,this.textureStyle=new tHt(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_${fgn++}`})}getOptimalTexture(r,i,a=1,l,d=!1){let _=Math.ceil(r*a-1e-6),g=Math.ceil(i*a-1e-6);_=SCt(_),g=SCt(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 pHt=new dgn;aHt.register(pHt);class pgn{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 ugn,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&&(pHt.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 _gn(t,r,i={}){for(const a in r)!i[a]&&r[a]!==void 0&&(t[a]=r[a])}const PRe=new _1(null),__e=new _1(null),NRe=new _1(null,1,1),m_e=new _1(null),jCt=1,mgn=2,ORe=4;class ute extends K1e{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=NRe,this._pivot=__e,this._origin=m_e,this._skew=PRe,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=[],_gn(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(ute,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(Wz,"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(pgn,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*Chn}set angle(r){this.rotation=r*Ehn}get pivot(){return this._pivot===__e&&(this._pivot=new _1(this,0,0)),this._pivot}set pivot(r){this._pivot===__e&&(this._pivot=new _1(this,0,0),this._origin!==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._pivot.set(r):this._pivot.copyFrom(r)}get skew(){return this._skew===PRe&&(this._skew=new _1(this,0,0)),this._skew}set skew(r){this._skew===PRe&&(this._skew=new _1(this,0,0)),this._skew.copyFrom(r)}get scale(){return this._scale===NRe&&(this._scale=new _1(this,1,1)),this._scale}set scale(r){this._scale===NRe&&(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===m_e&&(this._origin=new _1(this,0,0)),this._origin}set origin(r){this._origin===m_e&&(this._origin=new _1(this,0,0),this._pivot!==__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|=jCt,this._onUpdate())}get alpha(){return this.localAlpha}set tint(r){const a=Uhn.shared.setValue(r??16777215).toBgrNumber();a!==this.localColor&&(this.localColor=a,this._updateFlags|=jCt,this._onUpdate())}get tint(){return Lme(this.localColor)}set blendMode(r){this.localBlendMode!==r&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=mgn,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|=ORe,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|=ORe,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|=ORe,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(ute,Qhn,tgn,lgn,ogn,sgn,Xhn,Zhn,agn,Vhn,Hhn,ngn,Khn);class hgn extends ute{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 U8(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 aee extends hgn{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 aee(r):new aee(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 Ohn(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 ggn=new U8;function _Ht(t,r,i){const a=ggn;t.measurable=!0,cHt(t,i,a),r.addBoundsMask(a),t.measurable=!1}function mHt(t,r,i){const a=kP.get();t.measurable=!0;const l=yb.get().identity(),d=hHt(t,i,l);uHt(t,a,d),t.measurable=!1,r.addBoundsMask(a),yb.return(l),kP.return(a)}function hHt(t,r,i){return t?(t!==r&&(hHt(t.parent,r,i),t.updateLocalTransform(),i.append(t.localTransform)),i):(b8("Mask bounds, renderable is not inside the root container"),i)}class gHt{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 aee),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||_Ht(this.mask,r,i)}addLocalBounds(r,i){mHt(this.mask,r,i)}containsPoint(r,i){const a=this.mask;return i(a,r)}destroy(){this.reset()}static test(r){return r instanceof aee}}gHt.extension=bb.MaskEffect;class yHt{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"}}yHt.extension=bb.MaskEffect;class vHt{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){_Ht(this.mask,r,i)}addLocalBounds(r,i){mHt(this.mask,r,i)}containsPoint(r,i){const a=this.mask;return i(a,r)}destroy(){this.reset()}static test(r){return r instanceof ute}}vHt.extension=bb.MaskEffect;const ygn={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 BCt=ygn;const bQe={get(){return BCt},set(t){BCt=t}};class bHt extends FE{constructor(r){r.resource||(r.resource=bQe.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"))}}bHt.extension=bb.TextureSource;class AHt 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}}AHt.extension=bb.TextureSource;var M$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))(M$e||{});class FRe{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 SHt=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 FRe(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=M$e.NORMAL){return this._addListener(new FRe(r,i,a))}addOnce(r,i,a=M$e.NORMAL){return this._addListener(new FRe(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}};SHt.targetFPMS=.06;let h_e=SHt,RRe;async function vgn(){return RRe??(RRe=(async()=>{const r=bQe.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"})()),RRe}const Y1e=class xHt extends FE{constructor(r){super(r),this.isReady=!1,this.uploadMethodId="video",r={...xHt.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=h_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 vgn(),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&&(h_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||(h_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&&(h_e.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(r){return globalThis.HTMLVideoElement&&r instanceof HTMLVideoElement}};Y1e.extension=bb.TextureSource;Y1e.defaultOptions={...FE.defaultOptions,autoLoad:!0,autoPlay:!0,updateFPS:0,crossorigin:!0,loop:!1,muted:!0,playsinline:!0,preload:!1};Y1e.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let bgn=Y1e;const cq=(t,r,i=!1)=>(Array.isArray(t)||(t=[t]),r?t.map(a=>typeof a=="string"||i?r(a):a):t);class Agn{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 Agn,L$e=[];k9.handleByList(bb.TextureSource,L$e);function wHt(t={}){const r=t&&t.resource,i=r?t.resource:t,a=r?t:{resource:t};for(let l=0;l<L$e.length;l++){const d=L$e[l];if(d.test(i))return new d(a)}throw new Error(`Could not find a source type for resource: ${a.resource}`)}function Sgn(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:wHt(l)});return d.on("destroy",()=>{lq.has(a)&&lq.remove(a)}),r||lq.set(a,d),d}function xgn(t,r=!1){return typeof t=="string"?lq.get(t):t instanceof FE?new Fy({source:t}):Sgn(t,r)}Fy.from=xgn;FE.from=wHt;k9.add(gHt,yHt,vHt,bgn,AHt,bHt,yQe);var CHt=(t=>(t[t.Low=0]="Low",t[t.Normal=1]="Normal",t[t.High=2]="High",t))(CHt||{});function oE(t){if(typeof t!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(t)}`)}function wY(t){return t.split("?")[0].split("#")[0]}function wgn(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Cgn(t,r,i){return t.replace(new RegExp(wgn(r),"g"),i)}function Egn(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 cee={toPosix(t){return Cgn(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=wY(this.toPosix(r??bQe.get().getBaseUrl())),l=wY(this.toPosix(i??this.rootname(a)));return t=this.toPosix(t),t.startsWith("/")?cee.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=Egn(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=wY(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=wY(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=wY(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 EHt(t,r,i,a,l){const d=r[i];for(let _=0;_<d.length;_++){const g=d[_];i<r.length-1?EHt(t.replace(a[i],g),r,i+1,a,l):l.push(t.replace(a[i],g))}}function Tgn(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(_)}),EHt(t,l,0,i,a)}else a.push(t);return a}const $Ct=t=>!Array.isArray(t);class THt{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"?Tgn(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=$Ct(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=$Ct(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=cee.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??kgn(r.src),b!==void 0&&(r.progressSize=b),r}}THt.RETINA_PREFIX=/@([0-9\.]+)x/;function kgn(t){return t.split(".").pop().split("?").shift().split("#").shift()}const qCt=(t,r)=>{const i=r.split("?")[1];return i&&(t+=`?${i}`),t},kHt=class dX{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<=dX.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:dX.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*dX.BATCH_SIZE),this._batchIndex++,setTimeout(()=>{this._batchIndex*dX.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=[]}};kHt.BATCH_SIZE=1e3;let zCt=kHt;const Ign=["jpg","png","jpeg","avif","webp","basis","etc2","bc7","bc6h","bc5","bc4","bc3","bc2","bc1","eac","astc"];function IHt(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=cee.dirname(t[0]);r.linkedSheets.forEach((d,_)=>{const g=IHt([`${l}/${r.data.meta.related_multi_packs[_]}`],d,!0);Object.assign(a,g)})}return a}const Dgn={extension:bb.Asset,cache:{test:t=>t instanceof zCt,getCacheableAssets:(t,r)=>IHt(t,r,!1)},resolver:{extension:{type:bb.ResolveParser,name:"resolveSpritesheet"},test:t=>{const i=t.split("?")[0].split("."),a=i.pop(),l=i.pop();return a==="json"&&Ign.includes(l)},parse:t=>{const r=t.split(".");return{resolution:parseFloat(THt.RETINA_PREFIX.exec(t)?.[1]??"1"),format:r[r.length-2],src:t}}},loader:{name:"spritesheetLoader",id:"spritesheet",extension:{type:bb.LoadParser,priority:CHt.Normal,name:"spritesheetLoader"},async testParse(t,r){return cee.extname(r.src).toLowerCase()===".json"&&!!t.frames},async parse(t,r,i){const{texture:a,imageFilename:l,textureOptions:d,cachePrefix:_}=r?.data??{};let g=cee.dirname(r.src);g&&g.lastIndexOf("/")!==g.length-1&&(g+="/");let b;if(a instanceof Fy)b=a;else{const w=qCt(g+(l??t.meta.image),r.src);b=(await i.load([{src:w,data:d}]))[w]}const S=new zCt({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=qCt(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(Dgn);k9.add(bhn,Ahn);function Pgn(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 Ngn=new Set,Ogn=new Map;function Fgn(t){const r=Ogn.get(t);return r?r():Pgn([...Ngn])(t)}async function jPn(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=[],Rgn=0,DHt=0;const j$e=new Set;function B$e(){DHt++;for(const t of j$e)t()}function PHt(){B$e()}function $$e(){return Cb()}function AQe(){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 NHt(){for(const{session:t}of XN){const r=t.restartRequired?.()??null;if(r!==null)return r}return null}function OHt(){(Cb().find(i=>(i.restartRequired?.()??null)!==null)??Cb().find(i=>i.mounted()&&i.restart))?.restart?.()}function SQe(){for(const t of Cb()){if(!t.mounted())continue;const r=t.frameCanvas?.()??null;if(r)return r}return null}function xQe(t){for(const r of Cb())if(!(!r.mounted()||!r.snapshotFrame)&&r.frameCanvas?.()===t)return r.snapshotFrame();return null}function wQe(t){for(const r of Cb()){if(!r.mounted()||!r.command)continue;const i=r.command(t);if(i)return i}return null}function CQe(){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 X1e(){for(const t of Cb()){if(!t.mounted())continue;const r=t.surface?.()??null;if(r)return r}return null}function EQe(){for(const t of Cb()){if(!t.mounted())continue;const r=t.coverage?.()??null;if(r)return r}return null}function TQe(){for(const t of Cb()){if(!t.mounted())continue;const r=t.authoringRefusal?.()??null;if(r!==null)return r}return null}function FHt(t){return Cb().find(i=>i.mounted()&&i.remount)?.remount?.(t)??null}function RHt(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:Rgn++};return XN=[...XN,r],B$e(),()=>{XN=XN.filter(i=>i!==r),B$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 kQe(){return Cb().some(t=>t.mounted())}function Z1e(){return Cb().some(t=>t.playing())}function IQe(){for(const t of Cb())t.stop()}function MHt(t){for(const r of Cb()){const i=r.instanceContainer(t);if(i)return i}return null}function DQe(t){return j$e.add(t),()=>j$e.delete(t)}function LHt(){return DHt}const Mgn=Object.freeze(Object.defineProperty({__proto__:null,anyLiveSessionMounted:kQe,anyLiveSessionPlaying:Z1e,dispatchLiveCommand:wQe,liveAuthoringRefusal:TQe,liveCoverage:EQe,liveFrameCanvas:SQe,liveInstanceContainer:MHt,liveRestartRequired:NHt,liveRunWindow:AQe,liveScenes:CQe,liveSessions:$$e,liveSessionsVersion:LHt,liveSurface:X1e,notifyLiveSessionsChanged:PHt,registerLiveSession:RHt,remountLiveSelection:FHt,restartLiveSession:OHt,snapshotLiveFrame:xQe,stopAllLiveSessions:IQe,subscribeLiveSessions:DQe},Symbol.toStringTag,{value:"Module"}));async function q$e(t){const r=xQe(t);return r||Fgn(t)}const Lgn=Object.freeze(Object.defineProperty({__proto__:null,liveCanvasFrame:q$e},Symbol.toStringTag,{value:"Module"})),UCt="editor-chrome-root";async function VCt(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 q$e(i);if(l)return l;const d=t.captureViewportImage(a);return d?VCt(d):null}for(const l of NOr()){if(l.renderer.domElement!==i)continue;const d=await l.requestPresentedFrame();if(d)return d;const _=l.captureImage(a);return _?VCt(_):null}return q$e(i)}}async function Bgn(t,r){const i=document.getElementById(UCt);if(!i)throw new Error(`The editor chrome root (#${UCt}) 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 WWt(i,{canvasFrame:jgn(t,a),includeDocumentStyles:!0,size:d}),view:lte(t),size:d,scale:a}}function ebe(){return Z1e()}const gye=new Set;function $gn(t,r){const i={collect:t,reusableKeys:r?.reusableKeys??[]};return gye.add(i),()=>{gye.delete(i)}}function qgn(t=null){const r={};for(const i of gye)Object.assign(r,i.collect(t));return r}function zgn(){const t=[];for(const r of gye)t.push(...r.reusableKeys);return t}function fte(t,r,i){return t.hierarchy.object3D?.(i)??r.get(i)??null}function jHt(t){const r=CE(t,"entityId");return typeof r=="string"&&r?r:void 0}function BHt(t){return jHt(t)!==void 0}function BPn(t){let r=t??null;for(;r&&!BHt(r);)r=r.parent;return r}function $Pn(t,r){wZ(t,"entityId",r)}let GX=null;const a8=[];function Ugn(t){if(GX=t,a8.length!==0)for(const r of a8.splice(0,a8.length))r.resolve(t)}function Vgn(){return new Promise((t,r)=>{a8.push({resolve:t,reject:r})})}function Jgn(t){GX===t&&(GX=null,a8.length!==0&&queueMicrotask(()=>{if(!(GX!==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 JCt(){return GX}function Wgn(t,r){const i=[],a=[];for(const l of t.rows){const d=Hgn(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 Hgn(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 Ggn=[];function Qgn(){return Ggn}const z$e=new Set;let CY=null;function Kgn(t){return z$e.add(t),()=>{z$e.delete(t)}}function Ygn(){return CY||(CY=Promise.all([...z$e].map(t=>Promise.resolve().then(t))).then(()=>{}).finally(()=>{CY=null}),CY)}const jme=new Map;let $Ht=0;const U$e=new Set;function WCt(){$Ht++;for(const t of[...U$e])t()}function qPn(t,r){const i={store:r};return jme.set(t,i),WCt(),()=>{jme.get(t)===i&&(jme.delete(t),WCt())}}function lee(t){return t===null?null:jme.get(t)?.store??null}function qHt(t){return U$e.add(t),()=>{U$e.delete(t)}}function yye(){return $Ht}const Xgn={count:0,surface:null,visible:!1};function Zgn(t){return t==="three"||t==="canvas"||t==="dom"?t:null}function HCt(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 eyn(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=HCt(i?.kind);return a.kind!=="unknown"?a:HCt(r.descriptor.kind)}function tyn(t){return t instanceof Zh?t.childAdapters().some(r=>r.kind==="three"):!t.rects&&typeof t.hierarchy.object3D=="function"}function zHt(t,r,i,a){const l=By(t),d=oLe(t)&&tyn(l)?"three":null,_=t.playState,g=t.selectedEntityIds.size;if(g===0)return{documentId:r,chrome:a,subject:i,surface:d,selection:Xgn,play:_};const b=V4t(l,t.selectedEntityIds);return{documentId:r,chrome:a,subject:i,surface:d,selection:{count:g,surface:Zgn(b?.kind),visible:J4t(t,b)},play:_}}function UHt(t,r,i="document"){const a=eyn(r),l=Pw(r);if(l===null)return zHt(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 ryn(t){const r=I_();return r!==null?UHt(t,r):zHt(t,null,{kind:"unknown"},"document")}function bP(t){return lee(I_())??t}function nyn(t){return t.surface!=="three"?!1:t.selection.count===0?!0:t.selection.surface==="three"&&t.selection.visible}function iyn(t){return nyn(t)?_It(t.documentId)===null?"gizmo":"modal":"none"}function zPn(t){return t.surface==="three"&&t.selection.count>0&&t.selection.surface==="three"&&t.selection.visible}function VHt(t){return t.chrome==="embedded"||t.subject.kind==="story"||t.subject.kind==="artifact"}function UPn(t,r){return VHt(t)?!0:t.subject.kind==="data"&&!r}function VPn(t){return t.chrome==="document"&&VHt(t)}const syn=500;function GCt(t){const r=globalThis,i=r.requestIdleCallback;if(typeof i=="function"){const l=i.call(globalThis,t,{timeout:syn});return()=>r.cancelIdleCallback?.call(globalThis,l)}const a=setTimeout(t,0);return()=>clearTimeout(a)}const oyn=1,IP=[];function V$e(t){const r=IP.indexOf(t);r>=0&&IP.splice(r,1),t.renderer.dispose(),t.renderer.forceContextLoss(),t.canvas.remove()}function ayn(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||V$e(a)}),IP.push(a),a}function cyn(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=Dkt,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 JPn(t,r,i){let a=IP.find(_=>!_.leased&&!_.lost);a||(a=ayn(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){V$e(l);return}cyn(l);const _=IP.filter(g=>!g.leased&&!g.lost);for(const g of _.slice(oyn))V$e(g)}}}function lyn(){return{active:IP.filter(t=>t.leased&&!t.lost).length,idle:IP.filter(t=>!t.leased&&!t.lost).length}}const uyn=["three","canvas","dom"];function QCt(t){return t.provenance?.source==="boundary"}function fyn(t){return uyn.includes(t)?t:null}function dyn(){const t=t0e(),r=AE()?.descriptor.provenance?.rootId,i=r?wb()?.regions.find(_=>_.id===r):void 0,a=t?.adapter&&r&&i?{worldId:r,surface:i.surface,adapter:t.adapter}:null,l=KPt();if(!l)return a?[a]:[];if(l instanceof Zh){const _=l.childAdapters().filter(g=>g.role==="world"&&!QCt(g.adapter)).map(g=>({worldId:g.worldId,surface:fyn(g.kind),adapter:g.adapter}));return a?[a,..._.filter(g=>g.worldId!==r)]:_}if(QCt(l))return a?[a]:[];const d={worldId:"root",surface:X1e(),adapter:l};return a?[a,d]:[d]}const Bme=new Map,pyn=new Set;function KCt(){for(const t of pyn)t()}function WPn(t){return Bme.set(t.id,t),KCt(),()=>{Bme.get(t.id)===t&&(Bme.delete(t.id),KCt())}}function _yn(){return[...Bme.values()]}function PQe(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 myn(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 JHt(t){return t.filter(r=>r.failsafeEligible&&r.inlineHiding!==null)}function hyn(t){return t.some(r=>r.hiddenBy!==null)?JHt(t).length>0:null}const gyn=4e3;function yyn(t){const r=t.deadlineMs??gyn;if(t.framesProduced<=0)return{fire:!1};if(t.hiddenForMs===null||t.hiddenForMs<r)return{fire:!1};if(PQe(t.canvases)===null)return{fire:!1};const i=[...JHt(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 $me=new Map;function HPn(t){return $me.set(t.id,t),()=>{$me.get(t.id)===t&&$me.delete(t.id)}}function vyn(){return[...$me.values()]}const MRe=10,g_e=5e3;function byn(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 Ayn(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 Syn(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 xyn(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>=MRe?{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 ${MRe}fps floor`,cause:`the visible tab is rendering below the ${MRe}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 wyn(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<g_e?{status:"ok",detail:`play started ${t.play.startedMsAgo}ms ago and has not drawn yet — inside the ${g_e}ms deadline`}:{status:"violation",detail:`play started ${t.play.startedMsAgo}ms ago and has drawn no frame (deadline ${g_e}ms)`,cause:`play started and no frame has drawn within the ${g_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 WHt={"edit-mode-static":byn,"single-root-scene":Ayn,"canvas-revealed":Syn,"visible-tab-fps-floor":xyn,"play-drew-a-frame":wyn},Cyn=Object.keys(WHt);function Eyn(t){return Cyn.map(r=>({id:r,...WHt[r](t)}))}function Tyn(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 J$e=new Set;function kyn(t){return J$e.add(t),()=>{J$e.delete(t)}}function Iyn(){for(const t of[...J$e])try{t()}catch(r){ua.error(`a session-sample subscriber threw: ${String(r)}`,"invariant")}}const Dyn=5e3;let hw={frames:0,since:0},QX=null,Gq=null,BR=null;const KX=new Map;function Pyn(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 Nyn="editor-canvas";function Oyn(t){const r=t.style;return r.display==="none"?"display":r.visibility==="hidden"?"visibility":r.opacity!==""&&Number.parseFloat(r.opacity)===0?"opacity":null}function HHt(){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:Pyn(r),inlineHiding:Oyn(r),failsafeEligible:a!==Nyn}})}function Fyn(){const t=_yn();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 rR=new Map,EY=new Map;function Ryn(){const t=vyn(),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=EY.get(l);_===null?EY.delete(l):EY.set(l,_);const b=_===null||g===void 0?{}:{transportAdvanced:_!==g};let S;try{S=a.contentClock()}catch(N){return rR.delete(l),{id:l,label:d,advanced:null,unavailable:`its content clock threw: ${String(N)}`,...b}}if(S===null)return rR.delete(l),{id:l,label:d,advanced:null,unavailable:"its content clock is temporarily unavailable",...b};const k=S,w=rR.get(l);return rR.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[...rR.keys()])r.has(a)||rR.delete(a);for(const a of[...EY.keys()])r.has(a)||EY.delete(a);return i}function Myn(t=Date.now()){const r=ebe(),i=hw.since===0?0:t-hw.since,a=hw.frames,l=i>0&&a>0?a*1e3/i:null,d=r?{startedMsAgo:BR===null?0:t-BR,...Fyn()}:null;return{mode:r?"play":"edit",loops:[...$$e().map(_=>({name:`${_.id} session`,running:_.mounted()})),...$$e().map(_=>({name:`${_.id} playing`,running:_.playing()}))],designTimeSurfaces:Ryn(),presentedThreeRoots:KPt()?dyn().filter(_=>_.surface==="three").map(_=>_.worldId):null,...(()=>{const _=HHt();return{canvasHiddenBy:PQe(_),canvasHidesItself:hyn(_),hiddenCanvases:myn(_)}})(),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 GHt(){return Eyn(Myn())}let Cq=null;const YCt=new WeakSet;function Lyn(t,r){const i=PQe(t);if(i==null){Cq=null;return}if(Cq===null){Cq=r;return}const a=yyn({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||YCt.has(l)||(YCt.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=GHt();for(const r of t){const i=Tyn(r);if(!i){KX.delete(r.id);continue}if(r.id==="visible-tab-fps-floor"){const a=(KX.get(r.id)??0)+1;if(KX.set(r.id,a),a<3)continue}ua.warn(i,"invariant")}return t}function Byn(){if(Gq!==null)return XCt;hw={frames:0,since:Date.now()};const t=()=>{hw.frames++,QX=requestAnimationFrame(t)};return QX=requestAnimationFrame(t),Gq=setInterval(()=>{const r=ebe();r&&BR===null&&(BR=Date.now()),r||(BR=null),Iyn(),Lyn(HHt(),Date.now()),jyn(),hw={frames:0,since:Date.now()}},Dyn),XCt}function $yn(){hw={frames:0,since:Gq===null?0:Date.now()},BR=null,Cq=null,KX.clear(),rR.clear()}function XCt(){QX!==null&&cancelAnimationFrame(QX),Gq!==null&&clearInterval(Gq),QX=null,Gq=null,hw={frames:0,since:0},BR=null,Cq=null,KX.clear()}let W$e=null;function qyn(t){W$e=t}function NQe(){return W$e?(W$e(),!0):!1}let OQe=[];const H$e=new Set;function ZCt(t){OQe=t;for(const r of H$e)r()}function zyn(){return OQe}function Uyn(t){return H$e.add(t),()=>H$e.delete(t)}function Vyn(t){const r=OQe.find(i=>i.id===t);return r?(r.run(),!0):!1}let G$e=null;function Jyn(t){G$e=t}const Wyn=/^vgai\.([^.]+)\.(.+)$/;async function Hyn(t,r){if(G$e)return await G$e(t,r);const i=Wyn.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 la(async()=>{const{invokeViewVerb:l}=await Promise.resolve().then(()=>SMr);return{invokeViewVerb:l}},void 0);return a(i[1],i[2],r)}function QHt(t){return Array.from(document.querySelectorAll("[data-workspace-document-id]")).find(r=>r.dataset.workspaceDocumentId===t&&(Q9e()===null||r.dataset.workspaceViewId===Q9e()))??null}const Q$e=["document","header","shelf","rail","outliner","content"],Gyn={rail:{part:"properties",view:"vgai.properties",title:"Properties"},outliner:{part:"outliner",view:"vgai.outliner",title:"Outliner"},content:{part:"content",view:"vgai.content",title:"Content"}},Qyn={header:{prefix:"document-header",title:"header strip"},shelf:{prefix:"document-shelf",title:"tool shelf"}};function FQe(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 Kyn(t){return document.querySelector(`[data-vgai-part="${t}"]`)}function Yyn(t){const r=t==="rail"||t==="outliner"||t==="content"?Gyn[t]:null;if(r){const i=Kyn(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 Xyn(t)}function Xyn(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=QHt(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=Qyn[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 eEt(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: ${Q$e.filter(i=>i!==t.name).map(i=>`'${i}'`).join(", ")} (pass \`{ scope }\`). The rest of the page is deliberately unreachable.`)}const tEt=400,rEt="rgb(1, 2, 3)",Zyn="rgba(0, 0, 0, 0)";function e0n(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=rEt,t.appendChild(l);try{l.style.backgroundColor=`var(${r})`;const d=getComputedStyle(l).backgroundColor.trim();return d===rEt||d===Zyn?i:d}finally{l.remove()}}function t0n(t,r){const i=getComputedStyle(t),a={};for(const l of r)a[l]=l.startsWith("--")?e0n(t,l):i.getPropertyValue(r0n(l)).trim();return a}function r0n(t){return t.includes("-")?t:t.replace(/[A-Z]/g,r=>`-${r.toLowerCase()}`)}function nEt(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>tEt?`${b.slice(0,tEt)}…`: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:t0n(a,i)}:{}}}function qme(t,r,i){const a=YHt(t,r),l=a[i];if(!l)throw eEt(t,`${JSON.stringify(r)} matched ${a.length} element(s), so index ${i} does not exist`);if(!FQe(t).some(d=>d.contains(l)))throw eEt(t,`${JSON.stringify(r)} resolved outside the document's container`);return l}function n0n(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 i0n(t,r=1){const i=n0n(t),a=Math.max(1,Math.round(r));KHt(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 s0n(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 KHt(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 o0n(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]);KHt(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 a0n(t,r){if(r)return r;const i=document.activeElement;return i instanceof HTMLElement&&FQe(t).some(a=>a.contains(i))?i:t.container}function YHt(t,r){try{return FQe(t).flatMap(i=>Array.from(i.querySelectorAll(r)))}catch(i){throw new Error(`Invalid selector ${JSON.stringify(r)}: ${String(i)}`)}}function LRe(t,r){const i=r.selector===void 0?null:qme(t,r.selector,r.index??0);return a0n(t,i)}function c0n(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 l0n(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 jRe=["query","click","drag","key","paste","select","type"];function u0n(t){const r=t?.action;if(!jRe.includes(r))throw new Error(`Unknown document-probe action ${JSON.stringify(r)}. This door has exactly ${jRe.length} verbs: ${jRe.join(", ")} (\`editor.document.*\`).`);const i=t.scope??"document";if(!Q$e.includes(i))throw new Error(`Unknown scope ${JSON.stringify(i)}. This door addresses exactly these surfaces: ${Q$e.map(a=>`'${a}'`).join(", ")}.`);return Yyn(i)}async function f0n(t){const r=u0n(t),i={name:r.name,id:r.id,title:r.title},a=l=>({scope:i,matched:1,elements:[nEt(l,0)]});switch(t.action){case"query":{const l=YHt(r,t.selector);return{scope:i,matched:l.length,elements:l.slice(0,t.limit??25).map((d,_)=>nEt(d,_,t.styles))}}case"click":{const l=qme(r,t.selector,t.index??0);return i0n(l,t.clicks??1),a(l)}case"type":{const l=LRe(r,t);return s0n(l,t.text,t.replace??!0,t.enter??!0),a(l)}case"drag":{const l=qme(r,t.selector,t.index??0);return o0n(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=LRe(r,t),d=c0n(t);return l.dispatchEvent(new KeyboardEvent("keydown",d)),l.dispatchEvent(new KeyboardEvent("keyup",d)),a(l)}case"select":{const l=qme(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 l0n(l,t.value),a(l)}case"paste":{const l=LRe(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 RQe=[{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 d0n(t){const{liveCanvasFrame:r}=await la(async()=>{const{liveCanvasFrame:i}=await Promise.resolve().then(()=>Lgn);return{liveCanvasFrame:i}},void 0);return r(t)}async function p0n(...t){const{capturePlayComposite:r}=await la(async()=>{const{capturePlayComposite:i}=await Promise.resolve().then(()=>yhn);return{capturePlayComposite:i}},void 0);return r(...t)}async function iEt(){return la(()=>Promise.resolve().then(()=>S9r),void 0)}async function _0n(){return la(()=>Promise.resolve().then(()=>QAn),void 0)}const m0n=new Set(["solid","clay","unlit","wireframe","normals","overdraw"]);function h0n(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=m0e(()=>{gE().some(_=>_.id===t)&&d()}),gE().some(_=>_.id===t)?d():a=window.setTimeout(d,r)})}async function g0n(t){if(t){if(!gE().some(r=>r.id===t)){const r=t.startsWith(she);if(r&&(await(await iEt()).refreshProjectToolContributions(),await h0n(t)),!gE().some(i=>i.id===t)){const i=gE().map(l=>l.id),a=r?(await iEt()).contributionFailureHint(t.slice(she.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 XHt(t){const r=RQe.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(Jze(i),!await xE(()=>iPt()===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 y0n(t,r){return Sb("workspace:scene"),"workspace:scene"}async function v0n(t){let r=!1;if(await xE(()=>(r=C$e(t.id),r||_Ct(t.id)!==null),m9),r)return I_();const i=_Ct(t.id);throw i?new Error(i):new Error(`World document is not registered: ${t.id}`)}async function b0n(t,r){const i=_=>_.filter(g=>g.id===r||g.label===r);let a=[];if(!await xE(()=>{const _=bze(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 A0n(t,r){const i=await h0e(r.kind,t,r);if(i!==null)return i;let a=!1;if(await xE(()=>(a=Sb(r.id),a||mCt(r.id)!==null),m9),a)return r.story!==void 0&&await b0n(r.id,r.story),r.id;const l=mCt(r.id);throw l?new Error(l):new Error(`Workspace document is not available: ${r.id}`)}async function S0n(t,r){const i=await h0e(r.kind,t,r);if(i===null){const{kind:a,...l}=r,d=oRr();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 x0n(t){const r=$7r();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 w0n(t,r){if(!r)return I_();if(!LDr(r.kind))throw new Error(`present-view does not know the document kind "${String(r.kind)}". An EditorView addresses a document by one of: ${uIt.join(", ")}. `+x0n(String(r.kind)));switch(r.kind){case"scene":return y0n();case"world":return v0n(r);case"asset":case"tool":case"document":case"story":case"project-tool":case"generation":return S0n(t,r);case"workspace":return A0n(t,r)}}function C0n(t){const r=t.indexOf(",");return{base64:r>=0?t.slice(r+1):t,mimeType:"image/png"}}const sEt=QHt;function E0n(t,r,i){if(!i?.degenerate)return null;const a=SQe();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 T0n(t,r){const i=AE();if(!i)throw new Error("No active editor document to capture.");const{descriptor:a,title:l}=i,d=lte(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{...C0n(w),document:_,view:d,source:"object3d-document"}}const b=a.id===Sw?MHt()??sEt(a.id):sEt(a.id);if(!b)throw new Error(`Active document surface is not mounted: ${a.id}`);const S=await p0n(b,{canvasFrame:d0n,includeDocumentStyles:a.id!==Sw}),k=E0n(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 k0n(t){return t?Pw(t):null}function I0n(t,r,i){i!==void 0&&(r?r.setGrid(i):t.showGrid!==i&&t.toggleGrid())}function D0n(t,r,i,a){i&&(r?(r.setSkeleton(i==="skeleton"),r.setBounds(i==="bounds"),i==="skeleton"||i==="bounds"?r.setMode("solid"):r.setMode(i)):m0n.has(i)?t.setShadingMode(i):a.push(`Diagnostic ${i} is unavailable for this document.`))}function P0n(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 N0n(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 O0n(t,r,i,a){i.selection&&(r?r.select(i.selection.ids):t.selectMultiple(i.selection.ids)),I0n(t,r,i.viewport?.grid),D0n(t,r,i.viewport?.diagnostic,a),P0n(t,r,i.viewport?.camera,a),N0n(t,r,i,a)}async function vye(t,r,i={}){if(r?.version!==1)throw new Error("present-view requires EditorView version 1.");const a=Object.keys(r).filter(k=>!Q1t.includes(k));if(a.length>0)throw new Error(`present-view does not know ${a.map(k=>`"${k}"`).join(", ")}. An EditorView carries: ${Q1t.join(", ")}. A document's own address (kind, and the fields that kind reads) goes under "document".`);const l=lte(t);if(r.style!==void 0){const k=cU().map(w=>w.id);if(!k.includes(r.style))throw new Error(`present-view requires a style of ${k.join(", ")}, got ${String(r.style)}.`);tUe(r.style)}if(r.workspace!==void 0){if(!AZ(r.workspace))throw new Error(`present-view requires a workspace of ${Qze().join(", ")}, got ${String(r.workspace)}.`);if(wS()!==r.workspace){const k=yPt();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 w0n(t,r.document);await g0n(r.utility);const g=k0n(_);if(g&&_&&await IOr(_),!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_()!==_&&Sb(_),O0n(t,g,r,d),r.panel!==void 0&&await XHt(r.panel);const b=dIt(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 _0n()).showEditorPresentationNotice({presented:S,previousView:l}),S}const bye=new Map;let ZHt=0;const K$e=new Set;function eGt(){ZHt+=1;for(const t of K$e)t()}function F0n(t,r,i){const a=bye.get(t);a&&a.assetPath===r&&a.actions.length===i.length&&a.actions.every((l,d)=>l===i[d])||(bye.set(t,{assetPath:r,actions:i}),eGt())}function R0n(t){bye.delete(t)&&eGt()}function M0n(t){const r=[];for(const i of bye.values())i.assetPath===t&&r.push(...i.actions);return r}function L0n(t){return K$e.add(t),()=>K$e.delete(t)}function oEt(){return ZHt}const j0n=[],aEt=new Set;let B0n=0;function $0n(t){for(const r of j0n)if(r.match(t))return r;return null}function q0n(t){return aEt.add(t),()=>{aEt.delete(t)}}function cEt(){return B0n}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 tGt(t){return`vgai:project-content:v1:${t}`}const fP=[],Y$e=new Set,TY=new Map;let rGt=0;function BRe(){rGt++;for(const t of Y$e)t()}function z0n(t){const r=fP.findIndex(i=>i.owner===t.owner&&i.id===t.id);if(r>=0){const[i]=fP.splice(r,1);i&&(TY.get(i)?.(),TY.delete(i))}return fP.push(t),fP.sort((i,a)=>(i.order??0)-(a.order??0)),TY.set(t,t.subscribe(BRe)),BRe(),()=>{const i=fP.indexOf(t);i<0||(fP.splice(i,1),TY.get(t)?.(),TY.delete(t),BRe())}}const U0n=[];function V0n(){return fP.length===0?U0n:fP}function nGt(t){return Y$e.add(t),()=>{Y$e.delete(t)}}function Aye(){return rGt}function iGt(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 J0n(){const t=B0e();return t?{path:t.path,name:t.name,kind:t.kind,origin:t.origin??"project",...t.sourcePath?{sourcePath:t.sourcePath}:{}}:null}function W0n(t,r){return Xe.useEffect(()=>()=>R0n(t),[t]),Xe.useCallback(i=>{r!==null&&F0n(t,r,i)},[t,r])}function H0n({id:t,title:r,file:i,tool:a,Component:l}){Xe.useSyncExternalStore(j0e,TZ),Xe.useSyncExternalStore(Qye,T8,T8),Xe.useSyncExternalStore(Yye,k8,k8);const d=J0n(),_=W0n(t,d?.path??null),g=Xe.useRef(null),b=Xe.useCallback(k=>{g.current?.(),g.current=k===null?null:I3t(`building ${k.replace(/^building /,"")}`)},[]);Xe.useEffect(()=>()=>g.current?.(),[]);const S=Xe.useCallback(k=>oz({...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:{...kFr,marginBottom:4},children:[z.jsx(So,{icon:gb.tool.extension,tone:"muted",style:{marginRight:4}}),r]}),z.jsx(Fze,{file:i,children:z.jsx(l,{...a?{tool:a}:{},contributionId:t.slice(t.lastIndexOf(":")+1),client:y0e(),surfaces:Sze,account:pze(),play:Kye(),asset:d,setActions:_,notify:S,work:b})})]})}function G0n(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 sGt=32,X$e=new Set,lEt=new Map,uEt=new Map;let $R=null,YX=null,oGt=0,Z$e=0,Qq=0,V8=0,fEt=!1,AP={url:null,progress:0,playing:!1};function Q0n(){for(const t of X$e)t()}function Gz(t){AP.url===t.url&&AP.playing===t.playing&&Math.abs(AP.progress-t.progress)<.002||(AP=t,Q0n())}function MQe(){return $R??=new AudioContext,$R}function K0n(){if(fEt||typeof window>"u")return;fEt=!0;const t=()=>{if(!$R)return;const r=AP.url,i=V8;$R.resume().then(()=>{r&&i===V8&&!YX&&$R?.state==="running"&&lGt(r,i)})};window.addEventListener("pointerdown",t,{capture:!0}),window.addEventListener("keydown",t,{capture:!0})}function LQe(){if(Qq&&typeof cancelAnimationFrame=="function"&&cancelAnimationFrame(Qq),Qq=0,!YX)return;const t=YX;YX=null,t.onended=null;try{t.stop()}catch{}t.disconnect()}function aGt(){if(Qq=0,!AP.playing||!$R||Z$e<=0)return;const t=Math.min(1,($R.currentTime-oGt)/Z$e);Gz({url:AP.url,progress:t,playing:t<1}),t<1&&typeof requestAnimationFrame=="function"&&(Qq=requestAnimationFrame(aGt))}function Y0n(t,r,i){if(i!==V8)return;LQe();const a=MQe(),l=a.createBufferSource(),d=a.createGain();d.gain.value=1,l.buffer=t,l.connect(d),d.connect(a.destination),l.onended=()=>{i===V8&&Gz({url:r,progress:1,playing:!1})},l.start(),YX=l,oGt=a.currentTime,Z$e=t.duration,Gz({url:r,progress:0,playing:!0}),typeof requestAnimationFrame=="function"&&(Qq=requestAnimationFrame(aGt))}async function cGt(t){const r=lEt.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 MQe().decodeAudioData(l.slice(0))})().catch(()=>null);return lEt.set(t,i),i}async function lGt(t,r){K0n();const i=await cGt(t);if(r!==V8)return;if(!i){Gz({url:t,progress:0,playing:!1});return}const a=MQe();a.state==="suspended"&&(await a.resume(),r!==V8)||a.state==="running"&&Y0n(i,t,r)}function X0n(t){return X$e.add(t),()=>X$e.delete(t)}function Z0n(){return AP}function evn(t){const r=++V8;LQe(),Gz({url:t,progress:0,playing:!0}),lGt(t,r)}function tvn(t){t&&AP.url!==t||(V8+=1,LQe(),Gz({url:null,progress:0,playing:!1}))}function rvn(t,r=sGt){const i=`${t}#${r}`,a=uEt.get(i);if(a)return a;const l=cGt(t).then(d=>d?G0n(d.getChannelData(0),r):Array.from({length:r},()=>0));return uEt.set(i,l),l}const dEt=16,nvn=3e3,ivn=500;function GPn(t,r){return r-t>=ivn}function QPn(t){let r=!1;return t.traverse(i=>{!r&&X8(i,"gaussianSplat")&&(r=!0)}),r}function svn(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=nvn;const i=()=>{if(t.sorting){r>0?(r-=dEt,setTimeout(i,dEt)):console.warn("SparkRenderer did not become idle; skipped worker termination.");return}t.dispose()};i()}const y_e=128;let zme=null;const ovn=new Set(["glb","gltf","fbx","obj","dae","stl","ply","spz","bvh","3ds"]);function jQe(t){const r=t.split(/[?#]/,1)[0].toLowerCase(),i=r.slice(r.lastIndexOf(".")+1);return ovn.has(i)?i:void 0}class avn{renderer;scene;camera;cache=new Map;pending=new Map;sparkRenderer=null;constructor(){const r=document.createElement("canvas");r.width=y_e,r.height=y_e,this.renderer=UP(new $P({canvas:r,alpha:!0,antialias:!0,preserveDrawingBuffer:!0})),this.renderer.setSize(y_e,y_e),this.renderer.setPixelRatio(1),this.renderer.outputColorSpace=hv,this.renderer.toneMapping=u9,this.renderer.toneMappingExposure=1,this.scene=new Rye,Fee(this.scene,this.renderer),this.scene.add(new pIr(16777215,.8*V6t));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 jye(35,1,.01,1e3)}async render(r){const i=typeof r=="string"?{url:r}:r,a=i.format??jQe(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=fvn(await uvn(r));if(this.scene.add(i),r.format==="spz"&&!this.sparkRenderer){const{SparkRenderer:w}=await la(async()=>{const{SparkRenderer:N}=await import("./spark.module-uQlq--TY.js");return{SparkRenderer:N}},__vite__mapDeps([46,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=lvn(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 wkt),_=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=cvn(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=>{X8(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),svn(this.sparkRenderer),this.sparkRenderer=null),this.renderer.dispose(),this.renderer.forceContextLoss(),this.cache.clear(),zme=null}}function cvn(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 lvn(t){t.updateWorldMatrix(!0,!0);const r=new xS,i=new xS;return t.traverseVisible(a=>{if(X8(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 uvn(t){switch(t.format){case"glb":case"gltf":{const r=await uU.loadAsync(t.url);return r.scene.animations=[...r.animations],r.scene}case"fbx":{const{FBXLoader:r}=await la(async()=>{const{FBXLoader:i}=await import("./FBXLoader-DzWtiWYm.js");return{FBXLoader:i}},__vite__mapDeps([69,6,50]));return new r().loadAsync(t.url)}case"obj":{const{OBJLoader:r}=await la(async()=>{const{OBJLoader:l}=await import("./OBJLoader-8SrBLZ7J.js");return{OBJLoader:l}},__vite__mapDeps([70,6])),i=t.materialUrl??await _vn(t.url),a=new r;if(i){const{MTLLoader:l}=await la(async()=>{const{MTLLoader:_}=await import("./MTLLoader-D8SKGOsv.js");return{MTLLoader:_}},__vite__mapDeps([71,6])),d=await new l().loadAsync(i);d.preload(),a.setMaterials(d)}return a.loadAsync(t.url)}case"dae":{const{ColladaLoader:r}=await la(async()=>{const{ColladaLoader:l}=await import("./ColladaLoader-CyOCKXko.js");return{ColladaLoader:l}},__vite__mapDeps([72,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 la(async()=>{const{STLLoader:a}=await import("./STLLoader-U-3fQm8v.js");return{STLLoader:a}},__vite__mapDeps([73,6])),i=await new r().loadAsync(t.url);return new NA(i,new ez({color:7710680,roughness:.75}))}case"ply":{const{PLYLoader:r}=await la(async()=>{const{PLYLoader:l}=await import("./PLYLoader-BXUWXVtV.js");return{PLYLoader:l}},__vite__mapDeps([74,6])),i=await new r().loadAsync(t.url);if(i.index||i.hasAttribute("normal"))return i.hasAttribute("normal")||i.computeVertexNormals(),new NA(i,new ez({color:i.hasAttribute("color")?16777215:12112027,vertexColors:i.hasAttribute("color"),roughness:.8,side:gkt}));i.computeBoundingBox();const a=i.boundingBox?.getSize(new Tc).length()??1;return new Gqe(i,new hkt({color:i.hasAttribute("color")?16777215:12112027,vertexColors:i.hasAttribute("color"),size:Math.max(a/220,1e-4),sizeAttenuation:!0}))}case"spz":return j6t(t.url);case"bvh":{const{BVHLoader:r}=await la(async()=>{const{BVHLoader:d}=await import("./BVHLoader--2mLoe3e.js");return{BVHLoader:d}},__vite__mapDeps([75,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 la(async()=>{const{TDSLoader:i}=await import("./TDSLoader-BtiaQ4S3.js");return{TDSLoader:i}},__vite__mapDeps([76,6]));return new r().loadAsync(t.url)}}}function fvn(t){if(dvn(t))return t;t.updateWorldMatrix(!0,!0);const r=new dIr(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 dvn(t){let r=!1;return t.traverseVisible(i=>{!r&&pvn(i)&&(r=!0)}),r}function pvn(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 _vn(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 mvn(){return zme||(zme=new avn),zme}const BQe={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)"},hvn={folder:hee,model:oDr,prefab:gee,component:Ukt,audio:rIt,image:VIr,video:iDr,json:iIt,unknown:KIr,source:cIt};function DP({kind:t,size:r=24}){return z.jsx(So,{icon:hvn[t],style:{fontSize:r,color:BQe[t]}})}const gvn=100,yvn=50,vvn=new D4t(t=>{const r=jQe(t);return r?mvn().render({url:t,format:r,background:"neutral",output:"webp"}):Promise.reject(new Error(`No model preview loader for ${t}.`))},2);function uGt(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 SUe().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=vvn.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 fGt({url:t}){const r=uGt(t,gvn);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 ${vhe[2]}`,borderTopColor:BQe.model,borderRadius:"50%"}})})}function bvn({url:t,name:r}){const[i,a]=Xe.useState(()=>Array.from({length:sGt},()=>.15)),l=Xe.useSyncExternalStore(X0n,Z0n);Xe.useEffect(()=>{let g=!1;return rvn(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=BQe[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 dGt(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 KPn(t,r,i,a,l){return t==="fit"?dGt(r,i,a,l):t}function Avn(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 _=lqr(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 pGt({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?dGt(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||Avn(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 _Gt={fontSize:11,color:od[3],marginBottom:2},Svn={fontSize:11,color:od[1],wordBreak:"break-all"};function $Re({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 FPt().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(H0n,{id:i.id,title:i.title,file:i.file,tool:i.tool,Component:i.Component},`${i.id}:${i.version}`):null})}function pEt(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:_Gt,children:t}),z.jsx("div",{style:Svn,children:r})]})}function xvn({asset:t}){const r=t.capabilities?.editor==="environment";Xe.useSyncExternalStore(nGt,Aye,Aye);const i=t.componentPreview,a=i?iGt({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:Ize.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(Cvn,{path:t.path,name:t.name}):t.kind==="video"?z.jsx(wvn,{path:t.path}):t.kind==="model"?z.jsx(fGt,{url:t.path}):z.jsx(a9,{kind:t.kind,name:t.name,variant:"cell"})})}function wvn({path:t}){return z.jsx("video",{src:t,muted:!0,preload:"metadata",style:{width:"100%",height:"100%",objectFit:"contain"}})}function Cvn({path:t,name:r}){const{sheetPath:i,frameName:a}=q0e(t),[l,d]=Xe.useState(null);return Xe.useEffect(()=>{if(!a){d(null);return}let _=!1;return fetch(`/${uNt(i)}`).then(g=>g.ok?g.text():null).then(g=>{if(_||!g)return;const b=VUe(g);d(b?.frames.find(S=>S.name===a)??null)}).catch(()=>{_||d(null)}),()=>{_=!0}},[a,i]),l?z.jsx(pGt,{sheetUrl:`/${i}`,frame:l,maxEdge:96}):z.jsx("img",{src:t.split("#")[0],alt:r,style:{width:"100%",height:"100%",objectFit:"contain"}})}function Evn({asset:t}){const[r,i]=Xe.useState(null),{sheetPath:a,frameName:l}=q0e(t.path);return Xe.useEffect(()=>{if(i(null),t.kind!=="image"||t.capabilities?.editor==="environment")return;let d=!1;if(l)return fetch(`/${uNt(a)}`).then(g=>g.ok?g.text():null).then(g=>{if(d||!g)return;const b=VUe(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 Tvn(){Xe.useSyncExternalStore(q0n,cEt,cEt);const t=B0e();if(!t)return null;const r=$0n(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 ${vhe[1]}`,display:"flex",flexDirection:"column",gap:6},children:[z.jsx(r.View,{asset:t}),z.jsx($Re,{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(wNt,{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($Re,{asset:t})]}):z.jsxs("div",{"data-testid":"inspector-asset-selection",style:{pointerEvents:"auto",padding:8,borderBottom:`1px solid ${vhe[1]}`,display:"flex",flexDirection:"column",gap:6},children:[z.jsx(Evn,{asset:t}),z.jsx("div",{style:{..._Gt,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:pEt(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:pEt(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($Re,{asset:t})]})}function kvn(t){return M0n(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 Ivn(){const t=B0e();if(t===null)return null;const r=t0e();return r&&(r.adapter!==null||r.nodeId!==null)?null:{quickActions:kvn(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:uMe,title:"Preview",icon:jY,order:P3t,body:{kind:"preview",render:()=>z.jsx(xvn,{asset:t})}},{id:"asset-selection",title:"Asset",icon:vee,order:mZ,body:{kind:"custom",render:()=>z.jsx(Tvn,{})},keepMounted:!0}]}}const Dvn={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 Pvn(t){const r=Dvn[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 Nvn={ok:sDr,gap:Wkt,na:wDr,info:vee},Ovn={ok:Oo.semantic.success,gap:Oo.semantic.warning,na:Oo.content.dim,info:Oo.content.dim};function Fvn({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:Ovn[t.status],paddingTop:1},children:z.jsx(So,{icon:Nvn[t.status]})}),z.jsxs("div",{style:{minWidth:0},children:[z.jsx("div",{style:{color:Oo.content.primary,fontWeight:600},children:Pvn(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 Rvn({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(Fvn,{row:i},i.seam))]})}function Mvn(t){return{id:"ingest-coverage",title:"Ingest coverage",icon:cDr,order:9e3,description:`${t.summary.gaps} gap${t.summary.gaps===1?"":"s"}`,defaultOpen:!0,testId:"ingest-coverage-section",body:{kind:"custom",render:()=>z.jsx(Rvn,{report:t}),data:{summary:t.summary,rows:t.rows}}}}function Lvn(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 mGt="vgai-inspector-presentation-v2";function hGt(){try{return typeof window>"u"?null:window.localStorage}catch{return null}}function jvn(t){return t==="card"||t==="column"||t==="properties"}function Bvn(){const t=hGt()?.getItem(mGt);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 XX=null,gGt=0;const eqe=new Set;function yGt(){return XX===null&&(XX=Bvn()),XX}function tqe(t){return yGt()[t]??null}function vGt(t,r){if(tqe(t)!==r){XX={...yGt(),[t]:r},gGt++;try{hGt()?.setItem(mGt,JSON.stringify(XX))}catch{}for(const i of eqe)i()}}function $vn(t){return eqe.add(t),()=>{eqe.delete(t)}}function _Et(){return gGt}function qvn(t,r,i=null){return r??i??t}function bGt(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 rqe(t){return t==="three"||t==="canvas"||t==="dom"?t:null}function zvn(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?rqe(l.kind):null}function Uvn(t){const r=gze();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?rqe(l[0]?.kind??""):null;if(d)return d;const _=zvn(i,t);if(_)return _}return rqe(X1e()??"")??"three"}function $Qe(t,r){r(t);for(const i of t.children)O0e(i)||$Qe(i,r)}const qRe=new xS;function AGt(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 mEt=new SS,zRe=new xS;function Vvn(t,r,i){for(let a=0;a<r.count;a++)r.getMatrixAt(a,mEt),zRe.copy(i).applyMatrix4(mEt).applyMatrix4(r.matrixWorld),AGt(zRe)&&t.union(zRe)}function SGt(t,r){const i=r.geometry;if(!i)return;const a=Jvn(r,i);if(a){if(r.isInstancedMesh){Vvn(t,r,a);return}qRe.copy(a).applyMatrix4(r.matrixWorld),AGt(qRe)&&t.union(qRe)}}function Jvn(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 Wvn(t,r){return $Qe(r,i=>{i.updateWorldMatrix(!1,!1),SGt(t,i)}),t}const v_e=new xS;function xGt(t){const r=t.material;return r?Array.isArray(r)?r:[r]:[]}function Hvn(t){const r=xGt(t);return r.length>0&&r.every(i=>i.depthWrite===!1)}function Gvn(t){const r=xGt(t);return r.length>0&&r.every(i=>i.side===ukt)}function Qvn(t,r=[]){return $Qe(t,i=>{i.updateWorldMatrix(!1,!1),v_e.makeEmpty(),SGt(v_e,i),!v_e.isEmpty()&&r.push({box:v_e.clone(),overlay:Hvn(i),enclosure:Gvn(i)})}),r}function YPn(t,r=[]){for(const i of Qvn(t))r.push(i.box);return r}function wGt(t,r=new xS){return r.makeEmpty(),Wvn(r,t)}class XPn extends _Ir{entityObject;constructor(r,i){super(new xS,i),this.entityObject=r,this.update()}update(){wGt(this.entityObject,this.box)}}function Kvn({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 qQe(t){const r=new H8(...t);r.lengthSq()<Number.EPSILON?r.identity():r.normalize();const i=new Qqe().setFromQuaternion(r,"XYZ");return[vb.radToDeg(i.x),vb.radToDeg(i.y),vb.radToDeg(i.z)]}function Yvn(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 H8().setFromEuler(new Qqe(vb.degToRad(i[0]),vb.degToRad(i[1]),vb.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 Xvn(t,r,i){const a=qQe(t.rotation);a[r]=i;const l=new H8().setFromEuler(new Qqe(vb.degToRad(a[0]),vb.degToRad(a[1]),vb.degToRad(a[2]),"XYZ"));return{position:[...t.position],rotation:[l.x,l.y,l.z,l.w],scale:[...t.scale]}}const Zvn={x:"#e0726d",y:"#83bd66",z:"#6390dd"};function URe({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(q_e,{label:r,style:{padding:"4px 8px"},children:t.map(({axis:j,name:J})=>z.jsx(AX,{testId:`${a}-${J}`,label:J,labelColor:Zvn[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 e1n({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?.(Xvn(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(S5r,{children:[z.jsx(URe,{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(URe,{axes:t==="2d"?[{axis:2,name:"z"}]:S,label:t==="2d"?"Rotation (degrees)":"Rotation",testidPrefix:"ingest-rotation",values:qQe(r.rotation),step:1,precision:1,...P("rotation"),onBegin:d,onPreview:_&&N(_),onCommit:N(g)}),z.jsx(URe,{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 tbe(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 t1n=Xe.lazy(()=>la(()=>import("./InspectorObjectPreview-CO-GVXfu.js"),__vite__mapDeps([77,1,2,48,3,4,8,9,10,43,6,7,41,14,44,42,11])).then(t=>({default:t.InspectorObjectPreview}))),r1n=Xe.lazy(()=>la(()=>import("./InspectorCanvasPreview-CLDhscy0.js"),__vite__mapDeps([78,1,2,3,4])).then(t=>({default:t.InspectorCanvasPreview})));function n1n({object:t,displayName:r,previewKey:i,actions:a,mode:l="section"}){const d=l==="thumbnail",_=tbe(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(t1n,{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 i1n({source:t,entry:r,previewKey:i,actions:a,mode:l="section"}){const d=l==="thumbnail",_=tbe(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 s1n({capture:t,previewKey:r,actions:i,mode:a="section"}){const l=a==="thumbnail",d=tbe(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(r1n,{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 o1n(t){return t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function a1n(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:o1n(l),properties:a.get(l)}))}}function c1n(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 l1n=1e-4,u1n="World-anchored — content is placed in world space by the game each frame; moving this container offsets future placements away from their source.";function CGt(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 f1n(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)>l1n)return!1}return!0}const hEt=new xS,gEt=new Tc;function d1n(t,r){const i=CGt(t);if(i===0)return null;const a=p1n(t,r);return{units:i,detail:EGt(i),worldAnchored:a,note:a?u1n:null}}function p1n(t,r){if(!r||r.isEmpty()||!f1n(t.matrixWorld))return!1;const i=t.geometry;return i.boundingBox===null&&i.computeBoundingBox(),i.boundingBox?(hEt.copy(i.boundingBox),r.getCenter(gEt),!hEt.containsPoint(gEt)):!1}function _1n(t){const r=CGt(t);return r===0?null:EGt(r)}function EGt(t){return`${t} instanced unit${t===1?"":"s"}`}const m1n=14,h1n=[[/physic|rigid|collid/i,lDr],[/material/i,PIr],[/light/i,zkt],[/camera/i,qye],[/audio|sound|music/i,rIt],[/player|character|humanoid|person/i,aDr],[/anim|state|machine/i,JIr]];function g1n(t){for(const[r,i]of h1n)if(r.test(t))return i;return gee}function y1n(t){return r=>Xe.createElement(n1n,{object:t.object,displayName:t.displayName,previewKey:t.previewKey,actions:t.actions,...r?{mode:r}:{}})}function v1n(t){return r=>Xe.createElement(i1n,{source:t.picture.source,entry:t.picture.entry,previewKey:t.previewKey,actions:t.actions,...r?{mode:r}:{}})}function b1n(t){return r=>Xe.createElement(s1n,{capture:t.capture,previewKey:t.previewKey,actions:t.actions,...r?{mode:r}:{}})}function A1n(t){return t.object?.isCamera?null:t.object?y1n({object:t.object,displayName:t.displayName,previewKey:t.previewKey,actions:t.actions}):t.canvasCapture?b1n({capture:t.canvasCapture,previewKey:t.previewKey,actions:t.actions}):t.picture?v1n({picture:t.picture,previewKey:t.previewKey,actions:t.actions}):null}function VRe(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 S1n={position:[0,0,0],rotation:[0,0,0,1],scale:[1,1,1]};function x1n(t,r,i,a){if(O3t(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 TGt(t,r,i,a){const l=new Set,d=new Map,_=[];for(const g of t){const b=x1n(g,r,i,a).filter(k=>!l.has(k.id)),S=(O3t(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 kGt(t,r,i){return i===void 0?[...t]:t.filter(a=>r.get(a.id)===i.owner||i.builtins.includes(a.id))}function nqe(t){const{adapter:r,nullSubject:i}=t,{sections:a,claimed:l,owners:d}=TGt(r?t.contributions??[]:[],r,null,null),_=kGt([...(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:Mze(t.surface)},quickActions:i?.quickActions??[],related:[],sections:_}}function w1n(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 C1n(t){const{adapter:r,nodeId:i,node:a,contributions:l,onEdit:d}=t;if(i===null)return nqe({nullSubject:t.nullSubject??null,surface:t.surface,contributions:l,adapter:r,rail:t.rail});const{sections:_,claimed:g,owners:b}=TGt(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=t4t(r,i,cr,Yt);return d(),Lr},...r.inspector?.remove?{remove:cr=>{const Yt=z9r(r,i,cr);return d(),Yt}}:{}},k=r.inspector?.properties(i)??[],w=k.find(cr=>cr.path==="name"),{ungrouped:N,groups:P}=a1n(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?Kqe:Xqe,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:Vkt,placement:"identity",run:async()=>{await ZPt(r,i),d()}});const ue=new Map;ue.set(IFe,J);for(const cr of P)ue.set(pAt(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?iGt({name:ge,path:se?.anchored===!0?se.file:"",surface:"canvas"}):null,tt=G.filter(cr=>cr.placement==="preview"),Ct=A1n({object:de,canvasCapture:t.canvasPreview,picture:qe,displayName:a?.label??i,previewKey:i,actions:tt});!g.has(uMe)&&Ct!==null&&fe.push({id:uMe,title:"Preview",icon:f9,order:P3t,body:{kind:"preview",render:Ct}});const Ot=c1n(r,i);if(!g.has(dAt)&&Ot!==null){const cr=r.transforms?.get(i)??S1n,Yt=de?d1n(de,wGt(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:qQe(cr.rotation),scale:[...cr.scale]};fe.push({id:dAt,title:"Transform",icon:Gkt,order:KFr,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[VRe(on)],set:(on,gr)=>{if(!r.transforms)return;const An=Yvn(cr,VRe(on),gr);QMe(r,i),tme(r,i,An);const Rn=KMe(r,i);return d(),Rn},...r.transforms?.remove?{remove:on=>{const gr=XPt(r,i,VRe(on));return d(),gr}}:{}}},render:()=>Xe.createElement(e1n,{dimensions:Ot,transform:cr,readOnly:!r.capabilities.transform,channelEditability:Lr,...Yt?.note?{note:Yt.note}:{},onBegin:()=>{QMe(r,i)},onPreview:on=>{tme(r,i,on)},onCommit:on=>{tme(r,i,on),KMe(r,i),d()}})}})}g.has(IFe)||(J.length>0&&fe.push({id:IFe,title:"Properties",icon:Qkt,order:mZ,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:pAt(cr.groupId),title:cr.name,icon:g1n(cr.name),order:N3t+Yt,description:Lr>0?`${Lr} set of ${cr.properties.length}`:`${cr.properties.length} properties`,defaultOpen:Lr>0&&cr.properties.length<=m1n,testId:`ingest-group-${cr.groupId}`,body:{kind:"fields",fields:cr.properties,io:S}})}));const vt=t.stories;!g.has(D3t)&&vt&&fe.push(E1n(vt)),fe.push(..._.map(cr=>w1n(cr,S,ue))),fe.sort((cr,Yt)=>cr.order-Yt.order);const Et=kGt(fe,b,t.rail),Tt=u4t(r,i),Le=f4t(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:Mze(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 E1n(t){return{id:D3t,title:t.title??"Stories",icon:oIt,order:YFr,body:{kind:"custom",render:()=>Xe.createElement(Kvn,{stories:t.stories,activeStoryId:t.activeStoryId,onApplyStory:t.onApplyStory,isolation:t.isolation,unavailableReason:t.unavailableReason??null})}}}const T1n=["project-tool","tool-contribution"];function k1n(t){const{activeDocumentKind:r,documentSelection:i}=t;return r===null||!T1n.includes(r)?!1:i===null}function yEt(t){const{subject:r,surface:i,available:a,override:l,workspaceDefault:d=null}=t,_=r.presentation.preferred??Mze(),g=qvn(_,l,d);return{subject:r,surface:i,presentation:g,available:a,card:a&&g==="card",column:g!=="card"}}const I1n="game",D1n=3,P1n=Object.freeze({none:!0});function N1n(t){const r=Object.getPrototypeOf(t);return r===Object.prototype||r===null}function uee(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>=D1n)return{kind:"opaque",type:vEt(t)};if(Array.isArray(t))return t.map(d=>uee(d,r+1));const a=t;if(!N1n(a))return{kind:"opaque",type:vEt(a)};const l={};for(const[d,_]of Object.entries(a))_!==void 0&&(l[d]=uee(_,r+1));return l}function vEt(t){return t.constructor?.name??"object"}function bEt(t,r){let i;try{i=r.get(t.path)}catch{i=void 0}return{path:t.path,label:t.label,type:t.type,...lMe(i)?{mixed:!0}:{},...!lMe(i)&&i!==void 0?{value:uee(i)}:{},...t.defaulted!==void 0?{defaulted:t.defaulted}:{},...t.readonly!==void 0?{readonly:t.readonly}:{},...t.readonly?{readonlyReason:Rze(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=>uee(a))}:{}}}function AEt(t){const r={};for(const[i,a]of Object.entries(t))a!==void 0&&(r[i]=uee(a));return r}function O1n(t){const r=t.body;if(r.kind==="fields")return{kind:"fields",fields:r.fields.map(i=>bEt(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:AEt(r.data)};if(r.kind==="custom"&&r.editable!==void 0){const i=r.editable;return{kind:"fields",fields:i.fields.map(a=>bEt(a,i.io)),...r.data!==void 0?{data:AEt(r.data)}:{}}}return{kind:r.kind,id:t.id,title:t.title}}function F1n(t){return{id:t.id,title:t.title,order:t.order,...t.description!==void 0?{description:t.description}:{},body:O1n(t)}}function R1n(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(F1n)}}const SEt=new WeakMap;function M1n(t){const r=SEt.get(t);if(r)return r;const i=async a=>t.captureImage(a);return SEt.set(t,i),i}function L1n(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?M1n(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 L1n(a)?l=>a.previewImage(r,l,l):null}function B1n(){const t=I_();if(t===null)return null;const r=Lmn(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 $1n(t){const{store:r,adapter:i,documentSelection:a,surface:l}=t,d=Ivn();if(d!==null)return{subject:nqe({nullSubject:d,surface:l}),available:!0};const _=Lvn(a,r.selectedEntityIds,i),g=_?i.hierarchy.node(_):null;if(_!==null&&g===null)return{subject:nqe({nullSubject:null,surface:l}),available:!1};const b=()=>r.notifyIngestEdit(),S=_?null:pMr({adapter:i,surface:l,store:r,onEdit:b}),k=_?g?hAt(g,i):[]:hAt(null,i,{nullSubjectId:S?.id??null});return{subject:C1n({adapter:i,nodeId:_,node:g,surface:l,contributions:k,..._?{}:{nullSubject:S},previewObject:(_===null||l==="asset-lab"?null:fte(i,r.objectMap,_))??null,canvasPreview:j1n(i,_,l),assetDocument:_&&r.objectMap.has(_)?{open:()=>INt(r,_)}:null,stories:cMr(i,g,_),...B1n()??{},...a===null&&_!==null&&r.selectedEntityIds.size>1?{alsoSelected:r.selectedEntityIds.size-1}:{},onEdit:b}),available:_!==null||S!==null||k.length>0}}function rbe(t){const r=Uvn(t),{adapter:i,documentSelection:a}=wm(t),l=$1n({store:t,adapter:i,documentSelection:a,surface:r}),{subject:d}=l,_=l.available&&(d.id!==I1n||d.sections.length>0)&&!k1n({activeDocumentKind:AE()?.descriptor.kind??null,documentSelection:a}),g=I_()===Sw?EQe():null;if(g){const b=Mvn(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 yEt({subject:S,surface:r,available:!0,override:tqe(r),workspaceDefault:wP().inspector??null})}return yEt({subject:d,surface:r,available:_,override:tqe(r),workspaceDefault:wP().inspector??null})}function nbe(t){const{subject:r,surface:i,presentation:a,available:l}=rbe(t);return l?R1n(r,{surface:i,presentation:a}):P1n}async function q1n(t,r){const{subject:i,available:a}=rbe(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(),nbe(t)}function z1n(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 U1n(t,r,i){const a=IGt(t,r);z1n(a.field,i);const l=await a.io.set(r,i)??Uhe;return{subject:nbe(t),write:l}}function IGt(t,r){const{subject:i,available:a}=rbe(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: ${Rze(g.field)}`);return g}class iqe extends Error{constructor(r){super(r),this.name="InspectionRemovalUnavailableError"}}async function V1n(t,r){const i=IGt(t,r);if(i.field.resettable!==!0)throw new iqe(`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 iqe(`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)??Uhe;return{subject:nbe(t),write:a}}let J1n=[];const xEt=new Set;function ZPn(t){return xEt.add(t),()=>xEt.delete(t)}function DGt(){return J1n}function W1n(){const t=DGt();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 H1n(t){return t.liveMounted?t.livePlaying?t.storePlayState==="paused"?"paused":"playing":"paused":"stopped"}async function G1n(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 Sye="console";function Q1n(t){let r=kZ().length>0;const i=iNt(()=>{const d=kZ().length>0;d&&!r&&wP().drawer!=="hidden"&&hE(Sye),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(Sye)),a=_});return()=>{i(),l()}}function ibe(){W7r(Sye)}function sbe(){hE(Sye)}const K1n=new Map;function Y1n(){return[...K1n].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 X1n=new Set(["state","stateAll","providers","commands","events","snapshot"]);function Z1n(t){if(t.type!=="bridge-call")return[];const r=t.method;if(typeof r!="string"||!X1n.has(r))return[];const i=t.instance;try{const a=AOr(i).debug;if(a===void 0)return[];const l=[fOr(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 ebn(t,r,i){const a=Z1n(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":d3r(t.type)??f3r(t.type),playFullReport:r&&!l&&a.length>0?"explicit":r&&t.type==="bridge-call"&&t.method==="invoke"?"if-content-changed":"none"}}function tbn(t,r,i,a){return t==="none"?!1:!(t==="if-content-changed"&&r==="none"&&i===a)}function wEt(t,r){const i=eO(t);return i.hierarchy.node(r)!==null||fte(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 JRe(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 rbn(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 nbn(){return typeof document>"u"?null:{visibility:document.visibilityState,focused:document.hasFocus(),reportedAt:Date.now()}}const ibn=["entities","entityCount","ontologyInvariants"];function sbn(t){const r={...t};for(const i of ibn)delete r[i];for(const i of zgn())delete r[i];return{...r,_statePatch:!0}}function CEt(t,r=null){const i=kZ(),a=I_(),l=a?Pw(a)?.presentation():void 0,d=zUe(t),_=T3t.getSnapshot(),g=r?.entities??$0e(t);return{playState:H1n({storePlayState:t.playState,liveMounted:kQe(),livePlaying:Z1e()}),mountFailures:i.map(b=>({...b})),moduleSplits:Qgn().map(b=>({path:b.path,urls:[...b.urls]})),adapter:wb(),readiness:DGt().map(b=>({...b})),readinessWarning:W1n(),worldAdoption:Y1n().map(b=>({...b})),presence:nbn(),pageErrors:obn(),consoleErrors:abn(),sessionErrors:cbn(),sessionWarnings:lbn(),rendererResources:{hostLive:Tjr(),interactive:lyn(),inspectorPreview:Djr()},ontologyInvariants:r?.ontologyInvariants??GHt().map(b=>({...b})),...qgn(r),selectedEntityId:d[0]??null,selectedEntityIds:d,selectedCreationSite:Z$r(t),selectedWriteAnchorKind:eqr(t),activeViewportTab:t.activeViewportTab,activeDocumentId:a,activeUtilityId:V7r(),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&&TNt(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:qUe(t),saveState:sNt(t),camera:rbn(t),entities:g,viewportActivationTimings:WOr()}}function PGt(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 EEt(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<TEt||S>J$?`${String(t.type)}: "${b}" must be ${TEt}-${J$} — ${kEt}`: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 — ${kEt}`}:{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 TEt=64,J$=1024,kEt="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 zQe(t){const r=AQe();return!r||t<r.startedAt?!1:r.endedAt===null||t<=r.endedAt}function obn(){return ua.getEntries().filter(t=>t.level==="error"&&t.source==="runtime"&&zQe(t.timestamp)).slice(-100).map(t=>t.count>1?`${t.message} (×${t.count})`:t.message)}const IEt=200;function abn(){return UQe(ua.getEntries().filter(t=>t.level==="error"&&t.source!=="runtime"&&zQe(t.timestamp)))}function UQe(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>IEt?`${a.message.slice(0,IEt)}…`:a.message;return`${l}${_}${d}`});return{count:r,recent:i}}function cbn(){return UQe(ua.getEntries().filter(t=>t.level==="error"&&!zQe(t.timestamp)))}function lbn(){return UQe(ua.getEntries().filter(t=>t.level==="warn"))}async function ubn(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 x3t(i);const a=pZ(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 fbn(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=cNt("capture-asset-preview",j);if(typeof X=="string")return{ok:!1,error:X};const G=lNt("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=XBr(k)}catch(se){return{ok:!1,error:se instanceof Error?se.message:String(se)}}const xe=ome(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&&ome(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"?fte(eO(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=ome(ge.forward),tt={...typeof _=="number"?{width:_}:{},...typeof g=="number"?{height:g}:{},...qe?{refForward:qe}:{}};return{ok:!0,data:{...typeof i=="string"?await L$r(i,ge.glbBase64,tt):await eNt(fe,ge.glbBase64,tt)}}}return ee!==void 0?{ok:!0,data:{...typeof l=="string"?await k$r(l,ee,se):typeof i=="string"?await N$r(i,ee,se):BUe(fe,ee,se)}}:S==="source"?{ok:!0,data:{...typeof i=="string"?await D$r(i,xe,se):Q6t(fe,xe,se)}}:ue?{ok:!0,data:{...b$r(fe,ue,se)}}:typeof l=="string"?{ok:!0,data:{...await T$r(l,se)}}:{ok:!0,data:{...typeof i=="string"?await Z6t(i,se):M0e(fe,se)}}}catch(se){return{ok:!1,error:se instanceof Error?se.message:String(se)}}}async function dbn(t,r,i){rqr(r.type);const a=wQe(r);if(a)return a;if(r.type==="play"||r.type==="restart"){const _=kZ();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=xIt(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 PGt(r,_)}if(!rze(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 Ygn(),{ok:!0};case"select":{const _=r.id??null;if(_!==null){const g=wEt(t,_);if(g)return{ok:!1,error:g}}JRe(t,_?[_]:[],i);break}case"select-multiple":{const _=r.ids;for(const g of _){const b=wEt(t,g);if(b)return{ok:!1,error:b}}JRe(t,_,i);break}case"select-all":{JRe(t,$0e(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=eO(t);if(b.hierarchy.node(_)!==null&&b.rects){t.focusOnEntity(_);break}if(!fte(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 XHt(_)}}}catch(_){return{ok:!1,error:_ instanceof Error?_.message:String(_)}}case"active-tab":{const _=r.key;if(_!=="__inspector__"&&!Sb(_)){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 kNt(g,_))return{ok:!1,error:`Asset document did not finish mounting its Inspector: ${g}`};break}case"close-asset-tab":{const _=r.key;TNt(_)&&K8(_);break}case"toggle-command-palette":NQe();break;case"toggle-console":ibe();break;case"page-reload":return setTimeout(()=>{window.location.reload()},0),{ok:!0,data:{scheduled:!0}};case"set-workspace":{const _=r.workspace;if(!AZ(_))return{ok:!1,error:`set-workspace requires one of ${Qze().join(", ")}, got ${String(_)}.`};if(wS()===_)return{ok:!0,data:{workspace:_,applied:!0}};const g=yPt().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=cU().map(S=>S.id);if(typeof _!="string"||!g.includes(_))return{ok:!1,error:`set-style requires one of ${g.join(", ")}, got ${String(_)}.`};tUe(_);const b=jhe();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."}:r0e(_)?(wPt(_),{ok:!0,data:{material:uz(),style:jhe()}}):{ok:!1,error:`set-appearance material must be one of ${_5r().map(b=>b.id).join(", ")}, got ${String(_)}.`}}case"present-view":try{return{ok:!0,data:{...await vye(t,r.view)}}}catch(_){return{ok:!1,error:_ instanceof Error?_.message:String(_)}}case"current-view":return{ok:!0,data:{view:lte(t)}};case"inspect":return{ok:!0,data:{subject:nbe(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 q1n(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 Hyn(_,r.args);return{ok:!0,data:{result:g===void 0?null:g}}}catch(_){return{ok:!1,error:_ instanceof Error?_.message:String(_)}}case"hierarchy":{const _=JCt();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:Wgn(_,{playState:t.playState,activeViewportTab:t.activeViewportTab})}}}case"expand-hierarchy-all":case"collapse-hierarchy-all":{const _=r.type==="expand-hierarchy-all",g=JCt();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=Vgn();_?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 U1n(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 V1n(t,_);return{ok:!0,data:{subject:g.subject,write:g.write}}}catch(_){return _ instanceof iqe?{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=zUe(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=v0e(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 dUe(g,S):await zhe(g,w())}};case"duplicate":{if(S.length>1&&P.duplicateMany)return{ok:!0,data:{write:await i4t(g,S)}};const j=b0e(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 PR(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 pUe(g,w(),j)}}}case"wrap":return P.wrap?{ok:!0,data:{write:await A0e(g,w(),N("tag"))}}:{ok:!1,error:"structure-op: this adapter has no `wrap`."};case"unwrap":return P.unwrap?{ok:!0,data:{write:await S0e(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=x0e(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=_Ue(g,w());return{ok:!0,data:{ids:j.ids,write:await j.ack}}}case"copy":return P.copy?{ok:!0,data:{copied:await w0e(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 C0e(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 E0e(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 f0n(r.step)}}}catch(_){return{ok:!1,error:_ instanceof Error?_.message:String(_)}}case"capture-active-document":{const _=EEt(r);if("error"in _)return{ok:!1,error:_.error};try{return r.view&&await vye(t,r.view),{ok:!0,data:{...await T0n(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 Bgn(t,_===void 0?void 0:{scale:_})}}}catch(g){return{ok:!1,error:g instanceof Error?g.message:String(g)}}}case"capture-viewport":{const _=EEt(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 fbn(t,r);case"document-table":{const _=wb();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=ebe(),b=g?wb()?.scenes.entries.find(N=>N.id===_):void 0,S=g?async N=>await FHt(N)??{ok:!1,error:"No running lane can remount with a selection."}:void 0,w=(b?await G1n(b,{scenes:CQe,activateGameDocument:()=>Sb(Sw),gameDocumentId:Sw,...S?{remountSelection:S}:{}}):null)??await Ymn(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 ubn(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 pbn(t,r){const i=VP();let a=null,l=-1;const d=new Set;let _=!1,g=null,b=null,S=null;const k=()=>{Vpe()===null&&(a=CEt(t),l=t.contentVersion,V2t(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=GCt(()=>{w=null,_=!1,k()})},250)},J=cr=>{if(t.contentVersion!==cr){j();return}P(),b=cr,S=setTimeout(P,1e3)},X=()=>ebe()&&t.playState==="playing",G=cr=>{(cr!==null||b!==null&&t.contentVersion!==b||_&&t.contentVersion!==l)&&j()},ee=(cr,Yt,Lr)=>X()?(tbn(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(Vpe()!==null)return;if(a===null){k();return}const nn=CEt(t,a);a=nn,V2t(sbn(nn)),cr!=="none"&&(ee(Yt,Lr,cr)||(N(),P(),_=!1,!(cr==="if-content-changed"&&t.contentVersion===l)&&w===null&&(w=GCt(()=>{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=DQe(qe),Ot=YP(qe),vt=VOr(qe);k(),Jpe(!0),VFr(tzr),i.addEventListener("open",()=>{xe("if-content-changed"),Jpe(Vpe()===null)});const Et=JUe(cr=>{Jpe(cr===null)});i.addEventListener("editor-command",cr=>{try{const Yt=JSON.parse(cr.data),Lr=Yt._requestId,nn=t.contentVersion,on=Vpe();if(on!==null){const An=mqr(on,String(Yt.type));Lr&&J2t(Lr,!1,An);return}Lr&&ezr(Lr);let gr;dbn(t,Yt,{deferPresentation:An=>{gr=An},...r?{history:r}:{}}).catch(An=>PGt(Yt,An)).then(An=>{if(Lr){const ln=J2t(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=ebn(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),()=>{Jpe(!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 _bn(t,r,i){return Xe.createContext(i)}const XP=_bn(void 0,"EditorContext",null);function mbn({runtime:t,children:r}){const i=Xe.useMemo(()=>({begin:()=>{},end:()=>{}}),[]);return z.jsx(XP.Provider,{value:t,children:z.jsx(g3t.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 e4n(){const t=Xe.useContext(XP);if(!t)throw new Error("useEditorStats must be used within <EditorProvider>");return t.stats}function hbn(){const t=Xe.useContext(XP);if(!t)throw new Error("useEditorInit must be used within <EditorProvider>");return t.initPromise}function NGt(){const t=Xe.useContext(XP);if(!t)throw new Error("useHistoryService must be used within <EditorProvider>");return t.session.history}function gbn(){return Xe.useContext(XP)?.session.history??null}function t4n(){return Xe.useContext(XP)?.store??null}function r4n(){return Xe.useContext(XP)?.stats??null}function obe(){const t=Xe.useContext(XP);if(!t)throw new Error("useHistoryCommands must be used within <EditorProvider>");return t.session.historyCommands}function OGt(){const t=obe();return Xe.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getSnapshot)}class ybn{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 vbn=new Bye(-1,1,1,-1,0,1);class bbn extends Hqe{constructor(){super(),this.setAttribute("position",new q1t([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new q1t([0,2,0,0,2,0],2))}}const Abn=new bbn;class Sbn{constructor(r){this._mesh=new NA(Abn,r)}dispose(){this._mesh.geometry.dispose()}render(r){r.render(this._mesh,vbn)}get material(){return this._mesh.material}set material(r){this._mesh.material=r}}const b_e={name:"OutputShader",uniforms:{tDiffuse:{value:null},toneMappingExposure:{value:1}},vertexShader:`
|
|
1603
|
+
`)}const J$e=new Set;function kyn(t){return J$e.add(t),()=>{J$e.delete(t)}}function Iyn(){for(const t of[...J$e])try{t()}catch(r){ua.error(`a session-sample subscriber threw: ${String(r)}`,"invariant")}}const Dyn=5e3;let hw={frames:0,since:0},QX=null,Gq=null,BR=null;const KX=new Map;function Pyn(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 Nyn="editor-canvas";function Oyn(t){const r=t.style;return r.display==="none"?"display":r.visibility==="hidden"?"visibility":r.opacity!==""&&Number.parseFloat(r.opacity)===0?"opacity":null}function HHt(){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:Pyn(r),inlineHiding:Oyn(r),failsafeEligible:a!==Nyn}})}function Fyn(){const t=_yn();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 rR=new Map,EY=new Map;function Ryn(){const t=vyn(),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=EY.get(l);_===null?EY.delete(l):EY.set(l,_);const b=_===null||g===void 0?{}:{transportAdvanced:_!==g};let S;try{S=a.contentClock()}catch(N){return rR.delete(l),{id:l,label:d,advanced:null,unavailable:`its content clock threw: ${String(N)}`,...b}}if(S===null)return rR.delete(l),{id:l,label:d,advanced:null,unavailable:"its content clock is temporarily unavailable",...b};const k=S,w=rR.get(l);return rR.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[...rR.keys()])r.has(a)||rR.delete(a);for(const a of[...EY.keys()])r.has(a)||EY.delete(a);return i}function Myn(t=Date.now()){const r=ebe(),i=hw.since===0?0:t-hw.since,a=hw.frames,l=i>0&&a>0?a*1e3/i:null,d=r?{startedMsAgo:BR===null?0:t-BR,...Fyn()}:null;return{mode:r?"play":"edit",loops:[...$$e().map(_=>({name:`${_.id} session`,running:_.mounted()})),...$$e().map(_=>({name:`${_.id} playing`,running:_.playing()}))],designTimeSurfaces:Ryn(),presentedThreeRoots:KPt()?dyn().filter(_=>_.surface==="three").map(_=>_.worldId):null,...(()=>{const _=HHt();return{canvasHiddenBy:PQe(_),canvasHidesItself:hyn(_),hiddenCanvases:myn(_)}})(),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 GHt(){return Eyn(Myn())}let Cq=null;const YCt=new WeakSet;function Lyn(t,r){const i=PQe(t);if(i==null){Cq=null;return}if(Cq===null){Cq=r;return}const a=yyn({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||YCt.has(l)||(YCt.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=GHt();for(const r of t){const i=Tyn(r);if(!i){KX.delete(r.id);continue}if(r.id==="visible-tab-fps-floor"){const a=(KX.get(r.id)??0)+1;if(KX.set(r.id,a),a<3)continue}ua.warn(i,"invariant")}return t}function Byn(){if(Gq!==null)return XCt;hw={frames:0,since:Date.now()};const t=()=>{hw.frames++,QX=requestAnimationFrame(t)};return QX=requestAnimationFrame(t),Gq=setInterval(()=>{const r=ebe();r&&BR===null&&(BR=Date.now()),r||(BR=null),Iyn(),Lyn(HHt(),Date.now()),jyn(),hw={frames:0,since:Date.now()}},Dyn),XCt}function $yn(){hw={frames:0,since:Gq===null?0:Date.now()},BR=null,Cq=null,KX.clear(),rR.clear()}function XCt(){QX!==null&&cancelAnimationFrame(QX),Gq!==null&&clearInterval(Gq),QX=null,Gq=null,hw={frames:0,since:0},BR=null,Cq=null,KX.clear()}let W$e=null;function qyn(t){W$e=t}function NQe(){return W$e?(W$e(),!0):!1}let OQe=[];const H$e=new Set;function ZCt(t){OQe=t;for(const r of H$e)r()}function zyn(){return OQe}function Uyn(t){return H$e.add(t),()=>H$e.delete(t)}function Vyn(t){const r=OQe.find(i=>i.id===t);return r?(r.run(),!0):!1}let G$e=null;function Jyn(t){G$e=t}const Wyn=/^vgai\.([^.]+)\.(.+)$/;async function Hyn(t,r){if(G$e)return await G$e(t,r);const i=Wyn.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 la(async()=>{const{invokeViewVerb:l}=await Promise.resolve().then(()=>SMr);return{invokeViewVerb:l}},void 0);return a(i[1],i[2],r)}function QHt(t){return Array.from(document.querySelectorAll("[data-workspace-document-id]")).find(r=>r.dataset.workspaceDocumentId===t&&(Q9e()===null||r.dataset.workspaceViewId===Q9e()))??null}const Q$e=["document","header","shelf","rail","outliner","content"],Gyn={rail:{part:"properties",view:"vgai.properties",title:"Properties"},outliner:{part:"outliner",view:"vgai.outliner",title:"Outliner"},content:{part:"content",view:"vgai.content",title:"Content"}},Qyn={header:{prefix:"document-header",title:"header strip"},shelf:{prefix:"document-shelf",title:"tool shelf"}};function FQe(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 Kyn(t){return document.querySelector(`[data-vgai-part="${t}"]`)}function Yyn(t){const r=t==="rail"||t==="outliner"||t==="content"?Gyn[t]:null;if(r){const i=Kyn(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 Xyn(t)}function Xyn(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=QHt(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=Qyn[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 eEt(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: ${Q$e.filter(i=>i!==t.name).map(i=>`'${i}'`).join(", ")} (pass \`{ scope }\`). The rest of the page is deliberately unreachable.`)}const tEt=400,rEt="rgb(1, 2, 3)",Zyn="rgba(0, 0, 0, 0)";function e0n(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=rEt,t.appendChild(l);try{l.style.backgroundColor=`var(${r})`;const d=getComputedStyle(l).backgroundColor.trim();return d===rEt||d===Zyn?i:d}finally{l.remove()}}function t0n(t,r){const i=getComputedStyle(t),a={};for(const l of r)a[l]=l.startsWith("--")?e0n(t,l):i.getPropertyValue(r0n(l)).trim();return a}function r0n(t){return t.includes("-")?t:t.replace(/[A-Z]/g,r=>`-${r.toLowerCase()}`)}function nEt(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>tEt?`${b.slice(0,tEt)}…`: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:t0n(a,i)}:{}}}function qme(t,r,i){const a=YHt(t,r),l=a[i];if(!l)throw eEt(t,`${JSON.stringify(r)} matched ${a.length} element(s), so index ${i} does not exist`);if(!FQe(t).some(d=>d.contains(l)))throw eEt(t,`${JSON.stringify(r)} resolved outside the document's container`);return l}function n0n(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 i0n(t,r=1){const i=n0n(t),a=Math.max(1,Math.round(r));KHt(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 s0n(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 KHt(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 o0n(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]);KHt(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 a0n(t,r){if(r)return r;const i=document.activeElement;return i instanceof HTMLElement&&FQe(t).some(a=>a.contains(i))?i:t.container}function YHt(t,r){try{return FQe(t).flatMap(i=>Array.from(i.querySelectorAll(r)))}catch(i){throw new Error(`Invalid selector ${JSON.stringify(r)}: ${String(i)}`)}}function LRe(t,r){const i=r.selector===void 0?null:qme(t,r.selector,r.index??0);return a0n(t,i)}function c0n(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 l0n(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 jRe=["query","click","drag","key","paste","select","type"];function u0n(t){const r=t?.action;if(!jRe.includes(r))throw new Error(`Unknown document-probe action ${JSON.stringify(r)}. This door has exactly ${jRe.length} verbs: ${jRe.join(", ")} (\`editor.document.*\`).`);const i=t.scope??"document";if(!Q$e.includes(i))throw new Error(`Unknown scope ${JSON.stringify(i)}. This door addresses exactly these surfaces: ${Q$e.map(a=>`'${a}'`).join(", ")}.`);return Yyn(i)}async function f0n(t){const r=u0n(t),i={name:r.name,id:r.id,title:r.title},a=l=>({scope:i,matched:1,elements:[nEt(l,0)]});switch(t.action){case"query":{const l=YHt(r,t.selector);return{scope:i,matched:l.length,elements:l.slice(0,t.limit??25).map((d,_)=>nEt(d,_,t.styles))}}case"click":{const l=qme(r,t.selector,t.index??0);return i0n(l,t.clicks??1),a(l)}case"type":{const l=LRe(r,t);return s0n(l,t.text,t.replace??!0,t.enter??!0),a(l)}case"drag":{const l=qme(r,t.selector,t.index??0);return o0n(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=LRe(r,t),d=c0n(t);return l.dispatchEvent(new KeyboardEvent("keydown",d)),l.dispatchEvent(new KeyboardEvent("keyup",d)),a(l)}case"select":{const l=qme(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 l0n(l,t.value),a(l)}case"paste":{const l=LRe(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 RQe=[{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 d0n(t){const{liveCanvasFrame:r}=await la(async()=>{const{liveCanvasFrame:i}=await Promise.resolve().then(()=>Lgn);return{liveCanvasFrame:i}},void 0);return r(t)}async function p0n(...t){const{capturePlayComposite:r}=await la(async()=>{const{capturePlayComposite:i}=await Promise.resolve().then(()=>yhn);return{capturePlayComposite:i}},void 0);return r(...t)}async function iEt(){return la(()=>Promise.resolve().then(()=>S9r),void 0)}async function _0n(){return la(()=>Promise.resolve().then(()=>QAn),void 0)}const m0n=new Set(["solid","clay","unlit","wireframe","normals","overdraw"]);function h0n(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=m0e(()=>{gE().some(_=>_.id===t)&&d()}),gE().some(_=>_.id===t)?d():a=window.setTimeout(d,r)})}async function g0n(t){if(t){if(!gE().some(r=>r.id===t)){const r=t.startsWith(she);if(r&&(await(await iEt()).refreshProjectToolContributions(),await h0n(t)),!gE().some(i=>i.id===t)){const i=gE().map(l=>l.id),a=r?(await iEt()).contributionFailureHint(t.slice(she.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 XHt(t){const r=RQe.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(Jze(i),!await xE(()=>iPt()===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 y0n(t,r){return Sb("workspace:scene"),"workspace:scene"}async function v0n(t){let r=!1;if(await xE(()=>(r=C$e(t.id),r||_Ct(t.id)!==null),m9),r)return I_();const i=_Ct(t.id);throw i?new Error(i):new Error(`World document is not registered: ${t.id}`)}async function b0n(t,r){const i=_=>_.filter(g=>g.id===r||g.label===r);let a=[];if(!await xE(()=>{const _=bze(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 A0n(t,r){const i=await h0e(r.kind,t,r);if(i!==null)return i;let a=!1;if(await xE(()=>(a=Sb(r.id),a||mCt(r.id)!==null),m9),a)return r.story!==void 0&&await b0n(r.id,r.story),r.id;const l=mCt(r.id);throw l?new Error(l):new Error(`Workspace document is not available: ${r.id}`)}async function S0n(t,r){const i=await h0e(r.kind,t,r);if(i===null){const{kind:a,...l}=r,d=oRr();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 x0n(t){const r=$7r();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 w0n(t,r){if(!r)return I_();if(!LDr(r.kind))throw new Error(`present-view does not know the document kind "${String(r.kind)}". An EditorView addresses a document by one of: ${uIt.join(", ")}. `+x0n(String(r.kind)));switch(r.kind){case"scene":return y0n();case"world":return v0n(r);case"asset":case"tool":case"document":case"story":case"project-tool":case"generation":return S0n(t,r);case"workspace":return A0n(t,r)}}function C0n(t){const r=t.indexOf(",");return{base64:r>=0?t.slice(r+1):t,mimeType:"image/png"}}const sEt=QHt;function E0n(t,r,i){if(!i?.degenerate)return null;const a=SQe();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 T0n(t,r){const i=AE();if(!i)throw new Error("No active editor document to capture.");const{descriptor:a,title:l}=i,d=lte(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{...C0n(w),document:_,view:d,source:"object3d-document"}}const b=a.id===Sw?MHt()??sEt(a.id):sEt(a.id);if(!b)throw new Error(`Active document surface is not mounted: ${a.id}`);const S=await p0n(b,{canvasFrame:d0n,includeDocumentStyles:a.id!==Sw}),k=E0n(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 k0n(t){return t?Pw(t):null}function I0n(t,r,i){i!==void 0&&(r?r.setGrid(i):t.showGrid!==i&&t.toggleGrid())}function D0n(t,r,i,a){i&&(r?(r.setSkeleton(i==="skeleton"),r.setBounds(i==="bounds"),i==="skeleton"||i==="bounds"?r.setMode("solid"):r.setMode(i)):m0n.has(i)?t.setShadingMode(i):a.push(`Diagnostic ${i} is unavailable for this document.`))}function P0n(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 N0n(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 O0n(t,r,i,a){i.selection&&(r?r.select(i.selection.ids):t.selectMultiple(i.selection.ids)),I0n(t,r,i.viewport?.grid),D0n(t,r,i.viewport?.diagnostic,a),P0n(t,r,i.viewport?.camera,a),N0n(t,r,i,a)}async function vye(t,r,i={}){if(r?.version!==1)throw new Error("present-view requires EditorView version 1.");const a=Object.keys(r).filter(k=>!Q1t.includes(k));if(a.length>0)throw new Error(`present-view does not know ${a.map(k=>`"${k}"`).join(", ")}. An EditorView carries: ${Q1t.join(", ")}. A document's own address (kind, and the fields that kind reads) goes under "document".`);const l=lte(t);if(r.style!==void 0){const k=cU().map(w=>w.id);if(!k.includes(r.style))throw new Error(`present-view requires a style of ${k.join(", ")}, got ${String(r.style)}.`);tUe(r.style)}if(r.workspace!==void 0){if(!AZ(r.workspace))throw new Error(`present-view requires a workspace of ${Qze().join(", ")}, got ${String(r.workspace)}.`);if(wS()!==r.workspace){const k=yPt();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 w0n(t,r.document);await g0n(r.utility);const g=k0n(_);if(g&&_&&await IOr(_),!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_()!==_&&Sb(_),O0n(t,g,r,d),r.panel!==void 0&&await XHt(r.panel);const b=dIt(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 _0n()).showEditorPresentationNotice({presented:S,previousView:l}),S}const bye=new Map;let ZHt=0;const K$e=new Set;function eGt(){ZHt+=1;for(const t of K$e)t()}function F0n(t,r,i){const a=bye.get(t);a&&a.assetPath===r&&a.actions.length===i.length&&a.actions.every((l,d)=>l===i[d])||(bye.set(t,{assetPath:r,actions:i}),eGt())}function R0n(t){bye.delete(t)&&eGt()}function M0n(t){const r=[];for(const i of bye.values())i.assetPath===t&&r.push(...i.actions);return r}function L0n(t){return K$e.add(t),()=>K$e.delete(t)}function oEt(){return ZHt}const j0n=[],aEt=new Set;let B0n=0;function $0n(t){for(const r of j0n)if(r.match(t))return r;return null}function q0n(t){return aEt.add(t),()=>{aEt.delete(t)}}function cEt(){return B0n}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 tGt(t){return`vgai:project-content:v1:${t}`}const fP=[],Y$e=new Set,TY=new Map;let rGt=0;function BRe(){rGt++;for(const t of Y$e)t()}function z0n(t){const r=fP.findIndex(i=>i.owner===t.owner&&i.id===t.id);if(r>=0){const[i]=fP.splice(r,1);i&&(TY.get(i)?.(),TY.delete(i))}return fP.push(t),fP.sort((i,a)=>(i.order??0)-(a.order??0)),TY.set(t,t.subscribe(BRe)),BRe(),()=>{const i=fP.indexOf(t);i<0||(fP.splice(i,1),TY.get(t)?.(),TY.delete(t),BRe())}}const U0n=[];function V0n(){return fP.length===0?U0n:fP}function nGt(t){return Y$e.add(t),()=>{Y$e.delete(t)}}function Aye(){return rGt}function iGt(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 J0n(){const t=B0e();return t?{path:t.path,name:t.name,kind:t.kind,origin:t.origin??"project",...t.sourcePath?{sourcePath:t.sourcePath}:{}}:null}function W0n(t,r){return Xe.useEffect(()=>()=>R0n(t),[t]),Xe.useCallback(i=>{r!==null&&F0n(t,r,i)},[t,r])}function H0n({id:t,title:r,file:i,tool:a,Component:l}){Xe.useSyncExternalStore(j0e,TZ),Xe.useSyncExternalStore(Qye,T8,T8),Xe.useSyncExternalStore(Yye,k8,k8);const d=J0n(),_=W0n(t,d?.path??null),g=Xe.useRef(null),b=Xe.useCallback(k=>{g.current?.(),g.current=k===null?null:I3t(`building ${k.replace(/^building /,"")}`)},[]);Xe.useEffect(()=>()=>g.current?.(),[]);const S=Xe.useCallback(k=>oz({...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:{...kFr,marginBottom:4},children:[z.jsx(So,{icon:gb.tool.extension,tone:"muted",style:{marginRight:4}}),r]}),z.jsx(Fze,{file:i,children:z.jsx(l,{...a?{tool:a}:{},contributionId:t.slice(t.lastIndexOf(":")+1),client:y0e(),surfaces:Sze,account:pze(),play:Kye(),asset:d,setActions:_,notify:S,work:b})})]})}function G0n(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 sGt=32,X$e=new Set,lEt=new Map,uEt=new Map;let $R=null,YX=null,oGt=0,Z$e=0,Qq=0,V8=0,fEt=!1,AP={url:null,progress:0,playing:!1};function Q0n(){for(const t of X$e)t()}function Gz(t){AP.url===t.url&&AP.playing===t.playing&&Math.abs(AP.progress-t.progress)<.002||(AP=t,Q0n())}function MQe(){return $R??=new AudioContext,$R}function K0n(){if(fEt||typeof window>"u")return;fEt=!0;const t=()=>{if(!$R)return;const r=AP.url,i=V8;$R.resume().then(()=>{r&&i===V8&&!YX&&$R?.state==="running"&&lGt(r,i)})};window.addEventListener("pointerdown",t,{capture:!0}),window.addEventListener("keydown",t,{capture:!0})}function LQe(){if(Qq&&typeof cancelAnimationFrame=="function"&&cancelAnimationFrame(Qq),Qq=0,!YX)return;const t=YX;YX=null,t.onended=null;try{t.stop()}catch{}t.disconnect()}function aGt(){if(Qq=0,!AP.playing||!$R||Z$e<=0)return;const t=Math.min(1,($R.currentTime-oGt)/Z$e);Gz({url:AP.url,progress:t,playing:t<1}),t<1&&typeof requestAnimationFrame=="function"&&(Qq=requestAnimationFrame(aGt))}function Y0n(t,r,i){if(i!==V8)return;LQe();const a=MQe(),l=a.createBufferSource(),d=a.createGain();d.gain.value=1,l.buffer=t,l.connect(d),d.connect(a.destination),l.onended=()=>{i===V8&&Gz({url:r,progress:1,playing:!1})},l.start(),YX=l,oGt=a.currentTime,Z$e=t.duration,Gz({url:r,progress:0,playing:!0}),typeof requestAnimationFrame=="function"&&(Qq=requestAnimationFrame(aGt))}async function cGt(t){const r=lEt.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 MQe().decodeAudioData(l.slice(0))})().catch(()=>null);return lEt.set(t,i),i}async function lGt(t,r){K0n();const i=await cGt(t);if(r!==V8)return;if(!i){Gz({url:t,progress:0,playing:!1});return}const a=MQe();a.state==="suspended"&&(await a.resume(),r!==V8)||a.state==="running"&&Y0n(i,t,r)}function X0n(t){return X$e.add(t),()=>X$e.delete(t)}function Z0n(){return AP}function evn(t){const r=++V8;LQe(),Gz({url:t,progress:0,playing:!0}),lGt(t,r)}function tvn(t){t&&AP.url!==t||(V8+=1,LQe(),Gz({url:null,progress:0,playing:!1}))}function rvn(t,r=sGt){const i=`${t}#${r}`,a=uEt.get(i);if(a)return a;const l=cGt(t).then(d=>d?G0n(d.getChannelData(0),r):Array.from({length:r},()=>0));return uEt.set(i,l),l}const dEt=16,nvn=3e3,ivn=500;function GPn(t,r){return r-t>=ivn}function QPn(t){let r=!1;return t.traverse(i=>{!r&&X8(i,"gaussianSplat")&&(r=!0)}),r}function svn(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=nvn;const i=()=>{if(t.sorting){r>0?(r-=dEt,setTimeout(i,dEt)):console.warn("SparkRenderer did not become idle; skipped worker termination.");return}t.dispose()};i()}const y_e=128;let zme=null;const ovn=new Set(["glb","gltf","fbx","obj","dae","stl","ply","spz","bvh","3ds"]);function jQe(t){const r=t.split(/[?#]/,1)[0].toLowerCase(),i=r.slice(r.lastIndexOf(".")+1);return ovn.has(i)?i:void 0}class avn{renderer;scene;camera;cache=new Map;pending=new Map;sparkRenderer=null;constructor(){const r=document.createElement("canvas");r.width=y_e,r.height=y_e,this.renderer=UP(new $P({canvas:r,alpha:!0,antialias:!0,preserveDrawingBuffer:!0})),this.renderer.setSize(y_e,y_e),this.renderer.setPixelRatio(1),this.renderer.outputColorSpace=hv,this.renderer.toneMapping=u9,this.renderer.toneMappingExposure=1,this.scene=new Rye,Fee(this.scene,this.renderer),this.scene.add(new pIr(16777215,.8*V6t));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 jye(35,1,.01,1e3)}async render(r){const i=typeof r=="string"?{url:r}:r,a=i.format??jQe(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=fvn(await uvn(r));if(this.scene.add(i),r.format==="spz"&&!this.sparkRenderer){const{SparkRenderer:w}=await la(async()=>{const{SparkRenderer:N}=await import("./spark.module-B_-x7Z29.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=lvn(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 wkt),_=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=cvn(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=>{X8(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),svn(this.sparkRenderer),this.sparkRenderer=null),this.renderer.dispose(),this.renderer.forceContextLoss(),this.cache.clear(),zme=null}}function cvn(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 lvn(t){t.updateWorldMatrix(!0,!0);const r=new xS,i=new xS;return t.traverseVisible(a=>{if(X8(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 uvn(t){switch(t.format){case"glb":case"gltf":{const r=await uU.loadAsync(t.url);return r.scene.animations=[...r.animations],r.scene}case"fbx":{const{FBXLoader:r}=await la(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 la(async()=>{const{OBJLoader:l}=await import("./OBJLoader-8SrBLZ7J.js");return{OBJLoader:l}},__vite__mapDeps([69,6])),i=t.materialUrl??await _vn(t.url),a=new r;if(i){const{MTLLoader:l}=await la(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 la(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 la(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 ez({color:7710680,roughness:.75}))}case"ply":{const{PLYLoader:r}=await la(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 ez({color:i.hasAttribute("color")?16777215:12112027,vertexColors:i.hasAttribute("color"),roughness:.8,side:gkt}));i.computeBoundingBox();const a=i.boundingBox?.getSize(new Tc).length()??1;return new Gqe(i,new hkt({color:i.hasAttribute("color")?16777215:12112027,vertexColors:i.hasAttribute("color"),size:Math.max(a/220,1e-4),sizeAttenuation:!0}))}case"spz":return j6t(t.url);case"bvh":{const{BVHLoader:r}=await la(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 la(async()=>{const{TDSLoader:i}=await import("./TDSLoader-BtiaQ4S3.js");return{TDSLoader:i}},__vite__mapDeps([75,6]));return new r().loadAsync(t.url)}}}function fvn(t){if(dvn(t))return t;t.updateWorldMatrix(!0,!0);const r=new dIr(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 dvn(t){let r=!1;return t.traverseVisible(i=>{!r&&pvn(i)&&(r=!0)}),r}function pvn(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 _vn(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 mvn(){return zme||(zme=new avn),zme}const BQe={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)"},hvn={folder:hee,model:oDr,prefab:gee,component:Ukt,audio:rIt,image:VIr,video:iDr,json:iIt,unknown:KIr,source:cIt};function DP({kind:t,size:r=24}){return z.jsx(So,{icon:hvn[t],style:{fontSize:r,color:BQe[t]}})}const gvn=100,yvn=50,vvn=new D4t(t=>{const r=jQe(t);return r?mvn().render({url:t,format:r,background:"neutral",output:"webp"}):Promise.reject(new Error(`No model preview loader for ${t}.`))},2);function uGt(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 SUe().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=vvn.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 fGt({url:t}){const r=uGt(t,gvn);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 ${vhe[2]}`,borderTopColor:BQe.model,borderRadius:"50%"}})})}function bvn({url:t,name:r}){const[i,a]=Xe.useState(()=>Array.from({length:sGt},()=>.15)),l=Xe.useSyncExternalStore(X0n,Z0n);Xe.useEffect(()=>{let g=!1;return rvn(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=BQe[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 dGt(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 KPn(t,r,i,a,l){return t==="fit"?dGt(r,i,a,l):t}function Avn(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 _=lqr(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 pGt({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?dGt(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||Avn(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 _Gt={fontSize:11,color:od[3],marginBottom:2},Svn={fontSize:11,color:od[1],wordBreak:"break-all"};function $Re({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 FPt().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(H0n,{id:i.id,title:i.title,file:i.file,tool:i.tool,Component:i.Component},`${i.id}:${i.version}`):null})}function pEt(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:_Gt,children:t}),z.jsx("div",{style:Svn,children:r})]})}function xvn({asset:t}){const r=t.capabilities?.editor==="environment";Xe.useSyncExternalStore(nGt,Aye,Aye);const i=t.componentPreview,a=i?iGt({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:Ize.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(Cvn,{path:t.path,name:t.name}):t.kind==="video"?z.jsx(wvn,{path:t.path}):t.kind==="model"?z.jsx(fGt,{url:t.path}):z.jsx(a9,{kind:t.kind,name:t.name,variant:"cell"})})}function wvn({path:t}){return z.jsx("video",{src:t,muted:!0,preload:"metadata",style:{width:"100%",height:"100%",objectFit:"contain"}})}function Cvn({path:t,name:r}){const{sheetPath:i,frameName:a}=q0e(t),[l,d]=Xe.useState(null);return Xe.useEffect(()=>{if(!a){d(null);return}let _=!1;return fetch(`/${uNt(i)}`).then(g=>g.ok?g.text():null).then(g=>{if(_||!g)return;const b=VUe(g);d(b?.frames.find(S=>S.name===a)??null)}).catch(()=>{_||d(null)}),()=>{_=!0}},[a,i]),l?z.jsx(pGt,{sheetUrl:`/${i}`,frame:l,maxEdge:96}):z.jsx("img",{src:t.split("#")[0],alt:r,style:{width:"100%",height:"100%",objectFit:"contain"}})}function Evn({asset:t}){const[r,i]=Xe.useState(null),{sheetPath:a,frameName:l}=q0e(t.path);return Xe.useEffect(()=>{if(i(null),t.kind!=="image"||t.capabilities?.editor==="environment")return;let d=!1;if(l)return fetch(`/${uNt(a)}`).then(g=>g.ok?g.text():null).then(g=>{if(d||!g)return;const b=VUe(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 Tvn(){Xe.useSyncExternalStore(q0n,cEt,cEt);const t=B0e();if(!t)return null;const r=$0n(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 ${vhe[1]}`,display:"flex",flexDirection:"column",gap:6},children:[z.jsx(r.View,{asset:t}),z.jsx($Re,{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(wNt,{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($Re,{asset:t})]}):z.jsxs("div",{"data-testid":"inspector-asset-selection",style:{pointerEvents:"auto",padding:8,borderBottom:`1px solid ${vhe[1]}`,display:"flex",flexDirection:"column",gap:6},children:[z.jsx(Evn,{asset:t}),z.jsx("div",{style:{..._Gt,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:pEt(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:pEt(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($Re,{asset:t})]})}function kvn(t){return M0n(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 Ivn(){const t=B0e();if(t===null)return null;const r=t0e();return r&&(r.adapter!==null||r.nodeId!==null)?null:{quickActions:kvn(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:uMe,title:"Preview",icon:jY,order:P3t,body:{kind:"preview",render:()=>z.jsx(xvn,{asset:t})}},{id:"asset-selection",title:"Asset",icon:vee,order:mZ,body:{kind:"custom",render:()=>z.jsx(Tvn,{})},keepMounted:!0}]}}const Dvn={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 Pvn(t){const r=Dvn[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 Nvn={ok:sDr,gap:Wkt,na:wDr,info:vee},Ovn={ok:Oo.semantic.success,gap:Oo.semantic.warning,na:Oo.content.dim,info:Oo.content.dim};function Fvn({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:Ovn[t.status],paddingTop:1},children:z.jsx(So,{icon:Nvn[t.status]})}),z.jsxs("div",{style:{minWidth:0},children:[z.jsx("div",{style:{color:Oo.content.primary,fontWeight:600},children:Pvn(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 Rvn({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(Fvn,{row:i},i.seam))]})}function Mvn(t){return{id:"ingest-coverage",title:"Ingest coverage",icon:cDr,order:9e3,description:`${t.summary.gaps} gap${t.summary.gaps===1?"":"s"}`,defaultOpen:!0,testId:"ingest-coverage-section",body:{kind:"custom",render:()=>z.jsx(Rvn,{report:t}),data:{summary:t.summary,rows:t.rows}}}}function Lvn(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 mGt="vgai-inspector-presentation-v2";function hGt(){try{return typeof window>"u"?null:window.localStorage}catch{return null}}function jvn(t){return t==="card"||t==="column"||t==="properties"}function Bvn(){const t=hGt()?.getItem(mGt);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 XX=null,gGt=0;const eqe=new Set;function yGt(){return XX===null&&(XX=Bvn()),XX}function tqe(t){return yGt()[t]??null}function vGt(t,r){if(tqe(t)!==r){XX={...yGt(),[t]:r},gGt++;try{hGt()?.setItem(mGt,JSON.stringify(XX))}catch{}for(const i of eqe)i()}}function $vn(t){return eqe.add(t),()=>{eqe.delete(t)}}function _Et(){return gGt}function qvn(t,r,i=null){return r??i??t}function bGt(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 rqe(t){return t==="three"||t==="canvas"||t==="dom"?t:null}function zvn(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?rqe(l.kind):null}function Uvn(t){const r=gze();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?rqe(l[0]?.kind??""):null;if(d)return d;const _=zvn(i,t);if(_)return _}return rqe(X1e()??"")??"three"}function $Qe(t,r){r(t);for(const i of t.children)O0e(i)||$Qe(i,r)}const qRe=new xS;function AGt(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 mEt=new SS,zRe=new xS;function Vvn(t,r,i){for(let a=0;a<r.count;a++)r.getMatrixAt(a,mEt),zRe.copy(i).applyMatrix4(mEt).applyMatrix4(r.matrixWorld),AGt(zRe)&&t.union(zRe)}function SGt(t,r){const i=r.geometry;if(!i)return;const a=Jvn(r,i);if(a){if(r.isInstancedMesh){Vvn(t,r,a);return}qRe.copy(a).applyMatrix4(r.matrixWorld),AGt(qRe)&&t.union(qRe)}}function Jvn(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 Wvn(t,r){return $Qe(r,i=>{i.updateWorldMatrix(!1,!1),SGt(t,i)}),t}const v_e=new xS;function xGt(t){const r=t.material;return r?Array.isArray(r)?r:[r]:[]}function Hvn(t){const r=xGt(t);return r.length>0&&r.every(i=>i.depthWrite===!1)}function Gvn(t){const r=xGt(t);return r.length>0&&r.every(i=>i.side===ukt)}function Qvn(t,r=[]){return $Qe(t,i=>{i.updateWorldMatrix(!1,!1),v_e.makeEmpty(),SGt(v_e,i),!v_e.isEmpty()&&r.push({box:v_e.clone(),overlay:Hvn(i),enclosure:Gvn(i)})}),r}function YPn(t,r=[]){for(const i of Qvn(t))r.push(i.box);return r}function wGt(t,r=new xS){return r.makeEmpty(),Wvn(r,t)}class XPn extends _Ir{entityObject;constructor(r,i){super(new xS,i),this.entityObject=r,this.update()}update(){wGt(this.entityObject,this.box)}}function Kvn({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 qQe(t){const r=new H8(...t);r.lengthSq()<Number.EPSILON?r.identity():r.normalize();const i=new Qqe().setFromQuaternion(r,"XYZ");return[vb.radToDeg(i.x),vb.radToDeg(i.y),vb.radToDeg(i.z)]}function Yvn(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 H8().setFromEuler(new Qqe(vb.degToRad(i[0]),vb.degToRad(i[1]),vb.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 Xvn(t,r,i){const a=qQe(t.rotation);a[r]=i;const l=new H8().setFromEuler(new Qqe(vb.degToRad(a[0]),vb.degToRad(a[1]),vb.degToRad(a[2]),"XYZ"));return{position:[...t.position],rotation:[l.x,l.y,l.z,l.w],scale:[...t.scale]}}const Zvn={x:"#e0726d",y:"#83bd66",z:"#6390dd"};function URe({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(q_e,{label:r,style:{padding:"4px 8px"},children:t.map(({axis:j,name:J})=>z.jsx(AX,{testId:`${a}-${J}`,label:J,labelColor:Zvn[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 e1n({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?.(Xvn(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(S5r,{children:[z.jsx(URe,{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(URe,{axes:t==="2d"?[{axis:2,name:"z"}]:S,label:t==="2d"?"Rotation (degrees)":"Rotation",testidPrefix:"ingest-rotation",values:qQe(r.rotation),step:1,precision:1,...P("rotation"),onBegin:d,onPreview:_&&N(_),onCommit:N(g)}),z.jsx(URe,{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 tbe(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 t1n=Xe.lazy(()=>la(()=>import("./InspectorObjectPreview-MDmTPFBT.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}))),r1n=Xe.lazy(()=>la(()=>import("./InspectorCanvasPreview-CLDhscy0.js"),__vite__mapDeps([77,1,2,3,4])).then(t=>({default:t.InspectorCanvasPreview})));function n1n({object:t,displayName:r,previewKey:i,actions:a,mode:l="section"}){const d=l==="thumbnail",_=tbe(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(t1n,{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 i1n({source:t,entry:r,previewKey:i,actions:a,mode:l="section"}){const d=l==="thumbnail",_=tbe(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 s1n({capture:t,previewKey:r,actions:i,mode:a="section"}){const l=a==="thumbnail",d=tbe(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(r1n,{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 o1n(t){return t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function a1n(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:o1n(l),properties:a.get(l)}))}}function c1n(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 l1n=1e-4,u1n="World-anchored — content is placed in world space by the game each frame; moving this container offsets future placements away from their source.";function CGt(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 f1n(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)>l1n)return!1}return!0}const hEt=new xS,gEt=new Tc;function d1n(t,r){const i=CGt(t);if(i===0)return null;const a=p1n(t,r);return{units:i,detail:EGt(i),worldAnchored:a,note:a?u1n:null}}function p1n(t,r){if(!r||r.isEmpty()||!f1n(t.matrixWorld))return!1;const i=t.geometry;return i.boundingBox===null&&i.computeBoundingBox(),i.boundingBox?(hEt.copy(i.boundingBox),r.getCenter(gEt),!hEt.containsPoint(gEt)):!1}function _1n(t){const r=CGt(t);return r===0?null:EGt(r)}function EGt(t){return`${t} instanced unit${t===1?"":"s"}`}const m1n=14,h1n=[[/physic|rigid|collid/i,lDr],[/material/i,PIr],[/light/i,zkt],[/camera/i,qye],[/audio|sound|music/i,rIt],[/player|character|humanoid|person/i,aDr],[/anim|state|machine/i,JIr]];function g1n(t){for(const[r,i]of h1n)if(r.test(t))return i;return gee}function y1n(t){return r=>Xe.createElement(n1n,{object:t.object,displayName:t.displayName,previewKey:t.previewKey,actions:t.actions,...r?{mode:r}:{}})}function v1n(t){return r=>Xe.createElement(i1n,{source:t.picture.source,entry:t.picture.entry,previewKey:t.previewKey,actions:t.actions,...r?{mode:r}:{}})}function b1n(t){return r=>Xe.createElement(s1n,{capture:t.capture,previewKey:t.previewKey,actions:t.actions,...r?{mode:r}:{}})}function A1n(t){return t.object?.isCamera?null:t.object?y1n({object:t.object,displayName:t.displayName,previewKey:t.previewKey,actions:t.actions}):t.canvasCapture?b1n({capture:t.canvasCapture,previewKey:t.previewKey,actions:t.actions}):t.picture?v1n({picture:t.picture,previewKey:t.previewKey,actions:t.actions}):null}function VRe(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 S1n={position:[0,0,0],rotation:[0,0,0,1],scale:[1,1,1]};function x1n(t,r,i,a){if(O3t(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 TGt(t,r,i,a){const l=new Set,d=new Map,_=[];for(const g of t){const b=x1n(g,r,i,a).filter(k=>!l.has(k.id)),S=(O3t(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 kGt(t,r,i){return i===void 0?[...t]:t.filter(a=>r.get(a.id)===i.owner||i.builtins.includes(a.id))}function nqe(t){const{adapter:r,nullSubject:i}=t,{sections:a,claimed:l,owners:d}=TGt(r?t.contributions??[]:[],r,null,null),_=kGt([...(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:Mze(t.surface)},quickActions:i?.quickActions??[],related:[],sections:_}}function w1n(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 C1n(t){const{adapter:r,nodeId:i,node:a,contributions:l,onEdit:d}=t;if(i===null)return nqe({nullSubject:t.nullSubject??null,surface:t.surface,contributions:l,adapter:r,rail:t.rail});const{sections:_,claimed:g,owners:b}=TGt(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=t4t(r,i,cr,Yt);return d(),Lr},...r.inspector?.remove?{remove:cr=>{const Yt=z9r(r,i,cr);return d(),Yt}}:{}},k=r.inspector?.properties(i)??[],w=k.find(cr=>cr.path==="name"),{ungrouped:N,groups:P}=a1n(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?Kqe:Xqe,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:Vkt,placement:"identity",run:async()=>{await ZPt(r,i),d()}});const ue=new Map;ue.set(IFe,J);for(const cr of P)ue.set(pAt(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?iGt({name:ge,path:se?.anchored===!0?se.file:"",surface:"canvas"}):null,tt=G.filter(cr=>cr.placement==="preview"),Ct=A1n({object:de,canvasCapture:t.canvasPreview,picture:qe,displayName:a?.label??i,previewKey:i,actions:tt});!g.has(uMe)&&Ct!==null&&fe.push({id:uMe,title:"Preview",icon:f9,order:P3t,body:{kind:"preview",render:Ct}});const Ot=c1n(r,i);if(!g.has(dAt)&&Ot!==null){const cr=r.transforms?.get(i)??S1n,Yt=de?d1n(de,wGt(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:qQe(cr.rotation),scale:[...cr.scale]};fe.push({id:dAt,title:"Transform",icon:Gkt,order:KFr,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[VRe(on)],set:(on,gr)=>{if(!r.transforms)return;const An=Yvn(cr,VRe(on),gr);QMe(r,i),tme(r,i,An);const Rn=KMe(r,i);return d(),Rn},...r.transforms?.remove?{remove:on=>{const gr=XPt(r,i,VRe(on));return d(),gr}}:{}}},render:()=>Xe.createElement(e1n,{dimensions:Ot,transform:cr,readOnly:!r.capabilities.transform,channelEditability:Lr,...Yt?.note?{note:Yt.note}:{},onBegin:()=>{QMe(r,i)},onPreview:on=>{tme(r,i,on)},onCommit:on=>{tme(r,i,on),KMe(r,i),d()}})}})}g.has(IFe)||(J.length>0&&fe.push({id:IFe,title:"Properties",icon:Qkt,order:mZ,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:pAt(cr.groupId),title:cr.name,icon:g1n(cr.name),order:N3t+Yt,description:Lr>0?`${Lr} set of ${cr.properties.length}`:`${cr.properties.length} properties`,defaultOpen:Lr>0&&cr.properties.length<=m1n,testId:`ingest-group-${cr.groupId}`,body:{kind:"fields",fields:cr.properties,io:S}})}));const vt=t.stories;!g.has(D3t)&&vt&&fe.push(E1n(vt)),fe.push(..._.map(cr=>w1n(cr,S,ue))),fe.sort((cr,Yt)=>cr.order-Yt.order);const Et=kGt(fe,b,t.rail),Tt=u4t(r,i),Le=f4t(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:Mze(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 E1n(t){return{id:D3t,title:t.title??"Stories",icon:oIt,order:YFr,body:{kind:"custom",render:()=>Xe.createElement(Kvn,{stories:t.stories,activeStoryId:t.activeStoryId,onApplyStory:t.onApplyStory,isolation:t.isolation,unavailableReason:t.unavailableReason??null})}}}const T1n=["project-tool","tool-contribution"];function k1n(t){const{activeDocumentKind:r,documentSelection:i}=t;return r===null||!T1n.includes(r)?!1:i===null}function yEt(t){const{subject:r,surface:i,available:a,override:l,workspaceDefault:d=null}=t,_=r.presentation.preferred??Mze(),g=qvn(_,l,d);return{subject:r,surface:i,presentation:g,available:a,card:a&&g==="card",column:g!=="card"}}const I1n="game",D1n=3,P1n=Object.freeze({none:!0});function N1n(t){const r=Object.getPrototypeOf(t);return r===Object.prototype||r===null}function uee(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>=D1n)return{kind:"opaque",type:vEt(t)};if(Array.isArray(t))return t.map(d=>uee(d,r+1));const a=t;if(!N1n(a))return{kind:"opaque",type:vEt(a)};const l={};for(const[d,_]of Object.entries(a))_!==void 0&&(l[d]=uee(_,r+1));return l}function vEt(t){return t.constructor?.name??"object"}function bEt(t,r){let i;try{i=r.get(t.path)}catch{i=void 0}return{path:t.path,label:t.label,type:t.type,...lMe(i)?{mixed:!0}:{},...!lMe(i)&&i!==void 0?{value:uee(i)}:{},...t.defaulted!==void 0?{defaulted:t.defaulted}:{},...t.readonly!==void 0?{readonly:t.readonly}:{},...t.readonly?{readonlyReason:Rze(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=>uee(a))}:{}}}function AEt(t){const r={};for(const[i,a]of Object.entries(t))a!==void 0&&(r[i]=uee(a));return r}function O1n(t){const r=t.body;if(r.kind==="fields")return{kind:"fields",fields:r.fields.map(i=>bEt(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:AEt(r.data)};if(r.kind==="custom"&&r.editable!==void 0){const i=r.editable;return{kind:"fields",fields:i.fields.map(a=>bEt(a,i.io)),...r.data!==void 0?{data:AEt(r.data)}:{}}}return{kind:r.kind,id:t.id,title:t.title}}function F1n(t){return{id:t.id,title:t.title,order:t.order,...t.description!==void 0?{description:t.description}:{},body:O1n(t)}}function R1n(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(F1n)}}const SEt=new WeakMap;function M1n(t){const r=SEt.get(t);if(r)return r;const i=async a=>t.captureImage(a);return SEt.set(t,i),i}function L1n(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?M1n(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 L1n(a)?l=>a.previewImage(r,l,l):null}function B1n(){const t=I_();if(t===null)return null;const r=Lmn(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 $1n(t){const{store:r,adapter:i,documentSelection:a,surface:l}=t,d=Ivn();if(d!==null)return{subject:nqe({nullSubject:d,surface:l}),available:!0};const _=Lvn(a,r.selectedEntityIds,i),g=_?i.hierarchy.node(_):null;if(_!==null&&g===null)return{subject:nqe({nullSubject:null,surface:l}),available:!1};const b=()=>r.notifyIngestEdit(),S=_?null:pMr({adapter:i,surface:l,store:r,onEdit:b}),k=_?g?hAt(g,i):[]:hAt(null,i,{nullSubjectId:S?.id??null});return{subject:C1n({adapter:i,nodeId:_,node:g,surface:l,contributions:k,..._?{}:{nullSubject:S},previewObject:(_===null||l==="asset-lab"?null:fte(i,r.objectMap,_))??null,canvasPreview:j1n(i,_,l),assetDocument:_&&r.objectMap.has(_)?{open:()=>INt(r,_)}:null,stories:cMr(i,g,_),...B1n()??{},...a===null&&_!==null&&r.selectedEntityIds.size>1?{alsoSelected:r.selectedEntityIds.size-1}:{},onEdit:b}),available:_!==null||S!==null||k.length>0}}function rbe(t){const r=Uvn(t),{adapter:i,documentSelection:a}=wm(t),l=$1n({store:t,adapter:i,documentSelection:a,surface:r}),{subject:d}=l,_=l.available&&(d.id!==I1n||d.sections.length>0)&&!k1n({activeDocumentKind:AE()?.descriptor.kind??null,documentSelection:a}),g=I_()===Sw?EQe():null;if(g){const b=Mvn(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 yEt({subject:S,surface:r,available:!0,override:tqe(r),workspaceDefault:wP().inspector??null})}return yEt({subject:d,surface:r,available:_,override:tqe(r),workspaceDefault:wP().inspector??null})}function nbe(t){const{subject:r,surface:i,presentation:a,available:l}=rbe(t);return l?R1n(r,{surface:i,presentation:a}):P1n}async function q1n(t,r){const{subject:i,available:a}=rbe(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(),nbe(t)}function z1n(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 U1n(t,r,i){const a=IGt(t,r);z1n(a.field,i);const l=await a.io.set(r,i)??Uhe;return{subject:nbe(t),write:l}}function IGt(t,r){const{subject:i,available:a}=rbe(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: ${Rze(g.field)}`);return g}class iqe extends Error{constructor(r){super(r),this.name="InspectionRemovalUnavailableError"}}async function V1n(t,r){const i=IGt(t,r);if(i.field.resettable!==!0)throw new iqe(`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 iqe(`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)??Uhe;return{subject:nbe(t),write:a}}let J1n=[];const xEt=new Set;function ZPn(t){return xEt.add(t),()=>xEt.delete(t)}function DGt(){return J1n}function W1n(){const t=DGt();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 H1n(t){return t.liveMounted?t.livePlaying?t.storePlayState==="paused"?"paused":"playing":"paused":"stopped"}async function G1n(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 Sye="console";function Q1n(t){let r=kZ().length>0;const i=iNt(()=>{const d=kZ().length>0;d&&!r&&wP().drawer!=="hidden"&&hE(Sye),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(Sye)),a=_});return()=>{i(),l()}}function ibe(){W7r(Sye)}function sbe(){hE(Sye)}const K1n=new Map;function Y1n(){return[...K1n].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 X1n=new Set(["state","stateAll","providers","commands","events","snapshot"]);function Z1n(t){if(t.type!=="bridge-call")return[];const r=t.method;if(typeof r!="string"||!X1n.has(r))return[];const i=t.instance;try{const a=AOr(i).debug;if(a===void 0)return[];const l=[fOr(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 ebn(t,r,i){const a=Z1n(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":d3r(t.type)??f3r(t.type),playFullReport:r&&!l&&a.length>0?"explicit":r&&t.type==="bridge-call"&&t.method==="invoke"?"if-content-changed":"none"}}function tbn(t,r,i,a){return t==="none"?!1:!(t==="if-content-changed"&&r==="none"&&i===a)}function wEt(t,r){const i=eO(t);return i.hierarchy.node(r)!==null||fte(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 JRe(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 rbn(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 nbn(){return typeof document>"u"?null:{visibility:document.visibilityState,focused:document.hasFocus(),reportedAt:Date.now()}}const ibn=["entities","entityCount","ontologyInvariants"];function sbn(t){const r={...t};for(const i of ibn)delete r[i];for(const i of zgn())delete r[i];return{...r,_statePatch:!0}}function CEt(t,r=null){const i=kZ(),a=I_(),l=a?Pw(a)?.presentation():void 0,d=zUe(t),_=T3t.getSnapshot(),g=r?.entities??$0e(t);return{playState:H1n({storePlayState:t.playState,liveMounted:kQe(),livePlaying:Z1e()}),mountFailures:i.map(b=>({...b})),moduleSplits:Qgn().map(b=>({path:b.path,urls:[...b.urls]})),adapter:wb(),readiness:DGt().map(b=>({...b})),readinessWarning:W1n(),worldAdoption:Y1n().map(b=>({...b})),presence:nbn(),pageErrors:obn(),consoleErrors:abn(),sessionErrors:cbn(),sessionWarnings:lbn(),rendererResources:{hostLive:Tjr(),interactive:lyn(),inspectorPreview:Djr()},ontologyInvariants:r?.ontologyInvariants??GHt().map(b=>({...b})),...qgn(r),selectedEntityId:d[0]??null,selectedEntityIds:d,selectedCreationSite:Z$r(t),selectedWriteAnchorKind:eqr(t),activeViewportTab:t.activeViewportTab,activeDocumentId:a,activeUtilityId:V7r(),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&&TNt(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:qUe(t),saveState:sNt(t),camera:rbn(t),entities:g,viewportActivationTimings:WOr()}}function PGt(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 EEt(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<TEt||S>J$?`${String(t.type)}: "${b}" must be ${TEt}-${J$} — ${kEt}`: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 — ${kEt}`}:{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 TEt=64,J$=1024,kEt="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 zQe(t){const r=AQe();return!r||t<r.startedAt?!1:r.endedAt===null||t<=r.endedAt}function obn(){return ua.getEntries().filter(t=>t.level==="error"&&t.source==="runtime"&&zQe(t.timestamp)).slice(-100).map(t=>t.count>1?`${t.message} (×${t.count})`:t.message)}const IEt=200;function abn(){return UQe(ua.getEntries().filter(t=>t.level==="error"&&t.source!=="runtime"&&zQe(t.timestamp)))}function UQe(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>IEt?`${a.message.slice(0,IEt)}…`:a.message;return`${l}${_}${d}`});return{count:r,recent:i}}function cbn(){return UQe(ua.getEntries().filter(t=>t.level==="error"&&!zQe(t.timestamp)))}function lbn(){return UQe(ua.getEntries().filter(t=>t.level==="warn"))}async function ubn(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 x3t(i);const a=pZ(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 fbn(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=cNt("capture-asset-preview",j);if(typeof X=="string")return{ok:!1,error:X};const G=lNt("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=XBr(k)}catch(se){return{ok:!1,error:se instanceof Error?se.message:String(se)}}const xe=ome(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&&ome(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"?fte(eO(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=ome(ge.forward),tt={...typeof _=="number"?{width:_}:{},...typeof g=="number"?{height:g}:{},...qe?{refForward:qe}:{}};return{ok:!0,data:{...typeof i=="string"?await L$r(i,ge.glbBase64,tt):await eNt(fe,ge.glbBase64,tt)}}}return ee!==void 0?{ok:!0,data:{...typeof l=="string"?await k$r(l,ee,se):typeof i=="string"?await N$r(i,ee,se):BUe(fe,ee,se)}}:S==="source"?{ok:!0,data:{...typeof i=="string"?await D$r(i,xe,se):Q6t(fe,xe,se)}}:ue?{ok:!0,data:{...b$r(fe,ue,se)}}:typeof l=="string"?{ok:!0,data:{...await T$r(l,se)}}:{ok:!0,data:{...typeof i=="string"?await Z6t(i,se):M0e(fe,se)}}}catch(se){return{ok:!1,error:se instanceof Error?se.message:String(se)}}}async function dbn(t,r,i){rqr(r.type);const a=wQe(r);if(a)return a;if(r.type==="play"||r.type==="restart"){const _=kZ();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=xIt(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 PGt(r,_)}if(!rze(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 Ygn(),{ok:!0};case"select":{const _=r.id??null;if(_!==null){const g=wEt(t,_);if(g)return{ok:!1,error:g}}JRe(t,_?[_]:[],i);break}case"select-multiple":{const _=r.ids;for(const g of _){const b=wEt(t,g);if(b)return{ok:!1,error:b}}JRe(t,_,i);break}case"select-all":{JRe(t,$0e(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=eO(t);if(b.hierarchy.node(_)!==null&&b.rects){t.focusOnEntity(_);break}if(!fte(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 XHt(_)}}}catch(_){return{ok:!1,error:_ instanceof Error?_.message:String(_)}}case"active-tab":{const _=r.key;if(_!=="__inspector__"&&!Sb(_)){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 kNt(g,_))return{ok:!1,error:`Asset document did not finish mounting its Inspector: ${g}`};break}case"close-asset-tab":{const _=r.key;TNt(_)&&K8(_);break}case"toggle-command-palette":NQe();break;case"toggle-console":ibe();break;case"page-reload":return setTimeout(()=>{window.location.reload()},0),{ok:!0,data:{scheduled:!0}};case"set-workspace":{const _=r.workspace;if(!AZ(_))return{ok:!1,error:`set-workspace requires one of ${Qze().join(", ")}, got ${String(_)}.`};if(wS()===_)return{ok:!0,data:{workspace:_,applied:!0}};const g=yPt().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=cU().map(S=>S.id);if(typeof _!="string"||!g.includes(_))return{ok:!1,error:`set-style requires one of ${g.join(", ")}, got ${String(_)}.`};tUe(_);const b=jhe();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."}:r0e(_)?(wPt(_),{ok:!0,data:{material:uz(),style:jhe()}}):{ok:!1,error:`set-appearance material must be one of ${_5r().map(b=>b.id).join(", ")}, got ${String(_)}.`}}case"present-view":try{return{ok:!0,data:{...await vye(t,r.view)}}}catch(_){return{ok:!1,error:_ instanceof Error?_.message:String(_)}}case"current-view":return{ok:!0,data:{view:lte(t)}};case"inspect":return{ok:!0,data:{subject:nbe(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 q1n(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 Hyn(_,r.args);return{ok:!0,data:{result:g===void 0?null:g}}}catch(_){return{ok:!1,error:_ instanceof Error?_.message:String(_)}}case"hierarchy":{const _=JCt();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:Wgn(_,{playState:t.playState,activeViewportTab:t.activeViewportTab})}}}case"expand-hierarchy-all":case"collapse-hierarchy-all":{const _=r.type==="expand-hierarchy-all",g=JCt();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=Vgn();_?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 U1n(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 V1n(t,_);return{ok:!0,data:{subject:g.subject,write:g.write}}}catch(_){return _ instanceof iqe?{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=zUe(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=v0e(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 dUe(g,S):await zhe(g,w())}};case"duplicate":{if(S.length>1&&P.duplicateMany)return{ok:!0,data:{write:await i4t(g,S)}};const j=b0e(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 PR(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 pUe(g,w(),j)}}}case"wrap":return P.wrap?{ok:!0,data:{write:await A0e(g,w(),N("tag"))}}:{ok:!1,error:"structure-op: this adapter has no `wrap`."};case"unwrap":return P.unwrap?{ok:!0,data:{write:await S0e(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=x0e(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=_Ue(g,w());return{ok:!0,data:{ids:j.ids,write:await j.ack}}}case"copy":return P.copy?{ok:!0,data:{copied:await w0e(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 C0e(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 E0e(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 f0n(r.step)}}}catch(_){return{ok:!1,error:_ instanceof Error?_.message:String(_)}}case"capture-active-document":{const _=EEt(r);if("error"in _)return{ok:!1,error:_.error};try{return r.view&&await vye(t,r.view),{ok:!0,data:{...await T0n(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 Bgn(t,_===void 0?void 0:{scale:_})}}}catch(g){return{ok:!1,error:g instanceof Error?g.message:String(g)}}}case"capture-viewport":{const _=EEt(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 fbn(t,r);case"document-table":{const _=wb();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=ebe(),b=g?wb()?.scenes.entries.find(N=>N.id===_):void 0,S=g?async N=>await FHt(N)??{ok:!1,error:"No running lane can remount with a selection."}:void 0,w=(b?await G1n(b,{scenes:CQe,activateGameDocument:()=>Sb(Sw),gameDocumentId:Sw,...S?{remountSelection:S}:{}}):null)??await Ymn(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 ubn(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 pbn(t,r){const i=VP();let a=null,l=-1;const d=new Set;let _=!1,g=null,b=null,S=null;const k=()=>{Vpe()===null&&(a=CEt(t),l=t.contentVersion,V2t(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=GCt(()=>{w=null,_=!1,k()})},250)},J=cr=>{if(t.contentVersion!==cr){j();return}P(),b=cr,S=setTimeout(P,1e3)},X=()=>ebe()&&t.playState==="playing",G=cr=>{(cr!==null||b!==null&&t.contentVersion!==b||_&&t.contentVersion!==l)&&j()},ee=(cr,Yt,Lr)=>X()?(tbn(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(Vpe()!==null)return;if(a===null){k();return}const nn=CEt(t,a);a=nn,V2t(sbn(nn)),cr!=="none"&&(ee(Yt,Lr,cr)||(N(),P(),_=!1,!(cr==="if-content-changed"&&t.contentVersion===l)&&w===null&&(w=GCt(()=>{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=DQe(qe),Ot=YP(qe),vt=VOr(qe);k(),Jpe(!0),VFr(tzr),i.addEventListener("open",()=>{xe("if-content-changed"),Jpe(Vpe()===null)});const Et=JUe(cr=>{Jpe(cr===null)});i.addEventListener("editor-command",cr=>{try{const Yt=JSON.parse(cr.data),Lr=Yt._requestId,nn=t.contentVersion,on=Vpe();if(on!==null){const An=mqr(on,String(Yt.type));Lr&&J2t(Lr,!1,An);return}Lr&&ezr(Lr);let gr;dbn(t,Yt,{deferPresentation:An=>{gr=An},...r?{history:r}:{}}).catch(An=>PGt(Yt,An)).then(An=>{if(Lr){const ln=J2t(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=ebn(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),()=>{Jpe(!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 _bn(t,r,i){return Xe.createContext(i)}const XP=_bn(void 0,"EditorContext",null);function mbn({runtime:t,children:r}){const i=Xe.useMemo(()=>({begin:()=>{},end:()=>{}}),[]);return z.jsx(XP.Provider,{value:t,children:z.jsx(g3t.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 e4n(){const t=Xe.useContext(XP);if(!t)throw new Error("useEditorStats must be used within <EditorProvider>");return t.stats}function hbn(){const t=Xe.useContext(XP);if(!t)throw new Error("useEditorInit must be used within <EditorProvider>");return t.initPromise}function NGt(){const t=Xe.useContext(XP);if(!t)throw new Error("useHistoryService must be used within <EditorProvider>");return t.session.history}function gbn(){return Xe.useContext(XP)?.session.history??null}function t4n(){return Xe.useContext(XP)?.store??null}function r4n(){return Xe.useContext(XP)?.stats??null}function obe(){const t=Xe.useContext(XP);if(!t)throw new Error("useHistoryCommands must be used within <EditorProvider>");return t.session.historyCommands}function OGt(){const t=obe();return Xe.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getSnapshot)}class ybn{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 vbn=new Bye(-1,1,1,-1,0,1);class bbn extends Hqe{constructor(){super(),this.setAttribute("position",new q1t([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new q1t([0,2,0,0,2,0],2))}}const Abn=new bbn;class Sbn{constructor(r){this._mesh=new NA(Abn,r)}dispose(){this._mesh.geometry.dispose()}render(r){r.render(this._mesh,vbn)}get material(){return this._mesh.material}set material(r){this._mesh.material=r}}const b_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
|
}`)),DEt.value=t,W$}function Cbn(t,r=BHt){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 Ebn=1e20,Tbn=2e20;function kbn(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=Ebn,a.far=Tbn),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 Ibn=256;function Dbn(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=Dbn(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&&(wZ(a,"skeletonVisible",i),a.traverse(l=>{CE(l,"editorHelperType")==="skeletons"&&(wZ(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-Ibn);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(PUe(g))return;const b=jHt(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 z1t(d,_,{type:QN}),S=new z1t(d,_),k=g.getRenderTarget(),w=g.getPixelRatio(),N=this._camera,P=N.layers.mask,j=N instanceof jye?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),kbn(this._scene,()=>g.render(this._scene,N)),wbn().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?Cbn(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 Pbn{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 Nbn(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 Obn{constructor(r,i={}){this.projectIdentity=r,this.history=new jLr(i),this.historyCommands=new Pbn(this.history),this.releaseLimitNotices=Nbn(this.history)}history;historyCommands;releaseLimitNotices;dispose(){this.releaseLimitNotices(),this.historyCommands.dispose(),this.history.dispose()}}Promise.resolve();function Fbn(){const t=Rbn();return t.then(()=>{},()=>{}),t}async function Rbn(){await Mbn()}async function Mbn(){const t=ad();if(t){ua.log(`Opened project: ${t.config.name}`,"project");return}try{const r=await GNt();r&&ua.log(`Opened project: ${r.config.name}`,"project")}catch{}}function WRe(t){return Promise.reject(new Error(`This editor tier cannot ${t}.`))}const FGt={openPersistence:()=>WRe("persist Asset Lab documents"),replaceSource:()=>WRe("write project source"),saveThumbnailFraming:()=>WRe("write project thumbnail framing")};let Ume=FGt;function Lbn(t){if(Ume!==t){if(Ume!==FGt)throw new Error("An Object3D document write policy is already installed.");Ume=t}}function RGt(){return Ume}function jbn(){let t=0;const r=async()=>{const a=++t,l=ad();if(l)try{const d=await yNt();if(d.status!=="project"||d.project.path!==l.rootPath)return;const _=d.project.config;if(a!==t||ad()!==l)return;tze({...l,config:_})}catch(d){a===t&&ad()===l&&console.error("[project] Could not refresh project declarations:",d)}},i=DUr(()=>void r());return()=>{t++,i()}}const Bbn=400;let Vme=null,kY=null,Qz={},sqe=!1,Kq=null;function MGt(){return hh()}function abe(){const t=MGt();return Vme===t?Promise.resolve():kY?kY.then(()=>abe()):(kY=Promise.all([Xqr(),G3t()]).then(([r])=>{Qz=r&&typeof r=="object"?{...r}:{},Vme=t}).catch(()=>{Qz={},Vme=t}).finally(()=>{kY=null}),kY)}function dte(){return Vme===MGt()}function VQe(t){if(dte())return Qz[t]}function LGt(){Kq!==null&&(clearTimeout(Kq),Kq=null),sqe&&(sqe=!1,Zqr(Qz))}function cbe(t,r){const i=()=>{Qz={...Qz,[t]:r},sqe=!0,Kq!==null&&clearTimeout(Kq),Kq=setTimeout(LGt,Bbn)};dte()?i():abe().then(i)}function $bn(){LGt()}Iw(()=>{ad()&&abe()});typeof window<"u"&&window.addEventListener("pagehide",$bn);function qbn(){return s3r(()=>{IQe(),B9r(null),yOr(),$yn(),QOr(),WDt(),Rmn(),pP()})}async function zbn(){typeof performance<"u"&&performance.getEntriesByType("navigation").length>0&&await Promise.race([e0e(),new Promise(r=>setTimeout(r,5e3))]),await WR()}function Ubn(){zbn();const t=Iw(()=>void WR()),r=VNt(()=>void WR());return()=>{t(),r()}}const Vbn={tools:[],contributions:[],loadErrors:[]};let jGt=Vbn,BGt=0;const oqe=new Set;function PEt(t){jGt=t,BGt++;for(const r of oqe)r()}function Kz(){return jGt}function Jbn(){return BGt}function $Gt(t){return oqe.add(t),()=>oqe.delete(t)}async function ZX(){try{const t=await fetch("/__editor/project-tools"),r=await Eg(t,"Catalog request failed");return PEt(r),r}catch(t){const r={tools:[],contributions:[],loadErrors:[{sourcePath:"package.json#vgai.tools",message:t instanceof Error?t.message:String(t)}]};return PEt(r),r}}async function Wbn(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 Hbn(){ZX();const t=Iw(()=>void ZX()),r=VNt(()=>void ZX());return()=>{t(),r()}}let qGt=null;function Gbn(t){qGt=t,t!==null&&Qbn()}const NEt=128;let pX=[],eZ=null,zGt=0,HRe=!1;function Qbn(){if(HRe)return()=>{};if(typeof PerformanceObserver>"u")return()=>{};let t;try{t=new PerformanceObserver(r=>{for(const i of r.getEntries()){const a=i.duration;(eZ===null||a>eZ)&&(eZ=a),a>=100&&(zGt+=1),pX.push({start:i.startTime,duration:a}),pX.length>NEt&&(pX=pX.slice(-NEt))}}),t.observe({type:"longtask",buffered:!0})}catch{return()=>{}}return HRe=!0,()=>{t.disconnect(),HRe=!1}}function Kbn(t=performance.now()){const r=qGt;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 pX)_.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:eZ===null?null:Math.round(eZ),tasksOver100ms:zGt,lastCallLongestTaskMs:l===null?null:Math.round(l),wasmMemoryMB:i.wasmMemoryMB}}function OEt(t){return!("unavailable"in t)}function Ybn(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 Xbn=5e3,Zbn=4,eAn=1024*1024;function GRe(t){return Math.round(t/eAn*100)/100}function tAn(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*Zbn;return{heapUsedMB:OEt(r)?GRe(r.usedBytes):null,heapLimitMB:OEt(r)&&r.limitBytes!==null?GRe(r.limitBytes):null,mountEpochs:t.mountEpochs(),canvases:i.length,canvasMB:GRe(d),...l===null?{}:{blender:l},...a===null?{}:{textures:a.textures,geometries:a.geometries,...a.programs===null?{}:{programs:a.programs}}}}function rAn(t){const r=new Set;for(const i of t)try{const a=new URL(i.name,"http://vgai.invalid").searchParams.get(wUr);a!==null&&a.length>0&&r.add(a)}catch{}return r.size}function nAn(){return{heap:()=>Ybn(),mountEpochs:()=>rAn(performance.getEntriesByType("resource")),canvases:()=>[...document.querySelectorAll("canvas")],rendererCounts:()=>kOr()?.memorySnapshot?.().counts??null,blender:()=>Kbn()}}let UGt=null;function n4n(){return UGt}function iAn(t){const r=t.sources??nAn(),i=t.hidden??(()=>document.visibilityState==="hidden"),a=()=>{if(i())return;const d=tAn(r);UGt=d,t.report(d)};a();const l=setInterval(a,t.intervalMs??Xbn);return()=>clearInterval(l)}const sAn=oAn("SERVER_STATE_PERSISTENCE",()=>({save:t=>cbe("view",t),saveThumbnail:Gqr}));function oAn(t,r){return r()}function aAn({children:t}){const r=Xe.useRef(null);r.current||(r.current=new Eq,fzr(r.current));const i=Xe.useRef(null);if(!i.current){const _=ad();i.current=new Obn(_?.rootPath??"unknown-project")}r.current.attachHistory(i.current.history),yjr(xjr),Lbn(rjr),r.current.attachStatePersistence(sAn);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=Fbn()),Xe.useEffect(()=>pbn(r.current,i.current.historyCommands),[]),Xe.useEffect(()=>Ubn(),[]),Xe.useEffect(()=>Hbn(),[]),Xe.useEffect(()=>Dmn(),[]),Xe.useEffect(()=>jbn(),[]),Xe.useEffect(()=>qbn(),[]),Xe.useEffect(()=>Qmn(r.current),[]),Xe.useEffect(()=>iAn({report:Tqr}),[]);const d=Xe.useRef(!1);return Xe.useEffect(()=>{d.current=!0;const _=i.current;return()=>{d.current=!1,queueMicrotask(()=>{d.current||_.dispose()})}},[]),z.jsx(mbn,{runtime:{store:r.current,stats:a.current,initPromise:l.current,session:i.current},children:t})}const xye={x:0,y:0,zoom:1};function i4n(t=xye){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=xye,a())},subscribe:l=>(i.add(l),()=>i.delete(l))}}let bw=xye;const aqe=new Set,s4n={get:()=>cAn(),setView:(t,r,i)=>JQe(t,r,i),setPan:(t,r)=>lAn(t,r),setZoom:t=>uAn(t),reset:()=>JGt(),subscribe:t=>fAn(t)};function VGt(){for(const t of aqe)t()}function cAn(){return bw}function JQe(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},VGt())}function lAn(t,r){JQe(t,r,bw.zoom)}function uAn(t){JQe(bw.x,bw.y,t)}function JGt(){bw.x===0&&bw.y===0&&bw.zoom===1||(bw=xye,VGt())}function fAn(t){return aqe.add(t),()=>aqe.delete(t)}function o4n(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 dAn(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 FEt=8,J8=8,a4n=[{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 c4n(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/FEt)*FEt}function WGt(t,r,i,a,l){let d=Math.max(J8,gI(r.width+t,i)),_=null;return a.length&&(_=lbe(r.x+d,a,l),_&&(d=Math.max(J8,_.edge-r.x))),{value:d,match:_}}function HGt(t,r,i,a,l){const d=r.x+r.width;let _=Math.max(J8,gI(r.width-t,i)),g=null;return a.length&&(g=lbe(d-_,a,l),g&&(_=Math.max(J8,d-g.edge))),{value:_,eastEdge:d,match:g}}function GGt(t,r,i,a,l){let d=Math.max(J8,gI(r.height+t,i)),_=null;return a.length&&(_=lbe(r.y+d,a,l),_&&(d=Math.max(J8,_.edge-r.y))),{value:d,match:_}}function QGt(t,r,i,a,l){const d=r.y+r.height;let _=Math.max(J8,gI(r.height-t,i)),g=null;return a.length&&(g=lbe(d-_,a,l),g&&(_=Math.max(J8,d-g.edge))),{value:_,southEdge:d,match:g}}function pAn(t,r,i,a,l,d,_){if(t==="e"||t==="ne"||t==="se")return{width:WGt(r,i,l,d,_).value};if(t==="w"||t==="nw"||t==="sw"){const{value:g,eastEdge:b}=HGt(r,i,l,d,_);return a?{width:g,x:b-g}:{width:g}}return{}}function _An(t,r,i,a,l,d,_){if(t==="s"||t==="sw"||t==="se")return{height:GGt(r,i,l,d,_).value};if(t==="n"||t==="nw"||t==="ne"){const{value:g,southEdge:b}=QGt(r,i,l,d,_);return a?{height:g,y:b-g}:{height:g}}return{}}function l4n(t,r,i,a,l,d,_,g=c9){const b=!d&&_?pte(_):null,S=b?_te(b):[],k=b?mte(b):[];return{...pAn(t,r,a,l,d,S,g),..._An(t,i,a,l,d,k,g)}}const c9=4;function pte(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 _te(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 mte(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 Yz(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 lbe(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 u4n(t,r,i,a,l){let d=gI(i.x+t,a),_=gI(i.y+r,a);if(!a&&l){const g=pte(l);d=Yz(d,i.width,_te(g),c9).value,_=Yz(_,i.height,mte(g),c9).value}return{x:d,y:_}}function f4n(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:fee({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:fee({x:J.x,y:J.y,width:0,height:0},w,N),position:J}}function fee(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 d4n(t,r,i,a,l,d=c9){if(a||!l)return[];const _=gI(i.x+t,!1),g=gI(i.y+r,!1),b=pte(l),S=Yz(_,i.width,_te(b),d).match,k=Yz(g,i.height,mte(b),d).match,w={x:_,y:g,width:i.width,height:i.height};return fee(w,S,k)}function p4n(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?pte(a):null,k=S?_te(S):[],w=S?mte(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}:Yz(b.x,b.width,k,_),P=l==="x"?{value:b.y,match:null}:Yz(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:fee(j,N.match,P.match)}}function _4n(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=pte(d),N=_te(w),P=mte(w);let j=null;g?j=WGt(r,a,!1,N,_).match:b&&(j=HGt(r,a,!1,N,_).match);let J=null;return S?J=GGt(i,a,!1,P,_).match:k&&(J=QGt(i,a,!1,P,_).match),fee(a,j,J)}function m4n(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 REt=new WeakMap;function mAn(t){const r=t.boxEdit;if(!r)return null;const i=REt.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 REt.set(t,{provider:r,recorded:a}),a}function hAn(t,r){return I9(t,r)?.rects?.rect(r)??null}function gAn(t,r){const i=I9(t,r);return i?mAn(i):null}function h4n(t,r){return I9(t,r)?.rects?.contextRects?.(r)}function g4n(t,r){return I9(t,r)?.structure??null}function y4n(t,r){return I9(t,r)?.text??null}function v4n(t,r){return I9(t,r)?.colorSample??null}function b4n(t,r){const i=I9(t,r);return i?.rects?V9r(i):null}function A4n(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 yAn(t,r){const i=a=>{const l=t.inspector?.get(r,`style.${a}`);return dAn(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 vAn=4;function S4n(t,r){const i=w=>w>0?w:vAn,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 bAn(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 x4n(t,r,i,a){const l=bAn(t,r,i),d=Math.max(0,Math.round(a+l));return{[t]:d}}function w4n(t,r,i){return{x:t.x+r,y:t.y+i,width:t.width,height:t.height}}const QRe=3;function V7(t,r){return r==="x"?t.x+t.width/2:t.y+t.height/2}function AAn(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 SAn(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=QRe/2;return i?{x:r-d,y:a,width:QRe,height:l-a}:{x:a,y:r-d,width:l-a,height:QRe}}function C4n(t,r){if(t.length===0)return null;const i=Math.max(...t.map(N=>V7(N.rect,"x")))-Math.min(...t.map(N=>V7(N.rect,"x"))),a=Math.max(...t.map(N=>V7(N.rect,"y")))-Math.min(...t.map(N=>V7(N.rect,"y"))),l=i>=a,d=l?"x":"y",_=[...t].sort((N,P)=>V7(N.rect,d)-V7(P.rect,d)),g=l?r.x:r.y;let b=0;for(;b<_.length&&V7(_[b].rect,d)<g;)b++;const S=b<_.length?_[b].id:null,k=AAn(_,b,l),w=SAn(_,k,l);return{beforeSiblingId:S,index:b,marker:w}}function E4n(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 T4n(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 KRe(t,r,i){const a=t?.get(r,i);return typeof a=="string"&&a.length>0?a:null}function k4n(t,r){const i=KRe(t.inspector,r,"style.position");let a=null;const l=t.hierarchy.node(r)?.parentId??null;if(l){const d=KRe(t.inspector,l,"style.display");d==="flex"||d==="inline-flex"?a=`flex ${(KRe(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 I4n(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 D4n(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 P4n(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 xAn(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 MEt=!1;const KGt=new Set(["viewport","hierarchy","inspector","asset-browser","workspace","global"]);let YGt="viewport";const XGt="editorActiveHotkeyScope";function wAn(){const t=document.documentElement.dataset[XGt];return t&&KGt.has(t)?t:YGt}function W8(t){YGt=t,document.documentElement.dataset[XGt]=t}const CAn="data-editor-app-undo";function LEt(t){return t instanceof Element&&t.closest(`[${CAn}]`)!==null}function cqe(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 EAn(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&&KGt.has(i))return i}return null}function jEt(t){const r=EAn(t);r&&W8(r)}const YRe=[];function BEt(t){return YRe.push(...t),()=>{for(const r of t){const i=YRe.indexOf(r);i>=0&&YRe.splice(i,1)}}}function ZGt(){MEt||(window.addEventListener("pointerdown",jEt,!0),window.addEventListener("focusin",jEt,!0),MEt=!0)}const tZ=new Map;let eQt=0;const lqe=new Set;function $Et(){eQt++;for(const t of lqe)t()}function TAn(t){return tZ.set(t.id,t),$Et(),()=>{tZ.get(t.id)===t&&(tZ.delete(t.id),$Et())}}function kAn(){return[...tZ.values()]}function IAn(){return eQt}function DAn(t){return lqe.add(t),()=>lqe.delete(t)}function PAn(t){const r=tZ.get(t);return!r||r.enabled&&!r.enabled()?!1:(r.run(),!0)}const NAn=["position","rotation","scale"];function OAn(t){const r=t.role==="component"&&!!t.typeLabel;return{label:t.label,typeSuffix:r?t.typeLabel:null}}const WQe={locked:!1};function tQt(t){let r;for(const i of NAn){const a=t(i);if(!a||a.writable)return WQe;i==="position"&&(r=a.reason)}return r===void 0?{locked:!0}:{locked:!0,reason:r}}class FAn{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?tQt(g=>d(a,g)):WQe;return this.entries.set(a,_),_}}const RAn={draggable:!0,renamable:!0,writable:!0,searchable:!0},MAn={draggable:!1,renamable:!1,writable:!0,searchable:!0},LAn={draggable:!1,renamable:!1,writable:!1,searchable:!1};function HQe(t){return t.internal?LAn:t.structural?MAn:RAn}function jAn(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 BAn{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?jAn(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 _=tQt(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 zUe(t)}async function GQe(t){const r=ZP(t);r.length!==0&&await w0e(wm(t).adapter,r)}async function QQe(t){const r=ZP(t);r.length!==0&&await C0e(wm(t).adapter,r)}async function KQe(t){const r=wm(t).adapter,i=ZP(t)[0],a=i?r.hierarchy.node(i)?.parentId??null:null;await E0e(r,a)}let qEt=Promise.resolve();function ube(t){const r=qEt.then(()=>$An(t));return qEt=r.then(()=>{},()=>{}),r}async function $An(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 i4t(i,r);if(d&&!d.persisted){My(d.destination);return}}else for(const d of r){const _=await b0e(i,d).ack;if(_&&!_.persisted){My(_.destination);return}}My(`Duplicated ${l}`)}async function fbe(t){const r=ZP(t);if(r.length===0)return;const i=wm(t).adapter,a=i.structure;if(a)if(a.removeMany)await dUe(i,r);else{const l=new Map(YPt(i).map((_,g)=>[_,g])),d=[...r].sort((_,g)=>(l.get(g)??-1)-(l.get(_)??-1));for(const _ of d)await zhe(i,_)}}async function qAn(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 A0e(i,l)}async function zAn(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 S0e(i,l)}async function UAn(t){const r=ZP(t);if(r.length===0)return;const i=wm(t).adapter;i.structure?.group&&await x0e(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 _=gAn(l,d);if(!_)continue;const g=hAn(l,d);if(!g)continue;const b=l.inspector?.get(d,"style.position"),S=b==="absolute"||b==="fixed",k=yAn(l,d),w=xAn(r,i,S,g,{left:k.marginLeft,top:k.marginTop});Object.keys(w).length!==0&&(_.begin(d),_.apply(d,w),_.end(d))}}function VAn(t){const r=Array.isArray(t)?t:[t];return r.includes("global")?"global":r.length===1&&r[0]==="viewport"?"stage":"panel"}let Jme=null;function Eu(t,r){const{frameEnabled:i,...a}=r;return Jme?.push(TAn({id:t,run:l=>a.action(l??new KeyboardEvent("keydown")),scope:VAn(a.scope),...i?{enabled:i}:{}})),Uze(t).map(l=>({...a,...l}))}function rQt(t){const r=()=>{const _=[],g=Jme;Jme=_;try{return{rows:t(),actions:_}}finally{Jme=g}};let i=r(),a=BEt(i.rows);const l=()=>{a();for(const _ of i.actions)_()},d=sU(()=>{l(),i=r(),a=BEt(i.rows)});return()=>{d(),l()}}function JAn(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=rQt(()=>[...Eu("edit.redo",{scope:"global",allowInEditable:!0,when:d=>!cqe(d.target)||LEt(d.target),action:a}),...Eu("edit.undo",{scope:"global",allowInEditable:!0,when:d=>!cqe(d.target)||LEt(d.target),action:i}),...Eu("edit.copy",{scope:cw,when:H$,frameEnabled:H$,action:()=>void GQe(t)}),...Eu("edit.cut",{scope:cw,when:H$,frameEnabled:H$,action:()=>void QQe(t)}),...Eu("edit.paste",{scope:cw,when:H$,frameEnabled:H$,action:()=>void KQe(t)}),...Eu("edit.duplicate",{scope:cw,action:()=>void ube(t)}),...Eu("edit.group",{scope:cw,action:()=>void UAn(t)}),...Eu("edit.wrap",{scope:cw,action:()=>qAn(t)}),...Eu("edit.unwrap",{scope:cw,action:()=>zAn(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,YPt(d))}}),...Eu("edit.deselectAll",{scope:cw,action:()=>k0(wm(t).adapter,[])}),...Eu("edit.save",{scope:"global",allowInEditable:!0,action:()=>{r5r().then(d=>{d===null&&aNt(t)})}}),...Eu("view.resetPan",{scope:"viewport",action:()=>JGt()}),...Eu("edit.enterScope",{scope:cw,when:()=>t.playState==="stopped",frameEnabled:()=>t.playState==="stopped",action:()=>{Z9r(wm(t).adapter)}}),...Eu("edit.delete",{scope:cw,action:()=>void fbe(t)}),...Eu("edit.exitScopeOrDeselect",{scope:cw,when:()=>hUe()!==null||t.playState==="stopped",frameEnabled:()=>!0,action:()=>{const d=wm(t).adapter;if(!X9r(d)){if(t.playState!=="stopped"){IQe();return}t.select(null)}}}),...Eu("view.commandPalette",{scope:"global",action:()=>{NQe()||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:()=>ibe()}),...Eu("view.focusMode",{scope:"global",action:()=>Wze()}),...Eu("workspace.cycleNext",{scope:"global",action:()=>{Nhe(1)}}),...Eu("workspace.cyclePrevious",{scope:"global",action:()=>{Nhe(-1)}})]);return ZGt(),l}function N4n(t,r,i){const a=rQt(()=>[...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=()=>W8("viewport");i.addEventListener("pointerdown",l),ZGt();const d=b=>Uze("viewport.vertexSnapHold").some(S=>S.key===b.key.toLowerCase()),_=b=>{if(d(b)&&!b.metaKey&&!b.ctrlKey&&!b.repeat){if(wAn()!=="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 YQe(){H7r("undo-history")}function WAn(){const t=()=>YQe();return window.addEventListener("editor:show-history-tab",t),()=>window.removeEventListener("editor:show-history-tab",t)}let uqe=null,nQt=0;const fqe=new Set;function XQe(t){if(uqe!==t){uqe=t,nQt++;for(const r of fqe)r()}}function iQt(){return uqe}function HAn(t){XQe(t)}function sQt(){XQe(null)}function oQt(t){return fqe.add(t),()=>fqe.delete(t)}function dqe(){return nQt}function GAn(){XQe(null)}const QAn=Object.freeze(Object.defineProperty({__proto__:null,__resetEditorPresentationNoticeForTest:GAn,clearEditorPresentationNotice:sQt,editorPresentationNotice:iQt,editorPresentationNoticeVersion:dqe,showEditorPresentationNotice:HAn,subscribeEditorPresentationNotice:oQt},Symbol.toStringTag,{value:"Module"})),zEt="agent-presented-view";function KAn(){const t=D0();Xe.useSyncExternalStore(oQt,dqe,dqe);const r=iQt();return Xe.useEffect(()=>{if(!r){Oze(zEt);return}oz({id:zEt,tone:"info",title:"Agent presented this view.",...r.presented.warnings.length>0?{detail:r.presented.warnings.join(" ")}:{},onDismiss:sQt,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:()=>{vye(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 YAn=4e3;let rZ=null,Wme=null,wye=null,dee=!1,Hme=null,UEt=!1;const Cye=new Set,XAn=()=>null;function aQt(){const t=rZ;if(!t)return null;const r=Wme;return{id:Sw,title:"Game",kind:"game",workspaceRole:"authored-subject",Content:r?.Content??XAn,...r?.Toolbar?{Toolbar:r.Toolbar}:{},closeable:!1,presentation:()=>({kind:"workspace",id:Sw}),onActivate:()=>t.onActivate()}}function ZAn(t){return rZ=t,()=>{rZ===t&&(ZQe(),rZ=null)}}function e2n(t){if(Wme=t,dbe()){const r=aQt();r&&qP(r,{activate:!1})}return()=>{Wme===t&&(Wme=null)}}function dbe(){return FA().some(t=>t.descriptor.id===Sw)}function t2n(){return wye}function r2n(t){wye=t,dee=!0;for(const r of[...Cye])r();Cye.clear()}function n2n(t){wye===t&&(wye=null,dee=!1)}async function i2n(t=YAn){const r=aQt();return r?(dbe()?Sb(r.id):(Hme=I_(),qP(r)),dee?!0:new Promise(i=>{const a=()=>{clearTimeout(l),i(!0)},l=setTimeout(()=>{Cye.delete(a),i(dee)},t);Cye.add(a)})):!1}function ZQe(){if(!rZ||!dbe()){Hme=null;return}const t=Hme;Hme=null,dee=!1,K8(Sw,{discardDirty:!0}),t&&Sb(t)}function s2n(t){UEt&&!t&&ZQe(),UEt=t}function o2n(t){Xe.useEffect(()=>{const r=ZAn({onActivate:()=>t.setActiveViewportTab("play")}),i=()=>s2n(t.playState!=="stopped");i();const a=t.subscribe(i);return()=>{a(),r(),WDt()}},[t])}const pee={console:{id:"console",title:"Console"},lightExplorer:{id:"light-explorer",title:"Light Explorer"}},a2n={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(pee),...Object.values(a2n)];const c2n={info:Oo.content.primary,warn:Oo.semantic.warning,error:Oo.semantic.danger},VEt={scene:"#78dce8",physics:"#ff6188",animation:"#a9dc76",network:"#fc9867",audio:"#ab9df2",ai:"#ffd866",input:"#78dce8",core:Oo.content.primary},JEt={info:vee,warn:Zkt,error:qkt};function l2n(){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(w5r,{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:Lkt,size:"xs"})}),z.jsx(Zbt,{}),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(Zbt,{}),["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:JEt[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:c2n[ee.level]},children:[z.jsx("span",{style:{color:Oo.content.dim,marginRight:6,flexShrink:0},children:J(ee.timestamp)}),z.jsx(So,{icon:JEt[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:`${VEt[ee.subsystem]??Oo.content.muted}22`,color:VEt[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 u2n={enabled:"visible",color:"light.color",intensity:"light.intensity",range:"light.distance",shadows:"shadow.cast"};function cQt(t){const r=[],i=t;return lU(t.hierarchy,a=>{a.kind==="light"&&r.push(a)},{extraChildren:a=>i.internalChildren?.(a)}),r}function O4n(t){return cQt(t).length}function lQt(t,r){return t.find(i=>i.path===u2n[r])??null}function IY(t,r,i,a,l){const d=lQt(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 WEt=t=>typeof t=="boolean",f2n=t=>typeof t=="string",HEt=t=>typeof t=="number"&&Number.isFinite(t);function d2n(t){return cQt(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:IY(t,r.id,i,"enabled",WEt),color:IY(t,r.id,i,"color",f2n),intensity:IY(t,r.id,i,"intensity",HEt),range:IY(t,r.id,i,"range",HEt),shadows:IY(t,r.id,i,"shadows",WEt)}})}function p2n(t,r,i,a){if(!t.inspector)return 0;let l=0;for(const d of r){let _=null;try{_=lQt(t.inspector.properties(d),i)}catch{continue}!_||_.readonly||(t4t(t,d,_.path,a),l++)}return l}function _2n(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 GEt(t,r){return r==="name"||r==="type"?t[r]:t[r].value}function DY({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"?XIr:sIt,size:"xs"}):null]})}function pbe(){return z.jsx("span",{className:"vgai-light-explorer-unavailable",children:"—"})}function m2n({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(pbe,{})}function h2n({row:t,edit:r}){return!t.color.supported||!t.color.value?z.jsx(pbe,{}):z.jsxs("div",{className:"vgai-light-explorer-color",children:[z.jsx(y3t,{"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 QEt({row:t,field:r,step:i,edit:a}){const l=t[r];return l.supported?z.jsx(AX,{value:l.value,disabled:!l.writable,precision:2,step:i,onChange:d=>a(r,d)}):z.jsx(pbe,{})}function g2n({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(pbe,{})}function y2n({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(m2n,{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=>{b2n(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(h2n,{row:t,edit:_})}),z.jsx("td",{children:z.jsx(QEt,{row:t,field:"intensity",step:.1,edit:_})}),z.jsx("td",{children:z.jsx(QEt,{row:t,field:"range",step:.5,edit:_})}),z.jsx("td",{children:z.jsx(g2n,{row:t,edit:_})})]})}function v2n(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 b2n(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 A2n(){const t=D0();Xe.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getSnapshot),Xe.useSyncExternalStore(Aw,Ab,Ab),Xe.useSyncExternalStore(Pee,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=d2n(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=_2n(GEt(ue,g),GEt(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=v2n(ue,X,J);p2n(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(DY,{label:"Name",sortKey:"name",activeKey:g,direction:S,onSort:ee})}),z.jsx("th",{scope:"col",children:z.jsx(DY,{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(DY,{label:"Intensity",sortKey:"intensity",activeKey:g,direction:S,onSort:ee})}),z.jsx("th",{scope:"col",children:z.jsx(DY,{label:"Range",sortKey:"range",activeKey:g,direction:S,onSort:ee})}),z.jsx("th",{scope:"col",children:z.jsx(DY,{label:"Shadows",sortKey:"shadows",activeKey:g,direction:S,onSort:ee})})]})}),z.jsx("tbody",{children:J.map(ue=>z.jsx(y2n,{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 S2n=Zye();function x2n(){const{error:t,warn:r}=ua.counts;return t>0?{count:t+r,severity:"error"}:r>0?{count:r,severity:"warn"}:null}function w2n(){S2n.ensure(t=>{t(TMe({...pee.console,order:-100,Content:l2n,badge:x2n,subscribeBadge:ua.subscribe,badgeSnapshot:ua.getSnapshot,visibleByDefault:!1,closeable:!0})),t(TMe({...pee.lightExplorer,order:21,Content:A2n,visibleByDefault:!1,closeable:!0}))})}const C2n=5742335;function uQt(t,r,i){return t<<16|r<<8|i}function KEt(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:uQt(a[0],a[1],a[2])}function fQt(t){const r=KEt(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,KEt(String(i.fillStyle))):null}function D9(t){return typeof document>"u"?null:t?.closest(`.${iMe}`)??document.querySelector(`.${iMe}`)}function E2n(t){const r=Math.round((t>>16&255)*.42),i=Math.round((t>>8&255)*.42),a=Math.round((t&255)*.42);return uQt(r,i,a)}function l9(t,r){return t&&typeof getComputedStyle<"u"?getComputedStyle(t).getPropertyValue(r).trim():""}function F4n(t){const r=D9(t),i=l9(r,"--vgai-viewport-selection")||l9(r,"--vgai-accent"),a=fQt(i||sz.color.accent.default)??C2n;return{visible:a,hidden:E2n(a)}}function R4n(t){return T2n(t).background!==null}function T2n(t){const r=D9(t),i=a=>{const l=l9(r,a);return l?fQt(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 M4n(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 k2n(t){const r=l9(D9(t),"--vgai-viewport-shelf-tool");return r==="select"||r==="transform"?r:null}function L4n(t){const r=l9(D9(t),"--vgai-viewport-up-axis");return r==="y"||r==="z"?r:null}function j4n(t){const r=l9(D9(t),"--vgai-viewport-box-select");return r==="contain"||r==="touch"?r:null}function B4n(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 $4n(t,r){return r.skinnedMeshes>0?"skinned":r.uniqueBones>0?"rigged":t.clips>0?"animated":"static"}const I2n=["map","alphaMap","aoMap","bumpMap","displacementMap","emissiveMap","envMap","lightMap","metalnessMap","normalMap","roughnessMap","specularMap"];function D2n(t){if(!("color"in t))return null;const r=t.color;return r?.isColor===!0?`#${r.getHexString()}`:null}function P2n(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 YEt(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 N2n(t){const r=YEt(t.getAttribute("position"));if(!r)return null;for(const i of t.morphAttributes.position??[]){const a=YEt(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 XEt(t){return t.matrixAutoUpdate?new SS().compose(t.position,t.quaternion,t.scale):t.matrix.clone()}function O2n(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=N2n(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 F2n(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(XEt(i[d]));const l=(d,_)=>{const g=new SS().multiplyMatrices(_,XEt(d));O2n(r,d,g);for(const b of d.children)l(b,g)};return l(t,a),r.isEmpty()?null:r}function q4n(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+=P2n(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 I2n){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=F2n(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=ihe.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:q2n(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:D2n(tt),transparent:tt.transparent})),textureBindings:g}}function R2n(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 M2n(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 L2n(t,r){const i=ihe.parseTrackName(r.name).nodeName;return i&&!ihe.findNode(t,i)?i:null}function j2n(t){let r=0;const i=new Set;for(const a of t.animations)for(const l of a.tracks){r+=M2n(l);const d=L2n(t,l);d&&i.add(d)}return{nonFiniteValues:r,unresolvedTargets:i}}function z4n(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=R2n(ee);d+=xe.weightedVertices,_+=xe.nonNormalizedVertices,g+=xe.zeroWeightVertices,b+=xe.invalidJointIndices});const P=j2n(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 U4n(t){const r=t.clone().normalize();for(const i of["front","back","left","right","top","bottom"])if(B2n(i).angleTo(r)<.0087)return`${i[0]?.toUpperCase()}${i.slice(1)}`;return null}function B2n(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 $2n(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 q2n(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,pqe=new Map;function dQt(t){let r=pqe.get(t);return r||(r={frameListeners:new Set,helpers:new Map},pqe.set(t,r)),r}const _qe=new Set,mqe=new Set;function _be(){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 Gme=null;function ZEt(){Gme=null;const t=_Qt();for(const r of mqe)r(t)}function z2n(t,r){const i=dQt(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 V4n(t,r,i,a){const l=dQt(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 ZEt(),()=>{aI.get(a.documentId)===d&&(aI.delete(a.documentId),ZEt())}}function U2n(t,r){const i=_be();i&&(i.helpers.set(t,r),i.setHelper(t,r))}function hte(){return _be()?.rig??null}function V2n(t){const r=_be();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 pQt(t){return _qe.add(t),()=>{_qe.delete(t)}}function _Qt(){return Gme||(Gme=[...aI.values()].map(t=>z2n(t.documentId,t.rig))),Gme}function J2n(t){const r=pqe.get(t);return r?[...r.helpers].filter(([,i])=>i!==null).map(([i])=>i):[]}function W2n(t){return mqe.add(t),()=>{mqe.delete(t)}}function J4n(t,r){const i=aI.get(t);if(i){for(const a of i.frameListeners)a(r);if(_be()===i)for(const a of _qe)a(r)}}function H2n(){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 G2n({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?Kqe:Xqe,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(Cze,{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 mQt=[{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"}],Q2n=[{mode:"wireframe",glyph:"wireframe",label:"Wireframe"},{mode:"clay",glyph:"sphere",label:"Solid"},{mode:"solid",glyph:"preview",label:"Material"}];function K2n({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 hQt({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(VR,{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(K2n,{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 W4n({mode:t,onChange:r,disabled:i=!1}){return z.jsx(hQt,{mode:t,onChange:r,choices:mQt,disabled:i})}const eTt=()=>()=>{},A_e=()=>0,Y2n=[{key:"skeletons",label:"Bones"},{key:"weights",label:"Weights"}];function X2n({documentId:t,assetPath:r}){Xe.useSyncExternalStore(Xye,I8,I8);const i=Pw(t);Xe.useSyncExternalStore(zye,w8,w8),Xe.useSyncExternalStore(i?.subscribe??eTt,i?.getSnapshot??A_e,i?.getSnapshot??A_e),Xe.useSyncExternalStore(qHt,yye,yye);const a=lee(t);Xe.useSyncExternalStore(a?.subscribe??eTt,a?.getSnapshot??A_e,a?.getSnapshot??A_e);const l=J2n(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($2n(i.root).filter(fe=>fe.available).map(fe=>fe.mode)),G=[...mQt,...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 RGt().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 Z6t(r,fe):M0e(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:jkt,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(VR,{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:BIr,size:"md"})})}):null,gIt("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(hQt,{mode:J.mode,onChange:fe=>i.setMode(fe),choices:G,segments:Q2n,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(G2n,{glyph:z.jsx(H2n,{}),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?[]:Y2n.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:Rkt,size:"md"})})}),w&&z.jsxs(VR,{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:qye,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:eIt,size:"sm"}),"Reset viewport settings"]})]})]})]}),d?z.jsxs(wze,{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(C5r,{className:"vgai-model-toolbar-error",tone:"error",children:g}):null]})}function Z2n({documentId:t,runtime:r=!1,island:i=!1,assetPath:a,transformControls:l,children:d}){Xe.useSyncExternalStore(Xye,I8,I8);const _=Xe.useSyncExternalStore(Tee,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(X2n,{documentId:t,...a&&!a.startsWith("online:")?{assetPath:a}:{}}):null]})}function eSn({documentId:t,children:r}){const i=Xe.useSyncExternalStore(Tee,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 XRe({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 gQt({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(Cze,{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:eDr,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(wze,{className:"vgai-snap-popover",children:z.jsxs(i0e,{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($_e,{children:"Ctrl"})," while dragging to snap once ·"," ",z.jsx($_e,{children:ep("viewport.toggleSnap")})," toggles"]}),z.jsxs(Ru,{variant:"caption",tone:"dim",children:["Hold ",z.jsx($_e,{children:ep("viewport.vertexSnapHold")})," during translate for vertex snap"]})]})]})})]})}const tSn={"active-element":"Active Element","median-point":"Median Point","individual-origins":"Individual Origins"};function rSn({store:t}){const r=["active-element","median-point","individual-origins"],i=`Pivot: ${tSn[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:tIt,size:"md"})})})}const nSn={auto:"Auto",pivot:"Pivot",center:"Center"};function iSn({store:t}){const r=["auto","pivot","center"],i=`Anchor: ${nSn[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"?Zqe:QIr,size:"md"})})})}function sSn({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:sIt,size:"md"})})}),r?z.jsx(wze,{style:{minWidth:240},children:z.jsxs(i0e,{gap:3,children:[z.jsxs(fo,{size:"compact",variant:"ghost",onClick:()=>{t.snapSelectionToFloor(),i(!1)},children:["Snap Selection to Floor ",z.jsx($_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 oSn({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"?mDr:f9,size:"sm"}),z.jsx("span",{children:l}),z.jsx(So,{icon:x8,size:"xs"})]})}),r&&z.jsx(VR,{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 aSn({store:t}={}){const r=D0(),i=t??r;return Xe.useSyncExternalStore(i.subscribe,i.getShellSnapshot??i.getSnapshot),Xe.useSyncExternalStore(sU,uI,uI),z.jsxs(NP,{compact:!0,label:"Transform controls","data-testid":"transform-header-controls",className:"vgai-transform-header-controls",children:[z.jsx(oSn,{store:i}),z.jsxs(Cze,{children:[z.jsx(rSn,{store:i}),z.jsx(iSn,{store:i})]}),z.jsx(gQt,{store:i,size:"default",variant:"secondary"}),z.jsx(sSn,{store:i})]})}const cSn=()=>()=>{},tTt=()=>null;function lSn({dimensions:t="3d",door:r,store:i}={}){const a=D0(),l=i??a;Xe.useSyncExternalStore(l.subscribe,l.getShellSnapshot??l.getSnapshot),Xe.useSyncExternalStore(sU,uI,uI);const d=Xe.useSyncExternalStore(r?.subscribe??cSn,r?.armed??tTt,r?.armed??tTt),_=[{mode:"translate",faIcon:gb.tool.move,action:"transform.translate",label:"Move"},{mode:"rotate",faIcon:gb.tool.rotate,action:"transform.rotate",label:"Rotate"},{mode:"scale",faIcon:gb.tool.scale,action:"transform.scale",label:"Scale"}];return z.jsxs(E5r,{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(XRe,{faIcon:gb.tool.select,action:"transform.select",label:"Select",active:l.transformMode==="select",onArm:()=>yS(l,"select")}),_.map(g=>z.jsx(XRe,{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(XRe,{faIcon:gb.tool.transform,action:"transform.combined",label:"Transform (all handles)",active:l.transformMode==="combined",onArm:()=>yS(l,"combined")}),t==="2d"?z.jsx(gQt,{store:l,dimensions:"2d"}):null]})}const rTt=new WeakSet;function uSn(t){t===null||rTt.has(t)||(rTt.add(t),k2n()==="select"&&t.setTransformMode("select"))}function fSn(t){return t==="game"||t==="scene"||t==="world"?"world":"resource"}function yQt({viewId:t,descriptor:r,active:i,backdrop:a=!1,chrome:l=!0}){const d=r.Content,_=r.Toolbar,g=r.Shelf,b=fSn(r.kind),S=D0();Xe.useSyncExternalStore(S.subscribe,S.getShellSnapshot??S.getSnapshot),Xe.useSyncExternalStore(Pee,MP,MP),Xe.useSyncExternalStore(Xye,I8,I8),Xe.useSyncExternalStore(XDr,ebt,ebt),Xe.useSyncExternalStore(qHt,yye,yye);const k=i&&r.kind!=="game"?iyn(UHt(S,r.id)):"none",w=k==="modal"?_It(r.id):null,N=lee(r.id)??S,P=lee(r.id);return Xe.useEffect(()=>{k==="gizmo"&&uSn(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(Z2n,{documentId:r.id,runtime:r.kind==="game",island:a&&b==="world",assetPath:Czr(r.id)?.assetPath,transformControls:k==="gizmo"?z.jsx(aSn,{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(eSn,{documentId:r.id,children:k!=="none"||g?z.jsxs(z.Fragment,{children:[k==="none"?null:z.jsx(lSn,{store:N,...w?{door:w}:{}}),g?z.jsx(g,{documentId:r.id,active:i}):null]}):null})]})]})}const S_e=new Map;function dSn(t,r){const i=hh();let a=S_e.get(t);(!a||a.project!==i)&&(a={project:i,count:0,created:r},S_e.set(t,a)),a.count++;const l=a;return()=>{S_e.get(t)!==l||--l.count>0||(S_e.delete(t),l.created&&hh()===l.project&&K8(t))}}function pSn({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,Ab,Ab);const N=Xe.useSyncExternalStore(Xye,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 cQe(),!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 h0e(ee.kind,l,{...ee,activate:i});if(G()){if(!ue)throw new Error("The requested layout document is unavailable.");J=dSn(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||Sb(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(yQt,{descriptor:P.descriptor,active:i,chrome:r}):z.jsx("div",{role:"status",children:"Opening document…"})})}function _Sn(){return z.jsxs(gMr,{children:[z.jsx(yMr,{}),z.jsx(bMr,{}),z.jsx(vMr,{})]})}function mSn(){const t=D0();Xe.useSyncExternalStore(t.subscribe,t.getShellSnapshot??t.getSnapshot);const r=Xe.useSyncExternalStore(u0e,gZ,gZ),[i,a]=Xe.useState(!1),l=Xe.useSyncExternalStore(YP,dCt,dCt);if(Xe.useEffect(()=>{let _=!1;return cQe().then(()=>{_||a(!0)}),()=>{_=!0}},[]),!i)return z.jsx("div",{role:"status",children:l??"Loading project layout…"});const d=r.Layout??_Sn;return z.jsx(d,{playing:t.playState!=="stopped",paused:t.playState==="paused"})}let hSn=!0;const gSn=new Set;function ySn(){for(const t of gSn)t()}function eKe(){return{preview:null,previewPinned:!1,view:null,guidesVisible:hSn}}function vSn(){const t=eKe();return t.view?.subject??t.preview}function bSn(){const t=eKe(),r=t.preview;r&&(t.previewPinned||r.id,ySn())}function ASn(){}function tKe({size:t=64,animation:r="assemble"}){const i=r==="static"?"":`vgai-logo--${r}`;return z.jsx("svg",{width:t,height:t,viewBox:xX.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:xX.transform,children:z.jsx("g",{className:"vgai-logo-idle",children:xX.pieces.map(a=>z.jsx("path",{className:`vgai-logo-${a.id}`,d:a.path,fill:"#F3F4F6"},a.id))})})})}const hqe="account";function vQt(){return qP({id:hqe,title:"Account",kind:"tool-contribution",workspaceRole:"workspace-task",provenance:{origin:"Volter account"},Content:CSn,closeable:!0,presentation:()=>({kind:"workspace",id:hqe})})}g9({id:"workspace",owner:"account-documents",open:(t,r)=>r.id===hqe?vQt():null});function SSn(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:vee,className:"vgai-account-infostrip-icon","aria-hidden":"true"}),z.jsx("span",{children:t})]})}function xSn({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:SSn(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 C8r(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(()=>T8r(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 E8r(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 nTt({busy:t,run:r}){const i=dze(),[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(xSn,{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 iTt({busy:t,run:r}){const i=dze(),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(()=>x8r({...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),w8r({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 wSn({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 CSn(){Xe.useSyncExternalStore(Qye,T8,T8);const t=dze(),[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}O8r().then(Ot=>ue(Ot.device)).catch(()=>ue(!1))},[t.authenticated,t.backend]),Xe.useEffect(()=>{if(!G)return;const Ot=()=>{R8r(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=()=>{L8r(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}D8r().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}P8r().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(tKe,{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(()=>y8r(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 F8r();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 M8r();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(()=>g8r(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(iTt,{busy:w,run:fe}),z.jsx(nTt,{busy:w,run:fe}),(P||Dpe())&&z.jsx("div",{className:"vgai-account-status",role:"status",children:P??Dpe()})]})});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=>b8r({...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(wSn,{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(v8r),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(()=>Pbt("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 k8r(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 I8r(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 N8r();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(()=>Pbt("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(()=>S8r(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(iTt,{busy:w,run:fe}),z.jsx(nTt,{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(A8r),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||Dpe())&&z.jsx("div",{className:"vgai-account-status",role:"status",children:P??Dpe()})]})]})}function ESn(t,r,i){const l=navigator.platform.includes("Mac")?"⌘":"Ctrl+",d=eKe(),_=vSn(),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:()=>QQe(t)}]:[],...w?[{id:"editor.copy",label:"Copy",category:"action",shortcut:ep("edit.copy"),execute:()=>GQe(t)}]:[],...P?[{id:"editor.paste",label:"Paste",category:"action",shortcut:ep("edit.paste"),execute:()=>KQe(t)}]:[]],J=d.view?[{id:"camera.exitView",label:"Exit Camera View",category:"action",execute:ASn}]:_?[{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:bSn}]:[];return[{id:"account.open",label:"Account and Provider Connections",category:"action",execute:()=>{vQt()}},{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:()=>ube(t)},{id:"editor.delete",label:"Delete Selected",category:"action",shortcut:ep("edit.delete"),execute:()=>fbe(t)},{id:"editor.select-all",label:"Select All",category:"action",shortcut:ep("edit.selectAll"),execute:()=>oNt(t)},{id:"editor.deselect",label:"Deselect All",category:"action",shortcut:ep("edit.deselectAll")??ep("edit.exitScopeOrDeselect"),execute:()=>UUe(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:()=>{ibe()}},{id:"view.focusMode",label:"Toggle Focus Mode",category:"action",shortcut:ep("view.focusMode"),execute:()=>{Wze()}},...Y8().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:()=>{Nhe(1)}},{id:"workspace.cyclePrevious",label:"Previous Workspace",category:"action",shortcut:ep("workspace.cyclePrevious"),execute:()=>{Nhe(-1)}},...K3t().map(X=>({id:`keymap.${X.id}`,label:`Keymap: ${X.title}`,category:"action",execute:()=>{I7r(X.id)}})),...cU().map(X=>({id:`view.workspaceStyle.${X.id}`,label:`Workspace Style: ${X.title}`,category:"action",execute:()=>{tUe(X.id)}})),{id:"view.undoHistory",label:"Undo History",category:"action",execute:()=>{YQe()}},{id:"view.lightExplorer",label:"Open Light Explorer",category:"action",execute:()=>hE(pee.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:()=>{Jze("asset-library")}}]}function TSn(t){return $0e(t).filter(r=>r.id!==HMe).map(r=>({id:`entity:${r.id}`,label:r.name,category:"entity",execute:()=>{UUe(t,[r.id]),t.focusOnEntity(r.id)}}))}function kSn(){return dQe().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 Eye(t){const r=t.type;if(typeof r=="string")return r;if(Array.isArray(r))return r.find(i=>i!=="null")}function bQt(t){const r=A8(t);if("default"in r)return structuredClone(r.default);const i=Eye(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]=bQt(_))}return a}return i==="array"?[]:i==="boolean"?!1:i==="number"||i==="integer"?Number(r.minimum??0):""}function gqe(t){return t.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[-_]/g," ").replace(/^./,r=>r.toUpperCase())}function ISn({name:t,schema:r,value:i,required:a,onChange:l}){const d=Eye(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:{...PY,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:sTt,children:gqe(t)}),_&&z.jsx("span",{style:lR,children:_})]})]});const S=z.jsxs("span",{style:sTt,children:[gqe(t)," ",!a&&z.jsx("span",{style:PSn,children:"optional"})]});return g?z.jsxs("label",{style:PY,htmlFor:b,children:[S,z.jsxs(bS,{id:b,value:String(i??""),onChange:k=>l(k.target.value),style:x_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:lR,children:_})]}):d==="number"||d==="integer"?z.jsxs("label",{style:PY,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:x_e}),_&&z.jsx("span",{style:lR,children:_})]}):d==="array"&&Eye(A8(r.items))==="string"?z.jsxs("label",{style:PY,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:x_e}),_&&z.jsx("span",{style:lR,children:_})]}):z.jsxs("label",{style:PY,htmlFor:b,children:[S,z.jsx(k_,{id:b,value:typeof i=="string"?i:"",onChange:k=>l(k.target.value||(a?"":void 0)),style:x_e}),_&&z.jsx("span",{style:lR,children:_})]})}function AQt({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=Eye(b),k=w=>{const N={...r};w===void 0?delete N[_]:N[_]=w,i(N)};return S==="object"||b.properties?z.jsxs("fieldset",{style:NSn,children:[z.jsx("legend",{style:OSn,children:gqe(_)}),typeof b.description=="string"&&z.jsx("p",{style:{...lR,marginTop:0},children:b.description}),z.jsx(AQt,{schema:b,value:A8(r[_]),onChange:k,path:a?`${a}.${_}`:_})]},_):z.jsx(ISn,{name:a?`${a}.${_}`:_,schema:b,value:r[_],required:d.has(_),onChange:k},_)})})}function DSn({schema:t,value:r,onChange:i}){const a=A8(t);return a.properties?z.jsx(AQt,{schema:a,value:r,onChange:i}):z.jsx("div",{style:lR,children:"This schema has no form-compatible fields."})}const PY={display:"grid",gap:5},sTt={color:od[1],fontWeight:600,fontSize:"var(--vgai-font-sm)"},PSn={color:od[3],fontWeight:400,marginLeft:5},lR={display:"block",color:od[2],fontSize:"var(--vgai-font-sm)",lineHeight:1.4},x_e={boxSizing:"border-box",width:"100%"},NSn={margin:0,padding:14,border:"1px solid var(--vgai-boundary-default)",borderRadius:"var(--vgai-radius-md)"},OSn={padding:"0 6px",color:od[1],fontWeight:600},Tye="project-tools",yqe="project-tool:";function FSn(t){return`${yqe}${t}`}function mbe(t){qP({id:Tye,title:"Project Tools",kind:"project-tool",workspaceRole:"workspace-reference",Content:SQt,closeable:!0,presentation:()=>({kind:"workspace",id:Tye}),persist:()=>({catalog:!0}),onActivate:()=>t.setActiveViewportTab("edit")})}function hbe(t,r){const i=Kz().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:FSn(r),title:i.summary||i.name,kind:"project-tool",workspaceRole:"workspace-reference",provenance:{sourcePath:i.sourcePath,origin:i.name},Content:SQt,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!==Tye?null:(mbe(t),Tye)});g9({id:"project-tool",owner:"project-tool-documents",open:(t,r)=>hbe(t,r.name)?I_():null,settle:async t=>{if(await ZX().catch(()=>{}),!await xE(()=>Kz().tools.some(r=>r.name===t.name)))throw new Error(`Project tool is not registered: ${t.name}`)}});kee({kind:"project-tool",owner:"project-tool-documents",prepare:()=>ZX().then(()=>{},()=>{}),restore:({state:t,store:r})=>{const i=t;return i?.catalog===!0?(mbe(r),!0):typeof i?.name=="string"&&hbe(r,i.name)}});function RSn(t){return[{id:"project-tools:open",label:"Open Project Tools",category:"action",execute:()=>mbe(t)},...Kz().tools.map(r=>({id:`project-tool:${r.name}`,label:`Run: ${r.summary||r.name}`,category:"action",execute:()=>void hbe(t,r.name)}))]}function oTt({value:t}){return z.jsx("pre",{style:BSn,children:JSON.stringify(t,null,2)})}function SQt({documentId:t}){Xe.useSyncExternalStore($Gt,Jbn),Xe.useSyncExternalStore(jA,dI);const r=Kz(),i=t.startsWith(yqe)?t.slice(yqe.length):null,a=i?r.tools.find(l=>l.name===i):null;return i?a?z.jsx(MSn,{tool:a},a.name):z.jsx("div",{style:vqe,children:"This tool is no longer available."}):z.jsxs("div",{style:vqe,"data-testid":"project-tools-catalog",children:[z.jsx("h2",{style:xQt,children:"Project Tools"}),z.jsxs("p",{style:{...bqe,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:()=>hbe(null,l.name),"data-testid":`project-command-card:${l.name}`,children:[z.jsxs("span",{style:wQt,children:[z.jsx("strong",{style:{color:od[1],fontWeight:600},children:l.summary}),z.jsx("span",{style:CQt,children:"Open"})]}),z.jsx("code",{style:{color:od[2],fontSize:"var(--vgai-font-sm)"},children:l.name}),z.jsx("span",{style:LSn,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:bqe,children:"No project tools registered."}),r.loadErrors.map(l=>z.jsxs("div",{style:kye,children:[l.sourcePath,": ",l.message]},`${l.sourcePath}:${l.message}`)),oUe().map(l=>z.jsxs("div",{style:kye,children:[l.entryPath,": ",l.error]},`${l.entryPath}:${l.error}`))]})}function MSn({tool:t}){const r=wE().filter(J=>J.tool?.name===t.name),i=bQt(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 Wbn(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:vqe,"data-testid":`project-tool:${t.name}`,children:[z.jsx("h2",{style:xQt,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:bqe,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:wQt,children:[z.jsx("strong",{style:{color:od[1],fontWeight:600},children:J.title}),z.jsx("span",{style:CQt,children:"Open"})]})},J.id))})]}),!P&&z.jsx("div",{style:kye,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(DSn,{schema:t.inputSchema,value:a,onChange:J=>{l(J),_(JSON.stringify(J,null,2)),N(null)}})}),w&&z.jsx("div",{style:kye,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:ZRe,children:"Advanced JSON"}),z.jsx(Dze,{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:jSn}),z.jsxs("details",{children:[z.jsx("summary",{style:ZRe,children:"Input schema"}),z.jsx(oTt,{value:t.inputSchema})]})]})]}),g!==null&&z.jsxs("section",{children:[z.jsx("div",{style:ZRe,children:"Result"}),z.jsx(oTt,{value:g})]})]})}const vqe={width:"100%",maxWidth:960,margin:"0 auto",padding:24,boxSizing:"border-box",overflow:"auto",pointerEvents:"auto",color:od[1],fontSize:"var(--vgai-font-base)"},xQt={margin:"0 0 6px",fontSize:20},bqe={color:od[2],fontSize:"var(--vgai-font-sm)"},ZRe={display:"block",margin:"14px 0 6px",color:od[1]},wQt={display:"flex",width:"100%",alignItems:"center",justifyContent:"space-between",gap:12},CQt={color:od[2],fontSize:"var(--vgai-font-sm)",fontWeight:500},LSn={display:"flex",width:"100%",minWidth:0,alignItems:"center",justifyContent:"space-between",gap:12,color:od[2],fontSize:"var(--vgai-font-sm)"},kye={marginTop:10,color:eMe,whiteSpace:"pre-wrap"},jSn={width:"100%",boxSizing:"border-box",resize:"vertical"},BSn={overflow:"auto",padding:10,background:Ize.inset,border:`1px solid ${vhe[1]}`,borderRadius:fZ.sm,color:od[2]};function $Sn(t,r,i){const a=ESn(t,r,i),l=[...RSn(t),...kSn(),...cRr(t)],d=TSn(t),_=yIt().map(g=>({id:g.id,label:g.label,category:"action",execute:g.execute}));return[...a,...l,..._,...d]}function qSn(t){return t.map(r=>`${r.id}\0${r.label}`).join("")}function zSn(){const t=D0(),r=obe(),i=OGt(),a=Xe.useSyncExternalStore(zye,w8,w8),l=Xe.useSyncExternalStore(t.subscribe,t.getShellSnapshot??t.getSnapshot),d=Xe.useSyncExternalStore(EPt,Mhe,Mhe),_=Xe.useSyncExternalStore(sU,whe,whe),g=Xe.useMemo(()=>$Sn(t,r,i),[t,r,i,a,l,d,_]),b=Xe.useRef(null);return Xe.useEffect(()=>{const S=qSn(g);S!==b.current&&(b.current=S,ZCt(g.map(k=>({id:k.id,label:k.label,category:k.category,run:k.execute}))))},[g]),Xe.useEffect(()=>()=>{b.current=null,ZCt([])},[]),null}let EQt=[];const Aqe=new Set;function USn(t){return Aqe.add(t),()=>Aqe.delete(t)}function VSn(){return EQt}function JSn(){for(const t of Aqe)t()}function WSn(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 HSn(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(WSn(i),"assets");EQt=r,JSn()}async function GSn(t){try{const{materializeDeclaredAssetPacks:r}=await la(async()=>{const{materializeDeclaredAssetPacks:a}=await import("./hosted-asset-materialization-
|
|
1681
|
+
Run ${t.name}?`)){k(!0);try{b(await Wbn(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:vqe,"data-testid":`project-tool:${t.name}`,children:[z.jsx("h2",{style:xQt,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:bqe,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:wQt,children:[z.jsx("strong",{style:{color:od[1],fontWeight:600},children:J.title}),z.jsx("span",{style:CQt,children:"Open"})]})},J.id))})]}),!P&&z.jsx("div",{style:kye,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(DSn,{schema:t.inputSchema,value:a,onChange:J=>{l(J),_(JSON.stringify(J,null,2)),N(null)}})}),w&&z.jsx("div",{style:kye,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:ZRe,children:"Advanced JSON"}),z.jsx(Dze,{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:jSn}),z.jsxs("details",{children:[z.jsx("summary",{style:ZRe,children:"Input schema"}),z.jsx(oTt,{value:t.inputSchema})]})]})]}),g!==null&&z.jsxs("section",{children:[z.jsx("div",{style:ZRe,children:"Result"}),z.jsx(oTt,{value:g})]})]})}const vqe={width:"100%",maxWidth:960,margin:"0 auto",padding:24,boxSizing:"border-box",overflow:"auto",pointerEvents:"auto",color:od[1],fontSize:"var(--vgai-font-base)"},xQt={margin:"0 0 6px",fontSize:20},bqe={color:od[2],fontSize:"var(--vgai-font-sm)"},ZRe={display:"block",margin:"14px 0 6px",color:od[1]},wQt={display:"flex",width:"100%",alignItems:"center",justifyContent:"space-between",gap:12},CQt={color:od[2],fontSize:"var(--vgai-font-sm)",fontWeight:500},LSn={display:"flex",width:"100%",minWidth:0,alignItems:"center",justifyContent:"space-between",gap:12,color:od[2],fontSize:"var(--vgai-font-sm)"},kye={marginTop:10,color:eMe,whiteSpace:"pre-wrap"},jSn={width:"100%",boxSizing:"border-box",resize:"vertical"},BSn={overflow:"auto",padding:10,background:Ize.inset,border:`1px solid ${vhe[1]}`,borderRadius:fZ.sm,color:od[2]};function $Sn(t,r,i){const a=ESn(t,r,i),l=[...RSn(t),...kSn(),...cRr(t)],d=TSn(t),_=yIt().map(g=>({id:g.id,label:g.label,category:"action",execute:g.execute}));return[...a,...l,..._,...d]}function qSn(t){return t.map(r=>`${r.id}\0${r.label}`).join("")}function zSn(){const t=D0(),r=obe(),i=OGt(),a=Xe.useSyncExternalStore(zye,w8,w8),l=Xe.useSyncExternalStore(t.subscribe,t.getShellSnapshot??t.getSnapshot),d=Xe.useSyncExternalStore(EPt,Mhe,Mhe),_=Xe.useSyncExternalStore(sU,whe,whe),g=Xe.useMemo(()=>$Sn(t,r,i),[t,r,i,a,l,d,_]),b=Xe.useRef(null);return Xe.useEffect(()=>{const S=qSn(g);S!==b.current&&(b.current=S,ZCt(g.map(k=>({id:k.id,label:k.label,category:k.category,run:k.execute}))))},[g]),Xe.useEffect(()=>()=>{b.current=null,ZCt([])},[]),null}let EQt=[];const Aqe=new Set;function USn(t){return Aqe.add(t),()=>Aqe.delete(t)}function VSn(){return EQt}function JSn(){for(const t of Aqe)t()}function WSn(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 HSn(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(WSn(i),"assets");EQt=r,JSn()}async function GSn(t){try{const{materializeDeclaredAssetPacks:r}=await la(async()=>{const{materializeDeclaredAssetPacks:a}=await import("./hosted-asset-materialization-6HtWQ0od.js");return{materializeDeclaredAssetPacks:a}},__vite__mapDeps([78,3,2,4,1,8,9,10,11,6])),i=await r(t);HSn(i)}catch(r){ua.error(`Retrying asset materialization failed before any entry was attempted: ${r instanceof Error?r.message:String(r)}`,"assets")}}let TQt={kind:"quiet"},kQt=0;const Sqe=new Set;function QSn(){return TQt}function KSn(t){TQt=t,kQt+=1;for(const r of Sqe)r()}function YSn(t){return Sqe.add(t),()=>Sqe.delete(t)}function aTt(){return kQt}const XSn=()=>()=>{},cTt=()=>null;function ZSn(){const t=D0(),r=gbn();Xe.useSyncExternalStore(t.subscribe,t.getShellSnapshot??t.getSnapshot),Xe.useSyncExternalStore(r?.subscribe??XSn,r?.getSnapshot??cTt,r?.getSnapshot??cTt);const i=sNt(t);if(i==="saved")return null;const a=qUe(t),l=i==="failed",d=l?X$r(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?sbe():void aNt(t),title:g,children:[z.jsx("span",{className:"vgai-save-status-dot"}),_.label]})}function exn(){Xe.useSyncExternalStore(ua.subscribe,ua.getSnapshot);const t=ua.counts,r=[{id:"info",icon:vee,label:"message",count:t.info},{id:"warn",icon:Zkt,label:"warning",count:t.warn},{id:"error",icon:qkt,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:()=>sbe(),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 txn(t){return[...t.map(i=>`"${i.worldId}" (${i.kind} / ${i.identity}) — ${i.message}`),"See the Console for the full trace."].join(`
|
|
1682
1682
|
`)}function rxn(){const t=Xe.useSyncExternalStore(iNt,kZ);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:()=>sbe(),title:txn(t),children:t.length===1?"1 world failed to mount":`${t.length} worlds failed to mount`})}function nxn(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 ixn(){const t=Xe.useSyncExternalStore(USn,VSn),[r,i]=Xe.useState(!1),a=Xe.useCallback(()=>{i(!0),GSn(pz()).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:()=>sbe(),title:nxn(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 sxn(){const t=R7r(),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 oxn(){Xe.useSyncExternalStore(YSn,aTt,aTt);const t=QSn();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"?gb.status.error:gb.status.warning})," ",i]})}function axn(){Xe.useSyncExternalStore(m0e,rRr);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 cxn=Zye();function lxn(){cxn.ensure(t=>{t(iP({id:"editor-lease",name:"Editor server",align:"left",order:-90,Content:oxn})),t(iP({id:"save-status",name:"Save state",align:"left",order:0,Content:ZSn})),t(iP({id:"console-counts",name:"Console errors and warnings",align:"left",order:10,Content:exn})),t(iP({id:"mount-failure",name:"Mount failure",align:"left",order:5,Content:rxn})),t(iP({id:"asset-materialization",name:"Asset materialization",align:"left",order:15,Content:ixn})),t(iP({id:"play-state",name:"Play state",align:"left",order:20,Content:sxn})),t(iP({id:"project-utilities",name:"Project utilities",align:"left",order:25,Content:axn}))})}const uxn=Xe.lazy(async()=>({default:(await la(()=>import("./NonThreeAuthoringBootstrap-0nm5Hl3v.js"),__vite__mapDeps([80,3,2,4,59,1,8,9,10,11,6]))).ProjectAuthoringBootstrap}));function fxn(){const t=D0(),r=NGt(),i=obe();return Xe.use(hbn()),Xe.useSyncExternalStore(t.subscribe,t.getShellSnapshot??t.getSnapshot),o2n(t),Xe.useEffect(()=>lxn(),[]),Xe.useEffect(()=>w2n(),[]),Xe.useEffect(()=>Q1n(r),[r]),Xe.useEffect(()=>WAn(),[]),Xe.useEffect(()=>aRr(t),[t]),Xe.useEffect(()=>$mn(t),[t]),Xe.useEffect(()=>iLr(r),[r]),Xe.useEffect(()=>JAn(t,i),[t,i]),Xe.useEffect(()=>j$r(t),[t]),Xe.useEffect(()=>IUr(()=>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(uxn,{store:t})}),z.jsx(mSn,{}),z.jsx(KAn,{}),z.jsx(zSn,{})]})}const dxn=3,pxn=1e4,_xn=4e3;function mxn(t){return{bootIdentity:null,lastIdentity:null,consecutiveFailures:0,unbackedFailures:0,darkSince:t}}function lTt(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 hxn(t,r){return{bootIdentity:t.bootIdentity,lastIdentity:null,consecutiveFailures:0,unbackedFailures:0,darkSince:r}}function IQt(t,r){return!(t.project!==null&&r.project!==null&&t.project!==r.project||t.pid!==null&&r.pid!==null&&t.pid!==r.pid)}function gxn(t){const{consecutiveFailures:r,unbackedFailures:i,failureThreshold:a,darkForMs:l,minDarkWindowMs:d,bootIdentity:_,lastIdentity:g}=t;return _&&g&&!IQt(_,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 yxn(t,r){return!t?.project||!r.project?!1:r.project===t.project}function vxn(t,r){if(!r.ok)return"none";const i=r.identity;return t&&t.pid!==null&&i.pid===t.pid&&IQt(t,i)?"resume":yxn(t,i)?"reload":t?.project?"none":"offer-reload"}const Iye="vgai.editor.orphaned-tab.v1";function bxn(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 Axn(t){return JSON.stringify(t)}function Sxn(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 xxn=720*60*1e3;function wxn(t,r){const i=r-t.at;return i>=0&&i<=xxn}function rKe(){try{return typeof localStorage>"u"?null:localStorage}catch{return null}}function Cxn(t,r=rKe()){try{r?.setItem(Iye,Axn(t))}catch{}}function Exn(t=rKe()){if(!t)return null;try{const r=bxn(t.getItem(Iye));return t.removeItem(Iye),r}catch{return null}}function Txn(t=rKe()){try{t?.removeItem(Iye)}catch{}}function kxn(t){return t?t.split(/[\\/]/).filter(Boolean).at(-1)??null:null}async function Ixn(){try{const{stopAllLiveSessions:t}=await la(async()=>{const{stopAllLiveSessions:r}=await Promise.resolve().then(()=>Mgn);return{stopAllLiveSessions:r}},void 0);t()}catch{}}function Dxn(){const[t,r]=Xe.useState({kind:"quiet"}),i=Xe.useRef(mxn(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,dNt(X),X==="taken-over"&&g(),X==="server-gone"&&Cxn({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 Ixn()},S=(X,G,ee)=>{switch(vxn(i.current.bootIdentity,X)){case"resume":{a.current=null,_qr(),Txn(),i.current=lTt(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 Yqr(),G=Pqr(),ee=Date.now();if(d)return;if(a.current!==null){S(X,G,ee);return}i.current=lTt(i.current,X,G,ee);const xe=gxn({consecutiveFailures:i.current.consecutiveFailures,unbackedFailures:i.current.unbackedFailures,failureThreshold:dxn,darkForMs:ee-i.current.darkSince,minDarkWindowMs:pxn,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=hxn(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,_xn),()=>{d=!0,g(),document.removeEventListener("visibilitychange",j),window.removeEventListener("pageshow",P),J?.close()}},[]),Xe.useEffect(()=>{KSn(t);const d=kxn(i.current.bootIdentity?.project??null),_=()=>{l.current=!0,r({kind:"degraded",subject:"stale"})};if(t.kind==="quiet"){Oze(e9e);return}if(t.kind==="degraded"){oz({id:e9e,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}oz({id:e9e,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 e9e="editor-lease",Pxn="0.5.59",Nxn={version:Pxn},Oxn="0.5.59",Fxn={version:Oxn},DQt=Fxn.version,Rxn=Nxn.version;function Mxn({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:yee})}),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:nIt,"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 xqe({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(tKe,{size:30,animation:"static"})}),z.jsx("span",{className:"vgai-shell-wordmark",children:dz.name})]})}),z.jsx(Mxn,{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",DQt," · Engine v",Rxn]})})]})})}function Lxn({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(tKe,{size:72,animation:"loading"})}),z.jsx("div",{className:"vgai-splash-title",children:dz.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 jxn 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 ixn(){const t=Xe.useSyncExternalStore(USn,VSn),[r,i]=Xe.useState(!1),a=Xe.useCallback(()=>{i(!0),GSn(pz()).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:()=>sbe(),title:nxn(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 sxn(){const t=R7r(),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 oxn(){Xe.useSyncExternalStore(YSn,aTt,aTt);const t=QSn();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"?gb.status.error:gb.status.warning})," ",i]})}function axn(){Xe.useSyncExternalStore(m0e,rRr);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 cxn=Zye();function lxn(){cxn.ensure(t=>{t(iP({id:"editor-lease",name:"Editor server",align:"left",order:-90,Content:oxn})),t(iP({id:"save-status",name:"Save state",align:"left",order:0,Content:ZSn})),t(iP({id:"console-counts",name:"Console errors and warnings",align:"left",order:10,Content:exn})),t(iP({id:"mount-failure",name:"Mount failure",align:"left",order:5,Content:rxn})),t(iP({id:"asset-materialization",name:"Asset materialization",align:"left",order:15,Content:ixn})),t(iP({id:"play-state",name:"Play state",align:"left",order:20,Content:sxn})),t(iP({id:"project-utilities",name:"Project utilities",align:"left",order:25,Content:axn}))})}const uxn=Xe.lazy(async()=>({default:(await la(()=>import("./NonThreeAuthoringBootstrap-ab96Xbnn.js"),__vite__mapDeps([79,3,2,4,58,1,8,9,10,11,6]))).ProjectAuthoringBootstrap}));function fxn(){const t=D0(),r=NGt(),i=obe();return Xe.use(hbn()),Xe.useSyncExternalStore(t.subscribe,t.getShellSnapshot??t.getSnapshot),o2n(t),Xe.useEffect(()=>lxn(),[]),Xe.useEffect(()=>w2n(),[]),Xe.useEffect(()=>Q1n(r),[r]),Xe.useEffect(()=>WAn(),[]),Xe.useEffect(()=>aRr(t),[t]),Xe.useEffect(()=>$mn(t),[t]),Xe.useEffect(()=>iLr(r),[r]),Xe.useEffect(()=>JAn(t,i),[t,i]),Xe.useEffect(()=>j$r(t),[t]),Xe.useEffect(()=>IUr(()=>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(uxn,{store:t})}),z.jsx(mSn,{}),z.jsx(KAn,{}),z.jsx(zSn,{})]})}const dxn=3,pxn=1e4,_xn=4e3;function mxn(t){return{bootIdentity:null,lastIdentity:null,consecutiveFailures:0,unbackedFailures:0,darkSince:t}}function lTt(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 hxn(t,r){return{bootIdentity:t.bootIdentity,lastIdentity:null,consecutiveFailures:0,unbackedFailures:0,darkSince:r}}function IQt(t,r){return!(t.project!==null&&r.project!==null&&t.project!==r.project||t.pid!==null&&r.pid!==null&&t.pid!==r.pid)}function gxn(t){const{consecutiveFailures:r,unbackedFailures:i,failureThreshold:a,darkForMs:l,minDarkWindowMs:d,bootIdentity:_,lastIdentity:g}=t;return _&&g&&!IQt(_,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 yxn(t,r){return!t?.project||!r.project?!1:r.project===t.project}function vxn(t,r){if(!r.ok)return"none";const i=r.identity;return t&&t.pid!==null&&i.pid===t.pid&&IQt(t,i)?"resume":yxn(t,i)?"reload":t?.project?"none":"offer-reload"}const Iye="vgai.editor.orphaned-tab.v1";function bxn(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 Axn(t){return JSON.stringify(t)}function Sxn(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 xxn=720*60*1e3;function wxn(t,r){const i=r-t.at;return i>=0&&i<=xxn}function rKe(){try{return typeof localStorage>"u"?null:localStorage}catch{return null}}function Cxn(t,r=rKe()){try{r?.setItem(Iye,Axn(t))}catch{}}function Exn(t=rKe()){if(!t)return null;try{const r=bxn(t.getItem(Iye));return t.removeItem(Iye),r}catch{return null}}function Txn(t=rKe()){try{t?.removeItem(Iye)}catch{}}function kxn(t){return t?t.split(/[\\/]/).filter(Boolean).at(-1)??null:null}async function Ixn(){try{const{stopAllLiveSessions:t}=await la(async()=>{const{stopAllLiveSessions:r}=await Promise.resolve().then(()=>Mgn);return{stopAllLiveSessions:r}},void 0);t()}catch{}}function Dxn(){const[t,r]=Xe.useState({kind:"quiet"}),i=Xe.useRef(mxn(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,dNt(X),X==="taken-over"&&g(),X==="server-gone"&&Cxn({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 Ixn()},S=(X,G,ee)=>{switch(vxn(i.current.bootIdentity,X)){case"resume":{a.current=null,_qr(),Txn(),i.current=lTt(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 Yqr(),G=Pqr(),ee=Date.now();if(d)return;if(a.current!==null){S(X,G,ee);return}i.current=lTt(i.current,X,G,ee);const xe=gxn({consecutiveFailures:i.current.consecutiveFailures,unbackedFailures:i.current.unbackedFailures,failureThreshold:dxn,darkForMs:ee-i.current.darkSince,minDarkWindowMs:pxn,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=hxn(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,_xn),()=>{d=!0,g(),document.removeEventListener("visibilitychange",j),window.removeEventListener("pageshow",P),J?.close()}},[]),Xe.useEffect(()=>{KSn(t);const d=kxn(i.current.bootIdentity?.project??null),_=()=>{l.current=!0,r({kind:"degraded",subject:"stale"})};if(t.kind==="quiet"){Oze(e9e);return}if(t.kind==="degraded"){oz({id:e9e,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}oz({id:e9e,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 e9e="editor-lease",Pxn="0.5.60",Nxn={version:Pxn},Oxn="0.5.60",Fxn={version:Oxn},DQt=Fxn.version,Rxn=Nxn.version;function Mxn({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:yee})}),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:nIt,"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 xqe({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(tKe,{size:30,animation:"static"})}),z.jsx("span",{className:"vgai-shell-wordmark",children:dz.name})]})}),z.jsx(Mxn,{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",DQt," · Engine v",Rxn]})})]})})}function Lxn({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(tKe,{size:72,animation:"loading"})}),z.jsx("div",{className:"vgai-splash-title",children:dz.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 jxn 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(xqe,{error:{message:`The editor surface crashed: ${this.state.error.message}`},onRetry:()=>this.setState({error:null})}):this.props.children}}function w_e({children:t}){return z.jsxs(z.Fragment,{children:[t,z.jsx(Dxn,{})]})}function Bxn(t){const r=t instanceof Error?t.message:String(t);return t instanceof pI?{status:"error",message:r,recovery:t.recovery}:t instanceof bUe?{status:"error",message:r,report:t.report}:{status:"error",message:r}}const $xn=8e3;function qxn(t=QUr,r=$xn){return new Promise((i,a)=>{const l=window.setTimeout(()=>{a(new T4t(r))},r);t().then(d=>{window.clearTimeout(l),i(d)},d=>{window.clearTimeout(l),a(d)})})}const zxn=3;function Uxn(){const[t,r]=Xe.useState({status:"detecting",waitingSince:null}),[i,a]=Xe.useState(0);Xe.useEffect(()=>j8r(),[]),Xe.useEffect(()=>Nqr(),[]),Xe.useEffect(()=>Aqr(()=>a(b=>b+1)),[]),Xe.useEffect(()=>{let b=!1,S,k=0;const w=Date.now();r({status:"detecting",waitingSince:null});const N=()=>{qxn().then(P=>{b||r(P?{status:"ready",project:P}:{status:"no-project"})},P=>{if(b)return;k+=1;const j=UMr(P,k);if(j.kind==="terminal"){const X=Bxn(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===zxn&&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"&&jqr(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=x4t(g)},[g]),t.status==="detecting"?z.jsx(w_e,{children:z.jsx(Lxn,{wait:t.waitingSince===null?void 0:{seconds:d,detail:t.lastError}})}):t.status==="no-project"?z.jsx(w_e,{children:z.jsx(xqe,{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(w_e,{children:z.jsx(xqe,{error:{message:t.message,...t.recovery?{recovery:t.recovery}:{}},report:t.report,onRetry:()=>a(b=>b+1)})}):z.jsx(w_e,{children:z.jsx(aAn,{children:z.jsx(jxn,{children:z.jsx(fxn,{})})})})}function nKe(t){Xe.useSyncExternalStore(t.subscribe,t.getShellSnapshot,t.getShellSnapshot),Xe.useSyncExternalStore(Aw,Ab,Ab),Xe.useSyncExternalStore(Pee,MP,MP),Xe.useSyncExternalStore(Yye,k8,k8),Xe.useSyncExternalStore($vn,_Et,_Et),Xe.useSyncExternalStore(Tee,The,The),Xe.useSyncExternalStore(e7r,mAt,mAt),Xe.useSyncExternalStore(L0n,oEt,oEt),Xe.useSyncExternalStore(j0e,TZ,TZ),Xe.useSyncExternalStore($Dt,z9e,z9e),Xe.useSyncExternalStore(jOr,Vbt,Vbt),Xe.useSyncExternalStore(OFr,lAt,lAt);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]),rbe(t)}let zN=null,PQt=0;const wqe=new Set;function Vxn(){return zN}function uTt(){return PQt}function Jxn(t){return wqe.add(t),()=>wqe.delete(t)}function fTt(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,PQt+=1;for(const i of wqe)i()}}function Wxn(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 NQt=Xe.createContext(null);function Hxn({actions:t,children:r}){return z.jsx(NQt.Provider,{value:t,children:r})}function Gxn(){return Xe.useContext(NQt)}function RE(t,r){return{...r,iconName:t}}const Qxn=RE("outliner-object",f9),Kxn=RE("outliner-light",zkt),Yxn=RE("outliner-camera",qye),Xxn=RE("outliner-audio",fDr),t9e=RE("outliner-data",zIr),dTt=RE("outliner-mesh",f9),Zxn={three:Qxn,react:Ukt,canvas:lIt,scene:oIt,mesh:dTt,"skinned-mesh":dTt,"mesh-data":t9e,"three-source":t9e,"model-asset":t9e,light:Kxn,camera:Yxn,audio:Xxn,"reflection-probe":Zqe,group:w9e,object:Jkt,component:gee,img:jY,a:HIr,ul:M_e,ol:M_e,li:M_e,button:x9e,sprite:jY,animatedsprite:Ykt,nineslicesprite:jY,tilingsprite:jY,text:pDr,graphics:x9e,container:w9e},ewn=RE("outliner-render-on",qye),twn=RE("outliner-render-off",$Ir),rwn=RE("outliner-exclude-on",qIr),nwn=RE("outliner-exclude-off",x9e),iwn=/^blender-[a-z0-9-]+$/;function nZ(t,r=Jkt){const i=Zxn[t];return i||(iwn.test(t)?RE(t,r):r)}const swn=new Set(["mesh-data","blender-material-data","blender-shapekey-data","blender-texture-data","blender-image-data"]),own=["blender-outliner-data-","blender-light-","blender-lightprobe-"];function OQt(t){return t===void 0?!1:swn.has(t)?!0:own.some(r=>t.startsWith(r))}function pTt(t){return t.revertsTo===void 0?`Revert ${t.label} to default`:`Revert ${t.label} to ${t.revertsTo}`}function awn({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(y3t,{...a,ref:_,value:l??t,onChange:S=>{g.current===null&&(g.current=t),d(S.target.value),i?.(S.target.value)}})}async function FQt(t,r=xNt){const i=await Promise.all(r.map(a=>cwn(t,a)));return{assets:i.flatMap(a=>a.assets),failedListings:i.flatMap(a=>a.failedListings)}}async function cwn(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 lwn(t,r){const i=t.filter(g=>g.root==="public"),a=uwn(i),l=(await Promise.all(a.map(async g=>{const b=await r(g.path);if(!b)return null;const S=VUe(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=_Tt(g.path);for(const k of iqr(b.image))d.add(S?`${S}/${k}`:k);for(const k of i)hLe(k.path)===hLe(g.path)&&d.add(k.path)}const _=l.flatMap(({sidecar:g,parsed:b})=>{const S=_Tt(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 uwn(t){const r=new Map;for(const i of t){if(!/\.json$/i.test(i.path))continue;const a=hLe(i.path),l=r.get(a);(!l||R2t(i.path)>R2t(l.path))&&r.set(a,i)}return[...r.values()]}function _Tt(t){const r=t.lastIndexOf("/");return r<0?"":t.slice(0,r)}function RQt(t){const r=wg(t).kind;return r==="model"||r==="image"||r==="video"||r==="audio"?r:"other"}function fwn(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 dwn(t){return(t.surface==="three"?0:t.surface==="canvas"?10:t.surface==="dom"?20:30)+(t.exported?0:4)}const pwn=1e4,_wn={paths:[],failures:[]};let NY=null;async function mwn(){const t=await FQt(U0e,["public"]);return{paths:t.assets.filter(r=>RQt(r.entry.name)==="image").map(r=>r.path).sort((r,i)=>r.localeCompare(i)),failures:t.failedListings}}function hwn(){const t=Date.now();return(!NY||t-NY.at>pwn)&&(NY={at:t,scan:mwn().catch(r=>(NY=null,{paths:[],failures:[r instanceof Error?r.message:String(r)]}))}),NY.scan}function gwn(t){const[r,i]=Xe.useState(_wn);return Xe.useEffect(()=>{let a=!0;return hwn().then(l=>{a&&i(l)}),()=>{a=!1}},[t]),r}const ywn={width:64},mTt={width:IFr,fontSize:"var(--vgai-font-md)",color:Oo.content.muted};function UN(t){return`ingest-prop-${t.replace(/\./g,"-")}`}function vwn({field:t,io:r,value:i}){const{paths:a,failures:l}=gwn(!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(DFr,{testId:UN(t.path),value:i,options:a,previewUrlFor:k=>`/${k}`,disabled:t.readonly,note:b??S,onChange:g})}function bwn({field:t,io:r}){const i=t,a=r.get(i.path),l=lMe(a)?void 0:a,d=i.defaulted===!0&&l===void 0,_=i.readonly?Rze(i):void 0,g=i.resettable?z.jsx(rf,{"data-testid":`ingest-revert-${i.path.replace(/\./g,"-")}`,"aria-label":pTt(i),title:pTt(i),onClick:()=>r.remove?.(i.path),children:z.jsx(So,{icon:eIt})}):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?{...mTt,color:Oo.content.dim}:mTt,title:_??(i.defaulted?`${i.label} — default (not set here)`:i.label),children:i.label}),i.type==="color"?z.jsx(awn,{"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(aMe,{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:ywn}):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(TFr,{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(vwn,{field:i,io:r,value:typeof l=="string"?l:""}):i.type==="json"?z.jsx(Dze,{"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(aMe,{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 Awn({fields:t,io:r}){return z.jsx(z.Fragment,{children:t.map(i=>z.jsx(bwn,{field:i,io:r},i.path))})}function Cqe(t){return t.body.kind==="fields"?z.jsx(Awn,{fields:t.body.fields,io:t.body.io}):t.body.render()}function iKe({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 sKe(t){return t.related.find(r=>r.id.startsWith("definition:"))??null}function Swn(t){return t.related.filter(r=>!r.id.startsWith("creation-site:")&&!r.id.startsWith("definition:"))}function oKe({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:vDr}),z.jsx("span",{style:{maxWidth:120,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.title})]})}function MQt({subject:t}){const r=Swn(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 LQt({subject:t,onJump:r}){const i=bGt(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 xwn({render:t,glyph:r,subjectKey:i}){const a=tbe(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 aKe({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(aMe,{"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 jQt({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=sKe(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(aKe,{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}),Lze(t,"identity").map(a=>z.jsx(iKe,{action:a},a.id)),i&&z.jsx(oKe,{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 wwn({subject:t}){const r=t.identity;if(!r)return z.jsx(jQt,{subject:t});const i=sKe(t),a=r.kind?nZ(r.kind,Dye(t)):Dye(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})}),Lze(t,"identity").map(_=>z.jsx(iKe,{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(aKe,{subject:t}),i&&z.jsx(oKe,{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 Cwn({section:t}){return z.jsx("div",{"data-testid":t.testId,"data-inspector-section":t.id,children:z.jsx(xFr,{label:t.title,icon:t.icon,description:t.description,collapsible:!0,defaultOpen:t.defaultOpen??!0,children:Cqe(t)})})}function Ewn({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(jQt,{subject:t}),z.jsx(LQt,{subject:t,onJump:i}),z.jsx(MQt,{subject:t}),z.jsx("div",{ref:r,children:t.sections.map(a=>z.jsx(Xe.Fragment,{children:z.jsx(Cwn,{section:a})},a.id))})]})}const C_e=new Map;let hTt=null;function Twn({subject:t}){const r=bGt(t),i=C_e.get(t.id)??hTt,[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),C_e.size>200&&C_e.clear(),C_e.set(t.id,b),hTt=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(wwn,{subject:t}),z.jsx(MQt,{subject:t}),_?z.jsx("div",{"data-testid":_.testId,"data-inspector-section":_.id,children:Cqe(_)}):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:Cqe(b)},b.id))]})]})})}function Dye(t){return t.sections[0]?.icon??f9}function kwn({subject:t,surface:r}){const i=Gxn(),a=t.sections.find(b=>b.body.kind==="preview"),l=a?.body.kind==="preview"?a.body:null,d=sKe(t),_=r?()=>vGt(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:()=>W8("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:RIr})}),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(xwn,{render:l?l.render:null,glyph:Dye(t),subjectKey:t.id})}),g?z.jsxs("div",{className:"vgai-mini-inspector-identity",children:[z.jsx(aKe,{subject:t}),Lze(t,"identity").map(b=>z.jsx(iKe,{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(LQt,{subject:t,onJump:()=>_?.()}),d&&z.jsx("div",{className:"vgai-mini-inspector-actions",children:z.jsx(oKe,{link:d})})]})}function Iwn({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:Dye(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:Yqe})})]})}const E_e=new Map;function gTt({subject:t,presentation:r,surface:i}){const a=t.id,l=Xe.useCallback(d=>{d&&(d.scrollTop=E_e.get(a)??0)},[a]);return r==="card"?z.jsx(kwn,{subject:t,...i?{surface:i}:{}}):z.jsx(Pze,{name:"Inspector",hideHeader:!0,className:"vgai-content-frost","data-testid":"inspector-panel","data-vgai-inspector-presentation":r,onPointerDown:()=>W8("inspector"),style:{overflowY:"auto"},ref:l,onScroll:d=>{E_e.size>200&&E_e.clear(),E_e.set(a,d.currentTarget.scrollTop)},children:r==="properties"?z.jsx(Twn,{subject:t}):z.jsx(Ewn,{subject:t})})}const Dwn=250;let BQt=0,OY=null;const Qme=new Set;function Pwn(){BQt++;for(const t of Qme)t()}function $Qt(t){return Qme.add(t),OY===null&&(OY=setInterval(Pwn,Dwn)),()=>{Qme.delete(t),Qme.size===0&&OY!==null&&(clearInterval(OY),OY=null)}}function Nwn(){return BQt}function qQt(t){return Xe.useSyncExternalStore($Qt,t,t)}function Own({presentation:t,surface:r}){const i=TQe(),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:()=>vGt(r,"column"),children:z.jsx(So,{icon:Hkt})})}):null;return t==="card"?z.jsxs("div",{className:"vgai-mini-inspector","data-testid":"inspector-panel","data-vgai-inspector-presentation":"card",onPointerDown:()=>W8("inspector"),children:[l,a]}):z.jsx(Pze,{name:"Inspector (nothing to author)",hideHeader:!0,className:"vgai-content-frost","data-testid":"inspector-panel",onPointerDown:()=>W8("inspector"),children:a})}function cKe(){const t=D0();qQt(()=>SOr());const r=nKe(t),{adapter:i}=wm(t);return r.available?i.capabilities.inspectorFields?z.jsx(gTt,{subject:r.subject,presentation:r.presentation,surface:r.surface}):r.subject.identity!==null||r.subject.sections.length>0?z.jsx(gTt,{subject:r.subject,presentation:r.presentation,surface:r.surface}):az()?z.jsx(Own,{presentation:r.presentation,surface:r.surface}):null:null}const zQt=260,UQt=360,_ee=16,Fwn=200,VQt=220,Eqe=54,Rwn=52,Mwn={maxWidth:zQt,maxHeight:UQt,minSize:Fwn,margin:_ee},Lwn={right:_ee,bottom:_ee},jwn={maxWidth:VQt,maxHeight:Eqe,minSize:Eqe,margin:_ee};function Bwn(t,r,i){return Wxn(t,i?jwn:Mwn,r)}function $wn(){const t=D0();Xe.useSyncExternalStore(t.subscribe,t.getShellSnapshot),Xe.useSyncExternalStore(Aw,Ab,Ab),Xe.useSyncExternalStore(j0e,TZ,TZ),Xe.useSyncExternalStore(Jxn,uTt,uTt);const r=Vxn(),[i,a]=Xe.useState(!1),{subject:l}=nKe(t),d=Xe.useCallback(()=>{pP();const{adapter:g}=wm(t);k0(g,[])||t.select(null)},[t]),_=r?Bwn(r,Lwn,i):null;return z.jsx("div",{style:{position:"absolute",..._?{left:_.left,top:_.top,width:_.width,height:_.height}:{right:_ee,bottom:Rwn,width:i?VQt:zQt,height:i?Eqe:UQt},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(Iwn,{subject:l,onExpand:()=>a(!1),onClear:d}):z.jsx(Hxn,{actions:{minimize:()=>a(!0)},children:z.jsx(cKe,{})})})})}let qwn=1;const yTt=new WeakMap;function zwn(t){if(!t)return 0;const r=yTt.get(t);if(r!==void 0)return r;const i=qwn++;return yTt.set(t,i),i}const Uwn="/__editor/collaboration",vTt=["participants","presence","messages","revisions","audit","team-test"];let c8=null;const Tqe=new Set,Vwn=new Set;let bTt=0;function T_e(t){c8=t,CDt(t.revision);for(const r of Tqe)r(t);if(t.revision>bTt){bTt=t.revision;for(const r of Vwn)r(t.revision)}}async function kqe(t,r){const i=await fetch(`${Uwn}${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 Jwn(){return c8}let k_e=null,I_e=0;function Wwn(){if(I_e++,!k_e){const r=VP(),i=_=>{try{T_e(JSON.parse(_.data))}catch{}};let a=!1;const l=()=>{a||(a=!0,kqe("").then(T_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;T_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 vTt)r.addEventListener(`collaboration-${_}`,d);kqe("").then(T_e).catch(()=>{}),k_e=()=>{r.removeEventListener("collaboration-snapshot",i);for(const _ of vTt)r.removeEventListener(`collaboration-${_}`,d);r.close()}}let t=!1;return()=>{t||(t=!0,I_e--,I_e<=0&&(I_e=0,k_e?.(),k_e=null))}}function Hwn(t){Tqe.add(t),c8&&t(c8);const r=Wwn();return()=>{Tqe.delete(t),r()}}async function H4n(t){await kqe("/presence",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({participantId:z0e,presence:t})})}const ATt=500,JQt=()=>{};function Gwn(t,r){if(r===JQt)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++<ATt;){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>ATt)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 Qwn(t,r,i){for(const a of r)a.more||i(a.node.id)&&t.set(a.node.id,!1);return t}function Kwn(t,r){for(const i of t.childAdapters())if(t.groupNodeId(i.worldId)===r)return i.worldId;return t.ownerOf(r)}function Ywn(t,r,i){if(!(t instanceof Zh))return!0;const a=Kwn(t,i);return a===null?!1:r.every(l=>t.ownerOf(l)===a)}const Xwn="This world's structure comes from its own source, which the editor can't rewrite here — reparenting is not wired for it.",Zwn="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 STt(t){return t.hasStructureWritePath?t.targetIsInternal?Zwn:null:Xwn}const WQt="hierarchyExpansion",Xz=new Map;let xTt=!1;function lKe(){if(xTt||!dte())return;xTt=!0;const t=VQe(WQt)??{};for(const[r,i]of Object.entries(t))Xz.set(r,new Map(Object.entries(i)))}function HQt(){const t={};for(const[r,i]of Xz)t[r]=Object.fromEntries(i);cbe(WQt,t)}function eCn(t,r){return lKe(),Xz.get(t)?.get(r)}function wTt(t,r){lKe();let i=Xz.get(t);i||(i=new Map,Xz.set(t,i));for(const[a,l]of r)i.set(a,l);HQt()}function tCn(t){lKe(),Xz.delete(t),HQt()}let Pye=null;const Iqe=new Set;function rCn(){return Pye}function nCn(t){return Iqe.add(t),()=>{Iqe.delete(t)}}function GQt(t){if(Pye!==t){Pye=t;for(const r of Iqe)r()}}function iCn(t){Pye===t&&GQt(null)}const sCn=500,CTt=new Set,oCn=new Set;function aCn(t,r=oCn){if(typeof t.internalChildren!="function"||r.size===0)return{hierarchy:t.hierarchy,isInternal:()=>!1,revealRootIds:CTt,internalIds:CTt};const i=new Map,a=new Map,l=new Set,d=(g,b)=>{if(b>sCn||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 cCn(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 lCn(t){return QQt(t)!==void 0}function uCn(t){const r=CE(t,"authoringInstance");return typeof r=="string"&&r?r:void 0}function fCn(t){const r=t?.userData?.oid;return typeof r=="string"&&r?r:void 0}function QQt(t){const r=uCn(t);if(r!==void 0)return CE(t?.parent,"authoringInstance")===r?void 0:r}function dCn(t){const r=t?.__vgaiOid;return typeof r=="string"&&r?r:void 0}function G4n(t,r){return r===0?t:`${t}#${r}`}function Q4n(t){return QQt(t)??dCn(t)??fCn(t)}function pCn(t){const r=qjr(t);if(r||O0e(t)||CE(t,"authoringRoot")===!0||!lCn(t))return r;const i=CE(t,"authoringComponent");return typeof i=="string"&&i?i:void 0}function _Cn(t){const r=t.object3D;if(typeof r!="function")return JQt;const i=new Map;return a=>{if(i.has(a))return i.get(a);const l=r.call(t,a),d=l?{componentRoot:pCn(l),authoredEntity:CE(l,"authoringRoot")===!0,builtInternal:O0e(l)}:void 0;return i.set(a,d),d}}const Nye=20,mCn="__more__:",KQt=500;function hCn(t,r,i){return t?Math.max(Nye,r.get(i)??Nye):Number.POSITIVE_INFINITY}function gCn(t,r,i,a,l){return{node:{id:`${mCn}${t}`,label:"",kind:"object",parentId:i,childIds:[]},depth:r,pathKey:`${t}/__more__`,hasChildren:!1,hiddenByCollapse:a,more:{parentPathKey:t,hidden:l}}}function ETt(t,r,i=new Map,a=!1){const l=[],d=new Set,_=(g,b,S,k)=>{if(d.has(g.id)||b>KQt)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,hCn(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(gCn(S,b+1,g.id,P,g.childIds.length-j))};return t.roots().forEach((g,b)=>{_(g,0,`r${b}`,!1)}),l}function yCn(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>KQt){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 TTt(t){return`${t.pathKey}:${t.node.id}`}function vCn(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 bCn(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 r9e{#e=null;#t;computeCount=0;get current(){return this.#t}read(r,i){if(this.#e!==null&&bCn(this.#e,r))return this.#t;const a=i(this.#t);return this.#e=r,this.#t=a,this.computeCount+=1,a}}class ACn{#e=new r9e;#t=new r9e;#i=new r9e;#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 SCn(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 uKe(t){const r=t.split("."),i=[];for(let a=1;a<r.length;a++)i.push(r.slice(0,a).join("."));return i}function kTt(t,r){const i=new Set;for(const a of r)for(const l of t.pathKeysByNodeId.get(a)??[])for(const d of uKe(l)){const _=t.nodeIdByPathKey.get(d);_&&i.add(_)}return i}function xCn(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 wCn(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 n9e="application/x-editor-asset",i9e="application/x-hierarchy-reorder";function s9e(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:d3t.treeRow}const _X="var(--vgai-tree-indent)";function Kme(t){return`calc(${_X} * ${t})`}const ITt=5;function CCn(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 ECn=[],TCn=6,kCn=8,ICn=2400;function DCn(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 PCn=300,NCn=new Map,OCn={folder:hee,document:iIt,story:Ykt,component:gee,instance:w9e,boundary:yee};function FCn(t){return t.role==="root"?nZ(t.kind,lIt):t.role==="entity"||t.role==="element"?nZ(t.kind):(t.role?OCn[t.role]:void 0)??nZ(t.kind)}const YQt=new Set(["folder","root","document","story","boundary"]);function RCn(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 MCn(t,r){return r===null?t.hierarchy.roots().map(i=>i.id):t.hierarchy.node(r)?.childIds??[]}function fKe(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 Yme(t,r){return fKe(t,r)!==null}function dKe(t,r){return t instanceof Zh&&t.isOrganizationNode(r)}function XQt(t,r){if(!(t instanceof Zh))return t;const i=t.ownerOf(r);return t.childAdapters().find(a=>a.worldId===i)?.adapter??t}function DTt(t,r){return r===void 0?t.structure!==void 0:XQt(t,r).structure!==void 0}function LCn(t,r,i){return Yme(t,r)||dKe(t,r)||i!==void 0&&YQt.has(i)}function jCn(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=LCn(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=>OQt(d.get(N)));i.set(_.node.id,_.node.defaultExpanded??(!w&&(S||k<=1||b?.childIds.length===1)))}return i}function BCn(t,r,i){const a=new Set;for(const l of t)if(!(l.more||!HQe({structural:!1,internal:i(l.node.id)}).searchable)&&l.node.label.toLowerCase().includes(r)){a.add(l.pathKey);for(const d of uKe(l.pathKey))a.add(d)}return a}function $Cn(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 qCn({value:t,onChange:r}){const i=Xe.useRef(null);return z.jsxs("div",{style:{position:"relative",display:"flex",alignItems:"center",flex:`0 1 var(${UCn}, ${zCn}px)`,minWidth:VCn},children:[z.jsx(So,{icon:Mkt,"aria-hidden":"true",style:{position:"absolute",left:JCn,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(${HCn}, ${WCn}px)`,paddingRight:GCn}})]})}const zCn=64,UCn="--vgai-hierarchy-search-basis",VCn=56,JCn=2,WCn=21,HCn="--vgai-hierarchy-search-text-inset",GCn=2;function QCn({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:Xkt,"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 KCn({slot:t,search:r,setSearch:i,adapter:a,createTargetId:l,onCollapseAll:d,onResetExpansion:_,onExpandAll:g}){const b=z.jsxs(z.Fragment,{children:[z.jsx(qCn,{value:r,onChange:i}),z.jsx(QCn,{onCollapseAll:d,onResetExpansion:_,onExpandAll:g}),z.jsx(XCn,{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 YCn({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(e3t({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=XQt(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=sMr(u4t(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=HQe({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:()=>{C0e(r,Ot),_()}}),Le.push({label:"Copy",testId:"hierarchy-context-menu-copy",...X?.copy&&(r.structure?.canCopy?.(Ot)??!0)?{}:{disabledReason:Et},action:()=>{w0e(r,Ot),_()}}),Le.push({label:"Paste",testId:"hierarchy-context-menu-paste",...X?.paste&&(r.structure?.canPaste?.(P.parentId)??!0)?{}:{disabledReason:Tt},action:()=>{E0e(r,P.parentId),_()}}),Le.push({label:"Duplicate",testId:"hierarchy-context-menu-duplicate",...G?{}:{disabledReason:vt},action:()=>{Ct.length>1&&Ct.includes(t.nodeId)?ube(i):b0e(r,t.nodeId).ack,_()}}),X?.group&&Ct.length>1&&Ct.includes(t.nodeId)&&Le.push({label:"Group Selection",testId:"hierarchy-context-menu-group",action:()=>{x0e(r,Ct).ack,_()}}),X?.ungroup&&X.canUngroup?.(t.nodeId)&&Le.push({label:"Ungroup",testId:"hierarchy-context-menu-ungroup",action:()=>{_Ue(r,t.nodeId).ack,_()}}),X?.wrap&&Le.push({label:"Wrap",testId:"hierarchy-context-menu-wrap",action:()=>{A0e(r,t.nodeId),_()}}),X?.unwrap&&Le.push({label:"Unwrap",testId:"hierarchy-context-menu-unwrap",action:()=>{S0e(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 w9r({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)?fbe(i):r.structure.remove(t.nodeId),_()}})}return z.jsx(yhe,{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(b3t,{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,v0e(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:tAt.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:tAt.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 XCn({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:gDr,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,v0e(t,b.kind,r??void 0).ack,a(!1))},children:b.label},b.kind))})]})}function ZCn({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:Kme(t.depth+1)},children:["… ",i," more"]})}function PTt(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 ZQt(t,r){return t.length===r.length&&t.every((i,a)=>i===r[a])}function eEn(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&&ZQt(i.childIds,a.childIds)&&i.crossSurfaceId===a.crossSurfaceId&&i.crossSurfaceParentId===a.crossSurfaceParentId&&i.crossSurfaceOrder===a.crossSurfaceOrder&&i.crossSurfaceGroupLabel===a.crossSurfaceGroupLabel}function tEn(t,r){return eEn(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&&ZQt(t.remoteSelectionColors,r.remoteSelectionColors)}const rEn=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=fKe(i,Tt.id),Lr=Yt!==null,nn=dKe(i,Tt.id),on=Lr||nn||Tt.role!==void 0&&YQt.has(Tt.role),gr=HQe({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?z4t(Yt.worldId):!1,Sd=Yt?P0e(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=OAn(Tt),Cl=on?0:i.instances?.describe(Tt.id)?.overrides.length??0,ku=on?WQe:J.summaryFor(i,G,Tt.id),xi=on?null:X.badgeFor(i,G,Tt.id),Iu=on?null:_1n(fte(i,a.objectMap,Tt.id)),Xl=g&&cr?Tt.childIds.slice(0,TCn).map(sa=>i.hierarchy.node(sa)).filter(sa=>sa!==null&&OQt(sa.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:sa=>de(sa,Tt.id),onClick:sa=>{if(Yt?.role==="world"&&C$e(Yt.worldId),Tt.role==="story"){const oa=i instanceof Zh?i.ownerOf(Tt.id):null;oa&&C$e(oa),i.stories?.apply(Tt.id,Tt.id)}ge(sa,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:sa=>{sa.preventDefault(),se(sa,Tt.id)},style:{position:"relative",paddingLeft:Kme(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(Ybt,{position:"before",style:{left:Kme(Le)}}),b==="after"&&z.jsx(Ybt,{position:"after",style:{left:Kme(Le)}}),CCn(Le,w,N).map(sa=>z.jsx("span",{className:"vgai-tree-indent-guide","aria-hidden":"true",style:{left:`calc(${_X} * ${sa.column+.5} - 0.5px)`,top:sa.starts?ITt:0,bottom:sa.ends?ITt:0}},sa.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:sa=>{sa.stopPropagation(),xe(r,sa.altKey)},title:"Expand/collapse (Option/Alt-click applies to the branch)",className:"vgai-tree-caret",children:z.jsx(So,{icon:g?IIr:x8,"aria-hidden":"true"})}):z.jsx("span",{"data-testid":"ingest-row-caret","aria-hidden":"true",style:{width:_X,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(sa=>z.jsx("span",{style:{background:sa},"aria-hidden":"true"},sa))}),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:Zqe,"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:FCn(Tt),"aria-hidden":"true"})}),_?z.jsx(k_,{autoFocus:!0,defaultValue:Tt.label,onBlur:sa=>{i.inspector.set(Tt.id,"name",sa.currentTarget.value),a.notifyIngestEdit(),ue("")},onKeyDown:sa=>{sa.key==="Enter"&&(i.inspector.set(Tt.id,"name",sa.currentTarget.value),a.notifyIngestEdit(),ue("")),sa.key==="Escape"&&ue("")},onClick:sa=>sa.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:[PTt(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:PTt(Tt.label,j)}),Xl.map(sa=>z.jsx("span",{className:"vgai-tree-datablock","data-active":d?"true":void 0,title:`${sa.kind}: ${sa.label}`,children:z.jsx(So,{icon:nZ(sa.kind),"aria-hidden":"true"})},sa.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:yee,"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:J1t,"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:sa=>{sa.stopPropagation(),i.inspector.set(Tt.id,"locked",!$l),a.notifyIngestEdit()},children:z.jsx(So,{icon:$l?J1t:nDr,"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:sa=>{sa.stopPropagation(),i.inspector.set(Tt.id,"exclude",!ko),a.notifyIngestEdit()},children:z.jsx(So,{icon:ko?nwn:rwn,"aria-hidden":"true"})}):z.jsx("span",{"aria-hidden":"true",style:{width:_X,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:sa=>{sa.stopPropagation(),Yt?(ujr(Yt.worldId),a.notifyIngestEdit()):(i.inspector.set(Tt.id,"visible",!Qu),a.notifyIngestEdit())},children:z.jsx(So,{icon:Qu?Kqe:Xqe,"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:sa=>{sa.stopPropagation(),i.inspector.set(Tt.id,"renderVisible",!vl),a.notifyIngestEdit()},children:z.jsx(So,{icon:vl?ewn:twn,"aria-hidden":"true"})}):z.jsx("span",{"aria-hidden":"true",style:{width:_X,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:sa=>{sa.stopPropagation(),djr(Yt.worldId),a.notifyIngestEdit()},children:z.jsx(So,{icon:TDr,"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:sa=>{sa.stopPropagation(),_jr(Yt.worldId),a.notifyIngestEdit()},children:z.jsx(So,{icon:tIt,"aria-hidden":"true"})})]})},tEn);function nEn({store:t,adapter:r}){Xe.useSyncExternalStore(t.subscribe,t.getSnapshot);const i=Xe.useDeferredValue(t.contentVersion);Xe.useSyncExternalStore(K9r,Y9r),Xe.useSyncExternalStore(Tee,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(Jwn());Xe.useEffect(()=>r.subscribe?.(()=>{b.current=t.getSnapshot(),g()}),[r,t]),Xe.useEffect(()=>Hwn(k),[]);const w=Xe.useMemo(()=>{const Xi=new Map;for(const Qn of S?.participants??[])if(Qn.participantId!==z0e)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 FAn),P=Xe.useRef(new BAn),j=t.hierarchyRowFacetVersion,J=N0e(t),[X,G]=Xe.useState(""),ee=Xe.useSyncExternalStore(nCn,rCn,()=>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(xPt,LAt,LAt).includes("outliner")?"outliner":void 0,Yt=Xe.useRef(new Map),Lr=Xe.useRef(new Map),nn=Xe.useRef(new ACn),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=T0e(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=Gwn(r,_Cn(r.hierarchy)),Eo=aCn(Qn),lc=DCn(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?yCn(lc,Xi.structuralRows,eu.changedParentIds):null)??ETt(lc,new Set),zr=cCn(Qwn(jCn(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:SCn(Bt)}}),{marked:Sd,internals:Qu,hierarchyView:vu,structuralRows:$l,defaultExpansion:el}=ol,gc=Xi=>Lr.current.get(Xi)??eCn(Zs,Xi)??el.get(Xi)??!0,Cf=An.current;if(Cf?.adapter!==r||Cf.selection!==gn){for(const Qn of kTt(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&&($9r()||t.playState!=="stopped"),ku=$Cn(Yt.current,Cl?xCn(ol.index,_t):NCn),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 uKe(Xi.pathKey))Qn.delete(Eo)}return{scopeRow:Xi,effectiveCollapsedPaths:Qn}}),{scopeRow:Iu,effectiveCollapsedPaths:Xl}=xi,sa=nn.current.browse([ol,xi,Is,Cl,Cl?wCn(ku):""],()=>{const Xi=ETt(vu,Xl,ku,Cl),Qn=Is?BCn($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(Yme(r,Zl.node.id))return!0;let Ku=Zl.node.parentId;for(;Ku;){const eu=fKe(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:oa}=sa,Ef=Xe.useMemo(()=>oa.some(Xi=>r.inspector?.get(Xi.node.id,"exclude")!==void 0),[oa,r,_,i]);Xe.useEffect(()=>{Tt(0),Le.current&&(Le.current.scrollTop=0)},[Is]);const Tg=Le.current?.clientHeight||ICn,xp=s9e(Le.current),{start:aa,end:Tf}=oa.length>PCn?vCn(oa.length,Et,Tg,xp,kCn):{start:0,end:oa.length},qo=oa.slice(aa,Tf),eg=aa*xp,ac=(oa.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);wTt(Zs,Qn),on.current+=1,Mn()},[Zs,$l]),kf={rows:oa,window:{start:aa,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(()=>(Ugn(kf),()=>Jgn(kf)),[kf]);const Ze=Xe.useRef({adapter:r,rows:oa,selectedIds:_t,structuralRows:$l,isExpanded:Qr,projectIdentity:Zs});Ze.current={adapter:r,rows:oa,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);wTt(Eo.projectIdentity,sf),on.current+=1,Mn()},[]),Rt=Xe.useCallback(()=>{Lr.current.clear();for(const Xi of kTt(ol.index,_t))Lr.current.set(Xi,!0);tCn(Zs),on.current+=1,Mn()},[Zs,gn,ol]),ft=Xe.useCallback(Xi=>{const Qn=Yt.current;Qn.set(Xi,(Qn.get(Xi)??Nye)+Nye),on.current+=1,Mn()},[]),Tr=Xe.useCallback(Xi=>{tMr(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=oa.findIndex(Ku=>_t.has(Ku.node.id)),Eo=Le.current;if(Qn<0||!Eo)return;const lc=s9e(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,oa,_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(i9e,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(i9e),Eo=Xi.dataTransfer.types.includes(n9e);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=s9e(Le.current),eu=Math.floor(Zl/Ku);if(eu>=oa.length){ge(null),tt(!0),Qn&&Ct&&(vt.current=STt({hasStructureWritePath:DTt(r,Ct[0]),targetIsInternal:!1}));return}tt(!1);const ze=eu>=0?oa[eu]:void 0;if(!ze||ze.more){ge(null);return}const Bt=STt({hasStructureWritePath:Qn?DTt(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)||RCn(qr,Ct,r))return;if(!Ywn(r,Ct,qr)){ge(null);return}}if(Yme(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})},[oa,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(i9e);if(Zl&&sf){const eu=JSON.parse(Zl);if(Eo){for(const ns of eu)PR(r,ns,null);return}if(!Qn)return;const ze=oa.find(ns=>ns.node.id===Qn.nodeId);if(!ze)return;const Bt=ze.node.id;if(Qn.zone==="child"){for(const ns of eu)PR(r,ns,Bt);return}const zr=ze.node.parentId,Gt=MCn(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&&PR(r,ns,zr??null),pUe(r,ns,Ai);return}const Ku=Xi.dataTransfer.getData(n9e);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)&&YMe(r,"",eu.path,ze);return}if(!Qn)return;const Bt=oa.find(Gt=>Gt.node.id===Qn.nodeId);if(!Bt)return;const zr=Bt.node.id;r.assetDrop.accepts(zr,eu.path,ze)&&YMe(r,zr,eu.path,ze)}catch{}},[de,qe,oa,r]),nf=f4t(r)??"Untitled";return z.jsxs(Pze,{name:null,hideHeader:!0,onPointerDown:()=>W8("hierarchy"),onDragOver:Xi=>{Xi.dataTransfer.types.includes(n9e)&&(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(KCn,{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:()=>YAt(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:()=>YAt(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(ZCn,{row:Xi,onReveal:ft},TTt(Xi)):z.jsx(rEn,{row:Xi,rowIndex:aa+Qn,prevDepth:oa[aa+Qn-1]?.depth??-1,nextDepth:oa[aa+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)??ECn},TTt(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:oa.length*xp,height:2,background:Oo.accent.default,pointerEvents:"none",zIndex:VN.overlayLow}})]}),xe&&(()=>{const Xi=vu.node(xe.nodeId),Qn=Xi?Yme(r,Xi.id)||dKe(r,Xi.id):!1;return z.jsx(YCn,{state:xe,adapter:r,store:t,isGroupNode:Qn,isInternal:Qu.isInternal(xe.nodeId),onRename:se,onClose:()=>ue(null)})})()]})}function eKt(){const t=D0(),[,r]=Xe.useReducer(a=>a+1,0);Xe.useSyncExternalStore(Aw,Ab),Xe.useSyncExternalStore(Pee,MP);const{adapter:i}=wm(t);return Xe.useEffect(()=>i.subscribe?.(r),[i]),z.jsx(nEn,{store:t,adapter:i},zwn(i))}const gbe="https://vgai-learn.pages.dev/",iEn=`${gbe}quick-starts/`,sEn=`${gbe}manual/`,NTt=`${gbe}reference/`;function tKt(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 oEn(t){const r=tKt(t);return r===null?NTt:`${NTt}${r}/`}function D_e(t){window.open(t,"_blank","noopener,noreferrer")}function aEn(){const t=D0(),r=By(t),i=r.structure,a=[...t.selectedEntityIds],l=a[0],d=l?r.hierarchy.node(l)?.parentId??null:null,_=obe(),g=OGt(),b=Xe.useSyncExternalStore(jA,UMe,UMe);Xe.useSyncExternalStore(_Pt,Dhe,Dhe),Xe.useSyncExternalStore(sU,whe,whe),Xe.useSyncExternalStore(EPt,Mhe,Mhe),Xe.useSyncExternalStore(zye,w8,w8);const S=se=>{const de=vIt(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($Gt,Kz,Kz),w=Xe.useSyncExternalStore(gPt,wS,wS),P=Xe.useSyncExternalStore(Iw,ad,ad)?.config.engine.version??null,j=tKt(P),[J,X]=Xe.useState(null);qQt(()=>J?u3r():"");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(YQe),children:"Undo History…"}),z.jsx(Ny,{}),z.jsx(Wa,{disabled:a.length===0||!i?.cut||!(i.canCopy?.(a)??!0),onSelect:ue(()=>QQe(t)),children:"Cut"}),z.jsx(Wa,{disabled:a.length===0||!i?.copy||!(i.canCopy?.(a)??!0),onSelect:ue(()=>GQe(t)),children:"Copy"}),z.jsx(Wa,{disabled:!i?.paste||!(i.canPaste?.(d)??!0),onSelect:ue(()=>KQe(t)),children:"Paste"}),z.jsx(Ny,{}),z.jsx(Wa,{disabled:t.selectedEntityIds.size===0,onSelect:ue(()=>void ube(t)),children:"Duplicate"}),z.jsx(Wa,{disabled:t.selectedEntityIds.size===0,onSelect:ue(()=>void fbe(t)),children:"Delete"}),z.jsx(Ny,{}),z.jsx(Wa,{onSelect:ue(()=>oNt(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(()=>NQe()),children:"Command Palette…"}),z.jsx(Wa,{onSelect:ue(async()=>{const se=vhn(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(Wze),children:"Toggle Focus Mode"}),S("view")]}),window:z.jsxs(z.Fragment,{children:[Y8().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:gb.status.success,style:{opacity:w===se.id?1:0}}),"Workspace: ",se.title]},se.id)),z.jsx(Ny,{}),z.jsx(Wa,{onSelect:ue(ibe),children:"Console"}),z.jsx(Wa,{onSelect:ue(()=>hE(pee.lightExplorer.id)),children:"Light Explorer"}),z.jsx(Wa,{onSelect:ue(()=>Jze("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(()=>mbe(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(()=>D_e(gbe)),children:"vgai Learn"}),z.jsx(Wa,{"data-testid":"help-quick-starts",onSelect:ue(()=>D_e(iEn)),children:"Quick-starts"}),z.jsx(Wa,{"data-testid":"help-manual",onSelect:ue(()=>D_e(sEn)),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(()=>D_e(oEn(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(Eze,{"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(VR,{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 cEn=new Map,OTt=new Set;let lEn=0;function uEn(t){return cEn.get(t)??fEn}const fEn=[];function dEn(t){return OTt.add(t),()=>OTt.delete(t)}function FTt(){return lEn}function Xme({slot:t}){return Xe.useSyncExternalStore(dEn,FTt,FTt),z.jsx(z.Fragment,{children:uEn(t).map(r=>z.jsx(r.Content,{},r.owner))})}const pEn=[],RTt=new Set;let _En=0;async function mEn(t){const r=new Set,i=[];for(const a of pEn){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 hEn(t){return RTt.add(t),()=>{RTt.delete(t)}}function MTt(){return _En}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 gEn(){const t=await fetch("/__editor/git/status");return Eg(t,"Git status failed")}function yEn(t){return wI("/git/checkpoint",{method:"POST",body:JSON.stringify(t)})}function vEn(t){return wI("/git/publish",{method:"POST",...t?{signal:t}:{}})}function LTt(t){return wI("/git/stage",{method:"POST",body:JSON.stringify(t)})}function bEn(t){return wI("/git/fetch",{method:"POST",...t?{signal:t}:{}})}function AEn(t){return wI("/git/update",{method:"POST",...t?{signal:t}:{}})}function jTt(t){return wI("/git/rebase",{method:"POST",body:JSON.stringify({action:t})})}function SEn(){return wI("/git/readiness",{method:"POST"})}function xEn(t){return wI("/git/pull-request",{method:"POST",body:JSON.stringify(t)})}function wEn(){return wI("/git/pull-request/status")}function CEn(t){return wI("/git/pull-request/merge",{method:"POST",...t?{signal:t}:{}})}function EEn(){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(()=>{gEn().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),xEn({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),CEn(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:qY.sm,marginBottom:5},children:t}),l?.available?z.jsxs("details",{style:{marginTop:pv[4]},children:[z.jsxs("summary",{style:{cursor:"pointer",fontSize:qY.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:qY.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(()=>LTt({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(()=>LTt({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(()=>jTt("continue"),"Rebase continued."),children:"Continue rebase"}),z.jsx(fo,{type:"button",size:"compact",variant:"ghost",disabled:i,onClick:()=>void ue(()=>jTt("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(()=>yEn({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(bEn,"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(vEn,"Branch published.","Publishing"),children:"Publish"}),z.jsx(fo,{type:"button",size:"compact",variant:"outline",disabled:i||l.dirty||!l.baseRef,onClick:()=>void ue(AEn,"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 SEn().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 wEn().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:qY.sm},children:"Loading version control…"}),j!==null&&z.jsxs(K9e,{labelledBy:"vgai-pull-request-title-heading",onDismiss:()=>J(null),children:[z.jsx(Y9e,{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(KDt,{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(X9e,{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(K9e,{labelledBy:"vgai-merge-pr-heading",onDismiss:()=>G(!1),children:[z.jsx(Y9e,{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(X9e,{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 TEn={worktrees:[],branches:[],isolatedWorktrees:[]};function kEn(t){return`agent/${t.toLocaleLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"").slice(0,42)||"task"}`}function IEn({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(hEn,MTt,MTt);return Xe.useEffect(()=>{let ee=!0;return mEn(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(Dze,{"aria-label":"Task for the agent",placeholder:"Describe a bounded task…",value:a,onChange:ee=>{const xe=ee.target.value;l(xe),g||_(kEn(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),szr({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 DEn(t){return t.replace(/[\\/]$/,"").split(/[\\/]/).at(-1)??t}function PEn(t){const r=t.current?["Current worktree"]:[DEn(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=pKe(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 pKe(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 NEn(t){return t.kind==="agent"?"AI":t.displayName.split(/\s+/).slice(0,2).map(r=>r[0]?.toLocaleUpperCase()??"").join("")}function BTt({worktree:t}){const r=pKe(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:NEn(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 OEn={healthy:"ready",starting:"starting",unhealthy:"running, editor not responding",stopped:"stopped","docker-unavailable":"unknown — Docker not reachable"};function FEn(t){const r=OEn[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 o9e(t,...r){const i=t.trim().toLocaleLowerCase();return!i||r.some(a=>a?.toLocaleLowerCase().includes(i))}function $Tt(t,r){return[+!t.current,Math.min(...pKe(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 REn(t){return(r,i)=>{const a=$Tt(r,t),l=$Tt(i,t);return a.reduce((_,g,b)=>_||g-(l[b]??0),0)||(r.branch??r.root).localeCompare(i.branch??i.root)}}function MEn(){const[t,r]=Xe.useState(TEn),[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 nzr()),S(null)}catch(P){S(P instanceof Error?P.message:String(P))}finally{N||d(!1)}},[]);return Xe.useEffect(()=>{if(fze)return;let N=!0;return rzr().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 LEn(){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}=MEn();if(Xe.useEffect(()=>{r&&J()},[r,J]),fze)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(REn(ue)).filter(Le=>o9e(a,Le.branch,Le.root)),de=S.branches.filter(Le=>!Le.worktreeId&&o9e(a,Le.name)),ge=S.isolatedWorktrees.filter(Le=>o9e(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(Eze,{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:DIr}),G?.dirty&&z.jsx("span",{className:"vgai-worktree-dirty-dot","aria-hidden":"true"}),G&&z.jsx(BTt,{worktree:G})]}),r&&z.jsxs(VR,{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:Fkt})})]}),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:_Dr})}),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:FEn(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:WIr})}),z.jsx(fo,{type:"button",size:"compact",variant:"ghost","aria-label":`Show logs for ${Le.branch}`,title:"Show startup logs",disabled:N!==null,onClick:()=>{ozr(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:nIt})}),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}`,()=>azr(Le.id),()=>{b("Isolated branch exported as a Git bundle."),J(!0)}),children:z.jsx(So,{icon:SDr})}),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}`,()=>H2t(Le.id,!1),()=>i(!1)),children:z.jsx(So,{icon:S9e})}),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}`,()=>H2t(Le.id,!0),()=>i(!1))},children:z.jsx(So,{icon:Lkt})})]},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,()=>izr(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…":PEn(Le)})]}),z.jsx(BTt,{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}`,()=>lzr(Le.worktreeId,Le.sessions[0].sessionId),()=>i(!1)),children:z.jsx(So,{icon:S9e})}),!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}`,()=>czr(Le.worktreeId),()=>i(!1)),children:z.jsx(So,{icon:cIt})})]},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,()=>W2t(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",()=>W2t(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(IEn,{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(EEn,{})]}),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 jEn({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:[$ye()?.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(Eze,{"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:gb.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(LEn,{}),z.jsx(Nq,{onPointerDown:()=>a(!1),className:"vgai-project-app-menus",children:z.jsx(aEn,{})})]}),z.jsx(BEn,{}),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",DQt]}),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),yLe(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($En,{})}),z.jsx(Nq,{className:"vgai-project-header-right",justify:"end",align:"center",children:z.jsx(Xme,{slot:"header-trailing"})})]})}function BEn(){Xe.useSyncExternalStore(Tee,The,The),Xe.useSyncExternalStore(_Pt,Dhe,Dhe);const t=Xe.useSyncExternalStore(gPt,wS,wS);if(wP().workspaceTabs!=="shown")return null;const r=Y8().filter(i=>CP(i.id));return z.jsxs(z.Fragment,{children:[z.jsx(b5r,{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 $En(){Xe.useSyncExternalStore(zye,w8,w8);const t=gIt();return t.length===0?null:z.jsx(z.Fragment,{children:t.map(({id:r,Component:i})=>z.jsx(i,{documentId:""},r))})}function qEn({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 zEn(t,r){return window.confirm(r)}const UEn=4,VEn=4,JEn=24,WEn=4,HEn=3,GEn=new Set(["model","image"]),QEn=new Set(["glb","gltf","fbx","obj","dae","stl","ply","spz","bvh","3ds"]);function KEn(t){const r=t.lastIndexOf(".");return r>0&&QEn.has(t.slice(r+1).toLowerCase())}const YEn=new Set(["audio","video","prefab","json"]);function rKt(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 _Ke(t){return t.replace(/^(?:\.\/|\/)+/,"").replace(/\/+$/,"")}function XEn(t,r){const i=t?r.slice(t.length+1):r;return i.split("/",1)[0]??i}function qTt(t,r){return t.tier-r.tier||t.depth-r.depth||t.seq-r.seq}function ZEn(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 eTn(t,r){const i=[...t].sort(qTt),a=[],l=new Set;for(const d of[1,2]){const _=i.filter(g=>g.tier===d);ZEn(_,a,l,r)}return a.sort(qTt),a.map(({path:d,name:_,kind:g})=>({path:d,name:_,kind:g}))}function tTn(t){return GEn.has(t)?1:YEn.has(t)?2:0}function rTn(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 _=KEn(l.name)?"model":wg(l.name).kind,g=tTn(_);g!==0&&t.candidates.push({path:d,name:l.name,kind:_,tier:g,depth:r.depth,seq:t.seq++,subtree:XEn(t.base,d)})}}async function nTn(t,r,i={}){const a=i.listAssets??U0e,l=i.maxItems??UEn,d=i.maxListings??JEn,_=rKt(i.listConcurrency??WEn),g=_Ke(r),b={base:g,maxDepth:i.maxDepth??VEn,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}rTn(b,X,G.entries,j)}k=j}return{items:eTn(b.candidates,l),totalAssets:b.totalAssets,scannedAll:!b.truncated&&b.failedListings===0,failedListings:b.failedListings}}const nKt="\0",xR=new Map,iTn=rKt(HEn);function sTn(t,r,i){const a=`${t}${nKt}${_Ke(r)}`,l=xR.get(a);if(l)return l;const d=iTn(()=>nTn(t,r,i));xR.set(a,d);const _=()=>{xR.get(a)===d&&xR.delete(a)};return d.then(g=>{(g.failedListings>0||g.items.length===0&&g.totalAssets===0)&&_()},_),d}function oTn(t,r){return t===r||t===""||r===""||t.startsWith(`${r}/`)||r.startsWith(`${t}/`)}function zTt(t){if(t===void 0){xR.clear();return}const r=_Ke(t);for(const i of[...xR.keys()]){const a=i.slice(i.indexOf(nKt)+1);oTn(a,r)&&xR.delete(i)}}function Dqe(t,r="$"){return typeof t=="string"?[{path:r,value:t}]:Array.isArray(t)?t.flatMap((i,a)=>Dqe(i,`${r}[${a}]`)):!t||typeof t!="object"?[]:Object.entries(t).flatMap(([i,a])=>Dqe(a,`${r}.${i}`))}function aTn(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 cTn(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 _=aTn(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 Dqe(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 iKt(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 iKt(t,d)):/\.json$|\.gltf$/i.test(d)?a.push({path:d,text:await t.read(d)}):a.push({path:d})}return a}async function lTn(t,r){return cTn({assetPath:r,files:await iKt(t)})}function P_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 a9e(t,r){for(const i of r)if(await t.exists(i))throw new Error(`An asset already exists at ${i}.`)}async function uTn(t,r){const i=xUe(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 a9e(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 a9e(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&&P_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)P_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&&P_e({type:"delete",paths:a}),l}case"import":{const a=t.files.map(d=>({path:K3(d.path),data:d.bytes}));await a9e(r.backend,a.map(d=>d.path));const l=await i.mutate(a,{label:`Import ${a.length} asset${a.length===1?"":"s"}`});return l&&P_e({type:"change",paths:a.map(d=>d.path)}),l}}}const fTn=320,dTn=180,pTn="document-preview-v4",mX=new Map,_Tn=new D4t(async t=>{const r=mX.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 iZ=null,UTt,c9e=null;const FY=new Set;async function sKt(t){const r=pz();let i;try{i=await r.list(t)}catch{return[]}const a=[];for(const l of i)l.type==="dir"?a.push(...await sKt(l.path)):a.push(`${l.path}:${l.size??0}:${l.mtime??0}`);return a}async function mTn(){const t=ad()?.rootPath;return UTt!==t&&(UTt=t,iZ=null),iZ??=Promise.all([bNt([QUe,"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 nge(i)??""}`))),sKt("")]).then(([r,i])=>oKt([...r,...i].sort().join(`
|
|
1686
1686
|
`))),iZ}function hTn(t){return FY.add(t),c9e??=Qg.watch(r=>{if(r.path===Lq){I4t();for(const i of FY)i();return}if(!(!/^(src|public|\.storybook)\//.test(r.path)&&r.path!==QUe&&r.path!=="vgai.adapter.ts")){iZ=null;for(const i of FY)i()}}),()=>{FY.delete(t),FY.size===0&&(c9e?.(),c9e=null,iZ=null)}}async function gTn(t,r,i){r.throwIfAborted();let a=mX.get(t);a||(a={run:i,consumers:new Set},mX.set(t,a)),a.consumers.add(r);const l=_Tn.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&&mX.get(t)===a&&mX.delete(t)}}async function oKt(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 yTn(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 VTt(t,r="image/png"){const i=new Uint8Array(t.byteLength);return i.set(t),URL.createObjectURL(new Blob([i.buffer],{type:r}))}async function vTn(t){const r=await SUe();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 bTn(t,r,i,a){const l=ad()?.rootPath??"no-project",d=await vTn(t),_=JSON.stringify({projectId:l,documentId:t,recipe:pTn,revision:r.revision(),dependencies:await mTn(),camera:d});a.throwIfAborted();const g=await oKt(_),b=`.vgai/cache/document-previews/${g}.png`;if(i===0&&await Qg.exists(b))return VTt(await Qg.readBytes(b));const S=await gTn(g,a,()=>r.capture({width:fTn,height:dTn,...d?{camera:d}:{}}));a.throwIfAborted();const k=yTn(S);return await Qg.write(b,k.bytes),VTt(k.bytes,k.mime)}function ATn({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=hTn(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),bTn(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:qY.xs},children:a?"Refreshing preview…":"Loading preview…"}):null]})}function aKt(t,r){return J0e(t,r.path)}function STn({root:t,item:r}){const[i,a]=Xe.useState(!1);return i?z.jsx(DP,{kind:"image",size:14}):z.jsx("img",{src:aKt(t,r),alt:r.name,loading:"lazy",onError:()=>a(!0)})}function xTn({root:t,item:r}){const i=uGt(aKt(t,r),yvn);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 wTn({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(STn,{root:t,item:r}):r.kind==="model"?z.jsx(xTn,{root:t,item:r}):z.jsx(a9,{kind:r.kind,name:r.name,variant:"cell"})}function CTn({root:t,folderPath:r,revision:i}){const[a,l]=Xe.useState(null);if(Xe.useEffect(()=>{l(null)},[t,r]),Xe.useEffect(()=>{let _=!1;return sTn(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:Bkt,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(wTn,{root:t,item:_})},_.path))}),z.jsx("span",{className:"vgai-folder-preview__chip",children:z.jsx(So,{icon:hee})}),z.jsx("span",{className:"vgai-folder-preview__count",children:d})]})}function Pqe(t){return t.type==="directory"?"folder":wg(t.name).kind}function ETn(t,r,i){return J0e(t,r?`${r}/${i}`:i)}function TTn(t,r,i){return r?`/${r}/${i}`:`/${i}`}function kTn(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function Nqe(t){const r=wg(t);return r.importable?r.runtimeReady?"healthy":"source-only":"unsupported"}const ITn=640,JTt={scope:"content",root:"public",currentPath:"",viewMode:"grid",sort:"relevance",filter:"all",density:96,expanded:["public"],treeVisibility:"auto",facets:["component"]};function DTn(){try{const t=ad()?.rootPath??"__unscoped__",r=JSON.parse(localStorage.getItem(tGt(t))??"{}"),i=r.viewMode,a=r.treeVisibility,l=r.scope,d=r.root;return{...JTt,...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 JTt}}const PTn={listAssets:U0e,listProjectComponents:hNt},l9e="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.",NTn=new Set(["component","scene","canvas","model","image","video","audio","other"]);function OTn(t){const r=t.charAt(0).toUpperCase()+t.slice(1);return r.endsWith("s")?r:`${r}s`}async function WTt(t,r){if(!r&&I_()!==t)throw new Error("Open this scene as the active document before using its current view.");const i=lee(t)?.cameraPose;if(!r&&!i)throw new Error("The active scene has no ready 3D authoring view to save.");await RGt().saveThumbnailFraming(`document:${t}`,r?void 0:{position:i.position.toArray(),target:i.target.toArray(),fov:i.fov})}function FTn(t){return t.component.surface==="three"?"3d":t.component.surface==="canvas"?"2d":"ui"}function RTn(t){const r={"3d":"3D","2d":"2D",ui:"UI"};return["3d","2d","ui"].flatMap(i=>{const a=t.filter(l=>l.source==="component"&&FTn(l)===i);return a.length>0?[{id:`prefabs-${i}`,label:r[i],headingLevel:"category",entries:a}]:[]})}function MTn(t,r,i){return r==="files"?[{id:"files",label:null,headingLevel:null,entries:[...t]}]:i.length===1&&i[0]==="component"?RTn(t):t.length>0?[{id:"content",label:null,headingLevel:null,entries:[...t]}]:[]}function cKt(t){return t.source==="available"?t.available.category:t.source==="component"?t.component.contentKind??"component":t.source==="document"?t.document.kind:RQt(t.name)}function LTn(t){return t.source==="component"?t.component.contentKind??"component":t.source==="available"||t.source==="document"?"source":Pqe(t.entry)}function wR(t){const r=t.lastIndexOf("/");return r<0?"":t.slice(0,r)}function jTn(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}_(ETn(t.root,l,i.name),b)}}function lKt(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":kTn(t.entry.size)}function BTn(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=lKt(t);return r?`${t.name}
|
|
1690
1690
|
${r}`:t.name}function $Tn(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 Yq(t,r){return t.name.localeCompare(r.name)||t.path.localeCompare(r.path)}function HTt(t){return t.source==="asset"?fwn({path:t.path,root:t.root,entry:t.entry}):t.source==="available"||t.source==="document"?10:dwn(t.component)-100}function qTn(t,r){const i=HTt(t),a=HTt(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",Yq(t,r))}function GTt(t,r){return t===void 0?r===void 0?0:1:r===void 0?-1:r-t}function zTn(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 GTt(t.entry.size,r.entry.size);if(i==="modified"&&t.entry.modifiedAt!==r.entry.modifiedAt)return GTt(t.entry.modifiedAt,r.entry.modifiedAt);if(i==="type"){const a=Pqe(t.entry).localeCompare(Pqe(r.entry));if(a!==0)return a}if(i==="health"){const a=Nqe(t.name).localeCompare(Nqe(r.name));if(a!==0)return a}return Yq(t,r)}function UTn(t,r,i){return i==="relevance"?qTn(t,r):i==="name"?Yq(t,r):t.source!==r.source?t.source==="component"?-1:1:t.source!=="asset"||r.source!=="asset"?Yq(t,r):zTn(t,r,i)}function VTn(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=cKt(t);return r.facets.includes(i)}return r.scope==="content"||$Tn(t,r.filter,r.shownPath)}const JTn={width:"100%",minWidth:0,padding:0,textAlign:"center",display:"flex",flexDirection:"column",alignItems:"center",gap:3},WTn={width:"100%",minWidth:0,minHeight:28,padding:"3px 6px",textAlign:"left",display:"flex",flexDirection:"row",alignItems:"center",gap:7};function HTn(t){const r=new Map;if(!t.assetSubject)return r;const i=t.assetSubject.entries?.()??q9r(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 GTn=()=>()=>{},QTn=()=>0;function KTn({sheetUrl:t,frame:r}){return z.jsx(pGt,{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 YTn({item:t,kind:r,assetUrl:i,grid:a,folderPath:l,previewRevision:d}){const _=i;if(r==="folder")return a?z.jsx(CTn,{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(bvn,{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(ATn,{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(KTn,{sheetUrl:`/${t.spritesheet.sheetPath}`,frame:t.spritesheet}):z.jsx("img",{src:_,alt:t.name,style:{maxWidth:48,maxHeight:48,objectFit:"contain",borderRadius:fZ.sm}}):r==="video"&&_?z.jsx("video",{src:`${_}#t=0.1`,muted:!0,playsInline:!0,preload:"metadata",style:{maxWidth:48,maxHeight:48,objectFit:"contain",borderRadius:fZ.sm}}):r==="model"||jQe(i)?z.jsx(fGt,{url:i}):["prefab","json"].includes(r)?z.jsx(a9,{kind:r,name:t.name}):z.jsx(DP,{kind:r})}function XTn({item:t,selected:r,onDragStart:i,onSelect:a,onOpen:l,onContextMenu:d,viewMode:_,previewRevision:g,showPath:b}){const S=LTn(t),k=t.source==="asset"?t.entry:null,w=k?.type==="file"?wg(k.name):null,N=t.source==="asset"?J0e(t.root,t.path):"",P=t.path,j=BTn(t),J=k?k.type==="directory"||w?.placeable?w?.placeable?"grab":"pointer":"default":"pointer",X=lKt(t),G=t.source==="component"?t.path:t.source==="asset"?sge(t.root,wR(t.path)).replace(/\/$/,""):wR(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&&evn(N)},onPointerLeave:()=>{S==="audio"&&N&&tvn(N)},onDragStart:ue=>i(ue,t),onDragEnd:F9r,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?JTn:WTn,borderRadius:fZ.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:fZ.sm,pointerEvents:"none",position:"relative"},children:[z.jsx(YTn,{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 ZTn({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=wR(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(Xbt,{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:EDr})})}),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:FIr})})}),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:M_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?gb.action.close:gb.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:aIt})})}),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:hDr})})}),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(Xbt,{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=>!NTn.has(Lr)).sort().map(Lr=>[Lr,OTn(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:Rkt})})}),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 ekn(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=xNt.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:$kt,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:hee}),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 tkn(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>=ITn)};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 rkn({services:t=PTn}){const r=D0(),i=typeof r.subscribe=="function"?r.subscribe:GTn,a=typeof r.getSnapshot=="function"?r.getSnapshot:QTn,l=typeof r.getShellSnapshot=="function"?r.getShellSnapshot:a,d=Xe.useSyncExternalStore(i,l,l),_=Xe.useSyncExternalStore(Pee,MP,MP),g=Xe.useSyncExternalStore(Aw,Ab,Ab),b=Xe.useRef(r);b.current=r;const S=NGt(),k=Xe.useSyncExternalStore(jA,dI,dI),w=Xe.useSyncExternalStore(nGt,Aye,Aye),N=k.filter(Gt=>Gt.point==="workspace.document"&&Gt.tool?.generation?.role==="submit"),P=Xe.useMemo(DTn,[]),[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}=tkn(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(Fmn,dQe),Is=Xe.useSyncExternalStore(YP,wb,wb),[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),[sa,oa]=Xe.useState(null),Ef=Xe.useRef(null),Tg=Xe.useRef(new Map),xp=Xe.useRef("");Xe.useEffect(()=>{const Gt=ad()?.rootPath??"__unscoped__";localStorage.setItem(tGt(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 aa=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(()=>{aa(j,ue)},[j,ue,aa]);const Tf=Xe.useCallback(async()=>{Zc(!0);try{const[Gt,qr]=await Promise.all([FQt(t.listAssets),t.listProjectComponents()]),Ai=await lwn(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(()=>HTn(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=V0n().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=>VTn(ns,{query:Gt,scope:X,facets:ee,filter:tt,shownPath:kf})),Ai=X==="files"&&ge==="relevance"?"name":ge;return[...qr].sort((ns,vc)=>UTn(ns,vc,Ai))},[Rt,ee,kf,tt,X,Yl,ge]),ti=Xe.useMemo(()=>{const Gt=new Set;for(const qr of Rt)Gt.add(cKt(qr));return Gt},[Rt]),Gi=Xe.useMemo(()=>MTn(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. ${l9e}`);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:TTn(j,wR(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=J0e(Gt.root,Gt.path);if(YN({path:Wf,name:ns.name,kind:Fc,...ns.size===void 0?{}:{sizeBytes:ns.size},capabilities:vc,health:Nqe(ns.name),selectionCount:Ai.size,...Gt.path.startsWith("asset-library/local")?{sourcePath:"Asset Library provenance metadata"}:{}}),Gt.root!=="public")return;const Js=Gt.path;lTn(pz(),Js).then(Bd=>{const no=Wf;B0e()?.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){kzr(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=jWt(r,Gt.document.id);qr.ok||ua.error(qr.error,"scene");return}z8(r,Gt.document)||f8(r,`/${Gt.path}`,LWt(Gt.document));return}jTn(Gt,{currentRoot:j,currentPath:Gt.source==="asset"?wR(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)zTt(qr);else zTt();_c(qr=>qr+1),aa(j,ue),X==="content"&&Tf()},[j,ue,Tf,aa,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"?[sge(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 uTn(Gt,{backend:pz(),history:S}),Tg.current.clear(),j==="public"&&await aa(j,ue),X==="content"&&await Tf()},[ue,j,Tf,aa,S,X]),lc=Xe.useCallback(async()=>{Xi.length!==0&&zEn("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. ${l9e}`);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=wR(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. ${l9e}`);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=wR(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]&&yLe(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=sa?.item.source==="available"&&sa.item.available.descriptor.preview?sa.item:null;return z.jsxs("div",{ref:Et,className:"vgai-asset-browser","data-tree-visible":X==="files"&&Le,onPointerDown:()=>W8("asset-browser"),onKeyDown:Gt=>{if(!cqe(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(ekn,{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(ZTn,{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(XTn,{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),oa({x:Ai.clientX,y:Ai.clientY,item:ns}))},viewMode:se,previewRevision:Sa,showPath:X==="content"},qr.key))]},Gt.id)),Tr.length===0&&z.jsx(x5r,{compact:!0,style:{gridColumn:"1 / -1"},icon:z.jsx(So,{icon:ft?gb.status.warning:Yl?gb.action.search:gb.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&&sa&&z.jsx(yhe,{children:z.jsxs(OP,{autoFocusFirst:!0,className:"vgai-asset-context-menu",style:{left:sa.x,top:sa.y},onDismiss:()=>oa(null),children:[z.jsxs(Wa,{type:"button",role:"menuitem",onClick:()=>{yc(zr),oa(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;oa(null),WTt(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;oa(null),WTt(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:()=>{oa(null),_c(Gt=>Gt+1)},children:"Refresh preview"})]})}),sa&&sa.item.source==="asset"&&z.jsx(yhe,{children:z.jsxs(OP,{autoFocusFirst:!0,className:"vgai-asset-context-menu",style:{left:sa.x,top:sa.y},onDismiss:()=>oa(null),children:[z.jsxs(Wa,{type:"button",role:"menuitem","data-command-id":z_.open.id,onClick:()=>{yc(sa.item),oa(null)},children:["Open ",z.jsx("kbd",{children:"Enter"})]}),z.jsxs(Wa,{type:"button",role:"menuitem","data-command-id":z_.rename.id,onClick:()=>{eu(sa.item),oa(null)},children:["Rename ",z.jsx("kbd",{children:"F2"})]}),z.jsxs(Wa,{type:"button",role:"menuitem","data-command-id":z_.duplicate.id,onClick:()=>{ze(sa.item),oa(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(),oa(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]),oa(null)},children:"Copy path"}),vIt("asset").map(Gt=>{const qr=sa.item.source==="asset"&&sa.item.entry.type==="file",Ai=sa.item.source==="asset"?{assetPath:sge(sa.item.root,sa.item.path)}:{};return z.jsx(Wa,{type:"button",role:"menuitem","data-testid":Gt.testId,disabled:!qr||(Gt.disabled?.(Ai)??!1),onClick:()=>{Gt.execute(Ai),oa(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]&&yLe(Qn[0]),oa(null)},children:"Reveal in Finder"}),z.jsxs(Wa,{type:"button",role:"menuitem","data-command-id":z_.delete.id,disabled:Xi.length===0,onClick:()=>{lc(),oa(null)},children:["Delete ",z.jsx("kbd",{children:"⌫"})]})]})})]})}const nkn={agent:()=>z.jsx(Xme,{slot:"panel:agent"}),"project-work":()=>z.jsx(Xme,{slot:"panel:project-work"}),hierarchy:eKt,assets:({dependencies:t})=>z.jsx(rkn,{services:t?.assets}),"asset-library":()=>z.jsx(Xme,{slot:"panel:asset-library"}),inspector:cKe};class ikn 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 skn=RQe.map(t=>{const r=nkn[t.kind],i=a=>z.jsx(ikn,{title:t.title,children:z.jsx(r,{...a})});return i.displayName=`StaticPanel(${t.kind})`,{...t,Content:i}});function okn(t){return skn.find(r=>r.kind===t)}function akn({kind:t,dependencies:r}){const{Content:i}=okn(t);return z.jsx(i,{dependencies:r})}const ckn=250;function lkn(){const t=j3t(),r=ukn();return()=>{r(),t()}}function ukn(){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&&F8("console-entries",{entries:_,_clientId:jP})}const d=ua.subscribe(()=>{i||r!==null||(r=setTimeout(l,ckn))});return F8("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"},N_e=[RN.INPUT,RN.PRE_PHYSICS,RN.PHYSICS,RN.POST_PHYSICS,RN.GAME_LOGIC,RN.ANIMATION,RN.PRE_RENDER,RN.RENDER],Oye=1e-9,uKt=1e5;function fkn(t,r,i){const a=i.end-i.start,l=i.loop&&a>Oye,d=[];let _=t,g=r,b=!1,S=0;for(;;){const k=i.end-_;if(!l||g<=k+Oye){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>uKt){const w=i.start+g%a;d.push({from:_,to:w,direction:"forward"}),_=w;break}}return{pos:_,intervals:d,looped:b}}function dkn(t,r,i){const a=i.end-i.start,l=i.loop&&a>Oye,d=[];let _=t,g=r,b=!1,S=0;for(;;){const k=_-i.start;if(!l||g<=k+Oye){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>uKt){const w=i.end-g%a;d.push({from:_,to:w,direction:"reverse"}),_=w;break}}return{pos:_,intervals:d,looped:b}}function QTt(t,r){return t<r.start?r.start:t>r.end?r.end:t}class pkn{_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=QTt(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=QTt(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"?fkn(a,i,this._range):dkn(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(!N_e.includes(r))throw new Error(`[AnimationClock] unknown phase "${r}". Valid: ${N_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=N_e.indexOf(b.phase),w=N_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 O_e={start:0,end:0,fps:30},_kn=150;class K4n{constructor(r){this.store=r,this.stopStoreWatch=r.subscribe(()=>this.notify())}clock=new pkn;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:O_e.start,end:O_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??O_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()},_kn)}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()??O_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 Zme=new Map,Oqe=new Set;function KTt(){for(const t of[...Oqe])t()}function Y4n(t,r){return Zme.set(t,r),KTt(),()=>{Zme.get(t)===r&&(Zme.delete(t),KTt())}}function mkn(t){return t===null?null:Zme.get(t)??null}function hkn(t){return Oqe.add(t),()=>{Oqe.delete(t)}}const fKt="__vgaiWorkspacePersistenceSuppressed";function dKt(){return globalThis}function pKt(t){dKt()[fKt]=t}function gkn(){return dKt()[fKt]===!0}function _Kt(){return(d0e()?.immersivePlay??!1)&&!P8().play?.keepPanelsVisible}function ykn(t){return Math.min(1600,Math.max(800,900+t*25))}function vkn(t){return t<.5?4*t*t*t:1-(-2*t+2)**3/2}function mKt(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 hKt={phase:"idle",flightDone:!1,gameReady:!1};function bkn(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 Akn(t,r){if(r==="stop")return hKt;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 bkn(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 Skn=450,xkn=220,gKt=250;function wkn(t){t.style.setProperty("--vgai-play-dissolve-duration",`${Skn}ms`),t.style.setProperty("--vgai-play-materialize-duration",`${xkn}ms`),t.style.setProperty("--vgai-play-crossfade-duration",`${gKt}ms`)}let PP=null;function Ckn(t){return PP=t,typeof document<"u"&&wkn(document.documentElement),()=>{PP===t&&(PP=null)}}function yKt(){return typeof window<"u"&&(window.matchMedia?.("(prefers-reduced-motion: reduce)").matches??!1)}const Ekn=1<<31;function Tkn(t){return(t.layers.mask&Ekn)!==0||/gizmo/i.test(t.name)}function vKt(t){if(Tkn(t))return null;if(t.isCamera)return t;for(const r of t.children){const i=vKt(r);if(i)return i}return null}function kkn(t,r,i){const a=new Tc,l=new H8;return r.getWorldPosition(a),r.getWorldQuaternion(l),{entityId:t,position:a.toArray(),quaternion:l.toArray(),fov:i}}function Ikn(t){for(const[r,i]of t.objectMap){const a=vKt(i);if(!a)continue;const l=a;return kkn(r,a,l.isPerspectiveCamera?l.fov:60)}return null}let kE=null;function Dkn(){return kE?.state.phase??"idle"}const ehe=new Set;function bKt(){if(ehe.size===0)return;const t=[...ehe];ehe.clear();for(const r of t)r()}function Pkn(t){if(!kE||kE.state.phase==="playing"){t();return}ehe.add(t)}function Nkn(t,r,i){const a=setTimeout(()=>{t.timeouts.delete(a),i()},r);t.timeouts.add(a)}function Okn(t){t.curve=new Pkt(mKt(t.startPos,t.endPos))}function Xq(t){const r=kE;if(!r)return;const i=r.state,a=Akn(i,t);a!==i&&(r.state=a,a.phase==="crossfade"&&i.phase!=="crossfade"&&(PP?.root.classList.add("vgai-play-crossfade"),Nkn(r,gKt+30,()=>Xq("crossfade-done"))),a.phase==="playing"&&i.phase!=="playing"&&(PP?.root.classList.remove("vgai-play-flight","vgai-play-crossfade"),Fkn(),bKt()))}function Fkn(){const t=hte(),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 Rkn(){const t=_Kt(),r=Qh();Mkn(t&&r?Ikn(r):null,{immersive:t})}function Mkn(t,r){if(kE&&mKe(),!r.immersive)return;const i=yKt();pKt(!0);const a={state:hKt,reducedMotion:i,flight:null,cameraSnapshot:null,getLiveCamera:null,timeouts:new Set};if(kE=a,PP?.hideChrome(!i),i){Xq("start-reduced");return}Xq("start");const l=hte();if(!t||!l){Xq("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 H8().fromArray(t.quaternion),endFov:t.fov,curve:new Pkt(mKt(d,_)),startedAt:performance.now(),durationMs:ykn(d.distanceTo(_)),landed:!1};a.flight=g,l.orbit.enabled=!1,PP?.root.classList.add("vgai-play-flight")}function Lkn(t,r){(!t||!r)&&mKe()}function jkn(t){const r=kE;r&&(r.getLiveCamera=t??null,Xq("game-ready"))}const u9e=new Tc,YTt=new H8;pQt(Bkn);function Bkn(){const t=kE,r=hte(),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(u9e),l.getWorldQuaternion(YTt),u9e.distanceToSquared(i.endPos)>1e-8&&(i.endPos.copy(u9e),Okn(i)),i.endQuat.copy(YTt);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=vkn(_);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,Xq("flight-done"))}function mKe(){const t=kE;if(!t)return;kE=null;for(const i of t.timeouts)clearTimeout(i);t.timeouts.clear(),bKt(),PP?.root.classList.remove("vgai-play-flight","vgai-play-crossfade");const r=hte();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(!yKt()),pKt(!1)}const Fqe=new Set;let AKt=null;function SKt(){return ad()?.rootPath??null}function $kn(t){Fqe.add(t);const r=SKt();return r!==null&&AKt===r&&t(),()=>{Fqe.delete(t)}}async function X4n(){AKt=SKt();for(const t of[...Fqe])await t()}function qkn(){const t=I_();if(t===null)return null;const r=pZ(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 zkn=new Map;let Rqe=null;function Ukn(t){Rqe=t}function XTt(){if(!Rqe)throw new Error("The workbench Output service is not connected.");return Rqe}function Vkn(){ALr(I_),mMr({output:{write:(...t)=>XTt().write(...t),show:t=>XTt().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:RHt,mounted:kQe,playing:Z1e,runWindow:AQe,restartRequired:NHt,restart:OHt,subscribe:DQe,version:LHt,notifyChanged:PHt,snapshotFrame:xQe,frameCanvas:SQe,authoringRefusal:TQe,dispatch:wQe,scenes:CQe,surface:X1e,coverage:EQe},viewport:{rig:hte,presentRoots:V2n,onFrame:pQt,setHelper:U2n,stages:_Qt,onStages:W2n,transition:{begin:Rkn,ready:jkn,end:mKe,onSettled:Pkn,phase:Dkn}},hierarchy:{object:t=>Qh()?.objectMap.get(t)??null,objects:()=>Qh()?.objectMap??zkn,subscribe:t=>{const r=Wpe(t),i=Qh()?.subscribe(t);return()=>{r(),i?.()}},version:()=>{const t=Qh();return t?.getShellSnapshot?.()??t?.getSnapshot()??0}},session:{reportFacet:$gn,onSample:kyn,onCommandDispatched:tqr,playState:()=>Qh()?.playState??"stopped",playEditRegime:()=>Qh()?.playEditRegime??null,subscribe:t=>{const r=Wpe(t),i=Qh()?.subscribe(t);return()=>{r(),i?.()}},version:()=>{const t=Qh();return t?.getShellSnapshot?.()??t?.getSnapshot()??0},open:()=>Qh()!==null,onEnded:t=>JUe(r=>{r!==null&&t()}),onBeforeClose:Kgn,reportWorkerCallMeter:Gbn},project:{mounts:az,engineVersion:()=>ad()?.config.engine.version??null,subscribe:Iw,onReady:$kn},notify:t=>oz(t),systems:{inspected:hze,subscribe:vOr,inspectedNetworking:xOr,subscribeNetworking:wOr,inspectedAudio:()=>COr()??null,subscribeAudio:EOr,audioVersion:TOr},availability:{subscribe:$Qt,version:Nwn},workspace:{showUtility:hE,openContributedDocument:t=>fI(null,t),open:async t=>await h0e(t.kind,Qh()??{setActiveViewportTab:()=>{}},t)!==null,liveDocument:{id:Sw,register:e2n,acquire:i2n,release:ZQe,open:dbe,container:t2n,setContainer:r2n,releaseContainer:n2n}},documents:{activeId:I_,active:()=>{const t=AE();return t?{id:t.descriptor.id,kind:t.descriptor.kind,title:t.title}:null},subscribe:Aw,version:Ab,context:pZ,waitForContext:x3t,contextChanged:NFr},transport:{for:t=>mkn(t),subscribe:hkn},projectLocalState:{ready:dte,read:VQe,write:cbe,projectRootPath:()=>ad()?.rootPath??null},history:{record:L4t,setDelegate:vLr,onElement:xLr,invalidate:wLr,onInvalidated:CLr,changed:bLr,elements:SLr,focusedResource:()=>{const t=AE();if(!t)return null;const r=t.descriptor.provenance?.sourcePath;if(r)return r;const i=Qh();return i?Y$r(i)??qUe(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=M4t(t),i=Wpe(t),a=Qh()?.projectHistory?.subscribe(t),l=Aw(t);return()=>{r(),i(),a?.(),l()}}},files:{setProvider:HMr,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:_7r,get:b7r,set:S7r,inspect:Q3t,subscribe:t=>{const r=W3t(t),i=Cee(t);return()=>{r(),i()}}},keyboard:{actions:()=>kAn().map(({id:t,scope:r})=>({id:t,scope:r})),keymaps:()=>K3t().map(({id:t,title:r})=>({id:t,title:r,chords:rPt(t)})),activeKeymap:uI,invoke:t=>PAn(t),subscribe:t=>{const r=DAn(t),i=sU(t),a=Wpe(t),l=Qh()?.subscribe(t),d=Aw(t);return()=>{r(),i(),a(),l?.(),d()}},version:()=>IAn()+Ab(),stage:()=>{const t=Qh();return t?{surface:ryn(t).surface,mode:qkn()}:{surface:null,mode:null}}}})}let Jkn=0,mee=null;const Mqe=new Set;function ZTt(t){const r={generation:++Jkn,promise:t,active:!0};mee=r;for(const i of Mqe)i(r);return Mqe.clear(),r}function Wkn(){const t=mee;return t?.active?Promise.resolve(t):new Promise(r=>Mqe.add(r))}async function hKe(){for(;;){const t=await Wkn();if(await t.promise,mee===t&&t.active)return}}const xKt=15,Hkn=300,Gkn=1e4,wKt="workspace";function Qkn(){const t=VQe(wKt);return!t||t.version!==xKt?null:t}function Kkn(t){cbe(wKt,t)}function Ykn(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 Xkn(){const t={};let r=!1;for(const i of fPt()){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 Zkn(){const t=[];for(const i of FA()){const a=Ykn(i);a&&t.push(a)}const r=Xkn();return{version:xKt,workspace:wS(),documents:{open:t,activeId:I_(),...r?{kinds:r}:{}}}}async function eIn(t,r,i){for(const a of uPt(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 ekt(t){return t?s9(t)?!0:ajr.has(t)?(Omn(t),ZOr(t),!0):Sb(t):!1}function tIn(t,r){const i=r?.kinds??{},a=(r?.open.length??0)>0;for(const l of fPt())if(l.beginRestore)try{l.beginRestore({state:i[l.kind],hasDocumentsToRestore:a,store:t})}catch{}}function rIn(t){const r=new Set;for(const i of t)for(const a of uPt(i.kind))a.prepare&&r.add(a.prepare);return Promise.all([...r].map(i=>i().catch(()=>{})))}async function nIn(t,r){const i=r?.documents;if(tIn(t,i),!i||i.open.length===0){ekt(i?.activeId??null);return}await rIn(i.open);for(const a of i.open)await eIn(t,a,i.activeId);ekt(i.activeId)}function CKt(t){if(!dte()||ad()&&!wb()){let J=!1,X=null,G=()=>{};const ee=new Promise(ue=>{G=ue}),xe=ZTt(ee);return Promise.all([abe(),cQe()]).then(()=>{if(J){G();return}X=CKt(t),xe.active=!1,hKe().finally(G)}),()=>{J=!0,X?.()}}const r=Qkn();r?.workspace&&AZ(r.workspace)&&CP(r.workspace)?CS(r.workspace):CS(lz(),{provisional:!0});let i=!1,a=null;const l=[],d=()=>{a!==null&&(clearTimeout(a),a=null),!(gkn()||t.playState!==void 0&&t.playState!=="stopped")&&Kkn(Zkn())},_=()=>{a!==null&&clearTimeout(a),a=setTimeout(d,Hkn)},g=()=>d();let b=null;const S=typeof window<"u"&&pIt(window.location.href)!==null,k=S||!(r?.documents?.open.length??0)?Promise.resolve():WR().catch(()=>{}),w=k.then(()=>S?void 0:nIn(t,r)).catch(()=>{}),N=new Promise(J=>{k.then(()=>{i||(b=setTimeout(()=>{J()},Gkn))})}),P=Promise.race([w,N]).then(()=>{b!==null&&clearTimeout(b),!i&&(l.push(Aw(_)),window.addEventListener("pagehide",g))}),j=ZTt(P);return()=>{i=!0,j.active=!1,mee===j&&(mee=null),b!==null&&clearTimeout(b);for(const J of l)J();window.removeEventListener("pagehide",g),a!==null&&d()}}function iIn(t){Xe.useEffect(()=>{const r=pIt(window.location.href);if(!r)return;let i=!1;const a=hh(),l=()=>!i&&hh()===a;return hKe().then(()=>{if(l())return vye(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 tkt="vgai:stale-chunk-reload";function sIn(){typeof window>"u"||window.addEventListener("vite:preloadError",t=>{let r=0;try{r=Number(sessionStorage.getItem(tkt)??0)}catch{}if(!(Date.now()-r<6e4)){try{sessionStorage.setItem(tkt,String(Date.now()))}catch{}t.preventDefault(),window.location.reload()}})}const G$=[];function oIn(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 aIn(t,r){const i=[];for(const a of Object.keys(r).sort())i.push(`${a}=${cIn(r[a])}`);return`${t}|${i.join("&")}`}function cIn(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 Fye=new Map,F_e=new Map,rkt=new WeakMap;let nkt=Promise.resolve(),ikt=null,lIn=1;function uIn(){return typeof WebGLRenderingContext<"u"&&typeof navigator<"u"&&!navigator.userAgent.toLowerCase().includes("jsdom")}async function fIn(){await Promise.race([e0e(),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 dIn(){return ikt??=fIn(),ikt}function pIn(t){const r=rkt.get(t);if(r!==void 0)return r;const i=lIn++;return rkt.set(t,i),i}function _In(t,r,i,a){const l=Fye.get(t);if(l)return Promise.resolve(l);const d=F_e.get(t);if(d)return d;const _=nkt.then(async()=>{await dIn();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 la(async()=>{const{capturePixiStoryThumbnail:N}=await import("./story-pixi-preview-C6n-a2_M.js");return{capturePixiStoryThumbnail:N}},__vite__mapDeps([81,3,2,4,82,1,8,9,10,11,6]));return w(i.Component,S)}const{captureStoryComponentThumbnail:k}=await la(async()=>{const{captureStoryComponentThumbnail:w}=await import("./story-three-preview-BazrPMDu.js");return{captureStoryComponentThumbnail:w}},__vite__mapDeps([83,3,2,4,82,6,65,11,9,1,8,10]));return k(i.Component,S)});return nkt=_.then(()=>{},()=>{}),F_e.set(t,_),_.then(g=>{Fye.set(t,g),F_e.delete(t)},()=>F_e.delete(t)),_}function mIn({component:t,story:r,previewRevision:i,width:a=128,height:l=96}){const d=r.Component,_=`${t.surface}:${t.path}:${aIn(r.id,r.args)}:${pIn(d)}:${i}:${a}x${l}`,[g,b]=Xe.useState(()=>Fye.get(_)),[S,k]=Xe.useState(!1);return Xe.useEffect(()=>{let w=!1;if(k(!1),b(Fye.get(_)),!!uIn())return _In(_,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 ybe="story:three",vbe="story:isolated",hIn="story:docs";function gIn(t,r){return t.surface==="dom"?!1:r===null||t.surface===r}function yIn({entry:t,previewRevision:r,width:i,height:a}){const l=t.detail;return z.jsx(mIn,{component:t.component,story:l,previewRevision:r,...i===void 0?{}:{width:i},...a===void 0?{}:{height:a}})}const vIn="story",bIn={id:vIn,owner:"./component-content-source",entries(t){const r=H1e(),i=[];for(const a of t.components){if(!gIn(a,t.surface))continue;const l=omn(r,a.name,a.path);l&&i.push({id:`${a.path}:${a.name}`,component:a,detail:l})}return i},subscribe:G1e,Thumbnail:yIn,open(t,r,i){const a=r.detail,l=r.component.surface==="three";FP(l?ybe:vbe,t,l?{modulePath:a.modulePath,storyName:a.name,title:i}:{modulePath:a.modulePath,storyName:a.name})}};function skt(t){return amn(t.name,t.sourcePath)}const AIn={id:"portable-csf",owner:"./component-states",statesFor:(t,r)=>r.surface==="dom"?[]:skt(t).map(i=>({id:i.id,label:i.label})),apply:(t,r,i)=>{const a=skt(t).find(l=>l.id===r);if(a){if(i.surface==="three"){FP(ybe,i.store,{modulePath:a.modulePath,storyName:a.name,title:a.label});return}if(i.surface==="canvas"){FP(vbe,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 SIn(){let t=0,r=!1;const i=g=>{const b=++t;Z_n(),e0e().then(()=>{if(!(r||b!==t))return fmn(ad(),void 0,{deferUndeclared:!0,...g?{changedPaths:g}:{}})})};i();let a=null;const l=KNt(),d=Iw(()=>i()),_=NUr(i);return()=>{r=!0,t+=1,a!==null&&clearTimeout(a),l(),d(),_()}}const EKt="story",f9e=new Set,d9e=new Set;function xIn(t){const r=TWt({modulePath:t.modulePath,title:t.title}).leaf;return r===t.label?r:`${r} · ${t.label}`}function p9e(t){for(const r of H1e())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??xIn({modulePath:r.modulePath,title:i.title,label:i.label})}}return null}function wIn(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(hIn,t,a);const l=oQe({modulePath:i.modulePath,regions:sQe()});return l.medium===void 0?(X_n(i.modulePath,l.reason),null):FP(l.medium==="three"?ybe:vbe,t,a)}function okt(t){ua.warn(`No composed portable story carries the id ${JSON.stringify(t)}, so nothing opened it.`,"editor")}function CIn(){return g9({id:EKt,owner:"./story-opener",open:(t,r)=>{const i=p9e(r);return i?wIn(t,r,i):(r.modulePath?f9e.add(r.modulePath):r.storyId!==void 0&&(d9e.add(r.storyId),nmn()&&okt(r.storyId)),null)},settle:async()=>{await XLr();const t=[...f9e],r=[...d9e];if(f9e.clear(),d9e.clear(),await Promise.all(t.map(i=>cmn(ad(),i))),r.length!==0){await imn();for(const i of r)p9e({storyId:i})||okt(i)}},ready:async(t,r)=>{if(r.mode==="docs")return;const i=p9e(r);if(!(!i||oQe({modulePath:i.modulePath,regions:sQe()}).medium!=="three")&&!await xE(()=>Pw(t)!==null,m9))throw new Error(`The requested Object3D view did not mount for document: ${t}`)}})}const EIn={actions:()=>{if(!DAt(vbe)&&!DAt(ybe))return[];const t=[];for(const r of H1e()){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:EKt,modulePath:r.modulePath,storyName:a.name,title:a.name})})}return t},subscribe:t=>G1e(t)},TIn="packages/editor/src/stories/story-capture-command.ts",uq="capture-story-variants";async function kIn(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 nge("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=cNt(uq,t.camera);if(typeof g=="string")return{ok:!1,error:g};const b=lNt(uq,t.pose);if(typeof b=="string")return{ok:!1,error:b};const{captureProjectStoryVariants:S}=await la(async()=>{const{captureProjectStoryVariants:w}=await import("./story-capture-C2ExQiuI.js");return{captureProjectStoryVariants:w}},__vite__mapDeps([84,61,1,2,3,4,8,9,10,81,82,11,6,83,65]));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 IIn={[uq]:{timeoutMs:12e4,derivedRefresh:"if-content-changed",handle:kIn}};function DIn(){const t=z0n(bIn),r=oIn(AIn),i=CIn(),a=bIt(EIn),l=SIt(TIn,IIn),d=SIn(),_=G1e(()=>{WX()});return()=>{_(),d(),l(),a(),i(),r(),t()}}let _9e=null;const PIn=new Set;function NIn(t){return _9e=t,Lqe(),()=>{_9e===t&&(_9e=null,Lqe())}}function Lqe(){for(const t of PIn)t()}let Mm=null,TKt=0;const jqe=new Set;function OIn(t){return jqe.add(t),()=>jqe.delete(t)}function akt(){return TKt}function FIn(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&&kKt(t,r),TKt+=1;for(const i of jqe)i()}}function kKt(t,r){r.dataset.vgaiPart=t}const Zq=new Map;let IKt=0;const Bqe=new Set;function RIn(t,r){if(r){if(!Zq.delete(t.id))return}else{const i=Zq.get(t.id);if(i?.element===t.element&&i.documentId===t.documentId)return;Zq.set(t.id,{...t})}IKt+=1;for(const i of[...Bqe])i()}function MIn(t){return Bqe.add(t),()=>{Bqe.delete(t)}}function ckt(){return IKt}function CR({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 LIn({children:t}){return z.jsx(z.Fragment,{children:t})}function jIn(){return Mm?vS.createPortal(z.jsx(CR,{center:!0,children:z.jsx(jEn,{})}),Mm.header):null}function BIn(){return null}function $In(){const t=Xe.useRef(null);return Xe.useEffect(()=>{const r=t.current;if(r)return GQt(r),()=>iCn(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(eKt,{})})]})}const the=new Map,$qe=new Set;let qqe=0;function qIn(t,r){if(r){if(the.get(t)===r)return;the.set(t,r)}else if(!the.delete(t))return;qqe++;for(const i of $qe)i()}const rhe=new Map,zqe=new Set;let Uqe=0;function zIn(t,r){if(r){if(rhe.get(t)===r)return;rhe.set(t,r)}else if(!rhe.delete(t))return;Uqe++;for(const i of zqe)i()}function UIn(){return Xe.useSyncExternalStore(jDt,qbt,qbt),Xe.useSyncExternalStore(t=>(zqe.add(t),()=>zqe.delete(t)),()=>Uqe,()=>Uqe),z.jsx(z.Fragment,{children:[...$9e("left"),...$9e("right")].map(t=>{const r=rhe.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 VIn(){return Xe.useSyncExternalStore(m0e,IAt,IAt),Xe.useSyncExternalStore(t=>($qe.add(t),()=>$qe.delete(t)),()=>qqe,()=>qqe),z.jsx(z.Fragment,{children:gE().map(t=>{const r=the.get(t.id);return r?z.jsx(Xe.Fragment,{children:vS.createPortal(z.jsx(CR,{children:z.jsx(qEn,{utility:t})}),r)},t.id):null})})}function JIn({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(CR,{children:[z.jsx(yQt,{descriptor:t,viewId:r,active:l,chrome:!t.area}),d&&z.jsx($wn,{})]}),_)}let DKt=!0;function WIn({arrangement:t,immersivePlay:r}){const i=D0();iIn(i);const a=nKe(i);Xe.useLayoutEffect(()=>{DKt=a.column},[a.column]);const l=Zq.get(Q9e()??"")?.element??Mm?.center;Xe.useLayoutEffect(()=>{if(!l)return;const k=()=>fTt({x:0,y:0,width:l.clientWidth,height:l.clientHeight}),w=new ResizeObserver(k);return w.observe(l),k(),()=>{w.disconnect(),fTt(null)}},[l]),Xe.useSyncExternalStore(i.subscribe,i.getShellSnapshot??i.getSnapshot),Xe.useSyncExternalStore(Aw,Ab,Ab),Xe.useSyncExternalStore(MIn,ckt,ckt),Xe.useSyncExternalStore(OIn,akt,akt),Xe.useLayoutEffect(()=>{const k=z7r({...t?{arrangement:t}:{},...r===void 0?{}:{immersivePlay:r},playUtilities:[]});return t&&CS(t.id),vRr(),k},[t,r]);const d=i.playState!=="stopped",_=Xe.useSyncExternalStore(Cee,P8).play?.keepPanelsVisible;if(Xe.useEffect(()=>{Lkn(d,_Kt())},[d,r,_]),Xe.useEffect(()=>CKt(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:[...Zq.values()].map(({id:k,documentId:w,element:N})=>({id:k,documentId:w,visible:!!N}))},z.jsxs(z.Fragment,{children:[[...Zq.values()].map(k=>{const w=b.find(N=>N.descriptor.id===k.documentId)?.descriptor;return w?z.jsx(JIn,{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(CR,{children:z.jsx("div",{className:"vgai-vscode-empty",children:"No document open"})}),Mm.center),Mm.outliner&&vS.createPortal(z.jsx(CR,{children:z.jsx($In,{})}),Mm.outliner),Mm.properties&&a.column&&vS.createPortal(z.jsx(CR,{children:z.jsx(cKe,{})}),Mm.properties),Mm.content&&vS.createPortal(z.jsx(CR,{children:z.jsx(akn,{kind:"assets"})}),Mm.content),z.jsx(VIn,{}),z.jsx(UIn,{})]})}async function HIn(t){Mm=t;for(const[G,ee]of Object.entries(t))ee&&kKt(G,ee);t.chromeRoot.id="editor-chrome-root",hMr({Frame:LIn,Header:jIn,Footer:BIn,Workspace:WIn,Document:pSn}),lkn(),Byn();const r=Exn();r&&wxn(r,Date.now())&&ua.warn(Sxn(r,Date.now()),"editor"),sIn(),GLr(),Vkn(),DIn(),await Promise.all([G3t(),JRr()]),o9r(t.chromeRoot),t.chromeRoot.classList.toggle("vgai-native-menus",$ye()?.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),Vqe.createRoot(i).render(z.jsx(Uxn,{}));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:hKe,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?dRr().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=pRr(G);return()=>{ee(),xe()}},activate:(G,ee)=>{ee?YOr(G,ee):Sb(G)},close:G=>{if(K8(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)=>RIn(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:()=>[...h7r()],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:()=>aU(),notify:G=>{fv().notify(G)},subscribe:G=>{const ee=u0e(G),xe=xPt(G);return()=>{ee(),xe()}},report:a.report},b={list:()=>zyn().map(G=>({id:G.id,label:G.label,category:G.category})),invoke:G=>Vyn(G),subscribe:G=>Uyn(G),setPaletteOpener:G=>qyn(G),setCommandExecutor:G=>Jyn(G),report:a.report},S={setDelegate:G=>FFr(G?{show:G}:null)},k={list:()=>b4t().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)=>S4t(G,ee,xe),subscribe:G=>A4t(G)},w={list:()=>gE().map((G,ee)=>({id:G.id,title:G.title,order:G.order??ee})),subscribe:G=>m0e(G),offerBody:(G,ee)=>qIn(G,ee)};let N=!0,P=null,j=null;NIn(()=>N);const J={setActiveStaticPanel:G=>CAt(RQe.find(ee=>ee.kind===G)?.kind??null),focusCompactInspector:()=>{if(DKt)return!1;const G=Mm?.center.querySelector('[data-testid="compact-inspector-card"]');return G?(G.tabIndex=-1,G.focus(),CAt("inspector"),!0):!1},setPaneActive:G=>{N!==G&&(N=G,Lqe())},setImmersive:G=>{P?.(),P=null,!(!G||!Mm)&&(P=Ckn({root:Mm.chromeRoot,hideChrome:()=>G.enter(),showChrome:()=>G.exit()}))},setDockCommands:G=>{j?.(),j=null,G&&(j=J7r({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:Ukn},settings:g,status:{list:()=>["left","right"].flatMap(G=>$9e(G).map((ee,xe)=>({id:ee.id,title:ee.name,align:G,order:ee.order??xe}))),subscribe:G=>jDt(G),offerBody:(G,ee)=>zIn(G,ee)},game:J,offerPart:FIn}}function GIn(t){const r=Object.keys(t.packages);return kIr({id:t.id,packages:r,look:t.look,workspace:t.workspace,nativeMenus:t.nativeMenus}),PPt(r.flatMap(i=>t.packages[i]??[])),{mountVgai:HIn}}const{mountVgai:Z4n}=GIn({id:"editor",packages:{"@volter/editor-blender":TIr},look:"blender",workspace:"model"});export{HDn as $,fvn as A,fo as B,SE as C,Z8 as D,EDn as E,TDn as F,VN as G,U_ as H,Sbn as I,N4n as J,HPn as K,UDn as L,L0e as M,X8 as N,LP as O,E2t as P,svn as Q,wDn as R,xFr as S,Ru as T,X4n as U,dQe as V,FA as W,Omn as X,I_ as Y,ua as Z,la as _,o_ as a,DWt as a$,$2t as a0,q2t as a1,GDn as a2,My as a3,So as a4,aDn as a5,bS as a6,S8 as a7,lDn as a8,wWt as a9,$9r as aA,DDn as aB,KPt as aC,mZ as aD,cDn as aE,XFr as aF,Qkt as aG,s5r as aH,AX as aI,j_n as aJ,ODn as aK,M0e as aL,UDt as aM,W_ as aN,WWt as aO,T3t as aP,CDn as aQ,qY as aR,MPn as aS,LPn as aT,TWt as aU,rmn as aV,imn as aW,DPn as aX,oQe as aY,IWt as aZ,CWt as a_,jPn as aa,H4n as ab,wGt as ac,Jwn as ad,z0e as ae,iMe as af,sz as ag,AMr as ah,NP as ai,Wa as aj,xDn as ak,Ny as al,Eze as am,VR as an,e3n as ao,TX as ap,kDn as aq,r3n as ar,Zh as as,IDn as at,B9r as au,FDn as av,yw as aw,np as ax,HR as ay,ad as az,zDn as b,b8 as b$,z_n as b0,GR as b1,Pgn as b2,sQe as b3,Oee as b4,w5r as b5,sU as b6,uI as b7,ep as b8,e4n as b9,zR as bA,uv as bB,yFr as bC,k_ as bD,y3t as bE,XDn as bF,DOr as bG,pDn as bH,KNt as bI,i3n as bJ,ZDn as bK,SDn as bL,n3n as bM,NIr as bN,nge as bO,Ukt as bP,yee as bQ,wg as bR,jDn as bS,wbn as bT,S4t as bU,h_e as bV,M$e as bW,rI as bX,Ghn as bY,bb as bZ,K1e as b_,Nq as ba,n4n as bb,ph as bc,rf as bd,x8 as be,qye as bf,wze as bg,i0e as bh,Aw as bi,Ab as bj,Pee as bk,MP as bl,Xye as bm,I8 as bn,wm as bo,Pw as bp,E5r as bq,ADr as br,W4n as bs,G2n as bt,O4n as bu,zkt as bv,hE as bw,pee as bx,UHt as by,zPn as bz,mz as c,pUe as c$,k9 as c0,ute as c1,gv as c2,jd as c3,Tu as c4,wbt as c5,uDn as c6,bee as c7,xbt as c8,fDn as c9,I4n as cA,Zbt as cB,iDn as cC,LIr as cD,D4n as cE,gAn as cF,Dze as cG,By as cH,mjr as cI,RDn as cJ,y4n as cK,YMe as cL,hAn as cM,c1n as cN,h4n as cO,l4n as cP,_4n as cQ,p4n as cR,c9 as cS,u4n as cT,w4n as cU,d4n as cV,f4n as cW,m4n as cX,x4n as cY,v4n as cZ,C4n as c_,TNr as ca,kR as cb,JGt as cc,B4t as cd,jA as ce,fAn as cf,JDn as cg,WDn as ch,VDn as ci,zP as cj,z4t as ck,o4n as cl,cAn as cm,s4n as cn,TFe as co,YPt as cp,lSn as cq,jkt as cr,OIr as cs,MIr as ct,JQe as cu,Fkt as cv,P4n as cw,nDn as cx,oDn as cy,sDn as cz,dU as d,t3n as d$,k0 as d0,b4n as d1,A4n as d2,a4n as d3,c4n as d4,g4n as d5,E4n as d6,kQe as d7,S4n as d8,yAn as d9,wZ as dA,DUe as dB,$Dn as dC,BDn as dD,MDn as dE,B4n as dF,F4n as dG,T2n as dH,M4n as dI,L4n as dJ,j4n as dK,fte as dL,jHt as dM,XPn as dN,V9r as dO,Wvn as dP,YPn as dQ,CGt as dR,d1n as dS,Cbn as dT,GPn as dU,QPn as dV,QMe as dW,tme as dX,KMe as dY,NDn as dZ,PDn as d_,T4n as da,k4n as db,yhe as dc,OP as dd,x5r as de,K8 as df,$4t as dg,OPn as dh,RPn as di,njr as dj,Sw as dk,Sb as dl,NPn as dm,PPn as dn,FPn as dp,i4n as dq,ZPn as dr,DGt as ds,iNt as dt,kZ as du,e5r as dv,V4t as dw,zwn as dx,W8 as dy,_Dn as dz,fv as e,LDn as e0,PUe as e1,B2n as e2,BPn as e3,$Pn as e4,Q4n as e5,G4n as e6,q4n as e7,z4n as e8,$4n as e9,RGt as eA,hDn as eB,gDn as eC,bQe as eD,o8 as eE,U8 as eF,Uhn as eG,T_ as eH,SCt as eI,aHt as eJ,Lm as eK,pHt as eL,Fy as eM,Z4n as eN,gb as ea,R4n as eb,U4n as ec,pv as ed,t4n as ee,UPn as ef,VPn as eg,VHt as eh,r4n as ei,Qh as ej,Eq as ek,vDn as el,qPn as em,Y4n as en,W4t as eo,J4n as ep,ADn as eq,yDn as er,mDn as es,bP as et,V4n as eu,dDn as ev,WPn as ew,bDn as ex,K4n as ey,JPn as ez,QDn as f,CE as g,xUe as h,KDn as i,dE as j,q0e as k,Ry as l,uNt as m,KPn as n,Na as o,VUe as p,od as q,YDn as r,Ss as s,Oo as t,D0 as u,pGt as v,sLr as w,jQe as x,I$r as y,uvn 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 skn=RQe.map(t=>{const r=nkn[t.kind],i=a=>z.jsx(ikn,{title:t.title,children:z.jsx(r,{...a})});return i.displayName=`StaticPanel(${t.kind})`,{...t,Content:i}});function okn(t){return skn.find(r=>r.kind===t)}function akn({kind:t,dependencies:r}){const{Content:i}=okn(t);return z.jsx(i,{dependencies:r})}const ckn=250;function lkn(){const t=j3t(),r=ukn();return()=>{r(),t()}}function ukn(){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&&F8("console-entries",{entries:_,_clientId:jP})}const d=ua.subscribe(()=>{i||r!==null||(r=setTimeout(l,ckn))});return F8("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"},N_e=[RN.INPUT,RN.PRE_PHYSICS,RN.PHYSICS,RN.POST_PHYSICS,RN.GAME_LOGIC,RN.ANIMATION,RN.PRE_RENDER,RN.RENDER],Oye=1e-9,uKt=1e5;function fkn(t,r,i){const a=i.end-i.start,l=i.loop&&a>Oye,d=[];let _=t,g=r,b=!1,S=0;for(;;){const k=i.end-_;if(!l||g<=k+Oye){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>uKt){const w=i.start+g%a;d.push({from:_,to:w,direction:"forward"}),_=w;break}}return{pos:_,intervals:d,looped:b}}function dkn(t,r,i){const a=i.end-i.start,l=i.loop&&a>Oye,d=[];let _=t,g=r,b=!1,S=0;for(;;){const k=_-i.start;if(!l||g<=k+Oye){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>uKt){const w=i.end-g%a;d.push({from:_,to:w,direction:"reverse"}),_=w;break}}return{pos:_,intervals:d,looped:b}}function QTt(t,r){return t<r.start?r.start:t>r.end?r.end:t}class pkn{_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=QTt(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=QTt(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"?fkn(a,i,this._range):dkn(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(!N_e.includes(r))throw new Error(`[AnimationClock] unknown phase "${r}". Valid: ${N_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=N_e.indexOf(b.phase),w=N_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 O_e={start:0,end:0,fps:30},_kn=150;class K4n{constructor(r){this.store=r,this.stopStoreWatch=r.subscribe(()=>this.notify())}clock=new pkn;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:O_e.start,end:O_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??O_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()},_kn)}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()??O_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 Zme=new Map,Oqe=new Set;function KTt(){for(const t of[...Oqe])t()}function Y4n(t,r){return Zme.set(t,r),KTt(),()=>{Zme.get(t)===r&&(Zme.delete(t),KTt())}}function mkn(t){return t===null?null:Zme.get(t)??null}function hkn(t){return Oqe.add(t),()=>{Oqe.delete(t)}}const fKt="__vgaiWorkspacePersistenceSuppressed";function dKt(){return globalThis}function pKt(t){dKt()[fKt]=t}function gkn(){return dKt()[fKt]===!0}function _Kt(){return(d0e()?.immersivePlay??!1)&&!P8().play?.keepPanelsVisible}function ykn(t){return Math.min(1600,Math.max(800,900+t*25))}function vkn(t){return t<.5?4*t*t*t:1-(-2*t+2)**3/2}function mKt(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 hKt={phase:"idle",flightDone:!1,gameReady:!1};function bkn(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 Akn(t,r){if(r==="stop")return hKt;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 bkn(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 Skn=450,xkn=220,gKt=250;function wkn(t){t.style.setProperty("--vgai-play-dissolve-duration",`${Skn}ms`),t.style.setProperty("--vgai-play-materialize-duration",`${xkn}ms`),t.style.setProperty("--vgai-play-crossfade-duration",`${gKt}ms`)}let PP=null;function Ckn(t){return PP=t,typeof document<"u"&&wkn(document.documentElement),()=>{PP===t&&(PP=null)}}function yKt(){return typeof window<"u"&&(window.matchMedia?.("(prefers-reduced-motion: reduce)").matches??!1)}const Ekn=1<<31;function Tkn(t){return(t.layers.mask&Ekn)!==0||/gizmo/i.test(t.name)}function vKt(t){if(Tkn(t))return null;if(t.isCamera)return t;for(const r of t.children){const i=vKt(r);if(i)return i}return null}function kkn(t,r,i){const a=new Tc,l=new H8;return r.getWorldPosition(a),r.getWorldQuaternion(l),{entityId:t,position:a.toArray(),quaternion:l.toArray(),fov:i}}function Ikn(t){for(const[r,i]of t.objectMap){const a=vKt(i);if(!a)continue;const l=a;return kkn(r,a,l.isPerspectiveCamera?l.fov:60)}return null}let kE=null;function Dkn(){return kE?.state.phase??"idle"}const ehe=new Set;function bKt(){if(ehe.size===0)return;const t=[...ehe];ehe.clear();for(const r of t)r()}function Pkn(t){if(!kE||kE.state.phase==="playing"){t();return}ehe.add(t)}function Nkn(t,r,i){const a=setTimeout(()=>{t.timeouts.delete(a),i()},r);t.timeouts.add(a)}function Okn(t){t.curve=new Pkt(mKt(t.startPos,t.endPos))}function Xq(t){const r=kE;if(!r)return;const i=r.state,a=Akn(i,t);a!==i&&(r.state=a,a.phase==="crossfade"&&i.phase!=="crossfade"&&(PP?.root.classList.add("vgai-play-crossfade"),Nkn(r,gKt+30,()=>Xq("crossfade-done"))),a.phase==="playing"&&i.phase!=="playing"&&(PP?.root.classList.remove("vgai-play-flight","vgai-play-crossfade"),Fkn(),bKt()))}function Fkn(){const t=hte(),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 Rkn(){const t=_Kt(),r=Qh();Mkn(t&&r?Ikn(r):null,{immersive:t})}function Mkn(t,r){if(kE&&mKe(),!r.immersive)return;const i=yKt();pKt(!0);const a={state:hKt,reducedMotion:i,flight:null,cameraSnapshot:null,getLiveCamera:null,timeouts:new Set};if(kE=a,PP?.hideChrome(!i),i){Xq("start-reduced");return}Xq("start");const l=hte();if(!t||!l){Xq("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 H8().fromArray(t.quaternion),endFov:t.fov,curve:new Pkt(mKt(d,_)),startedAt:performance.now(),durationMs:ykn(d.distanceTo(_)),landed:!1};a.flight=g,l.orbit.enabled=!1,PP?.root.classList.add("vgai-play-flight")}function Lkn(t,r){(!t||!r)&&mKe()}function jkn(t){const r=kE;r&&(r.getLiveCamera=t??null,Xq("game-ready"))}const u9e=new Tc,YTt=new H8;pQt(Bkn);function Bkn(){const t=kE,r=hte(),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(u9e),l.getWorldQuaternion(YTt),u9e.distanceToSquared(i.endPos)>1e-8&&(i.endPos.copy(u9e),Okn(i)),i.endQuat.copy(YTt);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=vkn(_);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,Xq("flight-done"))}function mKe(){const t=kE;if(!t)return;kE=null;for(const i of t.timeouts)clearTimeout(i);t.timeouts.clear(),bKt(),PP?.root.classList.remove("vgai-play-flight","vgai-play-crossfade");const r=hte();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(!yKt()),pKt(!1)}const Fqe=new Set;let AKt=null;function SKt(){return ad()?.rootPath??null}function $kn(t){Fqe.add(t);const r=SKt();return r!==null&&AKt===r&&t(),()=>{Fqe.delete(t)}}async function X4n(){AKt=SKt();for(const t of[...Fqe])await t()}function qkn(){const t=I_();if(t===null)return null;const r=pZ(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 zkn=new Map;let Rqe=null;function Ukn(t){Rqe=t}function XTt(){if(!Rqe)throw new Error("The workbench Output service is not connected.");return Rqe}function Vkn(){ALr(I_),mMr({output:{write:(...t)=>XTt().write(...t),show:t=>XTt().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:RHt,mounted:kQe,playing:Z1e,runWindow:AQe,restartRequired:NHt,restart:OHt,subscribe:DQe,version:LHt,notifyChanged:PHt,snapshotFrame:xQe,frameCanvas:SQe,authoringRefusal:TQe,dispatch:wQe,scenes:CQe,surface:X1e,coverage:EQe},viewport:{rig:hte,presentRoots:V2n,onFrame:pQt,setHelper:U2n,stages:_Qt,onStages:W2n,transition:{begin:Rkn,ready:jkn,end:mKe,onSettled:Pkn,phase:Dkn}},hierarchy:{object:t=>Qh()?.objectMap.get(t)??null,objects:()=>Qh()?.objectMap??zkn,subscribe:t=>{const r=Wpe(t),i=Qh()?.subscribe(t);return()=>{r(),i?.()}},version:()=>{const t=Qh();return t?.getShellSnapshot?.()??t?.getSnapshot()??0}},session:{reportFacet:$gn,onSample:kyn,onCommandDispatched:tqr,playState:()=>Qh()?.playState??"stopped",playEditRegime:()=>Qh()?.playEditRegime??null,subscribe:t=>{const r=Wpe(t),i=Qh()?.subscribe(t);return()=>{r(),i?.()}},version:()=>{const t=Qh();return t?.getShellSnapshot?.()??t?.getSnapshot()??0},open:()=>Qh()!==null,onEnded:t=>JUe(r=>{r!==null&&t()}),onBeforeClose:Kgn,reportWorkerCallMeter:Gbn},project:{mounts:az,engineVersion:()=>ad()?.config.engine.version??null,subscribe:Iw,onReady:$kn},notify:t=>oz(t),systems:{inspected:hze,subscribe:vOr,inspectedNetworking:xOr,subscribeNetworking:wOr,inspectedAudio:()=>COr()??null,subscribeAudio:EOr,audioVersion:TOr},availability:{subscribe:$Qt,version:Nwn},workspace:{showUtility:hE,openContributedDocument:t=>fI(null,t),open:async t=>await h0e(t.kind,Qh()??{setActiveViewportTab:()=>{}},t)!==null,liveDocument:{id:Sw,register:e2n,acquire:i2n,release:ZQe,open:dbe,container:t2n,setContainer:r2n,releaseContainer:n2n}},documents:{activeId:I_,active:()=>{const t=AE();return t?{id:t.descriptor.id,kind:t.descriptor.kind,title:t.title}:null},subscribe:Aw,version:Ab,context:pZ,waitForContext:x3t,contextChanged:NFr},transport:{for:t=>mkn(t),subscribe:hkn},projectLocalState:{ready:dte,read:VQe,write:cbe,projectRootPath:()=>ad()?.rootPath??null},history:{record:L4t,setDelegate:vLr,onElement:xLr,invalidate:wLr,onInvalidated:CLr,changed:bLr,elements:SLr,focusedResource:()=>{const t=AE();if(!t)return null;const r=t.descriptor.provenance?.sourcePath;if(r)return r;const i=Qh();return i?Y$r(i)??qUe(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=M4t(t),i=Wpe(t),a=Qh()?.projectHistory?.subscribe(t),l=Aw(t);return()=>{r(),i(),a?.(),l()}}},files:{setProvider:HMr,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:_7r,get:b7r,set:S7r,inspect:Q3t,subscribe:t=>{const r=W3t(t),i=Cee(t);return()=>{r(),i()}}},keyboard:{actions:()=>kAn().map(({id:t,scope:r})=>({id:t,scope:r})),keymaps:()=>K3t().map(({id:t,title:r})=>({id:t,title:r,chords:rPt(t)})),activeKeymap:uI,invoke:t=>PAn(t),subscribe:t=>{const r=DAn(t),i=sU(t),a=Wpe(t),l=Qh()?.subscribe(t),d=Aw(t);return()=>{r(),i(),a(),l?.(),d()}},version:()=>IAn()+Ab(),stage:()=>{const t=Qh();return t?{surface:ryn(t).surface,mode:qkn()}:{surface:null,mode:null}}}})}let Jkn=0,mee=null;const Mqe=new Set;function ZTt(t){const r={generation:++Jkn,promise:t,active:!0};mee=r;for(const i of Mqe)i(r);return Mqe.clear(),r}function Wkn(){const t=mee;return t?.active?Promise.resolve(t):new Promise(r=>Mqe.add(r))}async function hKe(){for(;;){const t=await Wkn();if(await t.promise,mee===t&&t.active)return}}const xKt=15,Hkn=300,Gkn=1e4,wKt="workspace";function Qkn(){const t=VQe(wKt);return!t||t.version!==xKt?null:t}function Kkn(t){cbe(wKt,t)}function Ykn(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 Xkn(){const t={};let r=!1;for(const i of fPt()){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 Zkn(){const t=[];for(const i of FA()){const a=Ykn(i);a&&t.push(a)}const r=Xkn();return{version:xKt,workspace:wS(),documents:{open:t,activeId:I_(),...r?{kinds:r}:{}}}}async function eIn(t,r,i){for(const a of uPt(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 ekt(t){return t?s9(t)?!0:ajr.has(t)?(Omn(t),ZOr(t),!0):Sb(t):!1}function tIn(t,r){const i=r?.kinds??{},a=(r?.open.length??0)>0;for(const l of fPt())if(l.beginRestore)try{l.beginRestore({state:i[l.kind],hasDocumentsToRestore:a,store:t})}catch{}}function rIn(t){const r=new Set;for(const i of t)for(const a of uPt(i.kind))a.prepare&&r.add(a.prepare);return Promise.all([...r].map(i=>i().catch(()=>{})))}async function nIn(t,r){const i=r?.documents;if(tIn(t,i),!i||i.open.length===0){ekt(i?.activeId??null);return}await rIn(i.open);for(const a of i.open)await eIn(t,a,i.activeId);ekt(i.activeId)}function CKt(t){if(!dte()||ad()&&!wb()){let J=!1,X=null,G=()=>{};const ee=new Promise(ue=>{G=ue}),xe=ZTt(ee);return Promise.all([abe(),cQe()]).then(()=>{if(J){G();return}X=CKt(t),xe.active=!1,hKe().finally(G)}),()=>{J=!0,X?.()}}const r=Qkn();r?.workspace&&AZ(r.workspace)&&CP(r.workspace)?CS(r.workspace):CS(lz(),{provisional:!0});let i=!1,a=null;const l=[],d=()=>{a!==null&&(clearTimeout(a),a=null),!(gkn()||t.playState!==void 0&&t.playState!=="stopped")&&Kkn(Zkn())},_=()=>{a!==null&&clearTimeout(a),a=setTimeout(d,Hkn)},g=()=>d();let b=null;const S=typeof window<"u"&&pIt(window.location.href)!==null,k=S||!(r?.documents?.open.length??0)?Promise.resolve():WR().catch(()=>{}),w=k.then(()=>S?void 0:nIn(t,r)).catch(()=>{}),N=new Promise(J=>{k.then(()=>{i||(b=setTimeout(()=>{J()},Gkn))})}),P=Promise.race([w,N]).then(()=>{b!==null&&clearTimeout(b),!i&&(l.push(Aw(_)),window.addEventListener("pagehide",g))}),j=ZTt(P);return()=>{i=!0,j.active=!1,mee===j&&(mee=null),b!==null&&clearTimeout(b);for(const J of l)J();window.removeEventListener("pagehide",g),a!==null&&d()}}function iIn(t){Xe.useEffect(()=>{const r=pIt(window.location.href);if(!r)return;let i=!1;const a=hh(),l=()=>!i&&hh()===a;return hKe().then(()=>{if(l())return vye(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 tkt="vgai:stale-chunk-reload";function sIn(){typeof window>"u"||window.addEventListener("vite:preloadError",t=>{let r=0;try{r=Number(sessionStorage.getItem(tkt)??0)}catch{}if(!(Date.now()-r<6e4)){try{sessionStorage.setItem(tkt,String(Date.now()))}catch{}t.preventDefault(),window.location.reload()}})}const G$=[];function oIn(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 aIn(t,r){const i=[];for(const a of Object.keys(r).sort())i.push(`${a}=${cIn(r[a])}`);return`${t}|${i.join("&")}`}function cIn(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 Fye=new Map,F_e=new Map,rkt=new WeakMap;let nkt=Promise.resolve(),ikt=null,lIn=1;function uIn(){return typeof WebGLRenderingContext<"u"&&typeof navigator<"u"&&!navigator.userAgent.toLowerCase().includes("jsdom")}async function fIn(){await Promise.race([e0e(),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 dIn(){return ikt??=fIn(),ikt}function pIn(t){const r=rkt.get(t);if(r!==void 0)return r;const i=lIn++;return rkt.set(t,i),i}function _In(t,r,i,a){const l=Fye.get(t);if(l)return Promise.resolve(l);const d=F_e.get(t);if(d)return d;const _=nkt.then(async()=>{await dIn();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 la(async()=>{const{capturePixiStoryThumbnail:N}=await import("./story-pixi-preview-Cafk1Xbk.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 la(async()=>{const{captureStoryComponentThumbnail:w}=await import("./story-three-preview-ByMTQc8w.js");return{captureStoryComponentThumbnail:w}},__vite__mapDeps([82,3,2,4,81,6,64,11,9,1,8,10]));return k(i.Component,S)});return nkt=_.then(()=>{},()=>{}),F_e.set(t,_),_.then(g=>{Fye.set(t,g),F_e.delete(t)},()=>F_e.delete(t)),_}function mIn({component:t,story:r,previewRevision:i,width:a=128,height:l=96}){const d=r.Component,_=`${t.surface}:${t.path}:${aIn(r.id,r.args)}:${pIn(d)}:${i}:${a}x${l}`,[g,b]=Xe.useState(()=>Fye.get(_)),[S,k]=Xe.useState(!1);return Xe.useEffect(()=>{let w=!1;if(k(!1),b(Fye.get(_)),!!uIn())return _In(_,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 ybe="story:three",vbe="story:isolated",hIn="story:docs";function gIn(t,r){return t.surface==="dom"?!1:r===null||t.surface===r}function yIn({entry:t,previewRevision:r,width:i,height:a}){const l=t.detail;return z.jsx(mIn,{component:t.component,story:l,previewRevision:r,...i===void 0?{}:{width:i},...a===void 0?{}:{height:a}})}const vIn="story",bIn={id:vIn,owner:"./component-content-source",entries(t){const r=H1e(),i=[];for(const a of t.components){if(!gIn(a,t.surface))continue;const l=omn(r,a.name,a.path);l&&i.push({id:`${a.path}:${a.name}`,component:a,detail:l})}return i},subscribe:G1e,Thumbnail:yIn,open(t,r,i){const a=r.detail,l=r.component.surface==="three";FP(l?ybe:vbe,t,l?{modulePath:a.modulePath,storyName:a.name,title:i}:{modulePath:a.modulePath,storyName:a.name})}};function skt(t){return amn(t.name,t.sourcePath)}const AIn={id:"portable-csf",owner:"./component-states",statesFor:(t,r)=>r.surface==="dom"?[]:skt(t).map(i=>({id:i.id,label:i.label})),apply:(t,r,i)=>{const a=skt(t).find(l=>l.id===r);if(a){if(i.surface==="three"){FP(ybe,i.store,{modulePath:a.modulePath,storyName:a.name,title:a.label});return}if(i.surface==="canvas"){FP(vbe,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 SIn(){let t=0,r=!1;const i=g=>{const b=++t;Z_n(),e0e().then(()=>{if(!(r||b!==t))return fmn(ad(),void 0,{deferUndeclared:!0,...g?{changedPaths:g}:{}})})};i();let a=null;const l=KNt(),d=Iw(()=>i()),_=NUr(i);return()=>{r=!0,t+=1,a!==null&&clearTimeout(a),l(),d(),_()}}const EKt="story",f9e=new Set,d9e=new Set;function xIn(t){const r=TWt({modulePath:t.modulePath,title:t.title}).leaf;return r===t.label?r:`${r} · ${t.label}`}function p9e(t){for(const r of H1e())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??xIn({modulePath:r.modulePath,title:i.title,label:i.label})}}return null}function wIn(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(hIn,t,a);const l=oQe({modulePath:i.modulePath,regions:sQe()});return l.medium===void 0?(X_n(i.modulePath,l.reason),null):FP(l.medium==="three"?ybe:vbe,t,a)}function okt(t){ua.warn(`No composed portable story carries the id ${JSON.stringify(t)}, so nothing opened it.`,"editor")}function CIn(){return g9({id:EKt,owner:"./story-opener",open:(t,r)=>{const i=p9e(r);return i?wIn(t,r,i):(r.modulePath?f9e.add(r.modulePath):r.storyId!==void 0&&(d9e.add(r.storyId),nmn()&&okt(r.storyId)),null)},settle:async()=>{await XLr();const t=[...f9e],r=[...d9e];if(f9e.clear(),d9e.clear(),await Promise.all(t.map(i=>cmn(ad(),i))),r.length!==0){await imn();for(const i of r)p9e({storyId:i})||okt(i)}},ready:async(t,r)=>{if(r.mode==="docs")return;const i=p9e(r);if(!(!i||oQe({modulePath:i.modulePath,regions:sQe()}).medium!=="three")&&!await xE(()=>Pw(t)!==null,m9))throw new Error(`The requested Object3D view did not mount for document: ${t}`)}})}const EIn={actions:()=>{if(!DAt(vbe)&&!DAt(ybe))return[];const t=[];for(const r of H1e()){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:EKt,modulePath:r.modulePath,storyName:a.name,title:a.name})})}return t},subscribe:t=>G1e(t)},TIn="packages/editor/src/stories/story-capture-command.ts",uq="capture-story-variants";async function kIn(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 nge("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=cNt(uq,t.camera);if(typeof g=="string")return{ok:!1,error:g};const b=lNt(uq,t.pose);if(typeof b=="string")return{ok:!1,error:b};const{captureProjectStoryVariants:S}=await la(async()=>{const{captureProjectStoryVariants:w}=await import("./story-capture-D0H-H2_b.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 IIn={[uq]:{timeoutMs:12e4,derivedRefresh:"if-content-changed",handle:kIn}};function DIn(){const t=z0n(bIn),r=oIn(AIn),i=CIn(),a=bIt(EIn),l=SIt(TIn,IIn),d=SIn(),_=G1e(()=>{WX()});return()=>{_(),d(),l(),a(),i(),r(),t()}}let _9e=null;const PIn=new Set;function NIn(t){return _9e=t,Lqe(),()=>{_9e===t&&(_9e=null,Lqe())}}function Lqe(){for(const t of PIn)t()}let Mm=null,TKt=0;const jqe=new Set;function OIn(t){return jqe.add(t),()=>jqe.delete(t)}function akt(){return TKt}function FIn(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&&kKt(t,r),TKt+=1;for(const i of jqe)i()}}function kKt(t,r){r.dataset.vgaiPart=t}const Zq=new Map;let IKt=0;const Bqe=new Set;function RIn(t,r){if(r){if(!Zq.delete(t.id))return}else{const i=Zq.get(t.id);if(i?.element===t.element&&i.documentId===t.documentId)return;Zq.set(t.id,{...t})}IKt+=1;for(const i of[...Bqe])i()}function MIn(t){return Bqe.add(t),()=>{Bqe.delete(t)}}function ckt(){return IKt}function CR({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 LIn({children:t}){return z.jsx(z.Fragment,{children:t})}function jIn(){return Mm?vS.createPortal(z.jsx(CR,{center:!0,children:z.jsx(jEn,{})}),Mm.header):null}function BIn(){return null}function $In(){const t=Xe.useRef(null);return Xe.useEffect(()=>{const r=t.current;if(r)return GQt(r),()=>iCn(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(eKt,{})})]})}const the=new Map,$qe=new Set;let qqe=0;function qIn(t,r){if(r){if(the.get(t)===r)return;the.set(t,r)}else if(!the.delete(t))return;qqe++;for(const i of $qe)i()}const rhe=new Map,zqe=new Set;let Uqe=0;function zIn(t,r){if(r){if(rhe.get(t)===r)return;rhe.set(t,r)}else if(!rhe.delete(t))return;Uqe++;for(const i of zqe)i()}function UIn(){return Xe.useSyncExternalStore(jDt,qbt,qbt),Xe.useSyncExternalStore(t=>(zqe.add(t),()=>zqe.delete(t)),()=>Uqe,()=>Uqe),z.jsx(z.Fragment,{children:[...$9e("left"),...$9e("right")].map(t=>{const r=rhe.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 VIn(){return Xe.useSyncExternalStore(m0e,IAt,IAt),Xe.useSyncExternalStore(t=>($qe.add(t),()=>$qe.delete(t)),()=>qqe,()=>qqe),z.jsx(z.Fragment,{children:gE().map(t=>{const r=the.get(t.id);return r?z.jsx(Xe.Fragment,{children:vS.createPortal(z.jsx(CR,{children:z.jsx(qEn,{utility:t})}),r)},t.id):null})})}function JIn({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(CR,{children:[z.jsx(yQt,{descriptor:t,viewId:r,active:l,chrome:!t.area}),d&&z.jsx($wn,{})]}),_)}let DKt=!0;function WIn({arrangement:t,immersivePlay:r}){const i=D0();iIn(i);const a=nKe(i);Xe.useLayoutEffect(()=>{DKt=a.column},[a.column]);const l=Zq.get(Q9e()??"")?.element??Mm?.center;Xe.useLayoutEffect(()=>{if(!l)return;const k=()=>fTt({x:0,y:0,width:l.clientWidth,height:l.clientHeight}),w=new ResizeObserver(k);return w.observe(l),k(),()=>{w.disconnect(),fTt(null)}},[l]),Xe.useSyncExternalStore(i.subscribe,i.getShellSnapshot??i.getSnapshot),Xe.useSyncExternalStore(Aw,Ab,Ab),Xe.useSyncExternalStore(MIn,ckt,ckt),Xe.useSyncExternalStore(OIn,akt,akt),Xe.useLayoutEffect(()=>{const k=z7r({...t?{arrangement:t}:{},...r===void 0?{}:{immersivePlay:r},playUtilities:[]});return t&&CS(t.id),vRr(),k},[t,r]);const d=i.playState!=="stopped",_=Xe.useSyncExternalStore(Cee,P8).play?.keepPanelsVisible;if(Xe.useEffect(()=>{Lkn(d,_Kt())},[d,r,_]),Xe.useEffect(()=>CKt(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:[...Zq.values()].map(({id:k,documentId:w,element:N})=>({id:k,documentId:w,visible:!!N}))},z.jsxs(z.Fragment,{children:[[...Zq.values()].map(k=>{const w=b.find(N=>N.descriptor.id===k.documentId)?.descriptor;return w?z.jsx(JIn,{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(CR,{children:z.jsx("div",{className:"vgai-vscode-empty",children:"No document open"})}),Mm.center),Mm.outliner&&vS.createPortal(z.jsx(CR,{children:z.jsx($In,{})}),Mm.outliner),Mm.properties&&a.column&&vS.createPortal(z.jsx(CR,{children:z.jsx(cKe,{})}),Mm.properties),Mm.content&&vS.createPortal(z.jsx(CR,{children:z.jsx(akn,{kind:"assets"})}),Mm.content),z.jsx(VIn,{}),z.jsx(UIn,{})]})}async function HIn(t){Mm=t;for(const[G,ee]of Object.entries(t))ee&&kKt(G,ee);t.chromeRoot.id="editor-chrome-root",hMr({Frame:LIn,Header:jIn,Footer:BIn,Workspace:WIn,Document:pSn}),lkn(),Byn();const r=Exn();r&&wxn(r,Date.now())&&ua.warn(Sxn(r,Date.now()),"editor"),sIn(),GLr(),Vkn(),DIn(),await Promise.all([G3t(),JRr()]),o9r(t.chromeRoot),t.chromeRoot.classList.toggle("vgai-native-menus",$ye()?.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),Vqe.createRoot(i).render(z.jsx(Uxn,{}));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:hKe,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?dRr().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=pRr(G);return()=>{ee(),xe()}},activate:(G,ee)=>{ee?YOr(G,ee):Sb(G)},close:G=>{if(K8(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)=>RIn(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:()=>[...h7r()],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:()=>aU(),notify:G=>{fv().notify(G)},subscribe:G=>{const ee=u0e(G),xe=xPt(G);return()=>{ee(),xe()}},report:a.report},b={list:()=>zyn().map(G=>({id:G.id,label:G.label,category:G.category})),invoke:G=>Vyn(G),subscribe:G=>Uyn(G),setPaletteOpener:G=>qyn(G),setCommandExecutor:G=>Jyn(G),report:a.report},S={setDelegate:G=>FFr(G?{show:G}:null)},k={list:()=>b4t().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)=>S4t(G,ee,xe),subscribe:G=>A4t(G)},w={list:()=>gE().map((G,ee)=>({id:G.id,title:G.title,order:G.order??ee})),subscribe:G=>m0e(G),offerBody:(G,ee)=>qIn(G,ee)};let N=!0,P=null,j=null;NIn(()=>N);const J={setActiveStaticPanel:G=>CAt(RQe.find(ee=>ee.kind===G)?.kind??null),focusCompactInspector:()=>{if(DKt)return!1;const G=Mm?.center.querySelector('[data-testid="compact-inspector-card"]');return G?(G.tabIndex=-1,G.focus(),CAt("inspector"),!0):!1},setPaneActive:G=>{N!==G&&(N=G,Lqe())},setImmersive:G=>{P?.(),P=null,!(!G||!Mm)&&(P=Ckn({root:Mm.chromeRoot,hideChrome:()=>G.enter(),showChrome:()=>G.exit()}))},setDockCommands:G=>{j?.(),j=null,G&&(j=J7r({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:Ukn},settings:g,status:{list:()=>["left","right"].flatMap(G=>$9e(G).map((ee,xe)=>({id:ee.id,title:ee.name,align:G,order:ee.order??xe}))),subscribe:G=>jDt(G),offerBody:(G,ee)=>zIn(G,ee)},game:J,offerPart:FIn}}function GIn(t){const r=Object.keys(t.packages);return kIr({id:t.id,packages:r,look:t.look,workspace:t.workspace,nativeMenus:t.nativeMenus}),PPt(r.flatMap(i=>t.packages[i]??[])),{mountVgai:HIn}}const{mountVgai:Z4n}=GIn({id:"editor",packages:{"@volter/editor-blender":TIr},look:"blender",workspace:"model"});export{HDn as $,fvn as A,fo as B,SE as C,Z8 as D,EDn as E,TDn as F,VN as G,U_ as H,Sbn as I,N4n as J,HPn as K,UDn as L,L0e as M,X8 as N,LP as O,E2t as P,svn as Q,wDn as R,xFr as S,Ru as T,X4n as U,dQe as V,FA as W,Omn as X,I_ as Y,ua as Z,la as _,o_ as a,DWt as a$,$2t as a0,q2t as a1,GDn as a2,My as a3,So as a4,aDn as a5,bS as a6,S8 as a7,lDn as a8,wWt as a9,$9r as aA,DDn as aB,KPt as aC,mZ as aD,cDn as aE,XFr as aF,Qkt as aG,s5r as aH,AX as aI,j_n as aJ,ODn as aK,M0e as aL,UDt as aM,W_ as aN,WWt as aO,T3t as aP,CDn as aQ,qY as aR,MPn as aS,LPn as aT,TWt as aU,rmn as aV,imn as aW,DPn as aX,oQe as aY,IWt as aZ,CWt as a_,jPn as aa,H4n as ab,wGt as ac,Jwn as ad,z0e as ae,iMe as af,sz as ag,AMr as ah,NP as ai,Wa as aj,xDn as ak,Ny as al,Eze as am,VR as an,e3n as ao,TX as ap,kDn as aq,r3n as ar,Zh as as,IDn as at,B9r as au,FDn as av,yw as aw,np as ax,HR as ay,ad as az,zDn as b,b8 as b$,z_n as b0,GR as b1,Pgn as b2,sQe as b3,Oee as b4,w5r as b5,sU as b6,uI as b7,ep as b8,e4n as b9,zR as bA,uv as bB,yFr as bC,k_ as bD,y3t as bE,XDn as bF,DOr as bG,pDn as bH,KNt as bI,i3n as bJ,ZDn as bK,SDn as bL,n3n as bM,NIr as bN,nge as bO,Ukt as bP,yee as bQ,wg as bR,jDn as bS,wbn as bT,S4t as bU,h_e as bV,M$e as bW,rI as bX,Ghn as bY,bb as bZ,K1e as b_,Nq as ba,n4n as bb,ph as bc,rf as bd,x8 as be,qye as bf,wze as bg,i0e as bh,Aw as bi,Ab as bj,Pee as bk,MP as bl,Xye as bm,I8 as bn,wm as bo,Pw as bp,E5r as bq,ADr as br,W4n as bs,G2n as bt,O4n as bu,zkt as bv,hE as bw,pee as bx,UHt as by,zPn as bz,mz as c,pUe as c$,k9 as c0,ute as c1,gv as c2,jd as c3,Tu as c4,wbt as c5,uDn as c6,bee as c7,xbt as c8,fDn as c9,I4n as cA,Zbt as cB,iDn as cC,LIr as cD,D4n as cE,gAn as cF,Dze as cG,By as cH,mjr as cI,RDn as cJ,y4n as cK,YMe as cL,hAn as cM,c1n as cN,h4n as cO,l4n as cP,_4n as cQ,p4n as cR,c9 as cS,u4n as cT,w4n as cU,d4n as cV,f4n as cW,m4n as cX,x4n as cY,v4n as cZ,C4n as c_,TNr as ca,kR as cb,JGt as cc,B4t as cd,jA as ce,fAn as cf,JDn as cg,WDn as ch,VDn as ci,zP as cj,z4t as ck,o4n as cl,cAn as cm,s4n as cn,TFe as co,YPt as cp,lSn as cq,jkt as cr,OIr as cs,MIr as ct,JQe as cu,Fkt as cv,P4n as cw,nDn as cx,oDn as cy,sDn as cz,dU as d,t3n as d$,k0 as d0,b4n as d1,A4n as d2,a4n as d3,c4n as d4,g4n as d5,E4n as d6,kQe as d7,S4n as d8,yAn as d9,wZ as dA,DUe as dB,$Dn as dC,BDn as dD,MDn as dE,B4n as dF,F4n as dG,T2n as dH,M4n as dI,L4n as dJ,j4n as dK,fte as dL,jHt as dM,XPn as dN,V9r as dO,Wvn as dP,YPn as dQ,CGt as dR,d1n as dS,Cbn as dT,GPn as dU,QPn as dV,QMe as dW,tme as dX,KMe as dY,NDn as dZ,PDn as d_,T4n as da,k4n as db,yhe as dc,OP as dd,x5r as de,K8 as df,$4t as dg,OPn as dh,RPn as di,njr as dj,Sw as dk,Sb as dl,NPn as dm,PPn as dn,FPn as dp,i4n as dq,ZPn as dr,DGt as ds,iNt as dt,kZ as du,e5r as dv,V4t as dw,zwn as dx,W8 as dy,_Dn as dz,fv as e,LDn as e0,PUe as e1,B2n as e2,BPn as e3,$Pn as e4,Q4n as e5,G4n as e6,q4n as e7,z4n as e8,$4n as e9,RGt as eA,hDn as eB,gDn as eC,bQe as eD,o8 as eE,U8 as eF,Uhn as eG,T_ as eH,SCt as eI,aHt as eJ,Lm as eK,pHt as eL,Fy as eM,Z4n as eN,gb as ea,R4n as eb,U4n as ec,pv as ed,t4n as ee,UPn as ef,VPn as eg,VHt as eh,r4n as ei,Qh as ej,Eq as ek,vDn as el,qPn as em,Y4n as en,W4t as eo,J4n as ep,ADn as eq,yDn as er,mDn as es,bP as et,V4n as eu,dDn as ev,WPn as ew,bDn as ex,K4n as ey,JPn as ez,QDn as f,CE as g,xUe as h,KDn as i,dE as j,q0e as k,Ry as l,uNt as m,KPn as n,Na as o,VUe as p,od as q,YDn as r,Ss as s,Oo as t,D0 as u,pGt as v,sLr as w,jQe as x,I$r as y,uvn as z};
|