@citolab/qti-components 7.0.4 → 7.0.5

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 (285) hide show
  1. package/cdn/chunks/chunk-4UJBK6JO.js +1 -0
  2. package/cdn/chunks/chunk-5FCXUJAG.js +23 -0
  3. package/cdn/chunks/chunk-5O3Z7TDV.js +1 -0
  4. package/cdn/chunks/chunk-65LFT33L.js +8 -0
  5. package/cdn/chunks/chunk-6D25UFJR.js +8 -0
  6. package/cdn/chunks/chunk-6DMSHH5X.js +0 -0
  7. package/cdn/chunks/chunk-6UGPNL7M.js +1 -0
  8. package/cdn/chunks/chunk-CFXQCNG6.js +3523 -0
  9. package/cdn/chunks/chunk-CSUKVUZF.js +3 -0
  10. package/cdn/chunks/chunk-CSY3WI5A.js +1 -0
  11. package/cdn/chunks/chunk-DAZR7RUI.js +0 -0
  12. package/cdn/chunks/chunk-EHK76KRT.js +1 -0
  13. package/cdn/chunks/chunk-EOPEMJS3.js +0 -0
  14. package/cdn/chunks/chunk-G5O7EN45.js +5 -0
  15. package/cdn/chunks/chunk-GEFUIFM7.js +0 -0
  16. package/cdn/chunks/chunk-JLNHEMQG.js +1 -0
  17. package/cdn/chunks/chunk-LPWIM7QJ.js +902 -0
  18. package/cdn/chunks/chunk-M3YRM3AV.js +1 -0
  19. package/cdn/chunks/chunk-M6BOWL2U.js +1 -0
  20. package/cdn/chunks/chunk-P5IE36FO.js +8 -0
  21. package/cdn/chunks/chunk-PXH5KN5O.js +1 -0
  22. package/cdn/chunks/chunk-RBEI6NIF.js +1 -0
  23. package/cdn/chunks/chunk-SMKIYFFI.js +1 -0
  24. package/cdn/chunks/chunk-SRLMW23F.js +0 -0
  25. package/cdn/chunks/chunk-T3YDLD2H.js +11 -0
  26. package/cdn/chunks/chunk-T4HD2C4F.js +1 -0
  27. package/cdn/chunks/chunk-T6IXJ4W4.js +1 -0
  28. package/cdn/chunks/chunk-TFAUBGP2.js +0 -0
  29. package/cdn/chunks/chunk-UIEC4LXR.js +17 -0
  30. package/cdn/chunks/chunk-V44O3GTW.js +0 -0
  31. package/cdn/chunks/chunk-V6B54FQW.js +5 -0
  32. package/cdn/chunks/chunk-V6KX6BQN.js +1 -0
  33. package/cdn/chunks/chunk-VYANBI35.js +1 -0
  34. package/cdn/chunks/chunk-XUJ7TXHW.js +1 -0
  35. package/cdn/chunks/chunk-ZIZLFFSG.js +0 -0
  36. package/cdn/index.css +1 -0
  37. package/cdn/index.global.js +45 -45
  38. package/cdn/index.js +196 -476
  39. package/cdn/qti-components/index.global.js +226 -0
  40. package/cdn/qti-components/index.js +924 -0
  41. package/cdn/qti-item/components/index.css +1 -0
  42. package/cdn/qti-item/components/index.global.js +149 -0
  43. package/cdn/qti-item/components/index.js +3549 -0
  44. package/cdn/qti-item/components/item-container.css +1 -0
  45. package/cdn/qti-item/components/item-container.global.js +149 -0
  46. package/cdn/qti-item/components/item-container.js +3549 -0
  47. package/cdn/qti-item/index.css +1 -0
  48. package/cdn/qti-item/index.global.js +149 -0
  49. package/cdn/qti-item/index.js +3549 -0
  50. package/cdn/qti-item/qti-item.global.js +114 -0
  51. package/cdn/qti-item/qti-item.js +1 -0
  52. package/cdn/qti-loader/index.global.js +1 -0
  53. package/cdn/qti-loader/index.js +23 -0
  54. package/cdn/qti-test/components/index.css +1 -0
  55. package/cdn/qti-test/components/index.global.js +242 -0
  56. package/cdn/qti-test/components/index.js +3598 -0
  57. package/cdn/qti-test/components/styles.global.js +44 -0
  58. package/cdn/qti-test/components/styles.js +17 -0
  59. package/cdn/qti-test/components/test-component.abstract.global.js +170 -0
  60. package/cdn/qti-test/components/test-component.abstract.js +1 -0
  61. package/cdn/qti-test/components/test-container.css +1 -0
  62. package/cdn/qti-test/components/test-container.global.js +149 -0
  63. package/cdn/qti-test/components/test-container.js +3549 -0
  64. package/cdn/qti-test/components/test-item-link.global.js +170 -0
  65. package/cdn/qti-test/components/test-item-link.js +24 -0
  66. package/cdn/qti-test/components/test-next.global.js +170 -0
  67. package/cdn/qti-test/components/test-next.js +24 -0
  68. package/cdn/qti-test/components/test-next.spec.css +1 -0
  69. package/cdn/qti-test/components/test-next.spec.global.js +297 -0
  70. package/cdn/qti-test/components/test-next.spec.js +5215 -0
  71. package/cdn/qti-test/components/test-paging-buttons-stamp.global.js +207 -0
  72. package/cdn/qti-test/components/test-paging-buttons-stamp.js +3 -0
  73. package/cdn/qti-test/components/test-prev.global.js +170 -0
  74. package/cdn/qti-test/components/test-prev.js +24 -0
  75. package/cdn/qti-test/components/test-view.global.js +170 -0
  76. package/cdn/qti-test/components/test-view.js +11 -0
  77. package/cdn/qti-test/context/index.global.js +58 -0
  78. package/cdn/qti-test/context/index.js +1 -0
  79. package/cdn/qti-test/context/test.context.global.js +58 -0
  80. package/cdn/qti-test/context/test.context.js +1 -0
  81. package/cdn/qti-test/index.css +1 -0
  82. package/cdn/qti-test/index.global.js +242 -0
  83. package/cdn/qti-test/index.js +3598 -0
  84. package/cdn/qti-test/mixins/index.global.js +1 -0
  85. package/cdn/qti-test/mixins/index.js +23 -0
  86. package/cdn/qti-test/mixins/test-loader.mixin.global.js +1 -0
  87. package/cdn/qti-test/mixins/test-loader.mixin.js +23 -0
  88. package/cdn/qti-test/mixins/test-navigation.mixin.global.js +1 -0
  89. package/cdn/qti-test/mixins/test-navigation.mixin.js +1 -0
  90. package/cdn/qti-test/mixins/test-view.mixin.global.js +1 -0
  91. package/cdn/qti-test/mixins/test-view.mixin.js +1 -0
  92. package/cdn/qti-test/qti-assessment-test/index.global.js +170 -0
  93. package/cdn/qti-test/qti-assessment-test/index.js +1 -0
  94. package/cdn/qti-test/qti-assessment-test/qti-assessment-item-ref.global.js +170 -0
  95. package/cdn/qti-test/qti-assessment-test/qti-assessment-item-ref.js +1 -0
  96. package/cdn/qti-test/qti-assessment-test/qti-assessment-section.global.js +170 -0
  97. package/cdn/qti-test/qti-assessment-test/qti-assessment-section.js +1 -0
  98. package/cdn/qti-test/qti-assessment-test/qti-assessment-test.global.js +170 -0
  99. package/cdn/qti-test/qti-assessment-test/qti-assessment-test.js +1 -0
  100. package/cdn/qti-test/qti-assessment-test/qti-test-part.global.js +114 -0
  101. package/cdn/qti-test/qti-assessment-test/qti-test-part.js +1 -0
  102. package/cdn/qti-test/qti-test.global.js +170 -0
  103. package/cdn/qti-test/qti-test.js +23 -0
  104. package/cdn/qti-test/test-base.global.js +170 -0
  105. package/cdn/qti-test/test-base.js +1 -0
  106. package/cdn/qti-transformers/index.global.js +1 -0
  107. package/cdn/qti-transformers/index.js +23 -0
  108. package/dist/chunks/chunk-3G2DDBJW.js +44 -0
  109. package/dist/chunks/chunk-3G2DDBJW.js.map +1 -0
  110. package/dist/chunks/chunk-3NLCJYSX.js +1 -0
  111. package/dist/chunks/chunk-3NLCJYSX.js.map +1 -0
  112. package/dist/chunks/chunk-3OXGDCSU.js +6253 -0
  113. package/dist/chunks/chunk-3OXGDCSU.js.map +1 -0
  114. package/dist/chunks/chunk-3ROZMGAN.js +43 -0
  115. package/dist/chunks/chunk-3ROZMGAN.js.map +1 -0
  116. package/dist/chunks/chunk-4O5F7WV7.js +30 -0
  117. package/dist/chunks/chunk-4O5F7WV7.js.map +1 -0
  118. package/dist/chunks/chunk-6YE2KJ4C.js +55 -0
  119. package/dist/chunks/chunk-6YE2KJ4C.js.map +1 -0
  120. package/dist/chunks/chunk-AAQCM2FP.js +56 -0
  121. package/dist/chunks/chunk-AAQCM2FP.js.map +1 -0
  122. package/dist/chunks/chunk-D3RGDWKP.js +37 -0
  123. package/dist/chunks/chunk-D3RGDWKP.js.map +1 -0
  124. package/dist/chunks/chunk-DJLE6EV2.js +36 -0
  125. package/dist/chunks/chunk-DJLE6EV2.js.map +1 -0
  126. package/dist/chunks/chunk-ELDMXTUQ.js +31 -0
  127. package/dist/chunks/chunk-ELDMXTUQ.js.map +1 -0
  128. package/dist/chunks/chunk-EW5CTHAD.js +1 -0
  129. package/dist/chunks/chunk-EW5CTHAD.js.map +1 -0
  130. package/dist/chunks/chunk-HWA4A3SR.js +50 -0
  131. package/dist/chunks/chunk-HWA4A3SR.js.map +1 -0
  132. package/dist/chunks/chunk-IKZWK2C5.js +1 -0
  133. package/dist/chunks/chunk-IKZWK2C5.js.map +1 -0
  134. package/dist/chunks/chunk-IP7JSYO6.js +1 -0
  135. package/dist/chunks/chunk-IP7JSYO6.js.map +1 -0
  136. package/dist/chunks/chunk-JE6BMXZU.js +94 -0
  137. package/dist/chunks/chunk-JE6BMXZU.js.map +1 -0
  138. package/dist/chunks/chunk-JSPJGWGT.js +20 -0
  139. package/dist/chunks/chunk-JSPJGWGT.js.map +1 -0
  140. package/dist/chunks/chunk-LKINC6JO.js +118 -0
  141. package/dist/chunks/chunk-LKINC6JO.js.map +1 -0
  142. package/dist/chunks/chunk-LROTNPC2.js +94 -0
  143. package/dist/chunks/chunk-LROTNPC2.js.map +1 -0
  144. package/dist/chunks/chunk-MTMT2RMF.js +63 -0
  145. package/dist/chunks/chunk-MTMT2RMF.js.map +1 -0
  146. package/dist/chunks/chunk-NDJZGJUR.js +65 -0
  147. package/dist/chunks/chunk-NDJZGJUR.js.map +1 -0
  148. package/dist/chunks/chunk-OE2LFIH2.js +1 -0
  149. package/dist/chunks/chunk-OE2LFIH2.js.map +1 -0
  150. package/dist/chunks/chunk-OJ2XGDWK.js +1 -0
  151. package/dist/chunks/chunk-OJ2XGDWK.js.map +1 -0
  152. package/dist/chunks/chunk-PUBGXXTM.js +50 -0
  153. package/dist/chunks/chunk-PUBGXXTM.js.map +1 -0
  154. package/dist/chunks/chunk-QRCUNRP5.js +75 -0
  155. package/dist/chunks/chunk-QRCUNRP5.js.map +1 -0
  156. package/dist/chunks/chunk-S6JJYCO7.js +51 -0
  157. package/dist/chunks/chunk-S6JJYCO7.js.map +1 -0
  158. package/dist/chunks/chunk-U3AALKEP.js +1 -0
  159. package/dist/chunks/chunk-U3AALKEP.js.map +1 -0
  160. package/dist/chunks/chunk-UCQFSRYF.js +34 -0
  161. package/dist/chunks/chunk-UCQFSRYF.js.map +1 -0
  162. package/dist/chunks/chunk-URGVQ64M.js +1 -0
  163. package/dist/chunks/chunk-URGVQ64M.js.map +1 -0
  164. package/dist/chunks/chunk-V4FXK4TP.js +128 -0
  165. package/dist/chunks/chunk-V4FXK4TP.js.map +1 -0
  166. package/dist/chunks/chunk-W4B23OIP.js +72 -0
  167. package/dist/chunks/chunk-W4B23OIP.js.map +1 -0
  168. package/dist/chunks/chunk-XDFXD3BI.js +10 -0
  169. package/dist/chunks/chunk-XDFXD3BI.js.map +1 -0
  170. package/dist/chunks/chunk-XDMSEAYC.js +294 -0
  171. package/dist/chunks/chunk-XPDS72XY.js +29 -0
  172. package/dist/chunks/chunk-XPDS72XY.js.map +1 -0
  173. package/dist/chunks/chunk-Y6UWSECL.js +3529 -0
  174. package/dist/chunks/chunk-Y6UWSECL.js.map +1 -0
  175. package/dist/chunks/chunk-ZEFOMZNY.js +78 -0
  176. package/dist/chunks/chunk-ZEFOMZNY.js.map +1 -0
  177. package/dist/index-Cvrd4KQA.d.ts +109 -0
  178. package/dist/index.d.ts +18 -503
  179. package/dist/index.js +1666 -4206
  180. package/dist/index.js.map +1 -1
  181. package/dist/item.css +10 -10
  182. package/dist/qti-components/index.d.ts +150 -0
  183. package/dist/qti-components/index.js +6525 -0
  184. package/dist/qti-components/index.js.map +1 -0
  185. package/dist/qti-components-jsx.d.ts +93 -147
  186. package/dist/qti-item/components/index.d.ts +3 -0
  187. package/dist/qti-item/components/index.js +3856 -0
  188. package/dist/qti-item/components/index.js.map +1 -0
  189. package/dist/qti-item/components/item-container.d.ts +40 -0
  190. package/dist/qti-item/components/item-container.js +3856 -0
  191. package/dist/qti-item/components/item-container.js.map +1 -0
  192. package/dist/qti-item/index.d.ts +4 -0
  193. package/dist/qti-item/index.js +3869 -0
  194. package/dist/qti-item/index.js.map +1 -0
  195. package/dist/qti-item/qti-item.d.ts +25 -0
  196. package/dist/qti-item/qti-item.js +26 -0
  197. package/dist/qti-item/qti-item.js.map +1 -0
  198. package/dist/{loader → qti-loader}/index.d.ts +1 -1
  199. package/dist/{qti-simple-choice-D0GiMrqD.d.ts → qti-simple-choice-DxWcdKHi.d.ts} +30 -40
  200. package/dist/qti-test/components/index.d.ts +13 -0
  201. package/dist/qti-test/components/index.js +4144 -0
  202. package/dist/qti-test/components/index.js.map +1 -0
  203. package/dist/qti-test/components/styles.d.ts +8 -0
  204. package/dist/qti-test/components/styles.js +29 -0
  205. package/dist/qti-test/components/styles.js.map +1 -0
  206. package/dist/qti-test/components/test-component.abstract.d.ts +23 -0
  207. package/dist/qti-test/components/test-component.abstract.js +149 -0
  208. package/dist/qti-test/components/test-component.abstract.js.map +1 -0
  209. package/dist/qti-test/components/test-container.d.ts +37 -0
  210. package/dist/qti-test/components/test-container.js +3782 -0
  211. package/dist/qti-test/components/test-container.js.map +1 -0
  212. package/dist/qti-test/components/test-item-link.d.ts +21 -0
  213. package/dist/qti-test/components/test-item-link.js +202 -0
  214. package/dist/qti-test/components/test-item-link.js.map +1 -0
  215. package/dist/qti-test/components/test-next.d.ts +32 -0
  216. package/dist/qti-test/components/test-next.js +209 -0
  217. package/dist/qti-test/components/test-next.js.map +1 -0
  218. package/dist/qti-test/components/test-next.spec.d.ts +16 -0
  219. package/dist/qti-test/components/test-next.spec.js +56915 -0
  220. package/dist/qti-test/components/test-next.spec.js.map +1 -0
  221. package/dist/qti-test/components/test-paging-buttons-stamp.d.ts +22 -0
  222. package/dist/qti-test/components/test-paging-buttons-stamp.js +218 -0
  223. package/dist/qti-test/components/test-paging-buttons-stamp.js.map +1 -0
  224. package/dist/qti-test/components/test-prev.d.ts +32 -0
  225. package/dist/qti-test/components/test-prev.js +209 -0
  226. package/dist/qti-test/components/test-prev.js.map +1 -0
  227. package/dist/qti-test/components/test-view.d.ts +27 -0
  228. package/dist/qti-test/components/test-view.js +209 -0
  229. package/dist/qti-test/components/test-view.js.map +1 -0
  230. package/dist/qti-test/context/index.d.ts +6 -0
  231. package/dist/qti-test/context/index.js +9 -0
  232. package/dist/qti-test/context/index.js.map +1 -0
  233. package/dist/qti-test/context/test.context.d.ts +6 -0
  234. package/dist/qti-test/context/test.context.js +9 -0
  235. package/dist/qti-test/context/test.context.js.map +1 -0
  236. package/dist/qti-test/index.d.ts +14 -0
  237. package/dist/qti-test/index.js +4746 -0
  238. package/dist/qti-test/index.js.map +1 -0
  239. package/dist/qti-test/mixins/index.d.ts +8 -0
  240. package/dist/qti-test/mixins/index.js +350 -0
  241. package/dist/qti-test/mixins/index.js.map +1 -0
  242. package/dist/qti-test/mixins/test-loader.mixin.d.ts +8 -0
  243. package/dist/qti-test/mixins/test-loader.mixin.js +240 -0
  244. package/dist/qti-test/mixins/test-loader.mixin.js.map +1 -0
  245. package/dist/qti-test/mixins/test-navigation.mixin.d.ts +22 -0
  246. package/dist/qti-test/mixins/test-navigation.mixin.js +64 -0
  247. package/dist/qti-test/mixins/test-navigation.mixin.js.map +1 -0
  248. package/dist/qti-test/mixins/test-view.mixin.d.ts +6 -0
  249. package/dist/qti-test/mixins/test-view.mixin.js +50 -0
  250. package/dist/qti-test/mixins/test-view.mixin.js.map +1 -0
  251. package/dist/qti-test/qti-assessment-test/index.d.ts +6 -0
  252. package/dist/qti-test/qti-assessment-test/index.js +221 -0
  253. package/dist/qti-test/qti-assessment-test/index.js.map +1 -0
  254. package/dist/qti-test/qti-assessment-test/qti-assessment-item-ref.d.ts +6 -0
  255. package/dist/qti-test/qti-assessment-test/qti-assessment-item-ref.js +85 -0
  256. package/dist/qti-test/qti-assessment-test/qti-assessment-item-ref.js.map +1 -0
  257. package/dist/qti-test/qti-assessment-test/qti-assessment-section.d.ts +6 -0
  258. package/dist/qti-test/qti-assessment-test/qti-assessment-section.js +73 -0
  259. package/dist/qti-test/qti-assessment-test/qti-assessment-section.js.map +1 -0
  260. package/dist/qti-test/qti-assessment-test/qti-assessment-test.d.ts +6 -0
  261. package/dist/qti-test/qti-assessment-test/qti-assessment-test.js +54 -0
  262. package/dist/qti-test/qti-assessment-test/qti-assessment-test.js.map +1 -0
  263. package/dist/qti-test/qti-assessment-test/qti-test-part.d.ts +19 -0
  264. package/dist/qti-test/qti-assessment-test/qti-test-part.js +62 -0
  265. package/dist/qti-test/qti-assessment-test/qti-test-part.js.map +1 -0
  266. package/dist/qti-test/qti-test.d.ts +68 -0
  267. package/dist/qti-test/qti-test.js +500 -0
  268. package/dist/qti-test/qti-test.js.map +1 -0
  269. package/dist/qti-test/test-base.d.ts +6 -0
  270. package/dist/qti-test/test-base.js +137 -0
  271. package/dist/qti-test/test-base.js.map +1 -0
  272. package/dist/qti-transformers/index.js.map +1 -0
  273. package/dist/test-base-BJwG9Ie8.d.ts +109 -0
  274. package/dist/vscode.html-custom-data.json +49 -38
  275. package/package.json +28 -51
  276. package/dist/custom-element-eslint-rules.js +0 -329
  277. package/dist/custom-elements.json +0 -27271
  278. package/dist/qti-simple-choice-CfgBEvdI.d.ts +0 -1143
  279. package/dist/qti-simple-choice-UTrFa_RQ.d.ts +0 -1177
  280. package/dist/qti-simple-choice-zEsDq3c0.d.ts +0 -1147
  281. /package/dist/{transformers/index.js.map → chunks/chunk-XDMSEAYC.js.map} +0 -0
  282. /package/dist/{loader → qti-loader}/index.js +0 -0
  283. /package/dist/{loader → qti-loader}/index.js.map +0 -0
  284. /package/dist/{transformers → qti-transformers}/index.d.ts +0 -0
  285. /package/dist/{transformers → qti-transformers}/index.js +0 -0
@@ -0,0 +1,902 @@
1
+ import{a as Me}from"./chunk-EHK76KRT.js";import{a as y}from"./chunk-XUJ7TXHW.js";import{a as Rt}from"./chunk-5FCXUJAG.js";import{e as o}from"./chunk-T4HD2C4F.js";import{provide as yr}from"@lit/context";import{LitElement as xr,html as Er}from"lit";import{customElement as Cr,property as Y}from"lit/decorators.js";import{createContext as vr}from"@lit/context";var _t=[{identifier:"completionStatus",cardinality:"single",baseType:"string",value:"unknown",type:"outcome"},{identifier:"numAttempts",cardinality:"single",baseType:"integer",value:"0",type:"response"}],v=vr(Symbol("item"));var x=class extends xr{constructor(){super();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={identifier:this.getAttribute("identifier"),variables:_t};this._initialContext={...this._context,variables:this._context.variables};this._feedbackElements=[];this._interactionElements=[];this.addEventListener("qti-register-variable",e=>{this._context={...this._context,variables:[...this._context.variables,e.detail.variable]},this._initialContext=this._context,e.stopPropagation()}),this.addEventListener("qti-register-feedback",e=>{e.stopPropagation();let t=e.detail;this._feedbackElements.push(t),(Number(this._context.variables.find(s=>s.identifier==="numAttempts")?.value)||0)>0&&t.checkShowFeedback(t.outcomeIdentifier)}),this.addEventListener("qti-register-interaction",e=>{e.stopPropagation(),this._interactionElements.push(e.target)}),this.addEventListener("end-attempt",e=>{let{responseIdentifier:t,countAttempt:r}=e.detail;this.validate(),this.updateResponseVariable(t,"true"),this.processResponse(r)}),this.addEventListener("qti-set-outcome-value",e=>{let{outcomeIdentifier:t,value:r}=e.detail;this.updateOutcomeVariable(t,r),e.stopPropagation()}),this.addEventListener("qti-interaction-response",this.handleUpdateResponseVariable)}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(s=>s.identifier===t.identifier);return r?{...t,...r}:t})},this._context.variables.forEach(t=>{if(t.type==="response"){let r=this._interactionElements.find(s=>s.responseIdentifier===t.identifier);r&&(r.value=t.value)}})}async connectedCallback(){super.connectedCallback(),await this.updateComplete,this._emit("qti-assessment-item-connected",this)}set responses(e){if(e)for(let t of e){this.getResponse(t.responseIdentifier)&&this.updateResponseVariable(t.responseIdentifier,t.response);let s=this._interactionElements.find(l=>l.getAttribute("response-identifier")===t.responseIdentifier);s&&(s.value=t.response)}}render(){return Er`<slot></slot>`}showCorrectResponse(e){let r=this._context.variables.filter(s=>"correctResponse"in s&&s.correctResponse).map(s=>({responseIdentifier:s.identifier,response:s.correctResponse}));for(let s of r){let l=this._interactionElements.find(i=>i.getAttribute("response-identifier")===s.responseIdentifier);l&&(l.correctResponse=e?s.response:"")}}processResponse(e=!0){this.validate();let t=this.querySelector("qti-response-processing");return!t||!t.process?!1:(t.process(),this.adaptive==="false"&&this.updateOutcomeVariable("completionStatus",this._getCompletionStatus()),e&&this.updateOutcomeVariable("numAttempts",(+this._context.variables.find(r=>r.identifier==="numAttempts")?.value+1).toString()),this._emit("qti-response-processed"),!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}handleUpdateResponseVariable(e){let{responseIdentifier:t,response:r}=e.detail;this.updateResponseVariable(t,r)}updateResponseVariable(e,t){this._context={...this._context,variables:this._context.variables.map(r=>r.identifier!==e?r:{...r,value:t})},this._emit("qti-interaction-changed",{item:this.identifier,responseIdentifier:e,response:Array.isArray(t)?[...t]:t}),this.adaptive==="false"&&this.updateOutcomeVariable("completionStatus",this._getCompletionStatus())}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(s=>s.identifier!==e?s:{...s,value:r.cardinality==="single"?t:[...s.value,t]})},this._feedbackElements.forEach(s=>s.checkShowFeedback(e)),this._emit("qti-outcome-changed",{item:this.identifier,outcomeIdentifier:e,value:this._context.variables.find(s=>s.identifier===e)?.value})}validate(){return this._interactionElements.every(e=>e.validate())?!0:this._interactionElements.some(e=>e.validate())?!1:null}_getCompletionStatus(){let e=this.validate();return e===!0?"completed":e===!1?"incomplete":"not_attempted"}_emit(e,t=null){this.dispatchEvent(new CustomEvent(e,{bubbles:!0,composed:!0,detail:t}))}};o([Y({type:String})],x.prototype,"title",2),o([Y({type:String})],x.prototype,"identifier",2),o([Y({type:String})],x.prototype,"adaptive",2),o([Y({type:String})],x.prototype,"timeDependent",2),o([Y({type:Boolean})],x.prototype,"disabled",2),o([y("disabled",{waitUntilFirstUpdate:!0})],x.prototype,"_handleDisabledChange",2),o([Y({type:Boolean})],x.prototype,"readonly",2),o([y("readonly",{waitUntilFirstUpdate:!0})],x.prototype,"_handleReadonlyChange",2),o([yr({context:v})],x.prototype,"_context",2),x=o([Cr("qti-assessment-item")],x);import{LitElement as qr}from"lit";import{customElement as Tr,property as kt}from"lit/decorators.js";var j=class extends qr{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 s=this.closest("qti-assessment-item").querySelector(`[data-stimulus-idref=${this.identifier}]`);s?await this.updateStimulusRef(s):console.warn(`Stimulus with data-stimulus-idref ${this.identifier} not found`)}}async updateStimulusRef(e){let t=await Rt().load(this.href).then(r=>r.htmlDoc());if(t){let r=t.querySelectorAll("qti-stimulus-body, qti-stylesheet");e.innerHTML="",e.append(...r)}}};o([kt({type:String})],j.prototype,"identifier",2),o([kt({type:String})],j.prototype,"href",2),j=o([Tr("qti-assessment-stimulus-ref")],j);import{html as wr}from"lit";import{property as Se}from"lit/decorators.js";var Lt={toAttribute:p=>p?"true":"false",fromAttribute:p=>p==="true"};function w(p,n){class e extends p{constructor(...s){super(...s);this.identifier="";this.tabIndex=0;this.disabled=!1;this.readonly=!1;this.internals=this.attachInternals()}handleDisabledChange(s,l){this.tabIndex=l?-1:0,l&&this.blur()}connectedCallback(){super.connectedCallback(),this.addEventListener("keyup",this._onKeyUp),this.addEventListener("click",this._onClick),this.dispatchEvent(new CustomEvent(`register-${n}`,{bubbles:!0,composed:!0}))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("keyup",this._onKeyUp),this.removeEventListener("click",this._onClick),this.dispatchEvent(new CustomEvent(`unregister-${n}`,{bubbles:!0,composed:!0}))}_onKeyUp(s){s.altKey||s.code==="Space"&&(s.preventDefault(),this._activate())}_onClick(){this.disabled||this.readonly||(this.focus(),this._activate())}_activate(){this.disabled||this.readonly||this.dispatchEvent(new CustomEvent(`activate-${n}`,{bubbles:!0,composed:!0,detail:{identifier:this.identifier}}))}render(){return wr`<slot></slot>`}}return o([Se({type:String})],e.prototype,"identifier",2),o([Se({type:Number,reflect:!0,attribute:"tabindex"})],e.prototype,"tabIndex",2),o([Se({type:Boolean,reflect:!0,attribute:"aria-disabled",converter:Lt})],e.prototype,"disabled",2),o([Se({type:Boolean,reflect:!0,attribute:"aria-readonly",converter:Lt})],e.prototype,"readonly",2),o([y("disabled",{waitUntilFirstUpdate:!0})],e.prototype,"handleDisabledChange",1),e}import{customElement as Sr}from"lit/decorators.js";import{html as Rr,LitElement as _r}from"lit";import{css as Mr}from"lit";var At=Mr`
2
+ :host {
3
+ display: block;
4
+ }
5
+ `;var ie=class extends _r{render(){return Rr`<slot name="qti-rubric-block"></slot><slot></slot>`}};ie.styles=At,ie=o([Sr("qti-item-body")],ie);import{html as kr,LitElement as Lr}from"lit";import{customElement as Ar}from"lit/decorators.js";var Re=class extends Lr{render(){return kr`<slot></slot>`}connectedCallback(){this.parentElement.tagName.endsWith("INTERACTION")&&this.setAttribute("slot","prompt")}};Re=o([Ar("qti-prompt")],Re);import{LitElement as Dr}from"lit";import{customElement as Vr}from"lit/decorators.js";var _e=class extends Dr{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 s=this.minifyCss(r);this.styleElement=document.createElement("style"),this.styleElement.media="screen",this.styleElement.textContent=`@scope {${s}}`,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()}};_e=o([Vr("qti-stylesheet")],_e);import{consume as Ir}from"@lit/context";import{css as Or,html as Pr}from"lit";import{customElement as Fr,property as ke,state as zr}from"lit/decorators.js";import{html as Nr,LitElement as Hr}from"lit";import{customElement as $r}from"lit/decorators.js";var I=class extends Hr{render(){return Nr`<slot></slot>`}defaultValues(n){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||n.cardinality==="multiple"||n.cardinality==="ordered"?t:t[0]}};I=o([$r("qti-variabledeclaration")],I);var M=class extends I{constructor(){super(...arguments);this.externalScored=null}render(){let e=this.itemContext?.variables.find(t=>t.identifier===this.identifier)?.value;return Pr`${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 s=parseInt(r.getAttribute("source-value")),l=parseInt(r.getAttribute("target-value"));(isNaN(s)||isNaN(l))&&console.error("source-value or target-value is not a number in qti-interpolation-table-entry"),t.set(s,l)}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),this.dispatchEvent(new CustomEvent("qti-register-variable",{bubbles:!0,composed:!0,detail:{variable:e}}))}};M.styles=[Or`
6
+ :host {
7
+ display: none;
8
+ }
9
+ `],o([ke({type:String,attribute:"base-type"})],M.prototype,"baseType",2),o([ke({type:String,attribute:"external-scored"})],M.prototype,"externalScored",2),o([ke({type:String})],M.prototype,"identifier",2),o([ke({type:String})],M.prototype,"cardinality",2),o([Ir({context:v,subscribe:!0}),zr()],M.prototype,"itemContext",2),M=o([Fr("qti-outcome-declaration")],M);import{consume as Br}from"@lit/context";import{css as Ur,html as Xr}from"lit";import{customElement as Yr,property as Je,state as jr}from"lit/decorators.js";var D=class extends I{render(){let n=this.itemContext?.variables.find(e=>e.identifier===this.identifier)?.value;return Xr`${JSON.stringify(n,null,2)}`}connectedCallback(){super.connectedCallback();let n={baseType:this.baseType,identifier:this.identifier,correctResponse:this.correctResponse,cardinality:this.cardinality||"single",mapping:this.mapping,value:null,type:"response",candidateResponse:null};n.value=this.defaultValues(n),this.dispatchEvent(new CustomEvent("qti-register-variable",{bubbles:!0,composed:!0,detail:{variable:n}}))}get correctResponse(){let n,e=this.querySelector("qti-correct-response");if(e){let t=e.querySelectorAll("qti-value");if(this.cardinality==="single"&&t.length>0)n=t[0].textContent,t[0].remove();else if(this.cardinality!=="single"){n=[];for(let r=0;r<t.length;r++)n.push(t[r].textContent),t[r].remove()}}return n}get mapping(){return this.querySelector("qti-mapping")}};D.styles=[Ur`
10
+ :host {
11
+ display: none;
12
+ }
13
+ `],o([Je({type:String,attribute:"base-type"})],D.prototype,"baseType",2),o([Je({type:String})],D.prototype,"identifier",2),o([Je({type:String})],D.prototype,"cardinality",2),o([Br({context:v,subscribe:!0}),jr()],D.prototype,"itemContext",2),D=o([Yr("qti-response-declaration")],D);import{LitElement as Wr}from"lit";import{customElement as Kr}from"lit/decorators.js";var Le=class extends Wr{};Le=o([Kr("qti-companion-materials-info")],Le);import{LitElement as Jr,html as Zr}from"lit";import{customElement as Gr}from"lit/decorators.js";var Ae=class extends Jr{render(){return Zr`<slot></slot>`}};Ae=o([Gr("qti-content-body")],Ae);import{LitElement as Qr,css as ei,html as ti}from"lit";import{customElement as ri,property as De}from"lit/decorators.js";var S=class extends Qr{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 ti`<slot></slot>`}connectedCallback(){super.connectedCallback(),this.setAttribute("slot","qti-rubric-block")}};S.styles=ei`
14
+ :host {
15
+ display: block;
16
+ }
17
+ `,o([De({type:String})],S.prototype,"id",2),o([De({type:String})],S.prototype,"use",2),o([De({type:String})],S.prototype,"view",2),o([De({type:String,attribute:"class"})],S.prototype,"classNames",2),o([y("classNames",{waitUntilFirstUpdate:!0})],S.prototype,"handleclassNamesChange",1),S=o([ri("qti-rubric-block")],S);import{css as ai,html as li}from"lit";import{customElement as ci}from"lit/decorators.js";import{consume as si}from"@lit/context";import{LitElement as oi}from"lit";import{property as Ve,state as ni}from"lit/decorators.js";var ii=()=>new Intl.NumberFormat().format(.1).replace(/\d/g,""),se=p=>{if(typeof p=="string")return p;let n=ii();return n==="."?p.toLocaleString():p.toString().replace(".","").replace(n,".")};function Ze(p){return p==null}function oe(p){return p.replace(/([^:]\/)\/+/g,"$1").replace(/\/\//g,"/").replace("http:/","http://").replace("https:/","https://")}var E=class extends oi{connectedCallback(){super.connectedCallback(),this.dispatchEvent(new CustomEvent("qti-register-feedback",{bubbles:!0,composed:!0,detail:this}))}checkShowFeedback(n){let e=this._context.variables.find(r=>r.identifier===n)||null;if(this.outcomeIdentifier!==n||!e)return;let t=!1;Array.isArray(e.value)?t=e.value.includes(this.identifier):t=!Ze(this.identifier)&&!Ze(e?.value)&&this.identifier===e.value||!1,this.showFeedback(t)}showFeedback(n){this.showStatus=n&&this.showHide==="show"||!n&&this.showHide==="hide"?"on":"off"}};o([Ve({type:String,attribute:"show-hide"})],E.prototype,"showHide",2),o([Ve({type:String,attribute:"outcome-identifier"})],E.prototype,"outcomeIdentifier",2),o([Ve({type:String})],E.prototype,"identifier",2),o([Ve({type:String,attribute:!1})],E.prototype,"showStatus",2),o([si({context:v,subscribe:!0}),ni()],E.prototype,"_context",2);var ne=class extends E{render(){return li` <slot part="feedback" class="feedback ${this.showStatus}"></slot> `}firstUpdated(n){this.checkShowFeedback(this.outcomeIdentifier)}};ne.styles=ai`
18
+ :host {
19
+ display: block;
20
+ }
21
+ .on {
22
+ display: block;
23
+ }
24
+ .off {
25
+ display: none;
26
+ }
27
+ `,ne=o([ci("qti-feedback-block")],ne);import{css as pi,html as di}from"lit";import{customElement as ui}from"lit/decorators.js";var ae=class extends E{constructor(){super(...arguments);this.render=()=>di` <slot part="feedback" class="${this.showStatus}"></slot> `}};ae.styles=pi`
28
+ .on {
29
+ display: inline-block;
30
+ }
31
+ .off {
32
+ display: none;
33
+ }
34
+ `,ae=o([ui("qti-feedback-inline")],ae);import{css as hi,html as mi}from"lit";import{customElement as fi}from"lit/decorators.js";var le=class extends E{render(){return mi`
35
+ <dialog class="qti-dialog" part="feedback" ?open="${this.showStatus==="on"}">
36
+ <slot></slot>
37
+ <div style="margin-top: var(--qti-gap-size); text-align: center;">
38
+ <button class="button close-button" @click="${this.closeFeedback}"></button>
39
+ </div>
40
+ </dialog>
41
+ `}openFeedback(){let n=this.shadowRoot?.querySelector("dialog");n&&!n.open&&n.showModal()}closeFeedback(){let n=this.shadowRoot?.querySelector("dialog");n&&n.open&&(n.close(),this.showStatus="off")}firstUpdated(){this.showStatus==="on"&&this.openFeedback()}updated(n){n.has("showStatus")&&(this.showStatus==="on"?this.openFeedback():this.closeFeedback())}};le.styles=hi`
42
+ .qti-dialog {
43
+ background: var(--qti-bg);
44
+ border: var(--qti-border-thickness) var(--qti-border-style) var(--qti-border-color);
45
+ border-radius: var(--qti-border-radius);
46
+ padding: var(--qti-padding-vertical) var(--qti-padding-horizontal);
47
+ box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
48
+ position: fixed;
49
+ top: 50%;
50
+ left: 50%;
51
+ transform: translate(-50%, -50%);
52
+ z-index: 1000;
53
+ width: auto;
54
+ max-width: 90%;
55
+ }
56
+
57
+ .button {
58
+ border-radius: var(--qti-border-radius);
59
+ padding: var(--qti-padding-vertical) var(--qti-padding-horizontal);
60
+ background-color: var(--qti-bg-active);
61
+ border: var(--qti-border-active);
62
+ cursor: pointer;
63
+ position: relative;
64
+ display: inline-block;
65
+ }
66
+
67
+ .button:hover {
68
+ background-color: var(--qti-hover-bg);
69
+ }
70
+
71
+ .button:disabled {
72
+ background-color: var(--qti-disabled-bg);
73
+ color: var(--qti-disabled-color);
74
+ cursor: not-allowed;
75
+ }
76
+
77
+ .button:focus {
78
+ outline: var(--qti-focus-border-width) solid var(--qti-focus-color);
79
+ }
80
+
81
+ /* Text content of the button */
82
+ .button::after {
83
+ content: var(--qti-close-text, 'Close');
84
+ color: inherit;
85
+ font-size: inherit;
86
+ text-align: center;
87
+ display: inline-block;
88
+ line-height: 1.5;
89
+ }
90
+ `,le=o([fi("qti-modal-feedback")],le);import{html as yi}from"lit";import{ifDefined as xi}from"lit/directives/if-defined.js";import{property as Ge,state as gi}from"lit/decorators.js";import{LitElement as bi}from"lit";var m=class extends bi{constructor(){super();this.disabled=!1;this.readonly=!1;this._internals=this.attachInternals()}reportValidity(){return this._internals.reportValidity()}reset(){this.value=""}get correctResponse(){return this._correctResponse}set correctResponse(e){this._correctResponse=e}connectedCallback(){super.connectedCallback(),this.dispatchEvent(new CustomEvent("qti-register-interaction",{bubbles:!0,composed:!0,cancelable:!1,detail:{responseIdentifier:this.responseIdentifier}}))}saveResponse(e){this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,composed:!0,cancelable:!1,detail:{responseIdentifier:this.responseIdentifier,response:Array.isArray(e)?[...e]:e}}))}};m.formAssociated=!0,o([Ge({type:String,attribute:"response-identifier"})],m.prototype,"responseIdentifier",2),o([Ge({reflect:!0,type:Boolean})],m.prototype,"disabled",2),o([Ge({reflect:!0,type:Boolean})],m.prototype,"readonly",2),o([gi()],m.prototype,"_correctResponse",2);import{customElement as Ei,property as ce,state as Vt}from"lit/decorators.js";import{css as vi}from"lit";var Dt=vi`
91
+ /* PK: display host as block, else design will be collapsed */
92
+ :host {
93
+ display: block;
94
+ }
95
+ textarea {
96
+ box-sizing: border-box;
97
+ width: 100%;
98
+ height: 100%;
99
+ border: 0;
100
+ }
101
+ `;var C=class extends m{constructor(){super(...arguments);this._rows=5;this._value=""}handleclassNamesChange(e,t){let r=t.split(" "),s=!1;if(r.forEach(l=>{if(l.startsWith("qti-height-lines-")){let i=l.replace("qti-height-lines-","");this._rows=parseInt(i),s=!0}}),!s&&this.expectedLength){let l=Math.ceil(this.expectedLength/50);this._rows=l}}get value(){return this._value}set value(e){if(typeof e=="string"){this._value=e;let t=new FormData;t.append(this.responseIdentifier,e),this._internals.setFormValue(t),this.validate()}else throw new Error("Value must be a string")}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._value!==""&&e.checkValidity()}reportValidity(){let e=this.shadowRoot.querySelector("textarea");if(!e)return!1;let t=this.validate();return t||e.reportValidity(),t}render(){return yi`<slot name="prompt"></slot
102
+ ><textarea
103
+ part="textarea"
104
+ name="${this.responseIdentifier}"
105
+ spellcheck="false"
106
+ autocomplete="off"
107
+ maxlength="${5e3}"
108
+ @keydown="${e=>e.stopImmediatePropagation()}"
109
+ @keyup="${this.textChanged}"
110
+ @change="${this.textChanged}"
111
+ @blur="${e=>{this.reportValidity()}}"
112
+ placeholder="${xi(this.placeholderText?this.placeholderText:void 0)}"
113
+ rows="${this._rows}"
114
+ ?disabled="${this.disabled}"
115
+ ?readonly="${this.readonly}"
116
+ .value=${this._value}
117
+ ></textarea>`}textChanged(e){if(this.disabled||this.readonly)return;let t=e.target;this.setEmptyAttribute(t.value),this._value!==t.value&&(this.value=t.value,this.saveResponse(t.value))}setEmptyAttribute(e){this.setAttribute("empty",e===""?"true":"false")}};C.styles=Dt,o([Vt()],C.prototype,"_rows",2),o([ce({type:Number,attribute:"expected-length"})],C.prototype,"expectedLength",2),o([ce({type:String,attribute:"pattern-mask"})],C.prototype,"patternMask",2),o([ce({type:String,attribute:"placeholder-text"})],C.prototype,"placeholderText",2),o([ce({type:String,attribute:"data-patternmask-message"})],C.prototype,"dataPatternmaskMessage",2),o([Vt()],C.prototype,"_value",2),o([ce({type:String,attribute:"class"})],C.prototype,"classNames",2),o([y("classNames")],C.prototype,"handleclassNamesChange",1),C=o([Ei("qti-extended-text-interaction")],C);import{html as qi}from"lit";import{customElement as Ti,property as Ne,state as wi}from"lit/decorators.js";import{ifDefined as Ht}from"lit/directives/if-defined.js";import{createRef as Mi}from"lit/directives/ref.js";import{css as Ci}from"lit";var Nt=Ci`
118
+ :host {
119
+ display: inline-block;
120
+ }
121
+ [part='correct'] {
122
+ position: absolute;
123
+ width: 100%;
124
+ }
125
+ :host(.qti-input-width-1) [part='input'] {
126
+ width: 1.1rem;
127
+ min-width: 1.1rem;
128
+ }
129
+
130
+ :host(.qti-input-width-2) [part='input'] {
131
+ width: 2.3rem;
132
+ min-width: 2.3rem;
133
+ }
134
+
135
+ :host(.qti-input-width-3) [part='input'] {
136
+ width: 3.3rem;
137
+ min-width: 3.3rem;
138
+ }
139
+
140
+ :host(.qti-input-width-4) [part='input'] {
141
+ width: 4.2rem;
142
+ min-width: 4.2rem;
143
+ }
144
+
145
+ :host(.qti-input-width-6) [part='input'] {
146
+ width: 6.6rem;
147
+ min-width: 6.6rem;
148
+ }
149
+
150
+ :host(.qti-input-width-10) [part='input'] {
151
+ width: 8rem;
152
+ min-width: 8rem;
153
+ }
154
+
155
+ :host(.qti-input-width-15) [part='input'] {
156
+ width: 12rem;
157
+ min-width: 12rem;
158
+ }
159
+
160
+ :host(.qti-input-width-20) [part='input'] {
161
+ width: 17rem;
162
+ min-width: 17rem;
163
+ }
164
+
165
+ :host(.qti-input-width-25) [part='input'] {
166
+ width: 20rem;
167
+ min-width: 20rem;
168
+ }
169
+
170
+ :host(.qti-input-width-30) [part='input'] {
171
+ width: 24rem;
172
+ min-width: 24rem;
173
+ }
174
+
175
+ :host(.qti-input-width-35) [part='input'] {
176
+ width: 28rem;
177
+ min-width: 28rem;
178
+ }
179
+
180
+ :host(.qti-input-width-40) [part='input'] {
181
+ width: 32rem;
182
+ min-width: 32rem;
183
+ }
184
+
185
+ :host(.qti-input-width-45) [part='input'] {
186
+ width: 36rem;
187
+ min-width: 36rem;
188
+ }
189
+
190
+ :host(.qti-input-width-50) [part='input'] {
191
+ width: 40rem;
192
+ min-width: 40rem;
193
+ }
194
+
195
+ :host(.qti-input-width-72) [part='input'] {
196
+ width: 57rem;
197
+ min-width: 57rem;
198
+ }
199
+ `;var R=class extends m{constructor(){super(...arguments);this._value="";this.inputRef=Mi()}get value(){return this._value}set value(e){if(typeof e=="string"){this._value=e;let t=new FormData;t.append(this.responseIdentifier,e),this._internals.setFormValue(t),this.validate()}else throw new Error("Value must be a string")}validate(){let e=this.shadowRoot.querySelector("input");if(!e)return!1;if(this.patternMask&&this.dataPatternmaskMessage)this._internals.setValidity({}),e.setCustomValidity(""),e.checkValidity()||(this._internals.setValidity({customError:!0},this.dataPatternmaskMessage),e.setCustomValidity(this.dataPatternmaskMessage));else{let t=e.checkValidity();this._internals.setValidity(t?{}:{customError:!1})}return this._value!==""&&e.checkValidity()}render(){return qi`
200
+ <input
201
+ part="input"
202
+ name="${this.responseIdentifier}"
203
+ spellcheck="false"
204
+ autocomplete="off"
205
+ @blur="${e=>{this.reportValidity()}}"
206
+ @keydown="${e=>e.stopImmediatePropagation()}"
207
+ @keyup="${this.textChanged}"
208
+ @change="${this.textChanged}"
209
+ type="${this.patternMask=="[0-9]*"?"number":"text"}"
210
+ placeholder="${Ht(this.placeholderText?this.placeholderText:void 0)}"
211
+ .value="${this._value}"
212
+ pattern="${Ht(this.patternMask?this.patternMask:void 0)}"
213
+ maxlength=${1e3}
214
+ ?disabled="${this.disabled}"
215
+ ?readonly="${this.readonly}"
216
+ />
217
+ <div part="correct">${this._correctResponse}</div>
218
+ `}textChanged(e){if(this.disabled||this.readonly)return;let t=e.target;this.setEmptyAttribute(t.value),this._value!==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._value=""}setEmptyAttribute(e){this.setAttribute("empty",e===""?"true":"false")}};R.styles=Nt,o([Ne({type:Number,attribute:"expected-length"})],R.prototype,"expectedLength",2),o([Ne({type:String,attribute:"pattern-mask"})],R.prototype,"patternMask",2),o([Ne({type:String,attribute:"placeholder-text"})],R.prototype,"placeholderText",2),o([Ne({type:String,attribute:"data-patternmask-message"})],R.prototype,"dataPatternmaskMessage",2),o([wi()],R.prototype,"_value",2),R=o([Ti("qti-text-entry-interaction")],R);import{html as Ri}from"lit";import{customElement as _i}from"lit/decorators.js";import{property as $t,query as Si}from"lit/decorators.js";var O=(p,n)=>{class e extends p{constructor(){super(...arguments);this._choiceElements=[];this.minChoices=0;this.maxChoices=1;this._handleDisabledChange=(s,l)=>{this._choiceElements.forEach(i=>i.disabled=l)};this._handleReadonlyChange=(s,l)=>{this._choiceElements.forEach(i=>i.readonly=l)};this._value=""}_handleMaxChoicesChange(s,l){this._determineInputType()}get value(){return Array.isArray(this._value)?this._value.join(","):this._value}set value(s){if(this.maxChoices>1&&typeof s=="string"?this._value=s.split(","):this._value=s,Array.isArray(this._value)){let l=new FormData;this._value.forEach(i=>{l.append(this.responseIdentifier,i)}),this._internals.setFormValue(l)}else this._internals.setFormValue(this._value);this._updateChoiceSelection()}get correctResponse(){return this._correctResponse}set correctResponse(s){this._correctResponse=s;let l=Array.isArray(s)?s:[s];this._choiceElements.forEach(i=>{i.internals.states.delete("correct-response"),i.internals.states.delete("incorrect-response"),l.length>0&&(l.includes(i.identifier)?i.internals.states.add("correct-response"):i.internals.states.add("incorrect-response"))})}connectedCallback(){super.connectedCallback(),this.addEventListener(`register-${n}`,this._registerChoiceElement),this.addEventListener(`unregister-${n}`,this._unregisterChoiceElement),this.addEventListener(`activate-${n}`,this._choiceElementSelectedHandler)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(`register-${n}`,this._registerChoiceElement),this.removeEventListener(`unregister-${n}`,this._unregisterChoiceElement),this.removeEventListener(`activate-${n}`,this._choiceElementSelectedHandler)}validate(){let s=this._choiceElements.filter(c=>this._getChoiceChecked(c)),l=s.length,i=!0,a="";return this.maxChoices!==0&&l>this.maxChoices?(i=!1,a=this.dataset.maxSelectionsMessage||`You can select at most ${this.maxChoices} choices.`):l<this.minChoices&&(i=!1,a=this.dataset.minSelectionsMessage||`You must select at least ${this.minChoices} choices.`),s.length>0&&this._internals.setValidity(i?{}:{customError:!0},a,s[l-1]||this._choiceElements[0]||this),this.reportValidity(),i}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(s){s.stopPropagation();let l=s.target;l.disabled=this.disabled,this._choiceElements.push(l),this._setInputType(l)}_unregisterChoiceElement(s){s.stopPropagation();let l=s.target;this._choiceElements=this._choiceElements.filter(i=>i!==l)}_determineInputType(){this._choiceElements.forEach(s=>{this._setInputType(s)})}_setInputType(s){this._internals.ariaLabel=this.maxChoices===1?"radio-group":"checkbox-group";let l=this.maxChoices===1?"radio":"checkbox";s.internals.role=l,s.internals.states.delete(l==="radio"?"checkbox":"radio"),s.internals.states.add(l)}_choiceElementSelectedHandler(s){this._toggleChoiceChecked(s.target),this.maxChoices===1&&this._choiceElements.forEach(l=>{l.identifier!==s.detail.identifier&&this._setChoiceChecked(l,!1)}),this._handleChoiceSelection()}_setChoiceChecked(s,l){s.internals?.states&&(l?(s.internals.states.add("--checked"),s.internals.ariaChecked="true"):(s.internals.states.delete("--checked"),s.internals.ariaChecked="false"))}_getChoiceChecked(s){return s.internals.states.has("--checked")}_toggleChoiceChecked(s){let l=this._getChoiceChecked(s);this._setChoiceChecked(s,!l)}_handleChoiceSelection(){let l=this._choiceElements.filter(i=>this._getChoiceChecked(i)).map(i=>i.identifier);this.value=this.maxChoices===1?l[0]||"":l,this.validate(),this.saveResponse(this._value)}_updateChoiceSelection(){let s=Array.isArray(this._value)?this._value:[this._value];this._choiceElements.forEach(l=>{let i=s.includes(l.identifier);this._setChoiceChecked(l,i)})}}return o([Si("#validationMessage")],e.prototype,"_validationMessageElement",2),o([$t({type:Number,attribute:"min-choices"})],e.prototype,"minChoices",2),o([$t({type:Number,attribute:"max-choices"})],e.prototype,"maxChoices",2),o([y("maxChoices",{waitUntilFirstUpdate:!0})],e.prototype,"_handleMaxChoicesChange",1),o([y("disabled",{waitUntilFirstUpdate:!0})],e.prototype,"_handleDisabledChange",2),o([y("readonly",{waitUntilFirstUpdate:!0})],e.prototype,"_handleReadonlyChange",2),e};var He=class extends O(m,"qti-hottext"){constructor(){super(...arguments);this.render=()=>Ri`<slot></slot>`}};He=o([_i("qti-hottext-interaction")],He);import{css as ki,html as It}from"lit";import{customElement as Li,property as Ai,state as Ot}from"lit/decorators.js";import{unsafeHTML as Pt}from"lit/directives/unsafe-html.js";var P=class extends m{constructor(){super(...arguments);this.options=[];this.correctOption="";this.dataPrompt="select"}static get styles(){return[ki`
219
+ :host {
220
+ display: inline-block;
221
+ }
222
+ slot {
223
+ display: flex;
224
+ flex-direction: column;
225
+ }
226
+ [role='menu'] {
227
+ position: absolute;
228
+ z-index: 1000;
229
+ }
230
+ .anchor {
231
+ /* anchor-name: --infobox; */
232
+ width: fit-content;
233
+ }
234
+
235
+ .positionedElement {
236
+ position: absolute;
237
+ /* position-anchor: --infobox; */
238
+ /* top: anchor(bottom); */
239
+ }
240
+ `]}render(){return It`
241
+ <select part="select" @change="${this.choiceSelected}" ?disabled="${this.disabled}" ?readonly="${this.readonly}">
242
+ ${this.options.map(e=>It`
243
+ <option value="${e.value}" ?selected="${e.selected}">${Pt(e.textContent)}</option>
244
+ `)}
245
+ </select>
246
+
247
+ ${Pt(this.correctOption)}
248
+ `}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 value(e){this.options=this.options.map(t=>(e===t.value&&(t.selected=!0),t))}get value(){return this.options.find(e=>e.selected).value}set correctResponse(e){if(e===""){this.correctOption="";return}this.correctOption=`<span part="correct-option">${this.options.find(t=>e===t.value).textContent}</span>`}choiceSelected(e){let t=e.target.value;this.options=this.options.map(r=>({...r,selected:r.value===t})),this.saveResponse(t)}};P.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"],o([Ot()],P.prototype,"options",2),o([Ot()],P.prototype,"correctOption",2),o([Ai({attribute:"data-prompt",type:String})],P.prototype,"dataPrompt",2),P=o([Li("qti-inline-choice-interaction")],P);import{html as Hi}from"lit";import{customElement as $i,property as Ii}from"lit/decorators.js";import{property as Di}from"lit/decorators.js";var $e=(p,n)=>{class e extends p{constructor(){super(...arguments);this.shuffle="false"}connectedCallback(){super.connectedCallback(),this._applyShuffle()}updated(s){s.has("shuffle")&&this._applyShuffle()}_applyShuffle(){this.shuffle==="true"?this._shuffleChoices():this._resetShuffleChoices()}_shuffleChoices(){let s=Array.from(this.querySelectorAll(n)),l=s.filter(h=>h.hasAttribute("fixed")),i=s.filter(h=>!h.hasAttribute("fixed"));if(i.length<=1){console.warn("Shuffling is not possible with fewer than 2 non-fixed elements.");return}let a=[...i],c=!1,d=0;for(;!c&&d<10;){d++;for(let h=i.length-1;h>0;h--){let g=Math.floor(Math.random()*(h+1));[i[h],i[g]]=[i[g],i[h]]}c=!i.every((h,g)=>h===a[g])}c||console.warn("Failed to shuffle the choices after multiple attempts.");let u=1;[...l,...i].forEach(h=>{h.style.setProperty("order",String(u++))})}_resetShuffleChoices(){this.querySelectorAll(n).forEach(s=>{s.style.setProperty("order","initial")})}}return o([Di({type:String,reflect:!0})],e.prototype,"shuffle",2),e};import{property as Vi}from"lit/decorators.js";var Ft=(p,n)=>{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(s){s&&(this._classes=s.split(" "),this._addLabels())}get class(){return this._classes?.join(" ")||""}updated(s){super.updated(s),s.has("shuffle")&&this._addLabels()}_addLabels(){let s=this._classes.some(i=>this._allLabels.includes(i)||this._allLabelSuffixes.includes(i)),l=i=>!isNaN(+i);if(s){let a=Array.from(this.querySelectorAll("qti-simple-choice")).map(c=>c).map((c,d)=>({el:c,order:l(c.style.order)?+c.style.order:d+1})).sort((c,d)=>c.order-d.order).map(c=>c.el);for(let c=0;c<a.length;c++)a[c].marker=this._getLabel(c+1)}}_getLabel(s){let l=this._classes.filter(c=>this._allLabels.includes(c)).pop(),i=this._classes.filter(c=>this._allLabelSuffixes.includes(c)).pop();!l&&i&&(l="qti-labels-upper-alpha");let a="";switch(l){case"qti-labels-decimal":a=`${s}`;break;case"qti-labels-lower-alpha":a=`${String.fromCharCode(97+s-1)}`;break;case"qti-labels-upper-alpha":a=`${String.fromCharCode(65+s-1)}`;break}return i==="qti-labels-suffix-period"?a+=".":i==="qti-labels-suffix-parenthesis"&&(a+=")"),a}}return o([Vi({type:String,reflect:!0})],e.prototype,"class",1),e};import{css as Ni}from"lit";var zt=Ni`
249
+ [part='slot'] {
250
+ display: flex;
251
+ flex-direction: column;
252
+ gap: var(--qti-gap-size);
253
+ flex-wrap: wrap;
254
+ }
255
+
256
+ ::slotted(qti-simple-choice) {
257
+ flex: 0 0
258
+ calc((100% - (var(--qti-gap-size) * var(--choice-interactions-stacking))) / var(--choice-interactions-stacking)) !important;
259
+ box-sizing: border-box !important;
260
+ }
261
+
262
+ :host(.qti-choices-stacking-1) [part='slot'] {
263
+ flex-direction: row;
264
+ --choice-interactions-stacking: 1;
265
+ }
266
+
267
+ :host(.qti-choices-stacking-2) [part='slot'] {
268
+ flex-direction: row;
269
+ --choice-interactions-stacking: 2;
270
+ }
271
+ :host(.qti-choices-stacking-3) [part='slot'] {
272
+ flex-direction: row;
273
+ --choice-interactions-stacking: 3;
274
+ }
275
+ :host(.qti-choices-stacking-4) [part='slot'] {
276
+ flex-direction: row;
277
+ --choice-interactions-stacking: 4;
278
+ }
279
+ :host(.qti-choices-stacking-5) [part='slot'] {
280
+ flex-direction: row;
281
+ --choice-interactions-stacking: 5;
282
+ }
283
+ :host([orientation='horizontal']) [part='slot'] {
284
+ flex-direction: row;
285
+ }
286
+ `;var W=class extends Ft($e(O(m,"qti-simple-choice"),"qti-simple-choice"),"qti-simple-choice"){constructor(){super(),this._internals.role="group"}render(){return Hi`
287
+ <slot part="prompt" name="prompt"></slot><slot part="slot"></slot>
288
+ <div part="message" role="alert" id="validationMessage"></div>
289
+ `}};W.styles=zt,o([Ii({type:String})],W.prototype,"orientation",2),W=o([$i("qti-choice-interaction")],W);import{css as Oi,html as Pi}from"lit";import{customElement as Fi}from"lit/decorators.js";var pe=class extends m{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 value(){return this._base64}set value(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{...m.properties}}render(){return Pi`
290
+ <div>
291
+ <slot name="prompt"></slot>
292
+ <input type="file" @change="${this._onFileChange}" ?disabled="${this.disabled}" ?readonly="${this.readonly}" />
293
+ </div>
294
+ `}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 s=new FileReader;s.onload=()=>t(s.result),s.onerror=()=>r(s.error),s.readAsDataURL(e)})}};pe.styles=[Oi`
295
+ :host {
296
+ display: block;
297
+ margin: 1em 0;
298
+ }
299
+ input[type='file'] {
300
+ display: block;
301
+ margin-top: 0.5em;
302
+ }
303
+ `],pe=o([Fi("qti-upload-interaction")],pe);import{css as zi,html as Bi,LitElement as Ui}from"lit";import{customElement as Xi}from"lit/decorators.js";var de=class extends Ui{render(){return Bi`<slot></slot>`}process(){let n=new Qe,e=[...this.children];n.process(e)}};de.styles=[zi`
304
+ :host {
305
+ display: none;
306
+ }
307
+ `],de=o([Xi("qti-outcome-processing")],de);var Qe=class{process(n){for(let e of n)e.process()}};import{css as Yi,html as ji,LitElement as Wi}from"lit";import{customElement as Ki}from"lit/decorators.js";var Bt=`<qti-response-processing>
308
+ <qti-response-condition>
309
+ <qti-response-if>
310
+ <qti-match>
311
+ <qti-variable identifier="RESPONSE"></qti-variable>
312
+ <qti-correct identifier="RESPONSE"></qti-correct>
313
+ </qti-match>
314
+ <qti-set-outcome-value identifier="SCORE">
315
+ <qti-base-value base-type="float">1</qti-base-value>
316
+ </qti-set-outcome-value>
317
+ </qti-response-if>
318
+ <qti-response-else>
319
+ <qti-set-outcome-value identifier="SCORE">
320
+ <qti-base-value base-type="float">0</qti-base-value>
321
+ </qti-set-outcome-value>
322
+ </qti-response-else>
323
+ </qti-response-condition>
324
+ </qti-response-processing>`,Ut=`<qti-response-processing>
325
+ <qti-response-condition>
326
+ <qti-response-if>
327
+ <qti-is-null>
328
+ <qti-variable identifier="RESPONSE"></qti-variable>
329
+ </qti-is-null>
330
+ <qti-set-outcome-value identifier="SCORE">
331
+ <qti-base-value base-type="float">0.0</qti-base-value>
332
+ </qti-set-outcome-value>
333
+ </qti-response-if>
334
+ <qti-response-else>
335
+ <qti-set-outcome-value identifier="SCORE">
336
+ <qti-map-response identifier="RESPONSE"> </qti-map-response>
337
+ </qti-set-outcome-value>
338
+ </qti-response-else>
339
+ </qti-response-condition>
340
+ </qti-response-processing>`,Xt=`<qti-response-processing>
341
+ <qti-response-condition>
342
+ <qti-response-if>
343
+ <qti-is-null>
344
+ <qti-variable identifier="RESPONSE"></qti-variable>
345
+ </qti-is-null>
346
+ <qti-set-outcome-value identifier="SCORE">
347
+ <qti-base-value base-type="float">0</qti-base-value>
348
+ </qti-set-outcome-value>
349
+ </qti-response-if>
350
+ <qti-response-else>
351
+ <qti-set-outcome-value identifier="SCORE">
352
+ <qti-map-response-point identifier="RESPONSE"></qti-map-response-point>
353
+ </qti-set-outcome-value>
354
+ </qti-response-else>
355
+ </qti-response-condition>
356
+ </qti-response-processing>`;var U=class extends Wi{render(){return ji`<slot></slot>`}process(){if(!this.closest("qti-assessment-item"))return;let e=[...this.children];for(let t of e)t.process()}firstUpdated(n){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(Ut).firstElementChild.firstElementChild);break}case"map_response_point":{this.appendChild(this.fragmentFromString(Xt).firstElementChild.firstElementChild);break}case"match_correct":this.appendChild(this.fragmentFromString(Bt).firstElementChild.firstElementChild);break}}}fragmentFromString(n){return document.createRange().createContextualFragment(n)}};U.styles=[Yi`
357
+ :host {
358
+ display: none;
359
+ }
360
+ `],U=o([Ki("qti-response-processing")],U);import{property as Qi}from"lit/decorators.js";import{customElement as Ji}from"lit/decorators.js";import{html as Zi,LitElement as Gi}from"lit";var _=class extends Gi{render(){return Zi`<slot></slot>`}process(){throw new Error("Not implemented")}};_=o([Ji("qti-rule")],_);var Ie=class extends _{get childExpression(){return this.firstElementChild}process(){let n=this.getAttribute("identifier"),e=this.closest("qti-assessment-item").getVariable(n),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:se(t)}})),t)}};o([Qi({type:String})],Ie.prototype,"identifier",2);customElements.define("qti-lookup-outcome-value",Ie);import{html as es}from"lit";var et=class extends _{render(){return es`<slot></slot>`}process(){let n=[...this.children];for(let e=0;e<n.length;e++){let t=n[e];if(t.calculate()){t.process();return}}}};customElements.define("qti-response-condition",et);var tt=class extends _{process(){let n=this.getAttribute("identifier"),e=this.firstElementChild,r=new rt(e).process();this.dispatchEvent(new CustomEvent("qti-set-outcome-value",{bubbles:!0,composed:!0,detail:{outcomeIdentifier:n,value:Array.isArray(r)?r.map(s=>se(s)):se(r)}}))}},rt=class{constructor(n){this.expression=n}process(){let n=this.expression?this.expression.calculate():null;if(n==null){console.warn("setOutcomeValue: value is null or undefined");return}return n}};customElements.define("qti-set-outcome-value",tt);import{LitElement as ts,html as rs}from"lit";var ue=class extends ts{render(){return rs`<slot></slot>`}calculate(){return!0}getSubRules(){return[...this.children]}process(){let n=this.getSubRules();for(let e=0;e<n.length;e++)n[e].process()}};customElements.define("qti-response-else",ue);import{html as is}from"lit";var he=class extends ue{calculate(){return this.firstElementChild.calculate()}getSubRules(){let n=[];for(let e=1;e<this.children.length;e++)n.push(this.children[e]);return n}};customElements.define("qti-response-if",he);var it=class extends he{render(){return is`${super.render()}`}};customElements.define("qti-response-else-if",it);import{consume as ss}from"@lit/context";import{css as os,html as ns,LitElement as as}from"lit";import{state as Yt}from"lit/decorators.js";var f=class extends as{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(s=>s.identifier===t)||null}case"qti-multiple":{let r=e.getResult();return r.length>0?{identifier:"",baseType:r[0].baseType,value:r.map(s=>s.value),cardinality:"multiple",type:"response"}:null}case"qti-correct":{let t=e.getAttribute("identifier")||"",r=this.context.variables.find(s=>s.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 ns`<pre>${JSON.stringify(this.result,null,2)}</pre>
361
+ <slot></slot>`}calculate(){return this.result=this.getResult(),this.result}getResult(){throw new Error("Not implemented")}};f.styles=os`
362
+ slot {
363
+ display: none;
364
+ }
365
+ `,o([Yt()],f.prototype,"result",2),o([ss({context:v,subscribe:!0}),Yt()],f.prototype,"context",2);var q=class extends f{calculate(){return this.result=this.getResult(),this.result}getResult(){throw new Error("Not implemented")}};var Oe=class extends ls(q){calculate(){return this.calculateChildren(Array.from(this.children))}};function ls(p){return class extends p{calculateChildren(e){return e.map(r=>{let s=r;if(!s.calculate)return console.error("Element doesn't implement QtiConditionExpression"),null;let l=s.calculate(),i=!1;if(typeof l=="string")if(l==="true")i=!0;else if(l==="false")i=!1;else return console.error("unexpected val in qti-or, expected boolean"),null;else typeof l=="boolean"&&(i=l);return i}).every(r=>typeof r=="boolean"&&r)}}}customElements.define("qti-and",Oe);import{property as cs}from"lit/decorators.js";var Pe=class extends f{constructor(){super(...arguments);this.baseType="string"}getResult(){return this.textContent.trim()}};o([cs({type:String,attribute:"base-type"})],Pe.prototype,"baseType",2);customElements.define("qti-base-value",Pe);var st=class extends q{getResult(){let n=this.getVariables();if(this.children.length===2){let e=n[0],t=n[1];if(e.baseType==="directedPair"&&t.baseType==="directedPair"&&e.cardinality==="multiple"){let r=e.value,s=t.value;return r.filter(a=>s.includes(a)).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",st);var ot=class extends f{get interpretation(){return this.getAttribute("interpretation")||""}getResult(){let n=this.getAttribute("identifier")||"",e=this.context.variables.find(t=>t.identifier===n)||null;return e.cardinality!=="single"?e.correctResponse.length>0?e.correctResponse[0]:"":e.correctResponse}};customElements.define("qti-correct",ot);import{property as ps}from"lit/decorators.js";var Fe=class extends f{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 s=parseFloat(t.value),l=parseFloat(r.value);if(!isNaN(s)&&!isNaN(l))return this.roundingMode==="significantFigures"?s.toPrecision(this.figures)===l.toPrecision(this.figures):Math.round(s*Math.pow(10,this.figures))/Math.pow(10,this.figures)===Math.round(l*Math.pow(10,this.figures))/Math.pow(10,this.figures);console.error(`value cannot be casted to numeric value in equalRounded operator: ${s}, ${l}`);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}};o([ps({type:String})],Fe.prototype,"roundingMode",2);customElements.define("qti-equal-rounded",Fe);import{property as ds}from"lit/decorators.js";var T=class{static compareSingleValues(n,e,t){switch(t){case"identifier":case"string":return n===e;case"integer":{let r=parseInt(n,10),s=parseInt(e,10);if(!isNaN(r)&&!isNaN(s))return r===s;console.error(`Cannot convert ${n} and/or ${e} to int.`);break}case"float":{let r=parseFloat(n),s=parseFloat(e);if(!isNaN(r)&&!isNaN(s))return r===s;console.error(`couldn't convert ${n} and/or ${e} to float.`);break}case"pair":case"directedPair":{let r=n.split(" ").sort(),s=e.split(" ").sort();if(r.length===2&&s.length===2)return t==="pair"&&(r.sort(),s.sort()),r.join(" ")===s.join(" ");console.error(`compared two pair but one of the values does not have 2 values: 1: ${n} 2: ${e}`);break}}return!1}};var ze=class extends f{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):T.compareSingleValues(t.value,r.value,t.baseType)}return console.error("unexpected number of children in qti-equal"),null}};o([ds({type:String})],ze.prototype,"toleranceMode",2);customElements.define("qti-equal",ze);var nt=class extends f{getResult(){if(this.children.length===2){let n=this.getVariables(),e=n[0],t=n[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",nt);var at=class extends q{getResult(){if(this.children.length===2){let n=this.getVariables(),e=n[0],t=n[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",at);var lt=class extends f{getResult(){if(this.children.length===1){let n=this.getVariables();if(!n)return!0;let e=n[0].value;return e==null||e==null||e===""}return console.error("unexpected number of children in qti Null"),null}};customElements.define("qti-is-null",lt);var ct=class extends f{getResult(){if(this.children.length===2){let n=this.getVariables(),e=n[0],t=n[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",ct);var pt=class extends q{getResult(){if(this.children.length===2){let n=this.getVariables(),e=n[0],t=n[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",pt);import{property as us}from"lit/decorators.js";var Be=class extends f{getResult(){let n=this.context.variables.find(s=>s.identifier===this.identifier);if(!n)return console.warn(`Response ${this.identifier} can not be found`),null;let e=n.mapping,t=Array.isArray(n.value)?n.value:[n.value],r=0;for(let s of t){let l=e.mapEntries.find(i=>T.compareSingleValues(i.mapKey,s,n.baseType));l==null||l.mappedValue==null?r+=e.defaultValue:r+=l.mappedValue}return e.lowerBound!=null&&(r=Math.max(e.lowerBound,r)),e.upperBound!=null&&(r=Math.min(e.upperBound,r)),r}};o([us({type:String})],Be.prototype,"identifier",2);customElements.define("qti-map-response",Be);import{property as dt}from"lit/decorators.js";import{LitElement as hs}from"lit";var K=class extends hs{constructor(){super(...arguments);this.defaultValue=0}get mapEntries(){return Array.from(this.querySelectorAll("qti-map-entry")).map(e=>({mapKey:e.getAttribute("map-key"),mappedValue:+e.getAttribute("mapped-value")}))}};o([dt({attribute:"default-value",type:Number})],K.prototype,"defaultValue",2),o([dt({attribute:"lower-bound",type:Number})],K.prototype,"lowerBound",2),o([dt({attribute:"upper-bound",type:Number})],K.prototype,"upperBound",2);customElements.define("qti-mapping",K);var ut=class p extends f{getResult(){if(this.children.length===2){let n=this.getVariables(),e=n[0],t=n[1];return p.match(e,t)}return console.error("unexpected number of children in match"),null}static match(n,e){switch(e.cardinality){case"single":return n.value===null?!1:Array.isArray(n.value)||Array.isArray(e.value)?(console.error("unexpected cardinality in qti match"),!1):T.compareSingleValues(n.value?.toString(),e.value.toString(),e.baseType);case"ordered":{if(!Array.isArray(n.value)||!Array.isArray(e.value))return console.error("unexpected cardinality in qti match"),!1;if(n.value.length!==e.value.length)return!1;for(let t=0;t<n.value.length;t++)if(!T.compareSingleValues(e.value[t],n.value[t],e.baseType))return!1;return!0}case"multiple":{if(!Array.isArray(n.value)||!Array.isArray(e.value))return console.error("unexpected cardinality in qti match"),!1;if(n.value.length!==e.value.length)return!1;let t=0;for(let r of e.value){let s=null,l=[...n.value];for(let i of l)if(T.compareSingleValues(r,i,e.baseType)){s=i;break}if(s!==null)l.splice(l.indexOf(s),1);else return!1;t++}return!0}default:return console.error("unexpected cardinality in qti match"),!1}}};customElements.define("qti-match",ut);var ht=class extends f{getResult(){let n=this.getVariables();this.children.length!==2&&console.warn("The member operator takes two sub-expressions");let[e,t]=n;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",ht);var mt=class extends f{getResult(){let n=this.getVariables();if(n.length===0)return console.error("unexpected number of children in qti multiple"),null;for(let e of n)if(e.cardinality!=="multiple"&&e.cardinality!=="single")return console.error("unexpected cardinality in qti multiple"),[];return n}};customElements.define("qti-multiple",mt);import{html as ms}from"lit";var ft=class extends f{render(){return ms`${super.render()}`}getResult(){return!this.firstElementChild.calculate()}};customElements.define("qti-not",ft);var gt=class extends q{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(),s=!1;if(typeof r=="string")if(r==="true")s=!0;else if(r==="false")s=!1;else return console.error("unexpected val in qti-or, expected boolean"),null;else typeof r=="boolean"&&(s=r);return s}).some(e=>typeof e=="boolean"&&e)}};customElements.define("qti-or",gt);var bt=class extends f{getResult(){let n=this.getVariables();if(n.length===0)return console.error("unexpected number of children in qti multiple"),null;for(let e of n)if(e.cardinality!=="ordered"&&e.cardinality!=="single")return console.error("unexpected cardinality in qti ordered"),[];return n}};customElements.define("qti-ordered",bt);import{consume as fs}from"@lit/context";import{LitElement as gs,html as bs}from"lit";import{property as vs,state as ys}from"lit/decorators.js";var me=class extends gs{render(){let n=this.context?.variables.find(e=>e.identifier===this.identifier)?.value;return bs`${JSON.stringify(n,null,2)}`}calculate(){return this.context.variables.find(e=>e.identifier===this.identifier)||null}};o([vs({type:String})],me.prototype,"identifier",2),o([fs({context:v,subscribe:!0}),ys()],me.prototype,"context",2);customElements.define("qti-printed-variable",me);var vt=class extends f{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",vt);var Ue=class extends xs(f){getResult(){return this.calculateChildren(Array.from(this.children))}};function xs(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 s=r.calculate();return Number.isNaN(s)?(console.error("Unexpected value in qti-subtract, expected number"),null):Number(s)});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",Ue);import{property as Es}from"lit/decorators.js";var Xe=class extends f{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 s=this.caseSensitive==="true"?t.value:t.value.toLowerCase(),l=this.caseSensitive==="true"?r.value:r.value.toLowerCase();return T.compareSingleValues(s,l,t.baseType)}return console.error("unexpected number of children in qti-string-match"),null}};o([Es({type:String,attribute:"case-sensitive"})],Xe.prototype,"caseSensitive",2);customElements.define("qti-string-match",Xe);var yt=class extends f{constructor(){super(),this._expression=new xt(Array.from(this.children))}getResult(){return this._expression.calculate()}},xt=class{constructor(n){this.expressions=n}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",yt);var Et=class extends f{getResult(){let n=this.getAttribute("identifier");return this.context.variables.find(t=>t.identifier===n).value}};customElements.define("qti-variable",Et);import{html as jt}from"lit";import{customElement as Cs,property as Wt,state as qs}from"lit/decorators.js";var X=class extends m{constructor(){super(...arguments);this._errorMessage=null;this.loadConfig=async(e,t)=>{e=this.removeDoubleSlashes(e);try{let r=await fetch(e);if(r.ok){let l=await r.json();for(let i in l.paths)t&&(l.paths[i]=this.getResolvablePath(l.paths[i],t));return l}}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)}convertQtiVariableJSON(e){for(let t in e)if(e.hasOwnProperty(t)){let r=e[t];if(r){for(let s in r)if(r.hasOwnProperty(s)){let l=r[s];if(Array.isArray(l))return l.map(String);if(l!=null)return String(l)}}}return null}startChecking(){this.intervalId=setInterval(()=>{let e=this.pci.getResponse(),t=this.pci.getResponse(),r=JSON.stringify(e);if(r!==this.rawResponse){this.rawResponse=r;let s=this.convertQtiVariableJSON(t);this.value=s,this.saveResponse(s)}},200)}stopChecking(){this.intervalId!==void 0&&clearInterval(this.intervalId)}validate(){return!0}set value(e){}get value(){return this.rawResponse}getTAOConfig(e){let t=e.querySelectorAll("properties"),r={},s=i=>{let a={},c=i.getAttribute("key");if(c){let d=Array.from(i.children),u=d.map(g=>g.getAttribute("key"));u.length>0&&!u.find(g=>!Number.isInteger(+g))?a[c]=d.map(g=>l(g)):a[c]=i.textContent}return a},l=i=>{if(i){let a={};for(let c of i.children)a={...a,...s(c)};return a}};for(let i of t)return i.getAttribute("key")||(r={...r,...l(i)}),r;return console.log("Can not find qti-custom-interaction config"),null}register(e){this.pci=e;let t=this.parentElement.tagName==="QTI-CUSTOM-INTERACTION"?"TAO":"IMS",r=t=="IMS"?this.querySelector("qti-interaction-markup"):this.querySelector("markup");r.classList.add("qti-customInteraction"),t=="TAO"&&this.querySelector("properties")&&(this.querySelector("properties").style.display="none");let s=t=="IMS"?{properties:this.dataset,onready:()=>{console.log("onready")}}:this.getTAOConfig(this);t=="IMS"?e.getInstance(r,s,void 0):e.initialize(this.customInteractionTypeIdentifier,r.firstElementChild,s),t=="TAO"&&Array.from(this.querySelectorAll("link")).map(i=>i.getAttribute("href")).forEach(i=>{let a=document.createElement("link");a.rel="stylesheet",a.type="text/css",a.media="screen",a.href=i,r.appendChild(a)}),this.startChecking()}connectedCallback(){super.connectedCallback(),define("qtiCustomInteractionContext",()=>({register:r=>{this.register(r)},notifyReady:()=>{}}));let e=this.buildRequireConfig();requirejs.config(e)(["require"],r=>{r([this.module])})}disconnectedCallback(){super.disconnectedCallback(),requirejs.undef(this.customInteractionTypeIdentifier);let e=requirejs.s.contexts;delete e[this.customInteractionTypeIdentifier],this.stopChecking()}buildRequireConfig(){let e={context:this.customInteractionTypeIdentifier,catchError:!0,paths:window.requirePaths||{},shim: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 s=r.querySelectorAll("qti-interaction-module");for(let l of s){let i=l.getAttribute("id"),a=l.getAttribute("primary-path"),c=l.getAttribute("fallback-path");if(i&&a){let d=c?this.combineRequireResolvePaths(this.getResolvablePath(a,t),this.getResolvablePath(c,t)):this.getResolvablePath(a,t),u=e.paths[i]||[];e.paths[i]=this.combineRequireResolvePaths(u,d)}}}return e}combineRequireResolvePaths(e,t){let r=Array.isArray(e)?e:[e],s=Array.isArray(t)?t:[t];return r.concat(s)}removeDoubleSlashes(e){return e.replace(/([^:]\/)\/+/g,"$1").replace(/\/\//g,"/").replace("http:/","http://").replace("https:/","https://")}render(){return jt`<slot></slot>${this._errorMessage&&jt`<div style="color:red">
366
+ <h1>Error</h1>
367
+ ${this._errorMessage}
368
+ </div>`}`}};o([Wt({type:String,attribute:"module"})],X.prototype,"module",2),o([Wt({type:String,attribute:"custom-interaction-type-identifier"})],X.prototype,"customInteractionTypeIdentifier",2),o([qs()],X.prototype,"_errorMessage",2),X=o([Cs("qti-portable-custom-interaction")],X);import{html as Zt}from"lit";import{customElement as ws,state as Ms}from"lit/decorators.js";var Kt=(p,n,e)=>{class t extends p{}return t};import{property as Ct}from"lit/decorators.js";var k=(p,n,e,t)=>{class r extends Kt(p,e,n){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.rootNode=null;this.allDropzones=[];this.lastTarget=null;this.dropzoneOriginalParent=null;this.currentDropTarget=null;this.MIN_DRAG_DISTANCE=5;this.DRAG_CLONE_OPACITY=1;this.dataTransfer={data:{},setData(i,a){this.data[i]=a},getData(i){return this.data[i]},effectAllowed:"move"};this.configuration={copyStylesDragClone:!0,dragCanBePlacedBack:!0,dragOnClick:!1};this.minAssociations=1;this.maxAssociations=1;this.draggablesModified=(i,a)=>{for(let d of a)this.draggables.includes(d)&&(this.draggables=this.draggables.filter(u=>u!==d),d.removeAttribute("tabindex"),d.removeEventListener("touchstart",this.handleTouchStart.bind(this)),d.removeEventListener("mousedown",this.handleTouchStart.bind(this)));for(let d of i)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"),d.addEventListener("dragstart",this.handleDragStart),d.addEventListener("dragend",this.handleDragEnd),c++})};this.droppablesModified=(i,a)=>{for(let c of a)this.droppables.includes(c)&&(this.droppables=this.droppables.filter(d=>d!==c),this.allDropzones=this.allDropzones.filter(d=>d!==c));for(let c of i)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")};this.handleDragStart=i=>{let a=i.currentTarget;i.dataTransfer.setData("text",a.getAttribute("identifier")),this.responseIdentifier&&i.dataTransfer.setData("responseIdentifier",this.responseIdentifier),this._internals.states.add("--dragzone-enabled"),this._internals.states.add("--dragzone-active"),a.setAttribute("dragging",""),this.activateDragLocation(),this.activateDroppables(a)};this.handleDragEnd=async i=>{i.preventDefault();let a=i.currentTarget;this._internals.states.delete("--dragzone-enabled"),this._internals.states.delete("--dragzone-active"),this.deactivateDragLocation(),this.deactivateDroppables(),a.removeAttribute("dragging")}}handleDraggableContainerChange(i,a){this.isMatchTabular()||(i.length>0||a.length>0)&&this.dragContainersModified(i||[],a||[])}dragContainersModified(i,a){for(let c of a)this.dragContainers.includes(c)&&(this.dragContainers=this.dragContainers.filter(d=>d!==c),this.allDropzones=this.allDropzones.filter(d=>d!==c));for(let c of i)this.dragContainers.includes(c)||(this.dragContainers.push(c),this.allDropzones.push(c))}handleDraggablesChange(i,a){this.isMatchTabular()||(i.length>0||a.length>0)&&this.draggablesModified(i||[],a||[])}handleDroppablesChange(i,a){this.isMatchTabular()||(i.length>0||a.length>0)&&this.droppablesModified(i||[],a||[])}firstUpdated(i){super.firstUpdated(i),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(n)||[]).concat(Array.from(this.shadowRoot?.querySelectorAll(n)||[])),d=Array.from(this.querySelectorAll(e)||[]).concat(Array.from(this.shadowRoot?.querySelectorAll(e)||[])),u=Array.from(this.querySelectorAll(t)||[]).concat(Array.from(this.shadowRoot?.querySelectorAll(t)||[]));this.dragContainersModified(u,[]),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(g=>this.resizeObserver?.observe(g))}async moveDraggableToDroppable(i,a){(()=>{i.style.transform="translate(0, 0)",a.tagName==="SLOT"?i.setAttribute("slot",a.getAttribute("name")):a.appendChild(i),this.checkAllMaxAssociations(),this.saveResponse()})()}activateDroppable(i){this.dragContainers.includes(i)?(this._internals.states.add("--dragzone-active"),i.setAttribute("active","")):(this._internals.states.delete("--dragzone-active"),i.setAttribute("active",""))}deactivateDroppable(i,a=!0){a&&this._internals.states.add("--dragzone-active"),i.removeAttribute("active")}connectedCallback(){super.connectedCallback()}isMatchTabular(){return this.classList.contains("qti-match-tabular")}updateMinDimensionsForDropZones(){let i=this.querySelectorAll(n),a=Array.from(this.querySelectorAll(e)).map(h=>h),c=0,d=0;i.forEach(h=>{let g=h.getBoundingClientRect();c=Math.max(c,g.height),d=Math.max(d,g.width)});let u=this.querySelector(t)||this.shadowRoot?.querySelector(t);u&&(u.style.minHeight=`${c}px`,u.style.minWidth=`${d}px`);for(let h of a)h.style.minHeight=`${c}px`,h.style.minWidth=`${d}px`}activateDroppables(i){this.dragContainers.forEach(c=>{c.setAttribute("enabled",""),c.hasAttribute("disabled")&&(c.contains(i)||c.shadowRoot&&c.shadowRoot.contains(i))&&c.removeAttribute("disabled")}),this.droppables.forEach(c=>{c.setAttribute("enabled",""),c.hasAttribute("disabled")&&(c.contains(i)||c.shadowRoot&&c.shadowRoot.contains(i))&&c.removeAttribute("disabled")})}activateDragLocation(){this._internals.states.add("--dragzone-enabled")}deactivateDragLocation(){this._internals.states.delete("--dragzone-enabled")}deactivateDroppables(){this.dragContainers.forEach(a=>{a.removeAttribute("enabled")}),this.droppables.forEach(a=>a.removeAttribute("enabled"))}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(i){if(this.isDraggable&&this.dragClone){let{x:a,y:c}=this.getEventCoordinates(i),d={clientX:a,clientY:c};this.calculateDragDistance(d)>=this.MIN_DRAG_DISTANCE&&(this.isDragging=!0,this.updateDragClonePosition(d));let u=this.findClosestDropzone();this.currentDropTarget=u,u!==this.lastTarget&&(this.lastTarget&&(this.deactivateDroppable(this.lastTarget),this.dispatchCustomEvent(this.lastTarget,"dragleave")),u&&(this.activateDroppable(u),this.dispatchCustomEvent(u,"dragenter")),this.lastTarget=u),this.currentDropTarget&&this.dispatchCustomEvent(this.currentDropTarget,"dragover"),i.preventDefault()}}handleTouchEnd(i){if(this.isDragging){if(this.currentDropTarget){let a=this.dragClone;this.moveDraggableToDroppable(a,this.currentDropTarget)}this.resetDragState()}this._internals.states.delete("--dragzone-active"),this.checkAllMaxAssociations(),i.preventDefault()}handleTouchCancel(i){this.resetDragState()}validate(){if(!this.shadowRoot)return!1;let i=this.getValidAssociations(),a=!0,c="";this.maxAssociations>0&&i>this.maxAssociations?(a=!1,c=this.dataset.maxSelectionsMessage||`You've selected too many associations. Maximum allowed is ${this.maxAssociations}.`):this.minAssociations>0&&i<this.minAssociations&&(a=!1,c=this.dataset.minSelectionsMessage||`You haven't selected enough associations. Minimum required is ${this.minAssociations}.`);let d=this.lastElementChild;return this._internals.setValidity(a?{}:{customError:!0},c,d),this.reportValidity(),a}reportValidity(){let i=this.shadowRoot.querySelector("#validationMessage");return i&&(this._internals.validity.valid?(i.textContent="",i.style.display="none"):(i.textContent=this._internals.validationMessage,i.style.display="block")),this._internals.validity.valid}checkMaxAssociations(i){let a=this.getMatchMaxValue(i),c=i.querySelectorAll('[qti-draggable="true"]').length;return a===0||c>=a}resetDragState(){if(this.dragClone)if(!(this.currentDropTarget!==null)||this.dragContainers.includes(this.currentDropTarget))this.dragSource.style.opacity="1.0",this.dragSource.style.display="block",this.dragSource.style.pointerEvents="auto",this.dragClone.remove();else{let c=window.getComputedStyle(this.dragSource);for(let d=0;d<c.length;d++){let u=c[d];this.dragClone.style.setProperty(u,c.getPropertyValue(u))}this.dragClone.style.opacity="1.0",this.dragClone.style.display="block",this.dragClone.style.pointerEvents="auto"}this.isDragging=!1,this.isDraggable=!1,this.dragSource=null,this.dragClone=null,this.touchStartPoint=null,this.currentDropTarget=null,this.lastTarget=null}checkAllMaxAssociations(){this.droppables.forEach(i=>{this.checkMaxAssociations(i)?this.disableDroppable(i):this.enableDroppable(i)})}getMatchMaxValue(i){let a=i.getAttribute("match-max");return a?parseInt(a,10):1}disableDroppable(i){i.setAttribute("disabled","")}enableDroppable(i){i.removeAttribute("disabled")}get value(){return this.collectResponseData()}set value(i){if(!this.isMatchTabular())if(Array.isArray(i)){i?.forEach(c=>this.placeResponse(c));let a=new FormData;i.forEach(c=>{a.append(this.responseIdentifier,c)}),this._internals.setFormValue(a)}else this._internals.setFormValue(i)}placeResponse(i){let[a,...c]=i.split(" ").reverse(),d=this.findDroppableById(a);c.forEach(u=>this.placeDraggableInDroppable(u,d))}findDroppableById(i){return this.droppables.find(a=>a.getAttribute("identifier")===i)}async placeDraggableInDroppable(i,a){let c=this.querySelector(`[identifier=${i}]`);if(!a||!c){console.error(`Cannot find draggable or droppable with the given identifier: ${i}`);return}let d=()=>{c.style.transform="translate(0, 0)",console.log("droppable",a),a.appendChild(c),this.checkAllMaxAssociations()};document.startViewTransition?await document.startViewTransition(d).finished:d()}getValidAssociations(){return this.droppables.filter(i=>i.childElementCount>0).length}saveResponse(){this.validate();let i=this.collectResponseData();this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,composed:!0,detail:{responseIdentifier:this.responseIdentifier,response:i}}))}collectResponseData(){return this.droppables.map(a=>{let c=a.querySelectorAll('[qti-draggable="true"]'),d=Array.from(c).map(h=>h.getAttribute("identifier")),u=a.getAttribute("identifier");return d.map(h=>`${h} ${u}`)}).flat()}reset(i=!0){i&&this.saveResponse()}updateDragClonePosition(i){if(!this.isDragging||!this.dragClone)return;let a=i.clientX-this.cloneOffset.x,c=i.clientY-this.cloneOffset.y,{newLeft:d,newTop:u}=this.applyBoundaries(a,c,this.dragClone);this.dragClone.style.left=`${d}px`,this.dragClone.style.top=`${u}px`}getEventCoordinates(i,a=!1){let c=i.touches?i.touches[0]:i;return{x:a?c.pageX:c.clientX,y:a?c.pageY:c.clientY}}calculateDragDistance(i){let a=Math.abs(i.clientX-this.touchStartPoint.x),c=Math.abs(i.clientY-this.touchStartPoint.y);return a+c}applyBoundaries(i,a,c){let d=new DOMRect(0,0,window.innerWidth,window.innerHeight);this.rootNode instanceof ShadowRoot?d=this.rootNode.host.getBoundingClientRect():this.rootNode instanceof Document&&(d=document.documentElement.getBoundingClientRect());let u=c.getBoundingClientRect(),h=u.width,g=u.height,A=Math.max(d.left,Math.min(i,d.right-h)),b=Math.max(d.top,Math.min(a,d.bottom-g));return{newLeft:A,newTop:b}}findClosestDropzone(){let i=this.allDropzones.filter(u=>!u.hasAttribute("disabled"));if(!this.dragClone||i.length===0)return null;let a=this.dragClone.getBoundingClientRect(),c=null,d=0;for(let u of i){let h=u.getBoundingClientRect(),g=this.calculateOverlapArea(a,h);g>d&&(d=g,c=u)}if(!c){let u=200;for(let h of i){let g=h.getBoundingClientRect(),A=Math.sqrt(Math.pow(a.left-g.left,2)+Math.pow(a.top-g.top,2));A<u&&(u=A,c=h)}}return c}calculateOverlapArea(i,a){let c=Math.max(0,Math.min(i.right,a.right)-Math.max(i.left,a.left)),d=Math.max(0,Math.min(i.bottom,a.bottom)-Math.max(i.top,a.top));return c*d}dispatchCustomEvent(i,a,c=!0){if(!i)return;let d=new CustomEvent(a,{bubbles:c,cancelable:!0});d.dataTransfer=this.dataTransfer,i.dispatchEvent(d)}handleTouchStart(i){let{x:a,y:c}=this.getEventCoordinates(i);this.dropzoneOriginalParent=i.currentTarget.parentElement,this.touchStartPoint={x:a,y:c},this.dragSource=i.currentTarget,this.isDraggable=!0,this.rootNode=this.dragSource.getRootNode();let d=this.findDraggableInDraggableContainer(this.dragSource.getAttribute("identifier")),u=this.dragSource.parentElement;if(this.droppables.includes(u)){this.enableDroppable(u),this.dragClone=this.dragSource,this.dragSource=this.findDraggableInDraggableContainer(this.dragSource.getAttribute("identifier"));let h=this.findParentInteractionElement(this.dragSource),g=this.dragClone.getBoundingClientRect();h?h.appendChild(this.dragClone):this.rootNode instanceof ShadowRoot?this.rootNode.host.appendChild(this.dragClone):this.rootNode instanceof Document&&document.body.appendChild(this.dragClone),g&&this.setDragCloneStyles(g)}else{let h=d.getBoundingClientRect();this.cloneOffset.x=a-h.left,this.cloneOffset.y=c-h.top,this.dragClone=d.cloneNode(!0),h&&this.setDragCloneStyles(h);let g=this.findParentInteractionElement(this.dragSource);g?g.appendChild(this.dragClone):this.rootNode instanceof ShadowRoot?this.rootNode.host.appendChild(this.dragClone):this.rootNode instanceof Document&&document.body.appendChild(this.dragClone);let A=this.getMatchMaxValue(this.dragSource),b=this.draggables.filter(Ke=>Ke.getAttribute("identifier")===this.dragSource.getAttribute("identifier"));A!==0&&b.length>=A?(d.style.opacity="0.0",d.style.pointerEvents="none"):d.style.opacity="1.0",i.preventDefault()}}findParentInteractionElement(i){let a=i.parentElement;for(;a&&!a.tagName?.toLowerCase().endsWith("-interaction");)a=a.parentElement;return a}findDraggableInDraggableContainer(i){let a=this.dragContainers.flat();for(let c of a){if(c.getAttribute("identifier")===i)return c;let u=Array.from(c.assignedElements()||[]).find(h=>h.getAttribute("identifier")===i);if(u)return u}}setDragCloneStyles(i){this.dragClone.style.position="fixed",this.dragClone.style.top=`${i.top}px`,this.dragClone.style.left=`${i.left}px`,this.dragClone.style.width=`${i.width}px`,this.dragClone.style.height=`${i.height}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 o([Ct({attribute:!1,type:Object})],r.prototype,"configuration",2),o([Ct({type:Number,reflect:!0,attribute:"min-associations"})],r.prototype,"minAssociations",2),o([Ct({type:Number,reflect:!0,attribute:"max-associations"})],r.prototype,"maxAssociations",2),o([Me(t)],r.prototype,"handleDraggableContainerChange",1),o([Me(n)],r.prototype,"handleDraggablesChange",1),o([Me(e)],r.prototype,"handleDroppablesChange",1),r};import{css as Ts}from"lit";var Jt=Ts`
369
+ :host {
370
+ display: block; /* necessary to calculate scaling position */
371
+ }
372
+ slot[name='qti-simple-associable-choice'] {
373
+ display: flex;
374
+ align-items: flex-start;
375
+ flex: 1;
376
+ border: 2px solid transparent;
377
+ padding: 0.3rem;
378
+ border-radius: 0.3rem;
379
+ gap: 0.5rem;
380
+ }
381
+
382
+ :host::part(associables-container) {
383
+ display: flex;
384
+ padding: 0.5rem;
385
+ justify-content: space-between;
386
+ background: linear-gradient(
387
+ 180deg,
388
+ rgb(0 0 0 / 0%) calc(50% - 1px),
389
+ var(--qti-border-color-gray) calc(50%),
390
+ rgb(0 0 0 / 0%) calc(50% + 1px)
391
+ );
392
+ }
393
+ `;var J=class extends k(m,"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 Zt` <slot name="prompt"></slot>
394
+ <slot name="qti-simple-associable-choice"></slot>
395
+ <div part="drop-container">
396
+ ${this._childrenMap.length>0&&Array.from(Array(Math.ceil(this._childrenMap.length/2)).keys()).map((e,t)=>Zt`<div part="associables-container">
397
+ <div name="left${t}" part="drop-list" class="dl" identifier="droplist${t}_left"></div>
398
+ <div name="right${t}" part="drop-list" class="dl" identifier="droplist${t}_right"></div>
399
+ </div>`)}
400
+
401
+ <div role="alert" id="validationMessage"></div>
402
+ </div>`}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("register-qti-simple-associable-choice",this._registerChoiceHandler)}};J.styles=Jt,o([Ms()],J.prototype,"_childrenMap",2),J=o([ws("qti-associate-interaction")],J);import{html as Gt}from"lit";import{customElement as Ss,property as Ye,state as Rs}from"lit/decorators.js";var V=class extends m{constructor(){super();this._errorMessage=null;this.handlePostMessage=this.handlePostMessage.bind(this)}connectedCallback(){super.connectedCallback();let e=this.data.startsWith("http")?this.data:oe(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;window.addEventListener("message",this.handlePostMessage),t.open(),t.write(`
403
+ <html>
404
+ <head>
405
+ <link href='${oe(`${this.baseRefUrl}/${this.manifest.style[0]}`)}' rel="stylesheet" />
406
+ <script src='${oe(`${this.baseRefUrl}/${this.manifest.script[0]}`)}'></script>
407
+ </head>
408
+ <body></body>
409
+ </html>
410
+ `),t.close()}getIFrames(){let e=this.shadowRoot.querySelectorAll("iframe"),t=this.querySelectorAll("iframe"),r=[...e,...t];for(let s of r){let l=s.src;if(new URL(l,window.location.href).origin===window.location.origin)try{let a=s.contentDocument||s.contentWindow.document;a&&this.getInnerIFrames(a,r)}catch(a){console.error("Error accessing nested iframe:",a)}}return r.forEach((s,l)=>{r.indexOf(s)!==l&&r.splice(l,1)}),r}getInnerIFrames(e,t=[]){return e.querySelectorAll("iframe").forEach(s=>{t.push(s);let l=s.src;if(new URL(l,window.location.href).origin===window.location.origin)try{let a=s.contentDocument||s.contentWindow.document;this.getInnerIFrames(a,t)}catch(a){console.error("Error accessing nested iframe:",a)}else console.warn("Skipped cross-origin iframe:",l)}),t}postToWindowAndIframes(e,t){window.postMessage({type:e,data:t},"*");let r=this.getIFrames();for(let s of r)s.contentWindow&&s.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 s=this.manifest.media.map(l=>l.startsWith("http")?l:oe(this.baseRefUrl+"/"+l));this.postToWindowAndIframes("mediaData",s);break}case"setStageHeight":console.log("setStageHeight not implemented");break}}validate(){return this.rawResponse!==""}get value(){return this.rawResponse}set value(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 Gt`<iframe
411
+ width=${this.getAttribute("width")}
412
+ height=${this.getAttribute("height")}
413
+ frameborder="0"
414
+ title="pciContainer"
415
+ id="pciContainer"
416
+ >
417
+ </iframe>
418
+ ${this._errorMessage&&Gt`<div style="color:red">
419
+ <h1>Error</h1>
420
+ ${this._errorMessage}
421
+ </div>`}`}};o([Ye({type:String,attribute:"data"})],V.prototype,"data",2),o([Ye({type:String,attribute:"data-base-item"})],V.prototype,"baseItemUrl",2),o([Ye({type:String,attribute:"data-base-ref"})],V.prototype,"baseRefUrl",2),o([Ye({type:String,attribute:"id"})],V.prototype,"id",2),o([Rs()],V.prototype,"_errorMessage",2),V=o([Ss("qti-custom-interaction")],V);import{html as _s,LitElement as ks}from"lit";import{customElement as Ls,property as je}from"lit/decorators.js";var F=class extends ks{constructor(){super(...arguments);this.disabled=!1;this.countAttempt=null;this.title="end attempt"}render(){return _s`<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"}}))}};o([je({type:String,attribute:"response-identifier"})],F.prototype,"responseIdentifier",2),o([je({reflect:!0,type:Boolean})],F.prototype,"disabled",2),o([je({type:String,attribute:"count-attempt"})],F.prototype,"countAttempt",2),o([je({type:String})],F.prototype,"title",2),F=o([Ls("qti-end-attempt-interaction")],F);import{html as Ds}from"lit";import{customElement as Vs}from"lit/decorators.js";import{css as As}from"lit";var Qt=As`
422
+ :host {
423
+ display: flex;
424
+ align-items: flex-start;
425
+ flex-direction: column;
426
+ flex-wrap: wrap;
427
+ gap: 0.5rem;
428
+ }
429
+
430
+ :host(.qti-choices-top) {
431
+ flex-direction: column;
432
+ }
433
+ :host(.qti-choices-bottom) {
434
+ flex-direction: column-reverse;
435
+ }
436
+ :host(.qti-choices-left) {
437
+ flex-direction: row;
438
+ }
439
+ :host(.qti-choices-right) {
440
+ flex-direction: row-reverse;
441
+ }
442
+ /* [part='drops'] , */
443
+ [name='prompt'] {
444
+ width: 100%;
445
+ }
446
+ [name='drags'] {
447
+ display: flex;
448
+ align-items: flex-start;
449
+ flex: 1;
450
+ border: 2px solid transparent;
451
+ padding: 0.3rem;
452
+ border-radius: 0.3rem;
453
+ gap: 0.5rem;
454
+ }
455
+ `;var fe=class extends k(m,"qti-gap-text","qti-gap","slot[part='drags']"){render(){return Ds`<slot name="prompt"> </slot>
456
+ <slot part="drags" name="drags"></slot>
457
+ <slot part="drops"></slot>
458
+ <div role="alert" id="validationMessage"></div>`}set correctResponse(n){let e=[],t=Array.isArray(n)?n:[n];t&&(e=t.map(s=>{let l=s.split(" ");return{text:l[0],gap:l[1]}})),this.querySelectorAll("qti-gap").forEach(s=>{let l=s.getAttribute("identifier"),i=e.find(c=>c.gap===l)?.text,a=this.querySelector(`qti-gap-text[identifier="${i}"]`)?.textContent.trim();if(i&&a){if(!s.nextElementSibling?.classList.contains("correct-option")){let c=document.createElement("span");c.classList.add("correct-option"),c.textContent=a,s.insertAdjacentElement("afterend",c)}}else s.nextElementSibling?.classList.contains("correct-option")&&s.nextElementSibling.remove()})}};fe.styles=Qt,fe=o([Vs("qti-gap-match-interaction")],fe);import{html as Hs,svg as tr}from"lit";import{customElement as $s,queryAssignedElements as Is,state as qt}from"lit/decorators.js";import{ifDefined as rr}from"lit/directives/if-defined.js";import{repeat as Os}from"lit/directives/repeat.js";function Z(p,n,e,t){switch(p){case"circle":{let[r,s,l]=n,i=r/e.width*100,a=s/e.height*100,c=l/e.width*100;t.style.left=i-c+"%",t.style.top=a-c+"%",t.style.width=t.style.height=4*c+"px",t.style.borderRadius="9999px"}break;case"rect":{let[r,s,l,i]=n,a=r/e.width*100,c=s/e.height*100,d=l/e.width*100,u=i/e.height*100;t.style.left=a+"%",t.style.top=c+"%",t.style.width=d-a+"%",t.style.height=u-c+"%"}break;case"poly":{let r=n.reduce((b,Ke,St,gr)=>{if(St%2===1){let br=b.pop();b[b.length]={x:br,y:gr[St]}}else b.push(Ke);return b},[]),s=Math.min(...r.map(b=>b.x)),l=Math.max(...r.map(b=>b.x)),i=Math.min(...r.map(b=>b.y)),a=Math.max(...r.map(b=>b.y)),c=s/e.width*100,d=i/e.height*100,u=l/e.width*100,h=a/e.height*100;t.style.left=s/e.width*100+"%",t.style.top=i/e.height*100+"%",t.style.width=u-c+"%",t.style.height=h-d+"%";let A=r.map(b=>({x:(b.x-s)/(l-s)*100,y:(b.y-i)/(a-i)*100})).map(b=>Math.round(b.x)+"% "+Math.round(b.y)+"%").join(",");t.style.clipPath=`polygon(${A})`}break;default:break}}import{css as Ns}from"lit";var er=Ns`
459
+ slot:not([name='prompt']) {
460
+ // position: relative; /* qti-hotspot-choice relative to the slot */
461
+ display: block;
462
+ width: fit-content; /* hotspots not stretching further if image is at max size */
463
+ }
464
+ ::slotted(img) {
465
+ /* image not selectable anymore */
466
+ pointer-events: none;
467
+ user-select: none;
468
+ }
469
+ ::slotted(qti-associable-hotspot) {
470
+ transform: translate(-50%, -50%);
471
+ }
472
+ line-container {
473
+ display: block;
474
+ position: relative;
475
+ }
476
+ svg {
477
+ position: absolute;
478
+ top: 0px;
479
+ left: 0px;
480
+ }
481
+ `;var N=class extends m{constructor(){super();this.startPoint=null;this.endPoint=null;this._lines=[];this.addEventListener("qti-register-hotspot",this.positionHotspotOnRegister)}reset(){this._lines=[]}validate(){return this._lines.length>0}set value(e){Array.isArray(e)&&(this._lines=e)}get value(){return this._lines}render(){return Hs`<slot name="prompt"></slot>
482
+ <line-container>
483
+ <svg
484
+ width=${rr(this.grImage[0]?.width)}
485
+ height=${rr(this.grImage[0]?.height)}
486
+ viewbox="0 0 ${this.grImage[0]?.width} ${this.grImage[0]?.height}"
487
+ >
488
+ ${Os(this._lines,e=>e,(e,t)=>tr`
489
+ <line
490
+ part="line"
491
+ x1=${parseInt(this.querySelector("[identifier="+e.split(" ")[0]+"]").style.left)}
492
+ y1=${parseInt(this.querySelector("[identifier="+e.split(" ")[0]+"]").style.top)}
493
+ x2=${parseInt(this.querySelector("[identifier="+e.split(" ")[1]+"]").style.left)}
494
+ y2=${parseInt(this.querySelector("[identifier="+e.split(" ")[1]+"]").style.top)}
495
+ stroke="red"
496
+ stroke-width="3"
497
+ @click=${r=>{r.stopPropagation(),this._lines=this._lines.filter((s,l)=>l!==t),this.saveResponse(this._lines)}}
498
+ />
499
+ `)}
500
+ ${this.startPoint&&tr`<line
501
+ part="point"
502
+ x1=${this.startCoord.x}
503
+ y1=${this.startCoord.y}
504
+ x2=${this.mouseCoord.x}
505
+ y2=${this.mouseCoord.y}
506
+ stroke="red"
507
+ stroke-width="3"
508
+ />`}
509
+ </svg>
510
+ <slot></slot>
511
+ </line-container>
512
+ <div role="alert" id="validationMessage"></div>`}positionHotspotOnRegister(e){let t=this.querySelector("img"),r=e.target,s=r.getAttribute("coords"),l=r.getAttribute("shape"),i=s.split(",").map(a=>parseInt(a));Z(l,i,t,r)}firstUpdated(e){super.firstUpdated(e),this.hotspots=this.querySelectorAll("qti-associable-hotspot"),document.addEventListener("mousemove",t=>{this.mouseCoord={x:t.clientX-this.grImage[0].getBoundingClientRect().left,y:t.clientY-this.grImage[0].getBoundingClientRect().top}}),this.hotspots.forEach(t=>{t.style.left=t.getAttribute("coords").split(",")[0]+"px",t.style.top=t.getAttribute("coords").split(",")[1]+"px",t.addEventListener("click",r=>{this.startPoint?this.endPoint||(this.endPoint=r.target,this._lines=[...this._lines,this.startPoint.getAttribute("identifier")+" "+this.endPoint.getAttribute("identifier")],this.saveResponse(this._lines),this.startPoint=null,this.endPoint=null):(this.startPoint=r.target,this.startCoord={x:this.startPoint.getAttribute("coords").split(",")[0],y:this.startPoint.getAttribute("coords").split(",")[1]})})})}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-register-hotspot",this.positionHotspotOnRegister)}};N.styles=er,o([qt()],N.prototype,"_lines",2),o([qt()],N.prototype,"startCoord",2),o([qt()],N.prototype,"mouseCoord",2),o([Is({selector:"img"})],N.prototype,"grImage",2),N=o([$s("qti-graphic-associate-interaction")],N);import{html as Fs}from"lit";import{customElement as zs}from"lit/decorators.js";import{css as Ps}from"lit";var ir=Ps`
513
+ :host {
514
+ display: flex;
515
+ align-items: flex-start;
516
+ flex-direction: column;
517
+ flex-wrap: wrap;
518
+ gap: 0.5rem;
519
+ }
520
+
521
+ :host(.qti-choices-top) {
522
+ flex-direction: column-reverse;
523
+ }
524
+ :host(.qti-choices-bottom) {
525
+ flex-direction: column;
526
+ }
527
+ :host(.qti-choices-left) {
528
+ flex-direction: row-reverse;
529
+ & [name='drags'] {
530
+ width: 25%;
531
+ }
532
+ & [part='image'] {
533
+ width: 75%;
534
+ }
535
+ }
536
+ :host(.qti-choices-right) {
537
+ flex-direction: row;
538
+ & [name='drags'] {
539
+ width: 25%;
540
+ }
541
+ & [part='image'] {
542
+ width: 75%;
543
+ }
544
+ }
545
+ [part='image'] {
546
+ display: block;
547
+ position: relative;
548
+ }
549
+ /* [part='drops'] , */
550
+
551
+ [name='drags'] {
552
+ display: flex;
553
+ align-items: flex-start;
554
+ flex-wrap: wrap;
555
+ flex: 1;
556
+ border: 2px solid transparent;
557
+ padding: 0.3rem;
558
+ border-radius: 0.3rem;
559
+ gap: 0.5rem;
560
+ }
561
+ ::slotted(img) {
562
+ display: inline-block;
563
+ user-select: none;
564
+ pointer-events: none;
565
+ }
566
+ `;var ge=class extends k(m,"qti-gap-img, qti-gap-text","qti-associable-hotspot","slot[part='drags']"){render(){return Fs` <slot name="prompt"></slot>
567
+ <slot part="image"></slot>
568
+ <slot part="drags" name="drags" class="hover-border"></slot>
569
+ <div role="alert" id="validationMessage"></div>`}positionHotspotOnRegister(n){let e=n.target,t=e.getAttribute("coords"),r=e.getAttribute("shape"),s=t.split(",").map(l=>parseInt(l));switch(r){case"circle":{let[l,i,a]=s;e.style.left=l-a+"px",e.style.top=i-a+"px",e.style.width=e.style.height=2*a+"px"}break;case"rect":{let[l,i,a,c]=s;e.style.left=l+"px",e.style.top=i+"px",e.style.width=a-l+"px",e.style.height=c-i+"px"}break;default:break}}connectedCallback(){super.connectedCallback(),this.addEventListener("qti-register-hotspot",this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-register-hotspot",this.positionHotspotOnRegister)}};ge.styles=ir,ge=o([zs("qti-graphic-gap-match-interaction")],ge);import{html as Us}from"lit";import{customElement as Xs}from"lit/decorators.js";import{css as Bs}from"lit";var sr=Bs`
570
+ slot:not([name='prompt']) {
571
+ position: relative; /* qti-hotspot-choice relative to the slot */
572
+ display: block;
573
+ width: fit-content; /* hotspots not stretching further if image is at max size */
574
+ }
575
+ ::slotted(img) {
576
+ /* image not selectable anymore */
577
+ pointer-events: none;
578
+ user-select: none;
579
+ }
580
+ `;var be=class extends O(m,"qti-hotspot-choice"){constructor(){super(...arguments);this._choiceElements=[]}render(){return Us`
581
+ <slot name="prompt"></slot>
582
+ <slot></slot>
583
+ <div role="alert" id="validationMessage"></div>
584
+ `}setHotspotOrder(e){let{identifier:t}=e.detail,r=this._choiceElements.find(l=>l.getAttribute("identifier")===t),s=this._choiceElements.length;if(!this.choiceOrdering){if(this.choiceOrdering=!0,r.order==null){if(this._choiceElements.filter(l=>l.order>0).length>=s){this.choiceOrdering=!1;return}r.order=this._choiceElements.filter(l=>!!l.order).length+1,this.choiceOrdering=!1;return}else this._choiceElements.forEach(l=>(l.order>l.order&&l.order--,l)),r.order=null;this.choiceOrdering=!1}}positionHotspotOnRegister(e){let t=this.querySelector("img"),r=e.target,s=r.getAttribute("coords"),l=r.getAttribute("shape"),i=s.split(",").map(a=>parseInt(a));Z(l,i,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)}};be.styles=sr,be=o([Xs("qti-graphic-order-interaction")],be);import{html as js}from"lit";import{customElement as Ws}from"lit/decorators.js";import{css as Ys}from"lit";var or=Ys`
585
+ slot:not([name='prompt']) {
586
+ position: relative; /* qti-hotspot-choice relative to the slot */
587
+ display: block;
588
+ width: fit-content; /* hotspots not stretching further if image is at max size */
589
+ }
590
+ ::slotted(img) {
591
+ /* image not selectable anymore */
592
+ pointer-events: none;
593
+ user-select: none;
594
+ /* width:100%; */
595
+ }
596
+ `;var ve=class extends O(m,"qti-hotspot-choice"){render(){return js`
597
+ <slot name="prompt"></slot>
598
+ <slot></slot>
599
+ `}positionHotspotOnRegister(n){let e=this.querySelector("img"),t=n.target,r=t.getAttribute("coords"),s=t.getAttribute("shape"),l=r.split(",").map(i=>parseInt(i));Z(s,l,e,t)}connectedCallback(){super.connectedCallback(),this.addEventListener("register-qti-hotspot-choice",this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("unregister-qti-hotspot-choice",this.positionHotspotOnRegister)}};ve.styles=or,ve=o([Ws("qti-hotspot-interaction")],ve);import{html as ye,nothing as eo}from"lit";import{customElement as to,property as ar,state as lr}from"lit/decorators.js";import{unsafeHTML as cr}from"lit/directives/unsafe-html.js";import{css as Ks,html as Js,LitElement as Zs}from"lit";import{customElement as Gs,property as Tt}from"lit/decorators.js";var z=class extends w(Zs,"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 Js`
600
+ <slot part="slot"></slot>
601
+ <slot part="dropslot" name="qti-simple-associable-choice"></slot>
602
+ `}};z.styles=Ks`
603
+ :host {
604
+ display: flex;
605
+ user-select: none;
606
+ }
607
+ slot {
608
+ width: 100%;
609
+ display: block;
610
+ }
611
+ slot[name='qti-simple-associable-choice'] {
612
+ width: 100%;
613
+ }
614
+ `,o([Tt({type:Number,attribute:"match-min"})],z.prototype,"matchMin",2),o([Tt({type:Number,attribute:"match-max"})],z.prototype,"matchMax",2),o([Tt({type:Boolean,attribute:"fixed"})],z.prototype,"fixed",2),z=o([Gs("qti-simple-associable-choice")],z);import{css as Qs}from"lit";var nr=Qs`
615
+ slot:not([hidden]) {
616
+ /* slot where the */
617
+ display: flex;
618
+ flex-direction: column;
619
+ gap: 0.5rem;
620
+ align-items: flex-start; /* prevents the drag and drop container slots having the same height */
621
+ }
622
+ :host(.qti-choices-top) slot {
623
+ flex-direction: column;
624
+ }
625
+ :host(.qti-choices-bottom) slot {
626
+ flex-direction: column-reverse;
627
+ }
628
+ :host(.qti-choices-left) slot {
629
+ flex-direction: row;
630
+ }
631
+ :host(.qti-choices-right) slot {
632
+ flex-direction: row-reverse;
633
+ }
634
+ slot[name='prompt'] {
635
+ display: block;
636
+ }
637
+ ::slotted(qti-simple-match-set) {
638
+ /* Make sure the drag and drop container slots have the same width */
639
+ flex: 1;
640
+ }
641
+ `;var H=class extends k(m,"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,s=t.name,l=t.type;t.checked?(this.value?this.value.indexOf(r)===-1&&(l==="radio"&&(this.value=this.value.filter(i=>i.indexOf(s)===-1)),this.value=[...this.value,r]):this.value=[r],this.lastCheckedRadio=t):(this.value=this.value.filter(i=>i!==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.value)?[...this.value]:this.value}}))}}get value(){return this.classList.contains("qti-match-tabular")?this._response:super.value}set value(e){this.classList.contains("qti-match-tabular")?this._response=e:super.value=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.value=[]}set correctResponse(e){if(e===""){this.correctOptions=[];return}else Array.isArray(e)&&(this.correctOptions=e)}render(){let e=this.class.split(" ").includes("qti-match-tabular");return ye`
642
+ <slot name="prompt"></slot>
643
+ <slot ?hidden=${e}></slot>
644
+
645
+ ${e?ye`
646
+ <table>
647
+ <tr>
648
+ <td></td>
649
+ ${this.cols.map(t=>ye`<th part="r-header">${cr(t.innerHTML)}</th>`)}
650
+ </tr>
651
+
652
+ ${this.rows.map(t=>ye`<tr>
653
+ <td part="c-header">${cr(t.innerHTML)}</td>
654
+ ${this.cols.map(r=>{let s=t.getAttribute("identifier"),l=r.getAttribute("identifier"),i=`${s} ${l}`,a=this.value.filter(h=>h.split(" ")[0]===s).length||0,c=this.value.includes(i),d=`rb ${c?"rb-checked":""} ${this.correctOptions.includes(i)?"rb-correct":""}`,u=this.correctOptions.length>0?!0:t.matchMax===1?!1:a>=t.matchMax&&!c;return ye`<td>
655
+ <input
656
+ type=${t.matchMax===1?"radio":"checkbox"}
657
+ part=${d}
658
+ name=${s}
659
+ value=${i}
660
+ .disabled=${u}
661
+ @change=${h=>this.handleRadioChange(h)}
662
+ @click=${h=>t.matchMax===1?this.handleRadioClick(h):null}
663
+ />
664
+ </td>`})}
665
+ </tr>`)}
666
+ </table>
667
+ `:eo}
668
+
669
+ <div role="alert" id="validationMessage"></div>
670
+ `}};H.styles=nr,o([ar({type:String})],H.prototype,"class",2),o([lr()],H.prototype,"_response",2),o([ar({type:String,attribute:"response-identifier"})],H.prototype,"responseIdentifier",2),o([lr()],H.prototype,"correctOptions",2),H=o([to("qti-match-interaction")],H);import{css as ro,html as io}from"lit";import{customElement as so}from"lit/decorators.js";var xe=class extends m{constructor(){super();this._value=0}reset(){}validate(){return!0}get value(){return this._value.toString()}set value(e){if(!isNaN(parseInt(e.toString())))this._value=parseInt(e.toString());else throw new Error("Value must be a number")}static get properties(){return{...m.properties,step:{type:Number,attribute:"step",default:10}}}render(){return io` <slot name="prompt"></slot>
671
+ <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)})}};xe.styles=[ro``],xe=o([so("qti-media-interaction")],xe);import{html as dr}from"lit";import{customElement as no,property as ao,state as wt}from"lit/decorators.js";import{unsafeHTML as lo}from"lit/directives/unsafe-html.js";import{css as oo}from"lit";var pr=oo`
672
+ [part='drags'] {
673
+ display: flex;
674
+ align-items: flex-start;
675
+ flex: 1;
676
+ border: 2px solid transparent;
677
+ }
678
+
679
+ [part='drops'] {
680
+ flex: 1;
681
+ display: grid;
682
+ grid-auto-flow: column;
683
+ grid-auto-columns: 1fr;
684
+ }
685
+
686
+ :host([orientation='horizontal']) [part='drags'] {
687
+ flex-direction: row;
688
+ }
689
+ :host([orientation='horizontal']) [part='drops'] {
690
+ grid-auto-flow: column;
691
+ }
692
+ :host([orientation='vertical']) [part='drags'] {
693
+ flex-direction: column;
694
+ }
695
+ :host([orientation='vertical']) [part='drops'] {
696
+ grid-auto-flow: row;
697
+ }
698
+
699
+ [part='drop-list'] {
700
+ display: block;
701
+ flex: 1;
702
+ }
703
+
704
+ [part='container'] {
705
+ display: flex;
706
+ gap: 0.5rem;
707
+ }
708
+ :host(.qti-choices-top) [part='container'] {
709
+ flex-direction: column;
710
+ }
711
+ :host(.qti-choices-bottom) [part='container'] {
712
+ flex-direction: column-reverse;
713
+ }
714
+ :host(.qti-choices-left) [part='container'] {
715
+ flex-direction: row;
716
+ }
717
+ :host(.qti-choices-right) [part='container'] {
718
+ flex-direction: row-reverse;
719
+ }
720
+ `;var $=class extends $e(k(m,"qti-simple-choice","drop-list","slot[part='drags']"),"qti-simple-choice"){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),dr` <slot name="prompt"> </slot>
721
+ <div part="container">
722
+ <slot part="drags"> </slot>
723
+ <div part="drops">
724
+ ${Array.from(Array(this.nrChoices)).map((t,r)=>dr`<drop-list part="drop-list" identifier="droplist${r}"></drop-list>${this.showCorrectResponses&&this.correctResponses.length>r?lo(`<span part='correct-response'>${this.correctResponses[r]}</span>`):""}`)}
725
+ </div>
726
+ </div>`}set correctResponse(e){if(e===""){this.showCorrectResponses=!1;return}this.correctResponses.length===0&&(Array.isArray(e)?e:[e]).forEach(r=>{let s=this.querySelector(`qti-simple-choice[identifier="${r}"]`);s||(s=this.shadowRoot.querySelector(`qti-simple-choice[identifier="${r}"]`));let l=s?.textContent.trim();this.correctResponses=[...this.correctResponses,l]}),this.showCorrectResponses=!0}getResponse(){return Array.from(this.shadowRoot.querySelectorAll("drop-list")).map(r=>{let s=r.querySelectorAll('[qti-draggable="true"]');return[...Array.from(s).map(i=>i.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"))}};$.styles=pr,o([wt()],$.prototype,"nrChoices",2),o([wt()],$.prototype,"correctResponses",2),o([wt()],$.prototype,"showCorrectResponses",2),o([ao({type:String})],$.prototype,"orientation",2),$=o([no("qti-order-interaction")],$);import{LitElement as co,css as po,html as uo}from"lit";var We=class extends co{render(){return uo`<slot></slot>`}};We.styles=[po`
727
+ :host {
728
+ display: block;
729
+ }
730
+ ::slotted(img) {
731
+ position: absolute;
732
+ cursor: move;
733
+ user-select: none;
734
+ left: 50%;
735
+ transform: translateX(-50%);
736
+ }
737
+ `];customElements.define("qti-position-object-interaction",We);import{LitElement as ho,css as mo,html as fo}from"lit";import{customElement as go}from"lit/decorators.js";var Ee=class extends ho{render(){return fo`<slot></slot>`}constructor(){super(),this.removeMoveListener=this.removeMoveListener.bind(this),this.dragElementHandler=this.dragElementHandler.bind(this)}dragElementHandler(n){n.preventDefault();let e=n.clientX-this.startX,t=n.clientY-this.startY;this.dragElement.style.left=this.dragElement.offsetLeft+e+"px",this.dragElement.style.top=this.dragElement.offsetTop+t+"px",this.startX=n.clientX,this.startY=n.clientY}firstUpdated(n){super.firstUpdated(n),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)}};Ee.styles=[mo`
738
+ :host {
739
+ display: inline-block;
740
+ position: relative;
741
+ }
742
+ `],Ee=o([go("qti-position-object-stage")],Ee);import{css as bo,html as ur}from"lit";import{customElement as vo,property as hr,state as yo}from"lit/decorators.js";import{repeat as xo}from"lit/directives/repeat.js";import{styleMap as Eo}from"lit/directives/style-map.js";var B=class extends m{constructor(){super(...arguments);this.maxChoices=1/0;this.minChoices=0;this._points=[];this._imgElement=null;this._onImageClick=e=>{if(this._points.length<this.maxChoices){let t=e.offsetX,r=e.offsetY;this._points=[...this._points,`${t} ${r}`],this.saveResponse(this._points)}}}render(){return ur` <slot name="prompt"></slot>
743
+ <point-container>
744
+ ${xo(this._points,e=>e,(e,t)=>ur`
745
+ <button
746
+ part="point"
747
+ style=${Eo({position:"absolute",transform:"translate(-50%, -50%)",left:`${e.split(" ")[0]}px`,top:`${e.split(" ")[1]}px`})}
748
+ aria-label="Remove point at ${e}"
749
+ @click=${r=>{r.stopPropagation(),this._points=this._points.filter((s,l)=>l!==t),this.saveResponse(this._points)}}
750
+ ></button>
751
+ `)}
752
+ <slot></slot>
753
+ </point-container>`}reset(){this._points=[]}validate(){return this._points.length>=this.minChoices&&this._points.length<=this.maxChoices}set value(e){this._points=Array.isArray(e)?e:[e]}get value(){return this._points}firstUpdated(){this._imgElement=this.querySelector("img"),this._imgElement?this._imgElement.addEventListener("click",this._onImageClick):console.warn("No <img> element found in <qti-select-point-interaction>")}disconnectedCallback(){super.disconnectedCallback(),this._imgElement&&this._imgElement.removeEventListener("click",this._onImageClick)}};B.styles=[bo`
754
+ :host {
755
+ display: block;
756
+ }
757
+ point-container {
758
+ display: block;
759
+ position: relative;
760
+ }
761
+ `],o([hr({type:Number,attribute:"max-choices"})],B.prototype,"maxChoices",2),o([hr({type:Number,attribute:"min-choices"})],B.prototype,"minChoices",2),o([yo()],B.prototype,"_points",2),B=o([vo("qti-select-point-interaction")],B);import{html as qo,LitElement as To}from"lit";import{customElement as wo,property as Mt,query as Mo}from"lit/decorators.js";import{css as Co}from"lit";var mr=Co`
762
+ :host {
763
+ display: block;
764
+ --show-bounds: true;
765
+ --show-ticks: true;
766
+ --show-value: true;
767
+ }
768
+
769
+ [part='slider'] {
770
+ margin-left: 2rem; /* mx-8 */
771
+ margin-right: 2rem;
772
+ padding-bottom: 1rem; /* pb-4 */
773
+ padding-top: 1.25rem; /* pt-5 */
774
+ }
775
+
776
+ [part='bounds'] {
777
+ display: flex;
778
+ width: 100%;
779
+ justify-content: space-between;
780
+ margin-bottom: 0.5rem; /* mb-2 */
781
+ }
782
+
783
+ [part='ticks'] {
784
+ margin-left: 0.125rem; /* mx-0.5 */
785
+ margin-right: 0.125rem;
786
+ margin-bottom: 0.25rem; /* mb-1 */
787
+ height: 0.5rem; /* h-2 */
788
+ background: linear-gradient(to right, var(--qti-border-color) var(--qti-border-thickness), transparent 1px) repeat-x
789
+ 0 center / calc(calc(100% - var(--qti-border-thickness)) / ((var(--max) - var(--min)) / var(--step))) 100%;
790
+ }
791
+
792
+ [part='rail'] {
793
+ display: flex;
794
+ align-items: center;
795
+ box-sizing: border-box;
796
+ height: 0.375rem; /* h-1.5 */
797
+ width: 100%;
798
+ cursor: pointer;
799
+ border-radius: 9999px; /* rounded-full */
800
+ border: 1px solid #d1d5db; /* border-gray-300 */
801
+ background-color: #e5e7eb; /* bg-gray-200 */
802
+ }
803
+
804
+ [part='knob'] {
805
+ background-color: var(--qti-bg-active);
806
+ border: 2px solid var(--qti-border-active);
807
+ position: relative;
808
+ height: 1rem; /* h-4 */
809
+ width: 1rem; /* w-4 */
810
+ transform-origin: center;
811
+ transform: translateX(-50%);
812
+ cursor: pointer;
813
+ border-radius: 9999px; /* rounded-full */
814
+ left: var(--value-percentage);
815
+ }
816
+
817
+ [part='value'] {
818
+ position: absolute;
819
+ bottom: 2rem; /* bottom-8 */
820
+ left: 0.5rem; /* left-2 */
821
+ transform: translateX(-50%);
822
+ cursor: pointer;
823
+ border-radius: 0.25rem; /* rounded */
824
+ background-color: #f3f4f6; /* bg-gray-100 */
825
+ padding: 0.25rem 0.5rem; /* px-2 py-1 */
826
+ text-align: center;
827
+ color: #6b7280; /* text-gray-500 */
828
+ }
829
+ `;var L=class extends To{constructor(){super();this._value=0;this.min=0;this.max=100;this.step=1;this._internals=this.attachInternals()}connectedCallback(){super.connectedCallback(),this._updateValue(this.min),this.setAttribute("tabindex","0"),this.setAttribute("role","slider")}get value(){return this._value.toString()}set value(e){let t=parseInt(e,10);isNaN(t)||this._updateValue(t)}_updateValue(e){this._value=Math.min(this.max,Math.max(this.min,e));let t=(this._value-this.min)/(this.max-this.min)*100;this.style.setProperty("--value-percentage",`${t}%`),this._internals.setFormValue(this.value),this.requestUpdate()}render(){return qo`
830
+ <slot name="prompt"></slot>
831
+ <div id="slider" part="slider">
832
+ <div id="bounds" part="bounds">
833
+ <div>${this.min}</div>
834
+ <div>${this.max}</div>
835
+ </div>
836
+
837
+ <div id="ticks" part="ticks"></div>
838
+
839
+ <div id="rail" part="rail" @mousedown=${this._onMouseDown} @touchstart=${this._onTouchStart}>
840
+ <div id="knob" part="knob"><div id="value" part="value">${this.value}</div></div>
841
+ </div>
842
+ </div>
843
+ `}_onMouseDown(e){this._startDrag(e.pageX);let t=s=>this._onDrag(s.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=s=>this._onDrag(s.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,s=Math.min(1,Math.max(0,r/t.width)),l=this.min+Math.round(s*(this.max-this.min)/this.step)*this.step;this._updateValue(l)}_onDragEnd(){this.dispatchEvent(new Event("change",{bubbles:!0}))}};L.formAssociated=!0,L.styles=mr,o([Mo("#rail")],L.prototype,"_rail",2),o([Mt({type:Number,attribute:"lower-bound"})],L.prototype,"min",2),o([Mt({type:Number,attribute:"upper-bound"})],L.prototype,"max",2),o([Mt({type:Number,attribute:"step"})],L.prototype,"step",2),L=o([wo("qti-slider-interaction")],L);import{consume as So}from"@lit/context";import{LitElement as Ro,html as _o}from"lit";import{customElement as ko,state as Lo}from"lit/decorators.js";var Ce=class extends Ro{render(){return _o`<slot @slotchange=${this.handleSlotChange}></slot>`}handleSlotChange(){let n=Array.from(this.firstElementChild?.childNodes??[]).find(e=>e.nodeType===Node.COMMENT_NODE);try{this.operatorFunction=new Function("context","fn","item",n?.textContent??"")}catch(e){console.error("custom-operator contains invalid javascript code",e)}}calculate(){let n={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,n,e)}};o([So({context:v,subscribe:!0}),Lo()],Ce.prototype,"_context",2),Ce=o([ko("qti-custom-operator")],Ce);import{LitElement as Ao,css as Do,html as Vo}from"lit";import{customElement as No}from"lit/decorators.js";var qe=class extends Ao{connectedCallback(){super.connectedCallback(),this.dispatchEvent(new CustomEvent("qti-register-hotspot",{bubbles:!0,composed:!0,cancelable:!1}))}render(){return Vo` <slot name="drags"></slot> `}};qe.styles=Do`
844
+ :host {
845
+ display: flex;
846
+ user-select: none;
847
+ position: absolute;
848
+ }
849
+ `,qe=o([No("qti-associable-hotspot")],qe);import{css as Ho,html as $o,LitElement as Io}from"lit";import{customElement as Oo,property as Po}from"lit/decorators.js";var G=class extends Io{constructor(){super(...arguments);this.tabindex=0}render(){return $o` <slot name="drags"></slot>`}};G.styles=Ho`
850
+ :host {
851
+ display: flex;
852
+ user-select: none;
853
+ }
854
+ `,o([Po({type:Number,reflect:!0})],G.prototype,"tabindex",2),G=o([Oo("qti-gap")],G);import{css as Fo,LitElement as zo}from"lit";import{customElement as Bo,property as Uo}from"lit/decorators.js";var Q=class extends zo{constructor(){super(...arguments);this.tabindex=0}connectedCallback(){this.setAttribute("slot","drags")}};Q.styles=Fo`
855
+ :host {
856
+ display: flex;
857
+ user-select: none;
858
+ }
859
+ `,o([Uo({type:Number,reflect:!0})],Q.prototype,"tabindex",2),Q=o([Bo("qti-gap-img")],Q);import{css as Xo,html as Yo,LitElement as jo}from"lit";import{customElement as Wo,property as Ko}from"lit/decorators.js";var ee=class extends w(jo,"qti-gap-text"){constructor(){super(...arguments);this.tabindex=0}connectedCallback(){super.connectedCallback(),this.setAttribute("slot","drags")}render(){return Yo`<slot></slot>`}};ee.styles=Xo`
860
+ :host {
861
+ display: inline-flex;
862
+ user-select: none;
863
+ }
864
+ `,o([Ko({type:Number,reflect:!0})],ee.prototype,"tabindex",2),ee=o([Wo("qti-gap-text")],ee);import{css as Jo,LitElement as Zo}from"lit";import{customElement as Go,property as Qo}from"lit/decorators.js";var te=class extends w(Zo,"qti-hotspot-choice"){};te.styles=Jo`
865
+ :host {
866
+ display: flex;
867
+ user-select: none;
868
+ position: absolute;
869
+ }
870
+ `,o([Qo({attribute:"aria-ordervalue",type:Number,reflect:!0})],te.prototype,"order",2),te=o([Go("qti-hotspot-choice")],te);import{css as en,html as tn,LitElement as rn}from"lit";import{customElement as sn}from"lit/decorators.js";var Te=class extends w(rn,"qti-hottext"){render(){return tn`<div part="ch"><div part="cha"></div></div>
871
+ <slot></slot> `}};Te.styles=en`
872
+ :host {
873
+ display: flex;
874
+ user-select: none;
875
+ }
876
+ `,Te=o([sn("qti-hottext")],Te);import{css as on,html as nn,LitElement as an}from"lit";import{customElement as ln,property as cn}from"lit/decorators.js";var we=class extends an{static get styles(){return[on`
877
+ :host {
878
+ display: block;
879
+ cursor: pointer;
880
+ }
881
+ `]}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 nn` <slot></slot> `}_onSelectInlineChoice(){this.dispatchEvent(new CustomEvent("qti-inline-choice-select",{bubbles:!0,cancelable:!1,composed:!0,detail:{identifier:this.identifier}}))}};o([cn({type:String})],we.prototype,"identifier",2),we=o([ln("qti-inline-choice")],we);import{css as pn,html as fr,LitElement as dn,nothing as un}from"lit";import{customElement as hn,property as mn}from"lit/decorators.js";var re=class extends w(dn,"qti-simple-choice"){get checked(){return this.internals.states.has("--checked")}render(){return fr`<div part="ch">
882
+ <div part="cha"></div>
883
+ </div>
884
+ ${this.marker?fr`<div id="label">${this.marker}</div>`:un}
885
+ <slot part="slot"></slot> `}};re.styles=pn`
886
+ :host {
887
+ display: flex;
888
+ align-items: center;
889
+ user-select: none;
890
+ }
891
+ slot {
892
+ width: 100%;
893
+ display: flex;
894
+ align-items: center;
895
+ }
896
+ [part='ch'] {
897
+ display: flex;
898
+ flex-shrink: 0;
899
+ align-items: center;
900
+ justify-content: center;
901
+ }
902
+ `,o([mn({type:String,attribute:!1})],re.prototype,"marker",2),re=o([hn("qti-simple-choice")],re);export{_t as a,v as b,x as c,j as d,w as e,ie as f,Re as g,_e as h,M as i,D as j,Le as k,Ae as l,S as m,ne as n,ae as o,le as p,m as q,C as r,R as s,He as t,P as u,W as v,pe as w,de as x,Qe as y,U as z,_ as A,Ie as B,et as C,tt as D,rt as E,ue as F,he as G,it as H,f as I,q as J,Oe as K,ls as L,Pe as M,st as N,ot as O,Fe as P,ze as Q,nt as R,at as S,lt as T,ct as U,pt as V,Be as W,K as X,ut as Y,ht as Z,mt as _,ft as $,gt as aa,bt as ba,me as ca,vt as da,Ue as ea,xs as fa,Xe as ga,yt as ha,xt as ia,Et as ja,X as ka,J as la,V as ma,F as na,fe as oa,N as pa,ge as qa,be as ra,ve as sa,z as ta,H as ua,xe as va,$ as wa,We as xa,Ee as ya,B as za,L as Aa,Ce as Ba,qe as Ca,G as Da,Q as Ea,ee as Fa,te as Ga,Te as Ha,we as Ia,re as Ja};