@citolab/qti-components 7.0.11 → 7.0.12

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 (120) hide show
  1. package/cdn/chunks/chunk-34HKCUN3.js +1 -0
  2. package/cdn/chunks/chunk-4HUJGZW6.js +1 -0
  3. package/cdn/chunks/chunk-7HFMTJAH.js +1 -0
  4. package/cdn/chunks/chunk-ARBRHQDY.js +951 -0
  5. package/cdn/chunks/chunk-BGM3IB5N.js +8 -0
  6. package/cdn/chunks/chunk-CIN2QCYB.js +3537 -0
  7. package/cdn/chunks/chunk-DJM7EUKM.js +1 -0
  8. package/cdn/chunks/chunk-F7RWORNK.js +951 -0
  9. package/cdn/chunks/chunk-HD7EMR2A.js +1 -0
  10. package/cdn/chunks/chunk-HEKMMOBI.js +1 -0
  11. package/cdn/chunks/chunk-I76GONMP.js +951 -0
  12. package/cdn/chunks/chunk-KVCXK3CQ.js +8 -0
  13. package/cdn/chunks/chunk-LICVWYUY.js +3537 -0
  14. package/cdn/chunks/chunk-LWN3NRJE.js +3560 -0
  15. package/cdn/chunks/chunk-MBWNNFLY.js +951 -0
  16. package/cdn/chunks/chunk-MCTQZZG4.js +1 -0
  17. package/cdn/chunks/chunk-NGC3MISE.js +1 -0
  18. package/cdn/chunks/chunk-NP3JIBVS.js +1 -0
  19. package/cdn/chunks/chunk-NTR5PVWP.js +3560 -0
  20. package/cdn/chunks/chunk-P2YEZLMB.js +951 -0
  21. package/cdn/chunks/chunk-QWJABXM7.js +951 -0
  22. package/cdn/chunks/chunk-TCHROQU3.js +1 -0
  23. package/cdn/chunks/chunk-TSTGSXP2.js +951 -0
  24. package/cdn/chunks/chunk-V6G6L6I3.js +3537 -0
  25. package/cdn/exports/computed-item.context.js +1 -0
  26. package/cdn/exports/qti-condition-expression.js +1 -1
  27. package/cdn/exports/qti-expression.js +1 -1
  28. package/cdn/index.global.js +1 -1
  29. package/cdn/index.js +1 -1
  30. package/cdn/qti-components/index.js +1 -1
  31. package/cdn/qti-item/core/index.js +1 -1
  32. package/cdn/qti-test/components/index.js +1 -1
  33. package/cdn/qti-test/components/test-navigation.js +1 -1
  34. package/cdn/qti-test/components/test-next.js +1 -1
  35. package/cdn/qti-test/components/test-paging-buttons-stamp.js +1 -1
  36. package/cdn/qti-test/components/test-prev.js +1 -1
  37. package/cdn/qti-test/components/test-print-item-variables.js +1 -1
  38. package/cdn/qti-test/components/test-section-buttons-stamp.js +1 -1
  39. package/cdn/qti-test/components/test-view.js +1 -1
  40. package/cdn/qti-test/core/index.js +1 -1
  41. package/dist/chunks/chunk-4QYZHR36.js +6541 -0
  42. package/dist/chunks/chunk-4QYZHR36.js.map +1 -0
  43. package/dist/chunks/chunk-5QYVCPUS.js +3775 -0
  44. package/dist/chunks/chunk-5QYVCPUS.js.map +1 -0
  45. package/dist/chunks/chunk-6Z5YR5U2.js +8 -0
  46. package/dist/chunks/chunk-6Z5YR5U2.js.map +1 -0
  47. package/dist/chunks/chunk-7YUCREDM.js +3783 -0
  48. package/dist/chunks/chunk-7YUCREDM.js.map +1 -0
  49. package/dist/chunks/chunk-BIQNE2L4.js +6558 -0
  50. package/dist/chunks/chunk-BIQNE2L4.js.map +1 -0
  51. package/dist/chunks/chunk-CBSVVXVJ.js +6558 -0
  52. package/dist/chunks/chunk-CBSVVXVJ.js.map +1 -0
  53. package/dist/chunks/chunk-D4QP2AIX.js +222 -0
  54. package/dist/chunks/chunk-D4QP2AIX.js.map +1 -0
  55. package/dist/chunks/chunk-DACJEGD7.js +95 -0
  56. package/dist/chunks/chunk-DACJEGD7.js.map +1 -0
  57. package/dist/chunks/chunk-EFTOJP3Z.js +99 -0
  58. package/dist/chunks/chunk-EFTOJP3Z.js.map +1 -0
  59. package/dist/chunks/chunk-FSIQI3KQ.js +6541 -0
  60. package/dist/chunks/chunk-FSIQI3KQ.js.map +1 -0
  61. package/dist/chunks/chunk-KOQLAE5C.js +211 -0
  62. package/dist/chunks/chunk-KOQLAE5C.js.map +1 -0
  63. package/dist/chunks/chunk-KX5XK2I2.js +636 -0
  64. package/dist/chunks/chunk-KX5XK2I2.js.map +1 -0
  65. package/dist/chunks/chunk-LUJE2OUT.js +637 -0
  66. package/dist/chunks/chunk-LUJE2OUT.js.map +1 -0
  67. package/dist/chunks/chunk-M3ODN2LD.js +30 -0
  68. package/dist/chunks/chunk-M3ODN2LD.js.map +1 -0
  69. package/dist/chunks/chunk-O233FYKS.js +45 -0
  70. package/dist/chunks/chunk-O233FYKS.js.map +1 -0
  71. package/dist/chunks/chunk-STT3B34J.js +43 -0
  72. package/dist/chunks/chunk-STT3B34J.js.map +1 -0
  73. package/dist/chunks/chunk-TYV2BDMU.js +8 -0
  74. package/dist/chunks/chunk-TYV2BDMU.js.map +1 -0
  75. package/dist/chunks/chunk-UDUW5VX5.js +6545 -0
  76. package/dist/chunks/chunk-UDUW5VX5.js.map +1 -0
  77. package/dist/chunks/chunk-UIVMRBML.js +230 -0
  78. package/dist/chunks/chunk-UIVMRBML.js.map +1 -0
  79. package/dist/chunks/chunk-VYXSKCOZ.js +3706 -0
  80. package/dist/chunks/chunk-VYXSKCOZ.js.map +1 -0
  81. package/dist/chunks/chunk-X4BXOQJA.js +6558 -0
  82. package/dist/chunks/chunk-X4BXOQJA.js.map +1 -0
  83. package/dist/exports/computed-item.context.d.ts +16 -0
  84. package/dist/exports/computed-item.context.js +8 -0
  85. package/dist/exports/computed-item.context.js.map +1 -0
  86. package/dist/exports/computed.context.d.ts +4 -11
  87. package/dist/exports/computed.context.js +1 -1
  88. package/dist/exports/session.context.d.ts +2 -2
  89. package/dist/index.d.ts +5 -4
  90. package/dist/index.js +21 -16
  91. package/dist/qti-components/index.d.ts +2 -2
  92. package/dist/qti-components/index.js +2 -2
  93. package/dist/qti-components-jsx.d.ts +27 -1
  94. package/dist/qti-item/core/index.d.ts +35 -1
  95. package/dist/qti-item/core/index.js +6 -1
  96. package/dist/qti-loader/index.d.ts +2 -2
  97. package/dist/qti-response-declaration-CBb7rZqd.d.ts +1054 -0
  98. package/dist/qti-response-declaration-CgrlodE6.d.ts +1052 -0
  99. package/dist/qti-response-declaration-DZzGH8xM.d.ts +1057 -0
  100. package/dist/qti-response-declaration-DbMCe0zZ.d.ts +1052 -0
  101. package/dist/qti-test/components/index.d.ts +3 -2
  102. package/dist/qti-test/components/index.js +12 -12
  103. package/dist/qti-test/components/test-navigation.d.ts +4 -3
  104. package/dist/qti-test/components/test-navigation.js +2 -2
  105. package/dist/qti-test/components/test-next.d.ts +1 -0
  106. package/dist/qti-test/components/test-next.js +2 -2
  107. package/dist/qti-test/components/test-paging-buttons-stamp.js +2 -2
  108. package/dist/qti-test/components/test-prev.d.ts +1 -0
  109. package/dist/qti-test/components/test-prev.js +2 -2
  110. package/dist/qti-test/components/test-print-item-variables.d.ts +1 -0
  111. package/dist/qti-test/components/test-print-item-variables.js +2 -2
  112. package/dist/qti-test/components/test-section-buttons-stamp.js +2 -2
  113. package/dist/qti-test/core/index.d.ts +4 -4
  114. package/dist/qti-test/core/index.js +1 -1
  115. package/dist/qti-test-part-B8Dq08t9.d.ts +85 -0
  116. package/dist/qti-test-part-BYdORfcD.d.ts +85 -0
  117. package/dist/qti-test-part-CQycFqJC.d.ts +85 -0
  118. package/dist/qti-test-part-a-IuoG8-.d.ts +85 -0
  119. package/dist/vscode.html-custom-data.json +12 -0
  120. package/package.json +1 -1
@@ -0,0 +1,951 @@
1
+ import{a as je}from"./chunk-EHK76KRT.js";import{a as ce,b as J,c as pe,e as de,f as K,g as Ft,h as zt,i as We,j as Bt}from"./chunk-5BR5CJFH.js";import{a as k}from"./chunk-XUJ7TXHW.js";import{a as $}from"./chunk-M6ENLXRS.js";import{a as C}from"./chunk-NHPUZW62.js";import{a as M}from"./chunk-QQCGUVEV.js";import{a as Pt}from"./chunk-5FCXUJAG.js";import{a as Nt,b as S}from"./chunk-M5PPZ5M3.js";import{a as E}from"./chunk-LQ3DVN7N.js";import{a as m,b as u,c as x,d as Xe,e as Ot}from"./chunk-5GCSZ3CH.js";import{a as b,d as h,e as pt,f as le,g as V,i as v}from"./chunk-LZZB4VGC.js";import{a as It}from"./chunk-KWPDTFYH.js";import{a as n}from"./chunk-IAP2CEE7.js";var L=class extends v{constructor(){super();this.identifier="";this.adaptive="false";this.timeDependent=null;this._handleDisabledChange=(e,t)=>{this._interactionElements.forEach(i=>i.disabled=t)};this._handleReadonlyChange=(e,t)=>this._interactionElements.forEach(i=>i.readonly=t);this._contextInternal={identifier:this.getAttribute("identifier"),variables:It};this._contextProxy=new Proxy(this._contextInternal,{set:(e,t,i)=>(e[t]=i,this._emit("qti-item-context-changed",{itemContext:e}),!0)});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(r=>r.identifier==="numAttempts")?.value)||0)>0&&t.checkShowFeedback(t.outcomeIdentifier)}),this.addEventListener("qti-register-interaction",e=>{e.stopPropagation(),this._interactionElements.push(e.detail.interactionElement)}),this.addEventListener("end-attempt",e=>{let{responseIdentifier:t,countAttempt:i}=e.detail;this.validate(),this.updateResponseVariable(t,"true"),this.processResponse(i)}),this.addEventListener("qti-set-outcome-value",e=>{let{outcomeIdentifier:t,value:i}=e.detail;this.updateOutcomeVariable(t,i),e.stopPropagation()}),this.addEventListener("qti-interaction-response",this.handleUpdateResponseVariable)}get _context(){return this._contextProxy}set _context(e){Object.assign(this._contextProxy,e)}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 i=e.find(r=>r.identifier===t.identifier);return i?{...t,...i}:t})},this._context.variables.forEach(t=>{if(t.type==="response"){let i=this._interactionElements.find(r=>r.responseIdentifier===t.identifier);i&&(i.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 r=this._interactionElements.find(a=>a.getAttribute("response-identifier")===t.responseIdentifier);r&&(r.value=t.response)}}render(){return h`<slot></slot>`}showCorrectResponse(e){for(let t of this._context.variables.filter(i=>i.type==="response")){let i=this._interactionElements.find(r=>r.getAttribute("response-identifier")===t.identifier);i&&i.toggleCorrectResponse(t,e)}}processResponse(e=!0,t=!0){this.validate(t);let i=this.querySelector("qti-response-processing");return!i||!i.process?!1:(i.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:i}=e.detail;this.updateResponseVariable(t,i)}updateResponseVariable(e,t){this._context={...this._context,variables:this._context.variables.map(i=>i.identifier!==e?i:{...i,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 i=this.getOutcome(e);if(!i){console.warn(`Can not set qti-outcome-identifier: ${e}, it is not available`);return}this._context={...this._context,variables:this._context.variables.map(r=>r.identifier!==e?r:{...r,value:i.cardinality==="single"?t:[...r.value,t]})},this._feedbackElements.forEach(r=>r.checkShowFeedback(e)),this._emit("qti-outcome-changed",{item:this.identifier,outcomeIdentifier:e,value:this._context.variables.find(r=>r.identifier===e)?.value})}validate(e=!0){return this._interactionElements.every(t=>t.validate())?!0:this._interactionElements.some(t=>t.validate())?!1:(e&&this.reportValidity(),null)}reportValidity(){for(let e of this._interactionElements)e.reportValidity()}_getCompletionStatus(){let e=this.validate(!1);return e===!0?"completed":e===!1?"incomplete":"not_attempted"}_emit(e,t=null){this.dispatchEvent(new CustomEvent(e,{bubbles:!0,composed:!0,detail:t}))}};n([u({type:String})],L.prototype,"title",2),n([u({type:String})],L.prototype,"identifier",2),n([u({type:String})],L.prototype,"adaptive",2),n([u({type:String})],L.prototype,"timeDependent",2),n([u({type:Boolean})],L.prototype,"disabled",2),n([k("disabled",{waitUntilFirstUpdate:!0})],L.prototype,"_handleDisabledChange",2),n([u({type:Boolean})],L.prototype,"readonly",2),n([k("readonly",{waitUntilFirstUpdate:!0})],L.prototype,"_handleReadonlyChange",2),n([Nt({context:M})],L.prototype,"_contextProxy",2),L=n([m("qti-assessment-item")],L);var ue=class extends v{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 r=this.closest("qti-assessment-item").querySelector(`[data-stimulus-idref=${this.identifier}]`);r?await this.updateStimulusRef(r):console.warn(`Stimulus with data-stimulus-idref ${this.identifier} not found`)}}async updateStimulusRef(e){let t=await Pt().load(this.href).then(i=>i.htmlDoc());if(t){let i=t.querySelectorAll("qti-stimulus-body, qti-stylesheet");e.innerHTML="",e.append(...i)}}};n([u({type:String})],ue.prototype,"identifier",2),n([u({type:String})],ue.prototype,"href",2),ue=n([m("qti-assessment-stimulus-ref")],ue);var Je=class extends v{};Je=n([m("qti-companion-materials-info")],Je);var Ce=class extends v{render(){return h`<slot @slotchange=${this.handleSlotChange}></slot>`}handleSlotChange(){let s=Array.from(this.firstElementChild?.childNodes??[]).find(e=>e.nodeType===Node.COMMENT_NODE);try{this.operatorFunction=new Function("context","fn","item",s?.textContent??"")}catch(e){console.error("custom-operator contains invalid javascript code",e)}}calculate(){let s={variable:t=>this._context?.variables.find(i=>i.identifier===t)?.value??"",correct:t=>this._context?.variables.find(i=>i.identifier===t)?.correctResponse??""},e={getVariable:t=>this._context?.variables.find(i=>i.identifier===t),updateOutcomeVariable:(t,i)=>{this.dispatchEvent(new CustomEvent("qti-set-outcome-value",{bubbles:!0,composed:!0,detail:{outcomeIdentifier:t,value:i}}))},updateResponseVariable:(t,i)=>{this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,composed:!0,detail:{responseIdentifier:t,response:i}}))}};return this.operatorFunction(this._context,s,e)}};n([S({context:M,subscribe:!0}),x()],Ce.prototype,"_context",2),Ce=n([m("qti-custom-operator")],Ce);var hi=()=>new Intl.NumberFormat().format(.1).replace(/\d/g,""),qe=p=>{if(typeof p=="string")return p;let s=hi();return s==="."?p.toLocaleString():p.toString().replace(".","").replace(s,".")};function dt(p){return p==null}function Te(p){return p.replace(/([^:]\/)\/+/g,"$1").replace(/\/\//g,"/").replace("http:/","http://").replace("https:/","https://")}var A=class extends v{connectedCallback(){super.connectedCallback(),this.dispatchEvent(new CustomEvent("qti-register-feedback",{bubbles:!0,composed:!0,detail:this}))}checkShowFeedback(s){let e=this._context.variables.find(i=>i.identifier===s)||null;if(this.outcomeIdentifier!==s||!e)return;let t=!1;Array.isArray(e.value)?t=e.value.includes(this.identifier):t=!dt(this.identifier)&&!dt(e?.value)&&this.identifier===e.value||!1,this.showFeedback(t)}showFeedback(s){this.showStatus=s&&this.showHide==="show"||!s&&this.showHide==="hide"?"on":"off"}};n([u({type:String,attribute:"show-hide"})],A.prototype,"showHide",2),n([u({type:String,attribute:"outcome-identifier"})],A.prototype,"outcomeIdentifier",2),n([u({type:String})],A.prototype,"identifier",2),n([u({type:String,attribute:!1})],A.prototype,"showStatus",2),n([S({context:M,subscribe:!0}),x()],A.prototype,"_context",2);var we=class extends A{render(){return h` <slot part="feedback" class="feedback ${this.showStatus}"></slot> `}firstUpdated(s){this.checkShowFeedback(this.outcomeIdentifier)}};we.styles=b`
2
+ :host {
3
+ display: block;
4
+ }
5
+ .on {
6
+ display: block;
7
+ }
8
+ .off {
9
+ display: none;
10
+ }
11
+ `,we=n([m("qti-feedback-block")],we);var Me=class extends A{constructor(){super(...arguments);this.render=()=>h` <slot part="feedback" class="${this.showStatus}"></slot> `}};Me.styles=b`
12
+ .on {
13
+ display: inline-block;
14
+ }
15
+ .off {
16
+ display: none;
17
+ }
18
+ `,Me=n([m("qti-feedback-inline")],Me);var _e=class extends A{render(){return h`
19
+ <dialog class="qti-dialog" part="feedback" ?open="${this.showStatus==="on"}">
20
+ <slot></slot>
21
+ <div style="margin-top: var(--qti-gap-size); text-align: center;">
22
+ <button class="button close-button" @click="${this.closeFeedback}"></button>
23
+ </div>
24
+ </dialog>
25
+ `}openFeedback(){let s=this.shadowRoot?.querySelector("dialog");s&&!s.open&&s.showModal()}closeFeedback(){let s=this.shadowRoot?.querySelector("dialog");s&&s.open&&(s.close(),this.showStatus="off")}firstUpdated(){this.showStatus==="on"&&this.openFeedback()}updated(s){s.has("showStatus")&&(this.showStatus==="on"?this.openFeedback():this.closeFeedback())}};_e.styles=b`
26
+ .qti-dialog {
27
+ background: var(--qti-bg);
28
+ border: var(--qti-border-thickness) var(--qti-border-style) var(--qti-border-color);
29
+ border-radius: var(--qti-border-radius);
30
+ padding: var(--qti-padding-vertical) var(--qti-padding-horizontal);
31
+ box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
32
+ position: fixed;
33
+ top: 50%;
34
+ left: 50%;
35
+ transform: translate(-50%, -50%);
36
+ z-index: 1000;
37
+ width: auto;
38
+ max-width: 90%;
39
+ }
40
+
41
+ .button {
42
+ border-radius: var(--qti-border-radius);
43
+ padding: var(--qti-padding-vertical) var(--qti-padding-horizontal);
44
+ background-color: var(--qti-bg-active);
45
+ border: var(--qti-border-active);
46
+ cursor: pointer;
47
+ position: relative;
48
+ display: inline-block;
49
+ }
50
+
51
+ .button:hover {
52
+ background-color: var(--qti-hover-bg);
53
+ }
54
+
55
+ .button:disabled {
56
+ background-color: var(--qti-disabled-bg);
57
+ color: var(--qti-disabled-color);
58
+ cursor: not-allowed;
59
+ }
60
+
61
+ .button:focus {
62
+ outline: var(--qti-focus-border-width) solid var(--qti-focus-color);
63
+ }
64
+
65
+ /* Text content of the button */
66
+ .button::after {
67
+ content: var(--qti-close-text, 'Close');
68
+ color: inherit;
69
+ font-size: inherit;
70
+ text-align: center;
71
+ display: inline-block;
72
+ line-height: 1.5;
73
+ }
74
+ `,_e=n([m("qti-modal-feedback")],_e);var Se=class extends v{connectedCallback(){super.connectedCallback(),this.dispatchEvent(new CustomEvent("qti-register-hotspot",{bubbles:!0,composed:!0,cancelable:!1}))}render(){return h` <slot name="drags"></slot> `}};Se.styles=b`
75
+ :host {
76
+ display: flex;
77
+ user-select: none;
78
+ position: absolute;
79
+ }
80
+ `,Se=n([m("qti-associable-hotspot")],Se);var Yt=(p,s,e)=>{class t extends p{}return t};var H=(p,s,e,t)=>{class i extends Yt(p,e,s){constructor(){super(...arguments);this.observer=null;this.droppableObsever=null;this.resizeObserver=null;this.draggables=[];this.droppables=[];this.dragContainers=[];this.dragClone=null;this.dragSource=null;this.touchStartPoint=null;this.isDraggable=!1;this.cloneOffset={x:0,y:0};this.isDragging=!1;this.allDropzones=[];this.lastTarget=null;this.currentDropTarget=null;this.MIN_DRAG_DISTANCE=5;this.DRAG_CLONE_OPACITY=1;this.dataTransfer={data:{},setData(o,l){this.data[o]=l},getData(o){return this.data[o]},effectAllowed:"move"};this.configuration={copyStylesDragClone:!0,dragCanBePlacedBack:!0,dragOnClick:!1};this.minAssociations=1;this.maxAssociations=1;this.draggablesModified=(o,l)=>{for(let d of l)this.draggables.includes(d)&&(this.draggables=this.draggables.filter(f=>f!==d),d.removeAttribute("tabindex"),d.removeEventListener("touchstart",this.handleTouchStart.bind(this)),d.removeEventListener("mousedown",this.handleTouchStart.bind(this)));for(let d of o)this.draggables.includes(d)||(this.draggables.push(d),d.setAttribute("tabindex","0"),d.hasTouchStartListener||(d.addEventListener("touchstart",this.handleTouchStart.bind(this),{passive:!1}),d.addEventListener("mousedown",this.handleTouchStart.bind(this),{passive:!1}),d.hasTouchStartListener=!0));let c=0;this.draggables.forEach(d=>{d.style.viewTransitionName=`drag-${c}-${this.getAttribute("identifier")||crypto.randomUUID()}`,d.setAttribute("qti-draggable","true"),c++})};this.droppablesModified=(o,l)=>{for(let c of l)this.droppables.includes(c)&&(this.droppables=this.droppables.filter(d=>d!==c),this.allDropzones=this.allDropzones.filter(d=>d!==c));for(let c of o)this.droppables.includes(c)||(this.droppables.push(c),this.allDropzones.push(c));for(let c of this.droppables)this.dataset.choicesContainerWidth&&(c.style.width=`${this.dataset.choicesContainerWidth}px`,c.style.boxSizing="border-box")}}handleDraggableContainerChange(o,l){this.isMatchTabular()||(o.length>0||l.length>0)&&this.dragContainersModified(o||[],l||[])}dragContainersModified(o,l){for(let c of l)this.dragContainers.includes(c)&&(this.dragContainers=this.dragContainers.filter(d=>d!==c),this.allDropzones=this.allDropzones.filter(d=>d!==c));for(let c of o)this.dragContainers.includes(c)||(this.dragContainers.push(c),this.allDropzones.push(c))}handleDraggablesChange(o,l){this.isMatchTabular()||(o.length>0||l.length>0)&&this.draggablesModified(o||[],l||[])}handleDroppablesChange(o,l){this.isMatchTabular()||(o.length>0||l.length>0)&&this.droppablesModified(o||[],l||[])}firstUpdated(o){super.firstUpdated(o),this.hasAttribute("disabled")||(document.addEventListener("touchmove",this.handleTouchMove.bind(this),{passive:!1}),document.addEventListener("mousemove",this.handleTouchMove.bind(this),{passive:!1}),document.addEventListener("touchend",this.handleTouchEnd.bind(this),{passive:!1}),document.addEventListener("mouseup",this.handleTouchEnd.bind(this),{passive:!1}),document.addEventListener("touchcancel",this.handleTouchCancel.bind(this),{passive:!1}));let c=Array.from(this.querySelectorAll(s)||[]).concat(Array.from(this.shadowRoot?.querySelectorAll(s)||[])),d=Array.from(this.querySelectorAll(e)||[]).concat(Array.from(this.shadowRoot?.querySelectorAll(e)||[])),f=Array.from(this.querySelectorAll(t)||[]).concat(Array.from(this.shadowRoot?.querySelectorAll(t)||[]));this.dragContainersModified(f,[]),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(y=>this.resizeObserver?.observe(y))}async moveDraggableToDroppable(o,l){(()=>{o.style.transform="translate(0, 0)",l.tagName==="SLOT"?o.setAttribute("slot",l.getAttribute("name")):l.appendChild(o),this.checkAllMaxAssociations(),this.saveResponse()})()}activateDroppable(o){this.dragContainers.includes(o)?(this._internals.states.add("--dragzone-active"),o.setAttribute("active","")):(this._internals.states.delete("--dragzone-active"),o.setAttribute("active",""))}deactivateDroppable(o,l=!0){l&&this._internals.states.add("--dragzone-active"),o.removeAttribute("active")}connectedCallback(){super.connectedCallback()}isMatchTabular(){return this.classList.contains("qti-match-tabular")}updateMinDimensionsForDropZones(){let o=this.querySelectorAll(s),l=Array.from(this.querySelectorAll(e)).map(g=>g),c=0,d=0;o.forEach(g=>{let y=g.getBoundingClientRect();c=Math.max(c,y.height),d=Math.max(d,y.width)});let f=this.querySelector(t)||this.shadowRoot?.querySelector(t);f&&(f.style.minHeight=`${c}px`,f.style.minWidth=`${d}px`);for(let g of l)g.style.minHeight=`${c}px`,g.style.minWidth=`${d}px`}activateDroppables(o){this.dragContainers.forEach(c=>{c.setAttribute("enabled",""),c.hasAttribute("disabled")&&(c.contains(o)||c.shadowRoot&&c.shadowRoot.contains(o))&&c.removeAttribute("disabled")}),this.droppables.forEach(c=>{c.setAttribute("enabled",""),c.hasAttribute("disabled")&&(c.contains(o)||c.shadowRoot&&c.shadowRoot.contains(o))&&c.removeAttribute("disabled")})}activateDragLocation(){this._internals.states.add("--dragzone-enabled")}deactivateDragLocation(){this._internals.states.delete("--dragzone-enabled")}deactivateDroppables(){this.dragContainers.forEach(l=>{l.removeAttribute("enabled"),l.removeAttribute("active")}),this.droppables.forEach(l=>{l.removeAttribute("enabled"),l.removeAttribute("active")})}disconnectedCallback(){super.disconnectedCallback(),this.observer&&(this.observer.disconnect(),this.observer=null),this.droppableObsever&&(this.droppableObsever.disconnect(),this.droppableObsever=null),this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),document.removeEventListener("touchmove",this.handleTouchMove),document.removeEventListener("mousemove",this.handleTouchMove),document.removeEventListener("touchend",this.handleTouchEnd),document.removeEventListener("mouseup",this.handleTouchEnd),document.removeEventListener("touchcancel",this.handleTouchCancel)}handleTouchMove(o){if(this.isDraggable&&this.dragClone){let{x:l,y:c}=this.getEventCoordinates(o),d={clientX:l,clientY:c};this.calculateDragDistance(d)>=this.MIN_DRAG_DISTANCE&&(this.isDragging=!0,this.updateDragClonePosition(d));let f=this.findClosestDropzone();this.currentDropTarget=f,f!==this.lastTarget&&(this.lastTarget&&(this.deactivateDroppable(this.lastTarget),this.dispatchCustomEvent(this.lastTarget,"dragleave")),f&&(this.activateDroppable(f),this.dispatchCustomEvent(f,"dragenter")),this.lastTarget=f),this.currentDropTarget&&this.dispatchCustomEvent(this.currentDropTarget,"dragover"),o.preventDefault()}}handleTouchEnd(o){this.isDragging&&this.resetDragState(),this._internals.states.delete("--dragzone-active"),this.checkAllMaxAssociations(),this._internals.states.delete("--dragzone-enabled"),this._internals.states.delete("--dragzone-active"),this.deactivateDragLocation(),this.deactivateDroppables(),this.draggables.forEach(l=>{l.removeAttribute("dragging")}),o.preventDefault()}handleTouchCancel(o){this.resetDragState()}validate(){if(!this.shadowRoot)return!1;let o=this.getValidAssociations(),l=!0,c="";this.maxAssociations>0&&o>this.maxAssociations?(l=!1,c=this.dataset.maxSelectionsMessage||`You've selected too many associations. Maximum allowed is ${this.maxAssociations}.`):this.minAssociations>0&&o<this.minAssociations&&(l=!1,c=this.dataset.minSelectionsMessage||`You haven't selected enough associations. Minimum required is ${this.minAssociations}.`);let d=this.lastElementChild;return this._internals.setValidity(l?{}:{customError:!0},c,d),l}reportValidity(){let o=this.shadowRoot.querySelector("#validationMessage");return o&&(this._internals.validity.valid?(o.textContent="",o.style.display="none"):(o.textContent=this._internals.validationMessage,o.style.display="block")),this._internals.validity.valid}checkMaxAssociations(o){let l=this.getMatchMaxValue(o),c=o.querySelectorAll('[qti-draggable="true"]').length;return!(l===0)&&c>=l}dropDraggableInDroppable(o,l){let c=o.cloneNode(!0);c.removeAttribute("style"),this.moveDraggableToDroppable(c,l),this.draggablesModified([c],[]);let d=this.getMatchMaxValue(o),f=this.draggables.filter(g=>g.getAttribute("identifier")===o.getAttribute("identifier"));d!==0&&f.length>=d?(o.style.opacity="0.0",o.style.pointerEvents="none"):o.style.opacity="1.0"}resetDragState(){if(this.dragClone){let o=this.currentDropTarget!==null,l=!o||this.dragContainers.includes(this.currentDropTarget);o&&this.currentDropTarget&&!l&&this.dropDraggableInDroppable(this.dragSource,this.currentDropTarget),l&&(this.dragSource.style.opacity="1.0",this.dragSource.style.display="block",this.dragSource.style.position="static",this.dragSource.style.pointerEvents="auto",this.saveResponse()),this.dragClone.remove(),this.draggablesModified([],[this.dragClone])}this.isDragging=!1,this.isDraggable=!1,this.dragSource=null,this.dragClone=null,this.touchStartPoint=null,this.currentDropTarget=null,this.lastTarget=null,this.deactivateDroppables()}checkAllMaxAssociations(){let o=this.getValidAssociations(),l=this.maxAssociations!==0&&o>=this.maxAssociations;this.droppables.forEach(c=>{l?this.disableDroppable(c):this.checkMaxAssociations(c)?this.disableDroppable(c):this.enableDroppable(c)})}getMatchMaxValue(o){let l=o.getAttribute("match-max");return l?parseInt(l,10):1}disableDroppable(o){o.setAttribute("disabled","")}enableDroppable(o){o.removeAttribute("disabled")}get value(){return this.collectResponseData()}set value(o){if(!this.isMatchTabular())if(Array.isArray(o)){this.reset(),o?.forEach(c=>this.placeResponse(c));let l=new FormData;o.forEach(c=>{l.append(this.responseIdentifier,c)}),this._internals.setFormValue(l)}else this._internals.setFormValue(o||"")}placeResponse(o){let[l,...c]=o.split(" ").reverse(),d=Array.from(this.draggables),f=Array.from(this.droppables);c.forEach(g=>{let y=d.find(w=>w.getAttribute("identifier")===g),q=f.find(w=>w.getAttribute("identifier")===l);this.dropDraggableInDroppable(y,q)})}getValidAssociations(){let o=0;for(let l of this.droppables)o=o+this.getDraggablesFromDroppable(l).length;return o}saveResponse(){let o=this.collectResponseData();this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,composed:!0,detail:{responseIdentifier:this.responseIdentifier,response:o}}))}collectResponseData(){return this.droppables.map(l=>{let d=this.getDraggablesFromDroppable(l).map(g=>g.getAttribute("identifier")),f=l.getAttribute("identifier");return d.map(g=>`${g} ${f}`)}).flat()}getDraggablesFromDroppable(o){return this.draggables.map(d=>d.getAttribute("identifier")).filter((d,f,g)=>g.indexOf(d)===f).flatMap(d=>Array.from(o.querySelectorAll(`[identifier='${d}']`))).filter(d=>!!d).map(d=>d)}reset(o=!1){this.droppables.forEach(l=>{this.getDraggablesFromDroppable(l).forEach(d=>{d.remove(),this.draggablesModified([],[d])})}),this.dragContainers.forEach(l=>{Array.from(l.querySelectorAll('[qti-draggable="true"]')).forEach(d=>{d.style.opacity="1.0"})}),this.dragClone=null,this.dragSource=null,this.isDragging=!1,this.isDraggable=!1,this.currentDropTarget=null,this.lastTarget=null,o&&this.saveResponse()}updateDragClonePosition(o){if(!this.isDragging||!this.dragClone)return;let l=o.clientX-this.cloneOffset.x,c=o.clientY-this.cloneOffset.y,{newLeft:d,newTop:f}=this.applyInteractionBoundaries(l,c,this.dragClone);this.dragClone.style.left=`${d}px`,this.dragClone.style.top=`${f}px`}applyInteractionBoundaries(o,l,c){let d=this.getBoundingClientRect(),f=c.getBoundingClientRect(),g=f.width,y=f.height,q=Math.max(d.left,Math.min(o,d.right-g)),w=Math.max(d.top,Math.min(l,d.bottom-y));return{newLeft:q,newTop:w}}getEventCoordinates(o,l=!1){let c=o.touches?o.touches[0]:o;return{x:l?c.pageX:c.clientX,y:l?c.pageY:c.clientY}}calculateDragDistance(o){let l=Math.abs(o.clientX-this.touchStartPoint.x),c=Math.abs(o.clientY-this.touchStartPoint.y);return l+c}findClosestDropzone(){let o=this.allDropzones.filter(f=>!f.hasAttribute("disabled"));if(!this.dragClone||o.length===0)return null;let l=this.dragClone.getBoundingClientRect(),c=null,d=0;for(let f of o){let g=f.getBoundingClientRect(),y=this.calculateOverlapArea(l,g);y>d&&(d=y,c=f)}if(!c){let f=200;for(let g of o){let y=g.getBoundingClientRect(),q=Math.sqrt(Math.pow(l.left-y.left,2)+Math.pow(l.top-y.top,2));q<f&&(f=q,c=g)}}return c}calculateOverlapArea(o,l){let c=Math.max(0,Math.min(o.right,l.right)-Math.max(o.left,l.left)),d=Math.max(0,Math.min(o.bottom,l.bottom)-Math.max(o.top,l.top));return c*d}dispatchCustomEvent(o,l,c=!0){if(!o)return;let d=new CustomEvent(l,{bubbles:c,cancelable:!0});d.dataTransfer=this.dataTransfer,o.dispatchEvent(d)}appendClone(){document.body.appendChild(this.dragClone)}handleTouchStart(o){if(this.isDragging)return;let{x:l,y:c}=this.getEventCoordinates(o);this.touchStartPoint={x:l,y:c},this.dragSource=o.currentTarget,this.isDraggable=!0,this._internals.states.add("--dragzone-enabled"),this._internals.states.add("--dragzone-active"),this.activateDragLocation(),this.activateDroppables(this.dragSource);let d=this.findDraggableInDraggableContainer(this.dragSource.getAttribute("identifier")),f=this.droppables.some(T=>Array.from(T.children).some(ae=>ae===this.dragSource)),g=this.dragSource.getBoundingClientRect();f&&(this.dragSource.remove(),this.draggablesModified([],[this.dragSource]),this.dragSource=d),this.cloneOffset.x=l-g.left,this.cloneOffset.y=c-g.top,this.dragClone=d.cloneNode(!0);let y=window.getComputedStyle(d);for(let T=0;T<y.length;T++){let ae=y[T];this.dragClone.style.setProperty(ae,y.getPropertyValue(ae))}let q=d.getBoundingClientRect();this.dragClone.style.width=`${q.width}px`,this.dragClone.style.height=`${q.height}px`,g&&this.setDragCloneStyles(g),this.dragClone.style.display="block",this.dragClone.style.opacity="1",this.appendClone();let w=this.getMatchMaxValue(this.dragSource),R=this.draggables.filter(T=>T.getAttribute("identifier")===this.dragSource.getAttribute("identifier"));w!==0&&R.length>=w?(d.style.opacity="0.0",d.style.pointerEvents="none"):d.style.opacity="1.0",o.preventDefault(),this.dragClone.setAttribute("dragging","")}findDraggableInDraggableContainer(o){let l=this.dragContainers.flat();for(let c of l){if(c.getAttribute("identifier")===o)return c;let d;c instanceof HTMLSlotElement?d=Array.from(c?.assignedElements()||[]):d=Array.from(c.querySelectorAll(s));let f=d.find(g=>g.getAttribute("identifier")===o);if(f)return f}}setDragCloneStyles(o){this.dragClone.style.position="fixed",this.dragClone.style.top=`${o.top}px`,this.dragClone.style.left=`${o.left}px`,this.dragClone.style.setProperty("box-sizing","border-box","important"),this.dragClone.style.zIndex="9999",this.dragClone.style.pointerEvents="none",this.dragClone.style.opacity=this.DRAG_CLONE_OPACITY.toString(),this.dragClone.style.display="block"}}return n([u({attribute:!1,type:Object})],i.prototype,"configuration",2),n([u({type:Number,reflect:!0,attribute:"min-associations"})],i.prototype,"minAssociations",2),n([u({type:Number,reflect:!0,attribute:"max-associations"})],i.prototype,"maxAssociations",2),n([je(t)],i.prototype,"handleDraggableContainerChange",1),n([je(s)],i.prototype,"handleDraggablesChange",1),n([je(e)],i.prototype,"handleDroppablesChange",1),i};var Ut=b`
81
+ :host {
82
+ display: block; /* necessary to calculate scaling position */
83
+ }
84
+ slot[name='qti-simple-associable-choice'] {
85
+ display: flex;
86
+ align-items: flex-start;
87
+ flex: 1;
88
+ border: 2px solid transparent;
89
+ padding: 0.3rem;
90
+ border-radius: 0.3rem;
91
+ gap: 0.5rem;
92
+ }
93
+
94
+ :host::part(associables-container) {
95
+ display: flex;
96
+ padding: 0.5rem;
97
+ justify-content: space-between;
98
+ background: linear-gradient(
99
+ 180deg,
100
+ rgb(0 0 0 / 0%) calc(50% - 1px),
101
+ var(--qti-border-color-gray) calc(50%),
102
+ rgb(0 0 0 / 0%) calc(50% + 1px)
103
+ );
104
+ }
105
+ `;var he=class extends H(E,"qti-simple-associable-choice",".dl","slot[name='qti-simple-associable-choice']"){constructor(){super();this._childrenMap=[];this._registerChoiceHandler=this._registerChoice.bind(this),this.addEventListener("register-qti-simple-associable-choice",this._registerChoiceHandler)}_registerChoice(e){let t=e.target;this._childrenMap.push(t)}render(){return h` <slot name="prompt"></slot>
106
+ <slot name="qti-simple-associable-choice"></slot>
107
+ <div part="drop-container">
108
+ ${this._childrenMap.length>0&&Array.from(Array(Math.ceil(this._childrenMap.length/2)).keys()).map((e,t)=>h`<div part="associables-container">
109
+ <div name="left${t}" part="drop-list" class="dl" identifier="droplist${t}_left"></div>
110
+ <div name="right${t}" part="drop-list" class="dl" identifier="droplist${t}_right"></div>
111
+ </div>`)}
112
+
113
+ <div role="alert" id="validationMessage"></div>
114
+ </div>`}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("register-qti-simple-associable-choice",this._registerChoiceHandler)}};he.styles=Ut,n([x()],he.prototype,"_childrenMap",2),he=n([m("qti-associate-interaction")],he);var Z=(p,s)=>{class e extends p{constructor(){super(...arguments);this._choiceElements=[];this.minChoices=0;this.maxChoices=1;this._handleDisabledChange=(r,a)=>{this._choiceElements.forEach(o=>o.disabled=a)};this._handleReadonlyChange=(r,a)=>{this._choiceElements.forEach(o=>o.readonly=a)};this._value=""}_handleMaxChoicesChange(r,a){this._determineInputType()}get value(){return Array.isArray(this._value)&&this._value.length===0||this._value===""?null:Array.isArray(this._value)?this._value.join(","):this._value}set value(r){if(this.maxChoices>1&&(typeof r=="string"||r===null)?this._value=r?r.toString().split(","):[]:this._value=r||"",Array.isArray(this._value)){let a=new FormData;this._value.forEach(o=>{a.append(this.responseIdentifier,o)}),this._internals.setFormValue(a)}else this._internals.setFormValue(this._value);this._updateChoiceSelection()}set correctResponse(r){this._correctResponse=r;let a=Array.isArray(r)?r:[r];this._choiceElements.forEach(o=>{o.internals.states.delete("correct-response"),o.internals.states.delete("incorrect-response"),a.length>0&&(a.includes(o.identifier)?o.internals.states.add("correct-response"):o.internals.states.add("incorrect-response"))})}connectedCallback(){super.connectedCallback(),this.addEventListener(`register-${s}`,this._registerChoiceElement),this.addEventListener(`unregister-${s}`,this._unregisterChoiceElement),this.addEventListener(`activate-${s}`,this._choiceElementSelectedHandler)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(`register-${s}`,this._registerChoiceElement),this.removeEventListener(`unregister-${s}`,this._unregisterChoiceElement),this.removeEventListener(`activate-${s}`,this._choiceElementSelectedHandler)}validate(){let r=this._choiceElements.filter(c=>this._getChoiceChecked(c)),a=r.length,o=!0,l="";return this.maxChoices!==0&&a>this.maxChoices?(o=!1,l=this.dataset.maxSelectionsMessage||`Please select no more than ${this.maxChoices} ${this.maxChoices===1?"option":"options"}.`):a<this.minChoices&&(o=!1,l=`Please select at least ${this.minChoices} ${this.minChoices===1?"option":"options"}.`),r.length>0&&this._internals.setValidity(o?{}:{customError:!0},l,r[a-1]||this._choiceElements[0]||this),o}reportValidity(){return this._validationMessageElement&&(this._internals.validity.valid?(this._validationMessageElement.textContent="",this._validationMessageElement.style.display="none"):(this._validationMessageElement.textContent=this._internals.validationMessage,this._validationMessageElement.style.display="block")),this._internals.validity.valid}_registerChoiceElement(r){r.stopPropagation();let a=r.target;a.disabled=this.disabled,this._choiceElements.push(a),this._setInputType(a)}_unregisterChoiceElement(r){r.stopPropagation();let a=r.target;this._choiceElements=this._choiceElements.filter(o=>o!==a)}_determineInputType(){this._choiceElements.forEach(r=>{this._setInputType(r)})}_setInputType(r){this._internals.ariaLabel=this.maxChoices===1?"radio-group":"checkbox-group";let a=this.maxChoices===1?"radio":"checkbox";r.internals.role=a,r.internals.states.delete(a==="radio"?"checkbox":"radio"),r.internals.states.add(a)}_choiceElementSelectedHandler(r){this._toggleChoiceChecked(r.target),this.maxChoices===1&&this._choiceElements.forEach(a=>{a.identifier!==r.detail.identifier&&this._setChoiceChecked(a,!1)}),this._handleChoiceSelection()}_setChoiceChecked(r,a){r.internals?.states&&(a?(r.internals.states.add("--checked"),r.internals.ariaChecked="true"):(r.internals.states.delete("--checked"),r.internals.ariaChecked="false"))}_getChoiceChecked(r){return r.internals.states.has("--checked")}_toggleChoiceChecked(r){let a=this._getChoiceChecked(r);this._setChoiceChecked(r,!a)}_handleChoiceSelection(){let a=this._choiceElements.filter(o=>this._getChoiceChecked(o)).map(o=>o.identifier);this.value=this.maxChoices===1?a[0]||"":a,this.validate(),this.saveResponse(this._value)}_updateChoiceSelection(){let r=Array.isArray(this._value)?this._value:[this._value];this._choiceElements.forEach(a=>{let o=r.includes(a.identifier);this._setChoiceChecked(a,o)})}}return n([Xe("#validationMessage")],e.prototype,"_validationMessageElement",2),n([u({type:Number,attribute:"min-choices"})],e.prototype,"minChoices",2),n([u({type:Number,attribute:"max-choices"})],e.prototype,"maxChoices",2),n([k("maxChoices",{waitUntilFirstUpdate:!0})],e.prototype,"_handleMaxChoicesChange",1),n([k("disabled",{waitUntilFirstUpdate:!0})],e.prototype,"_handleDisabledChange",2),n([k("readonly",{waitUntilFirstUpdate:!0})],e.prototype,"_handleReadonlyChange",2),e};var Ke=(p,s)=>{class e extends p{constructor(){super(...arguments);this.shuffle="false"}connectedCallback(){super.connectedCallback(),this._applyShuffle()}updated(r){r.has("shuffle")&&this._applyShuffle()}_applyShuffle(){this.shuffle==="true"?this._shuffleChoices():this._resetShuffleChoices()}_shuffleChoices(){let r=Array.from(this.querySelectorAll(s)),a=r.filter(g=>g.hasAttribute("fixed")),o=r.filter(g=>!g.hasAttribute("fixed"));if(o.length<=1){console.warn("Shuffling is not possible with fewer than 2 non-fixed elements.");return}let l=[...o],c=!1,d=0;for(;!c&&d<10;){d++;for(let g=o.length-1;g>0;g--){let y=Math.floor(Math.random()*(g+1));[o[g],o[y]]=[o[y],o[g]]}c=!o.every((g,y)=>g===l[y])}c||console.warn("Failed to shuffle the choices after multiple attempts.");let f=1;[...a,...o].forEach(g=>{g.style.setProperty("order",String(f++))})}_resetShuffleChoices(){this.querySelectorAll(s).forEach(r=>{r.style.setProperty("order","initial")})}}return n([u({type:String,reflect:!0})],e.prototype,"shuffle",2),e};var Xt=(p,s)=>{class e extends p{constructor(){super(...arguments);this._classes=[];this._allLabels=["qti-labels-decimal","qti-labels-lower-alpha","qti-labels-upper-alpha"];this._allLabelSuffixes=["qti-labels-suffix-period","qti-labels-suffix-parenthesis"]}set class(r){r&&(this._classes=r.split(" "),this._addLabels())}get class(){return this._classes?.join(" ")||""}updated(r){super.updated(r),r.has("shuffle")&&this._addLabels()}_addLabels(){let r=this._classes.some(o=>this._allLabels.includes(o)||this._allLabelSuffixes.includes(o)),a=o=>!isNaN(+o);if(r){let l=Array.from(this.querySelectorAll("qti-simple-choice")).map(c=>c).map((c,d)=>({el:c,order:a(c.style.order)?+c.style.order:d+1})).sort((c,d)=>c.order-d.order).map(c=>c.el);for(let c=0;c<l.length;c++)l[c].marker=this._getLabel(c+1)}}_getLabel(r){let a=this._classes.filter(c=>this._allLabels.includes(c)).pop(),o=this._classes.filter(c=>this._allLabelSuffixes.includes(c)).pop();!a&&o&&(a="qti-labels-upper-alpha");let l="";switch(a){case"qti-labels-decimal":l=`${r}`;break;case"qti-labels-lower-alpha":l=`${String.fromCharCode(97+r-1)}`;break;case"qti-labels-upper-alpha":l=`${String.fromCharCode(65+r-1)}`;break}return o==="qti-labels-suffix-period"?l+=".":o==="qti-labels-suffix-parenthesis"&&(l+=")"),l}}return n([u({type:String,reflect:!0})],e.prototype,"class",1),e};var jt=b`
115
+ [part='slot'] {
116
+ display: flex;
117
+ flex-direction: column;
118
+ gap: var(--qti-gap-size);
119
+ flex-wrap: wrap;
120
+ }
121
+
122
+ ::slotted(qti-simple-choice) {
123
+ flex: 0 0
124
+ calc((100% - (var(--qti-gap-size) * var(--choice-interactions-stacking))) / var(--choice-interactions-stacking)) !important;
125
+ box-sizing: border-box !important;
126
+ }
127
+
128
+ :host(.qti-choices-stacking-1) [part='slot'] {
129
+ flex-direction: row;
130
+ --choice-interactions-stacking: 1;
131
+ }
132
+
133
+ :host(.qti-choices-stacking-2) [part='slot'] {
134
+ flex-direction: row;
135
+ --choice-interactions-stacking: 2;
136
+ }
137
+ :host(.qti-choices-stacking-3) [part='slot'] {
138
+ flex-direction: row;
139
+ --choice-interactions-stacking: 3;
140
+ }
141
+ :host(.qti-choices-stacking-4) [part='slot'] {
142
+ flex-direction: row;
143
+ --choice-interactions-stacking: 4;
144
+ }
145
+ :host(.qti-choices-stacking-5) [part='slot'] {
146
+ flex-direction: row;
147
+ --choice-interactions-stacking: 5;
148
+ }
149
+ :host([orientation='horizontal']) [part='slot'] {
150
+ flex-direction: row;
151
+ }
152
+ `;var me=class extends Xt(Ke(Z(E,"qti-simple-choice"),"qti-simple-choice"),"qti-simple-choice"){constructor(){super(),this._internals.role="group"}render(){return h`
153
+ <slot part="prompt" name="prompt"></slot><slot part="slot"></slot>
154
+ <div part="message" role="alert" id="validationMessage"></div>
155
+ `}};me.styles=jt,n([u({type:String})],me.prototype,"orientation",2),me=n([m("qti-choice-interaction")],me);var B=class extends E{constructor(){super();this._errorMessage=null;this.handlePostMessage=this.handlePostMessage.bind(this)}connectedCallback(){super.connectedCallback();let e=this.data.startsWith("http")?this.data:Te(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(`
156
+ <html>
157
+ <head>
158
+ <link href='${Te(`${this.baseRefUrl}/${this.manifest.style[0]}`)}' rel="stylesheet" />
159
+ <script src='${Te(`${this.baseRefUrl}/${this.manifest.script[0]}`)}'></script>
160
+ </head>
161
+ <body></body>
162
+ </html>
163
+ `),t.close()}getIFrames(){let e=this.shadowRoot.querySelectorAll("iframe"),t=this.querySelectorAll("iframe"),i=[...e,...t];for(let r of i){let a=r.src;if(new URL(a,window.location.href).origin===window.location.origin)try{let l=r.contentDocument||r.contentWindow.document;l&&this.getInnerIFrames(l,i)}catch(l){console.error("Error accessing nested iframe:",l)}}return i.forEach((r,a)=>{i.indexOf(r)!==a&&i.splice(a,1)}),i}getInnerIFrames(e,t=[]){return e.querySelectorAll("iframe").forEach(r=>{t.push(r);let a=r.src;if(new URL(a,window.location.href).origin===window.location.origin)try{let l=r.contentDocument||r.contentWindow.document;this.getInnerIFrames(l,t)}catch(l){console.error("Error accessing nested iframe:",l)}else console.warn("Skipped cross-origin iframe:",a)}),t}postToWindowAndIframes(e,t){window.postMessage({type:e,data:t},"*");let i=this.getIFrames();for(let r of i)r.contentWindow&&r.contentWindow.postMessage({type:e,data:t},"*")}handlePostMessage(e){let{type:t,data:i}=e.data;switch(t){case"setResponse":this.rawResponse=i,this.saveResponse(i);break;case"getResponse":{this.postToWindowAndIframes("responseData",this.rawResponse);break}case"getMedia":{let r=this.manifest.media.map(a=>a.startsWith("http")?a:Te(this.baseRefUrl+"/"+a));this.postToWindowAndIframes("mediaData",r);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 h`<iframe
164
+ width=${this.getAttribute("width")}
165
+ height=${this.getAttribute("height")}
166
+ frameborder="0"
167
+ title="pciContainer"
168
+ id="pciContainer"
169
+ >
170
+ </iframe>
171
+ ${this._errorMessage&&h`<div style="color:red">
172
+ <h1>Error</h1>
173
+ ${this._errorMessage}
174
+ </div>`}`}};n([u({type:String,attribute:"data"})],B.prototype,"data",2),n([u({type:String,attribute:"data-base-item"})],B.prototype,"baseItemUrl",2),n([u({type:String,attribute:"data-base-ref"})],B.prototype,"baseRefUrl",2),n([u({type:String,attribute:"id"})],B.prototype,"id",2),n([x()],B.prototype,"_errorMessage",2),B=n([m("qti-custom-interaction")],B);var G=class extends v{constructor(){super(...arguments);this.disabled=!1;this.countAttempt=null;this.title="end attempt"}render(){return h`<button ?disabled=${this.disabled} part="button" @click=${this.endAttempt}>${this.title}</button>`}endAttempt(e){this.dispatchEvent(new CustomEvent("end-attempt",{bubbles:!0,composed:!0,detail:{responseIdentifier:this.responseIdentifier,countAttempt:this.countAttempt==="true"}}))}};n([u({type:String,attribute:"response-identifier"})],G.prototype,"responseIdentifier",2),n([u({reflect:!0,type:Boolean})],G.prototype,"disabled",2),n([u({type:String,attribute:"count-attempt"})],G.prototype,"countAttempt",2),n([u({type:String})],G.prototype,"title",2),G=n([m("qti-end-attempt-interaction")],G);var Q=p=>p??V;var Wt=b`
175
+ /* PK: display host as block, else design will be collapsed */
176
+ :host {
177
+ display: block;
178
+ }
179
+ textarea {
180
+ box-sizing: border-box;
181
+ width: 100%;
182
+ height: 100%;
183
+ border: 0;
184
+ }
185
+ `;var D=class extends E{constructor(){super(...arguments);this._rows=5;this._value=""}handleclassNamesChange(e,t){let i=t.split(" "),r=!1;if(i.forEach(a=>{if(a.startsWith("qti-height-lines-")){let o=a.replace("qti-height-lines-","");this._rows=parseInt(o),r=!0}}),!r&&this.expectedLength){let a=Math.ceil(this.expectedLength/50);this._rows=a}}get value(){return this._value||null}set value(e){if(typeof e=="string"||e===null){this._value=e||"";let t=new FormData;t.append(this.responseIdentifier,this._value),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}$`,i=new RegExp(t);e.checkValidity()&&i.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 h`<slot name="prompt"></slot
186
+ ><textarea
187
+ part="textarea"
188
+ name="${this.responseIdentifier}"
189
+ spellcheck="false"
190
+ autocomplete="off"
191
+ maxlength="${5e3}"
192
+ @keydown="${e=>e.stopImmediatePropagation()}"
193
+ @keyup="${this.textChanged}"
194
+ @change="${this.textChanged}"
195
+ @blur="${e=>{this.reportValidity()}}"
196
+ placeholder="${Q(this.placeholderText?this.placeholderText:void 0)}"
197
+ rows="${this._rows}"
198
+ ?disabled="${this.disabled}"
199
+ ?readonly="${this.readonly}"
200
+ .value=${this._value}
201
+ ></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")}};D.styles=Wt,n([x()],D.prototype,"_rows",2),n([u({type:Number,attribute:"expected-length"})],D.prototype,"expectedLength",2),n([u({type:String,attribute:"pattern-mask"})],D.prototype,"patternMask",2),n([u({type:String,attribute:"placeholder-text"})],D.prototype,"placeholderText",2),n([u({type:String,attribute:"data-patternmask-message"})],D.prototype,"dataPatternmaskMessage",2),n([x()],D.prototype,"_value",2),n([u({type:String,attribute:"class"})],D.prototype,"classNames",2),n([k("classNames")],D.prototype,"handleclassNamesChange",1),D=n([m("qti-extended-text-interaction")],D);var fe=class extends v{constructor(){super(...arguments);this.tabindex=0}connectedCallback(){this.setAttribute("slot","drags")}};fe.styles=b`
202
+ :host {
203
+ display: flex;
204
+ user-select: none;
205
+ }
206
+ `,n([u({type:Number,reflect:!0})],fe.prototype,"tabindex",2),fe=n([m("qti-gap-img")],fe);var Jt=b`
207
+ :host {
208
+ display: flex;
209
+ align-items: flex-start;
210
+ flex-direction: column;
211
+ flex-wrap: wrap;
212
+ gap: 0.5rem;
213
+ }
214
+
215
+ :host(.qti-choices-top) {
216
+ flex-direction: column;
217
+ }
218
+ :host(.qti-choices-bottom) {
219
+ flex-direction: column-reverse;
220
+ }
221
+ :host(.qti-choices-left) {
222
+ flex-direction: row;
223
+ }
224
+ :host(.qti-choices-right) {
225
+ flex-direction: row-reverse;
226
+ }
227
+ /* [part='drops'] , */
228
+ [name='prompt'] {
229
+ width: 100%;
230
+ }
231
+ [name='drags'] {
232
+ display: flex;
233
+ align-items: flex-start;
234
+ flex: 1;
235
+ border: 2px solid transparent;
236
+ padding: 0.3rem;
237
+ border-radius: 0.3rem;
238
+ gap: 0.5rem;
239
+ }
240
+ `;var Re=class extends H(E,"qti-gap-text","qti-gap","slot[part='drags']"){render(){return h`<slot name="prompt"> </slot>
241
+ <slot part="drags" name="drags"></slot>
242
+ <slot part="drops"></slot>
243
+ <div role="alert" id="validationMessage"></div>`}set correctResponse(s){let e=[],t=Array.isArray(s)?s:[s];t&&(e=t.map(r=>{let a=r.split(" ");return{text:a[0],gap:a[1]}})),this.querySelectorAll("qti-gap").forEach(r=>{let a=r.getAttribute("identifier"),o=e.find(c=>c.gap===a)?.text,l=this.querySelector(`qti-gap-text[identifier="${o}"]`)?.textContent.trim();if(o&&l){if(!r.nextElementSibling?.classList.contains("correct-option")){let c=document.createElement("span");c.classList.add("correct-option"),c.textContent=l,r.insertAdjacentElement("afterend",c)}}else r.nextElementSibling?.classList.contains("correct-option")&&r.nextElementSibling.remove()})}};Re.styles=Jt,Re=n([m("qti-gap-match-interaction")],Re);var Kt={toAttribute:p=>p?"true":"false",fromAttribute:p=>p==="true"};function N(p,s){class e extends p{constructor(...r){super(...r);this.identifier="";this.tabIndex=0;this.disabled=!1;this.readonly=!1;this.internals=this.attachInternals()}handleDisabledChange(r,a){this.tabIndex=a?-1:0,a&&this.blur()}connectedCallback(){super.connectedCallback(),this.addEventListener("keyup",this._onKeyUp),this.addEventListener("click",this._onClick),this.dispatchEvent(new CustomEvent(`register-${s}`,{bubbles:!0,composed:!0}))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("keyup",this._onKeyUp),this.removeEventListener("click",this._onClick),this.dispatchEvent(new CustomEvent(`unregister-${s}`,{bubbles:!0,composed:!0}))}_onKeyUp(r){r.altKey||r.code==="Space"&&(r.preventDefault(),this._activate())}_onClick(){this.disabled||this.readonly||(this.focus(),this._activate())}_activate(){this.disabled||this.readonly||this.dispatchEvent(new CustomEvent(`activate-${s}`,{bubbles:!0,composed:!0,detail:{identifier:this.identifier}}))}render(){return h`<slot></slot>`}}return n([u({type:String})],e.prototype,"identifier",2),n([u({type:Number,reflect:!0,attribute:"tabindex"})],e.prototype,"tabIndex",2),n([u({type:Boolean,reflect:!0,attribute:"aria-disabled",converter:Kt})],e.prototype,"disabled",2),n([u({type:Boolean,reflect:!0,attribute:"aria-readonly",converter:Kt})],e.prototype,"readonly",2),n([k("disabled",{waitUntilFirstUpdate:!0})],e.prototype,"handleDisabledChange",1),e}var ge=class extends N(v,"qti-gap-text"){constructor(){super(...arguments);this.tabindex=0}connectedCallback(){super.connectedCallback(),this.setAttribute("slot","drags")}render(){return h`<slot></slot>`}};ge.styles=b`
244
+ :host {
245
+ display: inline-flex;
246
+ user-select: none;
247
+ }
248
+ `,n([u({type:Number,reflect:!0})],ge.prototype,"tabindex",2),ge=n([m("qti-gap-text")],ge);var be=class extends v{constructor(){super(...arguments);this.tabindex=0}render(){return h` <slot name="drags"></slot>`}};be.styles=b`
249
+ :host {
250
+ display: flex;
251
+ user-select: none;
252
+ }
253
+ `,n([u({type:Number,reflect:!0})],be.prototype,"tabindex",2),be=n([m("qti-gap")],be);var Zt=(p,s,e)=>{let t=new Map;for(let i=s;i<=e;i++)t.set(p[i],i);return t},ke=J(class extends pe{constructor(p){if(super(p),p.type!==ce.CHILD)throw Error("repeat() can only be used in text expressions")}dt(p,s,e){let t;e===void 0?e=s:s!==void 0&&(t=s);let i=[],r=[],a=0;for(let o of p)i[a]=t?t(o,a):a,r[a]=e(o,a),a++;return{values:r,keys:i}}render(p,s,e){return this.dt(p,s,e).values}update(p,[s,e,t]){let i=zt(p),{values:r,keys:a}=this.dt(s,e,t);if(!Array.isArray(i))return this.ut=a,r;let o=this.ut??(this.ut=[]),l=[],c,d,f=0,g=i.length-1,y=0,q=r.length-1;for(;f<=g&&y<=q;)if(i[f]===null)f++;else if(i[g]===null)g--;else if(o[f]===a[y])l[y]=K(i[f],r[y]),f++,y++;else if(o[g]===a[q])l[q]=K(i[g],r[q]),g--,q--;else if(o[f]===a[q])l[q]=K(i[f],r[q]),de(p,l[q+1],i[f]),f++,q--;else if(o[g]===a[y])l[y]=K(i[g],r[y]),de(p,i[f],i[g]),g--,y++;else if(c===void 0&&(c=Zt(a,y,q),d=Zt(o,f,g)),c.has(o[f]))if(c.has(o[g])){let w=d.get(a[y]),R=w!==void 0?i[w]:null;if(R===null){let T=de(p,i[f]);K(T,r[y]),l[y]=T}else l[y]=K(R,r[y]),de(p,i[f],R),i[w]=null;y++}else We(i[g]),g--;else We(i[f]),f++;for(;y<=q;){let w=de(p,l[q+1]);K(w,r[y]),l[y++]=w}for(;f<=g;){let w=i[f++];w!==null&&We(w)}return this.ut=a,Ft(p,l),le}});function ee(p,s,e,t){let i=e.getAttribute("width")?parseFloat(e.getAttribute("width")):e.naturalWidth,r=e.getAttribute("height")?parseFloat(e.getAttribute("height")):e.naturalHeight;switch(p){case"circle":{if(s.length!==3){console.error("Invalid cirlce coordinates:",s);return}let[a,o,l]=s,c=a/i*100,d=o/r*100,f=l/i*100;t.style.left=c-f+"%",t.style.top=d-f+"%";let g=l/i*100,y=l/r*100;t.style.width=2*g+"%",t.style.height=2*y+"%",t.style.borderRadius="50%"}break;case"rect":{if(s.length!==4){console.error("Invalid rectangle coordinates:",s);return}let[a,o,l,c]=s,d=a/i*100,f=o/r*100,g=l/i*100,y=c/r*100;t.style.left=d+"%",t.style.top=f+"%",t.style.width=g-d+"%",t.style.height=y-f+"%"}break;case"ellipse":{if(s.length!==4){console.error("Invalid ellipse coordinates:",s);return}let[a,o,l,c]=s,d=a/i*100,f=o/r*100,g=l/i*100,y=c/r*100;t.style.left=d-g+"%",t.style.top=f-y+"%",t.style.width=2*g+"%",t.style.height=2*y+"%",t.style.borderRadius="50%"}break;case"poly":{if(s.length<6||s.length%2!==0){console.error("Invalid polygon coordinates:",s);return}let a=[];for(let T=0;T<s.length;T+=2)a.push({x:s[T],y:s[T+1]});let o=Math.min(...a.map(T=>T.x)),l=Math.max(...a.map(T=>T.x)),c=Math.min(...a.map(T=>T.y)),d=Math.max(...a.map(T=>T.y)),f=o/i*100,g=c/r*100,y=l/i*100,q=d/r*100;t.style.left=f+"%",t.style.top=g+"%",t.style.width=y-f+"%",t.style.height=q-g+"%";let R=a.map(T=>({x:(T.x-o)/(l-o)*100,y:(T.y-c)/(d-c)*100})).map(T=>`${T.x}% ${T.y}%`).join(",");t.style.clipPath=`polygon(${R})`}break;default:console.error(`Unsupported shape: ${p}`);break}}var Gt=b`
254
+ slot:not([name='prompt']) {
255
+ // position: relative; /* qti-hotspot-choice relative to the slot */
256
+ display: block;
257
+ width: fit-content; /* hotspots not stretching further if image is at max size */
258
+ }
259
+ ::slotted(img) {
260
+ /* image not selectable anymore */
261
+ pointer-events: none;
262
+ user-select: none;
263
+ }
264
+ ::slotted(qti-associable-hotspot) {
265
+ transform: translate(-50%, -50%);
266
+ }
267
+ line-container {
268
+ display: block;
269
+ position: relative;
270
+ }
271
+ svg {
272
+ position: absolute;
273
+ top: 0px;
274
+ left: 0px;
275
+ }
276
+ `;var Y=class extends E{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 h`<slot name="prompt"></slot>
277
+ <line-container>
278
+ <svg
279
+ width=${Q(this.grImage[0]?.width)}
280
+ height=${Q(this.grImage[0]?.height)}
281
+ viewbox="0 0 ${this.grImage[0]?.width} ${this.grImage[0]?.height}"
282
+ >
283
+ ${ke(this._lines,e=>e,(e,t)=>pt`
284
+ <line
285
+ part="line"
286
+ x1=${parseInt(this.querySelector("[identifier="+e.split(" ")[0]+"]").style.left)}
287
+ y1=${parseInt(this.querySelector("[identifier="+e.split(" ")[0]+"]").style.top)}
288
+ x2=${parseInt(this.querySelector("[identifier="+e.split(" ")[1]+"]").style.left)}
289
+ y2=${parseInt(this.querySelector("[identifier="+e.split(" ")[1]+"]").style.top)}
290
+ stroke="red"
291
+ stroke-width="3"
292
+ @click=${i=>{i.stopPropagation(),this._lines=this._lines.filter((r,a)=>a!==t),this.saveResponse(this._lines)}}
293
+ />
294
+ `)}
295
+ ${this.startPoint&&pt`<line
296
+ part="point"
297
+ x1=${this.startCoord.x}
298
+ y1=${this.startCoord.y}
299
+ x2=${this.mouseCoord.x}
300
+ y2=${this.mouseCoord.y}
301
+ stroke="red"
302
+ stroke-width="3"
303
+ />`}
304
+ </svg>
305
+ <slot></slot>
306
+ </line-container>
307
+ <div role="alert" id="validationMessage"></div>`}positionHotspotOnRegister(e){let t=this.querySelector("img"),i=e.target,r=i.getAttribute("coords"),a=i.getAttribute("shape"),o=r.split(",").map(l=>parseInt(l));ee(a,o,t,i)}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",i=>{this.startPoint?this.endPoint||(this.endPoint=i.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=i.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)}};Y.styles=Gt,n([x()],Y.prototype,"_lines",2),n([x()],Y.prototype,"startCoord",2),n([x()],Y.prototype,"mouseCoord",2),n([Ot({selector:"img"})],Y.prototype,"grImage",2),Y=n([m("qti-graphic-associate-interaction")],Y);var Qt=b`
308
+ :host {
309
+ display: flex;
310
+ align-items: flex-start;
311
+ flex-direction: column;
312
+ flex-wrap: wrap;
313
+ gap: 0.5rem;
314
+ }
315
+
316
+ :host(.qti-choices-top) {
317
+ flex-direction: column-reverse;
318
+ }
319
+ :host(.qti-choices-bottom) {
320
+ flex-direction: column;
321
+ }
322
+ :host(.qti-choices-left) {
323
+ flex-direction: row-reverse;
324
+ & [name='drags'] {
325
+ width: 25%;
326
+ }
327
+ & [part='image'] {
328
+ width: 75%;
329
+ }
330
+ }
331
+ :host(.qti-choices-right) {
332
+ flex-direction: row;
333
+ & [name='drags'] {
334
+ width: 25%;
335
+ }
336
+ & [part='image'] {
337
+ width: 75%;
338
+ }
339
+ }
340
+ [part='image'] {
341
+ display: block;
342
+ position: relative;
343
+ }
344
+ /* [part='drops'] , */
345
+
346
+ [name='drags'] {
347
+ display: flex;
348
+ align-items: flex-start;
349
+ flex-wrap: wrap;
350
+ flex: 1;
351
+ border: 2px solid transparent;
352
+ padding: 0.3rem;
353
+ border-radius: 0.3rem;
354
+ gap: 0.5rem;
355
+ }
356
+ ::slotted(img) {
357
+ display: inline-block;
358
+ user-select: none;
359
+ pointer-events: none;
360
+ }
361
+ `;var Le=class extends H(E,"qti-gap-img, qti-gap-text","qti-associable-hotspot","slot[part='drags']"){render(){return h` <slot name="prompt"></slot>
362
+ <slot part="image"></slot>
363
+ <slot part="drags" name="drags" class="hover-border"></slot>
364
+ <div role="alert" id="validationMessage"></div>`}positionHotspotOnRegister(s){let e=s.target,t=e.getAttribute("coords"),i=e.getAttribute("shape"),r=t.split(",").map(a=>parseInt(a));switch(i){case"circle":{let[a,o,l]=r;e.style.left=a-l+"px",e.style.top=o-l+"px",e.style.width=e.style.height=2*l+"px"}break;case"rect":{let[a,o,l,c]=r;e.style.left=a+"px",e.style.top=o+"px",e.style.width=l-a+"px",e.style.height=c-o+"px"}break;default:break}}connectedCallback(){super.connectedCallback(),this.addEventListener("qti-register-hotspot",this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-register-hotspot",this.positionHotspotOnRegister)}};Le.styles=Qt,Le=n([m("qti-graphic-gap-match-interaction")],Le);var ei=b`
365
+ slot:not([name='prompt']) {
366
+ position: relative; /* qti-hotspot-choice relative to the slot */
367
+ display: block;
368
+ width: fit-content; /* hotspots not stretching further if image is at max size */
369
+ }
370
+ ::slotted(img) {
371
+ /* image not selectable anymore */
372
+ pointer-events: none;
373
+ user-select: none;
374
+ }
375
+ `;var Ae=class extends Z(E,"qti-hotspot-choice"){constructor(){super(...arguments);this._choiceElements=[]}render(){return h`
376
+ <slot name="prompt"></slot>
377
+ <slot></slot>
378
+ <div role="alert" id="validationMessage"></div>
379
+ `}setHotspotOrder(e){let{identifier:t}=e.detail,i=this._choiceElements.find(a=>a.getAttribute("identifier")===t);if(!i)return;let r=this._choiceElements.length;if(!this.choiceOrdering){if(this.choiceOrdering=!0,i.order==null){let a=this._choiceElements.filter(o=>o.order!=null).length;if(a>=r){this.choiceOrdering=!1;return}i.order=a+1}else{let a=i.order;i.order=null,this._choiceElements.forEach(o=>{o.order!=null&&o.order>a&&o.order--})}this.choiceOrdering=!1}}positionHotspotOnRegister(e){let t=this.querySelector("img"),i=e.target,r=i.getAttribute("coords"),a=i.getAttribute("shape"),o=r.split(",").map(l=>parseInt(l));ee(a,o,t,i)}connectedCallback(){super.connectedCallback(),this.addEventListener("activate-qti-hotspot-choice",this.setHotspotOrder),this.addEventListener("register-qti-hotspot-choice",this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("activate-qti-hotspot-choice",this.setHotspotOrder),this.removeEventListener("register-qti-hotspot-choice",this.positionHotspotOnRegister)}};Ae.styles=ei,Ae=n([m("qti-graphic-order-interaction")],Ae);var ve=class extends N(v,"qti-hotspot-choice"){};ve.styles=b`
380
+ :host {
381
+ display: flex;
382
+ user-select: none;
383
+ position: absolute;
384
+ }
385
+ `,n([u({attribute:"aria-ordervalue",type:Number,reflect:!0})],ve.prototype,"order",2),ve=n([m("qti-hotspot-choice")],ve);var ti=b`
386
+ slot:not([name='prompt']) {
387
+ position: relative; /* qti-hotspot-choice relative to the slot */
388
+ display: block;
389
+ width: fit-content; /* hotspots not stretching further if image is at max size */
390
+ }
391
+ ::slotted(img) {
392
+ /* image not selectable anymore */
393
+ pointer-events: none;
394
+ user-select: none;
395
+ /* width:100%; */
396
+ }
397
+ `;var De=class extends Z(E,"qti-hotspot-choice"){render(){return h`
398
+ <slot name="prompt"></slot>
399
+ <slot></slot>
400
+ `}positionHotspotOnRegister(s){let e=this.querySelector("img"),t=s.target,i=t.getAttribute("coords"),r=t.getAttribute("shape"),a=i.split(",").map(o=>parseInt(o));ee(r,a,e,t)}connectedCallback(){super.connectedCallback(),this.addEventListener("register-qti-hotspot-choice",this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("unregister-qti-hotspot-choice",this.positionHotspotOnRegister)}};De.styles=ti,De=n([m("qti-hotspot-interaction")],De);var Ze=class extends Z(E,"qti-hottext"){constructor(){super(...arguments);this.render=()=>h`<slot></slot>`}};Ze=n([m("qti-hottext-interaction")],Ze);var Ve=class extends N(v,"qti-hottext"){render(){return h`<div part="ch"><div part="cha"></div></div>
401
+ <slot></slot> `}};Ve.styles=b`
402
+ :host {
403
+ display: flex;
404
+ user-select: none;
405
+ }
406
+ `,Ve=n([m("qti-hottext")],Ve);var $e=class extends pe{constructor(s){if(super(s),this.it=V,s.type!==ce.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(s){if(s===V||s==null)return this._t=void 0,this.it=s;if(s===le)return s;if(typeof s!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(s===this.it)return this._t;this.it=s;let e=[s];return e.raw=e,this._t={_$litType$:this.constructor.resultType,strings:e,values:[]}}};$e.directiveName="unsafeHTML",$e.resultType=1;var te=J($e);var ie=class extends E{constructor(){super(...arguments);this.options=[];this.correctOption="";this.dataPrompt="select"}static get styles(){return[b`
407
+ :host {
408
+ display: inline-block;
409
+ }
410
+ slot {
411
+ display: flex;
412
+ flex-direction: column;
413
+ }
414
+ [role='menu'] {
415
+ position: absolute;
416
+ z-index: 1000;
417
+ }
418
+ .anchor {
419
+ /* anchor-name: --infobox; */
420
+ width: fit-content;
421
+ }
422
+
423
+ .positionedElement {
424
+ position: absolute;
425
+ /* position-anchor: --infobox; */
426
+ /* top: anchor(bottom); */
427
+ }
428
+ `]}render(){return h`
429
+ <select part="select" @change="${this.choiceSelected}" ?disabled="${this.disabled}" ?readonly="${this.readonly}">
430
+ ${this.options.map(e=>h`
431
+ <option value="${e.value}" ?selected="${e.selected}">${te(e.textContent)}</option>
432
+ `)}
433
+ </select>
434
+
435
+ ${te(this.correctOption)}
436
+ `}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&&e===t.value&&(t.selected=!0),t))}get value(){return this.options.find(e=>e.selected)?.value||null}toggleCorrectResponse(e,t){if(this.correctResponse=t?e.value:"",!this.correctResponse){this.correctOption="";return}this.correctOption=`<span part="correct-option">${this.options.find(i=>this.correctResponse===i.value).textContent}</span>`}choiceSelected(e){let t=e.target.value;this.options=this.options.map(i=>({...i,selected:i.value===t})),this.saveResponse(t)}};ie.inputWidthClass=["","qti-input-width-2","qti-input-width-1","qti-input-width-3","qti-input-width-4","qti-input-width-6","qti-input-width-10","qti-input-width-15","qti-input-width-20","qti-input-width-72"],n([x()],ie.prototype,"options",2),n([x()],ie.prototype,"correctOption",2),n([u({attribute:"data-prompt",type:String})],ie.prototype,"dataPrompt",2),ie=n([m("qti-inline-choice-interaction")],ie);var He=class extends v{static get styles(){return[b`
437
+ :host {
438
+ display: block;
439
+ cursor: pointer;
440
+ }
441
+ `]}connectedCallback(){super.connectedCallback(),this.addEventListener("click",this._onSelectInlineChoice),this.dispatchEvent(new CustomEvent("qti-inline-choice-register",{bubbles:!0,composed:!0,cancelable:!1}))}disconnectedCallback(){this.removeEventListener("click",this._onSelectInlineChoice)}render(){return h` <slot></slot> `}_onSelectInlineChoice(){this.dispatchEvent(new CustomEvent("qti-inline-choice-select",{bubbles:!0,cancelable:!1,composed:!0,detail:{identifier:this.identifier}}))}};n([u({type:String})],He.prototype,"identifier",2),He=n([m("qti-inline-choice")],He);var re=class extends N(v,"qti-simple-associable-choice"){constructor(){super(...arguments);this.matchMin=0;this.matchMax=1;this.fixed=!1}connectedCallback(){super.connectedCallback(),this.setAttribute("slot","qti-simple-associable-choice"),this.setAttribute("part","qti-simple-associable-choice")}render(){return h`
442
+ <slot part="slot"></slot>
443
+ <slot part="dropslot" name="qti-simple-associable-choice"></slot>
444
+ `}};re.styles=b`
445
+ :host {
446
+ display: flex;
447
+ user-select: none;
448
+ }
449
+ slot {
450
+ width: 100%;
451
+ display: block;
452
+ }
453
+ slot[name='qti-simple-associable-choice'] {
454
+ width: 100%;
455
+ }
456
+ `,n([u({type:Number,attribute:"match-min"})],re.prototype,"matchMin",2),n([u({type:Number,attribute:"match-max"})],re.prototype,"matchMax",2),n([u({type:Boolean,attribute:"fixed"})],re.prototype,"fixed",2),re=n([m("qti-simple-associable-choice")],re);var ii=b`
457
+ slot:not([hidden]) {
458
+ /* slot where the */
459
+ display: flex;
460
+ flex-direction: column;
461
+ gap: 0.5rem;
462
+ align-items: flex-start; /* prevents the drag and drop container slots having the same height */
463
+ }
464
+ :host(.qti-choices-top) slot {
465
+ flex-direction: column;
466
+ }
467
+ :host(.qti-choices-bottom) slot {
468
+ flex-direction: column-reverse;
469
+ }
470
+ :host(.qti-choices-left) slot {
471
+ flex-direction: row;
472
+ }
473
+ :host(.qti-choices-right) slot {
474
+ flex-direction: row-reverse;
475
+ }
476
+ slot[name='prompt'] {
477
+ display: block;
478
+ }
479
+ ::slotted(qti-simple-match-set) {
480
+ /* Make sure the drag and drop container slots have the same width */
481
+ flex: 1;
482
+ }
483
+ `;var U=class extends H(E,"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,i=t.value,r=t.name,a=t.type;t.checked?(this.value?this.value.indexOf(i)===-1&&(a==="radio"&&(this.value=this.value.filter(o=>o.indexOf(r)===-1)),this.value=[...this.value,i]):this.value=[i],this.lastCheckedRadio=t):(this.value=this.value.filter(o=>o!==i),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,this.class.split(" ").includes("qti-match-tabular")||(this.value=e))}render(){let e=this.class.split(" ").includes("qti-match-tabular");return h`
484
+ <slot name="prompt"></slot>
485
+ <slot ?hidden=${e}></slot>
486
+
487
+ ${e?h`
488
+ <table>
489
+ <tr>
490
+ <td></td>
491
+ ${this.cols.map(t=>h`<th part="r-header">${te(t.innerHTML)}</th>`)}
492
+ </tr>
493
+
494
+ ${this.rows.map(t=>h`<tr>
495
+ <td part="c-header">${te(t.innerHTML)}</td>
496
+ ${this.cols.map(i=>{let r=t.getAttribute("identifier"),a=i.getAttribute("identifier"),o=`${r} ${a}`,l=this.value.filter(g=>g.split(" ")[0]===r).length||0,c=this.value.includes(o),d=`rb ${c?"rb-checked":""} ${this.correctOptions.includes(o)?"rb-correct":""}`,f=this.correctOptions.length>0?!0:t.matchMax===1?!1:t.matchMax!==0&&l>=t.matchMax&&!c;return h`<td>
497
+ <input
498
+ type=${t.matchMax===1?"radio":"checkbox"}
499
+ part=${d}
500
+ name=${r}
501
+ value=${o}
502
+ .disabled=${f}
503
+ @change=${g=>this.handleRadioChange(g)}
504
+ @click=${g=>t.matchMax===1?this.handleRadioClick(g):null}
505
+ />
506
+ </td>`})}
507
+ </tr>`)}
508
+ </table>
509
+ `:V}
510
+
511
+ <div role="alert" id="validationMessage"></div>
512
+ `}};U.styles=ii,n([u({type:String})],U.prototype,"class",2),n([x()],U.prototype,"_response",2),n([u({type:String,attribute:"response-identifier"})],U.prototype,"responseIdentifier",2),n([x()],U.prototype,"correctOptions",2),U=n([m("qti-match-interaction")],U);var Ne=class extends E{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{...E.properties,step:{type:Number,attribute:"step",default:10}}}render(){return h` <slot name="prompt"></slot>
513
+ <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)})}};Ne.styles=[b``],Ne=n([m("qti-media-interaction")],Ne);var ri=b`
514
+ [part='drags'] {
515
+ display: flex;
516
+ align-items: flex-start;
517
+ flex: 1;
518
+ border: 2px solid transparent;
519
+ }
520
+
521
+ [part='drops'] {
522
+ flex: 1;
523
+ display: grid;
524
+ grid-auto-flow: column;
525
+ grid-auto-columns: 1fr;
526
+ }
527
+
528
+ :host([orientation='horizontal']) [part='drags'] {
529
+ flex-direction: row;
530
+ }
531
+ :host([orientation='horizontal']) [part='drops'] {
532
+ grid-auto-flow: column;
533
+ }
534
+ :host([orientation='vertical']) [part='drags'] {
535
+ flex-direction: column;
536
+ }
537
+ :host([orientation='vertical']) [part='drops'] {
538
+ grid-auto-flow: row;
539
+ }
540
+
541
+ [part='drop-list'] {
542
+ display: block;
543
+ flex: 1;
544
+ }
545
+
546
+ [part='container'] {
547
+ display: flex;
548
+ gap: 0.5rem;
549
+ }
550
+ :host(.qti-choices-top) [part='container'] {
551
+ flex-direction: column;
552
+ }
553
+ :host(.qti-choices-bottom) [part='container'] {
554
+ flex-direction: column-reverse;
555
+ }
556
+ :host(.qti-choices-left) [part='container'] {
557
+ flex-direction: row;
558
+ }
559
+ :host(.qti-choices-right) [part='container'] {
560
+ flex-direction: row-reverse;
561
+ }
562
+ `;var X=class extends Ke(H(E,"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),h` <slot name="prompt"> </slot>
563
+ <div part="container">
564
+ <slot part="drags"> </slot>
565
+ <div part="drops">
566
+ ${Array.from(Array(this.nrChoices)).map((t,i)=>h`<drop-list part="drop-list" identifier="droplist${i}"></drop-list>${this.showCorrectResponses&&this.correctResponses.length>i?te(`<span part='correct-response'>${this.correctResponses[i]}</span>`):""}`)}
567
+ </div>
568
+ </div>`}set correctResponse(e){if(e===""){this.showCorrectResponses=!1;return}this.correctResponses.length===0&&(Array.isArray(e)?e:[e]).forEach(i=>{let r=this.querySelector(`qti-simple-choice[identifier="${i}"]`);r||(r=this.shadowRoot.querySelector(`qti-simple-choice[identifier="${i}"]`));let a=r?.textContent.trim();this.correctResponses=[...this.correctResponses,a]}),this.showCorrectResponses=!0}getResponse(){return Array.from(this.shadowRoot.querySelectorAll("drop-list")).map(i=>{let r=i.querySelectorAll('[qti-draggable="true"]');return[...Array.from(r).map(o=>o.getAttribute("identifier"))].join(" ")})}async firstUpdated(e){super.firstUpdated(e),this.childrenMap=Array.from(this.querySelectorAll("qti-simple-choice")),this.childrenMap.forEach(t=>t.setAttribute("part","qti-simple-choice"))}};X.styles=ri,n([x()],X.prototype,"nrChoices",2),n([x()],X.prototype,"correctResponses",2),n([x()],X.prototype,"showCorrectResponses",2),n([u({type:String})],X.prototype,"orientation",2),X=n([m("qti-order-interaction")],X);var se=class extends E{constructor(){super(...arguments);this._errorMessage=null;this._onInteractionChanged=e=>{e.stopPropagation();let t=this.convertQtiVariableJSON(e.detail.value);this.value=t,this.saveResponse(t)};this.loadConfig=async(e,t)=>{e=this.removeDoubleSlashes(e);try{let i=await fetch(e);if(i.ok){let a=await i.json();for(let o in a.paths)t&&(a.paths[o]=this.getResolvablePath(a.paths[o],t));return a}}catch{}return null};this.getResolvablePathString=(e,t)=>(e=e.replace(/\.js$/,""),e?.toLocaleLowerCase().startsWith("http")||!t?e:this.removeDoubleSlashes(`${t}/${e}`));this.getResolvablePath=(e,t)=>Array.isArray(e)?e.map(i=>this.getResolvablePathString(i,t)):this.getResolvablePathString(e,t)}convertQtiVariableJSON(e){for(let t in e)if(e.hasOwnProperty(t)){let i=e[t];if(i){for(let r in i)if(i.hasOwnProperty(r)){let a=i[r];if(Array.isArray(a))return a.map(String);if(a!=null)return String(a)}}}return null}addHyphenatedKeys(e){let t={...e};for(let i in e)if(Object.prototype.hasOwnProperty.call(e,i)){let r=i.replace(/[A-Z]/g,a=>`-${a.toLowerCase()}`);t[r]=e[i]}return t}responseVariablesToQtiVariableJSON(e,t,i){if(t!=="single"){let r={list:{}};return r.list[i]=e,r}else{let r={base:{}};return r.base[i]=e,r}}validate(){return!0}set value(e){this._value=e}get value(){let e=this.pci?.getResponse();return e?this.convertQtiVariableJSON(e):this._value}set boundTo(e){let t=this.convertQtiVariableJSON(e);this._value=t,this.saveResponse(t)}get boundTo(){let e=this.responseVariablesToQtiVariableJSON(this._value,this.context?.variables?.find(i=>i.identifier===this.responseIdentifier)?.cardinality||"single",this.context?.variables?.find(i=>i.identifier===this.responseIdentifier)?.baseType||"string"),t={};return t[this.responseIdentifier]=e,t}register(e){this.pci=e,this.dom=this.querySelector("qti-interaction-markup"),this.dom||(this.dom=document.createElement("div"),this.appendChild(this.dom)),this.dom.classList.add("qti-customInteraction"),this.dom.addEventListener("qti-interaction-changed",this._onInteractionChanged),this.querySelector("properties")&&(this.querySelector("properties").style.display="none");let t={properties:this.addHyphenatedKeys({...this.dataset}),onready:i=>{this.pci=i},ondone:(i,r,a,o)=>{this.value=this.convertQtiVariableJSON(r),this.saveResponse(this.value)},responseIdentifier:this.responseIdentifier,boundTo:this.boundTo};if(e.getInstance)e.getInstance(this.dom,t,void 0);else{let r=(a=>{let o={},c=(d=>{let f={};Object.entries(d.dataset).forEach(([y,q])=>{y.includes("__")||(f[y]=q)});let g={};return Object.entries(d.dataset).forEach(([y,q])=>{let w=y.split("__");if(w.length>1){let[R,T,ae]=w;g[R]=g[R]||{},g[R][T]=g[R][T]||{},g[R][T][ae]=q}}),Object.entries(g).forEach(([y,q])=>{f[y]=Object.values(q)}),f})(a);for(let d in c)if(Object.prototype.hasOwnProperty.call(c,d)){let f=c[d];d==="config"?o[d]=JSON.parse(f):o[d]=f}return o})(this);e.initialize(this.customInteractionTypeIdentifier,this.dom.firstElementChild||this.dom,Object.keys(r).length?r:null)}}connectedCallback(){super.connectedCallback(),define("qtiCustomInteractionContext",()=>({register:i=>{this.register(i)},notifyReady:()=>{}}));let e=this.buildRequireConfig(),t=requirejs.config(e);requirejs.onError=function(i){throw console.error("RequireJS error:",i),i.requireType==="timeout"&&console.error("Modules that timed out:",i.requireModules),i},t(["require"],i=>{try{i([this.module],()=>{},r=>{console.error("Error loading module:",r)})}catch(r){console.error("Error in require call:",r)}})}disconnectedCallback(){super.disconnectedCallback(),requirejs.undef(this.customInteractionTypeIdentifier);let e=requirejs.s.contexts;delete e[this.customInteractionTypeIdentifier],this.removeEventListener("qti-interaction-changed",this._onInteractionChanged)}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"),i=this.querySelector("qti-interaction-modules");if(i){let r=i.querySelectorAll("qti-interaction-module");for(let a of r){let o=a.getAttribute("id"),l=a.getAttribute("primary-path"),c=a.getAttribute("fallback-path");if(o&&l){let d=c?this.combineRequireResolvePaths(this.getResolvablePath(l,t),this.getResolvablePath(c,t)):this.getResolvablePath(l,t),f=e.paths[o]||[];e.paths[o]=this.combineRequireResolvePaths(f,d)}}}return e}combineRequireResolvePaths(e,t){let i=Array.isArray(e)?e:[e],r=Array.isArray(t)?t:[t];return i.concat(r).filter((a,o,l)=>l.indexOf(a)===o)}removeDoubleSlashes(e){return e.replace(/([^:]\/)\/+/g,"$1").replace(/\/\//g,"/").replace("http:/","http://").replace("https:/","https://")}render(){return h`<slot></slot>${this._errorMessage&&h`<div style="color:red">
569
+ <h1>Error</h1>
570
+ ${this._errorMessage}
571
+ </div>`}`}};n([u({type:String,attribute:"module"})],se.prototype,"module",2),n([u({type:String,attribute:"custom-interaction-type-identifier"})],se.prototype,"customInteractionTypeIdentifier",2),n([x()],se.prototype,"_errorMessage",2),n([S({context:M,subscribe:!0}),x()],se.prototype,"context",2),se=n([m("qti-portable-custom-interaction-tao")],se);var Ge=class extends v{render(){return h`<slot></slot>`}};Ge.styles=[b`
572
+ :host {
573
+ display: block;
574
+ }
575
+ ::slotted(img) {
576
+ position: absolute;
577
+ cursor: move;
578
+ user-select: none;
579
+ left: 50%;
580
+ transform: translateX(-50%);
581
+ }
582
+ `];customElements.define("qti-position-object-interaction",Ge);var Oe=class extends v{render(){return h`<slot></slot>`}constructor(){super(),this.removeMoveListener=this.removeMoveListener.bind(this),this.dragElementHandler=this.dragElementHandler.bind(this)}dragElementHandler(s){s.preventDefault();let e=s.clientX-this.startX,t=s.clientY-this.startY;this.dragElement.style.left=this.dragElement.offsetLeft+e+"px",this.dragElement.style.top=this.dragElement.offsetTop+t+"px",this.startX=s.clientX,this.startY=s.clientY}firstUpdated(s){super.firstUpdated(s),this.dragElement=this.querySelector("qti-position-object-interaction>img"),this.startX=0,this.startY=0,this.dragElement.addEventListener("mousedown",e=>{this.startX=e.clientX,this.startY=e.clientY,document.addEventListener("mousemove",this.dragElementHandler,!0)}),document.addEventListener("mouseup",this.removeMoveListener)}removeMoveListener(){document.removeEventListener("mousemove",this.dragElementHandler,!0)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("mousemove",this.dragElementHandler),document.removeEventListener("mouseup",this.removeMoveListener)}};Oe.styles=[b`
583
+ :host {
584
+ display: inline-block;
585
+ position: relative;
586
+ }
587
+ `],Oe=n([m("qti-position-object-stage")],Oe);var si="important",mi=" !"+si,ut=J(class extends pe{constructor(p){if(super(p),p.type!==ce.ATTRIBUTE||p.name!=="style"||p.strings?.length>2)throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.")}render(p){return Object.keys(p).reduce((s,e)=>{let t=p[e];return t==null?s:s+`${e=e.includes("-")?e:e.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${t};`},"")}update(p,[s]){let{style:e}=p.element;if(this.ft===void 0)return this.ft=new Set(Object.keys(s)),this.render(s);for(let t of this.ft)s[t]==null&&(this.ft.delete(t),t.includes("-")?e.removeProperty(t):e[t]=null);for(let t in s){let i=s[t];if(i!=null){this.ft.add(t);let r=typeof i=="string"&&i.endsWith(mi);t.includes("-")||r?e.setProperty(t,r?i.slice(0,-11):i,r?si:""):e[t]=i}}return le}});var j=class extends E{constructor(){super(...arguments);this.maxChoices=1/0;this.minChoices=0;this._points=[];this._correctAreas=[];this._imgElement=null;this._scaleX=1;this._scaleY=1;this._imageWidthOrginal=0;this._imageHeightOrginal=0;this._onImageClick=e=>{if(!this._imgElement){console.warn("No <img> element found in <qti-select-point-interaction>");return}this.calculateScale();let t=this._imgElement.getBoundingClientRect(),i=(e.clientX-t.left)*this._scaleX,r=(e.clientY-t.top)*this._scaleY,a=`${i.toFixed()} ${r.toFixed()}`;this.maxChoices===1?this._points=[a]:this._points.length<this.maxChoices?this._points=[...this._points,a]:console.warn("Maximum number of points reached. Remove a marker to add a new one."),this.saveResponse(this._points)};this._onResize=()=>{this.calculateScale()}}connectedCallback(){super.connectedCallback(),window.addEventListener("resize",this._onResize)}toggleCorrectResponse(e,t){let i=e.areaMapping;if(!i){console.error("No area mapping found for the response variable.");return}let r=i.mapEntries;this._correctAreas=t?r.map(a=>({coords:a.coords,shape:a.shape})):[]}updated(e){super.updated(e);let t=this._imgElement;t&&e.has("_correctAreas")&&this._correctAreas.length>0&&(this.calculateScale(),this.shadowRoot.querySelectorAll("div").forEach(i=>{let r=i.dataset.coord,a=i.dataset.shape;r&&a&&ee(a,r.split(",").map(o=>+o),t,i)}))}render(){return h` <slot name="prompt"></slot>
588
+ <point-container>
589
+ ${ke(this._points.filter(e=>e),e=>e,(e,t)=>{let[i,r]=e.split(" ").map(Number),a=i/(this._imageWidthOrginal||1)*100,o=r/(this._imageHeightOrginal||1)*100;return h`
590
+ <button
591
+ part="point"
592
+ style=${ut({pointerEvents:this.maxChoices===1?"none":"auto",position:"absolute",transform:"translate(-50%, -50%)",left:`${a}%`,top:`${o}%`})}
593
+ aria-label="Remove point at ${e}"
594
+ @click=${l=>{l.stopPropagation(),console.log("click"),this._points=this._points.filter((c,d)=>d!==t),this.saveResponse(this._points)}}
595
+ ></button>
596
+ `})}
597
+ ${ke(this._correctAreas?.filter(e=>e),e=>e,(e,t)=>h`<div
598
+ style=${ut({position:"absolute",pointerEvents:"none",backgroundColor:"#808080",opacity:"0.5"})}
599
+ data-coord="${e.coords}"
600
+ data-shape="${e.shape}"
601
+ ></div>`)}
602
+ <slot></slot>
603
+ </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?[e]:[]}get value(){return this._points}calculateScale(){this._imageWidthOrginal=this._imgElement.getAttribute("width")?parseFloat(this._imgElement.getAttribute("width")):this._imgElement.naturalWidth,this._imageHeightOrginal=this._imgElement.getAttribute("height")?parseFloat(this._imgElement.getAttribute("height")):this._imgElement.naturalHeight;let e=this._imgElement.getBoundingClientRect();this._scaleX=e.width===0?1:this._imageWidthOrginal/e.width,this._scaleY=e.height===0?1:this._imageHeightOrginal/e.height}firstUpdated(){this._imgElement=this.querySelector("img"),this._imgElement?(this.calculateScale(),this._imgElement.addEventListener("click",this._onImageClick)):console.warn("No <img> element found in <qti-select-point-interaction>")}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("resize",this._onResize),this._imgElement&&this._imgElement.removeEventListener("click",this._onImageClick)}};j.styles=[b`
604
+ :host {
605
+ display: block;
606
+ }
607
+ point-container {
608
+ display: block;
609
+ position: relative;
610
+ width: fit-content;
611
+ }
612
+
613
+ ::slotted(img) {
614
+ max-width: 100%;
615
+ height: auto;
616
+ display: block;
617
+ }
618
+ `],n([u({type:Number,attribute:"max-choices"})],j.prototype,"maxChoices",2),n([u({type:Number,attribute:"min-choices"})],j.prototype,"minChoices",2),n([x()],j.prototype,"_points",2),n([x()],j.prototype,"_correctAreas",2),j=n([m("qti-select-point-interaction")],j);var ye=class extends N(v,"qti-simple-choice"){get checked(){return this.internals.states.has("--checked")}render(){return h`<div part="ch">
619
+ <div part="cha"></div>
620
+ </div>
621
+ ${this.marker?h`<div id="label">${this.marker}</div>`:V}
622
+ <slot part="slot"></slot> `}};ye.styles=b`
623
+ :host {
624
+ display: flex;
625
+ align-items: center;
626
+ user-select: none;
627
+ }
628
+ slot {
629
+ width: 100%;
630
+ display: flex;
631
+ align-items: center;
632
+ }
633
+ [part='ch'] {
634
+ display: flex;
635
+ flex-shrink: 0;
636
+ align-items: center;
637
+ justify-content: center;
638
+ }
639
+ `,n([u({type:String,attribute:!1})],ye.prototype,"marker",2),ye=n([m("qti-simple-choice")],ye);var oi=b`
640
+ :host {
641
+ display: block;
642
+ --show-bounds: true;
643
+ --show-ticks: true;
644
+ --show-value: true;
645
+ }
646
+
647
+ [part='slider'] {
648
+ margin-left: 2rem; /* mx-8 */
649
+ margin-right: 2rem;
650
+ padding-bottom: 1rem; /* pb-4 */
651
+ padding-top: 1.25rem; /* pt-5 */
652
+ }
653
+
654
+ [part='bounds'] {
655
+ display: flex;
656
+ width: 100%;
657
+ justify-content: space-between;
658
+ margin-bottom: 0.5rem; /* mb-2 */
659
+ }
660
+
661
+ [part='ticks'] {
662
+ margin-left: 0.125rem; /* mx-0.5 */
663
+ margin-right: 0.125rem;
664
+ margin-bottom: 0.25rem; /* mb-1 */
665
+ height: 0.5rem; /* h-2 */
666
+ background: linear-gradient(to right, var(--qti-border-color) var(--qti-border-thickness), transparent 1px) repeat-x
667
+ 0 center / calc(calc(100% - var(--qti-border-thickness)) / ((var(--max) - var(--min)) / var(--step))) 100%;
668
+ }
669
+
670
+ [part='rail'] {
671
+ display: flex;
672
+ align-items: center;
673
+ box-sizing: border-box;
674
+ height: 0.375rem; /* h-1.5 */
675
+ width: 100%;
676
+ cursor: pointer;
677
+ border-radius: 9999px; /* rounded-full */
678
+ border: 1px solid #d1d5db; /* border-gray-300 */
679
+ background-color: #e5e7eb; /* bg-gray-200 */
680
+ }
681
+
682
+ [part='knob'] {
683
+ background-color: var(--qti-bg-active);
684
+ border: 2px solid var(--qti-border-active);
685
+ position: relative;
686
+ height: 1rem; /* h-4 */
687
+ width: 1rem; /* w-4 */
688
+ transform-origin: center;
689
+ transform: translateX(-50%);
690
+ cursor: pointer;
691
+ border-radius: 9999px; /* rounded-full */
692
+ left: var(--value-percentage);
693
+ }
694
+
695
+ [part='value'] {
696
+ position: absolute;
697
+ bottom: 2rem; /* bottom-8 */
698
+ left: 0.5rem; /* left-2 */
699
+ transform: translateX(-50%);
700
+ cursor: pointer;
701
+ border-radius: 0.25rem; /* rounded */
702
+ background-color: #f3f4f6; /* bg-gray-100 */
703
+ padding: 0.25rem 0.5rem; /* px-2 py-1 */
704
+ text-align: center;
705
+ color: #6b7280; /* text-gray-500 */
706
+ }
707
+ `;var O=class extends v{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 h`
708
+ <slot name="prompt"></slot>
709
+ <div id="slider" part="slider">
710
+ <div id="bounds" part="bounds">
711
+ <div>${this.min}</div>
712
+ <div>${this.max}</div>
713
+ </div>
714
+
715
+ <div id="ticks" part="ticks"></div>
716
+
717
+ <div id="rail" part="rail" @mousedown=${this._onMouseDown} @touchstart=${this._onTouchStart}>
718
+ <div id="knob" part="knob"><div id="value" part="value">${this.value}</div></div>
719
+ </div>
720
+ </div>
721
+ `}_onMouseDown(e){this._startDrag(e.pageX);let t=r=>this._onDrag(r.pageX),i=()=>{document.removeEventListener("mousemove",t),document.removeEventListener("mouseup",i),this._onDragEnd()};document.addEventListener("mousemove",t),document.addEventListener("mouseup",i)}_onTouchStart(e){this._startDrag(e.touches[0].pageX);let t=r=>this._onDrag(r.touches[0].pageX),i=()=>{document.removeEventListener("touchmove",t),document.removeEventListener("touchend",i),this._onDragEnd()};document.addEventListener("touchmove",t,{passive:!1}),document.addEventListener("touchend",i)}_startDrag(e){this._onDrag(e)}_onDrag(e){let t=this._rail.getBoundingClientRect(),i=e-t.left,r=Math.min(1,Math.max(0,i/t.width)),a=this.min+Math.round(r*(this.max-this.min)/this.step)*this.step;this._updateValue(a)}_onDragEnd(){this.dispatchEvent(new Event("change",{bubbles:!0}))}};O.formAssociated=!0,O.styles=oi,n([Xe("#rail")],O.prototype,"_rail",2),n([u({type:Number,attribute:"lower-bound"})],O.prototype,"min",2),n([u({type:Number,attribute:"upper-bound"})],O.prototype,"max",2),n([u({type:Number,attribute:"step"})],O.prototype,"step",2),O=n([m("qti-slider-interaction")],O);var ni=()=>new mt,mt=class{},ht=new WeakMap,Ya=J(class extends Bt{render(p){return V}update(p,[s]){let e=s!==this.Y;return e&&this.Y!==void 0&&this.rt(void 0),(e||this.lt!==this.ct)&&(this.Y=s,this.ht=p.options?.host,this.rt(this.ct=p.element)),V}rt(p){if(this.isConnected||(p=void 0),typeof this.Y=="function"){let s=this.ht??globalThis,e=ht.get(s);e===void 0&&(e=new WeakMap,ht.set(s,e)),e.get(this.Y)!==void 0&&this.Y.call(this.ht,void 0),e.set(this.Y,p),p!==void 0&&this.Y.call(this.ht,p)}else this.Y.value=p}get lt(){return typeof this.Y=="function"?ht.get(this.ht??globalThis)?.get(this.Y):this.Y?.value}disconnected(){this.lt===this.ct&&this.rt(void 0)}reconnected(){this.rt(this.ct)}});var ai=b`
722
+ :host {
723
+ display: inline-block;
724
+ }
725
+ [part='correct'] {
726
+ position: absolute;
727
+ width: 100%;
728
+ }
729
+ :host(.qti-input-width-1) [part='input'] {
730
+ width: 1.1rem;
731
+ min-width: 1.1rem;
732
+ }
733
+
734
+ :host(.qti-input-width-2) [part='input'] {
735
+ width: 2.3rem;
736
+ min-width: 2.3rem;
737
+ }
738
+
739
+ :host(.qti-input-width-3) [part='input'] {
740
+ width: 3.3rem;
741
+ min-width: 3.3rem;
742
+ }
743
+
744
+ :host(.qti-input-width-4) [part='input'] {
745
+ width: 4.2rem;
746
+ min-width: 4.2rem;
747
+ }
748
+
749
+ :host(.qti-input-width-6) [part='input'] {
750
+ width: 6.6rem;
751
+ min-width: 6.6rem;
752
+ }
753
+
754
+ :host(.qti-input-width-10) [part='input'] {
755
+ width: 8rem;
756
+ min-width: 8rem;
757
+ }
758
+
759
+ :host(.qti-input-width-15) [part='input'] {
760
+ width: 12rem;
761
+ min-width: 12rem;
762
+ }
763
+
764
+ :host(.qti-input-width-20) [part='input'] {
765
+ width: 17rem;
766
+ min-width: 17rem;
767
+ }
768
+
769
+ :host(.qti-input-width-25) [part='input'] {
770
+ width: 20rem;
771
+ min-width: 20rem;
772
+ }
773
+
774
+ :host(.qti-input-width-30) [part='input'] {
775
+ width: 24rem;
776
+ min-width: 24rem;
777
+ }
778
+
779
+ :host(.qti-input-width-35) [part='input'] {
780
+ width: 28rem;
781
+ min-width: 28rem;
782
+ }
783
+
784
+ :host(.qti-input-width-40) [part='input'] {
785
+ width: 32rem;
786
+ min-width: 32rem;
787
+ }
788
+
789
+ :host(.qti-input-width-45) [part='input'] {
790
+ width: 36rem;
791
+ min-width: 36rem;
792
+ }
793
+
794
+ :host(.qti-input-width-50) [part='input'] {
795
+ width: 40rem;
796
+ min-width: 40rem;
797
+ }
798
+
799
+ :host(.qti-input-width-72) [part='input'] {
800
+ width: 57rem;
801
+ min-width: 57rem;
802
+ }
803
+ `;var I=class extends E{constructor(){super(...arguments);this._value="";this.inputRef=ni()}get value(){return this._value||null}set value(e){if(typeof e=="string"||e===null){this._value=e||"";let t=new FormData;t.append(this.responseIdentifier,this._value),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 h`
804
+ <input
805
+ part="input"
806
+ name="${this.responseIdentifier}"
807
+ spellcheck="false"
808
+ autocomplete="off"
809
+ @blur="${e=>{this.reportValidity()}}"
810
+ @keydown="${e=>e.stopImmediatePropagation()}"
811
+ @keyup="${this.textChanged}"
812
+ @change="${this.textChanged}"
813
+ type="${this.patternMask=="[0-9]*"?"number":"text"}"
814
+ placeholder="${Q(this.placeholderText?this.placeholderText:void 0)}"
815
+ .value="${this._value}"
816
+ pattern="${Q(this.patternMask?this.patternMask:void 0)}"
817
+ maxlength=${1e3}
818
+ ?disabled="${this.disabled}"
819
+ ?readonly="${this.readonly}"
820
+ />
821
+ <div part="correct">${this._correctResponse}</div>
822
+ `}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")}};I.styles=ai,n([u({type:Number,attribute:"expected-length"})],I.prototype,"expectedLength",2),n([u({type:String,attribute:"pattern-mask"})],I.prototype,"patternMask",2),n([u({type:String,attribute:"placeholder-text"})],I.prototype,"placeholderText",2),n([u({type:String,attribute:"data-patternmask-message"})],I.prototype,"dataPatternmaskMessage",2),n([x()],I.prototype,"_value",2),I=n([m("qti-text-entry-interaction")],I);var Ie=class extends E{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{...E.properties}}render(){return h`
823
+ <div>
824
+ <slot name="prompt"></slot>
825
+ <input type="file" @change="${this._onFileChange}" ?disabled="${this.disabled}" ?readonly="${this.readonly}" />
826
+ </div>
827
+ `}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,i)=>{let r=new FileReader;r.onload=()=>t(r.result),r.onerror=()=>i(r.error),r.readAsDataURL(e)})}};Ie.styles=[b`
828
+ :host {
829
+ display: block;
830
+ margin: 1em 0;
831
+ }
832
+ input[type='file'] {
833
+ display: block;
834
+ margin-top: 0.5em;
835
+ }
836
+ `],Ie=n([m("qti-upload-interaction")],Ie);var li=b`
837
+ :host {
838
+ display: block;
839
+ }
840
+ `;var Pe=class extends v{render(){return h`<slot name="qti-rubric-block"></slot><slot></slot>`}};Pe.styles=li,Pe=n([m("qti-item-body")],Pe);var Fe=class extends v{render(){return h`<slot></slot>`}process(){let s=new ft,e=[...this.children];s.process(e)}};Fe.styles=[b`
841
+ :host {
842
+ display: none;
843
+ }
844
+ `],Fe=n([m("qti-outcome-processing")],Fe);var ft=class{process(s){for(let e of s)e.process()}};var Qe=class extends v{render(){return h`<slot></slot>`}connectedCallback(){this.parentElement.tagName.endsWith("INTERACTION")&&this.setAttribute("slot","prompt")}};Qe=n([m("qti-prompt")],Qe);var ci=`<qti-response-processing>
845
+ <qti-response-condition>
846
+ <qti-response-if>
847
+ <qti-match>
848
+ <qti-variable identifier="RESPONSE"></qti-variable>
849
+ <qti-correct identifier="RESPONSE"></qti-correct>
850
+ </qti-match>
851
+ <qti-set-outcome-value identifier="SCORE">
852
+ <qti-base-value base-type="float">1</qti-base-value>
853
+ </qti-set-outcome-value>
854
+ </qti-response-if>
855
+ <qti-response-else>
856
+ <qti-set-outcome-value identifier="SCORE">
857
+ <qti-base-value base-type="float">0</qti-base-value>
858
+ </qti-set-outcome-value>
859
+ </qti-response-else>
860
+ </qti-response-condition>
861
+ </qti-response-processing>`,pi=`<qti-response-processing>
862
+ <qti-response-condition>
863
+ <qti-response-if>
864
+ <qti-is-null>
865
+ <qti-variable identifier="RESPONSE"></qti-variable>
866
+ </qti-is-null>
867
+ <qti-set-outcome-value identifier="SCORE">
868
+ <qti-base-value base-type="float">0.0</qti-base-value>
869
+ </qti-set-outcome-value>
870
+ </qti-response-if>
871
+ <qti-response-else>
872
+ <qti-set-outcome-value identifier="SCORE">
873
+ <qti-map-response identifier="RESPONSE"> </qti-map-response>
874
+ </qti-set-outcome-value>
875
+ </qti-response-else>
876
+ </qti-response-condition>
877
+ </qti-response-processing>`,di=`<qti-response-processing>
878
+ <qti-response-condition>
879
+ <qti-response-if>
880
+ <qti-is-null>
881
+ <qti-variable identifier="RESPONSE"></qti-variable>
882
+ </qti-is-null>
883
+ <qti-set-outcome-value identifier="SCORE">
884
+ <qti-base-value base-type="float">0</qti-base-value>
885
+ </qti-set-outcome-value>
886
+ </qti-response-if>
887
+ <qti-response-else>
888
+ <qti-set-outcome-value identifier="SCORE">
889
+ <qti-map-response-point identifier="RESPONSE"></qti-map-response-point>
890
+ </qti-set-outcome-value>
891
+ </qti-response-else>
892
+ </qti-response-condition>
893
+ </qti-response-processing>`;var ze=class extends v{render(){return h`<slot></slot>`}process(){if(!this.closest("qti-assessment-item"))return;let e=[...this.children];for(let t of e)t.process()}firstUpdated(s){if(this.getAttribute("template")){let e=this.getAttribute("template").split("/"),t=e[e.length-1].replace(".xml","");switch(this.innerHTML="",t){case"map_response":{this.appendChild(this.fragmentFromString(pi).firstElementChild.firstElementChild);break}case"map_response_point":{this.appendChild(this.fragmentFromString(di).firstElementChild.firstElementChild);break}case"match_correct":this.appendChild(this.fragmentFromString(ci).firstElementChild.firstElementChild);break}}}fragmentFromString(s){return document.createRange().createContextualFragment(s)}};ze.styles=[b`
894
+ :host {
895
+ display: none;
896
+ }
897
+ `],ze=n([m("qti-response-processing")],ze);var P=class extends v{render(){return h`<slot></slot>`}process(){throw new Error("Not implemented")}};P=n([m("qti-rule")],P);var et=class extends P{get childExpression(){return this.firstElementChild}process(){let s=this.getAttribute("identifier"),e=this.closest("qti-assessment-item").getVariable(s),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:qe(t)}})),t)}};n([u({type:String})],et.prototype,"identifier",2);customElements.define("qti-lookup-outcome-value",et);var gt=class extends P{render(){return h`<slot></slot>`}process(){let s=[...this.children];for(let e=0;e<s.length;e++){let t=s[e];if(t.calculate()){t.process();return}}}};customElements.define("qti-response-condition",gt);var bt=class extends P{process(){let s=this.getAttribute("identifier"),e=this.firstElementChild,i=new vt(e).process();this.dispatchEvent(new CustomEvent("qti-set-outcome-value",{bubbles:!0,composed:!0,detail:{outcomeIdentifier:s,value:Array.isArray(i)?i.map(r=>qe(r)):qe(i)}}))}},vt=class{constructor(s){this.expression=s}process(){let s=this.expression?this.expression.calculate():null;if(s==null){console.warn("setOutcomeValue: value is null or undefined");return}return s}};customElements.define("qti-set-outcome-value",bt);var Be=class extends v{render(){return h`<slot></slot>`}calculate(){return!0}getSubRules(){return[...this.children]}process(){let s=this.getSubRules();for(let e=0;e<s.length;e++)s[e].process()}};customElements.define("qti-response-else",Be);var Ye=class extends Be{calculate(){return this.firstElementChild.calculate()}getSubRules(){let s=[];for(let e=1;e<this.children.length;e++)s.push(this.children[e]);return s}};customElements.define("qti-response-if",Ye);var yt=class extends Ye{render(){return h`${super.render()}`}};customElements.define("qti-response-else-if",yt);var ui=class extends fi($){calculate(){return this.calculateChildren(Array.from(this.children))}};function fi(p){return class extends p{calculateChildren(e){return e.map(i=>{let r=i;if(!r.calculate)return console.error("Element doesn't implement QtiConditionExpression"),null;let a=r.calculate(),o=!1;if(typeof a=="string")if(a==="true")o=!0;else if(a==="false")o=!1;else return console.error("unexpected val in qti-or, expected boolean"),null;else typeof a=="boolean"&&(o=a);return o}).every(i=>typeof i=="boolean"&&i)}}}var tt=class extends C{constructor(){super(...arguments);this.baseType="string"}getResult(){return this.textContent.trim()}};n([u({type:String,attribute:"base-type"})],tt.prototype,"baseType",2);customElements.define("qti-base-value",tt);var xt=class extends ${getResult(){let s=this.getVariables();if(this.children.length===2){let e=s[0],t=s[1];if(e.baseType==="directedPair"&&t.baseType==="directedPair"&&e.cardinality==="multiple"){let i=e.value,r=t.value;return i.filter(l=>r.includes(l)).length>0}else if(e.baseType==="directedPair"&&t.baseType==="directedPair"&&e.cardinality==="single"){let i=e.value;return t.value.includes(i)}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",xt);var Et=class extends C{get interpretation(){return this.getAttribute("interpretation")||""}getResult(){let s=this.getAttribute("identifier")||"",e=this.context.variables.find(t=>t.identifier===s)||null;return e.cardinality!=="single"?e.correctResponse.length>0?e.correctResponse[0]:"":e.correctResponse}};customElements.define("qti-correct",Et);var it=class extends C{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],i=e[1];if(this.roundingMode===null)return null;if(t.cardinality!=="single"||i.cardinality!=="single"||Array.isArray(t.value)||Array.isArray(i.value))return console.error("unexpected cardinality in qti equal"),!1;switch(e[0].baseType){case"integer":case"float":{let r=parseFloat(t.value),a=parseFloat(i.value);if(!isNaN(r)&&!isNaN(a))return this.roundingMode==="significantFigures"?r.toPrecision(this.figures)===a.toPrecision(this.figures):Math.round(r*Math.pow(10,this.figures))/Math.pow(10,this.figures)===Math.round(a*Math.pow(10,this.figures))/Math.pow(10,this.figures);console.error(`value cannot be casted to numeric value in equalRounded operator: ${r}, ${a}`);break}default:{console.error("values other than float and int cannot be used in equalRounded operator.");break}}return!1}return console.error("unexpected number of children in qti-equal-rounded"),null}};n([u({type:String})],it.prototype,"roundingMode",2);customElements.define("qti-equal-rounded",it);var _=class{static isPointInArea(s,e,t){if(t!=="point")return console.warn(`Base type ${t} is not supported for point area mapping.`),!1;let[i,r]=s.split(" ").map(Number),[a,...o]=e.split(","),l=o.map(Number);switch(a.toLowerCase()){case"circle":case"default":{let[c,d,f]=l;return l.length!==3?(console.warn(`Invalid circle definition: ${e}`),!1):Math.sqrt((i-c)**2+(r-d)**2)<=f}case"rect":{let[c,d,f,g]=l;return l.length!==4?(console.warn(`Invalid rectangle definition: ${e}`),!1):i>=c&&i<=f&&r>=d&&r<=g}case"ellipse":{let[c,d,f,g]=l;if(l.length!==4)return console.warn(`Invalid ellipse definition: ${e}`),!1;let y=(i-c)**2/f**2,q=(r-d)**2/g**2;return y+q<=1}case"poly":{if(l.length<6||l.length%2!==0)return console.warn(`Invalid polygon definition: ${e}`),!1;let c=[];for(let d=0;d<l.length;d+=2)c.push({x:l[d],y:l[d+1]});return this.isPointInPolygon({x:i,y:r},c)}default:return console.warn(`Unsupported shape type: ${a}`),!1}}static isPointInPolygon(s,e){let t=!1;for(let i=0,r=e.length-1;i<e.length;r=i++){let a=e[i].x,o=e[i].y,l=e[r].x,c=e[r].y;o>s.y!=c>s.y&&s.x<(l-a)*(s.y-o)/(c-o)+a&&(t=!t)}return t}static compareSingleValues(s,e,t){switch(t){case"identifier":case"string":return s===e;case"integer":{let i=parseInt(s,10),r=parseInt(e,10);if(!isNaN(i)&&!isNaN(r))return i===r;console.error(`Cannot convert ${s} and/or ${e} to int.`);break}case"float":{let i=parseFloat(s),r=parseFloat(e);if(!isNaN(i)&&!isNaN(r))return i===r;console.error(`couldn't convert ${s} and/or ${e} to float.`);break}case"pair":case"directedPair":{let i=s.split(" ").sort(),r=e.split(" ").sort();if(i.length===2&&r.length===2)return t==="pair"&&(i.sort(),r.sort()),i.join(" ")===r.join(" ");console.error(`compared two pair but one of the values does not have 2 values: 1: ${s} 2: ${e}`);break}}return!1}};var rt=class extends C{constructor(){super(...arguments);this.toleranceMode="exact"}getResult(){if(this.children.length===2){let e=this.getVariables(),t=e[0],i=e[1];return this.toleranceMode!=="exact"?(console.error("toleranceMode is not supported yet"),!1):t.cardinality!=="single"||i.cardinality!=="single"||Array.isArray(t.value)||Array.isArray(i.value)?(console.error("unexpected cardinality in qti equal"),!1):_.compareSingleValues(t.value,i.value,t.baseType)}return console.error("unexpected number of children in qti-equal"),null}};n([u({type:String})],rt.prototype,"toleranceMode",2);customElements.define("qti-equal",rt);var Ct=class extends C{getResult(){if(this.children.length===2){let s=this.getVariables(),e=s[0],t=s[1];if((e.baseType==="integer"||e.baseType==="float")&&(t.baseType==="integer"||t.baseType==="float"))return+e.value>+t.value;console.error("unexpected baseType or cardinality in qti gt")}return console.error("unexpected number of children in qt"),null}};customElements.define("qti-gt",Ct);var qt=class extends ${getResult(){if(this.children.length===2){let s=this.getVariables(),e=s[0],t=s[1];return(e.baseType==="integer"||e.baseType==="float")&&(t.baseType==="integer"||t.baseType==="float")?+e.value>=+t.value:(console.error("unexpected baseType or cardinality in qti gte"),null)}return console.log("unexpected number of children in qte"),null}};customElements.define("qti-gte",qt);var Tt=class extends C{getResult(){if(this.children.length===1){let s=this.getVariables();if(!s)return!0;let e=s[0].value;return e==null||e==null||e===""}return console.error("unexpected number of children in qti Null"),null}};customElements.define("qti-is-null",Tt);var wt=class extends C{getResult(){if(this.children.length===2){let s=this.getVariables(),e=s[0],t=s[1];if((e.baseType==="integer"||e.baseType==="float")&&(t.baseType==="integer"||t.baseType==="float"))return+e.value<+t.value;console.error("unexpected baseType or cardinality in qti lt")}return console.error("unexpected number of children in lt"),null}};customElements.define("qti-lt",wt);var Mt=class extends ${getResult(){if(this.children.length===2){let s=this.getVariables(),e=s[0],t=s[1];return(e.baseType==="integer"||e.baseType==="float")&&(t.baseType==="integer"||t.baseType==="float")?+e.value<=+t.value:(console.error("unexpected baseType or cardinality in qti lte"),null)}return console.log("unexpected number of children in lte"),null}};customElements.define("qti-lte",Mt);var st=class extends C{getResult(){let s=this.context.variables.find(r=>r.identifier===this.identifier);if(!s||!s.mapping)return console.error(`Response ${this.identifier} can not be found`),null;let e=s.mapping,t=Array.isArray(s.value)?s.value:[s.value],i=0;for(let r of t){let o=e.mapEntries.filter(l=>s.baseType==="string"&&!l.caseSensitive?_.compareSingleValues(l.mapKey.toLowerCase(),r.toLowerCase(),s.baseType):_.compareSingleValues(l.mapKey,r,s.baseType)).reduce((l,c)=>l.mappedValue>c.mappedValue?l:c,{mapKey:null,mappedValue:null});o==null||o.mappedValue==null?i+=e.defaultValue:i+=o.mappedValue}return e.lowerBound!=null&&(i=Math.max(e.lowerBound,i)),e.upperBound!=null&&(i=Math.min(e.upperBound,i)),i}};n([u({type:String})],st.prototype,"identifier",2);customElements.define("qti-map-response",st);var ne=class extends v{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(r=>r.identifier===t)||null}case"qti-multiple":{let i=e.getResult();return i.length>0?{identifier:"",baseType:i[0].baseType,value:i.map(r=>r.value),cardinality:"multiple",type:"response"}:null}case"qti-correct":{let t=e.getAttribute("identifier")||"",i=this.context.variables.find(r=>r.identifier===t)||null;return{baseType:i.baseType,value:i.correctResponse,cardinality:i.cardinality}}default:{try{return{baseType:"integer",value:e.getResult().toString(),cardinality:"single"}}catch{console.warn("default not sufficient")}return null}}}).filter(e=>e!==null)}render(){return h`<pre>${JSON.stringify(this.result,null,2)}</pre>
898
+ <slot></slot>`}calculate(){return this.result=this.getResult(),this.result}getResult(){throw new Error("Not implemented")}};ne.styles=b`
899
+ slot {
900
+ display: none;
901
+ }
902
+ `,n([x()],ne.prototype,"result",2),n([S({context:M,subscribe:!0}),x()],ne.prototype,"context",2);var ot=class extends ne{getResult(){let s=this.context.variables.find(a=>a.identifier===this.identifier);if(!s)return console.warn(`Response ${this.identifier} cannot be found`),null;let e=s.areaMapping;if(!e)return console.warn(`Area mapping not found for response ${this.identifier}`),null;let t=Array.isArray(s.value)?s.value:[s.value];if(!t||t.length===0)return console.warn(`No candidate responses for response ${this.identifier}`),null;let i=0,r=new Set;for(let a of t)for(let o of e.mapEntries){if(r.has(o.coords))continue;_.isPointInArea(a,`${o.shape},${o.coords}`,s.baseType)&&(i+=o.mappedValue??0,r.add(o.coords))}return r.size<t.length&&(i+=e.defaultValue),e.lowerBound!=null&&(i=Math.max(e.lowerBound,i)),e.upperBound!=null&&(i=Math.min(e.upperBound,i)),i}};n([u({type:String})],ot.prototype,"identifier",2);customElements.define("qti-map-response-point",ot);var xe=class extends v{constructor(){super(...arguments);this.defaultValue=0}get mapEntries(){return Array.from(this.querySelectorAll("qti-map-entry")).map(e=>{let t=e.hasAttribute("case-sensitive")?e.getAttribute("case-sensitive")!=="false":!0;return{mapKey:e.getAttribute("map-key"),mappedValue:+e.getAttribute("mapped-value"),caseSensitive:t}})}};n([u({attribute:"default-value",type:Number})],xe.prototype,"defaultValue",2),n([u({attribute:"lower-bound",type:Number})],xe.prototype,"lowerBound",2),n([u({attribute:"upper-bound",type:Number})],xe.prototype,"upperBound",2);customElements.define("qti-mapping",xe);var Ee=class extends v{constructor(){super(...arguments);this.defaultValue=0}get mapEntries(){return Array.from(this.querySelectorAll("qti-area-map-entry")).map(e=>({shape:e.getAttribute("shape"),coords:e.getAttribute("coords"),mappedValue:+e.getAttribute("mapped-value"),defaultValue:e.getAttribute("default-value")?+e.getAttribute("default-value"):0}))}};n([u({attribute:"default-value",type:Number})],Ee.prototype,"defaultValue",2),n([u({attribute:"lower-bound",type:Number})],Ee.prototype,"lowerBound",2),n([u({attribute:"upper-bound",type:Number})],Ee.prototype,"upperBound",2);customElements.define("qti-area-mapping",Ee);var _t=class p extends C{getResult(){if(this.children.length===2){let s=this.getVariables(),e=s[0],t=s[1];return p.match(e,t)}return console.error("unexpected number of children in match"),null}static match(s,e){switch(e.cardinality){case"single":return s.value===null?!1:Array.isArray(s.value)||Array.isArray(e.value)?(console.error("unexpected cardinality in qti match"),!1):_.compareSingleValues(s.value?.toString(),e.value.toString(),e.baseType);case"ordered":{if(!Array.isArray(s.value)||!Array.isArray(e.value))return console.error("unexpected cardinality in qti match"),!1;if(s.value.length!==e.value.length)return!1;for(let t=0;t<s.value.length;t++)if(!_.compareSingleValues(e.value[t],s.value[t],e.baseType))return!1;return!0}case"multiple":{if(!Array.isArray(s.value)||!Array.isArray(e.value))return console.error("unexpected cardinality in qti match"),!1;if(s.value.length!==e.value.length)return!1;let t=0;for(let i of e.value){let r=null,a=[...s.value];for(let o of a)if(_.compareSingleValues(i,o,e.baseType)){r=o;break}if(r!==null)a.splice(a.indexOf(r),1);else return!1;t++}return!0}default:return console.error("unexpected cardinality in qti match"),!1}}};customElements.define("qti-match",_t);var St=class extends C{getResult(){let s=this.getVariables();this.children.length!==2&&console.warn("The member operator takes two sub-expressions");let[e,t]=s;if(e.baseType===t.baseType||e.baseType==="integer"&&t.baseType==="float"||e.baseType==="float"&&t.baseType==="integer"||console.warn("Which must both have the same base-type"),t.cardinality==="multiple"||t.cardinality==="ordered"||console.warn("and the second must be a multiple or ordered container"),(e.baseType==="float"||t.baseType==="float")&&console.warn("The member operator should not be used on sub-expressions with a base-type of float"),(e.baseType==="duration"||t.baseType==="duration")&&console.warn("It must not be used on sub-expressions with a base-type of duration"),e.value===null||t.value===null)return null;let i=e.value;return t.value.includes(i)}};customElements.define("qti-member",St);var Rt=class extends C{getResult(){let s=this.getVariables();if(s.length===0)return console.error("unexpected number of children in qti multiple"),null;for(let e of s)if(e.cardinality!=="multiple"&&e.cardinality!=="single")return console.error("unexpected cardinality in qti multiple"),[];return s}};customElements.define("qti-multiple",Rt);var kt=class extends C{render(){return h`${super.render()}`}getResult(){return!this.firstElementChild.calculate()}};customElements.define("qti-not",kt);var Lt=class extends ${getResult(){return Array.from(this.children).map(e=>{let t=e;if(!t.calculate)return console.error("Element doesn't implement QtiConditionExpression"),null;let i=t.calculate(),r=!1;if(typeof i=="string")if(i==="true")r=!0;else if(i==="false")r=!1;else return console.error("unexpected val in qti-or, expected boolean"),null;else typeof i=="boolean"&&(r=i);return r}).some(e=>typeof e=="boolean"&&e)}};customElements.define("qti-or",Lt);var At=class extends C{getResult(){let s=this.getVariables();if(s.length===0)return console.error("unexpected number of children in qti multiple"),null;for(let e of s)if(e.cardinality!=="ordered"&&e.cardinality!=="single")return console.error("unexpected cardinality in qti ordered"),[];return s}};customElements.define("qti-ordered",At);var Ue=class extends v{render(){let s=this.context?.variables.find(e=>e.identifier===this.identifier)?.value;return h`${JSON.stringify(s,null,2)}`}calculate(){return this.context.variables.find(e=>e.identifier===this.identifier)||null}};n([u({type:String})],Ue.prototype,"identifier",2),n([S({context:M,subscribe:!0}),x()],Ue.prototype,"context",2);customElements.define("qti-printed-variable",Ue);var Dt=class extends C{getResult(){return this.getVariables().reduce((t,i)=>{if(i.baseType=="float"||i.baseType=="integer")try{return t*parseInt(i.value.toString())}catch{console.warn("can not convert to number")}else console.warn(`has another baseType ${i.baseType}`);return t},1)}};customElements.define("qti-product",Dt);var nt=class extends gi(C){getResult(){return this.calculateChildren(Array.from(this.children))}};function gi(p){return class extends p{calculateChildren(e){let t=e.map(i=>{if(!i.calculate)return console.error("Element doesn't implement QtiConditionExpression"),null;let r=i.calculate();return Number.isNaN(r)?(console.error("Unexpected value in qti-subtract, expected number"),null):Number(r)});return t.some(i=>i===null)?(console.error("One or more child expressions returned invalid values"),0):t[0]-t[1]}}}customElements.define("qti-subtract",nt);var at=class extends C{constructor(){super(...arguments);this.caseSensitive="true"}getResult(){if(this.children.length===2){let e=this.getVariables(),t=e[0],i=e[1];if(t.cardinality!=="single"||i.cardinality!=="single"||Array.isArray(t.value)||Array.isArray(i.value))return console.error("unexpected cardinality in qti string-match"),!1;let r=this.caseSensitive==="true"?t.value:t.value.toLowerCase(),a=this.caseSensitive==="true"?i.value:i.value.toLowerCase();return _.compareSingleValues(r,a,t.baseType)}return console.error("unexpected number of children in qti-string-match"),null}};n([u({type:String,attribute:"case-sensitive"})],at.prototype,"caseSensitive",2);customElements.define("qti-string-match",at);var Vt=class extends C{constructor(){super(),this._expression=new $t(Array.from(this.children))}getResult(){return this._expression.calculate()}},$t=class{constructor(s){this.expressions=s}calculate(){return this.expressions.map(e=>{if(!e.calculate)return console.error("Element doesn't implement QtiConditionExpression"),null;let t=e.calculate();return Number.isNaN(t)?(console.error("unexpected value in qti-sum, expected number"),null):Number(t)}).reduce((e,t)=>e+t,0)}};customElements.define("qti-sum",Vt);var Ht=class extends C{getResult(){let s=this.getAttribute("identifier");return this.context.variables.find(t=>t.identifier===s).value}};customElements.define("qti-variable",Ht);var lt=class extends v{render(){return h`<slot></slot>`}};lt=n([m("qti-content-body")],lt);var F=class extends v{handleclassNamesChange(){this.classNames.split(" ").forEach(e=>{switch(e){case"qti-rubric-discretionary-placement":this.setAttribute("slot","qti-rubric-block");break;case"qti-rubric-inline":this.setAttribute("slot","");break;default:break}})}render(){return h`<slot></slot>`}connectedCallback(){super.connectedCallback(),this.setAttribute("slot","qti-rubric-block")}};F.styles=b`
903
+ :host {
904
+ display: block;
905
+ }
906
+ `,n([u({type:String})],F.prototype,"id",2),n([u({type:String})],F.prototype,"use",2),n([u({type:String})],F.prototype,"view",2),n([u({type:String,attribute:"class"})],F.prototype,"classNames",2),n([k("classNames",{waitUntilFirstUpdate:!0})],F.prototype,"handleclassNamesChange",1),F=n([m("qti-rubric-block")],F);var ct=class extends v{constructor(){super(...arguments);this.styleElement=null}firstUpdated(e){super.firstUpdated(e);let t=this.getAttribute("href");if(t!==null&&fetch(t).then(i=>i.text()).then(i=>{let r=this.minifyCss(i);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.")}).catch(i=>{console.error("Failed to load stylesheet:",i)}),this.textContent!==null&&this.textContent.trim()!==""){let i=this.minifyCss(this.textContent);this.styleElement=document.createElement("style"),this.styleElement.media="screen",this.styleElement.textContent=`@scope {${i}}`,this.parentElement?this.parentElement.appendChild(this.styleElement):console.warn("No parent element to append the scoped stylesheet to.")}}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()}};ct=n([m("qti-stylesheet")],ct);var oe=class extends v{render(){return h`<slot></slot>`}defaultValues(s){let e=Array.from(this.querySelectorAll("qti-default-value > qti-value"));if(e.length===0)return null;let t=e.map(i=>i.innerHTML.trim());return t.length>1||s.cardinality==="multiple"||s.cardinality==="ordered"?t:t[0]}};oe=n([m("qti-variabledeclaration")],oe);var z=class extends oe{constructor(){super(...arguments);this.externalScored=null}render(){let e=this.itemContext?.variables.find(t=>t.identifier===this.identifier)?.value;return h`${JSON.stringify(e,null,2)}`}get interpolationTable(){let e=this.querySelector("qti-interpolation-table");if(e){let t=new Map;for(let i of e.querySelectorAll("qti-interpolation-table-entry")){!i.getAttribute("source-value")&&i.getAttribute("target-value")&&console.error("source-value or target-value is missing in qti-interpolation-table-entry");let r=parseInt(i.getAttribute("source-value")),a=parseInt(i.getAttribute("target-value"));(isNaN(r)||isNaN(a))&&console.error("source-value or target-value is not a number in qti-interpolation-table-entry"),t.set(r,a)}return t}return null}connectedCallback(){super.connectedCallback();let e={identifier:this.identifier,cardinality:this.cardinality,baseType:this.baseType,type:"outcome",value:null,interpolationTable:this.interpolationTable,externalScored:this.externalScored};e.value=this.defaultValues(e),(e.value===null||e.value==null)&&(e.baseType==="integer"||e.baseType==="float")&&(e.value="0"),this.dispatchEvent(new CustomEvent("qti-register-variable",{bubbles:!0,composed:!0,detail:{variable:e}}))}};z.styles=[b`
907
+ :host {
908
+ display: none;
909
+ }
910
+ `],n([u({type:String,attribute:"base-type"})],z.prototype,"baseType",2),n([u({type:String,attribute:"external-scored"})],z.prototype,"externalScored",2),n([u({type:String})],z.prototype,"identifier",2),n([u({type:String})],z.prototype,"cardinality",2),n([S({context:M,subscribe:!0}),x()],z.prototype,"itemContext",2),z=n([m("qti-outcome-declaration")],z);var W=class extends oe{render(){let s=this.itemContext?.variables.find(e=>e.identifier===this.identifier)?.value;return h`${JSON.stringify(s,null,2)}`}connectedCallback(){super.connectedCallback();let s={baseType:this.baseType,identifier:this.identifier,correctResponse:this.correctResponse,cardinality:this.cardinality||"single",mapping:this.mapping,areaMapping:this.areaMapping,value:null,type:"response",candidateResponse:null};s.value=this.defaultValues(s),this.dispatchEvent(new CustomEvent("qti-register-variable",{bubbles:!0,composed:!0,detail:{variable:s}}))}get correctResponse(){let s,e=this.querySelector("qti-correct-response");if(e){let t=e.querySelectorAll("qti-value");if(this.cardinality==="single"&&t.length>0)s=t[0].textContent.trim(),t[0].remove();else if(this.cardinality!=="single"){s=[];for(let i=0;i<t.length;i++)s.push(t[i].textContent.trim()),t[i].remove()}}return s}get mapping(){return this.querySelector("qti-mapping")}get areaMapping(){return this.querySelector("qti-area-mapping")}};W.styles=[b`
911
+ :host {
912
+ display: none;
913
+ }
914
+ `],n([u({type:String,attribute:"base-type"})],W.prototype,"baseType",2),n([u({type:String})],W.prototype,"identifier",2),n([u({type:String})],W.prototype,"cardinality",2),n([S({context:M,subscribe:!0}),x()],W.prototype,"itemContext",2),W=n([m("qti-response-declaration")],W);export{L as a,ue as b,Je as c,Ce as d,we as e,Me as f,_e as g,Se as h,he as i,me as j,B as k,G as l,D as m,fe as n,Re as o,ge as p,be as q,Y as r,Le as s,Ae as t,ve as u,De as v,Ze as w,Ve as x,ie as y,He as z,re as A,U as B,Ne as C,X as D,se as E,Ge as F,Oe as G,j as H,ye as I,O as J,I as K,Ie as L,Pe as M,Fe as N,ft as O,Qe as P,ze as Q,P as R,et as S,gt as T,bt as U,vt as V,Be as W,Ye as X,yt as Y,ui as Z,fi as _,tt as $,xt as aa,Et as ba,it as ca,rt as da,Ct as ea,qt as fa,Tt as ga,wt as ha,Mt as ia,st as ja,ot as ka,xe as la,Ee as ma,_t as na,St as oa,Rt as pa,kt as qa,Lt as ra,At as sa,Ue as ta,Dt as ua,nt as va,gi as wa,at as xa,Vt as ya,$t as za,Ht as Aa,lt as Ba,F as Ca,ct as Da,z as Ea,W as Fa};
915
+ /*! Bundled license information:
916
+
917
+ lit-html/node/directives/if-defined.js:
918
+ (**
919
+ * @license
920
+ * Copyright 2018 Google LLC
921
+ * SPDX-License-Identifier: BSD-3-Clause
922
+ *)
923
+
924
+ lit-html/node/directives/repeat.js:
925
+ (**
926
+ * @license
927
+ * Copyright 2017 Google LLC
928
+ * SPDX-License-Identifier: BSD-3-Clause
929
+ *)
930
+
931
+ lit-html/node/directives/unsafe-html.js:
932
+ (**
933
+ * @license
934
+ * Copyright 2017 Google LLC
935
+ * SPDX-License-Identifier: BSD-3-Clause
936
+ *)
937
+
938
+ lit-html/node/directives/style-map.js:
939
+ (**
940
+ * @license
941
+ * Copyright 2018 Google LLC
942
+ * SPDX-License-Identifier: BSD-3-Clause
943
+ *)
944
+
945
+ lit-html/node/directives/ref.js:
946
+ (**
947
+ * @license
948
+ * Copyright 2020 Google LLC
949
+ * SPDX-License-Identifier: BSD-3-Clause
950
+ *)
951
+ */