@volter/editor 0.5.58 → 0.5.59
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 +259 -259
- package/dist/assets/{AudioViewer-CEfg6soG.js → AudioViewer-C5C4xeUl.js} +1 -1
- package/dist/assets/{EntityModelDocument-rBweka7M.js → EntityModelDocument-DyhU8umO.js} +1 -1
- package/dist/assets/{EnvironmentAssetDocument-VgR_on1P.js → EnvironmentAssetDocument-D_VZ2iFj.js} +1 -1
- package/dist/assets/{GameplaySessionTimeline-B9v8LIxV.js → GameplaySessionTimeline-kIIuhFBI.js} +1 -1
- package/dist/assets/{ImageViewer-CvnifCXj.js → ImageViewer-Crv-yzT_.js} +1 -1
- package/dist/assets/{InspectorObjectPreview-gbDaFcDe.js → InspectorObjectPreview-CO-GVXfu.js} +1 -1
- package/dist/assets/{JsonAssetDocument-B-ze7id8.js → JsonAssetDocument-Dtg2QwPN.js} +1 -1
- package/dist/assets/{ModelAssetDocument-NDTeB7b_.js → ModelAssetDocument-BpZ8SZXe.js} +1 -1
- package/dist/assets/{NonThreeAuthoringBootstrap-D1oTrvVk.js → NonThreeAuthoringBootstrap-0nm5Hl3v.js} +2 -2
- package/dist/assets/{Object3DPreview-DvXwCq08.js → Object3DPreview-dHzSO5Ym.js} +2 -2
- package/dist/assets/{OnlineAssetDetail-GdHcOske.js → OnlineAssetDetail-DAdWXnmZ.js} +2 -2
- package/dist/assets/{SourceAssetViewer-C0qk5wJl.js → SourceAssetViewer-D3m0wF8T.js} +2 -2
- package/dist/assets/{StageHost-BU-t7Wwj.js → StageHost-DD_m8W0k.js} +4 -4
- package/dist/assets/{ToolObject3DPreview-CP6YmA70.js → ToolObject3DPreview-CWdklUZ1.js} +1 -1
- package/dist/assets/{TransientHint-Rw3wxMUO.js → TransientHint-aFFUtbSY.js} +1 -1
- package/dist/assets/{VideoViewer-D8aW7n4N.js → VideoViewer-BhH8aSzx.js} +1 -1
- package/dist/assets/{asset-editor-persistence-COlYs9e4.js → asset-editor-persistence-D5wYXQEL.js} +1 -1
- package/dist/assets/{blender-emscripten-engine-BkrPLmPf.js → blender-emscripten-engine-BhbEQhcb.js} +1 -1
- package/dist/assets/{blender-node-editor.document-DtaO2jAu.js → blender-node-editor.document-D-hrVHmR.js} +1 -1
- package/dist/assets/{blender-outliner-model-CfXIMSXz.js → blender-outliner-model-FscHWpfW.js} +1 -1
- package/dist/assets/{blender-properties-tab-DYiaVS6T.js → blender-properties-tab-Czi3_yYZ.js} +1 -1
- package/dist/assets/blender-runtime-host-C3rVDyG8.js +4 -0
- package/dist/assets/{blender-runtime-skin-CBll8ovN.js → blender-runtime-skin-AJdtKKnf.js} +1 -1
- package/dist/assets/{blender-runtime.document-CStrnPJb.js → blender-runtime.document-JlYY0bb7.js} +1 -1
- package/dist/assets/{blender-timeline.document-WjHuKO96.js → blender-timeline.document-5UN8V20F.js} +1 -1
- package/dist/assets/{blender-uv-editor.document-CsjAI-Lc.js → blender-uv-editor.document-maFJQzgA.js} +1 -1
- package/dist/assets/{blender-version.status-BcaIEqih.js → blender-version.status-CukRH8K3.js} +1 -1
- package/dist/assets/{blender-wali-engine-Dtwixi7B.js → blender-wali-engine-B0Q2w2Be.js} +1 -1
- package/dist/assets/blender.command-CY6QiXxp.js +1 -0
- package/dist/assets/{browserAll-DAbE1efB.js → browserAll-BQIn-DRw.js} +1 -1
- package/dist/assets/{edit-mode-authoring-BBWCwYeE.js → edit-mode-authoring-CWTeROGv.js} +1 -1
- package/dist/assets/{hosted-asset-materialization-CvAt4P7_.js → hosted-asset-materialization-DcthzsYS.js} +1 -1
- package/dist/assets/{index-CY4oDLhJ.js → index-DmtPt6RQ.js} +331 -331
- package/dist/assets/{models.finder-CZNTvr_w.js → models.finder-CrDJ41Cp.js} +1 -1
- package/dist/assets/{product-Dr7coa2h.js → product-CqAh01LU.js} +1 -1
- package/dist/assets/{properties-bone-constraints.inspector-DBAuXqr4.js → properties-bone-constraints.inspector-BPN6BRJV.js} +1 -1
- package/dist/assets/{properties-bone.inspector-C_F8SxhT.js → properties-bone.inspector-C4xD61mX.js} +1 -1
- package/dist/assets/{properties-collection.inspector-C1DLm9eT.js → properties-collection.inspector-BTps8t6G.js} +1 -1
- package/dist/assets/{properties-constraints.inspector-BySUEgAb.js → properties-constraints.inspector-BVvP6esW.js} +1 -1
- package/dist/assets/{properties-data.inspector-BOvrvedq.js → properties-data.inspector-CKKO8DVT.js} +1 -1
- package/dist/assets/{properties-material.inspector-CGJmh_QM.js → properties-material.inspector-BGfT8kHT.js} +1 -1
- package/dist/assets/{properties-modifiers.inspector-xnsQ1ddN.js → properties-modifiers.inspector-DJRANpOY.js} +1 -1
- package/dist/assets/{properties-object.inspector-BOEEbStu.js → properties-object.inspector-CgVfWmw2.js} +1 -1
- package/dist/assets/{properties-output.inspector-NXZnMx4l.js → properties-output.inspector-CBl5xEMZ.js} +1 -1
- package/dist/assets/{properties-particles.inspector-D6D1g8l3.js → properties-particles.inspector-CxVZ09ZY.js} +1 -1
- package/dist/assets/{properties-physics.inspector-DoPfj0an.js → properties-physics.inspector-DmG3i3vY.js} +1 -1
- package/dist/assets/{properties-render.inspector-Cvnkkapn.js → properties-render.inspector-TCoPfEn0.js} +1 -1
- package/dist/assets/{properties-scene.inspector-C2mQ8GLM.js → properties-scene.inspector-BjsTOBiY.js} +1 -1
- package/dist/assets/{properties-texture.inspector-DvASuzXS.js → properties-texture.inspector-D1X9iyVV.js} +1 -1
- package/dist/assets/{properties-view-layer.inspector-FIxWmUI0.js → properties-view-layer.inspector-dXTVxzzk.js} +1 -1
- package/dist/assets/{properties-world.inspector-BfopwUSa.js → properties-world.inspector-CRxJK930.js} +1 -1
- package/dist/assets/{react-story-board-DBO76grK.js → react-story-board-CnCZAhn6.js} +1 -1
- package/dist/assets/{react-three-rapier.esm-Cj4NtDam.js → react-three-rapier.esm-DsJqtzy_.js} +1 -1
- package/dist/assets/{spark.module-BOFvGTtp.js → spark.module-uQlq--TY.js} +1 -1
- package/dist/assets/{stage-keyboard-BsKOZggP.js → stage-keyboard-DzZMNYAr.js} +1 -1
- package/dist/assets/{stage-overlay-set-bQwh25SV.js → stage-overlay-set-D6OOz1L9.js} +1 -1
- package/dist/assets/{stage-presence-markers-CALnBqqb.js → stage-presence-markers-BUaSzKCv.js} +1 -1
- package/dist/assets/{story-capture-BLVE1Bck.js → story-capture-C2ExQiuI.js} +1 -1
- package/dist/assets/{story-pixi-preview-B1LxWTHx.js → story-pixi-preview-C6n-a2_M.js} +1 -1
- package/dist/assets/{story-three-preview-CsjJKTcf.js → story-three-preview-BazrPMDu.js} +2 -2
- package/dist/assets/{webworkerAll-dq7Pw9V8.js → webworkerAll-FJN9IDir.js} +1 -1
- package/dist/assets/worker-CBvBkaXr.js +2 -0
- package/dist/assets/{world-documents-PX5fRvVn.js → world-documents-B6usBw3s.js} +1 -1
- package/dist-node/cli.js +13 -7
- package/package.json +7 -7
- package/dist/assets/blender-runtime-host-DGe1KLVZ.js +0 -4
- package/dist/assets/blender.command-B9Qf17Yr.js +0 -1
- package/dist/assets/worker-29OHwCKe.js +0 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a0 as QQ,g as cB,Z as JC,ad as kB,a as OA,V as F,ae as RB,W as BQ,i as CQ,j as nI,v as sI,af as Hg,Q as Z,x as FA,K as lI,ag as BA,u as v,k as vQ,$ as Ww,ah as UC,p as jw,L as gC,ai as nC,aj as eC,ak as zQ,al as HC,am as EQ,an as LC,ab as iQ,ao as FB,h as og,d as YA,c as gI,ap as dg,aq as RQ,ar as pA,as as Lg,at as YC,au as QC,av as Yg,z as vw,I as zw,aw as _w,F as $w,ax as As,ay as Is,az as gs,l as Qs,aA as FQ,aa as Bs,a1 as Cs,y as Es}from"./three.module-BynznMJN.js";import{I as SB}from"./index-
|
|
1
|
+
import{a0 as QQ,g as cB,Z as JC,ad as kB,a as OA,V as F,ae as RB,W as BQ,i as CQ,j as nI,v as sI,af as Hg,Q as Z,x as FA,K as lI,ag as BA,u as v,k as vQ,$ as Ww,ah as UC,p as jw,L as gC,ai as nC,aj as eC,ak as zQ,al as HC,am as EQ,an as LC,ab as iQ,ao as FB,h as og,d as YA,c as gI,ap as dg,aq as RQ,ar as pA,as as Lg,at as YC,au as QC,av as Yg,z as vw,I as zw,aw as _w,F as $w,ax as As,ay as Is,az as gs,l as Qs,aA as FQ,aa as Bs,a1 as Cs,y as Es}from"./three.module-BynznMJN.js";import{I as SB}from"./index-DmtPt6RQ.js";import"./index-DaQZGF7d.js";import"./_commonjsHelpers-D6-XlEtG.js";import"./index-D_NuPfjr.js";import"./jsx-runtime-DPjLkJKQ.js";import"./index-CtzuWnCS.js";import"./index-CinJrH5C.js";import"./index-D2LwEE0L.js";import"./client-DNXj_opT.js";class _Q extends LC{constructor(A,I){super(),this.ordering=A,this.setAttribute("position",new iQ(is,3)),this.setIndex(new iQ(Ds,1)),this._maxInstanceCount=A.length,this.instanceCount=I,this.attribute=new Is(A,1,!1,1),this.attribute.setUsage(gs),this.setAttribute("splatIndex",this.attribute)}update(A,I){this.ordering=A,this.attribute.array=A,this.instanceCount=I,this.attribute.addUpdateRange(0,I),this.attribute.needsUpdate=!0}}const is=new Float32Array([-1,-1,0,1,-1,0,1,1,0,-1,1,0]),Ds=new Uint16Array([0,1,2,0,2,3]),rC=`(function() {
|
|
2
2
|
"use strict";
|
|
3
3
|
class CsplatArray {
|
|
4
4
|
static __wrap(ptr) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as o}from"./index-DaQZGF7d.js";import{J as t}from"./index-
|
|
1
|
+
import{r as o}from"./index-DaQZGF7d.js";import{J as t}from"./index-DmtPt6RQ.js";import"./_commonjsHelpers-D6-XlEtG.js";import"./index-D_NuPfjr.js";import"./jsx-runtime-DPjLkJKQ.js";import"./index-CtzuWnCS.js";import"./index-CinJrH5C.js";import"./index-D2LwEE0L.js";import"./client-DNXj_opT.js";import"./three.module-BynznMJN.js";function v({stage:r}){return o.useEffect(()=>t(r.store,r.viewport,r.canvas),[r.store,r.viewport,r.canvas]),null}export{v as StageKeyboardBinding};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e}from"./jsx-runtime-DPjLkJKQ.js";import{r}from"./index-DaQZGF7d.js";import{b5 as C,T as d,b6 as I,b7 as E,b8 as z,b9 as O,ba as y,t as k,bb as $,bc as f,bd as j,a4 as w,be as N,bf as U,bg as G,bh as W,B as m,bi as V,bj as F,bk as P,bl as B,bm as L,bn as M,bo as K,bp as _,bq as q,br as Z,bs as J,bt as Q,bu as X,bv as Y,bw as ee,bx as te,by as se,bz as re}from"./index-
|
|
1
|
+
import{a as e}from"./jsx-runtime-DPjLkJKQ.js";import{r}from"./index-DaQZGF7d.js";import{b5 as C,T as d,b6 as I,b7 as E,b8 as z,b9 as O,ba as y,t as k,bb as $,bc as f,bd as j,a4 as w,be as N,bf as U,bg as G,bh as W,B as m,bi as V,bj as F,bk as P,bl as B,bm as L,bn as M,bo as K,bp as _,bq as q,br as Z,bs as J,bt as Q,bu as X,bv as Y,bw as ee,bx as te,by as se,bz as re}from"./index-DmtPt6RQ.js";import"./index-CtzuWnCS.js";import"./index-D2LwEE0L.js";import{s as A,o as b}from"./StageHost-DD_m8W0k.js";import{T as ne}from"./TransientHint-aFFUtbSY.js";import"./_commonjsHelpers-D6-XlEtG.js";import"./index-D_NuPfjr.js";import"./client-DNXj_opT.js";import"./index-CinJrH5C.js";import"./three.module-BynznMJN.js";import"./clip-planes-CnAI6DZn.js";import"./OrbitControls-BHxt84w6.js";import"./LineSegments2-vfeDUBfs.js";import"./viewport-pick-context-DkawXbEi.js";import"./editor-presentation-activity-C7SNSmTd.js";function H(){const t=z("viewport.frameSelection");return`Orbit: right-drag (or Alt+drag) · Pan: middle-drag · Zoom: wheel${t?` · ${t}: frame selection`:""}`}function R(){const t=z("viewport.toggleSnap");return`Trackpad: two-finger pan · pinch zoom · Alt+drag orbit${t?` · Snap: ${t}`:""}`}function D(){r.useSyncExternalStore(I,E,E)}function oe(){const t=r.useSyncExternalStore(A,b,b);return D(),t?null:e.jsxs(C,{variant:"overlay",border:!0,className:"vgai-viewport-controls-hint vgai-chrome-island vgai-glass-island","data-island-scale":"compact",style:{pointerEvents:"none"},children:[e.jsx(d,{variant:"code","data-testid":"viewport-controls-hint",children:H()}),e.jsx(d,{variant:"code",children:R()})]})}function g(t){return t.toFixed(2)}function ie(){const t=O(),[n,s]=r.useState({x:0,y:0,z:0}),[o,a]=r.useState({x:0,y:0,z:0}),i=r.useRef(0),c=r.useSyncExternalStore(A,b,b);return D(),r.useEffect(()=>{function p(){const u=t.cameraPosition,h=t.cameraTarget;s(l=>l.x!==u.x||l.y!==u.y||l.z!==u.z?{x:u.x,y:u.y,z:u.z}:l),a(l=>l.x!==h.x||l.y!==h.y||l.z!==h.z?{x:h.x,y:h.y,z:h.z}:l),i.current=requestAnimationFrame(p)}return i.current=requestAnimationFrame(p),()=>cancelAnimationFrame(i.current)},[t]),e.jsxs(C,{variant:"overlay",border:!0,className:"vgai-camera-info vgai-chrome-island vgai-glass-island","data-island-scale":"compact",children:[e.jsxs(y,{gap:8,align:"center",style:{whiteSpace:"nowrap"},children:[e.jsxs(d,{variant:"code",children:["Pos ",g(n.x)," ",g(n.y)," ",g(n.z)]}),e.jsxs(d,{variant:"code",children:["Target ",g(o.x)," ",g(o.y)," ",g(o.z)]})]}),!c&&e.jsxs(e.Fragment,{children:[e.jsx(d,{variant:"code","data-testid":"viewport-controls-hint",style:{whiteSpace:"nowrap"},children:H()}),e.jsx(d,{variant:"code",style:{whiteSpace:"nowrap"},children:R()})]})]})}function ae(){const t=O(),[,n]=r.useState(0),s=$();return r.useEffect(()=>{const o=setInterval(()=>n(a=>a+1),200);return()=>clearInterval(o)},[]),e.jsxs("div",{className:"vgai-hud-overlay vgai-chrome-island vgai-glass-island","data-island-scale":"compact","data-hud-border":"strong",style:{position:"absolute",top:"var(--vgai-viewport-overlay-hud-top, 48px)",right:8,padding:"6px 10px",pointerEvents:"auto",fontSize:"var(--vgai-font-base)",color:k.content.primary,fontFamily:k.typography.mono,lineHeight:"16px"},children:[e.jsxs("div",{children:["FPS: ",t.fps.toFixed(0)]}),e.jsxs("div",{children:["Draw: ",t.drawCalls]}),e.jsxs("div",{children:["Tris: ",t.triangles.toLocaleString()]}),e.jsxs("div",{children:["Frame: ",t.frameTime.toFixed(1),"ms"]}),s!==null&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:["Heap: ",s.heapUsedMB===null?"n/a":`${s.heapUsedMB.toFixed(0)}MB`,s.heapLimitMB===null?"":` / ${s.heapLimitMB.toFixed(0)}MB`]}),e.jsxs("div",{children:["Mount epochs: ",s.mountEpochs]}),e.jsxs("div",{children:["Canvas: ",s.canvasMB.toFixed(1),"MB ×",s.canvases]}),s.textures!==void 0&&e.jsxs("div",{children:["GPU: ",s.textures," tex, ",s.geometries??0," geo",s.programs===void 0?"":`, ${s.programs} prog`]})]})]})}let x={projection:"perspective"};const S=new Set;function T(){return x}function ce(t){return S.add(t),()=>S.delete(t)}function v(t){if(x.projection!==t){x={...x,projection:t};for(const n of S)n()}}function le({store:t}){const n=r.useSyncExternalStore(ce,T,T),[s,o]=r.useState(!1),a=r.useRef(null);r.useEffect(()=>{if(!s)return;const c=p=>{a.current?.contains(p.target)||o(!1)};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[s]);const i=c=>{v("orthographic"),t.setViewPreset(c)};return e.jsxs("div",{ref:a,className:"vgai-viewport-popover-anchor",children:[e.jsx(f,{text:n.projection==="perspective"?"Perspective":"Orthographic",children:e.jsx(j,{"aria-label":"Viewport views","aria-expanded":s,size:"comfortable",onClick:()=>o(c=>!c),children:e.jsx(w,{icon:s?N:U,size:"md"})})}),s?e.jsx(G,{style:{minWidth:230},children:e.jsxs(W,{gap:3,children:[e.jsx(d,{variant:"caption",tone:"muted",children:"Projection"}),e.jsxs(y,{gap:1,children:[e.jsx(m,{size:"compact",variant:n.projection==="perspective"?"primary":"ghost",onClick:()=>v("perspective"),children:"Perspective"}),e.jsx(m,{size:"compact",variant:n.projection==="orthographic"?"primary":"ghost",onClick:()=>v("orthographic"),children:"Orthographic"})]}),e.jsx(d,{variant:"caption",tone:"muted",children:"Axis View"}),e.jsxs(y,{gap:1,children:[e.jsx(m,{size:"compact",variant:"ghost",onClick:()=>i("top"),children:"Top"}),e.jsx(m,{size:"compact",variant:"ghost",onClick:()=>i("front"),children:"Front"}),e.jsx(m,{size:"compact",variant:"ghost",onClick:()=>i("right"),children:"Right"})]})]})}):null]})}function de({store:t,documentId:n}){r.useSyncExternalStore(t.subscribe,t.getSnapshot),r.useSyncExternalStore(V,F),r.useSyncExternalStore(P,B),r.useSyncExternalStore(L,M);const{adapter:s}=K(t),o=_(n);r.useSyncExternalStore(o?.subscribe??pe,o?.getSnapshot??ue);const a=o?o.presentation().grid:t.showGrid;return e.jsxs(q,{label:"Viewport display",className:"vgai-viewport-toolbar vgai-viewport-toolbar-right",children:[e.jsx(f,{text:`Grid: ${a?"On":"Off"}`,children:e.jsx(j,{"aria-label":"Toggle grid","aria-pressed":a,size:"comfortable",onClick:()=>o?o.setGrid(!a):t.toggleGrid(),children:e.jsx(w,{icon:Z,size:"md"})})}),e.jsx(ge,{store:t}),e.jsx(J,{mode:t.shadingMode,onChange:i=>t.setShadingMode(i)}),e.jsx(le,{store:t}),e.jsx(he,{adapter:s,store:t})]})}const pe=()=>()=>{},ue=()=>0,he=r.memo(function({adapter:n,store:s}){const[,o]=r.useReducer(i=>i+1,0);r.useEffect(()=>n.subscribe?.(o),[n]);const a=r.useMemo(()=>X(n),[n,s.contentVersion]);return a===0?null:e.jsx(f,{text:`Open Light Explorer · ${a} ${a===1?"light":"lights"}`,children:e.jsx(j,{"aria-label":"Open Light Explorer",size:"comfortable",onClick:()=>ee(te.lightExplorer.id),children:e.jsx(w,{icon:Y,size:"md"})})})});function ge({store:t}){const n=[{key:"bounds",label:"Bounds"},{key:"lights",label:"Lights"},{key:"cameras",label:"Cameras"},{key:"colliders",label:"Colliders"},{key:"joints",label:"Joints"},{key:"particles",label:"Particle Emitters"},{key:"lod",label:"LOD"},{key:"audio",label:"Audio"},{key:"splines",label:"Splines"},{key:"navmesh",label:"NavMesh"},{key:"constraints",label:"Constraints"},{key:"reflectionProbes",label:"Reflection Probes"},{key:"triggerVolumes",label:"Trigger Volumes"},{key:"skeletons",label:"Skeletons"},{key:"weights",label:"Weights"}];return e.jsx(Q,{label:"Helpers",master:{enabled:t.showHelpers,onToggle:()=>t.toggleHelpers()},choices:n.map(s=>({id:s.key,label:s.label,enabled:t.helperVisibility[s.key],onToggle:()=>t.toggleHelperType(s.key)}))})}function Pe({store:t,documentId:n,stage:s,active:o,chrome:a}){const i=s?.store??t;r.useSyncExternalStore(t.subscribe,t.getShellSnapshot??t.getSnapshot),r.useSyncExternalStore(i.subscribe,i.getShellSnapshot??i.getSnapshot),r.useSyncExternalStore(P,B),r.useSyncExternalStore(L,M),r.useSyncExternalStore(V,F);const c=se(t,n,a),p=re(c);return e.jsxs(e.Fragment,{children:[p?e.jsxs(e.Fragment,{children:[e.jsx(de,{store:i,documentId:n}),e.jsx(ie,{})]}):null,!p&&c.surface==="three"?e.jsx(oe,{}):null,c.surface==="three"&&i.showStats&&e.jsx(ae,{}),o?e.jsx(ne,{}):null]})}export{Pe as StageOverlaySet};
|
package/dist/assets/{stage-presence-markers-CALnBqqb.js → stage-presence-markers-BUaSzKCv.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./jsx-runtime-DPjLkJKQ.js";import"./index-DaQZGF7d.js";import"./index-CtzuWnCS.js";import{ab as H,ac as B,Y as W,ad as N,ae as k,af as J,ag as U}from"./index-
|
|
1
|
+
import"./jsx-runtime-DPjLkJKQ.js";import"./index-DaQZGF7d.js";import"./index-CtzuWnCS.js";import{ab as H,ac as B,Y as W,ad as N,ae as k,af as J,ag as U}from"./index-DmtPt6RQ.js";import"./index-D2LwEE0L.js";import{au as K,a as ee,k as te,bb as ne,d as P,e as oe,i as re,bc as ie,bd as ae,Q as se,V as I,av as ce,be as le,aC as de,aa as pe,aD as ue,b7 as fe}from"./three.module-BynznMJN.js";import"./_commonjsHelpers-D6-XlEtG.js";import"./index-D_NuPfjr.js";import"./index-CinJrH5C.js";import"./client-DNXj_opT.js";let v={document:null,file:null,oid:null,selection:[],camera:null,gesture:null},w="",R=!1,S=!1;const ge=100;function j(){R||S||(R=!0,globalThis.setTimeout(()=>{R=!1;const e=JSON.stringify(v);e!==w&&(w=e,S=!0,H(v).catch(()=>{w=""}).finally(()=>{S=!1,JSON.stringify(v)!==w&&j()}))},ge))}function C(e){v={...v,...e},j()}function me(){const e=document.querySelector(`.${J}`);return(e?getComputedStyle(e).getPropertyValue("--vgai-content-on-accent").trim():"")||U.color.content.onAccent}function Q(e,r){const n=e.image,o=n.getContext("2d");if(!o)return;o.clearRect(0,0,n.width,n.height),o.fillStyle=r.color,o.beginPath(),o.roundRect(2,2,n.width-4,n.height-4,16),o.fill(),o.fillStyle=me(),o.font="600 22px system-ui, sans-serif",o.textAlign="center",o.textBaseline="middle";const c=r.kind==="agent"?" · AI":"";o.fillText(`${r.displayName}${c}`,n.width/2,n.height/2,238),e.needsUpdate=!0}function ye(e){const r=new te(50,1,.2,1.4),n=new ne(r),o=new P(e.color);n.setColors(o,o,o,o,o),n.name=`Collaboration camera: ${e.displayName}`,n.userData.editorOnly=!0;const c=document.createElement("canvas");c.width=256,c.height=64;const p=new oe(c);p.colorSpace=re;const d=new ie(new ae({map:p,depthTest:!1,transparent:!0}));return d.name=`Collaboration label: ${e.displayName}`,d.userData.editorOnly=!0,d.scale.set(1.8,.45,1),d.renderOrder=1e4,Q(p,e),{camera:r,helper:n,label:d,texture:p,signature:"",targetPosition:new I,targetQuaternion:new se,targetFov:50,initialized:!1}}function he(e,r){const n=r.presence.camera;if(!n)return;e.targetPosition.set(n.x,n.y,n.z);const o=new ce;o.position.copy(e.targetPosition),o.lookAt(n.targetX,n.targetY,n.targetZ),e.targetQuaternion.copy(o.quaternion),e.targetFov=n.fov,e.initialized||(e.initialized=!0,e.camera.position.copy(e.targetPosition),e.camera.quaternion.copy(e.targetQuaternion),e.camera.fov=e.targetFov);const c=`${r.displayName}|${r.kind}|${r.color}|${r.status}`;c!==e.signature&&(e.signature=c,Q(e.texture,r))}function ve(e,r){const n=1-Math.exp(-12*Math.max(0,r));e.camera.position.lerp(e.targetPosition,n),e.camera.quaternion.slerp(e.targetQuaternion,n),e.camera.fov+=(e.targetFov-e.camera.fov)*n,e.camera.updateProjectionMatrix(),e.camera.updateMatrixWorld(!0),e.helper.update(),e.label.position.copy(e.camera.position),e.label.position.y+=.55}function Z(e){e.helper.removeFromParent(),e.label.removeFromParent(),e.helper.dispose(),e.texture.dispose(),e.label.material.dispose()}function be(e,r){const n=B(e),o=new le(n,new P(r));return o.name=`Collaboration selection: ${e.name||e.uuid}`,o.userData.editorOnly=!0,o.renderOrder=9999,o.material.depthTest=!1,{object:e,box:n,helper:o}}function M(e){e.helper.removeFromParent(),e.helper.geometry.dispose(),e.helper.material.dispose()}function we(e){if(!e||e.type!=="pointer-ray"||!["originX","originY","originZ","directionX","directionY","directionZ","length"].every(p=>typeof e[p]=="number"&&Number.isFinite(e[p])))return null;const n=new I(e.originX,e.originY,e.originZ),o=new I(e.directionX,e.directionY,e.directionZ),c=Math.min(1e3,Math.max(.1,e.length));return o.lengthSq()<1e-6?null:{origin:n,end:n.clone().add(o.normalize().multiplyScalar(c))}}function Oe(e){const{scene:r,store:n,documentId:o,container:c,canvas:p,viewport:d,readVisibleCameraPose:E}=e,y=()=>W()===o,b=()=>{if(!y())return;const i=E();C({camera:{x:i.position.x,y:i.position.y,z:i.position.z,targetX:i.target.x,targetY:i.target.y,targetZ:i.target.z,fov:i.fov}})};d.orbitControls.addEventListener("change",b);let x=!1;const z=i=>{const s=i.value===!0;x=s,y()&&C({gesture:s?{type:"transform",selection:[...n.selectedEntityIds]}:null})};d.transformControls.addEventListener("dragging-changed",z);const T=new K,L=new ee,F=i=>{if(x||i.buttons!==0||!y())return;const s=p.getBoundingClientRect();if(s.width<=0||s.height<=0)return;L.set((i.clientX-s.left)/s.width*2-1,-((i.clientY-s.top)/s.height)*2+1),T.setFromCamera(L,d.renderCamera);const l=T.ray,m=E();C({gesture:{type:"pointer-ray",originX:l.origin.x,originY:l.origin.y,originZ:l.origin.z,directionX:l.direction.x,directionY:l.direction.y,directionZ:l.direction.z,length:Math.max(2,m.position.distanceTo(m.target))}})},O=()=>{!x&&y()&&C({gesture:null})};c.addEventListener("pointermove",F),c.addEventListener("pointerleave",O),b();const f=new Map,u=new Map,g=new Map;let Y=-1;const V=()=>{const i=N();if(!i||i.sequence===Y)return;Y=i.sequence;const s=i.participants.filter(t=>t.participantId!==k&&t.presence.document===o),l=s.filter(t=>t.presence.camera),m=new Set(l.map(t=>t.participantId));for(const[t,a]of f)m.has(t)||(Z(a),f.delete(t));for(const t of l){let a=f.get(t.participantId);a||(a=ye(t),f.set(t.participantId,a),r.add(a.helper,a.label)),he(a,t)}const D=s.flatMap(t=>t.presence.selection.slice(0,20).map(a=>({key:`${t.participantId}:${a}`,objectId:a,color:t.color}))),_=new Set(D.map(t=>t.key));for(const[t,a]of u)_.has(t)||(M(a),u.delete(t));for(const t of D){const a=n.objectMap.get(t.objectId),h=u.get(t.key);if(!a){h&&(M(h),u.delete(t.key));continue}if(h?.object===a)continue;h&&M(h);const $=be(a,t.color);u.set(t.key,$),r.add($.helper)}const X=s.flatMap(t=>{const a=we(t.presence.gesture);return a?[{participantId:t.participantId,color:t.color,ray:a}]:[]}),G=new Set(X.map(t=>t.participantId));for(const[t,a]of g)G.has(t)||(q(a),g.delete(t));for(const t of X){let a=g.get(t.participantId);a||(a=Ce(t.color),g.set(t.participantId,a),r.add(a.line)),Me(a,t.ray)}},A=i=>{if(!y())return;const s=i.detail?.participantId;if(typeof s!="string")return;const l=N()?.participants.find(m=>m.participantId===s)?.presence.camera;l&&n.setCameraPose({x:l.x,y:l.y,z:l.z},{x:l.targetX,y:l.targetY,z:l.targetZ},l.fov)};return window.addEventListener("editor:collaboration-join",A),{reportCamera:b,syncMarkers:i=>{V();for(const s of f.values())ve(s,i);for(const s of u.values())B(s.object,s.box)},dispose:()=>{d.orbitControls.removeEventListener("change",b),d.transformControls.removeEventListener("dragging-changed",z),c.removeEventListener("pointermove",F),c.removeEventListener("pointerleave",O),window.removeEventListener("editor:collaboration-join",A);for(const i of f.values())Z(i);f.clear();for(const i of u.values())M(i);u.clear();for(const i of g.values())q(i);g.clear()}}}function Ce(e){const r=new de(new Float32Array(6),3),n=new pe;n.setAttribute("position",r);const o=new ue({color:new P(e),depthTest:!1,transparent:!0,opacity:.9}),c=new fe(n,o);return c.name="Collaboration pointer ray",c.userData.editorOnly=!0,c.renderOrder=10001,{line:c,positions:r}}function Me(e,r){e.positions.setXYZ(0,r.origin.x,r.origin.y,r.origin.z),e.positions.setXYZ(1,r.end.x,r.end.y,r.end.z),e.positions.needsUpdate=!0,e.line.geometry.computeBoundingSphere()}function q(e){e.line.removeFromParent(),e.line.geometry.dispose(),e.line.material.dispose()}export{Oe as bindStagePresenceMarkers};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as E}from"./react-story-board-DBO76grK.js";import{aS as I,a9 as M,t as $,aT as R,az as T,aU as D,aV as k,aW as L,aX as O,aY as N,aZ as U,a_ as W,a$ as A,b0 as B,aO as j,b1 as F,aa as H,b2 as G,b3 as V}from"./index-CY4oDLhJ.js";import{a as b}from"./jsx-runtime-DPjLkJKQ.js";import{r as _}from"./index-DaQZGF7d.js";import"./index-CtzuWnCS.js";import"./index-D2LwEE0L.js";import{awaitPixiStoryFrame as z}from"./story-pixi-preview-B1LxWTHx.js";import{supportsThreeStoryCapture as q,captureStoryComponentThumbnail as K,isStoryThreeClassificationRefusal as Y}from"./story-three-preview-CsjJKTcf.js";import"./client-DNXj_opT.js";import"./_commonjsHelpers-D6-XlEtG.js";import"./index-D_NuPfjr.js";import"./index-CinJrH5C.js";import"./three.module-BynznMJN.js";import"./story-mount-turn-2IYGgHob.js";import"./events-156d8d12.esm-Dy_KXdhT.js";class Q extends _.Component{state={error:null};static getDerivedStateFromError(t){return{error:t}}componentDidCatch(t,o){console.error(`[stories] ${this.props.modulePath} — story "${this.props.storyName}" crashed while rendering:`,t,o.componentStack)}render(){return this.state.error?b.jsxs("div",{style:{padding:12,fontSize:12,color:$.semantic.danger,maxWidth:640},children:[b.jsxs("div",{style:{fontWeight:600,marginBottom:4},children:["Story crashed: ",b.jsx("code",{children:this.props.modulePath})," — export"," ",b.jsx("code",{children:this.props.storyName})]}),b.jsx("div",{style:{whiteSpace:"pre-wrap"},children:String(this.state.error)})]}):this.props.children}}const x=new WeakMap;async function X(e,t,o,l,i){const n=x.get(e),a=(n?.generation??0)+1;x.set(e,{root:n?.root,generation:a}),I(e);const m=T();m&&await R(m.rootPath),await l.load();const{createRoot:p,flushSync:h}=await M(),f=x.get(e);if(!f||f.generation!==a)return null;const c=n?.root??p(e);return x.set(e,{root:c,generation:a}),h(()=>{c.render(b.jsx(Q,{modulePath:t,storyName:o,children:b.jsx(l,{})}))}),{root:c,unmount:()=>{queueMicrotask(()=>{const s=x.get(e);!s||s.generation!==a||!s.root||(x.delete(e),s.root.unmount())})}}}var Z={mobile1:{name:"Small mobile",styles:{height:"568px",width:"320px"},type:"mobile"},mobile2:{name:"Large mobile",styles:{height:"896px",width:"414px"},type:"mobile"},tablet:{name:"Tablet",styles:{height:"1112px",width:"834px"},type:"tablet"},desktop:{name:"Desktop",styles:{height:"1024px",width:"1280px"},type:"desktop"}};const J=640,tt=400;function et(e,t){return`portable-${e}:${t.map(o=>encodeURIComponent(o)).join("/")}`}function ot(e){const t=new Map,o=[],l=new Map,i=new Map;for(const n of e){const a=D({modulePath:n.modulePath,...n.title?{title:n.title}:{}}),m=[...a.segments,a.leaf];let p=null;for(let c=0;c<m.length;c++){const s=m.slice(0,c+1),g=c===m.length-1,u=et(g?"component":"folder",s);t.has(u)||(t.set(u,{id:u,label:s.at(-1),role:g?"component":"folder",kind:g?"component":"group",typeLabel:g?"Component":c===0?"Category":"Folder",parentId:p,childIds:[],...g?{secondaryLabel:n.modulePath}:{}}),p?t.get(p)?.childIds.push(u):o.push(u)),p=u}const h=p;t.get(h)?.childIds.push(n.id),l.set(n.id,h);const f=i.get(h);f?f.storyIds.push(n.id):i.set(h,{id:h,label:k(a),storyIds:[n.id]})}return{sections:[...i.values()],nodes:[...t.values()],rootIds:o,storyParentIds:l}}function S(e){return e&&typeof e=="object"?e:null}function P(e){if(typeof e!="string")return null;const t=Number.parseFloat(e);return Number.isFinite(t)&&t>0?t:null}function rt(e){const t=S(S(e.viewport)?.options),o={...Z};if(!t)return o;for(const[l,i]of Object.entries(t)){const n=S(i),a=S(n?.styles);!n||!a||typeof n.name!="string"||typeof a.width!="string"||typeof a.height!="string"||(o[l]={name:n.name,styles:{width:a.width,height:a.height},...typeof n.type=="string"?{type:n.type}:{}})}return o}function nt(e){const t=e.viewport;if(typeof t=="string")return{value:t||null,isRotated:!1};const o=S(t);return{value:typeof o?.value=="string"&&o.value?o.value:null,isRotated:o?.isRotated===!0}}function at(e,t,o,l){const i=e.parameters??{},n=e.globals??{},a=i.layout,m=a==="centered"||a==="fullscreen"||a==="padded"?a:"padded",p=rt(i),h=Object.entries(p).flatMap(([d,y])=>{const w=P(y.styles.width),v=P(y.styles.height);return w&&v?[{id:d,label:y.name,width:w,height:v}]:[]}),f=nt(n),c=o===void 0?f.value:o,s=h.find(d=>d.id===c),g=s?.width??t?.width??J,u=s?.height??t?.height??tt,r=l??f.isRotated;return{layout:m,choices:h,selectedViewportId:s?.id??null,locked:e.viewportLocked===!0,rotated:r,width:r?u:g,height:r?g:u}}function st(e,t=ot(e)){return{index:t,resolve:at}}async function Et(e,t){await L();const o=V(),l=O().filter(r=>N({modulePath:r.modulePath,regions:o}).medium==="dom"),i=document.createElement("canvas");i.width=e,i.height=t;const n=i.getContext("2d");if(!n)throw new Error("UI Canvas preview could not create a 2D output context.");if(l.length===0)return i.toDataURL("image/png");const a=st(l),m=T()?.config.resolution,p={width:m?.width??640,height:m?.height??400},h=new Map,f=new Map;for(const r of l){const d=a.resolve(r,p),[y]=await C(r.modulePath,[r],{width:d.width,height:d.height,capture:j,cropToContent:d.layout!=="fullscreen",layout:d.layout,transparent:!0});if(!y)throw new Error(`No preview rendered for ${r.id}.`);const w=new Image;w.src=`data:${y.mimeType};base64,${y.base64}`,await w.decode(),h.set(r.id,w),f.set(r.id,{width:w.naturalWidth,height:w.naturalHeight})}const c=E(l,a.index,r=>f.get(r.id)),s=Math.min(e/c.width,t/c.height),g=(e-c.width*s)/2,u=(t-c.height*s)/2;for(const[r,d]of c.layouts)n.drawImage(h.get(r),g+d.x*s,u+d.y*s,d.width*s,d.height*s);return i.toDataURL("image/png")}const it="#ffffff",ct="#14171c";async function It(e,t){const{modulePath:o,width:l,height:i}=t;if(!e)throw new Error(`No project is open, so '${o}' cannot be loaded. Open the project first.`);const n=await U(e),a=n.find(u=>u.modulePath===o);if(!a)throw new Error(`'${o}' is not a story file of this project. `+(n.length===0?"This project has no *.stories.tsx / *.stories.ts under src/.":`This project's story files are: ${n.map(u=>u.modulePath).join(", ")}.`));await W(await A(e));let m;try{m=await a.load()}catch(u){throw new Error(`'${o}' failed to import — ${u instanceof Error?u.message:String(u)}`)}const p=await B(o,m);if(!p.ok)throw new Error(p.error);const h=lt(o,p.stories,t.story),f=t.capture??j,c=t.captureThree??(q()?(u,r)=>K(u,{...r,...t.camera===void 0?{}:{camera:t.camera},...t.pose===void 0?{}:{pose:t.pose}}):void 0);if((t.camera||t.pose)&&!c)throw new Error(`'${o}': camera/clip parameters need the three capture leg, which this environment cannot provide (no WebGL).`);const s=await C(o,h,{width:l,height:i,capture:f,...c?{captureThree:c}:{},requireThree:!!(t.camera||t.pose)}),g=await ht(s,l,i);return{modulePath:o,width:l,height:i,variants:s,contactSheet:g}}function lt(e,t,o){if(o===void 0)return t;const l=t.find(i=>i.name===o);if(!l)throw new Error(`'${e}' exports no story named '${o}'. It exports: ${t.map(i=>i.name).join(", ")}.`);return[l]}async function C(e,t,o){const{width:l,height:i,capture:n,captureThree:a,requireThree:m,cropToContent:p=!0}=o,h=document.createElement("div");h.setAttribute("style",`position:fixed;left:-20000px;top:0;width:${l}px;height:${i}px;overflow:hidden;contain:strict;pointer-events:none;background:${o.transparent?"transparent":it};`),document.body.appendChild(h);const f=[];try{for(const c of t){if(a){const r=await a(c.Component,{width:l,height:i}).catch(d=>(Y(d)||console.warn(`[story-capture] three mount for '${c.name}' failed — falling back to the DOM leg:`,d instanceof Error?d.stack??d.message:String(d)),null));if(r===null&&m)throw new Error(`story '${c.name}' did not render on the three leg — --azimuth/--elevation/--distance/--clip/--time apply to three (R3F) stories only, and falling back to the DOM leg would silently ignore them. Narrow to a three story with --story <export>, or drop the camera/clip flags.`);if(r!==null){const d=r.indexOf(",");f.push({name:c.name,label:c.label,base64:d>=0?r.slice(d+1):r,mimeType:"image/png"});continue}}const s=document.createElement("div");s.setAttribute("style",`position:relative;width:${l}px;height:${i}px;overflow:hidden;`),o.layout==="padded"&&(s.style.padding="16px"),o.layout==="centered"&&(s.style.display="flex",s.style.alignItems="center",s.style.justifyContent="center"),s.style.boxSizing="border-box",h.replaceChildren(s);let g=[];const u=await H(async r=>{g=r;const d=await X(s,e,c.name,c.Component);return await dt(s),await z(r),d});try{const r=await n(h,{canvasFrame:G(g),cropToContent:p,...o.transparent?{allowTransparent:!0}:{}});f.push({name:c.name,label:c.label,base64:r.base64,mimeType:"image/png"})}finally{u?.unmount(),await new Promise(r=>setTimeout(r,0)),s.remove()}}}finally{h.remove()}return f}async function dt(e,t=10){for(let i=0;i<t&&!(e.childNodes.length>0);i++)await new Promise(n=>setTimeout(n,0));if(e.childNodes.length===0)return;const o=200,l=5e3;await new Promise(i=>{let n=null,a=!1;const m=new MutationObserver(()=>{n!==null&&clearTimeout(n),n=setTimeout(h,o)}),p=setTimeout(h,l);function h(){a||(a=!0,m.disconnect(),n!==null&&clearTimeout(n),clearTimeout(p),i())}m.observe(e,{subtree:!0,childList:!0,attributes:!0,characterData:!0}),n=setTimeout(h,o)})}async function ht(e,t,o,l={}){const i=Math.min(Math.max(1,e.length),Math.max(1,Math.floor(l.columns??2))),n=Math.max(1,Math.ceil(e.length/i)),a=[];for(const r of e){const d=new Image;d.src=`data:${r.mimeType};base64,${r.base64}`,await d.decode(),a.push(d)}const m=Math.max(1,...a.map(r=>r.naturalWidth),a.length?0:t),p=Math.max(1,...a.map(r=>r.naturalHeight),a.length?0:o),h=m*i,f=p*n,c=document.createElement("canvas");c.width=h,c.height=f;const s=c.getContext("2d");if(!s)throw new Error("Unable to create the story variant sheet.");s.fillStyle=ct,s.fillRect(0,0,h,f);for(const[r,d]of e.entries()){const y=r%i*m,w=Math.floor(r/i)*p,v=a[r];s.drawImage(v,y+Math.floor((m-v.naturalWidth)/2),w+Math.floor((p-v.naturalHeight)/2)),l.labels!==!1&&F(s,d.name.toUpperCase(),y,w,m,p)}const g=c.toDataURL("image/png"),u=g.indexOf(",");return{width:h,height:f,base64:u>=0?g.slice(u+1):g,mimeType:"image/png"}}export{Et as captureDomStoryBoardPreview,It as captureProjectStoryVariants,ht as composeVariantSheet,C as renderStoryVariants};
|
|
1
|
+
import{r as E}from"./react-story-board-CnCZAhn6.js";import{aS as I,a9 as M,t as $,aT as R,az as T,aU as D,aV as k,aW as L,aX as O,aY as N,aZ as U,a_ as W,a$ as A,b0 as B,aO as j,b1 as F,aa as H,b2 as G,b3 as V}from"./index-DmtPt6RQ.js";import{a as b}from"./jsx-runtime-DPjLkJKQ.js";import{r as _}from"./index-DaQZGF7d.js";import"./index-CtzuWnCS.js";import"./index-D2LwEE0L.js";import{awaitPixiStoryFrame as z}from"./story-pixi-preview-C6n-a2_M.js";import{supportsThreeStoryCapture as q,captureStoryComponentThumbnail as K,isStoryThreeClassificationRefusal as Y}from"./story-three-preview-BazrPMDu.js";import"./client-DNXj_opT.js";import"./_commonjsHelpers-D6-XlEtG.js";import"./index-D_NuPfjr.js";import"./index-CinJrH5C.js";import"./three.module-BynznMJN.js";import"./story-mount-turn-2IYGgHob.js";import"./events-156d8d12.esm-Dy_KXdhT.js";class Q extends _.Component{state={error:null};static getDerivedStateFromError(t){return{error:t}}componentDidCatch(t,o){console.error(`[stories] ${this.props.modulePath} — story "${this.props.storyName}" crashed while rendering:`,t,o.componentStack)}render(){return this.state.error?b.jsxs("div",{style:{padding:12,fontSize:12,color:$.semantic.danger,maxWidth:640},children:[b.jsxs("div",{style:{fontWeight:600,marginBottom:4},children:["Story crashed: ",b.jsx("code",{children:this.props.modulePath})," — export"," ",b.jsx("code",{children:this.props.storyName})]}),b.jsx("div",{style:{whiteSpace:"pre-wrap"},children:String(this.state.error)})]}):this.props.children}}const x=new WeakMap;async function X(e,t,o,l,i){const n=x.get(e),a=(n?.generation??0)+1;x.set(e,{root:n?.root,generation:a}),I(e);const m=T();m&&await R(m.rootPath),await l.load();const{createRoot:p,flushSync:h}=await M(),f=x.get(e);if(!f||f.generation!==a)return null;const c=n?.root??p(e);return x.set(e,{root:c,generation:a}),h(()=>{c.render(b.jsx(Q,{modulePath:t,storyName:o,children:b.jsx(l,{})}))}),{root:c,unmount:()=>{queueMicrotask(()=>{const s=x.get(e);!s||s.generation!==a||!s.root||(x.delete(e),s.root.unmount())})}}}var Z={mobile1:{name:"Small mobile",styles:{height:"568px",width:"320px"},type:"mobile"},mobile2:{name:"Large mobile",styles:{height:"896px",width:"414px"},type:"mobile"},tablet:{name:"Tablet",styles:{height:"1112px",width:"834px"},type:"tablet"},desktop:{name:"Desktop",styles:{height:"1024px",width:"1280px"},type:"desktop"}};const J=640,tt=400;function et(e,t){return`portable-${e}:${t.map(o=>encodeURIComponent(o)).join("/")}`}function ot(e){const t=new Map,o=[],l=new Map,i=new Map;for(const n of e){const a=D({modulePath:n.modulePath,...n.title?{title:n.title}:{}}),m=[...a.segments,a.leaf];let p=null;for(let c=0;c<m.length;c++){const s=m.slice(0,c+1),g=c===m.length-1,u=et(g?"component":"folder",s);t.has(u)||(t.set(u,{id:u,label:s.at(-1),role:g?"component":"folder",kind:g?"component":"group",typeLabel:g?"Component":c===0?"Category":"Folder",parentId:p,childIds:[],...g?{secondaryLabel:n.modulePath}:{}}),p?t.get(p)?.childIds.push(u):o.push(u)),p=u}const h=p;t.get(h)?.childIds.push(n.id),l.set(n.id,h);const f=i.get(h);f?f.storyIds.push(n.id):i.set(h,{id:h,label:k(a),storyIds:[n.id]})}return{sections:[...i.values()],nodes:[...t.values()],rootIds:o,storyParentIds:l}}function S(e){return e&&typeof e=="object"?e:null}function P(e){if(typeof e!="string")return null;const t=Number.parseFloat(e);return Number.isFinite(t)&&t>0?t:null}function rt(e){const t=S(S(e.viewport)?.options),o={...Z};if(!t)return o;for(const[l,i]of Object.entries(t)){const n=S(i),a=S(n?.styles);!n||!a||typeof n.name!="string"||typeof a.width!="string"||typeof a.height!="string"||(o[l]={name:n.name,styles:{width:a.width,height:a.height},...typeof n.type=="string"?{type:n.type}:{}})}return o}function nt(e){const t=e.viewport;if(typeof t=="string")return{value:t||null,isRotated:!1};const o=S(t);return{value:typeof o?.value=="string"&&o.value?o.value:null,isRotated:o?.isRotated===!0}}function at(e,t,o,l){const i=e.parameters??{},n=e.globals??{},a=i.layout,m=a==="centered"||a==="fullscreen"||a==="padded"?a:"padded",p=rt(i),h=Object.entries(p).flatMap(([d,y])=>{const w=P(y.styles.width),v=P(y.styles.height);return w&&v?[{id:d,label:y.name,width:w,height:v}]:[]}),f=nt(n),c=o===void 0?f.value:o,s=h.find(d=>d.id===c),g=s?.width??t?.width??J,u=s?.height??t?.height??tt,r=l??f.isRotated;return{layout:m,choices:h,selectedViewportId:s?.id??null,locked:e.viewportLocked===!0,rotated:r,width:r?u:g,height:r?g:u}}function st(e,t=ot(e)){return{index:t,resolve:at}}async function Et(e,t){await L();const o=V(),l=O().filter(r=>N({modulePath:r.modulePath,regions:o}).medium==="dom"),i=document.createElement("canvas");i.width=e,i.height=t;const n=i.getContext("2d");if(!n)throw new Error("UI Canvas preview could not create a 2D output context.");if(l.length===0)return i.toDataURL("image/png");const a=st(l),m=T()?.config.resolution,p={width:m?.width??640,height:m?.height??400},h=new Map,f=new Map;for(const r of l){const d=a.resolve(r,p),[y]=await C(r.modulePath,[r],{width:d.width,height:d.height,capture:j,cropToContent:d.layout!=="fullscreen",layout:d.layout,transparent:!0});if(!y)throw new Error(`No preview rendered for ${r.id}.`);const w=new Image;w.src=`data:${y.mimeType};base64,${y.base64}`,await w.decode(),h.set(r.id,w),f.set(r.id,{width:w.naturalWidth,height:w.naturalHeight})}const c=E(l,a.index,r=>f.get(r.id)),s=Math.min(e/c.width,t/c.height),g=(e-c.width*s)/2,u=(t-c.height*s)/2;for(const[r,d]of c.layouts)n.drawImage(h.get(r),g+d.x*s,u+d.y*s,d.width*s,d.height*s);return i.toDataURL("image/png")}const it="#ffffff",ct="#14171c";async function It(e,t){const{modulePath:o,width:l,height:i}=t;if(!e)throw new Error(`No project is open, so '${o}' cannot be loaded. Open the project first.`);const n=await U(e),a=n.find(u=>u.modulePath===o);if(!a)throw new Error(`'${o}' is not a story file of this project. `+(n.length===0?"This project has no *.stories.tsx / *.stories.ts under src/.":`This project's story files are: ${n.map(u=>u.modulePath).join(", ")}.`));await W(await A(e));let m;try{m=await a.load()}catch(u){throw new Error(`'${o}' failed to import — ${u instanceof Error?u.message:String(u)}`)}const p=await B(o,m);if(!p.ok)throw new Error(p.error);const h=lt(o,p.stories,t.story),f=t.capture??j,c=t.captureThree??(q()?(u,r)=>K(u,{...r,...t.camera===void 0?{}:{camera:t.camera},...t.pose===void 0?{}:{pose:t.pose}}):void 0);if((t.camera||t.pose)&&!c)throw new Error(`'${o}': camera/clip parameters need the three capture leg, which this environment cannot provide (no WebGL).`);const s=await C(o,h,{width:l,height:i,capture:f,...c?{captureThree:c}:{},requireThree:!!(t.camera||t.pose)}),g=await ht(s,l,i);return{modulePath:o,width:l,height:i,variants:s,contactSheet:g}}function lt(e,t,o){if(o===void 0)return t;const l=t.find(i=>i.name===o);if(!l)throw new Error(`'${e}' exports no story named '${o}'. It exports: ${t.map(i=>i.name).join(", ")}.`);return[l]}async function C(e,t,o){const{width:l,height:i,capture:n,captureThree:a,requireThree:m,cropToContent:p=!0}=o,h=document.createElement("div");h.setAttribute("style",`position:fixed;left:-20000px;top:0;width:${l}px;height:${i}px;overflow:hidden;contain:strict;pointer-events:none;background:${o.transparent?"transparent":it};`),document.body.appendChild(h);const f=[];try{for(const c of t){if(a){const r=await a(c.Component,{width:l,height:i}).catch(d=>(Y(d)||console.warn(`[story-capture] three mount for '${c.name}' failed — falling back to the DOM leg:`,d instanceof Error?d.stack??d.message:String(d)),null));if(r===null&&m)throw new Error(`story '${c.name}' did not render on the three leg — --azimuth/--elevation/--distance/--clip/--time apply to three (R3F) stories only, and falling back to the DOM leg would silently ignore them. Narrow to a three story with --story <export>, or drop the camera/clip flags.`);if(r!==null){const d=r.indexOf(",");f.push({name:c.name,label:c.label,base64:d>=0?r.slice(d+1):r,mimeType:"image/png"});continue}}const s=document.createElement("div");s.setAttribute("style",`position:relative;width:${l}px;height:${i}px;overflow:hidden;`),o.layout==="padded"&&(s.style.padding="16px"),o.layout==="centered"&&(s.style.display="flex",s.style.alignItems="center",s.style.justifyContent="center"),s.style.boxSizing="border-box",h.replaceChildren(s);let g=[];const u=await H(async r=>{g=r;const d=await X(s,e,c.name,c.Component);return await dt(s),await z(r),d});try{const r=await n(h,{canvasFrame:G(g),cropToContent:p,...o.transparent?{allowTransparent:!0}:{}});f.push({name:c.name,label:c.label,base64:r.base64,mimeType:"image/png"})}finally{u?.unmount(),await new Promise(r=>setTimeout(r,0)),s.remove()}}}finally{h.remove()}return f}async function dt(e,t=10){for(let i=0;i<t&&!(e.childNodes.length>0);i++)await new Promise(n=>setTimeout(n,0));if(e.childNodes.length===0)return;const o=200,l=5e3;await new Promise(i=>{let n=null,a=!1;const m=new MutationObserver(()=>{n!==null&&clearTimeout(n),n=setTimeout(h,o)}),p=setTimeout(h,l);function h(){a||(a=!0,m.disconnect(),n!==null&&clearTimeout(n),clearTimeout(p),i())}m.observe(e,{subtree:!0,childList:!0,attributes:!0,characterData:!0}),n=setTimeout(h,o)})}async function ht(e,t,o,l={}){const i=Math.min(Math.max(1,e.length),Math.max(1,Math.floor(l.columns??2))),n=Math.max(1,Math.ceil(e.length/i)),a=[];for(const r of e){const d=new Image;d.src=`data:${r.mimeType};base64,${r.base64}`,await d.decode(),a.push(d)}const m=Math.max(1,...a.map(r=>r.naturalWidth),a.length?0:t),p=Math.max(1,...a.map(r=>r.naturalHeight),a.length?0:o),h=m*i,f=p*n,c=document.createElement("canvas");c.width=h,c.height=f;const s=c.getContext("2d");if(!s)throw new Error("Unable to create the story variant sheet.");s.fillStyle=ct,s.fillRect(0,0,h,f);for(const[r,d]of e.entries()){const y=r%i*m,w=Math.floor(r/i)*p,v=a[r];s.drawImage(v,y+Math.floor((m-v.naturalWidth)/2),w+Math.floor((p-v.naturalHeight)/2)),l.labels!==!1&&F(s,d.name.toUpperCase(),y,w,m,p)}const g=c.toDataURL("image/png"),u=g.indexOf(",");return{width:h,height:f,base64:u>=0?g.slice(u+1):g,mimeType:"image/png"}}export{Et as captureDomStoryBoardPreview,It as captureProjectStoryVariants,ht as composeVariantSheet,C as renderStoryVariants};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as v}from"./index-DaQZGF7d.js";import{a9 as E,aa as M}from"./index-
|
|
1
|
+
import{r as v}from"./index-DaQZGF7d.js";import{a9 as E,aa as M}from"./index-DmtPt6RQ.js";import{r as T,C as P}from"./story-mount-turn-2IYGgHob.js";import"./_commonjsHelpers-D6-XlEtG.js";import"./index-D_NuPfjr.js";import"./jsx-runtime-DPjLkJKQ.js";import"./index-CtzuWnCS.js";import"./index-CinJrH5C.js";import"./index-D2LwEE0L.js";import"./client-DNXj_opT.js";import"./three.module-BynznMJN.js";function S(t){if(t.children.length===0)return!1;const o=t.getBounds();return o.width>1&&o.height>1}const m=1e4,k=12,I="position:fixed;left:-20000px;top:0;width:512px;height:512px;overflow:hidden;contain:strict;pointer-events:none;visibility:hidden;";function C(t){return T(()=>t(D))}function R(t,o={}){return C(n=>n(t,o))}function _(t){return T(async()=>t.dispose())}async function X(t,o={}){const n=await R(t,o.props??{});try{const i=o.width??128,r=o.height??96;n.app.renderer.render({container:n.stage});const s=n.stage.getBounds(),c=o.layout==="fullscreen",d=8,e=n.app.screen.clone();c||(e.x=s.x-d,e.y=s.y-d,e.width=Math.max(1,s.width+d*2),e.height=Math.max(1,s.height+d*2));const a=i/r;if(!c&&e.width/e.height<a){const l=e.height*a;e.x-=(l-e.width)/2,e.width=l}else if(!c&&e.width/e.height>a){const l=e.width/a;e.y-=(l-e.height)/2,e.height=l}const u=n.app.renderer.background,h=await n.app.renderer.extract.canvas({target:n.stage,frame:e,...c&&u.alpha>0?{clearColor:u.colorRgba}:{}}),w=document.createElement("canvas");w.width=i,w.height=r;const g=w.getContext("2d");if(!g)throw new Error("Canvas story preview could not create a 2D readback context.");const p=Math.min(i/h.width,r/h.height),y=h.width*p,x=h.height*p;return g.drawImage(h,(i-y)/2,(r-x)/2,y,x),w.toDataURL("image/png")}finally{await _(n)}}const f=()=>new Promise(t=>setTimeout(t,0));async function D(t,o={}){typeof t.load=="function"&&await t.load();const n=await E(),i=document.createElement("div");i.setAttribute("style",I),document.body.appendChild(i);let r=null;const s=()=>{r?.unmount(),r=null,i.remove()};try{return await M(async c=>{let d=null;r=n.createRoot(i),r.render(v.createElement(P,{onCaught:h=>{d??=h}},v.createElement(t,o)));for(let h=0;h<k&&!(d||i.querySelector("canvas"));h++)await f();if(d)throw b(d);if(!i.querySelector("canvas"))throw new Error("The story rendered no canvas — it does not mount Pixi content.");const e=Date.now()+m;let a;for(;Date.now()<e;){if(d)throw b(d);if(a??=c[0],a&&S(a.stage))break;await f()}if(!a)throw new Error(`The story rendered a canvas but never initialized a Pixi Application within ${m/1e3}s — it is not a canvas story, or its renderer could not be created here.`);a.stop(),a.ticker.lastTime=0;let u=!1;return{host:i,stage:a.stage,ticker:a.ticker,app:a,dispose(){u||(u=!0,s())}}})}catch(c){throw s(),c}}const O=m;async function Y(t,o=Date.now){if(t.length===0)return;const n=new Set,i=t.map(r=>{const s={postrender:()=>{n.add(r)}};return r.renderer?.runners.postrender.add(s),{app:r,observer:s}});try{const r=o()+O;for(;o()<r;){if(t.every(c=>c.stage!==void 0&&S(c.stage)&&n.has(c)))return;await f()}}finally{for(const{app:r,observer:s}of i)r.renderer?.runners.postrender.remove(s)}}function b(t){return new Error(`mountStoryPixi: the story threw while rendering — it does not mount Pixi content, or its component crashed. Original error: ${t instanceof Error?t.message:String(t)}`,{cause:t})}export{Y as awaitPixiStoryFrame,X as capturePixiStoryThumbnail,_ as disposeStoryPixi,R as mountStoryPixi,C as withPixiStoryMountTurn};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/react-three-rapier.esm-
|
|
2
|
-
import{aJ as B,aK as U,aL as W,aM as z,_ as G}from"./index-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/react-three-rapier.esm-DsJqtzy_.js","assets/index-DmtPt6RQ.js","assets/index-DaQZGF7d.js","assets/_commonjsHelpers-D6-XlEtG.js","assets/index-D_NuPfjr.js","assets/jsx-runtime-DPjLkJKQ.js","assets/index-CtzuWnCS.js","assets/index-CinJrH5C.js","assets/index-D2LwEE0L.js","assets/client-DNXj_opT.js","assets/three.module-BynznMJN.js","assets/index-D2fNXpHa.css","assets/events-156d8d12.esm-Dy_KXdhT.js","assets/BufferGeometryUtils-oP8-Ve4I.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{aJ as B,aK as U,aL as W,aM as z,_ as G}from"./index-DmtPt6RQ.js";import{r as j}from"./index-DaQZGF7d.js";import{r as H,C as $}from"./story-mount-turn-2IYGgHob.js";import{s as q,aW as Q,i as V,br as J}from"./three.module-BynznMJN.js";import{e as K,c as X}from"./events-156d8d12.esm-Dy_KXdhT.js";import"./jsx-runtime-DPjLkJKQ.js";import"./_commonjsHelpers-D6-XlEtG.js";import"./index-CtzuWnCS.js";import"./index-CinJrH5C.js";import"./index-D_NuPfjr.js";import"./index-D2LwEE0L.js";import"./client-DNXj_opT.js";const Y=1/60,Z=6,ee=15,_=1e-4,te=2,ne=10,re=250,oe=4e3;function S(e){e.updateMatrixWorld(!0);const t=[];return e.traverse(n=>{const r=n.matrixWorld.elements;t.push(r[12],r[13],r[14])}),t}function N(e){let t=0;return e.traverse(()=>{t++}),t}function D(e,t){if(e.length!==t.length)return Number.NaN;let n=0;for(let r=0;r<t.length;r+=3){const o=t[r]-e[r],a=t[r+1]-e[r+1],i=t[r+2]-e[r+2],s=Math.sqrt(o*o+a*a+i*i);if(!Number.isFinite(s))return Number.NaN;s>n&&(n=s)}return n}const ie=()=>new Promise(e=>setTimeout(e,0));async function se(e,t,n){const r=n();let o=N(e),a=r,i=!1;for(;n()-r<oe;){if(n()-a>=re){i=!0;break}await t();const s=N(e);s!==o&&(o=s,a=n())}return{buildWaitMs:n()-r,buildSettled:i}}function x(e){return{outcome:e,steps:0,lastMotion:0,buildWaitMs:0,buildSettled:!0}}function ae(e){return e.hasPhysicsSubscriber!==!1}async function ce(e,t={}){const n=t.yieldTurn??ie,r=t.now??(()=>Date.now()),o=e.update?.bind(e);if(!o)return x("unsupported");if(!ae(e))return x("still");const{buildWaitMs:a,buildSettled:i}=await se(e.scene,n,r);let s=S(e.scene),l=0,u=0,h=!1,E=0,y="still";for(let d=0;d<ee;d++){for(let w=0;w<Z;w++)o(Y),l++;await n();const m=S(e.scene),f=D(s,m);if(s=m,!Number.isFinite(f)){u=0;continue}if(E=f,f>_){h=!0,u=0,y="budget";continue}if(u++,h&&u>=te){y="rest";break}}for(let d=0;d<ne;d++){await n();const m=S(e.scene),f=D(s,m);if(s=m,Number.isFinite(f)&&f<=_)break}return{outcome:y,steps:l,lastMotion:E,buildWaitMs:a,buildSettled:i}}const ue={packaged:!1,createElement:j.createElement,createR3FRoot:X,extendThree:K,three:q};let g=null;async function le(){const e=await import(U);for(const t of["createElement","createR3FRoot","extendThree"])if(typeof e[t]!="function")throw new Error(`The packaged R3F preview runtime did not export ${t} as a function — see vite-plugin-module-doorways.ts.`);if(typeof e.projectThree!="object"||e.projectThree===null)throw new Error("The packaged R3F preview runtime did not export projectThree — see vite-plugin-module-doorways.ts.");return{packaged:!0,createElement:e.createElement,createR3FRoot:e.createR3FRoot,extendThree:e.extendThree,three:e.projectThree}}async function de(){return await B()?(g||(g=le()),g):ue}const R="vgai:story-preview-root",me=1e4;function v(e){if(typeof e=="function"){const t=e;return t.displayName||t.name||""}if(e&&typeof e=="object"){const t=e;return typeof t.displayName=="string"&&t.displayName.length>0?t.displayName:typeof t.name=="string"&&t.name.length>0?t.name:v(t.type??t.render)}return""}function fe(e){const t=e,n=t._reactInternals??t._reactInternalFiber;return n&&typeof n=="object"?n:void 0}function pe(e){const t=[v(e.type),v(e.elementType)];if(!(t.includes("RigidBody")||t.includes("InstancedRigidBodies")))return{provider:t.includes("Physics"),body:!1,movingBody:!1};const r=e.memoizedProps&&typeof e.memoizedProps=="object"?e.memoizedProps:{};return{provider:t.includes("Physics"),body:!0,movingBody:r.type!=="fixed"}}function he(e){const t=e?[e]:[],n=new Set;let r=!1,o=!1,a=!1;for(;t.length>0;){const i=t.pop();if(n.has(i))continue;n.add(i);const s=pe(i);r||=s.provider,o||=s.body,a||=s.movingBody,i.child&&t.push(i.child),i.sibling&&t.push(i.sibling)}return r?!o||a:!1}class ye extends j.Component{componentDidMount(){this.props.onReport(he(fe(this)))}render(){return this.props.children??null}}function we(e){return e instanceof Error&&e.message.includes("is not part of the THREE namespace")}function F(e){return we(e)?!0:e instanceof Error?e.message.includes("Hooks can only be used within the Canvas component")||e.message.includes("useGame: no Game in context"):!1}function ke(e){return F(e)}function L(e){return e instanceof Error&&e.message.includes("useRapier must be used within <Physics")}async function Ee(e){try{return(e.packaged?await import("/@id/@react-three/rapier"):await G(()=>import("./react-three-rapier.esm-DsJqtzy_.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13]))).Physics}catch{return null}}function Te(e,t,n){const r=globalThis,o=r.reportError,a=typeof o=="function"?o.bind(globalThis):i=>{console.error(i)};r.reportError=i=>{F(i)||t&&L(i)||a(i)};try{return n(e)}finally{r.reportError=o}}function be(e){return{domElement:e,xr:{enabled:!1,addEventListener(){},removeEventListener(){},setAnimationLoop(){},getSession(){return null}},shadowMap:{enabled:!1,type:J},outputColorSpace:V,toneMapping:Q,setPixelRatio(){},setSize(){},setClearColor(){},setClearAlpha(){},setViewport(){},setScissor(){},setScissorTest(){},setAnimationLoop(){},clear(){},render(){},compile(){},dispose(){},getPixelRatio(){return 1},getContext(){return null}}}let C=null;function I(e){return H(()=>e(ve))}function Se(e){C!==e.extendThree&&(C=e.extendThree,e.extendThree(e.three))}async function ge(e,t={}){return I(n=>n(e,t))}function Re(e){return I(async()=>e.dispose())}async function ve(e,t={}){const n=z(),r=n?Date.now():0,o=await de(),a=n?Date.now()-r:0,i=n?Date.now():0;typeof e.load=="function"&&await e.load();const s=n?Date.now()-i:0;try{return await O(o,e,t,void 0,{timed:n,runtimeMs:a,loadMs:s})}catch(l){if(!L(l))throw l;const u=await Ee(o);if(!u)throw l;return await O(o,e,t,h=>o.createElement(u,{paused:!1},h),{timed:n,runtimeMs:a,loadMs:s})}}async function O(e,t,n,r,o){Se(e);const a=document.createElement("canvas"),i=Te(a,r===void 0,e.createR3FRoot);let s;const l=new Promise(c=>{s=c});await i.configure({gl:(()=>be(a)),frameloop:"never",size:{width:128,height:96,top:0,left:0},onCreated:c=>s(c)});let u=null,h;const E=new Promise((c,b)=>{h=b}),y=c=>{u??=new Error("mountStoryObject3D: the story threw while reconciling into an R3F root — it does not render `three` content (a DOM/React story), or its component crashed. Original error: "+String(c instanceof Error?c.message:c),{cause:c}),h(u)},d=e.createElement(t,n);let m=!1;const f=c=>{m=c};i.render(e.createElement("group",{name:R},e.createElement($,{onCaught:y},e.createElement(ye,{onReport:f},r?r(d):d))));const w=o?.timed?Date.now():0;let P;const p=await Promise.race([l,E,new Promise((c,b)=>{P=setTimeout(()=>b(new Error("mountStoryObject3D: onCreated did not fire within 10s — the story never reached its first R3F commit and never threw. Either it is still SUSPENDED on a slow load (a suspending loader with no <Suspense> boundary holds the first commit until its content is ready), or its render is hung.")),me)})]).catch(c=>{throw o?.timed&&(o.runtimeMs,o.loadMs,Date.now()-w),i.unmount(),c}).finally(()=>clearTimeout(P));if(u)throw i.unmount(),u;p.clock.autoStart=!1,p.clock.stop();const T=p.scene.getObjectByName(R);if(!T)throw i.unmount(),new Error(`mountStoryObject3D: the story's wrapper group ("${R}") is not in the scene after its first commit — the story rendered nothing mountable.`);const k=o?.timed?Date.now()-w:0,A=o?.timed?Date.now():0;await ce({scene:T,update:c=>{p.advance(p.clock.elapsedTime+Math.min(c,.1),!1)},hasPhysicsSubscriber:m}),o?.timed&&(o.runtimeMs,o.loadMs,Date.now()-A);let M=p.clock.elapsedTime;return{root:T,scene:p.scene,advance(c){!(c>0)||!Number.isFinite(c)||(M+=Math.min(c,.1),p.advance(M,!1))},dispose(){i.unmount()}}}async function Ae(e,t={}){const n=await ge(e,t.props??{});try{const r=W(n.root,{width:t.width??128,height:t.height??96,...t.camera===void 0?{}:{camera:t.camera},...t.pose===void 0?{}:{pose:t.pose}}),o=r.views.find(a=>a.view==="perspective")??r.views[0];if(!o)throw new Error("Story preview capture returned no views.");return`data:${o.mimeType};base64,${o.base64}`}finally{await Re(n)}}function Be(){return typeof WebGLRenderingContext<"u"&&typeof navigator<"u"&&!navigator.userAgent.toLowerCase().includes("jsdom")}export{R as PREVIEW_ROOT_NAME,Ae as captureStoryComponentThumbnail,Re as disposeStoryObject3D,ke as isStoryThreeClassificationRefusal,ge as mountStoryObject3D,Be as supportsThreeStoryCapture,I as withStoryMountTurn};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{eD as v,eE as C,b_ as Z,eF as z,eG as R,eH as T,eI as te,eJ as Ce,eK as ce,eL as F,bZ as P,eM as E,b$ as Se,c0 as he}from"./index-
|
|
1
|
+
import{eD as v,eE as C,b_ as Z,eF as z,eG as R,eH as T,eI as te,eJ as Ce,eK as ce,eL as F,bZ as P,eM as E,b$ as Se,c0 as he}from"./index-DmtPt6RQ.js";import"./index-DaQZGF7d.js";import"./_commonjsHelpers-D6-XlEtG.js";import"./index-D_NuPfjr.js";import"./jsx-runtime-DPjLkJKQ.js";import"./index-CtzuWnCS.js";import"./index-CinJrH5C.js";import"./index-D2LwEE0L.js";import"./client-DNXj_opT.js";import"./three.module-BynznMJN.js";const B=Object.create(null),re=Object.create(null);function Q(s,e){let t=re[s];return t===void 0&&(B[e]===void 0&&(B[e]=1),re[s]=t=B[e]++),t}let k;function Pe(){return(!k||k?.isContextLost())&&(k=v.get().createCanvas().getContext("webgl",{})),k}let G;function Ie(){if(!G){G="mediump";const s=Pe();s&&s.getShaderPrecisionFormat&&(G=s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.HIGH_FLOAT).precision?"highp":"mediump")}return G}function Ae(s,e,t){return e?s:t?(s=s.replace("out vec4 finalColor;",""),`
|
|
2
2
|
|
|
3
3
|
#ifdef GL_ES // This checks if it is WebGL1
|
|
4
4
|
#define in varying
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const d="/work/.vgai-session",ae=`${d}/session.py`,se=[`${d}/in`,`${d}/reply`],I="/__editor/blender-wasm";function D(e){return new URL(`${I}/${e}`,import.meta.url).href}async function M(){const e=await fetch(D("status"));return e.ok?await e.json():{available:!1,skew:null,dir:null,sizes:{},encoded:{},missing:[`${I}/status answered ${e.status}`]}}async function J(e){const t=await M();if(!t.available)throw new Error(`The headless Blender WebAssembly build is not served by this editor: ${t.missing.join("; ")}`);if(t.skew==="wali"){const{startWaliBlenderEngine:n}=await import("./blender-wali-engine-B0Q2w2Be.js");return n(e,t)}const{startEmscriptenBlenderEngine:r}=await import("./blender-emscripten-engine-BhbEQhcb.js");return r(e,t)}function U(e){return e<200?1:e<5e3?5:25}const C=e=>new Promise(t=>setTimeout(t,e)),B=new TextDecoder;function ie(e,t,r){let n=0,a=0;const o=new Set;async function s(u){for(const l of o)u.has(`${l}.done`)||(await e.unlink(`${d}/reply/${l}.json`),await e.unlink(`${d}/reply/${l}.done`),o.delete(l))}async function i(){let u;try{u=await e.readdir(`${d}/ask`)}catch{return}const l=new Set(u.filter(h=>h.endsWith(".done")));await s(l);for(const h of l){const w=h.slice(0,-5);if(Number(w)<=a)continue;a=Number(w);const m=JSON.parse(B.decode(await e.readFile(`${d}/ask/${w}.json`)));let S;try{S=await t.ask(m)}catch(v){S={error:v instanceof Error?v.message:String(v)}}await e.writeFile(`${d}/reply/${w}.json`,JSON.stringify(S??null)),await e.writeFile(`${d}/reply/${w}.done`,"1"),o.add(w)}}async function c(u){const l=String(++n);await e.writeFile(`${d}/in/${l}.json`,JSON.stringify(u)),await e.writeFile(`${d}/in/${l}.done`,"1");const h=performance.now();for(;;){if(await i(),await e.stat(`${d}/out/${l}.done`)){const m=JSON.parse(B.decode(await e.readFile(`${d}/out/${l}.json`)));if(await e.unlink(`${d}/in/${l}.json`),await e.unlink(`${d}/in/${l}.done`),m.error)throw new Error(m.error);return m.result}const w=r?.();if(w)throw new Error(`Blender is gone, so this call will never be answered: ${w}. The session keeps its directory and its cached banner, so every later call would wait on the same missing answer; start a new program with \`blender-start {fresh: true}\` (\`VGAI_BLENDER_FRESH_SESSION=1\` for the battery harness).`);await C(U(performance.now()-h))}}return{request:c}}const N=e=>typeof e=="object"&&e!==null&&typeof e.offset=="number"&&typeof e.length=="number"&&typeof e.dtype=="string"&&typeof e.count=="number"&&typeof e.stride=="number",W={f32:e=>new Float32Array(e.buffer,e.byteOffset,e.byteLength>>2),f64:e=>new Float64Array(e.buffer,e.byteOffset,e.byteLength>>3),u32:e=>new Uint32Array(e.buffer,e.byteOffset,e.byteLength>>2),i32:e=>new Int32Array(e.buffer,e.byteOffset,e.byteLength>>2),u16:e=>new Uint16Array(e.buffer,e.byteOffset,e.byteLength>>1),i16:e=>new Int16Array(e.buffer,e.byteOffset,e.byteLength>>1),u8:e=>e,i8:e=>new Int8Array(e.buffer,e.byteOffset,e.byteLength)};function z(e,t,r){const n=W[r.dtype];if(!n)throw new Error(`Blender frame column ${t}: unknown dtype ${r.dtype}`);const{offset:a,length:o}=r;if(a<0||o<0||a+o>e.byteLength)throw new Error(`Blender frame column ${t}: bytes ${a}..${a+o} lie outside the ${e.byteLength}-byte export arena`);const s=e.subarray(a,a+o).slice(),i=n(s),c=r.count*r.stride;if(i.length!==c)throw new Error(`Blender frame column ${t}: ${i.length} values, ${c} declared (${r.count} x ${r.stride})`);return i}function H(e,t){const r=(n,a)=>{if(N(n)){const o=z(e,a,n);return a==="co"?Float64Array.from(o):o}if(Array.isArray(n))return n.map(o=>r(o,a));if(typeof n=="object"&&n!==null){const o={};for(const[s,i]of Object.entries(n))o[s]=r(i,s);return o}return n};return r(t,"")}async function V(e,t){const r=async(n,a)=>{if(N(n)){const{offset:o,length:s,dtype:i}=n;if(o<0||s<0||o+s>e.byteLength)throw new Error(`Blender frame column ${a}: bytes ${o}..${o+s} lie outside the ${e.byteLength}-byte export arena`);const c=e.subarray(o,o+s).slice(),u=await crypto.subtle.digest("SHA-256",c),l=[...new Uint8Array(u)].map(h=>h.toString(16).padStart(2,"0")).join("");return{dtype:i,length:s,sha256:l}}if(Array.isArray(n))return Promise.all(n.map(o=>r(o,a)));if(typeof n=="object"&&n!==null){const o={};for(const[s,i]of Object.entries(n))o[s]=await r(i,s);return o}return n};return r(t,"")}const b=e=>self.postMessage(e),O=(e,t)=>b({op:"log",level:e,text:t});let p=null,E=null,G=0;const j=new Map;function K(e,t,r){const n=++G,a=[],o=e;for(const s of[o?.meshes??{},o?.images??{}])for(const i of Object.values(s))for(const c of Object.values(i))ArrayBuffer.isView(c)&&c.buffer instanceof ArrayBuffer&&!a.includes(c.buffer)&&a.push(c.buffer);return new Promise((s,i)=>{j.set(n,{resolve:s,reject:i}),self.postMessage({op:"present",id:n,frame:e,description:t,...r?{capture:r}:{}},a)})}let f=null,$=null,P=!1,A=Promise.resolve();function Q(e){const t=A.then(e);return A=t.catch(()=>{}),t}function _(e){P=e,b({op:"document-dirty",dirty:e})}async function F(){if(!f||$===null)return;const e=$;let t;try{t=await f.request({op:"save-document"})}catch(n){throw new Error(`The Blender document ${e} could not be saved: ${g(n)}`)}if(!t?.saved||typeof t.path!="string")throw new Error(`Blender did not save the document ${e}`);let r;try{r=await f.files.readFile(t.path)}catch(n){throw new Error(`The Blender document ${e} could not be read back out of the engine: ${g(n)}`)}y.delete(t.path);try{const n=await fetch(`/__editor/blender-document?path=${encodeURIComponent(e)}`,{method:"POST",headers:{"content-type":"application/octet-stream"},body:new Blob([r])});if(!n.ok){const a=await n.text().catch(()=>"");throw new Error(`HTTP ${n.status} ${a}`)}}catch(n){throw new Error(`The Blender document ${e} was not written to the project: ${g(n)}`)}_(!1),O("log",`@@VGAI-DOCUMENT ${JSON.stringify({path:e,bytes:r.length})}`)}async function X(e,t){const r={engine:null},n=await J({project:e,log:O,ask:async({frame:o,capture:s,saveDue:i})=>{if(!r.engine)throw new Error("The Blender session presented before it started");i&&$!==null&&_(!0);const c=await r.engine.readArena(),u=await V(c,o),l=await K(H(c,o),u,s);return{...typeof l.capture=="object"&&l.capture!==null?l.capture:{},..."held"in l?{held:l.held}:{}}}});r.engine=n,f=n,t&&await L(n.files,e);const a=await n.request({op:"start",project:e,...t?{document:t}:{}});return t&&($=t),p={start:async()=>a,execute:async o=>{const s=await n.request({op:"execute",code:o});return s.error?`Error executing code: ${s.error}`:`Code executed successfully: ${s.result}`},sceneInfo:async()=>JSON.stringify(await n.request({op:"scene-info"}),null,2),objectInfo:async o=>JSON.stringify(await n.request({op:"object-info",name:o}),null,2),screenshotView:async o=>(await n.request({op:"present",capture:{size:o}}),JSON.stringify({view:{size:o}}))},{...a,engine:"blender-wasm",skew:n.skew,bootMs:Math.round(n.bootMs),releasedPayloadMB:n.releasedPayloadBytes===null?null:Math.round(n.releasedPayloadBytes/1048576)}}async function Y(){try{const e=await fetch("/__editor/blender-wasm/status");return e.ok?await e.json():{available:!1,missing:[`status answered ${e.status}`]}}catch(e){return{available:!1,missing:[String(e)]}}}async function Z(e,t){if(p)throw new Error("The Blender session is already started");if(!e.startsWith("/"))throw new Error("The Blender session needs the project's absolute path");if(t!==void 0&&!q(t))throw new Error(`The Blender document must be a project-relative .blend path with no traversal (models/model.blend); got ${JSON.stringify(t)}`);const r=await Y();if(!r.available)throw new Error(`Headless Blender is not served by this editor, so there is no modeling engine: ${r.missing.join("; ")}. The engine is Blender compiled to WebAssembly (packages/blender-engine/wasm, or the directory VGAI_BLENDER_WASM_DIR names); nothing stands in for it.`);return E=e,X(e,t)}function q(e){return!e.endsWith(".blend")||e.startsWith("/")||e.includes("\\")?!1:e.split("/").every(r=>r!==""&&r!=="."&&r!=="..")}const T=new Set;function k(e){T.has(e)||(T.add(e),O("error",e))}async function ee(e){const t=s=>(k(`The project's files are not readable from Python: ${s}`),null);let r;try{r=await fetch("/__editor/blender-project-index")}catch(s){return t(String(s))}if(!r.ok)return t(`/__editor/blender-project-index answered ${r.status}`);let n;try{if(n=await r.json(),typeof n?.root!="string"||!Array.isArray(n.files))return t("invalid project index")}catch(s){return t(String(s))}const{root:a,files:o}=n;return a!==e&&k(`The editor serving this tab has ${a} open, not ${e}; its files are mounted at ${e}, which is where Python is looking.`),o}const y=new Map;async function te(e,t){const r=await e.stat(t);return r?`${r.size}:${r.mtimeMs}`:""}async function L(e,t){const r=await ee(t);if(!r)return;const n=new Set(r.map(a=>`${t}/${a.path}`));for(const a of[...y.keys()])if(!n.has(a)){try{await e.unlink(a)}catch{}y.delete(a)}for(const a of r){const o=`${t}/${a.path}`,s=`${a.size}:${a.mtime}`;if(y.get(o)?.host===s||!y.has(o)&&await e.stat(o)!==null)continue;const i=await fetch(`/__editor/blender-project-file?path=${encodeURIComponent(a.path)}`);if(!i.ok){k(`${a.path}: HTTP ${i.status}`);continue}const c=o.slice(0,o.lastIndexOf("/"));c&&await e.mkdirTree(c),await e.writeFile(o,new Uint8Array(await i.arrayBuffer())),y.set(o,{host:s,engine:await te(e,o)})}}async function ne(e,t){const r=[],n=async a=>{let o;try{o=await e.readdir(a)}catch{return}for(const s of o){if(s==="."||s==="..")continue;const i=`${a.replace(/\/$/,"")}/${s}`,c=await e.stat(i);if(c){if((c.mode&61440)===16384){await n(i);continue}y.get(i)?.engine!==`${c.size}:${c.mtimeMs}`&&r.push({path:i,size:c.size,mtime:c.mtimeMs})}}};return await n(t),r}async function R(e){switch(e.op){case"start":return Z(e.project,e.document);case"present-result":{const n=j.get(e.id);j.delete(e.id),n&&(e.error?n.reject(new Error(e.error)):n.resolve({...e.capture===void 0?{}:{capture:e.capture},..."held"in e?{held:e.held}:{}}));return}}if(!p||!E||!f)throw new Error("The Blender session has not started");const t=f.files,r=f.request.bind(f);switch(e.op){case"flush-document":return await F(),{saved:!0};case"history-begin":case"history-end":return r({op:e.op});case"history-step":return r({op:"history-step",token:e.token,direction:e.direction});case"execute":await L(t,E);{const n=await r({op:"execute",code:e.code,history:e.history??!0,label:e.label??"Blender Python"});return n.error?`Error executing code: ${n.error}`:`Code executed successfully: ${n.result}`}case"present":return r({op:"present"});case"scene-info":return p.sceneInfo();case"object-info":return p.objectInfo(e.name);case"rna":return r({op:"rna",path:e.path,...e.names===void 0?{}:{names:e.names}});case"rna-context":return r({op:"rna-context",...e.object===void 0?{}:{object:e.object},...e.collection===void 0?{}:{collection:e.collection}});case"rna-set":return r({op:"rna-set",history:e.history!==!1,path:e.path,property:e.property,value:e.value,...e.index===void 0?{}:{index:e.index}});case"outliner":return r({op:"outliner",...e.selected===void 0?{}:{selected:[...e.selected]}});case"node-tree":return r({op:"node-tree",...e.path===void 0?{}:{path:e.path},...e.material===void 0?{}:{material:e.material}});case"uv-layout":return r({op:"uv-layout",...e.object===void 0?{}:{object:e.object},...e.uvLayer===void 0?{}:{uvLayer:e.uvLayer}});case"rig":return r({op:"rig",...e.object===void 0?{}:{object:e.object}});case"action-clip":return r({op:"action-clip",...e.object===void 0?{}:{object:e.object},...e.bake===void 0?{}:{bake:e.bake}});case"outliner-set":return r({op:"outliner-set",path:e.path,column:e.column,value:e.value});case"screenshot-view":return JSON.parse(await p.screenshotView(e.maxSize));case"read-file":return t.readFile(e.path);case"write-file":{const n=e.path.slice(0,e.path.lastIndexOf("/"));n&&await t.mkdirTree(n),await t.writeFile(e.path,e.bytes),y.delete(e.path);return}case"list-files":return ne(t,e.path)}throw new Error(`Unknown Blender worker request ${e.op}`)}function g(e){if(e instanceof Error)return e.stack??`${e.name}: ${e.message}`;if(typeof e=="object"&&e!==null){const t=e;if(typeof t.message=="string")return typeof t.name=="string"?`${t.name}: ${t.message}`:t.message;try{return JSON.stringify(e)??Object.prototype.toString.call(e)}catch{return Object.prototype.toString.call(e)}}return String(e)}function re(){if(!f)return;const e=f.memoryBytes();e!==null&&b({op:"memory",bytes:e})}self.onmessage=e=>{const t=e.data;if(t.op==="present-result"){R(t);return}Q(()=>oe(t))};async function oe(e){try{const t=await R(e);P&&await F(),await x(),b({id:e.id,result:t})}catch(t){let r=g(t);try{await x()}catch(n){r+=`
|
|
2
|
+
Unable to deliver Blender history: ${g(n)}`}b({id:e.id,error:r})}re()}async function x(){if(!f||!p)return;const e=await f.request({op:"history-events"});e.length&&b({op:"history",entries:e})}export{I as A,se as P,d as S,ae as a,D as b,ie as o,C as s};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{a}from"./jsx-runtime-DPjLkJKQ.js";import{cc as co,cd as uo,ce as po,cf as ee,az as bn,cg as Ge,ch as fo,Z as Ft,ci as ho,cj as yn,ck as go,cl as je,cm as ne,cn as Pe,co as Kt,u as oe,cp as vn,cq as mo,bq as Ut,bc as xo,bd as et,a4 as nt,br as bo,B as Zt,cr as wn,cs as Sn,ct as En,cu as Yt,a6 as yo,cv as vo,cw as wo,G as re,cx as _e,cy as Xe,cz as He,cA as So,cB as Eo,cC as Co,cD as ko,cE as Io,cF as J,cG as Ro,cH as Cn,cI as zo,cJ as jo,cK as pe,cL as Po,cM as F,cN as Se,cO as Rt,cP as Mo,cQ as Do,cR as To,cS as Lo,cT as $o,cU as Ve,cV as Bo,cW as Oo,cX as Ao,cY as Fo,cZ as Yo,c_ as No,c$ as Go,d0 as kn,d1 as _o,d2 as Xo,t as zt,d3 as Ho,d4 as Vo,d5 as Wo,d6 as Ko,as as In,d7 as Uo,d8 as Zo,d9 as qo,da as Jo,db as Qo,dc as tr,dd as er,aj as nr,de as or,df as rr,dg as Nt,dh as fe,di as ir,dj as Gt,dk as sr,dl as he,dm as We,dn as ar,Y as lr,dp as cr,W as dr,dq as ur,dr as pr,ds as fr,dt as hr,du as gr,dv as mr,dw as xr,dx as Ke,dy as br,dz as yr}from"./index-CY4oDLhJ.js";import{r as c}from"./index-DaQZGF7d.js";import{B as It,q as Ue,I as vr}from"./edit-mode-authoring-BBWCwYeE.js";import"./index-CtzuWnCS.js";import"./index-D2LwEE0L.js";import{T as wr}from"./TransientHint-Rw3wxMUO.js";import{s as Sr,g as Er,a as Cr,f as kr,t as Ir,z as Rr,b as zr}from"./react-story-board-DBO76grK.js";import{g as Me}from"./viewport-pick-context-DkawXbEi.js";import"./_commonjsHelpers-D6-XlEtG.js";import"./client-DNXj_opT.js";import"./index-D_NuPfjr.js";import"./index-CinJrH5C.js";import"./three.module-BynznMJN.js";const qt=[],Ze=new Set,jr=[];function Pr(){return qt.length===0?jr:qt}function vt(t){for(let e=qt.length-1;e>=0;e--){const n=qt[e];if(n&&n.kind===t)return n}return null}function Mr(t){return Ze.add(t),()=>{Ze.delete(t)}}const Dr={width:null,height:null};let Vt=Dr;const Ee=new Set;function Rn(){return Vt}function Jt(t,e){const n=t===null?null:Math.max(1,Math.round(t)),r=e===null?null:Math.max(1,Math.round(e));if(!(Vt.width===n&&Vt.height===r)){Vt={width:n,height:r};for(const s of Ee)s()}}function Tr(){Jt(null,null)}function zn(t){return Ee.add(t),()=>Ee.delete(t)}const Lr=1;function jn(t){const e=[];for(const{worldId:n,adapter:r}of t.childAdapters()){if(!(r instanceof It))continue;const s=r.inspector.get(n,"kind");if(s!=="dom"&&s!=="canvas"||r.inspector.get(n,"reason")!==void 0)continue;const d=r.inspector.get(n,"adapter");d?.startsWith("ingest")||d?.startsWith("module")||e.push({worldId:n,kind:s,path:r.inspector.get(n,"path"),zOrder:Number(r.inspector.get(n,"zOrder")??0),pausable:r.inspector.get(n,"pausable")!==!1})}return e}function $r(t){return jn(t)}function ge(t,e){return t.childAdapters().some(n=>n.worldId===e)}function Pn(t,e,n="dom"){const r=yn(e)?"none":"block";t.style.display=r,t.style.pointerEvents=vt(n)?.alwaysInteractive||go(e)?"auto":"none";for(const s of Array.from(t.parentElement?.children??[]))s instanceof HTMLElement&&s.dataset.vgaiStoryBoardChromeFor===e&&(s.style.display=r)}function Br(t,e,n,r){const{worldId:s}=e,i=document.createElement("div");return i.dataset.worldId=s,i.dataset.vgaiRootSurface="true",r&&(i.dataset.vgaiCanvasScene="true"),i.style.position="absolute",i.style.top="0",i.style.left="0",i.style.width="100%",i.style.height="100%",i.style.zIndex=String(n),i.style.contain="layout paint",Pn(i,s,e.kind),Ce(i),t.appendChild(i),i}function Ce(t){if(t.dataset.vgaiCanvasScene==="true"){t.style.transform="",t.style.width="100%",t.style.height="100%";return}if(t.style.transform=je(ne())??"",t.style.transformOrigin="0 0",t.dataset.vgaiReactStoryBoard==="true")return;const e=Rn();t.style.width=e.width===null?"100%":`${e.width}px`,t.style.height=e.height===null?"100%":`${e.height}px`}function Or(t,e,n,r,s,i,d){i?i.canvasSceneView.reset():co(),Tr();const x=bn();if(!i&&x?.config.resolution&&Jt(x.config.resolution.width,x.config.resolution.height),n.playState!=="stopped"){let u=!1,I=!1;const L=n.subscribe(()=>{u||I||n.playState!=="stopped"||(I=!0,u||Ue())});return()=>{u=!0,L()}}const v=x?.rootPath,y=r?[...r]:jn(e);if(y.length===0||!v)return()=>{};const w=v,z=uo(y.map(u=>({id:u.worldId,zOrder:u.zOrder}))).map(u=>y.find(I=>I.worldId===u.id)),j=new Map(z.map(u=>[u.worldId,u])),b=new Map,m=new Map,p=new Map,S=new Set,f=new Set,P=new Set;let D=!1,M=!1,k=!1;function X(){for(const u of m.values())try{u()}catch(I){Ft.error(`[design-time-layers] dispose failed: ${I}`,"authoring")}m.clear();for(const u of b.values())u.remove();b.clear();for(const u of z)s?.(u.worldId,null)}function V(){X();for(const u of S){const I=j.get(u);if(!I)continue;const L={id:I.worldId,kind:I.kind,entryOrScenePath:I.path,zOrder:I.zOrder,pausable:I.pausable};e.replaceChild(u,new It(n,L,"Design-time layer suspended by play mode — Stop restores it."))}S.clear(),n.notifyIngestEdit()}function W(u,I,L){const B=vt(u.kind);if(!B){f.add(u.worldId);return}f.delete(u.worldId);const G=(p.get(u.worldId)??0)+1;p.set(u.worldId,G);const A=Br(t,u,Lr+I,!!i);b.set(u.worldId,A);const xt={projectRootPath:w,store:n,...i?{view:i.canvasSceneView}:{},...d?{activationDocumentId:d}:{}};(async()=>B.mount(u,A,xt))().then(K=>{if(D||M||p.get(u.worldId)!==G){K.dispose();return}if(K.adapter)ge(e,u.worldId)&&(e.replaceChild(u.worldId,K.adapter),S.add(u.worldId)),s?.(u.worldId,K.adapter);else if(K.pick){const Q={id:u.worldId,kind:u.kind,entryOrScenePath:u.path,zOrder:u.zOrder,pausable:u.pausable};e.replaceChild(u.worldId,new It(n,Q,void 0,K.pick)),S.add(u.worldId)}m.set(u.worldId,K.dispose),Ge(u.worldId),n.notifyIngestEdit(),L?.()}).catch(K=>{if(p.get(u.worldId)!==G||(L?.(),A.remove(),b.get(u.worldId)===A&&b.delete(u.worldId),D||M))return;const Q=fo(K);Ft.error(`[design-time-layers] world "${u.worldId}" (${u.kind}) failed to mount: ${Q}`,"authoring");const ut={id:u.worldId,kind:u.kind,entryOrScenePath:u.path,zOrder:u.zOrder,pausable:u.pausable};s?.(u.worldId,null),ge(e,u.worldId)&&e.replaceChild(u.worldId,new It(n,ut,Q)),ho({worldId:u.worldId,kind:u.kind,identity:B.identity,message:Q}),n.notifyIngestEdit()})}z.forEach((u,I)=>{W(u,I)});function Mt(u,I){const L=m.get(u.worldId);m.delete(u.worldId);const B=b.get(u.worldId);b.delete(u.worldId),W(u,I,()=>{const A=b.get(u.worldId);if(A&&(A.style.visibility=""),L)try{L()}catch(xt){Ft.error(`[design-time-layers] re-projection dispose failed: ${xt}`,"authoring")}B?.remove()});const G=b.get(u.worldId);G&&G!==B&&(G.style.visibility="hidden")}function gt(u,I){const L=m.get(u.worldId);if(m.delete(u.worldId),L)try{L()}catch(G){Ft.error(`[design-time-layers] remount dispose failed: ${G}`,"authoring")}const B=b.get(u.worldId);B&&(B.remove(),b.delete(u.worldId)),W(u,I)}const Y=new Map;function Dt(){for(const[u,I]of Y)vt(u.kind)!==u&&(I(),Y.delete(u));for(const u of Pr()){if(Y.has(u)||vt(u.kind)!==u||!z.some(B=>B.kind===u.kind))continue;const I=[],L=B=>()=>{D||M||n.playState!=="stopped"||z.forEach((G,A)=>{G.kind===u.kind&&B(G,A)})};u.remountWhen&&I.push(u.remountWhen(L(gt))),u.reprojectWhen&&I.push(u.reprojectWhen(L(Mt))),Y.set(u,()=>{for(const B of I)B()})}}Dt();const mt=Mr(()=>{D||M||n.playState!=="stopped"||(z.forEach((u,I)=>{f.has(u.worldId)&&vt(u.kind)&&(P.delete(u.worldId),Ge(u.worldId),W(u,I))}),Dt())}),O=po(()=>{if(D||M)return;let u=!1;for(const I of z){if(!f.has(I.worldId)||P.has(I.worldId)||vt(I.kind)||(P.add(I.worldId),!ge(e,I.worldId)))continue;const L={id:I.worldId,kind:I.kind,entryOrScenePath:I.path,zOrder:I.zOrder,pausable:I.pausable};e.replaceChild(I.worldId,new It(n,L,`No package in this editor registered a design-time mount for a "${I.kind}" world, so there is nothing here to author it with. A build ships the packages its own entry in \`builds/\` lists.`)),u=!0}u&&n.notifyIngestEdit()}),se=ee(()=>{for(const u of b.values())Ce(u)}),ae=zn(()=>{for(const u of b.values())Ce(u)}),dt=n.subscribe(()=>{if(!M&&n.playState!=="stopped"){M=!0,V();return}if(M&&!k&&n.playState==="stopped"&&!D){k=!0,D||Ue();return}if(!M)for(const[u,I]of b)Pn(I,u,j.get(u)?.kind??"dom")});return()=>{D=!0;for(const u of Y.values())u();Y.clear(),mt(),O(),dt(),se(),ae(),X()}}const Mn=.1,Dn=4,Tn=.002,Ar=4;function ke(t,e,n){return e===1?t*16:e===2?t*n:t}function Fr(t,e){let n=ke(e.deltaX,e.deltaMode,e.bounds.width),r=ke(e.deltaY,e.deltaMode,e.bounds.height);if(e.ctrlKey||e.metaKey){const s=Math.min(Dn,Math.max(Mn,t.zoom*Math.exp(-r*Tn))),i=e.clientX-e.bounds.left,d=e.clientY-e.bounds.top,x=(i-t.x)/t.zoom,v=(d-t.y)/t.zoom;return{x:i-x*s,y:d-v*s,zoom:s}}return e.shiftKey&&n===0&&(n=r,r=0),{x:t.x-n,y:t.y-r,zoom:t.zoom}}function Yr(t,e){const n=ke(e.deltaY,e.deltaMode,e.bounds.height),r=Math.min(Dn,Math.max(Mn,t.zoom*Math.exp(-n*Tn))),s=e.clientX-e.bounds.left,i=e.clientY-e.bounds.top,d=(s-t.x)/t.zoom,x=(i-t.y)/t.zoom;return{x:s-d*r,y:i-x*r,zoom:r}}function me(t){return t instanceof Element&&t.closest('[data-vgai-canvas-navigation-ignore="true"]')!==null}function Ln(t,e,n,r={}){let s=null,i=!1,d="";const x=()=>t.querySelector('[data-testid="world-selection-overlay-interaction"]'),v=m=>{t.dataset.canvasPanning=m?"true":"false",t.style.cursor=m?"grabbing":"";const p=x();p&&(m?(d=p.style.cursor,p.style.cursor="grabbing"):p.style.cursor=d)},y=m=>{if(!s||m.pointerId!==s.pointerId)return;const p=s.button===1?4:2;if((m.buttons&p)===0){w(m);return}const S=m.clientX-s.startClientX,f=m.clientY-s.startClientY;if(!s.moved){if(Math.hypot(S,f)<=Ar)return;s.moved=!0,v(!0)}e.setPan(s.startPan.x+S,s.startPan.y+f)},w=m=>{if(!s||m.pointerId!==s.pointerId)return;const p=s.pointerId;s.button===2&&s.moved&&(i=!0),s=null,v(!1),t.hasPointerCapture?.(p)&&t.releasePointerCapture(p),window.removeEventListener("pointermove",y),window.removeEventListener("pointerup",w),window.removeEventListener("pointercancel",w)},E=m=>{const p=m.button===1,S=r.rightDragPans===!0&&m.button===2;!p&&!S||me(m.target)||(S&&(i=!1),m.preventDefault(),p&&m.stopPropagation(),s={pointerId:m.pointerId,button:m.button,startClientX:m.clientX,startClientY:m.clientY,startPan:e.get(),moved:p},t.setPointerCapture?.(m.pointerId),v(p),window.addEventListener("pointermove",y),window.addEventListener("pointerup",w),window.addEventListener("pointercancel",w))},z=m=>{m.button===1&&!me(m.target)&&m.preventDefault()},j=m=>{r.rightDragPans!==!0||!(s?.button===2&&s.moved)&&!i||(i=!1,m.preventDefault(),m.stopPropagation())},b=m=>{if(me(m.target))return;m.preventDefault(),m.stopPropagation();const p=n(e.get(),{clientX:m.clientX,clientY:m.clientY,deltaX:m.deltaX,deltaY:m.deltaY,deltaMode:m.deltaMode,ctrlKey:m.ctrlKey,metaKey:m.metaKey,shiftKey:m.shiftKey,bounds:t.getBoundingClientRect()});e.setView(p.x,p.y,p.zoom)};return t.addEventListener("pointerdown",E,!0),t.addEventListener("lostpointercapture",w,!0),t.addEventListener("mousedown",z,!0),t.addEventListener("contextmenu",j,!0),t.addEventListener("wheel",b,{capture:!0,passive:!1}),()=>{s=null,v(!1),t.removeEventListener("pointerdown",E,!0),t.removeEventListener("lostpointercapture",w,!0),t.removeEventListener("mousedown",z,!0),t.removeEventListener("contextmenu",j,!0),t.removeEventListener("wheel",b,!0),window.removeEventListener("pointermove",y),window.removeEventListener("pointerup",w),window.removeEventListener("pointercancel",w)}}function Nr(t,e=Pe){return Ln(t,e,Fr)}function Gr(t,e){return Ln(t,e,Yr,{rightDragPans:!0})}const Ie="#191c22",_r="rgba(255, 255, 255, 0.2)",jt=[],qe=new Set,Xr=[];function Hr(){return jt.length===0?Xr:jt}function Vr(t){for(let e=jt.length-1;e>=0;e--){const n=jt[e];if(n&&n.medium===t)return n}return null}function Wr(t){return jt.find(e=>e.documentId===t)??null}function Kr(t){return qe.add(t),()=>{qe.delete(t)}}function St(t){return t.map(e=>`“${e}”`).join(", ")}function Ur(t,e){const n=e.map(r=>r.worldId);return{tone:"error",title:n.length===1?`${t} root ${St(n)} failed`:`${n.length} ${t} roots failed`,description:`${e.map(r=>`${r.worldId} (${r.kind}, ${r.identity}): ${r.message}`).join(`
|
|
1
|
+
import{a}from"./jsx-runtime-DPjLkJKQ.js";import{cc as co,cd as uo,ce as po,cf as ee,az as bn,cg as Ge,ch as fo,Z as Ft,ci as ho,cj as yn,ck as go,cl as je,cm as ne,cn as Pe,co as Kt,u as oe,cp as vn,cq as mo,bq as Ut,bc as xo,bd as et,a4 as nt,br as bo,B as Zt,cr as wn,cs as Sn,ct as En,cu as Yt,a6 as yo,cv as vo,cw as wo,G as re,cx as _e,cy as Xe,cz as He,cA as So,cB as Eo,cC as Co,cD as ko,cE as Io,cF as J,cG as Ro,cH as Cn,cI as zo,cJ as jo,cK as pe,cL as Po,cM as F,cN as Se,cO as Rt,cP as Mo,cQ as Do,cR as To,cS as Lo,cT as $o,cU as Ve,cV as Bo,cW as Oo,cX as Ao,cY as Fo,cZ as Yo,c_ as No,c$ as Go,d0 as kn,d1 as _o,d2 as Xo,t as zt,d3 as Ho,d4 as Vo,d5 as Wo,d6 as Ko,as as In,d7 as Uo,d8 as Zo,d9 as qo,da as Jo,db as Qo,dc as tr,dd as er,aj as nr,de as or,df as rr,dg as Nt,dh as fe,di as ir,dj as Gt,dk as sr,dl as he,dm as We,dn as ar,Y as lr,dp as cr,W as dr,dq as ur,dr as pr,ds as fr,dt as hr,du as gr,dv as mr,dw as xr,dx as Ke,dy as br,dz as yr}from"./index-DmtPt6RQ.js";import{r as c}from"./index-DaQZGF7d.js";import{B as It,q as Ue,I as vr}from"./edit-mode-authoring-CWTeROGv.js";import"./index-CtzuWnCS.js";import"./index-D2LwEE0L.js";import{T as wr}from"./TransientHint-aFFUtbSY.js";import{s as Sr,g as Er,a as Cr,f as kr,t as Ir,z as Rr,b as zr}from"./react-story-board-CnCZAhn6.js";import{g as Me}from"./viewport-pick-context-DkawXbEi.js";import"./_commonjsHelpers-D6-XlEtG.js";import"./client-DNXj_opT.js";import"./index-D_NuPfjr.js";import"./index-CinJrH5C.js";import"./three.module-BynznMJN.js";const qt=[],Ze=new Set,jr=[];function Pr(){return qt.length===0?jr:qt}function vt(t){for(let e=qt.length-1;e>=0;e--){const n=qt[e];if(n&&n.kind===t)return n}return null}function Mr(t){return Ze.add(t),()=>{Ze.delete(t)}}const Dr={width:null,height:null};let Vt=Dr;const Ee=new Set;function Rn(){return Vt}function Jt(t,e){const n=t===null?null:Math.max(1,Math.round(t)),r=e===null?null:Math.max(1,Math.round(e));if(!(Vt.width===n&&Vt.height===r)){Vt={width:n,height:r};for(const s of Ee)s()}}function Tr(){Jt(null,null)}function zn(t){return Ee.add(t),()=>Ee.delete(t)}const Lr=1;function jn(t){const e=[];for(const{worldId:n,adapter:r}of t.childAdapters()){if(!(r instanceof It))continue;const s=r.inspector.get(n,"kind");if(s!=="dom"&&s!=="canvas"||r.inspector.get(n,"reason")!==void 0)continue;const d=r.inspector.get(n,"adapter");d?.startsWith("ingest")||d?.startsWith("module")||e.push({worldId:n,kind:s,path:r.inspector.get(n,"path"),zOrder:Number(r.inspector.get(n,"zOrder")??0),pausable:r.inspector.get(n,"pausable")!==!1})}return e}function $r(t){return jn(t)}function ge(t,e){return t.childAdapters().some(n=>n.worldId===e)}function Pn(t,e,n="dom"){const r=yn(e)?"none":"block";t.style.display=r,t.style.pointerEvents=vt(n)?.alwaysInteractive||go(e)?"auto":"none";for(const s of Array.from(t.parentElement?.children??[]))s instanceof HTMLElement&&s.dataset.vgaiStoryBoardChromeFor===e&&(s.style.display=r)}function Br(t,e,n,r){const{worldId:s}=e,i=document.createElement("div");return i.dataset.worldId=s,i.dataset.vgaiRootSurface="true",r&&(i.dataset.vgaiCanvasScene="true"),i.style.position="absolute",i.style.top="0",i.style.left="0",i.style.width="100%",i.style.height="100%",i.style.zIndex=String(n),i.style.contain="layout paint",Pn(i,s,e.kind),Ce(i),t.appendChild(i),i}function Ce(t){if(t.dataset.vgaiCanvasScene==="true"){t.style.transform="",t.style.width="100%",t.style.height="100%";return}if(t.style.transform=je(ne())??"",t.style.transformOrigin="0 0",t.dataset.vgaiReactStoryBoard==="true")return;const e=Rn();t.style.width=e.width===null?"100%":`${e.width}px`,t.style.height=e.height===null?"100%":`${e.height}px`}function Or(t,e,n,r,s,i,d){i?i.canvasSceneView.reset():co(),Tr();const x=bn();if(!i&&x?.config.resolution&&Jt(x.config.resolution.width,x.config.resolution.height),n.playState!=="stopped"){let u=!1,I=!1;const L=n.subscribe(()=>{u||I||n.playState!=="stopped"||(I=!0,u||Ue())});return()=>{u=!0,L()}}const v=x?.rootPath,y=r?[...r]:jn(e);if(y.length===0||!v)return()=>{};const w=v,z=uo(y.map(u=>({id:u.worldId,zOrder:u.zOrder}))).map(u=>y.find(I=>I.worldId===u.id)),j=new Map(z.map(u=>[u.worldId,u])),b=new Map,m=new Map,p=new Map,S=new Set,f=new Set,P=new Set;let D=!1,M=!1,k=!1;function X(){for(const u of m.values())try{u()}catch(I){Ft.error(`[design-time-layers] dispose failed: ${I}`,"authoring")}m.clear();for(const u of b.values())u.remove();b.clear();for(const u of z)s?.(u.worldId,null)}function V(){X();for(const u of S){const I=j.get(u);if(!I)continue;const L={id:I.worldId,kind:I.kind,entryOrScenePath:I.path,zOrder:I.zOrder,pausable:I.pausable};e.replaceChild(u,new It(n,L,"Design-time layer suspended by play mode — Stop restores it."))}S.clear(),n.notifyIngestEdit()}function W(u,I,L){const B=vt(u.kind);if(!B){f.add(u.worldId);return}f.delete(u.worldId);const G=(p.get(u.worldId)??0)+1;p.set(u.worldId,G);const A=Br(t,u,Lr+I,!!i);b.set(u.worldId,A);const xt={projectRootPath:w,store:n,...i?{view:i.canvasSceneView}:{},...d?{activationDocumentId:d}:{}};(async()=>B.mount(u,A,xt))().then(K=>{if(D||M||p.get(u.worldId)!==G){K.dispose();return}if(K.adapter)ge(e,u.worldId)&&(e.replaceChild(u.worldId,K.adapter),S.add(u.worldId)),s?.(u.worldId,K.adapter);else if(K.pick){const Q={id:u.worldId,kind:u.kind,entryOrScenePath:u.path,zOrder:u.zOrder,pausable:u.pausable};e.replaceChild(u.worldId,new It(n,Q,void 0,K.pick)),S.add(u.worldId)}m.set(u.worldId,K.dispose),Ge(u.worldId),n.notifyIngestEdit(),L?.()}).catch(K=>{if(p.get(u.worldId)!==G||(L?.(),A.remove(),b.get(u.worldId)===A&&b.delete(u.worldId),D||M))return;const Q=fo(K);Ft.error(`[design-time-layers] world "${u.worldId}" (${u.kind}) failed to mount: ${Q}`,"authoring");const ut={id:u.worldId,kind:u.kind,entryOrScenePath:u.path,zOrder:u.zOrder,pausable:u.pausable};s?.(u.worldId,null),ge(e,u.worldId)&&e.replaceChild(u.worldId,new It(n,ut,Q)),ho({worldId:u.worldId,kind:u.kind,identity:B.identity,message:Q}),n.notifyIngestEdit()})}z.forEach((u,I)=>{W(u,I)});function Mt(u,I){const L=m.get(u.worldId);m.delete(u.worldId);const B=b.get(u.worldId);b.delete(u.worldId),W(u,I,()=>{const A=b.get(u.worldId);if(A&&(A.style.visibility=""),L)try{L()}catch(xt){Ft.error(`[design-time-layers] re-projection dispose failed: ${xt}`,"authoring")}B?.remove()});const G=b.get(u.worldId);G&&G!==B&&(G.style.visibility="hidden")}function gt(u,I){const L=m.get(u.worldId);if(m.delete(u.worldId),L)try{L()}catch(G){Ft.error(`[design-time-layers] remount dispose failed: ${G}`,"authoring")}const B=b.get(u.worldId);B&&(B.remove(),b.delete(u.worldId)),W(u,I)}const Y=new Map;function Dt(){for(const[u,I]of Y)vt(u.kind)!==u&&(I(),Y.delete(u));for(const u of Pr()){if(Y.has(u)||vt(u.kind)!==u||!z.some(B=>B.kind===u.kind))continue;const I=[],L=B=>()=>{D||M||n.playState!=="stopped"||z.forEach((G,A)=>{G.kind===u.kind&&B(G,A)})};u.remountWhen&&I.push(u.remountWhen(L(gt))),u.reprojectWhen&&I.push(u.reprojectWhen(L(Mt))),Y.set(u,()=>{for(const B of I)B()})}}Dt();const mt=Mr(()=>{D||M||n.playState!=="stopped"||(z.forEach((u,I)=>{f.has(u.worldId)&&vt(u.kind)&&(P.delete(u.worldId),Ge(u.worldId),W(u,I))}),Dt())}),O=po(()=>{if(D||M)return;let u=!1;for(const I of z){if(!f.has(I.worldId)||P.has(I.worldId)||vt(I.kind)||(P.add(I.worldId),!ge(e,I.worldId)))continue;const L={id:I.worldId,kind:I.kind,entryOrScenePath:I.path,zOrder:I.zOrder,pausable:I.pausable};e.replaceChild(I.worldId,new It(n,L,`No package in this editor registered a design-time mount for a "${I.kind}" world, so there is nothing here to author it with. A build ships the packages its own entry in \`builds/\` lists.`)),u=!0}u&&n.notifyIngestEdit()}),se=ee(()=>{for(const u of b.values())Ce(u)}),ae=zn(()=>{for(const u of b.values())Ce(u)}),dt=n.subscribe(()=>{if(!M&&n.playState!=="stopped"){M=!0,V();return}if(M&&!k&&n.playState==="stopped"&&!D){k=!0,D||Ue();return}if(!M)for(const[u,I]of b)Pn(I,u,j.get(u)?.kind??"dom")});return()=>{D=!0;for(const u of Y.values())u();Y.clear(),mt(),O(),dt(),se(),ae(),X()}}const Mn=.1,Dn=4,Tn=.002,Ar=4;function ke(t,e,n){return e===1?t*16:e===2?t*n:t}function Fr(t,e){let n=ke(e.deltaX,e.deltaMode,e.bounds.width),r=ke(e.deltaY,e.deltaMode,e.bounds.height);if(e.ctrlKey||e.metaKey){const s=Math.min(Dn,Math.max(Mn,t.zoom*Math.exp(-r*Tn))),i=e.clientX-e.bounds.left,d=e.clientY-e.bounds.top,x=(i-t.x)/t.zoom,v=(d-t.y)/t.zoom;return{x:i-x*s,y:d-v*s,zoom:s}}return e.shiftKey&&n===0&&(n=r,r=0),{x:t.x-n,y:t.y-r,zoom:t.zoom}}function Yr(t,e){const n=ke(e.deltaY,e.deltaMode,e.bounds.height),r=Math.min(Dn,Math.max(Mn,t.zoom*Math.exp(-n*Tn))),s=e.clientX-e.bounds.left,i=e.clientY-e.bounds.top,d=(s-t.x)/t.zoom,x=(i-t.y)/t.zoom;return{x:s-d*r,y:i-x*r,zoom:r}}function me(t){return t instanceof Element&&t.closest('[data-vgai-canvas-navigation-ignore="true"]')!==null}function Ln(t,e,n,r={}){let s=null,i=!1,d="";const x=()=>t.querySelector('[data-testid="world-selection-overlay-interaction"]'),v=m=>{t.dataset.canvasPanning=m?"true":"false",t.style.cursor=m?"grabbing":"";const p=x();p&&(m?(d=p.style.cursor,p.style.cursor="grabbing"):p.style.cursor=d)},y=m=>{if(!s||m.pointerId!==s.pointerId)return;const p=s.button===1?4:2;if((m.buttons&p)===0){w(m);return}const S=m.clientX-s.startClientX,f=m.clientY-s.startClientY;if(!s.moved){if(Math.hypot(S,f)<=Ar)return;s.moved=!0,v(!0)}e.setPan(s.startPan.x+S,s.startPan.y+f)},w=m=>{if(!s||m.pointerId!==s.pointerId)return;const p=s.pointerId;s.button===2&&s.moved&&(i=!0),s=null,v(!1),t.hasPointerCapture?.(p)&&t.releasePointerCapture(p),window.removeEventListener("pointermove",y),window.removeEventListener("pointerup",w),window.removeEventListener("pointercancel",w)},E=m=>{const p=m.button===1,S=r.rightDragPans===!0&&m.button===2;!p&&!S||me(m.target)||(S&&(i=!1),m.preventDefault(),p&&m.stopPropagation(),s={pointerId:m.pointerId,button:m.button,startClientX:m.clientX,startClientY:m.clientY,startPan:e.get(),moved:p},t.setPointerCapture?.(m.pointerId),v(p),window.addEventListener("pointermove",y),window.addEventListener("pointerup",w),window.addEventListener("pointercancel",w))},z=m=>{m.button===1&&!me(m.target)&&m.preventDefault()},j=m=>{r.rightDragPans!==!0||!(s?.button===2&&s.moved)&&!i||(i=!1,m.preventDefault(),m.stopPropagation())},b=m=>{if(me(m.target))return;m.preventDefault(),m.stopPropagation();const p=n(e.get(),{clientX:m.clientX,clientY:m.clientY,deltaX:m.deltaX,deltaY:m.deltaY,deltaMode:m.deltaMode,ctrlKey:m.ctrlKey,metaKey:m.metaKey,shiftKey:m.shiftKey,bounds:t.getBoundingClientRect()});e.setView(p.x,p.y,p.zoom)};return t.addEventListener("pointerdown",E,!0),t.addEventListener("lostpointercapture",w,!0),t.addEventListener("mousedown",z,!0),t.addEventListener("contextmenu",j,!0),t.addEventListener("wheel",b,{capture:!0,passive:!1}),()=>{s=null,v(!1),t.removeEventListener("pointerdown",E,!0),t.removeEventListener("lostpointercapture",w,!0),t.removeEventListener("mousedown",z,!0),t.removeEventListener("contextmenu",j,!0),t.removeEventListener("wheel",b,!0),window.removeEventListener("pointermove",y),window.removeEventListener("pointerup",w),window.removeEventListener("pointercancel",w)}}function Nr(t,e=Pe){return Ln(t,e,Fr)}function Gr(t,e){return Ln(t,e,Yr,{rightDragPans:!0})}const Ie="#191c22",_r="rgba(255, 255, 255, 0.2)",jt=[],qe=new Set,Xr=[];function Hr(){return jt.length===0?Xr:jt}function Vr(t){for(let e=jt.length-1;e>=0;e--){const n=jt[e];if(n&&n.medium===t)return n}return null}function Wr(t){return jt.find(e=>e.documentId===t)??null}function Kr(t){return qe.add(t),()=>{qe.delete(t)}}function St(t){return t.map(e=>`“${e}”`).join(", ")}function Ur(t,e){const n=e.map(r=>r.worldId);return{tone:"error",title:n.length===1?`${t} root ${St(n)} failed`:`${n.length} ${t} roots failed`,description:`${e.map(r=>`${r.worldId} (${r.kind}, ${r.identity}): ${r.message}`).join(`
|
|
2
2
|
`)}
|
|
3
3
|
If this followed an edit, Undo (Ctrl+Z) restores the previous source and remounts.`}}function Zr(t,e){return{tone:"loading",title:e.length===0?`Loading ${t}`:e.length===1?`Loading ${t} root ${St(e)}`:`Loading ${e.length} ${t} roots`,description:e.length===0?"Reading the project declaration to identify the root that belongs here.":`Waiting for ${St(e)} to finish mounting.`}}function qr(t,e){return e.length===0?{tone:"neutral",title:`No ${t} root`,description:"No declared root belongs to this surface."}:{tone:"neutral",title:"No renderable content",description:(e.length===1?`Root ${St(e)} mounted successfully but currently produces no renderable content.`:`Roots ${St(e)} mounted successfully but currently produce no renderable content.`)+" If this world builds its content under its game systems, press Play (▶) to run it."}}function Jr(t){if(t.content==="present")return null;if(t.playSuspended)return{tone:"neutral",title:"Editing paused during Play",description:`${St(t.rootIds)} is running in the Game tab. Press Stop (⏹) to edit it here.`};const e=new Set(t.rootIds),n=(t.failures??[]).filter(i=>e.has(i.worldId));if(n.length>0)return Ur(t.surface,n);const r=(t.readiness??[]).filter(i=>i.state==="waiting"&&e.has(i.rootId)).map(i=>i.rootId),s=r.length>0?r:t.rootIds;return t.phase==="loading"||r.length>0||t.content==="unknown"?Zr(t.surface,s):qr(t.surface,t.rootIds)}const Qt=globalThis;function Re(){return Qt.__vgaiBreakpointListeners??=new Set,Qt.__vgaiBreakpointListeners}function Qr(){return Qt.__vgaiActiveBreakpoint??null}function ti(t){Qt.__vgaiActiveBreakpoint=t;for(const e of Re())e()}function ei(t){return Re().add(t),()=>Re().delete(t)}const $n="vgai:board-guides:v1";function Bn(){return typeof window>"u"?null:window.localStorage}function On(){try{return bn()?.rootPath??"(no-project)"}catch{return"(no-project)"}}function An(){try{return JSON.parse(Bn()?.getItem($n)??"{}")}catch{return{}}}function ni(t){try{Bn()?.setItem($n,JSON.stringify(t))}catch{}}const ze=new Set;let xe=null,Je=Date.now()%1e6;function Pt(){return xe||(xe=An()[On()]??{}),xe}function De(){const t=An();t[On()]=Pt(),ni(t);for(const e of ze)e()}const oi=[];function ie(t){return Pt()[t]??oi}function ri(t){return ze.add(t),()=>ze.delete(t)}function ii(t,e,n){Je+=1;const r=`guide-${Je}`;return Pt()[t]=[...ie(t),{id:r,axis:e,value:n}],De(),r}function Qe(t,e,n){Pt()[t]=ie(t).map(r=>r.id===e?{...r,value:n}:r),De()}function tn(t,e){Pt()[t]=ie(t).filter(n=>n.id!==e),De()}const q=16,be="rgba(255, 82, 82, 0.9)",en="rgba(18, 22, 26, 0.92)",_t="rgba(255, 255, 255, 0.28)";function si(t){return[10,25,50,100,250,500,1e3,2500,5e3].find(n=>n*t>=60)??1e4}function nn(t){return Math.abs(t)>=1e3?`${t/1e3}k`:String(t)}function ai({docId:t,containerRef:e}){const n=c.useSyncExternalStore(ee,ne),r=c.useSyncExternalStore(ri,()=>ie(t)),[s,i]=c.useState(null),d=c.useRef(null);c.useEffect(()=>{const p=e.current;if(!p)return;const S=p.getBoundingClientRect();return S.left,S.top,n.x,n.y,n.zoom,()=>void 0},[t,e,n.x,n.y,n.zoom]);const x=(p,S)=>Math.round((p-(S==="x"?n.x:n.y))/n.zoom),v=(p,S)=>(S==="x"?n.x:n.y)+p*n.zoom,y=p=>{const S=e.current?.getBoundingClientRect();return S?{x:p.clientX-S.left,y:p.clientY-S.top}:{x:0,y:0}},w=p=>S=>{S.preventDefault(),S.currentTarget.setPointerCapture(S.pointerId);const f=y(S);i({kind:"place",axis:p,id:null,at:p==="x"?f.x:f.y})},E=p=>S=>{S.preventDefault(),S.stopPropagation(),S.currentTarget.setPointerCapture(S.pointerId);const f=y(S);i({kind:"move",axis:p.axis,id:p.id,at:p.axis==="x"?f.x:f.y})},z=p=>{if(!s)return;const S=y(p),f=s.axis==="x"?S.x:S.y;i({...s,at:f}),s.kind==="move"&&s.id&&Qe(t,s.id,x(f,s.axis))},j=p=>{if(!s)return;const S=y(p),f=s.axis==="x"?S.x:S.y,P=f<=q;s.kind==="place"?P||ii(t,s.axis,x(f,s.axis)):s.id&&(P?tn(t,s.id):Qe(t,s.id,x(f,s.axis))),i(null)},b=p=>{const S=e.current,f=S?p==="x"?S.clientWidth:S.clientHeight:0,P=si(n.zoom),D=Math.ceil(x(q,p)/P)*P,M=x(f,p),k=[];for(let X=D;X<=M&&k.length<200;X+=P)k.push(X);return k},m={position:"absolute",background:en,zIndex:61,userSelect:"none",touchAction:"none",overflow:"hidden"};return a.jsxs("div",{ref:d,"data-testid":"board-rulers",style:{position:"absolute",inset:0,pointerEvents:"none",zIndex:60},onPointerMove:z,onPointerUp:j,children:[r.map(p=>{const S=v(p.value,p.axis),f=p.axis==="x";return a.jsx("div",{"data-testid":`board-guide-${p.axis}-${p.value}`,title:`${p.axis} = ${p.value} — drag to move, drop on the ruler or double-click to remove`,onPointerDown:E(p),onPointerMove:z,onPointerUp:j,onDoubleClick:()=>tn(t,p.id),style:{position:"absolute",pointerEvents:"auto",cursor:f?"col-resize":"row-resize",zIndex:60,...f?{left:S-2,top:0,bottom:0,width:5}:{top:S-2,left:0,right:0,height:5}},children:a.jsx("div",{style:{position:"absolute",background:be,...f?{left:2,top:0,bottom:0,width:1}:{top:2,left:0,right:0,height:1}}})},p.id)}),s&&a.jsx("div",{style:{position:"absolute",background:be,zIndex:62,...s.axis==="x"?{left:s.at,top:0,bottom:0,width:1}:{top:s.at,left:0,right:0,height:1}},children:a.jsx("span",{style:{position:"absolute",...s.axis==="x"?{top:q+4,left:4}:{left:q+4,top:4},fontSize:9,fontFamily:"ui-monospace, monospace",color:be,background:en,padding:"1px 3px",borderRadius:3,whiteSpace:"nowrap"},children:x(s.at,s.axis)})}),a.jsx("div",{"data-testid":"board-ruler-top",onPointerDown:w("y"),style:{...m,top:0,left:q,right:0,height:q,cursor:"row-resize",pointerEvents:"auto"},children:b("x").map(p=>a.jsx("span",{style:{position:"absolute",left:v(p,"x"),bottom:0,borderLeft:`1px solid ${_t}`,height:5},children:a.jsx("span",{style:{position:"absolute",left:2,bottom:3,fontSize:8,color:_t,fontFamily:"ui-monospace, monospace"},children:nn(p)})},p))}),a.jsx("div",{"data-testid":"board-ruler-left",onPointerDown:w("x"),style:{...m,top:q,left:0,bottom:0,width:q,cursor:"col-resize",pointerEvents:"auto"},children:b("y").map(p=>a.jsx("span",{style:{position:"absolute",top:v(p,"y"),right:0,borderTop:`1px solid ${_t}`,width:5},children:a.jsx("span",{style:{position:"absolute",top:1,right:3,fontSize:8,color:_t,fontFamily:"ui-monospace, monospace",writingMode:"vertical-rl"},children:nn(p)})},p))}),a.jsx(li,{}),a.jsx("div",{style:{...m,top:0,left:0,width:q,height:q,borderRight:`1px solid ${Kt.border}`,borderBottom:`1px solid ${Kt.border}`}})]})}function li(){const t=c.useSyncExternalStore(ei,Qr);return t?a.jsxs("button",{type:"button","data-testid":"board-breakpoint-pill",title:"Style edits are scoped to this breakpoint — click to return to Base",onClick:()=>ti(null),style:{position:"absolute",top:q+8,right:12,zIndex:62,pointerEvents:"auto",background:"rgba(18, 22, 26, 0.92)",color:Kt.accent,border:`1px solid ${Kt.accent}`,borderRadius:999,fontSize:10,padding:"3px 10px",cursor:"pointer"},children:["@ ",t," · editing this breakpoint — click to clear"]}):null}const on=new WeakMap;let rn=0;function Et(t){let e=on.get(t);return e||(e={guides:[],listeners:new Set,revision:0},on.set(t,e)),e}function Te(t){t.revision+=1;for(const e of t.listeners)e()}function Fn(t){return Et(t).guides}function Yn(t){return Et(t).revision}function Nn(t,e){const n=Et(t);return n.listeners.add(e),()=>n.listeners.delete(e)}function ci(t,e,n){rn+=1;const r=Et(t),s=`canvas-guide-${rn}`;return r.guides=[...r.guides,{id:s,axis:e,value:n}],Te(r),s}function Gn(t,e,n){const r=Et(t),s=r.guides.map(i=>i.id===e?{...i,value:n}:i);s.every((i,d)=>i===r.guides[d])||(r.guides=s,Te(r))}function di(t,e){const n=Et(t),r=n.guides.filter(s=>s.id!==e);r.length!==n.guides.length&&(n.guides=r,Te(n))}const sn="#111214";function _n(t){let e=32;for(;e*t<12;)e*=2;for(;e*t>48;)e/=2;return e}function ui(t){return _n(t)*t}function ye(t){if(t.length===0)return null;let e=Number.POSITIVE_INFINITY,n=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY,s=Number.NEGATIVE_INFINITY;for(const i of t)e=Math.min(e,i.x),n=Math.min(n,i.y),r=Math.max(r,i.x+i.width),s=Math.max(s,i.y+i.height);return{x:e,y:n,width:r-e,height:s-n}}function ve(t,e,n){if(!n||!(n.width>0)||!(n.height>0))return;const r=Math.max(1,t.clientWidth-96),s=Math.max(1,t.clientHeight-96),i=Math.min(4,Math.max(.1,Math.min(r/n.width,s/n.height)));e.setView(t.clientWidth/2-(n.x+n.width/2)*i,t.clientHeight/2-(n.y+n.height/2)*i,i)}function pi({view:t}){const e=oe();c.useSyncExternalStore(e.subscribe,e.getSnapshot);const n=c.useSyncExternalStore(t.subscribe,t.get,t.get);c.useSyncExternalStore(c.useCallback(d=>Nn(t,d),[t]),c.useCallback(()=>Yn(t),[t]));const r=Fn(t),s=ui(n.zoom),i=s*4;return a.jsxs("div",{"data-testid":"canvas-scene-backdrop",style:{position:"absolute",inset:0,zIndex:2,overflow:"hidden",pointerEvents:"none"},children:[e.showGrid&&a.jsx("div",{style:{position:"absolute",inset:0,backgroundImage:"linear-gradient(rgba(255,255,255,.075) 1px, transparent 1px),linear-gradient(90deg, rgba(255,255,255,.075) 1px, transparent 1px),linear-gradient(rgba(255,255,255,.14) 1px, transparent 1px),linear-gradient(90deg, rgba(255,255,255,.14) 1px, transparent 1px)",backgroundPosition:`${n.x}px ${n.y}px`,backgroundSize:`${s}px ${s}px, ${s}px ${s}px, ${i}px ${i}px, ${i}px ${i}px`}}),a.jsx("div",{"data-testid":"canvas-scene-origin-y",style:{position:"absolute",left:0,right:0,top:n.y,height:1,background:"rgba(238, 91, 91, .8)"}}),a.jsx("div",{"data-testid":"canvas-scene-origin-x",style:{position:"absolute",top:0,bottom:0,left:n.x,width:1,background:"rgba(87, 199, 126, .8)"}}),a.jsx("div",{style:{position:"absolute",left:n.x+6,top:n.y+6,color:"rgba(255,255,255,.68)",font:"10px ui-monospace, SFMono-Regular, Menlo, monospace"},children:"0, 0"}),r.map(d=>a.jsx("div",{"data-testid":`canvas-scene-guide-${d.axis}`,title:`${d.axis.toUpperCase()} ${Math.round(d.value*100)/100} · drag to move · right-click to remove`,onContextMenu:x=>{x.preventDefault(),di(t,d.id)},onPointerDown:x=>{x.preventDefault(),x.stopPropagation();const v=x.currentTarget.parentElement?.getBoundingClientRect();if(!v)return;const y=E=>{const z=d.axis==="x"?E.clientX-v.left:E.clientY-v.top,j=t.get();Gn(t,d.id,(z-(d.axis==="x"?j.x:j.y))/j.zoom)},w=()=>{window.removeEventListener("pointermove",y),window.removeEventListener("pointerup",w)};window.addEventListener("pointermove",y),window.addEventListener("pointerup",w,{once:!0})},style:{position:"absolute",pointerEvents:"auto",cursor:d.axis==="x"?"ew-resize":"ns-resize",...d.axis==="x"?{left:n.x+d.value*n.zoom-4,top:20,bottom:0,width:9,borderLeft:"1px solid rgba(74, 180, 255, .95)"}:{top:n.y+d.value*n.zoom-4,left:20,right:0,height:9,borderTop:"1px solid rgba(74, 180, 255, .95)"}}},d.id)),a.jsx(fi,{view:t})]})}function fi({view:t}){const e=c.useSyncExternalStore(t.subscribe,t.get,t.get),n=c.useRef(null),r=c.useRef(null),[s,i]=c.useState({width:0,height:0});c.useEffect(()=>{const E=()=>{const j=n.current?.clientWidth??0,b=r.current?.clientHeight??0;i(m=>m.width===j&&m.height===b?m:{width:j,height:b})};if(E(),typeof ResizeObserver>"u")return;const z=new ResizeObserver(E);return n.current&&z.observe(n.current),r.current&&z.observe(r.current),()=>z.disconnect()},[]);const d=(E,z)=>{if(!(z>0))return[];const j=E==="x"?e.x:e.y,b=_n(e.zoom),m=b*e.zoom,p=20,S=Math.ceil((p-j)/m),f=Math.floor((p+z-j)/m);return Array.from({length:Math.max(0,f-S+1)},(P,D)=>{const M=S+D;return{major:M%4===0,screen:j+M*m-p,value:M*b}})},x=d("x",s.width),v=d("y",s.height),y=(E,z)=>{z.preventDefault(),z.stopPropagation();const j=z.currentTarget.parentElement?.getBoundingClientRect();if(!j)return;const b=(f,P)=>{const D=t.get();return((E==="x"?f-j.left:P-j.top)-(E==="x"?D.x:D.y))/D.zoom},m=ci(t,E,b(z.clientX,z.clientY)),p=f=>Gn(t,m,b(f.clientX,f.clientY)),S=()=>{window.removeEventListener("pointermove",p),window.removeEventListener("pointerup",S)};window.addEventListener("pointermove",p),window.addEventListener("pointerup",S,{once:!0})},w={position:"absolute",pointerEvents:"auto",backgroundColor:"rgba(24, 26, 30, .96)",border:0,borderColor:"rgba(255,255,255,.14)",boxSizing:"border-box"};return a.jsxs(a.Fragment,{children:[a.jsx("button",{ref:n,type:"button","data-testid":"canvas-scene-ruler-x","aria-label":"Horizontal ruler; drag to create a horizontal guide",onPointerDown:E=>y("y",E),style:{...w,left:20,right:0,top:0,height:20,borderBottomStyle:"solid",borderBottomWidth:1,cursor:"row-resize",padding:0,overflow:"hidden"},children:x.map(E=>a.jsx("span",{"aria-hidden":"true","data-ruler-axis":"x","data-ruler-value":E.value,style:{position:"absolute",left:E.screen,bottom:0,width:1,height:E.major?8:4,background:E.major?"rgba(255,255,255,.5)":"rgba(255,255,255,.28)",pointerEvents:"none"},children:E.major&&a.jsx("span",{style:{position:"absolute",left:3,bottom:5,color:"rgba(255,255,255,.62)",font:"9px ui-monospace, SFMono-Regular, Menlo, monospace",lineHeight:1,whiteSpace:"nowrap"},children:E.value})},E.value))}),a.jsx("button",{ref:r,type:"button","data-testid":"canvas-scene-ruler-y","aria-label":"Vertical ruler; drag to create a vertical guide",onPointerDown:E=>y("x",E),style:{...w,top:20,bottom:0,left:0,width:20,borderRightStyle:"solid",borderRightWidth:1,cursor:"col-resize",padding:0,overflow:"hidden"},children:v.map(E=>a.jsx("span",{"aria-hidden":"true","data-ruler-axis":"y","data-ruler-value":E.value,style:{position:"absolute",top:E.screen,right:0,width:E.major?8:4,height:1,background:E.major?"rgba(255,255,255,.5)":"rgba(255,255,255,.28)",pointerEvents:"none"},children:E.major&&a.jsx("span",{style:{position:"absolute",right:4,top:3,color:"rgba(255,255,255,.62)",font:"9px ui-monospace, SFMono-Regular, Menlo, monospace",lineHeight:1,whiteSpace:"nowrap",writingMode:"vertical-rl",transform:"rotate(180deg)"},children:E.value})},E.value))}),a.jsx("div",{style:{...w,left:0,top:0,width:20,height:20}})]})}function hi({active:t,adapter:e,containerRef:n,view:r}){const s=oe();c.useSyncExternalStore(s.subscribe,s.getSnapshot);const i=c.useSyncExternalStore(r.subscribe,r.get,r.get),d=c.useCallback(w=>{const E=n.current;if(!E)return;const z=Math.min(4,Math.max(.1,w)),j=E.clientWidth/2,b=E.clientHeight/2,m=(j-i.x)/i.zoom,p=(b-i.y)/i.zoom;r.setView(j-m*z,b-p*z,z)},[n,i,r]),x=c.useCallback(w=>{if(!e?.rects)return[];const E=[];for(const z of w){const j=e.rects.rect(z);j&&j.width>0&&j.height>0&&E.push(j)}return E},[e]),v=c.useCallback(()=>{const w=n.current;w&&ve(w,r,ye(x(s.selectedEntityIds)))},[n,x,s,r]),y=c.useCallback(()=>{const w=n.current;!w||!e||ve(w,r,ye(x(vn(e))))},[e,n,x,r]);return c.useEffect(()=>{if(t)return s.onViewportAction(w=>{if(w.type==="focus-entity"){const E=n.current;if(!E)return;ve(E,r,ye(x([w.id])))}else w.type==="focus-selection"?v():w.type==="focus-scene"&&y()})},[t,n,y,v,x,s,r]),a.jsxs(a.Fragment,{children:[a.jsx(wr,{}),a.jsx(mo,{dimensions:"2d"}),a.jsxs(Ut,{label:"2D scene display",className:"vgai-viewport-toolbar vgai-viewport-toolbar-right","data-vgai-canvas-navigation-ignore":"true",children:[a.jsx(xo,{text:`Grid: ${s.showGrid?"On":"Off"}`,children:a.jsx(et,{"aria-label":"Toggle 2D grid","aria-pressed":s.showGrid,size:"comfortable",onClick:()=>s.toggleGrid(),children:a.jsx(nt,{icon:bo,size:"md"})})}),a.jsx(Zt,{"aria-label":"Frame all",variant:"ghost",size:"comfortable",onClick:y,children:"Frame all"})]}),a.jsxs(Ut,{label:"2D scene navigation",className:"vgai-canvas-scene-navigation","data-vgai-canvas-navigation-ignore":"true",children:[a.jsx(et,{"aria-label":"Frame selection",title:"Frame selection",size:"comfortable",disabled:s.selectedEntityIds.size===0,onClick:v,children:a.jsx(nt,{icon:wn,size:"md"})}),a.jsx(et,{"aria-label":"Zoom out",title:"Zoom out",size:"comfortable",onClick:()=>d(i.zoom/1.2),children:a.jsx(nt,{icon:Sn,size:"md"})}),a.jsxs(Zt,{variant:"ghost","aria-label":"Reset zoom to 100%",title:"Reset zoom to 100%",size:"comfortable",onClick:()=>d(1),children:[Math.round(i.zoom*100),"%"]}),a.jsx(et,{"aria-label":"Zoom in",title:"Zoom in",size:"comfortable",onClick:()=>d(i.zoom*1.2),children:a.jsx(nt,{icon:En,size:"md"})})]})]})}const an={fill:null,desktop:{width:1440,height:900},tablet:{width:768,height:1024},mobile:{width:390,height:844}};function gi({boardViewport:t,containerRef:e,selectViewport:n,viewportValue:r}){return a.jsxs(a.Fragment,{children:[a.jsxs(yo,{"aria-label":"Responsive viewport",title:t?.locked?"Viewport is locked by this story’s globals.viewport":"Responsive viewport",value:r,disabled:t?.locked===!0,onChange:s=>n(s.target.value),className:"vgai-react-viewport-select",children:[a.jsx("option",{value:"fill",children:"Responsive"}),t?t.choices.map(s=>a.jsxs("option",{value:s.id,children:[s.label," · ",s.width,"×",s.height]},s.id)):a.jsxs(a.Fragment,{children:[a.jsx("option",{value:"desktop",children:"Desktop · 1440×900"}),a.jsx("option",{value:"tablet",children:"Tablet · 768×1024"}),a.jsx("option",{value:"mobile",children:"Mobile · 390×844"})]})]}),t&&a.jsx(et,{"aria-label":"Rotate viewport",title:t.locked?"Viewport is locked by this story’s globals.viewport":"Rotate viewport",size:"comfortable",disabled:t.locked,onClick:()=>Ir(e.current),children:a.jsx(nt,{icon:vo,size:"md"})})]})}function mi({containerRef:t,context:e,boardOnly:n=!1}){const r=oe();c.useSyncExternalStore(r.subscribe,r.getSnapshot);const s=c.useSyncExternalStore(ee,ne),i=c.useSyncExternalStore(zn,Rn),d=c.useSyncExternalStore(Sr,()=>Er(t.current),()=>null),x=c.useCallback(b=>{const m=t.current;if(!m)return;const p=Math.min(4,Math.max(.1,b)),S=m.clientWidth/2,f=m.clientHeight/2,P=(S-s.x)/s.zoom,D=(f-s.y)/s.zoom;Yt(S-P*p,f-D*p,p)},[t,s]),v=c.useCallback(()=>{const b=t.current,m=[...r.selectedEntityIds].at(-1);if(!b||!m)return;const p=e?.adapter.rects?.rect(m);if(!p||p.width<=0||p.height<=0)return;const S=Math.max(1,b.clientWidth-96),f=Math.max(1,b.clientHeight-96),P=Math.min(4,Math.max(.1,Math.min(S/p.width,f/p.height)));Yt(b.clientWidth/2-(p.x+p.width/2)*P,b.clientHeight/2-(p.y+p.height/2)*P,P)},[t,e,r]),y=c.useCallback(b=>{const m=t.current;if(d){Cr(m,b==="fill"?null:b);return}const p=an[b];if(!m||p===null){Jt(null,null),Yt(0,0,1);return}Jt(p.width,p.height);const S=Math.min(1,Math.max(.1,Math.min((m.clientWidth-96)/p.width,(m.clientHeight-96)/p.height)));Yt((m.clientWidth-p.width*S)/2,(m.clientHeight-p.height*S)/2,S)},[d,t]),w=c.useCallback(()=>{const b=t.current;b&&kr(b)},[t]),E=d!==null,z=e?.kind==="dom"&&!!e.adapter.rects;if(n?!E:!z)return null;const j=d?d.selectedViewportId??"fill":Object.entries(an).find(([,b])=>b===null?i.width===null:b.width===i.width&&b.height===i.height)?.[0]??"fill";return a.jsxs(a.Fragment,{children:[!E&&i.width!==null&&i.height!==null&&a.jsx("div",{"data-testid":"react-canvas-device-frame",style:{position:"absolute",left:0,top:0,zIndex:0,width:i.width,height:i.height,transform:je(s),transformOrigin:"0 0",pointerEvents:"none",background:"#fff",boxShadow:"0 0 0 1px #ffffff40, 0 8px 30px #0009"}}),a.jsxs(Ut,{label:n?"2D component board view":"React canvas view","data-testid":n?"canvas-board-zoom-controls":"react-canvas-zoom-controls","data-vgai-canvas-navigation-ignore":"true",className:"vgai-react-canvas-controls",children:[!n&&a.jsx(gi,{boardViewport:d,containerRef:t,selectViewport:y,viewportValue:j}),E&&a.jsx(Zt,{variant:"ghost","aria-label":"Fit story board",title:"Fit all stories",size:"comfortable",onClick:w,children:"Fit board"}),a.jsx(et,{"aria-label":"Zoom out",title:"Zoom out",size:"comfortable",onClick:()=>x(s.zoom/1.2),children:a.jsx(nt,{icon:Sn,size:"md"})}),a.jsxs(Zt,{variant:"ghost","aria-label":"Reset zoom to 100%",title:"Reset zoom to 100%",size:"comfortable",onClick:()=>x(1),children:[Math.round(s.zoom*100),"%"]}),a.jsx(et,{"aria-label":"Zoom in",title:"Zoom in",size:"comfortable",onClick:()=>x(s.zoom*1.2),children:a.jsx(nt,{icon:En,size:"md"})}),!n&&a.jsx(et,{"aria-label":"Zoom to selection",title:"Zoom to selection",size:"comfortable",onClick:v,children:a.jsx(nt,{icon:wn,size:"md"})})]})]})}let xi=null;const ln=new Set;function bi(){return xi!==null}function yi(t){return ln.add(t),()=>ln.delete(t)}const vi=new Set(["","transparent","rgba(0, 0, 0, 0)"]);function wi(t){return vi.has(t)}function Si(t){for(const e of t)if(!wi(e))return e;return"#fff"}function cn(t,e){for(const n of e){const r=J(t,n.id);if(!r)continue;const s={};n.x!==void 0&&(s.x=n.x),n.y!==void 0&&(s.y=n.y),Object.keys(s).length!==0&&(r.begin(n.id),r.apply(n.id,s),r.end(n.id))}}const Ei=[{op:"left",testId:"align-left",label:"Align left",icon:_e},{op:"hcenter",testId:"align-hcenter",label:"Align horizontal center",icon:Xe},{op:"right",testId:"align-right",label:"Align right",icon:He},{op:"top",testId:"align-top",label:"Align top",icon:_e,rotate:!0},{op:"vcenter",testId:"align-vcenter",label:"Align vertical center",icon:Xe,rotate:!0},{op:"bottom",testId:"align-bottom",label:"Align bottom",icon:He,rotate:!0}],Ci=[{axis:"horizontal",testId:"distribute-horizontal",label:"Distribute horizontally",icon:Co},{axis:"vertical",testId:"distribute-vertical",label:"Distribute vertically",icon:ko}];function ki(t){const r=t.y-30-8;return{left:t.x,top:r<0?t.y+t.height+8:r}}function Ii({adapter:t,entries:e}){if(e.length<2)return null;const n=wo(e.map(d=>d.rect));if(!n)return null;const{left:r,top:s}=ki(n),i=e.length>=3;return a.jsxs(Ut,{label:"Align and distribute","data-testid":"align-toolbar",style:{position:"absolute",left:r,top:s,zIndex:re.overlayLow,gap:2,padding:3},children:[Ei.map(({op:d,testId:x,label:v,icon:y,rotate:w})=>a.jsx(et,{"data-testid":x,title:v,"aria-label":v,variant:"ghost",size:"compact",onClick:()=>cn(t,So(e,d)),children:a.jsx(nt,{icon:y,"aria-hidden":"true",style:w?{transform:"rotate(90deg)"}:void 0})},d)),i&&a.jsxs(a.Fragment,{children:[a.jsx(Eo,{}),Ci.map(({axis:d,testId:x,label:v,icon:y})=>a.jsx(et,{"data-testid":x,title:v,"aria-label":v,variant:"ghost",size:"compact",onClick:()=>cn(t,Io(e,d)),children:a.jsx(nt,{icon:y,"aria-hidden":"true"})},d))]})]})}function Ri({rect:t,initialText:e,onCommit:n,onCancel:r}){const[s,i]=c.useState(e),d=c.useRef(null),x=c.useRef(!1);c.useEffect(()=>{const w=d.current;w&&(w.focus(),w.select())},[]);const v=()=>{x.current||(x.current=!0,n(s))},y=()=>{x.current||(x.current=!0,r())};return a.jsx(Ro,{ref:d,"data-testid":"world-text-editor",value:s,onChange:w=>i(w.target.value),onBlur:v,onKeyDown:w=>{w.key==="Escape"?(w.stopPropagation(),y()):w.key==="Enter"&&!w.shiftKey&&(w.preventDefault(),v())},"data-variant":"inline-editor",style:{position:"absolute",left:t.x,top:t.y,width:Math.max(t.width,40),height:Math.max(t.height,20),boxSizing:"border-box",zIndex:re.overlayLow,pointerEvents:"auto",resize:"none"}})}const _=zt.accent.default,zi=re.overlayLow,te=5;function ji(t,e,n){return t?!1:Me()?.editorControls?.activate(e,n)??!1}function Pi(t,e,n,r,s,i){const d=t?null:Me()?.editorControls?.hover(e,n)??null;s(d),i(d?null:r(e,n))}function Mi(t,e){const n=t.hierarchy.node(e);return n?`${n.label}·${n.kind}`:e}function Di(t){return t instanceof In?t.childAdapters().some(e=>!!e.adapter.rects):!!t.rects}function Ti(t){const e=t instanceof In?t.childAdapters():[{worldId:"",adapter:t}],n=[];for(const{worldId:r,adapter:s}of e)if(s.rects&&!(r&&yn(r)))for(const i of vn(s)){if(s.inspector?.get(i,"locked")===!0)continue;const d=s.rects.rect(i);d&&n.push({id:i,rect:d})}return n}function Li(t,e){return t.x<e.x+e.width&&t.x+t.width>e.x&&t.y<e.y+e.height&&t.y+t.height>e.y}function $i(t,e,n){if(!n)return[e];const r=new Set(t);return r.has(e)?r.delete(e):r.add(e),[...r]}function Bi(t,e,n,r){return e&&!!n&&(n.width>te||n.height>te)&&n?Ti(t).filter(d=>Li(n,d.rect)).map(d=>d.id):r?null:[]}function Oi(t,e,n,r){return t?"grabbing":e?"grab":n||r?"crosshair":"default"}function ct(t){try{t.currentTarget.setPointerCapture?.(t.pointerId)}catch{}}function we(t){t.currentTarget.hasPointerCapture?.(t.pointerId)&&t.currentTarget.releasePointerCapture?.(t.pointerId)}function Ai(t,e){if(e!==null)return!1;const n=t.currentTarget.parentElement?.parentElement??null;return zr(n,t.clientX,t.clientY)}function dn(t,e){return{position:"absolute",left:t.x,top:t.y,width:t.width,height:t.height,border:`${e?2:1}px solid ${_}`,background:e?`color-mix(in srgb, ${_} 6%, transparent)`:"transparent",boxSizing:"border-box",pointerEvents:"none"}}function Fi(t){return{position:"absolute",left:t.x,top:Math.max(0,t.y-18),padding:"2px 6px",fontSize:11,fontFamily:"'SF Mono', 'Fira Code', Menlo, Consolas, monospace",fontWeight:600,color:"#fff",background:_,borderRadius:3,pointerEvents:"none",whiteSpace:"nowrap"}}const Xt=10,un=48;function pn(t,e){return{position:"absolute",left:t.x-Xt/2,top:t.y-Xt/2,width:Xt,height:Xt,background:"#fff",border:`1px solid ${_}`,boxSizing:"border-box",cursor:e,pointerEvents:"auto"}}const wt=12,Yi=24;function Ni(t){return{position:"absolute",left:t.x+t.width/2-wt/2,top:t.y-Yi-wt/2,width:wt,height:wt,borderRadius:"50%",background:"#fff",border:`1px solid ${_}`,boxSizing:"border-box",cursor:"grab",padding:0,pointerEvents:"auto"}}const fn=12;function Gi(t){return{position:"absolute",left:t.position[0],top:t.position[1],width:fn,height:fn,borderRadius:"50%",background:t.writable?t.color:"transparent",border:`2px solid ${t.color}`,boxSizing:"border-box",cursor:t.writable?"grab":"not-allowed",padding:0,pointerEvents:t.writable?"auto":"none",touchAction:"none"}}function _i(t){return{position:"absolute",left:t.x-8,top:t.y-8,width:16,height:16,display:"grid",placeItems:"center",borderRadius:t.kind==="anchor"?"50%":2,background:"#fff",border:`1px solid ${_}`,boxSizing:"border-box",color:_,cursor:"crosshair",fontSize:9,fontFamily:"'SF Mono', 'Fira Code', Menlo, Consolas, monospace",fontWeight:700,lineHeight:1,padding:0,pointerEvents:"auto",touchAction:"none"}}function Xi(t){return{position:"absolute",left:t.x,top:t.y+t.height+4,padding:"2px 6px",fontSize:11,fontFamily:"'SF Mono', 'Fira Code', Menlo, Consolas, monospace",fontWeight:600,color:"#fff",background:_,borderRadius:3,pointerEvents:"none",whiteSpace:"nowrap"}}const Hi="rgba(46, 204, 113, 0.25)",Vi="rgba(230, 126, 34, 0.25)";function Wi(t){return{position:"absolute",left:t.x,top:t.y,width:t.width,height:t.height,background:t.kind==="padding"?Hi:Vi,boxSizing:"border-box",cursor:t.cursor,pointerEvents:"auto"}}function Ki(t){return{position:"absolute",left:t.labelX,top:t.labelY,transform:"translate(-50%, -50%)",fontSize:10,fontFamily:"monospace",color:t.kind==="padding"?"#1b7a3d":"#a35a12",background:"rgba(255,255,255,0.85)",padding:"0 2px",borderRadius:2,pointerEvents:"none",whiteSpace:"nowrap"}}function Ui(t){return{position:"absolute",left:t.x,top:t.y,width:t.width,height:t.height,border:`2px dashed ${_}`,background:`color-mix(in srgb, ${_} 15%, transparent)`,boxSizing:"border-box",pointerEvents:"none",opacity:.7}}function Zi(t){return{position:"absolute",left:t.x,top:t.y,width:t.width,height:t.height,background:"#ff5fa2",borderRadius:2,pointerEvents:"none"}}const Le="#ff2d92",Ht=6;function qi(t){const e=t.orientation==="horizontal";return{position:"absolute",left:Math.min(t.x1,t.x2),top:Math.min(t.y1,t.y2),width:e?Math.abs(t.x2-t.x1):1,height:e?1:Math.abs(t.y2-t.y1),background:Le,pointerEvents:"none"}}function hn(t,e,n){return{position:"absolute",left:n?t:t-Ht/2,top:n?e-Ht/2:e,width:n?1:Ht,height:n?Ht:1,background:Le,pointerEvents:"none"}}function Ji(t){return{position:"absolute",left:t.labelX,top:t.labelY,transform:"translate(-50%, -50%)",padding:"1px 4px",fontSize:10,fontFamily:"monospace",fontWeight:600,color:"#fff",background:Le,borderRadius:2,pointerEvents:"none",whiteSpace:"nowrap"}}const gn="#f24822";function Qi(t){const e=t.orientation==="vertical";return{position:"absolute",left:e?t.at:t.start,top:e?t.start:t.at,width:e?1:t.end-t.start,height:e?t.end-t.start:1,borderLeft:e?`1px dashed ${gn}`:void 0,borderTop:e?void 0:`1px dashed ${gn}`,pointerEvents:"none"}}function ts(t){return{position:"absolute",left:t.x,top:Math.max(0,t.y-36),display:"flex",gap:4,pointerEvents:"none"}}const mn={padding:"2px 6px",fontSize:10,fontFamily:"'SF Mono', 'Fira Code', Menlo, Consolas, monospace",fontWeight:600,color:zt.content.onAccent,background:`color-mix(in srgb, ${_} 85%, transparent)`,borderRadius:3,whiteSpace:"nowrap"};function es(t){return{position:"absolute",left:t.x,top:t.y,width:t.width,height:t.height,border:`1px dashed color-mix(in srgb, ${_} 45%, transparent)`,boxSizing:"border-box",pointerEvents:"none"}}function xn(t,e,n){return e&&n>0?Math.round(t/n)*n:t}function ns(t,e,n,r,s,i){const d=t.nativeHandleSpan??1,x=t.nativeScaleAxis??"both";let v,y;if(x==="x")v=1+e/d,y=1;else if(x==="y")v=1,y=1+n/d;else{const w=1+(e+n)/(Math.SQRT2*d);v=w,y=w}return{...x!=="y"?{scaleXFactor:v}:{},...x!=="x"?{scaleYFactor:y}:{},...r&&!s?{scaleStep:i}:{}}}function os(t,e,n,r,s,i){const d=t.nativeOrigin;if(!d)return{};const x=r&&!s;return{...t.moveAxis!=="y"?{originX:xn(d.x+e,x,i)}:{},...t.moveAxis!=="x"?{originY:xn(d.y+n,x,i)}:{}}}function rs(t,e,n){return t==="x"?{x:e.x+n,y:e.y}:t==="y"?{x:e.x,y:e.y+n}:{x:e.x+n/Math.SQRT2,y:e.y+n/Math.SQRT2}}function is(t,e,n){return t==="x"?{dx:e,dy:0}:t==="y"?{dx:0,dy:n}:{dx:e,dy:n}}function ss(t,e){t.ownerBoxEdit.begin(t.id);for(const n of t.peers)n.ownerBoxEdit.begin(n.id);return{kind:"move",id:t.id,ownerBoxEdit:t.ownerBoxEdit,startLocal:e,origRect:t.origRect,context:t.context,...t.nativeOrigin?{nativeOrigin:t.nativeOrigin}:{},movePeers:t.peers}}function as(t,e,n){let r=e;for(let s=0;r!==null&&s<256;s++){if(n.has(r))return r;r=t.hierarchy.node(r)?.parentId??null}return null}function ls(t,e,n){const r=J(t,e);if(!r)return null;const s=t.inspector?.get(e,"style.position"),i=Se(t,e)==="2d";if(s!=="absolute"&&s!=="fixed"&&!i)return null;const d=F(t,e);if(!d)return null;const x=i?r.gizmoOrigin?.(e)??void 0:void 0,v=[];for(const y of n){if(y===e)continue;const w=J(t,y),E=F(t,y);if(!w||!E)continue;const z=t.inspector?.get(y,"style.position"),j=Se(t,y)==="2d";if(z!=="absolute"&&z!=="fixed"&&!j)continue;const b=j?w.gizmoOrigin?.(y)??void 0:void 0;v.push({id:y,ownerBoxEdit:w,origRect:E,...b?{nativeOrigin:b}:{}})}return{id:e,ownerBoxEdit:r,origRect:d,context:Rt(t,e),...x?{nativeOrigin:x}:{},peers:v}}function cs(t,e){if(!Wo(t,e)?.reorder)return null;const r=Ko(t,e);if(!r||r.length<3)return null;const s=F(t,e);if(!s)return null;const i=[];for(const d of r){if(d===e)continue;const x=F(t,d);x&&i.push({id:d,rect:x})}return i.length===0?null:{id:e,adapter:t,origRect:s,siblingRects:i}}function ds(){return Uo()}function us(t,e){if(e.size!==1)return null;const n=[...e][0],r=J(t,n);if(!r)return null;const s=F(t,n);if(!s)return null;const i=Zo(s,qo(t,n));return{id:n,rect:s,ownerBoxEdit:r,spacingBands:i}}function ps(t,e){if(e.size<2)return null;const n=[];for(const r of e){const s=F(t,r);if(!s||!J(t,r))return null;n.push({id:r,rect:s})}return n}function fs(t,e,n){const r=e.size===1?[...e][0]:null,s=r?F(t,r):null,i=s&&n?Jo(s,n):[],d=r?Qo(t,r):null,x=!!(d&&(d.position||d.parentLayout)),v=r?Rt(t,r)?.parent??null:null;return{selectedSingleRect:s,measureLines:i,positionBadge:d,showPositionBadge:x,parentRect:v}}function hs({state:t,adapter:e,onClose:n}){const r=c.useRef(null);return c.useEffect(()=>{const s=d=>{r.current?.contains(d.target)||n()},i=d=>{d.key==="Escape"&&n()};return document.addEventListener("pointerdown",s),document.addEventListener("keydown",i),()=>{document.removeEventListener("pointerdown",s),document.removeEventListener("keydown",i)}},[n]),a.jsx(tr,{children:a.jsx(er,{ref:r,"aria-label":"Pick object under pointer","data-testid":"viewport-pick-menu",style:{position:"fixed",left:t.x,top:t.y,minWidth:190,maxWidth:320,zIndex:re.dropdown},children:t.ids.map(s=>{const i=e.hierarchy.node(s);return a.jsxs(nr,{"data-testid":"viewport-pick-menu-item",onSelect:()=>{kn(e,[s]),n()},style:{justifyContent:"space-between",gap:20},children:[a.jsx("span",{children:i?.label??s}),a.jsx("span",{style:{color:zt.content.muted,fontSize:11},children:i?.kind??""})]},s)})})})}function gs({adapter:t,view:e,transformModeAware:n=!1}={}){const r=oe(),s=c.useSyncExternalStore(r.subscribe,r.getSnapshot),i=t??Cn(r),d=c.useCallback((o,l)=>t?t.pickable?.pick(o,l)??null:zo(r,o,l),[t,r]),x=c.useRef(null),v=c.useRef(null),y=c.useRef(null),[w,E]=c.useState(null),[z,j]=c.useState(null),[b,m]=c.useState(null),[p,S]=c.useState(null),f=c.useRef(null),P=c.useCallback((o,l)=>{const g=jo(r,o,l,{...t?{adapter:t}:{}});if(g.length===0){S(null);return}S({x:o,y:l,ids:g})},[t,r]);c.useEffect(()=>{const o=g=>{const h=f.current;!h||h.pointerId!==g.pointerId||h.moved||Math.hypot(g.clientX-h.startClientX,g.clientY-h.startClientY)>te&&(h.moved=!0)},l=g=>{const h=f.current;!h||h.pointerId!==g.pointerId||(f.current=null,g.type==="pointerup"&&!h.moved&&P(g.clientX,g.clientY))};return window.addEventListener("pointermove",o),window.addEventListener("pointerup",l),window.addEventListener("pointercancel",l),()=>{window.removeEventListener("pointermove",o),window.removeEventListener("pointerup",l),window.removeEventListener("pointercancel",l)}},[P]);const D=c.useCallback(o=>{o.preventDefault(),o.stopPropagation()},[]),M=e??Pe,k=c.useSyncExternalStore(M.subscribe,M.get,M.get);c.useSyncExternalStore(c.useCallback(o=>Nn(M,o),[M]),c.useCallback(()=>Yn(M),[M]));const X=n?Fn(M):[],V=n?1/k.zoom:1,W=c.useRef(!1),[Mt,gt]=c.useState(!1),Y=c.useRef(null),[Dt,mt]=c.useState(!1),O=c.useRef(null);c.useEffect(()=>()=>{const o=O.current;if(O.current=null,!!o){o.ownerBoxEdit.end(o.id);for(const l of o.movePeers??[])l.ownerBoxEdit.end(l.id)}},[]);const[,se]=c.useState(0),[ae,dt]=c.useState(null),[u,I]=c.useState([]),L=c.useRef(null),[B,G]=c.useState(null),A=c.useCallback(o=>{L.current=o,G(o)},[]),xt=c.useRef(null),[$e,K]=c.useState(null),[Q,ut]=c.useState(null),pt=c.useCallback(o=>{xt.current=o,K(o)},[]),le=c.useRef(null),Be=c.useRef(null);c.useEffect(()=>{const o=le.current;if(!o)return;le.current=null;const l=pe(i,o.id);l&&l.get(o.id)===null&&ut({id:o.id,rect:o.rect})},[s]);const Oe=c.useRef("");c.useEffect(()=>{const o=[...r.selectedEntityIds].sort().join(",");o!==Oe.current&&(Oe.current=o,Q&&ut(null))}),c.useEffect(()=>{if(!Q)return;const o=window.setTimeout(()=>ut(null),4e3);return()=>window.clearTimeout(o)},[Q]);const st=c.useSyncExternalStore(yi,bi),[Xn,Ae]=c.useState(null),tt=c.useCallback(o=>{y.current=o,E(o)},[]),T=c.useCallback((o,l)=>{const g=x.current?.getBoundingClientRect();return{x:(o-(g?.left??0)-k.x)/k.zoom,y:(l-(g?.top??0)-k.y)/k.zoom}},[k.x,k.y,k.zoom]),Hn=c.useCallback(o=>{!e||!n||!i.assetDrop||!o.dataTransfer.types.includes("application/x-editor-asset")||(o.preventDefault(),o.dataTransfer.dropEffect="copy")},[i.assetDrop,e,n]),Vn=c.useCallback(o=>{if(!e||!n||!i.assetDrop)return;const l=o.dataTransfer.getData("application/x-editor-asset");if(!l)return;let g;try{g=JSON.parse(l)}catch{return}const h=T(o.clientX,o.clientY),C={position:[h.x,h.y,0],item:g.component??{kind:"file",name:g.name??g.path.split("/").pop()??g.path}};i.assetDrop.accepts("",g.path,C)&&(o.preventDefault(),o.stopPropagation(),Po(i,"",g.path,C))},[i.assetDrop,e,T,n]),at=c.useCallback(()=>se(o=>o+1),[]),Tt=c.useCallback(()=>{const o=O.current;if(!o)return!1;O.current=null,o.ownerBoxEdit.end(o.id);for(const l of o.movePeers??[])l.ownerBoxEdit.end(l.id);return dt(null),I([]),at(),!0},[at]),Wn=c.useCallback((o,l)=>{if(l.stopPropagation(),l.button!==0)return;const g=r.selectedEntityIds;if(g.size!==1)return;const h=[...g][0],C=J(i,h),R=F(i,h);if(!C||!R)return;const $=i.inspector?.get(h,"style.position"),it=Se(i,h)==="2d";ct(l),C.begin(h),O.current={kind:"resize",id:h,ownerBoxEdit:C,startLocal:T(l.clientX,l.clientY),origRect:R,pos:o,isPositioned:$==="absolute"||$==="fixed"||it,context:Rt(i,h)}},[i,r,T]),Kn=c.useCallback(o=>{if(o.stopPropagation(),o.button!==0)return;const l=r.selectedEntityIds;if(l.size!==1)return;const g=[...l][0],h=J(i,g),C=F(i,g);if(!h||!C)return;const R=n?h.gizmoOrigin?.(g):null;ct(o),h.begin(g),O.current={kind:"rotate",id:g,ownerBoxEdit:h,startLocal:T(o.clientX,o.clientY),origRect:C,center:R??{x:C.x+C.width/2,y:C.y+C.height/2},...R?{nativeOrigin:R}:{}}},[i,r,T,n]),ce=c.useCallback((o,l)=>{if(l.stopPropagation(),l.button!==0)return;const g=r.selectedEntityIds;if(g.size!==1)return;const h=[...g][0],C=J(i,h),R=F(i,h);if(!C||!R)return;const $=C.gizmoOrigin?.(h)??{x:R.x+R.width/2,y:R.y+R.height/2};ct(l),C.begin(h),O.current={kind:"move",id:h,ownerBoxEdit:C,startLocal:T(l.clientX,l.clientY),origRect:R,context:Rt(i,h),moveAxis:o,nativeOrigin:$}},[i,r,T]),Un=c.useCallback((o,l)=>{if(l.stopPropagation(),l.button!==0)return;const g=r.selectedEntityIds;if(g.size!==1)return;const h=[...g][0],C=J(i,h),R=F(i,h);if(!C||!R)return;const $=C.gizmoOrigin?.(h)??{x:R.x+R.width/2,y:R.y+R.height/2};ct(l),C.begin(h),O.current={kind:"native-scale",id:h,ownerBoxEdit:C,startLocal:T(l.clientX,l.clientY),origRect:R,nativeOrigin:$,nativeScaleAxis:o,nativeHandleSpan:un/k.zoom}},[i,k.zoom,r,T]),Zn=c.useCallback((o,l)=>{if(l.stopPropagation(),l.button!==0)return;const g=r.selectedEntityIds;if(g.size!==1)return;const h=[...g][0],C=J(i,h),R=F(i,h);!C||!R||C.referencePoint?.(h)?.id!==o.id||(ct(l),C.begin(h),O.current={kind:"reference",id:h,ownerBoxEdit:C,startLocal:T(l.clientX,l.clientY),origRect:R,context:Rt(i,h),pointerId:l.pointerId,referencePoint:o})},[i,r,T]),Lt=c.useRef(null),qn=c.useCallback((o,l,g,h)=>{h.stopPropagation(),!(h.button!==0||!g.writable)&&(ct(h),Lt.current={id:o,handleId:g.id,provider:l})},[]),Jn=c.useCallback(o=>{const l=Lt.current;if(!l)return;const g=T(o.clientX,o.clientY);l.provider.preview(l.id,l.handleId,[g.x,g.y,0]),at()},[at,T]),de=c.useCallback(o=>{const l=Lt.current;if(Lt.current=null,!l)return;we(o);const g=T(o.clientX,o.clientY);l.provider.commit(l.id,l.handleId,[g.x,g.y,0]),at()},[at,T]),Qn=c.useCallback((o,l)=>{if(l.stopPropagation(),l.button!==0)return;const g=r.selectedEntityIds;if(g.size!==1)return;const h=[...g][0],C=J(i,h),R=F(i,h);!C||!R||(ct(l),C.begin(h),O.current={kind:"spacing",id:h,ownerBoxEdit:C,startLocal:T(l.clientX,l.clientY),origRect:R,side:o.side,origValue:o.value})},[i,r,T]),$t=c.useCallback((o,l)=>{if(o.pointerId!==void 0&&l.pointerId!==o.pointerId)return;const g=T(l.clientX,l.clientY),h=g.x-o.startLocal.x,C=g.y-o.startLocal.y;let R;if(o.kind==="resize")R=Mo(o.pos,h,C,o.origRect,!!o.isPositioned,l.altKey,o.context),I(Do(o.pos,h,C,o.origRect,l.altKey,o.context));else if(o.kind==="native-scale")R=ns(o,h,C,r.snapEnabled,l.altKey,r.snapValues.scale),I([]);else if(o.kind==="move"){const{dx:$,dy:it}=is(o.moveAxis,h,C);if(o.nativeOrigin){R=os(o,$,it,r.snapEnabled,l.altKey,r.snapValues.translate);const Z=To({x:R.originX??o.nativeOrigin.x,y:R.originY??o.nativeOrigin.y},o.nativeOrigin,o.origRect,o.context,o.moveAxis,!r.snapEnabled||l.altKey,Lo/Math.max(k.zoom,.01),{x:X.filter(ht=>ht.axis==="x").map(ht=>ht.value),y:X.filter(ht=>ht.axis==="y").map(ht=>ht.value)});R.originX!==void 0&&(R.originX=Z.position.x),R.originY!==void 0&&(R.originY=Z.position.y),I(Z.guides)}else R=$o($,it,o.origRect,l.altKey,o.context);dt(Ve(o.origRect,$,it)),o.nativeOrigin||I(Bo($,it,o.origRect,l.altKey,o.context))}else if(o.kind==="reference"){const $=Oo(g,o.origRect,l.altKey,o.context,{bounded:o.referencePoint?.bounded,snapPoints:o.referencePoint?.snapPoints});R={referenceX:$.position.x,referenceY:$.position.y},I($.guides)}else o.kind==="rotate"?R=Ao(o.center,o.startLocal,g,o.nativeOrigin&&!r.snapEnabled||l.altKey,o.nativeOrigin?r.snapValues.rotate:15):R=Fo(o.side,h,C,o.origValue??0);if(o.ownerBoxEdit.apply(o.id,R),o.kind==="move"&&o.movePeers){const $=o.nativeOrigin?(R.originX??o.nativeOrigin.x)-o.nativeOrigin.x:(R.x??o.origRect.x)-o.origRect.x,it=o.nativeOrigin?(R.originY??o.nativeOrigin.y)-o.nativeOrigin.y:(R.y??o.origRect.y)-o.origRect.y;for(const Z of o.movePeers)Z.ownerBoxEdit.apply(Z.id,Z.nativeOrigin?{originX:Z.nativeOrigin.x+$,originY:Z.nativeOrigin.y+it}:{x:Z.origRect.x+$,y:Z.origRect.y+it})}at()},[T,at,r,X,k.zoom]),Bt=c.useCallback((o,l)=>{const g=d(o,l);if(!g)return null;const h=Yo(i,g)?.backgroundChainAt(o,l)??null;return h?Si(h):null},[i,d]);c.useEffect(()=>{if(!st)return;const o=l=>{l.key};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[st]),c.useEffect(()=>{const o=h=>h instanceof HTMLInputElement||h instanceof HTMLTextAreaElement||h instanceof HTMLSelectElement||h instanceof HTMLElement&&h.isContentEditable,l=h=>{h.code!=="Space"||h.repeat||o(h.target)||h.target instanceof HTMLButtonElement||(h.preventDefault(),W.current=!0,gt(!0))},g=h=>{h.code==="Space"&&(W.current=!1,gt(!1),Y.current&&(Y.current=null,mt(!1)))};return window.addEventListener("keydown",l),window.addEventListener("keyup",g),()=>{window.removeEventListener("keydown",l),window.removeEventListener("keyup",g)}},[]);const Fe=c.useCallback(o=>{if(o.stopPropagation(),ct(o),W.current){Y.current={startClientX:o.clientX,startClientY:o.clientY,startPan:M.get()},mt(!0);return}if(st){Bt(o.clientX,o.clientY),Ae(null);return}if(ji(t,o.clientX,o.clientY)){v.current=null,j(null),tt(null);return}const l=d(o.clientX,o.clientY);if(Ai(o,l)){v.current=null,j(null),tt(null);return}const g=l!==null?as(i,l,r.selectedEntityIds):null,h=(!n||r.transformMode==="translate")&&g!==null?ls(i,g,r.selectedEntityIds):null,C=!h&&g!==null?cs(i,g):null;v.current={downClientX:o.clientX,downClientY:o.clientY,downLocal:T(o.clientX,o.clientY),hitAtDown:l,moved:!1,moveCandidate:h,reorderCandidate:C},j(null),tt(null)},[i,r,M,n,T,tt,st,Bt,d,t]),to=c.useCallback(o=>{if(o.button===2){f.current={pointerId:o.pointerId,startClientX:o.clientX,startClientY:o.clientY,moved:!1};return}o.button===0&&Fe(o)},[Fe]),Ye=c.useCallback((o,l)=>{const g=l.clientX-o.downClientX,h=l.clientY-o.downClientY;if(!o.moved&&Math.hypot(g,h)>te&&(o.moved=!0),!!o.moved){if(o.moveCandidate){const C=ss(o.moveCandidate,o.downLocal);O.current=C,$t(C,l);return}if(o.reorderCandidate){const C=T(l.clientX,l.clientY),R=No(o.reorderCandidate.siblingRects,C);R&&(A({id:o.reorderCandidate.id,adapter:o.reorderCandidate.adapter,gap:R}),dt(Ve(o.reorderCandidate.origRect,C.x-o.downLocal.x,C.y-o.downLocal.y)));return}if(o.hitAtDown===null){const C=T(l.clientX,l.clientY);tt({x:Math.min(o.downLocal.x,C.x),y:Math.min(o.downLocal.y,C.y),width:Math.abs(C.x-o.downLocal.x),height:Math.abs(C.y-o.downLocal.y)})}}},[T,tt,$t,A]),ot=c.useCallback(o=>{const l=Y.current;if(l){M.setPan(l.startPan.x+(o.clientX-l.startClientX),l.startPan.y+(o.clientY-l.startClientY));return}if(st){const C=T(o.clientX,o.clientY);Ae({...C,color:Bt(o.clientX,o.clientY)});return}const g=O.current;if(g){$t(g,o);return}if((o.buttons&1)===0){Pi(t,o.clientX,o.clientY,d,m,j);return}const h=v.current;h&&Ye(h,o)},[r,M,T,$t,st,Bt,Ye,d,t]),rt=c.useCallback(o=>{if(we(o),Y.current){Y.current=null,mt(!1);return}const l=O.current;if(l?.pointerId!==void 0&&o.pointerId!==l.pointerId||Tt())return;const g=L.current;if(g){A(null),dt(null),v.current=null,Go(g.adapter,g.id,g.gap.beforeSiblingId);return}const h=v.current;if(v.current=null,!h)return;const C=h.hitAtDown!==null?$i(r.selectedEntityIds,h.hitAtDown,o.shiftKey):Bi(i,h.moved,y.current,o.shiftKey);C!==null&&kn(i,C),tt(null)},[i,r,tt,Tt,A]),U=c.useCallback(o=>{if(we(o),Y.current){Y.current=null,mt(!1);return}const l=O.current;l?.pointerId!==void 0&&o.pointerId!==l.pointerId||Tt()||(L.current&&(A(null),dt(null)),v.current=null,tt(null))},[Tt,tt,A]),eo=c.useCallback(()=>{t||Me()?.editorControls?.clearHover(),m(null),j(null)},[t]),no=c.useCallback(o=>{const l=x.current?.parentElement??null;if(Rr(l,o.clientX,o.clientY))return;const g=d(o.clientX,o.clientY);if(!g)return;const h=pe(i,g);if(!h)return;const C=F(i,g);if(!C)return;const R=h.get(g);if(R===null){console.warn(`[RootSelectionOverlay] text edit refused for "${g}": dynamic body or has child elements — not inline-editable.`),pt(null),ut({id:g,rect:C});return}ut(null),pt({id:g,rect:C,initialText:R})},[i,d,pt]),oo=c.useCallback(o=>{const l=xt.current;if(!l)return;const g=pe(i,l.id);g&&(le.current={id:l.id,rect:l.rect},g.set(l.id,o)),pt(null)},[i,pt]),ro=c.useCallback(()=>pt(null),[pt]);if(!Di(i)||ds())return null;const ft=new Set([...r.selectedEntityIds].filter(o=>i.hierarchy.node(o)!==void 0)),ue=z!==null&&!ft.has(z)?F(i,z):null,H=us(i,ft),bt=H?.rect??null,io=H?.ownerBoxEdit??null,N=n&&H?H.ownerBoxEdit.gizmoOrigin?.(H.id)??{x:H.rect.x+H.rect.width/2,y:H.rect.y+H.rect.height/2}:null,Ct=un/k.zoom,lt=H?H.ownerBoxEdit.referencePoint?.(H.id):null,so=H?.spacingBands??[],yt=ft.size===1?[...ft][0]:null,Ot=yt?_o(i,yt):null,ao=yt&&Ot&&r.showHelpers?Ot.layers(yt).filter(o=>r.helperVisibility[o.category]??!0):[],kt=n?{selectedSingleRect:null,measureLines:[],positionBadge:null,showPositionBadge:!1,parentRect:null}:fs(i,ft,ue),Ne=n?null:ps(i,ft),At=Be.current,lo=n?[]:At&&At.adapter===i&&At.version===s?At.hints:(()=>{const o=Xo(i);return Be.current={adapter:i,version:s,hints:o},o})();return a.jsxs("div",{style:{position:"absolute",inset:0,zIndex:zi,pointerEvents:"none"},children:[a.jsx("div",{ref:x,"data-testid":"world-selection-overlay-interaction",style:{position:"absolute",inset:0,pointerEvents:"auto",touchAction:"none",userSelect:"none",cursor:b??Oi(Dt,Mt,st,!!w)},onPointerDownCapture:to,onPointerMove:ot,onPointerUp:rt,onPointerCancel:U,onLostPointerCapture:U,onPointerLeave:eo,onDoubleClick:no,onContextMenu:D,onDragOver:Hn,onDrop:Vn}),p?a.jsx(hs,{state:p,adapter:i,onClose:()=>S(null)}):null,a.jsxs("div",{"data-testid":"world-selection-overlay-chrome",style:{position:"absolute",inset:0,pointerEvents:"none",transform:je(k),transformOrigin:"0 0"},children:[!n&&lo.map(o=>a.jsx("div",{"data-testid":"world-empty-container-hint","data-entity-id":o.id,title:o.displayName,style:{position:"absolute",left:o.rect.x,top:o.rect.y,width:o.rect.width,height:o.rect.height,border:"1px dashed rgba(154, 160, 166, 0.7)",borderWidth:n?1/k.zoom:1,boxSizing:"border-box",pointerEvents:"none"}},o.id)),ue&&a.jsx("div",{"data-testid":"world-selection-hover",style:{...dn(ue,!1),...n?{borderWidth:1/k.zoom}:{}}}),[...ft].map(o=>{const l=F(i,o);return l?a.jsxs("div",{children:[a.jsx("div",{"data-testid":"world-selection-box","data-entity-id":o,style:{...dn(l,!0),...n?{borderWidth:1/k.zoom,background:"transparent"}:{}}}),!n&&a.jsx("div",{"data-testid":"world-selection-label",style:Fi(l),children:Mi(i,o)})]},o):null}),w&&a.jsx("div",{"data-testid":"world-selection-marquee",style:{position:"absolute",left:w.x,top:w.y,width:w.width,height:w.height,border:`1px solid ${_}`,background:`color-mix(in srgb, ${_} 10%, transparent)`,pointerEvents:"none"}}),!n&&a.jsx(ms,{measureLines:kt.measureLines,snapGuides:u,positionBadge:kt.positionBadge,showPositionBadge:kt.showPositionBadge,badgeAnchorRect:kt.selectedSingleRect,parentRect:kt.parentRect,screenScale:V,screenZoom:1}),!n&&a.jsx(xs,{dragGhost:ae,reorderPreview:B}),!n&&Ne&&a.jsx(Ii,{adapter:i,entries:Ne}),bt&&io&&a.jsxs(a.Fragment,{children:[!n&&so.map(o=>a.jsxs("div",{children:[a.jsx("div",{"data-testid":`world-spacing-${o.kind}-${ys(o.side)}`,style:Wi(o),onPointerDown:l=>Qn(o,l),onPointerMove:ot,onPointerUp:rt,onPointerCancel:U}),!o.isZero&&a.jsx("div",{style:{...Ki(o),...n?{transform:`translate(-50%, -50%) scale(${V})`,transformOrigin:"center"}:{}},children:Math.round(o.value)})]},o.side)),lt&&a.jsx("div",{"aria-label":`Edit ${lt.label}`,"data-reference-kind":lt.kind,"data-testid":"world-reference-point-handle",title:`${lt.label} (${lt.bounded?"native corner/edge/center snap":"8px/alignment snap"}, Alt for free movement)`,style:{..._i(lt),...n?{transform:`scale(${V})`,transformOrigin:"center"}:{}},onPointerDown:o=>Zn(lt,o),onPointerMove:ot,onPointerUp:rt,onPointerCancel:U,onLostPointerCapture:U,role:"button",tabIndex:0,children:lt.kind==="anchor"?"A":"P"}),yt&&Ot&&ao.flatMap(o=>o.handles.map(l=>a.jsx("div",{"aria-label":l.label,"data-testid":"world-spatial-handle","data-handle-id":l.id,"data-writable":l.writable,role:"button",tabIndex:0,title:l.writable?l.label:`${l.label} — ${l.reason}`,style:{...Gi(l),transform:`translate(-50%, -50%) scale(${V})`},onPointerDown:g=>qn(yt,Ot,l,g),onPointerMove:Jn,onPointerUp:de,onPointerCancel:de,onLostPointerCapture:de},`${o.id}:${l.id}`))),n&&r.transformMode==="translate"&&a.jsxs(a.Fragment,{children:[a.jsx("div",{"data-testid":"world-2d-move-axis-x",title:"Move on X axis",style:{position:"absolute",left:N.x,top:N.y-5/k.zoom,width:Ct,height:10/k.zoom,borderTop:`${2/k.zoom}px solid #ef5350`,boxSizing:"border-box",cursor:"ew-resize",pointerEvents:"auto"},onPointerDown:o=>ce("x",o),onPointerMove:ot,onPointerUp:rt,onPointerCancel:U}),a.jsx("div",{"data-testid":"world-2d-move-axis-y",title:"Move on Y axis",style:{position:"absolute",left:N.x-5/k.zoom,top:N.y,width:10/k.zoom,height:Ct,borderLeft:`${2/k.zoom}px solid #66bb6a`,boxSizing:"border-box",cursor:"ns-resize",pointerEvents:"auto"},onPointerDown:o=>ce("y",o),onPointerMove:ot,onPointerUp:rt,onPointerCancel:U}),a.jsx("div",{"data-testid":"world-2d-move-center",title:"Move freely",style:{position:"absolute",left:N.x-5/k.zoom,top:N.y-5/k.zoom,width:10/k.zoom,height:10/k.zoom,border:"1px solid rgba(255,255,255,.9)",background:"#4aa3ff",boxSizing:"border-box",cursor:"move",pointerEvents:"auto"},onPointerDown:o=>ce("both",o),onPointerMove:ot,onPointerUp:rt,onPointerCancel:U})]}),(!n||r.transformMode==="scale")&&(n?a.jsxs(a.Fragment,{children:[a.jsx("div",{"data-testid":"world-2d-scale-axis-x",style:{position:"absolute",left:N.x,top:N.y,width:Ct,borderTop:`${2/k.zoom}px solid #ef5350`,pointerEvents:"none"}}),a.jsx("div",{"data-testid":"world-2d-scale-axis-y",style:{position:"absolute",left:N.x,top:N.y,height:Ct,borderLeft:`${2/k.zoom}px solid #66bb6a`,pointerEvents:"none"}}),[["x","ew-resize"],["y","ns-resize"],["both","nwse-resize"]].map(([o,l])=>{const g=rs(o,N,Ct),h=o==="x"?"e":o==="y"?"s":"se";return a.jsx("div",{"data-testid":`world-resize-handle-${h}`,style:{...pn(g,l),transform:`scale(${V})`,transformOrigin:"center",background:o==="x"?"#ef5350":o==="y"?"#66bb6a":"#fff"},onPointerDown:C=>Un(o,C),onPointerMove:ot,onPointerUp:rt,onPointerCancel:U},o)})]}):a.jsxs(a.Fragment,{children:[Ho.map(({pos:o,cursor:l})=>a.jsx("div",{"data-testid":`world-resize-handle-${o}`,style:pn(Vo(bt,o),l),onPointerDown:g=>Wn(o,g),onPointerMove:ot,onPointerUp:rt,onPointerCancel:U},o)),a.jsx("div",{"data-testid":"world-resize-dimension-label",style:Xi(bt),children:`${Math.round(bt.width)}×${Math.round(bt.height)}`})]})),(!n||r.transformMode==="rotate")&&a.jsxs(a.Fragment,{children:[n&&a.jsx("div",{"data-testid":"world-2d-rotate-ring",style:{position:"absolute",left:N.x-40/k.zoom,top:N.y-40/k.zoom,width:80/k.zoom,height:80/k.zoom,border:`${1/k.zoom}px solid #4aa3ff`,borderRadius:"50%",boxSizing:"border-box",pointerEvents:"none"}}),a.jsx("div",{"data-testid":"world-rotate-handle","aria-label":"Rotate selection",title:"Rotate selection (15° snap, Alt for free rotation)",style:{...Ni(bt),...n?{left:N.x-wt/2,top:N.y-40/k.zoom-wt/2,transform:`scale(${V})`,transformOrigin:"center",background:"#4aa3ff"}:{}},onPointerDown:Kn,onPointerMove:ot,onPointerUp:rt,onPointerCancel:U,role:"button",tabIndex:0})]})]}),!n&&a.jsx(bs,{textEdit:$e,onCommitTextEdit:oo,onCancelTextEdit:ro,textEditRefused:Q,eyedropperActive:st,eyedropperPreview:Xn})]})]})}function ms(t){const{measureLines:e,snapGuides:n,positionBadge:r,showPositionBadge:s,badgeAnchorRect:i,parentRect:d,screenScale:x,screenZoom:v}=t;return a.jsxs(a.Fragment,{children:[d&&a.jsx("div",{"data-testid":"world-parent-outline",style:es(d)}),e.map(y=>a.jsxs("div",{"data-testid":"world-measure-line",children:[a.jsx("div",{style:qi(y)}),a.jsx("div",{style:hn(y.x1,y.y1,y.orientation==="horizontal")}),a.jsx("div",{style:hn(y.x2,y.y2,y.orientation==="horizontal")}),a.jsx("div",{"data-testid":"world-measure-line-label",style:{...Ji(y),...x!==1?{transform:`translate(-50%, -50%) scale(${x})`,transformOrigin:"center"}:{}},children:y.distance})]},y.orientation)),n.map(y=>a.jsx("div",{"data-testid":"world-snap-guide",style:Qi(y)},y.orientation)),s&&i&&r&&a.jsxs("div",{"data-testid":"world-position-badge",style:{...ts(i),...x!==1?{top:i.y-36/v,transform:`scale(${x})`,transformOrigin:"top left"}:{}},children:[r.position&&a.jsx("span",{"data-testid":"world-position-badge-mode",style:mn,children:r.position}),r.parentLayout&&a.jsx("span",{"data-testid":"world-position-badge-layout",style:mn,children:r.parentLayout})]})]})}function xs(t){const{dragGhost:e,reorderPreview:n}=t;return a.jsxs(a.Fragment,{children:[e&&a.jsx("div",{"data-testid":"world-drag-ghost",style:Ui(e)}),n&&a.jsx("div",{"data-testid":"world-reorder-preview",style:Zi(n.gap.marker)})]})}function bs(t){const{textEdit:e,onCommitTextEdit:n,onCancelTextEdit:r,textEditRefused:s,eyedropperActive:i,eyedropperPreview:d}=t;return a.jsxs(a.Fragment,{children:[e&&a.jsx("div",{style:{pointerEvents:"auto"},children:a.jsx(Ri,{rect:e.rect,initialText:e.initialText,onCommit:n,onCancel:r})}),s&&a.jsx("div",{"data-testid":"world-text-edit-refused",title:"dynamic body — not inline-editable",style:{position:"absolute",left:s.rect.x,top:s.rect.y,width:Math.max(s.rect.width,40),height:Math.max(s.rect.height,20),border:`2px dashed ${zt.semantic.danger}`,boxSizing:"border-box",background:zt.semantic.dangerMuted,pointerEvents:"none"}}),i&&d&&a.jsx("div",{"data-testid":"world-eyedropper-swatch","data-color-state":d.color?"resolved":"unknown",style:{position:"absolute",left:d.x+12,top:d.y+12,width:24,height:24,borderRadius:4,border:"2px solid #fff",boxShadow:"0 1px 4px rgba(0,0,0,0.5)",background:d.color??"repeating-linear-gradient(45deg, #999, #999 4px, #ccc 4px, #ccc 8px)",pointerEvents:"none"}})]})}function ys(t){return t.endsWith("Top")?"top":t.endsWith("Right")?"right":t.endsWith("Bottom")?"bottom":"left"}function vs({explanation:t,testId:e,style:n}){return t?a.jsx(or,{"data-testid":e,tone:t.tone,title:t.title,description:a.jsx("span",{style:{whiteSpace:"pre-wrap"},children:t.description}),style:{position:"absolute",inset:0,pointerEvents:"none",...n}}):null}const ws="Scene";function Ss({active:t,composite:e,descriptor:n,documentId:r,store:s}){const i=c.useRef(null),d=c.useRef(null),[x]=c.useState(ur),v=n.kind==="canvas",y=v?x:Pe;c.useSyncExternalStore(s.subscribe,s.getSnapshot);const w=c.useSyncExternalStore(pr,fr),E=c.useSyncExternalStore(hr,gr),[z,j]=c.useState(null),b=e.childAdapters().find(k=>k.worldId===n.worldId)?.adapter??z??void 0,m=v&&b?.provenance?.label==="babylon",p=b?.hierarchy.roots()??[],S=new Set(b?.rects?.emptyContainers?.().map(k=>k.id)??[]),f=p.some(k=>!S.has(k.id)),P=Jr({surface:v?"Scene":n.kind==="dom"?"UI":"World",rootIds:[n.worldId],playSuspended:s.playState!=="stopped"&&(!b||b.provenance?.source==="boundary"),phase:!b||b.provenance?.source==="boundary"?"loading":"ready",content:!b||b.provenance?.source==="boundary"?"unknown":f?"present":"empty",readiness:w,failures:E});c.useEffect(()=>{if(b)return mr(r,()=>({adapter:b,nodeId:[...s.selectedEntityIds].find(k=>b.hierarchy.node(k))??null}))},[e,b,r,s]),c.useEffect(()=>{const k=i.current;if(k&&!m)return v?Gr(k,y):Nr(k,y)},[y,m,v]),c.useEffect(()=>{if(!t)return;if(!!!d.current&&i.current){d.current=Or(i.current,e,s,[n],(Mt,gt)=>j(gt),v?{canvasSceneView:x}:void 0,r);return}let X=0,V=0;const W=()=>{if(X+=1,X<2){V=requestAnimationFrame(W);return}yr(r)};return V=requestAnimationFrame(W),()=>cancelAnimationFrame(V)},[t,x,e,n,r,v,s]),c.useEffect(()=>()=>{d.current?.(),d.current=null},[]);const D=xr(Cn(s),s.selectedEntityIds),M=D?.worldId===n.worldId?D:b?.rects?{worldId:n.worldId,kind:"dom",adapter:b}:null;return a.jsxs("div",{ref:i,"data-testid":`world-document:${n.worldId}`,"data-vgai-backdrop-color":t?m?"#111827":v?sn:Ie:void 0,"data-vgai-backdrop-policy":t?"dark-frost":void 0,onPointerDown:()=>br("viewport"),style:{position:"absolute",inset:0,overflow:"hidden",pointerEvents:"auto",backgroundColor:m?"#111827":v?sn:Ie,touchAction:"none"},children:[m?null:v?a.jsx(pi,{view:x}):a.jsx(Es,{}),a.jsx(gs,{...b?{adapter:b}:{},...v&&!m?{view:x,transformModeAware:!0}:{}},`selection:${Ke(b)}`),a.jsx(vs,{explanation:P,testId:`world-surface-status:${n.worldId}`,style:{zIndex:20}}),m?null:v?a.jsx(hi,{active:t,...b?{adapter:b}:{},containerRef:i,view:x},`controls:${Ke(b)}`):a.jsxs(a.Fragment,{children:[a.jsx(ai,{docId:n.worldId,containerRef:i}),a.jsx(mi,{containerRef:i,context:M})]})]})}function Es(){const t=c.useSyncExternalStore(ee,ne),e=Math.max(8,24*t.zoom),n=Math.max(.7,Math.min(1.4,t.zoom));return a.jsx("div",{"data-testid":"react-design-canvas-backdrop","aria-hidden":"true",style:{position:"absolute",inset:0,pointerEvents:"none",backgroundColor:Ie,backgroundImage:`radial-gradient(circle, ${_r} ${n}px, transparent ${n}px)`,backgroundPosition:`${t.x}px ${t.y}px`,backgroundSize:`${e}px ${e}px`}})}let Wt=null;function As(){return Wt}function Fs(t,e){Wt={store:t,composite:e};const n=lr(),r=e.childAdapters().some(f=>f.role==="world"&&f.kind==="three"),s=e.childAdapters().some(f=>f.kind===vr);!r&&!s&&rr(Nt,{discardDirty:!0});const i=new Set,d=[];let x=!1;for(const f of e.childAdapters())f.role==="world"&&f.kind==="three"&&d.push(fe(f.worldId,Nt));const v=$r(e),y=v.find(f=>f.kind==="canvas");y&&d.push(fe(y.worldId,Gt));const w=new Set([...e.childAdapters().filter(f=>f.role==="world"&&f.kind==="three"),...y?[y]:[]].map(f=>f.worldId)),E=new Map;function z(){for(const f of v){if(w.has(f.worldId)||E.has(f.worldId))continue;const P=Vr(f.kind);if(!P)continue;const D=fe(f.worldId,P.documentId),M=cr(f.worldId,()=>P.presence()==="absent"?`Root "${f.worldId}" has no document of its own: its design surface is the project's ${P.title} board (${P.documentId}). ${P.absentReason()}`:null);E.set(f.worldId,()=>{M(),D()})}}d.push(ir(f=>{const P=dr();if(P.some(M=>M.descriptor.id===f))return null;const D=Wr(f);return D?D.presence()==="absent"?D.absentReason():null:`No workspace document is named "${f}". Open in this session: ${P.map(M=>M.descriptor.id).join(", ")||"(none)"}. A component board is present only when the package that owns its medium says this project has one, so a board id can be absent for this project and present for another.`}));function j(f){const P=D=>a.jsx(Ss,{...D,composite:e,descriptor:f,store:t});ar({id:Gt,title:ws,kind:"world",workspaceRole:"authored-subject",provenance:{rootId:f.worldId,...f.path?{sourcePath:f.path}:{}},Content:P,presentation:()=>({kind:"world",id:f.worldId}),onActivate:()=>t.setActiveViewportTab("edit")},{category:"scene",default:!r,rootId:f.worldId})}function b(f){i.add(f.documentId);const P=()=>{i.delete(f.documentId)};try{Promise.resolve(f.install({store:t,composite:e})).catch(P)}catch{P()}}function m(){if(!x){z();for(const f of Hr()){const P=f.presence();if(P===null)continue;const D=i.has(f.documentId);P==="present"!==D&&(P==="present"?b(f):(We(f.documentId),i.delete(f.documentId)))}}}y&&(j(y),i.add(Gt)),m();const p=Kr(m),S=y?Gt:[...i][0];return!r&&S!==void 0&&(n===null||n===Nt||n===sr)?he(S):n?he(n):r&&he(Nt),()=>{x=!0,Wt?.store===t&&(Wt=null),p();for(const f of d)f();for(const f of E.values())f();E.clear();for(const f of i)We(f)}}export{Ss as RootDocumentContent,As as activeRootDocumentHost,Fs as installRootDocuments};
|
package/dist-node/cli.js
CHANGED
|
@@ -254,6 +254,10 @@ var init_client = __esm({
|
|
|
254
254
|
async restart() {
|
|
255
255
|
await this.command({ type: "play" });
|
|
256
256
|
}
|
|
257
|
+
/** Refuse shutdown if a document cannot be saved. Does not stop the server. */
|
|
258
|
+
async prepareClose() {
|
|
259
|
+
await this.command({ type: "session-prepare-close" });
|
|
260
|
+
}
|
|
257
261
|
/** Stops play, and finalizes this run's recording before the surface it was
|
|
258
262
|
* photographing is torn down. The capture is absent when nothing recorded. */
|
|
259
263
|
async stop() {
|
|
@@ -2279,7 +2283,7 @@ function hasManifest(dir) {
|
|
|
2279
2283
|
var package_default = {
|
|
2280
2284
|
name: "@volter/editor",
|
|
2281
2285
|
author: "Volter AI, Inc.",
|
|
2282
|
-
version: "0.5.
|
|
2286
|
+
version: "0.5.59",
|
|
2283
2287
|
publishConfig: {
|
|
2284
2288
|
access: "public"
|
|
2285
2289
|
},
|
|
@@ -2319,12 +2323,12 @@ var package_default = {
|
|
|
2319
2323
|
}
|
|
2320
2324
|
},
|
|
2321
2325
|
dependencies: {
|
|
2322
|
-
"@volter/editor-core": "0.5.
|
|
2323
|
-
"@volter/editor-blender": "0.1.
|
|
2324
|
-
"@volter/blender-engine": "0.1.
|
|
2325
|
-
"@volter/editor-project": "0.5.
|
|
2326
|
-
"@volter/editor-sdk": "0.5.
|
|
2327
|
-
"@volter/editor-live": "0.5.
|
|
2326
|
+
"@volter/editor-core": "0.5.59",
|
|
2327
|
+
"@volter/editor-blender": "0.1.2",
|
|
2328
|
+
"@volter/blender-engine": "0.1.2",
|
|
2329
|
+
"@volter/editor-project": "0.5.59",
|
|
2330
|
+
"@volter/editor-sdk": "0.5.59",
|
|
2331
|
+
"@volter/editor-live": "0.5.59",
|
|
2328
2332
|
"@modelcontextprotocol/sdk": "1.30.0",
|
|
2329
2333
|
undici: "7.29.1"
|
|
2330
2334
|
},
|
|
@@ -17732,6 +17736,8 @@ async function control(verb, argument, reason) {
|
|
|
17732
17736
|
if (verb === "close") {
|
|
17733
17737
|
const session = (await verifiedSessions(live.session.port)).find((s) => s.port === live.session.port && s.project === live.session.projectRoot && s.registered);
|
|
17734
17738
|
if (!session?.pid) throw new Error("Cannot close a session without verified process ownership.");
|
|
17739
|
+
const state = await client.getState();
|
|
17740
|
+
if (state.connected || (state.tabs?.length ?? 0) > 0) await client.prepareClose();
|
|
17735
17741
|
console.log(await terminateEditorSession({ pid: session.pid }));
|
|
17736
17742
|
return;
|
|
17737
17743
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volter/editor",
|
|
3
3
|
"author": "Volter AI, Inc.",
|
|
4
|
-
"version": "0.5.
|
|
4
|
+
"version": "0.5.59",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -41,12 +41,12 @@
|
|
|
41
41
|
}
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@volter/editor-core": "0.5.
|
|
45
|
-
"@volter/editor-blender": "0.1.
|
|
46
|
-
"@volter/blender-engine": "0.1.
|
|
47
|
-
"@volter/editor-project": "0.5.
|
|
48
|
-
"@volter/editor-sdk": "0.5.
|
|
49
|
-
"@volter/editor-live": "0.5.
|
|
44
|
+
"@volter/editor-core": "0.5.59",
|
|
45
|
+
"@volter/editor-blender": "0.1.2",
|
|
46
|
+
"@volter/blender-engine": "0.1.2",
|
|
47
|
+
"@volter/editor-project": "0.5.59",
|
|
48
|
+
"@volter/editor-sdk": "0.5.59",
|
|
49
|
+
"@volter/editor-live": "0.5.59",
|
|
50
50
|
"@modelcontextprotocol/sdk": "1.30.0",
|
|
51
51
|
"undici": "7.29.1"
|
|
52
52
|
},
|