@theokit/ui 0.13.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 (715) hide show
  1. package/CHANGELOG.md +1325 -0
  2. package/DESIGN.md +456 -0
  3. package/LICENSE +201 -0
  4. package/NOTICE +38 -0
  5. package/README.md +467 -0
  6. package/dist/chunk-27ENTTY7.js +146 -0
  7. package/dist/chunk-27ENTTY7.js.map +1 -0
  8. package/dist/chunk-2H6TQELG.js +33 -0
  9. package/dist/chunk-2H6TQELG.js.map +1 -0
  10. package/dist/chunk-2L6MRJD4.js +120 -0
  11. package/dist/chunk-2L6MRJD4.js.map +1 -0
  12. package/dist/chunk-2Y5V2PAL.js +80 -0
  13. package/dist/chunk-2Y5V2PAL.js.map +1 -0
  14. package/dist/chunk-34NAFDVL.js +46 -0
  15. package/dist/chunk-34NAFDVL.js.map +1 -0
  16. package/dist/chunk-36KJGXEK.js +112 -0
  17. package/dist/chunk-36KJGXEK.js.map +1 -0
  18. package/dist/chunk-3BMYYNN6.js +124 -0
  19. package/dist/chunk-3BMYYNN6.js.map +1 -0
  20. package/dist/chunk-3OHV7EEI.js +34 -0
  21. package/dist/chunk-3OHV7EEI.js.map +1 -0
  22. package/dist/chunk-3QKTS6F5.js +88 -0
  23. package/dist/chunk-3QKTS6F5.js.map +1 -0
  24. package/dist/chunk-3TBXLYNM.js +42 -0
  25. package/dist/chunk-3TBXLYNM.js.map +1 -0
  26. package/dist/chunk-4AM2HSXU.js +67 -0
  27. package/dist/chunk-4AM2HSXU.js.map +1 -0
  28. package/dist/chunk-4BCGKM65.js +44 -0
  29. package/dist/chunk-4BCGKM65.js.map +1 -0
  30. package/dist/chunk-4D3JILQX.js +145 -0
  31. package/dist/chunk-4D3JILQX.js.map +1 -0
  32. package/dist/chunk-4EJU2GBG.js +48 -0
  33. package/dist/chunk-4EJU2GBG.js.map +1 -0
  34. package/dist/chunk-4WKO3G5C.js +110 -0
  35. package/dist/chunk-4WKO3G5C.js.map +1 -0
  36. package/dist/chunk-53XPKI7Q.js +97 -0
  37. package/dist/chunk-53XPKI7Q.js.map +1 -0
  38. package/dist/chunk-55TDVDPG.js +58 -0
  39. package/dist/chunk-55TDVDPG.js.map +1 -0
  40. package/dist/chunk-56BJLFW7.js +26 -0
  41. package/dist/chunk-56BJLFW7.js.map +1 -0
  42. package/dist/chunk-5HOQLE6Y.js +35 -0
  43. package/dist/chunk-5HOQLE6Y.js.map +1 -0
  44. package/dist/chunk-5TY3NYF5.js +144 -0
  45. package/dist/chunk-5TY3NYF5.js.map +1 -0
  46. package/dist/chunk-5VOSCJKQ.js +92 -0
  47. package/dist/chunk-5VOSCJKQ.js.map +1 -0
  48. package/dist/chunk-65NVO6TK.js +171 -0
  49. package/dist/chunk-65NVO6TK.js.map +1 -0
  50. package/dist/chunk-6A5TPCKP.js +64 -0
  51. package/dist/chunk-6A5TPCKP.js.map +1 -0
  52. package/dist/chunk-6CO4LEXZ.js +41 -0
  53. package/dist/chunk-6CO4LEXZ.js.map +1 -0
  54. package/dist/chunk-6FVUPNPG.js +56 -0
  55. package/dist/chunk-6FVUPNPG.js.map +1 -0
  56. package/dist/chunk-76YWTIWK.js +106 -0
  57. package/dist/chunk-76YWTIWK.js.map +1 -0
  58. package/dist/chunk-7EI7424P.js +78 -0
  59. package/dist/chunk-7EI7424P.js.map +1 -0
  60. package/dist/chunk-AHTVYOPQ.js +26 -0
  61. package/dist/chunk-AHTVYOPQ.js.map +1 -0
  62. package/dist/chunk-AJTJNHKK.js +85 -0
  63. package/dist/chunk-AJTJNHKK.js.map +1 -0
  64. package/dist/chunk-AMT3CPMC.js +155 -0
  65. package/dist/chunk-AMT3CPMC.js.map +1 -0
  66. package/dist/chunk-AX5EH73R.js +59 -0
  67. package/dist/chunk-AX5EH73R.js.map +1 -0
  68. package/dist/chunk-B3VAJSZ2.js +35 -0
  69. package/dist/chunk-B3VAJSZ2.js.map +1 -0
  70. package/dist/chunk-B4CQMQ64.js +25 -0
  71. package/dist/chunk-B4CQMQ64.js.map +1 -0
  72. package/dist/chunk-BMRZXT5T.js +115 -0
  73. package/dist/chunk-BMRZXT5T.js.map +1 -0
  74. package/dist/chunk-BYZ6OFH4.js +73 -0
  75. package/dist/chunk-BYZ6OFH4.js.map +1 -0
  76. package/dist/chunk-C55VUQ7N.js +156 -0
  77. package/dist/chunk-C55VUQ7N.js.map +1 -0
  78. package/dist/chunk-D4GEAV4C.js +91 -0
  79. package/dist/chunk-D4GEAV4C.js.map +1 -0
  80. package/dist/chunk-DC43CHAM.js +152 -0
  81. package/dist/chunk-DC43CHAM.js.map +1 -0
  82. package/dist/chunk-DKCRLN35.js +92 -0
  83. package/dist/chunk-DKCRLN35.js.map +1 -0
  84. package/dist/chunk-DN5BUDBI.js +86 -0
  85. package/dist/chunk-DN5BUDBI.js.map +1 -0
  86. package/dist/chunk-DOLKDYMS.js +88 -0
  87. package/dist/chunk-DOLKDYMS.js.map +1 -0
  88. package/dist/chunk-DW34WXCG.js +28 -0
  89. package/dist/chunk-DW34WXCG.js.map +1 -0
  90. package/dist/chunk-DZAAKHGZ.js +135 -0
  91. package/dist/chunk-DZAAKHGZ.js.map +1 -0
  92. package/dist/chunk-E4IRSSHO.js +116 -0
  93. package/dist/chunk-E4IRSSHO.js.map +1 -0
  94. package/dist/chunk-E67WQXBV.js +104 -0
  95. package/dist/chunk-E67WQXBV.js.map +1 -0
  96. package/dist/chunk-EG6IHP3H.js +128 -0
  97. package/dist/chunk-EG6IHP3H.js.map +1 -0
  98. package/dist/chunk-EO7LOXG2.js +82 -0
  99. package/dist/chunk-EO7LOXG2.js.map +1 -0
  100. package/dist/chunk-EWDN56AS.js +24 -0
  101. package/dist/chunk-EWDN56AS.js.map +1 -0
  102. package/dist/chunk-F5P5P2SC.js +141 -0
  103. package/dist/chunk-F5P5P2SC.js.map +1 -0
  104. package/dist/chunk-FAWPRZTM.js +79 -0
  105. package/dist/chunk-FAWPRZTM.js.map +1 -0
  106. package/dist/chunk-FGYJ2WPX.js +36 -0
  107. package/dist/chunk-FGYJ2WPX.js.map +1 -0
  108. package/dist/chunk-GBG3I5I5.js +46 -0
  109. package/dist/chunk-GBG3I5I5.js.map +1 -0
  110. package/dist/chunk-GDMCDW66.js +19 -0
  111. package/dist/chunk-GDMCDW66.js.map +1 -0
  112. package/dist/chunk-H6HSQCOW.js +80 -0
  113. package/dist/chunk-H6HSQCOW.js.map +1 -0
  114. package/dist/chunk-HDM4RCIF.js +111 -0
  115. package/dist/chunk-HDM4RCIF.js.map +1 -0
  116. package/dist/chunk-HNTOGGVD.js +77 -0
  117. package/dist/chunk-HNTOGGVD.js.map +1 -0
  118. package/dist/chunk-HQW2ABO4.js +28 -0
  119. package/dist/chunk-HQW2ABO4.js.map +1 -0
  120. package/dist/chunk-HRDRGZ2Y.js +76 -0
  121. package/dist/chunk-HRDRGZ2Y.js.map +1 -0
  122. package/dist/chunk-HUOVA7SF.js +83 -0
  123. package/dist/chunk-HUOVA7SF.js.map +1 -0
  124. package/dist/chunk-ITA3SNOR.js +133 -0
  125. package/dist/chunk-ITA3SNOR.js.map +1 -0
  126. package/dist/chunk-IYNUPG2G.js +61 -0
  127. package/dist/chunk-IYNUPG2G.js.map +1 -0
  128. package/dist/chunk-JJ65ZI4P.js +199 -0
  129. package/dist/chunk-JJ65ZI4P.js.map +1 -0
  130. package/dist/chunk-JRBGZ6NI.js +106 -0
  131. package/dist/chunk-JRBGZ6NI.js.map +1 -0
  132. package/dist/chunk-K45OO62F.js +108 -0
  133. package/dist/chunk-K45OO62F.js.map +1 -0
  134. package/dist/chunk-KDTKA667.js +67 -0
  135. package/dist/chunk-KDTKA667.js.map +1 -0
  136. package/dist/chunk-KI7KZBSN.js +142 -0
  137. package/dist/chunk-KI7KZBSN.js.map +1 -0
  138. package/dist/chunk-KOJ7XOPZ.js +87 -0
  139. package/dist/chunk-KOJ7XOPZ.js.map +1 -0
  140. package/dist/chunk-KQTHJ22B.js +82 -0
  141. package/dist/chunk-KQTHJ22B.js.map +1 -0
  142. package/dist/chunk-KRC43RZR.js +77 -0
  143. package/dist/chunk-KRC43RZR.js.map +1 -0
  144. package/dist/chunk-LJQOEGQ2.js +116 -0
  145. package/dist/chunk-LJQOEGQ2.js.map +1 -0
  146. package/dist/chunk-LKRNUSKZ.js +149 -0
  147. package/dist/chunk-LKRNUSKZ.js.map +1 -0
  148. package/dist/chunk-LLL7QQ52.js +76 -0
  149. package/dist/chunk-LLL7QQ52.js.map +1 -0
  150. package/dist/chunk-LQ4B5X4Y.js +56 -0
  151. package/dist/chunk-LQ4B5X4Y.js.map +1 -0
  152. package/dist/chunk-M3FSLEHQ.js +76 -0
  153. package/dist/chunk-M3FSLEHQ.js.map +1 -0
  154. package/dist/chunk-M5G3O6H6.js +57 -0
  155. package/dist/chunk-M5G3O6H6.js.map +1 -0
  156. package/dist/chunk-M6JIC5PU.js +81 -0
  157. package/dist/chunk-M6JIC5PU.js.map +1 -0
  158. package/dist/chunk-N2HJ3SLS.js +186 -0
  159. package/dist/chunk-N2HJ3SLS.js.map +1 -0
  160. package/dist/chunk-NGZWBFTP.js +45 -0
  161. package/dist/chunk-NGZWBFTP.js.map +1 -0
  162. package/dist/chunk-OAKCXT35.js +34 -0
  163. package/dist/chunk-OAKCXT35.js.map +1 -0
  164. package/dist/chunk-OSD3U3HT.js +54 -0
  165. package/dist/chunk-OSD3U3HT.js.map +1 -0
  166. package/dist/chunk-OUXESQ2R.js +42 -0
  167. package/dist/chunk-OUXESQ2R.js.map +1 -0
  168. package/dist/chunk-OY2LJHMJ.js +43 -0
  169. package/dist/chunk-OY2LJHMJ.js.map +1 -0
  170. package/dist/chunk-OYEZR4CN.js +221 -0
  171. package/dist/chunk-OYEZR4CN.js.map +1 -0
  172. package/dist/chunk-P57HUMAE.js +66 -0
  173. package/dist/chunk-P57HUMAE.js.map +1 -0
  174. package/dist/chunk-P6Y2PI6L.js +82 -0
  175. package/dist/chunk-P6Y2PI6L.js.map +1 -0
  176. package/dist/chunk-PA7TDXUQ.js +51 -0
  177. package/dist/chunk-PA7TDXUQ.js.map +1 -0
  178. package/dist/chunk-PPBGGNPV.js +112 -0
  179. package/dist/chunk-PPBGGNPV.js.map +1 -0
  180. package/dist/chunk-PRH4HKND.js +48 -0
  181. package/dist/chunk-PRH4HKND.js.map +1 -0
  182. package/dist/chunk-PSPAZJUQ.js +32 -0
  183. package/dist/chunk-PSPAZJUQ.js.map +1 -0
  184. package/dist/chunk-Q5G5CGZ2.js +170 -0
  185. package/dist/chunk-Q5G5CGZ2.js.map +1 -0
  186. package/dist/chunk-QDAF3LP7.js +89 -0
  187. package/dist/chunk-QDAF3LP7.js.map +1 -0
  188. package/dist/chunk-QGVIGNJ3.js +37 -0
  189. package/dist/chunk-QGVIGNJ3.js.map +1 -0
  190. package/dist/chunk-QNUITYSY.js +68 -0
  191. package/dist/chunk-QNUITYSY.js.map +1 -0
  192. package/dist/chunk-QSWVN3RT.js +116 -0
  193. package/dist/chunk-QSWVN3RT.js.map +1 -0
  194. package/dist/chunk-QTLQZ7OJ.js +110 -0
  195. package/dist/chunk-QTLQZ7OJ.js.map +1 -0
  196. package/dist/chunk-QYAMLIG2.js +84 -0
  197. package/dist/chunk-QYAMLIG2.js.map +1 -0
  198. package/dist/chunk-REILH4XF.js +128 -0
  199. package/dist/chunk-REILH4XF.js.map +1 -0
  200. package/dist/chunk-S6SSK6QX.js +80 -0
  201. package/dist/chunk-S6SSK6QX.js.map +1 -0
  202. package/dist/chunk-SA7ED3PN.js +68 -0
  203. package/dist/chunk-SA7ED3PN.js.map +1 -0
  204. package/dist/chunk-SIJOEM4N.js +55 -0
  205. package/dist/chunk-SIJOEM4N.js.map +1 -0
  206. package/dist/chunk-SLOKAAH2.js +70 -0
  207. package/dist/chunk-SLOKAAH2.js.map +1 -0
  208. package/dist/chunk-TR6NPSMX.js +85 -0
  209. package/dist/chunk-TR6NPSMX.js.map +1 -0
  210. package/dist/chunk-TSZ5DEAT.js +106 -0
  211. package/dist/chunk-TSZ5DEAT.js.map +1 -0
  212. package/dist/chunk-TUNVF45W.js +127 -0
  213. package/dist/chunk-TUNVF45W.js.map +1 -0
  214. package/dist/chunk-TXOBNSQ5.js +63 -0
  215. package/dist/chunk-TXOBNSQ5.js.map +1 -0
  216. package/dist/chunk-U44DRLMM.js +88 -0
  217. package/dist/chunk-U44DRLMM.js.map +1 -0
  218. package/dist/chunk-U4THNRV5.js +114 -0
  219. package/dist/chunk-U4THNRV5.js.map +1 -0
  220. package/dist/chunk-UAZOFC4W.js +72 -0
  221. package/dist/chunk-UAZOFC4W.js.map +1 -0
  222. package/dist/chunk-UGKI466V.js +12 -0
  223. package/dist/chunk-UGKI466V.js.map +1 -0
  224. package/dist/chunk-VM4RMQQN.js +11 -0
  225. package/dist/chunk-VM4RMQQN.js.map +1 -0
  226. package/dist/chunk-VQ37VLAS.js +54 -0
  227. package/dist/chunk-VQ37VLAS.js.map +1 -0
  228. package/dist/chunk-VT7VSYH5.js +73 -0
  229. package/dist/chunk-VT7VSYH5.js.map +1 -0
  230. package/dist/chunk-VTIRUCLZ.js +57 -0
  231. package/dist/chunk-VTIRUCLZ.js.map +1 -0
  232. package/dist/chunk-VVBAEYKI.js +202 -0
  233. package/dist/chunk-VVBAEYKI.js.map +1 -0
  234. package/dist/chunk-WHFIQUCC.js +120 -0
  235. package/dist/chunk-WHFIQUCC.js.map +1 -0
  236. package/dist/chunk-WPSESV5Z.js +74 -0
  237. package/dist/chunk-WPSESV5Z.js.map +1 -0
  238. package/dist/chunk-WXEXCHEN.js +51 -0
  239. package/dist/chunk-WXEXCHEN.js.map +1 -0
  240. package/dist/chunk-X2DDPD3D.js +113 -0
  241. package/dist/chunk-X2DDPD3D.js.map +1 -0
  242. package/dist/chunk-X7VIMKLD.js +127 -0
  243. package/dist/chunk-X7VIMKLD.js.map +1 -0
  244. package/dist/chunk-XJ3EG6XY.js +30 -0
  245. package/dist/chunk-XJ3EG6XY.js.map +1 -0
  246. package/dist/chunk-XOT5HWSF.js +23 -0
  247. package/dist/chunk-XOT5HWSF.js.map +1 -0
  248. package/dist/chunk-Y72IP43U.js +117 -0
  249. package/dist/chunk-Y72IP43U.js.map +1 -0
  250. package/dist/chunk-YD6FLXBV.js +61 -0
  251. package/dist/chunk-YD6FLXBV.js.map +1 -0
  252. package/dist/chunk-YEQQGYYO.js +1022 -0
  253. package/dist/chunk-YEQQGYYO.js.map +1 -0
  254. package/dist/chunk-YYW6AEIT.js +46 -0
  255. package/dist/chunk-YYW6AEIT.js.map +1 -0
  256. package/dist/chunk-ZEVGXKRU.js +104 -0
  257. package/dist/chunk-ZEVGXKRU.js.map +1 -0
  258. package/dist/chunk-ZKSMMLDP.js +74 -0
  259. package/dist/chunk-ZKSMMLDP.js.map +1 -0
  260. package/dist/chunk-ZU6IM6PK.js +101 -0
  261. package/dist/chunk-ZU6IM6PK.js.map +1 -0
  262. package/dist/chunk-ZUS5KZGO.js +714 -0
  263. package/dist/chunk-ZUS5KZGO.js.map +1 -0
  264. package/dist/chunk-ZVS2GOT2.js +58 -0
  265. package/dist/chunk-ZVS2GOT2.js.map +1 -0
  266. package/dist/chunk-ZXPDS6DH.js +3 -0
  267. package/dist/chunk-ZXPDS6DH.js.map +1 -0
  268. package/dist/chunk-ZZQQJX5Z.js +173 -0
  269. package/dist/chunk-ZZQQJX5Z.js.map +1 -0
  270. package/dist/components.css +2 -0
  271. package/dist/composites/account-menu/index.js +6 -0
  272. package/dist/composites/account-menu/index.js.map +1 -0
  273. package/dist/composites/agent-composer/index.js +7 -0
  274. package/dist/composites/agent-composer/index.js.map +1 -0
  275. package/dist/composites/agent-editor/index.js +10 -0
  276. package/dist/composites/agent-editor/index.js.map +1 -0
  277. package/dist/composites/agent-stream/index.js +12 -0
  278. package/dist/composites/agent-stream/index.js.map +1 -0
  279. package/dist/composites/agent-timeline/index.js +5 -0
  280. package/dist/composites/agent-timeline/index.js.map +1 -0
  281. package/dist/composites/approval-card/index.js +5 -0
  282. package/dist/composites/approval-card/index.js.map +1 -0
  283. package/dist/composites/chat-composer/index.js +6 -0
  284. package/dist/composites/chat-composer/index.js.map +1 -0
  285. package/dist/composites/chat-message/index.js +6 -0
  286. package/dist/composites/chat-message/index.js.map +1 -0
  287. package/dist/composites/code-block/index.js +5 -0
  288. package/dist/composites/code-block/index.js.map +1 -0
  289. package/dist/composites/command-palette/index.js +5 -0
  290. package/dist/composites/command-palette/index.js.map +1 -0
  291. package/dist/composites/confirm-dialog/index.js +7 -0
  292. package/dist/composites/confirm-dialog/index.js.map +1 -0
  293. package/dist/composites/cron-jobs-list/index.js +5 -0
  294. package/dist/composites/cron-jobs-list/index.js.map +1 -0
  295. package/dist/composites/data-table/index.js +10 -0
  296. package/dist/composites/data-table/index.js.map +1 -0
  297. package/dist/composites/deployment-row/index.js +5 -0
  298. package/dist/composites/deployment-row/index.js.map +1 -0
  299. package/dist/composites/domain-config/index.js +7 -0
  300. package/dist/composites/domain-config/index.js.map +1 -0
  301. package/dist/composites/env-var-editor/index.js +7 -0
  302. package/dist/composites/env-var-editor/index.js.map +1 -0
  303. package/dist/composites/mcp-server-list/index.js +5 -0
  304. package/dist/composites/mcp-server-list/index.js.map +1 -0
  305. package/dist/composites/page-shell/index.js +7 -0
  306. package/dist/composites/page-shell/index.js.map +1 -0
  307. package/dist/composites/permission-modal/index.js +6 -0
  308. package/dist/composites/permission-modal/index.js.map +1 -0
  309. package/dist/composites/preview-env-card/index.js +6 -0
  310. package/dist/composites/preview-env-card/index.js.map +1 -0
  311. package/dist/composites/preview-panel/index.js +5 -0
  312. package/dist/composites/preview-panel/index.js.map +1 -0
  313. package/dist/composites/project-card/index.js +6 -0
  314. package/dist/composites/project-card/index.js.map +1 -0
  315. package/dist/composites/rollback-ui/index.js +6 -0
  316. package/dist/composites/rollback-ui/index.js.map +1 -0
  317. package/dist/composites/rule-editor/index.js +11 -0
  318. package/dist/composites/rule-editor/index.js.map +1 -0
  319. package/dist/composites/skill-editor/index.js +11 -0
  320. package/dist/composites/skill-editor/index.js.map +1 -0
  321. package/dist/composites/skills-list/index.js +5 -0
  322. package/dist/composites/skills-list/index.js.map +1 -0
  323. package/dist/composites/stability-bundle-viewer/index.js +4 -0
  324. package/dist/composites/stability-bundle-viewer/index.js.map +1 -0
  325. package/dist/composites/task-header/index.js +5 -0
  326. package/dist/composites/task-header/index.js.map +1 -0
  327. package/dist/composites/usage-meter/index.js +5 -0
  328. package/dist/composites/usage-meter/index.js.map +1 -0
  329. package/dist/fonts/LICENSE-GEIST.txt +92 -0
  330. package/dist/fonts/geist-400.woff2 +0 -0
  331. package/dist/fonts/geist-500.woff2 +0 -0
  332. package/dist/fonts/geist-600.woff2 +0 -0
  333. package/dist/fonts/geist-mono-400.woff2 +0 -0
  334. package/dist/fonts/geist-mono-500.woff2 +0 -0
  335. package/dist/fonts/geist-mono-600.woff2 +0 -0
  336. package/dist/fonts-cdn.css +28 -0
  337. package/dist/fonts.css +75 -0
  338. package/dist/index.d.ts +4621 -0
  339. package/dist/index.js +1338 -0
  340. package/dist/index.js.map +1 -0
  341. package/dist/plugin-D5xmXqYb.d.ts +172 -0
  342. package/dist/preset-v3-legacy.d.ts +35 -0
  343. package/dist/preset-v3-legacy.js +159 -0
  344. package/dist/preset-v3-legacy.js.map +1 -0
  345. package/dist/preset.css +27 -0
  346. package/dist/primitives/action-bar/index.js +4 -0
  347. package/dist/primitives/action-bar/index.js.map +1 -0
  348. package/dist/primitives/agent-error-card/index.js +5 -0
  349. package/dist/primitives/agent-error-card/index.js.map +1 -0
  350. package/dist/primitives/agent-event/index.js +4 -0
  351. package/dist/primitives/agent-event/index.js.map +1 -0
  352. package/dist/primitives/agent-handoff/index.js +4 -0
  353. package/dist/primitives/agent-handoff/index.js.map +1 -0
  354. package/dist/primitives/agent-profile/index.js +4 -0
  355. package/dist/primitives/agent-profile/index.js.map +1 -0
  356. package/dist/primitives/agent-starting-state/index.js +5 -0
  357. package/dist/primitives/agent-starting-state/index.js.map +1 -0
  358. package/dist/primitives/agent-streaming/index.js +5 -0
  359. package/dist/primitives/agent-streaming/index.js.map +1 -0
  360. package/dist/primitives/alert/index.js +4 -0
  361. package/dist/primitives/alert/index.js.map +1 -0
  362. package/dist/primitives/artifact-preview/index.js +4 -0
  363. package/dist/primitives/artifact-preview/index.js.map +1 -0
  364. package/dist/primitives/attachment-chip/index.js +4 -0
  365. package/dist/primitives/attachment-chip/index.js.map +1 -0
  366. package/dist/primitives/audit-log-entry/index.js +4 -0
  367. package/dist/primitives/audit-log-entry/index.js.map +1 -0
  368. package/dist/primitives/auto-compact-notice/index.js +5 -0
  369. package/dist/primitives/auto-compact-notice/index.js.map +1 -0
  370. package/dist/primitives/avatar/index.js +4 -0
  371. package/dist/primitives/avatar/index.js.map +1 -0
  372. package/dist/primitives/badge/index.js +4 -0
  373. package/dist/primitives/badge/index.js.map +1 -0
  374. package/dist/primitives/branch-indicator/index.js +4 -0
  375. package/dist/primitives/branch-indicator/index.js.map +1 -0
  376. package/dist/primitives/browser-controls/index.js +4 -0
  377. package/dist/primitives/browser-controls/index.js.map +1 -0
  378. package/dist/primitives/build-log-stream/index.js +5 -0
  379. package/dist/primitives/build-log-stream/index.js.map +1 -0
  380. package/dist/primitives/button/index.js +4 -0
  381. package/dist/primitives/button/index.js.map +1 -0
  382. package/dist/primitives/capability-indicator/index.js +4 -0
  383. package/dist/primitives/capability-indicator/index.js.map +1 -0
  384. package/dist/primitives/card/index.js +4 -0
  385. package/dist/primitives/card/index.js.map +1 -0
  386. package/dist/primitives/channel-card/index.js +4 -0
  387. package/dist/primitives/channel-card/index.js.map +1 -0
  388. package/dist/primitives/chat-thread/index.js +5 -0
  389. package/dist/primitives/chat-thread/index.js.map +1 -0
  390. package/dist/primitives/checkbox/index.js +4 -0
  391. package/dist/primitives/checkbox/index.js.map +1 -0
  392. package/dist/primitives/context-card/index.js +4 -0
  393. package/dist/primitives/context-card/index.js.map +1 -0
  394. package/dist/primitives/context-window-bar/index.js +4 -0
  395. package/dist/primitives/context-window-bar/index.js.map +1 -0
  396. package/dist/primitives/copy-button/index.js +4 -0
  397. package/dist/primitives/copy-button/index.js.map +1 -0
  398. package/dist/primitives/cost-meter/index.js +4 -0
  399. package/dist/primitives/cost-meter/index.js.map +1 -0
  400. package/dist/primitives/created-files-card/index.js +4 -0
  401. package/dist/primitives/created-files-card/index.js.map +1 -0
  402. package/dist/primitives/cron-job-card/index.js +4 -0
  403. package/dist/primitives/cron-job-card/index.js.map +1 -0
  404. package/dist/primitives/danger-zone/index.js +4 -0
  405. package/dist/primitives/danger-zone/index.js.map +1 -0
  406. package/dist/primitives/dialog/index.js +4 -0
  407. package/dist/primitives/dialog/index.js.map +1 -0
  408. package/dist/primitives/diff-viewer/index.js +4 -0
  409. package/dist/primitives/diff-viewer/index.js.map +1 -0
  410. package/dist/primitives/dropdown-menu/index.js +4 -0
  411. package/dist/primitives/dropdown-menu/index.js.map +1 -0
  412. package/dist/primitives/empty-state/index.js +4 -0
  413. package/dist/primitives/empty-state/index.js.map +1 -0
  414. package/dist/primitives/export-chat-dialog/index.js +4 -0
  415. package/dist/primitives/export-chat-dialog/index.js.map +1 -0
  416. package/dist/primitives/folder-context-card/index.js +4 -0
  417. package/dist/primitives/folder-context-card/index.js.map +1 -0
  418. package/dist/primitives/folder-selector/index.js +4 -0
  419. package/dist/primitives/folder-selector/index.js.map +1 -0
  420. package/dist/primitives/form-field/index.js +4 -0
  421. package/dist/primitives/form-field/index.js.map +1 -0
  422. package/dist/primitives/gateway-status-indicator/index.js +4 -0
  423. package/dist/primitives/gateway-status-indicator/index.js.map +1 -0
  424. package/dist/primitives/hook-config/index.js +4 -0
  425. package/dist/primitives/hook-config/index.js.map +1 -0
  426. package/dist/primitives/hook-event-log/index.js +4 -0
  427. package/dist/primitives/hook-event-log/index.js.map +1 -0
  428. package/dist/primitives/input/index.js +4 -0
  429. package/dist/primitives/input/index.js.map +1 -0
  430. package/dist/primitives/intent-selector/index.js +4 -0
  431. package/dist/primitives/intent-selector/index.js.map +1 -0
  432. package/dist/primitives/label/index.js +4 -0
  433. package/dist/primitives/label/index.js.map +1 -0
  434. package/dist/primitives/lane-board/index.js +4 -0
  435. package/dist/primitives/lane-board/index.js.map +1 -0
  436. package/dist/primitives/login-split/index.js +4 -0
  437. package/dist/primitives/login-split/index.js.map +1 -0
  438. package/dist/primitives/mcp-server-card/index.js +4 -0
  439. package/dist/primitives/mcp-server-card/index.js.map +1 -0
  440. package/dist/primitives/memory-editor/index.js +4 -0
  441. package/dist/primitives/memory-editor/index.js.map +1 -0
  442. package/dist/primitives/mention-menu/index.js +4 -0
  443. package/dist/primitives/mention-menu/index.js.map +1 -0
  444. package/dist/primitives/metrics-panel/index.js +4 -0
  445. package/dist/primitives/metrics-panel/index.js.map +1 -0
  446. package/dist/primitives/model-card/index.js +4 -0
  447. package/dist/primitives/model-card/index.js.map +1 -0
  448. package/dist/primitives/model-selector/index.js +4 -0
  449. package/dist/primitives/model-selector/index.js.map +1 -0
  450. package/dist/primitives/pagination/index.js +4 -0
  451. package/dist/primitives/pagination/index.js.map +1 -0
  452. package/dist/primitives/permission-matrix/index.js +4 -0
  453. package/dist/primitives/permission-matrix/index.js.map +1 -0
  454. package/dist/primitives/pin-input/index.js +4 -0
  455. package/dist/primitives/pin-input/index.js.map +1 -0
  456. package/dist/primitives/plan-badge/index.js +4 -0
  457. package/dist/primitives/plan-badge/index.js.map +1 -0
  458. package/dist/primitives/progress/index.js +4 -0
  459. package/dist/primitives/progress/index.js.map +1 -0
  460. package/dist/primitives/progress-checklist/index.js +4 -0
  461. package/dist/primitives/progress-checklist/index.js.map +1 -0
  462. package/dist/primitives/project-switcher/index.js +4 -0
  463. package/dist/primitives/project-switcher/index.js.map +1 -0
  464. package/dist/primitives/quick-action-chips/index.js +4 -0
  465. package/dist/primitives/quick-action-chips/index.js.map +1 -0
  466. package/dist/primitives/radio-group/index.js +4 -0
  467. package/dist/primitives/radio-group/index.js.map +1 -0
  468. package/dist/primitives/recent-folders-list/index.js +4 -0
  469. package/dist/primitives/recent-folders-list/index.js.map +1 -0
  470. package/dist/primitives/rule-card/index.js +4 -0
  471. package/dist/primitives/rule-card/index.js.map +1 -0
  472. package/dist/primitives/run-stats/index.js +4 -0
  473. package/dist/primitives/run-stats/index.js.map +1 -0
  474. package/dist/primitives/run-status-pill/index.js +4 -0
  475. package/dist/primitives/run-status-pill/index.js.map +1 -0
  476. package/dist/primitives/running-tasks-panel/index.js +4 -0
  477. package/dist/primitives/running-tasks-panel/index.js.map +1 -0
  478. package/dist/primitives/scroll-area/index.js +4 -0
  479. package/dist/primitives/scroll-area/index.js.map +1 -0
  480. package/dist/primitives/select/index.js +4 -0
  481. package/dist/primitives/select/index.js.map +1 -0
  482. package/dist/primitives/session-list-item/index.js +4 -0
  483. package/dist/primitives/session-list-item/index.js.map +1 -0
  484. package/dist/primitives/session-timeline/index.js +4 -0
  485. package/dist/primitives/session-timeline/index.js.map +1 -0
  486. package/dist/primitives/sheet/index.js +4 -0
  487. package/dist/primitives/sheet/index.js.map +1 -0
  488. package/dist/primitives/sidebar/index.js +4 -0
  489. package/dist/primitives/sidebar/index.js.map +1 -0
  490. package/dist/primitives/skeleton/index.js +5 -0
  491. package/dist/primitives/skeleton/index.js.map +1 -0
  492. package/dist/primitives/skill-card/index.js +4 -0
  493. package/dist/primitives/skill-card/index.js.map +1 -0
  494. package/dist/primitives/social-auth-row/index.js +4 -0
  495. package/dist/primitives/social-auth-row/index.js.map +1 -0
  496. package/dist/primitives/stat-tile/index.js +4 -0
  497. package/dist/primitives/stat-tile/index.js.map +1 -0
  498. package/dist/primitives/status-dot/index.js +4 -0
  499. package/dist/primitives/status-dot/index.js.map +1 -0
  500. package/dist/primitives/steps-rail/index.js +4 -0
  501. package/dist/primitives/steps-rail/index.js.map +1 -0
  502. package/dist/primitives/sub-agent-dispatch/index.js +4 -0
  503. package/dist/primitives/sub-agent-dispatch/index.js.map +1 -0
  504. package/dist/primitives/switch/index.js +4 -0
  505. package/dist/primitives/switch/index.js.map +1 -0
  506. package/dist/primitives/system-prompt-editor/index.js +4 -0
  507. package/dist/primitives/system-prompt-editor/index.js.map +1 -0
  508. package/dist/primitives/table/index.js +4 -0
  509. package/dist/primitives/table/index.js.map +1 -0
  510. package/dist/primitives/tabs/index.js +4 -0
  511. package/dist/primitives/tabs/index.js.map +1 -0
  512. package/dist/primitives/task-plan/index.js +4 -0
  513. package/dist/primitives/task-plan/index.js.map +1 -0
  514. package/dist/primitives/terminal-panel/index.js +5 -0
  515. package/dist/primitives/terminal-panel/index.js.map +1 -0
  516. package/dist/primitives/textarea/index.js +4 -0
  517. package/dist/primitives/textarea/index.js.map +1 -0
  518. package/dist/primitives/thinking-level-selector/index.js +4 -0
  519. package/dist/primitives/thinking-level-selector/index.js.map +1 -0
  520. package/dist/primitives/timestamp/index.js +4 -0
  521. package/dist/primitives/timestamp/index.js.map +1 -0
  522. package/dist/primitives/toast/index.js +4 -0
  523. package/dist/primitives/toast/index.js.map +1 -0
  524. package/dist/primitives/token-usage-chart/index.js +4 -0
  525. package/dist/primitives/token-usage-chart/index.js.map +1 -0
  526. package/dist/primitives/tool-call/index.js +4 -0
  527. package/dist/primitives/tool-call/index.js.map +1 -0
  528. package/dist/primitives/tool-call-card/index.js +4 -0
  529. package/dist/primitives/tool-call-card/index.js.map +1 -0
  530. package/dist/primitives/tool-result/index.js +4 -0
  531. package/dist/primitives/tool-result/index.js.map +1 -0
  532. package/dist/primitives/tools-list/index.js +4 -0
  533. package/dist/primitives/tools-list/index.js.map +1 -0
  534. package/dist/primitives/tooltip/index.js +4 -0
  535. package/dist/primitives/tooltip/index.js.map +1 -0
  536. package/dist/primitives/topnav/index.js +4 -0
  537. package/dist/primitives/topnav/index.js.map +1 -0
  538. package/dist/primitives/update-banner/index.js +4 -0
  539. package/dist/primitives/update-banner/index.js.map +1 -0
  540. package/dist/slide/index.d.ts +212 -0
  541. package/dist/slide/index.js +3 -0
  542. package/dist/slide/index.js.map +1 -0
  543. package/dist/slide/plugins/emoji/index.d.ts +29 -0
  544. package/dist/slide/plugins/emoji/index.js +157 -0
  545. package/dist/slide/plugins/emoji/index.js.map +1 -0
  546. package/dist/slide/plugins/math/index.d.ts +13 -0
  547. package/dist/slide/plugins/math/index.js +145 -0
  548. package/dist/slide/plugins/math/index.js.map +1 -0
  549. package/dist/slide/plugins/mermaid/index.d.ts +55 -0
  550. package/dist/slide/plugins/mermaid/index.js +218 -0
  551. package/dist/slide/plugins/mermaid/index.js.map +1 -0
  552. package/dist/slide/plugins/shiki/index.d.ts +18 -0
  553. package/dist/slide/plugins/shiki/index.js +87 -0
  554. package/dist/slide/plugins/shiki/index.js.map +1 -0
  555. package/dist/slide/themes/default.css +256 -0
  556. package/dist/slide/themes/layouts.css +143 -0
  557. package/dist/slide/themes/violet-forge.css +256 -0
  558. package/dist/slide-deck/index.css +52 -0
  559. package/dist/slide-deck/index.css.map +1 -0
  560. package/dist/slide-deck/index.d.ts +377 -0
  561. package/dist/slide-deck/index.js +1111 -0
  562. package/dist/slide-deck/index.js.map +1 -0
  563. package/dist/styles-v3-legacy.css +88 -0
  564. package/dist/styles.css +137 -0
  565. package/dist/tokens-v4.css +187 -0
  566. package/dist/tokens.css +230 -0
  567. package/dist/vite-plugin.d.ts +29 -0
  568. package/dist/vite-plugin.js +76 -0
  569. package/dist/vite-plugin.js.map +1 -0
  570. package/dist/whiteboard/index.d.ts +258 -0
  571. package/dist/whiteboard/index.js +738 -0
  572. package/dist/whiteboard/index.js.map +1 -0
  573. package/llms.txt +273 -0
  574. package/package.json +800 -0
  575. package/registry/index.json +856 -0
  576. package/registry/r/account-menu.json +24 -0
  577. package/registry/r/action-bar.json +22 -0
  578. package/registry/r/agent-composer.json +22 -0
  579. package/registry/r/agent-editor.json +27 -0
  580. package/registry/r/agent-error-card.json +22 -0
  581. package/registry/r/agent-event.json +24 -0
  582. package/registry/r/agent-handoff.json +22 -0
  583. package/registry/r/agent-profile.json +23 -0
  584. package/registry/r/agent-starting-state.json +22 -0
  585. package/registry/r/agent-stream.json +27 -0
  586. package/registry/r/agent-streaming.json +22 -0
  587. package/registry/r/agent-timeline.json +22 -0
  588. package/registry/r/agent-types.json +15 -0
  589. package/registry/r/alert.json +22 -0
  590. package/registry/r/approval-card.json +25 -0
  591. package/registry/r/artifact-preview.json +22 -0
  592. package/registry/r/attachment-chip.json +24 -0
  593. package/registry/r/audit-log-entry.json +23 -0
  594. package/registry/r/auto-compact-notice.json +22 -0
  595. package/registry/r/avatar.json +23 -0
  596. package/registry/r/badge.json +22 -0
  597. package/registry/r/browser-controls.json +22 -0
  598. package/registry/r/build-log-stream.json +19 -0
  599. package/registry/r/button.json +23 -0
  600. package/registry/r/capability-indicator.json +23 -0
  601. package/registry/r/card.json +22 -0
  602. package/registry/r/chat-composer.json +23 -0
  603. package/registry/r/chat-message.json +129 -0
  604. package/registry/r/chat-thread.json +20 -0
  605. package/registry/r/chat-types.json +15 -0
  606. package/registry/r/checkbox.json +24 -0
  607. package/registry/r/cn.json +19 -0
  608. package/registry/r/code-block.json +21 -0
  609. package/registry/r/command-palette.json +25 -0
  610. package/registry/r/confirm-dialog.json +25 -0
  611. package/registry/r/context-card.json +23 -0
  612. package/registry/r/context-window-bar.json +20 -0
  613. package/registry/r/copy-button.json +22 -0
  614. package/registry/r/cost-meter.json +22 -0
  615. package/registry/r/created-files-card.json +23 -0
  616. package/registry/r/cron-job-card.json +22 -0
  617. package/registry/r/cron-jobs-list.json +23 -0
  618. package/registry/r/danger-zone.json +20 -0
  619. package/registry/r/data-table.json +27 -0
  620. package/registry/r/deployment-row.json +23 -0
  621. package/registry/r/dialog.json +23 -0
  622. package/registry/r/diff-viewer.json +20 -0
  623. package/registry/r/domain-config.json +25 -0
  624. package/registry/r/dropdown-menu.json +23 -0
  625. package/registry/r/empty-state.json +20 -0
  626. package/registry/r/env-var-editor.json +25 -0
  627. package/registry/r/folder-context-card.json +23 -0
  628. package/registry/r/folder-selector.json +22 -0
  629. package/registry/r/form-field.json +23 -0
  630. package/registry/r/hook-config.json +22 -0
  631. package/registry/r/hook-event-log.json +22 -0
  632. package/registry/r/input.json +22 -0
  633. package/registry/r/intent-selector.json +24 -0
  634. package/registry/r/label.json +22 -0
  635. package/registry/r/lane-board.json +20 -0
  636. package/registry/r/live-region-context.json +16 -0
  637. package/registry/r/login-split.json +20 -0
  638. package/registry/r/mcp-server-card.json +22 -0
  639. package/registry/r/mcp-server-list.json +23 -0
  640. package/registry/r/memory-editor.json +23 -0
  641. package/registry/r/mention-menu.json +23 -0
  642. package/registry/r/metrics-panel.json +22 -0
  643. package/registry/r/mode-types.json +15 -0
  644. package/registry/r/model-card.json +23 -0
  645. package/registry/r/model-selector.json +23 -0
  646. package/registry/r/page-shell.json +25 -0
  647. package/registry/r/pagination.json +22 -0
  648. package/registry/r/permission-matrix.json +22 -0
  649. package/registry/r/permission-modal.json +24 -0
  650. package/registry/r/permission-types.json +15 -0
  651. package/registry/r/pin-input.json +20 -0
  652. package/registry/r/plan-badge.json +20 -0
  653. package/registry/r/preview-env-card.json +25 -0
  654. package/registry/r/preview-panel.json +21 -0
  655. package/registry/r/progress-checklist.json +23 -0
  656. package/registry/r/progress.json +20 -0
  657. package/registry/r/project-card.json +25 -0
  658. package/registry/r/project-switcher.json +22 -0
  659. package/registry/r/quick-action-chips.json +21 -0
  660. package/registry/r/radio-group.json +23 -0
  661. package/registry/r/recent-folders-list.json +22 -0
  662. package/registry/r/rollback-ui.json +24 -0
  663. package/registry/r/rule-card.json +23 -0
  664. package/registry/r/rule-editor.json +28 -0
  665. package/registry/r/rule-types.json +18 -0
  666. package/registry/r/run-stats.json +22 -0
  667. package/registry/r/running-tasks-panel.json +22 -0
  668. package/registry/r/safe-href.json +16 -0
  669. package/registry/r/scroll-area.json +22 -0
  670. package/registry/r/select.json +24 -0
  671. package/registry/r/session-list-item.json +20 -0
  672. package/registry/r/session-timeline.json +22 -0
  673. package/registry/r/sheet.json +24 -0
  674. package/registry/r/sidebar.json +19 -0
  675. package/registry/r/skeleton.json +19 -0
  676. package/registry/r/skill-card.json +24 -0
  677. package/registry/r/skill-editor.json +28 -0
  678. package/registry/r/skills-list.json +23 -0
  679. package/registry/r/slide-deck.json +130 -0
  680. package/registry/r/slide-plugin-emoji.json +28 -0
  681. package/registry/r/slide-plugin-math.json +24 -0
  682. package/registry/r/slide-plugin-mermaid.json +23 -0
  683. package/registry/r/slide-plugin-shiki.json +23 -0
  684. package/registry/r/slide.json +123 -0
  685. package/registry/r/social-auth-row.json +21 -0
  686. package/registry/r/stat-tile.json +22 -0
  687. package/registry/r/status-dot.json +20 -0
  688. package/registry/r/steps-rail.json +20 -0
  689. package/registry/r/sub-agent-dispatch.json +22 -0
  690. package/registry/r/switch.json +23 -0
  691. package/registry/r/system-prompt-editor.json +22 -0
  692. package/registry/r/table.json +22 -0
  693. package/registry/r/tabs.json +22 -0
  694. package/registry/r/tailwind-preset.json +19 -0
  695. package/registry/r/task-header.json +24 -0
  696. package/registry/r/task-plan.json +22 -0
  697. package/registry/r/task-types.json +15 -0
  698. package/registry/r/terminal-panel.json +22 -0
  699. package/registry/r/textarea.json +22 -0
  700. package/registry/r/theme-provider.json +59 -0
  701. package/registry/r/theme-script.json +18 -0
  702. package/registry/r/theo-ui-provider.json +20 -0
  703. package/registry/r/timestamp.json +20 -0
  704. package/registry/r/toast.json +30 -0
  705. package/registry/r/token-usage-chart.json +20 -0
  706. package/registry/r/tokens.json +21 -0
  707. package/registry/r/tool-call-card.json +23 -0
  708. package/registry/r/tool-call.json +22 -0
  709. package/registry/r/tool-result.json +20 -0
  710. package/registry/r/tools-list.json +23 -0
  711. package/registry/r/tooltip.json +22 -0
  712. package/registry/r/topnav.json +22 -0
  713. package/registry/r/types.json +15 -0
  714. package/registry/r/usage-meter.json +21 -0
  715. package/registry/r/whiteboard.json +101 -0
@@ -0,0 +1,738 @@
1
+ import { useMemo, useEffect, useRef, useState, useCallback } from 'react';
2
+ import rough from 'roughjs';
3
+ import { getStroke } from 'perfect-freehand';
4
+ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
5
+ import { z } from 'zod';
6
+
7
+ // src/components/primitives/whiteboard/whiteboard.tsx
8
+
9
+ // src/components/primitives/whiteboard/seed.ts
10
+ var FNV_OFFSET_BASIS_32 = 2166136261;
11
+ var FNV_PRIME_32 = 16777619;
12
+ function fnv1a32(input) {
13
+ let hash = FNV_OFFSET_BASIS_32;
14
+ for (let i = 0; i < input.length; i++) {
15
+ hash ^= input.charCodeAt(i);
16
+ hash = Math.imul(hash, FNV_PRIME_32);
17
+ }
18
+ return hash | 0;
19
+ }
20
+ function deriveSeed(el) {
21
+ if (typeof el.seed === "number" && Number.isFinite(el.seed)) {
22
+ return el.seed | 0;
23
+ }
24
+ const key = `${el.type}|${el.x}|${el.y}|${el.w ?? ""}|${el.h ?? ""}|${el.label ?? ""}`;
25
+ return fnv1a32(key);
26
+ }
27
+ var DEFAULT_STROKE_OPTIONS = {
28
+ size: 8,
29
+ thinning: 0.5,
30
+ smoothing: 0.5,
31
+ streamline: 0.5
32
+ };
33
+ function fmt(n) {
34
+ return typeof n === "number" && Number.isFinite(n) ? n.toFixed(2) : "0";
35
+ }
36
+ function svgPathFromStroke(points) {
37
+ if (points.length === 0) return "";
38
+ const first = points[0] ?? [];
39
+ let d = `M ${fmt(first[0])} ${fmt(first[1])}`;
40
+ for (let i = 1; i < points.length; i++) {
41
+ const p = points[i] ?? [];
42
+ d += ` L ${fmt(p[0])} ${fmt(p[1])}`;
43
+ }
44
+ d += " Z";
45
+ return d;
46
+ }
47
+ function renderFreedraw(el) {
48
+ const size = (el.strokeWidth ?? 1.5) * 5;
49
+ const inputPoints = el.points.map(([x, y, pressure]) => {
50
+ const tx = el.x + x;
51
+ const ty = el.y + y;
52
+ return pressure === void 0 ? [tx, ty] : [tx, ty, pressure];
53
+ });
54
+ const stroke = getStroke(inputPoints, {
55
+ ...DEFAULT_STROKE_OPTIONS,
56
+ size
57
+ });
58
+ const d = svgPathFromStroke(stroke);
59
+ return /* @__PURE__ */ jsx("g", { opacity: el.opacity ?? 1, children: /* @__PURE__ */ jsx("path", { d, fill: el.stroke ?? "currentColor", stroke: "none" }) });
60
+ }
61
+
62
+ // src/components/primitives/whiteboard/render/rough-paths.ts
63
+ function toRoughPaths(generator, drawable) {
64
+ const paths = generator.toPaths(drawable);
65
+ return paths.map((p) => ({
66
+ d: p.d,
67
+ stroke: p.stroke,
68
+ strokeWidth: p.strokeWidth,
69
+ fill: p.fill
70
+ }));
71
+ }
72
+
73
+ // src/components/primitives/whiteboard/render/style.ts
74
+ var DEFAULT_STROKE = "currentColor";
75
+ function buildOptions(src, seed) {
76
+ const o = {
77
+ seed,
78
+ stroke: src.stroke ?? DEFAULT_STROKE,
79
+ strokeWidth: src.strokeWidth ?? 1.5,
80
+ roughness: src.roughness ?? 1.2
81
+ };
82
+ if (src.strokeStyle === "dashed") o.strokeLineDash = [10, 6];
83
+ else if (src.strokeStyle === "dotted") o.strokeLineDash = [2, 4];
84
+ if (src.fill) o.fill = src.fill;
85
+ if (src.fillStyle) o.fillStyle = src.fillStyle;
86
+ return o;
87
+ }
88
+ function strokeDashArray(strokeStyle2, strokeWidth) {
89
+ if (strokeStyle2 === "dashed") {
90
+ const dash = Math.max(8, strokeWidth * 6);
91
+ const gap = Math.max(5, strokeWidth * 4);
92
+ return `${dash} ${gap}`;
93
+ }
94
+ if (strokeStyle2 === "dotted") {
95
+ return `${strokeWidth} ${strokeWidth * 2.5}`;
96
+ }
97
+ return void 0;
98
+ }
99
+ var HEAD_BASE_PX = 12;
100
+ var HEAD_ANGLE_RAD = Math.PI / 7;
101
+ function arrowHeadGeometry(fromX, fromY, toX, toY, strokeWidth) {
102
+ const dx = toX - fromX;
103
+ const dy = toY - fromY;
104
+ const dist = Math.sqrt(dx * dx + dy * dy);
105
+ if (dist === 0) return null;
106
+ const angle = Math.atan2(dy, dx);
107
+ const headLen = Math.min(HEAD_BASE_PX + strokeWidth * 2, dist * 0.4);
108
+ const leftX = toX - headLen * Math.cos(angle - HEAD_ANGLE_RAD);
109
+ const leftY = toY - headLen * Math.sin(angle - HEAD_ANGLE_RAD);
110
+ const rightX = toX - headLen * Math.cos(angle + HEAD_ANGLE_RAD);
111
+ const rightY = toY - headLen * Math.sin(angle + HEAD_ANGLE_RAD);
112
+ return { apexX: toX, apexY: toY, leftX, leftY, rightX, rightY };
113
+ }
114
+ function lineBody(gen, el, seed) {
115
+ const opts = buildOptions(el, seed);
116
+ const drawable = gen.line(el.x, el.y, el.to[0], el.to[1], opts);
117
+ const dash = strokeDashArray(el.strokeStyle, el.strokeWidth ?? 1.5);
118
+ return toRoughPaths(gen, drawable).map((p, i) => /* @__PURE__ */ jsx(
119
+ "path",
120
+ {
121
+ d: p.d,
122
+ stroke: p.stroke,
123
+ strokeWidth: p.strokeWidth,
124
+ fill: "none",
125
+ strokeLinecap: "round",
126
+ strokeLinejoin: "round",
127
+ strokeDasharray: dash
128
+ },
129
+ `body-${i}`
130
+ ));
131
+ }
132
+ function arrowHead(gen, fromX, fromY, toX, toY, seed, el, side) {
133
+ const geom = arrowHeadGeometry(fromX, fromY, toX, toY, el.strokeWidth ?? 1.5);
134
+ if (!geom) return [];
135
+ const opts = buildOptions(el, seed);
136
+ const leftDrawable = gen.line(geom.apexX, geom.apexY, geom.leftX, geom.leftY, opts);
137
+ const rightDrawable = gen.line(geom.apexX, geom.apexY, geom.rightX, geom.rightY, opts);
138
+ const leftPaths = toRoughPaths(gen, leftDrawable);
139
+ const rightPaths = toRoughPaths(gen, rightDrawable);
140
+ const nodes = [];
141
+ for (const [i, p] of leftPaths.entries()) {
142
+ nodes.push(
143
+ /* @__PURE__ */ jsx(
144
+ "path",
145
+ {
146
+ d: p.d,
147
+ stroke: p.stroke,
148
+ strokeWidth: p.strokeWidth,
149
+ fill: "none",
150
+ strokeLinecap: "round",
151
+ strokeLinejoin: "round",
152
+ "data-line-part": "arrowhead"
153
+ },
154
+ `${side}-l-${i}`
155
+ )
156
+ );
157
+ }
158
+ for (const [i, p] of rightPaths.entries()) {
159
+ nodes.push(
160
+ /* @__PURE__ */ jsx(
161
+ "path",
162
+ {
163
+ d: p.d,
164
+ stroke: p.stroke,
165
+ strokeWidth: p.strokeWidth,
166
+ fill: "none",
167
+ strokeLinecap: "round",
168
+ strokeLinejoin: "round",
169
+ "data-line-part": "arrowhead"
170
+ },
171
+ `${side}-r-${i}`
172
+ )
173
+ );
174
+ }
175
+ return nodes;
176
+ }
177
+ function renderLine(gen, el) {
178
+ return /* @__PURE__ */ jsx("g", { opacity: el.opacity ?? 1, children: lineBody(gen, el, el.seed ?? 0) });
179
+ }
180
+ function renderArrow(gen, el) {
181
+ const seed = el.seed ?? 0;
182
+ const nodes = [...lineBody(gen, el, seed)];
183
+ if (el.headEnd !== false) {
184
+ nodes.push(...arrowHead(gen, el.x, el.y, el.to[0], el.to[1], seed + 1, el, "end"));
185
+ }
186
+ if (el.headStart) {
187
+ nodes.push(...arrowHead(gen, el.to[0], el.to[1], el.x, el.y, seed + 2, el, "start"));
188
+ }
189
+ let label = null;
190
+ if (el.label) {
191
+ const midX = (el.x + el.to[0]) / 2;
192
+ const midY = (el.y + el.to[1]) / 2;
193
+ const dx = el.to[0] - el.x;
194
+ const dy = el.to[1] - el.y;
195
+ const dist = Math.sqrt(dx * dx + dy * dy) || 1;
196
+ const nx = -dy / dist;
197
+ const ny = dx / dist;
198
+ const offset = 12;
199
+ label = /* @__PURE__ */ jsx(
200
+ "text",
201
+ {
202
+ x: midX + nx * offset,
203
+ y: midY + ny * offset,
204
+ textAnchor: "middle",
205
+ dominantBaseline: "central",
206
+ fontSize: 14,
207
+ fontFamily: "ui-sans-serif, system-ui, sans-serif",
208
+ fill: el.stroke ?? "currentColor",
209
+ style: { pointerEvents: "none" },
210
+ children: el.label
211
+ }
212
+ );
213
+ }
214
+ return /* @__PURE__ */ jsxs("g", { opacity: el.opacity ?? 1, children: [
215
+ nodes,
216
+ label
217
+ ] });
218
+ }
219
+ function Label({ cx, cy, label, stroke }) {
220
+ return /* @__PURE__ */ jsx(
221
+ "text",
222
+ {
223
+ x: cx,
224
+ y: cy,
225
+ textAnchor: "middle",
226
+ dominantBaseline: "central",
227
+ fontSize: 16,
228
+ fontFamily: "ui-sans-serif, system-ui, sans-serif",
229
+ fill: stroke ?? "currentColor",
230
+ style: { pointerEvents: "none" },
231
+ children: label
232
+ }
233
+ );
234
+ }
235
+ function pathsToReactNodes(paths, keyPrefix, outlineStroke, dashArray) {
236
+ return paths.map((p, i) => {
237
+ const isOutline = p.stroke === outlineStroke;
238
+ return /* @__PURE__ */ jsx(
239
+ "path",
240
+ {
241
+ d: p.d,
242
+ stroke: p.stroke,
243
+ strokeWidth: p.strokeWidth,
244
+ fill: p.fill ?? "none",
245
+ strokeLinecap: "round",
246
+ strokeLinejoin: "round",
247
+ strokeDasharray: isOutline ? dashArray : void 0
248
+ },
249
+ `${keyPrefix}-${i}`
250
+ );
251
+ });
252
+ }
253
+ function renderRect(gen, el) {
254
+ const opts = buildOptions(el, el.seed ?? 0);
255
+ const drawable = gen.rectangle(el.x, el.y, el.w, el.h, opts);
256
+ const paths = toRoughPaths(gen, drawable);
257
+ const dash = strokeDashArray(el.strokeStyle, el.strokeWidth ?? 1.5);
258
+ return /* @__PURE__ */ jsxs("g", { opacity: el.opacity ?? 1, children: [
259
+ pathsToReactNodes(paths, "rect", opts.stroke, dash),
260
+ el.label ? /* @__PURE__ */ jsx(Label, { cx: el.x + el.w / 2, cy: el.y + el.h / 2, label: el.label, stroke: el.stroke }) : null
261
+ ] });
262
+ }
263
+ function renderEllipse(gen, el) {
264
+ const opts = buildOptions(el, el.seed ?? 0);
265
+ const drawable = gen.ellipse(el.x + el.w / 2, el.y + el.h / 2, el.w, el.h, opts);
266
+ const paths = toRoughPaths(gen, drawable);
267
+ const dash = strokeDashArray(el.strokeStyle, el.strokeWidth ?? 1.5);
268
+ return /* @__PURE__ */ jsxs("g", { opacity: el.opacity ?? 1, children: [
269
+ pathsToReactNodes(paths, "ellipse", opts.stroke, dash),
270
+ el.label ? /* @__PURE__ */ jsx(Label, { cx: el.x + el.w / 2, cy: el.y + el.h / 2, label: el.label, stroke: el.stroke }) : null
271
+ ] });
272
+ }
273
+ function renderDiamond(gen, el) {
274
+ const opts = buildOptions(el, el.seed ?? 0);
275
+ const cx = el.x + el.w / 2;
276
+ const cy = el.y + el.h / 2;
277
+ const points = [
278
+ [cx, el.y],
279
+ // top
280
+ [el.x + el.w, cy],
281
+ // right
282
+ [cx, el.y + el.h],
283
+ // bottom
284
+ [el.x, cy]
285
+ // left
286
+ ];
287
+ const drawable = gen.polygon(points, opts);
288
+ const paths = toRoughPaths(gen, drawable);
289
+ const dash = strokeDashArray(el.strokeStyle, el.strokeWidth ?? 1.5);
290
+ return /* @__PURE__ */ jsxs("g", { opacity: el.opacity ?? 1, children: [
291
+ pathsToReactNodes(paths, "diamond", opts.stroke, dash),
292
+ el.label ? /* @__PURE__ */ jsx(Label, { cx, cy, label: el.label, stroke: el.stroke }) : null
293
+ ] });
294
+ }
295
+ var FONT_STACKS = {
296
+ sans: "ui-sans-serif, system-ui, sans-serif",
297
+ serif: "ui-serif, Georgia, serif",
298
+ mono: "ui-monospace, SFMono-Regular, Menlo, monospace",
299
+ hand: '"Virgil", "Caveat", "Comic Sans MS", cursive'
300
+ };
301
+ function textAnchor(align2) {
302
+ if (align2 === "center") return "middle";
303
+ if (align2 === "right") return "end";
304
+ return "start";
305
+ }
306
+ function renderText(el) {
307
+ const fontSize = el.fontSize ?? 18;
308
+ const fontFamily2 = FONT_STACKS[el.fontFamily ?? "hand"];
309
+ const anchor = textAnchor(el.align);
310
+ const lines = el.text.split("\n");
311
+ return /* @__PURE__ */ jsx("g", { opacity: el.opacity ?? 1, children: /* @__PURE__ */ jsx(
312
+ "text",
313
+ {
314
+ x: el.x,
315
+ y: el.y,
316
+ textAnchor: anchor,
317
+ dominantBaseline: "hanging",
318
+ fontSize,
319
+ fontFamily: fontFamily2,
320
+ fill: el.stroke ?? "currentColor",
321
+ children: lines.map((line, i) => (
322
+ // biome-ignore lint/suspicious/noArrayIndexKey: text is split deterministically on '\n' so the line index is the most stable key.
323
+ /* @__PURE__ */ jsx("tspan", { x: el.x, dy: i === 0 ? 0 : fontSize * 1.2, children: line }, i)
324
+ ))
325
+ }
326
+ ) });
327
+ }
328
+ function elementWithSeed(el) {
329
+ if (typeof el.seed === "number") return el;
330
+ return { ...el, seed: deriveSeed(el) };
331
+ }
332
+ function renderElement(el, gen) {
333
+ switch (el.type) {
334
+ case "rect":
335
+ return renderRect(gen, elementWithSeed(el));
336
+ case "ellipse":
337
+ return renderEllipse(gen, elementWithSeed(el));
338
+ case "diamond":
339
+ return renderDiamond(gen, elementWithSeed(el));
340
+ case "line":
341
+ return renderLine(gen, elementWithSeed(el));
342
+ case "arrow":
343
+ return renderArrow(gen, elementWithSeed(el));
344
+ case "text":
345
+ return renderText(elementWithSeed(el));
346
+ case "freedraw":
347
+ return renderFreedraw(elementWithSeed(el));
348
+ }
349
+ }
350
+ function renderScene(scene, gen) {
351
+ return /* @__PURE__ */ jsx(Fragment, { children: scene.elements.map((el, i) => /* @__PURE__ */ jsx(
352
+ "g",
353
+ {
354
+ "data-element-id": el.id ?? String(i),
355
+ "data-element-type": el.type,
356
+ children: renderElement(el, gen)
357
+ },
358
+ el.id ?? `__idx-${i}`
359
+ )) });
360
+ }
361
+ var finiteNumber = z.number().finite();
362
+ var finitePositive = finiteNumber.positive();
363
+ var strokeStyle = z.enum(["solid", "dashed", "dotted"]);
364
+ var fillStyle = z.enum(["hachure", "solid", "cross-hatch", "zigzag"]);
365
+ var align = z.enum(["left", "center", "right"]);
366
+ var fontFamily = z.enum(["sans", "serif", "mono", "hand"]);
367
+ var roundness = z.enum(["sharp", "round"]);
368
+ var baseElement = z.object({
369
+ id: z.string().max(120).optional(),
370
+ x: finiteNumber,
371
+ y: finiteNumber,
372
+ stroke: z.string().max(64).optional(),
373
+ strokeWidth: finitePositive.max(50).optional(),
374
+ strokeStyle: strokeStyle.optional(),
375
+ fill: z.string().max(64).optional(),
376
+ fillStyle: fillStyle.optional(),
377
+ opacity: finiteNumber.min(0).max(1).optional(),
378
+ roughness: finiteNumber.min(0).max(3).optional(),
379
+ seed: z.number().int().finite().optional()
380
+ });
381
+ var dim = finitePositive.max(2e4);
382
+ var labelText = z.string().max(500);
383
+ var rectElement = baseElement.extend({
384
+ type: z.literal("rect"),
385
+ w: dim,
386
+ h: dim,
387
+ label: labelText.optional(),
388
+ roundness: roundness.optional()
389
+ });
390
+ var ellipseElement = baseElement.extend({
391
+ type: z.literal("ellipse"),
392
+ w: dim,
393
+ h: dim,
394
+ label: labelText.optional()
395
+ });
396
+ var diamondElement = baseElement.extend({
397
+ type: z.literal("diamond"),
398
+ w: dim,
399
+ h: dim,
400
+ label: labelText.optional()
401
+ });
402
+ var point2 = z.tuple([finiteNumber, finiteNumber]);
403
+ var lineElement = baseElement.extend({
404
+ type: z.literal("line"),
405
+ to: point2
406
+ });
407
+ var arrowElement = baseElement.extend({
408
+ type: z.literal("arrow"),
409
+ to: point2,
410
+ label: labelText.optional(),
411
+ headStart: z.boolean().optional(),
412
+ headEnd: z.boolean().default(true)
413
+ });
414
+ var textElement = baseElement.extend({
415
+ type: z.literal("text"),
416
+ text: z.string().max(5e3),
417
+ fontSize: finitePositive.max(500).optional(),
418
+ align: align.optional(),
419
+ fontFamily: fontFamily.optional()
420
+ });
421
+ var freedrawPoint = z.tuple([finiteNumber, finiteNumber, finiteNumber.optional()]);
422
+ var freedrawElement = baseElement.extend({
423
+ type: z.literal("freedraw"),
424
+ points: z.array(freedrawPoint).min(2).max(5e3)
425
+ });
426
+ var whiteboardElement = z.discriminatedUnion("type", [
427
+ rectElement,
428
+ ellipseElement,
429
+ diamondElement,
430
+ lineElement,
431
+ arrowElement,
432
+ textElement,
433
+ freedrawElement
434
+ ]);
435
+ var whiteboardScene = z.object({
436
+ version: z.literal(1),
437
+ width: dim,
438
+ // EC-4: clamped 1..20000
439
+ height: dim,
440
+ // EC-4: clamped 1..20000
441
+ background: z.string().max(64).optional(),
442
+ elements: z.array(whiteboardElement).max(5e3)
443
+ });
444
+
445
+ // src/components/primitives/whiteboard/validate.ts
446
+ function valueAtPath(input, path) {
447
+ let cursor = input;
448
+ for (const segment of path) {
449
+ if (cursor === null || typeof cursor !== "object") return void 0;
450
+ cursor = cursor[segment];
451
+ }
452
+ return cursor;
453
+ }
454
+ function formatIssue(issue, input) {
455
+ const error = {
456
+ path: issue.path.join("."),
457
+ message: issue.message,
458
+ code: issue.code
459
+ };
460
+ if ("received" in issue && issue.received !== void 0) {
461
+ error.got = issue.received;
462
+ } else if (issue.path.length > 0) {
463
+ const value = valueAtPath(input, issue.path);
464
+ if (value !== void 0) error.got = value;
465
+ }
466
+ return error;
467
+ }
468
+ function validateScene(input) {
469
+ const result = whiteboardScene.safeParse(input);
470
+ if (result.success) {
471
+ return { ok: true, scene: result.data };
472
+ }
473
+ const errors = result.error.issues.map(
474
+ (issue) => formatIssue(issue, input)
475
+ );
476
+ return { ok: false, errors };
477
+ }
478
+ function usePointerPan(ref, viewport, size) {
479
+ const dragRef = useRef(null);
480
+ const spaceHeldRef = useRef(false);
481
+ useEffect(() => {
482
+ const el = ref.current;
483
+ if (!el) return;
484
+ const handler = (e) => {
485
+ e.preventDefault();
486
+ const rect = el.getBoundingClientRect();
487
+ const localX = e.clientX - rect.left;
488
+ const localY = e.clientY - rect.top;
489
+ const scaleX = size.width / rect.width;
490
+ const scaleY = size.height / rect.height;
491
+ viewport.zoomAt(localX * scaleX, localY * scaleY, -e.deltaY * 1e-3, size);
492
+ };
493
+ el.addEventListener("wheel", handler, { passive: false });
494
+ return () => el.removeEventListener("wheel", handler);
495
+ }, [ref, viewport, size]);
496
+ useEffect(() => {
497
+ const down = (e) => {
498
+ if (e.code === "Space") spaceHeldRef.current = true;
499
+ };
500
+ const up = (e) => {
501
+ if (e.code === "Space") spaceHeldRef.current = false;
502
+ };
503
+ window.addEventListener("keydown", down);
504
+ window.addEventListener("keyup", up);
505
+ return () => {
506
+ window.removeEventListener("keydown", down);
507
+ window.removeEventListener("keyup", up);
508
+ };
509
+ }, []);
510
+ const onPointerDown = useCallback((e) => {
511
+ if (e.target instanceof Element && !e.currentTarget.contains(e.target)) return;
512
+ const isMouseButton = e.button === 0 || e.button === 1;
513
+ if (!isMouseButton && e.pointerType === "mouse") return;
514
+ if (e.pointerType === "mouse" && e.button !== 1 && !spaceHeldRef.current && e.button !== 0) {
515
+ return;
516
+ }
517
+ dragRef.current = { pointerId: e.pointerId, lastX: e.clientX, lastY: e.clientY };
518
+ e.currentTarget.setPointerCapture(e.pointerId);
519
+ }, []);
520
+ const onPointerMove = useCallback(
521
+ (e) => {
522
+ const drag = dragRef.current;
523
+ if (!drag || drag.pointerId !== e.pointerId) return;
524
+ const dx = e.clientX - drag.lastX;
525
+ const dy = e.clientY - drag.lastY;
526
+ drag.lastX = e.clientX;
527
+ drag.lastY = e.clientY;
528
+ const el = ref.current;
529
+ if (!el) return;
530
+ const rect = el.getBoundingClientRect();
531
+ const scaleX = size.width / rect.width;
532
+ const scaleY = size.height / rect.height;
533
+ viewport.pan(dx * scaleX, dy * scaleY);
534
+ },
535
+ [ref, viewport, size]
536
+ );
537
+ const releaseDrag = useCallback((e) => {
538
+ const drag = dragRef.current;
539
+ if (!drag || drag.pointerId !== e.pointerId) return;
540
+ try {
541
+ e.currentTarget.releasePointerCapture(e.pointerId);
542
+ } catch {
543
+ }
544
+ dragRef.current = null;
545
+ }, []);
546
+ return {
547
+ onPointerDown,
548
+ onPointerMove,
549
+ onPointerUp: releaseDrag,
550
+ onPointerCancel: releaseDrag
551
+ };
552
+ }
553
+ var MIN_ZOOM = 0.1;
554
+ var MAX_ZOOM = 8;
555
+ function clampZoom(z2) {
556
+ if (!Number.isFinite(z2)) return 1;
557
+ return Math.min(MAX_ZOOM, Math.max(MIN_ZOOM, z2));
558
+ }
559
+ function useViewport(opts) {
560
+ const initial = useMemo(() => {
561
+ const zoom = clampZoom(opts.initialZoom ?? 1);
562
+ if (opts.initialCenter) {
563
+ const [cx, cy] = opts.initialCenter;
564
+ return {
565
+ x: cx - opts.width / (2 * zoom),
566
+ y: cy - opts.height / (2 * zoom),
567
+ zoom
568
+ };
569
+ }
570
+ return { x: 0, y: 0, zoom };
571
+ }, [opts.initialCenter, opts.initialZoom, opts.width, opts.height]);
572
+ const [state, setState] = useState(initial);
573
+ const pan = useCallback((dx, dy) => {
574
+ setState((prev) => ({ ...prev, x: prev.x - dx / prev.zoom, y: prev.y - dy / prev.zoom }));
575
+ }, []);
576
+ const setZoom = useCallback((zoom) => {
577
+ setState((prev) => ({ ...prev, zoom: clampZoom(zoom) }));
578
+ }, []);
579
+ const zoomAt = useCallback(
580
+ (screenX, screenY, delta, _size) => {
581
+ setState((prev) => {
582
+ const oldZoom = prev.zoom;
583
+ const newZoom = clampZoom(prev.zoom * Math.exp(delta));
584
+ if (newZoom === oldZoom) return prev;
585
+ const worldX = prev.x + screenX / oldZoom;
586
+ const worldY = prev.y + screenY / oldZoom;
587
+ return {
588
+ x: worldX - screenX / newZoom,
589
+ y: worldY - screenY / newZoom,
590
+ zoom: newZoom
591
+ };
592
+ });
593
+ },
594
+ []
595
+ );
596
+ const reset = useCallback(() => setState(initial), [initial]);
597
+ const fitTo = useCallback((bounds, size) => {
598
+ const bboxWidth = Math.max(1, bounds.maxX - bounds.minX);
599
+ const bboxHeight = Math.max(1, bounds.maxY - bounds.minY);
600
+ const zoomX = size.width / bboxWidth;
601
+ const zoomY = size.height / bboxHeight;
602
+ const zoom = clampZoom(Math.min(zoomX, zoomY));
603
+ const cx = (bounds.minX + bounds.maxX) / 2;
604
+ const cy = (bounds.minY + bounds.maxY) / 2;
605
+ setState({
606
+ x: cx - size.width / (2 * zoom),
607
+ y: cy - size.height / (2 * zoom),
608
+ zoom
609
+ });
610
+ }, []);
611
+ const viewBox = useCallback(
612
+ (size) => `${state.x} ${state.y} ${size.width / state.zoom} ${size.height / state.zoom}`,
613
+ [state]
614
+ );
615
+ return { state, pan, setZoom, zoomAt, reset, fitTo, viewBox };
616
+ }
617
+ function computeBounds(scene) {
618
+ if (scene.elements.length === 0) return null;
619
+ let minX = Number.POSITIVE_INFINITY;
620
+ let minY = Number.POSITIVE_INFINITY;
621
+ let maxX = Number.NEGATIVE_INFINITY;
622
+ let maxY = Number.NEGATIVE_INFINITY;
623
+ for (const el of scene.elements) {
624
+ const x1 = el.x;
625
+ const y1 = el.y;
626
+ let x2 = el.x;
627
+ let y2 = el.y;
628
+ if (el.type === "rect" || el.type === "ellipse" || el.type === "diamond") {
629
+ x2 = el.x + el.w;
630
+ y2 = el.y + el.h;
631
+ } else if (el.type === "line" || el.type === "arrow") {
632
+ x2 = el.to[0];
633
+ y2 = el.to[1];
634
+ } else if (el.type === "freedraw") {
635
+ for (const [px, py] of el.points) {
636
+ const tx = el.x + px;
637
+ const ty = el.y + py;
638
+ if (tx < minX) minX = tx;
639
+ if (ty < minY) minY = ty;
640
+ if (tx > maxX) maxX = tx;
641
+ if (ty > maxY) maxY = ty;
642
+ }
643
+ continue;
644
+ }
645
+ if (x1 < minX) minX = x1;
646
+ if (y1 < minY) minY = y1;
647
+ if (x2 < minX) minX = x2;
648
+ if (y2 < minY) minY = y2;
649
+ if (x1 > maxX) maxX = x1;
650
+ if (y1 > maxY) maxY = y1;
651
+ if (x2 > maxX) maxX = x2;
652
+ if (y2 > maxY) maxY = y2;
653
+ }
654
+ if (!Number.isFinite(minX)) return null;
655
+ return { minX, minY, maxX, maxY };
656
+ }
657
+ function Whiteboard({
658
+ data,
659
+ className,
660
+ initialZoom,
661
+ initialCenter,
662
+ fitOnLoad,
663
+ onValidationError,
664
+ "aria-label": ariaLabel
665
+ }) {
666
+ const validation = useMemo(() => validateScene(data), [data]);
667
+ const scene = validation.ok ? validation.scene : null;
668
+ useEffect(() => {
669
+ if (!validation.ok && onValidationError) {
670
+ onValidationError(validation.errors);
671
+ }
672
+ }, [validation, onValidationError]);
673
+ const generator = useMemo(() => {
674
+ if (typeof globalThis === "undefined") return null;
675
+ try {
676
+ return rough.generator();
677
+ } catch {
678
+ return null;
679
+ }
680
+ }, []);
681
+ const sceneWidth = scene?.width ?? 400;
682
+ const sceneHeight = scene?.height ?? 300;
683
+ const sceneBackground = scene?.background;
684
+ const viewport = useViewport({
685
+ width: sceneWidth,
686
+ height: sceneHeight,
687
+ initialZoom,
688
+ initialCenter
689
+ });
690
+ const svgRef = useRef(null);
691
+ const fitTo = viewport.fitTo;
692
+ useEffect(() => {
693
+ if (!fitOnLoad || !scene) return;
694
+ const bounds = computeBounds(scene);
695
+ if (!bounds) return;
696
+ fitTo(bounds, { width: sceneWidth, height: sceneHeight });
697
+ }, [fitOnLoad, scene, sceneWidth, sceneHeight, fitTo]);
698
+ const handlers = usePointerPan(svgRef, viewport, {
699
+ width: sceneWidth,
700
+ height: sceneHeight
701
+ });
702
+ const label = ariaLabel ?? "Whiteboard diagram";
703
+ return /* @__PURE__ */ jsxs(
704
+ "svg",
705
+ {
706
+ ref: svgRef,
707
+ viewBox: viewport.viewBox({ width: sceneWidth, height: sceneHeight }),
708
+ width: sceneWidth,
709
+ height: sceneHeight,
710
+ className,
711
+ role: "img",
712
+ "aria-label": label,
713
+ xmlns: "http://www.w3.org/2000/svg",
714
+ "data-whiteboard-state": scene ? "ok" : "invalid",
715
+ style: { touchAction: "none", userSelect: "none" },
716
+ ...handlers,
717
+ children: [
718
+ /* @__PURE__ */ jsx("title", { children: label }),
719
+ sceneBackground ? /* @__PURE__ */ jsx(
720
+ "rect",
721
+ {
722
+ x: 0,
723
+ y: 0,
724
+ width: sceneWidth,
725
+ height: sceneHeight,
726
+ fill: sceneBackground,
727
+ "data-layer": "background"
728
+ }
729
+ ) : null,
730
+ scene && generator ? renderScene(scene, generator) : null
731
+ ]
732
+ }
733
+ );
734
+ }
735
+
736
+ export { Whiteboard, validateScene };
737
+ //# sourceMappingURL=index.js.map
738
+ //# sourceMappingURL=index.js.map