@mathscan/geometry-engine 0.1.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 (380) hide show
  1. package/README.md +1101 -0
  2. package/dist/coordinates/grid.d.cts +8 -0
  3. package/dist/coordinates/grid.d.ts +9 -0
  4. package/dist/coordinates/grid.d.ts.map +1 -0
  5. package/dist/coordinates/lineClipping.d.cts +3 -0
  6. package/dist/coordinates/lineClipping.d.ts +4 -0
  7. package/dist/coordinates/lineClipping.d.ts.map +1 -0
  8. package/dist/coordinates/transform.d.cts +18 -0
  9. package/dist/coordinates/transform.d.ts +19 -0
  10. package/dist/coordinates/transform.d.ts.map +1 -0
  11. package/dist/core.cjs +1 -0
  12. package/dist/core.mjs +4 -0
  13. package/dist/entries/core.d.cts +16 -0
  14. package/dist/entries/core.d.ts +17 -0
  15. package/dist/entries/core.d.ts.map +1 -0
  16. package/dist/entries/react.d.cts +18 -0
  17. package/dist/entries/react.d.ts +19 -0
  18. package/dist/entries/react.d.ts.map +1 -0
  19. package/dist/entries/schemas.d.cts +14 -0
  20. package/dist/entries/schemas.d.ts +15 -0
  21. package/dist/entries/schemas.d.ts.map +1 -0
  22. package/dist/entries/validation.d.cts +12 -0
  23. package/dist/entries/validation.d.ts +13 -0
  24. package/dist/entries/validation.d.ts.map +1 -0
  25. package/dist/exercise.schema-BV2b7rtN.cjs +2 -0
  26. package/dist/exercise.schema-BV2b7rtN.cjs.map +1 -0
  27. package/dist/exercise.schema-ckVBW9XA.js +212 -0
  28. package/dist/exercise.schema-ckVBW9XA.js.map +1 -0
  29. package/dist/geometry/distance.d.cts +9 -0
  30. package/dist/geometry/distance.d.ts +10 -0
  31. package/dist/geometry/distance.d.ts.map +1 -0
  32. package/dist/geometry/entities/circle.d.cts +36 -0
  33. package/dist/geometry/entities/circle.d.ts +37 -0
  34. package/dist/geometry/entities/circle.d.ts.map +1 -0
  35. package/dist/geometry/entities/index.d.cts +60 -0
  36. package/dist/geometry/entities/index.d.ts +61 -0
  37. package/dist/geometry/entities/index.d.ts.map +1 -0
  38. package/dist/geometry/entities/line.d.cts +43 -0
  39. package/dist/geometry/entities/line.d.ts +44 -0
  40. package/dist/geometry/entities/line.d.ts.map +1 -0
  41. package/dist/geometry/entities/point.d.cts +27 -0
  42. package/dist/geometry/entities/point.d.ts +28 -0
  43. package/dist/geometry/entities/point.d.ts.map +1 -0
  44. package/dist/geometry/entities/relations.d.cts +27 -0
  45. package/dist/geometry/entities/relations.d.ts +28 -0
  46. package/dist/geometry/entities/relations.d.ts.map +1 -0
  47. package/dist/geometry/entities/segment.d.cts +45 -0
  48. package/dist/geometry/entities/segment.d.ts +46 -0
  49. package/dist/geometry/entities/segment.d.ts.map +1 -0
  50. package/dist/geometry/entityCapabilities.d.cts +2 -0
  51. package/dist/geometry/entityCapabilities.d.ts +3 -0
  52. package/dist/geometry/entityCapabilities.d.ts.map +1 -0
  53. package/dist/geometry/entityModel.d.cts +139 -0
  54. package/dist/geometry/entityModel.d.ts +140 -0
  55. package/dist/geometry/entityModel.d.ts.map +1 -0
  56. package/dist/geometry/entityRecord.d.cts +27 -0
  57. package/dist/geometry/entityRecord.d.ts +28 -0
  58. package/dist/geometry/entityRecord.d.ts.map +1 -0
  59. package/dist/geometry/evaluateGraph.d.cts +37 -0
  60. package/dist/geometry/evaluateGraph.d.ts +38 -0
  61. package/dist/geometry/evaluateGraph.d.ts.map +1 -0
  62. package/dist/geometry/geometryObject.d.cts +4 -0
  63. package/dist/geometry/geometryObject.d.ts +5 -0
  64. package/dist/geometry/geometryObject.d.ts.map +1 -0
  65. package/dist/geometry/goalCandidate.d.cts +8 -0
  66. package/dist/geometry/goalCandidate.d.ts +9 -0
  67. package/dist/geometry/goalCandidate.d.ts.map +1 -0
  68. package/dist/geometry/hitTest.d.cts +23 -0
  69. package/dist/geometry/hitTest.d.ts +24 -0
  70. package/dist/geometry/hitTest.d.ts.map +1 -0
  71. package/dist/geometry/point.d.cts +5 -0
  72. package/dist/geometry/point.d.ts +6 -0
  73. package/dist/geometry/point.d.ts.map +1 -0
  74. package/dist/geometry/pointOrigin.d.cts +5 -0
  75. package/dist/geometry/pointOrigin.d.ts +6 -0
  76. package/dist/geometry/pointOrigin.d.ts.map +1 -0
  77. package/dist/geometry/v1Bridge.d.cts +41 -0
  78. package/dist/geometry/v1Bridge.d.ts +42 -0
  79. package/dist/geometry/v1Bridge.d.ts.map +1 -0
  80. package/dist/geometryAttemptStatus-5L_q6-9l.js +184 -0
  81. package/dist/geometryAttemptStatus-5L_q6-9l.js.map +1 -0
  82. package/dist/geometryAttemptStatus-N_XHIkiS.cjs +2 -0
  83. package/dist/geometryAttemptStatus-N_XHIkiS.cjs.map +1 -0
  84. package/dist/geometryState.schema-D0ixyGYE.js +955 -0
  85. package/dist/geometryState.schema-D0ixyGYE.js.map +1 -0
  86. package/dist/geometryState.schema-DKQ-durx.cjs +2 -0
  87. package/dist/geometryState.schema-DKQ-durx.cjs.map +1 -0
  88. package/dist/goals-C3ZwbEh_.js +451 -0
  89. package/dist/goals-C3ZwbEh_.js.map +1 -0
  90. package/dist/goals-CxR5qPDC.cjs +2 -0
  91. package/dist/goals-CxR5qPDC.cjs.map +1 -0
  92. package/dist/index.cjs +1 -0
  93. package/dist/index.d.cts +4 -0
  94. package/dist/index.d.ts +5 -0
  95. package/dist/index.d.ts.map +1 -0
  96. package/dist/index.mjs +10 -0
  97. package/dist/measure/geometryAdapter.d.cts +26 -0
  98. package/dist/measure/geometryAdapter.d.ts +27 -0
  99. package/dist/measure/geometryAdapter.d.ts.map +1 -0
  100. package/dist/measure/kernel.d.cts +25 -0
  101. package/dist/measure/kernel.d.ts +26 -0
  102. package/dist/measure/kernel.d.ts.map +1 -0
  103. package/dist/numerics/policy.d.cts +17 -0
  104. package/dist/numerics/policy.d.ts +18 -0
  105. package/dist/numerics/policy.d.ts.map +1 -0
  106. package/dist/react-BEcdx1f6.js +1851 -0
  107. package/dist/react-BEcdx1f6.js.map +1 -0
  108. package/dist/react-Pp_VSk--.cjs +2 -0
  109. package/dist/react-Pp_VSk--.cjs.map +1 -0
  110. package/dist/react.cjs +1 -0
  111. package/dist/react.mjs +2 -0
  112. package/dist/renderer/GeometryCanvas.d.cts +14 -0
  113. package/dist/renderer/GeometryCanvas.d.ts +15 -0
  114. package/dist/renderer/GeometryCanvas.d.ts.map +1 -0
  115. package/dist/renderer/GeometryCompanion.d.cts +29 -0
  116. package/dist/renderer/GeometryCompanion.d.ts +30 -0
  117. package/dist/renderer/GeometryCompanion.d.ts.map +1 -0
  118. package/dist/renderer/GeometryGrid.d.cts +7 -0
  119. package/dist/renderer/GeometryGrid.d.ts +8 -0
  120. package/dist/renderer/GeometryGrid.d.ts.map +1 -0
  121. package/dist/renderer/GeometryInstruments.d.cts +7 -0
  122. package/dist/renderer/GeometryInstruments.d.ts +8 -0
  123. package/dist/renderer/GeometryInstruments.d.ts.map +1 -0
  124. package/dist/renderer/StudentGeometryCanvas.d.cts +11 -0
  125. package/dist/renderer/StudentGeometryCanvas.d.ts +12 -0
  126. package/dist/renderer/StudentGeometryCanvas.d.ts.map +1 -0
  127. package/dist/renderer/StudentGeometryExercise.d.cts +36 -0
  128. package/dist/renderer/StudentGeometryExercise.d.ts +37 -0
  129. package/dist/renderer/StudentGeometryExercise.d.ts.map +1 -0
  130. package/dist/renderer/Toolbar.d.cts +7 -0
  131. package/dist/renderer/Toolbar.d.ts +8 -0
  132. package/dist/renderer/Toolbar.d.ts.map +1 -0
  133. package/dist/renderer/deriveRenderableGeometry.d.cts +15 -0
  134. package/dist/renderer/deriveRenderableGeometry.d.ts +16 -0
  135. package/dist/renderer/deriveRenderableGeometry.d.ts.map +1 -0
  136. package/dist/renderer/deriveSemanticScene.d.cts +58 -0
  137. package/dist/renderer/deriveSemanticScene.d.ts +59 -0
  138. package/dist/renderer/deriveSemanticScene.d.ts.map +1 -0
  139. package/dist/renderer/entityDisplayName.d.cts +12 -0
  140. package/dist/renderer/entityDisplayName.d.ts +13 -0
  141. package/dist/renderer/entityDisplayName.d.ts.map +1 -0
  142. package/dist/renderer/gesturePolicy.d.cts +97 -0
  143. package/dist/renderer/gesturePolicy.d.ts +98 -0
  144. package/dist/renderer/gesturePolicy.d.ts.map +1 -0
  145. package/dist/renderer/shapes/CircleShape.d.cts +17 -0
  146. package/dist/renderer/shapes/CircleShape.d.ts +18 -0
  147. package/dist/renderer/shapes/CircleShape.d.ts.map +1 -0
  148. package/dist/renderer/shapes/EntityLabel.d.cts +14 -0
  149. package/dist/renderer/shapes/EntityLabel.d.ts +15 -0
  150. package/dist/renderer/shapes/EntityLabel.d.ts.map +1 -0
  151. package/dist/renderer/shapes/EntityShape.d.cts +18 -0
  152. package/dist/renderer/shapes/EntityShape.d.ts +19 -0
  153. package/dist/renderer/shapes/EntityShape.d.ts.map +1 -0
  154. package/dist/renderer/shapes/LineShape.d.cts +16 -0
  155. package/dist/renderer/shapes/LineShape.d.ts +17 -0
  156. package/dist/renderer/shapes/LineShape.d.ts.map +1 -0
  157. package/dist/renderer/shapes/PointShape.d.cts +17 -0
  158. package/dist/renderer/shapes/PointShape.d.ts +18 -0
  159. package/dist/renderer/shapes/PointShape.d.ts.map +1 -0
  160. package/dist/renderer/shapes/SegmentShape.d.cts +17 -0
  161. package/dist/renderer/shapes/SegmentShape.d.ts +18 -0
  162. package/dist/renderer/shapes/SegmentShape.d.ts.map +1 -0
  163. package/dist/renderer/shapes/SnapMarker.d.cts +8 -0
  164. package/dist/renderer/shapes/SnapMarker.d.ts +9 -0
  165. package/dist/renderer/shapes/SnapMarker.d.ts.map +1 -0
  166. package/dist/renderer/shapes/StrokedLine.d.cts +18 -0
  167. package/dist/renderer/shapes/StrokedLine.d.ts +19 -0
  168. package/dist/renderer/shapes/StrokedLine.d.ts.map +1 -0
  169. package/dist/renderer/studentExerciseSession.d.cts +71 -0
  170. package/dist/renderer/studentExerciseSession.d.ts +72 -0
  171. package/dist/renderer/studentExerciseSession.d.ts.map +1 -0
  172. package/dist/renderer/useConnectionPreview.d.cts +44 -0
  173. package/dist/renderer/useConnectionPreview.d.ts +45 -0
  174. package/dist/renderer/useConnectionPreview.d.ts.map +1 -0
  175. package/dist/renderer/usePlacementSnap.d.cts +28 -0
  176. package/dist/renderer/usePlacementSnap.d.ts +29 -0
  177. package/dist/renderer/usePlacementSnap.d.ts.map +1 -0
  178. package/dist/renderer/usePointerGestures.d.cts +46 -0
  179. package/dist/renderer/usePointerGestures.d.ts +47 -0
  180. package/dist/renderer/usePointerGestures.d.ts.map +1 -0
  181. package/dist/schemas/circle.schema.d.cts +8 -0
  182. package/dist/schemas/circle.schema.d.ts +9 -0
  183. package/dist/schemas/circle.schema.d.ts.map +1 -0
  184. package/dist/schemas/entityDefinition.schema.d.cts +69 -0
  185. package/dist/schemas/entityDefinition.schema.d.ts +70 -0
  186. package/dist/schemas/entityDefinition.schema.d.ts.map +1 -0
  187. package/dist/schemas/entityDocument.d.cts +95 -0
  188. package/dist/schemas/entityDocument.d.ts +96 -0
  189. package/dist/schemas/entityDocument.d.ts.map +1 -0
  190. package/dist/schemas/entityPresentation.schema.d.cts +12 -0
  191. package/dist/schemas/entityPresentation.schema.d.ts +13 -0
  192. package/dist/schemas/entityPresentation.schema.d.ts.map +1 -0
  193. package/dist/schemas/exercise.schema.d.cts +217 -0
  194. package/dist/schemas/exercise.schema.d.ts +218 -0
  195. package/dist/schemas/exercise.schema.d.ts.map +1 -0
  196. package/dist/schemas/exerciseProjection.d.cts +10 -0
  197. package/dist/schemas/exerciseProjection.d.ts +11 -0
  198. package/dist/schemas/exerciseProjection.d.ts.map +1 -0
  199. package/dist/schemas/exerciseV2.schema.d.cts +137 -0
  200. package/dist/schemas/exerciseV2.schema.d.ts +138 -0
  201. package/dist/schemas/exerciseV2.schema.d.ts.map +1 -0
  202. package/dist/schemas/exerciseV3.schema.d.cts +149 -0
  203. package/dist/schemas/exerciseV3.schema.d.ts +150 -0
  204. package/dist/schemas/exerciseV3.schema.d.ts.map +1 -0
  205. package/dist/schemas/geometryObject.schema.d.cts +17 -0
  206. package/dist/schemas/geometryObject.schema.d.ts +18 -0
  207. package/dist/schemas/geometryObject.schema.d.ts.map +1 -0
  208. package/dist/schemas/geometryState.schema.d.cts +64 -0
  209. package/dist/schemas/geometryState.schema.d.ts +65 -0
  210. package/dist/schemas/geometryState.schema.d.ts.map +1 -0
  211. package/dist/schemas/givenElement.schema.d.cts +24 -0
  212. package/dist/schemas/givenElement.schema.d.ts +25 -0
  213. package/dist/schemas/givenElement.schema.d.ts.map +1 -0
  214. package/dist/schemas/goals/createGoal.schema.d.cts +12 -0
  215. package/dist/schemas/goals/createGoal.schema.d.ts +13 -0
  216. package/dist/schemas/goals/createGoal.schema.d.ts.map +1 -0
  217. package/dist/schemas/goals/geometryGoal.schema.d.cts +58 -0
  218. package/dist/schemas/goals/geometryGoal.schema.d.ts +59 -0
  219. package/dist/schemas/goals/geometryGoal.schema.d.ts.map +1 -0
  220. package/dist/schemas/goals/goalKindDeclaration.d.cts +53 -0
  221. package/dist/schemas/goals/goalKindDeclaration.d.ts +54 -0
  222. package/dist/schemas/goals/goalKindDeclaration.d.ts.map +1 -0
  223. package/dist/schemas/goals/midpointGoal.schema.d.cts +9 -0
  224. package/dist/schemas/goals/midpointGoal.schema.d.ts +10 -0
  225. package/dist/schemas/goals/midpointGoal.schema.d.ts.map +1 -0
  226. package/dist/schemas/goals/parallelGoal.schema.d.cts +15 -0
  227. package/dist/schemas/goals/parallelGoal.schema.d.ts +16 -0
  228. package/dist/schemas/goals/parallelGoal.schema.d.ts.map +1 -0
  229. package/dist/schemas/goals/perpendicularGoal.schema.d.cts +15 -0
  230. package/dist/schemas/goals/perpendicularGoal.schema.d.ts +16 -0
  231. package/dist/schemas/goals/perpendicularGoal.schema.d.ts.map +1 -0
  232. package/dist/schemas/goals/segmentLengthGoal.schema.d.cts +9 -0
  233. package/dist/schemas/goals/segmentLengthGoal.schema.d.ts +10 -0
  234. package/dist/schemas/goals/segmentLengthGoal.schema.d.ts.map +1 -0
  235. package/dist/schemas/goals/throughPointsGoal.schema.d.cts +13 -0
  236. package/dist/schemas/goals/throughPointsGoal.schema.d.ts +14 -0
  237. package/dist/schemas/goals/throughPointsGoal.schema.d.ts.map +1 -0
  238. package/dist/schemas/identifier.schema.d.cts +2 -0
  239. package/dist/schemas/identifier.schema.d.ts +3 -0
  240. package/dist/schemas/identifier.schema.d.ts.map +1 -0
  241. package/dist/schemas/line.schema.d.cts +7 -0
  242. package/dist/schemas/line.schema.d.ts +8 -0
  243. package/dist/schemas/line.schema.d.ts.map +1 -0
  244. package/dist/schemas/migrate.d.cts +21 -0
  245. package/dist/schemas/migrate.d.ts +22 -0
  246. package/dist/schemas/migrate.d.ts.map +1 -0
  247. package/dist/schemas/objectTypeName.schema.d.cts +8 -0
  248. package/dist/schemas/objectTypeName.schema.d.ts +9 -0
  249. package/dist/schemas/objectTypeName.schema.d.ts.map +1 -0
  250. package/dist/schemas/point.schema.d.cts +15 -0
  251. package/dist/schemas/point.schema.d.ts +16 -0
  252. package/dist/schemas/point.schema.d.ts.map +1 -0
  253. package/dist/schemas/pointOrigin.schema.d.cts +25 -0
  254. package/dist/schemas/pointOrigin.schema.d.ts +26 -0
  255. package/dist/schemas/pointOrigin.schema.d.ts.map +1 -0
  256. package/dist/schemas/segment.schema.d.cts +8 -0
  257. package/dist/schemas/segment.schema.d.ts +9 -0
  258. package/dist/schemas/segment.schema.d.ts.map +1 -0
  259. package/dist/schemas/v1ToV2.d.cts +37 -0
  260. package/dist/schemas/v1ToV2.d.ts +38 -0
  261. package/dist/schemas/v1ToV2.d.ts.map +1 -0
  262. package/dist/schemas/v2ToV3.d.cts +37 -0
  263. package/dist/schemas/v2ToV3.d.ts +38 -0
  264. package/dist/schemas/v2ToV3.d.ts.map +1 -0
  265. package/dist/schemas/v3ToV4.d.cts +3 -0
  266. package/dist/schemas/v3ToV4.d.ts +4 -0
  267. package/dist/schemas/v3ToV4.d.ts.map +1 -0
  268. package/dist/schemas/viewport.schema.d.cts +3 -0
  269. package/dist/schemas/viewport.schema.d.ts +4 -0
  270. package/dist/schemas/viewport.schema.d.ts.map +1 -0
  271. package/dist/schemas.cjs +1 -0
  272. package/dist/schemas.mjs +3 -0
  273. package/dist/snapping/computeSnap.d.cts +30 -0
  274. package/dist/snapping/computeSnap.d.ts +31 -0
  275. package/dist/snapping/computeSnap.d.ts.map +1 -0
  276. package/dist/state/geometryContext.d.cts +40 -0
  277. package/dist/state/geometryContext.d.ts +41 -0
  278. package/dist/state/geometryContext.d.ts.map +1 -0
  279. package/dist/state/resolvePoints.d.cts +51 -0
  280. package/dist/state/resolvePoints.d.ts +52 -0
  281. package/dist/state/resolvePoints.d.ts.map +1 -0
  282. package/dist/store/attemptChange.d.cts +30 -0
  283. package/dist/store/attemptChange.d.ts +31 -0
  284. package/dist/store/attemptChange.d.ts.map +1 -0
  285. package/dist/store/constructionCommand.d.cts +35 -0
  286. package/dist/store/constructionCommand.d.ts +36 -0
  287. package/dist/store/constructionCommand.d.ts.map +1 -0
  288. package/dist/store/constructionIdentity.d.cts +21 -0
  289. package/dist/store/constructionIdentity.d.ts +22 -0
  290. package/dist/store/constructionIdentity.d.ts.map +1 -0
  291. package/dist/store/createStore.d.cts +6 -0
  292. package/dist/store/createStore.d.ts +7 -0
  293. package/dist/store/createStore.d.ts.map +1 -0
  294. package/dist/store/history.d.cts +2 -0
  295. package/dist/store/history.d.ts +3 -0
  296. package/dist/store/history.d.ts.map +1 -0
  297. package/dist/store/studentStore.d.cts +151 -0
  298. package/dist/store/studentStore.d.ts +152 -0
  299. package/dist/store/studentStore.d.ts.map +1 -0
  300. package/dist/store/teacherStore.d.cts +111 -0
  301. package/dist/store/teacherStore.d.ts +112 -0
  302. package/dist/store/teacherStore.d.ts.map +1 -0
  303. package/dist/store/useStoreState.d.cts +2 -0
  304. package/dist/store/useStoreState.d.ts +3 -0
  305. package/dist/store/useStoreState.d.ts.map +1 -0
  306. package/dist/studentStore-CEKTtMCh.js +1162 -0
  307. package/dist/studentStore-CEKTtMCh.js.map +1 -0
  308. package/dist/studentStore-DLftfFAl.cjs +2 -0
  309. package/dist/studentStore-DLftfFAl.cjs.map +1 -0
  310. package/dist/validation/checkGeometryAnswer.d.cts +63 -0
  311. package/dist/validation/checkGeometryAnswer.d.ts +64 -0
  312. package/dist/validation/checkGeometryAnswer.d.ts.map +1 -0
  313. package/dist/validation/deriveGeometryCanvasFeedback.d.cts +7 -0
  314. package/dist/validation/deriveGeometryCanvasFeedback.d.ts +8 -0
  315. package/dist/validation/deriveGeometryCanvasFeedback.d.ts.map +1 -0
  316. package/dist/validation/exerciseLoad.d.cts +29 -0
  317. package/dist/validation/exerciseLoad.d.ts +30 -0
  318. package/dist/validation/exerciseLoad.d.ts.map +1 -0
  319. package/dist/validation/geometryAttemptStatus.d.cts +23 -0
  320. package/dist/validation/geometryAttemptStatus.d.ts +24 -0
  321. package/dist/validation/geometryAttemptStatus.d.ts.map +1 -0
  322. package/dist/validation/getGeometryExerciseWarnings.d.cts +16 -0
  323. package/dist/validation/getGeometryExerciseWarnings.d.ts +17 -0
  324. package/dist/validation/getGeometryExerciseWarnings.d.ts.map +1 -0
  325. package/dist/validation/goals/create.d.cts +3 -0
  326. package/dist/validation/goals/create.d.ts +4 -0
  327. package/dist/validation/goals/create.d.ts.map +1 -0
  328. package/dist/validation/goals/goalContext.d.cts +44 -0
  329. package/dist/validation/goals/goalContext.d.ts +45 -0
  330. package/dist/validation/goals/goalContext.d.ts.map +1 -0
  331. package/dist/validation/goals/goalKindHandler.d.cts +26 -0
  332. package/dist/validation/goals/goalKindHandler.d.ts +27 -0
  333. package/dist/validation/goals/goalKindHandler.d.ts.map +1 -0
  334. package/dist/validation/goals/index.d.cts +14 -0
  335. package/dist/validation/goals/index.d.ts +15 -0
  336. package/dist/validation/goals/index.d.ts.map +1 -0
  337. package/dist/validation/goals/midpoint.d.cts +4 -0
  338. package/dist/validation/goals/midpoint.d.ts +5 -0
  339. package/dist/validation/goals/midpoint.d.ts.map +1 -0
  340. package/dist/validation/goals/parallel.d.cts +3 -0
  341. package/dist/validation/goals/parallel.d.ts +4 -0
  342. package/dist/validation/goals/parallel.d.ts.map +1 -0
  343. package/dist/validation/goals/perpendicular.d.cts +3 -0
  344. package/dist/validation/goals/perpendicular.d.ts +4 -0
  345. package/dist/validation/goals/perpendicular.d.ts.map +1 -0
  346. package/dist/validation/goals/previewGeometry.d.cts +9 -0
  347. package/dist/validation/goals/previewGeometry.d.ts +10 -0
  348. package/dist/validation/goals/previewGeometry.d.ts.map +1 -0
  349. package/dist/validation/goals/segmentLength.d.cts +3 -0
  350. package/dist/validation/goals/segmentLength.d.ts +4 -0
  351. package/dist/validation/goals/segmentLength.d.ts.map +1 -0
  352. package/dist/validation/goals/throughPoints.d.cts +5 -0
  353. package/dist/validation/goals/throughPoints.d.ts +6 -0
  354. package/dist/validation/goals/throughPoints.d.ts.map +1 -0
  355. package/dist/validation/gradingFingerprints.d.cts +4 -0
  356. package/dist/validation/gradingFingerprints.d.ts +5 -0
  357. package/dist/validation/gradingFingerprints.d.ts.map +1 -0
  358. package/dist/validation/revealGeometryAnswers.d.cts +3 -0
  359. package/dist/validation/revealGeometryAnswers.d.ts +4 -0
  360. package/dist/validation/revealGeometryAnswers.d.ts.map +1 -0
  361. package/dist/validation/revealGeometryAttempt.d.cts +36 -0
  362. package/dist/validation/revealGeometryAttempt.d.ts +37 -0
  363. package/dist/validation/revealGeometryAttempt.d.ts.map +1 -0
  364. package/dist/validation/types.d.cts +58 -0
  365. package/dist/validation/types.d.ts +59 -0
  366. package/dist/validation/types.d.ts.map +1 -0
  367. package/dist/validation/validateGeometryExercise.d.cts +30 -0
  368. package/dist/validation/validateGeometryExercise.d.ts +31 -0
  369. package/dist/validation/validateGeometryExercise.d.ts.map +1 -0
  370. package/dist/validation/validateGeometryState.d.cts +16 -0
  371. package/dist/validation/validateGeometryState.d.ts +17 -0
  372. package/dist/validation/validateGeometryState.d.ts.map +1 -0
  373. package/dist/validation/validateGeometryStateInput.d.cts +22 -0
  374. package/dist/validation/validateGeometryStateInput.d.ts +23 -0
  375. package/dist/validation/validateGeometryStateInput.d.ts.map +1 -0
  376. package/dist/validation.cjs +2 -0
  377. package/dist/validation.cjs.map +1 -0
  378. package/dist/validation.mjs +269 -0
  379. package/dist/validation.mjs.map +1 -0
  380. package/package.json +150 -0
@@ -0,0 +1,31 @@
1
+ import { GeometryExercise } from '../schemas/exercise.schema.js';
2
+ import { GeometryExerciseWarning } from './getGeometryExerciseWarnings.js';
3
+ export interface GeometryExerciseValidationIssue {
4
+ path: Array<string | number>;
5
+ message: string;
6
+ }
7
+ export type GeometryExerciseValidationResult = {
8
+ success: true;
9
+ data: GeometryExercise;
10
+ errors: [];
11
+ warnings: GeometryExerciseWarning[];
12
+ } | {
13
+ success: false;
14
+ data: null;
15
+ errors: GeometryExerciseValidationIssue[];
16
+ warnings: [];
17
+ };
18
+ /**
19
+ * The whole stored exercise, authored solution included. Stored exercises are
20
+ * brought up to the current version before their structure is checked, exactly
21
+ * as attempts are (M2.6.b), and an embedded `solution` is then migrated and
22
+ * checked against the exercise as an attempt (ADR 0015), with its issues rooted
23
+ * at `solution`. On success `data.solution` is that normalized attempt.
24
+ *
25
+ * Grading does not go through here: Check and the student component load the
26
+ * solution-free projection, so a broken solution never disables them. An
27
+ * authoring tool does, and learns about it at save time.
28
+ */
29
+ export declare function validateGeometryExercise(input: unknown): GeometryExerciseValidationResult;
30
+ export declare function validateGeometryExerciseJson(json: string): GeometryExerciseValidationResult;
31
+ //# sourceMappingURL=validateGeometryExercise.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validateGeometryExercise.d.ts","sourceRoot":"","sources":["../../src/validation/validateGeometryExercise.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAA;AAElE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAA;AAE5E,MAAM,WAAW,+BAA+B;IAC9C,IAAI,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,CAAA;IAC5B,OAAO,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,MAAM,gCAAgC,GACxC;IACE,OAAO,EAAE,IAAI,CAAA;IACb,IAAI,EAAE,gBAAgB,CAAA;IACtB,MAAM,EAAE,EAAE,CAAA;IACV,QAAQ,EAAE,uBAAuB,EAAE,CAAA;CACpC,GACD;IACE,OAAO,EAAE,KAAK,CAAA;IACd,IAAI,EAAE,IAAI,CAAA;IACV,MAAM,EAAE,+BAA+B,EAAE,CAAA;IACzC,QAAQ,EAAE,EAAE,CAAA;CACb,CAAA;AAEL;;;;;;;;;;GAUG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,OAAO,GAAG,gCAAgC,CAmBzF;AAED,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,MAAM,GAAG,gCAAgC,CAgB3F"}
@@ -0,0 +1,16 @@
1
+ import { GeometryExercise } from '../schemas/exercise.schema.cjs';
2
+ import { GeometryState } from '../schemas/geometryState.schema.cjs';
3
+ import { DetailedGeometryFeedback, GeometryValidationFeedback, ValidationResult } from './types.cjs';
4
+ export declare function validateGeometryState(exercise: GeometryExercise, geometry: GeometryState): ValidationResult;
5
+ export declare function evaluateGeometryState(exercise: GeometryExercise, geometry: GeometryState): GeometryValidationFeedback;
6
+ /**
7
+ * The same grading, reported rather than summarized: why each goal landed where
8
+ * it did, as stable codes and entity ids (RFC 0004 § Decision 5). It measures
9
+ * nothing the plain evaluation does not — the codes are read off the existing
10
+ * goal handlers' own predicates — so the two can never disagree.
11
+ *
12
+ * `feedback` is exactly what `evaluateGeometryState()` returns for the same
13
+ * inputs. The extra work is one relevance pass per satisfied goal and the
14
+ * unresolved bookkeeping, which the plain path still skips.
15
+ */
16
+ export declare function evaluateGeometryStateDetailed(exercise: GeometryExercise, geometry: GeometryState): DetailedGeometryFeedback;
@@ -0,0 +1,17 @@
1
+ import { GeometryExercise } from '../schemas/exercise.schema.js';
2
+ import { GeometryState } from '../schemas/geometryState.schema.js';
3
+ import { DetailedGeometryFeedback, GeometryValidationFeedback, ValidationResult } from './types.js';
4
+ export declare function validateGeometryState(exercise: GeometryExercise, geometry: GeometryState): ValidationResult;
5
+ export declare function evaluateGeometryState(exercise: GeometryExercise, geometry: GeometryState): GeometryValidationFeedback;
6
+ /**
7
+ * The same grading, reported rather than summarized: why each goal landed where
8
+ * it did, as stable codes and entity ids (RFC 0004 § Decision 5). It measures
9
+ * nothing the plain evaluation does not — the codes are read off the existing
10
+ * goal handlers' own predicates — so the two can never disagree.
11
+ *
12
+ * `feedback` is exactly what `evaluateGeometryState()` returns for the same
13
+ * inputs. The extra work is one relevance pass per satisfied goal and the
14
+ * unresolved bookkeeping, which the plain path still skips.
15
+ */
16
+ export declare function evaluateGeometryStateDetailed(exercise: GeometryExercise, geometry: GeometryState): DetailedGeometryFeedback;
17
+ //# sourceMappingURL=validateGeometryState.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validateGeometryState.d.ts","sourceRoot":"","sources":["../../src/validation/validateGeometryState.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAA;AAClE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAA;AAGpE,OAAO,KAAK,EACV,wBAAwB,EAGxB,0BAA0B,EAG1B,gBAAgB,EACjB,MAAM,SAAS,CAAA;AAGhB,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,gBAAgB,EAC1B,QAAQ,EAAE,aAAa,GACtB,gBAAgB,CAElB;AAED,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,gBAAgB,EAC1B,QAAQ,EAAE,aAAa,GACtB,0BAA0B,CAE5B;AAED;;;;;;;;;GASG;AACH,wBAAgB,6BAA6B,CAC3C,QAAQ,EAAE,gBAAgB,EAC1B,QAAQ,EAAE,aAAa,GACtB,wBAAwB,CAE1B"}
@@ -0,0 +1,22 @@
1
+ import { GeometryExercise } from '../schemas/exercise.schema.cjs';
2
+ import { GeometryState } from '../schemas/geometryState.schema.cjs';
3
+ import { GeometryExerciseValidationIssue } from './validateGeometryExercise.cjs';
4
+ export type GeometryStateInputValidationResult = {
5
+ success: true;
6
+ data: GeometryState;
7
+ errors: [];
8
+ } | {
9
+ success: false;
10
+ data: null;
11
+ errors: GeometryExerciseValidationIssue[];
12
+ };
13
+ export declare function validateGeometryStateInput(input: unknown, exercise?: GeometryExercise): GeometryStateInputValidationResult;
14
+ /**
15
+ * Restores an attempt from stored JSON — the counterpart to
16
+ * validateGeometryExerciseJson(). Pass the exercise to also check the attempt
17
+ * against it — only allowed object types, parents naming entities that exist in
18
+ * one of the two documents — and to normalize it, which is what drops the given
19
+ * points a migrated v1 attempt still carries.
20
+ */
21
+ export declare function validateGeometryStateJson(json: string, exercise?: GeometryExercise): GeometryStateInputValidationResult;
22
+ export declare function serializeGeometryState(geometry: GeometryState): string;
@@ -0,0 +1,23 @@
1
+ import { GeometryExercise } from '../schemas/exercise.schema.js';
2
+ import { GeometryState } from '../schemas/geometryState.schema.js';
3
+ import { GeometryExerciseValidationIssue } from './validateGeometryExercise.js';
4
+ export type GeometryStateInputValidationResult = {
5
+ success: true;
6
+ data: GeometryState;
7
+ errors: [];
8
+ } | {
9
+ success: false;
10
+ data: null;
11
+ errors: GeometryExerciseValidationIssue[];
12
+ };
13
+ export declare function validateGeometryStateInput(input: unknown, exercise?: GeometryExercise): GeometryStateInputValidationResult;
14
+ /**
15
+ * Restores an attempt from stored JSON — the counterpart to
16
+ * validateGeometryExerciseJson(). Pass the exercise to also check the attempt
17
+ * against it — only allowed object types, parents naming entities that exist in
18
+ * one of the two documents — and to normalize it, which is what drops the given
19
+ * points a migrated v1 attempt still carries.
20
+ */
21
+ export declare function validateGeometryStateJson(json: string, exercise?: GeometryExercise): GeometryStateInputValidationResult;
22
+ export declare function serializeGeometryState(geometry: GeometryState): string;
23
+ //# sourceMappingURL=validateGeometryStateInput.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validateGeometryStateInput.d.ts","sourceRoot":"","sources":["../../src/validation/validateGeometryStateInput.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAA;AAClE,OAAO,EAGL,KAAK,aAAa,EACnB,MAAM,iCAAiC,CAAA;AACxC,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,4BAA4B,CAAA;AAwDjF,MAAM,MAAM,kCAAkC,GAC1C;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,aAAa,CAAC;IAAC,MAAM,EAAE,EAAE,CAAA;CAAE,GAClD;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,IAAI,EAAE,IAAI,CAAC;IAAC,MAAM,EAAE,+BAA+B,EAAE,CAAA;CAAE,CAAA;AAE7E,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,OAAO,EACd,QAAQ,CAAC,EAAE,gBAAgB,GAC1B,kCAAkC,CAgEpC;AAED;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,MAAM,EACZ,QAAQ,CAAC,EAAE,gBAAgB,GAC1B,kCAAkC,CAepC;AAID,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,aAAa,GAAG,MAAM,CAEtE"}
@@ -0,0 +1,2 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./geometryState.schema-DKQ-durx.cjs"),t=require("./goals-CxR5qPDC.cjs"),n=require("./geometryAttemptStatus-N_XHIkiS.cjs");function r(e,t){return i(e,t).result}function i(e,t){return o(e,t,!1).feedback}function a(e,t){return o(e,t,!0)}function o(n,r,i){let a=n.goals.length===0,o=n.grading?.extraObjects===`reject`,l=i||o;if(a&&!i)return{feedback:{result:{status:`incorrect`,goals:[]},goals:[]},goals:[],diagnostics:[],extraEntityIds:[]};let u=t.d(n,r),d={exercise:n,points:u.points},f=[],p=[],m=[];for(let t of r.answerEntityIds){if(e.O(n.entities,t))continue;let r=u.definitionOf(t);if(r){if(l&&m.push(t),u.resolvedOf(t)===void 0){l&&p.push({id:t,definition:r});continue}f.push({id:t,definition:r})}}let h=[],g=[],_=new Set;for(let e of n.goals){let n=f.filter(n=>t.r(n,e,d));if(l)for(let e of n)_.add(e.id);let r=n.length>0,a=r&&!i?[]:f.filter(n=>t.i(n,e,d)),o=r?n:a;if(h.push({id:e.id,status:r?`correct`:`incorrect`,constructionIds:o.filter(e=>!t.f(e)).map(e=>e.id),pointIds:o.filter(t.f).map(e=>e.id)}),!i)continue;let s=p.filter(n=>t.n(n,e));g.push({id:e.id,status:r?`correct`:`incorrect`,code:r?`goal-satisfied`:f.some(n=>t.n(n,e))?`goal-not-satisfied`:s.length>0?`unresolved-candidate`:`no-candidate`,matchedEntityIds:c(n),relevantEntityIds:c(a),unresolvedEntityIds:c(s)})}let v=l?s(m,_,u):[],y={status:!a&&h.every(e=>e.status===`correct`)&&!(o&&v.length>0)?`correct`:`incorrect`,goals:h.map(({id:e,status:t})=>({id:e,status:t}))},b=[];return a&&b.push({code:`no-goals`,entityIds:[]}),p.length>0&&b.push({code:`unresolved-entity`,entityIds:c(p)}),o&&v.length>0&&b.push({code:`extra-objects`,entityIds:v}),{feedback:{result:y,goals:h},goals:g,diagnostics:b,extraEntityIds:v}}function s(e,t,n){let r=new Set(t),i=[...t];for(;i.length>0;){let e=i.pop();if(e!==void 0)for(let t of n.parentsOf(e))r.has(t)||(r.add(t),i.push(t))}return[...new Set(e)].filter(e=>!r.has(e))}function c(e){return[...new Set(e.map(e=>e.id))]}function l(e,t){let r=n.r(e);if(!r.success)return{success:!1,data:null,errors:r.errors.map(e=>({...e,source:`exercise`})),warnings:[]};let a=n.u(t,r.data);return a.success?{success:!0,data:i(r.data,a.data),fingerprints:{exercise:n.s(r.data),attempt:n.o(a.data)},errors:[],warnings:r.warnings}:{success:!1,data:null,errors:a.errors.map(e=>({...e,source:`geometry`})),warnings:[]}}function u(e,t){let r=n.r(e);if(!r.success)return{success:!1,data:null,errors:r.errors.map(e=>({...e,source:`exercise`,code:`invalid-exercise`})),warnings:[]};let i=n.u(t,r.data);return i.success?{success:!0,data:a(r.data,i.data),fingerprints:{exercise:n.s(r.data),attempt:n.o(i.data)},errors:[],warnings:r.warnings}:{success:!1,data:null,errors:i.errors.map(e=>({...e,source:`geometry`,code:`invalid-attempt`})),warnings:[]}}function d(e){let n=t.l(e);return e.goals.map(r=>({id:r.id,shape:t.o(r,{exercise:e,points:n})}))}function f(e){return{success:!1,data:null,errors:e}}function p(e){let t=n.r(e);if(!t.success)return f(t.errors.map(e=>({code:`invalid-exercise`,...e})));if(t.solution===void 0)return f([{code:`invalid-canonical-attempt`,path:[`solution`],message:`this exercise has no canonical solution`}]);let i=n.i(t.solution,t.data);return i.success?r(t.data,i.data).status===`correct`?{success:!0,data:i.data,errors:[]}:f([{code:`canonical-attempt-incorrect`,path:[`solution`],message:`the canonical solution does not satisfy this exercise`}]):f(i.errors.map(e=>({code:`invalid-canonical-attempt`,...e})))}function m(e){let t=n.r(e);if(!t.success)return{success:!1,data:null,errors:t.errors,warnings:[]};if(t.solution===void 0)return{success:!0,data:t.data,errors:[],warnings:t.warnings};let r=n.i(t.solution,t.data);return r.success?{success:!0,data:{...t.data,solution:r.data},errors:[],warnings:t.warnings}:{success:!1,data:null,errors:r.errors,warnings:[]}}function h(e){try{return m(JSON.parse(e))}catch(e){return{success:!1,data:null,errors:[{path:[],message:e instanceof Error?e.message:`Invalid JSON syntax`}],warnings:[]}}}exports.checkGeometryAnswer=l,exports.checkGeometryAnswerDetailed=u,exports.createEmptyGeometryAttempt=n.t,exports.deriveGeometryCanvasFeedback=n.c,exports.evaluateGeometryState=i,exports.evaluateGeometryStateDetailed=a,exports.getGeometryExerciseWarnings=n.a,exports.getGoalKindHandler=t.t,exports.hasGeometryWork=n.n,exports.intersectionsOf=e.V,exports.revealGeometryAnswers=d,exports.revealGeometryAttempt=p,exports.serializeGeometryState=n.l,exports.validateGeometryExercise=m,exports.validateGeometryExerciseJson=h,exports.validateGeometryState=r,exports.validateGeometryStateInput=n.u,exports.validateGeometryStateJson=n.d;
2
+ //# sourceMappingURL=validation.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.cjs","names":[],"sources":["../src/validation/validateGeometryState.ts","../src/validation/checkGeometryAnswer.ts","../src/validation/revealGeometryAnswers.ts","../src/validation/revealGeometryAttempt.ts","../src/validation/validateGeometryExercise.ts"],"sourcesContent":["import { entryOf } from '../geometry/entityRecord'\nimport type { EntityId } from '../geometry/entityModel'\nimport type { GeometryExercise } from '../schemas/exercise.schema'\nimport type { GeometryState } from '../schemas/geometryState.schema'\nimport { isCandidatePoint, type GoalCandidate } from '../geometry/goalCandidate'\nimport { buildGeometryContext } from '../state/geometryContext'\nimport type {\n DetailedGeometryFeedback,\n DetailedGoalResult,\n GeometryDiagnostic,\n GeometryValidationFeedback,\n GoalGeometryFeedback,\n ValidationContext,\n ValidationResult,\n} from './types'\nimport { goalAcceptsCandidate, goalSatisfiedBy, isRelevantGoalAttempt } from './goals'\n\nexport function validateGeometryState(\n exercise: GeometryExercise,\n geometry: GeometryState,\n): ValidationResult {\n return evaluateGeometryState(exercise, geometry).result\n}\n\nexport function evaluateGeometryState(\n exercise: GeometryExercise,\n geometry: GeometryState,\n): GeometryValidationFeedback {\n return evaluate(exercise, geometry, false).feedback\n}\n\n/**\n * The same grading, reported rather than summarized: why each goal landed where\n * it did, as stable codes and entity ids (RFC 0004 § Decision 5). It measures\n * nothing the plain evaluation does not — the codes are read off the existing\n * goal handlers' own predicates — so the two can never disagree.\n *\n * `feedback` is exactly what `evaluateGeometryState()` returns for the same\n * inputs. The extra work is one relevance pass per satisfied goal and the\n * unresolved bookkeeping, which the plain path still skips.\n */\nexport function evaluateGeometryStateDetailed(\n exercise: GeometryExercise,\n geometry: GeometryState,\n): DetailedGeometryFeedback {\n return evaluate(exercise, geometry, true)\n}\n\nfunction evaluate(\n exercise: GeometryExercise,\n geometry: GeometryState,\n detailed: boolean,\n): DetailedGeometryFeedback {\n // An exercise nobody can answer is incorrect, and the report now says so in\n // one word rather than leaving a host to infer it from an empty goal list.\n // The plain path stops here, as it always has; the report does not, because\n // an unresolved answer entity is reported whatever the goals say — there is\n // simply no goal loop to run below.\n const noGoals = exercise.goals.length === 0\n // Absence means `allow` (ADR 0013), so an exercise authored before v3 keeps\n // exactly the verdict it had. The extra-object sets cost a closure walk, so\n // the plain path computes them only when the policy actually reads them:\n // under `allow` they are reported and never graded on.\n const strict = exercise.grading?.extraObjects === 'reject'\n const needsExtras = detailed || strict\n if (noGoals && !detailed) {\n return {\n feedback: { result: { status: 'incorrect', goals: [] }, goals: [] },\n goals: [],\n diagnostics: [],\n extraEntityIds: [],\n }\n }\n\n // Coordinates come from the dependency graph, not from storage: a derived\n // point is wherever its parents currently put it. A point that cannot be\n // resolved (its object was deleted, its intersection vanished) is absent\n // here and therefore cannot satisfy anything.\n const scene = buildGeometryContext(exercise, geometry)\n // The scene's own index, not a copy: `ValidationContext.points` is read-only\n // by contract (M2.3.c), so there is nothing to defend it against. The copy\n // this replaced was one `Map` allocation and one full rehash per validation.\n const context: ValidationContext = { exercise, points: scene.points }\n // One list for every kind, which is what `answerEntityIds` is: v1 kept a\n // candidacy list for points only and treated every construction as a\n // candidate, and the migration reproduces that by naming both. A goal kind\n // decides for itself which candidates it can be satisfied by (a midpoint goal\n // wants a point, a perpendicular goal wants a segment or line); points the\n // student only used as scaffolding are not named here and are never\n // candidates.\n //\n // An entity that no longer resolves has no coordinates to measure, so it is\n // dropped here rather than left for a handler to trip over: handlers may\n // assume every candidate they are handed can be looked up in `points`. An\n // entity resolves exactly when everything it is built on does, which is the\n // index's answer rather than a second scan.\n const candidates: GoalCandidate[] = []\n // Answer entities that exist but have no coordinates this evaluation. The\n // plain path drops them silently; the report names them, because \"you built\n // it and then deleted what it stood on\" is not the same as \"you built\n // nothing\".\n const unresolved: GoalCandidate[] = []\n // Set `A` of RFC 0004 § Decision 6, in answer order: every id the attempt\n // owns and names as an answer, resolved or not. The extra-object policy\n // subtracts from this list and nothing else, so scaffolding the student never\n // offered as an answer cannot be an extra.\n const answered: EntityId[] = []\n for (const id of geometry.answerEntityIds) {\n // A given is not an answer to anything (ADR 0008 § Amendment), whatever\n // the list says. `validateGeometryStateInput()` already strips these on\n // load, but grading takes both documents directly — a host holding a\n // migrated v1 attempt it never loaded through the engine, or a store still\n // in memory, would otherwise have the exercise's own given graded as the\n // student's construction (M2.G.2).\n if (entryOf(exercise.entities, id)) continue\n const definition = scene.definitionOf(id)\n if (!definition) continue\n if (needsExtras) answered.push(id)\n if (scene.resolvedOf(id) === undefined) {\n if (needsExtras) unresolved.push({ id, definition })\n continue\n }\n candidates.push({ id, definition })\n }\n const goals: GoalGeometryFeedback[] = []\n const detailedGoals: DetailedGoalResult[] = []\n // Set `M`: every candidate that satisfies *some* goal. A union, not an\n // assignment — one entity may answer two goals and two entities may answer\n // one, and this policy deliberately does not count solutions.\n const matched = new Set<EntityId>()\n for (const goal of exercise.goals) {\n const matching = candidates.filter((candidate) => goalSatisfiedBy(candidate, goal, context))\n if (needsExtras) for (const candidate of matching) matched.add(candidate.id)\n const correct = matching.length > 0\n // Highlighting wants relevance only when the goal is unsatisfied; the\n // report wants it either way, so a correct goal still says which other\n // attempts were aimed at it.\n const relevant =\n correct && !detailed\n ? []\n : candidates.filter((candidate) => isRelevantGoalAttempt(candidate, goal, context))\n const shown = correct ? matching : relevant\n goals.push({\n id: goal.id,\n status: correct ? 'correct' : 'incorrect',\n constructionIds: shown.filter((candidate) => !isCandidatePoint(candidate)).map((c) => c.id),\n pointIds: shown.filter(isCandidatePoint).map((candidate) => candidate.id),\n })\n if (!detailed) continue\n const unresolvedForGoal = unresolved.filter((candidate) =>\n goalAcceptsCandidate(candidate, goal),\n )\n detailedGoals.push({\n id: goal.id,\n status: correct ? 'correct' : 'incorrect',\n code: correct\n ? 'goal-satisfied'\n : candidates.some((candidate) => goalAcceptsCandidate(candidate, goal))\n ? 'goal-not-satisfied'\n : unresolvedForGoal.length > 0\n ? 'unresolved-candidate'\n : 'no-candidate',\n matchedEntityIds: distinctIds(matching),\n relevantEntityIds: distinctIds(relevant),\n unresolvedEntityIds: distinctIds(unresolvedForGoal),\n })\n }\n // `A − (M ∪ S)`: answer entities no goal needed, and that nothing a goal\n // needed was built on. Empty unless the policy or the report asked for it.\n const extraEntityIds = needsExtras ? withoutSupport(answered, matched, scene) : []\n const goalsMet = !noGoals && goals.every((goal) => goal.status === 'correct')\n const result: ValidationResult = {\n // `every` on an empty list is vacuously true, and a goalless exercise is\n // incorrect — the one place the two disagree.\n //\n // Under `reject`, an extra answer entity makes the attempt incorrect while\n // every goal stays as its own predicate found it: \"the goals are met and\n // something unused is still on the canvas\" is a different thing from a\n // failed goal, and the diagnostic below is where it is said.\n status: goalsMet && !(strict && extraEntityIds.length > 0) ? 'correct' : 'incorrect',\n goals: goals.map(({ id, status }) => ({ id, status })),\n }\n const diagnostics: GeometryDiagnostic[] = []\n if (noGoals) diagnostics.push({ code: 'no-goals', entityIds: [] })\n // Informational: an unresolved entity does not make a satisfied exercise\n // incorrect. Reporting it regardless is what lets a host say \"this one is\n // no longer on the canvas\" instead of leaving it unexplained.\n if (unresolved.length > 0) {\n diagnostics.push({ code: 'unresolved-entity', entityIds: distinctIds(unresolved) })\n }\n // Only under `reject`: the list is reported either way, but it is a finding\n // about the attempt only where the author asked for strictness. Last, because\n // an unresolved extra is explained by the diagnostic above it.\n if (strict && extraEntityIds.length > 0) {\n diagnostics.push({ code: 'extra-objects', entityIds: extraEntityIds })\n }\n return { feedback: { result, goals }, goals: detailedGoals, diagnostics, extraEntityIds }\n}\n\n/**\n * `answered` minus the matched entities and minus set `S`, their transitive\n * parents — the support closure.\n *\n * Support is exempt because it is not an alternative answer: the two points a\n * correct segment is drawn between, and the helper objects a correct derived\n * point stands on, are the construction, however the student named them. That\n * is why the walk goes *up* the graph from what satisfied a goal rather than\n * down from every answer entity.\n *\n * An unresolved answer entity cannot be in `matched` — nothing measured it —\n * and it can only be support if something that did resolve was built on it,\n * which is impossible. So it stays, which is the reported outcome RFC 0004 §\n * Decision 6 names.\n */\nfunction withoutSupport(\n answered: readonly EntityId[],\n matched: ReadonlySet<EntityId>,\n scene: { parentsOf(id: EntityId): readonly EntityId[] },\n): EntityId[] {\n const exempt = new Set<EntityId>(matched)\n const pending = [...matched]\n // Visited-bounded, because the graph is walked by id: a cycle is\n // unrepresentable in a stored document, but this must not depend on that.\n while (pending.length > 0) {\n const id = pending.pop()\n if (id === undefined) continue\n for (const parent of scene.parentsOf(id)) {\n if (exempt.has(parent)) continue\n exempt.add(parent)\n pending.push(parent)\n }\n }\n return [...new Set(answered)].filter((id) => !exempt.has(id))\n}\n\n/** `answerEntityIds` order, each id once — the reporting order RFC 0004 fixes. */\nfunction distinctIds(candidates: readonly GoalCandidate[]): string[] {\n return [...new Set(candidates.map((candidate) => candidate.id))]\n}\n","import type { DetailedGeometryFeedback, GeometryValidationFeedback } from './types'\nimport type { GeometryExerciseWarning } from './getGeometryExerciseWarnings'\nimport { fingerprintGeometryAttempt, fingerprintGeometryExercise } from './gradingFingerprints'\nimport { loadExerciseDocument } from './exerciseLoad'\nimport type { GeometryExerciseValidationIssue } from './validateGeometryExercise'\nimport { evaluateGeometryState, evaluateGeometryStateDetailed } from './validateGeometryState'\nimport { validateGeometryStateInput } from './validateGeometryStateInput'\n\nexport interface CheckGeometryAnswerIssue extends GeometryExerciseValidationIssue {\n source: 'exercise' | 'geometry'\n}\n\n/**\n * Which grading inputs a successful check described (RFC 0005 § Decision 2).\n * Both are opaque and engine-produced: equal for equal normalized content,\n * whatever the object identity or key order, and the exercise member ignores\n * the authored solution. A host passes the whole result on and never computes\n * or compares these itself.\n */\nexport interface CheckGeometryAnswerFingerprints {\n exercise: string\n attempt: string\n}\n\nexport type CheckGeometryAnswerResult =\n | {\n success: true\n data: GeometryValidationFeedback\n fingerprints: CheckGeometryAnswerFingerprints\n errors: []\n warnings: GeometryExerciseWarning[]\n }\n | {\n success: false\n data: null\n errors: CheckGeometryAnswerIssue[]\n warnings: []\n }\n\n/**\n * Safe public Check entry point for untrusted application data. Structure is\n * validated first; valid geometry is then evaluated by the JSXGraph-backed\n * goal handlers used by validateGeometryState().\n */\nexport function checkGeometryAnswer(\n exerciseInput: unknown,\n geometryInput: unknown,\n): CheckGeometryAnswerResult {\n // The solution-free load: grading ignores the authored solution, so a\n // malformed one cannot fail a check (ADR 0015).\n const exercise = loadExerciseDocument(exerciseInput)\n if (!exercise.success) {\n return {\n success: false,\n data: null,\n errors: exercise.errors.map((issue) => ({ ...issue, source: 'exercise' })),\n warnings: [],\n }\n }\n\n const geometry = validateGeometryStateInput(geometryInput, exercise.data)\n if (!geometry.success) {\n return {\n success: false,\n data: null,\n errors: geometry.errors.map((issue) => ({ ...issue, source: 'geometry' })),\n warnings: [],\n }\n }\n\n return {\n success: true,\n data: evaluateGeometryState(exercise.data, geometry.data),\n fingerprints: {\n exercise: fingerprintGeometryExercise(exercise.data),\n attempt: fingerprintGeometryAttempt(geometry.data),\n },\n errors: [],\n warnings: exercise.warnings,\n }\n}\n\n/**\n * Which document was rejected, as a code rather than a sentence. `message`\n * stays the schema's human-readable detail and is never a reason code: a\n * malformed document is not a student's wrong answer, and nothing here reaches\n * geometry evaluation (RFC 0004 § Decision 5).\n */\nexport type CheckGeometryAnswerErrorCode = 'invalid-exercise' | 'invalid-attempt'\n\nexport interface DetailedCheckGeometryAnswerIssue extends CheckGeometryAnswerIssue {\n code: CheckGeometryAnswerErrorCode\n}\n\nexport type DetailedCheckGeometryAnswerResult =\n | {\n success: true\n data: DetailedGeometryFeedback\n fingerprints: CheckGeometryAnswerFingerprints\n errors: []\n warnings: GeometryExerciseWarning[]\n }\n | {\n success: false\n data: null\n errors: DetailedCheckGeometryAnswerIssue[]\n warnings: []\n }\n\n/**\n * `checkGeometryAnswer()` with the structured report: same untrusted inputs,\n * same success discriminant, fingerprints and warnings, detailed data on\n * success.\n */\nexport function checkGeometryAnswerDetailed(\n exerciseInput: unknown,\n geometryInput: unknown,\n): DetailedCheckGeometryAnswerResult {\n // The solution-free load: grading ignores the authored solution, so a\n // malformed one cannot fail a check (ADR 0015).\n const exercise = loadExerciseDocument(exerciseInput)\n if (!exercise.success) {\n return {\n success: false,\n data: null,\n errors: exercise.errors.map((issue) => ({\n ...issue,\n source: 'exercise',\n code: 'invalid-exercise',\n })),\n warnings: [],\n }\n }\n\n const geometry = validateGeometryStateInput(geometryInput, exercise.data)\n if (!geometry.success) {\n return {\n success: false,\n data: null,\n errors: geometry.errors.map((issue) => ({\n ...issue,\n source: 'geometry',\n code: 'invalid-attempt',\n })),\n warnings: [],\n }\n }\n\n return {\n success: true,\n data: evaluateGeometryStateDetailed(exercise.data, geometry.data),\n fingerprints: {\n exercise: fingerprintGeometryExercise(exercise.data),\n attempt: fingerprintGeometryAttempt(geometry.data),\n },\n errors: [],\n warnings: exercise.warnings,\n }\n}\n","import type { GeometryExercise } from '../schemas/exercise.schema'\nimport { resolveExercisePoints } from '../state/resolvePoints'\nimport { revealedAnswerFor } from './goals'\nimport type { RevealedAnswer } from './types'\n\nexport function revealGeometryAnswers(exercise: GeometryExercise): RevealedAnswer[] {\n // The exercise's own points, resolved: a canonical answer is measured\n // against the givens and nothing else, so there is no attempt to index here.\n const points = resolveExercisePoints(exercise)\n\n return exercise.goals.map((goal) => ({\n id: goal.id,\n shape: revealedAnswerFor(goal, { exercise, points }),\n }))\n}\n","import type { GeometryState } from '../schemas/geometryState.schema'\nimport { loadExerciseDocument, validateEmbeddedSolution } from './exerciseLoad'\nimport { validateGeometryState } from './validateGeometryState'\n\n/**\n * Why no canonical attempt came back, as a code rather than a sentence (RFC\n * 0005 § Decision 4). The three are kept apart because a host acts on them\n * differently: a broken exercise is the whole widget's problem, a missing or\n * malformed solution is an authoring gap, and an incorrect one means the\n * authored answer and the goals disagree.\n */\nexport type RevealGeometryAttemptErrorCode =\n 'invalid-exercise' | 'invalid-canonical-attempt' | 'canonical-attempt-incorrect'\n\nexport interface RevealGeometryAttemptIssue {\n code: RevealGeometryAttemptErrorCode\n path: Array<string | number>\n message: string\n}\n\nexport type RevealGeometryAttemptResult =\n | { success: true; data: GeometryState; errors: [] }\n | { success: false; data: null; errors: RevealGeometryAttemptIssue[] }\n\nfunction refused(errors: RevealGeometryAttemptIssue[]): RevealGeometryAttemptResult {\n return { success: false, data: null, errors }\n}\n\n/**\n * The authored canonical attempt an exercise embeds, for a host's Reveal\n * (ADR 0015). Synchronous and DOM-free, and safe on untrusted input: the\n * exercise is migrated and parsed, then its `solution` is migrated, parsed and\n * normalized as an attempt against that exercise, then graded under the\n * exercise's own policy. Only a solution that grades correct is returned.\n *\n * Nothing is synthesized from goals and nothing is merged with student work:\n * the host replaces its attempt value with `data`. Paths of a malformed\n * solution are rooted at `solution`, so they point into the exercise document\n * the host holds.\n */\nexport function revealGeometryAttempt(exerciseInput: unknown): RevealGeometryAttemptResult {\n // The same two stages `validateGeometryExercise()` runs, kept apart here only\n // so each failure gets its own code.\n const exercise = loadExerciseDocument(exerciseInput)\n if (!exercise.success) {\n return refused(exercise.errors.map((issue) => ({ code: 'invalid-exercise', ...issue })))\n }\n\n if (exercise.solution === undefined) {\n return refused([\n {\n code: 'invalid-canonical-attempt',\n path: ['solution'],\n message: 'this exercise has no canonical solution',\n },\n ])\n }\n\n const attempt = validateEmbeddedSolution(exercise.solution, exercise.data)\n if (!attempt.success) {\n return refused(attempt.errors.map((issue) => ({ code: 'invalid-canonical-attempt', ...issue })))\n }\n\n if (validateGeometryState(exercise.data, attempt.data).status !== 'correct') {\n return refused([\n {\n code: 'canonical-attempt-incorrect',\n path: ['solution'],\n message: 'the canonical solution does not satisfy this exercise',\n },\n ])\n }\n\n return { success: true, data: attempt.data, errors: [] }\n}\n","import type { GeometryExercise } from '../schemas/exercise.schema'\nimport { loadExerciseDocument, validateEmbeddedSolution } from './exerciseLoad'\nimport type { GeometryExerciseWarning } from './getGeometryExerciseWarnings'\n\nexport interface GeometryExerciseValidationIssue {\n path: Array<string | number>\n message: string\n}\n\nexport type GeometryExerciseValidationResult =\n | {\n success: true\n data: GeometryExercise\n errors: []\n warnings: GeometryExerciseWarning[]\n }\n | {\n success: false\n data: null\n errors: GeometryExerciseValidationIssue[]\n warnings: []\n }\n\n/**\n * The whole stored exercise, authored solution included. Stored exercises are\n * brought up to the current version before their structure is checked, exactly\n * as attempts are (M2.6.b), and an embedded `solution` is then migrated and\n * checked against the exercise as an attempt (ADR 0015), with its issues rooted\n * at `solution`. On success `data.solution` is that normalized attempt.\n *\n * Grading does not go through here: Check and the student component load the\n * solution-free projection, so a broken solution never disables them. An\n * authoring tool does, and learns about it at save time.\n */\nexport function validateGeometryExercise(input: unknown): GeometryExerciseValidationResult {\n const loaded = loadExerciseDocument(input)\n if (!loaded.success) {\n return { success: false, data: null, errors: loaded.errors, warnings: [] }\n }\n if (loaded.solution === undefined) {\n return { success: true, data: loaded.data, errors: [], warnings: loaded.warnings }\n }\n\n const solution = validateEmbeddedSolution(loaded.solution, loaded.data)\n if (!solution.success) {\n return { success: false, data: null, errors: solution.errors, warnings: [] }\n }\n return {\n success: true,\n data: { ...loaded.data, solution: solution.data },\n errors: [],\n warnings: loaded.warnings,\n }\n}\n\nexport function validateGeometryExerciseJson(json: string): GeometryExerciseValidationResult {\n try {\n return validateGeometryExercise(JSON.parse(json))\n } catch (error) {\n return {\n success: false,\n data: null,\n errors: [\n {\n path: [],\n message: error instanceof Error ? error.message : 'Invalid JSON syntax',\n },\n ],\n warnings: [],\n }\n }\n}\n"],"mappings":"8MAiBA,SAAgB,EACd,EACA,EACkB,CAClB,OAAO,EAAsB,EAAU,CAAQ,CAAC,CAAC,MACnD,CAEA,SAAgB,EACd,EACA,EAC4B,CAC5B,OAAO,EAAS,EAAU,EAAU,EAAK,CAAC,CAAC,QAC7C,CAYA,SAAgB,EACd,EACA,EAC0B,CAC1B,OAAO,EAAS,EAAU,EAAU,EAAI,CAC1C,CAEA,SAAS,E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8BACN,KAAM,CAAC,UAAU,EACjB,QAAS,uDACX,CACF,CAAC,EAVM,EAAQ,EAAQ,OAAO,IAAK,IAAW,CAAE,KAAM,4BAA6B,GAAG,CAAM,EAAE,CAAC,CAcnG,CCxCA,SAAgB,EAAyB,EAAkD,CACzF,IAAM,EAAS,EAAA,EAAqB,CAAK,EACzC,GAAI,CAAC,EAAO,QACV,MAAO,CAAE,QAAS,GAAO,KAAM,KAAM,OAAQ,EAAO,OAAQ,SAAU,CAAC,CAAE,EAE3E,GAAI,EAAO,WAAa,IAAA,GACtB,MAAO,CAAE,QAAS,GAAM,KAAM,EAAO,KAAM,OAAQ,CAAC,EAAG,SAAU,EAAO,QAAS,EAGnF,IAAM,EAAW,EAAA,EAAyB,EAAO,SAAU,EAAO,IAAI,EAItE,OAHK,EAAS,QAGP,CACL,QAAS,GACT,KAAM,CAAE,GAAG,EAAO,KAAM,SAAU,EAAS,IAAK,EAChD,OAAQ,CAAC,EACT,SAAU,EAAO,QACnB,EAPS,CAAE,QAAS,GAAO,KAAM,KAAM,OAAQ,EAAS,OAAQ,SAAU,CAAC,CAAE,CAQ/E,CAEA,SAAgB,EAA6B,EAAgD,CAC3F,GAAI,CACF,OAAO,EAAyB,KAAK,MAAM,CAAI,CAAC,CAClD,OAAS,EAAO,CACd,MAAO,CACL,QAAS,GACT,KAAM,KACN,OAAQ,CACN,CACE,KAAM,CAAC,EACP,QAAS,aAAiB,MAAQ,EAAM,QAAU,qBACpD,CACF,EACA,SAAU,CAAC,CACb,CACF,CACF"}
@@ -0,0 +1,269 @@
1
+ import { O as e, V as t } from "./geometryState.schema-D0ixyGYE.js";
2
+ import { d as n, f as r, i, l as a, n as o, o as s, r as c, t as l } from "./goals-C3ZwbEh_.js";
3
+ import { a as u, c as d, d as f, i as p, l as m, n as h, o as g, r as _, s as v, t as y, u as b } from "./geometryAttemptStatus-5L_q6-9l.js";
4
+ //#region src/validation/validateGeometryState.ts
5
+ function x(e, t) {
6
+ return S(e, t).result;
7
+ }
8
+ function S(e, t) {
9
+ return w(e, t, !1).feedback;
10
+ }
11
+ function C(e, t) {
12
+ return w(e, t, !0);
13
+ }
14
+ function w(t, a, s) {
15
+ let l = t.goals.length === 0, u = t.grading?.extraObjects === "reject", d = s || u;
16
+ if (l && !s) return {
17
+ feedback: {
18
+ result: {
19
+ status: "incorrect",
20
+ goals: []
21
+ },
22
+ goals: []
23
+ },
24
+ goals: [],
25
+ diagnostics: [],
26
+ extraEntityIds: []
27
+ };
28
+ let f = n(t, a), p = {
29
+ exercise: t,
30
+ points: f.points
31
+ }, m = [], h = [], g = [];
32
+ for (let n of a.answerEntityIds) {
33
+ if (e(t.entities, n)) continue;
34
+ let r = f.definitionOf(n);
35
+ if (r) {
36
+ if (d && g.push(n), f.resolvedOf(n) === void 0) {
37
+ d && h.push({
38
+ id: n,
39
+ definition: r
40
+ });
41
+ continue;
42
+ }
43
+ m.push({
44
+ id: n,
45
+ definition: r
46
+ });
47
+ }
48
+ }
49
+ let _ = [], v = [], y = /* @__PURE__ */ new Set();
50
+ for (let e of t.goals) {
51
+ let t = m.filter((t) => c(t, e, p));
52
+ if (d) for (let e of t) y.add(e.id);
53
+ let n = t.length > 0, a = n && !s ? [] : m.filter((t) => i(t, e, p)), l = n ? t : a;
54
+ if (_.push({
55
+ id: e.id,
56
+ status: n ? "correct" : "incorrect",
57
+ constructionIds: l.filter((e) => !r(e)).map((e) => e.id),
58
+ pointIds: l.filter(r).map((e) => e.id)
59
+ }), !s) continue;
60
+ let u = h.filter((t) => o(t, e));
61
+ v.push({
62
+ id: e.id,
63
+ status: n ? "correct" : "incorrect",
64
+ code: n ? "goal-satisfied" : m.some((t) => o(t, e)) ? "goal-not-satisfied" : u.length > 0 ? "unresolved-candidate" : "no-candidate",
65
+ matchedEntityIds: E(t),
66
+ relevantEntityIds: E(a),
67
+ unresolvedEntityIds: E(u)
68
+ });
69
+ }
70
+ let b = d ? T(g, y, f) : [], x = {
71
+ status: !l && _.every((e) => e.status === "correct") && !(u && b.length > 0) ? "correct" : "incorrect",
72
+ goals: _.map(({ id: e, status: t }) => ({
73
+ id: e,
74
+ status: t
75
+ }))
76
+ }, S = [];
77
+ return l && S.push({
78
+ code: "no-goals",
79
+ entityIds: []
80
+ }), h.length > 0 && S.push({
81
+ code: "unresolved-entity",
82
+ entityIds: E(h)
83
+ }), u && b.length > 0 && S.push({
84
+ code: "extra-objects",
85
+ entityIds: b
86
+ }), {
87
+ feedback: {
88
+ result: x,
89
+ goals: _
90
+ },
91
+ goals: v,
92
+ diagnostics: S,
93
+ extraEntityIds: b
94
+ };
95
+ }
96
+ function T(e, t, n) {
97
+ let r = new Set(t), i = [...t];
98
+ for (; i.length > 0;) {
99
+ let e = i.pop();
100
+ if (e !== void 0) for (let t of n.parentsOf(e)) r.has(t) || (r.add(t), i.push(t));
101
+ }
102
+ return [...new Set(e)].filter((e) => !r.has(e));
103
+ }
104
+ function E(e) {
105
+ return [...new Set(e.map((e) => e.id))];
106
+ }
107
+ //#endregion
108
+ //#region src/validation/checkGeometryAnswer.ts
109
+ function D(e, t) {
110
+ let n = _(e);
111
+ if (!n.success) return {
112
+ success: !1,
113
+ data: null,
114
+ errors: n.errors.map((e) => ({
115
+ ...e,
116
+ source: "exercise"
117
+ })),
118
+ warnings: []
119
+ };
120
+ let r = b(t, n.data);
121
+ return r.success ? {
122
+ success: !0,
123
+ data: S(n.data, r.data),
124
+ fingerprints: {
125
+ exercise: v(n.data),
126
+ attempt: g(r.data)
127
+ },
128
+ errors: [],
129
+ warnings: n.warnings
130
+ } : {
131
+ success: !1,
132
+ data: null,
133
+ errors: r.errors.map((e) => ({
134
+ ...e,
135
+ source: "geometry"
136
+ })),
137
+ warnings: []
138
+ };
139
+ }
140
+ function O(e, t) {
141
+ let n = _(e);
142
+ if (!n.success) return {
143
+ success: !1,
144
+ data: null,
145
+ errors: n.errors.map((e) => ({
146
+ ...e,
147
+ source: "exercise",
148
+ code: "invalid-exercise"
149
+ })),
150
+ warnings: []
151
+ };
152
+ let r = b(t, n.data);
153
+ return r.success ? {
154
+ success: !0,
155
+ data: C(n.data, r.data),
156
+ fingerprints: {
157
+ exercise: v(n.data),
158
+ attempt: g(r.data)
159
+ },
160
+ errors: [],
161
+ warnings: n.warnings
162
+ } : {
163
+ success: !1,
164
+ data: null,
165
+ errors: r.errors.map((e) => ({
166
+ ...e,
167
+ source: "geometry",
168
+ code: "invalid-attempt"
169
+ })),
170
+ warnings: []
171
+ };
172
+ }
173
+ //#endregion
174
+ //#region src/validation/revealGeometryAnswers.ts
175
+ function k(e) {
176
+ let t = a(e);
177
+ return e.goals.map((n) => ({
178
+ id: n.id,
179
+ shape: s(n, {
180
+ exercise: e,
181
+ points: t
182
+ })
183
+ }));
184
+ }
185
+ //#endregion
186
+ //#region src/validation/revealGeometryAttempt.ts
187
+ function A(e) {
188
+ return {
189
+ success: !1,
190
+ data: null,
191
+ errors: e
192
+ };
193
+ }
194
+ function j(e) {
195
+ let t = _(e);
196
+ if (!t.success) return A(t.errors.map((e) => ({
197
+ code: "invalid-exercise",
198
+ ...e
199
+ })));
200
+ if (t.solution === void 0) return A([{
201
+ code: "invalid-canonical-attempt",
202
+ path: ["solution"],
203
+ message: "this exercise has no canonical solution"
204
+ }]);
205
+ let n = p(t.solution, t.data);
206
+ return n.success ? x(t.data, n.data).status === "correct" ? {
207
+ success: !0,
208
+ data: n.data,
209
+ errors: []
210
+ } : A([{
211
+ code: "canonical-attempt-incorrect",
212
+ path: ["solution"],
213
+ message: "the canonical solution does not satisfy this exercise"
214
+ }]) : A(n.errors.map((e) => ({
215
+ code: "invalid-canonical-attempt",
216
+ ...e
217
+ })));
218
+ }
219
+ //#endregion
220
+ //#region src/validation/validateGeometryExercise.ts
221
+ function M(e) {
222
+ let t = _(e);
223
+ if (!t.success) return {
224
+ success: !1,
225
+ data: null,
226
+ errors: t.errors,
227
+ warnings: []
228
+ };
229
+ if (t.solution === void 0) return {
230
+ success: !0,
231
+ data: t.data,
232
+ errors: [],
233
+ warnings: t.warnings
234
+ };
235
+ let n = p(t.solution, t.data);
236
+ return n.success ? {
237
+ success: !0,
238
+ data: {
239
+ ...t.data,
240
+ solution: n.data
241
+ },
242
+ errors: [],
243
+ warnings: t.warnings
244
+ } : {
245
+ success: !1,
246
+ data: null,
247
+ errors: n.errors,
248
+ warnings: []
249
+ };
250
+ }
251
+ function N(e) {
252
+ try {
253
+ return M(JSON.parse(e));
254
+ } catch (e) {
255
+ return {
256
+ success: !1,
257
+ data: null,
258
+ errors: [{
259
+ path: [],
260
+ message: e instanceof Error ? e.message : "Invalid JSON syntax"
261
+ }],
262
+ warnings: []
263
+ };
264
+ }
265
+ }
266
+ //#endregion
267
+ export { D as checkGeometryAnswer, O as checkGeometryAnswerDetailed, y as createEmptyGeometryAttempt, d as deriveGeometryCanvasFeedback, S as evaluateGeometryState, C as evaluateGeometryStateDetailed, u as getGeometryExerciseWarnings, l as getGoalKindHandler, h as hasGeometryWork, t as intersectionsOf, k as revealGeometryAnswers, j as revealGeometryAttempt, m as serializeGeometryState, M as validateGeometryExercise, N as validateGeometryExerciseJson, x as validateGeometryState, b as validateGeometryStateInput, f as validateGeometryStateJson };
268
+
269
+ //# sourceMappingURL=validation.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.mjs","names":[],"sources":["../src/validation/validateGeometryState.ts","../src/validation/checkGeometryAnswer.ts","../src/validation/revealGeometryAnswers.ts","../src/validation/revealGeometryAttempt.ts","../src/validation/validateGeometryExercise.ts"],"sourcesContent":["import { entryOf } from '../geometry/entityRecord'\nimport type { EntityId } from '../geometry/entityModel'\nimport type { GeometryExercise } from '../schemas/exercise.schema'\nimport type { GeometryState } from '../schemas/geometryState.schema'\nimport { isCandidatePoint, type GoalCandidate } from '../geometry/goalCandidate'\nimport { buildGeometryContext } from '../state/geometryContext'\nimport type {\n DetailedGeometryFeedback,\n DetailedGoalResult,\n GeometryDiagnostic,\n GeometryValidationFeedback,\n GoalGeometryFeedback,\n ValidationContext,\n ValidationResult,\n} from './types'\nimport { goalAcceptsCandidate, goalSatisfiedBy, isRelevantGoalAttempt } from './goals'\n\nexport function validateGeometryState(\n exercise: GeometryExercise,\n geometry: GeometryState,\n): ValidationResult {\n return evaluateGeometryState(exercise, geometry).result\n}\n\nexport function evaluateGeometryState(\n exercise: GeometryExercise,\n geometry: GeometryState,\n): GeometryValidationFeedback {\n return evaluate(exercise, geometry, false).feedback\n}\n\n/**\n * The same grading, reported rather than summarized: why each goal landed where\n * it did, as stable codes and entity ids (RFC 0004 § Decision 5). It measures\n * nothing the plain evaluation does not — the codes are read off the existing\n * goal handlers' own predicates — so the two can never disagree.\n *\n * `feedback` is exactly what `evaluateGeometryState()` returns for the same\n * inputs. The extra work is one relevance pass per satisfied goal and the\n * unresolved bookkeeping, which the plain path still skips.\n */\nexport function evaluateGeometryStateDetailed(\n exercise: GeometryExercise,\n geometry: GeometryState,\n): DetailedGeometryFeedback {\n return evaluate(exercise, geometry, true)\n}\n\nfunction evaluate(\n exercise: GeometryExercise,\n geometry: GeometryState,\n detailed: boolean,\n): DetailedGeometryFeedback {\n // An exercise nobody can answer is incorrect, and the report now says so in\n // one word rather than leaving a host to infer it from an empty goal list.\n // The plain path stops here, as it always has; the report does not, because\n // an unresolved answer entity is reported whatever the goals say — there is\n // simply no goal loop to run below.\n const noGoals = exercise.goals.length === 0\n // Absence means `allow` (ADR 0013), so an exercise authored before v3 keeps\n // exactly the verdict it had. The extra-object sets cost a closure walk, so\n // the plain path computes them only when the policy actually reads them:\n // under `allow` they are reported and never graded on.\n const strict = exercise.grading?.extraObjects === 'reject'\n const needsExtras = detailed || strict\n if (noGoals && !detailed) {\n return {\n feedback: { result: { status: 'incorrect', goals: [] }, goals: [] },\n goals: [],\n diagnostics: [],\n extraEntityIds: [],\n }\n }\n\n // Coordinates come from the dependency graph, not from storage: a derived\n // point is wherever its parents currently put it. A point that cannot be\n // resolved (its object was deleted, its intersection vanished) is absent\n // here and therefore cannot satisfy anything.\n const scene = buildGeometryContext(exercise, geometry)\n // The scene's own index, not a copy: `ValidationContext.points` is read-only\n // by contract (M2.3.c), so there is nothing to defend it against. The copy\n // this replaced was one `Map` allocation and one full rehash per validation.\n const context: ValidationContext = { exercise, points: scene.points }\n // One list for every kind, which is what `answerEntityIds` is: v1 kept a\n // candidacy list for points only and treated every construction as a\n // candidate, and the migration reproduces that by naming both. A goal kind\n // decides for itself which candidates it can be satisfied by (a midpoint goal\n // wants a point, a perpendicular goal wants a segment or line); points the\n // student only used as scaffolding are not named here and are never\n // candidates.\n //\n // An entity that no longer resolves has no coordinates to measure, so it is\n // dropped here rather than left for a handler to trip over: handlers may\n // assume every candidate they are handed can be looked up in `points`. An\n // entity resolves exactly when everything it is built on does, which is the\n // index's answer rather than a second scan.\n const candidates: GoalCandidate[] = []\n // Answer entities that exist but have no coordinates this evaluation. The\n // plain path drops them silently; the report names them, because \"you built\n // it and then deleted what it stood on\" is not the same as \"you built\n // nothing\".\n const unresolved: GoalCandidate[] = []\n // Set `A` of RFC 0004 § Decision 6, in answer order: every id the attempt\n // owns and names as an answer, resolved or not. The extra-object policy\n // subtracts from this list and nothing else, so scaffolding the student never\n // offered as an answer cannot be an extra.\n const answered: EntityId[] = []\n for (const id of geometry.answerEntityIds) {\n // A given is not an answer to anything (ADR 0008 § Amendment), whatever\n // the list says. `validateGeometryStateInput()` already strips these on\n // load, but grading takes both documents directly — a host holding a\n // migrated v1 attempt it never loaded through the engine, or a store still\n // in memory, would otherwise have the exercise's own given graded as the\n // student's construction (M2.G.2).\n if (entryOf(exercise.entities, id)) continue\n const definition = scene.definitionOf(id)\n if (!definition) continue\n if (needsExtras) answered.push(id)\n if (scene.resolvedOf(id) === undefined) {\n if (needsExtras) unresolved.push({ id, definition })\n continue\n }\n candidates.push({ id, definition })\n }\n const goals: GoalGeometryFeedback[] = []\n const detailedGoals: DetailedGoalResult[] = []\n // Set `M`: every candidate that satisfies *some* goal. A union, not an\n // assignment — one entity may answer two goals and two entities may answer\n // one, and this policy deliberately does not count solutions.\n const matched = new Set<EntityId>()\n for (const goal of exercise.goals) {\n const matching = candidates.filter((candidate) => goalSatisfiedBy(candidate, goal, context))\n if (needsExtras) for (const candidate of matching) matched.add(candidate.id)\n const correct = matching.length > 0\n // Highlighting wants relevance only when the goal is unsatisfied; the\n // report wants it either way, so a correct goal still says which other\n // attempts were aimed at it.\n const relevant =\n correct && !detailed\n ? []\n : candidates.filter((candidate) => isRelevantGoalAttempt(candidate, goal, context))\n const shown = correct ? matching : relevant\n goals.push({\n id: goal.id,\n status: correct ? 'correct' : 'incorrect',\n constructionIds: shown.filter((candidate) => !isCandidatePoint(candidate)).map((c) => c.id),\n pointIds: shown.filter(isCandidatePoint).map((candidate) => candidate.id),\n })\n if (!detailed) continue\n const unresolvedForGoal = unresolved.filter((candidate) =>\n goalAcceptsCandidate(candidate, goal),\n )\n detailedGoals.push({\n id: goal.id,\n status: correct ? 'correct' : 'incorrect',\n code: correct\n ? 'goal-satisfied'\n : candidates.some((candidate) => goalAcceptsCandidate(candidate, goal))\n ? 'goal-not-satisfied'\n : unresolvedForGoal.length > 0\n ? 'unresolved-candidate'\n : 'no-candidate',\n matchedEntityIds: distinctIds(matching),\n relevantEntityIds: distinctIds(relevant),\n unresolvedEntityIds: distinctIds(unresolvedForGoal),\n })\n }\n // `A − (M ∪ S)`: answer entities no goal needed, and that nothing a goal\n // needed was built on. Empty unless the policy or the report asked for it.\n const extraEntityIds = needsExtras ? withoutSupport(answered, matched, scene) : []\n const goalsMet = !noGoals && goals.every((goal) => goal.status === 'correct')\n const result: ValidationResult = {\n // `every` on an empty list is vacuously true, and a goalless exercise is\n // incorrect — the one place the two disagree.\n //\n // Under `reject`, an extra answer entity makes the attempt incorrect while\n // every goal stays as its own predicate found it: \"the goals are met and\n // something unused is still on the canvas\" is a different thing from a\n // failed goal, and the diagnostic below is where it is said.\n status: goalsMet && !(strict && extraEntityIds.length > 0) ? 'correct' : 'incorrect',\n goals: goals.map(({ id, status }) => ({ id, status })),\n }\n const diagnostics: GeometryDiagnostic[] = []\n if (noGoals) diagnostics.push({ code: 'no-goals', entityIds: [] })\n // Informational: an unresolved entity does not make a satisfied exercise\n // incorrect. Reporting it regardless is what lets a host say \"this one is\n // no longer on the canvas\" instead of leaving it unexplained.\n if (unresolved.length > 0) {\n diagnostics.push({ code: 'unresolved-entity', entityIds: distinctIds(unresolved) })\n }\n // Only under `reject`: the list is reported either way, but it is a finding\n // about the attempt only where the author asked for strictness. Last, because\n // an unresolved extra is explained by the diagnostic above it.\n if (strict && extraEntityIds.length > 0) {\n diagnostics.push({ code: 'extra-objects', entityIds: extraEntityIds })\n }\n return { feedback: { result, goals }, goals: detailedGoals, diagnostics, extraEntityIds }\n}\n\n/**\n * `answered` minus the matched entities and minus set `S`, their transitive\n * parents — the support closure.\n *\n * Support is exempt because it is not an alternative answer: the two points a\n * correct segment is drawn between, and the helper objects a correct derived\n * point stands on, are the construction, however the student named them. That\n * is why the walk goes *up* the graph from what satisfied a goal rather than\n * down from every answer entity.\n *\n * An unresolved answer entity cannot be in `matched` — nothing measured it —\n * and it can only be support if something that did resolve was built on it,\n * which is impossible. So it stays, which is the reported outcome RFC 0004 §\n * Decision 6 names.\n */\nfunction withoutSupport(\n answered: readonly EntityId[],\n matched: ReadonlySet<EntityId>,\n scene: { parentsOf(id: EntityId): readonly EntityId[] },\n): EntityId[] {\n const exempt = new Set<EntityId>(matched)\n const pending = [...matched]\n // Visited-bounded, because the graph is walked by id: a cycle is\n // unrepresentable in a stored document, but this must not depend on that.\n while (pending.length > 0) {\n const id = pending.pop()\n if (id === undefined) continue\n for (const parent of scene.parentsOf(id)) {\n if (exempt.has(parent)) continue\n exempt.add(parent)\n pending.push(parent)\n }\n }\n return [...new Set(answered)].filter((id) => !exempt.has(id))\n}\n\n/** `answerEntityIds` order, each id once — the reporting order RFC 0004 fixes. */\nfunction distinctIds(candidates: readonly GoalCandidate[]): string[] {\n return [...new Set(candidates.map((candidate) => candidate.id))]\n}\n","import type { DetailedGeometryFeedback, GeometryValidationFeedback } from './types'\nimport type { GeometryExerciseWarning } from './getGeometryExerciseWarnings'\nimport { fingerprintGeometryAttempt, fingerprintGeometryExercise } from './gradingFingerprints'\nimport { loadExerciseDocument } from './exerciseLoad'\nimport type { GeometryExerciseValidationIssue } from './validateGeometryExercise'\nimport { evaluateGeometryState, evaluateGeometryStateDetailed } from './validateGeometryState'\nimport { validateGeometryStateInput } from './validateGeometryStateInput'\n\nexport interface CheckGeometryAnswerIssue extends GeometryExerciseValidationIssue {\n source: 'exercise' | 'geometry'\n}\n\n/**\n * Which grading inputs a successful check described (RFC 0005 § Decision 2).\n * Both are opaque and engine-produced: equal for equal normalized content,\n * whatever the object identity or key order, and the exercise member ignores\n * the authored solution. A host passes the whole result on and never computes\n * or compares these itself.\n */\nexport interface CheckGeometryAnswerFingerprints {\n exercise: string\n attempt: string\n}\n\nexport type CheckGeometryAnswerResult =\n | {\n success: true\n data: GeometryValidationFeedback\n fingerprints: CheckGeometryAnswerFingerprints\n errors: []\n warnings: GeometryExerciseWarning[]\n }\n | {\n success: false\n data: null\n errors: CheckGeometryAnswerIssue[]\n warnings: []\n }\n\n/**\n * Safe public Check entry point for untrusted application data. Structure is\n * validated first; valid geometry is then evaluated by the JSXGraph-backed\n * goal handlers used by validateGeometryState().\n */\nexport function checkGeometryAnswer(\n exerciseInput: unknown,\n geometryInput: unknown,\n): CheckGeometryAnswerResult {\n // The solution-free load: grading ignores the authored solution, so a\n // malformed one cannot fail a check (ADR 0015).\n const exercise = loadExerciseDocument(exerciseInput)\n if (!exercise.success) {\n return {\n success: false,\n data: null,\n errors: exercise.errors.map((issue) => ({ ...issue, source: 'exercise' })),\n warnings: [],\n }\n }\n\n const geometry = validateGeometryStateInput(geometryInput, exercise.data)\n if (!geometry.success) {\n return {\n success: false,\n data: null,\n errors: geometry.errors.map((issue) => ({ ...issue, source: 'geometry' })),\n warnings: [],\n }\n }\n\n return {\n success: true,\n data: evaluateGeometryState(exercise.data, geometry.data),\n fingerprints: {\n exercise: fingerprintGeometryExercise(exercise.data),\n attempt: fingerprintGeometryAttempt(geometry.data),\n },\n errors: [],\n warnings: exercise.warnings,\n }\n}\n\n/**\n * Which document was rejected, as a code rather than a sentence. `message`\n * stays the schema's human-readable detail and is never a reason code: a\n * malformed document is not a student's wrong answer, and nothing here reaches\n * geometry evaluation (RFC 0004 § Decision 5).\n */\nexport type CheckGeometryAnswerErrorCode = 'invalid-exercise' | 'invalid-attempt'\n\nexport interface DetailedCheckGeometryAnswerIssue extends CheckGeometryAnswerIssue {\n code: CheckGeometryAnswerErrorCode\n}\n\nexport type DetailedCheckGeometryAnswerResult =\n | {\n success: true\n data: DetailedGeometryFeedback\n fingerprints: CheckGeometryAnswerFingerprints\n errors: []\n warnings: GeometryExerciseWarning[]\n }\n | {\n success: false\n data: null\n errors: DetailedCheckGeometryAnswerIssue[]\n warnings: []\n }\n\n/**\n * `checkGeometryAnswer()` with the structured report: same untrusted inputs,\n * same success discriminant, fingerprints and warnings, detailed data on\n * success.\n */\nexport function checkGeometryAnswerDetailed(\n exerciseInput: unknown,\n geometryInput: unknown,\n): DetailedCheckGeometryAnswerResult {\n // The solution-free load: grading ignores the authored solution, so a\n // malformed one cannot fail a check (ADR 0015).\n const exercise = loadExerciseDocument(exerciseInput)\n if (!exercise.success) {\n return {\n success: false,\n data: null,\n errors: exercise.errors.map((issue) => ({\n ...issue,\n source: 'exercise',\n code: 'invalid-exercise',\n })),\n warnings: [],\n }\n }\n\n const geometry = validateGeometryStateInput(geometryInput, exercise.data)\n if (!geometry.success) {\n return {\n success: false,\n data: null,\n errors: geometry.errors.map((issue) => ({\n ...issue,\n source: 'geometry',\n code: 'invalid-attempt',\n })),\n warnings: [],\n }\n }\n\n return {\n success: true,\n data: evaluateGeometryStateDetailed(exercise.data, geometry.data),\n fingerprints: {\n exercise: fingerprintGeometryExercise(exercise.data),\n attempt: fingerprintGeometryAttempt(geometry.data),\n },\n errors: [],\n warnings: exercise.warnings,\n }\n}\n","import type { GeometryExercise } from '../schemas/exercise.schema'\nimport { resolveExercisePoints } from '../state/resolvePoints'\nimport { revealedAnswerFor } from './goals'\nimport type { RevealedAnswer } from './types'\n\nexport function revealGeometryAnswers(exercise: GeometryExercise): RevealedAnswer[] {\n // The exercise's own points, resolved: a canonical answer is measured\n // against the givens and nothing else, so there is no attempt to index here.\n const points = resolveExercisePoints(exercise)\n\n return exercise.goals.map((goal) => ({\n id: goal.id,\n shape: revealedAnswerFor(goal, { exercise, points }),\n }))\n}\n","import type { GeometryState } from '../schemas/geometryState.schema'\nimport { loadExerciseDocument, validateEmbeddedSolution } from './exerciseLoad'\nimport { validateGeometryState } from './validateGeometryState'\n\n/**\n * Why no canonical attempt came back, as a code rather than a sentence (RFC\n * 0005 § Decision 4). The three are kept apart because a host acts on them\n * differently: a broken exercise is the whole widget's problem, a missing or\n * malformed solution is an authoring gap, and an incorrect one means the\n * authored answer and the goals disagree.\n */\nexport type RevealGeometryAttemptErrorCode =\n 'invalid-exercise' | 'invalid-canonical-attempt' | 'canonical-attempt-incorrect'\n\nexport interface RevealGeometryAttemptIssue {\n code: RevealGeometryAttemptErrorCode\n path: Array<string | number>\n message: string\n}\n\nexport type RevealGeometryAttemptResult =\n | { success: true; data: GeometryState; errors: [] }\n | { success: false; data: null; errors: RevealGeometryAttemptIssue[] }\n\nfunction refused(errors: RevealGeometryAttemptIssue[]): RevealGeometryAttemptResult {\n return { success: false, data: null, errors }\n}\n\n/**\n * The authored canonical attempt an exercise embeds, for a host's Reveal\n * (ADR 0015). Synchronous and DOM-free, and safe on untrusted input: the\n * exercise is migrated and parsed, then its `solution` is migrated, parsed and\n * normalized as an attempt against that exercise, then graded under the\n * exercise's own policy. Only a solution that grades correct is returned.\n *\n * Nothing is synthesized from goals and nothing is merged with student work:\n * the host replaces its attempt value with `data`. Paths of a malformed\n * solution are rooted at `solution`, so they point into the exercise document\n * the host holds.\n */\nexport function revealGeometryAttempt(exerciseInput: unknown): RevealGeometryAttemptResult {\n // The same two stages `validateGeometryExercise()` runs, kept apart here only\n // so each failure gets its own code.\n const exercise = loadExerciseDocument(exerciseInput)\n if (!exercise.success) {\n return refused(exercise.errors.map((issue) => ({ code: 'invalid-exercise', ...issue })))\n }\n\n if (exercise.solution === undefined) {\n return refused([\n {\n code: 'invalid-canonical-attempt',\n path: ['solution'],\n message: 'this exercise has no canonical solution',\n },\n ])\n }\n\n const attempt = validateEmbeddedSolution(exercise.solution, exercise.data)\n if (!attempt.success) {\n return refused(attempt.errors.map((issue) => ({ code: 'invalid-canonical-attempt', ...issue })))\n }\n\n if (validateGeometryState(exercise.data, attempt.data).status !== 'correct') {\n return refused([\n {\n code: 'canonical-attempt-incorrect',\n path: ['solution'],\n message: 'the canonical solution does not satisfy this exercise',\n },\n ])\n }\n\n return { success: true, data: attempt.data, errors: [] }\n}\n","import type { GeometryExercise } from '../schemas/exercise.schema'\nimport { loadExerciseDocument, validateEmbeddedSolution } from './exerciseLoad'\nimport type { GeometryExerciseWarning } from './getGeometryExerciseWarnings'\n\nexport interface GeometryExerciseValidationIssue {\n path: Array<string | number>\n message: string\n}\n\nexport type GeometryExerciseValidationResult =\n | {\n success: true\n data: GeometryExercise\n errors: []\n warnings: GeometryExerciseWarning[]\n }\n | {\n success: false\n data: null\n errors: GeometryExerciseValidationIssue[]\n warnings: []\n }\n\n/**\n * The whole stored exercise, authored solution included. Stored exercises are\n * brought up to the current version before their structure is checked, exactly\n * as attempts are (M2.6.b), and an embedded `solution` is then migrated and\n * checked against the exercise as an attempt (ADR 0015), with its issues rooted\n * at `solution`. On success `data.solution` is that normalized attempt.\n *\n * Grading does not go through here: Check and the student component load the\n * solution-free projection, so a broken solution never disables them. An\n * authoring tool does, and learns about it at save time.\n */\nexport function validateGeometryExercise(input: unknown): GeometryExerciseValidationResult {\n const loaded = loadExerciseDocument(input)\n if (!loaded.success) {\n return { success: false, data: null, errors: loaded.errors, warnings: [] }\n }\n if (loaded.solution === undefined) {\n return { success: true, data: loaded.data, errors: [], warnings: loaded.warnings }\n }\n\n const solution = validateEmbeddedSolution(loaded.solution, loaded.data)\n if (!solution.success) {\n return { success: false, data: null, errors: solution.errors, warnings: [] }\n }\n return {\n success: true,\n data: { ...loaded.data, solution: solution.data },\n errors: [],\n warnings: loaded.warnings,\n }\n}\n\nexport function validateGeometryExerciseJson(json: string): GeometryExerciseValidationResult {\n try {\n return validateGeometryExercise(JSON.parse(json))\n } catch (error) {\n return {\n success: false,\n data: null,\n errors: [\n {\n path: [],\n message: error instanceof Error ? error.message : 'Invalid JSON syntax',\n },\n ],\n warnings: [],\n }\n }\n}\n"],"mappings":";;;;AAiBA,SAAgB,EACd,GACA,GACkB;CAClB,OAAO,EAAsB,GAAU,CAAQ,CAAC,CAAC;AACnD;AAEA,SAAgB,EACd,GACA,GAC4B;CAC5B,OAAO,EAAS,GAAU,GAAU,EAAK,CAAC,CAAC;AAC7C;AAYA,SAAgB,EACd,GACA,GAC0B;CAC1B,OAAO,EAAS,GAAU,GAAU,EAAI;AAC1C;AAEA,SAAS,EACP,GACA,GACA,GAC0B;CAM1B,IAAM,IAAU,EAAS,MAAM,WAAW,GAKpC,IAAS,EAAS,SAAS,iBAAiB,UAC5C,IAAc,KAAY;CAChC,IAAI,KAAW,CAAC,GACd,OAAO;EACL,UAAU;GAAE,QAAQ;IAAE,QAAQ;IAAa,OAAO,CAAC;GAAE;GAAG,OAAO,CAAC;EAAE;EAClE,OAAO,CAAC;EACR,aAAa,CAAC;EACd,gBAAgB,CAAC;CACnB;CAOF,IAAM,IAAQ,EAAqB,GAAU,CAAQ,GAI/C,IAA6B;EAAE;EAAU,QAAQ,EAAM;CAAO,GAc9D,IAA8B,CAAC,GAK/B,IAA8B,CAAC,GAK/B,IAAuB,CAAC;CAC9B,KAAK,IAAM,KAAM,EAAS,iBAAiB;EAOzC,IAAI,EAAQ,EAAS,UAAU,CAAE,GAAG;EACpC,IAAM,IAAa,EAAM,aAAa,CAAE;EACnC,OAEL;OADI,KAAa,EAAS,KAAK,CAAE,GAC7B,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