@intellectif/lk-react 23.1.0 → 23.1.2

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 (360) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/README.md +9 -5
  3. package/dist/ActivityErrorBoundary-B379hvtL.cjs +39 -0
  4. package/dist/ActivityErrorBoundary-B379hvtL.cjs.map +1 -0
  5. package/dist/ActivityErrorBoundary-Dw6SbWv3.js +34 -0
  6. package/dist/ActivityErrorBoundary-Dw6SbWv3.js.map +1 -0
  7. package/dist/ActivityMedia-CQQTRNl7.cjs +641 -0
  8. package/dist/ActivityMedia-CQQTRNl7.cjs.map +1 -0
  9. package/dist/ActivityMedia-vDiP-Psa.js +636 -0
  10. package/dist/ActivityMedia-vDiP-Psa.js.map +1 -0
  11. package/dist/ActivityPreview-1hhTkYuj.js +240 -0
  12. package/dist/ActivityPreview-1hhTkYuj.js.map +1 -0
  13. package/dist/ActivityPreview-BKr34exz.cjs +245 -0
  14. package/dist/ActivityPreview-BKr34exz.cjs.map +1 -0
  15. package/dist/ActivitySequence-CkX87pfB.js +839 -0
  16. package/dist/ActivitySequence-CkX87pfB.js.map +1 -0
  17. package/dist/ActivitySequence-CmoSyDnp.cjs +844 -0
  18. package/dist/ActivitySequence-CmoSyDnp.cjs.map +1 -0
  19. package/dist/Dictation-BlxRp-3k.js +926 -0
  20. package/dist/Dictation-BlxRp-3k.js.map +1 -0
  21. package/dist/Dictation-jECzL88E.cjs +931 -0
  22. package/dist/Dictation-jECzL88E.cjs.map +1 -0
  23. package/dist/FeedbackRegion-BNNMtTY-.cjs +108 -0
  24. package/dist/FeedbackRegion-BNNMtTY-.cjs.map +1 -0
  25. package/dist/FeedbackRegion-CyPSp8bA.js +85 -0
  26. package/dist/FeedbackRegion-CyPSp8bA.js.map +1 -0
  27. package/dist/FillInTheBlanks-B6xzqYXx.js +474 -0
  28. package/dist/FillInTheBlanks-B6xzqYXx.js.map +1 -0
  29. package/dist/FillInTheBlanks-BpKhdHg2.cjs +479 -0
  30. package/dist/FillInTheBlanks-BpKhdHg2.cjs.map +1 -0
  31. package/dist/GapSelect-DUSiaEQH.js +441 -0
  32. package/dist/GapSelect-DUSiaEQH.js.map +1 -0
  33. package/dist/GapSelect-payTq_Zn.cjs +446 -0
  34. package/dist/GapSelect-payTq_Zn.cjs.map +1 -0
  35. package/dist/InteractiveVideo-BguGv-HA.cjs +2955 -0
  36. package/dist/InteractiveVideo-BguGv-HA.cjs.map +1 -0
  37. package/dist/InteractiveVideo-Cg2jbU3j.js +2944 -0
  38. package/dist/InteractiveVideo-Cg2jbU3j.js.map +1 -0
  39. package/dist/LkAiProvider-DAPpA3PQ.d.cts +84 -0
  40. package/dist/LkAiProvider-DAPpA3PQ.d.cts.map +1 -0
  41. package/dist/LkAiProvider-QdEcIhoo.d.ts +84 -0
  42. package/dist/LkAiProvider-QdEcIhoo.d.ts.map +1 -0
  43. package/dist/LkIntlProvider-D_FdYXjQ.js +375 -0
  44. package/dist/LkIntlProvider-D_FdYXjQ.js.map +1 -0
  45. package/dist/LkIntlProvider-oi57lYB0.cjs +410 -0
  46. package/dist/LkIntlProvider-oi57lYB0.cjs.map +1 -0
  47. package/dist/MultipleChoice-COn5MtKY.cjs +433 -0
  48. package/dist/MultipleChoice-COn5MtKY.cjs.map +1 -0
  49. package/dist/MultipleChoice-Dra0_KYD.js +428 -0
  50. package/dist/MultipleChoice-Dra0_KYD.js.map +1 -0
  51. package/dist/PronunciationFeedback-DlMPGjkR.cjs +831 -0
  52. package/dist/PronunciationFeedback-DlMPGjkR.cjs.map +1 -0
  53. package/dist/PronunciationFeedback-Dxd6XPkO.js +772 -0
  54. package/dist/PronunciationFeedback-Dxd6XPkO.js.map +1 -0
  55. package/dist/ReadAloud-C8RhaUqV.js +1092 -0
  56. package/dist/{chunk-DC4CQCK5.js.map → ReadAloud-C8RhaUqV.js.map} +1 -1
  57. package/dist/ReadAloud-akDehitT.cjs +1103 -0
  58. package/dist/ReadAloud-akDehitT.cjs.map +1 -0
  59. package/dist/StimulusPanel-BgzByfkb.js +74 -0
  60. package/dist/StimulusPanel-BgzByfkb.js.map +1 -0
  61. package/dist/StimulusPanel-b66gaN3i.cjs +79 -0
  62. package/dist/StimulusPanel-b66gaN3i.cjs.map +1 -0
  63. package/dist/ThemeProvider-B6DyGqzh.d.cts +62 -0
  64. package/dist/ThemeProvider-B6DyGqzh.d.cts.map +1 -0
  65. package/dist/ThemeProvider-BCrxBaY-.d.ts +62 -0
  66. package/dist/ThemeProvider-BCrxBaY-.d.ts.map +1 -0
  67. package/dist/ThemeProvider-BRN1tj4n.cjs +187 -0
  68. package/dist/ThemeProvider-BRN1tj4n.cjs.map +1 -0
  69. package/dist/ThemeProvider-C7K9iMLX.js +158 -0
  70. package/dist/ThemeProvider-C7K9iMLX.js.map +1 -0
  71. package/dist/WrittenResponse-Bj3eFmGl.cjs +491 -0
  72. package/dist/WrittenResponse-Bj3eFmGl.cjs.map +1 -0
  73. package/dist/WrittenResponse-Cl8G6nO_.js +486 -0
  74. package/dist/WrittenResponse-Cl8G6nO_.js.map +1 -0
  75. package/dist/ai/LkAiProvider.cjs +34 -14
  76. package/dist/ai/LkAiProvider.cjs.map +1 -1
  77. package/dist/ai/LkAiProvider.d.cts +2 -83
  78. package/dist/ai/LkAiProvider.d.ts +2 -83
  79. package/dist/ai/LkAiProvider.js +33 -2
  80. package/dist/ai/LkAiProvider.js.map +1 -1
  81. package/dist/ai/useAiHelp.cjs +7 -25
  82. package/dist/ai/useAiHelp.d.cts +175 -177
  83. package/dist/ai/useAiHelp.d.cts.map +1 -0
  84. package/dist/ai/useAiHelp.d.ts +175 -177
  85. package/dist/ai/useAiHelp.d.ts.map +1 -0
  86. package/dist/ai/useAiHelp.js +3 -4
  87. package/dist/components/ActivityPreview.cjs +3 -29
  88. package/dist/components/ActivityPreview.d.cts +2 -81
  89. package/dist/components/ActivityPreview.d.ts +2 -81
  90. package/dist/components/ActivityPreview.js +2 -20
  91. package/dist/components/ActivitySequence.cjs +3 -30
  92. package/dist/components/ActivitySequence.d.cts +2 -432
  93. package/dist/components/ActivitySequence.d.ts +2 -432
  94. package/dist/components/ActivitySequence.js +2 -21
  95. package/dist/components/Dictation.cjs +4 -21
  96. package/dist/components/Dictation.d.cts +2 -19
  97. package/dist/components/Dictation.d.ts +2 -19
  98. package/dist/components/Dictation.js +3 -12
  99. package/dist/components/FillInTheBlanks.cjs +4 -20
  100. package/dist/components/FillInTheBlanks.d.cts +2 -30
  101. package/dist/components/FillInTheBlanks.d.ts +2 -30
  102. package/dist/components/FillInTheBlanks.js +3 -11
  103. package/dist/components/GapSelect.cjs +4 -20
  104. package/dist/components/GapSelect.d.cts +2 -27
  105. package/dist/components/GapSelect.d.ts +2 -27
  106. package/dist/components/GapSelect.js +3 -11
  107. package/dist/components/InteractiveVideo.cjs +5 -32
  108. package/dist/components/InteractiveVideo.d.cts +3 -291
  109. package/dist/components/InteractiveVideo.d.ts +3 -291
  110. package/dist/components/InteractiveVideo.js +3 -19
  111. package/dist/components/MultipleChoice.cjs +4 -20
  112. package/dist/components/MultipleChoice.d.cts +2 -26
  113. package/dist/components/MultipleChoice.d.ts +2 -26
  114. package/dist/components/MultipleChoice.js +3 -11
  115. package/dist/components/PronunciationFeedback.cjs +4 -17
  116. package/dist/components/PronunciationFeedback.d.cts +2 -90
  117. package/dist/components/PronunciationFeedback.d.ts +2 -90
  118. package/dist/components/PronunciationFeedback.js +3 -8
  119. package/dist/components/ReadAloud.cjs +4 -22
  120. package/dist/components/ReadAloud.d.cts +7 -11
  121. package/dist/components/ReadAloud.d.cts.map +1 -0
  122. package/dist/components/ReadAloud.d.ts +7 -11
  123. package/dist/components/ReadAloud.d.ts.map +1 -0
  124. package/dist/components/ReadAloud.js +3 -13
  125. package/dist/components/StimulusPanel.cjs +3 -14
  126. package/dist/components/StimulusPanel.d.cts +2 -51
  127. package/dist/components/StimulusPanel.d.ts +2 -51
  128. package/dist/components/StimulusPanel.js +2 -5
  129. package/dist/components/WrittenResponse.cjs +4 -19
  130. package/dist/components/WrittenResponse.d.cts +3 -18
  131. package/dist/components/WrittenResponse.d.ts +3 -18
  132. package/dist/components/WrittenResponse.js +3 -10
  133. package/dist/direction-Dq0_HtA5.js +183 -0
  134. package/dist/direction-Dq0_HtA5.js.map +1 -0
  135. package/dist/direction-K1pj0HCA.cjs +200 -0
  136. package/dist/direction-K1pj0HCA.cjs.map +1 -0
  137. package/dist/hooks/useActivityState.cjs +28 -10
  138. package/dist/hooks/useActivityState.cjs.map +1 -1
  139. package/dist/hooks/useActivityState.d.cts +25 -24
  140. package/dist/hooks/useActivityState.d.cts.map +1 -0
  141. package/dist/hooks/useActivityState.d.ts +25 -24
  142. package/dist/hooks/useActivityState.d.ts.map +1 -0
  143. package/dist/hooks/useActivityState.js +28 -2
  144. package/dist/hooks/useActivityState.js.map +1 -1
  145. package/dist/hooks/useSpeechRecorder.cjs +5 -16
  146. package/dist/hooks/useSpeechRecorder.d.cts +2 -127
  147. package/dist/hooks/useSpeechRecorder.d.ts +2 -127
  148. package/dist/hooks/useSpeechRecorder.js +3 -3
  149. package/dist/hooks/useXAPI.cjs +126 -10
  150. package/dist/hooks/useXAPI.cjs.map +1 -1
  151. package/dist/hooks/useXAPI.d.cts +14 -14
  152. package/dist/hooks/useXAPI.d.cts.map +1 -0
  153. package/dist/hooks/useXAPI.d.ts +14 -14
  154. package/dist/hooks/useXAPI.d.ts.map +1 -0
  155. package/dist/hooks/useXAPI.js +126 -2
  156. package/dist/hooks/useXAPI.js.map +1 -1
  157. package/dist/i18n/LkIntlProvider.cjs +9 -32
  158. package/dist/i18n/LkIntlProvider.d.cts +34 -38
  159. package/dist/i18n/LkIntlProvider.d.cts.map +1 -0
  160. package/dist/i18n/LkIntlProvider.d.ts +34 -38
  161. package/dist/i18n/LkIntlProvider.d.ts.map +1 -0
  162. package/dist/i18n/LkIntlProvider.js +3 -3
  163. package/dist/index-6P4rJHrJ.d.cts +432 -0
  164. package/dist/index-6P4rJHrJ.d.cts.map +1 -0
  165. package/dist/index-90CX504k.d.ts +90 -0
  166. package/dist/index-90CX504k.d.ts.map +1 -0
  167. package/dist/index-B_SgnjsC.d.cts +291 -0
  168. package/dist/index-B_SgnjsC.d.cts.map +1 -0
  169. package/dist/index-BavVW5z5.d.cts +25 -0
  170. package/dist/index-BavVW5z5.d.cts.map +1 -0
  171. package/dist/index-BhHv6Fiu.d.cts +28 -0
  172. package/dist/index-BhHv6Fiu.d.cts.map +1 -0
  173. package/dist/index-Bsu8VciA.d.ts +432 -0
  174. package/dist/index-Bsu8VciA.d.ts.map +1 -0
  175. package/dist/index-C1KGpD1k.d.ts +49 -0
  176. package/dist/index-C1KGpD1k.d.ts.map +1 -0
  177. package/dist/index-CKTpYTCC.d.cts +49 -0
  178. package/dist/index-CKTpYTCC.d.cts.map +1 -0
  179. package/dist/index-CO_SRFJj.d.ts +16 -0
  180. package/dist/index-CO_SRFJj.d.ts.map +1 -0
  181. package/dist/index-CSsuUsP7.d.cts +124 -0
  182. package/dist/index-CSsuUsP7.d.cts.map +1 -0
  183. package/dist/index-CunUyeuN.d.cts +78 -0
  184. package/dist/index-CunUyeuN.d.cts.map +1 -0
  185. package/dist/index-CzfRzks6.d.cts +90 -0
  186. package/dist/index-CzfRzks6.d.cts.map +1 -0
  187. package/dist/index-D14xtpBS.d.cts +24 -0
  188. package/dist/index-D14xtpBS.d.cts.map +1 -0
  189. package/dist/index-DHRPAPZf.d.ts +291 -0
  190. package/dist/index-DHRPAPZf.d.ts.map +1 -0
  191. package/dist/index-DLV6cK26.d.cts +16 -0
  192. package/dist/index-DLV6cK26.d.cts.map +1 -0
  193. package/dist/index-DbCCQ9cP.d.ts +124 -0
  194. package/dist/index-DbCCQ9cP.d.ts.map +1 -0
  195. package/dist/index-DeV5B2m5.d.ts +24 -0
  196. package/dist/index-DeV5B2m5.d.ts.map +1 -0
  197. package/dist/index-TZCJVSge.d.ts +28 -0
  198. package/dist/index-TZCJVSge.d.ts.map +1 -0
  199. package/dist/index-ZVvLHsd3.d.ts +25 -0
  200. package/dist/index-ZVvLHsd3.d.ts.map +1 -0
  201. package/dist/index-eQwBgpSw.d.ts +78 -0
  202. package/dist/index-eQwBgpSw.d.ts.map +1 -0
  203. package/dist/index.cjs +118 -163
  204. package/dist/index.cjs.map +1 -1
  205. package/dist/index.d.cts +20 -24
  206. package/dist/index.d.ts +20 -24
  207. package/dist/index.js +84 -29
  208. package/dist/index.js.map +1 -1
  209. package/dist/theme/ThemeProvider.cjs +8 -28
  210. package/dist/theme/ThemeProvider.d.cts +2 -59
  211. package/dist/theme/ThemeProvider.d.ts +2 -59
  212. package/dist/theme/ThemeProvider.js +3 -3
  213. package/dist/tries-CbbtZkdG.cjs +363 -0
  214. package/dist/tries-CbbtZkdG.cjs.map +1 -0
  215. package/dist/tries-DTHSrLCm.js +310 -0
  216. package/dist/tries-DTHSrLCm.js.map +1 -0
  217. package/dist/types-BOQd93x3.d.cts +994 -0
  218. package/dist/types-BOQd93x3.d.cts.map +1 -0
  219. package/dist/types-HIrgF_mS.d.ts +994 -0
  220. package/dist/types-HIrgF_mS.d.ts.map +1 -0
  221. package/dist/useAiHelp-B-ccDL5Q.js +906 -0
  222. package/dist/useAiHelp-B-ccDL5Q.js.map +1 -0
  223. package/dist/useAiHelp-h9yOLFqt.cjs +995 -0
  224. package/dist/useAiHelp-h9yOLFqt.cjs.map +1 -0
  225. package/dist/useSpeechRecorder--O_f-xvt.cjs +720 -0
  226. package/dist/useSpeechRecorder--O_f-xvt.cjs.map +1 -0
  227. package/dist/useSpeechRecorder-DtAYvl02.d.cts +154 -0
  228. package/dist/useSpeechRecorder-DtAYvl02.d.cts.map +1 -0
  229. package/dist/useSpeechRecorder-DtAYvl02.d.ts +154 -0
  230. package/dist/useSpeechRecorder-DtAYvl02.d.ts.map +1 -0
  231. package/dist/useSpeechRecorder-zIi9Dlw8.js +709 -0
  232. package/dist/useSpeechRecorder-zIi9Dlw8.js.map +1 -0
  233. package/package.json +10 -11
  234. package/dist/WrittenResponse-B7A5gHMj.d.ts +0 -115
  235. package/dist/WrittenResponse-BpL9p2Hn.d.cts +0 -115
  236. package/dist/ai/useAiHelp.cjs.map +0 -1
  237. package/dist/ai/useAiHelp.js.map +0 -1
  238. package/dist/chunk-2PNSVBLQ.cjs +0 -54
  239. package/dist/chunk-2PNSVBLQ.cjs.map +0 -1
  240. package/dist/chunk-2TW6WLBC.js +0 -80
  241. package/dist/chunk-2TW6WLBC.js.map +0 -1
  242. package/dist/chunk-4ZZWZSWI.js +0 -61
  243. package/dist/chunk-4ZZWZSWI.js.map +0 -1
  244. package/dist/chunk-6N43WDVG.js +0 -29
  245. package/dist/chunk-6N43WDVG.js.map +0 -1
  246. package/dist/chunk-7ALBSPYR.cjs +0 -436
  247. package/dist/chunk-7ALBSPYR.cjs.map +0 -1
  248. package/dist/chunk-7NFY3M3W.js +0 -234
  249. package/dist/chunk-7NFY3M3W.js.map +0 -1
  250. package/dist/chunk-7SB2MJA4.js +0 -29
  251. package/dist/chunk-7SB2MJA4.js.map +0 -1
  252. package/dist/chunk-ABJJ3LII.js +0 -434
  253. package/dist/chunk-ABJJ3LII.js.map +0 -1
  254. package/dist/chunk-BIGGXHAW.cjs +0 -342
  255. package/dist/chunk-BIGGXHAW.cjs.map +0 -1
  256. package/dist/chunk-C7QZE5BI.js +0 -430
  257. package/dist/chunk-C7QZE5BI.js.map +0 -1
  258. package/dist/chunk-CWTUWNV3.cjs +0 -2937
  259. package/dist/chunk-CWTUWNV3.cjs.map +0 -1
  260. package/dist/chunk-DC4CQCK5.js +0 -915
  261. package/dist/chunk-DS6HN3YR.cjs +0 -496
  262. package/dist/chunk-DS6HN3YR.cjs.map +0 -1
  263. package/dist/chunk-FDQR4GAZ.js +0 -240
  264. package/dist/chunk-FDQR4GAZ.js.map +0 -1
  265. package/dist/chunk-FKGMSOJF.js +0 -394
  266. package/dist/chunk-FKGMSOJF.js.map +0 -1
  267. package/dist/chunk-G6PXJ2SA.js +0 -823
  268. package/dist/chunk-G6PXJ2SA.js.map +0 -1
  269. package/dist/chunk-HNLRVRQR.js +0 -335
  270. package/dist/chunk-HNLRVRQR.js.map +0 -1
  271. package/dist/chunk-J3C72RPK.cjs +0 -31
  272. package/dist/chunk-J3C72RPK.cjs.map +0 -1
  273. package/dist/chunk-K63VPFOV.cjs +0 -134
  274. package/dist/chunk-K63VPFOV.cjs.map +0 -1
  275. package/dist/chunk-KFLIDTDU.cjs +0 -825
  276. package/dist/chunk-KFLIDTDU.cjs.map +0 -1
  277. package/dist/chunk-KHKH5LCT.cjs +0 -250
  278. package/dist/chunk-KHKH5LCT.cjs.map +0 -1
  279. package/dist/chunk-LBEKRN6Y.cjs +0 -664
  280. package/dist/chunk-LBEKRN6Y.cjs.map +0 -1
  281. package/dist/chunk-LPUWXIPR.cjs +0 -578
  282. package/dist/chunk-LPUWXIPR.cjs.map +0 -1
  283. package/dist/chunk-MCO52PV5.js +0 -520
  284. package/dist/chunk-MCO52PV5.js.map +0 -1
  285. package/dist/chunk-MKXEM2C5.cjs +0 -396
  286. package/dist/chunk-MKXEM2C5.cjs.map +0 -1
  287. package/dist/chunk-MXNC5UNO.js +0 -563
  288. package/dist/chunk-MXNC5UNO.js.map +0 -1
  289. package/dist/chunk-NAK55BYU.cjs +0 -859
  290. package/dist/chunk-NAK55BYU.cjs.map +0 -1
  291. package/dist/chunk-NDBMKGQ5.cjs +0 -599
  292. package/dist/chunk-NDBMKGQ5.cjs.map +0 -1
  293. package/dist/chunk-OD65OZIW.cjs +0 -159
  294. package/dist/chunk-OD65OZIW.cjs.map +0 -1
  295. package/dist/chunk-ORT3KLGI.js +0 -50
  296. package/dist/chunk-ORT3KLGI.js.map +0 -1
  297. package/dist/chunk-PNNUPUH4.cjs +0 -82
  298. package/dist/chunk-PNNUPUH4.cjs.map +0 -1
  299. package/dist/chunk-PWHECW6N.js +0 -2934
  300. package/dist/chunk-PWHECW6N.js.map +0 -1
  301. package/dist/chunk-RBS5A2DF.js +0 -857
  302. package/dist/chunk-RBS5A2DF.js.map +0 -1
  303. package/dist/chunk-RPWUDXG5.cjs +0 -63
  304. package/dist/chunk-RPWUDXG5.cjs.map +0 -1
  305. package/dist/chunk-TCDJY3H6.js +0 -494
  306. package/dist/chunk-TCDJY3H6.js.map +0 -1
  307. package/dist/chunk-TP5UMRAU.cjs +0 -918
  308. package/dist/chunk-TP5UMRAU.cjs.map +0 -1
  309. package/dist/chunk-TS7J6DTY.js +0 -597
  310. package/dist/chunk-TS7J6DTY.js.map +0 -1
  311. package/dist/chunk-TUVENMXB.cjs +0 -20
  312. package/dist/chunk-TUVENMXB.cjs.map +0 -1
  313. package/dist/chunk-UDCQTOVU.cjs +0 -523
  314. package/dist/chunk-UDCQTOVU.cjs.map +0 -1
  315. package/dist/chunk-UHKZXOXD.js +0 -128
  316. package/dist/chunk-UHKZXOXD.js.map +0 -1
  317. package/dist/chunk-V6BA44DS.cjs +0 -236
  318. package/dist/chunk-V6BA44DS.cjs.map +0 -1
  319. package/dist/chunk-XO5R73Y4.js +0 -653
  320. package/dist/chunk-XO5R73Y4.js.map +0 -1
  321. package/dist/chunk-XOR4MPEN.cjs +0 -31
  322. package/dist/chunk-XOR4MPEN.cjs.map +0 -1
  323. package/dist/chunk-YORQQXGO.js +0 -155
  324. package/dist/chunk-YORQQXGO.js.map +0 -1
  325. package/dist/chunk-YY4PFR3Z.cjs +0 -432
  326. package/dist/chunk-YY4PFR3Z.cjs.map +0 -1
  327. package/dist/chunk-ZPI6Q42R.js +0 -17
  328. package/dist/chunk-ZPI6Q42R.js.map +0 -1
  329. package/dist/components/ActivityPreview.cjs.map +0 -1
  330. package/dist/components/ActivityPreview.js.map +0 -1
  331. package/dist/components/ActivitySequence.cjs.map +0 -1
  332. package/dist/components/ActivitySequence.js.map +0 -1
  333. package/dist/components/Dictation.cjs.map +0 -1
  334. package/dist/components/Dictation.js.map +0 -1
  335. package/dist/components/FillInTheBlanks.cjs.map +0 -1
  336. package/dist/components/FillInTheBlanks.js.map +0 -1
  337. package/dist/components/GapSelect.cjs.map +0 -1
  338. package/dist/components/GapSelect.js.map +0 -1
  339. package/dist/components/InteractiveVideo.cjs.map +0 -1
  340. package/dist/components/InteractiveVideo.js.map +0 -1
  341. package/dist/components/MultipleChoice.cjs.map +0 -1
  342. package/dist/components/MultipleChoice.js.map +0 -1
  343. package/dist/components/PronunciationFeedback.cjs.map +0 -1
  344. package/dist/components/PronunciationFeedback.js.map +0 -1
  345. package/dist/components/ReadAloud.cjs.map +0 -1
  346. package/dist/components/ReadAloud.js.map +0 -1
  347. package/dist/components/StimulusPanel.cjs.map +0 -1
  348. package/dist/components/StimulusPanel.js.map +0 -1
  349. package/dist/components/WrittenResponse.cjs.map +0 -1
  350. package/dist/components/WrittenResponse.js.map +0 -1
  351. package/dist/hooks/useSpeechRecorder.cjs.map +0 -1
  352. package/dist/hooks/useSpeechRecorder.js.map +0 -1
  353. package/dist/i18n/LkIntlProvider.cjs.map +0 -1
  354. package/dist/i18n/LkIntlProvider.js.map +0 -1
  355. package/dist/machine-CuwKqWXC.d.cts +0 -26
  356. package/dist/machine-CuwKqWXC.d.ts +0 -26
  357. package/dist/theme/ThemeProvider.cjs.map +0 -1
  358. package/dist/theme/ThemeProvider.js.map +0 -1
  359. package/dist/types-C4IsUQsK.d.ts +0 -989
  360. package/dist/types-CJgZWtl4.d.cts +0 -989
@@ -1,915 +0,0 @@
1
- 'use client';
2
- import { usePlaybackRefusal, readOutcome, readEvidence, percentOfGrade, PronunciationFeedback, markSentence, VISUALLY_HIDDEN, ReadingCoaching, readAssessResult, fractionOfGrade } from './chunk-XO5R73Y4.js';
3
- import { useSpeechRecorder } from './chunk-MCO52PV5.js';
4
- import { localeDirectionOf } from './chunk-YORQQXGO.js';
5
- import { useDeliveryPolicy, FeedbackRegion } from './chunk-ORT3KLGI.js';
6
- import { ActivityErrorBoundary } from './chunk-7SB2MJA4.js';
7
- import { SequenceSlotContext, isDevelopment, detailIsRight, mintTake, stampTake, ANONYMOUS_ACTOR, objectIdFor } from './chunk-MXNC5UNO.js';
8
- import { ActivityMedia } from './chunk-TS7J6DTY.js';
9
- import { useActivityState } from './chunk-6N43WDVG.js';
10
- import { useLkStrings } from './chunk-HNLRVRQR.js';
11
- import { assertRedacted, validateActivity, ActivitySchemaError, READ_ALOUD_MAX_SECONDS, READ_ALOUD_MAX_TAKES, xAPIBuilder, xapiDefinitionFor } from '@intellectif/lk-core';
12
- import { useContext, useMemo, useState, useId, useRef, useEffect, useCallback } from 'react';
13
- import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
14
-
15
- // src/components/shared/capture-registry.ts
16
- var groups = /* @__PURE__ */ new Map();
17
- function joinCaptureGroup(group, stop) {
18
- let members = groups.get(group);
19
- if (members === void 0) {
20
- members = /* @__PURE__ */ new Set();
21
- groups.set(group, members);
22
- }
23
- members.add(stop);
24
- return () => {
25
- const current = groups.get(group);
26
- if (current === void 0) {
27
- return;
28
- }
29
- current.delete(stop);
30
- if (current.size === 0) {
31
- groups.delete(group);
32
- }
33
- };
34
- }
35
- function stopCaptureGroup(group) {
36
- const members = groups.get(group);
37
- if (members === void 0) {
38
- return;
39
- }
40
- for (const stop of [...members]) {
41
- stop();
42
- }
43
- }
44
- var isNumber = (value) => typeof value === "number" && Number.isFinite(value);
45
- function readRecordingBounds(recording) {
46
- const bounds = typeof recording === "object" && recording !== null ? recording : {};
47
- const maxSeconds = isNumber(bounds.maxSeconds) && bounds.maxSeconds > 0 ? Math.min(bounds.maxSeconds, READ_ALOUD_MAX_SECONDS) : READ_ALOUD_MAX_SECONDS;
48
- const minSeconds = isNumber(bounds.minSeconds) && bounds.minSeconds >= 0 && bounds.minSeconds < maxSeconds ? bounds.minSeconds : void 0;
49
- const takes = bounds.maxTakes;
50
- const maxTakes = takes === void 0 || takes === null ? void 0 : isNumber(takes) ? Math.min(Math.max(1, Math.floor(takes)), READ_ALOUD_MAX_TAKES) : READ_ALOUD_MAX_TAKES;
51
- return { maxSeconds, minSeconds, maxTakes };
52
- }
53
- function secondsWithin(milliseconds, maxSeconds, rounding) {
54
- const seconds = milliseconds / 1e3;
55
- const whole = rounding === "nearest" ? Math.round(seconds) : Math.floor(seconds);
56
- return Math.min(Math.max(0, whole), maxSeconds);
57
- }
58
- var modelsGroupCount = 0;
59
- var VISIBLE_TEXT_RE = /[^\p{White_Space}\p{Cc}\p{Cf}\p{Default_Ignorable_Code_Point}]/u;
60
- var MARK_ID_RE = /^w\d+$/;
61
- var STORED_STATES = [
62
- "correct",
63
- "mispronounced",
64
- "omitted"
65
- ];
66
- var LEVEL_STEPS = 10;
67
- function offersRetry(phase, uploaded) {
68
- return phase.kind === "upload-failed" || phase.kind === "assess-failed" && phase.retryable && uploaded !== null;
69
- }
70
- function takeStateOf(phase, uploaded) {
71
- if (phase.kind === "uploading" || phase.kind === "assessing") {
72
- return "in-flight";
73
- }
74
- return offersRetry(phase, uploaded) ? "retryable" : "settled";
75
- }
76
- function capturing(status) {
77
- return status === "recording" || status === "requesting-permission";
78
- }
79
- function readingKeyOf(data, bounds) {
80
- const text = (value) => typeof value === "string" ? value : null;
81
- return JSON.stringify([
82
- text(data.id),
83
- text(data.referenceText),
84
- text(data.locale),
85
- String(bounds.maxSeconds),
86
- String(bounds.minSeconds),
87
- String(bounds.maxTakes)
88
- ]);
89
- }
90
- function slowMediaFor(data, label) {
91
- const slow = data.slowMedia;
92
- if (slow === void 0) {
93
- return void 0;
94
- }
95
- const policy = data.media?.playback ?? {};
96
- const { maxPlays: _budget, ...inherited } = policy;
97
- const hasPolicy = Object.values(inherited).some((value) => value !== void 0);
98
- return {
99
- type: "audio",
100
- url: slow.url,
101
- alt: slow.alt ?? label,
102
- ...hasPolicy ? { playback: inherited } : {}
103
- };
104
- }
105
- function marksFromDetails(details) {
106
- if (details.length === 0 || !details.every((detail) => MARK_ID_RE.test(detail.itemId))) {
107
- return null;
108
- }
109
- return details.map((detail) => {
110
- const heard = Array.isArray(detail.learnerResponse) ? detail.learnerResponse.join(" ") : detail.learnerResponse;
111
- const reference = Array.isArray(detail.correctResponse) ? detail.correctResponse.join(" ") : detail.correctResponse;
112
- const correct = detailIsRight(detail);
113
- const state = correct ? "correct" : detail.outcome === "incorrect-omission" ? "omitted" : "mispronounced";
114
- return {
115
- itemId: detail.itemId,
116
- reference,
117
- heard,
118
- state,
119
- // `ScoringDetail.score` is the word's accuracy divided by 100; the marks
120
- // carry it back in the units the assessment used.
121
- ...typeof detail.score === "number" ? { accuracy: detail.score * 100 } : {}
122
- };
123
- });
124
- }
125
- function recordingOf(response) {
126
- return response !== void 0 && response.type === "read-aloud" ? response.recording : null;
127
- }
128
- function responseOf(recording, takes) {
129
- return { type: "read-aloud", recording, ...takes > 0 ? { takes } : {} };
130
- }
131
- function unscorableMessage(code, s) {
132
- return code === "no_speech" || code === "insufficient_voiced_time" ? s.readAloudNotHeard : s.readAloudNotAssessed;
133
- }
134
- function AnnouncementText({ announcement }) {
135
- if (announcement === null) {
136
- return null;
137
- }
138
- return /* @__PURE__ */ jsxs(Fragment, { children: [
139
- announcement.text,
140
- announcement.feedback ? /* @__PURE__ */ jsxs(Fragment, { children: [
141
- " ",
142
- /* @__PURE__ */ jsx("span", { dir: "auto", children: announcement.feedback })
143
- ] }) : null
144
- ] });
145
- }
146
- function OutcomeSummary({
147
- reading,
148
- s,
149
- scoreShown
150
- }) {
151
- switch (reading.kind) {
152
- case "graded":
153
- return /* @__PURE__ */ jsx(
154
- "div",
155
- {
156
- className: "lk-ra-outcome",
157
- "data-status": reading.status,
158
- "data-passed": String(reading.grade.passed),
159
- children: scoreShown ? null : /* @__PURE__ */ jsxs(Fragment, { children: [
160
- /* @__PURE__ */ jsx("p", { className: "lk-ra-grade", children: s.scoreAnnouncement(percentOfGrade(reading.grade), reading.grade.passed) }),
161
- reading.grade.feedback ? /* @__PURE__ */ jsx("p", { className: "lk-ra-grade-feedback", dir: "auto", children: reading.grade.feedback }) : null
162
- ] })
163
- }
164
- );
165
- case "deferred":
166
- return /* @__PURE__ */ jsx("div", { className: "lk-ra-outcome", "data-status": "deferred", children: /* @__PURE__ */ jsx("p", { className: "lk-ra-grade", children: s.awaitingGrade }) });
167
- case "unscorable":
168
- return /* @__PURE__ */ jsx(
169
- "div",
170
- {
171
- className: "lk-ra-outcome",
172
- "data-status": "unscorable",
173
- ...reading.code !== void 0 ? { "data-code": reading.code } : {},
174
- children: /* @__PURE__ */ jsx("p", { className: "lk-ra-grade", children: s.couldNotBeGraded })
175
- }
176
- );
177
- default:
178
- return /* @__PURE__ */ jsx(
179
- "div",
180
- {
181
- className: "lk-ra-outcome",
182
- ...reading.status !== void 0 ? { "data-status": reading.status } : {},
183
- children: /* @__PURE__ */ jsx("p", { className: "lk-ra-grade", children: s.couldNotBeGraded })
184
- }
185
- );
186
- }
187
- }
188
- function ReadAloud({
189
- data,
190
- onComplete,
191
- onSubmit,
192
- onInteraction,
193
- value,
194
- defaultValue,
195
- defaultSubmitted,
196
- renderMode = "practice",
197
- outcome,
198
- mediaBudget,
199
- mediaStrings,
200
- strings,
201
- theme,
202
- locale,
203
- disabled,
204
- recordingBinding,
205
- assessment,
206
- breakThreshold,
207
- monotoneThreshold,
208
- workletUrl,
209
- delivery,
210
- ai
211
- }) {
212
- const isExam = renderMode === "exam";
213
- const policy = useDeliveryPolicy(delivery);
214
- const isReview = renderMode === "review";
215
- const s = useLkStrings(strings);
216
- const slot = useContext(SequenceSlotContext);
217
- const captureGroup = slot?.captureGroup;
218
- const devError = useMemo(() => {
219
- if (!isDevelopment()) {
220
- return null;
221
- }
222
- if (data.redacted === true) {
223
- try {
224
- assertRedacted(data);
225
- return null;
226
- } catch (error) {
227
- return error instanceof Error ? error : new Error(String(error));
228
- }
229
- }
230
- const result = validateActivity("read-aloud", data);
231
- return result.success ? null : new ActivitySchemaError("read-aloud", result.errors);
232
- }, [data]);
233
- const { maxSeconds, minSeconds, maxTakes } = readRecordingBounds(data.recording);
234
- const readingKey = readingKeyOf(data, { maxSeconds, minSeconds, maxTakes });
235
- const recorder = useSpeechRecorder(
236
- useMemo(
237
- () => ({
238
- maxDurationMs: maxSeconds * 1e3,
239
- ...minSeconds !== void 0 ? { minDurationMs: minSeconds * 1e3 } : {},
240
- ...maxTakes !== void 0 ? { maxTakes } : {},
241
- // Forwarded, never defaulted: without it the recorder mints its own
242
- // `blob:` module, which is the one a strict policy refuses.
243
- ...workletUrl !== void 0 ? { workletUrl } : {}
244
- }),
245
- [maxSeconds, minSeconds, maxTakes, workletUrl]
246
- )
247
- );
248
- const { state, start, complete, getTimeSpent, reset } = useActivityState(
249
- defaultSubmitted === true ? "completed" : "idle"
250
- );
251
- const [phase, setPhase] = useState({ kind: "idle" });
252
- const [uploaded, setUploaded] = useState(null);
253
- const [takeUrl, setTakeUrl] = useState(null);
254
- const [playbackUrl, setPlaybackUrl] = useState(null);
255
- const [errorNonce, setErrorNonce] = useState(0);
256
- const ids = useId();
257
- const titleId = `${ids}-title`;
258
- const [modelsGroup] = useState(() => {
259
- modelsGroupCount += 1;
260
- return `lk-ra-models-${modelsGroupCount}`;
261
- });
262
- const interactionRef = useRef(onInteraction);
263
- interactionRef.current = onInteraction;
264
- const bindingRef = useRef(recordingBinding);
265
- bindingRef.current = recordingBinding;
266
- const submittingRef = useRef(false);
267
- const runRef = useRef(0);
268
- const slotRef = useRef(slot);
269
- slotRef.current = slot;
270
- const reportedTakeRef = useRef(null);
271
- useEffect(
272
- () => () => {
273
- runRef.current += 1;
274
- const take2 = reportedTakeRef.current;
275
- if (take2 !== null) {
276
- slotRef.current?.takeState(take2, "settled");
277
- }
278
- },
279
- []
280
- );
281
- const fire = useCallback(
282
- (type, payload) => {
283
- interactionRef.current?.({ type, activityId: data.id, timestamp: Date.now(), payload });
284
- },
285
- [data.id]
286
- );
287
- const lastStatusRef = useRef(recorder.status);
288
- useEffect(() => {
289
- if (lastStatusRef.current === recorder.status) {
290
- return;
291
- }
292
- lastStatusRef.current = recorder.status;
293
- if (recorder.status === "recording") {
294
- fire("recording-started", { takes: recorder.takesUsed, durationMs: 0 });
295
- } else if (recorder.status === "recorded" && recorder.take !== null) {
296
- fire("recording-stopped", {
297
- takes: recorder.takesUsed,
298
- durationMs: recorder.take.durationMs
299
- });
300
- }
301
- }, [recorder.status, recorder.take, recorder.takesUsed, fire]);
302
- useEffect(() => {
303
- if (recorder.error !== null) {
304
- setErrorNonce((nonce) => nonce + 1);
305
- }
306
- }, [recorder.error]);
307
- const take = recorder.take;
308
- useEffect(() => {
309
- if (take === null || typeof URL.createObjectURL !== "function") {
310
- return;
311
- }
312
- const url = URL.createObjectURL(take.blob);
313
- setTakeUrl(url);
314
- return () => {
315
- URL.revokeObjectURL(url);
316
- setTakeUrl(null);
317
- };
318
- }, [take]);
319
- const restored = recordingOf(value ?? defaultValue);
320
- const restoredKey = restored?.key ?? null;
321
- useEffect(() => {
322
- const binding = bindingRef.current;
323
- if (!isReview || restored === null || binding?.playbackUrl === void 0) {
324
- return;
325
- }
326
- let live = true;
327
- void Promise.resolve(binding.playbackUrl(restored)).then(
328
- (url) => {
329
- if (live) {
330
- setPlaybackUrl(url);
331
- }
332
- },
333
- () => {
334
- }
335
- );
336
- return () => {
337
- live = false;
338
- };
339
- }, [isReview, restoredKey, readingKey]);
340
- const statusRef = useRef(recorder.status);
341
- statusRef.current = recorder.status;
342
- const releaseMicrophone = useCallback(() => {
343
- if (capturing(statusRef.current)) {
344
- recorder.discard();
345
- }
346
- }, [recorder.discard]);
347
- useEffect(() => {
348
- if (captureGroup === void 0) {
349
- return;
350
- }
351
- return joinCaptureGroup(captureGroup, releaseMicrophone);
352
- }, [captureGroup, releaseMicrophone]);
353
- const defaultSubmittedRef = useRef(defaultSubmitted);
354
- useEffect(() => {
355
- defaultSubmittedRef.current = defaultSubmitted;
356
- }, [defaultSubmitted]);
357
- const lastReadingRef = useRef(readingKey);
358
- useEffect(() => {
359
- if (lastReadingRef.current === readingKey) {
360
- return;
361
- }
362
- lastReadingRef.current = readingKey;
363
- submittingRef.current = false;
364
- runRef.current += 1;
365
- setPhase({ kind: "idle" });
366
- setUploaded(null);
367
- setPlaybackUrl(null);
368
- recorder.reset();
369
- reset(defaultSubmittedRef.current === true ? "completed" : "idle");
370
- }, [readingKey, reset, recorder.reset]);
371
- const phaseTake = phase.kind === "idle" ? null : phase.take;
372
- const phaseTakeState = takeStateOf(phase, uploaded);
373
- useEffect(() => {
374
- const take2 = phaseTake ?? reportedTakeRef.current;
375
- if (slot === null || take2 === null) {
376
- return;
377
- }
378
- reportedTakeRef.current = take2;
379
- slot.takeState(take2, phaseTakeState);
380
- }, [slot, phaseTake, phaseTakeState]);
381
- const modelsRef = useRef(null);
382
- const isCapturing = capturing(recorder.status);
383
- useEffect(() => {
384
- if (!isCapturing) {
385
- return;
386
- }
387
- const node = modelsRef.current;
388
- if (node === null) {
389
- return;
390
- }
391
- const hush = () => {
392
- for (const media of node.querySelectorAll("audio, video")) {
393
- const element = media;
394
- if (!element.paused) {
395
- element.pause();
396
- }
397
- }
398
- };
399
- hush();
400
- node.addEventListener("play", hush, true);
401
- return () => {
402
- node.removeEventListener("play", hush, true);
403
- };
404
- }, [isCapturing]);
405
- const slowMedia = useMemo(
406
- () => slowMediaFor(data, s.readAloudSlowRecording),
407
- [data, s.readAloudSlowRecording]
408
- );
409
- const takeAudio = isReview ? playbackUrl : takeUrl;
410
- const playback = usePlaybackRefusal(takeAudio);
411
- const submitRef = useRef(null);
412
- if (devError) {
413
- throw devError;
414
- }
415
- if (!isReview && recordingBinding?.upload === void 0) {
416
- throw new Error(
417
- `ReadAloud "${data.id}" was rendered in renderMode "${renderMode}" without \`recordingBinding.upload\`. The learner could record a take that is stored nowhere and submitted as nothing, which looks like a working activity the whole way through. Pass a \`recordingBinding\` whose \`upload\` puts the take in your storage and returns its key. \`assess\` is optional: without it the take is still recorded, uploaded and submitted, and a notice replaces the feedback.`
418
- );
419
- }
420
- const submitted = state === "completed";
421
- const inactive = disabled === true || submitted || isReview;
422
- const busy = phase.kind === "uploading" || phase.kind === "assessing";
423
- const takesLeft = maxTakes === void 0 ? void 0 : Math.max(0, maxTakes - recorder.takesUsed);
424
- const raise = (next) => {
425
- setErrorNonce((nonce) => nonce + 1);
426
- setPhase(next);
427
- };
428
- const beginTakeReport = (take2) => {
429
- reportedTakeRef.current = take2;
430
- slot?.takeState(take2, "in-flight");
431
- };
432
- const runAssess = async (ref, current, take2) => {
433
- const assess = bindingRef.current?.assess;
434
- const durationMs = current?.durationMs ?? 0;
435
- const takes = recorder.takesUsed;
436
- const run = runRef.current;
437
- if (assess === void 0) {
438
- setPhase({ kind: "unassessed", take: take2 });
439
- return;
440
- }
441
- setPhase({ kind: "assessing", take: take2 });
442
- fire("assessment-requested", { takes, durationMs });
443
- let answer;
444
- try {
445
- answer = await assess(ref);
446
- } catch {
447
- if (run !== runRef.current) {
448
- return;
449
- }
450
- raise({ kind: "assess-failed", take: take2, retryable: true });
451
- fire("assessment-failed", { takes, durationMs, retryable: true });
452
- return;
453
- }
454
- if (run !== runRef.current) {
455
- return;
456
- }
457
- const result = readAssessResult(answer);
458
- if (result.status === "failed") {
459
- raise({ kind: "assess-failed", take: take2, retryable: result.retryable });
460
- fire("assessment-failed", { takes, durationMs, retryable: result.retryable });
461
- return;
462
- }
463
- if (result.status === "unscorable") {
464
- setPhase({ kind: "unscorable", take: take2, code: result.code });
465
- fire("assessment-failed", {
466
- takes,
467
- durationMs,
468
- retryable: true,
469
- ...result.code !== void 0 ? { code: result.code } : {}
470
- });
471
- return;
472
- }
473
- const timeSpent = getTimeSpent();
474
- setPhase({ kind: "graded", take: take2, assessment: result.assessment, grade: result.grade });
475
- const grade = result.grade;
476
- if (grade === null) {
477
- fire("assessment-failed", { takes, durationMs, retryable: true });
478
- return;
479
- }
480
- onComplete?.(
481
- stampTake(
482
- {
483
- score: grade.score,
484
- maxScore: grade.maxScore,
485
- passed: grade.passed,
486
- timeSpent,
487
- xapiStatement: xAPIBuilder.buildAnsweredStatement({
488
- actor: ANONYMOUS_ACTOR,
489
- object: {
490
- id: objectIdFor(data.id),
491
- name: { [data.locale ?? "en-US"]: data.title },
492
- ...xapiDefinitionFor(data)
493
- },
494
- timeSpentMs: timeSpent,
495
- response: result.recognizedText ?? "",
496
- // `ScoringResult.details` is required where `GradeRecord.details` is
497
- // optional, and an empty list is the honest reading of "no per-word
498
- // marks were stored" — never a mark of its own.
499
- scoringResult: {
500
- score: fractionOfGrade(grade),
501
- maxScore: 1,
502
- passed: grade.passed,
503
- feedback: grade.feedback,
504
- details: grade.details ?? []
505
- }
506
- })
507
- },
508
- take2
509
- )
510
- );
511
- };
512
- const submitTake = async (current) => {
513
- const binding = bindingRef.current;
514
- if (inactive || submittingRef.current || binding === void 0) {
515
- return;
516
- }
517
- submittingRef.current = true;
518
- const takes = recorder.takesUsed;
519
- const run = runRef.current;
520
- const take2 = mintTake();
521
- beginTakeReport(take2);
522
- try {
523
- let ref = null;
524
- if (current !== null) {
525
- setPhase({ kind: "uploading", take: take2 });
526
- try {
527
- ref = await binding.upload(current);
528
- } catch {
529
- if (run !== runRef.current) {
530
- return;
531
- }
532
- raise({ kind: "upload-failed", take: take2 });
533
- fire("recording-upload-failed", {
534
- takes,
535
- durationMs: current.durationMs,
536
- retryable: true
537
- });
538
- return;
539
- }
540
- if (run !== runRef.current) {
541
- return;
542
- }
543
- setUploaded(ref);
544
- fire("recording-uploaded", { takes, durationMs: current.durationMs });
545
- }
546
- onSubmit?.(stampTake(responseOf(ref, takes), take2));
547
- fire("submitted", { takes, durationMs: current?.durationMs ?? 0 });
548
- if (isExam || ref === null) {
549
- complete();
550
- setPhase({ kind: "submitted", take: take2 });
551
- return;
552
- }
553
- await runAssess(ref, current, take2);
554
- } finally {
555
- submittingRef.current = false;
556
- }
557
- };
558
- const retryAssess = async (ref, take2) => {
559
- if (submittingRef.current) {
560
- return;
561
- }
562
- submittingRef.current = true;
563
- beginTakeReport(take2);
564
- try {
565
- await runAssess(ref, recorder.take, take2);
566
- } finally {
567
- submittingRef.current = false;
568
- }
569
- };
570
- const handleSubmit = (event) => {
571
- event.preventDefault();
572
- if (inactive || busy || recorder.take === null || phase.kind !== "idle") {
573
- return;
574
- }
575
- void submitTake(recorder.take);
576
- };
577
- const beginTake = () => {
578
- if (inactive || busy || !recorder.canRecord) {
579
- return;
580
- }
581
- if (recorder.take !== null) {
582
- fire("recording-discarded", {
583
- takes: recorder.takesUsed,
584
- durationMs: recorder.take.durationMs
585
- });
586
- }
587
- setPhase({ kind: "idle" });
588
- setUploaded(null);
589
- start();
590
- void recorder.start();
591
- };
592
- const contentLang = typeof data.locale === "string" ? data.locale : void 0;
593
- const contentDir = localeDirectionOf(data.locale);
594
- const coachingItem = {
595
- id: data.id,
596
- title: data.title,
597
- referenceText: data.referenceText,
598
- locale: data.locale,
599
- ...data.instructions !== void 0 ? { instructions: data.instructions } : {},
600
- ...data.ai !== void 0 ? { ai: data.ai } : {}
601
- };
602
- const outcomeReading = useMemo(() => readOutcome(outcome), [outcome]);
603
- const keptEvidence = useMemo(() => readEvidence(assessment), [assessment]);
604
- const storedGrade = outcomeReading?.kind === "graded" && outcomeReading.status === "graded" ? outcomeReading.grade : null;
605
- const storedMarks = useMemo(
606
- () => policy.feedback && isReview && keptEvidence === null && storedGrade?.details !== void 0 ? marksFromDetails(storedGrade.details) : null,
607
- [policy.feedback, isReview, keptEvidence, storedGrade]
608
- );
609
- const feedbackAssessment = !policy.feedback ? null : isReview ? keptEvidence : phase.kind === "graded" ? phase.assessment : null;
610
- const feedbackGrade = isReview ? storedGrade : phase.kind === "graded" ? phase.grade : null;
611
- const feedbackAudio = playback.refused ? null : takeAudio;
612
- const rootRef = useRef(null);
613
- const [panelLostTheGrade, setPanelLostTheGrade] = useState(false);
614
- const panelHasGrade = feedbackAssessment !== null && feedbackGrade !== null;
615
- const gradeShownInPanel = panelHasGrade && !panelLostTheGrade;
616
- useEffect(() => {
617
- const root = rootRef.current;
618
- const lost = panelHasGrade && (root === null || root.querySelector(".lk-pf-grade") === null);
619
- setPanelLostTheGrade((was) => was === lost ? was : lost);
620
- });
621
- const announcement = useMemo(() => {
622
- if (isReview) {
623
- return null;
624
- }
625
- if (recorder.status === "recording") {
626
- return { text: s.readAloudRecordingStarted, feedback: null };
627
- }
628
- const stopped = recorder.status === "recorded" && take !== null ? {
629
- text: s.readAloudRecordingStopped(
630
- secondsWithin(take.durationMs, maxSeconds, "nearest"),
631
- maxSeconds
632
- ),
633
- feedback: null
634
- } : null;
635
- if (isExam) {
636
- if (phase.kind === "submitted" || submitted) {
637
- return { text: s.answerSubmitted, feedback: null };
638
- }
639
- return phase.kind === "idle" ? stopped : null;
640
- }
641
- switch (phase.kind) {
642
- case "graded": {
643
- const grade = phase.grade;
644
- if (grade === null) {
645
- return { text: `${s.answerSubmitted} ${s.couldNotBeGraded}`, feedback: null };
646
- }
647
- if (!policy.feedback) {
648
- return { text: s.answerSubmitted, feedback: null };
649
- }
650
- return {
651
- text: `${s.answerSubmitted} ${s.scoreAnnouncement(percentOfGrade(grade), grade.passed)}`,
652
- feedback: grade.feedback
653
- };
654
- }
655
- case "unscorable":
656
- return { text: unscorableMessage(phase.code, s), feedback: null };
657
- case "unassessed":
658
- return { text: s.readAloudAssessmentUnavailable, feedback: null };
659
- case "idle":
660
- return stopped;
661
- default:
662
- return null;
663
- }
664
- }, [isReview, isExam, phase, submitted, s, recorder.status, take, maxSeconds, policy.feedback]);
665
- const alertText = recorder.error !== null ? s.readAloudRecorderError(recorder.error) : phase.kind === "upload-failed" ? s.readAloudUploadFailed : phase.kind === "assess-failed" ? s.readAloudAssessmentFailed : null;
666
- return /* @__PURE__ */ jsxs(
667
- "form",
668
- {
669
- className: "lk-ra",
670
- ref: rootRef,
671
- "aria-labelledby": VISIBLE_TEXT_RE.test(data.title) ? titleId : void 0,
672
- lang: locale,
673
- "data-render-mode": renderMode,
674
- style: theme,
675
- onSubmit: handleSubmit,
676
- children: [
677
- /* @__PURE__ */ jsx("p", { id: titleId, className: "lk-ra-title", dir: contentDir ?? "auto", lang: contentLang, children: data.title }),
678
- typeof data.instructions === "string" && data.instructions !== "" ? /* @__PURE__ */ jsx("p", { className: "lk-ra-instructions", dir: contentDir ?? "auto", lang: contentLang, children: data.instructions }) : null,
679
- /* @__PURE__ */ jsx("p", { className: "lk-ra-reference", dir: contentDir ?? "auto", lang: contentLang, children: data.referenceText }),
680
- data.media !== void 0 || slowMedia !== void 0 ? /* @__PURE__ */ jsxs("div", { className: "lk-ra-models", ref: modelsRef, children: [
681
- data.media !== void 0 ? /* @__PURE__ */ jsxs("fieldset", { className: "lk-ra-model", children: [
682
- /* @__PURE__ */ jsx("legend", { className: "lk-ra-model-label", children: s.readAloudModelRecording }),
683
- /* @__PURE__ */ jsx(
684
- ActivityMedia,
685
- {
686
- media: data.media,
687
- renderMode,
688
- playbackGroup: modelsGroup,
689
- ...mediaBudget !== void 0 ? { mediaBudget } : {},
690
- ...mediaStrings !== void 0 ? { mediaStrings } : {},
691
- ...strings !== void 0 ? { strings } : {},
692
- ...onInteraction !== void 0 ? { onInteraction } : {},
693
- ...locale !== void 0 ? { locale } : {},
694
- ...disabled === true || isCapturing ? { disabled: true } : {}
695
- }
696
- )
697
- ] }) : null,
698
- slowMedia !== void 0 ? /* @__PURE__ */ jsxs("fieldset", { className: "lk-ra-model", "data-slow": "true", children: [
699
- /* @__PURE__ */ jsx("legend", { className: "lk-ra-model-label", children: s.readAloudSlowRecording }),
700
- /* @__PURE__ */ jsx(
701
- ActivityMedia,
702
- {
703
- media: slowMedia,
704
- renderMode,
705
- playbackGroup: modelsGroup,
706
- ...mediaStrings !== void 0 ? { mediaStrings } : {},
707
- ...strings !== void 0 ? { strings } : {},
708
- ...locale !== void 0 ? { locale } : {},
709
- ...disabled === true || isCapturing ? { disabled: true } : {}
710
- }
711
- )
712
- ] }) : null
713
- ] }) : null,
714
- isReview || submitted ? null : /* @__PURE__ */ jsxs(
715
- "div",
716
- {
717
- className: "lk-ra-recorder",
718
- "data-status": recorder.status,
719
- "data-level": recorder.status === "recording" ? Math.min(LEVEL_STEPS, Math.round(recorder.level * LEVEL_STEPS)) : void 0,
720
- children: [
721
- recorder.status === "recording" ? /* @__PURE__ */ jsx(
722
- "button",
723
- {
724
- type: "button",
725
- className: "lk-ra-stop",
726
- disabled: inactive,
727
- onClick: () => recorder.stop(),
728
- children: s.readAloudStop
729
- }
730
- ) : (
731
- // aria-disabled, never disabled, once the takes are spent: a
732
- // natively disabled button drops keyboard focus to the page body,
733
- // and this is the control a learner comes back to.
734
- /* @__PURE__ */ jsx(
735
- "button",
736
- {
737
- type: "button",
738
- className: "lk-ra-record",
739
- disabled: inactive,
740
- "aria-disabled": !recorder.canRecord || busy || void 0,
741
- onClick: beginTake,
742
- children: recorder.take === null ? s.readAloudRecord : s.readAloudRerecord
743
- }
744
- )
745
- ),
746
- recorder.status === "recording" ? (
747
- // Visible, and hidden from assistive technology, beside the level
748
- // meter the recorder's `data-level` drives. Its text changes every
749
- // whole second, so as a live region it announced ten times in a
750
- // ten-second take — into the microphone. What a screen-reader
751
- // learner needs instead is said once each, below.
752
- /* @__PURE__ */ jsx("p", { className: "lk-ra-progress", "aria-hidden": "true", children: s.readAloudRecordingProgress(
753
- secondsWithin(recorder.elapsedMs, maxSeconds, "down"),
754
- maxSeconds
755
- ) })
756
- ) : null,
757
- takesLeft !== void 0 && maxTakes !== void 0 ? /* @__PURE__ */ jsx("p", { className: "lk-ra-takes", children: s.readAloudTakesRemaining(takesLeft, maxTakes) }) : null
758
- ]
759
- }
760
- ),
761
- takeAudio === null ? null : playback.refused ? (
762
- // In the player's place, not beside it: a player the page will not
763
- // load looks exactly like one that works until it is pressed, and then
764
- // does nothing. A note rather than an alert — the learner can still
765
- // submit, and nothing here asks them to act.
766
- /* @__PURE__ */ jsx("p", { className: "lk-ra-take-unavailable", role: "note", children: s.readAloudPlaybackUnavailable })
767
- ) : (
768
- // biome-ignore lint/a11y/useMediaCaption: the learner's own take has no caption track to offer; its accessible name says whose recording it is
769
- /* @__PURE__ */ jsx(
770
- "audio",
771
- {
772
- className: "lk-ra-take",
773
- controls: true,
774
- src: takeAudio,
775
- "aria-label": s.readAloudYourRecording,
776
- onError: (event) => playback.refuse(event.currentTarget),
777
- ...isReview ? {} : { "data-take": recorder.takesUsed }
778
- }
779
- )
780
- ),
781
- isReview || submitted ? null : /* @__PURE__ */ jsxs("div", { className: "lk-ra-actions", children: [
782
- /* @__PURE__ */ jsx(
783
- "button",
784
- {
785
- ref: submitRef,
786
- type: "submit",
787
- className: "lk-ra-submit",
788
- disabled: disabled === true,
789
- "aria-disabled": recorder.take === null || phase.kind !== "idle" || void 0,
790
- "aria-busy": busy || void 0,
791
- children: s.submit
792
- }
793
- ),
794
- isExam ? (
795
- // Explicit, and only here: an exam answer with no recording is a
796
- // decision a learner takes, never something a failed upload does
797
- // for them.
798
- /* @__PURE__ */ jsx(
799
- "button",
800
- {
801
- type: "button",
802
- className: "lk-ra-submit-blank",
803
- disabled: inactive,
804
- "aria-disabled": busy || void 0,
805
- onClick: () => {
806
- if (!busy) {
807
- void submitTake(null);
808
- }
809
- },
810
- children: s.readAloudSubmitWithoutRecording
811
- }
812
- )
813
- ) : null,
814
- offersRetry(phase, uploaded) ? /* @__PURE__ */ jsx(
815
- "button",
816
- {
817
- type: "button",
818
- className: "lk-ra-retry",
819
- onClick: () => {
820
- submitRef.current?.focus();
821
- if (phase.kind === "upload-failed") {
822
- void submitTake(recorder.take);
823
- } else if (phase.kind === "assess-failed" && uploaded !== null) {
824
- void retryAssess(uploaded, phase.take);
825
- }
826
- },
827
- children: s.readAloudTryAgain
828
- }
829
- ) : null
830
- ] }),
831
- busy ? /* @__PURE__ */ jsx("p", { className: "lk-ra-pending", role: "status", "aria-busy": "true", children: phase.kind === "uploading" ? s.readAloudUploading : s.readAloudAssessing }) : null,
832
- alertText !== null ? /* @__PURE__ */ jsx("p", { className: "lk-ra-alert", role: "alert", children: alertText }, errorNonce) : null,
833
- feedbackAssessment !== null ? /* @__PURE__ */ jsx(
834
- PronunciationFeedback,
835
- {
836
- data: coachingItem,
837
- assessment: feedbackAssessment,
838
- ...feedbackGrade !== null ? { grade: feedbackGrade } : {},
839
- ...feedbackAudio !== null ? { audioUrl: feedbackAudio } : {},
840
- ...breakThreshold !== void 0 ? { breakThreshold } : {},
841
- ...monotoneThreshold !== void 0 ? { monotoneThreshold } : {},
842
- ...locale !== void 0 ? { locale } : {},
843
- ...strings !== void 0 ? { strings } : {},
844
- ...ai !== void 0 ? { ai } : {},
845
- ...onInteraction !== void 0 ? { onInteraction } : {},
846
- renderMode,
847
- delivery: policy
848
- }
849
- ) : null,
850
- storedMarks !== null ? /* @__PURE__ */ jsxs("div", { className: "lk-ra-marks", children: [
851
- /* @__PURE__ */ jsx("ol", { className: "lk-ra-words", "aria-label": s.pronunciationWordsLabel, dir: contentDir, children: storedMarks.map((entry, index) => {
852
- const sentence = markSentence(entry, s);
853
- return /* @__PURE__ */ jsxs(
854
- "li",
855
- {
856
- className: "lk-ra-word",
857
- "data-state": entry.state,
858
- children: [
859
- /* @__PURE__ */ jsx("span", { className: "lk-visually-hidden", style: VISUALLY_HIDDEN, children: sentence }),
860
- /* @__PURE__ */ jsx(
861
- "span",
862
- {
863
- className: "lk-ra-word-text",
864
- "aria-hidden": "true",
865
- dir: contentDir ?? "auto",
866
- lang: contentLang,
867
- children: entry.reference
868
- }
869
- )
870
- ]
871
- },
872
- index
873
- );
874
- }) }),
875
- /* @__PURE__ */ jsx("ul", { className: "lk-ra-legend", children: STORED_STATES.map((state2) => /* @__PURE__ */ jsx("li", { "data-state": state2, children: s.pronunciationLegend(state2) }, state2)) }),
876
- /* @__PURE__ */ jsx(
877
- ReadingCoaching,
878
- {
879
- data: coachingItem,
880
- grade: storedGrade,
881
- renderMode,
882
- delivery: policy,
883
- ...ai !== void 0 ? { ai } : {},
884
- ...locale !== void 0 ? { locale } : {},
885
- ...onInteraction !== void 0 ? { onInteraction } : {},
886
- strings: s,
887
- contentLang,
888
- contentDir
889
- }
890
- )
891
- ] }) : null,
892
- /* @__PURE__ */ jsx(FeedbackRegion, { id: `${data.id}-feedback`, children: isReview ? (
893
- // A grade read back is feedback; "not graded yet" and a grade that
894
- // could not be read are not.
895
- outcomeReading !== void 0 && (policy.feedback || outcomeReading.kind !== "graded") ? /* @__PURE__ */ jsx(OutcomeSummary, { reading: outcomeReading, s, scoreShown: gradeShownInPanel }) : null
896
- ) : gradeShownInPanel ? (
897
- // Announced, not repeated. A grade the feedback panel is already
898
- // showing would otherwise be read on screen twice, feedback and all —
899
- // but a live region is the only thing that TELLS a screen-reader
900
- // learner a grade arrived, since nothing takes focus. Clipped rather
901
- // than `display: none`, which would stop it being announced at all.
902
- /* @__PURE__ */ jsx("span", { className: "lk-visually-hidden", style: VISUALLY_HIDDEN, children: /* @__PURE__ */ jsx(AnnouncementText, { announcement }) })
903
- ) : /* @__PURE__ */ jsx(AnnouncementText, { announcement }) })
904
- ]
905
- }
906
- );
907
- }
908
- function ReadAloud2(props) {
909
- const strings = useLkStrings(props.strings);
910
- return /* @__PURE__ */ jsx(ActivityErrorBoundary, { activityTitle: props.data?.title, strings, children: /* @__PURE__ */ jsx(ReadAloud, { ...props }) });
911
- }
912
-
913
- export { ReadAloud2 as ReadAloud, stopCaptureGroup };
914
- //# sourceMappingURL=chunk-DC4CQCK5.js.map
915
- //# sourceMappingURL=chunk-DC4CQCK5.js.map