@snaptrude/plugin-core 0.3.0 → 0.6.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 (302) hide show
  1. package/AGENTS.md +130 -48
  2. package/CHANGELOG.md +163 -0
  3. package/api-manifest.full.json +5600 -0
  4. package/api-manifest.json +5502 -0
  5. package/dist/api/analysis/heatmaps.d.ts +234 -0
  6. package/dist/api/analysis/heatmaps.d.ts.map +1 -0
  7. package/dist/api/analysis/illuminance.d.ts +145 -0
  8. package/dist/api/analysis/illuminance.d.ts.map +1 -0
  9. package/dist/api/analysis/index.d.ts +44 -0
  10. package/dist/api/analysis/index.d.ts.map +1 -0
  11. package/dist/api/analysis/shadows.d.ts +165 -0
  12. package/dist/api/analysis/shadows.d.ts.map +1 -0
  13. package/dist/api/analysis/sunlightHours.d.ts +208 -0
  14. package/dist/api/analysis/sunlightHours.d.ts.map +1 -0
  15. package/dist/api/analysis/sunpath.d.ts +80 -0
  16. package/dist/api/analysis/sunpath.d.ts.map +1 -0
  17. package/dist/api/core/buildings.d.ts +427 -0
  18. package/dist/api/core/buildings.d.ts.map +1 -0
  19. package/dist/api/core/comment/index.d.ts +230 -0
  20. package/dist/api/core/comment/index.d.ts.map +1 -0
  21. package/dist/api/core/geom/create/index.d.ts +247 -0
  22. package/dist/api/core/geom/create/index.d.ts.map +1 -0
  23. package/dist/api/core/geom/delete/index.d.ts +72 -0
  24. package/dist/api/core/geom/delete/index.d.ts.map +1 -0
  25. package/dist/api/core/geom/index.d.ts +24 -23
  26. package/dist/api/core/geom/index.d.ts.map +1 -1
  27. package/dist/api/core/geom/query/arc.d.ts +169 -0
  28. package/dist/api/core/geom/query/arc.d.ts.map +1 -0
  29. package/dist/api/core/geom/query/brep.d.ts +402 -0
  30. package/dist/api/core/geom/query/brep.d.ts.map +1 -0
  31. package/dist/api/core/geom/query/circle.d.ts +378 -0
  32. package/dist/api/core/geom/query/circle.d.ts.map +1 -0
  33. package/dist/api/core/geom/query/contour.d.ts +450 -0
  34. package/dist/api/core/geom/query/contour.d.ts.map +1 -0
  35. package/dist/api/core/geom/query/curve.d.ts +918 -0
  36. package/dist/api/core/geom/query/curve.d.ts.map +1 -0
  37. package/dist/api/core/geom/query/edge.d.ts +128 -0
  38. package/dist/api/core/geom/query/edge.d.ts.map +1 -0
  39. package/dist/api/core/geom/query/face.d.ts +363 -0
  40. package/dist/api/core/geom/query/face.d.ts.map +1 -0
  41. package/dist/api/core/geom/query/halfedge.d.ts +206 -0
  42. package/dist/api/core/geom/query/halfedge.d.ts.map +1 -0
  43. package/dist/api/core/geom/query/index.d.ts +61 -0
  44. package/dist/api/core/geom/query/index.d.ts.map +1 -0
  45. package/dist/api/core/geom/query/profile.d.ts +410 -0
  46. package/dist/api/core/geom/query/profile.d.ts.map +1 -0
  47. package/dist/api/core/geom/query/vertex.d.ts +187 -0
  48. package/dist/api/core/geom/query/vertex.d.ts.map +1 -0
  49. package/dist/api/core/geom/update/contour.d.ts +272 -0
  50. package/dist/api/core/geom/update/contour.d.ts.map +1 -0
  51. package/dist/api/core/geom/update/curve.d.ts +180 -0
  52. package/dist/api/core/geom/update/curve.d.ts.map +1 -0
  53. package/dist/api/core/geom/update/index.d.ts +27 -0
  54. package/dist/api/core/geom/update/index.d.ts.map +1 -0
  55. package/dist/api/core/geom/update/profile.d.ts +329 -0
  56. package/dist/api/core/geom/update/profile.d.ts.map +1 -0
  57. package/dist/api/core/groups.d.ts +485 -0
  58. package/dist/api/core/groups.d.ts.map +1 -0
  59. package/dist/api/core/history/index.d.ts +78 -0
  60. package/dist/api/core/history/index.d.ts.map +1 -0
  61. package/dist/api/core/index.d.ts +51 -1
  62. package/dist/api/core/index.d.ts.map +1 -1
  63. package/dist/api/core/io/import/index.d.ts +392 -0
  64. package/dist/api/core/io/import/index.d.ts.map +1 -0
  65. package/dist/api/core/io/index.d.ts +35 -0
  66. package/dist/api/core/io/index.d.ts.map +1 -0
  67. package/dist/api/core/io/job/index.d.ts +139 -0
  68. package/dist/api/core/io/job/index.d.ts.map +1 -0
  69. package/dist/api/core/io/query/index.d.ts +74 -0
  70. package/dist/api/core/io/query/index.d.ts.map +1 -0
  71. package/dist/api/core/io/terrain/index.d.ts +206 -0
  72. package/dist/api/core/io/terrain/index.d.ts.map +1 -0
  73. package/dist/api/core/io/underlay/index.d.ts +286 -0
  74. package/dist/api/core/io/underlay/index.d.ts.map +1 -0
  75. package/dist/api/core/layers.d.ts +402 -0
  76. package/dist/api/core/layers.d.ts.map +1 -0
  77. package/dist/api/core/math/quat.d.ts +111 -128
  78. package/dist/api/core/math/quat.d.ts.map +1 -1
  79. package/dist/api/core/math/vec3.d.ts +120 -102
  80. package/dist/api/core/math/vec3.d.ts.map +1 -1
  81. package/dist/api/core/project/index.d.ts +399 -0
  82. package/dist/api/core/project/index.d.ts.map +1 -0
  83. package/dist/api/core/tags.d.ts +755 -0
  84. package/dist/api/core/tags.d.ts.map +1 -0
  85. package/dist/api/core/units/index.d.ts +175 -0
  86. package/dist/api/core/units/index.d.ts.map +1 -0
  87. package/dist/api/core/zoom/index.d.ts +45 -0
  88. package/dist/api/core/zoom/index.d.ts.map +1 -0
  89. package/dist/api/design/boolean/index.d.ts +168 -0
  90. package/dist/api/design/boolean/index.d.ts.map +1 -0
  91. package/dist/api/design/create/index.d.ts +837 -0
  92. package/dist/api/design/create/index.d.ts.map +1 -0
  93. package/dist/api/design/delete/index.d.ts +63 -0
  94. package/dist/api/design/delete/index.d.ts.map +1 -0
  95. package/dist/api/design/doors/index.d.ts +268 -0
  96. package/dist/api/design/doors/index.d.ts.map +1 -0
  97. package/dist/api/design/edit/index.d.ts +49 -0
  98. package/dist/api/design/edit/index.d.ts.map +1 -0
  99. package/dist/api/design/erase/index.d.ts +160 -0
  100. package/dist/api/design/erase/index.d.ts.map +1 -0
  101. package/dist/api/design/furniture/index.d.ts +123 -0
  102. package/dist/api/design/furniture/index.d.ts.map +1 -0
  103. package/dist/api/design/index.d.ts +153 -0
  104. package/dist/api/design/index.d.ts.map +1 -0
  105. package/dist/api/design/lock.d.ts +41 -0
  106. package/dist/api/design/lock.d.ts.map +1 -0
  107. package/dist/api/design/materials/index.d.ts +297 -0
  108. package/dist/api/design/materials/index.d.ts.map +1 -0
  109. package/dist/api/design/query/geometry/index.d.ts +140 -0
  110. package/dist/api/design/query/geometry/index.d.ts.map +1 -0
  111. package/dist/api/design/query/index.d.ts +1011 -0
  112. package/dist/api/design/query/index.d.ts.map +1 -0
  113. package/dist/api/design/query/spaces.d.ts +221 -0
  114. package/dist/api/design/query/spaces.d.ts.map +1 -0
  115. package/dist/api/design/selection/index.d.ts +282 -0
  116. package/dist/api/design/selection/index.d.ts.map +1 -0
  117. package/dist/api/design/shared.d.ts +38 -0
  118. package/dist/api/design/shared.d.ts.map +1 -0
  119. package/dist/api/design/transform/index.d.ts +87 -0
  120. package/dist/api/design/transform/index.d.ts.map +1 -0
  121. package/dist/api/design/update/index.d.ts +178 -0
  122. package/dist/api/design/update/index.d.ts.map +1 -0
  123. package/dist/api/design/windows/index.d.ts +189 -0
  124. package/dist/api/design/windows/index.d.ts.map +1 -0
  125. package/dist/api/entity/buildableEnvelope.d.ts +261 -0
  126. package/dist/api/entity/buildableEnvelope.d.ts.map +1 -0
  127. package/dist/api/entity/department.d.ts +0 -98
  128. package/dist/api/entity/department.d.ts.map +1 -1
  129. package/dist/api/entity/index.d.ts +9 -9
  130. package/dist/api/entity/index.d.ts.map +1 -1
  131. package/dist/api/entity/referenceLine.d.ts +49 -106
  132. package/dist/api/entity/referenceLine.d.ts.map +1 -1
  133. package/dist/api/entity/space.d.ts +484 -251
  134. package/dist/api/entity/space.d.ts.map +1 -1
  135. package/dist/api/entity/story.d.ts +49 -39
  136. package/dist/api/entity/story.d.ts.map +1 -1
  137. package/dist/api/index.d.ts +22 -12
  138. package/dist/api/index.d.ts.map +1 -1
  139. package/dist/api/presentation/aiInspiration.d.ts +440 -0
  140. package/dist/api/presentation/aiInspiration.d.ts.map +1 -0
  141. package/dist/api/presentation/diagrams.d.ts +81 -0
  142. package/dist/api/presentation/diagrams.d.ts.map +1 -0
  143. package/dist/api/presentation/import.d.ts +113 -0
  144. package/dist/api/presentation/import.d.ts.map +1 -0
  145. package/dist/api/presentation/index.d.ts +46 -0
  146. package/dist/api/presentation/index.d.ts.map +1 -0
  147. package/dist/api/presentation/sheets.d.ts +176 -0
  148. package/dist/api/presentation/sheets.d.ts.map +1 -0
  149. package/dist/api/presentation/views.d.ts +296 -0
  150. package/dist/api/presentation/views.d.ts.map +1 -0
  151. package/dist/api/program/adjacency.d.ts +155 -0
  152. package/dist/api/program/adjacency.d.ts.map +1 -0
  153. package/dist/api/program/areas.d.ts +360 -0
  154. package/dist/api/program/areas.d.ts.map +1 -0
  155. package/dist/api/program/classification.d.ts +135 -0
  156. package/dist/api/program/classification.d.ts.map +1 -0
  157. package/dist/api/program/cores.d.ts +174 -0
  158. package/dist/api/program/cores.d.ts.map +1 -0
  159. package/dist/api/program/departments.d.ts +431 -0
  160. package/dist/api/program/departments.d.ts.map +1 -0
  161. package/dist/api/program/index.d.ts +69 -0
  162. package/dist/api/program/index.d.ts.map +1 -0
  163. package/dist/api/program/layout.d.ts +63 -0
  164. package/dist/api/program/layout.d.ts.map +1 -0
  165. package/dist/api/program/metrics.d.ts +108 -0
  166. package/dist/api/program/metrics.d.ts.map +1 -0
  167. package/dist/api/program/site.d.ts +451 -0
  168. package/dist/api/program/site.d.ts.map +1 -0
  169. package/dist/api/program/spreadsheet.d.ts +2041 -0
  170. package/dist/api/program/spreadsheet.d.ts.map +1 -0
  171. package/dist/handles.d.ts +171 -0
  172. package/dist/handles.d.ts.map +1 -0
  173. package/dist/host-utils.d.ts +7 -5
  174. package/dist/host-utils.d.ts.map +1 -1
  175. package/dist/index.cjs +4344 -899
  176. package/dist/index.cjs.map +1 -1
  177. package/dist/index.d.ts +1 -0
  178. package/dist/index.d.ts.map +1 -1
  179. package/dist/index.js +3682 -865
  180. package/dist/index.js.map +1 -1
  181. package/package.json +6 -2
  182. package/scripts/generate-manifest.mjs +193 -0
  183. package/scripts/generate-manifest.test.mjs +215 -0
  184. package/src/api/analysis/heatmaps.ts +256 -0
  185. package/src/api/analysis/illuminance.ts +155 -0
  186. package/src/api/analysis/index.ts +46 -0
  187. package/src/api/analysis/shadows.ts +183 -0
  188. package/src/api/analysis/sunlightHours.ts +211 -0
  189. package/src/api/analysis/sunpath.ts +83 -0
  190. package/src/api/core/buildings.ts +485 -0
  191. package/src/api/core/comment/index.ts +258 -0
  192. package/src/api/core/geom/create/index.ts +293 -0
  193. package/src/api/core/geom/delete/index.ts +78 -0
  194. package/src/api/core/geom/index.ts +24 -23
  195. package/src/api/core/geom/query/arc.ts +169 -0
  196. package/src/api/core/geom/query/brep.ts +444 -0
  197. package/src/api/core/geom/query/circle.ts +404 -0
  198. package/src/api/core/geom/query/contour.ts +540 -0
  199. package/src/api/core/geom/query/curve.ts +1078 -0
  200. package/src/api/core/geom/query/edge.ts +130 -0
  201. package/src/api/core/geom/query/face.ts +403 -0
  202. package/src/api/core/geom/query/halfedge.ts +210 -0
  203. package/src/api/core/geom/query/index.ts +63 -0
  204. package/src/api/core/geom/query/profile.ts +473 -0
  205. package/src/api/core/geom/query/vertex.ts +205 -0
  206. package/src/api/core/geom/update/contour.ts +315 -0
  207. package/src/api/core/geom/update/curve.ts +209 -0
  208. package/src/api/core/geom/update/index.ts +29 -0
  209. package/src/api/core/geom/update/profile.ts +377 -0
  210. package/src/api/core/groups.ts +521 -0
  211. package/src/api/core/history/index.ts +84 -0
  212. package/src/api/core/index.ts +51 -1
  213. package/src/api/core/io/import/index.ts +432 -0
  214. package/src/api/core/io/index.ts +37 -0
  215. package/src/api/core/io/job/index.ts +140 -0
  216. package/src/api/core/io/query/index.ts +71 -0
  217. package/src/api/core/io/terrain/index.ts +214 -0
  218. package/src/api/core/io/underlay/index.ts +295 -0
  219. package/src/api/core/layers.ts +333 -0
  220. package/src/api/core/math/quat.ts +112 -235
  221. package/src/api/core/math/vec3.ts +124 -159
  222. package/src/api/core/project/index.ts +418 -0
  223. package/src/api/core/tags.ts +808 -0
  224. package/src/api/core/units/index.ts +164 -0
  225. package/src/api/core/zoom/index.ts +47 -0
  226. package/src/api/design/boolean/index.ts +179 -0
  227. package/src/api/design/create/index.ts +895 -0
  228. package/src/api/design/delete/index.ts +67 -0
  229. package/src/api/design/doors/index.ts +285 -0
  230. package/src/api/design/edit/index.ts +54 -0
  231. package/src/api/design/erase/index.ts +151 -0
  232. package/src/api/design/furniture/index.ts +130 -0
  233. package/src/api/design/index.ts +162 -0
  234. package/src/api/design/lock.ts +42 -0
  235. package/src/api/design/materials/index.ts +301 -0
  236. package/src/api/design/query/geometry/index.ts +166 -0
  237. package/src/api/design/query/index.ts +937 -0
  238. package/src/api/design/query/spaces.ts +132 -0
  239. package/src/api/design/selection/index.ts +273 -0
  240. package/src/api/design/shared.ts +40 -0
  241. package/src/api/design/transform/index.ts +93 -0
  242. package/src/api/design/update/index.ts +117 -0
  243. package/src/api/design/windows/index.ts +207 -0
  244. package/src/api/entity/buildableEnvelope.ts +318 -0
  245. package/src/api/entity/department.ts +0 -113
  246. package/src/api/entity/index.ts +9 -9
  247. package/src/api/entity/referenceLine.ts +50 -38
  248. package/src/api/entity/space.ts +285 -226
  249. package/src/api/entity/story.ts +53 -42
  250. package/src/api/index.ts +22 -12
  251. package/src/api/presentation/aiInspiration.ts +362 -0
  252. package/src/api/presentation/diagrams.ts +84 -0
  253. package/src/api/presentation/import.ts +112 -0
  254. package/src/api/presentation/index.ts +48 -0
  255. package/src/api/presentation/sheets.ts +198 -0
  256. package/src/api/presentation/views.ts +303 -0
  257. package/src/api/program/adjacency.ts +164 -0
  258. package/src/api/program/areas.ts +335 -0
  259. package/src/api/program/classification.ts +138 -0
  260. package/src/api/program/cores.ts +171 -0
  261. package/src/api/program/departments.ts +465 -0
  262. package/src/api/program/index.ts +71 -0
  263. package/src/api/program/layout.ts +68 -0
  264. package/src/api/program/metrics.ts +120 -0
  265. package/src/api/program/site.ts +419 -0
  266. package/src/api/program/spreadsheet.ts +2075 -0
  267. package/src/handles.ts +194 -0
  268. package/src/host-utils.ts +10 -6
  269. package/src/index.ts +1 -0
  270. package/dist/api/core/geom/arc.d.ts +0 -81
  271. package/dist/api/core/geom/arc.d.ts.map +0 -1
  272. package/dist/api/core/geom/curve.d.ts +0 -70
  273. package/dist/api/core/geom/curve.d.ts.map +0 -1
  274. package/dist/api/core/geom/line.d.ts +0 -56
  275. package/dist/api/core/geom/line.d.ts.map +0 -1
  276. package/dist/api/core/geom/profile.d.ts +0 -121
  277. package/dist/api/core/geom/profile.d.ts.map +0 -1
  278. package/dist/api/tools/copy.d.ts +0 -59
  279. package/dist/api/tools/copy.d.ts.map +0 -1
  280. package/dist/api/tools/index.d.ts +0 -33
  281. package/dist/api/tools/index.d.ts.map +0 -1
  282. package/dist/api/tools/material.d.ts +0 -51
  283. package/dist/api/tools/material.d.ts.map +0 -1
  284. package/dist/api/tools/offset.d.ts +0 -43
  285. package/dist/api/tools/offset.d.ts.map +0 -1
  286. package/dist/api/tools/selection.d.ts +0 -48
  287. package/dist/api/tools/selection.d.ts.map +0 -1
  288. package/dist/api/tools/transform.d.ts +0 -114
  289. package/dist/api/tools/transform.d.ts.map +0 -1
  290. package/dist/api/units/index.d.ts +0 -163
  291. package/dist/api/units/index.d.ts.map +0 -1
  292. package/src/api/core/geom/arc.ts +0 -70
  293. package/src/api/core/geom/curve.ts +0 -41
  294. package/src/api/core/geom/line.ts +0 -53
  295. package/src/api/core/geom/profile.ts +0 -94
  296. package/src/api/tools/copy.ts +0 -55
  297. package/src/api/tools/index.ts +0 -39
  298. package/src/api/tools/material.ts +0 -49
  299. package/src/api/tools/offset.ts +0 -43
  300. package/src/api/tools/selection.ts +0 -51
  301. package/src/api/tools/transform.ts +0 -117
  302. package/src/api/units/index.ts +0 -163
@@ -1,187 +1,170 @@
1
- import * as z from "zod";
2
- import type { PVec3 } from "./vec3";
1
+ import { PluginApiReturn } from "../../../types";
2
+ import { Vec3Handle, QuatHandle, QuatComponents } from "../../../handles";
3
3
  /**
4
- * Quaternion operations for 3D rotations.
4
+ * Quaternion operations (all-handle model, §11).
5
5
  *
6
- * Quaternions avoid gimbal lock and provide smooth interpolation
7
- * compared to Euler angles. All methods are **pure** — they return
8
- * new {@linkcode PQuat} values without mutating the inputs.
9
- *
10
- * Accessed via `snaptrude.core.math.quat`.
6
+ * Quaternions are opaque {@linkcode QuatHandle}s; every operation is a host call
7
+ * returning a new handle. Read primitive components back with
8
+ * {@linkcode PluginQuatApi.components}. Accessed via `snaptrude.core.math.quat`.
11
9
  */
12
10
  export declare abstract class PluginQuatApi {
13
11
  constructor();
14
12
  /**
15
- * Create a new quaternion from raw components.
16
- *
17
- * For most use cases prefer {@linkcode PluginQuatApi.fromAxisAngle}
18
- * or {@linkcode PluginQuatApi.fromEuler} instead.
13
+ * Create a quaternion from primitive components.
19
14
  *
20
- * @param x - The X component
21
- * @param y - The Y component
22
- * @param z - The Z component
23
- * @param w - The W (scalar) component
24
- * @returns A new {@linkcode PQuat}
15
+ * # Example
16
+ * ```ts
17
+ * const q = await snaptrude.core.math.quat.new(0, 0, 0, 1)
18
+ * const { x, y, z, w } = await snaptrude.core.math.quat.components(q)
19
+ * ```
25
20
  */
26
- new(x: number, y: number, z: number, w: number): PQuat;
21
+ abstract new(x: number, y: number, z: number, w: number): PluginApiReturn<QuatHandle>;
27
22
  /**
28
- * Create an identity quaternion representing no rotation.
23
+ * Return the identity quaternion (no rotation).
29
24
  *
30
- * @returns `{ x: 0, y: 0, z: 0, w: 1 }`
25
+ * # Example
26
+ * ```ts
27
+ * const noRotation = await snaptrude.core.math.quat.identity()
28
+ * ```
31
29
  */
32
- identity(): PQuat;
30
+ abstract identity(): PluginApiReturn<QuatHandle>;
33
31
  /**
34
- * Create a quaternion from an axis and an angle.
35
- *
36
- * @param axis - The rotation axis as a {@linkcode PVec3} (will be normalized internally)
37
- * @param angle - The rotation angle in **radians**
38
- * @returns A new unit {@linkcode PQuat}, or identity if {@linkcode axis} has zero length
32
+ * Build a quaternion from a rotation axis and an angle in radians.
39
33
  *
40
34
  * # Example
41
35
  * ```ts
42
- * const { vec3, quat } = snaptrude.core.math
43
- * // 90° rotation around the Y axis
44
- * const rot = quat.fromAxisAngle(vec3.new(0, 1, 0), Math.PI / 2)
36
+ * const axis = await snaptrude.core.math.vec3.new(0, 0, 1)
37
+ * const quarterTurn = await snaptrude.core.math.quat.fromAxisAngle(axis, Math.PI / 2)
45
38
  * ```
46
39
  */
47
- fromAxisAngle(axis: PVec3, angle: number): PQuat;
40
+ abstract fromAxisAngle(axis: Vec3Handle, angle: number): PluginApiReturn<QuatHandle>;
48
41
  /**
49
- * Create a quaternion from Euler angles in **XYZ** rotation order.
42
+ * Build a quaternion from Euler angles in radians.
50
43
  *
51
- * @param x - Rotation around X axis in **radians**
52
- * @param y - Rotation around Y axis in **radians**
53
- * @param z - Rotation around Z axis in **radians**
54
- * @returns A new {@linkcode PQuat}
44
+ * # Example
45
+ * ```ts
46
+ * const q = await snaptrude.core.math.quat.fromEuler(0, Math.PI / 2, 0)
47
+ * ```
55
48
  */
56
- fromEuler(x: number, y: number, z: number): PQuat;
49
+ abstract fromEuler(x: number, y: number, z: number): PluginApiReturn<QuatHandle>;
57
50
  /**
58
- * Multiply two quaternions, combining their rotations.
51
+ * Compose two rotations with the Hamilton product `a * b` (apply `b` then `a`).
59
52
  *
60
- * Quaternion multiplication is **not commutative**: `a * b ≠ b * a`.
61
- * The result applies rotation {@linkcode b} first, then {@linkcode a}.
62
- *
63
- * @param a - First quaternion (applied second)
64
- * @param b - Second quaternion (applied first)
65
- * @returns A new {@linkcode PQuat} representing the combined rotation
53
+ * # Example
54
+ * ```ts
55
+ * const a = await snaptrude.core.math.quat.fromEuler(0, Math.PI / 2, 0)
56
+ * const b = await snaptrude.core.math.quat.fromEuler(Math.PI / 4, 0, 0)
57
+ * const combined = await snaptrude.core.math.quat.multiply(a, b) // b first, then a
58
+ * ```
66
59
  */
67
- multiply(a: PQuat, b: PQuat): PQuat;
60
+ abstract multiply(a: QuatHandle, b: QuatHandle): PluginApiReturn<QuatHandle>;
68
61
  /**
69
- * Compute the conjugate of a quaternion.
70
- *
71
- * For unit quaternions the conjugate equals the inverse.
62
+ * Compute the conjugate of a quaternion (negated vector part).
72
63
  *
73
- * @param q - The quaternion
74
- * @returns A new {@linkcode PQuat} with negated vector part `(-x, -y, -z, w)`
64
+ * # Example
65
+ * ```ts
66
+ * const q = await snaptrude.core.math.quat.fromEuler(0, Math.PI / 4, 0)
67
+ * const conj = await snaptrude.core.math.quat.conjugate(q)
68
+ * ```
75
69
  */
76
- conjugate(q: PQuat): PQuat;
70
+ abstract conjugate(q: QuatHandle): PluginApiReturn<QuatHandle>;
77
71
  /**
78
- * Compute the length (magnitude) of a quaternion.
72
+ * Compute the magnitude (norm) of a quaternion.
79
73
  *
80
- * @param q - The quaternion
81
- * @returns The magnitude `√(x² + y² + z² + w²)`
74
+ * # Example
75
+ * ```ts
76
+ * const q = await snaptrude.core.math.quat.new(0, 0, 0, 1)
77
+ * const len = await snaptrude.core.math.quat.length(q) // 1
78
+ * ```
82
79
  */
83
- length(q: PQuat): number;
80
+ abstract length(q: QuatHandle): PluginApiReturn<number>;
84
81
  /**
85
82
  * Normalize a quaternion to unit length.
86
83
  *
87
- * @param q - The quaternion to normalize
88
- * @returns A new unit-length {@linkcode PQuat}, or identity if the input has zero length
89
- */
90
- normalize(q: PQuat): PQuat;
91
- /**
92
- * Compute the inverse of a quaternion.
93
- *
94
- * The inverse satisfies `q * inverse(q) = identity`.
95
- *
96
- * @param q - The quaternion to invert
97
- * @returns A new {@linkcode PQuat} that is the multiplicative inverse,
98
- * or identity if the input has zero length
84
+ * # Example
85
+ * ```ts
86
+ * const q = await snaptrude.core.math.quat.new(0, 0, 1, 1)
87
+ * const unit = await snaptrude.core.math.quat.normalize(q)
88
+ * ```
99
89
  */
100
- inverse(q: PQuat): PQuat;
90
+ abstract normalize(q: QuatHandle): PluginApiReturn<QuatHandle>;
101
91
  /**
102
- * Rotate a 3D vector by a quaternion.
103
- *
104
- * Computes `q * v * conjugate(q)` using the Hamilton product.
105
- *
106
- * @param q - The rotation quaternion (should be unit-length)
107
- * @param v - The vector to rotate as a {@linkcode PVec3}
108
- * @returns A new rotated {@linkcode PVec3}
92
+ * Compute the inverse quaternion the rotation that undoes `q`.
109
93
  *
110
94
  * # Example
111
95
  * ```ts
112
- * const { vec3, quat } = snaptrude.core.math
113
- * const rot = quat.fromAxisAngle(vec3.new(0, 1, 0), Math.PI / 2)
114
- * const rotated = quat.rotateVec3(rot, vec3.new(1, 0, 0))
115
- * // ≈ { x: 0, y: 0, z: -1 }
96
+ * const q = await snaptrude.core.math.quat.fromEuler(0, Math.PI / 2, 0)
97
+ * const undo = await snaptrude.core.math.quat.inverse(q)
116
98
  * ```
117
99
  */
118
- rotateVec3(q: PQuat, v: PVec3): PVec3;
100
+ abstract inverse(q: QuatHandle): PluginApiReturn<QuatHandle>;
119
101
  /**
120
- * Convert a quaternion to axis-angle representation.
102
+ * Decompose a quaternion into its rotation axis and angle (radians).
121
103
  *
122
- * @param q - The quaternion to convert
123
- * @returns An object with:
124
- * - `axis` The rotation axis as a unit {@linkcode PVec3}
125
- * (defaults to `(1, 0, 0)` when angle is zero)
126
- * - `angle` The rotation angle in **radians**
104
+ * # Example
105
+ * ```ts
106
+ * const q = await snaptrude.core.math.quat.fromEuler(0, Math.PI / 3, 0)
107
+ * const { axis, angle } = await snaptrude.core.math.quat.toAxisAngle(q)
108
+ * const { x, y, z } = await snaptrude.core.math.vec3.components(axis)
109
+ * ```
127
110
  */
128
- toAxisAngle(q: PQuat): {
129
- axis: PVec3;
111
+ abstract toAxisAngle(q: QuatHandle): PluginApiReturn<{
112
+ axis: Vec3Handle;
130
113
  angle: number;
131
- };
114
+ }>;
132
115
  /**
133
- * Spherical linear interpolation between two quaternions.
134
- *
135
- * Produces smooth constant-speed rotation between {@linkcode a} and {@linkcode b}.
116
+ * Spherically interpolate (slerp) between two rotations by factor `t`.
136
117
  *
137
- * @param a - Start quaternion (returned when `t = 0`)
138
- * @param b - End quaternion (returned when `t = 1`)
139
- * @param t - Interpolation factor, typically in `[0, 1]`
140
- * @returns A new interpolated {@linkcode PQuat}
118
+ * # Example
119
+ * ```ts
120
+ * const start = await snaptrude.core.math.quat.identity()
121
+ * const end = await snaptrude.core.math.quat.fromEuler(0, Math.PI, 0)
122
+ * const halfway = await snaptrude.core.math.quat.slerp(start, end, 0.5)
123
+ * ```
141
124
  */
142
- slerp(a: PQuat, b: PQuat, t: number): PQuat;
125
+ abstract slerp(a: QuatHandle, b: QuatHandle, t: number): PluginApiReturn<QuatHandle>;
143
126
  /**
144
127
  * Compute the dot product of two quaternions.
145
128
  *
146
- * A value close to `1` or `-1` indicates similar orientations;
147
- * a value close to `0` indicates maximally different orientations.
148
- *
149
- * @param a - First quaternion
150
- * @param b - Second quaternion
151
- * @returns The scalar dot product
129
+ * # Example
130
+ * ```ts
131
+ * const a = await snaptrude.core.math.quat.identity()
132
+ * const b = await snaptrude.core.math.quat.fromEuler(0, Math.PI / 2, 0)
133
+ * const d = await snaptrude.core.math.quat.dot(a, b)
134
+ * ```
152
135
  */
153
- dot(a: PQuat, b: PQuat): number;
136
+ abstract dot(a: QuatHandle, b: QuatHandle): PluginApiReturn<number>;
154
137
  /**
155
- * Check if two quaternions are exactly equal (strict equality per component).
138
+ * Test whether two quaternions have exactly equal components.
156
139
  *
157
- * For floating-point comparisons, prefer {@linkcode PluginQuatApi.equalsApprox}.
140
+ * # Example
141
+ * ```ts
142
+ * const a = await snaptrude.core.math.quat.new(0, 0, 0, 1)
143
+ * const b = await snaptrude.core.math.quat.identity()
144
+ * const same = await snaptrude.core.math.quat.equals(a, b) // true
145
+ * ```
146
+ */
147
+ abstract equals(a: QuatHandle, b: QuatHandle): PluginApiReturn<boolean>;
148
+ /**
149
+ * Test whether two quaternions are equal within a tolerance `epsilon` (default `1e-6`).
158
150
  *
159
- * @param a - First quaternion
160
- * @param b - Second quaternion
161
- * @returns `true` if all components match exactly
151
+ * # Example
152
+ * ```ts
153
+ * const a = await snaptrude.core.math.quat.fromEuler(0, Math.PI / 2, 0)
154
+ * const b = await snaptrude.core.math.quat.fromEuler(0, 1.5711, 0)
155
+ * const close = await snaptrude.core.math.quat.equalsApprox(a, b, 1e-3) // true
156
+ * ```
162
157
  */
163
- equals(a: PQuat, b: PQuat): boolean;
158
+ abstract equalsApprox(a: QuatHandle, b: QuatHandle, epsilon?: number): PluginApiReturn<boolean>;
164
159
  /**
165
- * Check if two quaternions are approximately equal within a tolerance.
160
+ * Read the primitive `{ x, y, z, w }` components of a quaternion handle.
166
161
  *
167
- * @param a - First quaternion
168
- * @param b - Second quaternion
169
- * @param epsilon - Maximum allowed difference per component (default `1e-6`)
170
- * @returns `true` if `|a[i] - b[i]| < epsilon` for all components
162
+ * # Example
163
+ * ```ts
164
+ * const q = await snaptrude.core.math.quat.fromEuler(0, Math.PI / 2, 0)
165
+ * const { x, y, z, w } = await snaptrude.core.math.quat.components(q)
166
+ * ```
171
167
  */
172
- equalsApprox(a: PQuat, b: PQuat, epsilon?: number): boolean;
168
+ abstract components(q: QuatHandle): PluginApiReturn<QuatComponents>;
173
169
  }
174
- /**
175
- * A quaternion with `x`, `y`, `z`, and `w` components.
176
- *
177
- * Used for representing 3D rotations without gimbal lock.
178
- * Equivalent to `BABYLON.Quaternion`.
179
- */
180
- export declare const PQuat: z.ZodObject<{
181
- x: z.ZodNumber;
182
- y: z.ZodNumber;
183
- z: z.ZodNumber;
184
- w: z.ZodNumber;
185
- }, z.core.$strip>;
186
- export type PQuat = z.infer<typeof PQuat>;
187
170
  //# sourceMappingURL=quat.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"quat.d.ts","sourceRoot":"","sources":["../../../../src/api/core/math/quat.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AACxB,OAAO,KAAK,EAAE,KA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AAC;CACpE"}
@@ -1,156 +1,174 @@
1
- import * as z from "zod";
1
+ import { PluginApiReturn } from "../../../types";
2
+ import { Vec3Handle, Vec3Components } from "../../../handles";
2
3
  /**
3
- * 3D vector operations for positions, directions, and displacements.
4
+ * 3D vector operations (all-handle model, §11).
4
5
  *
5
- * All methods are **pure** — they return new {@linkcode PVec3} values
6
- * without mutating the inputs.
7
- *
8
- * Accessed via `snaptrude.core.math.vec3`.
6
+ * Vectors are opaque {@linkcode Vec3Handle}s; every operation is a host call
7
+ * returning a new handle (vectors are immutable). Read primitive components back
8
+ * with {@linkcode PluginVec3Api.components}. Accessed via `snaptrude.core.math.vec3`.
9
9
  */
10
10
  export declare abstract class PluginVec3Api {
11
11
  constructor();
12
12
  /**
13
- * Create a new 3D vector.
14
- *
15
- * @param x - The X component
16
- * @param y - The Y component
17
- * @param z - The Z component
18
- * @returns A new {@linkcode PVec3}
13
+ * Create a vector from primitive components.
19
14
  *
20
15
  * # Example
21
16
  * ```ts
22
- * const position = snaptrude.core.math.vec3.new(1, 2, 3)
23
- * // { x: 1, y: 2, z: 3 }
17
+ * const v = await snaptrude.core.math.vec3.new(10, 0, 5)
18
+ * const { x, y, z } = await snaptrude.core.math.vec3.components(v)
24
19
  * ```
25
20
  */
26
- new(x: number, y: number, z: number): PVec3;
21
+ abstract new(x: number, y: number, z: number): PluginApiReturn<Vec3Handle>;
27
22
  /**
28
- * Add two vectors component-wise.
23
+ * Add two vectors component-wise (`a + b`).
29
24
  *
30
- * @param a - First vector
31
- * @param b - Second vector
32
- * @returns A new {@linkcode PVec3} where each component is `a[i] + b[i]`
25
+ * # Example
26
+ * ```ts
27
+ * const a = await snaptrude.core.math.vec3.new(1, 0, 0)
28
+ * const b = await snaptrude.core.math.vec3.new(0, 1, 0)
29
+ * const sum = await snaptrude.core.math.vec3.add(a, b)
30
+ * ```
33
31
  */
34
- add(a: PVec3, b: PVec3): PVec3;
32
+ abstract add(a: Vec3Handle, b: Vec3Handle): PluginApiReturn<Vec3Handle>;
35
33
  /**
36
- * Subtract vector {@linkcode b} from vector {@linkcode a} component-wise.
34
+ * Subtract vector `b` from `a` component-wise (`a - b`).
37
35
  *
38
- * @param a - Vector to subtract from
39
- * @param b - Vector to subtract
40
- * @returns A new {@linkcode PVec3} where each component is `a[i] - b[i]`
36
+ * # Example
37
+ * ```ts
38
+ * const a = await snaptrude.core.math.vec3.new(3, 2, 1)
39
+ * const b = await snaptrude.core.math.vec3.new(1, 1, 1)
40
+ * const diff = await snaptrude.core.math.vec3.subtract(a, b)
41
+ * ```
41
42
  */
42
- subtract(a: PVec3, b: PVec3): PVec3;
43
+ abstract subtract(a: Vec3Handle, b: Vec3Handle): PluginApiReturn<Vec3Handle>;
43
44
  /**
44
- * Scale a vector by a scalar value.
45
+ * Scale `v` by a scalar.
45
46
  *
46
- * @param v - The vector to scale
47
- * @param scalar - The scalar multiplier
48
- * @returns A new {@linkcode PVec3} where each component is `v[i] * scalar`
47
+ * # Example
48
+ * ```ts
49
+ * const v = await snaptrude.core.math.vec3.new(1, 2, 3)
50
+ * const doubled = await snaptrude.core.math.vec3.scale(v, 2)
51
+ * ```
49
52
  */
50
- scale(v: PVec3, scalar: number): PVec3;
53
+ abstract scale(v: Vec3Handle, scalar: number): PluginApiReturn<Vec3Handle>;
51
54
  /**
52
55
  * Compute the dot product of two vectors.
53
56
  *
54
- * The dot product equals `|a| * |b| * cos(θ)` where `θ` is the angle
55
- * between the vectors. Useful for checking orthogonality (result = 0)
56
- * or projection.
57
- *
58
- * @param a - First vector
59
- * @param b - Second vector
60
- * @returns The scalar dot product
57
+ * # Example
58
+ * ```ts
59
+ * const a = await snaptrude.core.math.vec3.new(1, 0, 0)
60
+ * const b = await snaptrude.core.math.vec3.new(0.5, 0.5, 0)
61
+ * const d = await snaptrude.core.math.vec3.dot(a, b) // 0.5
62
+ * ```
61
63
  */
62
- dot(a: PVec3, b: PVec3): number;
64
+ abstract dot(a: Vec3Handle, b: Vec3Handle): PluginApiReturn<number>;
63
65
  /**
64
- * Compute the cross product of two vectors.
65
- *
66
- * The result is a vector perpendicular to both inputs, with magnitude
67
- * equal to the area of the parallelogram they span. Useful for computing
68
- * surface normals.
66
+ * Compute the cross product `a × b` — the vector perpendicular to both.
69
67
  *
70
- * @param a - First vector
71
- * @param b - Second vector
72
- * @returns A new {@linkcode PVec3} perpendicular to both {@linkcode a} and {@linkcode b}
68
+ * # Example
69
+ * ```ts
70
+ * const a = await snaptrude.core.math.vec3.new(1, 0, 0)
71
+ * const b = await snaptrude.core.math.vec3.new(0, 1, 0)
72
+ * const perpendicular = await snaptrude.core.math.vec3.cross(a, b)
73
+ * ```
73
74
  */
74
- cross(a: PVec3, b: PVec3): PVec3;
75
+ abstract cross(a: Vec3Handle, b: Vec3Handle): PluginApiReturn<Vec3Handle>;
75
76
  /**
76
- * Compute the length (magnitude) of a vector.
77
+ * Compute the Euclidean length (magnitude) of a vector.
77
78
  *
78
- * @param v - The vector
79
- * @returns The Euclidean length `√(x² + y² + z²)`
79
+ * # Example
80
+ * ```ts
81
+ * const v = await snaptrude.core.math.vec3.new(3, 4, 0)
82
+ * const len = await snaptrude.core.math.vec3.length(v) // 5
83
+ * ```
80
84
  */
81
- length(v: PVec3): number;
85
+ abstract length(v: Vec3Handle): PluginApiReturn<number>;
82
86
  /**
83
- * Compute the squared length of a vector.
84
- *
85
- * Avoids the `sqrt` call — prefer this over {@linkcode PluginVec3Api.length}
86
- * when comparing relative magnitudes.
87
+ * Compute the squared Euclidean length of a vector (avoids the sqrt).
87
88
  *
88
- * @param v - The vector
89
- * @returns The squared length `x² + y² + z²`
89
+ * # Example
90
+ * ```ts
91
+ * const v = await snaptrude.core.math.vec3.new(3, 4, 0)
92
+ * const sq = await snaptrude.core.math.vec3.lengthSquared(v) // 25
93
+ * ```
90
94
  */
91
- lengthSquared(v: PVec3): number;
95
+ abstract lengthSquared(v: Vec3Handle): PluginApiReturn<number>;
92
96
  /**
93
- * Normalize a vector to unit length.
97
+ * Return the unit vector in the same direction (the zero vector if length is 0).
94
98
  *
95
- * @param v - The vector to normalize
96
- * @returns A new unit-length {@linkcode PVec3} in the same direction,
97
- * or a zero vector `(0, 0, 0)` if the input has zero length
99
+ * # Example
100
+ * ```ts
101
+ * const v = await snaptrude.core.math.vec3.new(0, 0, 10)
102
+ * const unit = await snaptrude.core.math.vec3.normalize(v) // (0, 0, 1)
103
+ * ```
98
104
  */
99
- normalize(v: PVec3): PVec3;
105
+ abstract normalize(v: Vec3Handle): PluginApiReturn<Vec3Handle>;
100
106
  /**
101
- * Compute the Euclidean distance between two points.
107
+ * Measure the straight-line (Euclidean) distance between two points.
102
108
  *
103
- * @param a - First point
104
- * @param b - Second point
105
- * @returns The distance `|a - b|`
109
+ * @examplePrompt What is the distance between these two points?
110
+ * @examplePrompt Measure how far apart these two points are
111
+ *
112
+ * # Example
113
+ * ```ts
114
+ * const a = await snaptrude.core.math.vec3.new(0, 0, 0)
115
+ * const b = await snaptrude.core.math.vec3.new(3, 4, 0)
116
+ * const dist = await snaptrude.core.math.vec3.distance(a, b) // 5
117
+ * ```
106
118
  */
107
- distance(a: PVec3, b: PVec3): number;
119
+ abstract distance(a: Vec3Handle, b: Vec3Handle): PluginApiReturn<number>;
108
120
  /**
109
- * Linearly interpolate between two vectors.
121
+ * Linearly interpolate between two vectors: `a + (b - a) * t`.
110
122
  *
111
- * @param a - Start vector (returned when `t = 0`)
112
- * @param b - End vector (returned when `t = 1`)
113
- * @param t - Interpolation factor, typically in `[0, 1]`
114
- * @returns A new {@linkcode PVec3} at `a + (b - a) * t`
123
+ * # Example
124
+ * ```ts
125
+ * const a = await snaptrude.core.math.vec3.new(0, 0, 0)
126
+ * const b = await snaptrude.core.math.vec3.new(10, 0, 0)
127
+ * const midpoint = await snaptrude.core.math.vec3.lerp(a, b, 0.5)
128
+ * ```
115
129
  */
116
- lerp(a: PVec3, b: PVec3, t: number): PVec3;
130
+ abstract lerp(a: Vec3Handle, b: Vec3Handle, t: number): PluginApiReturn<Vec3Handle>;
117
131
  /**
118
- * Negate a vector (reverse its direction).
132
+ * Negate a vector, reversing its direction.
119
133
  *
120
- * @param v - The vector to negate
121
- * @returns A new {@linkcode PVec3} with all components negated
134
+ * # Example
135
+ * ```ts
136
+ * const v = await snaptrude.core.math.vec3.new(1, -2, 3)
137
+ * const reversed = await snaptrude.core.math.vec3.negate(v) // (-1, 2, -3)
138
+ * ```
122
139
  */
123
- negate(v: PVec3): PVec3;
140
+ abstract negate(v: Vec3Handle): PluginApiReturn<Vec3Handle>;
124
141
  /**
125
- * Check if two vectors are exactly equal (strict equality per component).
142
+ * Test whether two vectors have exactly equal components.
126
143
  *
127
- * For floating-point comparisons, prefer {@linkcode PluginVec3Api.equalsApprox}.
144
+ * # Example
145
+ * ```ts
146
+ * const a = await snaptrude.core.math.vec3.new(1, 2, 3)
147
+ * const b = await snaptrude.core.math.vec3.new(1, 2, 3)
148
+ * const same = await snaptrude.core.math.vec3.equals(a, b) // true
149
+ * ```
150
+ */
151
+ abstract equals(a: Vec3Handle, b: Vec3Handle): PluginApiReturn<boolean>;
152
+ /**
153
+ * Test whether two vectors are equal within a tolerance `epsilon` (default `1e-6`).
128
154
  *
129
- * @param a - First vector
130
- * @param b - Second vector
131
- * @returns `true` if all components match exactly
155
+ * # Example
156
+ * ```ts
157
+ * const a = await snaptrude.core.math.vec3.new(1, 2, 3)
158
+ * const b = await snaptrude.core.math.vec3.new(1.0004, 2, 3)
159
+ * const close = await snaptrude.core.math.vec3.equalsApprox(a, b, 1e-3) // true
160
+ * ```
132
161
  */
133
- equals(a: PVec3, b: PVec3): boolean;
162
+ abstract equalsApprox(a: Vec3Handle, b: Vec3Handle, epsilon?: number): PluginApiReturn<boolean>;
134
163
  /**
135
- * Check if two vectors are approximately equal within a tolerance.
164
+ * Read the primitive `{ x, y, z }` components of a vector handle.
136
165
  *
137
- * @param a - First vector
138
- * @param b - Second vector
139
- * @param epsilon - Maximum allowed difference per component (default `1e-6`)
140
- * @returns `true` if `|a[i] - b[i]| < epsilon` for all components
166
+ * # Example
167
+ * ```ts
168
+ * const v = await snaptrude.core.math.vec3.new(1, 2, 3)
169
+ * const { x, y, z } = await snaptrude.core.math.vec3.components(v)
170
+ * ```
141
171
  */
142
- equalsApprox(a: PVec3, b: PVec3, epsilon?: number): boolean;
172
+ abstract components(v: Vec3Handle): PluginApiReturn<Vec3Components>;
143
173
  }
144
- /**
145
- * A 3D vector with `x`, `y`, and `z` components.
146
- *
147
- * Used throughout the plugin API for positions, directions, displacements,
148
- * and Euler rotation angles. Equivalent to `BABYLON.Vector3`.
149
- */
150
- export declare const PVec3: z.ZodObject<{
151
- x: z.ZodNumber;
152
- y: z.ZodNumber;
153
- z: z.ZodNumber;
154
- }, z.core.$strip>;
155
- export type PVec3 = z.infer<typeof PVec3>;
156
174
  //# sourceMappingURL=vec3.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"vec3.d.ts","sourceRoot":"","sources":["../../../../src/api/core/math/vec3.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAExB;;;;;;;GAOG;AACH,8BAAsB,aAAa;;IAGjC;;;;;;;;;;;;;OAaG;IACH,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,KAAK;IAI3C;;;;;;OAMG;IACH,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,GAAG,KAAK;IAI9B;;;;;;OAMG;IACH,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,GAAG,KAAK;IAInC;;;;;;OAMG;IACH,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,GAAG,KAAK;IAItC;;;;;;;;;;OAUG;IACH,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,GAAG,MAAM;IAI/B;;;;;;;;;;OAUG;IACH,KAAK,CAAC,CAAC,EAAE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