@citolab/qti-components 6.9.1-beta.68 → 6.9.1-beta.69

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.
package/dist/index.min.js CHANGED
@@ -1,7 +1,7 @@
1
1
  var Nr=Object.defineProperty,zi=Object.defineProperties,Wi=Object.getOwnPropertyDescriptor,Yi=Object.getOwnPropertyDescriptors;var Hr=Object.getOwnPropertySymbols;var Ki=Object.prototype.hasOwnProperty,Zi=Object.prototype.propertyIsEnumerable;var Vr=(s,t,e)=>t in s?Nr(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e,q=(s,t)=>{for(var e in t||(t={}))Ki.call(t,e)&&Vr(s,e,t[e]);if(Hr)for(var e of Hr(t))Zi.call(t,e)&&Vr(s,e,t[e]);return s},S=(s,t)=>zi(s,Yi(t));var l=(s,t,e,r)=>{for(var i=r>1?void 0:r?Wi(t,e):t,o=s.length-1,n;o>=0;o--)(n=s[o])&&(i=(r?n(t,e,i):n(i))||i);return r&&i&&Nr(t,e,i),i};var ee=class extends Event{constructor(t,e,r){super("context-request",{bubbles:!0,composed:!0}),this.context=t,this.callback=e,this.subscribe=r!=null?r:!1}};var Ee=class{constructor(t,e,r,i){var o;if(this.subscribe=!1,this.provided=!1,this.value=void 0,this.t=(n,a)=>{this.unsubscribe&&(this.unsubscribe!==a&&(this.provided=!1,this.unsubscribe()),this.subscribe||this.unsubscribe()),this.value=n,this.host.requestUpdate(),this.provided&&!this.subscribe||(this.provided=!0,this.callback&&this.callback(n,a)),this.unsubscribe=a},this.host=t,e.context!==void 0){let n=e;this.context=n.context,this.callback=n.callback,this.subscribe=(o=n.subscribe)!=null?o:!1}else this.context=e,this.callback=r,this.subscribe=i!=null?i:!1;this.host.addController(this)}hostConnected(){this.dispatchRequest()}hostDisconnected(){this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=void 0)}dispatchRequest(){this.host.dispatchEvent(new ee(this.context,this.t,this.subscribe))}};var vt=class{get value(){return this.o}set value(t){this.setValue(t)}setValue(t,e=!1){let r=e||!Object.is(t,this.o);this.o=t,r&&this.updateObservers()}constructor(t){this.subscriptions=new Map,this.updateObservers=()=>{for(let[e,{disposer:r}]of this.subscriptions)e(this.o,r)},t!==void 0&&(this.value=t)}addCallback(t,e,r){if(!r)return void t(this.value);this.subscriptions.has(t)||this.subscriptions.set(t,{disposer:()=>{this.subscriptions.delete(t)},consumerHost:e});let{disposer:i}=this.subscriptions.get(t);t(this.value,i)}clearCallbacks(){this.subscriptions.clear()}};var Kt=class extends Event{constructor(t){super("context-provider",{bubbles:!0,composed:!0}),this.context=t}},Ce=class extends vt{constructor(t,e,r){var i,o;super(e.context!==void 0?e.initialValue:r),this.onContextRequest=n=>{let a=n.composedPath()[0];n.context===this.context&&a!==this.host&&(n.stopPropagation(),this.addCallback(n.callback,a,n.subscribe))},this.onProviderRequest=n=>{let a=n.composedPath()[0];if(n.context!==this.context||a===this.host)return;let c=new Set;for(let[p,{consumerHost:f}]of this.subscriptions)c.has(p)||(c.add(p),f.dispatchEvent(new ee(this.context,p,!0)));n.stopPropagation()},this.host=t,e.context!==void 0?this.context=e.context:this.context=e,this.attachListeners(),(o=(i=this.host).addController)==null||o.call(i,this)}attachListeners(){this.host.addEventListener("context-request",this.onContextRequest),this.host.addEventListener("context-provider",this.onProviderRequest)}hostConnected(){this.host.dispatchEvent(new Kt(this.context))}};function Zt({context:s}){return(t,e)=>{let r=new WeakMap;if(typeof e=="object")return e.addInitializer(function(){r.set(this,new Ce(this,{context:s}))}),{get(){return t.get.call(this)},set(i){var o;return(o=r.get(this))==null||o.setValue(i),t.set.call(this,i)},init(i){var o;return(o=r.get(this))==null||o.setValue(i),i}};{t.constructor.addInitializer(n=>{r.set(n,new Ce(n,{context:s}))});let i=Object.getOwnPropertyDescriptor(t,e),o;if(i===void 0){let n=new WeakMap;o={get(){return n.get(this)},set(a){r.get(this).setValue(a),n.set(this,a)},configurable:!0,enumerable:!0}}else{let n=i.set;o=S(q({},i),{set(a){r.get(this).setValue(a),n==null||n.call(this,a)}})}return void Object.defineProperty(t,e,o)}}}function k({context:s,subscribe:t}){return(e,r)=>{typeof r=="object"?r.addInitializer(function(){new Ee(this,{context:s,callback:i=>{e.set.call(this,i)},subscribe:t})}):e.constructor.addInitializer(i=>{new Ee(i,{context:s,callback:o=>{i[r]=o},subscribe:t})})}}var Pr=class{get shadowRoot(){return this.__host.__shadowRoot}constructor(t){this.ariaAtomic="",this.ariaAutoComplete="",this.ariaBrailleLabel="",this.ariaBrailleRoleDescription="",this.ariaBusy="",this.ariaChecked="",this.ariaColCount="",this.ariaColIndex="",this.ariaColSpan="",this.ariaCurrent="",this.ariaDescription="",this.ariaDisabled="",this.ariaExpanded="",this.ariaHasPopup="",this.ariaHidden="",this.ariaInvalid="",this.ariaKeyShortcuts="",this.ariaLabel="",this.ariaLevel="",this.ariaLive="",this.ariaModal="",this.ariaMultiLine="",this.ariaMultiSelectable="",this.ariaOrientation="",this.ariaPlaceholder="",this.ariaPosInSet="",this.ariaPressed="",this.ariaReadOnly="",this.ariaRequired="",this.ariaRoleDescription="",this.ariaRowCount="",this.ariaRowIndex="",this.ariaRowSpan="",this.ariaSelected="",this.ariaSetSize="",this.ariaSort="",this.ariaValueMax="",this.ariaValueMin="",this.ariaValueNow="",this.ariaValueText="",this.role="",this.form=null,this.labels=[],this.states=new Set,this.validationMessage="",this.validity={},this.willValidate=!0,this.__host=t}checkValidity(){return console.warn("`ElementInternals.checkValidity()` was called on the server.This method always returns true."),!0}reportValidity(){return!0}setFormValue(){}setValidity(){}};var Ir=new WeakMap,Oe=s=>{let t=Ir.get(s);return t===void 0&&Ir.set(s,t=new Map),t},Gi=class{constructor(){this.__shadowRootMode=null,this.__shadowRoot=null,this.__internals=null}get attributes(){return Array.from(Oe(this)).map(([t,e])=>({name:t,value:e}))}get shadowRoot(){return this.__shadowRootMode==="closed"?null:this.__shadowRoot}get localName(){return this.constructor.__localName}get tagName(){var t;return(t=this.localName)==null?void 0:t.toUpperCase()}setAttribute(t,e){Oe(this).set(t,String(e))}removeAttribute(t){Oe(this).delete(t)}toggleAttribute(t,e){if(this.hasAttribute(t)){if(e===void 0||!e)return this.removeAttribute(t),!1}else return e===void 0||e?(this.setAttribute(t,""),!0):!1;return!0}hasAttribute(t){return Oe(this).has(t)}attachShadow(t){let e={host:this};return this.__shadowRootMode=t.mode,t&&t.mode==="open"&&(this.__shadowRoot=e),e}attachInternals(){if(this.__internals!==null)throw new Error("Failed to execute 'attachInternals' on 'HTMLElement': ElementInternals for the specified element was already attached.");let t=new Pr(this);return this.__internals=t,t}getAttribute(t){let e=Oe(this).get(t);return e!=null?e:null}};var Qi=class extends Gi{},Or=Qi;var es=class{constructor(){this.__definitions=new Map}define(t,e){var r;if(this.__definitions.has(t))if(process.env.NODE_ENV==="development")console.warn(`'CustomElementRegistry' already has "${t}" defined. This may have been caused by live reload or hot module replacement in which case it can be safely ignored.
2
- Make sure to test your application with a production build as repeat registrations will throw in production.`);else throw new Error(`Failed to execute 'define' on 'CustomElementRegistry': the name "${t}" has already been used with this registry`);e.__localName=t,this.__definitions.set(t,{ctor:e,observedAttributes:(r=e.observedAttributes)!=null?r:[]})}get(t){let e=this.__definitions.get(t);return e==null?void 0:e.ctor}},ts=es;var Ur=new ts;var Ue=globalThis,yt=Ue.ShadowRoot&&(Ue.ShadyCSS===void 0||Ue.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Jt=Symbol(),Fr=new WeakMap,Fe=class{constructor(t,e,r){if(this._$cssResult$=!0,r!==Jt)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o,e=this.t;if(yt&&t===void 0){let r=e!==void 0&&e.length===1;r&&(t=Fr.get(e)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),r&&Fr.set(e,t))}return t}toString(){return this.cssText}},Br=s=>new Fe(typeof s=="string"?s:s+"",void 0,Jt),g=(s,...t)=>{let e=s.length===1?s[0]:t.reduce((r,i,o)=>r+(n=>{if(n._$cssResult$===!0)return n.cssText;if(typeof n=="number")return n;throw Error("Value passed to 'css' function must be a 'css' function result: "+n+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+s[o+1],s[0]);return new Fe(e,s,Jt)},Gt=(s,t)=>{if(yt)s.adoptedStyleSheets=t.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet);else for(let e of t){let r=document.createElement("style"),i=Ue.litNonce;i!==void 0&&r.setAttribute("nonce",i),r.textContent=e.cssText,s.appendChild(r)}},xt=yt||Ue.CSSStyleSheet===void 0?s=>s:s=>s instanceof CSSStyleSheet?(t=>{let e="";for(let r of t.cssRules)e+=r.cssText;return Br(e)})(s):s;var{is:rs,defineProperty:is,getOwnPropertyDescriptor:ss,getOwnPropertyNames:os,getOwnPropertySymbols:ns,getPrototypeOf:as}=Object,I=globalThis,zr;(zr=I.customElements)!=null||(I.customElements=Ur);var Xr=I.trustedTypes,ls=Xr?Xr.emptyScript:"",Qt=I.reactiveElementPolyfillSupport,Be=(s,t)=>s,Xe={toAttribute(s,t){switch(t){case Boolean:s=s?ls:null;break;case Object:case Array:s=s==null?s:JSON.stringify(s)}return s},fromAttribute(s,t){let e=s;switch(t){case Boolean:e=s!==null;break;case Number:e=s===null?null:Number(s);break;case Object:case Array:try{e=JSON.parse(s)}catch(r){e=null}}return e}},Et=(s,t)=>!rs(s,t),jr={attribute:!0,type:String,converter:Xe,reflect:!1,hasChanged:Et},Wr,Yr;(Wr=Symbol.metadata)!=null||(Symbol.metadata=Symbol("metadata")),(Yr=I.litPropertyMetadata)!=null||(I.litPropertyMetadata=new WeakMap);var Kr,K=class extends((Kr=globalThis.HTMLElement)!=null?Kr:Or){static addInitializer(t){var e;this._$Ei(),((e=this.l)!=null?e:this.l=[]).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=jr){if(e.state&&(e.attribute=!1),this._$Ei(),this.elementProperties.set(t,e),!e.noAccessor){let r=Symbol(),i=this.getPropertyDescriptor(t,r,e);i!==void 0&&is(this.prototype,t,i)}}static getPropertyDescriptor(t,e,r){var n;let{get:i,set:o}=(n=ss(this.prototype,t))!=null?n:{get(){return this[e]},set(a){this[e]=a}};return{get(){return i==null?void 0:i.call(this)},set(a){let c=i==null?void 0:i.call(this);o.call(this,a),this.requestUpdate(t,c,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){var e;return(e=this.elementProperties.get(t))!=null?e:jr}static _$Ei(){if(this.hasOwnProperty(Be("elementProperties")))return;let t=as(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(Be("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(Be("properties"))){let e=this.properties,r=[...os(e),...ns(e)];for(let i of r)this.createProperty(i,e[i])}let t=this[Symbol.metadata];if(t!==null){let e=litPropertyMetadata.get(t);if(e!==void 0)for(let[r,i]of e)this.elementProperties.set(r,i)}this._$Eh=new Map;for(let[e,r]of this.elementProperties){let i=this._$Eu(e,r);i!==void 0&&this._$Eh.set(i,e)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){let e=[];if(Array.isArray(t)){let r=new Set(t.flat(1/0).reverse());for(let i of r)e.unshift(xt(i))}else t!==void 0&&e.push(xt(t));return e}static _$Eu(t,e){let r=e.attribute;return r===!1?void 0:typeof r=="string"?r:typeof t=="string"?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){var t;this._$ES=new Promise(e=>this.enableUpdating=e),this._$AL=new Map,this._$E_(),this.requestUpdate(),(t=this.constructor.l)==null||t.forEach(e=>e(this))}addController(t){var e,r;((e=this._$EO)!=null?e:this._$EO=new Set).add(t),this.renderRoot!==void 0&&this.isConnected&&((r=t.hostConnected)==null||r.call(t))}removeController(t){var e;(e=this._$EO)==null||e.delete(t)}_$E_(){let t=new Map,e=this.constructor.elementProperties;for(let r of e.keys())this.hasOwnProperty(r)&&(t.set(r,this[r]),delete this[r]);t.size>0&&(this._$Ep=t)}createRenderRoot(){var e;let t=(e=this.shadowRoot)!=null?e:this.attachShadow(this.constructor.shadowRootOptions);return Gt(t,this.constructor.elementStyles),t}connectedCallback(){var t,e;(t=this.renderRoot)!=null||(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(e=this._$EO)==null||e.forEach(r=>{var i;return(i=r.hostConnected)==null?void 0:i.call(r)})}enableUpdating(t){}disconnectedCallback(){var t;(t=this._$EO)==null||t.forEach(e=>{var r;return(r=e.hostDisconnected)==null?void 0:r.call(e)})}attributeChangedCallback(t,e,r){this._$AK(t,r)}_$EC(t,e){var o;let r=this.constructor.elementProperties.get(t),i=this.constructor._$Eu(t,r);if(i!==void 0&&r.reflect===!0){let n=(((o=r.converter)==null?void 0:o.toAttribute)!==void 0?r.converter:Xe).toAttribute(e,r.type);this._$Em=t,n==null?this.removeAttribute(i):this.setAttribute(i,n),this._$Em=null}}_$AK(t,e){var o;let r=this.constructor,i=r._$Eh.get(t);if(i!==void 0&&this._$Em!==i){let n=r.getPropertyOptions(i),a=typeof n.converter=="function"?{fromAttribute:n.converter}:((o=n.converter)==null?void 0:o.fromAttribute)!==void 0?n.converter:Xe;this._$Em=i,this[i]=a.fromAttribute(e,n.type),this._$Em=null}}requestUpdate(t,e,r){var i;if(t!==void 0){if(r!=null||(r=this.constructor.getPropertyOptions(t)),!((i=r.hasChanged)!=null?i:Et)(this[t],e))return;this.P(t,e,r)}this.isUpdatePending===!1&&(this._$ES=this._$ET())}P(t,e,r){var i;this._$AL.has(t)||this._$AL.set(t,e),r.reflect===!0&&this._$Em!==t&&((i=this._$Ej)!=null?i:this._$Ej=new Set).add(t)}async _$ET(){this.isUpdatePending=!0;try{await this._$ES}catch(e){Promise.reject(e)}let t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var r,i;if(!this.isUpdatePending)return;if(!this.hasUpdated){if((r=this.renderRoot)!=null||(this.renderRoot=this.createRenderRoot()),this._$Ep){for(let[n,a]of this._$Ep)this[n]=a;this._$Ep=void 0}let o=this.constructor.elementProperties;if(o.size>0)for(let[n,a]of o)a.wrapped!==!0||this._$AL.has(n)||this[n]===void 0||this.P(n,this[n],a)}let t=!1,e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),(i=this._$EO)==null||i.forEach(o=>{var n;return(n=o.hostUpdate)==null?void 0:n.call(o)}),this.update(e)):this._$EU()}catch(o){throw t=!1,this._$EU(),o}t&&this._$AE(e)}willUpdate(t){}_$AE(t){var e;(e=this._$EO)==null||e.forEach(r=>{var i;return(i=r.hostUpdated)==null?void 0:i.call(r)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EU(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Ej&&(this._$Ej=this._$Ej.forEach(e=>this._$EC(e,this[e]))),this._$EU()}updated(t){}firstUpdated(t){}},Zr;K.elementStyles=[],K.shadowRootOptions={mode:"open"},K[Be("elementProperties")]=new Map,K[Be("finalized")]=new Map,Qt==null||Qt({ReactiveElement:K}),((Zr=I.reactiveElementVersions)!=null?Zr:I.reactiveElementVersions=[]).push("2.0.4");var _e=globalThis,Ct=_e.trustedTypes,Jr=Ct?Ct.createPolicy("lit-html",{createHTML:s=>s}):void 0,rr="$lit$",Z=`lit$${Math.random().toFixed(9).slice(2)}$`,ir="?"+Z,cs=`<${ir}>`,fe=_e.document===void 0?{createTreeWalker:()=>({})}:document,ze=()=>fe.createComment(""),We=s=>s===null||typeof s!="object"&&typeof s!="function",sr=Array.isArray,si=s=>sr(s)||typeof(s==null?void 0:s[Symbol.iterator])=="function",er=`[
3
- \f\r]`,je=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Gr=/-->/g,Qr=/>/g,he=RegExp(`>|${er}(?:([^\\s"'>=/]+)(${er}*=${er}*(?:[^
4
- \f\r"'\`<>=]|("|')|))|$)`,"g"),ei=/'/g,ti=/"/g,oi=/^(?:script|style|textarea|title)$/i,or=s=>(t,...e)=>({_$litType$:s,strings:t,values:e}),u=or(1),nr=or(2),ho=or(3),L=Symbol.for("lit-noChange"),w=Symbol.for("lit-nothing"),ri=new WeakMap,me=fe.createTreeWalker(fe,129);function ni(s,t){if(!sr(s)||!s.hasOwnProperty("raw"))throw Error("invalid template strings array");return Jr!==void 0?Jr.createHTML(t):t}var ai=(s,t)=>{let e=s.length-1,r=[],i,o=t===2?"<svg>":t===3?"<math>":"",n=je;for(let a=0;a<e;a++){let c=s[a],p,f,m=-1,y=0;for(;y<c.length&&(n.lastIndex=y,f=n.exec(c),f!==null);)y=n.lastIndex,n===je?f[1]==="!--"?n=Gr:f[1]!==void 0?n=Qr:f[2]!==void 0?(oi.test(f[2])&&(i=RegExp("</"+f[2],"g")),n=he):f[3]!==void 0&&(n=he):n===he?f[0]===">"?(n=i!=null?i:je,m=-1):f[1]===void 0?m=-2:(m=n.lastIndex-f[2].length,p=f[1],n=f[3]===void 0?he:f[3]==='"'?ti:ei):n===ti||n===ei?n=he:n===Gr||n===Qr?n=je:(n=he,i=void 0);let b=n===he&&s[a+1].startsWith("/>")?" ":"";o+=n===je?c+cs:m>=0?(r.push(p),c.slice(0,m)+rr+c.slice(m)+Z+b):c+Z+(m===-2?a:b)}return[ni(s,o+(s[e]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),r]},Ye=class s{constructor({strings:t,_$litType$:e},r){let i;this.parts=[];let o=0,n=0,a=t.length-1,c=this.parts,[p,f]=ai(t,e);if(this.el=s.createElement(p,r),me.currentNode=this.el.content,e===2||e===3){let m=this.el.content.firstChild;m.replaceWith(...m.childNodes)}for(;(i=me.nextNode())!==null&&c.length<a;){if(i.nodeType===1){if(i.hasAttributes())for(let m of i.getAttributeNames())if(m.endsWith(rr)){let y=f[n++],b=i.getAttribute(m).split(Z),C=/([.?@])?(.*)/.exec(y);c.push({type:1,index:o,name:C[2],strings:b,ctor:C[1]==="."?wt:C[1]==="?"?qt:C[1]==="@"?At:be}),i.removeAttribute(m)}else m.startsWith(Z)&&(c.push({type:6,index:o}),i.removeAttribute(m));if(oi.test(i.tagName)){let m=i.textContent.split(Z),y=m.length-1;if(y>0){i.textContent=Ct?Ct.emptyScript:"";for(let b=0;b<y;b++)i.append(m[b],ze()),me.nextNode(),c.push({type:2,index:++o});i.append(m[y],ze())}}}else if(i.nodeType===8)if(i.data===ir)c.push({type:2,index:o});else{let m=-1;for(;(m=i.data.indexOf(Z,m+1))!==-1;)c.push({type:7,index:o}),m+=Z.length-1}o++}}static createElement(t,e){let r=fe.createElement("template");return r.innerHTML=t,r}};function ge(s,t,e=s,r){var n,a,c;if(t===L)return t;let i=r!==void 0?(n=e._$Co)==null?void 0:n[r]:e._$Cl,o=We(t)?void 0:t._$litDirective$;return(i==null?void 0:i.constructor)!==o&&((a=i==null?void 0:i._$AO)==null||a.call(i,!1),o===void 0?i=void 0:(i=new o(s),i._$AT(s,e,r)),r!==void 0?((c=e._$Co)!=null?c:e._$Co=[])[r]=i:e._$Cl=i),i!==void 0&&(t=ge(s,i._$AS(s,t.values),i,r)),t}var _t=class{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){var p;let{el:{content:e},parts:r}=this._$AD,i=((p=t==null?void 0:t.creationScope)!=null?p:fe).importNode(e,!0);me.currentNode=i;let o=me.nextNode(),n=0,a=0,c=r[0];for(;c!==void 0;){if(n===c.index){let f;c.type===2?f=new we(o,o.nextSibling,this,t):c.type===1?f=new c.ctor(o,c.name,c.strings,this,t):c.type===6&&(f=new Tt(o,this,t)),this._$AV.push(f),c=r[++a]}n!==(c==null?void 0:c.index)&&(o=me.nextNode(),n++)}return me.currentNode=fe,i}p(t){let e=0;for(let r of this._$AV)r!==void 0&&(r.strings!==void 0?(r._$AI(t,r,e),e+=r.strings.length-2):r._$AI(t[e])),e++}},we=class s{get _$AU(){var t,e;return(e=(t=this._$AM)==null?void 0:t._$AU)!=null?e:this._$Cv}constructor(t,e,r,i){var o;this.type=2,this._$AH=w,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=r,this.options=i,this._$Cv=(o=i==null?void 0:i.isConnected)!=null?o:!0}get parentNode(){let t=this._$AA.parentNode,e=this._$AM;return e!==void 0&&(t==null?void 0:t.nodeType)===11&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=ge(this,t,e),We(t)?t===w||t==null||t===""?(this._$AH!==w&&this._$AR(),this._$AH=w):t!==this._$AH&&t!==L&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):si(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==w&&We(this._$AH)?this._$AA.nextSibling.data=t:this.T(fe.createTextNode(t)),this._$AH=t}$(t){var o;let{values:e,_$litType$:r}=t,i=typeof r=="number"?this._$AC(t):(r.el===void 0&&(r.el=Ye.createElement(ni(r.h,r.h[0]),this.options)),r);if(((o=this._$AH)==null?void 0:o._$AD)===i)this._$AH.p(e);else{let n=new _t(i,this),a=n.u(this.options);n.p(e),this.T(a),this._$AH=n}}_$AC(t){let e=ri.get(t.strings);return e===void 0&&ri.set(t.strings,e=new Ye(t)),e}k(t){sr(this._$AH)||(this._$AH=[],this._$AR());let e=this._$AH,r,i=0;for(let o of t)i===e.length?e.push(r=new s(this.O(ze()),this.O(ze()),this,this.options)):r=e[i],r._$AI(o),i++;i<e.length&&(this._$AR(r&&r._$AB.nextSibling,i),e.length=i)}_$AR(t=this._$AA.nextSibling,e){var r;for((r=this._$AP)==null?void 0:r.call(this,!1,!0,e);t&&t!==this._$AB;){let i=t.nextSibling;t.remove(),t=i}}setConnected(t){var e;this._$AM===void 0&&(this._$Cv=t,(e=this._$AP)==null||e.call(this,t))}},be=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,r,i,o){this.type=1,this._$AH=w,this._$AN=void 0,this.element=t,this.name=e,this._$AM=i,this.options=o,r.length>2||r[0]!==""||r[1]!==""?(this._$AH=Array(r.length-1).fill(new String),this.strings=r):this._$AH=w}_$AI(t,e=this,r,i){let o=this.strings,n=!1;if(o===void 0)t=ge(this,t,e,0),n=!We(t)||t!==this._$AH&&t!==L,n&&(this._$AH=t);else{let a=t,c,p;for(t=o[0],c=0;c<o.length-1;c++)p=ge(this,a[r+c],e,c),p===L&&(p=this._$AH[c]),n||(n=!We(p)||p!==this._$AH[c]),p===w?t=w:t!==w&&(t+=(p!=null?p:"")+o[c+1]),this._$AH[c]=p}n&&!i&&this.j(t)}j(t){t===w?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t!=null?t:"")}},wt=class extends be{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===w?void 0:t}},qt=class extends be{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==w)}},At=class extends be{constructor(t,e,r,i,o){super(t,e,r,i,o),this.type=5}_$AI(t,e=this){var n;if((t=(n=ge(this,t,e,0))!=null?n:w)===L)return;let r=this._$AH,i=t===w&&r!==w||t.capture!==r.capture||t.once!==r.once||t.passive!==r.passive,o=t!==w&&(r===w||i);i&&this.element.removeEventListener(this.name,this,r),o&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var e,r;typeof this._$AH=="function"?this._$AH.call((r=(e=this.options)==null?void 0:e.host)!=null?r:this.element,t):this._$AH.handleEvent(t)}},Tt=class{constructor(t,e,r){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=r}get _$AU(){return this._$AM._$AU}_$AI(t){ge(this,t)}},li={M:rr,P:Z,A:ir,C:1,L:ai,R:_t,D:si,V:ge,I:we,H:be,N:qt,U:At,B:wt,F:Tt},tr=_e.litHtmlPolyfillSupport,ii;tr==null||tr(Ye,we),((ii=_e.litHtmlVersions)!=null?ii:_e.litHtmlVersions=[]).push("3.2.1");var ci=(s,t,e)=>{var o,n;let r=(o=e==null?void 0:e.renderBefore)!=null?o:t,i=r._$litPart$;if(i===void 0){let a=(n=e==null?void 0:e.renderBefore)!=null?n:null;r._$litPart$=i=new we(t.insertBefore(ze(),a),a,void 0,e!=null?e:{})}return i._$AI(s),i};var v=class extends K{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var e,r;let t=super.createRenderRoot();return(r=(e=this.renderOptions).renderBefore)!=null||(e.renderBefore=t.firstChild),t}update(t){let e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=ci(e,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),(t=this._$Do)==null||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),(t=this._$Do)==null||t.setConnected(!1)}render(){return L}},pi;v._$litElement$=!0,v.finalized=!0,(pi=globalThis.litElementHydrateSupport)==null||pi.call(globalThis,{LitElement:v});var ar=globalThis.litElementPolyfillSupport;ar==null||ar({LitElement:v});var di;((di=globalThis.litElementVersions)!=null?di:globalThis.litElementVersions=[]).push("4.1.1");var h=s=>(t,e)=>{e!==void 0?e.addInitializer(()=>{customElements.define(s,t)}):customElements.define(s,t)};var ps={attribute:!0,type:String,converter:Xe,reflect:!1,hasChanged:Et},ds=(s=ps,t,e)=>{let{kind:r,metadata:i}=e,o=globalThis.litPropertyMetadata.get(i);if(o===void 0&&globalThis.litPropertyMetadata.set(i,o=new Map),o.set(e.name,s),r==="accessor"){let{name:n}=e;return{set(a){let c=t.get.call(this);t.set.call(this,a),this.requestUpdate(n,c,s)},init(a){return a!==void 0&&this.P(n,void 0,s),a}}}if(r==="setter"){let{name:n}=e;return function(a){let c=this[n];t.call(this,a),this.requestUpdate(n,c,s)}}throw Error("Unsupported decorator location: "+r)};function d(s){return(t,e)=>typeof e=="object"?ds(s,t,e):((r,i,o)=>{let n=i.hasOwnProperty(o);return i.constructor.createProperty(o,n?S(q({},r),{wrapped:!0}):r),n?Object.getOwnPropertyDescriptor(i,o):void 0})(s,t,e)}function E(s){return d(S(q({},s),{state:!0,attribute:!1}))}var te=(s,t,e)=>(e.configurable=!0,e.enumerable=!0,Reflect.decorate&&typeof t!="object"&&Object.defineProperty(s,t,e),e);function ve(s,t){return(e,r,i)=>{let o=n=>{var a,c;return(c=(a=n.renderRoot)==null?void 0:a.querySelector(s))!=null?c:null};if(t){let{get:n,set:a}=typeof r=="object"?e:i!=null?i:(()=>{let c=Symbol();return{get(){return this[c]},set(p){this[c]=p}}})();return te(e,r,{get(){let c=n.call(this);return c===void 0&&(c=o(this),(c!==null||this.hasUpdated)&&a.call(this,c)),c}})}return te(e,r,{get(){return o(this)}})}}function ui(s){return(t,e)=>{let{slot:r,selector:i}=s!=null?s:{},o="slot"+(r?`[name=${r}]`:":not([name])");return te(t,e,{get(){var c,p;let n=(c=this.renderRoot)==null?void 0:c.querySelector(o),a=(p=n==null?void 0:n.assignedElements(s))!=null?p:[];return i===void 0?a:a.filter(f=>f.matches(i))}})}}function M(s,t){let e=q({waitUntilFirstUpdate:!1},t);return(r,i)=>{let{update:o}=r,n=Array.isArray(s)?s:[s];r.update=function(a){n.forEach(c=>{let p=c;if(a.has(p)){let f=a.get(p),m=this[p];f!==m&&(!e.waitUntilFirstUpdate||this.hasUpdated)&&this[i](f,m)}}),o.call(this,a)}}}var hi=[{identifier:"completionStatus",cardinality:"single",baseType:"string",value:"unknown",type:"outcome"},{identifier:"numAttempts",cardinality:"single",baseType:"integer",value:"0",type:"response"}],$=Symbol("item");var D=class extends v{constructor(){super();this.identifier="";this.adaptive="false";this.timeDependent=null;this._handleDisabledChange=(e,r)=>{this._interactionElements.forEach(i=>i.disabled=r)};this._handleReadonlyChange=(e,r)=>this._interactionElements.forEach(i=>i.readonly=r);this._context={identifier:this.getAttribute("identifier"),variables:hi};this._initialContext=S(q({},this._context),{variables:this._context.variables});this._feedbackElements=[];this._interactionElements=[];this.addEventListener("qti-register-variable",e=>{this._context=S(q({},this._context),{variables:[...this._context.variables,e.detail.variable]}),this._initialContext=this._context,e.stopPropagation()}),this.addEventListener("qti-register-feedback",e=>{e.stopPropagation();let r=e.detail;this._feedbackElements.push(r),r.checkShowFeedback(r.outcomeIdentifier)}),this.addEventListener("qti-register-interaction",e=>{e.stopPropagation(),this._interactionElements.push(e.target)}),this.addEventListener("end-attempt",e=>{let{responseIdentifier:r,countAttempt:i}=e.detail;this.updateResponseVariable(r,"true"),this.processResponse(i)}),this.addEventListener("qti-set-outcome-value",e=>{let{outcomeIdentifier:r,value:i}=e.detail;this.updateOutcomeVariable(r,i),e.stopPropagation()}),this.addEventListener("qti-interaction-response",this.handleUpdateResponseVariable)}get variables(){return this._context.variables.map(e=>q({identifier:e.identifier,value:e.value,type:e.type},e.type==="outcome"&&e.identifier==="SCORE"?{externalScored:e.externalScored}:{}))}set variables(e){if(!Array.isArray(e)||e.some(r=>!("identifier"in r))){console.warn("variables property should be an array of VariableDeclaration");return}this._context=S(q({},this._context),{variables:this._context.variables.map(r=>{let i=e.find(o=>o.identifier===r.identifier);return i?q(q({},r),i):r})}),this._context.variables.forEach(r=>{if(r.type==="response"){let i=this._interactionElements.find(o=>o.responseIdentifier===r.identifier);i&&(i.value=r.value)}r.type==="outcome"&&this._feedbackElements.forEach(i=>i.checkShowFeedback(r.identifier))})}async connectedCallback(){super.connectedCallback(),await this.updateComplete,this._emit("qti-assessment-item-connected",this)}set responses(e){if(e)for(let r of e){this.getResponse(r.responseIdentifier)&&this.updateResponseVariable(r.responseIdentifier,r.response);let o=this._interactionElements.find(n=>n.getAttribute("response-identifier")===r.responseIdentifier);o&&(o.value=r.response)}}render(){return u`<slot></slot>`}showCorrectResponse(e){let i=this._context.variables.filter(o=>"correctResponse"in o&&o.correctResponse).map(o=>({responseIdentifier:o.identifier,response:o.correctResponse}));for(let o of i){let n=this._interactionElements.find(a=>a.getAttribute("response-identifier")===o.responseIdentifier);n&&(n.correctResponse=e?o.response:"")}}processResponse(e=!0){var i;let r=this.querySelector("qti-response-processing");return!r||!r.process?!1:(r.process(),this.adaptive==="false"&&this.updateOutcomeVariable("completionStatus",this._getCompletionStatus()),e&&this.updateOutcomeVariable("numAttempts",(+((i=this._context.variables.find(o=>o.identifier==="numAttempts"))==null?void 0:i.value)+1).toString()),this._emit("qti-response-processed"),!0)}resetResponses(){this._context=this._initialContext}getResponse(e){return this.getVariable(e)}getOutcome(e){return this.getVariable(e)}getVariable(e){return this._context.variables.find(r=>r.identifier===e)||null}handleUpdateResponseVariable(e){let{responseIdentifier:r,response:i}=e.detail;this.updateResponseVariable(r,i)}updateResponseVariable(e,r){this._context=S(q({},this._context),{variables:this._context.variables.map(i=>i.identifier!==e?i:S(q({},i),{value:r}))}),this._emit("qti-interaction-changed",{item:this.identifier,responseIdentifier:e,response:Array.isArray(r)?[...r]:r}),this.adaptive==="false"&&this.updateOutcomeVariable("completionStatus",this._getCompletionStatus())}updateOutcomeVariable(e,r){var o;let i=this.getOutcome(e);if(!i){console.warn(`Can not set qti-outcome-identifier: ${e}, it is not available`);return}this._context=S(q({},this._context),{variables:this._context.variables.map(n=>n.identifier!==e?n:S(q({},n),{value:i.cardinality==="single"?r:[...n.value,r]}))}),this._feedbackElements.forEach(n=>n.checkShowFeedback(e)),this._emit("qti-outcome-changed",{item:this.identifier,outcomeIdentifier:e,value:(o=this._context.variables.find(n=>n.identifier===e))==null?void 0:o.value})}_getCompletionStatus(){return this._interactionElements.every(e=>e.validate())?"completed":this._interactionElements.some(e=>e.validate())?"incomplete":"not_attempted"}_emit(e,r=null){this.dispatchEvent(new CustomEvent(e,{bubbles:!0,composed:!0,detail:r}))}};l([d({type:String})],D.prototype,"title",2),l([d({type:String})],D.prototype,"identifier",2),l([d({type:String})],D.prototype,"adaptive",2),l([d({type:String})],D.prototype,"timeDependent",2),l([d({type:Boolean})],D.prototype,"disabled",2),l([M("disabled",{waitUntilFirstUpdate:!0})],D.prototype,"_handleDisabledChange",2),l([d({type:Boolean})],D.prototype,"readonly",2),l([M("readonly",{waitUntilFirstUpdate:!0})],D.prototype,"_handleReadonlyChange",2),l([Zt({context:$})],D.prototype,"_context",2),D=l([h("qti-assessment-item")],D);var us=String.raw,hs=us`<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
2
+ Make sure to test your application with a production build as repeat registrations will throw in production.`);else throw new Error(`Failed to execute 'define' on 'CustomElementRegistry': the name "${t}" has already been used with this registry`);e.__localName=t,this.__definitions.set(t,{ctor:e,observedAttributes:(r=e.observedAttributes)!=null?r:[]})}get(t){let e=this.__definitions.get(t);return e==null?void 0:e.ctor}},ts=es;var Ur=new ts;var Ue=globalThis,yt=Ue.ShadowRoot&&(Ue.ShadyCSS===void 0||Ue.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Jt=Symbol(),Fr=new WeakMap,Fe=class{constructor(t,e,r){if(this._$cssResult$=!0,r!==Jt)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o,e=this.t;if(yt&&t===void 0){let r=e!==void 0&&e.length===1;r&&(t=Fr.get(e)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),r&&Fr.set(e,t))}return t}toString(){return this.cssText}},Br=s=>new Fe(typeof s=="string"?s:s+"",void 0,Jt),g=(s,...t)=>{let e=s.length===1?s[0]:t.reduce((r,i,o)=>r+(n=>{if(n._$cssResult$===!0)return n.cssText;if(typeof n=="number")return n;throw Error("Value passed to 'css' function must be a 'css' function result: "+n+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+s[o+1],s[0]);return new Fe(e,s,Jt)},Gt=(s,t)=>{if(yt)s.adoptedStyleSheets=t.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet);else for(let e of t){let r=document.createElement("style"),i=Ue.litNonce;i!==void 0&&r.setAttribute("nonce",i),r.textContent=e.cssText,s.appendChild(r)}},xt=yt||Ue.CSSStyleSheet===void 0?s=>s:s=>s instanceof CSSStyleSheet?(t=>{let e="";for(let r of t.cssRules)e+=r.cssText;return Br(e)})(s):s;var{is:rs,defineProperty:is,getOwnPropertyDescriptor:ss,getOwnPropertyNames:os,getOwnPropertySymbols:ns,getPrototypeOf:as}=Object,I=globalThis,zr;(zr=I.customElements)!=null||(I.customElements=Ur);var Xr=I.trustedTypes,ls=Xr?Xr.emptyScript:"",Qt=I.reactiveElementPolyfillSupport,Be=(s,t)=>s,Xe={toAttribute(s,t){switch(t){case Boolean:s=s?ls:null;break;case Object:case Array:s=s==null?s:JSON.stringify(s)}return s},fromAttribute(s,t){let e=s;switch(t){case Boolean:e=s!==null;break;case Number:e=s===null?null:Number(s);break;case Object:case Array:try{e=JSON.parse(s)}catch(r){e=null}}return e}},Et=(s,t)=>!rs(s,t),jr={attribute:!0,type:String,converter:Xe,reflect:!1,hasChanged:Et},Wr,Yr;(Wr=Symbol.metadata)!=null||(Symbol.metadata=Symbol("metadata")),(Yr=I.litPropertyMetadata)!=null||(I.litPropertyMetadata=new WeakMap);var Kr,Y=class extends((Kr=globalThis.HTMLElement)!=null?Kr:Or){static addInitializer(t){var e;this._$Ei(),((e=this.l)!=null?e:this.l=[]).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=jr){if(e.state&&(e.attribute=!1),this._$Ei(),this.elementProperties.set(t,e),!e.noAccessor){let r=Symbol(),i=this.getPropertyDescriptor(t,r,e);i!==void 0&&is(this.prototype,t,i)}}static getPropertyDescriptor(t,e,r){var n;let{get:i,set:o}=(n=ss(this.prototype,t))!=null?n:{get(){return this[e]},set(a){this[e]=a}};return{get(){return i==null?void 0:i.call(this)},set(a){let c=i==null?void 0:i.call(this);o.call(this,a),this.requestUpdate(t,c,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){var e;return(e=this.elementProperties.get(t))!=null?e:jr}static _$Ei(){if(this.hasOwnProperty(Be("elementProperties")))return;let t=as(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(Be("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(Be("properties"))){let e=this.properties,r=[...os(e),...ns(e)];for(let i of r)this.createProperty(i,e[i])}let t=this[Symbol.metadata];if(t!==null){let e=litPropertyMetadata.get(t);if(e!==void 0)for(let[r,i]of e)this.elementProperties.set(r,i)}this._$Eh=new Map;for(let[e,r]of this.elementProperties){let i=this._$Eu(e,r);i!==void 0&&this._$Eh.set(i,e)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){let e=[];if(Array.isArray(t)){let r=new Set(t.flat(1/0).reverse());for(let i of r)e.unshift(xt(i))}else t!==void 0&&e.push(xt(t));return e}static _$Eu(t,e){let r=e.attribute;return r===!1?void 0:typeof r=="string"?r:typeof t=="string"?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){var t;this._$ES=new Promise(e=>this.enableUpdating=e),this._$AL=new Map,this._$E_(),this.requestUpdate(),(t=this.constructor.l)==null||t.forEach(e=>e(this))}addController(t){var e,r;((e=this._$EO)!=null?e:this._$EO=new Set).add(t),this.renderRoot!==void 0&&this.isConnected&&((r=t.hostConnected)==null||r.call(t))}removeController(t){var e;(e=this._$EO)==null||e.delete(t)}_$E_(){let t=new Map,e=this.constructor.elementProperties;for(let r of e.keys())this.hasOwnProperty(r)&&(t.set(r,this[r]),delete this[r]);t.size>0&&(this._$Ep=t)}createRenderRoot(){var e;let t=(e=this.shadowRoot)!=null?e:this.attachShadow(this.constructor.shadowRootOptions);return Gt(t,this.constructor.elementStyles),t}connectedCallback(){var t,e;(t=this.renderRoot)!=null||(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(e=this._$EO)==null||e.forEach(r=>{var i;return(i=r.hostConnected)==null?void 0:i.call(r)})}enableUpdating(t){}disconnectedCallback(){var t;(t=this._$EO)==null||t.forEach(e=>{var r;return(r=e.hostDisconnected)==null?void 0:r.call(e)})}attributeChangedCallback(t,e,r){this._$AK(t,r)}_$EC(t,e){var o;let r=this.constructor.elementProperties.get(t),i=this.constructor._$Eu(t,r);if(i!==void 0&&r.reflect===!0){let n=(((o=r.converter)==null?void 0:o.toAttribute)!==void 0?r.converter:Xe).toAttribute(e,r.type);this._$Em=t,n==null?this.removeAttribute(i):this.setAttribute(i,n),this._$Em=null}}_$AK(t,e){var o;let r=this.constructor,i=r._$Eh.get(t);if(i!==void 0&&this._$Em!==i){let n=r.getPropertyOptions(i),a=typeof n.converter=="function"?{fromAttribute:n.converter}:((o=n.converter)==null?void 0:o.fromAttribute)!==void 0?n.converter:Xe;this._$Em=i,this[i]=a.fromAttribute(e,n.type),this._$Em=null}}requestUpdate(t,e,r){var i;if(t!==void 0){if(r!=null||(r=this.constructor.getPropertyOptions(t)),!((i=r.hasChanged)!=null?i:Et)(this[t],e))return;this.P(t,e,r)}this.isUpdatePending===!1&&(this._$ES=this._$ET())}P(t,e,r){var i;this._$AL.has(t)||this._$AL.set(t,e),r.reflect===!0&&this._$Em!==t&&((i=this._$Ej)!=null?i:this._$Ej=new Set).add(t)}async _$ET(){this.isUpdatePending=!0;try{await this._$ES}catch(e){Promise.reject(e)}let t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var r,i;if(!this.isUpdatePending)return;if(!this.hasUpdated){if((r=this.renderRoot)!=null||(this.renderRoot=this.createRenderRoot()),this._$Ep){for(let[n,a]of this._$Ep)this[n]=a;this._$Ep=void 0}let o=this.constructor.elementProperties;if(o.size>0)for(let[n,a]of o)a.wrapped!==!0||this._$AL.has(n)||this[n]===void 0||this.P(n,this[n],a)}let t=!1,e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),(i=this._$EO)==null||i.forEach(o=>{var n;return(n=o.hostUpdate)==null?void 0:n.call(o)}),this.update(e)):this._$EU()}catch(o){throw t=!1,this._$EU(),o}t&&this._$AE(e)}willUpdate(t){}_$AE(t){var e;(e=this._$EO)==null||e.forEach(r=>{var i;return(i=r.hostUpdated)==null?void 0:i.call(r)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EU(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Ej&&(this._$Ej=this._$Ej.forEach(e=>this._$EC(e,this[e]))),this._$EU()}updated(t){}firstUpdated(t){}},Zr;Y.elementStyles=[],Y.shadowRootOptions={mode:"open"},Y[Be("elementProperties")]=new Map,Y[Be("finalized")]=new Map,Qt==null||Qt({ReactiveElement:Y}),((Zr=I.reactiveElementVersions)!=null?Zr:I.reactiveElementVersions=[]).push("2.0.4");var _e=globalThis,Ct=_e.trustedTypes,Jr=Ct?Ct.createPolicy("lit-html",{createHTML:s=>s}):void 0,rr="$lit$",K=`lit$${Math.random().toFixed(9).slice(2)}$`,ir="?"+K,cs=`<${ir}>`,me=_e.document===void 0?{createTreeWalker:()=>({})}:document,ze=()=>me.createComment(""),We=s=>s===null||typeof s!="object"&&typeof s!="function",sr=Array.isArray,si=s=>sr(s)||typeof(s==null?void 0:s[Symbol.iterator])=="function",er=`[
3
+ \f\r]`,je=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Gr=/-->/g,Qr=/>/g,ue=RegExp(`>|${er}(?:([^\\s"'>=/]+)(${er}*=${er}*(?:[^
4
+ \f\r"'\`<>=]|("|')|))|$)`,"g"),ei=/'/g,ti=/"/g,oi=/^(?:script|style|textarea|title)$/i,or=s=>(t,...e)=>({_$litType$:s,strings:t,values:e}),u=or(1),nr=or(2),ho=or(3),L=Symbol.for("lit-noChange"),w=Symbol.for("lit-nothing"),ri=new WeakMap,he=me.createTreeWalker(me,129);function ni(s,t){if(!sr(s)||!s.hasOwnProperty("raw"))throw Error("invalid template strings array");return Jr!==void 0?Jr.createHTML(t):t}var ai=(s,t)=>{let e=s.length-1,r=[],i,o=t===2?"<svg>":t===3?"<math>":"",n=je;for(let a=0;a<e;a++){let c=s[a],p,f,m=-1,y=0;for(;y<c.length&&(n.lastIndex=y,f=n.exec(c),f!==null);)y=n.lastIndex,n===je?f[1]==="!--"?n=Gr:f[1]!==void 0?n=Qr:f[2]!==void 0?(oi.test(f[2])&&(i=RegExp("</"+f[2],"g")),n=ue):f[3]!==void 0&&(n=ue):n===ue?f[0]===">"?(n=i!=null?i:je,m=-1):f[1]===void 0?m=-2:(m=n.lastIndex-f[2].length,p=f[1],n=f[3]===void 0?ue:f[3]==='"'?ti:ei):n===ti||n===ei?n=ue:n===Gr||n===Qr?n=je:(n=ue,i=void 0);let b=n===ue&&s[a+1].startsWith("/>")?" ":"";o+=n===je?c+cs:m>=0?(r.push(p),c.slice(0,m)+rr+c.slice(m)+K+b):c+K+(m===-2?a:b)}return[ni(s,o+(s[e]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),r]},Ye=class s{constructor({strings:t,_$litType$:e},r){let i;this.parts=[];let o=0,n=0,a=t.length-1,c=this.parts,[p,f]=ai(t,e);if(this.el=s.createElement(p,r),he.currentNode=this.el.content,e===2||e===3){let m=this.el.content.firstChild;m.replaceWith(...m.childNodes)}for(;(i=he.nextNode())!==null&&c.length<a;){if(i.nodeType===1){if(i.hasAttributes())for(let m of i.getAttributeNames())if(m.endsWith(rr)){let y=f[n++],b=i.getAttribute(m).split(K),C=/([.?@])?(.*)/.exec(y);c.push({type:1,index:o,name:C[2],strings:b,ctor:C[1]==="."?wt:C[1]==="?"?qt:C[1]==="@"?At:ge}),i.removeAttribute(m)}else m.startsWith(K)&&(c.push({type:6,index:o}),i.removeAttribute(m));if(oi.test(i.tagName)){let m=i.textContent.split(K),y=m.length-1;if(y>0){i.textContent=Ct?Ct.emptyScript:"";for(let b=0;b<y;b++)i.append(m[b],ze()),he.nextNode(),c.push({type:2,index:++o});i.append(m[y],ze())}}}else if(i.nodeType===8)if(i.data===ir)c.push({type:2,index:o});else{let m=-1;for(;(m=i.data.indexOf(K,m+1))!==-1;)c.push({type:7,index:o}),m+=K.length-1}o++}}static createElement(t,e){let r=me.createElement("template");return r.innerHTML=t,r}};function fe(s,t,e=s,r){var n,a,c;if(t===L)return t;let i=r!==void 0?(n=e._$Co)==null?void 0:n[r]:e._$Cl,o=We(t)?void 0:t._$litDirective$;return(i==null?void 0:i.constructor)!==o&&((a=i==null?void 0:i._$AO)==null||a.call(i,!1),o===void 0?i=void 0:(i=new o(s),i._$AT(s,e,r)),r!==void 0?((c=e._$Co)!=null?c:e._$Co=[])[r]=i:e._$Cl=i),i!==void 0&&(t=fe(s,i._$AS(s,t.values),i,r)),t}var _t=class{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){var p;let{el:{content:e},parts:r}=this._$AD,i=((p=t==null?void 0:t.creationScope)!=null?p:me).importNode(e,!0);he.currentNode=i;let o=he.nextNode(),n=0,a=0,c=r[0];for(;c!==void 0;){if(n===c.index){let f;c.type===2?f=new we(o,o.nextSibling,this,t):c.type===1?f=new c.ctor(o,c.name,c.strings,this,t):c.type===6&&(f=new Tt(o,this,t)),this._$AV.push(f),c=r[++a]}n!==(c==null?void 0:c.index)&&(o=he.nextNode(),n++)}return he.currentNode=me,i}p(t){let e=0;for(let r of this._$AV)r!==void 0&&(r.strings!==void 0?(r._$AI(t,r,e),e+=r.strings.length-2):r._$AI(t[e])),e++}},we=class s{get _$AU(){var t,e;return(e=(t=this._$AM)==null?void 0:t._$AU)!=null?e:this._$Cv}constructor(t,e,r,i){var o;this.type=2,this._$AH=w,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=r,this.options=i,this._$Cv=(o=i==null?void 0:i.isConnected)!=null?o:!0}get parentNode(){let t=this._$AA.parentNode,e=this._$AM;return e!==void 0&&(t==null?void 0:t.nodeType)===11&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=fe(this,t,e),We(t)?t===w||t==null||t===""?(this._$AH!==w&&this._$AR(),this._$AH=w):t!==this._$AH&&t!==L&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):si(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==w&&We(this._$AH)?this._$AA.nextSibling.data=t:this.T(me.createTextNode(t)),this._$AH=t}$(t){var o;let{values:e,_$litType$:r}=t,i=typeof r=="number"?this._$AC(t):(r.el===void 0&&(r.el=Ye.createElement(ni(r.h,r.h[0]),this.options)),r);if(((o=this._$AH)==null?void 0:o._$AD)===i)this._$AH.p(e);else{let n=new _t(i,this),a=n.u(this.options);n.p(e),this.T(a),this._$AH=n}}_$AC(t){let e=ri.get(t.strings);return e===void 0&&ri.set(t.strings,e=new Ye(t)),e}k(t){sr(this._$AH)||(this._$AH=[],this._$AR());let e=this._$AH,r,i=0;for(let o of t)i===e.length?e.push(r=new s(this.O(ze()),this.O(ze()),this,this.options)):r=e[i],r._$AI(o),i++;i<e.length&&(this._$AR(r&&r._$AB.nextSibling,i),e.length=i)}_$AR(t=this._$AA.nextSibling,e){var r;for((r=this._$AP)==null?void 0:r.call(this,!1,!0,e);t&&t!==this._$AB;){let i=t.nextSibling;t.remove(),t=i}}setConnected(t){var e;this._$AM===void 0&&(this._$Cv=t,(e=this._$AP)==null||e.call(this,t))}},ge=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,r,i,o){this.type=1,this._$AH=w,this._$AN=void 0,this.element=t,this.name=e,this._$AM=i,this.options=o,r.length>2||r[0]!==""||r[1]!==""?(this._$AH=Array(r.length-1).fill(new String),this.strings=r):this._$AH=w}_$AI(t,e=this,r,i){let o=this.strings,n=!1;if(o===void 0)t=fe(this,t,e,0),n=!We(t)||t!==this._$AH&&t!==L,n&&(this._$AH=t);else{let a=t,c,p;for(t=o[0],c=0;c<o.length-1;c++)p=fe(this,a[r+c],e,c),p===L&&(p=this._$AH[c]),n||(n=!We(p)||p!==this._$AH[c]),p===w?t=w:t!==w&&(t+=(p!=null?p:"")+o[c+1]),this._$AH[c]=p}n&&!i&&this.j(t)}j(t){t===w?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t!=null?t:"")}},wt=class extends ge{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===w?void 0:t}},qt=class extends ge{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==w)}},At=class extends ge{constructor(t,e,r,i,o){super(t,e,r,i,o),this.type=5}_$AI(t,e=this){var n;if((t=(n=fe(this,t,e,0))!=null?n:w)===L)return;let r=this._$AH,i=t===w&&r!==w||t.capture!==r.capture||t.once!==r.once||t.passive!==r.passive,o=t!==w&&(r===w||i);i&&this.element.removeEventListener(this.name,this,r),o&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var e,r;typeof this._$AH=="function"?this._$AH.call((r=(e=this.options)==null?void 0:e.host)!=null?r:this.element,t):this._$AH.handleEvent(t)}},Tt=class{constructor(t,e,r){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=r}get _$AU(){return this._$AM._$AU}_$AI(t){fe(this,t)}},li={M:rr,P:K,A:ir,C:1,L:ai,R:_t,D:si,V:fe,I:we,H:ge,N:qt,U:At,B:wt,F:Tt},tr=_e.litHtmlPolyfillSupport,ii;tr==null||tr(Ye,we),((ii=_e.litHtmlVersions)!=null?ii:_e.litHtmlVersions=[]).push("3.2.1");var ci=(s,t,e)=>{var o,n;let r=(o=e==null?void 0:e.renderBefore)!=null?o:t,i=r._$litPart$;if(i===void 0){let a=(n=e==null?void 0:e.renderBefore)!=null?n:null;r._$litPart$=i=new we(t.insertBefore(ze(),a),a,void 0,e!=null?e:{})}return i._$AI(s),i};var v=class extends Y{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var e,r;let t=super.createRenderRoot();return(r=(e=this.renderOptions).renderBefore)!=null||(e.renderBefore=t.firstChild),t}update(t){let e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=ci(e,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),(t=this._$Do)==null||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),(t=this._$Do)==null||t.setConnected(!1)}render(){return L}},pi;v._$litElement$=!0,v.finalized=!0,(pi=globalThis.litElementHydrateSupport)==null||pi.call(globalThis,{LitElement:v});var ar=globalThis.litElementPolyfillSupport;ar==null||ar({LitElement:v});var di;((di=globalThis.litElementVersions)!=null?di:globalThis.litElementVersions=[]).push("4.1.1");var h=s=>(t,e)=>{e!==void 0?e.addInitializer(()=>{customElements.define(s,t)}):customElements.define(s,t)};var ps={attribute:!0,type:String,converter:Xe,reflect:!1,hasChanged:Et},ds=(s=ps,t,e)=>{let{kind:r,metadata:i}=e,o=globalThis.litPropertyMetadata.get(i);if(o===void 0&&globalThis.litPropertyMetadata.set(i,o=new Map),o.set(e.name,s),r==="accessor"){let{name:n}=e;return{set(a){let c=t.get.call(this);t.set.call(this,a),this.requestUpdate(n,c,s)},init(a){return a!==void 0&&this.P(n,void 0,s),a}}}if(r==="setter"){let{name:n}=e;return function(a){let c=this[n];t.call(this,a),this.requestUpdate(n,c,s)}}throw Error("Unsupported decorator location: "+r)};function d(s){return(t,e)=>typeof e=="object"?ds(s,t,e):((r,i,o)=>{let n=i.hasOwnProperty(o);return i.constructor.createProperty(o,n?S(q({},r),{wrapped:!0}):r),n?Object.getOwnPropertyDescriptor(i,o):void 0})(s,t,e)}function E(s){return d(S(q({},s),{state:!0,attribute:!1}))}var te=(s,t,e)=>(e.configurable=!0,e.enumerable=!0,Reflect.decorate&&typeof t!="object"&&Object.defineProperty(s,t,e),e);function be(s,t){return(e,r,i)=>{let o=n=>{var a,c;return(c=(a=n.renderRoot)==null?void 0:a.querySelector(s))!=null?c:null};if(t){let{get:n,set:a}=typeof r=="object"?e:i!=null?i:(()=>{let c=Symbol();return{get(){return this[c]},set(p){this[c]=p}}})();return te(e,r,{get(){let c=n.call(this);return c===void 0&&(c=o(this),(c!==null||this.hasUpdated)&&a.call(this,c)),c}})}return te(e,r,{get(){return o(this)}})}}function ui(s){return(t,e)=>{let{slot:r,selector:i}=s!=null?s:{},o="slot"+(r?`[name=${r}]`:":not([name])");return te(t,e,{get(){var c,p;let n=(c=this.renderRoot)==null?void 0:c.querySelector(o),a=(p=n==null?void 0:n.assignedElements(s))!=null?p:[];return i===void 0?a:a.filter(f=>f.matches(i))}})}}function M(s,t){let e=q({waitUntilFirstUpdate:!1},t);return(r,i)=>{let{update:o}=r,n=Array.isArray(s)?s:[s];r.update=function(a){n.forEach(c=>{let p=c;if(a.has(p)){let f=a.get(p),m=this[p];f!==m&&(!e.waitUntilFirstUpdate||this.hasUpdated)&&this[i](f,m)}}),o.call(this,a)}}}var hi=[{identifier:"completionStatus",cardinality:"single",baseType:"string",value:"unknown",type:"outcome"},{identifier:"numAttempts",cardinality:"single",baseType:"integer",value:"0",type:"response"}],$=Symbol("item");var D=class extends v{constructor(){super();this.identifier="";this.adaptive="false";this.timeDependent=null;this._handleDisabledChange=(e,r)=>{this._interactionElements.forEach(i=>i.disabled=r)};this._handleReadonlyChange=(e,r)=>this._interactionElements.forEach(i=>i.readonly=r);this._context={identifier:this.getAttribute("identifier"),variables:hi};this._initialContext=S(q({},this._context),{variables:this._context.variables});this._feedbackElements=[];this._interactionElements=[];this.addEventListener("qti-register-variable",e=>{this._context=S(q({},this._context),{variables:[...this._context.variables,e.detail.variable]}),this._initialContext=this._context,e.stopPropagation()}),this.addEventListener("qti-register-feedback",e=>{e.stopPropagation();let r=e.detail;this._feedbackElements.push(r),r.checkShowFeedback(r.outcomeIdentifier)}),this.addEventListener("qti-register-interaction",e=>{e.stopPropagation(),this._interactionElements.push(e.target)}),this.addEventListener("end-attempt",e=>{let{responseIdentifier:r,countAttempt:i}=e.detail;this.updateResponseVariable(r,"true"),this.processResponse(i)}),this.addEventListener("qti-set-outcome-value",e=>{let{outcomeIdentifier:r,value:i}=e.detail;this.updateOutcomeVariable(r,i),e.stopPropagation()}),this.addEventListener("qti-interaction-response",this.handleUpdateResponseVariable)}get variables(){return this._context.variables.map(e=>q({identifier:e.identifier,value:e.value,type:e.type},e.type==="outcome"&&e.identifier==="SCORE"?{externalScored:e.externalScored}:{}))}set variables(e){if(!Array.isArray(e)||e.some(r=>!("identifier"in r))){console.warn("variables property should be an array of VariableDeclaration");return}this._context=S(q({},this._context),{variables:this._context.variables.map(r=>{let i=e.find(o=>o.identifier===r.identifier);return i?q(q({},r),i):r})}),this._context.variables.forEach(r=>{if(r.type==="response"){let i=this._interactionElements.find(o=>o.responseIdentifier===r.identifier);i&&(i.value=r.value)}r.type==="outcome"&&this._feedbackElements.forEach(i=>i.checkShowFeedback(r.identifier))})}async connectedCallback(){super.connectedCallback(),await this.updateComplete,this._emit("qti-assessment-item-connected",this)}set responses(e){if(e)for(let r of e){this.getResponse(r.responseIdentifier)&&this.updateResponseVariable(r.responseIdentifier,r.response);let o=this._interactionElements.find(n=>n.getAttribute("response-identifier")===r.responseIdentifier);o&&(o.value=r.response)}}render(){return u`<slot></slot>`}showCorrectResponse(e){let i=this._context.variables.filter(o=>"correctResponse"in o&&o.correctResponse).map(o=>({responseIdentifier:o.identifier,response:o.correctResponse}));for(let o of i){let n=this._interactionElements.find(a=>a.getAttribute("response-identifier")===o.responseIdentifier);n&&(n.correctResponse=e?o.response:"")}}processResponse(e=!0){var i;let r=this.querySelector("qti-response-processing");return!r||!r.process?!1:(r.process(),this.adaptive==="false"&&this.updateOutcomeVariable("completionStatus",this._getCompletionStatus()),e&&this.updateOutcomeVariable("numAttempts",(+((i=this._context.variables.find(o=>o.identifier==="numAttempts"))==null?void 0:i.value)+1).toString()),this._emit("qti-response-processed"),!0)}resetResponses(){this._context=this._initialContext}getResponse(e){return this.getVariable(e)}getOutcome(e){return this.getVariable(e)}getVariable(e){return this._context.variables.find(r=>r.identifier===e)||null}handleUpdateResponseVariable(e){let{responseIdentifier:r,response:i}=e.detail;this.updateResponseVariable(r,i)}updateResponseVariable(e,r){this._context=S(q({},this._context),{variables:this._context.variables.map(i=>i.identifier!==e?i:S(q({},i),{value:r}))}),this._emit("qti-interaction-changed",{item:this.identifier,responseIdentifier:e,response:Array.isArray(r)?[...r]:r}),this.adaptive==="false"&&this.updateOutcomeVariable("completionStatus",this._getCompletionStatus())}updateOutcomeVariable(e,r){var o;let i=this.getOutcome(e);if(!i){console.warn(`Can not set qti-outcome-identifier: ${e}, it is not available`);return}this._context=S(q({},this._context),{variables:this._context.variables.map(n=>n.identifier!==e?n:S(q({},n),{value:i.cardinality==="single"?r:[...n.value,r]}))}),this._feedbackElements.forEach(n=>n.checkShowFeedback(e)),this._emit("qti-outcome-changed",{item:this.identifier,outcomeIdentifier:e,value:(o=this._context.variables.find(n=>n.identifier===e))==null?void 0:o.value})}_getCompletionStatus(){return this._interactionElements.every(e=>e.validate())?"completed":this._interactionElements.some(e=>e.validate())?"incomplete":"not_attempted"}_emit(e,r=null){this.dispatchEvent(new CustomEvent(e,{bubbles:!0,composed:!0,detail:r}))}};l([d({type:String})],D.prototype,"title",2),l([d({type:String})],D.prototype,"identifier",2),l([d({type:String})],D.prototype,"adaptive",2),l([d({type:String})],D.prototype,"timeDependent",2),l([d({type:Boolean})],D.prototype,"disabled",2),l([M("disabled",{waitUntilFirstUpdate:!0})],D.prototype,"_handleDisabledChange",2),l([d({type:Boolean})],D.prototype,"readonly",2),l([M("readonly",{waitUntilFirstUpdate:!0})],D.prototype,"_handleReadonlyChange",2),l([Zt({context:$})],D.prototype,"_context",2),D=l([h("qti-assessment-item")],D);var us=String.raw,hs=us`<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
5
5
  <xsl:output method="html" version="5.0" encoding="UTF-8" indent="yes" />
6
6
  <xsl:template match="@*|node()">
7
7
  <xsl:copy>
@@ -31,11 +31,11 @@ Make sure to test your application with a production build as repeat registratio
31
31
  :host {
32
32
  display: none;
33
33
  }
34
- `],l([d({type:String,attribute:"base-type"})],U.prototype,"baseType",2),l([d({type:String,attribute:"external-scored"})],U.prototype,"externalScored",2),l([d({type:String})],U.prototype,"identifier",2),l([d({type:String})],U.prototype,"cardinality",2),l([k({context:$,subscribe:!0}),E()],U.prototype,"itemContext",2),U=l([h("qti-outcome-declaration")],U);var J=class extends re{render(){var e,r;let t=(r=(e=this.itemContext)==null?void 0:e.variables.find(i=>i.identifier===this.identifier))==null?void 0:r.value;return u`${JSON.stringify(t,null,2)}`}connectedCallback(){super.connectedCallback();let t={baseType:this.baseType,identifier:this.identifier,correctResponse:this.correctResponse,cardinality:this.cardinality||"single",mapping:this.mapping,value:null,type:"response",candidateResponse:null};t.value=this.defaultValues(t),this.dispatchEvent(new CustomEvent("qti-register-variable",{bubbles:!0,composed:!0,detail:{variable:t}}))}get correctResponse(){let t,e=this.querySelector("qti-correct-response");if(e){let r=e.querySelectorAll("qti-value");if(this.cardinality==="single"&&r.length>0)t=r[0].textContent,r[0].remove();else if(this.cardinality!=="single"){t=[];for(let i=0;i<r.length;i++)t.push(r[i].textContent),r[i].remove()}}return t}get mapping(){return this.querySelector("qti-mapping")}};J.styles=[g`
34
+ `],l([d({type:String,attribute:"base-type"})],U.prototype,"baseType",2),l([d({type:String,attribute:"external-scored"})],U.prototype,"externalScored",2),l([d({type:String})],U.prototype,"identifier",2),l([d({type:String})],U.prototype,"cardinality",2),l([k({context:$,subscribe:!0}),E()],U.prototype,"itemContext",2),U=l([h("qti-outcome-declaration")],U);var Z=class extends re{render(){var e,r;let t=(r=(e=this.itemContext)==null?void 0:e.variables.find(i=>i.identifier===this.identifier))==null?void 0:r.value;return u`${JSON.stringify(t,null,2)}`}connectedCallback(){super.connectedCallback();let t={baseType:this.baseType,identifier:this.identifier,correctResponse:this.correctResponse,cardinality:this.cardinality||"single",mapping:this.mapping,value:null,type:"response",candidateResponse:null};t.value=this.defaultValues(t),this.dispatchEvent(new CustomEvent("qti-register-variable",{bubbles:!0,composed:!0,detail:{variable:t}}))}get correctResponse(){let t,e=this.querySelector("qti-correct-response");if(e){let r=e.querySelectorAll("qti-value");if(this.cardinality==="single"&&r.length>0)t=r[0].textContent,r[0].remove();else if(this.cardinality!=="single"){t=[];for(let i=0;i<r.length;i++)t.push(r[i].textContent),r[i].remove()}}return t}get mapping(){return this.querySelector("qti-mapping")}};Z.styles=[g`
35
35
  :host {
36
36
  display: none;
37
37
  }
38
- `],l([d({type:String,attribute:"base-type"})],J.prototype,"baseType",2),l([d({type:String})],J.prototype,"identifier",2),l([d({type:String})],J.prototype,"cardinality",2),l([k({context:$,subscribe:!0}),E()],J.prototype,"itemContext",2),J=l([h("qti-response-declaration")],J);var Rt=class extends v{};Rt=l([h("qti-companion-materials-info")],Rt);var kt=class extends v{render(){return u`<slot></slot>`}};kt=l([h("qti-content-body")],kt);var F=class extends v{handleclassNamesChange(t,e){this.classNames.split(" ").forEach(i=>{switch(i){case"qti-rubric-discretionary-placement":this.setAttribute("slot","qti-rubric-block");break;case"qti-rubric-inline":this.setAttribute("slot","");break;default:break}})}render(){return u`<slot></slot>`}connectedCallback(){super.connectedCallback(),this.setAttribute("slot","qti-rubric-block")}};F.styles=g`
38
+ `],l([d({type:String,attribute:"base-type"})],Z.prototype,"baseType",2),l([d({type:String})],Z.prototype,"identifier",2),l([d({type:String})],Z.prototype,"cardinality",2),l([k({context:$,subscribe:!0}),E()],Z.prototype,"itemContext",2),Z=l([h("qti-response-declaration")],Z);var Rt=class extends v{};Rt=l([h("qti-companion-materials-info")],Rt);var kt=class extends v{render(){return u`<slot></slot>`}};kt=l([h("qti-content-body")],kt);var F=class extends v{handleclassNamesChange(t,e){this.classNames.split(" ").forEach(i=>{switch(i){case"qti-rubric-discretionary-placement":this.setAttribute("slot","qti-rubric-block");break;case"qti-rubric-inline":this.setAttribute("slot","");break;default:break}})}render(){return u`<slot></slot>`}connectedCallback(){super.connectedCallback(),this.setAttribute("slot","qti-rubric-block")}};F.styles=g`
39
39
  :host {
40
40
  display: block;
41
41
  }
@@ -90,7 +90,7 @@ Make sure to test your application with a production build as repeat registratio
90
90
  ?disabled="${this.disabled}"
91
91
  ?readonly="${this.readonly}"
92
92
  .value=${this._value}
93
- ></textarea>`}textChanged(e){if(this.disabled||this.readonly)return;let r=e.target;if(this.setEmptyAttribute(r.value),this._value!==r.value){this.value=r.value;let i=this.validate();this.saveResponse(r.value)}}setEmptyAttribute(e){this.setAttribute("empty",e===""?"true":"false")}};l([E()],V.prototype,"_rows",2),l([d({type:Number,attribute:"expected-length"})],V.prototype,"expectedLength",2),l([d({type:String,attribute:"pattern-mask"})],V.prototype,"patternMask",2),l([d({type:String,attribute:"placeholder-text"})],V.prototype,"placeholderText",2),l([d({type:String,attribute:"data-patternmask-message"})],V.prototype,"dataPatternmaskMessage",2),l([E()],V.prototype,"_value",2),l([d({type:String,attribute:"class"})],V.prototype,"classNames",2),l([M("classNames")],V.prototype,"handleclassNamesChange",1),V=l([h("qti-extended-text-interaction")],V);var{I:fs}=li;var qi=s=>s.strings===void 0,wi=()=>document.createComment(""),Me=(s,t,e)=>{var o;let r=s._$AA.parentNode,i=t===void 0?s._$AB:t._$AA;if(e===void 0){let n=r.insertBefore(wi(),i),a=r.insertBefore(wi(),i);e=new fs(n,a,s,s.options)}else{let n=e._$AB.nextSibling,a=e._$AM,c=a!==s;if(c){let p;(o=e._$AQ)==null||o.call(e,s),e._$AM=s,e._$AP!==void 0&&(p=s._$AU)!==a._$AU&&e._$AP(p)}if(n!==i||c){let p=e._$AA;for(;p!==n;){let f=p.nextSibling;r.insertBefore(p,i),p=f}}}return e},se=(s,t,e=s)=>(s._$AI(t,e),s),gs={},Ai=(s,t=gs)=>s._$AH=t,Ti=s=>s._$AH,Lt=s=>{var r;(r=s._$AP)==null||r.call(s,!1,!0);let t=s._$AA,e=s._$AB.nextSibling;for(;t!==e;){let i=t.nextSibling;t.remove(),t=i}};var oe={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},G=s=>(...t)=>({_$litDirective$:s,values:t}),B=class{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,r){this._$Ct=t,this._$AM=e,this._$Ci=r}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}};var tt=(s,t)=>{var r;let e=s._$AN;if(e===void 0)return!1;for(let i of e)(r=i._$AO)==null||r.call(i,t,!1),tt(i,t);return!0},Dt=s=>{let t,e;do{if((t=s._$AM)===void 0)break;e=t._$AN,e.delete(s),s=t}while((e==null?void 0:e.size)===0)},Si=s=>{for(let t;t=s._$AM;s=t){let e=t._$AN;if(e===void 0)t._$AN=e=new Set;else if(e.has(s))break;e.add(s),ys(t)}};function bs(s){this._$AN!==void 0?(Dt(this),this._$AM=s,Si(this)):this._$AM=s}function vs(s,t=!1,e=0){let r=this._$AH,i=this._$AN;if(i!==void 0&&i.size!==0)if(t)if(Array.isArray(r))for(let o=e;o<r.length;o++)tt(r[o],!1),Dt(r[o]);else r!=null&&(tt(r,!1),Dt(r));else tt(this,s)}var ys=s=>{var t,e;s.type==oe.CHILD&&((t=s._$AP)!=null||(s._$AP=vs),(e=s._$AQ)!=null||(s._$AQ=bs))},Ht=class extends B{constructor(){super(...arguments),this._$AN=void 0}_$AT(t,e,r){super._$AT(t,e,r),Si(this),this.isConnected=t._$AU}_$AO(t,e=!0){var r,i;t!==this.isConnected&&(this.isConnected=t,t?(r=this.reconnected)==null||r.call(this):(i=this.disconnected)==null||i.call(this)),e&&(tt(this,t),Dt(this))}setValue(t){if(qi(this._$Ct))this._$Ct._$AI(t,this);else{let e=[...this._$Ct._$AH];e[this._$Ci]=t,this._$Ct._$AI(e,this,0)}}disconnected(){}reconnected(){}};var Mi=()=>new ur,ur=class{},dr=new WeakMap,Sl=G(class extends Ht{render(s){return w}update(s,[t]){var r;let e=t!==this.Y;return e&&this.Y!==void 0&&this.rt(void 0),(e||this.lt!==this.ct)&&(this.Y=t,this.ht=(r=s.options)==null?void 0:r.host,this.rt(this.ct=s.element)),w}rt(s){var t;if(this.isConnected||(s=void 0),typeof this.Y=="function"){let e=(t=this.ht)!=null?t:globalThis,r=dr.get(e);r===void 0&&(r=new WeakMap,dr.set(e,r)),r.get(this.Y)!==void 0&&this.Y.call(this.ht,void 0),r.set(this.Y,s),s!==void 0&&this.Y.call(this.ht,s)}else this.Y.value=s}get lt(){var s,t,e;return typeof this.Y=="function"?(t=dr.get((s=this.ht)!=null?s:globalThis))==null?void 0:t.get(this.Y):(e=this.Y)==null?void 0:e.value}disconnected(){this.lt===this.ct&&this.rt(void 0)}reconnected(){this.rt(this.ct)}});var $i=g`
93
+ ></textarea>`}textChanged(e){if(this.disabled||this.readonly)return;let r=e.target;if(this.setEmptyAttribute(r.value),this._value!==r.value){this.value=r.value;let i=this.validate();this.saveResponse(r.value)}}setEmptyAttribute(e){this.setAttribute("empty",e===""?"true":"false")}};l([E()],V.prototype,"_rows",2),l([d({type:Number,attribute:"expected-length"})],V.prototype,"expectedLength",2),l([d({type:String,attribute:"pattern-mask"})],V.prototype,"patternMask",2),l([d({type:String,attribute:"placeholder-text"})],V.prototype,"placeholderText",2),l([d({type:String,attribute:"data-patternmask-message"})],V.prototype,"dataPatternmaskMessage",2),l([E()],V.prototype,"_value",2),l([d({type:String,attribute:"class"})],V.prototype,"classNames",2),l([M("classNames")],V.prototype,"handleclassNamesChange",1),V=l([h("qti-extended-text-interaction")],V);var{I:fs}=li;var qi=s=>s.strings===void 0,wi=()=>document.createComment(""),Me=(s,t,e)=>{var o;let r=s._$AA.parentNode,i=t===void 0?s._$AB:t._$AA;if(e===void 0){let n=r.insertBefore(wi(),i),a=r.insertBefore(wi(),i);e=new fs(n,a,s,s.options)}else{let n=e._$AB.nextSibling,a=e._$AM,c=a!==s;if(c){let p;(o=e._$AQ)==null||o.call(e,s),e._$AM=s,e._$AP!==void 0&&(p=s._$AU)!==a._$AU&&e._$AP(p)}if(n!==i||c){let p=e._$AA;for(;p!==n;){let f=p.nextSibling;r.insertBefore(p,i),p=f}}}return e},se=(s,t,e=s)=>(s._$AI(t,e),s),gs={},Ai=(s,t=gs)=>s._$AH=t,Ti=s=>s._$AH,Lt=s=>{var r;(r=s._$AP)==null||r.call(s,!1,!0);let t=s._$AA,e=s._$AB.nextSibling;for(;t!==e;){let i=t.nextSibling;t.remove(),t=i}};var oe={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},J=s=>(...t)=>({_$litDirective$:s,values:t}),B=class{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,r){this._$Ct=t,this._$AM=e,this._$Ci=r}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}};var tt=(s,t)=>{var r;let e=s._$AN;if(e===void 0)return!1;for(let i of e)(r=i._$AO)==null||r.call(i,t,!1),tt(i,t);return!0},Dt=s=>{let t,e;do{if((t=s._$AM)===void 0)break;e=t._$AN,e.delete(s),s=t}while((e==null?void 0:e.size)===0)},Si=s=>{for(let t;t=s._$AM;s=t){let e=t._$AN;if(e===void 0)t._$AN=e=new Set;else if(e.has(s))break;e.add(s),ys(t)}};function bs(s){this._$AN!==void 0?(Dt(this),this._$AM=s,Si(this)):this._$AM=s}function vs(s,t=!1,e=0){let r=this._$AH,i=this._$AN;if(i!==void 0&&i.size!==0)if(t)if(Array.isArray(r))for(let o=e;o<r.length;o++)tt(r[o],!1),Dt(r[o]);else r!=null&&(tt(r,!1),Dt(r));else tt(this,s)}var ys=s=>{var t,e;s.type==oe.CHILD&&((t=s._$AP)!=null||(s._$AP=vs),(e=s._$AQ)!=null||(s._$AQ=bs))},Ht=class extends B{constructor(){super(...arguments),this._$AN=void 0}_$AT(t,e,r){super._$AT(t,e,r),Si(this),this.isConnected=t._$AU}_$AO(t,e=!0){var r,i;t!==this.isConnected&&(this.isConnected=t,t?(r=this.reconnected)==null||r.call(this):(i=this.disconnected)==null||i.call(this)),e&&(tt(this,t),Dt(this))}setValue(t){if(qi(this._$Ct))this._$Ct._$AI(t,this);else{let e=[...this._$Ct._$AH];e[this._$Ci]=t,this._$Ct._$AI(e,this,0)}}disconnected(){}reconnected(){}};var Mi=()=>new ur,ur=class{},dr=new WeakMap,Sl=J(class extends Ht{render(s){return w}update(s,[t]){var r;let e=t!==this.Y;return e&&this.Y!==void 0&&this.rt(void 0),(e||this.lt!==this.ct)&&(this.Y=t,this.ht=(r=s.options)==null?void 0:r.host,this.rt(this.ct=s.element)),w}rt(s){var t;if(this.isConnected||(s=void 0),typeof this.Y=="function"){let e=(t=this.ht)!=null?t:globalThis,r=dr.get(e);r===void 0&&(r=new WeakMap,dr.set(e,r)),r.get(this.Y)!==void 0&&this.Y.call(this.ht,void 0),r.set(this.Y,s),s!==void 0&&this.Y.call(this.ht,s)}else this.Y.value=s}get lt(){var s,t,e;return typeof this.Y=="function"?(t=dr.get((s=this.ht)!=null?s:globalThis))==null?void 0:t.get(this.Y):(e=this.Y)==null?void 0:e.value}disconnected(){this.lt===this.ct&&this.rt(void 0)}reconnected(){this.rt(this.ct)}});var $i=g`
94
94
  :host {
95
95
  display: inline-block;
96
96
  }
@@ -191,7 +191,7 @@ Make sure to test your application with a production build as repeat registratio
191
191
  ?readonly="${this.readonly}"
192
192
  />
193
193
  <div part="correct">${this._correctResponse}</div>
194
- `}textChanged(e){if(this.disabled||this.readonly)return;let r=e.target;if(this.setEmptyAttribute(r.value),this._value!==r.value){this.value=r.value;let i=this.validate();this.saveResponse(r.value)}}reportValidity(){let e=this.shadowRoot.querySelector("input");if(!e)return!1;let r=this.validate();return r||e.reportValidity(),r}reset(){this._value=""}setEmptyAttribute(e){this.setAttribute("empty",e===""?"true":"false")}};X.styles=$i,l([d({type:Number,attribute:"expected-length"})],X.prototype,"expectedLength",2),l([d({type:String,attribute:"pattern-mask"})],X.prototype,"patternMask",2),l([d({type:String,attribute:"placeholder-text"})],X.prototype,"placeholderText",2),l([d({type:String,attribute:"data-patternmask-message"})],X.prototype,"dataPatternmaskMessage",2),l([E()],X.prototype,"_value",2),X=l([h("qti-text-entry-interaction")],X);var ne=(s,t)=>{class e extends s{constructor(){super(...arguments);this._choiceElements=[];this.minChoices=0;this.maxChoices=1;this._handleDisabledChange=(o,n)=>{this._choiceElements.forEach(a=>a.disabled=n)};this._handleReadonlyChange=(o,n)=>{this._choiceElements.forEach(a=>a.readonly=n)};this._value=""}_handleMaxChoicesChange(o,n){this._determineInputType()}get value(){return Array.isArray(this._value)?this._value.join(","):this._value}set value(o){if(this.maxChoices>1&&typeof o=="string"?this._value=o.split(","):this._value=o,Array.isArray(this._value)){let n=new FormData;this._value.forEach(a=>{n.append(this.responseIdentifier,a)}),this._internals.setFormValue(n)}else this._internals.setFormValue(this._value);this._updateChoiceSelection()}get correctResponse(){return this._correctResponse}set correctResponse(o){this._correctResponse=o;let n=Array.isArray(o)?o:[o];this._choiceElements.forEach(a=>{a.internals.states.delete("correct-response"),a.internals.states.delete("incorrect-response"),n.length>0&&(n.includes(a.identifier)?a.internals.states.add("correct-response"):a.internals.states.add("incorrect-response"))})}connectedCallback(){super.connectedCallback(),this.addEventListener(`register-${t}`,this._registerChoiceElement),this.addEventListener(`unregister-${t}`,this._unregisterChoiceElement),this.addEventListener(`activate-${t}`,this._choiceElementSelectedHandler)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(`register-${t}`,this._registerChoiceElement),this.removeEventListener(`unregister-${t}`,this._unregisterChoiceElement),this.removeEventListener(`activate-${t}`,this._choiceElementSelectedHandler)}validate(){let o=this._choiceElements.filter(p=>this._getChoiceChecked(p)),n=o.length,a=!0,c="";return this.maxChoices!==0&&n>this.maxChoices?(a=!1,c=this.dataset.maxSelectionsMessage||`You can select at most ${this.maxChoices} choices.`):n<this.minChoices&&(a=!1,c=this.dataset.minSelectionsMessage||`You must select at least ${this.minChoices} choices.`),o.length>0&&this._internals.setValidity(a?{}:{customError:!0},c,o[n-1]||this._choiceElements[0]||this),this.reportValidity(),a}reportValidity(){return this._validationMessageElement&&(this._internals.validity.valid?(this._validationMessageElement.textContent="",this._validationMessageElement.style.display="none"):(this._validationMessageElement.textContent=this._internals.validationMessage,this._validationMessageElement.style.display="block")),this._internals.validity.valid}_registerChoiceElement(o){o.stopPropagation();let n=o.target;n.disabled=this.disabled,this._choiceElements.push(n),this._setInputType(n)}_unregisterChoiceElement(o){o.stopPropagation();let n=o.target;this._choiceElements=this._choiceElements.filter(a=>a!==n)}_determineInputType(){this._choiceElements.forEach(o=>{this._setInputType(o)})}_setInputType(o){o.internals.role=this.maxChoices===1?"radio":"checkbox",o.internals.states.add(o.internals.role)}_choiceElementSelectedHandler(o){this._toggleChoiceChecked(o.target),this.maxChoices===1&&this._choiceElements.forEach(n=>{n.identifier!==o.detail.identifier&&this._setChoiceChecked(n,!1)}),this._handleChoiceSelection()}_setChoiceChecked(o,n){var a;(a=o.internals)!=null&&a.states&&(n?(o.internals.states.add("--checked"),o.internals.ariaChecked="true"):(o.internals.states.delete("--checked"),o.internals.ariaChecked="false"))}_getChoiceChecked(o){return o.internals.states.has("--checked")}_toggleChoiceChecked(o){let n=this._getChoiceChecked(o);this._setChoiceChecked(o,!n)}_handleChoiceSelection(){let n=this._choiceElements.filter(a=>this._getChoiceChecked(a)).map(a=>a.identifier);this.value=this.maxChoices===1?n[0]||"":n,this.validate(),this.saveResponse(this._value)}_updateChoiceSelection(){let o=Array.isArray(this._value)?this._value:[this._value];this._choiceElements.forEach(n=>{let a=o.includes(n.identifier);this._setChoiceChecked(n,a)})}}return l([ve("#validationMessage")],e.prototype,"_validationMessageElement",2),l([d({type:Number,attribute:"min-choices"})],e.prototype,"minChoices",2),l([d({type:Number,attribute:"max-choices"})],e.prototype,"maxChoices",2),l([M("maxChoices",{waitUntilFirstUpdate:!0})],e.prototype,"_handleMaxChoicesChange",1),l([M("disabled",{waitUntilFirstUpdate:!0})],e.prototype,"_handleDisabledChange",2),l([M("readonly",{waitUntilFirstUpdate:!0})],e.prototype,"_handleReadonlyChange",2),e};var Vt=class extends ne(x,"qti-hottext"){constructor(){super(...arguments);this.render=()=>u`<slot></slot>`}connectedCallback(){super.connectedCallback(),this.setAttribute("qti-hottext-interaction","")}};Vt=l([h("qti-hottext-interaction")],Vt);var rt=class extends B{constructor(t){if(super(t),this.it=w,t.type!==oe.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(t){if(t===w||t==null)return this._t=void 0,this.it=t;if(t===L)return t;if(typeof t!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(t===this.it)return this._t;this.it=t;let e=[t];return e.raw=e,this._t={_$litType$:this.constructor.resultType,strings:e,values:[]}}};rt.directiveName="unsafeHTML",rt.resultType=1;var ae=G(rt);var le=class extends x{constructor(){super(...arguments);this.options=[];this.correctOption="";this.dataPrompt="select"}static get styles(){return[g`
194
+ `}textChanged(e){if(this.disabled||this.readonly)return;let r=e.target;if(this.setEmptyAttribute(r.value),this._value!==r.value){this.value=r.value;let i=this.validate();this.saveResponse(r.value)}}reportValidity(){let e=this.shadowRoot.querySelector("input");if(!e)return!1;let r=this.validate();return r||e.reportValidity(),r}reset(){this._value=""}setEmptyAttribute(e){this.setAttribute("empty",e===""?"true":"false")}};X.styles=$i,l([d({type:Number,attribute:"expected-length"})],X.prototype,"expectedLength",2),l([d({type:String,attribute:"pattern-mask"})],X.prototype,"patternMask",2),l([d({type:String,attribute:"placeholder-text"})],X.prototype,"placeholderText",2),l([d({type:String,attribute:"data-patternmask-message"})],X.prototype,"dataPatternmaskMessage",2),l([E()],X.prototype,"_value",2),X=l([h("qti-text-entry-interaction")],X);var ne=(s,t)=>{class e extends s{constructor(){super(...arguments);this._choiceElements=[];this.minChoices=0;this.maxChoices=1;this._handleDisabledChange=(o,n)=>{this._choiceElements.forEach(a=>a.disabled=n)};this._handleReadonlyChange=(o,n)=>{this._choiceElements.forEach(a=>a.readonly=n)};this._value=""}_handleMaxChoicesChange(o,n){this._determineInputType()}get value(){return Array.isArray(this._value)?this._value.join(","):this._value}set value(o){if(this.maxChoices>1&&typeof o=="string"?this._value=o.split(","):this._value=o,Array.isArray(this._value)){let n=new FormData;this._value.forEach(a=>{n.append(this.responseIdentifier,a)}),this._internals.setFormValue(n)}else this._internals.setFormValue(this._value);this._updateChoiceSelection()}get correctResponse(){return this._correctResponse}set correctResponse(o){this._correctResponse=o;let n=Array.isArray(o)?o:[o];this._choiceElements.forEach(a=>{a.internals.states.delete("correct-response"),a.internals.states.delete("incorrect-response"),n.length>0&&(n.includes(a.identifier)?a.internals.states.add("correct-response"):a.internals.states.add("incorrect-response"))})}connectedCallback(){super.connectedCallback(),this.addEventListener(`register-${t}`,this._registerChoiceElement),this.addEventListener(`unregister-${t}`,this._unregisterChoiceElement),this.addEventListener(`activate-${t}`,this._choiceElementSelectedHandler)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(`register-${t}`,this._registerChoiceElement),this.removeEventListener(`unregister-${t}`,this._unregisterChoiceElement),this.removeEventListener(`activate-${t}`,this._choiceElementSelectedHandler)}validate(){let o=this._choiceElements.filter(p=>this._getChoiceChecked(p)),n=o.length,a=!0,c="";return this.maxChoices!==0&&n>this.maxChoices?(a=!1,c=this.dataset.maxSelectionsMessage||`You can select at most ${this.maxChoices} choices.`):n<this.minChoices&&(a=!1,c=this.dataset.minSelectionsMessage||`You must select at least ${this.minChoices} choices.`),o.length>0&&this._internals.setValidity(a?{}:{customError:!0},c,o[n-1]||this._choiceElements[0]||this),this.reportValidity(),a}reportValidity(){return this._validationMessageElement&&(this._internals.validity.valid?(this._validationMessageElement.textContent="",this._validationMessageElement.style.display="none"):(this._validationMessageElement.textContent=this._internals.validationMessage,this._validationMessageElement.style.display="block")),this._internals.validity.valid}_registerChoiceElement(o){o.stopPropagation();let n=o.target;n.disabled=this.disabled,this._choiceElements.push(n),this._setInputType(n)}_unregisterChoiceElement(o){o.stopPropagation();let n=o.target;this._choiceElements=this._choiceElements.filter(a=>a!==n)}_determineInputType(){this._choiceElements.forEach(o=>{this._setInputType(o)})}_setInputType(o){o.internals.role=this.maxChoices===1?"radio":"checkbox",o.internals.states.add(o.internals.role)}_choiceElementSelectedHandler(o){this._toggleChoiceChecked(o.target),this.maxChoices===1&&this._choiceElements.forEach(n=>{n.identifier!==o.detail.identifier&&this._setChoiceChecked(n,!1)}),this._handleChoiceSelection()}_setChoiceChecked(o,n){var a;(a=o.internals)!=null&&a.states&&(n?(o.internals.states.add("--checked"),o.internals.ariaChecked="true"):(o.internals.states.delete("--checked"),o.internals.ariaChecked="false"))}_getChoiceChecked(o){return o.internals.states.has("--checked")}_toggleChoiceChecked(o){let n=this._getChoiceChecked(o);this._setChoiceChecked(o,!n)}_handleChoiceSelection(){let n=this._choiceElements.filter(a=>this._getChoiceChecked(a)).map(a=>a.identifier);this.value=this.maxChoices===1?n[0]||"":n,this.validate(),this.saveResponse(this._value)}_updateChoiceSelection(){let o=Array.isArray(this._value)?this._value:[this._value];this._choiceElements.forEach(n=>{let a=o.includes(n.identifier);this._setChoiceChecked(n,a)})}}return l([be("#validationMessage")],e.prototype,"_validationMessageElement",2),l([d({type:Number,attribute:"min-choices"})],e.prototype,"minChoices",2),l([d({type:Number,attribute:"max-choices"})],e.prototype,"maxChoices",2),l([M("maxChoices",{waitUntilFirstUpdate:!0})],e.prototype,"_handleMaxChoicesChange",1),l([M("disabled",{waitUntilFirstUpdate:!0})],e.prototype,"_handleDisabledChange",2),l([M("readonly",{waitUntilFirstUpdate:!0})],e.prototype,"_handleReadonlyChange",2),e};var Vt=class extends ne(x,"qti-hottext"){constructor(){super(...arguments);this.render=()=>u`<slot></slot>`}connectedCallback(){super.connectedCallback(),this.setAttribute("qti-hottext-interaction","")}};Vt=l([h("qti-hottext-interaction")],Vt);var rt=class extends B{constructor(t){if(super(t),this.it=w,t.type!==oe.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(t){if(t===w||t==null)return this._t=void 0,this.it=t;if(t===L)return t;if(typeof t!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(t===this.it)return this._t;this.it=t;let e=[t];return e.raw=e,this._t={_$litType$:this.constructor.resultType,strings:e,values:[]}}};rt.directiveName="unsafeHTML",rt.resultType=1;var ae=J(rt);var le=class extends x{constructor(){super(...arguments);this.options=[];this.correctOption="";this.dataPrompt="select"}static get styles(){return[g`
195
195
  :host {
196
196
  display: inline-block;
197
197
  }
@@ -315,19 +315,19 @@ Make sure to test your application with a production build as repeat registratio
315
315
  </qti-set-outcome-value>
316
316
  </qti-response-else>
317
317
  </qti-response-condition>
318
- </qti-response-processing>`;var ye=class extends v{render(){return u`<slot></slot>`}process(){let t=[...this.children];for(let e of t)e.process()}firstUpdated(t){if(this.getAttribute("template")){let e=this.getAttribute("template").split("/"),r=e[e.length-1].replace(".xml","");switch(this.innerHTML="",r){case"map_response":{this.appendChild(this.fragmentFromString(Di).firstElementChild.firstElementChild);break}case"map_response_point":{this.appendChild(this.fragmentFromString(Hi).firstElementChild.firstElementChild);break}case"match_correct":this.appendChild(this.fragmentFromString(Li).firstElementChild.firstElementChild);break}}}fragmentFromString(t){return document.createRange().createContextualFragment(t)}};ye.styles=[g`
318
+ </qti-response-processing>`;var ve=class extends v{render(){return u`<slot></slot>`}process(){let t=[...this.children];for(let e of t)e.process()}firstUpdated(t){if(this.getAttribute("template")){let e=this.getAttribute("template").split("/"),r=e[e.length-1].replace(".xml","");switch(this.innerHTML="",r){case"map_response":{this.appendChild(this.fragmentFromString(Di).firstElementChild.firstElementChild);break}case"map_response_point":{this.appendChild(this.fragmentFromString(Hi).firstElementChild.firstElementChild);break}case"match_correct":this.appendChild(this.fragmentFromString(Li).firstElementChild.firstElementChild);break}}}fragmentFromString(t){return document.createRange().createContextualFragment(t)}};ve.styles=[g`
319
319
  :host {
320
320
  display: none;
321
321
  }
322
- `],ye=l([h("qti-response-processing")],ye);var j=class extends v{render(){return u`<slot></slot>`}process(){throw new Error("Not implemented")}};j=l([h("qti-rule")],j);var Pt=class extends j{get childExpression(){return this.firstElementChild}process(){let t=this.getAttribute("identifier"),e=this.closest("qti-assessment-item").getVariable(t),r;return e.interpolationTable&&(r=e.interpolationTable.get(parseInt(this.childExpression.calculate()))),r==null?(console.warn("lookupOutcomeValue: value is null or undefined"),0):(this.dispatchEvent(new CustomEvent("qti-set-outcome-value",{bubbles:!0,composed:!0,detail:{outcomeIdentifier:this.identifier,value:Ze(r)}})),r)}};l([d({type:String})],Pt.prototype,"identifier",2);customElements.define("qti-lookup-outcome-value",Pt);var mr=class extends j{render(){return u`<slot></slot>`}process(){let t=[...this.children];for(let e=0;e<t.length;e++){let r=t[e];if(r.calculate()){r.process();return}}}};customElements.define("qti-response-condition",mr);var fr=class extends j{process(){let t=this.getAttribute("identifier"),e=this.firstElementChild,i=new gr(e).process();this.dispatchEvent(new CustomEvent("qti-set-outcome-value",{bubbles:!0,composed:!0,detail:{outcomeIdentifier:t,value:Array.isArray(i)?i.map(o=>Ze(o)):Ze(i)}}))}},gr=class{constructor(t){this.expression=t}process(){let t=this.expression?this.expression.calculate():null;if(t==null){console.warn("setOutcomeValue: value is null or undefined");return}return t}};customElements.define("qti-set-outcome-value",fr);var st=class extends v{render(){return u`<slot></slot>`}calculate(){return!0}getSubRules(){return[...this.children]}process(){let t=this.getSubRules();for(let e=0;e<t.length;e++)t[e].process()}};customElements.define("qti-response-else",st);var ot=class extends st{calculate(){return this.firstElementChild.calculate()}getSubRules(){let t=[];for(let e=1;e<this.children.length;e++)t.push(this.children[e]);return t}};customElements.define("qti-response-if",ot);var br=class extends ot{render(){return u`${super.render()}`}};customElements.define("qti-response-else-if",br);var _=class extends v{constructor(){super(...arguments);this.getVariables=()=>Array.from(this.children).map(e=>{switch(e.tagName.toLowerCase()){case"qti-base-value":return{baseType:e.getAttribute("base-type"),value:e.textContent.trim(),cardinality:"single"};case"qti-variable":{let r=e.getAttribute("identifier")||"";return this.context.variables.find(o=>o.identifier===r)||null}case"qti-multiple":{let i=e.getResult();return i.length>0?{identifier:"",baseType:i[0].baseType,value:i.map(o=>o.value),cardinality:"multiple",type:"response"}:null}case"qti-correct":{let r=e.getAttribute("identifier")||"",i=this.context.variables.find(o=>o.identifier===r)||null;return{baseType:i.baseType,value:i.correctResponse,cardinality:i.cardinality}}default:{try{return{baseType:"integer",value:e.getResult().toString(),cardinality:"single"}}catch(r){console.warn("default not sufficient")}return null}}}).filter(e=>e!==null)}render(){return u`<pre>${JSON.stringify(this.result,null,2)}</pre>
322
+ `],ve=l([h("qti-response-processing")],ve);var j=class extends v{render(){return u`<slot></slot>`}process(){throw new Error("Not implemented")}};j=l([h("qti-rule")],j);var Pt=class extends j{get childExpression(){return this.firstElementChild}process(){let t=this.getAttribute("identifier"),e=this.closest("qti-assessment-item").getVariable(t),r;return e.interpolationTable&&(r=e.interpolationTable.get(parseInt(this.childExpression.calculate()))),r==null?(console.warn("lookupOutcomeValue: value is null or undefined"),0):(this.dispatchEvent(new CustomEvent("qti-set-outcome-value",{bubbles:!0,composed:!0,detail:{outcomeIdentifier:this.identifier,value:Ze(r)}})),r)}};l([d({type:String})],Pt.prototype,"identifier",2);customElements.define("qti-lookup-outcome-value",Pt);var mr=class extends j{render(){return u`<slot></slot>`}process(){let t=[...this.children];for(let e=0;e<t.length;e++){let r=t[e];if(r.calculate()){r.process();return}}}};customElements.define("qti-response-condition",mr);var fr=class extends j{process(){let t=this.getAttribute("identifier"),e=this.firstElementChild,i=new gr(e).process();this.dispatchEvent(new CustomEvent("qti-set-outcome-value",{bubbles:!0,composed:!0,detail:{outcomeIdentifier:t,value:Array.isArray(i)?i.map(o=>Ze(o)):Ze(i)}}))}},gr=class{constructor(t){this.expression=t}process(){let t=this.expression?this.expression.calculate():null;if(t==null){console.warn("setOutcomeValue: value is null or undefined");return}return t}};customElements.define("qti-set-outcome-value",fr);var st=class extends v{render(){return u`<slot></slot>`}calculate(){return!0}getSubRules(){return[...this.children]}process(){let t=this.getSubRules();for(let e=0;e<t.length;e++)t[e].process()}};customElements.define("qti-response-else",st);var ot=class extends st{calculate(){return this.firstElementChild.calculate()}getSubRules(){let t=[];for(let e=1;e<this.children.length;e++)t.push(this.children[e]);return t}};customElements.define("qti-response-if",ot);var br=class extends ot{render(){return u`${super.render()}`}};customElements.define("qti-response-else-if",br);var _=class extends v{constructor(){super(...arguments);this.getVariables=()=>Array.from(this.children).map(e=>{switch(e.tagName.toLowerCase()){case"qti-base-value":return{baseType:e.getAttribute("base-type"),value:e.textContent.trim(),cardinality:"single"};case"qti-variable":{let r=e.getAttribute("identifier")||"";return this.context.variables.find(o=>o.identifier===r)||null}case"qti-multiple":{let i=e.getResult();return i.length>0?{identifier:"",baseType:i[0].baseType,value:i.map(o=>o.value),cardinality:"multiple",type:"response"}:null}case"qti-correct":{let r=e.getAttribute("identifier")||"",i=this.context.variables.find(o=>o.identifier===r)||null;return{baseType:i.baseType,value:i.correctResponse,cardinality:i.cardinality}}default:{try{return{baseType:"integer",value:e.getResult().toString(),cardinality:"single"}}catch(r){console.warn("default not sufficient")}return null}}}).filter(e=>e!==null)}render(){return u`<pre>${JSON.stringify(this.result,null,2)}</pre>
323
323
  <slot></slot>`}calculate(){return this.result=this.getResult(),this.result}getResult(){throw new Error("Not implemented")}};_.styles=g`
324
324
  slot {
325
325
  display: none;
326
326
  }
327
- `,l([E()],_.prototype,"result",2),l([k({context:$,subscribe:!0}),E()],_.prototype,"context",2);var N=class extends _{calculate(){return this.result=this.getResult(),this.result}getResult(){throw new Error("Not implemented")}};var It=class extends Es(N){calculate(){return this.calculateChildren(Array.from(this.children))}};function Es(s){return class extends s{calculateChildren(e){return e.map(i=>{let o=i;if(!o.calculate)return console.error("Element doesn't implement QtiConditionExpression"),null;let n=o.calculate(),a=!1;if(typeof n=="string")if(n==="true")a=!0;else if(n==="false")a=!1;else return console.error("unexpected val in qti-or, expected boolean"),null;else typeof n=="boolean"&&(a=n);return a}).every(i=>typeof i=="boolean"&&i)}}}customElements.define("qti-and",It);var Ot=class extends _{constructor(){super(...arguments);this.baseType="string"}getResult(){return this.textContent.trim()}};l([d({type:String,attribute:"base-type"})],Ot.prototype,"baseType",2);customElements.define("qti-base-value",Ot);var vr=class extends N{getResult(){let t=this.getVariables();if(this.children.length===2){let e=t[0],r=t[1];if(e.baseType==="directedPair"&&r.baseType==="directedPair"&&e.cardinality==="multiple"){let i=e.value,o=r.value;return i.filter(c=>o.includes(c)).length>0}else if(e.baseType==="directedPair"&&r.baseType==="directedPair"&&e.cardinality==="single"){let i=e.value;return r.value.includes(i)}else console.error("unsupported baseType or cardinality in qti contains, only baseType: directedPair and cardinality: multiple is supported")}else console.error("unexpected number of children in qti contains");return!1}};customElements.define("qti-contains",vr);var yr=class extends _{get interpretation(){return this.getAttribute("interpretation")||""}getResult(){let t=this.getAttribute("identifier")||"",e=this.context.variables.find(r=>r.identifier===t)||null;return e.cardinality!=="single"?e.correctResponse.length>0?e.correctResponse[0]:"":e.correctResponse}};customElements.define("qti-correct",yr);var Ut=class extends _{constructor(){super(...arguments);this.roundingMode="significantFigures"}get figures(){if(!this.getAttribute("figures"))return console.error("figures attribute is missing"),null;let r=parseInt(this.getAttribute("figures")||"0");return isNaN(r)?(console.error("figures attribute is not a number"),null):r<0?(console.error("figures attribute is negative"),null):r<1&&this.roundingMode==="significantFigures"?(console.error("figures cannot be smaller than 1 for RoundingMode significantFigures"),null):r}getResult(){if(this.children.length===2){let e=this.getVariables(),r=e[0],i=e[1];if(this.roundingMode===null)return null;if(r.cardinality!=="single"||i.cardinality!=="single"||Array.isArray(r.value)||Array.isArray(i.value))return console.error("unexpected cardinality in qti equal"),!1;switch(e[0].baseType){case"integer":case"float":{let o=parseFloat(r.value),n=parseFloat(i.value);if(!isNaN(o)&&!isNaN(n))return this.roundingMode==="significantFigures"?o.toPrecision(this.figures)===n.toPrecision(this.figures):Math.round(o*Math.pow(10,this.figures))/Math.pow(10,this.figures)===Math.round(n*Math.pow(10,this.figures))/Math.pow(10,this.figures);console.error(`value cannot be casted to numeric value in equalRounded operator: ${o}, ${n}`);break}default:{console.error("values other than float and int cannot be used in equalRounded operator.");break}}return!1}return console.error("unexpected number of children in qti-equal-rounded"),null}};l([d({type:String})],Ut.prototype,"roundingMode",2);customElements.define("qti-equal-rounded",Ut);var P=class{static compareSingleValues(t,e,r){switch(r){case"identifier":case"string":return t===e;case"integer":{let i=parseInt(t,10),o=parseInt(e,10);if(!isNaN(i)&&!isNaN(o))return i===o;console.error(`Cannot convert ${t} and/or ${e} to int.`);break}case"float":{let i=parseFloat(t),o=parseFloat(e);if(!isNaN(i)&&!isNaN(o))return i===o;console.error(`couldn't convert ${t} and/or ${e} to float.`);break}case"pair":case"directedPair":{let i=t.split(" ").sort(),o=e.split(" ").sort();if(i.length===2&&o.length===2)return r==="pair"&&(i.sort(),o.sort()),i.join(" ")===o.join(" ");console.error(`compared two pair but one of the values does not have 2 values: 1: ${t} 2: ${e}`);break}}return!1}};var Ft=class extends _{constructor(){super(...arguments);this.toleranceMode="exact"}getResult(){if(this.children.length===2){let e=this.getVariables(),r=e[0],i=e[1];return this.toleranceMode!=="exact"?(console.error("toleranceMode is not supported yet"),!1):r.cardinality!=="single"||i.cardinality!=="single"||Array.isArray(r.value)||Array.isArray(i.value)?(console.error("unexpected cardinality in qti equal"),!1):P.compareSingleValues(r.value,i.value,r.baseType)}return console.error("unexpected number of children in qti-equal"),null}};l([d({type:String})],Ft.prototype,"toleranceMode",2);customElements.define("qti-equal",Ft);var xr=class extends _{getResult(){if(this.children.length===2){let t=this.getVariables(),e=t[0],r=t[1];if(e.baseType===r.baseType&&(e.baseType==="integer"||e.baseType==="float"))return+e.value>+r.value;console.error("unexpected baseType or cardinality in qti gt")}return console.error("unexpected number of children in qt"),null}};customElements.define("qti-gt",xr);var Er=class extends N{getResult(){if(this.children.length===2){let t=this.getVariables(),e=t[0],r=t[1];return e.baseType===r.baseType&&(e.baseType==="integer"||e.baseType==="float")?+e.value>=+r.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",Er);var Cr=class extends _{getResult(){if(this.children.length===1){let t=this.getVariables();if(!t)return!0;let e=t[0].value;return e==null||e==null||e===""}return console.error("unexpected number of children in qti Null"),null}};customElements.define("qti-is-null",Cr);var _r=class extends _{getResult(){if(this.children.length===2){let t=this.getVariables(),e=t[0],r=t[1];if(e.baseType===r.baseType&&(e.baseType==="integer"||e.baseType==="float"))return+e.value<+r.value;console.error("unexpected baseType or cardinality in qti lt")}return console.error("unexpected number of children in lt"),null}};customElements.define("qti-lt",_r);var wr=class extends N{getResult(){if(this.children.length===2){let t=this.getVariables(),e=t[0],r=t[1];return e.baseType===r.baseType&&(e.baseType==="integer"||e.baseType==="float")?+e.value<=+r.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",wr);var Bt=class extends _{getResult(){let t=this.context.variables.find(o=>o.identifier===this.identifier);if(!t)return console.warn(`Response ${this.identifier} can not be found`),null;let e=t.mapping,r=Array.isArray(t.value)?t.value:[t.value],i=0;for(let o of r){let n=e.mapEntries.find(a=>P.compareSingleValues(a.mapKey,o,t.baseType));n==null||n.mappedValue==null?i+=e.defaultValue:i+=n.mappedValue}return e.lowerBound!=null&&(i=Math.max(e.lowerBound,i)),e.upperBound!=null&&(i=Math.min(e.upperBound,i)),i}};l([d({type:String})],Bt.prototype,"identifier",2);customElements.define("qti-map-response",Bt);var Re=class extends v{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")}))}};l([d({attribute:"default-value",type:Number})],Re.prototype,"defaultValue",2),l([d({attribute:"lower-bound",type:Number})],Re.prototype,"lowerBound",2),l([d({attribute:"upper-bound",type:Number})],Re.prototype,"upperBound",2);customElements.define("qti-mapping",Re);var qr=class s extends _{getResult(){if(this.children.length===2){let t=this.getVariables(),e=t[0],r=t[1];return s.match(e,r)}return console.error("unexpected number of children in match"),null}static match(t,e){var r;switch(e.cardinality){case"single":return t.value===null?!1:Array.isArray(t.value)||Array.isArray(e.value)?(console.error("unexpected cardinality in qti match"),!1):P.compareSingleValues((r=t.value)==null?void 0:r.toString(),e.value.toString(),e.baseType);case"ordered":{if(!Array.isArray(t.value)||!Array.isArray(e.value))return console.error("unexpected cardinality in qti match"),!1;if(t.value.length!==e.value.length)return!1;for(let i=0;i<t.value.length;i++)if(!P.compareSingleValues(e.value[i],t.value[i],e.baseType))return!1;return!0}case"multiple":{if(!Array.isArray(t.value)||!Array.isArray(e.value))return console.error("unexpected cardinality in qti match"),!1;if(t.value.length!==e.value.length)return!1;let i=0;for(let o of e.value){let n=null,a=[...t.value];for(let c of a)if(P.compareSingleValues(o,c,e.baseType)){n=c;break}if(n!==null)a.splice(a.indexOf(n),1);else return!1;i++}return!0}default:return console.error("unexpected cardinality in qti match"),!1}}};customElements.define("qti-match",qr);var Ar=class extends _{getResult(){let t=this.getVariables();this.children.length!==2&&console.warn("The member operator takes two sub-expressions");let[e,r]=t;if(e.baseType!==r.baseType&&console.warn("Which must both have the same base-type"),r.cardinality==="multiple"||r.cardinality==="ordered"||console.warn("and the second must be a multiple or ordered container"),(e.baseType==="float"||r.baseType==="float")&&console.warn("The member operator should not be used on sub-expressions with a base-type of float"),(e.baseType==="duration"||r.baseType==="duration")&&console.warn("It must not be used on sub-expressions with a base-type of duration"),e.value===null||r.value===null)return null;let i=e.value;return r.value.includes(i)}};customElements.define("qti-member",Ar);var Tr=class extends _{getResult(){let t=this.getVariables();if(t.length===0)return console.error("unexpected number of children in qti multiple"),null;for(let e of t)if(e.cardinality!=="multiple"&&e.cardinality!=="single")return console.error("unexpected cardinality in qti multiple"),[];return t}};customElements.define("qti-multiple",Tr);var Sr=class extends _{render(){return u`${super.render()}`}getResult(){return!this.firstElementChild.calculate()}};customElements.define("qti-not",Sr);var Mr=class extends N{getResult(){return Array.from(this.children).map(e=>{let r=e;if(!r.calculate)return console.error("Element doesn't implement QtiConditionExpression"),null;let i=r.calculate(),o=!1;if(typeof i=="string")if(i==="true")o=!0;else if(i==="false")o=!1;else return console.error("unexpected val in qti-or, expected boolean"),null;else typeof i=="boolean"&&(o=i);return o}).some(e=>typeof e=="boolean"&&e)}};customElements.define("qti-or",Mr);var $r=class extends _{getResult(){let t=this.getVariables();if(t.length===0)return console.error("unexpected number of children in qti multiple"),null;for(let e of t)if(e.cardinality!=="ordered"&&e.cardinality!=="single")return console.error("unexpected cardinality in qti ordered"),[];return t}};customElements.define("qti-ordered",$r);var nt=class extends v{render(){var e,r;let t=(r=(e=this.context)==null?void 0:e.variables.find(i=>i.identifier===this.identifier))==null?void 0:r.value;return u`${JSON.stringify(t,null,2)}`}calculate(){return this.context.variables.find(e=>e.identifier===this.identifier)||null}};l([d({type:String})],nt.prototype,"identifier",2),l([k({context:$,subscribe:!0}),E()],nt.prototype,"context",2);customElements.define("qti-printed-variable",nt);var Rr=class extends _{getResult(){return this.getVariables().reduce((r,i)=>{if(i.baseType=="float"||i.baseType=="integer")try{return r*parseInt(i.value.toString())}catch(o){console.warn("can not convert to number")}else console.warn(`has another baseType ${i.baseType}`);return r},1)}};customElements.define("qti-product",Rr);var Xt=class extends _{constructor(){super(...arguments);this.caseSensitive="true"}getResult(){if(this.children.length===2){let e=this.getVariables(),r=e[0],i=e[1];if(r.cardinality!=="single"||i.cardinality!=="single"||Array.isArray(r.value)||Array.isArray(i.value))return console.error("unexpected cardinality in qti string-match"),!1;let o=this.caseSensitive==="true"?r.value:r.value.toLowerCase(),n=this.caseSensitive==="true"?i.value:i.value.toLowerCase();return P.compareSingleValues(o,n,r.baseType)}return console.error("unexpected number of children in qti-string-match"),null}};l([d({type:String,attribute:"case-sensitive"})],Xt.prototype,"caseSensitive",2);customElements.define("qti-string-match",Xt);var kr=class extends _{constructor(){super(),this._expression=new Lr(Array.from(this.children))}getResult(){return this._expression.calculate()}},Lr=class{constructor(t){this.expressions=t}calculate(){return this.expressions.map(e=>{if(!e.calculate)return console.error("Element doesn't implement QtiConditionExpression"),null;let r=e.calculate();return Number.isNaN(r)?(console.error("unexpected value in qti-sum, expected number"),null):Number(r)}).reduce((e,r)=>e+r,0)}};customElements.define("qti-sum",kr);var Dr=class extends _{getResult(){let t=this.getAttribute("identifier");return this.context.variables.find(r=>r.identifier===t).value}};customElements.define("qti-variable",Dr);var ce=class extends x{constructor(){super(...arguments);this._errorMessage=null;this.loadConfig=async(e,r)=>{e=this.removeDoubleSlashes(e);try{let i=await fetch(e);if(i.ok){let n=await i.json();for(let a in n.paths)r&&(n.paths[a]=this.getResolvablePath(n.paths[a],r));return n}}catch(i){}return null};this.getResolvablePathString=(e,r)=>(e=e.replace(/\.js$/,""),e!=null&&e.toLocaleLowerCase().startsWith("http")||!r?e:this.removeDoubleSlashes(`${r}/${e}`));this.getResolvablePath=(e,r)=>Array.isArray(e)?e.map(i=>this.getResolvablePathString(i,r)):this.getResolvablePathString(e,r)}convertQtiVariableJSON(e){for(let r in e)if(e.hasOwnProperty(r)){let i=e[r];if(i){for(let o in i)if(i.hasOwnProperty(o)){let n=i[o];if(Array.isArray(n))return n.map(String);if(n!=null)return String(n)}}}return null}startChecking(){this.intervalId=setInterval(()=>{let e=this.pci.getResponse(),r=this.pci.getResponse(),i=JSON.stringify(e);if(i!==this.rawResponse){this.rawResponse=i;let o=this.convertQtiVariableJSON(r);this.value=o,this.saveResponse(o)}},200)}stopChecking(){this.intervalId!==void 0&&clearInterval(this.intervalId)}validate(){return!0}set value(e){}get value(){return this.rawResponse}getTAOConfig(e){let r=e.querySelectorAll("properties"),i={},o=a=>{let c={},p=a.getAttribute("key");if(p){let f=Array.from(a.children),m=f.map(b=>b.getAttribute("key"));m.length>0&&!m.find(b=>!Number.isInteger(+b))?c[p]=f.map(b=>n(b)):c[p]=a.textContent}return c},n=a=>{if(a){let c={};for(let p of a.children)c=q(q({},c),o(p));return c}};for(let a of r)return a.getAttribute("key")||(i=q(q({},i),n(a))),i;return console.log("Can not find qti-custom-interaction config"),null}register(e){this.pci=e;let r=this.parentElement.tagName==="QTI-CUSTOM-INTERACTION"?"TAO":"IMS",i=r=="IMS"?this.querySelector("qti-interaction-markup"):this.querySelector("markup");i.classList.add("qti-customInteraction"),r=="TAO"&&this.querySelector("properties")&&(this.querySelector("properties").style.display="none");let o=r=="IMS"?{properties:this.dataset,onready:()=>{console.log("onready")}}:this.getTAOConfig(this);r=="IMS"?e.getInstance(i,o,void 0):e.initialize(this.customInteractionTypeIdentifier,i.firstElementChild,o),r=="TAO"&&Array.from(this.querySelectorAll("link")).map(a=>a.getAttribute("href")).forEach(a=>{let c=document.createElement("link");c.rel="stylesheet",c.type="text/css",c.media="screen",c.href=a,i.appendChild(c)}),this.startChecking()}connectedCallback(){super.connectedCallback(),define("qtiCustomInteractionContext",()=>({register:i=>{this.register(i)},notifyReady:()=>{}}));let e=this.buildRequireConfig();requirejs.config(e)(["require"],i=>{i([this.module])})}disconnectedCallback(){super.disconnectedCallback(),requirejs.undef(this.customInteractionTypeIdentifier);let e=requirejs.s.contexts;delete e[this.customInteractionTypeIdentifier],this.stopChecking()}buildRequireConfig(){let e={context:this.customInteractionTypeIdentifier,catchError:!0,paths:window.requirePaths||{},shim:window.requireShim||{}};if(!globalThis.require)return this._errorMessage="RequireJS not found. Please load it via CDN: https://cdnjs.com/libraries/require.js",null;let r=this.getAttribute("data-base-url"),i=this.querySelector("qti-interaction-modules");if(i){let o=i.querySelectorAll("qti-interaction-module");for(let n of o){let a=n.getAttribute("id"),c=n.getAttribute("primary-path"),p=n.getAttribute("fallback-path");if(a&&c){let f=p?this.combineRequireResolvePaths(this.getResolvablePath(c,r),this.getResolvablePath(p,r)):this.getResolvablePath(c,r),m=e.paths[a]||[];e.paths[a]=this.combineRequireResolvePaths(m,f)}}}return e}combineRequireResolvePaths(e,r){let i=Array.isArray(e)?e:[e],o=Array.isArray(r)?r:[r];return i.concat(o)}removeDoubleSlashes(e){return e.replace(/([^:]\/)\/+/g,"$1").replace(/\/\//g,"/").replace("http:/","http://").replace("https:/","https://")}render(){return u`<slot></slot>${this._errorMessage&&u`<div style="color:red">
327
+ `,l([E()],_.prototype,"result",2),l([k({context:$,subscribe:!0}),E()],_.prototype,"context",2);var N=class extends _{calculate(){return this.result=this.getResult(),this.result}getResult(){throw new Error("Not implemented")}};var It=class extends Es(N){calculate(){return this.calculateChildren(Array.from(this.children))}};function Es(s){return class extends s{calculateChildren(e){return e.map(i=>{let o=i;if(!o.calculate)return console.error("Element doesn't implement QtiConditionExpression"),null;let n=o.calculate(),a=!1;if(typeof n=="string")if(n==="true")a=!0;else if(n==="false")a=!1;else return console.error("unexpected val in qti-or, expected boolean"),null;else typeof n=="boolean"&&(a=n);return a}).every(i=>typeof i=="boolean"&&i)}}}customElements.define("qti-and",It);var Ot=class extends _{constructor(){super(...arguments);this.baseType="string"}getResult(){return this.textContent.trim()}};l([d({type:String,attribute:"base-type"})],Ot.prototype,"baseType",2);customElements.define("qti-base-value",Ot);var vr=class extends N{getResult(){let t=this.getVariables();if(this.children.length===2){let e=t[0],r=t[1];if(e.baseType==="directedPair"&&r.baseType==="directedPair"&&e.cardinality==="multiple"){let i=e.value,o=r.value;return i.filter(c=>o.includes(c)).length>0}else if(e.baseType==="directedPair"&&r.baseType==="directedPair"&&e.cardinality==="single"){let i=e.value;return r.value.includes(i)}else console.error("unsupported baseType or cardinality in qti contains, only baseType: directedPair and cardinality: multiple is supported")}else console.error("unexpected number of children in qti contains");return!1}};customElements.define("qti-contains",vr);var yr=class extends _{get interpretation(){return this.getAttribute("interpretation")||""}getResult(){let t=this.getAttribute("identifier")||"",e=this.context.variables.find(r=>r.identifier===t)||null;return e.cardinality!=="single"?e.correctResponse.length>0?e.correctResponse[0]:"":e.correctResponse}};customElements.define("qti-correct",yr);var Ut=class extends _{constructor(){super(...arguments);this.roundingMode="significantFigures"}get figures(){if(!this.getAttribute("figures"))return console.error("figures attribute is missing"),null;let r=parseInt(this.getAttribute("figures")||"0");return isNaN(r)?(console.error("figures attribute is not a number"),null):r<0?(console.error("figures attribute is negative"),null):r<1&&this.roundingMode==="significantFigures"?(console.error("figures cannot be smaller than 1 for RoundingMode significantFigures"),null):r}getResult(){if(this.children.length===2){let e=this.getVariables(),r=e[0],i=e[1];if(this.roundingMode===null)return null;if(r.cardinality!=="single"||i.cardinality!=="single"||Array.isArray(r.value)||Array.isArray(i.value))return console.error("unexpected cardinality in qti equal"),!1;switch(e[0].baseType){case"integer":case"float":{let o=parseFloat(r.value),n=parseFloat(i.value);if(!isNaN(o)&&!isNaN(n))return this.roundingMode==="significantFigures"?o.toPrecision(this.figures)===n.toPrecision(this.figures):Math.round(o*Math.pow(10,this.figures))/Math.pow(10,this.figures)===Math.round(n*Math.pow(10,this.figures))/Math.pow(10,this.figures);console.error(`value cannot be casted to numeric value in equalRounded operator: ${o}, ${n}`);break}default:{console.error("values other than float and int cannot be used in equalRounded operator.");break}}return!1}return console.error("unexpected number of children in qti-equal-rounded"),null}};l([d({type:String})],Ut.prototype,"roundingMode",2);customElements.define("qti-equal-rounded",Ut);var P=class{static compareSingleValues(t,e,r){switch(r){case"identifier":case"string":return t===e;case"integer":{let i=parseInt(t,10),o=parseInt(e,10);if(!isNaN(i)&&!isNaN(o))return i===o;console.error(`Cannot convert ${t} and/or ${e} to int.`);break}case"float":{let i=parseFloat(t),o=parseFloat(e);if(!isNaN(i)&&!isNaN(o))return i===o;console.error(`couldn't convert ${t} and/or ${e} to float.`);break}case"pair":case"directedPair":{let i=t.split(" ").sort(),o=e.split(" ").sort();if(i.length===2&&o.length===2)return r==="pair"&&(i.sort(),o.sort()),i.join(" ")===o.join(" ");console.error(`compared two pair but one of the values does not have 2 values: 1: ${t} 2: ${e}`);break}}return!1}};var Ft=class extends _{constructor(){super(...arguments);this.toleranceMode="exact"}getResult(){if(this.children.length===2){let e=this.getVariables(),r=e[0],i=e[1];return this.toleranceMode!=="exact"?(console.error("toleranceMode is not supported yet"),!1):r.cardinality!=="single"||i.cardinality!=="single"||Array.isArray(r.value)||Array.isArray(i.value)?(console.error("unexpected cardinality in qti equal"),!1):P.compareSingleValues(r.value,i.value,r.baseType)}return console.error("unexpected number of children in qti-equal"),null}};l([d({type:String})],Ft.prototype,"toleranceMode",2);customElements.define("qti-equal",Ft);var xr=class extends _{getResult(){if(this.children.length===2){let t=this.getVariables(),e=t[0],r=t[1];if(e.baseType===r.baseType&&(e.baseType==="integer"||e.baseType==="float"))return+e.value>+r.value;console.error("unexpected baseType or cardinality in qti gt")}return console.error("unexpected number of children in qt"),null}};customElements.define("qti-gt",xr);var Er=class extends N{getResult(){if(this.children.length===2){let t=this.getVariables(),e=t[0],r=t[1];return e.baseType===r.baseType&&(e.baseType==="integer"||e.baseType==="float")?+e.value>=+r.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",Er);var Cr=class extends _{getResult(){if(this.children.length===1){let t=this.getVariables();if(!t)return!0;let e=t[0].value;return e==null||e==null||e===""}return console.error("unexpected number of children in qti Null"),null}};customElements.define("qti-is-null",Cr);var _r=class extends _{getResult(){if(this.children.length===2){let t=this.getVariables(),e=t[0],r=t[1];if(e.baseType===r.baseType&&(e.baseType==="integer"||e.baseType==="float"))return+e.value<+r.value;console.error("unexpected baseType or cardinality in qti lt")}return console.error("unexpected number of children in lt"),null}};customElements.define("qti-lt",_r);var wr=class extends N{getResult(){if(this.children.length===2){let t=this.getVariables(),e=t[0],r=t[1];return e.baseType===r.baseType&&(e.baseType==="integer"||e.baseType==="float")?+e.value<=+r.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",wr);var Bt=class extends _{getResult(){let t=this.context.variables.find(o=>o.identifier===this.identifier);if(!t)return console.warn(`Response ${this.identifier} can not be found`),null;let e=t.mapping,r=Array.isArray(t.value)?t.value:[t.value],i=0;for(let o of r){let n=e.mapEntries.find(a=>P.compareSingleValues(a.mapKey,o,t.baseType));n==null||n.mappedValue==null?i+=e.defaultValue:i+=n.mappedValue}return e.lowerBound!=null&&(i=Math.max(e.lowerBound,i)),e.upperBound!=null&&(i=Math.min(e.upperBound,i)),i}};l([d({type:String})],Bt.prototype,"identifier",2);customElements.define("qti-map-response",Bt);var Re=class extends v{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")}))}};l([d({attribute:"default-value",type:Number})],Re.prototype,"defaultValue",2),l([d({attribute:"lower-bound",type:Number})],Re.prototype,"lowerBound",2),l([d({attribute:"upper-bound",type:Number})],Re.prototype,"upperBound",2);customElements.define("qti-mapping",Re);var qr=class s extends _{getResult(){if(this.children.length===2){let t=this.getVariables(),e=t[0],r=t[1];return s.match(e,r)}return console.error("unexpected number of children in match"),null}static match(t,e){var r;switch(e.cardinality){case"single":return t.value===null?!1:Array.isArray(t.value)||Array.isArray(e.value)?(console.error("unexpected cardinality in qti match"),!1):P.compareSingleValues((r=t.value)==null?void 0:r.toString(),e.value.toString(),e.baseType);case"ordered":{if(!Array.isArray(t.value)||!Array.isArray(e.value))return console.error("unexpected cardinality in qti match"),!1;if(t.value.length!==e.value.length)return!1;for(let i=0;i<t.value.length;i++)if(!P.compareSingleValues(e.value[i],t.value[i],e.baseType))return!1;return!0}case"multiple":{if(!Array.isArray(t.value)||!Array.isArray(e.value))return console.error("unexpected cardinality in qti match"),!1;if(t.value.length!==e.value.length)return!1;let i=0;for(let o of e.value){let n=null,a=[...t.value];for(let c of a)if(P.compareSingleValues(o,c,e.baseType)){n=c;break}if(n!==null)a.splice(a.indexOf(n),1);else return!1;i++}return!0}default:return console.error("unexpected cardinality in qti match"),!1}}};customElements.define("qti-match",qr);var Ar=class extends _{getResult(){let t=this.getVariables();this.children.length!==2&&console.warn("The member operator takes two sub-expressions");let[e,r]=t;if(e.baseType!==r.baseType&&console.warn("Which must both have the same base-type"),r.cardinality==="multiple"||r.cardinality==="ordered"||console.warn("and the second must be a multiple or ordered container"),(e.baseType==="float"||r.baseType==="float")&&console.warn("The member operator should not be used on sub-expressions with a base-type of float"),(e.baseType==="duration"||r.baseType==="duration")&&console.warn("It must not be used on sub-expressions with a base-type of duration"),e.value===null||r.value===null)return null;let i=e.value;return r.value.includes(i)}};customElements.define("qti-member",Ar);var Tr=class extends _{getResult(){let t=this.getVariables();if(t.length===0)return console.error("unexpected number of children in qti multiple"),null;for(let e of t)if(e.cardinality!=="multiple"&&e.cardinality!=="single")return console.error("unexpected cardinality in qti multiple"),[];return t}};customElements.define("qti-multiple",Tr);var Sr=class extends _{render(){return u`${super.render()}`}getResult(){return!this.firstElementChild.calculate()}};customElements.define("qti-not",Sr);var Mr=class extends N{getResult(){return Array.from(this.children).map(e=>{let r=e;if(!r.calculate)return console.error("Element doesn't implement QtiConditionExpression"),null;let i=r.calculate(),o=!1;if(typeof i=="string")if(i==="true")o=!0;else if(i==="false")o=!1;else return console.error("unexpected val in qti-or, expected boolean"),null;else typeof i=="boolean"&&(o=i);return o}).some(e=>typeof e=="boolean"&&e)}};customElements.define("qti-or",Mr);var $r=class extends _{getResult(){let t=this.getVariables();if(t.length===0)return console.error("unexpected number of children in qti multiple"),null;for(let e of t)if(e.cardinality!=="ordered"&&e.cardinality!=="single")return console.error("unexpected cardinality in qti ordered"),[];return t}};customElements.define("qti-ordered",$r);var nt=class extends v{render(){var e,r;let t=(r=(e=this.context)==null?void 0:e.variables.find(i=>i.identifier===this.identifier))==null?void 0:r.value;return u`${JSON.stringify(t,null,2)}`}calculate(){return this.context.variables.find(e=>e.identifier===this.identifier)||null}};l([d({type:String})],nt.prototype,"identifier",2),l([k({context:$,subscribe:!0}),E()],nt.prototype,"context",2);customElements.define("qti-printed-variable",nt);var Rr=class extends _{getResult(){return this.getVariables().reduce((r,i)=>{if(i.baseType=="float"||i.baseType=="integer")try{return r*parseInt(i.value.toString())}catch(o){console.warn("can not convert to number")}else console.warn(`has another baseType ${i.baseType}`);return r},1)}};customElements.define("qti-product",Rr);var Xt=class extends _{constructor(){super(...arguments);this.caseSensitive="true"}getResult(){if(this.children.length===2){let e=this.getVariables(),r=e[0],i=e[1];if(r.cardinality!=="single"||i.cardinality!=="single"||Array.isArray(r.value)||Array.isArray(i.value))return console.error("unexpected cardinality in qti string-match"),!1;let o=this.caseSensitive==="true"?r.value:r.value.toLowerCase(),n=this.caseSensitive==="true"?i.value:i.value.toLowerCase();return P.compareSingleValues(o,n,r.baseType)}return console.error("unexpected number of children in qti-string-match"),null}};l([d({type:String,attribute:"case-sensitive"})],Xt.prototype,"caseSensitive",2);customElements.define("qti-string-match",Xt);var kr=class extends _{constructor(){super(),this._expression=new Lr(Array.from(this.children))}getResult(){return this._expression.calculate()}},Lr=class{constructor(t){this.expressions=t}calculate(){return this.expressions.map(e=>{if(!e.calculate)return console.error("Element doesn't implement QtiConditionExpression"),null;let r=e.calculate();return Number.isNaN(r)?(console.error("unexpected value in qti-sum, expected number"),null):Number(r)}).reduce((e,r)=>e+r,0)}};customElements.define("qti-sum",kr);var Dr=class extends _{getResult(){let t=this.getAttribute("identifier");return this.context.variables.find(r=>r.identifier===t).value}};customElements.define("qti-variable",Dr);var ye=class extends x{constructor(){super(...arguments);this._errorMessage=null;this.loadConfig=async(e,r)=>{e=this.removeDoubleSlashes(e);try{let i=await fetch(e);if(i.ok){let n=await i.json();for(let a in n.paths)r&&(n.paths[a]=this.getResolvablePath(n.paths[a],r));return n}}catch(i){}return null};this.getResolvablePathString=(e,r)=>(e=e.replace(/\.js$/,""),e!=null&&e.toLocaleLowerCase().startsWith("http")||!r?e:this.removeDoubleSlashes(`${r}/${e}`));this.getResolvablePath=(e,r)=>Array.isArray(e)?e.map(i=>this.getResolvablePathString(i,r)):this.getResolvablePathString(e,r)}convertQtiVariableJSON(e){for(let r in e)if(e.hasOwnProperty(r)){let i=e[r];if(i){for(let o in i)if(i.hasOwnProperty(o)){let n=i[o];if(Array.isArray(n))return n.map(String);if(n!=null)return String(n)}}}return null}startChecking(){this.intervalId=setInterval(()=>{let e=this.pci.getResponse(),r=this.pci.getResponse(),i=JSON.stringify(e);if(i!==this.rawResponse){this.rawResponse=i;let o=this.convertQtiVariableJSON(r);this.value=o,this.saveResponse(o)}},200)}stopChecking(){this.intervalId!==void 0&&clearInterval(this.intervalId)}validate(){return!0}set value(e){}get value(){return this.rawResponse}getTAOConfig(e){let r=e.querySelectorAll("properties"),i={},o=a=>{let c={},p=a.getAttribute("key");if(p){let f=Array.from(a.children),m=f.map(b=>b.getAttribute("key"));m.length>0&&!m.find(b=>!Number.isInteger(+b))?c[p]=f.map(b=>n(b)):c[p]=a.textContent}return c},n=a=>{if(a){let c={};for(let p of a.children)c=q(q({},c),o(p));return c}};for(let a of r)return a.getAttribute("key")||(i=q(q({},i),n(a))),i;return console.log("Can not find qti-custom-interaction config"),null}register(e){this.pci=e;let r=this.parentElement.tagName==="QTI-CUSTOM-INTERACTION"?"TAO":"IMS",i=r=="IMS"?this.querySelector("qti-interaction-markup"):this.querySelector("markup");i.classList.add("qti-customInteraction"),r=="TAO"&&this.querySelector("properties")&&(this.querySelector("properties").style.display="none");let o=r=="IMS"?{properties:this.dataset,onready:()=>{console.log("onready")}}:this.getTAOConfig(this);r=="IMS"?e.getInstance(i,o,void 0):e.initialize(this.customInteractionTypeIdentifier,i.firstElementChild,o),r=="TAO"&&Array.from(this.querySelectorAll("link")).map(a=>a.getAttribute("href")).forEach(a=>{let c=document.createElement("link");c.rel="stylesheet",c.type="text/css",c.media="screen",c.href=a,i.appendChild(c)}),this.startChecking()}connectedCallback(){super.connectedCallback(),define("qtiCustomInteractionContext",()=>({register:i=>{this.register(i)},notifyReady:()=>{}}));let e=this.buildRequireConfig();requirejs.config(e)(["require"],i=>{i([this.module])})}disconnectedCallback(){super.disconnectedCallback(),requirejs.undef(this.customInteractionTypeIdentifier);let e=requirejs.s.contexts;delete e[this.customInteractionTypeIdentifier],this.stopChecking()}buildRequireConfig(){let e={context:this.customInteractionTypeIdentifier,catchError:!0,paths:window.requirePaths||{},shim:window.requireShim||{}};if(!globalThis.require)return this._errorMessage="RequireJS not found. Please load it via CDN: https://cdnjs.com/libraries/require.js",null;let r=this.getAttribute("data-base-url"),i=this.querySelector("qti-interaction-modules");if(i){let o=i.querySelectorAll("qti-interaction-module");for(let n of o){let a=n.getAttribute("id"),c=n.getAttribute("primary-path"),p=n.getAttribute("fallback-path");if(a&&c){let f=p?this.combineRequireResolvePaths(this.getResolvablePath(c,r),this.getResolvablePath(p,r)):this.getResolvablePath(c,r),m=e.paths[a]||[];e.paths[a]=this.combineRequireResolvePaths(m,f)}}}return e}combineRequireResolvePaths(e,r){let i=Array.isArray(e)?e:[e],o=Array.isArray(r)?r:[r];return i.concat(o)}removeDoubleSlashes(e){return e.replace(/([^:]\/)\/+/g,"$1").replace(/\/\//g,"/").replace("http:/","http://").replace("https:/","https://")}render(){return u`<slot></slot>${this._errorMessage&&u`<div style="color:red">
328
328
  <h1>Error</h1>
329
329
  ${this._errorMessage}
330
- </div>`}`}};l([d({type:String,attribute:"response-identifier"})],ce.prototype,"responseIdentifier",2),l([d({type:String,attribute:"module"})],ce.prototype,"module",2),l([d({type:String,attribute:"custom-interaction-type-identifier"})],ce.prototype,"customInteractionTypeIdentifier",2),l([E()],ce.prototype,"_errorMessage",2),ce=l([h("qti-portable-custom-interaction")],ce);var jt=class s{constructor(){this.touchStartTime=0;this.touchStartPoint=null;this.lastClickTime=0;this.isDraggable=!1;this.dragSource=null;this.dragClone=null;this.touchEndTriggered=!1;this.isDragging=!1;this.initialTransform="";this.hasDispatchedDragStart=!1;this.rootNode=null;this.focusedElement=null;this.focusableDropZones=[];this.currentDropZoneIndex=-1;this.dataTransfer={data:{},setData(t,e){this.data[t]=e},getData(t){return this.data[t]},effectAllowed:"move"};this.cloneOffset={x:0,y:0};this.lastTarget=null;this.currentDropTarget=null;this.allowClick=!0;this.copyStylesForDragClone=!0;this.dragOnClickEnabled=!1;this.useDragClone=!1;this.MIN_DRAG_DISTANCE=5;this.DRAG_CLONE_OPACITY=1;if(s.instance)return s.instance;s.instance=this,document.addEventListener("touchmove",this.handleTouchMove.bind(this),{passive:!1}),document.addEventListener("mousemove",this.handleTouchMove.bind(this),{passive:!1}),document.addEventListener("touchend",this.handleTouchEnd.bind(this),{passive:!1}),document.addEventListener("mouseup",this.handleTouchEnd.bind(this),{passive:!1}),document.addEventListener("touchcancel",this.handleTouchCancel.bind(this),{passive:!1}),document.addEventListener("keydown",this.handleKeyDown.bind(this)),document.addEventListener("keyup",this.handleKeyUp.bind(this))}addDraggableElements(t){t.forEach(e=>{e.setAttribute("tabindex","0"),e.addEventListener("focus",()=>this.focusedElement=e),e.addEventListener("blur",()=>this.focusedElement=null),e.addEventListener("touchstart",this.handleTouchStart.bind(this),{passive:!1}),e.addEventListener("mousedown",this.handleTouchStart.bind(this),{passive:!1})})}handleTouchStart(t){this.touchStartTime=Date.now();let{x:e,y:r}=this.getEventCoordinates(t);if(this.touchStartPoint={x:e,y:r},this.dragSource=t.currentTarget,this.isDraggable=!0,this.rootNode=this.dragSource.getRootNode(),this.dragOnClickEnabled&&(this.isDragging=!0,this.createDragClone(t,{clientX:e,clientY:r})),!this.useDragClone){let i=window.getComputedStyle(this.dragSource);this.initialTransform=i.transform==="none"?"":i.transform,this.initialTransition=i.transition||"",this.dragSource.style.transition="none";let o=this.dragSource.getBoundingClientRect();this.cloneOffset.x=e-o.left,this.cloneOffset.y=r-o.top,this.dragSource.style.zIndex="9999",this.dragSource.focus()}t.preventDefault()}handleTouchMove(t){if(this.isDraggable&&this.dragSource){let{x:e,y:r}=this.getEventCoordinates(t),i={clientX:e,clientY:r};this.calculateDragDistance(i)>=this.MIN_DRAG_DISTANCE&&(this.dragSource.style.pointerEvents="none",this.isDragging=!0),this.createDragClone(t,i),t.preventDefault()}}createDragClone(t,e){if(!this.isDragging)return;if(this.useDragClone){if(!this.dragClone){if(this.dragSource.style.opacity=this.DRAG_CLONE_OPACITY.toString(),this.dragClone=this.dragSource.cloneNode(!0),this.copyStylesForDragClone){let i=window.getComputedStyle(this.dragSource);for(let o of i)this.dragClone.style[o]=i.getPropertyValue(o)}this.rootNode instanceof ShadowRoot?this.rootNode.host.appendChild(this.dragClone):this.rootNode instanceof Document&&document.body.appendChild(this.dragClone),this.calculateClonePosition(e),this.setDragCloneStyles(e),this.dispatchCustomEvent(this.dragSource,"dragstart")}this.updateDragClonePosition(e)}else if(this.touchStartPoint){let i=e.clientX-this.touchStartPoint.x,o=e.clientY-this.touchStartPoint.y;this.dragSource.style.transform=`${this.initialTransform} translate(${i}px, ${o}px)`,this.hasDispatchedDragStart||(this.dispatchCustomEvent(this.dragSource,"dragstart"),this.hasDispatchedDragStart=!0)}let r=this.findDropTarget(t);r!==this.lastTarget&&(this.dispatchCustomEvent(r,"dragenter"),this.dispatchCustomEvent(this.lastTarget,"dragleave"),this.lastTarget=r),this.currentDropTarget=r,this.currentDropTarget&&this.dispatchCustomEvent(r,"dragover")}handleTouchEnd(t){var r;this.touchEndTriggered=!0,this.isDraggable=!1;let e=!1;if(this.currentDropTarget)this.dispatchCustomEvent(this.currentDropTarget,"drop"),this.dispatchCustomEvent(this.dragSource,"dragend"),e=!0;else if(this.isDragging){let i=new CustomEvent("dragend",{bubbles:!0,cancelable:!0});i.dataTransfer={dropEffect:"none"},(r=this.dragSource)==null||r.dispatchEvent(i)}this.resetDragState(e)}handleTouchCancel(t){this.resetDragState()}findDropTarget(t){let{x:e,y:r}=this.getEventCoordinates(t);return this.getDropTargetAtPoint(document,e,r)}getDropTargetAtPoint(t,e,r,i=0){if(i>2)return null;let n=t.elementFromPoint(e,r);if(!n)return null;if(n.hasAttribute("dropzone"))return n;let a=n.parentElement;for(;a;){if(a.hasAttribute("dropzone"))return a;a=a.parentElement}if(n.shadowRoot&&i<2){let c=this.getDropTargetAtPoint(n.shadowRoot,e,r,i+1);if(c)return c}return null}handleKeyDown(t){this.focusedElement&&(t.key===" "&&!this.isDragging?(t.preventDefault(),this.isDraggable=!0,this.dragSource=this.focusedElement,this.isDragging=!0,this.collectDropZones(),this.dispatchCustomEvent(this.dragSource,"dragstart")):t.key==="Tab"&&this.isDragging&&(t.preventDefault(),this.moveToNextDropZone()))}handleKeyUp(t){t.key===" "&&this.isDragging&&this.currentDropTarget&&(t.preventDefault(),this.dispatchCustomEvent(this.currentDropTarget,"drop"),this.dispatchCustomEvent(this.dragSource,"dragend"),this.resetDragState(!0))}collectDropZones(){this.focusableDropZones=Array.from(document.querySelectorAll("[dropzone]")),this.currentDropZoneIndex=-1}moveToNextDropZone(){if(this.focusableDropZones.length===0)return;this.currentDropZoneIndex=(this.currentDropZoneIndex+1)%this.focusableDropZones.length;let t=this.focusableDropZones[this.currentDropZoneIndex];t.focus(),this.currentDropTarget=t,this.dispatchCustomEvent(t,"dragenter")}getEventCoordinates(t,e=!1){let r=t.touches?t.touches[0]:t;return{x:e?r.pageX:r.clientX,y:e?r.pageY:r.clientY}}calculateClonePosition(t){let e=this.dragSource.getBoundingClientRect();this.cloneOffset.x=t.clientX-e.left,this.cloneOffset.y=t.clientY-e.top}setDragCloneStyles(t){this.dragClone.style.position="fixed",this.dragClone.style.top=`${t.clientY-this.cloneOffset.y}px`,this.dragClone.style.left=`${t.clientX-this.cloneOffset.x}px`,this.dragClone.style.pointerEvents="none",this.dragClone.style.zIndex="999999"}updateDragClonePosition(t){requestAnimationFrame(()=>{if(this.touchEndTriggered||!this.dragClone)return;let e=t.clientX-this.cloneOffset.x,r=t.clientY-this.cloneOffset.y,{newLeft:i,newTop:o}=this.applyBoundaries(e,r,this.dragClone);this.dragClone.style.left=`${i}px`,this.dragClone.style.top=`${o}px`})}applyTransformBoundaries(t,e){let r;this.rootNode instanceof ShadowRoot?r=this.rootNode.host.getBoundingClientRect():this.rootNode instanceof Document?r=document.documentElement.getBoundingClientRect():r=new DOMRect(0,0,window.innerWidth,window.innerHeight);let i=this.dragSource.getBoundingClientRect(),o=i.width,n=i.height,a=i.left+t,c=i.top+e,p=Math.max(r.left,Math.min(a,r.right-o)),f=Math.max(r.top,Math.min(c,r.bottom-n)),m=p-i.left,y=f-i.top;return{boundedDeltaX:m,boundedDeltaY:y}}applyBoundaries(t,e,r){let i;this.rootNode instanceof ShadowRoot?i=this.rootNode.host.getBoundingClientRect():this.rootNode instanceof Document?i=document.documentElement.getBoundingClientRect():i=new DOMRect(0,0,window.innerWidth,window.innerHeight);let o=r.getBoundingClientRect(),n=o.width,a=o.height,c=Math.max(i.left,Math.min(t,i.right-n)),p=Math.max(i.top,Math.min(e,i.bottom-a));return{newLeft:c,newTop:p}}calculateDragDistance(t){let e=Math.abs(t.clientX-this.touchStartPoint.x),r=Math.abs(t.clientY-this.touchStartPoint.y);return e+r}dispatchCustomEvent(t,e,r=!0){if(!t)return;let i=new CustomEvent(e,{bubbles:r,cancelable:!0});i.dataTransfer=this.dataTransfer,t.dispatchEvent(i)}resetDragState(t=!1){var e;this.isDragging&&(this.useDragClone?(this.dragSource.style.opacity="1.0",(e=this.dragClone)==null||e.parentElement.removeChild(this.dragClone)):(t||(this.dragSource.style.transform="translate(0, 0)"),this.dragSource.style.zIndex="",this.dragSource.style.pointerEvents="",this.dragSource.style.transition=this.initialTransition,this.initialTransition="")),this.isDragging=!1,this.dragSource=null,this.dragClone=null,this.isDraggable=!1,this.touchStartTime=0,this.touchStartPoint=null,this.touchEndTriggered=!1,this.dataTransfer={data:{},setData(r,i){this.data[r]=i},getData(r){return this.data[r]},effectAllowed:"move"},this.cloneOffset={x:0,y:0},this.lastTarget=null,this.currentDropTarget=null,this.allowClick=!0,this.initialTransform="",this.hasDispatchedDragStart=!1,this.rootNode=null}};var Vi=(s,t,e)=>{class r extends s{constructor(){super(...arguments);this.disabled=!1}firstUpdated(n){if(this.isMatchTabular())return;super.firstUpdated(n);let a=this.getDroppableElements();this.initializeEventHandlers(),a.forEach(c=>{this.prepareDroppable(c),this.observeDroppableAttributes(c)})}isMatchTabular(){return this.classList.contains("qti-match-tabular")}getDroppableElements(){return Array.from(t?this.shadowRoot.querySelectorAll(e):this.querySelectorAll(e))}initializeEventHandlers(){this.dragoverHandler=this.dragoverHandler.bind(this),this.dragleaveHandler=this.dragleaveHandler.bind(this),this.dragenterHandler=this.dragenterHandler.bind(this),this.dropHandler=this.dropHandler.bind(this)}prepareDroppable(n){n.setAttribute("dropzone","move"),n.addEventListener("dragleave",this.dragleaveHandler),this.attachEventListeners(n)}observeDroppableAttributes(n){this.observer=new MutationObserver(a=>{a.forEach(({attributeName:c})=>{c==="disabled"&&this.toggleDroppableHandlers(n)})}),this.observer.observe(n,{attributes:!0})}toggleDroppableHandlers(n){n.hasAttribute("disabled")?this.removeEventListeners(n):this.attachEventListeners(n)}attachEventListeners(n){n.addEventListener("dragover",this.dragoverHandler),n.addEventListener("dragenter",this.dragenterHandler),n.addEventListener("drop",this.dropHandler)}removeEventListeners(n){n.removeEventListener("dragover",this.dragoverHandler),n.removeEventListener("dragenter",this.dragenterHandler),n.removeEventListener("drop",this.dropHandler)}disconnectedCallback(){var n;this.isMatchTabular()||(super.disconnectedCallback(),(n=this.observer)==null||n.disconnect())}dragenterHandler(n){n.preventDefault()}dragoverHandler(n){return n.preventDefault(),this.activateDroppable(n.currentTarget),n.dataTransfer.dropEffect="move",!1}activateDroppable(n){n.setAttribute("active","")}async dropHandler(n){n.preventDefault();let a=n.currentTarget,c=n.dataTransfer.getData("text"),p=this.findDraggable(c);return p?p&&!this.isValidDrop(a,p)?(p.style.transform="translate(0, 0)",!1):(await this.moveDraggableToDroppable(p,a),this.deactivateDroppable(a),!1):!1}findDraggable(n){return n?this.querySelector(`[identifier=${n}]`)||this.shadowRoot.querySelector(`[identifier=${n}]`):null}isValidDrop(n,a){return a.parentElement.getAttribute("identifier")!==n.getAttribute("identifier")}async moveDraggableToDroppable(n,a){let c=()=>{n.style.transform="translate(0, 0)",a.appendChild(n),this.checkMaxAssociations(),this.saveResponse(null)};if(!document.startViewTransition){c();return}await document.startViewTransition(c).finished}deactivateDroppable(n){n.removeAttribute("active")}dragleaveHandler(n){return n.preventDefault(),this.deactivateDroppable(n.currentTarget),n.dataTransfer.dropEffect="none",!1}}return l([d({type:Boolean,reflect:!0})],r.prototype,"disabled",2),r};var Ni=(s,t,e)=>{class r extends s{}return r};function Pi(s,t){let e,r=q({},t);return(i,o)=>{let{connectedCallback:n,disconnectedCallback:a}=i;i.connectedCallback=function(){var f;n.call(this);let c=m=>{let y=Array.from(this.querySelectorAll(s));for(let b of m){let C=Array.from(b.addedNodes).map(T=>T),A=Array.from(b.addedNodes).map(T=>T);b.type==="childList"&&C.find(T=>y.includes(T))&&this[o](C,A)}};e=new MutationObserver(c),e.observe(this,{childList:!0,subtree:!0});let p=(f=this.querySelectorAll(s))!=null?f:[];this[o](Array.from(p),[])},i.disconnectedCallback=function(){a.call(this),e.disconnect()}}}var z=(s,t,e,r)=>{class i extends Ni(Vi(s,e,r),r,t){constructor(){super(...arguments);this.draggables=new Map;this.droppables=[];this.configuration={copyStylesDragClone:!0,dragCanBePlacedBack:!0,dragOnClick:!1};this.minAssociations=1;this.maxAssociations=1;this.handleDragStart=a=>{let c=a.currentTarget;a.dataTransfer.setData("text",c.getAttribute("identifier")),c.setAttribute("dragging",""),this.activateDroppables()};this.handleDragEnd=async a=>{a.preventDefault(),this.deactivateDroppables();let c=a.currentTarget;c.removeAttribute("dragging"),await this.wasDropped(a)||this.configuration.dragCanBePlacedBack&&this.restoreInitialDraggablePosition(c)};this.checkForMoveTestItem=a=>a.dataTransfer.items?new Promise(c=>{let p=!1,f=Array.from(a.dataTransfer.items),m=f.length;if(m===0){c(!1);return}f.forEach(y=>{y.kind==="string"&&y.type==="text"?y.getAsString(b=>{b==="move-test"&&(p=!0),m===0&&c(p)}):m===0&&c(p)})}):Promise.resolve(!1)}handleDraggablesChange(a,c){if(this.isMatchTabular())return;let p=this.filterExistingDraggables(a);p.length>0&&this.addNewDraggables(p)}firstUpdated(a){super.firstUpdated(a),this.initializeDroppables()}connectedCallback(){super.connectedCallback(),this.initializeDragDropApi()}initializeDragDropApi(){this.dragDropApi=new jt,this.dispatchEvent(new CustomEvent("qti-register-interaction",{bubbles:!0,composed:!0,detail:this}))}isMatchTabular(){return this.classList.contains("qti-match-tabular")}filterExistingDraggables(a){return a.filter(c=>!this.draggables.has(c))}addNewDraggables(a){this.dragDropApi.addDraggableElements(a),a.forEach(c=>this.storeDraggable(c))}storeDraggable(a){let c=Array.from(a.parentNode.children).indexOf(a);this.draggables.set(a,{parent:a.parentElement,index:c}),a.style.viewTransitionName=`drag-${c}-${this.getAttribute("identifier")||crypto.randomUUID()}`,a.setAttribute("qti-draggable","true"),a.addEventListener("dragstart",this.handleDragStart),a.addEventListener("dragend",this.handleDragEnd)}initializeDroppables(){this.droppables=Array.from(e?this.shadowRoot.querySelectorAll(r):this.querySelectorAll(r))}activateDroppables(){this.droppables.forEach(a=>a.setAttribute("enabled",""))}deactivateDroppables(){this.droppables.forEach(a=>a.removeAttribute("enabled"))}async wasDropped(a){let c=await this.checkForMoveTestItem(a);return a.dataTransfer.dropEffect!=="none"||c}wasMoved(a){return a.dataTransfer.dropEffect==="move"}async restoreInitialDraggablePosition(a){let{parent:c,index:p}=this.draggables.get(a),f=Math.min(p,c.children.length),m=(b,C,A)=>{let T=Math.min(A,C.children.length);C.insertBefore(b,C.children[T]),b.style.transform="translate(0, 0)",this.checkMaxAssociations()};if(!document.startViewTransition){m(a,c,p);return}let y=document.startViewTransition(()=>{a.style.transform="",m(a,c,p)})}checkMaxAssociations(){this.droppables.forEach((a,c)=>{let p=+(a.getAttribute("match-max")||1);a.querySelectorAll('[qti-draggable="true"]').length>=p?this.disableDroppable(a):this.enableDroppable(a)})}disableDroppable(a){a.setAttribute("disabled",""),a.removeAttribute("dropzone")}enableDroppable(a){a.removeAttribute("disabled"),a.setAttribute("dropzone","move")}get value(){return this.collectResponseData()}set value(a){this.isMatchTabular()||(this.resetDroppables(),a==null||a.forEach(c=>this.placeResponse(c)))}placeResponse(a){let[c,...p]=a.split(" ").reverse(),f=this.findDroppableById(c);p.forEach(m=>this.placeDraggableInDroppable(m,f))}findDroppableById(a){return this.droppables.find(c=>c.getAttribute("identifier")===a)}async placeDraggableInDroppable(a,c){let p=this.querySelector(`[identifier=${a}]`);if(!c||!p){console.error(`Cannot find draggable or droppable with the given identifier: ${a}`);return}let f=()=>{p.style.transform="translate(0, 0)",c.appendChild(p),this.checkMaxAssociations()};document.startViewTransition?await document.startViewTransition(f).finished:f()}validate(){let a=this.getValidAssociations();return this.minAssociations<=0||this.minAssociations<=a}getValidAssociations(){return this.droppables.filter(a=>a.childElementCount>0).length}saveResponse(){let a=this.collectResponseData();this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,composed:!0,detail:{responseIdentifier:this.responseIdentifier,response:a}}))}collectResponseData(){return this.droppables.map(c=>{let p=c.querySelectorAll('[qti-draggable="true"]'),f=Array.from(p).map(y=>y.getAttribute("identifier")),m=c.getAttribute("identifier");return f.map(y=>`${y} ${m}`)}).flat()}reset(a=!0){this.resetDroppables(),a&&this.saveResponse()}async resetDroppables(){let a=(p,f,m)=>{p.style.transform="translate(0, 0)";let y=Math.min(m,f.children.length);f.insertBefore(p,f.children[y])};if(!document.startViewTransition){this.draggables.forEach(({parent:p,index:f},m)=>{a(m,p,f)});return}await document.startViewTransition(()=>{this.draggables.forEach(({parent:p,index:f},m)=>{a(m,p,f)})}).finished}}return l([d({attribute:!1,type:Object})],i.prototype,"configuration",2),l([d({type:Number,reflect:!0,attribute:"min-associations"})],i.prototype,"minAssociations",2),l([d({type:Number,reflect:!0,attribute:"max-associations"})],i.prototype,"maxAssociations",2),l([Pi(t)],i.prototype,"handleDraggablesChange",1),i};var Ii=g`
330
+ </div>`}`}};l([d({type:String,attribute:"module"})],ye.prototype,"module",2),l([d({type:String,attribute:"custom-interaction-type-identifier"})],ye.prototype,"customInteractionTypeIdentifier",2),l([E()],ye.prototype,"_errorMessage",2),ye=l([h("qti-portable-custom-interaction")],ye);var jt=class s{constructor(){this.touchStartTime=0;this.touchStartPoint=null;this.lastClickTime=0;this.isDraggable=!1;this.dragSource=null;this.dragClone=null;this.touchEndTriggered=!1;this.isDragging=!1;this.initialTransform="";this.hasDispatchedDragStart=!1;this.rootNode=null;this.focusedElement=null;this.focusableDropZones=[];this.currentDropZoneIndex=-1;this.dataTransfer={data:{},setData(t,e){this.data[t]=e},getData(t){return this.data[t]},effectAllowed:"move"};this.cloneOffset={x:0,y:0};this.lastTarget=null;this.currentDropTarget=null;this.allowClick=!0;this.copyStylesForDragClone=!0;this.dragOnClickEnabled=!1;this.useDragClone=!1;this.MIN_DRAG_DISTANCE=5;this.DRAG_CLONE_OPACITY=1;if(s.instance)return s.instance;s.instance=this,document.addEventListener("touchmove",this.handleTouchMove.bind(this),{passive:!1}),document.addEventListener("mousemove",this.handleTouchMove.bind(this),{passive:!1}),document.addEventListener("touchend",this.handleTouchEnd.bind(this),{passive:!1}),document.addEventListener("mouseup",this.handleTouchEnd.bind(this),{passive:!1}),document.addEventListener("touchcancel",this.handleTouchCancel.bind(this),{passive:!1}),document.addEventListener("keydown",this.handleKeyDown.bind(this)),document.addEventListener("keyup",this.handleKeyUp.bind(this))}addDraggableElements(t){t.forEach(e=>{e.setAttribute("tabindex","0"),e.addEventListener("focus",()=>this.focusedElement=e),e.addEventListener("blur",()=>this.focusedElement=null),e.addEventListener("touchstart",this.handleTouchStart.bind(this),{passive:!1}),e.addEventListener("mousedown",this.handleTouchStart.bind(this),{passive:!1})})}handleTouchStart(t){this.touchStartTime=Date.now();let{x:e,y:r}=this.getEventCoordinates(t);if(this.touchStartPoint={x:e,y:r},this.dragSource=t.currentTarget,this.isDraggable=!0,this.rootNode=this.dragSource.getRootNode(),this.dragOnClickEnabled&&(this.isDragging=!0,this.createDragClone(t,{clientX:e,clientY:r})),!this.useDragClone){let i=window.getComputedStyle(this.dragSource);this.initialTransform=i.transform==="none"?"":i.transform,this.initialTransition=i.transition||"",this.dragSource.style.transition="none";let o=this.dragSource.getBoundingClientRect();this.cloneOffset.x=e-o.left,this.cloneOffset.y=r-o.top,this.dragSource.style.zIndex="9999",this.dragSource.focus()}t.preventDefault()}handleTouchMove(t){if(this.isDraggable&&this.dragSource){let{x:e,y:r}=this.getEventCoordinates(t),i={clientX:e,clientY:r};this.calculateDragDistance(i)>=this.MIN_DRAG_DISTANCE&&(this.dragSource.style.pointerEvents="none",this.isDragging=!0),this.createDragClone(t,i),t.preventDefault()}}createDragClone(t,e){if(!this.isDragging)return;if(this.useDragClone){if(!this.dragClone){if(this.dragSource.style.opacity=this.DRAG_CLONE_OPACITY.toString(),this.dragClone=this.dragSource.cloneNode(!0),this.copyStylesForDragClone){let i=window.getComputedStyle(this.dragSource);for(let o of i)this.dragClone.style[o]=i.getPropertyValue(o)}this.rootNode instanceof ShadowRoot?this.rootNode.host.appendChild(this.dragClone):this.rootNode instanceof Document&&document.body.appendChild(this.dragClone),this.calculateClonePosition(e),this.setDragCloneStyles(e),this.dispatchCustomEvent(this.dragSource,"dragstart")}this.updateDragClonePosition(e)}else if(this.touchStartPoint){let i=e.clientX-this.touchStartPoint.x,o=e.clientY-this.touchStartPoint.y;this.dragSource.style.transform=`${this.initialTransform} translate(${i}px, ${o}px)`,this.hasDispatchedDragStart||(this.dispatchCustomEvent(this.dragSource,"dragstart"),this.hasDispatchedDragStart=!0)}let r=this.findDropTarget(t);r!==this.lastTarget&&(this.dispatchCustomEvent(r,"dragenter"),this.dispatchCustomEvent(this.lastTarget,"dragleave"),this.lastTarget=r),this.currentDropTarget=r,this.currentDropTarget&&this.dispatchCustomEvent(r,"dragover")}handleTouchEnd(t){var r;this.touchEndTriggered=!0,this.isDraggable=!1;let e=!1;if(this.currentDropTarget)this.dispatchCustomEvent(this.currentDropTarget,"drop"),this.dispatchCustomEvent(this.dragSource,"dragend"),e=!0;else if(this.isDragging){let i=new CustomEvent("dragend",{bubbles:!0,cancelable:!0});i.dataTransfer={dropEffect:"none"},(r=this.dragSource)==null||r.dispatchEvent(i)}this.resetDragState(e)}handleTouchCancel(t){this.resetDragState()}findDropTarget(t){let{x:e,y:r}=this.getEventCoordinates(t);return this.getDropTargetAtPoint(document,e,r)}getDropTargetAtPoint(t,e,r,i=0){if(i>2)return null;let n=t.elementFromPoint(e,r);if(!n)return null;if(n.hasAttribute("dropzone"))return n;let a=n.parentElement;for(;a;){if(a.hasAttribute("dropzone"))return a;a=a.parentElement}if(n.shadowRoot&&i<2){let c=this.getDropTargetAtPoint(n.shadowRoot,e,r,i+1);if(c)return c}return null}handleKeyDown(t){this.focusedElement&&(t.key===" "&&!this.isDragging?(t.preventDefault(),this.isDraggable=!0,this.dragSource=this.focusedElement,this.isDragging=!0,this.collectDropZones(),this.dispatchCustomEvent(this.dragSource,"dragstart")):t.key==="Tab"&&this.isDragging&&(t.preventDefault(),this.moveToNextDropZone()))}handleKeyUp(t){t.key===" "&&this.isDragging&&this.currentDropTarget&&(t.preventDefault(),this.dispatchCustomEvent(this.currentDropTarget,"drop"),this.dispatchCustomEvent(this.dragSource,"dragend"),this.resetDragState(!0))}collectDropZones(){this.focusableDropZones=Array.from(document.querySelectorAll("[dropzone]")),this.currentDropZoneIndex=-1}moveToNextDropZone(){if(this.focusableDropZones.length===0)return;this.currentDropZoneIndex=(this.currentDropZoneIndex+1)%this.focusableDropZones.length;let t=this.focusableDropZones[this.currentDropZoneIndex];t.focus(),this.currentDropTarget=t,this.dispatchCustomEvent(t,"dragenter")}getEventCoordinates(t,e=!1){let r=t.touches?t.touches[0]:t;return{x:e?r.pageX:r.clientX,y:e?r.pageY:r.clientY}}calculateClonePosition(t){let e=this.dragSource.getBoundingClientRect();this.cloneOffset.x=t.clientX-e.left,this.cloneOffset.y=t.clientY-e.top}setDragCloneStyles(t){this.dragClone.style.position="fixed",this.dragClone.style.top=`${t.clientY-this.cloneOffset.y}px`,this.dragClone.style.left=`${t.clientX-this.cloneOffset.x}px`,this.dragClone.style.pointerEvents="none",this.dragClone.style.zIndex="999999"}updateDragClonePosition(t){requestAnimationFrame(()=>{if(this.touchEndTriggered||!this.dragClone)return;let e=t.clientX-this.cloneOffset.x,r=t.clientY-this.cloneOffset.y,{newLeft:i,newTop:o}=this.applyBoundaries(e,r,this.dragClone);this.dragClone.style.left=`${i}px`,this.dragClone.style.top=`${o}px`})}applyTransformBoundaries(t,e){let r;this.rootNode instanceof ShadowRoot?r=this.rootNode.host.getBoundingClientRect():this.rootNode instanceof Document?r=document.documentElement.getBoundingClientRect():r=new DOMRect(0,0,window.innerWidth,window.innerHeight);let i=this.dragSource.getBoundingClientRect(),o=i.width,n=i.height,a=i.left+t,c=i.top+e,p=Math.max(r.left,Math.min(a,r.right-o)),f=Math.max(r.top,Math.min(c,r.bottom-n)),m=p-i.left,y=f-i.top;return{boundedDeltaX:m,boundedDeltaY:y}}applyBoundaries(t,e,r){let i;this.rootNode instanceof ShadowRoot?i=this.rootNode.host.getBoundingClientRect():this.rootNode instanceof Document?i=document.documentElement.getBoundingClientRect():i=new DOMRect(0,0,window.innerWidth,window.innerHeight);let o=r.getBoundingClientRect(),n=o.width,a=o.height,c=Math.max(i.left,Math.min(t,i.right-n)),p=Math.max(i.top,Math.min(e,i.bottom-a));return{newLeft:c,newTop:p}}calculateDragDistance(t){let e=Math.abs(t.clientX-this.touchStartPoint.x),r=Math.abs(t.clientY-this.touchStartPoint.y);return e+r}dispatchCustomEvent(t,e,r=!0){if(!t)return;let i=new CustomEvent(e,{bubbles:r,cancelable:!0});i.dataTransfer=this.dataTransfer,t.dispatchEvent(i)}resetDragState(t=!1){var e;this.isDragging&&(this.useDragClone?(this.dragSource.style.opacity="1.0",(e=this.dragClone)==null||e.parentElement.removeChild(this.dragClone)):(t||(this.dragSource.style.transform="translate(0, 0)"),this.dragSource.style.zIndex="",this.dragSource.style.pointerEvents="",this.dragSource.style.transition=this.initialTransition,this.initialTransition="")),this.isDragging=!1,this.dragSource=null,this.dragClone=null,this.isDraggable=!1,this.touchStartTime=0,this.touchStartPoint=null,this.touchEndTriggered=!1,this.dataTransfer={data:{},setData(r,i){this.data[r]=i},getData(r){return this.data[r]},effectAllowed:"move"},this.cloneOffset={x:0,y:0},this.lastTarget=null,this.currentDropTarget=null,this.allowClick=!0,this.initialTransform="",this.hasDispatchedDragStart=!1,this.rootNode=null}};var Vi=(s,t,e)=>{class r extends s{constructor(){super(...arguments);this.disabled=!1}firstUpdated(n){if(this.isMatchTabular())return;super.firstUpdated(n);let a=this.getDroppableElements();this.initializeEventHandlers(),a.forEach(c=>{this.prepareDroppable(c),this.observeDroppableAttributes(c)})}isMatchTabular(){return this.classList.contains("qti-match-tabular")}getDroppableElements(){return Array.from(t?this.shadowRoot.querySelectorAll(e):this.querySelectorAll(e))}initializeEventHandlers(){this.dragoverHandler=this.dragoverHandler.bind(this),this.dragleaveHandler=this.dragleaveHandler.bind(this),this.dragenterHandler=this.dragenterHandler.bind(this),this.dropHandler=this.dropHandler.bind(this)}prepareDroppable(n){n.setAttribute("dropzone","move"),n.addEventListener("dragleave",this.dragleaveHandler),this.attachEventListeners(n)}observeDroppableAttributes(n){this.observer=new MutationObserver(a=>{a.forEach(({attributeName:c})=>{c==="disabled"&&this.toggleDroppableHandlers(n)})}),this.observer.observe(n,{attributes:!0})}toggleDroppableHandlers(n){n.hasAttribute("disabled")?this.removeEventListeners(n):this.attachEventListeners(n)}attachEventListeners(n){n.addEventListener("dragover",this.dragoverHandler),n.addEventListener("dragenter",this.dragenterHandler),n.addEventListener("drop",this.dropHandler)}removeEventListeners(n){n.removeEventListener("dragover",this.dragoverHandler),n.removeEventListener("dragenter",this.dragenterHandler),n.removeEventListener("drop",this.dropHandler)}disconnectedCallback(){var n;this.isMatchTabular()||(super.disconnectedCallback(),(n=this.observer)==null||n.disconnect())}dragenterHandler(n){n.preventDefault()}dragoverHandler(n){return n.preventDefault(),this.activateDroppable(n.currentTarget),n.dataTransfer.dropEffect="move",!1}activateDroppable(n){n.setAttribute("active","")}async dropHandler(n){n.preventDefault();let a=n.currentTarget,c=n.dataTransfer.getData("text"),p=this.findDraggable(c);return p?p&&!this.isValidDrop(a,p)?(p.style.transform="translate(0, 0)",!1):(await this.moveDraggableToDroppable(p,a),this.deactivateDroppable(a),!1):!1}findDraggable(n){return n?this.querySelector(`[identifier=${n}]`)||this.shadowRoot.querySelector(`[identifier=${n}]`):null}isValidDrop(n,a){return a.parentElement.getAttribute("identifier")!==n.getAttribute("identifier")}async moveDraggableToDroppable(n,a){let c=()=>{n.style.transform="translate(0, 0)",a.appendChild(n),this.checkMaxAssociations(),this.saveResponse(null)};if(!document.startViewTransition){c();return}await document.startViewTransition(c).finished}deactivateDroppable(n){n.removeAttribute("active")}dragleaveHandler(n){return n.preventDefault(),this.deactivateDroppable(n.currentTarget),n.dataTransfer.dropEffect="none",!1}}return l([d({type:Boolean,reflect:!0})],r.prototype,"disabled",2),r};var Ni=(s,t,e)=>{class r extends s{}return r};function Pi(s,t){let e,r=q({},t);return(i,o)=>{let{connectedCallback:n,disconnectedCallback:a}=i;i.connectedCallback=function(){var f;n.call(this);let c=m=>{let y=Array.from(this.querySelectorAll(s));for(let b of m){let C=Array.from(b.addedNodes).map(T=>T),A=Array.from(b.addedNodes).map(T=>T);b.type==="childList"&&C.find(T=>y.includes(T))&&this[o](C,A)}};e=new MutationObserver(c),e.observe(this,{childList:!0,subtree:!0});let p=(f=this.querySelectorAll(s))!=null?f:[];this[o](Array.from(p),[])},i.disconnectedCallback=function(){a.call(this),e.disconnect()}}}var z=(s,t,e,r)=>{class i extends Ni(Vi(s,e,r),r,t){constructor(){super(...arguments);this.draggables=new Map;this.droppables=[];this.configuration={copyStylesDragClone:!0,dragCanBePlacedBack:!0,dragOnClick:!1};this.minAssociations=1;this.maxAssociations=1;this.handleDragStart=a=>{let c=a.currentTarget;a.dataTransfer.setData("text",c.getAttribute("identifier")),c.setAttribute("dragging",""),this.activateDroppables()};this.handleDragEnd=async a=>{a.preventDefault(),this.deactivateDroppables();let c=a.currentTarget;c.removeAttribute("dragging"),await this.wasDropped(a)||this.configuration.dragCanBePlacedBack&&this.restoreInitialDraggablePosition(c)};this.checkForMoveTestItem=a=>a.dataTransfer.items?new Promise(c=>{let p=!1,f=Array.from(a.dataTransfer.items),m=f.length;if(m===0){c(!1);return}f.forEach(y=>{y.kind==="string"&&y.type==="text"?y.getAsString(b=>{b==="move-test"&&(p=!0),m===0&&c(p)}):m===0&&c(p)})}):Promise.resolve(!1)}handleDraggablesChange(a,c){if(this.isMatchTabular())return;let p=this.filterExistingDraggables(a);p.length>0&&this.addNewDraggables(p)}firstUpdated(a){super.firstUpdated(a),this.initializeDroppables()}connectedCallback(){super.connectedCallback(),this.initializeDragDropApi()}initializeDragDropApi(){this.dragDropApi=new jt,this.dispatchEvent(new CustomEvent("qti-register-interaction",{bubbles:!0,composed:!0,detail:this}))}isMatchTabular(){return this.classList.contains("qti-match-tabular")}filterExistingDraggables(a){return a.filter(c=>!this.draggables.has(c))}addNewDraggables(a){this.dragDropApi.addDraggableElements(a),a.forEach(c=>this.storeDraggable(c))}storeDraggable(a){let c=Array.from(a.parentNode.children).indexOf(a);this.draggables.set(a,{parent:a.parentElement,index:c}),a.style.viewTransitionName=`drag-${c}-${this.getAttribute("identifier")||crypto.randomUUID()}`,a.setAttribute("qti-draggable","true"),a.addEventListener("dragstart",this.handleDragStart),a.addEventListener("dragend",this.handleDragEnd)}initializeDroppables(){this.droppables=Array.from(e?this.shadowRoot.querySelectorAll(r):this.querySelectorAll(r))}activateDroppables(){this.droppables.forEach(a=>a.setAttribute("enabled",""))}deactivateDroppables(){this.droppables.forEach(a=>a.removeAttribute("enabled"))}async wasDropped(a){let c=await this.checkForMoveTestItem(a);return a.dataTransfer.dropEffect!=="none"||c}wasMoved(a){return a.dataTransfer.dropEffect==="move"}async restoreInitialDraggablePosition(a){let{parent:c,index:p}=this.draggables.get(a),f=Math.min(p,c.children.length),m=(b,C,A)=>{let T=Math.min(A,C.children.length);C.insertBefore(b,C.children[T]),b.style.transform="translate(0, 0)",this.checkMaxAssociations()};if(!document.startViewTransition){m(a,c,p);return}let y=document.startViewTransition(()=>{a.style.transform="",m(a,c,p)})}checkMaxAssociations(){this.droppables.forEach((a,c)=>{let p=+(a.getAttribute("match-max")||1);a.querySelectorAll('[qti-draggable="true"]').length>=p?this.disableDroppable(a):this.enableDroppable(a)})}disableDroppable(a){a.setAttribute("disabled",""),a.removeAttribute("dropzone")}enableDroppable(a){a.removeAttribute("disabled"),a.setAttribute("dropzone","move")}get value(){return this.collectResponseData()}set value(a){this.isMatchTabular()||(this.resetDroppables(),a==null||a.forEach(c=>this.placeResponse(c)))}placeResponse(a){let[c,...p]=a.split(" ").reverse(),f=this.findDroppableById(c);p.forEach(m=>this.placeDraggableInDroppable(m,f))}findDroppableById(a){return this.droppables.find(c=>c.getAttribute("identifier")===a)}async placeDraggableInDroppable(a,c){let p=this.querySelector(`[identifier=${a}]`);if(!c||!p){console.error(`Cannot find draggable or droppable with the given identifier: ${a}`);return}let f=()=>{p.style.transform="translate(0, 0)",c.appendChild(p),this.checkMaxAssociations()};document.startViewTransition?await document.startViewTransition(f).finished:f()}validate(){let a=this.getValidAssociations();return this.minAssociations<=0||this.minAssociations<=a}getValidAssociations(){return this.droppables.filter(a=>a.childElementCount>0).length}saveResponse(){let a=this.collectResponseData();this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,composed:!0,detail:{responseIdentifier:this.responseIdentifier,response:a}}))}collectResponseData(){return this.droppables.map(c=>{let p=c.querySelectorAll('[qti-draggable="true"]'),f=Array.from(p).map(y=>y.getAttribute("identifier")),m=c.getAttribute("identifier");return f.map(y=>`${y} ${m}`)}).flat()}reset(a=!0){this.resetDroppables(),a&&this.saveResponse()}async resetDroppables(){let a=(p,f,m)=>{p.style.transform="translate(0, 0)";let y=Math.min(m,f.children.length);f.insertBefore(p,f.children[y])};if(!document.startViewTransition){this.draggables.forEach(({parent:p,index:f},m)=>{a(m,p,f)});return}await document.startViewTransition(()=>{this.draggables.forEach(({parent:p,index:f},m)=>{a(m,p,f)})}).finished}}return l([d({attribute:!1,type:Object})],i.prototype,"configuration",2),l([d({type:Number,reflect:!0,attribute:"min-associations"})],i.prototype,"minAssociations",2),l([d({type:Number,reflect:!0,attribute:"max-associations"})],i.prototype,"maxAssociations",2),l([Pi(t)],i.prototype,"handleDraggablesChange",1),i};var Ii=g`
331
331
  :host {
332
332
  display: block; /* necessary to calculate scaling position */
333
333
  }
@@ -354,7 +354,7 @@ Make sure to test your application with a production build as repeat registratio
354
354
  <div name="left${r}" part="drop-list" class="dl" identifier="droplist${r}_left"></div>
355
355
  <div name="right${r}" part="drop-list" class="dl" identifier="droplist${r}_right"></div>
356
356
  </div>`)}
357
- </div>`}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("register-qti-simple-associable-choice",this._registerChoiceHandler)}};ke.styles=Ii,l([E()],ke.prototype,"_childrenMap",2),ke=l([h("qti-associate-interaction")],ke);var W=class extends x{constructor(){super();this._errorMessage=null;this.handlePostMessage=this.handlePostMessage.bind(this)}connectedCallback(){super.connectedCallback();let e=this.data.startsWith("http")?this.data:Je(this.baseItemUrl+"/"+this.data);fetch(e).then(r=>r.json()).then(r=>{this.manifest=r,this.setupCES()}).catch(r=>{this._errorMessage=r})}setupCES(){let e=this.shadowRoot.querySelector("#pciContainer"),r=e.contentWindow||e,i=e.contentDocument;window.addEventListener("message",this.handlePostMessage),i.open(),i.write(`
357
+ </div>`}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("register-qti-simple-associable-choice",this._registerChoiceHandler)}};ke.styles=Ii,l([E()],ke.prototype,"_childrenMap",2),ke=l([h("qti-associate-interaction")],ke);var G=class extends x{constructor(){super();this._errorMessage=null;this.handlePostMessage=this.handlePostMessage.bind(this)}connectedCallback(){super.connectedCallback();let e=this.data.startsWith("http")?this.data:Je(this.baseItemUrl+"/"+this.data);fetch(e).then(r=>r.json()).then(r=>{this.manifest=r,this.setupCES()}).catch(r=>{this._errorMessage=r})}setupCES(){let e=this.shadowRoot.querySelector("#pciContainer"),r=e.contentWindow||e,i=e.contentDocument;window.addEventListener("message",this.handlePostMessage),i.open(),i.write(`
358
358
  <html>
359
359
  <head>
360
360
  <link href='${Je(`${this.baseRefUrl}/${this.manifest.style[0]}`)}' rel="stylesheet" />
@@ -373,7 +373,7 @@ Make sure to test your application with a production build as repeat registratio
373
373
  ${this._errorMessage&&u`<div style="color:red">
374
374
  <h1>Error</h1>
375
375
  ${this._errorMessage}
376
- </div>`}`}};l([d({type:String,attribute:"response-identifier"})],W.prototype,"responseIdentifier",2),l([d({type:String,attribute:"data"})],W.prototype,"data",2),l([d({type:String,attribute:"data-base-item"})],W.prototype,"baseItemUrl",2),l([d({type:String,attribute:"data-base-ref"})],W.prototype,"baseRefUrl",2),l([d({type:String,attribute:"id"})],W.prototype,"id",2),l([E()],W.prototype,"_errorMessage",2),W=l([h("qti-custom-interaction")],W);var Le=class extends x{constructor(){super(...arguments);this.countAttempt="true"}validate(){return!0}get value(){return""}set value(e){}render(){return u`<button ?disabled=${this.disabled} part="button" @click=${this.endAttempt}>${this.title}</button>`}endAttempt(e){this.dispatchEvent(new CustomEvent("end-attempt",{bubbles:!0,composed:!0,detail:{responseIdentifier:this.responseIdentifier,countAttempt:this.countAttempt==="true"}}))}};l([d({type:String,attribute:"count-attempt"})],Le.prototype,"countAttempt",2),l([d({type:String})],Le.prototype,"title",2),Le=l([h("qti-end-attempt-interaction")],Le);var at=class extends z(x,"qti-gap-text",!1,"qti-gap"){render(){return u`<slot name="prompt"> </slot><slot part="drags" name="qti-gap-text"></slot> <slot part="drops"></slot>`}set correctResponse(t){let e=[],r=Array.isArray(t)?t:[t];r&&(e=r.map(o=>{let n=o.split(" ");return{text:n[0],gap:n[1]}})),this.querySelectorAll("qti-gap").forEach((o,n)=>{var f,m,y,b;let a=o.getAttribute("identifier"),c=(f=e.find(C=>C.gap===a))==null?void 0:f.text,p=(m=this.querySelector(`qti-gap-text[identifier="${c}"]`))==null?void 0:m.textContent.trim();if(c&&p){if(!((y=o.nextElementSibling)!=null&&y.classList.contains("correct-option"))){let C=document.createElement("span");C.classList.add("correct-option"),C.textContent=p,o.insertAdjacentElement("afterend",C)}}else(b=o.nextElementSibling)!=null&&b.classList.contains("correct-option")&&o.nextElementSibling.remove()})}};at.styles=[g`
376
+ </div>`}`}};l([d({type:String,attribute:"data"})],G.prototype,"data",2),l([d({type:String,attribute:"data-base-item"})],G.prototype,"baseItemUrl",2),l([d({type:String,attribute:"data-base-ref"})],G.prototype,"baseRefUrl",2),l([d({type:String,attribute:"id"})],G.prototype,"id",2),l([E()],G.prototype,"_errorMessage",2),G=l([h("qti-custom-interaction")],G);var Le=class extends x{constructor(){super(...arguments);this.countAttempt="true"}validate(){return!0}get value(){return""}set value(e){}render(){return u`<button ?disabled=${this.disabled} part="button" @click=${this.endAttempt}>${this.title}</button>`}endAttempt(e){this.dispatchEvent(new CustomEvent("end-attempt",{bubbles:!0,composed:!0,detail:{responseIdentifier:this.responseIdentifier,countAttempt:this.countAttempt==="true"}}))}};l([d({type:String,attribute:"count-attempt"})],Le.prototype,"countAttempt",2),l([d({type:String})],Le.prototype,"title",2),Le=l([h("qti-end-attempt-interaction")],Le);var at=class extends z(x,"qti-gap-text",!1,"qti-gap"){render(){return u`<slot name="prompt"> </slot><slot part="drags" name="qti-gap-text"></slot> <slot part="drops"></slot>`}set correctResponse(t){let e=[],r=Array.isArray(t)?t:[t];r&&(e=r.map(o=>{let n=o.split(" ");return{text:n[0],gap:n[1]}})),this.querySelectorAll("qti-gap").forEach((o,n)=>{var f,m,y,b;let a=o.getAttribute("identifier"),c=(f=e.find(C=>C.gap===a))==null?void 0:f.text,p=(m=this.querySelector(`qti-gap-text[identifier="${c}"]`))==null?void 0:m.textContent.trim();if(c&&p){if(!((y=o.nextElementSibling)!=null&&y.classList.contains("correct-option"))){let C=document.createElement("span");C.classList.add("correct-option"),C.textContent=p,o.insertAdjacentElement("afterend",C)}}else(b=o.nextElementSibling)!=null&&b.classList.contains("correct-option")&&o.nextElementSibling.remove()})}};at.styles=[g`
377
377
  :host {
378
378
  display: flex;
379
379
  align-items: flex-start;
@@ -400,7 +400,7 @@ Make sure to test your application with a production build as repeat registratio
400
400
  flex: 1;
401
401
  gap: 0.5rem;
402
402
  }
403
- `],at=l([h("qti-gap-match-interaction")],at);var Oi=(s,t,e)=>{let r=new Map;for(let i=t;i<=e;i++)r.set(s[i],i);return r},zt=G(class extends B{constructor(s){if(super(s),s.type!==oe.CHILD)throw Error("repeat() can only be used in text expressions")}dt(s,t,e){let r;e===void 0?e=t:t!==void 0&&(r=t);let i=[],o=[],n=0;for(let a of s)i[n]=r?r(a,n):n,o[n]=e(a,n),n++;return{values:o,keys:i}}render(s,t,e){return this.dt(s,t,e).values}update(s,[t,e,r]){var A;let i=Ti(s),{values:o,keys:n}=this.dt(t,e,r);if(!Array.isArray(i))return this.ut=n,o;let a=(A=this.ut)!=null?A:this.ut=[],c=[],p,f,m=0,y=i.length-1,b=0,C=o.length-1;for(;m<=y&&b<=C;)if(i[m]===null)m++;else if(i[y]===null)y--;else if(a[m]===n[b])c[b]=se(i[m],o[b]),m++,b++;else if(a[y]===n[C])c[C]=se(i[y],o[C]),y--,C--;else if(a[m]===n[C])c[C]=se(i[m],o[C]),Me(s,c[C+1],i[m]),m++,C--;else if(a[y]===n[b])c[b]=se(i[y],o[b]),Me(s,i[m],i[y]),y--,b++;else if(p===void 0&&(p=Oi(n,b,C),f=Oi(a,m,y)),p.has(a[m]))if(p.has(a[y])){let T=f.get(n[b]),xe=T!==void 0?i[T]:null;if(xe===null){let bt=Me(s,i[m]);se(bt,o[b]),c[b]=bt}else c[b]=se(xe,o[b]),Me(s,i[m],xe),i[T]=null;b++}else Lt(i[y]),y--;else Lt(i[m]),m++;for(;b<=C;){let T=Me(s,c[C+1]);se(T,o[b]),c[b++]=T}for(;m<=y;){let T=i[m++];T!==null&&Lt(T)}return this.ut=n,Ai(s,c),L}});function De(s,t,e,r){switch(s){case"circle":{let[i,o,n]=t,a=i/e.width*100,c=o/e.height*100,p=n/e.width*100;r.style.left=a-p+"%",r.style.top=c-p+"%",r.style.width=r.style.height=4*p+"px",r.style.borderRadius="9999px"}break;case"rect":{let[i,o,n,a]=t,c=i/e.width*100,p=o/e.height*100,f=n/e.width*100,m=a/e.height*100;r.style.left=c+"%",r.style.top=p+"%",r.style.width=f-c+"%",r.style.height=m-p+"%"}break;case"poly":{let i=t.reduce((A,T,xe,bt)=>{if(xe%2===1){let ji=A.pop();A[A.length]={x:ji,y:bt[xe]}}else A.push(T);return A},[]),o=Math.min(...i.map(A=>A.x)),n=Math.max(...i.map(A=>A.x)),a=Math.min(...i.map(A=>A.y)),c=Math.max(...i.map(A=>A.y)),p=o/e.width*100,f=a/e.height*100,m=n/e.width*100,y=c/e.height*100;r.style.left=o/e.width*100+"%",r.style.top=a/e.height*100+"%",r.style.width=m-p+"%",r.style.height=y-f+"%";let C=i.map(A=>({x:(A.x-o)/(n-o)*100,y:(A.y-a)/(c-a)*100})).map(A=>Math.round(A.x)+"% "+Math.round(A.y)+"%").join(",");r.style.clipPath=`polygon(${C})`}break;default:break}}var Y=class extends x{constructor(){super();this.startPoint=null;this.endPoint=null;this._lines=[];this.addEventListener("qti-register-hotspot",this.positionHotspotOnRegister)}reset(){this._lines=[]}validate(){return this._lines.length>0}set value(e){Array.isArray(e)&&(this._lines=e)}get value(){return this._lines}render(){var e,r,i,o;return u`<slot name="prompt"></slot>
403
+ `],at=l([h("qti-gap-match-interaction")],at);var Oi=(s,t,e)=>{let r=new Map;for(let i=t;i<=e;i++)r.set(s[i],i);return r},zt=J(class extends B{constructor(s){if(super(s),s.type!==oe.CHILD)throw Error("repeat() can only be used in text expressions")}dt(s,t,e){let r;e===void 0?e=t:t!==void 0&&(r=t);let i=[],o=[],n=0;for(let a of s)i[n]=r?r(a,n):n,o[n]=e(a,n),n++;return{values:o,keys:i}}render(s,t,e){return this.dt(s,t,e).values}update(s,[t,e,r]){var A;let i=Ti(s),{values:o,keys:n}=this.dt(t,e,r);if(!Array.isArray(i))return this.ut=n,o;let a=(A=this.ut)!=null?A:this.ut=[],c=[],p,f,m=0,y=i.length-1,b=0,C=o.length-1;for(;m<=y&&b<=C;)if(i[m]===null)m++;else if(i[y]===null)y--;else if(a[m]===n[b])c[b]=se(i[m],o[b]),m++,b++;else if(a[y]===n[C])c[C]=se(i[y],o[C]),y--,C--;else if(a[m]===n[C])c[C]=se(i[m],o[C]),Me(s,c[C+1],i[m]),m++,C--;else if(a[y]===n[b])c[b]=se(i[y],o[b]),Me(s,i[m],i[y]),y--,b++;else if(p===void 0&&(p=Oi(n,b,C),f=Oi(a,m,y)),p.has(a[m]))if(p.has(a[y])){let T=f.get(n[b]),xe=T!==void 0?i[T]:null;if(xe===null){let bt=Me(s,i[m]);se(bt,o[b]),c[b]=bt}else c[b]=se(xe,o[b]),Me(s,i[m],xe),i[T]=null;b++}else Lt(i[y]),y--;else Lt(i[m]),m++;for(;b<=C;){let T=Me(s,c[C+1]);se(T,o[b]),c[b++]=T}for(;m<=y;){let T=i[m++];T!==null&&Lt(T)}return this.ut=n,Ai(s,c),L}});function De(s,t,e,r){switch(s){case"circle":{let[i,o,n]=t,a=i/e.width*100,c=o/e.height*100,p=n/e.width*100;r.style.left=a-p+"%",r.style.top=c-p+"%",r.style.width=r.style.height=4*p+"px",r.style.borderRadius="9999px"}break;case"rect":{let[i,o,n,a]=t,c=i/e.width*100,p=o/e.height*100,f=n/e.width*100,m=a/e.height*100;r.style.left=c+"%",r.style.top=p+"%",r.style.width=f-c+"%",r.style.height=m-p+"%"}break;case"poly":{let i=t.reduce((A,T,xe,bt)=>{if(xe%2===1){let ji=A.pop();A[A.length]={x:ji,y:bt[xe]}}else A.push(T);return A},[]),o=Math.min(...i.map(A=>A.x)),n=Math.max(...i.map(A=>A.x)),a=Math.min(...i.map(A=>A.y)),c=Math.max(...i.map(A=>A.y)),p=o/e.width*100,f=a/e.height*100,m=n/e.width*100,y=c/e.height*100;r.style.left=o/e.width*100+"%",r.style.top=a/e.height*100+"%",r.style.width=m-p+"%",r.style.height=y-f+"%";let C=i.map(A=>({x:(A.x-o)/(n-o)*100,y:(A.y-a)/(c-a)*100})).map(A=>Math.round(A.x)+"% "+Math.round(A.y)+"%").join(",");r.style.clipPath=`polygon(${C})`}break;default:break}}var W=class extends x{constructor(){super();this.startPoint=null;this.endPoint=null;this._lines=[];this.addEventListener("qti-register-hotspot",this.positionHotspotOnRegister)}reset(){this._lines=[]}validate(){return this._lines.length>0}set value(e){Array.isArray(e)&&(this._lines=e)}get value(){return this._lines}render(){var e,r,i,o;return u`<slot name="prompt"></slot>
404
404
  <line-container>
405
405
  <svg
406
406
  width=${ie((e=this.grImage[0])==null?void 0:e.width)}
@@ -430,7 +430,7 @@ Make sure to test your application with a production build as repeat registratio
430
430
  />`}
431
431
  </svg>
432
432
  <slot></slot>
433
- </line-container>`}positionHotspotOnRegister(e){let r=this.querySelector("img"),i=e.target,o=i.getAttribute("coords"),n=i.getAttribute("shape"),a=o.split(",").map(c=>parseInt(c));De(n,a,r,i)}firstUpdated(e){super.firstUpdated(e),this.hotspots=this.querySelectorAll("qti-associable-hotspot"),document.addEventListener("mousemove",r=>{this.mouseCoord={x:r.clientX-this.grImage[0].getBoundingClientRect().left,y:r.clientY-this.grImage[0].getBoundingClientRect().top}}),this.hotspots.forEach(r=>{r.style.left=r.getAttribute("coords").split(",")[0]+"px",r.style.top=r.getAttribute("coords").split(",")[1]+"px",r.addEventListener("click",i=>{this.startPoint?this.endPoint||(this.endPoint=i.target,this._lines=[...this._lines,this.startPoint.getAttribute("identifier")+" "+this.endPoint.getAttribute("identifier")],this.saveResponse(this._lines),this.startPoint=null,this.endPoint=null):(this.startPoint=i.target,this.startCoord={x:this.startPoint.getAttribute("coords").split(",")[0],y:this.startPoint.getAttribute("coords").split(",")[1]})})})}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-register-hotspot",this.positionHotspotOnRegister)}};Y.styles=[g`
433
+ </line-container>`}positionHotspotOnRegister(e){let r=this.querySelector("img"),i=e.target,o=i.getAttribute("coords"),n=i.getAttribute("shape"),a=o.split(",").map(c=>parseInt(c));De(n,a,r,i)}firstUpdated(e){super.firstUpdated(e),this.hotspots=this.querySelectorAll("qti-associable-hotspot"),document.addEventListener("mousemove",r=>{this.mouseCoord={x:r.clientX-this.grImage[0].getBoundingClientRect().left,y:r.clientY-this.grImage[0].getBoundingClientRect().top}}),this.hotspots.forEach(r=>{r.style.left=r.getAttribute("coords").split(",")[0]+"px",r.style.top=r.getAttribute("coords").split(",")[1]+"px",r.addEventListener("click",i=>{this.startPoint?this.endPoint||(this.endPoint=i.target,this._lines=[...this._lines,this.startPoint.getAttribute("identifier")+" "+this.endPoint.getAttribute("identifier")],this.saveResponse(this._lines),this.startPoint=null,this.endPoint=null):(this.startPoint=i.target,this.startCoord={x:this.startPoint.getAttribute("coords").split(",")[0],y:this.startPoint.getAttribute("coords").split(",")[1]})})})}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-register-hotspot",this.positionHotspotOnRegister)}};W.styles=[g`
434
434
  slot:not([name='prompt']) {
435
435
  // position: relative; /* qti-hotspot-choice relative to the slot */
436
436
  display: block;
@@ -453,7 +453,7 @@ Make sure to test your application with a production build as repeat registratio
453
453
  top: 0px;
454
454
  left: 0px;
455
455
  }
456
- `],l([E()],Y.prototype,"_lines",2),l([E()],Y.prototype,"startCoord",2),l([E()],Y.prototype,"mouseCoord",2),l([ve("svg")],Y.prototype,"svgContainer",2),l([ui({selector:"img"})],Y.prototype,"grImage",2),Y=l([h("qti-graphic-associate-interaction")],Y);var lt=class extends z(x,"qti-gap-img",!1,"qti-associable-hotspot"){render(){return u` <slot name="prompt"></slot>
456
+ `],l([E()],W.prototype,"_lines",2),l([E()],W.prototype,"startCoord",2),l([E()],W.prototype,"mouseCoord",2),l([be("svg")],W.prototype,"svgContainer",2),l([ui({selector:"img"})],W.prototype,"grImage",2),W=l([h("qti-graphic-associate-interaction")],W);var lt=class extends z(x,"qti-gap-img",!1,"qti-associable-hotspot"){render(){return u` <slot name="prompt"></slot>
457
457
  <slot></slot>
458
458
  <slot name="qti-gap-img"></slot>`}positionHotspotOnRegister(t){let e=this.querySelector("img"),r=t.target,i=r.getAttribute("coords"),o=r.getAttribute("shape"),n=i.split(",").map(a=>parseInt(a));switch(o){case"circle":{let[a,c,p]=n;r.style.left=a-p+"px",r.style.top=c-p+"px",r.style.width=r.style.height=2*p+"px"}break;case"rect":{let[a,c,p,f]=n;r.style.left=a+"px",r.style.top=c+"px",r.style.width=p-a+"px",r.style.height=f-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)}};lt.styles=g`
459
459
  :host {
@@ -497,10 +497,10 @@ Make sure to test your application with a production build as repeat registratio
497
497
  user-select: none;
498
498
  /* width:100%; */
499
499
  }
500
- `],pt=l([h("qti-hotspot-interaction")],pt);var pe=class extends O(v,"qti-simple-associable-choice"){constructor(){super(...arguments);this.matchMin=0;this.matchMax=1;this.fixed=!1}connectedCallback(){super.connectedCallback(),this.setAttribute("slot","qti-simple-associable-choice"),this.setAttribute("part","qti-simple-associable-choice")}render(){return u`
500
+ `],pt=l([h("qti-hotspot-interaction")],pt);var ce=class extends O(v,"qti-simple-associable-choice"){constructor(){super(...arguments);this.matchMin=0;this.matchMax=1;this.fixed=!1}connectedCallback(){super.connectedCallback(),this.setAttribute("slot","qti-simple-associable-choice"),this.setAttribute("part","qti-simple-associable-choice")}render(){return u`
501
501
  <slot part="slot"></slot>
502
502
  <slot part="dropslot" name="qti-simple-associable-choice"></slot>
503
- `}};pe.styles=g`
503
+ `}};ce.styles=g`
504
504
  :host {
505
505
  display: flex;
506
506
  user-select: none;
@@ -512,7 +512,7 @@ Make sure to test your application with a production build as repeat registratio
512
512
  slot[name='qti-simple-associable-choice'] {
513
513
  width: 100%;
514
514
  }
515
- `,l([d({type:Number,attribute:"match-min"})],pe.prototype,"matchMin",2),l([d({type:Number,attribute:"match-max"})],pe.prototype,"matchMax",2),l([d({type:Boolean,attribute:"fixed"})],pe.prototype,"fixed",2),pe=l([h("qti-simple-associable-choice")],pe);var Ui=g`
515
+ `,l([d({type:Number,attribute:"match-min"})],ce.prototype,"matchMin",2),l([d({type:Number,attribute:"match-max"})],ce.prototype,"matchMax",2),l([d({type:Boolean,attribute:"fixed"})],ce.prototype,"fixed",2),ce=l([h("qti-simple-associable-choice")],ce);var Ui=g`
516
516
  slot {
517
517
  /* slot where the */
518
518
  display: flex;
@@ -539,7 +539,7 @@ Make sure to test your application with a production build as repeat registratio
539
539
  /* Make sure the drag and drop container slots have the same width */
540
540
  flex: 1;
541
541
  }
542
- `;var de=class extends z(x,"qti-simple-match-set:first-of-type qti-simple-associable-choice",!1,"qti-simple-match-set:last-of-type qti-simple-associable-choice"){constructor(){super(...arguments);this.lastCheckedRadio=null;this._response=[];this.correctOptions=[];this.responseIdentifier="";this.handleRadioClick=e=>{let r=e.target;this.lastCheckedRadio===r?(r.checked=!1,this.lastCheckedRadio=null,this.handleRadioChange(e)):this.lastCheckedRadio=r};this.handleRadioChange=e=>{let r=e.target,i=r.value,o=r.name,n=r.type;r.checked?(this.value?this.value.indexOf(i)===-1&&(n==="radio"&&(this.value=this.value.filter(a=>a.indexOf(o)===-1)),this.value=[...this.value,i]):this.value=[i],this.lastCheckedRadio=r):(this.value=this.value.filter(a=>a!==i),this.lastCheckedRadio=null),this.requestUpdate(),this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,composed:!0,detail:{responseIdentifier:this.responseIdentifier,response:Array.isArray(this.value)?[...this.value]:this.value}}))}}get value(){return this.classList.contains("qti-match-tabular")?this._response:super.value}set value(e){this.classList.contains("qti-match-tabular")?this._response=e:super.value=e}async connectedCallback(){super.connectedCallback(),this.rows=Array.from(this.querySelectorAll("qti-simple-match-set:first-of-type qti-simple-associable-choice")),this.cols=Array.from(this.querySelectorAll("qti-simple-match-set:last-of-type qti-simple-associable-choice")),this.value=[]}set correctResponse(e){if(e===""){this.correctOptions=[];return}else Array.isArray(e)&&(this.correctOptions=e)}render(){return this.classList.contains("qti-match-tabular")?u`
542
+ `;var pe=class extends z(x,"qti-simple-match-set:first-of-type qti-simple-associable-choice",!1,"qti-simple-match-set:last-of-type qti-simple-associable-choice"){constructor(){super(...arguments);this.lastCheckedRadio=null;this._response=[];this.correctOptions=[];this.responseIdentifier="";this.handleRadioClick=e=>{let r=e.target;this.lastCheckedRadio===r?(r.checked=!1,this.lastCheckedRadio=null,this.handleRadioChange(e)):this.lastCheckedRadio=r};this.handleRadioChange=e=>{let r=e.target,i=r.value,o=r.name,n=r.type;r.checked?(this.value?this.value.indexOf(i)===-1&&(n==="radio"&&(this.value=this.value.filter(a=>a.indexOf(o)===-1)),this.value=[...this.value,i]):this.value=[i],this.lastCheckedRadio=r):(this.value=this.value.filter(a=>a!==i),this.lastCheckedRadio=null),this.requestUpdate(),this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,composed:!0,detail:{responseIdentifier:this.responseIdentifier,response:Array.isArray(this.value)?[...this.value]:this.value}}))}}get value(){return this.classList.contains("qti-match-tabular")?this._response:super.value}set value(e){this.classList.contains("qti-match-tabular")?this._response=e:super.value=e}async connectedCallback(){super.connectedCallback(),this.rows=Array.from(this.querySelectorAll("qti-simple-match-set:first-of-type qti-simple-associable-choice")),this.cols=Array.from(this.querySelectorAll("qti-simple-match-set:last-of-type qti-simple-associable-choice")),this.value=[]}set correctResponse(e){if(e===""){this.correctOptions=[];return}else Array.isArray(e)&&(this.correctOptions=e)}render(){return this.classList.contains("qti-match-tabular")?u`
543
543
  <slot name="prompt"></slot>
544
544
  <table>
545
545
  <tr>
@@ -562,7 +562,7 @@ Make sure to test your application with a production build as repeat registratio
562
562
  </td>`})}
563
563
  </tr>`)}
564
564
  </table>
565
- `:u`<slot name="prompt"></slot> <slot></slot>`}};de.styles=Ui,l([E()],de.prototype,"_response",2),l([E()],de.prototype,"correctOptions",2),l([d({type:String,attribute:"response-identifier"})],de.prototype,"responseIdentifier",2),de=l([h("qti-match-interaction")],de);var dt=class extends x{constructor(){super();this._value=0}reset(){}validate(){return!0}get value(){return this._value.toString()}set value(e){if(!isNaN(parseInt(e.toString())))this._value=parseInt(e.toString());else throw new Error("Value must be a number")}static get properties(){return S(q({},x.properties),{step:{type:Number,attribute:"step",default:10}})}render(){return u` <slot name="prompt"></slot>
565
+ `:u`<slot name="prompt"></slot> <slot></slot>`}};pe.styles=Ui,l([E()],pe.prototype,"_response",2),l([E()],pe.prototype,"correctOptions",2),l([d({type:String,attribute:"response-identifier"})],pe.prototype,"responseIdentifier",2),pe=l([h("qti-match-interaction")],pe);var dt=class extends x{constructor(){super();this._value=0}reset(){}validate(){return!0}get value(){return this._value.toString()}set value(e){if(!isNaN(parseInt(e.toString())))this._value=parseInt(e.toString());else throw new Error("Value must be a number")}static get properties(){return S(q({},x.properties),{step:{type:Number,attribute:"step",default:10}})}render(){return u` <slot name="prompt"></slot>
566
566
  <slot></slot>`}connectedCallback(){super.connectedCallback();let e=this.querySelector("audio")||this.querySelector("video")||this.querySelector("object");e&&e.addEventListener("ended",()=>{this._value++,this.saveResponse(this.value)})}};dt.styles=[g``],dt=l([h("qti-media-interaction")],dt);var Q=class extends Nt(z(x,"qti-simple-choice",!0,"drop-list"),"qti-simple-choice"){constructor(){super(...arguments);this.nrChoices=0;this.correctResponses=[];this.showCorrectResponses=!1}render(){let e=Array.from(this.querySelectorAll("qti-simple-choice"));return this.nrChoices<e.length&&(this.nrChoices=e.length),u` <slot name="prompt"> </slot>
567
567
  <div part="container">
568
568
  <slot part="drags"> </slot>
@@ -633,7 +633,7 @@ Make sure to test your application with a production build as repeat registratio
633
633
  display: inline-block;
634
634
  position: relative;
635
635
  }
636
- `],ut=l([h("qti-position-object-stage")],ut);var Fi="important",Cs=" !"+Fi,Bi=G(class extends B{constructor(s){var t;if(super(s),s.type!==oe.ATTRIBUTE||s.name!=="style"||((t=s.strings)==null?void 0:t.length)>2)throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.")}render(s){return Object.keys(s).reduce((t,e)=>{let r=s[e];return r==null?t:t+`${e=e.includes("-")?e:e.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${r};`},"")}update(s,[t]){let{style:e}=s.element;if(this.ft===void 0)return this.ft=new Set(Object.keys(t)),this.render(t);for(let r of this.ft)t[r]==null&&(this.ft.delete(r),r.includes("-")?e.removeProperty(r):e[r]=null);for(let r in t){let i=t[r];if(i!=null){this.ft.add(r);let o=typeof i=="string"&&i.endsWith(Cs);r.includes("-")||o?e.setProperty(r,o?i.slice(0,-11):i,o?Fi:""):e[r]=i}}return L}});var ue=class extends x{constructor(){super(...arguments);this.maxChoices=1/0;this.minChoices=0;this._points=[];this._imgElement=null;this._onImageClick=e=>{if(this._points.length<this.maxChoices){let r=e.offsetX,i=e.offsetY;this._points=[...this._points,`${r} ${i}`],this.saveResponse(this._points)}}}render(){return u` <slot name="prompt"></slot>
636
+ `],ut=l([h("qti-position-object-stage")],ut);var Fi="important",Cs=" !"+Fi,Bi=J(class extends B{constructor(s){var t;if(super(s),s.type!==oe.ATTRIBUTE||s.name!=="style"||((t=s.strings)==null?void 0:t.length)>2)throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.")}render(s){return Object.keys(s).reduce((t,e)=>{let r=s[e];return r==null?t:t+`${e=e.includes("-")?e:e.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${r};`},"")}update(s,[t]){let{style:e}=s.element;if(this.ft===void 0)return this.ft=new Set(Object.keys(t)),this.render(t);for(let r of this.ft)t[r]==null&&(this.ft.delete(r),r.includes("-")?e.removeProperty(r):e[r]=null);for(let r in t){let i=t[r];if(i!=null){this.ft.add(r);let o=typeof i=="string"&&i.endsWith(Cs);r.includes("-")||o?e.setProperty(r,o?i.slice(0,-11):i,o?Fi:""):e[r]=i}}return L}});var de=class extends x{constructor(){super(...arguments);this.maxChoices=1/0;this.minChoices=0;this._points=[];this._imgElement=null;this._onImageClick=e=>{if(this._points.length<this.maxChoices){let r=e.offsetX,i=e.offsetY;this._points=[...this._points,`${r} ${i}`],this.saveResponse(this._points)}}}render(){return u` <slot name="prompt"></slot>
637
637
  <point-container>
638
638
  ${zt(this._points,e=>e,(e,r)=>u`
639
639
  <button
@@ -644,7 +644,7 @@ Make sure to test your application with a production build as repeat registratio
644
644
  ></button>
645
645
  `)}
646
646
  <slot></slot>
647
- </point-container>`}reset(){this._points=[]}validate(){return this._points.length>=this.minChoices&&this._points.length<=this.maxChoices}set value(e){this._points=Array.isArray(e)?e:[e]}get value(){return this._points}firstUpdated(){this._imgElement=this.querySelector("img"),this._imgElement?this._imgElement.addEventListener("click",this._onImageClick):console.warn("No <img> element found in <qti-select-point-interaction>")}disconnectedCallback(){super.disconnectedCallback(),this._imgElement&&this._imgElement.removeEventListener("click",this._onImageClick)}};ue.styles=[g`
647
+ </point-container>`}reset(){this._points=[]}validate(){return this._points.length>=this.minChoices&&this._points.length<=this.maxChoices}set value(e){this._points=Array.isArray(e)?e:[e]}get value(){return this._points}firstUpdated(){this._imgElement=this.querySelector("img"),this._imgElement?this._imgElement.addEventListener("click",this._onImageClick):console.warn("No <img> element found in <qti-select-point-interaction>")}disconnectedCallback(){super.disconnectedCallback(),this._imgElement&&this._imgElement.removeEventListener("click",this._onImageClick)}};de.styles=[g`
648
648
  :host {
649
649
  display: block;
650
650
  }
@@ -652,7 +652,7 @@ Make sure to test your application with a production build as repeat registratio
652
652
  display: block;
653
653
  position: relative;
654
654
  }
655
- `],l([d({type:Number,attribute:"max-choices"})],ue.prototype,"maxChoices",2),l([d({type:Number,attribute:"min-choices"})],ue.prototype,"minChoices",2),l([E()],ue.prototype,"_points",2),ue=l([h("qti-select-point-interaction")],ue);var R=class extends x{constructor(){super();this._value=0;this.stepLabel=!1;this.reverse=!1;this._handleDisabledChange=(e,r)=>{};this._handleReadonlyChange=(e,r)=>{};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}get value(){return this._value.toString()}set value(e){if(!isNaN(parseInt(e.toString())))this._value=parseInt(e.toString());else throw new Error("Value must be a number")}set response(e){if(Array.isArray(e)){console.error("QtiSliderInteraction: response is an array, but should be a single value");return}let r=parseInt(e);if(Number.isNaN(r)){console.error("QtiSliderInteraction: response is not a number");return}this._value=r}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()),u`<slot name="prompt"></slot>
655
+ `],l([d({type:Number,attribute:"max-choices"})],de.prototype,"maxChoices",2),l([d({type:Number,attribute:"min-choices"})],de.prototype,"minChoices",2),l([E()],de.prototype,"_points",2),de=l([h("qti-select-point-interaction")],de);var R=class extends x{constructor(){super();this._value=0;this.stepLabel=!1;this.reverse=!1;this._handleDisabledChange=(e,r)=>{};this._handleReadonlyChange=(e,r)=>{};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}get value(){return this._value.toString()}set value(e){if(!isNaN(parseInt(e.toString())))this._value=parseInt(e.toString());else throw new Error("Value must be a number")}set response(e){if(Array.isArray(e)){console.error("QtiSliderInteraction: response is an array, but should be a single value");return}let r=parseInt(e);if(Number.isNaN(r)){console.error("QtiSliderInteraction: response is not a number");return}this._value=r}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()),u`<slot name="prompt"></slot>
656
656
  <div id="slider" part="slider">
657
657
  ${this.csLive.getPropertyValue("--show-bounds")=="true"?u`<div id="bounds" part="bounds">
658
658
  <div>${this._min}</div>
@@ -664,7 +664,7 @@ Make sure to test your application with a production build as repeat registratio
664
664
  ${this.csLive.getPropertyValue("--show-value")=="true"?u`<div id="value" part="value">${this.value}</div>`:w}
665
665
  </div>
666
666
  </div>
667
- </div>`}connectedCallback(){super.connectedCallback(),this.step=1,this.setAttribute("tabindex","0"),this.setAttribute("role","slider")}_onTouchMove(e){let r=a=>{let{x:c}=this.getPositionFromEvent(a),p=c-this._rail.getBoundingClientRect().left-document.documentElement.scrollLeft;this.calculateValue(p),a.stopPropagation()},i=()=>{document.removeEventListener("touchmove",r),document.removeEventListener("touchend",i),this.saveResponse(this.value.toString())};document.addEventListener("touchmove",r),document.addEventListener("touchend",i);let{x:o}=this.getPositionFromEvent(e),n=o-this._rail.getBoundingClientRect().left-document.documentElement.scrollLeft;this.calculateValue(n),e.stopPropagation()}_onMouseDown(e){let r=n=>{let a=n.pageX-this._rail.getBoundingClientRect().left-document.documentElement.scrollLeft;this.calculateValue(a),n.preventDefault(),n.stopPropagation()},i=()=>{document.removeEventListener("mousemove",r),document.removeEventListener("mouseup",i),this.saveResponse(this.value.toString())};document.addEventListener("mousemove",r),document.addEventListener("mouseup",i);let o=e.pageX-this._rail.getBoundingClientRect().left-document.documentElement.scrollLeft;this.calculateValue(o),e.preventDefault(),e.stopPropagation()}calculateValue(e){let r=this.min+(this.max-this.min)*e/this._rail.getBoundingClientRect().width,i=this.min+Math.round((r-this.min)/this._step)*this._step;this._value=i}getPositionFromEvent(e){let r;if(e.type=="touchstart"||e.type=="touchmove"||e.type=="touchend"||e.type=="touchcancel"){let i=typeof e.originalEvent=="undefined"?e:e.originalEvent,o=i.touches[0]||i.changedTouches[0];r={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")&&(r={x:e.clientX,y:e.clientY});return r}};R.styles=[g``],l([ve("#knob")],R.prototype,"_knob",2),l([ve("#rail")],R.prototype,"_rail",2),l([d({type:Boolean,attribute:"step-label"})],R.prototype,"stepLabel",2),l([d({type:Boolean})],R.prototype,"reverse",2),l([d({type:Number,attribute:"lower-bound"})],R.prototype,"min",1),l([d({type:Number,attribute:"upper-bound"})],R.prototype,"max",1),l([d({type:Number,attribute:"step"})],R.prototype,"step",1),l([M("disabled",{waitUntilFirstUpdate:!0})],R.prototype,"_handleDisabledChange",2),l([M("readonly",{waitUntilFirstUpdate:!0})],R.prototype,"_handleReadonlyChange",2),R=l([h("qti-slider-interaction")],R);var ht=class extends v{render(){return u`<slot @slotchange=${this.handleSlotChange}></slot>`}handleSlotChange(t){var r,i,o;let e=Array.from((i=(r=this.firstElementChild)==null?void 0:r.childNodes)!=null?i:[]).find(n=>n.nodeType===Node.COMMENT_NODE);try{this.operatorFunction=new Function("context","fn","item",(o=e.textContent)!=null?o:"")}catch(n){console.error("custom-operator contains invalid javascript code",n)}}calculate(){let t={variable:r=>{var i,o,n;return(n=(o=(i=this._context)==null?void 0:i.variables.find(a=>a.identifier===r))==null?void 0:o.value)!=null?n:""},correct:r=>{var i,o,n;return(n=(o=(i=this._context)==null?void 0:i.variables.find(a=>a.identifier===r))==null?void 0:o.correctResponse)!=null?n:""}},e={getVariable:r=>{var i;return(i=this._context)==null?void 0:i.variables.find(o=>o.identifier===r)},updateOutcomeVariable:(r,i)=>{this.dispatchEvent(new CustomEvent("qti-set-outcome-value",{bubbles:!0,composed:!0,detail:{outcomeIdentifier:r,value:i}}))},updateResponseVariable:(r,i)=>{this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,composed:!0,detail:{responseIdentifier:r,response:i}}))}};return this.operatorFunction(this._context,t,e)}};l([k({context:$,subscribe:!0}),E()],ht.prototype,"_context",2),ht=l([h("qti-custom-operator")],ht);var mt=class extends v{connectedCallback(){super.connectedCallback(),this.dispatchEvent(new CustomEvent("qti-register-hotspot",{bubbles:!0,composed:!0,cancelable:!1}))}render(){return u` <slot name="qti-gap-img"></slot> `}};mt.styles=g`
667
+ </div>`}connectedCallback(){super.connectedCallback(),this.step=1,this.setAttribute("tabindex","0"),this.setAttribute("role","slider")}_onTouchMove(e){let r=a=>{let{x:c}=this.getPositionFromEvent(a),p=c-this._rail.getBoundingClientRect().left-document.documentElement.scrollLeft;this.calculateValue(p),a.stopPropagation()},i=()=>{document.removeEventListener("touchmove",r),document.removeEventListener("touchend",i),this.saveResponse(this.value.toString())};document.addEventListener("touchmove",r),document.addEventListener("touchend",i);let{x:o}=this.getPositionFromEvent(e),n=o-this._rail.getBoundingClientRect().left-document.documentElement.scrollLeft;this.calculateValue(n),e.stopPropagation()}_onMouseDown(e){let r=n=>{let a=n.pageX-this._rail.getBoundingClientRect().left-document.documentElement.scrollLeft;this.calculateValue(a),n.preventDefault(),n.stopPropagation()},i=()=>{document.removeEventListener("mousemove",r),document.removeEventListener("mouseup",i),this.saveResponse(this.value.toString())};document.addEventListener("mousemove",r),document.addEventListener("mouseup",i);let o=e.pageX-this._rail.getBoundingClientRect().left-document.documentElement.scrollLeft;this.calculateValue(o),e.preventDefault(),e.stopPropagation()}calculateValue(e){let r=this.min+(this.max-this.min)*e/this._rail.getBoundingClientRect().width,i=this.min+Math.round((r-this.min)/this._step)*this._step;this._value=i}getPositionFromEvent(e){let r;if(e.type=="touchstart"||e.type=="touchmove"||e.type=="touchend"||e.type=="touchcancel"){let i=typeof e.originalEvent=="undefined"?e:e.originalEvent,o=i.touches[0]||i.changedTouches[0];r={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")&&(r={x:e.clientX,y:e.clientY});return r}};R.styles=[g``],l([be("#knob")],R.prototype,"_knob",2),l([be("#rail")],R.prototype,"_rail",2),l([d({type:Boolean,attribute:"step-label"})],R.prototype,"stepLabel",2),l([d({type:Boolean})],R.prototype,"reverse",2),l([d({type:Number,attribute:"lower-bound"})],R.prototype,"min",1),l([d({type:Number,attribute:"upper-bound"})],R.prototype,"max",1),l([d({type:Number,attribute:"step"})],R.prototype,"step",1),l([M("disabled",{waitUntilFirstUpdate:!0})],R.prototype,"_handleDisabledChange",2),l([M("readonly",{waitUntilFirstUpdate:!0})],R.prototype,"_handleReadonlyChange",2),R=l([h("qti-slider-interaction")],R);var ht=class extends v{render(){return u`<slot @slotchange=${this.handleSlotChange}></slot>`}handleSlotChange(t){var r,i,o;let e=Array.from((i=(r=this.firstElementChild)==null?void 0:r.childNodes)!=null?i:[]).find(n=>n.nodeType===Node.COMMENT_NODE);try{this.operatorFunction=new Function("context","fn","item",(o=e.textContent)!=null?o:"")}catch(n){console.error("custom-operator contains invalid javascript code",n)}}calculate(){let t={variable:r=>{var i,o,n;return(n=(o=(i=this._context)==null?void 0:i.variables.find(a=>a.identifier===r))==null?void 0:o.value)!=null?n:""},correct:r=>{var i,o,n;return(n=(o=(i=this._context)==null?void 0:i.variables.find(a=>a.identifier===r))==null?void 0:o.correctResponse)!=null?n:""}},e={getVariable:r=>{var i;return(i=this._context)==null?void 0:i.variables.find(o=>o.identifier===r)},updateOutcomeVariable:(r,i)=>{this.dispatchEvent(new CustomEvent("qti-set-outcome-value",{bubbles:!0,composed:!0,detail:{outcomeIdentifier:r,value:i}}))},updateResponseVariable:(r,i)=>{this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,composed:!0,detail:{responseIdentifier:r,response:i}}))}};return this.operatorFunction(this._context,t,e)}};l([k({context:$,subscribe:!0}),E()],ht.prototype,"_context",2),ht=l([h("qti-custom-operator")],ht);var mt=class extends v{connectedCallback(){super.connectedCallback(),this.dispatchEvent(new CustomEvent("qti-register-hotspot",{bubbles:!0,composed:!0,cancelable:!1}))}render(){return u` <slot name="qti-gap-img"></slot> `}};mt.styles=g`
668
668
  :host {
669
669
  display: flex;
670
670
  user-select: none;
@@ -723,7 +723,7 @@ Make sure to test your application with a production build as repeat registratio
723
723
  align-items: center;
724
724
  justify-content: center;
725
725
  }
726
- `,l([d({type:String,attribute:!1})],Ie.prototype,"marker",2),Ie=l([h("qti-simple-choice")],Ie);console.log("%cC\xBFTO%cLab%c: qti-components loaded","font-weight:bold; color:green",'font-family: "PT Sans", font-weight:bold; color:green; font-size: smaller;vertical-align: sub',"font-weight:unset");function Xi(s){class t extends s{createRenderRoot(){return this}get assessmentItem(){var r;return(r=this.renderRoot)==null?void 0:r.querySelector("qti-assessment-item")}async connectedCallback(){super.connectedCallback(),await this.updateComplete,this.dispatchEvent(new CustomEvent("qti-item-connected",{bubbles:!0,composed:!0,detail:{identifier:this.identifier,href:this.href}}))}render(){return u`${this.xmlDoc}`}}return l([d({type:String,reflect:!0})],t.prototype,"identifier",2),l([d({type:String})],t.prototype,"href",2),l([d({type:Object,attribute:!1})],t.prototype,"xmlDoc",2),t}var Yt=class extends Xi(v){};Yt=l([h("qti-item")],Yt);var bb=async s=>{let t=s.substring(0,s.lastIndexOf("/")),e=await Ei().load(`${s}`).then(a=>a.assessmentTest()),r=await cr().load(`${t}/${e.href}`).then(a=>a.htmlDoc()),i=await cr().load(`${t}/${e.href}`).then(a=>a.items()),o=`${t}/${e.href}`,n=`${t}/${e.href.substring(0,e.href.lastIndexOf("/"))}`;return{testHTMLDoc:r,testURI:n,testURL:o,items:i,testIdentifier:e.identifier}},vb=async s=>St().load(s).then(t=>t.htmlDoc().firstElementChild);export{O as ActiveElementMixin,x as Interaction,It as QtiAnd,D as QtiAssessmentItem,Se as QtiAssessmentStimulusRef,mt as QtiAssociableHotspot,ke as QtiAssociateInteraction,Ot as QtiBaseValue,$e as QtiChoiceInteraction,Rt as QtiCompanionMaterialsInfo,N as QtiConditionExpression,vr as QtiContains,kt as QtiContentBody,yr as QtiCorrect,W as QtiCustomInteraction,ht as QtiCustomOperator,Le as QtiEndAttemptInteraction,Ft as QtiEqual,Ut as QtiEqualRounded,_ as QtiExpression,V as QtiExtendedTextInteraction,Ge as QtiFeedbackBlock,Qe as QtiFeedbackInline,He as QtiGap,Ve as QtiGapImg,at as QtiGapMatchInteraction,Ne as QtiGapText,Y as QtiGraphicAssociateInteraction,lt as QtiGraphicGapMatchInteraction,ct as QtiGraphicOrderInteraction,xr as QtiGt,Er as QtiGte,Pe as QtiHotspotChoice,pt as QtiHotspotInteraction,ft as QtiHottext,Vt as QtiHottextInteraction,gt as QtiInlineChoice,le as QtiInlineChoiceInteraction,Cr as QtiIsNull,Yt as QtiItem,Ke as QtiItemBody,Xi as QtiItemMixin,Pt as QtiLookupOutcomeValue,_r as QtiLt,wr as QtiLte,Bt as QtiMapResponse,Re as QtiMapping,qr as QtiMatch,de as QtiMatchInteraction,dt as QtiMediaInteraction,Ar as QtiMember,et as QtiModalFeedback,Tr as QtiMultiple,Sr as QtiNot,Mr as QtiOr,Q as QtiOrderInteraction,$r as QtiOrdered,U as QtiOutcomeDeclaration,it as QtiOutcomeProcessing,hr as QtiOutcomeProcessingProcessor,ce as QtiPortableCustomInteraction,ut as QtiPositionObjectStage,nt as QtiPrintedVariable,Rr as QtiProduct,Mt as QtiPrompt,mr as QtiResponseCondition,J as QtiResponseDeclaration,st as QtiResponseElse,br as QtiResponseElseIf,ot as QtiResponseIf,ye as QtiResponseProcessing,F as QtiRubricBlock,j as QtiRule,Wt as QtiSPositionObjectInteraction,ue as QtiSelectPointInteraction,fr as QtiSetOutcomeValue,gr as QtiSetOutcomeValueRule,pe as QtiSimpleAssociableChoice,Ie as QtiSimpleChoice,R as QtiSliderInteraction,Xt as QtiStringMatch,$t as QtiStylesheet,kr as QtiSum,Lr as QtiSumExpression,X as QtiTextEntryInteraction,Dr as QtiVariable,vb as getItemByUri,bb as getManifestInfo,$ as itemContext,hi as itemContextVariables,Es as qtiAndMixin,St as qtiTransformItem,Ei as qtiTransformManifest,cr as qtiTransformTest};
726
+ `,l([d({type:String,attribute:!1})],Ie.prototype,"marker",2),Ie=l([h("qti-simple-choice")],Ie);console.log("%cC\xBFTO%cLab%c: qti-components loaded","font-weight:bold; color:green",'font-family: "PT Sans", font-weight:bold; color:green; font-size: smaller;vertical-align: sub',"font-weight:unset");function Xi(s){class t extends s{createRenderRoot(){return this}get assessmentItem(){var r;return(r=this.renderRoot)==null?void 0:r.querySelector("qti-assessment-item")}async connectedCallback(){super.connectedCallback(),await this.updateComplete,this.dispatchEvent(new CustomEvent("qti-item-connected",{bubbles:!0,composed:!0,detail:{identifier:this.identifier,href:this.href}}))}render(){return u`${this.xmlDoc}`}}return l([d({type:String,reflect:!0})],t.prototype,"identifier",2),l([d({type:String})],t.prototype,"href",2),l([d({type:Object,attribute:!1})],t.prototype,"xmlDoc",2),t}var Yt=class extends Xi(v){};Yt=l([h("qti-item")],Yt);var bb=async s=>{let t=s.substring(0,s.lastIndexOf("/")),e=await Ei().load(`${s}`).then(a=>a.assessmentTest()),r=await cr().load(`${t}/${e.href}`).then(a=>a.htmlDoc()),i=await cr().load(`${t}/${e.href}`).then(a=>a.items()),o=`${t}/${e.href}`,n=`${t}/${e.href.substring(0,e.href.lastIndexOf("/"))}`;return{testHTMLDoc:r,testURI:n,testURL:o,items:i,testIdentifier:e.identifier}},vb=async s=>St().load(s).then(t=>t.htmlDoc().firstElementChild);export{O as ActiveElementMixin,x as Interaction,It as QtiAnd,D as QtiAssessmentItem,Se as QtiAssessmentStimulusRef,mt as QtiAssociableHotspot,ke as QtiAssociateInteraction,Ot as QtiBaseValue,$e as QtiChoiceInteraction,Rt as QtiCompanionMaterialsInfo,N as QtiConditionExpression,vr as QtiContains,kt as QtiContentBody,yr as QtiCorrect,G as QtiCustomInteraction,ht as QtiCustomOperator,Le as QtiEndAttemptInteraction,Ft as QtiEqual,Ut as QtiEqualRounded,_ as QtiExpression,V as QtiExtendedTextInteraction,Ge as QtiFeedbackBlock,Qe as QtiFeedbackInline,He as QtiGap,Ve as QtiGapImg,at as QtiGapMatchInteraction,Ne as QtiGapText,W as QtiGraphicAssociateInteraction,lt as QtiGraphicGapMatchInteraction,ct as QtiGraphicOrderInteraction,xr as QtiGt,Er as QtiGte,Pe as QtiHotspotChoice,pt as QtiHotspotInteraction,ft as QtiHottext,Vt as QtiHottextInteraction,gt as QtiInlineChoice,le as QtiInlineChoiceInteraction,Cr as QtiIsNull,Yt as QtiItem,Ke as QtiItemBody,Xi as QtiItemMixin,Pt as QtiLookupOutcomeValue,_r as QtiLt,wr as QtiLte,Bt as QtiMapResponse,Re as QtiMapping,qr as QtiMatch,pe as QtiMatchInteraction,dt as QtiMediaInteraction,Ar as QtiMember,et as QtiModalFeedback,Tr as QtiMultiple,Sr as QtiNot,Mr as QtiOr,Q as QtiOrderInteraction,$r as QtiOrdered,U as QtiOutcomeDeclaration,it as QtiOutcomeProcessing,hr as QtiOutcomeProcessingProcessor,ye as QtiPortableCustomInteraction,ut as QtiPositionObjectStage,nt as QtiPrintedVariable,Rr as QtiProduct,Mt as QtiPrompt,mr as QtiResponseCondition,Z as QtiResponseDeclaration,st as QtiResponseElse,br as QtiResponseElseIf,ot as QtiResponseIf,ve as QtiResponseProcessing,F as QtiRubricBlock,j as QtiRule,Wt as QtiSPositionObjectInteraction,de as QtiSelectPointInteraction,fr as QtiSetOutcomeValue,gr as QtiSetOutcomeValueRule,ce as QtiSimpleAssociableChoice,Ie as QtiSimpleChoice,R as QtiSliderInteraction,Xt as QtiStringMatch,$t as QtiStylesheet,kr as QtiSum,Lr as QtiSumExpression,X as QtiTextEntryInteraction,Dr as QtiVariable,vb as getItemByUri,bb as getManifestInfo,$ as itemContext,hi as itemContextVariables,Es as qtiAndMixin,St as qtiTransformItem,Ei as qtiTransformManifest,cr as qtiTransformTest};
727
727
  /*! Bundled license information:
728
728
 
729
729
  @lit/context/lib/context-request-event.js: