@volter/editor 0.5.59 → 0.5.60

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/BUNDLED_NOTICES +6 -6
  2. package/dist/.vite/manifest.json +206 -232
  3. package/dist/assets/{AudioViewer-C5C4xeUl.js → AudioViewer-C9JP7n49.js} +1 -1
  4. package/dist/assets/{EntityModelDocument-DyhU8umO.js → EntityModelDocument-SFgsuX4_.js} +1 -1
  5. package/dist/assets/{EnvironmentAssetDocument-D_VZ2iFj.js → EnvironmentAssetDocument-DEqKuki2.js} +1 -1
  6. package/dist/assets/{GameplaySessionTimeline-kIIuhFBI.js → GameplaySessionTimeline-BtEPIu2F.js} +1 -1
  7. package/dist/assets/{ImageViewer-Crv-yzT_.js → ImageViewer-CyIXlQTG.js} +1 -1
  8. package/dist/assets/{InspectorObjectPreview-CO-GVXfu.js → InspectorObjectPreview-MDmTPFBT.js} +1 -1
  9. package/dist/assets/{JsonAssetDocument-Dtg2QwPN.js → JsonAssetDocument-Zyv_CDpC.js} +1 -1
  10. package/dist/assets/{ModelAssetDocument-BpZ8SZXe.js → ModelAssetDocument-BKdnWaJL.js} +1 -1
  11. package/dist/assets/{NonThreeAuthoringBootstrap-0nm5Hl3v.js → NonThreeAuthoringBootstrap-ab96Xbnn.js} +2 -2
  12. package/dist/assets/{Object3DPreview-dHzSO5Ym.js → Object3DPreview-ChopdNF4.js} +2 -2
  13. package/dist/assets/{OnlineAssetDetail-DAdWXnmZ.js → OnlineAssetDetail-B_l8XkeE.js} +2 -2
  14. package/dist/assets/{SourceAssetViewer-D3m0wF8T.js → SourceAssetViewer-zpxF5DOe.js} +2 -2
  15. package/dist/assets/{StageHost-DD_m8W0k.js → StageHost-B4P-uvV9.js} +4 -4
  16. package/dist/assets/{ToolObject3DPreview-CWdklUZ1.js → ToolObject3DPreview-DGcT5dDK.js} +1 -1
  17. package/dist/assets/{TransientHint-aFFUtbSY.js → TransientHint-9_u15mth.js} +1 -1
  18. package/dist/assets/{VideoViewer-BhH8aSzx.js → VideoViewer-3I_zUWEC.js} +1 -1
  19. package/dist/assets/{asset-editor-persistence-D5wYXQEL.js → asset-editor-persistence-B6Yg7dTC.js} +1 -1
  20. package/dist/assets/{blender-node-editor.document-D-hrVHmR.js → blender-node-editor.document-DGn6U6Kf.js} +1 -1
  21. package/dist/assets/blender-properties-tab-DkE9ensL.js +3 -0
  22. package/dist/assets/blender-runtime-host-JKPuUKtZ.js +4 -0
  23. package/dist/assets/{blender-runtime-skin-AJdtKKnf.js → blender-runtime-skin-BFLh4nHG.js} +1 -1
  24. package/dist/assets/{blender-runtime.document-JlYY0bb7.js → blender-runtime.document-C60VEa1_.js} +3 -3
  25. package/dist/assets/{blender-timeline.document-5UN8V20F.js → blender-timeline.document-D9BOYb0q.js} +1 -1
  26. package/dist/assets/{blender-uv-editor.document-maFJQzgA.js → blender-uv-editor.document-BK2pP2sR.js} +1 -1
  27. package/dist/assets/{blender-version.status-CukRH8K3.js → blender-version.status-ZqfW0upF.js} +1 -1
  28. package/dist/assets/{blender.command-CY6QiXxp.js → blender.command-BLtAEuIZ.js} +1 -1
  29. package/dist/assets/{browserAll-BQIn-DRw.js → browserAll-DTuU4PmC.js} +1 -1
  30. package/dist/assets/{edit-mode-authoring-CWTeROGv.js → edit-mode-authoring-DBEoND0w.js} +1 -1
  31. package/dist/assets/{hosted-asset-materialization-DcthzsYS.js → hosted-asset-materialization-6HtWQ0od.js} +1 -1
  32. package/dist/assets/{index-DmtPt6RQ.js → index-DuB3wHKD.js} +12 -12
  33. package/dist/assets/{models.finder-CrDJ41Cp.js → models.finder-Bs46IncP.js} +1 -1
  34. package/dist/assets/{product-CqAh01LU.js → product-FSoI1WhZ.js} +1 -1
  35. package/dist/assets/properties-bone-constraints.inspector-QML_-0yQ.js +1 -0
  36. package/dist/assets/properties-bone.inspector-DSDyP6-P.js +1 -0
  37. package/dist/assets/properties-collection.inspector-jic5mzgz.js +1 -0
  38. package/dist/assets/properties-constraints.inspector-TLHv00p7.js +1 -0
  39. package/dist/assets/properties-data.inspector-BJBPl88V.js +1 -0
  40. package/dist/assets/properties-material.inspector-xxWuVjrx.js +1 -0
  41. package/dist/assets/properties-modifiers.inspector-CWjdmu_J.js +1 -0
  42. package/dist/assets/properties-object.inspector-D15l44Tq.js +1 -0
  43. package/dist/assets/properties-output.inspector-DVuGGSBb.js +1 -0
  44. package/dist/assets/properties-particles.inspector-B94x32Ez.js +1 -0
  45. package/dist/assets/properties-physics.inspector-9EYMjwFP.js +1 -0
  46. package/dist/assets/properties-render.inspector-8yA_8luD.js +1 -0
  47. package/dist/assets/properties-scene.inspector-WM7qZhJ4.js +1 -0
  48. package/dist/assets/properties-texture.inspector-Cno5lCIz.js +1 -0
  49. package/dist/assets/properties-view-layer.inspector--PX0c9h6.js +1 -0
  50. package/dist/assets/properties-world.inspector-C3EuydM_.js +1 -0
  51. package/dist/assets/{react-story-board-CnCZAhn6.js → react-story-board-d_OfX68Z.js} +1 -1
  52. package/dist/assets/{react-three-rapier.esm-DsJqtzy_.js → react-three-rapier.esm-Ch_Gf2qR.js} +1 -1
  53. package/dist/assets/{spark.module-uQlq--TY.js → spark.module-B_-x7Z29.js} +1 -1
  54. package/dist/assets/{stage-keyboard-DzZMNYAr.js → stage-keyboard-C9wzGFxu.js} +1 -1
  55. package/dist/assets/{stage-overlay-set-D6OOz1L9.js → stage-overlay-set-D7J-N5eX.js} +1 -1
  56. package/dist/assets/{stage-presence-markers-BUaSzKCv.js → stage-presence-markers-DvbNl1W4.js} +1 -1
  57. package/dist/assets/{story-capture-C2ExQiuI.js → story-capture-D0H-H2_b.js} +1 -1
  58. package/dist/assets/{story-pixi-preview-C6n-a2_M.js → story-pixi-preview-Cafk1Xbk.js} +1 -1
  59. package/dist/assets/{story-three-preview-BazrPMDu.js → story-three-preview-ByMTQc8w.js} +2 -2
  60. package/dist/assets/{webworkerAll-FJN9IDir.js → webworkerAll-CS1yjkoi.js} +1 -1
  61. package/dist/assets/{world-documents-B6usBw3s.js → world-documents-CWiw361z.js} +1 -1
  62. package/dist-node/cli.js +7 -7
  63. package/package.json +7 -7
  64. package/dist/assets/blender-outliner-model-FscHWpfW.js +0 -1
  65. package/dist/assets/blender-properties-tab-Czi3_yYZ.js +0 -3
  66. package/dist/assets/blender-runtime-host-C3rVDyG8.js +0 -4
  67. package/dist/assets/properties-bone-constraints.inspector-BPN6BRJV.js +0 -1
  68. package/dist/assets/properties-bone.inspector-C4xD61mX.js +0 -1
  69. package/dist/assets/properties-collection.inspector-BTps8t6G.js +0 -1
  70. package/dist/assets/properties-constraints.inspector-BVvP6esW.js +0 -1
  71. package/dist/assets/properties-data.inspector-CKKO8DVT.js +0 -1
  72. package/dist/assets/properties-material.inspector-BGfT8kHT.js +0 -1
  73. package/dist/assets/properties-modifiers.inspector-DJRANpOY.js +0 -1
  74. package/dist/assets/properties-object.inspector-CgVfWmw2.js +0 -1
  75. package/dist/assets/properties-output.inspector-CBl5xEMZ.js +0 -1
  76. package/dist/assets/properties-particles.inspector-CxVZ09ZY.js +0 -1
  77. package/dist/assets/properties-physics.inspector-DmG3i3vY.js +0 -1
  78. package/dist/assets/properties-render.inspector-TCoPfEn0.js +0 -1
  79. package/dist/assets/properties-scene.inspector-BjsTOBiY.js +0 -1
  80. package/dist/assets/properties-texture.inspector-D1X9iyVV.js +0 -1
  81. package/dist/assets/properties-view-layer.inspector-dXTVxzzk.js +0 -1
  82. package/dist/assets/properties-world.inspector-CRxJK930.js +0 -1
@@ -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-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() {
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-DuB3wHKD.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-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
+ import{r as o}from"./index-DaQZGF7d.js";import{J as t}from"./index-DuB3wHKD.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-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};
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-DuB3wHKD.js";import"./index-CtzuWnCS.js";import"./index-D2LwEE0L.js";import{s as A,o as b}from"./StageHost-B4P-uvV9.js";import{T as ne}from"./TransientHint-9_u15mth.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};
@@ -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-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
+ 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-DuB3wHKD.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-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
+ import{r as E}from"./react-story-board-d_OfX68Z.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-DuB3wHKD.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-Cafk1Xbk.js";import{supportsThreeStoryCapture as q,captureStoryComponentThumbnail as K,isStoryThreeClassificationRefusal as Y}from"./story-three-preview-ByMTQc8w.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-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
+ import{r as v}from"./index-DaQZGF7d.js";import{a9 as E,aa as M}from"./index-DuB3wHKD.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-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
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/react-three-rapier.esm-Ch_Gf2qR.js","assets/index-DuB3wHKD.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-DuB3wHKD.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-Ch_Gf2qR.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-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;",""),`
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-DuB3wHKD.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
@@ -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-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(`
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-DuB3wHKD.js";import{r as c}from"./index-DaQZGF7d.js";import{B as It,q as Ue,I as vr}from"./edit-mode-authoring-DBEoND0w.js";import"./index-CtzuWnCS.js";import"./index-D2LwEE0L.js";import{T as wr}from"./TransientHint-9_u15mth.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-d_OfX68Z.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
@@ -2283,7 +2283,7 @@ function hasManifest(dir) {
2283
2283
  var package_default = {
2284
2284
  name: "@volter/editor",
2285
2285
  author: "Volter AI, Inc.",
2286
- version: "0.5.59",
2286
+ version: "0.5.60",
2287
2287
  publishConfig: {
2288
2288
  access: "public"
2289
2289
  },
@@ -2323,12 +2323,12 @@ var package_default = {
2323
2323
  }
2324
2324
  },
2325
2325
  dependencies: {
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",
2326
+ "@volter/editor-core": "0.5.60",
2327
+ "@volter/editor-blender": "0.1.3",
2328
+ "@volter/blender-engine": "0.1.3",
2329
+ "@volter/editor-project": "0.5.60",
2330
+ "@volter/editor-sdk": "0.5.60",
2331
+ "@volter/editor-live": "0.5.60",
2332
2332
  "@modelcontextprotocol/sdk": "1.30.0",
2333
2333
  undici: "7.29.1"
2334
2334
  },
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.59",
4
+ "version": "0.5.60",
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.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",
44
+ "@volter/editor-core": "0.5.60",
45
+ "@volter/editor-blender": "0.1.3",
46
+ "@volter/blender-engine": "0.1.3",
47
+ "@volter/editor-project": "0.5.60",
48
+ "@volter/editor-sdk": "0.5.60",
49
+ "@volter/editor-live": "0.5.60",
50
50
  "@modelcontextprotocol/sdk": "1.30.0",
51
51
  "undici": "7.29.1"
52
52
  },
@@ -1 +0,0 @@
1
- import{e as O}from"./index-DmtPt6RQ.js";import{b as g,a as F,c as x,d as E}from"./blender-runtime-host-C3rVDyG8.js";const I=e=>typeof e=="object"&&e!==null&&typeof e.subscribeFrames=="function"&&typeof e.objectForBlenderName=="function"&&typeof e.blenderObjectName=="function"&&typeof e.blenderSelection=="function"&&typeof e.setStageMode=="function";function p(){const e=O().documents.context(F());return I(e)?e:null}function H(){return p()?.blenderSelection()??{selected:[],active:null}}const R={tree:null,byId:new Map,parentOf:new Map,error:null,loading:!1};let d=R,M=0;const b=new Set;let l=null,c=null,S="",i=null;function q(e){const n=new Map,r=new Map,t=(o,P)=>{n.set(o.id,o),r.set(o.id,P);for(const V of o.children)t(V,o.id)};for(const o of e?.rows??[])t(o,null);return{byId:n,parentOf:r}}function u(e){d={...d,...e},M+=1;for(const n of[...b])n()}function K(e){return b.add(e),()=>{b.delete(e)}}function L(){return M}function Y(){return d}function h(e){i!==e&&(i=e,setTimeout(()=>{i===e&&(i=null,B(e===""?[]:e.split("\0")))},0))}let a=0,m=Promise.resolve();function B(e){const n=C(e);return m=n,n}async function C(e){const n=e.join("\0"),r=++a;c=n,S=n,u({loading:!0});try{const t=await E(e);if(r!==a)return;p()?.setStageMode(t?.mode??null),u({tree:t,...q(t),loading:!1,error:null})}catch(t){if(r!==a)return;u({loading:!1,error:j(t)})}}function N(){c=null,h(S);for(const e of[...w])e()}const w=new Set;function v(e){return y(),w.add(e),()=>{w.delete(e)}}let s=!1,f=null;function y(){const e=p();if(l!==null&&f===e)return;l!==null&&(l(),l=null,f=null);const n=e;if(n!==null){l=n.subscribeFrames(N),f=n;return}s||(s=!0,O().documents.waitForContext(F()).then(()=>{s=!1,y()}).catch(()=>{s=!1}))}function z(e){if(!g())return;y();const n=[...e].sort().join("\0");c!==n&&h(n)}async function A(e){if(!g())return;i=null;let n=B([...e].sort());for(;;){if(await n,m===n)return;n=m}}async function G(e,n,r){try{return await x(e,n,r),c=null,h(S),!0}catch(t){return u({error:j(t)}),!1}}function j(e){return e instanceof Error?e.message:String(e)}export{L as a,H as b,p as c,z as d,Y as e,v as o,A as r,K as s,G as w};
@@ -1,3 +0,0 @@
1
- import{a as i}from"./jsx-runtime-DPjLkJKQ.js";import{e as V}from"./index-DmtPt6RQ.js";import{a as H,b as X,x as le,y as oe,s as se,z as ce,p as ue}from"./blender-runtime-host-C3rVDyG8.js";import{e as de}from"./blender-outliner-model-FscHWpfW.js";import{r as g}from"./index-DaQZGF7d.js";const ae=e=>typeof e=="object"&&e!==null&&typeof e.subscribeFrames=="function"&&typeof e.blenderObjectName=="function",fe=e=>typeof e=="object"&&e!==null&&typeof e.documentId=="string"&&typeof e.hierarchy?.object3D=="function";function Y(){const e=V().documents.context(H());return ae(e)?e:null}function Z(e,t){if(e===null||!fe(t))return null;const n=Y();if(n===null)return null;if(e.id===t.documentId)return t.documentRootObject===n.root?{kind:"scene"}:null;const r=de().byId.get(e.id);if(r?.type==="TSE_LAYER_COLLECTION")return{kind:"collection",path:r.path};const l=t.hierarchy.object3D(e.id);if(l===null)return null;if(l===n.root)return{kind:"scene"};const o=n.blenderObjectName(l);return o===null?null:{kind:"object",name:o}}let N={object:null,collection:null,context:null,views:new Map,error:null,loading:!1},q=0;const F=new Set;let w=null;const I=new Set;let E=null;function b(e,t=!1){N={...N,...e},q+=1;for(const n of[...F])n();t&&V().documents.contextChanged(H())}function pe(e){return F.add(e),()=>{F.delete(e)}}function G(){return q}function M(){return N}function he(){const e=E;E=null,b({views:new Map}),e!==null&&J(e)}se(()=>{he()});let T=null;function J(e){T!==e&&(T=e,setTimeout(()=>{T===e&&(T=null,ge(e))},0))}function xe(e){return e.kind==="scene"?"":e.kind==="collection"?`collection:${e.path}`:e.name}function ye(){if(w!==null)return;const e=Y();e!==null&&(w=e.subscribeFrames(le))}async function ge(e){const t=e.startsWith("collection:")?e.slice(11):null,n=t===null&&e!==""?e:null;E=e,b({loading:!0,object:n,collection:t});try{const r=await oe(n??void 0,t??void 0);if(E!==e)return;b({context:r,loading:!1,error:null},!0)}catch(r){if(E!==e)return;b({context:null,loading:!1,error:D(r)},!0)}}function Q(e){if(!X())return;ye();const t=xe(e);E!==t&&J(t)}function R(e){const t=N.views.get(e);if(t!==void 0)return t;I.has(e)||!X()||(I.add(e),ce(e).then(n=>{if(I.delete(e),n===null)return;const r=new Map(N.views);r.set(e,n),b({views:r,error:null})}).catch(n=>{I.delete(e),b({error:D(n)})}))}async function be(e,t,n,r){try{await ue(e,t,n,r);const l=new Map(N.views);return l.delete(e),b({views:l,error:null}),!0}catch(l){return b({error:D(l)}),!1}}function D(e){return e instanceof Error?e.message:String(e)}const $=20,K=2,je="40%",me=25,U=20,m=8,ve=4,z=8,p=11,y=.5,x="#e6e6e6",Se="#3d3d3d",Ee="#ffffff11",Ae="rgba(0,0,0,0.12)",Ne="#545454",Re="#3d3d3d",$e="#4772b3",ee="#991616",Oe=8,Le=6,Ce=e=>Math.round(e*.2),te=e=>e.filter(t=>t.hidden!==!0&&t.undrawn!==!0);function C(){return g.useSyncExternalStore(pe,G,G)}function h({title:e,sub:t=!1,closed:n=!1,note:r,count:l,children:o}){const[c,u]=g.useState(!n);return i.jsxs("div",{style:{marginBottom:m,borderRadius:ve,boxShadow:t?"none":`inset 0 0 0 1px ${Ee}`,background:t?Ae:"transparent",overflow:"hidden"},children:[i.jsxs("button",{type:"button",onClick:()=>u(!c),style:{display:"flex",alignItems:"center",width:"100%",height:me,background:t?"transparent":Se,border:"none",padding:`0 ${z}px 0 ${t?U+14-20:0}px`,color:x,font:`${p}px inherit`,textAlign:"left",cursor:"pointer",gap:Le},children:[i.jsx("span",{"aria-hidden":"true",style:{width:U-8,textAlign:"center",fontSize:Oe,opacity:.85},children:c?"▼":"▶"}),i.jsx("span",{style:{fontWeight:400},title:r,children:e}),l===void 0?null:i.jsx("span",{style:{opacity:y,marginLeft:"auto"},children:l})]}),c?i.jsx("div",{style:{padding:m},children:o}):null]})}function A({label:e,title:t,readonly:n,identifier:r,children:l}){return i.jsxs("div",{"data-rna-field":r??"","data-field-label":e,"data-field-readonly":n?"true":void 0,style:{display:"flex",alignItems:"center",minHeight:$,marginBottom:K,gap:z,opacity:n?y:1},title:t,children:[i.jsx("span",{style:{flex:`0 0 ${je}`,textAlign:"right",color:x,fontSize:p,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e}),i.jsx("span",{style:{flex:"1 1 0",minWidth:0,display:"flex",gap:K},children:l})]})}const j={height:$,width:"100%",minWidth:0,boxSizing:"border-box",background:Ne,border:`1px solid ${Re}`,borderRadius:Ce($),color:x,fontSize:p,padding:`0 ${z}px`,textAlign:"center"};function v({children:e}){return i.jsx("span",{style:{...j,display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e})}const B=$-2*Math.floor(($-2)/6);function ne({value:e,readonly:t,label:n,onChange:r}){return i.jsx("input",{type:"checkbox",checked:e,readOnly:t,...n===void 0?{}:{"aria-label":n},onChange:l=>!t&&r(l.target.checked),style:{width:B,height:B,margin:`${($-B)/2}px 0`,accentColor:$e,cursor:t?"default":"pointer"}})}function ie({row:e,value:t,index:n,onWrite:r}){const[l,o]=g.useState(null),c=e.type==="FLOAT"?e.precision??3:0,u=l??(e.type==="FLOAT"?t.toFixed(c):String(t));return e.readonly?i.jsx(v,{children:u}):i.jsx("input",{type:"number","aria-label":O(e,n),value:u,...e.softMin===void 0?{}:{min:e.softMin},...e.softMax===void 0?{}:{max:e.softMax},...e.step===void 0?{}:{step:e.type==="FLOAT"?e.step/100:1},onChange:s=>o(s.target.value),onBlur:()=>{const s=Number(l);o(null),l!==null&&Number.isFinite(s)&&s!==t&&r(s,n)},onKeyDown:s=>{s.key==="Enter"&&s.target.blur(),s.key==="Escape"&&o(null)},style:j})}const k=["X","Y","Z","W"];function O(e,t){const n=e.name||e.identifier;return t===void 0?n:`${n} ${k[t]??t}`}function Ie(e){const t=n=>Math.max(0,Math.min(255,Math.round((e[n]??0)**.45454545454545453*255)));return`rgb(${t(0)}, ${t(1)}, ${t(2)})`}function Te({row:e,onOpen:t}){const n=e.value;if(n===null||n.path===null)return i.jsx(v,{children:n===null?"None":n.name??n.type});const r=n.path;return i.jsx("button",{type:"button","aria-label":O(e),onClick:()=>t(r),style:{...j,cursor:"pointer",textAlign:"left"},title:r,children:n.name??n.type})}function Pe({row:e,write:t}){const n=e.items??[];if(e.isFlag){const l=e.value??[];return i.jsx(v,{children:l.length===0?"None":l.join(", ")})}const r=String(e.value??"");return e.readonly?i.jsx(v,{children:n.find(l=>l.identifier===r)?.name??r}):i.jsx("select",{"aria-label":O(e),value:r,onChange:l=>t(l.target.value),style:{...j,textAlign:"left"},children:n.map(l=>i.jsx("option",{value:l.identifier,children:l.name},l.identifier))})}function ke({row:e,write:t}){const n=String(e.value??"");return e.readonly?i.jsx(v,{children:n}):i.jsx(De,{value:n,label:O(e),onWrite:r=>t(r)})}function Me({row:e}){const t=e.value??[];return i.jsx("span",{style:{...j,background:Ie(t),display:"block"},title:t.map(n=>n.toFixed(3)).join(", ")})}function Be({row:e,label:t,title:n,write:r}){const l=e.value??[];return i.jsx(i.Fragment,{children:l.map((o,c)=>i.jsx(A,{label:Fe(t,c,l.length),title:n,readonly:e.readonly,identifier:`${e.identifier}[${c}]`,children:e.type==="BOOLEAN"?i.jsx(ne,{value:o===!0,readonly:e.readonly,label:O(e,c),onChange:u=>r(u,c)}):i.jsx(ie,{row:e,value:Number(o),index:c,onWrite:(u,s)=>r(u,s)})},`${e.identifier}-${k[c]??c}`))})}function Fe(e,t,n){return n>k.length?t===0?e:`${e} ${t}`:`${t===0?`${e} `:""}${k[t]}`}function _e(e){const{row:t,write:n}=e;switch(t.type){case"POINTER":return i.jsx(Te,{...e});case"ENUM":return i.jsx(Pe,{...e});case"STRING":return i.jsx(ke,{...e});case"BOOLEAN":return i.jsx(ne,{value:t.value===!0,readonly:t.readonly,label:O(t),onChange:n});default:return i.jsx(ie,{row:t,value:Number(t.value??0),onWrite:r=>n(r)})}}function W({row:e,path:t,onOpen:n}){const r=(d,f)=>void be(t,e.identifier,d,f),l=e.name||e.identifier,o=`${e.identifier} — ${e.type}${e.subtype==="NONE"?"":`/${e.subtype}`}${e.readonly?" (read-only)":""}${e.description?`
2
- ${e.description}`:""}`,c={row:e,path:t,write:r,onOpen:n},u=e.valueOmitted??e.valueError;if(u!==void 0)return i.jsx(A,{label:l,title:o,readonly:!0,identifier:e.identifier,children:i.jsx(v,{children:u})});if(e.type==="COLLECTION")return i.jsx(ze,{label:l,title:o,value:e.value??{count:0},identifier:e.identifier,onOpen:()=>n(`${t}.${e.identifier}`)});const s=e.type==="INT"||e.type==="FLOAT";return e.arrayLength>0&&(s||e.type==="BOOLEAN")?s&&(e.subtype==="COLOR"||e.subtype==="COLOR_GAMMA")?i.jsx(A,{label:l,title:o,readonly:e.readonly,identifier:e.identifier,children:i.jsx(Me,{...c})}):i.jsx(Be,{...c,label:l,title:o}):i.jsx(A,{label:l,title:o,readonly:e.readonly,identifier:e.identifier,children:_e(c)})}function De({value:e,label:t,onWrite:n}){const[r,l]=g.useState(null);return i.jsx("input",{type:"text",...t===void 0?{}:{"aria-label":t},value:r??e,onChange:o=>l(o.target.value),onBlur:()=>{r!==null&&r!==e&&n(r),l(null)},onKeyDown:o=>{o.key==="Enter"&&o.target.blur(),o.key==="Escape"&&l(null)},style:{...j,textAlign:"left"}})}function ze({label:e,title:t,value:n,identifier:r,onOpen:l}){const[o,c]=g.useState(!1),u=n.names??[];return i.jsxs(i.Fragment,{children:[i.jsx(A,{label:e,title:t,readonly:!1,identifier:r,children:i.jsxs("button",{type:"button","aria-label":e,onClick:()=>u.length?c(!o):l(),style:{...j,cursor:"pointer",textAlign:"left"},children:[u.length?`${o?"▼":"▶"} `:"",n.count," ",n.count===1?"item":"items"]})}),o?u.map(s=>i.jsx(A,{label:"",readonly:!0,children:i.jsx(v,{children:s})},s)):null]})}const _=e=>typeof e=="string"?e:e.property;function We(e){if(e.active===void 0)return{path:null,index:null};const t=M().context?.[e.active];if(typeof t!="object"||t===null)return{path:null,index:null};const n=t;return{path:n.path??null,index:typeof n.index=="number"?n.index:null}}function we({panel:e,path:t,onOpen:n}){C();const r=R(t),l=We(e);return r===void 0?i.jsx(h,{title:e.title,closed:e.closed===!0,children:i.jsxs("div",{style:{color:x,opacity:y,fontSize:p},children:["Reading ",t,"…"]})}):r.kind!=="collection"?i.jsx(h,{title:e.title,closed:e.closed===!0,note:t,children:i.jsxs("div",{style:{color:ee,fontSize:p},children:[t," is not a collection — this panel is declared `collection: true`."]})}):i.jsxs(h,{title:e.title,closed:e.closed===!0,note:t,count:r.count,children:[r.items.length===0?i.jsx("div",{style:{color:x,opacity:y,fontSize:p},children:"None"}):null,r.items.map((o,c)=>i.jsx(h,{title:`${o.path!==null&&o.path===l.path||c===l.index?"● ":""}${o.name??o.type}`,sub:!0,children:o.path===null?i.jsxs("div",{style:{color:x,opacity:y,fontSize:p},children:[o.type," — RNA gives this member no address."]}):i.jsx(Ge,{path:o.path,properties:e.properties,andDeclared:e.andDeclared===!0,onOpen:n})},o.path??o.name??o.type))]})}function Ge({path:e,properties:t,andDeclared:n=!1,onOpen:r}){C();const l=R(e);if(l===void 0)return i.jsxs("div",{style:{color:x,opacity:y,fontSize:p},children:["Reading ",e,"…"]});const o=l.kind==="struct"?l.groups.flatMap(d=>d.rows):[],c=new Map(o.map(d=>[d.identifier,d])),u=t.map(d=>c.get(_(d))).filter(d=>d!==void 0),s=n&&l.kind==="struct"?te(o).filter(d=>d.group===l.type&&!t.some(f=>_(f)===d.identifier)):[];return i.jsx(i.Fragment,{children:[...u,...s].map(d=>i.jsx(W,{row:d,path:e,onOpen:r},d.identifier))})}function Ke(e,t){if(e.engine!==void 0){const n=M().context?.engine;if(n===void 0)return null;if(!e.engine.includes(n))return!1}for(const n of e.when??[]){const r=n.from??e.from,l=r?t.find(s=>s.label===r):t[0];if(l===void 0)return!1;const o=R(l.path);if(o===void 0)return null;if(o.kind!=="struct")return!1;const c=o.groups.flatMap(s=>s.rows).find(s=>s.identifier===n.property);if(c===void 0)return!1;const u=c.value;if(typeof u!="string"&&typeof u!="number"&&typeof u!="boolean"||n.is!==void 0&&!n.is.includes(u)||n.isNot!==void 0&&n.isNot.includes(u))return!1}return!0}function re({panel:e,paths:t,onOpen:n}){if(C(),Ke(e,t)!==!0)return null;const r=e.from?t.find(s=>s.label===e.from):t[0];if(r!==void 0&&e.collection===!0)return i.jsx(we,{panel:e,path:r.path,onOpen:n});if(r===void 0)return null;const l=R(r.path),o=e.sub??[],c=[],u=[];for(const s of e.properties){const d=_(s),f=typeof s=="string"?r:t.find(L=>L.label===s.from),a=f===void 0?void 0:R(f.path),S=a?.kind==="struct"?a.groups.flatMap(L=>L.rows).find(L=>L.identifier===d):void 0;S===void 0||f===void 0?u.push(d):c.push({identifier:d,row:S,path:f.path})}return l===void 0?i.jsx(h,{title:e.title,closed:e.closed===!0,children:i.jsxs("div",{style:{color:x,opacity:y,fontSize:p},children:["Reading ",r.path,"…"]})}):c.length===0&&o.length===0?null:i.jsxs(h,{title:e.title,closed:e.closed===!0,note:u.length===0?`${r.path}`:`${r.path}
3
- Not on this datablock: ${u.join(", ")}`,children:[c.map(s=>i.jsx(W,{row:s.row,path:s.path,onOpen:n},s.identifier)),o.map((s,d)=>i.jsx(re,{panel:s,paths:t,onOpen:n},`${d}:${s.title}`))]})}function P({path:e,onOpen:t}){C();const n=R(e);return n===void 0?i.jsxs("div",{style:{color:x,opacity:y,fontSize:p,padding:m},children:["Reading ",e,"…"]}):n.kind==="collection"?i.jsxs(i.Fragment,{children:[n.items.length===0?i.jsx("div",{style:{color:x,opacity:y,fontSize:p},children:n.count===0?"None":`${n.count} items`}):null,n.items.map(r=>i.jsx(h,{title:r.name??r.type,sub:!0,children:r.path===null?i.jsxs("div",{style:{color:x,opacity:y,fontSize:p},children:[r.type," — RNA gives this member no address."]}):i.jsx(P,{path:r.path,onOpen:t})},r.path??r.name??r.type))]}):i.jsx(i.Fragment,{children:n.groups.map(r=>{const l=te(r.rows);return l.length===0?null:i.jsx(h,{title:r.label,sub:!0,children:l.map(o=>i.jsx(W,{row:o,path:n.path,onOpen:t},o.identifier))},r.id)})})}function Ue({tabId:e,subject:t,curated:n=[]}){C(),g.useEffect(()=>Q(t),[t]);const[r,l]=g.useState([]),o=M(),c=o.context?.tabs.find(a=>a.id===e)??null,u=c?.paths??[],s=u.map(a=>a.path).join("|");if(g.useEffect(()=>l([]),[s]),o.error!==null)return i.jsx("div",{style:{color:ee,fontSize:p,padding:m},children:o.error});if(c===null)return i.jsx("div",{style:{color:x,opacity:y,fontSize:p,padding:m},children:o.loading?"Reading the engine…":"Blender shows no properties here."});const d=a=>l(S=>[...S,a]),f=r[r.length-1];return i.jsxs("div",{style:{padding:`${m}px 0`},children:[r.length>0?i.jsxs("button",{type:"button",onClick:()=>l(a=>a.slice(0,-1)),style:{...j,width:"auto",marginBottom:m,cursor:"pointer",textAlign:"left"},title:f,children:["← ",c.label]}):null,f!==void 0?i.jsx(h,{title:f.slice(f.lastIndexOf(".")+1),children:i.jsx(P,{path:f,onOpen:d})}):i.jsxs(i.Fragment,{children:[n.map((a,S)=>i.jsx(re,{panel:a,paths:u,onOpen:d},`${S}:${a.title}`)),n.length>0?i.jsx(h,{title:"All properties",closed:!0,children:u.map(a=>i.jsx(h,{title:a.label,sub:!0,children:i.jsx(P,{path:a.path,onOpen:d})},a.path))}):u.map(a=>i.jsx(h,{title:a.label,children:i.jsx(P,{path:a.path,onOpen:d})},a.path))]})]})}function qe(e){return(t,n)=>{const r=Z(t,n);if(r===null)return!1;if(Q(r),e.standing==="any")return!0;if(e.standing==="object")return r.kind==="object";const l=M(),o=r.kind==="object"?r.name:null,c=r.kind==="collection"?r.path:null;return l.object!==o||l.collection!==c?!1:l.context?.tabs.some(u=>u.id===e.id)??!1}}function Je(e){return function({node:n,adapter:r}){const l=Z(n,r);return l===null?null:i.jsx(Ue,{tabId:e.id,subject:l,curated:e.curated??[]})}}export{qe as a,Je as b,M as c,Z as r};