@volter/model-editor 0.5.66 → 0.5.67

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 (200) hide show
  1. package/dist/.vite/manifest.json +1022 -1006
  2. package/dist/assets/AudioViewer-DVXaSSYC.js +1 -0
  3. package/dist/assets/{BVHLoader-xUHWsz84.js → BVHLoader-msuIvJVn.js} +1 -1
  4. package/dist/assets/ColladaLoader-BpvxwqkB.js +3 -0
  5. package/dist/assets/EntityModelDocument-BtlQZcoU.js +1 -0
  6. package/dist/assets/EnvironmentAssetDocument-BH3zT9rt.js +1 -0
  7. package/dist/assets/FBXLoader-CsdO937F.js +1 -0
  8. package/dist/assets/{GameplaySessionTimeline-HJLZUV4Q.js → GameplaySessionTimeline-Dko95kB7.js} +10 -10
  9. package/dist/assets/ImageViewer-CZ_RMER2.js +1 -0
  10. package/dist/assets/{InspectorCanvasPreview-CLDhscy0.js → InspectorCanvasPreview-BLecDHpc.js} +1 -1
  11. package/dist/assets/InspectorObjectPreview-CSIWwJQE.js +1 -0
  12. package/dist/assets/JsonAssetDocument-CGYSeJyl.js +2 -0
  13. package/dist/assets/{LineSegments2-C8H20K8w.js → LineSegments2-BKEsgiC8.js} +2 -2
  14. package/dist/assets/LiveModuleDocument-CIvS-SUT.js +2 -0
  15. package/dist/assets/LutAssetDocument-BA70uU3w.js +1 -0
  16. package/dist/assets/{MTLLoader-C-rA0fNF.js → MTLLoader-DNh2pFDc.js} +2 -2
  17. package/dist/assets/ModelAssetDocument-D0lNEhOg.js +1 -0
  18. package/dist/assets/NonThreeAuthoringBootstrap-C0pCfkJ4.js +2 -0
  19. package/dist/assets/OBJLoader-DPi99VIm.js +5 -0
  20. package/dist/assets/Object3DDocumentToolbar-PGYkZEwr.js +1 -0
  21. package/dist/assets/Object3DPreview-BROKXSTC.js +2 -0
  22. package/dist/assets/OnlineAssetDetail-lEHnhdUS.js +1 -0
  23. package/dist/assets/OrbitControls-smIenN60.js +1 -0
  24. package/dist/assets/PLYLoader-Cx9Yc9xe.js +2 -0
  25. package/dist/assets/QuarksAssetDocument-C_8eG4KG.js +2 -0
  26. package/dist/assets/RectAreaLightUniformsLib-Iam8rS8R.js +1 -0
  27. package/dist/assets/STLLoader-BaJkM-k1.js +1 -0
  28. package/dist/assets/{ShaderAssetDocument-qlLeb2S3.js → ShaderAssetDocument-Gdp7OCfv.js} +5 -5
  29. package/dist/assets/SourceAssetViewer-l72u0hOa.js +1 -0
  30. package/dist/assets/StageHost-CdzuP0NS.js +1179 -0
  31. package/dist/assets/TDSLoader-BskhMiUy.js +1 -0
  32. package/dist/assets/ToolObject3DPreview-CU5klD6l.js +1 -0
  33. package/dist/assets/Toolbar-DI0LGx25.js +1 -0
  34. package/dist/assets/TransientHint-myZtSdd6.js +1 -0
  35. package/dist/assets/VideoViewer-z0JPXPKa.js +1 -0
  36. package/dist/assets/ViewportShadingMenu-CVU2bU_3.js +1 -0
  37. package/dist/assets/animation-mixers.service-DSIsxWG5.js +1 -0
  38. package/dist/assets/animation-timeline.utility-BEgDQC04.js +1 -0
  39. package/dist/assets/asset-editor-persistence-BtRQI8t6.js +1 -0
  40. package/dist/assets/bitmap-label-Ct4k6ehY.js +1 -0
  41. package/dist/assets/{blender-emscripten-engine-CEsWgnR7.js → blender-emscripten-engine-BeWFjMn-.js} +1 -1
  42. package/dist/assets/blender-node-editor.document-C_kpsARB.js +1 -0
  43. package/dist/assets/{blender-properties-tab-C5tUuCSv.js → blender-properties-tab-B_XBg6S8.js} +3 -3
  44. package/dist/assets/blender-runtime-host-CYhl4T9S.js +4 -0
  45. package/dist/assets/{blender-runtime-skin-DMq0XAvO.js → blender-runtime-skin-Bk6uXECD.js} +98 -51
  46. package/dist/assets/blender-runtime.document-CAPDRCvN.js +12 -0
  47. package/dist/assets/blender-timeline.document-CcEymQyL.js +1 -0
  48. package/dist/assets/blender-uv-editor.document-DSPvSEuE.js +1 -0
  49. package/dist/assets/blender-version.status-CEu7vCi3.js +1 -0
  50. package/dist/assets/{blender-wali-engine-D3iKpzn9.js → blender-wali-engine-da698rDf.js} +1 -1
  51. package/dist/assets/blender.command-BCb_c9lw.js +1 -0
  52. package/dist/assets/blender.keymap-_rF_vRX8.js +1 -0
  53. package/dist/assets/{blender.status-ujwGU6dU.js → blender.status-DrasQhJV.js} +1 -1
  54. package/dist/assets/{blender.style-CxfbTFcE.js → blender.style-DaIh9SiA.js} +1 -1
  55. package/dist/assets/{client-DNXj_opT.js → client-mkWk8S65.js} +1 -1
  56. package/dist/assets/content-bounds-_QWiKD5_.js +85 -0
  57. package/dist/assets/{hosted-asset-materialization-BXM49Qkc.js → hosted-asset-materialization-hUS3IhTD.js} +2 -2
  58. package/dist/assets/index-0Lm0Nf1M.css +1 -0
  59. package/dist/assets/{index-CJbYy-CF.js → index-7vd2obXq.js} +2 -2
  60. package/dist/assets/{index-DgapqSPi.js → index-BRLA7zdc.js} +1 -1
  61. package/dist/assets/{index-BtfYaG4D.js → index-CQG6JOSy.js} +18 -18
  62. package/dist/assets/{index-CanA16PU.js → index-CnvSS9lU.js} +1 -1
  63. package/dist/assets/{index-Bge9JUr6.js → index-DYNMP0kE.js} +1 -1
  64. package/dist/assets/index-Dm_h-T4x.js +1406 -0
  65. package/dist/assets/{index-gHZae-lw.js → index-Dz8qGBZc.js} +1 -1
  66. package/dist/assets/{index-BncK9THk.js → index-Fv4R0cYr.js} +1 -1
  67. package/dist/assets/{index-IEjydI9d.js → index-f-MQ14bP.js} +1 -1
  68. package/dist/assets/{index-D2LwEE0L.js → index-jib6KJY8.js} +6 -6
  69. package/dist/assets/{index-DUqP1RMl.js → index-ux8XhRyW.js} +1 -1
  70. package/dist/assets/{jsx-runtime-DPjLkJKQ.js → jsx-runtime-CAUTK36e.js} +1 -1
  71. package/dist/assets/layered-pick-CT4HlEpW.js +1 -0
  72. package/dist/assets/live-mixers-B-bwLZ7c.js +1 -0
  73. package/dist/assets/model-inspection-DDZE59vp.js +1 -0
  74. package/dist/assets/models.finder-Caf-3Yix.js +1 -0
  75. package/dist/assets/product-DbFrUS6F.js +1 -0
  76. package/dist/assets/properties-bone-constraints.inspector-DB3Rc_Hf.js +1 -0
  77. package/dist/assets/properties-bone.inspector-B7f7H_Co.js +1 -0
  78. package/dist/assets/properties-collection.inspector-JCtV3h3Y.js +1 -0
  79. package/dist/assets/properties-constraints.inspector-Cs8MwS-1.js +1 -0
  80. package/dist/assets/properties-data.inspector-DKGiHu8O.js +1 -0
  81. package/dist/assets/properties-material.inspector-Dc18RI13.js +1 -0
  82. package/dist/assets/properties-modifiers.inspector-DvGvXq2v.js +1 -0
  83. package/dist/assets/properties-object.inspector-Bl9nrytP.js +1 -0
  84. package/dist/assets/properties-output.inspector-B6QsU94n.js +1 -0
  85. package/dist/assets/properties-particles.inspector-B1dMnZSA.js +1 -0
  86. package/dist/assets/properties-physics.inspector-BwfNykfW.js +1 -0
  87. package/dist/assets/properties-render.inspector-KrL2EiTH.js +1 -0
  88. package/dist/assets/properties-scene.inspector-CewQnyRt.js +1 -0
  89. package/dist/assets/properties-texture.inspector-BITMzY-f.js +1 -0
  90. package/dist/assets/properties-view-layer.inspector-BpkDbmcb.js +1 -0
  91. package/dist/assets/properties-world.inspector-DLRH45Oj.js +1 -0
  92. package/dist/assets/{react-18-DyywM-Z2.js → react-18-D335xReo.js} +1 -1
  93. package/dist/assets/{react-story-board-B9V-j_Y5.js → react-story-board-CkaP4mEG.js} +1 -1
  94. package/dist/assets/{session-CsR0lApe.js → session-CTXsU1lK.js} +176 -1
  95. package/dist/assets/{spark.module-gG1EsWx8.js → spark.module-DMQ9J7rT.js} +11 -11
  96. package/dist/assets/stage-keyboard-BY7u9_MB.js +1 -0
  97. package/dist/assets/stage-overlay-set-DRFcVd27.js +1 -0
  98. package/dist/assets/stage-presence-markers-D2IpuOAY.js +1 -0
  99. package/dist/assets/stage-transform-tools-BGcIULoe.js +1 -0
  100. package/dist/assets/story-capture-RSWY8I8h.js +1 -0
  101. package/dist/assets/three-integration.service-0EyPpd5f.js +4 -0
  102. package/dist/assets/{three.module-ZILb6uB7.js → three.module-CrYDk-Xr.js} +1 -1
  103. package/dist/assets/transform-mode-request-Cz6fzydi.js +1 -0
  104. package/dist/assets/transport-strip-Co-ZDkf-.js +1 -0
  105. package/dist/assets/{vgai-shared-fontawesome-CFSkqz69.js → vgai-shared-fontawesome-2ZSGa7vM.js} +1 -1
  106. package/dist/assets/vgai-shared-jsx-dev-runtime-hkPLeIJV.js +1 -0
  107. package/dist/assets/vgai-shared-jsx-runtime-CUvvjEqj.js +1 -0
  108. package/dist/assets/{vgai-shared-react-dom-client-S0ozfl6_.js → vgai-shared-react-dom-client-CS681GK2.js} +1 -1
  109. package/dist/assets/{vgai-shared-three-DzfWDqlp.js → vgai-shared-three-CLJ0K3jQ.js} +1 -1
  110. package/dist/assets/viewport-door-BdL0u5rd.js +1 -0
  111. package/dist/assets/viewport-editor-controls-BYaAZ_Ku.js +1 -0
  112. package/dist/assets/viewport-surface-status-yS6CrXH7.js +24 -0
  113. package/dist/assets/{worker-B7zhIsFh.js → worker-CC9Ug5Ei.js} +1 -1
  114. package/dist/assets/world-documents-B5IWN-ng.js +3 -0
  115. package/dist/vgai-shared-react.json +4 -4
  116. package/dist/vgai-shared-three.json +1 -1
  117. package/dist-node/cli.js +248 -209
  118. package/dist-node/create.js +77 -77
  119. package/package.json +10 -10
  120. package/src/index.ts +1 -0
  121. package/dist/assets/AudioViewer-CRWsJVYN.js +0 -1
  122. package/dist/assets/ColladaLoader-Ccy_gHsu.js +0 -3
  123. package/dist/assets/EntityModelDocument-Dal8YnLK.js +0 -1
  124. package/dist/assets/EnvironmentAssetDocument-DFOFYX5v.js +0 -1
  125. package/dist/assets/FBXLoader-Dh0pOBW2.js +0 -1
  126. package/dist/assets/ImageViewer-BzqBpqL-.js +0 -1
  127. package/dist/assets/InspectorObjectPreview-BUZEp4xS.js +0 -1
  128. package/dist/assets/JsonAssetDocument-DCkqRS0N.js +0 -2
  129. package/dist/assets/LiveModuleDocument-CuOBVz3A.js +0 -2
  130. package/dist/assets/LutAssetDocument-IyEir1rq.js +0 -1
  131. package/dist/assets/ModelAssetDocument-DNStNyCc.js +0 -1
  132. package/dist/assets/NonThreeAuthoringBootstrap-BE15Wpmw.js +0 -2
  133. package/dist/assets/OBJLoader-CopWRneC.js +0 -5
  134. package/dist/assets/Object3DDocumentToolbar-5Dv_8caG.js +0 -1
  135. package/dist/assets/Object3DPreview-C09u9uQZ.js +0 -2
  136. package/dist/assets/OnlineAssetDetail-DOPUI1iu.js +0 -1
  137. package/dist/assets/OrbitControls-DrFzvAAB.js +0 -1
  138. package/dist/assets/PLYLoader-D_esTZ2f.js +0 -2
  139. package/dist/assets/QuarksAssetDocument-BbSJ970L.js +0 -2
  140. package/dist/assets/RectAreaLightUniformsLib-u1ciScuw.js +0 -1
  141. package/dist/assets/STLLoader-Cl5I0sAi.js +0 -1
  142. package/dist/assets/SourceAssetViewer-DwhuqbA4.js +0 -1
  143. package/dist/assets/StageHost-D-o8MsFS.js +0 -1122
  144. package/dist/assets/TDSLoader-KKBg8ef1.js +0 -1
  145. package/dist/assets/ToolObject3DPreview-ILbch3kN.js +0 -1
  146. package/dist/assets/Toolbar-DYJjJKTt.js +0 -1
  147. package/dist/assets/TransientHint-D94hsJSR.js +0 -1
  148. package/dist/assets/VideoViewer-Bx3FPbgE.js +0 -1
  149. package/dist/assets/ViewportShadingMenu-B3N6hSdN.js +0 -1
  150. package/dist/assets/animation-mixers.service-N9HxGOMf.js +0 -1
  151. package/dist/assets/asset-editor-persistence-DGD05u26.js +0 -1
  152. package/dist/assets/blender-node-editor.document-BT2M622g.js +0 -1
  153. package/dist/assets/blender-runtime-host-4ufXy47O.js +0 -4
  154. package/dist/assets/blender-runtime.document-DeFQQsF6.js +0 -8
  155. package/dist/assets/blender-timeline.document-BnlSdxy0.js +0 -1
  156. package/dist/assets/blender-uv-editor.document-UC-XeNn0.js +0 -1
  157. package/dist/assets/blender-version.status-BZP39oH7.js +0 -1
  158. package/dist/assets/blender.command-IGP5wuda.js +0 -1
  159. package/dist/assets/blender.keymap-GAQgeklK.js +0 -1
  160. package/dist/assets/browserAll-2r3AVaAO.js +0 -14
  161. package/dist/assets/canvas-preview-frames-CO60PDM7.js +0 -5
  162. package/dist/assets/index-B4bmKkgY.css +0 -1
  163. package/dist/assets/index-cpXNKgvz.js +0 -1498
  164. package/dist/assets/live-mixers-BRkRHd6g.js +0 -1
  165. package/dist/assets/material-preview.view-DqNcpd_b.js +0 -1
  166. package/dist/assets/model-inspection-JC6gbV8Q.js +0 -1
  167. package/dist/assets/models.finder-BplPGS4I.js +0 -1
  168. package/dist/assets/product-CfZaqLpw.js +0 -1
  169. package/dist/assets/properties-bone-constraints.inspector-Di8kNtAi.js +0 -1
  170. package/dist/assets/properties-bone.inspector-CqAIKNsE.js +0 -1
  171. package/dist/assets/properties-collection.inspector-DpHC_fXW.js +0 -1
  172. package/dist/assets/properties-constraints.inspector-C7G7NOZU.js +0 -1
  173. package/dist/assets/properties-data.inspector-D1sUUst6.js +0 -1
  174. package/dist/assets/properties-material.inspector-BUSjc8tl.js +0 -1
  175. package/dist/assets/properties-modifiers.inspector-Sq9bcfFz.js +0 -1
  176. package/dist/assets/properties-object.inspector-BzqiU_29.js +0 -1
  177. package/dist/assets/properties-output.inspector-BWpFqvfT.js +0 -1
  178. package/dist/assets/properties-particles.inspector-DO1KoaTz.js +0 -1
  179. package/dist/assets/properties-physics.inspector-BgkrTNSA.js +0 -1
  180. package/dist/assets/properties-render.inspector-BU5NOVoQ.js +0 -1
  181. package/dist/assets/properties-scene.inspector-DbMErJ48.js +0 -1
  182. package/dist/assets/properties-texture.inspector-toPpEwqp.js +0 -1
  183. package/dist/assets/properties-view-layer.inspector-COpx9iEK.js +0 -1
  184. package/dist/assets/properties-world.inspector-CxU0DrYX.js +0 -1
  185. package/dist/assets/react-three-rapier.esm-CN6t4A7c.js +0 -1
  186. package/dist/assets/stage-keyboard-CzlqI0nh.js +0 -1
  187. package/dist/assets/stage-overlay-set-DQeskS16.js +0 -1
  188. package/dist/assets/stage-presence-markers-S1lMOwIa.js +0 -1
  189. package/dist/assets/stage-transform-tools-Cqtv-ZQ1.js +0 -1
  190. package/dist/assets/story-capture-DmIUyEQn.js +0 -1
  191. package/dist/assets/story-mount-turn-2IYGgHob.js +0 -1
  192. package/dist/assets/story-pixi-preview-aw8xQhvF.js +0 -1
  193. package/dist/assets/story-three-preview-DDmMjlI8.js +0 -37
  194. package/dist/assets/transform-mode-request-DSPwviXs.js +0 -1
  195. package/dist/assets/vgai-shared-jsx-dev-runtime-DFDKL7fx.js +0 -1
  196. package/dist/assets/vgai-shared-jsx-runtime-DIqBpTut.js +0 -1
  197. package/dist/assets/viewport-pick-context-DkawXbEi.js +0 -1
  198. package/dist/assets/viewport-surface-status-DuININWe.js +0 -20
  199. package/dist/assets/webworkerAll-CqQUotBj.js +0 -101
  200. package/dist/assets/world-documents-DkBqH8VU.js +0 -3
@@ -1,20 +0,0 @@
1
- import{bn as J,bo as yt,bp as Mt,bq as wt,br as bt,bg as nt,bs as St,t as xt}from"./index-cpXNKgvz.js";import{a$ as W,aJ as Q,b6 as kt,B as It,k as Ft,i as Pt,l as Ct,V as Y,bp as Et,bq as Gt,A as Rt,br as Tt,b as d,av as Z,h as f,a4 as it,Z as rt,_ as Dt,E as At,I as $t,L as H,e as st,b0 as Ot,bc as _t,aF as tt}from"./three.module-ZILb6uB7.js";import{a as Bt}from"./jsx-runtime-DPjLkJKQ.js";import"./index-DaQZGF7d.js";import"./index-CtzuWnCS.js";import"./index-D2LwEE0L.js";let at=0;function Lt(){at++}function oe(){return at}const ne=[.8,.5,-1],N=new f(1975600),U=new f(5004144);function Ht(){const i=typeof document>"u"?null:document.querySelector("[data-vgai-palette]");if(!i)return{bottom:N.clone(),top:U.clone()};const t=getComputedStyle(i),o=document.createElement("canvas");o.width=o.height=1;const e=o.getContext("2d"),r=(s,u)=>{const p=t.getPropertyValue(s).trim();if(!e||!p||!CSS.supports("color",p))return u.clone();e.fillStyle=u.getStyle(),e.fillRect(0,0,1,1),e.fillStyle=t.getPropertyValue("--vgai-surface-shell").trim(),e.fillRect(0,0,1,1),e.fillStyle=p,e.fillRect(0,0,1,1);const[y,l,M]=e.getImageData(0,0,1,1).data;return new f().setRGB(y/255,l/255,M/255,st)},n=r("--vgai-surface-panel",N),a=r("--vgai-surface-raised",U),h=n.lerp(N,.25).lerp(new f(16777215),.03),c=a.lerp(U,.25).lerp(new f(16777215),.04);return{bottom:h,top:c}}function ie(i){if(typeof document>"u"||typeof MutationObserver>"u")return()=>{};const t=document.querySelector("[data-vgai-palette]");if(!t)return()=>{};const o=new MutationObserver(()=>{i(),Lt()});return o.observe(t,{attributes:!0,attributeFilter:["data-vgai-palette","data-vgai-material"]}),()=>o.disconnect()}function zt(i=Ht()){const o=new Uint8Array(512),e=new f;for(let n=0;n<128;n++)e.copy(i.bottom).lerp(i.top,n/127).convertLinearToSRGB(),o[n*4]=Math.round(e.r*255),o[n*4+1]=Math.round(e.g*255),o[n*4+2]=Math.round(e.b*255),o[n*4+3]=255;const r=new it(o,1,128,rt);return r.colorSpace=st,r.magFilter=H,r.minFilter=H,r.needsUpdate=!0,r}function Nt(i){const t=nt(i);if(t.isEmpty())return{size:50,centre:[0,0]};const o=Math.max(t.max.x-t.min.x,t.max.z-t.min.z);return{size:Math.min(Math.max(Math.ceil(o/10)*10+20,50),1e3),centre:[(t.min.x+t.max.x)/2,(t.min.z+t.max.z)/2]}}function Ut(i){for(const t of[1,2,5,10])if(i/t<=60)return Math.round(i/t);return Math.round(i/10)}function qt(i,t){const o=t/2,e=o*.55,r=o;i.onBeforeCompile=n=>{n.uniforms.uGridFadeStart={value:e},n.uniforms.uGridFadeEnd={value:r},n.vertexShader=n.vertexShader.replace("#include <common>",`#include <common>
2
- varying vec2 vGridPlanePosition;`).replace("#include <begin_vertex>",`#include <begin_vertex>
3
- vGridPlanePosition = position.xz;`),n.fragmentShader=n.fragmentShader.replace("#include <common>",`#include <common>
4
- varying vec2 vGridPlanePosition;
5
- uniform float uGridFadeStart;
6
- uniform float uGridFadeEnd;`).replace("#include <color_fragment>",`#include <color_fragment>
7
- diffuseColor.a *= 1.0 - smoothstep(uGridFadeStart, uGridFadeEnd, length(vGridPlanePosition));`)},i.customProgramCacheKey=()=>`vgai-grid-fade:${e}:${r}`}function re(i,t){const{environment:o,background:e=!0,keyLight:r=!0,grid:n=!1}=t,a=[],h=[];let c=null;if(o&&(i.environment=o.texture),e&&(c=zt(),i.background=c),r){const l=new W(16774109,1.9);l.name="vgai:standard-dressing-key",l.position.set(6,10,-4),l.castShadow=!0,J(l,"editorHelper",!0),i.add(l),a.push(l),h.push(l)}let s=null,u="";const p=l=>{if(!n)return;const{size:M,centre:w}=Nt(l),b=`${M}:${w.join(":")}`;if(b===u)return;u=b,s&&(s.removeFromParent(),s.dispose(),a.splice(a.indexOf(s),1));const g=new Ot(M,Ut(M),10066329,10066329);s=g;const S=g.material;S.transparent=!0,S.opacity=.35,S.depthWrite=!1,qt(S,M),g.name="vgai:standard-dressing-grid",g.position.set(w[0],-.02,w[1]),g.layers.set(St),J(g,"editorHelper",!0),i.add(g),a.push(g)};p(t.content??i);let y=!1;return{backgroundTexture:c,lights:h,frameContent:p,dispose(){if(!y){y=!0;for(const l of a)l.removeFromParent(),l.dispose?.();o&&(i.environment===o.texture&&(i.environment=null),o.dispose()),c&&(i.background===c&&(i.background=null),c.dispose())}}}}const q=12,Vt=`
8
- vec3 vgaiHable( vec3 x ) {
9
- const float A = 0.22 * 4.0;
10
- const float B = 0.30 * 2.0;
11
- const float C = 0.10;
12
- const float D = 0.20;
13
- const float E = 0.01;
14
- const float F = 0.30;
15
- return ( ( x * ( A * x + C * B ) + D * E ) / ( x * ( A * x + B ) + D * F ) ) - E / F;
16
- }
17
- vec3 CustomToneMapping( vec3 color ) {
18
- color *= toneMappingExposure;
19
- return clamp( vgaiHable( max( vec3( 0.0 ), color ) ) / vgaiHable( vec3( 1.0 ) ), 0.0, 1.0 );
20
- }`;{const i=tt.tonemapping_pars_fragment,t="vec3 CustomToneMapping( vec3 color ) { return color; }";i.includes(t)&&(tt.tonemapping_pars_fragment=i.replace(t,Vt))}const Wt={none:Tt,aces:Rt,agx:Gt,filmic:Et};function et(i){return`image|${i.id}|${i.url}`}function V(i){return i*i*(3-2*i)}function k(i,t,o){let e=Math.imul(i,374761393)^Math.imul(t,668265263)^Math.imul(o,1440662683);return e=Math.imul(e^e>>>13,1274126177),((e^e>>>16)>>>0)/4294967296}function jt(i,t,o){const e=Math.floor(i),r=Math.floor(t),n=Math.floor(o),a=V(i-e),h=V(t-r),c=V(o-n),s=d.lerp,u=s(k(e,r,n),k(e+1,r,n),a),p=s(k(e,r+1,n),k(e+1,r+1,n),a),y=s(k(e,r,n+1),k(e+1,r,n+1),a),l=s(k(e,r+1,n+1),k(e+1,r+1,n+1),a);return s(s(u,p,h),s(y,l,h),c)}function lt(i,t,o){let e=0,r=.5,n=1,a=0;for(let h=0;h<5;h++)e+=r*jt(i*n,t*n,o*n),a+=r,r*=.5,n*=2;return e/a}let A=null;function Kt(i){if(!A){const o=new Float32Array(4096);for(let e=0;e<o.length;e++){const r=1-2*(e+.5)/o.length,n=Math.sqrt(1-r*r),a=e*2.399963229728653;o[e]=lt(Math.cos(a)*n*4,r*4,Math.sin(a)*n*4)}A=o.sort()}const t=d.clamp(Math.round((1-i)*(A.length-1)),0,A.length-1);return A[t]}function Xt(i){if(!i)return null;const t=(e,r)=>typeof e=="number"&&Number.isFinite(e)?e:r,o={cover:d.clamp(t(i.cover,.5),0,1),opacity:d.clamp(t(i.opacity,1),0,1),scale:Math.max(t(i.scale,4),.1)};return o.cover>0&&o.opacity>0?o:null}const R=4,ot=400;class se{constructor(t,o){this.onReady=o,this.group.name="vgai:stage-presentation-rig",this.group.userData.editorHelper=!0,this.group.add(this.ambient),t.add(this.group),this.previewGroup.name="vgai:stage-preview-rig",this.previewGroup.userData.editorHelper=!0,this.sun.name="vgai:preview-sun",this.sun.userData.editorHelper=!0,this.previewGroup.add(this.sun,this.sun.target),this.previewGroup.visible=!1,t.add(this.previewGroup),this.floor.name="vgai:preview-floor",this.floor.userData.editorHelper=!0,this.floor.receiveShadow=!0,this.floor.visible=!1,t.add(this.floor)}group=new Q;ambient=new kt(16777215,0);lights=[];preset=null;presentation=null;source="studio";previewGroup=new Q;sun=new W(16777215,1);floorBounds=new It;floorContent=null;floor=new Ft(new Pt(ot,ot).rotateX(-Math.PI/2),new Ct({roughness:.9,metalness:0,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1}));sky=null;pmrem=null;direction=new Y;loadingImage=null;pendingImage=null;failedImages=new Set;latestSky=null;rotation=0;disposed=!1;apply(t,o,e,r={}){this.presentation=t;const{lighting:n}=t,a=r.floor!==!1&&t.overlays.floor.visible,h=a&&!this.floor.visible;this.floor.visible=a,h&&this.floorContent&&this.placeFloor(this.floorContent),this.floor.material.color.set(t.overlays.floor.color);const c=yt(n.studioPreset);c!==this.preset&&this.build(c),this.source=n.source,this.group.visible=n.source==="studio",r.tone!==!1&&(o.toneMapping=e??Wt[n.tone.mapper],o.toneMappingExposure=n.tone.exposure);const{sun:s,environment:u}=n.preview,p=d.degToRad(s.altitude),y=d.degToRad(s.azimuth);this.sun.color.set(s.color),this.sun.intensity=s.enabled?s.energy:0,this.sun.position.set(Math.sin(y)*Math.cos(p),Math.sin(p),-Math.cos(y)*Math.cos(p)).multiplyScalar(q),this.sun.castShadow=s.enabled&&s.shadowDistance>0;const l=Math.min(Math.max(s.shadowDistance,1),50)/2;if(Object.assign(this.sun.shadow.camera,{left:-l,right:l,top:l,bottom:-l}),this.sun.shadow.camera.updateProjectionMatrix(),this.sun.updateMatrixWorld(),this.sun.target.updateMatrixWorld(),this.rotation=d.degToRad(u.rotation),!(r.sky!==!1&&u.enabled&&(n.source==="preview"||t.backdrop.source==="environment"))){this.loadingImage=null,this.pendingImage=null;return}const w=u.image===null?null:Mt(u.image),b=()=>this.buildSky(u.sky,o,s.enabled?{direction:this.sun.position.clone().normalize(),color:s.color,energy:s.energy}:null);if(this.latestSky=b,w&&!this.failedImages.has(et(w))){this.sky||b(),this.buildImage(w,o);return}this.loadingImage=null,this.pendingImage=u.image===null?null:{id:u.image,state:w?"failed":"unregistered"},b()}buildImage(t,o){const e=et(t);if(this.sky?.key===e){this.pendingImage=null;return}this.loadingImage!==e&&(this.loadingImage=e,this.pendingImage={id:t.id,state:"loading"},wt(t.url,t.format).then(r=>{if(this.disposed||this.loadingImage!==e){r.dispose();return}let n;try{this.pmrem??=new Z(o),n=this.pmrem.fromEquirectangular(r)}catch(a){throw r.dispose(),a}this.loadingImage=null,this.pendingImage=null,this.disposeSky(),this.sky={key:e,image:t.id,background:r,environment:n},this.onReady?.()}).catch(r=>{this.disposed||this.loadingImage!==e||(this.loadingImage=null,this.failedImages.add(e),this.pendingImage={id:t.id,state:"failed"},bt.error(`Environment image "${t.id}" (${t.url}) did not load: ${String(r)}`,"viewport"),this.latestSky?.(),this.onReady?.())}))}placeFloor(t){if(this.floorContent=t,!this.floor.visible)return;const o=nt(t,this.floorBounds);this.floor.position.y=o.isEmpty()?0:o.min.y,this.floor.updateMatrixWorld()}forgetFailedImages(){this.failedImages.clear()}sceneLightsShown(){return this.source!=="preview"||this.presentation?.lighting.preview.sceneLights!==!1}imageReport(){return{shown:this.sky?.image??null,pending:this.pendingImage}}turn(){return this.sky?.image?this.rotation:0}buildSky(t,o,e){const r=e?`${e.direction.toArray().map(m=>m.toFixed(4)).join(",")}|${e.color}|${e.energy}`:"none",n=Xt(t.clouds),a=n?`${n.cover}|${n.opacity}|${n.scale}`:"clear",h=`${t.top}|${t.horizon}|${t.ground}|${t.topCurve}|${t.groundCurve}|${a}|${r}`;if(this.sky?.key===h)return;this.disposeSky();const c=1024,s=512,u=d.degToRad(.5),p=d.degToRad(30),y=.15,l=new f(t.top),M=new f(t.horizon),w=new f(t.ground),b=e?new f(e.color).multiplyScalar(e.energy):null,g=new Uint16Array(c*s*4),S=m=>_t.toHalfFloat(Math.min(m,65504)),ct=Math.max(t.topCurve,.001),ut=Math.max(t.groundCurve,.001),$=new f,I=new f,dt=new f(.92,.93,.95).lerp(M,.2),T=c/R,z=s/2/R+1,j=n?Kt(n.cover):1;let O=null;if(n){O=new Float32Array(T*z);for(let m=0;m<z;m++){const P=((Math.min(s/2+m*R,s-1)+.5)/s-.5)*Math.PI;for(let C=0;C<T;C++){const v=((C*R+.5)/c-.5)*Math.PI*2;O[m*T+C]=lt(Math.cos(v)*Math.cos(P)*n.scale,Math.sin(P)*n.scale,Math.sin(v)*Math.cos(P)*n.scale)}}}const K=new Y;for(let m=0;m<s;m++){const x=((m+.5)/s-.5)*Math.PI,P=Math.PI/2-x;if(P<=Math.PI/2){const v=1-P/(Math.PI/2);$.copy(M).lerp(l,d.clamp(1-Math.pow(1-v,1/ct),0,1))}else{const v=(P-Math.PI/2)/(Math.PI/2);$.copy(M).lerp(w,d.clamp(1-Math.pow(1-v,1/ut),0,1))}const C=n&&x>0?d.smoothstep(Math.sin(x),0,.25):0;for(let v=0;v<c;v++){if(I.copy($),n&&O&&C>0){const D=v/R,E=(m-s/2)/R,G=Math.floor(D),B=Math.max(0,Math.floor(E)),X=D-G,pt=E-Math.floor(E),L=(ft,vt)=>O[Math.min(vt,z-1)*T+ft%T],gt=d.lerp(d.lerp(L(G,B),L(G+1,B),X),d.lerp(L(G,B+1),L(G+1,B+1),X),pt),mt=d.smoothstep(gt,j-.1,j+.1);I.lerp(dt,mt*n.opacity*C)}if(b&&e&&x>-Math.PI/2){const D=((v+.5)/c-.5)*Math.PI*2;K.set(Math.cos(D)*Math.cos(x),Math.sin(x),Math.sin(D)*Math.cos(x));const E=K.angleTo(e.direction);if(E<u)I.copy(b);else if(E<p){const G=(E-u)/(p-u);I.copy(b).lerp($,d.clamp(1-Math.pow(1-G,1/y),0,1))}}const _=(m*c+v)*4;g[_]=S(I.r),g[_+1]=S(I.g),g[_+2]=S(I.b),g[_+3]=S(1)}}const F=new it(g,c,s,rt,Dt);F.mapping=At,F.colorSpace=$t,F.magFilter=H,F.minFilter=H,F.needsUpdate=!0,this.pmrem??=new Z(o);const ht=this.pmrem.fromEquirectangular(F);this.sky={key:h,image:null,background:F,environment:ht}}disposeSky(){this.sky?.background.dispose(),this.sky?.environment.dispose(),this.sky=null}environment(){const t=this.presentation?.lighting;return t?this.source==="studio"?{texture:null,intensity:this.preset?.environmentIntensity??0,rotation:0}:this.source==="preview"?t.preview.environment.enabled?{texture:this.sky?.environment.texture??null,intensity:t.preview.environment.energy,rotation:this.turn()}:{texture:null,intensity:0,rotation:0}:null:null}backdrop(){const t=this.presentation?.backdrop;return!t||t.source==="fill"||t.source==="scene"?"keep":t.source==="transparent"?{value:null,blur:0,intensity:1,rotation:0}:t.source==="color"?{value:new f(t.color),blur:0,intensity:1,rotation:0}:this.sky?{value:this.sky.background,blur:t.blur,intensity:t.opacity,rotation:this.turn()}:"keep"}resolveSource(t){const o=this.presentation?.lighting;let e=o?.source??"studio";return o?.auto&&e!=="scene"&&o.auto.takeover.some(r=>t[r]===!0)&&(e="scene"),this.source=e,this.group.visible=e==="studio",this.previewGroup.visible=e==="preview",e}roots(){return[this.group,this.previewGroup,this.floor]}lightsVisible(){return this.group.visible&&this.lights.length>0}presetId(){return this.preset?.id??null}update(t){if(this.group.visible)for(const{light:o,spec:e}of this.lights)this.direction.set(...e.direction).normalize(),e.space==="camera"&&this.direction.applyQuaternion(t.quaternion),o.position.copy(this.direction).multiplyScalar(-q),o.target.position.set(0,0,0),o.updateMatrixWorld(),o.target.updateMatrixWorld()}dispose(){this.disposed=!0,this.clearLights(),this.group.removeFromParent(),this.previewGroup.removeFromParent(),this.floor.removeFromParent(),this.floor.geometry.dispose(),this.floor.material.dispose(),this.sun.dispose(),this.disposeSky(),this.pmrem?.dispose()}build(t){this.clearLights(),this.preset=t,this.ambient.color.set(t.ambient.color),this.ambient.intensity=t.ambient.intensity;for(const o of t.lights){const e=new W(o.color,o.intensity);e.name=`vgai:studio-light:${t.id}`,e.castShadow=o.castShadow===!0,e.userData.editorHelper=!0,this.group.add(e),this.group.add(e.target),this.lights.push({light:e,spec:o})}this.direction.set(0,0,0);for(const{light:o,spec:e}of this.lights)e.space==="world"&&(this.direction.set(...e.direction).normalize(),o.position.copy(this.direction).multiplyScalar(-q),o.updateMatrixWorld(),o.target.updateMatrixWorld())}clearLights(){for(const{light:t}of this.lights)t.removeFromParent(),t.target.removeFromParent(),t.dispose();this.lights=[]}}const ae="Preparing the viewport…";function le({testId:i,children:t}){return Bt.jsx("div",{"data-testid":i,style:{position:"absolute",inset:0,padding:16,fontSize:12,color:xt.content.muted,pointerEvents:"none"},children:t})}export{ae as O,ne as S,le as V,se as a,re as b,zt as c,Lt as i,oe as s,ie as w};
@@ -1,101 +0,0 @@
1
- import{D as v,u as C,a as Q,B as z,c as R,g as T,n as te,G as Ce,M as ce,d as F,E as P,f as E,b as Se,e as he}from"./canvas-preview-frames-CO60PDM7.js";import"./index-cpXNKgvz.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-ZILb6uB7.js";const B=Object.create(null),re=Object.create(null);function Z(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
-
3
- #ifdef GL_ES // This checks if it is WebGL1
4
- #define in varying
5
- #define finalColor gl_FragColor
6
- #define texture texture2D
7
- #endif
8
- ${s}
9
- `):`
10
-
11
- #ifdef GL_ES // This checks if it is WebGL1
12
- #define in attribute
13
- #define out varying
14
- #endif
15
- ${s}
16
- `}function Me(s,e,t){const r=t?e.maxSupportedFragmentPrecision:e.maxSupportedVertexPrecision;if(s.substring(0,9)!=="precision"){let i=t?e.requestedFragmentPrecision:e.requestedVertexPrecision;return i==="highp"&&r!=="highp"&&(i="mediump"),`precision ${i} float;
17
- ${s}`}else if(r!=="highp"&&s.substring(0,15)==="precision highp")return s.replace("precision highp","precision mediump");return s}function Re(s,e){return e?`#version 300 es
18
- ${s}`:s}const Ee={},ke={};function Ge(s,{name:e="pixi-program"},t=!0){e=e.replace(/\s+/g,"-"),e+=t?"-fragment":"-vertex";const r=t?Ee:ke;return r[e]?(r[e]++,e+=`-${r[e]}`):r[e]=1,s.indexOf("#define SHADER_NAME")!==-1?s:`${`#define SHADER_NAME ${e}`}
19
- ${s}`}function Oe(s,e){return e?s.replace("#version 300 es",""):s}const V={stripVersion:Oe,ensurePrecision:Me,addProgramDefines:Ae,setProgramName:Ge,insertVersion:Re},I=Object.create(null),de=class j{constructor(e){e={...j.defaultOptions,...e};const t=e.fragment.indexOf("#version 300 es")!==-1,r={stripVersion:t,ensurePrecision:{requestedFragmentPrecision:e.preferredFragmentPrecision,requestedVertexPrecision:e.preferredVertexPrecision,maxSupportedVertexPrecision:"highp",maxSupportedFragmentPrecision:Ie()},setProgramName:{name:e.name},addProgramDefines:t,insertVersion:t};let i=e.fragment,n=e.vertex;Object.keys(V).forEach(o=>{const a=r[o];i=V[o](i,a,!0),n=V[o](n,a,!1)}),this.fragment=i,this.vertex=n,this.transformFeedbackVaryings=e.transformFeedbackVaryings,this._key=Z(`${this.vertex}:${this.fragment}`,"gl-program")}destroy(){this.fragment=null,this.vertex=null,this._attributeData=null,this._uniformData=null,this._uniformBlockData=null,this.transformFeedbackVaryings=null,I[this._cacheKey]=null}static from(e){const t=`${e.vertex}:${e.fragment}`;return I[t]||(I[t]=new j(e),I[t]._cacheKey=t),I[t]}};de.defaultOptions={preferredVertexPrecision:"highp",preferredFragmentPrecision:"mediump"};let J=de;const ie={uint8x2:{size:2,stride:2,normalised:!1},uint8x4:{size:4,stride:4,normalised:!1},sint8x2:{size:2,stride:2,normalised:!1},sint8x4:{size:4,stride:4,normalised:!1},unorm8x2:{size:2,stride:2,normalised:!0},unorm8x4:{size:4,stride:4,normalised:!0},snorm8x2:{size:2,stride:2,normalised:!0},snorm8x4:{size:4,stride:4,normalised:!0},uint16x2:{size:2,stride:4,normalised:!1},uint16x4:{size:4,stride:8,normalised:!1},sint16x2:{size:2,stride:4,normalised:!1},sint16x4:{size:4,stride:8,normalised:!1},unorm16x2:{size:2,stride:4,normalised:!0},unorm16x4:{size:4,stride:8,normalised:!0},snorm16x2:{size:2,stride:4,normalised:!0},snorm16x4:{size:4,stride:8,normalised:!0},float16x2:{size:2,stride:4,normalised:!1},float16x4:{size:4,stride:8,normalised:!1},float32:{size:1,stride:4,normalised:!1},float32x2:{size:2,stride:8,normalised:!1},float32x3:{size:3,stride:12,normalised:!1},float32x4:{size:4,stride:16,normalised:!1},uint32:{size:1,stride:4,normalised:!1},uint32x2:{size:2,stride:8,normalised:!1},uint32x3:{size:3,stride:12,normalised:!1},uint32x4:{size:4,stride:16,normalised:!1},sint32:{size:1,stride:4,normalised:!1},sint32x2:{size:2,stride:8,normalised:!1},sint32x3:{size:3,stride:12,normalised:!1},sint32x4:{size:4,stride:16,normalised:!1}};function De(s){return ie[s]??ie.float32}const ze={f32:"float32","vec2<f32>":"float32x2","vec3<f32>":"float32x3","vec4<f32>":"float32x4",vec2f:"float32x2",vec3f:"float32x3",vec4f:"float32x4",i32:"sint32","vec2<i32>":"sint32x2","vec3<i32>":"sint32x3","vec4<i32>":"sint32x4",vec2i:"sint32x2",vec3i:"sint32x3",vec4i:"sint32x4",u32:"uint32","vec2<u32>":"uint32x2","vec3<u32>":"uint32x3","vec4<u32>":"uint32x4",vec2u:"uint32x2",vec3u:"uint32x3",vec4u:"uint32x4",bool:"uint32","vec2<bool>":"uint32x2","vec3<bool>":"uint32x3","vec4<bool>":"uint32x4"},se=/@location\((\d+)\)\s+([a-zA-Z0-9_]+)\s*:\s*([a-zA-Z0-9_<>]+)(?:,|\s|\)|$)/g;function ne(s,e){let t;for(;(t=se.exec(s))!==null;){const r=ze[t[3]]??"float32";e[t[2]]={location:parseInt(t[1],10),format:r,stride:De(r).stride,offset:0,instance:!1,start:0}}se.lastIndex=0}function Be(s){return s.replace(/\/\/.*$/gm,"").replace(/\/\*[\s\S]*?\*\//g,"")}function Ve({source:s,entryPoint:e}){const t={},r=Be(s),i=r.indexOf(`fn ${e}(`);if(i===-1)return t;const n=r.indexOf("->",i);if(n===-1)return t;const o=r.substring(i,n);if(ne(o,t),Object.keys(t).length===0){const a=o.match(/\(\s*\w+\s*:\s*(\w+)/);if(a){const u=a[1],c=new RegExp(`struct\\s+${u}\\s*\\{([^}]+)\\}`,"s"),h=r.match(c);h&&ne(h[1],t)}}return t}function L(s){const e=/(^|[^/])@(group|binding)\(\d+\)[^;]+;/g,t=/@group\((\d+)\)/,r=/@binding\((\d+)\)/,i=/var(<[^>]+>)? (\w+)/,n=/:\s*([\w<>]+)/,o=/struct\s+(\w+)\s*{([^}]+)}/g,a=/(\w+)\s*:\s*([\w\<\>]+)/g,u=/struct\s+(\w+)/,c=s.match(e)?.map(l=>({group:parseInt(l.match(t)[1],10),binding:parseInt(l.match(r)[1],10),name:l.match(i)[2],isUniform:l.match(i)[1]==="<uniform>",type:l.match(n)[1]}));if(!c)return{groups:[],structs:[]};const h=s.match(o)?.map(l=>{const d=l.match(u)[1],f=l.match(a).reduce((g,m)=>{const[x,_]=m.split(":");return g[x.trim()]=_.trim(),g},{});return f?{name:d,members:f}:null}).filter(({name:l})=>c.some(d=>d.type===l||d.type.includes(`<${l}>`)))??[];return{groups:c,structs:h}}var w=(s=>(s[s.VERTEX=1]="VERTEX",s[s.FRAGMENT=2]="FRAGMENT",s[s.COMPUTE=4]="COMPUTE",s))(w||{});function Le({groups:s}){const e=[];for(let t=0;t<s.length;t++){const r=s[t];e[r.group]||(e[r.group]=[]),r.isUniform?e[r.group].push({binding:r.binding,visibility:w.VERTEX|w.FRAGMENT,buffer:{type:"uniform"}}):r.type==="sampler"?e[r.group].push({binding:r.binding,visibility:w.FRAGMENT,sampler:{type:"filtering"}}):r.type==="texture_2d"||r.type.startsWith("texture_2d<")?e[r.group].push({binding:r.binding,visibility:w.FRAGMENT,texture:{sampleType:"float",viewDimension:"2d",multisampled:!1}}):r.type==="texture_2d_array"||r.type.startsWith("texture_2d_array<")?e[r.group].push({binding:r.binding,visibility:w.FRAGMENT,texture:{sampleType:"float",viewDimension:"2d-array",multisampled:!1}}):(r.type==="texture_cube"||r.type.startsWith("texture_cube<"))&&e[r.group].push({binding:r.binding,visibility:w.FRAGMENT,texture:{sampleType:"float",viewDimension:"cube",multisampled:!1}})}for(let t=0;t<e.length;t++)e[t]||(e[t]=[]);return e}function Ne({groups:s}){const e=[];for(let t=0;t<s.length;t++){const r=s[t];e[r.group]||(e[r.group]={}),e[r.group][r.name]=r.binding}return e}function Ue(s,e){const t=new Set,r=new Set,i=[...s.structs,...e.structs].filter(o=>t.has(o.name)?!1:(t.add(o.name),!0)),n=[...s.groups,...e.groups].filter(o=>{const a=`${o.name}-${o.binding}`;return r.has(a)?!1:(r.add(a),!0)});return{structs:i,groups:n}}const A=Object.create(null);class M{constructor(e){this._layoutKey=0,this._attributeLocationsKey=0;const{fragment:t,vertex:r,layout:i,gpuLayout:n,name:o}=e;if(this.name=o,this.fragment=t,this.vertex=r,t.source===r.source){const a=L(t.source);this.structsAndGroups=a}else{const a=L(r.source),u=L(t.source);this.structsAndGroups=Ue(a,u)}this.layout=i??Ne(this.structsAndGroups),this.gpuLayout=n??Le(this.structsAndGroups),this.autoAssignGlobalUniforms=this.layout[0]?.globalUniforms!==void 0,this.autoAssignLocalUniforms=this.layout[1]?.localUniforms!==void 0,this._generateProgramKey()}_generateProgramKey(){const{vertex:e,fragment:t}=this,r=e.source+t.source+e.entryPoint+t.entryPoint;this._layoutKey=Z(r,"program")}get attributeData(){return this._attributeData??(this._attributeData=Ve(this.vertex)),this._attributeData}destroy(){this.gpuLayout=null,this.layout=null,this.structsAndGroups=null,this.fragment=null,this.vertex=null,A[this._cacheKey]=null}static from(e){const t=`${e.vertex.source}:${e.fragment.source}:${e.fragment.entryPoint}:${e.vertex.entryPoint}`;return A[t]||(A[t]=new M(e),A[t]._cacheKey=t),A[t]}}const fe=["f32","i32","vec2<f32>","vec3<f32>","vec4<f32>","mat2x2<f32>","mat3x3<f32>","mat4x4<f32>","mat3x2<f32>","mat4x2<f32>","mat2x3<f32>","mat4x3<f32>","mat2x4<f32>","mat3x4<f32>","vec2<i32>","vec3<i32>","vec4<i32>"],$e=fe.reduce((s,e)=>(s[e]=!0,s),{});function We(s,e){switch(s){case"f32":return 0;case"vec2<f32>":return new Float32Array(2*e);case"vec3<f32>":return new Float32Array(3*e);case"vec4<f32>":return new Float32Array(4*e);case"mat2x2<f32>":return new Float32Array([1,0,0,1]);case"mat3x3<f32>":return new Float32Array([1,0,0,0,1,0,0,0,1]);case"mat4x4<f32>":return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}return null}const pe=class ge{constructor(e,t){this._touched=0,this.uid=C("uniform"),this._resourceType="uniformGroup",this._resourceId=C("resource"),this.isUniformGroup=!0,this._dirtyId=0,this.destroyed=!1,t={...ge.defaultOptions,...t},this.uniformStructures=e;const r={};for(const i in e){const n=e[i];if(n.name=i,n.size=n.size??1,!$e[n.type]){const o=n.type.match(/^array<(\w+(?:<\w+>)?),\s*(\d+)>$/);if(o){const[,a,u]=o;throw new Error(`Uniform type ${n.type} is not supported. Use type: '${a}', size: ${u} instead.`)}throw new Error(`Uniform type ${n.type} is not supported. Supported uniform types are: ${fe.join(", ")}`)}n.value??(n.value=We(n.type,n.size)),r[i]=n.value}this.uniforms=r,this._dirtyId=1,this.ubo=t.ubo,this.isStatic=t.isStatic,this._signature=Z(Object.keys(r).map(i=>`${i}-${e[i].type}`).join("-"),"uniform-group")}update(){this._dirtyId++}};pe.defaultOptions={ubo:!1,isStatic:!1};let me=pe;class O{constructor(e){this.resources=Object.create(null),this._dirty=!0;let t=0;for(const r in e){const i=e[r];this.setResource(i,t++)}this._updateKey()}_updateKey(){if(!this._dirty)return;this._dirty=!1;const e=[];let t=0;for(const r in this.resources)e[t++]=this.resources[r]._resourceId;this._key=e.join("|")}setResource(e,t){const r=this.resources[t];e!==r&&(r?.off?.("change",this.onResourceChange,this),e.on?.("change",this.onResourceChange,this),this.resources[t]=e,this._dirty=!0)}getResource(e){return this.resources[e]}_touch(e,t){const r=this.resources;for(const i in r)r[i]._gcLastUsed=e,r[i]._touched=t}destroy(){const e=this.resources;for(const t in e)e[t]?.off?.("change",this.onResourceChange,this);this.resources=null}onResourceChange(e){this._dirty=!0,e.destroyed?this.destroy():this._updateKey()}}var D=(s=>(s[s.WEBGL=1]="WEBGL",s[s.WEBGPU=2]="WEBGPU",s[s.CANVAS=4]="CANVAS",s[s.BOTH=3]="BOTH",s))(D||{});class ee extends Q{constructor(e){super(),this.uid=C("shader"),this._uniformBindMap=Object.create(null),this._ownedBindGroups=[],this._destroyed=!1;let{gpuProgram:t,glProgram:r,groups:i,resources:n,compatibleRenderers:o,groupMap:a}=e;this.gpuProgram=t,this.glProgram=r,o===void 0&&(o=0,t&&(o|=D.WEBGPU),r&&(o|=D.WEBGL)),this.compatibleRenderers=o;const u={};if(!n&&!i&&(n={}),n&&i)throw new Error("[Shader] Cannot have both resources and groups");if(!t&&i&&!a)throw new Error("[Shader] No group map or WebGPU shader provided - consider using resources instead.");if(!t&&i&&a)for(const c in a)for(const h in a[c]){const l=a[c][h];u[l]={group:c,binding:h,name:l}}else if(t&&i&&!a){const c=t.structsAndGroups.groups;a={},c.forEach(h=>{a[h.group]=a[h.group]||{},a[h.group][h.binding]=h.name,u[h.name]=h})}else if(n){i={},a={},t&&t.structsAndGroups.groups.forEach(l=>{a[l.group]=a[l.group]||{},a[l.group][l.binding]=l.name,u[l.name]=l});let c=0;for(const h in n)u[h]||(i[99]||(i[99]=new O,this._ownedBindGroups.push(i[99])),u[h]={group:99,binding:c,name:h},a[99]=a[99]||{},a[99][c]=h,c++);for(const h in n){const l=h;let d=n[h];!d.source&&!d._resourceType&&(d=new me(d));const f=u[l];f&&(i[f.group]||(i[f.group]=new O,this._ownedBindGroups.push(i[f.group])),i[f.group].setResource(d,f.binding))}}this.groups=i,this._uniformBindMap=a,this.resources=this._buildResourceAccessor(i,u)}addResource(e,t,r){var i,n;(i=this._uniformBindMap)[t]||(i[t]={}),(n=this._uniformBindMap[t])[r]||(n[r]=e),this.groups[t]||(this.groups[t]=new O,this._ownedBindGroups.push(this.groups[t]))}_buildResourceAccessor(e,t){const r={};for(const i in t){const n=t[i];Object.defineProperty(r,n.name,{get(){return e[n.group].getResource(n.binding)},set(o){e[n.group].setResource(o,n.binding)}})}return r}destroy(e=!1){this._destroyed||(this._destroyed=!0,this.emit("destroy",this),e&&(this.gpuProgram?.destroy(),this.glProgram?.destroy()),this.gpuProgram=null,this.glProgram=null,this.removeAllListeners(),this._uniformBindMap=null,this._ownedBindGroups.forEach(t=>{t.destroy()}),this._ownedBindGroups=null,this.resources=null,this.groups=null)}static from(e){const{gpu:t,gl:r,...i}=e;let n,o;return t&&(n=M.from(t)),r&&(o=J.from(r)),new ee({gpuProgram:n,glProgram:o,...i})}}const Ye={normal:0,add:1,multiply:2,screen:3,overlay:4,erase:5,"normal-npm":6,"add-npm":7,"screen-npm":8,min:9,max:10},N=0,U=1,$=2,W=3,Y=4,X=5,H=class xe{constructor(){this.data=0,this.blendMode="normal",this.polygonOffset=0,this.blend=!0,this.depthMask=!0}get blend(){return!!(this.data&1<<N)}set blend(e){!!(this.data&1<<N)!==e&&(this.data^=1<<N)}get offsets(){return!!(this.data&1<<U)}set offsets(e){!!(this.data&1<<U)!==e&&(this.data^=1<<U)}set cullMode(e){if(e==="none"){this.culling=!1;return}this.culling=!0,this.clockwiseFrontFace=e==="front"}get cullMode(){return this.culling?this.clockwiseFrontFace?"front":"back":"none"}get culling(){return!!(this.data&1<<$)}set culling(e){!!(this.data&1<<$)!==e&&(this.data^=1<<$)}get depthTest(){return!!(this.data&1<<W)}set depthTest(e){!!(this.data&1<<W)!==e&&(this.data^=1<<W)}get depthMask(){return!!(this.data&1<<X)}set depthMask(e){!!(this.data&1<<X)!==e&&(this.data^=1<<X)}get clockwiseFrontFace(){return!!(this.data&1<<Y)}set clockwiseFrontFace(e){!!(this.data&1<<Y)!==e&&(this.data^=1<<Y)}get blendMode(){return this._blendMode}set blendMode(e){this.blend=e!=="none",this._blendMode=e,this._blendModeId=Ye[e]||0}get polygonOffset(){return this._polygonOffset}set polygonOffset(e){this.offsets=!!e,this._polygonOffset=e}toString(){return`[pixi.js/core:State blendMode=${this.blendMode} clockwiseFrontFace=${this.clockwiseFrontFace} culling=${this.culling} depthMask=${this.depthMask} polygonOffset=${this.polygonOffset}]`}static for2d(){const e=new xe;return e.depthTest=!1,e.blend=!0,e}};H.default2d=H.for2d();let Xe=H;const _e=class q extends ee{constructor(e){e={...q.defaultOptions,...e},super(e),this.enabled=!0,this._state=Xe.for2d(),this.blendMode=e.blendMode,this.padding=e.padding,typeof e.antialias=="boolean"?this.antialias=e.antialias?"on":"off":this.antialias=e.antialias,this.resolution=e.resolution,this.blendRequired=e.blendRequired,this.clipToViewport=e.clipToViewport,this.addResource("uTexture",0,1),e.blendRequired&&this.addResource("uBackTexture",0,3)}apply(e,t,r,i){e.applyFilter(this,t,r,i)}get blendMode(){return this._state.blendMode}set blendMode(e){this._state.blendMode=e}static from(e){const{gpu:t,gl:r,...i}=e;let n,o;return t&&(n=M.from(t)),r&&(o=J.from(r)),new q({gpuProgram:n,glProgram:o,...i})}};_e.defaultOptions={blendMode:"normal",resolution:1,padding:0,antialias:"off",blendRequired:!1,clipToViewport:!0};let je=_e;var b=(s=>(s[s.MAP_READ=1]="MAP_READ",s[s.MAP_WRITE=2]="MAP_WRITE",s[s.COPY_SRC=4]="COPY_SRC",s[s.COPY_DST=8]="COPY_DST",s[s.INDEX=16]="INDEX",s[s.VERTEX=32]="VERTEX",s[s.UNIFORM=64]="UNIFORM",s[s.STORAGE=128]="STORAGE",s[s.INDIRECT=256]="INDIRECT",s[s.QUERY_RESOLVE=512]="QUERY_RESOLVE",s[s.STATIC=1024]="STATIC",s))(b||{});class K extends Q{constructor(e){let{data:t,size:r}=e;const{usage:i,label:n,shrinkToFit:o}=e;super(),this._gpuData=Object.create(null),this._gcLastUsed=-1,this.autoGarbageCollect=!0,this.uid=C("buffer"),this._resourceType="buffer",this._resourceId=C("resource"),this._touched=0,this._updateID=1,this._dataInt32=null,this.shrinkToFit=!0,this.destroyed=!1,t instanceof Array&&(t=new Float32Array(t)),this._data=t,r??(r=t?.byteLength);const a=!!t;this.descriptor={size:r,usage:i,mappedAtCreation:a,label:n},this.shrinkToFit=o??!0}get data(){return this._data}set data(e){this.setDataWithSize(e,e.length,!0)}get dataInt32(){return this._dataInt32||(this._dataInt32=new Int32Array(this.data.buffer)),this._dataInt32}get static(){return!!(this.descriptor.usage&b.STATIC)}set static(e){e?this.descriptor.usage|=b.STATIC:this.descriptor.usage&=~b.STATIC}setDataWithSize(e,t,r){if(this._updateID++,this._updateSize=t*e.BYTES_PER_ELEMENT,this._data===e){r&&this.emit("update",this);return}const i=this._data;if(this._data=e,this._dataInt32=null,!i||i.length!==e.length){!this.shrinkToFit&&i&&e.byteLength<i.byteLength?r&&this.emit("update",this):(this.descriptor.size=e.byteLength,this._resourceId=C("resource"),this.emit("change",this));return}r&&this.emit("update",this)}update(e){this._updateSize=e??this._updateSize,this._updateID++,this.emit("update",this)}unload(){this.emit("unload",this);for(const e in this._gpuData)this._gpuData[e]?.destroy();this._gpuData=Object.create(null)}destroy(){this.destroyed=!0,this.unload(),this.emit("destroy",this),this.emit("change",this),this._data=null,this.descriptor=null,this.removeAllListeners()}}function ye(s,e){if(!(s instanceof K)){let t=e?b.INDEX:b.VERTEX;s instanceof Array&&(e?(s=new Uint32Array(s),t=b.INDEX|b.COPY_DST):(s=new Float32Array(s),t=b.VERTEX|b.COPY_DST)),s=new K({data:s,label:e?"index-mesh-buffer":"vertex-mesh-buffer",usage:t})}return s}function He(s,e,t){const r=s.getAttribute(e);if(!r)return t.minX=0,t.minY=0,t.maxX=0,t.maxY=0,t;const i=r.buffer.data;let n=1/0,o=1/0,a=-1/0,u=-1/0;const c=i.BYTES_PER_ELEMENT,h=(r.offset||0)/c,l=(r.stride||8)/c;for(let d=h;d<i.length;d+=l){const f=i[d],g=i[d+1];f>a&&(a=f),g>u&&(u=g),f<n&&(n=f),g<o&&(o=g)}return t.minX=n,t.minY=o,t.maxX=a,t.maxY=u,t}function qe(s){return(s instanceof K||Array.isArray(s)||s.BYTES_PER_ELEMENT)&&(s={buffer:s}),s.buffer=ye(s.buffer,!1),s}class Ke extends Q{constructor(e={}){super(),this._gpuData=Object.create(null),this.autoGarbageCollect=!0,this._gcLastUsed=-1,this.uid=C("geometry"),this._layoutKey=0,this.instanceCount=1,this._bounds=new z,this._boundsDirty=!0;const{attributes:t,indexBuffer:r,topology:i}=e;if(this.buffers=[],this.attributes={},t)for(const n in t)this.addAttribute(n,t[n]);this.instanceCount=e.instanceCount??1,r&&this.addIndex(r),this.topology=i||"triangle-list"}onBufferUpdate(){this._boundsDirty=!0,this.emit("update",this)}getAttribute(e){return this.attributes[e]}getIndex(){return this.indexBuffer}getBuffer(e){return this.getAttribute(e).buffer}getSize(){for(const e in this.attributes){const t=this.attributes[e];return t.buffer.data.length/(t.stride/4||t.size)}return 0}addAttribute(e,t){const r=qe(t);this.buffers.indexOf(r.buffer)===-1&&(this.buffers.push(r.buffer),r.buffer.on("update",this.onBufferUpdate,this),r.buffer.on("change",this.onBufferUpdate,this)),this.attributes[e]=r}addIndex(e){this.indexBuffer=ye(e,!0),this.buffers.push(this.indexBuffer)}get bounds(){return this._boundsDirty?(this._boundsDirty=!1,He(this,"aPosition",this._bounds)):this._bounds}unload(){this.emit("unload",this);for(const e in this._gpuData)this._gpuData[e]?.destroy();this._gpuData=Object.create(null)}destroy(e=!1){this.emit("destroy",this),this.removeAllListeners(),e&&this.buffers.forEach(t=>t.destroy()),this.unload(),this.indexBuffer?.destroy(),this.attributes=null,this.buffers=null,this.indexBuffer=null,this._bounds=null}}let S;function oe(s){const e=v.get().createCanvas(6,1),t=e.getContext("2d");return t.fillStyle=s,t.fillRect(0,0,6,1),e}function Qe(){if(S!==void 0)return S;try{const s=oe("#ff00ff"),e=oe("#ffff00"),r=v.get().createCanvas(6,1).getContext("2d");r.globalCompositeOperation="multiply",r.drawImage(s,0,0),r.drawImage(e,2,0);const i=r.getImageData(2,0,1,1);if(!i)S=!1;else{const n=i.data;S=n[0]===255&&n[1]===0&&n[2]===0}}catch{S=!1}return S}const p={canvas:null,convertTintToImage:!1,cacheStepsPerColorChannel:8,canUseMultiply:Qe(),tintMethod:null,_canvasSourceCache:new WeakMap,_unpremultipliedCache:new WeakMap,getCanvasSource:s=>{const e=s.source,t=e?.resource;if(!t)return null;const r=e.alphaMode==="premultiplied-alpha",i=e.resourceWidth??e.pixelWidth,n=e.resourceHeight??e.pixelHeight,o=i!==e.pixelWidth||n!==e.pixelHeight;if(r){if((t instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&t instanceof OffscreenCanvas)&&!o)return t;const a=p._unpremultipliedCache.get(e);if(a?.resourceId===e._resourceId)return a.canvas}if(t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int8Array||t instanceof Uint16Array||t instanceof Int16Array||t instanceof Uint32Array||t instanceof Int32Array||t instanceof Float32Array||t instanceof ArrayBuffer){const a=p._canvasSourceCache.get(e);if(a?.resourceId===e._resourceId)return a.canvas;const u=v.get().createCanvas(e.pixelWidth,e.pixelHeight),c=u.getContext("2d"),h=c.createImageData(e.pixelWidth,e.pixelHeight),l=h.data,d=t instanceof ArrayBuffer?new Uint8Array(t):new Uint8Array(t.buffer,t.byteOffset,t.byteLength);if(e.format==="bgra8unorm")for(let f=0;f<l.length&&f+3<d.length;f+=4)l[f]=d[f+2],l[f+1]=d[f+1],l[f+2]=d[f],l[f+3]=d[f+3];else l.set(d.subarray(0,l.length));return c.putImageData(h,0,0),p._canvasSourceCache.set(e,{canvas:u,resourceId:e._resourceId}),u}if(r){const a=v.get().createCanvas(e.pixelWidth,e.pixelHeight),u=a.getContext("2d",{willReadFrequently:!0});a.width=e.pixelWidth,a.height=e.pixelHeight,u.drawImage(t,0,0);const c=u.getImageData(0,0,a.width,a.height),h=c.data;for(let l=0;l<h.length;l+=4){const d=h[l+3];if(d>0){const f=255/d;h[l]=Math.min(255,h[l]*f+.5),h[l+1]=Math.min(255,h[l+1]*f+.5),h[l+2]=Math.min(255,h[l+2]*f+.5)}}return u.putImageData(c,0,0),p._unpremultipliedCache.set(e,{canvas:a,resourceId:e._resourceId}),a}if(o){const a=p._canvasSourceCache.get(e);if(a?.resourceId===e._resourceId)return a.canvas;const u=v.get().createCanvas(e.pixelWidth,e.pixelHeight),c=u.getContext("2d");return u.width=e.pixelWidth,u.height=e.pixelHeight,c.drawImage(t,0,0),p._canvasSourceCache.set(e,{canvas:u,resourceId:e._resourceId}),u}return t},getTintedCanvas:(s,e)=>{const t=s.texture,r=R.shared.setValue(e).toHex(),i=t.tintCache||(t.tintCache={}),n=i[r],o=t.source._resourceId;if(n?.tintId===o)return n;const a=n&&"getContext"in n?n:v.get().createCanvas();return p.tintMethod(t,e,a),a.tintId=o,i[r]=a,i[r]},getTintedPattern:(s,e)=>{const t=R.shared.setValue(e).toHex(),r=s.patternCache||(s.patternCache={}),i=s.source._resourceId;let n=r[t];return n?.tintId===i||(p.canvas||(p.canvas=v.get().createCanvas()),p.tintMethod(s,e,p.canvas),n=p.canvas.getContext("2d").createPattern(p.canvas,"repeat"),n.tintId=i,r[t]=n),n},applyPatternTransform:(s,e,t=!0)=>{if(!e)return;const r=s;if(!r.setTransform)return;const i=globalThis.DOMMatrix;if(!i)return;const n=new i([e.a,e.b,e.c,e.d,e.tx,e.ty]);r.setTransform(t?n.inverse():n)},tintWithMultiply:(s,e,t)=>{const r=t.getContext("2d"),i=s.frame.clone(),n=s.source._resolution??s.source.resolution??1,o=s.rotate;i.x*=n,i.y*=n,i.width*=n,i.height*=n;const a=T.isVertical(o),u=a?i.height:i.width,c=a?i.width:i.height;t.width=Math.ceil(u),t.height=Math.ceil(c),r.save(),r.fillStyle=R.shared.setValue(e).toHex(),r.fillRect(0,0,u,c),r.globalCompositeOperation="multiply";const h=p.getCanvasSource(s);if(!h){r.restore();return}o&&p._applyInverseRotation(r,o,i.width,i.height),r.drawImage(h,i.x,i.y,i.width,i.height,0,0,i.width,i.height),r.globalCompositeOperation="destination-atop",r.drawImage(h,i.x,i.y,i.width,i.height,0,0,i.width,i.height),r.restore()},tintWithOverlay:(s,e,t)=>{const r=t.getContext("2d"),i=s.frame.clone(),n=s.source._resolution??s.source.resolution??1,o=s.rotate;i.x*=n,i.y*=n,i.width*=n,i.height*=n;const a=T.isVertical(o),u=a?i.height:i.width,c=a?i.width:i.height;t.width=Math.ceil(u),t.height=Math.ceil(c),r.save(),r.globalCompositeOperation="copy",r.fillStyle=R.shared.setValue(e).toHex(),r.fillRect(0,0,u,c),r.globalCompositeOperation="destination-atop";const h=p.getCanvasSource(s);if(!h){r.restore();return}o&&p._applyInverseRotation(r,o,i.width,i.height),r.drawImage(h,i.x,i.y,i.width,i.height,0,0,i.width,i.height),r.restore()},tintWithPerPixel:(s,e,t)=>{const r=t.getContext("2d"),i=s.frame.clone(),n=s.source._resolution??s.source.resolution??1,o=s.rotate;i.x*=n,i.y*=n,i.width*=n,i.height*=n;const a=T.isVertical(o),u=a?i.height:i.width,c=a?i.width:i.height;t.width=Math.ceil(u),t.height=Math.ceil(c),r.save(),r.globalCompositeOperation="copy";const h=p.getCanvasSource(s);if(!h){r.restore();return}o&&p._applyInverseRotation(r,o,i.width,i.height),r.drawImage(h,i.x,i.y,i.width,i.height,0,0,i.width,i.height),r.restore();const l=e>>16&255,d=e>>8&255,f=e&255,g=r.getImageData(0,0,u,c),m=g.data;for(let x=0;x<m.length;x+=4)m[x]=m[x]*l/255,m[x+1]=m[x+1]*d/255,m[x+2]=m[x+2]*f/255;r.putImageData(g,0,0)},_applyInverseRotation:(s,e,t,r)=>{const i=T.inv(e),n=T.uX(i),o=T.uY(i),a=T.vX(i),u=T.vY(i),c=-Math.min(0,n*t,a*r,n*t+a*r),h=-Math.min(0,o*t,u*r,o*t+u*r);s.transform(n,o,a,u,c,h)}};p.tintMethod=p.canUseMultiply?p.tintWithMultiply:p.tintWithPerPixel;class Ze{constructor(e){this._canvasPool=Object.create(null),this.canvasOptions=e||{},this.enableFullScreen=!1}_createCanvasAndContext(e,t){const r=v.get().createCanvas();r.width=e,r.height=t;const i=r.getContext("2d");return{canvas:r,context:i}}getOptimalCanvasAndContext(e,t,r=1){e=Math.ceil(e*r-1e-6),t=Math.ceil(t*r-1e-6),e=te(e),t=te(t);const i=(e<<17)+(t<<1);this._canvasPool[i]||(this._canvasPool[i]=[]);let n=this._canvasPool[i].pop();return n||(n=this._createCanvasAndContext(e,t)),n}returnCanvasAndContext(e){const t=e.canvas,{width:r,height:i}=t,n=(r<<17)+(i<<1);e.context.resetTransform(),e.context.clearRect(0,0,r,i),this._canvasPool[n].push(e)}clear(){this._canvasPool={}}}const be=new Ze;Ce.register(be);const ae=new ce;function ve(s,e){e.clear();const t=e.matrix;for(let r=0;r<s.length;r++){const i=s[r];if(i.globalDisplayStatus<7)continue;const n=i.renderGroup??i.parentRenderGroup;n?.isCachedAsTexture?e.matrix=ae.copyFrom(n.textureOffsetInverseTransform).append(i.worldTransform):n?._parentCacheAsTextureRenderGroup?e.matrix=ae.copyFrom(n._parentCacheAsTextureRenderGroup.inverseWorldTransform).append(i.groupTransform):e.matrix=i.worldTransform,e.addBounds(i.bounds)}return e.matrix=t,e}const Je=new z;function et(s,e,t,r,i=!1){const n=Je;n.minX=0,n.minY=0,n.maxX=s.width/r|0,n.maxY=s.height/r|0;const o=F.getOptimalTexture(n.width,n.height,r,!1,i);return o.source.uploadMethodId="image",o.source.resource=s,o.source.alphaMode="premultiply-alpha-on-upload",o.frame.width=e/r,o.frame.height=t/r,o.source.emit("update",o.source),o.updateUvs(),o}function ue(s){return typeof s.getCanvasFilterString=="function"}class tt{constructor(){this.skip=!1,this.useClip=!1,this.filters=null,this.container=null,this.bounds=new z,this.cssFilterString=""}}class Te{constructor(e){this._filterStack=[],this._filterStackIndex=0,this._savedStates=[],this._alphaMultiplier=1,this._warnedFilterTypes=new Set,this.renderer=e}push(e){const t=this._pushFilterFrame(),r=e.filterEffect.filters;if(t.skip=!1,t.useClip=!1,t.filters=r,t.container=e.container,t.cssFilterString="",r.every(u=>!u.enabled)){t.skip=!0;return}const i=[],n=1;for(const u of r){if(!u.enabled)continue;if(!ue(u)){this._warnUnsupportedFilter(u);continue}const c=u.getCanvasFilterString();if(c===null){this._warnUnsupportedFilter(u);continue}c&&i.push(c)}if(i.length===0&&n===1){t.skip=!0;return}t.cssFilterString=i.join(" "),this._calculateFilterArea(e,t.bounds),t.useClip=!!e.filterEffect.filterArea;const o=this.renderer.canvasContext.activeContext,a=o.filter||"none";if(this._savedStates.push({filter:a,alphaMultiplier:this._alphaMultiplier}),t.useClip&&Number.isFinite(t.bounds.width)&&Number.isFinite(t.bounds.height)&&t.bounds.width>0&&t.bounds.height>0){const u=this.renderer.canvasContext.activeResolution||1;o.save(),o.setTransform(1,0,0,1,0,0),o.beginPath(),o.rect(t.bounds.x*u,t.bounds.y*u,t.bounds.width*u,t.bounds.height*u),o.clip()}else t.useClip=!1;t.cssFilterString&&(o.filter=a!=="none"?`${a} ${t.cssFilterString}`:t.cssFilterString)}pop(){const e=this._popFilterFrame();if(e.skip)return;const t=this._savedStates.pop();if(!t)return;const r=this.renderer.canvasContext.activeContext;e.useClip?r.restore():r.filter=t.filter,this._alphaMultiplier=t.alphaMultiplier}generateFilteredTexture({texture:e,filters:t}){if(!t?.length||t.every(_=>!_.enabled))return e;const r=[],i=1;for(const _ of t){if(!_.enabled)continue;if(!ue(_)){this._warnUnsupportedFilter(_);continue}const y=_.getCanvasFilterString();if(y===null){this._warnUnsupportedFilter(_);continue}y&&r.push(y)}if(r.length===0&&i===1)return e;const n=p.getCanvasSource(e);if(!n)return e;const o=e.frame,a=e.source._resolution??e.source.resolution??1,u=o.width,c=o.height,h=be.getOptimalCanvasAndContext(u,c,a),{canvas:l,context:d}=h;d.setTransform(1,0,0,1,0,0),d.clearRect(0,0,l.width,l.height),r.length&&(d.filter=r.join(" "));const f=o.x*a,g=o.y*a,m=u*a,x=c*a;return d.drawImage(n,f,g,m,x,0,0,m,x),d.filter="none",d.globalAlpha=1,et(l,u,c,a)}_calculateFilterArea(e,t){if(e.renderables?ve(e.renderables,t):e.filterEffect.filterArea?(t.clear(),t.addRect(e.filterEffect.filterArea),t.applyMatrix(e.container.worldTransform)):e.container.getFastGlobalBounds(!0,t),e.container){const i=(e.container.renderGroup||e.container.parentRenderGroup)?.cacheToLocalTransform;i&&t.applyMatrix(i)}}_warnUnsupportedFilter(e){const t=e?.constructor?.name||"Filter";this._warnedFilterTypes.has(t)||(this._warnedFilterTypes.add(t),console.warn(`CanvasRenderer: filter "${t}" is not supported in Canvas2D and will be skipped.`))}get alphaMultiplier(){return this._alphaMultiplier}_pushFilterFrame(){let e=this._filterStack[this._filterStackIndex];return e||(e=this._filterStack[this._filterStackIndex]=new tt),this._filterStackIndex++,e}_popFilterFrame(){return this._filterStackIndex<=0?this._filterStack[0]:(this._filterStackIndex--,this._filterStack[this._filterStackIndex])}destroy(){this._filterStack=null,this._savedStates=null,this._warnedFilterTypes=null,this._alphaMultiplier=1}}Te.extension={type:[P.CanvasSystem],name:"filter"};var rt=`in vec2 aPosition;
20
- out vec2 vTextureCoord;
21
-
22
- uniform vec4 uInputSize;
23
- uniform vec4 uOutputFrame;
24
- uniform vec4 uOutputTexture;
25
-
26
- vec4 filterVertexPosition( void )
27
- {
28
- vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy;
29
-
30
- position.x = position.x * (2.0 / uOutputTexture.x) - 1.0;
31
- position.y = position.y * (2.0*uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z;
32
-
33
- return vec4(position, 0.0, 1.0);
34
- }
35
-
36
- vec2 filterTextureCoord( void )
37
- {
38
- return aPosition * (uOutputFrame.zw * uInputSize.zw);
39
- }
40
-
41
- void main(void)
42
- {
43
- gl_Position = filterVertexPosition();
44
- vTextureCoord = filterTextureCoord();
45
- }
46
- `,it=`in vec2 vTextureCoord;
47
- out vec4 finalColor;
48
- uniform sampler2D uTexture;
49
- void main() {
50
- finalColor = texture(uTexture, vTextureCoord);
51
- }
52
- `,le=`struct GlobalFilterUniforms {
53
- uInputSize: vec4<f32>,
54
- uInputPixel: vec4<f32>,
55
- uInputClamp: vec4<f32>,
56
- uOutputFrame: vec4<f32>,
57
- uGlobalFrame: vec4<f32>,
58
- uOutputTexture: vec4<f32>,
59
- };
60
-
61
- @group(0) @binding(0) var <uniform> gfu: GlobalFilterUniforms;
62
- @group(0) @binding(1) var uTexture: texture_2d<f32>;
63
- @group(0) @binding(2) var uSampler: sampler;
64
-
65
- struct VSOutput {
66
- @builtin(position) position: vec4<f32>,
67
- @location(0) uv: vec2<f32>
68
- };
69
-
70
- fn filterVertexPosition(aPosition: vec2<f32>) -> vec4<f32>
71
- {
72
- var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy;
73
-
74
- position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0;
75
- position.y = position.y * (2.0 * gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z;
76
-
77
- return vec4(position, 0.0, 1.0);
78
- }
79
-
80
- fn filterTextureCoord(aPosition: vec2<f32>) -> vec2<f32>
81
- {
82
- return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);
83
- }
84
-
85
- @vertex
86
- fn mainVertex(
87
- @location(0) aPosition: vec2<f32>,
88
- ) -> VSOutput {
89
- return VSOutput(
90
- filterVertexPosition(aPosition),
91
- filterTextureCoord(aPosition)
92
- );
93
- }
94
-
95
- @fragment
96
- fn mainFragment(
97
- @location(0) uv: vec2<f32>,
98
- ) -> @location(0) vec4<f32> {
99
- return textureSample(uTexture, uSampler, uv);
100
- }
101
- `;class st extends je{constructor(){const e=M.from({vertex:{source:le,entryPoint:"mainVertex"},fragment:{source:le,entryPoint:"mainFragment"},name:"passthrough-filter"}),t=J.from({vertex:rt,fragment:it,name:"passthrough-filter"});super({gpuProgram:e,glProgram:t})}}class Fe{constructor(e){this._renderer=e}push(e,t,r){this._renderer.renderPipes.batch.break(r),r.add({renderPipeId:"filter",canBundle:!1,action:"pushFilter",container:t,filterEffect:e})}pop(e,t,r){this._renderer.renderPipes.batch.break(r),r.add({renderPipeId:"filter",action:"popFilter",canBundle:!1})}execute(e){e.action==="pushFilter"?this._renderer.filter.push(e):e.action==="popFilter"&&this._renderer.filter.pop()}destroy(){this._renderer=null}}Fe.extension={type:[P.WebGLPipes,P.WebGPUPipes,P.CanvasPipes],name:"filter"};const nt=new Ke({attributes:{aPosition:{buffer:new Float32Array([0,0,1,0,1,1,0,1]),format:"float32x2",stride:8,offset:0}},indexBuffer:new Uint32Array([0,1,2,0,2,3])});class ot{constructor(){this.skip=!1,this.inputTexture=null,this.backTexture=null,this.filters=null,this.bounds=new z,this.container=null,this.blendRequired=!1,this.outputRenderSurface=null,this.globalFrame={x:0,y:0,width:0,height:0},this.firstEnabledIndex=-1,this.lastEnabledIndex=-1}}class we{constructor(e){this._filterStackIndex=0,this._filterStack=[],this._filterGlobalUniforms=new me({uInputSize:{value:new Float32Array(4),type:"vec4<f32>"},uInputPixel:{value:new Float32Array(4),type:"vec4<f32>"},uInputClamp:{value:new Float32Array(4),type:"vec4<f32>"},uOutputFrame:{value:new Float32Array(4),type:"vec4<f32>"},uGlobalFrame:{value:new Float32Array(4),type:"vec4<f32>"},uOutputTexture:{value:new Float32Array(4),type:"vec4<f32>"}}),this._globalFilterBindGroup=new O({}),this.renderer=e}get activeBackTexture(){return this._activeFilterData?.backTexture}push(e){const t=this.renderer,r=e.filterEffect.filters,i=this._pushFilterData();i.skip=!1,i.filters=r,i.container=e.container,i.outputRenderSurface=t.renderTarget.renderSurface;const n=t.renderTarget.renderTarget.colorTexture.source,o=n.resolution,a=n.antialias;if(r.every(f=>!f.enabled)){i.skip=!0;return}const u=i.bounds;if(this._calculateFilterArea(e,u),this._calculateFilterBounds(i,t.renderTarget.rootViewPort,a,o,1),i.skip)return;const c=this._getPreviousFilterData(),h=this._findFilterResolution(o);let l=0,d=0;c&&(l=c.bounds.minX,d=c.bounds.minY),this._calculateGlobalFrame(i,l,d,h,n.width,n.height),this._setupFilterTextures(i,u,t,c)}generateFilteredTexture({texture:e,filters:t}){const r=this._pushFilterData();this._activeFilterData=r,r.skip=!1,r.filters=t;const i=e.source,n=i.resolution,o=i.antialias;if(t.every(f=>!f.enabled))return r.skip=!0,e;const a=r.bounds;if(a.addRect(e.frame),this._calculateFilterBounds(r,a.rectangle,o,n,0),r.skip)return e;const u=n;this._calculateGlobalFrame(r,0,0,u,i.width,i.height),r.outputRenderSurface=F.getOptimalTexture(a.width,a.height,r.resolution,r.antialias),r.backTexture=E.EMPTY,r.inputTexture=e,this.renderer.renderTarget.finishRenderPass(),this._applyFiltersToTexture(r,!0);const d=r.outputRenderSurface;return d.source.alphaMode="premultiplied-alpha",d}pop(){const e=this.renderer,t=this._popFilterData();t.skip||(e.globalUniforms.pop(),e.renderTarget.finishRenderPass(),this._activeFilterData=t,this._applyFiltersToTexture(t,!1),t.blendRequired&&F.returnTexture(t.backTexture),F.returnTexture(t.inputTexture))}getBackTexture(e,t,r){const i=e.colorTexture.source._resolution,n=F.getOptimalTexture(t.width,t.height,i,!1);let o=t.minX,a=t.minY;r&&(o-=r.minX,a-=r.minY),o=Math.floor(o*i),a=Math.floor(a*i);const u=Math.ceil(t.width*i),c=Math.ceil(t.height*i);return this.renderer.renderTarget.copyToTexture(e,n,{x:o,y:a},{width:u,height:c},{x:0,y:0}),n}applyFilter(e,t,r,i){const n=this.renderer,o=this._activeFilterData,u=o.outputRenderSurface===r,c=n.renderTarget.rootRenderTarget.colorTexture.source._resolution,h=this._findFilterResolution(c);let l=0,d=0;if(u){const g=this._findPreviousFilterOffset();l=g.x,d=g.y}this._updateFilterUniforms(t,r,o,l,d,h,u,i);const f=e.enabled?e:this._getPassthroughFilter();this._setupBindGroupsAndRender(f,t,n)}calculateSpriteMatrix(e,t){const r=this._activeFilterData,i=e.set(r.inputTexture._source.width,0,0,r.inputTexture._source.height,r.bounds.minX,r.bounds.minY),n=t.worldTransform.copyTo(ce.shared),o=t.renderGroup||t.parentRenderGroup;return o&&o.cacheToLocalTransform&&n.prepend(o.cacheToLocalTransform),n.invert(),i.prepend(n),i.scale(1/t.texture.orig.width,1/t.texture.orig.height),i.translate(t.anchor.x,t.anchor.y),i}destroy(){this._passthroughFilter?.destroy(!0),this._passthroughFilter=null}_getPassthroughFilter(){return this._passthroughFilter??(this._passthroughFilter=new st),this._passthroughFilter}_setupBindGroupsAndRender(e,t,r){if(r.renderPipes.uniformBatch){const i=r.renderPipes.uniformBatch.getUboResource(this._filterGlobalUniforms);this._globalFilterBindGroup.setResource(i,0)}else this._globalFilterBindGroup.setResource(this._filterGlobalUniforms,0);this._globalFilterBindGroup.setResource(t.source,1),this._globalFilterBindGroup.setResource(t.source.style,2),e.groups[0]=this._globalFilterBindGroup,r.encoder.draw({geometry:nt,shader:e,state:e._state,topology:"triangle-list"}),r.type===D.WEBGL&&r.renderTarget.finishRenderPass()}_setupFilterTextures(e,t,r,i){if(e.backTexture=E.EMPTY,e.inputTexture=F.getOptimalTexture(t.width,t.height,e.resolution,e.antialias),e.blendRequired){r.renderTarget.finishRenderPass();const n=r.renderTarget.getRenderTarget(e.outputRenderSurface);e.backTexture=this.getBackTexture(n,t,i?.bounds)}r.renderTarget.bind(e.inputTexture,!0),r.globalUniforms.push({offset:t})}_calculateGlobalFrame(e,t,r,i,n,o){const a=e.globalFrame;a.x=t*i,a.y=r*i,a.width=n*i,a.height=o*i}_updateFilterUniforms(e,t,r,i,n,o,a,u){const c=this._filterGlobalUniforms.uniforms,h=c.uOutputFrame,l=c.uInputSize,d=c.uInputPixel,f=c.uInputClamp,g=c.uGlobalFrame,m=c.uOutputTexture;a?(h[0]=r.bounds.minX-i,h[1]=r.bounds.minY-n):(h[0]=0,h[1]=0),h[2]=e.frame.width,h[3]=e.frame.height,l[0]=e.source.width,l[1]=e.source.height,l[2]=1/l[0],l[3]=1/l[1],d[0]=e.source.pixelWidth,d[1]=e.source.pixelHeight,d[2]=1/d[0],d[3]=1/d[1],f[0]=.5*d[2],f[1]=.5*d[3],f[2]=e.frame.width*l[2]-.5*d[2],f[3]=e.frame.height*l[3]-.5*d[3];const x=this.renderer.renderTarget.rootRenderTarget.colorTexture;g[0]=i*o,g[1]=n*o,g[2]=x.source.width*o,g[3]=x.source.height*o,t instanceof E&&(t.source.resource=null);const _=this.renderer.renderTarget.getRenderTarget(t);this.renderer.renderTarget.bind(t,!!u),t instanceof E?(m[0]=t.frame.width,m[1]=t.frame.height):(m[0]=_.width,m[1]=_.height),m[2]=_.isRoot?-1:1,this._filterGlobalUniforms.update()}_findFilterResolution(e){let t=this._filterStackIndex-1;for(;t>0&&this._filterStack[t].skip;)--t;return t>0&&this._filterStack[t].inputTexture?this._filterStack[t].inputTexture.source._resolution:e}_findPreviousFilterOffset(){let e=0,t=0,r=this._filterStackIndex;for(;r>0;){r--;const i=this._filterStack[r];if(!i.skip){e=i.bounds.minX,t=i.bounds.minY;break}}return{x:e,y:t}}_calculateFilterArea(e,t){if(e.renderables?ve(e.renderables,t):e.filterEffect.filterArea?(t.clear(),t.addRect(e.filterEffect.filterArea),t.applyMatrix(e.container.worldTransform)):e.container.getFastGlobalBounds(!0,t),e.container){const i=(e.container.renderGroup||e.container.parentRenderGroup).cacheToLocalTransform;i&&t.applyMatrix(i)}}_applyFiltersToTexture(e,t){const r=e.inputTexture,i=e.bounds,n=e.filters,o=e.firstEnabledIndex,a=e.lastEnabledIndex;if(this._globalFilterBindGroup.setResource(r.source.style,2),this._globalFilterBindGroup.setResource(e.backTexture.source,3),o===a)n[o].apply(this,r,e.outputRenderSurface,t);else{let u=e.inputTexture;const c=F.getOptimalTexture(i.width,i.height,u.source._resolution,!1);let h=c;for(let l=o;l<a;l++){const d=n[l];if(!d.enabled)continue;d.apply(this,u,h,!0);const f=u;u=h,h=f}n[a].apply(this,u,e.outputRenderSurface,t),F.returnTexture(c)}}_calculateFilterBounds(e,t,r,i,n){const o=this.renderer,a=e.bounds,u=e.filters;let c=1/0,h=0,l=!0,d=!1,f=!1,g=!0,m=-1,x=-1;for(let _=0;_<u.length;_++){const y=u[_];if(!y.enabled)continue;if(m===-1&&(m=_),x=_,c=Math.min(c,y.resolution==="inherit"?i:y.resolution),h+=y.padding,y.antialias==="off"?l=!1:y.antialias==="inherit"&&l&&(l=r),y.clipToViewport||(g=!1),!!!(y.compatibleRenderers&o.type)){f=!1;break}if(y.blendRequired&&!(o.backBuffer?.useBackBuffer??!0)){Se("Blend filter requires backBuffer on WebGL renderer to be enabled. Set `useBackBuffer: true` in the renderer options."),f=!1;break}f=!0,d||(d=y.blendRequired)}if(!f){e.skip=!0;return}if(g&&a.fitBounds(0,t.width/i,0,t.height/i),a.scale(c).ceil().scale(1/c).pad((h|0)*n),!a.isPositive){e.skip=!0;return}e.antialias=l,e.resolution=c,e.blendRequired=d,e.firstEnabledIndex=m,e.lastEnabledIndex=x}_popFilterData(){return this._filterStackIndex--,this._filterStack[this._filterStackIndex]}_getPreviousFilterData(){let e,t=this._filterStackIndex-1;for(;t>0&&(t--,e=this._filterStack[t],!!e.skip););return e}_pushFilterData(){let e=this._filterStack[this._filterStackIndex];return e||(e=this._filterStack[this._filterStackIndex]=new ot),this._filterStackIndex++,e}}we.extension={type:[P.WebGLSystem,P.WebGPUSystem],name:"filter"};he.add(we,Te);he.add(Fe);
@@ -1,3 +0,0 @@
1
- import{a}from"./jsx-runtime-DPjLkJKQ.js";import{cP as fo,cQ as ho,cR as go,cS as te,v as bn,cT as _e,cU as mo,br as Ft,cV as xo,cW as yn,cX as bo,cY as ze,cZ as ee,c_ as Pe,c$ as Wt,F as je,G as ne,d0 as yo,a2 as vn,a3 as wn,ar as Sn,d1 as En,aH as Kt,a8 as vo,a9 as et,aa as nt,cA as wo,aq as So,B as Ut,ab as Cn,d2 as kn,d3 as In,d4 as Yt,al as Eo,d5 as Co,d6 as ko,aV as oe,d7 as Ge,d8 as Xe,d9 as Ve,da as Io,db as Ro,dc as zo,dd as Po,de as jo,df as Q,dg as Mo,aA as Rn,dh as Do,di as To,dj as ue,dk as Lo,dl as F,dm as we,dn as Rt,dp as $o,dq as Oo,dr as Bo,ds as Ao,dt as Fo,du as He,dv as Yo,dw as No,dx as _o,dy as Go,dz as Xo,dA as Vo,dB as Ho,dC as zn,dD as Wo,dE as Ko,t as zt,dF as Uo,dG as Zo,dH as qo,dI as Qo,cd as Pn,dJ as Jo,dK as tr,dL as er,dM as nr,dN as or,dO as rr,bc as ir,af as sr,dP as ar,dQ as lr,dR as Nt,dS as pe,dT as cr,dU as _t,dV as dr,dW as fe,dX as We,dY as ur,bh as pr,dZ as fr,cq as hr,d_ as gr,d$ as mr,e0 as xr,e1 as br,e2 as yr,e3 as vr,e4 as wr,e5 as Ke,c7 as Sr,e6 as Er}from"./index-cpXNKgvz.js";import{r as c}from"./index-DaQZGF7d.js";import{B as It,q as Ue,I as Cr}from"./NonThreeAuthoringBootstrap-BE15Wpmw.js";import"./index-CtzuWnCS.js";import"./index-D2LwEE0L.js";import{a as kr}from"./Toolbar-DYJjJKTt.js";import{T as Ir}from"./TransientHint-D94hsJSR.js";import{s as Rr,g as zr,a as Pr,f as jr,t as Mr,z as Dr,b as Tr}from"./react-story-board-B9V-j_Y5.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-ZILb6uB7.js";import"./transform-mode-request-DSPwviXs.js";const Se="#191c22",Lr="rgba(255, 255, 255, 0.2)",$r={width:null,height:null};let Ht=$r;const Ee=new Set;function jn(){return Ht}function Zt(t,e){const n=t===null?null:Math.max(1,Math.round(t)),r=e===null?null:Math.max(1,Math.round(e));if(!(Ht.width===n&&Ht.height===r)){Ht={width:n,height:r};for(const s of Ee)s()}}function Or(){Zt(null,null)}function Mn(t){return Ee.add(t),()=>Ee.delete(t)}const qt=[],Ze=new Set,Br=[];function Ar(){return qt.length===0?Br: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 Fr(t){return Ze.add(t),()=>{Ze.delete(t)}}const Yr=1;function Dn(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 Nr(t){return Dn(t)}function he(t,e){return t.childAdapters().some(n=>n.worldId===e)}function Tn(t,e,n="dom"){const r=yn(e)?"none":"block";t.style.display=r,t.style.pointerEvents=vt(n)?.alwaysInteractive||bo(e)?"auto":"none";for(const s of Array.from(t.parentElement?.children??[]))s instanceof HTMLElement&&s.dataset.vgaiStoryBoardChromeFor===e&&(s.style.display=r)}function _r(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",i.style.cssText+="font: initial; color: initial; letter-spacing: normal; word-spacing: normal; text-align: start; text-indent: 0; text-transform: none; white-space: normal; direction: ltr;",Tn(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=ze(ee())??"",t.style.transformOrigin="0 0",t.dataset.vgaiReactStoryBoard==="true")return;const e=jn();t.style.width=e.width===null?"100%":`${e.width}px`,t.style.height=e.height===null?"100%":`${e.height}px`}function Gr(t,e,n,r,s,i,d){i?i.canvasSceneView.reset():fo(),Or();const y=bn();if(!i&&y?.config.resolution&&Zt(y.config.resolution.width,y.config.resolution.height),n.playState!=="stopped"){let u=!1,R=!1;const L=n.subscribe(()=>{u||R||n.playState!=="stopped"||(R=!0,u||Ue())});return()=>{u=!0,L()}}const b=y?.rootPath,v=r?[...r]:Dn(e);if(v.length===0||!b)return()=>{};const E=b,k=ho(v.map(u=>({id:u.worldId,zOrder:u.zOrder}))).map(u=>v.find(R=>R.worldId===u.id)),P=new Map(k.map(u=>[u.worldId,u])),x=new Map,f=new Map,p=new Map,w=new Set,h=new Set,j=new Set;let D=!1,M=!1,I=!1;function X(){for(const u of f.values())try{u()}catch(R){Ft.error(`[design-time-layers] dispose failed: ${R}`,"authoring")}f.clear();for(const u of x.values())u.remove();x.clear();for(const u of k)s?.(u.worldId,null)}function H(){X();for(const u of w){const R=P.get(u);if(!R)continue;const L={id:R.worldId,kind:R.kind,entryOrScenePath:R.path,zOrder:R.zOrder,pausable:R.pausable};e.replaceChild(u,new It(n,L,"Design-time layer suspended by play mode — Stop restores it."))}w.clear(),n.notifyIngestEdit()}function W(u,R,L){const O=vt(u.kind);if(!O){h.add(u.worldId);return}h.delete(u.worldId);const _=(p.get(u.worldId)??0)+1;p.set(u.worldId,_);const A=_r(t,u,Yr+R,!!i);x.set(u.worldId,A);const xt={projectRootPath:E,store:n,...i?{view:i.canvasSceneView}:{},...d?{activationDocumentId:d}:{}};(async()=>O.mount(u,A,xt))().then(K=>{if(D||M||p.get(u.worldId)!==_){K.dispose();return}if(K.adapter)he(e,u.worldId)&&(e.replaceChild(u.worldId,K.adapter),w.add(u.worldId)),s?.(u.worldId,K.adapter);else if(K.pick){const J={id:u.worldId,kind:u.kind,entryOrScenePath:u.path,zOrder:u.zOrder,pausable:u.pausable};e.replaceChild(u.worldId,new It(n,J,void 0,K.pick)),w.add(u.worldId)}f.set(u.worldId,K.dispose),_e(u.worldId),n.notifyIngestEdit(),L?.()}).catch(K=>{if(p.get(u.worldId)!==_||(L?.(),A.remove(),x.get(u.worldId)===A&&x.delete(u.worldId),D||M))return;const J=mo(K);Ft.error(`[design-time-layers] world "${u.worldId}" (${u.kind}) failed to mount: ${J}`,"authoring");const ut={id:u.worldId,kind:u.kind,entryOrScenePath:u.path,zOrder:u.zOrder,pausable:u.pausable};s?.(u.worldId,null),he(e,u.worldId)&&e.replaceChild(u.worldId,new It(n,ut,J)),xo({worldId:u.worldId,kind:u.kind,identity:O.identity,message:J}),n.notifyIngestEdit()})}k.forEach((u,R)=>{W(u,R)});function Mt(u,R){const L=f.get(u.worldId);f.delete(u.worldId);const O=x.get(u.worldId);x.delete(u.worldId),W(u,R,()=>{const A=x.get(u.worldId);if(A&&(A.style.visibility=""),L)try{L()}catch(xt){Ft.error(`[design-time-layers] re-projection dispose failed: ${xt}`,"authoring")}O?.remove()});const _=x.get(u.worldId);_&&_!==O&&(_.style.visibility="hidden")}function gt(u,R){const L=f.get(u.worldId);if(f.delete(u.worldId),L)try{L()}catch(_){Ft.error(`[design-time-layers] remount dispose failed: ${_}`,"authoring")}const O=x.get(u.worldId);O&&(O.remove(),x.delete(u.worldId)),W(u,R)}const Y=new Map;function Dt(){for(const[u,R]of Y)vt(u.kind)!==u&&(R(),Y.delete(u));for(const u of Ar()){if(Y.has(u)||vt(u.kind)!==u||!k.some(O=>O.kind===u.kind))continue;const R=[],L=O=>()=>{D||M||n.playState!=="stopped"||k.forEach((_,A)=>{_.kind===u.kind&&O(_,A)})};u.remountWhen&&R.push(u.remountWhen(L(gt))),u.reprojectWhen&&R.push(u.reprojectWhen(L(Mt))),Y.set(u,()=>{for(const O of R)O()})}}Dt();const mt=Fr(()=>{D||M||n.playState!=="stopped"||(k.forEach((u,R)=>{h.has(u.worldId)&&vt(u.kind)&&(j.delete(u.worldId),_e(u.worldId),W(u,R))}),Dt())}),B=go(()=>{if(D||M)return;let u=!1;for(const R of k){if(!h.has(R.worldId)||j.has(R.worldId)||vt(R.kind)||(j.add(R.worldId),!he(e,R.worldId)))continue;const L={id:R.worldId,kind:R.kind,entryOrScenePath:R.path,zOrder:R.zOrder,pausable:R.pausable};e.replaceChild(R.worldId,new It(n,L,`No package in this editor registered a design-time mount for a "${R.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()}),ie=te(()=>{for(const u of x.values())Ce(u)}),se=Mn(()=>{for(const u of x.values())Ce(u)}),dt=n.subscribe(()=>{if(!M&&n.playState!=="stopped"){M=!0,H();return}if(M&&!I&&n.playState==="stopped"&&!D){I=!0,D||Ue();return}if(!M)for(const[u,R]of x)Tn(R,u,P.get(u)?.kind??"dom")});return()=>{D=!0;for(const u of Y.values())u();Y.clear(),mt(),B(),dt(),ie(),se(),X()}}const Ln=.1,$n=4,On=.002,Xr=4;function ke(t,e,n){return e===1?t*16:e===2?t*n:t}function Vr(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($n,Math.max(Ln,t.zoom*Math.exp(-r*On))),i=e.clientX-e.bounds.left,d=e.clientY-e.bounds.top,y=(i-t.x)/t.zoom,b=(d-t.y)/t.zoom;return{x:i-y*s,y:d-b*s,zoom:s}}return e.shiftKey&&n===0&&(n=r,r=0),{x:t.x-n,y:t.y-r,zoom:t.zoom}}function Hr(t,e){const n=ke(e.deltaY,e.deltaMode,e.bounds.height),r=Math.min($n,Math.max(Ln,t.zoom*Math.exp(-n*On))),s=e.clientX-e.bounds.left,i=e.clientY-e.bounds.top,d=(s-t.x)/t.zoom,y=(i-t.y)/t.zoom;return{x:s-d*r,y:i-y*r,zoom:r}}function ge(t){return t instanceof Element&&t.closest('[data-vgai-canvas-navigation-ignore="true"]')!==null}function Bn(t,e,n,r={}){let s=null,i=!1,d="";const y=()=>t.querySelector('[data-testid="world-selection-overlay-interaction"]'),b=f=>{t.dataset.canvasPanning=f?"true":"false",t.style.cursor=f?"grabbing":"";const p=y();p&&(f?(d=p.style.cursor,p.style.cursor="grabbing"):p.style.cursor=d)},v=f=>{if(!s||f.pointerId!==s.pointerId)return;const p=s.button===1?4:2;if((f.buttons&p)===0){E(f);return}const w=f.clientX-s.startClientX,h=f.clientY-s.startClientY;if(!s.moved){if(Math.hypot(w,h)<=Xr)return;s.moved=!0,b(!0)}e.setPan(s.startPan.x+w,s.startPan.y+h)},E=f=>{if(!s||f.pointerId!==s.pointerId)return;const p=s.pointerId;s.button===2&&s.moved&&(i=!0),s=null,b(!1),t.hasPointerCapture?.(p)&&t.releasePointerCapture(p),window.removeEventListener("pointermove",v),window.removeEventListener("pointerup",E),window.removeEventListener("pointercancel",E)},C=f=>{const p=f.button===1,w=r.rightDragPans===!0&&f.button===2;!p&&!w||ge(f.target)||(w&&(i=!1),f.preventDefault(),p&&f.stopPropagation(),s={pointerId:f.pointerId,button:f.button,startClientX:f.clientX,startClientY:f.clientY,startPan:e.get(),moved:p},t.setPointerCapture?.(f.pointerId),b(p),window.addEventListener("pointermove",v),window.addEventListener("pointerup",E),window.addEventListener("pointercancel",E))},k=f=>{f.button===1&&!ge(f.target)&&f.preventDefault()},P=f=>{r.rightDragPans!==!0||!(s?.button===2&&s.moved)&&!i||(i=!1,f.preventDefault(),f.stopPropagation())},x=f=>{if(ge(f.target))return;f.preventDefault(),f.stopPropagation();const p=n(e.get(),{clientX:f.clientX,clientY:f.clientY,deltaX:f.deltaX,deltaY:f.deltaY,deltaMode:f.deltaMode,ctrlKey:f.ctrlKey,metaKey:f.metaKey,shiftKey:f.shiftKey,bounds:t.getBoundingClientRect()});e.setView(p.x,p.y,p.zoom)};return t.addEventListener("pointerdown",C,!0),t.addEventListener("lostpointercapture",E,!0),t.addEventListener("mousedown",k,!0),t.addEventListener("contextmenu",P,!0),t.addEventListener("wheel",x,{capture:!0,passive:!1}),()=>{s=null,b(!1),t.removeEventListener("pointerdown",C,!0),t.removeEventListener("lostpointercapture",E,!0),t.removeEventListener("mousedown",k,!0),t.removeEventListener("contextmenu",P,!0),t.removeEventListener("wheel",x,!0),window.removeEventListener("pointermove",v),window.removeEventListener("pointerup",E),window.removeEventListener("pointercancel",E)}}function Wr(t,e=Pe){return Bn(t,e,Vr)}function Kr(t,e){return Bn(t,e,Hr,{rightDragPans:!0})}const Pt=[],qe=new Set,Ur=[];function Zr(){return Pt.length===0?Ur:Pt}function qr(t){for(let e=Pt.length-1;e>=0;e--){const n=Pt[e];if(n&&n.medium===t)return n}return null}function Qr(t){return Pt.find(e=>e.documentId===t)??null}function Jr(t){return qe.add(t),()=>{qe.delete(t)}}function St(t){return t.map(e=>`“${e}”`).join(", ")}function ti(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
- `)}
3
- If this followed an edit, Undo (Ctrl+Z) restores the previous source and remounts.`}}function ei(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 ni(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 oi(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 ti(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"?ei(t.surface,s):ni(t.surface,t.rootIds)}const Qt=globalThis;function Ie(){return Qt.__vgaiBreakpointListeners??=new Set,Qt.__vgaiBreakpointListeners}function ri(){return Qt.__vgaiActiveBreakpoint??null}function ii(t){Qt.__vgaiActiveBreakpoint=t;for(const e of Ie())e()}function si(t){return Ie().add(t),()=>Ie().delete(t)}const An="vgai:board-guides:v1";function Fn(){return typeof window>"u"?null:window.localStorage}function Yn(){try{return bn()?.rootPath??"(no-project)"}catch{return"(no-project)"}}function Nn(){try{return JSON.parse(Fn()?.getItem(An)??"{}")}catch{return{}}}function ai(t){try{Fn()?.setItem(An,JSON.stringify(t))}catch{}}const Re=new Set;let me=null,Qe=Date.now()%1e6;function jt(){return me||(me=Nn()[Yn()]??{}),me}function De(){const t=Nn();t[Yn()]=jt(),ai(t);for(const e of Re)e()}const li=[];function re(t){return jt()[t]??li}function ci(t){return Re.add(t),()=>Re.delete(t)}function di(t,e,n){Qe+=1;const r=`guide-${Qe}`;return jt()[t]=[...re(t),{id:r,axis:e,value:n}],De(),r}function Je(t,e,n){jt()[t]=re(t).map(r=>r.id===e?{...r,value:n}:r),De()}function tn(t,e){jt()[t]=re(t).filter(n=>n.id!==e),De()}const q=16,xe="rgba(255, 82, 82, 0.9)",en="rgba(18, 22, 26, 0.92)",Gt="rgba(255, 255, 255, 0.28)";function ui(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 pi({docId:t,containerRef:e}){const n=c.useSyncExternalStore(te,ee),r=c.useSyncExternalStore(ci,()=>re(t)),[s,i]=c.useState(null),d=c.useRef(null);c.useEffect(()=>{const p=e.current;if(!p)return;const w=p.getBoundingClientRect();return w.left,w.top,n.x,n.y,n.zoom,()=>void 0},[t,e,n.x,n.y,n.zoom]);const y=(p,w)=>Math.round((p-(w==="x"?n.x:n.y))/n.zoom),b=(p,w)=>(w==="x"?n.x:n.y)+p*n.zoom,v=p=>{const w=e.current?.getBoundingClientRect();return w?{x:p.clientX-w.left,y:p.clientY-w.top}:{x:0,y:0}},E=p=>w=>{w.preventDefault(),w.currentTarget.setPointerCapture(w.pointerId);const h=v(w);i({kind:"place",axis:p,id:null,at:p==="x"?h.x:h.y})},C=p=>w=>{w.preventDefault(),w.stopPropagation(),w.currentTarget.setPointerCapture(w.pointerId);const h=v(w);i({kind:"move",axis:p.axis,id:p.id,at:p.axis==="x"?h.x:h.y})},k=p=>{if(!s)return;const w=v(p),h=s.axis==="x"?w.x:w.y;i({...s,at:h}),s.kind==="move"&&s.id&&Je(t,s.id,y(h,s.axis))},P=p=>{if(!s)return;const w=v(p),h=s.axis==="x"?w.x:w.y,j=h<=q;s.kind==="place"?j||di(t,s.axis,y(h,s.axis)):s.id&&(j?tn(t,s.id):Je(t,s.id,y(h,s.axis))),i(null)},x=p=>{const w=e.current,h=w?p==="x"?w.clientWidth:w.clientHeight:0,j=ui(n.zoom),D=Math.ceil(y(q,p)/j)*j,M=y(h,p),I=[];for(let X=D;X<=M&&I.length<200;X+=j)I.push(X);return I},f={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:k,onPointerUp:P,children:[r.map(p=>{const w=b(p.value,p.axis),h=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:C(p),onPointerMove:k,onPointerUp:P,onDoubleClick:()=>tn(t,p.id),style:{position:"absolute",pointerEvents:"auto",cursor:h?"col-resize":"row-resize",zIndex:60,...h?{left:w-2,top:0,bottom:0,width:5}:{top:w-2,left:0,right:0,height:5}},children:a.jsx("div",{style:{position:"absolute",background:xe,...h?{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:xe,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:xe,background:en,padding:"1px 3px",borderRadius:3,whiteSpace:"nowrap"},children:y(s.at,s.axis)})}),a.jsx("div",{"data-testid":"board-ruler-top",onPointerDown:E("y"),style:{...f,top:0,left:q,right:0,height:q,cursor:"row-resize",pointerEvents:"auto"},children:x("x").map(p=>a.jsx("span",{style:{position:"absolute",left:b(p,"x"),bottom:0,borderLeft:`1px solid ${Gt}`,height:5},children:a.jsx("span",{style:{position:"absolute",left:2,bottom:3,fontSize:8,color:Gt,fontFamily:"ui-monospace, monospace"},children:nn(p)})},p))}),a.jsx("div",{"data-testid":"board-ruler-left",onPointerDown:E("x"),style:{...f,top:q,left:0,bottom:0,width:q,cursor:"col-resize",pointerEvents:"auto"},children:x("y").map(p=>a.jsx("span",{style:{position:"absolute",top:b(p,"y"),right:0,borderTop:`1px solid ${Gt}`,width:5},children:a.jsx("span",{style:{position:"absolute",top:1,right:3,fontSize:8,color:Gt,fontFamily:"ui-monospace, monospace",writingMode:"vertical-rl"},children:nn(p)})},p))}),a.jsx(fi,{}),a.jsx("div",{style:{...f,top:0,left:0,width:q,height:q,borderRight:`1px solid ${Wt.border}`,borderBottom:`1px solid ${Wt.border}`}})]})}function fi(){const t=c.useSyncExternalStore(si,ri);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:()=>ii(null),style:{position:"absolute",top:q+8,right:12,zIndex:62,pointerEvents:"auto",background:"rgba(18, 22, 26, 0.92)",color:Wt.accent,border:`1px solid ${Wt.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 _n(t){return Et(t).guides}function Gn(t){return Et(t).revision}function Xn(t,e){const n=Et(t);return n.listeners.add(e),()=>n.listeners.delete(e)}function hi(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 Vn(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 gi(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 Hn(t){let e=32;for(;e*t<12;)e*=2;for(;e*t>48;)e/=2;return e}function mi(t){return Hn(t)*t}function be(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 ye(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 xi({view:t,documentId:e}){const n=je(ne());c.useSyncExternalStore(n.subscribe,n.getSnapshot),c.useEffect(()=>yo(e,"canvas"),[e]),c.useSyncExternalStore(vn,wn);const r=Sn(e),s=c.useSyncExternalStore(t.subscribe,t.get,t.get);c.useSyncExternalStore(c.useCallback(b=>Xn(t,b),[t]),c.useCallback(()=>Gn(t),[t]));const i=_n(t),d=mi(s.zoom),y=d*4;return a.jsxs("div",{"data-testid":"canvas-scene-backdrop",style:{position:"absolute",inset:0,zIndex:2,overflow:"hidden",pointerEvents:"none"},children:[r&&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:`${s.x}px ${s.y}px`,backgroundSize:`${d}px ${d}px, ${d}px ${d}px, ${y}px ${y}px, ${y}px ${y}px`}}),a.jsx("div",{"data-testid":"canvas-scene-origin-y",style:{position:"absolute",left:0,right:0,top:s.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:s.x,width:1,background:"rgba(87, 199, 126, .8)"}}),a.jsx("div",{style:{position:"absolute",left:s.x+6,top:s.y+6,color:"rgba(255,255,255,.68)",font:"10px ui-monospace, SFMono-Regular, Menlo, monospace"},children:"0, 0"}),i.map(b=>a.jsx("div",{"data-testid":`canvas-scene-guide-${b.axis}`,title:`${b.axis.toUpperCase()} ${Math.round(b.value*100)/100} · drag to move · right-click to remove`,onContextMenu:v=>{v.preventDefault(),gi(t,b.id)},onPointerDown:v=>{v.preventDefault(),v.stopPropagation();const E=v.currentTarget.parentElement?.getBoundingClientRect();if(!E)return;const C=P=>{const x=b.axis==="x"?P.clientX-E.left:P.clientY-E.top,f=t.get();Vn(t,b.id,(x-(b.axis==="x"?f.x:f.y))/f.zoom)},k=()=>{window.removeEventListener("pointermove",C),window.removeEventListener("pointerup",k)};window.addEventListener("pointermove",C),window.addEventListener("pointerup",k,{once:!0})},style:{position:"absolute",pointerEvents:"auto",cursor:b.axis==="x"?"ew-resize":"ns-resize",...b.axis==="x"?{left:s.x+b.value*s.zoom-4,top:20,bottom:0,width:9,borderLeft:"1px solid rgba(74, 180, 255, .95)"}:{top:s.y+b.value*s.zoom-4,left:20,right:0,height:9,borderTop:"1px solid rgba(74, 180, 255, .95)"}}},b.id)),a.jsx(bi,{view:t})]})}function bi({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 C=()=>{const P=n.current?.clientWidth??0,x=r.current?.clientHeight??0;i(f=>f.width===P&&f.height===x?f:{width:P,height:x})};if(C(),typeof ResizeObserver>"u")return;const k=new ResizeObserver(C);return n.current&&k.observe(n.current),r.current&&k.observe(r.current),()=>k.disconnect()},[]);const d=(C,k)=>{if(!(k>0))return[];const P=C==="x"?e.x:e.y,x=Hn(e.zoom),f=x*e.zoom,p=20,w=Math.ceil((p-P)/f),h=Math.floor((p+k-P)/f);return Array.from({length:Math.max(0,h-w+1)},(j,D)=>{const M=w+D;return{major:M%4===0,screen:P+M*f-p,value:M*x}})},y=d("x",s.width),b=d("y",s.height),v=(C,k)=>{k.preventDefault(),k.stopPropagation();const P=k.currentTarget.parentElement?.getBoundingClientRect();if(!P)return;const x=(h,j)=>{const D=t.get();return((C==="x"?h-P.left:j-P.top)-(C==="x"?D.x:D.y))/D.zoom},f=hi(t,C,x(k.clientX,k.clientY)),p=h=>Vn(t,f,x(h.clientX,h.clientY)),w=()=>{window.removeEventListener("pointermove",p),window.removeEventListener("pointerup",w)};window.addEventListener("pointermove",p),window.addEventListener("pointerup",w,{once:!0})},E={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:C=>v("y",C),style:{...E,left:20,right:0,top:0,height:20,borderBottomStyle:"solid",borderBottomWidth:1,cursor:"row-resize",padding:0,overflow:"hidden"},children:y.map(C=>a.jsx("span",{"aria-hidden":"true","data-ruler-axis":"x","data-ruler-value":C.value,style:{position:"absolute",left:C.screen,bottom:0,width:1,height:C.major?8:4,background:C.major?"rgba(255,255,255,.5)":"rgba(255,255,255,.28)",pointerEvents:"none"},children:C.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:C.value})},C.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:C=>v("x",C),style:{...E,top:20,bottom:0,left:0,width:20,borderRightStyle:"solid",borderRightWidth:1,cursor:"col-resize",padding:0,overflow:"hidden"},children:b.map(C=>a.jsx("span",{"aria-hidden":"true","data-ruler-axis":"y","data-ruler-value":C.value,style:{position:"absolute",top:C.screen,right:0,width:C.major?8:4,height:1,background:C.major?"rgba(255,255,255,.5)":"rgba(255,255,255,.28)",pointerEvents:"none"},children:C.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:C.value})},C.value))}),a.jsx("div",{style:{...E,left:0,top:0,width:20,height:20}})]})}function yi({active:t,adapter:e,containerRef:n,view:r,documentId:s}){const i=je(ne());c.useSyncExternalStore(i.subscribe,i.getSnapshot),c.useSyncExternalStore(vn,wn);const d=Sn(s),y=c.useSyncExternalStore(r.subscribe,r.get,r.get),b=c.useCallback(k=>{const P=n.current;if(!P)return;const x=Math.min(4,Math.max(.1,k)),f=P.clientWidth/2,p=P.clientHeight/2,w=(f-y.x)/y.zoom,h=(p-y.y)/y.zoom;r.setView(f-w*x,p-h*x,x)},[n,y,r]),v=c.useCallback(k=>{if(!e?.rects)return[];const P=[];for(const x of k){const f=e.rects.rect(x);f&&f.width>0&&f.height>0&&P.push(f)}return P},[e]),E=c.useCallback(()=>{const k=n.current;k&&ye(k,r,be(v(i.selectedEntityIds)))},[n,v,i,r]),C=c.useCallback(()=>{const k=n.current;!k||!e||ye(k,r,be(v(En(e))))},[e,n,v,r]);return c.useEffect(()=>{if(t)return i.onViewportAction(k=>{if(k.type==="focus-entity"){const P=n.current;if(!P)return;ye(P,r,be(v([k.id])))}else k.type==="focus-selection"?E():k.type==="focus-scene"&&C()})},[t,n,C,E,v,i,r]),a.jsxs(a.Fragment,{children:[a.jsx(Ir,{}),a.jsx(kr,{dimensions:"2d"}),a.jsxs(Kt,{label:"2D scene display",className:"vgai-viewport-toolbar vgai-viewport-toolbar-right","data-vgai-canvas-navigation-ignore":"true",children:[a.jsx(vo,{text:`Grid: ${d?"On":"Off"}`,children:a.jsx(et,{"aria-label":"Toggle 2D grid","aria-pressed":d,size:"comfortable",onClick:()=>So(s,!d),children:a.jsx(nt,{icon:wo,size:"md"})})}),a.jsx(Ut,{"aria-label":"Frame all",variant:"ghost",size:"comfortable",onClick:C,children:"Frame all"})]}),a.jsxs(Kt,{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:i.selectedEntityIds.size===0,onClick:E,children:a.jsx(nt,{icon:Cn,size:"md"})}),a.jsx(et,{"aria-label":"Zoom out",title:"Zoom out",size:"comfortable",onClick:()=>b(y.zoom/1.2),children:a.jsx(nt,{icon:kn,size:"md"})}),a.jsxs(Ut,{variant:"ghost","aria-label":"Reset zoom to 100%",title:"Reset zoom to 100%",size:"comfortable",onClick:()=>b(1),children:[Math.round(y.zoom*100),"%"]}),a.jsx(et,{"aria-label":"Zoom in",title:"Zoom in",size:"comfortable",onClick:()=>b(y.zoom*1.2),children:a.jsx(nt,{icon:In,size:"md"})})]})]})}const an={fill:null,desktop:{width:1440,height:900},tablet:{width:768,height:1024},mobile:{width:390,height:844}};function vi({boardViewport:t,containerRef:e,selectViewport:n,viewportValue:r}){return a.jsxs(a.Fragment,{children:[a.jsxs(Eo,{"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:()=>Mr(e.current),children:a.jsx(nt,{icon:Co,size:"md"})})]})}function wi({containerRef:t,context:e,boardOnly:n=!1}){const r=ne();c.useSyncExternalStore(r.subscribe,r.getSnapshot);const s=c.useSyncExternalStore(te,ee),i=c.useSyncExternalStore(Mn,jn),d=c.useSyncExternalStore(Rr,()=>zr(t.current),()=>null),y=c.useCallback(x=>{const f=t.current;if(!f)return;const p=Math.min(4,Math.max(.1,x)),w=f.clientWidth/2,h=f.clientHeight/2,j=(w-s.x)/s.zoom,D=(h-s.y)/s.zoom;Yt(w-j*p,h-D*p,p)},[t,s]),b=c.useCallback(()=>{const x=t.current,f=[...r.selectedEntityIds].at(-1);if(!x||!f)return;const p=e?.adapter.rects?.rect(f);if(!p||p.width<=0||p.height<=0)return;const w=Math.max(1,x.clientWidth-96),h=Math.max(1,x.clientHeight-96),j=Math.min(4,Math.max(.1,Math.min(w/p.width,h/p.height)));Yt(x.clientWidth/2-(p.x+p.width/2)*j,x.clientHeight/2-(p.y+p.height/2)*j,j)},[t,e,r]),v=c.useCallback(x=>{const f=t.current;if(d){Pr(f,x==="fill"?null:x);return}const p=an[x];if(!f||p===null){Zt(null,null),Yt(0,0,1);return}Zt(p.width,p.height);const w=Math.min(1,Math.max(.1,Math.min((f.clientWidth-96)/p.width,(f.clientHeight-96)/p.height)));Yt((f.clientWidth-p.width*w)/2,(f.clientHeight-p.height*w)/2,w)},[d,t]),E=c.useCallback(()=>{const x=t.current;x&&jr(x)},[t]),C=d!==null,k=e?.kind==="dom"&&!!e.adapter.rects;if(n?!C:!k)return null;const P=d?d.selectedViewportId??"fill":Object.entries(an).find(([,x])=>x===null?i.width===null:x.width===i.width&&x.height===i.height)?.[0]??"fill";return a.jsxs(a.Fragment,{children:[!C&&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:ze(s),transformOrigin:"0 0",pointerEvents:"none",background:"#fff",boxShadow:"0 0 0 1px #ffffff40, 0 8px 30px #0009"}}),a.jsxs(Kt,{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(vi,{boardViewport:d,containerRef:t,selectViewport:v,viewportValue:P}),C&&a.jsx(Ut,{variant:"ghost","aria-label":"Fit story board",title:"Fit all stories",size:"comfortable",onClick:E,children:"Fit board"}),a.jsx(et,{"aria-label":"Zoom out",title:"Zoom out",size:"comfortable",onClick:()=>y(s.zoom/1.2),children:a.jsx(nt,{icon:kn,size:"md"})}),a.jsxs(Ut,{variant:"ghost","aria-label":"Reset zoom to 100%",title:"Reset zoom to 100%",size:"comfortable",onClick:()=>y(1),children:[Math.round(s.zoom*100),"%"]}),a.jsx(et,{"aria-label":"Zoom in",title:"Zoom in",size:"comfortable",onClick:()=>y(s.zoom*1.2),children:a.jsx(nt,{icon:In,size:"md"})}),!n&&a.jsx(et,{"aria-label":"Zoom to selection",title:"Zoom to selection",size:"comfortable",onClick:b,children:a.jsx(nt,{icon:Cn,size:"md"})})]})]})}let Si=null;const ln=new Set;function Ei(){return Si!==null}function Ci(t){return ln.add(t),()=>ln.delete(t)}const ki=new Set(["","transparent","rgba(0, 0, 0, 0)"]);function Ii(t){return ki.has(t)}function Ri(t){for(const e of t)if(!Ii(e))return e;return"#fff"}function cn(t,e){for(const n of e){const r=Q(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 zi=[{op:"left",testId:"align-left",label:"Align left",icon:Ge},{op:"hcenter",testId:"align-hcenter",label:"Align horizontal center",icon:Xe},{op:"right",testId:"align-right",label:"Align right",icon:Ve},{op:"top",testId:"align-top",label:"Align top",icon:Ge,rotate:!0},{op:"vcenter",testId:"align-vcenter",label:"Align vertical center",icon:Xe,rotate:!0},{op:"bottom",testId:"align-bottom",label:"Align bottom",icon:Ve,rotate:!0}],Pi=[{axis:"horizontal",testId:"distribute-horizontal",label:"Distribute horizontally",icon:zo},{axis:"vertical",testId:"distribute-vertical",label:"Distribute vertically",icon:Po}];function ji(t){const r=t.y-30-8;return{left:t.x,top:r<0?t.y+t.height+8:r}}function Mi({adapter:t,entries:e}){if(e.length<2)return null;const n=ko(e.map(d=>d.rect));if(!n)return null;const{left:r,top:s}=ji(n),i=e.length>=3;return a.jsxs(Kt,{label:"Align and distribute","data-testid":"align-toolbar",style:{position:"absolute",left:r,top:s,zIndex:oe.overlayLow,gap:2,padding:3},children:[zi.map(({op:d,testId:y,label:b,icon:v,rotate:E})=>a.jsx(et,{"data-testid":y,title:b,"aria-label":b,variant:"ghost",size:"compact",onClick:()=>cn(t,Io(e,d)),children:a.jsx(nt,{icon:v,"aria-hidden":"true",style:E?{transform:"rotate(90deg)"}:void 0})},d)),i&&a.jsxs(a.Fragment,{children:[a.jsx(Ro,{}),Pi.map(({axis:d,testId:y,label:b,icon:v})=>a.jsx(et,{"data-testid":y,title:b,"aria-label":b,variant:"ghost",size:"compact",onClick:()=>cn(t,jo(e,d)),children:a.jsx(nt,{icon:v,"aria-hidden":"true"})},d))]})]})}function Di({rect:t,initialText:e,onCommit:n,onCancel:r}){const[s,i]=c.useState(e),d=c.useRef(null),y=c.useRef(!1);c.useEffect(()=>{const E=d.current;E&&(E.focus(),E.select())},[]);const b=()=>{y.current||(y.current=!0,n(s))},v=()=>{y.current||(y.current=!0,r())};return a.jsx(Mo,{ref:d,"data-testid":"world-text-editor",value:s,onChange:E=>i(E.target.value),onBlur:b,onKeyDown:E=>{E.key==="Escape"?(E.stopPropagation(),v()):E.key==="Enter"&&!E.shiftKey&&(E.preventDefault(),b())},"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:oe.overlayLow,pointerEvents:"auto",resize:"none"}})}const G=zt.accent.default,Ti=oe.overlayLow,Jt=5;function Li(t,e,n){return t?!1:Me()?.editorControls?.activate(e,n)??!1}function $i(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 Oi(t,e){const n=t.hierarchy.node(e);return n?`${n.label}·${n.kind}`:e}function Bi(t){return t instanceof Pn?t.childAdapters().some(e=>!!e.adapter.rects):!!t.rects}function Ai(t){const e=t instanceof Pn?t.childAdapters():[{worldId:"",adapter:t}],n=[];for(const{worldId:r,adapter:s}of e)if(s.rects&&!(r&&yn(r)))for(const i of En(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 Fi(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 Yi(t,e,n){if(!n)return[e];const r=new Set(t);return r.has(e)?r.delete(e):r.add(e),[...r]}function Ni(t,e,n,r){return e&&!!n&&(n.width>Jt||n.height>Jt)&&n?Ai(t).filter(d=>Fi(n,d.rect)).map(d=>d.id):r?null:[]}function _i(t,e,n,r){return t?"grabbing":e?"grab":n||r?"crosshair":"default"}function ct(t){try{t.currentTarget.setPointerCapture?.(t.pointerId)}catch{}}function ve(t){t.currentTarget.hasPointerCapture?.(t.pointerId)&&t.currentTarget.releasePointerCapture?.(t.pointerId)}function Gi(t,e){if(e!==null)return!1;const n=t.currentTarget.parentElement?.parentElement??null;return Tr(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 ${G}`,background:e?`color-mix(in srgb, ${G} 6%, transparent)`:"transparent",boxSizing:"border-box",pointerEvents:"none"}}function Xi(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:G,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 ${G}`,boxSizing:"border-box",cursor:e,pointerEvents:"auto"}}const wt=12,Vi=24;function Hi(t){return{position:"absolute",left:t.x+t.width/2-wt/2,top:t.y-Vi-wt/2,width:wt,height:wt,borderRadius:"50%",background:"#fff",border:`1px solid ${G}`,boxSizing:"border-box",cursor:"grab",padding:0,pointerEvents:"auto"}}const fn=12;function Wi(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 Ki(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 ${G}`,boxSizing:"border-box",color:G,cursor:"crosshair",fontSize:9,fontFamily:"'SF Mono', 'Fira Code', Menlo, Consolas, monospace",fontWeight:700,lineHeight:1,padding:0,pointerEvents:"auto",touchAction:"none"}}function Ui(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:G,borderRadius:3,pointerEvents:"none",whiteSpace:"nowrap"}}const Zi="rgba(46, 204, 113, 0.25)",qi="rgba(230, 126, 34, 0.25)";function Qi(t){return{position:"absolute",left:t.x,top:t.y,width:t.width,height:t.height,background:t.kind==="padding"?Zi:qi,boxSizing:"border-box",cursor:t.cursor,pointerEvents:"auto"}}function Ji(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 ts(t){return{position:"absolute",left:t.x,top:t.y,width:t.width,height:t.height,border:`2px dashed ${G}`,background:`color-mix(in srgb, ${G} 15%, transparent)`,boxSizing:"border-box",pointerEvents:"none",opacity:.7}}function es(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",Vt=6;function ns(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-Vt/2,top:n?e-Vt/2:e,width:n?1:Vt,height:n?Vt:1,background:Le,pointerEvents:"none"}}function os(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 rs(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 is(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, ${G} 85%, transparent)`,borderRadius:3,whiteSpace:"nowrap"};function ss(t){return{position:"absolute",left:t.x,top:t.y,width:t.width,height:t.height,border:`1px dashed color-mix(in srgb, ${G} 45%, transparent)`,boxSizing:"border-box",pointerEvents:"none"}}function xn(t,e,n){return e&&n>0?Math.round(t/n)*n:t}function as(t,e,n,r,s,i){const d=t.nativeHandleSpan??1,y=t.nativeScaleAxis??"both";let b,v;if(y==="x")b=1+e/d,v=1;else if(y==="y")b=1,v=1+n/d;else{const E=1+(e+n)/(Math.SQRT2*d);b=E,v=E}return{...y!=="y"?{scaleXFactor:b}:{},...y!=="x"?{scaleYFactor:v}:{},...r&&!s?{scaleStep:i}:{}}}function ls(t,e,n,r,s,i){const d=t.nativeOrigin;if(!d)return{};const y=r&&!s;return{...t.moveAxis!=="y"?{originX:xn(d.x+e,y,i)}:{},...t.moveAxis!=="x"?{originY:xn(d.y+n,y,i)}:{}}}function cs(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 ds(t,e,n){return t==="x"?{dx:e,dy:0}:t==="y"?{dx:0,dy:n}:{dx:e,dy:n}}function us(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 ps(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 fs(t,e,n){const r=Q(t,e);if(!r)return null;const s=t.inspector?.get(e,"style.position"),i=we(t,e)==="2d";if(s!=="absolute"&&s!=="fixed"&&!i)return null;const d=F(t,e);if(!d)return null;const y=i?r.gizmoOrigin?.(e)??void 0:void 0,b=[];for(const v of n){if(v===e)continue;const E=Q(t,v),C=F(t,v);if(!E||!C)continue;const k=t.inspector?.get(v,"style.position"),P=we(t,v)==="2d";if(k!=="absolute"&&k!=="fixed"&&!P)continue;const x=P?E.gizmoOrigin?.(v)??void 0:void 0;b.push({id:v,ownerBoxEdit:E,origRect:C,...x?{nativeOrigin:x}:{}})}return{id:e,ownerBoxEdit:r,origRect:d,context:Rt(t,e),...y?{nativeOrigin:y}:{},peers:b}}function hs(t,e){if(!qo(t,e)?.reorder)return null;const r=Qo(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 y=F(t,d);y&&i.push({id:d,rect:y})}return i.length===0?null:{id:e,adapter:t,origRect:s,siblingRects:i}}function gs(){return Jo()}function ms(t,e){if(e.size!==1)return null;const n=[...e][0],r=Q(t,n);if(!r)return null;const s=F(t,n);if(!s)return null;const i=tr(s,er(t,n));return{id:n,rect:s,ownerBoxEdit:r,spacingBands:i}}function xs(t,e){if(e.size<2)return null;const n=[];for(const r of e){const s=F(t,r);if(!s||!Q(t,r))return null;n.push({id:r,rect:s})}return n}function bs(t,e,n){const r=e.size===1?[...e][0]:null,s=r?F(t,r):null,i=s&&n?nr(s,n):[],d=r?or(t,r):null,y=!!(d&&(d.position||d.parentLayout)),b=r?Rt(t,r)?.parent??null:null;return{selectedSingleRect:s,measureLines:i,positionBadge:d,showPositionBadge:y,parentRect:b}}function ys({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(rr,{children:a.jsx(ir,{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:oe.dropdown},children:t.ids.map(s=>{const i=e.hierarchy.node(s);return a.jsxs(sr,{"data-testid":"viewport-pick-menu-item",onSelect:()=>{zn(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 vs({adapter:t,view:e,transformModeAware:n=!1}={}){const r=je(ne()),s=c.useSyncExternalStore(r.subscribe,r.getSnapshot),i=t??Rn(r),d=c.useCallback((o,l)=>t?t.pickable?.pick(o,l)??null:Do(r,o,l),[t,r]),y=c.useRef(null),b=c.useRef(null),v=c.useRef(null),[E,C]=c.useState(null),[k,P]=c.useState(null),[x,f]=c.useState(null),[p,w]=c.useState(null),h=c.useRef(null),j=c.useCallback((o,l)=>{const m=To(r,o,l,{...t?{adapter:t}:{}});if(m.length===0){w(null);return}w({x:o,y:l,ids:m})},[t,r]);c.useEffect(()=>{const o=m=>{const g=h.current;!g||g.pointerId!==m.pointerId||g.moved||Math.hypot(m.clientX-g.startClientX,m.clientY-g.startClientY)>Jt&&(g.moved=!0)},l=m=>{const g=h.current;!g||g.pointerId!==m.pointerId||(h.current=null,m.type==="pointerup"&&!g.moved&&j(m.clientX,m.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)}},[j]);const D=c.useCallback(o=>{o.preventDefault(),o.stopPropagation()},[]),M=e??Pe,I=c.useSyncExternalStore(M.subscribe,M.get,M.get);c.useSyncExternalStore(c.useCallback(o=>Xn(M,o),[M]),c.useCallback(()=>Gn(M),[M]));const X=n?_n(M):[],H=n?1/I.zoom:1,W=c.useRef(!1),[Mt,gt]=c.useState(!1),Y=c.useRef(null),[Dt,mt]=c.useState(!1),B=c.useRef(null);c.useEffect(()=>()=>{const o=B.current;if(B.current=null,!!o){o.ownerBoxEdit.end(o.id);for(const l of o.movePeers??[])l.ownerBoxEdit.end(l.id)}},[]);const[,ie]=c.useState(0),[se,dt]=c.useState(null),[u,R]=c.useState([]),L=c.useRef(null),[O,_]=c.useState(null),A=c.useCallback(o=>{L.current=o,_(o)},[]),xt=c.useRef(null),[$e,K]=c.useState(null),[J,ut]=c.useState(null),pt=c.useCallback(o=>{xt.current=o,K(o)},[]),ae=c.useRef(null),Oe=c.useRef(null);c.useEffect(()=>{const o=ae.current;if(!o)return;ae.current=null;const l=ue(i,o.id);l&&l.get(o.id)===null&&ut({id:o.id,rect:o.rect})},[s]);const Be=c.useRef("");c.useEffect(()=>{const o=[...r.selectedEntityIds].sort().join(",");o!==Be.current&&(Be.current=o,J&&ut(null))}),c.useEffect(()=>{if(!J)return;const o=window.setTimeout(()=>ut(null),4e3);return()=>window.clearTimeout(o)},[J]);const st=c.useSyncExternalStore(Ci,Ei),[Wn,Ae]=c.useState(null),tt=c.useCallback(o=>{v.current=o,C(o)},[]),T=c.useCallback((o,l)=>{const m=y.current?.getBoundingClientRect();return{x:(o-(m?.left??0)-I.x)/I.zoom,y:(l-(m?.top??0)-I.y)/I.zoom}},[I.x,I.y,I.zoom]),Kn=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]),Un=c.useCallback(o=>{if(!e||!n||!i.assetDrop)return;const l=o.dataTransfer.getData("application/x-editor-asset");if(!l)return;let m;try{m=JSON.parse(l)}catch{return}const g=T(o.clientX,o.clientY),S={position:[g.x,g.y,0],item:m.component??{kind:"file",name:m.name??m.path.split("/").pop()??m.path}};i.assetDrop.accepts("",m.path,S)&&(o.preventDefault(),o.stopPropagation(),Lo(i,"",m.path,S))},[i.assetDrop,e,T,n]),at=c.useCallback(()=>ie(o=>o+1),[]),Tt=c.useCallback(()=>{const o=B.current;if(!o)return!1;B.current=null,o.ownerBoxEdit.end(o.id);for(const l of o.movePeers??[])l.ownerBoxEdit.end(l.id);return dt(null),R([]),at(),!0},[at]),Zn=c.useCallback((o,l)=>{if(l.stopPropagation(),l.button!==0)return;const m=r.selectedEntityIds;if(m.size!==1)return;const g=[...m][0],S=Q(i,g),z=F(i,g);if(!S||!z)return;const $=i.inspector?.get(g,"style.position"),it=we(i,g)==="2d";ct(l),S.begin(g),B.current={kind:"resize",id:g,ownerBoxEdit:S,startLocal:T(l.clientX,l.clientY),origRect:z,pos:o,isPositioned:$==="absolute"||$==="fixed"||it,context:Rt(i,g)}},[i,r,T]),qn=c.useCallback(o=>{if(o.stopPropagation(),o.button!==0)return;const l=r.selectedEntityIds;if(l.size!==1)return;const m=[...l][0],g=Q(i,m),S=F(i,m);if(!g||!S)return;const z=n?g.gizmoOrigin?.(m):null;ct(o),g.begin(m),B.current={kind:"rotate",id:m,ownerBoxEdit:g,startLocal:T(o.clientX,o.clientY),origRect:S,center:z??{x:S.x+S.width/2,y:S.y+S.height/2},...z?{nativeOrigin:z}:{}}},[i,r,T,n]),le=c.useCallback((o,l)=>{if(l.stopPropagation(),l.button!==0)return;const m=r.selectedEntityIds;if(m.size!==1)return;const g=[...m][0],S=Q(i,g),z=F(i,g);if(!S||!z)return;const $=S.gizmoOrigin?.(g)??{x:z.x+z.width/2,y:z.y+z.height/2};ct(l),S.begin(g),B.current={kind:"move",id:g,ownerBoxEdit:S,startLocal:T(l.clientX,l.clientY),origRect:z,context:Rt(i,g),moveAxis:o,nativeOrigin:$}},[i,r,T]),Qn=c.useCallback((o,l)=>{if(l.stopPropagation(),l.button!==0)return;const m=r.selectedEntityIds;if(m.size!==1)return;const g=[...m][0],S=Q(i,g),z=F(i,g);if(!S||!z)return;const $=S.gizmoOrigin?.(g)??{x:z.x+z.width/2,y:z.y+z.height/2};ct(l),S.begin(g),B.current={kind:"native-scale",id:g,ownerBoxEdit:S,startLocal:T(l.clientX,l.clientY),origRect:z,nativeOrigin:$,nativeScaleAxis:o,nativeHandleSpan:un/I.zoom}},[i,I.zoom,r,T]),Jn=c.useCallback((o,l)=>{if(l.stopPropagation(),l.button!==0)return;const m=r.selectedEntityIds;if(m.size!==1)return;const g=[...m][0],S=Q(i,g),z=F(i,g);!S||!z||S.referencePoint?.(g)?.id!==o.id||(ct(l),S.begin(g),B.current={kind:"reference",id:g,ownerBoxEdit:S,startLocal:T(l.clientX,l.clientY),origRect:z,context:Rt(i,g),pointerId:l.pointerId,referencePoint:o})},[i,r,T]),Lt=c.useRef(null),to=c.useCallback((o,l,m,g)=>{g.stopPropagation(),!(g.button!==0||!m.writable)&&(ct(g),Lt.current={id:o,handleId:m.id,provider:l})},[]),eo=c.useCallback(o=>{const l=Lt.current;if(!l)return;const m=T(o.clientX,o.clientY);l.provider.preview(l.id,l.handleId,[m.x,m.y,0]),at()},[at,T]),ce=c.useCallback(o=>{const l=Lt.current;if(Lt.current=null,!l)return;ve(o);const m=T(o.clientX,o.clientY);l.provider.commit(l.id,l.handleId,[m.x,m.y,0]),at()},[at,T]),no=c.useCallback((o,l)=>{if(l.stopPropagation(),l.button!==0)return;const m=r.selectedEntityIds;if(m.size!==1)return;const g=[...m][0],S=Q(i,g),z=F(i,g);!S||!z||(ct(l),S.begin(g),B.current={kind:"spacing",id:g,ownerBoxEdit:S,startLocal:T(l.clientX,l.clientY),origRect:z,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 m=T(l.clientX,l.clientY),g=m.x-o.startLocal.x,S=m.y-o.startLocal.y;let z;if(o.kind==="resize")z=$o(o.pos,g,S,o.origRect,!!o.isPositioned,l.altKey,o.context),R(Oo(o.pos,g,S,o.origRect,l.altKey,o.context));else if(o.kind==="native-scale")z=as(o,g,S,r.snapEnabled,l.altKey,r.snapValues.scale),R([]);else if(o.kind==="move"){const{dx:$,dy:it}=ds(o.moveAxis,g,S);if(o.nativeOrigin){z=ls(o,$,it,r.snapEnabled,l.altKey,r.snapValues.translate);const Z=Bo({x:z.originX??o.nativeOrigin.x,y:z.originY??o.nativeOrigin.y},o.nativeOrigin,o.origRect,o.context,o.moveAxis,!r.snapEnabled||l.altKey,Ao/Math.max(I.zoom,.01),{x:X.filter(ht=>ht.axis==="x").map(ht=>ht.value),y:X.filter(ht=>ht.axis==="y").map(ht=>ht.value)});z.originX!==void 0&&(z.originX=Z.position.x),z.originY!==void 0&&(z.originY=Z.position.y),R(Z.guides)}else z=Fo($,it,o.origRect,l.altKey,o.context);dt(He(o.origRect,$,it)),o.nativeOrigin||R(Yo($,it,o.origRect,l.altKey,o.context))}else if(o.kind==="reference"){const $=No(m,o.origRect,l.altKey,o.context,{bounded:o.referencePoint?.bounded,snapPoints:o.referencePoint?.snapPoints});z={referenceX:$.position.x,referenceY:$.position.y},R($.guides)}else o.kind==="rotate"?z=_o(o.center,o.startLocal,m,o.nativeOrigin&&!r.snapEnabled||l.altKey,o.nativeOrigin?r.snapValues.rotate:15):z=Go(o.side,g,S,o.origValue??0);if(o.ownerBoxEdit.apply(o.id,z),o.kind==="move"&&o.movePeers){const $=o.nativeOrigin?(z.originX??o.nativeOrigin.x)-o.nativeOrigin.x:(z.x??o.origRect.x)-o.origRect.x,it=o.nativeOrigin?(z.originY??o.nativeOrigin.y)-o.nativeOrigin.y:(z.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,I.zoom]),Ot=c.useCallback((o,l)=>{const m=d(o,l);if(!m)return null;const g=Xo(i,m)?.backgroundChainAt(o,l)??null;return g?Ri(g):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=g=>g instanceof HTMLInputElement||g instanceof HTMLTextAreaElement||g instanceof HTMLSelectElement||g instanceof HTMLElement&&g.isContentEditable,l=g=>{g.code!=="Space"||g.repeat||o(g.target)||g.target instanceof HTMLButtonElement||(g.preventDefault(),W.current=!0,gt(!0))},m=g=>{g.code==="Space"&&(W.current=!1,gt(!1),Y.current&&(Y.current=null,mt(!1)))};return window.addEventListener("keydown",l),window.addEventListener("keyup",m),()=>{window.removeEventListener("keydown",l),window.removeEventListener("keyup",m)}},[]);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){Ot(o.clientX,o.clientY),Ae(null);return}if(Li(t,o.clientX,o.clientY)){b.current=null,P(null),tt(null);return}const l=d(o.clientX,o.clientY);if(Gi(o,l)){b.current=null,P(null),tt(null);return}const m=l!==null?ps(i,l,r.selectedEntityIds):null,g=(!n||r.transformMode==="translate")&&m!==null?fs(i,m,r.selectedEntityIds):null,S=!g&&m!==null?hs(i,m):null;b.current={downClientX:o.clientX,downClientY:o.clientY,downLocal:T(o.clientX,o.clientY),hitAtDown:l,moved:!1,moveCandidate:g,reorderCandidate:S},P(null),tt(null)},[i,r,M,n,T,tt,st,Ot,d,t]),oo=c.useCallback(o=>{if(o.button===2){h.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 m=l.clientX-o.downClientX,g=l.clientY-o.downClientY;if(!o.moved&&Math.hypot(m,g)>Jt&&(o.moved=!0),!!o.moved){if(o.moveCandidate){const S=us(o.moveCandidate,o.downLocal);B.current=S,$t(S,l);return}if(o.reorderCandidate){const S=T(l.clientX,l.clientY),z=Vo(o.reorderCandidate.siblingRects,S);z&&(A({id:o.reorderCandidate.id,adapter:o.reorderCandidate.adapter,gap:z}),dt(He(o.reorderCandidate.origRect,S.x-o.downLocal.x,S.y-o.downLocal.y)));return}if(o.hitAtDown===null){const S=T(l.clientX,l.clientY);tt({x:Math.min(o.downLocal.x,S.x),y:Math.min(o.downLocal.y,S.y),width:Math.abs(S.x-o.downLocal.x),height:Math.abs(S.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 S=T(o.clientX,o.clientY);Ae({...S,color:Ot(o.clientX,o.clientY)});return}const m=B.current;if(m){$t(m,o);return}if((o.buttons&1)===0){$i(t,o.clientX,o.clientY,d,f,P);return}const g=b.current;g&&Ye(g,o)},[r,M,T,$t,st,Ot,Ye,d,t]),rt=c.useCallback(o=>{if(ve(o),Y.current){Y.current=null,mt(!1);return}const l=B.current;if(l?.pointerId!==void 0&&o.pointerId!==l.pointerId||Tt())return;const m=L.current;if(m){A(null),dt(null),b.current=null,Ho(m.adapter,m.id,m.gap.beforeSiblingId);return}const g=b.current;if(b.current=null,!g)return;const S=g.hitAtDown!==null?Yi(r.selectedEntityIds,g.hitAtDown,o.shiftKey):Ni(i,g.moved,v.current,o.shiftKey);S!==null&&zn(i,S),tt(null)},[i,r,tt,Tt,A]),U=c.useCallback(o=>{if(ve(o),Y.current){Y.current=null,mt(!1);return}const l=B.current;l?.pointerId!==void 0&&o.pointerId!==l.pointerId||Tt()||(L.current&&(A(null),dt(null)),b.current=null,tt(null))},[Tt,tt,A]),ro=c.useCallback(()=>{t||Me()?.editorControls?.clearHover(),f(null),P(null)},[t]),io=c.useCallback(o=>{const l=y.current?.parentElement??null;if(Dr(l,o.clientX,o.clientY))return;const m=d(o.clientX,o.clientY);if(!m)return;const g=ue(i,m);if(!g)return;const S=F(i,m);if(!S)return;const z=g.get(m);if(z===null){console.warn(`[RootSelectionOverlay] text edit refused for "${m}": dynamic body or has child elements — not inline-editable.`),pt(null),ut({id:m,rect:S});return}ut(null),pt({id:m,rect:S,initialText:z})},[i,d,pt]),so=c.useCallback(o=>{const l=xt.current;if(!l)return;const m=ue(i,l.id);m&&(ae.current={id:l.id,rect:l.rect},m.set(l.id,o)),pt(null)},[i,pt]),ao=c.useCallback(()=>pt(null),[pt]);if(!Bi(i)||gs())return null;const ft=new Set([...r.selectedEntityIds].filter(o=>i.hierarchy.node(o)!==void 0)),de=k!==null&&!ft.has(k)?F(i,k):null,V=ms(i,ft),bt=V?.rect??null,lo=V?.ownerBoxEdit??null,N=n&&V?V.ownerBoxEdit.gizmoOrigin?.(V.id)??{x:V.rect.x+V.rect.width/2,y:V.rect.y+V.rect.height/2}:null,Ct=un/I.zoom,lt=V?V.ownerBoxEdit.referencePoint?.(V.id):null,co=V?.spacingBands??[],yt=ft.size===1?[...ft][0]:null,Bt=yt?Wo(i,yt):null,uo=yt&&Bt&&r.showHelpers?Bt.layers(yt).filter(o=>r.helperVisibility[o.category]??!0):[],kt=n?{selectedSingleRect:null,measureLines:[],positionBadge:null,showPositionBadge:!1,parentRect:null}:bs(i,ft,de),Ne=n?null:xs(i,ft),At=Oe.current,po=n?[]:At&&At.adapter===i&&At.version===s?At.hints:(()=>{const o=Ko(i);return Oe.current={adapter:i,version:s,hints:o},o})();return a.jsxs("div",{style:{position:"absolute",inset:0,zIndex:Ti,pointerEvents:"none"},children:[a.jsx("div",{ref:y,"data-testid":"world-selection-overlay-interaction",style:{position:"absolute",inset:0,pointerEvents:"auto",touchAction:"none",userSelect:"none",cursor:x??_i(Dt,Mt,st,!!E)},onPointerDownCapture:oo,onPointerMove:ot,onPointerUp:rt,onPointerCancel:U,onLostPointerCapture:U,onPointerLeave:ro,onDoubleClick:io,onContextMenu:D,onDragOver:Kn,onDrop:Un}),p?a.jsx(ys,{state:p,adapter:i,onClose:()=>w(null)}):null,a.jsxs("div",{"data-testid":"world-selection-overlay-chrome",style:{position:"absolute",inset:0,pointerEvents:"none",transform:ze(I),transformOrigin:"0 0"},children:[!n&&po.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/I.zoom:1,boxSizing:"border-box",pointerEvents:"none"}},o.id)),de&&a.jsx("div",{"data-testid":"world-selection-hover",style:{...dn(de,!1),...n?{borderWidth:1/I.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/I.zoom,background:"transparent"}:{}}}),!n&&a.jsx("div",{"data-testid":"world-selection-label",style:Xi(l),children:Oi(i,o)})]},o):null}),E&&a.jsx("div",{"data-testid":"world-selection-marquee",style:{position:"absolute",left:E.x,top:E.y,width:E.width,height:E.height,border:`1px solid ${G}`,background:`color-mix(in srgb, ${G} 10%, transparent)`,pointerEvents:"none"}}),!n&&a.jsx(ws,{measureLines:kt.measureLines,snapGuides:u,positionBadge:kt.positionBadge,showPositionBadge:kt.showPositionBadge,badgeAnchorRect:kt.selectedSingleRect,parentRect:kt.parentRect,screenScale:H,screenZoom:1}),!n&&a.jsx(Ss,{dragGhost:se,reorderPreview:O}),!n&&Ne&&a.jsx(Mi,{adapter:i,entries:Ne}),bt&&lo&&a.jsxs(a.Fragment,{children:[!n&&co.map(o=>a.jsxs("div",{children:[a.jsx("div",{"data-testid":`world-spacing-${o.kind}-${Cs(o.side)}`,style:Qi(o),onPointerDown:l=>no(o,l),onPointerMove:ot,onPointerUp:rt,onPointerCancel:U}),!o.isZero&&a.jsx("div",{style:{...Ji(o),...n?{transform:`translate(-50%, -50%) scale(${H})`,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:{...Ki(lt),...n?{transform:`scale(${H})`,transformOrigin:"center"}:{}},onPointerDown:o=>Jn(lt,o),onPointerMove:ot,onPointerUp:rt,onPointerCancel:U,onLostPointerCapture:U,role:"button",tabIndex:0,children:lt.kind==="anchor"?"A":"P"}),yt&&Bt&&uo.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:{...Wi(l),transform:`translate(-50%, -50%) scale(${H})`},onPointerDown:m=>to(yt,Bt,l,m),onPointerMove:eo,onPointerUp:ce,onPointerCancel:ce,onLostPointerCapture:ce},`${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/I.zoom,width:Ct,height:10/I.zoom,borderTop:`${2/I.zoom}px solid #ef5350`,boxSizing:"border-box",cursor:"ew-resize",pointerEvents:"auto"},onPointerDown:o=>le("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/I.zoom,top:N.y,width:10/I.zoom,height:Ct,borderLeft:`${2/I.zoom}px solid #66bb6a`,boxSizing:"border-box",cursor:"ns-resize",pointerEvents:"auto"},onPointerDown:o=>le("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/I.zoom,top:N.y-5/I.zoom,width:10/I.zoom,height:10/I.zoom,border:"1px solid rgba(255,255,255,.9)",background:"#4aa3ff",boxSizing:"border-box",cursor:"move",pointerEvents:"auto"},onPointerDown:o=>le("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/I.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/I.zoom}px solid #66bb6a`,pointerEvents:"none"}}),[["x","ew-resize"],["y","ns-resize"],["both","nwse-resize"]].map(([o,l])=>{const m=cs(o,N,Ct),g=o==="x"?"e":o==="y"?"s":"se";return a.jsx("div",{"data-testid":`world-resize-handle-${g}`,style:{...pn(m,l),transform:`scale(${H})`,transformOrigin:"center",background:o==="x"?"#ef5350":o==="y"?"#66bb6a":"#fff"},onPointerDown:S=>Qn(o,S),onPointerMove:ot,onPointerUp:rt,onPointerCancel:U},o)})]}):a.jsxs(a.Fragment,{children:[Uo.map(({pos:o,cursor:l})=>a.jsx("div",{"data-testid":`world-resize-handle-${o}`,style:pn(Zo(bt,o),l),onPointerDown:m=>Zn(o,m),onPointerMove:ot,onPointerUp:rt,onPointerCancel:U},o)),a.jsx("div",{"data-testid":"world-resize-dimension-label",style:Ui(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/I.zoom,top:N.y-40/I.zoom,width:80/I.zoom,height:80/I.zoom,border:`${1/I.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:{...Hi(bt),...n?{left:N.x-wt/2,top:N.y-40/I.zoom-wt/2,transform:`scale(${H})`,transformOrigin:"center",background:"#4aa3ff"}:{}},onPointerDown:qn,onPointerMove:ot,onPointerUp:rt,onPointerCancel:U,role:"button",tabIndex:0})]})]}),!n&&a.jsx(Es,{textEdit:$e,onCommitTextEdit:so,onCancelTextEdit:ao,textEditRefused:J,eyedropperActive:st,eyedropperPreview:Wn})]})]})}function ws(t){const{measureLines:e,snapGuides:n,positionBadge:r,showPositionBadge:s,badgeAnchorRect:i,parentRect:d,screenScale:y,screenZoom:b}=t;return a.jsxs(a.Fragment,{children:[d&&a.jsx("div",{"data-testid":"world-parent-outline",style:ss(d)}),e.map(v=>a.jsxs("div",{"data-testid":"world-measure-line",children:[a.jsx("div",{style:ns(v)}),a.jsx("div",{style:hn(v.x1,v.y1,v.orientation==="horizontal")}),a.jsx("div",{style:hn(v.x2,v.y2,v.orientation==="horizontal")}),a.jsx("div",{"data-testid":"world-measure-line-label",style:{...os(v),...y!==1?{transform:`translate(-50%, -50%) scale(${y})`,transformOrigin:"center"}:{}},children:v.distance})]},v.orientation)),n.map(v=>a.jsx("div",{"data-testid":"world-snap-guide",style:rs(v)},v.orientation)),s&&i&&r&&a.jsxs("div",{"data-testid":"world-position-badge",style:{...is(i),...y!==1?{top:i.y-36/b,transform:`scale(${y})`,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 Ss(t){const{dragGhost:e,reorderPreview:n}=t;return a.jsxs(a.Fragment,{children:[e&&a.jsx("div",{"data-testid":"world-drag-ghost",style:ts(e)}),n&&a.jsx("div",{"data-testid":"world-reorder-preview",style:es(n.gap.marker)})]})}function Es(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(Di,{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 Cs(t){return t.endsWith("Top")?"top":t.endsWith("Right")?"right":t.endsWith("Bottom")?"bottom":"left"}function ks({explanation:t,testId:e,style:n}){return t?a.jsx(ar,{"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 Is="Scene";function Rs({active:t,composite:e,descriptor:n,documentId:r,store:s}){const i=c.useRef(null),d=c.useRef(null),[y]=c.useState(gr),b=n.kind==="canvas",v=b?y:Pe;c.useSyncExternalStore(s.subscribe,s.getSnapshot);const E=c.useSyncExternalStore(mr,xr),C=c.useSyncExternalStore(br,yr),[k,P]=c.useState(null),x=e.childAdapters().find(I=>I.worldId===n.worldId)?.adapter??k??void 0,f=b&&x?.provenance?.label==="babylon",p=x?.hierarchy.roots()??[],w=new Set(x?.rects?.emptyContainers?.().map(I=>I.id)??[]),h=p.some(I=>!w.has(I.id)),j=oi({surface:b?"Scene":n.kind==="dom"?"UI":"World",rootIds:[n.worldId],playSuspended:s.playState!=="stopped"&&(!x||x.provenance?.source==="boundary"),phase:!x||x.provenance?.source==="boundary"?"loading":"ready",content:!x||x.provenance?.source==="boundary"?"unknown":h?"present":"empty",readiness:E,failures:C});c.useEffect(()=>{if(x)return vr(r,()=>({adapter:x,nodeId:[...s.selectedEntityIds].find(I=>x.hierarchy.node(I))??null}))},[e,x,r,s]),c.useEffect(()=>{const I=i.current;if(I&&!f)return b?Kr(I,v):Wr(I,v)},[v,f,b]),c.useEffect(()=>{if(!t)return;if(!!!d.current&&i.current){d.current=Gr(i.current,e,s,[n],(Mt,gt)=>P(gt),b?{canvasSceneView:y}:void 0,r);return}let X=0,H=0;const W=()=>{if(X+=1,X<2){H=requestAnimationFrame(W);return}Er(r)};return H=requestAnimationFrame(W),()=>cancelAnimationFrame(H)},[t,y,e,n,r,b,s]),c.useEffect(()=>()=>{d.current?.(),d.current=null},[]);const D=wr(Rn(s),s.selectedEntityIds),M=D?.worldId===n.worldId?D:x?.rects?{worldId:n.worldId,kind:"dom",adapter:x}:null;return a.jsxs("div",{ref:i,"data-testid":`world-document:${n.worldId}`,"data-vgai-backdrop-color":t?f?"#111827":b?sn:Se:void 0,"data-vgai-backdrop-policy":t?"dark-frost":void 0,onPointerDown:()=>Sr("viewport"),style:{position:"absolute",inset:0,overflow:"hidden",pointerEvents:"auto",backgroundColor:f?"#111827":b?sn:Se,touchAction:"none"},children:[f?null:b?a.jsx(xi,{view:y,documentId:r}):a.jsx(zs,{}),a.jsx(vs,{...x?{adapter:x}:{},...b&&!f?{view:y,transformModeAware:!0}:{}},`selection:${Ke(x)}`),a.jsx(ks,{explanation:j,testId:`world-surface-status:${n.worldId}`,style:{zIndex:20}}),f?null:b?a.jsx(yi,{active:t,...x?{adapter:x}:{},containerRef:i,view:y,documentId:r},`controls:${Ke(x)}`):a.jsxs(a.Fragment,{children:[a.jsx(pi,{docId:n.worldId,containerRef:i}),a.jsx(wi,{containerRef:i,context:M})]})]})}function zs(){const t=c.useSyncExternalStore(te,ee),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:Se,backgroundImage:`radial-gradient(circle, ${Lr} ${n}px, transparent ${n}px)`,backgroundPosition:`${t.x}px ${t.y}px`,backgroundSize:`${e}px ${e}px`}})}function Vs(t,e){const n=pr(),r=e.childAdapters().some(h=>h.role==="world"&&h.kind==="three"),s=e.childAdapters().some(h=>h.kind===Cr);!r&&!s&&lr(Nt,{discardDirty:!0});const i=new Set,d=[];let y=!1;for(const h of e.childAdapters())h.role==="world"&&h.kind==="three"&&d.push(pe(h.worldId,Nt));const b=Nr(e),v=b.find(h=>h.kind==="canvas");v&&d.push(pe(v.worldId,_t));const E=new Set([...e.childAdapters().filter(h=>h.role==="world"&&h.kind==="three"),...v?[v]:[]].map(h=>h.worldId)),C=new Map;function k(){for(const h of b){if(E.has(h.worldId)||C.has(h.worldId))continue;const j=qr(h.kind);if(!j)continue;const D=pe(h.worldId,j.documentId),M=fr(h.worldId,()=>j.presence()==="absent"?`Root "${h.worldId}" has no document of its own: its design surface is the project's ${j.title} board (${j.documentId}). ${j.absentReason()}`:null);C.set(h.worldId,()=>{M(),D()})}}d.push(cr(h=>{const j=hr();if(j.some(M=>M.descriptor.id===h))return null;const D=Qr(h);return D?D.presence()==="absent"?D.absentReason():null:`No workspace document is named "${h}". Open in this session: ${j.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 P(h){const j=D=>a.jsx(Rs,{...D,composite:e,descriptor:h,store:t});ur({id:_t,title:Is,kind:"world",workspaceRole:"authored-subject",provenance:{rootId:h.worldId,...h.path?{sourcePath:h.path}:{}},Content:j,presentation:()=>({kind:"world",id:h.worldId})},{category:"scene",default:!r,rootId:h.worldId})}function x(h){i.add(h.documentId);const j=()=>{i.delete(h.documentId)};try{Promise.resolve(h.install({store:t,composite:e})).catch(j)}catch{j()}}function f(){if(!y){k();for(const h of Zr()){const j=h.presence();if(j===null)continue;const D=i.has(h.documentId);j==="present"!==D&&(j==="present"?x(h):(We(h.documentId),i.delete(h.documentId)))}}}v&&(P(v),i.add(_t)),f();const p=Jr(f),w=v?_t:[...i][0];return!r&&w!==void 0&&(n===null||n===Nt||n===dr)?fe(w):n?fe(n):r&&fe(Nt),()=>{y=!0,p();for(const h of d)h();for(const h of C.values())h();C.clear();for(const h of i)We(h)}}export{Rs as RootDocumentContent,Vs as installRootDocuments};