@citolab/qti-components 7.14.1 → 7.14.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/cdn/index.global.js +1 -1
  2. package/cdn/index.js +86 -78
  3. package/custom-elements.json +427 -5
  4. package/dist/chunks/{chunk-YD7FVKDP.js → chunk-AGV5GOTF.js} +3 -5
  5. package/dist/chunks/chunk-AGV5GOTF.js.map +1 -0
  6. package/dist/chunks/{chunk-TISKSGJE.js → chunk-C4ELTNV7.js} +77 -18
  7. package/dist/chunks/chunk-C4ELTNV7.js.map +1 -0
  8. package/dist/chunks/{chunk-7567ZPN6.js → chunk-DGBI4IU5.js} +2 -2
  9. package/dist/chunks/{chunk-XEKFVRIO.js → chunk-E4GR4K26.js} +3 -4
  10. package/dist/chunks/{chunk-XEKFVRIO.js.map → chunk-E4GR4K26.js.map} +1 -1
  11. package/dist/chunks/{chunk-PT5ASWGQ.js → chunk-TN75CWLX.js} +9 -1
  12. package/dist/chunks/{chunk-PT5ASWGQ.js.map → chunk-TN75CWLX.js.map} +1 -1
  13. package/dist/exports/qti-test.d.ts +2 -2
  14. package/dist/index.d.ts +2 -3
  15. package/dist/index.js +16 -14
  16. package/dist/index.js.map +1 -1
  17. package/dist/item.css +8 -0
  18. package/dist/qti-components/index.d.ts +5 -3
  19. package/dist/qti-components/index.js +4 -2
  20. package/dist/qti-components-jsx.d.ts +23 -22
  21. package/dist/qti-item/index.js +2 -2
  22. package/dist/{qti-modal-feedback-PKbhO-3w.d.ts → qti-modal-feedback-Cp3CHVKw.d.ts} +1 -1
  23. package/dist/qti-test/index.d.ts +5 -6
  24. package/dist/qti-test/index.js +3 -3
  25. package/dist/{qti-test-Db7oNIWY.d.ts → qti-test-mmY8zNIj.d.ts} +1 -1
  26. package/dist/vscode.html-custom-data.json +7 -7
  27. package/package.json +10 -10
  28. package/dist/chunks/chunk-TISKSGJE.js.map +0 -1
  29. package/dist/chunks/chunk-YD7FVKDP.js.map +0 -1
  30. /package/dist/chunks/{chunk-7567ZPN6.js.map → chunk-DGBI4IU5.js.map} +0 -0
package/cdn/index.js CHANGED
@@ -1,7 +1,7 @@
1
- var rn=Object.defineProperty;var sn=Object.getOwnPropertyDescriptor;var c=(o,r,e,t)=>{for(var i=t>1?void 0:t?sn(r,e):r,s=o.length-1,n;s>=0;s--)(n=o[s])&&(i=(t?n(r,e,i):n(i))||i);return t&&i&&rn(r,e,i),i};var Re=class extends Event{constructor(r,e,t,i){super("context-request",{bubbles:!0,composed:!0}),this.context=r,this.contextTarget=e,this.callback=t,this.subscribe=i??!1}};var st=class{constructor(r,e,t,i){if(this.subscribe=!1,this.provided=!1,this.value=void 0,this.t=(s,n)=>{this.unsubscribe&&(this.unsubscribe!==n&&(this.provided=!1,this.unsubscribe()),this.subscribe||this.unsubscribe()),this.value=s,this.host.requestUpdate(),this.provided&&!this.subscribe||(this.provided=!0,this.callback&&this.callback(s,n)),this.unsubscribe=n},this.host=r,e.context!==void 0){let s=e;this.context=s.context,this.callback=s.callback,this.subscribe=s.subscribe??!1}else this.context=e,this.callback=t,this.subscribe=i??!1;this.host.addController(this)}hostConnected(){this.dispatchRequest()}hostDisconnected(){this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=void 0)}dispatchRequest(){this.host.dispatchEvent(new Re(this.context,this.host,this.t,this.subscribe))}};var Sr=class{get value(){return this.o}set value(r){this.setValue(r)}setValue(r,e=!1){let t=e||!Object.is(r,this.o);this.o=r,t&&this.updateObservers()}constructor(r){this.subscriptions=new Map,this.updateObservers=()=>{for(let[e,{disposer:t}]of this.subscriptions)e(this.o,t)},r!==void 0&&(this.value=r)}addCallback(r,e,t){if(!t)return void r(this.value);this.subscriptions.has(r)||this.subscriptions.set(r,{disposer:()=>{this.subscriptions.delete(r)},consumerHost:e});let{disposer:i}=this.subscriptions.get(r);r(this.value,i)}clearCallbacks(){this.subscriptions.clear()}};var vi=class extends Event{constructor(r,e){super("context-provider",{bubbles:!0,composed:!0}),this.context=r,this.contextTarget=e}},ot=class extends Sr{constructor(r,e,t){super(e.context!==void 0?e.initialValue:t),this.onContextRequest=i=>{if(i.context!==this.context)return;let s=i.contextTarget??i.composedPath()[0];s!==this.host&&(i.stopPropagation(),this.addCallback(i.callback,s,i.subscribe))},this.onProviderRequest=i=>{if(i.context!==this.context||(i.contextTarget??i.composedPath()[0])===this.host)return;let s=new Set;for(let[n,{consumerHost:a}]of this.subscriptions)s.has(n)||(s.add(n),a.dispatchEvent(new Re(this.context,a,n,!0)));i.stopPropagation()},this.host=r,e.context!==void 0?this.context=e.context:this.context=e,this.attachListeners(),this.host.addController?.(this)}attachListeners(){this.host.addEventListener("context-request",this.onContextRequest),this.host.addEventListener("context-provider",this.onProviderRequest)}hostConnected(){this.host.dispatchEvent(new vi(this.context,this.host))}};function X({context:o}){return(r,e)=>{let t=new WeakMap;if(typeof e=="object")return{get(){return r.get.call(this)},set(i){return t.get(this).setValue(i),r.set.call(this,i)},init(i){return t.set(this,new ot(this,{context:o,initialValue:i})),i}};{r.constructor.addInitializer((n=>{t.set(n,new ot(n,{context:o}))}));let i=Object.getOwnPropertyDescriptor(r,e),s;if(i===void 0){let n=new WeakMap;s={get(){return n.get(this)},set(a){t.get(this).setValue(a),n.set(this,a)},configurable:!0,enumerable:!0}}else{let n=i.set;s={...i,set(a){t.get(this).setValue(a),n?.call(this,a)}}}return void Object.defineProperty(r,e,s)}}}function _({context:o,subscribe:r}){return(e,t)=>{typeof t=="object"?t.addInitializer((function(){new st(this,{context:o,callback:i=>{e.set.call(this,i)},subscribe:r})})):e.constructor.addInitializer((i=>{new st(i,{context:o,callback:s=>{i[t]=s},subscribe:r})}))}}var ks=class{get shadowRoot(){return this.__host.__shadowRoot}constructor(r){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=r}checkValidity(){return console.warn("`ElementInternals.checkValidity()` was called on the server.This method always returns true."),!0}reportValidity(){return!0}setFormValue(){}setValidity(){}};var re=function(o,r,e,t,i){if(t==="m")throw new TypeError("Private method is not writable");if(t==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof r=="function"?o!==r||!i:!r.has(o))throw new TypeError("Cannot write private member to an object whose class did not declare it");return t==="a"?i.call(o,e):i?i.value=e:r.set(o,e),e},D=function(o,r,e,t){if(e==="a"&&!t)throw new TypeError("Private accessor was defined without a getter");if(typeof r=="function"?o!==r||!t:!r.has(o))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?t:e==="a"?t.call(o):t?t.value:r.get(o)},nt,Rr,Mr,Mt,yi,It,Ir,Be,Lt,Me,Lr,Ss,Rs=o=>typeof o=="boolean"?o:o?.capture??!1;var xi=class{constructor(){this.__eventListeners=new Map,this.__captureEventListeners=new Map}addEventListener(r,e,t){if(e==null)return;let i=Rs(t)?this.__captureEventListeners:this.__eventListeners,s=i.get(r);if(s===void 0)s=new Map,i.set(r,s);else if(s.has(e))return;let n=typeof t=="object"&&t?t:{};n.signal?.addEventListener("abort",()=>this.removeEventListener(r,e,t)),s.set(e,n??{})}removeEventListener(r,e,t){if(e==null)return;let i=Rs(t)?this.__captureEventListeners:this.__eventListeners,s=i.get(r);s!==void 0&&(s.delete(e),s.size||i.delete(r))}dispatchEvent(r){let e=[this],t=this.__eventTargetParent;if(r.composed)for(;t;)e.push(t),t=t.__eventTargetParent;else for(;t&&t!==this.__host;)e.push(t),t=t.__eventTargetParent;let i=!1,s=!1,n=0,a=null,l=null,d=null,p=r.stopPropagation,m=r.stopImmediatePropagation;Object.defineProperties(r,{target:{get(){return a??l},...L},srcElement:{get(){return r.target},...L},currentTarget:{get(){return d},...L},eventPhase:{get(){return n},...L},composedPath:{value:()=>e,...L},stopPropagation:{value:()=>{i=!0,p.call(r)},...L},stopImmediatePropagation:{value:()=>{s=!0,m.call(r)},...L}});let f=(q,T,M)=>{typeof q=="function"?q(r):typeof q?.handleEvent=="function"&&q.handleEvent(r),T.once&&M.delete(q)},b=()=>(d=null,n=0,!r.defaultPrevented),y=e.slice().reverse();a=!this.__host||!r.composed?this:null;let E=q=>{for(l=this;l.__host&&q.includes(l.__host);)l=l.__host};for(let q of y){!a&&(!l||l===q.__host)&&E(y.slice(y.indexOf(q))),d=q,n=q===r.target?2:1;let T=q.__captureEventListeners.get(r.type);if(T){for(let[M,O]of T)if(f(M,O,T),s)return b()}if(i)return b()}let S=r.bubbles?e:[this];l=null;for(let q of S){!a&&(!l||q===l.__host)&&E(S.slice(0,S.indexOf(q)+1)),d=q,n=q===r.target?2:3;let T=q.__eventListeners.get(r.type);if(T){for(let[M,O]of T)if(f(M,O,T),s)return b()}if(i)return b()}return b()}},qi=xi;var L={__proto__:null};L.enumerable=!0;Object.freeze(L);var Ci=(Me=class{constructor(r,e={}){if(nt.set(this,!1),Rr.set(this,!1),Mr.set(this,!1),Mt.set(this,!1),yi.set(this,Date.now()),It.set(this,!1),Ir.set(this,void 0),Be.set(this,void 0),Lt.set(this,void 0),this.NONE=0,this.CAPTURING_PHASE=1,this.AT_TARGET=2,this.BUBBLING_PHASE=3,arguments.length===0)throw new Error("The type argument must be specified");if(typeof e!="object"||!e)throw new Error('The "options" argument must be an object');let{bubbles:t,cancelable:i,composed:s}=e;re(this,nt,!!i,"f"),re(this,Rr,!!t,"f"),re(this,Mr,!!s,"f"),re(this,Ir,`${r}`,"f"),re(this,Be,null,"f"),re(this,Lt,!1,"f")}initEvent(r,e,t){throw new Error("Method not implemented.")}stopImmediatePropagation(){this.stopPropagation()}preventDefault(){re(this,Mt,!0,"f")}get target(){return D(this,Be,"f")}get currentTarget(){return D(this,Be,"f")}get srcElement(){return D(this,Be,"f")}get type(){return D(this,Ir,"f")}get cancelable(){return D(this,nt,"f")}get defaultPrevented(){return D(this,nt,"f")&&D(this,Mt,"f")}get timeStamp(){return D(this,yi,"f")}composedPath(){return D(this,Lt,"f")?[D(this,Be,"f")]:[]}get returnValue(){return!D(this,nt,"f")||!D(this,Mt,"f")}get bubbles(){return D(this,Rr,"f")}get composed(){return D(this,Mr,"f")}get eventPhase(){return D(this,Lt,"f")?Me.AT_TARGET:Me.NONE}get cancelBubble(){return D(this,It,"f")}set cancelBubble(r){r&&re(this,It,!0,"f")}stopPropagation(){re(this,It,!0,"f")}get isTrusted(){return!1}},nt=new WeakMap,Rr=new WeakMap,Mr=new WeakMap,Mt=new WeakMap,yi=new WeakMap,It=new WeakMap,Ir=new WeakMap,Be=new WeakMap,Lt=new WeakMap,Me.NONE=0,Me.CAPTURING_PHASE=1,Me.AT_TARGET=2,Me.BUBBLING_PHASE=3,Me);Object.defineProperties(Ci.prototype,{initEvent:L,stopImmediatePropagation:L,preventDefault:L,target:L,currentTarget:L,srcElement:L,type:L,cancelable:L,defaultPrevented:L,timeStamp:L,composedPath:L,returnValue:L,bubbles:L,composed:L,eventPhase:L,cancelBubble:L,stopPropagation:L,isTrusted:L});var Ms=(Ss=class extends Ci{constructor(r,e={}){super(r,e),Lr.set(this,void 0),re(this,Lr,e?.detail??null,"f")}initCustomEvent(r,e,t,i){throw new Error("Method not implemented.")}get detail(){return D(this,Lr,"f")}},Lr=new WeakMap,Ss);Object.defineProperties(Ms.prototype,{detail:L});var Ei=Ci,wi=Ms;globalThis.Event??=Ei;globalThis.CustomEvent??=wi;var Is=new WeakMap,$t=o=>{let r=Is.get(o);return r===void 0&&Is.set(o,r=new Map),r},on=class extends qi{constructor(){super(...arguments),this.__shadowRootMode=null,this.__shadowRoot=null,this.__internals=null}get attributes(){return Array.from($t(this)).map(([r,e])=>({name:r,value:e}))}get shadowRoot(){return this.__shadowRootMode==="closed"?null:this.__shadowRoot}get localName(){return this.constructor.__localName}get tagName(){return this.localName?.toUpperCase()}setAttribute(r,e){$t(this).set(r,String(e))}removeAttribute(r){$t(this).delete(r)}toggleAttribute(r,e){if(this.hasAttribute(r)){if(e===void 0||!e)return this.removeAttribute(r),!1}else return e===void 0||e?(this.setAttribute(r,""),!0):!1;return!0}hasAttribute(r){return $t(this).has(r)}attachShadow(r){let e={host:this};return this.__shadowRootMode=r.mode,r&&r.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 r=new ks(this);return this.__internals=r,r}getAttribute(r){return $t(this).get(r)??null}};var nn=class extends on{},Ti=nn;globalThis.litServerRoot??=Object.defineProperty(new Ti,"localName",{get(){return"lit-server-root"}});function an(){let o,r;return{promise:new Promise((t,i)=>{o=t,r=i}),resolve:o,reject:r}}var _i=class{constructor(){this.__definitions=new Map,this.__reverseDefinitions=new Map,this.__pendingWhenDefineds=new Map}define(r,e){if(this.__definitions.has(r))if(process.env.NODE_ENV==="development")console.warn(`'CustomElementRegistry' already has "${r}" 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 "${r}" has already been used with this registry`);if(this.__reverseDefinitions.has(e))throw new Error(`Failed to execute 'define' on 'CustomElementRegistry': the constructor has already been used with this registry for the tag name ${this.__reverseDefinitions.get(e)}`);e.__localName=r,this.__definitions.set(r,{ctor:e,observedAttributes:e.observedAttributes??[]}),this.__reverseDefinitions.set(e,r),this.__pendingWhenDefineds.get(r)?.resolve(e),this.__pendingWhenDefineds.delete(r)}get(r){return this.__definitions.get(r)?.ctor}getName(r){return this.__reverseDefinitions.get(r)??null}upgrade(r){throw new Error("customElements.upgrade is not currently supported in SSR. Please file a bug if you need it.")}async whenDefined(r){let e=this.__definitions.get(r);if(e)return e.ctor;let t=this.__pendingWhenDefineds.get(r);return t||(t=an(),this.__pendingWhenDefineds.set(r,t)),t.promise}},ln=_i;var Ls=new ln;var Pt=globalThis,$r=Pt.ShadowRoot&&(Pt.ShadyCSS===void 0||Pt.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Ai=Symbol(),$s=new WeakMap,Vt=class{constructor(r,e,t){if(this._$cssResult$=!0,t!==Ai)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=r,this.t=e}get styleSheet(){let r=this.o,e=this.t;if($r&&r===void 0){let t=e!==void 0&&e.length===1;t&&(r=$s.get(e)),r===void 0&&((this.o=r=new CSSStyleSheet).replaceSync(this.cssText),t&&$s.set(e,r))}return r}toString(){return this.cssText}},Ps=o=>new Vt(typeof o=="string"?o:o+"",void 0,Ai),x=(o,...r)=>{let e=o.length===1?o[0]:r.reduce(((t,i,s)=>t+(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)+o[s+1]),o[0]);return new Vt(e,o,Ai)},Vs=(o,r)=>{if($r)o.adoptedStyleSheets=r.map((e=>e instanceof CSSStyleSheet?e:e.styleSheet));else for(let e of r){let t=document.createElement("style"),i=Pt.litNonce;i!==void 0&&t.setAttribute("nonce",i),t.textContent=e.cssText,o.appendChild(t)}},ki=$r||Pt.CSSStyleSheet===void 0?o=>o:o=>o instanceof CSSStyleSheet?(r=>{let e="";for(let t of r.cssRules)e+=t.cssText;return Ps(e)})(o):o;var{is:cn,defineProperty:dn,getOwnPropertyDescriptor:pn,getOwnPropertyNames:un,getOwnPropertySymbols:mn,getPrototypeOf:hn}=Object,Dt=globalThis;Dt.customElements??=Ls;var Os=Dt.trustedTypes,fn=Os?Os.emptyScript:"",gn=Dt.reactiveElementPolyfillSupport,Ot=(o,r)=>o,Nt={toAttribute(o,r){switch(r){case Boolean:o=o?fn:null;break;case Object:case Array:o=o==null?o:JSON.stringify(o)}return o},fromAttribute(o,r){let e=o;switch(r){case Boolean:e=o!==null;break;case Number:e=o===null?null:Number(o);break;case Object:case Array:try{e=JSON.parse(o)}catch{e=null}}return e}},Pr=(o,r)=>!cn(o,r),Ns={attribute:!0,type:String,converter:Nt,reflect:!1,useDefault:!1,hasChanged:Pr};Symbol.metadata??=Symbol("metadata"),Dt.litPropertyMetadata??=new WeakMap;var ge=class extends(globalThis.HTMLElement??Ti){static addInitializer(r){this._$Ei(),(this.l??=[]).push(r)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(r,e=Ns){if(e.state&&(e.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(r)&&((e=Object.create(e)).wrapped=!0),this.elementProperties.set(r,e),!e.noAccessor){let t=Symbol(),i=this.getPropertyDescriptor(r,t,e);i!==void 0&&dn(this.prototype,r,i)}}static getPropertyDescriptor(r,e,t){let{get:i,set:s}=pn(this.prototype,r)??{get(){return this[e]},set(n){this[e]=n}};return{get:i,set(n){let a=i?.call(this);s?.call(this,n),this.requestUpdate(r,a,t)},configurable:!0,enumerable:!0}}static getPropertyOptions(r){return this.elementProperties.get(r)??Ns}static _$Ei(){if(this.hasOwnProperty(Ot("elementProperties")))return;let r=hn(this);r.finalize(),r.l!==void 0&&(this.l=[...r.l]),this.elementProperties=new Map(r.elementProperties)}static finalize(){if(this.hasOwnProperty(Ot("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(Ot("properties"))){let e=this.properties,t=[...un(e),...mn(e)];for(let i of t)this.createProperty(i,e[i])}let r=this[Symbol.metadata];if(r!==null){let e=litPropertyMetadata.get(r);if(e!==void 0)for(let[t,i]of e)this.elementProperties.set(t,i)}this._$Eh=new Map;for(let[e,t]of this.elementProperties){let i=this._$Eu(e,t);i!==void 0&&this._$Eh.set(i,e)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(r){let e=[];if(Array.isArray(r)){let t=new Set(r.flat(1/0).reverse());for(let i of t)e.unshift(ki(i))}else r!==void 0&&e.push(ki(r));return e}static _$Eu(r,e){let t=e.attribute;return t===!1?void 0:typeof t=="string"?t:typeof r=="string"?r.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise((r=>this.enableUpdating=r)),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach((r=>r(this)))}addController(r){(this._$EO??=new Set).add(r),this.renderRoot!==void 0&&this.isConnected&&r.hostConnected?.()}removeController(r){this._$EO?.delete(r)}_$E_(){let r=new Map,e=this.constructor.elementProperties;for(let t of e.keys())this.hasOwnProperty(t)&&(r.set(t,this[t]),delete this[t]);r.size>0&&(this._$Ep=r)}createRenderRoot(){let r=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return Vs(r,this.constructor.elementStyles),r}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach((r=>r.hostConnected?.()))}enableUpdating(r){}disconnectedCallback(){this._$EO?.forEach((r=>r.hostDisconnected?.()))}attributeChangedCallback(r,e,t){this._$AK(r,t)}_$ET(r,e){let t=this.constructor.elementProperties.get(r),i=this.constructor._$Eu(r,t);if(i!==void 0&&t.reflect===!0){let s=(t.converter?.toAttribute!==void 0?t.converter:Nt).toAttribute(e,t.type);this._$Em=r,s==null?this.removeAttribute(i):this.setAttribute(i,s),this._$Em=null}}_$AK(r,e){let t=this.constructor,i=t._$Eh.get(r);if(i!==void 0&&this._$Em!==i){let s=t.getPropertyOptions(i),n=typeof s.converter=="function"?{fromAttribute:s.converter}:s.converter?.fromAttribute!==void 0?s.converter:Nt;this._$Em=i;let a=n.fromAttribute(e,s.type);this[i]=a??this._$Ej?.get(i)??a,this._$Em=null}}requestUpdate(r,e,t){if(r!==void 0){let i=this.constructor,s=this[r];if(t??=i.getPropertyOptions(r),!((t.hasChanged??Pr)(s,e)||t.useDefault&&t.reflect&&s===this._$Ej?.get(r)&&!this.hasAttribute(i._$Eu(r,t))))return;this.C(r,e,t)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(r,e,{useDefault:t,reflect:i,wrapped:s},n){t&&!(this._$Ej??=new Map).has(r)&&(this._$Ej.set(r,n??e??this[r]),s!==!0||n!==void 0)||(this._$AL.has(r)||(this.hasUpdated||t||(e=void 0),this._$AL.set(r,e)),i===!0&&this._$Em!==r&&(this._$Eq??=new Set).add(r))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(e){Promise.reject(e)}let r=this.scheduleUpdate();return r!=null&&await r,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(let[i,s]of this._$Ep)this[i]=s;this._$Ep=void 0}let t=this.constructor.elementProperties;if(t.size>0)for(let[i,s]of t){let{wrapped:n}=s,a=this[i];n!==!0||this._$AL.has(i)||a===void 0||this.C(i,void 0,s,a)}}let r=!1,e=this._$AL;try{r=this.shouldUpdate(e),r?(this.willUpdate(e),this._$EO?.forEach((t=>t.hostUpdate?.())),this.update(e)):this._$EM()}catch(t){throw r=!1,this._$EM(),t}r&&this._$AE(e)}willUpdate(r){}_$AE(r){this._$EO?.forEach((e=>e.hostUpdated?.())),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(r)),this.updated(r)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(r){return!0}update(r){this._$Eq&&=this._$Eq.forEach((e=>this._$ET(e,this[e]))),this._$EM()}updated(r){}firstUpdated(r){}};ge.elementStyles=[],ge.shadowRootOptions={mode:"open"},ge[Ot("elementProperties")]=new Map,ge[Ot("finalized")]=new Map,gn?.({ReactiveElement:ge}),(Dt.reactiveElementVersions??=[]).push("2.1.1");var Fr=globalThis,Vr=Fr.trustedTypes,Ds=Vr?Vr.createPolicy("lit-html",{createHTML:o=>o}):void 0,Ri="$lit$",be=`lit$${Math.random().toFixed(9).slice(2)}$`,Mi="?"+be,bn=`<${Mi}>`,Ge=Fr.document===void 0?{createTreeWalker:()=>({})}:document,zt=()=>Ge.createComment(""),Ft=o=>o===null||typeof o!="object"&&typeof o!="function",Ii=Array.isArray,Bs=o=>Ii(o)||typeof o?.[Symbol.iterator]=="function",Si=`[
1
+ var rn=Object.defineProperty;var sn=Object.getOwnPropertyDescriptor;var c=(o,r,e,t)=>{for(var i=t>1?void 0:t?sn(r,e):r,s=o.length-1,n;s>=0;s--)(n=o[s])&&(i=(t?n(r,e,i):n(i))||i);return t&&i&&rn(r,e,i),i};var Re=class extends Event{constructor(r,e,t,i){super("context-request",{bubbles:!0,composed:!0}),this.context=r,this.contextTarget=e,this.callback=t,this.subscribe=i??!1}};var st=class{constructor(r,e,t,i){if(this.subscribe=!1,this.provided=!1,this.value=void 0,this.t=(s,n)=>{this.unsubscribe&&(this.unsubscribe!==n&&(this.provided=!1,this.unsubscribe()),this.subscribe||this.unsubscribe()),this.value=s,this.host.requestUpdate(),this.provided&&!this.subscribe||(this.provided=!0,this.callback&&this.callback(s,n)),this.unsubscribe=n},this.host=r,e.context!==void 0){let s=e;this.context=s.context,this.callback=s.callback,this.subscribe=s.subscribe??!1}else this.context=e,this.callback=t,this.subscribe=i??!1;this.host.addController(this)}hostConnected(){this.dispatchRequest()}hostDisconnected(){this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=void 0)}dispatchRequest(){this.host.dispatchEvent(new Re(this.context,this.host,this.t,this.subscribe))}};var Sr=class{get value(){return this.o}set value(r){this.setValue(r)}setValue(r,e=!1){let t=e||!Object.is(r,this.o);this.o=r,t&&this.updateObservers()}constructor(r){this.subscriptions=new Map,this.updateObservers=()=>{for(let[e,{disposer:t}]of this.subscriptions)e(this.o,t)},r!==void 0&&(this.value=r)}addCallback(r,e,t){if(!t)return void r(this.value);this.subscriptions.has(r)||this.subscriptions.set(r,{disposer:()=>{this.subscriptions.delete(r)},consumerHost:e});let{disposer:i}=this.subscriptions.get(r);r(this.value,i)}clearCallbacks(){this.subscriptions.clear()}};var vi=class extends Event{constructor(r,e){super("context-provider",{bubbles:!0,composed:!0}),this.context=r,this.contextTarget=e}},ot=class extends Sr{constructor(r,e,t){super(e.context!==void 0?e.initialValue:t),this.onContextRequest=i=>{if(i.context!==this.context)return;let s=i.contextTarget??i.composedPath()[0];s!==this.host&&(i.stopPropagation(),this.addCallback(i.callback,s,i.subscribe))},this.onProviderRequest=i=>{if(i.context!==this.context||(i.contextTarget??i.composedPath()[0])===this.host)return;let s=new Set;for(let[n,{consumerHost:a}]of this.subscriptions)s.has(n)||(s.add(n),a.dispatchEvent(new Re(this.context,a,n,!0)));i.stopPropagation()},this.host=r,e.context!==void 0?this.context=e.context:this.context=e,this.attachListeners(),this.host.addController?.(this)}attachListeners(){this.host.addEventListener("context-request",this.onContextRequest),this.host.addEventListener("context-provider",this.onProviderRequest)}hostConnected(){this.host.dispatchEvent(new vi(this.context,this.host))}};function G({context:o}){return(r,e)=>{let t=new WeakMap;if(typeof e=="object")return{get(){return r.get.call(this)},set(i){return t.get(this).setValue(i),r.set.call(this,i)},init(i){return t.set(this,new ot(this,{context:o,initialValue:i})),i}};{r.constructor.addInitializer((n=>{t.set(n,new ot(n,{context:o}))}));let i=Object.getOwnPropertyDescriptor(r,e),s;if(i===void 0){let n=new WeakMap;s={get(){return n.get(this)},set(a){t.get(this).setValue(a),n.set(this,a)},configurable:!0,enumerable:!0}}else{let n=i.set;s={...i,set(a){t.get(this).setValue(a),n?.call(this,a)}}}return void Object.defineProperty(r,e,s)}}}function _({context:o,subscribe:r}){return(e,t)=>{typeof t=="object"?t.addInitializer((function(){new st(this,{context:o,callback:i=>{e.set.call(this,i)},subscribe:r})})):e.constructor.addInitializer((i=>{new st(i,{context:o,callback:s=>{i[t]=s},subscribe:r})}))}}var ks=class{get shadowRoot(){return this.__host.__shadowRoot}constructor(r){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=r}checkValidity(){return console.warn("`ElementInternals.checkValidity()` was called on the server.This method always returns true."),!0}reportValidity(){return!0}setFormValue(){}setValidity(){}};var re=function(o,r,e,t,i){if(t==="m")throw new TypeError("Private method is not writable");if(t==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof r=="function"?o!==r||!i:!r.has(o))throw new TypeError("Cannot write private member to an object whose class did not declare it");return t==="a"?i.call(o,e):i?i.value=e:r.set(o,e),e},N=function(o,r,e,t){if(e==="a"&&!t)throw new TypeError("Private accessor was defined without a getter");if(typeof r=="function"?o!==r||!t:!r.has(o))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?t:e==="a"?t.call(o):t?t.value:r.get(o)},nt,Rr,Mr,Mt,yi,It,Ir,Be,Lt,Me,Lr,Ss,Rs=o=>typeof o=="boolean"?o:o?.capture??!1;var xi=class{constructor(){this.__eventListeners=new Map,this.__captureEventListeners=new Map}addEventListener(r,e,t){if(e==null)return;let i=Rs(t)?this.__captureEventListeners:this.__eventListeners,s=i.get(r);if(s===void 0)s=new Map,i.set(r,s);else if(s.has(e))return;let n=typeof t=="object"&&t?t:{};n.signal?.addEventListener("abort",()=>this.removeEventListener(r,e,t)),s.set(e,n??{})}removeEventListener(r,e,t){if(e==null)return;let i=Rs(t)?this.__captureEventListeners:this.__eventListeners,s=i.get(r);s!==void 0&&(s.delete(e),s.size||i.delete(r))}dispatchEvent(r){let e=[this],t=this.__eventTargetParent;if(r.composed)for(;t;)e.push(t),t=t.__eventTargetParent;else for(;t&&t!==this.__host;)e.push(t),t=t.__eventTargetParent;let i=!1,s=!1,n=0,a=null,l=null,d=null,p=r.stopPropagation,m=r.stopImmediatePropagation;Object.defineProperties(r,{target:{get(){return a??l},...L},srcElement:{get(){return r.target},...L},currentTarget:{get(){return d},...L},eventPhase:{get(){return n},...L},composedPath:{value:()=>e,...L},stopPropagation:{value:()=>{i=!0,p.call(r)},...L},stopImmediatePropagation:{value:()=>{s=!0,m.call(r)},...L}});let f=(q,T,M)=>{typeof q=="function"?q(r):typeof q?.handleEvent=="function"&&q.handleEvent(r),T.once&&M.delete(q)},b=()=>(d=null,n=0,!r.defaultPrevented),y=e.slice().reverse();a=!this.__host||!r.composed?this:null;let C=q=>{for(l=this;l.__host&&q.includes(l.__host);)l=l.__host};for(let q of y){!a&&(!l||l===q.__host)&&C(y.slice(y.indexOf(q))),d=q,n=q===r.target?2:1;let T=q.__captureEventListeners.get(r.type);if(T){for(let[M,O]of T)if(f(M,O,T),s)return b()}if(i)return b()}let A=r.bubbles?e:[this];l=null;for(let q of A){!a&&(!l||q===l.__host)&&C(A.slice(0,A.indexOf(q)+1)),d=q,n=q===r.target?2:3;let T=q.__eventListeners.get(r.type);if(T){for(let[M,O]of T)if(f(M,O,T),s)return b()}if(i)return b()}return b()}},qi=xi;var L={__proto__:null};L.enumerable=!0;Object.freeze(L);var Ci=(Me=class{constructor(r,e={}){if(nt.set(this,!1),Rr.set(this,!1),Mr.set(this,!1),Mt.set(this,!1),yi.set(this,Date.now()),It.set(this,!1),Ir.set(this,void 0),Be.set(this,void 0),Lt.set(this,void 0),this.NONE=0,this.CAPTURING_PHASE=1,this.AT_TARGET=2,this.BUBBLING_PHASE=3,arguments.length===0)throw new Error("The type argument must be specified");if(typeof e!="object"||!e)throw new Error('The "options" argument must be an object');let{bubbles:t,cancelable:i,composed:s}=e;re(this,nt,!!i,"f"),re(this,Rr,!!t,"f"),re(this,Mr,!!s,"f"),re(this,Ir,`${r}`,"f"),re(this,Be,null,"f"),re(this,Lt,!1,"f")}initEvent(r,e,t){throw new Error("Method not implemented.")}stopImmediatePropagation(){this.stopPropagation()}preventDefault(){re(this,Mt,!0,"f")}get target(){return N(this,Be,"f")}get currentTarget(){return N(this,Be,"f")}get srcElement(){return N(this,Be,"f")}get type(){return N(this,Ir,"f")}get cancelable(){return N(this,nt,"f")}get defaultPrevented(){return N(this,nt,"f")&&N(this,Mt,"f")}get timeStamp(){return N(this,yi,"f")}composedPath(){return N(this,Lt,"f")?[N(this,Be,"f")]:[]}get returnValue(){return!N(this,nt,"f")||!N(this,Mt,"f")}get bubbles(){return N(this,Rr,"f")}get composed(){return N(this,Mr,"f")}get eventPhase(){return N(this,Lt,"f")?Me.AT_TARGET:Me.NONE}get cancelBubble(){return N(this,It,"f")}set cancelBubble(r){r&&re(this,It,!0,"f")}stopPropagation(){re(this,It,!0,"f")}get isTrusted(){return!1}},nt=new WeakMap,Rr=new WeakMap,Mr=new WeakMap,Mt=new WeakMap,yi=new WeakMap,It=new WeakMap,Ir=new WeakMap,Be=new WeakMap,Lt=new WeakMap,Me.NONE=0,Me.CAPTURING_PHASE=1,Me.AT_TARGET=2,Me.BUBBLING_PHASE=3,Me);Object.defineProperties(Ci.prototype,{initEvent:L,stopImmediatePropagation:L,preventDefault:L,target:L,currentTarget:L,srcElement:L,type:L,cancelable:L,defaultPrevented:L,timeStamp:L,composedPath:L,returnValue:L,bubbles:L,composed:L,eventPhase:L,cancelBubble:L,stopPropagation:L,isTrusted:L});var Ms=(Ss=class extends Ci{constructor(r,e={}){super(r,e),Lr.set(this,void 0),re(this,Lr,e?.detail??null,"f")}initCustomEvent(r,e,t,i){throw new Error("Method not implemented.")}get detail(){return N(this,Lr,"f")}},Lr=new WeakMap,Ss);Object.defineProperties(Ms.prototype,{detail:L});var Ei=Ci,wi=Ms;globalThis.Event??=Ei;globalThis.CustomEvent??=wi;var Is=new WeakMap,$t=o=>{let r=Is.get(o);return r===void 0&&Is.set(o,r=new Map),r},on=class extends qi{constructor(){super(...arguments),this.__shadowRootMode=null,this.__shadowRoot=null,this.__internals=null}get attributes(){return Array.from($t(this)).map(([r,e])=>({name:r,value:e}))}get shadowRoot(){return this.__shadowRootMode==="closed"?null:this.__shadowRoot}get localName(){return this.constructor.__localName}get tagName(){return this.localName?.toUpperCase()}setAttribute(r,e){$t(this).set(r,String(e))}removeAttribute(r){$t(this).delete(r)}toggleAttribute(r,e){if(this.hasAttribute(r)){if(e===void 0||!e)return this.removeAttribute(r),!1}else return e===void 0||e?(this.setAttribute(r,""),!0):!1;return!0}hasAttribute(r){return $t(this).has(r)}attachShadow(r){let e={host:this};return this.__shadowRootMode=r.mode,r&&r.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 r=new ks(this);return this.__internals=r,r}getAttribute(r){return $t(this).get(r)??null}};var nn=class extends on{},Ti=nn;globalThis.litServerRoot??=Object.defineProperty(new Ti,"localName",{get(){return"lit-server-root"}});function an(){let o,r;return{promise:new Promise((t,i)=>{o=t,r=i}),resolve:o,reject:r}}var _i=class{constructor(){this.__definitions=new Map,this.__reverseDefinitions=new Map,this.__pendingWhenDefineds=new Map}define(r,e){if(this.__definitions.has(r))if(process.env.NODE_ENV==="development")console.warn(`'CustomElementRegistry' already has "${r}" 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 "${r}" has already been used with this registry`);if(this.__reverseDefinitions.has(e))throw new Error(`Failed to execute 'define' on 'CustomElementRegistry': the constructor has already been used with this registry for the tag name ${this.__reverseDefinitions.get(e)}`);e.__localName=r,this.__definitions.set(r,{ctor:e,observedAttributes:e.observedAttributes??[]}),this.__reverseDefinitions.set(e,r),this.__pendingWhenDefineds.get(r)?.resolve(e),this.__pendingWhenDefineds.delete(r)}get(r){return this.__definitions.get(r)?.ctor}getName(r){return this.__reverseDefinitions.get(r)??null}upgrade(r){throw new Error("customElements.upgrade is not currently supported in SSR. Please file a bug if you need it.")}async whenDefined(r){let e=this.__definitions.get(r);if(e)return e.ctor;let t=this.__pendingWhenDefineds.get(r);return t||(t=an(),this.__pendingWhenDefineds.set(r,t)),t.promise}},ln=_i;var Ls=new ln;var Pt=globalThis,$r=Pt.ShadowRoot&&(Pt.ShadyCSS===void 0||Pt.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Ai=Symbol(),$s=new WeakMap,Vt=class{constructor(r,e,t){if(this._$cssResult$=!0,t!==Ai)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=r,this.t=e}get styleSheet(){let r=this.o,e=this.t;if($r&&r===void 0){let t=e!==void 0&&e.length===1;t&&(r=$s.get(e)),r===void 0&&((this.o=r=new CSSStyleSheet).replaceSync(this.cssText),t&&$s.set(e,r))}return r}toString(){return this.cssText}},Ps=o=>new Vt(typeof o=="string"?o:o+"",void 0,Ai),x=(o,...r)=>{let e=o.length===1?o[0]:r.reduce(((t,i,s)=>t+(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)+o[s+1]),o[0]);return new Vt(e,o,Ai)},Vs=(o,r)=>{if($r)o.adoptedStyleSheets=r.map((e=>e instanceof CSSStyleSheet?e:e.styleSheet));else for(let e of r){let t=document.createElement("style"),i=Pt.litNonce;i!==void 0&&t.setAttribute("nonce",i),t.textContent=e.cssText,o.appendChild(t)}},ki=$r||Pt.CSSStyleSheet===void 0?o=>o:o=>o instanceof CSSStyleSheet?(r=>{let e="";for(let t of r.cssRules)e+=t.cssText;return Ps(e)})(o):o;var{is:cn,defineProperty:dn,getOwnPropertyDescriptor:pn,getOwnPropertyNames:un,getOwnPropertySymbols:mn,getPrototypeOf:hn}=Object,Nt=globalThis;Nt.customElements??=Ls;var Os=Nt.trustedTypes,fn=Os?Os.emptyScript:"",gn=Nt.reactiveElementPolyfillSupport,Ot=(o,r)=>o,Dt={toAttribute(o,r){switch(r){case Boolean:o=o?fn:null;break;case Object:case Array:o=o==null?o:JSON.stringify(o)}return o},fromAttribute(o,r){let e=o;switch(r){case Boolean:e=o!==null;break;case Number:e=o===null?null:Number(o);break;case Object:case Array:try{e=JSON.parse(o)}catch{e=null}}return e}},Pr=(o,r)=>!cn(o,r),Ds={attribute:!0,type:String,converter:Dt,reflect:!1,useDefault:!1,hasChanged:Pr};Symbol.metadata??=Symbol("metadata"),Nt.litPropertyMetadata??=new WeakMap;var ge=class extends(globalThis.HTMLElement??Ti){static addInitializer(r){this._$Ei(),(this.l??=[]).push(r)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(r,e=Ds){if(e.state&&(e.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(r)&&((e=Object.create(e)).wrapped=!0),this.elementProperties.set(r,e),!e.noAccessor){let t=Symbol(),i=this.getPropertyDescriptor(r,t,e);i!==void 0&&dn(this.prototype,r,i)}}static getPropertyDescriptor(r,e,t){let{get:i,set:s}=pn(this.prototype,r)??{get(){return this[e]},set(n){this[e]=n}};return{get:i,set(n){let a=i?.call(this);s?.call(this,n),this.requestUpdate(r,a,t)},configurable:!0,enumerable:!0}}static getPropertyOptions(r){return this.elementProperties.get(r)??Ds}static _$Ei(){if(this.hasOwnProperty(Ot("elementProperties")))return;let r=hn(this);r.finalize(),r.l!==void 0&&(this.l=[...r.l]),this.elementProperties=new Map(r.elementProperties)}static finalize(){if(this.hasOwnProperty(Ot("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(Ot("properties"))){let e=this.properties,t=[...un(e),...mn(e)];for(let i of t)this.createProperty(i,e[i])}let r=this[Symbol.metadata];if(r!==null){let e=litPropertyMetadata.get(r);if(e!==void 0)for(let[t,i]of e)this.elementProperties.set(t,i)}this._$Eh=new Map;for(let[e,t]of this.elementProperties){let i=this._$Eu(e,t);i!==void 0&&this._$Eh.set(i,e)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(r){let e=[];if(Array.isArray(r)){let t=new Set(r.flat(1/0).reverse());for(let i of t)e.unshift(ki(i))}else r!==void 0&&e.push(ki(r));return e}static _$Eu(r,e){let t=e.attribute;return t===!1?void 0:typeof t=="string"?t:typeof r=="string"?r.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise((r=>this.enableUpdating=r)),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach((r=>r(this)))}addController(r){(this._$EO??=new Set).add(r),this.renderRoot!==void 0&&this.isConnected&&r.hostConnected?.()}removeController(r){this._$EO?.delete(r)}_$E_(){let r=new Map,e=this.constructor.elementProperties;for(let t of e.keys())this.hasOwnProperty(t)&&(r.set(t,this[t]),delete this[t]);r.size>0&&(this._$Ep=r)}createRenderRoot(){let r=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return Vs(r,this.constructor.elementStyles),r}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach((r=>r.hostConnected?.()))}enableUpdating(r){}disconnectedCallback(){this._$EO?.forEach((r=>r.hostDisconnected?.()))}attributeChangedCallback(r,e,t){this._$AK(r,t)}_$ET(r,e){let t=this.constructor.elementProperties.get(r),i=this.constructor._$Eu(r,t);if(i!==void 0&&t.reflect===!0){let s=(t.converter?.toAttribute!==void 0?t.converter:Dt).toAttribute(e,t.type);this._$Em=r,s==null?this.removeAttribute(i):this.setAttribute(i,s),this._$Em=null}}_$AK(r,e){let t=this.constructor,i=t._$Eh.get(r);if(i!==void 0&&this._$Em!==i){let s=t.getPropertyOptions(i),n=typeof s.converter=="function"?{fromAttribute:s.converter}:s.converter?.fromAttribute!==void 0?s.converter:Dt;this._$Em=i;let a=n.fromAttribute(e,s.type);this[i]=a??this._$Ej?.get(i)??a,this._$Em=null}}requestUpdate(r,e,t){if(r!==void 0){let i=this.constructor,s=this[r];if(t??=i.getPropertyOptions(r),!((t.hasChanged??Pr)(s,e)||t.useDefault&&t.reflect&&s===this._$Ej?.get(r)&&!this.hasAttribute(i._$Eu(r,t))))return;this.C(r,e,t)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(r,e,{useDefault:t,reflect:i,wrapped:s},n){t&&!(this._$Ej??=new Map).has(r)&&(this._$Ej.set(r,n??e??this[r]),s!==!0||n!==void 0)||(this._$AL.has(r)||(this.hasUpdated||t||(e=void 0),this._$AL.set(r,e)),i===!0&&this._$Em!==r&&(this._$Eq??=new Set).add(r))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(e){Promise.reject(e)}let r=this.scheduleUpdate();return r!=null&&await r,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(let[i,s]of this._$Ep)this[i]=s;this._$Ep=void 0}let t=this.constructor.elementProperties;if(t.size>0)for(let[i,s]of t){let{wrapped:n}=s,a=this[i];n!==!0||this._$AL.has(i)||a===void 0||this.C(i,void 0,s,a)}}let r=!1,e=this._$AL;try{r=this.shouldUpdate(e),r?(this.willUpdate(e),this._$EO?.forEach((t=>t.hostUpdate?.())),this.update(e)):this._$EM()}catch(t){throw r=!1,this._$EM(),t}r&&this._$AE(e)}willUpdate(r){}_$AE(r){this._$EO?.forEach((e=>e.hostUpdated?.())),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(r)),this.updated(r)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(r){return!0}update(r){this._$Eq&&=this._$Eq.forEach((e=>this._$ET(e,this[e]))),this._$EM()}updated(r){}firstUpdated(r){}};ge.elementStyles=[],ge.shadowRootOptions={mode:"open"},ge[Ot("elementProperties")]=new Map,ge[Ot("finalized")]=new Map,gn?.({ReactiveElement:ge}),(Nt.reactiveElementVersions??=[]).push("2.1.1");var Fr=globalThis,Vr=Fr.trustedTypes,Ns=Vr?Vr.createPolicy("lit-html",{createHTML:o=>o}):void 0,Ri="$lit$",be=`lit$${Math.random().toFixed(9).slice(2)}$`,Mi="?"+be,bn=`<${Mi}>`,Ge=Fr.document===void 0?{createTreeWalker:()=>({})}:document,zt=()=>Ge.createComment(""),Ft=o=>o===null||typeof o!="object"&&typeof o!="function",Ii=Array.isArray,Bs=o=>Ii(o)||typeof o?.[Symbol.iterator]=="function",Si=`[
3
3
  \f\r]`,Ht=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Hs=/-->/g,zs=/>/g,We=RegExp(`>|${Si}(?:([^\\s"'>=/]+)(${Si}*=${Si}*(?:[^
4
- \f\r"'\`<>=]|("|')|))|$)`,"g"),Fs=/'/g,Us=/"/g,Ws=/^(?:script|style|textarea|title)$/i,Li=o=>(r,...e)=>({_$litType$:o,strings:r,values:e}),h=Li(1),Ur=Li(2),Ba=Li(3),V=Symbol.for("lit-noChange"),R=Symbol.for("lit-nothing"),js=new WeakMap,Xe=Ge.createTreeWalker(Ge,129);function Xs(o,r){if(!Ii(o)||!o.hasOwnProperty("raw"))throw Error("invalid template strings array");return Ds!==void 0?Ds.createHTML(r):r}var Gs=(o,r)=>{let e=o.length-1,t=[],i,s=r===2?"<svg>":r===3?"<math>":"",n=Ht;for(let a=0;a<e;a++){let l=o[a],d,p,m=-1,f=0;for(;f<l.length&&(n.lastIndex=f,p=n.exec(l),p!==null);)f=n.lastIndex,n===Ht?p[1]==="!--"?n=Hs:p[1]!==void 0?n=zs:p[2]!==void 0?(Ws.test(p[2])&&(i=RegExp("</"+p[2],"g")),n=We):p[3]!==void 0&&(n=We):n===We?p[0]===">"?(n=i??Ht,m=-1):p[1]===void 0?m=-2:(m=n.lastIndex-p[2].length,d=p[1],n=p[3]===void 0?We:p[3]==='"'?Us:Fs):n===Us||n===Fs?n=We:n===Hs||n===zs?n=Ht:(n=We,i=void 0);let b=n===We&&o[a+1].startsWith("/>")?" ":"";s+=n===Ht?l+bn:m>=0?(t.push(d),l.slice(0,m)+Ri+l.slice(m)+be+b):l+be+(m===-2?a:b)}return[Xs(o,s+(o[e]||"<?>")+(r===2?"</svg>":r===3?"</math>":"")),t]},Ut=class o{constructor({strings:r,_$litType$:e},t){let i;this.parts=[];let s=0,n=0,a=r.length-1,l=this.parts,[d,p]=Gs(r,e);if(this.el=o.createElement(d,t),Xe.currentNode=this.el.content,e===2||e===3){let m=this.el.content.firstChild;m.replaceWith(...m.childNodes)}for(;(i=Xe.nextNode())!==null&&l.length<a;){if(i.nodeType===1){if(i.hasAttributes())for(let m of i.getAttributeNames())if(m.endsWith(Ri)){let f=p[n++],b=i.getAttribute(m).split(be),y=/([.?@])?(.*)/.exec(f);l.push({type:1,index:s,name:y[2],strings:b,ctor:y[1]==="."?Nr:y[1]==="?"?Dr:y[1]==="@"?Hr:Je}),i.removeAttribute(m)}else m.startsWith(be)&&(l.push({type:6,index:s}),i.removeAttribute(m));if(Ws.test(i.tagName)){let m=i.textContent.split(be),f=m.length-1;if(f>0){i.textContent=Vr?Vr.emptyScript:"";for(let b=0;b<f;b++)i.append(m[b],zt()),Xe.nextNode(),l.push({type:2,index:++s});i.append(m[f],zt())}}}else if(i.nodeType===8)if(i.data===Mi)l.push({type:2,index:s});else{let m=-1;for(;(m=i.data.indexOf(be,m+1))!==-1;)l.push({type:7,index:s}),m+=be.length-1}s++}}static createElement(r,e){let t=Ge.createElement("template");return t.innerHTML=r,t}};function Ye(o,r,e=o,t){if(r===V)return r;let i=t!==void 0?e._$Co?.[t]:e._$Cl,s=Ft(r)?void 0:r._$litDirective$;return i?.constructor!==s&&(i?._$AO?.(!1),s===void 0?i=void 0:(i=new s(o),i._$AT(o,e,t)),t!==void 0?(e._$Co??=[])[t]=i:e._$Cl=i),i!==void 0&&(r=Ye(o,i._$AS(o,r.values),i,t)),r}var Or=class{constructor(r,e){this._$AV=[],this._$AN=void 0,this._$AD=r,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(r){let{el:{content:e},parts:t}=this._$AD,i=(r?.creationScope??Ge).importNode(e,!0);Xe.currentNode=i;let s=Xe.nextNode(),n=0,a=0,l=t[0];for(;l!==void 0;){if(n===l.index){let d;l.type===2?d=new at(s,s.nextSibling,this,r):l.type===1?d=new l.ctor(s,l.name,l.strings,this,r):l.type===6&&(d=new zr(s,this,r)),this._$AV.push(d),l=t[++a]}n!==l?.index&&(s=Xe.nextNode(),n++)}return Xe.currentNode=Ge,i}p(r){let e=0;for(let t of this._$AV)t!==void 0&&(t.strings!==void 0?(t._$AI(r,t,e),e+=t.strings.length-2):t._$AI(r[e])),e++}},at=class o{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(r,e,t,i){this.type=2,this._$AH=R,this._$AN=void 0,this._$AA=r,this._$AB=e,this._$AM=t,this.options=i,this._$Cv=i?.isConnected??!0}get parentNode(){let r=this._$AA.parentNode,e=this._$AM;return e!==void 0&&r?.nodeType===11&&(r=e.parentNode),r}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(r,e=this){r=Ye(this,r,e),Ft(r)?r===R||r==null||r===""?(this._$AH!==R&&this._$AR(),this._$AH=R):r!==this._$AH&&r!==V&&this._(r):r._$litType$!==void 0?this.$(r):r.nodeType!==void 0?this.T(r):Bs(r)?this.k(r):this._(r)}O(r){return this._$AA.parentNode.insertBefore(r,this._$AB)}T(r){this._$AH!==r&&(this._$AR(),this._$AH=this.O(r))}_(r){this._$AH!==R&&Ft(this._$AH)?this._$AA.nextSibling.data=r:this.T(Ge.createTextNode(r)),this._$AH=r}$(r){let{values:e,_$litType$:t}=r,i=typeof t=="number"?this._$AC(r):(t.el===void 0&&(t.el=Ut.createElement(Xs(t.h,t.h[0]),this.options)),t);if(this._$AH?._$AD===i)this._$AH.p(e);else{let s=new Or(i,this),n=s.u(this.options);s.p(e),this.T(n),this._$AH=s}}_$AC(r){let e=js.get(r.strings);return e===void 0&&js.set(r.strings,e=new Ut(r)),e}k(r){Ii(this._$AH)||(this._$AH=[],this._$AR());let e=this._$AH,t,i=0;for(let s of r)i===e.length?e.push(t=new o(this.O(zt()),this.O(zt()),this,this.options)):t=e[i],t._$AI(s),i++;i<e.length&&(this._$AR(t&&t._$AB.nextSibling,i),e.length=i)}_$AR(r=this._$AA.nextSibling,e){for(this._$AP?.(!1,!0,e);r!==this._$AB;){let t=r.nextSibling;r.remove(),r=t}}setConnected(r){this._$AM===void 0&&(this._$Cv=r,this._$AP?.(r))}},Je=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(r,e,t,i,s){this.type=1,this._$AH=R,this._$AN=void 0,this.element=r,this.name=e,this._$AM=i,this.options=s,t.length>2||t[0]!==""||t[1]!==""?(this._$AH=Array(t.length-1).fill(new String),this.strings=t):this._$AH=R}_$AI(r,e=this,t,i){let s=this.strings,n=!1;if(s===void 0)r=Ye(this,r,e,0),n=!Ft(r)||r!==this._$AH&&r!==V,n&&(this._$AH=r);else{let a=r,l,d;for(r=s[0],l=0;l<s.length-1;l++)d=Ye(this,a[t+l],e,l),d===V&&(d=this._$AH[l]),n||=!Ft(d)||d!==this._$AH[l],d===R?r=R:r!==R&&(r+=(d??"")+s[l+1]),this._$AH[l]=d}n&&!i&&this.j(r)}j(r){r===R?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,r??"")}},Nr=class extends Je{constructor(){super(...arguments),this.type=3}j(r){this.element[this.name]=r===R?void 0:r}},Dr=class extends Je{constructor(){super(...arguments),this.type=4}j(r){this.element.toggleAttribute(this.name,!!r&&r!==R)}},Hr=class extends Je{constructor(r,e,t,i,s){super(r,e,t,i,s),this.type=5}_$AI(r,e=this){if((r=Ye(this,r,e,0)??R)===V)return;let t=this._$AH,i=r===R&&t!==R||r.capture!==t.capture||r.once!==t.once||r.passive!==t.passive,s=r!==R&&(t===R||i);i&&this.element.removeEventListener(this.name,this,t),s&&this.element.addEventListener(this.name,this,r),this._$AH=r}handleEvent(r){typeof this._$AH=="function"?this._$AH.call(this.options?.host??this.element,r):this._$AH.handleEvent(r)}},zr=class{constructor(r,e,t){this.element=r,this.type=6,this._$AN=void 0,this._$AM=e,this.options=t}get _$AU(){return this._$AM._$AU}_$AI(r){Ye(this,r)}},H={M:Ri,P:be,A:Mi,C:1,L:Gs,R:Or,D:Bs,V:Ye,I:at,H:Je,N:Dr,U:Hr,B:Nr,F:zr},vn=Fr.litHtmlPolyfillSupport;vn?.(Ut,at),(Fr.litHtmlVersions??=[]).push("3.3.1");var $i=(o,r,e)=>{let t=e?.renderBefore??r,i=t._$litPart$;if(i===void 0){let s=e?.renderBefore??null;t._$litPart$=i=new at(r.insertBefore(zt(),s),s,void 0,e??{})}return i._$AI(o),i};var Pi=globalThis,v=class extends ge{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){let r=super.createRenderRoot();return this.renderOptions.renderBefore??=r.firstChild,r}update(r){let e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(r),this._$Do=$i(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return V}};v._$litElement$=!0,v.finalized=!0,Pi.litElementHydrateSupport?.({LitElement:v});var yn=Pi.litElementPolyfillSupport;yn?.({LitElement:v});(Pi.litElementVersions??=[]).push("4.2.1");var g=o=>(r,e)=>{e!==void 0?e.addInitializer((()=>{customElements.define(o,r)})):customElements.define(o,r)};var xn={attribute:!0,type:String,converter:Nt,reflect:!1,hasChanged:Pr},qn=(o=xn,r,e)=>{let{kind:t,metadata:i}=e,s=globalThis.litPropertyMetadata.get(i);if(s===void 0&&globalThis.litPropertyMetadata.set(i,s=new Map),t==="setter"&&((o=Object.create(o)).wrapped=!0),s.set(e.name,o),t==="accessor"){let{name:n}=e;return{set(a){let l=r.get.call(this);r.set.call(this,a),this.requestUpdate(n,l,o)},init(a){return a!==void 0&&this.C(n,void 0,o,a),a}}}if(t==="setter"){let{name:n}=e;return function(a){let l=this[n];r.call(this,a),this.requestUpdate(n,l,o)}}throw Error("Unsupported decorator location: "+t)};function u(o){return(r,e)=>typeof e=="object"?qn(o,r,e):((t,i,s)=>{let n=i.hasOwnProperty(s);return i.constructor.createProperty(s,t),n?Object.getOwnPropertyDescriptor(i,s):void 0})(o,r,e)}function C(o){return u({...o,state:!0,attribute:!1})}var Ie=(o,r,e)=>(e.configurable=!0,e.enumerable=!0,Reflect.decorate&&typeof r!="object"&&Object.defineProperty(o,r,e),e);function lt(o,r){return(e,t,i)=>{let s=n=>n.renderRoot?.querySelector(o)??null;if(r){let{get:n,set:a}=typeof t=="object"?e:i??(()=>{let l=Symbol();return{get(){return this[l]},set(d){this[l]=d}}})();return Ie(e,t,{get(){let l=n.call(this);return l===void 0&&(l=s(this),(l!==null||this.hasUpdated)&&a.call(this,l)),l}})}return Ie(e,t,{get(){return s(this)}})}}function Ys(o){return(r,e)=>{let{slot:t,selector:i}=o??{},s="slot"+(t?`[name=${t}]`:":not([name])");return Ie(r,e,{get(){let n=this.renderRoot?.querySelector(s),a=n?.assignedElements(o)??[];return i===void 0?a:a.filter((l=>l.matches(i)))}})}}function jr(o,r){return(e,t)=>{let{connectedCallback:i,disconnectedCallback:s}=e;e.connectedCallback=function(){i.call(this);let n=this[t],a=m=>{let f=[],b=[];for(let q of m)q.type==="childList"&&(q.addedNodes.forEach(T=>{if(T.nodeType!==1)return;let M=T;M.matches?.(o)&&f.push(M),f.push(...M.querySelectorAll?.(o)??[])}),q.removedNodes.forEach(T=>{if(T.nodeType!==1)return;let M=T;M.matches?.(o)&&b.push(M),b.push(...M.querySelectorAll?.(o)??[])}));let y=q=>Array.from(new Set(q)),E=y(f),S=y(b);(E.length||S.length)&&n.call(this,E,S)},l=new MutationObserver(a);l.observe(this,{childList:!0,subtree:!0});let d=this.shadowRoot?new MutationObserver(a):null;d?.observe(this.shadowRoot,{childList:!0,subtree:!0}),this.__lqObservers=[l,d].filter(m=>!!m),(async()=>{r?.waitUntilFirstUpdate&&"updateComplete"in this&&await this.updateComplete;let m=[...this.querySelectorAll(o),...this.shadowRoot?.querySelectorAll(o)??[]];m.length&&n.call(this,m,[])})()},e.disconnectedCallback=function(){s.call(this),this.__lqObservers?.forEach(n=>n.disconnect()),this.__lqObservers=void 0}}}function I(o,r){let e={waitUntilFirstUpdate:!1,...r};return(t,i)=>{let{update:s}=t,n=Array.isArray(o)?o:[o];t.update=function(a){n.forEach(l=>{let d=l;if(a.has(d)){let p=a.get(d),m=this[d];p!==m&&(!e.waitUntilFirstUpdate||this.hasUpdated)&&this[i](p,m)}}),s.call(this,a)}}}var $=Symbol("item");var Js=[{identifier:"completionStatus",cardinality:"single",baseType:"string",value:"unknown",type:"outcome"},{identifier:"numAttempts",cardinality:"single",baseType:"integer",value:"0",type:"response"}];var G=class extends v{constructor(){super(...arguments);this._templateProcessing=null;this.identifier="";this.adaptive="false";this.timeDependent=null;this._handleDisabledChange=(e,t)=>{this._interactionElements.forEach(i=>i.disabled=t)};this._handleReadonlyChange=(e,t)=>this._interactionElements.forEach(i=>i.readonly=t);this._context={variables:Js};this._initialContext={...this._context,variables:this._context.variables};this._feedbackElements=[];this._interactionElements=[];this._handleRegisterVariable=e=>{e.stopImmediatePropagation(),this._context={...this._context,variables:[...this._context.variables,e.detail.variable]},this._initialContext=this._context,e.stopPropagation()};this._handleRegisterFeedback=e=>{e.stopImmediatePropagation();let t=e.detail;this._feedbackElements.push(t),(Number(this._context.variables.find(s=>s.identifier==="numAttempts")?.value)||0)>0&&t.checkShowFeedback(t.outcomeIdentifier)};this._handleRegisterInteraction=e=>{e.stopImmediatePropagation(),this._interactionElements.push(e.detail.interactionElement)};this._handleEndAttempt=e=>{e.stopImmediatePropagation();let{responseIdentifier:t,countAttempt:i}=e.detail;this.validate(),this.updateResponseVariable(t,"true"),this.processResponse(i)};this._handleSetOutcomeValue=e=>{e.stopImmediatePropagation();let{outcomeIdentifier:t,value:i}=e.detail;this.updateOutcomeVariable(t,i),e.stopPropagation()};this._handleUpdateResponseVariable=e=>{e.stopImmediatePropagation();let{responseIdentifier:t,response:i}=e.detail;this.updateResponseVariable(t,i),this.dispatchEvent(new CustomEvent("qti-item-context-updated",{bubbles:!0,composed:!0,detail:{itemContext:this._context}}))}}get title(){return this._itemTitle}set title(e){this._itemTitle=e,this.removeAttribute("title"),this.setAttribute("data-title",e)}set assessmentItemRefId(e){this._context={...this._context,identifier:e}}get assessmentItemRefId(){return this._context.identifier}get variables(){return this._context.variables.map(e=>({identifier:e.identifier,value:e.value,type:e.type,...e.type==="outcome"&&e.identifier==="SCORE"?{externalScored:e.externalScored}:{}}))}set variables(e){if(!Array.isArray(e)||e.some(t=>!("identifier"in t))){console.warn("variables property should be an array of VariableDeclaration");return}this._context={...this._context,variables:this._context.variables.map(t=>{let i=e.find(s=>s.identifier===t.identifier);return i?{...t,...i,interpolationTable:t.interpolationTable}:t})},this._context.variables.forEach(t=>{if(t.type==="response"){let i=this._interactionElements.find(s=>s.responseIdentifier===t.identifier);i&&(i.response=t.value)}}),this.variables.forEach(t=>{t.type==="outcome"&&this._feedbackElements.forEach(i=>i.checkShowFeedback(t.identifier))})}set responses(e){if(e)for(let t of e){this.getResponse(t.responseIdentifier)&&this.updateResponseVariable(t.responseIdentifier,t.response);let s=this._interactionElements.find(n=>n.getAttribute("response-identifier")===t.responseIdentifier);s&&(s.response=t.response)}}render(){return h`<slot></slot>`}connectedCallback(){this._attachEventListeners(),super.connectedCallback(),this.updateComplete.then(()=>{this.dispatchEvent(new CustomEvent("qti-assessment-item-connected",{bubbles:!0,composed:!0,detail:this})),this._processTemplates()})}disconnectedCallback(){this._removeEventListeners(),super.disconnectedCallback()}_attachEventListeners(){this.addEventListener("qti-register-variable",this._handleRegisterVariable),this.addEventListener("qti-register-feedback",this._handleRegisterFeedback),this.addEventListener("qti-register-interaction",this._handleRegisterInteraction),this.addEventListener("end-attempt",this._handleEndAttempt),this.addEventListener("qti-set-outcome-value",this._handleSetOutcomeValue),this.addEventListener("qti-interaction-response",this._handleUpdateResponseVariable)}_removeEventListeners(){this.removeEventListener("qti-register-variable",this._handleRegisterVariable),this.removeEventListener("qti-register-feedback",this._handleRegisterFeedback),this.removeEventListener("qti-register-interaction",this._handleRegisterInteraction),this.removeEventListener("end-attempt",this._handleEndAttempt),this.removeEventListener("qti-set-outcome-value",this._handleSetOutcomeValue),this.removeEventListener("qti-interaction-response",this._handleUpdateResponseVariable)}showCorrectResponse(e){for(let t of this._interactionElements)t.toggleCorrectResponse(e);document.querySelectorAll("item-show-correct-response").forEach(t=>{t.shown=e})}showCandidateCorrection(e){for(let t of this._interactionElements)t.toggleCandidateCorrection(e);document.querySelectorAll("item-show-candidate-correction").forEach(t=>{t.shown=e})}_processTemplates(){this._templateProcessing=this.querySelector("qti-template-processing"),this._templateProcessing&&this._templateProcessing.process()}processResponse(e=!0,t=!0){this.validate(t),e&&this.updateOutcomeVariable("numAttempts",(+this._context.variables.find(s=>s.identifier==="numAttempts")?.value+1).toString());let i=this.querySelector("qti-response-processing");return!i||!i.process?!1:(i.process(),this.adaptive==="false"&&this.updateOutcomeVariable("completionStatus",this._getCompletionStatus()),this.dispatchEvent(new CustomEvent("qti-item-context-updated",{bubbles:!0,composed:!0,detail:{itemContext:this._context}})),!0)}resetResponses(){this._context=this._initialContext}getResponse(e){return this.getVariable(e)}getOutcome(e){return this.getVariable(e)}getVariable(e){return this._context.variables.find(t=>t.identifier===e)||null}updateResponseVariable(e,t){this._context={...this._context,variables:this._context.variables.map(i=>i.identifier!==e?i:{...i,value:t})},this.showCandidateCorrection(!1),this.dispatchEvent(new CustomEvent("qti-interaction-changed",{bubbles:!0,composed:!0,detail:{item:this.identifier,responseIdentifier:e,response:Array.isArray(t)?[...t]:t}})),this.adaptive==="false"&&this.updateOutcomeVariable("completionStatus",this._getCompletionStatus())}setOutcomeVariable(e,t){this.updateOutcomeVariable(e,t),this.dispatchEvent(new CustomEvent("qti-item-context-updated",{bubbles:!0,composed:!0,detail:{itemContext:this._context}}))}updateOutcomeVariable(e,t){let i=this.getOutcome(e);if(!i){console.warn(`Can not set qti-outcome-identifier: ${e}, it is not available`);return}this._context={...this._context,variables:this._context.variables.map(s=>s.identifier!==e?s:{...s,value:i.cardinality==="single"||Array.isArray(t)?t:[t]})},this._feedbackElements.forEach(s=>s.checkShowFeedback(e)),this.dispatchEvent(new CustomEvent("qti-outcome-changed",{bubbles:!0,composed:!0,detail:{item:this.identifier,outcomeIdentifier:e,value:this._context.variables.find(s=>s.identifier===e)?.value}}))}validate(e=!0){let t=this._interactionElements.every(i=>i.validate());return e&&this.reportValidity(),t}reportValidity(){for(let e of this._interactionElements)e.reportValidity()}_getCompletionStatus(){let e=this.validate(!1);return e===!0?"completed":e===!1?"incomplete":"not_attempted"}};c([u({type:String})],G.prototype,"identifier",2),c([u({type:String})],G.prototype,"adaptive",2),c([u({type:String})],G.prototype,"timeDependent",2),c([u({type:String})],G.prototype,"title",1),c([u({type:Boolean})],G.prototype,"disabled",2),c([I("disabled",{waitUntilFirstUpdate:!0})],G.prototype,"_handleDisabledChange",2),c([u({type:Boolean})],G.prototype,"readonly",2),c([I("readonly",{waitUntilFirstUpdate:!0})],G.prototype,"_handleReadonlyChange",2),c([X({context:$})],G.prototype,"_context",2),G=c([g("qti-assessment-item")],G);var Cn=String.raw,En=Cn`<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
4
+ \f\r"'\`<>=]|("|')|))|$)`,"g"),Fs=/'/g,Us=/"/g,Ws=/^(?:script|style|textarea|title)$/i,Li=o=>(r,...e)=>({_$litType$:o,strings:r,values:e}),h=Li(1),Ur=Li(2),Ba=Li(3),V=Symbol.for("lit-noChange"),R=Symbol.for("lit-nothing"),js=new WeakMap,Xe=Ge.createTreeWalker(Ge,129);function Xs(o,r){if(!Ii(o)||!o.hasOwnProperty("raw"))throw Error("invalid template strings array");return Ns!==void 0?Ns.createHTML(r):r}var Gs=(o,r)=>{let e=o.length-1,t=[],i,s=r===2?"<svg>":r===3?"<math>":"",n=Ht;for(let a=0;a<e;a++){let l=o[a],d,p,m=-1,f=0;for(;f<l.length&&(n.lastIndex=f,p=n.exec(l),p!==null);)f=n.lastIndex,n===Ht?p[1]==="!--"?n=Hs:p[1]!==void 0?n=zs:p[2]!==void 0?(Ws.test(p[2])&&(i=RegExp("</"+p[2],"g")),n=We):p[3]!==void 0&&(n=We):n===We?p[0]===">"?(n=i??Ht,m=-1):p[1]===void 0?m=-2:(m=n.lastIndex-p[2].length,d=p[1],n=p[3]===void 0?We:p[3]==='"'?Us:Fs):n===Us||n===Fs?n=We:n===Hs||n===zs?n=Ht:(n=We,i=void 0);let b=n===We&&o[a+1].startsWith("/>")?" ":"";s+=n===Ht?l+bn:m>=0?(t.push(d),l.slice(0,m)+Ri+l.slice(m)+be+b):l+be+(m===-2?a:b)}return[Xs(o,s+(o[e]||"<?>")+(r===2?"</svg>":r===3?"</math>":"")),t]},Ut=class o{constructor({strings:r,_$litType$:e},t){let i;this.parts=[];let s=0,n=0,a=r.length-1,l=this.parts,[d,p]=Gs(r,e);if(this.el=o.createElement(d,t),Xe.currentNode=this.el.content,e===2||e===3){let m=this.el.content.firstChild;m.replaceWith(...m.childNodes)}for(;(i=Xe.nextNode())!==null&&l.length<a;){if(i.nodeType===1){if(i.hasAttributes())for(let m of i.getAttributeNames())if(m.endsWith(Ri)){let f=p[n++],b=i.getAttribute(m).split(be),y=/([.?@])?(.*)/.exec(f);l.push({type:1,index:s,name:y[2],strings:b,ctor:y[1]==="."?Dr:y[1]==="?"?Nr:y[1]==="@"?Hr:Je}),i.removeAttribute(m)}else m.startsWith(be)&&(l.push({type:6,index:s}),i.removeAttribute(m));if(Ws.test(i.tagName)){let m=i.textContent.split(be),f=m.length-1;if(f>0){i.textContent=Vr?Vr.emptyScript:"";for(let b=0;b<f;b++)i.append(m[b],zt()),Xe.nextNode(),l.push({type:2,index:++s});i.append(m[f],zt())}}}else if(i.nodeType===8)if(i.data===Mi)l.push({type:2,index:s});else{let m=-1;for(;(m=i.data.indexOf(be,m+1))!==-1;)l.push({type:7,index:s}),m+=be.length-1}s++}}static createElement(r,e){let t=Ge.createElement("template");return t.innerHTML=r,t}};function Ye(o,r,e=o,t){if(r===V)return r;let i=t!==void 0?e._$Co?.[t]:e._$Cl,s=Ft(r)?void 0:r._$litDirective$;return i?.constructor!==s&&(i?._$AO?.(!1),s===void 0?i=void 0:(i=new s(o),i._$AT(o,e,t)),t!==void 0?(e._$Co??=[])[t]=i:e._$Cl=i),i!==void 0&&(r=Ye(o,i._$AS(o,r.values),i,t)),r}var Or=class{constructor(r,e){this._$AV=[],this._$AN=void 0,this._$AD=r,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(r){let{el:{content:e},parts:t}=this._$AD,i=(r?.creationScope??Ge).importNode(e,!0);Xe.currentNode=i;let s=Xe.nextNode(),n=0,a=0,l=t[0];for(;l!==void 0;){if(n===l.index){let d;l.type===2?d=new at(s,s.nextSibling,this,r):l.type===1?d=new l.ctor(s,l.name,l.strings,this,r):l.type===6&&(d=new zr(s,this,r)),this._$AV.push(d),l=t[++a]}n!==l?.index&&(s=Xe.nextNode(),n++)}return Xe.currentNode=Ge,i}p(r){let e=0;for(let t of this._$AV)t!==void 0&&(t.strings!==void 0?(t._$AI(r,t,e),e+=t.strings.length-2):t._$AI(r[e])),e++}},at=class o{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(r,e,t,i){this.type=2,this._$AH=R,this._$AN=void 0,this._$AA=r,this._$AB=e,this._$AM=t,this.options=i,this._$Cv=i?.isConnected??!0}get parentNode(){let r=this._$AA.parentNode,e=this._$AM;return e!==void 0&&r?.nodeType===11&&(r=e.parentNode),r}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(r,e=this){r=Ye(this,r,e),Ft(r)?r===R||r==null||r===""?(this._$AH!==R&&this._$AR(),this._$AH=R):r!==this._$AH&&r!==V&&this._(r):r._$litType$!==void 0?this.$(r):r.nodeType!==void 0?this.T(r):Bs(r)?this.k(r):this._(r)}O(r){return this._$AA.parentNode.insertBefore(r,this._$AB)}T(r){this._$AH!==r&&(this._$AR(),this._$AH=this.O(r))}_(r){this._$AH!==R&&Ft(this._$AH)?this._$AA.nextSibling.data=r:this.T(Ge.createTextNode(r)),this._$AH=r}$(r){let{values:e,_$litType$:t}=r,i=typeof t=="number"?this._$AC(r):(t.el===void 0&&(t.el=Ut.createElement(Xs(t.h,t.h[0]),this.options)),t);if(this._$AH?._$AD===i)this._$AH.p(e);else{let s=new Or(i,this),n=s.u(this.options);s.p(e),this.T(n),this._$AH=s}}_$AC(r){let e=js.get(r.strings);return e===void 0&&js.set(r.strings,e=new Ut(r)),e}k(r){Ii(this._$AH)||(this._$AH=[],this._$AR());let e=this._$AH,t,i=0;for(let s of r)i===e.length?e.push(t=new o(this.O(zt()),this.O(zt()),this,this.options)):t=e[i],t._$AI(s),i++;i<e.length&&(this._$AR(t&&t._$AB.nextSibling,i),e.length=i)}_$AR(r=this._$AA.nextSibling,e){for(this._$AP?.(!1,!0,e);r!==this._$AB;){let t=r.nextSibling;r.remove(),r=t}}setConnected(r){this._$AM===void 0&&(this._$Cv=r,this._$AP?.(r))}},Je=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(r,e,t,i,s){this.type=1,this._$AH=R,this._$AN=void 0,this.element=r,this.name=e,this._$AM=i,this.options=s,t.length>2||t[0]!==""||t[1]!==""?(this._$AH=Array(t.length-1).fill(new String),this.strings=t):this._$AH=R}_$AI(r,e=this,t,i){let s=this.strings,n=!1;if(s===void 0)r=Ye(this,r,e,0),n=!Ft(r)||r!==this._$AH&&r!==V,n&&(this._$AH=r);else{let a=r,l,d;for(r=s[0],l=0;l<s.length-1;l++)d=Ye(this,a[t+l],e,l),d===V&&(d=this._$AH[l]),n||=!Ft(d)||d!==this._$AH[l],d===R?r=R:r!==R&&(r+=(d??"")+s[l+1]),this._$AH[l]=d}n&&!i&&this.j(r)}j(r){r===R?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,r??"")}},Dr=class extends Je{constructor(){super(...arguments),this.type=3}j(r){this.element[this.name]=r===R?void 0:r}},Nr=class extends Je{constructor(){super(...arguments),this.type=4}j(r){this.element.toggleAttribute(this.name,!!r&&r!==R)}},Hr=class extends Je{constructor(r,e,t,i,s){super(r,e,t,i,s),this.type=5}_$AI(r,e=this){if((r=Ye(this,r,e,0)??R)===V)return;let t=this._$AH,i=r===R&&t!==R||r.capture!==t.capture||r.once!==t.once||r.passive!==t.passive,s=r!==R&&(t===R||i);i&&this.element.removeEventListener(this.name,this,t),s&&this.element.addEventListener(this.name,this,r),this._$AH=r}handleEvent(r){typeof this._$AH=="function"?this._$AH.call(this.options?.host??this.element,r):this._$AH.handleEvent(r)}},zr=class{constructor(r,e,t){this.element=r,this.type=6,this._$AN=void 0,this._$AM=e,this.options=t}get _$AU(){return this._$AM._$AU}_$AI(r){Ye(this,r)}},H={M:Ri,P:be,A:Mi,C:1,L:Gs,R:Or,D:Bs,V:Ye,I:at,H:Je,N:Nr,U:Hr,B:Dr,F:zr},vn=Fr.litHtmlPolyfillSupport;vn?.(Ut,at),(Fr.litHtmlVersions??=[]).push("3.3.1");var $i=(o,r,e)=>{let t=e?.renderBefore??r,i=t._$litPart$;if(i===void 0){let s=e?.renderBefore??null;t._$litPart$=i=new at(r.insertBefore(zt(),s),s,void 0,e??{})}return i._$AI(o),i};var Pi=globalThis,v=class extends ge{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){let r=super.createRenderRoot();return this.renderOptions.renderBefore??=r.firstChild,r}update(r){let e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(r),this._$Do=$i(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return V}};v._$litElement$=!0,v.finalized=!0,Pi.litElementHydrateSupport?.({LitElement:v});var yn=Pi.litElementPolyfillSupport;yn?.({LitElement:v});(Pi.litElementVersions??=[]).push("4.2.1");var g=o=>(r,e)=>{e!==void 0?e.addInitializer((()=>{customElements.define(o,r)})):customElements.define(o,r)};var xn={attribute:!0,type:String,converter:Dt,reflect:!1,hasChanged:Pr},qn=(o=xn,r,e)=>{let{kind:t,metadata:i}=e,s=globalThis.litPropertyMetadata.get(i);if(s===void 0&&globalThis.litPropertyMetadata.set(i,s=new Map),t==="setter"&&((o=Object.create(o)).wrapped=!0),s.set(e.name,o),t==="accessor"){let{name:n}=e;return{set(a){let l=r.get.call(this);r.set.call(this,a),this.requestUpdate(n,l,o)},init(a){return a!==void 0&&this.C(n,void 0,o,a),a}}}if(t==="setter"){let{name:n}=e;return function(a){let l=this[n];r.call(this,a),this.requestUpdate(n,l,o)}}throw Error("Unsupported decorator location: "+t)};function u(o){return(r,e)=>typeof e=="object"?qn(o,r,e):((t,i,s)=>{let n=i.hasOwnProperty(s);return i.constructor.createProperty(s,t),n?Object.getOwnPropertyDescriptor(i,s):void 0})(o,r,e)}function E(o){return u({...o,state:!0,attribute:!1})}var Ie=(o,r,e)=>(e.configurable=!0,e.enumerable=!0,Reflect.decorate&&typeof r!="object"&&Object.defineProperty(o,r,e),e);function lt(o,r){return(e,t,i)=>{let s=n=>n.renderRoot?.querySelector(o)??null;if(r){let{get:n,set:a}=typeof t=="object"?e:i??(()=>{let l=Symbol();return{get(){return this[l]},set(d){this[l]=d}}})();return Ie(e,t,{get(){let l=n.call(this);return l===void 0&&(l=s(this),(l!==null||this.hasUpdated)&&a.call(this,l)),l}})}return Ie(e,t,{get(){return s(this)}})}}function Ys(o){return(r,e)=>{let{slot:t,selector:i}=o??{},s="slot"+(t?`[name=${t}]`:":not([name])");return Ie(r,e,{get(){let n=this.renderRoot?.querySelector(s),a=n?.assignedElements(o)??[];return i===void 0?a:a.filter((l=>l.matches(i)))}})}}function jr(o,r){return(e,t)=>{let{connectedCallback:i,disconnectedCallback:s}=e;e.connectedCallback=function(){i.call(this);let n=this[t],a=m=>{let f=[],b=[];for(let q of m)q.type==="childList"&&(q.addedNodes.forEach(T=>{if(T.nodeType!==1)return;let M=T;M.matches?.(o)&&f.push(M),f.push(...M.querySelectorAll?.(o)??[])}),q.removedNodes.forEach(T=>{if(T.nodeType!==1)return;let M=T;M.matches?.(o)&&b.push(M),b.push(...M.querySelectorAll?.(o)??[])}));let y=q=>Array.from(new Set(q)),C=y(f),A=y(b);(C.length||A.length)&&n.call(this,C,A)},l=new MutationObserver(a);l.observe(this,{childList:!0,subtree:!0});let d=this.shadowRoot?new MutationObserver(a):null;d?.observe(this.shadowRoot,{childList:!0,subtree:!0}),this.__lqObservers=[l,d].filter(m=>!!m),(async()=>{r?.waitUntilFirstUpdate&&"updateComplete"in this&&await this.updateComplete;let m=[...this.querySelectorAll(o),...this.shadowRoot?.querySelectorAll(o)??[]];m.length&&n.call(this,m,[])})()},e.disconnectedCallback=function(){s.call(this),this.__lqObservers?.forEach(n=>n.disconnect()),this.__lqObservers=void 0}}}function I(o,r){let e={waitUntilFirstUpdate:!1,...r};return(t,i)=>{let{update:s}=t,n=Array.isArray(o)?o:[o];t.update=function(a){n.forEach(l=>{let d=l;if(a.has(d)){let p=a.get(d),m=this[d];p!==m&&(!e.waitUntilFirstUpdate||this.hasUpdated)&&this[i](p,m)}}),s.call(this,a)}}}var $=Symbol("item");var Js=[{identifier:"completionStatus",cardinality:"single",baseType:"string",value:"unknown",type:"outcome"},{identifier:"numAttempts",cardinality:"single",baseType:"integer",value:"0",type:"response"}];var Y=class extends v{constructor(){super(...arguments);this._templateProcessing=null;this.identifier="";this.adaptive="false";this.timeDependent=null;this._handleDisabledChange=(e,t)=>{this._interactionElements.forEach(i=>i.disabled=t)};this._handleReadonlyChange=(e,t)=>this._interactionElements.forEach(i=>i.readonly=t);this._context={variables:Js};this._initialContext={...this._context,variables:this._context.variables};this._feedbackElements=[];this._interactionElements=[];this._handleRegisterVariable=e=>{e.stopImmediatePropagation(),this._context={...this._context,variables:[...this._context.variables,e.detail.variable]},this._initialContext=this._context,e.stopPropagation()};this._handleRegisterFeedback=e=>{e.stopImmediatePropagation();let t=e.detail;this._feedbackElements.push(t),(Number(this._context.variables.find(s=>s.identifier==="numAttempts")?.value)||0)>0&&t.checkShowFeedback(t.outcomeIdentifier)};this._handleRegisterInteraction=e=>{e.stopImmediatePropagation(),this._interactionElements.push(e.detail.interactionElement)};this._handleEndAttempt=e=>{e.stopImmediatePropagation();let{responseIdentifier:t,countAttempt:i}=e.detail;this.validate(),this.updateResponseVariable(t,"true"),this.processResponse(i)};this._handleSetOutcomeValue=e=>{e.stopImmediatePropagation();let{outcomeIdentifier:t,value:i}=e.detail;this.updateOutcomeVariable(t,i),e.stopPropagation()};this._handleUpdateResponseVariable=e=>{e.stopImmediatePropagation();let{responseIdentifier:t,response:i}=e.detail;this.updateResponseVariable(t,i),this.dispatchEvent(new CustomEvent("qti-item-context-updated",{bubbles:!0,composed:!0,detail:{itemContext:this._context}}))}}get title(){return this._itemTitle}set title(e){this._itemTitle=e,this.removeAttribute("title"),this.setAttribute("data-title",e)}set assessmentItemRefId(e){this._context={...this._context,identifier:e}}get assessmentItemRefId(){return this._context.identifier}get variables(){return this._context.variables.map(e=>({identifier:e.identifier,value:e.value,type:e.type,...e.type==="outcome"&&e.identifier==="SCORE"?{externalScored:e.externalScored}:{}}))}set variables(e){if(!Array.isArray(e)||e.some(t=>!("identifier"in t))){console.warn("variables property should be an array of VariableDeclaration");return}this._context={...this._context,variables:this._context.variables.map(t=>{let i=e.find(s=>s.identifier===t.identifier);return i?{...t,...i,interpolationTable:t.interpolationTable}:t})},this._context.variables.forEach(t=>{if(t.type==="response"){let i=this._interactionElements.find(s=>s.responseIdentifier===t.identifier);i&&(i.response=t.value)}}),this.variables.forEach(t=>{t.type==="outcome"&&this._feedbackElements.forEach(i=>i.checkShowFeedback(t.identifier))})}set responses(e){if(e)for(let t of e){this.getResponse(t.responseIdentifier)&&this.updateResponseVariable(t.responseIdentifier,t.response);let s=this._interactionElements.find(n=>n.getAttribute("response-identifier")===t.responseIdentifier);s&&(s.response=t.response)}}render(){return h`<slot></slot>`}connectedCallback(){this._attachEventListeners(),super.connectedCallback(),this.updateComplete.then(()=>{this.dispatchEvent(new CustomEvent("qti-assessment-item-connected",{bubbles:!0,composed:!0,detail:this})),this._processTemplates()})}disconnectedCallback(){this._removeEventListeners(),super.disconnectedCallback()}_attachEventListeners(){this.addEventListener("qti-register-variable",this._handleRegisterVariable),this.addEventListener("qti-register-feedback",this._handleRegisterFeedback),this.addEventListener("qti-register-interaction",this._handleRegisterInteraction),this.addEventListener("end-attempt",this._handleEndAttempt),this.addEventListener("qti-set-outcome-value",this._handleSetOutcomeValue),this.addEventListener("qti-interaction-response",this._handleUpdateResponseVariable)}_removeEventListeners(){this.removeEventListener("qti-register-variable",this._handleRegisterVariable),this.removeEventListener("qti-register-feedback",this._handleRegisterFeedback),this.removeEventListener("qti-register-interaction",this._handleRegisterInteraction),this.removeEventListener("end-attempt",this._handleEndAttempt),this.removeEventListener("qti-set-outcome-value",this._handleSetOutcomeValue),this.removeEventListener("qti-interaction-response",this._handleUpdateResponseVariable)}showCorrectResponse(e){for(let t of this._interactionElements)t.toggleCorrectResponse(e);document.querySelectorAll("item-show-correct-response").forEach(t=>{t.shown=e})}showCandidateCorrection(e){for(let t of this._interactionElements)t.toggleCandidateCorrection(e);document.querySelectorAll("item-show-candidate-correction").forEach(t=>{t.shown=e})}_processTemplates(){this._templateProcessing=this.querySelector("qti-template-processing"),this._templateProcessing&&this._templateProcessing.process()}processResponse(e=!0,t=!0){this.validate(t),e&&this.updateOutcomeVariable("numAttempts",(+this._context.variables.find(s=>s.identifier==="numAttempts")?.value+1).toString());let i=this.querySelector("qti-response-processing");return!i||!i.process?!1:(i.process(),this.adaptive==="false"&&this.updateOutcomeVariable("completionStatus",this._getCompletionStatus()),this.dispatchEvent(new CustomEvent("qti-item-context-updated",{bubbles:!0,composed:!0,detail:{itemContext:this._context}})),!0)}resetResponses(){this._context=this._initialContext}getResponse(e){return this.getVariable(e)}getOutcome(e){return this.getVariable(e)}getVariable(e){return this._context.variables.find(t=>t.identifier===e)||null}updateResponseVariable(e,t){this._context={...this._context,variables:this._context.variables.map(i=>i.identifier!==e?i:{...i,value:t})},this.showCandidateCorrection(!1),this.dispatchEvent(new CustomEvent("qti-interaction-changed",{bubbles:!0,composed:!0,detail:{item:this.identifier,responseIdentifier:e,response:Array.isArray(t)?[...t]:t}})),this.adaptive==="false"&&this.updateOutcomeVariable("completionStatus",this._getCompletionStatus())}setOutcomeVariable(e,t){this.updateOutcomeVariable(e,t),this.dispatchEvent(new CustomEvent("qti-item-context-updated",{bubbles:!0,composed:!0,detail:{itemContext:this._context}}))}updateOutcomeVariable(e,t){let i=this.getOutcome(e);if(!i){console.warn(`Can not set qti-outcome-identifier: ${e}, it is not available`);return}this._context={...this._context,variables:this._context.variables.map(s=>s.identifier!==e?s:{...s,value:i.cardinality==="single"||Array.isArray(t)?t:[t]})},this._feedbackElements.forEach(s=>s.checkShowFeedback(e)),this.dispatchEvent(new CustomEvent("qti-outcome-changed",{bubbles:!0,composed:!0,detail:{item:this.identifier,outcomeIdentifier:e,value:this._context.variables.find(s=>s.identifier===e)?.value}}))}validate(e=!0){let t=this._interactionElements.every(i=>i.validate());return e&&this.reportValidity(),t}reportValidity(){for(let e of this._interactionElements)e.reportValidity()}_getCompletionStatus(){let e=this.validate(!1);return e===!0?"completed":e===!1?"incomplete":"not_attempted"}};c([u({type:String})],Y.prototype,"identifier",2),c([u({type:String})],Y.prototype,"adaptive",2),c([u({type:String})],Y.prototype,"timeDependent",2),c([u({type:String})],Y.prototype,"title",1),c([u({type:Boolean})],Y.prototype,"disabled",2),c([I("disabled",{waitUntilFirstUpdate:!0})],Y.prototype,"_handleDisabledChange",2),c([u({type:Boolean})],Y.prototype,"readonly",2),c([I("readonly",{waitUntilFirstUpdate:!0})],Y.prototype,"_handleReadonlyChange",2),c([G({context:$})],Y.prototype,"_context",2),Y=c([g("qti-assessment-item")],Y);var Cn=String.raw,En=Cn`<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>
@@ -23,7 +23,7 @@ Make sure to test your application with a production build as repeat registratio
23
23
  <xsl:apply-templates/>
24
24
  </xsl:element>
25
25
  </xsl:template>
26
- </xsl:stylesheet>`;function Ks(o,r,e){o.querySelectorAll(r).forEach(t=>{let i=`${r}-${e}`,s=Qs(t,i);t.replaceWith(s)})}function Zs(o,r){o.querySelectorAll("*").forEach(e=>{let t=e.classList;t&&t.forEach(i=>{if(i.startsWith(`${r}:`)){let s=i.slice(`${r}:`.length),n=`${e.nodeName}-${s}`,a=Qs(e,n);e.replaceWith(a)}})})}function Qs(o,r){let e=o.ownerDocument.createElement(r);for(let t of o.attributes)e.setAttribute(t.name,t.value);for(;o.firstChild;)e.appendChild(o.firstChild);return e}function eo(o){let r=[];return o.querySelectorAll("qti-assessment-item-ref").forEach(e=>{let t=e.getAttribute("identifier"),i=e.getAttribute("href"),s=e.getAttribute("category");r.push({identifier:t,href:i,category:s})}),r}function jt(o,r){return fetch(o,{signal:r}).then(e=>{if(!e.ok)throw new Error(`HTTP error! status: ${e.status}`);return e.text()}).then(e=>new DOMParser().parseFromString(e,"text/xml")).catch(e=>{throw e.name==="AbortError"?e:new Error(`Failed to load XML: ${e.message}`)})}function Bt(o){return new DOMParser().parseFromString(o,"text/xml")}function ct(o){let r=new XSLTProcessor,e=new DOMParser().parseFromString(En,"text/xml");return r.importStylesheet(e),r.transformToFragment(o,document)}function dt(o,r){r.endsWith("/")||(r+="/"),o.querySelectorAll("[src],[href],[primary-path]").forEach(e=>{let t="";e.getAttribute("src")&&(t="src"),e.getAttribute("href")&&(t="href"),e.getAttribute("primary-path")&&(t="primary-path");let i=e.getAttribute(t)?.trim();if(!/^(data:|https?:|blob:)/.test(i)){let s=r+encodeURI(i);e.setAttribute(t,s)}})}function to(o){o.querySelectorAll('qti-custom-operator[class="js.org"] > qti-base-value').forEach(e=>{let t=document.createComment(e.textContent);e.replaceChild(t,e.firstChild)})}function ro(o){o.querySelectorAll("qti-stylesheet").forEach(r=>r.remove())}function io(o){switch(o){case"qti-choice-interaction":case"qti-order-interaction":return"qti-simple-choice";case"qti-inline-choice-interaction":return"qti-inline-choice";case"qti-match-interaction":return["qti-simple-match-set:first-of-type qti-simple-associable-choice","qti-simple-match-set:last-of-type > qti-simple-associable-choice"];case"qti-gap-match-interaction":return"qti-gap-text";case"qti-associate-interaction":return"qti-simple-associable-choice";default:}}var Le=(o=!1)=>{let r,e="",t={load(i,s){e=i;let n=encodeURI(i);return o&&sessionStorage.getItem(n)?Promise.resolve(t.parse(sessionStorage.getItem(n))):jt(i,s).then(a=>(r=a,t.shuffleInteractions(),o&&sessionStorage.setItem(n,new XMLSerializer().serializeToString(r)),t))},parse(i){return r=Bt(i),t},path:i=>(dt(r,i),e=null,t),fn(i){return i(r),t},pciHooks(i){let s=["hook","module"],n=i.substring(0,i.lastIndexOf("/"));for(let a of s)r.querySelectorAll("["+a+"]").forEach(d=>{let p=d.getAttribute(a);!p.startsWith("data:")&&!p.startsWith("http")&&(d.setAttribute("base-url",i),d.setAttribute("module",n+"/"+encodeURI(p+(p.endsWith(".js")?"":".js"))))});return t},async configurePci(i,s,n="qti-portable-custom-interaction"){let a=[],l=r.querySelectorAll(n),d=await s(i,"/modules/module_resolution.js"),p=await s(i,"/modules/fallback_module_resolution.js");if(l.length>0)for(let m of Array.from(l)){m.setAttribute("data-base-url",i);let f=m.getAttribute("custom-interaction-type-identifier");f&&a.includes(f)&&(f=f+a.length,m.setAttribute("custom-interaction-type-identifier",f),a.push(f)),f&&a.push(f);let b=m.querySelector("qti-interaction-modules");if(b&&b.getAttribute("primary-configuration")){let y=b.getAttribute("primary-configuration");if(y)try{let E=await s(i,`/${y}`),S=Array.from(b.querySelectorAll("qti-interaction-module"));for(let q of S){let T=q.getAttribute("id");if(T&&E.paths&&E.paths[T]){let M=E.paths[T],O=Array.isArray(M)?M[0]:M;if(q.setAttribute("primary-path",O),p&&p.paths&&p.paths[T]){let N=p.paths[T];Array.isArray(N)?q.setAttribute("fallback-path",N[0]):q.setAttribute("fallback-path",N)}}}if(E.paths){for(let q in E.paths)if(!b.querySelector(`qti-interaction-module[id="${q}"]`)){let M=r.createElement("qti-interaction-module");M.setAttribute("id",q);let O=Array.isArray(E.paths[q])?E.paths[q][0]:E.paths[q];if(M.setAttribute("primary-path",O),p&&p.paths&&p.paths[q]){let N=p.paths[q];Array.isArray(N)?M.setAttribute("fallback-path",N[0]):M.setAttribute("fallback-path",N)}b.appendChild(M)}}E.urlArgs&&b.setAttribute("url-args",E.urlArgs)}catch(E){console.warn(`Failed to load primary configuration: ${y}`,E)}}else if(d){m.querySelector("qti-interaction-modules")===null?(b=r.createElement("qti-interaction-modules"),m.appendChild(b)):b=m.querySelector("qti-interaction-modules");for(let y in d.paths){let E=d.paths[y],S="";p&&p.paths&&p.paths[y]&&(S=p.paths[y]);let q=Array.isArray(E)?E:[E],T=Array.isArray(S)?S:[S],M=q.map((O,N)=>{let tn=T.length>N?T[N]:"";return{primaryPath:O,fallbackPath:tn}});for(let O of T)M.some(N=>N.fallbackPath===O)||M.push({primaryPath:q.length>0?q[0]:O,fallbackPath:O});for(let O of M){let N=r.createElement("qti-interaction-module");O.fallbackPath&&N.setAttribute("fallback-path",O.fallbackPath),N.setAttribute("id",y),N.setAttribute("primary-path",O.primaryPath),b&&b.appendChild(N)}}}}return t},shuffleInteractions(){let i=r.querySelectorAll('[shuffle="true"]'),s=Array.from(i).filter(n=>n.tagName?.toLowerCase().endsWith("-interaction"));for(let n of s){let a=io(n.tagName.toLowerCase()),l=Array.isArray(a)?a:[a];for(let d of l){let p=Array.from(n.querySelectorAll(d)),m=p.map((q,T)=>({element:q,fixed:q.hasAttribute("fixed")&&q.getAttribute("fixed")==="true",originalOrder:T})).filter(q=>q.fixed),f=p.filter(q=>!q.hasAttribute("fixed")||q.getAttribute("fixed")!=="true");if(f.length<=1)return console.warn("Shuffling is not possible with fewer than 2 non-fixed elements."),t;let b=[...f],y=!1,E=0;for(;!y&&E<20;){E++;for(let q=f.length-1;q>0;q--){let T=Math.floor(Math.random()*(q+1));[f[q],f[T]]=[f[T],f[q]]}y=!f.every((q,T)=>q===b[T])}if(!y)return console.warn("Failed to shuffle the choices after multiple attempts."),null;n.removeAttribute("shuffle");let S=0;for(let q of f)q.parentElement.insertBefore(q,m[S]?.element),S++;for(let q of m)q.element.parentElement.insertBefore(q.element,f[q.originalOrder])}}return t},extendElementName:(i,s)=>(Ks(r,i,s),t),extendElementsWithClass:(i="extend")=>(Zs(r,i),t),customInteraction(i,s){let n=r.querySelector("qti-custom-interaction"),a=n.querySelector("object");return n.setAttribute("data-base-ref",i),n.setAttribute("data-base-item",i+s),n.setAttribute("data",a.getAttribute("data")),n.setAttribute("width",a.getAttribute("width")),n.setAttribute("height",a.getAttribute("height")),n.removeChild(a),t},convertCDATAtoComment(){return to(r),t},stripStyleSheets(){return ro(r),t},html(){return e!==null&&dt(r,e.substring(0,e.lastIndexOf("/"))),new XMLSerializer().serializeToString(ct(r))},xml(){return new XMLSerializer().serializeToString(r)},htmlDoc(){return e!==null&&dt(r,e.substring(0,e.lastIndexOf("/"))),ct(r)},xmlDoc(){return r}};return t};var Vi=()=>{let o,r={async load(e,t){return new Promise((i,s)=>{jt(e,t).then(n=>(o=n,r.path(e.substring(0,e.lastIndexOf("/"))),i(r)))})},parse(e){return o=Bt(e),r},path:e=>(dt(o,e),r),fn(e){return e(o),r},items(){return eo(o)},html(){return new XMLSerializer().serializeToString(ct(o))},xml(){return new XMLSerializer().serializeToString(o)},htmlDoc(){return ct(o)},xmlDoc(){return o}};return r};var Oi=class o extends Event{constructor(e,t){super(o.eventName,{bubbles:!0,composed:!0,cancelable:!0});this.element=e;this.item=t}static{this.eventName="qti-assessment-stimulus-ref-connected"}},pt=class extends v{constructor(){super(...arguments);this.identifier="";this.href=""}async connectedCallback(){super.connectedCallback(),await this.updateComplete;let e=this.closest("qti-assessment-item"),t=new Oi(this,e);this.dispatchEvent(t);let i=e?.querySelector(`[data-stimulus-idref="${this.identifier}"]`);!t.defaultPrevented&&i&&await this.updateStimulusRef(i)}async updateStimulusRef(e){let t=await Le().load(this.href).then(i=>i.htmlDoc());if(t){let i=t.querySelectorAll("qti-stimulus-body, qti-stylesheet");e.innerHTML="",e.append(...i)}}};c([u({type:String})],pt.prototype,"identifier",2),c([u({type:String})],pt.prototype,"href",2),pt=c([g("qti-assessment-stimulus-ref")],pt);var Br=class extends v{};Br=c([g("qti-companion-materials-info")],Br);var Wt=class extends v{render(){return h`<slot @slotchange=${this.handleSlotChange}></slot>`}handleSlotChange(){let r=Array.from(this.firstElementChild?.childNodes??[]).find(e=>e.nodeType===Node.COMMENT_NODE);try{this.operatorFunction=new Function("context","fn","item",r?.textContent??"")}catch(e){console.error("custom-operator contains invalid javascript code",e)}}calculate(){let r={variable:t=>this._context?.variables.find(i=>i.identifier===t)?.value??"",correct:t=>this._context?.variables.find(i=>i.identifier===t)?.correctResponse??""},e={getVariable:t=>this._context?.variables.find(i=>i.identifier===t),updateOutcomeVariable:(t,i)=>{this.dispatchEvent(new CustomEvent("qti-set-outcome-value",{bubbles:!0,composed:!0,detail:{outcomeIdentifier:t,value:i}}))},updateResponseVariable:(t,i)=>{this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,composed:!0,detail:{responseIdentifier:t,response:i}}))}};return this.operatorFunction(this._context,r,e)}};c([_({context:$,subscribe:!0}),C()],Wt.prototype,"_context",2),Wt=c([g("qti-custom-operator")],Wt);var wn=()=>new Intl.NumberFormat().format(.1).replace(/\d/g,""),Xt=o=>{if(typeof o=="string")return o;let r=wn();return r==="."?o.toLocaleString():o.toString().replace(".","").replace(r,".")};function Ni(o){return o==null}function Ke(o){return o.replace(/([^:]\/)\/+/g,"$1").replace(/\/\//g,"/").replace("http:/","http://").replace("https:/","https://")}var Y=class extends v{connectedCallback(){super.connectedCallback(),this.dispatchEvent(new CustomEvent("qti-register-feedback",{bubbles:!0,composed:!0,detail:this}))}checkShowFeedback(r){let e=this._context.variables.find(i=>i.identifier===r)||null;if(this.outcomeIdentifier!==r||!e)return;let t=!1;Array.isArray(e.value)?t=e.value.includes(this.identifier):t=!Ni(this.identifier)&&!Ni(e?.value)&&this.identifier===e.value||!1,this.showFeedback(t)}showFeedback(r){this.showStatus=r&&this.showHide==="show"||!r&&this.showHide==="hide"?"on":"off"}};c([u({type:String,attribute:"show-hide"})],Y.prototype,"showHide",2),c([u({type:String,attribute:"outcome-identifier"})],Y.prototype,"outcomeIdentifier",2),c([u({type:String})],Y.prototype,"identifier",2),c([u({type:String,attribute:!1})],Y.prototype,"showStatus",2),c([_({context:$,subscribe:!0}),C()],Y.prototype,"_context",2);var Gt=class extends Y{render(){return h` <slot part="feedback" class="feedback ${this.showStatus}"></slot> `}connectedCallback(){super.connectedCallback(),this.checkShowFeedback(this.outcomeIdentifier)}};Gt.styles=x`
26
+ </xsl:stylesheet>`;function Ks(o,r,e){o.querySelectorAll(r).forEach(t=>{let i=`${r}-${e}`,s=Qs(t,i);t.replaceWith(s)})}function Zs(o,r){o.querySelectorAll("*").forEach(e=>{let t=e.classList;t&&t.forEach(i=>{if(i.startsWith(`${r}:`)){let s=i.slice(`${r}:`.length),n=`${e.nodeName}-${s}`,a=Qs(e,n);e.replaceWith(a)}})})}function Qs(o,r){let e=o.ownerDocument.createElement(r);for(let t of o.attributes)e.setAttribute(t.name,t.value);for(;o.firstChild;)e.appendChild(o.firstChild);return e}function eo(o){let r=[];return o.querySelectorAll("qti-assessment-item-ref").forEach(e=>{let t=e.getAttribute("identifier"),i=e.getAttribute("href"),s=e.getAttribute("category");r.push({identifier:t,href:i,category:s})}),r}function jt(o,r){return fetch(o,{signal:r}).then(e=>{if(!e.ok)throw new Error(`HTTP error! status: ${e.status}`);return e.text()}).then(e=>new DOMParser().parseFromString(e,"text/xml")).catch(e=>{throw e.name==="AbortError"?e:new Error(`Failed to load XML: ${e.message}`)})}function Bt(o){return new DOMParser().parseFromString(o,"text/xml")}function ct(o){let r=new XSLTProcessor,e=new DOMParser().parseFromString(En,"text/xml");return r.importStylesheet(e),r.transformToFragment(o,document)}function dt(o,r){r.endsWith("/")||(r+="/"),o.querySelectorAll("[src],[href],[primary-path]").forEach(e=>{let t="";e.getAttribute("src")&&(t="src"),e.getAttribute("href")&&(t="href"),e.getAttribute("primary-path")&&(t="primary-path");let i=e.getAttribute(t)?.trim();if(!/^(data:|https?:|blob:)/.test(i)){let s=r+encodeURI(i);e.setAttribute(t,s)}})}function to(o){o.querySelectorAll('qti-custom-operator[class="js.org"] > qti-base-value').forEach(e=>{let t=document.createComment(e.textContent);e.replaceChild(t,e.firstChild)})}function ro(o){o.querySelectorAll("qti-stylesheet").forEach(r=>r.remove())}function io(o){switch(o){case"qti-choice-interaction":case"qti-order-interaction":return"qti-simple-choice";case"qti-inline-choice-interaction":return"qti-inline-choice";case"qti-match-interaction":return["qti-simple-match-set:first-of-type qti-simple-associable-choice","qti-simple-match-set:last-of-type > qti-simple-associable-choice"];case"qti-gap-match-interaction":return"qti-gap-text";case"qti-associate-interaction":return"qti-simple-associable-choice";default:}}var Le=(o=!1)=>{let r,e="",t={load(i,s){e=i;let n=encodeURI(i);return o&&sessionStorage.getItem(n)?Promise.resolve(t.parse(sessionStorage.getItem(n))):jt(i,s).then(a=>(r=a,t.shuffleInteractions(),o&&sessionStorage.setItem(n,new XMLSerializer().serializeToString(r)),t))},parse(i){return r=Bt(i),t},path:i=>(dt(r,i),e=null,t),fn(i){return i(r),t},pciHooks(i){let s=["hook","module"],n=i.substring(0,i.lastIndexOf("/"));for(let a of s)r.querySelectorAll("["+a+"]").forEach(d=>{let p=d.getAttribute(a);!p.startsWith("data:")&&!p.startsWith("http")&&(d.setAttribute("base-url",i),d.setAttribute("module",n+"/"+encodeURI(p+(p.endsWith(".js")?"":".js"))))});return t},async configurePci(i,s,n="qti-portable-custom-interaction"){let a=[],l=r.querySelectorAll(n),d=await s(i,"/modules/module_resolution.js"),p=await s(i,"/modules/fallback_module_resolution.js");if(l.length>0)for(let m of Array.from(l)){m.setAttribute("data-base-url",i);let f=m.getAttribute("custom-interaction-type-identifier");f&&a.includes(f)&&(f=f+a.length,m.setAttribute("custom-interaction-type-identifier",f),a.push(f)),f&&a.push(f);let b=m.querySelector("qti-interaction-modules");if(b&&b.getAttribute("primary-configuration")){let y=b.getAttribute("primary-configuration");if(y)try{let C=await s(i,`/${y}`),A=Array.from(b.querySelectorAll("qti-interaction-module"));for(let q of A){let T=q.getAttribute("id");if(T&&C.paths&&C.paths[T]){let M=C.paths[T],O=Array.isArray(M)?M[0]:M;if(q.setAttribute("primary-path",O),p&&p.paths&&p.paths[T]){let D=p.paths[T];Array.isArray(D)?q.setAttribute("fallback-path",D[0]):q.setAttribute("fallback-path",D)}}}if(C.paths){for(let q in C.paths)if(!b.querySelector(`qti-interaction-module[id="${q}"]`)){let M=r.createElement("qti-interaction-module");M.setAttribute("id",q);let O=Array.isArray(C.paths[q])?C.paths[q][0]:C.paths[q];if(M.setAttribute("primary-path",O),p&&p.paths&&p.paths[q]){let D=p.paths[q];Array.isArray(D)?M.setAttribute("fallback-path",D[0]):M.setAttribute("fallback-path",D)}b.appendChild(M)}}C.urlArgs&&b.setAttribute("url-args",C.urlArgs)}catch(C){console.warn(`Failed to load primary configuration: ${y}`,C)}}else if(d){m.querySelector("qti-interaction-modules")===null?(b=r.createElement("qti-interaction-modules"),m.appendChild(b)):b=m.querySelector("qti-interaction-modules");for(let y in d.paths){let C=d.paths[y],A="";p&&p.paths&&p.paths[y]&&(A=p.paths[y]);let q=Array.isArray(C)?C:[C],T=Array.isArray(A)?A:[A],M=q.map((O,D)=>{let tn=T.length>D?T[D]:"";return{primaryPath:O,fallbackPath:tn}});for(let O of T)M.some(D=>D.fallbackPath===O)||M.push({primaryPath:q.length>0?q[0]:O,fallbackPath:O});for(let O of M){let D=r.createElement("qti-interaction-module");O.fallbackPath&&D.setAttribute("fallback-path",O.fallbackPath),D.setAttribute("id",y),D.setAttribute("primary-path",O.primaryPath),b&&b.appendChild(D)}}}}return t},shuffleInteractions(){let i=r.querySelectorAll('[shuffle="true"]'),s=Array.from(i).filter(n=>n.tagName?.toLowerCase().endsWith("-interaction"));for(let n of s){let a=io(n.tagName.toLowerCase()),l=Array.isArray(a)?a:[a];for(let d of l){let p=Array.from(n.querySelectorAll(d)),m=p.map((q,T)=>({element:q,fixed:q.hasAttribute("fixed")&&q.getAttribute("fixed")==="true",originalOrder:T})).filter(q=>q.fixed),f=p.filter(q=>!q.hasAttribute("fixed")||q.getAttribute("fixed")!=="true");if(f.length<=1)return console.warn("Shuffling is not possible with fewer than 2 non-fixed elements."),t;let b=[...f],y=!1,C=0;for(;!y&&C<20;){C++;for(let q=f.length-1;q>0;q--){let T=Math.floor(Math.random()*(q+1));[f[q],f[T]]=[f[T],f[q]]}y=!f.every((q,T)=>q===b[T])}if(!y)return console.warn("Failed to shuffle the choices after multiple attempts."),null;n.removeAttribute("shuffle");let A=0;for(let q of f)q.parentElement.insertBefore(q,m[A]?.element),A++;for(let q of m)q.element.parentElement.insertBefore(q.element,f[q.originalOrder])}}return t},extendElementName:(i,s)=>(Ks(r,i,s),t),extendElementsWithClass:(i="extend")=>(Zs(r,i),t),customInteraction(i,s){let n=r.querySelector("qti-custom-interaction"),a=n.querySelector("object");return n.setAttribute("data-base-ref",i),n.setAttribute("data-base-item",i+s),n.setAttribute("data",a.getAttribute("data")),n.setAttribute("width",a.getAttribute("width")),n.setAttribute("height",a.getAttribute("height")),n.removeChild(a),t},convertCDATAtoComment(){return to(r),t},stripStyleSheets(){return ro(r),t},html(){return e!==null&&dt(r,e.substring(0,e.lastIndexOf("/"))),new XMLSerializer().serializeToString(ct(r))},xml(){return new XMLSerializer().serializeToString(r)},htmlDoc(){return e!==null&&dt(r,e.substring(0,e.lastIndexOf("/"))),ct(r)},xmlDoc(){return r}};return t};var Vi=()=>{let o,r={async load(e,t){return new Promise((i,s)=>{jt(e,t).then(n=>(o=n,r.path(e.substring(0,e.lastIndexOf("/"))),i(r)))})},parse(e){return o=Bt(e),r},path:e=>(dt(o,e),r),fn(e){return e(o),r},items(){return eo(o)},html(){return new XMLSerializer().serializeToString(ct(o))},xml(){return new XMLSerializer().serializeToString(o)},htmlDoc(){return ct(o)},xmlDoc(){return o}};return r};var Oi=class o extends Event{constructor(e,t){super(o.eventName,{bubbles:!0,composed:!0,cancelable:!0});this.element=e;this.item=t}static{this.eventName="qti-assessment-stimulus-ref-connected"}},pt=class extends v{constructor(){super(...arguments);this.identifier="";this.href=""}async connectedCallback(){super.connectedCallback(),await this.updateComplete;let e=this.closest("qti-assessment-item"),t=new Oi(this,e);this.dispatchEvent(t);let i=e?.querySelector(`[data-stimulus-idref="${this.identifier}"]`);!t.defaultPrevented&&i&&await this.updateStimulusRef(i)}async updateStimulusRef(e){let t=await Le().load(this.href).then(i=>i.htmlDoc());if(t){let i=t.querySelectorAll("qti-stimulus-body, qti-stylesheet");e.innerHTML="",e.append(...i)}}};c([u({type:String})],pt.prototype,"identifier",2),c([u({type:String})],pt.prototype,"href",2),pt=c([g("qti-assessment-stimulus-ref")],pt);var Br=class extends v{};Br=c([g("qti-companion-materials-info")],Br);var Wt=class extends v{render(){return h`<slot @slotchange=${this.handleSlotChange}></slot>`}handleSlotChange(){let r=Array.from(this.firstElementChild?.childNodes??[]).find(e=>e.nodeType===Node.COMMENT_NODE);try{this.operatorFunction=new Function("context","fn","item",r?.textContent??"")}catch(e){console.error("custom-operator contains invalid javascript code",e)}}calculate(){let r={variable:t=>this._context?.variables.find(i=>i.identifier===t)?.value??"",correct:t=>this._context?.variables.find(i=>i.identifier===t)?.correctResponse??""},e={getVariable:t=>this._context?.variables.find(i=>i.identifier===t),updateOutcomeVariable:(t,i)=>{this.dispatchEvent(new CustomEvent("qti-set-outcome-value",{bubbles:!0,composed:!0,detail:{outcomeIdentifier:t,value:i}}))},updateResponseVariable:(t,i)=>{this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,composed:!0,detail:{responseIdentifier:t,response:i}}))}};return this.operatorFunction(this._context,r,e)}};c([_({context:$,subscribe:!0}),E()],Wt.prototype,"_context",2),Wt=c([g("qti-custom-operator")],Wt);var wn=()=>new Intl.NumberFormat().format(.1).replace(/\d/g,""),Xt=o=>{if(typeof o=="string")return o;let r=wn();return r==="."?o.toLocaleString():o.toString().replace(".","").replace(r,".")};function Di(o){return o==null}function Ke(o){return o.replace(/([^:]\/)\/+/g,"$1").replace(/\/\//g,"/").replace("http:/","http://").replace("https:/","https://")}var U=class extends v{connectedCallback(){super.connectedCallback(),this.dispatchEvent(new CustomEvent("qti-register-feedback",{bubbles:!0,composed:!0,detail:this}))}checkShowFeedback(r){let e=this._context.variables.find(i=>i.identifier===r)||null;if(this.outcomeIdentifier!==r||!e)return;let t=!1;Array.isArray(e.value)?t=e.value.includes(this.identifier):t=!Di(this.identifier)&&!Di(e?.value)&&this.identifier===e.value||!1,this.showFeedback(t)}showFeedback(r){this.showStatus=r&&this.showHide==="show"||!r&&this.showHide==="hide"?"on":"off"}};c([u({type:String,attribute:"show-hide"})],U.prototype,"showHide",2),c([u({type:String,attribute:"outcome-identifier"})],U.prototype,"outcomeIdentifier",2),c([u({type:String})],U.prototype,"identifier",2),c([u({type:String,attribute:!1})],U.prototype,"showStatus",2),c([_({context:$,subscribe:!0}),E()],U.prototype,"_context",2);var Gt=class extends U{render(){return h` <slot part="feedback" class="feedback ${this.showStatus}"></slot> `}connectedCallback(){super.connectedCallback(),this.checkShowFeedback(this.outcomeIdentifier)}};Gt.styles=x`
27
27
  :host {
28
28
  display: block;
29
29
  }
@@ -33,14 +33,14 @@ Make sure to test your application with a production build as repeat registratio
33
33
  .off {
34
34
  display: none;
35
35
  }
36
- `,Gt=c([g("qti-feedback-block")],Gt);var ie=o=>o??R;var Yt=class extends Y{constructor(){super(...arguments);this.render=()=>h` <slot part="feedback" class="${ie(this.showStatus)}"></slot> `}connectedCallback(){super.connectedCallback(),this.checkShowFeedback(this.outcomeIdentifier)}};Yt.styles=x`
36
+ `,Gt=c([g("qti-feedback-block")],Gt);var ie=o=>o??R;var Yt=class extends U{constructor(){super(...arguments);this.render=()=>h` <slot part="feedback" class="${ie(this.showStatus)}"></slot> `}connectedCallback(){super.connectedCallback(),this.checkShowFeedback(this.outcomeIdentifier)}};Yt.styles=x`
37
37
  .on {
38
38
  display: inline-block;
39
39
  }
40
40
  .off {
41
41
  display: none;
42
42
  }
43
- `,Yt=c([g("qti-feedback-inline")],Yt);var Ze=class extends Y{render(){return h`
43
+ `,Yt=c([g("qti-feedback-inline")],Yt);var Ze=class extends U{render(){return h`
44
44
  <dialog class="qti-dialog" part="feedback" ?open="${this.showStatus==="on"}">
45
45
  <slot></slot>
46
46
  <div style="margin-top: var(--qti-gap-size); text-align: center;">
@@ -92,7 +92,7 @@ Make sure to test your application with a production build as repeat registratio
92
92
  user-select: none;
93
93
  position: absolute;
94
94
  }
95
- `,Jt=c([g("qti-associable-hotspot")],Jt);var so=(o,r,e)=>{class t extends o{}return t};var se=(o,r,e,t)=>{class i extends so(o,e,r){constructor(){super(...arguments);this.observer=null;this.droppableObsever=null;this.resizeObserver=null;this.draggables=[];this.droppables=[];this.dragContainers=[];this.dragClone=null;this.dragSource=null;this.touchStartPoint=null;this.isDraggable=!1;this.cloneOffset={x:0,y:0};this.isDragging=!1;this.allDropzones=[];this.lastTarget=null;this.currentDropTarget=null;this.onMove=this.handleTouchMove.bind(this);this.onEnd=this.handleTouchEnd.bind(this);this.onCancel=this.handleTouchCancel.bind(this);this.MIN_DRAG_DISTANCE=5;this.DRAG_CLONE_OPACITY=1;this.dataTransfer={data:{},setData(a,l){this.data[a]=l},getData(a){return this.data[a]},effectAllowed:"move"};this.configuration={copyStylesDragClone:!0,dragCanBePlacedBack:!0,dragOnClick:!1};this.minAssociations=1;this.maxAssociations=0;this.draggablesModified=(a,l)=>{if(this.isMatchTabular())return;for(let p of l)this.draggables.includes(p)&&(this.draggables=this.draggables.filter(m=>m!==p),p.removeAttribute("tabindex"),p.removeEventListener("touchstart",this.handleTouchStart.bind(this)),p.removeEventListener("mousedown",this.handleTouchStart.bind(this)));for(let p of a)this.draggables.includes(p)||(this.draggables.push(p),p.setAttribute("tabindex","0"),p.hasTouchStartListener||(p.addEventListener("touchstart",this.handleTouchStart.bind(this),{passive:!1}),p.addEventListener("mousedown",this.handleTouchStart.bind(this),{passive:!1}),p.hasTouchStartListener=!0));let d=0;this.draggables.forEach(p=>{p.style.viewTransitionName=`drag-${d}-${this.getAttribute("identifier")||crypto.randomUUID()}`,p.setAttribute("qti-draggable","true"),d++})};this.droppablesModified=(a,l)=>{if(!this.isMatchTabular()){for(let d of l)this.droppables.includes(d)&&(this.droppables=this.droppables.filter(p=>p!==d),this.allDropzones=this.allDropzones.filter(p=>p!==d));for(let d of a)this.droppables.includes(d)||(this.droppables.push(d),this.allDropzones.push(d));for(let d of this.droppables)this.dataset.choicesContainerWidth&&(d.style.width=`${this.dataset.choicesContainerWidth}px`,d.style.boxSizing="border-box")}}}handleDraggableContainerChange(a,l){this.isMatchTabular()||(a.length>0||l.length>0)&&this.dragContainersModified(a||[],l||[])}dragContainersModified(a,l){for(let d of l)this.dragContainers.includes(d)&&(this.dragContainers=this.dragContainers.filter(p=>p!==d),this.allDropzones=this.allDropzones.filter(p=>p!==d));for(let d of a)this.dragContainers.includes(d)||(this.dragContainers.push(d),this.allDropzones.push(d))}handleDraggablesChange(a,l){this.isMatchTabular()||(a.length>0||l.length>0)&&this.draggablesModified(a||[],l||[])}handleDroppablesChange(a,l){this.isMatchTabular()||(a.length>0||l.length>0)&&this.droppablesModified(a||[],l||[])}firstUpdated(a){if(super.firstUpdated(a),this.isMatchTabular())return;this.hasAttribute("disabled")||(document.addEventListener("mousemove",this.onMove,{passive:!1}),document.addEventListener("mouseup",this.onEnd,{passive:!1}),document.addEventListener("touchmove",this.onMove,{passive:!1}),document.addEventListener("touchend",this.onEnd,{passive:!1}),document.addEventListener("touchcancel",this.onCancel,{passive:!1}));let d=Array.from(this.querySelectorAll(r)||[]).concat(Array.from(this.shadowRoot?.querySelectorAll(r)||[])),p=Array.from(this.querySelectorAll(e)||[]).concat(Array.from(this.shadowRoot?.querySelectorAll(e)||[])),m=Array.from(this.querySelectorAll(t)||[]).concat(Array.from(this.shadowRoot?.querySelectorAll(t)||[]));this.dragContainersModified(m,[]),this.droppablesModified(p,[]),this.draggablesModified(d,[]),this.updateMinDimensionsForDropZones(),this.observer=new MutationObserver(()=>this.updateMinDimensionsForDropZones()),this.observer.observe(this,{childList:!0,subtree:!0}),this.resizeObserver=new ResizeObserver(()=>this.updateMinDimensionsForDropZones()),this.querySelectorAll("qti-gap-text").forEach(b=>this.resizeObserver?.observe(b))}async moveDraggableToDroppable(a,l){if(this.isMatchTabular())return;(()=>{a.style.transform="translate(0, 0)",l.tagName==="SLOT"?a.setAttribute("slot",l.getAttribute("name")):l.appendChild(a),this.checkAllMaxAssociations(),this.saveResponse()})()}activateDroppable(a){this.dragContainers.includes(a)?(this._internals.states.add("--dragzone-active"),a.setAttribute("active","")):(this._internals.states.delete("--dragzone-active"),a.setAttribute("active",""))}deactivateDroppable(a,l=!0){l&&this._internals.states.add("--dragzone-active"),a.removeAttribute("active")}connectedCallback(){super.connectedCallback()}isMatchTabular(){return this.classList.contains("qti-match-tabular")}async updateMinDimensionsForDropZones(){if(await this.updateComplete,this.isMatchTabular())return;let a=this.querySelectorAll(r),l=Array.from(this.querySelectorAll(e)).map(b=>b),d=0,p=0;a.forEach(b=>{let y=b.getBoundingClientRect();d=Math.max(d,y.height),p=Math.max(p,y.width)});let m=this.querySelector(t)||this.shadowRoot?.querySelector(t),f=l[0]?.parentElement;f&&(f.style.gridTemplateColumns=`repeat(auto-fit, minmax(calc(${p}px + 2 * var(--qti-dropzone-padding)), 1fr))`),m&&(m.style.minHeight=`${d}px`,m.style.minWidth=`${p}px`);for(let b of l){b.style.minHeight=`${d}px`,b.style.minWidth=`${p}px`;let y=b.shadowRoot?.querySelector('slot[part="dropslot"]');y&&(y.style.minHeight=`${d}px`,y.style.minWidth=`${p}px`)}}activateDroppables(a){if(this.isMatchTabular())return;this.dragContainers.forEach(d=>{d.setAttribute("enabled",""),d.hasAttribute("disabled")&&(d.contains(a)||d.shadowRoot&&d.shadowRoot.contains(a))&&d.removeAttribute("disabled")}),this.droppables.forEach(d=>{d.setAttribute("enabled",""),d.hasAttribute("disabled")&&(d.contains(a)||d.shadowRoot&&d.shadowRoot.contains(a))&&d.removeAttribute("disabled")})}activateDragLocation(){this._internals.states.add("--dragzone-enabled")}deactivateDragLocation(){this._internals.states.delete("--dragzone-enabled")}deactivateDroppables(){this.dragContainers.forEach(l=>{l.removeAttribute("enabled"),l.removeAttribute("active")}),this.droppables.forEach(l=>{l.removeAttribute("enabled"),l.removeAttribute("active")})}disconnectedCallback(){super.disconnectedCallback(),this.observer&&(this.observer.disconnect(),this.observer=null),this.droppableObsever&&(this.droppableObsever.disconnect(),this.droppableObsever=null),this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),document.removeEventListener("mousemove",this.onMove),document.removeEventListener("mouseup",this.onEnd),document.removeEventListener("touchmove",this.onMove),document.removeEventListener("touchend",this.onEnd),document.removeEventListener("touchcancel",this.onCancel)}handleTouchMove(a){if(!this.isMatchTabular()&&this.isDraggable&&this.dragClone){let{x:l,y:d}=this.getEventCoordinates(a),p={clientX:l,clientY:d};this.calculateDragDistance(p)>=this.MIN_DRAG_DISTANCE&&(this.isDragging=!0,this.updateDragClonePosition(p));let m=this.findClosestDropzone();this.currentDropTarget=m,m!==this.lastTarget&&(this.lastTarget&&(this.deactivateDroppable(this.lastTarget),this.dispatchCustomEvent(this.lastTarget,"dragleave")),m&&(this.activateDroppable(m),this.dispatchCustomEvent(m,"dragenter")),this.lastTarget=m),this.currentDropTarget&&this.dispatchCustomEvent(this.currentDropTarget,"dragover"),a.preventDefault()}}handleTouchEnd(a){this.isMatchTabular()||((this.isDragging||this.isDraggable||this.dragClone)&&this.resetDragState(),this._internals.states.delete("--dragzone-active"),this.checkAllMaxAssociations(),this._internals.states.delete("--dragzone-enabled"),this._internals.states.delete("--dragzone-active"),this.deactivateDragLocation(),this.deactivateDroppables(),this.draggables.forEach(l=>{l.removeAttribute("dragging")}),a.preventDefault())}handleTouchCancel(a){this.resetDragState()}validate(){if(this.isMatchTabular())return;if(!this.shadowRoot)return!1;let a=this.getValidAssociations(),l=!0,d="";this.maxAssociations>0&&a>this.maxAssociations?(l=!1,d=this.dataset.maxSelectionsMessage||`You've selected too many associations. Maximum allowed is ${this.maxAssociations}.`):this.minAssociations>0&&a<this.minAssociations&&(l=!1,d=this.dataset.minSelectionsMessage||`You haven't selected enough associations. Minimum required is ${this.minAssociations}.`);let p=this.lastElementChild;return this._internals.setValidity(l?{}:{customError:!0},d,p),l}reportValidity(){let a=this.shadowRoot.querySelector("#validation-message");return a&&(this._internals.validity.valid?(a.textContent="",a.style.display="none"):(a.textContent=this._internals.validationMessage,a.style.setProperty("display","block","important"))),this._internals.validity.valid}checkMaxAssociations(a){let l=this.getMatchMaxValue(a),d=a.querySelectorAll('[qti-draggable="true"]').length;return!(l===0)&&d>=l}dropDraggableInDroppable(a,l){let d=a.cloneNode(!0);d.removeAttribute("style"),this.moveDraggableToDroppable(d,l),this.draggablesModified([d],[]);let p=this.getMatchMaxValue(a),m=this.draggables.filter(f=>f.getAttribute("identifier")===a.getAttribute("identifier"));p!==0&&m.length>=p?(a.style.opacity="0.0",a.style.pointerEvents="none"):a.style.opacity="1.0"}resetDragState(){if(this.dragClone){let a=this.currentDropTarget!==null,l=!a||this.dragContainers.includes(this.currentDropTarget);a&&this.currentDropTarget&&!l&&this.dropDraggableInDroppable(this.dragSource,this.currentDropTarget),l&&(this.dragSource.style.opacity="1.0",this.dragSource.style.display="block",this.dragSource.style.position="static",this.dragSource.style.pointerEvents="auto",this.saveResponse()),this.dragClone.remove(),this.draggablesModified([],[this.dragClone])}this.isDragging=!1,this.isDraggable=!1,this.dragSource=null,this.dragClone=null,this.touchStartPoint=null,this.currentDropTarget=null,this.lastTarget=null,this.deactivateDroppables()}checkAllMaxAssociations(){let a=this.getValidAssociations(),l=this.maxAssociations!==0&&a>=this.maxAssociations;this.droppables.forEach(d=>{l?this.disableDroppable(d):this.checkMaxAssociations(d)?this.disableDroppable(d):this.enableDroppable(d)})}getMatchMaxValue(a){let l=a.getAttribute("match-max");return l?parseInt(l,10):1}disableDroppable(a){a.setAttribute("disabled","")}enableDroppable(a){a.removeAttribute("disabled")}get response(){let a;return typeof this.getResponse=="function"?a=this.getResponse():a=this.collectResponseData(),a.join(",")}set response(a){if(!this.isMatchTabular())if(typeof this.getValue=="function"&&(a=this.getValue(a)),Array.isArray(a)){this.reset(!1),a?.forEach(d=>this.placeResponse(d));let l=new FormData;a.forEach(d=>{l.append(this.responseIdentifier,d)}),this._internals.setFormValue(l)}else this._internals.setFormValue(a||"")}placeResponse(a){let[l,...d]=a.split(" ").reverse(),p=Array.from(this.draggables),m=Array.from(this.droppables);d.forEach(f=>{if(f==="")return;let b=p.find(E=>E.getAttribute("identifier")===f),y=m.find(E=>E.getAttribute("identifier")===l);this.dropDraggableInDroppable(b,y)})}getValidAssociations(){let a=0;for(let l of this.droppables)a=a+this.getDraggablesFromDroppable(l).length;return a}saveResponse(){let a;typeof this.getResponse=="function"?a=this.getResponse():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(l=>{let p=this.getDraggablesFromDroppable(l).map(f=>f.getAttribute("identifier")),m=l.getAttribute("identifier");return p.map(f=>`${f} ${m}`)}).flat()}getDraggablesFromDroppable(a){return this.draggables.map(p=>p.getAttribute("identifier")).filter((p,m,f)=>f.indexOf(p)===m).flatMap(p=>Array.from(a.querySelectorAll(`[identifier='${p}']`))).filter(p=>!!p).map(p=>p)}reset(a=!0){this.droppables.forEach(l=>{this.getDraggablesFromDroppable(l).forEach(p=>{p.remove(),this.draggablesModified([],[p])})}),this.dragContainers.forEach(l=>{Array.from(l.querySelectorAll('[qti-draggable="true"]')).forEach(p=>{p.style.opacity="1.0"})}),this.dragClone=null,this.dragSource=null,this.isDragging=!1,this.isDraggable=!1,this.currentDropTarget=null,this.lastTarget=null,a&&this.saveResponse()}updateDragClonePosition(a){if(!this.isDragging||!this.dragClone)return;let l=a.clientX-this.cloneOffset.x,d=a.clientY-this.cloneOffset.y,{newLeft:p,newTop:m}=this.applyInteractionBoundaries(l,d,this.dragClone);this.dragClone.style.left=`${p}px`,this.dragClone.style.top=`${m}px`}applyInteractionBoundaries(a,l,d){let p=this.getBoundingClientRect(),m=d.getBoundingClientRect(),f=m.width,b=m.height,y=Math.max(p.left,Math.min(a,p.right-f)),E=Math.max(p.top,Math.min(l,p.bottom-b));return{newLeft:y,newTop:E}}getEventCoordinates(a,l=!1){let d=a.touches?a.touches[0]:a;return{x:l?d.pageX:d.clientX,y:l?d.pageY:d.clientY}}calculateDragDistance(a){let l=Math.abs(a.clientX-this.touchStartPoint.x),d=Math.abs(a.clientY-this.touchStartPoint.y);return l+d}getDropzoneRect(a){return(a.shadowRoot?.querySelector('slot[part="dropslot"]')??a).getBoundingClientRect()}findClosestDropzone(){let a=this.allDropzones.filter(f=>!f.hasAttribute("disabled"));if(!this.dragClone||a.length===0)return null;let l=this.dragClone.getBoundingClientRect(),d=null,p=0,m=f=>{for(let b of f){let y=this.getDropzoneRect(b),E=this.calculateOverlapArea(l,y);E>p&&(p=E,d=b)}};if(m(this.droppables.filter(f=>!f.hasAttribute("disabled"))),d||m(this.dragContainers.filter(f=>!f.hasAttribute("disabled"))),!d){let f=Number.POSITIVE_INFINITY;for(let b of a){let y=this.getDropzoneRect(b),E=Math.hypot(l.left-y.left,l.top-y.top);E<f&&(f=E,d=b)}}return d}calculateOverlapArea(a,l){let d=Math.max(0,Math.min(a.right,l.right)-Math.max(a.left,l.left)),p=Math.max(0,Math.min(a.bottom,l.bottom)-Math.max(a.top,l.top));return d*p}dispatchCustomEvent(a,l,d=!0){if(!a)return;let p=new CustomEvent(l,{bubbles:d,cancelable:!0});p.dataTransfer=this.dataTransfer,a.dispatchEvent(p)}appendClone(){document.body.appendChild(this.dragClone)}handleTouchStart(a){if(this.isMatchTabular()||a instanceof MouseEvent&&a.button!==0||this.isDragging)return;let{x:l,y:d}=this.getEventCoordinates(a);this.touchStartPoint={x:l,y:d},this.dragSource=a.currentTarget,this.isDraggable=!0,this._internals.states.add("--dragzone-enabled"),this._internals.states.add("--dragzone-active"),this.activateDragLocation(),this.activateDroppables(this.dragSource);let p=this.findDraggableInDraggableContainer(this.dragSource.getAttribute("identifier")),m=this.droppables.some(q=>Array.from(q.children).some(T=>T===this.dragSource)),f=this.dragSource.getBoundingClientRect();m&&(this.dragSource.remove(),this.draggablesModified([],[this.dragSource]),this.dragSource=p),this.cloneOffset.x=l-f.left,this.cloneOffset.y=d-f.top,this.dragClone=p.cloneNode(!0);let b=window.getComputedStyle(p);for(let q=0;q<b.length;q++){let T=b[q];this.dragClone.style.setProperty(T,b.getPropertyValue(T))}let y=p.getBoundingClientRect();this.dragClone.style.width=`${y.width}px`,this.dragClone.style.height=`${y.height}px`,f&&this.setDragCloneStyles(f),this.dragClone.style.display="block",this.dragClone.style.opacity="1",this.appendClone();let E=this.getMatchMaxValue(this.dragSource),S=this.draggables.filter(q=>q.getAttribute("identifier")===this.dragSource.getAttribute("identifier"));E!==0&&S.length>=E?(p.style.opacity="0.0",p.style.pointerEvents="none"):p.style.opacity="1.0",a.preventDefault(),this.dragClone.setAttribute("dragging","")}findDraggableInDraggableContainer(a){let l=this.dragContainers.flat();for(let d of l){if(d.getAttribute("identifier")===a)return d;let p;d instanceof HTMLSlotElement?p=Array.from(d?.assignedElements()||[]):p=Array.from(d.querySelectorAll(r));let m=p.find(f=>f.getAttribute("identifier")===a);if(m)return m}}setDragCloneStyles(a){this.dragClone.style.position="fixed",this.dragClone.style.top=`${a.top}px`,this.dragClone.style.left=`${a.left}px`,this.dragClone.style.setProperty("box-sizing","border-box","important"),this.dragClone.style.zIndex="9999",this.dragClone.style.pointerEvents="none",this.dragClone.style.opacity=this.DRAG_CLONE_OPACITY.toString(),this.dragClone.style.display="block"}}return c([u({attribute:!1,type:Object})],i.prototype,"configuration",2),c([u({type:Number,reflect:!0,attribute:"min-associations"})],i.prototype,"minAssociations",2),c([u({type:Number,reflect:!0,attribute:"max-associations"})],i.prototype,"maxAssociations",2),c([jr(t)],i.prototype,"handleDraggableContainerChange",1),c([jr(r)],i.prototype,"handleDraggablesChange",1),c([jr(e)],i.prototype,"handleDroppablesChange",1),i};var oo=x`
95
+ `,Jt=c([g("qti-associable-hotspot")],Jt);var so=(o,r,e)=>{class t extends o{}return t};var se=(o,r,e,t)=>{class i extends so(o,e,r){constructor(){super(...arguments);this.observer=null;this.droppableObsever=null;this.resizeObserver=null;this.draggables=[];this.droppables=[];this.dragContainers=[];this.dragClone=null;this.dragSource=null;this.touchStartPoint=null;this.isDraggable=!1;this.cloneOffset={x:0,y:0};this.isDragging=!1;this.allDropzones=[];this.lastTarget=null;this.currentDropTarget=null;this.onMove=this.handleTouchMove.bind(this);this.onEnd=this.handleTouchEnd.bind(this);this.onCancel=this.handleTouchCancel.bind(this);this.MIN_DRAG_DISTANCE=5;this.DRAG_CLONE_OPACITY=1;this.MAX_DRAGGABLE_WIDTH=600;this.dataTransfer={data:{},setData(a,l){this.data[a]=l},getData(a){return this.data[a]},effectAllowed:"move"};this.configuration={copyStylesDragClone:!0,dragCanBePlacedBack:!0,dragOnClick:!1};this.minAssociations=1;this.maxAssociations=0;this.draggablesModified=(a,l)=>{if(this.isMatchTabular())return;for(let p of l)this.draggables.includes(p)&&(this.draggables=this.draggables.filter(m=>m!==p),p.removeAttribute("tabindex"),p.removeEventListener("touchstart",this.handleTouchStart.bind(this)),p.removeEventListener("mousedown",this.handleTouchStart.bind(this)));for(let p of a)this.draggables.includes(p)||(this.draggables.push(p),p.setAttribute("tabindex","0"),p.hasTouchStartListener||(p.addEventListener("touchstart",this.handleTouchStart.bind(this),{passive:!1}),p.addEventListener("mousedown",this.handleTouchStart.bind(this),{passive:!1}),p.hasTouchStartListener=!0));let d=0;this.draggables.forEach(p=>{p.style.viewTransitionName=`drag-${d}-${this.getAttribute("identifier")||crypto.randomUUID()}`,p.setAttribute("qti-draggable","true"),d++})};this.droppablesModified=(a,l)=>{if(!this.isMatchTabular()){for(let d of l)this.droppables.includes(d)&&(this.droppables=this.droppables.filter(p=>p!==d),this.allDropzones=this.allDropzones.filter(p=>p!==d));for(let d of a)this.droppables.includes(d)||(this.droppables.push(d),this.allDropzones.push(d));for(let d of this.droppables)this.dataset.choicesContainerWidth&&(d.style.width=`${this.dataset.choicesContainerWidth}px`,d.style.boxSizing="border-box")}}}handleDraggableContainerChange(a,l){this.isMatchTabular()||(a.length>0||l.length>0)&&this.dragContainersModified(a||[],l||[])}dragContainersModified(a,l){for(let d of l)this.dragContainers.includes(d)&&(this.dragContainers=this.dragContainers.filter(p=>p!==d),this.allDropzones=this.allDropzones.filter(p=>p!==d));for(let d of a)this.dragContainers.includes(d)||(this.dragContainers.push(d),this.allDropzones.push(d))}handleDraggablesChange(a,l){this.isMatchTabular()||(a.length>0||l.length>0)&&this.draggablesModified(a||[],l||[])}handleDroppablesChange(a,l){this.isMatchTabular()||(a.length>0||l.length>0)&&this.droppablesModified(a||[],l||[])}firstUpdated(a){if(super.firstUpdated(a),this.isMatchTabular())return;this.hasAttribute("disabled")||(document.addEventListener("mousemove",this.onMove,{passive:!1}),document.addEventListener("mouseup",this.onEnd,{passive:!1}),document.addEventListener("touchmove",this.onMove,{passive:!1}),document.addEventListener("touchend",this.onEnd,{passive:!1}),document.addEventListener("touchcancel",this.onCancel,{passive:!1}));let d=Array.from(this.querySelectorAll(r)||[]).concat(Array.from(this.shadowRoot?.querySelectorAll(r)||[])),p=Array.from(this.querySelectorAll(e)||[]).concat(Array.from(this.shadowRoot?.querySelectorAll(e)||[])),m=Array.from(this.querySelectorAll(t)||[]).concat(Array.from(this.shadowRoot?.querySelectorAll(t)||[]));this.dragContainersModified(m,[]),this.droppablesModified(p,[]),this.draggablesModified(d,[]),this.updateMinDimensionsForDropZones(),this.observer=new MutationObserver(()=>this.updateMinDimensionsForDropZones()),this.observer.observe(this,{childList:!0,subtree:!0}),this.resizeObserver=new ResizeObserver(()=>this.updateMinDimensionsForDropZones()),this.querySelectorAll("qti-gap-text").forEach(b=>this.resizeObserver?.observe(b))}async moveDraggableToDroppable(a,l){if(this.isMatchTabular())return;(()=>{a.style.transform="translate(0, 0)",l.tagName==="SLOT"?a.setAttribute("slot",l.getAttribute("name")):l.appendChild(a),this.checkAllMaxAssociations(),this.saveResponse()})()}activateDroppable(a){this.dragContainers.includes(a)?(this._internals.states.add("--dragzone-active"),a.setAttribute("active","")):(this._internals.states.delete("--dragzone-active"),a.setAttribute("active",""))}deactivateDroppable(a,l=!0){l&&this._internals.states.add("--dragzone-active"),a.removeAttribute("active")}connectedCallback(){super.connectedCallback()}isMatchTabular(){return this.classList.contains("qti-match-tabular")}async updateMinDimensionsForDropZones(){if(await this.updateComplete,this.isMatchTabular())return;let a=this.querySelectorAll(r),l=this.querySelector(t)||this.shadowRoot?.querySelector(t),d=this.querySelectorAll(e),p=d[0]?.parentElement,m=this.determineMaxWidth(l,p),f=0,b=0;for(let y of a){y.style.maxWidth=m+"px";let{width:C,height:A}=await this.measureIntrinsicSize(y);f=Math.max(f,A),b=Math.max(b,C)}p&&(p.style.gridTemplateColumns=`repeat(auto-fit, minmax(calc(min(${m}px,${b}px + 2 * var(--qti-dropzone-padding))), 1fr))`),l&&(l.style.minHeight=`${f}px`);for(let y of d){y.style.minHeight=`${f}px`,y.style.minWidth=`${b}px`;let C=y.shadowRoot?.querySelector('slot[part="dropslot"]');C&&(C.style.minHeight=`${f}px`)}}determineMaxWidth(a,l){let d=l??a;if(!d||d.clientWidth==0)return this.MAX_DRAGGABLE_WIDTH;let p=window.getComputedStyle(d),m=parseFloat(p.paddingLeft),f=parseFloat(p.paddingRight);return Math.min(this.MAX_DRAGGABLE_WIDTH,d.clientWidth-m-f)}async measureIntrinsicSize(a){let l=a.style.position;a.style.position="fixed";let d=a.getBoundingClientRect();return a.style.position=l,{width:d.width,height:d.height}}activateDroppables(a){if(this.isMatchTabular())return;this.dragContainers.forEach(d=>{d.setAttribute("enabled",""),d.hasAttribute("disabled")&&(d.contains(a)||d.shadowRoot&&d.shadowRoot.contains(a))&&d.removeAttribute("disabled")}),this.droppables.forEach(d=>{d.setAttribute("enabled",""),d.hasAttribute("disabled")&&(d.contains(a)||d.shadowRoot&&d.shadowRoot.contains(a))&&d.removeAttribute("disabled")})}activateDragLocation(){this._internals.states.add("--dragzone-enabled")}deactivateDragLocation(){this._internals.states.delete("--dragzone-enabled")}deactivateDroppables(){this.dragContainers.forEach(l=>{l.removeAttribute("enabled"),l.removeAttribute("active")}),this.droppables.forEach(l=>{l.removeAttribute("enabled"),l.removeAttribute("active")})}disconnectedCallback(){super.disconnectedCallback(),this.observer&&(this.observer.disconnect(),this.observer=null),this.droppableObsever&&(this.droppableObsever.disconnect(),this.droppableObsever=null),this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),document.removeEventListener("mousemove",this.onMove),document.removeEventListener("mouseup",this.onEnd),document.removeEventListener("touchmove",this.onMove),document.removeEventListener("touchend",this.onEnd),document.removeEventListener("touchcancel",this.onCancel)}handleTouchMove(a){if(!this.isMatchTabular()&&this.isDraggable&&this.dragClone){let{x:l,y:d}=this.getEventCoordinates(a),p={clientX:l,clientY:d};this.calculateDragDistance(p)>=this.MIN_DRAG_DISTANCE&&(this.isDragging=!0,this.updateDragClonePosition(p));let m=this.findClosestDropzone();this.currentDropTarget=m,m!==this.lastTarget&&(this.lastTarget&&(this.deactivateDroppable(this.lastTarget),this.dispatchCustomEvent(this.lastTarget,"dragleave")),m&&(this.activateDroppable(m),this.dispatchCustomEvent(m,"dragenter")),this.lastTarget=m),this.currentDropTarget&&this.dispatchCustomEvent(this.currentDropTarget,"dragover"),a.preventDefault()}}handleTouchEnd(a){this.isMatchTabular()||((this.isDragging||this.isDraggable||this.dragClone)&&this.resetDragState(),this._internals.states.delete("--dragzone-active"),this.checkAllMaxAssociations(),this._internals.states.delete("--dragzone-enabled"),this._internals.states.delete("--dragzone-active"),this.deactivateDragLocation(),this.deactivateDroppables(),this.draggables.forEach(l=>{l.removeAttribute("dragging")}),a.preventDefault())}handleTouchCancel(a){this.resetDragState()}validate(){if(this.isMatchTabular())return;if(!this.shadowRoot)return!1;let a=this.getValidAssociations(),l=!0,d="";this.maxAssociations>0&&a>this.maxAssociations?(l=!1,d=this.dataset.maxSelectionsMessage||`You've selected too many associations. Maximum allowed is ${this.maxAssociations}.`):this.minAssociations>0&&a<this.minAssociations&&(l=!1,d=this.dataset.minSelectionsMessage||`You haven't selected enough associations. Minimum required is ${this.minAssociations}.`);let p=this.lastElementChild;return this._internals.setValidity(l?{}:{customError:!0},d,p),l}reportValidity(){let a=this.shadowRoot.querySelector("#validation-message");return a&&(this._internals.validity.valid?(a.textContent="",a.style.display="none"):(a.textContent=this._internals.validationMessage,a.style.setProperty("display","block","important"))),this._internals.validity.valid}checkMaxAssociations(a){let l=this.getMatchMaxValue(a),d=a.querySelectorAll('[qti-draggable="true"]').length;return!(l===0)&&d>=l}dropDraggableInDroppable(a,l){let d=a.cloneNode(!0);d.removeAttribute("style"),this.moveDraggableToDroppable(d,l),this.draggablesModified([d],[]);let p=this.getMatchMaxValue(a),m=this.draggables.filter(f=>f.getAttribute("identifier")===a.getAttribute("identifier"));p!==0&&m.length>=p?(a.style.opacity="0.0",a.style.pointerEvents="none"):a.style.opacity="1.0"}resetDragState(){if(this.dragClone){let a=this.currentDropTarget!==null,l=!a||this.dragContainers.includes(this.currentDropTarget);a&&this.currentDropTarget&&!l&&this.dropDraggableInDroppable(this.dragSource,this.currentDropTarget),l&&(this.dragSource.style.opacity="1.0",this.dragSource.style.display="block",this.dragSource.style.position="static",this.dragSource.style.pointerEvents="auto",this.saveResponse()),this.dragClone.remove(),this.draggablesModified([],[this.dragClone])}this.isDragging=!1,this.isDraggable=!1,this.dragSource=null,this.dragClone=null,this.touchStartPoint=null,this.currentDropTarget=null,this.lastTarget=null,this.deactivateDroppables()}checkAllMaxAssociations(){let a=this.getValidAssociations(),l=this.maxAssociations!==0&&a>=this.maxAssociations;this.droppables.forEach(d=>{l?this.disableDroppable(d):this.checkMaxAssociations(d)?this.disableDroppable(d):this.enableDroppable(d)})}getMatchMaxValue(a){let l=a.getAttribute("match-max");return l?parseInt(l,10):1}disableDroppable(a){a.setAttribute("disabled","")}enableDroppable(a){a.removeAttribute("disabled")}get response(){let a;return typeof this.getResponse=="function"?a=this.getResponse():a=this.collectResponseData(),a.join(",")}set response(a){if(!this.isMatchTabular())if(typeof this.getValue=="function"&&(a=this.getValue(a)),Array.isArray(a)){this.reset(!1),a?.forEach(d=>this.placeResponse(d));let l=new FormData;a.forEach(d=>{l.append(this.responseIdentifier,d)}),this._internals.setFormValue(l)}else this._internals.setFormValue(a||"")}placeResponse(a){let[l,...d]=a.split(" ").reverse(),p=Array.from(this.draggables),m=Array.from(this.droppables);d.forEach(f=>{if(f==="")return;let b=p.find(C=>C.getAttribute("identifier")===f),y=m.find(C=>C.getAttribute("identifier")===l);this.dropDraggableInDroppable(b,y)})}getValidAssociations(){let a=0;for(let l of this.droppables)a=a+this.getDraggablesFromDroppable(l).length;return a}saveResponse(){let a;typeof this.getResponse=="function"?a=this.getResponse():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(l=>{let p=this.getDraggablesFromDroppable(l).map(f=>f.getAttribute("identifier")),m=l.getAttribute("identifier");return p.map(f=>`${f} ${m}`)}).flat()}getDraggablesFromDroppable(a){return this.draggables.map(p=>p.getAttribute("identifier")).filter((p,m,f)=>f.indexOf(p)===m).flatMap(p=>Array.from(a.querySelectorAll(`[identifier='${p}']`))).filter(p=>!!p).map(p=>p)}reset(a=!0){this.droppables.forEach(l=>{this.getDraggablesFromDroppable(l).forEach(p=>{p.remove(),this.draggablesModified([],[p])})}),this.dragContainers.forEach(l=>{Array.from(l.querySelectorAll('[qti-draggable="true"]')).forEach(p=>{p.style.opacity="1.0"})}),this.dragClone=null,this.dragSource=null,this.isDragging=!1,this.isDraggable=!1,this.currentDropTarget=null,this.lastTarget=null,a&&this.saveResponse()}updateDragClonePosition(a){if(!this.isDragging||!this.dragClone)return;let l=a.clientX-this.cloneOffset.x,d=a.clientY-this.cloneOffset.y,{newLeft:p,newTop:m}=this.applyInteractionBoundaries(l,d,this.dragClone);this.dragClone.style.left=`${p}px`,this.dragClone.style.top=`${m}px`}applyInteractionBoundaries(a,l,d){let p=this.getBoundingClientRect(),m=d.getBoundingClientRect(),f=m.width,b=m.height,y=Math.max(p.left,Math.min(a,p.right-f)),C=Math.max(p.top,Math.min(l,p.bottom-b));return{newLeft:y,newTop:C}}getEventCoordinates(a,l=!1){let d=a.touches?a.touches[0]:a;return{x:l?d.pageX:d.clientX,y:l?d.pageY:d.clientY}}calculateDragDistance(a){let l=Math.abs(a.clientX-this.touchStartPoint.x),d=Math.abs(a.clientY-this.touchStartPoint.y);return l+d}getDropzoneRect(a){return(a.shadowRoot?.querySelector('slot[part="dropslot"]')??a).getBoundingClientRect()}findClosestDropzone(){let a=this.allDropzones.filter(f=>!f.hasAttribute("disabled"));if(!this.dragClone||a.length===0)return null;let l=this.dragClone.getBoundingClientRect(),d=null,p=0,m=f=>{for(let b of f){let y=this.getDropzoneRect(b),C=this.calculateOverlapArea(l,y);C>p&&(p=C,d=b)}};if(m(this.droppables.filter(f=>!f.hasAttribute("disabled"))),d||m(this.dragContainers.filter(f=>!f.hasAttribute("disabled"))),!d){let f=Number.POSITIVE_INFINITY;for(let b of a){let y=this.getDropzoneRect(b),C=Math.hypot(l.left-y.left,l.top-y.top);C<f&&(f=C,d=b)}}return d}calculateOverlapArea(a,l){let d=Math.max(0,Math.min(a.right,l.right)-Math.max(a.left,l.left)),p=Math.max(0,Math.min(a.bottom,l.bottom)-Math.max(a.top,l.top));return d*p}dispatchCustomEvent(a,l,d=!0){if(!a)return;let p=new CustomEvent(l,{bubbles:d,cancelable:!0});p.dataTransfer=this.dataTransfer,a.dispatchEvent(p)}appendClone(){document.body.appendChild(this.dragClone)}handleTouchStart(a){if(this.isMatchTabular()||a instanceof MouseEvent&&a.button!==0||this.isDragging)return;let{x:l,y:d}=this.getEventCoordinates(a);this.touchStartPoint={x:l,y:d},this.dragSource=a.currentTarget,this.isDraggable=!0,this._internals.states.add("--dragzone-enabled"),this._internals.states.add("--dragzone-active"),this.activateDragLocation(),this.activateDroppables(this.dragSource);let p=this.findDraggableInDraggableContainer(this.dragSource.getAttribute("identifier")),m=this.droppables.some(q=>Array.from(q.children).some(T=>T===this.dragSource)),f=this.dragSource.getBoundingClientRect();m&&(this.dragSource.remove(),this.draggablesModified([],[this.dragSource]),this.dragSource=p),this.cloneOffset.x=l-f.left,this.cloneOffset.y=d-f.top,this.dragClone=p.cloneNode(!0);let b=window.getComputedStyle(p);for(let q=0;q<b.length;q++){let T=b[q];this.dragClone.style.setProperty(T,b.getPropertyValue(T))}let y=p.getBoundingClientRect();this.dragClone.style.width=`${y.width}px`,this.dragClone.style.height=`${y.height}px`,f&&this.setDragCloneStyles(f),this.dragClone.style.display="block",this.dragClone.style.opacity="1",this.appendClone();let C=this.getMatchMaxValue(this.dragSource),A=this.draggables.filter(q=>q.getAttribute("identifier")===this.dragSource.getAttribute("identifier"));C!==0&&A.length>=C?(p.style.opacity="0.0",p.style.pointerEvents="none"):p.style.opacity="1.0",a.preventDefault(),this.dragClone.setAttribute("dragging","")}findDraggableInDraggableContainer(a){let l=this.dragContainers.flat();for(let d of l){if(d.getAttribute("identifier")===a)return d;let p;d instanceof HTMLSlotElement?p=Array.from(d?.assignedElements()||[]):p=Array.from(d.querySelectorAll(r));let m=p.find(f=>f.getAttribute("identifier")===a);if(m)return m}}setDragCloneStyles(a){this.dragClone.style.position="fixed",this.dragClone.style.top=`${a.top}px`,this.dragClone.style.left=`${a.left}px`,this.dragClone.style.setProperty("box-sizing","border-box","important"),this.dragClone.style.zIndex="9999",this.dragClone.style.pointerEvents="none",this.dragClone.style.opacity=this.DRAG_CLONE_OPACITY.toString(),this.dragClone.style.display="block"}}return c([u({attribute:!1,type:Object})],i.prototype,"configuration",2),c([u({type:Number,reflect:!0,attribute:"min-associations"})],i.prototype,"minAssociations",2),c([u({type:Number,reflect:!0,attribute:"max-associations"})],i.prototype,"maxAssociations",2),c([jr(t)],i.prototype,"handleDraggableContainerChange",1),c([jr(r)],i.prototype,"handleDraggablesChange",1),c([jr(e)],i.prototype,"handleDroppablesChange",1),i};var oo=x`
96
96
  :host {
97
97
  display: block; /* necessary to calculate scaling position */
98
98
  }
@@ -126,7 +126,7 @@ Make sure to test your application with a production build as repeat registratio
126
126
  rgb(0 0 0 / 0%) calc(50% + 1px)
127
127
  );
128
128
  }
129
- `;var oe=Symbol("configContext");var k=class extends v{constructor(){super();this.disabled=!1;this.readonly=!1;this._internals=this.attachInternals()}static{this.formAssociated=!0}get internals(){return this._internals}get isFullCorrectResponse(){return this._isFullCorrectResponse}set isFullCorrectResponse(e){this._isFullCorrectResponse=e,e&&(this.disabled=!0,this.setAttribute("response-identifier",this.responseIdentifier+"_cr"))}get correctResponse(){return this._correctResponse}set correctResponse(e){this._correctResponse=e}get correctness(){let e=this.responseVariable;return!e||e.correctResponse===null?null:e.correctResponse===e.value?"correct":"incorrect"}get isInline(){return!1}get responseVariable(){let e=this._context.variables.filter(i=>i.type==="response"),t=this.getAttribute("response-identifier");return e.find(i=>i.identifier===t)}toggleCorrectResponse(e){(this?.configContext?.correctResponseMode||"internal")==="full"?this.toggleFullCorrectResponse(e):this.toggleInternalCorrectResponse(e)}async toggleFullCorrectResponse(e){let t=this.nextSibling,i=t instanceof HTMLDivElement&&t?.classList.contains("full-correct-response"),s=this.responseVariable;if(!s)return;if(!(e&&(this?.configContext?.fullCorrectResponseOnlyWhenIncorrect===!1||this.correctness!=="correct"))){if(!i)return;this.parentElement?.removeChild(t)}if(i)return;let a=this.cloneNode(!0),l=document.createElement("div");l.classList.add("full-correct-response"),this.isInline?l.classList.add("full-correct-response-inline"):l.classList.add("full-correct-response-block"),l.role="full-correct-response",l.appendChild(a),a.isFullCorrectResponse=!0,this.parentElement?.insertBefore(l,this.nextSibling),await a.updateComplete,a.response=Array.isArray(s.correctResponse)?[...s.correctResponse]:s.correctResponse}toggleInternalCorrectResponse(e){let t=this.responseVariable;this.correctResponse=e?t?.correctResponse:t?.cardinality==="single"?"":[]}toggleCandidateCorrection(e){this.responseVariable&&(this._internals.states.delete("candidate-correct"),this._internals.states.delete("candidate-partially-correct"),this._internals.states.delete("candidate-incorrect"),e&&(this.correctness==="correct"&&this._internals.states.add("candidate-correct"),this.correctness==="partially-correct"&&this._internals.states.add("candidate-partially-correct"),this.correctness==="incorrect"&&this._internals.states.add("candidate-incorrect")))}get value(){return JSON.stringify(this.response)}set value(e){this.response=e?JSON.parse(e):null}reportValidity(){return this._internals.reportValidity()}reset(){this.response=null}connectedCallback(){super.connectedCallback(),!this.isFullCorrectResponse&&this.dispatchEvent(new CustomEvent("qti-register-interaction",{bubbles:!0,composed:!0,cancelable:!1,detail:{interactionElement:this,responseIdentifier:this.responseIdentifier}}))}saveResponse(e){this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,composed:!0,cancelable:!1,detail:{responseIdentifier:this.responseIdentifier,response:Array.isArray(e)?[...e]:e}}))}};c([_({context:$,subscribe:!0})],k.prototype,"_context",2),c([_({context:oe,subscribe:!0})],k.prototype,"configContext",2),c([u({type:String,attribute:"response-identifier"})],k.prototype,"responseIdentifier",2),c([u({reflect:!0,type:Boolean})],k.prototype,"disabled",2),c([u({reflect:!0,type:Boolean})],k.prototype,"readonly",2),c([C()],k.prototype,"_isFullCorrectResponse",2),c([C()],k.prototype,"_correctResponse",2);var ut=class extends se(k,"qti-simple-associable-choice",".dl","slot[name='qti-simple-associable-choice']"){constructor(){super();this._childrenMap=[];this._registerChoiceHandler=this._registerChoice.bind(this),this.addEventListener("register-qti-simple-associable-choice",this._registerChoiceHandler)}_registerChoice(e){let t=e.target;this._childrenMap.push(t)}render(){return h` <slot name="prompt"></slot>
129
+ `;var oe=Symbol("configContext");var S=class extends v{constructor(){super();this.disabled=!1;this.readonly=!1;this._internals=this.attachInternals()}static{this.formAssociated=!0}get internals(){return this._internals}get isFullCorrectResponse(){return this._isFullCorrectResponse}set isFullCorrectResponse(e){this._isFullCorrectResponse=e,e&&(this.disabled=!0,this.setAttribute("response-identifier",this.responseIdentifier+"_cr"))}get correctResponse(){return this._correctResponse}set correctResponse(e){this._correctResponse=e}get correctness(){let e=this.responseVariable;return!e||e.correctResponse===null?null:e.correctResponse===e.value?"correct":"incorrect"}get isInline(){return!1}get responseVariable(){let e=this._context.variables.filter(i=>i.type==="response"),t=this.getAttribute("response-identifier");return e.find(i=>i.identifier===t)}toggleCorrectResponse(e){(this?.configContext?.correctResponseMode||"internal")==="full"?this.toggleFullCorrectResponse(e):this.toggleInternalCorrectResponse(e)}async toggleFullCorrectResponse(e){let t=this.nextSibling,i=t instanceof HTMLDivElement&&t?.classList.contains("full-correct-response"),s=this.responseVariable;if(!s)return;if(!(e&&(this?.configContext?.fullCorrectResponseOnlyWhenIncorrect===!1||this.correctness!=="correct"))){if(!i)return;this.parentElement?.removeChild(t)}if(i)return;let a=this.cloneNode(!0),l=document.createElement("div");l.classList.add("full-correct-response"),this.isInline?l.classList.add("full-correct-response-inline"):l.classList.add("full-correct-response-block"),l.role="full-correct-response",l.appendChild(a),a.isFullCorrectResponse=!0,this.parentElement?.insertBefore(l,this.nextSibling),await a.updateComplete,a.response=Array.isArray(s.correctResponse)?[...s.correctResponse]:s.correctResponse}toggleInternalCorrectResponse(e){let t=this.responseVariable;this.correctResponse=e?t?.correctResponse:t?.cardinality==="single"?"":[]}toggleCandidateCorrection(e){this.responseVariable&&(this._internals.states.delete("candidate-correct"),this._internals.states.delete("candidate-partially-correct"),this._internals.states.delete("candidate-incorrect"),e&&(this.correctness==="correct"&&this._internals.states.add("candidate-correct"),this.correctness==="partially-correct"&&this._internals.states.add("candidate-partially-correct"),this.correctness==="incorrect"&&this._internals.states.add("candidate-incorrect")))}get value(){return JSON.stringify(this.response)}set value(e){this.response=e?JSON.parse(e):null}reportValidity(){return this._internals.reportValidity()}reset(){this.response=null}connectedCallback(){super.connectedCallback(),!this.isFullCorrectResponse&&this.dispatchEvent(new CustomEvent("qti-register-interaction",{bubbles:!0,composed:!0,cancelable:!1,detail:{interactionElement:this,responseIdentifier:this.responseIdentifier}}))}saveResponse(e){this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,composed:!0,cancelable:!1,detail:{responseIdentifier:this.responseIdentifier,response:Array.isArray(e)?[...e]:e}}))}};c([_({context:$,subscribe:!0})],S.prototype,"_context",2),c([_({context:oe,subscribe:!0})],S.prototype,"configContext",2),c([u({type:String,attribute:"response-identifier"})],S.prototype,"responseIdentifier",2),c([u({reflect:!0,type:Boolean})],S.prototype,"disabled",2),c([u({reflect:!0,type:Boolean})],S.prototype,"readonly",2),c([E()],S.prototype,"_isFullCorrectResponse",2),c([E()],S.prototype,"_correctResponse",2);var ut=class extends se(S,"qti-simple-associable-choice",".dl","slot[name='qti-simple-associable-choice']"){constructor(){super();this._childrenMap=[];this._registerChoiceHandler=this._registerChoice.bind(this),this.addEventListener("register-qti-simple-associable-choice",this._registerChoiceHandler)}_registerChoice(e){let t=e.target;this._childrenMap.push(t)}render(){return h` <slot name="prompt"></slot>
130
130
  <slot name="qti-simple-associable-choice"></slot>
131
131
  <div part="drop-container">
132
132
  ${this._childrenMap.length>0&&Array.from(Array(Math.ceil(this._childrenMap.length/2)).keys()).map((e,t)=>h`<div part="associables-container">
@@ -135,7 +135,7 @@ Make sure to test your application with a production build as repeat registratio
135
135
  </div>`)}
136
136
 
137
137
  <div role="alert" part="message" id="validation-message"></div>
138
- </div>`}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("register-qti-simple-associable-choice",this._registerChoiceHandler)}};ut.styles=oo,c([C()],ut.prototype,"_childrenMap",2),ut=c([g("qti-associate-interaction")],ut);var $e=(o,r)=>{class e extends o{constructor(){super(...arguments);this._choiceElements=[];this.minChoices=0;this.maxChoices=1;this._handleDisabledChange=(s,n)=>{this._choiceElements.forEach(a=>a.disabled=n)};this._handleReadonlyChange=(s,n)=>{this._choiceElements.forEach(a=>a.readonly=n)};this.response="";this._handleValueChange=()=>{this._internals.setFormValue(this.value),this._updateChoiceSelection()}}_handleMaxChoicesChange(s,n){this._determineInputType()}get value(){return Array.isArray(this.response)&&this.response.length===0||this.response===""?null:Array.isArray(this.response)?this.response.join(","):this.response}set value(s){this.maxChoices>1&&(typeof s=="string"||s===null)?this.response=s?s.toString().split(","):[]:this.response=s||""}toggleInternalCorrectResponse(s){let n=this.responseVariable;if(n?.correctResponse){let a=Array.isArray(n.correctResponse)?n.correctResponse:[n.correctResponse];this._choiceElements.forEach(l=>{l.internals.states.delete("correct-response"),l.internals.states.delete("incorrect-response"),s&&a.length>0&&(a.includes(l.identifier)?l.internals.states.add("correct-response"):l.internals.states.add("incorrect-response"))})}}toggleCandidateCorrection(s){let n=this.responseVariable;if(!n?.correctResponse)return;let a=Array.isArray(n.correctResponse)?n.correctResponse:[n.correctResponse],l=Array.isArray(n.value)?n.value:[n.value];this._choiceElements.forEach(d=>{d.internals.states.delete("candidate-correct"),d.internals.states.delete("candidate-incorrect"),s&&l.includes(d.identifier)&&(a.includes(d.identifier)?d.internals.states.add("candidate-correct"):d.internals.states.add("candidate-incorrect"))})}connectedCallback(){super.connectedCallback(),this.addEventListener(`register-${r}`,this._registerChoiceElement),this.addEventListener(`unregister-${r}`,this._unregisterChoiceElement),this.addEventListener(`activate-${r}`,this._choiceElementSelectedHandler)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(`register-${r}`,this._registerChoiceElement),this.removeEventListener(`unregister-${r}`,this._unregisterChoiceElement),this.removeEventListener(`activate-${r}`,this._choiceElementSelectedHandler)}validate(){let s=this._choiceElements.filter(d=>this._getChoiceChecked(d)),n=s.length,a=!0,l="";return this.maxChoices!==0&&n>this.maxChoices?(a=!1,l=this.dataset.maxSelectionsMessage||`Please select no more than ${this.maxChoices} ${this.maxChoices===1?"option":"options"}.`):n<this.minChoices&&(a=!1,l=this.dataset.minSelectionsMessage||`Please select at least ${this.minChoices} ${this.minChoices===1?"option":"options"}.`),s.length>0&&this._internals.setValidity(a?{}:{customError:!0},l,s[n-1]||this._choiceElements[0]||this),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.setProperty("display","block","important"))),this._internals.validity.valid}_registerChoiceElement(s){s.stopPropagation();let n=s.target;n.disabled=this.disabled,this._choiceElements.push(n),this._setInputType(n)}_unregisterChoiceElement(s){s.stopPropagation();let n=s.target;this._choiceElements=this._choiceElements.filter(a=>a!==n)}_determineInputType(){this._choiceElements.forEach(s=>{this._setInputType(s)})}_setInputType(s){this._internals.role=this.maxChoices===1?"radiogroup":null;let n=this.maxChoices===1?"radio":"checkbox";s.internals.role=n,s.internals.states.delete(n==="radio"?"checkbox":"radio"),s.internals.states.add(n)}_choiceElementSelectedHandler(s){this._toggleChoiceChecked(s.target),this.maxChoices===1?this._choiceElements.forEach(n=>{n.identifier!==s.detail.identifier&&this._setChoiceChecked(n,!1)}):this._configContext?.disableAfterIfMaxChoicesReached&&(this._choiceElements.filter(a=>this._getChoiceChecked(a)).length>=this.maxChoices?this._choiceElements.forEach(a=>{this._getChoiceChecked(a)||(a.disabled=!0)}):this._choiceElements.forEach(a=>a.disabled=!1)),this._handleChoiceSelection()}_setChoiceChecked(s,n){s.internals?.states&&(n?(s.internals.states.add("--checked"),s.internals.ariaChecked="true"):(s.internals.states.delete("--checked"),s.internals.ariaChecked="false"))}_getChoiceChecked(s){return s.internals.states.has("--checked")}_toggleChoiceChecked(s){let n=this._getChoiceChecked(s);this._setChoiceChecked(s,!n)}_handleChoiceSelection(){let n=this._choiceElements.filter(a=>this._getChoiceChecked(a)).map(a=>a.identifier);this.response=this.maxChoices===1?n[0]||"":n,this.validate(),this.saveResponse(this.response)}_updateChoiceSelection(){let s=Array.isArray(this.response)?this.response:[this.response];this._choiceElements.forEach(n=>{let a=s.includes(n.identifier);this._setChoiceChecked(n,a)})}}return c([lt("#validation-message")],e.prototype,"_validationMessageElement",2),c([u({type:Number,attribute:"min-choices"})],e.prototype,"minChoices",2),c([u({type:Number,attribute:"max-choices"})],e.prototype,"maxChoices",2),c([I("maxChoices",{waitUntilFirstUpdate:!0})],e.prototype,"_handleMaxChoicesChange",1),c([I("disabled",{waitUntilFirstUpdate:!0})],e.prototype,"_handleDisabledChange",2),c([I("readonly",{waitUntilFirstUpdate:!0})],e.prototype,"_handleReadonlyChange",2),c([C()],e.prototype,"response",2),c([I("response",{waitUntilFirstUpdate:!0})],e.prototype,"_handleValueChange",2),c([C(),_({context:oe,subscribe:!0})],e.prototype,"_configContext",2),e};var no=(o,r)=>{class e extends o{constructor(){super(...arguments);this._classes=[];this._allLabels=["qti-labels-decimal","qti-labels-lower-alpha","qti-labels-upper-alpha"];this._allLabelSuffixes=["qti-labels-suffix-period","qti-labels-suffix-parenthesis"]}set class(s){s&&(this._classes=s.split(" "),this._addLabels())}get class(){return this._classes?.join(" ")||""}updated(s){super.updated(s),this._addLabels()}_addLabels(){let s=this._classes.some(a=>this._allLabels.includes(a)||this._allLabelSuffixes.includes(a)),n=a=>!isNaN(+a);if(s){let l=Array.from(this.querySelectorAll("qti-simple-choice")).map(d=>d).map((d,p)=>({el:d,order:n(d.style.order)?+d.style.order:p+1})).sort((d,p)=>d.order-p.order).map(d=>d.el);for(let d=0;d<l.length;d++)l[d].marker=this._getLabel(d+1)}}_getLabel(s){let n=this._classes.filter(d=>this._allLabels.includes(d)).pop(),a=this._classes.filter(d=>this._allLabelSuffixes.includes(d)).pop();!n&&a&&(n="qti-labels-upper-alpha");let l="";switch(n){case"qti-labels-decimal":l=`${s}`;break;case"qti-labels-lower-alpha":l=`${String.fromCharCode(97+s-1)}`;break;case"qti-labels-upper-alpha":l=`${String.fromCharCode(65+s-1)}`;break}return a==="qti-labels-suffix-period"?l+=".":a==="qti-labels-suffix-parenthesis"&&(l+=")"),l}}return c([u({type:String,reflect:!0})],e.prototype,"class",1),e};var ao=x`
138
+ </div>`}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("register-qti-simple-associable-choice",this._registerChoiceHandler)}};ut.styles=oo,c([E()],ut.prototype,"_childrenMap",2),ut=c([g("qti-associate-interaction")],ut);var $e=(o,r)=>{class e extends o{constructor(){super(...arguments);this._choiceElements=[];this.minChoices=0;this.maxChoices=1;this._handleDisabledChange=(s,n)=>{this._choiceElements.forEach(a=>a.disabled=n)};this._handleReadonlyChange=(s,n)=>{this._choiceElements.forEach(a=>a.readonly=n)};this.response="";this._handleValueChange=()=>{this._internals.setFormValue(this.value),this._updateChoiceSelection()}}_handleMaxChoicesChange(s,n){this._determineInputType()}get value(){return Array.isArray(this.response)&&this.response.length===0||this.response===""?null:Array.isArray(this.response)?this.response.join(","):this.response}set value(s){this.maxChoices>1&&(typeof s=="string"||s===null)?this.response=s?s.toString().split(","):[]:this.response=s||""}toggleInternalCorrectResponse(s){let n=this.responseVariable;if(n?.correctResponse){let a=Array.isArray(n.correctResponse)?n.correctResponse:[n.correctResponse];this._choiceElements.forEach(l=>{l.internals.states.delete("correct-response"),l.internals.states.delete("incorrect-response"),s&&a.length>0&&(a.includes(l.identifier)?l.internals.states.add("correct-response"):l.internals.states.add("incorrect-response"))})}}toggleCandidateCorrection(s){let n=this.responseVariable;if(!n?.correctResponse)return;let a=Array.isArray(n.correctResponse)?n.correctResponse:[n.correctResponse],l=Array.isArray(n.value)?n.value:[n.value];this._choiceElements.forEach(d=>{d.internals.states.delete("candidate-correct"),d.internals.states.delete("candidate-incorrect"),s&&l.includes(d.identifier)&&(a.includes(d.identifier)?d.internals.states.add("candidate-correct"):d.internals.states.add("candidate-incorrect"))})}connectedCallback(){super.connectedCallback(),this.addEventListener(`register-${r}`,this._registerChoiceElement),this.addEventListener(`unregister-${r}`,this._unregisterChoiceElement),this.addEventListener(`activate-${r}`,this._choiceElementSelectedHandler)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(`register-${r}`,this._registerChoiceElement),this.removeEventListener(`unregister-${r}`,this._unregisterChoiceElement),this.removeEventListener(`activate-${r}`,this._choiceElementSelectedHandler)}validate(){let s=this._choiceElements.filter(d=>this._getChoiceChecked(d)),n=s.length,a=!0,l="";return this.maxChoices!==0&&n>this.maxChoices?(a=!1,l=this.dataset.maxSelectionsMessage||`Please select no more than ${this.maxChoices} ${this.maxChoices===1?"option":"options"}.`):n<this.minChoices&&(a=!1,l=this.dataset.minSelectionsMessage||`Please select at least ${this.minChoices} ${this.minChoices===1?"option":"options"}.`),s.length>0&&this._internals.setValidity(a?{}:{customError:!0},l,s[n-1]||this._choiceElements[0]||this),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.setProperty("display","block","important"))),this._internals.validity.valid}_registerChoiceElement(s){s.stopPropagation();let n=s.target;n.disabled=this.disabled,this._choiceElements.push(n),this._setInputType(n)}_unregisterChoiceElement(s){s.stopPropagation();let n=s.target;this._choiceElements=this._choiceElements.filter(a=>a!==n)}_determineInputType(){this._choiceElements.forEach(s=>{this._setInputType(s)})}_setInputType(s){this._internals.role=this.maxChoices===1?"radiogroup":null;let n=this.maxChoices===1?"radio":"checkbox";s.internals.role=n,s.internals.states.delete(n==="radio"?"checkbox":"radio"),s.internals.states.add(n)}_choiceElementSelectedHandler(s){this._toggleChoiceChecked(s.target),this.maxChoices===1?this._choiceElements.forEach(n=>{n.identifier!==s.detail.identifier&&this._setChoiceChecked(n,!1)}):this.maxChoices!==0&&this._configContext?.disableAfterIfMaxChoicesReached&&(this._choiceElements.filter(a=>this._getChoiceChecked(a)).length>=this.maxChoices?this._choiceElements.forEach(a=>{this._getChoiceChecked(a)||(a.disabled=!0)}):this._choiceElements.forEach(a=>a.disabled=!1)),this._handleChoiceSelection()}_setChoiceChecked(s,n){s.internals?.states&&(n?(s.internals.states.add("--checked"),s.internals.ariaChecked="true"):(s.internals.states.delete("--checked"),s.internals.ariaChecked="false"))}_getChoiceChecked(s){return s.internals.states.has("--checked")}_toggleChoiceChecked(s){let n=this._getChoiceChecked(s);this._setChoiceChecked(s,!n)}_handleChoiceSelection(){let n=this._choiceElements.filter(a=>this._getChoiceChecked(a)).map(a=>a.identifier);this.response=this.maxChoices===1?n[0]||"":n,this.validate(),this.saveResponse(this.response)}_updateChoiceSelection(){let s=Array.isArray(this.response)?this.response:[this.response];this._choiceElements.forEach(n=>{let a=s.includes(n.identifier);this._setChoiceChecked(n,a)})}}return c([lt("#validation-message")],e.prototype,"_validationMessageElement",2),c([u({type:Number,attribute:"min-choices"})],e.prototype,"minChoices",2),c([u({type:Number,attribute:"max-choices"})],e.prototype,"maxChoices",2),c([I("maxChoices",{waitUntilFirstUpdate:!0})],e.prototype,"_handleMaxChoicesChange",1),c([I("disabled",{waitUntilFirstUpdate:!0})],e.prototype,"_handleDisabledChange",2),c([I("readonly",{waitUntilFirstUpdate:!0})],e.prototype,"_handleReadonlyChange",2),c([E()],e.prototype,"response",2),c([I("response",{waitUntilFirstUpdate:!0})],e.prototype,"_handleValueChange",2),c([E(),_({context:oe,subscribe:!0})],e.prototype,"_configContext",2),e};var no=(o,r)=>{class e extends o{constructor(){super(...arguments);this._classes=[];this._allLabels=["qti-labels-decimal","qti-labels-lower-alpha","qti-labels-upper-alpha"];this._allLabelSuffixes=["qti-labels-suffix-period","qti-labels-suffix-parenthesis"]}set class(s){s&&(this._classes=s.split(" "),this._addLabels())}get class(){return this._classes?.join(" ")||""}updated(s){super.updated(s),this._addLabels()}_addLabels(){let s=this._classes.some(a=>this._allLabels.includes(a)||this._allLabelSuffixes.includes(a)),n=a=>!isNaN(+a);if(s){let l=Array.from(this.querySelectorAll("qti-simple-choice")).map(d=>d).map((d,p)=>({el:d,order:n(d.style.order)?+d.style.order:p+1})).sort((d,p)=>d.order-p.order).map(d=>d.el);for(let d=0;d<l.length;d++)l[d].marker=this._getLabel(d+1)}}_getLabel(s){let n=this._classes.filter(d=>this._allLabels.includes(d)).pop(),a=this._classes.filter(d=>this._allLabelSuffixes.includes(d)).pop();!n&&a&&(n="qti-labels-upper-alpha");let l="";switch(n){case"qti-labels-decimal":l=`${s}`;break;case"qti-labels-lower-alpha":l=`${String.fromCharCode(97+s-1)}`;break;case"qti-labels-upper-alpha":l=`${String.fromCharCode(65+s-1)}`;break}return a==="qti-labels-suffix-period"?l+=".":a==="qti-labels-suffix-parenthesis"&&(l+=")"),l}}return c([u({type:String,reflect:!0})],e.prototype,"class",1),e};var ao=x`
139
139
  :host {
140
140
  display: block;
141
141
  }
@@ -205,11 +205,11 @@ Make sure to test your application with a production build as repeat registratio
205
205
  :host(.qti-orientation-vertical) ::slotted(qti-simple-choice:nth-child(even)) {
206
206
  grid-row: auto;
207
207
  }
208
- `;var mt=class extends no($e(k,"qti-simple-choice"),"qti-simple-choice"){constructor(){super(...arguments);this.orientation="vertical"}_handleSlotChange(){let e=this.querySelectorAll("qti-simple-choice");this.style.setProperty("--item-count",e.length.toString())}render(){return h`
208
+ `;var mt=class extends no($e(S,"qti-simple-choice"),"qti-simple-choice"){constructor(){super(...arguments);this.orientation="vertical"}_handleSlotChange(){let e=this.querySelectorAll("qti-simple-choice");this.style.setProperty("--item-count",e.length.toString())}render(){return h`
209
209
  <slot part="prompt" name="prompt"></slot>
210
210
  <slot part="slot" @slotchange=${this._handleSlotChange}></slot>
211
211
  <div part="message" role="alert" id="validation-message"></div>
212
- `}};mt.styles=ao,c([u({type:String})],mt.prototype,"orientation",2),mt=c([g("qti-choice-interaction")],mt);var ve=class extends k{constructor(){super();this.rawResponse="";this._errorMessage=null;this.handlePostMessage=this.handlePostMessage.bind(this)}connectedCallback(){super.connectedCallback();let e=this.data.startsWith("http")||this.data.startsWith("blob")?this.data:Ke(this.baseItemUrl+"/"+this.data);fetch(e).then(t=>t.json()).then(t=>{this.manifest=t,this.setupCES()}).catch(t=>{this._errorMessage=t})}setupCES(){let t=this.shadowRoot.querySelector("#pciContainer").contentDocument;if(!this.manifest.script||this.manifest.script.length===0){this._errorMessage="No script found in manifest";return}if(!this.manifest.style||this.manifest.style.length===0){this._errorMessage="No style found in manifest";return}let i=this.manifest.style[0],s=i.startsWith("http")||i.startsWith("blob")?i:Ke(`${this.baseRefUrl}/${i}`),n=this.manifest.script[0],a=n.startsWith("http")||n.startsWith("blob")?n:Ke(`${this.baseRefUrl}/${n}`);window.addEventListener("message",this.handlePostMessage),t.open(),t.write(`
212
+ `}};mt.styles=ao,c([u({type:String})],mt.prototype,"orientation",2),mt=c([g("qti-choice-interaction")],mt);var ve=class extends S{constructor(){super();this.rawResponse="";this._errorMessage=null;this.handlePostMessage=this.handlePostMessage.bind(this)}connectedCallback(){super.connectedCallback();let e=this.data.startsWith("http")||this.data.startsWith("blob")?this.data:Ke(this.baseItemUrl+"/"+this.data);fetch(e).then(t=>t.json()).then(t=>{this.manifest=t,this.setupCES()}).catch(t=>{this._errorMessage=t})}setupCES(){let t=this.shadowRoot.querySelector("#pciContainer").contentDocument;if(!this.manifest.script||this.manifest.script.length===0){this._errorMessage="No script found in manifest";return}if(!this.manifest.style||this.manifest.style.length===0){this._errorMessage="No style found in manifest";return}let i=this.manifest.style[0],s=i.startsWith("http")||i.startsWith("blob")?i:Ke(`${this.baseRefUrl}/${i}`),n=this.manifest.script[0],a=n.startsWith("http")||n.startsWith("blob")?n:Ke(`${this.baseRefUrl}/${n}`);window.addEventListener("message",this.handlePostMessage),t.open(),t.write(`
213
213
  <html>
214
214
  <head>
215
215
  <link href='${s}' rel="stylesheet" />
@@ -228,7 +228,7 @@ Make sure to test your application with a production build as repeat registratio
228
228
  ${this._errorMessage&&h`<div style="color:red">
229
229
  <h1>Error</h1>
230
230
  ${this._errorMessage}
231
- </div>`}`}};c([u({type:String,attribute:"data"})],ve.prototype,"data",2),c([u({type:String,attribute:"data-base-item"})],ve.prototype,"baseItemUrl",2),c([u({type:String,attribute:"data-base-ref"})],ve.prototype,"baseRefUrl",2),c([u({type:String,attribute:"id"})],ve.prototype,"id",2),c([C()],ve.prototype,"_errorMessage",2),ve=c([g("qti-custom-interaction")],ve);var Pe=class extends v{constructor(){super(...arguments);this.disabled=!1;this.countAttempt=null;this.title="end attempt"}render(){return h`<button ?disabled=${this.disabled} part="button" @click=${this.endAttempt}>${this.title}</button>`}endAttempt(e){this.dispatchEvent(new CustomEvent("end-attempt",{bubbles:!0,composed:!0,detail:{responseIdentifier:this.responseIdentifier,countAttempt:this.countAttempt==="true"}}))}};c([u({type:String,attribute:"response-identifier"})],Pe.prototype,"responseIdentifier",2),c([u({reflect:!0,type:Boolean})],Pe.prototype,"disabled",2),c([u({type:String,attribute:"count-attempt"})],Pe.prototype,"countAttempt",2),c([u({type:String})],Pe.prototype,"title",2),Pe=c([g("qti-end-attempt-interaction")],Pe);var lo=x`
231
+ </div>`}`}};c([u({type:String,attribute:"data"})],ve.prototype,"data",2),c([u({type:String,attribute:"data-base-item"})],ve.prototype,"baseItemUrl",2),c([u({type:String,attribute:"data-base-ref"})],ve.prototype,"baseRefUrl",2),c([u({type:String,attribute:"id"})],ve.prototype,"id",2),c([E()],ve.prototype,"_errorMessage",2),ve=c([g("qti-custom-interaction")],ve);var Pe=class extends v{constructor(){super(...arguments);this.disabled=!1;this.countAttempt=null;this.title="end attempt"}render(){return h`<button ?disabled=${this.disabled} part="button" @click=${this.endAttempt}>${this.title}</button>`}endAttempt(e){this.dispatchEvent(new CustomEvent("end-attempt",{bubbles:!0,composed:!0,detail:{responseIdentifier:this.responseIdentifier,countAttempt:this.countAttempt==="true"}}))}};c([u({type:String,attribute:"response-identifier"})],Pe.prototype,"responseIdentifier",2),c([u({reflect:!0,type:Boolean})],Pe.prototype,"disabled",2),c([u({type:String,attribute:"count-attempt"})],Pe.prototype,"countAttempt",2),c([u({type:String})],Pe.prototype,"title",2),Pe=c([g("qti-end-attempt-interaction")],Pe);var lo=x`
232
232
  /* PK: display host as block, else design will be collapsed */
233
233
  :host {
234
234
  display: block;
@@ -239,7 +239,7 @@ Make sure to test your application with a production build as repeat registratio
239
239
  height: 100%;
240
240
  border: 0;
241
241
  }
242
- `;var U=class extends k{constructor(){super(...arguments);this._rows=5;this.response=null;this._handleResponseChange=()=>{this._internals.setFormValue(this.value),this.validate()}}handleclassNamesChange(e,t){let i=t.split(" "),s=!1;if(i.forEach(n=>{if(n.startsWith("qti-height-lines-")){let a=n.replace("qti-height-lines-","");this._rows=parseInt(a),s=!0}}),!s&&this.expectedLength){let n=Math.ceil(this.expectedLength/50);this._rows=n}}get value(){return this.response||null}set value(e){this.response=e||null}validate(){let e=this.shadowRoot.querySelector("textarea");if(!e)return!1;if(this.patternMask&&this.dataPatternmaskMessage){this._internals.setValidity({}),e.setCustomValidity("");let t=this.patternMask.startsWith("^")&&this.patternMask.endsWith("$")?this.patternMask:`^${this.patternMask}$`,i=new RegExp(t);e.checkValidity()&&i.test(e.value)||(this._internals.setValidity({customError:!0},this.dataPatternmaskMessage),e.setCustomValidity(this.dataPatternmaskMessage))}else{let t=e.checkValidity();this._internals.setValidity(t?{}:{customError:!1})}return!!this.response&&e.checkValidity()}toggleCorrectResponse(){}reportValidity(){let e=this.shadowRoot.querySelector("textarea");if(!e)return!1;let t=this.validate();return t||e.reportValidity(),t}render(){return h`<slot name="prompt"></slot
242
+ `;var j=class extends S{constructor(){super(...arguments);this._rows=5;this.response=null;this._handleResponseChange=()=>{this._internals.setFormValue(this.value),this.validate()}}handleclassNamesChange(e,t){let i=t.split(" "),s=!1;if(i.forEach(n=>{if(n.startsWith("qti-height-lines-")){let a=n.replace("qti-height-lines-","");this._rows=parseInt(a),s=!0}}),!s&&this.expectedLength){let n=Math.ceil(this.expectedLength/50);this._rows=n}}get value(){return this.response||null}set value(e){this.response=e||null}validate(){let e=this.shadowRoot.querySelector("textarea");if(!e)return!1;if(this.patternMask&&this.dataPatternmaskMessage){this._internals.setValidity({}),e.setCustomValidity("");let t=this.patternMask.startsWith("^")&&this.patternMask.endsWith("$")?this.patternMask:`^${this.patternMask}$`,i=new RegExp(t);e.checkValidity()&&i.test(e.value)||(this._internals.setValidity({customError:!0},this.dataPatternmaskMessage),e.setCustomValidity(this.dataPatternmaskMessage))}else{let t=e.checkValidity();this._internals.setValidity(t?{}:{customError:!1})}return!!this.response&&e.checkValidity()}toggleCorrectResponse(){}reportValidity(){let e=this.shadowRoot.querySelector("textarea");if(!e)return!1;let t=this.validate();return t||e.reportValidity(),t}render(){return h`<slot name="prompt"></slot
243
243
  ><textarea
244
244
  part="textarea"
245
245
  name="${this.responseIdentifier}"
@@ -255,7 +255,7 @@ Make sure to test your application with a production build as repeat registratio
255
255
  ?disabled="${this.disabled}"
256
256
  ?readonly="${this.readonly}"
257
257
  .value=${this.response}
258
- ></textarea>`}textChanged(e){if(this.disabled||this.readonly)return;let t=e.target;this.setEmptyAttribute(t.value),this.response!==t.value&&(this.value=t.value,this.saveResponse(t.value))}setEmptyAttribute(e){this.setAttribute("empty",e===""?"true":"false")}};U.styles=lo,c([C()],U.prototype,"_rows",2),c([u({type:Number,attribute:"expected-length"})],U.prototype,"expectedLength",2),c([u({type:String,attribute:"pattern-mask"})],U.prototype,"patternMask",2),c([u({type:String,attribute:"placeholder-text"})],U.prototype,"placeholderText",2),c([u({type:String,attribute:"data-patternmask-message"})],U.prototype,"dataPatternmaskMessage",2),c([u({type:String,attribute:"class"})],U.prototype,"classNames",2),c([I("classNames")],U.prototype,"handleclassNamesChange",1),c([C()],U.prototype,"response",2),c([I("response",{waitUntilFirstUpdate:!0})],U.prototype,"_handleResponseChange",2),U=c([g("qti-extended-text-interaction")],U);var ht=class extends v{constructor(){super(...arguments);this.tabindex=0}connectedCallback(){this.setAttribute("slot","drags")}};ht.styles=x`
258
+ ></textarea>`}textChanged(e){if(this.disabled||this.readonly)return;let t=e.target;this.setEmptyAttribute(t.value),this.response!==t.value&&(this.value=t.value,this.saveResponse(t.value))}setEmptyAttribute(e){this.setAttribute("empty",e===""?"true":"false")}};j.styles=lo,c([E()],j.prototype,"_rows",2),c([u({type:Number,attribute:"expected-length"})],j.prototype,"expectedLength",2),c([u({type:String,attribute:"pattern-mask"})],j.prototype,"patternMask",2),c([u({type:String,attribute:"placeholder-text"})],j.prototype,"placeholderText",2),c([u({type:String,attribute:"data-patternmask-message"})],j.prototype,"dataPatternmaskMessage",2),c([u({type:String,attribute:"class"})],j.prototype,"classNames",2),c([I("classNames")],j.prototype,"handleclassNamesChange",1),c([E()],j.prototype,"response",2),c([I("response",{waitUntilFirstUpdate:!0})],j.prototype,"_handleResponseChange",2),j=c([g("qti-extended-text-interaction")],j);var ht=class extends v{constructor(){super(...arguments);this.tabindex=0}connectedCallback(){this.setAttribute("slot","drags")}};ht.styles=x`
259
259
  :host {
260
260
  display: flex;
261
261
  user-select: none;
@@ -294,10 +294,10 @@ Make sure to test your application with a production build as repeat registratio
294
294
  border-radius: 0.3rem;
295
295
  gap: 0.5rem;
296
296
  }
297
- `;var Kt=class extends se(k,"qti-gap-text","qti-gap","slot[part='drags']"){render(){return h`<slot name="prompt"> </slot>
297
+ `;var Kt=class extends se(S,"qti-gap-text","qti-gap","slot[part='drags']"){render(){return h`<slot name="prompt"> </slot>
298
298
  <slot part="drags" name="drags"></slot>
299
299
  <slot part="drops"></slot>
300
- <div role="alert" part="message" id="validation-message"></div>`}toggleCorrectResponse(r){let e=this.responseVariable;if(r&&e?.correctResponse){let t=[],i=Array.isArray(e.correctResponse)?e.correctResponse:[e.correctResponse];i&&(t=i.map(n=>{let a=n.split(" ");return{text:a[0],gap:a[1]}})),this.querySelectorAll("qti-gap").forEach(n=>{let a=n.getAttribute("identifier"),l=t.find(p=>p.gap===a)?.text,d=this.querySelector(`qti-gap-text[identifier="${l}"]`)?.textContent.trim();if(l&&d){if(!n.nextElementSibling?.classList.contains("correct-option")){let p=document.createElement("span");p.classList.add("correct-option"),p.textContent=d,p.style.border="1px solid var(--qti-correct)",p.style.borderRadius="4px",p.style.padding="2px 4px",p.style.display="inline-block",n.insertAdjacentElement("afterend",p)}}else n.nextElementSibling?.classList.contains("correct-option")&&n.nextElementSibling.remove()})}else this.querySelectorAll(".correct-option").forEach(i=>{i.remove()})}};Kt.styles=co,Kt=c([g("qti-gap-match-interaction")],Kt);var po={toAttribute:o=>o?"true":"false",fromAttribute:o=>o==="true"};function ne(o,r){class e extends o{constructor(...s){super(...s);this.identifier="";this.tabIndex=0;this.disabled=!1;this.readonly=!1;this.internals=this.attachInternals()}handleDisabledChange(s,n){this.tabIndex=n?-1:0,n&&this.blur()}connectedCallback(){super.connectedCallback(),this.addEventListener("keyup",this._onKeyUp),this.addEventListener("click",this._onClick),this.dispatchEvent(new CustomEvent(`register-${r}`,{bubbles:!0,composed:!0}))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("keyup",this._onKeyUp),this.removeEventListener("click",this._onClick),this.dispatchEvent(new CustomEvent(`unregister-${r}`,{bubbles:!0,composed:!0}))}_onKeyUp(s){s.altKey||s.code==="Space"&&(s.preventDefault(),this._activate())}_onClick(){this.disabled||this.readonly||(this.focus(),this._activate())}_activate(){this.disabled||this.readonly||this.dispatchEvent(new CustomEvent(`activate-${r}`,{bubbles:!0,composed:!0,detail:{identifier:this.identifier}}))}render(){return h`<slot></slot>`}}return c([u({type:String})],e.prototype,"identifier",2),c([u({type:Number,reflect:!0,attribute:"tabindex"})],e.prototype,"tabIndex",2),c([u({type:Boolean,reflect:!0,attribute:"aria-disabled",converter:po})],e.prototype,"disabled",2),c([u({type:Boolean,reflect:!0,attribute:"aria-readonly",converter:po})],e.prototype,"readonly",2),c([I("disabled",{waitUntilFirstUpdate:!0})],e.prototype,"handleDisabledChange",1),e}var ft=class extends ne(v,"qti-gap-text"){constructor(){super(...arguments);this.tabindex=0}connectedCallback(){super.connectedCallback(),this.setAttribute("slot","drags")}render(){return h`<slot></slot>`}};ft.styles=x`
300
+ <div role="alert" part="message" id="validation-message"></div>`}toggleCorrectResponse(r){let e=this.responseVariable;if(r&&e?.correctResponse){let t=[],i=Array.isArray(e.correctResponse)?e.correctResponse:[e.correctResponse];i&&(t=i.map(n=>{let a=n.split(" ");return{text:a[0],gap:a[1]}})),this.querySelectorAll("qti-gap").forEach(n=>{let a=n.getAttribute("identifier"),l=t.find(p=>p.gap===a)?.text,d=this.querySelector(`qti-gap-text[identifier="${l}"]`)?.textContent.trim();if(l&&d){if(!n.nextElementSibling?.classList.contains("correct-option")){let p=document.createElement("span");p.classList.add("correct-option"),p.textContent=d,p.style.border="1px solid var(--qti-correct)",p.style.borderRadius="4px",p.style.padding="2px 4px",p.style.display="inline-block",n.insertAdjacentElement("afterend",p)}}else n.nextElementSibling?.classList.contains("correct-option")&&n.nextElementSibling.remove()})}else this.querySelectorAll(".correct-option").forEach(i=>{i.remove()})}getMatches(r){if(!r.correctResponse)return[];let e=Array.isArray(r.correctResponse)?r.correctResponse:[r.correctResponse],t=[];return e&&e.forEach(i=>{let s=i.split(" ");t.push({source:s[0],target:s[1]})}),t}toggleCandidateCorrection(r){let e=this.responseVariable;if(!e?.correctResponse)return;let t=this.getMatches(e);Array.from(this.querySelectorAll("qti-gap")).forEach(s=>{let n=s.getAttribute("identifier"),a=t.filter(d=>d.target===n);s.querySelectorAll("qti-gap-text").forEach(d=>{if(d.internals.states.delete("candidate-correct"),d.internals.states.delete("candidate-incorrect"),!r)return;a.find(m=>m.source===d.identifier)?.source!==void 0?d.internals.states.add("candidate-correct"):d.internals.states.add("candidate-incorrect")})})}};Kt.styles=co,Kt=c([g("qti-gap-match-interaction")],Kt);var po={toAttribute:o=>o?"true":"false",fromAttribute:o=>o==="true"};function ne(o,r){class e extends o{constructor(...s){super(...s);this.identifier="";this.tabIndex=0;this.disabled=!1;this.readonly=!1;this.internals=this.attachInternals()}handleDisabledChange(s,n){this.tabIndex=n?-1:0,n&&this.blur()}connectedCallback(){super.connectedCallback(),this.addEventListener("keyup",this._onKeyUp),this.addEventListener("click",this._onClick),this.dispatchEvent(new CustomEvent(`register-${r}`,{bubbles:!0,composed:!0}))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("keyup",this._onKeyUp),this.removeEventListener("click",this._onClick),this.dispatchEvent(new CustomEvent(`unregister-${r}`,{bubbles:!0,composed:!0}))}_onKeyUp(s){s.altKey||s.code==="Space"&&(s.preventDefault(),this._activate())}_onClick(){this.disabled||this.readonly||(this.focus(),this._activate())}_activate(){this.disabled||this.readonly||this.dispatchEvent(new CustomEvent(`activate-${r}`,{bubbles:!0,composed:!0,detail:{identifier:this.identifier}}))}render(){return h`<slot></slot>`}}return c([u({type:String})],e.prototype,"identifier",2),c([u({type:Number,reflect:!0,attribute:"tabindex"})],e.prototype,"tabIndex",2),c([u({type:Boolean,reflect:!0,attribute:"aria-disabled",converter:po})],e.prototype,"disabled",2),c([u({type:Boolean,reflect:!0,attribute:"aria-readonly",converter:po})],e.prototype,"readonly",2),c([I("disabled",{waitUntilFirstUpdate:!0})],e.prototype,"handleDisabledChange",1),e}var ft=class extends ne(v,"qti-gap-text"){constructor(){super(...arguments);this.tabindex=0}connectedCallback(){super.connectedCallback(),this.setAttribute("slot","drags")}render(){return h`<slot></slot>`}};ft.styles=x`
301
301
  :host {
302
302
  display: inline-flex;
303
303
  user-select: none;
@@ -307,7 +307,7 @@ Make sure to test your application with a production build as repeat registratio
307
307
  display: flex;
308
308
  user-select: none;
309
309
  }
310
- `,c([u({type:Number,reflect:!0})],gt.prototype,"tabindex",2),gt=c([g("qti-gap")],gt);var Ve={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},Q=o=>(...r)=>({_$litDirective$:o,values:r}),ae=class{constructor(r){}get _$AU(){return this._$AM._$AU}_$AT(r,e,t){this._$Ct=r,this._$AM=e,this._$Ci=t}_$AS(r,e){return this.update(r,e)}update(r,e){return this.render(...e)}};var{I:_n}=H,mo=o=>o===null||typeof o!="object"&&typeof o!="function";var ho=o=>o.strings===void 0,uo=()=>document.createComment(""),bt=(o,r,e)=>{let t=o._$AA.parentNode,i=r===void 0?o._$AB:r._$AA;if(e===void 0){let s=t.insertBefore(uo(),i),n=t.insertBefore(uo(),i);e=new _n(s,n,o,o.options)}else{let s=e._$AB.nextSibling,n=e._$AM,a=n!==o;if(a){let l;e._$AQ?.(o),e._$AM=o,e._$AP!==void 0&&(l=o._$AU)!==n._$AU&&e._$AP(l)}if(s!==i||a){let l=e._$AA;for(;l!==s;){let d=l.nextSibling;t.insertBefore(l,i),l=d}}}return e},Oe=(o,r,e=o)=>(o._$AI(r,e),o),Tn={},fo=(o,r=Tn)=>o._$AH=r,go=o=>o._$AH,Wr=o=>{o._$AR(),o._$AA.remove()};var bo=(o,r,e)=>{let t=new Map;for(let i=r;i<=e;i++)t.set(o[i],i);return t},vt=Q(class extends ae{constructor(o){if(super(o),o.type!==Ve.CHILD)throw Error("repeat() can only be used in text expressions")}dt(o,r,e){let t;e===void 0?e=r:r!==void 0&&(t=r);let i=[],s=[],n=0;for(let a of o)i[n]=t?t(a,n):n,s[n]=e(a,n),n++;return{values:s,keys:i}}render(o,r,e){return this.dt(o,r,e).values}update(o,[r,e,t]){let i=go(o),{values:s,keys:n}=this.dt(r,e,t);if(!Array.isArray(i))return this.ut=n,s;let a=this.ut??=[],l=[],d,p,m=0,f=i.length-1,b=0,y=s.length-1;for(;m<=f&&b<=y;)if(i[m]===null)m++;else if(i[f]===null)f--;else if(a[m]===n[b])l[b]=Oe(i[m],s[b]),m++,b++;else if(a[f]===n[y])l[y]=Oe(i[f],s[y]),f--,y--;else if(a[m]===n[y])l[y]=Oe(i[m],s[y]),bt(o,l[y+1],i[m]),m++,y--;else if(a[f]===n[b])l[b]=Oe(i[f],s[b]),bt(o,i[m],i[f]),f--,b++;else if(d===void 0&&(d=bo(n,b,y),p=bo(a,m,f)),d.has(a[m]))if(d.has(a[f])){let E=p.get(n[b]),S=E!==void 0?i[E]:null;if(S===null){let q=bt(o,i[m]);Oe(q,s[b]),l[b]=q}else l[b]=Oe(S,s[b]),bt(o,i[m],S),i[E]=null;b++}else Wr(i[f]),f--;else Wr(i[m]),m++;for(;b<=y;){let E=bt(o,l[y+1]);Oe(E,s[b]),l[b++]=E}for(;m<=f;){let E=i[m++];E!==null&&Wr(E)}return this.ut=n,fo(o,l),V}});function Ne(o,r,e,t){let i=e.getAttribute("width")?parseFloat(e.getAttribute("width")):e.naturalWidth,s=e.getAttribute("height")?parseFloat(e.getAttribute("height")):e.naturalHeight;switch(o){case"circle":{if(r.length!==3){console.error("Invalid circle coordinates:",r);return}let[n,a,l]=r,d=n/i*100,p=a/s*100,m=l/i*100,f=l/s*100;t.style.left=d-m+"%",t.style.top=p-f+"%",t.style.width=2*m+"%",t.style.height=2*f+"%",t.style.borderRadius="50%"}break;case"rect":{if(r.length!==4){console.error("Invalid rectangle coordinates:",r);return}let[n,a,l,d]=r,p=n/i*100,m=a/s*100,f=l/i*100,b=d/s*100;t.style.left=p+"%",t.style.top=m+"%",t.style.width=f-p+"%",t.style.height=b-m+"%"}break;case"ellipse":{if(r.length!==4){console.error("Invalid ellipse coordinates:",r);return}let[n,a,l,d]=r,p=n/i*100,m=a/s*100,f=l/i*100,b=d/s*100;t.style.left=p-f+"%",t.style.top=m-b+"%",t.style.width=2*f+"%",t.style.height=2*b+"%",t.style.borderRadius="50%"}break;case"poly":{if(r.length<6||r.length%2!==0){console.error("Invalid polygon coordinates:",r);return}let n=[];for(let q=0;q<r.length;q+=2)n.push({x:r[q],y:r[q+1]});let a=Math.min(...n.map(q=>q.x)),l=Math.max(...n.map(q=>q.x)),d=Math.min(...n.map(q=>q.y)),p=Math.max(...n.map(q=>q.y)),m=a/i*100,f=d/s*100,b=l/i*100,y=p/s*100;t.style.left=m+"%",t.style.top=f+"%",t.style.width=b-m+"%",t.style.height=y-f+"%";let S=n.map(q=>({x:(q.x-a)/(l-a)*100,y:(q.y-d)/(p-d)*100})).map(q=>`${q.x}% ${q.y}%`).join(",");t.style.clipPath=`polygon(${S})`}break;default:console.error(`Unsupported shape: ${o}`);break}}var vo=x`
310
+ `,c([u({type:Number,reflect:!0})],gt.prototype,"tabindex",2),gt=c([g("qti-gap")],gt);var Ve={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},Q=o=>(...r)=>({_$litDirective$:o,values:r}),ae=class{constructor(r){}get _$AU(){return this._$AM._$AU}_$AT(r,e,t){this._$Ct=r,this._$AM=e,this._$Ci=t}_$AS(r,e){return this.update(r,e)}update(r,e){return this.render(...e)}};var{I:_n}=H,mo=o=>o===null||typeof o!="object"&&typeof o!="function";var ho=o=>o.strings===void 0,uo=()=>document.createComment(""),bt=(o,r,e)=>{let t=o._$AA.parentNode,i=r===void 0?o._$AB:r._$AA;if(e===void 0){let s=t.insertBefore(uo(),i),n=t.insertBefore(uo(),i);e=new _n(s,n,o,o.options)}else{let s=e._$AB.nextSibling,n=e._$AM,a=n!==o;if(a){let l;e._$AQ?.(o),e._$AM=o,e._$AP!==void 0&&(l=o._$AU)!==n._$AU&&e._$AP(l)}if(s!==i||a){let l=e._$AA;for(;l!==s;){let d=l.nextSibling;t.insertBefore(l,i),l=d}}}return e},Oe=(o,r,e=o)=>(o._$AI(r,e),o),Tn={},fo=(o,r=Tn)=>o._$AH=r,go=o=>o._$AH,Wr=o=>{o._$AR(),o._$AA.remove()};var bo=(o,r,e)=>{let t=new Map;for(let i=r;i<=e;i++)t.set(o[i],i);return t},vt=Q(class extends ae{constructor(o){if(super(o),o.type!==Ve.CHILD)throw Error("repeat() can only be used in text expressions")}dt(o,r,e){let t;e===void 0?e=r:r!==void 0&&(t=r);let i=[],s=[],n=0;for(let a of o)i[n]=t?t(a,n):n,s[n]=e(a,n),n++;return{values:s,keys:i}}render(o,r,e){return this.dt(o,r,e).values}update(o,[r,e,t]){let i=go(o),{values:s,keys:n}=this.dt(r,e,t);if(!Array.isArray(i))return this.ut=n,s;let a=this.ut??=[],l=[],d,p,m=0,f=i.length-1,b=0,y=s.length-1;for(;m<=f&&b<=y;)if(i[m]===null)m++;else if(i[f]===null)f--;else if(a[m]===n[b])l[b]=Oe(i[m],s[b]),m++,b++;else if(a[f]===n[y])l[y]=Oe(i[f],s[y]),f--,y--;else if(a[m]===n[y])l[y]=Oe(i[m],s[y]),bt(o,l[y+1],i[m]),m++,y--;else if(a[f]===n[b])l[b]=Oe(i[f],s[b]),bt(o,i[m],i[f]),f--,b++;else if(d===void 0&&(d=bo(n,b,y),p=bo(a,m,f)),d.has(a[m]))if(d.has(a[f])){let C=p.get(n[b]),A=C!==void 0?i[C]:null;if(A===null){let q=bt(o,i[m]);Oe(q,s[b]),l[b]=q}else l[b]=Oe(A,s[b]),bt(o,i[m],A),i[C]=null;b++}else Wr(i[f]),f--;else Wr(i[m]),m++;for(;b<=y;){let C=bt(o,l[y+1]);Oe(C,s[b]),l[b++]=C}for(;m<=f;){let C=i[m++];C!==null&&Wr(C)}return this.ut=n,fo(o,l),V}});function De(o,r,e,t){let i=e.getAttribute("width")?parseFloat(e.getAttribute("width")):e.naturalWidth,s=e.getAttribute("height")?parseFloat(e.getAttribute("height")):e.naturalHeight;switch(o){case"circle":{if(r.length!==3){console.error("Invalid circle coordinates:",r);return}let[n,a,l]=r,d=n/i*100,p=a/s*100,m=l/i*100,f=l/s*100;t.style.left=d-m+"%",t.style.top=p-f+"%",t.style.width=2*m+"%",t.style.height=2*f+"%",t.style.borderRadius="50%"}break;case"rect":{if(r.length!==4){console.error("Invalid rectangle coordinates:",r);return}let[n,a,l,d]=r,p=n/i*100,m=a/s*100,f=l/i*100,b=d/s*100;t.style.left=p+"%",t.style.top=m+"%",t.style.width=f-p+"%",t.style.height=b-m+"%"}break;case"ellipse":{if(r.length!==4){console.error("Invalid ellipse coordinates:",r);return}let[n,a,l,d]=r,p=n/i*100,m=a/s*100,f=l/i*100,b=d/s*100;t.style.left=p-f+"%",t.style.top=m-b+"%",t.style.width=2*f+"%",t.style.height=2*b+"%",t.style.borderRadius="50%"}break;case"poly":{if(r.length<6||r.length%2!==0){console.error("Invalid polygon coordinates:",r);return}let n=[];for(let q=0;q<r.length;q+=2)n.push({x:r[q],y:r[q+1]});let a=Math.min(...n.map(q=>q.x)),l=Math.max(...n.map(q=>q.x)),d=Math.min(...n.map(q=>q.y)),p=Math.max(...n.map(q=>q.y)),m=a/i*100,f=d/s*100,b=l/i*100,y=p/s*100;t.style.left=m+"%",t.style.top=f+"%",t.style.width=b-m+"%",t.style.height=y-f+"%";let A=n.map(q=>({x:(q.x-a)/(l-a)*100,y:(q.y-d)/(p-d)*100})).map(q=>`${q.x}% ${q.y}%`).join(",");t.style.clipPath=`polygon(${A})`}break;default:console.error(`Unsupported shape: ${o}`);break}}var vo=x`
311
311
  slot:not([name='prompt']) {
312
312
  // position: relative; /* qti-hotspot-choice relative to the slot */
313
313
  display: block;
@@ -331,7 +331,7 @@ Make sure to test your application with a production build as repeat registratio
331
331
  top: 0px;
332
332
  left: 0px;
333
333
  }
334
- `;var le=class extends k{constructor(){super();this.startPoint=null;this.endPoint=null;this._correctLines=[];this._response=[];this.addEventListener("qti-register-hotspot",this.positionHotspotOnRegister)}reset(){this._response=[],this._correctLines=[]}validate(){return this.response.length>0}set response(e){this._response=e}get response(){return this._response}toggleInternalCorrectResponse(e){let t=this.responseVariable;if(!e||!t){this._correctLines=[];return}if(!t.correctResponse){console.error("No correct response found for this interaction.");return}let i=Array.isArray(t.correctResponse)?t.correctResponse:[t.correctResponse];this._correctLines=i}render(){return h`<slot name="prompt"></slot>
334
+ `;var le=class extends S{constructor(){super();this.startPoint=null;this.endPoint=null;this._correctLines=[];this._response=[];this.addEventListener("qti-register-hotspot",this.positionHotspotOnRegister)}reset(){this._response=[],this._correctLines=[]}validate(){return this.response.length>0}set response(e){this._response=e}get response(){return this._response}toggleInternalCorrectResponse(e){let t=this.responseVariable;if(!e||!t){this._correctLines=[];return}if(!t.correctResponse){console.error("No correct response found for this interaction.");return}let i=Array.isArray(t.correctResponse)?t.correctResponse:[t.correctResponse];this._correctLines=i}render(){return h`<slot name="prompt"></slot>
335
335
  <line-container>
336
336
  <svg
337
337
  width=${ie(this.grImage[0]?.width)}
@@ -374,7 +374,7 @@ Make sure to test your application with a production build as repeat registratio
374
374
  </svg>
375
375
  <slot></slot>
376
376
  </line-container>
377
- <div role="alert" part="message" id="validation-message"></div>`}positionHotspotOnRegister(e){let t=this.querySelector("img"),i=e.target,s=i.getAttribute("coords"),n=i.getAttribute("shape"),a=s.split(",").map(l=>parseInt(l));Ne(n,a,t,i)}firstUpdated(){this.hotspots=this.querySelectorAll("qti-associable-hotspot"),this.addEventListener("mousemove",e=>{let t=this.grImage[0];if(!t)return;let i=t.getBoundingClientRect();this.mouseCoord={x:e.clientX-i.left,y:e.clientY-i.top}}),this.hotspots.forEach(e=>{e.style.left=e.getAttribute("coords").split(",")[0]+"px",e.style.top=e.getAttribute("coords").split(",")[1]+"px",e.addEventListener("click",t=>{this.startPoint?this.endPoint||(this.endPoint=t.target,this._response=[...this.response,`${this.startPoint.getAttribute("identifier")} ${this.endPoint.getAttribute("identifier")}`],this.saveResponse(this.response),this.startPoint=null,this.endPoint=null):(this.startPoint=t.target,this.startCoord={x:parseInt(this.startPoint.getAttribute("coords").split(",")[0]),y:parseInt(this.startPoint.getAttribute("coords").split(",")[1])})})})}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-register-hotspot",this.positionHotspotOnRegister)}};le.styles=vo,c([C()],le.prototype,"_correctLines",2),c([C()],le.prototype,"startCoord",2),c([C()],le.prototype,"mouseCoord",2),c([Ys({selector:"img"})],le.prototype,"grImage",2),c([C()],le.prototype,"_response",2),le=c([g("qti-graphic-associate-interaction")],le);var yo=x`
377
+ <div role="alert" part="message" id="validation-message"></div>`}positionHotspotOnRegister(e){let t=this.querySelector("img"),i=e.target,s=i.getAttribute("coords"),n=i.getAttribute("shape"),a=s.split(",").map(l=>parseInt(l));De(n,a,t,i)}firstUpdated(){this.hotspots=this.querySelectorAll("qti-associable-hotspot"),this.addEventListener("mousemove",e=>{let t=this.grImage[0];if(!t)return;let i=t.getBoundingClientRect();this.mouseCoord={x:e.clientX-i.left,y:e.clientY-i.top}}),this.hotspots.forEach(e=>{e.style.left=e.getAttribute("coords").split(",")[0]+"px",e.style.top=e.getAttribute("coords").split(",")[1]+"px",e.addEventListener("click",t=>{this.startPoint?this.endPoint||(this.endPoint=t.target,this._response=[...this.response,`${this.startPoint.getAttribute("identifier")} ${this.endPoint.getAttribute("identifier")}`],this.saveResponse(this.response),this.startPoint=null,this.endPoint=null):(this.startPoint=t.target,this.startCoord={x:parseInt(this.startPoint.getAttribute("coords").split(",")[0]),y:parseInt(this.startPoint.getAttribute("coords").split(",")[1])})})})}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-register-hotspot",this.positionHotspotOnRegister)}};le.styles=vo,c([E()],le.prototype,"_correctLines",2),c([E()],le.prototype,"startCoord",2),c([E()],le.prototype,"mouseCoord",2),c([Ys({selector:"img"})],le.prototype,"grImage",2),c([E()],le.prototype,"_response",2),le=c([g("qti-graphic-associate-interaction")],le);var yo=x`
378
378
  :host {
379
379
  display: flex;
380
380
  align-items: flex-start;
@@ -428,7 +428,7 @@ Make sure to test your application with a production build as repeat registratio
428
428
  user-select: none;
429
429
  pointer-events: none;
430
430
  }
431
- `;var Zt=class extends se(k,"qti-gap-img, qti-gap-text","qti-associable-hotspot","slot[part='drags']"){render(){return h` <slot name="prompt"></slot>
431
+ `;var Zt=class extends se(S,"qti-gap-img, qti-gap-text","qti-associable-hotspot","slot[part='drags']"){render(){return h` <slot name="prompt"></slot>
432
432
  <slot part="image"></slot>
433
433
  <slot part="drags" name="drags" class="hover-border"></slot>
434
434
  <div role="alert" part="message" id="validation-message"></div>`}positionHotspotOnRegister(r){let e=r.target,t=e.getAttribute("coords"),i=e.getAttribute("shape"),s=t.split(",").map(n=>parseInt(n));switch(i){case"circle":{let[n,a,l]=s;e.style.left=n-l+"px",e.style.top=a-l+"px",e.style.width=e.style.height=2*l+"px"}break;case"rect":{let[n,a,l,d]=s;e.style.left=n+"px",e.style.top=a+"px",e.style.width=l-n+"px",e.style.height=d-a+"px"}break;default:break}}connectedCallback(){super.connectedCallback(),this.addEventListener("qti-register-hotspot",this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-register-hotspot",this.positionHotspotOnRegister)}};Zt.styles=yo,Zt=c([g("qti-graphic-gap-match-interaction")],Zt);var xo=x`
@@ -442,11 +442,11 @@ Make sure to test your application with a production build as repeat registratio
442
442
  pointer-events: none;
443
443
  user-select: none;
444
444
  }
445
- `;var Qt=class extends $e(k,"qti-hotspot-choice"){constructor(){super(...arguments);this._choiceElements=[]}render(){return h`
445
+ `;var Qt=class extends $e(S,"qti-hotspot-choice"){constructor(){super(...arguments);this._choiceElements=[]}render(){return h`
446
446
  <slot name="prompt"></slot>
447
447
  <slot></slot>
448
448
  <div role="alert" part="message" id="validation-message"></div>
449
- `}setHotspotOrder(e){let{identifier:t}=e.detail,i=this._choiceElements.find(n=>n.getAttribute("identifier")===t);if(!i)return;let s=this._choiceElements.length;if(!this.choiceOrdering){if(this.choiceOrdering=!0,i.order==null){let n=this._choiceElements.filter(a=>a.order!=null).length;if(n>=s){this.choiceOrdering=!1;return}i.order=n+1}else{let n=i.order;i.order=null,this._choiceElements.forEach(a=>{a.order!=null&&a.order>n&&a.order--})}this.choiceOrdering=!1}}toggleCorrectResponse(e){let t=this.responseVariable,i=this._choiceElements;for(let s of i)if(e&&t?.correctResponse?.length>0&&Array.isArray(t.correctResponse)){let n=t.correctResponse.findIndex(a=>a===s.identifier);n>=0?s.orderCorrect=n+1:s.orderCorrect=null}else s.orderCorrect=null}positionHotspotOnRegister(e){let t=this.querySelector("img"),i=e.target,s=i.getAttribute("coords"),n=i.getAttribute("shape"),a=s.split(",").map(l=>parseInt(l));Ne(n,a,t,i)}connectedCallback(){super.connectedCallback(),this.addEventListener("activate-qti-hotspot-choice",this.setHotspotOrder),this.addEventListener("register-qti-hotspot-choice",this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("activate-qti-hotspot-choice",this.setHotspotOrder),this.removeEventListener("register-qti-hotspot-choice",this.positionHotspotOnRegister)}};Qt.styles=xo,Qt=c([g("qti-graphic-order-interaction")],Qt);var Qe=class extends ne(v,"qti-hotspot-choice"){};Qe.styles=x`
449
+ `}setHotspotOrder(e){let{identifier:t}=e.detail,i=this._choiceElements.find(n=>n.getAttribute("identifier")===t);if(!i)return;let s=this._choiceElements.length;if(!this.choiceOrdering){if(this.choiceOrdering=!0,i.order==null){let n=this._choiceElements.filter(a=>a.order!=null).length;if(n>=s){this.choiceOrdering=!1;return}i.order=n+1}else{let n=i.order;i.order=null,this._choiceElements.forEach(a=>{a.order!=null&&a.order>n&&a.order--})}this.choiceOrdering=!1}}toggleCorrectResponse(e){let t=this.responseVariable,i=this._choiceElements;for(let s of i)if(e&&t?.correctResponse?.length>0&&Array.isArray(t.correctResponse)){let n=t.correctResponse.findIndex(a=>a===s.identifier);n>=0?s.orderCorrect=n+1:s.orderCorrect=null}else s.orderCorrect=null}positionHotspotOnRegister(e){let t=this.querySelector("img"),i=e.target,s=i.getAttribute("coords"),n=i.getAttribute("shape"),a=s.split(",").map(l=>parseInt(l));De(n,a,t,i)}connectedCallback(){super.connectedCallback(),this.addEventListener("activate-qti-hotspot-choice",this.setHotspotOrder),this.addEventListener("register-qti-hotspot-choice",this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("activate-qti-hotspot-choice",this.setHotspotOrder),this.removeEventListener("register-qti-hotspot-choice",this.positionHotspotOnRegister)}};Qt.styles=xo,Qt=c([g("qti-graphic-order-interaction")],Qt);var Qe=class extends ne(v,"qti-hotspot-choice"){};Qe.styles=x`
450
450
  :host {
451
451
  display: flex;
452
452
  user-select: none;
@@ -466,17 +466,17 @@ Make sure to test your application with a production build as repeat registratio
466
466
  user-select: none;
467
467
  /* width:100%; */
468
468
  }
469
- `;var er=class extends $e(k,"qti-hotspot-choice"){constructor(){super(...arguments);this.imageLoadPromise=null}render(){return h`
469
+ `;var er=class extends $e(S,"qti-hotspot-choice"){constructor(){super(...arguments);this.imageLoadPromise=null}render(){return h`
470
470
  <slot name="prompt"></slot>
471
471
  <slot></slot>
472
- `}getImageLoadPromise(e){return this.imageLoadPromise||(e.naturalWidth>0&&e.naturalHeight>0?this.imageLoadPromise=Promise.resolve(e):this.imageLoadPromise=new Promise(t=>{let i=()=>{e.removeEventListener("load",i),t(e)};e.addEventListener("load",i)})),this.imageLoadPromise}async positionHotspotOnRegister(e){let t=this.querySelector("img"),i=e.target,s=i.getAttribute("coords"),n=i.getAttribute("shape"),a=s.split(",").map(d=>parseInt(d)),l=await this.getImageLoadPromise(t);Ne(n,a,l,i)}connectedCallback(){super.connectedCallback(),this.addEventListener("register-qti-hotspot-choice",this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("unregister-qti-hotspot-choice",this.positionHotspotOnRegister)}};er.styles=qo,er=c([g("qti-hotspot-interaction")],er);var tr=class extends $e(k,"qti-hottext"){constructor(){super(...arguments);this.class="";this.render=()=>h`<slot></slot>
472
+ `}getImageLoadPromise(e){return this.imageLoadPromise||(e.naturalWidth>0&&e.naturalHeight>0?this.imageLoadPromise=Promise.resolve(e):this.imageLoadPromise=new Promise(t=>{let i=()=>{e.removeEventListener("load",i),t(e)};e.addEventListener("load",i)})),this.imageLoadPromise}async positionHotspotOnRegister(e){let t=this.querySelector("img"),i=e.target,s=i.getAttribute("coords"),n=i.getAttribute("shape"),a=s.split(",").map(d=>parseInt(d)),l=await this.getImageLoadPromise(t);De(n,a,l,i)}connectedCallback(){super.connectedCallback(),this.addEventListener("register-qti-hotspot-choice",this.positionHotspotOnRegister)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("unregister-qti-hotspot-choice",this.positionHotspotOnRegister)}};er.styles=qo,er=c([g("qti-hotspot-interaction")],er);var tr=class extends $e(S,"qti-hottext"){constructor(){super(...arguments);this.class="";this.render=()=>h`<slot></slot>
473
473
  <div part="message" role="alert" id="validation-message"></div>`}get classObject(){let e={"qti-input-control-hidden":!0};return this.class&&this.class.split(" ").forEach(t=>{t.trim()&&(e[t.trim()]=!0)}),e}connectedCallback(){super.connectedCallback(),this.updateHostClasses()}updated(e){super.updated(e),this.updateHostClasses()}updateHostClasses(){let e=Object.keys(this.classObject).join(" ");this.className=e}};c([u({type:String,reflect:!0})],tr.prototype,"class",2),tr=c([g("qti-hottext-interaction")],tr);var rr=class extends ne(v,"qti-hottext"){render(){return h`<div part="ch"><div part="cha"></div></div>
474
474
  <slot></slot> `}};rr.styles=x`
475
475
  :host {
476
476
  display: flex;
477
477
  user-select: none;
478
478
  }
479
- `,rr=c([g("qti-hottext")],rr);var ir=class extends ae{constructor(r){if(super(r),this.it=R,r.type!==Ve.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(r){if(r===R||r==null)return this._t=void 0,this.it=r;if(r===V)return r;if(typeof r!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(r===this.it)return this._t;this.it=r;let e=[r];return e.raw=e,this._t={_$litType$:this.constructor.resultType,strings:e,values:[]}}};ir.directiveName="unsafeHTML",ir.resultType=1;var yt=Q(ir);var ye=class extends k{constructor(){super(...arguments);this.options=[];this.correctOption="";this.dataPrompt=""}get isInline(){return!0}static get styles(){return[x`
479
+ `,rr=c([g("qti-hottext")],rr);var ir=class extends ae{constructor(r){if(super(r),this.it=R,r.type!==Ve.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(r){if(r===R||r==null)return this._t=void 0,this.it=r;if(r===V)return r;if(typeof r!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(r===this.it)return this._t;this.it=r;let e=[r];return e.raw=e,this._t={_$litType$:this.constructor.resultType,strings:e,values:[]}}};ir.directiveName="unsafeHTML",ir.resultType=1;var yt=Q(ir);var ye=class extends S{constructor(){super(...arguments);this.options=[];this.correctOption="";this.dataPrompt=""}get isInline(){return!0}static get styles(){return[x`
480
480
  :host {
481
481
  display: inline-block;
482
482
  }
@@ -506,15 +506,15 @@ Make sure to test your application with a production build as repeat registratio
506
506
  </select>
507
507
 
508
508
  ${yt(this.correctOption)}
509
- `}connectedCallback(){super.connectedCallback(),this.addEventListener("on-dropdown-selected",this.choiceSelected)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("on-dropdown-selected",this.choiceSelected)}willUpdate(e){(e.has("configContext")||e.has("dataPrompt"))&&this._updateOptions()}_updateOptions(){let e=Array.from(this.querySelectorAll("qti-inline-choice")),t=this.dataPrompt||this.configContext?.inlineChoicePrompt||"select";!this.options||this.options.length===0?this.options=[{textContent:t,value:"",selected:!1},...e.map(i=>({textContent:i.innerHTML,value:i.getAttribute("identifier"),selected:!1}))]:this.options=this.options.map(i=>i.value===""?{...i,textContent:t}:i)}validate(){let e=this.options.find(t=>t.selected);return e?e.value!=="":!1}reset(){this.options=this.options.map((e,t)=>({...e,selected:t===0}))}set response(e){this.options=this.options.map(t=>(e&&e===t.value&&(t.selected=!0),t))}get response(){return this.options.find(e=>e.selected)?.value||null}toggleInternalCorrectResponse(e){if(this.correctResponse=e&&this.responseVariable?.correctResponse?.toString(),!this.correctResponse){this.correctOption="";return}this.correctOption=`<span part="correct-option" style="border:1px solid var(--qti-correct); border-radius:4px; padding: 2px 4px; margin: 4px; display:inline-block">${this.options.find(t=>this.correctResponse===t.value).textContent}</span>`}choiceSelected(e){let t=e.target.value;this.options=this.options.map(i=>({...i,selected:i.value===t})),this.saveResponse(t)}};ye.inputWidthClass=["","qti-input-width-2","qti-input-width-1","qti-input-width-3","qti-input-width-4","qti-input-width-6","qti-input-width-10","qti-input-width-15","qti-input-width-20","qti-input-width-72"],c([C()],ye.prototype,"options",2),c([C()],ye.prototype,"correctOption",2),c([u({attribute:"data-prompt",type:String})],ye.prototype,"dataPrompt",2),c([_({context:oe,subscribe:!0}),u({attribute:!1})],ye.prototype,"configContext",2),ye=c([g("qti-inline-choice-interaction")],ye);var sr=class extends v{static get styles(){return[x`
509
+ `}connectedCallback(){super.connectedCallback(),this.addEventListener("on-dropdown-selected",this.choiceSelected)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("on-dropdown-selected",this.choiceSelected)}willUpdate(e){(e.has("configContext")||e.has("dataPrompt"))&&this._updateOptions()}_updateOptions(){let e=Array.from(this.querySelectorAll("qti-inline-choice")),t=this.dataPrompt||this.configContext?.inlineChoicePrompt||"select";!this.options||this.options.length===0?this.options=[{textContent:t,value:"",selected:!1},...e.map(i=>({textContent:i.innerHTML,value:i.getAttribute("identifier"),selected:!1}))]:this.options=this.options.map(i=>i.value===""?{...i,textContent:t}:i)}validate(){let e=this.options.find(t=>t.selected);return e?e.value!=="":!1}reset(){this.options=this.options.map((e,t)=>({...e,selected:t===0}))}set response(e){this.options=this.options.map(t=>(e&&e===t.value&&(t.selected=!0),t))}get response(){return this.options.find(e=>e.selected)?.value||null}toggleInternalCorrectResponse(e){if(this.correctResponse=e&&this.responseVariable?.correctResponse?.toString(),!this.correctResponse){this.correctOption="";return}this.correctOption=`<span part="correct-option" style="border:1px solid var(--qti-correct); border-radius:4px; padding: 2px 4px; margin: 4px; display:inline-block">${this.options.find(t=>this.correctResponse===t.value).textContent}</span>`}choiceSelected(e){let t=e.target.value;this.options=this.options.map(i=>({...i,selected:i.value===t})),this.saveResponse(t)}};ye.inputWidthClass=["","qti-input-width-2","qti-input-width-1","qti-input-width-3","qti-input-width-4","qti-input-width-6","qti-input-width-10","qti-input-width-15","qti-input-width-20","qti-input-width-72"],c([E()],ye.prototype,"options",2),c([E()],ye.prototype,"correctOption",2),c([u({attribute:"data-prompt",type:String})],ye.prototype,"dataPrompt",2),c([_({context:oe,subscribe:!0}),u({attribute:!1})],ye.prototype,"configContext",2),ye=c([g("qti-inline-choice-interaction")],ye);var sr=class extends v{static get styles(){return[x`
510
510
  :host {
511
511
  display: block;
512
512
  cursor: pointer;
513
513
  }
514
- `]}connectedCallback(){super.connectedCallback(),this.addEventListener("click",this._onSelectInlineChoice),this.dispatchEvent(new CustomEvent("qti-inline-choice-register",{bubbles:!0,composed:!0,cancelable:!1}))}disconnectedCallback(){this.removeEventListener("click",this._onSelectInlineChoice)}render(){return h` <slot></slot> `}_onSelectInlineChoice(){this.dispatchEvent(new CustomEvent("qti-inline-choice-select",{bubbles:!0,cancelable:!1,composed:!0,detail:{identifier:this.identifier}}))}};c([u({type:String})],sr.prototype,"identifier",2),sr=c([g("qti-inline-choice")],sr);var De=class extends ne(v,"qti-simple-associable-choice"){constructor(){super(...arguments);this.matchMin=0;this.matchMax=1;this.fixed=!1}connectedCallback(){super.connectedCallback(),this.setAttribute("slot","qti-simple-associable-choice"),this.setAttribute("part","qti-simple-associable-choice")}render(){return h`
514
+ `]}connectedCallback(){super.connectedCallback(),this.addEventListener("click",this._onSelectInlineChoice),this.dispatchEvent(new CustomEvent("qti-inline-choice-register",{bubbles:!0,composed:!0,cancelable:!1}))}disconnectedCallback(){this.removeEventListener("click",this._onSelectInlineChoice)}render(){return h` <slot></slot> `}_onSelectInlineChoice(){this.dispatchEvent(new CustomEvent("qti-inline-choice-select",{bubbles:!0,cancelable:!1,composed:!0,detail:{identifier:this.identifier}}))}};c([u({type:String})],sr.prototype,"identifier",2),sr=c([g("qti-inline-choice")],sr);var Ne=class extends ne(v,"qti-simple-associable-choice"){constructor(){super(...arguments);this.matchMin=0;this.matchMax=1;this.fixed=!1}connectedCallback(){super.connectedCallback(),this.setAttribute("slot","qti-simple-associable-choice"),this.setAttribute("part","qti-simple-associable-choice")}render(){return h`
515
515
  <slot part="slot"></slot>
516
516
  <slot part="dropslot" name="qti-simple-associable-choice"></slot>
517
- `}};De.styles=x`
517
+ `}};Ne.styles=x`
518
518
  :host {
519
519
  display: flex;
520
520
  user-select: none;
@@ -526,7 +526,7 @@ Make sure to test your application with a production build as repeat registratio
526
526
  slot[name='qti-simple-associable-choice'] {
527
527
  width: auto;
528
528
  }
529
- `,c([u({type:Number,attribute:"match-min"})],De.prototype,"matchMin",2),c([u({type:Number,attribute:"match-max"})],De.prototype,"matchMax",2),c([u({type:String,attribute:"fixed",converter:{fromAttribute:e=>e==="true",toAttribute:e=>String(e)}})],De.prototype,"fixed",2),De=c([g("qti-simple-associable-choice")],De);var Co=x`
529
+ `,c([u({type:Number,attribute:"match-min"})],Ne.prototype,"matchMin",2),c([u({type:Number,attribute:"match-max"})],Ne.prototype,"matchMax",2),c([u({type:String,attribute:"fixed",converter:{fromAttribute:e=>e==="true",toAttribute:e=>String(e)}})],Ne.prototype,"fixed",2),Ne=c([g("qti-simple-associable-choice")],Ne);var Co=x`
530
530
  slot:not([hidden]) {
531
531
  /* slot where the */
532
532
  display: flex;
@@ -552,7 +552,7 @@ Make sure to test your application with a production build as repeat registratio
552
552
  /* Make sure the drag and drop container slots have the same width */
553
553
  flex: 1;
554
554
  }
555
- `;var xe=class extends se(k,"qti-simple-match-set:first-of-type qti-simple-associable-choice, qti-simple-match-set:last-of-type > qti-simple-associable-choice > qti-simple-associable-choice","qti-simple-match-set:last-of-type > qti-simple-associable-choice","qti-simple-match-set:first-of-type"){constructor(){super(...arguments);this.lastCheckedRadio=null;this.class="";this._response=[];this.responseIdentifier="";this.correctOptions=null;this.handleRadioClick=e=>{let t=e.target;this.lastCheckedRadio===t?(t.checked=!1,this.lastCheckedRadio=null,this.handleRadioChange(e)):this.lastCheckedRadio=t};this.handleRadioChange=e=>{let t=e.target,i=t.value,s=t.name,n=t.type;t.checked?(this.response?this.response.indexOf(i)===-1&&(n==="radio"&&(this.response=(this.response||[]).filter(a=>a.indexOf(s)===-1)),this.response=[...this.response,i]):this.response=[i],this.lastCheckedRadio=t):(this.response=(this.response||[]).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.response)?[...this.response]:this.response}}))}}get response(){return this.classList.contains("qti-match-tabular")?this._response:super.response}set response(e){this.classList.contains("qti-match-tabular")?this._response=e:super.response=e}async connectedCallback(){super.connectedCallback(),this.sourceChoices=Array.from(this.querySelectorAll("qti-simple-match-set:first-of-type qti-simple-associable-choice")),this.targetChoices=Array.from(this.querySelectorAll("qti-simple-match-set:last-of-type qti-simple-associable-choice")),this.response=[]}validate(){return this.class.split(" ").includes("qti-match-tabular")?this.response?.length===this.sourceChoices.length:super.validate()}getMatches(e){if(!e.correctResponse)return[];let t=Array.isArray(e.correctResponse)?e.correctResponse:[e.correctResponse],i=[];return t&&t.forEach(s=>{let n=s.split(" ");i.push({source:n[0],target:n[1]})}),i}toggleInternalCorrectResponse(e){let t=this.responseVariable;if(!t?.correctResponse){this.querySelectorAll(".correct-option").forEach(s=>s.remove());return}let i=this.getMatches(t);this.class.split(" ").includes("qti-match-tabular")?e?this.correctOptions=i||[]:this.correctOptions=null:e?(this.querySelectorAll(".correct-option").forEach(s=>s.remove()),this.targetChoices.forEach(s=>{let n=s.getAttribute("identifier"),a=i.find(l=>l.target===n);if(a?.source){let d=this.querySelector(`qti-simple-associable-choice[identifier="${a.source}"]`)?.textContent?.trim();if(d&&!s.previousElementSibling?.classList.contains("correct-option")){let p=document.createElement("span");p.classList.add("correct-option"),p.textContent=d,p.style.border="1px solid var(--qti-correct)",p.style.borderRadius="4px",p.style.padding="2px 4px",p.style.display="inline-block",s.insertAdjacentElement("beforebegin",p)}}})):this.correctOptions=null}toggleCandidateCorrection(e){let t=this.responseVariable;if(!t?.correctResponse)return;let i=this.getMatches(t);this.targetChoices.forEach(s=>{let n=s.getAttribute("identifier"),a=i.filter(d=>d.target===n);s.querySelectorAll("qti-simple-associable-choice").forEach(d=>{if(d.internals.states.delete("candidate-correct"),d.internals.states.delete("candidate-incorrect"),!e)return;a.find(m=>m.source===d.identifier)?.source!==void 0?d.internals.states.add("candidate-correct"):d.internals.states.add("candidate-incorrect")})})}render(){let e=this.class.split(" ").includes("qti-match-tabular"),t=this.correctOptions!==null;return h`
555
+ `;var xe=class extends se(S,"qti-simple-match-set:first-of-type qti-simple-associable-choice, qti-simple-match-set:last-of-type > qti-simple-associable-choice > qti-simple-associable-choice","qti-simple-match-set:last-of-type > qti-simple-associable-choice","qti-simple-match-set:first-of-type"){constructor(){super(...arguments);this.lastCheckedRadio=null;this.class="";this._response=[];this.responseIdentifier="";this.correctOptions=null;this.handleRadioClick=e=>{let t=e.target;this.lastCheckedRadio===t?(t.checked=!1,this.lastCheckedRadio=null,this.handleRadioChange(e)):this.lastCheckedRadio=t};this.handleRadioChange=e=>{let t=e.target,i=t.value,s=t.name,n=t.type;t.checked?(this.response?this.response.indexOf(i)===-1&&(n==="radio"&&(this.response=(this.response||[]).filter(a=>a.indexOf(s)===-1)),this.response=[...this.response,i]):this.response=[i],this.lastCheckedRadio=t):(this.response=(this.response||[]).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.response)?[...this.response]:this.response}}))}}get response(){return this.classList.contains("qti-match-tabular")?this._response:super.response}set response(e){this.classList.contains("qti-match-tabular")?this._response=e:super.response=e}async connectedCallback(){super.connectedCallback(),this.sourceChoices=Array.from(this.querySelectorAll("qti-simple-match-set:first-of-type qti-simple-associable-choice")),this.targetChoices=Array.from(this.querySelectorAll("qti-simple-match-set:last-of-type qti-simple-associable-choice")),this.response=[]}validate(){return this.class.split(" ").includes("qti-match-tabular")?this.response?.length===this.sourceChoices.length:super.validate()}getMatches(e){if(!e.correctResponse)return[];let t=Array.isArray(e.correctResponse)?e.correctResponse:[e.correctResponse],i=[];return t&&t.forEach(s=>{let n=s.split(" ");i.push({source:n[0],target:n[1]})}),i}toggleInternalCorrectResponse(e){let t=this.responseVariable;if(!t?.correctResponse){this.querySelectorAll(".correct-option").forEach(s=>s.remove());return}let i=this.getMatches(t);this.class.split(" ").includes("qti-match-tabular")?e?this.correctOptions=i||[]:this.correctOptions=null:e?(this.querySelectorAll(".correct-option").forEach(s=>s.remove()),this.targetChoices.forEach(s=>{let n=s.getAttribute("identifier"),a=i.find(l=>l.target===n);if(a?.source){let d=this.querySelector(`qti-simple-associable-choice[identifier="${a.source}"]`)?.textContent?.trim();if(d&&!s.previousElementSibling?.classList.contains("correct-option")){let p=document.createElement("span");p.classList.add("correct-option"),p.textContent=d,p.style.border="1px solid var(--qti-correct)",p.style.borderRadius="4px",p.style.padding="2px 4px",p.style.display="inline-block",s.insertAdjacentElement("beforebegin",p)}}})):this.correctOptions=null}toggleCandidateCorrection(e){let t=this.responseVariable;if(!t?.correctResponse)return;let i=this.getMatches(t);this.targetChoices.forEach(s=>{let n=s.getAttribute("identifier"),a=i.filter(d=>d.target===n);s.querySelectorAll("qti-simple-associable-choice").forEach(d=>{if(d.internals.states.delete("candidate-correct"),d.internals.states.delete("candidate-incorrect"),!e)return;a.find(m=>m.source===d.identifier)?.source!==void 0?d.internals.states.add("candidate-correct"):d.internals.states.add("candidate-incorrect")})})}render(){let e=this.class.split(" ").includes("qti-match-tabular"),t=this.correctOptions!==null;return h`
556
556
  <slot name="prompt"></slot>
557
557
  <slot ?hidden=${e}></slot>
558
558
 
@@ -565,7 +565,7 @@ Make sure to test your application with a production build as repeat registratio
565
565
 
566
566
  ${this.sourceChoices.map(i=>h`<tr part="row">
567
567
  <td part="c-header">${yt(i.innerHTML)}</td>
568
- ${this.targetChoices.map(s=>{let n=i.getAttribute("identifier"),a=s.getAttribute("identifier"),l=`${n} ${a}`,d=(this.response||[]).filter(E=>E.split(" ")[0]===n).length||0,p=this.response?.includes(l)||!1,m=i.matchMax===1?"radio":"checkbox",f=!!this.correctOptions?.find(E=>E.source===n&&E.target===a),b=m==="radio"?`rb ${p?"rb-checked":""} ${t?f?"rb-correct":"rb-incorrect":""}`:`cb ${p?"cb-checked":""} ${t?f?"cb-correct":"cb-incorrect":""}`,y=this.correctOptions?.length>0?!0:i.matchMax===1?!1:i.matchMax!==0&&d>=i.matchMax&&!p;return h`<td part="input-cell">
568
+ ${this.targetChoices.map(s=>{let n=i.getAttribute("identifier"),a=s.getAttribute("identifier"),l=`${n} ${a}`,d=(this.response||[]).filter(C=>C.split(" ")[0]===n).length||0,p=this.response?.includes(l)||!1,m=i.matchMax===1?"radio":"checkbox",f=!!this.correctOptions?.find(C=>C.source===n&&C.target===a),b=m==="radio"?`rb ${p?"rb-checked":""} ${t?f?"rb-correct":"rb-incorrect":""}`:`cb ${p?"cb-checked":""} ${t?f?"cb-correct":"cb-incorrect":""}`,y=this.correctOptions?.length>0?!0:i.matchMax===1?!1:i.matchMax!==0&&d>=i.matchMax&&!p;return h`<td part="input-cell">
569
569
  <div
570
570
  class="input-container"
571
571
  style="position: relative; width: 24px; height: 24px; margin: 0 auto;"
@@ -576,8 +576,8 @@ Make sure to test your application with a production build as repeat registratio
576
576
  name=${n}
577
577
  value=${l}
578
578
  .disabled=${y}
579
- @change=${E=>this.handleRadioChange(E)}
580
- @click=${E=>i.matchMax===1?this.handleRadioClick(E):null}
579
+ @change=${C=>this.handleRadioChange(C)}
580
+ @click=${C=>i.matchMax===1?this.handleRadioClick(C):null}
581
581
  />
582
582
  ${m==="checkbox"&&p?h`
583
583
  <svg
@@ -595,7 +595,7 @@ Make sure to test your application with a production build as repeat registratio
595
595
  `:R}
596
596
 
597
597
  <div role="alert" part="message" id="validation-message"></div>
598
- `}};xe.styles=Co,c([u({type:String})],xe.prototype,"class",2),c([C()],xe.prototype,"_response",2),c([u({type:String,attribute:"response-identifier"})],xe.prototype,"responseIdentifier",2),c([C()],xe.prototype,"correctOptions",2),xe=c([g("qti-match-interaction")],xe);var or=class extends k{constructor(){super();this._value=null}reset(){}validate(){return!0}get response(){return this._value?this._value.toString():null}set response(e){if(e)if(!isNaN(parseInt(e?.toString())))this._value=parseInt(e.toString());else throw new Error(`Value must be a number ${e}`)}static get properties(){return{...k.properties,step:{type:Number,attribute:"step",default:10}}}render(){return h` <slot name="prompt"></slot>
598
+ `}};xe.styles=Co,c([u({type:String})],xe.prototype,"class",2),c([E()],xe.prototype,"_response",2),c([u({type:String,attribute:"response-identifier"})],xe.prototype,"responseIdentifier",2),c([E()],xe.prototype,"correctOptions",2),xe=c([g("qti-match-interaction")],xe);var or=class extends S{constructor(){super();this._value=null}reset(){}validate(){return!0}get response(){return this._value?this._value.toString():null}set response(e){if(e)if(!isNaN(parseInt(e?.toString())))this._value=parseInt(e.toString());else throw new Error(`Value must be a number ${e}`)}static get properties(){return{...S.properties,step:{type:Number,attribute:"step",default:10}}}render(){return h` <slot name="prompt"></slot>
599
599
  <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)})}};or.styles=[x``],or=c([g("qti-media-interaction")],or);var Eo=x`
600
600
  [part='drags'] {
601
601
  display: flex;
@@ -654,17 +654,17 @@ Make sure to test your application with a production build as repeat registratio
654
654
  :host(.qti-choices-right) [part='container'] {
655
655
  flex-direction: row-reverse;
656
656
  }
657
- `;var qe=class extends se(k,"qti-simple-choice","drop-list","slot[part='drags']"){constructor(){super(...arguments);this.nrChoices=0;this.correctResponses=[];this.showCorrectResponses=!1}render(){let e=Array.from(this.querySelectorAll("qti-simple-choice"));return this.nrChoices<e.length&&(this.nrChoices=e.length),h` <slot name="prompt"> </slot>
657
+ `;var qe=class extends se(S,"qti-simple-choice","drop-list","slot[part='drags']"){constructor(){super(...arguments);this.nrChoices=0;this.correctResponses=[];this.showCorrectResponses=!1}render(){let e=Array.from(this.querySelectorAll("qti-simple-choice"));return this.nrChoices<e.length&&(this.nrChoices=e.length),h` <slot name="prompt"> </slot>
658
658
  <div part="container">
659
659
  <slot part="drags"> </slot>
660
660
  <div part="drops">
661
661
  ${[...Array(this.nrChoices)].map((t,i)=>h`<drop-list role="region" part="drop-list" identifier="droplist${i}"></drop-list>`)}
662
662
  </div>
663
- </div>`}toggleCorrectResponse(e){let t=this.responseVariable;if(this.shadowRoot.querySelectorAll(".correct-option").forEach(i=>i.remove()),e&&t?.correctResponse){let s=(Array.isArray(t.correctResponse)?t.correctResponse:[t.correctResponse]).map(l=>l.split(" ")[0]),n=new Set;this.querySelectorAll("qti-simple-choice").forEach((l,d)=>{let p=l.getAttribute("identifier");if(!p||!s.includes(p)||n.has(p))return;n.add(p);let m=l.textContent?.trim();if(!m)return;let f=this.shadowRoot.querySelector(`drop-list[identifier="droplist${d}"]`);if(!f)return;let b=document.createElement("span");b.classList.add("correct-option"),b.textContent=m,b.style.border="1px solid var(--qti-correct)",b.style.borderRadius="4px",b.style.padding="2px 4px",b.style.display="inline-block",b.style.marginTop="4px",f.insertAdjacentElement("afterend",b)})}}getValue(e){return e?.map((t,i)=>`${t} droplist${i}`)||[]}getResponse(){return Array.from(this.shadowRoot.querySelectorAll("drop-list")).map(i=>{let s=i.querySelectorAll('[qti-draggable="true"]');return[...Array.from(s).map(a=>a.getAttribute("identifier"))].join(" ")})}async firstUpdated(e){super.firstUpdated(e),this.childrenMap=Array.from(this.querySelectorAll("qti-simple-choice")),this.childrenMap.forEach(t=>t.setAttribute("part","qti-simple-choice"))}};qe.styles=Eo,c([C()],qe.prototype,"nrChoices",2),c([C()],qe.prototype,"correctResponses",2),c([C()],qe.prototype,"showCorrectResponses",2),c([u({type:String})],qe.prototype,"orientation",2),qe=c([g("qti-order-interaction")],qe);var wo=x`
663
+ </div>`}toggleCorrectResponse(e){let t=this.responseVariable;if(this.shadowRoot.querySelectorAll(".correct-option").forEach(i=>i.remove()),e&&t?.correctResponse){let s=(Array.isArray(t.correctResponse)?t.correctResponse:[t.correctResponse]).map(l=>l.split(" ")[0]),n=new Set;this.querySelectorAll("qti-simple-choice").forEach((l,d)=>{let p=l.getAttribute("identifier");if(!p||!s.includes(p)||n.has(p))return;n.add(p);let m=l.textContent?.trim();if(!m)return;let f=this.shadowRoot.querySelector(`drop-list[identifier="droplist${d}"]`);if(!f)return;let b=document.createElement("span");b.classList.add("correct-option"),b.textContent=m,b.style.border="1px solid var(--qti-correct)",b.style.borderRadius="4px",b.style.padding="2px 4px",b.style.display="inline-block",b.style.marginTop="4px",f.insertAdjacentElement("afterend",b)})}}getValue(e){return e?.map((t,i)=>`${t} droplist${i}`)||[]}getResponse(){return Array.from(this.shadowRoot.querySelectorAll("drop-list")).map(i=>{let s=i.querySelectorAll('[qti-draggable="true"]');return[...Array.from(s).map(a=>a.getAttribute("identifier"))].join(" ")})}async firstUpdated(e){super.firstUpdated(e),this.childrenMap=Array.from(this.querySelectorAll("qti-simple-choice")),this.childrenMap.forEach(t=>t.setAttribute("part","qti-simple-choice"))}};qe.styles=Eo,c([E()],qe.prototype,"nrChoices",2),c([E()],qe.prototype,"correctResponses",2),c([E()],qe.prototype,"showCorrectResponses",2),c([u({type:String})],qe.prototype,"orientation",2),qe=c([g("qti-order-interaction")],qe);var wo=x`
664
664
  ::slotted(qti-interaction-markup) {
665
665
  display: none;
666
666
  }
667
- `;var z=class extends k{constructor(){super(...arguments);this._iframeLoaded=!1;this._pendingMessages=[];this._responseCheckInterval=null;this.requirePathsJson="";this.requireShimJson="";this.requireJsUrl="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js";this.baseUrl="";this.useIframe=!1;this.useDefaultShims=!1;this.useDefaultPaths=!1;this._errorMessage=null;this.response=[];this._parsedRequirePaths=null;this._parsedRequireShim=null;this.handleIframeMessage=e=>{let{data:t}=e;if(!(!t||t.source!=="qti-pci-iframe"))switch(t.method){case"iframeReady":this.initializeInteraction(),this.processPendingMessages(),this.dispatchEvent(new CustomEvent("qti-portable-custom-interaction-loaded",{bubbles:!0}));break;case"resize":typeof t.height=="number"&&this.iframe&&(this.iframe.style.height=`${t.height}px`,this.iframe.style.width=`${t.width}px`);break;case"interactionChanged":{let i=this.convertQtiVariableJSON(t.params.value);this.response=i,this.validate(),this.saveResponse(this.response);break}case"error":this._errorMessage=t.params.message,console.error("Error from PCI iframe:",t.params.message);break}};this._onInteractionChanged=e=>{e.stopPropagation();let t=this.convertQtiVariableJSON(e.detail.value);this.response=t,this.saveResponse(t)};this.loadConfig=async(e,t)=>{e=this.removeDoubleSlashes(e);try{let i=await fetch(e);if(i.ok){let n=await i.json();for(let a in n.paths)t&&(n.paths[a]=this.getResolvablePath(n.paths[a],t));return n}}catch{}return null};this.getResolvablePathString=(e,t)=>(e=e.replace(/\.js$/,""),e?.toLocaleLowerCase().startsWith("http")||!t?e:this.removeDoubleSlashes(`${t}/${e}`));this.getResolvablePath=(e,t)=>Array.isArray(e)?e.map(i=>this.getResolvablePathString(i,t)):this.getResolvablePathString(e,t);this._previousState=null}getRequirePaths(){if(this._parsedRequirePaths===null&&this.requirePathsJson)try{let e=JSON.parse(this.requirePathsJson);Array.isArray(e)?(this._parsedRequirePaths={},e.forEach(t=>{t.name&&t.value&&(this._parsedRequirePaths[t.name]=t.value)})):this._parsedRequirePaths=e}catch(e){console.error("Error parsing require paths JSON:",e),this._errorMessage=`Error parsing require paths JSON: ${e.message}`,this._parsedRequirePaths={}}return this._parsedRequirePaths||{}}getRequireShim(){if(this._parsedRequireShim===null&&this.requireShimJson)try{this._parsedRequireShim=JSON.parse(this.requireShimJson)}catch(e){console.error("Error parsing require shim JSON:",e),this._errorMessage=`Error parsing require shim JSON: ${e.message}`,this._parsedRequireShim={}}return this._parsedRequireShim||{}}getDefaultRequirePaths(){return{"taoQtiItem/portableLib/OAT/util/event":"/assets/pci-scripts/portableLib/OAT/util/event","taoQtiItem/portableLib/OAT/util/html":"/assets/pci-scripts/portableLib/OAT/util/html","taoQtiItem/portableLib/OAT/util/EventMgr":"/assets/pci-scripts/portableLib/OAT/util/EventMgr","taoQtiItem/portableLib/OAT/util/math":"/assets/pci-scripts/portableLib/OAT/util/math","taoQtiItem/portableLib/OAT/util/xml":"/assets/pci-scripts/portableLib/OAT/util/xml","taoQtiItem/portableLib/OAT/util/tooltip":"/assets/pci-scripts/portableLib/OAT/util/tooltip","taoQtiItem/portableLib/jquery_2_1_1":"/assets/pci-scripts/portableLib/jquery_2_1_1","taoQtiItem/pci-scripts/portableLib/jquery.qtip":"/assets/portableLib/jquery.qtip","taoQtiItem/pci-scripts/portableLib/lodash":"/assets/pci-scripts/portableLib/lodash","taoQtiItem/pci-scripts/portableLib/raphael":"/assets/pci-scripts/portableLib/raphael","IMSGlobal/jquery_2_1_1":"/assets/pci-scripts/IMSGlobal/jquery_2_1_1","OAT/util/event":"/assets/pci-scripts/legacyPortableSharedLib/OAT/util/event","OAT/util/html":"/assets/pci-scripts/legacyPortableSharedLib/OAT/util/html","OAT/util/EventMgr":"/assets/pci-scripts/legacyPortableSharedLib/OAT/util/EventMgr","OAT/util/math":"/assets/pci-scripts/legacyPortableSharedLib/OAT/util/math","OAT/util/xml":"/assets/pci-scripts/legacyPortableSharedLib/OAT/util/xml","OAT/util/tooltip":"/assets/pci-scripts/legacyPortableSharedLib/OAT/util/tooltip","OAT/lodash":"/assets/pci-scripts/legacyPortableSharedLib/lodash",mathJax:"/assets/pci-scripts/mathjax/mathJax",css:"/assets/pci-scripts/css/css"}}getDefaultRequireShim(){return{mathJax:{exports:"MathJax",init:function(){let e=window;if(e.MathJax)return e.MathJax.Hub.Config({showMathMenu:!1,showMathMenuMSIE:!1,menuSettings:{inTabOrder:!1}}),e.MathJax.Hub.Startup.MenuZoom=function(){},e.MathJax.Hub.Startup.onload(),e.MathJax}}}}getFinalRequirePaths(){let e=this.getDefaultRequirePaths(),t=this.getRequirePaths();return this.useDefaultPaths?{...e,...t}:t}getFinalRequireShim(){let e=this.getRequireShim(),t=this.getDefaultRequireShim();return this.useDefaultShims?{...t,...e}:e}convertQtiVariableJSON(e){for(let t in e)if(e.hasOwnProperty(t)){let i=e[t];if(i){for(let s in i)if(i.hasOwnProperty(s)){let n=i[s];if(Array.isArray(n))return n.map(String);if(n!=null)return String(n)}}}return null}addHyphenatedKeys(e){let t={...e};for(let i in e)if(Object.prototype.hasOwnProperty.call(e,i)){let s=i.replace(/[A-Z]/g,n=>`-${n.toLowerCase()}`);t[s]=e[i]}return t}responseVariablesToQtiVariableJSON(e,t,i){if(t!=="single"){let s={list:{}};return s.list[i]=e,s}else{let s={base:{}};return s.base[i]=e,s}}validate(){return!0}set value(e){e===null?this._value=[]:this._value=Array.isArray(e)?e:e.split(",")}get value(){if(this.useIframe)return this._value?.toString()||null;{let e=this.pci?.getResponse();if(e){let t=this.convertQtiVariableJSON(e);return Array.isArray(t)?t.join(","):t}}return Array.isArray(this._value)?this._value.join(","):this._value?.toString()||null}set boundTo(e){if(!e||!e[this.responseIdentifier])return;let t=this.convertQtiVariableJSON(e[this.responseIdentifier]);this._value=t,this.saveResponse(t)}get boundTo(){let e={};if(this.context?.variables?.find(i=>i.identifier===this.responseIdentifier)){let i=this.context?.variables?.find(l=>l.identifier===this.responseIdentifier)?.cardinality||"single",s=this.context?.variables?.find(l=>l.identifier===this.responseIdentifier)?.baseType||"string",n=this.context?.variables?.find(l=>l.identifier===this.responseIdentifier)?.value||null,a=this.responseVariablesToQtiVariableJSON(n,i,s);e[this.responseIdentifier]=a}return e}unescapeHtml(e){return e&&e.replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#x27;/g,"'").replace(/&#x2F;/g,"/").replace(/&#x60;/g,"`").replace(/&#x3D;/g,"=")}unescapeDataAttributes(e){let t={};for(let[i,s]of Object.entries(e))typeof s=="string"?t[i]=this.unescapeHtml(s):t[i]=s;return t}register(e){this.pci=e,this.dom=this.querySelector("qti-interaction-markup"),this.dom||(this.dom=document.createElement("div"),this.appendChild(this.dom)),this.dom.classList.add("qti-customInteraction"),this.dom.style.width="100%",this.dom.style.minHeight="50px",this.dom.style.display="block",this.dom.addEventListener("qti-interaction-changed",this._onInteractionChanged),this.querySelector("properties")&&(this.querySelector("properties").style.display="none");let t={properties:this.addHyphenatedKeys(this.unescapeDataAttributes({...this.dataset})),contextVariables:{},templateVariables:{},onready:i=>{this.pci=i;try{let s=new ResizeObserver(n=>{for(let a of n)a.contentRect&&a.contentRect.height>0&&(this.style.height=`${a.contentRect.height+20}px`)});s.observe(this.dom),this._resizeObserver=s}catch{console.warn("ResizeObserver not supported, falling back to static sizing")}},ondone:(i,s,n,a)=>{this.response=this.convertQtiVariableJSON(s),this.saveResponse(this.response)},responseIdentifier:this.responseIdentifier,boundTo:this.boundTo};if(e.getInstance)e.getInstance(this.dom,t,void 0);else{let s=(n=>{let a={},d=(p=>{let m={};Object.entries(p.dataset).forEach(([b,y])=>{b.includes("__")||(m[b]=y)});let f={};return Object.entries(p.dataset).forEach(([b,y])=>{let E=b.split("__");if(E.length>1){let[S,q,T]=E;f[S]=f[S]||{},f[S][q]=f[S][q]||{},f[S][q][T]=y}}),Object.entries(f).forEach(([b,y])=>{m[b]=Object.values(y)}),m})(n);for(let p in d)if(Object.prototype.hasOwnProperty.call(d,p)){let m=d[p];p==="config"?a[p]=JSON.parse(m):a[p]=m}return a})(this);e.initialize(this.customInteractionTypeIdentifier,this.dom.firstElementChild||this.dom,Object.keys(s).length?s:null)}}disconnectedCallback(){if(super.disconnectedCallback(),this.useIframe)window.removeEventListener("message",this.handleIframeMessage);else{this.stopResponseCheck(),this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=null),requirejs.undef(this.customInteractionTypeIdentifier);let e=requirejs.s.contexts;delete e[this.customInteractionTypeIdentifier],this.removeEventListener("qti-interaction-changed",this._onInteractionChanged)}}sendMessageToIframe(e,t){if(!this._iframeLoaded){this._pendingMessages.push({method:e,params:t});return}this.iframe.contentWindow.postMessage({source:"qti-portable-custom-interaction",method:e,params:t},"*")}processPendingMessages(){this._pendingMessages.length&&(this._pendingMessages.forEach(e=>{this.sendMessageToIframe(e.method,e.params)}),this._pendingMessages=[])}createIframe(){this.iframe=document.createElement("iframe"),this.iframe.id=`pci-iframe-${this.responseIdentifier}`,this.iframe.setAttribute("title","QTI PCI Iframe"),this.iframe.setAttribute("aria-label","QTI PCI Iframe"),this.iframe.setAttribute("aria-hidden","false"),this.iframe.setAttribute("role","application"),this.iframe.style.width="100%",this.iframe.style.border="none",this.iframe.style.display="block",this.iframe.onload=()=>{this._iframeLoaded=!0,this.addMarkupToIframe(),this.sendIframeInitData()};let e=`qti-pci-${this.responseIdentifier}-${Date.now()}`;this.iframe.name=e;let t=this.generateIframeContent(),i=encodeURIComponent(t);this.iframe.src=`data:text/html;charset=utf-8,${i}`,this.appendChild(this.iframe)}sendIframeInitData(){let e={module:this.module,customInteractionTypeIdentifier:this.customInteractionTypeIdentifier,baseUrl:this.baseUrl?this.baseUrl.startsWith("http")||this.baseUrl.startsWith("blob")||this.baseUrl.startsWith("base64")?this.baseUrl:Ke(`${window.location.origin}${this.baseUrl}`):window.location.origin,responseIdentifier:this.responseIdentifier,dataAttributes:{...this.dataset},interactionModules:this.getInteractionModules(),boundTo:this.boundTo};this.sendMessageToIframe("initialize",e)}getInteractionModules(){let e=[],t=this.querySelector("qti-interaction-modules");if(t){let i=t.querySelectorAll("qti-interaction-module");for(let s of i)e.push({id:s.getAttribute("id"),primaryPath:s.getAttribute("primary-path"),fallbackPath:s.getAttribute("fallback-path")})}return e}addMarkupToIframe(){let e=this.querySelector("qti-interaction-markup");e&&this.sendMessageToIframe("setMarkup",e.innerHTML);let t=this.querySelector("properties");t&&this.sendMessageToIframe("setProperties",t.innerHTML)}initializeInteraction(){}connectedCallback(){if(super.connectedCallback(),this.useIframe)window.addEventListener("message",this.handleIframeMessage),this.createIframe();else{define("qtiCustomInteractionContext",()=>({register:t=>{this.register(t)},notifyReady:()=>{}}));let e=this.buildRequireConfig();if(e){let t=requirejs.config(e);requirejs.onError=function(i){throw console.error("RequireJS error:",i),i.requireType==="timeout"&&console.error("Modules that timed out:",i.requireModules),i},t(["require"],i=>{try{i([this.module],()=>{},s=>{console.error("Error loading module:",s)})}catch(s){console.error("Error in require call:",s)}})}}}stopResponseCheck(){this._responseCheckInterval!==null&&(window.clearInterval(this._responseCheckInterval),this._responseCheckInterval=null)}buildRequireConfig(){let e={context:this.customInteractionTypeIdentifier,catchError:!0,paths:{...this.getFinalRequirePaths(),...window.requirePaths||{}},shim:{...this.getFinalRequireShim(),...window.requireShim||{}}};if(!globalThis.require)return this._errorMessage="RequireJS not found. Please load it via CDN: https://cdnjs.com/libraries/require.js",null;let t=this.getAttribute("data-base-url"),i=this.querySelector("qti-interaction-modules");if(i){let s=i.querySelectorAll("qti-interaction-module");for(let n of s){let a=n.getAttribute("id"),l=n.getAttribute("primary-path"),d=n.getAttribute("fallback-path");if(a&&l){let p=d?this.combineRequireResolvePaths(this.getResolvablePath(l,t),this.getResolvablePath(d,t)):this.getResolvablePath(l,t),m=e.paths[a]||[];e.paths[a]=this.combineRequireResolvePaths(m,p)}}}return e}combineRequireResolvePaths(e,t){let i=Array.isArray(e)?e:[e],s=Array.isArray(t)?t:[t];return i.concat(s).filter((n,a,l)=>l.indexOf(n)===a)}removeDoubleSlashes(e){return e.replace(/([^:]\/)\/+/g,"$1").replace(/\/\//g,"/").replace("http:/","http://").replace("https:/","https://")}generateIframeContent(){let e=window.getComputedStyle(document.body),t=JSON.stringify(this.getFinalRequirePaths()),i=JSON.stringify(this.getFinalRequireShim()),s=`
667
+ `;var z=class extends S{constructor(){super(...arguments);this._iframeLoaded=!1;this._pendingMessages=[];this._responseCheckInterval=null;this.requirePathsJson="";this.requireShimJson="";this.requireJsUrl="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js";this.baseUrl="";this.useIframe=!1;this.useDefaultShims=!1;this.useDefaultPaths=!1;this._errorMessage=null;this.response=[];this._parsedRequirePaths=null;this._parsedRequireShim=null;this.handleIframeMessage=e=>{let{data:t}=e;if(!(!t||t.source!=="qti-pci-iframe"))switch(t.method){case"iframeReady":this.initializeInteraction(),this.processPendingMessages(),this.dispatchEvent(new CustomEvent("qti-portable-custom-interaction-loaded",{bubbles:!0}));break;case"resize":typeof t.height=="number"&&this.iframe&&(this.iframe.style.height=`${t.height}px`,this.iframe.style.width=`${t.width}px`);break;case"interactionChanged":{let i=this.convertQtiVariableJSON(t.params.value);this.response=i,this.validate(),this.saveResponse(this.response);break}case"error":this._errorMessage=t.params.message,console.error("Error from PCI iframe:",t.params.message);break}};this._onInteractionChanged=e=>{e.stopPropagation();let t=this.convertQtiVariableJSON(e.detail.value);this.response=t,this.saveResponse(t)};this.loadConfig=async(e,t)=>{e=this.removeDoubleSlashes(e);try{let i=await fetch(e);if(i.ok){let n=await i.json();for(let a in n.paths)t&&(n.paths[a]=this.getResolvablePath(n.paths[a],t));return n}}catch{}return null};this.getResolvablePathString=(e,t)=>(e=e.replace(/\.js$/,""),e?.toLocaleLowerCase().startsWith("http")||!t?e:this.removeDoubleSlashes(`${t}/${e}`));this.getResolvablePath=(e,t)=>Array.isArray(e)?e.map(i=>this.getResolvablePathString(i,t)):this.getResolvablePathString(e,t);this._previousState=null}getRequirePaths(){if(this._parsedRequirePaths===null&&this.requirePathsJson)try{let e=JSON.parse(this.requirePathsJson);Array.isArray(e)?(this._parsedRequirePaths={},e.forEach(t=>{t.name&&t.value&&(this._parsedRequirePaths[t.name]=t.value)})):this._parsedRequirePaths=e}catch(e){console.error("Error parsing require paths JSON:",e),this._errorMessage=`Error parsing require paths JSON: ${e.message}`,this._parsedRequirePaths={}}return this._parsedRequirePaths||{}}getRequireShim(){if(this._parsedRequireShim===null&&this.requireShimJson)try{this._parsedRequireShim=JSON.parse(this.requireShimJson)}catch(e){console.error("Error parsing require shim JSON:",e),this._errorMessage=`Error parsing require shim JSON: ${e.message}`,this._parsedRequireShim={}}return this._parsedRequireShim||{}}getDefaultRequirePaths(){return{"taoQtiItem/portableLib/OAT/util/event":"/assets/pci-scripts/portableLib/OAT/util/event","taoQtiItem/portableLib/OAT/util/html":"/assets/pci-scripts/portableLib/OAT/util/html","taoQtiItem/portableLib/OAT/util/EventMgr":"/assets/pci-scripts/portableLib/OAT/util/EventMgr","taoQtiItem/portableLib/OAT/util/math":"/assets/pci-scripts/portableLib/OAT/util/math","taoQtiItem/portableLib/OAT/util/xml":"/assets/pci-scripts/portableLib/OAT/util/xml","taoQtiItem/portableLib/OAT/util/tooltip":"/assets/pci-scripts/portableLib/OAT/util/tooltip","taoQtiItem/portableLib/jquery_2_1_1":"/assets/pci-scripts/portableLib/jquery_2_1_1","taoQtiItem/pci-scripts/portableLib/jquery.qtip":"/assets/portableLib/jquery.qtip","taoQtiItem/pci-scripts/portableLib/lodash":"/assets/pci-scripts/portableLib/lodash","taoQtiItem/pci-scripts/portableLib/raphael":"/assets/pci-scripts/portableLib/raphael","IMSGlobal/jquery_2_1_1":"/assets/pci-scripts/IMSGlobal/jquery_2_1_1","OAT/util/event":"/assets/pci-scripts/legacyPortableSharedLib/OAT/util/event","OAT/util/html":"/assets/pci-scripts/legacyPortableSharedLib/OAT/util/html","OAT/util/EventMgr":"/assets/pci-scripts/legacyPortableSharedLib/OAT/util/EventMgr","OAT/util/math":"/assets/pci-scripts/legacyPortableSharedLib/OAT/util/math","OAT/util/xml":"/assets/pci-scripts/legacyPortableSharedLib/OAT/util/xml","OAT/util/tooltip":"/assets/pci-scripts/legacyPortableSharedLib/OAT/util/tooltip","OAT/lodash":"/assets/pci-scripts/legacyPortableSharedLib/lodash",mathJax:"/assets/pci-scripts/mathjax/mathJax",css:"/assets/pci-scripts/css/css"}}getDefaultRequireShim(){return{mathJax:{exports:"MathJax",init:function(){let e=window;if(e.MathJax)return e.MathJax.Hub.Config({showMathMenu:!1,showMathMenuMSIE:!1,menuSettings:{inTabOrder:!1}}),e.MathJax.Hub.Startup.MenuZoom=function(){},e.MathJax.Hub.Startup.onload(),e.MathJax}}}}getFinalRequirePaths(){let e=this.getDefaultRequirePaths(),t=this.getRequirePaths();return this.useDefaultPaths?{...e,...t}:t}getFinalRequireShim(){let e=this.getRequireShim(),t=this.getDefaultRequireShim();return this.useDefaultShims?{...t,...e}:e}convertQtiVariableJSON(e){for(let t in e)if(e.hasOwnProperty(t)){let i=e[t];if(i){for(let s in i)if(i.hasOwnProperty(s)){let n=i[s];if(Array.isArray(n))return n.map(String);if(n!=null)return String(n)}}}return null}addHyphenatedKeys(e){let t={...e};for(let i in e)if(Object.prototype.hasOwnProperty.call(e,i)){let s=i.replace(/[A-Z]/g,n=>`-${n.toLowerCase()}`);t[s]=e[i]}return t}responseVariablesToQtiVariableJSON(e,t,i){if(t!=="single"){let s={list:{}};return s.list[i]=e,s}else{let s={base:{}};return s.base[i]=e,s}}validate(){return!0}set value(e){e===null?this._value=[]:this._value=Array.isArray(e)?e:e.split(",")}get value(){if(this.useIframe)return this._value?.toString()||null;{let e=this.pci?.getResponse();if(e){let t=this.convertQtiVariableJSON(e);return Array.isArray(t)?t.join(","):t}}return Array.isArray(this._value)?this._value.join(","):this._value?.toString()||null}set boundTo(e){if(!e||!e[this.responseIdentifier])return;let t=this.convertQtiVariableJSON(e[this.responseIdentifier]);this._value=t,this.saveResponse(t)}get boundTo(){let e={};if(this.context?.variables?.find(i=>i.identifier===this.responseIdentifier)){let i=this.context?.variables?.find(l=>l.identifier===this.responseIdentifier)?.cardinality||"single",s=this.context?.variables?.find(l=>l.identifier===this.responseIdentifier)?.baseType||"string",n=this.context?.variables?.find(l=>l.identifier===this.responseIdentifier)?.value||null,a=this.responseVariablesToQtiVariableJSON(n,i,s);e[this.responseIdentifier]=a}return e}unescapeHtml(e){return e&&e.replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#x27;/g,"'").replace(/&#x2F;/g,"/").replace(/&#x60;/g,"`").replace(/&#x3D;/g,"=")}unescapeDataAttributes(e){let t={};for(let[i,s]of Object.entries(e))typeof s=="string"?t[i]=this.unescapeHtml(s):t[i]=s;return t}register(e){this.pci=e,this.dom=this.querySelector("qti-interaction-markup"),this.dom||(this.dom=document.createElement("div"),this.appendChild(this.dom)),this.dom.classList.add("qti-customInteraction"),this.dom.style.width="100%",this.dom.style.minHeight="50px",this.dom.style.display="block",this.dom.addEventListener("qti-interaction-changed",this._onInteractionChanged),this.querySelector("properties")&&(this.querySelector("properties").style.display="none");let t={properties:this.addHyphenatedKeys(this.unescapeDataAttributes({...this.dataset})),contextVariables:{},templateVariables:{},onready:i=>{this.pci=i;try{let s=new ResizeObserver(n=>{for(let a of n)a.contentRect&&a.contentRect.height>0&&(this.style.height=`${a.contentRect.height+20}px`)});s.observe(this.dom),this._resizeObserver=s}catch{console.warn("ResizeObserver not supported, falling back to static sizing")}},ondone:(i,s,n,a)=>{this.response=this.convertQtiVariableJSON(s),this.saveResponse(this.response)},responseIdentifier:this.responseIdentifier,boundTo:this.boundTo};if(e.getInstance)e.getInstance(this.dom,t,void 0);else{let s=(n=>{let a={},d=(p=>{let m={};Object.entries(p.dataset).forEach(([b,y])=>{b.includes("__")||(m[b]=y)});let f={};return Object.entries(p.dataset).forEach(([b,y])=>{let C=b.split("__");if(C.length>1){let[A,q,T]=C;f[A]=f[A]||{},f[A][q]=f[A][q]||{},f[A][q][T]=y}}),Object.entries(f).forEach(([b,y])=>{m[b]=Object.values(y)}),m})(n);for(let p in d)if(Object.prototype.hasOwnProperty.call(d,p)){let m=d[p];p==="config"?a[p]=JSON.parse(m):a[p]=m}return a})(this);e.initialize(this.customInteractionTypeIdentifier,this.dom.firstElementChild||this.dom,Object.keys(s).length?s:null)}}disconnectedCallback(){if(super.disconnectedCallback(),this.useIframe)window.removeEventListener("message",this.handleIframeMessage);else{this.stopResponseCheck(),this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=null),requirejs.undef(this.customInteractionTypeIdentifier);let e=requirejs.s.contexts;delete e[this.customInteractionTypeIdentifier],this.removeEventListener("qti-interaction-changed",this._onInteractionChanged)}}sendMessageToIframe(e,t){if(!this._iframeLoaded){this._pendingMessages.push({method:e,params:t});return}this.iframe.contentWindow.postMessage({source:"qti-portable-custom-interaction",method:e,params:t},"*")}processPendingMessages(){this._pendingMessages.length&&(this._pendingMessages.forEach(e=>{this.sendMessageToIframe(e.method,e.params)}),this._pendingMessages=[])}createIframe(){this.iframe=document.createElement("iframe"),this.iframe.id=`pci-iframe-${this.responseIdentifier}`,this.iframe.setAttribute("title","QTI PCI Iframe"),this.iframe.setAttribute("aria-label","QTI PCI Iframe"),this.iframe.setAttribute("aria-hidden","false"),this.iframe.setAttribute("role","application"),this.iframe.style.width="100%",this.iframe.style.border="none",this.iframe.style.display="block",this.iframe.onload=()=>{this._iframeLoaded=!0,this.addMarkupToIframe(),this.sendIframeInitData()};let e=`qti-pci-${this.responseIdentifier}-${Date.now()}`;this.iframe.name=e;let t=this.generateIframeContent(),i=encodeURIComponent(t);this.iframe.src=`data:text/html;charset=utf-8,${i}`,this.appendChild(this.iframe)}sendIframeInitData(){let e={module:this.module,customInteractionTypeIdentifier:this.customInteractionTypeIdentifier,baseUrl:this.baseUrl?this.baseUrl.startsWith("http")||this.baseUrl.startsWith("blob")||this.baseUrl.startsWith("base64")?this.baseUrl:Ke(`${window.location.origin}${this.baseUrl}`):window.location.origin,responseIdentifier:this.responseIdentifier,dataAttributes:{...this.dataset},interactionModules:this.getInteractionModules(),boundTo:this.boundTo};this.sendMessageToIframe("initialize",e)}getInteractionModules(){let e=[],t=this.querySelector("qti-interaction-modules");if(t){let i=t.querySelectorAll("qti-interaction-module");for(let s of i)e.push({id:s.getAttribute("id"),primaryPath:s.getAttribute("primary-path"),fallbackPath:s.getAttribute("fallback-path")})}return e}addMarkupToIframe(){let e=this.querySelector("qti-interaction-markup");e&&this.sendMessageToIframe("setMarkup",e.innerHTML);let t=this.querySelector("properties");t&&this.sendMessageToIframe("setProperties",t.innerHTML)}initializeInteraction(){}connectedCallback(){if(super.connectedCallback(),this.useIframe)window.addEventListener("message",this.handleIframeMessage),this.createIframe();else{define("qtiCustomInteractionContext",()=>({register:t=>{this.register(t)},notifyReady:()=>{}}));let e=this.buildRequireConfig();if(e){let t=requirejs.config(e);requirejs.onError=function(i){throw console.error("RequireJS error:",i),i.requireType==="timeout"&&console.error("Modules that timed out:",i.requireModules),i},t(["require"],i=>{try{i([this.module],()=>{},s=>{console.error("Error loading module:",s)})}catch(s){console.error("Error in require call:",s)}})}}}stopResponseCheck(){this._responseCheckInterval!==null&&(window.clearInterval(this._responseCheckInterval),this._responseCheckInterval=null)}buildRequireConfig(){let e={context:this.customInteractionTypeIdentifier,catchError:!0,paths:{...this.getFinalRequirePaths(),...window.requirePaths||{}},shim:{...this.getFinalRequireShim(),...window.requireShim||{}}};if(!globalThis.require)return this._errorMessage="RequireJS not found. Please load it via CDN: https://cdnjs.com/libraries/require.js",null;let t=this.getAttribute("data-base-url"),i=this.querySelector("qti-interaction-modules");if(i){let s=i.querySelectorAll("qti-interaction-module");for(let n of s){let a=n.getAttribute("id"),l=n.getAttribute("primary-path"),d=n.getAttribute("fallback-path");if(a&&l){let p=d?this.combineRequireResolvePaths(this.getResolvablePath(l,t),this.getResolvablePath(d,t)):this.getResolvablePath(l,t),m=e.paths[a]||[];e.paths[a]=this.combineRequireResolvePaths(m,p)}}}return e}combineRequireResolvePaths(e,t){let i=Array.isArray(e)?e:[e],s=Array.isArray(t)?t:[t];return i.concat(s).filter((n,a,l)=>l.indexOf(n)===a)}removeDoubleSlashes(e){return e.replace(/([^:]\/)\/+/g,"$1").replace(/\/\//g,"/").replace("http:/","http://").replace("https:/","https://")}generateIframeContent(){let e=window.getComputedStyle(document.body),t=JSON.stringify(this.getFinalRequirePaths()),i=JSON.stringify(this.getFinalRequireShim()),s=`
668
668
  font-family: ${e.getPropertyValue("font-family")};
669
669
  font-size: ${e.getPropertyValue("font-size")};
670
670
  line-height: ${e.getPropertyValue("line-height")};
@@ -1102,7 +1102,7 @@ Make sure to test your application with a production build as repeat registratio
1102
1102
  width: 100%;
1103
1103
  min-height: 50px;
1104
1104
  }
1105
- `],c([u({type:String,attribute:"module"})],z.prototype,"module",2),c([u({type:String,attribute:"custom-interaction-type-identifier"})],z.prototype,"customInteractionTypeIdentifier",2),c([u({type:String,attribute:"data-require-paths"})],z.prototype,"requirePathsJson",2),c([u({type:String,attribute:"data-require-shim"})],z.prototype,"requireShimJson",2),c([u({type:String,attribute:"data-require-js-url"})],z.prototype,"requireJsUrl",2),c([u({type:String,attribute:"data-base-url"})],z.prototype,"baseUrl",2),c([u({type:Boolean,attribute:"data-use-iframe"})],z.prototype,"useIframe",2),c([u({type:Boolean,attribute:"data-use-default-shims"})],z.prototype,"useDefaultShims",2),c([u({type:Boolean,attribute:"data-use-default-paths"})],z.prototype,"useDefaultPaths",2),c([C()],z.prototype,"_errorMessage",2),c([_({context:$,subscribe:!0}),C()],z.prototype,"context",2),c([C()],z.prototype,"response",2),z=c([g("qti-portable-custom-interaction")],z);var Di=class extends v{render(){return h`<slot></slot>`}static{this.styles=[x`
1105
+ `],c([u({type:String,attribute:"module"})],z.prototype,"module",2),c([u({type:String,attribute:"custom-interaction-type-identifier"})],z.prototype,"customInteractionTypeIdentifier",2),c([u({type:String,attribute:"data-require-paths"})],z.prototype,"requirePathsJson",2),c([u({type:String,attribute:"data-require-shim"})],z.prototype,"requireShimJson",2),c([u({type:String,attribute:"data-require-js-url"})],z.prototype,"requireJsUrl",2),c([u({type:String,attribute:"data-base-url"})],z.prototype,"baseUrl",2),c([u({type:Boolean,attribute:"data-use-iframe"})],z.prototype,"useIframe",2),c([u({type:Boolean,attribute:"data-use-default-shims"})],z.prototype,"useDefaultShims",2),c([u({type:Boolean,attribute:"data-use-default-paths"})],z.prototype,"useDefaultPaths",2),c([E()],z.prototype,"_errorMessage",2),c([_({context:$,subscribe:!0}),E()],z.prototype,"context",2),c([E()],z.prototype,"response",2),z=c([g("qti-portable-custom-interaction")],z);var Ni=class extends v{render(){return h`<slot></slot>`}static{this.styles=[x`
1106
1106
  :host {
1107
1107
  display: block;
1108
1108
  }
@@ -1113,12 +1113,12 @@ Make sure to test your application with a production build as repeat registratio
1113
1113
  left: 50%;
1114
1114
  transform: translateX(-50%);
1115
1115
  }
1116
- `]}};customElements.define("qti-position-object-interaction",Di);var nr=class extends v{render(){return h`<slot></slot>`}constructor(){super(),this.removeMoveListener=this.removeMoveListener.bind(this),this.dragElementHandler=this.dragElementHandler.bind(this)}dragElementHandler(r){r.preventDefault();let e=r.clientX-this.startX,t=r.clientY-this.startY;this.dragElement.style.left=this.dragElement.offsetLeft+e+"px",this.dragElement.style.top=this.dragElement.offsetTop+t+"px",this.startX=r.clientX,this.startY=r.clientY}firstUpdated(r){super.firstUpdated(r),this.dragElement=this.querySelector("qti-position-object-interaction>img"),this.startX=0,this.startY=0,this.dragElement.addEventListener("mousedown",e=>{this.startX=e.clientX,this.startY=e.clientY,document.addEventListener("mousemove",this.dragElementHandler,!0)}),document.addEventListener("mouseup",this.removeMoveListener)}removeMoveListener(){document.removeEventListener("mousemove",this.dragElementHandler,!0)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("mousemove",this.dragElementHandler),document.removeEventListener("mouseup",this.removeMoveListener)}};nr.styles=[x`
1116
+ `]}};customElements.define("qti-position-object-interaction",Ni);var nr=class extends v{render(){return h`<slot></slot>`}constructor(){super(),this.removeMoveListener=this.removeMoveListener.bind(this),this.dragElementHandler=this.dragElementHandler.bind(this)}dragElementHandler(r){r.preventDefault();let e=r.clientX-this.startX,t=r.clientY-this.startY;this.dragElement.style.left=this.dragElement.offsetLeft+e+"px",this.dragElement.style.top=this.dragElement.offsetTop+t+"px",this.startX=r.clientX,this.startY=r.clientY}firstUpdated(r){super.firstUpdated(r),this.dragElement=this.querySelector("qti-position-object-interaction>img"),this.startX=0,this.startY=0,this.dragElement.addEventListener("mousedown",e=>{this.startX=e.clientX,this.startY=e.clientY,document.addEventListener("mousemove",this.dragElementHandler,!0)}),document.addEventListener("mouseup",this.removeMoveListener)}removeMoveListener(){document.removeEventListener("mousemove",this.dragElementHandler,!0)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("mousemove",this.dragElementHandler),document.removeEventListener("mouseup",this.removeMoveListener)}};nr.styles=[x`
1117
1117
  :host {
1118
1118
  display: inline-block;
1119
1119
  position: relative;
1120
1120
  }
1121
- `],nr=c([g("qti-position-object-stage")],nr);var _o="important",An=" !"+_o,Hi=Q(class extends ae{constructor(o){if(super(o),o.type!==Ve.ATTRIBUTE||o.name!=="style"||o.strings?.length>2)throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.")}render(o){return Object.keys(o).reduce(((r,e)=>{let t=o[e];return t==null?r:r+`${e=e.includes("-")?e:e.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${t};`}),"")}update(o,[r]){let{style:e}=o.element;if(this.ft===void 0)return this.ft=new Set(Object.keys(r)),this.render(r);for(let t of this.ft)r[t]==null&&(this.ft.delete(t),t.includes("-")?e.removeProperty(t):e[t]=null);for(let t in r){let i=r[t];if(i!=null){this.ft.add(t);let s=typeof i=="string"&&i.endsWith(An);t.includes("-")||s?e.setProperty(t,s?i.slice(0,-11):i,s?_o:""):e[t]=i}}return V}});var F=class{static isPointInArea(r,e,t){if(t!=="point")return console.warn(`Base type ${t} is not supported for point area mapping.`),!1;let[i,s]=r.split(" ").map(Number),[n,...a]=e.split(","),l=a.map(Number);switch(n.toLowerCase()){case"circle":case"default":{let[d,p,m]=l;return l.length!==3?(console.warn(`Invalid circle definition: ${e}`),!1):Math.sqrt((i-d)**2+(s-p)**2)<=m}case"rect":{let[d,p,m,f]=l;return l.length!==4?(console.warn(`Invalid rectangle definition: ${e}`),!1):i>=d&&i<=m&&s>=p&&s<=f}case"ellipse":{let[d,p,m,f]=l;if(l.length!==4)return console.warn(`Invalid ellipse definition: ${e}`),!1;let b=(i-d)**2/m**2,y=(s-p)**2/f**2;return b+y<=1}case"poly":{if(l.length<6||l.length%2!==0)return console.warn(`Invalid polygon definition: ${e}`),!1;let d=[];for(let p=0;p<l.length;p+=2)d.push({x:l[p],y:l[p+1]});return this.isPointInPolygon({x:i,y:s},d)}default:return console.warn(`Unsupported shape type: ${n}`),!1}}static isPointInPolygon(r,e){let t=!1;for(let i=0,s=e.length-1;i<e.length;s=i++){let n=e[i].x,a=e[i].y,l=e[s].x,d=e[s].y;a>r.y!=d>r.y&&r.x<(l-n)*(r.y-a)/(d-a)+n&&(t=!t)}return t}static compareSingleValues(r,e,t){switch(t){case"identifier":case"string":return r===e;case"integer":{let i=parseInt(r,10),s=parseInt(e,10);if(!isNaN(i)&&!isNaN(s))return i===s;console.error(`Cannot convert ${r} and/or ${e} to int.`);break}case"float":{let i=parseFloat(r),s=parseFloat(e);if(!isNaN(i)&&!isNaN(s))return i===s;console.error(`couldn't convert ${r} and/or ${e} to float.`);break}case"pair":case"directedPair":{let i=r.split(" ").sort(),s=e.split(" ").sort();if(i.length===2&&s.length===2)return t==="pair"&&(i.sort(),s.sort()),i.join(" ")===s.join(" ");console.error(`compared two pair but one of the values does not have 2 values: 1: ${r} 2: ${e}`);break}}return!1}};var ce=class extends k{constructor(){super(...arguments);this.maxChoices=1/0;this.minChoices=0;this.response=null;this._correctAreas=[];this._responseCorrection=[];this._imgElement=null;this._scaleX=1;this._scaleY=1;this._imageWidthOriginal=0;this._imageHeightOriginal=0;this._onImageClick=e=>{if(this.disabled)return;if(!this._imgElement){console.warn("No <img> element found in <qti-select-point-interaction>");return}this.calculateScale();let t=this._imgElement.getBoundingClientRect(),i=(e.clientX-t.left)*this._scaleX,s=(e.clientY-t.top)*this._scaleY,n=`${i.toFixed()} ${s.toFixed()}`;this.maxChoices===1?this.response=[n]:(this.maxChoices===0||(this.response||[]).length<this.maxChoices)&&(this.response=[...this.response||[],n]),this.saveResponse(this.response)};this._onResize=()=>{this.calculateScale()}}connectedCallback(){super.connectedCallback(),window.addEventListener("resize",this._onResize)}get responsePoints(){return(this.response||[]).filter(e=>e).map(e=>{let[t,i]=e.split(" ").map(Number);return{x:t,y:i}})}toggleCandidateCorrection(e){this._responseCorrection=[],e&&this.responsePoints.forEach(t=>{let i=this.responseVariable.areaMapping.areaMapEntries.some(s=>F.isPointInArea(`${t.x} ${t.y}`,`${s.shape},${s.coords}`,this.responseVariable.baseType));this._responseCorrection.push(i)})}toggleCorrectResponse(e){let t=this.responseVariable;if(!e||!t){this._correctAreas=[];return}let i=t.areaMapping,s=[];if(!i||i.areaMapEntries.length===0)if(t.correctResponse){let n=Array.isArray(t.correctResponse)?t.correctResponse:[t.correctResponse];if(n.length===0||n.find(a=>a.split(" ").length<2))return console.error("No valid correct responses found for the response variable."),null;console.warn("No area mapping found for the response variable. Using the correct responses to display the correct response but it probably won't score correct."),s=n.map(a=>({shape:"circle",coords:a.split(" ").join(",").concat(",10"),defaultValue:1,mappedValue:1}))}else{console.error("No area mapping found for the response variable.");return}else s=i.areaMapEntries;this._correctAreas=s.map(n=>({coords:n.coords,shape:n.shape}))}updated(e){super.updated(e);let t=this._imgElement;t&&e.has("_correctAreas")&&this._correctAreas.length>0&&(this.calculateScale(),this.shadowRoot.querySelectorAll("div").forEach(i=>{let s=i.dataset.coord,n=i.dataset.shape;s&&n&&Ne(n,s.split(",").map(a=>+a),t,i)}))}render(){return h` <slot name="prompt"></slot>
1121
+ `],nr=c([g("qti-position-object-stage")],nr);var _o="important",An=" !"+_o,Hi=Q(class extends ae{constructor(o){if(super(o),o.type!==Ve.ATTRIBUTE||o.name!=="style"||o.strings?.length>2)throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.")}render(o){return Object.keys(o).reduce(((r,e)=>{let t=o[e];return t==null?r:r+`${e=e.includes("-")?e:e.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${t};`}),"")}update(o,[r]){let{style:e}=o.element;if(this.ft===void 0)return this.ft=new Set(Object.keys(r)),this.render(r);for(let t of this.ft)r[t]==null&&(this.ft.delete(t),t.includes("-")?e.removeProperty(t):e[t]=null);for(let t in r){let i=r[t];if(i!=null){this.ft.add(t);let s=typeof i=="string"&&i.endsWith(An);t.includes("-")||s?e.setProperty(t,s?i.slice(0,-11):i,s?_o:""):e[t]=i}}return V}});var F=class{static isPointInArea(r,e,t){if(t!=="point")return console.warn(`Base type ${t} is not supported for point area mapping.`),!1;let[i,s]=r.split(" ").map(Number),[n,...a]=e.split(","),l=a.map(Number);switch(n.toLowerCase()){case"circle":case"default":{let[d,p,m]=l;return l.length!==3?(console.warn(`Invalid circle definition: ${e}`),!1):Math.sqrt((i-d)**2+(s-p)**2)<=m}case"rect":{let[d,p,m,f]=l;return l.length!==4?(console.warn(`Invalid rectangle definition: ${e}`),!1):i>=d&&i<=m&&s>=p&&s<=f}case"ellipse":{let[d,p,m,f]=l;if(l.length!==4)return console.warn(`Invalid ellipse definition: ${e}`),!1;let b=(i-d)**2/m**2,y=(s-p)**2/f**2;return b+y<=1}case"poly":{if(l.length<6||l.length%2!==0)return console.warn(`Invalid polygon definition: ${e}`),!1;let d=[];for(let p=0;p<l.length;p+=2)d.push({x:l[p],y:l[p+1]});return this.isPointInPolygon({x:i,y:s},d)}default:return console.warn(`Unsupported shape type: ${n}`),!1}}static isPointInPolygon(r,e){let t=!1;for(let i=0,s=e.length-1;i<e.length;s=i++){let n=e[i].x,a=e[i].y,l=e[s].x,d=e[s].y;a>r.y!=d>r.y&&r.x<(l-n)*(r.y-a)/(d-a)+n&&(t=!t)}return t}static compareSingleValues(r,e,t){switch(t){case"identifier":case"string":return r===e;case"integer":{let i=parseInt(r,10),s=parseInt(e,10);if(!isNaN(i)&&!isNaN(s))return i===s;console.error(`Cannot convert ${r} and/or ${e} to int.`);break}case"float":{let i=parseFloat(r),s=parseFloat(e);if(!isNaN(i)&&!isNaN(s))return i===s;console.error(`couldn't convert ${r} and/or ${e} to float.`);break}case"pair":case"directedPair":{let i=r.split(" ").sort(),s=e.split(" ").sort();if(i.length===2&&s.length===2)return t==="pair"&&(i.sort(),s.sort()),i.join(" ")===s.join(" ");console.error(`compared two pair but one of the values does not have 2 values: 1: ${r} 2: ${e}`);break}}return!1}};var ce=class extends S{constructor(){super(...arguments);this.maxChoices=1/0;this.minChoices=0;this.response=null;this._correctAreas=[];this._responseCorrection=[];this._imgElement=null;this._scaleX=1;this._scaleY=1;this._imageWidthOriginal=0;this._imageHeightOriginal=0;this._onImageClick=e=>{if(this.disabled)return;if(!this._imgElement){console.warn("No <img> element found in <qti-select-point-interaction>");return}this.calculateScale();let t=this._imgElement.getBoundingClientRect(),i=(e.clientX-t.left)*this._scaleX,s=(e.clientY-t.top)*this._scaleY,n=`${i.toFixed()} ${s.toFixed()}`;this.maxChoices===1?this.response=[n]:(this.maxChoices===0||(this.response||[]).length<this.maxChoices)&&(this.response=[...this.response||[],n]),this.saveResponse(this.response)};this._onResize=()=>{this.calculateScale()}}connectedCallback(){super.connectedCallback(),window.addEventListener("resize",this._onResize)}get responsePoints(){return(this.response||[]).filter(e=>e).map(e=>{let[t,i]=e.split(" ").map(Number);return{x:t,y:i}})}toggleCandidateCorrection(e){this._responseCorrection=[],e&&this.responsePoints.forEach(t=>{let i=this.responseVariable.areaMapping.areaMapEntries.some(s=>F.isPointInArea(`${t.x} ${t.y}`,`${s.shape},${s.coords}`,this.responseVariable.baseType));this._responseCorrection.push(i)})}toggleCorrectResponse(e){let t=this.responseVariable;if(!e||!t){this._correctAreas=[];return}let i=t.areaMapping,s=[];if(!i||i.areaMapEntries.length===0)if(t.correctResponse){let n=Array.isArray(t.correctResponse)?t.correctResponse:[t.correctResponse];if(n.length===0||n.find(a=>a.split(" ").length<2))return console.error("No valid correct responses found for the response variable."),null;console.warn("No area mapping found for the response variable. Using the correct responses to display the correct response but it probably won't score correct."),s=n.map(a=>({shape:"circle",coords:a.split(" ").join(",").concat(",10"),defaultValue:1,mappedValue:1}))}else{console.error("No area mapping found for the response variable.");return}else s=i.areaMapEntries;this._correctAreas=s.map(n=>({coords:n.coords,shape:n.shape}))}updated(e){super.updated(e);let t=this._imgElement;t&&e.has("_correctAreas")&&this._correctAreas.length>0&&(this.calculateScale(),this.shadowRoot.querySelectorAll("div").forEach(i=>{let s=i.dataset.coord,n=i.dataset.shape;s&&n&&De(n,s.split(",").map(a=>+a),t,i)}))}render(){return h` <slot name="prompt"></slot>
1122
1122
  <point-container>
1123
1123
  ${vt((this.response||[]).filter(e=>e),e=>e,(e,t)=>{let[i,s]=e.split(" ").map(Number),n=i/(this._imageWidthOriginal||1)*100,a=s/(this._imageHeightOriginal||1)*100,l=16,d=l/(this._imageWidthOriginal||1)*100,p=l/(this._imageHeightOriginal||1)*100,m="";return this._responseCorrection[t]===!0?m=" correct":this._responseCorrection[t]===!1&&(m=" incorrect"),h`
1124
1124
  <button
@@ -1151,7 +1151,7 @@ Make sure to test your application with a production build as repeat registratio
1151
1151
  height: auto;
1152
1152
  display: block;
1153
1153
  }
1154
- `],c([u({type:Number,attribute:"max-choices"})],ce.prototype,"maxChoices",2),c([u({type:Number,attribute:"min-choices"})],ce.prototype,"minChoices",2),c([C()],ce.prototype,"response",2),c([C()],ce.prototype,"_correctAreas",2),c([C()],ce.prototype,"_responseCorrection",2),ce=c([g("qti-select-point-interaction")],ce);var Ce=class extends ne(v,"qti-simple-choice"){constructor(){super(...arguments);this.templateIdentifier=null;this.showHide="show";this.fixed=!1}get checked(){return this.internals.states.has("--checked")}render(){return h`<div part="ch">
1154
+ `],c([u({type:Number,attribute:"max-choices"})],ce.prototype,"maxChoices",2),c([u({type:Number,attribute:"min-choices"})],ce.prototype,"minChoices",2),c([E()],ce.prototype,"response",2),c([E()],ce.prototype,"_correctAreas",2),c([E()],ce.prototype,"_responseCorrection",2),ce=c([g("qti-select-point-interaction")],ce);var Ce=class extends ne(v,"qti-simple-choice"){constructor(){super(...arguments);this.templateIdentifier=null;this.showHide="show";this.fixed=!1}get checked(){return this.internals.states.has("--checked")}render(){return h`<div part="ch">
1155
1155
  <div part="cha"></div>
1156
1156
  </div>
1157
1157
  ${this.marker?h`<div id="label">${this.marker}</div>`:R}
@@ -1252,7 +1252,7 @@ Make sure to test your application with a production build as repeat registratio
1252
1252
  text-align: center;
1253
1253
  color: #6b7280; /* text-gray-500 */
1254
1254
  }
1255
- `;var Ee=class extends k{constructor(){super(...arguments);this._value=0;this._correctResponseNumber=null;this.min=0;this.max=100;this.step=1}validate(){return!0}connectedCallback(){super.connectedCallback(),this._updateValue(this.min),this.setAttribute("tabindex","0"),this.setAttribute("role","slider")}get response(){return this._value.toString()}set response(e){let t=parseInt(e,10);isNaN(t)||this._updateValue(t)}toggleCorrectResponse(e){let t=this.responseVariable;if(t?.correctResponse){if(e){this._correctResponse=t.correctResponse.toString();let i=parseFloat(t.correctResponse.toString());if(isNaN(i))this._correctResponseNumber=null;else{this._correctResponseNumber=i;let s=(this._correctResponseNumber-this.min)/(this.max-this.min)*100;this.style.setProperty("--value-percentage-correct",`${s}%`)}}else this._correctResponseNumber=null;this.requestUpdate()}}_updateValue(e){let t=this._value;if(this._value=Math.min(this.max,Math.max(this.min,e)),this._value===t)return;let i=(this._value-this.min)/(this.max-this.min)*100;this.style.setProperty("--value-percentage",`${i}%`),this._internals.setFormValue(this.value),this.saveResponse(this.response),this.requestUpdate()}render(){return h`
1255
+ `;var Ee=class extends S{constructor(){super(...arguments);this._value=0;this._correctResponseNumber=null;this.min=0;this.max=100;this.step=1}validate(){return!0}connectedCallback(){super.connectedCallback(),this._updateValue(this.min),this.setAttribute("tabindex","0"),this.setAttribute("role","slider")}get response(){return this._value.toString()}set response(e){let t=parseInt(e,10);isNaN(t)||this._updateValue(t)}toggleCorrectResponse(e){let t=this.responseVariable;if(t?.correctResponse){if(e){this._correctResponse=t.correctResponse.toString();let i=parseFloat(t.correctResponse.toString());if(isNaN(i))this._correctResponseNumber=null;else{this._correctResponseNumber=i;let s=(this._correctResponseNumber-this.min)/(this.max-this.min)*100;this.style.setProperty("--value-percentage-correct",`${s}%`)}}else this._correctResponseNumber=null;this.requestUpdate()}}_updateValue(e){let t=this._value;if(this._value=Math.min(this.max,Math.max(this.min,e)),this._value===t)return;let i=(this._value-this.min)/(this.max-this.min)*100;this.style.setProperty("--value-percentage",`${i}%`),this._internals.setFormValue(this.value),this.saveResponse(this.response),this.requestUpdate()}render(){return h`
1256
1256
  <slot name="prompt"></slot>
1257
1257
  <div id="slider" part="slider">
1258
1258
  <div id="bounds" part="bounds">
@@ -1382,7 +1382,7 @@ Make sure to test your application with a production build as repeat registratio
1382
1382
  bottom: 0;
1383
1383
  }
1384
1384
  }
1385
- `;var J=class extends k{constructor(){super(...arguments);this.inputRef=ko();this.response=null;this._handleValueChange=()=>{this._internals.setFormValue(this.value),this.validate()}}get value(){return this.response||null}set value(e){this.response=e||null}get correctness(){let e=this.responseVariable;if(!e)return null;if(e.value===null)return"incorrect";if(e.mapping){let t=e.mapping.mapEntries.reduce((i,s)=>Math.max(s.mappedValue,i),0);for(let i of e.mapping.mapEntries){let s=i.mapKey,n=e.value;if(i.caseSensitive||(s=s.toLowerCase(),n=n.toLowerCase()),s===n)return i.mappedValue===t?"correct":i.mappedValue<=(e.mapping.defaultValue||0)?"incorrect":"partially-correct"}}return e.correctResponse===e.value?"correct":"incorrect"}get isInline(){return!0}validate(){if(!this._input)return!1;if(this.patternMask&&this.dataPatternmaskMessage)this._internals.setValidity({}),this._input.setCustomValidity(""),this._input.checkValidity()||(this._internals.setValidity({customError:!0},this.dataPatternmaskMessage),this._input.setCustomValidity(this.dataPatternmaskMessage));else{let e=this._input.checkValidity();this._internals.setValidity(e?{}:{customError:!1})}return this.response!==""&&this._input.checkValidity()}toggleInternalCorrectResponse(e){let t=this.responseVariable;if(e&&t?.correctResponse){let i=t.correctResponse.toString();this._correctResponse=i}else this._correctResponse=null}render(){return h`
1385
+ `;var J=class extends S{constructor(){super(...arguments);this.inputRef=ko();this.response=null;this._handleValueChange=()=>{this._internals.setFormValue(this.value),this.validate()}}get value(){return this.response||null}set value(e){this.response=e||null}get correctness(){let e=this.responseVariable;if(!e)return null;if(e.value===null)return"incorrect";if(e.mapping){let t=e.mapping.mapEntries.reduce((i,s)=>Math.max(s.mappedValue,i),0);for(let i of e.mapping.mapEntries){let s=i.mapKey,n=e.value;if(i.caseSensitive||(s=s.toLowerCase(),n=n.toLowerCase()),s===n)return i.mappedValue===t?"correct":i.mappedValue<=(e.mapping.defaultValue||0)?"incorrect":"partially-correct"}}return e.correctResponse===e.value?"correct":"incorrect"}get isInline(){return!0}validate(){if(!this._input)return!1;if(this.patternMask&&this.dataPatternmaskMessage)this._internals.setValidity({}),this._input.setCustomValidity(""),this._input.checkValidity()||(this._internals.setValidity({customError:!0},this.dataPatternmaskMessage),this._input.setCustomValidity(this.dataPatternmaskMessage));else{let e=this._input.checkValidity();this._internals.setValidity(e?{}:{customError:!1})}return this.response!==""&&this._input.checkValidity()}toggleInternalCorrectResponse(e){let t=this.responseVariable;if(e&&t?.correctResponse){let i=t.correctResponse.toString();this._correctResponse=i}else this._correctResponse=null}render(){return h`
1386
1386
  <input
1387
1387
  part="input"
1388
1388
  name="${this.responseIdentifier}"
@@ -1401,7 +1401,7 @@ Make sure to test your application with a production build as repeat registratio
1401
1401
  ?readonly="${this.readonly}"
1402
1402
  />
1403
1403
  ${this._correctResponse?h`<div part="correct">${this._correctResponse}</div>`:R}
1404
- `}textChanged(e){if(this.disabled||this.readonly)return;let t=e.target;this.setEmptyAttribute(t.value),this.response!==t.value&&(this.value=t.value,this.saveResponse(t.value))}reportValidity(){let e=this.shadowRoot.querySelector("input");if(!e)return!1;let t=this.validate();return t||e.reportValidity(),t}reset(){this.response=""}setEmptyAttribute(e){this.setAttribute("empty",e===""?"true":"false")}};J.styles=So,c([u({type:Number,attribute:"expected-length"})],J.prototype,"expectedLength",2),c([u({type:String,attribute:"pattern-mask"})],J.prototype,"patternMask",2),c([u({type:String,attribute:"placeholder-text"})],J.prototype,"placeholderText",2),c([u({type:String,attribute:"data-patternmask-message"})],J.prototype,"dataPatternmaskMessage",2),c([C()],J.prototype,"response",2),c([lt("input")],J.prototype,"_input",2),c([I("response",{waitUntilFirstUpdate:!0})],J.prototype,"_handleValueChange",2),J=c([g("qti-text-entry-interaction")],J);var lr=class extends k{constructor(){super(...arguments);this._file=null;this._base64=null}reset(){this._file=null,this._base64=null,this.saveResponse(null)}validate(){return this._base64!==null}get response(){return this._base64}set response(e){if(typeof e=="string")this._base64=e,this.saveResponse(e);else if(e===null)this.reset();else throw new Error("Value must be a Base64-encoded string or null")}static get properties(){return{...k.properties}}render(){return h`
1404
+ `}textChanged(e){if(this.disabled||this.readonly)return;let t=e.target;this.setEmptyAttribute(t.value),this.response!==t.value&&(this.value=t.value,this.saveResponse(t.value))}reportValidity(){let e=this.shadowRoot.querySelector("input");if(!e)return!1;let t=this.validate();return t||e.reportValidity(),t}reset(){this.response=""}setEmptyAttribute(e){this.setAttribute("empty",e===""?"true":"false")}};J.styles=So,c([u({type:Number,attribute:"expected-length"})],J.prototype,"expectedLength",2),c([u({type:String,attribute:"pattern-mask"})],J.prototype,"patternMask",2),c([u({type:String,attribute:"placeholder-text"})],J.prototype,"placeholderText",2),c([u({type:String,attribute:"data-patternmask-message"})],J.prototype,"dataPatternmaskMessage",2),c([E()],J.prototype,"response",2),c([lt("input")],J.prototype,"_input",2),c([I("response",{waitUntilFirstUpdate:!0})],J.prototype,"_handleValueChange",2),J=c([g("qti-text-entry-interaction")],J);var lr=class extends S{constructor(){super(...arguments);this._file=null;this._base64=null}reset(){this._file=null,this._base64=null,this.saveResponse(null)}validate(){return this._base64!==null}get response(){return this._base64}set response(e){if(typeof e=="string")this._base64=e,this.saveResponse(e);else if(e===null)this.reset();else throw new Error("Value must be a Base64-encoded string or null")}static get properties(){return{...S.properties}}render(){return h`
1405
1405
  <div>
1406
1406
  <slot name="prompt"></slot>
1407
1407
  <input type="file" @change="${this._onFileChange}" ?disabled="${this.disabled}" ?readonly="${this.readonly}" />
@@ -1476,12 +1476,12 @@ Make sure to test your application with a production build as repeat registratio
1476
1476
  :host {
1477
1477
  display: none;
1478
1478
  }
1479
- `],pr=c([g("qti-response-processing")],pr);var de=class extends v{render(){return h`<slot></slot>`}process(){throw new Error("Not implemented")}};de=c([g("qti-rule")],de);var ur=class extends de{get childExpression(){return this.firstElementChild}process(){let r=this.getAttribute("identifier"),e=this.context.variables.find(i=>i.identifier===r)||null,t;return e.interpolationTable&&(t=e.interpolationTable.get(parseFloat(this.childExpression.calculate()))),t==null?(console.warn("lookupOutcomeValue: value is null or undefined"),0):(this.dispatchEvent(new CustomEvent("qti-set-outcome-value",{bubbles:!0,composed:!0,detail:{outcomeIdentifier:this.identifier,value:Xt(t)}})),t)}};c([u({type:String})],ur.prototype,"identifier",2),c([_({context:$,subscribe:!0}),C()],ur.prototype,"context",2);customElements.define("qti-lookup-outcome-value",ur);var ji=class extends de{render(){return h`<slot></slot>`}process(){let r=[...this.children];for(let e=0;e<r.length;e++){let t=r[e];if(t.calculate()){t.process();return}}}};customElements.define("qti-response-condition",ji);var Bi=class extends de{process(){let r=this.getAttribute("identifier");if(!r){console.warn('QtiSetOutcomeValue: Missing "identifier" attribute.');return}let e=this.firstElementChild;if(!e){console.warn("QtiSetOutcomeValue: No expression found.");return}let i=new Wi(e).process();this.dispatchEvent(new CustomEvent("qti-set-outcome-value",{bubbles:!0,composed:!0,detail:{outcomeIdentifier:r,value:this.formatValue(i)}}))}formatValue(r){return Array.isArray(r)?r.map(Xt):r!==null?Xt(r):null}},Wi=class{constructor(r){this.expression=r}process(){let r=this.expression.calculate()??null;return r===null&&console.warn("QtiSetOutcomeValueRule: Evaluated value is null."),Array.isArray(r)?r.map(e=>e.value?e.value:e):r}};customElements.define("qti-set-outcome-value",Bi);var mr=class extends v{render(){return h`<slot></slot>`}calculate(){return!0}getSubRules(){return[...this.children]}process(){let r=this.getSubRules();for(let e=0;e<r.length;e++)r[e].process()}};customElements.define("qti-response-else",mr);var hr=class extends mr{calculate(){return this.firstElementChild.calculate()}getSubRules(){let r=[];for(let e=1;e<this.children.length;e++)r.push(this.children[e]);return r}};customElements.define("qti-response-if",hr);var Xi=class extends hr{render(){return h`${super.render()}`}};customElements.define("qti-response-else-if",Xi);var Yr=Symbol("qtiContext");var w=class extends v{constructor(){super(...arguments);this.getVariables=()=>Array.from(this.children).map(e=>{switch(console.debug("getVariables",e.tagName.toLowerCase()),e.tagName.toLowerCase()){case"qti-base-value":return{baseType:e.getAttribute("base-type"),value:e.textContent.trim(),cardinality:"single"};case"qti-variable":{let t=e.getAttribute("identifier")||"";return t==="QTI_CONTEXT"?this.qtiContext?.QTI_CONTEXT?{identifier:"QTI_CONTEXT",baseType:"record",value:this.qtiContext.QTI_CONTEXT,cardinality:"record",type:"context"}:(console.warn("QTI_CONTEXT not available"),{identifier:"QTI_CONTEXT",baseType:"record",value:this.qtiContext.QTI_CONTEXT,cardinality:"record",type:"context"}):this.context.variables.find(s=>s.identifier===t)||null}case"qti-multiple":{let i=e.getResult();return console.debug("values",i),i?.length>0?{identifier:"",baseType:i[0].baseType,value:i.map(s=>s.value),cardinality:"multiple",type:"response"}:null}case"qti-ordered":{let i=e.getResult();return i?.length>0?{identifier:"",baseType:i[0].baseType,value:i.map(s=>s.value),cardinality:"ordered",type:"response"}:null}case"qti-correct":{let t=e.getAttribute("identifier")||"",i=this.context.variables.find(s=>s.identifier===t)||null;return{baseType:i.baseType,value:i.correctResponse,cardinality:i.cardinality}}default:{try{return{baseType:"integer",value:e.getResult()?.toString()||null,cardinality:"single"}}catch{console.warn("default not sufficient")}return null}}}).filter(e=>e!==null)}static{this.styles=x`
1479
+ `],pr=c([g("qti-response-processing")],pr);var de=class extends v{render(){return h`<slot></slot>`}process(){throw new Error("Not implemented")}};de=c([g("qti-rule")],de);var ur=class extends de{get childExpression(){return this.firstElementChild}process(){let r=this.getAttribute("identifier"),e=this.context.variables.find(i=>i.identifier===r)||null,t;return e.interpolationTable&&(t=e.interpolationTable.get(parseFloat(this.childExpression.calculate()))),t==null?(console.warn("lookupOutcomeValue: value is null or undefined"),0):(this.dispatchEvent(new CustomEvent("qti-set-outcome-value",{bubbles:!0,composed:!0,detail:{outcomeIdentifier:this.identifier,value:Xt(t)}})),t)}};c([u({type:String})],ur.prototype,"identifier",2),c([_({context:$,subscribe:!0}),E()],ur.prototype,"context",2);customElements.define("qti-lookup-outcome-value",ur);var ji=class extends de{render(){return h`<slot></slot>`}process(){let r=[...this.children];for(let e=0;e<r.length;e++){let t=r[e];if(t.calculate()){t.process();return}}}};customElements.define("qti-response-condition",ji);var Bi=class extends de{process(){let r=this.getAttribute("identifier");if(!r){console.warn('QtiSetOutcomeValue: Missing "identifier" attribute.');return}let e=this.firstElementChild;if(!e){console.warn("QtiSetOutcomeValue: No expression found.");return}let i=new Wi(e).process();this.dispatchEvent(new CustomEvent("qti-set-outcome-value",{bubbles:!0,composed:!0,detail:{outcomeIdentifier:r,value:this.formatValue(i)}}))}formatValue(r){return Array.isArray(r)?r.map(Xt):r!==null?Xt(r):null}},Wi=class{constructor(r){this.expression=r}process(){let r=this.expression.calculate()??null;return r===null&&console.warn("QtiSetOutcomeValueRule: Evaluated value is null."),Array.isArray(r)?r.map(e=>e.value?e.value:e):r}};customElements.define("qti-set-outcome-value",Bi);var mr=class extends v{render(){return h`<slot></slot>`}calculate(){return!0}getSubRules(){return[...this.children]}process(){let r=this.getSubRules();for(let e=0;e<r.length;e++)r[e].process()}};customElements.define("qti-response-else",mr);var hr=class extends mr{calculate(){return this.firstElementChild.calculate()}getSubRules(){let r=[];for(let e=1;e<this.children.length;e++)r.push(this.children[e]);return r}};customElements.define("qti-response-if",hr);var Xi=class extends hr{render(){return h`${super.render()}`}};customElements.define("qti-response-else-if",Xi);var Yr=Symbol("qtiContext");var w=class extends v{constructor(){super(...arguments);this.getVariables=()=>Array.from(this.children).map(e=>{switch(console.debug("getVariables",e.tagName.toLowerCase()),e.tagName.toLowerCase()){case"qti-base-value":return{baseType:e.getAttribute("base-type"),value:e.textContent.trim(),cardinality:"single"};case"qti-variable":{let t=e.getAttribute("identifier")||"";return t==="QTI_CONTEXT"?this.qtiContext?.QTI_CONTEXT?{identifier:"QTI_CONTEXT",baseType:"record",value:this.qtiContext.QTI_CONTEXT,cardinality:"record",type:"context"}:(console.warn("QTI_CONTEXT not available"),{identifier:"QTI_CONTEXT",baseType:"record",value:this.qtiContext.QTI_CONTEXT,cardinality:"record",type:"context"}):this.context.variables.find(s=>s.identifier===t)||null}case"qti-multiple":{let i=e.getResult();return console.debug("values",i),i?.length>0?{identifier:"",baseType:i[0].baseType,value:i.map(s=>s.value),cardinality:"multiple",type:"response"}:null}case"qti-ordered":{let i=e.getResult();return i?.length>0?{identifier:"",baseType:i[0].baseType,value:i.map(s=>s.value),cardinality:"ordered",type:"response"}:null}case"qti-correct":{let t=e.getAttribute("identifier")||"",i=this.context.variables.find(s=>s.identifier===t)||null;return{baseType:i.baseType,value:i.correctResponse,cardinality:i.cardinality}}default:{try{return{baseType:"integer",value:e.getResult()?.toString()||null,cardinality:"single"}}catch{console.warn("default not sufficient")}return null}}}).filter(e=>e!==null)}static{this.styles=x`
1480
1480
  slot {
1481
1481
  display: none;
1482
1482
  }
1483
1483
  `}render(){return h`<pre>${JSON.stringify(this.result,null,2)}</pre>
1484
- <slot></slot>`}calculate(){return this.result=this.getResult(),this.result}getResult(){throw new Error("Not implemented")}};c([C()],w.prototype,"result",2),c([_({context:$,subscribe:!0}),C()],w.prototype,"context",2),c([_({context:Yr,subscribe:!0}),C()],w.prototype,"qtiContext",2);var K=class extends w{calculate(){return this.result=this.getResult(),this.result}getResult(){throw new Error("Not implemented")}};var Jr=class extends Mn(K){calculate(){return this.calculateChildren(Array.from(this.children))}};Jr=c([g("qti-and")],Jr);function Mn(o){return class extends o{calculateChildren(e){return e.map(i=>{let s=i;if(!s.calculate)return console.error("Element doesn't implement QtiConditionExpression"),null;let n=s.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)}}}var Kr=class extends w{constructor(){super(...arguments);this.baseType="string"}getResult(){return this.textContent.trim()}};c([u({type:String,attribute:"base-type"})],Kr.prototype,"baseType",2);customElements.define("qti-base-value",Kr);var Gi=class extends w{getResult(){if(this.children?.length!==1)return console.error("qti-container-size must have exactly one child expression"),0;let r=this.getVariables();if(!r||r?.length===0)return 0;let e=r[0];return e.value===null||e.value===void 0?0:e.cardinality!=="multiple"&&e.cardinality!=="ordered"?(console.error("qti-container-size requires multiple or ordered cardinality"),0):Array.isArray(e.value)?e.value.length:(console.error("qti-container-size: expected array value for multiple/ordered cardinality"),0)}};customElements.define("qti-container-size",Gi);var Yi=class extends K{getResult(){let r=this.getVariables();if(this.children.length===2){let e=r[0],t=r[1];if(e.baseType==="directedPair"&&t.baseType==="directedPair"&&e.cardinality==="multiple"){let i=e.value,s=t.value;return i.filter(l=>s.includes(l)).length>0}else if(e.baseType==="directedPair"&&t.baseType==="directedPair"&&e.cardinality==="single"){let i=e.value;return t.value.includes(i)}else console.error("unsupported baseType or cardinality in qti contains, only baseType: directedPair and cardinality: multiple is supported")}else console.error("unexpected number of children in qti contains");return!1}};customElements.define("qti-contains",Yi);var Ji=class extends w{get interpretation(){return this.getAttribute("interpretation")||""}getResult(){let r=this.getAttribute("identifier")||"",e=this.context.variables.find(t=>t.identifier===r)||null;return e.cardinality!=="single"?e.correctResponse.length>0?e.correctResponse[0]:"":e.correctResponse}};customElements.define("qti-correct",Ji);var Ki={items:[],testOutcomeVariables:[]},pe=Symbol("testContext");var qt=class extends w{constructor(){super(...arguments);this.identifier=""}getResult(){if(!this.identifier)return console.error("qti-default requires an identifier attribute"),null;let e=this.identifier.split("."),t=null,i;if(e.length===2)t=e[0],i=e[1];else if(e.length===1)i=e[0];else return console.error("qti-default: invalid identifier format"),null;if(t){let n=this._testContext.items.find(l=>l.identifier===t);if(console.debug(`itemContext: ${JSON.stringify(n)}`),!this._testContext||!n)return console.warn(`qti-default: item "${t}" not found in test context`),null;let a=this._testContext.items.find(l=>l.identifier===t)?.variables.find(l=>l.identifier===i);return a?a.defaultValue||null:(console.warn(`qti-default: variable "${i}" not found in item "${t}"`),null)}if(!this.context?.variables)return console.warn("qti-default: no variables found in item context"),null;let s=this.context.variables.find(n=>n.identifier===i);return s?s.defaultValue||null:(console.warn(`qti-default: variable "${i}" not found in item context`),null)}};c([u({type:String})],qt.prototype,"identifier",2),c([_({context:$,subscribe:!0}),C()],qt.prototype,"context",2),c([C(),_({context:pe,subscribe:!0})],qt.prototype,"_testContext",2);customElements.define("qti-default",qt);var Zr=class extends w{constructor(){super(...arguments);this.roundingMode="significantFigures"}get figures(){if(!this.getAttribute("figures"))return console.error("figures attribute is missing"),null;let t=parseInt(this.getAttribute("figures")||"0");return isNaN(t)?(console.error("figures attribute is not a number"),null):t<0?(console.error("figures attribute is negative"),null):t<1&&this.roundingMode==="significantFigures"?(console.error("figures cannot be smaller than 1 for RoundingMode significantFigures"),null):t}getResult(){if(this.children.length===2){let e=this.getVariables(),t=e[0],i=e[1];if(this.roundingMode===null)return null;if(t.cardinality!=="single"||i.cardinality!=="single"||Array.isArray(t.value)||Array.isArray(i.value))return console.error("unexpected cardinality in qti equal"),!1;switch(e[0].baseType){case"integer":case"float":{let s=parseFloat(t.value),n=parseFloat(i.value);if(!isNaN(s)&&!isNaN(n))return this.roundingMode==="significantFigures"?s.toPrecision(this.figures)===n.toPrecision(this.figures):Math.round(s*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: ${s}, ${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}};c([u({type:String})],Zr.prototype,"roundingMode",2);customElements.define("qti-equal-rounded",Zr);var Zi=class extends w{getResult(){if(this.children.length!==1)return console.error("qti-round must have exactly one child expression"),null;let r=this.getVariables();if(!r||r.length===0)return null;let e=r[0];if(e.cardinality!=="single")return console.error("qti-round requires single cardinality"),null;if(Array.isArray(e.value))return console.error("qti-round unexpected array value for single cardinality"),null;if(e.value===null||e.value===void 0)return null;if(e.baseType!=="integer"&&e.baseType!=="float")return console.error("qti-round requires numerical base-type (integer or float)"),null;let t=parseFloat(e.value);return isNaN(t)?(console.warn("qti-round: NaN input results in NULL"),null):isFinite(t)?Math.floor(t+.5):t===1/0?1/0:t===-1/0?-1/0:null}};customElements.define("qti-round",Zi);var fr=class extends w{constructor(){super(...arguments);this.roundingMode="significantFigures";this.figures=3}getResult(){if(this.children.length!==1)return console.error("qti-round-to must have exactly one child expression"),null;let e=this.getVariables();if(!e||e.length===0)return null;let t=e[0];if(t.cardinality!=="single")return console.error("qti-round-to requires single cardinality"),null;if(Array.isArray(t.value))return console.error("qti-round-to unexpected array value for single cardinality"),null;if(t.value===null||t.value===void 0)return null;if(t.baseType!=="integer"&&t.baseType!=="float")return console.error("qti-round-to requires numerical base-type"),null;let i=parseFloat(t.value);return isNaN(i)?null:isFinite(i)?this.figures<0?(console.error("qti-round-to: figures must be non-negative"),null):this.roundingMode==="significantFigures"&&this.figures<1?(console.error("qti-round-to: figures must be at least 1 for significantFigures mode"),null):this.roundingMode==="decimalPlaces"?this._roundToDecimalPlaces(i,this.figures):this._roundToSignificantFigures(i,this.figures):i===1/0?1/0:i===-1/0?-1/0:null}_roundToDecimalPlaces(e,t){if(e===0)return 0;let i=Math.pow(10,t);return Math.round(e*i)/i}_roundToSignificantFigures(e,t){if(e===0)return 0;let i=Math.floor(Math.log10(Math.abs(e))),s=Math.pow(10,t-i-1);return Math.round(e*s)/s}};c([u({type:String,attribute:"rounding-mode"})],fr.prototype,"roundingMode",2),c([u({type:Number})],fr.prototype,"figures",2);customElements.define("qti-round-to",fr);var Qr=class extends w{constructor(){super(...arguments);this.toleranceMode="exact"}getResult(){if(this.children.length===2){let e=this.getVariables(),t=e[0],i=e[1];return this.toleranceMode!=="exact"?(console.error("toleranceMode is not supported yet"),!1):t.cardinality!=="single"||i.cardinality!=="single"||Array.isArray(t.value)||Array.isArray(i.value)?(console.error("unexpected cardinality in qti equal"),!1):F.compareSingleValues(t.value,i.value,t.baseType)}return console.error("unexpected number of children in qti-equal"),null}};c([u({type:String})],Qr.prototype,"toleranceMode",2);customElements.define("qti-equal",Qr);var Qi=class extends w{getResult(){if(this.children.length===0)return console.error("qti-gcd must have at least one child expression"),null;let r=this.getVariables();if(!r||r.length===0)return null;let e=[];for(let t of r){if(t.baseType!=="integer")return console.error("qti-gcd requires integer base-type"),null;if(t.value===null||t.value===void 0)return null;if(t.cardinality==="single"){if(Array.isArray(t.value))return console.error("qti-gcd unexpected array value for single cardinality"),null;let i=parseInt(t.value,10);if(isNaN(i))return console.error("qti-gcd non-numerical value"),null;e.push(i)}else if(t.cardinality==="multiple"||t.cardinality==="ordered"){if(!Array.isArray(t.value))return console.error("qti-gcd expected array value for multiple/ordered cardinality"),null;for(let i of t.value){if(i==null)return null;let s=parseInt(i,10);if(isNaN(s))return console.error("qti-gcd non-numerical value"),null;e.push(s)}}else return console.error("qti-gcd unsupported cardinality"),null}return e.length===0?null:this._calculateGcd(e)}_calculateGcd(r){if(r.length===0)return 0;if(r.length===1)return Math.abs(r[0]);let e=Math.abs(r[0]);for(let t=1;t<r.length&&(e=this._gcdTwoNumbers(e,Math.abs(r[t])),e!==1);t++);return e}_gcdTwoNumbers(r,e){if(r===0&&e===0)return 0;if(r===0)return e;if(e===0)return r;for(;e!==0;){let t=e;e=r%e,r=t}return r}};customElements.define("qti-gcd",Qi);var es=class extends w{getResult(){if(this.children.length===2){let r=this.getVariables(),e=r[0],t=r[1];if((e.baseType==="integer"||e.baseType==="float")&&(t.baseType==="integer"||t.baseType==="float"))return+e.value>+t.value;console.error("unexpected baseType or cardinality in qti gt")}return console.error("unexpected number of children in qt"),null}};customElements.define("qti-gt",es);var ts=class extends K{getResult(){if(this.children.length===2){let r=this.getVariables(),e=r[0],t=r[1];return(e.baseType==="integer"||e.baseType==="float")&&(t.baseType==="integer"||t.baseType==="float")?+e.value>=+t.value:(console.error("unexpected baseType or cardinality in qti gte"),null)}return console.log("unexpected number of children in qte"),null}};customElements.define("qti-gte",ts);var rs=class extends w{getResult(){return null}};customElements.define("qti-null",rs);var is=class extends w{getResult(){if(this.children.length===1){let r=this.getVariables();if(!r)return!0;let e=r[0].value;return e==null||e==null||e===""}return console.error("unexpected number of children in qti Null"),null}};customElements.define("qti-is-null",is);var ss=class extends w{getResult(){let r=this.getAttribute("field-identifier");if(!r)throw new Error("field-identifier attribute is required");if(Array.from(this.children).length!==1)throw new Error("qti-field-value must have exactly one child expression");let t=this.getVariables()[0];if(t.baseType!=="record"||t.value===null)throw new Error("qti-field-value child expression must return a record");let i=t.value[r];if(i===void 0)throw new Error(`Field "${r}" not found in record`);return i}};customElements.define("qti-field-value",ss);var os=class extends w{getResult(){if(this.children.length===2){let r=this.getVariables(),e=r[0],t=r[1];if((e.baseType==="integer"||e.baseType==="float")&&(t.baseType==="integer"||t.baseType==="float"))return+e.value<+t.value;console.error("unexpected baseType or cardinality in qti lt")}return console.error("unexpected number of children in lt"),null}};customElements.define("qti-lt",os);var ns=class extends K{getResult(){if(this.children.length===2){let r=this.getVariables(),e=r[0],t=r[1];return(e.baseType==="integer"||e.baseType==="float")&&(t.baseType==="integer"||t.baseType==="float")?+e.value<=+t.value:(console.error("unexpected baseType or cardinality in qti lte"),null)}return console.log("unexpected number of children in lte"),null}};customElements.define("qti-lte",ns);var ei=class extends w{getResult(){let r=this.context.variables.find(s=>s.identifier===this.identifier);if(!r||!r.mapping)return console.error(`Response ${this.identifier} can not be found`),null;let e=r.mapping,t=Array.isArray(r.value)?r.value:[r.value],i=0;for(let s of t){let n=e.mapEntries.filter(l=>r.baseType==="string"&&!l.caseSensitive?F.compareSingleValues(l.mapKey.toLowerCase(),s.toLowerCase(),r.baseType):F.compareSingleValues(l.mapKey,s,r.baseType)),a=n.reduce((l,d)=>l.mappedValue>d.mappedValue?l:d,n.length>0?n[0]:{mapKey:null,mappedValue:null});a===null||a.mappedValue==null?i+=e.defaultValue:i+=a.mappedValue}return e?.lowerBound!==null&&e?.lowerBound!==void 0&&(i=Math.max(e.lowerBound,i)),e?.upperBound!==null&&e?.upperBound!==void 0&&(i=Math.min(e.upperBound,i)),i}};c([u({type:String})],ei.prototype,"identifier",2);customElements.define("qti-map-response",ei);var ti=class extends w{getResult(){let r=this.context.variables.find(n=>n.identifier===this.identifier);if(!r)return console.warn(`Response ${this.identifier} cannot be found`),null;let e=r.areaMapping;if(!e)return console.warn(`Area mapping not found for response ${this.identifier}`),null;let t=Array.isArray(r.value)?r.value:[r.value];if(!t||t.length===0)return console.warn(`No candidate responses for response ${this.identifier}`),null;let i=0,s=new Set;for(let n of t)for(let a of e.areaMapEntries){if(s.has(a.coords))continue;F.isPointInArea(n,`${a.shape},${a.coords}`,r.baseType)&&(i+=a.mappedValue??0,s.add(a.coords))}return s.size<t.length&&(i+=e.defaultValue),e.lowerBound!=null&&(i=Math.max(e.lowerBound,i)),e.upperBound!=null&&(i=Math.min(e.upperBound,i)),i}};c([u({type:String})],ti.prototype,"identifier",2);customElements.define("qti-map-response-point",ti);var ri=class extends w{constructor(){super(...arguments);this.name=""}getResult(){if(!this.name)return console.error("qti-math-operator requires a name attribute"),null;let e=this.getVariables();if(!e||e.length===0)return null;let t=[];for(let i of e){if(i.cardinality!=="single")return console.error("qti-math-operator requires single cardinality"),null;if(Array.isArray(i.value))return console.error("qti-math-operator unexpected array value for single cardinality"),null;if(i.value===null||i.value===void 0)return null;if(i.baseType!=="integer"&&i.baseType!=="float")return console.error("qti-math-operator requires numerical base-type"),null;let s=parseFloat(i.value);if(isNaN(s))return console.error("qti-math-operator non-numerical value"),null;t.push(s)}return this._performOperation(this.name,t)}_performOperation(e,t){try{switch(e.toLowerCase()){case"sin":return t.length!==1?null:Math.sin(t[0]);case"cos":return t.length!==1?null:Math.cos(t[0]);case"tan":return t.length!==1?null:Math.tan(t[0]);case"asin":return t.length!==1||t[0]<-1||t[0]>1?null:Math.asin(t[0]);case"acos":return t.length!==1||t[0]<-1||t[0]>1?null:Math.acos(t[0]);case"atan":return t.length!==1?null:Math.atan(t[0]);case"sinh":return t.length!==1?null:Math.sinh(t[0]);case"cosh":return t.length!==1?null:Math.cosh(t[0]);case"tanh":return t.length!==1?null:Math.tanh(t[0]);case"log":return t.length!==1||t[0]<=0?null:Math.log(t[0]);case"ln":return t.length!==1||t[0]<=0?null:Math.log(t[0]);case"log10":return t.length!==1||t[0]<=0?null:Math.log10(t[0]);case"exp":return t.length!==1?null:Math.exp(t[0]);case"abs":return t.length!==1?null:Math.abs(t[0]);case"sqrt":return t.length!==1||t[0]<0?null:Math.sqrt(t[0]);case"signum":return t.length!==1?null:Math.sign(t[0]);case"floor":return t.length!==1?null:Math.floor(t[0]);case"ceil":return t.length!==1?null:Math.ceil(t[0]);case"round":return t.length!==1?null:Math.round(t[0]);case"atan2":return t.length!==2?null:Math.atan2(t[0],t[1]);case"pow":{if(t.length!==2)return null;let i=t[0],s=t[1];return i===0&&s<=0||i<0&&!Number.isInteger(s)?null:Math.pow(i,s)}case"log_base":{if(t.length!==2)return null;let i=t[0],s=t[1];return i<=0||s<=0||s===1?null:Math.log(i)/Math.log(s)}case"mod":return t.length!==2||t[1]===0?null:t[0]%t[1];case"max":return t.length<1?null:Math.max(...t);case"min":return t.length<1?null:Math.min(...t);default:return console.error(`qti-math-operator: unknown operation "${e}"`),null}}catch(i){return console.error(`qti-math-operator: error performing operation "${e}":`,i),null}}};c([u({type:String})],ri.prototype,"name",2);customElements.define("qti-math-operator",ri);var as=class o extends w{getResult(){if(this.children.length===2){let r=this.getVariables(),e=r[0],t=r[1];return o.match(e,t)}return console.error("unexpected number of children in match"),null}static match(r,e){if(r.value===null)return!1;switch(e.cardinality){case"single":return Array.isArray(r.value)||Array.isArray(e.value)?(console.error("unexpected cardinality in qti match"),!1):F.compareSingleValues(r.value?.toString(),e.value.toString(),e.baseType);case"ordered":{if(!Array.isArray(r.value)||!Array.isArray(e.value))return console.error("unexpected cardinality in qti match"),!1;if(r.value.length!==e.value.length)return!1;for(let t=0;t<r.value.length;t++)if(!F.compareSingleValues(e.value[t],r.value[t],e.baseType))return!1;return!0}case"multiple":{if(!Array.isArray(r.value)||!Array.isArray(e.value))return console.error("unexpected cardinality in qti match"),!1;if(r.value.length!==e.value.length)return!1;let t=0;for(let i of e.value){let s=null,n=[...r.value];for(let a of n)if(F.compareSingleValues(i,a,e.baseType)){s=a;break}if(s!==null)n.splice(n.indexOf(s),1);else return!1;t++}return!0}default:return console.error("unexpected cardinality in qti match"),!1}}};customElements.define("qti-match",as);var ls=class extends w{getResult(){let r=this.getVariables();this.children.length!==2&&console.warn("The member operator takes two sub-expressions");let[e,t]=r;if(e.baseType===t.baseType||e.baseType==="integer"&&t.baseType==="float"||e.baseType==="float"&&t.baseType==="integer"||console.warn("Which must both have the same base-type"),t.cardinality==="multiple"||t.cardinality==="ordered"||console.warn("and the second must be a multiple or ordered container"),(e.baseType==="float"||t.baseType==="float")&&console.warn("The member operator should not be used on sub-expressions with a base-type of float"),(e.baseType==="duration"||t.baseType==="duration")&&console.warn("It must not be used on sub-expressions with a base-type of duration"),e.value===null||t.value===null)return null;let i=e.value;return t.value.includes(i)}};customElements.define("qti-member",ls);var cs=class extends w{getResult(){console.debug("qti-multiple getResult called",this.innerHTML);let r=this.getVariables();if(r.length===0)return console.error("unexpected number of children in qti multiple"),null;for(let e of r)if(e.cardinality!=="multiple"&&e.cardinality!=="single")return console.error("unexpected cardinality in qti multiple"),[];return r}};customElements.define("qti-multiple",cs);var ds=class extends w{render(){return h`${super.render()}`}getResult(){return!this.firstElementChild.calculate()}};customElements.define("qti-not",ds);var ps=class extends K{getResult(){return Array.from(this.children).map(e=>{let t=e;if(!t.calculate)return console.error("Element doesn't implement QtiConditionExpression"),null;let i=t.calculate(),s=!1;if(typeof i=="string")if(i==="true")s=!0;else if(i==="false")s=!1;else return console.error("unexpected val in qti-or, expected boolean"),null;else typeof i=="boolean"&&(s=i);return s}).some(e=>typeof e=="boolean"&&e)}};customElements.define("qti-or",ps);var us=class extends w{getResult(){let r=this.getVariables();if(r.length===0)return console.error("unexpected number of children in qti multiple"),null;for(let e of r)if(e.cardinality!=="ordered"&&e.cardinality!=="single")return console.error("unexpected cardinality in qti ordered"),[];return r}};customElements.define("qti-ordered",us);var ms=class extends w{getResult(){if(this.children.length!==2)return console.error("qti-power must have exactly two child expressions"),null;let r=this.getVariables();if(!r||r.length!==2)return null;let[e,t]=r;if(e.cardinality!=="single"||t.cardinality!=="single")return console.error("qti-power requires single cardinality for both expressions"),null;if(Array.isArray(e.value)||Array.isArray(t.value))return console.error("qti-power unexpected array value for single cardinality"),null;if(e.value===null||e.value===void 0||t.value===null||t.value===void 0)return null;if(e.baseType!=="integer"&&e.baseType!=="float"||t.baseType!=="integer"&&t.baseType!=="float")return console.error("qti-power requires numerical base-types"),null;let i=parseFloat(e.value),s=parseFloat(t.value);if(isNaN(i)||isNaN(s))return console.error("qti-power: non-numerical values encountered"),null;if(i===0&&s<=0||i<0&&!Number.isInteger(s))return null;let n;try{n=Math.pow(i,s)}catch(a){return console.error("qti-power: error calculating power:",a),null}if(isNaN(n))return null;if(n===1/0||n===-1/0)return n;if(!isFinite(n)||Math.abs(n)>Number.MAX_VALUE||n!==0&&Math.abs(n)<Number.MIN_VALUE)return null;if(isFinite(n)&&n!==0){let a=Math.floor(Math.log10(Math.abs(n))),l=Math.max(0,14-a),d=Math.pow(10,l);n=Math.round(n*d)/d}return n}};customElements.define("qti-power",ms);var gr=class extends v{render(){let r=this.context?.variables.find(e=>e.identifier===this.identifier)?.value;return r===null?R:h`${JSON.stringify(r,null,2)}`}calculate(){return this.context.variables.find(e=>e.identifier===this.identifier)||null}};c([u({type:String})],gr.prototype,"identifier",2),c([_({context:$,subscribe:!0}),C()],gr.prototype,"context",2);customElements.define("qti-printed-variable",gr);var hs=class extends w{getResult(){return this.getVariables().reduce((t,i)=>{if(i.baseType=="float"||i.baseType=="integer")try{return t*parseFloat(i.value.toString())}catch{console.warn("can not convert to number")}else console.warn(`has another baseType ${i.baseType}`);return t},1)}};customElements.define("qti-product",hs);var ii=class extends In(w){getResult(){return this.calculateChildren(Array.from(this.children))}};function In(o){return class extends o{calculateChildren(e){let t=e.map(i=>{if(!i.calculate)return console.error("Element doesn't implement QtiConditionExpression"),null;let s=i.calculate();return Number.isNaN(s)?(console.error("Unexpected value in qti-subtract, expected number"),null):Number(s)});return t.some(i=>i===null)?(console.error("One or more child expressions returned invalid values"),0):t[0]-t[1]}}}customElements.define("qti-subtract",ii);var si=class extends w{constructor(){super(...arguments);this.caseSensitive="true"}getResult(){if(this.children.length===2){let e=this.getVariables(),t=e[0],i=e[1];if(t.cardinality!=="single"||i.cardinality!=="single"||Array.isArray(t.value)||Array.isArray(i.value))return console.error("unexpected cardinality in qti string-match"),!1;let s=this.caseSensitive==="true"?t.value:t.value.toLowerCase(),n=this.caseSensitive==="true"?i.value:i.value.toLowerCase();return F.compareSingleValues(s,n,t.baseType)}return console.error("unexpected number of children in qti-string-match"),null}};c([u({type:String,attribute:"case-sensitive"})],si.prototype,"caseSensitive",2);customElements.define("qti-string-match",si);var fs=class extends w{constructor(){super(),this._expression=new gs(Array.from(this.children))}getResult(){return this._expression.calculate()}},gs=class{constructor(r){this.expressions=r}calculate(){return this.expressions.filter(t=>t.calculate!==void 0).some(t=>t.calculate()===null)?null:this.expressions.map(t=>{let i=t.calculate();return Number.isNaN(i)?(console.error("unexpected value in qti-sum, expected number"),null):Number(i)}).reduce((t,i)=>t+i,0)}};customElements.define("qti-sum",fs);var bs=class extends w{getResult(){let r=this.getAttribute("identifier");return this.context.variables.find(t=>t.identifier===r).value}};customElements.define("qti-variable",bs);var Ct=class extends w{constructor(){super(...arguments);this.min=0;this.max=10;this.step=1}getResult(){if(this.min>this.max)return console.error("qti-random-integer: min cannot be greater than max"),this.min;if(this.step<=0)return console.error("qti-random-integer: step must be positive"),this.min;let e=[],t=0;for(;;){let s=this.min+this.step*t;if(s>this.max)break;Number.isInteger(s)&&e.push(s),t++}if(e.length===0)return console.warn("qti-random-integer: no valid integer values in range"),Number.isInteger(this.min)?this.min:Math.floor(this.min);let i=Math.floor(Math.random()*e.length);return e[i]}getPossibleValues(){let e=[];if(this.min>this.max||this.step<=0)return[Number.isInteger(this.min)?this.min:Math.floor(this.min)];let t=0;for(;;){let i=this.min+this.step*t;if(i>this.max)break;Number.isInteger(i)&&e.push(i),t++}return e.length>0?e:[Number.isInteger(this.min)?this.min:Math.floor(this.min)]}};c([u({type:Number})],Ct.prototype,"min",2),c([u({type:Number})],Ct.prototype,"max",2),c([u({type:Number})],Ct.prototype,"step",2);customElements.define("qti-random-integer",Ct);var vs=class extends w{getResult(){let r=this.getVariables();if(r.length===1){let e=r[0].value;if(Array.isArray(e)){let t=Math.floor(Math.random()*e.length);return e[t]}return e}return console.error("unexpected number of children in match"),null}};customElements.define("qti-random",vs);var ys=class extends w{getResult(){if(this.children.length===2){let r=this.getVariables(),e=r[0],t=r[1];return e.cardinality!=="single"||!Array.isArray(t.value)?(console.error("unexpected cardinality in qti equal"),null):r[0].baseType!==r[1].baseType?(console.error("The baseType of the two variables is different"),null):t.value.filter(s=>!e.value.includes(s))}}};customElements.define("qti-delete",ys);var br=class extends w{getResult(){if(!this.n)return console.error('qti-index: missing required attribute "n"'),null;if(this.children.length!==1)return console.error("qti-index: must have exactly one child container element"),null;let r=this.getVariables()[0];if(!r)return console.error("qti-index: missing container"),null;let e;if(!isNaN(Number(this.n)))e=Number(this.n);else{let t=this.lookupVariableValue(this.n);if(t===null)return console.error(`qti-index: variable "${this.n}" is not a valid number`),null;e=Number(t)}if(e<=0||!Number.isInteger(e))return console.error("qti-index: index must be a positive integer"),null;if(r.cardinality==="ordered"){let t=Array.isArray(r.value)?r.value:[r.value];return r.value===null||e>t.length?null:t[e-1]}else return console.error("qti-index: child must have ordered cardinality"),null}lookupVariableValue(r){let e=this.context.variables.find(t=>t.identifier===r)?.value;return e===null||isNaN(Number(e))?null:Number(e)}};c([u({type:String})],br.prototype,"n",2),br=c([g("qti-index")],br);var oi=class extends v{render(){return h`<slot></slot>`}};oi=c([g("qti-content-body")],oi);var ue=class extends v{handleclassNamesChange(){this.classNames.split(" ").forEach(e=>{switch(e){case"qti-rubric-discretionary-placement":{let t=new CustomEvent("qti-rubric:discretionary-placement",{detail:{className:e,element:this},bubbles:!0,composed:!0,cancelable:!0});if(!this.dispatchEvent(t))return;this.setAttribute("slot","qti-rubric-block")}break;case"qti-rubric-inline":this.setAttribute("slot","");break;default:break}})}render(){return h`<slot></slot>`}};ue.styles=x`
1484
+ <slot></slot>`}calculate(){return this.result=this.getResult(),this.result}getResult(){throw new Error("Not implemented")}};c([E()],w.prototype,"result",2),c([_({context:$,subscribe:!0}),E()],w.prototype,"context",2),c([_({context:Yr,subscribe:!0}),E()],w.prototype,"qtiContext",2);var K=class extends w{calculate(){return this.result=this.getResult(),this.result}getResult(){throw new Error("Not implemented")}};var Jr=class extends Mn(K){calculate(){return this.calculateChildren(Array.from(this.children))}};Jr=c([g("qti-and")],Jr);function Mn(o){return class extends o{calculateChildren(e){return e.map(i=>{let s=i;if(!s.calculate)return console.error("Element doesn't implement QtiConditionExpression"),null;let n=s.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)}}}var Kr=class extends w{constructor(){super(...arguments);this.baseType="string"}getResult(){return this.textContent.trim()}};c([u({type:String,attribute:"base-type"})],Kr.prototype,"baseType",2);customElements.define("qti-base-value",Kr);var Gi=class extends w{getResult(){if(this.children?.length!==1)return console.error("qti-container-size must have exactly one child expression"),0;let r=this.getVariables();if(!r||r?.length===0)return 0;let e=r[0];return e.value===null||e.value===void 0?0:e.cardinality!=="multiple"&&e.cardinality!=="ordered"?(console.error("qti-container-size requires multiple or ordered cardinality"),0):Array.isArray(e.value)?e.value.length:(console.error("qti-container-size: expected array value for multiple/ordered cardinality"),0)}};customElements.define("qti-container-size",Gi);var Yi=class extends K{getResult(){let r=this.getVariables();if(this.children.length===2){let e=r[0],t=r[1];if(e.baseType==="directedPair"&&t.baseType==="directedPair"&&e.cardinality==="multiple"){let i=e.value,s=t.value;return i.filter(l=>s.includes(l)).length>0}else if(e.baseType==="directedPair"&&t.baseType==="directedPair"&&e.cardinality==="single"){let i=e.value;return t.value.includes(i)}else console.error("unsupported baseType or cardinality in qti contains, only baseType: directedPair and cardinality: multiple is supported")}else console.error("unexpected number of children in qti contains");return!1}};customElements.define("qti-contains",Yi);var Ji=class extends w{get interpretation(){return this.getAttribute("interpretation")||""}getResult(){let r=this.getAttribute("identifier")||"",e=this.context.variables.find(t=>t.identifier===r)||null;return e.cardinality!=="single"?e.correctResponse.length>0?e.correctResponse[0]:"":e.correctResponse}};customElements.define("qti-correct",Ji);var Ki={items:[],testOutcomeVariables:[]},pe=Symbol("testContext");var qt=class extends w{constructor(){super(...arguments);this.identifier=""}getResult(){if(!this.identifier)return console.error("qti-default requires an identifier attribute"),null;let e=this.identifier.split("."),t=null,i;if(e.length===2)t=e[0],i=e[1];else if(e.length===1)i=e[0];else return console.error("qti-default: invalid identifier format"),null;if(t){let n=this._testContext.items.find(l=>l.identifier===t);if(console.debug(`itemContext: ${JSON.stringify(n)}`),!this._testContext||!n)return console.warn(`qti-default: item "${t}" not found in test context`),null;let a=this._testContext.items.find(l=>l.identifier===t)?.variables.find(l=>l.identifier===i);return a?a.defaultValue||null:(console.warn(`qti-default: variable "${i}" not found in item "${t}"`),null)}if(!this.context?.variables)return console.warn("qti-default: no variables found in item context"),null;let s=this.context.variables.find(n=>n.identifier===i);return s?s.defaultValue||null:(console.warn(`qti-default: variable "${i}" not found in item context`),null)}};c([u({type:String})],qt.prototype,"identifier",2),c([_({context:$,subscribe:!0}),E()],qt.prototype,"context",2),c([E(),_({context:pe,subscribe:!0})],qt.prototype,"_testContext",2);customElements.define("qti-default",qt);var Zr=class extends w{constructor(){super(...arguments);this.roundingMode="significantFigures"}get figures(){if(!this.getAttribute("figures"))return console.error("figures attribute is missing"),null;let t=parseInt(this.getAttribute("figures")||"0");return isNaN(t)?(console.error("figures attribute is not a number"),null):t<0?(console.error("figures attribute is negative"),null):t<1&&this.roundingMode==="significantFigures"?(console.error("figures cannot be smaller than 1 for RoundingMode significantFigures"),null):t}getResult(){if(this.children.length===2){let e=this.getVariables(),t=e[0],i=e[1];if(this.roundingMode===null)return null;if(t.cardinality!=="single"||i.cardinality!=="single"||Array.isArray(t.value)||Array.isArray(i.value))return console.error("unexpected cardinality in qti equal"),!1;switch(e[0].baseType){case"integer":case"float":{let s=parseFloat(t.value),n=parseFloat(i.value);if(!isNaN(s)&&!isNaN(n))return this.roundingMode==="significantFigures"?s.toPrecision(this.figures)===n.toPrecision(this.figures):Math.round(s*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: ${s}, ${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}};c([u({type:String})],Zr.prototype,"roundingMode",2);customElements.define("qti-equal-rounded",Zr);var Zi=class extends w{getResult(){if(this.children.length!==1)return console.error("qti-round must have exactly one child expression"),null;let r=this.getVariables();if(!r||r.length===0)return null;let e=r[0];if(e.cardinality!=="single")return console.error("qti-round requires single cardinality"),null;if(Array.isArray(e.value))return console.error("qti-round unexpected array value for single cardinality"),null;if(e.value===null||e.value===void 0)return null;if(e.baseType!=="integer"&&e.baseType!=="float")return console.error("qti-round requires numerical base-type (integer or float)"),null;let t=parseFloat(e.value);return isNaN(t)?(console.warn("qti-round: NaN input results in NULL"),null):isFinite(t)?Math.floor(t+.5):t===1/0?1/0:t===-1/0?-1/0:null}};customElements.define("qti-round",Zi);var fr=class extends w{constructor(){super(...arguments);this.roundingMode="significantFigures";this.figures=3}getResult(){if(this.children.length!==1)return console.error("qti-round-to must have exactly one child expression"),null;let e=this.getVariables();if(!e||e.length===0)return null;let t=e[0];if(t.cardinality!=="single")return console.error("qti-round-to requires single cardinality"),null;if(Array.isArray(t.value))return console.error("qti-round-to unexpected array value for single cardinality"),null;if(t.value===null||t.value===void 0)return null;if(t.baseType!=="integer"&&t.baseType!=="float")return console.error("qti-round-to requires numerical base-type"),null;let i=parseFloat(t.value);return isNaN(i)?null:isFinite(i)?this.figures<0?(console.error("qti-round-to: figures must be non-negative"),null):this.roundingMode==="significantFigures"&&this.figures<1?(console.error("qti-round-to: figures must be at least 1 for significantFigures mode"),null):this.roundingMode==="decimalPlaces"?this._roundToDecimalPlaces(i,this.figures):this._roundToSignificantFigures(i,this.figures):i===1/0?1/0:i===-1/0?-1/0:null}_roundToDecimalPlaces(e,t){if(e===0)return 0;let i=Math.pow(10,t);return Math.round(e*i)/i}_roundToSignificantFigures(e,t){if(e===0)return 0;let i=Math.floor(Math.log10(Math.abs(e))),s=Math.pow(10,t-i-1);return Math.round(e*s)/s}};c([u({type:String,attribute:"rounding-mode"})],fr.prototype,"roundingMode",2),c([u({type:Number})],fr.prototype,"figures",2);customElements.define("qti-round-to",fr);var Qr=class extends w{constructor(){super(...arguments);this.toleranceMode="exact"}getResult(){if(this.children.length===2){let e=this.getVariables(),t=e[0],i=e[1];return this.toleranceMode!=="exact"?(console.error("toleranceMode is not supported yet"),!1):t.cardinality!=="single"||i.cardinality!=="single"||Array.isArray(t.value)||Array.isArray(i.value)?(console.error("unexpected cardinality in qti equal"),!1):F.compareSingleValues(t.value,i.value,t.baseType)}return console.error("unexpected number of children in qti-equal"),null}};c([u({type:String})],Qr.prototype,"toleranceMode",2);customElements.define("qti-equal",Qr);var Qi=class extends w{getResult(){if(this.children.length===0)return console.error("qti-gcd must have at least one child expression"),null;let r=this.getVariables();if(!r||r.length===0)return null;let e=[];for(let t of r){if(t.baseType!=="integer")return console.error("qti-gcd requires integer base-type"),null;if(t.value===null||t.value===void 0)return null;if(t.cardinality==="single"){if(Array.isArray(t.value))return console.error("qti-gcd unexpected array value for single cardinality"),null;let i=parseInt(t.value,10);if(isNaN(i))return console.error("qti-gcd non-numerical value"),null;e.push(i)}else if(t.cardinality==="multiple"||t.cardinality==="ordered"){if(!Array.isArray(t.value))return console.error("qti-gcd expected array value for multiple/ordered cardinality"),null;for(let i of t.value){if(i==null)return null;let s=parseInt(i,10);if(isNaN(s))return console.error("qti-gcd non-numerical value"),null;e.push(s)}}else return console.error("qti-gcd unsupported cardinality"),null}return e.length===0?null:this._calculateGcd(e)}_calculateGcd(r){if(r.length===0)return 0;if(r.length===1)return Math.abs(r[0]);let e=Math.abs(r[0]);for(let t=1;t<r.length&&(e=this._gcdTwoNumbers(e,Math.abs(r[t])),e!==1);t++);return e}_gcdTwoNumbers(r,e){if(r===0&&e===0)return 0;if(r===0)return e;if(e===0)return r;for(;e!==0;){let t=e;e=r%e,r=t}return r}};customElements.define("qti-gcd",Qi);var es=class extends w{getResult(){if(this.children.length===2){let r=this.getVariables(),e=r[0],t=r[1];if((e.baseType==="integer"||e.baseType==="float")&&(t.baseType==="integer"||t.baseType==="float"))return+e.value>+t.value;console.error("unexpected baseType or cardinality in qti gt")}return console.error("unexpected number of children in qt"),null}};customElements.define("qti-gt",es);var ts=class extends K{getResult(){if(this.children.length===2){let r=this.getVariables(),e=r[0],t=r[1];return(e.baseType==="integer"||e.baseType==="float")&&(t.baseType==="integer"||t.baseType==="float")?+e.value>=+t.value:(console.error("unexpected baseType or cardinality in qti gte"),null)}return console.log("unexpected number of children in qte"),null}};customElements.define("qti-gte",ts);var rs=class extends w{getResult(){return null}};customElements.define("qti-null",rs);var is=class extends w{getResult(){if(this.children.length===1){let r=this.getVariables();if(!r)return!0;let e=r[0].value;return e==null||e==null||e===""}return console.error("unexpected number of children in qti Null"),null}};customElements.define("qti-is-null",is);var ss=class extends w{getResult(){let r=this.getAttribute("field-identifier");if(!r)throw new Error("field-identifier attribute is required");if(Array.from(this.children).length!==1)throw new Error("qti-field-value must have exactly one child expression");let t=this.getVariables()[0];if(t.baseType!=="record"||t.value===null)throw new Error("qti-field-value child expression must return a record");let i=t.value[r];if(i===void 0)throw new Error(`Field "${r}" not found in record`);return i}};customElements.define("qti-field-value",ss);var os=class extends w{getResult(){if(this.children.length===2){let r=this.getVariables(),e=r[0],t=r[1];if((e.baseType==="integer"||e.baseType==="float")&&(t.baseType==="integer"||t.baseType==="float"))return+e.value<+t.value;console.error("unexpected baseType or cardinality in qti lt")}return console.error("unexpected number of children in lt"),null}};customElements.define("qti-lt",os);var ns=class extends K{getResult(){if(this.children.length===2){let r=this.getVariables(),e=r[0],t=r[1];return(e.baseType==="integer"||e.baseType==="float")&&(t.baseType==="integer"||t.baseType==="float")?+e.value<=+t.value:(console.error("unexpected baseType or cardinality in qti lte"),null)}return console.log("unexpected number of children in lte"),null}};customElements.define("qti-lte",ns);var ei=class extends w{getResult(){let r=this.context.variables.find(s=>s.identifier===this.identifier);if(!r||!r.mapping)return console.error(`Response ${this.identifier} can not be found`),null;let e=r.mapping,t=Array.isArray(r.value)?r.value:[r.value],i=0;for(let s of t){let n=e.mapEntries.filter(l=>r.baseType==="string"&&!l.caseSensitive?F.compareSingleValues(l.mapKey.toLowerCase(),s.toLowerCase(),r.baseType):F.compareSingleValues(l.mapKey,s,r.baseType)),a=n.reduce((l,d)=>l.mappedValue>d.mappedValue?l:d,n.length>0?n[0]:{mapKey:null,mappedValue:null});a===null||a.mappedValue==null?i+=e.defaultValue:i+=a.mappedValue}return e?.lowerBound!==null&&e?.lowerBound!==void 0&&(i=Math.max(e.lowerBound,i)),e?.upperBound!==null&&e?.upperBound!==void 0&&(i=Math.min(e.upperBound,i)),i}};c([u({type:String})],ei.prototype,"identifier",2);customElements.define("qti-map-response",ei);var ti=class extends w{getResult(){let r=this.context.variables.find(n=>n.identifier===this.identifier);if(!r)return console.warn(`Response ${this.identifier} cannot be found`),null;let e=r.areaMapping;if(!e)return console.warn(`Area mapping not found for response ${this.identifier}`),null;let t=Array.isArray(r.value)?r.value:[r.value];if(!t||t.length===0)return console.warn(`No candidate responses for response ${this.identifier}`),null;let i=0,s=new Set;for(let n of t)for(let a of e.areaMapEntries){if(s.has(a.coords))continue;F.isPointInArea(n,`${a.shape},${a.coords}`,r.baseType)&&(i+=a.mappedValue??0,s.add(a.coords))}return s.size<t.length&&(i+=e.defaultValue),e.lowerBound!=null&&(i=Math.max(e.lowerBound,i)),e.upperBound!=null&&(i=Math.min(e.upperBound,i)),i}};c([u({type:String})],ti.prototype,"identifier",2);customElements.define("qti-map-response-point",ti);var ri=class extends w{constructor(){super(...arguments);this.name=""}getResult(){if(!this.name)return console.error("qti-math-operator requires a name attribute"),null;let e=this.getVariables();if(!e||e.length===0)return null;let t=[];for(let i of e){if(i.cardinality!=="single")return console.error("qti-math-operator requires single cardinality"),null;if(Array.isArray(i.value))return console.error("qti-math-operator unexpected array value for single cardinality"),null;if(i.value===null||i.value===void 0)return null;if(i.baseType!=="integer"&&i.baseType!=="float")return console.error("qti-math-operator requires numerical base-type"),null;let s=parseFloat(i.value);if(isNaN(s))return console.error("qti-math-operator non-numerical value"),null;t.push(s)}return this._performOperation(this.name,t)}_performOperation(e,t){try{switch(e.toLowerCase()){case"sin":return t.length!==1?null:Math.sin(t[0]);case"cos":return t.length!==1?null:Math.cos(t[0]);case"tan":return t.length!==1?null:Math.tan(t[0]);case"asin":return t.length!==1||t[0]<-1||t[0]>1?null:Math.asin(t[0]);case"acos":return t.length!==1||t[0]<-1||t[0]>1?null:Math.acos(t[0]);case"atan":return t.length!==1?null:Math.atan(t[0]);case"sinh":return t.length!==1?null:Math.sinh(t[0]);case"cosh":return t.length!==1?null:Math.cosh(t[0]);case"tanh":return t.length!==1?null:Math.tanh(t[0]);case"log":return t.length!==1||t[0]<=0?null:Math.log(t[0]);case"ln":return t.length!==1||t[0]<=0?null:Math.log(t[0]);case"log10":return t.length!==1||t[0]<=0?null:Math.log10(t[0]);case"exp":return t.length!==1?null:Math.exp(t[0]);case"abs":return t.length!==1?null:Math.abs(t[0]);case"sqrt":return t.length!==1||t[0]<0?null:Math.sqrt(t[0]);case"signum":return t.length!==1?null:Math.sign(t[0]);case"floor":return t.length!==1?null:Math.floor(t[0]);case"ceil":return t.length!==1?null:Math.ceil(t[0]);case"round":return t.length!==1?null:Math.round(t[0]);case"atan2":return t.length!==2?null:Math.atan2(t[0],t[1]);case"pow":{if(t.length!==2)return null;let i=t[0],s=t[1];return i===0&&s<=0||i<0&&!Number.isInteger(s)?null:Math.pow(i,s)}case"log_base":{if(t.length!==2)return null;let i=t[0],s=t[1];return i<=0||s<=0||s===1?null:Math.log(i)/Math.log(s)}case"mod":return t.length!==2||t[1]===0?null:t[0]%t[1];case"max":return t.length<1?null:Math.max(...t);case"min":return t.length<1?null:Math.min(...t);default:return console.error(`qti-math-operator: unknown operation "${e}"`),null}}catch(i){return console.error(`qti-math-operator: error performing operation "${e}":`,i),null}}};c([u({type:String})],ri.prototype,"name",2);customElements.define("qti-math-operator",ri);var as=class o extends w{getResult(){if(this.children.length===2){let r=this.getVariables(),e=r[0],t=r[1];return o.match(e,t)}return console.error("unexpected number of children in match"),null}static match(r,e){if(r.value===null)return!1;switch(e.cardinality){case"single":return Array.isArray(r.value)||Array.isArray(e.value)?(console.error("unexpected cardinality in qti match"),!1):F.compareSingleValues(r.value?.toString(),e.value.toString(),e.baseType);case"ordered":{if(!Array.isArray(r.value)||!Array.isArray(e.value))return console.error("unexpected cardinality in qti match"),!1;if(r.value.length!==e.value.length)return!1;for(let t=0;t<r.value.length;t++)if(!F.compareSingleValues(e.value[t],r.value[t],e.baseType))return!1;return!0}case"multiple":{if(!Array.isArray(r.value)||!Array.isArray(e.value))return console.error("unexpected cardinality in qti match"),!1;if(r.value.length!==e.value.length)return!1;let t=0;for(let i of e.value){let s=null,n=[...r.value];for(let a of n)if(F.compareSingleValues(i,a,e.baseType)){s=a;break}if(s!==null)n.splice(n.indexOf(s),1);else return!1;t++}return!0}default:return console.error("unexpected cardinality in qti match"),!1}}};customElements.define("qti-match",as);var ls=class extends w{getResult(){let r=this.getVariables();this.children.length!==2&&console.warn("The member operator takes two sub-expressions");let[e,t]=r;if(e.baseType===t.baseType||e.baseType==="integer"&&t.baseType==="float"||e.baseType==="float"&&t.baseType==="integer"||console.warn("Which must both have the same base-type"),t.cardinality==="multiple"||t.cardinality==="ordered"||console.warn("and the second must be a multiple or ordered container"),(e.baseType==="float"||t.baseType==="float")&&console.warn("The member operator should not be used on sub-expressions with a base-type of float"),(e.baseType==="duration"||t.baseType==="duration")&&console.warn("It must not be used on sub-expressions with a base-type of duration"),e.value===null||t.value===null)return null;let i=e.value;return t.value.includes(i)}};customElements.define("qti-member",ls);var cs=class extends w{getResult(){console.debug("qti-multiple getResult called",this.innerHTML);let r=this.getVariables();if(r.length===0)return console.error("unexpected number of children in qti multiple"),null;for(let e of r)if(e.cardinality!=="multiple"&&e.cardinality!=="single")return console.error("unexpected cardinality in qti multiple"),[];return r}};customElements.define("qti-multiple",cs);var ds=class extends w{render(){return h`${super.render()}`}getResult(){return!this.firstElementChild.calculate()}};customElements.define("qti-not",ds);var ps=class extends K{getResult(){return Array.from(this.children).map(e=>{let t=e;if(!t.calculate)return console.error("Element doesn't implement QtiConditionExpression"),null;let i=t.calculate(),s=!1;if(typeof i=="string")if(i==="true")s=!0;else if(i==="false")s=!1;else return console.error("unexpected val in qti-or, expected boolean"),null;else typeof i=="boolean"&&(s=i);return s}).some(e=>typeof e=="boolean"&&e)}};customElements.define("qti-or",ps);var us=class extends w{getResult(){let r=this.getVariables();if(r.length===0)return console.error("unexpected number of children in qti multiple"),null;for(let e of r)if(e.cardinality!=="ordered"&&e.cardinality!=="single")return console.error("unexpected cardinality in qti ordered"),[];return r}};customElements.define("qti-ordered",us);var ms=class extends w{getResult(){if(this.children.length!==2)return console.error("qti-power must have exactly two child expressions"),null;let r=this.getVariables();if(!r||r.length!==2)return null;let[e,t]=r;if(e.cardinality!=="single"||t.cardinality!=="single")return console.error("qti-power requires single cardinality for both expressions"),null;if(Array.isArray(e.value)||Array.isArray(t.value))return console.error("qti-power unexpected array value for single cardinality"),null;if(e.value===null||e.value===void 0||t.value===null||t.value===void 0)return null;if(e.baseType!=="integer"&&e.baseType!=="float"||t.baseType!=="integer"&&t.baseType!=="float")return console.error("qti-power requires numerical base-types"),null;let i=parseFloat(e.value),s=parseFloat(t.value);if(isNaN(i)||isNaN(s))return console.error("qti-power: non-numerical values encountered"),null;if(i===0&&s<=0||i<0&&!Number.isInteger(s))return null;let n;try{n=Math.pow(i,s)}catch(a){return console.error("qti-power: error calculating power:",a),null}if(isNaN(n))return null;if(n===1/0||n===-1/0)return n;if(!isFinite(n)||Math.abs(n)>Number.MAX_VALUE||n!==0&&Math.abs(n)<Number.MIN_VALUE)return null;if(isFinite(n)&&n!==0){let a=Math.floor(Math.log10(Math.abs(n))),l=Math.max(0,14-a),d=Math.pow(10,l);n=Math.round(n*d)/d}return n}};customElements.define("qti-power",ms);var gr=class extends v{render(){let r=this.context?.variables.find(e=>e.identifier===this.identifier)?.value;return r===null?R:h`${JSON.stringify(r,null,2)}`}calculate(){return this.context.variables.find(e=>e.identifier===this.identifier)||null}};c([u({type:String})],gr.prototype,"identifier",2),c([_({context:$,subscribe:!0}),E()],gr.prototype,"context",2);customElements.define("qti-printed-variable",gr);var hs=class extends w{getResult(){return this.getVariables().reduce((t,i)=>{if(i.baseType=="float"||i.baseType=="integer")try{return t*parseFloat(i.value.toString())}catch{console.warn("can not convert to number")}else console.warn(`has another baseType ${i.baseType}`);return t},1)}};customElements.define("qti-product",hs);var ii=class extends In(w){getResult(){return this.calculateChildren(Array.from(this.children))}};function In(o){return class extends o{calculateChildren(e){let t=e.map(i=>{if(!i.calculate)return console.error("Element doesn't implement QtiConditionExpression"),null;let s=i.calculate();return Number.isNaN(s)?(console.error("Unexpected value in qti-subtract, expected number"),null):Number(s)});return t.some(i=>i===null)?(console.error("One or more child expressions returned invalid values"),0):t[0]-t[1]}}}customElements.define("qti-subtract",ii);var si=class extends w{constructor(){super(...arguments);this.caseSensitive="true"}getResult(){if(this.children.length===2){let e=this.getVariables(),t=e[0],i=e[1];if(t.cardinality!=="single"||i.cardinality!=="single"||Array.isArray(t.value)||Array.isArray(i.value))return console.error("unexpected cardinality in qti string-match"),!1;let s=this.caseSensitive==="true"?t.value:t.value.toLowerCase(),n=this.caseSensitive==="true"?i.value:i.value.toLowerCase();return F.compareSingleValues(s,n,t.baseType)}return console.error("unexpected number of children in qti-string-match"),null}};c([u({type:String,attribute:"case-sensitive"})],si.prototype,"caseSensitive",2);customElements.define("qti-string-match",si);var fs=class extends w{constructor(){super(),this._expression=new gs(Array.from(this.children))}getResult(){return this._expression.calculate()}},gs=class{constructor(r){this.expressions=r}calculate(){return this.expressions.filter(t=>t.calculate!==void 0).some(t=>t.calculate()===null)?null:this.expressions.map(t=>{let i=t.calculate();return Number.isNaN(i)?(console.error("unexpected value in qti-sum, expected number"),null):Number(i)}).reduce((t,i)=>t+i,0)}};customElements.define("qti-sum",fs);var bs=class extends w{getResult(){let r=this.getAttribute("identifier");return this.context.variables.find(t=>t.identifier===r).value}};customElements.define("qti-variable",bs);var Ct=class extends w{constructor(){super(...arguments);this.min=0;this.max=10;this.step=1}getResult(){if(this.min>this.max)return console.error("qti-random-integer: min cannot be greater than max"),this.min;if(this.step<=0)return console.error("qti-random-integer: step must be positive"),this.min;let e=[],t=0;for(;;){let s=this.min+this.step*t;if(s>this.max)break;Number.isInteger(s)&&e.push(s),t++}if(e.length===0)return console.warn("qti-random-integer: no valid integer values in range"),Number.isInteger(this.min)?this.min:Math.floor(this.min);let i=Math.floor(Math.random()*e.length);return e[i]}getPossibleValues(){let e=[];if(this.min>this.max||this.step<=0)return[Number.isInteger(this.min)?this.min:Math.floor(this.min)];let t=0;for(;;){let i=this.min+this.step*t;if(i>this.max)break;Number.isInteger(i)&&e.push(i),t++}return e.length>0?e:[Number.isInteger(this.min)?this.min:Math.floor(this.min)]}};c([u({type:Number})],Ct.prototype,"min",2),c([u({type:Number})],Ct.prototype,"max",2),c([u({type:Number})],Ct.prototype,"step",2);customElements.define("qti-random-integer",Ct);var vs=class extends w{getResult(){let r=this.getVariables();if(r.length===1){let e=r[0].value;if(Array.isArray(e)){let t=Math.floor(Math.random()*e.length);return e[t]}return e}return console.error("unexpected number of children in match"),null}};customElements.define("qti-random",vs);var ys=class extends w{getResult(){if(this.children.length===2){let r=this.getVariables(),e=r[0],t=r[1];return e.cardinality!=="single"||!Array.isArray(t.value)?(console.error("unexpected cardinality in qti equal"),null):r[0].baseType!==r[1].baseType?(console.error("The baseType of the two variables is different"),null):t.value.filter(s=>!e.value.includes(s))}}};customElements.define("qti-delete",ys);var br=class extends w{getResult(){if(!this.n)return console.error('qti-index: missing required attribute "n"'),null;if(this.children.length!==1)return console.error("qti-index: must have exactly one child container element"),null;let r=this.getVariables()[0];if(!r)return console.error("qti-index: missing container"),null;let e;if(!isNaN(Number(this.n)))e=Number(this.n);else{let t=this.lookupVariableValue(this.n);if(t===null)return console.error(`qti-index: variable "${this.n}" is not a valid number`),null;e=Number(t)}if(e<=0||!Number.isInteger(e))return console.error("qti-index: index must be a positive integer"),null;if(r.cardinality==="ordered"){let t=Array.isArray(r.value)?r.value:[r.value];return r.value===null||e>t.length?null:t[e-1]}else return console.error("qti-index: child must have ordered cardinality"),null}lookupVariableValue(r){let e=this.context.variables.find(t=>t.identifier===r)?.value;return e===null||isNaN(Number(e))?null:Number(e)}};c([u({type:String})],br.prototype,"n",2),br=c([g("qti-index")],br);var oi=class extends v{render(){return h`<slot></slot>`}};oi=c([g("qti-content-body")],oi);var ue=class extends v{handleclassNamesChange(){this.classNames.split(" ").forEach(e=>{switch(e){case"qti-rubric-discretionary-placement":{let t=new CustomEvent("qti-rubric:discretionary-placement",{detail:{className:e,element:this},bubbles:!0,composed:!0,cancelable:!0});if(!this.dispatchEvent(t))return;this.setAttribute("slot","qti-rubric-block")}break;case"qti-rubric-inline":this.setAttribute("slot","");break;default:break}})}render(){return h`<slot></slot>`}};ue.styles=x`
1485
1485
  :host {
1486
1486
  display: block;
1487
1487
  }
@@ -1489,45 +1489,45 @@ Make sure to test your application with a production build as repeat registratio
1489
1489
  :host {
1490
1490
  display: none;
1491
1491
  }
1492
- `],c([u({type:String,attribute:"base-type"})],me.prototype,"baseType",2),c([u({type:String,attribute:"external-scored"})],me.prototype,"externalScored",2),c([u({type:String})],me.prototype,"identifier",2),c([u({type:String})],me.prototype,"cardinality",2),c([_({context:$,subscribe:!0}),C()],me.prototype,"itemContext",2),me=c([g("qti-outcome-declaration")],me);var we=class extends He{render(){let r=this.itemContext?.variables.find(e=>e.identifier===this.identifier)?.value;return h`${JSON.stringify(r,null,2)}`}connectedCallback(){super.connectedCallback();let r=this.defaultValues(this.cardinality),e={baseType:this.baseType,identifier:this.identifier,correctResponse:this.correctResponse,cardinality:this.cardinality||"single",mapping:this.mapping,defaultValue:r,areaMapping:this.areaMapping,value:null,type:"response",candidateResponse:null};e.value=r,this.dispatchEvent(new CustomEvent("qti-register-variable",{bubbles:!0,composed:!0,detail:{variable:e}}))}get correctResponse(){let r,e=this.querySelector("qti-correct-response");if(e){let t=e.querySelectorAll("qti-value");if(this.cardinality==="single"&&t.length>0)r=t[0].textContent.trim(),t[0].remove();else if(this.cardinality!=="single"){r=[];for(let i=0;i<t.length;i++)r.push(t[i].textContent.trim()),t[i].remove()}}return r}get mapping(){let r=this.querySelector("qti-mapping"),e=parseFloat(r?.getAttribute("lower-bound")),t=parseFloat(r?.getAttribute("upper-bound"));return{defaultValue:Number(r?.getAttribute("default-value"))||0,lowerBound:isNaN(e)?null:e,upperBound:isNaN(t)?null:t,mapEntries:Array.from(r?.querySelectorAll("qti-map-entry")||[]).map(s=>({mapKey:s.getAttribute("map-key")||"",mappedValue:Number(s.getAttribute("mapped-value"))||0,caseSensitive:s.hasAttribute("case-sensitive")?s.getAttribute("case-sensitive")!=="false":!1}))}}get areaMapping(){let r=this.querySelector("qti-area-mapping"),e=Number(r?.getAttribute("default-value"))||0,t=parseFloat(r?.getAttribute("lower-bound")),i=parseFloat(r?.getAttribute("upper-bound")),s=Array.from(r?.querySelectorAll("qti-area-map-entry")||[]).map(n=>({shape:n.getAttribute("shape")||"default",coords:n.getAttribute("coords")||"",mappedValue:Number(n.getAttribute("mapped-value"))||0,defaultValue:Number(n.getAttribute("default-value"))||0}));return{defaultValue:e,lowerBound:isNaN(t)?null:t,upperBound:isNaN(i)?null:i,areaMapEntries:s}}};we.styles=[x`
1492
+ `],c([u({type:String,attribute:"base-type"})],me.prototype,"baseType",2),c([u({type:String,attribute:"external-scored"})],me.prototype,"externalScored",2),c([u({type:String})],me.prototype,"identifier",2),c([u({type:String})],me.prototype,"cardinality",2),c([_({context:$,subscribe:!0}),E()],me.prototype,"itemContext",2),me=c([g("qti-outcome-declaration")],me);var we=class extends He{render(){let r=this.itemContext?.variables.find(e=>e.identifier===this.identifier)?.value;return h`${JSON.stringify(r,null,2)}`}connectedCallback(){super.connectedCallback();let r=this.defaultValues(this.cardinality),e={baseType:this.baseType,identifier:this.identifier,correctResponse:this.correctResponse,cardinality:this.cardinality||"single",mapping:this.mapping,defaultValue:r,areaMapping:this.areaMapping,value:null,type:"response",candidateResponse:null};e.value=r,this.dispatchEvent(new CustomEvent("qti-register-variable",{bubbles:!0,composed:!0,detail:{variable:e}}))}get correctResponse(){let r,e=this.querySelector("qti-correct-response");if(e){let t=e.querySelectorAll("qti-value");if(this.cardinality==="single"&&t.length>0)r=t[0].textContent.trim(),t[0].remove();else if(this.cardinality!=="single"){r=[];for(let i=0;i<t.length;i++)r.push(t[i].textContent.trim()),t[i].remove()}}return r}get mapping(){let r=this.querySelector("qti-mapping"),e=parseFloat(r?.getAttribute("lower-bound")),t=parseFloat(r?.getAttribute("upper-bound"));return{defaultValue:Number(r?.getAttribute("default-value"))||0,lowerBound:isNaN(e)?null:e,upperBound:isNaN(t)?null:t,mapEntries:Array.from(r?.querySelectorAll("qti-map-entry")||[]).map(s=>({mapKey:s.getAttribute("map-key")||"",mappedValue:Number(s.getAttribute("mapped-value"))||0,caseSensitive:s.hasAttribute("case-sensitive")?s.getAttribute("case-sensitive")!=="false":!1}))}}get areaMapping(){let r=this.querySelector("qti-area-mapping"),e=Number(r?.getAttribute("default-value"))||0,t=parseFloat(r?.getAttribute("lower-bound")),i=parseFloat(r?.getAttribute("upper-bound")),s=Array.from(r?.querySelectorAll("qti-area-map-entry")||[]).map(n=>({shape:n.getAttribute("shape")||"default",coords:n.getAttribute("coords")||"",mappedValue:Number(n.getAttribute("mapped-value"))||0,defaultValue:Number(n.getAttribute("default-value"))||0}));return{defaultValue:e,lowerBound:isNaN(t)?null:t,upperBound:isNaN(i)?null:i,areaMapEntries:s}}};we.styles=[x`
1493
1493
  :host {
1494
1494
  display: none;
1495
1495
  }
1496
- `],c([u({type:String,attribute:"base-type"})],we.prototype,"baseType",2),c([u({type:String})],we.prototype,"identifier",2),c([u({type:String})],we.prototype,"cardinality",2),c([_({context:$,subscribe:!0}),C()],we.prototype,"itemContext",2),we=c([g("qti-response-declaration")],we);var $o=o=>{class r extends o{constructor(...i){super(...i);this.navigate=null;this.cacheTransform=!1;this.requestTimeout=3e4;this.postLoadTransformCallback=null;this.postLoadTestTransformCallback=null;this._activeController=null;this._loadResults=[];this._loadingState={expectedItems:0,connectedItems:0,expectedStimulus:0,loadedStimulus:0,isComplete:!1};this._loadedStimulusHrefs=new Set;this._loadingStimulusHrefs=new Set;this._bindEventHandlers()}navigateTo(i,s){let n=s||this._getDefaultNavigationId(i);n&&this.dispatchEvent(new CustomEvent("qti-request-navigation",{detail:{type:i,id:n},bubbles:!0,composed:!0}))}_bindEventHandlers(){this.addEventListener("qti-request-navigation",this._handleNavigationRequest.bind(this)),this.addEventListener("qti-assessment-test-connected",this._handleTestConnected.bind(this)),this.addEventListener("qti-assessment-item-connected",this._handleItemConnected.bind(this)),this.addEventListener("qti-assessment-stimulus-ref-connected",this._handleStimulusRefConnected.bind(this))}_handleTestConnected(i){this._testElement=i.detail,this._initializeNavigation()}_handleItemConnected(i){let s=i.detail;this._loadingState.connectedItems++;let n=s.querySelectorAll("qti-assessment-stimulus-ref");this._loadingState.expectedStimulus+=n.length,this._checkLoadingComplete()}async _handleStimulusRefConnected(i){i.preventDefault();let{element:s,item:n}=i;if(console.info("Stimulus ref connected:",{identifier:s.identifier,href:s.href,item:n.identifier}),this._loadedStimulusHrefs.has(s.href)){console.info("Stimulus already loaded, skipping:",s.href),this._loadingState.loadedStimulus++,this._checkLoadingComplete();return}if(this._loadingStimulusHrefs.has(s.href)){console.info("Stimulus already loading, skipping duplicate:",s.href),this._loadingState.loadedStimulus++,this._checkLoadingComplete();return}this._loadingStimulusHrefs.add(s.href),console.info("Starting stimulus load:",s.href);try{await this._loadStimulusRef(s,n),this._loadedStimulusHrefs.add(s.href),this._loadingState.loadedStimulus++,console.info("Stimulus loaded successfully:",s.href),this._checkLoadingComplete()}catch(a){a.name!=="AbortError"&&console.warn(`Failed to load stimulus ${s.identifier}:`,a),this._loadingState.loadedStimulus++,this._checkLoadingComplete()}finally{this._loadingStimulusHrefs.delete(s.href)}}_getDefaultNavigationId(i){return i==="section"?this._testElement?.querySelector("qti-assessment-section")?.identifier:this.sessionContext?.navItemRefId??this._testElement?.querySelector("qti-assessment-item-ref")?.identifier}_initializeNavigation(){if(!this.navigate)return;let i=this._getDefaultNavigationId(this.navigate);i&&this.navigateTo(this.navigate,i)}async _handleNavigationRequest({detail:i}){if(i?.id){this._cancelPreviousNavigation();try{this._dispatchLoadingStarted(i.type,i.id),this._activeController=new AbortController,await this._executeNavigation(i.type,i.id)}catch(s){this._handleNavigationError(s,i.type,i.id)}finally{this._activeController=null,this._dispatchLoadingEnded(i.type,i.id)}}}_handleNavigationError(i,s,n){i.name!=="AbortError"&&this._dispatchError(this._createNavigationError(i,s,n))}async _executeNavigation(i,s){i==="item"?await this._navigateToItem(s):await this._navigateToSection(s)}async _navigateToItem(i){let s=this._findItemRef(i);this._updateSessionContext(s,i),this._resetLoadingState(),this._loadingState.expectedItems=1,await this._loadItems([i]),await this._waitForLoadingComplete(),this._dispatchTestLoaded(this._loadResults)}async _navigateToSection(i){let n=this._findSection(i)?.closest("qti-test-part")?.identifier;this.sessionContext={...this.sessionContext,navPartId:n,navSectionId:i,navItemRefId:null};let a=this._getSectionItemIds(i);this._resetLoadingState(),this._loadingState.expectedItems=a.length,await this._loadItems(a),await this._waitForLoadingComplete(),this._dispatchTestLoaded(this._loadResults)}_resetLoadingState(){this._loadingState={expectedItems:0,connectedItems:0,expectedStimulus:0,loadedStimulus:0,isComplete:!1},this._loadedStimulusHrefs.clear(),this._loadingStimulusHrefs.clear()}_checkLoadingComplete(){let i=this._loadingState.connectedItems>=this._loadingState.expectedItems,s=this._loadingState.loadedStimulus>=this._loadingState.expectedStimulus;i&&s&&!this._loadingState.isComplete&&(this._loadingState.isComplete=!0,console.info("Loading complete:",this._loadingState))}async _waitForLoadingComplete(){for(;!this._loadingState.isComplete;)await new Promise(i=>setTimeout(i,10))}getLoadingProgress(){return{...this._loadingState}}async _loadStimulusRef(i,s){console.info("Loading stimulus:",i.href);let n=await this._loadStimulus(i.href);console.info("Stimulus loaded, applying content:",n?"has content":"no content"),this._applyStimulusContent(n,i,s)}_applyStimulusContent(i,s,n){if(!i){console.warn("No stimulus content to apply");return}let a=i.querySelectorAll("qti-stimulus-body, qti-stylesheet");if(console.info(`Found ${a.length} stimulus elements to apply for ${s.identifier}`),a.length===0){console.warn("No qti-stimulus-body or qti-stylesheet elements found in stimulus");return}let l=[],d=document.querySelector(`qti-assessment-item[identifier="${n.identifier}"] [data-stimulus-idref="${s.identifier}"]`);if(d)l.push(d),console.info("Found specific target:",d);else{let p=Array.from(this.querySelectorAll(`[data-stimulus-idref="${s.identifier}"]`));if(p.length>0)l=p,console.info("Found targets by identifier:",p.length);else{let m=Array.from(this.querySelectorAll("[data-stimulus-idref]"));l=m,console.info("Using fallback targets:",m.length)}}if(l.length===0){console.warn("No targets found for stimulus content");return}l.forEach((p,m)=>{p.innerHTML="";let f=Array.from(a).map(b=>b.cloneNode(!0));p.append(...f),console.info(`Applied stimulus content to target ${m+1}/${l.length}`)})}_cancelPreviousNavigation(){this._activeController&&(this._activeController.abort(),console.info("Previous navigation request cancelled")),this._clearNavigationState()}_clearNavigationState(){this._clearLoadedItems(),this._resetLoadingState(),this._loadResults=[]}async _loadItems(i){if(!this._testElement||i.length===0)return;let s=i.map(l=>this._findItemRef(l));this._clearLoadedItems(),this._clearStimulusRef();let a=(await Promise.all(s.map(l=>this._loadSingleItem(l)))).filter(Boolean);a.forEach(({itemRef:l,doc:d})=>{l&&d&&(l.xmlDoc=d)}),this._loadResults=a}async _loadSingleItem(i){try{let s=await Le(this.cacheTransform).load(i.href,this._activeController?.signal);return this.postLoadTransformCallback&&(s=await this.postLoadTransformCallback(s,i)),{itemRef:i,doc:s.htmlDoc()}}catch(s){if(s.name==="AbortError")throw console.info(`Item load for ${i.identifier} was aborted`),s;return console.warn(`Failed to load item ${i.identifier}:`,s),null}}async _loadStimulus(i){return(await Le().load(i,this._activeController?.signal)).htmlDoc()}_findItemRef(i){let s=this._testElement?.querySelector(`qti-assessment-item-ref[identifier="${i}"]`);if(!s)throw new Error(`Item with identifier "${i}" not found`);return s}_findSection(i){return this._testElement?.querySelector(`qti-assessment-section[identifier="${i}"]`)||null}_updateSessionContext(i,s){let n=i.closest("qti-test-part")?.identifier,a=i.closest("qti-assessment-section")?.identifier;this.sessionContext={...this.sessionContext,navPartId:n,navSectionId:a,navItemRefId:s}}_getSectionItemIds(i){return Array.from(this._testElement.querySelectorAll(`qti-assessment-section[identifier="${i}"] > qti-assessment-item-ref`)).map(s=>s.identifier).filter(Boolean)}_clearLoadedItems(){let i=this._testElement?.querySelectorAll("qti-assessment-item-ref");Array.from(i||[]).forEach(s=>{s.xmlDoc=null})}_clearStimulusRef(){this.querySelectorAll("[data-stimulus-idref]").forEach(i=>i.innerHTML="")}_createNavigationError(i,s,n){return{message:i.message||`Failed to load ${s}: ${n}`,details:i,itemId:s==="item"?n:void 0,sectionId:s==="section"?n:void 0}}_dispatchLoadingStarted(i,s){this.dispatchEvent(new CustomEvent("qti-navigation-loading-started",{detail:{type:i,id:s},bubbles:!0,composed:!0}))}_dispatchLoadingEnded(i,s){this.dispatchEvent(new CustomEvent("qti-navigation-loading-ended",{detail:{type:i,id:s},bubbles:!0,composed:!0}))}_dispatchError(i){this.dispatchEvent(new CustomEvent("qti-navigation-error",{detail:i,bubbles:!0,composed:!0}))}_dispatchTestLoaded(i){requestAnimationFrame(()=>{this.dispatchEvent(new CustomEvent("qti-test-loaded",{detail:i.map(({itemRef:s})=>({identifier:s?.identifier,element:s})),bubbles:!0,composed:!0}))})}}return c([u({type:String})],r.prototype,"navigate",2),c([u({type:Boolean,attribute:"cache-transform"})],r.prototype,"cacheTransform",2),c([u({type:Number})],r.prototype,"requestTimeout",2),c([u({attribute:!1})],r.prototype,"postLoadTransformCallback",2),c([u({attribute:!1})],r.prototype,"postLoadTestTransformCallback",2),r};var Po=o=>{class r extends o{constructor(...t){super(...t),this.sessionContext={...this.sessionContext,view:"candidate"},this.addEventListener("on-test-switch-view",i=>{this.sessionContext={...this.sessionContext,view:i.detail},this._updateElementView()}),this.addEventListener("qti-assessment-test-connected",()=>{this._updateElementView()}),this.addEventListener("qti-assessment-item-connected",i=>{this._updateElementView(),this._setCorrectResponseVisibility(i.detail)})}willUpdate(t){super.willUpdate(t),t.has("sessionContext")&&this._updateElementView()}_updateElementView(){if(this._testElement){Array.from(this._testElement.querySelectorAll("[view]")).forEach(n=>{n.classList.toggle("show",n.getAttribute("view")===this.sessionContext.view)});let s=this._testElement.querySelector(`qti-assessment-item-ref[identifier="${this.sessionContext.navItemRefId}"]`)?.assessmentItem;s&&s.showCorrectResponse(this.sessionContext.view==="scorer")}}_setCorrectResponseVisibility(t){t.showCorrectResponse(this.sessionContext.view==="scorer")}}return r};var xs={view:"candidate"},ze=Symbol("testContext");var Et=class extends v{constructor(){super();this.testContext=Ki;this.sessionContext=xs;this._updateItemInTestContext=e=>{let t=e._context,i=t.identifier,s=t.variables,n=this.testContext.items.find(a=>a?.identifier===i);if(!n){console.warn(`Item IDs between assessment.xml and item.xml should match: ${i} is not found!`);return}if(n.variables?.length===1)this._updateItemVariablesInTestContext(i,s);else{let a=[...e.variables];for(let l of n.variables){let d=a.find(p=>p.identifier===l.identifier);d?d.value=l.value:a.push(l)}e.variables=a}};this.addEventListener("qti-assessment-test-connected",e=>{if(this.testContext=Ki,this.sessionContext=xs,this.testContext&&this.testContext.items.length>0)return;this._testElement=e.detail;let t=Array.from(this._testElement.querySelectorAll("qti-assessment-item-ref")).map(i=>({href:i.href,identifier:i.identifier,category:i.category,variables:[{identifier:"completionStatus",value:"not_attempted",type:"outcome"}]}));this.testContext={...this.testContext,items:t}}),this.addEventListener("qti-assessment-item-connected",e=>{let t=e.detail,i=t.closest("qti-assessment-item-ref")?.identifier;i&&(t.assessmentItemRefId=i),this._updateItemInTestContext(e.detail)}),this.addEventListener("qti-item-context-updated",e=>{this._updateItemVariablesInTestContext(e.detail.itemContext.identifier,e.detail.itemContext.variables)})}updateItemVariables(e,t){let i=this.testContext.items.find(n=>n.identifier===e);i&&(i.variables=i.variables.map(n=>{let a=t.find(l=>l.identifier===n.identifier);return a?{...n,...a}:n}));let s=this._testElement.querySelector(`qti-assessment-item-ref[identifier="${e}"]`);s&&s.assessmentItem&&(s.assessmentItem.variables=t)}_updateItemVariablesInTestContext(e,t){this.testContext={...this.testContext,items:this.testContext.items.map(i=>i.identifier!==e?i:{...i,variables:t.map(s=>{let n=i.variables.find(a=>a.identifier===s.identifier);return n?{...n,...s}:s})})},this.dispatchEvent(new CustomEvent("qti-test-context-updated",{detail:this.testContext,bubbles:!1,composed:!1}))}};c([u({attribute:!1,type:Object}),X({context:pe})],Et.prototype,"testContext",2),c([u({attribute:!1,type:Object}),X({context:ze})],Et.prototype,"sessionContext",2);var Vo=o=>{class r extends o{constructor(...t){super(...t),this.addEventListener("qti-register-variable",i=>{this.testContext={...this.testContext,testOutcomeVariables:[...this.testContext.testOutcomeVariables||[],i.detail.variable]},i.stopPropagation()}),this.addEventListener("qti-set-outcome-value",i=>{let{outcomeIdentifier:s,value:n}=i.detail;this.updateOutcomeVariable(s,n),i.stopPropagation()})}outcomeProcessing(){let t=this.querySelector("qti-outcome-processing");return t?(t?.process(),!0):!1}updateOutcomeVariable(t,i){let s=this.getOutcome(t);if(!s){console.warn(`Can not set qti-outcome-identifier: ${t}, it is not available`);return}this.testContext={...this.testContext,testOutcomeVariables:this.testContext.testOutcomeVariables?.map(n=>n.identifier!==t?n:{...n,value:s.cardinality==="single"?i:[...n.value,i]})}}getOutcome(t){return this.getVariable(t)}getVariable(t){return this.testContext.testOutcomeVariables?.find(i=>i.identifier===t)||null}}return r};var ai=class extends $o(Po(Vo(Et))){async connectedCallback(){super.connectedCallback(),await this.updateComplete,this.dispatchEvent(new CustomEvent("qti-test-connected",{detail:this}))}render(){return h`<slot></slot>`}};ai=c([g("qti-test")],ai);var Oo={fromAttribute(o){return o==="true"},toAttribute(o){return o?"true":"false"}},_e=class extends v{constructor(){super(...arguments);this.weigths=new Map}createRenderRoot(){return this}get assessmentItem(){return this.renderRoot?.querySelector("qti-assessment-item")}async connectedCallback(){super.connectedCallback(),await this.updateComplete,this.dispatchEvent(new CustomEvent("qti-assessment-item-ref-connected",{bubbles:!0,composed:!0,detail:{identifier:this.identifier,href:this.href,category:this.category}}))}render(){return this.myTemplate?this.myTemplate({xmlDoc:this.xmlDoc}):this.xmlDoc}};c([u({type:String})],_e.prototype,"category",2),c([u({type:String})],_e.prototype,"identifier",2),c([u({type:Boolean,converter:Oo})],_e.prototype,"required",2),c([u({type:Boolean,converter:Oo})],_e.prototype,"fixed",2),c([u({type:String})],_e.prototype,"href",2),c([u({type:Object,attribute:!1})],_e.prototype,"xmlDoc",2);customElements.get("qti-assessment-item-ref")||customElements.define("qti-assessment-item-ref",_e);var qs={fromAttribute(o){return o==="true"},toAttribute(o){return o?"true":"false"}},Te=class extends v{constructor(){super(...arguments);this._title=""}get title(){return this._title}set title(e){this._title=e,this.removeAttribute("title"),this.setAttribute("data-title",e)}async connectedCallback(){this._title=this.getAttribute("title")||"",super.connectedCallback(),await this.updateComplete,this.dispatchEvent(new Event("qti-assessment-section-connected",{bubbles:!0,composed:!0}))}render(){return h`<slot name="qti-rubric-block"></slot><slot></slot>`}};c([u({type:String})],Te.prototype,"identifier",2),c([u({type:String})],Te.prototype,"required",2),c([u({type:Boolean,converter:qs})],Te.prototype,"fixed",2),c([u({type:Boolean,converter:qs})],Te.prototype,"visible",2),c([u({type:Boolean,converter:qs,attribute:"keep-together"})],Te.prototype,"keepTogether",2),c([_({context:pe,subscribe:!0})],Te.prototype,"_testContext",2);customElements.get("qti-assessment-section")||customElements.define("qti-assessment-section",Te);var et=class extends v{constructor(){super(...arguments);this._title=""}get title(){return this._title}set title(e){this._title=e,this.removeAttribute("title"),this.setAttribute("data-title",e)}async connectedCallback(){super.connectedCallback(),await this.updateComplete,this.dispatchEvent(new CustomEvent("qti-assessment-test-connected",{detail:this,bubbles:!0,composed:!0}))}render(){return h` <slot></slot>`}};c([u({type:String})],et.prototype,"identifier",2),c([u({type:String})],et.prototype,"title",1),c([_({context:pe,subscribe:!0})],et.prototype,"_testContext",2),et=c([g("qti-assessment-test")],et);var Ae=class extends v{constructor(){super(...arguments);this.identifier="";this.class="";this.navigationMode="nonlinear";this.submissionMode="individual";this._title=""}get title(){return this._title}set title(e){this._title=e,this.removeAttribute("title"),this.setAttribute("data-title",e)}async connectedCallback(){super.connectedCallback(),await this.updateComplete,this.dispatchEvent(new Event("qti-test-part-connected",{bubbles:!0,composed:!0}))}render(){return h` <slot></slot>`}};c([u({type:String})],Ae.prototype,"identifier",2),c([u({type:String})],Ae.prototype,"class",2),c([u({type:String,attribute:"navigation-mode"})],Ae.prototype,"navigationMode",2),c([u({type:String,attribute:"submission-mode"})],Ae.prototype,"submissionMode",2),Ae=c([g("qti-test-part")],Ae);customElements.get("qti-test-part")||customElements.define("qti-test-part",Ae);var vr=class extends Ze{render(){return h``}};vr.styles=x`
1496
+ `],c([u({type:String,attribute:"base-type"})],we.prototype,"baseType",2),c([u({type:String})],we.prototype,"identifier",2),c([u({type:String})],we.prototype,"cardinality",2),c([_({context:$,subscribe:!0}),E()],we.prototype,"itemContext",2),we=c([g("qti-response-declaration")],we);var $o=o=>{class r extends o{constructor(...i){super(...i);this.navigate=null;this.cacheTransform=!1;this.requestTimeout=3e4;this.postLoadTransformCallback=null;this.postLoadTestTransformCallback=null;this._activeController=null;this._loadResults=[];this._loadingState={expectedItems:0,connectedItems:0,expectedStimulus:0,loadedStimulus:0,isComplete:!1};this._loadedStimulusHrefs=new Set;this._loadingStimulusHrefs=new Set;this._bindEventHandlers()}navigateTo(i,s){let n=s||this._getDefaultNavigationId(i);n&&this.dispatchEvent(new CustomEvent("qti-request-navigation",{detail:{type:i,id:n},bubbles:!0,composed:!0}))}_bindEventHandlers(){this.addEventListener("qti-request-navigation",this._handleNavigationRequest.bind(this)),this.addEventListener("qti-assessment-test-connected",this._handleTestConnected.bind(this)),this.addEventListener("qti-assessment-item-connected",this._handleItemConnected.bind(this)),this.addEventListener("qti-assessment-stimulus-ref-connected",this._handleStimulusRefConnected.bind(this))}_handleTestConnected(i){this._testElement=i.detail,this._initializeNavigation()}_handleItemConnected(i){let s=i.detail;this._loadingState.connectedItems++;let n=s.querySelectorAll("qti-assessment-stimulus-ref");this._loadingState.expectedStimulus+=n.length,this._checkLoadingComplete()}async _handleStimulusRefConnected(i){i.preventDefault();let{element:s,item:n}=i;if(console.info("Stimulus ref connected:",{identifier:s.identifier,href:s.href,item:n.identifier}),this._loadedStimulusHrefs.has(s.href)){console.info("Stimulus already loaded, skipping:",s.href),this._loadingState.loadedStimulus++,this._checkLoadingComplete();return}if(this._loadingStimulusHrefs.has(s.href)){console.info("Stimulus already loading, skipping duplicate:",s.href),this._loadingState.loadedStimulus++,this._checkLoadingComplete();return}this._loadingStimulusHrefs.add(s.href),console.info("Starting stimulus load:",s.href);try{await this._loadStimulusRef(s,n),this._loadedStimulusHrefs.add(s.href),this._loadingState.loadedStimulus++,console.info("Stimulus loaded successfully:",s.href),this._checkLoadingComplete()}catch(a){a.name!=="AbortError"&&console.warn(`Failed to load stimulus ${s.identifier}:`,a),this._loadingState.loadedStimulus++,this._checkLoadingComplete()}finally{this._loadingStimulusHrefs.delete(s.href)}}_getDefaultNavigationId(i){return i==="section"?this._testElement?.querySelector("qti-assessment-section")?.identifier:this.sessionContext?.navItemRefId??this._testElement?.querySelector("qti-assessment-item-ref")?.identifier}_initializeNavigation(){if(!this.navigate)return;let i=this._getDefaultNavigationId(this.navigate);i&&this.navigateTo(this.navigate,i)}async _handleNavigationRequest({detail:i}){if(i?.id){this._cancelPreviousNavigation();try{this._dispatchLoadingStarted(i.type,i.id),this._activeController=new AbortController,await this._executeNavigation(i.type,i.id)}catch(s){this._handleNavigationError(s,i.type,i.id)}finally{this._activeController=null,this._dispatchLoadingEnded(i.type,i.id)}}}_handleNavigationError(i,s,n){i.name!=="AbortError"&&this._dispatchError(this._createNavigationError(i,s,n))}async _executeNavigation(i,s){i==="item"?await this._navigateToItem(s):await this._navigateToSection(s)}async _navigateToItem(i){let s=this._findItemRef(i);this._updateSessionContext(s,i),this._resetLoadingState(),this._loadingState.expectedItems=1,await this._loadItems([i]),await this._waitForLoadingComplete(),this._dispatchTestLoaded(this._loadResults)}async _navigateToSection(i){let n=this._findSection(i)?.closest("qti-test-part")?.identifier;this.sessionContext={...this.sessionContext,navPartId:n,navSectionId:i,navItemRefId:null};let a=this._getSectionItemIds(i);this._resetLoadingState(),this._loadingState.expectedItems=a.length,await this._loadItems(a),await this._waitForLoadingComplete(),this._dispatchTestLoaded(this._loadResults)}_resetLoadingState(){this._loadingState={expectedItems:0,connectedItems:0,expectedStimulus:0,loadedStimulus:0,isComplete:!1},this._loadedStimulusHrefs.clear(),this._loadingStimulusHrefs.clear()}_checkLoadingComplete(){let i=this._loadingState.connectedItems>=this._loadingState.expectedItems,s=this._loadingState.loadedStimulus>=this._loadingState.expectedStimulus;i&&s&&!this._loadingState.isComplete&&(this._loadingState.isComplete=!0)}async _waitForLoadingComplete(){for(;!this._loadingState.isComplete;)await new Promise(i=>setTimeout(i,10))}getLoadingProgress(){return{...this._loadingState}}async _loadStimulusRef(i,s){console.info("Loading stimulus:",i.href);let n=await this._loadStimulus(i.href);console.info("Stimulus loaded, applying content:",n?"has content":"no content"),this._applyStimulusContent(n,i,s)}_applyStimulusContent(i,s,n){if(!i){console.warn("No stimulus content to apply");return}let a=i.querySelectorAll("qti-stimulus-body, qti-stylesheet");if(console.info(`Found ${a.length} stimulus elements to apply for ${s.identifier}`),a.length===0){console.warn("No qti-stimulus-body or qti-stylesheet elements found in stimulus");return}let l=[],d=document.querySelector(`qti-assessment-item[identifier="${n.identifier}"] [data-stimulus-idref="${s.identifier}"]`);if(d)l.push(d),console.info("Found specific target:",d);else{let p=Array.from(this.querySelectorAll(`[data-stimulus-idref="${s.identifier}"]`));if(p.length>0)l=p,console.info("Found targets by identifier:",p.length);else{let m=Array.from(this.querySelectorAll("[data-stimulus-idref]"));l=m,console.info("Using fallback targets:",m.length)}}if(l.length===0){console.warn("No targets found for stimulus content");return}l.forEach((p,m)=>{p.innerHTML="";let f=Array.from(a).map(b=>b.cloneNode(!0));p.append(...f),console.info(`Applied stimulus content to target ${m+1}/${l.length}`)})}_cancelPreviousNavigation(){this._activeController&&(this._activeController.abort(),console.info("Previous navigation request cancelled")),this._clearNavigationState()}_clearNavigationState(){this._clearLoadedItems(),this._resetLoadingState(),this._loadResults=[]}async _loadItems(i){if(!this._testElement||i.length===0)return;let s=i.map(l=>this._findItemRef(l));this._clearLoadedItems(),this._clearStimulusRef();let a=(await Promise.all(s.map(l=>this._loadSingleItem(l)))).filter(Boolean);a.forEach(({itemRef:l,doc:d})=>{l&&d&&(l.xmlDoc=d)}),this._loadResults=a}async _loadSingleItem(i){try{let s=await Le(this.cacheTransform).load(i.href,this._activeController?.signal);return this.postLoadTransformCallback&&(s=await this.postLoadTransformCallback(s,i)),{itemRef:i,doc:s.htmlDoc()}}catch(s){if(s.name==="AbortError")throw console.info(`Item load for ${i.identifier} was aborted`),s;return console.warn(`Failed to load item ${i.identifier}:`,s),null}}async _loadStimulus(i){return(await Le().load(i,this._activeController?.signal)).htmlDoc()}_findItemRef(i){let s=this._testElement?.querySelector(`qti-assessment-item-ref[identifier="${i}"]`);if(!s)throw new Error(`Item with identifier "${i}" not found`);return s}_findSection(i){return this._testElement?.querySelector(`qti-assessment-section[identifier="${i}"]`)||null}_updateSessionContext(i,s){let n=i.closest("qti-test-part")?.identifier,a=i.closest("qti-assessment-section")?.identifier;this.sessionContext={...this.sessionContext,navPartId:n,navSectionId:a,navItemRefId:s}}_getSectionItemIds(i){return Array.from(this._testElement.querySelectorAll(`qti-assessment-section[identifier="${i}"] > qti-assessment-item-ref`)).map(s=>s.identifier).filter(Boolean)}_clearLoadedItems(){let i=this._testElement?.querySelectorAll("qti-assessment-item-ref");Array.from(i||[]).forEach(s=>{s.xmlDoc=null})}_clearStimulusRef(){this.querySelectorAll("[data-stimulus-idref]").forEach(i=>i.innerHTML="")}_createNavigationError(i,s,n){return{message:i.message||`Failed to load ${s}: ${n}`,details:i,itemId:s==="item"?n:void 0,sectionId:s==="section"?n:void 0}}_dispatchLoadingStarted(i,s){this.dispatchEvent(new CustomEvent("qti-navigation-loading-started",{detail:{type:i,id:s},bubbles:!0,composed:!0}))}_dispatchLoadingEnded(i,s){this.dispatchEvent(new CustomEvent("qti-navigation-loading-ended",{detail:{type:i,id:s},bubbles:!0,composed:!0}))}_dispatchError(i){this.dispatchEvent(new CustomEvent("qti-navigation-error",{detail:i,bubbles:!0,composed:!0}))}_dispatchTestLoaded(i){requestAnimationFrame(()=>{this.dispatchEvent(new CustomEvent("qti-test-loaded",{detail:i.map(({itemRef:s})=>({identifier:s?.identifier,element:s})),bubbles:!0,composed:!0}))})}}return c([u({type:String})],r.prototype,"navigate",2),c([u({type:Boolean,attribute:"cache-transform"})],r.prototype,"cacheTransform",2),c([u({type:Number})],r.prototype,"requestTimeout",2),c([u({attribute:!1})],r.prototype,"postLoadTransformCallback",2),c([u({attribute:!1})],r.prototype,"postLoadTestTransformCallback",2),r};var Po=o=>{class r extends o{constructor(...t){super(...t),this.sessionContext={...this.sessionContext,view:"candidate"},this.addEventListener("on-test-switch-view",i=>{this.sessionContext={...this.sessionContext,view:i.detail},this._updateElementView()}),this.addEventListener("qti-assessment-test-connected",()=>{this._updateElementView()}),this.addEventListener("qti-assessment-item-connected",i=>{this._updateElementView(),this._setCorrectResponseVisibility(i.detail)})}willUpdate(t){super.willUpdate(t),t.has("sessionContext")&&this._updateElementView()}_updateElementView(){if(this._testElement){Array.from(this._testElement.querySelectorAll("[view]")).forEach(n=>{n.classList.toggle("show",n.getAttribute("view")===this.sessionContext.view)});let s=this._testElement.querySelector(`qti-assessment-item-ref[identifier="${this.sessionContext.navItemRefId}"]`)?.assessmentItem;s&&s.showCorrectResponse(this.sessionContext.view==="scorer")}}_setCorrectResponseVisibility(t){t.showCorrectResponse(this.sessionContext.view==="scorer")}}return r};var xs={view:"candidate"},ze=Symbol("testContext");var Et=class extends v{constructor(){super();this.testContext=Ki;this.sessionContext=xs;this._updateItemInTestContext=e=>{let t=e._context,i=t.identifier,s=t.variables,n=this.testContext.items.find(a=>a?.identifier===i);if(!n){console.warn(`Item IDs between assessment.xml and item.xml should match: ${i} is not found!`);return}if(n.variables?.length===1)this._updateItemVariablesInTestContext(i,s);else{let a=[...e.variables];for(let l of n.variables){let d=a.find(p=>p.identifier===l.identifier);d?d.value=l.value:a.push(l)}e.variables=a}};this.addEventListener("qti-assessment-test-connected",e=>{if(this.testContext=Ki,this.sessionContext=xs,this.testContext&&this.testContext.items.length>0)return;this._testElement=e.detail;let t=Array.from(this._testElement.querySelectorAll("qti-assessment-item-ref")).map(i=>({href:i.href,identifier:i.identifier,category:i.category,variables:[{identifier:"completionStatus",value:"not_attempted",type:"outcome"}]}));this.testContext={...this.testContext,items:t}}),this.addEventListener("qti-assessment-item-connected",e=>{let t=e.detail,i=t.closest("qti-assessment-item-ref")?.identifier;i&&(t.assessmentItemRefId=i),this._updateItemInTestContext(e.detail)}),this.addEventListener("qti-item-context-updated",e=>{this._updateItemVariablesInTestContext(e.detail.itemContext.identifier,e.detail.itemContext.variables)})}updateItemVariables(e,t){let i=this.testContext.items.find(n=>n.identifier===e);i&&(i.variables=i.variables.map(n=>{let a=t.find(l=>l.identifier===n.identifier);return a?{...n,...a}:n}));let s=this._testElement.querySelector(`qti-assessment-item-ref[identifier="${e}"]`);s&&s.assessmentItem&&(s.assessmentItem.variables=t)}_updateItemVariablesInTestContext(e,t){this.testContext={...this.testContext,items:this.testContext.items.map(i=>i.identifier!==e?i:{...i,variables:t.map(s=>{let n=i.variables.find(a=>a.identifier===s.identifier);return n?{...n,...s}:s})})},this.dispatchEvent(new CustomEvent("qti-test-context-updated",{detail:this.testContext,bubbles:!1,composed:!1}))}};c([u({attribute:!1,type:Object}),G({context:pe})],Et.prototype,"testContext",2),c([u({attribute:!1,type:Object}),G({context:ze})],Et.prototype,"sessionContext",2);var Vo=o=>{class r extends o{constructor(...t){super(...t),this.addEventListener("qti-register-variable",i=>{this.testContext={...this.testContext,testOutcomeVariables:[...this.testContext.testOutcomeVariables||[],i.detail.variable]},i.stopPropagation()}),this.addEventListener("qti-set-outcome-value",i=>{let{outcomeIdentifier:s,value:n}=i.detail;this.updateOutcomeVariable(s,n),i.stopPropagation()})}outcomeProcessing(){let t=this.querySelector("qti-outcome-processing");return t?(t?.process(),!0):!1}updateOutcomeVariable(t,i){let s=this.getOutcome(t);if(!s){console.warn(`Can not set qti-outcome-identifier: ${t}, it is not available`);return}this.testContext={...this.testContext,testOutcomeVariables:this.testContext.testOutcomeVariables?.map(n=>n.identifier!==t?n:{...n,value:s.cardinality==="single"?i:[...n.value,i]})}}getOutcome(t){return this.getVariable(t)}getVariable(t){return this.testContext.testOutcomeVariables?.find(i=>i.identifier===t)||null}}return r};var ai=class extends $o(Po(Vo(Et))){async connectedCallback(){super.connectedCallback(),await this.updateComplete,this.dispatchEvent(new CustomEvent("qti-test-connected",{detail:this}))}render(){return h`<slot></slot>`}};ai=c([g("qti-test")],ai);var Oo={fromAttribute(o){return o==="true"},toAttribute(o){return o?"true":"false"}},_e=class extends v{constructor(){super(...arguments);this.weigths=new Map}createRenderRoot(){return this}get assessmentItem(){return this.renderRoot?.querySelector("qti-assessment-item")}async connectedCallback(){super.connectedCallback(),await this.updateComplete,this.dispatchEvent(new CustomEvent("qti-assessment-item-ref-connected",{bubbles:!0,composed:!0,detail:{identifier:this.identifier,href:this.href,category:this.category}}))}render(){return this.myTemplate?this.myTemplate({xmlDoc:this.xmlDoc}):this.xmlDoc}};c([u({type:String})],_e.prototype,"category",2),c([u({type:String})],_e.prototype,"identifier",2),c([u({type:Boolean,converter:Oo})],_e.prototype,"required",2),c([u({type:Boolean,converter:Oo})],_e.prototype,"fixed",2),c([u({type:String})],_e.prototype,"href",2),c([u({type:Object,attribute:!1})],_e.prototype,"xmlDoc",2);customElements.get("qti-assessment-item-ref")||customElements.define("qti-assessment-item-ref",_e);var qs={fromAttribute(o){return o==="true"},toAttribute(o){return o?"true":"false"}},Te=class extends v{constructor(){super(...arguments);this._title=""}get title(){return this._title}set title(e){this._title=e,this.removeAttribute("title"),this.setAttribute("data-title",e)}async connectedCallback(){this._title=this.getAttribute("title")||"",super.connectedCallback(),await this.updateComplete,this.dispatchEvent(new Event("qti-assessment-section-connected",{bubbles:!0,composed:!0}))}render(){return h`<slot name="qti-rubric-block"></slot><slot></slot>`}};c([u({type:String})],Te.prototype,"identifier",2),c([u({type:String})],Te.prototype,"required",2),c([u({type:Boolean,converter:qs})],Te.prototype,"fixed",2),c([u({type:Boolean,converter:qs})],Te.prototype,"visible",2),c([u({type:Boolean,converter:qs,attribute:"keep-together"})],Te.prototype,"keepTogether",2),c([_({context:pe,subscribe:!0})],Te.prototype,"_testContext",2);customElements.get("qti-assessment-section")||customElements.define("qti-assessment-section",Te);var et=class extends v{constructor(){super(...arguments);this._title=""}get title(){return this._title}set title(e){this._title=e,this.removeAttribute("title"),this.setAttribute("data-title",e)}async connectedCallback(){super.connectedCallback(),await this.updateComplete,this.dispatchEvent(new CustomEvent("qti-assessment-test-connected",{detail:this,bubbles:!0,composed:!0}))}render(){return h` <slot></slot>`}};c([u({type:String})],et.prototype,"identifier",2),c([u({type:String})],et.prototype,"title",1),c([_({context:pe,subscribe:!0})],et.prototype,"_testContext",2),et=c([g("qti-assessment-test")],et);var Ae=class extends v{constructor(){super(...arguments);this.identifier="";this.class="";this.navigationMode="nonlinear";this.submissionMode="individual";this._title=""}get title(){return this._title}set title(e){this._title=e,this.removeAttribute("title"),this.setAttribute("data-title",e)}async connectedCallback(){super.connectedCallback(),await this.updateComplete,this.dispatchEvent(new Event("qti-test-part-connected",{bubbles:!0,composed:!0}))}render(){return h` <slot></slot>`}};c([u({type:String})],Ae.prototype,"identifier",2),c([u({type:String})],Ae.prototype,"class",2),c([u({type:String,attribute:"navigation-mode"})],Ae.prototype,"navigationMode",2),c([u({type:String,attribute:"submission-mode"})],Ae.prototype,"submissionMode",2),Ae=c([g("qti-test-part")],Ae);customElements.get("qti-test-part")||customElements.define("qti-test-part",Ae);var vr=class extends Ze{render(){return h``}};vr.styles=x`
1497
1497
  :host {
1498
1498
  color: gray;
1499
1499
  }
1500
- `,vr=c([g("qti-test-feedback")],vr);var P=Symbol("computedContext");var Z=class extends v{constructor(){super();this.identifier=void 0;this.initContext=[];this.qtiContext={QTI_CONTEXT:{testIdentifier:"",candidateIdentifier:"",environmentIdentifier:"default"}};this.configContext={};this.autoScoreItems=!1;this.addEventListener("qti-assessment-test-connected",this._handleTestConnected.bind(this)),this.addEventListener("qti-assessment-item-connected",this._handleItemConnected.bind(this)),this.addEventListener("qti-interaction-changed",this._handleInteractionChanged.bind(this)),this.addEventListener("test-end-attempt",this._handleTestEndAttempt.bind(this)),this.addEventListener("test-show-correct-response",this._handleTestShowCorrectResponse.bind(this)),this.addEventListener("test-show-candidate-correction",this._handleTestShowCandidateCorrection.bind(this)),this.addEventListener("test-update-outcome-variable",this._handleTestUpdateOutcomeVariable.bind(this))}_handleTestEndAttempt(e){let i=this._testElement.querySelector(`qti-assessment-item-ref[identifier="${this._sessionContext.navItemRefId}"]`).assessmentItem,s=this.configContext?.reportValidityAfterScoring===!0;i.processResponse(!0,s)}_handleTestShowCorrectResponse(e){let i=this._testElement.querySelector(`qti-assessment-item-ref[identifier="${this._sessionContext.navItemRefId}"]`).assessmentItem;i&&i.showCorrectResponse(e.detail)}_handleTestShowCandidateCorrection(e){this._testElement.querySelector(`qti-assessment-item-ref[identifier="${this._sessionContext.navItemRefId}"]`).assessmentItem.showCandidateCorrection(e.detail)}_handleTestUpdateOutcomeVariable(e){this._testElement.querySelector(`qti-assessment-item-ref[identifier="${e.detail.assessmentItemRefId}"]`).assessmentItem.setOutcomeVariable(e.detail.outcomeVariableId,e.detail.value)}_handleInteractionChanged(e){if(this.autoScoreItems){let t=e.composedPath()[0].closest("qti-assessment-item"),i=t.variables.find(s=>s.identifier==="SCORE");if(i&&i.externalScored===null&&t.adaptive==="false"){let s=this.configContext?.reportValidityAfterScoring===!0;t.processResponse(!0,s)}}}render(){return h`<slot></slot>`}_handleTestConnected(e){if(this._testElement=e.detail,!this.qtiContext.QTI_CONTEXT?.testIdentifier){let s=this.qtiContext.QTI_CONTEXT||{testIdentifier:"",candidateIdentifier:"not set",environmentIdentifier:"default"};this.qtiContext={QTI_CONTEXT:{...s,testIdentifier:this._testElement.identifier,environmentIdentifier:s.environmentIdentifier||"default"}}}this._testElement.querySelectorAll('qti-context-declaration[identifier="QTI_CONTEXT"]').forEach(s=>{let n=this._extractDefaultValues(s);Object.keys(n).length>0&&(this.qtiContext={QTI_CONTEXT:{...n,...this.qtiContext.QTI_CONTEXT}})});let i=Array.from(this._testElement?.querySelectorAll("qti-test-part")||[]);this.computedContext={identifier:this._testElement.identifier,title:this._testElement.title,view:this._sessionContext?.view,testParts:i.map(s=>{let n=[...s.querySelectorAll("qti-assessment-section")];return{active:!1,identifier:s.identifier,navigationMode:s.navigationMode,submissionMode:s.submissionMode,sections:n.map(a=>{let l=[...a.querySelectorAll("qti-assessment-item-ref")];return{active:!1,identifier:a.identifier,title:a.title,items:l.map(d=>({...this.initContext?.find(p=>p.identifier===d.identifier),active:!1,identifier:d.identifier,categories:d.category?d.category?.split(" "):[],href:d.href,variables:[]}))}})}})}}_extractDefaultValues(e){let t={},i=e.querySelector("qti-default-value");return i&&i.querySelectorAll("qti-value[field-identifier]").forEach(n=>{let a=n.getAttribute("field-identifier"),l=n.getAttribute("base-type")||"string",d=n.textContent?.trim()||"";if(a){let p=d;switch(l){case"integer":p=parseInt(d,10);break;case"float":case"duration":p=parseFloat(d);break;case"boolean":p=d.toLowerCase()==="true";break;case"string":default:p=d;break}t[a]=p}}),t}_handleItemConnected(e){let t=e.detail;this.computedContext={...this.computedContext,testParts:this.computedContext.testParts.map(i=>({...i,sections:i.sections.map(s=>({...s,items:s.items.map(n=>{if(n.identifier!==t.parentElement.getAttribute("identifier"))return n;let l=t.querySelector("qti-outcome-declaration[identifier='SCORE']")?.getAttribute("externalScored"),d=t.querySelectorAll("qti-response-declaration"),p=Array.from(d).some(y=>y.querySelector("qti-correct-response")),m=Array.from(d).some(y=>{let E=y.querySelector("qti-mapping"),S=y.querySelector("qti-area-mapping");return E?.querySelector("qti-map-entry")||S?.querySelector("qti-area-map-entry")}),f=p||m,b=!!t.querySelector("qti-response-processing");return{...n,assessmentItemIdentifier:t.getAttribute("identifier"),label:t.getAttribute("label"),title:t.title,externalScored:l,adaptive:t.adaptive=="true"||!1,timeDependent:t.timeDependent=="true"||!1,variables:t.variables,hasCorrectResponse:f,hasResponseProcessing:b}})}))}))}}willUpdate(e){if(!this.computedContext)return;let t=1;this.computedContext={...this.computedContext,view:this._sessionContext?.view,testParts:this.computedContext.testParts.map(i=>({...i,active:this._sessionContext?.navPartId===i.identifier||!1,sections:i.sections.map(s=>({...s,active:this._sessionContext?.navSectionId===s.identifier||!1,completed:s.items.every(n=>this._testContext.items.find(a=>a.identifier===n.identifier)?.variables.find(a=>a.identifier==="completionStatus").value==="completed"),items:s.items.map(n=>{let a=this._testContext?.items.find(T=>T.identifier===n.identifier),l={...n,...a,...this.initContext?.find(T=>T.identifier===n.identifier)},d=l.variables?.find(T=>T.identifier=="SCORE")?.value,p=d==null?null:parseFloat(d?.toString()),m=l.variables?.find(T=>T.identifier==="completionStatus")?.value,f=l.variables?.find(T=>T.identifier==="RESPONSE")?.value||"",b=l.variables?.find(T=>T.identifier==="numAttempts")?.value||0,y=this._sessionContext?.navItemRefId===l.identifier||!1,E=n.categories.includes(this.configContext?.infoItemCategory)?null:t++,S=n.variables?.find(T=>T.identifier=="MAXSCORE")?.value,q=S==null?null:parseFloat(S?.toString());return{...l,completionStatus:m,numAttempts:b,score:p,response:f,index:E,active:y,maxScore:q}})}))}))},this.dispatchEvent(new CustomEvent("qti-computed-context-updated",{detail:this.computedContext,bubbles:!0}))}};c([u({type:String})],Z.prototype,"identifier",2),c([C()],Z.prototype,"initContext",2),c([C(),X({context:Yr})],Z.prototype,"qtiContext",2),c([C(),X({context:oe})],Z.prototype,"configContext",2),c([C(),_({context:pe,subscribe:!0})],Z.prototype,"_testContext",2),c([C(),_({context:ze,subscribe:!0})],Z.prototype,"_sessionContext",2),c([C(),X({context:P})],Z.prototype,"computedContext",2),c([u({type:Boolean,attribute:"auto-score-items"})],Z.prototype,"autoScoreItems",2),Z=c([g("test-navigation")],Z);var No=x`
1500
+ `,vr=c([g("qti-test-feedback")],vr);var P=Symbol("computedContext");var Z=class extends v{constructor(){super();this.identifier=void 0;this.initContext=[];this.qtiContext={QTI_CONTEXT:{testIdentifier:"",candidateIdentifier:"",environmentIdentifier:"default"}};this.configContext={};this.autoScoreItems=!1;this.addEventListener("qti-assessment-test-connected",this._handleTestConnected.bind(this)),this.addEventListener("qti-assessment-item-connected",this._handleItemConnected.bind(this)),this.addEventListener("qti-interaction-changed",this._handleInteractionChanged.bind(this)),this.addEventListener("test-end-attempt",this._handleTestEndAttempt.bind(this)),this.addEventListener("test-show-correct-response",this._handleTestShowCorrectResponse.bind(this)),this.addEventListener("test-show-candidate-correction",this._handleTestShowCandidateCorrection.bind(this)),this.addEventListener("test-update-outcome-variable",this._handleTestUpdateOutcomeVariable.bind(this))}_handleTestEndAttempt(e){let i=this._testElement.querySelector(`qti-assessment-item-ref[identifier="${this._sessionContext.navItemRefId}"]`).assessmentItem,s=this.configContext?.reportValidityAfterScoring===!0;i.processResponse(!0,s)}_handleTestShowCorrectResponse(e){let i=this._testElement.querySelector(`qti-assessment-item-ref[identifier="${this._sessionContext.navItemRefId}"]`).assessmentItem;i&&i.showCorrectResponse(e.detail)}_handleTestShowCandidateCorrection(e){this._testElement.querySelector(`qti-assessment-item-ref[identifier="${this._sessionContext.navItemRefId}"]`).assessmentItem.showCandidateCorrection(e.detail)}_handleTestUpdateOutcomeVariable(e){this._testElement.querySelector(`qti-assessment-item-ref[identifier="${e.detail.assessmentItemRefId}"]`).assessmentItem.setOutcomeVariable(e.detail.outcomeVariableId,e.detail.value)}_handleInteractionChanged(e){if(this.autoScoreItems){let t=e.composedPath()[0].closest("qti-assessment-item"),i=t.variables.find(s=>s.identifier==="SCORE");if(i&&i.externalScored===null&&t.adaptive==="false"){let s=this.configContext?.reportValidityAfterScoring===!0;t.processResponse(!0,s)}}}render(){return h`<slot></slot>`}_handleTestConnected(e){if(this._testElement=e.detail,!this.qtiContext.QTI_CONTEXT?.testIdentifier){let s=this.qtiContext.QTI_CONTEXT||{testIdentifier:"",candidateIdentifier:"not set",environmentIdentifier:"default"};this.qtiContext={QTI_CONTEXT:{...s,testIdentifier:this._testElement.identifier,environmentIdentifier:s.environmentIdentifier||"default"}}}this._testElement.querySelectorAll('qti-context-declaration[identifier="QTI_CONTEXT"]').forEach(s=>{let n=this._extractDefaultValues(s);Object.keys(n).length>0&&(this.qtiContext={QTI_CONTEXT:{...n,...this.qtiContext.QTI_CONTEXT}})});let i=Array.from(this._testElement?.querySelectorAll("qti-test-part")||[]);this.computedContext={identifier:this._testElement.identifier,title:this._testElement.title,view:this._sessionContext?.view,testParts:i.map(s=>{let n=[...s.querySelectorAll("qti-assessment-section")];return{active:!1,identifier:s.identifier,navigationMode:s.navigationMode,submissionMode:s.submissionMode,sections:n.map(a=>{let l=[...a.querySelectorAll("qti-assessment-item-ref")];return{active:!1,identifier:a.identifier,title:a.title,items:l.map(d=>({...this.initContext?.find(p=>p.identifier===d.identifier),active:!1,identifier:d.identifier,categories:d.category?d.category?.split(" "):[],href:d.href,variables:[]}))}})}})}}_extractDefaultValues(e){let t={},i=e.querySelector("qti-default-value");return i&&i.querySelectorAll("qti-value[field-identifier]").forEach(n=>{let a=n.getAttribute("field-identifier"),l=n.getAttribute("base-type")||"string",d=n.textContent?.trim()||"";if(a){let p=d;switch(l){case"integer":p=parseInt(d,10);break;case"float":case"duration":p=parseFloat(d);break;case"boolean":p=d.toLowerCase()==="true";break;case"string":default:p=d;break}t[a]=p}}),t}_handleItemConnected(e){let t=e.detail;this.computedContext={...this.computedContext,testParts:this.computedContext.testParts.map(i=>({...i,sections:i.sections.map(s=>({...s,items:s.items.map(n=>{if(n.identifier!==t.parentElement.getAttribute("identifier"))return n;let l=t.querySelector("qti-outcome-declaration[identifier='SCORE']")?.getAttribute("externalScored"),d=t.querySelectorAll("qti-response-declaration"),p=Array.from(d).some(y=>y.querySelector("qti-correct-response")),m=Array.from(d).some(y=>{let C=y.querySelector("qti-mapping"),A=y.querySelector("qti-area-mapping");return C?.querySelector("qti-map-entry")||A?.querySelector("qti-area-map-entry")}),f=p||m,b=!!t.querySelector("qti-response-processing");return{...n,assessmentItemIdentifier:t.getAttribute("identifier"),label:t.getAttribute("label"),title:t.title,externalScored:l,adaptive:t.adaptive=="true"||!1,timeDependent:t.timeDependent=="true"||!1,variables:t.variables,hasCorrectResponse:f,hasResponseProcessing:b}})}))}))}}willUpdate(e){if(!this.computedContext)return;let t=1;this.computedContext={...this.computedContext,view:this._sessionContext?.view,testParts:this.computedContext.testParts.map(i=>({...i,active:this._sessionContext?.navPartId===i.identifier||!1,sections:i.sections.map(s=>({...s,active:this._sessionContext?.navSectionId===s.identifier||!1,completed:s.items.every(n=>this._testContext.items.find(a=>a.identifier===n.identifier)?.variables.find(a=>a.identifier==="completionStatus").value==="completed"),items:s.items.map(n=>{let a=this._testContext?.items.find(T=>T.identifier===n.identifier),l={...n,...a,...this.initContext?.find(T=>T.identifier===n.identifier)},d=l.variables?.find(T=>T.identifier=="SCORE")?.value,p=d==null?null:parseFloat(d?.toString()),m=l.variables?.find(T=>T.identifier==="completionStatus")?.value,f=l.variables?.find(T=>T.identifier==="RESPONSE")?.value||"",b=l.variables?.find(T=>T.identifier==="numAttempts")?.value||0,y=this._sessionContext?.navItemRefId===l.identifier||!1,C=n.categories.includes(this.configContext?.infoItemCategory)?null:t++,A=n.variables?.find(T=>T.identifier=="MAXSCORE")?.value,q=A==null?null:parseFloat(A?.toString());return{...l,completionStatus:m,numAttempts:b,score:p,response:f,index:C,active:y,maxScore:q}})}))}))},this.dispatchEvent(new CustomEvent("qti-computed-context-updated",{detail:this.computedContext,bubbles:!0}))}};c([u({type:String})],Z.prototype,"identifier",2),c([E()],Z.prototype,"initContext",2),c([E(),G({context:Yr})],Z.prototype,"qtiContext",2),c([E(),G({context:oe})],Z.prototype,"configContext",2),c([E(),_({context:pe,subscribe:!0})],Z.prototype,"_testContext",2),c([E(),_({context:ze,subscribe:!0})],Z.prototype,"_sessionContext",2),c([E(),G({context:P})],Z.prototype,"computedContext",2),c([u({type:Boolean,attribute:"auto-score-items"})],Z.prototype,"autoScoreItems",2),Z=c([g("test-navigation")],Z);var Do=x`
1501
1501
  display: inline-flex;
1502
1502
  align-items: center;
1503
1503
  cursor: pointer;
1504
1504
  padding: 0.5rem 1rem;
1505
1505
  border-radius: 0.25rem;
1506
1506
  user-select: none;
1507
- `,j=x`
1508
- background-color: lightgray;
1509
- ${No};
1510
1507
  `,B=x`
1508
+ background-color: lightgray;
1509
+ ${Do};
1510
+ `,W=x`
1511
1511
  cursor: not-allowed;
1512
1512
  opacity: 0.8;
1513
- `,gC=x`
1514
- ${No};
1513
+ `,bC=x`
1514
+ ${Do};
1515
1515
  border: 1px solid gray;
1516
1516
  `;var Fe=class extends v{constructor(){super();this._internalDisabled=!0;this._internals=this.attachInternals(),this._internals.role="button",this._internals.ariaLabel="Next item",this.addEventListener("click",e=>{e.preventDefault(),this._internalDisabled||this._requestItem(this.sectionItems[this.itemIndex+1].identifier)})}_handleTestElementChange(e,t){t&&(this._internalDisabled=!1)}connectedCallback(){super.connectedCallback(),this.checkDisabled()}willUpdate(e){if(!this.computedContext)return;let t=this.computedContext?.testParts.find(i=>i.active);t&&(this.sectionItems=t.sections.flatMap(i=>i.items),this.itemIndex=this.sectionItems.findIndex(i=>i.active),this.checkDisabled())}checkDisabled(){this._internalDisabled=!this.computedContext||this.itemIndex<0||this.itemIndex>=this.sectionItems?.length-1}_requestItem(e){this.dispatchEvent(new CustomEvent("qti-request-navigation",{composed:!0,bubbles:!0,detail:{type:"item",id:e}}))}render(){return h`<slot></slot>`}};Fe.styles=x`
1517
1517
  :host {
1518
- ${j};
1518
+ ${B};
1519
1519
  }
1520
1520
  :host([disabled]) {
1521
- ${B};
1521
+ ${W};
1522
1522
  }
1523
1523
  `,c([u({type:Boolean,reflect:!0,attribute:"disabled"})],Fe.prototype,"_internalDisabled",2),c([_({context:P,subscribe:!0})],Fe.prototype,"computedContext",2),c([I("computedContext")],Fe.prototype,"_handleTestElementChange",1),Fe=c([g("test-next")],Fe);var Ue=class extends v{constructor(){super();this._internalDisabled=!0;this.addEventListener("click",e=>{e.preventDefault(),this._internalDisabled||this._requestItem(this.sectionItems[this.itemIndex-1].identifier)})}_handleTestElementChange(e,t){t&&(this._internalDisabled=!1)}willUpdate(e){if(!this.computedContext)return;let t=this.computedContext?.testParts.find(i=>i.active);t&&(this.sectionItems=t.sections.flatMap(i=>i.items),this.itemIndex=this.sectionItems.findIndex(i=>i.active),this.checkDisabled())}checkDisabled(){this._internalDisabled=!this.computedContext||this.itemIndex===0||this.itemIndex===-1}_requestItem(e){this.dispatchEvent(new CustomEvent("qti-request-navigation",{composed:!0,bubbles:!0,detail:{type:"item",id:e}}))}render(){return h`<slot></slot>`}};Ue.styles=x`
1524
1524
  :host {
1525
- ${j};
1525
+ ${B};
1526
1526
  }
1527
1527
  :host([disabled]) {
1528
- ${B};
1528
+ ${W};
1529
1529
  }
1530
- `,c([u({type:Boolean,reflect:!0,attribute:"disabled"})],Ue.prototype,"_internalDisabled",2),c([_({context:P,subscribe:!0})],Ue.prototype,"computedContext",2),c([I("computedContext")],Ue.prototype,"_handleTestElementChange",1),Ue=c([g("test-prev")],Ue);var W=class extends v{constructor(){super(...arguments);this.label="view";this._handleViewOptionsChange=()=>{this.updateViewOptions()};this._viewOptions=W.DEFAULT_VIEW_OPTIONS}connectedCallback(){super.connectedCallback(),this.updateViewOptions()}updateViewOptions(){if(this.viewOptions){let e=this.viewOptions.split(",").map(t=>t.trim());this._viewOptions=e.filter(t=>W.DEFAULT_VIEW_OPTIONS.includes(t))}else this._viewOptions=W.DEFAULT_VIEW_OPTIONS}_switchView(e){this.dispatchEvent(new CustomEvent("on-test-switch-view",{composed:!0,bubbles:!0,detail:e}))}render(){return h`
1530
+ `,c([u({type:Boolean,reflect:!0,attribute:"disabled"})],Ue.prototype,"_internalDisabled",2),c([_({context:P,subscribe:!0})],Ue.prototype,"computedContext",2),c([I("computedContext")],Ue.prototype,"_handleTestElementChange",1),Ue=c([g("test-prev")],Ue);var X=class extends v{constructor(){super(...arguments);this.label="view";this._handleViewOptionsChange=()=>{this.updateViewOptions()};this._viewOptions=X.DEFAULT_VIEW_OPTIONS}connectedCallback(){super.connectedCallback(),this.updateViewOptions()}updateViewOptions(){if(this.viewOptions){let e=this.viewOptions.split(",").map(t=>t.trim());this._viewOptions=e.filter(t=>X.DEFAULT_VIEW_OPTIONS.includes(t))}else this._viewOptions=X.DEFAULT_VIEW_OPTIONS}_switchView(e){this.dispatchEvent(new CustomEvent("on-test-switch-view",{composed:!0,bubbles:!0,detail:e}))}render(){return h`
1531
1531
  <label part="label" for="viewSelect">${this.label}</label>
1532
1532
  <select
1533
1533
  part="select"
@@ -1536,29 +1536,29 @@ Make sure to test your application with a production build as repeat registratio
1536
1536
  >
1537
1537
  ${this._viewOptions.map(e=>h`<option value="${e}" ?selected=${e===this.sessionContext.view}>${e}</option>`)}
1538
1538
  </select>
1539
- `}};W.DEFAULT_VIEW_OPTIONS=["author","candidate","proctor","scorer","testConstructor","tutor"],c([_({context:ze,subscribe:!0})],W.prototype,"sessionContext",2),c([u({type:String})],W.prototype,"label",2),c([u({type:String,attribute:"view-options"})],W.prototype,"viewOptions",2),c([I("viewOptions",{waitUntilFirstUpdate:!0})],W.prototype,"_handleViewOptionsChange",2),c([C()],W.prototype,"_viewOptions",2),W=c([g("test-view")],W);var wt=class extends v{constructor(){super();this.itemId=null;this.addEventListener("click",()=>this._requestItem(this.itemId))}_requestItem(e){this.dispatchEvent(new CustomEvent("qti-request-navigation",{composed:!0,bubbles:!0,detail:{type:"item",id:e}}))}render(){return h` <slot></slot> `}};wt.styles=x`
1539
+ `}};X.DEFAULT_VIEW_OPTIONS=["author","candidate","proctor","scorer","testConstructor","tutor"],c([_({context:ze,subscribe:!0})],X.prototype,"sessionContext",2),c([u({type:String})],X.prototype,"label",2),c([u({type:String,attribute:"view-options"})],X.prototype,"viewOptions",2),c([I("viewOptions",{waitUntilFirstUpdate:!0})],X.prototype,"_handleViewOptionsChange",2),c([E()],X.prototype,"_viewOptions",2),X=c([g("test-view")],X);var wt=class extends v{constructor(){super();this.itemId=null;this.addEventListener("click",()=>this._requestItem(this.itemId))}_requestItem(e){this.dispatchEvent(new CustomEvent("qti-request-navigation",{composed:!0,bubbles:!0,detail:{type:"item",id:e}}))}render(){return h` <slot></slot> `}};wt.styles=x`
1540
1540
  :host {
1541
- ${j};
1541
+ ${B};
1542
1542
  }
1543
1543
  :host([disabled]) {
1544
- ${B};
1544
+ ${W};
1545
1545
  }
1546
1546
  `,c([u({type:String,attribute:"item-id"})],wt.prototype,"itemId",2),wt=c([g("test-item-link")],wt);var yr=class extends v{constructor(){super(),this.addEventListener("click",()=>this.dispatchEvent(new CustomEvent("test-end-attempt",{bubbles:!0})))}render(){return h` <slot></slot> `}};yr.styles=x`
1547
1547
  :host {
1548
- ${j};
1548
+ ${B};
1549
1549
  }
1550
1550
  :host([disabled]) {
1551
- ${B};
1551
+ ${W};
1552
1552
  }
1553
1553
  `,yr=c([g("test-end-attempt")],yr);var ee=class extends v{constructor(){super(...arguments);this.shown=!1;this.disabled=!1;this.showCorrectText="Show correct response";this.hideCorrectText="Hide correct response";this.noCorrectResponseText="No correct response specified"}willUpdate(e){let t=this.computedContext?.testParts.flatMap(i=>i.sections.flatMap(s=>s.items)).find(i=>i.active);if(this._previousActiveItem!==t&&(this.shown=!1,this._previousActiveItem=t),t){let i=!!t?.variables?.some(n=>n.correctResponse),s=!!t?.variables?.some(n=>n.mapping?.mapEntries?.length>0||n.areaMapping?.areaMapEntries?.length>0);this.disabled=!i&&!s}else this.disabled=!0}_toggleState(){this.disabled||(this.shown=!this.shown,this.dispatchEvent(new CustomEvent("test-show-correct-response",{detail:this.shown,bubbles:!0})))}_getDisplayedText(){return this.disabled?this.noCorrectResponseText:this.shown?this.hideCorrectText:this.showCorrectText}render(){return h` <div @click="${this._toggleState}">${this._getDisplayedText()}</div> `}};ee.styles=x`
1554
1554
  :host {
1555
- ${j};
1555
+ ${B};
1556
1556
  }
1557
1557
  :host([disabled]) {
1558
- ${B};
1558
+ ${W};
1559
1559
  }
1560
- `,c([_({context:P,subscribe:!0})],ee.prototype,"computedContext",2),c([u({type:Boolean,reflect:!0})],ee.prototype,"shown",2),c([u({type:Boolean,reflect:!0})],ee.prototype,"disabled",2),c([u({type:String})],ee.prototype,"showCorrectText",2),c([u({type:String})],ee.prototype,"hideCorrectText",2),c([u({type:String})],ee.prototype,"noCorrectResponseText",2),ee=c([g("test-show-correct-response")],ee);var li=["this"],Do=["+","-","!"],Ho=["=","+","-","*","/","%","^","==","!=",">","<",">=","<=","||","&&","??","&","===","!==","|","|>"],Cs={"!":0,":":0,",":0,")":0,"]":0,"}":0,"|>":1,"?":2,"??":3,"||":4,"&&":5,"|":6,"^":7,"&":8,"!=":9,"==":9,"!==":9,"===":9,">=":10,">":10,"<=":10,"<":10,"+":11,"-":11,"%":12,"/":12,"*":12,"(":13,"[":13,".":13,"{":13},ci=13;var Ln=["==","!=","<=",">=","||","&&","??","|>"],$n=["===","!=="],A;(function(o){o[o.STRING=1]="STRING",o[o.IDENTIFIER=2]="IDENTIFIER",o[o.DOT=3]="DOT",o[o.COMMA=4]="COMMA",o[o.COLON=5]="COLON",o[o.INTEGER=6]="INTEGER",o[o.DECIMAL=7]="DECIMAL",o[o.OPERATOR=8]="OPERATOR",o[o.GROUPER=9]="GROUPER",o[o.KEYWORD=10]="KEYWORD",o[o.ARROW=11]="ARROW"})(A||(A={}));var he=(o,r,e=0)=>({kind:o,value:r,precedence:e}),Pn=o=>o===9||o===10||o===13||o===32,zo=o=>o===95||o===36||(o&=-33,65<=o&&o<=90),Vn=o=>zo(o)||xr(o),On=o=>li.indexOf(o)!==-1,Nn=o=>o===34||o===39,xr=o=>48<=o&&o<=57,Dn=o=>o===43||o===45||o===42||o===47||o===33||o===38||o===37||o===60||o===61||o===62||o===63||o===94||o===124,Hn=o=>o===40||o===41||o===91||o===93||o===123||o===125,zn=o=>o.replace(/\\(.)/g,(r,e)=>{switch(e){case"n":return`
1561
- `;case"r":return"\r";case"t":return" ";case"b":return"\b";case"f":return"\f";default:return e}}),di=class{#s;#n=-1;#i=0;#t;constructor(r){this.#s=r,this.#e()}nextToken(){for(;Pn(this.#t);)this.#e(!0);if(Nn(this.#t))return this.#l();if(zo(this.#t))return this.#d();if(xr(this.#t))return this.#p();if(this.#t===46)return this.#a();if(this.#t===44)return this.#u();if(this.#t===58)return this.#c();if(Dn(this.#t))return this.#h();if(Hn(this.#t))return this.#f();if(this.#e(),this.#t!==void 0)throw new Error(`Expected end of input, got ${this.#t}`)}#e(r){this.#n++,this.#n<this.#s.length?(this.#t=this.#s.charCodeAt(this.#n),r===!0&&(this.#i=this.#n)):this.#t=void 0}#r(r=0){let e=this.#s.substring(this.#i,this.#n+r);return r===0&&this.#o(),e}#o(){this.#i=this.#n}#l(){let r="unterminated string",e=this.#t;for(this.#e(!0);this.#t!==e;){if(this.#t===void 0)throw new Error(r);if(this.#t===92&&(this.#e(),this.#t===void 0))throw new Error(r);this.#e()}let t=he(A.STRING,zn(this.#r()));return this.#e(),t}#d(){do this.#e();while(Vn(this.#t));let r=this.#r(),e=On(r)?A.KEYWORD:A.IDENTIFIER;return he(e,r)}#p(){do this.#e();while(xr(this.#t));return this.#t===46?this.#a():he(A.INTEGER,this.#r())}#a(){return this.#e(),xr(this.#t)?this.#m():(this.#o(),he(A.DOT,".",ci))}#u(){return this.#e(!0),he(A.COMMA,",")}#c(){return this.#e(!0),he(A.COLON,":")}#m(){do this.#e();while(xr(this.#t));return he(A.DECIMAL,this.#r())}#h(){this.#e();let r=this.#r(2);if($n.indexOf(r)!==-1)this.#e(),this.#e();else{if(r=this.#r(1),r==="=>")return this.#e(),he(A.ARROW,r);Ln.indexOf(r)!==-1&&this.#e()}return r=this.#r(),he(A.OPERATOR,r,Cs[r])}#f(){let r=String.fromCharCode(this.#t),e=he(A.GROUPER,r,Cs[r]);return this.#e(!0),e}};var Es=(o,r)=>new qr(o,r).parse(),qr=class{#s;#n;#i;#t;#e;constructor(r,e){this.#n=new di(r),this.#i=e}parse(){return this.#r(),this.#o()}#r(r,e){if(!this._matches(r,e))throw new Error(`Expected kind ${r} (${e}), was ${this.#t?.kind} (${this.#t?.value})`);let t=this.#n.nextToken();this.#t=t,this.#s=t?.kind,this.#e=t?.value}_matches(r,e){return!(r&&this.#s!==r||e&&this.#e!==e)}#o(){if(!this.#t)return this.#i.empty();let r=this.#a();return r===void 0?void 0:this.#l(r,0)}#l(r,e){if(r===void 0)throw new Error("Expected left to be defined.");for(;this.#t;)if(this._matches(A.GROUPER,"(")){let t=this.#g();r=this.#i.invoke(r,void 0,t)}else if(this._matches(A.GROUPER,"[")){let t=this.#x();r=this.#i.index(r,t)}else if(this._matches(A.DOT)){this.#r();let t=this.#a();r=this.#d(r,t)}else{if(this._matches(A.KEYWORD))break;if(this._matches(A.OPERATOR)&&this.#t.precedence>=e)r=this.#e==="?"?this.#u(r):this.#p(r,this.#t);else break}return r}#d(r,e){if(e===void 0)throw new Error("expected identifier");if(e.type==="ID")return this.#i.getter(r,e.value);if(e.type==="Invoke"&&e.receiver.type==="ID"){let t=e.receiver;return this.#i.invoke(r,t.value,e.arguments)}else throw new Error(`expected identifier: ${e}`)}#p(r,e){if(Ho.indexOf(e.value)===-1)throw new Error(`unknown operator: ${e.value}`);this.#r();let t=this.#a();for(;(this.#s===A.OPERATOR||this.#s===A.DOT||this.#s===A.GROUPER)&&this.#t.precedence>e.precedence;)t=this.#l(t,this.#t.precedence);return this.#i.binary(r,e.value,t)}#a(){if(this._matches(A.OPERATOR)){let r=this.#e;if(this.#r(),r==="+"||r==="-"){if(this._matches(A.INTEGER))return this.#b(r);if(this._matches(A.DECIMAL))return this.#v(r)}if(Do.indexOf(r)===-1)throw new Error(`unexpected token: ${r}`);let e=this.#l(this.#c(),ci);return this.#i.unary(r,e)}return this.#c()}#u(r){this.#r(A.OPERATOR,"?");let e=this.#o();this.#r(A.COLON);let t=this.#o();return this.#i.ternary(r,e,t)}#c(){switch(this.#s){case A.KEYWORD:let r=this.#e;if(r==="this")return this.#r(),this.#i.id(r);throw li.indexOf(r)!==-1?new Error(`unexpected keyword: ${r}`):new Error(`unrecognized keyword: ${r}`);case A.IDENTIFIER:return this.#f();case A.STRING:return this.#C();case A.INTEGER:return this.#b();case A.DECIMAL:return this.#v();case A.GROUPER:return this.#e==="("?this.#q():this.#e==="{"?this.#h():this.#e==="["?this.#m():void 0;case A.COLON:throw new Error('unexpected token ":"');default:return}}#m(){let r=[];do{if(this.#r(),this._matches(A.GROUPER,"]"))break;r.push(this.#o())}while(this._matches(A.COMMA));return this.#r(A.GROUPER,"]"),this.#i.list(r)}#h(){let r={};do{if(this.#r(),this._matches(A.GROUPER,"}"))break;let e=this.#e;(this._matches(A.STRING)||this._matches(A.IDENTIFIER))&&this.#r(),this.#r(A.COLON),r[e]=this.#o()}while(this._matches(A.COMMA));return this.#r(A.GROUPER,"}"),this.#i.map(r)}#f(){let r=this.#e;if(r==="true")return this.#r(),this.#i.literal(!0);if(r==="false")return this.#r(),this.#i.literal(!1);if(r==="null")return this.#r(),this.#i.literal(null);if(r==="undefined")return this.#r(),this.#i.literal(void 0);let e=this.#y(),t=this.#g();return t?this.#i.invoke(e,void 0,t):e}#y(){if(!this._matches(A.IDENTIFIER))throw new Error(`expected identifier: ${this.#e}`);let r=this.#e;return this.#r(),this.#i.id(r)}#g(){if(!this._matches(A.GROUPER,"("))return;let r=[];do{if(this.#r(),this._matches(A.GROUPER,")"))break;let e=this.#o();r.push(e)}while(this._matches(A.COMMA));return this.#r(A.GROUPER,")"),r}#x(){this.#r();let r=this.#o();return this.#r(A.GROUPER,"]"),r}#q(){let r=this.#g();if(this._matches(A.ARROW)){this.#r();let e=this.#o(),t=r?.map(i=>i.value)??[];return this.#i.arrowFunction(t,e)}else return this.#i.paren(r[0])}#C(){let r=this.#i.literal(this.#e);return this.#r(),r}#b(r=""){let e=this.#i.literal(parseInt(`${r}${this.#e}`,10));return this.#r(),e}#v(r=""){let e=this.#i.literal(parseFloat(`${r}${this.#e}`));return this.#r(),e}};var{hasOwn:Fo,fromEntries:Fn}=Object,Un={"+":(o,r)=>o+r,"-":(o,r)=>o-r,"*":(o,r)=>o*r,"/":(o,r)=>o/r,"%":(o,r)=>o%r,"==":(o,r)=>o==r,"!=":(o,r)=>o!=r,"===":(o,r)=>o===r,"!==":(o,r)=>o!==r,">":(o,r)=>o>r,">=":(o,r)=>o>=r,"<":(o,r)=>o<r,"<=":(o,r)=>o<=r,"||":(o,r)=>o||r,"&&":(o,r)=>o&&r,"??":(o,r)=>o??r,"|":(o,r)=>r(o),"|>":(o,r)=>r(o)},jn={"+":o=>o,"-":o=>-o,"!":o=>!o},pi=class{empty(){return{type:"Empty",evaluate(r){return r},getIds(r){return r}}}literal(r){return{type:"Literal",value:r,evaluate(e){return this.value},getIds(e){return e}}}id(r){return{type:"ID",value:r,evaluate(e){return this.value==="this"?e:e?.[this.value]},getIds(e){return e.push(this.value),e}}}unary(r,e){let t=jn[r];return{type:"Unary",operator:r,child:e,evaluate(i){return t(this.child.evaluate(i))},getIds(i){return this.child.getIds(i)}}}binary(r,e,t){let i=Un[e];return{type:"Binary",operator:e,left:r,right:t,evaluate(s){if(this.operator==="="){if(this.left.type!=="ID"&&this.left.type!=="Getter"&&this.left.type!=="Index")throw new Error(`Invalid assignment target: ${this.left}`);let n=this.right.evaluate(s),a,l;return this.left.type==="Getter"?(a=this.left.receiver.evaluate(s),l=this.left.name):this.left.type==="Index"?(a=this.left.receiver.evaluate(s),l=this.left.argument.evaluate(s)):this.left.type==="ID"&&(a=s,l=this.left.value),a===void 0?void 0:a[l]=n}return i(this.left.evaluate(s),this.right.evaluate(s))},getIds(s){return this.left.getIds(s),this.right.getIds(s),s}}}getter(r,e){return{type:"Getter",receiver:r,name:e,evaluate(t){return this.receiver.evaluate(t)?.[this.name]},getIds(t){return this.receiver.getIds(t),t}}}invoke(r,e,t){if(e!=null&&typeof e!="string")throw new Error("method not a string");return{type:"Invoke",receiver:r,method:e,arguments:t,evaluate(i){let s=this.receiver.evaluate(i),n=this.method?s:i?.this??i,a=this.method?s?.[e]:s,d=(this.arguments??[]).map(p=>p?.evaluate(i));return a?.apply?.(n,d)},getIds(i){return this.receiver.getIds(i),this.arguments?.forEach(s=>s?.getIds(i)),i}}}paren(r){return r}index(r,e){return{type:"Index",receiver:r,argument:e,evaluate(t){return this.receiver.evaluate(t)?.[this.argument.evaluate(t)]},getIds(t){return this.receiver.getIds(t),t}}}ternary(r,e,t){return{type:"Ternary",condition:r,trueExpr:e,falseExpr:t,evaluate(i){return this.condition.evaluate(i)?this.trueExpr.evaluate(i):this.falseExpr.evaluate(i)},getIds(i){return this.condition.getIds(i),this.trueExpr.getIds(i),this.falseExpr.getIds(i),i}}}map(r){return{type:"Map",entries:r,evaluate(e){let t={};if(r&&this.entries)for(let i in r){let s=this.entries[i];s&&(t[i]=s.evaluate(e))}return t},getIds(e){if(r&&this.entries)for(let t in r){let i=this.entries[t];i&&i.getIds(e)}return e}}}list(r){return{type:"List",items:r,evaluate(e){return this.items?.map(t=>t?.evaluate(e))},getIds(e){return this.items?.forEach(t=>t?.getIds(e)),e}}}arrowFunction(r,e){return{type:"ArrowFunction",params:r,body:e,evaluate(t){let i=this.params,s=this.body;return function(...n){let a=Fn(i.map((d,p)=>[d,n[p]])),l=new Proxy(t??{},{set(d,p,m){return Fo(a,p)&&(a[p]=m),d[p]=m},get(d,p){return Fo(a,p)?a[p]:d[p]}});return s.evaluate(l)}},getIds(t){return this.body.getIds(t).filter(i=>!this.params.includes(i))}}}};var ws=null,Uo={boundAttributeSuffix:H.M,marker:H.P,markerMatch:H.A,HTML_RESULT:H.C,getTemplateHtml:H.L,overrideDirectiveResolve:(o,r)=>class extends o{_$AS(e,t){return r(this,t)}},patchDirectiveResolve:(o,r)=>{if(o.prototype._$AS.name!==r.name){ws??=o.prototype._$AS.name;for(let e=o.prototype;e!==Object.prototype;e=Object.getPrototypeOf(e))if(e.hasOwnProperty(ws))return void(e[ws]=r);throw Error("Internal error: It is possible that both dev mode and production mode Lit was mixed together during SSR. Please comment on the issue: https://github.com/lit/lit/issues/4527")}},setDirectiveClass(o,r){o._$litDirective$=r},getAttributePartCommittedValue:(o,r,e)=>{let t=V;return o.j=i=>t=i,o._$AI(r,o,e),t},connectedDisconnectable:o=>({...o,_$AU:!0}),resolveDirective:H.V,AttributePart:H.H,PropertyPart:H.B,BooleanAttributePart:H.N,EventPart:H.U,ElementPart:H.F,TemplateInstance:H.R,isIterable:H.D,ChildPart:H.I};var{AttributePart:Bn,PropertyPart:Wn,BooleanAttributePart:Xn,EventPart:Gn}=Uo,Ts=new pi,_s=new Map,jo=o=>o.replace(/-(-|\w)/g,(r,e)=>e.toUpperCase()),ui=(o,r)=>{let e=_s.get(o);if(e===void 0){if(_s.has(o))return;if(o=o.trim(),o.startsWith("{{")&&o.endsWith("}}")){let t=o.substring(2,o.length-2).trim();e=new qr(t,Ts).parse(),_s.set(o,e)}}return e?.evaluate(r)},Yn=(o,r,e,t)=>{let i=o.getAttribute("if");if(i!==null&&ui(i,r))return mi(o,r,e,t)},Bo=/(?<!\\){{(.*?)(?:(?<!\\)}})/g,Wo=o=>/(?:\\{{)|(?:\\}})/g.test(o),Cr=o=>o.replaceAll(/\\{{/g,"{{").replace(/\\}}/g,"}}"),Jn=(o,r,e,t)=>{let i=o.getAttribute("repeat");if(i!==null){let s=ui(i,r);if(!s[Symbol.iterator])return R;let n=Er(o),a=-1,l=[];for(let d of s){a++;let p=Object.create(r);p.item=d,p.index=a,p.this=r.this??r;let m=[];for(let b of n.parts){let y=b.update(p,e,t);b.type===1?m.push(...y):m.push(y)}let f={_$litType$:n,values:m};l.push(f)}return l}},Go={if:Yn,repeat:Jn},fe=(o,r=Go,e={},t)=>{let s=Er(o).renderers;if(t){let a=Er(t).renderers,l=s.super;l!==void 0?e={...s,...e,super:(d,p,m)=>(m={...a,...m,super:(f,b,y)=>mi(t,f,b,y)},l(d,p,m))}:(e={...a,...s,...e},o=t)}else e={...s,...e};return n=>mi(o,n,r,e)};var mi=(o,r,e=Go,t={})=>{let i=Er(o),s=[];for(let a of i.parts){let l=a.update(r,e,t);a.type===1?s.push(...l):s.push(l)}return{_$litType$:i,values:s}},Xo=new Map,Er=o=>{let r=Xo.get(o);return r===void 0&&Xo.set(o,r=Kn(o)),r},Kn=o=>{let r={h:void 0,el:o.cloneNode(!0),parts:[],renderers:{}},e=document.createTreeWalker(r.el.content,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT|NodeFilter.SHOW_COMMENT),t=e.currentNode,i=-1,s=[];for(;(t=e.nextNode())!==null;)if(t.nodeType===Node.COMMENT_NODE)i++;else if(t.nodeType===Node.ELEMENT_NODE){i++;let n=t;if(n.tagName==="TEMPLATE"){let l=n.getAttribute("type"),d=n.getAttribute("name"),p=n.getAttribute("call");if(p!==null||l!==null||d!==null){n.parentNode.insertBefore(document.createComment(""),n),s.push(n);let m;if(p!==null){let f=p.trim(),b=f.startsWith("{{")&&f.endsWith("}}");m=(y,E,S)=>{let q=n.getAttribute("data"),T=q===null?void 0:ui(q,y);return(b?ui(f,y):S[p])?.(T,E,S)}}else l!==null?m=(f,b,y)=>{let E=b[l];return E?.(n,f,b,y)}:(d==="super"?r.renderers.super=(f,b,y)=>{let E=y.super,S=Er(n);return y={...y,...S.renderers},E(f,b,y)}:r.renderers[d]=(f,b,y)=>mi(n,f,b,y),m=(f,b,y)=>{let E=y[d];return E?.(f,b,y)});r.parts.push({type:2,index:i,update:m});continue}}let a=n.getAttributeNames();for(let l of a){let d=n.getAttribute(l),p=d.split(Bo);if(p.length===1){Wo(d)&&n.setAttribute(l,Cr(d));continue}n.removeAttribute(l);let m=l,f=Bn,b=l[0];b==="."?(m=jo(l.substring(1)),f=Wn):b==="?"?(m=l.substring(1),f=Xn):b==="@"&&(m=jo(l.substring(1)),f=Gn);let y=[Cr(p[0])],E=[];for(let S=1;S<p.length;S+=2){let q=p[S];E.push(Es(q,Ts)),y.push(Cr(p[S+1]))}r.parts.push({type:1,index:i,name:m,strings:y,ctor:f,update:(S,q,T)=>E.map(M=>M.evaluate(S))})}}else if(t.nodeType===Node.TEXT_NODE){let n=t,a=n.textContent,l=a.split(Bo);l.length>1?n.textContent=Cr(l[0]):Wo(a)&&(n.textContent=Cr(a));for(let d=1;d<l.length;d+=2){let p=l[d],m=Es(p,Ts);r.parts.push({type:2,index:++i,update:(b,y)=>m.evaluate(b)});let f=new Text(l[d+1].replace("\\{{","{{"));n.parentNode.insertBefore(f,n.nextSibling),n.parentNode.insertBefore(document.createComment(""),n.nextSibling),n=f,e.currentNode=f}}for(let n of s)n.remove();return r};var wr=class extends v{createRenderRoot(){return this}constructor(){super(),this._internals=this.attachInternals(),this._internals.ariaLabel="pagination"}connectedCallback(){super.connectedCallback();let r=this.querySelector("template");this.myTemplate=fe(r)}render(){if(!this.computedContext)return h``;let r=this.computedContext.testParts.flatMap(e=>e.sections.flatMap(t=>t.items));return h` ${r.map(e=>this.myTemplate({item:e,view:this.computedContext.view}))} `}};c([_({context:P,subscribe:!0})],wr.prototype,"computedContext",2),wr=c([g("test-paging-buttons-stamp")],wr);var hi=class{constructor(r){this.G=r}disconnect(){this.G=void 0}reconnect(r){this.G=r}deref(){return this.G}},fi=class{constructor(){this.Y=void 0,this.Z=void 0}get(){return this.Y}pause(){this.Y??=new Promise((r=>this.Z=r))}resume(){this.Z?.(),this.Y=this.Z=void 0}};var Yo=o=>!mo(o)&&typeof o.then=="function",Jo=1073741823,As=class extends xt{constructor(){super(...arguments),this._$Cwt=Jo,this._$Cbt=[],this._$CK=new hi(this),this._$CX=new fi}render(...r){return r.find((e=>!Yo(e)))??V}update(r,e){let t=this._$Cbt,i=t.length;this._$Cbt=e;let s=this._$CK,n=this._$CX;this.isConnected||this.disconnected();for(let a=0;a<e.length&&!(a>this._$Cwt);a++){let l=e[a];if(!Yo(l))return this._$Cwt=a,l;a<i&&l===t[a]||(this._$Cwt=Jo,i=0,Promise.resolve(l).then((async d=>{for(;n.get();)await n.get();let p=s.deref();if(p!==void 0){let m=p._$Cbt.indexOf(l);m>-1&&m<p._$Cwt&&(p._$Cwt=m,p.setValue(d))}})))}return V}disconnected(){this._$CK.disconnect(),this._$CX.pause()}reconnected(){this._$CK.reconnect(this),this._$CX.resume()}},gi=Q(As);var bi=`@layer qti-base, qti-components, qti-utilities, qti-variants, qti-extended;
1560
+ `,c([_({context:P,subscribe:!0})],ee.prototype,"computedContext",2),c([u({type:Boolean,reflect:!0})],ee.prototype,"shown",2),c([u({type:Boolean,reflect:!0})],ee.prototype,"disabled",2),c([u({type:String})],ee.prototype,"showCorrectText",2),c([u({type:String})],ee.prototype,"hideCorrectText",2),c([u({type:String})],ee.prototype,"noCorrectResponseText",2),ee=c([g("test-show-correct-response")],ee);var li=["this"],No=["+","-","!"],Ho=["=","+","-","*","/","%","^","==","!=",">","<",">=","<=","||","&&","??","&","===","!==","|","|>"],Cs={"!":0,":":0,",":0,")":0,"]":0,"}":0,"|>":1,"?":2,"??":3,"||":4,"&&":5,"|":6,"^":7,"&":8,"!=":9,"==":9,"!==":9,"===":9,">=":10,">":10,"<=":10,"<":10,"+":11,"-":11,"%":12,"/":12,"*":12,"(":13,"[":13,".":13,"{":13},ci=13;var Ln=["==","!=","<=",">=","||","&&","??","|>"],$n=["===","!=="],k;(function(o){o[o.STRING=1]="STRING",o[o.IDENTIFIER=2]="IDENTIFIER",o[o.DOT=3]="DOT",o[o.COMMA=4]="COMMA",o[o.COLON=5]="COLON",o[o.INTEGER=6]="INTEGER",o[o.DECIMAL=7]="DECIMAL",o[o.OPERATOR=8]="OPERATOR",o[o.GROUPER=9]="GROUPER",o[o.KEYWORD=10]="KEYWORD",o[o.ARROW=11]="ARROW"})(k||(k={}));var he=(o,r,e=0)=>({kind:o,value:r,precedence:e}),Pn=o=>o===9||o===10||o===13||o===32,zo=o=>o===95||o===36||(o&=-33,65<=o&&o<=90),Vn=o=>zo(o)||xr(o),On=o=>li.indexOf(o)!==-1,Dn=o=>o===34||o===39,xr=o=>48<=o&&o<=57,Nn=o=>o===43||o===45||o===42||o===47||o===33||o===38||o===37||o===60||o===61||o===62||o===63||o===94||o===124,Hn=o=>o===40||o===41||o===91||o===93||o===123||o===125,zn=o=>o.replace(/\\(.)/g,(r,e)=>{switch(e){case"n":return`
1561
+ `;case"r":return"\r";case"t":return" ";case"b":return"\b";case"f":return"\f";default:return e}}),di=class{#s;#n=-1;#i=0;#t;constructor(r){this.#s=r,this.#e()}nextToken(){for(;Pn(this.#t);)this.#e(!0);if(Dn(this.#t))return this.#l();if(zo(this.#t))return this.#d();if(xr(this.#t))return this.#p();if(this.#t===46)return this.#a();if(this.#t===44)return this.#u();if(this.#t===58)return this.#c();if(Nn(this.#t))return this.#h();if(Hn(this.#t))return this.#f();if(this.#e(),this.#t!==void 0)throw new Error(`Expected end of input, got ${this.#t}`)}#e(r){this.#n++,this.#n<this.#s.length?(this.#t=this.#s.charCodeAt(this.#n),r===!0&&(this.#i=this.#n)):this.#t=void 0}#r(r=0){let e=this.#s.substring(this.#i,this.#n+r);return r===0&&this.#o(),e}#o(){this.#i=this.#n}#l(){let r="unterminated string",e=this.#t;for(this.#e(!0);this.#t!==e;){if(this.#t===void 0)throw new Error(r);if(this.#t===92&&(this.#e(),this.#t===void 0))throw new Error(r);this.#e()}let t=he(k.STRING,zn(this.#r()));return this.#e(),t}#d(){do this.#e();while(Vn(this.#t));let r=this.#r(),e=On(r)?k.KEYWORD:k.IDENTIFIER;return he(e,r)}#p(){do this.#e();while(xr(this.#t));return this.#t===46?this.#a():he(k.INTEGER,this.#r())}#a(){return this.#e(),xr(this.#t)?this.#m():(this.#o(),he(k.DOT,".",ci))}#u(){return this.#e(!0),he(k.COMMA,",")}#c(){return this.#e(!0),he(k.COLON,":")}#m(){do this.#e();while(xr(this.#t));return he(k.DECIMAL,this.#r())}#h(){this.#e();let r=this.#r(2);if($n.indexOf(r)!==-1)this.#e(),this.#e();else{if(r=this.#r(1),r==="=>")return this.#e(),he(k.ARROW,r);Ln.indexOf(r)!==-1&&this.#e()}return r=this.#r(),he(k.OPERATOR,r,Cs[r])}#f(){let r=String.fromCharCode(this.#t),e=he(k.GROUPER,r,Cs[r]);return this.#e(!0),e}};var Es=(o,r)=>new qr(o,r).parse(),qr=class{#s;#n;#i;#t;#e;constructor(r,e){this.#n=new di(r),this.#i=e}parse(){return this.#r(),this.#o()}#r(r,e){if(!this._matches(r,e))throw new Error(`Expected kind ${r} (${e}), was ${this.#t?.kind} (${this.#t?.value})`);let t=this.#n.nextToken();this.#t=t,this.#s=t?.kind,this.#e=t?.value}_matches(r,e){return!(r&&this.#s!==r||e&&this.#e!==e)}#o(){if(!this.#t)return this.#i.empty();let r=this.#a();return r===void 0?void 0:this.#l(r,0)}#l(r,e){if(r===void 0)throw new Error("Expected left to be defined.");for(;this.#t;)if(this._matches(k.GROUPER,"(")){let t=this.#g();r=this.#i.invoke(r,void 0,t)}else if(this._matches(k.GROUPER,"[")){let t=this.#x();r=this.#i.index(r,t)}else if(this._matches(k.DOT)){this.#r();let t=this.#a();r=this.#d(r,t)}else{if(this._matches(k.KEYWORD))break;if(this._matches(k.OPERATOR)&&this.#t.precedence>=e)r=this.#e==="?"?this.#u(r):this.#p(r,this.#t);else break}return r}#d(r,e){if(e===void 0)throw new Error("expected identifier");if(e.type==="ID")return this.#i.getter(r,e.value);if(e.type==="Invoke"&&e.receiver.type==="ID"){let t=e.receiver;return this.#i.invoke(r,t.value,e.arguments)}else throw new Error(`expected identifier: ${e}`)}#p(r,e){if(Ho.indexOf(e.value)===-1)throw new Error(`unknown operator: ${e.value}`);this.#r();let t=this.#a();for(;(this.#s===k.OPERATOR||this.#s===k.DOT||this.#s===k.GROUPER)&&this.#t.precedence>e.precedence;)t=this.#l(t,this.#t.precedence);return this.#i.binary(r,e.value,t)}#a(){if(this._matches(k.OPERATOR)){let r=this.#e;if(this.#r(),r==="+"||r==="-"){if(this._matches(k.INTEGER))return this.#b(r);if(this._matches(k.DECIMAL))return this.#v(r)}if(No.indexOf(r)===-1)throw new Error(`unexpected token: ${r}`);let e=this.#l(this.#c(),ci);return this.#i.unary(r,e)}return this.#c()}#u(r){this.#r(k.OPERATOR,"?");let e=this.#o();this.#r(k.COLON);let t=this.#o();return this.#i.ternary(r,e,t)}#c(){switch(this.#s){case k.KEYWORD:let r=this.#e;if(r==="this")return this.#r(),this.#i.id(r);throw li.indexOf(r)!==-1?new Error(`unexpected keyword: ${r}`):new Error(`unrecognized keyword: ${r}`);case k.IDENTIFIER:return this.#f();case k.STRING:return this.#C();case k.INTEGER:return this.#b();case k.DECIMAL:return this.#v();case k.GROUPER:return this.#e==="("?this.#q():this.#e==="{"?this.#h():this.#e==="["?this.#m():void 0;case k.COLON:throw new Error('unexpected token ":"');default:return}}#m(){let r=[];do{if(this.#r(),this._matches(k.GROUPER,"]"))break;r.push(this.#o())}while(this._matches(k.COMMA));return this.#r(k.GROUPER,"]"),this.#i.list(r)}#h(){let r={};do{if(this.#r(),this._matches(k.GROUPER,"}"))break;let e=this.#e;(this._matches(k.STRING)||this._matches(k.IDENTIFIER))&&this.#r(),this.#r(k.COLON),r[e]=this.#o()}while(this._matches(k.COMMA));return this.#r(k.GROUPER,"}"),this.#i.map(r)}#f(){let r=this.#e;if(r==="true")return this.#r(),this.#i.literal(!0);if(r==="false")return this.#r(),this.#i.literal(!1);if(r==="null")return this.#r(),this.#i.literal(null);if(r==="undefined")return this.#r(),this.#i.literal(void 0);let e=this.#y(),t=this.#g();return t?this.#i.invoke(e,void 0,t):e}#y(){if(!this._matches(k.IDENTIFIER))throw new Error(`expected identifier: ${this.#e}`);let r=this.#e;return this.#r(),this.#i.id(r)}#g(){if(!this._matches(k.GROUPER,"("))return;let r=[];do{if(this.#r(),this._matches(k.GROUPER,")"))break;let e=this.#o();r.push(e)}while(this._matches(k.COMMA));return this.#r(k.GROUPER,")"),r}#x(){this.#r();let r=this.#o();return this.#r(k.GROUPER,"]"),r}#q(){let r=this.#g();if(this._matches(k.ARROW)){this.#r();let e=this.#o(),t=r?.map(i=>i.value)??[];return this.#i.arrowFunction(t,e)}else return this.#i.paren(r[0])}#C(){let r=this.#i.literal(this.#e);return this.#r(),r}#b(r=""){let e=this.#i.literal(parseInt(`${r}${this.#e}`,10));return this.#r(),e}#v(r=""){let e=this.#i.literal(parseFloat(`${r}${this.#e}`));return this.#r(),e}};var{hasOwn:Fo,fromEntries:Fn}=Object,Un={"+":(o,r)=>o+r,"-":(o,r)=>o-r,"*":(o,r)=>o*r,"/":(o,r)=>o/r,"%":(o,r)=>o%r,"==":(o,r)=>o==r,"!=":(o,r)=>o!=r,"===":(o,r)=>o===r,"!==":(o,r)=>o!==r,">":(o,r)=>o>r,">=":(o,r)=>o>=r,"<":(o,r)=>o<r,"<=":(o,r)=>o<=r,"||":(o,r)=>o||r,"&&":(o,r)=>o&&r,"??":(o,r)=>o??r,"|":(o,r)=>r(o),"|>":(o,r)=>r(o)},jn={"+":o=>o,"-":o=>-o,"!":o=>!o},pi=class{empty(){return{type:"Empty",evaluate(r){return r},getIds(r){return r}}}literal(r){return{type:"Literal",value:r,evaluate(e){return this.value},getIds(e){return e}}}id(r){return{type:"ID",value:r,evaluate(e){return this.value==="this"?e:e?.[this.value]},getIds(e){return e.push(this.value),e}}}unary(r,e){let t=jn[r];return{type:"Unary",operator:r,child:e,evaluate(i){return t(this.child.evaluate(i))},getIds(i){return this.child.getIds(i)}}}binary(r,e,t){let i=Un[e];return{type:"Binary",operator:e,left:r,right:t,evaluate(s){if(this.operator==="="){if(this.left.type!=="ID"&&this.left.type!=="Getter"&&this.left.type!=="Index")throw new Error(`Invalid assignment target: ${this.left}`);let n=this.right.evaluate(s),a,l;return this.left.type==="Getter"?(a=this.left.receiver.evaluate(s),l=this.left.name):this.left.type==="Index"?(a=this.left.receiver.evaluate(s),l=this.left.argument.evaluate(s)):this.left.type==="ID"&&(a=s,l=this.left.value),a===void 0?void 0:a[l]=n}return i(this.left.evaluate(s),this.right.evaluate(s))},getIds(s){return this.left.getIds(s),this.right.getIds(s),s}}}getter(r,e){return{type:"Getter",receiver:r,name:e,evaluate(t){return this.receiver.evaluate(t)?.[this.name]},getIds(t){return this.receiver.getIds(t),t}}}invoke(r,e,t){if(e!=null&&typeof e!="string")throw new Error("method not a string");return{type:"Invoke",receiver:r,method:e,arguments:t,evaluate(i){let s=this.receiver.evaluate(i),n=this.method?s:i?.this??i,a=this.method?s?.[e]:s,d=(this.arguments??[]).map(p=>p?.evaluate(i));return a?.apply?.(n,d)},getIds(i){return this.receiver.getIds(i),this.arguments?.forEach(s=>s?.getIds(i)),i}}}paren(r){return r}index(r,e){return{type:"Index",receiver:r,argument:e,evaluate(t){return this.receiver.evaluate(t)?.[this.argument.evaluate(t)]},getIds(t){return this.receiver.getIds(t),t}}}ternary(r,e,t){return{type:"Ternary",condition:r,trueExpr:e,falseExpr:t,evaluate(i){return this.condition.evaluate(i)?this.trueExpr.evaluate(i):this.falseExpr.evaluate(i)},getIds(i){return this.condition.getIds(i),this.trueExpr.getIds(i),this.falseExpr.getIds(i),i}}}map(r){return{type:"Map",entries:r,evaluate(e){let t={};if(r&&this.entries)for(let i in r){let s=this.entries[i];s&&(t[i]=s.evaluate(e))}return t},getIds(e){if(r&&this.entries)for(let t in r){let i=this.entries[t];i&&i.getIds(e)}return e}}}list(r){return{type:"List",items:r,evaluate(e){return this.items?.map(t=>t?.evaluate(e))},getIds(e){return this.items?.forEach(t=>t?.getIds(e)),e}}}arrowFunction(r,e){return{type:"ArrowFunction",params:r,body:e,evaluate(t){let i=this.params,s=this.body;return function(...n){let a=Fn(i.map((d,p)=>[d,n[p]])),l=new Proxy(t??{},{set(d,p,m){return Fo(a,p)&&(a[p]=m),d[p]=m},get(d,p){return Fo(a,p)?a[p]:d[p]}});return s.evaluate(l)}},getIds(t){return this.body.getIds(t).filter(i=>!this.params.includes(i))}}}};var ws=null,Uo={boundAttributeSuffix:H.M,marker:H.P,markerMatch:H.A,HTML_RESULT:H.C,getTemplateHtml:H.L,overrideDirectiveResolve:(o,r)=>class extends o{_$AS(e,t){return r(this,t)}},patchDirectiveResolve:(o,r)=>{if(o.prototype._$AS.name!==r.name){ws??=o.prototype._$AS.name;for(let e=o.prototype;e!==Object.prototype;e=Object.getPrototypeOf(e))if(e.hasOwnProperty(ws))return void(e[ws]=r);throw Error("Internal error: It is possible that both dev mode and production mode Lit was mixed together during SSR. Please comment on the issue: https://github.com/lit/lit/issues/4527")}},setDirectiveClass(o,r){o._$litDirective$=r},getAttributePartCommittedValue:(o,r,e)=>{let t=V;return o.j=i=>t=i,o._$AI(r,o,e),t},connectedDisconnectable:o=>({...o,_$AU:!0}),resolveDirective:H.V,AttributePart:H.H,PropertyPart:H.B,BooleanAttributePart:H.N,EventPart:H.U,ElementPart:H.F,TemplateInstance:H.R,isIterable:H.D,ChildPart:H.I};var{AttributePart:Bn,PropertyPart:Wn,BooleanAttributePart:Xn,EventPart:Gn}=Uo,Ts=new pi,_s=new Map,jo=o=>o.replace(/-(-|\w)/g,(r,e)=>e.toUpperCase()),ui=(o,r)=>{let e=_s.get(o);if(e===void 0){if(_s.has(o))return;if(o=o.trim(),o.startsWith("{{")&&o.endsWith("}}")){let t=o.substring(2,o.length-2).trim();e=new qr(t,Ts).parse(),_s.set(o,e)}}return e?.evaluate(r)},Yn=(o,r,e,t)=>{let i=o.getAttribute("if");if(i!==null&&ui(i,r))return mi(o,r,e,t)},Bo=/(?<!\\){{(.*?)(?:(?<!\\)}})/g,Wo=o=>/(?:\\{{)|(?:\\}})/g.test(o),Cr=o=>o.replaceAll(/\\{{/g,"{{").replace(/\\}}/g,"}}"),Jn=(o,r,e,t)=>{let i=o.getAttribute("repeat");if(i!==null){let s=ui(i,r);if(!s[Symbol.iterator])return R;let n=Er(o),a=-1,l=[];for(let d of s){a++;let p=Object.create(r);p.item=d,p.index=a,p.this=r.this??r;let m=[];for(let b of n.parts){let y=b.update(p,e,t);b.type===1?m.push(...y):m.push(y)}let f={_$litType$:n,values:m};l.push(f)}return l}},Go={if:Yn,repeat:Jn},fe=(o,r=Go,e={},t)=>{let s=Er(o).renderers;if(t){let a=Er(t).renderers,l=s.super;l!==void 0?e={...s,...e,super:(d,p,m)=>(m={...a,...m,super:(f,b,y)=>mi(t,f,b,y)},l(d,p,m))}:(e={...a,...s,...e},o=t)}else e={...s,...e};return n=>mi(o,n,r,e)};var mi=(o,r,e=Go,t={})=>{let i=Er(o),s=[];for(let a of i.parts){let l=a.update(r,e,t);a.type===1?s.push(...l):s.push(l)}return{_$litType$:i,values:s}},Xo=new Map,Er=o=>{let r=Xo.get(o);return r===void 0&&Xo.set(o,r=Kn(o)),r},Kn=o=>{let r={h:void 0,el:o.cloneNode(!0),parts:[],renderers:{}},e=document.createTreeWalker(r.el.content,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT|NodeFilter.SHOW_COMMENT),t=e.currentNode,i=-1,s=[];for(;(t=e.nextNode())!==null;)if(t.nodeType===Node.COMMENT_NODE)i++;else if(t.nodeType===Node.ELEMENT_NODE){i++;let n=t;if(n.tagName==="TEMPLATE"){let l=n.getAttribute("type"),d=n.getAttribute("name"),p=n.getAttribute("call");if(p!==null||l!==null||d!==null){n.parentNode.insertBefore(document.createComment(""),n),s.push(n);let m;if(p!==null){let f=p.trim(),b=f.startsWith("{{")&&f.endsWith("}}");m=(y,C,A)=>{let q=n.getAttribute("data"),T=q===null?void 0:ui(q,y);return(b?ui(f,y):A[p])?.(T,C,A)}}else l!==null?m=(f,b,y)=>{let C=b[l];return C?.(n,f,b,y)}:(d==="super"?r.renderers.super=(f,b,y)=>{let C=y.super,A=Er(n);return y={...y,...A.renderers},C(f,b,y)}:r.renderers[d]=(f,b,y)=>mi(n,f,b,y),m=(f,b,y)=>{let C=y[d];return C?.(f,b,y)});r.parts.push({type:2,index:i,update:m});continue}}let a=n.getAttributeNames();for(let l of a){let d=n.getAttribute(l),p=d.split(Bo);if(p.length===1){Wo(d)&&n.setAttribute(l,Cr(d));continue}n.removeAttribute(l);let m=l,f=Bn,b=l[0];b==="."?(m=jo(l.substring(1)),f=Wn):b==="?"?(m=l.substring(1),f=Xn):b==="@"&&(m=jo(l.substring(1)),f=Gn);let y=[Cr(p[0])],C=[];for(let A=1;A<p.length;A+=2){let q=p[A];C.push(Es(q,Ts)),y.push(Cr(p[A+1]))}r.parts.push({type:1,index:i,name:m,strings:y,ctor:f,update:(A,q,T)=>C.map(M=>M.evaluate(A))})}}else if(t.nodeType===Node.TEXT_NODE){let n=t,a=n.textContent,l=a.split(Bo);l.length>1?n.textContent=Cr(l[0]):Wo(a)&&(n.textContent=Cr(a));for(let d=1;d<l.length;d+=2){let p=l[d],m=Es(p,Ts);r.parts.push({type:2,index:++i,update:(b,y)=>m.evaluate(b)});let f=new Text(l[d+1].replace("\\{{","{{"));n.parentNode.insertBefore(f,n.nextSibling),n.parentNode.insertBefore(document.createComment(""),n.nextSibling),n=f,e.currentNode=f}}for(let n of s)n.remove();return r};var wr=class extends v{createRenderRoot(){return this}constructor(){super(),this._internals=this.attachInternals(),this._internals.ariaLabel="pagination"}connectedCallback(){super.connectedCallback();let r=this.querySelector("template");this.myTemplate=fe(r)}render(){if(!this.computedContext)return h``;let r=this.computedContext.testParts.flatMap(e=>e.sections.flatMap(t=>t.items));return h` ${r.map(e=>this.myTemplate({item:e,view:this.computedContext.view}))} `}};c([_({context:P,subscribe:!0})],wr.prototype,"computedContext",2),wr=c([g("test-paging-buttons-stamp")],wr);var hi=class{constructor(r){this.G=r}disconnect(){this.G=void 0}reconnect(r){this.G=r}deref(){return this.G}},fi=class{constructor(){this.Y=void 0,this.Z=void 0}get(){return this.Y}pause(){this.Y??=new Promise((r=>this.Z=r))}resume(){this.Z?.(),this.Y=this.Z=void 0}};var Yo=o=>!mo(o)&&typeof o.then=="function",Jo=1073741823,As=class extends xt{constructor(){super(...arguments),this._$Cwt=Jo,this._$Cbt=[],this._$CK=new hi(this),this._$CX=new fi}render(...r){return r.find((e=>!Yo(e)))??V}update(r,e){let t=this._$Cbt,i=t.length;this._$Cbt=e;let s=this._$CK,n=this._$CX;this.isConnected||this.disconnected();for(let a=0;a<e.length&&!(a>this._$Cwt);a++){let l=e[a];if(!Yo(l))return this._$Cwt=a,l;a<i&&l===t[a]||(this._$Cwt=Jo,i=0,Promise.resolve(l).then((async d=>{for(;n.get();)await n.get();let p=s.deref();if(p!==void 0){let m=p._$Cbt.indexOf(l);m>-1&&m<p._$Cwt&&(p._$Cwt=m,p.setValue(d))}})))}return V}disconnected(){this._$CK.disconnect(),this._$CX.pause()}reconnected(){this._$CK.reconnect(this),this._$CX.resume()}},gi=Q(As);var bi=`@layer qti-base, qti-components, qti-utilities, qti-variants, qti-extended;
1562
1562
 
1563
1563
  :root,
1564
1564
  :host {
@@ -3927,6 +3927,14 @@ qti-response-declaration {
3927
3927
  &:focus {
3928
3928
  box-shadow: 0 0 0 var(--qti-focus-border-width) var(--qti-focus-color);
3929
3929
  }
3930
+
3931
+ &:state(candidate-correct) {
3932
+ background-color: var(--qti-correct);
3933
+ }
3934
+
3935
+ &:state(candidate-incorrect) {
3936
+ background-color: var(--qti-incorrect);
3937
+ }
3930
3938
 
3931
3939
  box-sizing: border-box;
3932
3940
 
@@ -5296,7 +5304,7 @@ div.full-correct-response-inline {
5296
5304
  ${this.templateContent}
5297
5305
  <slot></slot>
5298
5306
  ${gi(this.testDoc,h`<span>Loading...</span>`)}
5299
- `}};c([u({type:String,attribute:"test-url"})],ke.prototype,"testURL",2),c([C()],ke.prototype,"testDoc",2),c([C()],ke.prototype,"testXML",2),c([I("testURL",{waitUntilFirstUpdate:!0})],ke.prototype,"handleTestURLChange",1),c([I("testXML",{waitUntilFirstUpdate:!0})],ke.prototype,"handleTestXMLChange",1),ke=c([g("test-container")],ke);var _t=class extends v{render(){let r=this.computedContext?.testParts.flatMap(s=>s.sections.flatMap(n=>n.items)).find(s=>s.active);if(!r||!r.variables)return h``;let e=r.variables.filter(s=>s.type==="response"),t=r.variables.filter(s=>s.type==="outcome"),i=(s,n)=>h`
5307
+ `}};c([u({type:String,attribute:"test-url"})],ke.prototype,"testURL",2),c([E()],ke.prototype,"testDoc",2),c([E()],ke.prototype,"testXML",2),c([I("testURL",{waitUntilFirstUpdate:!0})],ke.prototype,"handleTestURLChange",1),c([I("testXML",{waitUntilFirstUpdate:!0})],ke.prototype,"handleTestXMLChange",1),ke=c([g("test-container")],ke);var _t=class extends v{render(){let r=this.computedContext?.testParts.flatMap(s=>s.sections.flatMap(n=>n.items)).find(s=>s.active);if(!r||!r.variables)return h``;let e=r.variables.filter(s=>s.type==="response"),t=r.variables.filter(s=>s.type==="outcome"),i=(s,n)=>h`
5300
5308
  <h3>${n}</h3>
5301
5309
  <table>
5302
5310
  <thead>
@@ -5345,24 +5353,24 @@ div.full-correct-response-inline {
5345
5353
  }
5346
5354
  `,c([_({context:P,subscribe:!0})],_t.prototype,"computedContext",2),_t=c([g("test-print-item-variables")],_t);var _r=class extends v{createRenderRoot(){return this}constructor(){super(),this._internals=this.attachInternals(),this._internals.ariaLabel="pagination"}connectedCallback(){super.connectedCallback();let r=this.querySelector("template");this.myTemplate=fe(r)}render(){if(!this.computedContext)return h``;let r=this.computedContext.testParts.flatMap(e=>e.sections);return h` ${r.map(e=>this.myTemplate({item:e}))} `}};c([_({context:P,subscribe:!0})],_r.prototype,"computedContext",2),_r=c([g("test-section-buttons-stamp")],_r);var Tt=class extends v{constructor(){super();this.sectionId=null;this.addEventListener("click",()=>this._requestItem(this.sectionId))}_requestItem(e){this.dispatchEvent(new CustomEvent("qti-request-navigation",{composed:!0,bubbles:!0,detail:{type:"section",id:e}}))}render(){return h` <slot></slot> `}};Tt.styles=x`
5347
5355
  :host {
5348
- ${j};
5356
+ ${B};
5349
5357
  }
5350
5358
  :host([disabled]) {
5351
- ${B};
5359
+ ${W};
5352
5360
  }
5353
- `,c([u({type:String,attribute:"section-id"})],Tt.prototype,"sectionId",2),Tt=c([g("test-section-link")],Tt);var Tr=class extends v{render(){return h` <small><pre>${JSON.stringify(this.computedContext,null,2)}</pre></small> `}};c([C(),_({context:P,subscribe:!0})],Tr.prototype,"computedContext",2),Tr=c([g("test-print-context")],Tr);var rt=class extends v{constructor(){super(...arguments);this.debug=!1;this.stampContext={view:"candidate",activeItem:{},activeSection:{items:[]},activeTestpart:{items:[],sections:[]},test:{}}}createRenderRoot(){return this}connectedCallback(){super.connectedCallback();let e=this.querySelector("template");if(!e){this.myTemplate=null;return}this.myTemplate=fe(e)}willUpdate(e){if(!this.computedContext)return;let t=this.computedContext.testParts.find(f=>f.active),i=t?.sections.find(f=>f.active),s=i?.items.find(f=>f.active),{variables:n,...a}=s||{};if(!t||!i||!s)return;let l={...t,items:t.sections.flatMap(f=>f.items.map(({variables:b,...y})=>y)),sections:t.sections.map(f=>({...f,items:f.items.map(({variables:b,...y})=>y)}))},d={...i,items:i.items.map(({variables:f,...b})=>b)},{testParts:p,...m}=this.computedContext;this.stampContext={view:this.computedContext.view,activeItem:a,activeSection:d,activeTestpart:l,test:m},this.dispatchEvent(new CustomEvent("qti-stamp-context-updated",{detail:this.stampContext,bubbles:!0}))}render(){return h` ${this.debug?h`<small><pre>${JSON.stringify(this.stampContext,null,2)}</pre></small>`:R}
5354
- ${this.myTemplate?this.myTemplate(this.stampContext):R}`}};c([u({type:Boolean,reflect:!0})],rt.prototype,"debug",2),c([C(),_({context:P,subscribe:!0})],rt.prototype,"computedContext",2),c([C()],rt.prototype,"stampContext",2),rt=c([g("test-stamp")],rt);var it=class extends v{constructor(){super();this.view="";this.disabled=!1;this.myTemplate=null;this.addEventListener("click",e=>{let t=e.target,i=parseFloat(t.value);t.tagName==="INPUT"&&this._changeOutcomeScore(i)})}createRenderRoot(){return this}connectedCallback(){super.connectedCallback();let e=this.querySelector("template");if(!e){this.myTemplate=null;return}this.myTemplate=fe(e)}_changeOutcomeScore(e){let s=(this.computedContext?.testParts.find(n=>n.active)).sections.flatMap(n=>n.items).find(n=>n.active)?.identifier;this.dispatchEvent(new CustomEvent("test-update-outcome-variable",{detail:{assessmentItemRefId:s,outcomeVariableId:"SCORE",value:e},bubbles:!0}))}render(){let e=this.computedContext?.testParts.flatMap(l=>l.sections.flatMap(d=>d.items)).find(l=>l.active);if(!e||!e.variables)return h``;let t=e.variables.find(l=>l.identifier=="MAXSCORE")?.value,i=e.variables.find(l=>l.identifier=="SCORE"),s=i?.value,n=i?.externalScored!=="human";if(!t||!i)return R;let a=[...Array(Number(t)+1).keys()];return h`${this.myTemplate?this.myTemplate({scores:a,score:s,disabled:n}):R}`}};c([u({type:String,attribute:"view"})],it.prototype,"view",2),c([u({type:Boolean})],it.prototype,"disabled",2),c([_({context:P,subscribe:!0})],it.prototype,"computedContext",2),it=c([g("test-scoring-buttons")],it);var Ar=class extends v{createRenderRoot(){return this}connectedCallback(){super.connectedCallback();let r=this.querySelector("template");if(!r){this.myTemplate=null;return}this.myTemplate=fe(r)}_switchView(r){this.dispatchEvent(new CustomEvent("on-test-switch-view",{composed:!0,bubbles:!0,detail:r}))}firstUpdated(r){this.addEventListener("click",()=>{this.sessionContext?.view==="scorer"?this._switchView("candidate"):this._switchView("scorer")})}render(){return h`${this.myTemplate?this.myTemplate({view:this.sessionContext?.view}):R}`}};c([_({context:ze,subscribe:!0})],Ar.prototype,"sessionContext",2),Ar=c([g("test-view-toggle")],Ar);var At=class extends v{constructor(){super(...arguments);this.view=null}render(){let e=this.computedContext?.testParts.flatMap(l=>l.sections.flatMap(d=>d.items)).find(l=>l.active);if(!e||!e.variables)return h``;if(e.category==="dep-informational")return h`<div>${this.dataset.informational}</div>`;let t=e?.variables.find(l=>l.identifier==="completionStatus")?.value,i=e?.variables.find(l=>l.identifier=="SCORE"),s=parseFloat(i?.value),n=e.externalScored;return h`<div>${t!=="completed"?this.dataset.textNoResponse:!n&&s!==void 0&&!Number.isNaN(s)?s>0?this.dataset.textCorrect:this.dataset.textIncorrect:n==="externalMachine"?Number.isNaN(s)||s===void 0?this.dataset.scoreUnknown:`We hebben je antwoord ${s===0?"geen punten":s==1?"\xE9\xE9n punt":`${s} punten`} gegeven. Je kunt je score zelf aanpassen als je denkt dat dat niet klopt.`:n==="human"?Number.isNaN(s)?"":"Deze score heb je zelf toegekend.":this.dataset.inProgress}</div>`}};c([_({context:P,subscribe:!0})],At.prototype,"computedContext",2),c([u({type:String,attribute:"view"})],At.prototype,"view",2),At=c([g("test-scoring-feedback")],At);var kr=class extends v{constructor(){super(),this.addEventListener("click",()=>{this.dispatchEvent(new CustomEvent("test-end-attempt",{bubbles:!0})),this.dispatchEvent(new CustomEvent("test-show-correct-response",{detail:!0,bubbles:!0}));let e=this.closest("qti-test").querySelector("test-container");Array.from(e.shadowRoot.querySelectorAll("[view]")).forEach(i=>{i.classList.toggle("show",!0)})})}render(){return h` <slot></slot> `}};kr.styles=x`
5361
+ `,c([u({type:String,attribute:"section-id"})],Tt.prototype,"sectionId",2),Tt=c([g("test-section-link")],Tt);var Tr=class extends v{render(){return h` <small><pre>${JSON.stringify(this.computedContext,null,2)}</pre></small> `}};c([E(),_({context:P,subscribe:!0})],Tr.prototype,"computedContext",2),Tr=c([g("test-print-context")],Tr);var rt=class extends v{constructor(){super(...arguments);this.debug=!1;this.stampContext={view:"candidate",activeItem:{},activeSection:{items:[]},activeTestpart:{items:[],sections:[]},test:{}}}createRenderRoot(){return this}connectedCallback(){super.connectedCallback();let e=this.querySelector("template");if(!e){this.myTemplate=null;return}this.myTemplate=fe(e)}willUpdate(e){if(!this.computedContext)return;let t=this.computedContext.testParts.find(f=>f.active),i=t?.sections.find(f=>f.active),s=i?.items.find(f=>f.active),{variables:n,...a}=s||{};if(!t||!i||!s)return;let l={...t,items:t.sections.flatMap(f=>f.items.map(({variables:b,...y})=>y)),sections:t.sections.map(f=>({...f,items:f.items.map(({variables:b,...y})=>y)}))},d={...i,items:i.items.map(({variables:f,...b})=>b)},{testParts:p,...m}=this.computedContext;this.stampContext={view:this.computedContext.view,activeItem:a,activeSection:d,activeTestpart:l,test:m},this.dispatchEvent(new CustomEvent("qti-stamp-context-updated",{detail:this.stampContext,bubbles:!0}))}render(){return h` ${this.debug?h`<small><pre>${JSON.stringify(this.stampContext,null,2)}</pre></small>`:R}
5362
+ ${this.myTemplate?this.myTemplate(this.stampContext):R}`}};c([u({type:Boolean,reflect:!0})],rt.prototype,"debug",2),c([E(),_({context:P,subscribe:!0})],rt.prototype,"computedContext",2),c([E()],rt.prototype,"stampContext",2),rt=c([g("test-stamp")],rt);var it=class extends v{constructor(){super();this.view="";this.disabled=!1;this.myTemplate=null;this.addEventListener("click",e=>{let t=e.target,i=parseFloat(t.value);t.tagName==="INPUT"&&this._changeOutcomeScore(i)})}createRenderRoot(){return this}connectedCallback(){super.connectedCallback();let e=this.querySelector("template");if(!e){this.myTemplate=null;return}this.myTemplate=fe(e)}_changeOutcomeScore(e){let s=(this.computedContext?.testParts.find(n=>n.active)).sections.flatMap(n=>n.items).find(n=>n.active)?.identifier;this.dispatchEvent(new CustomEvent("test-update-outcome-variable",{detail:{assessmentItemRefId:s,outcomeVariableId:"SCORE",value:e},bubbles:!0}))}render(){let e=this.computedContext?.testParts.flatMap(l=>l.sections.flatMap(d=>d.items)).find(l=>l.active);if(!e||!e.variables)return h``;let t=e.variables.find(l=>l.identifier=="MAXSCORE")?.value,i=e.variables.find(l=>l.identifier=="SCORE"),s=i?.value,n=i?.externalScored!=="human";if(!t||!i)return R;let a=[...Array(Number(t)+1).keys()];return h`${this.myTemplate?this.myTemplate({scores:a,score:s,disabled:n}):R}`}};c([u({type:String,attribute:"view"})],it.prototype,"view",2),c([u({type:Boolean})],it.prototype,"disabled",2),c([_({context:P,subscribe:!0})],it.prototype,"computedContext",2),it=c([g("test-scoring-buttons")],it);var Ar=class extends v{createRenderRoot(){return this}connectedCallback(){super.connectedCallback();let r=this.querySelector("template");if(!r){this.myTemplate=null;return}this.myTemplate=fe(r)}_switchView(r){this.dispatchEvent(new CustomEvent("on-test-switch-view",{composed:!0,bubbles:!0,detail:r}))}firstUpdated(r){this.addEventListener("click",()=>{this.sessionContext?.view==="scorer"?this._switchView("candidate"):this._switchView("scorer")})}render(){return h`${this.myTemplate?this.myTemplate({view:this.sessionContext?.view}):R}`}};c([_({context:ze,subscribe:!0})],Ar.prototype,"sessionContext",2),Ar=c([g("test-view-toggle")],Ar);var At=class extends v{constructor(){super(...arguments);this.view=null}render(){let e=this.computedContext?.testParts.flatMap(l=>l.sections.flatMap(d=>d.items)).find(l=>l.active);if(!e||!e.variables)return h``;if(e.category==="dep-informational")return h`<div>${this.dataset.informational}</div>`;let t=e?.variables.find(l=>l.identifier==="completionStatus")?.value,i=e?.variables.find(l=>l.identifier=="SCORE"),s=parseFloat(i?.value),n=e.externalScored;return h`<div>${t!=="completed"?this.dataset.textNoResponse:!n&&s!==void 0&&!Number.isNaN(s)?s>0?this.dataset.textCorrect:this.dataset.textIncorrect:n==="externalMachine"?Number.isNaN(s)||s===void 0?this.dataset.scoreUnknown:`We hebben je antwoord ${s===0?"geen punten":s==1?"\xE9\xE9n punt":`${s} punten`} gegeven. Je kunt je score zelf aanpassen als je denkt dat dat niet klopt.`:n==="human"?Number.isNaN(s)?"":"Deze score heb je zelf toegekend.":this.dataset.inProgress}</div>`}};c([_({context:P,subscribe:!0})],At.prototype,"computedContext",2),c([u({type:String,attribute:"view"})],At.prototype,"view",2),At=c([g("test-scoring-feedback")],At);var kr=class extends v{constructor(){super(),this.addEventListener("click",()=>{this.dispatchEvent(new CustomEvent("test-end-attempt",{bubbles:!0})),this.dispatchEvent(new CustomEvent("test-show-correct-response",{detail:!0,bubbles:!0}));let e=this.closest("qti-test").querySelector("test-container");Array.from(e.shadowRoot.querySelectorAll("[view]")).forEach(i=>{i.classList.toggle("show",!0)})})}render(){return h` <slot></slot> `}};kr.styles=x`
5355
5363
  :host {
5356
- ${j};
5364
+ ${B};
5357
5365
  }
5358
5366
  :host([disabled]) {
5359
- ${B};
5367
+ ${W};
5360
5368
  }
5361
5369
  `,kr=c([g("test-check-item")],kr);var Se=class extends v{constructor(){super(...arguments);this.itemURL=null;this.itemDoc=null;this.itemXML=null;this.templateContent=null}async handleItemURLChange(){if(this.itemURL)try{let e=await Le().load(this.itemURL);this.itemDoc=e.htmlDoc()}catch(e){console.error("Error loading or parsing XML:",e)}}handleItemXMLChange(){if(this.itemXML)try{this.itemDoc=Le().parse(this.itemXML).htmlDoc()}catch(e){console.error("Error parsing XML:",e)}}async connectedCallback(){super.connectedCallback(),this.initializeTemplateContent(),this.applyStyles(),this.itemURL&&this.handleItemURLChange(),this.itemXML&&this.handleItemXMLChange()}initializeTemplateContent(){let e=this.querySelector("template");this.templateContent=e?e.content:h``}applyStyles(){let e=new CSSStyleSheet;e.replaceSync(bi),this.shadowRoot.adoptedStyleSheets=[e]}render(){return h`
5362
5370
  ${this.templateContent}
5363
5371
  <slot></slot>
5364
5372
  ${gi(this.itemDoc,h`<span>Loading...</span>`)}
5365
- `}};c([u({type:String,attribute:"item-url"})],Se.prototype,"itemURL",2),c([C()],Se.prototype,"itemDoc",2),c([C()],Se.prototype,"itemXML",2),c([I("itemURL",{waitUntilFirstUpdate:!0})],Se.prototype,"handleItemURLChange",1),c([I("itemXML",{waitUntilFirstUpdate:!0})],Se.prototype,"handleItemXMLChange",1),Se=c([g("item-container")],Se);var kt=Symbol("computedItemContext");var St=class extends v{render(){let r=this.computedContext;if(!r||!r.variables)return h``;let e=r.variables.filter(s=>s.type==="response"),t=r.variables.filter(s=>s.type==="outcome"),i=(s,n)=>h`
5373
+ `}};c([u({type:String,attribute:"item-url"})],Se.prototype,"itemURL",2),c([E()],Se.prototype,"itemDoc",2),c([E()],Se.prototype,"itemXML",2),c([I("itemURL",{waitUntilFirstUpdate:!0})],Se.prototype,"handleItemURLChange",1),c([I("itemXML",{waitUntilFirstUpdate:!0})],Se.prototype,"handleItemXMLChange",1),Se=c([g("item-container")],Se);var kt=Symbol("computedItemContext");var St=class extends v{render(){let r=this.computedContext;if(!r||!r.variables)return h``;let e=r.variables.filter(s=>s.type==="response"),t=r.variables.filter(s=>s.type==="outcome"),i=(s,n)=>h`
5366
5374
  <h3>${n}</h3>
5367
5375
  <table>
5368
5376
  <thead>
@@ -5422,7 +5430,7 @@ div.full-correct-response-inline {
5422
5430
  `,Qo=x`
5423
5431
  cursor: not-allowed;
5424
5432
  opacity: 0.8;
5425
- `,A0=x`
5433
+ `,k0=x`
5426
5434
  ${Ko};
5427
5435
  border: 1px solid gray;
5428
5436
  `;var te=class extends v{constructor(){super(...arguments);this.shown=!1;this.disabled=!1;this.showCorrectText="Show correct response";this.hideCorrectText="Hide correct response";this.noCorrectResponseText="No correct response specified";this._hasCorrectResponse=!1;this._previousActiveItem=""}updated(){if(!this._hasCorrectResponse||this._previousActiveItem!==this.computedContext?.identifier){this._previousActiveItem=this.computedContext?.identifier;let e=!!this.computedContext?.variables.some(i=>i.correctResponse),t=!!this.computedContext?.variables.some(i=>i.mapping?.mapEntries?.length>0||i.areaMapping?.areaMapEntries?.length>0);this._hasCorrectResponse=e||t}this.disabled=!this._hasCorrectResponse}_toggleState(){this.disabled||this.dispatchEvent(new CustomEvent("item-show-correct-response",{detail:!this.shown,bubbles:!0}))}_getDisplayedText(){return this.disabled?this.noCorrectResponseText:this.shown?this.hideCorrectText:this.showCorrectText}render(){return h` <div @click="${this._toggleState}">${this._getDisplayedText()}</div> `}};te.styles=x`
@@ -5432,7 +5440,7 @@ div.full-correct-response-inline {
5432
5440
  :host([disabled]) {
5433
5441
  ${Qo};
5434
5442
  }
5435
- `,c([_({context:kt,subscribe:!0})],te.prototype,"computedContext",2),c([u({type:Boolean,reflect:!0})],te.prototype,"shown",2),c([u({type:Boolean,reflect:!0})],te.prototype,"disabled",2),c([u({type:String})],te.prototype,"showCorrectText",2),c([u({type:String})],te.prototype,"hideCorrectText",2),c([u({type:String})],te.prototype,"noCorrectResponseText",2),te=c([g("item-show-correct-response")],te);var Rt=class extends v{constructor(){super();this.configContext={};this._onItemContextChanged=this._handleItemContextChanged.bind(this);this._onAssessmentItemConnected=this._handleAssessmentItemConnected.bind(this);this._onHandleShowCorrectResponse=this._handleShowCorrectResponse.bind(this);this._onHandleShowCandidateCorrection=this._handleShowCandidateCorrection.bind(this);this._onHandleSwitchCorrectResponseMode=this._handleSwitchCorrectResponseMode.bind(this);this.addEventListener("qti-item-context-updated",this._onItemContextChanged),this.addEventListener("qti-assessment-item-connected",this._onAssessmentItemConnected),this.addEventListener("item-show-correct-response",this._onHandleShowCorrectResponse),this.addEventListener("item-show-candidate-correction",this._onHandleShowCandidateCorrection),this.addEventListener("item-switch-correct-response-mode",this._onHandleSwitchCorrectResponseMode)}_handleItemContextChanged(e){this._updateItemVariablesInTestContext(e.detail.itemContext.identifier,e.detail?.itemContext?.variables||[])}_handleAssessmentItemConnected(e){let t=e.detail._context.variables;this._qtiAssessmentItem=e.detail,this.computedContext=this.computedContext?.identifier===this._qtiAssessmentItem.identifier?{...this.computedContext,title:this._qtiAssessmentItem.title}:{identifier:this._qtiAssessmentItem.identifier,title:this._qtiAssessmentItem.title,adaptive:this._qtiAssessmentItem.getAttribute("adaptive")?.toLowerCase()==="true"||!1,variables:t,correctResponseMode:"internal"},this._updateItemVariablesInTestContext(this._qtiAssessmentItem.identifier,t||[])}_handleShowCorrectResponse(e){this._qtiAssessmentItem&&this._qtiAssessmentItem.showCorrectResponse(e.detail)}_handleShowCandidateCorrection(e){this._qtiAssessmentItem&&this._qtiAssessmentItem.showCandidateCorrection(e.detail)}_handleSwitchCorrectResponseMode(e){this._handleShowCorrectResponse(new CustomEvent("item-show-correct-response",{detail:!1,bubbles:!0})),this.configContext={...this.configContext,correctResponseMode:e.detail}}_updateItemVariablesInTestContext(e,t){let i=t?.find(p=>p.identifier=="SCORE")?.value,s=parseFloat(i?.toString()),n=t?.find(p=>p.identifier==="completionStatus")?.value,a=s!==void 0&&!isNaN(s)&&s>0,l=s!==void 0&&!isNaN(s)&&s<=0,d=n==="completed";this.computedContext={...this.computedContext,identifier:e,correct:a,incorrect:l,completed:d,variables:t}}render(){return h`<slot></slot>`}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-item-context-changed",this._onItemContextChanged),this.removeEventListener("qti-assessment-item-connected",this._onAssessmentItemConnected)}};c([C(),X({context:kt})],Rt.prototype,"computedContext",2),c([C(),X({context:oe})],Rt.prototype,"configContext",2),Rt=c([g("qti-item")],Rt);var en={name:"@citolab/qti-components",repository:{type:"git",url:"git+https://github.com/Citolab/qti-components.git"},description:"QTI webcomponents",author:{name:"Patrick de Klein"},contributors:[{name:"Sander Looise"},{name:"Marcel Hoekstra"}],license:"GPLv3",private:!1,engines:{node:">=22.0.0"},version:"7.14.1",type:"module",main:"./dist/index.js",types:"./dist/index.d.ts",sideEffects:!0,exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.js"},"./exports/*":{import:"./dist/exports/*"},"./qti-components":{types:"./dist/qti-components/index.d.ts",import:"./dist/qti-components/index.js"},"./qti-item":{types:"./dist/qti-item/index.d.ts",import:"./dist/qti-item/index.js"},"./qti-test":{types:"./dist/qti-test/index.d.ts",import:"./dist/qti-test/index.js"},"./qti-loader":{types:"./dist/qti-loader/index.d.ts",import:"./dist/qti-loader/index.js"},"./qti-transformers":{types:"./dist/qti-transformers/index.d.ts",import:"./dist/qti-transformers/index.js"},"./customElements":"./custom-elements.json","./react":"./dist/qti-components-jsx.d.ts","./item.css":"./dist/item.css","./cdn/*":"./cdn/*","./package.json":"./package.json"},files:["dist","cdn","custom-elements.json"],scripts:{storybook:"run-p storybook:dev cem:watch",watch:'nodemon --watch src --ext ts,css --exec "run-s tsup cem css && yalc push"',"-----------------------cmds--":"-","pre-commit":"run-s lint stylelint madge","commit-msg":"commitlint --edit","build-storybook":"npm run cem && storybook build","-----------------------scripts--":"-",build:"run-p cem css tsup","storybook:dev":"storybook dev -p 6006",cem:"cem analyze","cem:watch":"cem analyze --watch",css:"postcss src/item.css -d dist -m",ci:"npm ci",tsup:"tsup",publint:"publint",lint:"eslint src/**/*.ts",stylelint:'stylelint "src/**/*.css"',test:"vitest run",attw:"attw --profile esm-only --pack --exclude-entrypoints ./item.css ./react",chromatic:"node chromatic-runner.cjs",clean:"rm -rf dist cdn",madge:"madge --circular --extensions ts src",commitlint:"commitlint --edit","-----------------------npm--":"-",prepare:"husky"},peerDependencies:{"@heximal/templates":"^0.1.5","@lit/context":"^1.1.3",lit:"^3.2.1"},devDependencies:{"@arethetypeswrong/cli":"^0.18.2","@chromatic-com/storybook":"^4.1.1","@commitlint/cli":"^19.8.1","@commitlint/config-conventional":"^19.8.1","@custom-elements-manifest/analyzer":"^0.10.4","@eslint/js":"^9.29.0","@heximal/templates":"0.1.5","@lit/context":"^1.1.5","@open-wc/lit-helpers":"^0.7.0","@storybook/addon-a11y":"^9.1.5","@storybook/addon-docs":"^9.1.5","@storybook/addon-links":"^9.1.5","@storybook/addon-themes":"^9.1.5","@storybook/addon-vitest":"^9.1.5","@storybook/web-components-vite":"^9.1.5","@swc/core":"^1.12.1","@testing-library/dom":"^10.4.0","@types/dom-view-transitions":"^1.0.6","@types/node":"^24.0.3","@vitest/browser":"^3.2.4","@vitest/coverage-v8":"^3.2.4","@vitest/ui":"^3.2.4","@wc-toolkit/cem-inheritance":"^1.1.0","@wc-toolkit/cem-sorter":"^1.0.1","@wc-toolkit/cem-utilities":"^1.3.0","@wc-toolkit/changelog":"^1.0.1","@wc-toolkit/jsx-types":"^1.2.2","@wc-toolkit/storybook-helpers":"^9.0.0","@wc-toolkit/type-parser":"^1.1.0",autoprefixer:"^10.4.21",chromatic:"^13.0.0","custom-element-vs-code-integration":"^1.5.0","custom-elements-manifest-deprecator":"^1.2.0",dotenv:"^16.5.0",eslint:"^9.29.0","eslint-import-resolver-typescript":"^4.4.3","eslint-plugin-import":"^2.31.0","eslint-plugin-lit":"^2.1.1","eslint-plugin-lit-a11y":"^5.0.1","eslint-plugin-react":"^7.37.5","eslint-plugin-sort-imports-es6-autofix":"^0.6.0","eslint-plugin-storybook":"^9.1.5","eslint-plugin-wc":"^3.0.1","fast-xml-parser":"^5.2.5",globals:"^16.2.0",globby:"^14.1.0",husky:"^9.1.7",lit:"^3.3.0",madge:"^8.0.0","mdx-mermaid":"^2.0.3",mermaid:"^11.12.0",msw:"^2.11.5","msw-storybook-addon":"^2.0.5",nodemon:"^3.1.10","npm-run-all":"^4.1.5","path-browserify":"^1.0.1","pkg-pr-new":"^0.0.51",playwright:"^1.53.0",postcss:"^8.5.6","postcss-class-apply":"^4.0.1","postcss-cli":"^11.0.1","postcss-import":"^16.1.1","postcss-nesting":"^13.0.2",prettier:"3.5.3","prettier-v2":"npm:prettier@2.8.8",publint:"^0.3.12","remark-gfm":"^4.0.1","shadow-dom-testing-library":"^1.12.0",storybook:"^9.1.5","storybook-addon-tag-badges":"^2.0.1",stylelint:"^16.20.0","stylelint-config-standard":"^38.0.0","stylelint-prettier":"^5.0.3",tsup:"^8.5.0",typescript:"^5.8.3","typescript-eslint":"^8.34.1",vite:"^6.3.5","vite-tsconfig-paths":"^5.1.4",vitest:"^3.2.4",yalc:"^1.0.0-pre.53"},optionalDependencies:{"@rollup/rollup-linux-x64-gnu":"^4.43.0"},customElements:"custom-elements.json",bugs:{url:"https://github.com/Citolab/qti-components/issues"},homepage:"https://github.com/Citolab/qti-components#readme",overrides:{storybook:"$storybook"},msw:{workerDirectory:["public"]}};console.info("%cC\xBFTO%cLab%c: qti-components v%c%s%c loaded",'font-family: "PT Sans", font-weight:bold; color:green; font-size: smaller;vertical-align: sub',"font-weight:bold; color:green","font-weight:unset","font-weight:bold; color:#2563eb",en.version,"font-weight:unset");export{Ki as INITIAL_TEST_CONTEXT,Se as ItemContainer,te as ItemShowCorrectResponse,St as PrintItemVariables,Jr as QtiAnd,G as QtiAssessmentItem,_e as QtiAssessmentItemRef,Te as QtiAssessmentSection,pt as QtiAssessmentStimulusRef,Oi as QtiAssessmentStimulusRefConnectedEvent,et as QtiAssessmentTest,Jt as QtiAssociableHotspot,ut as QtiAssociateInteraction,Kr as QtiBaseValue,mt as QtiChoiceInteraction,Br as QtiCompanionMaterialsInfo,Gi as QtiContainerSize,Yi as QtiContains,oi as QtiContentBody,Ji as QtiCorrect,ve as QtiCustomInteraction,Wt as QtiCustomOperator,qt as QtiDefault,ys as QtiDelete,Pe as QtiEndAttemptInteraction,Qr as QtiEqual,Zr as QtiEqualRounded,U as QtiExtendedTextInteraction,Gt as QtiFeedbackBlock,Yt as QtiFeedbackInline,ss as QtiFieldValue,gt as QtiGap,ht as QtiGapImg,Kt as QtiGapMatchInteraction,ft as QtiGapText,Qi as QtiGcd,le as QtiGraphicAssociateInteraction,Zt as QtiGraphicGapMatchInteraction,Qt as QtiGraphicOrderInteraction,es as QtiGt,ts as QtiGte,Qe as QtiHotspotChoice,er as QtiHotspotInteraction,rr as QtiHottext,tr as QtiHottextInteraction,br as QtiIndex,sr as QtiInlineChoice,ye as QtiInlineChoiceInteraction,is as QtiIsNull,Rt as QtiItem,cr as QtiItemBody,ur as QtiLookupOutcomeValue,os as QtiLt,ns as QtiLte,ei as QtiMapResponse,ti as QtiMapResponsePoint,as as QtiMatch,xe as QtiMatchInteraction,ri as QtiMathOperator,or as QtiMediaInteraction,ls as QtiMember,Ze as QtiModalFeedback,cs as QtiMultiple,ds as QtiNot,rs as QtiNull,ps as QtiOr,qe as QtiOrderInteraction,us as QtiOrdered,me as QtiOutcomeDeclaration,dr as QtiOutcomeProcessing,Ui as QtiOutcomeProcessingProcessor,z as QtiPortableCustomInteraction,Di as QtiPositionObjectInteraction,nr as QtiPositionObjectStage,ms as QtiPower,gr as QtiPrintedVariable,hs as QtiProduct,Gr as QtiPrompt,vs as QtiRandom,Ct as QtiRandomInteger,ji as QtiResponseCondition,we as QtiResponseDeclaration,mr as QtiResponseElse,Xi as QtiResponseElseIf,hr as QtiResponseIf,pr as QtiResponseProcessing,Zi as QtiRound,fr as QtiRoundTo,ue as QtiRubricBlock,de as QtiRule,ce as QtiSelectPointInteraction,Bi as QtiSetOutcomeValue,Wi as QtiSetOutcomeValueRule,De as QtiSimpleAssociableChoice,Ce as QtiSimpleChoice,Ee as QtiSliderInteraction,si as QtiStringMatch,ni as QtiStylesheet,ii as QtiSubtract,fs as QtiSum,gs as QtiSumExpression,ai as QtiTest,vr as QtiTestFeedback,Ae as QtiTestPart,J as QtiTextEntryInteraction,lr as QtiUploadInteraction,bs as QtiVariable,kr as TestCheckItem,ke as TestContainer,yr as TestEndAttempt,wt as TestItemLink,Z as TestNavigation,Fe as TestNext,wr as TestPagingButtonsStamp,Ue as TestPrev,Tr as TestPrintContext,_t as TestPrintVariables,it as TestScoringButtons,At as TestScoringFeedback,_r as TestSectionButtonsStamp,Tt as TestSectionLink,ee as TestShowCorrectResponse,rt as TestStamp,W as TestView,Ar as TestViewToggle,Mn as qtiAndMixin,In as qtiSubtractMixin,pe as testContext};
5443
+ `,c([_({context:kt,subscribe:!0})],te.prototype,"computedContext",2),c([u({type:Boolean,reflect:!0})],te.prototype,"shown",2),c([u({type:Boolean,reflect:!0})],te.prototype,"disabled",2),c([u({type:String})],te.prototype,"showCorrectText",2),c([u({type:String})],te.prototype,"hideCorrectText",2),c([u({type:String})],te.prototype,"noCorrectResponseText",2),te=c([g("item-show-correct-response")],te);var Rt=class extends v{constructor(){super();this.configContext={};this._onItemContextChanged=this._handleItemContextChanged.bind(this);this._onAssessmentItemConnected=this._handleAssessmentItemConnected.bind(this);this._onHandleShowCorrectResponse=this._handleShowCorrectResponse.bind(this);this._onHandleShowCandidateCorrection=this._handleShowCandidateCorrection.bind(this);this._onHandleSwitchCorrectResponseMode=this._handleSwitchCorrectResponseMode.bind(this);this.addEventListener("qti-item-context-updated",this._onItemContextChanged),this.addEventListener("qti-assessment-item-connected",this._onAssessmentItemConnected),this.addEventListener("item-show-correct-response",this._onHandleShowCorrectResponse),this.addEventListener("item-show-candidate-correction",this._onHandleShowCandidateCorrection),this.addEventListener("item-switch-correct-response-mode",this._onHandleSwitchCorrectResponseMode)}_handleItemContextChanged(e){this._updateItemVariablesInTestContext(e.detail.itemContext.identifier,e.detail?.itemContext?.variables||[])}_handleAssessmentItemConnected(e){let t=e.detail._context.variables;this._qtiAssessmentItem=e.detail,this.computedContext=this.computedContext?.identifier===this._qtiAssessmentItem.identifier?{...this.computedContext,title:this._qtiAssessmentItem.title}:{identifier:this._qtiAssessmentItem.identifier,title:this._qtiAssessmentItem.title,adaptive:this._qtiAssessmentItem.getAttribute("adaptive")?.toLowerCase()==="true"||!1,variables:t,correctResponseMode:"internal"},this._updateItemVariablesInTestContext(this._qtiAssessmentItem.identifier,t||[])}_handleShowCorrectResponse(e){this._qtiAssessmentItem&&this._qtiAssessmentItem.showCorrectResponse(e.detail)}_handleShowCandidateCorrection(e){this._qtiAssessmentItem&&this._qtiAssessmentItem.showCandidateCorrection(e.detail)}_handleSwitchCorrectResponseMode(e){this._handleShowCorrectResponse(new CustomEvent("item-show-correct-response",{detail:!1,bubbles:!0})),this.configContext={...this.configContext,correctResponseMode:e.detail}}_updateItemVariablesInTestContext(e,t){let i=t?.find(p=>p.identifier=="SCORE")?.value,s=parseFloat(i?.toString()),n=t?.find(p=>p.identifier==="completionStatus")?.value,a=s!==void 0&&!isNaN(s)&&s>0,l=s!==void 0&&!isNaN(s)&&s<=0,d=n==="completed";this.computedContext={...this.computedContext,identifier:e,correct:a,incorrect:l,completed:d,variables:t}}render(){return h`<slot></slot>`}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-item-context-changed",this._onItemContextChanged),this.removeEventListener("qti-assessment-item-connected",this._onAssessmentItemConnected)}};c([E(),G({context:kt})],Rt.prototype,"computedContext",2),c([E(),G({context:oe})],Rt.prototype,"configContext",2),Rt=c([g("qti-item")],Rt);var en={name:"@citolab/qti-components",repository:{type:"git",url:"git+https://github.com/Citolab/qti-components.git"},description:"QTI webcomponents",author:{name:"Patrick de Klein"},contributors:[{name:"Sander Looise"},{name:"Marcel Hoekstra"}],license:"GPLv3",private:!1,engines:{node:">=22.0.0"},version:"7.14.3",type:"module",main:"./dist/index.js",types:"./dist/index.d.ts",sideEffects:!0,exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.js"},"./exports/*":{import:"./dist/exports/*"},"./qti-components":{types:"./dist/qti-components/index.d.ts",import:"./dist/qti-components/index.js"},"./qti-item":{types:"./dist/qti-item/index.d.ts",import:"./dist/qti-item/index.js"},"./qti-test":{types:"./dist/qti-test/index.d.ts",import:"./dist/qti-test/index.js"},"./qti-loader":{types:"./dist/qti-loader/index.d.ts",import:"./dist/qti-loader/index.js"},"./qti-transformers":{types:"./dist/qti-transformers/index.d.ts",import:"./dist/qti-transformers/index.js"},"./customElements":"./custom-elements.json","./react":"./dist/qti-components-jsx.d.ts","./item.css":"./dist/item.css","./cdn/*":"./cdn/*","./package.json":"./package.json"},files:["dist","cdn","custom-elements.json"],scripts:{storybook:"run-p storybook:dev cem:watch",watch:'nodemon --watch src --ext ts,css --exec "run-s tsup cem css && yalc push"',"-----------------------cmds--":"-","pre-commit":"run-s lint stylelint madge","commit-msg":"commitlint --edit","build-storybook":"npm run cem && storybook build","-----------------------scripts--":"-",build:"run-p cem css tsup","storybook:dev":"storybook dev -p 6006 --no-open",cem:"cem analyze","cem:watch":"cem analyze --watch",css:"postcss src/item.css -d dist -m",ci:"npm ci",tsup:"tsup",publint:"publint",lint:"eslint src/**/*.ts",stylelint:'stylelint "src/**/*.css"',test:"vitest run",attw:"attw --profile esm-only --pack --exclude-entrypoints ./item.css ./react",chromatic:"node chromatic-runner.cjs",clean:"rm -rf dist cdn",madge:"madge --circular --extensions ts src",commitlint:"commitlint --edit","-----------------------npm--":"-",prepare:"husky && npm run build"},peerDependencies:{"@heximal/templates":"^0.1.5","@lit/context":"^1.1.3",lit:"^3.2.1"},devDependencies:{"@arethetypeswrong/cli":"^0.18.2","@chromatic-com/storybook":"^4.1.1","@commitlint/cli":"^19.8.1","@commitlint/config-conventional":"^19.8.1","@custom-elements-manifest/analyzer":"^0.10.4","@eslint/js":"^9.29.0","@heximal/templates":"0.1.5","@lit/context":"^1.1.5","@open-wc/lit-helpers":"^0.7.0","@storybook/addon-a11y":"^9.1.5","@storybook/addon-docs":"^9.1.5","@storybook/addon-links":"^9.1.5","@storybook/addon-themes":"^9.1.5","@storybook/addon-vitest":"^9.1.5","@storybook/web-components-vite":"^9.1.5","@swc/core":"^1.12.1","@testing-library/dom":"^10.4.0","@types/dom-view-transitions":"^1.0.6","@types/node":"^24.0.3","@vitest/browser":"^3.2.4","@vitest/coverage-v8":"^3.2.4","@vitest/ui":"^3.2.4","@wc-toolkit/cem-inheritance":"^1.2.2","@wc-toolkit/cem-sorter":"^1.0.1","@wc-toolkit/cem-utilities":"^1.5.0","@wc-toolkit/changelog":"^1.0.2","@wc-toolkit/jsx-types":"^1.4.3","@wc-toolkit/storybook-helpers":"^9.0.1","@wc-toolkit/type-parser":"^1.2.0",autoprefixer:"^10.4.21",chromatic:"^13.0.0","custom-element-vs-code-integration":"^1.5.0","custom-elements-manifest-deprecator":"^1.2.0",dotenv:"^16.5.0",eslint:"^9.29.0","eslint-import-resolver-typescript":"^4.4.3","eslint-plugin-import":"^2.31.0","eslint-plugin-lit":"^2.1.1","eslint-plugin-lit-a11y":"^5.0.1","eslint-plugin-react":"^7.37.5","eslint-plugin-sort-imports-es6-autofix":"^0.6.0","eslint-plugin-storybook":"^9.1.5","eslint-plugin-wc":"^3.0.1","fast-xml-parser":"^5.2.5",globals:"^16.2.0",globby:"^14.1.0",husky:"^9.1.7",lit:"^3.3.0",madge:"^8.0.0","mdx-mermaid":"^2.0.3",mermaid:"^11.12.0",msw:"^2.11.5","msw-storybook-addon":"^2.0.5",nodemon:"^3.1.10","npm-run-all":"^4.1.5","path-browserify":"^1.0.1","pkg-pr-new":"^0.0.51",playwright:"^1.53.0",postcss:"^8.5.6","postcss-class-apply":"^4.0.1","postcss-cli":"^11.0.1","postcss-import":"^16.1.1","postcss-nesting":"^13.0.2",prettier:"3.5.3","prettier-v2":"npm:prettier@2.8.8",publint:"^0.3.12","remark-gfm":"^4.0.1","shadow-dom-testing-library":"^1.12.0",storybook:"^9.1.5","storybook-addon-tag-badges":"^2.0.1",stylelint:"^16.20.0","stylelint-config-standard":"^38.0.0","stylelint-prettier":"^5.0.3",tsup:"^8.5.0",typescript:"^5.8.3","typescript-eslint":"^8.34.1",vite:"^6.3.5","vite-tsconfig-paths":"^5.1.4",vitest:"^3.2.4",yalc:"^1.0.0-pre.53"},optionalDependencies:{"@rollup/rollup-linux-x64-gnu":"^4.43.0"},customElements:"custom-elements.json",bugs:{url:"https://github.com/Citolab/qti-components/issues"},homepage:"https://github.com/Citolab/qti-components#readme",overrides:{storybook:"$storybook"},msw:{workerDirectory:["public"]}};console.info("%cC\xBFTO%cLab%c: qti-components v%c%s%c loaded",'font-family: "PT Sans", font-weight:bold; color:green; font-size: smaller;vertical-align: sub',"font-weight:bold; color:green","font-weight:unset","font-weight:bold; color:#2563eb",en.version,"font-weight:unset");export{Ki as INITIAL_TEST_CONTEXT,Se as ItemContainer,te as ItemShowCorrectResponse,St as PrintItemVariables,Jr as QtiAnd,Y as QtiAssessmentItem,_e as QtiAssessmentItemRef,Te as QtiAssessmentSection,pt as QtiAssessmentStimulusRef,Oi as QtiAssessmentStimulusRefConnectedEvent,et as QtiAssessmentTest,Jt as QtiAssociableHotspot,ut as QtiAssociateInteraction,Kr as QtiBaseValue,mt as QtiChoiceInteraction,Br as QtiCompanionMaterialsInfo,Gi as QtiContainerSize,Yi as QtiContains,oi as QtiContentBody,Ji as QtiCorrect,ve as QtiCustomInteraction,Wt as QtiCustomOperator,qt as QtiDefault,ys as QtiDelete,Pe as QtiEndAttemptInteraction,Qr as QtiEqual,Zr as QtiEqualRounded,j as QtiExtendedTextInteraction,U as QtiFeedback,Gt as QtiFeedbackBlock,Yt as QtiFeedbackInline,ss as QtiFieldValue,gt as QtiGap,ht as QtiGapImg,Kt as QtiGapMatchInteraction,ft as QtiGapText,Qi as QtiGcd,le as QtiGraphicAssociateInteraction,Zt as QtiGraphicGapMatchInteraction,Qt as QtiGraphicOrderInteraction,es as QtiGt,ts as QtiGte,Qe as QtiHotspotChoice,er as QtiHotspotInteraction,rr as QtiHottext,tr as QtiHottextInteraction,br as QtiIndex,sr as QtiInlineChoice,ye as QtiInlineChoiceInteraction,is as QtiIsNull,Rt as QtiItem,cr as QtiItemBody,ur as QtiLookupOutcomeValue,os as QtiLt,ns as QtiLte,ei as QtiMapResponse,ti as QtiMapResponsePoint,as as QtiMatch,xe as QtiMatchInteraction,ri as QtiMathOperator,or as QtiMediaInteraction,ls as QtiMember,Ze as QtiModalFeedback,cs as QtiMultiple,ds as QtiNot,rs as QtiNull,ps as QtiOr,qe as QtiOrderInteraction,us as QtiOrdered,me as QtiOutcomeDeclaration,dr as QtiOutcomeProcessing,Ui as QtiOutcomeProcessingProcessor,z as QtiPortableCustomInteraction,Ni as QtiPositionObjectInteraction,nr as QtiPositionObjectStage,ms as QtiPower,gr as QtiPrintedVariable,hs as QtiProduct,Gr as QtiPrompt,vs as QtiRandom,Ct as QtiRandomInteger,ji as QtiResponseCondition,we as QtiResponseDeclaration,mr as QtiResponseElse,Xi as QtiResponseElseIf,hr as QtiResponseIf,pr as QtiResponseProcessing,Zi as QtiRound,fr as QtiRoundTo,ue as QtiRubricBlock,de as QtiRule,ce as QtiSelectPointInteraction,Bi as QtiSetOutcomeValue,Wi as QtiSetOutcomeValueRule,Ne as QtiSimpleAssociableChoice,Ce as QtiSimpleChoice,Ee as QtiSliderInteraction,si as QtiStringMatch,ni as QtiStylesheet,ii as QtiSubtract,fs as QtiSum,gs as QtiSumExpression,ai as QtiTest,vr as QtiTestFeedback,Ae as QtiTestPart,J as QtiTextEntryInteraction,lr as QtiUploadInteraction,bs as QtiVariable,kr as TestCheckItem,ke as TestContainer,yr as TestEndAttempt,wt as TestItemLink,Z as TestNavigation,Fe as TestNext,wr as TestPagingButtonsStamp,Ue as TestPrev,Tr as TestPrintContext,_t as TestPrintVariables,it as TestScoringButtons,At as TestScoringFeedback,_r as TestSectionButtonsStamp,Tt as TestSectionLink,ee as TestShowCorrectResponse,rt as TestStamp,X as TestView,Ar as TestViewToggle,Mn as qtiAndMixin,In as qtiSubtractMixin,pe as testContext};
5436
5444
  /*! Bundled license information:
5437
5445
 
5438
5446
  @lit/context/lib/context-request-event.js: