@citolab/qti-components 6.0.3 → 6.0.4-0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/dist/chunk-HOQW4KDA.cjs +1 -0
  2. package/dist/{chunk-MYPYIYN5.js → chunk-K2XJ4SA2.js} +740 -264
  3. package/dist/chunk-KHP4WL3V.cjs +1 -0
  4. package/dist/{themes/qti.css → chunk-KTKSC3PR.cjs} +756 -263
  5. package/dist/custom-elements.json +557 -1292
  6. package/dist/index.cjs +2955 -0
  7. package/dist/index.css +2194 -1
  8. package/dist/index.js +2366 -190
  9. package/dist/{qti-assessment-item-219cef9e.d.ts → qti-assessment-item-f1fcf393.d.ts} +20 -2
  10. package/dist/qti-components/index.cjs +472 -0
  11. package/dist/qti-components/index.d.ts +72 -156
  12. package/dist/qti-components/index.js +141 -76
  13. package/dist/qti-item/index.cjs +1 -0
  14. package/dist/qti-item/index.d.ts +1 -2
  15. package/dist/qti-item/index.js +1 -1
  16. package/dist/qti-item-react/index.cjs +1 -0
  17. package/dist/qti-item-react/index.d.ts +5 -3
  18. package/dist/qti-item-react/index.js +1 -1
  19. package/dist/{qti-rule-e2aee685.d.ts → qti-simple-choice-c13f4eef.d.ts} +34 -33
  20. package/dist/qti-transform/index.cjs +17 -0
  21. package/dist/qti-transform/index.d.ts +1 -2
  22. package/dist/qti-transform/index.js +2 -87
  23. package/package.json +11 -9
  24. package/dist/ExpressionResult-b1ac7b27.d.ts +0 -23
  25. package/dist/ExpressionResult-d0123389.d.ts +0 -19
  26. package/dist/chunk-7KH3TY23.js +0 -18
  27. package/dist/chunk-7LF4QM4D.js +0 -17
  28. package/dist/chunk-M3YT56HW.js +0 -1437
  29. package/dist/qti-assessment-item-d2af2995.d.ts +0 -102
  30. package/dist/qti-components.js +0 -13502
  31. package/dist/qti-item/index.css +0 -1
  32. package/dist/qti-item-react/index.css +0 -1
  33. package/dist/qti-rule-5fe4f91e.d.ts +0 -303
  34. package/dist/qti-test/index.d.ts +0 -61
  35. package/dist/qti-test/index.js +0 -14
  36. package/dist/vite.svg +0 -1
@@ -1,20 +1,20 @@
1
- import{a as g,b as ie}from"../chunk-DLLHO3W2.js";import{a as C,b as P,c as s}from"../chunk-NMCIOGD2.js";var at={};var lt={};var ct={};var pt={};var dt={};var ut={};var mt={};var ht={};var ft={};var gt={ON_OUTCOME_CHANGED:"qti-outcome-changed",ON_INTERACTION_CHANGED:"on-interaction-changed",ON_REGISTER_VARIABLE:"on-register-variable",ON_REGISTER_FEEDBACK:"on-register-feedback",ON_REGISTER_INTERACTION:"on-register-interaction",ON_REGISTER_CHOICE:"on-register-choice",ON_REGISTER_HOTSPOT:"on-register-hotspot",ON_LOOSE_CHOICE:"on-loose-choice",ON_INTERACTION_RESPONSE:"on-interaction-response",ON_DROPDOWN_SELECTED:"on-dropdown-selected",ON_CHOICE_ELEMENT_SELECTED:"choice-element-selected"};var $=class{constructor({mapping:i,correctResponse:e,cardinality:t,baseType:r,identifier:o}){this._basetype="string";this._mapping=i,this._correctResponse=e,this._cardinality=t,this._basetype=r,this._identifier=o}get mapping(){return this._mapping}get correctResponse(){return this._correctResponse}get cardinality(){return this._cardinality}get baseType(){return this._basetype}get identifier(){return this._identifier}get value(){return this._candidateResponse}set value(i){this._candidateResponse=i}};var I=class{constructor(){this.value=0}};import{customElement as Nt,property as se}from"lit/decorators.js";import{html as Ht,LitElement as Ot}from"lit";var q=class extends Ot{constructor(){super();this.variables=[];this.feedbackElements=[];this.interactionElements=[];this._handleDisabledChange=(e,t)=>{this.interactionElements.forEach(r=>r.disabled=t)};this._handleReadonlyChange=(e,t)=>this.interactionElements.forEach(r=>r.readonly=t);this.addEventListener("qti-register-variable",this._registerVariable),this.addEventListener("qti-register-feedback",this.registerFeedbackElement),this.addEventListener("qti-register-interaction",this.registerInteractionElement),this.addEventListener("qti-outcome-changed",this.outcomeChanged),this.addEventListener("qti-interaction-response",this.interactionResponse)}render(){return Ht`<slot></slot>`}disconnectedCallback(){this.removeEventListener("qti-register-variable",this._registerVariable),this.removeEventListener("qti-register-feedback",this.registerFeedbackElement),this.removeEventListener("qti-register-interaction",this.registerInteractionElement),this.removeEventListener("qti-outcome-changed",this.outcomeChanged),this.removeEventListener("qti-interaction-response",this.interactionResponse)}_registerVariable(e){this.variables.push(e.detail.variable)}showCorrectResponse(){let e=this.variables.filter(t=>"correctResponse"in t);this.responses=e.map(t=>({responseIdentifier:t.identifier,response:t.correctResponse}))}processResponse(){if(!this.validateResponses())return console.info("Item is not valid, call validateResponses first"),!1;let e=this.querySelector("qti-response-processing");return e?e.process?(e.process(),!0):(console.info("Client side response webcomponents not available"),!1):(console.info("Client side response processing template not available"),!1)}set responses(e){if(e)for(let t of e){let r=this.interactionElements.find(l=>l.getAttribute("response-identifier")===t.responseIdentifier),o=this.getResponse(t.responseIdentifier);o&&(o.value=t.response),r&&(r.response=t.response)}}resetInteractions(){this.interactionElements.forEach(e=>e.reset())}validateResponses(){let e=!0;return this.interactionElements.forEach(t=>{t.validate()||(e=!1)}),e}getVariableValue(e){let t=this.variables.find(r=>r.identifier===e);return t?t.value:(console.warn(`Variable with identifier ${e} was not found`),null)}getResponse(e){let t=this.variables.find(o=>o.identifier===e);return t instanceof $?t:null}getOutcome(e){let t=this.variables.find(r=>r.identifier===e);return t instanceof I?t:null}registerFeedbackElement(e){e.stopPropagation(),this.feedbackElements.push(e.detail)}registerInteractionElement(e){e.stopPropagation(),this.interactionElements.push(e.target)}interactionResponse(e){let t=e.detail,r=this.getResponse(t.responseIdentifier);r&&(r.value=t.response),e.stopImmediatePropagation();let o=this.getAttribute("identifier");o||console.warn("qti-assessment-item has no identifier specified"),this.dispatchEvent(new CustomEvent("qti-interaction-changed",{bubbles:!0,composed:!0,detail:{item:o,responseIdentifier:t.responseIdentifier,response:t.response}}))}outcomeChanged(e){this.feedbackElements.forEach(t=>{t.checkShowFeedback(e.detail.outcomeIdentifier,e.detail.value)})}setOutcomeValue(e,t){let r=this.getOutcome(e);if(!r){console.warn(`Can not set qti-outcome-identifier: ${e}, it is not available`);return}r.value=t,this.dispatchEvent(new CustomEvent("qti-outcome-changed",{bubbles:!0,composed:!0,detail:{item:this.identifier,outcomeIdentifier:e,value:t}}))}};s([se({type:Boolean})],q.prototype,"disabled",2),s([se({type:Boolean})],q.prototype,"readonly",2),s([se({type:String})],q.prototype,"title",2),s([se({type:String})],q.prototype,"identifier",2),s([g("disabled",{waitUntilFirstUpdate:!0})],q.prototype,"_handleDisabledChange",2),s([g("readonly",{waitUntilFirstUpdate:!0})],q.prototype,"_handleReadonlyChange",2),q=s([Nt("qti-assessment-item")],q);import{LitElement as Dt}from"lit";var Le=class extends Dt{constructor(){super()}connectedCallback(){super.connectedCallback();let e=this.closest("qti-assessment-item"),t=this.getAttribute("href"),r=document.createElement("link");r.rel="stylesheet",r.type="text/css",r.media="screen",r.href=t,e.appendChild(r),this.styleLink=r}disconnectedCallback(){let e=this.closest("qti-assessment-item");if(this.styleLink&&this.styleLink.parentElement===this)try{e.removeChild(this.styleLink)}catch(t){console.log("could not remove stylesheet")}}};customElements.define("qti-stylesheet",Le);import{customElement as Pt}from"lit/decorators.js";import{html as $t,LitElement as It}from"lit";import{css as Vt}from"lit";var bt=Vt`
1
+ import{a as g,b as nt}from"../chunk-DLLHO3W2.js";import{a as C,b as $,c as s}from"../chunk-NMCIOGD2.js";var at={};var lt={};var ct={};var pt={};var dt={};var ut={};var mt={};var ht={};var ft={};var gt={ON_OUTCOME_CHANGED:"qti-outcome-changed",ON_INTERACTION_CHANGED:"on-interaction-changed",ON_REGISTER_VARIABLE:"on-register-variable",ON_REGISTER_FEEDBACK:"on-register-feedback",ON_REGISTER_INTERACTION:"on-register-interaction",ON_REGISTER_CHOICE:"on-register-choice",ON_REGISTER_HOTSPOT:"on-register-hotspot",ON_LOOSE_CHOICE:"on-loose-choice",ON_INTERACTION_RESPONSE:"on-interaction-response",ON_DROPDOWN_SELECTED:"on-dropdown-selected",ON_CHOICE_ELEMENT_SELECTED:"choice-element-selected"};var I=class{constructor({mapping:i,correctResponse:e,cardinality:t,baseType:r,identifier:o}){this._basetype="string";this._mapping=i,this._correctResponse=e,this._cardinality=t,this._basetype=r,this._identifier=o}get mapping(){return this._mapping}get correctResponse(){return this._correctResponse}get cardinality(){return this._cardinality}get baseType(){return this._basetype}get identifier(){return this._identifier}get value(){return this._candidateResponse}set value(i){this._candidateResponse=i}};var F=class{constructor(){this.value=0}};import{customElement as Dt,property as se}from"lit/decorators.js";import{html as Vt,LitElement as Pt}from"lit";var q=class extends Pt{constructor(){super();this.variables=[];this.feedbackElements=[];this.interactionElements=[];this._handleDisabledChange=(e,t)=>{this.interactionElements.forEach(r=>r.disabled=t)};this._handleReadonlyChange=(e,t)=>this.interactionElements.forEach(r=>r.readonly=t);this.addEventListener("qti-register-variable",this._registerVariable),this.addEventListener("qti-register-feedback",this.registerFeedbackElement),this.addEventListener("qti-register-interaction",this.registerInteractionElement),this.addEventListener("qti-outcome-changed",this.outcomeChanged),this.addEventListener("qti-interaction-response",this.interactionResponse)}render(){return Vt`<slot></slot>`}connectedCallback(){super.connectedCallback(),this.dispatchEvent(new CustomEvent("qti-item-connected",{bubbles:!0,composed:!0,detail:{identifier:this.identifier}}))}disconnectedCallback(){this.removeEventListener("qti-register-variable",this._registerVariable),this.removeEventListener("qti-register-feedback",this.registerFeedbackElement),this.removeEventListener("qti-register-interaction",this.registerInteractionElement),this.removeEventListener("qti-outcome-changed",this.outcomeChanged),this.removeEventListener("qti-interaction-response",this.interactionResponse)}_registerVariable(e){this.variables.push(e.detail.variable)}showCorrectResponse(){let e=this.variables.filter(t=>"correctResponse"in t);this.responses=e.map(t=>({responseIdentifier:t.identifier,response:t.correctResponse}))}processResponse(){if(!this.validateResponses())return console.info("Item is not valid, call validateResponses first"),!1;let e=this.querySelector("qti-response-processing");return e?e.process?(e.process(),!0):(console.info("Client side response webcomponents not available"),!1):(console.info("Client side response processing template not available"),!1)}set responses(e){if(e)for(let t of e){let r=this.interactionElements.find(n=>n.getAttribute("response-identifier")===t.responseIdentifier),o=this.getResponse(t.responseIdentifier);o&&(o.value=t.response),r&&(r.response=t.response)}}resetInteractions(){this.interactionElements.forEach(e=>e.reset())}validateResponses(){let e=!0;return this.interactionElements.forEach(t=>{t.validate()||(e=!1)}),e}getVariableValue(e){let t=this.variables.find(r=>r.identifier===e);return t?t.value:(console.warn(`Variable with identifier ${e} was not found`),null)}getResponse(e){let t=this.variables.find(o=>o.identifier===e);return t instanceof I?t:null}getOutcome(e){let t=this.variables.find(r=>r.identifier===e);return t instanceof F?t:null}registerFeedbackElement(e){e.stopPropagation(),this.feedbackElements.push(e.detail)}registerInteractionElement(e){e.stopPropagation(),this.interactionElements.push(e.target)}interactionResponse(e){let t=e.detail,r=this.getResponse(t.responseIdentifier);r&&(r.value=t.response),e.stopImmediatePropagation();let o=this.getAttribute("identifier");o||console.warn("qti-assessment-item has no identifier specified"),this.dispatchEvent(new CustomEvent("qti-interaction-changed",{bubbles:!0,composed:!0,detail:{item:o,responseIdentifier:t.responseIdentifier,response:t.response}}))}outcomeChanged(e){this.feedbackElements.forEach(t=>{t.checkShowFeedback(e.detail.outcomeIdentifier,e.detail.value)})}setOutcomeValue(e,t){let r=this.getOutcome(e);if(!r){console.warn(`Can not set qti-outcome-identifier: ${e}, it is not available`);return}r.value=t,this.dispatchEvent(new CustomEvent("qti-outcome-changed",{bubbles:!0,composed:!0,detail:{item:this.identifier,outcomeIdentifier:e,value:t}}))}};s([se({type:Boolean})],q.prototype,"disabled",2),s([se({type:Boolean})],q.prototype,"readonly",2),s([se({type:String})],q.prototype,"title",2),s([se({type:String})],q.prototype,"identifier",2),s([g("disabled",{waitUntilFirstUpdate:!0})],q.prototype,"_handleDisabledChange",2),s([g("readonly",{waitUntilFirstUpdate:!0})],q.prototype,"_handleReadonlyChange",2),q=s([Dt("qti-assessment-item")],q);import{LitElement as $t}from"lit";var Te=class extends $t{constructor(){super()}connectedCallback(){super.connectedCallback();let e=this.closest("qti-assessment-item"),t=this.getAttribute("href"),r=document.createElement("link");r.rel="stylesheet",r.type="text/css",r.media="screen",r.href=t,e.appendChild(r),this.styleLink=r}disconnectedCallback(){let e=this.closest("qti-assessment-item");if(this.styleLink&&this.styleLink.parentElement===this)try{e.removeChild(this.styleLink)}catch(t){console.log("could not remove stylesheet")}}};customElements.define("qti-stylesheet",Te);import{customElement as Ft}from"lit/decorators.js";import{html as Ut,LitElement as Xt}from"lit";import{css as It}from"lit";var bt=It`
2
2
  :host {
3
3
  display: block;
4
4
  }
5
- `;var F=class extends It{render(){return $t` <slot name="qti-rubric-block"></slot>
6
- <slot></slot>`}};F.styles=bt,F=s([Pt("qti-item-body")],F);import{html as Ft,LitElement as Ut}from"lit";var Se=class extends Ut{render(){return Ft` <slot></slot> `}connectedCallback(){this.parentElement.tagName.endsWith("INTERACTION")&&this.setAttribute("slot","prompt")}};customElements.define("qti-prompt",Se);import{html as Bt}from"lit/static-html.js";import{property as W}from"lit/decorators.js";import{LitElement as Xt}from"lit";var Yt={SPACE:32},y=class extends Xt{constructor(){super(...arguments);this.tabindex=0;this.disabled=!1;this.readonly=!1;this.checked=!1}handleDisabledChange(e,t){t?(this.tabindex=void 0,this.blur()):this.tabIndex=0}connectedCallback(){super.connectedCallback(),this.addEventListener("keyup",this._onKeyUp),this.addEventListener("click",this._onClick),this.dispatchEvent(new CustomEvent("qti-register-choice",{bubbles:!0,cancelable:!1,composed:!0}))}disconnectedCallback(){this.removeEventListener("keyup",this._onKeyUp),this.removeEventListener("click",this._onClick),this.dispatchEvent(new CustomEvent("qti-loose-choice",{bubbles:!0,cancelable:!1,composed:!0}))}reset(){this.checked=!1,this.disabled=!1}_onKeyUp(e){if(!e.altKey)switch(e.keyCode){case Yt.SPACE:e.preventDefault(),this._toggleChecked();break;default:}}_onClick(){this._toggleChecked()}_toggleChecked(){this.disabled||this.readonly||(this.checked=!this.checked,this.dispatchEvent(new CustomEvent("qti-choice-element-selected",{bubbles:!0,cancelable:!1,composed:!0,detail:{identifier:this.identifier,checked:this.checked}})))}validateAllProps(){return!!this.getAttribute("identifier")}render(){return this.validateAllProps()||console.warn(`Invalid props for ${this.outerHTML}`,"missing identifier"),Bt` <slot></slot> `}};s([W({type:String})],y.prototype,"identifier",2),s([W({type:Number,reflect:!0})],y.prototype,"tabindex",2),s([W({reflect:!0,type:Boolean,attribute:"aria-disabled",converter:{toAttribute:a=>a}})],y.prototype,"disabled",2),s([W({reflect:!0,type:Boolean,attribute:"aria-readonly",converter:{toAttribute:a=>a}})],y.prototype,"readonly",2),s([W({reflect:!0,type:Boolean,attribute:"aria-checked",converter:{toAttribute:a=>a}})],y.prototype,"checked",2),s([g("disabled",{waitUntilFirstUpdate:!0})],y.prototype,"handleDisabledChange",1);import{html as Kt,LitElement as zt}from"lit";var O=class extends zt{render(){return Kt``}};customElements.define("qti-variabledeclaration",O);import{property as Me}from"lit/decorators.js";var U=class extends O{connectedCallback(){super.connectedCallback();let e=new $({baseType:this.baseType,identifier:this.identifier,correctResponse:this.correctResponse,cardinality:this.cardinality||"single",mapping:this.mapping});this.dispatchEvent(new CustomEvent("qti-register-variable",{bubbles:!0,composed:!0,detail:{variable:e}}))}get correctResponse(){let e,t=this.querySelector("qti-correct-response");if(t){let r=t.querySelectorAll("qti-value");if(this.cardinality==="single"&&r.length>0)e=r[0].textContent,r[0].remove();else if(this.cardinality!=="single"){e=[];for(let o=0;o<r.length;o++)e.push(r[o].textContent),r[o].remove()}}return e}get mapping(){return this.querySelector("qti-mapping")}};s([Me({type:String,attribute:"base-type"})],U.prototype,"baseType",2),s([Me({type:String,attribute:"identifier"})],U.prototype,"identifier",2),s([Me({type:String,attribute:"cardinality"})],U.prototype,"cardinality",2);customElements.define("qti-response-declaration",U);var Ne=class extends O{static get observedAttributes(){return["identifier","cardinality","base-type"]}get interpolationTable(){let i=this.querySelector("qti-interpolation-table");if(i){let e=new Map;for(let t of i.querySelectorAll("qti-interpolation-table-entry")){!t.getAttribute("source-value")&&t.getAttribute("target-value")&&console.error("source-value or target-value is missing in qti-interpolation-table-entry");let r=parseInt(t.getAttribute("source-value")),o=parseInt(t.getAttribute("target-value"));(isNaN(r)||isNaN(o))&&console.error("source-value or target-value is not a number in qti-interpolation-table-entry"),e.set(r,o)}}return null}connectedCallback(){super.connectedCallback();let i=this.getAttribute("identifier"),e=new I;e.identifier=i,this.dispatchEvent(new CustomEvent("qti-register-variable",{bubbles:!0,composed:!0,detail:{variable:e}}))}};customElements.define("qti-outcome-declaration",Ne);import{LitElement as jt}from"lit";import{customElement as Gt}from"lit/decorators.js";var oe=class extends jt{};oe=s([Gt("qti-companion-materials-info")],oe);import{LitElement as Wt,css as Jt,html as Zt}from"lit";import{customElement as Qt,property as ne}from"lit/decorators.js";import{ContextConsumer as er}from"@lit-labs/context";var _=class extends Wt{constructor(){super(...arguments);this.logger=new er(this,ie,e=>this.style.display=this.view===e.view?"block":"none",!0)}handleclassNamesChange(e,t){this.classNames.split(" ").forEach(o=>{switch(o){case"qti-rubric-discretionary-placement":this.setAttribute("slot","qti-rubric-block");break;case"qti-rubric-inline":this.setAttribute("slot","");break;default:break}})}render(){return Zt`<slot></slot>`}connectedCallback(){super.connectedCallback(),this.setAttribute("slot","qti-rubric-block")}};_.styles=Jt`
5
+ `;var U=class extends Xt{render(){return Ut` <slot name="qti-rubric-block"></slot>
6
+ <slot></slot>`}};U.styles=bt,U=s([Ft("qti-item-body")],U);import{html as Yt,LitElement as Bt}from"lit";var Se=class extends Bt{render(){return Yt` <slot></slot> `}connectedCallback(){this.parentElement.tagName.endsWith("INTERACTION")&&this.setAttribute("slot","prompt")}};customElements.define("qti-prompt",Se);import{html as Kt}from"lit/static-html.js";import{property as J}from"lit/decorators.js";import{LitElement as jt}from"lit";var zt={SPACE:32},y=class extends jt{constructor(){super(...arguments);this.tabindex=0;this.disabled=!1;this.readonly=!1;this.checked=!1}handleDisabledChange(e,t){t?(this.tabindex=void 0,this.blur()):this.tabIndex=0}connectedCallback(){super.connectedCallback(),this.addEventListener("keyup",this._onKeyUp),this.addEventListener("click",this._onClick),this.dispatchEvent(new CustomEvent("qti-register-choice",{bubbles:!0,cancelable:!1,composed:!0}))}disconnectedCallback(){this.removeEventListener("keyup",this._onKeyUp),this.removeEventListener("click",this._onClick),this.dispatchEvent(new CustomEvent("qti-loose-choice",{bubbles:!0,cancelable:!1,composed:!0}))}reset(){this.checked=!1,this.disabled=!1}_onKeyUp(e){if(!e.altKey)switch(e.keyCode){case zt.SPACE:e.preventDefault(),this._toggleChecked();break;default:}}_onClick(){this._toggleChecked()}_toggleChecked(){this.disabled||this.readonly||(this.checked=!this.checked,this.dispatchEvent(new CustomEvent("qti-choice-element-selected",{bubbles:!0,cancelable:!1,composed:!0,detail:{identifier:this.identifier,checked:this.checked}})))}validateAllProps(){return!!this.getAttribute("identifier")}render(){return this.validateAllProps()||console.warn(`Invalid props for ${this.outerHTML}`,"missing identifier"),Kt` <slot></slot> `}};s([J({type:String})],y.prototype,"identifier",2),s([J({type:Number,reflect:!0})],y.prototype,"tabindex",2),s([J({reflect:!0,type:Boolean,attribute:"aria-disabled",converter:{toAttribute:a=>a}})],y.prototype,"disabled",2),s([J({reflect:!0,type:Boolean,attribute:"aria-readonly",converter:{toAttribute:a=>a}})],y.prototype,"readonly",2),s([J({reflect:!0,type:Boolean,attribute:"aria-checked",converter:{toAttribute:a=>a}})],y.prototype,"checked",2),s([g("disabled",{waitUntilFirstUpdate:!0})],y.prototype,"handleDisabledChange",1);import{html as Gt,LitElement as Wt}from"lit";var O=class extends Wt{render(){return Gt``}};customElements.define("qti-variabledeclaration",O);import{property as Me}from"lit/decorators.js";var X=class extends O{connectedCallback(){super.connectedCallback();let e=new I({baseType:this.baseType,identifier:this.identifier,correctResponse:this.correctResponse,cardinality:this.cardinality||"single",mapping:this.mapping});this.dispatchEvent(new CustomEvent("qti-register-variable",{bubbles:!0,composed:!0,detail:{variable:e}}))}get correctResponse(){let e,t=this.querySelector("qti-correct-response");if(t){let r=t.querySelectorAll("qti-value");if(this.cardinality==="single"&&r.length>0)e=r[0].textContent,r[0].remove();else if(this.cardinality!=="single"){e=[];for(let o=0;o<r.length;o++)e.push(r[o].textContent),r[o].remove()}}return e}get mapping(){return this.querySelector("qti-mapping")}};s([Me({type:String,attribute:"base-type"})],X.prototype,"baseType",2),s([Me({type:String,attribute:"identifier"})],X.prototype,"identifier",2),s([Me({type:String,attribute:"cardinality"})],X.prototype,"cardinality",2);customElements.define("qti-response-declaration",X);var Ne=class extends O{static get observedAttributes(){return["identifier","cardinality","base-type"]}get interpolationTable(){let i=this.querySelector("qti-interpolation-table");if(i){let e=new Map;for(let t of i.querySelectorAll("qti-interpolation-table-entry")){!t.getAttribute("source-value")&&t.getAttribute("target-value")&&console.error("source-value or target-value is missing in qti-interpolation-table-entry");let r=parseInt(t.getAttribute("source-value")),o=parseInt(t.getAttribute("target-value"));(isNaN(r)||isNaN(o))&&console.error("source-value or target-value is not a number in qti-interpolation-table-entry"),e.set(r,o)}}return null}connectedCallback(){super.connectedCallback();let i=this.getAttribute("identifier"),e=new F;e.identifier=i,this.dispatchEvent(new CustomEvent("qti-register-variable",{bubbles:!0,composed:!0,detail:{variable:e}}))}};customElements.define("qti-outcome-declaration",Ne);import{LitElement as Jt}from"lit";import{customElement as Zt}from"lit/decorators.js";var oe=class extends Jt{};oe=s([Zt("qti-companion-materials-info")],oe);import{LitElement as Qt,css as er,html as tr}from"lit";import{customElement as rr,property as ne}from"lit/decorators.js";import{ContextConsumer as ir}from"@lit-labs/context";var _=class extends Qt{constructor(){super(...arguments);this.logger=new ir(this,nt,e=>this.style.display=this.view===e.view?"block":"none",!0)}handleclassNamesChange(e,t){this.classNames.split(" ").forEach(o=>{switch(o){case"qti-rubric-discretionary-placement":this.setAttribute("slot","qti-rubric-block");break;case"qti-rubric-inline":this.setAttribute("slot","");break;default:break}})}render(){return tr`<slot></slot>`}connectedCallback(){super.connectedCallback(),this.setAttribute("slot","qti-rubric-block")}};_.styles=er`
7
7
  :host {
8
8
  display: block;
9
9
  }
10
- `,s([ne({type:String})],_.prototype,"id",2),s([ne({type:String})],_.prototype,"use",2),s([ne({type:String})],_.prototype,"view",2),s([ne({type:String,attribute:"class"})],_.prototype,"classNames",2),s([g("classNames",{waitUntilFirstUpdate:!0})],_.prototype,"handleclassNamesChange",1),_=s([Qt("qti-rubric-block")],_);import{LitElement as tr,html as rr}from"lit";import{customElement as ir}from"lit/decorators.js";var ae=class extends tr{render(){return rr`<slot></slot>`}};ae=s([ir("qti-content-body")],ae);import{css as or,html as nr}from"lit";import{LitElement as sr}from"lit";import{property as le}from"lit/decorators.js";var k=class extends sr{constructor(){super();this.showHide="show",this.showFeedback(this.showHide==="hide")}connectedCallback(){super.connectedCallback(),this.dispatchEvent(new CustomEvent("qti-register-feedback",{bubbles:!0,composed:!0,detail:this}))}checkShowFeedback(e,t){if(this.outcomeIdentifier!==e||!t)return;let r=Array.isArray(t)?t.includes(this.identifier):this.identifier===t.toString();this.showFeedback(r)}showFeedback(e){this.showStatus=e?"on":"off"}};s([le({type:String,attribute:"show-hide"})],k.prototype,"showHide",2),s([le({type:String,attribute:"outcome-identifier"})],k.prototype,"outcomeIdentifier",2),s([le({type:String})],k.prototype,"identifier",2),s([le({type:String,attribute:!1})],k.prototype,"showStatus",2);var ce=class extends k{constructor(){super(...arguments);this.render=()=>nr` <slot class="${this.showStatus}"></slot> `}};ce.styles=or`
10
+ `,s([ne({type:String})],_.prototype,"id",2),s([ne({type:String})],_.prototype,"use",2),s([ne({type:String})],_.prototype,"view",2),s([ne({type:String,attribute:"class"})],_.prototype,"classNames",2),s([g("classNames",{waitUntilFirstUpdate:!0})],_.prototype,"handleclassNamesChange",1),_=s([rr("qti-rubric-block")],_);import{LitElement as sr,html as or}from"lit";import{customElement as nr}from"lit/decorators.js";var ae=class extends sr{render(){return or`<slot></slot>`}};ae=s([nr("qti-content-body")],ae);import{css as lr,html as cr}from"lit";import{LitElement as ar}from"lit";import{property as le}from"lit/decorators.js";var k=class extends ar{constructor(){super();this.showHide="show",this.showFeedback(this.showHide==="hide")}connectedCallback(){super.connectedCallback(),this.dispatchEvent(new CustomEvent("qti-register-feedback",{bubbles:!0,composed:!0,detail:this}))}checkShowFeedback(e,t){if(this.outcomeIdentifier!==e||!t)return;let r=Array.isArray(t)?t.includes(this.identifier):this.identifier===t.toString();this.showFeedback(r)}showFeedback(e){this.showStatus=e?"on":"off"}};s([le({type:String,attribute:"show-hide"})],k.prototype,"showHide",2),s([le({type:String,attribute:"outcome-identifier"})],k.prototype,"outcomeIdentifier",2),s([le({type:String})],k.prototype,"identifier",2),s([le({type:String,attribute:!1})],k.prototype,"showStatus",2);var ce=class extends k{constructor(){super(...arguments);this.render=()=>cr` <slot class="${this.showStatus}"></slot> `}};ce.styles=lr`
11
11
  .on {
12
12
  display: inline-block;
13
13
  }
14
14
  .off {
15
15
  display: none;
16
16
  }
17
- `;customElements.define("qti-feedback-inline",ce);import{html as ar}from"lit";var He=class extends k{render(){return ar`
17
+ `;customElements.define("qti-feedback-inline",ce);import{html as pr}from"lit";var He=class extends k{render(){return pr`
18
18
  <style>
19
19
  .on {
20
20
  display: inline-block;
@@ -26,7 +26,7 @@ import{a as g,b as ie}from"../chunk-DLLHO3W2.js";import{a as C,b as P,c as s}fro
26
26
  <div class="feedback ${this.showStatus}">
27
27
  <slot></slot>
28
28
  </div>
29
- `}};customElements.define("qti-modal-feedback",He);import{css as pr,html as dr}from"lit";import{ifDefined as De}from"lit/directives/if-defined.js";import{property as Oe}from"lit/decorators.js";import{LitElement as lr}from"lit";var b=class extends lr{constructor(){super(...arguments);this.responseIdentifier="";this.disabled=!1;this.readonly=!1}connectedCallback(){super.connectedCallback(),this.dispatchEvent(new CustomEvent("qti-register-interaction",{bubbles:!0,cancelable:!1,composed:!0}))}saveResponse(e){this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,cancelable:!1,composed:!0,detail:{responseIdentifier:this.responseIdentifier,response:e}}))}};s([Oe({attribute:"response-identifier"})],b.prototype,"responseIdentifier",2),s([Oe({reflect:!0,type:Boolean})],b.prototype,"disabled",2),s([Oe({reflect:!0,type:Boolean})],b.prototype,"readonly",2);import{css as cr}from"lit";var B=cr`
29
+ `}};customElements.define("qti-modal-feedback",He);import{css as mr,html as hr}from"lit";import{ifDefined as De}from"lit/directives/if-defined.js";import{property as Oe}from"lit/decorators.js";import{LitElement as dr}from"lit";var f=class extends dr{constructor(){super(...arguments);this.responseIdentifier="";this.disabled=!1;this.readonly=!1}connectedCallback(){super.connectedCallback(),this.dispatchEvent(new CustomEvent("qti-register-interaction",{bubbles:!0,cancelable:!1,composed:!0}))}saveResponse(e){this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,cancelable:!1,composed:!0,detail:{responseIdentifier:this.responseIdentifier,response:e}}))}};s([Oe({attribute:"response-identifier"})],f.prototype,"responseIdentifier",2),s([Oe({reflect:!0,type:Boolean})],f.prototype,"disabled",2),s([Oe({reflect:!0,type:Boolean})],f.prototype,"readonly",2);import{css as ur}from"lit";var Y=ur`
30
30
  /***
31
31
  The new CSS reset - version 1.4.9 (last updated 11.2.2022)
32
32
  GitHub page: https://github.com/elad2412/the-new-css-reset
@@ -106,7 +106,7 @@ import{a as g,b as ie}from"../chunk-DLLHO3W2.js";import{a as C,b as P,c as s}fro
106
106
  :where([draggable='true']) {
107
107
  -webkit-user-drag: element;
108
108
  }
109
- `;import{customElement as ur,property as pe,state as mr}from"lit/decorators.js";var S=class extends b{constructor(){super(...arguments);this._value=""}set response(e){this._value=e!==void 0?e:""}validate(){return this._value!==""}static get styles(){return[B,pr`
109
+ `;import{customElement as fr,property as pe,state as gr}from"lit/decorators.js";var T=class extends f{constructor(){super(...arguments);this._value=""}set response(e){this._value=e!==void 0?e:""}validate(){return this._value!==""}static get styles(){return[Y,mr`
110
110
  /* PK: display host as block, else design will be collapsed */
111
111
  :host {
112
112
  display: inline-block;
@@ -114,7 +114,7 @@ import{a as g,b as ie}from"../chunk-DLLHO3W2.js";import{a as C,b as P,c as s}fro
114
114
  input {
115
115
  padding: var(--qti-padding, 0.5rem);
116
116
  }
117
- `]}render(){return dr` <input
117
+ `]}render(){return hr` <input
118
118
  part="input"
119
119
  spellcheck="false"
120
120
  autocomplete="off"
@@ -128,7 +128,7 @@ import{a as g,b as ie}from"../chunk-DLLHO3W2.js";import{a as C,b as P,c as s}fro
128
128
  pattern="${De(this.patternMask?this.patternMask:void 0)}"
129
129
  ?disabled="${this.disabled}"
130
130
  ?readonly="${this.readonly}"
131
- />`}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))}reset(){this._value=""}setEmptyAttribute(e){this.setAttribute("empty",e===""?"true":"false")}};s([pe({type:Number,attribute:"expected-length"})],S.prototype,"expectedLength",2),s([pe({type:String,attribute:"pattern-mask"})],S.prototype,"patternMask",2),s([pe({type:String,attribute:"placeholder-text"})],S.prototype,"placeholderText",2),s([mr()],S.prototype,"_value",2),s([pe({type:String,attribute:"class"})],S.prototype,"classNames",2),S=s([ur("qti-text-entry-interaction")],S);import{css as hr,html as fr}from"lit";import{ifDefined as Ve}from"lit/directives/if-defined.js";import{ref as gr,createRef as br}from"lit/directives/ref.js";import{customElement as vr,property as de,state as yr}from"lit/decorators.js";var w=class extends b{constructor(){super(...arguments);this.textareaRef=br();this._value=""}handleclassNamesChange(e,t){this.classNames.split(" ").forEach(o=>{if(o.startsWith("qti-height-lines")){let l=o.replace("qti-height-lines-","");this.textareaRef&&(this.textareaRef.value.rows=parseInt(l))}})}set response(e){this._value=e!==void 0?e:""}validate(){return this._value!==""}static get styles(){return[B,hr`
131
+ />`}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))}reset(){this._value=""}setEmptyAttribute(e){this.setAttribute("empty",e===""?"true":"false")}};s([pe({type:Number,attribute:"expected-length"})],T.prototype,"expectedLength",2),s([pe({type:String,attribute:"pattern-mask"})],T.prototype,"patternMask",2),s([pe({type:String,attribute:"placeholder-text"})],T.prototype,"placeholderText",2),s([gr()],T.prototype,"_value",2),s([pe({type:String,attribute:"class"})],T.prototype,"classNames",2),T=s([fr("qti-text-entry-interaction")],T);import{css as br,html as vr}from"lit";import{ifDefined as Ve}from"lit/directives/if-defined.js";import{ref as yr,createRef as Er}from"lit/directives/ref.js";import{customElement as xr,property as de,state as Cr}from"lit/decorators.js";var A=class extends f{constructor(){super(...arguments);this.textareaRef=Er();this._value=""}handleclassNamesChange(e,t){this.classNames.split(" ").forEach(o=>{if(o.startsWith("qti-height-lines")){let n=o.replace("qti-height-lines-","");this.textareaRef&&(this.textareaRef.value.rows=parseInt(n))}})}set response(e){this._value=e!==void 0?e:""}validate(){return this._value!==""}static get styles(){return[Y,br`
132
132
  /* PK: display host as block, else design will be collapsed */
133
133
  :host {
134
134
  display: block;
@@ -138,9 +138,9 @@ import{a as g,b as ie}from"../chunk-DLLHO3W2.js";import{a as C,b as P,c as s}fro
138
138
  width: 100%;
139
139
  height: 100%;
140
140
  }
141
- `]}render(){return fr`<textarea
141
+ `]}render(){return vr`<textarea
142
142
  part="textarea"
143
- ${gr(this.textareaRef)}
143
+ ${yr(this.textareaRef)}
144
144
  spellcheck="false"
145
145
  autocomplete="off"
146
146
  @keydown="${e=>e.stopImmediatePropagation()}"
@@ -152,20 +152,24 @@ import{a as g,b as ie}from"../chunk-DLLHO3W2.js";import{a as C,b as P,c as s}fro
152
152
  ?disabled="${this.disabled}"
153
153
  ?readonly="${this.readonly}"
154
154
  .value=${this._value}
155
- ></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))}reset(){this._value=""}setEmptyAttribute(e){this.setAttribute("empty",e===""?"true":"false")}};s([de({type:Number,attribute:"expected-length"})],w.prototype,"expectedLength",2),s([de({type:String,attribute:"pattern-mask"})],w.prototype,"patternMask",2),s([de({type:String,attribute:"placeholder-text"})],w.prototype,"placeholderText",2),s([yr()],w.prototype,"_value",2),s([de({type:String,attribute:"class"})],w.prototype,"classNames",2),s([g("classNames",{waitUntilFirstUpdate:!0})],w.prototype,"handleclassNamesChange",1),w=s([vr("qti-extended-text-interaction")],w);import{customElement as xr}from"lit/decorators.js";import{html as Er}from"lit";var ue=class extends y{render(){return Er`<div part="ch"><div part="cha"></div></div>
156
- <slot></slot> `}};ue=s([xr("qti-hottext")],ue);import{html as Cr}from"lit";import{property as vt}from"lit/decorators.js";var v=class extends b{constructor(){super();this._choiceElements=[];this.minChoices=0;this.maxChoices=1;this._handleDisabledChange=(e,t)=>this._choiceElements.forEach(r=>r.disabled=t);this._handleReadonlyChange=(e,t)=>this._choiceElements.forEach(r=>r.readonly=t);this._handleMaxChoicesChange=()=>this._determineInputType();this.addEventListener("qti-register-choice",this._registerChoiceElement),this.addEventListener("qti-loose-choice",this._looseChoiceElement)}reset(){this._choiceElements.forEach(e=>{e.reset()})}validate(){return this._choiceElements.reduce((t,r)=>t+(r.checked?1:0),0)>=this.minChoices}set response(e){this._choiceElements.forEach(r=>{r.checked=!1}),(Array.isArray(e)?e:[e]).forEach(r=>{let o=this.querySelector(`[identifier='${r}']`);o&&(o.checked=!0)})}connectedCallback(){super.connectedCallback(),this.addEventListener("qti-choice-element-selected",this._choiceElementSelectedHandler)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-choice-element-selected",this._choiceElementSelectedHandler),this.removeEventListener("qti-register-choice",this._registerChoiceElement)}_registerChoiceElement(e){e.stopPropagation();let t=e.target;this._choiceElements.push(t),this._setInputType(t)}_looseChoiceElement(e){e.stopPropagation();let t=e.target;this._choiceElements.push(t),this._choiceElements=this._choiceElements.filter(r=>r!==t)}_determineInputType(){this._choiceElements.forEach(e=>{this._setInputType(e)})}_setInputType(e){this.maxChoices===1?e.setAttribute("role","radio"):e.setAttribute("role","checkbox")}_choiceElementSelectedHandler(e){this.maxChoices===1&&this._choiceElements.filter(t=>t.identifier!==e.detail.identifier).forEach(t=>{t.checked=!1}),this._choiceElementSelected()}_choiceElementSelected(){let e=this._choiceElements.filter(r=>r.checked).map(r=>r.identifier);this.maxChoices>1&&(this.maxChoices===e.length?this._choiceElements.forEach(r=>r.disabled=!r.checked):this._choiceElements.forEach(r=>r.disabled=!1));let t;this.maxChoices===1?t=e.length>0?e[0]:void 0:t=e,this.saveResponse(t)}};s([vt({type:Number,attribute:"min-choices"})],v.prototype,"minChoices",2),s([vt({type:Number,attribute:"max-choices"})],v.prototype,"maxChoices",2),s([g("disabled",{waitUntilFirstUpdate:!0})],v.prototype,"_handleDisabledChange",2),s([g("readonly",{waitUntilFirstUpdate:!0})],v.prototype,"_handleReadonlyChange",2),s([g("maxChoices",{waitUntilFirstUpdate:!0})],v.prototype,"_handleMaxChoicesChange",2);var Pe=class extends v{constructor(){super(...arguments);this.render=()=>Cr`<slot></slot>`}connectedCallback(){super.connectedCallback(),this.setAttribute("qti-hottext-interaction","")}};customElements.define("qti-hottext-interaction",Pe);import{css as qr,html as yt}from"lit";var me=class extends b{constructor(){super();this.options=[];this.addEventListener(gt.ON_DROPDOWN_SELECTED,this.choiceSelected);let e=Array.from(this.querySelectorAll("qti-inline-choice"));this.options=[{textContent:"select",value:"",selected:!1},...e.map(t=>({textContent:t.innerHTML,value:t.getAttribute("identifier"),selected:!1}))]}static get properties(){return P(C({},b.properties),{options:{type:Array,value:[],attribute:!1}})}connectedCallback(){super.connectedCallback()}static get styles(){return[B,qr`
155
+ ></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))}reset(){this._value=""}setEmptyAttribute(e){this.setAttribute("empty",e===""?"true":"false")}};s([de({type:Number,attribute:"expected-length"})],A.prototype,"expectedLength",2),s([de({type:String,attribute:"pattern-mask"})],A.prototype,"patternMask",2),s([de({type:String,attribute:"placeholder-text"})],A.prototype,"placeholderText",2),s([Cr()],A.prototype,"_value",2),s([de({type:String,attribute:"class"})],A.prototype,"classNames",2),s([g("classNames",{waitUntilFirstUpdate:!0})],A.prototype,"handleclassNamesChange",1),A=s([xr("qti-extended-text-interaction")],A);import{html as _r}from"lit";import{property as Pe}from"lit/decorators.js";var v=class extends f{constructor(){super();this._choiceElements=[];this.minChoices=0;this.maxChoices=1;this._handleDisabledChange=(e,t)=>this._choiceElements.forEach(r=>r.disabled=t);this._handleReadonlyChange=(e,t)=>this._choiceElements.forEach(r=>r.readonly=t);this._handleMaxChoicesChange=()=>this._determineInputType();this.shuffle=!1;this._handleShuffleChange=(e,t)=>{let r=[],o=Array.from(this.querySelectorAll("qti-simple-choice"));if(o.forEach((c,p)=>{c.style.order="initial"}),!t)return;let n=Array.from(o).filter((c,p)=>(c.hasAttribute("fixed")&&r.push(p),!c.hasAttribute("fixed")));o.forEach((c,p)=>{c.style.order=p+""});let l=qr(o.length,r);console.log(o.length,r),n.forEach((c,p)=>{c.style.order=l[p]+""})};this.addEventListener("qti-register-choice",this._registerChoiceElement),this.addEventListener("qti-loose-choice",this._looseChoiceElement)}reset(){this._choiceElements.forEach(e=>{e.reset()})}validate(){return this._choiceElements.reduce((t,r)=>t+(r.checked?1:0),0)>=this.minChoices}set response(e){this._choiceElements.forEach(r=>{r.checked=!1}),(Array.isArray(e)?e:[e]).forEach(r=>{let o=this.querySelector(`[identifier='${r}']`);o&&(o.checked=!0)})}connectedCallback(){super.connectedCallback(),this.addEventListener("qti-choice-element-selected",this._choiceElementSelectedHandler)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-choice-element-selected",this._choiceElementSelectedHandler),this.removeEventListener("qti-register-choice",this._registerChoiceElement)}_registerChoiceElement(e){e.stopPropagation();let t=e.target;this._choiceElements.push(t),this._setInputType(t)}_looseChoiceElement(e){e.stopPropagation();let t=e.target;this._choiceElements.push(t),this._choiceElements=this._choiceElements.filter(r=>r!==t)}_determineInputType(){this._choiceElements.forEach(e=>{this._setInputType(e)})}_setInputType(e){this.maxChoices===1?e.setAttribute("role","radio"):e.setAttribute("role","checkbox")}_choiceElementSelectedHandler(e){this.maxChoices===1&&this._choiceElements.filter(t=>t.identifier!==e.detail.identifier).forEach(t=>{t.checked=!1}),this._choiceElementSelected()}_choiceElementSelected(){let e=this._choiceElements.filter(r=>r.checked).map(r=>r.identifier);this.maxChoices>1&&(this.maxChoices===e.length?this._choiceElements.forEach(r=>r.disabled=!r.checked):this._choiceElements.forEach(r=>r.disabled=!1));let t;this.maxChoices===1?t=e.length>0?e[0]:void 0:t=e,this.saveResponse(t)}};s([Pe({type:Number,attribute:"min-choices"})],v.prototype,"minChoices",2),s([Pe({type:Number,attribute:"max-choices"})],v.prototype,"maxChoices",2),s([g("disabled",{waitUntilFirstUpdate:!0})],v.prototype,"_handleDisabledChange",2),s([g("readonly",{waitUntilFirstUpdate:!0})],v.prototype,"_handleReadonlyChange",2),s([g("maxChoices",{waitUntilFirstUpdate:!0})],v.prototype,"_handleMaxChoicesChange",2),s([Pe({reflect:!0,type:Boolean})],v.prototype,"shuffle",2),s([g("shuffle",{waitUntilFirstUpdate:!0})],v.prototype,"_handleShuffleChange",2);var qr=(a,i=[])=>{let e=Array.from({length:a},(t,r)=>r+1);return e=e.filter(t=>!i.includes(t)),e.forEach((t,r,o)=>{let n=Math.floor(Math.random()*(r+1));[o[r],o[n]]=[o[n],o[r]]}),e};var $e=class extends v{constructor(){super(...arguments);this.render=()=>_r`<slot></slot>`}connectedCallback(){super.connectedCallback(),this.setAttribute("qti-hottext-interaction","")}};customElements.define("qti-hottext-interaction",$e);import{css as kr,html as vt}from"lit";var ue=class extends f{constructor(){super();this.options=[];this.addEventListener(gt.ON_DROPDOWN_SELECTED,this.choiceSelected);let e=Array.from(this.querySelectorAll("qti-inline-choice"));this.options=[{textContent:"select",value:"",selected:!1},...e.map(t=>({textContent:t.innerHTML,value:t.getAttribute("identifier"),selected:!1}))]}static get properties(){return $(C({},f.properties),{options:{type:Array,value:[],attribute:!1}})}connectedCallback(){super.connectedCallback()}static get styles(){return[Y,kr`
157
156
  :host {
158
157
  display: inline-block;
159
158
  }
160
- `]}render(){return yt` <select
159
+ `]}render(){return vt` <select
161
160
  part="select"
162
161
  @change="${this.choiceSelected}"
163
162
  ?disabled="${this.disabled}"
164
163
  ?readonly="${this.readonly}"
165
164
  >
166
- ${this.options.map(e=>yt` <option value="${e.value}" ?selected="${e.selected}">${e.textContent}</option> `)}
167
- </select>`}validate(){let e=this.options.find(t=>t.selected);return e?e.value!=="":!1}reset(){this.options=this.options.map((e,t)=>P(C({},e),{selected:t===0}))}set response(e){this.options=this.options.map(t=>(e===t.value&&(t.selected=!0),t))}choiceSelected(e){let t=e.target.value;this.options=this.options.map(r=>P(C({},r),{selected:r.value===t})),this.saveResponse(t)}};me.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"];customElements.define("qti-inline-choice-interaction",me);import{customElement as kr,property as wr}from"lit/decorators.js";import{html as Ar}from"lit";import{css as _r}from"lit";var xt=_r``;var D=class extends v{constructor(){super(...arguments);this.render=()=>Ar` <slot name="prompt"></slot><slot></slot>`}};D.styles=xt,s([wr({type:String})],D.prototype,"orientation",2),D=s([kr("qti-choice-interaction")],D);import{customElement as Rr}from"lit/decorators.js";import{html as Tr}from"lit";var J=class extends y{render(){return Tr`<div part="ch"><div part="cha"></div></div>
168
- <slot></slot> `}};J=s([Rr("qti-simple-choice")],J);import{customElement as Lr}from"lit/decorators.js";import{html as Sr,LitElement as Mr}from"lit";var Et=`<qti-response-processing>
165
+ ${this.options.map(e=>vt` <option value="${e.value}" ?selected="${e.selected}">${e.textContent}</option> `)}
166
+ </select>`}validate(){let e=this.options.find(t=>t.selected);return e?e.value!=="":!1}reset(){this.options=this.options.map((e,t)=>$(C({},e),{selected:t===0}))}set response(e){this.options=this.options.map(t=>(e===t.value&&(t.selected=!0),t))}choiceSelected(e){let t=e.target.value;this.options=this.options.map(r=>$(C({},r),{selected:r.value===t})),this.saveResponse(t)}};ue.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"];customElements.define("qti-inline-choice-interaction",ue);import{customElement as wr,property as Rr}from"lit/decorators.js";import{html as Lr}from"lit";import{css as Ar}from"lit";var yt=Ar`
167
+ :host {
168
+ display: flex;
169
+ flex-direction: column;
170
+ align-items: flex-start;
171
+ }
172
+ `;var D=class extends v{constructor(){super(...arguments);this.render=()=>Lr` <slot name="prompt"></slot><slot></slot>`}};D.styles=yt,s([Rr({type:String})],D.prototype,"orientation",2),D=s([wr("qti-choice-interaction")],D);import{customElement as Tr}from"lit/decorators.js";import{html as Sr,LitElement as Mr}from"lit";var Et=`<qti-response-processing>
169
173
  <qti-response-condition>
170
174
  <qti-response-if>
171
175
  <qti-match>
@@ -182,7 +186,7 @@ import{a as g,b as ie}from"../chunk-DLLHO3W2.js";import{a as C,b as P,c as s}fro
182
186
  </qti-set-outcome-value>
183
187
  </qti-response-else>
184
188
  </qti-response-condition>
185
- </qti-response-processing>`,Ct=`<qti-response-processing>
189
+ </qti-response-processing>`,xt=`<qti-response-processing>
186
190
  <qti-response-condition>
187
191
  <qti-response-if>
188
192
  <qti-is-null>
@@ -198,7 +202,7 @@ import{a as g,b as ie}from"../chunk-DLLHO3W2.js";import{a as C,b as P,c as s}fro
198
202
  </qti-set-outcome-value>
199
203
  </qti-response-else>
200
204
  </qti-response-condition>
201
- </qti-response-processing>`,qt=`<qti-response-processing>
205
+ </qti-response-processing>`,Ct=`<qti-response-processing>
202
206
  <qti-response-condition>
203
207
  <qti-response-if>
204
208
  <qti-is-null>
@@ -214,14 +218,14 @@ import{a as g,b as ie}from"../chunk-DLLHO3W2.js";import{a as C,b as P,c as s}fro
214
218
  </qti-set-outcome-value>
215
219
  </qti-response-else>
216
220
  </qti-response-condition>
217
- </qti-response-processing>`;var X=class extends Mr{render(){return Sr`<slot></slot>`}static get observedAttributes(){return["identifier"]}process(){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(Ct));break}case"map_response_point":{this.appendChild(this.fragmentFromString(qt));break}case"match_correct":this.appendChild(this.fragmentFromString(Et));break}}let i=[...this.children];for(let e of i)e.process()}fragmentFromString(i){return document.createRange().createContextualFragment(i)}};X=s([Lr("qti-response-processing")],X);import{customElement as Nr}from"lit/decorators.js";import{html as Hr,LitElement as Or}from"lit";var M=class extends Or{render(){return Hr``}process(){throw new Error("Not implemented")}};M=s([Nr("qti-rule")],M);import{html as Dr}from"lit";var $e=class extends M{render(){return Dr`<slot></slot>`}process(){let i=[...this.children];for(let e=0;e<i.length;e++){let t=i[e];if(t.calculate()){t.process();return}}}};customElements.define("qti-response-condition",$e);var Ie=class extends M{process(){let i=this.getAttribute("identifier"),e=this.firstElementChild,t=e?e.calculate():null;if(t==null){console.warn("setOutcomeValue: value is null or undefined");return}this.closest("qti-assessment-item").setOutcomeValue(i,t)}};customElements.define("qti-set-outcome-value",Ie);import{html as $r}from"lit";import{html as Vr,LitElement as Pr}from"lit";var Z=class extends Pr{static get properties(){return{debugCalculateResult:{type:Object}}}render(){return Vr` <slot></slot>`}calculate(){return!0}getSubRules(){return[...this.children]}process(){let i=this.getSubRules();for(let e=0;e<i.length;e++)i[e].process()}};customElements.define("qti-response-else",Z);var Q=class extends Z{render(){return $r`${super.render()}`}calculate(){return this.firstElementChild.calculate()}getSubRules(){let i=[];for(let e=1;e<this.children.length;e++)i.push(this.children[e]);return i}};customElements.define("qti-response-if",Q);import{html as Ir}from"lit";var Fe=class extends Q{render(){return Ir`${super.render()}`}};customElements.define("qti-response-else-if",Fe);import{LitElement as Fr,html as Ur}from"lit";var u=class extends Fr{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,cardinality:"single"};case"qti-variable":{let t=e.getAttribute("identifier")||"";return this.assessmentItem.getResponse(t)}case"qti-multiple":{let r=e.calculate();return r.length>0?{baseType:r[0].baseType,value:r.map(o=>o.value),cardinality:"multiple"}:null}case"qti-correct":{let t=e.getAttribute("identifier")||"",r=this.assessmentItem.getResponse(t);return{baseType:r.baseType,value:r.correctResponse,cardinality:r.cardinality}}default:return null}}).filter(e=>e!==null)}render(){return Ur``}calculate(){throw new Error("Not implemented")}get assessmentItem(){return this.closest("qti-assessment-item")}};customElements.define("qti-expression",u);var Ue=class extends u{calculate(){if(this.children.length===2){let i=this.getVariables(),e=i[0],t=i[1];if(e.baseType===t.baseType&&(e.baseType==="integer"||e.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",Ue);import{html as Br}from"lit";var N=class extends u{render(){return Br``}calculate(){throw new Error("Not implemented")}};var Be=class extends N{calculate(){if(this.children.length===2){let i=this.getVariables(),e=i[0],t=i[1];return e.baseType===t.baseType&&(e.baseType==="integer"||e.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",Be);import{html as Xr}from"lit";var Xe=class extends N{render(){return Xr``}calculate(){return Array.from(this.children).map(e=>{let t=e;if(!t.calculate)return console.error("Element doesn't implement QtiConditionExpression"),null;let r=t.calculate();if(typeof r=="string")if(r==="true")r=!0;else if(r==="false")r=!1;else return console.error("unexpected value in qti-and, expected boolean"),null;return r}).every(e=>typeof e=="boolean"&&e)}};customElements.define("qti-and",Xe);import{html as Yr}from"lit";var Ye=class extends N{render(){return Yr``}calculate(){return Array.from(this.children).map(e=>{let t=e;if(!t.calculate)return console.error("Element doesn't implement QtiConditionExpression"),null;let r=t.calculate();if(typeof r=="string")if(r==="true")r=!0;else if(r==="false")r=!1;else return console.error("unexpected value in qti-and, expected boolean"),null;return r}).some(e=>typeof e=="boolean"&&e)}};customElements.define("qti-or",Ye);import{property as Kr}from"lit/decorators.js";var A=class{static compareSingleValues(i,e,t){switch(t){case"identifier":case"string":return i===e;case"integer":{let r=parseInt(i,10),o=parseInt(e,10);if(!isNaN(r)&&!isNaN(o))return r===o;console.error(`Cannot convert ${i} and/or ${e} to int.`);break}case"float":{let r=parseFloat(i),o=parseFloat(e);if(!isNaN(r)&&!isNaN(o))return r===o;console.error(`couldn't convert ${i} and/or ${e} to float.`);break}case"pair":case"directedPair":{let r=i.split(" ").sort(),o=e.split(" ").sort();if(r.length===2&&o.length===2)return t==="pair"&&(r.sort(),o.sort()),r.join(" ")===o.join(" ");console.error(`compared two pair but one of the values does not have 2 values: 1: ${i} 2: ${e}`);break}}return!1}};var he=class extends u{constructor(){super(...arguments);this.toleranceMode="exact"}calculate(){if(this.children.length===2){let e=this.getVariables(),t=e[0],r=e[1];return this.toleranceMode!=="exact"?(console.error("toleranceMode is not supported yet"),!1):t.cardinality!=="single"||r.cardinality!=="single"||Array.isArray(t.value)||Array.isArray(r.value)?(console.error("unexpected cardinality in qti equal"),!1):A.compareSingleValues(t.value,r.value,t.baseType)}return console.error("unexpected number of children in qti-equal"),null}};s([Kr({type:String})],he.prototype,"toleranceMode",2);customElements.define("qti-equal",he);import{property as zr}from"lit/decorators.js";var fe=class extends u{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}calculate(){if(this.children.length===2){let e=this.getVariables(),t=e[0],r=e[1];if(this.roundingMode===null)return null;if(t.cardinality!=="single"||r.cardinality!=="single"||Array.isArray(t.value)||Array.isArray(r.value))return console.error("unexpected cardinality in qti equal"),!1;switch(e[0].baseType){case"integer":case"float":{let o=parseFloat(t.value),l=parseFloat(r.value);if(!isNaN(o)&&!isNaN(l))return this.roundingMode==="significantFigures"?o.toPrecision(this.figures)===l.toPrecision(this.figures):Math.round(o*Math.pow(10,this.figures))/Math.pow(10,this.figures)===Math.round(l*Math.pow(10,this.figures))/Math.pow(10,this.figures);console.error(`value cannot be casted to numeric value in equalRounded operator: ${o}, ${l}`);break}default:{console.error("values other than float and int cannot be used in equalRounded operator.");break}}return!1}return console.error("unexpected number of children in qti-equal-rounded"),null}};s([zr({type:String})],fe.prototype,"roundingMode",2);customElements.define("qti-equal-rounded",fe);import{property as jr}from"lit/decorators.js";var ge=class extends u{constructor(){super(...arguments);this.baseType="string"}calculate(){return this.textContent}};s([jr({type:String})],ge.prototype,"baseType",2);customElements.define("qti-base-value",ge);var Ke=class extends u{calculate(){let i=this.getVariables();if(this.children.length===2){let e=i[0],t=i[1];if(e.baseType==="directedPair"&&t.baseType==="directedPair"&&e.cardinality==="multiple"){let r=e.value,o=t.value;return r.filter(c=>o.includes(c)).length>0}else if(e.baseType==="directedPair"&&t.baseType==="directedPair"&&e.cardinality==="single"){let r=e.value;return t.value.includes(r)}else console.error("unsupported baseType or cardinality in qti contains, only baseType: directedPair and cardinality: multiple is supported")}else console.error("unexpected number of children in qti contains");return!1}};customElements.define("qti-contains",Ke);import{html as Gr}from"lit";var ze=class extends u{render(){return Gr``}get interpretation(){return this.getAttribute("interpretation")||""}calculate(){let i=this.getAttribute("identifier")||"",e=this.closest("qti-assessment-item").getResponse(i);return e.correctResponse,e.cardinality!=="single"?e.correctResponse.length>0?e.correctResponse[0]:"":e.correctResponse}};customElements.define("qti-correct",ze);var je=class extends u{calculate(){if(this.children.length===1){let i=this.getVariables();if(!i)return!0;let e=i[0].value;return e==null||e==null||e===""}return console.error("unexpected number of children in qti Null"),null}};customElements.define("qti-is-null",je);import{property as Wr}from"lit/decorators.js";var be=class extends u{calculate(){let e=this.assessmentItem.getResponse(this.identifier);if(!e)return console.warn(`Response ${this.identifier} can not be found`),null;let t=e.mapping,r=Array.isArray(e.value)?e.value:[e.value],o=0;for(let l of r){let n=t.mapEntries.find(c=>A.compareSingleValues(c.mapKey,l,e.baseType));n==null||n.mappedValue==null?o+=t.defaultValue:o+=n.mappedValue}return t.lowerBound!=null&&(o=Math.max(t.lowerBound,o)),t.upperBound!=null&&(o=Math.min(t.upperBound,o)),o}};s([Wr({type:String})],be.prototype,"identifier",2);customElements.define("qti-map-response",be);var Ge=class extends u{calculate(){if(this.children.length===2){let i=this.getVariables(),e=i[0],t=i[1];if(t.cardinality==="single")return Array.isArray(e.value)||Array.isArray(t.value)?(console.error("unexpected cardinality in qti match"),!1):A.compareSingleValues(e.value.toString(),t.value.toString(),t.baseType);{if(!Array.isArray(e.value)||!Array.isArray(t.value))return console.error("unexpected cardinality in qti match"),!1;if(e.value.length!==t.value.length)return!1;let r=0;for(let o of t.value){if(t.cardinality==="ordered"){let l=e[r];if(!A.compareSingleValues(o,l,t.baseType))return!1}else{let l=null;for(let n of e.value)if(A.compareSingleValues(o,n,t.baseType)){l=n;break}if(l!==null)e.value.splice(e.value.indexOf(l),1);else return!1}r++}return!0}}return console.error("unexpected number of children in match"),null}};customElements.define("qti-match",Ge);import{html as Jr}from"lit";var We=class extends u{render(){return Jr``}calculate(){let i=this.getAttribute("identifier");return this.closest("qti-assessment-item").getVariableValue(i)}};customElements.define("qti-variable",We);var Je=class extends u{calculate(){let i=this.getVariables();if(i.length===0)return console.error("unexpected number of children in qti multiple"),null;for(let e of i)if(e.cardinality!=="multiple"&&e.cardinality!=="single")return console.error("unexpected cardinality in qti multiple"),[];return i}};customElements.define("qti-multiple",Je);var Ze=class extends u{calculate(){let i=this.getVariables();if(i.length===0)return console.error("unexpected number of children in qti multiple"),null;for(let e of i)if(e.cardinality!=="ordered"&&e.cardinality!=="single")return console.error("unexpected cardinality in qti ordered"),[];return i}};customElements.define("qti-ordered",Ze);import{property as Qe}from"lit/decorators.js";import{LitElement as Zr}from"lit";var Y=class extends Zr{constructor(){super(...arguments);this.defaultValue=0}get mapEntries(){return Array.from(this.querySelectorAll("qti-map-entry")).map(e=>({mapKey:e.getAttribute("map-key"),mappedValue:+e.getAttribute("mapped-value")}))}};s([Qe({attribute:"default-value",type:Number})],Y.prototype,"defaultValue",2),s([Qe({attribute:"lower-bound",type:Number})],Y.prototype,"lowerBound",2),s([Qe({attribute:"upper-bound",type:Number})],Y.prototype,"upperBound",2);customElements.define("qti-mapping",Y);import{LitElement as Qr,html as _t}from"lit";var et=class extends Qr{constructor(){super(...arguments);this._errorMessage=null}static get properties(){return{responseIdentifier:{type:String,attribute:"response-identifier"},module:{type:String,attribute:"module"},customInteractionTypeIdentifier:{type:String,attribute:"custom-interaction-type-identifier"},baseUrl:{type:String,attribute:"base-url"},_errorMessage:{type:String,state:!0}}}getTAOConfig(e){let t=e.querySelectorAll("properties"),r={},o=n=>{let c={},p=n.getAttribute("key");if(p){let d=Array.from(n.children),m=d.map(f=>f.getAttribute("key"));m.length>0&&!m.find(f=>!Number.isInteger(+f))?c[p]=d.map(f=>l(f)):c[p]=n.textContent}return c},l=n=>{if(n){let c={};for(let p of n.children)c=C(C({},c),o(p));return c}};for(let n of t)return n.getAttribute("key")||(r=C(C({},r),l(n))),r;console.log("Can not find qti-custom-interaction config")}register(e){let t=this.parentElement.tagName==="QTI-CUSTOM-INTERACTION"?"TAO":"IMS",r=t=="IMS"?this.querySelector("qti-interaction-markup"):this.querySelector("markup");r.classList.add("qti-customInteraction"),t=="TAO"&&this.querySelector("properties")&&(this.querySelector("properties").style.display="none");let o=t=="IMS"?{properties:this.dataset}:this.getTAOConfig(this);t=="IMS"?e.getInstance(r,o,void 0):e.initialize(this.customInteractionTypeIdentifier,r.firstElementChild,o),t=="TAO"&&Array.from(this.querySelectorAll("link")).map(n=>n.getAttribute("href")).forEach(n=>{let c=document.createElement("link");c.rel="stylesheet",c.type="text/css",c.media="screen",c.href=n,r.appendChild(c)})}connectedCallback(){super.connectedCallback();let e={context:this.customInteractionTypeIdentifier,baseUrl:this.baseUrl,catchError:!0};window.requirePaths&&window.requireShim&&(e.paths=window.requirePaths,e.shim=window.requireShim),requirejs.config(e)(["require"],r=>{define("qtiCustomInteractionContext",()=>({register:o=>{this.register(o)},notifyReady:()=>{}})),r([this.module],()=>{},o=>{this._errorMessage=o})},r=>{this._errorMessage=r})}render(){return _t`<slot></slot>${this._errorMessage&&_t`<div style="color:red">
221
+ </qti-response-processing>`;var B=class extends Mr{render(){return Sr`<slot></slot>`}static get observedAttributes(){return["identifier"]}process(){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(xt));break}case"map_response_point":{this.appendChild(this.fragmentFromString(Ct));break}case"match_correct":this.appendChild(this.fragmentFromString(Et));break}}let i=[...this.children];for(let e of i)e.process()}fragmentFromString(i){return document.createRange().createContextualFragment(i)}};B=s([Tr("qti-response-processing")],B);import{customElement as Nr}from"lit/decorators.js";import{html as Hr,LitElement as Or}from"lit";var S=class extends Or{render(){return Hr``}process(){throw new Error("Not implemented")}};S=s([Nr("qti-rule")],S);import{html as Dr}from"lit";var Ie=class extends S{render(){return Dr`<slot></slot>`}process(){let i=[...this.children];for(let e=0;e<i.length;e++){let t=i[e];if(t.calculate()){t.process();return}}}};customElements.define("qti-response-condition",Ie);var Fe=class extends S{process(){let i=this.getAttribute("identifier"),e=this.firstElementChild,t=e?e.calculate():null;if(t==null){console.warn("setOutcomeValue: value is null or undefined");return}this.closest("qti-assessment-item").setOutcomeValue(i,t)}};customElements.define("qti-set-outcome-value",Fe);import{html as $r}from"lit";import{html as Vr,LitElement as Pr}from"lit";var Z=class extends Pr{static get properties(){return{debugCalculateResult:{type:Object}}}render(){return Vr` <slot></slot>`}calculate(){return!0}getSubRules(){return[...this.children]}process(){let i=this.getSubRules();for(let e=0;e<i.length;e++)i[e].process()}};customElements.define("qti-response-else",Z);var Q=class extends Z{render(){return $r`${super.render()}`}calculate(){return this.firstElementChild.calculate()}getSubRules(){let i=[];for(let e=1;e<this.children.length;e++)i.push(this.children[e]);return i}};customElements.define("qti-response-if",Q);import{html as Ir}from"lit";var Ue=class extends Q{render(){return Ir`${super.render()}`}};customElements.define("qti-response-else-if",Ue);import{LitElement as Fr,html as Ur}from"lit";var u=class extends Fr{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,cardinality:"single"};case"qti-variable":{let t=e.getAttribute("identifier")||"";return this.assessmentItem.getResponse(t)}case"qti-multiple":{let r=e.calculate();return r.length>0?{baseType:r[0].baseType,value:r.map(o=>o.value),cardinality:"multiple"}:null}case"qti-correct":{let t=e.getAttribute("identifier")||"",r=this.assessmentItem.getResponse(t);return{baseType:r.baseType,value:r.correctResponse,cardinality:r.cardinality}}default:return null}}).filter(e=>e!==null)}render(){return Ur``}calculate(){throw new Error("Not implemented")}get assessmentItem(){return this.closest("qti-assessment-item")}};customElements.define("qti-expression",u);var Xe=class extends u{calculate(){if(this.children.length===2){let i=this.getVariables(),e=i[0],t=i[1];if(e.baseType===t.baseType&&(e.baseType==="integer"||e.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",Xe);import{html as Xr}from"lit";var N=class extends u{render(){return Xr``}calculate(){throw new Error("Not implemented")}};var Ye=class extends N{calculate(){if(this.children.length===2){let i=this.getVariables(),e=i[0],t=i[1];return e.baseType===t.baseType&&(e.baseType==="integer"||e.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",Ye);import{html as Yr}from"lit";var Be=class extends N{render(){return Yr``}calculate(){return Array.from(this.children).map(e=>{let t=e;if(!t.calculate)return console.error("Element doesn't implement QtiConditionExpression"),null;let r=t.calculate();if(typeof r=="string")if(r==="true")r=!0;else if(r==="false")r=!1;else return console.error("unexpected value in qti-and, expected boolean"),null;return r}).every(e=>typeof e=="boolean"&&e)}};customElements.define("qti-and",Be);import{html as Br}from"lit";var Ke=class extends N{render(){return Br``}calculate(){return Array.from(this.children).map(e=>{let t=e;if(!t.calculate)return console.error("Element doesn't implement QtiConditionExpression"),null;let r=t.calculate();if(typeof r=="string")if(r==="true")r=!0;else if(r==="false")r=!1;else return console.error("unexpected value in qti-and, expected boolean"),null;return r}).some(e=>typeof e=="boolean"&&e)}};customElements.define("qti-or",Ke);import{property as Kr}from"lit/decorators.js";var w=class{static compareSingleValues(i,e,t){switch(t){case"identifier":case"string":return i===e;case"integer":{let r=parseInt(i,10),o=parseInt(e,10);if(!isNaN(r)&&!isNaN(o))return r===o;console.error(`Cannot convert ${i} and/or ${e} to int.`);break}case"float":{let r=parseFloat(i),o=parseFloat(e);if(!isNaN(r)&&!isNaN(o))return r===o;console.error(`couldn't convert ${i} and/or ${e} to float.`);break}case"pair":case"directedPair":{let r=i.split(" ").sort(),o=e.split(" ").sort();if(r.length===2&&o.length===2)return t==="pair"&&(r.sort(),o.sort()),r.join(" ")===o.join(" ");console.error(`compared two pair but one of the values does not have 2 values: 1: ${i} 2: ${e}`);break}}return!1}};var me=class extends u{constructor(){super(...arguments);this.toleranceMode="exact"}calculate(){if(this.children.length===2){let e=this.getVariables(),t=e[0],r=e[1];return this.toleranceMode!=="exact"?(console.error("toleranceMode is not supported yet"),!1):t.cardinality!=="single"||r.cardinality!=="single"||Array.isArray(t.value)||Array.isArray(r.value)?(console.error("unexpected cardinality in qti equal"),!1):w.compareSingleValues(t.value,r.value,t.baseType)}return console.error("unexpected number of children in qti-equal"),null}};s([Kr({type:String})],me.prototype,"toleranceMode",2);customElements.define("qti-equal",me);import{property as jr}from"lit/decorators.js";var he=class extends u{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}calculate(){if(this.children.length===2){let e=this.getVariables(),t=e[0],r=e[1];if(this.roundingMode===null)return null;if(t.cardinality!=="single"||r.cardinality!=="single"||Array.isArray(t.value)||Array.isArray(r.value))return console.error("unexpected cardinality in qti equal"),!1;switch(e[0].baseType){case"integer":case"float":{let o=parseFloat(t.value),n=parseFloat(r.value);if(!isNaN(o)&&!isNaN(n))return this.roundingMode==="significantFigures"?o.toPrecision(this.figures)===n.toPrecision(this.figures):Math.round(o*Math.pow(10,this.figures))/Math.pow(10,this.figures)===Math.round(n*Math.pow(10,this.figures))/Math.pow(10,this.figures);console.error(`value cannot be casted to numeric value in equalRounded operator: ${o}, ${n}`);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}};s([jr({type:String})],he.prototype,"roundingMode",2);customElements.define("qti-equal-rounded",he);import{property as zr}from"lit/decorators.js";var fe=class extends u{constructor(){super(...arguments);this.baseType="string"}calculate(){return this.textContent}};s([zr({type:String})],fe.prototype,"baseType",2);customElements.define("qti-base-value",fe);var je=class extends u{calculate(){let i=this.getVariables();if(this.children.length===2){let e=i[0],t=i[1];if(e.baseType==="directedPair"&&t.baseType==="directedPair"&&e.cardinality==="multiple"){let r=e.value,o=t.value;return r.filter(c=>o.includes(c)).length>0}else if(e.baseType==="directedPair"&&t.baseType==="directedPair"&&e.cardinality==="single"){let r=e.value;return t.value.includes(r)}else console.error("unsupported baseType or cardinality in qti contains, only baseType: directedPair and cardinality: multiple is supported")}else console.error("unexpected number of children in qti contains");return!1}};customElements.define("qti-contains",je);import{html as Gr}from"lit";var ze=class extends u{render(){return Gr``}get interpretation(){return this.getAttribute("interpretation")||""}calculate(){let i=this.getAttribute("identifier")||"",e=this.closest("qti-assessment-item").getResponse(i);return e.correctResponse,e.cardinality!=="single"?e.correctResponse.length>0?e.correctResponse[0]:"":e.correctResponse}};customElements.define("qti-correct",ze);var Ge=class extends u{calculate(){if(this.children.length===1){let i=this.getVariables();if(!i)return!0;let e=i[0].value;return e==null||e==null||e===""}return console.error("unexpected number of children in qti Null"),null}};customElements.define("qti-is-null",Ge);import{property as Wr}from"lit/decorators.js";var ge=class extends u{calculate(){let e=this.assessmentItem.getResponse(this.identifier);if(!e)return console.warn(`Response ${this.identifier} can not be found`),null;let t=e.mapping,r=Array.isArray(e.value)?e.value:[e.value],o=0;for(let n of r){let l=t.mapEntries.find(c=>w.compareSingleValues(c.mapKey,n,e.baseType));l==null||l.mappedValue==null?o+=t.defaultValue:o+=l.mappedValue}return t.lowerBound!=null&&(o=Math.max(t.lowerBound,o)),t.upperBound!=null&&(o=Math.min(t.upperBound,o)),o}};s([Wr({type:String})],ge.prototype,"identifier",2);customElements.define("qti-map-response",ge);var We=class extends u{calculate(){if(this.children.length===2){let i=this.getVariables(),e=i[0],t=i[1];if(t.cardinality==="single")return Array.isArray(e.value)||Array.isArray(t.value)?(console.error("unexpected cardinality in qti match"),!1):w.compareSingleValues(e.value.toString(),t.value.toString(),t.baseType);{if(!Array.isArray(e.value)||!Array.isArray(t.value))return console.error("unexpected cardinality in qti match"),!1;if(e.value.length!==t.value.length)return!1;let r=0;for(let o of t.value){if(t.cardinality==="ordered"){let n=e[r];if(!w.compareSingleValues(o,n,t.baseType))return!1}else{let n=null;for(let l of e.value)if(w.compareSingleValues(o,l,t.baseType)){n=l;break}if(n!==null)e.value.splice(e.value.indexOf(n),1);else return!1}r++}return!0}}return console.error("unexpected number of children in match"),null}};customElements.define("qti-match",We);import{html as Jr}from"lit";var Je=class extends u{render(){return Jr``}calculate(){let i=this.getAttribute("identifier");return this.closest("qti-assessment-item").getVariableValue(i)}};customElements.define("qti-variable",Je);var Ze=class extends u{calculate(){let i=this.getVariables();if(i.length===0)return console.error("unexpected number of children in qti multiple"),null;for(let e of i)if(e.cardinality!=="multiple"&&e.cardinality!=="single")return console.error("unexpected cardinality in qti multiple"),[];return i}};customElements.define("qti-multiple",Ze);var Qe=class extends u{calculate(){let i=this.getVariables();if(i.length===0)return console.error("unexpected number of children in qti multiple"),null;for(let e of i)if(e.cardinality!=="ordered"&&e.cardinality!=="single")return console.error("unexpected cardinality in qti ordered"),[];return i}};customElements.define("qti-ordered",Qe);import{property as et}from"lit/decorators.js";import{LitElement as Zr}from"lit";var K=class extends Zr{constructor(){super(...arguments);this.defaultValue=0}get mapEntries(){return Array.from(this.querySelectorAll("qti-map-entry")).map(e=>({mapKey:e.getAttribute("map-key"),mappedValue:+e.getAttribute("mapped-value")}))}};s([et({attribute:"default-value",type:Number})],K.prototype,"defaultValue",2),s([et({attribute:"lower-bound",type:Number})],K.prototype,"lowerBound",2),s([et({attribute:"upper-bound",type:Number})],K.prototype,"upperBound",2);customElements.define("qti-mapping",K);import{LitElement as Qr,html as qt}from"lit";var tt=class extends Qr{constructor(){super(...arguments);this._errorMessage=null}static get properties(){return{responseIdentifier:{type:String,attribute:"response-identifier"},module:{type:String,attribute:"module"},customInteractionTypeIdentifier:{type:String,attribute:"custom-interaction-type-identifier"},baseUrl:{type:String,attribute:"base-url"},_errorMessage:{type:String,state:!0}}}getTAOConfig(e){let t=e.querySelectorAll("properties"),r={},o=l=>{let c={},p=l.getAttribute("key");if(p){let d=Array.from(l.children),m=d.map(b=>b.getAttribute("key"));m.length>0&&!m.find(b=>!Number.isInteger(+b))?c[p]=d.map(b=>n(b)):c[p]=l.textContent}return c},n=l=>{if(l){let c={};for(let p of l.children)c=C(C({},c),o(p));return c}};for(let l of t)return l.getAttribute("key")||(r=C(C({},r),n(l))),r;console.log("Can not find qti-custom-interaction config")}register(e){let t=this.parentElement.tagName==="QTI-CUSTOM-INTERACTION"?"TAO":"IMS",r=t=="IMS"?this.querySelector("qti-interaction-markup"):this.querySelector("markup");r.classList.add("qti-customInteraction"),t=="TAO"&&this.querySelector("properties")&&(this.querySelector("properties").style.display="none");let o=t=="IMS"?{properties:this.dataset}:this.getTAOConfig(this);t=="IMS"?e.getInstance(r,o,void 0):e.initialize(this.customInteractionTypeIdentifier,r.firstElementChild,o),t=="TAO"&&Array.from(this.querySelectorAll("link")).map(l=>l.getAttribute("href")).forEach(l=>{let c=document.createElement("link");c.rel="stylesheet",c.type="text/css",c.media="screen",c.href=l,r.appendChild(c)})}connectedCallback(){super.connectedCallback();let e={context:this.customInteractionTypeIdentifier,baseUrl:this.baseUrl,catchError:!0};if(window.requirePaths&&window.requireShim&&(e.paths=window.requirePaths,e.shim=window.requireShim),!globalThis.require){this._errorMessage="requirejs not found, load with cdn: https://cdnjs.com/libraries/require.js";return}requirejs.config(e)(["require"],r=>{define("qtiCustomInteractionContext",()=>({register:o=>{this.register(o)},notifyReady:()=>{}})),r([this.module],()=>{},o=>{this._errorMessage=o})},r=>{this._errorMessage=r})}render(){return qt`<slot></slot>${this._errorMessage&&qt`<div style="color:red">
218
222
  <h1>Error</h1>
219
223
  ${this._errorMessage}
220
- </div>`}`}};customElements.define("qti-portable-custom-interaction",et);import{LitElement as ti,css as ri,html as Rt}from"lit";var H=class{constructor(){this._touchBegin=0;this._touchDown=null;this._lastClick=0;this._canDrag=!1;this._dragSrc=null;this._dragCopy=null;this._touchEndCalled=!1;this._dragRunning=!1;this._dataTransfer={data:{},setData:function(i,e){this.data[i]=e},getData:function(i){return this.data[i]},effectAllowed:"move"};this._copyOffset={x:0,y:0};this._lastTarget=null;this._currentDropContainer=null;this._handleClick=!0;this._DBLCLICKDELAY=500;this._CONTEXTMENUDELAY=1e3;this._DRAGDELTA=5;this._COPYOPACITY=.7;this.copyStylesDragClone=!0;this.dragOnClick=!1;this._createDragCopy=(i,e)=>{if(this._dragCopy===null&&this._dragRunning){this._dragSrc.style.opacity=this._COPYOPACITY,this._dragCopy=this._dragSrc.cloneNode(!0);let t=window.getComputedStyle(this._dragSrc);if(this._dragCopy.style="",this._dragCopy.setAttribute("dragclone",""),this.copyStylesDragClone)for(let r of t)this._dragCopy.style[r]=t.getPropertyValue(r);this._calculateDragCopyPosition(e),this._dragCopy.style.top=e.clientY-this._copyOffset.y+"px",this._dragCopy.style.left=e.clientX-this._copyOffset.x+"px",this._dragCopy.style.position="fixed",this._dragCopy.style.pointerEvents="none",this._dragCopy.style.zIndex="999999",this._dragCopy=document.body.appendChild(this._dragCopy),this._dispatchEvent(this._dragSrc,"dragstart")}if(this._dragRunning){let t=this;requestAnimationFrame(function(){t._touchEndCalled||t._dragCopy===null||(t._dragCopy.style.top=e.clientY-t._copyOffset.y+"px",t._dragCopy.style.left=e.clientX-t._copyOffset.x+"px")});let r=this._findDroppable(i);r!=this._lastTarget&&(this._dispatchEvent(r,"dragenter"),this._dispatchEvent(this._lastTarget,"dragleave"),this._lastTarget=r),this._currentDropContainer=r,this._currentDropContainer&&this._dispatchEvent(r,"dragover")}};return H._instance?H._instance:(H._instance=this,document.addEventListener("touchmove",this._touchMove.bind(this),{passive:!1,capture:!1}),document.addEventListener("mousemove",this._touchMove.bind(this),{passive:!1,capture:!1}),document.addEventListener("touchend",this._touchEnd.bind(this),{passive:!1,capture:!1}),document.addEventListener("mouseup",this._touchEnd.bind(this),{passive:!1,capture:!1}),document.addEventListener("touchcancel",this._touchCancel.bind(this),{passive:!1,capture:!1}),this)}addDraggables(i){i.forEach(e=>{e.addEventListener("touchstart",this._touchStart.bind(this),{passive:!1,capture:!1}),e.addEventListener("mousedown",this._touchStart.bind(this),{passive:!1,capture:!1})})}_touchStart(i){this._touchBegin=Date.now();let{x:e,y:t}=this._getPositionFromEvent(i);if(this._touchDown={x:e,y:t},this._dragSrc=i.currentTarget,this._canDrag=!0,this.dragOnClick){let r={clientX:e,clientY:t};this._dragRunning=!0,this._createDragCopy(i,r)}i.preventDefault()}_touchMove(i){if(this._canDrag&&this._dragSrc){let{x:e,y:t}=this._getPositionFromEvent(i),r={clientX:e,clientY:t};this._getDelta(r)>=this._DRAGDELTA&&(this._dragRunning=!0),this._createDragCopy(i,r),i.preventDefault()}}_touchEnd(i){var e;if(this._touchEndCalled=!0,this._canDrag=!1,this._currentDropContainer)this._dispatchEvent(this._currentDropContainer,"drop"),this._dispatchEvent(this._dragSrc,"dragend");else if(this._dragRunning){let t=new CustomEvent("dragend",{bubbles:!0,cancelable:!0});t.dataTransfer={dropEffect:"none"},(e=this._dragSrc)==null||e.dispatchEvent(t)}this._reset()}_touchCancel(i){this._reset()}_findDroppable(i){let e,t=i.composedPath().find(r=>{if(r.nodeType===1&&r.nodeName!=="SLOT"&&r.hasAttribute("dropzone"))return r});if(t){let r=t.getRootNode(),o=this._getPoint(i);e=r.elementFromPoint(o.x,o.y)}return e}_getPoint(i,e){return i&&i.touches&&(i=i.touches[0]),{x:e?i.pageX:i.clientX,y:e?i.pageY:i.clientY}}_calculateDragCopyPosition(i){let e=this._dragSrc.getBoundingClientRect();this._copyOffset.x=i.clientX-e.left,this._copyOffset.y=i.clientY-e.top}_getDelta(i){let e=Math.abs(i.clientX-this._touchDown.x),t=Math.abs(i.clientY-this._touchDown.y);return e+t}_dispatchEvent(i,e,t=!0){if(!i)return!1;let r=new CustomEvent(e,{bubbles:t,cancelable:!0});return r.dataTransfer=this._dataTransfer,i.dispatchEvent(r),r.defaultPrevented}_reset(){this._dragRunning&&(this._dragSrc.style.opacity="1.0",this._dragCopy.parentElement.removeChild(this._dragCopy)),this._dragRunning=!1,this._dragSrc=null,this._dragCopy=null,this._canDrag=!1,this._touchBegin=0,this._touchDown=null,this._lastClick=0,this._touchEndCalled=!1,this._dataTransfer={data:{},setData:function(i,e){this.data[i]=e},getData:function(i){return this.data[i]},effectAllowed:"move"},this._copyOffset={x:0,y:0},this._lastTarget=null,this._currentDropContainer=null,this._handleClick=!0}_getPositionFromEvent(i){let e;if(i.type=="touchstart"||i.type=="touchmove"||i.type=="touchend"||i.type=="touchcancel"){let t=typeof i.originalEvent=="undefined"?i:i.originalEvent,r=t.touches[0]||t.changedTouches[0];e={x:r.pageX,y:r.pageY}}else(i.type=="mousedown"||i.type=="mouseup"||i.type=="mousemove"||i.type=="mouseover"||i.type=="mouseout"||i.type=="mouseenter"||i.type=="mouseleave")&&(e={x:i.clientX,y:i.clientY});return e}};import{property as ei}from"lit/decorators.js";var kt=(a,i,e)=>{class t extends a{constructor(){super(...arguments);this.disabled=!1}firstUpdated(l){if(this.classList.contains("qti-match-tabular"))return;super.firstUpdated(l);let n=Array.from(i?this.shadowRoot.querySelectorAll(e):this.querySelectorAll(e));this.dragoverHandler=this.dragoverHandler.bind(this),this.dragleaveHandler=this.dragleaveHandler.bind(this),this.dropHandler=this.dropHandler.bind(this),n.forEach(c=>{c.setAttribute("dropzone","move"),c.addEventListener("dragleave",this.dragleaveHandler),this.attachHandler(c)});for(let c of n)this.observer=new MutationObserver(p=>{p.forEach(d=>{if(d.type==="attributes")switch(d.attributeName){case"disabled":{c.hasAttribute("disabled")?this.removeHandler(c):this.attachHandler(c);break}}})}),this.observer.observe(c,{attributes:!0})}attachHandler(l){l.addEventListener("dragover",this.dragoverHandler),l.addEventListener("drop",this.dropHandler)}removeHandler(l){l.removeEventListener("dragover",this.dragoverHandler),l.removeEventListener("drop",this.dropHandler)}disconnectedCallback(){var l;this.classList.contains("qti-match-tabular")||(super.disconnectedCallback(),(l=this.observer)==null||l.disconnect())}dragoverHandler(l){return l.preventDefault(),l.currentTarget.setAttribute("active",""),l.dataTransfer.dropEffect="move",!1}dropHandler(l){l.preventDefault();let n=l.currentTarget,c=this.querySelector(`[identifier=${l.dataTransfer.getData("text")}`),p=c||this.shadowRoot.querySelector(`[identifier=${l.dataTransfer.getData("text")}`);return n?p.parentElement.getAttribute("identifier")!==n.getAttribute("identifier")&&n.appendChild(p):console.error(`cannot find droppable, target: ${l.target?JSON.stringify(l.target):"null"}`),n.removeAttribute("active"),!1}dragleaveHandler(l){return l.preventDefault(),l.currentTarget.removeAttribute("active"),!1}}return s([ei({type:Boolean,reflect:!0})],t.prototype,"disabled",2),t};var wt=(a,i,e)=>{class t extends a{}return t};import{property as K}from"lit/decorators.js";function At(a,i){let e,t=C({},i);return(r,o)=>{let{connectedCallback:l,disconnectedCallback:n}=r;r.connectedCallback=function(){var d;l.call(this);let c=m=>{let E=Array.from(this.querySelectorAll(a));for(let f of m){let V=Array.from(f.addedNodes).map(L=>L),h=Array.from(f.addedNodes).map(L=>L);f.type==="childList"&&V.find(L=>E.includes(L))&&this[o](V,h)}};e=new MutationObserver(c),e.observe(this,{childList:!0,subtree:!0});let p=(d=this.querySelectorAll(a))!=null?d:[];this[o](Array.from(p),[])},r.disconnectedCallback=function(){n.call(this),e.disconnect()}}}var R=(a,i,e,t)=>{class r extends wt(kt(a,e,t),t,i){constructor(){super(...arguments);this.draggables=new Map;this.responseIdentifier="";this.configuration={copyStylesDragClone:!0,dragCanBePlacedBack:!0,dragOnClick:!1};this.disabled=!1;this.readonly=!1;this.minAssociations=1;this.maxAssociations=1}reInitDragAndDrop(n,c){if(this.classList.contains("qti-match-tabular"))return;n.filter(d=>!this.draggables||!this.draggables.get(d)).length>0&&(this.dragDropApi.addDraggables(n),n.forEach(d=>{this.draggables.set(d,{parent:d.parentElement,index:Array.from(d.parentNode.children).indexOf(d)}),d.setAttribute("qti-draggable","true"),d.addEventListener("dragstart",m=>{m.dataTransfer.setData("text",m.currentTarget.getAttribute("identifier")),d.setAttribute("dragging","")}),d.addEventListener("dragend",m=>{if(m.preventDefault(),d.removeAttribute("over"),d.removeAttribute("dragging"),m.dataTransfer.dropEffect==="none"&&this.configuration.dragCanBePlacedBack){let E=m.currentTarget,f=this.draggables.get(E),V=f.index<f.parent.children.length?f.index:f.parent.children.length-1,h=f.parent,L=f.parent.children[V];h.insertBefore(E,L),this.saveResponse(),this.checkMaxMatchAssociations()}m.dataTransfer.dropEffect==="move"&&(this.saveResponse(),this.checkMaxMatchAssociations())})}))}handleDragOptionsChanged(n,c){this.dragDropApi.copyStylesDragClone=c.copyStylesDragClone,this.dragDropApi.dragOnClick=c.dragOnClick}handleDisabledChange(n,c){this.draggables.forEach((p,d)=>{c?d.setAttribute("disabled",""):d.removeAttribute("disabled"),c?d.removeAttribute("qti-draggable"):d.setAttribute("qti-draggable","true")})}handleReadonlyChange(n,c){this.draggables.forEach((p,d)=>{c?d.setAttribute("readonly",""):d.removeAttribute("readonly"),c?d.removeAttribute("qti-draggable"):d.setAttribute("qti-draggable","true")})}firstUpdated(n){super.firstUpdated(n),this.droppables=Array.from(e?this.shadowRoot.querySelectorAll(t):this.querySelectorAll(t))}connectedCallback(){super.connectedCallback(),this.dragDropApi=new H,this.dispatchEvent(new CustomEvent("qti-register-interaction",{bubbles:!0,composed:!0,detail:this}))}reset(n=!0){this.draggables.forEach((c,p)=>{let d=c.parent.children,m=c.index<d.length?c.index:d.length;c.parent.insertBefore(p,d[m])}),n&&this.saveResponse()}checkMaxMatchAssociations(){this.droppables.forEach(n=>{let p=+(n.getAttribute("match-max")||1)<=(n.children.length||0);p?n.setAttribute("disabled",""):n.removeAttribute("disabled"),p?n.removeAttribute("dropzone"):n.setAttribute("dropzone","move")})}set response(n){this.classList.contains("qti-match-tabular")||(this.reset(!1),n!==null&&Array.isArray(n)&&n.forEach(c=>{let[p,...d]=c.split(" ").reverse();if(p){let m=this.droppables.find(E=>E.getAttribute("identifier")===p);d.forEach(E=>{let f=this.querySelector(`[identifier=${E}]`);m?f?(m.appendChild(f),this.checkMaxMatchAssociations()):console.error(`cannot find draggable with identifier: ${E}`):console.error(`cannot find droppable with identifier: ${p}`)})}}))}validate(){let c=(e?Array.from(this.shadowRoot.querySelectorAll(t)):Array.from(this.querySelectorAll(t))).filter(p=>p.childElementCount>0).length;return this.minAssociations<=0||this.minAssociations<=c}saveResponse(){let n=this.droppables.map(c=>{var d;let p="";return((d=c.children)==null?void 0:d.length)>0&&(p+=Array.from(c.children).map(m=>m.getAttribute("identifier")).join(" ")+" "),p+=c.getAttribute("identifier"),p});this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,composed:!0,detail:{responseIdentifier:this.responseIdentifier,response:n}}))}}return s([At(i)],r.prototype,"reInitDragAndDrop",1),s([K({type:String,attribute:"response-identifier"})],r.prototype,"responseIdentifier",2),s([K({attribute:!1,type:Object})],r.prototype,"configuration",2),s([g("configuration")],r.prototype,"handleDragOptionsChanged",1),s([K({type:Boolean,reflect:!0})],r.prototype,"disabled",2),s([g("disabled",{waitUntilFirstUpdate:!0})],r.prototype,"handleDisabledChange",1),s([K({type:Boolean,reflect:!0})],r.prototype,"readonly",2),s([g("readonly",{waitUntilFirstUpdate:!0})],r.prototype,"handleReadonlyChange",1),s([K({type:Number,reflect:!0,attribute:"min-associations"})],r.prototype,"minAssociations",2),s([K({type:Number,reflect:!0,attribute:"max-associations"})],r.prototype,"maxAssociations",2),r};import{state as ii}from"lit/decorators.js";var ee=class extends R(ti,"qti-simple-associable-choice",!0,".dl"){render(){return Rt` <slot name="prompt"></slot>
224
+ </div>`}`}};customElements.define("qti-portable-custom-interaction",tt);import{LitElement as ti,css as ri,html as wt}from"lit";var H=class{constructor(){this._touchBegin=0;this._touchDown=null;this._lastClick=0;this._canDrag=!1;this._dragSrc=null;this._dragCopy=null;this._touchEndCalled=!1;this._dragRunning=!1;this._dataTransfer={data:{},setData:function(i,e){this.data[i]=e},getData:function(i){return this.data[i]},effectAllowed:"move"};this._copyOffset={x:0,y:0};this._lastTarget=null;this._currentDropContainer=null;this._handleClick=!0;this._DBLCLICKDELAY=500;this._CONTEXTMENUDELAY=1e3;this._DRAGDELTA=5;this._COPYOPACITY=.7;this.copyStylesDragClone=!0;this.dragOnClick=!1;this._createDragCopy=(i,e)=>{if(this._dragCopy===null&&this._dragRunning){this._dragSrc.style.opacity=this._COPYOPACITY,this._dragCopy=this._dragSrc.cloneNode(!0);let t=window.getComputedStyle(this._dragSrc);if(this._dragCopy.style="",this._dragCopy.setAttribute("dragclone",""),this.copyStylesDragClone)for(let r of t)this._dragCopy.style[r]=t.getPropertyValue(r);this._calculateDragCopyPosition(e),this._dragCopy.style.top=e.clientY-this._copyOffset.y+"px",this._dragCopy.style.left=e.clientX-this._copyOffset.x+"px",this._dragCopy.style.position="fixed",this._dragCopy.style.pointerEvents="none",this._dragCopy.style.zIndex="999999",this._dragCopy=document.body.appendChild(this._dragCopy),this._dispatchEvent(this._dragSrc,"dragstart")}if(this._dragRunning){let t=this;requestAnimationFrame(function(){t._touchEndCalled||t._dragCopy===null||(t._dragCopy.style.top=e.clientY-t._copyOffset.y+"px",t._dragCopy.style.left=e.clientX-t._copyOffset.x+"px")});let r=this._findDroppable(i);r!=this._lastTarget&&(this._dispatchEvent(r,"dragenter"),this._dispatchEvent(this._lastTarget,"dragleave"),this._lastTarget=r),this._currentDropContainer=r,this._currentDropContainer&&this._dispatchEvent(r,"dragover")}};return H._instance?H._instance:(H._instance=this,document.addEventListener("touchmove",this._touchMove.bind(this),{passive:!1,capture:!1}),document.addEventListener("mousemove",this._touchMove.bind(this),{passive:!1,capture:!1}),document.addEventListener("touchend",this._touchEnd.bind(this),{passive:!1,capture:!1}),document.addEventListener("mouseup",this._touchEnd.bind(this),{passive:!1,capture:!1}),document.addEventListener("touchcancel",this._touchCancel.bind(this),{passive:!1,capture:!1}),this)}addDraggables(i){i.forEach(e=>{e.addEventListener("touchstart",this._touchStart.bind(this),{passive:!1,capture:!1}),e.addEventListener("mousedown",this._touchStart.bind(this),{passive:!1,capture:!1})})}_touchStart(i){this._touchBegin=Date.now();let{x:e,y:t}=this._getPositionFromEvent(i);if(this._touchDown={x:e,y:t},this._dragSrc=i.currentTarget,this._canDrag=!0,this.dragOnClick){let r={clientX:e,clientY:t};this._dragRunning=!0,this._createDragCopy(i,r)}i.preventDefault()}_touchMove(i){if(this._canDrag&&this._dragSrc){let{x:e,y:t}=this._getPositionFromEvent(i),r={clientX:e,clientY:t};this._getDelta(r)>=this._DRAGDELTA&&(this._dragRunning=!0),this._createDragCopy(i,r),i.preventDefault()}}_touchEnd(i){var e;if(this._touchEndCalled=!0,this._canDrag=!1,this._currentDropContainer)this._dispatchEvent(this._currentDropContainer,"drop"),this._dispatchEvent(this._dragSrc,"dragend");else if(this._dragRunning){let t=new CustomEvent("dragend",{bubbles:!0,cancelable:!0});t.dataTransfer={dropEffect:"none"},(e=this._dragSrc)==null||e.dispatchEvent(t)}this._reset()}_touchCancel(i){this._reset()}_findDroppable(i){let e,t=i.composedPath().find(r=>{if(r.nodeType===1&&r.nodeName!=="SLOT"&&r.hasAttribute("dropzone"))return r});if(t){let r=t.getRootNode(),o=this._getPoint(i);e=r.elementFromPoint(o.x,o.y)}return e}_getPoint(i,e){return i&&i.touches&&(i=i.touches[0]),{x:e?i.pageX:i.clientX,y:e?i.pageY:i.clientY}}_calculateDragCopyPosition(i){let e=this._dragSrc.getBoundingClientRect();this._copyOffset.x=i.clientX-e.left,this._copyOffset.y=i.clientY-e.top}_getDelta(i){let e=Math.abs(i.clientX-this._touchDown.x),t=Math.abs(i.clientY-this._touchDown.y);return e+t}_dispatchEvent(i,e,t=!0){if(!i)return!1;let r=new CustomEvent(e,{bubbles:t,cancelable:!0});return r.dataTransfer=this._dataTransfer,i.dispatchEvent(r),r.defaultPrevented}_reset(){this._dragRunning&&(this._dragSrc.style.opacity="1.0",this._dragCopy.parentElement.removeChild(this._dragCopy)),this._dragRunning=!1,this._dragSrc=null,this._dragCopy=null,this._canDrag=!1,this._touchBegin=0,this._touchDown=null,this._lastClick=0,this._touchEndCalled=!1,this._dataTransfer={data:{},setData:function(i,e){this.data[i]=e},getData:function(i){return this.data[i]},effectAllowed:"move"},this._copyOffset={x:0,y:0},this._lastTarget=null,this._currentDropContainer=null,this._handleClick=!0}_getPositionFromEvent(i){let e;if(i.type=="touchstart"||i.type=="touchmove"||i.type=="touchend"||i.type=="touchcancel"){let t=typeof i.originalEvent=="undefined"?i:i.originalEvent,r=t.touches[0]||t.changedTouches[0];e={x:r.pageX,y:r.pageY}}else(i.type=="mousedown"||i.type=="mouseup"||i.type=="mousemove"||i.type=="mouseover"||i.type=="mouseout"||i.type=="mouseenter"||i.type=="mouseleave")&&(e={x:i.clientX,y:i.clientY});return e}};import{property as ei}from"lit/decorators.js";var _t=(a,i,e)=>{class t extends a{constructor(){super(...arguments);this.disabled=!1}firstUpdated(n){if(this.classList.contains("qti-match-tabular"))return;super.firstUpdated(n);let l=Array.from(i?this.shadowRoot.querySelectorAll(e):this.querySelectorAll(e));this.dragoverHandler=this.dragoverHandler.bind(this),this.dragleaveHandler=this.dragleaveHandler.bind(this),this.dropHandler=this.dropHandler.bind(this),l.forEach(c=>{c.setAttribute("dropzone","move"),c.addEventListener("dragleave",this.dragleaveHandler),this.attachHandler(c)});for(let c of l)this.observer=new MutationObserver(p=>{p.forEach(d=>{if(d.type==="attributes")switch(d.attributeName){case"disabled":{c.hasAttribute("disabled")?this.removeHandler(c):this.attachHandler(c);break}}})}),this.observer.observe(c,{attributes:!0})}attachHandler(n){n.addEventListener("dragover",this.dragoverHandler),n.addEventListener("drop",this.dropHandler)}removeHandler(n){n.removeEventListener("dragover",this.dragoverHandler),n.removeEventListener("drop",this.dropHandler)}disconnectedCallback(){var n;this.classList.contains("qti-match-tabular")||(super.disconnectedCallback(),(n=this.observer)==null||n.disconnect())}dragoverHandler(n){return n.preventDefault(),n.currentTarget.setAttribute("active",""),n.dataTransfer.dropEffect="move",!1}dropHandler(n){n.preventDefault();let l=n.currentTarget,c=this.querySelector(`[identifier=${n.dataTransfer.getData("text")}`),p=c||this.shadowRoot.querySelector(`[identifier=${n.dataTransfer.getData("text")}`);return l?p.parentElement.getAttribute("identifier")!==l.getAttribute("identifier")&&l.appendChild(p):console.error(`cannot find droppable, target: ${n.target?JSON.stringify(n.target):"null"}`),l.removeAttribute("active"),!1}dragleaveHandler(n){return n.preventDefault(),n.currentTarget.removeAttribute("active"),!1}}return s([ei({type:Boolean,reflect:!0})],t.prototype,"disabled",2),t};var kt=(a,i,e)=>{class t extends a{}return t};import{property as j}from"lit/decorators.js";function At(a,i){let e,t=C({},i);return(r,o)=>{let{connectedCallback:n,disconnectedCallback:l}=r;r.connectedCallback=function(){var d;n.call(this);let c=m=>{let x=Array.from(this.querySelectorAll(a));for(let b of m){let P=Array.from(b.addedNodes).map(L=>L),h=Array.from(b.addedNodes).map(L=>L);b.type==="childList"&&P.find(L=>x.includes(L))&&this[o](P,h)}};e=new MutationObserver(c),e.observe(this,{childList:!0,subtree:!0});let p=(d=this.querySelectorAll(a))!=null?d:[];this[o](Array.from(p),[])},r.disconnectedCallback=function(){l.call(this),e.disconnect()}}}var R=(a,i,e,t)=>{class r extends kt(_t(a,e,t),t,i){constructor(){super(...arguments);this.draggables=new Map;this.responseIdentifier="";this.configuration={copyStylesDragClone:!0,dragCanBePlacedBack:!0,dragOnClick:!1};this.disabled=!1;this.readonly=!1;this.minAssociations=1;this.maxAssociations=1}reInitDragAndDrop(l,c){if(this.classList.contains("qti-match-tabular"))return;l.filter(d=>!this.draggables||!this.draggables.get(d)).length>0&&(this.dragDropApi.addDraggables(l),l.forEach(d=>{this.draggables.set(d,{parent:d.parentElement,index:Array.from(d.parentNode.children).indexOf(d)}),d.setAttribute("qti-draggable","true"),d.addEventListener("dragstart",m=>{m.dataTransfer.setData("text",m.currentTarget.getAttribute("identifier")),d.setAttribute("dragging","")}),d.addEventListener("dragend",m=>{if(m.preventDefault(),d.removeAttribute("over"),d.removeAttribute("dragging"),m.dataTransfer.dropEffect==="none"&&this.configuration.dragCanBePlacedBack){let x=m.currentTarget,b=this.draggables.get(x),P=b.index<b.parent.children.length?b.index:b.parent.children.length-1,h=b.parent,L=b.parent.children[P];h.insertBefore(x,L),this.saveResponse(),this.checkMaxMatchAssociations()}m.dataTransfer.dropEffect==="move"&&(this.saveResponse(),this.checkMaxMatchAssociations())})}))}handleDragOptionsChanged(l,c){this.dragDropApi.copyStylesDragClone=c.copyStylesDragClone,this.dragDropApi.dragOnClick=c.dragOnClick}handleDisabledChange(l,c){this.draggables.forEach((p,d)=>{c?d.setAttribute("disabled",""):d.removeAttribute("disabled"),c?d.removeAttribute("qti-draggable"):d.setAttribute("qti-draggable","true")})}handleReadonlyChange(l,c){this.draggables.forEach((p,d)=>{c?d.setAttribute("readonly",""):d.removeAttribute("readonly"),c?d.removeAttribute("qti-draggable"):d.setAttribute("qti-draggable","true")})}firstUpdated(l){super.firstUpdated(l),this.droppables=Array.from(e?this.shadowRoot.querySelectorAll(t):this.querySelectorAll(t))}connectedCallback(){super.connectedCallback(),this.dragDropApi=new H,this.dispatchEvent(new CustomEvent("qti-register-interaction",{bubbles:!0,composed:!0,detail:this}))}reset(l=!0){this.draggables.forEach((c,p)=>{let d=c.parent.children,m=c.index<d.length?c.index:d.length;c.parent.insertBefore(p,d[m])}),l&&this.saveResponse()}checkMaxMatchAssociations(){this.droppables.forEach(l=>{let p=+(l.getAttribute("match-max")||1)<=(l.children.length||0);p?l.setAttribute("disabled",""):l.removeAttribute("disabled"),p?l.removeAttribute("dropzone"):l.setAttribute("dropzone","move")})}set response(l){this.classList.contains("qti-match-tabular")||(this.reset(!1),l!==null&&Array.isArray(l)&&l.forEach(c=>{let[p,...d]=c.split(" ").reverse();if(p){let m=this.droppables.find(x=>x.getAttribute("identifier")===p);d.forEach(x=>{let b=this.querySelector(`[identifier=${x}]`);m?b?(m.appendChild(b),this.checkMaxMatchAssociations()):console.error(`cannot find draggable with identifier: ${x}`):console.error(`cannot find droppable with identifier: ${p}`)})}}))}validate(){let c=(e?Array.from(this.shadowRoot.querySelectorAll(t)):Array.from(this.querySelectorAll(t))).filter(p=>p.childElementCount>0).length;return this.minAssociations<=0||this.minAssociations<=c}saveResponse(){let l=this.droppables.map(c=>{var d;let p="";return((d=c.children)==null?void 0:d.length)>0&&(p+=Array.from(c.children).map(m=>m.getAttribute("identifier")).join(" ")+" "),p+=c.getAttribute("identifier"),p});this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,composed:!0,detail:{responseIdentifier:this.responseIdentifier,response:l}}))}}return s([At(i)],r.prototype,"reInitDragAndDrop",1),s([j({type:String,attribute:"response-identifier"})],r.prototype,"responseIdentifier",2),s([j({attribute:!1,type:Object})],r.prototype,"configuration",2),s([g("configuration")],r.prototype,"handleDragOptionsChanged",1),s([j({type:Boolean,reflect:!0})],r.prototype,"disabled",2),s([g("disabled",{waitUntilFirstUpdate:!0})],r.prototype,"handleDisabledChange",1),s([j({type:Boolean,reflect:!0})],r.prototype,"readonly",2),s([g("readonly",{waitUntilFirstUpdate:!0})],r.prototype,"handleReadonlyChange",1),s([j({type:Number,reflect:!0,attribute:"min-associations"})],r.prototype,"minAssociations",2),s([j({type:Number,reflect:!0,attribute:"max-associations"})],r.prototype,"maxAssociations",2),r};import{state as ii}from"lit/decorators.js";var ee=class extends R(ti,"qti-simple-associable-choice",!0,".dl"){render(){return wt` <slot name="prompt"></slot>
221
225
  <slot name="qti-simple-associable-choice"></slot>
222
- ${this._childrenMap.length>0&&Array.from(Array(Math.ceil(this._childrenMap.length/2)).keys()).map((e,t)=>Rt`<div part="associables-container">
223
- <slot name="left${t}" part="drop-list" class="dl" identifier="droplist${t}_left"></slot>
224
- <slot name="right${t}" part="drop-list" class="dl" identifier="droplist${t}_right"></slot>
226
+ ${this._childrenMap.length>0&&Array.from(Array(Math.ceil(this._childrenMap.length/2)).keys()).map((e,t)=>wt`<div part="associables-container">
227
+ <div name="left${t}" part="drop-list" class="dl" identifier="droplist${t}_left"></div>
228
+ <div name="right${t}" part="drop-list" class="dl" identifier="droplist${t}_right"></div>
225
229
  </div>`)}`}connectedCallback(){super.connectedCallback(),this._childrenMap=Array.from(this.querySelectorAll("qti-simple-associable-choice"))}};ee.styles=ri`
226
230
  :host {
227
231
  display: block; /* necessary to calculate scaling position */
@@ -231,11 +235,8 @@ import{a as g,b as ie}from"../chunk-DLLHO3W2.js";import{a as C,b as P,c as s}fro
231
235
  flex-wrap: wrap;
232
236
  gap: 0.5rem;
233
237
  }
234
- `,s([ii()],ee.prototype,"_childrenMap",2);customElements.define("qti-associate-interaction",ee);import{html as si,LitElement as oi}from"lit";var tt=class extends oi{connectedCallback(){super.connectedCallback(),this.setAttribute("slot","qti-simple-associable-choice"),this.setAttribute("part","qti-simple-associable-choice")}render(){return si`
235
- <slot></slot>
236
- <slot name="qti-simple-associable-choice"></slot>
237
- `}};customElements.define("qti-simple-associable-choice",tt);import{css as ni,html as ai,LitElement as li}from"lit";var ve=class extends R(li,"qti-gap-text",!1,"qti-gap"){render(){return ai` <slot part="drags" name="qti-gap-text"></slot>
238
- <slot part="drops"></slot>`}};ve.styles=[ni`
238
+ `,s([ii()],ee.prototype,"_childrenMap",2);customElements.define("qti-associate-interaction",ee);import{css as si,html as oi,LitElement as ni}from"lit";var be=class extends R(ni,"qti-gap-text",!1,"qti-gap"){render(){return oi` <slot part="drags" name="qti-gap-text"></slot>
239
+ <slot part="drops"></slot>`}};be.styles=[si`
239
240
  :host {
240
241
  display: flex;
241
242
  align-items: flex-start;
@@ -258,14 +259,39 @@ import{a as g,b as ie}from"../chunk-DLLHO3W2.js";import{a as C,b as P,c as s}fro
258
259
  align-items: flex-start;
259
260
  flex: 1;
260
261
  }
261
- `];customElements.define("qti-gap-match-interaction",ve);import{html as ci,LitElement as pi}from"lit";import{property as di}from"lit/decorators.js";var ye=class extends pi{constructor(){super(...arguments);this.tabindex=0}connectedCallback(){super.connectedCallback(),this.setAttribute("slot","qti-gap-text")}render(){return ci`<slot></slot>`}};s([di({type:Number,reflect:!0})],ye.prototype,"tabindex",2);customElements.define("qti-gap-text",ye);import{html as ui,LitElement as mi}from"lit";import{property as hi}from"lit/decorators.js";var xe=class extends mi{constructor(){super(...arguments);this.tabindex=0}render(){return ui` <slot name="qti-gap-text"></slot>`}};s([hi({type:Number,reflect:!0})],xe.prototype,"tabindex",2);customElements.define("qti-gap",xe);import{LitElement as fi}from"lit";var rt=class extends fi{};customElements.define("qti-inline-choice",rt);import{css as gi,html as bi}from"lit";function z(a,i,e,t){switch(a){case"circle":{let[r,o,l]=i,n=r/e.width*100,c=o/e.height*100,p=l/e.width*100;t.style.left=n-p+"%",t.style.top=c-p+"%",t.style.width=t.style.height=4*p+"px",t.style.borderRadius="9999px"}break;case"rect":{let[r,o,l,n]=i,c=r/e.width*100,p=o/e.height*100,d=l/e.width*100,m=n/e.height*100;t.style.left=c+"%",t.style.top=p+"%",t.style.width=d-c+"%",t.style.height=m-p+"%"}break;case"poly":{let r=i.reduce((h,L,nt,St)=>{if(nt%2===1){let Mt=h.pop();h[h.length]={x:Mt,y:St[nt]}}else h.push(L);return h},[]),o=Math.min(...r.map(h=>h.x)),l=Math.max(...r.map(h=>h.x)),n=Math.min(...r.map(h=>h.y)),c=Math.max(...r.map(h=>h.y)),p=o/e.width*100,d=n/e.height*100,m=l/e.width*100,E=c/e.height*100;t.style.left=o/e.width*100+"%",t.style.top=n/e.height*100+"%",t.style.width=m-p+"%",t.style.height=E-d+"%";let V=r.map(h=>({x:(h.x-o)/(l-o)*100,y:(h.y-n)/(c-n)*100})).map(h=>Math.round(h.x)+"% "+Math.round(h.y)+"%").join(",");t.style.clipPath=`polygon(${V})`}break;default:break}}var Ee=class extends v{render(){return bi`
262
- <slot name="prompt"></slot>
263
- <!-- slot for the prompt -->
264
- <slot></slot>
265
- <!-- slot for the image and hotspots -->
266
- `}positionHotspotOnRegister(e){let t=this.querySelector("img"),r=e.target,o=r.getAttribute("coords"),l=r.getAttribute("shape"),n=o.split(",").map(c=>parseInt(c));z(l,n,t,r)}connectedCallback(){super.connectedCallback(),this.addEventListener("qti-register-hotspot",this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-register-hotspot",this.positionHotspotOnRegister)}};Ee.styles=[gi`
262
+ `];customElements.define("qti-gap-match-interaction",be);import{css as ai,svg as Rt,html as li}from"lit";function z(a,i,e,t){switch(a){case"circle":{let[r,o,n]=i,l=r/e.width*100,c=o/e.height*100,p=n/e.width*100;t.style.left=l-p+"%",t.style.top=c-p+"%",t.style.width=t.style.height=4*p+"px",t.style.borderRadius="9999px"}break;case"rect":{let[r,o,n,l]=i,c=r/e.width*100,p=o/e.height*100,d=n/e.width*100,m=l/e.height*100;t.style.left=c+"%",t.style.top=p+"%",t.style.width=d-c+"%",t.style.height=m-p+"%"}break;case"poly":{let r=i.reduce((h,L,ot,Ht)=>{if(ot%2===1){let Ot=h.pop();h[h.length]={x:Ot,y:Ht[ot]}}else h.push(L);return h},[]),o=Math.min(...r.map(h=>h.x)),n=Math.max(...r.map(h=>h.x)),l=Math.min(...r.map(h=>h.y)),c=Math.max(...r.map(h=>h.y)),p=o/e.width*100,d=l/e.height*100,m=n/e.width*100,x=c/e.height*100;t.style.left=o/e.width*100+"%",t.style.top=l/e.height*100+"%",t.style.width=m-p+"%",t.style.height=x-d+"%";let P=r.map(h=>({x:(h.x-o)/(n-o)*100,y:(h.y-l)/(c-l)*100})).map(h=>Math.round(h.x)+"% "+Math.round(h.y)+"%").join(",");t.style.clipPath=`polygon(${P})`}break;default:break}}import{query as ci,queryAssignedElements as pi,state as rt}from"lit/decorators.js";import{repeat as di}from"lit/directives/repeat.js";import{ifDefined as Lt}from"lit/directives/if-defined.js";var M=class extends f{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 response(e){Array.isArray(e)&&(this._lines=e)}render(){var e,t,r,o;return li`<slot name="prompt"></slot>
263
+ <line-container>
264
+ <svg
265
+ width=${Lt((e=this.grImage[0])==null?void 0:e.width)}
266
+ height=${Lt((t=this.grImage[0])==null?void 0:t.height)}
267
+ viewbox="0 0 ${(r=this.grImage[0])==null?void 0:r.width} ${(o=this.grImage[0])==null?void 0:o.height}"
268
+ >
269
+ ${di(this._lines,n=>n,(n,l)=>Rt`
270
+ <line
271
+ part="line"
272
+ x1=${parseInt(this.querySelector("[identifier="+n.split(" ")[0]+"]").style.left)}
273
+ y1=${parseInt(this.querySelector("[identifier="+n.split(" ")[0]+"]").style.top)}
274
+ x2=${parseInt(this.querySelector("[identifier="+n.split(" ")[1]+"]").style.left)}
275
+ y2=${parseInt(this.querySelector("[identifier="+n.split(" ")[1]+"]").style.top)}
276
+ stroke="red"
277
+ stroke-width="3"
278
+ @click=${c=>{c.stopPropagation(),this._lines=this._lines.filter((p,d)=>d!==l),this.saveResponse(this._lines)}}
279
+ />
280
+ `)}
281
+ ${this.startPoint&&Rt`<line
282
+ part="point"
283
+ x1=${this.startCoord.x}
284
+ y1=${this.startCoord.y}
285
+ x2=${this.mouseCoord.x}
286
+ y2=${this.mouseCoord.y}
287
+ stroke="red"
288
+ stroke-width="3"
289
+ />`}
290
+ </svg>
291
+ <slot></slot>
292
+ </line-container>`}positionHotspotOnRegister(e){let t=this.querySelector("img"),r=e.target,o=r.getAttribute("coords"),n=r.getAttribute("shape"),l=o.split(",").map(c=>parseInt(c));z(n,l,t,r)}firstUpdated(e){super.firstUpdated(e),this.hotspots=document.querySelectorAll("qti-associable-hotspot"),document.addEventListener("mousemove",t=>{this.mouseCoord={x:t.clientX-this.grImage[0].getBoundingClientRect().left,y:t.clientY-this.grImage[0].getBoundingClientRect().top}}),this.hotspots.forEach(t=>{t.style.left=t.getAttribute("coords").split(",")[0]+"px",t.style.top=t.getAttribute("coords").split(",")[1]+"px",t.addEventListener("click",r=>{this.startPoint?this.endPoint||(this.endPoint=r.target,this._lines=[...this._lines,this.startPoint.getAttribute("identifier")+" "+this.endPoint.getAttribute("identifier")],this.saveResponse(this._lines),this.startPoint=null,this.endPoint=null):(this.startPoint=r.target,this.startCoord={x:this.startPoint.getAttribute("coords").split(",")[0],y:this.startPoint.getAttribute("coords").split(",")[1]})})})}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-register-hotspot",this.positionHotspotOnRegister)}};M.styles=[ai`
267
293
  slot:not([name='prompt']) {
268
- position: relative; /* qti-hotspot-choice relative to the slot */
294
+ // position: relative; /* qti-hotspot-choice relative to the slot */
269
295
  display: block;
270
296
  width: fit-content; /* hotspots not stretching further if image is at max size */
271
297
  }
@@ -274,22 +300,34 @@ import{a as g,b as ie}from"../chunk-DLLHO3W2.js";import{a as C,b as P,c as s}fro
274
300
  pointer-events: none;
275
301
  user-select: none;
276
302
  }
277
- `];customElements.define("qti-graphic-associate-interaction",Ee);import{css as vi,html as yi,LitElement as xi}from"lit";var Ce=class extends R(xi,"qti-gap-img",!1,"qti-associable-hotspot"){render(){return yi` <slot></slot>
278
- <slot name="qti-gap-img"></slot>`}positionHotspotOnRegister(i){let e=i.target,t=e.getAttribute("coords"),r=e.getAttribute("shape"),o=t.split(",").map(l=>parseInt(l));switch(r){case"circle":{let[l,n,c]=o;e.style.left=l-c+"px",e.style.top=n-c+"px",e.style.width=e.style.height=2*c+"px"}break;case"rect":{let[l,n,c,p]=o;e.style.left=l+"px",e.style.top=n+"px",e.style.width=c-l+"px",e.style.height=p-n+"px"}break;default:break}}connectedCallback(){super.connectedCallback(),this.addEventListener("qti-register-hotspot",this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-register-hotspot",this.positionHotspotOnRegister)}};Ce.styles=vi`
303
+ ::slotted(qti-associable-hotspot) {
304
+ transform: translate(-50%, -50%);
305
+ }
306
+ line-container {
307
+ display: block;
308
+ position: relative;
309
+ }
310
+ svg {
311
+ position: absolute;
312
+ top: 0px;
313
+ left: 0px;
314
+ }
315
+ `],s([rt()],M.prototype,"_lines",2),s([rt()],M.prototype,"startCoord",2),s([rt()],M.prototype,"mouseCoord",2),s([ci("svg")],M.prototype,"svgContainer",2),s([pi({selector:"img"})],M.prototype,"grImage",2);customElements.define("qti-graphic-associate-interaction",M);import{css as ui,html as mi,LitElement as hi}from"lit";var ve=class extends R(hi,"qti-gap-img",!1,"qti-associable-hotspot"){render(){return mi` <slot></slot>
316
+ <slot name="qti-gap-img"></slot>`}positionHotspotOnRegister(i){let e=this.querySelector("img"),t=i.target,r=t.getAttribute("coords"),o=t.getAttribute("shape"),n=r.split(",").map(l=>parseInt(l));switch(o){case"circle":{let[l,c,p]=n;t.style.left=l-p+"px",t.style.top=c-p+"px",t.style.width=t.style.height=2*p+"px"}break;case"rect":{let[l,c,p,d]=n;t.style.left=l+"px",t.style.top=c+"px",t.style.width=p-l+"px",t.style.height=d-c+"px"}break;default:break}}connectedCallback(){super.connectedCallback(),this.addEventListener("qti-register-hotspot",this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-register-hotspot",this.positionHotspotOnRegister)}};ve.styles=ui`
279
317
  :host {
280
- display: block;
318
+ display: inline-block;
281
319
  position: relative;
282
320
  }
283
321
  slot[name='qti-gap-img'] {
284
322
  display: flex;
285
323
  gap: 1rem;
286
324
  }
287
- `;customElements.define("qti-graphic-gap-match-interaction",Ce);import{css as Ei,html as Ci}from"lit";var qe=class extends v{render(){return Ci`
325
+ `;customElements.define("qti-graphic-gap-match-interaction",ve);import{css as fi,html as gi}from"lit";var ye=class extends v{render(){return gi`
288
326
  <slot name="prompt"></slot>
289
327
  <!-- slot for the prompt -->
290
328
  <slot></slot>
291
329
  <!-- slot for the image and hotspots -->
292
- `}setHotspotOrder(e){let{identifier:t}=e.detail,r=this._choiceElements.find(l=>l.getAttribute("identifier")===t),o=this._choiceElements.length;if(!this.choiceOrdering){if(this.choiceOrdering=!0,r.order==null){if(this._choiceElements.filter(l=>l.order>0).length>=o){this.choiceOrdering=!1;return}r.order=this._choiceElements.filter(l=>!!l.order).length+1,this.choiceOrdering=!1;return}else this._choiceElements.forEach(l=>(l.order>l.order&&l.order--,l)),r.order=null;this.choiceOrdering=!1}}positionHotspotOnRegister(e){let t=this.querySelector("img"),r=e.target,o=r.getAttribute("coords"),l=r.getAttribute("shape"),n=o.split(",").map(c=>parseInt(c));z(l,n,t,r)}connectedCallback(){super.connectedCallback(),this.addEventListener("qti-choice-element-selected",this.setHotspotOrder),this.addEventListener("qti-register-choice",this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-choice-element-selected",this.setHotspotOrder),this.removeEventListener("qti-register-choice",this.positionHotspotOnRegister)}};qe.styles=[Ei`
330
+ `}setHotspotOrder(e){let{identifier:t}=e.detail,r=this._choiceElements.find(n=>n.getAttribute("identifier")===t),o=this._choiceElements.length;if(!this.choiceOrdering){if(this.choiceOrdering=!0,r.order==null){if(this._choiceElements.filter(n=>n.order>0).length>=o){this.choiceOrdering=!1;return}r.order=this._choiceElements.filter(n=>!!n.order).length+1,this.choiceOrdering=!1;return}else this._choiceElements.forEach(n=>(n.order>n.order&&n.order--,n)),r.order=null;this.choiceOrdering=!1}}positionHotspotOnRegister(e){let t=this.querySelector("img"),r=e.target,o=r.getAttribute("coords"),n=r.getAttribute("shape"),l=o.split(",").map(c=>parseInt(c));z(n,l,t,r)}connectedCallback(){super.connectedCallback(),this.addEventListener("qti-choice-element-selected",this.setHotspotOrder),this.addEventListener("qti-register-choice",this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-choice-element-selected",this.setHotspotOrder),this.removeEventListener("qti-register-choice",this.positionHotspotOnRegister)}};ye.styles=[fi`
293
331
  slot:not([name='prompt']) {
294
332
  position: relative; /* qti-hotspot-choice relative to the slot */
295
333
  display: block;
@@ -300,12 +338,12 @@ import{a as g,b as ie}from"../chunk-DLLHO3W2.js";import{a as C,b as P,c as s}fro
300
338
  pointer-events: none;
301
339
  user-select: none;
302
340
  }
303
- `];customElements.define("qti-graphic-order-interaction",qe);import{css as qi,html as _i}from"lit";var _e=class extends v{render(){return _i`
341
+ `];customElements.define("qti-graphic-order-interaction",ye);import{css as bi,html as vi}from"lit";var Ee=class extends v{render(){return vi`
304
342
  <slot name="prompt"></slot>
305
343
  <!-- slot for the prompt -->
306
344
  <slot></slot>
307
345
  <!-- slot for the image and hotspots -->
308
- `}positionHotspotOnRegister(i){let e=this.querySelector("img"),t=i.target,r=t.getAttribute("coords"),o=t.getAttribute("shape"),l=r.split(",").map(n=>parseInt(n));z(o,l,e,t)}connectedCallback(){super.connectedCallback(),this.addEventListener("qti-register-choice",this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-register-choice",this.positionHotspotOnRegister)}};_e.styles=[qi`
346
+ `}positionHotspotOnRegister(i){let e=this.querySelector("img"),t=i.target,r=t.getAttribute("coords"),o=t.getAttribute("shape"),n=r.split(",").map(l=>parseInt(l));z(o,n,e,t)}connectedCallback(){super.connectedCallback(),this.addEventListener("qti-register-choice",this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-register-choice",this.positionHotspotOnRegister)}};Ee.styles=[bi`
309
347
  slot:not([name='prompt']) {
310
348
  position: relative; /* qti-hotspot-choice relative to the slot */
311
349
  display: block;
@@ -317,19 +355,26 @@ import{a as g,b as ie}from"../chunk-DLLHO3W2.js";import{a as C,b as P,c as s}fro
317
355
  user-select: none;
318
356
  /* width:100%; */
319
357
  }
320
- `];customElements.define("qti-hotspot-interaction",_e);import{css as ki}from"lit";import{property as wi}from"lit/decorators.js";var te=class extends y{};te.styles=ki`
321
- :host {
322
- position: absolute;
323
- }
324
- `,s([wi({attribute:"aria-ordervalue",type:Number,reflect:!0})],te.prototype,"order",2);customElements.define("qti-hotspot-choice",te);import{html as Ai,LitElement as Ri}from"lit";var ke=class extends R(Ri,"qti-simple-match-set:first-of-type qti-simple-associable-choice",!1,"qti-simple-match-set:last-of-type qti-simple-associable-choice"){render(){return Ai` <slot name="prompt"></slot>
325
- <slot></slot>`}};ke.styles=[];customElements.define("qti-match-interaction",ke);import{css as Ti,html as Li}from"lit";var we=class extends b{constructor(){super()}reset(){}validate(){return!0}set response(e){}static get properties(){return P(C({},b.properties),{step:{type:Number,attribute:"step",default:10}})}render(){return Li` <slot name="prompt"></slot>
326
- <slot></slot>`}connectedCallback(){super.connectedCallback()}};we.styles=[Ti``];customElements.define("qti-media-interaction",we);import{css as Si,html as Tt,LitElement as Mi}from"lit";import{property as Ni}from"lit/decorators.js";var j=class extends R(Mi,"qti-simple-choice",!0,"drop-list"){render(){return Tt` <slot name="prompt"> </slot>
358
+ `];customElements.define("qti-hotspot-interaction",Ee);import{html as te,LitElement as xi}from"lit";import{html as yi,LitElement as Ei}from"lit";var it=class extends Ei{connectedCallback(){super.connectedCallback(),this.setAttribute("slot","qti-simple-associable-choice"),this.setAttribute("part","qti-simple-associable-choice")}render(){return yi`
359
+ <slot></slot>
360
+ <slot name="qti-simple-associable-choice"></slot>
361
+ `}};customElements.define("qti-simple-associable-choice",it);var xe=class extends R(xi,"qti-simple-match-set:first-of-type qti-simple-associable-choice",!1,"qti-simple-match-set:last-of-type qti-simple-associable-choice"){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"))}render(){return this.classList.contains("qti-match-tabular")?te`<table>
362
+ <tr>
363
+ <td><slot name="prompt"></slot></td>
364
+ ${this.cols.map((e,t)=>te`<th>${e.innerHTML}</th>`)}
365
+ </tr>
366
+ ${this.rows.map(e=>te`<tr>
367
+ <td>${e.innerHTML}</td>
368
+ ${this.cols.map((t,r)=>te`<td><input type="checkbox" /></td>`)}
369
+ </tr>`)}
370
+ </table>`:te`<slot name="prompt"></slot> <slot></slot>`}};xe.styles=[];customElements.define("qti-match-interaction",xe);import{css as Ci,html as qi}from"lit";var Ce=class extends f{constructor(){super()}reset(){}validate(){return!0}set response(e){}static get properties(){return $(C({},f.properties),{step:{type:Number,attribute:"step",default:10}})}render(){return qi` <slot name="prompt"></slot>
371
+ <slot></slot>`}connectedCallback(){super.connectedCallback()}};Ce.styles=[Ci``];customElements.define("qti-media-interaction",Ce);import{css as _i,html as Tt,LitElement as ki}from"lit";import{property as Ai}from"lit/decorators.js";var G=class extends R(ki,"qti-simple-choice",!0,"drop-list"){render(){return Tt` <slot name="prompt"> </slot>
327
372
  <div part="container">
328
373
  <slot part="drags"> </slot>
329
374
  <div part="drops">
330
375
  ${Array.from(this.querySelectorAll("qti-simple-choice")).map((e,t)=>Tt`<drop-list part="drop-list" identifier="droplist${t}"></drop-list>`)}
331
376
  </div>
332
- </div>`}connectedCallback(){super.connectedCallback(),this.childrenMap=Array.from(this.querySelectorAll("qti-simple-choice")),this.childrenMap.forEach(e=>e.setAttribute("part","qti-simple-choice"))}};j.layoutClass=["qti-choices-top","qti-choices-bottom","qti-choices-left","qti-choices-right"],j.styles=[Si`
377
+ </div>`}connectedCallback(){super.connectedCallback(),this.childrenMap=Array.from(this.querySelectorAll("qti-simple-choice")),this.childrenMap.forEach(e=>e.setAttribute("part","qti-simple-choice"))}};G.layoutClass=["qti-choices-top","qti-choices-bottom","qti-choices-left","qti-choices-right"],G.styles=[_i`
333
378
  [part='drags'] {
334
379
  display: flex;
335
380
  align-items: flex-start;
@@ -377,31 +422,51 @@ import{a as g,b as ie}from"../chunk-DLLHO3W2.js";import{a as C,b as P,c as s}fro
377
422
  :host(.qti-choices-right) [part='container'] {
378
423
  flex-direction: row-reverse;
379
424
  }
380
- `],s([Ni({type:String})],j.prototype,"orientation",2);customElements.define("qti-order-interaction",j);import{html as Hi}from"lit";var Ae=class extends v{constructor(){super()}render(){return Hi`<slot></slot>
381
- <div class="notification"></div>`}connectedCallback(){super.connectedCallback()}disconnectedCallback(){super.disconnectedCallback()}};Ae.styles=[];customElements.define("qti-select-point-interaction",Ae);import{css as Oi,html as Di}from"lit";import{property as G,query as Lt}from"lit/decorators.js";var x=class extends b{constructor(){super(...arguments);this.stepLabel=!1;this.reverse=!1;this._handleDisabledChange=(e,t)=>{};this._handleReadonlyChange=(e,t)=>{}}set min(e){this._min=e,this.style.setProperty("--min",`${this._min}`)}get min(){return this._min}set max(e){this._max=e,this.style.setProperty("--max",`${this._max}`)}get max(){return this._max}set step(e){this._step=e,this.style.setProperty("--step",`${this._step}`)}get step(){return this._step}reset(){}validate(){return!0}set response(e){if(Array.isArray(e)){console.error("QtiSliderInteraction: response is an array, but should be a single value");return}let t=parseInt(e);if(Number.isNaN(t)){console.error("QtiSliderInteraction: response is not a number");return}this.value=t}render(){this.value<this.min&&(this.value=this.min),this.value>this.max&&(this.value=this.max);let e=(this.value-this.min)/(this.max-this.min)*100;return Di`<slot name="prompt"></slot>
382
- <div
383
- id="rail"
384
- @mousedown=${this._onMouseDown}
385
- @touchstart=${this._onTouchMove}
386
- part="rail"
387
- >
425
+ `],s([Ai({type:String})],G.prototype,"orientation",2);customElements.define("qti-order-interaction",G);import{LitElement as wi,css as Ri,html as Li}from"lit";var qe=class extends wi{render(){return Li`<slot></slot>`}};qe.styles=[Ri`
426
+ :host {
427
+ display: block;
428
+ }
429
+ ::slotted(img) {
430
+ position: absolute;
431
+ cursor: move;
432
+ user-select: none;
433
+ left: 50%;
434
+ transform: translateX(-50%);
435
+ }
436
+ `];customElements.define("qti-position-object-interaction",qe);import{LitElement as Ti,css as Si,html as Mi}from"lit";var _e=class extends Ti{constructor(){super();this.removeMoveListener=this.removeMoveListener.bind(this),this.dragElementHandler=this.dragElementHandler.bind(this)}render(){return Mi`<slot></slot>`}dragElementHandler(e){e.preventDefault();let t=e.clientX-this.startX,r=e.clientY-this.startY;this.dragElement.style.left=this.dragElement.offsetLeft+t+"px",this.dragElement.style.top=this.dragElement.offsetTop+r+"px",this.startX=e.clientX,this.startY=e.clientY}connectedCallback(){super.connectedCallback(),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(e){document.removeEventListener("mousemove",this.dragElementHandler,!0)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("mousemove",this.dragElementHandler),document.removeEventListener("mouseup",this.removeMoveListener)}};_e.styles=[Si`
437
+ :host {
438
+ display: inline-block;
439
+ position: relative;
440
+ }
441
+ `];customElements.define("qti-position-object-stage",_e);import{css as Ni,html as St}from"lit";import{property as Mt,state as Hi}from"lit/decorators.js";import{repeat as Oi}from"lit/directives/repeat.js";import{styleMap as Di}from"lit/directives/style-map.js";var V=class extends f{constructor(){super(...arguments);this.maxChoices=0;this.minChoices=0;this._points=[]}render(){return St` <slot name="prompt"></slot>
442
+ <point-container>
443
+ ${Oi(this._points,e=>e,(e,t)=>St`
444
+ <button
445
+ part="point"
446
+ style=${Di({position:"absolute",transform:"translate(-50%, -50%)",left:`${e.split(" ")[0]}px`,top:`${e.split(" ")[1]}px`})}
447
+ @click=${r=>{r.stopPropagation(),this._points=this._points.filter((o,n)=>n!==t),this.saveResponse(this._points)}}
448
+ ></button>
449
+ `)}
450
+ <slot></slot>
451
+ </point-container>`}reset(){this._points=[]}validate(){return this._points.length>=this.minChoices&&this._points.length<=this.maxChoices}set response(e){this._points=Array.isArray(e)?e:[e]}connectedCallback(){super.connectedCallback(),this.querySelector("img").addEventListener("click",t=>{let r=t.offsetX,o=t.offsetY;this._points=[...this._points,r+" "+o],this.saveResponse(this._points)})}disconnectedCallback(){super.disconnectedCallback()}};V.styles=[Ni`
452
+ host() {
453
+ display: block;
454
+ }
455
+ point-container {
456
+ display: block;
457
+ position: relative;
458
+ }
459
+ `],s([Mt({type:Number,attribute:"max-choices"})],V.prototype,"maxChoices",2),s([Mt({type:Number,attribute:"min-choices"})],V.prototype,"minChoices",2),s([Hi()],V.prototype,"_points",2);customElements.define("qti-select-point-interaction",V);import{css as Vi,html as Pi}from"lit";import{property as W,query as Nt}from"lit/decorators.js";var E=class extends f{constructor(){super(...arguments);this.stepLabel=!1;this.reverse=!1;this._handleDisabledChange=(e,t)=>{};this._handleReadonlyChange=(e,t)=>{}}set min(e){this._min=e,this.style.setProperty("--min",`${this._min}`)}get min(){return this._min}set max(e){this._max=e,this.style.setProperty("--max",`${this._max}`)}get max(){return this._max}set step(e){this._step=e,this.style.setProperty("--step",`${this._step}`)}get step(){return this._step}reset(){}validate(){return!0}set response(e){if(Array.isArray(e)){console.error("QtiSliderInteraction: response is an array, but should be a single value");return}let t=parseInt(e);if(Number.isNaN(t)){console.error("QtiSliderInteraction: response is not a number");return}this.value=t}render(){this.value<this.min&&(this.value=this.min),this.value>this.max&&(this.value=this.max);let e=(this.value-this.min)/(this.max-this.min)*100;return Pi`<slot name="prompt"></slot>
460
+ <div id="rail" @mousedown=${this._onMouseDown} @touchstart=${this._onTouchMove} part="rail">
388
461
  <div id="knob" part="knob" style="left:${e}%"></div>
389
- </div>`}connectedCallback(){super.connectedCallback(),this.step=1,this.setAttribute("tabindex","0"),this.setAttribute("role","slider")}_onTouchMove(e){let t=n=>{let{x:c}=this.getPositionFromEvent(n),p=c-this._rail.getBoundingClientRect().left-document.documentElement.scrollLeft;this.calculateValue(p),n.stopPropagation()},r=()=>{document.removeEventListener("touchmove",t),document.removeEventListener("touchend",r),this.saveResponse(this.value.toString())};document.addEventListener("touchmove",t),document.addEventListener("touchend",r);let{x:o}=this.getPositionFromEvent(e),l=o-this._rail.getBoundingClientRect().left-document.documentElement.scrollLeft;this.calculateValue(l),e.stopPropagation()}_onMouseDown(e){let t=l=>{let n=l.pageX-this._rail.getBoundingClientRect().left-document.documentElement.scrollLeft;this.calculateValue(n),l.preventDefault(),l.stopPropagation()},r=()=>{document.removeEventListener("mousemove",t),document.removeEventListener("mouseup",r),this.saveResponse(this.value.toString())};document.addEventListener("mousemove",t),document.addEventListener("mouseup",r);let o=e.pageX-this._rail.getBoundingClientRect().left-document.documentElement.scrollLeft;this.calculateValue(o),e.preventDefault(),e.stopPropagation()}calculateValue(e){let t=this.min+(this.max-this.min)*e/this.offsetWidth,r=this.min+Math.round((t-this.min)/this._step)*this._step;this.value=r}getPositionFromEvent(e){let t;if(e.type=="touchstart"||e.type=="touchmove"||e.type=="touchend"||e.type=="touchcancel"){let r=typeof e.originalEvent=="undefined"?e:e.originalEvent,o=r.touches[0]||r.changedTouches[0];t={x:o.pageX,y:o.pageY}}else(e.type=="mousedown"||e.type=="mouseup"||e.type=="mousemove"||e.type=="mouseover"||e.type=="mouseout"||e.type=="mouseenter"||e.type=="mouseleave")&&(t={x:e.clientX,y:e.clientY});return t}};x.styles=[Oi``],s([Lt("#knob")],x.prototype,"_knob",2),s([Lt("#rail")],x.prototype,"_rail",2),s([G({type:Number})],x.prototype,"value",2),s([G({type:Boolean,attribute:"step-label"})],x.prototype,"stepLabel",2),s([G({type:Boolean})],x.prototype,"reverse",2),s([G({type:Number,attribute:"lower-bound"})],x.prototype,"min",1),s([G({type:Number,attribute:"upper-bound"})],x.prototype,"max",1),s([G({type:Number,attribute:"step"})],x.prototype,"step",1),s([g("disabled",{waitUntilFirstUpdate:!0})],x.prototype,"_handleDisabledChange",2),s([g("readonly",{waitUntilFirstUpdate:!0})],x.prototype,"_handleReadonlyChange",2);customElements.define("qti-slider-interaction",x);import{html as Vi}from"lit";var Re=class extends u{constructor(){super(...arguments);this.value=0;this.render=()=>Vi`${this.value}`}levenshtein(e,t){let r;if(e.length===0)return t.length;if(t.length===0)return e.length;e.length>t.length&&(r=e,e=t,t=r);let o=e.length,l=t.length,n=Array(o),c,p,d;for(c=0;c<=o;c++)n[c]=c;for(c=1;c<=l;c++){for(d=c,p=1;p<=o;p++)r=n[p-1].toString(),n[p-1]=d,d=Math.min(Number(r)+(t.charAt(c-1)!==e.charAt(p-1)?1:0),d+1,n[p]+1);n[p-1]=d}return d}calculate(){let e=this.firstElementChild,t=this.lastElementChild,r=e.calculate(),o=t.calculate();return this.value=100-this.levenshtein(r.toString().trim(),o.toString().trim())/o.toString().length*100,this.value}};Re.properties={value:{}};customElements.define("qti-custom-operator-levenshtein",Re);import{html as Pi,LitElement as $i}from"lit";var it=class extends $i{render(){return Pi``}calculate(){var t;let e=(t=this.firstElementChild.calculate())==null?void 0:t.toString();return e?e.replace(/[^0-9$.,]/g,""):""}};customElements.define("qti-custom-operator-numeric",it);import{LitElement as Ii,html as Fi}from"lit";var Te=class extends Ii{constructor(){super(...arguments);this.render=()=>Fi`${this.value}`}calculate(){var o;let e,r=(o=this.firstElementChild.calculate())==null?void 0:o.toString();return this.value=r?this.parseNumber(r,e):"",this.value}parseNumber(e,t=navigator.languages){let r=Intl.NumberFormat(t).format(1.1),o=new RegExp(`[^-+0-9${r.charAt(1)}]`,"g"),n=e.replace(o,"").replace(r.charAt(1),".");return parseFloat(n)}};Te.properties={value:{}};customElements.define("qti-custom-operator-parse-numeric-nl",Te);import{LitElement as Ui,html as Bi}from"lit";var st=class extends Ui{render(){return Bi``}calculate(){var t;let e=(t=this.firstElementChild.calculate())==null?void 0:t.toString();return e?e.replace(/ /g,""):""}};customElements.define("qti-custom-operator-remove-spaces",st);import{LitElement as Xi,html as Yi}from"lit";var ot=class extends Xi{render(){return Yi``}calculate(){return this.firstElementChild.calculate().toString().trim()}};customElements.define("qti-custom-operator-trim",ot);import{ContextConsumer as Ki}from"@lit-labs/context";import{LitElement as zi,css as ji,html as Gi}from"lit";import{customElement as Wi,property as re}from"lit/decorators.js";var T=class extends zi{constructor(){super(...arguments);this.disabled=!1;this.readonly=!1;this.logger=new Ki(this,ie,e=>{this.style.display=e.view==="scorer"?"block":"none"},!0)}textChanged(e){if(this.disabled||this.readonly)return;let t=e.target;this.value=t.value,this.closest("qti-test").manualOutcomeValue=this.value}render(){return Gi`<input
390
- part="input"
391
- type="number"
392
- spellcheck="false"
393
- autocomplete="off"
394
- @keyup=${this.textChanged}
395
- @change=${this.textChanged}
396
- placeholder="score"
397
- min=${this.min}
398
- max=${this.max}
399
- .value=${this.value}
400
- size="10"
401
- ?disabled=${this.disabled}
402
- ?readonly=${this.readonly}
403
- />`}};T.styles=ji`
462
+ </div>`}connectedCallback(){super.connectedCallback(),this.step=1,this.setAttribute("tabindex","0"),this.setAttribute("role","slider")}_onTouchMove(e){let t=l=>{let{x:c}=this.getPositionFromEvent(l),p=c-this._rail.getBoundingClientRect().left-document.documentElement.scrollLeft;this.calculateValue(p),l.stopPropagation()},r=()=>{document.removeEventListener("touchmove",t),document.removeEventListener("touchend",r),this.saveResponse(this.value.toString())};document.addEventListener("touchmove",t),document.addEventListener("touchend",r);let{x:o}=this.getPositionFromEvent(e),n=o-this._rail.getBoundingClientRect().left-document.documentElement.scrollLeft;this.calculateValue(n),e.stopPropagation()}_onMouseDown(e){let t=n=>{let l=n.pageX-this._rail.getBoundingClientRect().left-document.documentElement.scrollLeft;this.calculateValue(l),n.preventDefault(),n.stopPropagation()},r=()=>{document.removeEventListener("mousemove",t),document.removeEventListener("mouseup",r),this.saveResponse(this.value.toString())};document.addEventListener("mousemove",t),document.addEventListener("mouseup",r);let o=e.pageX-this._rail.getBoundingClientRect().left-document.documentElement.scrollLeft;this.calculateValue(o),e.preventDefault(),e.stopPropagation()}calculateValue(e){let t=this.min+(this.max-this.min)*e/this.offsetWidth,r=this.min+Math.round((t-this.min)/this._step)*this._step;this.value=r}getPositionFromEvent(e){let t;if(e.type=="touchstart"||e.type=="touchmove"||e.type=="touchend"||e.type=="touchcancel"){let r=typeof e.originalEvent=="undefined"?e:e.originalEvent,o=r.touches[0]||r.changedTouches[0];t={x:o.pageX,y:o.pageY}}else(e.type=="mousedown"||e.type=="mouseup"||e.type=="mousemove"||e.type=="mouseover"||e.type=="mouseout"||e.type=="mouseenter"||e.type=="mouseleave")&&(t={x:e.clientX,y:e.clientY});return t}};E.styles=[Vi``],s([Nt("#knob")],E.prototype,"_knob",2),s([Nt("#rail")],E.prototype,"_rail",2),s([W({type:Number})],E.prototype,"value",2),s([W({type:Boolean,attribute:"step-label"})],E.prototype,"stepLabel",2),s([W({type:Boolean})],E.prototype,"reverse",2),s([W({type:Number,attribute:"lower-bound"})],E.prototype,"min",1),s([W({type:Number,attribute:"upper-bound"})],E.prototype,"max",1),s([W({type:Number,attribute:"step"})],E.prototype,"step",1),s([g("disabled",{waitUntilFirstUpdate:!0})],E.prototype,"_handleDisabledChange",2),s([g("readonly",{waitUntilFirstUpdate:!0})],E.prototype,"_handleReadonlyChange",2);customElements.define("qti-slider-interaction",E);import{LitElement as $i,css as Ii,html as Fi}from"lit";var ke=class extends $i{connectedCallback(){super.connectedCallback(),this.dispatchEvent(new CustomEvent("qti-register-hotspot",{bubbles:!0,cancelable:!1,composed:!0}))}render(){return Fi` <slot name="qti-gap-img"></slot> `}};ke.styles=Ii`
404
463
  :host {
405
- display: none;
464
+ position: absolute;
465
+ }
466
+ `;customElements.define("qti-associable-hotspot",ke);import{LitElement as Ui}from"lit";import{property as Xi}from"lit/decorators.js";var Ae=class extends Ui{constructor(){super(...arguments);this.tabindex=0}connectedCallback(){this.setAttribute("slot","qti-gap-img")}};s([Xi({type:Number,reflect:!0})],Ae.prototype,"tabindex",2);customElements.define("qti-gap-img",Ae);import{html as Yi,LitElement as Bi}from"lit";import{property as Ki}from"lit/decorators.js";var we=class extends Bi{constructor(){super(...arguments);this.tabindex=0}connectedCallback(){super.connectedCallback(),this.setAttribute("slot","qti-gap-text")}render(){return Yi`<slot></slot>`}};s([Ki({type:Number,reflect:!0})],we.prototype,"tabindex",2);customElements.define("qti-gap-text",we);import{html as ji,LitElement as zi}from"lit";import{property as Gi}from"lit/decorators.js";var Re=class extends zi{constructor(){super(...arguments);this.tabindex=0}render(){return ji` <slot name="qti-gap-text"></slot>`}};s([Gi({type:Number,reflect:!0})],Re.prototype,"tabindex",2);customElements.define("qti-gap",Re);import{css as Wi}from"lit";import{property as Ji}from"lit/decorators.js";var re=class extends y{};re.styles=Wi`
467
+ :host {
468
+ position: absolute;
406
469
  }
407
- `,s([re({type:Boolean})],T.prototype,"disabled",2),s([re({type:Boolean})],T.prototype,"readonly",2),s([re({type:Number})],T.prototype,"value",2),s([re({type:Number})],T.prototype,"min",2),s([re({type:Number})],T.prototype,"max",2),T=s([Wi("qti-manual-scoring")],T);export{v as Choices,R as DragDropInteractionMixin,kt as DroppablesMixin,gt as Events,wt as FlippablesMixin,I as OutcomeVariable,Xe as QtiAnd,q as QtiAssessmentItem,ee as QtiAssociateInteraction,ge as QtiBaseValue,y as QtiChoice,ft as QtiChoiceElementSelected,oe as QtiCompanionMaterialsInfo,Ke as QtiContains,ze as QtiCorrect,Re as QtiCustomOperatorLevenshtein,it as QtiCustomOperatorNumericOnly,Te as QtiCustomOperatorParseNumberLocalNl,st as QtiCustomOperatorRemoveAllSpaces,ot as QtiCustomOperatorTrim,he as QtiEqual,fe as QtiEqualRounded,u as QtiExpression,w as QtiExtendedTextInteraction,ce as QtiFeedbackInline,xe as QtiGap,ve as QtiGapMatchInteraction,ye as QtiGapText,Ee as QtiGraphicAssociateInteraction,Ce as QtiGraphicGapMatchInteraction,qe as QtiGraphicOrderInteraction,Ue as QtiGt,Be as QtiGte,te as QtiHotspotChoice,_e as QtiHotspotInteraction,ue as QtiHottext,Pe as QtiHottextInteraction,rt as QtiInlineChoice,me as QtiInlineChoiceInteraction,lt as QtiInteractionChanged,ht as QtiInteractionResponse,je as QtiIsNull,mt as QtiLooseChoice,T as QtiManualScoring,be as QtiMapResponse,Y as QtiMapping,Ge as QtiMatch,ke as QtiMatchInteraction,we as QtiMediaInteraction,He as QtiModalFeedback,Je as QtiMultiple,Ye as QtiOr,j as QtiOrderInteraction,Ze as QtiOrdered,at as QtiOutcomeChanged,Ne as QtiOutcomeDeclaration,et as QtiPortableCustomInteraction,Se as QtiPrompt,dt as QtiRegisterChoice,ut as QtiRegisterHotspot,pt as QtiRegisterInteraction,ct as QtiRegisterVariable,$e as QtiResponseCondition,U as QtiResponseDeclaration,Z as QtiResponseElse,Fe as QtiResponseElseIf,Q as QtiResponseIf,X as QtiResponseProcessing,M as QtiRule,Ae as QtiSelectPointInteraction,Ie as QtiSetOutcomeValue,tt as QtiSimpleAssociableChoice,x as QtiSliderInteraction,Le as QtiStylesheet,S as QtiTextEntryInteraction,We as QtiVariable,$ as ResponseVariable,H as TouchDragAndDrop,ae as qtiContentBody,_ as qtiRubricBlock};
470
+ `,s([Ji({attribute:"aria-ordervalue",type:Number,reflect:!0})],re.prototype,"order",2);customElements.define("qti-hotspot-choice",re);import{customElement as Zi}from"lit/decorators.js";import{html as Qi}from"lit";var Le=class extends y{render(){return Qi`<div part="ch"><div part="cha"></div></div>
471
+ <slot></slot> `}};Le=s([Zi("qti-hottext")],Le);import{LitElement as es}from"lit";var st=class extends es{};customElements.define("qti-inline-choice",st);import{customElement as ts}from"lit/decorators.js";import{html as rs}from"lit";var ie=class extends y{render(){return rs`<div part="ch"><div part="cha"></div></div>
472
+ <slot></slot> `}};ie=s([ts("qti-simple-choice")],ie);export{gt as Events,F as OutcomeVariable,Be as QtiAnd,q as QtiAssessmentItem,ke as QtiAssociableHotspot,ee as QtiAssociateInteraction,fe as QtiBaseValue,y as QtiChoice,ft as QtiChoiceElementSelected,oe as QtiCompanionMaterialsInfo,je as QtiContains,ze as QtiCorrect,me as QtiEqual,he as QtiEqualRounded,u as QtiExpression,A as QtiExtendedTextInteraction,ce as QtiFeedbackInline,Re as QtiGap,Ae as QtiGapImg,be as QtiGapMatchInteraction,we as QtiGapText,M as QtiGraphicAssociateInteraction,ve as QtiGraphicGapMatchInteraction,ye as QtiGraphicOrderInteraction,Xe as QtiGt,Ye as QtiGte,re as QtiHotspotChoice,Ee as QtiHotspotInteraction,Le as QtiHottext,$e as QtiHottextInteraction,st as QtiInlineChoice,ue as QtiInlineChoiceInteraction,lt as QtiInteractionChanged,ht as QtiInteractionResponse,Ge as QtiIsNull,mt as QtiLooseChoice,ge as QtiMapResponse,K as QtiMapping,We as QtiMatch,xe as QtiMatchInteraction,Ce as QtiMediaInteraction,He as QtiModalFeedback,Ze as QtiMultiple,Ke as QtiOr,G as QtiOrderInteraction,Qe as QtiOrdered,at as QtiOutcomeChanged,Ne as QtiOutcomeDeclaration,tt as QtiPortableCustomInteraction,_e as QtiPositionObjectStage,Se as QtiPrompt,dt as QtiRegisterChoice,ut as QtiRegisterHotspot,pt as QtiRegisterInteraction,ct as QtiRegisterVariable,Ie as QtiResponseCondition,X as QtiResponseDeclaration,Z as QtiResponseElse,Ue as QtiResponseElseIf,Q as QtiResponseIf,B as QtiResponseProcessing,S as QtiRule,qe as QtiSPositionObjectInteraction,V as QtiSelectPointInteraction,Fe as QtiSetOutcomeValue,it as QtiSimpleAssociableChoice,E as QtiSliderInteraction,Te as QtiStylesheet,T as QtiTextEntryInteraction,Je as QtiVariable,I as ResponseVariable,ae as qtiContentBody,_ as qtiRubricBlock};