@citolab/qti-components 7.3.8 → 7.3.10

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 (406) hide show
  1. package/cdn/chunks/chunk-2AQB5QOU.js +1465 -0
  2. package/cdn/chunks/chunk-2D2T677T.js +5 -0
  3. package/cdn/chunks/chunk-2DBFRSMX.js +1 -0
  4. package/cdn/chunks/chunk-2KM4IIVZ.js +1 -0
  5. package/cdn/chunks/chunk-2MP4QXCW.js +5 -0
  6. package/cdn/chunks/chunk-2WMJ3FRH.js +5 -0
  7. package/cdn/chunks/chunk-3EL6MWIP.js +5 -0
  8. package/cdn/chunks/chunk-3FL7LAD7.js +3609 -0
  9. package/cdn/chunks/chunk-3OFR7NBQ.js +5 -0
  10. package/cdn/chunks/chunk-44FEGMMP.js +5 -0
  11. package/cdn/chunks/chunk-4AGPIRXC.js +3623 -0
  12. package/cdn/chunks/chunk-4BD24CBG.js +5 -0
  13. package/cdn/chunks/chunk-4JCAGCJ7.js +5 -0
  14. package/cdn/chunks/chunk-4KA72ZXP.js +5 -0
  15. package/cdn/chunks/chunk-4RGI2NPT.js +5 -0
  16. package/cdn/chunks/chunk-4V4EH3XE.js +5 -0
  17. package/cdn/chunks/chunk-5A6EZOWQ.js +1465 -0
  18. package/cdn/chunks/chunk-5MA2ACUN.js +5 -0
  19. package/cdn/chunks/chunk-5NPTQSKH.js +5 -0
  20. package/cdn/chunks/chunk-5OT7GAD6.js +1465 -0
  21. package/cdn/chunks/chunk-5X3DXTZR.js +5 -0
  22. package/cdn/chunks/chunk-5ZJGXWHS.js +5 -0
  23. package/cdn/chunks/chunk-65IPR5FK.js +5 -0
  24. package/cdn/chunks/chunk-67XELO2Z.js +5 -0
  25. package/cdn/chunks/chunk-6CVU566T.js +3604 -0
  26. package/cdn/chunks/chunk-6DAXA4WF.js +1465 -0
  27. package/cdn/chunks/chunk-6HMBATJ5.js +5 -0
  28. package/cdn/chunks/chunk-6I6VSJRU.js +5 -0
  29. package/cdn/chunks/chunk-6NH7EB4Y.js +5 -0
  30. package/cdn/chunks/chunk-6OGNTNZS.js +5 -0
  31. package/cdn/chunks/chunk-6U7KZ7RT.js +5 -0
  32. package/cdn/chunks/chunk-75AAESDA.js +5 -0
  33. package/cdn/chunks/chunk-7HRE6EJN.js +1465 -0
  34. package/cdn/chunks/chunk-A2IAVB65.js +5 -0
  35. package/cdn/chunks/chunk-AK7BBQIN.js +1465 -0
  36. package/cdn/chunks/chunk-AL7MMWN4.js +5 -0
  37. package/cdn/chunks/chunk-AU5IFIAE.js +5 -0
  38. package/cdn/chunks/chunk-B34CVRZY.js +3611 -0
  39. package/cdn/chunks/chunk-B5KBEV6C.js +5 -0
  40. package/cdn/chunks/chunk-BDVDUFDX.js +3604 -0
  41. package/cdn/chunks/chunk-BEKC2KXP.js +1465 -0
  42. package/cdn/chunks/chunk-BIPSM53R.js +3604 -0
  43. package/cdn/chunks/chunk-BUSPJKBW.js +5 -0
  44. package/cdn/chunks/chunk-BVGQYBYI.js +5 -0
  45. package/cdn/chunks/chunk-C2TYLPUF.js +5 -0
  46. package/cdn/chunks/chunk-C4S3TBY7.js +5 -0
  47. package/cdn/chunks/chunk-CA2BB5TT.js +1465 -0
  48. package/cdn/chunks/chunk-CAPYSR2Y.js +3605 -0
  49. package/cdn/chunks/chunk-CB2PW7DM.js +3604 -0
  50. package/cdn/chunks/chunk-CBEIZQ7O.js +5 -0
  51. package/cdn/chunks/chunk-DIM5R2XZ.js +3609 -0
  52. package/cdn/chunks/chunk-DM55ZVIS.js +3608 -0
  53. package/cdn/chunks/chunk-DNGQ3HHD.js +8 -0
  54. package/cdn/chunks/chunk-DTSNON3E.js +5 -0
  55. package/cdn/chunks/chunk-DUCVF666.js +5 -0
  56. package/cdn/chunks/chunk-DWKO2XVJ.js +3626 -0
  57. package/cdn/chunks/chunk-E5QYUREF.js +1465 -0
  58. package/cdn/chunks/chunk-EGMZWVEN.js +5 -0
  59. package/cdn/chunks/chunk-ETDUKPJ5.js +1465 -0
  60. package/cdn/chunks/chunk-FBCUILM4.js +5 -0
  61. package/cdn/chunks/chunk-FHKI336W.js +5 -0
  62. package/cdn/chunks/chunk-G6JBUK7M.js +8 -0
  63. package/cdn/chunks/chunk-GI643I6D.js +5 -0
  64. package/cdn/chunks/chunk-H5N66JWX.js +1 -0
  65. package/cdn/chunks/chunk-H6DTW4CH.js +1465 -0
  66. package/cdn/chunks/chunk-HVRUXHOA.js +5 -0
  67. package/cdn/chunks/chunk-HY6LZ42L.js +5 -0
  68. package/cdn/chunks/chunk-I4QFJPZG.js +1465 -0
  69. package/cdn/chunks/chunk-IAGXHLJ5.js +5 -0
  70. package/cdn/chunks/chunk-IAWUN2QB.js +5 -0
  71. package/cdn/chunks/chunk-ICRWHWJ3.js +5 -0
  72. package/cdn/chunks/chunk-IWOEDFXH.js +1465 -0
  73. package/cdn/chunks/chunk-IXOHXGV7.js +1464 -0
  74. package/cdn/chunks/chunk-J5BD6EO5.js +5 -0
  75. package/cdn/chunks/chunk-J6V7VRWX.js +3605 -0
  76. package/cdn/chunks/chunk-JESKBIHK.js +1465 -0
  77. package/cdn/chunks/chunk-JGH5ZZNA.js +1465 -0
  78. package/cdn/chunks/chunk-JIUUHGM7.js +1465 -0
  79. package/cdn/chunks/chunk-JX2BBAUD.js +3609 -0
  80. package/cdn/chunks/chunk-JZNXP6Z6.js +1465 -0
  81. package/cdn/chunks/chunk-K6RDKEPY.js +5 -0
  82. package/cdn/chunks/chunk-KVODKRRX.js +5 -0
  83. package/cdn/chunks/chunk-LDAQNEWI.js +5 -0
  84. package/cdn/chunks/chunk-M2CUHPCU.js +5 -0
  85. package/cdn/chunks/chunk-M2L4SJPE.js +5 -0
  86. package/cdn/chunks/chunk-M6UCMG2T.js +1465 -0
  87. package/cdn/chunks/chunk-MUO2LFIC.js +3604 -0
  88. package/cdn/chunks/chunk-MX6YXRD5.js +5 -0
  89. package/cdn/chunks/chunk-MX7JGUEV.js +5 -0
  90. package/cdn/chunks/chunk-MZEVJMUS.js +5 -0
  91. package/cdn/chunks/chunk-NHUCLA7C.js +5 -0
  92. package/cdn/chunks/chunk-NJMK5GFV.js +3604 -0
  93. package/cdn/chunks/chunk-NPUY7KWX.js +5 -0
  94. package/cdn/chunks/chunk-NQ3BSLED.js +1465 -0
  95. package/cdn/chunks/chunk-NSDTAG5H.js +1465 -0
  96. package/cdn/chunks/chunk-NW5BDXND.js +5 -0
  97. package/cdn/chunks/chunk-OITWX2VZ.js +1464 -0
  98. package/cdn/chunks/chunk-OUASGGRF.js +5 -0
  99. package/cdn/chunks/chunk-P32DF2PX.js +5 -0
  100. package/cdn/chunks/chunk-P67MLABM.js +5 -0
  101. package/cdn/chunks/chunk-PDGJCLPL.js +5 -0
  102. package/cdn/chunks/chunk-PEIVTIUB.js +5 -0
  103. package/cdn/chunks/chunk-PIVDVXEN.js +1465 -0
  104. package/cdn/chunks/chunk-QLAUWZGN.js +1465 -0
  105. package/cdn/chunks/chunk-QXXWBEQF.js +3609 -0
  106. package/cdn/chunks/chunk-QZPQCRI5.js +1465 -0
  107. package/cdn/chunks/chunk-S4473XKU.js +5 -0
  108. package/cdn/chunks/chunk-SAF2F2BZ.js +1 -0
  109. package/cdn/chunks/chunk-SG6DVQL7.js +5 -0
  110. package/cdn/chunks/chunk-SHTWKDDX.js +1465 -0
  111. package/cdn/chunks/chunk-SLPPK4MX.js +1465 -0
  112. package/cdn/chunks/chunk-SNOJ7YK5.js +5 -0
  113. package/cdn/chunks/chunk-SRIMN6LS.js +5 -0
  114. package/cdn/chunks/chunk-STP2XHRQ.js +5 -0
  115. package/cdn/chunks/chunk-SX5UYWRC.js +5 -0
  116. package/cdn/chunks/chunk-SXBW34TA.js +5 -0
  117. package/cdn/chunks/chunk-SZIHBKW7.js +5 -0
  118. package/cdn/chunks/chunk-TBOYZAKT.js +10 -0
  119. package/cdn/chunks/chunk-TJQOQP3Y.js +5 -0
  120. package/cdn/chunks/chunk-TNTVGKFL.js +5 -0
  121. package/cdn/chunks/chunk-TUP6KJ75.js +5 -0
  122. package/cdn/chunks/chunk-TZ3JSM57.js +1465 -0
  123. package/cdn/chunks/chunk-TZR6VRWS.js +5 -0
  124. package/cdn/chunks/chunk-U2ZZRG5F.js +5 -0
  125. package/cdn/chunks/chunk-U44QDOCL.js +3623 -0
  126. package/cdn/chunks/chunk-U7TJTJQN.js +5 -0
  127. package/cdn/chunks/chunk-UFYKSOJU.js +5 -0
  128. package/cdn/chunks/chunk-UQBB2LW3.js +5 -0
  129. package/cdn/chunks/chunk-UYN4HJOQ.js +5 -0
  130. package/cdn/chunks/chunk-V4TTNYV7.js +5 -0
  131. package/cdn/chunks/chunk-VDZLUVD6.js +3626 -0
  132. package/cdn/chunks/chunk-VPCDMES4.js +1465 -0
  133. package/cdn/chunks/chunk-VU7RTCTH.js +5 -0
  134. package/cdn/chunks/chunk-X4D22CNL.js +1465 -0
  135. package/cdn/chunks/chunk-XWDDTFCA.js +1 -0
  136. package/cdn/chunks/chunk-YTHXVBE7.js +5 -0
  137. package/cdn/chunks/chunk-YXJMYFQN.js +3609 -0
  138. package/cdn/chunks/chunk-ZJOPT4QJ.js +1465 -0
  139. package/cdn/chunks/chunk-ZQX3RHXX.js +1465 -0
  140. package/cdn/chunks/chunk-ZXFMPBFU.js +5 -0
  141. package/cdn/exports/qti-condition-expression.js +1 -1
  142. package/cdn/exports/qti-expression.js +1 -1
  143. package/cdn/index.global.js +1 -1
  144. package/cdn/index.js +1 -1
  145. package/cdn/qti-components/index.js +1 -1
  146. package/cdn/qti-item/components/item-container.js +1 -1
  147. package/cdn/qti-item/components/item-show-correct-response.js +1 -1
  148. package/cdn/qti-item/components/print-item-variables.js +1 -1
  149. package/cdn/qti-item/core/index.js +1 -1
  150. package/cdn/qti-test/components/index.js +1 -1
  151. package/cdn/qti-test/components/test-container.js +1 -1
  152. package/cdn/qti-test/components/test-navigation.js +1 -1
  153. package/cdn/qti-test/components/test-next.js +1 -1
  154. package/cdn/qti-test/components/test-paging-buttons-stamp.js +1 -1
  155. package/cdn/qti-test/components/test-prev.js +1 -1
  156. package/cdn/qti-test/components/test-print-context.js +1 -1
  157. package/cdn/qti-test/components/test-print-item-variables.js +1 -1
  158. package/cdn/qti-test/components/test-scoring-buttons.js +1 -1
  159. package/cdn/qti-test/components/test-scoring-feedback.js +1 -1
  160. package/cdn/qti-test/components/test-section-buttons-stamp.js +1 -1
  161. package/cdn/qti-test/components/test-show-correct-response.js +1 -1
  162. package/cdn/qti-test/components/test-stamp.js +1 -1
  163. package/cdn/qti-test/components/test-view-toggle.js +1 -1
  164. package/cdn/qti-test/components/test-view.js +1 -1
  165. package/cdn/qti-test/core/index.js +1 -1
  166. package/dist/chunks/chunk-22ADH5XX.js +94 -0
  167. package/dist/chunks/chunk-22ADH5XX.js.map +1 -0
  168. package/dist/chunks/chunk-24YH3T77.js +3594 -0
  169. package/dist/chunks/chunk-24YH3T77.js.map +1 -0
  170. package/dist/chunks/chunk-2KLMYWXY.js +94 -0
  171. package/dist/chunks/chunk-2KLMYWXY.js.map +1 -0
  172. package/dist/chunks/chunk-2M36WE6U.js +887 -0
  173. package/dist/chunks/chunk-2M36WE6U.js.map +1 -0
  174. package/dist/chunks/chunk-33UVTXDH.js +7970 -0
  175. package/dist/chunks/chunk-33UVTXDH.js.map +1 -0
  176. package/dist/chunks/chunk-3E2HPYC2.js +7970 -0
  177. package/dist/chunks/chunk-3E2HPYC2.js.map +1 -0
  178. package/dist/chunks/chunk-3IDGBR6L.js +94 -0
  179. package/dist/chunks/chunk-3IDGBR6L.js.map +1 -0
  180. package/dist/chunks/chunk-3KHLBN4E.js +7969 -0
  181. package/dist/chunks/chunk-3KHLBN4E.js.map +1 -0
  182. package/dist/chunks/chunk-3OFGPZKB.js +887 -0
  183. package/dist/chunks/chunk-3OFGPZKB.js.map +1 -0
  184. package/dist/chunks/chunk-3Q3GJFP2.js +94 -0
  185. package/dist/chunks/chunk-3Q3GJFP2.js.map +1 -0
  186. package/dist/chunks/chunk-4HSJSPKC.js +3594 -0
  187. package/dist/chunks/chunk-4HSJSPKC.js.map +1 -0
  188. package/dist/chunks/chunk-4IY7EZRG.js +94 -0
  189. package/dist/chunks/chunk-4IY7EZRG.js.map +1 -0
  190. package/dist/chunks/chunk-52LKP43M.js +7970 -0
  191. package/dist/chunks/chunk-52LKP43M.js.map +1 -0
  192. package/dist/chunks/chunk-5SMBVUWD.js +94 -0
  193. package/dist/chunks/chunk-5SMBVUWD.js.map +1 -0
  194. package/dist/chunks/chunk-5UK3GDC4.js +270 -0
  195. package/dist/chunks/chunk-5UK3GDC4.js.map +1 -0
  196. package/dist/chunks/chunk-6RGVMISK.js +91 -0
  197. package/dist/chunks/chunk-6RGVMISK.js.map +1 -0
  198. package/dist/chunks/chunk-76V23CCX.js +887 -0
  199. package/dist/chunks/chunk-76V23CCX.js.map +1 -0
  200. package/dist/chunks/chunk-7OYG6HQK.js +887 -0
  201. package/dist/chunks/chunk-7OYG6HQK.js.map +1 -0
  202. package/dist/chunks/chunk-7PXD4SKY.js +94 -0
  203. package/dist/chunks/chunk-7PXD4SKY.js.map +1 -0
  204. package/dist/chunks/chunk-7S77KG7E.js +3598 -0
  205. package/dist/chunks/chunk-7S77KG7E.js.map +1 -0
  206. package/dist/chunks/chunk-7UNBWVTX.js +94 -0
  207. package/dist/chunks/chunk-7UNBWVTX.js.map +1 -0
  208. package/dist/chunks/chunk-A7GWMVMW.js +94 -0
  209. package/dist/chunks/chunk-A7GWMVMW.js.map +1 -0
  210. package/dist/chunks/chunk-AATFMNQ7.js +887 -0
  211. package/dist/chunks/chunk-AATFMNQ7.js.map +1 -0
  212. package/dist/chunks/chunk-AE5G2IBM.js +7969 -0
  213. package/dist/chunks/chunk-AE5G2IBM.js.map +1 -0
  214. package/dist/chunks/chunk-B4T3VSOK.js +7969 -0
  215. package/dist/chunks/chunk-B4T3VSOK.js.map +1 -0
  216. package/dist/chunks/chunk-B6J55LEH.js +887 -0
  217. package/dist/chunks/chunk-B6J55LEH.js.map +1 -0
  218. package/dist/chunks/chunk-BD3UXA45.js +94 -0
  219. package/dist/chunks/chunk-BD3UXA45.js.map +1 -0
  220. package/dist/chunks/chunk-BJ34MOX3.js +3594 -0
  221. package/dist/chunks/chunk-BJ34MOX3.js.map +1 -0
  222. package/dist/chunks/chunk-BSMH5QAT.js +7970 -0
  223. package/dist/chunks/chunk-BSMH5QAT.js.map +1 -0
  224. package/dist/chunks/chunk-BXUZQSIJ.js +7972 -0
  225. package/dist/chunks/chunk-BXUZQSIJ.js.map +1 -0
  226. package/dist/chunks/chunk-CIJVRB7X.js +887 -0
  227. package/dist/chunks/chunk-CIJVRB7X.js.map +1 -0
  228. package/dist/chunks/chunk-COMEKBI4.js +887 -0
  229. package/dist/chunks/chunk-COMEKBI4.js.map +1 -0
  230. package/dist/chunks/chunk-CZTJMCR5.js +887 -0
  231. package/dist/chunks/chunk-CZTJMCR5.js.map +1 -0
  232. package/dist/chunks/chunk-D3QPTBGD.js +94 -0
  233. package/dist/chunks/chunk-D3QPTBGD.js.map +1 -0
  234. package/dist/chunks/chunk-D4LXKUTU.js +3595 -0
  235. package/dist/chunks/chunk-D4LXKUTU.js.map +1 -0
  236. package/dist/chunks/chunk-D5F2SQNW.js +7969 -0
  237. package/dist/chunks/chunk-D5F2SQNW.js.map +1 -0
  238. package/dist/chunks/chunk-DB7E3FQS.js +94 -0
  239. package/dist/chunks/chunk-DB7E3FQS.js.map +1 -0
  240. package/dist/chunks/chunk-DHPEGVWN.js +84 -0
  241. package/dist/chunks/chunk-DHPEGVWN.js.map +1 -0
  242. package/dist/chunks/chunk-DO2QLC5X.js +7970 -0
  243. package/dist/chunks/chunk-DO2QLC5X.js.map +1 -0
  244. package/dist/chunks/chunk-DS4BD2ZQ.js +887 -0
  245. package/dist/chunks/chunk-DS4BD2ZQ.js.map +1 -0
  246. package/dist/chunks/chunk-DSLV5YA6.js +3594 -0
  247. package/dist/chunks/chunk-DSLV5YA6.js.map +1 -0
  248. package/dist/chunks/chunk-DU577TCY.js +3599 -0
  249. package/dist/chunks/chunk-DU577TCY.js.map +1 -0
  250. package/dist/chunks/chunk-DX7I752N.js +3601 -0
  251. package/dist/chunks/chunk-DX7I752N.js.map +1 -0
  252. package/dist/chunks/chunk-EAYSUJ5L.js +887 -0
  253. package/dist/chunks/chunk-EAYSUJ5L.js.map +1 -0
  254. package/dist/chunks/chunk-EFXOXSPI.js +7969 -0
  255. package/dist/chunks/chunk-EFXOXSPI.js.map +1 -0
  256. package/dist/chunks/chunk-ER2AETF4.js +94 -0
  257. package/dist/chunks/chunk-ER2AETF4.js.map +1 -0
  258. package/dist/chunks/chunk-FMBMEJA6.js +887 -0
  259. package/dist/chunks/chunk-FMBMEJA6.js.map +1 -0
  260. package/dist/chunks/chunk-FQ42YLGN.js +94 -0
  261. package/dist/chunks/chunk-FQ42YLGN.js.map +1 -0
  262. package/dist/chunks/chunk-G52LAMAB.js +94 -0
  263. package/dist/chunks/chunk-G52LAMAB.js.map +1 -0
  264. package/dist/chunks/chunk-G5FFQER7.js +7969 -0
  265. package/dist/chunks/chunk-G5FFQER7.js.map +1 -0
  266. package/dist/chunks/chunk-GCOODLFL.js +94 -0
  267. package/dist/chunks/chunk-GCOODLFL.js.map +1 -0
  268. package/dist/chunks/chunk-GH26RKOD.js +887 -0
  269. package/dist/chunks/chunk-GH26RKOD.js.map +1 -0
  270. package/dist/chunks/chunk-GKY4X7OQ.js +94 -0
  271. package/dist/chunks/chunk-GKY4X7OQ.js.map +1 -0
  272. package/dist/chunks/chunk-GZRKK3QW.js +7970 -0
  273. package/dist/chunks/chunk-GZRKK3QW.js.map +1 -0
  274. package/dist/chunks/chunk-H4HFOONR.js +94 -0
  275. package/dist/chunks/chunk-H4HFOONR.js.map +1 -0
  276. package/dist/chunks/chunk-H7E4LC4K.js +7969 -0
  277. package/dist/chunks/chunk-H7E4LC4K.js.map +1 -0
  278. package/dist/chunks/chunk-HFLNMWQY.js +887 -0
  279. package/dist/chunks/chunk-HFLNMWQY.js.map +1 -0
  280. package/dist/chunks/chunk-HIPJ4SLP.js +94 -0
  281. package/dist/chunks/chunk-HIPJ4SLP.js.map +1 -0
  282. package/dist/chunks/chunk-HWBOMIKQ.js +94 -0
  283. package/dist/chunks/chunk-HWBOMIKQ.js.map +1 -0
  284. package/dist/chunks/chunk-I5QWPTNS.js +7970 -0
  285. package/dist/chunks/chunk-I5QWPTNS.js.map +1 -0
  286. package/dist/chunks/chunk-IDQVCLFW.js +3594 -0
  287. package/dist/chunks/chunk-IDQVCLFW.js.map +1 -0
  288. package/dist/chunks/chunk-IHM5AGLK.js +94 -0
  289. package/dist/chunks/chunk-IHM5AGLK.js.map +1 -0
  290. package/dist/chunks/chunk-IHVWYU6H.js +887 -0
  291. package/dist/chunks/chunk-IHVWYU6H.js.map +1 -0
  292. package/dist/chunks/chunk-IM3XJ5J3.js +94 -0
  293. package/dist/chunks/chunk-IM3XJ5J3.js.map +1 -0
  294. package/dist/chunks/chunk-J6QL36DE.js +887 -0
  295. package/dist/chunks/chunk-J6QL36DE.js.map +1 -0
  296. package/dist/chunks/chunk-JCSGX6KS.js +887 -0
  297. package/dist/chunks/chunk-JCSGX6KS.js.map +1 -0
  298. package/dist/chunks/chunk-JKVAOL23.js +94 -0
  299. package/dist/chunks/chunk-JKVAOL23.js.map +1 -0
  300. package/dist/chunks/chunk-JSFSSO4N.js +7968 -0
  301. package/dist/chunks/chunk-JSFSSO4N.js.map +1 -0
  302. package/dist/chunks/chunk-KGLPF52L.js +887 -0
  303. package/dist/chunks/chunk-KGLPF52L.js.map +1 -0
  304. package/dist/chunks/chunk-KGUUVU4R.js +94 -0
  305. package/dist/chunks/chunk-KGUUVU4R.js.map +1 -0
  306. package/dist/chunks/chunk-KUR3WYNE.js +94 -0
  307. package/dist/chunks/chunk-KUR3WYNE.js.map +1 -0
  308. package/dist/chunks/chunk-LP5XIBBR.js +3616 -0
  309. package/dist/chunks/chunk-LP5XIBBR.js.map +1 -0
  310. package/dist/chunks/chunk-MHN7KBCQ.js +94 -0
  311. package/dist/chunks/chunk-MHN7KBCQ.js.map +1 -0
  312. package/dist/chunks/chunk-MVUREGEC.js +3594 -0
  313. package/dist/chunks/chunk-MVUREGEC.js.map +1 -0
  314. package/dist/chunks/chunk-ND4URIPN.js +3595 -0
  315. package/dist/chunks/chunk-ND4URIPN.js.map +1 -0
  316. package/dist/chunks/chunk-NHJSQ6EC.js +887 -0
  317. package/dist/chunks/chunk-NHJSQ6EC.js.map +1 -0
  318. package/dist/chunks/chunk-NS4XSJTY.js +94 -0
  319. package/dist/chunks/chunk-NS4XSJTY.js.map +1 -0
  320. package/dist/chunks/chunk-NYM2PFSX.js +887 -0
  321. package/dist/chunks/chunk-NYM2PFSX.js.map +1 -0
  322. package/dist/chunks/chunk-O4YARITG.js +94 -0
  323. package/dist/chunks/chunk-O4YARITG.js.map +1 -0
  324. package/dist/chunks/chunk-OEU7UL5H.js +7970 -0
  325. package/dist/chunks/chunk-OEU7UL5H.js.map +1 -0
  326. package/dist/chunks/chunk-PZUCEOGK.js +887 -0
  327. package/dist/chunks/chunk-PZUCEOGK.js.map +1 -0
  328. package/dist/chunks/chunk-QANFQNGJ.js +94 -0
  329. package/dist/chunks/chunk-QANFQNGJ.js.map +1 -0
  330. package/dist/chunks/chunk-QJCCWOJA.js +7969 -0
  331. package/dist/chunks/chunk-QJCCWOJA.js.map +1 -0
  332. package/dist/chunks/chunk-QRVZKLRL.js +94 -0
  333. package/dist/chunks/chunk-QRVZKLRL.js.map +1 -0
  334. package/dist/chunks/chunk-QZQGK6RL.js +3616 -0
  335. package/dist/chunks/chunk-QZQGK6RL.js.map +1 -0
  336. package/dist/chunks/chunk-R4NPDD3O.js +7970 -0
  337. package/dist/chunks/chunk-R4NPDD3O.js.map +1 -0
  338. package/dist/chunks/chunk-R5EF3ZV3.js +887 -0
  339. package/dist/chunks/chunk-R5EF3ZV3.js.map +1 -0
  340. package/dist/chunks/chunk-RBZA3P3W.js +94 -0
  341. package/dist/chunks/chunk-RBZA3P3W.js.map +1 -0
  342. package/dist/chunks/chunk-RGFVMAPK.js +887 -0
  343. package/dist/chunks/chunk-RGFVMAPK.js.map +1 -0
  344. package/dist/chunks/chunk-RQF4P6PJ.js +94 -0
  345. package/dist/chunks/chunk-RQF4P6PJ.js.map +1 -0
  346. package/dist/chunks/chunk-SUD3U36A.js +7971 -0
  347. package/dist/chunks/chunk-SUD3U36A.js.map +1 -0
  348. package/dist/chunks/chunk-T7AYE2YI.js +887 -0
  349. package/dist/chunks/chunk-T7AYE2YI.js.map +1 -0
  350. package/dist/chunks/chunk-TL4SWC5W.js +94 -0
  351. package/dist/chunks/chunk-TL4SWC5W.js.map +1 -0
  352. package/dist/chunks/chunk-TNBMHBCA.js +94 -0
  353. package/dist/chunks/chunk-TNBMHBCA.js.map +1 -0
  354. package/dist/chunks/chunk-TNSZ52TC.js +269 -0
  355. package/dist/chunks/chunk-TNSZ52TC.js.map +1 -0
  356. package/dist/chunks/chunk-UL5627MO.js +94 -0
  357. package/dist/chunks/chunk-UL5627MO.js.map +1 -0
  358. package/dist/chunks/chunk-V7JDFAR4.js +887 -0
  359. package/dist/chunks/chunk-V7JDFAR4.js.map +1 -0
  360. package/dist/chunks/chunk-VAMHDDOF.js +3599 -0
  361. package/dist/chunks/chunk-VAMHDDOF.js.map +1 -0
  362. package/dist/chunks/chunk-VWKPIAXJ.js +887 -0
  363. package/dist/chunks/chunk-VWKPIAXJ.js.map +1 -0
  364. package/dist/chunks/chunk-W7DTVLFL.js +3599 -0
  365. package/dist/chunks/chunk-W7DTVLFL.js.map +1 -0
  366. package/dist/chunks/chunk-WGRV4XGF.js +94 -0
  367. package/dist/chunks/chunk-WGRV4XGF.js.map +1 -0
  368. package/dist/chunks/chunk-WGYRA3PV.js +3599 -0
  369. package/dist/chunks/chunk-WGYRA3PV.js.map +1 -0
  370. package/dist/chunks/chunk-WPILGOKJ.js +7970 -0
  371. package/dist/chunks/chunk-WPILGOKJ.js.map +1 -0
  372. package/dist/chunks/chunk-WTHWEPDU.js +887 -0
  373. package/dist/chunks/chunk-WTHWEPDU.js.map +1 -0
  374. package/dist/chunks/chunk-WUME5EGP.js +3599 -0
  375. package/dist/chunks/chunk-WUME5EGP.js.map +1 -0
  376. package/dist/chunks/chunk-XKCAACM6.js +7970 -0
  377. package/dist/chunks/chunk-XKCAACM6.js.map +1 -0
  378. package/dist/chunks/chunk-XNIBWYHL.js +887 -0
  379. package/dist/chunks/chunk-XNIBWYHL.js.map +1 -0
  380. package/dist/chunks/chunk-Y5W2PVX7.js +3613 -0
  381. package/dist/chunks/chunk-Y5W2PVX7.js.map +1 -0
  382. package/dist/chunks/chunk-YHIY6E3N.js +94 -0
  383. package/dist/chunks/chunk-YHIY6E3N.js.map +1 -0
  384. package/dist/chunks/chunk-YHTY7DUW.js +3613 -0
  385. package/dist/chunks/chunk-YHTY7DUW.js.map +1 -0
  386. package/dist/chunks/chunk-YKBQIZ42.js +7971 -0
  387. package/dist/chunks/chunk-YKBQIZ42.js.map +1 -0
  388. package/dist/chunks/chunk-YZNWGPQB.js +7970 -0
  389. package/dist/chunks/chunk-YZNWGPQB.js.map +1 -0
  390. package/dist/chunks/chunk-ZEIFNXEY.js +887 -0
  391. package/dist/chunks/chunk-ZEIFNXEY.js.map +1 -0
  392. package/dist/chunks/chunk-ZL6XU46A.js +94 -0
  393. package/dist/chunks/chunk-ZL6XU46A.js.map +1 -0
  394. package/dist/chunks/chunk-ZXLMZGX3.js +7970 -0
  395. package/dist/chunks/chunk-ZXLMZGX3.js.map +1 -0
  396. package/dist/index.js +5 -5
  397. package/dist/item.css +41 -4
  398. package/dist/qti-components/index.js +1 -1
  399. package/dist/qti-components-jsx.d.ts +7 -7
  400. package/dist/qti-item/components/item-container.js +2 -2
  401. package/dist/qti-item/core/index.js +2 -2
  402. package/dist/qti-test/components/index.js +2 -2
  403. package/dist/qti-test/components/test-container.js +2 -2
  404. package/dist/qti-test/core/index.js +2 -2
  405. package/dist/vscode.html-custom-data.json +6 -6
  406. package/package.json +1 -1
@@ -0,0 +1,1465 @@
1
+ import{a as Xe}from"./chunk-EHK76KRT.js";import{a as ue,b as Q,c as he,e as me,f as ee,g as zt,h as Ft,i as Ye,j as Ut}from"./chunk-6BGG2JJR.js";import{a as S}from"./chunk-XUJ7TXHW.js";import{a as N}from"./chunk-2WJEB7LD.js";import{a as q}from"./chunk-LXJSKVMQ.js";import{a as T}from"./chunk-QQCGUVEV.js";import{a as Pt}from"./chunk-ULI6NOVG.js";import{a as Nt,b as _}from"./chunk-7WJYJA45.js";import{a as C}from"./chunk-3BEVQM67.js";import{a as f,b as u,c as x,d as de,e as Ot}from"./chunk-42P7F3FC.js";import{a as b,d as h,e as Je,f as pe,g as k,i as y}from"./chunk-65CZNGQC.js";import{a as Ht}from"./chunk-KWPDTFYH.js";import{a as n}from"./chunk-JR322KXH.js";var D=class extends y{constructor(){super(...arguments);this.identifier="";this.adaptive="false";this.timeDependent=null;this._handleDisabledChange=(e,t)=>{this._interactionElements.forEach(r=>r.disabled=t)};this._handleReadonlyChange=(e,t)=>this._interactionElements.forEach(r=>r.readonly=t);this._context={variables:Ht};this._initialContext={...this._context,variables:this._context.variables};this._feedbackElements=[];this._interactionElements=[];this._handleRegisterVariable=e=>{e.stopImmediatePropagation(),this._context={...this._context,variables:[...this._context.variables,e.detail.variable]},this._initialContext=this._context,e.stopPropagation()};this._handleRegisterFeedback=e=>{e.stopImmediatePropagation();let t=e.detail;this._feedbackElements.push(t),(Number(this._context.variables.find(i=>i.identifier==="numAttempts")?.value)||0)>0&&t.checkShowFeedback(t.outcomeIdentifier)};this._handleRegisterInteraction=e=>{e.stopImmediatePropagation(),this._interactionElements.push(e.detail.interactionElement)};this._handleEndAttempt=e=>{e.stopImmediatePropagation();let{responseIdentifier:t,countAttempt:r}=e.detail;this.validate(),this.updateResponseVariable(t,"true"),this.processResponse(r)};this._handleSetOutcomeValue=e=>{e.stopImmediatePropagation();let{outcomeIdentifier:t,value:r}=e.detail;this.updateOutcomeVariable(t,r),e.stopPropagation()};this._handleUpdateResponseVariable=e=>{e.stopImmediatePropagation();let{responseIdentifier:t,response:r}=e.detail;this.updateResponseVariable(t,r),this.dispatchEvent(new CustomEvent("qti-item-context-updated",{bubbles:!0,composed:!0,detail:{itemContext:this._context}}))}}get title(){return this._itemTitle}set title(e){this._itemTitle=e,this.removeAttribute("title"),this.setAttribute("data-title",e)}set assessmentItemRefId(e){this._context={...this._context,identifier:e}}get assessmentItemRefId(){return this._context.identifier}get variables(){return this._context.variables.map(e=>({identifier:e.identifier,value:e.value,type:e.type,...e.type==="outcome"&&e.identifier==="SCORE"?{externalScored:e.externalScored}:{}}))}set variables(e){if(!Array.isArray(e)||e.some(t=>!("identifier"in t))){console.warn("variables property should be an array of VariableDeclaration");return}this._context={...this._context,variables:this._context.variables.map(t=>{let r=e.find(i=>i.identifier===t.identifier);return r?{...t,...r,interpolationTable:t.interpolationTable}:t})},this._context.variables.forEach(t=>{if(t.type==="response"){let r=this._interactionElements.find(i=>i.responseIdentifier===t.identifier);r&&(r.response=t.value)}}),this.variables.forEach(t=>{t.type==="outcome"&&this._feedbackElements.forEach(r=>r.checkShowFeedback(t.identifier))})}set responses(e){if(e)for(let t of e){this.getResponse(t.responseIdentifier)&&this.updateResponseVariable(t.responseIdentifier,t.response);let i=this._interactionElements.find(a=>a.getAttribute("response-identifier")===t.responseIdentifier);i&&(i.response=t.response)}}render(){return h`<slot></slot>`}connectedCallback(){this._attachEventListeners(),super.connectedCallback(),this.updateComplete.then(()=>{this.dispatchEvent(new CustomEvent("qti-assessment-item-connected",{bubbles:!0,composed:!0,detail:this}))})}disconnectedCallback(){this._removeEventListeners(),super.disconnectedCallback()}_attachEventListeners(){this.addEventListener("qti-register-variable",this._handleRegisterVariable),this.addEventListener("qti-register-feedback",this._handleRegisterFeedback),this.addEventListener("qti-register-interaction",this._handleRegisterInteraction),this.addEventListener("end-attempt",this._handleEndAttempt),this.addEventListener("qti-set-outcome-value",this._handleSetOutcomeValue),this.addEventListener("qti-interaction-response",this._handleUpdateResponseVariable)}_removeEventListeners(){this.removeEventListener("qti-register-variable",this._handleRegisterVariable),this.removeEventListener("qti-register-feedback",this._handleRegisterFeedback),this.removeEventListener("qti-register-interaction",this._handleRegisterInteraction),this.removeEventListener("end-attempt",this._handleEndAttempt),this.removeEventListener("qti-set-outcome-value",this._handleSetOutcomeValue),this.removeEventListener("qti-interaction-response",this._handleUpdateResponseVariable)}showCorrectResponse(e){let t=this._context.variables.filter(r=>r.type==="response");for(let r of this._interactionElements){let i=r.getAttribute("response-identifier"),a=t.find(o=>o.identifier===i);a&&r.toggleCorrectResponse(a,e)}}processResponse(e=!0,t=!0){this.validate(t),e&&this.updateOutcomeVariable("numAttempts",(+this._context.variables.find(i=>i.identifier==="numAttempts")?.value+1).toString());let r=this.querySelector("qti-response-processing");return!r||!r.process?!1:(r.process(),this.adaptive==="false"&&this.updateOutcomeVariable("completionStatus",this._getCompletionStatus()),this.dispatchEvent(new CustomEvent("qti-item-context-updated",{bubbles:!0,composed:!0,detail:{itemContext:this._context}})),!0)}resetResponses(){this._context=this._initialContext}getResponse(e){return this.getVariable(e)}getOutcome(e){return this.getVariable(e)}getVariable(e){return this._context.variables.find(t=>t.identifier===e)||null}updateResponseVariable(e,t){this._context={...this._context,variables:this._context.variables.map(r=>r.identifier!==e?r:{...r,value:t})},this.dispatchEvent(new CustomEvent("qti-interaction-changed",{bubbles:!0,composed:!0,detail:{item:this.identifier,responseIdentifier:e,response:Array.isArray(t)?[...t]:t}})),this.adaptive==="false"&&this.updateOutcomeVariable("completionStatus",this._getCompletionStatus())}setOutcomeVariable(e,t){this.updateOutcomeVariable(e,t),this.dispatchEvent(new CustomEvent("qti-item-context-updated",{bubbles:!0,composed:!0,detail:{itemContext:this._context}}))}updateOutcomeVariable(e,t){let r=this.getOutcome(e);if(!r){console.warn(`Can not set qti-outcome-identifier: ${e}, it is not available`);return}this._context={...this._context,variables:this._context.variables.map(i=>i.identifier!==e?i:{...i,value:r.cardinality==="single"?t:[...i.value,t]})},this._feedbackElements.forEach(i=>i.checkShowFeedback(e)),this.dispatchEvent(new CustomEvent("qti-outcome-changed",{bubbles:!0,composed:!0,detail:{item:this.identifier,outcomeIdentifier:e,value:this._context.variables.find(i=>i.identifier===e)?.value}}))}validate(e=!0){return this._interactionElements.every(t=>t.validate())?!0:this._interactionElements.some(t=>t.validate())?!1:(e&&this.reportValidity(),null)}reportValidity(){for(let e of this._interactionElements)e.reportValidity()}_getCompletionStatus(){let e=this.validate(!1);return e===!0?"completed":e===!1?"incomplete":"not_attempted"}};n([u({type:String})],D.prototype,"identifier",2),n([u({type:String})],D.prototype,"adaptive",2),n([u({type:String})],D.prototype,"timeDependent",2),n([u({type:String})],D.prototype,"title",1),n([u({type:Boolean})],D.prototype,"disabled",2),n([S("disabled",{waitUntilFirstUpdate:!0})],D.prototype,"_handleDisabledChange",2),n([u({type:Boolean})],D.prototype,"readonly",2),n([S("readonly",{waitUntilFirstUpdate:!0})],D.prototype,"_handleReadonlyChange",2),n([Nt({context:T})],D.prototype,"_context",2),D=n([f("qti-assessment-item")],D);var fe=class extends y{constructor(){super(...arguments);this.identifier="";this.href=""}async connectedCallback(){super.connectedCallback();let e=new Event("qti-assessment-stimulus-ref-connected",{cancelable:!0,bubbles:!0,composed:!0});if(this.dispatchEvent(e)){let i=this.closest("qti-assessment-item").querySelector(`[data-stimulus-idref=${this.identifier}]`);i?await this.updateStimulusRef(i):console.warn(`Stimulus with data-stimulus-idref ${this.identifier} not found`)}}async updateStimulusRef(e){let t=await Pt().load(this.href).promise.then(r=>r.htmlDoc());if(t){let r=t.querySelectorAll("qti-stimulus-body, qti-stylesheet");e.innerHTML="",e.append(...r)}}};n([u({type:String})],fe.prototype,"identifier",2),n([u({type:String})],fe.prototype,"href",2),fe=n([f("qti-assessment-stimulus-ref")],fe);var We=class extends y{};We=n([f("qti-companion-materials-info")],We);var qe=class extends y{render(){return h`<slot @slotchange=${this.handleSlotChange}></slot>`}handleSlotChange(){let s=Array.from(this.firstElementChild?.childNodes??[]).find(e=>e.nodeType===Node.COMMENT_NODE);try{this.operatorFunction=new Function("context","fn","item",s?.textContent??"")}catch(e){console.error("custom-operator contains invalid javascript code",e)}}calculate(){let s={variable:t=>this._context?.variables.find(r=>r.identifier===t)?.value??"",correct:t=>this._context?.variables.find(r=>r.identifier===t)?.correctResponse??""},e={getVariable:t=>this._context?.variables.find(r=>r.identifier===t),updateOutcomeVariable:(t,r)=>{this.dispatchEvent(new CustomEvent("qti-set-outcome-value",{bubbles:!0,composed:!0,detail:{outcomeIdentifier:t,value:r}}))},updateResponseVariable:(t,r)=>{this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,composed:!0,detail:{responseIdentifier:t,response:r}}))}};return this.operatorFunction(this._context,s,e)}};n([_({context:T,subscribe:!0}),x()],qe.prototype,"_context",2),qe=n([f("qti-custom-operator")],qe);var hr=()=>new Intl.NumberFormat().format(.1).replace(/\d/g,""),we=p=>{if(typeof p=="string")return p;let s=hr();return s==="."?p.toLocaleString():p.toString().replace(".","").replace(s,".")};function ct(p){return p==null}function ae(p){return p.replace(/([^:]\/)\/+/g,"$1").replace(/\/\//g,"/").replace("http:/","http://").replace("https:/","https://")}var V=class extends y{connectedCallback(){super.connectedCallback(),this.dispatchEvent(new CustomEvent("qti-register-feedback",{bubbles:!0,composed:!0,detail:this}))}checkShowFeedback(s){let e=this._context.variables.find(r=>r.identifier===s)||null;if(this.outcomeIdentifier!==s||!e)return;let t=!1;Array.isArray(e.value)?t=e.value.includes(this.identifier):t=!ct(this.identifier)&&!ct(e?.value)&&this.identifier===e.value||!1,this.showFeedback(t)}showFeedback(s){this.showStatus=s&&this.showHide==="show"||!s&&this.showHide==="hide"?"on":"off"}};n([u({type:String,attribute:"show-hide"})],V.prototype,"showHide",2),n([u({type:String,attribute:"outcome-identifier"})],V.prototype,"outcomeIdentifier",2),n([u({type:String})],V.prototype,"identifier",2),n([u({type:String,attribute:!1})],V.prototype,"showStatus",2),n([_({context:T,subscribe:!0}),x()],V.prototype,"_context",2);var Re=class extends V{render(){return h` <slot part="feedback" class="feedback ${this.showStatus}"></slot> `}connectedCallback(){super.connectedCallback(),this.checkShowFeedback(this.outcomeIdentifier)}};Re.styles=b`
2
+ :host {
3
+ display: block;
4
+ }
5
+ .on {
6
+ display: block;
7
+ }
8
+ .off {
9
+ display: none;
10
+ }
11
+ `,Re=n([f("qti-feedback-block")],Re);var O=p=>p??k;var Te=class extends V{constructor(){super(...arguments);this.render=()=>h` <slot part="feedback" class="${O(this.showStatus)}"></slot> `}connectedCallback(){super.connectedCallback(),this.checkShowFeedback(this.outcomeIdentifier)}};Te.styles=b`
12
+ .on {
13
+ display: inline-block;
14
+ }
15
+ .off {
16
+ display: none;
17
+ }
18
+ `,Te=n([f("qti-feedback-inline")],Te);var Se=class extends V{render(){return h`
19
+ <dialog class="qti-dialog" part="feedback" ?open="${this.showStatus==="on"}">
20
+ <slot></slot>
21
+ <div style="margin-top: var(--qti-gap-size); text-align: center;">
22
+ <button class="button close-button" @click="${this.closeFeedback}">Close</button>
23
+ </div>
24
+ </dialog>
25
+ `}openFeedback(){let s=this.shadowRoot?.querySelector("dialog");s&&!s.open&&s.showModal()}closeFeedback(){let s=this.shadowRoot?.querySelector("dialog");s&&s.open&&(s.close(),this.showStatus="off")}connectedCallback(){super.connectedCallback(),this.showStatus==="on"&&this.openFeedback()}updated(s){s.has("showStatus")&&(this.showStatus==="on"?this.openFeedback():this.closeFeedback())}};Se.styles=b`
26
+ .qti-dialog {
27
+ background: var(--qti-bg);
28
+ border: var(--qti-border-thickness) var(--qti-border-style) var(--qti-border-color);
29
+ border-radius: var(--qti-border-radius);
30
+ padding: var(--qti-padding-vertical) var(--qti-padding-horizontal);
31
+ box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
32
+ position: fixed;
33
+ top: 50%;
34
+ left: 50%;
35
+ transform: translate(-50%, -50%);
36
+ z-index: 1000;
37
+ width: auto;
38
+ max-width: 90%;
39
+ }
40
+
41
+ .button {
42
+ border-radius: var(--qti-border-radius);
43
+ padding: var(--qti-padding-vertical) var(--qti-padding-horizontal);
44
+ background-color: var(--qti-bg-active);
45
+ border: var(--qti-border-active);
46
+ cursor: pointer;
47
+ position: relative;
48
+ display: inline-block;
49
+ }
50
+
51
+ .button:hover {
52
+ background-color: var(--qti-hover-bg);
53
+ }
54
+
55
+ .button:disabled {
56
+ background-color: var(--qti-disabled-bg);
57
+ color: var(--qti-disabled-color);
58
+ cursor: not-allowed;
59
+ }
60
+
61
+ .button:focus {
62
+ outline: var(--qti-focus-border-width) solid var(--qti-focus-color);
63
+ }
64
+ `,Se=n([f("qti-modal-feedback")],Se);var Me=class extends y{connectedCallback(){super.connectedCallback(),this.dispatchEvent(new CustomEvent("qti-register-hotspot",{bubbles:!0,composed:!0,cancelable:!1}))}render(){return h` <slot name="drags"></slot> `}};Me.styles=b`
65
+ :host {
66
+ display: flex;
67
+ user-select: none;
68
+ position: absolute;
69
+ }
70
+ `,Me=n([f("qti-associable-hotspot")],Me);var jt=(p,s,e)=>{class t extends p{}return t};var H=(p,s,e,t)=>{class r extends jt(p,e,s){constructor(){super(...arguments);this.observer=null;this.droppableObsever=null;this.resizeObserver=null;this.draggables=[];this.droppables=[];this.dragContainers=[];this.dragClone=null;this.dragSource=null;this.touchStartPoint=null;this.isDraggable=!1;this.cloneOffset={x:0,y:0};this.isDragging=!1;this.allDropzones=[];this.lastTarget=null;this.currentDropTarget=null;this.MIN_DRAG_DISTANCE=5;this.DRAG_CLONE_OPACITY=1;this.dataTransfer={data:{},setData(o,l){this.data[o]=l},getData(o){return this.data[o]},effectAllowed:"move"};this.configuration={copyStylesDragClone:!0,dragCanBePlacedBack:!0,dragOnClick:!1};this.minAssociations=1;this.maxAssociations=0;this.draggablesModified=(o,l)=>{for(let d of l)this.draggables.includes(d)&&(this.draggables=this.draggables.filter(m=>m!==d),d.removeAttribute("tabindex"),d.removeEventListener("touchstart",this.handleTouchStart.bind(this)),d.removeEventListener("mousedown",this.handleTouchStart.bind(this)));for(let d of o)this.draggables.includes(d)||(this.draggables.push(d),d.setAttribute("tabindex","0"),d.hasTouchStartListener||(d.addEventListener("touchstart",this.handleTouchStart.bind(this),{passive:!1}),d.addEventListener("mousedown",this.handleTouchStart.bind(this),{passive:!1}),d.hasTouchStartListener=!0));let c=0;this.draggables.forEach(d=>{d.style.viewTransitionName=`drag-${c}-${this.getAttribute("identifier")||crypto.randomUUID()}`,d.setAttribute("qti-draggable","true"),c++})};this.droppablesModified=(o,l)=>{for(let c of l)this.droppables.includes(c)&&(this.droppables=this.droppables.filter(d=>d!==c),this.allDropzones=this.allDropzones.filter(d=>d!==c));for(let c of o)this.droppables.includes(c)||(this.droppables.push(c),this.allDropzones.push(c));for(let c of this.droppables)this.dataset.choicesContainerWidth&&(c.style.width=`${this.dataset.choicesContainerWidth}px`,c.style.boxSizing="border-box")}}handleDraggableContainerChange(o,l){this.isMatchTabular()||(o.length>0||l.length>0)&&this.dragContainersModified(o||[],l||[])}dragContainersModified(o,l){for(let c of l)this.dragContainers.includes(c)&&(this.dragContainers=this.dragContainers.filter(d=>d!==c),this.allDropzones=this.allDropzones.filter(d=>d!==c));for(let c of o)this.dragContainers.includes(c)||(this.dragContainers.push(c),this.allDropzones.push(c))}handleDraggablesChange(o,l){this.isMatchTabular()||(o.length>0||l.length>0)&&this.draggablesModified(o||[],l||[])}handleDroppablesChange(o,l){this.isMatchTabular()||(o.length>0||l.length>0)&&this.droppablesModified(o||[],l||[])}firstUpdated(o){super.firstUpdated(o),this.hasAttribute("disabled")||(document.addEventListener("touchmove",this.handleTouchMove.bind(this),{passive:!1}),document.addEventListener("mousemove",this.handleTouchMove.bind(this),{passive:!1}),document.addEventListener("touchend",this.handleTouchEnd.bind(this),{passive:!1}),document.addEventListener("mouseup",this.handleTouchEnd.bind(this),{passive:!1}),document.addEventListener("touchcancel",this.handleTouchCancel.bind(this),{passive:!1}));let c=Array.from(this.querySelectorAll(s)||[]).concat(Array.from(this.shadowRoot?.querySelectorAll(s)||[])),d=Array.from(this.querySelectorAll(e)||[]).concat(Array.from(this.shadowRoot?.querySelectorAll(e)||[])),m=Array.from(this.querySelectorAll(t)||[]).concat(Array.from(this.shadowRoot?.querySelectorAll(t)||[]));this.dragContainersModified(m,[]),this.droppablesModified(d,[]),this.draggablesModified(c,[]),this.updateMinDimensionsForDropZones(),this.observer=new MutationObserver(()=>this.updateMinDimensionsForDropZones()),this.observer.observe(this,{childList:!0,subtree:!0}),this.resizeObserver=new ResizeObserver(()=>this.updateMinDimensionsForDropZones()),this.querySelectorAll("qti-gap-text").forEach(v=>this.resizeObserver?.observe(v))}async moveDraggableToDroppable(o,l){(()=>{o.style.transform="translate(0, 0)",l.tagName==="SLOT"?o.setAttribute("slot",l.getAttribute("name")):l.appendChild(o),this.checkAllMaxAssociations(),this.saveResponse()})()}activateDroppable(o){this.dragContainers.includes(o)?(this._internals.states.add("--dragzone-active"),o.setAttribute("active","")):(this._internals.states.delete("--dragzone-active"),o.setAttribute("active",""))}deactivateDroppable(o,l=!0){l&&this._internals.states.add("--dragzone-active"),o.removeAttribute("active")}connectedCallback(){super.connectedCallback()}isMatchTabular(){return this.classList.contains("qti-match-tabular")}updateMinDimensionsForDropZones(){let o=this.querySelectorAll(s),l=Array.from(this.querySelectorAll(e)).map(g=>g),c=0,d=0;o.forEach(g=>{let v=g.getBoundingClientRect();c=Math.max(c,v.height),d=Math.max(d,v.width)});let m=this.querySelector(t)||this.shadowRoot?.querySelector(t);m&&(m.style.minHeight=`${c}px`,m.style.minWidth=`${d}px`);for(let g of l)g.style.minHeight=`${c}px`,g.style.minWidth=`${d}px`}activateDroppables(o){this.dragContainers.forEach(c=>{c.setAttribute("enabled",""),c.hasAttribute("disabled")&&(c.contains(o)||c.shadowRoot&&c.shadowRoot.contains(o))&&c.removeAttribute("disabled")}),this.droppables.forEach(c=>{c.setAttribute("enabled",""),c.hasAttribute("disabled")&&(c.contains(o)||c.shadowRoot&&c.shadowRoot.contains(o))&&c.removeAttribute("disabled")})}activateDragLocation(){this._internals.states.add("--dragzone-enabled")}deactivateDragLocation(){this._internals.states.delete("--dragzone-enabled")}deactivateDroppables(){this.dragContainers.forEach(l=>{l.removeAttribute("enabled"),l.removeAttribute("active")}),this.droppables.forEach(l=>{l.removeAttribute("enabled"),l.removeAttribute("active")})}disconnectedCallback(){super.disconnectedCallback(),this.observer&&(this.observer.disconnect(),this.observer=null),this.droppableObsever&&(this.droppableObsever.disconnect(),this.droppableObsever=null),this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),document.removeEventListener("touchmove",this.handleTouchMove),document.removeEventListener("mousemove",this.handleTouchMove),document.removeEventListener("touchend",this.handleTouchEnd),document.removeEventListener("mouseup",this.handleTouchEnd),document.removeEventListener("touchcancel",this.handleTouchCancel)}handleTouchMove(o){if(this.isDraggable&&this.dragClone){let{x:l,y:c}=this.getEventCoordinates(o),d={clientX:l,clientY:c};this.calculateDragDistance(d)>=this.MIN_DRAG_DISTANCE&&(this.isDragging=!0,this.updateDragClonePosition(d));let m=this.findClosestDropzone();this.currentDropTarget=m,m!==this.lastTarget&&(this.lastTarget&&(this.deactivateDroppable(this.lastTarget),this.dispatchCustomEvent(this.lastTarget,"dragleave")),m&&(this.activateDroppable(m),this.dispatchCustomEvent(m,"dragenter")),this.lastTarget=m),this.currentDropTarget&&this.dispatchCustomEvent(this.currentDropTarget,"dragover"),o.preventDefault()}}handleTouchEnd(o){this.isDragging&&this.resetDragState(),this._internals.states.delete("--dragzone-active"),this.checkAllMaxAssociations(),this._internals.states.delete("--dragzone-enabled"),this._internals.states.delete("--dragzone-active"),this.deactivateDragLocation(),this.deactivateDroppables(),this.draggables.forEach(l=>{l.removeAttribute("dragging")}),o.preventDefault()}handleTouchCancel(o){this.resetDragState()}validate(){if(!this.shadowRoot)return!1;let o=this.getValidAssociations(),l=!0,c="";this.maxAssociations>0&&o>this.maxAssociations?(l=!1,c=this.dataset.maxSelectionsMessage||`You've selected too many associations. Maximum allowed is ${this.maxAssociations}.`):this.minAssociations>0&&o<this.minAssociations&&(l=!1,c=this.dataset.minSelectionsMessage||`You haven't selected enough associations. Minimum required is ${this.minAssociations}.`);let d=this.lastElementChild;return this._internals.setValidity(l?{}:{customError:!0},c,d),l}reportValidity(){let o=this.shadowRoot.querySelector("#validation-message");return o&&(this._internals.validity.valid?(o.textContent="",o.style.display="none"):(o.textContent=this._internals.validationMessage,o.style.display="block")),this._internals.validity.valid}checkMaxAssociations(o){let l=this.getMatchMaxValue(o),c=o.querySelectorAll('[qti-draggable="true"]').length;return!(l===0)&&c>=l}dropDraggableInDroppable(o,l){let c=o.cloneNode(!0);c.removeAttribute("style"),this.moveDraggableToDroppable(c,l),this.draggablesModified([c],[]);let d=this.getMatchMaxValue(o),m=this.draggables.filter(g=>g.getAttribute("identifier")===o.getAttribute("identifier"));d!==0&&m.length>=d?(o.style.opacity="0.0",o.style.pointerEvents="none"):o.style.opacity="1.0"}resetDragState(){if(this.dragClone){let o=this.currentDropTarget!==null,l=!o||this.dragContainers.includes(this.currentDropTarget);o&&this.currentDropTarget&&!l&&this.dropDraggableInDroppable(this.dragSource,this.currentDropTarget),l&&(this.dragSource.style.opacity="1.0",this.dragSource.style.display="block",this.dragSource.style.position="static",this.dragSource.style.pointerEvents="auto",this.saveResponse()),this.dragClone.remove(),this.draggablesModified([],[this.dragClone])}this.isDragging=!1,this.isDraggable=!1,this.dragSource=null,this.dragClone=null,this.touchStartPoint=null,this.currentDropTarget=null,this.lastTarget=null,this.deactivateDroppables()}checkAllMaxAssociations(){let o=this.getValidAssociations(),l=this.maxAssociations!==0&&o>=this.maxAssociations;this.droppables.forEach(c=>{l?this.disableDroppable(c):this.checkMaxAssociations(c)?this.disableDroppable(c):this.enableDroppable(c)})}getMatchMaxValue(o){let l=o.getAttribute("match-max");return l?parseInt(l,10):1}disableDroppable(o){o.setAttribute("disabled","")}enableDroppable(o){o.removeAttribute("disabled")}get response(){let o;return typeof this.getResponse=="function"?o=this.getResponse():o=this.collectResponseData(),o.join(",")}set response(o){if(!this.isMatchTabular())if(typeof this.getValue=="function"&&(o=this.getValue(o)),Array.isArray(o)){this.reset(!1),o?.forEach(c=>this.placeResponse(c));let l=new FormData;o.forEach(c=>{l.append(this.responseIdentifier,c)}),this._internals.setFormValue(l)}else this._internals.setFormValue(o||"")}placeResponse(o){let[l,...c]=o.split(" ").reverse(),d=Array.from(this.draggables),m=Array.from(this.droppables);c.forEach(g=>{if(g==="")return;let v=d.find(R=>R.getAttribute("identifier")===g),E=m.find(R=>R.getAttribute("identifier")===l);this.dropDraggableInDroppable(v,E)})}getValidAssociations(){let o=0;for(let l of this.droppables)o=o+this.getDraggablesFromDroppable(l).length;return o}saveResponse(){let o;typeof this.getResponse=="function"?o=this.getResponse():o=this.collectResponseData(),this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,composed:!0,detail:{responseIdentifier:this.responseIdentifier,response:o}}))}collectResponseData(){return this.droppables.map(l=>{let d=this.getDraggablesFromDroppable(l).map(g=>g.getAttribute("identifier")),m=l.getAttribute("identifier");return d.map(g=>`${g} ${m}`)}).flat()}getDraggablesFromDroppable(o){return this.draggables.map(d=>d.getAttribute("identifier")).filter((d,m,g)=>g.indexOf(d)===m).flatMap(d=>Array.from(o.querySelectorAll(`[identifier='${d}']`))).filter(d=>!!d).map(d=>d)}reset(o=!0){this.droppables.forEach(l=>{this.getDraggablesFromDroppable(l).forEach(d=>{d.remove(),this.draggablesModified([],[d])})}),this.dragContainers.forEach(l=>{Array.from(l.querySelectorAll('[qti-draggable="true"]')).forEach(d=>{d.style.opacity="1.0"})}),this.dragClone=null,this.dragSource=null,this.isDragging=!1,this.isDraggable=!1,this.currentDropTarget=null,this.lastTarget=null,o&&this.saveResponse()}updateDragClonePosition(o){if(!this.isDragging||!this.dragClone)return;let l=o.clientX-this.cloneOffset.x,c=o.clientY-this.cloneOffset.y,{newLeft:d,newTop:m}=this.applyInteractionBoundaries(l,c,this.dragClone);this.dragClone.style.left=`${d}px`,this.dragClone.style.top=`${m}px`}applyInteractionBoundaries(o,l,c){let d=this.getBoundingClientRect(),m=c.getBoundingClientRect(),g=m.width,v=m.height,E=Math.max(d.left,Math.min(o,d.right-g)),R=Math.max(d.top,Math.min(l,d.bottom-v));return{newLeft:E,newTop:R}}getEventCoordinates(o,l=!1){let c=o.touches?o.touches[0]:o;return{x:l?c.pageX:c.clientX,y:l?c.pageY:c.clientY}}calculateDragDistance(o){let l=Math.abs(o.clientX-this.touchStartPoint.x),c=Math.abs(o.clientY-this.touchStartPoint.y);return l+c}findClosestDropzone(){let o=this.allDropzones.filter(m=>!m.hasAttribute("disabled"));if(!this.dragClone||o.length===0)return null;let l=this.dragClone.getBoundingClientRect(),c=null,d=0;for(let m of o){let g=m.getBoundingClientRect(),v=this.calculateOverlapArea(l,g);v>d&&(d=v,c=m)}if(!c){let m=200;for(let g of o){let v=g.getBoundingClientRect(),E=Math.sqrt(Math.pow(l.left-v.left,2)+Math.pow(l.top-v.top,2));E<m&&(m=E,c=g)}}return c}calculateOverlapArea(o,l){let c=Math.max(0,Math.min(o.right,l.right)-Math.max(o.left,l.left)),d=Math.max(0,Math.min(o.bottom,l.bottom)-Math.max(o.top,l.top));return c*d}dispatchCustomEvent(o,l,c=!0){if(!o)return;let d=new CustomEvent(l,{bubbles:c,cancelable:!0});d.dataTransfer=this.dataTransfer,o.dispatchEvent(d)}appendClone(){document.body.appendChild(this.dragClone)}handleTouchStart(o){if(this.isDragging)return;let{x:l,y:c}=this.getEventCoordinates(o);this.touchStartPoint={x:l,y:c},this.dragSource=o.currentTarget,this.isDraggable=!0,this._internals.states.add("--dragzone-enabled"),this._internals.states.add("--dragzone-active"),this.activateDragLocation(),this.activateDroppables(this.dragSource);let d=this.findDraggableInDraggableContainer(this.dragSource.getAttribute("identifier")),m=this.droppables.some(w=>Array.from(w.children).some(ce=>ce===this.dragSource)),g=this.dragSource.getBoundingClientRect();m&&(this.dragSource.remove(),this.draggablesModified([],[this.dragSource]),this.dragSource=d),this.cloneOffset.x=l-g.left,this.cloneOffset.y=c-g.top,this.dragClone=d.cloneNode(!0);let v=window.getComputedStyle(d);for(let w=0;w<v.length;w++){let ce=v[w];this.dragClone.style.setProperty(ce,v.getPropertyValue(ce))}let E=d.getBoundingClientRect();this.dragClone.style.width=`${E.width}px`,this.dragClone.style.height=`${E.height}px`,g&&this.setDragCloneStyles(g),this.dragClone.style.display="block",this.dragClone.style.opacity="1",this.appendClone();let R=this.getMatchMaxValue(this.dragSource),I=this.draggables.filter(w=>w.getAttribute("identifier")===this.dragSource.getAttribute("identifier"));R!==0&&I.length>=R?(d.style.opacity="0.0",d.style.pointerEvents="none"):d.style.opacity="1.0",o.preventDefault(),this.dragClone.setAttribute("dragging","")}findDraggableInDraggableContainer(o){let l=this.dragContainers.flat();for(let c of l){if(c.getAttribute("identifier")===o)return c;let d;c instanceof HTMLSlotElement?d=Array.from(c?.assignedElements()||[]):d=Array.from(c.querySelectorAll(s));let m=d.find(g=>g.getAttribute("identifier")===o);if(m)return m}}setDragCloneStyles(o){this.dragClone.style.position="fixed",this.dragClone.style.top=`${o.top}px`,this.dragClone.style.left=`${o.left}px`,this.dragClone.style.setProperty("box-sizing","border-box","important"),this.dragClone.style.zIndex="9999",this.dragClone.style.pointerEvents="none",this.dragClone.style.opacity=this.DRAG_CLONE_OPACITY.toString(),this.dragClone.style.display="block"}}return n([u({attribute:!1,type:Object})],r.prototype,"configuration",2),n([u({type:Number,reflect:!0,attribute:"min-associations"})],r.prototype,"minAssociations",2),n([u({type:Number,reflect:!0,attribute:"max-associations"})],r.prototype,"maxAssociations",2),n([Xe(t)],r.prototype,"handleDraggableContainerChange",1),n([Xe(s)],r.prototype,"handleDraggablesChange",1),n([Xe(e)],r.prototype,"handleDroppablesChange",1),r};var Bt=b`
71
+ :host {
72
+ display: block; /* necessary to calculate scaling position */
73
+ }
74
+ slot[name='qti-simple-associable-choice'] {
75
+ display: flex;
76
+ align-items: flex-start;
77
+ flex: 1;
78
+ border: 2px solid transparent;
79
+ padding: 0.3rem;
80
+ border-radius: 0.3rem;
81
+ gap: 0.5rem;
82
+ }
83
+
84
+ :host::part(associables-container) {
85
+ display: flex;
86
+ padding: 0.5rem;
87
+ justify-content: space-between;
88
+ background: linear-gradient(
89
+ 180deg,
90
+ rgb(0 0 0 / 0%) calc(50% - 1px),
91
+ var(--qti-border-color-gray) calc(50%),
92
+ rgb(0 0 0 / 0%) calc(50% + 1px)
93
+ );
94
+ }
95
+ `;var ge=class extends H(C,"qti-simple-associable-choice",".dl","slot[name='qti-simple-associable-choice']"){constructor(){super();this._childrenMap=[];this._registerChoiceHandler=this._registerChoice.bind(this),this.addEventListener("register-qti-simple-associable-choice",this._registerChoiceHandler)}_registerChoice(e){let t=e.target;this._childrenMap.push(t)}render(){return h` <slot name="prompt"></slot>
96
+ <slot name="qti-simple-associable-choice"></slot>
97
+ <div part="drop-container">
98
+ ${this._childrenMap.length>0&&Array.from(Array(Math.ceil(this._childrenMap.length/2)).keys()).map((e,t)=>h`<div part="associables-container">
99
+ <div name="left${t}" part="drop-list" class="dl" identifier="droplist${t}_left"></div>
100
+ <div name="right${t}" part="drop-list" class="dl" identifier="droplist${t}_right"></div>
101
+ </div>`)}
102
+
103
+ <div role="alert" id="validationMessage"></div>
104
+ </div>`}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("register-qti-simple-associable-choice",this._registerChoiceHandler)}};ge.styles=Bt,n([x()],ge.prototype,"_childrenMap",2),ge=n([f("qti-associate-interaction")],ge);var te=(p,s)=>{class e extends p{constructor(){super(...arguments);this._choiceElements=[];this.minChoices=0;this.maxChoices=1;this._handleDisabledChange=(i,a)=>{this._choiceElements.forEach(o=>o.disabled=a)};this._handleReadonlyChange=(i,a)=>{this._choiceElements.forEach(o=>o.readonly=a)};this.response="";this._handleValueChange=()=>{this._internals.setFormValue(this.value),this._updateChoiceSelection()}}_handleMaxChoicesChange(i,a){this._determineInputType()}get value(){return Array.isArray(this.response)&&this.response.length===0||this.response===""?null:Array.isArray(this.response)?this.response.join(","):this.response}set value(i){this.maxChoices>1&&(typeof i=="string"||i===null)?this.response=i?i.toString().split(","):[]:this.response=i||""}toggleCorrectResponse(i,a){if(i.correctResponse){let o=Array.isArray(i.correctResponse)?i.correctResponse:[i.correctResponse];this._choiceElements.forEach(l=>{l.internals.states.delete("correct-response"),l.internals.states.delete("incorrect-response"),a&&o.length>0&&(o.includes(l.identifier)?l.internals.states.add("correct-response"):l.internals.states.add("incorrect-response"))})}}connectedCallback(){super.connectedCallback(),this.addEventListener(`register-${s}`,this._registerChoiceElement),this.addEventListener(`unregister-${s}`,this._unregisterChoiceElement),this.addEventListener(`activate-${s}`,this._choiceElementSelectedHandler)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(`register-${s}`,this._registerChoiceElement),this.removeEventListener(`unregister-${s}`,this._unregisterChoiceElement),this.removeEventListener(`activate-${s}`,this._choiceElementSelectedHandler)}validate(){let i=this._choiceElements.filter(c=>this._getChoiceChecked(c)),a=i.length,o=!0,l="";return this.maxChoices!==0&&a>this.maxChoices?(o=!1,l=this.dataset.maxSelectionsMessage||`Please select no more than ${this.maxChoices} ${this.maxChoices===1?"option":"options"}.`):a<this.minChoices&&(o=!1,l=this.dataset.minSelectionsMessage||`Please select at least ${this.minChoices} ${this.minChoices===1?"option":"options"}.`),i.length>0&&this._internals.setValidity(o?{}:{customError:!0},l,i[a-1]||this._choiceElements[0]||this),o}reportValidity(){return this._validationMessageElement&&(this._internals.validity.valid?(this._validationMessageElement.textContent="",this._validationMessageElement.style.display="none"):(this._validationMessageElement.textContent=this._internals.validationMessage,this._validationMessageElement.style.display="block")),this._internals.validity.valid}_registerChoiceElement(i){i.stopPropagation();let a=i.target;a.disabled=this.disabled,this._choiceElements.push(a),this._setInputType(a)}_unregisterChoiceElement(i){i.stopPropagation();let a=i.target;this._choiceElements=this._choiceElements.filter(o=>o!==a)}_determineInputType(){this._choiceElements.forEach(i=>{this._setInputType(i)})}_setInputType(i){this._internals.role=this.maxChoices===1?"radiogroup":null;let a=this.maxChoices===1?"radio":"checkbox";i.internals.role=a,i.internals.states.delete(a==="radio"?"checkbox":"radio"),i.internals.states.add(a)}_choiceElementSelectedHandler(i){this._toggleChoiceChecked(i.target),this.maxChoices===1&&this._choiceElements.forEach(a=>{a.identifier!==i.detail.identifier&&this._setChoiceChecked(a,!1)}),this._handleChoiceSelection()}_setChoiceChecked(i,a){i.internals?.states&&(a?(i.internals.states.add("--checked"),i.internals.ariaChecked="true"):(i.internals.states.delete("--checked"),i.internals.ariaChecked="false"))}_getChoiceChecked(i){return i.internals.states.has("--checked")}_toggleChoiceChecked(i){let a=this._getChoiceChecked(i);this._setChoiceChecked(i,!a)}_handleChoiceSelection(){let a=this._choiceElements.filter(o=>this._getChoiceChecked(o)).map(o=>o.identifier);this.response=this.maxChoices===1?a[0]||"":a,this.validate(),this.saveResponse(this.response)}_updateChoiceSelection(){let i=Array.isArray(this.response)?this.response:[this.response];this._choiceElements.forEach(a=>{let o=i.includes(a.identifier);this._setChoiceChecked(a,o)})}}return n([de("#validation-message")],e.prototype,"_validationMessageElement",2),n([u({type:Number,attribute:"min-choices"})],e.prototype,"minChoices",2),n([u({type:Number,attribute:"max-choices"})],e.prototype,"maxChoices",2),n([S("maxChoices",{waitUntilFirstUpdate:!0})],e.prototype,"_handleMaxChoicesChange",1),n([S("disabled",{waitUntilFirstUpdate:!0})],e.prototype,"_handleDisabledChange",2),n([S("readonly",{waitUntilFirstUpdate:!0})],e.prototype,"_handleReadonlyChange",2),n([x()],e.prototype,"response",2),n([S("response",{waitUntilFirstUpdate:!0})],e.prototype,"_handleValueChange",2),e};var Jt=(p,s)=>{class e extends p{constructor(){super(...arguments);this._classes=[];this._allLabels=["qti-labels-decimal","qti-labels-lower-alpha","qti-labels-upper-alpha"];this._allLabelSuffixes=["qti-labels-suffix-period","qti-labels-suffix-parenthesis"]}set class(i){i&&(this._classes=i.split(" "),this._addLabels())}get class(){return this._classes?.join(" ")||""}updated(i){super.updated(i),this._addLabels()}_addLabels(){let i=this._classes.some(o=>this._allLabels.includes(o)||this._allLabelSuffixes.includes(o)),a=o=>!isNaN(+o);if(i){let l=Array.from(this.querySelectorAll("qti-simple-choice")).map(c=>c).map((c,d)=>({el:c,order:a(c.style.order)?+c.style.order:d+1})).sort((c,d)=>c.order-d.order).map(c=>c.el);for(let c=0;c<l.length;c++)l[c].marker=this._getLabel(c+1)}}_getLabel(i){let a=this._classes.filter(c=>this._allLabels.includes(c)).pop(),o=this._classes.filter(c=>this._allLabelSuffixes.includes(c)).pop();!a&&o&&(a="qti-labels-upper-alpha");let l="";switch(a){case"qti-labels-decimal":l=`${i}`;break;case"qti-labels-lower-alpha":l=`${String.fromCharCode(97+i-1)}`;break;case"qti-labels-upper-alpha":l=`${String.fromCharCode(65+i-1)}`;break}return o==="qti-labels-suffix-period"?l+=".":o==="qti-labels-suffix-parenthesis"&&(l+=")"),l}}return n([u({type:String,reflect:!0})],e.prototype,"class",1),e};var Xt=b`
105
+ :host {
106
+ display: block;
107
+ }
108
+
109
+ [part='slot'] {
110
+ display: grid;
111
+ gap: 10px;
112
+ }
113
+
114
+ /* Define the number of columns dynamically */
115
+ :host([class*='qti-choices-stacking-']) [part='slot'] {
116
+ grid-template-columns: repeat(var(--stacking-count, 1), 1fr);
117
+ }
118
+
119
+ /* Apply dynamic stacking count based on class */
120
+ :host(.qti-choices-stacking-1) {
121
+ --stacking-count: 1;
122
+ }
123
+ :host(.qti-choices-stacking-2) {
124
+ --stacking-count: 2;
125
+ }
126
+ :host(.qti-choices-stacking-3) {
127
+ --stacking-count: 3;
128
+ }
129
+ :host(.qti-choices-stacking-4) {
130
+ --stacking-count: 4;
131
+ }
132
+ :host(.qti-choices-stacking-5) {
133
+ --stacking-count: 5;
134
+ }
135
+ :host(.qti-choices-stacking-6) {
136
+ --stacking-count: 6;
137
+ }
138
+
139
+ /* Default slot item layout */
140
+ ::slotted(qti-simple-choice) {
141
+ display: flex;
142
+ align-items: center;
143
+ white-space: normal;
144
+ }
145
+
146
+ /* Orientation styles */
147
+ :host(.qti-orientation-horizontal) [part='slot'] {
148
+ grid-auto-flow: dense column;
149
+ grid-auto-columns: 1fr;
150
+ }
151
+
152
+ :host(.qti-orientation-vertical) [part='slot'] {
153
+ grid-auto-flow: row;
154
+ }
155
+
156
+ /* Vertical and horizontal stacking logic */
157
+ :host(.qti-orientation-vertical[class*='qti-choices-stacking-']) [part='slot'] {
158
+ grid-auto-flow: dense column;
159
+ grid-auto-columns: 1fr;
160
+ grid-template-columns: repeat(var(--stacking-count), 1fr);
161
+ grid-template-rows: repeat(calc(var(--item-count) / var(--stacking-count)), 1fr);
162
+ }
163
+
164
+ :host(.qti-orientation-horizontal[class*='qti-choices-stacking-']) [part='slot'] {
165
+ grid-auto-flow: row;
166
+ grid-template-columns: repeat(var(--stacking-count), 1fr);
167
+ grid-template-rows: unset;
168
+ }
169
+
170
+ /* Ensure even distribution in vertical mode */
171
+ :host(.qti-orientation-vertical) ::slotted(qti-simple-choice:nth-child(even)) {
172
+ grid-row: auto;
173
+ }
174
+ `;var be=class extends Jt(te(C,"qti-simple-choice"),"qti-simple-choice"){constructor(){super(...arguments);this.orientation="vertical"}_handleSlotChange(){let e=this.querySelectorAll("qti-simple-choice");this.style.setProperty("--item-count",e.length.toString())}render(){return h`
175
+ <slot part="prompt" name="prompt"></slot><slot part="slot" @slotchange=${this._handleSlotChange}></slot>
176
+ <div part="message" role="alert" id="validationMessage"></div>
177
+ `}};be.styles=Xt,n([u({type:String})],be.prototype,"orientation",2),be=n([f("qti-choice-interaction")],be);var B=class extends C{constructor(){super();this._errorMessage=null;this.handlePostMessage=this.handlePostMessage.bind(this)}connectedCallback(){super.connectedCallback();let e=this.data.startsWith("http")||this.data.startsWith("blob")?this.data:ae(this.baseItemUrl+"/"+this.data);fetch(e).then(t=>t.json()).then(t=>{this.manifest=t,this.setupCES()}).catch(t=>{this._errorMessage=t})}setupCES(){let e=this.shadowRoot.querySelector("#pciContainer"),t=e.contentDocument;if(!this.manifest.script||this.manifest.script.length===0){this._errorMessage="No script found in manifest";return}if(!this.manifest.style||this.manifest.style.length===0){this._errorMessage="No style found in manifest";return}let r=this.manifest.style[0],i=r.startsWith("http")||r.startsWith("blob")?r:ae(`${this.baseRefUrl}/${r}`),a=this.manifest.script[0],o=a.startsWith("http")||a.startsWith("blob")?a:ae(`${this.baseRefUrl}/${a}`);window.addEventListener("message",this.handlePostMessage),t.open(),t.write(`
178
+ <html>
179
+ <head>
180
+ <link href='${i}' rel="stylesheet" />
181
+ <script src='${o}'></script>
182
+ </head>
183
+ <body></body>
184
+ </html>
185
+ `),t.close()}getIFrames(){let e=this.shadowRoot.querySelectorAll("iframe"),t=this.querySelectorAll("iframe"),r=[...e,...t];for(let i of r){let a=i.src;if(new URL(a,window.location.href).origin===window.location.origin)try{let l=i.contentDocument||i.contentWindow.document;l&&this.getInnerIFrames(l,r)}catch(l){console.error("Error accessing nested iframe:",l)}}return r.forEach((i,a)=>{r.indexOf(i)!==a&&r.splice(a,1)}),r}getInnerIFrames(e,t=[]){return e.querySelectorAll("iframe").forEach(i=>{t.push(i);let a=i.src;if(new URL(a,window.location.href).origin===window.location.origin)try{let l=i.contentDocument||i.contentWindow.document;this.getInnerIFrames(l,t)}catch(l){console.error("Error accessing nested iframe:",l)}else console.warn("Skipped cross-origin iframe:",a)}),t}postToWindowAndIframes(e,t){window.postMessage({type:e,data:t},"*");let r=this.getIFrames();for(let i of r)i.contentWindow&&i.contentWindow.postMessage({type:e,data:t},"*")}handlePostMessage(e){let{type:t,data:r}=e.data;switch(t){case"setResponse":this.rawResponse=r,this.saveResponse(r);break;case"getResponse":{this.postToWindowAndIframes("responseData",this.rawResponse);break}case"getMedia":{let i=this.manifest.media.map(a=>a.startsWith("http")||a.startsWith("blob")?a:ae(this.baseRefUrl+"/"+a));this.postToWindowAndIframes("mediaData",i);break}case"setStageHeight":console.log("setStageHeight not implemented");break}}validate(){return this.rawResponse!==""}get response(){return this.rawResponse}set response(e){if(typeof e=="string")this.rawResponse=e,this.saveResponse(e);else throw new Error("Value must be a string")}disconnectedCallback(){window.removeEventListener("message",this.handlePostMessage),super.disconnectedCallback()}render(){return h`<iframe
186
+ width=${this.getAttribute("width")}
187
+ height=${this.getAttribute("height")}
188
+ frameborder="0"
189
+ title="pciContainer"
190
+ id="pciContainer"
191
+ >
192
+ </iframe>
193
+ ${this._errorMessage&&h`<div style="color:red">
194
+ <h1>Error</h1>
195
+ ${this._errorMessage}
196
+ </div>`}`}};n([u({type:String,attribute:"data"})],B.prototype,"data",2),n([u({type:String,attribute:"data-base-item"})],B.prototype,"baseItemUrl",2),n([u({type:String,attribute:"data-base-ref"})],B.prototype,"baseRefUrl",2),n([u({type:String,attribute:"id"})],B.prototype,"id",2),n([x()],B.prototype,"_errorMessage",2),B=n([f("qti-custom-interaction")],B);var re=class extends y{constructor(){super(...arguments);this.disabled=!1;this.countAttempt=null;this.title="end attempt"}render(){return h`<button ?disabled=${this.disabled} part="button" @click=${this.endAttempt}>${this.title}</button>`}endAttempt(e){this.dispatchEvent(new CustomEvent("end-attempt",{bubbles:!0,composed:!0,detail:{responseIdentifier:this.responseIdentifier,countAttempt:this.countAttempt==="true"}}))}};n([u({type:String,attribute:"response-identifier"})],re.prototype,"responseIdentifier",2),n([u({reflect:!0,type:Boolean})],re.prototype,"disabled",2),n([u({type:String,attribute:"count-attempt"})],re.prototype,"countAttempt",2),n([u({type:String})],re.prototype,"title",2),re=n([f("qti-end-attempt-interaction")],re);var Yt=b`
197
+ /* PK: display host as block, else design will be collapsed */
198
+ :host {
199
+ display: block;
200
+ }
201
+ textarea {
202
+ box-sizing: border-box;
203
+ width: 100%;
204
+ height: 100%;
205
+ border: 0;
206
+ }
207
+ `;var L=class extends C{constructor(){super(...arguments);this._rows=5;this.response=null;this._handleResponseChange=()=>{this._internals.setFormValue(this.value),this.validate()}}handleclassNamesChange(e,t){let r=t.split(" "),i=!1;if(r.forEach(a=>{if(a.startsWith("qti-height-lines-")){let o=a.replace("qti-height-lines-","");this._rows=parseInt(o),i=!0}}),!i&&this.expectedLength){let a=Math.ceil(this.expectedLength/50);this._rows=a}}get value(){return this.response||null}set value(e){this.response=e||null}validate(){let e=this.shadowRoot.querySelector("textarea");if(!e)return!1;if(this.patternMask&&this.dataPatternmaskMessage){this._internals.setValidity({}),e.setCustomValidity("");let t=this.patternMask.startsWith("^")&&this.patternMask.endsWith("$")?this.patternMask:`^${this.patternMask}$`,r=new RegExp(t);e.checkValidity()&&r.test(e.value)||(this._internals.setValidity({customError:!0},this.dataPatternmaskMessage),e.setCustomValidity(this.dataPatternmaskMessage))}else{let t=e.checkValidity();this._internals.setValidity(t?{}:{customError:!1})}return!!this.response&&e.checkValidity()}reportValidity(){let e=this.shadowRoot.querySelector("textarea");if(!e)return!1;let t=this.validate();return t||e.reportValidity(),t}render(){return h`<slot name="prompt"></slot
208
+ ><textarea
209
+ part="textarea"
210
+ name="${this.responseIdentifier}"
211
+ spellcheck="false"
212
+ autocomplete="off"
213
+ maxlength="${5e3}"
214
+ @keydown="${e=>e.stopImmediatePropagation()}"
215
+ @keyup="${this.textChanged}"
216
+ @change="${this.textChanged}"
217
+ @blur="${e=>{this.reportValidity()}}"
218
+ placeholder="${O(this.placeholderText?this.placeholderText:void 0)}"
219
+ rows="${this._rows}"
220
+ ?disabled="${this.disabled}"
221
+ ?readonly="${this.readonly}"
222
+ .value=${this.response}
223
+ ></textarea>`}textChanged(e){if(this.disabled||this.readonly)return;let t=e.target;this.setEmptyAttribute(t.value),this.response!==t.value&&(this.value=t.value,this.saveResponse(t.value))}setEmptyAttribute(e){this.setAttribute("empty",e===""?"true":"false")}};L.styles=Yt,n([x()],L.prototype,"_rows",2),n([u({type:Number,attribute:"expected-length"})],L.prototype,"expectedLength",2),n([u({type:String,attribute:"pattern-mask"})],L.prototype,"patternMask",2),n([u({type:String,attribute:"placeholder-text"})],L.prototype,"placeholderText",2),n([u({type:String,attribute:"data-patternmask-message"})],L.prototype,"dataPatternmaskMessage",2),n([u({type:String,attribute:"class"})],L.prototype,"classNames",2),n([S("classNames")],L.prototype,"handleclassNamesChange",1),n([x()],L.prototype,"response",2),n([S("response",{waitUntilFirstUpdate:!0})],L.prototype,"_handleResponseChange",2),L=n([f("qti-extended-text-interaction")],L);var ve=class extends y{constructor(){super(...arguments);this.tabindex=0}connectedCallback(){this.setAttribute("slot","drags")}};ve.styles=b`
224
+ :host {
225
+ display: flex;
226
+ user-select: none;
227
+ }
228
+ `,n([u({type:Number,reflect:!0})],ve.prototype,"tabindex",2),ve=n([f("qti-gap-img")],ve);var Wt=b`
229
+ :host {
230
+ display: flex;
231
+ align-items: flex-start;
232
+ flex-direction: column;
233
+ flex-wrap: wrap;
234
+ gap: 0.5rem;
235
+ }
236
+
237
+ :host(.qti-choices-top) {
238
+ flex-direction: column;
239
+ }
240
+ :host(.qti-choices-bottom) {
241
+ flex-direction: column-reverse;
242
+ }
243
+ :host(.qti-choices-left) {
244
+ flex-direction: row;
245
+ }
246
+ :host(.qti-choices-right) {
247
+ flex-direction: row-reverse;
248
+ }
249
+ /* [part='drops'] , */
250
+ [name='prompt'] {
251
+ width: 100%;
252
+ }
253
+ [name='drags'] {
254
+ display: flex;
255
+ align-items: flex-start;
256
+ flex: 1;
257
+ border: 2px solid transparent;
258
+ padding: 0.3rem;
259
+ border-radius: 0.3rem;
260
+ gap: 0.5rem;
261
+ }
262
+ `;var _e=class extends H(C,"qti-gap-text","qti-gap","slot[part='drags']"){render(){return h`<slot name="prompt"> </slot>
263
+ <slot part="drags" name="drags"></slot>
264
+ <slot part="drops"></slot>
265
+ <div role="alert" id="validation-message"></div>`}toggleCorrectResponse(s,e){if(e&&s.correctResponse){let t=[],r=Array.isArray(s.correctResponse)?s.correctResponse:[s.correctResponse];r&&(t=r.map(a=>{let o=a.split(" ");return{text:o[0],gap:o[1]}})),this.querySelectorAll("qti-gap").forEach(a=>{let o=a.getAttribute("identifier"),l=t.find(d=>d.gap===o)?.text,c=this.querySelector(`qti-gap-text[identifier="${l}"]`)?.textContent.trim();if(l&&c){if(!a.nextElementSibling?.classList.contains("correct-option")){let d=document.createElement("span");d.classList.add("correct-option"),d.textContent=c,d.style.border="1px solid var(--qti-correct)",d.style.borderRadius="4px",d.style.padding="2px 4px",d.style.display="inline-block",a.insertAdjacentElement("afterend",d)}}else a.nextElementSibling?.classList.contains("correct-option")&&a.nextElementSibling.remove()})}else this.querySelectorAll(".correct-option").forEach(r=>{r.remove()})}};_e.styles=Wt,_e=n([f("qti-gap-match-interaction")],_e);var Gt={toAttribute:p=>p?"true":"false",fromAttribute:p=>p==="true"};function P(p,s){class e extends p{constructor(...i){super(...i);this.identifier="";this.tabIndex=0;this.disabled=!1;this.readonly=!1;this.internals=this.attachInternals()}handleDisabledChange(i,a){this.tabIndex=a?-1:0,a&&this.blur()}connectedCallback(){super.connectedCallback(),this.addEventListener("keyup",this._onKeyUp),this.addEventListener("click",this._onClick),this.dispatchEvent(new CustomEvent(`register-${s}`,{bubbles:!0,composed:!0}))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("keyup",this._onKeyUp),this.removeEventListener("click",this._onClick),this.dispatchEvent(new CustomEvent(`unregister-${s}`,{bubbles:!0,composed:!0}))}_onKeyUp(i){i.altKey||i.code==="Space"&&(i.preventDefault(),this._activate())}_onClick(){this.disabled||this.readonly||(this.focus(),this._activate())}_activate(){this.disabled||this.readonly||this.dispatchEvent(new CustomEvent(`activate-${s}`,{bubbles:!0,composed:!0,detail:{identifier:this.identifier}}))}render(){return h`<slot></slot>`}}return n([u({type:String})],e.prototype,"identifier",2),n([u({type:Number,reflect:!0,attribute:"tabindex"})],e.prototype,"tabIndex",2),n([u({type:Boolean,reflect:!0,attribute:"aria-disabled",converter:Gt})],e.prototype,"disabled",2),n([u({type:Boolean,reflect:!0,attribute:"aria-readonly",converter:Gt})],e.prototype,"readonly",2),n([S("disabled",{waitUntilFirstUpdate:!0})],e.prototype,"handleDisabledChange",1),e}var ye=class extends P(y,"qti-gap-text"){constructor(){super(...arguments);this.tabindex=0}connectedCallback(){super.connectedCallback(),this.setAttribute("slot","drags")}render(){return h`<slot></slot>`}};ye.styles=b`
266
+ :host {
267
+ display: inline-flex;
268
+ user-select: none;
269
+ }
270
+ `,n([u({type:Number,reflect:!0})],ye.prototype,"tabindex",2),ye=n([f("qti-gap-text")],ye);var xe=class extends y{constructor(){super(...arguments);this.tabindex=0}render(){return h` <slot name="drags"></slot>`}};xe.styles=b`
271
+ :host {
272
+ display: flex;
273
+ user-select: none;
274
+ }
275
+ `,n([u({type:Number,reflect:!0})],xe.prototype,"tabindex",2),xe=n([f("qti-gap")],xe);var Kt=(p,s,e)=>{let t=new Map;for(let r=s;r<=e;r++)t.set(p[r],r);return t},Ee=Q(class extends he{constructor(p){if(super(p),p.type!==ue.CHILD)throw Error("repeat() can only be used in text expressions")}dt(p,s,e){let t;e===void 0?e=s:s!==void 0&&(t=s);let r=[],i=[],a=0;for(let o of p)r[a]=t?t(o,a):a,i[a]=e(o,a),a++;return{values:i,keys:r}}render(p,s,e){return this.dt(p,s,e).values}update(p,[s,e,t]){let r=Ft(p),{values:i,keys:a}=this.dt(s,e,t);if(!Array.isArray(r))return this.ut=a,i;let o=this.ut??(this.ut=[]),l=[],c,d,m=0,g=r.length-1,v=0,E=i.length-1;for(;m<=g&&v<=E;)if(r[m]===null)m++;else if(r[g]===null)g--;else if(o[m]===a[v])l[v]=ee(r[m],i[v]),m++,v++;else if(o[g]===a[E])l[E]=ee(r[g],i[E]),g--,E--;else if(o[m]===a[E])l[E]=ee(r[m],i[E]),me(p,l[E+1],r[m]),m++,E--;else if(o[g]===a[v])l[v]=ee(r[g],i[v]),me(p,r[m],r[g]),g--,v++;else if(c===void 0&&(c=Kt(a,v,E),d=Kt(o,m,g)),c.has(o[m]))if(c.has(o[g])){let R=d.get(a[v]),I=R!==void 0?r[R]:null;if(I===null){let w=me(p,r[m]);ee(w,i[v]),l[v]=w}else l[v]=ee(I,i[v]),me(p,r[m],I),r[R]=null;v++}else Ye(r[g]),g--;else Ye(r[m]),m++;for(;v<=E;){let R=me(p,l[E+1]);ee(R,i[v]),l[v++]=R}for(;m<=g;){let R=r[m++];R!==null&&Ye(R)}return this.ut=a,zt(p,l),pe}});function ie(p,s,e,t){let r=e.getAttribute("width")?parseFloat(e.getAttribute("width")):e.naturalWidth,i=e.getAttribute("height")?parseFloat(e.getAttribute("height")):e.naturalHeight;switch(p){case"circle":{if(s.length!==3){console.error("Invalid cirlce coordinates:",s);return}let[a,o,l]=s,c=a/r*100,d=o/i*100,m=l/r*100;t.style.left=c-m+"%",t.style.top=d-m+"%";let g=l/r*100,v=l/i*100;t.style.width=2*g+"%",t.style.height=2*v+"%",t.style.borderRadius="50%"}break;case"rect":{if(s.length!==4){console.error("Invalid rectangle coordinates:",s);return}let[a,o,l,c]=s,d=a/r*100,m=o/i*100,g=l/r*100,v=c/i*100;t.style.left=d+"%",t.style.top=m+"%",t.style.width=g-d+"%",t.style.height=v-m+"%"}break;case"ellipse":{if(s.length!==4){console.error("Invalid ellipse coordinates:",s);return}let[a,o,l,c]=s,d=a/r*100,m=o/i*100,g=l/r*100,v=c/i*100;t.style.left=d-g+"%",t.style.top=m-v+"%",t.style.width=2*g+"%",t.style.height=2*v+"%",t.style.borderRadius="50%"}break;case"poly":{if(s.length<6||s.length%2!==0){console.error("Invalid polygon coordinates:",s);return}let a=[];for(let w=0;w<s.length;w+=2)a.push({x:s[w],y:s[w+1]});let o=Math.min(...a.map(w=>w.x)),l=Math.max(...a.map(w=>w.x)),c=Math.min(...a.map(w=>w.y)),d=Math.max(...a.map(w=>w.y)),m=o/r*100,g=c/i*100,v=l/r*100,E=d/i*100;t.style.left=m+"%",t.style.top=g+"%",t.style.width=v-m+"%",t.style.height=E-g+"%";let I=a.map(w=>({x:(w.x-o)/(l-o)*100,y:(w.y-c)/(d-c)*100})).map(w=>`${w.x}% ${w.y}%`).join(",");t.style.clipPath=`polygon(${I})`}break;default:console.error(`Unsupported shape: ${p}`);break}}var Zt=b`
276
+ slot:not([name='prompt']) {
277
+ // position: relative; /* qti-hotspot-choice relative to the slot */
278
+ display: block;
279
+ width: fit-content; /* hotspots not stretching further if image is at max size */
280
+ }
281
+ ::slotted(img) {
282
+ /* image not selectable anymore */
283
+ pointer-events: none;
284
+ user-select: none;
285
+ }
286
+ ::slotted(qti-associable-hotspot) {
287
+ transform: translate(-50%, -50%);
288
+ }
289
+ line-container {
290
+ display: block;
291
+ position: relative;
292
+ width: fit-content;
293
+ }
294
+ svg {
295
+ position: absolute;
296
+ top: 0px;
297
+ left: 0px;
298
+ }
299
+ `;var z=class extends C{constructor(){super();this.startPoint=null;this.endPoint=null;this._correctLines=[];this._response=[];this.addEventListener("qti-register-hotspot",this.positionHotspotOnRegister)}reset(){this._response=[],this._correctLines=[]}validate(){return this.response.length>0}set response(e){this._response=e}get response(){return this._response}toggleCorrectResponse(e,t){if(!t){this._correctLines=[];return}if(!e.correctResponse){console.error("No correct response found for this interaction.");return}let r=Array.isArray(e.correctResponse)?e.correctResponse:[e.correctResponse];this._correctLines=r}render(){return h`<slot name="prompt"></slot>
300
+ <line-container>
301
+ <svg
302
+ width=${O(this.grImage[0]?.width)}
303
+ height=${O(this.grImage[0]?.height)}
304
+ viewbox="0 0 ${this.grImage[0]?.width} ${this.grImage[0]?.height}"
305
+ >
306
+ ${Ee(this.response||[],e=>e,(e,t)=>Je`
307
+ <line
308
+ part="line"
309
+ x1=${parseInt(this.querySelector(`[identifier=${e.split(" ")[0]}]`).style.left)}
310
+ y1=${parseInt(this.querySelector(`[identifier=${e.split(" ")[0]}]`).style.top)}
311
+ x2=${parseInt(this.querySelector(`[identifier=${e.split(" ")[1]}]`).style.left)}
312
+ y2=${parseInt(this.querySelector(`[identifier=${e.split(" ")[1]}]`).style.top)}
313
+ stroke="red"
314
+ stroke-width="3"
315
+ @click=${r=>{r.stopPropagation(),this._response=this._response.filter((i,a)=>a!==t),this.saveResponse(this.response)}}
316
+ />
317
+ `)}
318
+ ${Ee(this._correctLines||[],e=>e,(e,t)=>Je`
319
+ <line
320
+ part="correct-line"
321
+ x1=${parseInt(this.querySelector(`[identifier=${e.split(" ")[0]}]`).style.left)}
322
+ y1=${parseInt(this.querySelector(`[identifier=${e.split(" ")[0]}]`).style.top)}
323
+ x2=${parseInt(this.querySelector(`[identifier=${e.split(" ")[1]}]`).style.left)}
324
+ y2=${parseInt(this.querySelector(`[identifier=${e.split(" ")[1]}]`).style.top)}
325
+ stroke="var(--qti-correct)"
326
+ stroke-width="3"
327
+ stroke-dasharray="5,5"
328
+ />
329
+ `)}
330
+ ${this.startPoint&&Je`<line
331
+ part="point"
332
+ x1=${this.startCoord.x}
333
+ y1=${this.startCoord.y}
334
+ x2=${this.mouseCoord.x}
335
+ y2=${this.mouseCoord.y}
336
+ stroke="var(--qti-border-active)"
337
+ stroke-width="3"
338
+ />`}
339
+ </svg>
340
+ <slot></slot>
341
+ </line-container>
342
+ <div role="alert" id="validationMessage"></div>`}positionHotspotOnRegister(e){let t=this.querySelector("img"),r=e.target,i=r.getAttribute("coords"),a=r.getAttribute("shape"),o=i.split(",").map(l=>parseInt(l));ie(a,o,t,r)}firstUpdated(){this.hotspots=this.querySelectorAll("qti-associable-hotspot"),this.addEventListener("mousemove",e=>{let t=this.grImage[0];if(!t)return;let r=t.getBoundingClientRect();this.mouseCoord={x:e.clientX-r.left,y:e.clientY-r.top}}),this.hotspots.forEach(e=>{e.style.left=e.getAttribute("coords").split(",")[0]+"px",e.style.top=e.getAttribute("coords").split(",")[1]+"px",e.addEventListener("click",t=>{this.startPoint?this.endPoint||(this.endPoint=t.target,this._response=[...this.response,`${this.startPoint.getAttribute("identifier")} ${this.endPoint.getAttribute("identifier")}`],this.saveResponse(this.response),this.startPoint=null,this.endPoint=null):(this.startPoint=t.target,this.startCoord={x:parseInt(this.startPoint.getAttribute("coords").split(",")[0]),y:parseInt(this.startPoint.getAttribute("coords").split(",")[1])})})})}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-register-hotspot",this.positionHotspotOnRegister)}};z.styles=Zt,n([x()],z.prototype,"_correctLines",2),n([x()],z.prototype,"startCoord",2),n([x()],z.prototype,"mouseCoord",2),n([Ot({selector:"img"})],z.prototype,"grImage",2),n([x()],z.prototype,"_response",2),z=n([f("qti-graphic-associate-interaction")],z);var Qt=b`
343
+ :host {
344
+ display: flex;
345
+ align-items: flex-start;
346
+ flex-direction: column;
347
+ flex-wrap: wrap;
348
+ gap: 0.5rem;
349
+ }
350
+
351
+ :host(.qti-choices-top) {
352
+ flex-direction: column-reverse;
353
+ }
354
+ :host(.qti-choices-bottom) {
355
+ flex-direction: column;
356
+ }
357
+ :host(.qti-choices-left) {
358
+ flex-direction: row-reverse;
359
+ & [name='drags'] {
360
+ width: 25%;
361
+ }
362
+ & [part='image'] {
363
+ width: 75%;
364
+ }
365
+ }
366
+ :host(.qti-choices-right) {
367
+ flex-direction: row;
368
+ & [name='drags'] {
369
+ width: 25%;
370
+ }
371
+ & [part='image'] {
372
+ width: 75%;
373
+ }
374
+ }
375
+ [part='image'] {
376
+ display: block;
377
+ position: relative;
378
+ }
379
+ /* [part='drops'] , */
380
+
381
+ [name='drags'] {
382
+ display: flex;
383
+ align-items: flex-start;
384
+ flex-wrap: wrap;
385
+ flex: 1;
386
+ border: 2px solid transparent;
387
+ padding: 0.3rem;
388
+ border-radius: 0.3rem;
389
+ gap: 0.5rem;
390
+ }
391
+ ::slotted(img) {
392
+ display: inline-block;
393
+ user-select: none;
394
+ pointer-events: none;
395
+ }
396
+ `;var ke=class extends H(C,"qti-gap-img, qti-gap-text","qti-associable-hotspot","slot[part='drags']"){render(){return h` <slot name="prompt"></slot>
397
+ <slot part="image"></slot>
398
+ <slot part="drags" name="drags" class="hover-border"></slot>
399
+ <div role="alert" id="validationMessage"></div>`}positionHotspotOnRegister(s){let e=s.target,t=e.getAttribute("coords"),r=e.getAttribute("shape"),i=t.split(",").map(a=>parseInt(a));switch(r){case"circle":{let[a,o,l]=i;e.style.left=a-l+"px",e.style.top=o-l+"px",e.style.width=e.style.height=2*l+"px"}break;case"rect":{let[a,o,l,c]=i;e.style.left=a+"px",e.style.top=o+"px",e.style.width=l-a+"px",e.style.height=c-o+"px"}break;default:break}}connectedCallback(){super.connectedCallback(),this.addEventListener("qti-register-hotspot",this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-register-hotspot",this.positionHotspotOnRegister)}};ke.styles=Qt,ke=n([f("qti-graphic-gap-match-interaction")],ke);var er=b`
400
+ slot:not([name='prompt']) {
401
+ position: relative; /* qti-hotspot-choice relative to the slot */
402
+ display: block;
403
+ width: fit-content; /* hotspots not stretching further if image is at max size */
404
+ }
405
+ ::slotted(img) {
406
+ /* image not selectable anymore */
407
+ pointer-events: none;
408
+ user-select: none;
409
+ }
410
+ `;var Ae=class extends te(C,"qti-hotspot-choice"){constructor(){super(...arguments);this._choiceElements=[]}render(){return h`
411
+ <slot name="prompt"></slot>
412
+ <slot></slot>
413
+ <div role="alert" id="validationMessage"></div>
414
+ `}setHotspotOrder(e){let{identifier:t}=e.detail,r=this._choiceElements.find(a=>a.getAttribute("identifier")===t);if(!r)return;let i=this._choiceElements.length;if(!this.choiceOrdering){if(this.choiceOrdering=!0,r.order==null){let a=this._choiceElements.filter(o=>o.order!=null).length;if(a>=i){this.choiceOrdering=!1;return}r.order=a+1}else{let a=r.order;r.order=null,this._choiceElements.forEach(o=>{o.order!=null&&o.order>a&&o.order--})}this.choiceOrdering=!1}}toggleCorrectResponse(e,t){let r=this._choiceElements;for(let i of r)if(t&&e.correctResponse?.length>0&&Array.isArray(e.correctResponse)){let a=e.correctResponse.findIndex(o=>o===i.identifier);a>=0?i.orderCorrect=a+1:i.orderCorrect=null}else i.orderCorrect=null}positionHotspotOnRegister(e){let t=this.querySelector("img"),r=e.target,i=r.getAttribute("coords"),a=r.getAttribute("shape"),o=i.split(",").map(l=>parseInt(l));ie(a,o,t,r)}connectedCallback(){super.connectedCallback(),this.addEventListener("activate-qti-hotspot-choice",this.setHotspotOrder),this.addEventListener("register-qti-hotspot-choice",this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("activate-qti-hotspot-choice",this.setHotspotOrder),this.removeEventListener("register-qti-hotspot-choice",this.positionHotspotOnRegister)}};Ae.styles=er,Ae=n([f("qti-graphic-order-interaction")],Ae);var le=class extends P(y,"qti-hotspot-choice"){};le.styles=b`
415
+ :host {
416
+ display: flex;
417
+ user-select: none;
418
+ position: absolute;
419
+ }
420
+ `,n([u({attribute:"aria-ordervalue",type:Number,reflect:!0})],le.prototype,"order",2),n([u({attribute:"aria-ordercorrectvalue",type:Number,reflect:!0})],le.prototype,"orderCorrect",2),le=n([f("qti-hotspot-choice")],le);var tr=b`
421
+ slot:not([name='prompt']) {
422
+ position: relative; /* qti-hotspot-choice relative to the slot */
423
+ display: block;
424
+ width: fit-content; /* hotspots not stretching further if image is at max size */
425
+ }
426
+ ::slotted(img) {
427
+ /* image not selectable anymore */
428
+ pointer-events: none;
429
+ user-select: none;
430
+ /* width:100%; */
431
+ }
432
+ `;var Le=class extends te(C,"qti-hotspot-choice"){render(){return h`
433
+ <slot name="prompt"></slot>
434
+ <slot></slot>
435
+ `}positionHotspotOnRegister(s){let e=this.querySelector("img"),t=s.target,r=t.getAttribute("coords"),i=t.getAttribute("shape"),a=r.split(",").map(o=>parseInt(o));ie(i,a,e,t)}connectedCallback(){super.connectedCallback(),this.addEventListener("register-qti-hotspot-choice",this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("unregister-qti-hotspot-choice",this.positionHotspotOnRegister)}};Le.styles=tr,Le=n([f("qti-hotspot-interaction")],Le);var Ge=class extends te(C,"qti-hottext"){constructor(){super(...arguments);this.render=()=>h` <slot></slot>
436
+ <div part="message" role="alert" id="validationMessage"></div>`}};Ge=n([f("qti-hottext-interaction")],Ge);var Ie=class extends P(y,"qti-hottext"){render(){return h`<div part="ch"><div part="cha"></div></div>
437
+ <slot></slot> `}};Ie.styles=b`
438
+ :host {
439
+ display: flex;
440
+ user-select: none;
441
+ }
442
+ `,Ie=n([f("qti-hottext")],Ie);var De=class extends he{constructor(s){if(super(s),this.it=k,s.type!==ue.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(s){if(s===k||s==null)return this._t=void 0,this.it=s;if(s===pe)return s;if(typeof s!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(s===this.it)return this._t;this.it=s;let e=[s];return e.raw=e,this._t={_$litType$:this.constructor.resultType,strings:e,values:[]}}};De.directiveName="unsafeHTML",De.resultType=1;var Ce=Q(De);var se=class extends C{constructor(){super(...arguments);this.options=[];this.correctOption="";this.dataPrompt="select"}static get styles(){return[b`
443
+ :host {
444
+ display: inline-block;
445
+ }
446
+ slot {
447
+ display: flex;
448
+ flex-direction: column;
449
+ }
450
+ [role='menu'] {
451
+ position: absolute;
452
+ z-index: 1000;
453
+ }
454
+ .anchor {
455
+ /* anchor-name: --infobox; */
456
+ width: fit-content;
457
+ }
458
+
459
+ .positionedElement {
460
+ position: absolute;
461
+ /* position-anchor: --infobox; */
462
+ /* top: anchor(bottom); */
463
+ }
464
+ `]}render(){return h`
465
+ <select part="select" @change="${this.choiceSelected}" ?disabled="${this.disabled}" ?readonly="${this.readonly}">
466
+ ${this.options.map(e=>h`
467
+ <option value="${e.value}" ?selected="${e.selected}">${Ce(e.textContent)}</option>
468
+ `)}
469
+ </select>
470
+
471
+ ${Ce(this.correctOption)}
472
+ `}connectedCallback(){super.connectedCallback(),this.addEventListener("on-dropdown-selected",this.choiceSelected);let e=Array.from(this.querySelectorAll("qti-inline-choice"));this.options=[{textContent:this.dataPrompt,value:"",selected:!1},...e.map(t=>({textContent:t.innerHTML,value:t.getAttribute("identifier"),selected:!1}))]}disconnectedCallback(){this.removeEventListener("on-dropdown-selected",this.choiceSelected)}validate(){let e=this.options.find(t=>t.selected);return e?e.value!=="":!1}reset(){this.options=this.options.map((e,t)=>({...e,selected:t===0}))}set response(e){this.options=this.options.map(t=>(e&&e===t.value&&(t.selected=!0),t))}get response(){return this.options.find(e=>e.selected)?.value||null}toggleCorrectResponse(e,t){if(this.correctResponse=t&&e.correctResponse?.toString(),!this.correctResponse){this.correctOption="";return}this.correctOption=`<span part="correct-option" style="border:1px solid var(--qti-correct); border-radius:4px; padding: 2px 4px; margin: 4px; display:inline-block">${this.options.find(r=>this.correctResponse===r.value).textContent}</span>`}choiceSelected(e){let t=e.target.value;this.options=this.options.map(r=>({...r,selected:r.value===t})),this.saveResponse(t)}};se.inputWidthClass=["","qti-input-width-2","qti-input-width-1","qti-input-width-3","qti-input-width-4","qti-input-width-6","qti-input-width-10","qti-input-width-15","qti-input-width-20","qti-input-width-72"],n([x()],se.prototype,"options",2),n([x()],se.prototype,"correctOption",2),n([u({attribute:"data-prompt",type:String})],se.prototype,"dataPrompt",2),se=n([f("qti-inline-choice-interaction")],se);var Ve=class extends y{static get styles(){return[b`
473
+ :host {
474
+ display: block;
475
+ cursor: pointer;
476
+ }
477
+ `]}connectedCallback(){super.connectedCallback(),this.addEventListener("click",this._onSelectInlineChoice),this.dispatchEvent(new CustomEvent("qti-inline-choice-register",{bubbles:!0,composed:!0,cancelable:!1}))}disconnectedCallback(){this.removeEventListener("click",this._onSelectInlineChoice)}render(){return h` <slot></slot> `}_onSelectInlineChoice(){this.dispatchEvent(new CustomEvent("qti-inline-choice-select",{bubbles:!0,cancelable:!1,composed:!0,detail:{identifier:this.identifier}}))}};n([u({type:String})],Ve.prototype,"identifier",2),Ve=n([f("qti-inline-choice")],Ve);var oe=class extends P(y,"qti-simple-associable-choice"){constructor(){super(...arguments);this.matchMin=0;this.matchMax=1;this.fixed=!1}connectedCallback(){super.connectedCallback(),this.setAttribute("slot","qti-simple-associable-choice"),this.setAttribute("part","qti-simple-associable-choice")}render(){return h`
478
+ <slot part="slot"></slot>
479
+ <slot part="dropslot" name="qti-simple-associable-choice"></slot>
480
+ `}};oe.styles=b`
481
+ :host {
482
+ display: flex;
483
+ user-select: none;
484
+ }
485
+ slot {
486
+ width: 100%;
487
+ display: block;
488
+ }
489
+ slot[name='qti-simple-associable-choice'] {
490
+ /* width: 100%; */
491
+ }
492
+ `,n([u({type:Number,attribute:"match-min"})],oe.prototype,"matchMin",2),n([u({type:Number,attribute:"match-max"})],oe.prototype,"matchMax",2),n([u({type:String,attribute:"fixed",converter:{fromAttribute:e=>e==="true",toAttribute:e=>String(e)}})],oe.prototype,"fixed",2),oe=n([f("qti-simple-associable-choice")],oe);var rr=b`
493
+ slot:not([hidden]) {
494
+ /* slot where the */
495
+ display: flex;
496
+ flex-direction: column;
497
+ gap: 0.5rem;
498
+ align-items: flex-start; /* prevents the drag and drop container slots having the same height */
499
+ }
500
+ :host(.qti-choices-top) slot {
501
+ flex-direction: column;
502
+ }
503
+ :host(.qti-choices-bottom) slot {
504
+ flex-direction: column-reverse;
505
+ }
506
+ :host(.qti-choices-left) slot {
507
+ flex-direction: row;
508
+ }
509
+ :host(.qti-choices-right) slot {
510
+ flex-direction: row-reverse;
511
+ }
512
+ slot[name='prompt'] {
513
+ display: block;
514
+ }
515
+ ::slotted(qti-simple-match-set) {
516
+ /* Make sure the drag and drop container slots have the same width */
517
+ flex: 1;
518
+ }
519
+ `;var J=class extends H(C,"qti-simple-match-set:first-of-type qti-simple-associable-choice, qti-simple-match-set:last-of-type > qti-simple-associable-choice > qti-simple-associable-choice","qti-simple-match-set:last-of-type > qti-simple-associable-choice","qti-simple-match-set:first-of-type"){constructor(){super(...arguments);this.lastCheckedRadio=null;this.class="";this._response=[];this.responseIdentifier="";this.correctOptions=[];this.handleRadioClick=e=>{let t=e.target;this.lastCheckedRadio===t?(t.checked=!1,this.lastCheckedRadio=null,this.handleRadioChange(e)):this.lastCheckedRadio=t};this.handleRadioChange=e=>{let t=e.target,r=t.value,i=t.name,a=t.type;t.checked?(this.response?this.response.indexOf(r)===-1&&(a==="radio"&&(this.response=this.response.filter(o=>o.indexOf(i)===-1)),this.response=[...this.response,r]):this.response=[r],this.lastCheckedRadio=t):(this.response=this.response.filter(o=>o!==r),this.lastCheckedRadio=null),this.requestUpdate(),this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,composed:!0,detail:{responseIdentifier:this.responseIdentifier,response:Array.isArray(this.response)?[...this.response]:this.response}}))}}get response(){return this.classList.contains("qti-match-tabular")?this._response:super.response}set response(e){this.classList.contains("qti-match-tabular")?this._response=e:super.response=e}async connectedCallback(){super.connectedCallback(),this.rows=Array.from(this.querySelectorAll("qti-simple-match-set:first-of-type qti-simple-associable-choice")),this.cols=Array.from(this.querySelectorAll("qti-simple-match-set:last-of-type qti-simple-associable-choice")),this.response=[]}validate(){return this.class.split(" ").includes("qti-match-tabular")?this.response?.length===this.rows.length:super.validate()}toggleCorrectResponse(e,t){if(e.correctResponse){let i=(Array.isArray(e.correctResponse)?e.correctResponse:[e.correctResponse]).map(a=>{let[o,l]=a.split(" ");return{text:o,gap:l}});this.class.split(" ").includes("qti-match-tabular")?t?this.correctOptions=i:this.correctOptions=null:t&&(this.querySelectorAll(".correct-option").forEach(a=>a.remove()),this.cols.forEach(a=>{let o=a.getAttribute("identifier"),l=i.find(c=>c.gap===o);if(l?.text){let d=this.querySelector(`qti-simple-associable-choice[identifier="${l.text}"]`)?.textContent?.trim();if(d&&!a.previousElementSibling?.classList.contains("correct-option")){let m=document.createElement("span");m.classList.add("correct-option"),m.textContent=d,m.style.border="1px solid var(--qti-correct)",m.style.borderRadius="4px",m.style.padding="2px 4px",m.style.display="inline-block",a.insertAdjacentElement("beforebegin",m)}}}))}else this.querySelectorAll(".correct-option").forEach(r=>r.remove())}render(){let e=this.class.split(" ").includes("qti-match-tabular");return h`
520
+ <slot name="prompt"></slot>
521
+ <slot ?hidden=${e}></slot>
522
+
523
+ ${e?h`
524
+ <table part="table">
525
+ <tr part="r-header">
526
+ <td></td>
527
+ ${this.cols.map(t=>h`<th part="r-header">${Ce(t.innerHTML)}</th>`)}
528
+ </tr>
529
+
530
+ ${this.rows.map(t=>h`<tr part="row">
531
+ <td part="c-header">${Ce(t.innerHTML)}</td>
532
+ ${this.cols.map(r=>{let i=t.getAttribute("identifier"),a=r.getAttribute("identifier"),o=`${i} ${a}`,l=this.response.filter(E=>E.split(" ")[0]===i).length||0,c=this.response.includes(o),d=t.matchMax===1?"radio":"checkbox",m=!!this.correctOptions?.find(E=>E.text===i&&E.gap===a),g=d==="radio"?`rb ${c?"rb-checked":""} ${this.correctOptions?m?"rb-correct":"rb-incorrect":""}`:`cb ${c?"cb-checked":""} ${this.correctOptions?m?"cb-correct":"cb-incorrect":""}`,v=this.correctOptions?.length>0?!0:t.matchMax===1?!1:t.matchMax!==0&&l>=t.matchMax&&!c;return h`<td part="input-cell">
533
+ <div
534
+ class="input-container"
535
+ style="position: relative; width: 24px; height: 24px; margin: 0 auto;"
536
+ >
537
+ <input
538
+ type=${d}
539
+ part=${g}
540
+ name=${i}
541
+ value=${o}
542
+ .disabled=${v}
543
+ @change=${E=>this.handleRadioChange(E)}
544
+ @click=${E=>t.matchMax===1?this.handleRadioClick(E):null}
545
+ />
546
+ ${d==="checkbox"&&c?h`
547
+ <svg
548
+ part="checkmark"
549
+ viewBox="0 0 24 24"
550
+ style="position: absolute; width: 20px; height: 20px; top: 2px; left: 2px; pointer-events: none;"
551
+ >
552
+ <path d="M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41L9 16.17z" fill="white" />
553
+ </svg>
554
+ `:""}
555
+ </div>
556
+ </td>`})}
557
+ </tr>`)}
558
+ </table>
559
+ `:k}
560
+
561
+ <div role="alert" id="validationMessage"></div>
562
+ `}};J.styles=rr,n([u({type:String})],J.prototype,"class",2),n([x()],J.prototype,"_response",2),n([u({type:String,attribute:"response-identifier"})],J.prototype,"responseIdentifier",2),n([x()],J.prototype,"correctOptions",2),J=n([f("qti-match-interaction")],J);var $e=class extends C{constructor(){super();this._value=null}reset(){}validate(){return!0}get response(){return this._value?this._value.toString():null}set response(e){if(e)if(!isNaN(parseInt(e?.toString())))this._value=parseInt(e.toString());else throw new Error(`Value must be a number ${e}`)}static get properties(){return{...C.properties,step:{type:Number,attribute:"step",default:10}}}render(){return h` <slot name="prompt"></slot>
563
+ <slot></slot>`}connectedCallback(){super.connectedCallback();let e=this.querySelector("audio")||this.querySelector("video")||this.querySelector("object");e&&e.addEventListener("ended",()=>{this._value++,this.saveResponse(this.value)})}};$e.styles=[b``],$e=n([f("qti-media-interaction")],$e);var ir=b`
564
+ [part='drags'] {
565
+ display: flex;
566
+ align-items: flex-start;
567
+ flex: 1;
568
+ flex-wrap: wrap;
569
+ }
570
+
571
+ [part='drops'] {
572
+ flex: 1;
573
+ display: grid;
574
+ grid-auto-flow: column;
575
+ grid-auto-columns: 1fr;
576
+ }
577
+
578
+ :host([orientation='horizontal']) [part='drags'] {
579
+ flex-direction: row;
580
+ }
581
+ :host([orientation='horizontal']) [part='drops'] {
582
+ grid-auto-flow: column;
583
+ }
584
+ :host([orientation='vertical']) [part='drags'] {
585
+ flex-direction: column;
586
+ }
587
+ :host([orientation='vertical']) [part='drops'] {
588
+ grid-auto-flow: row;
589
+ }
590
+
591
+ [part='drop-list'] {
592
+ display: block;
593
+ flex: 1;
594
+ }
595
+
596
+ [part='container'] {
597
+ display: flex;
598
+ gap: 0.5rem;
599
+ }
600
+ :host(.qti-choices-top) [part='container'] {
601
+ flex-direction: column;
602
+ }
603
+ :host(.qti-choices-bottom) [part='container'] {
604
+ flex-direction: column-reverse;
605
+ }
606
+ :host(.qti-choices-left) [part='container'] {
607
+ flex-direction: row;
608
+ }
609
+ :host(.qti-choices-right) [part='container'] {
610
+ flex-direction: row-reverse;
611
+ }
612
+ `;var X=class extends H(C,"qti-simple-choice","drop-list","slot[part='drags']"){constructor(){super(...arguments);this.nrChoices=0;this.correctResponses=[];this.showCorrectResponses=!1}render(){let e=Array.from(this.querySelectorAll("qti-simple-choice"));return this.nrChoices<e.length&&(this.nrChoices=e.length),h` <slot name="prompt"> </slot>
613
+ <div part="container">
614
+ <slot part="drags"> </slot>
615
+ <div part="drops">
616
+ ${[...Array(this.nrChoices)].map((t,r)=>h`<drop-list role="region" part="drop-list" identifier="droplist${r}"></drop-list>`)}
617
+ </div>
618
+ </div>`}toggleCorrectResponse(e,t){if(this.shadowRoot.querySelectorAll(".correct-option").forEach(r=>r.remove()),t&&e.correctResponse){let i=(Array.isArray(e.correctResponse)?e.correctResponse:[e.correctResponse]).map(l=>l.split(" ")[0]),a=new Set;this.querySelectorAll("qti-simple-choice").forEach((l,c)=>{let d=l.getAttribute("identifier");if(!d||!i.includes(d)||a.has(d))return;a.add(d);let m=l.textContent?.trim();if(!m)return;let g=this.shadowRoot.querySelector(`drop-list[identifier="droplist${c}"]`);if(!g)return;let v=document.createElement("span");v.classList.add("correct-option"),v.textContent=m,v.style.border="1px solid var(--qti-correct)",v.style.borderRadius="4px",v.style.padding="2px 4px",v.style.display="inline-block",v.style.marginTop="4px",g.insertAdjacentElement("afterend",v)})}}getValue(e){return e?.map((t,r)=>`${t} droplist${r}`)||[]}getResponse(){return Array.from(this.shadowRoot.querySelectorAll("drop-list")).map(r=>{let i=r.querySelectorAll('[qti-draggable="true"]');return[...Array.from(i).map(o=>o.getAttribute("identifier"))].join(" ")})}async firstUpdated(e){super.firstUpdated(e),this.childrenMap=Array.from(this.querySelectorAll("qti-simple-choice")),this.childrenMap.forEach(t=>t.setAttribute("part","qti-simple-choice"))}};X.styles=ir,n([x()],X.prototype,"nrChoices",2),n([x()],X.prototype,"correctResponses",2),n([x()],X.prototype,"showCorrectResponses",2),n([u({type:String})],X.prototype,"orientation",2),X=n([f("qti-order-interaction")],X);var sr=b`
619
+ ::slotted(qti-interaction-markup) {
620
+ display: none;
621
+ }
622
+ `;var M=class extends C{constructor(){super(...arguments);this._iframeLoaded=!1;this._pendingMessages=[];this._responseCheckInterval=null;this._lastResponseStr="";this.requirePathsJson="";this.requireShimJson="";this.requireJsUrl="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js";this.baseUrl="";this.useIframe=!1;this.useDefaultShims=!1;this.useDefaultPaths=!1;this._errorMessage=null;this.response=[];this._parsedRequirePaths=null;this._parsedRequireShim=null;this.handleIframeMessage=e=>{let{data:t}=e;if(!(!t||t.source!=="qti-pci-iframe"))switch(t.method){case"iframeReady":this.initializeInteraction(),this.processPendingMessages(),this.dispatchEvent(new CustomEvent("qti-portable-custom-interaction-loaded",{bubbles:!0}));break;case"resize":typeof t.height=="number"&&this.iframe&&(this.iframe.style.height=`${t.height}px`,this.iframe.style.width=`${t.width}px`);break;case"interactionChanged":{let r=this.convertQtiVariableJSON(t.params.value);console.log("Interaction changed:",r),this.response=r,this.validate(),this.saveResponse(this.response);break}case"error":this._errorMessage=t.params.message,console.error("Error from PCI iframe:",t.params.message);break}};this._onInteractionChanged=e=>{e.stopPropagation();let t=this.convertQtiVariableJSON(e.detail.value);this.response=t,this.saveResponse(t)};this.loadConfig=async(e,t)=>{e=this.removeDoubleSlashes(e);try{let r=await fetch(e);if(r.ok){let a=await r.json();for(let o in a.paths)t&&(a.paths[o]=this.getResolvablePath(a.paths[o],t));return a}}catch{}return null};this.getResolvablePathString=(e,t)=>(e=e.replace(/\.js$/,""),e?.toLocaleLowerCase().startsWith("http")||!t?e:this.removeDoubleSlashes(`${t}/${e}`));this.getResolvablePath=(e,t)=>Array.isArray(e)?e.map(r=>this.getResolvablePathString(r,t)):this.getResolvablePathString(e,t);this._previousState=null}getRequirePaths(){if(this._parsedRequirePaths===null&&this.requirePathsJson)try{let e=JSON.parse(this.requirePathsJson);Array.isArray(e)?(this._parsedRequirePaths={},e.forEach(t=>{t.name&&t.value&&(this._parsedRequirePaths[t.name]=t.value)})):this._parsedRequirePaths=e}catch(e){console.error("Error parsing require paths JSON:",e),this._errorMessage=`Error parsing require paths JSON: ${e.message}`,this._parsedRequirePaths={}}return this._parsedRequirePaths||{}}getRequireShim(){if(this._parsedRequireShim===null&&this.requireShimJson)try{this._parsedRequireShim=JSON.parse(this.requireShimJson)}catch(e){console.error("Error parsing require shim JSON:",e),this._errorMessage=`Error parsing require shim JSON: ${e.message}`,this._parsedRequireShim={}}return this._parsedRequireShim||{}}getDefaultRequirePaths(){return{"taoQtiItem/portableLib/OAT/util/event":"/assets/pci-scripts/portableLib/OAT/util/event","taoQtiItem/portableLib/OAT/util/html":"/assets/pci-scripts/portableLib/OAT/util/html","taoQtiItem/portableLib/OAT/util/EventMgr":"/assets/pci-scripts/portableLib/OAT/util/EventMgr","taoQtiItem/portableLib/OAT/util/math":"/assets/pci-scripts/portableLib/OAT/util/math","taoQtiItem/portableLib/OAT/util/xml":"/assets/pci-scripts/portableLib/OAT/util/xml","taoQtiItem/portableLib/OAT/util/tooltip":"/assets/pci-scripts/portableLib/OAT/util/tooltip","taoQtiItem/portableLib/jquery_2_1_1":"/assets/pci-scripts/portableLib/jquery_2_1_1","taoQtiItem/pci-scripts/portableLib/jquery.qtip":"/assets/portableLib/jquery.qtip","taoQtiItem/pci-scripts/portableLib/lodash":"/assets/pci-scripts/portableLib/lodash","taoQtiItem/pci-scripts/portableLib/raphael":"/assets/pci-scripts/portableLib/raphael","IMSGlobal/jquery_2_1_1":"/assets/pci-scripts/IMSGlobal/jquery_2_1_1","OAT/util/event":"/assets/pci-scripts/legacyPortableSharedLib/OAT/util/event","OAT/util/html":"/assets/pci-scripts/legacyPortableSharedLib/OAT/util/html","OAT/util/EventMgr":"/assets/pci-scripts/legacyPortableSharedLib/OAT/util/EventMgr","OAT/util/math":"/assets/pci-scripts/legacyPortableSharedLib/OAT/util/math","OAT/util/xml":"/assets/pci-scripts/legacyPortableSharedLib/OAT/util/xml","OAT/util/tooltip":"/assets/pci-scripts/legacyPortableSharedLib/OAT/util/tooltip","OAT/lodash":"/assets/pci-scripts/legacyPortableSharedLib/lodash",mathJax:"/assets/pci-scripts/mathjax/mathJax",css:"/assets/pci-scripts/css/css"}}getDefaultRequireShim(){return{mathJax:{exports:"MathJax",init:function(){let e=window;if(e.MathJax)return e.MathJax.Hub.Config({showMathMenu:!1,showMathMenuMSIE:!1,menuSettings:{inTabOrder:!1}}),e.MathJax.Hub.Startup.MenuZoom=function(){},e.MathJax.Hub.Startup.onload(),e.MathJax}}}}getFinalRequirePaths(){let e=this.getDefaultRequirePaths(),t=this.getRequirePaths();return this.useDefaultPaths?{...e,...t}:t}getFinalRequireShim(){let e=this.getRequireShim(),t=this.getDefaultRequireShim();return this.useDefaultShims?{...t,...e}:e}convertQtiVariableJSON(e){for(let t in e)if(e.hasOwnProperty(t)){let r=e[t];if(r){for(let i in r)if(r.hasOwnProperty(i)){let a=r[i];if(Array.isArray(a))return a.map(String);if(a!=null)return String(a)}}}return null}addHyphenatedKeys(e){let t={...e};for(let r in e)if(Object.prototype.hasOwnProperty.call(e,r)){let i=r.replace(/[A-Z]/g,a=>`-${a.toLowerCase()}`);t[i]=e[r]}return t}responseVariablesToQtiVariableJSON(e,t,r){if(t!=="single"){let i={list:{}};return i.list[r]=e,i}else{let i={base:{}};return i.base[r]=e,i}}validate(){return!0}set value(e){e===null?this._value=[]:this._value=Array.isArray(e)?e:e.split(",")}get value(){if(this.useIframe)return this._value?.toString()||null;{let e=this.pci?.getResponse();if(e){let t=this.convertQtiVariableJSON(e);return Array.isArray(t)?t.join(","):t}}return Array.isArray(this._value)?this._value.join(","):this._value?.toString()||null}set boundTo(e){if(!e||!e[this.responseIdentifier])return;let t=this.convertQtiVariableJSON(e[this.responseIdentifier]);this._value=t,this.saveResponse(t)}get boundTo(){let e={};if(this.context?.variables?.find(r=>r.identifier===this.responseIdentifier)){let r=this.context?.variables?.find(l=>l.identifier===this.responseIdentifier)?.cardinality||"single",i=this.context?.variables?.find(l=>l.identifier===this.responseIdentifier)?.baseType||"string",a=this.context?.variables?.find(l=>l.identifier===this.responseIdentifier)?.value||null,o=this.responseVariablesToQtiVariableJSON(a,r,i);e[this.responseIdentifier]=o}return e}register(e){this.pci=e,this.dom=this.querySelector("qti-interaction-markup"),this.dom||(this.dom=document.createElement("div"),this.appendChild(this.dom)),this.dom.classList.add("qti-customInteraction"),this.dom.style.width="100%",this.dom.style.minHeight="50px",this.dom.style.display="block",this.dom.addEventListener("qti-interaction-changed",this._onInteractionChanged),this.querySelector("properties")&&(this.querySelector("properties").style.display="none");let t={properties:this.addHyphenatedKeys({...this.dataset}),onready:r=>{if(this.pci=r,this.pci&&typeof this.pci.getResponse=="function")try{let i=this.pci.getResponse();this._lastResponseStr=JSON.stringify(i)}catch(i){console.error("Error getting initial response:",i)}try{let i=new ResizeObserver(a=>{for(let o of a)o.contentRect&&o.contentRect.height>0&&(this.style.height=`${o.contentRect.height+20}px`)});i.observe(this.dom),this._resizeObserver=i}catch{console.warn("ResizeObserver not supported, falling back to static sizing")}},ondone:(r,i,a,o)=>{this.response=this.convertQtiVariableJSON(i),this.saveResponse(this.response),this._lastResponseStr=JSON.stringify(i)},responseIdentifier:this.responseIdentifier,boundTo:this.boundTo};if(e.getInstance)e.getInstance(this.dom,t,void 0);else{let i=(a=>{let o={},c=(d=>{let m={};Object.entries(d.dataset).forEach(([v,E])=>{v.includes("__")||(m[v]=E)});let g={};return Object.entries(d.dataset).forEach(([v,E])=>{let R=v.split("__");if(R.length>1){let[I,w,ce]=R;g[I]=g[I]||{},g[I][w]=g[I][w]||{},g[I][w][ce]=E}}),Object.entries(g).forEach(([v,E])=>{m[v]=Object.values(E)}),m})(a);for(let d in c)if(Object.prototype.hasOwnProperty.call(c,d)){let m=c[d];d==="config"?o[d]=JSON.parse(m):o[d]=m}return o})(this);e.initialize(this.customInteractionTypeIdentifier,this.dom.firstElementChild||this.dom,Object.keys(i).length?i:null)}}disconnectedCallback(){if(super.disconnectedCallback(),this.useIframe)window.removeEventListener("message",this.handleIframeMessage);else{this.stopResponseCheck(),this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=null),requirejs.undef(this.customInteractionTypeIdentifier);let e=requirejs.s.contexts;delete e[this.customInteractionTypeIdentifier],this.removeEventListener("qti-interaction-changed",this._onInteractionChanged)}}sendMessageToIframe(e,t){if(!this._iframeLoaded){this._pendingMessages.push({method:e,params:t});return}this.iframe.contentWindow.postMessage({source:"qti-portable-custom-interaction",method:e,params:t},"*")}processPendingMessages(){this._pendingMessages.length&&(this._pendingMessages.forEach(e=>{this.sendMessageToIframe(e.method,e.params)}),this._pendingMessages=[])}createIframe(){this.iframe=document.createElement("iframe"),this.iframe.id=`pci-iframe-${this.responseIdentifier}`,this.iframe.setAttribute("title","QTI PCI Iframe"),this.iframe.setAttribute("aria-label","QTI PCI Iframe"),this.iframe.setAttribute("aria-hidden","false"),this.iframe.setAttribute("role","application"),this.iframe.style.width="100%",this.iframe.style.border="none",this.iframe.style.display="block",this.iframe.onload=()=>{this._iframeLoaded=!0,this.addMarkupToIframe(),this.sendIframeInitData()};let e=`qti-pci-${this.responseIdentifier}-${Date.now()}`;this.iframe.name=e;let t=this.generateIframeContent(),r=encodeURIComponent(t);this.iframe.src=`data:text/html;charset=utf-8,${r}`,this.appendChild(this.iframe)}sendIframeInitData(){let e={module:this.module,customInteractionTypeIdentifier:this.customInteractionTypeIdentifier,baseUrl:this.baseUrl?this.baseUrl.startsWith("http")||this.baseUrl.startsWith("blob")||this.baseUrl.startsWith("base64")?this.baseUrl:ae(`${window.location.origin}${this.baseUrl}`):window.location.origin,responseIdentifier:this.responseIdentifier,dataAttributes:{...this.dataset},interactionModules:this.getInteractionModules(),boundTo:this.boundTo};this.sendMessageToIframe("initialize",e)}getInteractionModules(){let e=[],t=this.querySelector("qti-interaction-modules");if(t){let r=t.querySelectorAll("qti-interaction-module");for(let i of r)e.push({id:i.getAttribute("id"),primaryPath:i.getAttribute("primary-path"),fallbackPath:i.getAttribute("fallback-path")})}return e}addMarkupToIframe(){let e=this.querySelector("qti-interaction-markup");e&&this.sendMessageToIframe("setMarkup",e.innerHTML);let t=this.querySelector("properties");t&&this.sendMessageToIframe("setProperties",t.innerHTML)}initializeInteraction(){}connectedCallback(){if(super.connectedCallback(),this.useIframe)window.addEventListener("message",this.handleIframeMessage),this.createIframe();else{define("qtiCustomInteractionContext",()=>({register:t=>{this.register(t)},notifyReady:()=>{}}));let e=this.buildRequireConfig();if(e){let t=requirejs.config(e);requirejs.onError=function(r){throw console.error("RequireJS error:",r),r.requireType==="timeout"&&console.error("Modules that timed out:",r.requireModules),r},t(["require"],r=>{try{r([this.module],()=>{},i=>{console.error("Error loading module:",i)})}catch(i){console.error("Error in require call:",i)}}),this.startResponseCheck()}}}startResponseCheck(){this.stopResponseCheck(),this._responseCheckInterval=window.setInterval(()=>{if(this.pci&&typeof this.pci.getResponse=="function")try{let e=this.pci.getResponse(),t=JSON.stringify(e);if(t!==this._lastResponseStr){this._lastResponseStr=t;let r=this.convertQtiVariableJSON(e);this.saveResponse(r)}}catch(e){console.error("Error checking for response changes:",e)}},500)}stopResponseCheck(){this._responseCheckInterval!==null&&(window.clearInterval(this._responseCheckInterval),this._responseCheckInterval=null)}buildRequireConfig(){let e={context:this.customInteractionTypeIdentifier,catchError:!0,paths:{...this.getFinalRequirePaths(),...window.requirePaths||{}},shim:{...this.getFinalRequireShim(),...window.requireShim||{}}};if(!globalThis.require)return this._errorMessage="RequireJS not found. Please load it via CDN: https://cdnjs.com/libraries/require.js",null;let t=this.getAttribute("data-base-url"),r=this.querySelector("qti-interaction-modules");if(r){let i=r.querySelectorAll("qti-interaction-module");for(let a of i){let o=a.getAttribute("id"),l=a.getAttribute("primary-path"),c=a.getAttribute("fallback-path");if(o&&l){let d=c?this.combineRequireResolvePaths(this.getResolvablePath(l,t),this.getResolvablePath(c,t)):this.getResolvablePath(l,t),m=e.paths[o]||[];e.paths[o]=this.combineRequireResolvePaths(m,d)}}}return e}combineRequireResolvePaths(e,t){let r=Array.isArray(e)?e:[e],i=Array.isArray(t)?t:[t];return r.concat(i).filter((a,o,l)=>l.indexOf(a)===o)}removeDoubleSlashes(e){return e.replace(/([^:]\/)\/+/g,"$1").replace(/\/\//g,"/").replace("http:/","http://").replace("https:/","https://")}generateIframeContent(){let e=window.getComputedStyle(document.body),t=JSON.stringify(this.getFinalRequirePaths()),r=JSON.stringify(this.getFinalRequireShim()),i=`
623
+ font-family: ${e.getPropertyValue("font-family")};
624
+ font-size: ${e.getPropertyValue("font-size")};
625
+ line-height: ${e.getPropertyValue("line-height")};
626
+ font-weight: ${e.getPropertyValue("font-weight")};
627
+ color: ${e.getPropertyValue("color")};
628
+ `;return`<!DOCTYPE html>
629
+ <html lang="en">
630
+ <head>
631
+ <meta charset="utf-8" />
632
+ <title>QTI PCI Container</title>
633
+ <base href="${window.location.origin}" />
634
+ <style>
635
+ body, html {
636
+ margin: 0;
637
+ padding: 0;
638
+ width: 100%;
639
+ height: auto;
640
+ overflow: hidden;
641
+ /* Add the extracted font styles here */
642
+ ${i}
643
+ }
644
+ .qti-customInteraction {
645
+ width: 100%;
646
+ height: 100%;
647
+ }
648
+ #pci-container {
649
+ width: 100%;
650
+ </style>
651
+ <script src="${this.requireJsUrl}"></script>
652
+ <script>
653
+ // Define standard paths and shims
654
+ window.requirePaths = ${t};
655
+
656
+ window.requireShim = ${r};
657
+
658
+ // Single initial RequireJS configuration with error handling
659
+ window.requirejs.config({
660
+ catchError: true,
661
+ waitSeconds: 30,
662
+ paths: window.requirePaths,
663
+ shim: window.requireShim,
664
+ onNodeCreated: function(node, config, moduleName, url) {
665
+ console.log('RequireJS creating node for module:', moduleName, 'URL:', url);
666
+
667
+ // Add error handler to script node
668
+ node.addEventListener('error', function(evt) {
669
+ console.error('Script load error for module:', moduleName, 'URL:', url, 'Event:', evt);
670
+ });
671
+ },
672
+ onError: function(err) {
673
+ console.error('RequireJS error:', {
674
+ type: err.requireType,
675
+ modules: err.requireModules,
676
+ error: err
677
+ });
678
+
679
+ if (err.requireType === 'scripterror') {
680
+ console.error('Script error usually indicates a network or CORS issue with:', err.requireModules);
681
+ }
682
+
683
+ // Notify parent window about the error
684
+ window.parent.postMessage({
685
+ source: 'qti-pci-iframe',
686
+ method: 'error',
687
+ params: {
688
+ message: 'RequireJS ' + err.requireType + ' error for modules: ' + err.requireModules,
689
+ details: {
690
+ type: err.requireType,
691
+ modules: err.requireModules,
692
+ error: err.toString()
693
+ }
694
+ }
695
+ }, '*');
696
+ }
697
+ });
698
+
699
+ // PCI Manager for iframe implementation
700
+ window.PCIManager = {
701
+ pciInstance: null,
702
+ container: null,
703
+ customInteractionTypeIdentifier: null,
704
+
705
+ initialize: function(config) {
706
+ this.customInteractionTypeIdentifier = config.customInteractionTypeIdentifier;
707
+ this.container = document.getElementById('pci-container');
708
+ this.container.classList.add('qti-customInteraction');
709
+
710
+ function getResolvablePath(path, basePath) {
711
+ if (Array.isArray(path)) {
712
+ return path.map(p => getResolvablePathString(p, basePath));
713
+ } else {
714
+ return getResolvablePathString(path, basePath);
715
+ }
716
+ }
717
+
718
+ function removeDoubleSlashes(str) {
719
+ return str
720
+ .replace(/([^:\\/])\\/\\/+/g, '$1/')
721
+ .replace(/\\/\\//g, '/')
722
+ .replace('http:/', 'http://')
723
+ .replace('https:/', 'https://');
724
+ }
725
+
726
+ function getResolvablePathString(path, basePath) {
727
+ path = path.replace(/\\.js$/, '');
728
+ return path?.toLocaleLowerCase().startsWith('http') || !basePath
729
+ ? path
730
+ : removeDoubleSlashes(\`\${basePath}/\${path}\`);
731
+ }
732
+
733
+ function combineRequireResolvePaths(path1, path2, baseUrl) {
734
+ path1 = getResolvablePath(path1, baseUrl);
735
+ const path1Array = Array.isArray(path1) ? path1 : [path1];
736
+ if (!path2) {
737
+ return path1Array;
738
+ }
739
+ path2 = getResolvablePath(path2, baseUrl);
740
+ const path2Array = Array.isArray(path2) ? path2 : [path2];
741
+ return path1Array.concat(path2Array).filter((value, index, self) => self.indexOf(value) === index);
742
+ }
743
+
744
+ // Update paths with modules from the config
745
+ if (config.interactionModules && config.interactionModules.length > 0) {
746
+ config.interactionModules.forEach(module => {
747
+ if (module.id && module.primaryPath) {
748
+ const currentPath = window.requirePaths[module.id] || [];
749
+ const currentPaths = Array.isArray(currentPath) ? currentPath : [currentPath];
750
+ const newPath = combineRequireResolvePaths(
751
+ module.primaryPath, module.fallbackPath, config.baseUrl
752
+ );
753
+ window.requirePaths[module.id] = currentPaths.concat(newPath).filter((value, index, self) => self.indexOf(value) === index);
754
+ }
755
+ });
756
+ }
757
+
758
+ // The ONLY other requirejs.config call - with the context for this specific PCI
759
+ window.requirejs.config({
760
+ context: this.customInteractionTypeIdentifier,
761
+ paths: window.requirePaths,
762
+ shim: window.requireShim
763
+ });
764
+
765
+ // Define qtiCustomInteractionContext for the PCI
766
+ define('qtiCustomInteractionContext', () => {
767
+ return {
768
+ register: pciInstance => {
769
+ this.pciInstance = pciInstance;
770
+ // Configure PCI instance
771
+ const pciConfig = {
772
+ properties: this.addHyphenatedKeys({ ...config.dataAttributes }),
773
+ onready: pciInstance => {
774
+ this.pciInstance = pciInstance;
775
+ this.notifyReady();
776
+ },
777
+ ondone: (pciInstance, response, state, status) => {
778
+ this.notifyInteractionChanged(response);
779
+ },
780
+ responseIdentifier: config.responseIdentifier,
781
+ boundTo: config.boundTo,
782
+ };
783
+
784
+ if (pciInstance.getInstance) {
785
+ pciInstance.getInstance(this.container, pciConfig, undefined);
786
+ } else {
787
+ // TAO custom interaction initialization
788
+ const restoreTAOConfig = (dataset) => {
789
+ const config = {};
790
+ const parseDataAttributes = () => {
791
+ const result = {};
792
+
793
+ // Separate direct attributes from nested ones
794
+ Object.entries(dataset || []).forEach(([key, value]) => {
795
+ if (!key.includes('__')) {
796
+ // Direct attributes (like version)
797
+ result[key] = value;
798
+ }
799
+ });
800
+
801
+ // Parse nested attributes
802
+ const nestedData = {};
803
+
804
+ Object.entries(dataset || []).forEach(([key, value]) => {
805
+ const parts = key.split('__');
806
+ if (parts.length > 1) {
807
+ const [group, index, prop] = parts;
808
+ nestedData[group] = nestedData[group] || {};
809
+ nestedData[group][index] = nestedData[group][index] || {};
810
+ nestedData[group][index][prop] = value;
811
+ }
812
+ });
813
+
814
+ // Convert nested groups to arrays
815
+ Object.entries(nestedData).forEach(([key, group]) => {
816
+ result[key] = Object.values(group);
817
+ });
818
+ return result;
819
+ };
820
+ const data = parseDataAttributes();
821
+ for (const key in data) {
822
+ if (Object.prototype.hasOwnProperty.call(data, key)) {
823
+ const value = data[key];
824
+ if (key === 'config') {
825
+ config[key] = JSON.parse(value);
826
+ } else {
827
+ config[key] = value;
828
+ }
829
+ }
830
+ }
831
+ return config;
832
+ };
833
+ const taoConfig = restoreTAOConfig(config.dataAttributes);
834
+
835
+ this.pciInstance.initialize(
836
+ this.customInteractionTypeIdentifier,
837
+ this.container.firstElementChild || this.container,
838
+ Object.keys(taoConfig).length ? taoConfig : null
839
+ );
840
+ }
841
+ },
842
+ notifyReady: () => {
843
+ // Notify parent that the PCI is ready
844
+ window.parent.postMessage({
845
+ source: 'qti-pci-iframe',
846
+ method: 'pciReady'
847
+ }, '*');
848
+ }
849
+ };
850
+ });
851
+
852
+ // Load the PCI module
853
+ this.loadModule(config.module);
854
+ },
855
+
856
+ loadModule: function(modulePath) {
857
+ try {
858
+ // Get the context-specific require
859
+ const contextRequire = window.requirejs.config({
860
+ context: this.customInteractionTypeIdentifier
861
+ });
862
+
863
+ contextRequire(['require'], require => {
864
+ // Now load the actual module
865
+ require([modulePath], () => {
866
+ }, err => {
867
+ console.error('Error loading module after tap loaded:', modulePath, err);
868
+ this.notifyError('Module load error: ' + err.toString());
869
+ });
870
+ });
871
+ } catch (error) {
872
+ console.error('Exception in loadModule:', error);
873
+ this.notifyError('Error in require call: ' + error.toString());
874
+ }
875
+ },
876
+
877
+ notifyReady: function() {
878
+ window.parent.postMessage({
879
+ source: 'qti-pci-iframe',
880
+ method: 'iframeReady'
881
+ }, '*');
882
+ },
883
+
884
+ notifyInteractionChanged: function(response) {
885
+ window.parent.postMessage({
886
+ source: 'qti-pci-iframe',
887
+ method: 'interactionChanged',
888
+ params: { value: response }
889
+ }, '*');
890
+ },
891
+
892
+ notifyError: function(message) {
893
+ console.error('PCI Error:', message);
894
+ window.parent.postMessage({
895
+ source: 'qti-pci-iframe',
896
+ method: 'error',
897
+ params: { message: message }
898
+ }, '*');
899
+ },
900
+
901
+ setMarkup: function(markupHtml) {
902
+ this.container = document.getElementById('pci-container');
903
+ this.container.innerHTML = markupHtml;
904
+ },
905
+
906
+ addHyphenatedKeys: function(properties) {
907
+ const updatedProperties = { ...properties };
908
+ for (const key in properties) {
909
+ if (Object.prototype.hasOwnProperty.call(properties, key)) {
910
+ const hyphenatedKey = key.replace(/[A-Z]/g, char => \`-\${char.toLowerCase()}\`);
911
+ updatedProperties[hyphenatedKey] = properties[key];
912
+ }
913
+ }
914
+ return updatedProperties;
915
+ },
916
+ };
917
+
918
+ // Set up message listener for communication with parent
919
+ window.addEventListener('message', function(event) {
920
+ const { data } = event;
921
+
922
+ // Ensure the message is from our parent
923
+ if (!data || data.source !== 'qti-portable-custom-interaction') {
924
+ return;
925
+ }
926
+
927
+ switch(data.method) {
928
+ case 'initialize':
929
+ PCIManager.initialize(data.params);
930
+ break;
931
+
932
+ case 'setMarkup':
933
+ PCIManager.setMarkup(data.params);
934
+ break;
935
+
936
+ case 'setBoundTo':
937
+ // Handle setting boundTo
938
+ break;
939
+
940
+ case 'setProperties':
941
+ // Handle setting properties
942
+ break;
943
+ }
944
+ });
945
+
946
+ // Notify parent that iframe has loaded
947
+ window.addEventListener('load', function() {
948
+ window.parent.postMessage({
949
+ source: 'qti-pci-iframe',
950
+ method: 'iframeLoaded'
951
+ }, '*');
952
+ });
953
+ let resizeTimeout;
954
+ let previousHeight = 0;
955
+ const notifyResize = () => {
956
+ const container = document.getElementById('pci-container');
957
+ const newHeight = container.scrollHeight + 100;
958
+ if (newHeight !== previousHeight) {
959
+ previousHeight = newHeight;
960
+ clearTimeout(resizeTimeout);
961
+ resizeTimeout = setTimeout(() => {
962
+ window.parent.postMessage({
963
+ source: 'qti-pci-iframe',
964
+ method: 'resize',
965
+ height: newHeight,
966
+ width: container.scrollWidth
967
+ }, '*');
968
+ }, 100); // Adjust debounce time as needed
969
+ }
970
+ };
971
+
972
+ function setupResizeObserver() {
973
+ const container = document.getElementById('pci-container');
974
+ if (!container || !(container instanceof Element)) {
975
+ console.warn('ResizeObserver: document.container is not an Element');
976
+ return;
977
+ }
978
+
979
+ const resizeObserver = new ResizeObserver(() => {
980
+ notifyResize();
981
+ });
982
+
983
+ resizeObserver.observe(container);
984
+ }
985
+
986
+ // Run setup once DOM is ready
987
+ if (document.readyState === 'loading') {
988
+ document.addEventListener('DOMContentLoaded', () => {
989
+ notifyResize(); // initial resize
990
+ setupResizeObserver();
991
+ });
992
+ } else {
993
+ notifyResize();
994
+ setupResizeObserver();
995
+ }
996
+
997
+ window.addEventListener('load', () => {
998
+ notifyResize();
999
+ });
1000
+ let lastResponseStr = '';
1001
+ setInterval(() => {
1002
+ if (PCIManager.pciInstance && PCIManager.pciInstance.getResponse) {
1003
+ const response = PCIManager.pciInstance.getResponse();
1004
+ const responseStr = JSON.stringify(response);
1005
+
1006
+ if (responseStr !== lastResponseStr) {
1007
+ lastResponseStr = responseStr;
1008
+ window.parent.postMessage({
1009
+ source: 'qti-pci-iframe',
1010
+ method: 'interactionChanged',
1011
+ params: { value: response }
1012
+ }, '*');
1013
+ }
1014
+ }
1015
+ }, 500); // Check every 500ms
1016
+ </script>
1017
+ </head>
1018
+ <body>
1019
+ <div id="pci-container"></div>
1020
+ </body>
1021
+ </html>`}toggleCorrectResponse(e,t){this.correctResponse=t?e?.correctResponse:e.cardinality==="single"?"":[];let r=`correct-response-container-${this.responseIdentifier}`,i=this.parentElement?.querySelectorAll(`#${r}`);if(i&&i.forEach(m=>{m.remove()}),t)this.disable();else{this.enable();return}if(!t||!e?.correctResponse)return;let a=document.createElement("div");a.id=r,a.className="pci-correct-response-container",a.style.position="relative",a.style.marginTop="20px",a.style.border="2px solid green",a.style.padding="16px",a.style.borderRadius="4px",a.style.backgroundColor="rgba(0, 128, 0, 0.05)";let o=document.createElement("div");o.textContent="Correct Response:",o.style.fontWeight="bold",o.style.marginBottom="10px",o.style.color="green",a.appendChild(o);let l=document.createElement("qti-portable-custom-interaction");Array.from(this.attributes).forEach(m=>{m.name!=="id"&&m.name!=="response-identifier"&&l.setAttribute(m.name,m.value)});let c=this.responseIdentifier;l.responseIdentifier=`${c}-correct`,Array.from(this.children).forEach(m=>{let g=m.cloneNode(!0);l.appendChild(g)});let d=e.correctResponse;if(this.useIframe){let m=l.connectedCallback;l.connectedCallback=function(){m.call(this);let g=()=>this._iframeLoaded?(setTimeout(()=>{let v=this.responseVariablesToQtiVariableJSON(d,e.cardinality,e.baseType);this.sendMessageToIframe("setBoundTo",{[c]:v}),this.sendMessageToIframe("setState",{state:"review"})},1e3),!0):!1;if(!g()){let v=setInterval(()=>{g()&&clearInterval(v)},100);setTimeout(()=>{clearInterval(v)},1e4)}}}else{let m=l.register;l.register=function(g){m.call(this,g);let v=()=>{if(this.pci&&typeof this.pci.setResponse=="function"){let E=this.responseVariablesToQtiVariableJSON(d,e.cardinality,e.baseType);return this.pci.setResponse(E),typeof this.pci.setState=="function"&&this.pci.setState("review"),!0}return!1};setTimeout(()=>{if(!v()){let E=setInterval(()=>{v()&&clearInterval(E)},200);setTimeout(()=>{clearInterval(E)},5e3)}},500)}}l.style.pointerEvents="none",a.appendChild(l),this.after(a)}disable(){if(this._previousState={pointerEvents:this.style.pointerEvents,position:this.style.position},this.useIframe&&this.sendMessageToIframe("setState",{state:"disabled"}),!this.querySelector(".pci-interaction-overlay")){let t=document.createElement("div");t.className="pci-interaction-overlay",t.style.position="absolute",t.style.top="0",t.style.left="0",t.style.width="100%",t.style.height="100%",t.style.backgroundColor="rgba(200, 200, 200, 0.3)",t.style.zIndex="100",t.style.pointerEvents="all",t.style.cursor="not-allowed",getComputedStyle(this).position==="static"&&(this.style.position="relative"),this.appendChild(t)}}enable(){let e=this.querySelector(".pci-interaction-overlay");e&&e.remove(),this._previousState&&(this._previousState.pointerEvents&&(this.style.pointerEvents=this._previousState.pointerEvents),this._previousState.position&&(this.style.position=this._previousState.position),this._previousState=null),this.useIframe&&this.sendMessageToIframe("setState",{state:"interacting"})}render(){return h`
1022
+ <slot></slot>
1023
+ ${this._errorMessage?h`<div style="color:red">
1024
+ <h1>Error</h1>
1025
+ ${this._errorMessage}
1026
+ </div>`:""}
1027
+ `}};M.styles=[sr,b`
1028
+ :host {
1029
+ display: block;
1030
+ width: 100%;
1031
+ min-height: 50px;
1032
+ }
1033
+ .qti-customInteraction {
1034
+ display: block;
1035
+ width: 100%;
1036
+ min-height: 50px;
1037
+ }
1038
+ `],n([u({type:String,attribute:"module"})],M.prototype,"module",2),n([u({type:String,attribute:"custom-interaction-type-identifier"})],M.prototype,"customInteractionTypeIdentifier",2),n([u({type:String,attribute:"data-require-paths"})],M.prototype,"requirePathsJson",2),n([u({type:String,attribute:"data-require-shim"})],M.prototype,"requireShimJson",2),n([u({type:String,attribute:"data-require-js-url"})],M.prototype,"requireJsUrl",2),n([u({type:String,attribute:"data-base-url"})],M.prototype,"baseUrl",2),n([u({type:Boolean,attribute:"data-use-iframe"})],M.prototype,"useIframe",2),n([u({type:Boolean,attribute:"data-use-default-shims"})],M.prototype,"useDefaultShims",2),n([u({type:Boolean,attribute:"data-use-default-paths"})],M.prototype,"useDefaultPaths",2),n([x()],M.prototype,"_errorMessage",2),n([_({context:T,subscribe:!0}),x()],M.prototype,"context",2),n([x()],M.prototype,"response",2),M=n([f("qti-portable-custom-interaction")],M);var Ke=class extends y{render(){return h`<slot></slot>`}};Ke.styles=[b`
1039
+ :host {
1040
+ display: block;
1041
+ }
1042
+ ::slotted(img) {
1043
+ position: absolute;
1044
+ cursor: move;
1045
+ user-select: none;
1046
+ left: 50%;
1047
+ transform: translateX(-50%);
1048
+ }
1049
+ `];customElements.define("qti-position-object-interaction",Ke);var Ne=class extends y{render(){return h`<slot></slot>`}constructor(){super(),this.removeMoveListener=this.removeMoveListener.bind(this),this.dragElementHandler=this.dragElementHandler.bind(this)}dragElementHandler(s){s.preventDefault();let e=s.clientX-this.startX,t=s.clientY-this.startY;this.dragElement.style.left=this.dragElement.offsetLeft+e+"px",this.dragElement.style.top=this.dragElement.offsetTop+t+"px",this.startX=s.clientX,this.startY=s.clientY}firstUpdated(s){super.firstUpdated(s),this.dragElement=this.querySelector("qti-position-object-interaction>img"),this.startX=0,this.startY=0,this.dragElement.addEventListener("mousedown",e=>{this.startX=e.clientX,this.startY=e.clientY,document.addEventListener("mousemove",this.dragElementHandler,!0)}),document.addEventListener("mouseup",this.removeMoveListener)}removeMoveListener(){document.removeEventListener("mousemove",this.dragElementHandler,!0)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("mousemove",this.dragElementHandler),document.removeEventListener("mouseup",this.removeMoveListener)}};Ne.styles=[b`
1050
+ :host {
1051
+ display: inline-block;
1052
+ position: relative;
1053
+ }
1054
+ `],Ne=n([f("qti-position-object-stage")],Ne);var or="important",mr=" !"+or,pt=Q(class extends he{constructor(p){if(super(p),p.type!==ue.ATTRIBUTE||p.name!=="style"||p.strings?.length>2)throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.")}render(p){return Object.keys(p).reduce((s,e)=>{let t=p[e];return t==null?s:s+`${e=e.includes("-")?e:e.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${t};`},"")}update(p,[s]){let{style:e}=p.element;if(this.ft===void 0)return this.ft=new Set(Object.keys(s)),this.render(s);for(let t of this.ft)s[t]==null&&(this.ft.delete(t),t.includes("-")?e.removeProperty(t):e[t]=null);for(let t in s){let r=s[t];if(r!=null){this.ft.add(t);let i=typeof r=="string"&&r.endsWith(mr);t.includes("-")||i?e.setProperty(t,i?r.slice(0,-11):r,i?or:""):e[t]=r}}return pe}});var Y=class extends C{constructor(){super(...arguments);this.maxChoices=1/0;this.minChoices=0;this.response=[];this._correctAreas=[];this._imgElement=null;this._scaleX=1;this._scaleY=1;this._imageWidthOrginal=0;this._imageHeightOrginal=0;this._onImageClick=e=>{if(!this._imgElement){console.warn("No <img> element found in <qti-select-point-interaction>");return}this.calculateScale();let t=this._imgElement.getBoundingClientRect(),r=(e.clientX-t.left)*this._scaleX,i=(e.clientY-t.top)*this._scaleY,a=`${r.toFixed()} ${i.toFixed()}`;this.maxChoices===1?this.response=[a]:(this.maxChoices===0||this.response.length<this.maxChoices)&&(this.response=[...this.response,a]),this.saveResponse(this.response)};this._onResize=()=>{this.calculateScale()}}connectedCallback(){super.connectedCallback(),window.addEventListener("resize",this._onResize)}toggleCorrectResponse(e,t){if(!t){this._correctAreas=[];return}let r=e.areaMapping,i=[];if(!r||r.areaMapEntries.length===0)if(e.correctResponse){let a=Array.isArray(e.correctResponse)?e.correctResponse:[e.correctResponse];if(a.length===0||a.find(o=>o.split(" ").length<2))return console.error("No valid correct responses found for the response variable."),null;console.warn("No area mapping found for the response variable. Using the correct responses to display the correct response but it probably won't score correct."),i=a.map(o=>({shape:"circle",coords:o.split(" ").join(",").concat(",10"),defaultValue:1,mappedValue:1}))}else{console.error("No area mapping found for the response variable.");return}else i=r.areaMapEntries;this._correctAreas=i.map(a=>({coords:a.coords,shape:a.shape}))}updated(e){super.updated(e);let t=this._imgElement;t&&e.has("_correctAreas")&&this._correctAreas.length>0&&(this.calculateScale(),this.shadowRoot.querySelectorAll("div").forEach(r=>{let i=r.dataset.coord,a=r.dataset.shape;i&&a&&ie(a,i.split(",").map(o=>+o),t,r)}))}render(){return h` <slot name="prompt"></slot>
1055
+ <point-container>
1056
+ ${Ee(this.response?.filter(e=>e)||[],e=>e,(e,t)=>{let[r,i]=e.split(" ").map(Number),a=r/(this._imageWidthOrginal||1)*100,o=i/(this._imageHeightOrginal||1)*100,l=16,c=l/(this._imageWidthOrginal||1)*100,d=l/(this._imageHeightOrginal||1)*100;return h`
1057
+ <button
1058
+ part="point"
1059
+ style=${pt({pointerEvents:this.maxChoices===1?"none":"auto",position:"absolute",transform:"translate(-50%, -50%)",left:`${a}%`,top:`${o}%`,width:`min(${c}%, 1rem)`,height:`min(${d}%, 1rem)`,minWidth:`min(${c}%, 1rem)`,minHeight:`min(${d}%, 1rem)`,borderRadius:"50%",background:"red"})}
1060
+ aria-label="Remove point at ${e}"
1061
+ @click=${m=>{m.stopPropagation(),this.response=(this.response||[]).filter((g,v)=>v!==t),this.saveResponse(this.response)}}
1062
+ ></button>
1063
+ `})}
1064
+ ${Ee(this._correctAreas?.filter(e=>e)||[],e=>e,(e,t)=>h`<div
1065
+ style=${pt({position:"absolute",pointerEvents:"none",backgroundColor:"var(--qti-correct)",opacity:"0.5"})}
1066
+ data-coord="${e.coords}"
1067
+ alt=${`correct-response-${t+1}`}
1068
+ data-shape="${e.shape}"
1069
+ ></div>`)}
1070
+ <slot></slot>
1071
+ </point-container>`}reset(){this.response=null}validate(){return this.response.length>=this.minChoices&&this.response.length<=this.maxChoices}calculateScale(){this._imageWidthOrginal=this._imgElement.getAttribute("width")?parseFloat(this._imgElement.getAttribute("width")):this._imgElement.naturalWidth,this._imageHeightOrginal=this._imgElement.getAttribute("height")?parseFloat(this._imgElement.getAttribute("height")):this._imgElement.naturalHeight;let e=this._imgElement.getBoundingClientRect();this._scaleX=e.width===0?1:this._imageWidthOrginal/e.width,this._scaleY=e.height===0?1:this._imageHeightOrginal/e.height}firstUpdated(){this._imgElement=this.querySelector("img"),this._imgElement?(this.calculateScale(),this._imgElement.addEventListener("click",this._onImageClick)):console.warn("No <img> element found in <qti-select-point-interaction>")}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("resize",this._onResize),this._imgElement&&this._imgElement.removeEventListener("click",this._onImageClick)}};Y.styles=[b`
1072
+ :host {
1073
+ display: block;
1074
+ }
1075
+ point-container {
1076
+ display: block;
1077
+ position: relative;
1078
+ width: fit-content;
1079
+ }
1080
+
1081
+ ::slotted(img) {
1082
+ max-width: 100%;
1083
+ height: auto;
1084
+ display: block;
1085
+ }
1086
+ `],n([u({type:Number,attribute:"max-choices"})],Y.prototype,"maxChoices",2),n([u({type:Number,attribute:"min-choices"})],Y.prototype,"minChoices",2),n([x()],Y.prototype,"response",2),n([x()],Y.prototype,"_correctAreas",2),Y=n([f("qti-select-point-interaction")],Y);var W=class extends P(y,"qti-simple-choice"){constructor(){super(...arguments);this.templateIdentifier=null;this.showHide="show";this.fixed=!1}get checked(){return this.internals.states.has("--checked")}render(){return h`<div part="ch">
1087
+ <div part="cha"></div>
1088
+ </div>
1089
+ ${this.marker?h`<div id="label">${this.marker}</div>`:k}
1090
+ <slot part="slot"></slot>`}};W.styles=b`
1091
+ :host {
1092
+ display: flex;
1093
+ align-items: center;
1094
+ user-select: none;
1095
+ }
1096
+ slot {
1097
+ width: 100%;
1098
+ display: flex;
1099
+ align-items: center;
1100
+ }
1101
+ [part='ch'] {
1102
+ display: flex;
1103
+ flex-shrink: 0;
1104
+ align-items: center;
1105
+ justify-content: center;
1106
+ }
1107
+ `,n([u({type:String,attribute:"template-identifier"})],W.prototype,"templateIdentifier",2),n([u({type:String,attribute:"show-hide"})],W.prototype,"showHide",2),n([u({type:Boolean,converter:{fromAttribute:e=>e==="true",toAttribute:e=>String(e)}})],W.prototype,"fixed",2),n([u({type:String,attribute:!1})],W.prototype,"marker",2),W=n([f("qti-simple-choice")],W);var nr=b`
1108
+ :host {
1109
+ display: block;
1110
+ --show-bounds: true;
1111
+ --show-ticks: true;
1112
+ --show-value: true;
1113
+ }
1114
+
1115
+ [part='slider'] {
1116
+ margin-left: 2rem; /* mx-8 */
1117
+ margin-right: 2rem;
1118
+ padding-bottom: 1rem; /* pb-4 */
1119
+ padding-top: 1.25rem; /* pt-5 */
1120
+ }
1121
+
1122
+ [part='bounds'] {
1123
+ display: flex;
1124
+ width: 100%;
1125
+ justify-content: space-between;
1126
+ margin-bottom: 0.5rem; /* mb-2 */
1127
+ }
1128
+
1129
+ [part='ticks'] {
1130
+ margin-left: 0.125rem; /* mx-0.5 */
1131
+ margin-right: 0.125rem;
1132
+ margin-bottom: 0.25rem; /* mb-1 */
1133
+ height: 0.5rem; /* h-2 */
1134
+ background: linear-gradient(to right, var(--qti-border-color) var(--qti-border-thickness), transparent 1px) repeat-x
1135
+ 0 center / calc(calc(100% - var(--qti-border-thickness)) / ((var(--max) - var(--min)) / var(--step))) 100%;
1136
+ }
1137
+
1138
+ [part='rail'] {
1139
+ display: flex;
1140
+ align-items: center;
1141
+ box-sizing: border-box;
1142
+ height: 0.375rem; /* h-1.5 */
1143
+ width: 100%;
1144
+ cursor: pointer;
1145
+ border-radius: 9999px; /* rounded-full */
1146
+ border: 1px solid #d1d5db; /* border-gray-300 */
1147
+ background-color: #e5e7eb; /* bg-gray-200 */
1148
+ }
1149
+
1150
+ [part='knob'] {
1151
+ background-color: var(--qti-bg-active);
1152
+ border: 2px solid var(--qti-border-active);
1153
+ position: relative;
1154
+ height: 1rem; /* h-4 */
1155
+ width: 1rem; /* w-4 */
1156
+ transform-origin: center;
1157
+ transform: translateX(-50%);
1158
+ cursor: pointer;
1159
+ border-radius: 9999px; /* rounded-full */
1160
+ left: var(--value-percentage);
1161
+ }
1162
+ [part='knob-correct'] {
1163
+ background-color: var(--qti-correct-light);
1164
+ border: 2px solid var(--qti-correct);
1165
+ position: relative;
1166
+ height: 1rem; /* h-4 */
1167
+ width: 1rem; /* w-4 */
1168
+ transform-origin: center;
1169
+ transform: translateX(-50%);
1170
+ cursor: pointer;
1171
+ border-radius: 9999px; /* rounded-full */
1172
+ left: var(--value-percentage-correct);
1173
+ }
1174
+
1175
+ [part='value'] {
1176
+ position: absolute;
1177
+ bottom: 2rem; /* bottom-8 */
1178
+ left: 0.5rem; /* left-2 */
1179
+ transform: translateX(-50%);
1180
+ cursor: pointer;
1181
+ border-radius: 0.25rem; /* rounded */
1182
+ background-color: #f3f4f6; /* bg-gray-100 */
1183
+ padding: 0.25rem 0.5rem; /* px-2 py-1 */
1184
+ text-align: center;
1185
+ color: #6b7280; /* text-gray-500 */
1186
+ }
1187
+ `;var G=class extends C{constructor(){super(...arguments);this._value=0;this._correctResponseNumber=null;this.min=0;this.max=100;this.step=1}validate(){return!0}connectedCallback(){super.connectedCallback(),this._updateValue(this.min),this.setAttribute("tabindex","0"),this.setAttribute("role","slider")}get response(){return this._value.toString()}set response(e){let t=parseInt(e,10);isNaN(t)||this._updateValue(t)}toggleCorrectResponse(e,t){if(t){this._correctResponse=e.correctResponse.toString();let r=parseFloat(e.correctResponse.toString());if(isNaN(r))this._correctResponseNumber=null;else{this._correctResponseNumber=r;let i=(this._correctResponseNumber-this.min)/(this.max-this.min)*100;this.style.setProperty("--value-percentage-correct",`${i}%`)}}else this._correctResponseNumber=null;this.requestUpdate()}_updateValue(e){let t=this._value;if(this._value=Math.min(this.max,Math.max(this.min,e)),this._value===t)return;let r=(this._value-this.min)/(this.max-this.min)*100;this.style.setProperty("--value-percentage",`${r}%`),this._internals.setFormValue(this.value),this.saveResponse(this.response),this.requestUpdate()}render(){return h`
1188
+ <slot name="prompt"></slot>
1189
+ <div id="slider" part="slider">
1190
+ <div id="bounds" part="bounds">
1191
+ <div>${this.min}</div>
1192
+ <div>${this.max}</div>
1193
+ </div>
1194
+
1195
+ <div id="ticks" part="ticks"></div>
1196
+
1197
+ <div id="rail" part="rail" @mousedown=${this._onMouseDown} @touchstart=${this._onTouchStart}>
1198
+ <div id="knob" part="knob">
1199
+ <div id="value" part="value">${this.response}</div>
1200
+ </div>
1201
+
1202
+ ${this._correctResponseNumber!==null?h`
1203
+ <div id="knob-correct" part="knob-correct">
1204
+ <div id="value" part="value">${this._correctResponseNumber}</div>
1205
+ </div>
1206
+ `:null}
1207
+ </div>
1208
+ </div>
1209
+ `}_onMouseDown(e){this._startDrag(e.pageX);let t=i=>this._onDrag(i.pageX),r=()=>{document.removeEventListener("mousemove",t),document.removeEventListener("mouseup",r),this._onDragEnd()};document.addEventListener("mousemove",t),document.addEventListener("mouseup",r)}_onTouchStart(e){this._startDrag(e.touches[0].pageX);let t=i=>this._onDrag(i.touches[0].pageX),r=()=>{document.removeEventListener("touchmove",t),document.removeEventListener("touchend",r),this._onDragEnd()};document.addEventListener("touchmove",t,{passive:!1}),document.addEventListener("touchend",r)}_startDrag(e){this._onDrag(e)}_onDrag(e){let t=this._rail.getBoundingClientRect(),r=e-t.left,i=Math.min(1,Math.max(0,r/t.width)),a=this.min+Math.round(i*(this.max-this.min)/this.step)*this.step;this._updateValue(a)}_onDragEnd(){this.dispatchEvent(new Event("change",{bubbles:!0}))}};G.styles=nr,n([de("#rail")],G.prototype,"_rail",2),n([u({type:Number,attribute:"lower-bound"})],G.prototype,"min",2),n([u({type:Number,attribute:"upper-bound"})],G.prototype,"max",2),n([u({type:Number,attribute:"step"})],G.prototype,"step",2),G=n([f("qti-slider-interaction")],G);var ar=()=>new ut,ut=class{},dt=new WeakMap,ja=Q(class extends Ut{render(p){return k}update(p,[s]){let e=s!==this.G;return e&&this.G!==void 0&&this.rt(void 0),(e||this.lt!==this.ct)&&(this.G=s,this.ht=p.options?.host,this.rt(this.ct=p.element)),k}rt(p){if(this.isConnected||(p=void 0),typeof this.G=="function"){let s=this.ht??globalThis,e=dt.get(s);e===void 0&&(e=new WeakMap,dt.set(s,e)),e.get(this.G)!==void 0&&this.G.call(this.ht,void 0),e.set(this.G,p),p!==void 0&&this.G.call(this.ht,p)}else this.G.value=p}get lt(){return typeof this.G=="function"?dt.get(this.ht??globalThis)?.get(this.G):this.G?.value}disconnected(){this.lt===this.ct&&this.rt(void 0)}reconnected(){this.rt(this.ct)}});var lr=b`
1210
+ :host {
1211
+ display: inline-block;
1212
+ }
1213
+
1214
+ :host(.qti-input-width-1) [part='input'] {
1215
+ width: 1.1rem;
1216
+ min-width: 1.1rem;
1217
+ }
1218
+
1219
+ :host(.qti-input-width-2) [part='input'] {
1220
+ width: 2.3rem;
1221
+ min-width: 2.3rem;
1222
+ }
1223
+
1224
+ :host(.qti-input-width-3) [part='input'] {
1225
+ width: 3.3rem;
1226
+ min-width: 3.3rem;
1227
+ }
1228
+
1229
+ :host(.qti-input-width-4) [part='input'] {
1230
+ width: 4.2rem;
1231
+ min-width: 4.2rem;
1232
+ }
1233
+
1234
+ :host(.qti-input-width-6) [part='input'] {
1235
+ width: 6.6rem;
1236
+ min-width: 6.6rem;
1237
+ }
1238
+
1239
+ :host(.qti-input-width-10) [part='input'] {
1240
+ width: 8rem;
1241
+ min-width: 8rem;
1242
+ }
1243
+
1244
+ :host(.qti-input-width-15) [part='input'] {
1245
+ width: 12rem;
1246
+ min-width: 12rem;
1247
+ }
1248
+
1249
+ :host(.qti-input-width-20) [part='input'] {
1250
+ width: 17rem;
1251
+ min-width: 17rem;
1252
+ }
1253
+
1254
+ :host(.qti-input-width-25) [part='input'] {
1255
+ width: 20rem;
1256
+ min-width: 20rem;
1257
+ }
1258
+
1259
+ :host(.qti-input-width-30) [part='input'] {
1260
+ width: 24rem;
1261
+ min-width: 24rem;
1262
+ }
1263
+
1264
+ :host(.qti-input-width-35) [part='input'] {
1265
+ width: 28rem;
1266
+ min-width: 28rem;
1267
+ }
1268
+
1269
+ :host(.qti-input-width-40) [part='input'] {
1270
+ width: 32rem;
1271
+ min-width: 32rem;
1272
+ }
1273
+
1274
+ :host(.qti-input-width-45) [part='input'] {
1275
+ width: 36rem;
1276
+ min-width: 36rem;
1277
+ }
1278
+
1279
+ :host(.qti-input-width-50) [part='input'] {
1280
+ width: 40rem;
1281
+ min-width: 40rem;
1282
+ }
1283
+
1284
+ :host(.qti-input-width-72) [part='input'] {
1285
+ width: 57rem;
1286
+ min-width: 57rem;
1287
+ }
1288
+
1289
+ :host {
1290
+ position: relative;
1291
+ }
1292
+ input {
1293
+ anchor-name: --text-entry-input;
1294
+ z-index: 100;
1295
+ position: relative;
1296
+ }
1297
+
1298
+ [part='correct'] {
1299
+ padding: var(--qti-padding-vertical) var(--qti-padding-horizontal);
1300
+ background-color: var(--qti-bg);
1301
+ z-index: 0;
1302
+ position: absolute;
1303
+ left: 0;
1304
+ right: 0;
1305
+ position-anchor: --text-entry-input;
1306
+ bottom: anchor(top);
1307
+ left: anchor(left);
1308
+ /* opacity: 1; */
1309
+ transition: all 1s;
1310
+
1311
+ @starting-style {
1312
+ display: grid;
1313
+ /* opacity: 0; */
1314
+ bottom: 0;
1315
+ }
1316
+ }
1317
+ `;var $=class extends C{constructor(){super(...arguments);this.inputRef=ar();this.response=null;this._handleValueChange=()=>{this._internals.setFormValue(this.value),this.validate()}}get value(){return this.response||null}set value(e){this.response=e||null}validate(){if(!this._input)return!1;if(this.patternMask&&this.dataPatternmaskMessage)this._internals.setValidity({}),this._input.setCustomValidity(""),this._input.checkValidity()||(this._internals.setValidity({customError:!0},this.dataPatternmaskMessage),this._input.setCustomValidity(this.dataPatternmaskMessage));else{let e=this._input.checkValidity();this._internals.setValidity(e?{}:{customError:!1})}return this.response!==""&&this._input.checkValidity()}toggleCorrectResponse(e,t){if(t&&e.correctResponse){let r=e.correctResponse.toString();this._correctResponse=r}else this._correctResponse=null}render(){return h`
1318
+ <input
1319
+ part="input"
1320
+ name="${this.responseIdentifier}"
1321
+ spellcheck="false"
1322
+ autocomplete="off"
1323
+ @blur="${e=>{this.reportValidity()}}"
1324
+ @keydown="${e=>e.stopImmediatePropagation()}"
1325
+ @keyup="${this.textChanged}"
1326
+ @change="${this.textChanged}"
1327
+ type="${this.patternMask=="[0-9]*"?"number":"text"}"
1328
+ placeholder="${O(this.placeholderText?this.placeholderText:void 0)}"
1329
+ .value="${this.response}"
1330
+ pattern="${O(this.patternMask?this.patternMask:void 0)}"
1331
+ maxlength=${1e3}
1332
+ ?disabled="${this.disabled}"
1333
+ ?readonly="${this.readonly}"
1334
+ />
1335
+ ${this._correctResponse?h`<div part="correct">${this._correctResponse}</div>`:k}
1336
+ `}textChanged(e){if(this.disabled||this.readonly)return;let t=e.target;this.setEmptyAttribute(t.value),this.response!==t.value&&(this.value=t.value,this.saveResponse(t.value))}reportValidity(){let e=this.shadowRoot.querySelector("input");if(!e)return!1;let t=this.validate();return t||e.reportValidity(),t}reset(){this.response=""}setEmptyAttribute(e){this.setAttribute("empty",e===""?"true":"false")}};$.styles=lr,n([u({type:Number,attribute:"expected-length"})],$.prototype,"expectedLength",2),n([u({type:String,attribute:"pattern-mask"})],$.prototype,"patternMask",2),n([u({type:String,attribute:"placeholder-text"})],$.prototype,"placeholderText",2),n([u({type:String,attribute:"data-patternmask-message"})],$.prototype,"dataPatternmaskMessage",2),n([x()],$.prototype,"response",2),n([de("input")],$.prototype,"_input",2),n([S("response",{waitUntilFirstUpdate:!0})],$.prototype,"_handleValueChange",2),$=n([f("qti-text-entry-interaction")],$);var Oe=class extends C{constructor(){super(...arguments);this._file=null;this._base64=null}reset(){this._file=null,this._base64=null,this.saveResponse(null)}validate(){return this._base64!==null}get response(){return this._base64}set response(e){if(typeof e=="string")this._base64=e,this.saveResponse(e);else if(e===null)this.reset();else throw new Error("Value must be a Base64-encoded string or null")}static get properties(){return{...C.properties}}render(){return h`
1337
+ <div>
1338
+ <slot name="prompt"></slot>
1339
+ <input type="file" @change="${this._onFileChange}" ?disabled="${this.disabled}" ?readonly="${this.readonly}" />
1340
+ </div>
1341
+ `}async _onFileChange(e){let t=e.target;t.files&&t.files.length>0&&(this._file=t.files[0],this._base64=await this._convertToBase64(this._file),this.saveResponse(this._base64),this.dispatchEvent(new CustomEvent("qti-interaction-response",{detail:{response:this._base64}})))}_convertToBase64(e){return new Promise((t,r)=>{let i=new FileReader;i.onload=()=>t(i.result),i.onerror=()=>r(i.error),i.readAsDataURL(e)})}};Oe.styles=[b`
1342
+ :host {
1343
+ display: block;
1344
+ margin: 1em 0;
1345
+ }
1346
+ input[type='file'] {
1347
+ display: block;
1348
+ margin-top: 0.5em;
1349
+ }
1350
+ `],Oe=n([f("qti-upload-interaction")],Oe);var cr=b`
1351
+ :host {
1352
+ display: block;
1353
+ }
1354
+ `;var He=class extends y{render(){return h`<slot part="qti-rubric-blocks" name="qti-rubric-block"></slot><slot></slot>`}};He.styles=cr,He=n([f("qti-item-body")],He);var Pe=class extends y{render(){return h`<slot></slot>`}process(){let s=new ht,e=[...this.children];s.process(e)}};Pe.styles=[b`
1355
+ :host {
1356
+ display: none;
1357
+ }
1358
+ `],Pe=n([f("qti-outcome-processing")],Pe);var ht=class{process(s){for(let e of s)e.process()}};var Ze=class extends y{render(){return h`<slot></slot>`}connectedCallback(){this.parentElement.tagName.endsWith("INTERACTION")&&this.setAttribute("slot","prompt")}};Ze=n([f("qti-prompt")],Ze);var pr=`<qti-response-processing>
1359
+ <qti-response-condition>
1360
+ <qti-response-if>
1361
+ <qti-match>
1362
+ <qti-variable identifier="RESPONSE"></qti-variable>
1363
+ <qti-correct identifier="RESPONSE"></qti-correct>
1364
+ </qti-match>
1365
+ <qti-set-outcome-value identifier="SCORE">
1366
+ <qti-base-value base-type="float">1</qti-base-value>
1367
+ </qti-set-outcome-value>
1368
+ </qti-response-if>
1369
+ <qti-response-else>
1370
+ <qti-set-outcome-value identifier="SCORE">
1371
+ <qti-base-value base-type="float">0</qti-base-value>
1372
+ </qti-set-outcome-value>
1373
+ </qti-response-else>
1374
+ </qti-response-condition>
1375
+ </qti-response-processing>`,dr=`<qti-response-processing>
1376
+ <qti-response-condition>
1377
+ <qti-response-if>
1378
+ <qti-is-null>
1379
+ <qti-variable identifier="RESPONSE"></qti-variable>
1380
+ </qti-is-null>
1381
+ <qti-set-outcome-value identifier="SCORE">
1382
+ <qti-base-value base-type="float">0.0</qti-base-value>
1383
+ </qti-set-outcome-value>
1384
+ </qti-response-if>
1385
+ <qti-response-else>
1386
+ <qti-set-outcome-value identifier="SCORE">
1387
+ <qti-map-response identifier="RESPONSE"> </qti-map-response>
1388
+ </qti-set-outcome-value>
1389
+ </qti-response-else>
1390
+ </qti-response-condition>
1391
+ </qti-response-processing>`,ur=`<qti-response-processing>
1392
+ <qti-response-condition>
1393
+ <qti-response-if>
1394
+ <qti-is-null>
1395
+ <qti-variable identifier="RESPONSE"></qti-variable>
1396
+ </qti-is-null>
1397
+ <qti-set-outcome-value identifier="SCORE">
1398
+ <qti-base-value base-type="float">0</qti-base-value>
1399
+ </qti-set-outcome-value>
1400
+ </qti-response-if>
1401
+ <qti-response-else>
1402
+ <qti-set-outcome-value identifier="SCORE">
1403
+ <qti-map-response-point identifier="RESPONSE"></qti-map-response-point>
1404
+ </qti-set-outcome-value>
1405
+ </qti-response-else>
1406
+ </qti-response-condition>
1407
+ </qti-response-processing>`;var ze=class extends y{render(){return h`<slot></slot>`}process(){if(!this.closest("qti-assessment-item"))return;let e=[...this.children];for(let t of e)t.process()}firstUpdated(s){if(this.getAttribute("template")){let e=this.getAttribute("template").split("/"),t=e[e.length-1].replace(".xml","");switch(this.innerHTML="",t){case"map_response":{this.appendChild(this.fragmentFromString(dr).firstElementChild.firstElementChild);break}case"map_response_point":{this.appendChild(this.fragmentFromString(ur).firstElementChild.firstElementChild);break}case"match_correct":this.appendChild(this.fragmentFromString(pr).firstElementChild.firstElementChild);break}}}fragmentFromString(s){return document.createRange().createContextualFragment(s)}};ze.styles=[b`
1408
+ :host {
1409
+ display: none;
1410
+ }
1411
+ `],ze=n([f("qti-response-processing")],ze);var F=class extends y{render(){return h`<slot></slot>`}process(){throw new Error("Not implemented")}};F=n([f("qti-rule")],F);var Fe=class extends F{get childExpression(){return this.firstElementChild}process(){let s=this.getAttribute("identifier"),e=this.context.variables.find(r=>r.identifier===s)||null,t;return e.interpolationTable&&(t=e.interpolationTable.get(parseInt(this.childExpression.calculate()))),t==null?(console.warn("lookupOutcomeValue: value is null or undefined"),0):(this.dispatchEvent(new CustomEvent("qti-set-outcome-value",{bubbles:!0,composed:!0,detail:{outcomeIdentifier:this.identifier,value:we(t)}})),t)}};n([u({type:String})],Fe.prototype,"identifier",2),n([_({context:T,subscribe:!0}),x()],Fe.prototype,"context",2);customElements.define("qti-lookup-outcome-value",Fe);var mt=class extends F{render(){return h`<slot></slot>`}process(){let s=[...this.children];for(let e=0;e<s.length;e++){let t=s[e];if(t.calculate()){t.process();return}}}};customElements.define("qti-response-condition",mt);var ft=class extends F{process(){let s=this.getAttribute("identifier");if(!s){console.warn('QtiSetOutcomeValue: Missing "identifier" attribute.');return}let e=this.firstElementChild;if(!e){console.warn("QtiSetOutcomeValue: No expression found.");return}let r=new gt(e).process();this.dispatchEvent(new CustomEvent("qti-set-outcome-value",{bubbles:!0,composed:!0,detail:{outcomeIdentifier:s,value:this.formatValue(r)}}))}formatValue(s){return Array.isArray(s)?s.map(we):s!==null?we(s):null}},gt=class{constructor(s){this.expression=s}process(){let s=this.expression.calculate()??null;return s===null&&console.warn("QtiSetOutcomeValueRule: Evaluated value is null."),Array.isArray(s)?s.map(e=>e.value?e.value:e):s}};customElements.define("qti-set-outcome-value",ft);var Ue=class extends y{render(){return h`<slot></slot>`}calculate(){return!0}getSubRules(){return[...this.children]}process(){let s=this.getSubRules();for(let e=0;e<s.length;e++)s[e].process()}};customElements.define("qti-response-else",Ue);var je=class extends Ue{calculate(){return this.firstElementChild.calculate()}getSubRules(){let s=[];for(let e=1;e<this.children.length;e++)s.push(this.children[e]);return s}};customElements.define("qti-response-if",je);var bt=class extends je{render(){return h`${super.render()}`}};customElements.define("qti-response-else-if",bt);var Qe=class extends fr(N){calculate(){return this.calculateChildren(Array.from(this.children))}};Qe=n([f("qti-and")],Qe);function fr(p){return class extends p{calculateChildren(e){return e.map(r=>{let i=r;if(!i.calculate)return console.error("Element doesn't implement QtiConditionExpression"),null;let a=i.calculate(),o=!1;if(typeof a=="string")if(a==="true")o=!0;else if(a==="false")o=!1;else return console.error("unexpected val in qti-or, expected boolean"),null;else typeof a=="boolean"&&(o=a);return o}).every(r=>typeof r=="boolean"&&r)}}}var et=class extends q{constructor(){super(...arguments);this.baseType="string"}getResult(){return this.textContent.trim()}};n([u({type:String,attribute:"base-type"})],et.prototype,"baseType",2);customElements.define("qti-base-value",et);var vt=class extends N{getResult(){let s=this.getVariables();if(this.children.length===2){let e=s[0],t=s[1];if(e.baseType==="directedPair"&&t.baseType==="directedPair"&&e.cardinality==="multiple"){let r=e.value,i=t.value;return r.filter(l=>i.includes(l)).length>0}else if(e.baseType==="directedPair"&&t.baseType==="directedPair"&&e.cardinality==="single"){let r=e.value;return t.value.includes(r)}else console.error("unsupported baseType or cardinality in qti contains, only baseType: directedPair and cardinality: multiple is supported")}else console.error("unexpected number of children in qti contains");return!1}};customElements.define("qti-contains",vt);var yt=class extends q{get interpretation(){return this.getAttribute("interpretation")||""}getResult(){let s=this.getAttribute("identifier")||"",e=this.context.variables.find(t=>t.identifier===s)||null;return e.cardinality!=="single"?e.correctResponse.length>0?e.correctResponse[0]:"":e.correctResponse}};customElements.define("qti-correct",yt);var tt=class extends q{constructor(){super(...arguments);this.roundingMode="significantFigures"}get figures(){if(!this.getAttribute("figures"))return console.error("figures attribute is missing"),null;let t=parseInt(this.getAttribute("figures")||"0");return isNaN(t)?(console.error("figures attribute is not a number"),null):t<0?(console.error("figures attribute is negative"),null):t<1&&this.roundingMode==="significantFigures"?(console.error("figures cannot be smaller than 1 for RoundingMode significantFigures"),null):t}getResult(){if(this.children.length===2){let e=this.getVariables(),t=e[0],r=e[1];if(this.roundingMode===null)return null;if(t.cardinality!=="single"||r.cardinality!=="single"||Array.isArray(t.value)||Array.isArray(r.value))return console.error("unexpected cardinality in qti equal"),!1;switch(e[0].baseType){case"integer":case"float":{let i=parseFloat(t.value),a=parseFloat(r.value);if(!isNaN(i)&&!isNaN(a))return this.roundingMode==="significantFigures"?i.toPrecision(this.figures)===a.toPrecision(this.figures):Math.round(i*Math.pow(10,this.figures))/Math.pow(10,this.figures)===Math.round(a*Math.pow(10,this.figures))/Math.pow(10,this.figures);console.error(`value cannot be casted to numeric value in equalRounded operator: ${i}, ${a}`);break}default:{console.error("values other than float and int cannot be used in equalRounded operator.");break}}return!1}return console.error("unexpected number of children in qti-equal-rounded"),null}};n([u({type:String})],tt.prototype,"roundingMode",2);customElements.define("qti-equal-rounded",tt);var A=class{static isPointInArea(s,e,t){if(t!=="point")return console.warn(`Base type ${t} is not supported for point area mapping.`),!1;let[r,i]=s.split(" ").map(Number),[a,...o]=e.split(","),l=o.map(Number);switch(a.toLowerCase()){case"circle":case"default":{let[c,d,m]=l;return l.length!==3?(console.warn(`Invalid circle definition: ${e}`),!1):Math.sqrt((r-c)**2+(i-d)**2)<=m}case"rect":{let[c,d,m,g]=l;return l.length!==4?(console.warn(`Invalid rectangle definition: ${e}`),!1):r>=c&&r<=m&&i>=d&&i<=g}case"ellipse":{let[c,d,m,g]=l;if(l.length!==4)return console.warn(`Invalid ellipse definition: ${e}`),!1;let v=(r-c)**2/m**2,E=(i-d)**2/g**2;return v+E<=1}case"poly":{if(l.length<6||l.length%2!==0)return console.warn(`Invalid polygon definition: ${e}`),!1;let c=[];for(let d=0;d<l.length;d+=2)c.push({x:l[d],y:l[d+1]});return this.isPointInPolygon({x:r,y:i},c)}default:return console.warn(`Unsupported shape type: ${a}`),!1}}static isPointInPolygon(s,e){let t=!1;for(let r=0,i=e.length-1;r<e.length;i=r++){let a=e[r].x,o=e[r].y,l=e[i].x,c=e[i].y;o>s.y!=c>s.y&&s.x<(l-a)*(s.y-o)/(c-o)+a&&(t=!t)}return t}static compareSingleValues(s,e,t){switch(t){case"identifier":case"string":return s===e;case"integer":{let r=parseInt(s,10),i=parseInt(e,10);if(!isNaN(r)&&!isNaN(i))return r===i;console.error(`Cannot convert ${s} and/or ${e} to int.`);break}case"float":{let r=parseFloat(s),i=parseFloat(e);if(!isNaN(r)&&!isNaN(i))return r===i;console.error(`couldn't convert ${s} and/or ${e} to float.`);break}case"pair":case"directedPair":{let r=s.split(" ").sort(),i=e.split(" ").sort();if(r.length===2&&i.length===2)return t==="pair"&&(r.sort(),i.sort()),r.join(" ")===i.join(" ");console.error(`compared two pair but one of the values does not have 2 values: 1: ${s} 2: ${e}`);break}}return!1}};var rt=class extends q{constructor(){super(...arguments);this.toleranceMode="exact"}getResult(){if(this.children.length===2){let e=this.getVariables(),t=e[0],r=e[1];return this.toleranceMode!=="exact"?(console.error("toleranceMode is not supported yet"),!1):t.cardinality!=="single"||r.cardinality!=="single"||Array.isArray(t.value)||Array.isArray(r.value)?(console.error("unexpected cardinality in qti equal"),!1):A.compareSingleValues(t.value,r.value,t.baseType)}return console.error("unexpected number of children in qti-equal"),null}};n([u({type:String})],rt.prototype,"toleranceMode",2);customElements.define("qti-equal",rt);var xt=class extends q{getResult(){if(this.children.length===2){let s=this.getVariables(),e=s[0],t=s[1];if((e.baseType==="integer"||e.baseType==="float")&&(t.baseType==="integer"||t.baseType==="float"))return+e.value>+t.value;console.error("unexpected baseType or cardinality in qti gt")}return console.error("unexpected number of children in qt"),null}};customElements.define("qti-gt",xt);var Et=class extends N{getResult(){if(this.children.length===2){let s=this.getVariables(),e=s[0],t=s[1];return(e.baseType==="integer"||e.baseType==="float")&&(t.baseType==="integer"||t.baseType==="float")?+e.value>=+t.value:(console.error("unexpected baseType or cardinality in qti gte"),null)}return console.log("unexpected number of children in qte"),null}};customElements.define("qti-gte",Et);var Ct=class extends q{getResult(){if(this.children.length===1){let s=this.getVariables();if(!s)return!0;let e=s[0].value;return e==null||e==null||e===""}return console.error("unexpected number of children in qti Null"),null}};customElements.define("qti-is-null",Ct);var qt=class extends q{getResult(){if(this.children.length===2){let s=this.getVariables(),e=s[0],t=s[1];if((e.baseType==="integer"||e.baseType==="float")&&(t.baseType==="integer"||t.baseType==="float"))return+e.value<+t.value;console.error("unexpected baseType or cardinality in qti lt")}return console.error("unexpected number of children in lt"),null}};customElements.define("qti-lt",qt);var wt=class extends N{getResult(){if(this.children.length===2){let s=this.getVariables(),e=s[0],t=s[1];return(e.baseType==="integer"||e.baseType==="float")&&(t.baseType==="integer"||t.baseType==="float")?+e.value<=+t.value:(console.error("unexpected baseType or cardinality in qti lte"),null)}return console.log("unexpected number of children in lte"),null}};customElements.define("qti-lte",wt);var it=class extends q{getResult(){let s=this.context.variables.find(i=>i.identifier===this.identifier);if(!s||!s.mapping)return console.error(`Response ${this.identifier} can not be found`),null;let e=s.mapping,t=Array.isArray(s.value)?s.value:[s.value],r=0;for(let i of t){let a=e.mapEntries.filter(l=>s.baseType==="string"&&!l.caseSensitive?A.compareSingleValues(l.mapKey.toLowerCase(),i.toLowerCase(),s.baseType):A.compareSingleValues(l.mapKey,i,s.baseType)),o=a.reduce((l,c)=>l.mappedValue>c.mappedValue?l:c,a.length>0?a[0]:{mapKey:null,mappedValue:null});o===null||o.mappedValue==null?r+=e.defaultValue:r+=o.mappedValue}return e?.lowerBound!==null&&e?.lowerBound!==void 0&&(r=Math.max(e.lowerBound,r)),e?.upperBound!==null&&e?.upperBound!==void 0&&(r=Math.min(e.upperBound,r)),r}};n([u({type:String})],it.prototype,"identifier",2);customElements.define("qti-map-response",it);var K=class extends y{constructor(){super(...arguments);this.getVariables=()=>Array.from(this.children).map(e=>{switch(e.tagName.toLowerCase()){case"qti-base-value":return{baseType:e.getAttribute("base-type"),value:e.textContent.trim(),cardinality:"single"};case"qti-variable":{let t=e.getAttribute("identifier")||"";return this.context.variables.find(i=>i.identifier===t)||null}case"qti-multiple":{let r=e.getResult();return r.length>0?{identifier:"",baseType:r[0].baseType,value:r.map(i=>i.value),cardinality:"multiple",type:"response"}:null}case"qti-correct":{let t=e.getAttribute("identifier")||"",r=this.context.variables.find(i=>i.identifier===t)||null;return{baseType:r.baseType,value:r.correctResponse,cardinality:r.cardinality}}default:{try{return{baseType:"integer",value:e.getResult().toString(),cardinality:"single"}}catch{console.warn("default not sufficient")}return null}}}).filter(e=>e!==null)}render(){return h`<pre>${JSON.stringify(this.result,null,2)}</pre>
1412
+ <slot></slot>`}calculate(){return this.result=this.getResult(),this.result}getResult(){throw new Error("Not implemented")}};K.styles=b`
1413
+ slot {
1414
+ display: none;
1415
+ }
1416
+ `,n([x()],K.prototype,"result",2),n([_({context:T,subscribe:!0}),x()],K.prototype,"context",2);var st=class extends K{getResult(){let s=this.context.variables.find(a=>a.identifier===this.identifier);if(!s)return console.warn(`Response ${this.identifier} cannot be found`),null;let e=s.areaMapping;if(!e)return console.warn(`Area mapping not found for response ${this.identifier}`),null;let t=Array.isArray(s.value)?s.value:[s.value];if(!t||t.length===0)return console.warn(`No candidate responses for response ${this.identifier}`),null;let r=0,i=new Set;for(let a of t)for(let o of e.areaMapEntries){if(i.has(o.coords))continue;A.isPointInArea(a,`${o.shape},${o.coords}`,s.baseType)&&(r+=o.mappedValue??0,i.add(o.coords))}return i.size<t.length&&(r+=e.defaultValue),e.lowerBound!=null&&(r=Math.max(e.lowerBound,r)),e.upperBound!=null&&(r=Math.min(e.upperBound,r)),r}};n([u({type:String})],st.prototype,"identifier",2);customElements.define("qti-map-response-point",st);var Rt=class p extends q{getResult(){if(this.children.length===2){let s=this.getVariables(),e=s[0],t=s[1];return p.match(e,t)}return console.error("unexpected number of children in match"),null}static match(s,e){if(s.value===null)return!1;switch(e.cardinality){case"single":return Array.isArray(s.value)||Array.isArray(e.value)?(console.error("unexpected cardinality in qti match"),!1):A.compareSingleValues(s.value?.toString(),e.value.toString(),e.baseType);case"ordered":{if(!Array.isArray(s.value)||!Array.isArray(e.value))return console.error("unexpected cardinality in qti match"),!1;if(s.value.length!==e.value.length)return!1;for(let t=0;t<s.value.length;t++)if(!A.compareSingleValues(e.value[t],s.value[t],e.baseType))return!1;return!0}case"multiple":{if(!Array.isArray(s.value)||!Array.isArray(e.value))return console.error("unexpected cardinality in qti match"),!1;if(s.value.length!==e.value.length)return!1;let t=0;for(let r of e.value){let i=null,a=[...s.value];for(let o of a)if(A.compareSingleValues(r,o,e.baseType)){i=o;break}if(i!==null)a.splice(a.indexOf(i),1);else return!1;t++}return!0}default:return console.error("unexpected cardinality in qti match"),!1}}};customElements.define("qti-match",Rt);var Tt=class extends q{getResult(){let s=this.getVariables();this.children.length!==2&&console.warn("The member operator takes two sub-expressions");let[e,t]=s;if(e.baseType===t.baseType||e.baseType==="integer"&&t.baseType==="float"||e.baseType==="float"&&t.baseType==="integer"||console.warn("Which must both have the same base-type"),t.cardinality==="multiple"||t.cardinality==="ordered"||console.warn("and the second must be a multiple or ordered container"),(e.baseType==="float"||t.baseType==="float")&&console.warn("The member operator should not be used on sub-expressions with a base-type of float"),(e.baseType==="duration"||t.baseType==="duration")&&console.warn("It must not be used on sub-expressions with a base-type of duration"),e.value===null||t.value===null)return null;let r=e.value;return t.value.includes(r)}};customElements.define("qti-member",Tt);var St=class extends q{getResult(){let s=this.getVariables();if(s.length===0)return console.error("unexpected number of children in qti multiple"),null;for(let e of s)if(e.cardinality!=="multiple"&&e.cardinality!=="single")return console.error("unexpected cardinality in qti multiple"),[];return s}};customElements.define("qti-multiple",St);var Mt=class extends q{render(){return h`${super.render()}`}getResult(){return!this.firstElementChild.calculate()}};customElements.define("qti-not",Mt);var _t=class extends N{getResult(){return Array.from(this.children).map(e=>{let t=e;if(!t.calculate)return console.error("Element doesn't implement QtiConditionExpression"),null;let r=t.calculate(),i=!1;if(typeof r=="string")if(r==="true")i=!0;else if(r==="false")i=!1;else return console.error("unexpected val in qti-or, expected boolean"),null;else typeof r=="boolean"&&(i=r);return i}).some(e=>typeof e=="boolean"&&e)}};customElements.define("qti-or",_t);var kt=class extends q{getResult(){let s=this.getVariables();if(s.length===0)return console.error("unexpected number of children in qti multiple"),null;for(let e of s)if(e.cardinality!=="ordered"&&e.cardinality!=="single")return console.error("unexpected cardinality in qti ordered"),[];return s}};customElements.define("qti-ordered",kt);var Be=class extends y{render(){let s=this.context?.variables.find(e=>e.identifier===this.identifier)?.value;return s===null?k:h`${JSON.stringify(s,null,2)}`}calculate(){return this.context.variables.find(e=>e.identifier===this.identifier)||null}};n([u({type:String})],Be.prototype,"identifier",2),n([_({context:T,subscribe:!0}),x()],Be.prototype,"context",2);customElements.define("qti-printed-variable",Be);var At=class extends q{getResult(){return this.getVariables().reduce((t,r)=>{if(r.baseType=="float"||r.baseType=="integer")try{return t*parseInt(r.value.toString())}catch{console.warn("can not convert to number")}else console.warn(`has another baseType ${r.baseType}`);return t},1)}};customElements.define("qti-product",At);var ot=class extends gr(q){getResult(){return this.calculateChildren(Array.from(this.children))}};function gr(p){return class extends p{calculateChildren(e){let t=e.map(r=>{if(!r.calculate)return console.error("Element doesn't implement QtiConditionExpression"),null;let i=r.calculate();return Number.isNaN(i)?(console.error("Unexpected value in qti-subtract, expected number"),null):Number(i)});return t.some(r=>r===null)?(console.error("One or more child expressions returned invalid values"),0):t[0]-t[1]}}}customElements.define("qti-subtract",ot);var nt=class extends q{constructor(){super(...arguments);this.caseSensitive="true"}getResult(){if(this.children.length===2){let e=this.getVariables(),t=e[0],r=e[1];if(t.cardinality!=="single"||r.cardinality!=="single"||Array.isArray(t.value)||Array.isArray(r.value))return console.error("unexpected cardinality in qti string-match"),!1;let i=this.caseSensitive==="true"?t.value:t.value.toLowerCase(),a=this.caseSensitive==="true"?r.value:r.value.toLowerCase();return A.compareSingleValues(i,a,t.baseType)}return console.error("unexpected number of children in qti-string-match"),null}};n([u({type:String,attribute:"case-sensitive"})],nt.prototype,"caseSensitive",2);customElements.define("qti-string-match",nt);var Lt=class extends q{constructor(){super(),this._expression=new It(Array.from(this.children))}getResult(){return this._expression.calculate()}},It=class{constructor(s){this.expressions=s}calculate(){return this.expressions.map(e=>{if(!e.calculate)return console.error("Element doesn't implement QtiConditionExpression"),null;let t=e.calculate();return Number.isNaN(t)?(console.error("unexpected value in qti-sum, expected number"),null):Number(t)}).reduce((e,t)=>e+t,0)}};customElements.define("qti-sum",Lt);var Dt=class extends q{getResult(){let s=this.getAttribute("identifier");return this.context.variables.find(t=>t.identifier===s).value}};customElements.define("qti-variable",Dt);var Vt=class extends q{getResult(){let s=this.getVariables();if(s.length===1){let e=s[0].value;if(Array.isArray(e)){let t=Math.floor(Math.random()*e.length);return e[t]}return e}return console.error("unexpected number of children in match"),null}};customElements.define("qti-random",Vt);var $t=class extends K{getResult(){if(this.children.length===2){let s=this.getVariables(),e=s[0],t=s[1];return e.cardinality!=="single"||!Array.isArray(t.value)?(console.error("unexpected cardinality in qti equal"),null):s[0].baseType!==s[1].baseType?(console.error("The baseType of the two variables is different"),null):t.value.filter(i=>!e.value.includes(i))}}};customElements.define("qti-delete",$t);var at=class extends y{render(){return h`<slot></slot>`}};at=n([f("qti-content-body")],at);var U=class extends y{handleclassNamesChange(){this.classNames.split(" ").forEach(e=>{switch(e){case"qti-rubric-discretionary-placement":this.setAttribute("slot","qti-rubric-block");break;case"qti-rubric-inline":this.setAttribute("slot","");break;default:break}})}render(){return h`<slot></slot>`}};U.styles=b`
1417
+ :host {
1418
+ display: block;
1419
+ }
1420
+ `,n([u({type:String})],U.prototype,"id",2),n([u({type:String})],U.prototype,"use",2),n([u({type:String})],U.prototype,"view",2),n([u({type:String,attribute:"class"})],U.prototype,"classNames",2),n([S("classNames",{waitUntilFirstUpdate:!0})],U.prototype,"handleclassNamesChange",1),U=n([f("qti-rubric-block")],U);var lt=class extends y{constructor(){super(...arguments);this.styleElement=null}firstUpdated(e){super.firstUpdated(e);let t=this.getAttribute("href");if(t!==null&&fetch(t).then(r=>r.text()).then(r=>{let i=this.minifyCss(r);this.styleElement=document.createElement("style"),this.styleElement.media="screen",this.styleElement.textContent=`@scope {${i}}`,this.parentElement?this.parentElement.appendChild(this.styleElement):console.warn("No parent element to append the scoped stylesheet to.")}).catch(r=>{console.error("Failed to load stylesheet:",r)}),this.textContent!==null&&this.textContent.trim()!==""){let r=this.minifyCss(this.textContent);this.styleElement=document.createElement("style"),this.styleElement.media="screen",this.styleElement.textContent=`@scope {${r}}`,this.parentElement?this.parentElement.appendChild(this.styleElement):console.warn("No parent element to append the scoped stylesheet to.")}}minifyCss(e){return e.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\s+/g," ").replace(/\s*([{}:;])\s*/g,"$1").trim()}disconnectedCallback(){if(this.styleElement)try{this.styleElement.remove()}catch(e){console.error("Could not remove stylesheet:",e)}super.disconnectedCallback()}};lt=n([f("qti-stylesheet")],lt);var ne=class extends y{render(){return h`<slot></slot>`}defaultValues(s){let e=Array.from(this.querySelectorAll("qti-default-value > qti-value"));if(e.length===0)return null;let t=e.map(r=>r.innerHTML.trim());return t.length>1||s.cardinality==="multiple"||s.cardinality==="ordered"?t:t[0]}};ne=n([f("qti-variabledeclaration")],ne);var j=class extends ne{constructor(){super(...arguments);this.externalScored=null}render(){let e=this.itemContext?.variables.find(t=>t.identifier===this.identifier)?.value;return h`${JSON.stringify(e,null,2)}`}get interpolationTable(){let e=this.querySelector("qti-interpolation-table");if(e){let t=new Map;for(let r of e.querySelectorAll("qti-interpolation-table-entry")){!r.getAttribute("source-value")&&r.getAttribute("target-value")&&console.error("source-value or target-value is missing in qti-interpolation-table-entry");let i=parseInt(r.getAttribute("source-value")),a=parseInt(r.getAttribute("target-value"));(isNaN(i)||isNaN(a))&&console.error("source-value or target-value is not a number in qti-interpolation-table-entry"),t.set(i,a)}return t}return null}connectedCallback(){super.connectedCallback();let e={identifier:this.identifier,cardinality:this.cardinality,baseType:this.baseType,type:"outcome",value:null,interpolationTable:this.interpolationTable,externalScored:this.externalScored};e.value=this.defaultValues(e),(e.value===null||e.value==null)&&(e.baseType==="integer"||e.baseType==="float")&&(e.value="0"),this.dispatchEvent(new CustomEvent("qti-register-variable",{bubbles:!0,composed:!0,detail:{variable:e}}))}};j.styles=[b`
1421
+ :host {
1422
+ display: none;
1423
+ }
1424
+ `],n([u({type:String,attribute:"base-type"})],j.prototype,"baseType",2),n([u({type:String,attribute:"external-scored"})],j.prototype,"externalScored",2),n([u({type:String})],j.prototype,"identifier",2),n([u({type:String})],j.prototype,"cardinality",2),n([_({context:T,subscribe:!0}),x()],j.prototype,"itemContext",2),j=n([f("qti-outcome-declaration")],j);var Z=class extends ne{render(){let s=this.itemContext?.variables.find(e=>e.identifier===this.identifier)?.value;return h`${JSON.stringify(s,null,2)}`}connectedCallback(){super.connectedCallback();let s={baseType:this.baseType,identifier:this.identifier,correctResponse:this.correctResponse,cardinality:this.cardinality||"single",mapping:this.mapping,areaMapping:this.areaMapping,value:null,type:"response",candidateResponse:null};s.value=this.defaultValues(s),this.dispatchEvent(new CustomEvent("qti-register-variable",{bubbles:!0,composed:!0,detail:{variable:s}}))}get correctResponse(){let s,e=this.querySelector("qti-correct-response");if(e){let t=e.querySelectorAll("qti-value");if(this.cardinality==="single"&&t.length>0)s=t[0].textContent.trim(),t[0].remove();else if(this.cardinality!=="single"){s=[];for(let r=0;r<t.length;r++)s.push(t[r].textContent.trim()),t[r].remove()}}return s}get mapping(){let s=this.querySelector("qti-mapping"),e=parseInt(s?.getAttribute("lower-bound")),t=parseInt(s?.getAttribute("upper-bound"));return{defaultValue:Number(s?.getAttribute("default-value"))||0,lowerBound:isNaN(e)?null:e,upperBound:isNaN(t)?null:t,mapEntries:Array.from(s?.querySelectorAll("qti-map-entry")||[]).map(i=>({mapKey:i.getAttribute("map-key")||"",mappedValue:Number(i.getAttribute("mapped-value"))||0,caseSensitive:i.hasAttribute("case-sensitive")?i.getAttribute("case-sensitive")!=="false":!0}))}}get areaMapping(){let s=this.querySelector("qti-area-mapping"),e=Number(s?.getAttribute("default-value"))||0,t=parseInt(s?.getAttribute("lower-bound")),r=parseInt(s?.getAttribute("upper-bound")),i=Array.from(s?.querySelectorAll("qti-area-map-entry")||[]).map(a=>({shape:a.getAttribute("shape")||"default",coords:a.getAttribute("coords")||"",mappedValue:Number(a.getAttribute("mapped-value"))||0,defaultValue:Number(a.getAttribute("default-value"))||0}));return{defaultValue:e,lowerBound:isNaN(t)?null:t,upperBound:isNaN(r)?null:r,areaMapEntries:i}}};Z.styles=[b`
1425
+ :host {
1426
+ display: none;
1427
+ }
1428
+ `],n([u({type:String,attribute:"base-type"})],Z.prototype,"baseType",2),n([u({type:String})],Z.prototype,"identifier",2),n([u({type:String})],Z.prototype,"cardinality",2),n([_({context:T,subscribe:!0}),x()],Z.prototype,"itemContext",2),Z=n([f("qti-response-declaration")],Z);export{D as a,fe as b,We as c,qe as d,Re as e,Te as f,Se as g,Me as h,ge as i,be as j,B as k,re as l,L as m,ve as n,_e as o,ye as p,xe as q,z as r,ke as s,Ae as t,le as u,Le as v,Ge as w,Ie as x,se as y,Ve as z,oe as A,J as B,$e as C,X as D,M as E,Ke as F,Ne as G,Y as H,W as I,G as J,$ as K,Oe as L,He as M,Pe as N,ht as O,Ze as P,ze as Q,F as R,Fe as S,mt as T,ft as U,gt as V,Ue as W,je as X,bt as Y,Qe as Z,fr as _,et as $,vt as aa,yt as ba,tt as ca,rt as da,xt as ea,Et as fa,Ct as ga,qt as ha,wt as ia,it as ja,st as ka,Rt as la,Tt as ma,St as na,Mt as oa,_t as pa,kt as qa,Be as ra,At as sa,ot as ta,gr as ua,nt as va,Lt as wa,It as xa,Dt as ya,Vt as za,$t as Aa,at as Ba,U as Ca,lt as Da,j as Ea,Z as Fa};
1429
+ /*! Bundled license information:
1430
+
1431
+ lit-html/node/directives/if-defined.js:
1432
+ (**
1433
+ * @license
1434
+ * Copyright 2018 Google LLC
1435
+ * SPDX-License-Identifier: BSD-3-Clause
1436
+ *)
1437
+
1438
+ lit-html/node/directives/repeat.js:
1439
+ (**
1440
+ * @license
1441
+ * Copyright 2017 Google LLC
1442
+ * SPDX-License-Identifier: BSD-3-Clause
1443
+ *)
1444
+
1445
+ lit-html/node/directives/unsafe-html.js:
1446
+ (**
1447
+ * @license
1448
+ * Copyright 2017 Google LLC
1449
+ * SPDX-License-Identifier: BSD-3-Clause
1450
+ *)
1451
+
1452
+ lit-html/node/directives/style-map.js:
1453
+ (**
1454
+ * @license
1455
+ * Copyright 2018 Google LLC
1456
+ * SPDX-License-Identifier: BSD-3-Clause
1457
+ *)
1458
+
1459
+ lit-html/node/directives/ref.js:
1460
+ (**
1461
+ * @license
1462
+ * Copyright 2020 Google LLC
1463
+ * SPDX-License-Identifier: BSD-3-Clause
1464
+ *)
1465
+ */