@citolab/qti-components 6.0.18 → 6.0.19

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.
@@ -1,20 +1,20 @@
1
- import{a as ct}from"../chunk-RPGALUIV.js";import{a as lt}from"../chunk-HQKT4SJF.js";import{a as g}from"../chunk-WFLR5TH7.js";import{a as C,b as O,c as s}from"../chunk-NMCIOGD2.js";var pt={};var dt={};var ut={};var mt={};var ht={};var ft={};var gt={};var bt={};var vt={};var yt={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 V=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 $=class{constructor(){this.value=0}};import{customElement as Pt,property as ee}from"lit/decorators.js";import{html as It,LitElement as Ft}from"lit";var q=class extends Ft{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 It`<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(a=>a.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 V?t:null}getOutcome(e){let t=this.variables.find(r=>r.identifier===e);return t instanceof $?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([ee({type:Boolean})],q.prototype,"disabled",2),s([ee({type:Boolean})],q.prototype,"readonly",2),s([ee({type:String})],q.prototype,"title",2),s([ee({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([Pt("qti-assessment-item")],q);import{LitElement as Xt}from"lit";var Re=class extends Xt{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",Re);import{customElement as Ut}from"lit/decorators.js";import{html as Bt,LitElement as Kt}from"lit";import{css as Yt}from"lit";var Et=Yt`
1
+ import{a as ht}from"../chunk-RPGALUIV.js";import{a as mt}from"../chunk-HQKT4SJF.js";import{a as g}from"../chunk-WFLR5TH7.js";import{a as C,b as O,c as s}from"../chunk-NMCIOGD2.js";var ft={};var gt={};var bt={};var vt={};var yt={};var xt={};var Et={};var qt={};var Ct={};var _t={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 V=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 $=class{constructor(){this.value=void 0}};import{customElement as Ut,property as ee}from"lit/decorators.js";import{html as Bt,LitElement as Kt}from"lit";var _=class extends Kt{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 Bt`<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(){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(a=>a.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 V?t:null}getOutcome(e){let t=this.variables.find(r=>r.identifier===e);return t instanceof $?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.showFeedback(e)}showFeedback(e){this.feedbackElements.forEach(t=>{t.checkShowFeedback(e.detail.outcomeIdentifier)})}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([ee({type:Boolean})],_.prototype,"disabled",2),s([ee({type:Boolean})],_.prototype,"readonly",2),s([ee({type:String})],_.prototype,"title",2),s([ee({type:String})],_.prototype,"identifier",2),s([g("disabled",{waitUntilFirstUpdate:!0})],_.prototype,"_handleDisabledChange",2),s([g("readonly",{waitUntilFirstUpdate:!0})],_.prototype,"_handleReadonlyChange",2),_=s([Ut("qti-assessment-item")],_);import{LitElement as jt}from"lit";var Ne=class extends jt{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",Ne);import{customElement as Gt}from"lit/decorators.js";import{html as Wt,LitElement as Jt}from"lit";import{css as zt}from"lit";var kt=zt`
2
2
  :host {
3
3
  display: block;
4
4
  }
5
- `;var P=class extends Kt{render(){return Bt` <slot name="qti-rubric-block"></slot>
6
- <slot></slot>`}};P.styles=Et,P=s([Ut("qti-item-body")],P);import{html as jt,LitElement as zt}from"lit";var Se=class extends zt{render(){return jt` <slot></slot> `}connectedCallback(){this.parentElement.tagName.endsWith("INTERACTION")&&this.setAttribute("slot","prompt")}};customElements.define("qti-prompt",Se);import{html as Gt}from"lit/static-html.js";import{property as j}from"lit/decorators.js";import{LitElement as Wt}from"lit";var Jt={SPACE:32},y=class extends Wt{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 Jt.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"),Gt` <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:n=>n}})],y.prototype,"disabled",2),s([j({reflect:!0,type:Boolean,attribute:"aria-readonly",converter:{toAttribute:n=>n}})],y.prototype,"readonly",2),s([j({reflect:!0,type:Boolean,attribute:"aria-checked",converter:{toAttribute:n=>n}})],y.prototype,"checked",2),s([g("disabled",{waitUntilFirstUpdate:!0})],y.prototype,"handleDisabledChange",1);import{html as Zt,LitElement as Qt}from"lit";var N=class extends Qt{render(){return Zt``}};customElements.define("qti-variabledeclaration",N);import{property as Me}from"lit/decorators.js";var I=class extends N{connectedCallback(){super.connectedCallback();let e=new V({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"})],I.prototype,"baseType",2),s([Me({type:String,attribute:"identifier"})],I.prototype,"identifier",2),s([Me({type:String,attribute:"cardinality"})],I.prototype,"cardinality",2);customElements.define("qti-response-declaration",I);var Ne=class extends N{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 $;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 er}from"lit";import{customElement as tr}from"lit/decorators.js";var te=class extends er{};te=s([tr("qti-companion-materials-info")],te);import{LitElement as rr,css as ir,html as sr}from"lit";import{customElement as or,property as re}from"lit/decorators.js";import{ContextConsumer as nr}from"@lit-labs/context";var _=class extends rr{constructor(){super(...arguments);this.logger=new nr(this,lt,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 sr`<slot></slot>`}connectedCallback(){super.connectedCallback(),this.setAttribute("slot","qti-rubric-block")}};_.styles=ir`
5
+ `;var P=class extends Jt{render(){return Wt` <slot name="qti-rubric-block"></slot>
6
+ <slot></slot>`}};P.styles=kt,P=s([Gt("qti-item-body")],P);import{html as Zt,LitElement as Qt}from"lit";var De=class extends Qt{render(){return Zt` <slot></slot> `}connectedCallback(){this.parentElement.tagName.endsWith("INTERACTION")&&this.setAttribute("slot","prompt")}};customElements.define("qti-prompt",De);import{html as er}from"lit/static-html.js";import{property as j}from"lit/decorators.js";import{LitElement as tr}from"lit";var rr={SPACE:32},y=class extends tr{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 rr.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"),er` <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:n=>n}})],y.prototype,"disabled",2),s([j({reflect:!0,type:Boolean,attribute:"aria-readonly",converter:{toAttribute:n=>n}})],y.prototype,"readonly",2),s([j({reflect:!0,type:Boolean,attribute:"aria-checked",converter:{toAttribute:n=>n}})],y.prototype,"checked",2),s([g("disabled",{waitUntilFirstUpdate:!0})],y.prototype,"handleDisabledChange",1);import{html as ir,LitElement as sr}from"lit";var N=class extends sr{render(){return ir``}};customElements.define("qti-variabledeclaration",N);import{property as He}from"lit/decorators.js";var I=class extends N{connectedCallback(){super.connectedCallback();let e=new V({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([He({type:String,attribute:"base-type"})],I.prototype,"baseType",2),s([He({type:String,attribute:"identifier"})],I.prototype,"identifier",2),s([He({type:String,attribute:"cardinality"})],I.prototype,"cardinality",2);customElements.define("qti-response-declaration",I);var Oe=class extends N{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(){var t;super.connectedCallback();let i=this.getAttribute("identifier"),e=new $;e.identifier=i,e.value=(t=this.querySelector("qti-default-value qti-value"))==null?void 0:t.innerHTML,this.dispatchEvent(new CustomEvent("qti-register-variable",{bubbles:!0,composed:!0,detail:{variable:e}}))}};customElements.define("qti-outcome-declaration",Oe);import{LitElement as or}from"lit";import{customElement as nr}from"lit/decorators.js";var te=class extends or{};te=s([nr("qti-companion-materials-info")],te);import{LitElement as ar,css as lr,html as cr}from"lit";import{customElement as pr,property as re}from"lit/decorators.js";import{ContextConsumer as dr}from"@lit-labs/context";var k=class extends ar{constructor(){super(...arguments);this.logger=new dr(this,mt,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 cr`<slot></slot>`}connectedCallback(){super.connectedCallback(),this.setAttribute("slot","qti-rubric-block")}};k.styles=lr`
7
7
  :host {
8
8
  display: block;
9
9
  }
10
- `,s([re({type:String})],_.prototype,"id",2),s([re({type:String})],_.prototype,"use",2),s([re({type:String})],_.prototype,"view",2),s([re({type:String,attribute:"class"})],_.prototype,"classNames",2),s([g("classNames",{waitUntilFirstUpdate:!0})],_.prototype,"handleclassNamesChange",1),_=s([or("qti-rubric-block")],_);import{LitElement as ar,html as lr}from"lit";import{customElement as cr}from"lit/decorators.js";var ie=class extends ar{render(){return lr`<slot></slot>`}};ie=s([cr("qti-content-body")],ie);import{css as dr,html as ur}from"lit";import{LitElement as pr}from"lit";import{property as se}from"lit/decorators.js";var k=class extends pr{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([se({type:String,attribute:"show-hide"})],k.prototype,"showHide",2),s([se({type:String,attribute:"outcome-identifier"})],k.prototype,"outcomeIdentifier",2),s([se({type:String})],k.prototype,"identifier",2),s([se({type:String,attribute:!1})],k.prototype,"showStatus",2);var oe=class extends k{constructor(){super(...arguments);this.render=()=>ur` <slot class="${this.showStatus}"></slot> `}};oe.styles=dr`
10
+ `,s([re({type:String})],k.prototype,"id",2),s([re({type:String})],k.prototype,"use",2),s([re({type:String})],k.prototype,"view",2),s([re({type:String,attribute:"class"})],k.prototype,"classNames",2),s([g("classNames",{waitUntilFirstUpdate:!0})],k.prototype,"handleclassNamesChange",1),k=s([pr("qti-rubric-block")],k);import{LitElement as ur,html as mr}from"lit";import{customElement as hr}from"lit/decorators.js";var ie=class extends ur{render(){return mr`<slot></slot>`}};ie=s([hr("qti-content-body")],ie);import{css as gr,html as br}from"lit";import{LitElement as fr}from"lit";import{property as se}from"lit/decorators.js";var E=class extends fr{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){var o;let t=this.closest("qti-assessment-item").getOutcome(e);if(this.outcomeIdentifier!==e||!t)return;let r=Array.isArray(t)?t.includes(this.identifier):this.identifier===((o=t==null?void 0:t.value)==null?void 0:o.toString());this.showFeedback(r)}showFeedback(e){this.showStatus=e?"on":"off"}};s([se({type:String,attribute:"show-hide"})],E.prototype,"showHide",2),s([se({type:String,attribute:"outcome-identifier"})],E.prototype,"outcomeIdentifier",2),s([se({type:String})],E.prototype,"identifier",2),s([se({type:String,attribute:!1})],E.prototype,"showStatus",2);var oe=class extends E{constructor(){super(...arguments);this.render=()=>br` <slot class="${this.showStatus}"></slot> `}};oe.styles=gr`
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",oe);import{html as mr}from"lit";var De=class extends k{render(){return mr`
17
+ `;customElements.define("qti-feedback-inline",oe);import{html as vr}from"lit";var Ve=class extends E{render(){return vr`
18
18
  <style>
19
19
  .on {
20
20
  display: inline-block;
@@ -26,15 +26,27 @@ import{a as ct}from"../chunk-RPGALUIV.js";import{a as lt}from"../chunk-HQKT4SJF.
26
26
  <div class="feedback ${this.showStatus}">
27
27
  <slot></slot>
28
28
  </div>
29
- `}};customElements.define("qti-modal-feedback",De);import{css as fr,html as gr}from"lit";import{ifDefined as Oe}from"lit/directives/if-defined.js";import{property as He}from"lit/decorators.js";import{LitElement as hr}from"lit";var m=class extends hr{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([He({attribute:"response-identifier"})],m.prototype,"responseIdentifier",2),s([He({reflect:!0,type:Boolean})],m.prototype,"disabled",2),s([He({reflect:!0,type:Boolean})],m.prototype,"readonly",2);import{customElement as br,property as ne,state as vr}from"lit/decorators.js";var R=class extends m{constructor(){super(...arguments);this._value=""}set response(e){this._value=e!==void 0?e:""}validate(){return this._value!==""}static get styles(){return[fr`
29
+ `}};customElements.define("qti-modal-feedback",Ve);import{html as yr}from"lit";var $e=class extends E{render(){return yr`
30
+ <style>
31
+ .on {
32
+ display: inline-block;
33
+ }
34
+ .off {
35
+ display: none;
36
+ }
37
+ </style>
38
+ <div class="feedback ${this.showStatus}">
39
+ <slot></slot>
40
+ </div>
41
+ `}firstUpdated(i){this.checkShowFeedback(this.outcomeIdentifier)}};customElements.define("qti-feedback-block",$e);import{css as Er,html as qr}from"lit";import{ifDefined as Ie}from"lit/directives/if-defined.js";import{property as Pe}from"lit/decorators.js";import{LitElement as xr}from"lit";var m=class extends xr{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([Pe({attribute:"response-identifier"})],m.prototype,"responseIdentifier",2),s([Pe({reflect:!0,type:Boolean})],m.prototype,"disabled",2),s([Pe({reflect:!0,type:Boolean})],m.prototype,"readonly",2);import{customElement as Cr,property as ne,state as _r}from"lit/decorators.js";var R=class extends m{constructor(){super(...arguments);this._value=""}set response(e){this._value=e!==void 0?e:""}validate(){return this._value!==""}static get styles(){return[Er`
30
42
  /* PK: display host as block, else design will be collapsed */
31
43
  :host {
32
44
  display: inline-block;
33
45
  }
34
46
  input {
35
- padding: var(--qti-padding, 0.5rem);
47
+ border: 0;
36
48
  }
37
- `]}render(){return gr` <input
49
+ `]}render(){return qr` <input
38
50
  part="input"
39
51
  spellcheck="false"
40
52
  autocomplete="off"
@@ -42,54 +54,54 @@ import{a as ct}from"../chunk-RPGALUIV.js";import{a as lt}from"../chunk-HQKT4SJF.
42
54
  @keyup="${this.textChanged}"
43
55
  @change="${this.textChanged}"
44
56
  type="text"
45
- placeholder="${Oe(this.placeholderText?this.placeholderText:void 0)}"
57
+ placeholder="${Ie(this.placeholderText?this.placeholderText:void 0)}"
46
58
  .value="${this._value}"
47
- size="${Oe(this.expectedLength?this.expectedLength:void 0)}"
48
- pattern="${Oe(this.patternMask?this.patternMask:void 0)}"
59
+ size="${Ie(this.expectedLength?this.expectedLength:void 0)}"
60
+ pattern="${Ie(this.patternMask?this.patternMask:void 0)}"
49
61
  ?disabled="${this.disabled}"
50
62
  ?readonly="${this.readonly}"
51
- />`}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([ne({type:Number,attribute:"expected-length"})],R.prototype,"expectedLength",2),s([ne({type:String,attribute:"pattern-mask"})],R.prototype,"patternMask",2),s([ne({type:String,attribute:"placeholder-text"})],R.prototype,"placeholderText",2),s([vr()],R.prototype,"_value",2),s([ne({type:String,attribute:"class"})],R.prototype,"classNames",2),R=s([br("qti-text-entry-interaction")],R);import{css as yr,html as Er}from"lit";import{ifDefined as Ve}from"lit/directives/if-defined.js";import{ref as xr,createRef as Cr}from"lit/directives/ref.js";import{customElement as qr,property as ae,state as _r}from"lit/decorators.js";var A=class extends m{constructor(){super(...arguments);this.textareaRef=Cr();this._value=""}handleclassNamesChange(e,t){this.classNames.split(" ").forEach(o=>{if(o.startsWith("qti-height-lines")){let a=o.replace("qti-height-lines-","");this.textareaRef&&(this.textareaRef.value.rows=parseInt(a))}})}set response(e){this._value=e!==void 0?e:""}validate(){return this._value!==""}static get styles(){return[yr`
63
+ />`}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([ne({type:Number,attribute:"expected-length"})],R.prototype,"expectedLength",2),s([ne({type:String,attribute:"pattern-mask"})],R.prototype,"patternMask",2),s([ne({type:String,attribute:"placeholder-text"})],R.prototype,"placeholderText",2),s([_r()],R.prototype,"_value",2),s([ne({type:String,attribute:"class"})],R.prototype,"classNames",2),R=s([Cr("qti-text-entry-interaction")],R);import{css as kr,html as Ar}from"lit";import{ifDefined as Fe}from"lit/directives/if-defined.js";import{ref as wr,createRef as Tr}from"lit/directives/ref.js";import{customElement as Lr,property as ae,state as Rr}from"lit/decorators.js";var A=class extends m{constructor(){super(...arguments);this.textareaRef=Tr();this._value=""}handleclassNamesChange(e,t){this.classNames.split(" ").forEach(o=>{if(o.startsWith("qti-height-lines")){let a=o.replace("qti-height-lines-","");this.textareaRef&&(this.textareaRef.value.rows=parseInt(a))}})}set response(e){this._value=e!==void 0?e:""}validate(){return this._value!==""}static get styles(){return[kr`
52
64
  /* PK: display host as block, else design will be collapsed */
53
65
  :host {
54
66
  display: block;
55
67
  }
56
68
  textarea {
57
- padding: var(--qti-padding, 0.5rem);
58
69
  width: 100%;
59
70
  height: 100%;
71
+ border: 0;
60
72
  }
61
- `]}render(){return Er`<textarea
73
+ `]}render(){return Ar`<textarea
62
74
  part="textarea"
63
- ${xr(this.textareaRef)}
75
+ ${wr(this.textareaRef)}
64
76
  spellcheck="false"
65
77
  autocomplete="off"
66
78
  @keydown="${e=>e.stopImmediatePropagation()}"
67
79
  @keyup="${this.textChanged}"
68
80
  @change="${this.textChanged}"
69
- placeholder="${Ve(this.placeholderText?this.placeholderText:void 0)}"
70
- maxlength="${Ve(this.expectedLength?this.expectedLength:void 0)}"
71
- pattern="${Ve(this.patternMask?this.patternMask:void 0)}"
81
+ placeholder="${Fe(this.placeholderText?this.placeholderText:void 0)}"
82
+ maxlength="${Fe(this.expectedLength?this.expectedLength:void 0)}"
83
+ pattern="${Fe(this.patternMask?this.patternMask:void 0)}"
72
84
  ?disabled="${this.disabled}"
73
85
  ?readonly="${this.readonly}"
74
86
  .value=${this._value}
75
- ></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([ae({type:Number,attribute:"expected-length"})],A.prototype,"expectedLength",2),s([ae({type:String,attribute:"pattern-mask"})],A.prototype,"patternMask",2),s([ae({type:String,attribute:"placeholder-text"})],A.prototype,"placeholderText",2),s([_r()],A.prototype,"_value",2),s([ae({type:String,attribute:"class"})],A.prototype,"classNames",2),s([g("classNames",{waitUntilFirstUpdate:!0})],A.prototype,"handleclassNamesChange",1),A=s([qr("qti-extended-text-interaction")],A);import{html as kr}from"lit";import{property as xt}from"lit/decorators.js";var v=class extends m{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([xt({type:Number,attribute:"min-choices"})],v.prototype,"minChoices",2),s([xt({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 $e=class extends v{constructor(){super(...arguments);this.render=()=>kr`<slot></slot>`}connectedCallback(){super.connectedCallback(),this.setAttribute("qti-hottext-interaction","")}};customElements.define("qti-hottext-interaction",$e);import{css as Ar,html as Ct}from"lit";var le=class extends m{constructor(){super();this.options=[];this.addEventListener(yt.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 O(C({},m.properties),{options:{type:Array,value:[],attribute:!1}})}connectedCallback(){super.connectedCallback()}static get styles(){return[Ar`
87
+ ></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([ae({type:Number,attribute:"expected-length"})],A.prototype,"expectedLength",2),s([ae({type:String,attribute:"pattern-mask"})],A.prototype,"patternMask",2),s([ae({type:String,attribute:"placeholder-text"})],A.prototype,"placeholderText",2),s([Rr()],A.prototype,"_value",2),s([ae({type:String,attribute:"class"})],A.prototype,"classNames",2),s([g("classNames",{waitUntilFirstUpdate:!0})],A.prototype,"handleclassNamesChange",1),A=s([Lr("qti-extended-text-interaction")],A);import{html as Sr}from"lit";import{property as At}from"lit/decorators.js";var v=class extends m{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([At({type:Number,attribute:"min-choices"})],v.prototype,"minChoices",2),s([At({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 Xe=class extends v{constructor(){super(...arguments);this.render=()=>Sr`<slot></slot>`}connectedCallback(){super.connectedCallback(),this.setAttribute("qti-hottext-interaction","")}};customElements.define("qti-hottext-interaction",Xe);import{css as Mr,html as wt}from"lit";var le=class extends m{constructor(){super();this.options=[];this.addEventListener(_t.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 O(C({},m.properties),{options:{type:Array,value:[],attribute:!1}})}connectedCallback(){super.connectedCallback()}static get styles(){return[Mr`
76
88
  :host {
77
89
  display: inline-block;
78
90
  }
79
- `]}render(){return Ct` <select
91
+ `]}render(){return wt` <select
80
92
  part="select"
81
93
  @change="${this.choiceSelected}"
82
94
  ?disabled="${this.disabled}"
83
95
  ?readonly="${this.readonly}"
84
96
  >
85
- ${this.options.map(e=>Ct` <option value="${e.value}" ?selected="${e.selected}">${e.textContent}</option> `)}
86
- </select>`}validate(){let e=this.options.find(t=>t.selected);return e?e.value!=="":!1}reset(){this.options=this.options.map((e,t)=>O(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=>O(C({},r),{selected:r.value===t})),this.saveResponse(t)}};le.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",le);import{customElement as Tr,property as Lr}from"lit/decorators.js";import{html as Rr}from"lit";import{css as wr}from"lit";var qt=wr`
97
+ ${this.options.map(e=>wt` <option value="${e.value}" ?selected="${e.selected}">${e.textContent}</option> `)}
98
+ </select>`}validate(){let e=this.options.find(t=>t.selected);return e?e.value!=="":!1}reset(){this.options=this.options.map((e,t)=>O(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=>O(C({},r),{selected:r.value===t})),this.saveResponse(t)}};le.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",le);import{customElement as Dr,property as Hr}from"lit/decorators.js";import{html as Or}from"lit";import{css as Nr}from"lit";var Tt=Nr`
87
99
  :host {
88
100
  display: flex;
89
101
  flex-direction: column;
90
102
  align-items: flex-start;
91
103
  }
92
- `;var D=class extends v{constructor(){super(...arguments);this.render=()=>Rr` <slot name="prompt"></slot><slot></slot>`}};D.styles=qt,s([Lr({type:String})],D.prototype,"orientation",2),D=s([Tr("qti-choice-interaction")],D);import{customElement as Sr}from"lit/decorators.js";import{html as Mr,LitElement as Nr}from"lit";var _t=`<qti-response-processing>
104
+ `;var D=class extends v{constructor(){super(...arguments);this.render=()=>Or` <slot name="prompt"></slot><slot></slot>`}};D.styles=Tt,s([Hr({type:String})],D.prototype,"orientation",2),D=s([Dr("qti-choice-interaction")],D);import{customElement as Vr}from"lit/decorators.js";import{html as $r,LitElement as Pr}from"lit";var Lt=`<qti-response-processing>
93
105
  <qti-response-condition>
94
106
  <qti-response-if>
95
107
  <qti-match>
@@ -106,7 +118,7 @@ import{a as ct}from"../chunk-RPGALUIV.js";import{a as lt}from"../chunk-HQKT4SJF.
106
118
  </qti-set-outcome-value>
107
119
  </qti-response-else>
108
120
  </qti-response-condition>
109
- </qti-response-processing>`,kt=`<qti-response-processing>
121
+ </qti-response-processing>`,Rt=`<qti-response-processing>
110
122
  <qti-response-condition>
111
123
  <qti-response-if>
112
124
  <qti-is-null>
@@ -122,7 +134,7 @@ import{a as ct}from"../chunk-RPGALUIV.js";import{a as lt}from"../chunk-HQKT4SJF.
122
134
  </qti-set-outcome-value>
123
135
  </qti-response-else>
124
136
  </qti-response-condition>
125
- </qti-response-processing>`,At=`<qti-response-processing>
137
+ </qti-response-processing>`,St=`<qti-response-processing>
126
138
  <qti-response-condition>
127
139
  <qti-response-if>
128
140
  <qti-is-null>
@@ -138,15 +150,15 @@ import{a as ct}from"../chunk-RPGALUIV.js";import{a as lt}from"../chunk-HQKT4SJF.
138
150
  </qti-set-outcome-value>
139
151
  </qti-response-else>
140
152
  </qti-response-condition>
141
- </qti-response-processing>`;var F=class extends Nr{render(){return Mr`<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(kt));break}case"map_response_point":{this.appendChild(this.fragmentFromString(At));break}case"match_correct":this.appendChild(this.fragmentFromString(_t));break}}let i=[...this.children];for(let e of i)e.process()}fragmentFromString(i){return document.createRange().createContextualFragment(i)}};F=s([Sr("qti-response-processing")],F);import{customElement as Dr}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([Dr("qti-rule")],S);import{html as Vr}from"lit";var Pe=class extends S{render(){return Vr`<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",Pe);var Ie=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",Ie);import{html as Ir}from"lit";import{html as $r,LitElement as Pr}from"lit";var z=class extends Pr{static get properties(){return{debugCalculateResult:{type:Object}}}render(){return $r` <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 G=class extends z{render(){return Ir`${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",G);import{html as Fr}from"lit";var Fe=class extends G{render(){return Fr`${super.render()}`}};customElements.define("qti-response-else-if",Fe);import{LitElement as Xr,html as Yr}from"lit";var u=class extends Xr{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 Yr``}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 Ur}from"lit";var w=class extends u{render(){return Ur``}calculate(){throw new Error("Not implemented")}};var Ye=class extends w{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);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 lt")}return console.error("unexpected number of children in lt"),null}};customElements.define("qti-lt",Ue);var Be=class extends w{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 lte"),null)}return console.log("unexpected number of children in lte"),null}};customElements.define("qti-lte",Be);import{html as Br}from"lit";var Ke=class extends w{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}).every(e=>typeof e=="boolean"&&e)}};customElements.define("qti-and",Ke);import{html as Kr}from"lit";var je=class extends w{render(){return Kr``}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",je);import{property as jr}from"lit/decorators.js";var T=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 ce=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):T.compareSingleValues(t.value,r.value,t.baseType)}return console.error("unexpected number of children in qti-equal"),null}};s([jr({type:String})],ce.prototype,"toleranceMode",2);customElements.define("qti-equal",ce);import{property as zr}from"lit/decorators.js";var pe=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),a=parseFloat(r.value);if(!isNaN(o)&&!isNaN(a))return this.roundingMode==="significantFigures"?o.toPrecision(this.figures)===a.toPrecision(this.figures):Math.round(o*Math.pow(10,this.figures))/Math.pow(10,this.figures)===Math.round(a*Math.pow(10,this.figures))/Math.pow(10,this.figures);console.error(`value cannot be casted to numeric value in equalRounded operator: ${o}, ${a}`);break}default:{console.error("values other than float and int cannot be used in equalRounded operator.");break}}return!1}return console.error("unexpected number of children in qti-equal-rounded"),null}};s([zr({type:String})],pe.prototype,"roundingMode",2);customElements.define("qti-equal-rounded",pe);import{property as Gr}from"lit/decorators.js";var de=class extends u{constructor(){super(...arguments);this.baseType="string"}calculate(){return this.textContent}};s([Gr({type:String})],de.prototype,"baseType",2);customElements.define("qti-base-value",de);var ze=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",ze);import{html as Wr}from"lit";var Ge=class extends u{render(){return Wr``}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",Ge);var We=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",We);import{property as Jr}from"lit/decorators.js";var ue=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 a of r){let l=t.mapEntries.find(c=>T.compareSingleValues(c.mapKey,a,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([Jr({type:String})],ue.prototype,"identifier",2);customElements.define("qti-map-response",ue);var Je=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):T.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 a=e[r];if(!T.compareSingleValues(o,a,t.baseType))return!1}else{let a=null;for(let l of e.value)if(T.compareSingleValues(o,l,t.baseType)){a=l;break}if(a!==null)e.value.splice(e.value.indexOf(a),1);else return!1}r++}return!0}}return console.error("unexpected number of children in match"),null}};customElements.define("qti-match",Je);import{html as Zr}from"lit";var Ze=class extends u{render(){return Zr``}calculate(){let i=this.getAttribute("identifier");return this.closest("qti-assessment-item").getVariableValue(i)}};customElements.define("qti-variable",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!=="multiple"&&e.cardinality!=="single")return console.error("unexpected cardinality in qti multiple"),[];return i}};customElements.define("qti-multiple",Qe);var et=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",et);import{property as tt}from"lit/decorators.js";import{LitElement as Qr}from"lit";var X=class extends Qr{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([tt({attribute:"default-value",type:Number})],X.prototype,"defaultValue",2),s([tt({attribute:"lower-bound",type:Number})],X.prototype,"lowerBound",2),s([tt({attribute:"upper-bound",type:Number})],X.prototype,"upperBound",2);customElements.define("qti-mapping",X);import{LitElement as ei,html as wt}from"lit";var rt=class extends ei{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),h=d.map(b=>b.getAttribute("key"));h.length>0&&!h.find(b=>!Number.isInteger(+b))?c[p]=d.map(b=>a(b)):c[p]=l.textContent}return c},a=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),a(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 wt`<slot></slot>${this._errorMessage&&wt`<div style="color:red">
153
+ </qti-response-processing>`;var F=class extends Pr{render(){return $r`<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(Rt));break}case"map_response_point":{this.appendChild(this.fragmentFromString(St));break}case"match_correct":this.appendChild(this.fragmentFromString(Lt));break}}let i=[...this.children];for(let e of i)e.process()}fragmentFromString(i){return document.createRange().createContextualFragment(i)}};F=s([Vr("qti-response-processing")],F);import{customElement as Ir}from"lit/decorators.js";import{html as Fr,LitElement as Xr}from"lit";var S=class extends Xr{render(){return Fr``}process(){throw new Error("Not implemented")}};S=s([Ir("qti-rule")],S);import{html as Yr}from"lit";var Ye=class extends S{render(){return Yr`<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",Ye);var Ue=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",Ue);import{html as Kr}from"lit";import{html as Ur,LitElement as Br}from"lit";var z=class extends Br{static get properties(){return{debugCalculateResult:{type:Object}}}render(){return Ur` <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 G=class extends z{render(){return Kr`${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",G);import{html as jr}from"lit";var Be=class extends G{render(){return jr`${super.render()}`}};customElements.define("qti-response-else-if",Be);import{LitElement as zr,html as Gr}from"lit";var u=class extends zr{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:{try{return{baseType:"integer",value:e.calculate().toString(),cardinality:"single"}}catch(t){console.warn("default not sufficient")}return null}}}).filter(e=>e!==null)}render(){return Gr``}calculate(){throw new Error("Not implemented")}get assessmentItem(){return this.closest("qti-assessment-item")}};customElements.define("qti-expression",u);var Ke=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",Ke);import{html as Wr}from"lit";var w=class extends u{render(){return Wr``}calculate(){throw new Error("Not implemented")}};var je=class extends w{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",je);var ze=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 lt")}return console.error("unexpected number of children in lt"),null}};customElements.define("qti-lt",ze);var Ge=class extends w{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 lte"),null)}return console.log("unexpected number of children in lte"),null}};customElements.define("qti-lte",Ge);import{html as Jr}from"lit";var We=class extends w{render(){return Jr``}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",We);import{state as Zr}from"lit/decorators.js";import{html as Qr}from"lit";var ce=class extends u{constructor(){super(...arguments);this.mult=0;this.render=()=>Qr`<pre>${this.mult}</pre>`}calculate(){let t=this.getVariables().reduce((r,o)=>{if(o.baseType=="float"||o.baseType=="integer")try{return r*parseInt(o.value.toString())}catch(a){console.warn("can not convert to number")}else console.warn(`has another baseType ${o.baseType}`);return r},1);return this.mult=t,t}};s([Zr()],ce.prototype,"mult",2);customElements.define("qti-product",ce);import{html as ei}from"lit";var Je=class extends w{render(){return ei``}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",Je);import{property as ti}from"lit/decorators.js";var T=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 pe=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):T.compareSingleValues(t.value,r.value,t.baseType)}return console.error("unexpected number of children in qti-equal"),null}};s([ti({type:String})],pe.prototype,"toleranceMode",2);customElements.define("qti-equal",pe);import{property as ri}from"lit/decorators.js";var de=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),a=parseFloat(r.value);if(!isNaN(o)&&!isNaN(a))return this.roundingMode==="significantFigures"?o.toPrecision(this.figures)===a.toPrecision(this.figures):Math.round(o*Math.pow(10,this.figures))/Math.pow(10,this.figures)===Math.round(a*Math.pow(10,this.figures))/Math.pow(10,this.figures);console.error(`value cannot be casted to numeric value in equalRounded operator: ${o}, ${a}`);break}default:{console.error("values other than float and int cannot be used in equalRounded operator.");break}}return!1}return console.error("unexpected number of children in qti-equal-rounded"),null}};s([ri({type:String})],de.prototype,"roundingMode",2);customElements.define("qti-equal-rounded",de);import{property as ii}from"lit/decorators.js";var ue=class extends u{constructor(){super(...arguments);this.baseType="string"}calculate(){return this.textContent}};s([ii({type:String})],ue.prototype,"baseType",2);customElements.define("qti-base-value",ue);var Ze=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",Ze);import{html as si}from"lit";var Qe=class extends u{render(){return si``}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",Qe);var et=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",et);import{html as oi}from"lit";var tt=class extends u{render(){return oi`${super.render()}`}calculate(){return!this.firstElementChild.calculate()}};customElements.define("qti-not",tt);import{property as ni}from"lit/decorators.js";var me=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 a of r){let l=t.mapEntries.find(c=>T.compareSingleValues(c.mapKey,a,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([ni({type:String})],me.prototype,"identifier",2);customElements.define("qti-map-response",me);var rt=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):T.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 a=e[r];if(!T.compareSingleValues(o,a,t.baseType))return!1}else{let a=null;for(let l of e.value)if(T.compareSingleValues(o,l,t.baseType)){a=l;break}if(a!==null)e.value.splice(e.value.indexOf(a),1);else return!1}r++}return!0}}return console.error("unexpected number of children in match"),null}};customElements.define("qti-match",rt);import{html as ai}from"lit";var it=class extends u{render(){return ai``}calculate(){let i=this.getAttribute("identifier");return this.closest("qti-assessment-item").getVariableValue(i)}};customElements.define("qti-variable",it);var st=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",st);var ot=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",ot);import{LitElement as li,html as ci}from"lit";import{property as pi}from"lit/decorators.js";var he=class extends li{constructor(){super();this.value="";this.closest("qti-assessment-item").addEventListener("qti-outcome-changed",()=>{this.value=this.calculate()})}render(){return ci`${this.value}`}calculate(){let e=this.closest("qti-assessment-item"),t=this.getAttribute("identifier");return e.getVariableValue(t)}};s([pi({type:String})],he.prototype,"value",2);customElements.define("qti-printed-variable",he);import{property as nt}from"lit/decorators.js";import{LitElement as di}from"lit";var X=class extends di{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([nt({attribute:"default-value",type:Number})],X.prototype,"defaultValue",2),s([nt({attribute:"lower-bound",type:Number})],X.prototype,"lowerBound",2),s([nt({attribute:"upper-bound",type:Number})],X.prototype,"upperBound",2);customElements.define("qti-mapping",X);import{LitElement as ui,html as Mt}from"lit";var at=class extends ui{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),h=d.map(b=>b.getAttribute("key"));h.length>0&&!h.find(b=>!Number.isInteger(+b))?c[p]=d.map(b=>a(b)):c[p]=l.textContent}return c},a=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),a(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 Mt`<slot></slot>${this._errorMessage&&Mt`<div style="color:red">
142
154
  <h1>Error</h1>
143
155
  ${this._errorMessage}
144
- </div>`}`}};customElements.define("qti-portable-custom-interaction",rt);import{LitElement as ri,css as ii,html as Rt}from"lit";var me=class n{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 n._instance?n._instance:(n._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 ti}from"lit/decorators.js";var Tt=(n,i,e)=>{class t extends n{constructor(){super(...arguments);this.disabled=!1}firstUpdated(a){if(this.classList.contains("qti-match-tabular"))return;super.firstUpdated(a);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(a){a.addEventListener("dragover",this.dragoverHandler),a.addEventListener("drop",this.dropHandler)}removeHandler(a){a.removeEventListener("dragover",this.dragoverHandler),a.removeEventListener("drop",this.dropHandler)}disconnectedCallback(){var a;this.classList.contains("qti-match-tabular")||(super.disconnectedCallback(),(a=this.observer)==null||a.disconnect())}dragoverHandler(a){return a.preventDefault(),a.currentTarget.setAttribute("active",""),a.dataTransfer.dropEffect="move",!1}dropHandler(a){a.preventDefault();let l=a.currentTarget,c=this.querySelector(`[identifier=${a.dataTransfer.getData("text")}`),p=c||this.shadowRoot.querySelector(`[identifier=${a.dataTransfer.getData("text")}`);return l?p.parentElement.getAttribute("identifier")!==l.getAttribute("identifier")&&l.appendChild(p):console.error(`cannot find droppable, target: ${a.target?JSON.stringify(a.target):"null"}`),l.removeAttribute("active"),!1}dragleaveHandler(a){return a.preventDefault(),a.currentTarget.removeAttribute("active"),!1}}return s([ti({type:Boolean,reflect:!0})],t.prototype,"disabled",2),t};var Lt=(n,i,e)=>{class t extends n{}return t};import{property as Y}from"lit/decorators.js";var L=(n,i,e,t)=>{class r extends Lt(Tt(n,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",h=>{h.dataTransfer.setData("text",h.currentTarget.getAttribute("identifier")),d.setAttribute("dragging","")}),d.addEventListener("dragend",h=>{if(h.preventDefault(),d.removeAttribute("over"),d.removeAttribute("dragging"),h.dataTransfer.dropEffect==="none"&&this.configuration.dragCanBePlacedBack){let x=h.currentTarget,b=this.draggables.get(x),Te=b.index<b.parent.children.length?b.index:b.parent.children.length-1,f=b.parent,Le=b.parent.children[Te];f.insertBefore(x,Le),this.saveResponse(),this.checkMaxMatchAssociations()}h.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 me,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,h=c.index<d.length?c.index:d.length;c.parent.insertBefore(p,d[h])}),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 h=this.droppables.find(x=>x.getAttribute("identifier")===p);d.forEach(x=>{let b=this.querySelector(`[identifier=${x}]`);h?b?(h.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(h=>h.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([ct(i)],r.prototype,"reInitDragAndDrop",1),s([Y({type:String,attribute:"response-identifier"})],r.prototype,"responseIdentifier",2),s([Y({attribute:!1,type:Object})],r.prototype,"configuration",2),s([g("configuration")],r.prototype,"handleDragOptionsChanged",1),s([Y({type:Boolean,reflect:!0})],r.prototype,"disabled",2),s([g("disabled",{waitUntilFirstUpdate:!0})],r.prototype,"handleDisabledChange",1),s([Y({type:Boolean,reflect:!0})],r.prototype,"readonly",2),s([g("readonly",{waitUntilFirstUpdate:!0})],r.prototype,"handleReadonlyChange",1),s([Y({type:Number,reflect:!0,attribute:"min-associations"})],r.prototype,"minAssociations",2),s([Y({type:Number,reflect:!0,attribute:"max-associations"})],r.prototype,"maxAssociations",2),r};import{state as si}from"lit/decorators.js";var W=class extends L(ri,"qti-simple-associable-choice",!0,".dl"){render(){return Rt` <slot name="prompt"></slot>
156
+ </div>`}`}};customElements.define("qti-portable-custom-interaction",at);import{LitElement as hi,css as fi,html as Ht}from"lit";var fe=class n{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 n._instance?n._instance:(n._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 mi}from"lit/decorators.js";var Nt=(n,i,e)=>{class t extends n{constructor(){super(...arguments);this.disabled=!1}firstUpdated(a){if(this.classList.contains("qti-match-tabular"))return;super.firstUpdated(a);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(a){a.addEventListener("dragover",this.dragoverHandler),a.addEventListener("drop",this.dropHandler)}removeHandler(a){a.removeEventListener("dragover",this.dragoverHandler),a.removeEventListener("drop",this.dropHandler)}disconnectedCallback(){var a;this.classList.contains("qti-match-tabular")||(super.disconnectedCallback(),(a=this.observer)==null||a.disconnect())}dragoverHandler(a){return a.preventDefault(),a.currentTarget.setAttribute("active",""),a.dataTransfer.dropEffect="move",!1}dropHandler(a){a.preventDefault();let l=a.currentTarget,c=this.querySelector(`[identifier=${a.dataTransfer.getData("text")}`),p=c||this.shadowRoot.querySelector(`[identifier=${a.dataTransfer.getData("text")}`);return l?p.parentElement.getAttribute("identifier")!==l.getAttribute("identifier")&&l.appendChild(p):console.error(`cannot find droppable, target: ${a.target?JSON.stringify(a.target):"null"}`),l.removeAttribute("active"),!1}dragleaveHandler(a){return a.preventDefault(),a.currentTarget.removeAttribute("active"),!1}}return s([mi({type:Boolean,reflect:!0})],t.prototype,"disabled",2),t};var Dt=(n,i,e)=>{class t extends n{}return t};import{property as Y}from"lit/decorators.js";var L=(n,i,e,t)=>{class r extends Dt(Nt(n,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",h=>{h.dataTransfer.setData("text",h.currentTarget.getAttribute("identifier")),d.setAttribute("dragging","")}),d.addEventListener("dragend",h=>{if(h.preventDefault(),d.removeAttribute("over"),d.removeAttribute("dragging"),h.dataTransfer.dropEffect==="none"&&this.configuration.dragCanBePlacedBack){let q=h.currentTarget,b=this.draggables.get(q),Se=b.index<b.parent.children.length?b.index:b.parent.children.length-1,f=b.parent,Me=b.parent.children[Se];f.insertBefore(q,Me),this.saveResponse(),this.checkMaxMatchAssociations()}h.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 fe,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,h=c.index<d.length?c.index:d.length;c.parent.insertBefore(p,d[h])}),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 h=this.droppables.find(q=>q.getAttribute("identifier")===p);d.forEach(q=>{let b=this.querySelector(`[identifier=${q}]`);h?b?(h.appendChild(b),this.checkMaxMatchAssociations()):console.error(`cannot find draggable with identifier: ${q}`):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(h=>h.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([ht(i)],r.prototype,"reInitDragAndDrop",1),s([Y({type:String,attribute:"response-identifier"})],r.prototype,"responseIdentifier",2),s([Y({attribute:!1,type:Object})],r.prototype,"configuration",2),s([g("configuration")],r.prototype,"handleDragOptionsChanged",1),s([Y({type:Boolean,reflect:!0})],r.prototype,"disabled",2),s([g("disabled",{waitUntilFirstUpdate:!0})],r.prototype,"handleDisabledChange",1),s([Y({type:Boolean,reflect:!0})],r.prototype,"readonly",2),s([g("readonly",{waitUntilFirstUpdate:!0})],r.prototype,"handleReadonlyChange",1),s([Y({type:Number,reflect:!0,attribute:"min-associations"})],r.prototype,"minAssociations",2),s([Y({type:Number,reflect:!0,attribute:"max-associations"})],r.prototype,"maxAssociations",2),r};import{state as gi}from"lit/decorators.js";var W=class extends L(hi,"qti-simple-associable-choice",!0,".dl"){render(){return Ht` <slot name="prompt"></slot>
145
157
  <slot name="qti-simple-associable-choice"></slot>
146
- ${this._childrenMap.length>0&&Array.from(Array(Math.ceil(this._childrenMap.length/2)).keys()).map((e,t)=>Rt`<div part="associables-container">
158
+ ${this._childrenMap.length>0&&Array.from(Array(Math.ceil(this._childrenMap.length/2)).keys()).map((e,t)=>Ht`<div part="associables-container">
147
159
  <div name="left${t}" part="drop-list" class="dl" identifier="droplist${t}_left"></div>
148
160
  <div name="right${t}" part="drop-list" class="dl" identifier="droplist${t}_right"></div>
149
- </div>`)}`}connectedCallback(){super.connectedCallback(),this._childrenMap=Array.from(this.querySelectorAll("qti-simple-associable-choice"))}};W.styles=ii`
161
+ </div>`)}`}connectedCallback(){super.connectedCallback(),this._childrenMap=Array.from(this.querySelectorAll("qti-simple-associable-choice"))}};W.styles=fi`
150
162
  :host {
151
163
  display: block; /* necessary to calculate scaling position */
152
164
  }
@@ -155,8 +167,8 @@ import{a as ct}from"../chunk-RPGALUIV.js";import{a as lt}from"../chunk-HQKT4SJF.
155
167
  flex-wrap: wrap;
156
168
  gap: 0.5rem;
157
169
  }
158
- `,s([si()],W.prototype,"_childrenMap",2);customElements.define("qti-associate-interaction",W);import{css as oi,html as ni,LitElement as ai}from"lit";var he=class extends L(ai,"qti-gap-text",!1,"qti-gap"){render(){return ni` <slot part="drags" name="qti-gap-text"></slot>
159
- <slot part="drops"></slot>`}};he.styles=[oi`
170
+ `,s([gi()],W.prototype,"_childrenMap",2);customElements.define("qti-associate-interaction",W);import{css as bi,html as vi,LitElement as yi}from"lit";var ge=class extends L(yi,"qti-gap-text",!1,"qti-gap"){render(){return vi` <slot part="drags" name="qti-gap-text"></slot>
171
+ <slot part="drops"></slot>`}};ge.styles=[bi`
160
172
  :host {
161
173
  display: flex;
162
174
  align-items: flex-start;
@@ -179,14 +191,14 @@ import{a as ct}from"../chunk-RPGALUIV.js";import{a as lt}from"../chunk-HQKT4SJF.
179
191
  align-items: flex-start;
180
192
  flex: 1;
181
193
  }
182
- `];customElements.define("qti-gap-match-interaction",he);import{css as li,svg as St,html as ci}from"lit";function U(n,i,e,t){switch(n){case"circle":{let[r,o,a]=i,l=r/e.width*100,c=o/e.height*100,p=a/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,a,l]=i,c=r/e.width*100,p=o/e.height*100,d=a/e.width*100,h=l/e.height*100;t.style.left=c+"%",t.style.top=p+"%",t.style.width=d-c+"%",t.style.height=h-p+"%"}break;case"poly":{let r=i.reduce((f,Le,at,Vt)=>{if(at%2===1){let $t=f.pop();f[f.length]={x:$t,y:Vt[at]}}else f.push(Le);return f},[]),o=Math.min(...r.map(f=>f.x)),a=Math.max(...r.map(f=>f.x)),l=Math.min(...r.map(f=>f.y)),c=Math.max(...r.map(f=>f.y)),p=o/e.width*100,d=l/e.height*100,h=a/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=h-p+"%",t.style.height=x-d+"%";let Te=r.map(f=>({x:(f.x-o)/(a-o)*100,y:(f.y-l)/(c-l)*100})).map(f=>Math.round(f.x)+"% "+Math.round(f.y)+"%").join(",");t.style.clipPath=`polygon(${Te})`}break;default:break}}import{query as pi,queryAssignedElements as di,state as it}from"lit/decorators.js";import{repeat as ui}from"lit/directives/repeat.js";import{ifDefined as Mt}from"lit/directives/if-defined.js";var M=class extends m{constructor(){super();this.startPoint=null;this.endPoint=null;this._lines=[];this.addEventListener("qti-register-hotspot",this.positionHotspotOnRegister)}reset(){this._lines=[]}validate(){return this._lines.length>0}set response(e){Array.isArray(e)&&(this._lines=e)}render(){var e,t,r,o;return ci`<slot name="prompt"></slot>
194
+ `];customElements.define("qti-gap-match-interaction",ge);import{css as xi,svg as Ot,html as Ei}from"lit";function U(n,i,e,t){switch(n){case"circle":{let[r,o,a]=i,l=r/e.width*100,c=o/e.height*100,p=a/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,a,l]=i,c=r/e.width*100,p=o/e.height*100,d=a/e.width*100,h=l/e.height*100;t.style.left=c+"%",t.style.top=p+"%",t.style.width=d-c+"%",t.style.height=h-p+"%"}break;case"poly":{let r=i.reduce((f,Me,ut,Xt)=>{if(ut%2===1){let Yt=f.pop();f[f.length]={x:Yt,y:Xt[ut]}}else f.push(Me);return f},[]),o=Math.min(...r.map(f=>f.x)),a=Math.max(...r.map(f=>f.x)),l=Math.min(...r.map(f=>f.y)),c=Math.max(...r.map(f=>f.y)),p=o/e.width*100,d=l/e.height*100,h=a/e.width*100,q=c/e.height*100;t.style.left=o/e.width*100+"%",t.style.top=l/e.height*100+"%",t.style.width=h-p+"%",t.style.height=q-d+"%";let Se=r.map(f=>({x:(f.x-o)/(a-o)*100,y:(f.y-l)/(c-l)*100})).map(f=>Math.round(f.x)+"% "+Math.round(f.y)+"%").join(",");t.style.clipPath=`polygon(${Se})`}break;default:break}}import{query as qi,queryAssignedElements as Ci,state as lt}from"lit/decorators.js";import{repeat as _i}from"lit/directives/repeat.js";import{ifDefined as Vt}from"lit/directives/if-defined.js";var M=class extends m{constructor(){super();this.startPoint=null;this.endPoint=null;this._lines=[];this.addEventListener("qti-register-hotspot",this.positionHotspotOnRegister)}reset(){this._lines=[]}validate(){return this._lines.length>0}set response(e){Array.isArray(e)&&(this._lines=e)}render(){var e,t,r,o;return Ei`<slot name="prompt"></slot>
183
195
  <line-container>
184
196
  <svg
185
- width=${Mt((e=this.grImage[0])==null?void 0:e.width)}
186
- height=${Mt((t=this.grImage[0])==null?void 0:t.height)}
197
+ width=${Vt((e=this.grImage[0])==null?void 0:e.width)}
198
+ height=${Vt((t=this.grImage[0])==null?void 0:t.height)}
187
199
  viewbox="0 0 ${(r=this.grImage[0])==null?void 0:r.width} ${(o=this.grImage[0])==null?void 0:o.height}"
188
200
  >
189
- ${ui(this._lines,a=>a,(a,l)=>St`
201
+ ${_i(this._lines,a=>a,(a,l)=>Ot`
190
202
  <line
191
203
  part="line"
192
204
  x1=${parseInt(this.querySelector("[identifier="+a.split(" ")[0]+"]").style.left)}
@@ -198,7 +210,7 @@ import{a as ct}from"../chunk-RPGALUIV.js";import{a as lt}from"../chunk-HQKT4SJF.
198
210
  @click=${c=>{c.stopPropagation(),this._lines=this._lines.filter((p,d)=>d!==l),this.saveResponse(this._lines)}}
199
211
  />
200
212
  `)}
201
- ${this.startPoint&&St`<line
213
+ ${this.startPoint&&Ot`<line
202
214
  part="point"
203
215
  x1=${this.startCoord.x}
204
216
  y1=${this.startCoord.y}
@@ -209,7 +221,7 @@ import{a as ct}from"../chunk-RPGALUIV.js";import{a as lt}from"../chunk-HQKT4SJF.
209
221
  />`}
210
222
  </svg>
211
223
  <slot></slot>
212
- </line-container>`}positionHotspotOnRegister(e){let t=this.querySelector("img"),r=e.target,o=r.getAttribute("coords"),a=r.getAttribute("shape"),l=o.split(",").map(c=>parseInt(c));U(a,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=[li`
224
+ </line-container>`}positionHotspotOnRegister(e){let t=this.querySelector("img"),r=e.target,o=r.getAttribute("coords"),a=r.getAttribute("shape"),l=o.split(",").map(c=>parseInt(c));U(a,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=[xi`
213
225
  slot:not([name='prompt']) {
214
226
  // position: relative; /* qti-hotspot-choice relative to the slot */
215
227
  display: block;
@@ -232,8 +244,8 @@ import{a as ct}from"../chunk-RPGALUIV.js";import{a as lt}from"../chunk-HQKT4SJF.
232
244
  top: 0px;
233
245
  left: 0px;
234
246
  }
235
- `],s([it()],M.prototype,"_lines",2),s([it()],M.prototype,"startCoord",2),s([it()],M.prototype,"mouseCoord",2),s([pi("svg")],M.prototype,"svgContainer",2),s([di({selector:"img"})],M.prototype,"grImage",2);customElements.define("qti-graphic-associate-interaction",M);import{css as mi,html as hi,LitElement as fi}from"lit";var fe=class extends L(fi,"qti-gap-img",!1,"qti-associable-hotspot"){render(){return hi` <slot></slot>
236
- <slot name="qti-gap-img"></slot>`}positionHotspotOnRegister(i){let e=this.querySelector("img"),t=i.target,r=t.getAttribute("coords"),o=t.getAttribute("shape"),a=r.split(",").map(l=>parseInt(l));switch(o){case"circle":{let[l,c,p]=a;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]=a;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)}};fe.styles=mi`
247
+ `],s([lt()],M.prototype,"_lines",2),s([lt()],M.prototype,"startCoord",2),s([lt()],M.prototype,"mouseCoord",2),s([qi("svg")],M.prototype,"svgContainer",2),s([Ci({selector:"img"})],M.prototype,"grImage",2);customElements.define("qti-graphic-associate-interaction",M);import{css as ki,html as Ai,LitElement as wi}from"lit";var be=class extends L(wi,"qti-gap-img",!1,"qti-associable-hotspot"){render(){return Ai` <slot></slot>
248
+ <slot name="qti-gap-img"></slot>`}positionHotspotOnRegister(i){let e=this.querySelector("img"),t=i.target,r=t.getAttribute("coords"),o=t.getAttribute("shape"),a=r.split(",").map(l=>parseInt(l));switch(o){case"circle":{let[l,c,p]=a;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]=a;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)}};be.styles=ki`
237
249
  :host {
238
250
  display: inline-block;
239
251
  position: relative;
@@ -242,12 +254,12 @@ import{a as ct}from"../chunk-RPGALUIV.js";import{a as lt}from"../chunk-HQKT4SJF.
242
254
  display: flex;
243
255
  gap: 1rem;
244
256
  }
245
- `;customElements.define("qti-graphic-gap-match-interaction",fe);import{css as gi,html as bi}from"lit";var ge=class extends v{render(){return bi`
257
+ `;customElements.define("qti-graphic-gap-match-interaction",be);import{css as Ti,html as Li}from"lit";var ve=class extends v{render(){return Li`
246
258
  <slot name="prompt"></slot>
247
259
  <!-- slot for the prompt -->
248
260
  <slot></slot>
249
261
  <!-- slot for the image and hotspots -->
250
- `}setHotspotOrder(e){let{identifier:t}=e.detail,r=this._choiceElements.find(a=>a.getAttribute("identifier")===t),o=this._choiceElements.length;if(!this.choiceOrdering){if(this.choiceOrdering=!0,r.order==null){if(this._choiceElements.filter(a=>a.order>0).length>=o){this.choiceOrdering=!1;return}r.order=this._choiceElements.filter(a=>!!a.order).length+1,this.choiceOrdering=!1;return}else this._choiceElements.forEach(a=>(a.order>a.order&&a.order--,a)),r.order=null;this.choiceOrdering=!1}}positionHotspotOnRegister(e){let t=this.querySelector("img"),r=e.target,o=r.getAttribute("coords"),a=r.getAttribute("shape"),l=o.split(",").map(c=>parseInt(c));U(a,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)}};ge.styles=[gi`
262
+ `}setHotspotOrder(e){let{identifier:t}=e.detail,r=this._choiceElements.find(a=>a.getAttribute("identifier")===t),o=this._choiceElements.length;if(!this.choiceOrdering){if(this.choiceOrdering=!0,r.order==null){if(this._choiceElements.filter(a=>a.order>0).length>=o){this.choiceOrdering=!1;return}r.order=this._choiceElements.filter(a=>!!a.order).length+1,this.choiceOrdering=!1;return}else this._choiceElements.forEach(a=>(a.order>a.order&&a.order--,a)),r.order=null;this.choiceOrdering=!1}}positionHotspotOnRegister(e){let t=this.querySelector("img"),r=e.target,o=r.getAttribute("coords"),a=r.getAttribute("shape"),l=o.split(",").map(c=>parseInt(c));U(a,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)}};ve.styles=[Ti`
251
263
  slot:not([name='prompt']) {
252
264
  position: relative; /* qti-hotspot-choice relative to the slot */
253
265
  display: block;
@@ -258,12 +270,12 @@ import{a as ct}from"../chunk-RPGALUIV.js";import{a as lt}from"../chunk-HQKT4SJF.
258
270
  pointer-events: none;
259
271
  user-select: none;
260
272
  }
261
- `];customElements.define("qti-graphic-order-interaction",ge);import{css as vi,html as yi}from"lit";var be=class extends v{render(){return yi`
273
+ `];customElements.define("qti-graphic-order-interaction",ve);import{css as Ri,html as Si}from"lit";var ye=class extends v{render(){return Si`
262
274
  <slot name="prompt"></slot>
263
275
  <!-- slot for the prompt -->
264
276
  <slot></slot>
265
277
  <!-- slot for the image and hotspots -->
266
- `}positionHotspotOnRegister(i){let e=this.querySelector("img"),t=i.target,r=t.getAttribute("coords"),o=t.getAttribute("shape"),a=r.split(",").map(l=>parseInt(l));U(o,a,e,t)}connectedCallback(){super.connectedCallback(),this.addEventListener("qti-register-choice",this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-register-choice",this.positionHotspotOnRegister)}};be.styles=[vi`
278
+ `}positionHotspotOnRegister(i){let e=this.querySelector("img"),t=i.target,r=t.getAttribute("coords"),o=t.getAttribute("shape"),a=r.split(",").map(l=>parseInt(l));U(o,a,e,t)}connectedCallback(){super.connectedCallback(),this.addEventListener("qti-register-choice",this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-register-choice",this.positionHotspotOnRegister)}};ye.styles=[Ri`
267
279
  slot:not([name='prompt']) {
268
280
  position: relative; /* qti-hotspot-choice relative to the slot */
269
281
  display: block;
@@ -275,10 +287,10 @@ import{a as ct}from"../chunk-RPGALUIV.js";import{a as lt}from"../chunk-HQKT4SJF.
275
287
  user-select: none;
276
288
  /* width:100%; */
277
289
  }
278
- `];customElements.define("qti-hotspot-interaction",be);import{html as J,LitElement as Ci}from"lit";import{html as Ei,LitElement as xi}from"lit";var st=class extends xi{connectedCallback(){super.connectedCallback(),this.setAttribute("slot","qti-simple-associable-choice"),this.setAttribute("part","qti-simple-associable-choice")}render(){return Ei`
290
+ `];customElements.define("qti-hotspot-interaction",ye);import{html as J,LitElement as Di}from"lit";import{html as Mi,LitElement as Ni}from"lit";var ct=class extends Ni{connectedCallback(){super.connectedCallback(),this.setAttribute("slot","qti-simple-associable-choice"),this.setAttribute("part","qti-simple-associable-choice")}render(){return Mi`
279
291
  <slot></slot>
280
292
  <slot name="qti-simple-associable-choice"></slot>
281
- `}};customElements.define("qti-simple-associable-choice",st);var ve=class extends L(Ci,"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")?J`<table>
293
+ `}};customElements.define("qti-simple-associable-choice",ct);var xe=class extends L(Di,"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")?J`<table>
282
294
  <tr>
283
295
  <td><slot name="prompt"></slot></td>
284
296
  ${this.cols.map((e,t)=>J`<th>${e.innerHTML}</th>`)}
@@ -287,14 +299,14 @@ import{a as ct}from"../chunk-RPGALUIV.js";import{a as lt}from"../chunk-HQKT4SJF.
287
299
  <td>${e.innerHTML}</td>
288
300
  ${this.cols.map((t,r)=>J`<td><input type="checkbox" /></td>`)}
289
301
  </tr>`)}
290
- </table>`:J`<slot name="prompt"></slot> <slot></slot>`}};ve.styles=[];customElements.define("qti-match-interaction",ve);import{css as qi,html as _i}from"lit";var ye=class extends m{constructor(){super()}reset(){}validate(){return!0}set response(e){}static get properties(){return O(C({},m.properties),{step:{type:Number,attribute:"step",default:10}})}render(){return _i` <slot name="prompt"></slot>
291
- <slot></slot>`}connectedCallback(){super.connectedCallback()}};ye.styles=[qi``];customElements.define("qti-media-interaction",ye);import{css as ki,html as Nt,LitElement as Ai}from"lit";import{property as wi}from"lit/decorators.js";var B=class extends L(Ai,"qti-simple-choice",!0,"drop-list"){render(){return Nt` <slot name="prompt"> </slot>
302
+ </table>`:J`<slot name="prompt"></slot> <slot></slot>`}};xe.styles=[];customElements.define("qti-match-interaction",xe);import{css as Hi,html as Oi}from"lit";var Ee=class extends m{constructor(){super()}reset(){}validate(){return!0}set response(e){}static get properties(){return O(C({},m.properties),{step:{type:Number,attribute:"step",default:10}})}render(){return Oi` <slot name="prompt"></slot>
303
+ <slot></slot>`}connectedCallback(){super.connectedCallback()}};Ee.styles=[Hi``];customElements.define("qti-media-interaction",Ee);import{css as Vi,html as $t,LitElement as $i}from"lit";import{property as Pi}from"lit/decorators.js";var B=class extends L($i,"qti-simple-choice",!0,"drop-list"){render(){return $t` <slot name="prompt"> </slot>
292
304
  <div part="container">
293
305
  <slot part="drags"> </slot>
294
306
  <div part="drops">
295
- ${Array.from(this.querySelectorAll("qti-simple-choice")).map((e,t)=>Nt`<drop-list part="drop-list" identifier="droplist${t}"></drop-list>`)}
307
+ ${Array.from(this.querySelectorAll("qti-simple-choice")).map((e,t)=>$t`<drop-list part="drop-list" identifier="droplist${t}"></drop-list>`)}
296
308
  </div>
297
- </div>`}connectedCallback(){super.connectedCallback(),this.childrenMap=Array.from(this.querySelectorAll("qti-simple-choice")),this.childrenMap.forEach(e=>e.setAttribute("part","qti-simple-choice"))}};B.layoutClass=["qti-choices-top","qti-choices-bottom","qti-choices-left","qti-choices-right"],B.styles=[ki`
309
+ </div>`}connectedCallback(){super.connectedCallback(),this.childrenMap=Array.from(this.querySelectorAll("qti-simple-choice")),this.childrenMap.forEach(e=>e.setAttribute("part","qti-simple-choice"))}};B.layoutClass=["qti-choices-top","qti-choices-bottom","qti-choices-left","qti-choices-right"],B.styles=[Vi`
298
310
  [part='drags'] {
299
311
  display: flex;
300
312
  align-items: flex-start;
@@ -342,7 +354,7 @@ import{a as ct}from"../chunk-RPGALUIV.js";import{a as lt}from"../chunk-HQKT4SJF.
342
354
  :host(.qti-choices-right) [part='container'] {
343
355
  flex-direction: row-reverse;
344
356
  }
345
- `],s([wi({type:String})],B.prototype,"orientation",2);customElements.define("qti-order-interaction",B);import{LitElement as Ti,css as Li,html as Ri}from"lit";var Ee=class extends Ti{render(){return Ri`<slot></slot>`}};Ee.styles=[Li`
357
+ `],s([Pi({type:String})],B.prototype,"orientation",2);customElements.define("qti-order-interaction",B);import{LitElement as Ii,css as Fi,html as Xi}from"lit";var qe=class extends Ii{render(){return Xi`<slot></slot>`}};qe.styles=[Fi`
346
358
  :host {
347
359
  display: block;
348
360
  }
@@ -353,22 +365,22 @@ import{a as ct}from"../chunk-RPGALUIV.js";import{a as lt}from"../chunk-HQKT4SJF.
353
365
  left: 50%;
354
366
  transform: translateX(-50%);
355
367
  }
356
- `];customElements.define("qti-position-object-interaction",Ee);import{LitElement as Si,css as Mi,html as Ni}from"lit";var xe=class extends Si{constructor(){super();this.removeMoveListener=this.removeMoveListener.bind(this),this.dragElementHandler=this.dragElementHandler.bind(this)}render(){return Ni`<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)}};xe.styles=[Mi`
368
+ `];customElements.define("qti-position-object-interaction",qe);import{LitElement as Yi,css as Ui,html as Bi}from"lit";var Ce=class extends Yi{constructor(){super();this.removeMoveListener=this.removeMoveListener.bind(this),this.dragElementHandler=this.dragElementHandler.bind(this)}render(){return Bi`<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)}};Ce.styles=[Ui`
357
369
  :host {
358
370
  display: inline-block;
359
371
  position: relative;
360
372
  }
361
- `];customElements.define("qti-position-object-stage",xe);import{css as Di,html as Dt}from"lit";import{property as Ht,state as Hi}from"lit/decorators.js";import{repeat as Oi}from"lit/directives/repeat.js";import{styleMap as Vi}from"lit/directives/style-map.js";var H=class extends m{constructor(){super(...arguments);this.maxChoices=0;this.minChoices=0;this._points=[]}render(){return Dt` <slot name="prompt"></slot>
373
+ `];customElements.define("qti-position-object-stage",Ce);import{css as Ki,html as Pt}from"lit";import{property as It,state as ji}from"lit/decorators.js";import{repeat as zi}from"lit/directives/repeat.js";import{styleMap as Gi}from"lit/directives/style-map.js";var H=class extends m{constructor(){super(...arguments);this.maxChoices=0;this.minChoices=0;this._points=[]}render(){return Pt` <slot name="prompt"></slot>
362
374
  <point-container>
363
- ${Oi(this._points,e=>e,(e,t)=>Dt`
375
+ ${zi(this._points,e=>e,(e,t)=>Pt`
364
376
  <button
365
377
  part="point"
366
- style=${Vi({position:"absolute",transform:"translate(-50%, -50%)",left:`${e.split(" ")[0]}px`,top:`${e.split(" ")[1]}px`})}
378
+ style=${Gi({position:"absolute",transform:"translate(-50%, -50%)",left:`${e.split(" ")[0]}px`,top:`${e.split(" ")[1]}px`})}
367
379
  @click=${r=>{r.stopPropagation(),this._points=this._points.filter((o,a)=>a!==t),this.saveResponse(this._points)}}
368
380
  ></button>
369
381
  `)}
370
382
  <slot></slot>
371
- </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()}};H.styles=[Di`
383
+ </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()}};H.styles=[Ki`
372
384
  host() {
373
385
  display: block;
374
386
  }
@@ -376,26 +388,26 @@ import{a as ct}from"../chunk-RPGALUIV.js";import{a as lt}from"../chunk-HQKT4SJF.
376
388
  display: block;
377
389
  position: relative;
378
390
  }
379
- `],s([Ht({type:Number,attribute:"max-choices"})],H.prototype,"maxChoices",2),s([Ht({type:Number,attribute:"min-choices"})],H.prototype,"minChoices",2),s([Hi()],H.prototype,"_points",2);customElements.define("qti-select-point-interaction",H);import{css as $i,html as Ce,nothing as ot}from"lit";import{property as K,query as Ot}from"lit/decorators.js";var E=class extends m{constructor(){super();this.stepLabel=!1;this.reverse=!1;this._handleDisabledChange=(e,t)=>{};this._handleReadonlyChange=(e,t)=>{};this.csLive=getComputedStyle(this)}set min(e){this._min=e,this.value=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 this.style.setProperty("--value-percentage",`${e}%`),this.setAttribute("aria-valuenow",this.value.toString()),Ce`<slot name="prompt"></slot>
391
+ `],s([It({type:Number,attribute:"max-choices"})],H.prototype,"maxChoices",2),s([It({type:Number,attribute:"min-choices"})],H.prototype,"minChoices",2),s([ji()],H.prototype,"_points",2);customElements.define("qti-select-point-interaction",H);import{css as Wi,html as _e,nothing as pt}from"lit";import{property as K,query as Ft}from"lit/decorators.js";var x=class extends m{constructor(){super();this.stepLabel=!1;this.reverse=!1;this._handleDisabledChange=(e,t)=>{};this._handleReadonlyChange=(e,t)=>{};this.csLive=getComputedStyle(this)}set min(e){this._min=e,this.value=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 this.style.setProperty("--value-percentage",`${e}%`),this.setAttribute("aria-valuenow",this.value.toString()),_e`<slot name="prompt"></slot>
380
392
  <div id="slider" part="slider">
381
- ${this.csLive.getPropertyValue("--show-bounds")=="true"?Ce`<div id="bounds" part="bounds">
393
+ ${this.csLive.getPropertyValue("--show-bounds")=="true"?_e`<div id="bounds" part="bounds">
382
394
  <div>${this._min}</div>
383
395
  <div>${this._max}</div>
384
- </div>`:ot}
385
- ${this.csLive.getPropertyValue("--show-ticks")=="true"?Ce`<div id="ticks" part="ticks"></div>`:ot}
396
+ </div>`:pt}
397
+ ${this.csLive.getPropertyValue("--show-ticks")=="true"?_e`<div id="ticks" part="ticks"></div>`:pt}
386
398
  <div id="rail" part="rail" @mousedown=${this._onMouseDown} @touchstart=${this._onTouchMove}>
387
399
  <div id="knob" part="knob">
388
- ${this.csLive.getPropertyValue("--show-value")=="true"?Ce`<div id="value" part="value">${this.value}</div>`:ot}
400
+ ${this.csLive.getPropertyValue("--show-value")=="true"?_e`<div id="value" part="value">${this.value}</div>`:pt}
389
401
  </div>
390
402
  </div>
391
- </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),a=o-this._rail.getBoundingClientRect().left-document.documentElement.scrollLeft;this.calculateValue(a),e.stopPropagation()}_onMouseDown(e){let t=a=>{let l=a.pageX-this._rail.getBoundingClientRect().left-document.documentElement.scrollLeft;this.calculateValue(l),a.preventDefault(),a.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._rail.getBoundingClientRect().width,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=[$i``],s([Ot("#knob")],E.prototype,"_knob",2),s([Ot("#rail")],E.prototype,"_rail",2),s([K({type:Number})],E.prototype,"value",2),s([K({type:Boolean,attribute:"step-label"})],E.prototype,"stepLabel",2),s([K({type:Boolean})],E.prototype,"reverse",2),s([K({type:Number,attribute:"lower-bound"})],E.prototype,"min",1),s([K({type:Number,attribute:"upper-bound"})],E.prototype,"max",1),s([K({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 Pi,css as Ii,html as Fi}from"lit";var qe=class extends Pi{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> `}};qe.styles=Ii`
403
+ </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),a=o-this._rail.getBoundingClientRect().left-document.documentElement.scrollLeft;this.calculateValue(a),e.stopPropagation()}_onMouseDown(e){let t=a=>{let l=a.pageX-this._rail.getBoundingClientRect().left-document.documentElement.scrollLeft;this.calculateValue(l),a.preventDefault(),a.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._rail.getBoundingClientRect().width,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=[Wi``],s([Ft("#knob")],x.prototype,"_knob",2),s([Ft("#rail")],x.prototype,"_rail",2),s([K({type:Number})],x.prototype,"value",2),s([K({type:Boolean,attribute:"step-label"})],x.prototype,"stepLabel",2),s([K({type:Boolean})],x.prototype,"reverse",2),s([K({type:Number,attribute:"lower-bound"})],x.prototype,"min",1),s([K({type:Number,attribute:"upper-bound"})],x.prototype,"max",1),s([K({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{LitElement as Ji,html as Zi}from"lit";import{property as Qi}from"lit/decorators.js";var ke=class extends Ji{render(){return Zi`<button @click=${this.endAttempt}>${this.title}</button>`}endAttempt(e){this.closest("qti-assessment-item").processResponse()}};s([Qi({type:String})],ke.prototype,"title",2);customElements.define("qti-end-attempt-interaction",ke);import{LitElement as es,css as ts,html as rs}from"lit";var Ae=class extends es{connectedCallback(){super.connectedCallback(),this.dispatchEvent(new CustomEvent("qti-register-hotspot",{bubbles:!0,cancelable:!1,composed:!0}))}render(){return rs` <slot name="qti-gap-img"></slot> `}};Ae.styles=ts`
392
404
  :host {
393
405
  position: absolute;
394
406
  }
395
- `;customElements.define("qti-associable-hotspot",qe);import{LitElement as Xi}from"lit";import{property as Yi}from"lit/decorators.js";var _e=class extends Xi{constructor(){super(...arguments);this.tabindex=0}connectedCallback(){this.setAttribute("slot","qti-gap-img")}};s([Yi({type:Number,reflect:!0})],_e.prototype,"tabindex",2);customElements.define("qti-gap-img",_e);import{html as Ui,LitElement as Bi}from"lit";import{property as Ki}from"lit/decorators.js";var ke=class extends Bi{constructor(){super(...arguments);this.tabindex=0}connectedCallback(){super.connectedCallback(),this.setAttribute("slot","qti-gap-text")}render(){return Ui`<slot></slot>`}};s([Ki({type:Number,reflect:!0})],ke.prototype,"tabindex",2);customElements.define("qti-gap-text",ke);import{html as ji,LitElement as zi}from"lit";import{property as Gi}from"lit/decorators.js";var Ae=class extends zi{constructor(){super(...arguments);this.tabindex=0}render(){return ji` <slot name="qti-gap-text"></slot>`}};s([Gi({type:Number,reflect:!0})],Ae.prototype,"tabindex",2);customElements.define("qti-gap",Ae);import{css as Wi}from"lit";import{property as Ji}from"lit/decorators.js";var Z=class extends y{};Z.styles=Wi`
407
+ `;customElements.define("qti-associable-hotspot",Ae);import{LitElement as is}from"lit";import{property as ss}from"lit/decorators.js";var we=class extends is{constructor(){super(...arguments);this.tabindex=0}connectedCallback(){this.setAttribute("slot","qti-gap-img")}};s([ss({type:Number,reflect:!0})],we.prototype,"tabindex",2);customElements.define("qti-gap-img",we);import{html as os,LitElement as ns}from"lit";import{property as as}from"lit/decorators.js";var Te=class extends ns{constructor(){super(...arguments);this.tabindex=0}connectedCallback(){super.connectedCallback(),this.setAttribute("slot","qti-gap-text")}render(){return os`<slot></slot>`}};s([as({type:Number,reflect:!0})],Te.prototype,"tabindex",2);customElements.define("qti-gap-text",Te);import{html as ls,LitElement as cs}from"lit";import{property as ps}from"lit/decorators.js";var Le=class extends cs{constructor(){super(...arguments);this.tabindex=0}render(){return ls` <slot name="qti-gap-text"></slot>`}};s([ps({type:Number,reflect:!0})],Le.prototype,"tabindex",2);customElements.define("qti-gap",Le);import{css as ds}from"lit";import{property as us}from"lit/decorators.js";var Z=class extends y{};Z.styles=ds`
396
408
  :host {
397
409
  position: absolute;
398
410
  }
399
- `,s([Ji({attribute:"aria-ordervalue",type:Number,reflect:!0})],Z.prototype,"order",2);customElements.define("qti-hotspot-choice",Z);import{customElement as Zi}from"lit/decorators.js";import{html as Qi}from"lit";var we=class extends y{render(){return Qi`<div part="ch"><div part="cha"></div></div>
400
- <slot></slot> `}};we=s([Zi("qti-hottext")],we);import{LitElement as es}from"lit";var nt=class extends es{};customElements.define("qti-inline-choice",nt);import{customElement as ts}from"lit/decorators.js";import{html as rs}from"lit";var Q=class extends y{render(){return rs`<div part="ch"><div part="cha"></div></div>
401
- <slot></slot> `}};Q=s([ts("qti-simple-choice")],Q);export{yt as Events,$ as OutcomeVariable,Ke as QtiAnd,q as QtiAssessmentItem,qe as QtiAssociableHotspot,W as QtiAssociateInteraction,de as QtiBaseValue,y as QtiChoice,vt as QtiChoiceElementSelected,te as QtiCompanionMaterialsInfo,ze as QtiContains,Ge as QtiCorrect,ce as QtiEqual,pe as QtiEqualRounded,u as QtiExpression,A as QtiExtendedTextInteraction,oe as QtiFeedbackInline,Ae as QtiGap,_e as QtiGapImg,he as QtiGapMatchInteraction,ke as QtiGapText,M as QtiGraphicAssociateInteraction,fe as QtiGraphicGapMatchInteraction,ge as QtiGraphicOrderInteraction,Xe as QtiGt,Ye as QtiGte,Z as QtiHotspotChoice,be as QtiHotspotInteraction,we as QtiHottext,$e as QtiHottextInteraction,nt as QtiInlineChoice,le as QtiInlineChoiceInteraction,dt as QtiInteractionChanged,bt as QtiInteractionResponse,We as QtiIsNull,gt as QtiLooseChoice,Ue as QtiLt,Be as QtiLte,ue as QtiMapResponse,X as QtiMapping,Je as QtiMatch,ve as QtiMatchInteraction,ye as QtiMediaInteraction,De as QtiModalFeedback,Qe as QtiMultiple,je as QtiOr,B as QtiOrderInteraction,et as QtiOrdered,pt as QtiOutcomeChanged,Ne as QtiOutcomeDeclaration,rt as QtiPortableCustomInteraction,xe as QtiPositionObjectStage,Se as QtiPrompt,ht as QtiRegisterChoice,ft as QtiRegisterHotspot,mt as QtiRegisterInteraction,ut as QtiRegisterVariable,Pe as QtiResponseCondition,I as QtiResponseDeclaration,z as QtiResponseElse,Fe as QtiResponseElseIf,G as QtiResponseIf,F as QtiResponseProcessing,S as QtiRule,Ee as QtiSPositionObjectInteraction,H as QtiSelectPointInteraction,Ie as QtiSetOutcomeValue,st as QtiSimpleAssociableChoice,E as QtiSliderInteraction,Re as QtiStylesheet,R as QtiTextEntryInteraction,Ze as QtiVariable,V as ResponseVariable,ie as qtiContentBody,_ as qtiRubricBlock};
411
+ `,s([us({attribute:"aria-ordervalue",type:Number,reflect:!0})],Z.prototype,"order",2);customElements.define("qti-hotspot-choice",Z);import{customElement as ms}from"lit/decorators.js";import{html as hs}from"lit";var Re=class extends y{render(){return hs`<div part="ch"><div part="cha"></div></div>
412
+ <slot></slot> `}};Re=s([ms("qti-hottext")],Re);import{LitElement as fs}from"lit";var dt=class extends fs{};customElements.define("qti-inline-choice",dt);import{customElement as gs}from"lit/decorators.js";import{html as bs}from"lit";var Q=class extends y{render(){return bs`<div part="ch"><div part="cha"></div></div>
413
+ <slot></slot> `}};Q=s([gs("qti-simple-choice")],Q);export{_t as Events,$ as OutcomeVariable,he as QtPrintedVariable,We as QtiAnd,_ as QtiAssessmentItem,Ae as QtiAssociableHotspot,W as QtiAssociateInteraction,ue as QtiBaseValue,y as QtiChoice,Ct as QtiChoiceElementSelected,te as QtiCompanionMaterialsInfo,Ze as QtiContains,Qe as QtiCorrect,ke as QtiEndAttemptInteraction,pe as QtiEqual,de as QtiEqualRounded,u as QtiExpression,A as QtiExtendedTextInteraction,$e as QtiFeedbackBlock,oe as QtiFeedbackInline,Le as QtiGap,we as QtiGapImg,ge as QtiGapMatchInteraction,Te as QtiGapText,M as QtiGraphicAssociateInteraction,be as QtiGraphicGapMatchInteraction,ve as QtiGraphicOrderInteraction,Ke as QtiGt,je as QtiGte,Z as QtiHotspotChoice,ye as QtiHotspotInteraction,Re as QtiHottext,Xe as QtiHottextInteraction,dt as QtiInlineChoice,le as QtiInlineChoiceInteraction,gt as QtiInteractionChanged,qt as QtiInteractionResponse,et as QtiIsNull,Et as QtiLooseChoice,ze as QtiLt,Ge as QtiLte,me as QtiMapResponse,X as QtiMapping,rt as QtiMatch,xe as QtiMatchInteraction,Ee as QtiMediaInteraction,Ve as QtiModalFeedback,st as QtiMultiple,tt as QtiNot,Je as QtiOr,B as QtiOrderInteraction,ot as QtiOrdered,ft as QtiOutcomeChanged,Oe as QtiOutcomeDeclaration,at as QtiPortableCustomInteraction,Ce as QtiPositionObjectStage,ce as QtiProduct,De as QtiPrompt,yt as QtiRegisterChoice,xt as QtiRegisterHotspot,vt as QtiRegisterInteraction,bt as QtiRegisterVariable,Ye as QtiResponseCondition,I as QtiResponseDeclaration,z as QtiResponseElse,Be as QtiResponseElseIf,G as QtiResponseIf,F as QtiResponseProcessing,S as QtiRule,qe as QtiSPositionObjectInteraction,H as QtiSelectPointInteraction,Ue as QtiSetOutcomeValue,ct as QtiSimpleAssociableChoice,x as QtiSliderInteraction,Ne as QtiStylesheet,R as QtiTextEntryInteraction,it as QtiVariable,V as ResponseVariable,ie as qtiContentBody,k as qtiRubricBlock};