@tangle-network/agent-app 0.61.4 → 0.62.0

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 (307) hide show
  1. package/dist/{DesignCanvas-L6J72JQ2.js → DesignCanvas-IQKYAEC4.js} +3 -2
  2. package/dist/{DesignCanvasEditor-QFQD63MR.js → DesignCanvasEditor-O7OCZTGC.js} +5 -4
  3. package/dist/{TimelineEditor-7KBPJQLT.js → TimelineEditor-VB2UJ34D.js} +4 -2
  4. package/dist/VaultPane-AYW7CO33.js +8 -0
  5. package/dist/agent-profiles/d1.js +1 -1
  6. package/dist/agent-profiles/index.d.ts +0 -82
  7. package/dist/agent-profiles/index.js +1 -21
  8. package/dist/agent-profiles/self-management.d.ts +0 -55
  9. package/dist/alerting/index.d.ts +1 -1
  10. package/dist/alerting/index.js +1 -3
  11. package/dist/alerting/slack.d.ts +6 -79
  12. package/dist/app-auth/drizzle.d.ts +17 -271
  13. package/dist/app-auth/drizzle.js +6 -2
  14. package/dist/app-auth/drizzle.js.map +1 -1
  15. package/dist/app-auth/index.js +3 -3
  16. package/dist/assets/types.d.ts +2 -1
  17. package/dist/assistant/AssistantPanel.d.ts +1 -1
  18. package/dist/assistant/index.js +635 -392
  19. package/dist/assistant/index.js.map +1 -1
  20. package/dist/billing/identity-locks.d.ts +5 -0
  21. package/dist/billing/index.js +1 -1
  22. package/dist/brand-extraction/index.js.map +1 -1
  23. package/dist/brand-extraction/types.d.ts +2 -1
  24. package/dist/chat-react/index.js +6 -5
  25. package/dist/chat-routes/attachment-write-safety.d.ts +4 -0
  26. package/dist/chat-routes/draft-persistence.d.ts +2 -14
  27. package/dist/chat-routes/index.d.ts +1 -0
  28. package/dist/chat-routes/index.js +853 -773
  29. package/dist/chat-routes/index.js.map +1 -1
  30. package/dist/chat-routes/sandbox-model-source.d.ts +20 -0
  31. package/dist/chat-routes/stored-attachments.d.ts +18 -0
  32. package/dist/chat-routes/turn-admission.d.ts +1 -1
  33. package/dist/chat-routes/turn-execution.d.ts +2 -2
  34. package/dist/chat-routes/turn-route-contracts.d.ts +3 -29
  35. package/dist/chat-store/core.d.ts +19 -1
  36. package/dist/chat-store/index.js.map +1 -1
  37. package/dist/chat-store/store.d.ts +3 -29
  38. package/dist/{chunk-ATQQCG4I.js → chunk-2VJLLRVV.js} +2 -2
  39. package/dist/{chunk-R4X5474U.js → chunk-52SDU43B.js} +12 -27
  40. package/dist/chunk-52SDU43B.js.map +1 -0
  41. package/dist/{chunk-MDRH3SDA.js → chunk-54YIL7WM.js} +3 -3
  42. package/dist/{chunk-6QJ3GB3A.js → chunk-5GSZGTPJ.js} +2 -2
  43. package/dist/{chunk-5IM2CLYX.js → chunk-6JEDSKFH.js} +232 -218
  44. package/dist/chunk-6JEDSKFH.js.map +1 -0
  45. package/dist/{chunk-6PRQ45QE.js → chunk-6OG4244Y.js} +1 -1
  46. package/dist/chunk-6OG4244Y.js.map +1 -0
  47. package/dist/{chunk-ZDPUC6CM.js → chunk-6ZVSMA4T.js} +3 -3
  48. package/dist/{chunk-TXUAGSFR.js → chunk-76MPX7JQ.js} +47 -1
  49. package/dist/chunk-76MPX7JQ.js.map +1 -0
  50. package/dist/{chunk-BOQ4HVVH.js → chunk-7ISHKBAD.js} +61 -52
  51. package/dist/chunk-7ISHKBAD.js.map +1 -0
  52. package/dist/chunk-7PULOECS.js +22 -0
  53. package/dist/chunk-7PULOECS.js.map +1 -0
  54. package/dist/{chunk-KJODHPWM.js → chunk-CPVGRQ43.js} +511 -339
  55. package/dist/chunk-CPVGRQ43.js.map +1 -0
  56. package/dist/{chunk-LO6VQ35O.js → chunk-CQZVJVME.js} +2 -2
  57. package/dist/{chunk-Y43PXON2.js → chunk-EFQUAWWF.js} +577 -546
  58. package/dist/chunk-EFQUAWWF.js.map +1 -0
  59. package/dist/{chunk-FPNZMIAW.js → chunk-ELX5YITO.js} +1 -1
  60. package/dist/chunk-ELX5YITO.js.map +1 -0
  61. package/dist/chunk-FGAROAUF.js +19 -0
  62. package/dist/chunk-FGAROAUF.js.map +1 -0
  63. package/dist/{chunk-HN6MZ2XL.js → chunk-FTNGGR37.js} +641 -466
  64. package/dist/chunk-FTNGGR37.js.map +1 -0
  65. package/dist/{chunk-G4F2NWZH.js → chunk-FZ3ZFVAC.js} +4 -4
  66. package/dist/{chunk-UCCSJX64.js → chunk-GIEUZBQQ.js} +1112 -644
  67. package/dist/chunk-GIEUZBQQ.js.map +1 -0
  68. package/dist/{chunk-MEKOWH5E.js → chunk-IVBREL7A.js} +785 -526
  69. package/dist/chunk-IVBREL7A.js.map +1 -0
  70. package/dist/{chunk-WSEXFTN4.js → chunk-JBXNU5WD.js} +26 -26
  71. package/dist/chunk-JBXNU5WD.js.map +1 -0
  72. package/dist/{chunk-F2VX6TTJ.js → chunk-JRCZHDRG.js} +2 -41
  73. package/dist/chunk-JRCZHDRG.js.map +1 -0
  74. package/dist/{chunk-LXYQOOXU.js → chunk-JRW6LCIA.js} +552 -302
  75. package/dist/chunk-JRW6LCIA.js.map +1 -0
  76. package/dist/{chunk-TVPH5T4F.js → chunk-KS4I7KVC.js} +16 -22
  77. package/dist/{chunk-TVPH5T4F.js.map → chunk-KS4I7KVC.js.map} +1 -1
  78. package/dist/{chunk-J2BBYVGF.js → chunk-MRZP65DZ.js} +1 -117
  79. package/dist/chunk-MRZP65DZ.js.map +1 -0
  80. package/dist/{chunk-4ZSLX3LY.js → chunk-OODZCBSM.js} +1 -1
  81. package/dist/chunk-OODZCBSM.js.map +1 -0
  82. package/dist/chunk-P4RRC4AO.js +47 -0
  83. package/dist/chunk-P4RRC4AO.js.map +1 -0
  84. package/dist/{chunk-ORQD4AUO.js → chunk-PCAY23GS.js} +1 -6
  85. package/dist/chunk-PCAY23GS.js.map +1 -0
  86. package/dist/{chunk-NMZUW6VJ.js → chunk-PEJ5OP5B.js} +3 -3
  87. package/dist/chunk-PEJ5OP5B.js.map +1 -0
  88. package/dist/{chunk-NHYRIM4I.js → chunk-PIPNDZ6H.js} +304 -194
  89. package/dist/chunk-PIPNDZ6H.js.map +1 -0
  90. package/dist/{chunk-L7LQRJGD.js → chunk-TCJ4TMOW.js} +37 -33
  91. package/dist/{chunk-L7LQRJGD.js.map → chunk-TCJ4TMOW.js.map} +1 -1
  92. package/dist/chunk-UHSUY6H6.js +79 -0
  93. package/dist/chunk-UHSUY6H6.js.map +1 -0
  94. package/dist/{chunk-PDD5A43Y.js → chunk-UTL6TEN6.js} +3 -3
  95. package/dist/{chunk-VJBFCNAU.js → chunk-UW2DKTEM.js} +123 -130
  96. package/dist/chunk-UW2DKTEM.js.map +1 -0
  97. package/dist/{chunk-S27DKRI6.js → chunk-VDYEVCQQ.js} +2 -2
  98. package/dist/{chunk-UFQM46NV.js → chunk-VK3F4N4U.js} +2 -2
  99. package/dist/{chunk-6ZIC6OG5.js → chunk-VYBTQK25.js} +126 -122
  100. package/dist/chunk-VYBTQK25.js.map +1 -0
  101. package/dist/{chunk-RL3Z747H.js → chunk-W2BV2XOC.js} +1491 -700
  102. package/dist/chunk-W2BV2XOC.js.map +1 -0
  103. package/dist/{chunk-FUZETA6Z.js → chunk-X6SZGQTK.js} +2 -2
  104. package/dist/{chunk-CD2LQXY6.js → chunk-XOHE6SKU.js} +14 -16
  105. package/dist/{chunk-CD2LQXY6.js.map → chunk-XOHE6SKU.js.map} +1 -1
  106. package/dist/{chunk-ZBB5KQ6B.js → chunk-Y3GO6SG3.js} +73 -66
  107. package/dist/chunk-Y3GO6SG3.js.map +1 -0
  108. package/dist/chunk-ZAMHLXNS.js +56 -0
  109. package/dist/chunk-ZAMHLXNS.js.map +1 -0
  110. package/dist/{chunk-RHFN7TUV.js → chunk-ZDHCV462.js} +47 -44
  111. package/dist/{chunk-RHFN7TUV.js.map → chunk-ZDHCV462.js.map} +1 -1
  112. package/dist/chunk-ZOS3D26Z.js +72 -0
  113. package/dist/chunk-ZOS3D26Z.js.map +1 -0
  114. package/dist/design-canvas/index.js +32 -32
  115. package/dist/design-canvas/index.js.map +1 -1
  116. package/dist/design-canvas-react/components/DesignCanvas.d.ts +1 -1
  117. package/dist/design-canvas-react/components/Workspace.d.ts +1 -1
  118. package/dist/design-canvas-react/components/glyphs.d.ts +31 -40
  119. package/dist/design-canvas-react/components/transform-math.d.ts +0 -8
  120. package/dist/design-canvas-react/components/use-workspace-keyboard.d.ts +2 -2
  121. package/dist/design-canvas-react/contracts.d.ts +2 -2
  122. package/dist/design-canvas-react/engine.js +1 -1
  123. package/dist/design-canvas-react/index.js +9 -7
  124. package/dist/design-canvas-react/index.js.map +1 -1
  125. package/dist/design-canvas-react/lazy.js +1 -1
  126. package/dist/eval/calibration.d.ts +1 -38
  127. package/dist/eval/index.d.ts +2 -4
  128. package/dist/eval/index.js +0 -84
  129. package/dist/eval/index.js.map +1 -1
  130. package/dist/harness/index.d.ts +1 -1
  131. package/dist/harness/index.js +1 -1
  132. package/dist/harness/session-selection.d.ts +2 -2
  133. package/dist/hub-approvals/index.js +1 -1
  134. package/dist/hub-approvals/result.d.ts +1 -1
  135. package/dist/hub-approvals-react/index.js +4 -4
  136. package/dist/hub-approvals-react/index.js.map +1 -1
  137. package/dist/hub-approvals-react/parts.d.ts +1 -1
  138. package/dist/launch-invariants/cli.js +4 -4
  139. package/dist/launch-invariants/index.js +3 -3
  140. package/dist/launch-invariants/testing.js +4 -4
  141. package/dist/legibility/cli.js +1 -1
  142. package/dist/legibility/index.js +1 -1
  143. package/dist/{mention-editor-B23OMFT2.js → mention-editor-4BKBMWIK.js} +83 -57
  144. package/dist/mention-editor-4BKBMWIK.js.map +1 -0
  145. package/dist/missions/index.js +144 -137
  146. package/dist/missions/index.js.map +1 -1
  147. package/dist/operator/index.js +1 -1
  148. package/dist/peer-floors/check.js +1 -1
  149. package/dist/peer-floors/cli.js +6 -14
  150. package/dist/peer-floors/cli.js.map +1 -1
  151. package/dist/peer-floors/source-entries.d.ts +6 -0
  152. package/dist/platform/index.js +10 -10
  153. package/dist/preset-cloudflare/index.js +1 -1
  154. package/dist/profile/index.d.ts +0 -1
  155. package/dist/profile/index.js +1 -422
  156. package/dist/profile/index.js.map +1 -1
  157. package/dist/profile-editor/server.d.ts +0 -1
  158. package/dist/profile-editor/server.js +0 -1
  159. package/dist/profile-editor/server.js.map +1 -1
  160. package/dist/public-consultation/index.d.ts +2 -2
  161. package/dist/public-consultation/index.js +6 -6
  162. package/dist/record/drizzle.js +156 -148
  163. package/dist/record/drizzle.js.map +1 -1
  164. package/dist/runtime/index.js +4 -4
  165. package/dist/runtime/router-turn.js +3 -3
  166. package/dist/sandbox/index.js +5 -5
  167. package/dist/sequences/drizzle.js +5 -15
  168. package/dist/sequences/drizzle.js.map +1 -1
  169. package/dist/sequences/index.d.ts +1 -0
  170. package/dist/sequences/index.js +18 -14
  171. package/dist/sequences/index.js.map +1 -1
  172. package/dist/sequences/row-mapping.d.ts +7 -0
  173. package/dist/sequences-react/components/TimelineEditor.d.ts +0 -40
  174. package/dist/sequences-react/components/TimelineHistory.d.ts +31 -0
  175. package/dist/sequences-react/components/glyphs.d.ts +12 -21
  176. package/dist/sequences-react/components/index.d.ts +0 -2
  177. package/dist/sequences-react/components/interaction-math.d.ts +3 -3
  178. package/dist/sequences-react/contracts.d.ts +1 -1
  179. package/dist/sequences-react/engine/snap.d.ts +2 -2
  180. package/dist/sequences-react/index.js +4 -4
  181. package/dist/sequences-react/index.js.map +1 -1
  182. package/dist/settings-react/index.js +13 -30
  183. package/dist/settings-react/index.js.map +1 -1
  184. package/dist/settings-react/timezone-picker.d.ts +0 -6
  185. package/dist/signoff/browser-budget.d.ts +6 -1
  186. package/dist/signoff/cli.d.ts +0 -7
  187. package/dist/signoff/cli.js +1 -2
  188. package/dist/signoff/cli.js.map +1 -1
  189. package/dist/signoff/index.js +1 -1
  190. package/dist/skills/index.d.ts +1 -1
  191. package/dist/skills/index.js +5 -25
  192. package/dist/skills/marketplace.d.ts +1 -75
  193. package/dist/skills-placement/box.js +3 -4
  194. package/dist/skills-placement/box.js.map +1 -1
  195. package/dist/skills-placement/index.js +3 -4
  196. package/dist/spend/cli-args.d.ts +1 -1
  197. package/dist/spend/cli.js +3 -3
  198. package/dist/spend/cli.js.map +1 -1
  199. package/dist/spend/index.js +1 -1
  200. package/dist/stories/design-canvas/fixtures.d.ts +1 -14
  201. package/dist/stream/index.js +17 -17
  202. package/dist/studio/generation.d.ts +1 -1
  203. package/dist/studio/index.js +1 -1
  204. package/dist/studio-react/index.js +353 -184
  205. package/dist/studio-react/index.js.map +1 -1
  206. package/dist/studio-react/studio-composer.d.ts +1 -5
  207. package/dist/studio-react/studio-history-screen.d.ts +1 -1
  208. package/dist/teams/invitations-api.d.ts +3 -3
  209. package/dist/teams/invitations-api.js +74 -72
  210. package/dist/teams/invitations-api.js.map +1 -1
  211. package/dist/teams/member-sync.d.ts +2 -0
  212. package/dist/teams/members-api.d.ts +2 -2
  213. package/dist/teams/members-api.js +1 -1
  214. package/dist/teams-react/index.js +28 -45
  215. package/dist/teams-react/index.js.map +1 -1
  216. package/dist/tools/index.js +1 -1
  217. package/dist/tools/mcp-arguments.d.ts +1 -1
  218. package/dist/trace/index.d.ts +1 -18
  219. package/dist/trace/index.js +1 -36
  220. package/dist/trace/index.js.map +1 -1
  221. package/dist/trace/mission-flow.d.ts +1 -59
  222. package/dist/turn-health/index.d.ts +1 -1
  223. package/dist/turn-health/index.js +2 -2
  224. package/dist/turn-health/sink.d.ts +2 -1
  225. package/dist/turn-trace/index.js +2 -4
  226. package/dist/turn-trace/recorder.d.ts +0 -2
  227. package/dist/vault/VaultPane.d.ts +0 -20
  228. package/dist/vault/VaultPaneOperations.d.ts +318 -0
  229. package/dist/vault/index.js +2 -1
  230. package/dist/vault/index.js.map +1 -1
  231. package/dist/vault/lazy.js +1 -1
  232. package/dist/web-react/agent-profile-editor.d.ts +1 -2
  233. package/dist/web-react/agent-profile-editor.js +6 -5
  234. package/dist/web-react/chat-composer.d.ts +1 -1
  235. package/dist/web-react/durable-plan-flow.d.ts +6 -1
  236. package/dist/web-react/editor-glyphs.d.ts +12 -0
  237. package/dist/web-react/focus-navigation.d.ts +12 -0
  238. package/dist/web-react/history-controls.d.ts +37 -0
  239. package/dist/web-react/index.js +36 -34
  240. package/dist/web-react/interaction-question-card.d.ts +1 -1
  241. package/dist/web-react/record-grid-writes.d.ts +31 -0
  242. package/dist/web-react/record-grid.d.ts +1 -48
  243. package/dist/web-react/session-history-panel.d.ts +1 -9
  244. package/dist/web-react/use-document-dark.d.ts +1 -0
  245. package/dist/workspace-export/engine.d.ts +1 -6
  246. package/dist/workspace-export/index.js +198 -185
  247. package/dist/workspace-export/index.js.map +1 -1
  248. package/dist/workspace-export/routes.d.ts +1 -1
  249. package/dist/workspace-react/index.js +9 -8
  250. package/dist/workspace-react/index.js.map +1 -1
  251. package/package.json +1 -11
  252. package/dist/VaultPane-RXL3WLA2.js +0 -7
  253. package/dist/agent-profiles/reaper.d.ts +0 -31
  254. package/dist/agent-profiles/reaper.js +0 -29
  255. package/dist/agent-profiles/reaper.js.map +0 -1
  256. package/dist/chunk-4ZSLX3LY.js.map +0 -1
  257. package/dist/chunk-5IM2CLYX.js.map +0 -1
  258. package/dist/chunk-6OSJNJA2.js +0 -251
  259. package/dist/chunk-6OSJNJA2.js.map +0 -1
  260. package/dist/chunk-6PRQ45QE.js.map +0 -1
  261. package/dist/chunk-6ZIC6OG5.js.map +0 -1
  262. package/dist/chunk-BDEBQ4WO.js +0 -38
  263. package/dist/chunk-BDEBQ4WO.js.map +0 -1
  264. package/dist/chunk-BOQ4HVVH.js.map +0 -1
  265. package/dist/chunk-F2VX6TTJ.js.map +0 -1
  266. package/dist/chunk-FPNZMIAW.js.map +0 -1
  267. package/dist/chunk-HN6MZ2XL.js.map +0 -1
  268. package/dist/chunk-J2BBYVGF.js.map +0 -1
  269. package/dist/chunk-KJODHPWM.js.map +0 -1
  270. package/dist/chunk-LTWJYNEC.js +0 -100
  271. package/dist/chunk-LTWJYNEC.js.map +0 -1
  272. package/dist/chunk-LXYQOOXU.js.map +0 -1
  273. package/dist/chunk-MEKOWH5E.js.map +0 -1
  274. package/dist/chunk-NHYRIM4I.js.map +0 -1
  275. package/dist/chunk-NMZUW6VJ.js.map +0 -1
  276. package/dist/chunk-ORQD4AUO.js.map +0 -1
  277. package/dist/chunk-R4X5474U.js.map +0 -1
  278. package/dist/chunk-RL3Z747H.js.map +0 -1
  279. package/dist/chunk-TXUAGSFR.js.map +0 -1
  280. package/dist/chunk-UCCSJX64.js.map +0 -1
  281. package/dist/chunk-VJBFCNAU.js.map +0 -1
  282. package/dist/chunk-WSEXFTN4.js.map +0 -1
  283. package/dist/chunk-Y43PXON2.js.map +0 -1
  284. package/dist/chunk-ZBB5KQ6B.js.map +0 -1
  285. package/dist/eval/parity.d.ts +0 -74
  286. package/dist/mention-editor-B23OMFT2.js.map +0 -1
  287. package/dist/profile/humanizer-skill.d.ts +0 -23
  288. package/dist/profile/humanizer-skill.vendored.d.ts +0 -4
  289. package/dist/sequences-react/components/BrandMark.d.ts +0 -10
  290. package/dist/skills/marketplace-drizzle.d.ts +0 -121
  291. package/dist/skills/marketplace-drizzle.js +0 -34
  292. package/dist/skills/marketplace-drizzle.js.map +0 -1
  293. package/dist/teams-react/components/BrandMark.d.ts +0 -10
  294. /package/dist/{DesignCanvas-L6J72JQ2.js.map → DesignCanvas-IQKYAEC4.js.map} +0 -0
  295. /package/dist/{DesignCanvasEditor-QFQD63MR.js.map → DesignCanvasEditor-O7OCZTGC.js.map} +0 -0
  296. /package/dist/{TimelineEditor-7KBPJQLT.js.map → TimelineEditor-VB2UJ34D.js.map} +0 -0
  297. /package/dist/{VaultPane-RXL3WLA2.js.map → VaultPane-AYW7CO33.js.map} +0 -0
  298. /package/dist/{chunk-ATQQCG4I.js.map → chunk-2VJLLRVV.js.map} +0 -0
  299. /package/dist/{chunk-MDRH3SDA.js.map → chunk-54YIL7WM.js.map} +0 -0
  300. /package/dist/{chunk-6QJ3GB3A.js.map → chunk-5GSZGTPJ.js.map} +0 -0
  301. /package/dist/{chunk-ZDPUC6CM.js.map → chunk-6ZVSMA4T.js.map} +0 -0
  302. /package/dist/{chunk-LO6VQ35O.js.map → chunk-CQZVJVME.js.map} +0 -0
  303. /package/dist/{chunk-G4F2NWZH.js.map → chunk-FZ3ZFVAC.js.map} +0 -0
  304. /package/dist/{chunk-PDD5A43Y.js.map → chunk-UTL6TEN6.js.map} +0 -0
  305. /package/dist/{chunk-S27DKRI6.js.map → chunk-VDYEVCQQ.js.map} +0 -0
  306. /package/dist/{chunk-UFQM46NV.js.map → chunk-VK3F4N4U.js.map} +0 -0
  307. /package/dist/{chunk-FUZETA6Z.js.map → chunk-X6SZGQTK.js.map} +0 -0
@@ -2,9 +2,11 @@ import {
2
2
  BleedTrimOverlay,
3
3
  BrandKnot,
4
4
  DesignCanvas,
5
- PlusGlyph,
6
5
  ShapesGlyph
7
- } from "./chunk-NHYRIM4I.js";
6
+ } from "./chunk-PIPNDZ6H.js";
7
+ import {
8
+ PlusGlyph
9
+ } from "./chunk-P4RRC4AO.js";
8
10
  import {
9
11
  DEFAULT_INSERT_TEMPLATES,
10
12
  collectGridTargets,
@@ -15,9 +17,10 @@ import {
15
17
  identifyTaintedSrc,
16
18
  isExportHiddenNodeName,
17
19
  marqueeSelect,
20
+ nudgeDelta,
18
21
  resolveExportParams,
19
22
  resolveNodeCachePixelRatio
20
- } from "./chunk-4ZSLX3LY.js";
23
+ } from "./chunk-OODZCBSM.js";
21
24
  import {
22
25
  addElementCommand,
23
26
  createSceneCommandStack,
@@ -289,107 +292,6 @@ import { useRef as useRef2 } from "react";
289
292
  // src/design-canvas-react/components/workspace-gesture-state.ts
290
293
  var NO_MARQUEE = { active: false, startDocX: 0, startDocY: 0, endDocX: 0, endDocY: 0 };
291
294
 
292
- // src/design-canvas-react/components/transform-math.ts
293
- function bakeRectTransform(node) {
294
- return {
295
- x: node.x,
296
- y: node.y,
297
- width: Math.abs(node.width * node.scaleX),
298
- height: Math.abs(node.height * node.scaleY),
299
- rotation: node.rotation
300
- };
301
- }
302
- function bakeLineTransform(node) {
303
- const points = node.points.map((v, i) => i % 2 === 0 ? v * node.scaleX : v * node.scaleY);
304
- return {
305
- x: node.x,
306
- y: node.y,
307
- // Width/height for a line derive from its points; baking is for points only.
308
- // We still return them so callers have a uniform shape.
309
- width: node.width * Math.abs(node.scaleX),
310
- height: node.height * Math.abs(node.scaleY),
311
- rotation: node.rotation,
312
- points
313
- };
314
- }
315
- function bakeTextTransform(node) {
316
- return {
317
- x: node.x,
318
- y: node.y,
319
- width: Math.abs(node.width * node.scaleX),
320
- // Height is excluded — it re-derives from content.
321
- height: node.height,
322
- rotation: node.rotation,
323
- fontSize: Math.max(1, node.fontSize * Math.abs(node.scaleY))
324
- };
325
- }
326
- function ellipseCenterFromTopLeft(topLeft) {
327
- return {
328
- x: topLeft.x + topLeft.width / 2,
329
- y: topLeft.y + topLeft.height / 2,
330
- radiusX: topLeft.width / 2,
331
- radiusY: topLeft.height / 2
332
- };
333
- }
334
- function ellipseTopLeftFromCenter(center) {
335
- return {
336
- x: center.x - center.radiusX,
337
- y: center.y - center.radiusY,
338
- width: center.radiusX * 2,
339
- height: center.radiusY * 2
340
- };
341
- }
342
- function normalizeMarquee(startX, startY, endX, endY) {
343
- const x = Math.min(startX, endX);
344
- const y = Math.min(startY, endY);
345
- return {
346
- x,
347
- y,
348
- width: Math.abs(endX - startX),
349
- height: Math.abs(endY - startY)
350
- };
351
- }
352
- function computeTextOverlayPosition(input) {
353
- const left = input.panX + input.elementX * input.zoom;
354
- const top = input.panY + input.elementY * input.zoom;
355
- return {
356
- left,
357
- top,
358
- width: input.elementWidth * input.zoom,
359
- fontSize: input.elementFontSize * input.zoom
360
- };
361
- }
362
- var SNAP_ANGLES_DEG = [0, 45, 90, 135, 180, 225, 270, 315, 360];
363
- function snapRotation(angleDeg, thresholdDeg = 5) {
364
- const normalized = (angleDeg % 360 + 360) % 360;
365
- let best = normalized;
366
- let bestDist = Infinity;
367
- for (const snap of SNAP_ANGLES_DEG) {
368
- const dist = Math.abs(normalized - snap);
369
- if (dist < bestDist) {
370
- bestDist = dist;
371
- best = snap % 360;
372
- }
373
- }
374
- return bestDist <= thresholdDeg ? best : normalized;
375
- }
376
- function nudgeDelta(key, shift) {
377
- const step = shift ? 10 : 1;
378
- switch (key) {
379
- case "ArrowLeft":
380
- return { dx: -step, dy: 0 };
381
- case "ArrowRight":
382
- return { dx: step, dy: 0 };
383
- case "ArrowUp":
384
- return { dx: 0, dy: -step };
385
- case "ArrowDown":
386
- return { dx: 0, dy: step };
387
- }
388
- }
389
- function gridVisible(gridSize, zoom, minScreenPx = 4) {
390
- return gridSize * zoom >= minScreenPx;
391
- }
392
-
393
295
  // src/design-canvas-react/components/use-workspace-keyboard.ts
394
296
  var DUPLICATE_OFFSET = 10;
395
297
  function useWorkspaceKeyboard({ stack, state, activePage, canWrite, onApplyOperations, persist, gestureRef, spaceHeldRef, setMarquee, setActiveSnap, editingElementId, setEditingElementId }) {
@@ -555,6 +457,96 @@ function useWorkspaceKeyboard({ stack, state, activePage, canWrite, onApplyOpera
555
457
  // src/design-canvas-react/components/ElementNode.tsx
556
458
  import { memo, useEffect as useEffect2, useRef as useRef3, useState as useState2 } from "react";
557
459
  import { Group, Rect, Ellipse, Line, Text, Image as KonvaImage } from "react-konva";
460
+
461
+ // src/design-canvas-react/components/transform-math.ts
462
+ function bakeRectTransform(node) {
463
+ return {
464
+ x: node.x,
465
+ y: node.y,
466
+ width: Math.abs(node.width * node.scaleX),
467
+ height: Math.abs(node.height * node.scaleY),
468
+ rotation: node.rotation
469
+ };
470
+ }
471
+ function bakeLineTransform(node) {
472
+ const points = node.points.map((v, i) => i % 2 === 0 ? v * node.scaleX : v * node.scaleY);
473
+ return {
474
+ x: node.x,
475
+ y: node.y,
476
+ // Width/height for a line derive from its points; baking is for points only.
477
+ // We still return them so callers have a uniform shape.
478
+ width: node.width * Math.abs(node.scaleX),
479
+ height: node.height * Math.abs(node.scaleY),
480
+ rotation: node.rotation,
481
+ points
482
+ };
483
+ }
484
+ function bakeTextTransform(node) {
485
+ return {
486
+ x: node.x,
487
+ y: node.y,
488
+ width: Math.abs(node.width * node.scaleX),
489
+ // Height is excluded — it re-derives from content.
490
+ height: node.height,
491
+ rotation: node.rotation,
492
+ fontSize: Math.max(1, node.fontSize * Math.abs(node.scaleY))
493
+ };
494
+ }
495
+ function ellipseCenterFromTopLeft(topLeft) {
496
+ return {
497
+ x: topLeft.x + topLeft.width / 2,
498
+ y: topLeft.y + topLeft.height / 2,
499
+ radiusX: topLeft.width / 2,
500
+ radiusY: topLeft.height / 2
501
+ };
502
+ }
503
+ function ellipseTopLeftFromCenter(center) {
504
+ return {
505
+ x: center.x - center.radiusX,
506
+ y: center.y - center.radiusY,
507
+ width: center.radiusX * 2,
508
+ height: center.radiusY * 2
509
+ };
510
+ }
511
+ function normalizeMarquee(startX, startY, endX, endY) {
512
+ const x = Math.min(startX, endX);
513
+ const y = Math.min(startY, endY);
514
+ return {
515
+ x,
516
+ y,
517
+ width: Math.abs(endX - startX),
518
+ height: Math.abs(endY - startY)
519
+ };
520
+ }
521
+ function computeTextOverlayPosition(input) {
522
+ const left = input.panX + input.elementX * input.zoom;
523
+ const top = input.panY + input.elementY * input.zoom;
524
+ return {
525
+ left,
526
+ top,
527
+ width: input.elementWidth * input.zoom,
528
+ fontSize: input.elementFontSize * input.zoom
529
+ };
530
+ }
531
+ var SNAP_ANGLES_DEG = [0, 45, 90, 135, 180, 225, 270, 315, 360];
532
+ function snapRotation(angleDeg, thresholdDeg = 5) {
533
+ const normalized = (angleDeg % 360 + 360) % 360;
534
+ let best = normalized;
535
+ let bestDist = Infinity;
536
+ for (const snap of SNAP_ANGLES_DEG) {
537
+ const dist = Math.abs(normalized - snap);
538
+ if (dist < bestDist) {
539
+ bestDist = dist;
540
+ best = snap % 360;
541
+ }
542
+ }
543
+ return bestDist <= thresholdDeg ? best : normalized;
544
+ }
545
+ function gridVisible(gridSize, zoom, minScreenPx = 4) {
546
+ return gridSize * zoom >= minScreenPx;
547
+ }
548
+
549
+ // src/design-canvas-react/components/ElementNode.tsx
558
550
  import { jsx as jsx2 } from "react/jsx-runtime";
559
551
  var IMAGE_CACHE_MAX = 256;
560
552
  var imageCache = /* @__PURE__ */ new Map();
@@ -653,13 +645,7 @@ function RectNode({ element, ...rest }) {
653
645
  Rect,
654
646
  {
655
647
  ref,
656
- name: element.id,
657
- x: element.x,
658
- y: element.y,
659
- width: element.width,
660
- height: element.height,
661
- rotation: element.rotation,
662
- opacity: element.opacity,
648
+ ...canvasElementFrame(element),
663
649
  fill: element.fill,
664
650
  stroke: element.stroke,
665
651
  strokeWidth: element.strokeWidth,
@@ -763,13 +749,7 @@ function ImageNode({ element, ...rest }) {
763
749
  Rect,
764
750
  {
765
751
  ref,
766
- name: element.id,
767
- x: element.x,
768
- y: element.y,
769
- width: element.width,
770
- height: element.height,
771
- rotation: element.rotation,
772
- opacity: element.opacity,
752
+ ...canvasElementFrame(element),
773
753
  fill: render.brokenFill,
774
754
  stroke: render.brokenStroke,
775
755
  strokeWidth: 1,
@@ -807,13 +787,7 @@ function ImageNode({ element, ...rest }) {
807
787
  KonvaImage,
808
788
  {
809
789
  ref,
810
- name: element.id,
811
- x: element.x,
812
- y: element.y,
813
- width: element.width,
814
- height: element.height,
815
- rotation: element.rotation,
816
- opacity: element.opacity,
790
+ ...canvasElementFrame(element),
817
791
  image: img,
818
792
  ...cropProps,
819
793
  ...drag
@@ -838,13 +812,7 @@ function VideoNode({ element, ...rest }) {
838
812
  Rect,
839
813
  {
840
814
  ref,
841
- name: element.id,
842
- x: element.x,
843
- y: element.y,
844
- width: element.width,
845
- height: element.height,
846
- rotation: element.rotation,
847
- opacity: element.opacity,
815
+ ...canvasElementFrame(element),
848
816
  fill: render.placeholderFill,
849
817
  stroke: render.placeholderStroke,
850
818
  strokeWidth: 1,
@@ -856,13 +824,7 @@ function VideoNode({ element, ...rest }) {
856
824
  KonvaImage,
857
825
  {
858
826
  ref,
859
- name: element.id,
860
- x: element.x,
861
- y: element.y,
862
- width: element.width,
863
- height: element.height,
864
- rotation: element.rotation,
865
- opacity: element.opacity,
827
+ ...canvasElementFrame(element),
866
828
  image: img,
867
829
  ...drag
868
830
  }
@@ -884,6 +846,9 @@ function GroupNode({ element, ...rest }) {
884
846
  }
885
847
  );
886
848
  }
849
+ function canvasElementFrame(element) {
850
+ return { name: element.id, x: element.x, y: element.y, width: element.width, height: element.height, rotation: element.rotation, opacity: element.opacity };
851
+ }
887
852
 
888
853
  // src/design-canvas-react/components/SelectionLayer.tsx
889
854
  import { useEffect as useEffect3, useRef as useRef4 } from "react";
@@ -1252,7 +1217,7 @@ var SNAP_THRESHOLD_SCREEN_PX = 8;
1252
1217
  var ZOOM_FACTOR_WHEEL = 0.998;
1253
1218
  var ZOOM_MIN = 0.05;
1254
1219
  var ZOOM_MAX = 32;
1255
- function WorkspaceView({
1220
+ function useWorkspaceViewViewState({
1256
1221
  canWrite,
1257
1222
  onApplyOperations,
1258
1223
  onSelectionChange,
@@ -1295,204 +1260,80 @@ function WorkspaceView({
1295
1260
  stack.rollback(command);
1296
1261
  }
1297
1262
  }
1298
- function handleWheel(e) {
1299
- e.preventDefault();
1300
- const rect = containerRef.current?.getBoundingClientRect();
1301
- if (!rect) return;
1302
- const screenX = e.clientX - rect.left;
1303
- const screenY = e.clientY - rect.top;
1304
- const factor = Math.pow(ZOOM_FACTOR_WHEEL, e.deltaY);
1305
- const next = zoomPanMath.zoomAtPoint({ zoom, panX, panY }, factor, screenX, screenY);
1306
- stack.setView(next);
1307
- }
1308
- function handlePointerDown(e) {
1309
- if (e.button === 1 || spaceHeldRef.current) {
1310
- e.preventDefault();
1311
- e.currentTarget.setPointerCapture(e.pointerId);
1312
- gestureRef.current = "pan";
1313
- panOriginRef.current = { screenX: e.clientX, screenY: e.clientY, panX, panY };
1314
- return;
1315
- }
1316
- if (e.button !== 0) return;
1317
- const rect = containerRef.current?.getBoundingClientRect();
1318
- if (!rect) return;
1319
- const screenX = e.clientX - rect.left;
1320
- const screenY = e.clientY - rect.top;
1321
- const docPos = zoomPanMath.screenToDocument({ zoom, panX, panY }, screenX, screenY);
1322
- if (hitTestPoint(activePage, docPos.x, docPos.y) !== null) {
1323
- return;
1324
- }
1325
- e.preventDefault();
1326
- e.currentTarget.setPointerCapture(e.pointerId);
1327
- gestureRef.current = "marquee";
1328
- const m = { active: true, startDocX: docPos.x, startDocY: docPos.y, endDocX: docPos.x, endDocY: docPos.y };
1329
- marqueeRef.current = m;
1330
- setMarquee(m);
1331
- stack.setView({ selectedElementIds: [] });
1332
- }
1333
- function handlePointerMove(e) {
1334
- const mode = gestureRef.current;
1335
- const rect = containerRef.current?.getBoundingClientRect();
1336
- if (!rect) return;
1337
- if (mode === "pan") {
1338
- const dx = e.clientX - panOriginRef.current.screenX;
1339
- const dy = e.clientY - panOriginRef.current.screenY;
1340
- stack.setView({ panX: panOriginRef.current.panX + dx, panY: panOriginRef.current.panY + dy });
1341
- return;
1342
- }
1343
- if (mode === "marquee") {
1344
- const screenX = e.clientX - rect.left;
1345
- const screenY = e.clientY - rect.top;
1346
- const docPos = zoomPanMath.screenToDocument({ zoom, panX, panY }, screenX, screenY);
1347
- const m = { ...marqueeRef.current, active: true, endDocX: docPos.x, endDocY: docPos.y };
1348
- marqueeRef.current = m;
1349
- setMarquee(m);
1350
- const normalized = normalizeMarquee(m.startDocX, m.startDocY, m.endDocX, m.endDocY);
1351
- const ids = marqueeSelect(activePage, normalized);
1352
- stack.setView({ selectedElementIds: ids });
1353
- }
1354
- }
1355
- function handlePointerUp(e) {
1356
- gestureRef.current = "idle";
1357
- setMarquee(NO_MARQUEE);
1358
- marqueeRef.current = NO_MARQUEE;
1359
- setActiveSnap(null);
1360
- e.currentTarget.releasePointerCapture(e.pointerId);
1361
- }
1362
- function snapDragBounds(snapBounds, draggingIds) {
1363
- const targets = snapEngine.collectTargets(state, draggingIds);
1364
- if (gridEnabled) {
1365
- const thresholdDoc = SNAP_THRESHOLD_SCREEN_PX / zoom;
1366
- const gt = collectGridTargets(snapBounds, gridSize, activePage, thresholdDoc);
1367
- targets.vertical.push(...gt.vertical);
1368
- targets.horizontal.push(...gt.horizontal);
1369
- }
1370
- return snapEngine.apply(snapBounds, targets, SNAP_THRESHOLD_SCREEN_PX, zoom);
1371
- }
1372
- function handleElementDragStart(elementId) {
1373
- if (!canWrite) return;
1374
- const ids = selectedElementIds.includes(elementId) ? selectedElementIds : [elementId];
1375
- const origins = /* @__PURE__ */ new Map();
1376
- for (const id of ids) {
1377
- const found = findElement(activePage, id);
1378
- if (found) {
1379
- const aabb = elementAabb(found.element);
1380
- origins.set(id, { x: found.element.x, y: found.element.y, width: aabb.width, height: aabb.height });
1381
- }
1382
- }
1383
- dragOriginRef.current = origins;
1384
- gestureRef.current = "drag";
1385
- if (!selectedElementIds.includes(elementId)) {
1386
- stack.setView({ selectedElementIds: [elementId] });
1387
- }
1388
- }
1389
- function handleElementDragMove(elementId, dx, dy) {
1390
- if (!canWrite) return;
1391
- const origin = dragOriginRef.current.get(elementId);
1392
- if (!origin) return;
1393
- const dragging = selectedElementIds.includes(elementId) ? selectedElementIds : [elementId];
1394
- const proposedX = origin.x + dx;
1395
- const proposedY = origin.y + dy;
1396
- const snapBounds = { x: proposedX, y: proposedY, width: origin.width, height: origin.height };
1397
- if (snapEnabled) {
1398
- const snapResult = snapDragBounds(snapBounds, dragging);
1399
- setActiveSnap(snapResult);
1400
- }
1401
- }
1402
- async function handleElementDragEnd(elementId, finalX, finalY) {
1403
- if (!canWrite) return;
1404
- gestureRef.current = "idle";
1405
- setActiveSnap(null);
1406
- const origin = dragOriginRef.current.get(elementId);
1407
- if (!origin) return;
1408
- const draggingIds = selectedElementIds.includes(elementId) ? selectedElementIds : [elementId];
1409
- let snappedX = finalX;
1410
- let snappedY = finalY;
1411
- if (snapEnabled) {
1412
- const snapBounds = { x: finalX, y: finalY, width: origin.width, height: origin.height };
1413
- const snapResult = snapDragBounds(snapBounds, draggingIds);
1414
- snappedX = snapResult.x;
1415
- snappedY = snapResult.y;
1416
- }
1417
- const dx = snappedX - origin.x;
1418
- const dy = snappedY - origin.y;
1419
- if (draggingIds.length === 1) {
1420
- const el = findElement(activePage, elementId)?.element;
1421
- if (!el) return;
1422
- await persist(
1423
- setAttrsCommand({
1424
- pageId: activePageId,
1425
- elementId,
1426
- attrs: { x: snappedX, y: snappedY },
1427
- priorAttrs: { x: el.x, y: el.y }
1428
- })
1429
- );
1430
- } else {
1431
- const entries = [];
1432
- for (const id of draggingIds) {
1433
- const el = findElement(activePage, id)?.element;
1434
- const orig = dragOriginRef.current.get(id);
1435
- if (!el || !orig) continue;
1436
- entries.push({
1437
- pageId: activePageId,
1438
- elementId: id,
1439
- attrs: { x: orig.x + dx, y: orig.y + dy },
1440
- priorAttrs: { x: orig.x, y: orig.y }
1441
- });
1442
- }
1443
- if (entries.length > 0) await persist(multiSetAttrsCommand(entries));
1444
- }
1445
- dragOriginRef.current = /* @__PURE__ */ new Map();
1446
- }
1447
- function handleElementClick(elementId) {
1448
- stack.setView({ selectedElementIds: [elementId] });
1449
- }
1450
- function handleElementDoubleClick(elementId) {
1451
- if (!canWrite) return;
1452
- const found = findElement(activePage, elementId);
1453
- if (!found || found.element.kind !== "text") return;
1454
- editingPreRef.current = found.element.text;
1455
- setEditingElementId(elementId);
1456
- }
1457
- async function handleTextCommit(text) {
1458
- const id = editingElementId;
1459
- setEditingElementId(null);
1460
- if (!id || !canWrite) return;
1461
- const found = findElement(activePage, id);
1462
- if (!found || found.element.kind !== "text") return;
1463
- if (text === editingPreRef.current) return;
1464
- await persist(
1465
- setAttrsCommand({
1466
- pageId: activePageId,
1467
- elementId: id,
1468
- attrs: { text },
1469
- priorAttrs: { text: editingPreRef.current }
1470
- })
1471
- );
1472
- }
1473
- function handleTextCancel() {
1474
- setEditingElementId(null);
1475
- }
1476
- async function handleTransformEnd(entries) {
1477
- if (!canWrite || entries.length === 0) return;
1478
- await persist(multiSetAttrsCommand(entries));
1479
- }
1480
- async function handleStartTemplate() {
1481
- if (!canWrite) return;
1482
- const template = DEFAULT_INSERT_TEMPLATES[0];
1483
- if (!template) return;
1484
- const ops = template.build({
1485
- pageId: activePageId,
1486
- width: activePage.width,
1487
- height: activePage.height,
1488
- background: activePage.background
1489
- });
1490
- const addedIds = [];
1491
- for (const op of ops) {
1492
- if (op.type === "add_element") {
1493
- await persist(addElementCommand({ pageId: op.pageId, element: op.element }));
1494
- addedIds.push(op.element.id);
1495
- }
1263
+ const {
1264
+ handleWheel,
1265
+ handlePointerDown,
1266
+ handlePointerMove,
1267
+ handlePointerUp
1268
+ } = createWorkspacePointerHandlers({
1269
+ containerRef,
1270
+ zoomPanMath,
1271
+ zoom,
1272
+ panX,
1273
+ panY,
1274
+ stack,
1275
+ spaceHeldRef,
1276
+ gestureRef,
1277
+ panOriginRef,
1278
+ activePage,
1279
+ marqueeRef,
1280
+ setMarquee,
1281
+ setActiveSnap
1282
+ });
1283
+ const {
1284
+ snapDragBounds,
1285
+ handleElementDragStart,
1286
+ handleElementDragMove,
1287
+ handleElementDragEnd
1288
+ } = createWorkspaceDragHandlers({
1289
+ snapEngine,
1290
+ state,
1291
+ gridEnabled,
1292
+ zoom,
1293
+ gridSize,
1294
+ activePage,
1295
+ canWrite,
1296
+ selectedElementIds,
1297
+ dragOriginRef,
1298
+ gestureRef,
1299
+ stack,
1300
+ snapEnabled,
1301
+ setActiveSnap,
1302
+ persist,
1303
+ activePageId
1304
+ });
1305
+ const {
1306
+ handleElementClick,
1307
+ handleElementDoubleClick,
1308
+ handleTextCommit,
1309
+ handleTextCancel,
1310
+ handleTransformEnd
1311
+ } = createWorkspaceElementHandlers({
1312
+ stack,
1313
+ canWrite,
1314
+ activePage,
1315
+ editingPreRef,
1316
+ setEditingElementId,
1317
+ editingElementId,
1318
+ persist,
1319
+ activePageId
1320
+ });
1321
+ async function handleStartTemplate() {
1322
+ if (!canWrite) return;
1323
+ const template = DEFAULT_INSERT_TEMPLATES[0];
1324
+ if (!template) return;
1325
+ const ops = template.build({
1326
+ pageId: activePageId,
1327
+ width: activePage.width,
1328
+ height: activePage.height,
1329
+ background: activePage.background
1330
+ });
1331
+ const addedIds = [];
1332
+ for (const op of ops) {
1333
+ if (op.type === "add_element") {
1334
+ await persist(addElementCommand({ pageId: op.pageId, element: op.element }));
1335
+ addedIds.push(op.element.id);
1336
+ }
1496
1337
  }
1497
1338
  if (addedIds.length > 0) stack.setView({ selectedElementIds: addedIds });
1498
1339
  }
@@ -1574,6 +1415,107 @@ function WorkspaceView({
1574
1415
  (el) => pinned.has(el.id) || boundsIntersect(elementAabb(el), pageRect)
1575
1416
  );
1576
1417
  }, [activePage.elements, activePage.width, activePage.height, selectedElementIds, editingElementId]);
1418
+ return {
1419
+ className,
1420
+ containerRef,
1421
+ handleWheel,
1422
+ handlePointerDown,
1423
+ handlePointerMove,
1424
+ handlePointerUp,
1425
+ handleKeyDown,
1426
+ handleKeyUp,
1427
+ spaceHeldRef,
1428
+ stageRef,
1429
+ containerSize,
1430
+ dpr,
1431
+ gridEnabled,
1432
+ activePage,
1433
+ gridSize,
1434
+ zoom,
1435
+ panX,
1436
+ panY,
1437
+ render,
1438
+ visibleElements,
1439
+ selectedElementIds,
1440
+ onElementClick,
1441
+ onElementDragStart,
1442
+ onElementDragMove,
1443
+ onElementDragEnd,
1444
+ onElementDoubleClick,
1445
+ activeVerticalGuide,
1446
+ activeHorizontalGuide,
1447
+ selectedElements,
1448
+ canWrite,
1449
+ handleTransformEnd,
1450
+ activePageId,
1451
+ showBleed,
1452
+ pageScreenX,
1453
+ pageScreenY,
1454
+ pageScreenW,
1455
+ pageScreenH,
1456
+ normalizedMarquee,
1457
+ editingTextElement,
1458
+ handleTextCommit,
1459
+ handleTextCancel,
1460
+ showEmptyState,
1461
+ editingElementId,
1462
+ handleStartTemplate,
1463
+ handleAddElement,
1464
+ onAskAgent
1465
+ };
1466
+ }
1467
+ function WorkspaceView(props) {
1468
+ const view = useWorkspaceViewViewState(props);
1469
+ return /* @__PURE__ */ jsx7(WorkspaceViewView, { ...view });
1470
+ }
1471
+ function WorkspaceViewView({
1472
+ className,
1473
+ containerRef,
1474
+ handleWheel,
1475
+ handlePointerDown,
1476
+ handlePointerMove,
1477
+ handlePointerUp,
1478
+ handleKeyDown,
1479
+ handleKeyUp,
1480
+ spaceHeldRef,
1481
+ stageRef,
1482
+ containerSize,
1483
+ dpr,
1484
+ gridEnabled,
1485
+ activePage,
1486
+ gridSize,
1487
+ zoom,
1488
+ panX,
1489
+ panY,
1490
+ render,
1491
+ visibleElements,
1492
+ selectedElementIds,
1493
+ onElementClick,
1494
+ onElementDragStart,
1495
+ onElementDragMove,
1496
+ onElementDragEnd,
1497
+ onElementDoubleClick,
1498
+ activeVerticalGuide,
1499
+ activeHorizontalGuide,
1500
+ selectedElements,
1501
+ canWrite,
1502
+ handleTransformEnd,
1503
+ activePageId,
1504
+ showBleed,
1505
+ pageScreenX,
1506
+ pageScreenY,
1507
+ pageScreenW,
1508
+ pageScreenH,
1509
+ normalizedMarquee,
1510
+ editingTextElement,
1511
+ handleTextCommit,
1512
+ handleTextCancel,
1513
+ showEmptyState,
1514
+ editingElementId,
1515
+ handleStartTemplate,
1516
+ handleAddElement,
1517
+ onAskAgent
1518
+ }) {
1577
1519
  return /* @__PURE__ */ jsxs3(
1578
1520
  "div",
1579
1521
  {
@@ -1768,6 +1710,236 @@ function Workspace(props) {
1768
1710
  }
1769
1711
  );
1770
1712
  }
1713
+ function createWorkspacePointerHandlers({
1714
+ containerRef,
1715
+ zoomPanMath,
1716
+ zoom,
1717
+ panX,
1718
+ panY,
1719
+ stack,
1720
+ spaceHeldRef,
1721
+ gestureRef,
1722
+ panOriginRef,
1723
+ activePage,
1724
+ marqueeRef,
1725
+ setMarquee,
1726
+ setActiveSnap
1727
+ }) {
1728
+ function handleWheel(e) {
1729
+ e.preventDefault();
1730
+ const rect = containerRef.current?.getBoundingClientRect();
1731
+ if (!rect) return;
1732
+ const screenX = e.clientX - rect.left;
1733
+ const screenY = e.clientY - rect.top;
1734
+ const factor = Math.pow(ZOOM_FACTOR_WHEEL, e.deltaY);
1735
+ const next = zoomPanMath.zoomAtPoint({ zoom, panX, panY }, factor, screenX, screenY);
1736
+ stack.setView(next);
1737
+ }
1738
+ function handlePointerDown(e) {
1739
+ if (e.button === 1 || spaceHeldRef.current) {
1740
+ e.preventDefault();
1741
+ e.currentTarget.setPointerCapture(e.pointerId);
1742
+ gestureRef.current = "pan";
1743
+ panOriginRef.current = { screenX: e.clientX, screenY: e.clientY, panX, panY };
1744
+ return;
1745
+ }
1746
+ if (e.button !== 0) return;
1747
+ const rect = containerRef.current?.getBoundingClientRect();
1748
+ if (!rect) return;
1749
+ const screenX = e.clientX - rect.left;
1750
+ const screenY = e.clientY - rect.top;
1751
+ const docPos = zoomPanMath.screenToDocument({ zoom, panX, panY }, screenX, screenY);
1752
+ if (hitTestPoint(activePage, docPos.x, docPos.y) !== null) {
1753
+ return;
1754
+ }
1755
+ e.preventDefault();
1756
+ e.currentTarget.setPointerCapture(e.pointerId);
1757
+ gestureRef.current = "marquee";
1758
+ const m = { active: true, startDocX: docPos.x, startDocY: docPos.y, endDocX: docPos.x, endDocY: docPos.y };
1759
+ marqueeRef.current = m;
1760
+ setMarquee(m);
1761
+ stack.setView({ selectedElementIds: [] });
1762
+ }
1763
+ function handlePointerMove(e) {
1764
+ const mode = gestureRef.current;
1765
+ const rect = containerRef.current?.getBoundingClientRect();
1766
+ if (!rect) return;
1767
+ if (mode === "pan") {
1768
+ const dx = e.clientX - panOriginRef.current.screenX;
1769
+ const dy = e.clientY - panOriginRef.current.screenY;
1770
+ stack.setView({ panX: panOriginRef.current.panX + dx, panY: panOriginRef.current.panY + dy });
1771
+ return;
1772
+ }
1773
+ if (mode === "marquee") {
1774
+ const screenX = e.clientX - rect.left;
1775
+ const screenY = e.clientY - rect.top;
1776
+ const docPos = zoomPanMath.screenToDocument({ zoom, panX, panY }, screenX, screenY);
1777
+ const m = { ...marqueeRef.current, active: true, endDocX: docPos.x, endDocY: docPos.y };
1778
+ marqueeRef.current = m;
1779
+ setMarquee(m);
1780
+ const normalized = normalizeMarquee(m.startDocX, m.startDocY, m.endDocX, m.endDocY);
1781
+ const ids = marqueeSelect(activePage, normalized);
1782
+ stack.setView({ selectedElementIds: ids });
1783
+ }
1784
+ }
1785
+ function handlePointerUp(e) {
1786
+ gestureRef.current = "idle";
1787
+ setMarquee(NO_MARQUEE);
1788
+ marqueeRef.current = NO_MARQUEE;
1789
+ setActiveSnap(null);
1790
+ e.currentTarget.releasePointerCapture(e.pointerId);
1791
+ }
1792
+ return { handleWheel, handlePointerDown, handlePointerMove, handlePointerUp };
1793
+ }
1794
+ function createWorkspaceDragHandlers({
1795
+ snapEngine,
1796
+ state,
1797
+ gridEnabled,
1798
+ zoom,
1799
+ gridSize,
1800
+ activePage,
1801
+ canWrite,
1802
+ selectedElementIds,
1803
+ dragOriginRef,
1804
+ gestureRef,
1805
+ stack,
1806
+ snapEnabled,
1807
+ setActiveSnap,
1808
+ persist,
1809
+ activePageId
1810
+ }) {
1811
+ function snapDragBounds(snapBounds, draggingIds) {
1812
+ const targets = snapEngine.collectTargets(state, draggingIds);
1813
+ if (gridEnabled) {
1814
+ const thresholdDoc = SNAP_THRESHOLD_SCREEN_PX / zoom;
1815
+ const gt = collectGridTargets(snapBounds, gridSize, activePage, thresholdDoc);
1816
+ targets.vertical.push(...gt.vertical);
1817
+ targets.horizontal.push(...gt.horizontal);
1818
+ }
1819
+ return snapEngine.apply(snapBounds, targets, SNAP_THRESHOLD_SCREEN_PX, zoom);
1820
+ }
1821
+ function handleElementDragStart(elementId) {
1822
+ if (!canWrite) return;
1823
+ const ids = selectedElementIds.includes(elementId) ? selectedElementIds : [elementId];
1824
+ const origins = /* @__PURE__ */ new Map();
1825
+ for (const id of ids) {
1826
+ const found = findElement(activePage, id);
1827
+ if (found) {
1828
+ const aabb = elementAabb(found.element);
1829
+ origins.set(id, { x: found.element.x, y: found.element.y, width: aabb.width, height: aabb.height });
1830
+ }
1831
+ }
1832
+ dragOriginRef.current = origins;
1833
+ gestureRef.current = "drag";
1834
+ if (!selectedElementIds.includes(elementId)) {
1835
+ stack.setView({ selectedElementIds: [elementId] });
1836
+ }
1837
+ }
1838
+ function handleElementDragMove(elementId, dx, dy) {
1839
+ if (!canWrite) return;
1840
+ const origin = dragOriginRef.current.get(elementId);
1841
+ if (!origin) return;
1842
+ const dragging = selectedElementIds.includes(elementId) ? selectedElementIds : [elementId];
1843
+ const proposedX = origin.x + dx;
1844
+ const proposedY = origin.y + dy;
1845
+ const snapBounds = { x: proposedX, y: proposedY, width: origin.width, height: origin.height };
1846
+ if (snapEnabled) {
1847
+ const snapResult = snapDragBounds(snapBounds, dragging);
1848
+ setActiveSnap(snapResult);
1849
+ }
1850
+ }
1851
+ async function handleElementDragEnd(elementId, finalX, finalY) {
1852
+ if (!canWrite) return;
1853
+ gestureRef.current = "idle";
1854
+ setActiveSnap(null);
1855
+ const origin = dragOriginRef.current.get(elementId);
1856
+ if (!origin) return;
1857
+ const draggingIds = selectedElementIds.includes(elementId) ? selectedElementIds : [elementId];
1858
+ let snappedX = finalX;
1859
+ let snappedY = finalY;
1860
+ if (snapEnabled) {
1861
+ const snapBounds = { x: finalX, y: finalY, width: origin.width, height: origin.height };
1862
+ const snapResult = snapDragBounds(snapBounds, draggingIds);
1863
+ snappedX = snapResult.x;
1864
+ snappedY = snapResult.y;
1865
+ }
1866
+ const dx = snappedX - origin.x;
1867
+ const dy = snappedY - origin.y;
1868
+ if (draggingIds.length === 1) {
1869
+ const el = findElement(activePage, elementId)?.element;
1870
+ if (!el) return;
1871
+ await persist(
1872
+ setAttrsCommand({
1873
+ pageId: activePageId,
1874
+ elementId,
1875
+ attrs: { x: snappedX, y: snappedY },
1876
+ priorAttrs: { x: el.x, y: el.y }
1877
+ })
1878
+ );
1879
+ } else {
1880
+ const entries = [];
1881
+ for (const id of draggingIds) {
1882
+ const el = findElement(activePage, id)?.element;
1883
+ const orig = dragOriginRef.current.get(id);
1884
+ if (!el || !orig) continue;
1885
+ entries.push({
1886
+ pageId: activePageId,
1887
+ elementId: id,
1888
+ attrs: { x: orig.x + dx, y: orig.y + dy },
1889
+ priorAttrs: { x: orig.x, y: orig.y }
1890
+ });
1891
+ }
1892
+ if (entries.length > 0) await persist(multiSetAttrsCommand(entries));
1893
+ }
1894
+ dragOriginRef.current = /* @__PURE__ */ new Map();
1895
+ }
1896
+ return { snapDragBounds, handleElementDragStart, handleElementDragMove, handleElementDragEnd };
1897
+ }
1898
+ function createWorkspaceElementHandlers({
1899
+ stack,
1900
+ canWrite,
1901
+ activePage,
1902
+ editingPreRef,
1903
+ setEditingElementId,
1904
+ editingElementId,
1905
+ persist,
1906
+ activePageId
1907
+ }) {
1908
+ function handleElementClick(elementId) {
1909
+ stack.setView({ selectedElementIds: [elementId] });
1910
+ }
1911
+ function handleElementDoubleClick(elementId) {
1912
+ if (!canWrite) return;
1913
+ const found = findElement(activePage, elementId);
1914
+ if (!found || found.element.kind !== "text") return;
1915
+ editingPreRef.current = found.element.text;
1916
+ setEditingElementId(elementId);
1917
+ }
1918
+ async function handleTextCommit(text) {
1919
+ const id = editingElementId;
1920
+ setEditingElementId(null);
1921
+ if (!id || !canWrite) return;
1922
+ const found = findElement(activePage, id);
1923
+ if (!found || found.element.kind !== "text") return;
1924
+ if (text === editingPreRef.current) return;
1925
+ await persist(
1926
+ setAttrsCommand({
1927
+ pageId: activePageId,
1928
+ elementId: id,
1929
+ attrs: { text },
1930
+ priorAttrs: { text: editingPreRef.current }
1931
+ })
1932
+ );
1933
+ }
1934
+ function handleTextCancel() {
1935
+ setEditingElementId(null);
1936
+ }
1937
+ async function handleTransformEnd(entries) {
1938
+ if (!canWrite || entries.length === 0) return;
1939
+ await persist(multiSetAttrsCommand(entries));
1940
+ }
1941
+ return { handleElementClick, handleElementDoubleClick, handleTextCommit, handleTextCancel, handleTransformEnd };
1942
+ }
1771
1943
 
1772
1944
  // src/design-canvas-react/components/DesignCanvasEditor.tsx
1773
1945
  import { jsx as jsx8 } from "react/jsx-runtime";
@@ -1951,4 +2123,4 @@ export {
1951
2123
  Workspace,
1952
2124
  DesignCanvasEditor
1953
2125
  };
1954
- //# sourceMappingURL=chunk-KJODHPWM.js.map
2126
+ //# sourceMappingURL=chunk-CPVGRQ43.js.map