@citolab/qti-components 10.0.0-next.5 → 10.0.0-next.6

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 (33) hide show
  1. package/cdn/index.global.js +1 -1
  2. package/cdn/index.js +80 -75
  3. package/dist/{chunk-A2AP6CUL.js → chunk-7IRGNPCV.js} +2 -2
  4. package/dist/{chunk-JNZ3HSFI.js → chunk-GZVLORVJ.js} +2 -2
  5. package/dist/{chunk-WV53LUE3.js → chunk-KXYSYDIM.js} +2 -2
  6. package/dist/chunk-QVZLJY75.js +7 -0
  7. package/dist/chunk-QVZLJY75.js.map +1 -0
  8. package/dist/{chunk-WC3P4KCV.js → chunk-VY2DM47N.js} +173 -119
  9. package/dist/chunk-VY2DM47N.js.map +1 -0
  10. package/dist/{chunk-F7QDRKCR.js → chunk-W4NUIWRO.js} +2 -2
  11. package/dist/{chunk-KB2NJTSD.js → chunk-WAHTXGBK.js} +4 -4
  12. package/dist/{chunk-WVDQLBMT.js → chunk-Z545U7O3.js} +2 -2
  13. package/dist/corrections.d.ts +1 -1
  14. package/dist/corrections.js +5 -5
  15. package/dist/index.d.ts +1 -1
  16. package/dist/index.js +8 -8
  17. package/dist/interactions.d.ts +2 -2
  18. package/dist/interactions.js +2 -2
  19. package/dist/item.css +2 -1
  20. package/dist/item.js +3 -3
  21. package/dist/qti-components-jsx.d.ts +26 -0
  22. package/dist/{qti-text-entry-interaction.d-q8u5BiVK.d.ts → qti-text-entry-interaction.d-828kFi2A.d.ts} +14 -0
  23. package/dist/test.js +3 -3
  24. package/package.json +1 -1
  25. package/dist/chunk-WC3P4KCV.js.map +0 -1
  26. package/dist/chunk-ZP6QQYSU.js +0 -7
  27. package/dist/chunk-ZP6QQYSU.js.map +0 -1
  28. /package/dist/{chunk-A2AP6CUL.js.map → chunk-7IRGNPCV.js.map} +0 -0
  29. /package/dist/{chunk-JNZ3HSFI.js.map → chunk-GZVLORVJ.js.map} +0 -0
  30. /package/dist/{chunk-WV53LUE3.js.map → chunk-KXYSYDIM.js.map} +0 -0
  31. /package/dist/{chunk-F7QDRKCR.js.map → chunk-W4NUIWRO.js.map} +0 -0
  32. /package/dist/{chunk-KB2NJTSD.js.map → chunk-WAHTXGBK.js.map} +0 -0
  33. /package/dist/{chunk-WVDQLBMT.js.map → chunk-Z545U7O3.js.map} +0 -0
package/cdn/index.js CHANGED
@@ -1,8 +1,8 @@
1
- var xc=class{get shadowRoot(){return this.__host.__shadowRoot}constructor(t){this.ariaActiveDescendantElement=null,this.ariaAtomic="",this.ariaAutoComplete="",this.ariaBrailleLabel="",this.ariaBrailleRoleDescription="",this.ariaBusy="",this.ariaChecked="",this.ariaColCount="",this.ariaColIndex="",this.ariaColIndexText="",this.ariaColSpan="",this.ariaControlsElements=null,this.ariaCurrent="",this.ariaDescribedByElements=null,this.ariaDescription="",this.ariaDetailsElements=null,this.ariaDisabled="",this.ariaErrorMessageElements=null,this.ariaExpanded="",this.ariaFlowToElements=null,this.ariaHasPopup="",this.ariaHidden="",this.ariaInvalid="",this.ariaKeyShortcuts="",this.ariaLabel="",this.ariaLabelledByElements=null,this.ariaLevel="",this.ariaLive="",this.ariaModal="",this.ariaMultiLine="",this.ariaMultiSelectable="",this.ariaOrientation="",this.ariaOwnsElements=null,this.ariaPlaceholder="",this.ariaPosInSet="",this.ariaPressed="",this.ariaReadOnly="",this.ariaRelevant="",this.ariaRequired="",this.ariaRoleDescription="",this.ariaRowCount="",this.ariaRowIndex="",this.ariaRowIndexText="",this.ariaRowSpan="",this.ariaSelected="",this.ariaSetSize="",this.ariaSort="",this.ariaValueMax="",this.ariaValueMin="",this.ariaValueNow="",this.ariaValueText="",this.role="",this.form=null,this.labels=[],this.states=new Set,this.validationMessage="",this.validity={},this.willValidate=!0,this.__host=t}checkValidity(){return console.warn("`ElementInternals.checkValidity()` was called on the server.This method always returns true."),!0}reportValidity(){return!0}setFormValue(){}setValidity(){}};var Ut=function(o,t,e,i,n){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?o!==t||!n:!t.has(o))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?n.call(o,e):n?n.value=e:t.set(o,e),e},et=function(o,t,e,i){if(e==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?o!==t||!i:!t.has(o))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?i:e==="a"?i.call(o):i?i.value:t.get(o)},Ei,Rn,Pn,wr,Ea,xr,On,Ye,qr,be,Mn,qc;var B={__proto__:null};B.enumerable=!0;Object.freeze(B);var Aa=(be=class{constructor(t,e={}){if(Ei.set(this,!1),Rn.set(this,!1),Pn.set(this,!1),wr.set(this,!1),Ea.set(this,Date.now()),xr.set(this,!1),On.set(this,void 0),Ye.set(this,void 0),qr.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:i,cancelable:n,composed:r}=e;Ut(this,Ei,!!n,"f"),Ut(this,Rn,!!i,"f"),Ut(this,Pn,!!r,"f"),Ut(this,On,`${t}`,"f"),Ut(this,Ye,null,"f"),Ut(this,qr,!1,"f")}initEvent(t,e,i){throw new Error("Method not implemented.")}stopImmediatePropagation(){this.stopPropagation()}preventDefault(){Ut(this,wr,!0,"f")}get target(){return et(this,Ye,"f")}get currentTarget(){return et(this,Ye,"f")}get srcElement(){return et(this,Ye,"f")}get type(){return et(this,On,"f")}get cancelable(){return et(this,Ei,"f")}get defaultPrevented(){return et(this,Ei,"f")&&et(this,wr,"f")}get timeStamp(){return et(this,Ea,"f")}composedPath(){return et(this,qr,"f")?[et(this,Ye,"f")]:[]}get returnValue(){return!et(this,Ei,"f")||!et(this,wr,"f")}get bubbles(){return et(this,Rn,"f")}get composed(){return et(this,Pn,"f")}get eventPhase(){return et(this,qr,"f")?be.AT_TARGET:be.NONE}get cancelBubble(){return et(this,xr,"f")}set cancelBubble(t){t&&Ut(this,xr,!0,"f")}stopPropagation(){Ut(this,xr,!0,"f")}get isTrusted(){return!1}},Ei=new WeakMap,Rn=new WeakMap,Pn=new WeakMap,wr=new WeakMap,Ea=new WeakMap,xr=new WeakMap,On=new WeakMap,Ye=new WeakMap,qr=new WeakMap,be.NONE=0,be.CAPTURING_PHASE=1,be.AT_TARGET=2,be.BUBBLING_PHASE=3,be);Object.defineProperties(Aa.prototype,{initEvent:B,stopImmediatePropagation:B,preventDefault:B,target:B,currentTarget:B,srcElement:B,type:B,cancelable:B,defaultPrevented:B,timeStamp:B,composedPath:B,returnValue:B,bubbles:B,composed:B,eventPhase:B,cancelBubble:B,stopPropagation:B,isTrusted:B});var Cc=(qc=class extends Aa{constructor(t,e={}){super(t,e),Mn.set(this,void 0),Ut(this,Mn,e?.detail??null,"f")}initCustomEvent(t,e,i,n){throw new Error("Method not implemented.")}get detail(){return et(this,Mn,"f")}},Mn=new WeakMap,qc);Object.defineProperties(Cc.prototype,{detail:B});var ee=Aa,Ia=Cc;var dt;var Bf=(dt=class{constructor(){this.STYLE_RULE=1,this.CHARSET_RULE=2,this.IMPORT_RULE=3,this.MEDIA_RULE=4,this.FONT_FACE_RULE=5,this.PAGE_RULE=6,this.NAMESPACE_RULE=10,this.KEYFRAMES_RULE=7,this.KEYFRAME_RULE=8,this.SUPPORTS_RULE=12,this.COUNTER_STYLE_RULE=11,this.FONT_FEATURE_VALUES_RULE=14,this.MARGIN_RULE=9,this.__parentStyleSheet=null,this.cssText=""}get parentRule(){return null}get parentStyleSheet(){return this.__parentStyleSheet}get type(){return 0}},dt.STYLE_RULE=1,dt.CHARSET_RULE=2,dt.IMPORT_RULE=3,dt.MEDIA_RULE=4,dt.FONT_FACE_RULE=5,dt.PAGE_RULE=6,dt.NAMESPACE_RULE=10,dt.KEYFRAMES_RULE=7,dt.KEYFRAME_RULE=8,dt.SUPPORTS_RULE=12,dt.COUNTER_STYLE_RULE=11,dt.FONT_FEATURE_VALUES_RULE=14,dt.MARGIN_RULE=9,dt);globalThis.Event??=ee;globalThis.CustomEvent??=Ia;var Ta=Symbol(),kc=o=>typeof o=="boolean"?o:o?.capture??!1,ie={__proto__:null};ie.enumerable=!0;Object.freeze(ie);var Dn=class{constructor(){this.__eventListeners=new Map,this.__captureEventListeners=new Map}addEventListener(t,e,i){if(e==null)return;let n=kc(i)?this.__captureEventListeners:this.__eventListeners,r=n.get(t);if(r===void 0)r=new Map,n.set(t,r);else if(r.has(e))return;let s=typeof i=="object"&&i?i:{};s.signal?.addEventListener("abort",()=>this.removeEventListener(t,e,i)),r.set(e,s??{})}removeEventListener(t,e,i){if(e==null)return;let n=kc(i)?this.__captureEventListeners:this.__eventListeners,r=n.get(t);r!==void 0&&(r.delete(e),r.size||n.delete(t))}dispatchEvent(t){let e=this.__resolveFullEventPath();!t.composed&&this.__host&&(e=e.slice(0,e.indexOf(this.__host)));let i=!1,n=!1,r=ee.NONE,s=null,a=null,l=null,c=t.stopPropagation,d=t.stopImmediatePropagation;Object.defineProperties(t,{target:{get(){return s??a},...ie},srcElement:{get(){return t.target},...ie},currentTarget:{get(){return l},...ie},eventPhase:{get(){return r},...ie},composedPath:{value:()=>e,...ie},stopPropagation:{value:()=>{i=!0,c.call(t)},...ie},stopImmediatePropagation:{value:()=>{n=!0,d.call(t)},...ie}});let h=(u,g,y)=>{typeof u=="function"?u(t):typeof u?.handleEvent=="function"&&u.handleEvent(t),g.once&&y.delete(u)},f=()=>(l=null,r=ee.NONE,!t.defaultPrevented),m=e.slice().reverse();s=!this.__host||!t.composed?this:null;let v=u=>{for(a=this;a.__host&&u.includes(a.__host);)a=a.__host};for(let u of m){!s&&(!a||a===u.__host)&&v(m.slice(m.indexOf(u))),l=u,r=u===t.target?ee.AT_TARGET:ee.CAPTURING_PHASE;let g=u.__captureEventListeners.get(t.type);if(g){for(let[y,w]of g)if(h(y,w,g),n)return f()}if(i)return f()}let x=t.bubbles?e:[this];a=null;for(let u of x){!s&&(!a||u===a.__host)&&v(x.slice(0,x.indexOf(u)+1)),l=u,r=u===t.target?ee.AT_TARGET:ee.BUBBLING_PHASE;let g=u.__eventListeners.get(t.type);if(g){for(let[y,w]of g)if(h(y,w,g),n)return f()}if(i)return f()}return f()}__resolveFullEventPath(){return this.__eventPathCache?this.__eventPathCache:this.__eventTargetParent?this.__eventPathCache=[this,...this.__eventTargetParent.__resolveFullEventPath()]:this.__eventPathCache=[this,Ac,nu]}};var Sc=new WeakMap,Cr=o=>{let t=Sc.get(o);return t===void 0&&Sc.set(o,t=new Map),t},kr=class extends Dn{getRootNode(t){return t?.composed?_a:this.__host?.__shadowRoot??_a}};var Ec=class extends kr{get adoptedStyleSheets(){return[]}createTreeWalker(){return{}}createTextNode(){return{}}createElement(){return{}}};var Ac=new Ec,_a=Ac;var Ic=class extends kr{constructor(t){if(super(),t!==Ta)throw new TypeError("Illegal constructor");Object.assign(this,globalThis,{CustomElementRegistry:Nn,customElements:Pa,document:_a,Document:Ec,Element:_c,EventTarget:Dn,HTMLElement:Tc,Node:kr,ShadowRoot:Rc,window:this,Window:Ic})}};var _c=class extends kr{constructor(){super(...arguments),this.__shadowRootMode=null,this.__shadowRoot=null,this.__internals=null}get attributes(){return Array.from(Cr(this)).map(([t,e])=>({name:t,value:e}))}get shadowRoot(){return this.__shadowRootMode==="closed"?null:this.__shadowRoot}get localName(){return this.constructor.__localName}get tagName(){return this.localName?.toUpperCase()}setAttribute(t,e){Cr(this).set(t,String(e))}removeAttribute(t){Cr(this).delete(t)}toggleAttribute(t,e){if(this.hasAttribute(t)){if(e===void 0||!e)return this.removeAttribute(t),!1}else return e===void 0||e?(this.setAttribute(t,""),!0):!1;return!0}hasAttribute(t){return Cr(this).has(t)}attachShadow(t){this.__shadowRootMode=t.mode;let e=new Rc(Ta,t);return e.__eventTargetParent=this,e.__host=this,this.__shadowRoot=e}attachInternals(){if(this.__internals!==null)throw new Error("Failed to execute 'attachInternals' on 'HTMLElement': ElementInternals for the specified element was already attached.");let t=new xc(this);return this.__internals=t,t}getAttribute(t){return Cr(this).get(t)??null}};var Tc=class extends _c{},Ra=Tc;var Rc=class extends kr{get host(){return this.__host}constructor(t,e){if(super(),t!==t)throw new TypeError("Illegal constructor");this.mode=e.mode}};globalThis.litServerRoot??=Object.defineProperty(new Ra,"localName",{get(){return"lit-server-root"}});function iu(){let o,t;return{promise:new Promise((i,n)=>{o=i,t=n}),resolve:o,reject:t}}var Nn=class{constructor(){this.__definitions=new Map,this.__reverseDefinitions=new Map,this.__pendingWhenDefineds=new Map}define(t,e){if(this.__definitions.has(t))if(process.env.NODE_ENV==="development")console.warn(`'CustomElementRegistry' already has "${t}" defined. This may have been caused by live reload or hot module replacement in which case it can be safely ignored.
2
- Make sure to test your application with a production build as repeat registrations will throw in production.`);else throw new Error(`Failed to execute 'define' on 'CustomElementRegistry': the name "${t}" has already been used with this registry`);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=t,this.__definitions.set(t,{ctor:e,observedAttributes:e.observedAttributes??[]}),this.__reverseDefinitions.set(e,t),this.__pendingWhenDefineds.get(t)?.resolve(e),this.__pendingWhenDefineds.delete(t)}get(t){return this.__definitions.get(t)?.ctor}getName(t){return this.__reverseDefinitions.get(t)??null}initialize(t){throw new Error("customElements.initialize is not currently supported in SSR. Please file a bug if you need it.")}upgrade(t){throw new Error("customElements.upgrade is not currently supported in SSR. Please file a bug if you need it.")}async whenDefined(t){let e=this.__definitions.get(t);if(e)return e.ctor;let i=this.__pendingWhenDefineds.get(t);return i||(i=iu(),this.__pendingWhenDefineds.set(t,i)),i.promise}},ru=Nn;var Pa=new ru,nu=new Ic(Ta);var Sr=globalThis,$n=Sr.ShadowRoot&&(Sr.ShadyCSS===void 0||Sr.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Oa=Symbol(),Pc=new WeakMap,Er=class{constructor(t,e,i){if(this._$cssResult$=!0,i!==Oa)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o,e=this.t;if($n&&t===void 0){let i=e!==void 0&&e.length===1;i&&(t=Pc.get(e)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),i&&Pc.set(e,t))}return t}toString(){return this.cssText}},Oc=o=>new Er(typeof o=="string"?o:o+"",void 0,Oa),q=(o,...t)=>{let e=o.length===1?o[0]:t.reduce((i,n,r)=>i+(s=>{if(s._$cssResult$===!0)return s.cssText;if(typeof s=="number")return s;throw Error("Value passed to 'css' function must be a 'css' function result: "+s+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(n)+o[r+1],o[0]);return new Er(e,o,Oa)},Mc=(o,t)=>{if($n)o.adoptedStyleSheets=t.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet);else for(let e of t){let i=document.createElement("style"),n=Sr.litNonce;n!==void 0&&i.setAttribute("nonce",n),i.textContent=e.cssText,o.appendChild(i)}},Ma=$n||Sr.CSSStyleSheet===void 0?o=>o:o=>o instanceof CSSStyleSheet?(t=>{let e="";for(let i of t.cssRules)e+=i.cssText;return Oc(e)})(o):o;var{is:ou,defineProperty:su,getOwnPropertyDescriptor:au,getOwnPropertyNames:lu,getOwnPropertySymbols:cu,getPrototypeOf:du}=Object,_r=globalThis;_r.customElements??=Pa;var Dc=_r.trustedTypes,hu=Dc?Dc.emptyScript:"",pu=_r.reactiveElementPolyfillSupport,Ar=(o,t)=>o,Ir={toAttribute(o,t){switch(t){case Boolean:o=o?hu:null;break;case Object:case Array:o=o==null?o:JSON.stringify(o)}return o},fromAttribute(o,t){let e=o;switch(t){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}},Ln=(o,t)=>!ou(o,t),Nc={attribute:!0,type:String,converter:Ir,reflect:!1,useDefault:!1,hasChanged:Ln};Symbol.metadata??=Symbol("metadata"),_r.litPropertyMetadata??=new WeakMap;var re=class extends(globalThis.HTMLElement??Ra){static addInitializer(t){this._$Ei(),(this.l??=[]).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=Nc){if(e.state&&(e.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(t)&&((e=Object.create(e)).wrapped=!0),this.elementProperties.set(t,e),!e.noAccessor){let i=Symbol(),n=this.getPropertyDescriptor(t,i,e);n!==void 0&&su(this.prototype,t,n)}}static getPropertyDescriptor(t,e,i){let{get:n,set:r}=au(this.prototype,t)??{get(){return this[e]},set(s){this[e]=s}};return{get:n,set(s){let a=n?.call(this);r?.call(this,s),this.requestUpdate(t,a,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??Nc}static _$Ei(){if(this.hasOwnProperty(Ar("elementProperties")))return;let t=du(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(Ar("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(Ar("properties"))){let e=this.properties,i=[...lu(e),...cu(e)];for(let n of i)this.createProperty(n,e[n])}let t=this[Symbol.metadata];if(t!==null){let e=litPropertyMetadata.get(t);if(e!==void 0)for(let[i,n]of e)this.elementProperties.set(i,n)}this._$Eh=new Map;for(let[e,i]of this.elementProperties){let n=this._$Eu(e,i);n!==void 0&&this._$Eh.set(n,e)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){let e=[];if(Array.isArray(t)){let i=new Set(t.flat(1/0).reverse());for(let n of i)e.unshift(Ma(n))}else t!==void 0&&e.push(Ma(t));return e}static _$Eu(t,e){let i=e.attribute;return i===!1?void 0:typeof i=="string"?i:typeof t=="string"?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(t=>this.enableUpdating=t),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(t=>t(this))}addController(t){(this._$EO??=new Set).add(t),this.renderRoot!==void 0&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$EO?.delete(t)}_$E_(){let t=new Map,e=this.constructor.elementProperties;for(let i of e.keys())this.hasOwnProperty(i)&&(t.set(i,this[i]),delete this[i]);t.size>0&&(this._$Ep=t)}createRenderRoot(){let t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return Mc(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(t=>t.hostConnected?.())}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach(t=>t.hostDisconnected?.())}attributeChangedCallback(t,e,i){this._$AK(t,i)}_$ET(t,e){let i=this.constructor.elementProperties.get(t),n=this.constructor._$Eu(t,i);if(n!==void 0&&i.reflect===!0){let r=(i.converter?.toAttribute!==void 0?i.converter:Ir).toAttribute(e,i.type);this._$Em=t,r==null?this.removeAttribute(n):this.setAttribute(n,r),this._$Em=null}}_$AK(t,e){let i=this.constructor,n=i._$Eh.get(t);if(n!==void 0&&this._$Em!==n){let r=i.getPropertyOptions(n),s=typeof r.converter=="function"?{fromAttribute:r.converter}:r.converter?.fromAttribute!==void 0?r.converter:Ir;this._$Em=n;let a=s.fromAttribute(e,r.type);this[n]=a??this._$Ej?.get(n)??a,this._$Em=null}}requestUpdate(t,e,i,n=!1,r){if(t!==void 0){let s=this.constructor;if(n===!1&&(r=this[t]),i??=s.getPropertyOptions(t),!((i.hasChanged??Ln)(r,e)||i.useDefault&&i.reflect&&r===this._$Ej?.get(t)&&!this.hasAttribute(s._$Eu(t,i))))return;this.C(t,e,i)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(t,e,{useDefault:i,reflect:n,wrapped:r},s){i&&!(this._$Ej??=new Map).has(t)&&(this._$Ej.set(t,s??e??this[t]),r!==!0||s!==void 0)||(this._$AL.has(t)||(this.hasUpdated||i||(e=void 0),this._$AL.set(t,e)),n===!0&&this._$Em!==t&&(this._$Eq??=new Set).add(t))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(e){Promise.reject(e)}let t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(let[n,r]of this._$Ep)this[n]=r;this._$Ep=void 0}let i=this.constructor.elementProperties;if(i.size>0)for(let[n,r]of i){let{wrapped:s}=r,a=this[n];s!==!0||this._$AL.has(n)||a===void 0||this.C(n,void 0,r,a)}}let t=!1,e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),this._$EO?.forEach(i=>i.hostUpdate?.()),this.update(e)):this._$EM()}catch(i){throw t=!1,this._$EM(),i}t&&this._$AE(e)}willUpdate(t){}_$AE(t){this._$EO?.forEach(e=>e.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Eq&&=this._$Eq.forEach(e=>this._$ET(e,this[e])),this._$EM()}updated(t){}firstUpdated(t){}};re.elementStyles=[],re.shadowRootOptions={mode:"open"},re[Ar("elementProperties")]=new Map,re[Ar("finalized")]=new Map,pu?.({ReactiveElement:re}),(_r.reactiveElementVersions??=[]).push("2.1.2");var Hn=globalThis,$c=o=>o,Vn=Hn.trustedTypes,Lc=Vn?Vn.createPolicy("lit-html",{createHTML:o=>o}):void 0,Na="$lit$",ne=`lit$${Math.random().toFixed(9).slice(2)}$`,$a="?"+ne,uu=`<${$a}>`,Ze=Hn.document===void 0?{createTreeWalker:()=>({})}:document,Rr=()=>Ze.createComment(""),Pr=o=>o===null||typeof o!="object"&&typeof o!="function",La=Array.isArray,Uc=o=>La(o)||typeof o?.[Symbol.iterator]=="function",Da=`[
1
+ var xc=class{get shadowRoot(){return this.__host.__shadowRoot}constructor(t){this.ariaActiveDescendantElement=null,this.ariaAtomic="",this.ariaAutoComplete="",this.ariaBrailleLabel="",this.ariaBrailleRoleDescription="",this.ariaBusy="",this.ariaChecked="",this.ariaColCount="",this.ariaColIndex="",this.ariaColIndexText="",this.ariaColSpan="",this.ariaControlsElements=null,this.ariaCurrent="",this.ariaDescribedByElements=null,this.ariaDescription="",this.ariaDetailsElements=null,this.ariaDisabled="",this.ariaErrorMessageElements=null,this.ariaExpanded="",this.ariaFlowToElements=null,this.ariaHasPopup="",this.ariaHidden="",this.ariaInvalid="",this.ariaKeyShortcuts="",this.ariaLabel="",this.ariaLabelledByElements=null,this.ariaLevel="",this.ariaLive="",this.ariaModal="",this.ariaMultiLine="",this.ariaMultiSelectable="",this.ariaOrientation="",this.ariaOwnsElements=null,this.ariaPlaceholder="",this.ariaPosInSet="",this.ariaPressed="",this.ariaReadOnly="",this.ariaRelevant="",this.ariaRequired="",this.ariaRoleDescription="",this.ariaRowCount="",this.ariaRowIndex="",this.ariaRowIndexText="",this.ariaRowSpan="",this.ariaSelected="",this.ariaSetSize="",this.ariaSort="",this.ariaValueMax="",this.ariaValueMin="",this.ariaValueNow="",this.ariaValueText="",this.role="",this.form=null,this.labels=[],this.states=new Set,this.validationMessage="",this.validity={},this.willValidate=!0,this.__host=t}checkValidity(){return console.warn("`ElementInternals.checkValidity()` was called on the server.This method always returns true."),!0}reportValidity(){return!0}setFormValue(){}setValidity(){}};var Ut=function(o,t,e,i,n){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?o!==t||!n:!t.has(o))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?n.call(o,e):n?n.value=e:t.set(o,e),e},et=function(o,t,e,i){if(e==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?o!==t||!i:!t.has(o))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?i:e==="a"?i.call(o):i?i.value:t.get(o)},Ai,Rn,Pn,wr,Ea,xr,On,Ye,qr,be,Mn,qc;var B={__proto__:null};B.enumerable=!0;Object.freeze(B);var Aa=(be=class{constructor(t,e={}){if(Ai.set(this,!1),Rn.set(this,!1),Pn.set(this,!1),wr.set(this,!1),Ea.set(this,Date.now()),xr.set(this,!1),On.set(this,void 0),Ye.set(this,void 0),qr.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:i,cancelable:n,composed:r}=e;Ut(this,Ai,!!n,"f"),Ut(this,Rn,!!i,"f"),Ut(this,Pn,!!r,"f"),Ut(this,On,`${t}`,"f"),Ut(this,Ye,null,"f"),Ut(this,qr,!1,"f")}initEvent(t,e,i){throw new Error("Method not implemented.")}stopImmediatePropagation(){this.stopPropagation()}preventDefault(){Ut(this,wr,!0,"f")}get target(){return et(this,Ye,"f")}get currentTarget(){return et(this,Ye,"f")}get srcElement(){return et(this,Ye,"f")}get type(){return et(this,On,"f")}get cancelable(){return et(this,Ai,"f")}get defaultPrevented(){return et(this,Ai,"f")&&et(this,wr,"f")}get timeStamp(){return et(this,Ea,"f")}composedPath(){return et(this,qr,"f")?[et(this,Ye,"f")]:[]}get returnValue(){return!et(this,Ai,"f")||!et(this,wr,"f")}get bubbles(){return et(this,Rn,"f")}get composed(){return et(this,Pn,"f")}get eventPhase(){return et(this,qr,"f")?be.AT_TARGET:be.NONE}get cancelBubble(){return et(this,xr,"f")}set cancelBubble(t){t&&Ut(this,xr,!0,"f")}stopPropagation(){Ut(this,xr,!0,"f")}get isTrusted(){return!1}},Ai=new WeakMap,Rn=new WeakMap,Pn=new WeakMap,wr=new WeakMap,Ea=new WeakMap,xr=new WeakMap,On=new WeakMap,Ye=new WeakMap,qr=new WeakMap,be.NONE=0,be.CAPTURING_PHASE=1,be.AT_TARGET=2,be.BUBBLING_PHASE=3,be);Object.defineProperties(Aa.prototype,{initEvent:B,stopImmediatePropagation:B,preventDefault:B,target:B,currentTarget:B,srcElement:B,type:B,cancelable:B,defaultPrevented:B,timeStamp:B,composedPath:B,returnValue:B,bubbles:B,composed:B,eventPhase:B,cancelBubble:B,stopPropagation:B,isTrusted:B});var Cc=(qc=class extends Aa{constructor(t,e={}){super(t,e),Mn.set(this,void 0),Ut(this,Mn,e?.detail??null,"f")}initCustomEvent(t,e,i,n){throw new Error("Method not implemented.")}get detail(){return et(this,Mn,"f")}},Mn=new WeakMap,qc);Object.defineProperties(Cc.prototype,{detail:B});var ee=Aa,Ia=Cc;var dt;var Uf=(dt=class{constructor(){this.STYLE_RULE=1,this.CHARSET_RULE=2,this.IMPORT_RULE=3,this.MEDIA_RULE=4,this.FONT_FACE_RULE=5,this.PAGE_RULE=6,this.NAMESPACE_RULE=10,this.KEYFRAMES_RULE=7,this.KEYFRAME_RULE=8,this.SUPPORTS_RULE=12,this.COUNTER_STYLE_RULE=11,this.FONT_FEATURE_VALUES_RULE=14,this.MARGIN_RULE=9,this.__parentStyleSheet=null,this.cssText=""}get parentRule(){return null}get parentStyleSheet(){return this.__parentStyleSheet}get type(){return 0}},dt.STYLE_RULE=1,dt.CHARSET_RULE=2,dt.IMPORT_RULE=3,dt.MEDIA_RULE=4,dt.FONT_FACE_RULE=5,dt.PAGE_RULE=6,dt.NAMESPACE_RULE=10,dt.KEYFRAMES_RULE=7,dt.KEYFRAME_RULE=8,dt.SUPPORTS_RULE=12,dt.COUNTER_STYLE_RULE=11,dt.FONT_FEATURE_VALUES_RULE=14,dt.MARGIN_RULE=9,dt);globalThis.Event??=ee;globalThis.CustomEvent??=Ia;var Ta=Symbol(),Sc=o=>typeof o=="boolean"?o:o?.capture??!1,ie={__proto__:null};ie.enumerable=!0;Object.freeze(ie);var Dn=class{constructor(){this.__eventListeners=new Map,this.__captureEventListeners=new Map}addEventListener(t,e,i){if(e==null)return;let n=Sc(i)?this.__captureEventListeners:this.__eventListeners,r=n.get(t);if(r===void 0)r=new Map,n.set(t,r);else if(r.has(e))return;let s=typeof i=="object"&&i?i:{};s.signal?.addEventListener("abort",()=>this.removeEventListener(t,e,i)),r.set(e,s??{})}removeEventListener(t,e,i){if(e==null)return;let n=Sc(i)?this.__captureEventListeners:this.__eventListeners,r=n.get(t);r!==void 0&&(r.delete(e),r.size||n.delete(t))}dispatchEvent(t){let e=this.__resolveFullEventPath();!t.composed&&this.__host&&(e=e.slice(0,e.indexOf(this.__host)));let i=!1,n=!1,r=ee.NONE,s=null,a=null,l=null,c=t.stopPropagation,d=t.stopImmediatePropagation;Object.defineProperties(t,{target:{get(){return s??a},...ie},srcElement:{get(){return t.target},...ie},currentTarget:{get(){return l},...ie},eventPhase:{get(){return r},...ie},composedPath:{value:()=>e,...ie},stopPropagation:{value:()=>{i=!0,c.call(t)},...ie},stopImmediatePropagation:{value:()=>{n=!0,d.call(t)},...ie}});let h=(u,g,y)=>{typeof u=="function"?u(t):typeof u?.handleEvent=="function"&&u.handleEvent(t),g.once&&y.delete(u)},f=()=>(l=null,r=ee.NONE,!t.defaultPrevented),m=e.slice().reverse();s=!this.__host||!t.composed?this:null;let v=u=>{for(a=this;a.__host&&u.includes(a.__host);)a=a.__host};for(let u of m){!s&&(!a||a===u.__host)&&v(m.slice(m.indexOf(u))),l=u,r=u===t.target?ee.AT_TARGET:ee.CAPTURING_PHASE;let g=u.__captureEventListeners.get(t.type);if(g){for(let[y,w]of g)if(h(y,w,g),n)return f()}if(i)return f()}let x=t.bubbles?e:[this];a=null;for(let u of x){!s&&(!a||u===a.__host)&&v(x.slice(0,x.indexOf(u)+1)),l=u,r=u===t.target?ee.AT_TARGET:ee.BUBBLING_PHASE;let g=u.__eventListeners.get(t.type);if(g){for(let[y,w]of g)if(h(y,w,g),n)return f()}if(i)return f()}return f()}__resolveFullEventPath(){return this.__eventPathCache?this.__eventPathCache:this.__eventTargetParent?this.__eventPathCache=[this,...this.__eventTargetParent.__resolveFullEventPath()]:this.__eventPathCache=[this,Ac,nu]}};var kc=new WeakMap,Cr=o=>{let t=kc.get(o);return t===void 0&&kc.set(o,t=new Map),t},Sr=class extends Dn{getRootNode(t){return t?.composed?_a:this.__host?.__shadowRoot??_a}};var Ec=class extends Sr{get adoptedStyleSheets(){return[]}createTreeWalker(){return{}}createTextNode(){return{}}createElement(){return{}}};var Ac=new Ec,_a=Ac;var Ic=class extends Sr{constructor(t){if(super(),t!==Ta)throw new TypeError("Illegal constructor");Object.assign(this,globalThis,{CustomElementRegistry:Nn,customElements:Pa,document:_a,Document:Ec,Element:_c,EventTarget:Dn,HTMLElement:Tc,Node:Sr,ShadowRoot:Rc,window:this,Window:Ic})}};var _c=class extends Sr{constructor(){super(...arguments),this.__shadowRootMode=null,this.__shadowRoot=null,this.__internals=null}get attributes(){return Array.from(Cr(this)).map(([t,e])=>({name:t,value:e}))}get shadowRoot(){return this.__shadowRootMode==="closed"?null:this.__shadowRoot}get localName(){return this.constructor.__localName}get tagName(){return this.localName?.toUpperCase()}setAttribute(t,e){Cr(this).set(t,String(e))}removeAttribute(t){Cr(this).delete(t)}toggleAttribute(t,e){if(this.hasAttribute(t)){if(e===void 0||!e)return this.removeAttribute(t),!1}else return e===void 0||e?(this.setAttribute(t,""),!0):!1;return!0}hasAttribute(t){return Cr(this).has(t)}attachShadow(t){this.__shadowRootMode=t.mode;let e=new Rc(Ta,t);return e.__eventTargetParent=this,e.__host=this,this.__shadowRoot=e}attachInternals(){if(this.__internals!==null)throw new Error("Failed to execute 'attachInternals' on 'HTMLElement': ElementInternals for the specified element was already attached.");let t=new xc(this);return this.__internals=t,t}getAttribute(t){return Cr(this).get(t)??null}};var Tc=class extends _c{},Ra=Tc;var Rc=class extends Sr{get host(){return this.__host}constructor(t,e){if(super(),t!==t)throw new TypeError("Illegal constructor");this.mode=e.mode}};globalThis.litServerRoot??=Object.defineProperty(new Ra,"localName",{get(){return"lit-server-root"}});function iu(){let o,t;return{promise:new Promise((i,n)=>{o=i,t=n}),resolve:o,reject:t}}var Nn=class{constructor(){this.__definitions=new Map,this.__reverseDefinitions=new Map,this.__pendingWhenDefineds=new Map}define(t,e){if(this.__definitions.has(t))if(process.env.NODE_ENV==="development")console.warn(`'CustomElementRegistry' already has "${t}" defined. This may have been caused by live reload or hot module replacement in which case it can be safely ignored.
2
+ Make sure to test your application with a production build as repeat registrations will throw in production.`);else throw new Error(`Failed to execute 'define' on 'CustomElementRegistry': the name "${t}" has already been used with this registry`);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=t,this.__definitions.set(t,{ctor:e,observedAttributes:e.observedAttributes??[]}),this.__reverseDefinitions.set(e,t),this.__pendingWhenDefineds.get(t)?.resolve(e),this.__pendingWhenDefineds.delete(t)}get(t){return this.__definitions.get(t)?.ctor}getName(t){return this.__reverseDefinitions.get(t)??null}initialize(t){throw new Error("customElements.initialize is not currently supported in SSR. Please file a bug if you need it.")}upgrade(t){throw new Error("customElements.upgrade is not currently supported in SSR. Please file a bug if you need it.")}async whenDefined(t){let e=this.__definitions.get(t);if(e)return e.ctor;let i=this.__pendingWhenDefineds.get(t);return i||(i=iu(),this.__pendingWhenDefineds.set(t,i)),i.promise}},ru=Nn;var Pa=new ru,nu=new Ic(Ta);var kr=globalThis,$n=kr.ShadowRoot&&(kr.ShadyCSS===void 0||kr.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Oa=Symbol(),Pc=new WeakMap,Er=class{constructor(t,e,i){if(this._$cssResult$=!0,i!==Oa)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o,e=this.t;if($n&&t===void 0){let i=e!==void 0&&e.length===1;i&&(t=Pc.get(e)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),i&&Pc.set(e,t))}return t}toString(){return this.cssText}},Oc=o=>new Er(typeof o=="string"?o:o+"",void 0,Oa),q=(o,...t)=>{let e=o.length===1?o[0]:t.reduce((i,n,r)=>i+(s=>{if(s._$cssResult$===!0)return s.cssText;if(typeof s=="number")return s;throw Error("Value passed to 'css' function must be a 'css' function result: "+s+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(n)+o[r+1],o[0]);return new Er(e,o,Oa)},Mc=(o,t)=>{if($n)o.adoptedStyleSheets=t.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet);else for(let e of t){let i=document.createElement("style"),n=kr.litNonce;n!==void 0&&i.setAttribute("nonce",n),i.textContent=e.cssText,o.appendChild(i)}},Ma=$n||kr.CSSStyleSheet===void 0?o=>o:o=>o instanceof CSSStyleSheet?(t=>{let e="";for(let i of t.cssRules)e+=i.cssText;return Oc(e)})(o):o;var{is:ou,defineProperty:su,getOwnPropertyDescriptor:au,getOwnPropertyNames:lu,getOwnPropertySymbols:cu,getPrototypeOf:du}=Object,_r=globalThis;_r.customElements??=Pa;var Dc=_r.trustedTypes,hu=Dc?Dc.emptyScript:"",pu=_r.reactiveElementPolyfillSupport,Ar=(o,t)=>o,Ir={toAttribute(o,t){switch(t){case Boolean:o=o?hu:null;break;case Object:case Array:o=o==null?o:JSON.stringify(o)}return o},fromAttribute(o,t){let e=o;switch(t){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}},Ln=(o,t)=>!ou(o,t),Nc={attribute:!0,type:String,converter:Ir,reflect:!1,useDefault:!1,hasChanged:Ln};Symbol.metadata??=Symbol("metadata"),_r.litPropertyMetadata??=new WeakMap;var re=class extends(globalThis.HTMLElement??Ra){static addInitializer(t){this._$Ei(),(this.l??=[]).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=Nc){if(e.state&&(e.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(t)&&((e=Object.create(e)).wrapped=!0),this.elementProperties.set(t,e),!e.noAccessor){let i=Symbol(),n=this.getPropertyDescriptor(t,i,e);n!==void 0&&su(this.prototype,t,n)}}static getPropertyDescriptor(t,e,i){let{get:n,set:r}=au(this.prototype,t)??{get(){return this[e]},set(s){this[e]=s}};return{get:n,set(s){let a=n?.call(this);r?.call(this,s),this.requestUpdate(t,a,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??Nc}static _$Ei(){if(this.hasOwnProperty(Ar("elementProperties")))return;let t=du(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(Ar("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(Ar("properties"))){let e=this.properties,i=[...lu(e),...cu(e)];for(let n of i)this.createProperty(n,e[n])}let t=this[Symbol.metadata];if(t!==null){let e=litPropertyMetadata.get(t);if(e!==void 0)for(let[i,n]of e)this.elementProperties.set(i,n)}this._$Eh=new Map;for(let[e,i]of this.elementProperties){let n=this._$Eu(e,i);n!==void 0&&this._$Eh.set(n,e)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){let e=[];if(Array.isArray(t)){let i=new Set(t.flat(1/0).reverse());for(let n of i)e.unshift(Ma(n))}else t!==void 0&&e.push(Ma(t));return e}static _$Eu(t,e){let i=e.attribute;return i===!1?void 0:typeof i=="string"?i:typeof t=="string"?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(t=>this.enableUpdating=t),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(t=>t(this))}addController(t){(this._$EO??=new Set).add(t),this.renderRoot!==void 0&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$EO?.delete(t)}_$E_(){let t=new Map,e=this.constructor.elementProperties;for(let i of e.keys())this.hasOwnProperty(i)&&(t.set(i,this[i]),delete this[i]);t.size>0&&(this._$Ep=t)}createRenderRoot(){let t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return Mc(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(t=>t.hostConnected?.())}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach(t=>t.hostDisconnected?.())}attributeChangedCallback(t,e,i){this._$AK(t,i)}_$ET(t,e){let i=this.constructor.elementProperties.get(t),n=this.constructor._$Eu(t,i);if(n!==void 0&&i.reflect===!0){let r=(i.converter?.toAttribute!==void 0?i.converter:Ir).toAttribute(e,i.type);this._$Em=t,r==null?this.removeAttribute(n):this.setAttribute(n,r),this._$Em=null}}_$AK(t,e){let i=this.constructor,n=i._$Eh.get(t);if(n!==void 0&&this._$Em!==n){let r=i.getPropertyOptions(n),s=typeof r.converter=="function"?{fromAttribute:r.converter}:r.converter?.fromAttribute!==void 0?r.converter:Ir;this._$Em=n;let a=s.fromAttribute(e,r.type);this[n]=a??this._$Ej?.get(n)??a,this._$Em=null}}requestUpdate(t,e,i,n=!1,r){if(t!==void 0){let s=this.constructor;if(n===!1&&(r=this[t]),i??=s.getPropertyOptions(t),!((i.hasChanged??Ln)(r,e)||i.useDefault&&i.reflect&&r===this._$Ej?.get(t)&&!this.hasAttribute(s._$Eu(t,i))))return;this.C(t,e,i)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(t,e,{useDefault:i,reflect:n,wrapped:r},s){i&&!(this._$Ej??=new Map).has(t)&&(this._$Ej.set(t,s??e??this[t]),r!==!0||s!==void 0)||(this._$AL.has(t)||(this.hasUpdated||i||(e=void 0),this._$AL.set(t,e)),n===!0&&this._$Em!==t&&(this._$Eq??=new Set).add(t))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(e){Promise.reject(e)}let t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(let[n,r]of this._$Ep)this[n]=r;this._$Ep=void 0}let i=this.constructor.elementProperties;if(i.size>0)for(let[n,r]of i){let{wrapped:s}=r,a=this[n];s!==!0||this._$AL.has(n)||a===void 0||this.C(n,void 0,r,a)}}let t=!1,e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),this._$EO?.forEach(i=>i.hostUpdate?.()),this.update(e)):this._$EM()}catch(i){throw t=!1,this._$EM(),i}t&&this._$AE(e)}willUpdate(t){}_$AE(t){this._$EO?.forEach(e=>e.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Eq&&=this._$Eq.forEach(e=>this._$ET(e,this[e])),this._$EM()}updated(t){}firstUpdated(t){}};re.elementStyles=[],re.shadowRootOptions={mode:"open"},re[Ar("elementProperties")]=new Map,re[Ar("finalized")]=new Map,pu?.({ReactiveElement:re}),(_r.reactiveElementVersions??=[]).push("2.1.2");var Hn=globalThis,$c=o=>o,Vn=Hn.trustedTypes,Lc=Vn?Vn.createPolicy("lit-html",{createHTML:o=>o}):void 0,Na="$lit$",ne=`lit$${Math.random().toFixed(9).slice(2)}$`,$a="?"+ne,uu=`<${$a}>`,Ze=Hn.document===void 0?{createTreeWalker:()=>({})}:document,Rr=()=>Ze.createComment(""),Pr=o=>o===null||typeof o!="object"&&typeof o!="function",La=Array.isArray,Uc=o=>La(o)||typeof o?.[Symbol.iterator]=="function",Da=`[
3
3
  \f\r]`,Tr=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Vc=/-->/g,zc=/>/g,Je=RegExp(`>|${Da}(?:([^\\s"'>=/]+)(${Da}*=${Da}*(?:[^
4
- \f\r"'\`<>=]|("|')|))|$)`,"g"),jc=/'/g,Fc=/"/g,Hc=/^(?:script|style|textarea|title)$/i,Va=o=>(t,...e)=>({_$litType$:o,strings:t,values:e}),b=Va(1),Mr=Va(2),qg=Va(3),rt=Symbol.for("lit-noChange"),O=Symbol.for("lit-nothing"),Bc=new WeakMap,Ke=Ze.createTreeWalker(Ze,129);function Wc(o,t){if(!La(o)||!o.hasOwnProperty("raw"))throw Error("invalid template strings array");return Lc!==void 0?Lc.createHTML(t):t}var Qc=(o,t)=>{let e=o.length-1,i=[],n,r=t===2?"<svg>":t===3?"<math>":"",s=Tr;for(let a=0;a<e;a++){let l=o[a],c,d,h=-1,f=0;for(;f<l.length&&(s.lastIndex=f,d=s.exec(l),d!==null);)f=s.lastIndex,s===Tr?d[1]==="!--"?s=Vc:d[1]!==void 0?s=zc:d[2]!==void 0?(Hc.test(d[2])&&(n=RegExp("</"+d[2],"g")),s=Je):d[3]!==void 0&&(s=Je):s===Je?d[0]===">"?(s=n??Tr,h=-1):d[1]===void 0?h=-2:(h=s.lastIndex-d[2].length,c=d[1],s=d[3]===void 0?Je:d[3]==='"'?Fc:jc):s===Fc||s===jc?s=Je:s===Vc||s===zc?s=Tr:(s=Je,n=void 0);let m=s===Je&&o[a+1].startsWith("/>")?" ":"";r+=s===Tr?l+uu:h>=0?(i.push(c),l.slice(0,h)+Na+l.slice(h)+ne+m):l+ne+(h===-2?a:m)}return[Wc(o,r+(o[e]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),i]},Or=class o{constructor({strings:t,_$litType$:e},i){let n;this.parts=[];let r=0,s=0,a=t.length-1,l=this.parts,[c,d]=Qc(t,e);if(this.el=o.createElement(c,i),Ke.currentNode=this.el.content,e===2||e===3){let h=this.el.content.firstChild;h.replaceWith(...h.childNodes)}for(;(n=Ke.nextNode())!==null&&l.length<a;){if(n.nodeType===1){if(n.hasAttributes())for(let h of n.getAttributeNames())if(h.endsWith(Na)){let f=d[s++],m=n.getAttribute(h).split(ne),v=/([.?@])?(.*)/.exec(f);l.push({type:1,index:r,name:v[2],strings:m,ctor:v[1]==="."?jn:v[1]==="?"?Fn:v[1]==="@"?Bn:ei}),n.removeAttribute(h)}else h.startsWith(ne)&&(l.push({type:6,index:r}),n.removeAttribute(h));if(Hc.test(n.tagName)){let h=n.textContent.split(ne),f=h.length-1;if(f>0){n.textContent=Vn?Vn.emptyScript:"";for(let m=0;m<f;m++)n.append(h[m],Rr()),Ke.nextNode(),l.push({type:2,index:++r});n.append(h[f],Rr())}}}else if(n.nodeType===8)if(n.data===$a)l.push({type:2,index:r});else{let h=-1;for(;(h=n.data.indexOf(ne,h+1))!==-1;)l.push({type:7,index:r}),h+=ne.length-1}r++}}static createElement(t,e){let i=Ze.createElement("template");return i.innerHTML=t,i}};function ti(o,t,e=o,i){if(t===rt)return t;let n=i!==void 0?e._$Co?.[i]:e._$Cl,r=Pr(t)?void 0:t._$litDirective$;return n?.constructor!==r&&(n?._$AO?.(!1),r===void 0?n=void 0:(n=new r(o),n._$AT(o,e,i)),i!==void 0?(e._$Co??=[])[i]=n:e._$Cl=n),n!==void 0&&(t=ti(o,n._$AS(o,t.values),n,i)),t}var zn=class{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){let{el:{content:e},parts:i}=this._$AD,n=(t?.creationScope??Ze).importNode(e,!0);Ke.currentNode=n;let r=Ke.nextNode(),s=0,a=0,l=i[0];for(;l!==void 0;){if(s===l.index){let c;l.type===2?c=new Ai(r,r.nextSibling,this,t):l.type===1?c=new l.ctor(r,l.name,l.strings,this,t):l.type===6&&(c=new Un(r,this,t)),this._$AV.push(c),l=i[++a]}s!==l?.index&&(r=Ke.nextNode(),s++)}return Ke.currentNode=Ze,n}p(t){let e=0;for(let i of this._$AV)i!==void 0&&(i.strings!==void 0?(i._$AI(t,i,e),e+=i.strings.length-2):i._$AI(t[e])),e++}},Ai=class o{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,e,i,n){this.type=2,this._$AH=O,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=i,this.options=n,this._$Cv=n?.isConnected??!0}get parentNode(){let t=this._$AA.parentNode,e=this._$AM;return e!==void 0&&t?.nodeType===11&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=ti(this,t,e),Pr(t)?t===O||t==null||t===""?(this._$AH!==O&&this._$AR(),this._$AH=O):t!==this._$AH&&t!==rt&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):Uc(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==O&&Pr(this._$AH)?this._$AA.nextSibling.data=t:this.T(Ze.createTextNode(t)),this._$AH=t}$(t){let{values:e,_$litType$:i}=t,n=typeof i=="number"?this._$AC(t):(i.el===void 0&&(i.el=Or.createElement(Wc(i.h,i.h[0]),this.options)),i);if(this._$AH?._$AD===n)this._$AH.p(e);else{let r=new zn(n,this),s=r.u(this.options);r.p(e),this.T(s),this._$AH=r}}_$AC(t){let e=Bc.get(t.strings);return e===void 0&&Bc.set(t.strings,e=new Or(t)),e}k(t){La(this._$AH)||(this._$AH=[],this._$AR());let e=this._$AH,i,n=0;for(let r of t)n===e.length?e.push(i=new o(this.O(Rr()),this.O(Rr()),this,this.options)):i=e[n],i._$AI(r),n++;n<e.length&&(this._$AR(i&&i._$AB.nextSibling,n),e.length=n)}_$AR(t=this._$AA.nextSibling,e){for(this._$AP?.(!1,!0,e);t!==this._$AB;){let i=$c(t).nextSibling;$c(t).remove(),t=i}}setConnected(t){this._$AM===void 0&&(this._$Cv=t,this._$AP?.(t))}},ei=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,i,n,r){this.type=1,this._$AH=O,this._$AN=void 0,this.element=t,this.name=e,this._$AM=n,this.options=r,i.length>2||i[0]!==""||i[1]!==""?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=O}_$AI(t,e=this,i,n){let r=this.strings,s=!1;if(r===void 0)t=ti(this,t,e,0),s=!Pr(t)||t!==this._$AH&&t!==rt,s&&(this._$AH=t);else{let a=t,l,c;for(t=r[0],l=0;l<r.length-1;l++)c=ti(this,a[i+l],e,l),c===rt&&(c=this._$AH[l]),s||=!Pr(c)||c!==this._$AH[l],c===O?t=O:t!==O&&(t+=(c??"")+r[l+1]),this._$AH[l]=c}s&&!n&&this.j(t)}j(t){t===O?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}},jn=class extends ei{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===O?void 0:t}},Fn=class extends ei{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==O)}},Bn=class extends ei{constructor(t,e,i,n,r){super(t,e,i,n,r),this.type=5}_$AI(t,e=this){if((t=ti(this,t,e,0)??O)===rt)return;let i=this._$AH,n=t===O&&i!==O||t.capture!==i.capture||t.once!==i.once||t.passive!==i.passive,r=t!==O&&(i===O||n);n&&this.element.removeEventListener(this.name,this,i),r&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){typeof this._$AH=="function"?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t)}},Un=class{constructor(t,e,i){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(t){ti(this,t)}},it={M:Na,P:ne,A:$a,C:1,L:Qc,R:zn,D:Uc,V:ti,I:Ai,H:ei,N:Fn,U:Bn,B:jn,F:Un},mu=Hn.litHtmlPolyfillSupport;mu?.(Or,Ai),(Hn.litHtmlVersions??=[]).push("3.3.3");var za=(o,t,e)=>{let i=e?.renderBefore??t,n=i._$litPart$;if(n===void 0){let r=e?.renderBefore??null;i._$litPart$=n=new Ai(t.insertBefore(Rr(),r),r,void 0,e??{})}return n._$AI(o),n};var ja=globalThis,C=class extends re{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){let t=super.createRenderRoot();return this.renderOptions.renderBefore??=t.firstChild,t}update(t){let e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=za(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return rt}};C._$litElement$=!0,C.finalized=!0,ja.litElementHydrateSupport?.({LitElement:C});var fu=ja.litElementPolyfillSupport;fu?.({LitElement:C});(ja.litElementVersions??=[]).push("4.2.2");var gu={attribute:!0,type:String,converter:Ir,reflect:!1,hasChanged:Ln},bu=(o=gu,t,e)=>{let{kind:i,metadata:n}=e,r=globalThis.litPropertyMetadata.get(n);if(r===void 0&&globalThis.litPropertyMetadata.set(n,r=new Map),i==="setter"&&((o=Object.create(o)).wrapped=!0),r.set(e.name,o),i==="accessor"){let{name:s}=e;return{set(a){let l=t.get.call(this);t.set.call(this,a),this.requestUpdate(s,l,o,!0,a)},init(a){return a!==void 0&&this.C(s,void 0,o,a),a}}}if(i==="setter"){let{name:s}=e;return function(a){let l=this[s];t.call(this,a),this.requestUpdate(s,l,o,!0,a)}}throw Error("Unsupported decorator location: "+i)};function p(o){return(t,e)=>typeof e=="object"?bu(o,t,e):((i,n,r)=>{let s=n.hasOwnProperty(r);return n.constructor.createProperty(r,i),s?Object.getOwnPropertyDescriptor(n,r):void 0})(o,t,e)}function T(o){return p({...o,state:!0,attribute:!1})}var ye=(o,t,e)=>(e.configurable=!0,e.enumerable=!0,Reflect.decorate&&typeof t!="object"&&Object.defineProperty(o,t,e),e);function Ii(o,t){return(e,i,n)=>{let r=s=>s.renderRoot?.querySelector(o)??null;if(t){let{get:s,set:a}=typeof i=="object"?e:n??(()=>{let l=Symbol();return{get(){return this[l]},set(c){this[l]=c}}})();return ye(e,i,{get(){let l=s.call(this);return l===void 0&&(l=r(this),(l!==null||this.hasUpdated)&&a.call(this,l)),l}})}return ye(e,i,{get(){return r(this)}})}}function Xc(o){return(t,e)=>{let{slot:i,selector:n}=o??{},r="slot"+(i?`[name=${i}]`:":not([name])");return ye(t,e,{get(){let s=this.renderRoot?.querySelector(r),a=s?.assignedElements(o)??[];return n===void 0?a:a.filter(l=>l.matches(n))}})}}var oe=class extends Event{constructor(t,e,i,n){super("context-request",{bubbles:!0,composed:!0}),this.context=t,this.contextTarget=e,this.callback=i,this.subscribe=n??!1}};var wt=class{constructor(t,e,i,n){if(this.subscribe=!1,this.provided=!1,this.value=void 0,this.t=(r,s)=>{this.unsubscribe&&(this.unsubscribe!==s&&(this.provided=!1,this.unsubscribe()),this.subscribe||this.unsubscribe()),this.value=r,this.host.requestUpdate(),this.provided&&!this.subscribe||(this.provided=!0,this.callback&&this.callback(r,s)),this.unsubscribe=s},this.host=t,e.context!==void 0){let r=e;this.context=r.context,this.callback=r.callback,this.subscribe=r.subscribe??!1}else this.context=e,this.callback=i,this.subscribe=n??!1;this.host.addController(this)}hostConnected(){this.dispatchRequest()}hostDisconnected(){this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=void 0)}dispatchRequest(){this.host.dispatchEvent(new oe(this.context,this.host,this.t,this.subscribe))}};var Wn=class{get value(){return this.o}set value(t){this.setValue(t)}setValue(t,e=!1){let i=e||!Object.is(t,this.o);this.o=t,i&&this.updateObservers()}constructor(t){this.subscriptions=new Map,this.updateObservers=()=>{for(let[e,{disposer:i}]of this.subscriptions)e(this.o,i)},t!==void 0&&(this.value=t)}addCallback(t,e,i){if(!i)return void t(this.value);this.subscriptions.has(t)||this.subscriptions.set(t,{disposer:()=>{this.subscriptions.delete(t)},consumerHost:e});let{disposer:n}=this.subscriptions.get(t);t(this.value,n)}clearCallbacks(){this.subscriptions.clear()}};var Fa=class extends Event{constructor(t,e){super("context-provider",{bubbles:!0,composed:!0}),this.context=t,this.contextTarget=e}},ve=class extends Wn{constructor(t,e,i){super(e.context!==void 0?e.initialValue:i),this.onContextRequest=n=>{if(n.context!==this.context)return;let r=n.contextTarget??n.composedPath()[0];r!==this.host&&(n.stopPropagation(),this.addCallback(n.callback,r,n.subscribe))},this.onProviderRequest=n=>{if(n.context!==this.context||(n.contextTarget??n.composedPath()[0])===this.host)return;let r=new Set;for(let[s,{consumerHost:a}]of this.subscriptions)r.has(s)||(r.add(s),a.dispatchEvent(new oe(this.context,a,s,!0)));n.stopPropagation()},this.host=t,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 Fa(this.context,this.host))}};var Dr=class{constructor(){this.pendingContextRequests=new Map,this.onContextProvider=t=>{let e=this.pendingContextRequests.get(t.context);if(e===void 0)return;this.pendingContextRequests.delete(t.context);let{requests:i}=e;for(let{elementRef:n,callbackRef:r}of i){let s=n.deref(),a=r.deref();s===void 0||a===void 0||s.dispatchEvent(new oe(t.context,s,a,!0))}},this.onContextRequest=t=>{if(t.subscribe!==!0)return;let e=t.contextTarget??t.composedPath()[0],i=t.callback,n=this.pendingContextRequests.get(t.context);n===void 0&&this.pendingContextRequests.set(t.context,n={callbacks:new WeakMap,requests:[]});let r=n.callbacks.get(e);r===void 0&&n.callbacks.set(e,r=new WeakSet),r.has(i)||(r.add(i),n.requests.push({elementRef:new WeakRef(e),callbackRef:new WeakRef(i)}))}}attach(t){t.addEventListener("context-request",this.onContextRequest),t.addEventListener("context-provider",this.onContextProvider)}detach(t){t.removeEventListener("context-request",this.onContextRequest),t.removeEventListener("context-provider",this.onContextProvider)}};function U({context:o}){return(t,e)=>{let i=new WeakMap;if(typeof e=="object")return{get(){return t.get.call(this)},set(n){return i.get(this).setValue(n),t.set.call(this,n)},init(n){return i.set(this,new ve(this,{context:o,initialValue:n})),n}};{t.constructor.addInitializer((s=>{i.set(s,new ve(s,{context:o}))}));let n=Object.getOwnPropertyDescriptor(t,e),r;if(n===void 0){let s=new WeakMap;r={get(){return s.get(this)},set(a){i.get(this).setValue(a),s.set(this,a)},configurable:!0,enumerable:!0}}else{let s=n.set;r={...n,set(a){i.get(this).setValue(a),s?.call(this,a)}}}return void Object.defineProperty(t,e,r)}}}function _({context:o,subscribe:t}){return(e,i)=>{typeof i=="object"?i.addInitializer((function(){new wt(this,{context:o,callback:n=>{e.set.call(this,n)},subscribe:t})})):e.constructor.addInitializer((n=>{new wt(n,{context:o,callback:r=>{n[i]=r},subscribe:t})}))}}var Qn=["this"],Gc=["+","-","!"],Yc=["=","+","-","*","/","%","^","==","!=",">","<",">=","<=","||","&&","??","&","===","!==","|","|>"],Ba={"!":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},Xn=13;var yu=["==","!=","<=",">=","||","&&","??","|>"],vu=["===","!=="],M;(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"})(M||(M={}));var Ht=(o,t,e=0)=>({kind:o,value:t,precedence:e}),wu=o=>o===9||o===10||o===13||o===32,Jc=o=>o===95||o===36||(o&=-33,65<=o&&o<=90),xu=o=>Jc(o)||Nr(o),qu=o=>Qn.indexOf(o)!==-1,Cu=o=>o===34||o===39,Nr=o=>48<=o&&o<=57,ku=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,Su=o=>o===40||o===41||o===91||o===93||o===123||o===125,Eu=o=>o.replace(/\\(.)/g,(t,e)=>{switch(e){case"n":return`
5
- `;case"r":return"\r";case"t":return" ";case"b":return"\b";case"f":return"\f";default:return e}}),Gn=class{#t;#e=-1;#i=0;#r;constructor(t){this.#t=t,this.#n()}nextToken(){for(;wu(this.#r);)this.#n(!0);if(Cu(this.#r))return this.#a();if(Jc(this.#r))return this.#c();if(Nr(this.#r))return this.#p();if(this.#r===46)return this.#l();if(this.#r===44)return this.#m();if(this.#r===58)return this.#d();if(ku(this.#r))return this.#h();if(Su(this.#r))return this.#b();if(this.#n(),this.#r!==void 0)throw new Error(`Expected end of input, got ${this.#r}`)}#n(t){this.#e++,this.#e<this.#t.length?(this.#r=this.#t.charCodeAt(this.#e),t===!0&&(this.#i=this.#e)):this.#r=void 0}#o(t=0){let e=this.#t.substring(this.#i,this.#e+t);return t===0&&this.#s(),e}#s(){this.#i=this.#e}#a(){let t="unterminated string",e=this.#r;for(this.#n(!0);this.#r!==e;){if(this.#r===void 0)throw new Error(t);if(this.#r===92&&(this.#n(),this.#r===void 0))throw new Error(t);this.#n()}let i=Ht(M.STRING,Eu(this.#o()));return this.#n(),i}#c(){do this.#n();while(xu(this.#r));let t=this.#o(),e=qu(t)?M.KEYWORD:M.IDENTIFIER;return Ht(e,t)}#p(){do this.#n();while(Nr(this.#r));return this.#r===46?this.#l():Ht(M.INTEGER,this.#o())}#l(){return this.#n(),Nr(this.#r)?this.#u():(this.#s(),Ht(M.DOT,".",Xn))}#m(){return this.#n(!0),Ht(M.COMMA,",")}#d(){return this.#n(!0),Ht(M.COLON,":")}#u(){do this.#n();while(Nr(this.#r));return Ht(M.DECIMAL,this.#o())}#h(){this.#n();let t=this.#o(2);if(vu.indexOf(t)!==-1)this.#n(),this.#n();else{if(t=this.#o(1),t==="=>")return this.#n(),Ht(M.ARROW,t);yu.indexOf(t)!==-1&&this.#n()}return t=this.#o(),Ht(M.OPERATOR,t,Ba[t])}#b(){let t=String.fromCharCode(this.#r),e=Ht(M.GROUPER,t,Ba[t]);return this.#n(!0),e}};var Ua=(o,t)=>new $r(o,t).parse(),$r=class{#t;#e;#i;#r;#n;constructor(t,e){this.#e=new Gn(t),this.#i=e}parse(){return this.#o(),this.#s()}#o(t,e){if(!this._matches(t,e))throw new Error(`Expected kind ${t} (${e}), was ${this.#r?.kind} (${this.#r?.value})`);let i=this.#e.nextToken();this.#r=i,this.#t=i?.kind,this.#n=i?.value}_matches(t,e){return!(t&&this.#t!==t||e&&this.#n!==e)}#s(){if(!this.#r)return this.#i.empty();let t=this.#l();return t===void 0?void 0:this.#a(t,0)}#a(t,e){if(t===void 0)throw new Error("Expected left to be defined.");for(;this.#r;)if(this._matches(M.GROUPER,"(")){let i=this.#y();t=this.#i.invoke(t,void 0,i)}else if(this._matches(M.GROUPER,"[")){let i=this.#g();t=this.#i.index(t,i)}else if(this._matches(M.DOT)){this.#o();let i=this.#l();t=this.#c(t,i)}else{if(this._matches(M.KEYWORD))break;if(this._matches(M.OPERATOR)&&this.#r.precedence>=e)t=this.#n==="?"?this.#m(t):this.#p(t,this.#r);else break}return t}#c(t,e){if(e===void 0)throw new Error("expected identifier");if(e.type==="ID")return this.#i.getter(t,e.value);if(e.type==="Invoke"&&e.receiver.type==="ID"){let i=e.receiver;return this.#i.invoke(t,i.value,e.arguments)}else throw new Error(`expected identifier: ${e}`)}#p(t,e){if(Yc.indexOf(e.value)===-1)throw new Error(`unknown operator: ${e.value}`);this.#o();let i=this.#l();for(;(this.#t===M.OPERATOR||this.#t===M.DOT||this.#t===M.GROUPER)&&this.#r.precedence>e.precedence;)i=this.#a(i,this.#r.precedence);return this.#i.binary(t,e.value,i)}#l(){if(this._matches(M.OPERATOR)){let t=this.#n;if(this.#o(),t==="+"||t==="-"){if(this._matches(M.INTEGER))return this.#C(t);if(this._matches(M.DECIMAL))return this.#E(t)}if(Gc.indexOf(t)===-1)throw new Error(`unexpected token: ${t}`);let e=this.#a(this.#d(),Xn);return this.#i.unary(t,e)}return this.#d()}#m(t){this.#o(M.OPERATOR,"?");let e=this.#s();this.#o(M.COLON);let i=this.#s();return this.#i.ternary(t,e,i)}#d(){switch(this.#t){case M.KEYWORD:let t=this.#n;if(t==="this")return this.#o(),this.#i.id(t);throw Qn.indexOf(t)!==-1?new Error(`unexpected keyword: ${t}`):new Error(`unrecognized keyword: ${t}`);case M.IDENTIFIER:return this.#b();case M.STRING:return this.#x();case M.INTEGER:return this.#C();case M.DECIMAL:return this.#E();case M.GROUPER:return this.#n==="("?this.#v():this.#n==="{"?this.#h():this.#n==="["?this.#u():void 0;case M.COLON:throw new Error('unexpected token ":"');default:return}}#u(){let t=[];do{if(this.#o(),this._matches(M.GROUPER,"]"))break;t.push(this.#s())}while(this._matches(M.COMMA));return this.#o(M.GROUPER,"]"),this.#i.list(t)}#h(){let t={};do{if(this.#o(),this._matches(M.GROUPER,"}"))break;let e=this.#n;(this._matches(M.STRING)||this._matches(M.IDENTIFIER))&&this.#o(),this.#o(M.COLON),t[e]=this.#s()}while(this._matches(M.COMMA));return this.#o(M.GROUPER,"}"),this.#i.map(t)}#b(){let t=this.#n;if(t==="true")return this.#o(),this.#i.literal(!0);if(t==="false")return this.#o(),this.#i.literal(!1);if(t==="null")return this.#o(),this.#i.literal(null);if(t==="undefined")return this.#o(),this.#i.literal(void 0);let e=this.#f(),i=this.#y();return i?this.#i.invoke(e,void 0,i):e}#f(){if(!this._matches(M.IDENTIFIER))throw new Error(`expected identifier: ${this.#n}`);let t=this.#n;return this.#o(),this.#i.id(t)}#y(){if(!this._matches(M.GROUPER,"("))return;let t=[];do{if(this.#o(),this._matches(M.GROUPER,")"))break;let e=this.#s();t.push(e)}while(this._matches(M.COMMA));return this.#o(M.GROUPER,")"),t}#g(){this.#o();let t=this.#s();return this.#o(M.GROUPER,"]"),t}#v(){let t=this.#y();if(this._matches(M.ARROW)){this.#o();let e=this.#s(),i=t?.map(n=>n.value)??[];return this.#i.arrowFunction(i,e)}else return this.#i.paren(t[0])}#x(){let t=this.#i.literal(this.#n);return this.#o(),t}#C(t=""){let e=this.#i.literal(parseInt(`${t}${this.#n}`,10));return this.#o(),e}#E(t=""){let e=this.#i.literal(parseFloat(`${t}${this.#n}`));return this.#o(),e}};var{hasOwn:Kc,fromEntries:Au}=Object,Iu={"+":(o,t)=>o+t,"-":(o,t)=>o-t,"*":(o,t)=>o*t,"/":(o,t)=>o/t,"%":(o,t)=>o%t,"==":(o,t)=>o==t,"!=":(o,t)=>o!=t,"===":(o,t)=>o===t,"!==":(o,t)=>o!==t,">":(o,t)=>o>t,">=":(o,t)=>o>=t,"<":(o,t)=>o<t,"<=":(o,t)=>o<=t,"||":(o,t)=>o||t,"&&":(o,t)=>o&&t,"??":(o,t)=>o??t,"|":(o,t)=>t(o),"|>":(o,t)=>t(o)},_u={"+":o=>o,"-":o=>-o,"!":o=>!o},Yn=class{empty(){return{type:"Empty",evaluate(t){return t},getIds(t){return t}}}literal(t){return{type:"Literal",value:t,evaluate(e){return this.value},getIds(e){return e}}}id(t){return{type:"ID",value:t,evaluate(e){return this.value==="this"?e:e?.[this.value]},getIds(e){return e.push(this.value),e}}}unary(t,e){let i=_u[t];return{type:"Unary",operator:t,child:e,evaluate(n){return i(this.child.evaluate(n))},getIds(n){return this.child.getIds(n)}}}binary(t,e,i){let n=Iu[e];return{type:"Binary",operator:e,left:t,right:i,evaluate(r){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 s=this.right.evaluate(r),a,l;return this.left.type==="Getter"?(a=this.left.receiver.evaluate(r),l=this.left.name):this.left.type==="Index"?(a=this.left.receiver.evaluate(r),l=this.left.argument.evaluate(r)):this.left.type==="ID"&&(a=r,l=this.left.value),a===void 0?void 0:a[l]=s}return n(this.left.evaluate(r),this.right.evaluate(r))},getIds(r){return this.left.getIds(r),this.right.getIds(r),r}}}getter(t,e){return{type:"Getter",receiver:t,name:e,evaluate(i){return this.receiver.evaluate(i)?.[this.name]},getIds(i){return this.receiver.getIds(i),i}}}invoke(t,e,i){if(e!=null&&typeof e!="string")throw new Error("method not a string");return{type:"Invoke",receiver:t,method:e,arguments:i,evaluate(n){let r=this.receiver.evaluate(n),s=this.method?r:n?.this??n,a=this.method?r?.[e]:r,c=(this.arguments??[]).map(d=>d?.evaluate(n));return a?.apply?.(s,c)},getIds(n){return this.receiver.getIds(n),this.arguments?.forEach(r=>r?.getIds(n)),n}}}paren(t){return t}index(t,e){return{type:"Index",receiver:t,argument:e,evaluate(i){return this.receiver.evaluate(i)?.[this.argument.evaluate(i)]},getIds(i){return this.receiver.getIds(i),i}}}ternary(t,e,i){return{type:"Ternary",condition:t,trueExpr:e,falseExpr:i,evaluate(n){return this.condition.evaluate(n)?this.trueExpr.evaluate(n):this.falseExpr.evaluate(n)},getIds(n){return this.condition.getIds(n),this.trueExpr.getIds(n),this.falseExpr.getIds(n),n}}}map(t){return{type:"Map",entries:t,evaluate(e){let i={};if(t&&this.entries)for(let n in t){let r=this.entries[n];r&&(i[n]=r.evaluate(e))}return i},getIds(e){if(t&&this.entries)for(let i in t){let n=this.entries[i];n&&n.getIds(e)}return e}}}list(t){return{type:"List",items:t,evaluate(e){return this.items?.map(i=>i?.evaluate(e))},getIds(e){return this.items?.forEach(i=>i?.getIds(e)),e}}}arrowFunction(t,e){return{type:"ArrowFunction",params:t,body:e,evaluate(i){let n=this.params,r=this.body;return function(...s){let a=Au(n.map((c,d)=>[c,s[d]])),l=new Proxy(i??{},{set(c,d,h){return Kc(a,d)&&(a[d]=h),c[d]=h},get(c,d){return Kc(a,d)?a[d]:c[d]}});return r.evaluate(l)}},getIds(i){return this.body.getIds(i).filter(n=>!this.params.includes(n))}}}};var Ha=null,Zc={boundAttributeSuffix:it.M,marker:it.P,markerMatch:it.A,HTML_RESULT:it.C,getTemplateHtml:it.L,overrideDirectiveResolve:(o,t)=>class extends o{_$AS(e,i){return t(this,i)}},patchDirectiveResolve:(o,t)=>{if(o.prototype._$AS.name!==t.name){Ha??=o.prototype._$AS.name;for(let e=o.prototype;e!==Object.prototype;e=Object.getPrototypeOf(e))if(e.hasOwnProperty(Ha))return void(e[Ha]=t);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,t){o._$litDirective$=t},getAttributePartCommittedValue:(o,t,e)=>{let i=rt;return o.j=n=>i=n,o._$AI(t,o,e),i},connectedDisconnectable:o=>({...o,_$AU:!0}),resolveDirective:it.V,AttributePart:it.H,PropertyPart:it.B,BooleanAttributePart:it.N,EventPart:it.U,ElementPart:it.F,TemplateInstance:it.R,isIterable:it.D,ChildPart:it.I};var{AttributePart:Tu,PropertyPart:Ru,BooleanAttributePart:Pu,EventPart:Ou}=Zc,Qa=new Yn,Wa=new Map,td=o=>o.replace(/-(-|\w)/g,(t,e)=>e.toUpperCase()),Jn=(o,t)=>{let e=Wa.get(o);if(e===void 0){if(Wa.has(o))return;if(o=o.trim(),o.startsWith("{{")&&o.endsWith("}}")){let i=o.substring(2,o.length-2).trim();e=new $r(i,Qa).parse(),Wa.set(o,e)}}return e?.evaluate(t)},Mu=(o,t,e,i)=>{let n=o.getAttribute("if");if(n!==null&&Jn(n,t))return Kn(o,t,e,i)},ed=/(?<!\\){{(.*?)(?:(?<!\\)}})/g,id=o=>/(?:\\{{)|(?:\\}})/g.test(o),Lr=o=>o.replaceAll(/\\{{/g,"{{").replace(/\\}}/g,"}}"),Du=(o,t,e,i)=>{let n=o.getAttribute("repeat");if(n!==null){let r=Jn(n,t);if(!r[Symbol.iterator])return O;let s=Vr(o),a=-1,l=[];for(let c of r){a++;let d=Object.create(t);d.item=c,d.index=a,d.this=t.this??t;let h=[];for(let m of s.parts){let v=m.update(d,e,i);m.type===1?h.push(...v):h.push(v)}let f={_$litType$:s,values:h};l.push(f)}return l}},nd={if:Mu,repeat:Du},we=(o,t=nd,e={},i)=>{let r=Vr(o).renderers;if(i){let a=Vr(i).renderers,l=r.super;l!==void 0?e={...r,...e,super:(c,d,h)=>(h={...a,...h,super:(f,m,v)=>Kn(i,f,m,v)},l(c,d,h))}:(e={...a,...r,...e},o=i)}else e={...r,...e};return s=>Kn(o,s,t,e)};var Kn=(o,t,e=nd,i={})=>{let n=Vr(o),r=[];for(let a of n.parts){let l=a.update(t,e,i);a.type===1?r.push(...l):r.push(l)}return{_$litType$:n,values:r}},rd=new Map,Vr=o=>{let t=rd.get(o);return t===void 0&&rd.set(o,t=Nu(o)),t},Nu=o=>{let t={h:void 0,el:o.cloneNode(!0),parts:[],renderers:{}},e=document.createTreeWalker(t.el.content,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT|NodeFilter.SHOW_COMMENT),i=e.currentNode,n=-1,r=[];for(;(i=e.nextNode())!==null;)if(i.nodeType===Node.COMMENT_NODE)n++;else if(i.nodeType===Node.ELEMENT_NODE){n++;let s=i;if(s.tagName==="TEMPLATE"){let l=s.getAttribute("type"),c=s.getAttribute("name"),d=s.getAttribute("call");if(d!==null||l!==null||c!==null){s.parentNode.insertBefore(document.createComment(""),s),r.push(s);let h;if(d!==null){let f=d.trim(),m=f.startsWith("{{")&&f.endsWith("}}");h=(v,x,u)=>{let g=s.getAttribute("data"),y=g===null?void 0:Jn(g,v);return(m?Jn(f,v):u[d])?.(y,x,u)}}else l!==null?h=(f,m,v)=>{let x=m[l];return x?.(s,f,m,v)}:(c==="super"?t.renderers.super=(f,m,v)=>{let x=v.super,u=Vr(s);return v={...v,...u.renderers},x(f,m,v)}:t.renderers[c]=(f,m,v)=>Kn(s,f,m,v),h=(f,m,v)=>{let x=v[c];return x?.(f,m,v)});t.parts.push({type:2,index:n,update:h});continue}}let a=s.getAttributeNames();for(let l of a){let c=s.getAttribute(l),d=c.split(ed);if(d.length===1){id(c)&&s.setAttribute(l,Lr(c));continue}s.removeAttribute(l);let h=l,f=Tu,m=l[0];m==="."?(h=td(l.substring(1)),f=Ru):m==="?"?(h=l.substring(1),f=Pu):m==="@"&&(h=td(l.substring(1)),f=Ou);let v=[Lr(d[0])],x=[];for(let u=1;u<d.length;u+=2){let g=d[u];x.push(Ua(g,Qa)),v.push(Lr(d[u+1]))}t.parts.push({type:1,index:n,name:h,strings:v,ctor:f,update:(u,g,y)=>x.map(w=>w.evaluate(u))})}}else if(i.nodeType===Node.TEXT_NODE){let s=i,a=s.textContent,l=a.split(ed);l.length>1?s.textContent=Lr(l[0]):id(a)&&(s.textContent=Lr(a));for(let c=1;c<l.length;c+=2){let d=l[c],h=Ua(d,Qa);t.parts.push({type:2,index:++n,update:(m,v)=>h.evaluate(m)});let f=new Text(l[c+1].replace("\\{{","{{"));s.parentNode.insertBefore(f,s.nextSibling),s.parentNode.insertBefore(document.createComment(""),s.nextSibling),s=f,e.currentNode=f}}for(let s of r)s.remove();return t};var Xa=Symbol.for("qti-components.context-root"),$u=()=>{if(typeof document>"u")return;let o=globalThis;o[Xa]||(o[Xa]=new Dr,o[Xa].attach(document.documentElement))};$u();var od=[];var Ya=class extends Set{#t;constructor(t){super(),this.#t=t}add(t){return super.add(t),this.#e(),this}delete(t){let e=super.delete(t);return this.#e(),e}clear(){super.clear(),this.#e()}#e(){this.#t.isConnected?this.#i():queueMicrotask(()=>this.#i())}#i(){this.size===0?this.#t.removeAttribute("data-state"):this.#t.setAttribute("data-state",Array.from(this).join(" "))}},Ga="custom-state-support-probe";function Lu(o){if(!("states"in ElementInternals.prototype))return"missing";if(typeof customElements>"u")return"modern";try{customElements.get(Ga)||customElements.define(Ga,class extends HTMLElement{});let t=o.call(document.createElement(Ga)).states;return t?(t.add("probe"),t.delete("probe"),"modern"):"missing"}catch{return"legacy"}}var sd=!1;function ad(){if(sd)return"already-installed";if(typeof HTMLElement>"u"||typeof ElementInternals>"u")return"modern";let o=HTMLElement.prototype.attachInternals;if(!o)return"modern";let t=Lu(o);return t==="modern"||(sd=!0,HTMLElement.prototype.attachInternals=function(){let i=o.call(this);return Object.defineProperty(i,"states",{configurable:!0,enumerable:!0,value:new Ya(this)}),i}),t}ad();for(let{tag:o,ctor:t}of od)customElements.get(o)||customElements.define(o,t);var xe=Symbol("computedItemContext");var j=Symbol("computedContext");var xt=Symbol("configContext");var _i=Symbol("interactionContext");var F=Symbol("item");var ld=[{identifier:"completionStatus",cardinality:"single",baseType:"string",value:"unknown",type:"outcome"},{identifier:"numAttempts",cardinality:"single",baseType:"integer",value:"0",type:"response"}];var Vu=/^[A-Za-z0-9-]+$/,zu=o=>typeof o=="string"&&Vu.test(o),my=o=>zu(o)?o:void 0,qt=Symbol("qtiContext");var Ja={view:"candidate"},qe=Symbol("sessionContext");var Ka={items:[],testOutcomeVariables:[]},nt=Symbol("testContext");var P=q`
4
+ \f\r"'\`<>=]|("|')|))|$)`,"g"),jc=/'/g,Fc=/"/g,Hc=/^(?:script|style|textarea|title)$/i,Va=o=>(t,...e)=>({_$litType$:o,strings:t,values:e}),b=Va(1),Mr=Va(2),Cg=Va(3),rt=Symbol.for("lit-noChange"),O=Symbol.for("lit-nothing"),Bc=new WeakMap,Ke=Ze.createTreeWalker(Ze,129);function Wc(o,t){if(!La(o)||!o.hasOwnProperty("raw"))throw Error("invalid template strings array");return Lc!==void 0?Lc.createHTML(t):t}var Qc=(o,t)=>{let e=o.length-1,i=[],n,r=t===2?"<svg>":t===3?"<math>":"",s=Tr;for(let a=0;a<e;a++){let l=o[a],c,d,h=-1,f=0;for(;f<l.length&&(s.lastIndex=f,d=s.exec(l),d!==null);)f=s.lastIndex,s===Tr?d[1]==="!--"?s=Vc:d[1]!==void 0?s=zc:d[2]!==void 0?(Hc.test(d[2])&&(n=RegExp("</"+d[2],"g")),s=Je):d[3]!==void 0&&(s=Je):s===Je?d[0]===">"?(s=n??Tr,h=-1):d[1]===void 0?h=-2:(h=s.lastIndex-d[2].length,c=d[1],s=d[3]===void 0?Je:d[3]==='"'?Fc:jc):s===Fc||s===jc?s=Je:s===Vc||s===zc?s=Tr:(s=Je,n=void 0);let m=s===Je&&o[a+1].startsWith("/>")?" ":"";r+=s===Tr?l+uu:h>=0?(i.push(c),l.slice(0,h)+Na+l.slice(h)+ne+m):l+ne+(h===-2?a:m)}return[Wc(o,r+(o[e]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),i]},Or=class o{constructor({strings:t,_$litType$:e},i){let n;this.parts=[];let r=0,s=0,a=t.length-1,l=this.parts,[c,d]=Qc(t,e);if(this.el=o.createElement(c,i),Ke.currentNode=this.el.content,e===2||e===3){let h=this.el.content.firstChild;h.replaceWith(...h.childNodes)}for(;(n=Ke.nextNode())!==null&&l.length<a;){if(n.nodeType===1){if(n.hasAttributes())for(let h of n.getAttributeNames())if(h.endsWith(Na)){let f=d[s++],m=n.getAttribute(h).split(ne),v=/([.?@])?(.*)/.exec(f);l.push({type:1,index:r,name:v[2],strings:m,ctor:v[1]==="."?jn:v[1]==="?"?Fn:v[1]==="@"?Bn:ei}),n.removeAttribute(h)}else h.startsWith(ne)&&(l.push({type:6,index:r}),n.removeAttribute(h));if(Hc.test(n.tagName)){let h=n.textContent.split(ne),f=h.length-1;if(f>0){n.textContent=Vn?Vn.emptyScript:"";for(let m=0;m<f;m++)n.append(h[m],Rr()),Ke.nextNode(),l.push({type:2,index:++r});n.append(h[f],Rr())}}}else if(n.nodeType===8)if(n.data===$a)l.push({type:2,index:r});else{let h=-1;for(;(h=n.data.indexOf(ne,h+1))!==-1;)l.push({type:7,index:r}),h+=ne.length-1}r++}}static createElement(t,e){let i=Ze.createElement("template");return i.innerHTML=t,i}};function ti(o,t,e=o,i){if(t===rt)return t;let n=i!==void 0?e._$Co?.[i]:e._$Cl,r=Pr(t)?void 0:t._$litDirective$;return n?.constructor!==r&&(n?._$AO?.(!1),r===void 0?n=void 0:(n=new r(o),n._$AT(o,e,i)),i!==void 0?(e._$Co??=[])[i]=n:e._$Cl=n),n!==void 0&&(t=ti(o,n._$AS(o,t.values),n,i)),t}var zn=class{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){let{el:{content:e},parts:i}=this._$AD,n=(t?.creationScope??Ze).importNode(e,!0);Ke.currentNode=n;let r=Ke.nextNode(),s=0,a=0,l=i[0];for(;l!==void 0;){if(s===l.index){let c;l.type===2?c=new Ii(r,r.nextSibling,this,t):l.type===1?c=new l.ctor(r,l.name,l.strings,this,t):l.type===6&&(c=new Un(r,this,t)),this._$AV.push(c),l=i[++a]}s!==l?.index&&(r=Ke.nextNode(),s++)}return Ke.currentNode=Ze,n}p(t){let e=0;for(let i of this._$AV)i!==void 0&&(i.strings!==void 0?(i._$AI(t,i,e),e+=i.strings.length-2):i._$AI(t[e])),e++}},Ii=class o{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,e,i,n){this.type=2,this._$AH=O,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=i,this.options=n,this._$Cv=n?.isConnected??!0}get parentNode(){let t=this._$AA.parentNode,e=this._$AM;return e!==void 0&&t?.nodeType===11&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=ti(this,t,e),Pr(t)?t===O||t==null||t===""?(this._$AH!==O&&this._$AR(),this._$AH=O):t!==this._$AH&&t!==rt&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):Uc(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==O&&Pr(this._$AH)?this._$AA.nextSibling.data=t:this.T(Ze.createTextNode(t)),this._$AH=t}$(t){let{values:e,_$litType$:i}=t,n=typeof i=="number"?this._$AC(t):(i.el===void 0&&(i.el=Or.createElement(Wc(i.h,i.h[0]),this.options)),i);if(this._$AH?._$AD===n)this._$AH.p(e);else{let r=new zn(n,this),s=r.u(this.options);r.p(e),this.T(s),this._$AH=r}}_$AC(t){let e=Bc.get(t.strings);return e===void 0&&Bc.set(t.strings,e=new Or(t)),e}k(t){La(this._$AH)||(this._$AH=[],this._$AR());let e=this._$AH,i,n=0;for(let r of t)n===e.length?e.push(i=new o(this.O(Rr()),this.O(Rr()),this,this.options)):i=e[n],i._$AI(r),n++;n<e.length&&(this._$AR(i&&i._$AB.nextSibling,n),e.length=n)}_$AR(t=this._$AA.nextSibling,e){for(this._$AP?.(!1,!0,e);t!==this._$AB;){let i=$c(t).nextSibling;$c(t).remove(),t=i}}setConnected(t){this._$AM===void 0&&(this._$Cv=t,this._$AP?.(t))}},ei=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,i,n,r){this.type=1,this._$AH=O,this._$AN=void 0,this.element=t,this.name=e,this._$AM=n,this.options=r,i.length>2||i[0]!==""||i[1]!==""?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=O}_$AI(t,e=this,i,n){let r=this.strings,s=!1;if(r===void 0)t=ti(this,t,e,0),s=!Pr(t)||t!==this._$AH&&t!==rt,s&&(this._$AH=t);else{let a=t,l,c;for(t=r[0],l=0;l<r.length-1;l++)c=ti(this,a[i+l],e,l),c===rt&&(c=this._$AH[l]),s||=!Pr(c)||c!==this._$AH[l],c===O?t=O:t!==O&&(t+=(c??"")+r[l+1]),this._$AH[l]=c}s&&!n&&this.j(t)}j(t){t===O?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}},jn=class extends ei{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===O?void 0:t}},Fn=class extends ei{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==O)}},Bn=class extends ei{constructor(t,e,i,n,r){super(t,e,i,n,r),this.type=5}_$AI(t,e=this){if((t=ti(this,t,e,0)??O)===rt)return;let i=this._$AH,n=t===O&&i!==O||t.capture!==i.capture||t.once!==i.once||t.passive!==i.passive,r=t!==O&&(i===O||n);n&&this.element.removeEventListener(this.name,this,i),r&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){typeof this._$AH=="function"?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t)}},Un=class{constructor(t,e,i){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(t){ti(this,t)}},it={M:Na,P:ne,A:$a,C:1,L:Qc,R:zn,D:Uc,V:ti,I:Ii,H:ei,N:Fn,U:Bn,B:jn,F:Un},mu=Hn.litHtmlPolyfillSupport;mu?.(Or,Ii),(Hn.litHtmlVersions??=[]).push("3.3.3");var za=(o,t,e)=>{let i=e?.renderBefore??t,n=i._$litPart$;if(n===void 0){let r=e?.renderBefore??null;i._$litPart$=n=new Ii(t.insertBefore(Rr(),r),r,void 0,e??{})}return n._$AI(o),n};var ja=globalThis,C=class extends re{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){let t=super.createRenderRoot();return this.renderOptions.renderBefore??=t.firstChild,t}update(t){let e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=za(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return rt}};C._$litElement$=!0,C.finalized=!0,ja.litElementHydrateSupport?.({LitElement:C});var fu=ja.litElementPolyfillSupport;fu?.({LitElement:C});(ja.litElementVersions??=[]).push("4.2.2");var gu={attribute:!0,type:String,converter:Ir,reflect:!1,hasChanged:Ln},bu=(o=gu,t,e)=>{let{kind:i,metadata:n}=e,r=globalThis.litPropertyMetadata.get(n);if(r===void 0&&globalThis.litPropertyMetadata.set(n,r=new Map),i==="setter"&&((o=Object.create(o)).wrapped=!0),r.set(e.name,o),i==="accessor"){let{name:s}=e;return{set(a){let l=t.get.call(this);t.set.call(this,a),this.requestUpdate(s,l,o,!0,a)},init(a){return a!==void 0&&this.C(s,void 0,o,a),a}}}if(i==="setter"){let{name:s}=e;return function(a){let l=this[s];t.call(this,a),this.requestUpdate(s,l,o,!0,a)}}throw Error("Unsupported decorator location: "+i)};function p(o){return(t,e)=>typeof e=="object"?bu(o,t,e):((i,n,r)=>{let s=n.hasOwnProperty(r);return n.constructor.createProperty(r,i),s?Object.getOwnPropertyDescriptor(n,r):void 0})(o,t,e)}function T(o){return p({...o,state:!0,attribute:!1})}var ye=(o,t,e)=>(e.configurable=!0,e.enumerable=!0,Reflect.decorate&&typeof t!="object"&&Object.defineProperty(o,t,e),e);function _i(o,t){return(e,i,n)=>{let r=s=>s.renderRoot?.querySelector(o)??null;if(t){let{get:s,set:a}=typeof i=="object"?e:n??(()=>{let l=Symbol();return{get(){return this[l]},set(c){this[l]=c}}})();return ye(e,i,{get(){let l=s.call(this);return l===void 0&&(l=r(this),(l!==null||this.hasUpdated)&&a.call(this,l)),l}})}return ye(e,i,{get(){return r(this)}})}}function Gc(o){return(t,e)=>{let{slot:i,selector:n}=o??{},r="slot"+(i?`[name=${i}]`:":not([name])");return ye(t,e,{get(){let s=this.renderRoot?.querySelector(r),a=s?.assignedElements(o)??[];return n===void 0?a:a.filter(l=>l.matches(n))}})}}var oe=class extends Event{constructor(t,e,i,n){super("context-request",{bubbles:!0,composed:!0}),this.context=t,this.contextTarget=e,this.callback=i,this.subscribe=n??!1}};var wt=class{constructor(t,e,i,n){if(this.subscribe=!1,this.provided=!1,this.value=void 0,this.t=(r,s)=>{this.unsubscribe&&(this.unsubscribe!==s&&(this.provided=!1,this.unsubscribe()),this.subscribe||this.unsubscribe()),this.value=r,this.host.requestUpdate(),this.provided&&!this.subscribe||(this.provided=!0,this.callback&&this.callback(r,s)),this.unsubscribe=s},this.host=t,e.context!==void 0){let r=e;this.context=r.context,this.callback=r.callback,this.subscribe=r.subscribe??!1}else this.context=e,this.callback=i,this.subscribe=n??!1;this.host.addController(this)}hostConnected(){this.dispatchRequest()}hostDisconnected(){this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=void 0)}dispatchRequest(){this.host.dispatchEvent(new oe(this.context,this.host,this.t,this.subscribe))}};var Wn=class{get value(){return this.o}set value(t){this.setValue(t)}setValue(t,e=!1){let i=e||!Object.is(t,this.o);this.o=t,i&&this.updateObservers()}constructor(t){this.subscriptions=new Map,this.updateObservers=()=>{for(let[e,{disposer:i}]of this.subscriptions)e(this.o,i)},t!==void 0&&(this.value=t)}addCallback(t,e,i){if(!i)return void t(this.value);this.subscriptions.has(t)||this.subscriptions.set(t,{disposer:()=>{this.subscriptions.delete(t)},consumerHost:e});let{disposer:n}=this.subscriptions.get(t);t(this.value,n)}clearCallbacks(){this.subscriptions.clear()}};var Fa=class extends Event{constructor(t,e){super("context-provider",{bubbles:!0,composed:!0}),this.context=t,this.contextTarget=e}},ve=class extends Wn{constructor(t,e,i){super(e.context!==void 0?e.initialValue:i),this.onContextRequest=n=>{if(n.context!==this.context)return;let r=n.contextTarget??n.composedPath()[0];r!==this.host&&(n.stopPropagation(),this.addCallback(n.callback,r,n.subscribe))},this.onProviderRequest=n=>{if(n.context!==this.context||(n.contextTarget??n.composedPath()[0])===this.host)return;let r=new Set;for(let[s,{consumerHost:a}]of this.subscriptions)r.has(s)||(r.add(s),a.dispatchEvent(new oe(this.context,a,s,!0)));n.stopPropagation()},this.host=t,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 Fa(this.context,this.host))}};var Dr=class{constructor(){this.pendingContextRequests=new Map,this.onContextProvider=t=>{let e=this.pendingContextRequests.get(t.context);if(e===void 0)return;this.pendingContextRequests.delete(t.context);let{requests:i}=e;for(let{elementRef:n,callbackRef:r}of i){let s=n.deref(),a=r.deref();s===void 0||a===void 0||s.dispatchEvent(new oe(t.context,s,a,!0))}},this.onContextRequest=t=>{if(t.subscribe!==!0)return;let e=t.contextTarget??t.composedPath()[0],i=t.callback,n=this.pendingContextRequests.get(t.context);n===void 0&&this.pendingContextRequests.set(t.context,n={callbacks:new WeakMap,requests:[]});let r=n.callbacks.get(e);r===void 0&&n.callbacks.set(e,r=new WeakSet),r.has(i)||(r.add(i),n.requests.push({elementRef:new WeakRef(e),callbackRef:new WeakRef(i)}))}}attach(t){t.addEventListener("context-request",this.onContextRequest),t.addEventListener("context-provider",this.onContextProvider)}detach(t){t.removeEventListener("context-request",this.onContextRequest),t.removeEventListener("context-provider",this.onContextProvider)}};function U({context:o}){return(t,e)=>{let i=new WeakMap;if(typeof e=="object")return{get(){return t.get.call(this)},set(n){return i.get(this).setValue(n),t.set.call(this,n)},init(n){return i.set(this,new ve(this,{context:o,initialValue:n})),n}};{t.constructor.addInitializer((s=>{i.set(s,new ve(s,{context:o}))}));let n=Object.getOwnPropertyDescriptor(t,e),r;if(n===void 0){let s=new WeakMap;r={get(){return s.get(this)},set(a){i.get(this).setValue(a),s.set(this,a)},configurable:!0,enumerable:!0}}else{let s=n.set;r={...n,set(a){i.get(this).setValue(a),s?.call(this,a)}}}return void Object.defineProperty(t,e,r)}}}function _({context:o,subscribe:t}){return(e,i)=>{typeof i=="object"?i.addInitializer((function(){new wt(this,{context:o,callback:n=>{e.set.call(this,n)},subscribe:t})})):e.constructor.addInitializer((n=>{new wt(n,{context:o,callback:r=>{n[i]=r},subscribe:t})}))}}var Qn=["this"],Xc=["+","-","!"],Yc=["=","+","-","*","/","%","^","==","!=",">","<",">=","<=","||","&&","??","&","===","!==","|","|>"],Ba={"!":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},Gn=13;var yu=["==","!=","<=",">=","||","&&","??","|>"],vu=["===","!=="],M;(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"})(M||(M={}));var Ht=(o,t,e=0)=>({kind:o,value:t,precedence:e}),wu=o=>o===9||o===10||o===13||o===32,Jc=o=>o===95||o===36||(o&=-33,65<=o&&o<=90),xu=o=>Jc(o)||Nr(o),qu=o=>Qn.indexOf(o)!==-1,Cu=o=>o===34||o===39,Nr=o=>48<=o&&o<=57,Su=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,ku=o=>o===40||o===41||o===91||o===93||o===123||o===125,Eu=o=>o.replace(/\\(.)/g,(t,e)=>{switch(e){case"n":return`
5
+ `;case"r":return"\r";case"t":return" ";case"b":return"\b";case"f":return"\f";default:return e}}),Xn=class{#t;#e=-1;#i=0;#r;constructor(t){this.#t=t,this.#n()}nextToken(){for(;wu(this.#r);)this.#n(!0);if(Cu(this.#r))return this.#a();if(Jc(this.#r))return this.#c();if(Nr(this.#r))return this.#p();if(this.#r===46)return this.#l();if(this.#r===44)return this.#m();if(this.#r===58)return this.#d();if(Su(this.#r))return this.#h();if(ku(this.#r))return this.#b();if(this.#n(),this.#r!==void 0)throw new Error(`Expected end of input, got ${this.#r}`)}#n(t){this.#e++,this.#e<this.#t.length?(this.#r=this.#t.charCodeAt(this.#e),t===!0&&(this.#i=this.#e)):this.#r=void 0}#o(t=0){let e=this.#t.substring(this.#i,this.#e+t);return t===0&&this.#s(),e}#s(){this.#i=this.#e}#a(){let t="unterminated string",e=this.#r;for(this.#n(!0);this.#r!==e;){if(this.#r===void 0)throw new Error(t);if(this.#r===92&&(this.#n(),this.#r===void 0))throw new Error(t);this.#n()}let i=Ht(M.STRING,Eu(this.#o()));return this.#n(),i}#c(){do this.#n();while(xu(this.#r));let t=this.#o(),e=qu(t)?M.KEYWORD:M.IDENTIFIER;return Ht(e,t)}#p(){do this.#n();while(Nr(this.#r));return this.#r===46?this.#l():Ht(M.INTEGER,this.#o())}#l(){return this.#n(),Nr(this.#r)?this.#u():(this.#s(),Ht(M.DOT,".",Gn))}#m(){return this.#n(!0),Ht(M.COMMA,",")}#d(){return this.#n(!0),Ht(M.COLON,":")}#u(){do this.#n();while(Nr(this.#r));return Ht(M.DECIMAL,this.#o())}#h(){this.#n();let t=this.#o(2);if(vu.indexOf(t)!==-1)this.#n(),this.#n();else{if(t=this.#o(1),t==="=>")return this.#n(),Ht(M.ARROW,t);yu.indexOf(t)!==-1&&this.#n()}return t=this.#o(),Ht(M.OPERATOR,t,Ba[t])}#b(){let t=String.fromCharCode(this.#r),e=Ht(M.GROUPER,t,Ba[t]);return this.#n(!0),e}};var Ua=(o,t)=>new $r(o,t).parse(),$r=class{#t;#e;#i;#r;#n;constructor(t,e){this.#e=new Xn(t),this.#i=e}parse(){return this.#o(),this.#s()}#o(t,e){if(!this._matches(t,e))throw new Error(`Expected kind ${t} (${e}), was ${this.#r?.kind} (${this.#r?.value})`);let i=this.#e.nextToken();this.#r=i,this.#t=i?.kind,this.#n=i?.value}_matches(t,e){return!(t&&this.#t!==t||e&&this.#n!==e)}#s(){if(!this.#r)return this.#i.empty();let t=this.#l();return t===void 0?void 0:this.#a(t,0)}#a(t,e){if(t===void 0)throw new Error("Expected left to be defined.");for(;this.#r;)if(this._matches(M.GROUPER,"(")){let i=this.#y();t=this.#i.invoke(t,void 0,i)}else if(this._matches(M.GROUPER,"[")){let i=this.#g();t=this.#i.index(t,i)}else if(this._matches(M.DOT)){this.#o();let i=this.#l();t=this.#c(t,i)}else{if(this._matches(M.KEYWORD))break;if(this._matches(M.OPERATOR)&&this.#r.precedence>=e)t=this.#n==="?"?this.#m(t):this.#p(t,this.#r);else break}return t}#c(t,e){if(e===void 0)throw new Error("expected identifier");if(e.type==="ID")return this.#i.getter(t,e.value);if(e.type==="Invoke"&&e.receiver.type==="ID"){let i=e.receiver;return this.#i.invoke(t,i.value,e.arguments)}else throw new Error(`expected identifier: ${e}`)}#p(t,e){if(Yc.indexOf(e.value)===-1)throw new Error(`unknown operator: ${e.value}`);this.#o();let i=this.#l();for(;(this.#t===M.OPERATOR||this.#t===M.DOT||this.#t===M.GROUPER)&&this.#r.precedence>e.precedence;)i=this.#a(i,this.#r.precedence);return this.#i.binary(t,e.value,i)}#l(){if(this._matches(M.OPERATOR)){let t=this.#n;if(this.#o(),t==="+"||t==="-"){if(this._matches(M.INTEGER))return this.#C(t);if(this._matches(M.DECIMAL))return this.#E(t)}if(Xc.indexOf(t)===-1)throw new Error(`unexpected token: ${t}`);let e=this.#a(this.#d(),Gn);return this.#i.unary(t,e)}return this.#d()}#m(t){this.#o(M.OPERATOR,"?");let e=this.#s();this.#o(M.COLON);let i=this.#s();return this.#i.ternary(t,e,i)}#d(){switch(this.#t){case M.KEYWORD:let t=this.#n;if(t==="this")return this.#o(),this.#i.id(t);throw Qn.indexOf(t)!==-1?new Error(`unexpected keyword: ${t}`):new Error(`unrecognized keyword: ${t}`);case M.IDENTIFIER:return this.#b();case M.STRING:return this.#x();case M.INTEGER:return this.#C();case M.DECIMAL:return this.#E();case M.GROUPER:return this.#n==="("?this.#v():this.#n==="{"?this.#h():this.#n==="["?this.#u():void 0;case M.COLON:throw new Error('unexpected token ":"');default:return}}#u(){let t=[];do{if(this.#o(),this._matches(M.GROUPER,"]"))break;t.push(this.#s())}while(this._matches(M.COMMA));return this.#o(M.GROUPER,"]"),this.#i.list(t)}#h(){let t={};do{if(this.#o(),this._matches(M.GROUPER,"}"))break;let e=this.#n;(this._matches(M.STRING)||this._matches(M.IDENTIFIER))&&this.#o(),this.#o(M.COLON),t[e]=this.#s()}while(this._matches(M.COMMA));return this.#o(M.GROUPER,"}"),this.#i.map(t)}#b(){let t=this.#n;if(t==="true")return this.#o(),this.#i.literal(!0);if(t==="false")return this.#o(),this.#i.literal(!1);if(t==="null")return this.#o(),this.#i.literal(null);if(t==="undefined")return this.#o(),this.#i.literal(void 0);let e=this.#f(),i=this.#y();return i?this.#i.invoke(e,void 0,i):e}#f(){if(!this._matches(M.IDENTIFIER))throw new Error(`expected identifier: ${this.#n}`);let t=this.#n;return this.#o(),this.#i.id(t)}#y(){if(!this._matches(M.GROUPER,"("))return;let t=[];do{if(this.#o(),this._matches(M.GROUPER,")"))break;let e=this.#s();t.push(e)}while(this._matches(M.COMMA));return this.#o(M.GROUPER,")"),t}#g(){this.#o();let t=this.#s();return this.#o(M.GROUPER,"]"),t}#v(){let t=this.#y();if(this._matches(M.ARROW)){this.#o();let e=this.#s(),i=t?.map(n=>n.value)??[];return this.#i.arrowFunction(i,e)}else return this.#i.paren(t[0])}#x(){let t=this.#i.literal(this.#n);return this.#o(),t}#C(t=""){let e=this.#i.literal(parseInt(`${t}${this.#n}`,10));return this.#o(),e}#E(t=""){let e=this.#i.literal(parseFloat(`${t}${this.#n}`));return this.#o(),e}};var{hasOwn:Kc,fromEntries:Au}=Object,Iu={"+":(o,t)=>o+t,"-":(o,t)=>o-t,"*":(o,t)=>o*t,"/":(o,t)=>o/t,"%":(o,t)=>o%t,"==":(o,t)=>o==t,"!=":(o,t)=>o!=t,"===":(o,t)=>o===t,"!==":(o,t)=>o!==t,">":(o,t)=>o>t,">=":(o,t)=>o>=t,"<":(o,t)=>o<t,"<=":(o,t)=>o<=t,"||":(o,t)=>o||t,"&&":(o,t)=>o&&t,"??":(o,t)=>o??t,"|":(o,t)=>t(o),"|>":(o,t)=>t(o)},_u={"+":o=>o,"-":o=>-o,"!":o=>!o},Yn=class{empty(){return{type:"Empty",evaluate(t){return t},getIds(t){return t}}}literal(t){return{type:"Literal",value:t,evaluate(e){return this.value},getIds(e){return e}}}id(t){return{type:"ID",value:t,evaluate(e){return this.value==="this"?e:e?.[this.value]},getIds(e){return e.push(this.value),e}}}unary(t,e){let i=_u[t];return{type:"Unary",operator:t,child:e,evaluate(n){return i(this.child.evaluate(n))},getIds(n){return this.child.getIds(n)}}}binary(t,e,i){let n=Iu[e];return{type:"Binary",operator:e,left:t,right:i,evaluate(r){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 s=this.right.evaluate(r),a,l;return this.left.type==="Getter"?(a=this.left.receiver.evaluate(r),l=this.left.name):this.left.type==="Index"?(a=this.left.receiver.evaluate(r),l=this.left.argument.evaluate(r)):this.left.type==="ID"&&(a=r,l=this.left.value),a===void 0?void 0:a[l]=s}return n(this.left.evaluate(r),this.right.evaluate(r))},getIds(r){return this.left.getIds(r),this.right.getIds(r),r}}}getter(t,e){return{type:"Getter",receiver:t,name:e,evaluate(i){return this.receiver.evaluate(i)?.[this.name]},getIds(i){return this.receiver.getIds(i),i}}}invoke(t,e,i){if(e!=null&&typeof e!="string")throw new Error("method not a string");return{type:"Invoke",receiver:t,method:e,arguments:i,evaluate(n){let r=this.receiver.evaluate(n),s=this.method?r:n?.this??n,a=this.method?r?.[e]:r,c=(this.arguments??[]).map(d=>d?.evaluate(n));return a?.apply?.(s,c)},getIds(n){return this.receiver.getIds(n),this.arguments?.forEach(r=>r?.getIds(n)),n}}}paren(t){return t}index(t,e){return{type:"Index",receiver:t,argument:e,evaluate(i){return this.receiver.evaluate(i)?.[this.argument.evaluate(i)]},getIds(i){return this.receiver.getIds(i),i}}}ternary(t,e,i){return{type:"Ternary",condition:t,trueExpr:e,falseExpr:i,evaluate(n){return this.condition.evaluate(n)?this.trueExpr.evaluate(n):this.falseExpr.evaluate(n)},getIds(n){return this.condition.getIds(n),this.trueExpr.getIds(n),this.falseExpr.getIds(n),n}}}map(t){return{type:"Map",entries:t,evaluate(e){let i={};if(t&&this.entries)for(let n in t){let r=this.entries[n];r&&(i[n]=r.evaluate(e))}return i},getIds(e){if(t&&this.entries)for(let i in t){let n=this.entries[i];n&&n.getIds(e)}return e}}}list(t){return{type:"List",items:t,evaluate(e){return this.items?.map(i=>i?.evaluate(e))},getIds(e){return this.items?.forEach(i=>i?.getIds(e)),e}}}arrowFunction(t,e){return{type:"ArrowFunction",params:t,body:e,evaluate(i){let n=this.params,r=this.body;return function(...s){let a=Au(n.map((c,d)=>[c,s[d]])),l=new Proxy(i??{},{set(c,d,h){return Kc(a,d)&&(a[d]=h),c[d]=h},get(c,d){return Kc(a,d)?a[d]:c[d]}});return r.evaluate(l)}},getIds(i){return this.body.getIds(i).filter(n=>!this.params.includes(n))}}}};var Ha=null,Zc={boundAttributeSuffix:it.M,marker:it.P,markerMatch:it.A,HTML_RESULT:it.C,getTemplateHtml:it.L,overrideDirectiveResolve:(o,t)=>class extends o{_$AS(e,i){return t(this,i)}},patchDirectiveResolve:(o,t)=>{if(o.prototype._$AS.name!==t.name){Ha??=o.prototype._$AS.name;for(let e=o.prototype;e!==Object.prototype;e=Object.getPrototypeOf(e))if(e.hasOwnProperty(Ha))return void(e[Ha]=t);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,t){o._$litDirective$=t},getAttributePartCommittedValue:(o,t,e)=>{let i=rt;return o.j=n=>i=n,o._$AI(t,o,e),i},connectedDisconnectable:o=>({...o,_$AU:!0}),resolveDirective:it.V,AttributePart:it.H,PropertyPart:it.B,BooleanAttributePart:it.N,EventPart:it.U,ElementPart:it.F,TemplateInstance:it.R,isIterable:it.D,ChildPart:it.I};var{AttributePart:Tu,PropertyPart:Ru,BooleanAttributePart:Pu,EventPart:Ou}=Zc,Qa=new Yn,Wa=new Map,td=o=>o.replace(/-(-|\w)/g,(t,e)=>e.toUpperCase()),Jn=(o,t)=>{let e=Wa.get(o);if(e===void 0){if(Wa.has(o))return;if(o=o.trim(),o.startsWith("{{")&&o.endsWith("}}")){let i=o.substring(2,o.length-2).trim();e=new $r(i,Qa).parse(),Wa.set(o,e)}}return e?.evaluate(t)},Mu=(o,t,e,i)=>{let n=o.getAttribute("if");if(n!==null&&Jn(n,t))return Kn(o,t,e,i)},ed=/(?<!\\){{(.*?)(?:(?<!\\)}})/g,id=o=>/(?:\\{{)|(?:\\}})/g.test(o),Lr=o=>o.replaceAll(/\\{{/g,"{{").replace(/\\}}/g,"}}"),Du=(o,t,e,i)=>{let n=o.getAttribute("repeat");if(n!==null){let r=Jn(n,t);if(!r[Symbol.iterator])return O;let s=Vr(o),a=-1,l=[];for(let c of r){a++;let d=Object.create(t);d.item=c,d.index=a,d.this=t.this??t;let h=[];for(let m of s.parts){let v=m.update(d,e,i);m.type===1?h.push(...v):h.push(v)}let f={_$litType$:s,values:h};l.push(f)}return l}},nd={if:Mu,repeat:Du},we=(o,t=nd,e={},i)=>{let r=Vr(o).renderers;if(i){let a=Vr(i).renderers,l=r.super;l!==void 0?e={...r,...e,super:(c,d,h)=>(h={...a,...h,super:(f,m,v)=>Kn(i,f,m,v)},l(c,d,h))}:(e={...a,...r,...e},o=i)}else e={...r,...e};return s=>Kn(o,s,t,e)};var Kn=(o,t,e=nd,i={})=>{let n=Vr(o),r=[];for(let a of n.parts){let l=a.update(t,e,i);a.type===1?r.push(...l):r.push(l)}return{_$litType$:n,values:r}},rd=new Map,Vr=o=>{let t=rd.get(o);return t===void 0&&rd.set(o,t=Nu(o)),t},Nu=o=>{let t={h:void 0,el:o.cloneNode(!0),parts:[],renderers:{}},e=document.createTreeWalker(t.el.content,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT|NodeFilter.SHOW_COMMENT),i=e.currentNode,n=-1,r=[];for(;(i=e.nextNode())!==null;)if(i.nodeType===Node.COMMENT_NODE)n++;else if(i.nodeType===Node.ELEMENT_NODE){n++;let s=i;if(s.tagName==="TEMPLATE"){let l=s.getAttribute("type"),c=s.getAttribute("name"),d=s.getAttribute("call");if(d!==null||l!==null||c!==null){s.parentNode.insertBefore(document.createComment(""),s),r.push(s);let h;if(d!==null){let f=d.trim(),m=f.startsWith("{{")&&f.endsWith("}}");h=(v,x,u)=>{let g=s.getAttribute("data"),y=g===null?void 0:Jn(g,v);return(m?Jn(f,v):u[d])?.(y,x,u)}}else l!==null?h=(f,m,v)=>{let x=m[l];return x?.(s,f,m,v)}:(c==="super"?t.renderers.super=(f,m,v)=>{let x=v.super,u=Vr(s);return v={...v,...u.renderers},x(f,m,v)}:t.renderers[c]=(f,m,v)=>Kn(s,f,m,v),h=(f,m,v)=>{let x=v[c];return x?.(f,m,v)});t.parts.push({type:2,index:n,update:h});continue}}let a=s.getAttributeNames();for(let l of a){let c=s.getAttribute(l),d=c.split(ed);if(d.length===1){id(c)&&s.setAttribute(l,Lr(c));continue}s.removeAttribute(l);let h=l,f=Tu,m=l[0];m==="."?(h=td(l.substring(1)),f=Ru):m==="?"?(h=l.substring(1),f=Pu):m==="@"&&(h=td(l.substring(1)),f=Ou);let v=[Lr(d[0])],x=[];for(let u=1;u<d.length;u+=2){let g=d[u];x.push(Ua(g,Qa)),v.push(Lr(d[u+1]))}t.parts.push({type:1,index:n,name:h,strings:v,ctor:f,update:(u,g,y)=>x.map(w=>w.evaluate(u))})}}else if(i.nodeType===Node.TEXT_NODE){let s=i,a=s.textContent,l=a.split(ed);l.length>1?s.textContent=Lr(l[0]):id(a)&&(s.textContent=Lr(a));for(let c=1;c<l.length;c+=2){let d=l[c],h=Ua(d,Qa);t.parts.push({type:2,index:++n,update:(m,v)=>h.evaluate(m)});let f=new Text(l[c+1].replace("\\{{","{{"));s.parentNode.insertBefore(f,s.nextSibling),s.parentNode.insertBefore(document.createComment(""),s.nextSibling),s=f,e.currentNode=f}}for(let s of r)s.remove();return t};var Ga=Symbol.for("qti-components.context-root"),$u=()=>{if(typeof document>"u")return;let o=globalThis;o[Ga]||(o[Ga]=new Dr,o[Ga].attach(document.documentElement))};$u();var od=[];var Ya=class extends Set{#t;constructor(t){super(),this.#t=t}add(t){return super.add(t),this.#e(),this}delete(t){let e=super.delete(t);return this.#e(),e}clear(){super.clear(),this.#e()}#e(){this.#t.isConnected?this.#i():queueMicrotask(()=>this.#i())}#i(){this.size===0?this.#t.removeAttribute("data-state"):this.#t.setAttribute("data-state",Array.from(this).join(" "))}},Xa="custom-state-support-probe";function Lu(o){if(!("states"in ElementInternals.prototype))return"missing";if(typeof customElements>"u")return"modern";try{customElements.get(Xa)||customElements.define(Xa,class extends HTMLElement{});let t=o.call(document.createElement(Xa)).states;return t?(t.add("probe"),t.delete("probe"),"modern"):"missing"}catch{return"legacy"}}var sd=!1;function ad(){if(sd)return"already-installed";if(typeof HTMLElement>"u"||typeof ElementInternals>"u")return"modern";let o=HTMLElement.prototype.attachInternals;if(!o)return"modern";let t=Lu(o);return t==="modern"||(sd=!0,HTMLElement.prototype.attachInternals=function(){let i=o.call(this);return Object.defineProperty(i,"states",{configurable:!0,enumerable:!0,value:new Ya(this)}),i}),t}ad();for(let{tag:o,ctor:t}of od)customElements.get(o)||customElements.define(o,t);var xe=Symbol("computedItemContext");var j=Symbol("computedContext");var xt=Symbol("configContext");var Ti=Symbol("interactionContext");var F=Symbol("item");var ld=[{identifier:"completionStatus",cardinality:"single",baseType:"string",value:"unknown",type:"outcome"},{identifier:"numAttempts",cardinality:"single",baseType:"integer",value:"0",type:"response"}];var Vu=/^[A-Za-z0-9-]+$/,zu=o=>typeof o=="string"&&Vu.test(o),fy=o=>zu(o)?o:void 0,qt=Symbol("qtiContext");var Ja={view:"candidate"},qe=Symbol("sessionContext");var Ka={items:[],testOutcomeVariables:[]},nt=Symbol("testContext");var P=q`
6
6
  :host {
7
7
  box-sizing: border-box;
8
8
  }
@@ -56,15 +56,15 @@ Make sure to test your application with a production build as repeat registratio
56
56
  [part~='message'] {
57
57
  display: none;
58
58
  }
59
- `;var Ti=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},D=class extends C{#t;get _context(){return this.#t.value}#e;#i;#r(t){t?.readonly!==void 0&&t.readonly!==this.#e&&(this.#e=t.readonly,this.readonly=t.readonly),t?.disabled!==void 0&&t.disabled!==this.#i&&(this.#i=t.disabled,this.disabled=t.disabled),this.#a(t)}#n;#o;#s;#a(t){let e=this.responseIdentifier??this.getAttribute("response-identifier"),i=t?.variables?.find(s=>s.type==="response"&&s.identifier===e);if(!i)return;if(!this.hasUpdated){this.#s||(this.#s=!0,this.updateComplete.then(()=>{this.#s=!1,this.#a(this._context)}));return}let n=this.#n===void 0,r=JSON.stringify(i.value??null);r!==this.#n&&(this.#n=r,!(n&&(i.value===null||i.value===void 0))&&r!==this.#o&&(this.#o=r,this.response=i.value))}#c;static{this.formAssociated=!0}get internals(){return this._internals}get registersWithItem(){return!0}get isInline(){return!1}get responseVariable(){if(!this._context?.variables)return;let t=this._context.variables.filter(i=>i.type==="response"),e=this.getAttribute("response-identifier");return t.find(i=>i.identifier===e)}get value(){return JSON.stringify(this.response)}set value(t){this.response=t?JSON.parse(t):null}reportValidity(){let t=this._internals.validity.valid,e=this.validationDisplayMode;return(e==="native"||e==="both")&&this._internals.reportValidity(),e==="inline"||e==="both"?this.updateInlineValidationMessage():this.clearInlineValidationMessage(),e==="none"&&this.clearInlineValidationMessage(),t}get validationDisplayMode(){return this.configContext?.validationDisplayMode??"inline"}resolveAllowReorder(t){let e=t?.defaultWhenUnset??!0,i=this.configContext;return i&&i.allowReorder!==void 0?i.allowReorder:e}resolveDisableAfterMaxReached(t){let e=t?.defaultWhenUnset??!1,i=this.configContext;return i?i.disableAfterMaxReached!==void 0?i.disableAfterMaxReached:i.disableAfterIfMaxChoicesReached!==void 0?(this.#c||(this.#c=!0,console.warn("[QTI Config] `disableAfterIfMaxChoicesReached` is deprecated. Use `disableAfterMaxReached` instead.")),i.disableAfterIfMaxChoicesReached):e:e}setInteractionValidity(t,e="",i,n){let r=i??this;this._internals.setValidity(t?{}:{customError:!0},e,r),n?.suppressInline!==!0&&(this.validationDisplayMode==="inline"||this.validationDisplayMode==="both")&&this.updateInlineValidationMessage()}updateInlineValidationMessage(){let t=this.getValidationMessageElement();if(t){if(!this._internals.validity.valid){t.textContent=this._internals.validationMessage,t.style.setProperty("display","block","important");return}t.textContent="",t.style.display="none"}}clearInlineValidationMessage(){let t=this.getValidationMessageElement();t&&(t.textContent="",t.style.display="none")}getValidationMessageElement(){return this.shadowRoot?.querySelector("#validation-message")}reset(){this.response=null}formResetCallback(){this.reset()}connectedCallback(){super.connectedCallback(),this.registersWithItem&&this.dispatchEvent(new CustomEvent("qti-register-interaction",{bubbles:!0,composed:!0,cancelable:!1,detail:{interactionElement:this,responseIdentifier:this.responseIdentifier}}))}saveResponse(t,e){this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,composed:!0,cancelable:!1,detail:{responseIdentifier:this.responseIdentifier,response:Array.isArray(t)?[...t]:t,...e!==void 0?{state:e}:{}}}))}constructor(){super(),this.#t=new wt(this,{context:F,subscribe:!0,callback:t=>this.#r(t)}),this.#s=!1,this.#c=!1,this._interactionContext={choiceRole:null,draggablesSelector:null},this.disabled=!1,this.readonly=!1,this._internals=this.attachInternals(),this.addEventListener("qti-interaction-response",t=>{this.#o=JSON.stringify(t.detail?.response??null)})}firstUpdated(t){}};Ti([_({context:xt,subscribe:!0})],D.prototype,"configContext",void 0);Ti([U({context:_i})],D.prototype,"_interactionContext",void 0);Ti([p({type:String,attribute:"response-identifier"})],D.prototype,"responseIdentifier",void 0);Ti([p({reflect:!0,type:Boolean})],D.prototype,"disabled",void 0);Ti([p({reflect:!0,type:Boolean})],D.prototype,"readonly",void 0);Ti([p({type:String})],D.prototype,"name",void 0);var Ri=class extends C{render(){return b`<slot></slot>`}defaultValues(t){let e=Array.from(this.querySelectorAll("qti-default-value > qti-value"));if(e.length===0)return null;let i=e.map(n=>n.innerHTML.trim());return i.length>1||t==="multiple"||t==="ordered"?i:i[0]}};var tl=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},Za=(o,t)=>o==null?{identifier:"",baseType:"string",value:null,cardinality:"single",type:"response"}:Array.isArray(o)?{identifier:"",baseType:t??cd(o[0]),value:o.map(e=>String(e)),cardinality:"multiple",type:"response"}:{identifier:"",baseType:t??cd(o),value:String(o),cardinality:"single",type:"response"},cd=o=>typeof o=="number"?Number.isInteger(o)?"integer":"float":typeof o=="boolean"?"boolean":"string",ju=(o,t)=>{if(!(!Array.isArray(t)||t.length>0))return o.lastVariables.find(e=>e?.baseType&&e.baseType!=="record"&&e.cardinality!=="record")?.baseType},E=class extends C{constructor(){super(...arguments),this.#t=[],this.getVariables=()=>{let t=Array.from(this.children).map(e=>{switch(e.tagName.toLowerCase()){case"qti-base-value":return{baseType:e.getAttribute("base-type"),value:e.textContent.trim(),cardinality:"single"};case"qti-variable":{let i=e.getAttribute("identifier")||"";return i==="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.resolveVariable(i)}case"qti-multiple":{let n=e.getResult();return n?.length>0?{identifier:"",baseType:n[0].baseType,value:n.map(r=>r.value),cardinality:"multiple",type:"response"}:null}case"qti-ordered":{let n=e.getResult();return n?.length>0?{identifier:"",baseType:n[0].baseType,value:n.map(r=>r.value),cardinality:"ordered",type:"response"}:null}case"qti-repeat":{let n=e.getResult();return n?.length>0?n:null}case"qti-custom-operator":return Za(e.calculate?.());case"qti-correct":{let i=e.getAttribute("identifier")||"",n=this.context?.variables?.find(r=>r.identifier===i);return n?{baseType:n.baseType,value:n.correctResponse,cardinality:n.cardinality}:(console.warn(`qti-correct: no response declaration for "${i}"`),Za(null))}default:{try{let i=e,n=i.getResult();return Za(n,i.resultBaseType??ju(i,n))}catch(i){console.warn(`getVariables: could not read a value from <${e.tagName.toLowerCase()}>`,i)}return null}}}).flatMap(e=>Array.isArray(e)?e:[e]).filter(e=>e!==null);return this.#t=t,t}}#t;get lastResult(){return this.result}get lastVariables(){return this.#t}static{this.styles=q`
59
+ `;var Ri=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},D=class extends C{#t;get _context(){return this.#t.value}#e;#i;#r(t){t?.readonly!==void 0&&t.readonly!==this.#e&&(this.#e=t.readonly,this.readonly=t.readonly),t?.disabled!==void 0&&t.disabled!==this.#i&&(this.#i=t.disabled,this.disabled=t.disabled),this.#a(t)}#n;#o;#s;#a(t){let e=this.responseIdentifier??this.getAttribute("response-identifier"),i=t?.variables?.find(s=>s.type==="response"&&s.identifier===e);if(!i)return;if(!this.hasUpdated){this.#s||(this.#s=!0,this.updateComplete.then(()=>{this.#s=!1,this.#a(this._context)}));return}let n=this.#n===void 0,r=JSON.stringify(i.value??null);r!==this.#n&&(this.#n=r,!(n&&(i.value===null||i.value===void 0))&&r!==this.#o&&(this.#o=r,this.response=i.value))}#c;static{this.formAssociated=!0}get internals(){return this._internals}get registersWithItem(){return!0}get isInline(){return!1}get responseVariable(){if(!this._context?.variables)return;let t=this._context.variables.filter(i=>i.type==="response"),e=this.getAttribute("response-identifier");return t.find(i=>i.identifier===e)}get value(){return JSON.stringify(this.response)}set value(t){this.response=t?JSON.parse(t):null}reportValidity(){let t=this._internals.validity.valid,e=this.validationDisplayMode;return(e==="native"||e==="both")&&this._internals.reportValidity(),e==="inline"||e==="both"?this.updateInlineValidationMessage():this.clearInlineValidationMessage(),e==="none"&&this.clearInlineValidationMessage(),t}get validationDisplayMode(){return this.configContext?.validationDisplayMode??"inline"}resolveAllowReorder(t){let e=t?.defaultWhenUnset??!0,i=this.configContext;return i&&i.allowReorder!==void 0?i.allowReorder:e}resolveDisableAfterMaxReached(t){let e=t?.defaultWhenUnset??!1,i=this.configContext;return i?i.disableAfterMaxReached!==void 0?i.disableAfterMaxReached:i.disableAfterIfMaxChoicesReached!==void 0?(this.#c||(this.#c=!0,console.warn("[QTI Config] `disableAfterIfMaxChoicesReached` is deprecated. Use `disableAfterMaxReached` instead.")),i.disableAfterIfMaxChoicesReached):e:e}setInteractionValidity(t,e="",i,n){let r=i??this;this._internals.setValidity(t?{}:{customError:!0},e,r),n?.suppressInline!==!0&&(this.validationDisplayMode==="inline"||this.validationDisplayMode==="both")&&this.updateInlineValidationMessage()}updateInlineValidationMessage(){let t=this.getValidationMessageElement();if(t){if(!this._internals.validity.valid){t.textContent=this._internals.validationMessage,t.style.setProperty("display","block","important");return}t.textContent="",t.style.display="none"}}clearInlineValidationMessage(){let t=this.getValidationMessageElement();t&&(t.textContent="",t.style.display="none")}getValidationMessageElement(){return this.shadowRoot?.querySelector("#validation-message")}reset(){this.response=null}formResetCallback(){this.reset()}connectedCallback(){super.connectedCallback(),this.registersWithItem&&this.dispatchEvent(new CustomEvent("qti-register-interaction",{bubbles:!0,composed:!0,cancelable:!1,detail:{interactionElement:this,responseIdentifier:this.responseIdentifier}}))}saveResponse(t,e){this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,composed:!0,cancelable:!1,detail:{responseIdentifier:this.responseIdentifier,response:Array.isArray(t)?[...t]:t,...e!==void 0?{state:e}:{}}}))}constructor(){super(),this.#t=new wt(this,{context:F,subscribe:!0,callback:t=>this.#r(t)}),this.#s=!1,this.#c=!1,this._interactionContext={choiceRole:null,draggablesSelector:null},this.disabled=!1,this.readonly=!1,this._internals=this.attachInternals(),this.addEventListener("qti-interaction-response",t=>{this.#o=JSON.stringify(t.detail?.response??null)})}firstUpdated(t){}};Ri([_({context:xt,subscribe:!0})],D.prototype,"configContext",void 0);Ri([U({context:Ti})],D.prototype,"_interactionContext",void 0);Ri([p({type:String,attribute:"response-identifier"})],D.prototype,"responseIdentifier",void 0);Ri([p({reflect:!0,type:Boolean})],D.prototype,"disabled",void 0);Ri([p({reflect:!0,type:Boolean})],D.prototype,"readonly",void 0);Ri([p({type:String})],D.prototype,"name",void 0);var Pi=class extends C{render(){return b`<slot></slot>`}defaultValues(t){let e=Array.from(this.querySelectorAll("qti-default-value > qti-value"));if(e.length===0)return null;let i=e.map(n=>n.innerHTML.trim());return i.length>1||t==="multiple"||t==="ordered"?i:i[0]}};var tl=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},Za=(o,t)=>o==null?{identifier:"",baseType:"string",value:null,cardinality:"single",type:"response"}:Array.isArray(o)?{identifier:"",baseType:t??cd(o[0]),value:o.map(e=>String(e)),cardinality:"multiple",type:"response"}:{identifier:"",baseType:t??cd(o),value:String(o),cardinality:"single",type:"response"},cd=o=>typeof o=="number"?Number.isInteger(o)?"integer":"float":typeof o=="boolean"?"boolean":"string",ju=(o,t)=>{if(!(!Array.isArray(t)||t.length>0))return o.lastVariables.find(e=>e?.baseType&&e.baseType!=="record"&&e.cardinality!=="record")?.baseType},E=class extends C{constructor(){super(...arguments),this.#t=[],this.getVariables=()=>{let t=Array.from(this.children).map(e=>{switch(e.tagName.toLowerCase()){case"qti-base-value":return{baseType:e.getAttribute("base-type"),value:e.textContent.trim(),cardinality:"single"};case"qti-variable":{let i=e.getAttribute("identifier")||"";return i==="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.resolveVariable(i)}case"qti-multiple":{let n=e.getResult();return n?.length>0?{identifier:"",baseType:n[0].baseType,value:n.map(r=>r.value),cardinality:"multiple",type:"response"}:null}case"qti-ordered":{let n=e.getResult();return n?.length>0?{identifier:"",baseType:n[0].baseType,value:n.map(r=>r.value),cardinality:"ordered",type:"response"}:null}case"qti-repeat":{let n=e.getResult();return n?.length>0?n:null}case"qti-custom-operator":return Za(e.calculate?.());case"qti-correct":{let i=e.getAttribute("identifier")||"",n=this.context?.variables?.find(r=>r.identifier===i);return n?{baseType:n.baseType,value:n.correctResponse,cardinality:n.cardinality}:(console.warn(`qti-correct: no response declaration for "${i}"`),Za(null))}default:{try{let i=e,n=i.getResult();return Za(n,i.resultBaseType??ju(i,n))}catch(i){console.warn(`getVariables: could not read a value from <${e.tagName.toLowerCase()}>`,i)}return null}}}).flatMap(e=>Array.isArray(e)?e:[e]).filter(e=>e!==null);return this.#t=t,t}}#t;get lastResult(){return this.result}get lastVariables(){return this.#t}static{this.styles=q`
60
60
  slot {
61
61
  display: none;
62
62
  }
63
- `}render(){return b`<slot></slot>`}shouldUpdate(){return!this.hasUpdated}calculate(){return this.result=this.getResult(),this.result}getResult(){throw new Error("Not implemented")}get resultBaseType(){}resolveVariable(t){return this.context?.variables.find(e=>e.identifier===t)??this._testContext?.testOutcomeVariables?.find(e=>e.identifier===t)??this.resolveItemVariable(t)}resolveItemVariable(t){if(!t?.includes("."))return null;let e=t.split(".");return this._testContext?.items?.find(n=>n.identifier===e[0])?.variables?.find(n=>n.identifier===e[e.length-1])??null}};tl([_({context:F,subscribe:!0})],E.prototype,"context",void 0);tl([_({context:qt,subscribe:!0})],E.prototype,"qtiContext",void 0);tl([_({context:nt,subscribe:!0})],E.prototype,"_testContext",void 0);var Qt=class extends E{calculate(){return this.result=this.getResult(),this.result}getResult(){throw new Error("Not implemented")}};var By=()=>new Intl.NumberFormat().format(.1).replace(/\d/g,""),Rt=o=>typeof o=="string"?o:o.toString();function el(o){return o==null}function Zn(o){return o.replace(/([^:]\/)\/+/g,"$1").replace(/\/\//g,"/").replace("http:/","http://").replace("https:/","https://")}var zr=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},mt=class extends C{constructor(){super(...arguments),this.showHide="show",this.#t=new wt(this,{context:F,subscribe:!0,callback:t=>this.#i(t)})}#t;get _context(){return this.#t.value}#e;#i(t){let e=t?.variables;if(!e||!this.outcomeIdentifier)return;let i=JSON.stringify(e.find(s=>s.identifier===this.outcomeIdentifier)?.value??null),n=Number(e.find(s=>s.identifier==="numAttempts")?.value)||0,r=this.#e===void 0?n>0:this.#e!==i||n>0;this.#e=i,r&&this.checkShowFeedback(this.outcomeIdentifier)}checkShowFeedback(t){let e=this._context.variables.find(n=>n.identifier===t)||null;if(this.outcomeIdentifier!==t||!e)return;let i=!1;Array.isArray(e.value)?i=e.value.includes(this.identifier):i=!el(this.identifier)&&!el(e?.value)&&this.identifier===e.value||!1,this.#r(i)}#r(t){if(!this.#n()){this.showStatus="off";return}this.showStatus=t&&this.showHide==="show"||!t&&this.showHide==="hide"?"on":"off"}#n(){if(!this._computedContext)return!0;let t=this._computedContext.testParts?.find(n=>n.active)?.sections.flatMap(n=>n.items).find(n=>n.active);if(!t||t.showFeedback)return!0;if(t.adaptive)return t.completionStatus!=="completed";let e=t.maxAttempts??1;return e<=0?!0:(Number(this._context?.variables?.find(n=>n.identifier==="numAttempts")?.value)||0)<e}};zr([p({type:String,attribute:"show-hide"})],mt.prototype,"showHide",void 0);zr([p({type:String,attribute:"outcome-identifier"})],mt.prototype,"outcomeIdentifier",void 0);zr([p({type:String})],mt.prototype,"identifier",void 0);zr([p({type:String,attribute:!1})],mt.prototype,"showStatus",void 0);zr([_({context:j,subscribe:!0}),T()],mt.prototype,"_computedContext",void 0);function il(o){if(o==null)return null;if(!o.includes(",")){let e=o.trim();return e.length>0?e:null}let t=o.split(",").map(e=>e.trim()).filter(e=>e.length>0);return t.length===0?null:t.length===1?t[0]:t}function rl(o){if(o==null)return null;if(Array.isArray(o)){let e=o.map(i=>i.trim()).filter(i=>i.length>0);return e.length>0?e.join(","):null}let t=o.trim();return t.length>0?t:null}function*Ky(o){if(o!=null){if(Array.isArray(o)){for(let t of o){let e=t.trim();e&&(yield e)}return}if(!o.includes(",")){let t=o.trim();t&&(yield t);return}for(let t of o.split(",")){let e=t.trim();e&&(yield e)}}}function Zy(o){let[t,e,...i]=o.trim().split(/\s+/);if(!t||!e||i.length>0)throw new Error(`malformed directed-pair value: "${o}" (expected "source target")`);return{source:t,target:e}}function tv(o,t){return`${o} ${t}`}function ev(o){let[t,e,...i]=o.trim().split(/\s+/),n=Number(t),r=Number(e);if(!Number.isFinite(n)||!Number.isFinite(r)||i.length>0)throw new Error(`malformed point value: "${o}" (expected "x y" numeric coords)`);return{x:n,y:r}}function iv(o,t){return`${o} ${t}`}function Xt(o){let{emptyAs:t}=o,e=i=>i===t||i==null||i===""||Array.isArray(i)&&i.length===0;return{fromAttribute:i=>{let n=il(i);return n===null?t:n},toAttribute:i=>e(i)?null:rl(i)}}var dd=class extends C{},Pi=class extends Error{constructor(){super("qti-exit-response"),this.name="QtiExitResponseSignal"}},Oi=class extends Error{constructor(){super("qti-exit-test"),this.name="QtiExitTestSignal"}};var Fu=o=>{let t=o[0];return t==null?null:Array.isArray(t)?t[0]??null:String(t)},nl=o=>t=>{let e=Fu(t);return e===null?null:o(e)},Bu=["depcp","questify","qade"],Uu={Trim:nl(o=>o.trim()),ToAscii:nl(o=>o.normalize("NFD").replace(/[̀-ͯ]/g,"")),ParseCommaDecimal:nl(o=>o.replace(",","."))},Hu=new Map(Bu.flatMap(o=>Object.entries(Uu).map(([t,e])=>[`${o}:${t}`,e]))),ol=new Map,sv=(o,t)=>{ol.set(o,t)},av=o=>{ol.delete(o)},hd=o=>ol.get(o)??Hu.get(o)??null;var pd={true:!0,1:!0,false:!1,0:!1},J=class{static isPointInArea(t,e,i){if(i!=="point")return console.warn(`Base type ${i} is not supported for point area mapping.`),!1;let[n,r]=t.split(" ").map(Number),[s,...a]=e.split(","),l=a.map(Number);switch(s.toLowerCase()){case"default":return!0;case"circle":{let[c,d,h]=l;return l.length!==3?(console.warn(`Invalid circle definition: ${e}`),!1):Math.sqrt((n-c)**2+(r-d)**2)<=h}case"rect":{let[c,d,h,f]=l;return l.length!==4?(console.warn(`Invalid rectangle definition: ${e}`),!1):n>=c&&n<=h&&r>=d&&r<=f}case"ellipse":{let[c,d,h,f]=l;if(l.length!==4)return console.warn(`Invalid ellipse definition: ${e}`),!1;let m=(n-c)**2/h**2,v=(r-d)**2/f**2;return m+v<=1}case"poly":{if(l.length<6||l.length%2!==0)return console.warn(`Invalid polygon definition: ${e}`),!1;let c=[];for(let d=0;d<l.length;d+=2)c.push({x:l[d],y:l[d+1]});return this.isPointInPolygon({x:n,y:r},c)}default:return console.warn(`Unsupported shape type: ${s}`),!1}}static isPointInPolygon(t,e){let i=!1;for(let n=0,r=e.length-1;n<e.length;r=n++){let s=e[n].x,a=e[n].y,l=e[r].x,c=e[r].y;a>t.y!=c>t.y&&t.x<(l-s)*(t.y-a)/(c-a)+s&&(i=!i)}return i}static compareSingleValues(t,e,i){switch(i){case"identifier":case"string":return t===e;case"boolean":{let n=pd[t.trim().toLowerCase()];return n!==void 0&&n===pd[e.trim().toLowerCase()]}case"integer":{let n=parseInt(t,10),r=parseInt(e,10);if(!isNaN(n)&&!isNaN(r)){let s=parseFloat(t),a=parseFloat(e);return!Number.isInteger(s)||!Number.isInteger(a)?s===a:n===r}else console.error(`Cannot convert ${t} and/or ${e} to int.`);break}case"float":{let n=parseFloat(t),r=parseFloat(e);if(!isNaN(n)&&!isNaN(r))return n===r;console.error(`couldn't convert ${t} and/or ${e} to float.`);break}case"pair":case"directedPair":{let n=t.split(" "),r=e.split(" ");if(n.length===2&&r.length===2)return i==="pair"&&(n.sort(),r.sort()),n.join(" ")===r.join(" ");console.error(`compared two pair but one of the values does not have 2 values: 1: ${t} 2: ${e}`);break}}return!1}};var Ce=Symbol("testHost");var md={"cito-item-rendered":{kind:"notification",scope:"item"},"cito-item-response-changed":{kind:"notification",scope:"item",deprecated:"qti-interaction-changed"},"cito-item-outcome-changed":{kind:"notification",scope:"item",deprecated:"qti-outcome-changed"},"cito-item-rubric-placement":{kind:"notification",scope:"item",deprecated:"qti-rubric:discretionary-placement"}};function sl(o,t,e,i,n=!1){let r={detail:i??{},bubbles:!0,composed:!0,cancelable:n},s=o.dispatchEvent(new CustomEvent(e,r)),{deprecated:a}=t[e];return a?o.dispatchEvent(new CustomEvent(a,r))&&s:s}var ud=new Set;function al(o,t,e,i){let n;o.addEventListener(e,s=>{n=s.detail,queueMicrotask(()=>n=void 0),i(s)});let{deprecated:r}=t[e];r&&o.addEventListener(r,s=>{n!==void 0&&s.detail===n||(ud.has(r)||(ud.add(r),console.warn(`[qti-components] The event "${r}" is deprecated; dispatch "${e}" instead.`)),i(s))})}function Mi(o,t,e,i=!1){return sl(o,md,t,e,i)}function fd(o,t,e){al(o,md,t,e)}var gd={"cito-test-navigate":{kind:"request",scope:"test",deprecated:"qti-request-navigation"},"cito-test-end-attempt":{kind:"request",scope:"test",deprecated:"test-end-attempt"},"cito-test-update-outcome":{kind:"request",scope:"test",deprecated:"test-update-outcome-variable"},"cito-test-update-plugin-state":{kind:"request",scope:"test"},"cito-test-switch-view":{kind:"request",scope:"test",deprecated:"on-test-switch-view"},"cito-test-navigated":{kind:"notification",scope:"test"},"cito-test-navigation-started":{kind:"notification",scope:"test",deprecated:"qti-navigation-loading-started"},"cito-test-navigation-failed":{kind:"notification",scope:"test",deprecated:"qti-navigation-error"},"cito-test-rendered":{kind:"notification",scope:"test",deprecated:"qti-test-loaded"},"cito-test-loaded":{kind:"notification",scope:"test",deprecated:"qti-assessment-test-connected"},"cito-test-state-changed":{kind:"notification",scope:"test",deprecated:"qti-state-changed"},"cito-test-items-skipped":{kind:"notification",scope:"test"},"cito-test-end-reached":{kind:"notification",scope:"test"},"cito-item-ref-connected":{kind:"notification",scope:"item",deprecated:"qti-assessment-item-ref-connected"}};function V(o,t,e){sl(o,gd,t,e)}function H(o,t,e){al(o,gd,t,e)}var ke=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},bd={fromAttribute(o){return o==="true"},toAttribute(o){return o?"true":"false"}},Ct=class extends C{constructor(){super(...arguments),this.xmlDoc=null,this.myTemplate=null,this.#e=null}get weights(){let t=new Map;for(let e of this.querySelectorAll(":scope > qti-weight")){let i=e.getAttribute("identifier");if(!i)continue;let n=Number(e.getAttribute("value"));if(Number.isNaN(n)){console.warn(`qti-weight "${i}" has a non-numeric value, ignoring it`);continue}t.set(i,n)}return t}createRenderRoot(){return this}get assessmentItem(){return this.renderRoot?.querySelector("qti-assessment-item")}disconnectedCallback(){super.disconnectedCallback(),this.testHost=void 0}async connectedCallback(){super.connectedCallback();let t=this.testHost?.querySelector("template[item-ref]");this.myTemplate=t?we(t):null,this.requestUpdate(),await this.updateComplete,V(this,"cito-item-ref-connected",{identifier:this.identifier,href:this.href,category:this.category})}#t(){for(let t of this.computedContext?.testParts??[])for(let e of t.sections){let i=e.items.find(n=>n.identifier===this.identifier);if(i)return i}}#e;render(){if(!this.xmlDoc)return this.#e=null,O;(this.#e?.source!==this.xmlDoc||this.#e.template!==this.myTemplate)&&(this.#e={source:this.xmlDoc,template:this.myTemplate,doc:this.xmlDoc.cloneNode(!0)});let t=this.#e.doc;if(!this.myTemplate)return t;let e={xmlDoc:t,identifier:this.identifier,href:this.href,category:this.category,item:this.#t(),itemRef:this};return this.myTemplate(e)}};ke([p({type:String})],Ct.prototype,"category",void 0);ke([p({type:String})],Ct.prototype,"identifier",void 0);ke([p({type:Boolean,converter:bd})],Ct.prototype,"required",void 0);ke([p({type:Boolean,converter:bd})],Ct.prototype,"fixed",void 0);ke([p({type:String})],Ct.prototype,"href",void 0);ke([T(),_({context:j,subscribe:!0})],Ct.prototype,"computedContext",void 0);ke([p({type:Object,attribute:!1})],Ct.prototype,"xmlDoc",void 0);ke([_({context:Ce,subscribe:!0})],Ct.prototype,"testHost",void 0);var Se=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},ll={fromAttribute(o){return o==="true"},toAttribute(o){return o?"true":"false"}},kt=class extends C{get title(){return this.#t}set title(t){this.#t=t,this.removeAttribute("title"),this.setAttribute("data-title",t)}#t="";async connectedCallback(){this.#t=this.getAttribute("title")||"",super.connectedCallback(),await this.updateComplete,this.dispatchEvent(new Event("qti-assessment-section-connected",{bubbles:!0,composed:!0}))}render(){return b`<slot name="qti-rubric-block"></slot><slot></slot>`}};Se([p({type:String})],kt.prototype,"identifier",void 0);Se([p({type:String})],kt.prototype,"required",void 0);Se([p({type:Boolean,converter:ll})],kt.prototype,"fixed",void 0);Se([p({type:Boolean,converter:ll})],kt.prototype,"visible",void 0);Se([p({type:Boolean,converter:ll,attribute:"keep-together"})],kt.prototype,"keepTogether",void 0);Se([p({type:String,attribute:"navigation-mode"})],kt.prototype,"navigationMode",void 0);Se([p({type:String,attribute:"submission-mode"})],kt.prototype,"submissionMode",void 0);Se([_({context:nt,subscribe:!0})],kt.prototype,"_testContext",void 0);var cl=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},ii=class extends C{get title(){return this.#t}set title(t){this.#t=t,this.removeAttribute("title"),this.setAttribute("data-title",t)}#t="";async connectedCallback(){super.connectedCallback(),await this.updateComplete,V(this,"cito-test-loaded",this)}render(){return b` <slot></slot>`}};cl([p({type:String})],ii.prototype,"identifier",void 0);cl([p({type:String})],ii.prototype,"title",null);cl([_({context:nt,subscribe:!0})],ii.prototype,"_testContext",void 0);function to(o,t){let e=o.firstElementChild;if(!e||typeof e.calculate!="function")return console.warn(`<${o.localName}> has no evaluable expression child`,o),t;try{let i=e.calculate();return i===!0||i==="true"}catch(i){return console.warn(`<${o.localName}> could not evaluate its expression`,i),t}}var Wu=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},se=class extends C{constructor(){super(...arguments),this.target=""}static{this.EXIT_SECTION="EXIT_SECTION"}static{this.EXIT_TESTPART="EXIT_TESTPART"}static{this.EXIT_TEST="EXIT_TEST"}static{this.styles=q`
63
+ `}render(){return b`<slot></slot>`}shouldUpdate(){return!this.hasUpdated}calculate(){return this.result=this.getResult(),this.result}getResult(){throw new Error("Not implemented")}get resultBaseType(){}resolveVariable(t){return this.context?.variables.find(e=>e.identifier===t)??this._testContext?.testOutcomeVariables?.find(e=>e.identifier===t)??this.resolveItemVariable(t)}resolveItemVariable(t){if(!t?.includes("."))return null;let e=t.split(".");return this._testContext?.items?.find(n=>n.identifier===e[0])?.variables?.find(n=>n.identifier===e[e.length-1])??null}};tl([_({context:F,subscribe:!0})],E.prototype,"context",void 0);tl([_({context:qt,subscribe:!0})],E.prototype,"qtiContext",void 0);tl([_({context:nt,subscribe:!0})],E.prototype,"_testContext",void 0);var Qt=class extends E{calculate(){return this.result=this.getResult(),this.result}getResult(){throw new Error("Not implemented")}};var Uy=()=>new Intl.NumberFormat().format(.1).replace(/\d/g,""),Rt=o=>typeof o=="string"?o:o.toString();function el(o){return o==null}function Zn(o){return o.replace(/([^:]\/)\/+/g,"$1").replace(/\/\//g,"/").replace("http:/","http://").replace("https:/","https://")}var zr=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},mt=class extends C{constructor(){super(...arguments),this.showHide="show",this.#t=new wt(this,{context:F,subscribe:!0,callback:t=>this.#i(t)})}#t;get _context(){return this.#t.value}#e;#i(t){let e=t?.variables;if(!e||!this.outcomeIdentifier)return;let i=JSON.stringify(e.find(s=>s.identifier===this.outcomeIdentifier)?.value??null),n=Number(e.find(s=>s.identifier==="numAttempts")?.value)||0,r=this.#e===void 0?n>0:this.#e!==i||n>0;this.#e=i,r&&this.checkShowFeedback(this.outcomeIdentifier)}checkShowFeedback(t){let e=this._context.variables.find(n=>n.identifier===t)||null;if(this.outcomeIdentifier!==t||!e)return;let i=!1;Array.isArray(e.value)?i=e.value.includes(this.identifier):i=!el(this.identifier)&&!el(e?.value)&&this.identifier===e.value||!1,this.#r(i)}#r(t){if(!this.#n()){this.showStatus="off";return}this.showStatus=t&&this.showHide==="show"||!t&&this.showHide==="hide"?"on":"off"}#n(){if(!this._computedContext)return!0;let t=this._computedContext.testParts?.find(n=>n.active)?.sections.flatMap(n=>n.items).find(n=>n.active);if(!t||t.showFeedback)return!0;if(t.adaptive)return t.completionStatus!=="completed";let e=t.maxAttempts??1;return e<=0?!0:(Number(this._context?.variables?.find(n=>n.identifier==="numAttempts")?.value)||0)<e}};zr([p({type:String,attribute:"show-hide"})],mt.prototype,"showHide",void 0);zr([p({type:String,attribute:"outcome-identifier"})],mt.prototype,"outcomeIdentifier",void 0);zr([p({type:String})],mt.prototype,"identifier",void 0);zr([p({type:String,attribute:!1})],mt.prototype,"showStatus",void 0);zr([_({context:j,subscribe:!0}),T()],mt.prototype,"_computedContext",void 0);function il(o){if(o==null)return null;if(!o.includes(",")){let e=o.trim();return e.length>0?e:null}let t=o.split(",").map(e=>e.trim()).filter(e=>e.length>0);return t.length===0?null:t.length===1?t[0]:t}function rl(o){if(o==null)return null;if(Array.isArray(o)){let e=o.map(i=>i.trim()).filter(i=>i.length>0);return e.length>0?e.join(","):null}let t=o.trim();return t.length>0?t:null}function*Zy(o){if(o!=null){if(Array.isArray(o)){for(let t of o){let e=t.trim();e&&(yield e)}return}if(!o.includes(",")){let t=o.trim();t&&(yield t);return}for(let t of o.split(",")){let e=t.trim();e&&(yield e)}}}function tv(o){let[t,e,...i]=o.trim().split(/\s+/);if(!t||!e||i.length>0)throw new Error(`malformed directed-pair value: "${o}" (expected "source target")`);return{source:t,target:e}}function ev(o,t){return`${o} ${t}`}function iv(o){let[t,e,...i]=o.trim().split(/\s+/),n=Number(t),r=Number(e);if(!Number.isFinite(n)||!Number.isFinite(r)||i.length>0)throw new Error(`malformed point value: "${o}" (expected "x y" numeric coords)`);return{x:n,y:r}}function rv(o,t){return`${o} ${t}`}function Gt(o){let{emptyAs:t}=o,e=i=>i===t||i==null||i===""||Array.isArray(i)&&i.length===0;return{fromAttribute:i=>{let n=il(i);return n===null?t:n},toAttribute:i=>e(i)?null:rl(i)}}var dd=class extends C{},Oi=class extends Error{constructor(){super("qti-exit-response"),this.name="QtiExitResponseSignal"}},Mi=class extends Error{constructor(){super("qti-exit-test"),this.name="QtiExitTestSignal"}};var Fu=o=>{let t=o[0];return t==null?null:Array.isArray(t)?t[0]??null:String(t)},nl=o=>t=>{let e=Fu(t);return e===null?null:o(e)},Bu=["depcp","questify","qade"],Uu={Trim:nl(o=>o.trim()),ToAscii:nl(o=>o.normalize("NFD").replace(/[̀-ͯ]/g,"")),ParseCommaDecimal:nl(o=>o.replace(",","."))},Hu=new Map(Bu.flatMap(o=>Object.entries(Uu).map(([t,e])=>[`${o}:${t}`,e]))),ol=new Map,av=(o,t)=>{ol.set(o,t)},lv=o=>{ol.delete(o)},hd=o=>ol.get(o)??Hu.get(o)??null;var pd={true:!0,1:!0,false:!1,0:!1},J=class{static isPointInArea(t,e,i){if(i!=="point")return console.warn(`Base type ${i} is not supported for point area mapping.`),!1;let[n,r]=t.split(" ").map(Number),[s,...a]=e.split(","),l=a.map(Number);switch(s.toLowerCase()){case"default":return!0;case"circle":{let[c,d,h]=l;return l.length!==3?(console.warn(`Invalid circle definition: ${e}`),!1):Math.sqrt((n-c)**2+(r-d)**2)<=h}case"rect":{let[c,d,h,f]=l;return l.length!==4?(console.warn(`Invalid rectangle definition: ${e}`),!1):n>=c&&n<=h&&r>=d&&r<=f}case"ellipse":{let[c,d,h,f]=l;if(l.length!==4)return console.warn(`Invalid ellipse definition: ${e}`),!1;let m=(n-c)**2/h**2,v=(r-d)**2/f**2;return m+v<=1}case"poly":{if(l.length<6||l.length%2!==0)return console.warn(`Invalid polygon definition: ${e}`),!1;let c=[];for(let d=0;d<l.length;d+=2)c.push({x:l[d],y:l[d+1]});return this.isPointInPolygon({x:n,y:r},c)}default:return console.warn(`Unsupported shape type: ${s}`),!1}}static isPointInPolygon(t,e){let i=!1;for(let n=0,r=e.length-1;n<e.length;r=n++){let s=e[n].x,a=e[n].y,l=e[r].x,c=e[r].y;a>t.y!=c>t.y&&t.x<(l-s)*(t.y-a)/(c-a)+s&&(i=!i)}return i}static compareSingleValues(t,e,i){switch(i){case"identifier":case"string":return t===e;case"boolean":{let n=pd[t.trim().toLowerCase()];return n!==void 0&&n===pd[e.trim().toLowerCase()]}case"integer":{let n=parseInt(t,10),r=parseInt(e,10);if(!isNaN(n)&&!isNaN(r)){let s=parseFloat(t),a=parseFloat(e);return!Number.isInteger(s)||!Number.isInteger(a)?s===a:n===r}else console.error(`Cannot convert ${t} and/or ${e} to int.`);break}case"float":{let n=parseFloat(t),r=parseFloat(e);if(!isNaN(n)&&!isNaN(r))return n===r;console.error(`couldn't convert ${t} and/or ${e} to float.`);break}case"pair":case"directedPair":{let n=t.split(" "),r=e.split(" ");if(n.length===2&&r.length===2)return i==="pair"&&(n.sort(),r.sort()),n.join(" ")===r.join(" ");console.error(`compared two pair but one of the values does not have 2 values: 1: ${t} 2: ${e}`);break}}return!1}};var Ce=Symbol("testHost");var md={"cito-item-rendered":{kind:"notification",scope:"item"},"cito-item-response-changed":{kind:"notification",scope:"item",deprecated:"qti-interaction-changed"},"cito-item-outcome-changed":{kind:"notification",scope:"item",deprecated:"qti-outcome-changed"},"cito-item-rubric-placement":{kind:"notification",scope:"item",deprecated:"qti-rubric:discretionary-placement"}};function sl(o,t,e,i,n=!1){let r={detail:i??{},bubbles:!0,composed:!0,cancelable:n},s=o.dispatchEvent(new CustomEvent(e,r)),{deprecated:a}=t[e];return a?o.dispatchEvent(new CustomEvent(a,r))&&s:s}var ud=new Set;function al(o,t,e,i){let n;o.addEventListener(e,s=>{n=s.detail,queueMicrotask(()=>n=void 0),i(s)});let{deprecated:r}=t[e];r&&o.addEventListener(r,s=>{n!==void 0&&s.detail===n||(ud.has(r)||(ud.add(r),console.warn(`[qti-components] The event "${r}" is deprecated; dispatch "${e}" instead.`)),i(s))})}function Di(o,t,e,i=!1){return sl(o,md,t,e,i)}function fd(o,t,e){al(o,md,t,e)}var gd={"cito-test-navigate":{kind:"request",scope:"test",deprecated:"qti-request-navigation"},"cito-test-end-attempt":{kind:"request",scope:"test",deprecated:"test-end-attempt"},"cito-test-update-outcome":{kind:"request",scope:"test",deprecated:"test-update-outcome-variable"},"cito-test-update-plugin-state":{kind:"request",scope:"test"},"cito-test-switch-view":{kind:"request",scope:"test",deprecated:"on-test-switch-view"},"cito-test-navigated":{kind:"notification",scope:"test"},"cito-test-navigation-started":{kind:"notification",scope:"test",deprecated:"qti-navigation-loading-started"},"cito-test-navigation-failed":{kind:"notification",scope:"test",deprecated:"qti-navigation-error"},"cito-test-rendered":{kind:"notification",scope:"test",deprecated:"qti-test-loaded"},"cito-test-loaded":{kind:"notification",scope:"test",deprecated:"qti-assessment-test-connected"},"cito-test-state-changed":{kind:"notification",scope:"test",deprecated:"qti-state-changed"},"cito-test-items-skipped":{kind:"notification",scope:"test"},"cito-test-end-reached":{kind:"notification",scope:"test"},"cito-item-ref-connected":{kind:"notification",scope:"item",deprecated:"qti-assessment-item-ref-connected"}};function V(o,t,e){sl(o,gd,t,e)}function H(o,t,e){al(o,gd,t,e)}var Se=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},bd={fromAttribute(o){return o==="true"},toAttribute(o){return o?"true":"false"}},Ct=class extends C{constructor(){super(...arguments),this.xmlDoc=null,this.myTemplate=null,this.#e=null}get weights(){let t=new Map;for(let e of this.querySelectorAll(":scope > qti-weight")){let i=e.getAttribute("identifier");if(!i)continue;let n=Number(e.getAttribute("value"));if(Number.isNaN(n)){console.warn(`qti-weight "${i}" has a non-numeric value, ignoring it`);continue}t.set(i,n)}return t}createRenderRoot(){return this}get assessmentItem(){return this.renderRoot?.querySelector("qti-assessment-item")}disconnectedCallback(){super.disconnectedCallback(),this.testHost=void 0}async connectedCallback(){super.connectedCallback();let t=this.testHost?.querySelector("template[item-ref]");this.myTemplate=t?we(t):null,this.requestUpdate(),await this.updateComplete,V(this,"cito-item-ref-connected",{identifier:this.identifier,href:this.href,category:this.category})}#t(){for(let t of this.computedContext?.testParts??[])for(let e of t.sections){let i=e.items.find(n=>n.identifier===this.identifier);if(i)return i}}#e;render(){if(!this.xmlDoc)return this.#e=null,O;(this.#e?.source!==this.xmlDoc||this.#e.template!==this.myTemplate)&&(this.#e={source:this.xmlDoc,template:this.myTemplate,doc:this.xmlDoc.cloneNode(!0)});let t=this.#e.doc;if(!this.myTemplate)return t;let e={xmlDoc:t,identifier:this.identifier,href:this.href,category:this.category,item:this.#t(),itemRef:this};return this.myTemplate(e)}};Se([p({type:String})],Ct.prototype,"category",void 0);Se([p({type:String})],Ct.prototype,"identifier",void 0);Se([p({type:Boolean,converter:bd})],Ct.prototype,"required",void 0);Se([p({type:Boolean,converter:bd})],Ct.prototype,"fixed",void 0);Se([p({type:String})],Ct.prototype,"href",void 0);Se([T(),_({context:j,subscribe:!0})],Ct.prototype,"computedContext",void 0);Se([p({type:Object,attribute:!1})],Ct.prototype,"xmlDoc",void 0);Se([_({context:Ce,subscribe:!0})],Ct.prototype,"testHost",void 0);var ke=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},ll={fromAttribute(o){return o==="true"},toAttribute(o){return o?"true":"false"}},St=class extends C{get title(){return this.#t}set title(t){this.#t=t,this.removeAttribute("title"),this.setAttribute("data-title",t)}#t="";async connectedCallback(){this.#t=this.getAttribute("title")||"",super.connectedCallback(),await this.updateComplete,this.dispatchEvent(new Event("qti-assessment-section-connected",{bubbles:!0,composed:!0}))}render(){return b`<slot name="qti-rubric-block"></slot><slot></slot>`}};ke([p({type:String})],St.prototype,"identifier",void 0);ke([p({type:String})],St.prototype,"required",void 0);ke([p({type:Boolean,converter:ll})],St.prototype,"fixed",void 0);ke([p({type:Boolean,converter:ll})],St.prototype,"visible",void 0);ke([p({type:Boolean,converter:ll,attribute:"keep-together"})],St.prototype,"keepTogether",void 0);ke([p({type:String,attribute:"navigation-mode"})],St.prototype,"navigationMode",void 0);ke([p({type:String,attribute:"submission-mode"})],St.prototype,"submissionMode",void 0);ke([_({context:nt,subscribe:!0})],St.prototype,"_testContext",void 0);var cl=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},ii=class extends C{get title(){return this.#t}set title(t){this.#t=t,this.removeAttribute("title"),this.setAttribute("data-title",t)}#t="";async connectedCallback(){super.connectedCallback(),await this.updateComplete,V(this,"cito-test-loaded",this)}render(){return b` <slot></slot>`}};cl([p({type:String})],ii.prototype,"identifier",void 0);cl([p({type:String})],ii.prototype,"title",null);cl([_({context:nt,subscribe:!0})],ii.prototype,"_testContext",void 0);function to(o,t){let e=o.firstElementChild;if(!e||typeof e.calculate!="function")return console.warn(`<${o.localName}> has no evaluable expression child`,o),t;try{let i=e.calculate();return i===!0||i==="true"}catch(i){return console.warn(`<${o.localName}> could not evaluate its expression`,i),t}}var Wu=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},se=class extends C{constructor(){super(...arguments),this.target=""}static{this.EXIT_SECTION="EXIT_SECTION"}static{this.EXIT_TESTPART="EXIT_TESTPART"}static{this.EXIT_TEST="EXIT_TEST"}static{this.styles=q`
64
64
  :host {
65
65
  display: none;
66
66
  }
67
- `}evaluate(){return to(this,!1)}render(){return b`<slot></slot>`}};Wu([p({type:String})],se.prototype,"target",void 0);var ri=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},Di={fromAttribute(o){return o==="true"},toAttribute(o){return o?"true":"false"}},Pt=class extends C{constructor(){super(...arguments),this.maxAttempts=1,this.showFeedback=!1,this.allowReview=!0,this.showSolution=!1,this.allowComment=!1,this.allowSkipping=!0,this.validateResponses=!1}async connectedCallback(){super.connectedCallback(),await this.updateComplete,this.dispatchEvent(new CustomEvent("qti-item-session-control-connected",{detail:this,bubbles:!0,composed:!0}))}render(){return b`<slot></slot>`}};ri([p({type:Number,attribute:"max-attempts"})],Pt.prototype,"maxAttempts",void 0);ri([p({type:Boolean,converter:Di,attribute:"show-feedback"})],Pt.prototype,"showFeedback",void 0);ri([p({type:Boolean,converter:Di,attribute:"allow-review"})],Pt.prototype,"allowReview",void 0);ri([p({type:Boolean,converter:Di,attribute:"show-solution"})],Pt.prototype,"showSolution",void 0);ri([p({type:Boolean,converter:Di,attribute:"allow-comment"})],Pt.prototype,"allowComment",void 0);ri([p({type:Boolean,converter:Di,attribute:"allow-skipping"})],Pt.prototype,"allowSkipping",void 0);ri([p({type:Boolean,converter:Di,attribute:"validate-responses"})],Pt.prototype,"validateResponses",void 0);var dl=o=>o?.split(/\s+/).filter(Boolean)??[],Ni=o=>({sectionIdentifier:o.getAttribute("section-identifier"),includeCategories:dl(o.getAttribute("include-category")),excludeCategories:dl(o.getAttribute("exclude-category"))}),$i=(o,{sectionIdentifier:t,includeCategories:e,excludeCategories:i})=>{let n=t?Array.from(o.querySelectorAll(`qti-assessment-section[identifier="${CSS.escape(t)}"]`)):[o];return n.length===0?(console.warn(`no qti-assessment-section with identifier "${t}"`),[]):n.flatMap(r=>Array.from(r.querySelectorAll("qti-assessment-item-ref"))).filter(r=>{let s=dl(r.category);return!(e.length>0&&!s.some(a=>e.includes(a))||i.length>0&&s.some(a=>i.includes(a)))})};var Qu=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},jr=class extends E{#t=null;constructor(){super(),H(this,"cito-test-loaded",t=>this.#t=t.detail)}get#e(){return this.#t??this.closest("qti-assessment-test")}getResult(){let t=this.#e;if(!t)return console.warn("qti-number-presented: no enclosing qti-assessment-test, nothing to count"),0;let e=new Set((this._testContext?.items??[]).filter(i=>{let n=i.variables?.find(r=>r.identifier==="completionStatus")?.value;return n!=null&&n!=="not_attempted"}).map(i=>i.identifier));return $i(t,Ni(this)).filter(i=>e.has(i.identifier)).length}calculate(){return this.getResult()}};Qu([_({context:nt,subscribe:!0})],jr.prototype,"_testContext",void 0);var eo=class extends E{#t=null;constructor(){super(),H(this,"cito-test-loaded",t=>this.#t=t.detail)}get#e(){return this.#t??this.closest("qti-assessment-test")}getResult(){let t=this.#e;return t?$i(t,Ni(this)).length:(console.warn("qti-number-selected: no enclosing qti-assessment-test, nothing to count"),0)}calculate(){return this.getResult()}};var io=class extends C{static{this.styles=q`
67
+ `}evaluate(){return to(this,!1)}render(){return b`<slot></slot>`}};Wu([p({type:String})],se.prototype,"target",void 0);var ri=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},Ni={fromAttribute(o){return o==="true"},toAttribute(o){return o?"true":"false"}},Pt=class extends C{constructor(){super(...arguments),this.maxAttempts=1,this.showFeedback=!1,this.allowReview=!0,this.showSolution=!1,this.allowComment=!1,this.allowSkipping=!0,this.validateResponses=!1}async connectedCallback(){super.connectedCallback(),await this.updateComplete,this.dispatchEvent(new CustomEvent("qti-item-session-control-connected",{detail:this,bubbles:!0,composed:!0}))}render(){return b`<slot></slot>`}};ri([p({type:Number,attribute:"max-attempts"})],Pt.prototype,"maxAttempts",void 0);ri([p({type:Boolean,converter:Ni,attribute:"show-feedback"})],Pt.prototype,"showFeedback",void 0);ri([p({type:Boolean,converter:Ni,attribute:"allow-review"})],Pt.prototype,"allowReview",void 0);ri([p({type:Boolean,converter:Ni,attribute:"show-solution"})],Pt.prototype,"showSolution",void 0);ri([p({type:Boolean,converter:Ni,attribute:"allow-comment"})],Pt.prototype,"allowComment",void 0);ri([p({type:Boolean,converter:Ni,attribute:"allow-skipping"})],Pt.prototype,"allowSkipping",void 0);ri([p({type:Boolean,converter:Ni,attribute:"validate-responses"})],Pt.prototype,"validateResponses",void 0);var dl=o=>o?.split(/\s+/).filter(Boolean)??[],$i=o=>({sectionIdentifier:o.getAttribute("section-identifier"),includeCategories:dl(o.getAttribute("include-category")),excludeCategories:dl(o.getAttribute("exclude-category"))}),Li=(o,{sectionIdentifier:t,includeCategories:e,excludeCategories:i})=>{let n=t?Array.from(o.querySelectorAll(`qti-assessment-section[identifier="${CSS.escape(t)}"]`)):[o];return n.length===0?(console.warn(`no qti-assessment-section with identifier "${t}"`),[]):n.flatMap(r=>Array.from(r.querySelectorAll("qti-assessment-item-ref"))).filter(r=>{let s=dl(r.category);return!(e.length>0&&!s.some(a=>e.includes(a))||i.length>0&&s.some(a=>i.includes(a)))})};var Qu=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},jr=class extends E{#t=null;constructor(){super(),H(this,"cito-test-loaded",t=>this.#t=t.detail)}get#e(){return this.#t??this.closest("qti-assessment-test")}getResult(){let t=this.#e;if(!t)return console.warn("qti-number-presented: no enclosing qti-assessment-test, nothing to count"),0;let e=new Set((this._testContext?.items??[]).filter(i=>{let n=i.variables?.find(r=>r.identifier==="completionStatus")?.value;return n!=null&&n!=="not_attempted"}).map(i=>i.identifier));return Li(t,$i(this)).filter(i=>e.has(i.identifier)).length}calculate(){return this.getResult()}};Qu([_({context:nt,subscribe:!0})],jr.prototype,"_testContext",void 0);var eo=class extends E{#t=null;constructor(){super(),H(this,"cito-test-loaded",t=>this.#t=t.detail)}get#e(){return this.#t??this.closest("qti-assessment-test")}getResult(){let t=this.#e;return t?Li(t,$i(this)).length:(console.warn("qti-number-selected: no enclosing qti-assessment-test, nothing to count"),0)}calculate(){return this.getResult()}};var io=class extends C{static{this.styles=q`
68
68
  :host {
69
69
  display: none;
70
70
  }
@@ -72,7 +72,7 @@ Make sure to test your application with a production build as repeat registratio
72
72
  :host {
73
73
  display: none;
74
74
  }
75
- `]}render(){return b`<slot></slot>`}process(){let t=new hl,e=[...this.children];t.process(e)}},hl=class{process(t){try{for(let e of t)e.process()}catch(e){if(!(e instanceof Oi))throw e}}};var ni=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},ft=class extends C{constructor(){super(...arguments),this.#e=null,this.identifier="",this.adaptive="false",this.timeDependent=null,this._context={variables:ld},this.#i={...this._context,variables:this._context.variables},this.#r=new Map,this.#n=!1,this.interactionElements=[],this.#a=t=>{t.stopImmediatePropagation();let{variable:e}=t.detail,i=e.type==="template"?this.#r.get(e.identifier):void 0,n=i!==void 0?{...e,value:i}:e;this._context={...this._context,variables:[...this._context.variables,n]},this.#i=this._context,t.stopPropagation()},this.#c=t=>{t.stopImmediatePropagation(),this.interactionElements.push(t.detail.interactionElement)},this.#p=t=>{t.stopImmediatePropagation();let{responseIdentifier:e,countAttempt:i}=t.detail;this.validate(),this.updateResponseVariable(e,"true"),this.processResponse(i)},this.#l=t=>{t.stopImmediatePropagation();let{outcomeIdentifier:e,value:i}=t.detail;this.updateOutcomeVariable(e,i),t.stopPropagation()},this.#m=t=>{t.stopImmediatePropagation();let{templateIdentifier:e,value:i}=t.detail;this.#r.has(e)||this.updateTemplateVariable(e,i??void 0),t.stopPropagation()},this.#d=t=>{t.stopImmediatePropagation();let{responseIdentifier:e,value:i}=t.detail;this.updateCorrectResponse(e,i??void 0),t.stopPropagation()},this.#u=t=>{t.stopImmediatePropagation();let{responseIdentifier:e,response:i,state:n}=t.detail;this.updateResponseVariable(e,i),n!==void 0&&(this._context={...this._context,state:{...this._context.state||{},[e]:n}}),this.validate(!1),this.dispatchEvent(new CustomEvent("qti-item-context-updated",{bubbles:!0,composed:!0,detail:{itemContext:this._context}}))}}#t;#e;get title(){return this.#t}set title(t){this.#t=t,this.removeAttribute("title"),this.setAttribute("data-title",t)}willUpdate(t){super.willUpdate(t);let e=t.has("readonly")&&(this.readonly??!1)!==(this._context.readonly??!1),i=t.has("disabled")&&(this.disabled??!1)!==(this._context.disabled??!1);(e||i)&&(this._context={...this._context,...e?{readonly:!!this.readonly}:{},...i?{disabled:!!this.disabled}:{}})}set assessmentItemRefId(t){this._context={...this._context,identifier:t}}get assessmentItemRefId(){return this._context.identifier}get itemContext(){return this._context}get variables(){return this._context.variables.map(t=>({identifier:t.identifier,value:t.value,type:t.type,...t.type==="outcome"&&t.identifier==="SCORE"?{externalScored:t.externalScored}:{}}))}set variables(t){if(!Array.isArray(t)||t.some(r=>!("identifier"in r))){console.warn("variables property should be an array of VariableDeclaration");return}let e=this._context.variables,i=t.filter(r=>r.value!==null&&r.value!==void 0&&(r.type==="template"||e.some(s=>s.identifier===r.identifier&&s.type==="template")));i.forEach(r=>this.#r.set(r.identifier,r.value));let n=i.some(r=>JSON.stringify(e.find(s=>s.identifier===r.identifier)?.value)!==JSON.stringify(r.value));this._context={...this._context,variables:this._context.variables.map(r=>{let s=t.find(a=>a.identifier===r.identifier);return s?{...r,...s,interpolationTable:r.interpolationTable,matchTable:r.matchTable}:r})},this.#n&&n&&this.#b(),this.updateComplete.then(()=>this.#y())}get state(){return this._context.state}set state(t){this._context={...this._context,state:t?{...t}:void 0}}#i;#r;#n;set responses(t){if(t)for(let e of t){this.getResponse(e.responseIdentifier)&&this.updateResponseVariable(e.responseIdentifier,e.response);let n=this.interactionElements.find(r=>r.getAttribute("response-identifier")===e.responseIdentifier);n&&(n.response=e.response)}}render(){return b`<slot></slot>`}connectedCallback(){this.#o(),super.connectedCallback(),this.updateComplete.then(()=>{this.validate(!1),Mi(this,"cito-item-rendered",this),this.dispatchEvent(new CustomEvent("qti-assessment-item-connected",{bubbles:!0,composed:!0,detail:this})),this.#h()})}disconnectedCallback(){this.#s(),super.disconnectedCallback()}#o(){this.addEventListener("qti-register-variable",this.#a),this.addEventListener("qti-register-interaction",this.#c),this.addEventListener("end-attempt",this.#p),this.addEventListener("qti-set-outcome-value",this.#l),this.addEventListener("qti-set-template-value",this.#m),this.addEventListener("qti-set-correct-response",this.#d),this.addEventListener("qti-interaction-response",this.#u)}#s(){this.removeEventListener("qti-register-variable",this.#a),this.removeEventListener("qti-register-interaction",this.#c),this.removeEventListener("end-attempt",this.#p),this.removeEventListener("qti-set-outcome-value",this.#l),this.removeEventListener("qti-set-template-value",this.#m),this.removeEventListener("qti-set-correct-response",this.#d),this.removeEventListener("qti-interaction-response",this.#u)}#a;#c;#p;#l;#m;#d;#u;async#h(){let t=Array.from(this.querySelectorAll("qti-template-declaration"));t.length>0&&(await Promise.all(t.map(e=>e.updateComplete)),await Promise.resolve()),this.#e=this.querySelector("qti-template-processing"),this.#n=!0,this.#b()}#b(){this.#e&&(this.#e.process(),this.#i={...this._context,variables:this._context.variables})}processResponse(t=!0,e=!0){this.validate(e),t&&this.updateOutcomeVariable("numAttempts",(+this._context.variables.find(r=>r.identifier==="numAttempts")?.value+1).toString()),this.adaptive==="false"&&this.#v();let i=this.querySelector("qti-response-processing"),n=!!(i&&typeof i.process=="function");return n&&i.process(),this.adaptive==="false"&&this.updateOutcomeVariable("completionStatus",this.#g()),this.dispatchEvent(new CustomEvent("qti-item-context-updated",{bubbles:!0,composed:!0,detail:{itemContext:this._context,responseProcessed:!0}})),n}resetResponses(){this._context=this.#i}getResponse(t){return this.getVariable(t)}getOutcome(t){return this.getVariable(t)}getVariable(t){return this._context.variables.find(e=>e.identifier===t)||null}afterResponseVariableUpdated(){}updateResponseVariable(t,e){this._context={...this._context,variables:this._context.variables.map(i=>i.identifier!==t?i:{...i,value:e})},this.afterResponseVariableUpdated(),Mi(this,"cito-item-response-changed",{item:this.identifier,responseIdentifier:t,response:Array.isArray(e)?[...e]:e}),this.adaptive==="false"&&this.updateOutcomeVariable("completionStatus",this.#g())}updateTemplateVariable(t,e){let i=this._context.variables.find(r=>r.identifier===t&&r.type==="template");if(!i){console.warn(`Can not set qti-template-identifier: ${t}, it is not available`);return}let n=i.cardinality==="single"?Array.isArray(e)?e[0]:e??null:e==null?null:Array.isArray(e)?e:[e];this._context={...this._context,variables:this._context.variables.map(r=>r.identifier!==t?r:{...r,value:n})},this.dispatchEvent(new CustomEvent("qti-item-context-updated",{bubbles:!0,composed:!0,detail:{itemContext:this._context}}))}updateCorrectResponse(t,e){let i=this.getResponse(t);if(!i){console.warn(`Can not set correct response for identifier: ${t}, it is not available`);return}let n=i.cardinality==="single"?Array.isArray(e)?e[0]:e??null:e==null?null:Array.isArray(e)?e:[e];this._context={...this._context,variables:this._context.variables.map(r=>r.identifier!==t?r:{...r,correctResponse:n})},this.dispatchEvent(new CustomEvent("qti-item-context-updated",{bubbles:!0,composed:!0,detail:{itemContext:this._context}}))}setOutcomeVariable(t,e){this.updateOutcomeVariable(t,e),this.dispatchEvent(new CustomEvent("qti-item-context-updated",{bubbles:!0,composed:!0,detail:{itemContext:this._context}}))}updateOutcomeVariable(t,e){let i=this.getOutcome(t);if(!i){console.warn(`Can not set qti-outcome-identifier: ${t}, it is not available`);return}this._context={...this._context,variables:this._context.variables.map(n=>n.identifier!==t?n:{...n,value:i.cardinality==="single"||Array.isArray(e)?e:[e]})},Mi(this,"cito-item-outcome-changed",{item:this.identifier,outcomeIdentifier:t,value:this._context.variables.find(n=>n.identifier===t)?.value})}validate(t=!0){let e=this.interactionElements.every(i=>i.validate());return this.#f(e),t&&this.reportValidity(),e}#f(t){this._context.valid!==t&&(this._context={...this._context,valid:t})}#y(){let t=this._context.valid;this.validate(!1),this._context.valid!==t&&this.dispatchEvent(new CustomEvent("qti-item-context-updated",{bubbles:!0,composed:!0,detail:{itemContext:this._context}}))}reportValidity(){for(let t of this.interactionElements)t.reportValidity()}#g(){let t=this.validate(!1);return t===!0?"completed":t===!1?"incomplete":"not_attempted"}#v(){this._context={...this._context,variables:this._context.variables.map(t=>{if(t.type!=="outcome")return t;let n=("defaultValue"in t?t.defaultValue:null)??null;return n==null&&(t.baseType==="integer"||t.baseType==="float")&&(n="0"),{...t,value:n}})}}};ni([p({type:String})],ft.prototype,"identifier",void 0);ni([p({type:String})],ft.prototype,"adaptive",void 0);ni([p({type:String,attribute:"time-dependent"})],ft.prototype,"timeDependent",void 0);ni([p({type:String})],ft.prototype,"title",null);ni([p({type:Boolean})],ft.prototype,"disabled",void 0);ni([p({type:Boolean})],ft.prototype,"readonly",void 0);ni([U({context:F})],ft.prototype,"_context",void 0);var yd=q`
75
+ `]}render(){return b`<slot></slot>`}process(){let t=new hl,e=[...this.children];t.process(e)}},hl=class{process(t){try{for(let e of t)e.process()}catch(e){if(!(e instanceof Mi))throw e}}};var ni=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},ft=class extends C{constructor(){super(...arguments),this.#e=null,this.identifier="",this.adaptive="false",this.timeDependent=null,this._context={variables:ld},this.#i={...this._context,variables:this._context.variables},this.#r=new Map,this.#n=!1,this.interactionElements=[],this.#a=t=>{t.stopImmediatePropagation();let{variable:e}=t.detail,i=e.type==="template"?this.#r.get(e.identifier):void 0,n=i!==void 0?{...e,value:i}:e;this._context={...this._context,variables:[...this._context.variables,n]},this.#i=this._context,t.stopPropagation()},this.#c=t=>{t.stopImmediatePropagation(),this.interactionElements.push(t.detail.interactionElement)},this.#p=t=>{t.stopImmediatePropagation();let{responseIdentifier:e,countAttempt:i}=t.detail;this.validate(),this.updateResponseVariable(e,"true"),this.processResponse(i)},this.#l=t=>{t.stopImmediatePropagation();let{outcomeIdentifier:e,value:i}=t.detail;this.updateOutcomeVariable(e,i),t.stopPropagation()},this.#m=t=>{t.stopImmediatePropagation();let{templateIdentifier:e,value:i}=t.detail;this.#r.has(e)||this.updateTemplateVariable(e,i??void 0),t.stopPropagation()},this.#d=t=>{t.stopImmediatePropagation();let{responseIdentifier:e,value:i}=t.detail;this.updateCorrectResponse(e,i??void 0),t.stopPropagation()},this.#u=t=>{t.stopImmediatePropagation();let{responseIdentifier:e,response:i,state:n}=t.detail;this.updateResponseVariable(e,i),n!==void 0&&(this._context={...this._context,state:{...this._context.state||{},[e]:n}}),this.validate(!1),this.dispatchEvent(new CustomEvent("qti-item-context-updated",{bubbles:!0,composed:!0,detail:{itemContext:this._context}}))}}#t;#e;get title(){return this.#t}set title(t){this.#t=t,this.removeAttribute("title"),this.setAttribute("data-title",t)}willUpdate(t){super.willUpdate(t);let e=t.has("readonly")&&(this.readonly??!1)!==(this._context.readonly??!1),i=t.has("disabled")&&(this.disabled??!1)!==(this._context.disabled??!1);(e||i)&&(this._context={...this._context,...e?{readonly:!!this.readonly}:{},...i?{disabled:!!this.disabled}:{}})}set assessmentItemRefId(t){this._context={...this._context,identifier:t}}get assessmentItemRefId(){return this._context.identifier}get itemContext(){return this._context}get variables(){return this._context.variables.map(t=>({identifier:t.identifier,value:t.value,type:t.type,...t.type==="outcome"&&t.identifier==="SCORE"?{externalScored:t.externalScored}:{}}))}set variables(t){if(!Array.isArray(t)||t.some(r=>!("identifier"in r))){console.warn("variables property should be an array of VariableDeclaration");return}let e=this._context.variables,i=t.filter(r=>r.value!==null&&r.value!==void 0&&(r.type==="template"||e.some(s=>s.identifier===r.identifier&&s.type==="template")));i.forEach(r=>this.#r.set(r.identifier,r.value));let n=i.some(r=>JSON.stringify(e.find(s=>s.identifier===r.identifier)?.value)!==JSON.stringify(r.value));this._context={...this._context,variables:this._context.variables.map(r=>{let s=t.find(a=>a.identifier===r.identifier);return s?{...r,...s,interpolationTable:r.interpolationTable,matchTable:r.matchTable}:r})},this.#n&&n&&this.#b(),this.updateComplete.then(()=>this.#y())}get state(){return this._context.state}set state(t){this._context={...this._context,state:t?{...t}:void 0}}#i;#r;#n;set responses(t){if(t)for(let e of t){this.getResponse(e.responseIdentifier)&&this.updateResponseVariable(e.responseIdentifier,e.response);let n=this.interactionElements.find(r=>r.getAttribute("response-identifier")===e.responseIdentifier);n&&(n.response=e.response)}}render(){return b`<slot></slot>`}connectedCallback(){this.#o(),super.connectedCallback(),this.updateComplete.then(()=>{this.validate(!1),Di(this,"cito-item-rendered",this),this.dispatchEvent(new CustomEvent("qti-assessment-item-connected",{bubbles:!0,composed:!0,detail:this})),this.#h()})}disconnectedCallback(){this.#s(),super.disconnectedCallback()}#o(){this.addEventListener("qti-register-variable",this.#a),this.addEventListener("qti-register-interaction",this.#c),this.addEventListener("end-attempt",this.#p),this.addEventListener("qti-set-outcome-value",this.#l),this.addEventListener("qti-set-template-value",this.#m),this.addEventListener("qti-set-correct-response",this.#d),this.addEventListener("qti-interaction-response",this.#u)}#s(){this.removeEventListener("qti-register-variable",this.#a),this.removeEventListener("qti-register-interaction",this.#c),this.removeEventListener("end-attempt",this.#p),this.removeEventListener("qti-set-outcome-value",this.#l),this.removeEventListener("qti-set-template-value",this.#m),this.removeEventListener("qti-set-correct-response",this.#d),this.removeEventListener("qti-interaction-response",this.#u)}#a;#c;#p;#l;#m;#d;#u;async#h(){let t=Array.from(this.querySelectorAll("qti-template-declaration"));t.length>0&&(await Promise.all(t.map(e=>e.updateComplete)),await Promise.resolve()),this.#e=this.querySelector("qti-template-processing"),this.#n=!0,this.#b()}#b(){this.#e&&(this.#e.process(),this.#i={...this._context,variables:this._context.variables})}processResponse(t=!0,e=!0){this.validate(e),t&&this.updateOutcomeVariable("numAttempts",(+this._context.variables.find(r=>r.identifier==="numAttempts")?.value+1).toString()),this.adaptive==="false"&&this.#v();let i=this.querySelector("qti-response-processing"),n=!!(i&&typeof i.process=="function");return n&&i.process(),this.adaptive==="false"&&this.updateOutcomeVariable("completionStatus",this.#g()),this.dispatchEvent(new CustomEvent("qti-item-context-updated",{bubbles:!0,composed:!0,detail:{itemContext:this._context,responseProcessed:!0}})),n}resetResponses(){this._context=this.#i}getResponse(t){return this.getVariable(t)}getOutcome(t){return this.getVariable(t)}getVariable(t){return this._context.variables.find(e=>e.identifier===t)||null}afterResponseVariableUpdated(){}updateResponseVariable(t,e){this._context={...this._context,variables:this._context.variables.map(i=>i.identifier!==t?i:{...i,value:e})},this.afterResponseVariableUpdated(),Di(this,"cito-item-response-changed",{item:this.identifier,responseIdentifier:t,response:Array.isArray(e)?[...e]:e}),this.adaptive==="false"&&this.updateOutcomeVariable("completionStatus",this.#g())}updateTemplateVariable(t,e){let i=this._context.variables.find(r=>r.identifier===t&&r.type==="template");if(!i){console.warn(`Can not set qti-template-identifier: ${t}, it is not available`);return}let n=i.cardinality==="single"?Array.isArray(e)?e[0]:e??null:e==null?null:Array.isArray(e)?e:[e];this._context={...this._context,variables:this._context.variables.map(r=>r.identifier!==t?r:{...r,value:n})},this.dispatchEvent(new CustomEvent("qti-item-context-updated",{bubbles:!0,composed:!0,detail:{itemContext:this._context}}))}updateCorrectResponse(t,e){let i=this.getResponse(t);if(!i){console.warn(`Can not set correct response for identifier: ${t}, it is not available`);return}let n=i.cardinality==="single"?Array.isArray(e)?e[0]:e??null:e==null?null:Array.isArray(e)?e:[e];this._context={...this._context,variables:this._context.variables.map(r=>r.identifier!==t?r:{...r,correctResponse:n})},this.dispatchEvent(new CustomEvent("qti-item-context-updated",{bubbles:!0,composed:!0,detail:{itemContext:this._context}}))}setOutcomeVariable(t,e){this.updateOutcomeVariable(t,e),this.dispatchEvent(new CustomEvent("qti-item-context-updated",{bubbles:!0,composed:!0,detail:{itemContext:this._context}}))}updateOutcomeVariable(t,e){let i=this.getOutcome(t);if(!i){console.warn(`Can not set qti-outcome-identifier: ${t}, it is not available`);return}this._context={...this._context,variables:this._context.variables.map(n=>n.identifier!==t?n:{...n,value:i.cardinality==="single"||Array.isArray(e)?e:[e]})},Di(this,"cito-item-outcome-changed",{item:this.identifier,outcomeIdentifier:t,value:this._context.variables.find(n=>n.identifier===t)?.value})}validate(t=!0){let e=this.interactionElements.every(i=>i.validate());return this.#f(e),t&&this.reportValidity(),e}#f(t){this._context.valid!==t&&(this._context={...this._context,valid:t})}#y(){let t=this._context.valid;this.validate(!1),this._context.valid!==t&&this.dispatchEvent(new CustomEvent("qti-item-context-updated",{bubbles:!0,composed:!0,detail:{itemContext:this._context}}))}reportValidity(){for(let t of this.interactionElements)t.reportValidity()}#g(){let t=this.validate(!1);return t===!0?"completed":t===!1?"incomplete":"not_attempted"}#v(){this._context={...this._context,variables:this._context.variables.map(t=>{if(t.type!=="outcome")return t;let n=("defaultValue"in t?t.defaultValue:null)??null;return n==null&&(t.baseType==="integer"||t.baseType==="float")&&(n="0"),{...t,value:n}})}}};ni([p({type:String})],ft.prototype,"identifier",void 0);ni([p({type:String})],ft.prototype,"adaptive",void 0);ni([p({type:String,attribute:"time-dependent"})],ft.prototype,"timeDependent",void 0);ni([p({type:String})],ft.prototype,"title",null);ni([p({type:Boolean})],ft.prototype,"disabled",void 0);ni([p({type:Boolean})],ft.prototype,"readonly",void 0);ni([U({context:F})],ft.prototype,"_context",void 0);var yd=q`
76
76
  :host {
77
77
  display: contents;
78
78
  }
@@ -80,11 +80,11 @@ Make sure to test your application with a production build as repeat registratio
80
80
  ::slotted(qti-catalog-info) {
81
81
  display: none;
82
82
  }
83
- `;var no=class extends C{static{this.styles=yd}connectedCallback(){super.connectedCallback(),this.removeAttribute("title")}render(){return b`<slot></slot>`}};function vd(o){o.querySelectorAll('qti-custom-operator[class="js.org"] > qti-base-value').forEach(e=>{let i=document.createComment(e.textContent);e.replaceChild(i,e.firstChild)})}async function wd(o,t,e,i="qti-portable-custom-interaction"){let n=[],r=o.querySelectorAll(i);if(r.length===0)return;let s=null,a=null,l=async()=>{if(s===null)try{s=await e(t,"/modules/module_resolution.js")}catch{s=null}if(a===null)try{a=await e(t,"/modules/fallback_module_resolution.js")}catch{a=null}};for(let c of Array.from(r)){c.setAttribute("data-base-url",t);let d=c.getAttribute("custom-interaction-type-identifier");d&&n.includes(d)&&(d=d+n.length,c.setAttribute("custom-interaction-type-identifier",d),n.push(d)),d&&n.push(d);let h=c.querySelector("qti-interaction-modules");if(h&&h.getAttribute("primary-configuration")){await l();let f=h.getAttribute("primary-configuration");if(f)try{let m=await e(t,`/${f}`),v=Array.from(h.querySelectorAll("qti-interaction-module"));for(let x of v){let u=x.getAttribute("id");if(u&&m.paths&&m.paths[u]){let g=m.paths[u],y=Array.isArray(g)?g[0]:g;if(x.setAttribute("primary-path",y),a&&a.paths&&a.paths[u]){let w=a.paths[u];Array.isArray(w)?x.setAttribute("fallback-path",w[0]):x.setAttribute("fallback-path",w)}}}if(m.paths){for(let x in m.paths)if(!h.querySelector(`qti-interaction-module[id="${x}"]`)){let g=o.createElement("qti-interaction-module");g.setAttribute("id",x);let y=Array.isArray(m.paths[x])?m.paths[x][0]:m.paths[x];if(g.setAttribute("primary-path",y),a&&a.paths&&a.paths[x]){let w=a.paths[x];Array.isArray(w)?g.setAttribute("fallback-path",w[0]):g.setAttribute("fallback-path",w)}h.appendChild(g)}}m.urlArgs&&h.setAttribute("url-args",m.urlArgs)}catch(m){console.warn(`Failed to load primary configuration: ${f}`,m)}}else if(await l(),s){c.querySelector("qti-interaction-modules")===null?(h=o.createElement("qti-interaction-modules"),c.appendChild(h)):h=c.querySelector("qti-interaction-modules");for(let f in s.paths){let m=s.paths[f],v="";a&&a.paths&&a.paths[f]&&(v=a.paths[f]);let x=Array.isArray(m)?m:[m],u=Array.isArray(v)?v:[v],g=x.map((y,w)=>{let I=u.length>w?u[w]:"";return{primaryPath:y,fallbackPath:I}});for(let y of u)g.some(w=>w.fallbackPath===y)||g.push({primaryPath:x.length>0?x[0]:y,fallbackPath:y});for(let y of g){let w=o.createElement("qti-interaction-module");y.fallbackPath&&w.setAttribute("fallback-path",y.fallbackPath),w.setAttribute("id",f),w.setAttribute("primary-path",y.primaryPath),h&&h.appendChild(w)}}}}}function xd(o,t,e){Array.from(o.getElementsByTagName("*")).filter(r=>r.localName===t||r.localName?.toLowerCase()===t.toLowerCase()).forEach(r=>{let s=`${t}-${e}`,a=Cd(r,s);r.replaceWith(a)})}function qd(o,t){o.querySelectorAll("*").forEach(e=>{let i=e.classList;i&&i.forEach(n=>{if(n.startsWith(`${t}:`)){let r=n.slice(`${t}:`.length),s=`${e.nodeName}-${r}`,a=Cd(e,s);e.replaceWith(a)}})})}function Cd(o,t){let e=o.ownerDocument.createElement(t);for(let i of o.attributes)e.setAttribute(i.name,i.value);for(;o.firstChild;)e.appendChild(o.firstChild);return e}function kd(o,t){let e=["hook","module"],i=t.substring(0,t.lastIndexOf("/"));for(let n of e)o.querySelectorAll("["+n+"]").forEach(s=>{let a=s.getAttribute(n);!a.startsWith("data:")&&!a.startsWith("http")&&(s.setAttribute("base-url",t),s.setAttribute("module",i+"/"+encodeURI(a+(a.endsWith(".js")?"":".js"))))})}var pl=class o{#t;constructor(t){if(!(t instanceof Uint8Array))throw new TypeError("SeededRandom seed must be a Uint8Array.");if(t.length>32)throw new RangeError("SeededRandom seed must be 32 bytes or less.");let e=new Uint8Array(32);e.set(t,32-t.length),this.#t=Gu(e)}static fromSeed(t){if(t.length!==32)throw new RangeError("SeededRandom.fromSeed requires a 32-byte seed.");return new o(t)}static fromFixed(t){if(typeof t!="number")throw new TypeError("SeededRandom.fromFixed requires a number.");if(!Number.isInteger(t)||t<0||t>255)throw new RangeError("SeededRandom.fromFixed requires an integer from 0 to 255.");let e=new Uint8Array(32);return e[31]=t,new o(e)}static fromSeedKey(t){let e=new o(new Uint8Array);return e.#t=Xu(`${t}`),e}random(){this.#t|=0,this.#t=this.#t+1831565813|0;let t=Math.imul(this.#t^this.#t>>>15,1|this.#t);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296}};function oo(o){return pl.fromSeedKey(o)}function Xu(o){let t=1779033703^o.length;for(let e=0;e<o.length;e++)t=Math.imul(t^o.charCodeAt(e),3432918353),t=t<<13|t>>>19;return Sd(t)}function Gu(o){let t=1779033703^o.length;for(let e=0;e<o.length;e++)t=Math.imul(t^o[e],3432918353),t=t<<13|t>>>19;return Sd(t)}function Sd(o){let t=Math.imul(o^o>>>16,2246822507);return t=Math.imul(t^t>>>13,3266489909),(t^t>>>16)>>>0}var Yu=o=>typeof o=="function"?o():o.random();function so(o,t){let e=o.filter(n=>!n.fixed);for(let n=e.length-1;n>0;n--){let r=Math.floor(Yu(t)*(n+1));[e[n],e[r]]=[e[r],e[n]]}let i=0;return o.map(n=>n.fixed?n:e[i++])}function Ju(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:return null}}function ul(o,t){let e=o.querySelectorAll('[shuffle="true"]'),i=Array.from(e).filter(a=>a.tagName?.toLowerCase().endsWith("-interaction")),n=t!=null&&`${t}`.length>0,r=o.querySelector?.("qti-assessment-item")?.getAttribute("identifier")??"",s=0;for(let a of i){let l=a.getAttribute("response-identifier")??`${s}`;s++;let c=Ju(a.tagName.toLowerCase()),d=Array.isArray(c)?c:[c],h=!1,f=0;for(let m of d){if(!m)continue;let v=n?oo(`${t}:${r}:${l}:${f}`):Math.random;f++;let x=Array.from(a.querySelectorAll(m)).filter(w=>w.parentElement!==null);if(x.filter(w=>w.getAttribute("fixed")!=="true").length<=1){console.warn("Shuffling is not possible with fewer than 2 non-fixed elements.");continue}let u=x[0].parentElement;if(!u||x.some(w=>w.parentElement!==u)){console.warn("Shuffling is not possible when choices do not share the same parent element.");continue}let g=x[x.length-1].nextSibling,y=so(x.map(w=>({element:w,fixed:w.getAttribute("fixed")==="true"})),v);for(let w of x)w.remove();for(let{element:w}of y)u.insertBefore(w,g);h=!0}h&&a.removeAttribute("shuffle")}}function Ed(o){o.querySelectorAll("qti-stylesheet").forEach(t=>t.remove())}var Ad=!1;function ao(o,t){Ad||(Ad=!0,console.warn(`[${o}] No QTI_CONTEXT.seed provided; using "${t}" as deterministic fallback seed.`))}function Ku(o){return(o.textContent||"").replace(/\s+/g," ").trim().replace(/^This page contains the following errors:\s*/i,"").replace(/\s*Below is a rendering of the page up to the first error\.?\s*$/i,"").trim()||"malformed XML"}function Id(o,t){let i=new DOMParser().parseFromString(o.replace(/^[\s\uFEFF]+/,""),"text/xml"),n=i.getElementsByTagNameNS("http://www.w3.org/1999/xhtml","parsererror")[0]??i.getElementsByTagNameNS("http://www.mozilla.org/newlayout/xml/parsererror.xml","parsererror")[0];if(n)throw new Error(t(Ku(n)));return i}function Li(o,t){return fetch(o,{signal:t}).then(e=>{if(!e.ok)throw new Error(`HTTP error! status: ${e.status}`);return e.text()}).then(e=>Id(e,i=>`is not well-formed XML: ${i}`)).catch(e=>{throw e.name==="AbortError"?e:new Error(`Failed to load XML: ${e.message}`)})}function Vi(o){return Id(o,t=>`Failed to parse XML: ${t}`)}function _d(o,t,e){if(o.nodeType===Node.ELEMENT_NODE){let i=o,n;!i.namespaceURI||i.namespaceURI.startsWith("http://www.imsglobal.org/xsd/qti/")||i.namespaceURI.startsWith("http://www.imsglobal.org/xsd/imsqti")?n=e?t.createElement(i.localName,{customElementRegistry:e}):t.createElement(i.localName):n=t.createElementNS(i.namespaceURI,i.tagName);for(let r=0;r<i.attributes.length;r++){let s=i.attributes[r];n.setAttribute(s.localName,s.value)}for(let r=0;r<i.childNodes.length;r++)n.appendChild(_d(i.childNodes[r],t,e));return n}return o.cloneNode(!1)}function zi(o,t){let e=document.createDocumentFragment();for(let i=0;i<o.childNodes.length;i++)e.appendChild(_d(o.childNodes[i],document,t));return e}function ji(o,t){t.endsWith("/")||(t+="/"),o.querySelectorAll("*").forEach(i=>{for(let n of["src","href","srcset","poster"]){let r=i.getAttribute(n)?.trim();if(r&&!/^(data:|https?:|blob:)/.test(r)){let s=t+encodeURI(r);i.setAttribute(n,s)}}})}var Gt=()=>{let o,t="",e={load(i,n){return t=i,Li(i,n).then(r=>(o=r,e))},parse(i){return o=Vi(i),t="",e},path:i=>(ji(o,i),t=null,e),fn(i){return i(o),e},pciHooks(i){return kd(o,i),e},async configurePci(i,n,r="qti-portable-custom-interaction"){return await wd(o,i,n,r),e},shuffleInteractions(i){let n=typeof i=="string"?i.trim():i;if(n==null||n===""){let r=t||"default-item-seed";return ao("qtiTransformItem",r),ul(o,r),e}return ul(o,n),e},extendElementName:(i,n)=>(xd(o,i,n),e),extendElementsWithClass:(i="extend")=>(qd(o,i),e),customInteraction(i,n){let r=o.querySelector("qti-custom-interaction"),s=r.querySelector("object");return r.setAttribute("data-base-ref",i),r.setAttribute("data-base-item",i+n),r.setAttribute("data",s.getAttribute("data")),r.setAttribute("width",s.getAttribute("width")),r.setAttribute("height",s.getAttribute("height")),r.removeChild(s),e},convertCDATAtoComment(){return vd(o),e},stripStyleSheets(){return Ed(o),e},html(){return t!==null&&ji(o,t.substring(0,t.lastIndexOf("/"))),new XMLSerializer().serializeToString(zi(o))},xml(){return new XMLSerializer().serializeToString(o)},htmlDoc(i){return t!==null&&ji(o,t.substring(0,t.lastIndexOf("/"))),zi(o,i)},xmlDoc(){return o}};return e};var Td=()=>{let o,t={async load(e,i){return o=await Li(e,i),t},parse(e){o=Vi(e)},assessmentTest(){let e=o.querySelector('resource[type="imsqti_test_xmlv3p0"]');return{href:e.getAttribute("href"),identifier:e.getAttribute("identifier")}}};return t};function Rd(o){let t=[];return o.querySelectorAll("qti-assessment-item-ref").forEach(e=>{let i=e.getAttribute("identifier"),n=e.getAttribute("href"),r=e.getAttribute("category");t.push({identifier:i,href:n,category:r})}),t}var lo=(o,...t)=>t.includes(o.localName)||t.includes(o.localName?.toLowerCase?.()),Pd=o=>lo(o,"qti-assessment-item-ref","assessmentitemref"),Br=o=>lo(o,"qti-assessment-section","assessmentsection"),Fr=(o,...t)=>t.some(e=>{let i=(o.getAttribute(e)??"").trim().toLowerCase();return i==="true"||i==="1"}),Zu=(o,...t)=>t.some(e=>{let i=(o.getAttribute(e)??"").trim().toLowerCase();return i==="false"||i==="0"}),ml=o=>lo(o,"qti-ordering","ordering"),tm=o=>lo(o,"qti-selection","selection"),em=o=>Array.from(o.children).filter(t=>ml(t)&&Fr(t,"shuffle")),im=(o,t)=>oo(`${o}:${t}`);function rm(o){let t=[],e=[],i=n=>{for(let r of Array.from(n.children))Pd(r)?t.push(r):Br(r)?i(r):!ml(r)&&!tm(r)&&e.push(r.localName)};return i(o),{itemRefs:t,dropped:e}}function nm(o,t){if(t.length===0)return;let e=o.getAttribute("identifier")??"(no identifier)";console.warn(`[qtiTransformTest] Subsection "${e}" is consumed by section ordering; discarding its ${[...new Set(t)].join(", ")}.`)}function Od(o,t){for(let l of Array.from(o.children))Br(l)&&Od(l,t);let e=em(o);if(e.length===0)return;let i=[],n=[];for(let l of Array.from(o.children))if(Pd(l))i.push({nodes:[l],fixed:Fr(l,"fixed")}),n.push(l);else if(Br(l)){let{itemRefs:c,dropped:d}=rm(l);if(nm(l,d),Zu(l,"keep-together","keeptogether"))for(let h of c)i.push({nodes:[h],fixed:Fr(h,"fixed")});else c.length>0&&i.push({nodes:c,fixed:Fr(l,"fixed")});n.push(l)}let r=n.length>0?n[n.length-1].nextSibling:null,s=o.getAttribute("identifier")??"",a=so(i,im(t,s));for(let l of n)l.remove();for(let l of a)for(let c of l.nodes)o.insertBefore(c,r);for(let l of e)l.remove()}function Md(o){return Array.from(o.getElementsByTagName("*")).some(t=>ml(t)&&Fr(t,"shuffle"))}function fl(o,t){let e=Array.from(o.getElementsByTagName("*")).filter(i=>Br(i));for(let i of e){if(!i.parentNode)continue;let n=i.parentElement;n&&Br(n)||Od(i,t)}}var Fi=()=>{let o,t="",e={async load(i,n){return o=await Li(i,n),t=i,e.path(i.substring(0,i.lastIndexOf("/"))),e},parse(i){return o=Vi(i),t="",e},path:i=>(ji(o,i),e),fn(i){return i(o),e},shuffleOrdering(i){if(!Md(o))return e;let n=typeof i=="string"?i.trim():i;if(n==null||n===""){let r=t||"default-test-seed";return ao("qtiTransformTest",r),fl(o,r),e}return fl(o,n),e},items(){return Rd(o)},html(){return new XMLSerializer().serializeToString(zi(o))},xml(){return new XMLSerializer().serializeToString(o)},htmlDoc(i){return zi(o,i)},xmlDoc(){return o}};return e};var Dd=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},gl=class o extends Event{static{this.eventName="qti-assessment-stimulus-ref-connected"}constructor(t,e){super(o.eventName,{bubbles:!0,composed:!0,cancelable:!0}),this.element=t,this.item=e}},Bi=class extends C{constructor(){super(...arguments),this.identifier="",this.href=""}async connectedCallback(){super.connectedCallback(),await this.updateComplete;let t=this.closest("qti-assessment-item"),e=new gl(this,t);this.dispatchEvent(e);let i=t?.querySelector(`[data-stimulus-idref="${this.identifier}"]`);!e.defaultPrevented&&i&&await this.updateStimulusRef(i)}async updateStimulusRef(t){let i=(await Gt().load(this.href).then(n=>n.htmlDoc()))?.querySelector("qti-assessment-stimulus");i&&(t.innerHTML="",t.append(i))}};Dd([p({type:String})],Bi.prototype,"identifier",void 0);Dd([p({type:String})],Bi.prototype,"href",void 0);var co=class extends C{};var om=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},Ur=class extends C{render(){return b`<slot @slotchange=${this.#t}></slot>`}connectedCallback(){super.connectedCallback(),this.updateComplete.then(()=>this.#t())}updated(t){t.has("context")&&this.#t()}#t(){let t=new Map,e=(this.context?.variables??[]).filter(n=>n.type==="template");for(let n of e){let r=n;r.mathVariable!==!0||r.value===null||r.value===void 0||t.set(r.identifier,this.#e(r.value))}if(t.size===0)return;let i=Array.from(this.querySelectorAll("*")).filter(n=>n.localName.toLowerCase()==="mi"||n.localName.toLowerCase()==="mn");for(let n of i){let r=n.getAttribute("data-qti-math-variable-source")??n.textContent?.trim()??"",s=t.get(r);if(!s)continue;if(n.localName.toLowerCase()==="mn"){n.textContent=s,n.setAttribute("data-qti-math-variable-source",r);continue}let a=document.createElement("mn");a.textContent=s,a.setAttribute("data-qti-math-variable-source",r),n.replaceWith(a)}}#e(t){return Array.isArray(t)?t.join(" "):t?.toString()??""}};om([_({context:F,subscribe:!0}),T()],Ur.prototype,"context",void 0);var Nd=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},Ui=class extends C{constructor(){super(...arguments),this.identifier="",this.cardinality="record"}static{this.styles=[q`
83
+ `;var no=class extends C{static{this.styles=yd}connectedCallback(){super.connectedCallback(),this.removeAttribute("title")}render(){return b`<slot></slot>`}};function vd(o){o.querySelectorAll('qti-custom-operator[class="js.org"] > qti-base-value').forEach(e=>{let i=document.createComment(e.textContent);e.replaceChild(i,e.firstChild)})}async function wd(o,t,e,i="qti-portable-custom-interaction"){let n=[],r=o.querySelectorAll(i);if(r.length===0)return;let s=null,a=null,l=async()=>{if(s===null)try{s=await e(t,"/modules/module_resolution.js")}catch{s=null}if(a===null)try{a=await e(t,"/modules/fallback_module_resolution.js")}catch{a=null}};for(let c of Array.from(r)){c.setAttribute("data-base-url",t);let d=c.getAttribute("custom-interaction-type-identifier");d&&n.includes(d)&&(d=d+n.length,c.setAttribute("custom-interaction-type-identifier",d),n.push(d)),d&&n.push(d);let h=c.querySelector("qti-interaction-modules");if(h&&h.getAttribute("primary-configuration")){await l();let f=h.getAttribute("primary-configuration");if(f)try{let m=await e(t,`/${f}`),v=Array.from(h.querySelectorAll("qti-interaction-module"));for(let x of v){let u=x.getAttribute("id");if(u&&m.paths&&m.paths[u]){let g=m.paths[u],y=Array.isArray(g)?g[0]:g;if(x.setAttribute("primary-path",y),a&&a.paths&&a.paths[u]){let w=a.paths[u];Array.isArray(w)?x.setAttribute("fallback-path",w[0]):x.setAttribute("fallback-path",w)}}}if(m.paths){for(let x in m.paths)if(!h.querySelector(`qti-interaction-module[id="${x}"]`)){let g=o.createElement("qti-interaction-module");g.setAttribute("id",x);let y=Array.isArray(m.paths[x])?m.paths[x][0]:m.paths[x];if(g.setAttribute("primary-path",y),a&&a.paths&&a.paths[x]){let w=a.paths[x];Array.isArray(w)?g.setAttribute("fallback-path",w[0]):g.setAttribute("fallback-path",w)}h.appendChild(g)}}m.urlArgs&&h.setAttribute("url-args",m.urlArgs)}catch(m){console.warn(`Failed to load primary configuration: ${f}`,m)}}else if(await l(),s){c.querySelector("qti-interaction-modules")===null?(h=o.createElement("qti-interaction-modules"),c.appendChild(h)):h=c.querySelector("qti-interaction-modules");for(let f in s.paths){let m=s.paths[f],v="";a&&a.paths&&a.paths[f]&&(v=a.paths[f]);let x=Array.isArray(m)?m:[m],u=Array.isArray(v)?v:[v],g=x.map((y,w)=>{let I=u.length>w?u[w]:"";return{primaryPath:y,fallbackPath:I}});for(let y of u)g.some(w=>w.fallbackPath===y)||g.push({primaryPath:x.length>0?x[0]:y,fallbackPath:y});for(let y of g){let w=o.createElement("qti-interaction-module");y.fallbackPath&&w.setAttribute("fallback-path",y.fallbackPath),w.setAttribute("id",f),w.setAttribute("primary-path",y.primaryPath),h&&h.appendChild(w)}}}}}function xd(o,t,e){Array.from(o.getElementsByTagName("*")).filter(r=>r.localName===t||r.localName?.toLowerCase()===t.toLowerCase()).forEach(r=>{let s=`${t}-${e}`,a=Cd(r,s);r.replaceWith(a)})}function qd(o,t){o.querySelectorAll("*").forEach(e=>{let i=e.classList;i&&i.forEach(n=>{if(n.startsWith(`${t}:`)){let r=n.slice(`${t}:`.length),s=`${e.nodeName}-${r}`,a=Cd(e,s);e.replaceWith(a)}})})}function Cd(o,t){let e=o.ownerDocument.createElement(t);for(let i of o.attributes)e.setAttribute(i.name,i.value);for(;o.firstChild;)e.appendChild(o.firstChild);return e}function Sd(o,t){let e=["hook","module"],i=t.substring(0,t.lastIndexOf("/"));for(let n of e)o.querySelectorAll("["+n+"]").forEach(s=>{let a=s.getAttribute(n);!a.startsWith("data:")&&!a.startsWith("http")&&(s.setAttribute("base-url",t),s.setAttribute("module",i+"/"+encodeURI(a+(a.endsWith(".js")?"":".js"))))})}var pl=class o{#t;constructor(t){if(!(t instanceof Uint8Array))throw new TypeError("SeededRandom seed must be a Uint8Array.");if(t.length>32)throw new RangeError("SeededRandom seed must be 32 bytes or less.");let e=new Uint8Array(32);e.set(t,32-t.length),this.#t=Xu(e)}static fromSeed(t){if(t.length!==32)throw new RangeError("SeededRandom.fromSeed requires a 32-byte seed.");return new o(t)}static fromFixed(t){if(typeof t!="number")throw new TypeError("SeededRandom.fromFixed requires a number.");if(!Number.isInteger(t)||t<0||t>255)throw new RangeError("SeededRandom.fromFixed requires an integer from 0 to 255.");let e=new Uint8Array(32);return e[31]=t,new o(e)}static fromSeedKey(t){let e=new o(new Uint8Array);return e.#t=Gu(`${t}`),e}random(){this.#t|=0,this.#t=this.#t+1831565813|0;let t=Math.imul(this.#t^this.#t>>>15,1|this.#t);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296}};function oo(o){return pl.fromSeedKey(o)}function Gu(o){let t=1779033703^o.length;for(let e=0;e<o.length;e++)t=Math.imul(t^o.charCodeAt(e),3432918353),t=t<<13|t>>>19;return kd(t)}function Xu(o){let t=1779033703^o.length;for(let e=0;e<o.length;e++)t=Math.imul(t^o[e],3432918353),t=t<<13|t>>>19;return kd(t)}function kd(o){let t=Math.imul(o^o>>>16,2246822507);return t=Math.imul(t^t>>>13,3266489909),(t^t>>>16)>>>0}var Yu=o=>typeof o=="function"?o():o.random();function so(o,t){let e=o.filter(n=>!n.fixed);for(let n=e.length-1;n>0;n--){let r=Math.floor(Yu(t)*(n+1));[e[n],e[r]]=[e[r],e[n]]}let i=0;return o.map(n=>n.fixed?n:e[i++])}function Ju(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:return null}}function ul(o,t){let e=o.querySelectorAll('[shuffle="true"]'),i=Array.from(e).filter(a=>a.tagName?.toLowerCase().endsWith("-interaction")),n=t!=null&&`${t}`.length>0,r=o.querySelector?.("qti-assessment-item")?.getAttribute("identifier")??"",s=0;for(let a of i){let l=a.getAttribute("response-identifier")??`${s}`;s++;let c=Ju(a.tagName.toLowerCase()),d=Array.isArray(c)?c:[c],h=!1,f=0;for(let m of d){if(!m)continue;let v=n?oo(`${t}:${r}:${l}:${f}`):Math.random;f++;let x=Array.from(a.querySelectorAll(m)).filter(w=>w.parentElement!==null);if(x.filter(w=>w.getAttribute("fixed")!=="true").length<=1){console.warn("Shuffling is not possible with fewer than 2 non-fixed elements.");continue}let u=x[0].parentElement;if(!u||x.some(w=>w.parentElement!==u)){console.warn("Shuffling is not possible when choices do not share the same parent element.");continue}let g=x[x.length-1].nextSibling,y=so(x.map(w=>({element:w,fixed:w.getAttribute("fixed")==="true"})),v);for(let w of x)w.remove();for(let{element:w}of y)u.insertBefore(w,g);h=!0}h&&a.removeAttribute("shuffle")}}function Ed(o){o.querySelectorAll("qti-stylesheet").forEach(t=>t.remove())}var Ad=!1;function ao(o,t){Ad||(Ad=!0,console.warn(`[${o}] No QTI_CONTEXT.seed provided; using "${t}" as deterministic fallback seed.`))}function Ku(o){return(o.textContent||"").replace(/\s+/g," ").trim().replace(/^This page contains the following errors:\s*/i,"").replace(/\s*Below is a rendering of the page up to the first error\.?\s*$/i,"").trim()||"malformed XML"}function Id(o,t){let i=new DOMParser().parseFromString(o.replace(/^[\s\uFEFF]+/,""),"text/xml"),n=i.getElementsByTagNameNS("http://www.w3.org/1999/xhtml","parsererror")[0]??i.getElementsByTagNameNS("http://www.mozilla.org/newlayout/xml/parsererror.xml","parsererror")[0];if(n)throw new Error(t(Ku(n)));return i}function Vi(o,t){return fetch(o,{signal:t}).then(e=>{if(!e.ok)throw new Error(`HTTP error! status: ${e.status}`);return e.text()}).then(e=>Id(e,i=>`is not well-formed XML: ${i}`)).catch(e=>{throw e.name==="AbortError"?e:new Error(`Failed to load XML: ${e.message}`)})}function zi(o){return Id(o,t=>`Failed to parse XML: ${t}`)}function _d(o,t,e){if(o.nodeType===Node.ELEMENT_NODE){let i=o,n;!i.namespaceURI||i.namespaceURI.startsWith("http://www.imsglobal.org/xsd/qti/")||i.namespaceURI.startsWith("http://www.imsglobal.org/xsd/imsqti")?n=e?t.createElement(i.localName,{customElementRegistry:e}):t.createElement(i.localName):n=t.createElementNS(i.namespaceURI,i.tagName);for(let r=0;r<i.attributes.length;r++){let s=i.attributes[r];n.setAttribute(s.localName,s.value)}for(let r=0;r<i.childNodes.length;r++)n.appendChild(_d(i.childNodes[r],t,e));return n}return o.cloneNode(!1)}function ji(o,t){let e=document.createDocumentFragment();for(let i=0;i<o.childNodes.length;i++)e.appendChild(_d(o.childNodes[i],document,t));return e}function Fi(o,t){t.endsWith("/")||(t+="/"),o.querySelectorAll("*").forEach(i=>{for(let n of["src","href","srcset","poster"]){let r=i.getAttribute(n)?.trim();if(r&&!/^(data:|https?:|blob:)/.test(r)){let s=t+encodeURI(r);i.setAttribute(n,s)}}})}var Xt=()=>{let o,t="",e={load(i,n){return t=i,Vi(i,n).then(r=>(o=r,e))},parse(i){return o=zi(i),t="",e},path:i=>(Fi(o,i),t=null,e),fn(i){return i(o),e},pciHooks(i){return Sd(o,i),e},async configurePci(i,n,r="qti-portable-custom-interaction"){return await wd(o,i,n,r),e},shuffleInteractions(i){let n=typeof i=="string"?i.trim():i;if(n==null||n===""){let r=t||"default-item-seed";return ao("qtiTransformItem",r),ul(o,r),e}return ul(o,n),e},extendElementName:(i,n)=>(xd(o,i,n),e),extendElementsWithClass:(i="extend")=>(qd(o,i),e),customInteraction(i,n){let r=o.querySelector("qti-custom-interaction"),s=r.querySelector("object");return r.setAttribute("data-base-ref",i),r.setAttribute("data-base-item",i+n),r.setAttribute("data",s.getAttribute("data")),r.setAttribute("width",s.getAttribute("width")),r.setAttribute("height",s.getAttribute("height")),r.removeChild(s),e},convertCDATAtoComment(){return vd(o),e},stripStyleSheets(){return Ed(o),e},html(){return t!==null&&Fi(o,t.substring(0,t.lastIndexOf("/"))),new XMLSerializer().serializeToString(ji(o))},xml(){return new XMLSerializer().serializeToString(o)},htmlDoc(i){return t!==null&&Fi(o,t.substring(0,t.lastIndexOf("/"))),ji(o,i)},xmlDoc(){return o}};return e};var Td=()=>{let o,t={async load(e,i){return o=await Vi(e,i),t},parse(e){o=zi(e)},assessmentTest(){let e=o.querySelector('resource[type="imsqti_test_xmlv3p0"]');return{href:e.getAttribute("href"),identifier:e.getAttribute("identifier")}}};return t};function Rd(o){let t=[];return o.querySelectorAll("qti-assessment-item-ref").forEach(e=>{let i=e.getAttribute("identifier"),n=e.getAttribute("href"),r=e.getAttribute("category");t.push({identifier:i,href:n,category:r})}),t}var lo=(o,...t)=>t.includes(o.localName)||t.includes(o.localName?.toLowerCase?.()),Pd=o=>lo(o,"qti-assessment-item-ref","assessmentitemref"),Br=o=>lo(o,"qti-assessment-section","assessmentsection"),Fr=(o,...t)=>t.some(e=>{let i=(o.getAttribute(e)??"").trim().toLowerCase();return i==="true"||i==="1"}),Zu=(o,...t)=>t.some(e=>{let i=(o.getAttribute(e)??"").trim().toLowerCase();return i==="false"||i==="0"}),ml=o=>lo(o,"qti-ordering","ordering"),tm=o=>lo(o,"qti-selection","selection"),em=o=>Array.from(o.children).filter(t=>ml(t)&&Fr(t,"shuffle")),im=(o,t)=>oo(`${o}:${t}`);function rm(o){let t=[],e=[],i=n=>{for(let r of Array.from(n.children))Pd(r)?t.push(r):Br(r)?i(r):!ml(r)&&!tm(r)&&e.push(r.localName)};return i(o),{itemRefs:t,dropped:e}}function nm(o,t){if(t.length===0)return;let e=o.getAttribute("identifier")??"(no identifier)";console.warn(`[qtiTransformTest] Subsection "${e}" is consumed by section ordering; discarding its ${[...new Set(t)].join(", ")}.`)}function Od(o,t){for(let l of Array.from(o.children))Br(l)&&Od(l,t);let e=em(o);if(e.length===0)return;let i=[],n=[];for(let l of Array.from(o.children))if(Pd(l))i.push({nodes:[l],fixed:Fr(l,"fixed")}),n.push(l);else if(Br(l)){let{itemRefs:c,dropped:d}=rm(l);if(nm(l,d),Zu(l,"keep-together","keeptogether"))for(let h of c)i.push({nodes:[h],fixed:Fr(h,"fixed")});else c.length>0&&i.push({nodes:c,fixed:Fr(l,"fixed")});n.push(l)}let r=n.length>0?n[n.length-1].nextSibling:null,s=o.getAttribute("identifier")??"",a=so(i,im(t,s));for(let l of n)l.remove();for(let l of a)for(let c of l.nodes)o.insertBefore(c,r);for(let l of e)l.remove()}function Md(o){return Array.from(o.getElementsByTagName("*")).some(t=>ml(t)&&Fr(t,"shuffle"))}function fl(o,t){let e=Array.from(o.getElementsByTagName("*")).filter(i=>Br(i));for(let i of e){if(!i.parentNode)continue;let n=i.parentElement;n&&Br(n)||Od(i,t)}}var Bi=()=>{let o,t="",e={async load(i,n){return o=await Vi(i,n),t=i,e.path(i.substring(0,i.lastIndexOf("/"))),e},parse(i){return o=zi(i),t="",e},path:i=>(Fi(o,i),e),fn(i){return i(o),e},shuffleOrdering(i){if(!Md(o))return e;let n=typeof i=="string"?i.trim():i;if(n==null||n===""){let r=t||"default-test-seed";return ao("qtiTransformTest",r),fl(o,r),e}return fl(o,n),e},items(){return Rd(o)},html(){return new XMLSerializer().serializeToString(ji(o))},xml(){return new XMLSerializer().serializeToString(o)},htmlDoc(i){return ji(o,i)},xmlDoc(){return o}};return e};var Dd=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},gl=class o extends Event{static{this.eventName="qti-assessment-stimulus-ref-connected"}constructor(t,e){super(o.eventName,{bubbles:!0,composed:!0,cancelable:!0}),this.element=t,this.item=e}},Ui=class extends C{constructor(){super(...arguments),this.identifier="",this.href=""}async connectedCallback(){super.connectedCallback(),await this.updateComplete;let t=this.closest("qti-assessment-item"),e=new gl(this,t);this.dispatchEvent(e);let i=t?.querySelector(`[data-stimulus-idref="${this.identifier}"]`);!e.defaultPrevented&&i&&await this.updateStimulusRef(i)}async updateStimulusRef(t){let i=(await Xt().load(this.href).then(n=>n.htmlDoc()))?.querySelector("qti-assessment-stimulus");i&&(t.innerHTML="",t.append(i))}};Dd([p({type:String})],Ui.prototype,"identifier",void 0);Dd([p({type:String})],Ui.prototype,"href",void 0);var co=class extends C{};var om=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},Ur=class extends C{render(){return b`<slot @slotchange=${this.#t}></slot>`}connectedCallback(){super.connectedCallback(),this.updateComplete.then(()=>this.#t())}updated(t){t.has("context")&&this.#t()}#t(){let t=new Map,e=(this.context?.variables??[]).filter(n=>n.type==="template");for(let n of e){let r=n;r.mathVariable!==!0||r.value===null||r.value===void 0||t.set(r.identifier,this.#e(r.value))}if(t.size===0)return;let i=Array.from(this.querySelectorAll("*")).filter(n=>n.localName.toLowerCase()==="mi"||n.localName.toLowerCase()==="mn");for(let n of i){let r=n.getAttribute("data-qti-math-variable-source")??n.textContent?.trim()??"",s=t.get(r);if(!s)continue;if(n.localName.toLowerCase()==="mn"){n.textContent=s,n.setAttribute("data-qti-math-variable-source",r);continue}let a=document.createElement("mn");a.textContent=s,a.setAttribute("data-qti-math-variable-source",r),n.replaceWith(a)}}#e(t){return Array.isArray(t)?t.join(" "):t?.toString()??""}};om([_({context:F,subscribe:!0}),T()],Ur.prototype,"context",void 0);var Nd=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},Hi=class extends C{constructor(){super(...arguments),this.identifier="",this.cardinality="record"}static{this.styles=[q`
84
84
  :host {
85
85
  display: none;
86
86
  }
87
- `]}render(){return b`<slot></slot>`}};Nd([p({type:String})],Ui.prototype,"identifier",void 0);Nd([p({type:String})],Ui.prototype,"cardinality",void 0);var sm=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},Hr=class extends C{#t;render(){return b`<slot @slotchange=${this.handleSlotChange}></slot>`}handleSlotChange(){let t=Array.from(this.firstElementChild?.childNodes??[]).find(e=>e.nodeType===Node.COMMENT_NODE);try{this.#t=new Function("context","fn","item",t?.textContent??"")}catch(e){console.error("custom-operator contains invalid javascript code",e)}}calculate(){let t=this.getAttribute("definition");if(t)return this.#e(t);let e={variable:n=>this._context?.variables.find(r=>r.identifier===n)?.value??"",correct:n=>this._context?.variables.find(r=>r.identifier===n)?.correctResponse??""},i={getVariable:n=>this._context?.variables.find(r=>r.identifier===n),updateOutcomeVariable:(n,r)=>{this.dispatchEvent(new CustomEvent("qti-set-outcome-value",{bubbles:!0,composed:!0,detail:{outcomeIdentifier:n,value:r}}))},updateResponseVariable:(n,r)=>{this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,composed:!0,detail:{responseIdentifier:n,response:r}}))}};return this.#t(this._context,e,i)}#e(t){let e=hd(t);if(!e)return console.warn(`qti-custom-operator: no operator registered for definition "${t}"`),null;let i=Array.from(this.children).map(n=>{let r=n.calculate;return typeof r=="function"?r.call(n):null});return e(i)}};sm([_({context:F,subscribe:!0}),T()],Hr.prototype,"_context",void 0);var ho=class extends mt{static{this.styles=q`
87
+ `]}render(){return b`<slot></slot>`}};Nd([p({type:String})],Hi.prototype,"identifier",void 0);Nd([p({type:String})],Hi.prototype,"cardinality",void 0);var sm=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},Hr=class extends C{#t;render(){return b`<slot @slotchange=${this.handleSlotChange}></slot>`}handleSlotChange(){let t=Array.from(this.firstElementChild?.childNodes??[]).find(e=>e.nodeType===Node.COMMENT_NODE);try{this.#t=new Function("context","fn","item",t?.textContent??"")}catch(e){console.error("custom-operator contains invalid javascript code",e)}}calculate(){let t=this.getAttribute("definition");if(t)return this.#e(t);let e={variable:n=>this._context?.variables.find(r=>r.identifier===n)?.value??"",correct:n=>this._context?.variables.find(r=>r.identifier===n)?.correctResponse??""},i={getVariable:n=>this._context?.variables.find(r=>r.identifier===n),updateOutcomeVariable:(n,r)=>{this.dispatchEvent(new CustomEvent("qti-set-outcome-value",{bubbles:!0,composed:!0,detail:{outcomeIdentifier:n,value:r}}))},updateResponseVariable:(n,r)=>{this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,composed:!0,detail:{responseIdentifier:n,response:r}}))}};return this.#t(this._context,e,i)}#e(t){let e=hd(t);if(!e)return console.warn(`qti-custom-operator: no operator registered for definition "${t}"`),null;let i=Array.from(this.children).map(n=>{let r=n.calculate;return typeof r=="function"?r.call(n):null});return e(i)}};sm([_({context:F,subscribe:!0}),T()],Hr.prototype,"_context",void 0);var ho=class extends mt{static{this.styles=q`
88
88
  :host {
89
89
  display: block;
90
90
  }
@@ -105,7 +105,7 @@ Make sure to test your application with a production build as repeat registratio
105
105
  :host {
106
106
  display: block;
107
107
  }
108
- `;var uo=class extends C{static{this.styles=$d}render(){return b`<slot part="qti-rubric-blocks" name="qti-rubric-block"></slot><slot></slot>`}};var Hi=class extends mt{static{this.styles=q`
108
+ `;var uo=class extends C{static{this.styles=$d}render(){return b`<slot part="qti-rubric-blocks" name="qti-rubric-block"></slot><slot></slot>`}};var Wi=class extends mt{static{this.styles=q`
109
109
  .cito-dialog {
110
110
  background: var(--qti-bg);
111
111
  border: var(--qti-border-thickness) var(--qti-border-style) var(--qti-border-color);
@@ -150,11 +150,11 @@ Make sure to test your application with a production build as repeat registratio
150
150
  <button class="button close-button" @click="${this.closeFeedback}">Close</button>
151
151
  </div>
152
152
  </dialog>
153
- `}openFeedback(){let t=this.shadowRoot?.querySelector("dialog");t&&!t.open&&t.showModal()}closeFeedback(){let t=this.shadowRoot?.querySelector("dialog");t&&t.open&&(t.close(),this.showStatus="off")}connectedCallback(){super.connectedCallback(),this.showStatus==="on"&&this.openFeedback()}updated(t){t.has("showStatus")&&(this.showStatus==="on"?this.openFeedback():this.closeFeedback())}};var Wr=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},ae=class extends Ri{constructor(){super(...arguments),this.externalScored=null}static{this.styles=[q`
153
+ `}openFeedback(){let t=this.shadowRoot?.querySelector("dialog");t&&!t.open&&t.showModal()}closeFeedback(){let t=this.shadowRoot?.querySelector("dialog");t&&t.open&&(t.close(),this.showStatus="off")}connectedCallback(){super.connectedCallback(),this.showStatus==="on"&&this.openFeedback()}updated(t){t.has("showStatus")&&(this.showStatus==="on"?this.openFeedback():this.closeFeedback())}};var Wr=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},ae=class extends Pi{constructor(){super(...arguments),this.externalScored=null}static{this.styles=[q`
154
154
  :host {
155
155
  display: none;
156
156
  }
157
- `]}render(){let t=this.itemContext?.variables.find(e=>e.identifier===this.identifier)?.value;return b`${JSON.stringify(t,null,2)}`}get interpolationTable(){let t=this.querySelector("qti-interpolation-table");if(!t)return null;let e=[];for(let i of t.querySelectorAll("qti-interpolation-table-entry")){let n=parseFloat(i.getAttribute("source-value")),r=parseFloat(i.getAttribute("target-value"));if(Number.isNaN(n)||Number.isNaN(r)){console.error("source-value or target-value is missing or not a number in qti-interpolation-table-entry");continue}e.push({sourceValue:n,targetValue:r,includeBoundary:i.getAttribute("include-boundary")!=="false"})}return e}get matchTable(){let t=this.querySelector("qti-match-table");if(!t)return null;let e=new Map;for(let i of t.querySelectorAll("qti-match-table-entry")){let n=parseFloat(i.getAttribute("source-value")),r=i.getAttribute("target-value");if(Number.isNaN(n)||r===null){console.error("source-value or target-value is missing or invalid in qti-match-table-entry");continue}e.set(n,r)}return e}connectedCallback(){super.connectedCallback();let t=this.defaultValues(this.cardinality),e={identifier:this.identifier,cardinality:this.cardinality,baseType:this.baseType,defaultValue:t,type:"outcome",value:null,interpolationTable:this.interpolationTable,matchTable:this.matchTable,externalScored:this.externalScored};e.value=t,(e.value===null||e.value==null)&&(e.baseType==="integer"||e.baseType==="float")&&(e.value="0"),this.dispatchEvent(new CustomEvent("qti-register-variable",{bubbles:!0,composed:!0,detail:{variable:e}}))}};Wr([p({type:String,attribute:"base-type"})],ae.prototype,"baseType",void 0);Wr([p({type:String,attribute:"external-scored"})],ae.prototype,"externalScored",void 0);Wr([p({type:String})],ae.prototype,"identifier",void 0);Wr([p({type:String})],ae.prototype,"cardinality",void 0);Wr([_({context:F,subscribe:!0}),T()],ae.prototype,"itemContext",void 0);var mo=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},Ee=class extends Ri{static{this.styles=[q`
157
+ `]}render(){let t=this.itemContext?.variables.find(e=>e.identifier===this.identifier)?.value;return b`${JSON.stringify(t,null,2)}`}get interpolationTable(){let t=this.querySelector("qti-interpolation-table");if(!t)return null;let e=[];for(let i of t.querySelectorAll("qti-interpolation-table-entry")){let n=parseFloat(i.getAttribute("source-value")),r=parseFloat(i.getAttribute("target-value"));if(Number.isNaN(n)||Number.isNaN(r)){console.error("source-value or target-value is missing or not a number in qti-interpolation-table-entry");continue}e.push({sourceValue:n,targetValue:r,includeBoundary:i.getAttribute("include-boundary")!=="false"})}return e}get matchTable(){let t=this.querySelector("qti-match-table");if(!t)return null;let e=new Map;for(let i of t.querySelectorAll("qti-match-table-entry")){let n=parseFloat(i.getAttribute("source-value")),r=i.getAttribute("target-value");if(Number.isNaN(n)||r===null){console.error("source-value or target-value is missing or invalid in qti-match-table-entry");continue}e.set(n,r)}return e}connectedCallback(){super.connectedCallback();let t=this.defaultValues(this.cardinality),e={identifier:this.identifier,cardinality:this.cardinality,baseType:this.baseType,defaultValue:t,type:"outcome",value:null,interpolationTable:this.interpolationTable,matchTable:this.matchTable,externalScored:this.externalScored};e.value=t,(e.value===null||e.value==null)&&(e.baseType==="integer"||e.baseType==="float")&&(e.value="0"),this.dispatchEvent(new CustomEvent("qti-register-variable",{bubbles:!0,composed:!0,detail:{variable:e}}))}};Wr([p({type:String,attribute:"base-type"})],ae.prototype,"baseType",void 0);Wr([p({type:String,attribute:"external-scored"})],ae.prototype,"externalScored",void 0);Wr([p({type:String})],ae.prototype,"identifier",void 0);Wr([p({type:String})],ae.prototype,"cardinality",void 0);Wr([_({context:F,subscribe:!0}),T()],ae.prototype,"itemContext",void 0);var mo=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},Ee=class extends Pi{static{this.styles=[q`
158
158
  :host {
159
159
  display: none;
160
160
  }
@@ -205,23 +205,23 @@ Make sure to test your application with a production build as repeat registratio
205
205
  :host {
206
206
  display: none;
207
207
  }
208
- `]}render(){return b`<slot></slot>`}process(){if(!this.closest("qti-assessment-item"))return;let e=[...this.children];try{for(let i of e)i.process()}catch(i){if(!(i instanceof Pi))throw i}}firstUpdated(t){let e=this.getAttribute("template");if(!e)return;let i=e.split("/").pop().replace(".xml",""),n=am[i];n&&(this.innerHTML=n)}};function L(o,t){let e={waitUntilFirstUpdate:!1,...t};return(i,n)=>{let{update:r}=i,s=Array.isArray(o)?o:[o];i.update=function(a){s.forEach(l=>{let c=l;if(a.has(c)){let d=a.get(c),h=this[c];d!==h&&(!e.waitUntilFirstUpdate||this.hasUpdated)&&this[n](d,h)}}),r.call(this,a)}}}var Wi={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},Ot=o=>(...t)=>({_$litDirective$:o,values:t}),Ae=class{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,i){this._$Ct=t,this._$AM=e,this._$Ci=i}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}};var{I:lm}=it,jd=o=>o,Bd=o=>o===null||typeof o!="object"&&typeof o!="function";var Ud=o=>o.strings===void 0,Fd=()=>document.createComment(""),Qi=(o,t,e)=>{let i=o._$AA.parentNode,n=t===void 0?o._$AB:t._$AA;if(e===void 0){let r=i.insertBefore(Fd(),n),s=i.insertBefore(Fd(),n);e=new lm(r,s,o,o.options)}else{let r=e._$AB.nextSibling,s=e._$AM,a=s!==o;if(a){let l;e._$AQ?.(o),e._$AM=o,e._$AP!==void 0&&(l=o._$AU)!==s._$AU&&e._$AP(l)}if(r!==n||a){let l=e._$AA;for(;l!==r;){let c=jd(l).nextSibling;jd(i).insertBefore(l,n),l=c}}}return e},Ie=(o,t,e=o)=>(o._$AI(t,e),o),cm={},Hd=(o,t=cm)=>o._$AH=t,Wd=o=>o._$AH,go=o=>{o._$AR(),o._$AA.remove()};var Qr=(o,t)=>{let e=o._$AN;if(e===void 0)return!1;for(let i of e)i._$AO?.(t,!1),Qr(i,t);return!0},bo=o=>{let t,e;do{if((t=o._$AM)===void 0)break;e=t._$AN,e.delete(o),o=t}while(e?.size===0)},Qd=o=>{for(let t;t=o._$AM;o=t){let e=t._$AN;if(e===void 0)t._$AN=e=new Set;else if(e.has(o))break;e.add(o),pm(t)}};function dm(o){this._$AN!==void 0?(bo(this),this._$AM=o,Qd(this)):this._$AM=o}function hm(o,t=!1,e=0){let i=this._$AH,n=this._$AN;if(n!==void 0&&n.size!==0)if(t)if(Array.isArray(i))for(let r=e;r<i.length;r++)Qr(i[r],!1),bo(i[r]);else i!=null&&(Qr(i,!1),bo(i));else Qr(this,o)}var pm=o=>{o.type==Wi.CHILD&&(o._$AP??=hm,o._$AQ??=dm)},_e=class extends Ae{constructor(){super(...arguments),this._$AN=void 0}_$AT(t,e,i){super._$AT(t,e,i),Qd(this),this.isConnected=t._$AU}_$AO(t,e=!0){t!==this.isConnected&&(this.isConnected=t,t?this.reconnected?.():this.disconnected?.()),e&&(Qr(this,t),bo(this))}setValue(t){if(Ud(this._$Ct))this._$Ct._$AI(t,this);else{let e=[...this._$Ct._$AH];e[this._$Ci]=t,this._$Ct._$AI(e,this,0)}}disconnected(){}reconnected(){}};var bl=class extends _e{constructor(){super(...arguments),this.prevData={}}render(t){return O}update(t,[e]){return this.element!==t.element&&(this.element=t.element),this.host=t.options?.host||this.element,this.apply(e),this.groom(e),this.prevData={...e},O}apply(t){let e=this.#t(t),{prevData:i,element:n}=this;for(let r in e){let s=e[r];s!==i[r]&&(s===!0?n.setAttribute(r,""):s===!1?n.removeAttribute(r):s!=null?n.setAttribute(r,String(s)):n.removeAttribute(r))}}groom(t){let{prevData:e,element:i}=this;if(!e)return;let n=t?this.#t(t):{};for(let r in e)(!n||!(r in n))&&i.removeAttribute(r)}#t(t){return Object.fromEntries(Object.entries(t).filter(([e,i])=>typeof i=="function"?!1:e==="max-choices"&&i===0?!0:!(i===""||i===null||i===void 0)))}},Yq=Ot(bl);var Xr=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},le=class extends C{handleclassNamesChange(){this.classNames.split(" ").forEach(e=>{switch(e){case"qti-rubric-discretionary-placement":{if(!Mi(this,"cito-item-rubric-placement",{className:e,element:this},!0))return;this.setAttribute("slot","qti-rubric-block")}break;case"qti-rubric-inline":this.setAttribute("slot","");break;default:break}})}static{this.styles=q`
208
+ `]}render(){return b`<slot></slot>`}process(){if(!this.closest("qti-assessment-item"))return;let e=[...this.children];try{for(let i of e)i.process()}catch(i){if(!(i instanceof Oi))throw i}}firstUpdated(t){let e=this.getAttribute("template");if(!e)return;let i=e.split("/").pop().replace(".xml",""),n=am[i];n&&(this.innerHTML=n)}};function L(o,t){let e={waitUntilFirstUpdate:!1,...t};return(i,n)=>{let{update:r}=i,s=Array.isArray(o)?o:[o];i.update=function(a){s.forEach(l=>{let c=l;if(a.has(c)){let d=a.get(c),h=this[c];d!==h&&(!e.waitUntilFirstUpdate||this.hasUpdated)&&this[n](d,h)}}),r.call(this,a)}}}var Qi={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},Ot=o=>(...t)=>({_$litDirective$:o,values:t}),Ae=class{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,i){this._$Ct=t,this._$AM=e,this._$Ci=i}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}};var{I:lm}=it,jd=o=>o,Bd=o=>o===null||typeof o!="object"&&typeof o!="function";var Ud=o=>o.strings===void 0,Fd=()=>document.createComment(""),Gi=(o,t,e)=>{let i=o._$AA.parentNode,n=t===void 0?o._$AB:t._$AA;if(e===void 0){let r=i.insertBefore(Fd(),n),s=i.insertBefore(Fd(),n);e=new lm(r,s,o,o.options)}else{let r=e._$AB.nextSibling,s=e._$AM,a=s!==o;if(a){let l;e._$AQ?.(o),e._$AM=o,e._$AP!==void 0&&(l=o._$AU)!==s._$AU&&e._$AP(l)}if(r!==n||a){let l=e._$AA;for(;l!==r;){let c=jd(l).nextSibling;jd(i).insertBefore(l,n),l=c}}}return e},Ie=(o,t,e=o)=>(o._$AI(t,e),o),cm={},Hd=(o,t=cm)=>o._$AH=t,Wd=o=>o._$AH,go=o=>{o._$AR(),o._$AA.remove()};var Qr=(o,t)=>{let e=o._$AN;if(e===void 0)return!1;for(let i of e)i._$AO?.(t,!1),Qr(i,t);return!0},bo=o=>{let t,e;do{if((t=o._$AM)===void 0)break;e=t._$AN,e.delete(o),o=t}while(e?.size===0)},Qd=o=>{for(let t;t=o._$AM;o=t){let e=t._$AN;if(e===void 0)t._$AN=e=new Set;else if(e.has(o))break;e.add(o),pm(t)}};function dm(o){this._$AN!==void 0?(bo(this),this._$AM=o,Qd(this)):this._$AM=o}function hm(o,t=!1,e=0){let i=this._$AH,n=this._$AN;if(n!==void 0&&n.size!==0)if(t)if(Array.isArray(i))for(let r=e;r<i.length;r++)Qr(i[r],!1),bo(i[r]);else i!=null&&(Qr(i,!1),bo(i));else Qr(this,o)}var pm=o=>{o.type==Qi.CHILD&&(o._$AP??=hm,o._$AQ??=dm)},_e=class extends Ae{constructor(){super(...arguments),this._$AN=void 0}_$AT(t,e,i){super._$AT(t,e,i),Qd(this),this.isConnected=t._$AU}_$AO(t,e=!0){t!==this.isConnected&&(this.isConnected=t,t?this.reconnected?.():this.disconnected?.()),e&&(Qr(this,t),bo(this))}setValue(t){if(Ud(this._$Ct))this._$Ct._$AI(t,this);else{let e=[...this._$Ct._$AH];e[this._$Ci]=t,this._$Ct._$AI(e,this,0)}}disconnected(){}reconnected(){}};var bl=class extends _e{constructor(){super(...arguments),this.prevData={}}render(t){return O}update(t,[e]){return this.element!==t.element&&(this.element=t.element),this.host=t.options?.host||this.element,this.apply(e),this.groom(e),this.prevData={...e},O}apply(t){let e=this.#t(t),{prevData:i,element:n}=this;for(let r in e){let s=e[r];s!==i[r]&&(s===!0?n.setAttribute(r,""):s===!1?n.removeAttribute(r):s!=null?n.setAttribute(r,String(s)):n.removeAttribute(r))}}groom(t){let{prevData:e,element:i}=this;if(!e)return;let n=t?this.#t(t):{};for(let r in e)(!n||!(r in n))&&i.removeAttribute(r)}#t(t){return Object.fromEntries(Object.entries(t).filter(([e,i])=>typeof i=="function"?!1:e==="max-choices"&&i===0?!0:!(i===""||i===null||i===void 0)))}},Jq=Ot(bl);var Gr=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},le=class extends C{handleclassNamesChange(){this.classNames.split(" ").forEach(e=>{switch(e){case"qti-rubric-discretionary-placement":{if(!Di(this,"cito-item-rubric-placement",{className:e,element:this},!0))return;this.setAttribute("slot","qti-rubric-block")}break;case"qti-rubric-inline":this.setAttribute("slot","");break;default:break}})}static{this.styles=q`
209
209
  :host {
210
210
  display: block;
211
211
  }
212
- `}render(){return b`<slot></slot>`}};Xr([p({type:String})],le.prototype,"id",void 0);Xr([p({type:String})],le.prototype,"use",void 0);Xr([p({type:String})],le.prototype,"view",void 0);Xr([p({type:String,attribute:"class"})],le.prototype,"classNames",void 0);Xr([L("classNames",{waitUntilFirstUpdate:!0})],le.prototype,"handleclassNamesChange",null);var yo=class extends C{#t=null;firstUpdated(t){super.firstUpdated(t);let e=this.getAttribute("href");if(e!==null&&fetch(e).then(i=>i.text()).then(i=>{let n=this.#e(i);this.#t=document.createElement("style"),this.#t.media="screen",this.#t.textContent=`@scope {${n}}`,this.parentElement?this.parentElement.appendChild(this.#t):console.warn("No parent element to append the scoped stylesheet to.")}).catch(i=>{console.error("Failed to load stylesheet:",i)}),this.textContent!==null&&this.textContent.trim()!==""){let i=this.#e(this.textContent);this.#t=document.createElement("style"),this.#t.media="screen",this.#t.textContent=`@scope {${i}}`,this.parentElement?this.parentElement.appendChild(this.#t):console.warn("No parent element to append the scoped stylesheet to.")}}#e(t){return t.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\s+/g," ").replace(/\s*([{}:;])\s*/g,"$1").trim()}disconnectedCallback(){if(this.#t)try{this.#t.remove()}catch(t){console.error("Could not remove stylesheet:",t)}super.disconnectedCallback()}};var vo=class extends C{render(){return b`<slot></slot>`}calculate(){let t=[...this.children];if(t.length!==1)return console.error("qti-template-constraint must have exactly one child expression"),!0;try{return!!t[0].calculate()}catch(e){return console.error("Error evaluating template constraint:",e),!0}}getSubRules(){return[]}process(){let t=this.calculate();return t||console.debug("Template constraint not satisfied, restarting template processing"),t}};var Gr=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},ce=class extends C{constructor(){super(...arguments),this.identifier="",this.cardinality="single",this.baseType="string",this.mathVariable=!1,this.paramVariable=!1,this.#t=null}#t;static{this.styles=[q`
212
+ `}render(){return b`<slot></slot>`}};Gr([p({type:String})],le.prototype,"id",void 0);Gr([p({type:String})],le.prototype,"use",void 0);Gr([p({type:String})],le.prototype,"view",void 0);Gr([p({type:String,attribute:"class"})],le.prototype,"classNames",void 0);Gr([L("classNames",{waitUntilFirstUpdate:!0})],le.prototype,"handleclassNamesChange",null);var yo=class extends C{#t=null;firstUpdated(t){super.firstUpdated(t);let e=this.getAttribute("href");if(e!==null&&fetch(e).then(i=>i.text()).then(i=>{let n=this.#e(i);this.#t=document.createElement("style"),this.#t.media="screen",this.#t.textContent=`@scope {${n}}`,this.parentElement?this.parentElement.appendChild(this.#t):console.warn("No parent element to append the scoped stylesheet to.")}).catch(i=>{console.error("Failed to load stylesheet:",i)}),this.textContent!==null&&this.textContent.trim()!==""){let i=this.#e(this.textContent);this.#t=document.createElement("style"),this.#t.media="screen",this.#t.textContent=`@scope {${i}}`,this.parentElement?this.parentElement.appendChild(this.#t):console.warn("No parent element to append the scoped stylesheet to.")}}#e(t){return t.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\s+/g," ").replace(/\s*([{}:;])\s*/g,"$1").trim()}disconnectedCallback(){if(this.#t)try{this.#t.remove()}catch(t){console.error("Could not remove stylesheet:",t)}super.disconnectedCallback()}};var vo=class extends C{render(){return b`<slot></slot>`}calculate(){let t=[...this.children];if(t.length!==1)return console.error("qti-template-constraint must have exactly one child expression"),!0;try{return!!t[0].calculate()}catch(e){return console.error("Error evaluating template constraint:",e),!0}}getSubRules(){return[]}process(){let t=this.calculate();return t||console.debug("Template constraint not satisfied, restarting template processing"),t}};var Xr=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},ce=class extends C{constructor(){super(...arguments),this.identifier="",this.cardinality="single",this.baseType="string",this.mathVariable=!1,this.paramVariable=!1,this.#t=null}#t;static{this.styles=[q`
213
213
  :host {
214
214
  display: none;
215
215
  }
216
- `]}render(){return b`<slot></slot>`}connectedCallback(){super.connectedCallback(),this.updateComplete.then(()=>{this.#e(),this.#r()})}#e(){let t=this.querySelector("qti-default-value");if(!t)return;let e=t.textContent?.trim()||"";this.#t=this.#i(e)}#i(t){if(!t)return null;switch(this.baseType){case"integer":return parseInt(t,10);case"float":case"duration":return parseFloat(t);case"boolean":return t.toLowerCase()==="true";default:return t}}#r(){let e={...{identifier:this.identifier,cardinality:this.cardinality,baseType:this.baseType,defaultValue:this.#t,value:this.#t,type:"template",mathVariable:this.mathVariable,paramVariable:this.paramVariable},value:this.#t?.toString()||""};this.dispatchEvent(new CustomEvent("qti-register-variable",{bubbles:!0,composed:!0,detail:{variable:e}}))}getTemplateVariable(){return{identifier:this.identifier,cardinality:this.cardinality,baseType:this.baseType,value:this.#t,type:"template",mathVariable:this.mathVariable,paramVariable:this.paramVariable}}};Gr([p({type:String})],ce.prototype,"identifier",void 0);Gr([p({type:String})],ce.prototype,"cardinality",void 0);Gr([p({type:String,attribute:"base-type"})],ce.prototype,"baseType",void 0);Gr([p({type:Boolean,attribute:"math-variable"})],ce.prototype,"mathVariable",void 0);Gr([p({type:Boolean,attribute:"param-variable"})],ce.prototype,"paramVariable",void 0);var wo=class extends C{static{this.styles=[q`
216
+ `]}render(){return b`<slot></slot>`}connectedCallback(){super.connectedCallback(),this.updateComplete.then(()=>{this.#e(),this.#r()})}#e(){let t=this.querySelector("qti-default-value");if(!t)return;let e=t.textContent?.trim()||"";this.#t=this.#i(e)}#i(t){if(!t)return null;switch(this.baseType){case"integer":return parseInt(t,10);case"float":case"duration":return parseFloat(t);case"boolean":return t.toLowerCase()==="true";default:return t}}#r(){let e={...{identifier:this.identifier,cardinality:this.cardinality,baseType:this.baseType,defaultValue:this.#t,value:this.#t,type:"template",mathVariable:this.mathVariable,paramVariable:this.paramVariable},value:this.#t?.toString()||""};this.dispatchEvent(new CustomEvent("qti-register-variable",{bubbles:!0,composed:!0,detail:{variable:e}}))}getTemplateVariable(){return{identifier:this.identifier,cardinality:this.cardinality,baseType:this.baseType,value:this.#t,type:"template",mathVariable:this.mathVariable,paramVariable:this.paramVariable}}};Xr([p({type:String})],ce.prototype,"identifier",void 0);Xr([p({type:String})],ce.prototype,"cardinality",void 0);Xr([p({type:String,attribute:"base-type"})],ce.prototype,"baseType",void 0);Xr([p({type:Boolean,attribute:"math-variable"})],ce.prototype,"mathVariable",void 0);Xr([p({type:Boolean,attribute:"param-variable"})],ce.prototype,"paramVariable",void 0);var wo=class extends C{static{this.styles=[q`
217
217
  :host {
218
218
  display: none;
219
219
  }
220
- `]}#t=100;render(){return b`<slot></slot>`}process(){if(!this.closest("qti-assessment-item")){console.warn("qti-template-processing must be inside qti-assessment-item");return}let e=0,i=!1;do{if(i=!1,e++,e>this.#t){console.error("Template processing exceeded maximum iterations. Possible infinite loop.");break}try{let n=[...this.children];for(let r of n)if(r.tagName.toLowerCase()==="qti-template-constraint"){if(r.calculate()===!1){i=!0;break}}else r.process()}catch(n){console.error("Error during template processing:",n);break}}while(i);this.dispatchEvent(new CustomEvent("qti-template-processing-complete",{bubbles:!0,composed:!0,detail:{iterations:e}}))}firstUpdated(t){this.getAttribute("template")&&console.info("Template processing with external template not yet implemented")}};var Xd=[{tag:"qti-assessment-item",ctor:ft},{tag:"qti-assessment-stimulus",ctor:no},{tag:"qti-assessment-stimulus-ref",ctor:Bi},{tag:"qti-companion-materials-info",ctor:co},{tag:"qti-content-body",ctor:Ur},{tag:"qti-context-declaration",ctor:Ui},{tag:"qti-custom-operator",ctor:Hr},{tag:"qti-feedback-block",ctor:ho},{tag:"qti-feedback-inline",ctor:po},{tag:"qti-item-body",ctor:uo},{tag:"qti-modal-feedback",ctor:Hi},{tag:"qti-outcome-declaration",ctor:ae},{tag:"qti-response-declaration",ctor:Ee},{tag:"qti-response-processing",ctor:fo},{tag:"qti-rubric-block",ctor:le},{tag:"qti-stylesheet",ctor:yo},{tag:"qti-template-constraint",ctor:vo},{tag:"qti-template-declaration",ctor:ce},{tag:"qti-template-processing",ctor:wo}];var um=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},Yr=class extends Hi{constructor(){super(...arguments),this.access="atEnd"}static{this.styles=q`
220
+ `]}#t=100;render(){return b`<slot></slot>`}process(){if(!this.closest("qti-assessment-item")){console.warn("qti-template-processing must be inside qti-assessment-item");return}let e=0,i=!1;do{if(i=!1,e++,e>this.#t){console.error("Template processing exceeded maximum iterations. Possible infinite loop.");break}try{let n=[...this.children];for(let r of n)if(r.tagName.toLowerCase()==="qti-template-constraint"){if(r.calculate()===!1){i=!0;break}}else r.process()}catch(n){console.error("Error during template processing:",n);break}}while(i);this.dispatchEvent(new CustomEvent("qti-template-processing-complete",{bubbles:!0,composed:!0,detail:{iterations:e}}))}firstUpdated(t){this.getAttribute("template")&&console.info("Template processing with external template not yet implemented")}};var Gd=[{tag:"qti-assessment-item",ctor:ft},{tag:"qti-assessment-stimulus",ctor:no},{tag:"qti-assessment-stimulus-ref",ctor:Ui},{tag:"qti-companion-materials-info",ctor:co},{tag:"qti-content-body",ctor:Ur},{tag:"qti-context-declaration",ctor:Hi},{tag:"qti-custom-operator",ctor:Hr},{tag:"qti-feedback-block",ctor:ho},{tag:"qti-feedback-inline",ctor:po},{tag:"qti-item-body",ctor:uo},{tag:"qti-modal-feedback",ctor:Wi},{tag:"qti-outcome-declaration",ctor:ae},{tag:"qti-response-declaration",ctor:Ee},{tag:"qti-response-processing",ctor:fo},{tag:"qti-rubric-block",ctor:le},{tag:"qti-stylesheet",ctor:yo},{tag:"qti-template-constraint",ctor:vo},{tag:"qti-template-declaration",ctor:ce},{tag:"qti-template-processing",ctor:wo}];var um=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},Yr=class extends Wi{constructor(){super(...arguments),this.access="atEnd"}static{this.styles=q`
221
221
  :host {
222
222
  color: gray;
223
223
  }
224
- `}matches(t){let e=Array.isArray(t)?t.includes(this.identifier):t!=null&&t===this.identifier;return this.showHide==="hide"?!e:e}render(){return b``}};um([p({type:String})],Yr.prototype,"access",void 0);var xo=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},Te=class extends C{constructor(){super(...arguments),this.identifier="",this.class="",this.navigationMode="nonlinear",this.submissionMode="individual",this.#t=""}get title(){return this.#t}set title(t){this.#t=t,this.removeAttribute("title"),this.setAttribute("data-title",t)}#t;async connectedCallback(){super.connectedCallback(),await this.updateComplete,this.dispatchEvent(new Event("qti-test-part-connected",{bubbles:!0,composed:!0}))}render(){return b` <slot></slot>`}};xo([p({type:String})],Te.prototype,"identifier",void 0);xo([p({type:String})],Te.prototype,"class",void 0);xo([p({type:String,attribute:"navigation-mode"})],Te.prototype,"navigationMode",void 0);xo([p({type:String,attribute:"submission-mode"})],Te.prototype,"submissionMode",void 0);var mm=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},Jr=class extends E{#t=null;constructor(){super(),H(this,"cito-test-loaded",t=>this.#t=t.detail)}get#e(){return this.#t??this.closest("qti-assessment-test")}getResult(){let t=this.#e;if(!t)return console.warn("qti-test-variables: no enclosing qti-assessment-test, nothing to aggregate"),0;let e=this.getAttribute("weight-identifier")??"",i=this.getAttribute("variable-identifier"),n=$i(t,Ni(this)).map(a=>({item:a.identifier,weight:(e?a.weights.get(e):void 0)??1}));return new yl(this._testContext,i,n).calculate()}calculate(){return this.getResult()}};mm([_({context:nt,subscribe:!0})],Jr.prototype,"_testContext",void 0);var yl=class{constructor(t,e,i){this.testContext=t,this.itemVariable=e,this.includedItems=i}calculate(){let t=this.testContext?.items??[],e=0,i=[...new Set(this.includedItems.map(n=>n.item))];return t.forEach(n=>{if(i.includes(n.identifier)){let r=n.variables.find(a=>a.identifier===this.itemVariable),s=this.includedItems.find(a=>a.item===n.identifier)?.weight??1;if(r){let a=Number(r.value);Number.isNaN(a)||(e+=a*s)}}}),e}};var Kr="qti-assessment-section",qo="qti-test-part",Mt=o=>o.identifier||o.getAttribute("identifier")||"";function Gd(o,t){let e=o[t],i=t+1,n=fm(e,o,t);if(n){let s=gm(n,o,t);if(s===null)return{id:null,skipped:o.slice(t+1).map(Mt)};s>t?i=s:console.warn(`qti-branch-rule target "${n.target}" is not ahead of "${Mt(e)}", ignored`)}let r=o.slice(t+1,i).map(Mt);for(let s=i;s<o.length;s++){if(Jd(o[s],e))return{id:Mt(o[s]),skipped:r};r.push(Mt(o[s]))}return{id:null,skipped:r}}function Yd(o){let t=[];for(let e of o){if(Jd(e,null))return{id:Mt(e),skipped:t};t.push(Mt(e))}return{id:null,skipped:t}}function fm(o,t,e){let i=[o];for(let n=o.parentElement;n&&(n.localName===Kr||n.localName===qo)&&!n.contains(t[e+1]??null);n=n.parentElement)i.push(n);for(let n of i)for(let r of n.querySelectorAll(":scope > qti-branch-rule"))if(r.evaluate?.())return r;return null}function gm(o,t,e){let i=o.parentElement,n=r=>{if(!r)return null;let s=t.findLastIndex(a=>r.contains(a));return s+1<t.length?s+1:null};switch(o.target){case se.EXIT_TEST:return null;case se.EXIT_TESTPART:return n(i.closest(qo));case se.EXIT_SECTION:{let r=i.localName===Kr?i:i.closest(Kr);return n(r??i)}default:{let r=t.findIndex(l=>Mt(l)===o.target);if(r>=0)return r;let s=[...i.closest("qti-assessment-test")?.querySelectorAll(`${Kr}, ${qo}`)??[]].find(l=>l.getAttribute("identifier")===o.target),a=s?t.findIndex(l=>s.contains(l)):-1;return a>=0?a:(console.warn(`qti-branch-rule target "${o.target}" not found`),e+1)}}}function Jd(o,t){let e=[o];for(let i=o.parentElement;i&&(i.localName===Kr||i.localName===qo);i=i.parentElement)(!t||!i.contains(t))&&e.push(i);return e.every(i=>[...i.querySelectorAll(":scope > qti-pre-condition")].every(n=>n.evaluate?.()??!0))}var Co=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},Kd=o=>{class t extends o{constructor(...i){super(...i),this.navigate=null,this.requestTimeout=3e4,this.postLoadTransformCallback=null,this.postLoadTestTransformCallback=null,this._activeController=null,this._loadResults=[],this._navigationId=0,this._loadingState={expectedItems:0,connectedItems:0,expectedStimulus:0,loadedStimulus:0,isComplete:!1},this._loadedStimulusHrefs=new Set,this._loadingStimulusHrefs=new Set,this._bindEventHandlers()}navigateTo(i,n){let r=n||this._getDefaultNavigationId(i);r&&V(this,"cito-test-navigate",{type:i,id:r})}_bindEventHandlers(){H(this,"cito-test-navigate",this._handleNavigationRequest.bind(this)),H(this,"cito-test-loaded",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 n=i.detail;this._loadingState.connectedItems++;let r=n.querySelectorAll("qti-assessment-stimulus-ref");this._loadingState.expectedStimulus+=r.length,this._checkLoadingComplete()}async _handleStimulusRefConnected(i){i.preventDefault();let{element:n,item:r}=i;if(console.info("Stimulus ref connected:",{identifier:n.identifier,href:n.href,item:r.identifier}),this._loadedStimulusHrefs.has(n.href)){console.info("Stimulus already loaded, skipping:",n.href),this._loadingState.loadedStimulus++,this._checkLoadingComplete();return}if(this._loadingStimulusHrefs.has(n.href)){console.info("Stimulus already loading, skipping duplicate:",n.href),this._loadingState.loadedStimulus++,this._checkLoadingComplete();return}this._loadingStimulusHrefs.add(n.href),console.info("Starting stimulus load:",n.href);try{await this._loadStimulusRef(n,r),this._loadedStimulusHrefs.add(n.href),this._loadingState.loadedStimulus++,console.info("Stimulus loaded successfully:",n.href),this._checkLoadingComplete()}catch(s){s.name!=="AbortError"&&console.warn(`Failed to load stimulus ${n.identifier}:`,s),this._loadingState.loadedStimulus++,this._checkLoadingComplete()}finally{this._loadingStimulusHrefs.delete(n.href)}}_getDefaultNavigationId(i){return i==="section"?this.sessionContext?.navSectionId??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);if(this.navigate==="item"&&this._testElement&&!this.sessionContext?.navItemRefId){let n=[...this._testElement.querySelectorAll("qti-assessment-item-ref")];if(n[0]?.closest("qti-test-part")?.getAttribute("navigation-mode")==="linear"){let r=Yd(n);if(r.skipped.length&&V(this,"cito-test-items-skipped",{ids:r.skipped}),r.id===null){V(this,"cito-test-end-reached",{});return}i=r.id}}i&&this.navigateTo(this.navigate,i)}_isLinearNavigationRestricted(i,n){let r=this.sessionContext?.navItemRefId;if(!r||i==="item"&&n===r)return!1;let s=this._testElement?.querySelector(`qti-assessment-item-ref[identifier="${r}"]`);if(!s)return!1;let a=s.closest("qti-assessment-section"),l=s.closest("qti-test-part");if((a?.navigationMode||a?.getAttribute("navigation-mode")||l?.navigationMode||l?.getAttribute("navigation-mode")||"nonlinear")!=="linear")return!1;let d=Array.from(this._testElement?.querySelectorAll("qti-assessment-item-ref")||[]),h=d.findIndex(f=>f.identifier===r);if(i==="item"){let f=d.findIndex(m=>m.identifier===n);return f===-1||h===-1?!1:f!==h+1}return!0}_resolveLinearNext(i,n){if(i!=="item"||!this._testElement)return;let r=[...this._testElement.querySelectorAll("qti-assessment-item-ref")],s=r.findIndex(l=>Mt(l)===this.sessionContext?.navItemRefId);if(s<0||!r[s+1]||Mt(r[s+1])!==n||r[s].closest("qti-test-part")?.getAttribute("navigation-mode")!=="linear")return;let a=Gd(r,s);if(a.id!==n)return a}async _handleNavigationRequest({detail:i}){if(!i?.id)return;let n=this._resolveLinearNext(i.type,i.id);if(n?.id===null){n.skipped.length&&V(this,"cito-test-items-skipped",{ids:n.skipped}),V(this,"cito-test-end-reached",{});return}let r=n?.id??i.id;if(!n&&this._isLinearNavigationRestricted(i.type,r)){this._handleNavigationError(new Error("Navigation restricted in linear mode"),i.type,i.id);return}this._cancelPreviousNavigation();let s=++this._navigationId,a=new AbortController;try{this._dispatchLoadingStarted(i.type,r),this._activeController=a,await this._executeNavigation(i.type,r,s,a),n?.skipped.length&&s===this._navigationId&&!a.signal.aborted&&V(this,"cito-test-items-skipped",{ids:n.skipped})}catch(l){this._handleNavigationError(l,i.type,r)}finally{this._activeController===a&&(this._activeController=null),this._dispatchLoadingEnded(i.type,r)}}_handleNavigationError(i,n,r){i.name!=="AbortError"&&this._dispatchError(this._createNavigationError(i,n,r))}async _executeNavigation(i,n,r,s){i==="item"?await this._navigateToItem(n,r,s):await this._navigateToSection(n,r,s)}async _navigateToItem(i,n,r){let s=this._findItemRef(i);this._updateSessionContext(s,i),this._resetLoadingState(),this._loadingState.expectedItems=1,await this._loadItems([i],n,r),await this._waitForLoadingComplete(n,r),!this._isStaleNavigation(n,r)&&this._dispatchTestLoaded(this._loadResults,"item",i)}async _navigateToSection(i,n,r){let a=this._findSection(i)?.closest("qti-test-part")?.identifier;this.sessionContext={...this.sessionContext,navPartId:a,navSectionId:i,navItemRefId:null};let l=this._getSectionItemIds(i);this._resetLoadingState(),this._loadingState.expectedItems=l.length,await this._loadItems(l,n,r),await this._waitForLoadingComplete(n,r),!this._isStaleNavigation(n,r)&&this._dispatchTestLoaded(this._loadResults,"section",i)}_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,n=this._loadingState.loadedStimulus>=this._loadingState.expectedStimulus;i&&n&&!this._loadingState.isComplete&&(this._loadingState.isComplete=!0)}async _waitForLoadingComplete(i,n){for(;!this._loadingState.isComplete;){if(this._isStaleNavigation(i,n))return;await new Promise(r=>setTimeout(r,10))}}getLoadingProgress(){return{...this._loadingState}}async _loadStimulusRef(i,n){console.info("Loading stimulus:",i.href);let r=await this._loadStimulus(i.href);console.info("Stimulus loaded, applying content:",r?"has content":"no content"),this._applyStimulusContent(r,i,n)}_applyStimulusContent(i,n,r){if(!i){console.warn("No stimulus content to apply");return}let s=i.querySelector("qti-assessment-stimulus");if(!s){console.warn("No qti-assessment-stimulus element found in stimulus");return}let a=[],l=r.querySelector(`[data-stimulus-idref="${n.identifier}"]`);if(l)a.push(l),console.info("Found specific target:",l);else{let c=Array.from(this.querySelectorAll(`[data-stimulus-idref="${n.identifier}"]`));if(c.length>0)a=c,console.info("Found targets by identifier:",c.length);else{let d=Array.from(this.querySelectorAll("[data-stimulus-idref]"));a=d,console.info("Using fallback targets:",d.length)}}if(a.length===0){console.warn("No targets found for stimulus content");return}a.forEach((c,d)=>{c.innerHTML="",c.append(s.cloneNode(!0)),console.info(`Applied stimulus content to target ${d+1}/${a.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,n,r){if(!this._testElement||i.length===0)return;let s=i.map(c=>this._findItemRef(c));this._clearLoadedItems(),this._clearStimulusRef();let l=(await Promise.all(s.map(c=>this._loadSingleItem(c,n,r)))).filter(Boolean);this._isStaleNavigation(n,r)||(l.forEach(({itemRef:c,doc:d})=>{c&&d&&(c.xmlDoc=d)}),l.forEach(({itemRef:c})=>{let d=c?.identifier;if(!c||!d)return;let h=this.testContext.items.find(f=>f.identifier===d)?.state;h!==void 0&&c.updateComplete.then(()=>{let f=c.assessmentItem;f&&(f.state=h)})}),this._loadResults=l)}async _loadSingleItem(i,n,r){try{let s=this.qtiContext?.QTI_CONTEXT?.seed,a=(await Gt().load(i.href,r.signal)).shuffleInteractions(s);return this.postLoadTransformCallback&&(a=await this.postLoadTransformCallback(a,i)),this._isStaleNavigation(n,r)?null:{itemRef:i,doc:a.htmlDoc(this._customElementRegistry())}}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 Gt().load(i,this._activeController?.signal)).htmlDoc(this._customElementRegistry())}_customElementRegistry(){let i=this.querySelector("test-container");if(i)return i.customElementRegistry??void 0}_findItemRef(i){let n=this._testElement?.querySelector(`qti-assessment-item-ref[identifier="${i}"]`);if(!n)throw new Error(`Item with identifier "${i}" not found`);return n}_findSection(i){return this._testElement?.querySelector(`qti-assessment-section[identifier="${i}"]`)||null}_updateSessionContext(i,n){let r=i.closest("qti-test-part")?.identifier,s=i.closest("qti-assessment-section")?.identifier;this.sessionContext={...this.sessionContext,navPartId:r,navSectionId:s,navItemRefId:n}}_getSectionItemIds(i){return Array.from(this._testElement.querySelectorAll(`qti-assessment-section[identifier="${i}"] > qti-assessment-item-ref`)).map(n=>n.identifier).filter(Boolean)}_clearLoadedItems(){let i=this._testElement?.querySelectorAll("qti-assessment-item-ref");Array.from(i||[]).forEach(n=>{n.xmlDoc=null})}_clearStimulusRef(){this.querySelectorAll("[data-stimulus-idref]").forEach(i=>i.innerHTML="")}_isStaleNavigation(i,n){return n.signal.aborted||i!==this._navigationId}_createNavigationError(i,n,r){return{message:i.message||`Failed to load ${n}: ${r}`,details:i,itemId:n==="item"?r:void 0,sectionId:n==="section"?r:void 0}}_dispatchLoadingStarted(i,n){V(this,"cito-test-navigation-started",{type:i,id:n})}_dispatchLoadingEnded(i,n){this.dispatchEvent(new CustomEvent("qti-navigation-loading-ended",{detail:{type:i,id:n},bubbles:!0,composed:!0}))}_dispatchError(i){V(this,"cito-test-navigation-failed",i)}_dispatchTestLoaded(i,n,r){requestAnimationFrame(()=>{V(this,"cito-test-rendered",i.map(({itemRef:s})=>({identifier:s?.identifier,element:s}))),V(this,"cito-test-navigated",{type:n,id:r})})}}return Co([p({type:String})],t.prototype,"navigate",void 0),Co([p({type:Number})],t.prototype,"requestTimeout",void 0),Co([p({attribute:!1})],t.prototype,"postLoadTransformCallback",void 0),Co([p({attribute:!1})],t.prototype,"postLoadTestTransformCallback",void 0),t};var Zd=o=>{class t extends o{constructor(...i){super(...i),this.sessionContext={...this.sessionContext,view:"candidate"},H(this,"cito-test-switch-view",n=>{this.sessionContext={...this.sessionContext,view:n.detail},this._updateElementView()}),H(this,"cito-test-loaded",()=>{this._updateElementView()}),this.addEventListener("qti-assessment-item-connected",n=>{this._updateElementView(),this._setCorrectResponseVisibility(n.detail)})}willUpdate(i){super.willUpdate(i),i.has("sessionContext")&&this._updateElementView()}_updateElementView(){if(this._testElement){Array.from(this._testElement.querySelectorAll("[view]")).forEach(s=>{s.classList.toggle("show",s.getAttribute("view")===this.sessionContext.view)});let r=this._testElement.querySelector(`qti-assessment-item-ref[identifier="${this.sessionContext.navItemRefId}"]`)?.assessmentItem;r&&this.updateAssessmentItemView(r,this.sessionContext.view)}}_setCorrectResponseVisibility(i){this.updateAssessmentItemView(i,this.sessionContext.view)}updateAssessmentItemView(i,n){}}return t};var th=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},vl=o=>{class t extends o{constructor(...i){super(...i),this.testContext=Ka,this.sessionContext=Ja,this._updateItemInTestContext=n=>{let r=n.itemContext,s=r.identifier,a=r.variables,l=this.testContext.items.find(c=>c?.identifier===s);if(!l){console.warn(`Item IDs between assessment.xml and item.xml should match: ${s} is not found!`);return}if(l.variables?.length===1)this._updateItemVariablesInTestContext(s,a,void 0,r.valid);else{let c=[...n.variables];for(let d of l.variables){if(d.identifier==="completionStatus"&&d.value==="not_attempted")continue;let h=c.find(f=>f.identifier===d.identifier);h?h.value=d.value:c.push(d)}n.variables=c,this.#t(s,c.find(d=>d.identifier==="completionStatus")?.value),l.state&&(n.state=l.state)}},this._initializeEventListeners()}updateItemVariables(i,n,r){this.testContext={...this.testContext,items:this.testContext.items.map(a=>{if(a.identifier!==i)return a;let l=[...a.variables??[]];for(let{identifier:c,type:d,value:h}of n){let f=l.findIndex(v=>v.identifier===c),m={...f>=0?l[f]:{},identifier:c,...d?{type:d}:{},value:Array.isArray(h)?[...h]:h};f>=0?l[f]=m:l.push(m)}return{...a,variables:l,...r?{state:{...r}}:{}}})};let s=this._testElement?.querySelector(`qti-assessment-item-ref[identifier="${CSS.escape(i)}"]`)?.assessmentItem;s&&(s.variables=[...this.testContext.items.find(a=>a.identifier===i)?.variables??[]],r&&(s.state=r))}_initializeEventListeners(){this.addEventListener("qti-testdoc-loaded",()=>{this.testContext=Ka,this.sessionContext=Ja}),H(this,"cito-test-loaded",i=>{this._testElement=i.detail;let n=Array.from(this._testElement.querySelectorAll("qti-assessment-item-ref")).map(r=>({href:r.href,identifier:r.identifier,category:r.category,variables:[{identifier:"completionStatus",value:"not_attempted",type:"outcome"}]}));this.testContext={...this.testContext,items:n}}),this.addEventListener("qti-assessment-item-connected",i=>{let n=i.detail,r=n.closest("qti-assessment-item-ref")?.identifier;r&&(n.assessmentItemRefId=r),this._updateItemInTestContext(i.detail)}),this.addEventListener("qti-item-context-updated",i=>{this._updateItemVariablesInTestContext(i.detail.itemContext.identifier,i.detail.itemContext.variables,i.detail.itemContext.state,i.detail.itemContext.valid)})}_updateItemVariablesInTestContext(i,n,r,s){this.testContext={...this.testContext,items:this.testContext.items.map(a=>a.identifier!==i?a:{...a,variables:n.map(l=>{let c=a.variables.find(d=>d.identifier===l.identifier);return c?{...c,...l}:l}),...r!==void 0?{state:r?{...r}:void 0}:{},...s!==void 0?{valid:s}:{}})},this.dispatchEvent(new CustomEvent("qti-test-context-updated",{detail:this.testContext,bubbles:!1,composed:!1}))}#t(i,n){typeof n!="string"||n==="not_attempted"||this.testContext.items.find(a=>a.identifier===i)?.variables.find(a=>a.identifier==="completionStatus")?.value!=="not_attempted"||(this.testContext={...this.testContext,items:this.testContext.items.map(a=>a.identifier!==i?a:{...a,variables:a.variables.map(l=>l.identifier==="completionStatus"?{...l,value:n}:l)})})}}return th([p({attribute:!1,type:Object}),U({context:nt})],t.prototype,"testContext",void 0),th([p({attribute:!1,type:Object}),U({context:qe})],t.prototype,"sessionContext",void 0),t},eh=class extends vl(C){};var ko=1;var wl=o=>Array.isArray(o)?[...o]:o??null,bm=o=>{let t=o;return t?.version===1&&Array.isArray(t.test?.items)&&Array.isArray(t.test?.outcomes)&&typeof t.session=="object"&&t.session!==null},ym=(o,t)=>({version:1,test:{items:(o?.items??[]).filter(e=>e.identifier).map(e=>({identifier:e.identifier,variables:(e.variables??[]).map(i=>({identifier:i.identifier,...i.type?{type:i.type}:{},value:wl(i.value)})),...e.state?{state:{...e.state}}:{}})),outcomes:(o?.testOutcomeVariables??[]).map(e=>({identifier:e.identifier,value:wl(e.value)}))},session:{...t?.plugins&&Object.keys(t.plugins).length>0?{plugins:{...t.plugins}}:{},...t?.navPartId!==void 0?{navPartId:t.navPartId}:{},...t?.navSectionId!==void 0?{navSectionId:t.navSectionId}:{},...t?.navItemRefId!==void 0?{navItemRefId:t.navItemRefId}:{}}}),ih=o=>{class t extends o{#t=null;#e=!1;#i=null;constructor(...i){super(...i),this.addEventListener("qti-testdoc-loaded",()=>{this.#e=!1,this.#i=null}),H(this,"cito-test-update-plugin-state",({detail:n})=>this.#r(n)),H(this,"cito-test-loaded",()=>{this.#t&&(this.#n(this.#t),this.#t=null),this.#e=!0})}#r({plugin:i,value:n}){if(typeof i!="string"||i==="")return;let{[i]:r,...s}=this.sessionContext.plugins??{},a=s;if(n!=null)try{a={...s,[i]:JSON.parse(JSON.stringify(n))}}catch{console.warn(`[qti-test] Ignoring plugin state for "${i}": it is not JSON.`);return}this.sessionContext={...this.sessionContext,plugins:a}}get state(){return ym(this.testContext,this.sessionContext)}set state(i){if(!bm(i)){console.warn(`[qti-test] Ignoring a state that is not a version ${1} QtiTestState.`);return}if(!this.#e){this.#t=i;return}let{navItemRefId:n,navSectionId:r}=this.sessionContext;this.#n(i);let s=this.sessionContext;s.navItemRefId&&s.navItemRefId!==n?this.#s("item",s.navItemRefId):!s.navItemRefId&&s.navSectionId&&s.navSectionId!==r&&this.#s("section",s.navSectionId)}updated(i){if(super.updated(i),!this.#e||!(i.has("testContext")||i.has("sessionContext")))return;let n=this.state,r=JSON.stringify(n);r!==this.#i&&(this.#i=r,V(this,"cito-test-state-changed",n))}#n(i){for(let r of i.test.items)this.updateItemVariables(r.identifier,r.variables,r.state);let n=new Map(i.test.outcomes.map(r=>[r.identifier,r.value]));this.testContext={...this.testContext,testOutcomeVariables:this.testContext.testOutcomeVariables?.map(r=>n.has(r.identifier)?{...r,value:wl(n.get(r.identifier))}:r)},this.sessionContext={...this.sessionContext,...this.#o(i.session),plugins:i.session.plugins&&typeof i.session.plugins=="object"?{...i.session.plugins}:{}}}#o(i){let n=(r,s)=>!!s&&!!this._testElement?.querySelector(`${r}[identifier="${CSS.escape(s)}"]`);return{...n("qti-test-part",i.navPartId)?{navPartId:i.navPartId}:{},...n("qti-assessment-section",i.navSectionId)?{navSectionId:i.navSectionId}:{},...this.testContext.items.some(r=>r.identifier===i.navItemRefId)?{navItemRefId:i.navItemRefId}:{}}}#s(i,n){V(this,"cito-test-navigate",{type:i,id:n})}}return t};var rh=o=>{class t extends o{constructor(...i){super(...i),this.addEventListener("qti-register-variable",n=>{this.testContext={...this.testContext,testOutcomeVariables:[...this.testContext.testOutcomeVariables||[],n.detail.variable]},n.stopPropagation()}),this.addEventListener("qti-set-outcome-value",n=>{let{outcomeIdentifier:r,value:s}=n.detail;this.updateOutcomeVariable(r,s),n.stopPropagation()})}outcomeProcessing(){let i=(this._testElement??this).querySelector("qti-outcome-processing");return i?(i?.process(),!0):!1}getTestFeedback(i){return Array.from((this._testElement??this).querySelectorAll("qti-test-feedback")??[]).filter(r=>(!i||r.access===i)&&r.matches(this.getOutcome(r.outcomeIdentifier)?.value))}updateOutcomeVariable(i,n){let r=this.getOutcome(i);if(!r){console.warn(`Can not set qti-outcome-identifier: ${i}, it is not available`);return}this.testContext={...this.testContext,testOutcomeVariables:this.testContext.testOutcomeVariables?.map(s=>s.identifier!==i?s:{...s,value:r.cardinality==="single"?n:[...s.value,n]})}}getOutcome(i){return this.getVariable(i)}getVariable(i){return this.testContext.testOutcomeVariables?.find(n=>n.identifier===i)||null}}return t};var nh=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},Re=class extends Kd(Zd(rh(ih(vl(C))))){constructor(){super(),this.configContext={},this.qtiContext={QTI_CONTEXT:{testIdentifier:"",candidateIdentifier:"",environmentIdentifier:"default"}},new ve(this,{context:Ce,initialValue:this})}async connectedCallback(){super.connectedCallback(),await this.updateComplete,this.dispatchEvent(new CustomEvent("qti-test-connected",{detail:this}))}render(){return b`<slot></slot>`}};nh([T(),U({context:xt})],Re.prototype,"configContext",void 0);nh([T(),U({context:qt})],Re.prototype,"qtiContext",void 0);var So=class{constructor(t){this.G=t}disconnect(){this.G=void 0}reconnect(t){this.G=t}deref(){return this.G}},Eo=class{constructor(){this.Y=void 0,this.Z=void 0}get(){return this.Y}pause(){this.Y??=new Promise(t=>this.Z=t)}resume(){this.Z?.(),this.Y=this.Z=void 0}};var oh=o=>!Bd(o)&&typeof o.then=="function",sh=1073741823,xl=class extends _e{constructor(){super(...arguments),this._$Cwt=sh,this._$Cbt=[],this._$CK=new So(this),this._$CX=new Eo}render(...t){return t.find(e=>!oh(e))??rt}update(t,e){let i=this._$Cbt,n=i.length;this._$Cbt=e;let r=this._$CK,s=this._$CX;this.isConnected||this.disconnected();for(let a=0;a<e.length&&!(a>this._$Cwt);a++){let l=e[a];if(!oh(l))return this._$Cwt=a,l;a<n&&l===i[a]||(this._$Cwt=sh,n=0,Promise.resolve(l).then(async c=>{for(;s.get();)await s.get();let d=r.deref();if(d!==void 0){let h=d._$Cbt.indexOf(l);h>-1&&h<d._$Cwt&&(d._$Cwt=h,d.setValue(c))}}))}return rt}disconnected(){this._$CK.disconnect(),this._$CX.pause()}reconnected(){this._$CK.reconnect(this),this._$CX.resume()}},Ao=Ot(xl);var Io=`
224
+ `}matches(t){let e=Array.isArray(t)?t.includes(this.identifier):t!=null&&t===this.identifier;return this.showHide==="hide"?!e:e}render(){return b``}};um([p({type:String})],Yr.prototype,"access",void 0);var xo=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},Te=class extends C{constructor(){super(...arguments),this.identifier="",this.class="",this.navigationMode="nonlinear",this.submissionMode="individual",this.#t=""}get title(){return this.#t}set title(t){this.#t=t,this.removeAttribute("title"),this.setAttribute("data-title",t)}#t;async connectedCallback(){super.connectedCallback(),await this.updateComplete,this.dispatchEvent(new Event("qti-test-part-connected",{bubbles:!0,composed:!0}))}render(){return b` <slot></slot>`}};xo([p({type:String})],Te.prototype,"identifier",void 0);xo([p({type:String})],Te.prototype,"class",void 0);xo([p({type:String,attribute:"navigation-mode"})],Te.prototype,"navigationMode",void 0);xo([p({type:String,attribute:"submission-mode"})],Te.prototype,"submissionMode",void 0);var mm=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},Jr=class extends E{#t=null;constructor(){super(),H(this,"cito-test-loaded",t=>this.#t=t.detail)}get#e(){return this.#t??this.closest("qti-assessment-test")}getResult(){let t=this.#e;if(!t)return console.warn("qti-test-variables: no enclosing qti-assessment-test, nothing to aggregate"),0;let e=this.getAttribute("weight-identifier")??"",i=this.getAttribute("variable-identifier"),n=Li(t,$i(this)).map(a=>({item:a.identifier,weight:(e?a.weights.get(e):void 0)??1}));return new yl(this._testContext,i,n).calculate()}calculate(){return this.getResult()}};mm([_({context:nt,subscribe:!0})],Jr.prototype,"_testContext",void 0);var yl=class{constructor(t,e,i){this.testContext=t,this.itemVariable=e,this.includedItems=i}calculate(){let t=this.testContext?.items??[],e=0,i=[...new Set(this.includedItems.map(n=>n.item))];return t.forEach(n=>{if(i.includes(n.identifier)){let r=n.variables.find(a=>a.identifier===this.itemVariable),s=this.includedItems.find(a=>a.item===n.identifier)?.weight??1;if(r){let a=Number(r.value);Number.isNaN(a)||(e+=a*s)}}}),e}};var Kr="qti-assessment-section",qo="qti-test-part",Mt=o=>o.identifier||o.getAttribute("identifier")||"";function Xd(o,t){let e=o[t],i=t+1,n=fm(e,o,t);if(n){let s=gm(n,o,t);if(s===null)return{id:null,skipped:o.slice(t+1).map(Mt)};s>t?i=s:console.warn(`qti-branch-rule target "${n.target}" is not ahead of "${Mt(e)}", ignored`)}let r=o.slice(t+1,i).map(Mt);for(let s=i;s<o.length;s++){if(Jd(o[s],e))return{id:Mt(o[s]),skipped:r};r.push(Mt(o[s]))}return{id:null,skipped:r}}function Yd(o){let t=[];for(let e of o){if(Jd(e,null))return{id:Mt(e),skipped:t};t.push(Mt(e))}return{id:null,skipped:t}}function fm(o,t,e){let i=[o];for(let n=o.parentElement;n&&(n.localName===Kr||n.localName===qo)&&!n.contains(t[e+1]??null);n=n.parentElement)i.push(n);for(let n of i)for(let r of n.querySelectorAll(":scope > qti-branch-rule"))if(r.evaluate?.())return r;return null}function gm(o,t,e){let i=o.parentElement,n=r=>{if(!r)return null;let s=t.findLastIndex(a=>r.contains(a));return s+1<t.length?s+1:null};switch(o.target){case se.EXIT_TEST:return null;case se.EXIT_TESTPART:return n(i.closest(qo));case se.EXIT_SECTION:{let r=i.localName===Kr?i:i.closest(Kr);return n(r??i)}default:{let r=t.findIndex(l=>Mt(l)===o.target);if(r>=0)return r;let s=[...i.closest("qti-assessment-test")?.querySelectorAll(`${Kr}, ${qo}`)??[]].find(l=>l.getAttribute("identifier")===o.target),a=s?t.findIndex(l=>s.contains(l)):-1;return a>=0?a:(console.warn(`qti-branch-rule target "${o.target}" not found`),e+1)}}}function Jd(o,t){let e=[o];for(let i=o.parentElement;i&&(i.localName===Kr||i.localName===qo);i=i.parentElement)(!t||!i.contains(t))&&e.push(i);return e.every(i=>[...i.querySelectorAll(":scope > qti-pre-condition")].every(n=>n.evaluate?.()??!0))}var Co=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},Kd=o=>{class t extends o{constructor(...i){super(...i),this.navigate=null,this.requestTimeout=3e4,this.postLoadTransformCallback=null,this.postLoadTestTransformCallback=null,this._activeController=null,this._loadResults=[],this._navigationId=0,this._loadingState={expectedItems:0,connectedItems:0,expectedStimulus:0,loadedStimulus:0,isComplete:!1},this._loadedStimulusHrefs=new Set,this._loadingStimulusHrefs=new Set,this._bindEventHandlers()}navigateTo(i,n){let r=n||this._getDefaultNavigationId(i);r&&V(this,"cito-test-navigate",{type:i,id:r})}_bindEventHandlers(){H(this,"cito-test-navigate",this._handleNavigationRequest.bind(this)),H(this,"cito-test-loaded",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 n=i.detail;this._loadingState.connectedItems++;let r=n.querySelectorAll("qti-assessment-stimulus-ref");this._loadingState.expectedStimulus+=r.length,this._checkLoadingComplete()}async _handleStimulusRefConnected(i){i.preventDefault();let{element:n,item:r}=i;if(console.info("Stimulus ref connected:",{identifier:n.identifier,href:n.href,item:r.identifier}),this._loadedStimulusHrefs.has(n.href)){console.info("Stimulus already loaded, skipping:",n.href),this._loadingState.loadedStimulus++,this._checkLoadingComplete();return}if(this._loadingStimulusHrefs.has(n.href)){console.info("Stimulus already loading, skipping duplicate:",n.href),this._loadingState.loadedStimulus++,this._checkLoadingComplete();return}this._loadingStimulusHrefs.add(n.href),console.info("Starting stimulus load:",n.href);try{await this._loadStimulusRef(n,r),this._loadedStimulusHrefs.add(n.href),this._loadingState.loadedStimulus++,console.info("Stimulus loaded successfully:",n.href),this._checkLoadingComplete()}catch(s){s.name!=="AbortError"&&console.warn(`Failed to load stimulus ${n.identifier}:`,s),this._loadingState.loadedStimulus++,this._checkLoadingComplete()}finally{this._loadingStimulusHrefs.delete(n.href)}}_getDefaultNavigationId(i){return i==="section"?this.sessionContext?.navSectionId??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);if(this.navigate==="item"&&this._testElement&&!this.sessionContext?.navItemRefId){let n=[...this._testElement.querySelectorAll("qti-assessment-item-ref")];if(n[0]?.closest("qti-test-part")?.getAttribute("navigation-mode")==="linear"){let r=Yd(n);if(r.skipped.length&&V(this,"cito-test-items-skipped",{ids:r.skipped}),r.id===null){V(this,"cito-test-end-reached",{});return}i=r.id}}i&&this.navigateTo(this.navigate,i)}_isLinearNavigationRestricted(i,n){let r=this.sessionContext?.navItemRefId;if(!r||i==="item"&&n===r)return!1;let s=this._testElement?.querySelector(`qti-assessment-item-ref[identifier="${r}"]`);if(!s)return!1;let a=s.closest("qti-assessment-section"),l=s.closest("qti-test-part");if((a?.navigationMode||a?.getAttribute("navigation-mode")||l?.navigationMode||l?.getAttribute("navigation-mode")||"nonlinear")!=="linear")return!1;let d=Array.from(this._testElement?.querySelectorAll("qti-assessment-item-ref")||[]),h=d.findIndex(f=>f.identifier===r);if(i==="item"){let f=d.findIndex(m=>m.identifier===n);return f===-1||h===-1?!1:f!==h+1}return!0}_resolveLinearNext(i,n){if(i!=="item"||!this._testElement)return;let r=[...this._testElement.querySelectorAll("qti-assessment-item-ref")],s=r.findIndex(l=>Mt(l)===this.sessionContext?.navItemRefId);if(s<0||!r[s+1]||Mt(r[s+1])!==n||r[s].closest("qti-test-part")?.getAttribute("navigation-mode")!=="linear")return;let a=Xd(r,s);if(a.id!==n)return a}async _handleNavigationRequest({detail:i}){if(!i?.id)return;let n=this._resolveLinearNext(i.type,i.id);if(n?.id===null){n.skipped.length&&V(this,"cito-test-items-skipped",{ids:n.skipped}),V(this,"cito-test-end-reached",{});return}let r=n?.id??i.id;if(!n&&this._isLinearNavigationRestricted(i.type,r)){this._handleNavigationError(new Error("Navigation restricted in linear mode"),i.type,i.id);return}this._cancelPreviousNavigation();let s=++this._navigationId,a=new AbortController;try{this._dispatchLoadingStarted(i.type,r),this._activeController=a,await this._executeNavigation(i.type,r,s,a),n?.skipped.length&&s===this._navigationId&&!a.signal.aborted&&V(this,"cito-test-items-skipped",{ids:n.skipped})}catch(l){this._handleNavigationError(l,i.type,r)}finally{this._activeController===a&&(this._activeController=null),this._dispatchLoadingEnded(i.type,r)}}_handleNavigationError(i,n,r){i.name!=="AbortError"&&this._dispatchError(this._createNavigationError(i,n,r))}async _executeNavigation(i,n,r,s){i==="item"?await this._navigateToItem(n,r,s):await this._navigateToSection(n,r,s)}async _navigateToItem(i,n,r){let s=this._findItemRef(i);this._updateSessionContext(s,i),this._resetLoadingState(),this._loadingState.expectedItems=1,await this._loadItems([i],n,r),await this._waitForLoadingComplete(n,r),!this._isStaleNavigation(n,r)&&this._dispatchTestLoaded(this._loadResults,"item",i)}async _navigateToSection(i,n,r){let a=this._findSection(i)?.closest("qti-test-part")?.identifier;this.sessionContext={...this.sessionContext,navPartId:a,navSectionId:i,navItemRefId:null};let l=this._getSectionItemIds(i);this._resetLoadingState(),this._loadingState.expectedItems=l.length,await this._loadItems(l,n,r),await this._waitForLoadingComplete(n,r),!this._isStaleNavigation(n,r)&&this._dispatchTestLoaded(this._loadResults,"section",i)}_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,n=this._loadingState.loadedStimulus>=this._loadingState.expectedStimulus;i&&n&&!this._loadingState.isComplete&&(this._loadingState.isComplete=!0)}async _waitForLoadingComplete(i,n){for(;!this._loadingState.isComplete;){if(this._isStaleNavigation(i,n))return;await new Promise(r=>setTimeout(r,10))}}getLoadingProgress(){return{...this._loadingState}}async _loadStimulusRef(i,n){console.info("Loading stimulus:",i.href);let r=await this._loadStimulus(i.href);console.info("Stimulus loaded, applying content:",r?"has content":"no content"),this._applyStimulusContent(r,i,n)}_applyStimulusContent(i,n,r){if(!i){console.warn("No stimulus content to apply");return}let s=i.querySelector("qti-assessment-stimulus");if(!s){console.warn("No qti-assessment-stimulus element found in stimulus");return}let a=[],l=r.querySelector(`[data-stimulus-idref="${n.identifier}"]`);if(l)a.push(l),console.info("Found specific target:",l);else{let c=Array.from(this.querySelectorAll(`[data-stimulus-idref="${n.identifier}"]`));if(c.length>0)a=c,console.info("Found targets by identifier:",c.length);else{let d=Array.from(this.querySelectorAll("[data-stimulus-idref]"));a=d,console.info("Using fallback targets:",d.length)}}if(a.length===0){console.warn("No targets found for stimulus content");return}a.forEach((c,d)=>{c.innerHTML="",c.append(s.cloneNode(!0)),console.info(`Applied stimulus content to target ${d+1}/${a.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,n,r){if(!this._testElement||i.length===0)return;let s=i.map(c=>this._findItemRef(c));this._clearLoadedItems(),this._clearStimulusRef();let l=(await Promise.all(s.map(c=>this._loadSingleItem(c,n,r)))).filter(Boolean);this._isStaleNavigation(n,r)||(l.forEach(({itemRef:c,doc:d})=>{c&&d&&(c.xmlDoc=d)}),l.forEach(({itemRef:c})=>{let d=c?.identifier;if(!c||!d)return;let h=this.testContext.items.find(f=>f.identifier===d)?.state;h!==void 0&&c.updateComplete.then(()=>{let f=c.assessmentItem;f&&(f.state=h)})}),this._loadResults=l)}async _loadSingleItem(i,n,r){try{let s=this.qtiContext?.QTI_CONTEXT?.seed,a=(await Xt().load(i.href,r.signal)).shuffleInteractions(s);return this.postLoadTransformCallback&&(a=await this.postLoadTransformCallback(a,i)),this._isStaleNavigation(n,r)?null:{itemRef:i,doc:a.htmlDoc(this._customElementRegistry())}}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 Xt().load(i,this._activeController?.signal)).htmlDoc(this._customElementRegistry())}_customElementRegistry(){let i=this.querySelector("test-container");if(i)return i.customElementRegistry??void 0}_findItemRef(i){let n=this._testElement?.querySelector(`qti-assessment-item-ref[identifier="${i}"]`);if(!n)throw new Error(`Item with identifier "${i}" not found`);return n}_findSection(i){return this._testElement?.querySelector(`qti-assessment-section[identifier="${i}"]`)||null}_updateSessionContext(i,n){let r=i.closest("qti-test-part")?.identifier,s=i.closest("qti-assessment-section")?.identifier;this.sessionContext={...this.sessionContext,navPartId:r,navSectionId:s,navItemRefId:n}}_getSectionItemIds(i){return Array.from(this._testElement.querySelectorAll(`qti-assessment-section[identifier="${i}"] > qti-assessment-item-ref`)).map(n=>n.identifier).filter(Boolean)}_clearLoadedItems(){let i=this._testElement?.querySelectorAll("qti-assessment-item-ref");Array.from(i||[]).forEach(n=>{n.xmlDoc=null})}_clearStimulusRef(){this.querySelectorAll("[data-stimulus-idref]").forEach(i=>i.innerHTML="")}_isStaleNavigation(i,n){return n.signal.aborted||i!==this._navigationId}_createNavigationError(i,n,r){return{message:i.message||`Failed to load ${n}: ${r}`,details:i,itemId:n==="item"?r:void 0,sectionId:n==="section"?r:void 0}}_dispatchLoadingStarted(i,n){V(this,"cito-test-navigation-started",{type:i,id:n})}_dispatchLoadingEnded(i,n){this.dispatchEvent(new CustomEvent("qti-navigation-loading-ended",{detail:{type:i,id:n},bubbles:!0,composed:!0}))}_dispatchError(i){V(this,"cito-test-navigation-failed",i)}_dispatchTestLoaded(i,n,r){requestAnimationFrame(()=>{V(this,"cito-test-rendered",i.map(({itemRef:s})=>({identifier:s?.identifier,element:s}))),V(this,"cito-test-navigated",{type:n,id:r})})}}return Co([p({type:String})],t.prototype,"navigate",void 0),Co([p({type:Number})],t.prototype,"requestTimeout",void 0),Co([p({attribute:!1})],t.prototype,"postLoadTransformCallback",void 0),Co([p({attribute:!1})],t.prototype,"postLoadTestTransformCallback",void 0),t};var Zd=o=>{class t extends o{constructor(...i){super(...i),this.sessionContext={...this.sessionContext,view:"candidate"},H(this,"cito-test-switch-view",n=>{this.sessionContext={...this.sessionContext,view:n.detail},this._updateElementView()}),H(this,"cito-test-loaded",()=>{this._updateElementView()}),this.addEventListener("qti-assessment-item-connected",n=>{this._updateElementView(),this._setCorrectResponseVisibility(n.detail)})}willUpdate(i){super.willUpdate(i),i.has("sessionContext")&&this._updateElementView()}_updateElementView(){if(this._testElement){Array.from(this._testElement.querySelectorAll("[view]")).forEach(s=>{s.classList.toggle("show",s.getAttribute("view")===this.sessionContext.view)});let r=this._testElement.querySelector(`qti-assessment-item-ref[identifier="${this.sessionContext.navItemRefId}"]`)?.assessmentItem;r&&this.updateAssessmentItemView(r,this.sessionContext.view)}}_setCorrectResponseVisibility(i){this.updateAssessmentItemView(i,this.sessionContext.view)}updateAssessmentItemView(i,n){}}return t};var th=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},vl=o=>{class t extends o{constructor(...i){super(...i),this.testContext=Ka,this.sessionContext=Ja,this._updateItemInTestContext=n=>{let r=n.itemContext,s=r.identifier,a=r.variables,l=this.testContext.items.find(c=>c?.identifier===s);if(!l){console.warn(`Item IDs between assessment.xml and item.xml should match: ${s} is not found!`);return}if(l.variables?.length===1)this._updateItemVariablesInTestContext(s,a,void 0,r.valid);else{let c=[...n.variables];for(let d of l.variables){if(d.identifier==="completionStatus"&&d.value==="not_attempted")continue;let h=c.find(f=>f.identifier===d.identifier);h?h.value=d.value:c.push(d)}n.variables=c,this.#t(s,c.find(d=>d.identifier==="completionStatus")?.value),l.state&&(n.state=l.state)}},this._initializeEventListeners()}updateItemVariables(i,n,r){this.testContext={...this.testContext,items:this.testContext.items.map(a=>{if(a.identifier!==i)return a;let l=[...a.variables??[]];for(let{identifier:c,type:d,value:h}of n){let f=l.findIndex(v=>v.identifier===c),m={...f>=0?l[f]:{},identifier:c,...d?{type:d}:{},value:Array.isArray(h)?[...h]:h};f>=0?l[f]=m:l.push(m)}return{...a,variables:l,...r?{state:{...r}}:{}}})};let s=this._testElement?.querySelector(`qti-assessment-item-ref[identifier="${CSS.escape(i)}"]`)?.assessmentItem;s&&(s.variables=[...this.testContext.items.find(a=>a.identifier===i)?.variables??[]],r&&(s.state=r))}_initializeEventListeners(){this.addEventListener("qti-testdoc-loaded",()=>{this.testContext=Ka,this.sessionContext=Ja}),H(this,"cito-test-loaded",i=>{this._testElement=i.detail;let n=Array.from(this._testElement.querySelectorAll("qti-assessment-item-ref")).map(r=>({href:r.href,identifier:r.identifier,category:r.category,variables:[{identifier:"completionStatus",value:"not_attempted",type:"outcome"}]}));this.testContext={...this.testContext,items:n}}),this.addEventListener("qti-assessment-item-connected",i=>{let n=i.detail,r=n.closest("qti-assessment-item-ref")?.identifier;r&&(n.assessmentItemRefId=r),this._updateItemInTestContext(i.detail)}),this.addEventListener("qti-item-context-updated",i=>{this._updateItemVariablesInTestContext(i.detail.itemContext.identifier,i.detail.itemContext.variables,i.detail.itemContext.state,i.detail.itemContext.valid)})}_updateItemVariablesInTestContext(i,n,r,s){this.testContext={...this.testContext,items:this.testContext.items.map(a=>a.identifier!==i?a:{...a,variables:n.map(l=>{let c=a.variables.find(d=>d.identifier===l.identifier);return c?{...c,...l}:l}),...r!==void 0?{state:r?{...r}:void 0}:{},...s!==void 0?{valid:s}:{}})},this.dispatchEvent(new CustomEvent("qti-test-context-updated",{detail:this.testContext,bubbles:!1,composed:!1}))}#t(i,n){typeof n!="string"||n==="not_attempted"||this.testContext.items.find(a=>a.identifier===i)?.variables.find(a=>a.identifier==="completionStatus")?.value!=="not_attempted"||(this.testContext={...this.testContext,items:this.testContext.items.map(a=>a.identifier!==i?a:{...a,variables:a.variables.map(l=>l.identifier==="completionStatus"?{...l,value:n}:l)})})}}return th([p({attribute:!1,type:Object}),U({context:nt})],t.prototype,"testContext",void 0),th([p({attribute:!1,type:Object}),U({context:qe})],t.prototype,"sessionContext",void 0),t},eh=class extends vl(C){};var So=1;var wl=o=>Array.isArray(o)?[...o]:o??null,bm=o=>{let t=o;return t?.version===1&&Array.isArray(t.test?.items)&&Array.isArray(t.test?.outcomes)&&typeof t.session=="object"&&t.session!==null},ym=(o,t)=>({version:1,test:{items:(o?.items??[]).filter(e=>e.identifier).map(e=>({identifier:e.identifier,variables:(e.variables??[]).map(i=>({identifier:i.identifier,...i.type?{type:i.type}:{},value:wl(i.value)})),...e.state?{state:{...e.state}}:{}})),outcomes:(o?.testOutcomeVariables??[]).map(e=>({identifier:e.identifier,value:wl(e.value)}))},session:{...t?.plugins&&Object.keys(t.plugins).length>0?{plugins:{...t.plugins}}:{},...t?.navPartId!==void 0?{navPartId:t.navPartId}:{},...t?.navSectionId!==void 0?{navSectionId:t.navSectionId}:{},...t?.navItemRefId!==void 0?{navItemRefId:t.navItemRefId}:{}}}),ih=o=>{class t extends o{#t=null;#e=!1;#i=null;constructor(...i){super(...i),this.addEventListener("qti-testdoc-loaded",()=>{this.#e=!1,this.#i=null}),H(this,"cito-test-update-plugin-state",({detail:n})=>this.#r(n)),H(this,"cito-test-loaded",()=>{this.#t&&(this.#n(this.#t),this.#t=null),this.#e=!0})}#r({plugin:i,value:n}){if(typeof i!="string"||i==="")return;let{[i]:r,...s}=this.sessionContext.plugins??{},a=s;if(n!=null)try{a={...s,[i]:JSON.parse(JSON.stringify(n))}}catch{console.warn(`[qti-test] Ignoring plugin state for "${i}": it is not JSON.`);return}this.sessionContext={...this.sessionContext,plugins:a}}get state(){return ym(this.testContext,this.sessionContext)}set state(i){if(!bm(i)){console.warn(`[qti-test] Ignoring a state that is not a version ${1} QtiTestState.`);return}if(!this.#e){this.#t=i;return}let{navItemRefId:n,navSectionId:r}=this.sessionContext;this.#n(i);let s=this.sessionContext;s.navItemRefId&&s.navItemRefId!==n?this.#s("item",s.navItemRefId):!s.navItemRefId&&s.navSectionId&&s.navSectionId!==r&&this.#s("section",s.navSectionId)}updated(i){if(super.updated(i),!this.#e||!(i.has("testContext")||i.has("sessionContext")))return;let n=this.state,r=JSON.stringify(n);r!==this.#i&&(this.#i=r,V(this,"cito-test-state-changed",n))}#n(i){for(let r of i.test.items)this.updateItemVariables(r.identifier,r.variables,r.state);let n=new Map(i.test.outcomes.map(r=>[r.identifier,r.value]));this.testContext={...this.testContext,testOutcomeVariables:this.testContext.testOutcomeVariables?.map(r=>n.has(r.identifier)?{...r,value:wl(n.get(r.identifier))}:r)},this.sessionContext={...this.sessionContext,...this.#o(i.session),plugins:i.session.plugins&&typeof i.session.plugins=="object"?{...i.session.plugins}:{}}}#o(i){let n=(r,s)=>!!s&&!!this._testElement?.querySelector(`${r}[identifier="${CSS.escape(s)}"]`);return{...n("qti-test-part",i.navPartId)?{navPartId:i.navPartId}:{},...n("qti-assessment-section",i.navSectionId)?{navSectionId:i.navSectionId}:{},...this.testContext.items.some(r=>r.identifier===i.navItemRefId)?{navItemRefId:i.navItemRefId}:{}}}#s(i,n){V(this,"cito-test-navigate",{type:i,id:n})}}return t};var rh=o=>{class t extends o{constructor(...i){super(...i),this.addEventListener("qti-register-variable",n=>{this.testContext={...this.testContext,testOutcomeVariables:[...this.testContext.testOutcomeVariables||[],n.detail.variable]},n.stopPropagation()}),this.addEventListener("qti-set-outcome-value",n=>{let{outcomeIdentifier:r,value:s}=n.detail;this.updateOutcomeVariable(r,s),n.stopPropagation()})}outcomeProcessing(){let i=(this._testElement??this).querySelector("qti-outcome-processing");return i?(i?.process(),!0):!1}getTestFeedback(i){return Array.from((this._testElement??this).querySelectorAll("qti-test-feedback")??[]).filter(r=>(!i||r.access===i)&&r.matches(this.getOutcome(r.outcomeIdentifier)?.value))}updateOutcomeVariable(i,n){let r=this.getOutcome(i);if(!r){console.warn(`Can not set qti-outcome-identifier: ${i}, it is not available`);return}this.testContext={...this.testContext,testOutcomeVariables:this.testContext.testOutcomeVariables?.map(s=>s.identifier!==i?s:{...s,value:r.cardinality==="single"?n:[...s.value,n]})}}getOutcome(i){return this.getVariable(i)}getVariable(i){return this.testContext.testOutcomeVariables?.find(n=>n.identifier===i)||null}}return t};var nh=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},Re=class extends Kd(Zd(rh(ih(vl(C))))){constructor(){super(),this.configContext={},this.qtiContext={QTI_CONTEXT:{testIdentifier:"",candidateIdentifier:"",environmentIdentifier:"default"}},new ve(this,{context:Ce,initialValue:this})}async connectedCallback(){super.connectedCallback(),await this.updateComplete,this.dispatchEvent(new CustomEvent("qti-test-connected",{detail:this}))}render(){return b`<slot></slot>`}};nh([T(),U({context:xt})],Re.prototype,"configContext",void 0);nh([T(),U({context:qt})],Re.prototype,"qtiContext",void 0);var ko=class{constructor(t){this.G=t}disconnect(){this.G=void 0}reconnect(t){this.G=t}deref(){return this.G}},Eo=class{constructor(){this.Y=void 0,this.Z=void 0}get(){return this.Y}pause(){this.Y??=new Promise(t=>this.Z=t)}resume(){this.Z?.(),this.Y=this.Z=void 0}};var oh=o=>!Bd(o)&&typeof o.then=="function",sh=1073741823,xl=class extends _e{constructor(){super(...arguments),this._$Cwt=sh,this._$Cbt=[],this._$CK=new ko(this),this._$CX=new Eo}render(...t){return t.find(e=>!oh(e))??rt}update(t,e){let i=this._$Cbt,n=i.length;this._$Cbt=e;let r=this._$CK,s=this._$CX;this.isConnected||this.disconnected();for(let a=0;a<e.length&&!(a>this._$Cwt);a++){let l=e[a];if(!oh(l))return this._$Cwt=a,l;a<n&&l===i[a]||(this._$Cwt=sh,n=0,Promise.resolve(l).then(async c=>{for(;s.get();)await s.get();let d=r.deref();if(d!==void 0){let h=d._$Cbt.indexOf(l);h>-1&&h<d._$Cwt&&(d._$Cwt=h,d.setValue(c))}}))}return rt}disconnected(){this._$CK.disconnect(),this._$CX.pause()}reconnected(){this._$CK.reconnect(this),this._$CX.resume()}},Ao=Ot(xl);var Io=`
225
225
  @layer qti-base, qti-components, qti-extended;
226
226
 
227
227
  @layer qti-components.reset, qti-components.global, qti-components.interactions.base,
@@ -2943,7 +2943,8 @@ Make sure to test your application with a production build as repeat registratio
2943
2943
  * (positionShapes), so they scale along \u2014 see qti-graphic-gap-match-interaction.styles.ts.
2944
2944
  * reset.css gives every picture inside an interaction \`max-width: none\`, which outranks that
2945
2945
  * component's ::slotted() rule, so the fluid sizing is restated here for the graphic alone: a
2946
- * direct child, never a chip's picture, which must keep its size in the bank and the hotspot.
2946
+ * direct child, never a chip's picture: a chip scales by the graphic's factor as a whole
2947
+ * (\`--qti-graphic-scale\`, qti-gap-img.styles.ts), the same in the bank and the hotspot.
2947
2948
  */
2948
2949
  qti-graphic-gap-match-interaction > img,qti-graphic-gap-match-interaction > object {
2949
2950
  max-width: 100%;
@@ -6305,11 +6306,11 @@ div.full-correct-response-inline {
6305
6306
  display: inline-block;
6306
6307
  }
6307
6308
  }
6308
- `;var Pe=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},St=class extends C{constructor(){super(...arguments),this.customElementRegistry=null,this.testURL=null,this.testDoc=null,this.testXML=null,this.qtiContext={QTI_CONTEXT:{testIdentifier:"",candidateIdentifier:"",environmentIdentifier:"default"}},this.#t=null,this.#e=null}#t;#e;createRenderRoot(){let t=this.customElementRegistry;return this.#e=t,this.shadowRoot??this.attachShadow({...this.constructor.shadowRootOptions,...t?{customElementRegistry:t}:{}})}async handleTestURLChange(){if(this.testURL)try{let t=this.qtiContext?.QTI_CONTEXT?.seed,e=(await Fi().load(this.testURL)).shuffleOrdering(t),i=this.testHost;if(i?.postLoadTestTransformCallback){let r=e.htmlDoc(this.#e??void 0).querySelector("qti-assessment-test");r&&(e=await i.postLoadTestTransformCallback(e,r))}this.#i(e.htmlDoc(this.#e??void 0))}catch(t){console.error("Error loading or parsing XML:",t)}}#i(t){this.testDoc=t,this.dispatchEvent(new CustomEvent("qti-testdoc-loaded",{bubbles:!0,composed:!0}))}handleTestXMLChange(){if(this.testXML)try{let t=this.qtiContext?.QTI_CONTEXT?.seed;this.#i(Fi().parse(this.testXML).shuffleOrdering(t).htmlDoc(this.#e??void 0))}catch(t){console.error("Error parsing XML:",t)}}async connectedCallback(){super.connectedCallback(),this.#r(),this.#n(),this.testURL&&this.handleTestURLChange(),this.testXML&&this.handleTestXMLChange()}#r(){let t=this.querySelector("template");this.#t=t?t.content:b``}#n(){let t=new CSSStyleSheet;t.replaceSync(Io),this.shadowRoot.adoptedStyleSheets=[t]}render(){return b`
6309
+ `;var Pe=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},kt=class extends C{constructor(){super(...arguments),this.customElementRegistry=null,this.testURL=null,this.testDoc=null,this.testXML=null,this.qtiContext={QTI_CONTEXT:{testIdentifier:"",candidateIdentifier:"",environmentIdentifier:"default"}},this.#t=null,this.#e=null}#t;#e;createRenderRoot(){let t=this.customElementRegistry;return this.#e=t,this.shadowRoot??this.attachShadow({...this.constructor.shadowRootOptions,...t?{customElementRegistry:t}:{}})}async handleTestURLChange(){if(this.testURL)try{let t=this.qtiContext?.QTI_CONTEXT?.seed,e=(await Bi().load(this.testURL)).shuffleOrdering(t),i=this.testHost;if(i?.postLoadTestTransformCallback){let r=e.htmlDoc(this.#e??void 0).querySelector("qti-assessment-test");r&&(e=await i.postLoadTestTransformCallback(e,r))}this.#i(e.htmlDoc(this.#e??void 0))}catch(t){console.error("Error loading or parsing XML:",t)}}#i(t){this.testDoc=t,this.dispatchEvent(new CustomEvent("qti-testdoc-loaded",{bubbles:!0,composed:!0}))}handleTestXMLChange(){if(this.testXML)try{let t=this.qtiContext?.QTI_CONTEXT?.seed;this.#i(Bi().parse(this.testXML).shuffleOrdering(t).htmlDoc(this.#e??void 0))}catch(t){console.error("Error parsing XML:",t)}}async connectedCallback(){super.connectedCallback(),this.#r(),this.#n(),this.testURL&&this.handleTestURLChange(),this.testXML&&this.handleTestXMLChange()}#r(){let t=this.querySelector("template");this.#t=t?t.content:b``}#n(){let t=new CSSStyleSheet;t.replaceSync(Io),this.shadowRoot.adoptedStyleSheets=[t]}render(){return b`
6309
6310
  ${this.#t}
6310
6311
  <slot></slot>
6311
6312
  ${Ao(this.testDoc,b`<span>Loading...</span>`)}
6312
- `}};Pe([p({attribute:!1})],St.prototype,"customElementRegistry",void 0);Pe([p({type:String,attribute:"test-url"})],St.prototype,"testURL",void 0);Pe([T()],St.prototype,"testDoc",void 0);Pe([T()],St.prototype,"testXML",void 0);Pe([_({context:Ce,subscribe:!0})],St.prototype,"testHost",void 0);Pe([T(),_({context:qt,subscribe:!0})],St.prototype,"qtiContext",void 0);Pe([L("testURL",{waitUntilFirstUpdate:!0})],St.prototype,"handleTestURLChange",null);Pe([L("testXML",{waitUntilFirstUpdate:!0})],St.prototype,"handleTestXMLChange",null);var ah=q`
6313
+ `}};Pe([p({attribute:!1})],kt.prototype,"customElementRegistry",void 0);Pe([p({type:String,attribute:"test-url"})],kt.prototype,"testURL",void 0);Pe([T()],kt.prototype,"testDoc",void 0);Pe([T()],kt.prototype,"testXML",void 0);Pe([_({context:Ce,subscribe:!0})],kt.prototype,"testHost",void 0);Pe([T(),_({context:qt,subscribe:!0})],kt.prototype,"qtiContext",void 0);Pe([L("testURL",{waitUntilFirstUpdate:!0})],kt.prototype,"handleTestURLChange",null);Pe([L("testXML",{waitUntilFirstUpdate:!0})],kt.prototype,"handleTestXMLChange",null);var ah=q`
6313
6314
  display: inline-flex;
6314
6315
  align-items: center;
6315
6316
  justify-content: center;
@@ -6336,7 +6337,7 @@ div.full-correct-response-inline {
6336
6337
  `,lt=q`
6337
6338
  cursor: not-allowed;
6338
6339
  opacity: 0.45;
6339
- `,ZC=q`
6340
+ `,tS=q`
6340
6341
  ${ah};
6341
6342
  border: 1px solid gray;
6342
6343
  `;var ql=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},oi=class extends C{_handleTestElementChange(t,e){e&&this.requestUpdate()}static{this.styles=q`
@@ -6365,7 +6366,7 @@ div.full-correct-response-inline {
6365
6366
  :host([disabled]) {
6366
6367
  ${lt};
6367
6368
  }
6368
- `}constructor(){super(),this.itemId=null,this.addEventListener("click",()=>this._requestItem(this.itemId))}_requestItem(t){V(this,"cito-test-navigate",{type:"item",id:t})}render(){return b` <slot></slot> `}};vm([p({type:String,attribute:"item-id"})],Zr.prototype,"itemId",void 0);var si=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},wm=()=>({QTI_CONTEXT:{testIdentifier:"",candidateIdentifier:"",environmentIdentifier:"default"}}),gt=class extends C{get qtiContext(){return this.#n()?.qtiContext??(this.#t??=wm())}set qtiContext(t){this.#e||(this.#e=!0,console.warn("[qti-components] `test-navigation.qtiContext` is deprecated and will be removed in the next major release. Set `qtiContext` on `<qti-test>` instead; it is the same value.")),this.#i(t)}#t;#e;#i(t){let e=this.#n();e?e.qtiContext=t:this.#t=t}#r;#n(){return this.#r.value??null}#o;#s;constructor(){super(),this.identifier=void 0,this.initContext=[],this.#e=!1,this.#r=new wt(this,{context:Ce,subscribe:!0,callback:t=>{t&&this.#t&&(t.qtiContext=this.#t,this.#t=void 0)}}),this.configContext={},this.autoScoreItems=!1,this.#s=new Map,this.#p=t=>this.#c(t)??null,H(this,"cito-test-loaded",this.#u.bind(this)),this.addEventListener("qti-assessment-item-connected",this.#b.bind(this)),fd(this,"cito-item-response-changed",this.#d.bind(this)),this.addEventListener("qti-item-context-updated",this.#a.bind(this)),H(this,"cito-test-end-attempt",this.#l.bind(this)),H(this,"cito-test-update-outcome",this.#m.bind(this))}#a(t){if(!t.detail?.responseProcessed)return;let e=t.detail.itemContext;if(!e?.identifier)return;let i=this.#y(e);this.#s.set(e.identifier,i);let n=this.computedItemFor(e.identifier),r=Number(e.variables?.find(a=>a.identifier==="numAttempts")?.value)||0,s=e.variables?.find(a=>a.identifier==="completionStatus")?.value;this.afterAttemptEnded(t.composedPath()[0]?.closest("qti-assessment-item"),n,this.#f(r,i,n?.maxAttempts,n?.adaptive,s))}afterAttemptEnded(t,e,i){}computedItemFor(t){return this.computedContext?.testParts?.flatMap(e=>e.sections).flatMap(e=>e.items).find(e=>e.identifier===t)}#c(t){return t?this.#o?.querySelector(`qti-assessment-item-ref[identifier="${CSS.escape(t)}"]`)?.assessmentItem??void 0:void 0}#p;get activeAssessmentItem(){if(!(!this.#o||!this._sessionContext?.navItemRefId))return this.#o.querySelector(`qti-assessment-item-ref[identifier="${this._sessionContext.navItemRefId}"]`)?.assessmentItem}#l(t){let e=this.activeAssessmentItem;if(!e)return;let i=this.configContext?.reportValidityAfterScoring===!0;e.processResponse(!0,i)}#m(t){let e=this.#c(t.detail?.assessmentItemRefId);e&&e.setOutcomeVariable(t.detail.outcomeVariableId,t.detail.value)}#d(t){if(this.autoScoreItems){let e=t.composedPath()[0].closest("qti-assessment-item");if(!e)return;let i=e.variables.find(n=>n.identifier==="SCORE");if(i&&i.externalScored===null&&e.adaptive==="false"){let n=this.configContext?.reportValidityAfterScoring===!0;e.processResponse(!0,n)}}}render(){return b`<slot></slot>`}#u(t){if(this.#o=t.detail,this.#s.clear(),!this.qtiContext.QTI_CONTEXT?.testIdentifier){let n=this.qtiContext.QTI_CONTEXT||{testIdentifier:"",candidateIdentifier:"not set",environmentIdentifier:"default"};this.#i({QTI_CONTEXT:{...n,testIdentifier:this.#o.identifier,environmentIdentifier:n.environmentIdentifier||"default"}})}this.#o.querySelectorAll('qti-context-declaration[identifier="QTI_CONTEXT"]').forEach(n=>{let r=this.#h(n);Object.keys(r).length>0&&this.#i({QTI_CONTEXT:{...r,...this.qtiContext.QTI_CONTEXT}})});let i=Array.from(this.#o?.querySelectorAll("qti-test-part")||[]);this.computedContext={itemElement:this.#p,identifier:this.#o.identifier,title:this.#o.title,view:this._sessionContext?.view,plugins:this._sessionContext?.plugins??{},testParts:i.map(n=>{let r=[...n.querySelectorAll("qti-assessment-section")],s=n.querySelector(":scope > qti-item-session-control"),a=s?s.allowSkipping:!0,l=s?s.maxAttempts:1,c=s?s.showFeedback:!1,d=s?s.showSolution:!1;return{active:!1,identifier:n.identifier,navigationMode:n.navigationMode,submissionMode:n.submissionMode,allowSkipping:a,sections:r.map(h=>{let f=[...h.querySelectorAll("qti-assessment-item-ref")],m=h.querySelector(":scope > qti-item-session-control"),v=m?m.allowSkipping:a,x=m?m.maxAttempts:l,u=m?m.showFeedback:c,g=m?m.showSolution:d;return{active:!1,identifier:h.identifier,title:h.title,navigationMode:h.navigationMode,submissionMode:h.submissionMode,allowSkipping:v,items:f.map(y=>{let w=y.querySelector(":scope > qti-item-session-control"),I=w?w.allowSkipping:v,A=w?w.maxAttempts:x,S=w?w.showFeedback:u,k=w?w.showSolution:g;return{...this.initContext?.find(R=>R.identifier===y.identifier),active:!1,identifier:y.identifier,categories:y.category?y.category?.split(" "):[],href:y.href,variables:[],allowSkipping:I,maxAttempts:A,showFeedback:S,showSolution:k}})}})}})}}#h(t){let e={},i=t.querySelector("qti-default-value");return i&&i.querySelectorAll("qti-value[field-identifier]").forEach(r=>{let s=r.getAttribute("field-identifier"),a=r.getAttribute("base-type")||"string",l=r.textContent?.trim()||"";if(s){let c=l;switch(a){case"integer":c=parseInt(l,10);break;case"float":case"duration":c=parseFloat(l);break;case"boolean":c=l.toLowerCase()==="true";break;default:c=l;break}e[s]=c}}),e}#b(t){let e=t.detail;this.computedContext={...this.computedContext,testParts:this.computedContext.testParts.map(i=>({...i,sections:i.sections.map(n=>({...n,items:n.items.map(r=>{if(r.identifier!==e.parentElement.getAttribute("identifier"))return r;let a=e.querySelector("qti-outcome-declaration[identifier='SCORE']")?.getAttribute("externalScored"),l=e.querySelectorAll("qti-response-declaration"),c=Array.from(l).some(m=>m.querySelector("qti-correct-response")),d=Array.from(l).some(m=>{let v=m.querySelector("qti-mapping"),x=m.querySelector("qti-area-mapping");return v?.querySelector("qti-map-entry")||x?.querySelector("qti-area-map-entry")}),h=c||d,f=!!e.querySelector("qti-response-processing");return{...r,assessmentItemIdentifier:e.getAttribute("identifier"),label:e.getAttribute("label"),title:e.title,externalScored:a,adaptive:e.adaptive=="true"||!1,timeDependent:e.timeDependent=="true"||!1,variables:e.variables,hasCorrectResponse:h,hasResponseProcessing:f}})}))}))}}willUpdate(t){if(!this.computedContext)return;let e=1;this.computedContext={...this.computedContext,view:this._sessionContext?.view,plugins:this._sessionContext?.plugins??{},testParts:this.computedContext.testParts.map(i=>({...i,active:this._sessionContext?.navPartId===i.identifier||!1,sections:i.sections.map(n=>({...n,active:this._sessionContext?.navSectionId===n.identifier||!1,completed:n.items.every(r=>this._testContext.items.find(s=>s.identifier===r.identifier)?.variables.find(s=>s.identifier==="completionStatus").value==="completed"),items:n.items.map(r=>{let s=this._testContext?.items.find(S=>S.identifier===r.identifier),a={...r,...s,...this.initContext?.find(S=>S.identifier===r.identifier)},l=a.variables?.find(S=>S.identifier=="SCORE")?.value,c=l==null?null:parseFloat(l?.toString()),d=a.variables?.find(S=>S.identifier==="completionStatus")?.value,h=a.variables?.find(S=>S.identifier==="RESPONSE")?.value||"",f=Number(a.variables?.find(S=>S.identifier==="numAttempts")?.value)||0,m=this._sessionContext?.navItemRefId===a.identifier||!1,v=s?.valid??!0,u=(s?.variables?.filter(S=>S.type==="response")||[]).every(S=>{if(S.value===void 0||S.value===null)return!0;let k;switch(S.baseType){case"integer":case"float":case"duration":k="0";break;case"boolean":k="false";break;default:k="";break}let R=S.defaultValue??k;if(Array.isArray(S.value)){let N=Array.isArray(R)?R:[R];return S.value.length===N.length&&S.value.every((z,$)=>z===N[$])}return S.value===R}),g=r.categories.includes(this.configContext?.infoItemCategory)?null:e++,y=r.variables?.find(S=>S.identifier=="MAXSCORE")?.value,w=y==null?null:parseFloat(y?.toString()),I=this.#s.get(a.identifier);I===void 0&&(I=s?this.#y(s):"unscored",f>0&&this.#s.set(a.identifier,I));let A=this.#f(f,I,a.maxAttempts,a.adaptive,d);return{...a,completionStatus:d,numAttempts:f,score:c,response:h,index:g,active:m,valid:v,isDefaultResponse:u,maxScore:w,done:A,optimal:this.#s.get(a.identifier)==="optimal"}})}))}))},this.dispatchEvent(new CustomEvent("qti-computed-context-updated",{detail:this.computedContext,bubbles:!0}))}#f(t,e,i,n,r){if(t===0)return!1;if(n)return r==="completed";if(e!=="suboptimal")return!0;let s=i??1;return s>0&&t>=s}#y(t){let e=t.variables??[],i=this.#g(e,"SCORE"),n=this.#g(e,"MAXSCORE");if(i!==null&&n!==null)return i>=n?"optimal":"suboptimal";let r=e.filter(a=>a.type==="response"&&a.correctResponse!==void 0&&a.correctResponse!==null);return r.length===0?"unscored":r.every(a=>{let l=a.correctResponse,c=a.value;return c==null?!1:Array.isArray(l)&&Array.isArray(c)?l.length===c.length&&l.every(d=>c.includes(d)):Array.isArray(l)||Array.isArray(c)?!1:l===c})?"optimal":"suboptimal"}#g(t,e){let i=t?.find(r=>r.identifier===e)?.value;if(i==null||Array.isArray(i))return null;let n=parseFloat(i.toString());return Number.isNaN(n)?null:n}};si([p({type:String})],gt.prototype,"identifier",void 0);si([T()],gt.prototype,"initContext",void 0);si([T(),_({context:xt,subscribe:!0})],gt.prototype,"configContext",void 0);si([T(),_({context:nt,subscribe:!0})],gt.prototype,"_testContext",void 0);si([T(),_({context:qe,subscribe:!0})],gt.prototype,"_sessionContext",void 0);si([T(),U({context:j})],gt.prototype,"computedContext",void 0);si([p({type:Boolean,attribute:"auto-score-items"})],gt.prototype,"autoScoreItems",void 0);var Cl=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},ai=class extends C{_handleTestElementChange(t,e){e&&this.requestUpdate()}static{this.styles=q`
6369
+ `}constructor(){super(),this.itemId=null,this.addEventListener("click",()=>this._requestItem(this.itemId))}_requestItem(t){V(this,"cito-test-navigate",{type:"item",id:t})}render(){return b` <slot></slot> `}};vm([p({type:String,attribute:"item-id"})],Zr.prototype,"itemId",void 0);var si=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},wm=()=>({QTI_CONTEXT:{testIdentifier:"",candidateIdentifier:"",environmentIdentifier:"default"}}),gt=class extends C{get qtiContext(){return this.#n()?.qtiContext??(this.#t??=wm())}set qtiContext(t){this.#e||(this.#e=!0,console.warn("[qti-components] `test-navigation.qtiContext` is deprecated and will be removed in the next major release. Set `qtiContext` on `<qti-test>` instead; it is the same value.")),this.#i(t)}#t;#e;#i(t){let e=this.#n();e?e.qtiContext=t:this.#t=t}#r;#n(){return this.#r.value??null}#o;#s;constructor(){super(),this.identifier=void 0,this.initContext=[],this.#e=!1,this.#r=new wt(this,{context:Ce,subscribe:!0,callback:t=>{t&&this.#t&&(t.qtiContext=this.#t,this.#t=void 0)}}),this.configContext={},this.autoScoreItems=!1,this.#s=new Map,this.#p=t=>this.#c(t)??null,H(this,"cito-test-loaded",this.#u.bind(this)),this.addEventListener("qti-assessment-item-connected",this.#b.bind(this)),fd(this,"cito-item-response-changed",this.#d.bind(this)),this.addEventListener("qti-item-context-updated",this.#a.bind(this)),H(this,"cito-test-end-attempt",this.#l.bind(this)),H(this,"cito-test-update-outcome",this.#m.bind(this))}#a(t){if(!t.detail?.responseProcessed)return;let e=t.detail.itemContext;if(!e?.identifier)return;let i=this.#y(e);this.#s.set(e.identifier,i);let n=this.computedItemFor(e.identifier),r=Number(e.variables?.find(a=>a.identifier==="numAttempts")?.value)||0,s=e.variables?.find(a=>a.identifier==="completionStatus")?.value;this.afterAttemptEnded(t.composedPath()[0]?.closest("qti-assessment-item"),n,this.#f(r,i,n?.maxAttempts,n?.adaptive,s))}afterAttemptEnded(t,e,i){}computedItemFor(t){return this.computedContext?.testParts?.flatMap(e=>e.sections).flatMap(e=>e.items).find(e=>e.identifier===t)}#c(t){return t?this.#o?.querySelector(`qti-assessment-item-ref[identifier="${CSS.escape(t)}"]`)?.assessmentItem??void 0:void 0}#p;get activeAssessmentItem(){if(!(!this.#o||!this._sessionContext?.navItemRefId))return this.#o.querySelector(`qti-assessment-item-ref[identifier="${this._sessionContext.navItemRefId}"]`)?.assessmentItem}#l(t){let e=this.activeAssessmentItem;if(!e)return;let i=this.configContext?.reportValidityAfterScoring===!0;e.processResponse(!0,i)}#m(t){let e=this.#c(t.detail?.assessmentItemRefId);e&&e.setOutcomeVariable(t.detail.outcomeVariableId,t.detail.value)}#d(t){if(this.autoScoreItems){let e=t.composedPath()[0].closest("qti-assessment-item");if(!e)return;let i=e.variables.find(n=>n.identifier==="SCORE");if(i&&i.externalScored===null&&e.adaptive==="false"){let n=this.configContext?.reportValidityAfterScoring===!0;e.processResponse(!0,n)}}}render(){return b`<slot></slot>`}#u(t){if(this.#o=t.detail,this.#s.clear(),!this.qtiContext.QTI_CONTEXT?.testIdentifier){let n=this.qtiContext.QTI_CONTEXT||{testIdentifier:"",candidateIdentifier:"not set",environmentIdentifier:"default"};this.#i({QTI_CONTEXT:{...n,testIdentifier:this.#o.identifier,environmentIdentifier:n.environmentIdentifier||"default"}})}this.#o.querySelectorAll('qti-context-declaration[identifier="QTI_CONTEXT"]').forEach(n=>{let r=this.#h(n);Object.keys(r).length>0&&this.#i({QTI_CONTEXT:{...r,...this.qtiContext.QTI_CONTEXT}})});let i=Array.from(this.#o?.querySelectorAll("qti-test-part")||[]);this.computedContext={itemElement:this.#p,identifier:this.#o.identifier,title:this.#o.title,view:this._sessionContext?.view,plugins:this._sessionContext?.plugins??{},testParts:i.map(n=>{let r=[...n.querySelectorAll("qti-assessment-section")],s=n.querySelector(":scope > qti-item-session-control"),a=s?s.allowSkipping:!0,l=s?s.maxAttempts:1,c=s?s.showFeedback:!1,d=s?s.showSolution:!1;return{active:!1,identifier:n.identifier,navigationMode:n.navigationMode,submissionMode:n.submissionMode,allowSkipping:a,sections:r.map(h=>{let f=[...h.querySelectorAll("qti-assessment-item-ref")],m=h.querySelector(":scope > qti-item-session-control"),v=m?m.allowSkipping:a,x=m?m.maxAttempts:l,u=m?m.showFeedback:c,g=m?m.showSolution:d;return{active:!1,identifier:h.identifier,title:h.title,navigationMode:h.navigationMode,submissionMode:h.submissionMode,allowSkipping:v,items:f.map(y=>{let w=y.querySelector(":scope > qti-item-session-control"),I=w?w.allowSkipping:v,A=w?w.maxAttempts:x,k=w?w.showFeedback:u,S=w?w.showSolution:g;return{...this.initContext?.find(R=>R.identifier===y.identifier),active:!1,identifier:y.identifier,categories:y.category?y.category?.split(" "):[],href:y.href,variables:[],allowSkipping:I,maxAttempts:A,showFeedback:k,showSolution:S}})}})}})}}#h(t){let e={},i=t.querySelector("qti-default-value");return i&&i.querySelectorAll("qti-value[field-identifier]").forEach(r=>{let s=r.getAttribute("field-identifier"),a=r.getAttribute("base-type")||"string",l=r.textContent?.trim()||"";if(s){let c=l;switch(a){case"integer":c=parseInt(l,10);break;case"float":case"duration":c=parseFloat(l);break;case"boolean":c=l.toLowerCase()==="true";break;default:c=l;break}e[s]=c}}),e}#b(t){let e=t.detail;this.computedContext={...this.computedContext,testParts:this.computedContext.testParts.map(i=>({...i,sections:i.sections.map(n=>({...n,items:n.items.map(r=>{if(r.identifier!==e.parentElement.getAttribute("identifier"))return r;let a=e.querySelector("qti-outcome-declaration[identifier='SCORE']")?.getAttribute("externalScored"),l=e.querySelectorAll("qti-response-declaration"),c=Array.from(l).some(m=>m.querySelector("qti-correct-response")),d=Array.from(l).some(m=>{let v=m.querySelector("qti-mapping"),x=m.querySelector("qti-area-mapping");return v?.querySelector("qti-map-entry")||x?.querySelector("qti-area-map-entry")}),h=c||d,f=!!e.querySelector("qti-response-processing");return{...r,assessmentItemIdentifier:e.getAttribute("identifier"),label:e.getAttribute("label"),title:e.title,externalScored:a,adaptive:e.adaptive=="true"||!1,timeDependent:e.timeDependent=="true"||!1,variables:e.variables,hasCorrectResponse:h,hasResponseProcessing:f}})}))}))}}willUpdate(t){if(!this.computedContext)return;let e=1;this.computedContext={...this.computedContext,view:this._sessionContext?.view,plugins:this._sessionContext?.plugins??{},testParts:this.computedContext.testParts.map(i=>({...i,active:this._sessionContext?.navPartId===i.identifier||!1,sections:i.sections.map(n=>({...n,active:this._sessionContext?.navSectionId===n.identifier||!1,completed:n.items.every(r=>this._testContext.items.find(s=>s.identifier===r.identifier)?.variables.find(s=>s.identifier==="completionStatus").value==="completed"),items:n.items.map(r=>{let s=this._testContext?.items.find(k=>k.identifier===r.identifier),a={...r,...s,...this.initContext?.find(k=>k.identifier===r.identifier)},l=a.variables?.find(k=>k.identifier=="SCORE")?.value,c=l==null?null:parseFloat(l?.toString()),d=a.variables?.find(k=>k.identifier==="completionStatus")?.value,h=a.variables?.find(k=>k.identifier==="RESPONSE")?.value||"",f=Number(a.variables?.find(k=>k.identifier==="numAttempts")?.value)||0,m=this._sessionContext?.navItemRefId===a.identifier||!1,v=s?.valid??!0,u=(s?.variables?.filter(k=>k.type==="response")||[]).every(k=>{if(k.value===void 0||k.value===null)return!0;let S;switch(k.baseType){case"integer":case"float":case"duration":S="0";break;case"boolean":S="false";break;default:S="";break}let R=k.defaultValue??S;if(Array.isArray(k.value)){let N=Array.isArray(R)?R:[R];return k.value.length===N.length&&k.value.every((z,$)=>z===N[$])}return k.value===R}),g=r.categories.includes(this.configContext?.infoItemCategory)?null:e++,y=r.variables?.find(k=>k.identifier=="MAXSCORE")?.value,w=y==null?null:parseFloat(y?.toString()),I=this.#s.get(a.identifier);I===void 0&&(I=s?this.#y(s):"unscored",f>0&&this.#s.set(a.identifier,I));let A=this.#f(f,I,a.maxAttempts,a.adaptive,d);return{...a,completionStatus:d,numAttempts:f,score:c,response:h,index:g,active:m,valid:v,isDefaultResponse:u,maxScore:w,done:A,optimal:this.#s.get(a.identifier)==="optimal"}})}))}))},this.dispatchEvent(new CustomEvent("qti-computed-context-updated",{detail:this.computedContext,bubbles:!0}))}#f(t,e,i,n,r){if(t===0)return!1;if(n)return r==="completed";if(e!=="suboptimal")return!0;let s=i??1;return s>0&&t>=s}#y(t){let e=t.variables??[],i=this.#g(e,"SCORE"),n=this.#g(e,"MAXSCORE");if(i!==null&&n!==null)return i>=n?"optimal":"suboptimal";let r=e.filter(a=>a.type==="response"&&a.correctResponse!==void 0&&a.correctResponse!==null);return r.length===0?"unscored":r.every(a=>{let l=a.correctResponse,c=a.value;return c==null?!1:Array.isArray(l)&&Array.isArray(c)?l.length===c.length&&l.every(d=>c.includes(d)):Array.isArray(l)||Array.isArray(c)?!1:l===c})?"optimal":"suboptimal"}#g(t,e){let i=t?.find(r=>r.identifier===e)?.value;if(i==null||Array.isArray(i))return null;let n=parseFloat(i.toString());return Number.isNaN(n)?null:n}};si([p({type:String})],gt.prototype,"identifier",void 0);si([T()],gt.prototype,"initContext",void 0);si([T(),_({context:xt,subscribe:!0})],gt.prototype,"configContext",void 0);si([T(),_({context:nt,subscribe:!0})],gt.prototype,"_testContext",void 0);si([T(),_({context:qe,subscribe:!0})],gt.prototype,"_sessionContext",void 0);si([T(),U({context:j})],gt.prototype,"computedContext",void 0);si([p({type:Boolean,attribute:"auto-score-items"})],gt.prototype,"autoScoreItems",void 0);var Cl=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},ai=class extends C{_handleTestElementChange(t,e){e&&this.requestUpdate()}static{this.styles=q`
6369
6370
  :host {
6370
6371
  ${ot};
6371
6372
  }
@@ -6378,7 +6379,7 @@ div.full-correct-response-inline {
6378
6379
  :host([disabled]) {
6379
6380
  ${lt};
6380
6381
  }
6381
- `}#t;constructor(){super(),this._internalDisabled=!0,this.#t=this.attachInternals(),this.#t.role="button",this.#t.ariaLabel="Next item",this.addEventListener("click",t=>{t.preventDefault(),this._internalDisabled||this._requestItem(this.sectionItems[this.itemIndex+1].identifier)})}connectedCallback(){super.connectedCallback(),this.checkDisabled()}willUpdate(t){if(!this.computedContext)return;let e=this.computedContext?.testParts.find(i=>i.active);e&&(this.sectionItems=e.sections.flatMap(i=>i.items),this.itemIndex=this.sectionItems.findIndex(i=>i.active),this.checkDisabled())}checkDisabled(){let t=this.computedContext?.testParts.find(a=>a.active);if(!t)return;let e=t.sections.find(a=>a.active),i=e?.navigationMode||t.navigationMode,n=e?.submissionMode||t.submissionMode,r=this.sectionItems[this.itemIndex],s=i==="linear"&&n==="individual";this._internalDisabled=!this.computedContext||this.itemIndex<0||this.itemIndex>=(this.sectionItems?.length??0)-1||s&&!r?.done}_requestItem(t){V(this,"cito-test-navigate",{type:"item",id:t})}render(){return b`<slot></slot>`}};Cl([p({type:Boolean,reflect:!0,attribute:"disabled"})],ai.prototype,"_internalDisabled",void 0);Cl([_({context:j,subscribe:!0})],ai.prototype,"computedContext",void 0);Cl([L("computedContext")],ai.prototype,"_handleTestElementChange",null);var kl=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},li=class extends C{_handleTestElementChange(t,e){e&&this.requestUpdate()}static{this.styles=q`
6382
+ `}#t;constructor(){super(),this._internalDisabled=!0,this.#t=this.attachInternals(),this.#t.role="button",this.#t.ariaLabel="Next item",this.addEventListener("click",t=>{t.preventDefault(),this._internalDisabled||this._requestItem(this.sectionItems[this.itemIndex+1].identifier)})}connectedCallback(){super.connectedCallback(),this.checkDisabled()}willUpdate(t){if(!this.computedContext)return;let e=this.computedContext?.testParts.find(i=>i.active);e&&(this.sectionItems=e.sections.flatMap(i=>i.items),this.itemIndex=this.sectionItems.findIndex(i=>i.active),this.checkDisabled())}checkDisabled(){let t=this.computedContext?.testParts.find(a=>a.active);if(!t)return;let e=t.sections.find(a=>a.active),i=e?.navigationMode||t.navigationMode,n=e?.submissionMode||t.submissionMode,r=this.sectionItems[this.itemIndex],s=i==="linear"&&n==="individual";this._internalDisabled=!this.computedContext||this.itemIndex<0||this.itemIndex>=(this.sectionItems?.length??0)-1||s&&!r?.done}_requestItem(t){V(this,"cito-test-navigate",{type:"item",id:t})}render(){return b`<slot></slot>`}};Cl([p({type:Boolean,reflect:!0,attribute:"disabled"})],ai.prototype,"_internalDisabled",void 0);Cl([_({context:j,subscribe:!0})],ai.prototype,"computedContext",void 0);Cl([L("computedContext")],ai.prototype,"_handleTestElementChange",null);var Sl=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},li=class extends C{_handleTestElementChange(t,e){e&&this.requestUpdate()}static{this.styles=q`
6382
6383
  :host {
6383
6384
  ${ot};
6384
6385
  }
@@ -6391,7 +6392,7 @@ div.full-correct-response-inline {
6391
6392
  :host([disabled]) {
6392
6393
  ${lt};
6393
6394
  }
6394
- `}constructor(){super(),this._internalDisabled=!0,this.addEventListener("click",t=>{t.preventDefault(),this._internalDisabled||this._requestItem(this.sectionItems[this.itemIndex-1].identifier)})}willUpdate(t){if(!this.computedContext)return;let e=this.computedContext?.testParts.find(i=>i.active);e&&(this.sectionItems=e.sections.flatMap(i=>i.items),this.itemIndex=this.sectionItems.findIndex(i=>i.active),this.checkDisabled())}checkDisabled(){let t=this.computedContext?.testParts.find(n=>n.active),i=t?.sections.find(n=>n.active)?.navigationMode||t?.navigationMode||"nonlinear";this._internalDisabled=i==="linear"||!this.computedContext||this.itemIndex===0||this.itemIndex===-1}_requestItem(t){V(this,"cito-test-navigate",{type:"item",id:t})}render(){return b`<slot></slot>`}};kl([p({type:Boolean,reflect:!0,attribute:"disabled"})],li.prototype,"_internalDisabled",void 0);kl([_({context:j,subscribe:!0})],li.prototype,"computedContext",void 0);kl([L("computedContext")],li.prototype,"_handleTestElementChange",null);var xm=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},tn=class extends C{static{this.styles=q`
6395
+ `}constructor(){super(),this._internalDisabled=!0,this.addEventListener("click",t=>{t.preventDefault(),this._internalDisabled||this._requestItem(this.sectionItems[this.itemIndex-1].identifier)})}willUpdate(t){if(!this.computedContext)return;let e=this.computedContext?.testParts.find(i=>i.active);e&&(this.sectionItems=e.sections.flatMap(i=>i.items),this.itemIndex=this.sectionItems.findIndex(i=>i.active),this.checkDisabled())}checkDisabled(){let t=this.computedContext?.testParts.find(n=>n.active),i=t?.sections.find(n=>n.active)?.navigationMode||t?.navigationMode||"nonlinear";this._internalDisabled=i==="linear"||!this.computedContext||this.itemIndex===0||this.itemIndex===-1}_requestItem(t){V(this,"cito-test-navigate",{type:"item",id:t})}render(){return b`<slot></slot>`}};Sl([p({type:Boolean,reflect:!0,attribute:"disabled"})],li.prototype,"_internalDisabled",void 0);Sl([_({context:j,subscribe:!0})],li.prototype,"computedContext",void 0);Sl([L("computedContext")],li.prototype,"_handleTestElementChange",null);var xm=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},tn=class extends C{static{this.styles=q`
6395
6396
  :host {
6396
6397
  ${ot};
6397
6398
  }
@@ -6404,7 +6405,7 @@ div.full-correct-response-inline {
6404
6405
  :host([disabled]) {
6405
6406
  ${lt};
6406
6407
  }
6407
- `}#t(t){V(this,"cito-test-navigate",{type:"section",id:t})}constructor(){super(),this.sectionId=null,this.addEventListener("click",()=>this.#t(this.sectionId))}render(){return b` <slot></slot> `}};xm([p({type:String,attribute:"section-id"})],tn.prototype,"sectionId",void 0);var lh=(o,t)=>o?.plugins?.[t];var _o=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},Sl=o=>lh(o,"bookmarks")??[],ch=o=>{let t=o.closest("qti-assessment-item-ref");if(t)return t.getAttribute("identifier")??void 0;let e=o.getRootNode();return e instanceof ShadowRoot?ch(e.host):void 0},Me=class extends C{static{this.styles=q`
6408
+ `}#t(t){V(this,"cito-test-navigate",{type:"section",id:t})}constructor(){super(),this.sectionId=null,this.addEventListener("click",()=>this.#t(this.sectionId))}render(){return b` <slot></slot> `}};xm([p({type:String,attribute:"section-id"})],tn.prototype,"sectionId",void 0);var lh=(o,t)=>o?.plugins?.[t];var _o=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},kl=o=>lh(o,"bookmarks")??[],ch=o=>{let t=o.closest("qti-assessment-item-ref");if(t)return t.getAttribute("identifier")??void 0;let e=o.getRootNode();return e instanceof ShadowRoot?ch(e.host):void 0},Me=class extends C{static{this.styles=q`
6408
6409
  :host {
6409
6410
  ${ot};
6410
6411
  }
@@ -6437,7 +6438,7 @@ div.full-correct-response-inline {
6437
6438
  :host([disabled]) {
6438
6439
  ${lt};
6439
6440
  }
6440
- `}constructor(){super(),this.bookmarked=!1,this.disabled=!1,this.addEventListener("click",()=>this.#e()),this.addEventListener("keydown",t=>{t.key!=="Enter"&&t.key!==" "||(t.preventDefault(),this.#e())})}connectedCallback(){super.connectedCallback(),this.hasAttribute("role")||this.setAttribute("role","button"),this.hasAttribute("tabindex")||this.setAttribute("tabindex","0")}get#t(){return this.item||(ch(this)??this.computedContext?.testParts?.flatMap(t=>t.sections.flatMap(e=>e.items)).find(t=>t.active)?.identifier)}willUpdate(){let t=this.#t;this.disabled=!t,this.bookmarked=!!t&&Sl(this.computedContext).includes(t)}updated(){this.setAttribute("aria-pressed",String(this.bookmarked)),this.setAttribute("aria-disabled",String(this.disabled))}#e(){let t=this.#t;if(!t)return;let e=Sl(this.computedContext),i=e.includes(t)?e.filter(n=>n!==t):[...e,t];V(this,"cito-test-update-plugin-state",{plugin:"bookmarks",value:i.length>0?i:null})}render(){return b`<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M6 3h12v18l-6-4.5L6 21z" /></svg><slot></slot>`}};_o([_({context:j,subscribe:!0}),p({attribute:!1})],Me.prototype,"computedContext",void 0);_o([p({reflect:!0})],Me.prototype,"item",void 0);_o([p({type:Boolean,reflect:!0})],Me.prototype,"bookmarked",void 0);_o([p({type:Boolean,reflect:!0})],Me.prototype,"disabled",void 0);var qm=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},ci=class extends C{static{this.styles=q`
6441
+ `}constructor(){super(),this.bookmarked=!1,this.disabled=!1,this.addEventListener("click",()=>this.#e()),this.addEventListener("keydown",t=>{t.key!=="Enter"&&t.key!==" "||(t.preventDefault(),this.#e())})}connectedCallback(){super.connectedCallback(),this.hasAttribute("role")||this.setAttribute("role","button"),this.hasAttribute("tabindex")||this.setAttribute("tabindex","0")}get#t(){return this.item||(ch(this)??this.computedContext?.testParts?.flatMap(t=>t.sections.flatMap(e=>e.items)).find(t=>t.active)?.identifier)}willUpdate(){let t=this.#t;this.disabled=!t,this.bookmarked=!!t&&kl(this.computedContext).includes(t)}updated(){this.setAttribute("aria-pressed",String(this.bookmarked)),this.setAttribute("aria-disabled",String(this.disabled))}#e(){let t=this.#t;if(!t)return;let e=kl(this.computedContext),i=e.includes(t)?e.filter(n=>n!==t):[...e,t];V(this,"cito-test-update-plugin-state",{plugin:"bookmarks",value:i.length>0?i:null})}render(){return b`<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M6 3h12v18l-6-4.5L6 21z" /></svg><slot></slot>`}};_o([_({context:j,subscribe:!0}),p({attribute:!1})],Me.prototype,"computedContext",void 0);_o([p({reflect:!0})],Me.prototype,"item",void 0);_o([p({type:Boolean,reflect:!0})],Me.prototype,"bookmarked",void 0);_o([p({type:Boolean,reflect:!0})],Me.prototype,"disabled",void 0);var qm=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},ci=class extends C{static{this.styles=q`
6441
6442
  :host {
6442
6443
  ${ot};
6443
6444
  }
@@ -6450,7 +6451,7 @@ div.full-correct-response-inline {
6450
6451
  :host([disabled]) {
6451
6452
  ${lt};
6452
6453
  }
6453
- `}constructor(){super(),this.view="scorer",this.addEventListener("click",()=>{V(this,"cito-test-end-attempt",{}),V(this,"cito-test-switch-view",this.view)})}render(){return b` <slot></slot> `}};qm([p({type:String})],ci.prototype,"view",void 0);var Cm=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},en=class extends C{render(){return b` <small><pre>${JSON.stringify(this.computedContext,null,2)}</pre></small> `}};Cm([T(),_({context:j,subscribe:!0})],en.prototype,"computedContext",void 0);var km=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},rn=class extends C{static{this.styles=q`
6454
+ `}constructor(){super(),this.view="scorer",this.addEventListener("click",()=>{V(this,"cito-test-end-attempt",{}),V(this,"cito-test-switch-view",this.view)})}render(){return b` <slot></slot> `}};qm([p({type:String})],ci.prototype,"view",void 0);var Cm=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},en=class extends C{render(){return b` <small><pre>${JSON.stringify(this.computedContext,null,2)}</pre></small> `}};Cm([T(),_({context:j,subscribe:!0})],en.prototype,"computedContext",void 0);var Sm=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},rn=class extends C{static{this.styles=q`
6454
6455
  table {
6455
6456
  width: 100%;
6456
6457
  border-collapse: collapse;
@@ -6497,7 +6498,7 @@ div.full-correct-response-inline {
6497
6498
  </table>
6498
6499
  `;return b`
6499
6500
  ${n(e,"Response Variables")} ${n(i,"Outcome Variables")}
6500
- `}};km([_({context:j,subscribe:!0})],rn.prototype,"computedContext",void 0);var El=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},di=class extends C{createRenderRoot(){return this}connectedCallback(){super.connectedCallback();let t=this.querySelector("template");if(!t){this.myTemplate=null;return}this.myTemplate=we(t)}#t(t){let n=(this.computedContext?.testParts.find(r=>r.active)).sections.flatMap(r=>r.items).find(r=>r.active)?.identifier;V(this,"cito-test-update-outcome",{assessmentItemRefId:n,outcomeVariableId:"SCORE",value:t})}render(){let t=this.computedContext?.testParts.flatMap(a=>a.sections.flatMap(l=>l.items)).find(a=>a.active);if(!t||!t.variables)return b``;let e=t.variables.find(a=>a.identifier=="MAXSCORE")?.value,i=t.variables.find(a=>a.identifier=="SCORE"),n=i?.value,r=i?.externalScored!=="human";if(!e||!i)return O;let s=[...Array(Number(e)+1).keys()];return b`${this.myTemplate?this.myTemplate({scores:s,score:n,disabled:r}):O}`}constructor(){super(),this.view="",this.disabled=!1,this.myTemplate=null,this.addEventListener("click",t=>{let e=t.target,i=parseFloat(e.value);e.tagName==="INPUT"&&this.#t(i)})}};El([p({type:String,attribute:"view"})],di.prototype,"view",void 0);El([p({type:Boolean})],di.prototype,"disabled",void 0);El([_({context:j,subscribe:!0})],di.prototype,"computedContext",void 0);var dh=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},Xi=class extends C{constructor(){super(...arguments),this.view=null}render(){let t=this.computedContext?.testParts.flatMap(a=>a.sections.flatMap(l=>l.items)).find(a=>a.active);if(!t||!t.variables)return b``;if(t.category==="dep-informational")return b`<div>${this.dataset.informational}</div>`;let e=t?.variables.find(a=>a.identifier==="completionStatus")?.value,i=t?.variables.find(a=>a.identifier=="SCORE"),n=parseFloat(i?.value),r=t.externalScored;return b`<div>${e!=="completed"?this.dataset.textNoResponse:!r&&n!==void 0&&!Number.isNaN(n)?n>0?this.dataset.textCorrect:this.dataset.textIncorrect:r==="externalMachine"?Number.isNaN(n)||n===void 0?this.dataset.scoreUnknown:`We hebben je antwoord ${n===0?"geen punten":n==1?"\xE9\xE9n punt":`${n} punten`} gegeven. Je kunt je score zelf aanpassen als je denkt dat dat niet klopt.`:r==="human"?Number.isNaN(n)?"":"Deze score heb je zelf toegekend.":this.dataset.inProgress}</div>`}};dh([_({context:j,subscribe:!0})],Xi.prototype,"computedContext",void 0);dh([p({type:String,attribute:"view"})],Xi.prototype,"view",void 0);var Al=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},hi=class extends C{constructor(){super(...arguments),this.debug=!1,this.stampContext={view:"candidate",activeItem:{},activeSection:{items:[]},activeTestpart:{items:[],sections:[]},test:{}}}createRenderRoot(){return this}connectedCallback(){super.connectedCallback();let t=this.querySelector("template");if(!t){this.myTemplate=null;return}this.myTemplate=we(t)}willUpdate(t){if(!this.computedContext)return;let e=this.computedContext.testParts.find(h=>h.active),i=e?.sections.find(h=>h.active),n=i?.items.find(h=>h.active),{variables:r,...s}=n||{};if(!e)return;let a={...e,items:e.sections.flatMap(h=>h.items.map(({variables:f,...m})=>m)),sections:e.sections.map(h=>({...h,items:h.items.map(({variables:f,...m})=>m)}))},l={...i,items:(i?.items??[]).map(({variables:h,...f})=>f)},{testParts:c,...d}=this.computedContext;this.stampContext={view:this.computedContext.view,activeItem:s,activeSection:l,activeTestpart:a,test:d},this.dispatchEvent(new CustomEvent("qti-stamp-context-updated",{detail:this.stampContext,bubbles:!0}))}render(){return b` ${this.debug?b`<small><pre>${JSON.stringify(this.stampContext,null,2)}</pre></small>`:O}
6501
+ `}};Sm([_({context:j,subscribe:!0})],rn.prototype,"computedContext",void 0);var El=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},di=class extends C{createRenderRoot(){return this}connectedCallback(){super.connectedCallback();let t=this.querySelector("template");if(!t){this.myTemplate=null;return}this.myTemplate=we(t)}#t(t){let n=(this.computedContext?.testParts.find(r=>r.active)).sections.flatMap(r=>r.items).find(r=>r.active)?.identifier;V(this,"cito-test-update-outcome",{assessmentItemRefId:n,outcomeVariableId:"SCORE",value:t})}render(){let t=this.computedContext?.testParts.flatMap(a=>a.sections.flatMap(l=>l.items)).find(a=>a.active);if(!t||!t.variables)return b``;let e=t.variables.find(a=>a.identifier=="MAXSCORE")?.value,i=t.variables.find(a=>a.identifier=="SCORE"),n=i?.value,r=i?.externalScored!=="human";if(!e||!i)return O;let s=[...Array(Number(e)+1).keys()];return b`${this.myTemplate?this.myTemplate({scores:s,score:n,disabled:r}):O}`}constructor(){super(),this.view="",this.disabled=!1,this.myTemplate=null,this.addEventListener("click",t=>{let e=t.target,i=parseFloat(e.value);e.tagName==="INPUT"&&this.#t(i)})}};El([p({type:String,attribute:"view"})],di.prototype,"view",void 0);El([p({type:Boolean})],di.prototype,"disabled",void 0);El([_({context:j,subscribe:!0})],di.prototype,"computedContext",void 0);var dh=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},Xi=class extends C{constructor(){super(...arguments),this.view=null}render(){let t=this.computedContext?.testParts.flatMap(a=>a.sections.flatMap(l=>l.items)).find(a=>a.active);if(!t||!t.variables)return b``;if(t.category==="dep-informational")return b`<div>${this.dataset.informational}</div>`;let e=t?.variables.find(a=>a.identifier==="completionStatus")?.value,i=t?.variables.find(a=>a.identifier=="SCORE"),n=parseFloat(i?.value),r=t.externalScored;return b`<div>${e!=="completed"?this.dataset.textNoResponse:!r&&n!==void 0&&!Number.isNaN(n)?n>0?this.dataset.textCorrect:this.dataset.textIncorrect:r==="externalMachine"?Number.isNaN(n)||n===void 0?this.dataset.scoreUnknown:`We hebben je antwoord ${n===0?"geen punten":n==1?"\xE9\xE9n punt":`${n} punten`} gegeven. Je kunt je score zelf aanpassen als je denkt dat dat niet klopt.`:r==="human"?Number.isNaN(n)?"":"Deze score heb je zelf toegekend.":this.dataset.inProgress}</div>`}};dh([_({context:j,subscribe:!0})],Xi.prototype,"computedContext",void 0);dh([p({type:String,attribute:"view"})],Xi.prototype,"view",void 0);var Al=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},hi=class extends C{constructor(){super(...arguments),this.debug=!1,this.stampContext={view:"candidate",activeItem:{},activeSection:{items:[]},activeTestpart:{items:[],sections:[]},test:{}}}createRenderRoot(){return this}connectedCallback(){super.connectedCallback();let t=this.querySelector("template");if(!t){this.myTemplate=null;return}this.myTemplate=we(t)}willUpdate(t){if(!this.computedContext)return;let e=this.computedContext.testParts.find(h=>h.active),i=e?.sections.find(h=>h.active),n=i?.items.find(h=>h.active),{variables:r,...s}=n||{};if(!e)return;let a={...e,items:e.sections.flatMap(h=>h.items.map(({variables:f,...m})=>m)),sections:e.sections.map(h=>({...h,items:h.items.map(({variables:f,...m})=>m)}))},l={...i,items:(i?.items??[]).map(({variables:h,...f})=>f)},{testParts:c,...d}=this.computedContext;this.stampContext={view:this.computedContext.view,activeItem:s,activeSection:l,activeTestpart:a,test:d},this.dispatchEvent(new CustomEvent("qti-stamp-context-updated",{detail:this.stampContext,bubbles:!0}))}render(){return b` ${this.debug?b`<small><pre>${JSON.stringify(this.stampContext,null,2)}</pre></small>`:O}
6501
6502
  ${this.myTemplate?this.myTemplate(this.stampContext):O}`}};Al([p({type:Boolean,reflect:!0})],hi.prototype,"debug",void 0);Al([T(),_({context:j,subscribe:!0})],hi.prototype,"computedContext",void 0);Al([T()],hi.prototype,"stampContext",void 0);var nn=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},To,Yt=class extends C{constructor(){super(...arguments),this.label="view",this._handleViewOptionsChange=()=>{this.#t()},this._viewOptions=To.DEFAULT_VIEW_OPTIONS}static{this.DEFAULT_VIEW_OPTIONS=["author","candidate","proctor","scorer","testConstructor","tutor"]}connectedCallback(){super.connectedCallback(),this.#t()}#t(){if(this.viewOptions){let t=this.viewOptions.split(",").map(e=>e.trim());this._viewOptions=t.filter(e=>To.DEFAULT_VIEW_OPTIONS.includes(e))}else this._viewOptions=To.DEFAULT_VIEW_OPTIONS}_switchView(t){V(this,"cito-test-switch-view",t)}render(){return b`
6502
6503
  <label part="label" for="viewSelect">${this.label}</label>
6503
6504
  <select
@@ -6507,7 +6508,7 @@ div.full-correct-response-inline {
6507
6508
  >
6508
6509
  ${this._viewOptions.map(t=>b`<option value="${t}" ?selected=${t===this.sessionContext.view}>${t}</option>`)}
6509
6510
  </select>
6510
- `}};To=Yt;nn([_({context:qe,subscribe:!0})],Yt.prototype,"sessionContext",void 0);nn([p({type:String})],Yt.prototype,"label",void 0);nn([p({type:String,attribute:"view-options"})],Yt.prototype,"viewOptions",void 0);nn([L("viewOptions",{waitUntilFirstUpdate:!0})],Yt.prototype,"_handleViewOptionsChange",void 0);nn([T()],Yt.prototype,"_viewOptions",void 0);var Sm=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},on=class extends C{createRenderRoot(){return this}connectedCallback(){super.connectedCallback();let t=this.querySelector("template");if(!t){this.myTemplate=null;return}this.myTemplate=we(t)}_switchView(t){V(this,"cito-test-switch-view",t)}firstUpdated(t){this.addEventListener("click",()=>{this.sessionContext?.view==="scorer"?this._switchView("candidate"):this._switchView("scorer")})}render(){return b`${this.myTemplate?this.myTemplate({view:this.sessionContext?.view}):O}`}};Sm([_({context:qe,subscribe:!0})],on.prototype,"sessionContext",void 0);var Gi=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},Po="tts-element",Oo="tts-word",Ro=null;function Em(){return Ro||(Ro=new CSSStyleSheet,Ro.replaceSync(`
6511
+ `}};To=Yt;nn([_({context:qe,subscribe:!0})],Yt.prototype,"sessionContext",void 0);nn([p({type:String})],Yt.prototype,"label",void 0);nn([p({type:String,attribute:"view-options"})],Yt.prototype,"viewOptions",void 0);nn([L("viewOptions",{waitUntilFirstUpdate:!0})],Yt.prototype,"_handleViewOptionsChange",void 0);nn([T()],Yt.prototype,"_viewOptions",void 0);var km=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},on=class extends C{createRenderRoot(){return this}connectedCallback(){super.connectedCallback();let t=this.querySelector("template");if(!t){this.myTemplate=null;return}this.myTemplate=we(t)}_switchView(t){V(this,"cito-test-switch-view",t)}firstUpdated(t){this.addEventListener("click",()=>{this.sessionContext?.view==="scorer"?this._switchView("candidate"):this._switchView("scorer")})}render(){return b`${this.myTemplate?this.myTemplate({view:this.sessionContext?.view}):O}`}};km([_({context:qe,subscribe:!0})],on.prototype,"sessionContext",void 0);var Yi=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},Po="tts-element",Oo="tts-word",Ro=null;function Em(){return Ro||(Ro=new CSSStyleSheet,Ro.replaceSync(`
6511
6512
  ::highlight(${Po}) { background-color: #dbeafe; color: inherit; }
6512
6513
  ::highlight(${Oo}) { background-color: #ffe066; color: inherit; }
6513
6514
  `)),Ro}var hh=Symbol("tts-context"),Am={play:"M8 5v14l11-7z",pause:"M6 5h4v14H6zM14 5h4v14h-4z",stop:"M6 6h12v12H6z",prev:"M6 5h2v14H6zM20 5v14L9 12z",next:"M16 5h2v14h-2zM4 5v14l11-7z",pick:"M5 3l13 7-5.5 1.6 3.4 6.6-2.4 1.3-3.4-6.7L6 17z"},De=(o,t)=>{let e=b`<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false">
@@ -6557,18 +6558,18 @@ div.full-correct-response-inline {
6557
6558
  clip-path: inset(50%);
6558
6559
  white-space: nowrap;
6559
6560
  }
6560
- `}#t=this.attachInternals();#e;#i=!1;updated(t){let e=this._tts?.state,i=this._tts?.picking??!1;e===this.#e&&i===this.#i||(this.#e=e,this.#i=i,this.#t.states.clear(),e&&this.#t.states.add(e),i&&this.#t.states.add("picking"))}};Gi([p({type:String})],Dt.prototype,"label",void 0);Gi([_({context:hh,subscribe:!0})],Dt.prototype,"_tts",void 0);var pi=class extends C{static{this.styles=q`
6561
+ `}#t=this.attachInternals();#e;#i=!1;updated(t){let e=this._tts?.state,i=this._tts?.picking??!1;e===this.#e&&i===this.#i||(this.#e=e,this.#i=i,this.#t.states.clear(),e&&this.#t.states.add(e),i&&this.#t.states.add("picking"))}};Yi([p({type:String})],Dt.prototype,"label",void 0);Yi([_({context:hh,subscribe:!0})],Dt.prototype,"_tts",void 0);var pi=class extends C{static{this.styles=q`
6561
6562
  :host {
6562
6563
  display: inline-flex;
6563
6564
  flex-wrap: wrap;
6564
6565
  align-items: center;
6565
6566
  gap: var(--test-tts-gap, 0.25rem);
6566
6567
  }
6567
- `}#t;#e;#i;#r;#n;#o;#s;#a;#c;#p;#l;#m;#d;#u;#h;#b;#f;#y;#g;#v;#x;constructor(){super(),this.language="nl-NL",this.#t=this.attachInternals(),this.#e=!1,this.#i=null,this.#r=!1,this.#n=null,this.#o=null,this.#s=this.#E.bind(this),this.#a=()=>this.#R(),this.#c=void 0,this.#p=void 0,this.#l=null,this.#m=null,this.#d=0,this.#u=[],this.#h=null,this.#b=!1,this.#f=null,this.#y=this.#Q.bind(this),this.#g=!1,this.#v=new Highlight,this.#x=new Highlight,this._ttsContext={state:"idle",currentElementIndex:0,elementCount:0,play:()=>this.#F(),pause:()=>this.#B(),resume:()=>this.#U(),stop:()=>{this.#S(),this.#R()},prevElement:()=>this.#X(),nextElement:()=>this.#G(),togglePick:()=>this.#H(),picking:!1}}willUpdate(t){if(super.willUpdate(t),this.#e||this.#r||this.#n)return;let{item:e,section:i}=this.#w(),n=this.#c!==void 0&&this.#c!==e,r=this.#p!==void 0&&this.#p!==i,s=this.#l!==null&&this.#m!==null&&this.#m!==this.#D();(n||r||s)&&this.#C(),this.#c=e,this.#p=i}#C(){this.#S(),this.#R(),this.#l=null,this.#d=0,this.#g=!1,this.#A()}connectedCallback(){if(super.connectedCallback(),this.#q("idle"),this.#e=this.#O()!==null,this.#e){this.#i=new MutationObserver(t=>{t.some(e=>!this.contains(e.target))&&this.#L()}),this.#i.observe(this.parentElement,{childList:!0,subtree:!0});return}this.#r=this.#M()!==null,!this.#r&&(this.#n=this.closest("qti-assessment-item-ref"),this.#n?(this.#o=this.#n,this.#o.addEventListener("qti-assessment-item-connected",this.#s)):(this.#o=this.closest("test-navigation")??this.getRootNode(),this.#o.addEventListener("cito-test-navigate",this.#a),this.#o.addEventListener("qti-request-navigation",this.#a)))}disconnectedCallback(){super.disconnectedCallback(),this.#h&&(this.#h=null,speechSynthesis.cancel()),this.#S(),this.#_(),this.#o?.removeEventListener("qti-assessment-item-connected",this.#s),this.#o?.removeEventListener("cito-test-navigate",this.#a),this.#o?.removeEventListener("qti-request-navigation",this.#a),this.#o=null,this.#n=null,this.#i?.disconnect(),this.#i=null,this.#e=!1,this.#r=!1}render(){return b`<slot></slot>`}#E(){this.#l!==null&&this.#C()}#w(){for(let t of this._computedContext?.testParts??[])for(let e of t.sections)if(e.active)return{item:e.items.find(i=>i.active)?.identifier??null,section:e.identifier};return{item:null,section:null}}#L(){this.#h&&(this.#h=null,speechSynthesis.cancel()),this.#S(),this.#_(),this.#q("idle"),this.#l=null,this.#d=0,this.#g=!1,this.#A()}#O(){return this.parentElement?.querySelector(":scope > [data-stimulus-idref]")??null}#M(){return this.parentElement?.querySelector(":scope > [data-tts-content]")??null}#D(){return this.#e?this.#O()?.querySelector("qti-stimulus-body")??null:this.#r?this.#M():this.#V()?.querySelector("qti-item-body")??null}#V(){if(this.#n)return this.#n.assessmentItem;let{item:t}=this.#w();return t?this._computedContext?.itemElement?.(t)??null:null}#q(t){this._ttsContext={...this._ttsContext,state:t},this.#t.states.delete("idle"),this.#t.states.delete("playing"),this.#t.states.delete("paused"),this.#t.states.add(t)}#A(){this._ttsContext={...this._ttsContext,currentElementIndex:this.#d,elementCount:this.#k().length}}#k(){if(this.#r&&this.#l?.some(t=>!t.isConnected)&&(this.#l=null,this.#d=0,this.#g=!1),this.#l===null){let t=this.#D();if(!t)return[];this.#m=t;let e="p, h1, h2, h3, h4, h5, h6, li, dt, dd, th, td, caption, blockquote, figcaption, qti-prompt, qti-simple-choice";this.#l=Array.from(t.querySelectorAll(e)).filter(i=>(i.textContent??"").trim().length>0&&!i.querySelector(e)&&!i.closest('[aria-hidden="true"]'))}return this.#l.filter(t=>this.#z(t))}#z(t){return typeof t.checkVisibility=="function"?t.checkVisibility({checkOpacity:!1,checkVisibilityCSS:!0}):t.getClientRects().length>0}#j(t){let e=t;for(;e;){let n=e.getAttribute("lang")||e.getAttribute("xml:lang");if(n?.trim())return n.trim();e=e.parentElement??e.getRootNode().host??null}let i=document.documentElement.getAttribute("lang");return i?.trim()?i.trim():this.language}#F(){if(!this.#k().length){console.warn("test-item-to-speech: no readable elements found");return}this.#S(),speechSynthesis.cancel(),this.#g&&(this.#g=!1,this.#d=0),this.#r&&this.#d===0&&(this.#l=null),this.#T(this.#d)}#T(t){let e=this.#k();if(t>=e.length){this.#I(),this.#d=e.length-1,e.length>0&&this.#P(e[this.#d]),this.#g=!0,this.#q("idle"),this.#A();return}this.#d=t,this.#g=!1,this.#A();let i=e[t];i.scrollIntoView({behavior:"smooth",block:"nearest"}),this.#P(i),this.#u=this.#Y(i);let n=this.#u.map(s=>s.textContent??"").join("");if(!n.trim()){this.#T(t+1);return}let r=new SpeechSynthesisUtterance(n);r.lang=this.#j(i),r.rate=1,r.onboundary=s=>{s.name==="word"&&this.#J(s.charIndex,s.charLength??0)},r.onend=()=>{this.#h===r&&(this.#h=null,this.#I(),this.#T(this.#d+1))},r.onerror=()=>{this.#h===r&&(this.#h=null,this.#_(),this.#q("idle"))},this.#h=r,speechSynthesis.speak(r),this.#q("playing")}#B(){speechSynthesis.pause(),this.#q("paused")}#U(){speechSynthesis.resume(),this.#q("playing")}#R(){this.#h=null,speechSynthesis.cancel(),this.#_(),this.#q("idle")}#H(){this.#b?this.#S():this.#W()}#W(){this.#r&&(this.#l=null);let t=this.#k();if(!t.length){console.warn("test-item-to-speech: no readable elements found");return}this.#R(),this.#b=!0,this.#t.states.add("picking"),this.#N(t),this.#f=t[0].getRootNode(),this.#f.addEventListener("click",this.#y,!0),this._ttsContext={...this._ttsContext,picking:!0}}#S(){this.#b&&(this.#b=!1,this.#t.states.delete("picking"),this.#f?.removeEventListener("click",this.#y,!0),this.#f=null,this.#_(),this._ttsContext={...this._ttsContext,picking:!1})}#Q(t){let e=this.#k(),i=t.composedPath(),n=e.findIndex(r=>i.includes(r));if(n<0){let r=i.find(s=>s instanceof Element&&s.matches("qti-simple-choice, li, qti-prompt"));r&&(n=e.findIndex(s=>r.contains(s)))}n<0||(t.preventDefault(),t.stopPropagation(),this.#S(),speechSynthesis.cancel(),this.#T(n))}#X(){let t=this.#k();if(!t.length)return;this.#h=null,speechSynthesis.cancel(),this.#I(),this.#d=Math.max(0,this.#d-1),this.#g=!1,this.#A();let e=t[this.#d];e.scrollIntoView({behavior:"smooth",block:"nearest"}),this.#P(e),this.#q("idle")}#G(){let t=this.#k();if(!t.length)return;this.#h=null,speechSynthesis.cancel(),this.#I(),this.#d=Math.min(t.length-1,this.#d+1),this.#g=!1,this.#A();let e=t[this.#d];e.scrollIntoView({behavior:"smooth",block:"nearest"}),this.#P(e),this.#q("idle")}#Y(t){let e=[],i=document.createTreeWalker(t,NodeFilter.SHOW_TEXT),n;for(;n=i.nextNode();)(n.textContent??"").length>0&&!n.parentElement?.closest('[aria-hidden="true"]')&&e.push(n);return e}#P(t){this.#N([t])}#N(t){if("highlights"in CSS){this.#$(),this.#v.clear();for(let e of t){let i=new Range;i.selectNodeContents(e),this.#v.add(i)}CSS.highlights.set(Po,this.#v)}}#J(t,e){if(!("highlights"in CSS))return;this.#$(),this.#x.clear();let i=this.#u.map(d=>d.textContent??"").join(""),n=t+(e>0?e:this.#K(t,i)),r=0,s=null,a=0,l=null,c=0;for(let d of this.#u){let h=d.textContent?.length??0;if(!s&&r+h>t&&(s=d,a=t-r),s&&r+h>=n){l=d,c=n-r;break}r+=h}if(s&&l){let d=new Range;d.setStart(s,a),d.setEnd(l,c),this.#x.add(d),CSS.highlights.set(Oo,this.#x)}}#I(){"highlights"in CSS&&(this.#x.clear(),CSS.highlights.get(Oo)===this.#x&&CSS.highlights.delete(Oo))}#_(){"highlights"in CSS&&(this.#I(),this.#v.clear(),CSS.highlights.get(Po)===this.#v&&CSS.highlights.delete(Po))}#K(t,e){let i=e.slice(t).search(/\s/);return i<0?e.length-t:i}#$(){if(!("highlights"in CSS))return;let t=Em();document.adoptedStyleSheets.includes(t)||(document.adoptedStyleSheets=[...document.adoptedStyleSheets,t]);let e=new Set,i=this.getRootNode();i instanceof ShadowRoot&&e.add(i);let n=this.#l?.[0]?.getRootNode();n instanceof ShadowRoot&&e.add(n);for(let r of e)r.adoptedStyleSheets.includes(t)||(r.adoptedStyleSheets=[...r.adoptedStyleSheets,t])}};Gi([p({type:String})],pi.prototype,"language",void 0);Gi([_({context:j,subscribe:!0})],pi.prototype,"_computedContext",void 0);Gi([T(),U({context:hh})],pi.prototype,"_ttsContext",void 0);var sn=class extends Dt{#t(){this._tts&&(this._tts.state==="idle"?this._tts.play():this._tts.state==="playing"?this._tts.pause():this._tts.resume())}render(){let t=this._tts?.state==="playing";return b`
6568
+ `}#t;#e;#i;#r;#n;#o;#s;#a;#c;#p;#l;#m;#d;#u;#h;#b;#f;#y;#g;#v;#x;constructor(){super(),this.language="nl-NL",this.#t=this.attachInternals(),this.#e=!1,this.#i=null,this.#r=!1,this.#n=null,this.#o=null,this.#s=this.#E.bind(this),this.#a=()=>this.#R(),this.#c=void 0,this.#p=void 0,this.#l=null,this.#m=null,this.#d=0,this.#u=[],this.#h=null,this.#b=!1,this.#f=null,this.#y=this.#Q.bind(this),this.#g=!1,this.#v=new Highlight,this.#x=new Highlight,this._ttsContext={state:"idle",currentElementIndex:0,elementCount:0,play:()=>this.#F(),pause:()=>this.#B(),resume:()=>this.#U(),stop:()=>{this.#k(),this.#R()},prevElement:()=>this.#G(),nextElement:()=>this.#X(),togglePick:()=>this.#H(),picking:!1}}willUpdate(t){if(super.willUpdate(t),this.#e||this.#r||this.#n)return;let{item:e,section:i}=this.#w(),n=this.#c!==void 0&&this.#c!==e,r=this.#p!==void 0&&this.#p!==i,s=this.#l!==null&&this.#m!==null&&this.#m!==this.#D();(n||r||s)&&this.#C(),this.#c=e,this.#p=i}#C(){this.#k(),this.#R(),this.#l=null,this.#d=0,this.#g=!1,this.#A()}connectedCallback(){if(super.connectedCallback(),this.#q("idle"),this.#e=this.#O()!==null,this.#e){this.#i=new MutationObserver(t=>{t.some(e=>!this.contains(e.target))&&this.#L()}),this.#i.observe(this.parentElement,{childList:!0,subtree:!0});return}this.#r=this.#M()!==null,!this.#r&&(this.#n=this.closest("qti-assessment-item-ref"),this.#n?(this.#o=this.#n,this.#o.addEventListener("qti-assessment-item-connected",this.#s)):(this.#o=this.closest("test-navigation")??this.getRootNode(),this.#o.addEventListener("cito-test-navigate",this.#a),this.#o.addEventListener("qti-request-navigation",this.#a)))}disconnectedCallback(){super.disconnectedCallback(),this.#h&&(this.#h=null,speechSynthesis.cancel()),this.#k(),this.#_(),this.#o?.removeEventListener("qti-assessment-item-connected",this.#s),this.#o?.removeEventListener("cito-test-navigate",this.#a),this.#o?.removeEventListener("qti-request-navigation",this.#a),this.#o=null,this.#n=null,this.#i?.disconnect(),this.#i=null,this.#e=!1,this.#r=!1}render(){return b`<slot></slot>`}#E(){this.#l!==null&&this.#C()}#w(){for(let t of this._computedContext?.testParts??[])for(let e of t.sections)if(e.active)return{item:e.items.find(i=>i.active)?.identifier??null,section:e.identifier};return{item:null,section:null}}#L(){this.#h&&(this.#h=null,speechSynthesis.cancel()),this.#k(),this.#_(),this.#q("idle"),this.#l=null,this.#d=0,this.#g=!1,this.#A()}#O(){return this.parentElement?.querySelector(":scope > [data-stimulus-idref]")??null}#M(){return this.parentElement?.querySelector(":scope > [data-tts-content]")??null}#D(){return this.#e?this.#O()?.querySelector("qti-stimulus-body")??null:this.#r?this.#M():this.#V()?.querySelector("qti-item-body")??null}#V(){if(this.#n)return this.#n.assessmentItem;let{item:t}=this.#w();return t?this._computedContext?.itemElement?.(t)??null:null}#q(t){this._ttsContext={...this._ttsContext,state:t},this.#t.states.delete("idle"),this.#t.states.delete("playing"),this.#t.states.delete("paused"),this.#t.states.add(t)}#A(){this._ttsContext={...this._ttsContext,currentElementIndex:this.#d,elementCount:this.#S().length}}#S(){if(this.#r&&this.#l?.some(t=>!t.isConnected)&&(this.#l=null,this.#d=0,this.#g=!1),this.#l===null){let t=this.#D();if(!t)return[];this.#m=t;let e="p, h1, h2, h3, h4, h5, h6, li, dt, dd, th, td, caption, blockquote, figcaption, qti-prompt, qti-simple-choice";this.#l=Array.from(t.querySelectorAll(e)).filter(i=>(i.textContent??"").trim().length>0&&!i.querySelector(e)&&!i.closest('[aria-hidden="true"]'))}return this.#l.filter(t=>this.#z(t))}#z(t){return typeof t.checkVisibility=="function"?t.checkVisibility({checkOpacity:!1,checkVisibilityCSS:!0}):t.getClientRects().length>0}#j(t){let e=t;for(;e;){let n=e.getAttribute("lang")||e.getAttribute("xml:lang");if(n?.trim())return n.trim();e=e.parentElement??e.getRootNode().host??null}let i=document.documentElement.getAttribute("lang");return i?.trim()?i.trim():this.language}#F(){if(!this.#S().length){console.warn("test-item-to-speech: no readable elements found");return}this.#k(),speechSynthesis.cancel(),this.#g&&(this.#g=!1,this.#d=0),this.#r&&this.#d===0&&(this.#l=null),this.#T(this.#d)}#T(t){let e=this.#S();if(t>=e.length){this.#I(),this.#d=e.length-1,e.length>0&&this.#P(e[this.#d]),this.#g=!0,this.#q("idle"),this.#A();return}this.#d=t,this.#g=!1,this.#A();let i=e[t];i.scrollIntoView({behavior:"smooth",block:"nearest"}),this.#P(i),this.#u=this.#Y(i);let n=this.#u.map(s=>s.textContent??"").join("");if(!n.trim()){this.#T(t+1);return}let r=new SpeechSynthesisUtterance(n);r.lang=this.#j(i),r.rate=1,r.onboundary=s=>{s.name==="word"&&this.#J(s.charIndex,s.charLength??0)},r.onend=()=>{this.#h===r&&(this.#h=null,this.#I(),this.#T(this.#d+1))},r.onerror=()=>{this.#h===r&&(this.#h=null,this.#_(),this.#q("idle"))},this.#h=r,speechSynthesis.speak(r),this.#q("playing")}#B(){speechSynthesis.pause(),this.#q("paused")}#U(){speechSynthesis.resume(),this.#q("playing")}#R(){this.#h=null,speechSynthesis.cancel(),this.#_(),this.#q("idle")}#H(){this.#b?this.#k():this.#W()}#W(){this.#r&&(this.#l=null);let t=this.#S();if(!t.length){console.warn("test-item-to-speech: no readable elements found");return}this.#R(),this.#b=!0,this.#t.states.add("picking"),this.#N(t),this.#f=t[0].getRootNode(),this.#f.addEventListener("click",this.#y,!0),this._ttsContext={...this._ttsContext,picking:!0}}#k(){this.#b&&(this.#b=!1,this.#t.states.delete("picking"),this.#f?.removeEventListener("click",this.#y,!0),this.#f=null,this.#_(),this._ttsContext={...this._ttsContext,picking:!1})}#Q(t){let e=this.#S(),i=t.composedPath(),n=e.findIndex(r=>i.includes(r));if(n<0){let r=i.find(s=>s instanceof Element&&s.matches("qti-simple-choice, li, qti-prompt"));r&&(n=e.findIndex(s=>r.contains(s)))}n<0||(t.preventDefault(),t.stopPropagation(),this.#k(),speechSynthesis.cancel(),this.#T(n))}#G(){let t=this.#S();if(!t.length)return;this.#h=null,speechSynthesis.cancel(),this.#I(),this.#d=Math.max(0,this.#d-1),this.#g=!1,this.#A();let e=t[this.#d];e.scrollIntoView({behavior:"smooth",block:"nearest"}),this.#P(e),this.#q("idle")}#X(){let t=this.#S();if(!t.length)return;this.#h=null,speechSynthesis.cancel(),this.#I(),this.#d=Math.min(t.length-1,this.#d+1),this.#g=!1,this.#A();let e=t[this.#d];e.scrollIntoView({behavior:"smooth",block:"nearest"}),this.#P(e),this.#q("idle")}#Y(t){let e=[],i=document.createTreeWalker(t,NodeFilter.SHOW_TEXT),n;for(;n=i.nextNode();)(n.textContent??"").length>0&&!n.parentElement?.closest('[aria-hidden="true"]')&&e.push(n);return e}#P(t){this.#N([t])}#N(t){if("highlights"in CSS){this.#$(),this.#v.clear();for(let e of t){let i=new Range;i.selectNodeContents(e),this.#v.add(i)}CSS.highlights.set(Po,this.#v)}}#J(t,e){if(!("highlights"in CSS))return;this.#$(),this.#x.clear();let i=this.#u.map(d=>d.textContent??"").join(""),n=t+(e>0?e:this.#K(t,i)),r=0,s=null,a=0,l=null,c=0;for(let d of this.#u){let h=d.textContent?.length??0;if(!s&&r+h>t&&(s=d,a=t-r),s&&r+h>=n){l=d,c=n-r;break}r+=h}if(s&&l){let d=new Range;d.setStart(s,a),d.setEnd(l,c),this.#x.add(d),CSS.highlights.set(Oo,this.#x)}}#I(){"highlights"in CSS&&(this.#x.clear(),CSS.highlights.get(Oo)===this.#x&&CSS.highlights.delete(Oo))}#_(){"highlights"in CSS&&(this.#I(),this.#v.clear(),CSS.highlights.get(Po)===this.#v&&CSS.highlights.delete(Po))}#K(t,e){let i=e.slice(t).search(/\s/);return i<0?e.length-t:i}#$(){if(!("highlights"in CSS))return;let t=Em();document.adoptedStyleSheets.includes(t)||(document.adoptedStyleSheets=[...document.adoptedStyleSheets,t]);let e=new Set,i=this.getRootNode();i instanceof ShadowRoot&&e.add(i);let n=this.#l?.[0]?.getRootNode();n instanceof ShadowRoot&&e.add(n);for(let r of e)r.adoptedStyleSheets.includes(t)||(r.adoptedStyleSheets=[...r.adoptedStyleSheets,t])}};Yi([p({type:String})],pi.prototype,"language",void 0);Yi([_({context:j,subscribe:!0})],pi.prototype,"_computedContext",void 0);Yi([T(),U({context:hh})],pi.prototype,"_ttsContext",void 0);var sn=class extends Dt{#t(){this._tts&&(this._tts.state==="idle"?this._tts.play():this._tts.state==="playing"?this._tts.pause():this._tts.resume())}render(){let t=this._tts?.state==="playing";return b`
6568
6569
  <button part="button" aria-label=${Z(t?this.pauseLabel:this.label)} @click=${this.#t}>
6569
6570
  ${t?b`<slot name="pause">${De("pause",this.pauseLabel??"Pause")}</slot>`:b`<slot name="play">${De("play",this.label??"Play")}</slot>`}
6570
6571
  </button>
6571
- `}};Gi([p({type:String,attribute:"pause-label"})],sn.prototype,"pauseLabel",void 0);var Mo=class extends Dt{render(){return b`
6572
+ `}};Yi([p({type:String,attribute:"pause-label"})],sn.prototype,"pauseLabel",void 0);var Mo=class extends Dt{render(){return b`
6572
6573
  <button
6573
6574
  part="button"
6574
6575
  aria-label=${Z(this.label)}
@@ -6617,7 +6618,7 @@ div.full-correct-response-inline {
6617
6618
  >
6618
6619
  <slot>${De("pick",this.label??"Read from here")}</slot>
6619
6620
  </button>
6620
- `}};var ph=[{tag:"test-item-to-speech",ctor:pi},{tag:"test-tts-next",ctor:Lo},{tag:"test-tts-pause",ctor:Mo},{tag:"test-tts-pick",ctor:Vo},{tag:"test-tts-play",ctor:sn},{tag:"test-tts-prev",ctor:$o},{tag:"test-tts-resume",ctor:Do},{tag:"test-tts-stop",ctor:No}];var uh=[{tag:"test-check-item",ctor:ci},{tag:"test-bookmark",ctor:Me},{tag:"test-print-context",ctor:en},{tag:"test-print-item-variables",ctor:rn},{tag:"test-scoring-buttons",ctor:di},{tag:"test-scoring-feedback",ctor:Xi},{tag:"test-stamp",ctor:hi},{tag:"test-view",ctor:Yt},{tag:"test-view-toggle",ctor:on},...ph];var mh=[{tag:"qti-assessment-item-ref",ctor:Ct},{tag:"qti-assessment-section",ctor:kt},{tag:"qti-assessment-test",ctor:ii},{tag:"qti-branch-rule",ctor:se},{tag:"qti-item-session-control",ctor:Pt},{tag:"qti-number-presented",ctor:jr},{tag:"qti-number-selected",ctor:eo},{tag:"qti-outcome-processing",ctor:ro},{tag:"qti-pre-condition",ctor:io},{tag:"qti-test",ctor:Re},{tag:"qti-test-feedback",ctor:Yr},{tag:"qti-test-part",ctor:Te},{tag:"qti-test-variables",ctor:Jr},{tag:"test-container",ctor:St},{tag:"test-end-attempt",ctor:oi},{tag:"test-item-link",ctor:Zr},{tag:"test-navigation",ctor:gt},{tag:"test-next",ctor:ai},{tag:"test-prev",ctor:li},{tag:"test-section-link",ctor:tn},...uh];for(let{tag:o,ctor:t}of mh)customElements.get(o)||customElements.define(o,t);var ui=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},Nt=class extends C{constructor(){super(...arguments),this.customElementRegistry=null,this.itemURL=null,this.itemDoc=null,this.itemXML=null,this.qtiContext={QTI_CONTEXT:{testIdentifier:"",candidateIdentifier:"",environmentIdentifier:"default"}},this.#t=null,this.#e=null}#t;#e;createRenderRoot(){let t=this.customElementRegistry;return this.#e=t,this.shadowRoot??this.attachShadow({...this.constructor.shadowRootOptions,...t?{customElementRegistry:t}:{}})}async handleItemURLChange(){if(this.itemURL)try{let t=this.qtiContext?.QTI_CONTEXT?.seed,e=(await Gt().load(this.itemURL)).shuffleInteractions(t);this.itemDoc=e.htmlDoc(this.#e??void 0)}catch(t){console.error("Error loading or parsing XML:",t)}}handleItemXMLChange(){if(this.itemXML)try{this.itemDoc=Gt().parse(this.itemXML).htmlDoc(this.#e??void 0)}catch(t){console.error("Error parsing XML:",t)}}async connectedCallback(){super.connectedCallback(),this.#i(),this.#r(),this.itemURL&&this.handleItemURLChange(),this.itemXML&&this.handleItemXMLChange()}#i(){let t=this.querySelector("template");this.#t=t?t.content:b``}#r(){let t=new CSSStyleSheet;t.replaceSync(Io),this.shadowRoot.adoptedStyleSheets=[t]}render(){return b`
6621
+ `}};var ph=[{tag:"test-item-to-speech",ctor:pi},{tag:"test-tts-next",ctor:Lo},{tag:"test-tts-pause",ctor:Mo},{tag:"test-tts-pick",ctor:Vo},{tag:"test-tts-play",ctor:sn},{tag:"test-tts-prev",ctor:$o},{tag:"test-tts-resume",ctor:Do},{tag:"test-tts-stop",ctor:No}];var uh=[{tag:"test-check-item",ctor:ci},{tag:"test-bookmark",ctor:Me},{tag:"test-print-context",ctor:en},{tag:"test-print-item-variables",ctor:rn},{tag:"test-scoring-buttons",ctor:di},{tag:"test-scoring-feedback",ctor:Xi},{tag:"test-stamp",ctor:hi},{tag:"test-view",ctor:Yt},{tag:"test-view-toggle",ctor:on},...ph];var mh=[{tag:"qti-assessment-item-ref",ctor:Ct},{tag:"qti-assessment-section",ctor:St},{tag:"qti-assessment-test",ctor:ii},{tag:"qti-branch-rule",ctor:se},{tag:"qti-item-session-control",ctor:Pt},{tag:"qti-number-presented",ctor:jr},{tag:"qti-number-selected",ctor:eo},{tag:"qti-outcome-processing",ctor:ro},{tag:"qti-pre-condition",ctor:io},{tag:"qti-test",ctor:Re},{tag:"qti-test-feedback",ctor:Yr},{tag:"qti-test-part",ctor:Te},{tag:"qti-test-variables",ctor:Jr},{tag:"test-container",ctor:kt},{tag:"test-end-attempt",ctor:oi},{tag:"test-item-link",ctor:Zr},{tag:"test-navigation",ctor:gt},{tag:"test-next",ctor:ai},{tag:"test-prev",ctor:li},{tag:"test-section-link",ctor:tn},...uh];for(let{tag:o,ctor:t}of mh)customElements.get(o)||customElements.define(o,t);var ui=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},Nt=class extends C{constructor(){super(...arguments),this.customElementRegistry=null,this.itemURL=null,this.itemDoc=null,this.itemXML=null,this.qtiContext={QTI_CONTEXT:{testIdentifier:"",candidateIdentifier:"",environmentIdentifier:"default"}},this.#t=null,this.#e=null}#t;#e;createRenderRoot(){let t=this.customElementRegistry;return this.#e=t,this.shadowRoot??this.attachShadow({...this.constructor.shadowRootOptions,...t?{customElementRegistry:t}:{}})}async handleItemURLChange(){if(this.itemURL)try{let t=this.qtiContext?.QTI_CONTEXT?.seed,e=(await Xt().load(this.itemURL)).shuffleInteractions(t);this.itemDoc=e.htmlDoc(this.#e??void 0)}catch(t){console.error("Error loading or parsing XML:",t)}}handleItemXMLChange(){if(this.itemXML)try{this.itemDoc=Xt().parse(this.itemXML).htmlDoc(this.#e??void 0)}catch(t){console.error("Error parsing XML:",t)}}async connectedCallback(){super.connectedCallback(),this.#i(),this.#r(),this.itemURL&&this.handleItemURLChange(),this.itemXML&&this.handleItemXMLChange()}#i(){let t=this.querySelector("template");this.#t=t?t.content:b``}#r(){let t=new CSSStyleSheet;t.replaceSync(Io),this.shadowRoot.adoptedStyleSheets=[t]}render(){return b`
6621
6622
  ${this.#t}
6622
6623
  <slot></slot>
6623
6624
  ${Ao(this.itemDoc,b`<span>Loading...</span>`)}
@@ -6668,7 +6669,7 @@ div.full-correct-response-inline {
6668
6669
  </table>
6669
6670
  `;return b`
6670
6671
  ${n(e,"Response Variables")} ${n(i,"Outcome Variables")}
6671
- `}};Im([_({context:xe,subscribe:!0})],an.prototype,"computedContext",void 0);var _m=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},fh=o=>{class t extends o{#t;constructor(...i){super(...i),this.view="candidate",this.addEventListener("qti-assessment-item-connected",n=>{this.#t=n.detail,this.#e()}),this.addEventListener("item-switch-view",n=>{this.view=n.detail})}willUpdate(i){super.willUpdate(i),i.has("view")&&this.#e()}#e(){let i=this.#t;i&&(i.querySelectorAll("[view]").forEach(n=>{n.classList.toggle("show",n.getAttribute("view")===this.view)}),this.updateAssessmentItemView(i,this.view))}updateAssessmentItemView(i,n){}}return _m([p({type:String})],t.prototype,"view",void 0),t};var Il=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},de=class extends fh(C){#t;#e;constructor(){super(),this.configContext={},this.qtiContext={QTI_CONTEXT:{testIdentifier:"",candidateIdentifier:"",environmentIdentifier:"default"}},this.#t=this.#i.bind(this),this.#e=this.#r.bind(this),this.addEventListener("qti-item-context-updated",this.#t),this.addEventListener("qti-assessment-item-connected",this.#e)}#i(t){this.#n(t.detail.itemContext.identifier,t.detail?.itemContext?.variables||[])}#r(t){let e=t.detail._context.variables;this.assessmentItem=t.detail,this.computedContext=this.computedContext?.identifier===this.assessmentItem.identifier?{...this.computedContext,title:this.assessmentItem.title}:{identifier:this.assessmentItem.identifier,title:this.assessmentItem.title,adaptive:this.assessmentItem.getAttribute("adaptive")?.toLowerCase()==="true"||!1,variables:e},this.#n(this.assessmentItem.identifier,e||[])}#n(t,e){let i=e?.find(c=>c.identifier=="SCORE")?.value,n=parseFloat(i?.toString()),r=e?.find(c=>c.identifier==="completionStatus")?.value,s=n!==void 0&&!isNaN(n)&&n>0,a=n!==void 0&&!isNaN(n)&&n<=0,l=r==="completed";this.computedContext={...this.computedContext,identifier:t,correct:s,incorrect:a,completed:l,variables:e}}render(){return b`<slot></slot>`}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-item-context-changed",this.#t),this.removeEventListener("qti-assessment-item-connected",this.#e)}};Il([T(),U({context:xe})],de.prototype,"computedContext",void 0);Il([T(),U({context:xt})],de.prototype,"configContext",void 0);Il([T(),U({context:qt})],de.prototype,"qtiContext",void 0);var gh=[{tag:"item-container",ctor:Nt},{tag:"item-print-variables",ctor:an},{tag:"qti-item",ctor:de}];for(let{tag:o,ctor:t}of gh)customElements.get(o)||customElements.define(o,t);for(let{tag:o,ctor:t}of Xd)customElements.get(o)||customElements.define(o,t);var bh=(o,t,e)=>{let i=new Map;for(let n=t;n<=e;n++)i.set(o[n],n);return i},Q=Ot(class extends Ae{constructor(o){if(super(o),o.type!==Wi.CHILD)throw Error("repeat() can only be used in text expressions")}dt(o,t,e){let i;e===void 0?e=t:t!==void 0&&(i=t);let n=[],r=[],s=0;for(let a of o)n[s]=i?i(a,s):s,r[s]=e(a,s),s++;return{values:r,keys:n}}render(o,t,e){return this.dt(o,t,e).values}update(o,[t,e,i]){let n=Wd(o),{values:r,keys:s}=this.dt(t,e,i);if(!Array.isArray(n))return this.ut=s,r;let a=this.ut??=[],l=[],c,d,h=0,f=n.length-1,m=0,v=r.length-1;for(;h<=f&&m<=v;)if(n[h]===null)h++;else if(n[f]===null)f--;else if(a[h]===s[m])l[m]=Ie(n[h],r[m]),h++,m++;else if(a[f]===s[v])l[v]=Ie(n[f],r[v]),f--,v--;else if(a[h]===s[v])l[v]=Ie(n[h],r[v]),Qi(o,l[v+1],n[h]),h++,v--;else if(a[f]===s[m])l[m]=Ie(n[f],r[m]),Qi(o,n[h],n[f]),f--,m++;else if(c===void 0&&(c=bh(s,m,v),d=bh(a,h,f)),c.has(a[h]))if(c.has(a[f])){let x=d.get(s[m]),u=x!==void 0?n[x]:null;if(u===null){let g=Qi(o,n[h]);Ie(g,r[m]),l[m]=g}else l[m]=Ie(u,r[m]),Qi(o,n[h],u),n[x]=null;m++}else go(n[f]),f--;else go(n[h]),h++;for(;m<=v;){let x=Qi(o,l[v+1]);Ie(x,r[m]),l[m++]=x}for(;h<=f;){let x=n[h++];x!==null&&go(x)}return this.ut=s,Hd(o,l),rt}});var Ne=Symbol("dragDropContext");var yh=[P,Wt,q`
6672
+ `}};Im([_({context:xe,subscribe:!0})],an.prototype,"computedContext",void 0);var _m=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},fh=o=>{class t extends o{#t;constructor(...i){super(...i),this.view="candidate",this.addEventListener("qti-assessment-item-connected",n=>{this.#t=n.detail,this.#e()}),this.addEventListener("item-switch-view",n=>{this.view=n.detail})}willUpdate(i){super.willUpdate(i),i.has("view")&&this.#e()}#e(){let i=this.#t;i&&(i.querySelectorAll("[view]").forEach(n=>{n.classList.toggle("show",n.getAttribute("view")===this.view)}),this.updateAssessmentItemView(i,this.view))}updateAssessmentItemView(i,n){}}return _m([p({type:String})],t.prototype,"view",void 0),t};var Il=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},de=class extends fh(C){#t;#e;constructor(){super(),this.configContext={},this.qtiContext={QTI_CONTEXT:{testIdentifier:"",candidateIdentifier:"",environmentIdentifier:"default"}},this.#t=this.#i.bind(this),this.#e=this.#r.bind(this),this.addEventListener("qti-item-context-updated",this.#t),this.addEventListener("qti-assessment-item-connected",this.#e)}#i(t){this.#n(t.detail.itemContext.identifier,t.detail?.itemContext?.variables||[])}#r(t){let e=t.detail._context.variables;this.assessmentItem=t.detail,this.computedContext=this.computedContext?.identifier===this.assessmentItem.identifier?{...this.computedContext,title:this.assessmentItem.title}:{identifier:this.assessmentItem.identifier,title:this.assessmentItem.title,adaptive:this.assessmentItem.getAttribute("adaptive")?.toLowerCase()==="true"||!1,variables:e},this.#n(this.assessmentItem.identifier,e||[])}#n(t,e){let i=e?.find(c=>c.identifier=="SCORE")?.value,n=parseFloat(i?.toString()),r=e?.find(c=>c.identifier==="completionStatus")?.value,s=n!==void 0&&!isNaN(n)&&n>0,a=n!==void 0&&!isNaN(n)&&n<=0,l=r==="completed";this.computedContext={...this.computedContext,identifier:t,correct:s,incorrect:a,completed:l,variables:e}}render(){return b`<slot></slot>`}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-item-context-changed",this.#t),this.removeEventListener("qti-assessment-item-connected",this.#e)}};Il([T(),U({context:xe})],de.prototype,"computedContext",void 0);Il([T(),U({context:xt})],de.prototype,"configContext",void 0);Il([T(),U({context:qt})],de.prototype,"qtiContext",void 0);var gh=[{tag:"item-container",ctor:Nt},{tag:"item-print-variables",ctor:an},{tag:"qti-item",ctor:de}];for(let{tag:o,ctor:t}of gh)customElements.get(o)||customElements.define(o,t);for(let{tag:o,ctor:t}of Gd)customElements.get(o)||customElements.define(o,t);var bh=(o,t,e)=>{let i=new Map;for(let n=t;n<=e;n++)i.set(o[n],n);return i},Q=Ot(class extends Ae{constructor(o){if(super(o),o.type!==Qi.CHILD)throw Error("repeat() can only be used in text expressions")}dt(o,t,e){let i;e===void 0?e=t:t!==void 0&&(i=t);let n=[],r=[],s=0;for(let a of o)n[s]=i?i(a,s):s,r[s]=e(a,s),s++;return{values:r,keys:n}}render(o,t,e){return this.dt(o,t,e).values}update(o,[t,e,i]){let n=Wd(o),{values:r,keys:s}=this.dt(t,e,i);if(!Array.isArray(n))return this.ut=s,r;let a=this.ut??=[],l=[],c,d,h=0,f=n.length-1,m=0,v=r.length-1;for(;h<=f&&m<=v;)if(n[h]===null)h++;else if(n[f]===null)f--;else if(a[h]===s[m])l[m]=Ie(n[h],r[m]),h++,m++;else if(a[f]===s[v])l[v]=Ie(n[f],r[v]),f--,v--;else if(a[h]===s[v])l[v]=Ie(n[h],r[v]),Gi(o,l[v+1],n[h]),h++,v--;else if(a[f]===s[m])l[m]=Ie(n[f],r[m]),Gi(o,n[h],n[f]),f--,m++;else if(c===void 0&&(c=bh(s,m,v),d=bh(a,h,f)),c.has(a[h]))if(c.has(a[f])){let x=d.get(s[m]),u=x!==void 0?n[x]:null;if(u===null){let g=Gi(o,n[h]);Ie(g,r[m]),l[m]=g}else l[m]=Ie(u,r[m]),Gi(o,n[h],u),n[x]=null;m++}else go(n[f]),f--;else go(n[h]),h++;for(;m<=v;){let x=Gi(o,l[v+1]);Ie(x,r[m]),l[m++]=x}for(;h<=f;){let x=n[h++];x!==null&&go(x)}return this.ut=s,Hd(o,l),rt}});var Ne=Symbol("dragDropContext");var yh=[P,Wt,q`
6672
6673
  /* A drop target — see qti-gap.styles.ts. The interaction publishes the chip measurements as
6673
6674
  custom properties on its host; the properties themselves live here. */
6674
6675
  :host {
@@ -6686,9 +6687,9 @@ div.full-correct-response-inline {
6686
6687
  width: 100%;
6687
6688
  height: 100%;
6688
6689
  }
6689
- `];var vh=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},Yi=class extends C{constructor(){super(...arguments),this.internals=this.attachInternals(),this.acceptsDeclarativeDrops=!0}static{this.styles=yh}get drags(){return this._dragDrop?.nodesByTarget?.[this.identifier]??[]}connectedCallback(){super.connectedCallback(),this.dispatchEvent(new CustomEvent("qti-register-hotspot",{bubbles:!0,composed:!0,cancelable:!1}))}render(){return b`<div part="drop">
6690
+ `];var vh=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},Ji=class extends C{constructor(){super(...arguments),this.internals=this.attachInternals(),this.acceptsDeclarativeDrops=!0}static{this.styles=yh}get drags(){return this._dragDrop?.nodesByTarget?.[this.identifier]??[]}connectedCallback(){super.connectedCallback(),this.dispatchEvent(new CustomEvent("qti-register-hotspot",{bubbles:!0,composed:!0,cancelable:!1}))}render(){return b`<div part="drop">
6690
6691
  ${Q(this.drags,t=>t.getAttribute("identifier"),t=>t)}
6691
- </div>`}};vh([p({type:String,reflect:!0})],Yi.prototype,"identifier",void 0);vh([_({context:Ne,subscribe:!0}),T()],Yi.prototype,"_dragDrop",void 0);var wh=[{tag:"qti-associable-hotspot",ctor:Yi}];var xh=[P,Wt,q`
6692
+ </div>`}};vh([p({type:String,reflect:!0})],Ji.prototype,"identifier",void 0);vh([_({context:Ne,subscribe:!0}),T()],Ji.prototype,"_dragDrop",void 0);var wh=[{tag:"qti-associable-hotspot",ctor:Ji}];var xh=[P,Wt,q`
6692
6693
  /*
6693
6694
  * A drop target. The interaction measures its chips and publishes the result as custom
6694
6695
  * properties on its own host; the actual CSS properties live here, not in a style attribute.
@@ -6743,8 +6744,12 @@ div.full-correct-response-inline {
6743
6744
  align-items: center;
6744
6745
  justify-content: center;
6745
6746
  user-select: none;
6747
+ /* In graphic-gap-match the picture's authored size is in the graphic's coordinate space, so it
6748
+ scales with the graphic and keeps fitting its hotspot. The interaction publishes the factor;
6749
+ anywhere else it is unset and the chip keeps its size. */
6750
+ zoom: var(--qti-graphic-scale, 1);
6746
6751
  }
6747
- `];var Tm=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},ln=class extends C{constructor(){super(...arguments),this.tabindex=0,this.internals=this.attachInternals()}static{this.styles=Ch}connectedCallback(){super.connectedCallback(),this.setAttribute("slot","drags")}render(){return b`<slot part="label"></slot>`}};Tm([p({type:Number,reflect:!0})],ln.prototype,"tabindex",void 0);var kh=[{tag:"qti-gap-img",ctor:ln}];var fi=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},Sh={toAttribute:o=>o?"true":"false",fromAttribute:o=>o==="true"};function Et(o,t){class e extends o{#t;#e(){let r=this._interactionContext?.choiceRole??null;r!==this.#t&&(this.#t&&this.internals.states.delete(this.#t),this.#t=r,this.internals.role=r,r&&this.internals.states.add(r))}handleDisabledChange(n,r){r?(this.internals.ariaDisabled="true",this.internals.states.add("disabled"),this.blur()):(this.internals.ariaDisabled=null,this.internals.states.delete("disabled")),this.tabIndex=r?-1:0}handleReadonlyChange(n,r){r?(this.internals.ariaReadOnly="true",this.internals.states.add("readonly")):(this.internals.ariaReadOnly=null,this.internals.states.delete("readonly"))}constructor(...n){super(...n),this.identifier="",this.tabIndex=0,this.disabled=!1,this.readonly=!1,this.#t=null,this.internals=this.attachInternals()}willUpdate(n){super.willUpdate(n),this.#e()}connectedCallback(){super.connectedCallback(),this.internals.ariaChecked="false",this.disabled&&(this.internals.ariaDisabled="true",this.internals.states.add("disabled"),this.tabIndex=-1),this.readonly&&(this.internals.ariaReadOnly="true",this.internals.states.add("readonly")),this.addEventListener("keyup",this._onKeyUp),this.addEventListener("click",this._onClick),this.dispatchEvent(new CustomEvent(`register-${t}`,{bubbles:!0,composed:!0}))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("keyup",this._onKeyUp),this.removeEventListener("click",this._onClick),this.dispatchEvent(new CustomEvent(`unregister-${t}`,{bubbles:!0,composed:!0}))}_onKeyUp(n){n.altKey||(n.code==="Space"||n.code==="Enter")&&(n.preventDefault(),this._activate())}_onClick(){this.disabled||this.readonly||(this.focus(),this._activate())}_activate(){this.disabled||this.readonly||this.dispatchEvent(new CustomEvent(`activate-${t}`,{bubbles:!0,composed:!0,detail:{identifier:this.identifier}}))}render(){return b`<slot></slot>`}}return fi([p({type:String})],e.prototype,"identifier",void 0),fi([p({type:Number,reflect:!0,attribute:"tabindex"})],e.prototype,"tabIndex",void 0),fi([p({type:Boolean,attribute:"aria-disabled",converter:Sh})],e.prototype,"disabled",void 0),fi([p({type:Boolean,attribute:"aria-readonly",converter:Sh})],e.prototype,"readonly",void 0),fi([_({context:_i,subscribe:!0}),T()],e.prototype,"_interactionContext",void 0),fi([L("disabled",{waitUntilFirstUpdate:!0})],e.prototype,"handleDisabledChange",null),fi([L("readonly",{waitUntilFirstUpdate:!0})],e.prototype,"handleReadonlyChange",null),e}var Eh=[P,q`
6752
+ `];var Tm=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},ln=class extends C{constructor(){super(...arguments),this.tabindex=0,this.internals=this.attachInternals()}static{this.styles=Ch}connectedCallback(){super.connectedCallback(),this.setAttribute("slot","drags")}render(){return b`<slot part="label"></slot>`}};Tm([p({type:Number,reflect:!0})],ln.prototype,"tabindex",void 0);var Sh=[{tag:"qti-gap-img",ctor:ln}];var fi=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},kh={toAttribute:o=>o?"true":"false",fromAttribute:o=>o==="true"};function Et(o,t){class e extends o{#t;#e(){let r=this._interactionContext?.choiceRole??null;r!==this.#t&&(this.#t&&this.internals.states.delete(this.#t),this.#t=r,this.internals.role=r,r&&this.internals.states.add(r))}handleDisabledChange(n,r){r?(this.internals.ariaDisabled="true",this.internals.states.add("disabled"),this.blur()):(this.internals.ariaDisabled=null,this.internals.states.delete("disabled")),this.tabIndex=r?-1:0}handleReadonlyChange(n,r){r?(this.internals.ariaReadOnly="true",this.internals.states.add("readonly")):(this.internals.ariaReadOnly=null,this.internals.states.delete("readonly"))}constructor(...n){super(...n),this.identifier="",this.tabIndex=0,this.disabled=!1,this.readonly=!1,this.#t=null,this.internals=this.attachInternals()}willUpdate(n){super.willUpdate(n),this.#e()}connectedCallback(){super.connectedCallback(),this.internals.ariaChecked="false",this.disabled&&(this.internals.ariaDisabled="true",this.internals.states.add("disabled"),this.tabIndex=-1),this.readonly&&(this.internals.ariaReadOnly="true",this.internals.states.add("readonly")),this.addEventListener("keyup",this._onKeyUp),this.addEventListener("click",this._onClick),this.dispatchEvent(new CustomEvent(`register-${t}`,{bubbles:!0,composed:!0}))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("keyup",this._onKeyUp),this.removeEventListener("click",this._onClick),this.dispatchEvent(new CustomEvent(`unregister-${t}`,{bubbles:!0,composed:!0}))}_onKeyUp(n){n.altKey||(n.code==="Space"||n.code==="Enter")&&(n.preventDefault(),this._activate())}_onClick(){this.disabled||this.readonly||(this.focus(),this._activate())}_activate(){this.disabled||this.readonly||this.dispatchEvent(new CustomEvent(`activate-${t}`,{bubbles:!0,composed:!0,detail:{identifier:this.identifier}}))}render(){return b`<slot></slot>`}}return fi([p({type:String})],e.prototype,"identifier",void 0),fi([p({type:Number,reflect:!0,attribute:"tabindex"})],e.prototype,"tabIndex",void 0),fi([p({type:Boolean,attribute:"aria-disabled",converter:kh})],e.prototype,"disabled",void 0),fi([p({type:Boolean,attribute:"aria-readonly",converter:kh})],e.prototype,"readonly",void 0),fi([_({context:Ti,subscribe:!0}),T()],e.prototype,"_interactionContext",void 0),fi([L("disabled",{waitUntilFirstUpdate:!0})],e.prototype,"handleDisabledChange",null),fi([L("readonly",{waitUntilFirstUpdate:!0})],e.prototype,"handleReadonlyChange",null),e}var Eh=[P,q`
6748
6753
  /*
6749
6754
  * A chip's own box. Both drag-drop interactions that use this element laid it out from the
6750
6755
  * theme — gap-match with 'display: flex !important; align-items: center !important',
@@ -7045,7 +7050,7 @@ div.full-correct-response-inline {
7045
7050
  }
7046
7051
  `];var Fo=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},Lt=class extends Et(C,"qti-simple-choice"){constructor(){super(...arguments),this.templateIdentifier=null,this.showHide="show",this.fixed=!1}static{this.styles=Lh}static{this.shadowRootOptions={...C.shadowRootOptions,delegatesFocus:!0}}get checked(){return this.internals.states.has("checked")}render(){return b`<div part="control" tabindex="0"><div part="control-mark"></div></div>
7047
7052
  ${this.marker?b`<div id="label" part="marker">${this.marker}</div>`:O}
7048
- <slot part="label"></slot>`}};Fo([p({type:String,attribute:"template-identifier"})],Lt.prototype,"templateIdentifier",void 0);Fo([p({type:String,attribute:"show-hide"})],Lt.prototype,"showHide",void 0);Fo([p({type:Boolean,converter:{fromAttribute:o=>o==="true",toAttribute:o=>String(o)}})],Lt.prototype,"fixed",void 0);Fo([p({type:String,attribute:!1})],Lt.prototype,"marker",void 0);var Vh=[{tag:"qti-simple-choice",ctor:Lt}];var zh=[...wh,...qh,...kh,...Ah,..._h,...Rh,...Oh,...Dh,...$h,...Vh];var Dm=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r};function Nm(o,t,e,i,n={}){let r=n.publishWidth??!0,s=n.hostWindow??(typeof window<"u"?window:null);if(!t.length||!e.length||!s)return;let a=0,l=0,c=i.length?i:[o],d=c.map(h=>({el:h,reservation:h.style.getPropertyValue("--qti-drag-min-width"),hadStyleAttribute:h.hasAttribute("style")}));c.forEach(h=>h.style.setProperty("--qti-drag-min-width","0px")),t.forEach(h=>{let f=h.getBoundingClientRect();a=Math.max(a,f.height),l=Math.max(l,f.width)}),d.forEach(({el:h,reservation:f,hadStyleAttribute:m})=>{f?h.style.setProperty("--qti-drag-min-width",f):h.style.removeProperty("--qti-drag-min-width"),!m&&h.getAttribute("style")===""&&h.removeAttribute("style")}),n.hasChanged?.({height:a,width:l})!==!1&&(o.style.setProperty("--qti-dropzone-min-height",`${a}px`),r&&(o.style.setProperty("--qti-dropzone-min-width",`${l}px`),o.style.setProperty("--qti-drag-min-width",`${l}px`)),i.forEach(h=>{h.style.minHeight=`var(--qti-drag-container-min-height, ${a}px)`,h.style.setProperty("--qti-dropzone-min-height",`${a}px`),r&&(h.style.setProperty("--qti-dropzone-min-width",`${l}px`),h.style.setProperty("--qti-drag-min-width",`${l}px`))}))}var Tl=(o,t,e,i='slot[part="drags"]')=>{class n extends o{constructor(){super(...arguments),this.autoSizeDropzones=!0,this.#t=null,this.#e=new Set,this.#i=null,this.#r=0,this.#n=null}get autoSizeDropzoneWidth(){return!0}#t;#e;#i;#r;#n;collectAutoSizeTargets(){let s=(a,l)=>Array.from(l?.querySelectorAll(a)??[]);return{draggables:[...s(t,this),...s(t,this.shadowRoot)],droppables:[...s(e,this),...s(e,this.shadowRoot)],dragContainers:[...s(i,this),...s(i,this.shadowRoot)]}}dropzonePropertyTarget(){return this}updateMinDimensionsForDropZones(){if(!this.autoSizeDropzones)return;let{draggables:s,droppables:a,dragContainers:l}=this.collectAutoSizeTargets();s.length!==0&&(Nm(this.dropzonePropertyTarget(),s,a,l,{publishWidth:this.autoSizeDropzoneWidth,hasChanged:c=>{let d=this.#n;return d&&d.height===c.height&&d.width===c.width?!1:(this.#n=c,!0)}}),this.#a(s),this.#o())}#o(){typeof MutationObserver>"u"||this.#i||(this.#i=new MutationObserver(()=>this.#s()),this.#i.observe(this,{childList:!0,subtree:!0,characterData:!0}))}#s(){this.#r||(this.#r=requestAnimationFrame(()=>{this.#r=0,this.updateMinDimensionsForDropZones()}))}#a(s){if(typeof ResizeObserver>"u")return;this.#t??=new ResizeObserver(()=>this.#s());let a=new Set(s);for(let l of this.#e)a.has(l)||this.#t.unobserve(l);for(let l of a)this.#e.has(l)||this.#t.observe(l);this.#e=a}disconnectedCallback(){this.#t?.disconnect(),this.#t=null,this.#e.clear(),this.#i?.disconnect(),this.#i=null,this.#r&&cancelAnimationFrame(this.#r),this.#r=0,super.disconnectedCallback()}}return Dm([p({type:Boolean,attribute:"auto-size-dropzones"})],n.prototype,"autoSizeDropzones",void 0),n};var{AbortController:Jt,AbortSignal:Rl,WeakMap:$m,WeakRef:Lm,Window:jh,reportError:Bo=console.log}=globalThis,Le=o=>o&&o.defaultView!==null&&o.defaultView.document===o&&(o.defaultView.top===o.defaultView||Le(o.defaultView.parent.document)),yi=()=>!!jh&&globalThis instanceof jh,Pl=Symbol("unset"),[Fh,Vm]=(()=>{function o(x,u,g=!0){Object.defineProperty(x,u,{...Object.getOwnPropertyDescriptor(x,u),enumerable:g})}let t="try"in Promise?Promise.try.bind(Promise):(x,...u)=>new Promise(g=>g(x(...u))),e="withResolvers"in Promise?Promise.withResolvers.bind(Promise):()=>{let x,u;return{promise:new Promise((y,w)=>(x=y,u=w)),resolve:x,reject:u}};function i(x,u){let g=u.call(x);if(g===null||typeof g!="object")throw new TypeError("Iterator is not an object");return g}let n=new $m,r={next(...x){let u=this,g=n.get(u);if(!g?.syncIteratorRecord)throw new TypeError("AsyncFromSyncIteratorPrototype.next called on invalid object");let{syncIteratorRecord:y}=g;return t(()=>y.next(...x))},return(...x){let u=this,g=n.get(u);if(!g?.syncIteratorRecord)throw new TypeError("AsyncFromSyncIteratorPrototype.return called on invalid object");let{syncIteratorRecord:y}=g;return t(()=>y.return?y.return(...x):{value:void 0,done:!0})},throw(...x){let u=this,g=n.get(u);if(!g?.syncIteratorRecord)throw new TypeError("AsyncFromSyncIteratorPrototype.throw called on invalid object");let{syncIteratorRecord:y}=g;return t(()=>{if(!y.throw)throw y.return(),new TypeError("no throw method");return y.throw(...x)})}};function s(x){let u=Object.create(r);return n.set(u,{syncIteratorRecord:x}),u}function a(x,u){let g;if(u){if(g=x[Symbol.asyncIterator],g==null){if(g=x[Symbol.iterator],g==null)throw new TypeError("Object is not async iterable");let y=i(x,g);return s(y)}}else g=x[Symbol.iterator];if(g==null)throw new TypeError("Object is not iterable");return i(x,g)}let l="any"in Rl?Rl.any.bind(Rl):x=>{let u=new Jt;for(let g of x)if(g.aborted)return u.abort(g.reason),u.signal;for(let g of x)g.addEventListener("abort",()=>{u.abort(g.reason)},{signal:u.signal});return u.signal},c=x=>l(x.filter(Boolean));class d{constructor({next:u,error:g,complete:y}={}){n.set(this,{next:u,error:g,complete:y})}next(u){let{next:g}=n.get(this)||{};g&&g(u)}error(u){let{error:g}=n.get(this)||{};g?g(u):Bo(u)}complete(){let{complete:u}=n.get(this)||{};u&&u()}}function h(x,u){let g=n.get(x);if(g?.active){g.active=!1,g.subscriptionController.abort(u);for(let y of g.teardowns.reverse()){if(yi()&&!Le(document))return;try{y()}catch(w){Bo(w)}}}}function f(x,u,g={}){if(yi()&&!Le(document))return;let y;typeof u=="function"?y=new d({next:u}):u&&!(u instanceof d)?y=new d(u):y=u||new d;let w=n.get(x),I=w.weakSubscriber?.deref();if(I?.active){let S=I,k=n.get(S);k.observers.add(y),g.signal&&(g.signal.aborted?k.observers.delete(y):g.signal.addEventListener("abort",()=>{let R=n.get(S);R?.active&&(R.observers.delete(y),R.observers.size==0&&h(S,g.signal.reason))}));return}let A=new m(y);if(w.weakSubscriber=new Lm(A),"signal"in g&&(g.signal.aborted?h(A,g.signal.reason):g.signal.addEventListener("abort",()=>{let S=n.get(A);S?.active&&(S.observers.delete(y),S.observers.size==0&&h(A,g.signal.reason))})),w.subscribeCallback)try{w.subscribeCallback(A)}catch(S){A.error(S)}}class m{get[Symbol.toStringTag](){return"Subscriber"}constructor(u=null){if(!(u instanceof d))throw new TypeError("Illegal constructor");n.set(this,{active:!0,observers:new Set([u]),teardowns:[],subscriptionController:new Jt})}next(u){if(!(this instanceof m))throw new TypeError("illegal invocation");if(!arguments.length)throw new TypeError("too few arguments");let g=n.get(this);if(!g?.active||yi()&&!Le(document))return;let y=new Set(g.observers);for(let w of y)w.next(u)}error(u){if(!(this instanceof m))throw new TypeError("illegal invocation");if(!arguments.length)throw new TypeError("too few arguments");let g=n.get(this);if(!g?.active){Bo(u);return}if(yi()&&!Le(document))return;h(this,u);let y=new Set(g.observers);for(let w of y)w.error(u)}complete(){if(!(this instanceof m))throw new TypeError("illegal invocation");let u=n.get(this);if(!u?.active||yi()&&!Le(document))return;h(this);let g=new Set(u.observers);for(let y of g)y.complete()}addTeardown(u){if(!(this instanceof m))throw new TypeError("illegal invocation");if(typeof u!="function")throw new TypeError("Parameter 1 is not of type 'Function'");if(yi()&&!Le(document))return;let g=n.get(this);g?.active?g.teardowns.push(u):u()}get active(){if(!(this instanceof m))throw new TypeError("illegal invocation");return!!n.get(this)?.active}get signal(){if(!(this instanceof m))throw new TypeError("illegal invocation");if(!n.has(this)){let u=new Jt;return u.abort(),u.signal}return n.get(this).subscriptionController.signal}}o(m.prototype,"next"),o(m.prototype,"error"),o(m.prototype,"complete"),o(m.prototype,"addTeardown"),o(m.prototype,"active"),o(m.prototype,"signal");class v{get[Symbol.toStringTag](){return"Observable"}constructor(u){if(!u)throw new TypeError("1 argument required but 0 present");n.set(this,{weakSubscriber:null,subscribeCallback:u})}static from(u){if(u===null||typeof u!="object")throw new TypeError("Observable.from only accepts objects");if(u instanceof v)return u;if(typeof(Symbol.asyncIterator in u&&u[Symbol.asyncIterator])=="function"){let I=function(A,S){if(A.signal.aborted)return;let k;try{let R=S.next();k=Promise.resolve(R)}catch(R){k=Promise.reject(R)}k.then(R=>{if(R===null||typeof R!="object"){A.error(new TypeError("Not an IteratorResult."));return}try{({done:w}=R)}catch(z){A.error(z);return}if(w){A.complete();return}let N;try{N=R.value}catch(z){A.error(z);return}A.next(N),I(A,S)},R=>{A.error(R)})},w=!1;return new v(A=>{if(A.signal.aborted)return;let S;try{S=a(u,!0)}catch(R){A.error(R);return}let k=S;A.signal.aborted||(A.signal.addEventListener("abort",()=>{if(typeof k.return!="function"||w)return;t(()=>k.return(A.signal.reason)).then(N=>{if(N===null||typeof N!="object")throw new TypeError("Iterator .return() must return an Object")})}),I(A,k))})}if(typeof(Symbol.iterator in u&&u[Symbol.iterator])=="function")return new v(w=>{if(w.signal.aborted)return;let I;try{I=a(u,!1)}catch(k){w.error(k);return}let A=!1,S=I;if(!w.signal.aborted)for(w.signal.addEventListener("abort",()=>{if(typeof S.return!="function"||A)return;let k=S.return();if(k===null||typeof k!="object")throw new TypeError("Iterator .return() must return an Object")});;)try{let k=S.next();if({done:A}=k,A){w.complete();return}if(w.next(k.value),w.signal.aborted)break}catch(k){w.error(k);break}});if(u instanceof Promise||typeof u.then=="function")return new v(w=>{u.then(I=>{w.next(I),w.complete()},I=>{w.error(I)})});throw new TypeError("Could not convert value to Observable")}subscribe(u=null,g={}){if(!(this instanceof v))throw new TypeError("illegal invocation");f(this,u,g)}takeUntil(u){if(!(this instanceof v))throw new TypeError("illegal invocation");let g=this,y=v.from(u);return new v(w=>{let I=new d({next(){w.complete()},error(){w.complete()}}),A={signal:w.signal};if(f(y,I,A),!w.active)return;let S=new d({next(k){w.next(k)},error(k){w.error(k)},complete(){w.complete()}});f(g,S,A)})}map(u){if(!(this instanceof v))throw new TypeError("illegal invocation");if(typeof u!="function")throw new TypeError("Parameter 1 is not of type 'Function'");let g=this;return new v(y=>{let w=0,I=new d({next(S){let k;try{k=u(S,w)}catch(R){y.error(R);return}w+=1,y.next(k)},error(S){y.error(S)},complete(){y.complete()}}),A={signal:y.signal};f(g,I,A)})}inspect(u={}){let g=null,y=null,w=null,I=null,A=null;typeof u=="function"?y=u:u&&typeof u=="object"&&("subscribe"in u&&(g=u.subscribe),"next"in u&&(y=u.next),"error"in u&&(w=u.error),"complete"in u&&(I=u.complete),"abort"in u&&(A=u.abort));let S=this;return new v(k=>{if(g!==null)try{g()}catch($){k.error($);return}let R=()=>{try{A!==null&&A(k.signal.reason)}catch($){Bo($)}};k.signal.addEventListener("abort",R,{once:!0});let N=new d({next($){if(y!==null)try{y($)}catch(ut){k.signal.removeEventListener("abort",R),k.error(ut);return}k.next($)},error($){if(k.signal.removeEventListener("abort",R),w!==null)try{w($)}catch(ut){k.error(ut);return}k.error($)},complete(){if(k.signal.removeEventListener("abort",R),I!==null)try{I()}catch($){k.error($);return}k.complete()}}),z={signal:k.signal};f(S,N,z)})}filter(u){if(!(this instanceof v))throw new TypeError("illegal invocation");if(typeof u!="function")throw new TypeError("Parameter 1 is not of type 'Function'");let g=this;return new v(y=>{let w=0,I=new d({next(S){let k=!1;try{k=u(S,w)}catch(R){y.error(R);return}w+=1,k&&y.next(S)},error(S){y.error(S)},complete(){y.complete()}}),A={signal:y.signal};f(g,I,A)})}take(u){if(!(this instanceof v))throw new TypeError("illegal invocation");let g=this;return new v(y=>{let w=u;if(w==0)return y.complete();let I=new d({next(S){y.next(S),w-=1,w==0&&y.complete()},error(S){y.error(S)},complete(){y.complete()}}),A={signal:y.signal};f(g,I,A)})}drop(u){if(!(this instanceof v))throw new TypeError("illegal invocation");let g=this;return new v(y=>{let w=u,I=new d({next(S){if(w>0)return w-=1;w==0&&y.next(S)},error(S){y.error(S)},complete(){y.complete()}}),A={signal:y.signal};f(g,I,A)})}flatMap(u){if(!(this instanceof v))throw new TypeError("illegal invocation");if(typeof u!="function")throw new TypeError("Parameter 1 is not of type 'Function'");let g=this;return new v(y=>{let w=0,I=!1,A=[];function S(z){let $;try{$=u(z,w)}catch(te){return y.error(te)}w+=1;let ut;try{ut=v.from($)}catch(te){return y.error(te)}let Sa=new d({next(te){y.next(te)},error(te){y.error(te)},complete(){if(A.length){let te=A.shift();S(te)}else k=!1,I&&y.complete()}}),Bt={signal:y.signal};f(ut,Sa,Bt)}let k=!1,R=new d({next(z){k?A.push(z):(k=!0,S(z))},error(z){y.error(z)},complete(){I=!0,!k&&!A.length&&y.complete()}}),N={signal:y.signal};f(g,R,N)})}switchMap(u){if(!(this instanceof v))throw new TypeError("illegal invocation");if(typeof u!="function")throw new TypeError("Parameter 1 is not of type 'Function'");let g=this;return new v(y=>{let w=0,I=!1,A=null;function S(N){let z;try{z=u(N,w)}catch(Bt){return y.error(Bt)}w+=1;let $;try{$=v.from(z)}catch(Bt){return y.error(Bt)}let ut=new d({next(Bt){y.next(Bt)},error(Bt){y.error(Bt)},complete(Bt){I?y.complete():A=null}}),Sa={signal:c([A.signal,y.signal])};f($,ut,Sa)}let k=new d({next(N){A&&A.abort(),A=new Jt,S(N)},error(N){y.error(N)},complete(){I=!0,A||y.complete()}}),R={signal:y.signal};f(g,k,R)})}catch(u){if(!(this instanceof v))throw new TypeError("illegal invocation");if(typeof u!="function")throw new TypeError("Parameter 1 is not of type 'Function'");let g=this;return new v(w=>{let I=new d({next(S){w.next(S)},error(S){let k;try{k=u(S)}catch($){w.error($);return}let R;try{R=v.from(k)}catch($){w.error($);return}let N=new d({next($){w.next($)},error($){w.error($)},complete(){w.complete()}}),z={signal:w.signal};f(R,N,z)},complete(){w.complete()}}),A={signal:w.signal};f(g,I,A)})}finally(u){if(!(this instanceof v))throw new TypeError("illegal invocation");if(typeof u!="function")throw new TypeError("Parameter 1 is not of type 'Function'");let g=this;return new v(y=>{y.addTeardown(u);let w=new d({next(A){y.next(A)},error(A){y.error(A)},complete(){y.complete()}}),I={signal:y.signal};f(g,w,I)})}toArray(u={}){if(!(this instanceof v))throw new TypeError("illegal invocation");let{promise:g,resolve:y,reject:w}=e();if(u.signal){if(u.signal.aborted)return Promise.reject(u.signal.reason);u.signal.addEventListener("abort",()=>{w(u.signal.reason)})}let I=[],A=new d({next(S){I.push(S)},error(S){w(S)},complete(){y(I)}});return f(this,A,u),g}forEach(u,g={}){if(!(this instanceof v))throw new TypeError("illegal invocation");if(typeof u!="function")throw new TypeError("Parameter 1 is not of type 'Function'");let{promise:y,resolve:w,reject:I}=e(),A=new Jt,S={signal:c([A.signal,g.signal])};if(S.signal.aborted)return I(S.signal.reason),y;S.signal.addEventListener("abort",()=>{I(S.signal.reason)});let k=0,R=new d({next(N){try{u(N,k)}catch(z){I(z),A.abort(z)}k+=1},error(N){I(N)},complete(){w()}});return f(this,R,S),y}every(u,g={}){if(!(this instanceof v))throw new TypeError("illegal invocation");if(typeof u!="function")throw new TypeError("Parameter 1 is not of type 'Function'");let{promise:y,resolve:w,reject:I}=e(),A=new Jt,S={signal:c([A.signal,g.signal])};if(S.signal.aborted)return I(S.signal.reason),y;S.signal.addEventListener("abort",()=>{I(S.signal.reason)});let k=0,R=new d({next(N){let z=!1;try{z=u(N,k)}catch($){I($),A.abort($)}k+=1,z||(w(!1),A.abort())},error(N){I(N)},complete(){w(!0)}});return f(this,R,S),y}first(u={}){if(!(this instanceof v))throw new TypeError("illegal invocation");let{promise:g,resolve:y,reject:w}=e(),I=new Jt,A={signal:c([I.signal,u.signal])};if(A.signal.aborted)return w(A.signal.reason),g;A.signal.addEventListener("abort",()=>{w(A.signal.reason)});let S=new d({next(k){y(k),I.abort()},error(k){w(k)},complete(){w(new RangeError("No values in Observable"))}});return f(this,S,A),g}last(u={}){if(!(this instanceof v))throw new TypeError("illegal invocation");let{promise:g,resolve:y,reject:w}=e();if(u.signal){if(u.signal.aborted)return w(u.signal.reason),g;u.signal.addEventListener("abort",()=>{w(u.signal.reason)})}let I=null,A=!1,S=new d({next(k){A=!0,I=k},error(k){w(k)},complete(){A?y(I):w(new RangeError("No values in Observable"))}});return f(this,S,u),g}find(u,g={}){if(!(this instanceof v))throw new TypeError("illegal invocation");if(typeof u!="function")throw new TypeError("Parameter 1 is not of type 'Function'");let{promise:y,resolve:w,reject:I}=e(),A=new Jt,S={signal:c([A.signal,g.signal])};if(S.signal.aborted)return I(S.signal.reason),y;S.signal.addEventListener("abort",()=>{I(S.signal.reason)});let k=0,R=new d({next(N){let z=!1;try{z=u(N,k)}catch($){I($),A.abort($)}k+=1,z&&(w(N),A.abort())},error(N){I(N)},complete(){w()}});return f(this,R,S),y}some(u,g={}){if(!(this instanceof v))throw new TypeError("illegal invocation");if(typeof u!="function")throw new TypeError("Parameter 1 is not of type 'Function'");let{promise:y,resolve:w,reject:I}=e(),A=new Jt,S={signal:c([A.signal,g.signal])};if(S.signal.aborted)return I(S.signal.reason),y;S.signal.addEventListener("abort",()=>{I(S.signal.reason)});let k=0,R=new d({next(N){let z=!1;try{z=u(N,k)}catch($){I($),A.abort($)}k+=1,z&&(w(!0),A.abort())},error(N){I(N)},complete(){w(!1)}});return f(this,R,S),y}reduce(u,g,y={}){if(!(this instanceof v))throw new TypeError("illegal invocation");if(typeof u!="function")throw new TypeError("Parameter 1 is not of type 'Function'");let{promise:w,resolve:I,reject:A}=e(),S=new Jt,k={signal:c([S.signal,y.signal])};if(k.signal.aborted)return A(k.signal.reason),w;k.signal.addEventListener("abort",()=>{A(k.signal.reason)},{once:!0});let R=0,N=arguments.length>1?g:Pl,z=new d({next($){if(N===Pl){N=$,R++;return}try{let ut=u(N,$,R);R++,N=ut}catch(ut){A(ut),S.abort(ut);return}},error($){A($)},complete(){N!==Pl?I(N):A(new TypeError("no initial value provided and no values emitted"))}});return f(this,z,k),w}}return o(v.prototype,"subscribe"),[v,m]})();function Bh(){return typeof globalThis.Observable=="function"}function Uh(){Object.defineProperties(globalThis,{Observable:{value:Fh,configurable:!0,writable:!0},Subscriber:{value:Vm,configurable:!0,writable:!0}}),EventTarget.prototype.when=function(o,t={}){if(yi()&&!Le(document))return;let e=this;return new Fh(i=>{if(!e||i.signal.aborted)return;let n=r=>{i.next(r)};e.addEventListener(o,n,{capture:t.capture||!1,passive:t.passive,once:!1,signal:i.signal})})}}function Ol(o,t,e){let i=o.filter(n=>!n.hasAttribute("disabled"));for(let n of i){let r=n.getBoundingClientRect();if(t>=r.left&&t<=r.right&&e>=r.top&&e<=r.bottom)return n}return null}function Hh(o,t,e,i){if(!i)return null;let n=o.filter(s=>!s.hasAttribute("disabled")),r=i.getBoundingClientRect();for(let s of n){let a=s.getBoundingClientRect();if(!(r.right<a.left||r.left>a.right||r.bottom<a.top||r.top>a.bottom))return s}return null}function Wh(o,t,e,i){let n=o.filter(c=>!c.hasAttribute("disabled"));if(n.length===0)return null;let r,s;if(i){let c=i.getBoundingClientRect();r=c.left+c.width/2,s=c.top+c.height/2}else r=t,s=e;let a=null,l=1/0;for(let c of n){let d=c.getBoundingClientRect(),h=d.left+d.width/2,f=d.top+d.height/2,m=Math.sqrt(Math.pow(r-h,2)+Math.pow(s-f,2));m<l&&(l=m,a=c)}return a}function Qh(o,t,e,i){let n=o.filter(l=>!l.hasAttribute("disabled"));if(n.length===0)return null;let r;if(i){let l=i.getBoundingClientRect();r=[{x:l.left,y:l.top},{x:l.right,y:l.top},{x:l.left,y:l.bottom},{x:l.right,y:l.bottom}]}else r=[{x:t,y:e},{x:t,y:e},{x:t,y:e},{x:t,y:e}];let s=null,a=1/0;for(let l of n){let c=l.getBoundingClientRect(),d=[{x:c.left,y:c.top},{x:c.right,y:c.top},{x:c.left,y:c.bottom},{x:c.right,y:c.bottom}],h=0,f=0;for(let v of r)for(let x of d){let u=Math.sqrt(Math.pow(v.x-x.x,2)+Math.pow(v.y-x.y,2));h+=u,f++}let m=h/f;m<a&&(a=m,s=l)}return s}function zm(o,t,e){let i=o.getBoundingClientRect();return t>=i.left&&t<=i.right&&e>=i.top&&e<=i.bottom}function jm(o,t,e,i,n){let r=n&&n.length>0?o.filter(g=>n.includes(g)):o.filter(g=>g.tagName==="SLOT"&&g.hasAttribute("part")&&g.getAttribute("part")?.includes("drags")),a=o.filter(g=>!r.includes(g));if(r.length===0&&a.length===0)return null;let l;if(i){let g=i.getBoundingClientRect();l=[{x:g.left,y:g.top},{x:g.right,y:g.top},{x:g.left,y:g.bottom},{x:g.right,y:g.bottom}]}else l=[{x:t,y:e},{x:t,y:e},{x:t,y:e},{x:t,y:e}];let c=g=>{let y=g.getBoundingClientRect(),w=[{x:y.left,y:y.top},{x:y.right,y:y.top},{x:y.left,y:y.bottom},{x:y.right,y:y.bottom}],I=0,A=0;for(let S of l)for(let k of w){let R=Math.sqrt(Math.pow(S.x-k.x,2)+Math.pow(S.y-k.y,2));I+=R,A++}return I/A},d=null,h=1/0;for(let g of r){let y=c(g);y<h&&(h=y,d=g)}let f=null,m=1/0;for(let g of a){let y=c(g);y<m&&(m=y,f=g)}if(d&&i){let g=i.getBoundingClientRect(),y=d.getBoundingClientRect(),w=g.left+g.width/2,I=g.top+g.height/2;if(w>=y.left&&w<=y.right&&I>=y.top&&I<=y.bottom)return d}if(f&&zm(f,t,e))return f;let x=i?.getAttribute("data-drag-origin")==="droppable"?.85:1.5;return d&&f?h<=m*x?d:f:d||f}function Xh(o){switch(o){case"pointerWithin":return Ol;case"rectangleIntersection":return Hh;case"closestCenter":return Wh;case"closestCorners":return Qh;case"closestCornersWithInventoryPriority":return jm;default:return Ol}}function Ji(o,t,e,i,n="pointerWithin",r){return Xh(n)(o,t,e,i,r)}function Ve(o,t){let e=o.composedPath?o.composedPath():[o.target];for(let i of e)if(i instanceof HTMLElement&&i.tagName!=="SLOT"){if(i.matches(t)||i.hasAttribute("qti-draggable"))return i;let n=i.closest(t)||i.closest('[qti-draggable="true"]');if(n)return n}return null}function dn(o){return o?o.hasAttribute("disabled")?!0:o.internals?.states?.has("disabled")??!1:!1}var Ml=o=>o?.internals;function Vt(o,t,e){let i=Ml(o)?.states;i&&(e?i.add(t):i.delete(t))}function Uo(o,t){return Ml(o)?.states?.has(t)??!1}function hn(o){Vt(o,"dragging",!1),Vt(o,"placeholder",!1),Vt(o,"return-anchor",!1)}function vi(o){return Uo(o,"dragging")||Uo(o,"placeholder")}function he(o,t,e){if(!o)return;e?o.setAttribute(t,""):o.removeAttribute(t);let i=Ml(o)?.states;if(i){e?i.add(t):i.delete(t);return}let n=new Set((o.getAttribute("part")??"").split(/\s+/).filter(Boolean));n.has("drop")&&(e?n.add(t):n.delete(t),o.setAttribute("part",[...n].join(" ")))}function Ki(o,t){he(o,"filled",t)}function Zi(o,t){let e=[];return o.forEach(i=>{let n=[];i.tagName.toLowerCase()==="slot"?n=i.assignedElements({flatten:!0}).filter(a=>a.getAttribute("identifier")===t):n=Array.from(i.querySelectorAll(`[identifier="${t}"]`)),e.push(...n)}),e}function Gh(o,t){let e=o.find(n=>n.getAttribute("identifier")===t);if(!e)return 1;let i=e.getAttribute("match-max");return i?parseInt(i,10)||0:1}var Dl={origin:{x:0,y:0},scale:{x:1,y:1}},Ho=100,Fm=o=>{let t=o.fullscreenElement??o.webkitFullscreenElement??null;for(;t instanceof HTMLElement;){let e=t.shadowRoot?.fullscreenElement??null;if(!e||e===t)break;t=e}return t instanceof HTMLElement?t:null},Bm=o=>{let t=o.shadowRoot;return t?t.querySelector("slot:not([name])")?o:t:o},Um=(o,t)=>{let e=t;for(;e;){if(e===o)return!0;e=e.parentNode??e.host??null}return!1},Nl=(o,t)=>{let e=o.ownerDocument??document,i=t??e.body,n=Fm(e);return n&&!Um(n,i)?Bm(n):i},$l=o=>{let e=(o.ownerDocument??document).createElement("div");e.style.cssText=`position:fixed;left:0;top:0;width:${Ho}px;height:${Ho}px;margin:0;padding:0;border:0;visibility:hidden;pointer-events:none;`,o.appendChild(e);let i=e.getBoundingClientRect();return e.remove(),{origin:{x:i.left,y:i.top},scale:{x:i.width/Ho||1,y:i.height/Ho||1}}},Yh=(o,t,e)=>({x:(t-o.origin.x)/o.scale.x,y:(e-o.origin.y)/o.scale.y});Bh()||Uh();var Jh=new WeakSet;function Hm(o){!o||Jh.has(o)||(o.addEventListener("touchmove",()=>{},{capture:!1,passive:!1}),Jh.add(o))}var Kh=o=>!!o.internals?.states,Wo=(o,t,e,i='slot[part="drags"]',n="pointerWithin")=>{class r extends o{constructor(){super(...arguments),this.trackedDraggables=[],this.trackedDroppables=[],this.trackedDragContainers=[],this.allDropzones=[],this.collisionDetectionAlgorithm=n,this.dragState={dragging:!1,dragSource:null,dragClone:null,startOffset:{x:0,y:0},currentTarget:null,sourceDroppable:null,inputType:null,returnAnchorItems:[]},this.cloneFrame=Dl,this.subscriptions=[],this.dragSubscriptions=[],this.lastPointerDownAt=0,this.lastTouchStartAt=0,this.#t=new Set,this.#e=new Set,this.#i=a=>{let l=a;if(l.context!==_i)return;let c=l.contextTarget;c instanceof HTMLElement&&this.#e.add(c)}}#t;isDragDropEnabled(){return!0}publishDraggablesSelector(){let a=this.isDragDropEnabled()?t:null;this._interactionContext.draggablesSelector!==a&&(this._interactionContext={...this._interactionContext,draggablesSelector:a})}connectedCallback(){super.connectedCallback(),this.addEventListener("context-request",this.#i,{capture:!0}),Hm(this.ownerDocument?.defaultView),this.publishDraggablesSelector(),this.setupDragDrop()}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("context-request",this.#i,{capture:!0}),this.#e.clear(),this.cleanup()}async setupDragDrop(){await this.updateComplete,this.cacheInteractiveElements(),this.afterCache(),this.setupDragObservables()}afterCache(){}removeChipFromDroppable(a,l){l.remove()}#e;#i;registeredMatching(a){for(let l of this.#e)l.isConnected||this.#e.delete(l);return[...this.#e].filter(l=>l.matches(a))}cacheInteractiveElements(){let a=(k,R)=>Array.from(R?.querySelectorAll(k)??[]),l=a(t,this),c=a(t,this.shadowRoot),d=a('[qti-draggable="true"]:not([data-drag-clone])',this),h=a('[qti-draggable="true"]:not([data-drag-clone])',this.shadowRoot),f=this.registeredMatching(t);this.trackedDraggables=Array.from(new Set([...l,...c,...d,...h,...f]));let m=a(e,this),v=a(e,this.shadowRoot);this.trackedDroppables=Array.from(new Set([...m,...v]));let x=a(i,this),u=a(i,this.shadowRoot);this.trackedDragContainers=Array.from(new Set([...x,...u])),this.allDropzones=[...this.trackedDroppables,...this.trackedDragContainers];let g=this.isDragDropEnabled(),y=new Set(this.trackedDraggables),w=new Set(this.trackedDroppables),I=g?y:new Set,A=g?w:new Set,S=new Set([...y,...w].filter(Kh));for(let k of this.#t)S.has(k)||(k.internals.states.delete("drag"),k.internals.states.delete("droppable"));for(let k of S){let R=I.has(k),N=!R&&A.has(k);R?k.internals.states.add("drag"):k.internals.states.delete("drag"),N?k.internals.states.add("droppable"):k.internals.states.delete("droppable")}this.#t=S,this.trackedDraggables.forEach(k=>{let R=vi(k);g&&!R?(k.style.cursor="grab",k.style.userSelect="none",k.style.touchAction="none",k.style.webkitUserSelect="none",k.style.webkitTouchCallout="none",k.setAttribute("qti-draggable","true"),k.setAttribute("tabindex","0")):(k.style.cursor="",k.style.userSelect="",k.style.touchAction="",k.style.webkitUserSelect="",k.style.webkitTouchCallout="",k.removeAttribute("qti-draggable"),k.getAttribute("tabindex")==="0"&&k.removeAttribute("tabindex"))})}setupDragObservables(){let a=this.shadowRoot;if(!a){console.error("\u274C [Observable DnD] No shadow root found!");return}let l=a.when("pointerdown").filter(m=>{if(!m.isTrusted)return!1;let v=Ve(m,t),x=this.disabled||this.readonly,u=dn(v)||vi(v),g=Date.now()-this.lastTouchStartAt<50;return v&&m.isPrimary!==!1&&m.button===0&&!x&&!u&&!g}).subscribe(m=>{this.lastPointerDownAt=Date.now();let v=Ve(m,t);if(!v){console.warn("\u26A0\uFE0F [Observable DnD] No draggable target found");return}m.pointerType==="touch"&&(m.preventDefault(),m.stopPropagation());let x=m.isTrusted?m.pointerType==="touch"?100:10:0;if(this.dragState.activationTimeout&&clearTimeout(this.dragState.activationTimeout),x===0){this.dragState.dragging||this.initiateDrag(v,m.clientX,m.clientY,m.pointerType,"pointer",m.pointerId,m.isTrusted);return}let u=()=>{this.dragState.activationTimeout&&(clearTimeout(this.dragState.activationTimeout),this.dragState.activationTimeout=void 0),document.removeEventListener("pointerup",u,!0),document.removeEventListener("pointercancel",u,!0)};document.addEventListener("pointerup",u,{once:!0,capture:!0}),document.addEventListener("pointercancel",u,{once:!0,capture:!0}),this.dragState.activationTimeout=window.setTimeout(()=>{this.dragState.activationTimeout=void 0,document.removeEventListener("pointerup",u,!0),document.removeEventListener("pointercancel",u,!0),this.dragState.dragging||this.initiateDrag(v,m.clientX,m.clientY,m.pointerType,"pointer",m.pointerId,m.isTrusted)},x)}),c=a.when("mousedown").filter(m=>{let v=Ve(m,t),x=this.disabled||this.readonly,u=dn(v)||vi(v),g=m.button===0,y=Date.now()-this.lastPointerDownAt<50;return v&&g&&!x&&!u&&!y}).subscribe(m=>{let v=Ve(m,t);!v||this.dragState.dragging||(m.preventDefault(),this.initiateDrag(v,m.clientX,m.clientY,"mouse","mouse",void 0,m.isTrusted))}),d=a.when("touchstart").filter(m=>{let v=Ve(m,t),x=this.disabled||this.readonly,u=dn(v)||vi(v),g=!!(m.touches?.[0]||m.changedTouches?.[0]),y=Date.now()-this.lastPointerDownAt<50;return v&&g&&!x&&!u&&!y}).subscribe(m=>{let v=Ve(m,t),x=m.touches?.[0]||m.changedTouches?.[0];!v||!x||this.dragState.dragging||(this.lastTouchStartAt=Date.now(),m.preventDefault(),m.stopPropagation(),this.initiateDrag(v,x.clientX,x.clientY,"touch","touch",void 0,m.isTrusted))}),h={dragging:!1,dragElement:null,dragIndex:0,dropIndex:0,dropElement:null},f=a.when("keydown").subscribe(m=>{let v=this.trackedDraggables.filter(u=>!vi(u)),x=[...this.trackedDroppables,...this.trackedDragContainers];if(h.dragging)switch(m.code){case"ArrowRight":case"ArrowDown":{m.preventDefault();let u=(h.dropIndex+1)%x.length;h={...h,dropIndex:u,dropElement:x[u]};break}case"ArrowLeft":case"ArrowUp":{m.preventDefault();let u=(h.dropIndex-1+x.length)%x.length;h={...h,dropIndex:u,dropElement:x[u]};break}case"Space":case"Enter":case"Tab":{m.preventDefault(),h.dragElement&&h.dropElement&&(this.allowDrop(h.dragElement,h.dropElement)||this.trackedDragContainers.includes(h.dropElement)?this.handleDrop(h.dragElement,h.dropElement):this.handleInvalidDrop(h.dragElement)),this.trackedDraggables.forEach(u=>u.removeAttribute("data-keyboard-dragging")),this.saveResponse(),h={dragging:!1,dragElement:null,dragIndex:0,dropIndex:0,dropElement:null};break}case"Escape":{m.preventDefault(),this.trackedDraggables.forEach(u=>u.removeAttribute("data-keyboard-dragging")),h={dragging:!1,dragElement:null,dragIndex:0,dropIndex:0,dropElement:null};break}}else{let u=Ve(m,t),g=this.disabled||this.readonly,y=dn(u)||vi(u);u&&["Space","Enter"].includes(m.code)&&!g&&!y&&(m.preventDefault(),u.setAttribute("data-keyboard-dragging","true"),h={dragging:!0,dragElement:u,dragIndex:v.indexOf(u),dropIndex:0,dropElement:x[0]})}this.allDropzones.forEach(u=>u.removeAttribute("hover")),h.dragging&&h.dropElement&&(h.dropElement.setAttribute("hover",""),h.dropElement.hasAttribute("tabindex")&&h.dropElement.getAttribute("tabindex")!=="-1"&&h.dropElement.focus())});this.subscriptions.push(l,c,d,f)}initiateDrag(a,l,c,d,h="pointer",f,m){if(this.dragState.dragging){console.warn("\u26A0\uFE0F [Observable DnD] Already dragging, ignoring initiateDrag");return}if(a.hasAttribute("data-drag-clone")){console.warn("\u26A0\uFE0F [Observable DnD] Attempted to drag visual clone, ignoring");return}let v=y=>y.contains(a)||!!y.shadowRoot?.contains(a),x=this.trackedDroppables.some(v),u=this.trackedDroppables.find(v)||null;a.getAnimations().forEach(y=>y.cancel());let g=a.getBoundingClientRect();if(this.dragState={dragging:!0,dragSource:a,dragClone:this.createDragClone(a,g),startOffset:{x:l-g.left,y:c-g.top},currentTarget:null,sourceDroppable:u,inputType:d,pointerId:f,startedFromTrustedEvent:m,initialCoordinates:{x:l,y:c},returnAnchorItems:[]},x){this.dragState.dragClone?.setAttribute("data-drag-origin","droppable"),this.removeChipFromDroppable(u,a),this.cacheInteractiveElements(),u&&u.setAttribute("data-drag-source","true");let y=a.getAttribute("identifier");if(y){let w=Zi(this.trackedDragContainers,y);w.forEach(I=>Vt(I,"return-anchor",!0)),this.dragState.returnAnchorItems=w}}else this.dragState.dragClone?.setAttribute("data-drag-origin","inventory"),Vt(a,"dragging",!0);this.updateClonePosition(l,c),this.activateAllDroppables(),this.watchDragCloneHost(),this.setupMoveObservables(d,h)}setupMoveObservables(a,l="pointer"){if(a==="touch"){if(l==="pointer")try{let w=this.dragState.dragSource,I=this.dragState.pointerId;w&&I!==void 0&&w.setPointerCapture&&w.setPointerCapture(I)}catch{}let g=w=>{w.cancelable&&(w.preventDefault(),l==="pointer"&&w.stopPropagation())};document.addEventListener("touchmove",g,{passive:!1,capture:!0}),document.addEventListener("touchstart",g,{passive:!1,capture:!0}),document.addEventListener("touchend",g,{passive:!1,capture:!0}),document.addEventListener("gesturestart",g,{passive:!1}),document.addEventListener("gesturechange",g,{passive:!1}),document.addEventListener("gestureend",g,{passive:!1});let y=()=>{if(document.removeEventListener("touchmove",g,{capture:!0}),document.removeEventListener("touchstart",g,{capture:!0}),document.removeEventListener("touchend",g,{capture:!0}),document.removeEventListener("gesturestart",g),document.removeEventListener("gesturechange",g),document.removeEventListener("gestureend",g),l==="pointer")try{let w=this.dragState.dragSource,I=this.dragState.pointerId;w&&I!==void 0&&w.releasePointerCapture&&w.releasePointerCapture(I)}catch{}};this.dragState.touchCleanup=y}let c=l==="mouse"?"mousemove":l==="touch"?"touchmove":"pointermove",d=l==="mouse"?"mouseup":l==="touch"?"touchend":"pointerup",h=g=>{let y=this.dragState.startedFromTrustedEvent;return y===void 0||g.isTrusted===y},f=document.when(c).takeUntil(document.when(d)).subscribe({next:g=>{if(h(g)){if(g.preventDefault(),g.stopPropagation(),l==="touch"){let y=g.touches?.[0]||g.changedTouches?.[0];if(!y)return;this.handleDragMove(y.clientX,y.clientY);return}if(l==="mouse"){let y=g;if(typeof y.buttons=="number"&&(y.buttons&1)!==1)return}this.handleDragMove(g.clientX,g.clientY)}}}),m=document.when(d).subscribe({next:g=>{h(g)&&(g.preventDefault(),g.stopPropagation(),this.handleDragEnd())}}),v=l==="touch"?document.when("touchcancel").subscribe({next:g=>{h(g)&&this.handleDragEnd()}}):l==="mouse"?null:document.when("pointercancel").subscribe({next:g=>{h(g)&&this.handleDragEnd()}}),x=document.when("keydown").filter(g=>g.key==="Escape").subscribe({next:g=>{h(g)&&this.handleDragEnd()}}),u=[f,m,x];v&&u.push(v),this.dragSubscriptions.push(...u)}handleDragMove(a,l){if(!this.dragState.dragging||!this.dragState.dragClone)return;this.updateClonePosition(a,l);let c=Ji(this.allDropzones,a,l,this.dragState.dragClone,this.collisionDetectionAlgorithm,this.trackedDragContainers),d=Date.now(),h=d-(this.dragState.lastTargetChangeTime||0);c!==this.dragState.currentTarget&&(c===null||h>=50)&&(this.allDropzones.forEach(m=>he(m,"hover",!1)),c&&he(c,"hover",!0),this.dragState.currentTarget=c,this.dragState.lastTargetChangeTime=d)}handleDragEnd(){if(!this.dragState.dragging)return;let{dragSource:a,dragClone:l,currentTarget:c,sourceDroppable:d}=this.dragState,h=c;if(l){let v=l.getBoundingClientRect();h=Ji(this.allDropzones,v.left+v.width/2,v.top+v.height/2,l,this.collisionDetectionAlgorithm,this.trackedDragContainers)??c}!!a&&!!h&&this.allowDrop(a,h)&&a&&h?(this.handleDrop(a,h),Vt(a,"dragging",!1)):this.handleInvalidDrop(a),l&&l.remove(),(this.dragState.returnAnchorItems||[]).forEach(v=>{Vt(v,"return-anchor",!1)}),this.dragState.touchCleanup&&this.dragState.touchCleanup(),this.resetDragState(),this.deactivateAllDroppables(),this.saveResponse(),d&&d.removeAttribute("data-drag-source"),this.cacheInteractiveElements();let m=this.checkAllMaxAssociations;typeof m=="function"&&m.call(this)}allowDrop(a,l){return this.trackedDroppables.includes(l)||this.trackedDragContainers.includes(l)}handleInvalidDrop(a){hn(a)}createDragClone(a,l){let c=a.cloneNode(!0),d=window.getComputedStyle(a);for(let f=0;f<d.length;f++){let m=d[f];c.style.setProperty(m,d.getPropertyValue(m))}let h=Nl(a.isConnected?a:this,this.dragCloneRoot());return this.cloneFrame=$l(h),c.style.position="fixed",c.style.width=`${l.width/this.cloneFrame.scale.x}px`,c.style.height=`${l.height/this.cloneFrame.scale.y}px`,c.style.zIndex="9999",c.style.pointerEvents="none",c.style.touchAction="none",c.style.userSelect="none",c.style.opacity="0.8",c.removeAttribute("qti-draggable"),c.removeAttribute("tabindex"),c.setAttribute("data-drag-clone","true"),c.setAttribute("data-drag-interaction",this.tagName.toLowerCase()),h.appendChild(c),c}dragCloneRoot(){let a=this.getRootNode();return a instanceof ShadowRoot?a:null}updateClonePosition(a,l){if(this.dragState.lastCoordinates={x:a,y:l},!this.dragState.dragClone)return;let{startOffset:c}=this.dragState,{x:d,y:h}=Yh(this.cloneFrame,a-c.x,l-c.y);this.dragState.dragClone.style.left=`${d}px`,this.dragState.dragClone.style.top=`${h}px`}watchDragCloneHost(){let a=this.ownerDocument??document,l=()=>{let{dragClone:c,dragSource:d,lastCoordinates:h}=this.dragState;if(!c)return;let f=d?.isConnected?d:this,m=Nl(f,this.dragCloneRoot());m!==c.parentNode&&(m.appendChild(c),this.cloneFrame=$l(m),h&&this.updateClonePosition(h.x,h.y))};a.addEventListener("fullscreenchange",l),a.addEventListener("webkitfullscreenchange",l),this.dragSubscriptions.push({unsubscribe:()=>{a.removeEventListener("fullscreenchange",l),a.removeEventListener("webkitfullscreenchange",l)}})}activateAllDroppables(){this.setInternalsState("dragzone-enabled",!0),this.setInternalsState("dragzone-active",!0),this.allDropzones.forEach(a=>{he(a,"enabled",!0),he(a,"active",!0)})}deactivateAllDroppables(){this.setInternalsState("dragzone-enabled",!1),this.setInternalsState("dragzone-active",!1),this.allDropzones.forEach(a=>{he(a,"enabled",!1),he(a,"active",!1),he(a,"hover",!1)})}resetDragState(){if(this.dragState.activationTimeout&&clearTimeout(this.dragState.activationTimeout),(this.dragState.returnAnchorItems||[]).forEach(a=>{Vt(a,"return-anchor",!1)}),this.dragState.touchCleanup)try{this.dragState.touchCleanup()}catch(a){console.warn("\u26A0\uFE0F [Observable DnD] Error during touch cleanup:",a)}this.dragSubscriptions.forEach(a=>{try{a&&typeof a.unsubscribe=="function"&&a.unsubscribe()}catch(l){console.warn("\u26A0\uFE0F [Observable DnD] Error unsubscribing:",l)}}),this.dragSubscriptions=[],this.cloneFrame=Dl,this.dragState={dragging:!1,dragSource:null,dragClone:null,startOffset:{x:0,y:0},currentTarget:null,sourceDroppable:null,inputType:null,pointerId:void 0,startedFromTrustedEvent:void 0,touchCleanup:void 0,returnAnchorItems:[]}}setInternalsState(a,l){let c=this._internals;c?.states&&(l?c.states.add(a):c.states.delete(a))}cleanup(){this.subscriptions.forEach(a=>{try{a.unsubscribe()}catch{}}),this.subscriptions=[],this.dragState.dragClone&&this.dragState.dragClone.remove();for(let a of this.#t)Kh(a)&&(a.internals.states.delete("drag"),a.internals.states.delete("droppable"));this.#t.clear(),this.resetDragState()}}return r};var Zh={duration:250,easing:"ease",fill:"both"};function Ll(o){let t=o.getBoundingClientRect();return{left:t.left,top:t.top,width:t.width,height:t.height}}function tp(o){return{left:o.left,top:o.top,width:o.width,height:o.height}}function ze(o){let t=new Map;return o.forEach(e=>{t.set(e,Ll(e))}),t}function ep(o,t){return{deltaX:o.left-t.left,deltaY:o.top-t.top,deltaW:o.width/t.width,deltaH:o.height/t.height}}function Qo(o){if(typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches)return 0;if(!o)return 1;let t=getComputedStyle(o).getPropertyValue("--qti-motion").trim();if(t==="")return 1;let e=Number.parseFloat(t);return Number.isFinite(e)&&e>0?e:0}function Vl(o){return Qo(o)>0}function Xo(o,t,e={}){let i=Qo(o);if(i<=0)return null;let n=Ll(o),{deltaX:r,deltaY:s,deltaW:a,deltaH:l}=ep(t,n);if(r===0&&s===0&&a===1&&l===1)return null;let{duration:c,easing:d,fill:h}={...Zh,...e};return o.animate([{transformOrigin:"top left",transform:`translate(${r}px, ${s}px) scale(${a}, ${l})`},{transformOrigin:"top left",transform:"none"}],{duration:c*i,easing:d,fill:h})}function je(o,t={}){let e=new Map;return o.forEach((i,n)=>{if(!(n instanceof HTMLElement))return;let r=Xo(n,i,t);r&&e.set(n,r)}),e}var pn=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},zt=(o,t,e,i='slot[part="drags"]',n="closestCornersWithInventoryPriority")=>{let r=Tl(o,t,e,i),s=Wo(r,t,e,i,n);class a extends s{constructor(){super(...arguments),this.minAssociations=1,this._maxAssociations=0,this._maxAssociationsDefaultApplied=!1,this._response=[],this._dragDrop={dragsByTarget:{},countByTarget:{},nodesByTarget:{}},this.#t=new WeakMap,this._dropBlockedDueToMax=!1,this.flipAnimationConfig={duration:200,easing:"ease"},this._enableFlipAnimations=!0,this._pendingResponse=void 0}get maxAssociations(){if(!this._maxAssociationsDefaultApplied){this._maxAssociationsDefaultApplied=!0;let c=this.tagName?.toLowerCase()||"";(c==="qti-graphic-gap-match-interaction"||c==="qti-gap-match-interaction")&&!this.hasAttribute("max-associations")&&this._maxAssociations===0&&(this._maxAssociations=1)}return this._maxAssociations}set maxAssociations(c){let d=this._maxAssociations;this._maxAssociations=c,this.requestUpdate("maxAssociations",d)}#t;isSwapTarget(c){let d=this.dragState.sourceDroppable,h=parseInt(c.getAttribute("match-max")||"1",10);return(Number.isNaN(h)?1:h)===1&&this.isDeclarativeTarget(c)&&!!d&&d!==c&&this.trackedDroppables.includes(d)}isDeclarativeTarget(c){return c?c.acceptsDeclarativeDrops===!0?!0:c.hasAttribute("data-declarative-drops"):!1}chipsIn(c){return this.isDeclarativeTarget(c)?[...this.#t.get(c)??[]]:Array.from(c.querySelectorAll(t))}droppableHolding(c){return this.trackedDroppables.find(d=>this.chipsIn(d).includes(c)||d.contains(c)||!!d.shadowRoot?.contains(c))??null}placeChip(c,d){this.#t.set(c,[...this.#t.get(c)??[],d])}removeChipFromDroppable(c,d){let h=c??this.droppableHolding(d);if(h&&this.isDeclarativeTarget(h)){let f=(this.#t.get(h)??[]).filter(m=>m!==d);this.#t.set(h,f),f.length===0&&Ki(h,!1),this.syncDragDropState();return}d.remove()}clearChips(c){this.isDeclarativeTarget(c)?(this.#t.set(c,[]),this.syncDragDropState()):this.chipsIn(c).forEach(d=>d.remove()),Ki(c,!1)}syncDragDropState(){let c={},d={},h={};for(let f of this.trackedDroppables){let m=f.getAttribute("identifier");if(!m)continue;let v=this.chipsIn(f),x=this.isDeclarativeTarget(f)?v:Array.from(f.querySelectorAll('[qti-draggable="true"]'));c[m]=v.map(u=>u.getAttribute("identifier")).filter(u=>!!u),d[m]=Math.max(v.length,x.length),h[m]=v}this._dragDrop={dragsByTarget:c,countByTarget:d,nodesByTarget:h},this.requestUpdate()}responseFromState(){this.syncDragDropState();let{dragsByTarget:c}=this._dragDrop;return this.trackedDroppables.flatMap(d=>{let h=d.getAttribute("identifier");return h?(c[h]??[]).map(f=>`${f} ${h}`):[]})}totalAssociationsFromState(){return this.syncDragDropState(),Object.values(this._dragDrop.countByTarget).reduce((c,d)=>c+d,0)}droppableAtCapacityFromState(c){let d=parseInt(c.getAttribute("match-max")||"1",10),h=Number.isNaN(d)?1:d;if(h===0)return!1;let f=c.getAttribute("identifier");return(f?this._dragDrop.countByTarget[f]??0:0)>=h}set disableAnimations(c){this._enableFlipAnimations=!c}get disableAnimations(){return!this._enableFlipAnimations}get enableFlipAnimations(){return this._enableFlipAnimations&&Vl(this)}collectAutoSizeTargets(){return{draggables:this.trackedDraggables,droppables:this.trackedDroppables,dragContainers:this.trackedDragContainers}}get response(){let c=this.getResponse,d=typeof c=="function"?c.call(this):void 0;return(Array.isArray(d)?d:(this.cacheInteractiveElements(),this.responseFromState())).join(",")}set response(c){if(Array.isArray(c)){if(!this.trackedDroppables||this.trackedDroppables.length===0){this._pendingResponse=c,this._internals.setFormValue(JSON.stringify(c));return}let d=this.getValue,h=typeof d=="function"?d.call(this,c):c,f=Array.isArray(h)?h:typeof h=="string"&&h.length>0?[h]:[];this.reset(!1),f.forEach(x=>this.placeResponse(x));let m=this.getResponse,v=typeof m=="function"?m.call(this):void 0;this._response=Array.isArray(v)?v:(this.cacheInteractiveElements(),this.responseFromState())}else this._response=typeof c=="string"&&c.length>0?[c]:[];this._internals.setFormValue(JSON.stringify(this._response))}afterCache(){if(this.updateMinDimensionsForDropZones(),this.applyConfiguredChoicesContainerWidth(),this._pendingResponse!==void 0){let c=this._pendingResponse;this._pendingResponse=void 0,this.response=c}}get autoSizeDropzoneWidth(){return!this.dataset.choicesContainerWidth}applyConfiguredChoicesContainerWidth(){let c=this.dataset.choicesContainerWidth;c&&this.trackedDroppables.forEach(d=>{d.style.width=`${c}px`,d.style.boxSizing="border-box"})}shouldTreatBlockedMaxAsInvalid(){return!0}shouldReturnToInventoryOnInventoryDrop(){return!1}getFirstMessageAttribute(c){for(let h of c){let f=this.getAttribute(h);if(f&&f.trim().length>0)return f}let d=c.map(h=>h.toLowerCase());for(let h of Array.from(this.attributes))if(d.includes(h.name.toLowerCase())&&h.value.trim().length>0)return h.value;return null}allowDrop(c,d){if(this.trackedDragContainers.includes(d))return!0;let h=this.trackedDroppables.includes(d),f=d.hasAttribute("disabled"),m=d.hasAttribute("data-drag-source");return f&&this.isSwapTarget(d)?!0:h&&(!f||m)}handleDrop(c,d){let h=this.dragState.dragClone?.getBoundingClientRect();this.dropDraggableInDroppable(c,d,h);let f=c.getAttribute("identifier");f&&this.updateInventoryBasedOnMatchMax(f),this.validate(),this.reportValidity()}handleInvalidDrop(c){let d=this.dragState.sourceDroppable,h=this.dragState.currentTarget,f=!h,m=this.trackedDragContainers[0]||null;if(!c)return;if(d&&f&&m)this.dropDraggableInDroppable(c,m);else if(d&&this.trackedDroppables.includes(d))this.dropDraggableInDroppable(c,d,this.dragState.dragClone?.getBoundingClientRect());else if(Uo(c,"dragging")){this.restoreInventoryItem(c,this.dragState.dragClone?.getBoundingClientRect());let g=c.getAttribute("identifier");g&&this.updateInventoryBasedOnMatchMax(g),this.cacheInteractiveElements(),this.checkAllMaxAssociations()}let v=this.totalAssociationsFromState(),x=this.maxAssociations>0&&v>=this.maxAssociations,u=!!h&&h.hasAttribute("disabled")&&!h.hasAttribute("data-drag-source");this._dropBlockedDueToMax=u&&x,this.validate(),this.reportValidity()}animateReturn(c,d){!c||!d||!this.enableFlipAnimations||requestAnimationFrame(()=>{Xo(c,tp(d),this.flipAnimationConfig)})}restoreInventoryItem(c,d){hn(c),c.style.display="",c.style.position="",this.animateReturn(c,d)}placeResponse(c){let[d,...h]=c.split(" ").reverse(),f=this.trackedDroppables.find(m=>m.getAttribute("identifier")===d);f&&h.forEach(m=>{if(!m)return;let x=Zi(this.trackedDragContainers,m).at(0)||this.trackedDraggables.find(u=>u.getAttribute("identifier")===m);x&&this.dropDraggableInDroppable(x,f)})}dropDraggableInDroppable(c,d,h){if(this.trackedDragContainers.includes(d)){if(!this.dragState.sourceDroppable){if(this.shouldReturnToInventoryOnInventoryDrop()){this.returnToInventory(c,h),this._dropBlockedDueToMax=!1,this.validate();return}this.restoreInventoryItem(c,h),this.cacheInteractiveElements(),this.checkAllMaxAssociations(),this._dropBlockedDueToMax=!1,this.validate();return}let I=c.getAttribute("identifier");this.removeChipFromDroppable(this.droppableHolding(c),c),I&&this.restoreOriginalInInventory(I,h),this.cacheInteractiveElements(),this.checkAllMaxAssociations(),this._dropBlockedDueToMax=!1,this.validate();return}let m=parseInt(d.getAttribute("match-max")||"1",10),v=Number.isNaN(m)?1:m,x=v===0||v>1,u=Array.from(d.querySelectorAll('[qti-draggable="true"]')),g=this.enableFlipAnimations&&u.length>0?ze(u):null;if(!x){let I=this.chipsIn(d)[0]??(this.isDeclarativeTarget(d)?null:d.querySelector('[qti-draggable="true"]'));if(I){let A=I.getAttribute("identifier"),S=I.getBoundingClientRect();this.removeChipFromDroppable(d,I);let k=this.dragState.sourceDroppable,R=this.isDeclarativeTarget(d)&&k&&k!==d&&this.isDeclarativeTarget(k)?k:null;R?(this.placeChip(R,I),Ki(R,!0),this.animateReturn(I,S)):A&&this.restoreOriginalInInventory(A,S)}}let y=c.cloneNode(!0);y.removeAttribute("style"),y.removeAttribute("data-keyboard-dragging"),y.setAttribute("qti-draggable","true"),y.setAttribute("tabindex","0"),this.isDeclarativeTarget(d)?(y.setAttribute("part","drag"),y.setAttribute("exportparts","control: drag-control, label: drag-label, correction, correction-correct, correction-incorrect"),this.placeChip(d,y)):d.tagName==="SLOT"?y.setAttribute("slot",d.getAttribute("name")||""):(d.tagName==="QTI-SIMPLE-ASSOCIABLE-CHOICE"&&y.setAttribute("slot","qti-simple-associable-choice"),d.appendChild(y)),Ki(d,!0),this.syncDragDropState(),g&&this.enableFlipAnimations&&je(g,this.flipAnimationConfig),h&&this.enableFlipAnimations&&requestAnimationFrame(()=>{let I=y.getBoundingClientRect(),A=h.left-I.left,S=h.top-I.top;(A!==0||S!==0)&&y.animate([{transform:`translate(${A}px, ${S}px)`,opacity:.8},{transform:"translate(0, 0)",opacity:1}],{duration:this.flipAnimationConfig.duration||200,easing:this.flipAnimationConfig.easing||"ease",fill:"both"})});let w=c.getAttribute("identifier");w&&this.updateInventoryBasedOnMatchMax(w),this.cacheInteractiveElements(),this.checkAllMaxAssociations()}returnToInventory(c,d){let h=c.getAttribute("identifier");h&&(this.trackedDroppables.forEach(f=>{let m=this.chipsIn(f).filter(v=>v.getAttribute("identifier")===h);m.forEach(v=>this.removeChipFromDroppable(f,v)),m.length>0&&this.chipsIn(f).length===0&&Ki(f,!1)}),this.restoreOriginalInInventory(h,d)),this.cacheInteractiveElements(),this.checkAllMaxAssociations()}restoreOriginalInInventory(c,d){let h=Zi(this.trackedDragContainers,c),f=new Set(h),m=[];this.trackedDragContainers.forEach(x=>{x.querySelectorAll('[qti-draggable="true"]').forEach(u=>!f.has(u)&&m.push(u))});let v=this.enableFlipAnimations&&m.length>0?ze(m):null;h.forEach(x=>{hn(x),x.style.display="",x.style.visibility="visible"}),v&&this.enableFlipAnimations&&je(v,this.flipAnimationConfig),h.forEach(x=>this.animateReturn(x,d))}updateInventoryBasedOnMatchMax(c){let d=Zi(this.trackedDragContainers,c),h=Gh(this.trackedDraggables,c),f=this.trackedDroppables.reduce((m,v)=>this.isDeclarativeTarget(v)?m+this.chipsIn(v).filter(x=>x.getAttribute("identifier")===c).length:m+v.querySelectorAll(`[identifier="${c}"]`).length,0);d.forEach(m=>{Vt(m,"placeholder",h!==0&&f>=h)})}checkAllMaxAssociations(){let c=this.totalAssociationsFromState(),d=this.resolveDisableAfterMaxReached({defaultWhenUnset:!0}),h=this.maxAssociations>0&&c>=this.maxAssociations;this.trackedDroppables.forEach(f=>{let m=f.hasAttribute("data-drag-source");(this.droppableAtCapacityFromState(f)||d&&h)&&!m?f.setAttribute("disabled",""):f.removeAttribute("disabled")})}saveResponse(c){let d=this.getResponse,h=c??(typeof d=="function"?d.call(this):void 0),f=Array.isArray(h)?h:typeof h=="string"?[h]:(this.cacheInteractiveElements(),this.responseFromState());this._response=f,this._internals.setFormValue(JSON.stringify(this._response)),this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,composed:!0,detail:{responseIdentifier:this.responseIdentifier,response:f}})),this.requestUpdate()}reset(c=!0){this.trackedDroppables.forEach(d=>{this.clearChips(d)}),this.trackedDraggables.forEach(d=>{let h=d.getAttribute("identifier");h&&this.restoreOriginalInInventory(h)}),this.resetDragState(),this.cacheInteractiveElements(),this._response=[],this._internals.setFormValue(JSON.stringify(this._response)),c&&this.saveResponse()}validate(){let c=this.totalAssociationsFromState(),d=this.maxAssociations>0&&c>=this.maxAssociations,h=this.maxAssociations>0&&c>this.maxAssociations,f=this.minAssociations>0&&c<this.minAssociations,m="",v=!0;h?(m=this.getFirstMessageAttribute(["data-max-associations-message","data-max-selections-message"])||this.dataset.maxAssociationsMessage||this.dataset.maxSelectionsMessage||`You've selected too many associations. Maximum allowed is ${this.maxAssociations}.`,v=!1):d&&this._dropBlockedDueToMax&&this.shouldTreatBlockedMaxAsInvalid()?(m=this.getFirstMessageAttribute(["data-max-associations-message","data-max-selections-message"])||this.dataset.maxAssociationsMessage||this.dataset.maxSelectionsMessage||`You've selected too many associations. Maximum allowed is ${this.maxAssociations}.`,v=!1):f?(m=this.getFirstMessageAttribute(["data-min-associations-message","data-min-selections-message"])||this.dataset.minAssociationsMessage||this.dataset.minSelectionsMessage||`Please select at least ${this.minAssociations} ${this.minAssociations===1?"association":"associations"}.`,v=!1,this._dropBlockedDueToMax=!1):this._dropBlockedDueToMax=!1;let x=this.trackedDroppables[0]??this.trackedDraggables[0]??this;return this.setInteractionValidity(v,m,x,{suppressInline:!0}),v}reportValidity(){return super.reportValidity()}}return pn([p({type:Number,reflect:!0,attribute:"min-associations"})],a.prototype,"minAssociations",void 0),pn([p({type:Number,reflect:!0,attribute:"max-associations"})],a.prototype,"maxAssociations",null),pn([U({context:Ne})],a.prototype,"_dragDrop",void 0),pn([p({type:Boolean,attribute:"disable-animations"})],a.prototype,"disableAnimations",null),pn([p({attribute:"response",reflect:!1,noAccessor:!0,converter:Xt({emptyAs:[]})})],a.prototype,"response",null),a};var Go=class{getInsertPosition(t,e,i,n,r){let s=t.indexOf(i);if(s===-1)return null;let a=i.getBoundingClientRect(),l=(r-a.top)/a.height,d=Math.min(1,Math.max(0,l))>.5;return{index:s,placeAfter:d}}};var ip=new Go;var Wm={borderStyle:"2px dashed",borderColor:"var(--qti-drop-highlight-border-color, #c1c1c1)",background:"transparent",transitionDuration:150};function un(){return{placeholder:null,lastHoverTarget:null,lastPlacement:null,sortContainer:null}}function Yo(o){o.placeholder?.remove(),o.placeholder=null,o.lastHoverTarget=null,o.lastPlacement=null,o.sortContainer=null}function Jo(o,t,e={}){let i={...Wm,...e},n=document.createElement("div");return n.setAttribute("data-drop-placeholder","true"),n.style.width=`${t.width}px`,n.style.height=`${t.height}px`,n.style.margin=window.getComputedStyle(o).margin,n.style.boxSizing="border-box",n.style.border=`${i.borderStyle} ${i.borderColor}`,n.style.borderRadius=getComputedStyle(o).borderRadius,n.style.background=i.background,n.style.transition=`transform ${i.transitionDuration*Qo(o)}ms ease`,n.style.pointerEvents="none",n}function zl(o,t){for(let e of t)if(e.contains(o)&&e!==o)return e;return null}var jt=(o,t='[qti-draggable="true"]')=>{class e extends o{constructor(){super(...arguments),this.#t=null,this.#e=null,this.#i=un(),this.#r={hoveredSlot:null,originalPositions:new Map},this.#n=new Set,this.sortablePlaceholderConfig={},this.sortableAnimationConfig={duration:150,easing:"ease"}}#t;#e;#i;#r;#n;#o;set allowReorder(n){this.#o=n}get allowReorder(){return this.#o??this.resolveAllowReorder({defaultWhenUnset:!0})}get isDraggingFromSlot(){return this.#t!==null}findContainingDroppable(n){return zl(n,this.trackedDroppables)}#s(n){return n.querySelector(t)}#a(n){let r=this.#c(n);return r===0||r>1}#c(n){let r=parseInt(n.getAttribute("match-max")||"1",10);return Number.isNaN(r)?1:r}#p(n){return n.querySelectorAll(t).length}#l(n){let r=this.#c(n);return r===0?!1:this.#p(n)>=r}#m(){this.#r={hoveredSlot:null,originalPositions:new Map}}#d(n){if(!this.#t||n===this.#t){this.#u();return}if(this.#r.hoveredSlot===n)return;this.#u();let r=this.#s(n);if(!r){this.#i.placeholder&&n.appendChild(this.#i.placeholder),this.#r.hoveredSlot=n;return}if(this.#a(n)){if(this.#l(n)){this.#i.placeholder&&this.#t&&this.#t.appendChild(this.#i.placeholder),this.#r.hoveredSlot=null;return}this.#i.placeholder&&n.appendChild(this.#i.placeholder),this.#r.hoveredSlot=n;return}if(this.isDeclarativeTarget(n)){this.#i.placeholder?.parentElement&&this.#i.placeholder.remove(),this.#r.hoveredSlot=n;return}let a=ze([r]);this.#r.originalPositions.set(r,n),this.#i.placeholder&&this.#i.placeholder.parentElement&&this.#i.placeholder.remove(),this.#t.appendChild(r),this.#i.placeholder&&n.appendChild(this.#i.placeholder),this.#r.hoveredSlot=n,je(a,this.sortableAnimationConfig)}#u(){if(this.#r.originalPositions.size===0&&this.#r.hoveredSlot===null)return;let n=Array.from(this.#r.originalPositions.keys()),r=n.length>0?ze(n):null;for(let[s,a]of this.#r.originalPositions)a.appendChild(s);this.#i.placeholder&&this.#t&&this.#t.appendChild(this.#i.placeholder),r&&je(r,this.sortableAnimationConfig),this.#r.originalPositions.clear(),this.#r.hoveredSlot=null}initiateDrag(n,r,s,a,...l){this.#t=null,this.#i=un(),this.#m();let c=this.findContainingDroppable(n);if(this.#e=c,c&&this.allowReorder){this.#t=c,this.#i.sortContainer=c;let h=n.getBoundingClientRect();this.#i.placeholder=Jo(n,h,this.sortablePlaceholderConfig);let f=n.getAttribute("slot");f&&this.#i.placeholder.setAttribute("slot",f),this.#i.placeholder.style.visibility="hidden",c.appendChild(this.#i.placeholder),this.trackedDroppables.forEach(m=>{if(m!==c&&m.hasAttribute("disabled")){if(this.#a(m)&&this.#l(m))return;m.removeAttribute("disabled"),this.#n.add(m)}})}let[d]=l;super.initiateDrag(n,r,s,a,d)}cleanupSortableState(n=!0){if(n)for(let[r,s]of this.#r.originalPositions)s.appendChild(r);this.#i.placeholder&&this.#i.placeholder.remove(),Yo(this.#i),this.#n.clear(),this.#t=null,this.#m()}onSortableDragMove(n,r){if(!this.isDraggingFromSlot)return;let s=Ji(this.trackedDroppables,n,r,this.dragState.dragClone,this.collisionDetectionAlgorithm);s?this.#d(s):this.#u()}handleDragMove(n,r){Object.getPrototypeOf(e.prototype).handleDragMove?.call(this,n,r),this.onSortableDragMove(n,r)}allowDrop(n,r){return!this.allowReorder&&this.#e&&!this.trackedDragContainers.includes(this.#e)&&r!==this.#e&&this.trackedDroppables.includes(r)?!1:this.isDraggingFromSlot&&this.trackedDroppables.includes(r)?this.#a(r)?!this.#l(r):!0:this.isDraggingFromSlot&&this.trackedDragContainers.includes(r)?!0:super.allowDrop(n,r)}handleDrop(n,r){super.handleDrop(n,r),this.cleanupSortableState(!1)}handleInvalidDrop(n){this.cleanupSortableState(),super.handleInvalidDrop(n)}}return e};var rp=[P,W,Wt,q`
7053
+ <slot part="label"></slot>`}};Fo([p({type:String,attribute:"template-identifier"})],Lt.prototype,"templateIdentifier",void 0);Fo([p({type:String,attribute:"show-hide"})],Lt.prototype,"showHide",void 0);Fo([p({type:Boolean,converter:{fromAttribute:o=>o==="true",toAttribute:o=>String(o)}})],Lt.prototype,"fixed",void 0);Fo([p({type:String,attribute:!1})],Lt.prototype,"marker",void 0);var Vh=[{tag:"qti-simple-choice",ctor:Lt}];var zh=[...wh,...qh,...Sh,...Ah,..._h,...Rh,...Oh,...Dh,...$h,...Vh];var Dm=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r};function Nm(o,t,e,i,n={}){let r=n.publishWidth??!0,s=n.hostWindow??(typeof window<"u"?window:null);if(!t.length||!e.length||!s)return;let a=0,l=0,c=i.length?i:[o],d=c.map(h=>({el:h,reservation:h.style.getPropertyValue("--qti-drag-min-width"),hadStyleAttribute:h.hasAttribute("style")}));c.forEach(h=>h.style.setProperty("--qti-drag-min-width","0px")),t.forEach(h=>{let f=h.getBoundingClientRect();a=Math.max(a,f.height),l=Math.max(l,f.width)}),d.forEach(({el:h,reservation:f,hadStyleAttribute:m})=>{f?h.style.setProperty("--qti-drag-min-width",f):h.style.removeProperty("--qti-drag-min-width"),!m&&h.getAttribute("style")===""&&h.removeAttribute("style")}),n.hasChanged?.({height:a,width:l})!==!1&&(o.style.setProperty("--qti-dropzone-min-height",`${a}px`),r&&(o.style.setProperty("--qti-dropzone-min-width",`${l}px`),o.style.setProperty("--qti-drag-min-width",`${l}px`)),i.forEach(h=>{h.style.minHeight=`var(--qti-drag-container-min-height, ${a}px)`,h.style.setProperty("--qti-dropzone-min-height",`${a}px`),r&&(h.style.setProperty("--qti-dropzone-min-width",`${l}px`),h.style.setProperty("--qti-drag-min-width",`${l}px`))}))}var Tl=(o,t,e,i='slot[part="drags"]')=>{class n extends o{constructor(){super(...arguments),this.autoSizeDropzones=!0,this.#t=null,this.#e=new Set,this.#i=null,this.#r=0,this.#n=null}get autoSizeDropzoneWidth(){return!0}#t;#e;#i;#r;#n;collectAutoSizeTargets(){let s=(a,l)=>Array.from(l?.querySelectorAll(a)??[]);return{draggables:[...s(t,this),...s(t,this.shadowRoot)],droppables:[...s(e,this),...s(e,this.shadowRoot)],dragContainers:[...s(i,this),...s(i,this.shadowRoot)]}}dropzonePropertyTarget(){return this}updateMinDimensionsForDropZones(){if(!this.autoSizeDropzones)return;let{draggables:s,droppables:a,dragContainers:l}=this.collectAutoSizeTargets();s.length!==0&&(Nm(this.dropzonePropertyTarget(),s,a,l,{publishWidth:this.autoSizeDropzoneWidth,hasChanged:c=>{let d=this.#n;return d&&d.height===c.height&&d.width===c.width?!1:(this.#n=c,!0)}}),this.#a(s),this.#o())}#o(){typeof MutationObserver>"u"||this.#i||(this.#i=new MutationObserver(()=>this.#s()),this.#i.observe(this,{childList:!0,subtree:!0,characterData:!0}))}#s(){this.#r||(this.#r=requestAnimationFrame(()=>{this.#r=0,this.updateMinDimensionsForDropZones()}))}#a(s){if(typeof ResizeObserver>"u")return;this.#t??=new ResizeObserver(()=>this.#s());let a=new Set(s);for(let l of this.#e)a.has(l)||this.#t.unobserve(l);for(let l of a)this.#e.has(l)||this.#t.observe(l);this.#e=a}disconnectedCallback(){this.#t?.disconnect(),this.#t=null,this.#e.clear(),this.#i?.disconnect(),this.#i=null,this.#r&&cancelAnimationFrame(this.#r),this.#r=0,super.disconnectedCallback()}}return Dm([p({type:Boolean,attribute:"auto-size-dropzones"})],n.prototype,"autoSizeDropzones",void 0),n};var{AbortController:Jt,AbortSignal:Rl,WeakMap:$m,WeakRef:Lm,Window:jh,reportError:Bo=console.log}=globalThis,Le=o=>o&&o.defaultView!==null&&o.defaultView.document===o&&(o.defaultView.top===o.defaultView||Le(o.defaultView.parent.document)),yi=()=>!!jh&&globalThis instanceof jh,Pl=Symbol("unset"),[Fh,Vm]=(()=>{function o(x,u,g=!0){Object.defineProperty(x,u,{...Object.getOwnPropertyDescriptor(x,u),enumerable:g})}let t="try"in Promise?Promise.try.bind(Promise):(x,...u)=>new Promise(g=>g(x(...u))),e="withResolvers"in Promise?Promise.withResolvers.bind(Promise):()=>{let x,u;return{promise:new Promise((y,w)=>(x=y,u=w)),resolve:x,reject:u}};function i(x,u){let g=u.call(x);if(g===null||typeof g!="object")throw new TypeError("Iterator is not an object");return g}let n=new $m,r={next(...x){let u=this,g=n.get(u);if(!g?.syncIteratorRecord)throw new TypeError("AsyncFromSyncIteratorPrototype.next called on invalid object");let{syncIteratorRecord:y}=g;return t(()=>y.next(...x))},return(...x){let u=this,g=n.get(u);if(!g?.syncIteratorRecord)throw new TypeError("AsyncFromSyncIteratorPrototype.return called on invalid object");let{syncIteratorRecord:y}=g;return t(()=>y.return?y.return(...x):{value:void 0,done:!0})},throw(...x){let u=this,g=n.get(u);if(!g?.syncIteratorRecord)throw new TypeError("AsyncFromSyncIteratorPrototype.throw called on invalid object");let{syncIteratorRecord:y}=g;return t(()=>{if(!y.throw)throw y.return(),new TypeError("no throw method");return y.throw(...x)})}};function s(x){let u=Object.create(r);return n.set(u,{syncIteratorRecord:x}),u}function a(x,u){let g;if(u){if(g=x[Symbol.asyncIterator],g==null){if(g=x[Symbol.iterator],g==null)throw new TypeError("Object is not async iterable");let y=i(x,g);return s(y)}}else g=x[Symbol.iterator];if(g==null)throw new TypeError("Object is not iterable");return i(x,g)}let l="any"in Rl?Rl.any.bind(Rl):x=>{let u=new Jt;for(let g of x)if(g.aborted)return u.abort(g.reason),u.signal;for(let g of x)g.addEventListener("abort",()=>{u.abort(g.reason)},{signal:u.signal});return u.signal},c=x=>l(x.filter(Boolean));class d{constructor({next:u,error:g,complete:y}={}){n.set(this,{next:u,error:g,complete:y})}next(u){let{next:g}=n.get(this)||{};g&&g(u)}error(u){let{error:g}=n.get(this)||{};g?g(u):Bo(u)}complete(){let{complete:u}=n.get(this)||{};u&&u()}}function h(x,u){let g=n.get(x);if(g?.active){g.active=!1,g.subscriptionController.abort(u);for(let y of g.teardowns.reverse()){if(yi()&&!Le(document))return;try{y()}catch(w){Bo(w)}}}}function f(x,u,g={}){if(yi()&&!Le(document))return;let y;typeof u=="function"?y=new d({next:u}):u&&!(u instanceof d)?y=new d(u):y=u||new d;let w=n.get(x),I=w.weakSubscriber?.deref();if(I?.active){let k=I,S=n.get(k);S.observers.add(y),g.signal&&(g.signal.aborted?S.observers.delete(y):g.signal.addEventListener("abort",()=>{let R=n.get(k);R?.active&&(R.observers.delete(y),R.observers.size==0&&h(k,g.signal.reason))}));return}let A=new m(y);if(w.weakSubscriber=new Lm(A),"signal"in g&&(g.signal.aborted?h(A,g.signal.reason):g.signal.addEventListener("abort",()=>{let k=n.get(A);k?.active&&(k.observers.delete(y),k.observers.size==0&&h(A,g.signal.reason))})),w.subscribeCallback)try{w.subscribeCallback(A)}catch(k){A.error(k)}}class m{get[Symbol.toStringTag](){return"Subscriber"}constructor(u=null){if(!(u instanceof d))throw new TypeError("Illegal constructor");n.set(this,{active:!0,observers:new Set([u]),teardowns:[],subscriptionController:new Jt})}next(u){if(!(this instanceof m))throw new TypeError("illegal invocation");if(!arguments.length)throw new TypeError("too few arguments");let g=n.get(this);if(!g?.active||yi()&&!Le(document))return;let y=new Set(g.observers);for(let w of y)w.next(u)}error(u){if(!(this instanceof m))throw new TypeError("illegal invocation");if(!arguments.length)throw new TypeError("too few arguments");let g=n.get(this);if(!g?.active){Bo(u);return}if(yi()&&!Le(document))return;h(this,u);let y=new Set(g.observers);for(let w of y)w.error(u)}complete(){if(!(this instanceof m))throw new TypeError("illegal invocation");let u=n.get(this);if(!u?.active||yi()&&!Le(document))return;h(this);let g=new Set(u.observers);for(let y of g)y.complete()}addTeardown(u){if(!(this instanceof m))throw new TypeError("illegal invocation");if(typeof u!="function")throw new TypeError("Parameter 1 is not of type 'Function'");if(yi()&&!Le(document))return;let g=n.get(this);g?.active?g.teardowns.push(u):u()}get active(){if(!(this instanceof m))throw new TypeError("illegal invocation");return!!n.get(this)?.active}get signal(){if(!(this instanceof m))throw new TypeError("illegal invocation");if(!n.has(this)){let u=new Jt;return u.abort(),u.signal}return n.get(this).subscriptionController.signal}}o(m.prototype,"next"),o(m.prototype,"error"),o(m.prototype,"complete"),o(m.prototype,"addTeardown"),o(m.prototype,"active"),o(m.prototype,"signal");class v{get[Symbol.toStringTag](){return"Observable"}constructor(u){if(!u)throw new TypeError("1 argument required but 0 present");n.set(this,{weakSubscriber:null,subscribeCallback:u})}static from(u){if(u===null||typeof u!="object")throw new TypeError("Observable.from only accepts objects");if(u instanceof v)return u;if(typeof(Symbol.asyncIterator in u&&u[Symbol.asyncIterator])=="function"){let I=function(A,k){if(A.signal.aborted)return;let S;try{let R=k.next();S=Promise.resolve(R)}catch(R){S=Promise.reject(R)}S.then(R=>{if(R===null||typeof R!="object"){A.error(new TypeError("Not an IteratorResult."));return}try{({done:w}=R)}catch(z){A.error(z);return}if(w){A.complete();return}let N;try{N=R.value}catch(z){A.error(z);return}A.next(N),I(A,k)},R=>{A.error(R)})},w=!1;return new v(A=>{if(A.signal.aborted)return;let k;try{k=a(u,!0)}catch(R){A.error(R);return}let S=k;A.signal.aborted||(A.signal.addEventListener("abort",()=>{if(typeof S.return!="function"||w)return;t(()=>S.return(A.signal.reason)).then(N=>{if(N===null||typeof N!="object")throw new TypeError("Iterator .return() must return an Object")})}),I(A,S))})}if(typeof(Symbol.iterator in u&&u[Symbol.iterator])=="function")return new v(w=>{if(w.signal.aborted)return;let I;try{I=a(u,!1)}catch(S){w.error(S);return}let A=!1,k=I;if(!w.signal.aborted)for(w.signal.addEventListener("abort",()=>{if(typeof k.return!="function"||A)return;let S=k.return();if(S===null||typeof S!="object")throw new TypeError("Iterator .return() must return an Object")});;)try{let S=k.next();if({done:A}=S,A){w.complete();return}if(w.next(S.value),w.signal.aborted)break}catch(S){w.error(S);break}});if(u instanceof Promise||typeof u.then=="function")return new v(w=>{u.then(I=>{w.next(I),w.complete()},I=>{w.error(I)})});throw new TypeError("Could not convert value to Observable")}subscribe(u=null,g={}){if(!(this instanceof v))throw new TypeError("illegal invocation");f(this,u,g)}takeUntil(u){if(!(this instanceof v))throw new TypeError("illegal invocation");let g=this,y=v.from(u);return new v(w=>{let I=new d({next(){w.complete()},error(){w.complete()}}),A={signal:w.signal};if(f(y,I,A),!w.active)return;let k=new d({next(S){w.next(S)},error(S){w.error(S)},complete(){w.complete()}});f(g,k,A)})}map(u){if(!(this instanceof v))throw new TypeError("illegal invocation");if(typeof u!="function")throw new TypeError("Parameter 1 is not of type 'Function'");let g=this;return new v(y=>{let w=0,I=new d({next(k){let S;try{S=u(k,w)}catch(R){y.error(R);return}w+=1,y.next(S)},error(k){y.error(k)},complete(){y.complete()}}),A={signal:y.signal};f(g,I,A)})}inspect(u={}){let g=null,y=null,w=null,I=null,A=null;typeof u=="function"?y=u:u&&typeof u=="object"&&("subscribe"in u&&(g=u.subscribe),"next"in u&&(y=u.next),"error"in u&&(w=u.error),"complete"in u&&(I=u.complete),"abort"in u&&(A=u.abort));let k=this;return new v(S=>{if(g!==null)try{g()}catch($){S.error($);return}let R=()=>{try{A!==null&&A(S.signal.reason)}catch($){Bo($)}};S.signal.addEventListener("abort",R,{once:!0});let N=new d({next($){if(y!==null)try{y($)}catch(ut){S.signal.removeEventListener("abort",R),S.error(ut);return}S.next($)},error($){if(S.signal.removeEventListener("abort",R),w!==null)try{w($)}catch(ut){S.error(ut);return}S.error($)},complete(){if(S.signal.removeEventListener("abort",R),I!==null)try{I()}catch($){S.error($);return}S.complete()}}),z={signal:S.signal};f(k,N,z)})}filter(u){if(!(this instanceof v))throw new TypeError("illegal invocation");if(typeof u!="function")throw new TypeError("Parameter 1 is not of type 'Function'");let g=this;return new v(y=>{let w=0,I=new d({next(k){let S=!1;try{S=u(k,w)}catch(R){y.error(R);return}w+=1,S&&y.next(k)},error(k){y.error(k)},complete(){y.complete()}}),A={signal:y.signal};f(g,I,A)})}take(u){if(!(this instanceof v))throw new TypeError("illegal invocation");let g=this;return new v(y=>{let w=u;if(w==0)return y.complete();let I=new d({next(k){y.next(k),w-=1,w==0&&y.complete()},error(k){y.error(k)},complete(){y.complete()}}),A={signal:y.signal};f(g,I,A)})}drop(u){if(!(this instanceof v))throw new TypeError("illegal invocation");let g=this;return new v(y=>{let w=u,I=new d({next(k){if(w>0)return w-=1;w==0&&y.next(k)},error(k){y.error(k)},complete(){y.complete()}}),A={signal:y.signal};f(g,I,A)})}flatMap(u){if(!(this instanceof v))throw new TypeError("illegal invocation");if(typeof u!="function")throw new TypeError("Parameter 1 is not of type 'Function'");let g=this;return new v(y=>{let w=0,I=!1,A=[];function k(z){let $;try{$=u(z,w)}catch(te){return y.error(te)}w+=1;let ut;try{ut=v.from($)}catch(te){return y.error(te)}let ka=new d({next(te){y.next(te)},error(te){y.error(te)},complete(){if(A.length){let te=A.shift();k(te)}else S=!1,I&&y.complete()}}),Bt={signal:y.signal};f(ut,ka,Bt)}let S=!1,R=new d({next(z){S?A.push(z):(S=!0,k(z))},error(z){y.error(z)},complete(){I=!0,!S&&!A.length&&y.complete()}}),N={signal:y.signal};f(g,R,N)})}switchMap(u){if(!(this instanceof v))throw new TypeError("illegal invocation");if(typeof u!="function")throw new TypeError("Parameter 1 is not of type 'Function'");let g=this;return new v(y=>{let w=0,I=!1,A=null;function k(N){let z;try{z=u(N,w)}catch(Bt){return y.error(Bt)}w+=1;let $;try{$=v.from(z)}catch(Bt){return y.error(Bt)}let ut=new d({next(Bt){y.next(Bt)},error(Bt){y.error(Bt)},complete(Bt){I?y.complete():A=null}}),ka={signal:c([A.signal,y.signal])};f($,ut,ka)}let S=new d({next(N){A&&A.abort(),A=new Jt,k(N)},error(N){y.error(N)},complete(){I=!0,A||y.complete()}}),R={signal:y.signal};f(g,S,R)})}catch(u){if(!(this instanceof v))throw new TypeError("illegal invocation");if(typeof u!="function")throw new TypeError("Parameter 1 is not of type 'Function'");let g=this;return new v(w=>{let I=new d({next(k){w.next(k)},error(k){let S;try{S=u(k)}catch($){w.error($);return}let R;try{R=v.from(S)}catch($){w.error($);return}let N=new d({next($){w.next($)},error($){w.error($)},complete(){w.complete()}}),z={signal:w.signal};f(R,N,z)},complete(){w.complete()}}),A={signal:w.signal};f(g,I,A)})}finally(u){if(!(this instanceof v))throw new TypeError("illegal invocation");if(typeof u!="function")throw new TypeError("Parameter 1 is not of type 'Function'");let g=this;return new v(y=>{y.addTeardown(u);let w=new d({next(A){y.next(A)},error(A){y.error(A)},complete(){y.complete()}}),I={signal:y.signal};f(g,w,I)})}toArray(u={}){if(!(this instanceof v))throw new TypeError("illegal invocation");let{promise:g,resolve:y,reject:w}=e();if(u.signal){if(u.signal.aborted)return Promise.reject(u.signal.reason);u.signal.addEventListener("abort",()=>{w(u.signal.reason)})}let I=[],A=new d({next(k){I.push(k)},error(k){w(k)},complete(){y(I)}});return f(this,A,u),g}forEach(u,g={}){if(!(this instanceof v))throw new TypeError("illegal invocation");if(typeof u!="function")throw new TypeError("Parameter 1 is not of type 'Function'");let{promise:y,resolve:w,reject:I}=e(),A=new Jt,k={signal:c([A.signal,g.signal])};if(k.signal.aborted)return I(k.signal.reason),y;k.signal.addEventListener("abort",()=>{I(k.signal.reason)});let S=0,R=new d({next(N){try{u(N,S)}catch(z){I(z),A.abort(z)}S+=1},error(N){I(N)},complete(){w()}});return f(this,R,k),y}every(u,g={}){if(!(this instanceof v))throw new TypeError("illegal invocation");if(typeof u!="function")throw new TypeError("Parameter 1 is not of type 'Function'");let{promise:y,resolve:w,reject:I}=e(),A=new Jt,k={signal:c([A.signal,g.signal])};if(k.signal.aborted)return I(k.signal.reason),y;k.signal.addEventListener("abort",()=>{I(k.signal.reason)});let S=0,R=new d({next(N){let z=!1;try{z=u(N,S)}catch($){I($),A.abort($)}S+=1,z||(w(!1),A.abort())},error(N){I(N)},complete(){w(!0)}});return f(this,R,k),y}first(u={}){if(!(this instanceof v))throw new TypeError("illegal invocation");let{promise:g,resolve:y,reject:w}=e(),I=new Jt,A={signal:c([I.signal,u.signal])};if(A.signal.aborted)return w(A.signal.reason),g;A.signal.addEventListener("abort",()=>{w(A.signal.reason)});let k=new d({next(S){y(S),I.abort()},error(S){w(S)},complete(){w(new RangeError("No values in Observable"))}});return f(this,k,A),g}last(u={}){if(!(this instanceof v))throw new TypeError("illegal invocation");let{promise:g,resolve:y,reject:w}=e();if(u.signal){if(u.signal.aborted)return w(u.signal.reason),g;u.signal.addEventListener("abort",()=>{w(u.signal.reason)})}let I=null,A=!1,k=new d({next(S){A=!0,I=S},error(S){w(S)},complete(){A?y(I):w(new RangeError("No values in Observable"))}});return f(this,k,u),g}find(u,g={}){if(!(this instanceof v))throw new TypeError("illegal invocation");if(typeof u!="function")throw new TypeError("Parameter 1 is not of type 'Function'");let{promise:y,resolve:w,reject:I}=e(),A=new Jt,k={signal:c([A.signal,g.signal])};if(k.signal.aborted)return I(k.signal.reason),y;k.signal.addEventListener("abort",()=>{I(k.signal.reason)});let S=0,R=new d({next(N){let z=!1;try{z=u(N,S)}catch($){I($),A.abort($)}S+=1,z&&(w(N),A.abort())},error(N){I(N)},complete(){w()}});return f(this,R,k),y}some(u,g={}){if(!(this instanceof v))throw new TypeError("illegal invocation");if(typeof u!="function")throw new TypeError("Parameter 1 is not of type 'Function'");let{promise:y,resolve:w,reject:I}=e(),A=new Jt,k={signal:c([A.signal,g.signal])};if(k.signal.aborted)return I(k.signal.reason),y;k.signal.addEventListener("abort",()=>{I(k.signal.reason)});let S=0,R=new d({next(N){let z=!1;try{z=u(N,S)}catch($){I($),A.abort($)}S+=1,z&&(w(!0),A.abort())},error(N){I(N)},complete(){w(!1)}});return f(this,R,k),y}reduce(u,g,y={}){if(!(this instanceof v))throw new TypeError("illegal invocation");if(typeof u!="function")throw new TypeError("Parameter 1 is not of type 'Function'");let{promise:w,resolve:I,reject:A}=e(),k=new Jt,S={signal:c([k.signal,y.signal])};if(S.signal.aborted)return A(S.signal.reason),w;S.signal.addEventListener("abort",()=>{A(S.signal.reason)},{once:!0});let R=0,N=arguments.length>1?g:Pl,z=new d({next($){if(N===Pl){N=$,R++;return}try{let ut=u(N,$,R);R++,N=ut}catch(ut){A(ut),k.abort(ut);return}},error($){A($)},complete(){N!==Pl?I(N):A(new TypeError("no initial value provided and no values emitted"))}});return f(this,z,S),w}}return o(v.prototype,"subscribe"),[v,m]})();function Bh(){return typeof globalThis.Observable=="function"}function Uh(){Object.defineProperties(globalThis,{Observable:{value:Fh,configurable:!0,writable:!0},Subscriber:{value:Vm,configurable:!0,writable:!0}}),EventTarget.prototype.when=function(o,t={}){if(yi()&&!Le(document))return;let e=this;return new Fh(i=>{if(!e||i.signal.aborted)return;let n=r=>{i.next(r)};e.addEventListener(o,n,{capture:t.capture||!1,passive:t.passive,once:!1,signal:i.signal})})}}function Ol(o,t,e){let i=o.filter(n=>!n.hasAttribute("disabled"));for(let n of i){let r=n.getBoundingClientRect();if(t>=r.left&&t<=r.right&&e>=r.top&&e<=r.bottom)return n}return null}function Hh(o,t,e,i){if(!i)return null;let n=o.filter(s=>!s.hasAttribute("disabled")),r=i.getBoundingClientRect();for(let s of n){let a=s.getBoundingClientRect();if(!(r.right<a.left||r.left>a.right||r.bottom<a.top||r.top>a.bottom))return s}return null}function Wh(o,t,e,i){let n=o.filter(c=>!c.hasAttribute("disabled"));if(n.length===0)return null;let r,s;if(i){let c=i.getBoundingClientRect();r=c.left+c.width/2,s=c.top+c.height/2}else r=t,s=e;let a=null,l=1/0;for(let c of n){let d=c.getBoundingClientRect(),h=d.left+d.width/2,f=d.top+d.height/2,m=Math.sqrt(Math.pow(r-h,2)+Math.pow(s-f,2));m<l&&(l=m,a=c)}return a}function Qh(o,t,e,i){let n=o.filter(l=>!l.hasAttribute("disabled"));if(n.length===0)return null;let r;if(i){let l=i.getBoundingClientRect();r=[{x:l.left,y:l.top},{x:l.right,y:l.top},{x:l.left,y:l.bottom},{x:l.right,y:l.bottom}]}else r=[{x:t,y:e},{x:t,y:e},{x:t,y:e},{x:t,y:e}];let s=null,a=1/0;for(let l of n){let c=l.getBoundingClientRect(),d=[{x:c.left,y:c.top},{x:c.right,y:c.top},{x:c.left,y:c.bottom},{x:c.right,y:c.bottom}],h=0,f=0;for(let v of r)for(let x of d){let u=Math.sqrt(Math.pow(v.x-x.x,2)+Math.pow(v.y-x.y,2));h+=u,f++}let m=h/f;m<a&&(a=m,s=l)}return s}function zm(o,t,e){let i=o.getBoundingClientRect();return t>=i.left&&t<=i.right&&e>=i.top&&e<=i.bottom}function jm(o,t,e,i,n){let r=n&&n.length>0?o.filter(g=>n.includes(g)):o.filter(g=>g.tagName==="SLOT"&&g.hasAttribute("part")&&g.getAttribute("part")?.includes("drags")),a=o.filter(g=>!r.includes(g));if(r.length===0&&a.length===0)return null;let l;if(i){let g=i.getBoundingClientRect();l=[{x:g.left,y:g.top},{x:g.right,y:g.top},{x:g.left,y:g.bottom},{x:g.right,y:g.bottom}]}else l=[{x:t,y:e},{x:t,y:e},{x:t,y:e},{x:t,y:e}];let c=g=>{let y=g.getBoundingClientRect(),w=[{x:y.left,y:y.top},{x:y.right,y:y.top},{x:y.left,y:y.bottom},{x:y.right,y:y.bottom}],I=0,A=0;for(let k of l)for(let S of w){let R=Math.sqrt(Math.pow(k.x-S.x,2)+Math.pow(k.y-S.y,2));I+=R,A++}return I/A},d=null,h=1/0;for(let g of r){let y=c(g);y<h&&(h=y,d=g)}let f=null,m=1/0;for(let g of a){let y=c(g);y<m&&(m=y,f=g)}if(d&&i){let g=i.getBoundingClientRect(),y=d.getBoundingClientRect(),w=g.left+g.width/2,I=g.top+g.height/2;if(w>=y.left&&w<=y.right&&I>=y.top&&I<=y.bottom)return d}if(f&&zm(f,t,e))return f;let x=i?.getAttribute("data-drag-origin")==="droppable"?.85:1.5;return d&&f?h<=m*x?d:f:d||f}function Gh(o){switch(o){case"pointerWithin":return Ol;case"rectangleIntersection":return Hh;case"closestCenter":return Wh;case"closestCorners":return Qh;case"closestCornersWithInventoryPriority":return jm;default:return Ol}}function Ki(o,t,e,i,n="pointerWithin",r){return Gh(n)(o,t,e,i,r)}function Ve(o,t){let e=o.composedPath?o.composedPath():[o.target];for(let i of e)if(i instanceof HTMLElement&&i.tagName!=="SLOT"){if(i.matches(t)||i.hasAttribute("qti-draggable"))return i;let n=i.closest(t)||i.closest('[qti-draggable="true"]');if(n)return n}return null}function dn(o){return o?o.hasAttribute("disabled")?!0:o.internals?.states?.has("disabled")??!1:!1}var Ml=o=>o?.internals;function Vt(o,t,e){let i=Ml(o)?.states;i&&(e?i.add(t):i.delete(t))}function Uo(o,t){return Ml(o)?.states?.has(t)??!1}function hn(o){Vt(o,"dragging",!1),Vt(o,"placeholder",!1),Vt(o,"return-anchor",!1)}function vi(o){return Uo(o,"dragging")||Uo(o,"placeholder")}function he(o,t,e){if(!o)return;e?o.setAttribute(t,""):o.removeAttribute(t);let i=Ml(o)?.states;if(i){e?i.add(t):i.delete(t);return}let n=new Set((o.getAttribute("part")??"").split(/\s+/).filter(Boolean));n.has("drop")&&(e?n.add(t):n.delete(t),o.setAttribute("part",[...n].join(" ")))}function Zi(o,t){he(o,"filled",t)}function tr(o,t){let e=[];return o.forEach(i=>{let n=[];i.tagName.toLowerCase()==="slot"?n=i.assignedElements({flatten:!0}).filter(a=>a.getAttribute("identifier")===t):n=Array.from(i.querySelectorAll(`[identifier="${t}"]`)),e.push(...n)}),e}function Xh(o,t){let e=o.find(n=>n.getAttribute("identifier")===t);if(!e)return 1;let i=e.getAttribute("match-max");return i?parseInt(i,10)||0:1}var Dl={origin:{x:0,y:0},scale:{x:1,y:1}},Ho=100,Fm=o=>{let t=o.fullscreenElement??o.webkitFullscreenElement??null;for(;t instanceof HTMLElement;){let e=t.shadowRoot?.fullscreenElement??null;if(!e||e===t)break;t=e}return t instanceof HTMLElement?t:null},Bm=o=>{let t=o.shadowRoot;return t?t.querySelector("slot:not([name])")?o:t:o},Um=(o,t)=>{let e=t;for(;e;){if(e===o)return!0;e=e.parentNode??e.host??null}return!1},Nl=(o,t)=>{let e=o.ownerDocument??document,i=t??e.body,n=Fm(e);return n&&!Um(n,i)?Bm(n):i},$l=(o,t=1)=>{let i=(o.ownerDocument??document).createElement("div");i.style.cssText=`position:fixed;left:0;top:0;width:${Ho}px;height:${Ho}px;margin:0;padding:0;border:0;visibility:hidden;pointer-events:none;`,o.appendChild(i);let n=i.getBoundingClientRect();return i.remove(),{origin:{x:n.left,y:n.top},scale:{x:(n.width/Ho||1)*t,y:(n.height/Ho||1)*t}}},Yh=(o,t,e)=>({x:(t-o.origin.x)/o.scale.x,y:(e-o.origin.y)/o.scale.y});Bh()||Uh();var Jh=new WeakSet;function Hm(o){!o||Jh.has(o)||(o.addEventListener("touchmove",()=>{},{capture:!1,passive:!1}),Jh.add(o))}var Kh=o=>!!o.internals?.states,Wo=(o,t,e,i='slot[part="drags"]',n="pointerWithin")=>{class r extends o{constructor(){super(...arguments),this.trackedDraggables=[],this.trackedDroppables=[],this.trackedDragContainers=[],this.allDropzones=[],this.collisionDetectionAlgorithm=n,this.dragState={dragging:!1,dragSource:null,dragClone:null,startOffset:{x:0,y:0},currentTarget:null,sourceDroppable:null,inputType:null,returnAnchorItems:[]},this.cloneFrame=Dl,this.cloneZoom=1,this.subscriptions=[],this.dragSubscriptions=[],this.lastPointerDownAt=0,this.lastTouchStartAt=0,this.#t=new Set,this.#e=new Set,this.#i=a=>{let l=a;if(l.context!==Ti)return;let c=l.contextTarget;c instanceof HTMLElement&&this.#e.add(c)}}#t;isDragDropEnabled(){return!0}publishDraggablesSelector(){let a=this.isDragDropEnabled()?t:null;this._interactionContext.draggablesSelector!==a&&(this._interactionContext={...this._interactionContext,draggablesSelector:a})}connectedCallback(){super.connectedCallback(),this.addEventListener("context-request",this.#i,{capture:!0}),Hm(this.ownerDocument?.defaultView),this.publishDraggablesSelector(),this.setupDragDrop()}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("context-request",this.#i,{capture:!0}),this.#e.clear(),this.cleanup()}async setupDragDrop(){await this.updateComplete,this.cacheInteractiveElements(),this.afterCache(),this.setupDragObservables()}afterCache(){}removeChipFromDroppable(a,l){l.remove()}#e;#i;registeredMatching(a){for(let l of this.#e)l.isConnected||this.#e.delete(l);return[...this.#e].filter(l=>l.matches(a))}cacheInteractiveElements(){let a=(S,R)=>Array.from(R?.querySelectorAll(S)??[]),l=a(t,this),c=a(t,this.shadowRoot),d=a('[qti-draggable="true"]:not([data-drag-clone])',this),h=a('[qti-draggable="true"]:not([data-drag-clone])',this.shadowRoot),f=this.registeredMatching(t);this.trackedDraggables=Array.from(new Set([...l,...c,...d,...h,...f]));let m=a(e,this),v=a(e,this.shadowRoot);this.trackedDroppables=Array.from(new Set([...m,...v]));let x=a(i,this),u=a(i,this.shadowRoot);this.trackedDragContainers=Array.from(new Set([...x,...u])),this.allDropzones=[...this.trackedDroppables,...this.trackedDragContainers];let g=this.isDragDropEnabled(),y=new Set(this.trackedDraggables),w=new Set(this.trackedDroppables),I=g?y:new Set,A=g?w:new Set,k=new Set([...y,...w].filter(Kh));for(let S of this.#t)k.has(S)||(S.internals.states.delete("drag"),S.internals.states.delete("droppable"));for(let S of k){let R=I.has(S),N=!R&&A.has(S);R?S.internals.states.add("drag"):S.internals.states.delete("drag"),N?S.internals.states.add("droppable"):S.internals.states.delete("droppable")}this.#t=k,this.trackedDraggables.forEach(S=>{let R=vi(S);g&&!R?(S.style.cursor="grab",S.style.userSelect="none",S.style.touchAction="none",S.style.webkitUserSelect="none",S.style.webkitTouchCallout="none",S.setAttribute("qti-draggable","true"),S.setAttribute("tabindex","0")):(S.style.cursor="",S.style.userSelect="",S.style.touchAction="",S.style.webkitUserSelect="",S.style.webkitTouchCallout="",S.removeAttribute("qti-draggable"),S.getAttribute("tabindex")==="0"&&S.removeAttribute("tabindex"))})}setupDragObservables(){let a=this.shadowRoot;if(!a){console.error("\u274C [Observable DnD] No shadow root found!");return}let l=a.when("pointerdown").filter(m=>{if(!m.isTrusted)return!1;let v=Ve(m,t),x=this.disabled||this.readonly,u=dn(v)||vi(v),g=Date.now()-this.lastTouchStartAt<50;return v&&m.isPrimary!==!1&&m.button===0&&!x&&!u&&!g}).subscribe(m=>{this.lastPointerDownAt=Date.now();let v=Ve(m,t);if(!v){console.warn("\u26A0\uFE0F [Observable DnD] No draggable target found");return}m.pointerType==="touch"&&(m.preventDefault(),m.stopPropagation());let x=m.isTrusted?m.pointerType==="touch"?100:10:0;if(this.dragState.activationTimeout&&clearTimeout(this.dragState.activationTimeout),x===0){this.dragState.dragging||this.initiateDrag(v,m.clientX,m.clientY,m.pointerType,"pointer",m.pointerId,m.isTrusted);return}let u=()=>{this.dragState.activationTimeout&&(clearTimeout(this.dragState.activationTimeout),this.dragState.activationTimeout=void 0),document.removeEventListener("pointerup",u,!0),document.removeEventListener("pointercancel",u,!0)};document.addEventListener("pointerup",u,{once:!0,capture:!0}),document.addEventListener("pointercancel",u,{once:!0,capture:!0}),this.dragState.activationTimeout=window.setTimeout(()=>{this.dragState.activationTimeout=void 0,document.removeEventListener("pointerup",u,!0),document.removeEventListener("pointercancel",u,!0),this.dragState.dragging||this.initiateDrag(v,m.clientX,m.clientY,m.pointerType,"pointer",m.pointerId,m.isTrusted)},x)}),c=a.when("mousedown").filter(m=>{let v=Ve(m,t),x=this.disabled||this.readonly,u=dn(v)||vi(v),g=m.button===0,y=Date.now()-this.lastPointerDownAt<50;return v&&g&&!x&&!u&&!y}).subscribe(m=>{let v=Ve(m,t);!v||this.dragState.dragging||(m.preventDefault(),this.initiateDrag(v,m.clientX,m.clientY,"mouse","mouse",void 0,m.isTrusted))}),d=a.when("touchstart").filter(m=>{let v=Ve(m,t),x=this.disabled||this.readonly,u=dn(v)||vi(v),g=!!(m.touches?.[0]||m.changedTouches?.[0]),y=Date.now()-this.lastPointerDownAt<50;return v&&g&&!x&&!u&&!y}).subscribe(m=>{let v=Ve(m,t),x=m.touches?.[0]||m.changedTouches?.[0];!v||!x||this.dragState.dragging||(this.lastTouchStartAt=Date.now(),m.preventDefault(),m.stopPropagation(),this.initiateDrag(v,x.clientX,x.clientY,"touch","touch",void 0,m.isTrusted))}),h={dragging:!1,dragElement:null,dragIndex:0,dropIndex:0,dropElement:null},f=a.when("keydown").subscribe(m=>{let v=this.trackedDraggables.filter(u=>!vi(u)),x=[...this.trackedDroppables,...this.trackedDragContainers];if(h.dragging)switch(m.code){case"ArrowRight":case"ArrowDown":{m.preventDefault();let u=(h.dropIndex+1)%x.length;h={...h,dropIndex:u,dropElement:x[u]};break}case"ArrowLeft":case"ArrowUp":{m.preventDefault();let u=(h.dropIndex-1+x.length)%x.length;h={...h,dropIndex:u,dropElement:x[u]};break}case"Space":case"Enter":case"Tab":{m.preventDefault(),h.dragElement&&h.dropElement&&(this.allowDrop(h.dragElement,h.dropElement)||this.trackedDragContainers.includes(h.dropElement)?this.handleDrop(h.dragElement,h.dropElement):this.handleInvalidDrop(h.dragElement)),this.trackedDraggables.forEach(u=>u.removeAttribute("data-keyboard-dragging")),this.saveResponse(),h={dragging:!1,dragElement:null,dragIndex:0,dropIndex:0,dropElement:null};break}case"Escape":{m.preventDefault(),this.trackedDraggables.forEach(u=>u.removeAttribute("data-keyboard-dragging")),h={dragging:!1,dragElement:null,dragIndex:0,dropIndex:0,dropElement:null};break}}else{let u=Ve(m,t),g=this.disabled||this.readonly,y=dn(u)||vi(u);u&&["Space","Enter"].includes(m.code)&&!g&&!y&&(m.preventDefault(),u.setAttribute("data-keyboard-dragging","true"),h={dragging:!0,dragElement:u,dragIndex:v.indexOf(u),dropIndex:0,dropElement:x[0]})}this.allDropzones.forEach(u=>u.removeAttribute("hover")),h.dragging&&h.dropElement&&(h.dropElement.setAttribute("hover",""),h.dropElement.hasAttribute("tabindex")&&h.dropElement.getAttribute("tabindex")!=="-1"&&h.dropElement.focus())});this.subscriptions.push(l,c,d,f)}initiateDrag(a,l,c,d,h="pointer",f,m){if(this.dragState.dragging){console.warn("\u26A0\uFE0F [Observable DnD] Already dragging, ignoring initiateDrag");return}if(a.hasAttribute("data-drag-clone")){console.warn("\u26A0\uFE0F [Observable DnD] Attempted to drag visual clone, ignoring");return}let v=y=>y.contains(a)||!!y.shadowRoot?.contains(a),x=this.trackedDroppables.some(v),u=this.trackedDroppables.find(v)||null;a.getAnimations().forEach(y=>y.cancel());let g=a.getBoundingClientRect();if(this.dragState={dragging:!0,dragSource:a,dragClone:this.createDragClone(a,g),startOffset:{x:l-g.left,y:c-g.top},currentTarget:null,sourceDroppable:u,inputType:d,pointerId:f,startedFromTrustedEvent:m,initialCoordinates:{x:l,y:c},returnAnchorItems:[]},x){this.dragState.dragClone?.setAttribute("data-drag-origin","droppable"),this.removeChipFromDroppable(u,a),this.cacheInteractiveElements(),u&&u.setAttribute("data-drag-source","true");let y=a.getAttribute("identifier");if(y){let w=tr(this.trackedDragContainers,y);w.forEach(I=>Vt(I,"return-anchor",!0)),this.dragState.returnAnchorItems=w}}else this.dragState.dragClone?.setAttribute("data-drag-origin","inventory"),Vt(a,"dragging",!0);this.updateClonePosition(l,c),this.activateAllDroppables(),this.watchDragCloneHost(),this.setupMoveObservables(d,h)}setupMoveObservables(a,l="pointer"){if(a==="touch"){if(l==="pointer")try{let w=this.dragState.dragSource,I=this.dragState.pointerId;w&&I!==void 0&&w.setPointerCapture&&w.setPointerCapture(I)}catch{}let g=w=>{w.cancelable&&(w.preventDefault(),l==="pointer"&&w.stopPropagation())};document.addEventListener("touchmove",g,{passive:!1,capture:!0}),document.addEventListener("touchstart",g,{passive:!1,capture:!0}),document.addEventListener("touchend",g,{passive:!1,capture:!0}),document.addEventListener("gesturestart",g,{passive:!1}),document.addEventListener("gesturechange",g,{passive:!1}),document.addEventListener("gestureend",g,{passive:!1});let y=()=>{if(document.removeEventListener("touchmove",g,{capture:!0}),document.removeEventListener("touchstart",g,{capture:!0}),document.removeEventListener("touchend",g,{capture:!0}),document.removeEventListener("gesturestart",g),document.removeEventListener("gesturechange",g),document.removeEventListener("gestureend",g),l==="pointer")try{let w=this.dragState.dragSource,I=this.dragState.pointerId;w&&I!==void 0&&w.releasePointerCapture&&w.releasePointerCapture(I)}catch{}};this.dragState.touchCleanup=y}let c=l==="mouse"?"mousemove":l==="touch"?"touchmove":"pointermove",d=l==="mouse"?"mouseup":l==="touch"?"touchend":"pointerup",h=g=>{let y=this.dragState.startedFromTrustedEvent;return y===void 0||g.isTrusted===y},f=document.when(c).takeUntil(document.when(d)).subscribe({next:g=>{if(h(g)){if(g.preventDefault(),g.stopPropagation(),l==="touch"){let y=g.touches?.[0]||g.changedTouches?.[0];if(!y)return;this.handleDragMove(y.clientX,y.clientY);return}if(l==="mouse"){let y=g;if(typeof y.buttons=="number"&&(y.buttons&1)!==1)return}this.handleDragMove(g.clientX,g.clientY)}}}),m=document.when(d).subscribe({next:g=>{h(g)&&(g.preventDefault(),g.stopPropagation(),this.handleDragEnd())}}),v=l==="touch"?document.when("touchcancel").subscribe({next:g=>{h(g)&&this.handleDragEnd()}}):l==="mouse"?null:document.when("pointercancel").subscribe({next:g=>{h(g)&&this.handleDragEnd()}}),x=document.when("keydown").filter(g=>g.key==="Escape").subscribe({next:g=>{h(g)&&this.handleDragEnd()}}),u=[f,m,x];v&&u.push(v),this.dragSubscriptions.push(...u)}handleDragMove(a,l){if(!this.dragState.dragging||!this.dragState.dragClone)return;this.updateClonePosition(a,l);let c=Ki(this.allDropzones,a,l,this.dragState.dragClone,this.collisionDetectionAlgorithm,this.trackedDragContainers),d=Date.now(),h=d-(this.dragState.lastTargetChangeTime||0);c!==this.dragState.currentTarget&&(c===null||h>=50)&&(this.allDropzones.forEach(m=>he(m,"hover",!1)),c&&he(c,"hover",!0),this.dragState.currentTarget=c,this.dragState.lastTargetChangeTime=d)}handleDragEnd(){if(!this.dragState.dragging)return;let{dragSource:a,dragClone:l,currentTarget:c,sourceDroppable:d}=this.dragState,h=c;if(l){let v=l.getBoundingClientRect();h=Ki(this.allDropzones,v.left+v.width/2,v.top+v.height/2,l,this.collisionDetectionAlgorithm,this.trackedDragContainers)??c}!!a&&!!h&&this.allowDrop(a,h)&&a&&h?(this.handleDrop(a,h),Vt(a,"dragging",!1)):this.handleInvalidDrop(a),l&&l.remove(),(this.dragState.returnAnchorItems||[]).forEach(v=>{Vt(v,"return-anchor",!1)}),this.dragState.touchCleanup&&this.dragState.touchCleanup(),this.resetDragState(),this.deactivateAllDroppables(),this.saveResponse(),d&&d.removeAttribute("data-drag-source"),this.cacheInteractiveElements();let m=this.checkAllMaxAssociations;typeof m=="function"&&m.call(this)}allowDrop(a,l){return this.trackedDroppables.includes(l)||this.trackedDragContainers.includes(l)}handleInvalidDrop(a){hn(a)}createDragClone(a,l){let c=a.cloneNode(!0),d=window.getComputedStyle(a);for(let f=0;f<d.length;f++){let m=d[f];c.style.setProperty(m,d.getPropertyValue(m))}let h=Nl(a.isConnected?a:this,this.dragCloneRoot());return this.cloneZoom=parseFloat(d.zoom)||1,this.cloneFrame=$l(h,this.cloneZoom),c.style.position="fixed",c.style.width=`${l.width/this.cloneFrame.scale.x}px`,c.style.height=`${l.height/this.cloneFrame.scale.y}px`,c.style.zIndex="9999",c.style.pointerEvents="none",c.style.touchAction="none",c.style.userSelect="none",c.style.opacity="0.8",c.removeAttribute("qti-draggable"),c.removeAttribute("tabindex"),c.setAttribute("data-drag-clone","true"),c.setAttribute("data-drag-interaction",this.tagName.toLowerCase()),h.appendChild(c),c}dragCloneRoot(){let a=this.getRootNode();return a instanceof ShadowRoot?a:null}updateClonePosition(a,l){if(this.dragState.lastCoordinates={x:a,y:l},!this.dragState.dragClone)return;let{startOffset:c}=this.dragState,{x:d,y:h}=Yh(this.cloneFrame,a-c.x,l-c.y);this.dragState.dragClone.style.left=`${d}px`,this.dragState.dragClone.style.top=`${h}px`}watchDragCloneHost(){let a=this.ownerDocument??document,l=()=>{let{dragClone:c,dragSource:d,lastCoordinates:h}=this.dragState;if(!c)return;let f=d?.isConnected?d:this,m=Nl(f,this.dragCloneRoot());m!==c.parentNode&&(m.appendChild(c),this.cloneFrame=$l(m,this.cloneZoom),h&&this.updateClonePosition(h.x,h.y))};a.addEventListener("fullscreenchange",l),a.addEventListener("webkitfullscreenchange",l),this.dragSubscriptions.push({unsubscribe:()=>{a.removeEventListener("fullscreenchange",l),a.removeEventListener("webkitfullscreenchange",l)}})}activateAllDroppables(){this.setInternalsState("dragzone-enabled",!0),this.setInternalsState("dragzone-active",!0),this.allDropzones.forEach(a=>{he(a,"enabled",!0),he(a,"active",!0)})}deactivateAllDroppables(){this.setInternalsState("dragzone-enabled",!1),this.setInternalsState("dragzone-active",!1),this.allDropzones.forEach(a=>{he(a,"enabled",!1),he(a,"active",!1),he(a,"hover",!1)})}resetDragState(){if(this.dragState.activationTimeout&&clearTimeout(this.dragState.activationTimeout),(this.dragState.returnAnchorItems||[]).forEach(a=>{Vt(a,"return-anchor",!1)}),this.dragState.touchCleanup)try{this.dragState.touchCleanup()}catch(a){console.warn("\u26A0\uFE0F [Observable DnD] Error during touch cleanup:",a)}this.dragSubscriptions.forEach(a=>{try{a&&typeof a.unsubscribe=="function"&&a.unsubscribe()}catch(l){console.warn("\u26A0\uFE0F [Observable DnD] Error unsubscribing:",l)}}),this.dragSubscriptions=[],this.cloneFrame=Dl,this.cloneZoom=1,this.dragState={dragging:!1,dragSource:null,dragClone:null,startOffset:{x:0,y:0},currentTarget:null,sourceDroppable:null,inputType:null,pointerId:void 0,startedFromTrustedEvent:void 0,touchCleanup:void 0,returnAnchorItems:[]}}setInternalsState(a,l){let c=this._internals;c?.states&&(l?c.states.add(a):c.states.delete(a))}cleanup(){this.subscriptions.forEach(a=>{try{a.unsubscribe()}catch{}}),this.subscriptions=[],this.dragState.dragClone&&this.dragState.dragClone.remove();for(let a of this.#t)Kh(a)&&(a.internals.states.delete("drag"),a.internals.states.delete("droppable"));this.#t.clear(),this.resetDragState()}}return r};var Zh={duration:250,easing:"ease",fill:"both"};function Ll(o){let t=o.getBoundingClientRect();return{left:t.left,top:t.top,width:t.width,height:t.height}}function tp(o){return{left:o.left,top:o.top,width:o.width,height:o.height}}function ze(o){let t=new Map;return o.forEach(e=>{t.set(e,Ll(e))}),t}function ep(o,t){return{deltaX:o.left-t.left,deltaY:o.top-t.top,deltaW:o.width/t.width,deltaH:o.height/t.height}}function Qo(o){if(typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches)return 0;if(!o)return 1;let t=getComputedStyle(o).getPropertyValue("--qti-motion").trim();if(t==="")return 1;let e=Number.parseFloat(t);return Number.isFinite(e)&&e>0?e:0}function Vl(o){return Qo(o)>0}function Go(o,t,e={}){let i=Qo(o);if(i<=0)return null;let n=Ll(o),{deltaX:r,deltaY:s,deltaW:a,deltaH:l}=ep(t,n);if(r===0&&s===0&&a===1&&l===1)return null;let{duration:c,easing:d,fill:h}={...Zh,...e};return o.animate([{transformOrigin:"top left",transform:`translate(${r}px, ${s}px) scale(${a}, ${l})`},{transformOrigin:"top left",transform:"none"}],{duration:c*i,easing:d,fill:h})}function je(o,t={}){let e=new Map;return o.forEach((i,n)=>{if(!(n instanceof HTMLElement))return;let r=Go(n,i,t);r&&e.set(n,r)}),e}var pn=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},zt=(o,t,e,i='slot[part="drags"]',n="closestCornersWithInventoryPriority")=>{let r=Tl(o,t,e,i),s=Wo(r,t,e,i,n);class a extends s{constructor(){super(...arguments),this.minAssociations=1,this._maxAssociations=0,this._maxAssociationsDefaultApplied=!1,this._response=[],this._dragDrop={dragsByTarget:{},countByTarget:{},nodesByTarget:{}},this.#t=new WeakMap,this._dropBlockedDueToMax=!1,this.flipAnimationConfig={duration:200,easing:"ease"},this._enableFlipAnimations=!0,this._pendingResponse=void 0}get maxAssociations(){if(!this._maxAssociationsDefaultApplied){this._maxAssociationsDefaultApplied=!0;let c=this.tagName?.toLowerCase()||"";(c==="qti-graphic-gap-match-interaction"||c==="qti-gap-match-interaction")&&!this.hasAttribute("max-associations")&&this._maxAssociations===0&&(this._maxAssociations=1)}return this._maxAssociations}set maxAssociations(c){let d=this._maxAssociations;this._maxAssociations=c,this.requestUpdate("maxAssociations",d)}#t;isSwapTarget(c){let d=this.dragState.sourceDroppable,h=parseInt(c.getAttribute("match-max")||"1",10);return(Number.isNaN(h)?1:h)===1&&this.isDeclarativeTarget(c)&&!!d&&d!==c&&this.trackedDroppables.includes(d)}isDeclarativeTarget(c){return c?c.acceptsDeclarativeDrops===!0?!0:c.hasAttribute("data-declarative-drops"):!1}chipsIn(c){return this.isDeclarativeTarget(c)?[...this.#t.get(c)??[]]:Array.from(c.querySelectorAll(t))}droppableHolding(c){return this.trackedDroppables.find(d=>this.chipsIn(d).includes(c)||d.contains(c)||!!d.shadowRoot?.contains(c))??null}placeChip(c,d){this.#t.set(c,[...this.#t.get(c)??[],d])}removeChipFromDroppable(c,d){let h=c??this.droppableHolding(d);if(h&&this.isDeclarativeTarget(h)){let f=(this.#t.get(h)??[]).filter(m=>m!==d);this.#t.set(h,f),f.length===0&&Zi(h,!1),this.syncDragDropState();return}d.remove()}clearChips(c){this.isDeclarativeTarget(c)?(this.#t.set(c,[]),this.syncDragDropState()):this.chipsIn(c).forEach(d=>d.remove()),Zi(c,!1)}syncDragDropState(){let c={},d={},h={};for(let f of this.trackedDroppables){let m=f.getAttribute("identifier");if(!m)continue;let v=this.chipsIn(f),x=this.isDeclarativeTarget(f)?v:Array.from(f.querySelectorAll('[qti-draggable="true"]'));c[m]=v.map(u=>u.getAttribute("identifier")).filter(u=>!!u),d[m]=Math.max(v.length,x.length),h[m]=v}this._dragDrop={dragsByTarget:c,countByTarget:d,nodesByTarget:h},this.requestUpdate()}responseFromState(){this.syncDragDropState();let{dragsByTarget:c}=this._dragDrop;return this.trackedDroppables.flatMap(d=>{let h=d.getAttribute("identifier");return h?(c[h]??[]).map(f=>`${f} ${h}`):[]})}totalAssociationsFromState(){return this.syncDragDropState(),Object.values(this._dragDrop.countByTarget).reduce((c,d)=>c+d,0)}droppableAtCapacityFromState(c){let d=parseInt(c.getAttribute("match-max")||"1",10),h=Number.isNaN(d)?1:d;if(h===0)return!1;let f=c.getAttribute("identifier");return(f?this._dragDrop.countByTarget[f]??0:0)>=h}set disableAnimations(c){this._enableFlipAnimations=!c}get disableAnimations(){return!this._enableFlipAnimations}get enableFlipAnimations(){return this._enableFlipAnimations&&Vl(this)}collectAutoSizeTargets(){return{draggables:this.trackedDraggables,droppables:this.trackedDroppables,dragContainers:this.trackedDragContainers}}get response(){let c=this.getResponse,d=typeof c=="function"?c.call(this):void 0;return(Array.isArray(d)?d:(this.cacheInteractiveElements(),this.responseFromState())).join(",")}set response(c){if(Array.isArray(c)){if(!this.trackedDroppables||this.trackedDroppables.length===0){this._pendingResponse=c,this._internals.setFormValue(JSON.stringify(c));return}let d=this.getValue,h=typeof d=="function"?d.call(this,c):c,f=Array.isArray(h)?h:typeof h=="string"&&h.length>0?[h]:[];this.reset(!1),f.forEach(x=>this.placeResponse(x));let m=this.getResponse,v=typeof m=="function"?m.call(this):void 0;this._response=Array.isArray(v)?v:(this.cacheInteractiveElements(),this.responseFromState())}else this._response=typeof c=="string"&&c.length>0?[c]:[];this._internals.setFormValue(JSON.stringify(this._response))}afterCache(){if(this.updateMinDimensionsForDropZones(),this.applyConfiguredChoicesContainerWidth(),this._pendingResponse!==void 0){let c=this._pendingResponse;this._pendingResponse=void 0,this.response=c}}get autoSizeDropzoneWidth(){return!this.dataset.choicesContainerWidth}applyConfiguredChoicesContainerWidth(){let c=this.dataset.choicesContainerWidth;c&&this.trackedDroppables.forEach(d=>{d.style.width=`${c}px`,d.style.boxSizing="border-box"})}shouldTreatBlockedMaxAsInvalid(){return!0}shouldReturnToInventoryOnInventoryDrop(){return!1}getFirstMessageAttribute(c){for(let h of c){let f=this.getAttribute(h);if(f&&f.trim().length>0)return f}let d=c.map(h=>h.toLowerCase());for(let h of Array.from(this.attributes))if(d.includes(h.name.toLowerCase())&&h.value.trim().length>0)return h.value;return null}allowDrop(c,d){if(this.trackedDragContainers.includes(d))return!0;let h=this.trackedDroppables.includes(d),f=d.hasAttribute("disabled"),m=d.hasAttribute("data-drag-source");return f&&this.isSwapTarget(d)?!0:h&&(!f||m)}handleDrop(c,d){let h=this.dragState.dragClone?.getBoundingClientRect();this.dropDraggableInDroppable(c,d,h);let f=c.getAttribute("identifier");f&&this.updateInventoryBasedOnMatchMax(f),this.validate(),this.reportValidity()}handleInvalidDrop(c){let d=this.dragState.sourceDroppable,h=this.dragState.currentTarget,f=!h,m=this.trackedDragContainers[0]||null;if(!c)return;if(d&&f&&m)this.dropDraggableInDroppable(c,m);else if(d&&this.trackedDroppables.includes(d))this.dropDraggableInDroppable(c,d,this.dragState.dragClone?.getBoundingClientRect());else if(Uo(c,"dragging")){this.restoreInventoryItem(c,this.dragState.dragClone?.getBoundingClientRect());let g=c.getAttribute("identifier");g&&this.updateInventoryBasedOnMatchMax(g),this.cacheInteractiveElements(),this.checkAllMaxAssociations()}let v=this.totalAssociationsFromState(),x=this.maxAssociations>0&&v>=this.maxAssociations,u=!!h&&h.hasAttribute("disabled")&&!h.hasAttribute("data-drag-source");this._dropBlockedDueToMax=u&&x,this.validate(),this.reportValidity()}animateReturn(c,d){!c||!d||!this.enableFlipAnimations||requestAnimationFrame(()=>{Go(c,tp(d),this.flipAnimationConfig)})}restoreInventoryItem(c,d){hn(c),c.style.display="",c.style.position="",this.animateReturn(c,d)}placeResponse(c){let[d,...h]=c.split(" ").reverse(),f=this.trackedDroppables.find(m=>m.getAttribute("identifier")===d);f&&h.forEach(m=>{if(!m)return;let x=tr(this.trackedDragContainers,m).at(0)||this.trackedDraggables.find(u=>u.getAttribute("identifier")===m);x&&this.dropDraggableInDroppable(x,f)})}dropDraggableInDroppable(c,d,h){if(this.trackedDragContainers.includes(d)){if(!this.dragState.sourceDroppable){if(this.shouldReturnToInventoryOnInventoryDrop()){this.returnToInventory(c,h),this._dropBlockedDueToMax=!1,this.validate();return}this.restoreInventoryItem(c,h),this.cacheInteractiveElements(),this.checkAllMaxAssociations(),this._dropBlockedDueToMax=!1,this.validate();return}let I=c.getAttribute("identifier");this.removeChipFromDroppable(this.droppableHolding(c),c),I&&this.restoreOriginalInInventory(I,h),this.cacheInteractiveElements(),this.checkAllMaxAssociations(),this._dropBlockedDueToMax=!1,this.validate();return}let m=parseInt(d.getAttribute("match-max")||"1",10),v=Number.isNaN(m)?1:m,x=v===0||v>1,u=Array.from(d.querySelectorAll('[qti-draggable="true"]')),g=this.enableFlipAnimations&&u.length>0?ze(u):null;if(!x){let I=this.chipsIn(d)[0]??(this.isDeclarativeTarget(d)?null:d.querySelector('[qti-draggable="true"]'));if(I){let A=I.getAttribute("identifier"),k=I.getBoundingClientRect();this.removeChipFromDroppable(d,I);let S=this.dragState.sourceDroppable,R=this.isDeclarativeTarget(d)&&S&&S!==d&&this.isDeclarativeTarget(S)?S:null;R?(this.placeChip(R,I),Zi(R,!0),this.animateReturn(I,k)):A&&this.restoreOriginalInInventory(A,k)}}let y=c.cloneNode(!0);y.removeAttribute("style"),y.removeAttribute("data-keyboard-dragging"),y.setAttribute("qti-draggable","true"),y.setAttribute("tabindex","0"),this.isDeclarativeTarget(d)?(y.setAttribute("part","drag"),y.setAttribute("exportparts","control: drag-control, label: drag-label, correction, correction-correct, correction-incorrect"),this.placeChip(d,y)):d.tagName==="SLOT"?y.setAttribute("slot",d.getAttribute("name")||""):(d.tagName==="QTI-SIMPLE-ASSOCIABLE-CHOICE"&&y.setAttribute("slot","qti-simple-associable-choice"),d.appendChild(y)),Zi(d,!0),this.syncDragDropState(),g&&this.enableFlipAnimations&&je(g,this.flipAnimationConfig),h&&this.enableFlipAnimations&&requestAnimationFrame(()=>{let I=y.getBoundingClientRect(),A=h.left-I.left,k=h.top-I.top;(A!==0||k!==0)&&y.animate([{transform:`translate(${A}px, ${k}px)`,opacity:.8},{transform:"translate(0, 0)",opacity:1}],{duration:this.flipAnimationConfig.duration||200,easing:this.flipAnimationConfig.easing||"ease",fill:"both"})});let w=c.getAttribute("identifier");w&&this.updateInventoryBasedOnMatchMax(w),this.cacheInteractiveElements(),this.checkAllMaxAssociations()}returnToInventory(c,d){let h=c.getAttribute("identifier");h&&(this.trackedDroppables.forEach(f=>{let m=this.chipsIn(f).filter(v=>v.getAttribute("identifier")===h);m.forEach(v=>this.removeChipFromDroppable(f,v)),m.length>0&&this.chipsIn(f).length===0&&Zi(f,!1)}),this.restoreOriginalInInventory(h,d)),this.cacheInteractiveElements(),this.checkAllMaxAssociations()}restoreOriginalInInventory(c,d){let h=tr(this.trackedDragContainers,c),f=new Set(h),m=[];this.trackedDragContainers.forEach(x=>{x.querySelectorAll('[qti-draggable="true"]').forEach(u=>!f.has(u)&&m.push(u))});let v=this.enableFlipAnimations&&m.length>0?ze(m):null;h.forEach(x=>{hn(x),x.style.display="",x.style.visibility="visible"}),v&&this.enableFlipAnimations&&je(v,this.flipAnimationConfig),h.forEach(x=>this.animateReturn(x,d))}updateInventoryBasedOnMatchMax(c){let d=tr(this.trackedDragContainers,c),h=Xh(this.trackedDraggables,c),f=this.trackedDroppables.reduce((m,v)=>this.isDeclarativeTarget(v)?m+this.chipsIn(v).filter(x=>x.getAttribute("identifier")===c).length:m+v.querySelectorAll(`[identifier="${c}"]`).length,0);d.forEach(m=>{Vt(m,"placeholder",h!==0&&f>=h)})}checkAllMaxAssociations(){let c=this.totalAssociationsFromState(),d=this.resolveDisableAfterMaxReached({defaultWhenUnset:!0}),h=this.maxAssociations>0&&c>=this.maxAssociations;this.trackedDroppables.forEach(f=>{let m=f.hasAttribute("data-drag-source");(this.droppableAtCapacityFromState(f)||d&&h)&&!m?f.setAttribute("disabled",""):f.removeAttribute("disabled")})}saveResponse(c){let d=this.getResponse,h=c??(typeof d=="function"?d.call(this):void 0),f=Array.isArray(h)?h:typeof h=="string"?[h]:(this.cacheInteractiveElements(),this.responseFromState());this._response=f,this._internals.setFormValue(JSON.stringify(this._response)),this.dispatchEvent(new CustomEvent("qti-interaction-response",{bubbles:!0,composed:!0,detail:{responseIdentifier:this.responseIdentifier,response:f}})),this.requestUpdate()}reset(c=!0){this.trackedDroppables.forEach(d=>{this.clearChips(d)}),this.trackedDraggables.forEach(d=>{let h=d.getAttribute("identifier");h&&this.restoreOriginalInInventory(h)}),this.resetDragState(),this.cacheInteractiveElements(),this._response=[],this._internals.setFormValue(JSON.stringify(this._response)),c&&this.saveResponse()}validate(){let c=this.totalAssociationsFromState(),d=this.maxAssociations>0&&c>=this.maxAssociations,h=this.maxAssociations>0&&c>this.maxAssociations,f=this.minAssociations>0&&c<this.minAssociations,m="",v=!0;h?(m=this.getFirstMessageAttribute(["data-max-associations-message","data-max-selections-message"])||this.dataset.maxAssociationsMessage||this.dataset.maxSelectionsMessage||`You've selected too many associations. Maximum allowed is ${this.maxAssociations}.`,v=!1):d&&this._dropBlockedDueToMax&&this.shouldTreatBlockedMaxAsInvalid()?(m=this.getFirstMessageAttribute(["data-max-associations-message","data-max-selections-message"])||this.dataset.maxAssociationsMessage||this.dataset.maxSelectionsMessage||`You've selected too many associations. Maximum allowed is ${this.maxAssociations}.`,v=!1):f?(m=this.getFirstMessageAttribute(["data-min-associations-message","data-min-selections-message"])||this.dataset.minAssociationsMessage||this.dataset.minSelectionsMessage||`Please select at least ${this.minAssociations} ${this.minAssociations===1?"association":"associations"}.`,v=!1,this._dropBlockedDueToMax=!1):this._dropBlockedDueToMax=!1;let x=this.trackedDroppables[0]??this.trackedDraggables[0]??this;return this.setInteractionValidity(v,m,x,{suppressInline:!0}),v}reportValidity(){return super.reportValidity()}}return pn([p({type:Number,reflect:!0,attribute:"min-associations"})],a.prototype,"minAssociations",void 0),pn([p({type:Number,reflect:!0,attribute:"max-associations"})],a.prototype,"maxAssociations",null),pn([U({context:Ne})],a.prototype,"_dragDrop",void 0),pn([p({type:Boolean,attribute:"disable-animations"})],a.prototype,"disableAnimations",null),pn([p({attribute:"response",reflect:!1,noAccessor:!0,converter:Gt({emptyAs:[]})})],a.prototype,"response",null),a};var Xo=class{getInsertPosition(t,e,i,n,r){let s=t.indexOf(i);if(s===-1)return null;let a=i.getBoundingClientRect(),l=(r-a.top)/a.height,d=Math.min(1,Math.max(0,l))>.5;return{index:s,placeAfter:d}}};var ip=new Xo;var Wm={borderStyle:"2px dashed",borderColor:"var(--qti-drop-highlight-border-color, #c1c1c1)",background:"transparent",transitionDuration:150};function un(){return{placeholder:null,lastHoverTarget:null,lastPlacement:null,sortContainer:null}}function Yo(o){o.placeholder?.remove(),o.placeholder=null,o.lastHoverTarget=null,o.lastPlacement=null,o.sortContainer=null}function Jo(o,t,e={}){let i={...Wm,...e},n=document.createElement("div");return n.setAttribute("data-drop-placeholder","true"),n.style.width=`${t.width}px`,n.style.height=`${t.height}px`,n.style.margin=window.getComputedStyle(o).margin,n.style.boxSizing="border-box",n.style.border=`${i.borderStyle} ${i.borderColor}`,n.style.borderRadius=getComputedStyle(o).borderRadius,n.style.background=i.background,n.style.transition=`transform ${i.transitionDuration*Qo(o)}ms ease`,n.style.pointerEvents="none",n}function zl(o,t){for(let e of t)if(e.contains(o)&&e!==o)return e;return null}var jt=(o,t='[qti-draggable="true"]')=>{class e extends o{constructor(){super(...arguments),this.#t=null,this.#e=null,this.#i=un(),this.#r={hoveredSlot:null,originalPositions:new Map},this.#n=new Set,this.sortablePlaceholderConfig={},this.sortableAnimationConfig={duration:150,easing:"ease"}}#t;#e;#i;#r;#n;#o;set allowReorder(n){this.#o=n}get allowReorder(){return this.#o??this.resolveAllowReorder({defaultWhenUnset:!0})}get isDraggingFromSlot(){return this.#t!==null}findContainingDroppable(n){return zl(n,this.trackedDroppables)}#s(n){return n.querySelector(t)}#a(n){let r=this.#c(n);return r===0||r>1}#c(n){let r=parseInt(n.getAttribute("match-max")||"1",10);return Number.isNaN(r)?1:r}#p(n){return n.querySelectorAll(t).length}#l(n){let r=this.#c(n);return r===0?!1:this.#p(n)>=r}#m(){this.#r={hoveredSlot:null,originalPositions:new Map}}#d(n){if(!this.#t||n===this.#t){this.#u();return}if(this.#r.hoveredSlot===n)return;this.#u();let r=this.#s(n);if(!r){this.#i.placeholder&&n.appendChild(this.#i.placeholder),this.#r.hoveredSlot=n;return}if(this.#a(n)){if(this.#l(n)){this.#i.placeholder&&this.#t&&this.#t.appendChild(this.#i.placeholder),this.#r.hoveredSlot=null;return}this.#i.placeholder&&n.appendChild(this.#i.placeholder),this.#r.hoveredSlot=n;return}if(this.isDeclarativeTarget(n)){this.#i.placeholder?.parentElement&&this.#i.placeholder.remove(),this.#r.hoveredSlot=n;return}let a=ze([r]);this.#r.originalPositions.set(r,n),this.#i.placeholder&&this.#i.placeholder.parentElement&&this.#i.placeholder.remove(),this.#t.appendChild(r),this.#i.placeholder&&n.appendChild(this.#i.placeholder),this.#r.hoveredSlot=n,je(a,this.sortableAnimationConfig)}#u(){if(this.#r.originalPositions.size===0&&this.#r.hoveredSlot===null)return;let n=Array.from(this.#r.originalPositions.keys()),r=n.length>0?ze(n):null;for(let[s,a]of this.#r.originalPositions)a.appendChild(s);this.#i.placeholder&&this.#t&&this.#t.appendChild(this.#i.placeholder),r&&je(r,this.sortableAnimationConfig),this.#r.originalPositions.clear(),this.#r.hoveredSlot=null}initiateDrag(n,r,s,a,...l){this.#t=null,this.#i=un(),this.#m();let c=this.findContainingDroppable(n);if(this.#e=c,c&&this.allowReorder){this.#t=c,this.#i.sortContainer=c;let h=n.getBoundingClientRect();this.#i.placeholder=Jo(n,h,this.sortablePlaceholderConfig);let f=n.getAttribute("slot");f&&this.#i.placeholder.setAttribute("slot",f),this.#i.placeholder.style.visibility="hidden",c.appendChild(this.#i.placeholder),this.trackedDroppables.forEach(m=>{if(m!==c&&m.hasAttribute("disabled")){if(this.#a(m)&&this.#l(m))return;m.removeAttribute("disabled"),this.#n.add(m)}})}let[d]=l;super.initiateDrag(n,r,s,a,d)}cleanupSortableState(n=!0){if(n)for(let[r,s]of this.#r.originalPositions)s.appendChild(r);this.#i.placeholder&&this.#i.placeholder.remove(),Yo(this.#i),this.#n.clear(),this.#t=null,this.#m()}onSortableDragMove(n,r){if(!this.isDraggingFromSlot)return;let s=Ki(this.trackedDroppables,n,r,this.dragState.dragClone,this.collisionDetectionAlgorithm);s?this.#d(s):this.#u()}handleDragMove(n,r){Object.getPrototypeOf(e.prototype).handleDragMove?.call(this,n,r),this.onSortableDragMove(n,r)}allowDrop(n,r){return!this.allowReorder&&this.#e&&!this.trackedDragContainers.includes(this.#e)&&r!==this.#e&&this.trackedDroppables.includes(r)?!1:this.isDraggingFromSlot&&this.trackedDroppables.includes(r)?this.#a(r)?!this.#l(r):!0:this.isDraggingFromSlot&&this.trackedDragContainers.includes(r)?!0:super.allowDrop(n,r)}handleDrop(n,r){super.handleDrop(n,r),this.cleanupSortableState(!1)}handleInvalidDrop(n){this.cleanupSortableState(),super.handleInvalidDrop(n)}}return e};var rp=[P,W,Wt,q`
7049
7054
  :host {
7050
7055
  display: block; /* necessary to calculate scaling position */
7051
7056
  }
@@ -7109,7 +7114,7 @@ div.full-correct-response-inline {
7109
7114
  </div>`)}
7110
7115
 
7111
7116
  <div role="alert" part="message" id="validation-message"></div>
7112
- </div>`}updated(t){super.updated(t),t.has("_childrenMap")&&this.cacheInteractiveElements()}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("register-qti-simple-associable-choice",this._registerChoiceHandler)}};Km([T()],wi.prototype,"_childrenMap",void 0);var Ko=[{tag:"qti-associate-interaction",ctor:wi}];var Fe=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},Be=(o,t)=>{class e extends o{constructor(){super(...arguments),this._choiceElements=[],this.#t=null,this.minChoices=0,this.maxChoices=1,this._handleDisabledChange=(n,r)=>{this._choiceElements.forEach(s=>s.disabled=r)},this._handleReadonlyChange=(n,r)=>{this._choiceElements.forEach(s=>s.readonly=r)},this.response="",this._handleValueChange=()=>{this._internals.setFormValue(this.value),this._updateChoiceSelection()}}#t;_handleMaxChoicesChange(n,r){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(n){this.maxChoices>1&&(typeof n=="string"||n===null)?this.response=n?n.toString().split(","):[]:this.response=n||""}firstUpdated(){super.firstUpdated(),this._updateChoiceSelection()}connectedCallback(){super.connectedCallback(),this.addEventListener(`activate-${t}`,this._choiceElementSelectedHandler),this.#t=new MutationObserver(()=>this._syncChoicesFromDOM()),this.#t.observe(this,{childList:!0,subtree:!0}),this._syncChoicesFromDOM()}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(`activate-${t}`,this._choiceElementSelectedHandler),this.#t&&(this.#t.disconnect(),this.#t=null)}_syncChoicesFromDOM(){let n=new Set(this._choiceElements);this._choiceElements=Array.from(this.querySelectorAll(t)),this._choiceElements.forEach(s=>{n.has(s)||(this.disabled&&(s.disabled=!0),s.readonly=this.readonly,s.internals&&!s.internals.ariaChecked&&(s.internals.ariaChecked="false"))}),this._determineInputType();let r=new Set(this._choiceElements.map(s=>s.identifier));if(Array.isArray(this.response)){let s=this.response.filter(a=>r.has(a));s.length!==this.response.length&&(this.response=s)}else this.response&&!r.has(this.response)&&(this.response="");this._updateChoiceSelection()}validate(){let r=this._choiceElements.filter(c=>this._getChoiceChecked(c)).length,s=!0,a="";this.maxChoices!==0&&r>this.maxChoices?(s=!1,a=this.dataset.maxSelectionsMessage||`Please select no more than ${this.maxChoices} ${this.maxChoices===1?"option":"options"}.`):r<this.minChoices&&(s=!1,a=this.dataset.minSelectionsMessage||`Please select at least ${this.minChoices} ${this.minChoices===1?"option":"options"}.`);let l=this._choiceElements.find(c=>this.contains(c))||this;return this.setInteractionValidity(s,a,l,{suppressInline:!0}),s}reportValidity(){return super.reportValidity()}_determineInputType(){this._internals.role=this.maxChoices===1?"radiogroup":null;let n=this.maxChoices===1?"radio":"checkbox";this._interactionContext.choiceRole!==n&&(this._interactionContext={...this._interactionContext,choiceRole:n})}_choiceElementSelectedHandler(n){this._toggleChoiceChecked(n.target);let r=this.resolveDisableAfterMaxReached({defaultWhenUnset:!1});this.maxChoices===1?this._choiceElements.forEach(s=>{s.identifier!==n.detail.identifier&&this._setChoiceChecked(s,!1)}):this.maxChoices!==0&&r&&(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(n,r){n.internals?.states&&(r?(n.internals.states.add("checked"),n.internals.ariaChecked="true"):(n.internals.states.delete("checked"),n.internals.ariaChecked="false"))}_getChoiceChecked(n){return n.internals.states.has("checked")}_toggleChoiceChecked(n){let r=this._getChoiceChecked(n);this._setChoiceChecked(n,!r)}_handleChoiceSelection(){let r=this._choiceElements.filter(s=>this._getChoiceChecked(s)).map(s=>s.identifier);this.response=this.maxChoices===1?r[0]||"":r,this.validate(),this.reportValidity(),this.saveResponse(this.response)}_updateChoiceSelection(){let n=Array.isArray(this.response)?this.response:[this.response];this._choiceElements.forEach(r=>{let s=n.includes(r.identifier);this._setChoiceChecked(r,s)})}}return Fe([Ii("#validation-message")],e.prototype,"_validationMessageElement",void 0),Fe([p({type:Number,attribute:"min-choices"})],e.prototype,"minChoices",void 0),Fe([p({type:Number,attribute:"max-choices"})],e.prototype,"maxChoices",void 0),Fe([L("maxChoices")],e.prototype,"_handleMaxChoicesChange",null),Fe([L("disabled",{waitUntilFirstUpdate:!0})],e.prototype,"_handleDisabledChange",void 0),Fe([L("readonly",{waitUntilFirstUpdate:!0})],e.prototype,"_handleReadonlyChange",void 0),Fe([p({attribute:"response",reflect:!1,converter:Xt({emptyAs:""})})],e.prototype,"response",void 0),Fe([L("response",{waitUntilFirstUpdate:!0})],e.prototype,"_handleValueChange",void 0),e};var tf=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},np=(o,t)=>{class e extends o{#t=[];#e=["qti-labels-none","qti-labels-decimal","qti-labels-lower-alpha","qti-labels-upper-alpha"];#i=["qti-labels-suffix-none","qti-labels-suffix-period","qti-labels-suffix-parenthesis"];#r=null;set class(n){this.#t=this.#n(n),this.#o()}get class(){return this.#t.join(" ")}attributeChangedCallback(n,r,s){super.attributeChangedCallback(n,r,s),n==="class"&&r!==s&&(this.class=s??"")}updated(n){super.updated(n),this.#o()}connectedCallback(){super.connectedCallback(),this.class=this.getAttribute("class")??"",this.#r=new MutationObserver(n=>{n.some(r=>r.type==="childList"||r.type==="attributes"&&r.attributeName==="style")&&this.#o()}),this.#r.observe(this,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["style"]})}disconnectedCallback(){super.disconnectedCallback(),this.#r?.disconnect(),this.#r=null}#n(n){return n?n.split(/\s+/).map(r=>r.trim()).filter(Boolean).filter((r,s,a)=>a.indexOf(r)===s):[]}#o(){let n=Array.from(this.querySelectorAll("qti-simple-choice")).map(l=>l),r=this.#s(n),s=this.#a(),a=this.#c();r.forEach((l,c)=>{l.marker=this.#p(c+1,s,a)})}#s(n){return n.map((r,s)=>{let a=Number(r.style.order);return{el:r,order:Number.isFinite(a)?a:s+1,index:s}}).sort((r,s)=>r.order-s.order||r.index-s.index).map(r=>r.el)}#a(){return this.#t.filter(n=>this.#e.includes(n)).pop()??null}#c(){return this.#t.filter(n=>this.#i.includes(n)).pop()??null}#p(n,r,s){let a=r;if(!a&&s&&s!=="qti-labels-suffix-none"&&(a="qti-labels-upper-alpha"),!a||a==="qti-labels-none")return"";let l="";switch(a){case"qti-labels-decimal":l=`${n}`;break;case"qti-labels-lower-alpha":l=this.#l(n,"lower");break;case"qti-labels-upper-alpha":l=this.#l(n,"upper");break}return s==="qti-labels-suffix-period"?`${l}.`:s==="qti-labels-suffix-parenthesis"?`${l})`:l}#l(n,r){let s=n,a="",l=r==="lower"?97:65;for(;s>0;)s-=1,a=String.fromCharCode(l+s%26)+a,s=Math.floor(s/26);return a}}return tf([p({type:String,attribute:"class"})],e.prototype,"class",null),e};var op=[P,W,q`
7117
+ </div>`}updated(t){super.updated(t),t.has("_childrenMap")&&this.cacheInteractiveElements()}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("register-qti-simple-associable-choice",this._registerChoiceHandler)}};Km([T()],wi.prototype,"_childrenMap",void 0);var Ko=[{tag:"qti-associate-interaction",ctor:wi}];var Fe=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},Be=(o,t)=>{class e extends o{constructor(){super(...arguments),this._choiceElements=[],this.#t=null,this.minChoices=0,this.maxChoices=1,this._handleDisabledChange=(n,r)=>{this._choiceElements.forEach(s=>s.disabled=r)},this._handleReadonlyChange=(n,r)=>{this._choiceElements.forEach(s=>s.readonly=r)},this.response="",this._handleValueChange=()=>{this._internals.setFormValue(this.value),this._updateChoiceSelection()}}#t;_handleMaxChoicesChange(n,r){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(n){this.maxChoices>1&&(typeof n=="string"||n===null)?this.response=n?n.toString().split(","):[]:this.response=n||""}firstUpdated(){super.firstUpdated(),this._updateChoiceSelection()}connectedCallback(){super.connectedCallback(),this.addEventListener(`activate-${t}`,this._choiceElementSelectedHandler),this.#t=new MutationObserver(()=>this._syncChoicesFromDOM()),this.#t.observe(this,{childList:!0,subtree:!0}),this._syncChoicesFromDOM()}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(`activate-${t}`,this._choiceElementSelectedHandler),this.#t&&(this.#t.disconnect(),this.#t=null)}_syncChoicesFromDOM(){let n=new Set(this._choiceElements);this._choiceElements=Array.from(this.querySelectorAll(t)),this._choiceElements.forEach(s=>{n.has(s)||(this.disabled&&(s.disabled=!0),s.readonly=this.readonly,s.internals&&!s.internals.ariaChecked&&(s.internals.ariaChecked="false"))}),this._determineInputType();let r=new Set(this._choiceElements.map(s=>s.identifier));if(Array.isArray(this.response)){let s=this.response.filter(a=>r.has(a));s.length!==this.response.length&&(this.response=s)}else this.response&&!r.has(this.response)&&(this.response="");this._updateChoiceSelection()}validate(){let r=this._choiceElements.filter(c=>this._getChoiceChecked(c)).length,s=!0,a="";this.maxChoices!==0&&r>this.maxChoices?(s=!1,a=this.dataset.maxSelectionsMessage||`Please select no more than ${this.maxChoices} ${this.maxChoices===1?"option":"options"}.`):r<this.minChoices&&(s=!1,a=this.dataset.minSelectionsMessage||`Please select at least ${this.minChoices} ${this.minChoices===1?"option":"options"}.`);let l=this._choiceElements.find(c=>this.contains(c))||this;return this.setInteractionValidity(s,a,l,{suppressInline:!0}),s}reportValidity(){return super.reportValidity()}_determineInputType(){this._internals.role=this.maxChoices===1?"radiogroup":null;let n=this.maxChoices===1?"radio":"checkbox";this._interactionContext.choiceRole!==n&&(this._interactionContext={...this._interactionContext,choiceRole:n})}_choiceElementSelectedHandler(n){this._toggleChoiceChecked(n.target);let r=this.resolveDisableAfterMaxReached({defaultWhenUnset:!1});this.maxChoices===1?this._choiceElements.forEach(s=>{s.identifier!==n.detail.identifier&&this._setChoiceChecked(s,!1)}):this.maxChoices!==0&&r&&(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(n,r){n.internals?.states&&(r?(n.internals.states.add("checked"),n.internals.ariaChecked="true"):(n.internals.states.delete("checked"),n.internals.ariaChecked="false"))}_getChoiceChecked(n){return n.internals.states.has("checked")}_toggleChoiceChecked(n){let r=this._getChoiceChecked(n);this._setChoiceChecked(n,!r)}_handleChoiceSelection(){let r=this._choiceElements.filter(s=>this._getChoiceChecked(s)).map(s=>s.identifier);this.response=this.maxChoices===1?r[0]||"":r,this.validate(),this.reportValidity(),this.saveResponse(this.response)}_updateChoiceSelection(){let n=Array.isArray(this.response)?this.response:[this.response];this._choiceElements.forEach(r=>{let s=n.includes(r.identifier);this._setChoiceChecked(r,s)})}}return Fe([_i("#validation-message")],e.prototype,"_validationMessageElement",void 0),Fe([p({type:Number,attribute:"min-choices"})],e.prototype,"minChoices",void 0),Fe([p({type:Number,attribute:"max-choices"})],e.prototype,"maxChoices",void 0),Fe([L("maxChoices")],e.prototype,"_handleMaxChoicesChange",null),Fe([L("disabled",{waitUntilFirstUpdate:!0})],e.prototype,"_handleDisabledChange",void 0),Fe([L("readonly",{waitUntilFirstUpdate:!0})],e.prototype,"_handleReadonlyChange",void 0),Fe([p({attribute:"response",reflect:!1,converter:Gt({emptyAs:""})})],e.prototype,"response",void 0),Fe([L("response",{waitUntilFirstUpdate:!0})],e.prototype,"_handleValueChange",void 0),e};var tf=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},np=(o,t)=>{class e extends o{#t=[];#e=["qti-labels-none","qti-labels-decimal","qti-labels-lower-alpha","qti-labels-upper-alpha"];#i=["qti-labels-suffix-none","qti-labels-suffix-period","qti-labels-suffix-parenthesis"];#r=null;set class(n){this.#t=this.#n(n),this.#o()}get class(){return this.#t.join(" ")}attributeChangedCallback(n,r,s){super.attributeChangedCallback(n,r,s),n==="class"&&r!==s&&(this.class=s??"")}updated(n){super.updated(n),this.#o()}connectedCallback(){super.connectedCallback(),this.class=this.getAttribute("class")??"",this.#r=new MutationObserver(n=>{n.some(r=>r.type==="childList"||r.type==="attributes"&&r.attributeName==="style")&&this.#o()}),this.#r.observe(this,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["style"]})}disconnectedCallback(){super.disconnectedCallback(),this.#r?.disconnect(),this.#r=null}#n(n){return n?n.split(/\s+/).map(r=>r.trim()).filter(Boolean).filter((r,s,a)=>a.indexOf(r)===s):[]}#o(){let n=Array.from(this.querySelectorAll("qti-simple-choice")).map(l=>l),r=this.#s(n),s=this.#a(),a=this.#c();r.forEach((l,c)=>{l.marker=this.#p(c+1,s,a)})}#s(n){return n.map((r,s)=>{let a=Number(r.style.order);return{el:r,order:Number.isFinite(a)?a:s+1,index:s}}).sort((r,s)=>r.order-s.order||r.index-s.index).map(r=>r.el)}#a(){return this.#t.filter(n=>this.#e.includes(n)).pop()??null}#c(){return this.#t.filter(n=>this.#i.includes(n)).pop()??null}#p(n,r,s){let a=r;if(!a&&s&&s!=="qti-labels-suffix-none"&&(a="qti-labels-upper-alpha"),!a||a==="qti-labels-none")return"";let l="";switch(a){case"qti-labels-decimal":l=`${n}`;break;case"qti-labels-lower-alpha":l=this.#l(n,"lower");break;case"qti-labels-upper-alpha":l=this.#l(n,"upper");break}return s==="qti-labels-suffix-period"?`${l}.`:s==="qti-labels-suffix-parenthesis"?`${l})`:l}#l(n,r){let s=n,a="",l=r==="lower"?97:65;for(;s>0;)s-=1,a=String.fromCharCode(l+s%26)+a,s=Math.floor(s/26);return a}}return tf([p({type:String,attribute:"class"})],e.prototype,"class",null),e};var op=[P,W,q`
7113
7118
  :host {
7114
7119
  display: block;
7115
7120
  }
@@ -7329,7 +7334,7 @@ CES.load();
7329
7334
  height: 100%;
7330
7335
  border: 0;
7331
7336
  }
7332
- `];var bt=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},cp=5,nf=50,dp="qti-height-lines-",hp=!1,X=class extends D{constructor(){super(...arguments),this._rows=cp,this.format="plain",this._handleFormatChange=()=>{this.format!=="xhtml"||hp||(hp=!0,console.warn('<qti-extended-text-interaction format="xhtml"> renders as plain text. The interaction has no rich-text editor; the recorded response will contain no markup.'))},this.minStrings=0,this.response=null,this._handleResponseChange=()=>{this._internals.setFormValue(this.value),this.validate()}}static{this.styles=lp}_handleRowsInputChange(){this._rows=this.#t()}#t(){let t=this.#e();return t!==null?t:this.expectedLines>0?this.expectedLines:this.expectedLength>0?Math.ceil(this.expectedLength/nf):cp}#e(){for(let t of(this.classNames??"").split(" ")){if(!t.startsWith(dp))continue;let e=parseInt(t.slice(dp.length),10);if(!Number.isNaN(e)&&e>0)return e}return null}get value(){return this.response||null}set value(t){this.response=t||null}validate(){let t=this.shadowRoot.querySelector("textarea");if(!t)return!1;let e="",i=!1;if(this.patternMask&&this.dataPatternmaskMessage){t.setCustomValidity("");let n=this.patternMask.startsWith("^")&&this.patternMask.endsWith("$")?this.patternMask:`^${this.patternMask}$`,r=new RegExp(n);i=t.checkValidity()&&r.test(t.value),i||(e=this.dataPatternmaskMessage,t.setCustomValidity(this.dataPatternmaskMessage))}else i=t.checkValidity();return i&&!this.response&&this.minStrings>=1&&(i=!1),!i&&!e&&(e=t.validationMessage||"Invalid value."),this.setInteractionValidity(i,e,t,{suppressInline:!0}),i}reportValidity(){return this.validate(),super.reportValidity()}renderPrompt(){return b`<slot name="prompt"></slot>`}renderTextarea(){return b`<textarea
7337
+ `];var bt=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},cp=5,nf=50,dp="qti-height-lines-",hp=!1,G=class extends D{constructor(){super(...arguments),this._rows=cp,this.format="plain",this._handleFormatChange=()=>{this.format!=="xhtml"||hp||(hp=!0,console.warn('<qti-extended-text-interaction format="xhtml"> renders as plain text. The interaction has no rich-text editor; the recorded response will contain no markup.'))},this.minStrings=0,this.response=null,this._handleResponseChange=()=>{this._internals.setFormValue(this.value),this.validate()}}static{this.styles=lp}_handleRowsInputChange(){this._rows=this.#t()}#t(){let t=this.#e();return t!==null?t:this.expectedLines>0?this.expectedLines:this.expectedLength>0?Math.ceil(this.expectedLength/nf):cp}#e(){for(let t of(this.classNames??"").split(" ")){if(!t.startsWith(dp))continue;let e=parseInt(t.slice(dp.length),10);if(!Number.isNaN(e)&&e>0)return e}return null}get value(){return this.response||null}set value(t){this.response=t||null}validate(){let t=this.shadowRoot.querySelector("textarea");if(!t)return!1;let e="",i=!1;if(this.patternMask&&this.dataPatternmaskMessage){t.setCustomValidity("");let n=this.patternMask.startsWith("^")&&this.patternMask.endsWith("$")?this.patternMask:`^${this.patternMask}$`,r=new RegExp(n);i=t.checkValidity()&&r.test(t.value),i||(e=this.dataPatternmaskMessage,t.setCustomValidity(this.dataPatternmaskMessage))}else i=t.checkValidity();return i&&!this.response&&this.minStrings>=1&&(i=!1),!i&&!e&&(e=t.validationMessage||"Invalid value."),this.setInteractionValidity(i,e,t,{suppressInline:!0}),i}reportValidity(){return this.validate(),super.reportValidity()}renderPrompt(){return b`<slot name="prompt"></slot>`}renderTextarea(){return b`<textarea
7333
7338
  part="textarea"
7334
7339
  name="${this.responseIdentifier}"
7335
7340
  spellcheck="false"
@@ -7344,7 +7349,7 @@ CES.load();
7344
7349
  ?disabled="${this.disabled}"
7345
7350
  ?readonly="${this.readonly}"
7346
7351
  .value=${this.response}
7347
- ></textarea>`}renderValidationMessage(){return b`<div id="validation-message" part="message" role="alert" style="display:none;"></div>`}render(){return b`${this.renderPrompt()}${this.renderTextarea()} ${this.renderValidationMessage()}`}textChanged(t){if(this.disabled||this.readonly)return;let e=t.target;this.response!==e.value&&(this.value=e.value,this.saveResponse(e.value))}};bt([T()],X.prototype,"_rows",void 0);bt([p({type:Number,attribute:"expected-length"})],X.prototype,"expectedLength",void 0);bt([p({type:Number,attribute:"expected-lines"})],X.prototype,"expectedLines",void 0);bt([p({type:String,reflect:!0})],X.prototype,"format",void 0);bt([L("format")],X.prototype,"_handleFormatChange",void 0);bt([p({type:Number,attribute:"min-strings"})],X.prototype,"minStrings",void 0);bt([p({type:String,attribute:"pattern-mask"})],X.prototype,"patternMask",void 0);bt([p({type:String,attribute:"placeholder-text"})],X.prototype,"placeholderText",void 0);bt([p({type:String,attribute:"data-patternmask-message"})],X.prototype,"dataPatternmaskMessage",void 0);bt([p({type:String,attribute:"class"})],X.prototype,"classNames",void 0);bt([L(["classNames","expectedLines","expectedLength"])],X.prototype,"_handleRowsInputChange",null);bt([p({type:String,attribute:"response",reflect:!1})],X.prototype,"response",void 0);bt([L("response",{waitUntilFirstUpdate:!0})],X.prototype,"_handleResponseChange",void 0);var rs=[{tag:"qti-extended-text-interaction",ctor:X}];var pp=[P,W,q`
7352
+ ></textarea>`}renderValidationMessage(){return b`<div id="validation-message" part="message" role="alert" style="display:none;"></div>`}render(){return b`${this.renderPrompt()}${this.renderTextarea()} ${this.renderValidationMessage()}`}textChanged(t){if(this.disabled||this.readonly)return;let e=t.target;this.response!==e.value&&(this.value=e.value,this.saveResponse(e.value))}};bt([T()],G.prototype,"_rows",void 0);bt([p({type:Number,attribute:"expected-length"})],G.prototype,"expectedLength",void 0);bt([p({type:Number,attribute:"expected-lines"})],G.prototype,"expectedLines",void 0);bt([p({type:String,reflect:!0})],G.prototype,"format",void 0);bt([L("format")],G.prototype,"_handleFormatChange",void 0);bt([p({type:Number,attribute:"min-strings"})],G.prototype,"minStrings",void 0);bt([p({type:String,attribute:"pattern-mask"})],G.prototype,"patternMask",void 0);bt([p({type:String,attribute:"placeholder-text"})],G.prototype,"placeholderText",void 0);bt([p({type:String,attribute:"data-patternmask-message"})],G.prototype,"dataPatternmaskMessage",void 0);bt([p({type:String,attribute:"class"})],G.prototype,"classNames",void 0);bt([L(["classNames","expectedLines","expectedLength"])],G.prototype,"_handleRowsInputChange",null);bt([p({type:String,attribute:"response",reflect:!1})],G.prototype,"response",void 0);bt([L("response",{waitUntilFirstUpdate:!0})],G.prototype,"_handleResponseChange",void 0);var rs=[{tag:"qti-extended-text-interaction",ctor:G}];var pp=[P,W,q`
7348
7353
  :host {
7349
7354
  display: flex;
7350
7355
  align-items: flex-start;
@@ -7388,10 +7393,10 @@ CES.load();
7388
7393
  :host([answer-key]) [part~='drags'] {
7389
7394
  display: none;
7390
7395
  }
7391
- `];var tr=class extends jt(zt(D,"qti-gap-text","qti-gap","slot[part~='drags']"),'[qti-draggable="true"]'){static{this.styles=pp}render(){return b`<slot name="prompt"> </slot>
7396
+ `];var er=class extends jt(zt(D,"qti-gap-text","qti-gap","slot[part~='drags']"),'[qti-draggable="true"]'){static{this.styles=pp}render(){return b`<slot name="prompt"> </slot>
7392
7397
  <slot part="drags" name="drags"></slot>
7393
7398
  <slot part="drops"></slot>
7394
- <div role="alert" part="message" id="validation-message"></div>`}};var ns=[{tag:"qti-gap-match-interaction",ctor:tr}];function gp(o){return o.querySelector('img, object[type^="image"]')}function up(o,t){let e=o.getAttribute(t)?.trim();if(!e||e.endsWith("%"))return null;let i=parseFloat(e);return Number.isFinite(i)&&i>0?i:null}var bp=new WeakMap,mp=new WeakMap;function of(o){let t=mp.get(o);return t||(t=new Promise(e=>{let i=o.data;if(!i){e(null);return}let n=new Image;n.onload=()=>{let r={width:n.naturalWidth,height:n.naturalHeight};if(!(r.width>0)||!(r.height>0)){e(null);return}bp.set(o,r),e(r)},n.onerror=()=>e(null),n.src=i}),mp.set(o,t)),t}function sf(o){if(o.localName==="object")return bp.get(o)??null;let t=o;return t.naturalWidth>0&&t.naturalHeight>0?{width:t.naturalWidth,height:t.naturalHeight}:null}function os(o){let t=up(o,"width"),e=up(o,"height");if(t!==null&&e!==null)return{width:t,height:e};let i=sf(o);return i?{width:t??i.width,height:e??i.height}:null}function af(o){let t=os(o);if(t)return Promise.resolve(t);if(o.localName==="object")return of(o).then(()=>os(o));let e=o;return e.complete?Promise.resolve(null):new Promise(i=>{let n=()=>{e.removeEventListener("load",n),e.removeEventListener("error",n),i(os(o))};e.addEventListener("load",n),e.addEventListener("error",n)})}function Kt(o,t,e,i){let n=os(e);if(n){fp(o,t,n,i);return}af(e).then(r=>{if(!r){console.error("Cannot position hotspots: the graphic has no usable width/height.",e);return}fp(o,t,r,i)})}function fp(o,t,{width:e,height:i},n){switch(o){case"circle":{if(t.length!==3){console.error("Invalid circle coordinates:",t);return}let[r,s,a]=t,l=r/e*100,c=s/i*100,d=a/e*100,h=a/i*100;n.style.left=l-d+"%",n.style.top=c-h+"%",n.style.width=2*d+"%",n.style.height=2*h+"%",n.style.borderRadius="50%"}break;case"rect":{if(t.length!==4){console.error("Invalid rectangle coordinates:",t);return}let[r,s,a,l]=t,c=r/e*100,d=s/i*100,h=a/e*100,f=l/i*100;n.style.left=c+"%",n.style.top=d+"%",n.style.width=h-c+"%",n.style.height=f-d+"%"}break;case"ellipse":{if(t.length!==4){console.error("Invalid ellipse coordinates:",t);return}let[r,s,a,l]=t,c=r/e*100,d=s/i*100,h=a/e*100,f=l/i*100;n.style.left=c-h+"%",n.style.top=d-f+"%",n.style.width=2*h+"%",n.style.height=2*f+"%",n.style.borderRadius="50%"}break;case"poly":{if(t.length<6||t.length%2!==0){console.error("Invalid polygon coordinates:",t);return}let r=[];for(let y=0;y<t.length;y+=2)r.push({x:t[y],y:t[y+1]});let s=Math.min(...r.map(y=>y.x)),a=Math.max(...r.map(y=>y.x)),l=Math.min(...r.map(y=>y.y)),c=Math.max(...r.map(y=>y.y)),d=s/e*100,h=l/i*100,f=a/e*100,m=c/i*100;n.style.left=d+"%",n.style.top=h+"%",n.style.width=f-d+"%",n.style.height=m-h+"%";let v=r.map(y=>({x:(y.x-s)/(a-s)*100,y:(y.y-l)/(c-l)*100})),x=v.map(y=>`${y.x}% ${y.y}%`).join(",");n.style.clipPath=`polygon(${x})`;let u=v.map(y=>`${y.x},${y.y}`).join(" "),g=y=>`url("data:image/svg+xml,${encodeURIComponent(`<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' preserveAspectRatio='none'><polygon points='${u}' fill='none' stroke='black' stroke-width='${y}' vector-effect='non-scaling-stroke' stroke-linejoin='round'/></svg>`)}")`;n.style.setProperty("--qti-shape-outline",g(4)),n.style.setProperty("--qti-shape-outline-bold",g(8))}break;case"default":n.style.left="0%",n.style.top="0%",n.style.width="100%",n.style.height="100%";break;default:console.error(`Unsupported shape: ${o}`);break}}var yp=[P,W,q`
7399
+ <div role="alert" part="message" id="validation-message"></div>`}};var ns=[{tag:"qti-gap-match-interaction",ctor:er}];function gp(o){return o.querySelector('img, object[type^="image"]')}function up(o,t){let e=o.getAttribute(t)?.trim();if(!e||e.endsWith("%"))return null;let i=parseFloat(e);return Number.isFinite(i)&&i>0?i:null}var bp=new WeakMap,mp=new WeakMap;function of(o){let t=mp.get(o);return t||(t=new Promise(e=>{let i=o.data;if(!i){e(null);return}let n=new Image;n.onload=()=>{let r={width:n.naturalWidth,height:n.naturalHeight};if(!(r.width>0)||!(r.height>0)){e(null);return}bp.set(o,r),e(r)},n.onerror=()=>e(null),n.src=i}),mp.set(o,t)),t}function sf(o){if(o.localName==="object")return bp.get(o)??null;let t=o;return t.naturalWidth>0&&t.naturalHeight>0?{width:t.naturalWidth,height:t.naturalHeight}:null}function os(o){let t=up(o,"width"),e=up(o,"height");if(t!==null&&e!==null)return{width:t,height:e};let i=sf(o);return i?{width:t??i.width,height:e??i.height}:null}function af(o){let t=os(o);if(t)return Promise.resolve(t);if(o.localName==="object")return of(o).then(()=>os(o));let e=o;return e.complete?Promise.resolve(null):new Promise(i=>{let n=()=>{e.removeEventListener("load",n),e.removeEventListener("error",n),i(os(o))};e.addEventListener("load",n),e.addEventListener("error",n)})}function Kt(o,t,e,i){let n=os(e);if(n){fp(o,t,n,i);return}af(e).then(r=>{if(!r){console.error("Cannot position hotspots: the graphic has no usable width/height.",e);return}fp(o,t,r,i)})}function fp(o,t,{width:e,height:i},n){switch(o){case"circle":{if(t.length!==3){console.error("Invalid circle coordinates:",t);return}let[r,s,a]=t,l=r/e*100,c=s/i*100,d=a/e*100,h=a/i*100;n.style.left=l-d+"%",n.style.top=c-h+"%",n.style.width=2*d+"%",n.style.height=2*h+"%",n.style.borderRadius="50%"}break;case"rect":{if(t.length!==4){console.error("Invalid rectangle coordinates:",t);return}let[r,s,a,l]=t,c=r/e*100,d=s/i*100,h=a/e*100,f=l/i*100;n.style.left=c+"%",n.style.top=d+"%",n.style.width=h-c+"%",n.style.height=f-d+"%"}break;case"ellipse":{if(t.length!==4){console.error("Invalid ellipse coordinates:",t);return}let[r,s,a,l]=t,c=r/e*100,d=s/i*100,h=a/e*100,f=l/i*100;n.style.left=c-h+"%",n.style.top=d-f+"%",n.style.width=2*h+"%",n.style.height=2*f+"%",n.style.borderRadius="50%"}break;case"poly":{if(t.length<6||t.length%2!==0){console.error("Invalid polygon coordinates:",t);return}let r=[];for(let y=0;y<t.length;y+=2)r.push({x:t[y],y:t[y+1]});let s=Math.min(...r.map(y=>y.x)),a=Math.max(...r.map(y=>y.x)),l=Math.min(...r.map(y=>y.y)),c=Math.max(...r.map(y=>y.y)),d=s/e*100,h=l/i*100,f=a/e*100,m=c/i*100;n.style.left=d+"%",n.style.top=h+"%",n.style.width=f-d+"%",n.style.height=m-h+"%";let v=r.map(y=>({x:(y.x-s)/(a-s)*100,y:(y.y-l)/(c-l)*100})),x=v.map(y=>`${y.x}% ${y.y}%`).join(",");n.style.clipPath=`polygon(${x})`;let u=v.map(y=>`${y.x},${y.y}`).join(" "),g=y=>`url("data:image/svg+xml,${encodeURIComponent(`<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' preserveAspectRatio='none'><polygon points='${u}' fill='none' stroke='black' stroke-width='${y}' vector-effect='non-scaling-stroke' stroke-linejoin='round'/></svg>`)}")`;n.style.setProperty("--qti-shape-outline",g(4)),n.style.setProperty("--qti-shape-outline-bold",g(8))}break;case"default":n.style.left="0%",n.style.top="0%",n.style.width="100%",n.style.height="100%";break;default:console.error(`Unsupported shape: ${o}`);break}}var yp=[P,W,q`
7395
7400
  /* Containing block for the absolutely positioned hotspots over the image. Was on this host in
7396
7401
  the theme, together with a 'display: block' this component now owns. */
7397
7402
  :host {
@@ -7453,7 +7458,7 @@ CES.load();
7453
7458
  </svg>
7454
7459
  <slot></slot>
7455
7460
  </line-container>
7456
- <div role="alert" part="message" id="validation-message"></div>`}#o(t){let e=this.querySelector("img"),i=t.target,n=i.getAttribute("coords"),r=i.getAttribute("shape"),s=n.split(",").map(a=>parseInt(a));Kt(r,s,e,i)}firstUpdated(){super.firstUpdated(),this.#t=Array.from(this.querySelectorAll("qti-associable-hotspot")),this.addEventListener("mousemove",t=>{let e=this.grImage[0];if(!e)return;let i=e.getBoundingClientRect();this.mouseCoord={x:t.clientX-i.left,y:t.clientY-i.top}}),this.#t.forEach(t=>{t.style.left=t.getAttribute("coords").split(",")[0]+"px",t.style.top=t.getAttribute("coords").split(",")[1]+"px",t.addEventListener("click",e=>{this.#e?this.#i||(this.#i=e.target,this._response=this.#n(),this._response=[...this._response,`${this.#e.getAttribute("identifier")} ${this.#i.getAttribute("identifier")}`],this.saveResponse(this.response),this.#e=null,this.#i=null):(this.#e=e.target,this.startCoord={x:parseInt(this.#e.getAttribute("coords").split(",")[0]),y:parseInt(this.#e.getAttribute("coords").split(",")[1])})})})}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-register-hotspot",this.#o)}};fn([T()],Ft.prototype,"startCoord",void 0);fn([T()],Ft.prototype,"mouseCoord",void 0);fn([Xc({selector:"img"})],Ft.prototype,"grImage",void 0);fn([T()],Ft.prototype,"_response",void 0);fn([p({attribute:"response",reflect:!1,noAccessor:!0,converter:Xt({emptyAs:[]})})],Ft.prototype,"response",null);var ss=[{tag:"qti-graphic-associate-interaction",ctor:Ft}];var vp=[P,W,q`
7461
+ <div role="alert" part="message" id="validation-message"></div>`}#o(t){let e=this.querySelector("img"),i=t.target,n=i.getAttribute("coords"),r=i.getAttribute("shape"),s=n.split(",").map(a=>parseInt(a));Kt(r,s,e,i)}firstUpdated(){super.firstUpdated(),this.#t=Array.from(this.querySelectorAll("qti-associable-hotspot")),this.addEventListener("mousemove",t=>{let e=this.grImage[0];if(!e)return;let i=e.getBoundingClientRect();this.mouseCoord={x:t.clientX-i.left,y:t.clientY-i.top}}),this.#t.forEach(t=>{t.style.left=t.getAttribute("coords").split(",")[0]+"px",t.style.top=t.getAttribute("coords").split(",")[1]+"px",t.addEventListener("click",e=>{this.#e?this.#i||(this.#i=e.target,this._response=this.#n(),this._response=[...this._response,`${this.#e.getAttribute("identifier")} ${this.#i.getAttribute("identifier")}`],this.saveResponse(this.response),this.#e=null,this.#i=null):(this.#e=e.target,this.startCoord={x:parseInt(this.#e.getAttribute("coords").split(",")[0]),y:parseInt(this.#e.getAttribute("coords").split(",")[1])})})})}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-register-hotspot",this.#o)}};fn([T()],Ft.prototype,"startCoord",void 0);fn([T()],Ft.prototype,"mouseCoord",void 0);fn([Gc({selector:"img"})],Ft.prototype,"grImage",void 0);fn([T()],Ft.prototype,"_response",void 0);fn([p({attribute:"response",reflect:!1,noAccessor:!0,converter:Gt({emptyAs:[]})})],Ft.prototype,"response",null);var ss=[{tag:"qti-graphic-associate-interaction",ctor:Ft}];var vp=[P,W,q`
7457
7462
  :host {
7458
7463
  display: flex;
7459
7464
  align-items: flex-start;
@@ -7538,10 +7543,10 @@ CES.load();
7538
7543
  user-select: none;
7539
7544
  pointer-events: none;
7540
7545
  }
7541
- `];var lf=zt(D,"qti-gap-img, qti-gap-text","qti-associable-hotspot","slot[part~='drags']"),er=class extends jt(lf,'[qti-draggable="true"]'){static{this.styles=vp}render(){return b` <slot name="prompt"></slot>
7542
- <slot part="image"></slot>
7543
- <slot part="drags" name="drags" class="hover-border"></slot>
7544
- <div role="alert" part="message" id="validation-message"></div>`}shouldReturnToInventoryOnInventoryDrop(){return!0}#t(){return this.querySelector(':scope > img, :scope > object[type^="image"]')}#e(t){if(t.style.aspectRatio)return;let e=r=>{let s=(t.getAttribute(r)??"").trim(),a=parseFloat(s);return s.endsWith("%")||!(a>0)?null:a},i=e("width"),n=e("height");i&&n&&(t.style.aspectRatio=`${i} / ${n}`)}#i(t){let e=this.#t(),i=t.getAttribute("coords"),n=t.getAttribute("shape");!e||!i||!n||(this.#e(e),Kt(n,i.split(",").map(r=>parseFloat(r)),e,t))}#r=t=>{this.#i(t.target)};connectedCallback(){super.connectedCallback(),this.addEventListener("qti-register-hotspot",this.#r),this.querySelectorAll(":scope > qti-associable-hotspot").forEach(t=>this.#i(t))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-register-hotspot",this.#r)}};var as=[{tag:"qti-graphic-gap-match-interaction",ctor:er}];var wp=[P,W,q`
7546
+ `];var lf=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},cf=zt(D,"qti-gap-img, qti-gap-text","qti-associable-hotspot","slot[part~='drags']"),qi=class extends jt(cf,'[qti-draggable="true"]'){constructor(){super(...arguments),this.autoSizeDropzones=!1,this._graphicScale=1,this.#t=null,this.#e=null,this.#s=t=>{this.#n(t.target)}}static{this.styles=vp}#t;#e;render(){let t=`--qti-graphic-scale: ${this._graphicScale}`;return b` <slot name="prompt"></slot>
7547
+ <slot part="image" style=${t}></slot>
7548
+ <slot part="drags" name="drags" class="hover-border" style=${t}></slot>
7549
+ <div role="alert" part="message" id="validation-message"></div>`}shouldReturnToInventoryOnInventoryDrop(){return!0}#i(){return this.querySelector(':scope > img, :scope > object[type^="image"]')}#r(t){if(t.style.aspectRatio)return;let e=r=>{let s=(t.getAttribute(r)??"").trim(),a=parseFloat(s);return s.endsWith("%")||!(a>0)?null:a},i=e("width"),n=e("height");i&&n&&(t.style.aspectRatio=`${i} / ${n}`)}#n(t){let e=this.#i(),i=t.getAttribute("coords"),n=t.getAttribute("shape");!e||!i||!n||(this.#r(e),this.#o(e),Kt(n,i.split(",").map(r=>parseFloat(r)),e,t))}#o(t){this.#e!==t&&(this.#t?.disconnect(),this.#e=t,this.#t=new ResizeObserver(()=>{let e=parseFloat(t.getAttribute("width")??""),i=t.getBoundingClientRect().width,n=e>0&&i>0?Math.min(1,i/e):1,r=Math.round(n*1e3)/1e3;r!==this._graphicScale&&(this._graphicScale=r)}),this.#t.observe(t))}#s;connectedCallback(){super.connectedCallback(),this.addEventListener("qti-register-hotspot",this.#s),this.querySelectorAll(":scope > qti-associable-hotspot").forEach(t=>this.#n(t))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("qti-register-hotspot",this.#s),this.#t?.disconnect(),this.#t=null,this.#e=null}};lf([T()],qi.prototype,"_graphicScale",void 0);var as=[{tag:"qti-graphic-gap-match-interaction",ctor:qi}];var wp=[P,W,q`
7545
7550
  /* The order pins are anchored outside their hotspot's box. */
7546
7551
  :host {
7547
7552
  /* The box this element already had. See the note in qti-match-interaction.styles.ts. */
@@ -7642,7 +7647,7 @@ CES.load();
7642
7647
  display: block;
7643
7648
  }
7644
7649
  `];var rr=class extends Be(D,"qti-hottext"){constructor(){super(...arguments),this.render=()=>b`<slot></slot>
7645
- <div part="message" role="alert" id="validation-message"></div>`}static{this.styles=Cp}};var ds=[{tag:"qti-hottext-interaction",ctor:rr}];var Fl=(o,t="[part='menu']",e="[part='trigger']",i="--qti-inline-choice-width")=>{class n extends o{#t=null;#e=null;#i=null;#r=0;#n=null;shouldAutoSizeMenu(){return!1}menuAutoSizeExtraWidth(){return 0}menuAutoSizePropertyTarget(){return this.renderRoot?.querySelector(e)??null}menuAutoSizeRows(){let s=this.renderRoot?.querySelector(t);return s?Array.from(s.children).flatMap(a=>a instanceof HTMLSlotElement?a.assignedElements().filter(l=>l instanceof HTMLElement):a instanceof HTMLElement?[a]:[]):[]}withMenuMeasurable(s){let a=this.renderRoot?.querySelector(t);if(!a)return s();let l=a.matches(":popover-open"),c=a.style.visibility,d=a.style.display;l||(a.style.visibility="hidden",a.style.display="block",a.showPopover?.());try{return s()}finally{l||(a.hidePopover?.(),a.style.visibility=c,a.style.display=d)}}updateMenuWidth(){if(!this.isConnected||!this.shouldAutoSizeMenu())return;let s=this.menuAutoSizePropertyTarget();if(!s)return;let a=this.renderRoot?.querySelector(t);a&&this.#c(a),this.#s();let l=this.#o()+this.menuAutoSizeExtraWidth();l<=0||l===this.#n||(this.#n=l,s.style.setProperty(i,`${l}px`))}#o(){return this.withMenuMeasurable(()=>{let s=0;for(let c of this.menuAutoSizeRows()){let d=c.style.width;c.style.width="max-content",s=Math.max(s,c.getBoundingClientRect().width),c.style.width=d}if(s<=0)return 0;let a=this.renderRoot?.querySelector(t);if(!a)return s;let l=getComputedStyle(a);return s+parseFloat(l.paddingLeft)+parseFloat(l.paddingRight)+parseFloat(l.borderLeftWidth)+parseFloat(l.borderRightWidth)})}#s(){typeof MutationObserver>"u"||this.#i||(this.#i=new MutationObserver(()=>this.#a()),this.#i.observe(this,{childList:!0,subtree:!0,characterData:!0}))}#a(){this.#r||(this.#r=requestAnimationFrame(()=>{this.#r=0,this.updateMenuWidth()}))}#c(s){typeof ResizeObserver>"u"||this.#e===s||(this.#t??=new ResizeObserver(()=>{this.#e?.matches(":popover-open")&&this.#a()}),this.#e&&this.#t.unobserve(this.#e),this.#t.observe(s),this.#e=s)}disconnectedCallback(){this.#t?.disconnect(),this.#t=null,this.#e=null,this.#i?.disconnect(),this.#i=null,this.#r&&cancelAnimationFrame(this.#r),this.#r=0,super.disconnectedCallback()}}return n};var cf=q`
7650
+ <div part="message" role="alert" id="validation-message"></div>`}static{this.styles=Cp}};var ds=[{tag:"qti-hottext-interaction",ctor:rr}];var Fl=(o,t="[part='menu']",e="[part='trigger']",i="--qti-inline-choice-width")=>{class n extends o{#t=null;#e=null;#i=null;#r=0;#n=null;shouldAutoSizeMenu(){return!1}menuAutoSizeExtraWidth(){return 0}menuAutoSizePropertyTarget(){return this.renderRoot?.querySelector(e)??null}menuAutoSizeRows(){let s=this.renderRoot?.querySelector(t);return s?Array.from(s.children).flatMap(a=>a instanceof HTMLSlotElement?a.assignedElements().filter(l=>l instanceof HTMLElement):a instanceof HTMLElement?[a]:[]):[]}withMenuMeasurable(s){let a=this.renderRoot?.querySelector(t);if(!a)return s();let l=a.matches(":popover-open"),c=a.style.visibility,d=a.style.display;l||(a.style.visibility="hidden",a.style.display="block",a.showPopover?.());try{return s()}finally{l||(a.hidePopover?.(),a.style.visibility=c,a.style.display=d)}}updateMenuWidth(){if(!this.isConnected||!this.shouldAutoSizeMenu())return;let s=this.menuAutoSizePropertyTarget();if(!s)return;let a=this.renderRoot?.querySelector(t);a&&this.#c(a),this.#s();let l=this.#o()+this.menuAutoSizeExtraWidth();l<=0||l===this.#n||(this.#n=l,s.style.setProperty(i,`${l}px`))}#o(){return this.withMenuMeasurable(()=>{let s=0;for(let c of this.menuAutoSizeRows()){let d=c.style.width;c.style.width="max-content",s=Math.max(s,c.getBoundingClientRect().width),c.style.width=d}if(s<=0)return 0;let a=this.renderRoot?.querySelector(t);if(!a)return s;let l=getComputedStyle(a);return s+parseFloat(l.paddingLeft)+parseFloat(l.paddingRight)+parseFloat(l.borderLeftWidth)+parseFloat(l.borderRightWidth)})}#s(){typeof MutationObserver>"u"||this.#i||(this.#i=new MutationObserver(()=>this.#a()),this.#i.observe(this,{childList:!0,subtree:!0,characterData:!0}))}#a(){this.#r||(this.#r=requestAnimationFrame(()=>{this.#r=0,this.updateMenuWidth()}))}#c(s){typeof ResizeObserver>"u"||this.#e===s||(this.#t??=new ResizeObserver(()=>{this.#e?.matches(":popover-open")&&this.#a()}),this.#e&&this.#t.unobserve(this.#e),this.#t.observe(s),this.#e=s)}disconnectedCallback(){this.#t?.disconnect(),this.#t=null,this.#e=null,this.#i?.disconnect(),this.#i=null,this.#r&&cancelAnimationFrame(this.#r),this.#r=0,super.disconnectedCallback()}}return n};var df=q`
7646
7651
  /* ── Host ──────────────────────────────────────────────────────────────────
7647
7652
  Inline-block so the element flows with surrounding text.
7648
7653
  --qti-inline-choice-width is the single width control surface:
@@ -7823,7 +7828,7 @@ CES.load();
7823
7828
  z-index: var(--qti-overlay-z-index);
7824
7829
  white-space: nowrap;
7825
7830
  }
7826
- `,df=cf,kp=df;var ue=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},hf=0,ct=class extends Fl(D){constructor(){super(),this.options=[],this._dropdownOpen=!1,this._slotObserver=null,this._menuId=`qti-inline-choice-menu-${hf++}`,this._handleDataPromptChange=()=>{this.#e()},this.required=!1,this.minChoices=0,this._handleRequiredChange=()=>{this.validate(),this.reportValidity()},this._pendingResponse=void 0,this.#n=t=>{(this.disabled||this.readonly)&&t.preventDefault()},this.#o=t=>{this.disabled||this.readonly||(t.key==="ArrowDown"||t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this.#r(!0))},this.#s=t=>{let i=t.newState==="open";this._dropdownOpen!==i&&(this._dropdownOpen=i),i?this._internals.states.add("open"):this._internals.states.delete("open")},this.#a=t=>{if(!this._dropdownOpen)return;if(t.key==="Escape"){t.preventDefault(),this.#r(!1),this.#c();return}let e=this.#y(),i=this.renderRoot.activeElement,n=this.#p(),r=i||(n instanceof HTMLElement&&this.#l(n)?n:null),s=e.findIndex(a=>a===r);if(t.key==="ArrowDown"&&(t.preventDefault(),e[Math.min(e.length-1,Math.max(0,s+1))]?.focus()),t.key==="ArrowUp"&&(t.preventDefault(),e[Math.max(0,s-1)]?.focus()),t.key==="Enter"||t.key===" "){if(!r)return;if(t.preventDefault(),r instanceof HTMLButtonElement)r.click();else{let a=r.getAttribute("identifier")??"";this.#i(a)}}},this.#u=()=>{this.#e()},this.#h=t=>{if(this.disabled||this.readonly)return;let i=t.currentTarget.getAttribute("identifier")??"";this.#i(i)},this.internals.role="listbox"}get isInline(){return!0}static get styles(){return[kp]}renderTrigger(){let t=this.#t();return b`
7831
+ `,hf=df,Sp=hf;var ue=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},pf=0,ct=class extends Fl(D){constructor(){super(),this.options=[],this._dropdownOpen=!1,this._slotObserver=null,this._menuId=`qti-inline-choice-menu-${pf++}`,this._handleDataPromptChange=()=>{this.#e()},this.required=!1,this.minChoices=0,this._handleRequiredChange=()=>{this.validate(),this.reportValidity()},this._pendingResponse=void 0,this.#n=t=>{(this.disabled||this.readonly)&&t.preventDefault()},this.#o=t=>{this.disabled||this.readonly||(t.key==="ArrowDown"||t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this.#r(!0))},this.#s=t=>{let i=t.newState==="open";this._dropdownOpen!==i&&(this._dropdownOpen=i),i?this._internals.states.add("open"):this._internals.states.delete("open")},this.#a=t=>{if(!this._dropdownOpen)return;if(t.key==="Escape"){t.preventDefault(),this.#r(!1),this.#c();return}let e=this.#y(),i=this.renderRoot.activeElement,n=this.#p(),r=i||(n instanceof HTMLElement&&this.#l(n)?n:null),s=e.findIndex(a=>a===r);if(t.key==="ArrowDown"&&(t.preventDefault(),e[Math.min(e.length-1,Math.max(0,s+1))]?.focus()),t.key==="ArrowUp"&&(t.preventDefault(),e[Math.max(0,s-1)]?.focus()),t.key==="Enter"||t.key===" "){if(!r)return;if(t.preventDefault(),r instanceof HTMLButtonElement)r.click();else{let a=r.getAttribute("identifier")??"";this.#i(a)}}},this.#u=()=>{this.#e()},this.#h=t=>{if(this.disabled||this.readonly)return;let i=t.currentTarget.getAttribute("identifier")??"";this.#i(i)},this.internals.role="listbox"}get isInline(){return!0}static get styles(){return[Sp]}renderTrigger(){let t=this.#t();return b`
7827
7832
  <button
7828
7833
  part="trigger"
7829
7834
  type="button"
@@ -7863,7 +7868,7 @@ CES.load();
7863
7868
  </button>
7864
7869
  <slot @slotchange=${this.#u}></slot>
7865
7870
  </div>
7866
- `}renderValidationMessage(){return b`<div id="validation-message" part="message" role="alert" style="display:none;"></div>`}render(){return b` ${this.renderTrigger()} ${this.renderMenu()} ${this.renderValidationMessage()} `}async connectedCallback(){super.connectedCallback(),this.#e(),this.#d(),await this.updateComplete,this.isConnected&&this.updateMenuWidth()}disconnectedCallback(){super.disconnectedCallback(),this.#b(),this._slotObserver?.disconnect(),this._slotObserver=null}willUpdate(t){t.has("configContext")&&this.#e()}updated(t){t.has("_dropdownOpen")&&this._dropdownOpen&&(this.#f(),this.#y()[0]?.focus()),(t.has("disabled")||t.has("readonly"))&&this.#f()}#t(){return this.options.find(t=>t.selected)??this.options[0]}#e(){let t=Array.from(this.querySelectorAll("qti-inline-choice")),e=this.dataPrompt||this.configContext?.inlineChoicePrompt||"select",i=this._pendingResponse,n=i!==void 0?i??"":this.options.find(a=>a.selected)?.value??"",r=[{content:e,value:"",selected:n===""},...t.map(a=>{let l=a.getAttribute("identifier")??"";return{content:Array.from(a.childNodes).map(c=>c.cloneNode(!0)),value:l,selected:l!==""&&l===n}})],s=r.some(a=>a.selected);this.options=s?r:r.map((a,l)=>({...a,selected:l===0})),this._pendingResponse=void 0,this.#f(),this.updateMenuWidth()}shouldAutoSizeMenu(){return this.configContext?.inlineChoiceAutosize?!Array.from(this.classList).some(t=>t.startsWith("qti-input-width-")):!1}menuAutoSizeExtraWidth(){return this.renderRoot.querySelector('span[part~="dropdown-icon"]')?.offsetWidth??0}validate(){let t=this.options.find(s=>s.selected),e=t?t.value!=="":!1,i=this.required||this.minChoices>=1,n=e||!i,r=this.dataset.minChoicesMessage||"Please select an option.";return this.setInteractionValidity(n,n?"":r,this,{suppressInline:!0}),n}reportValidity(){return super.reportValidity()}reset(){this.#r(!1),this.options=this.options.map((t,e)=>({...t,selected:e===0})),this.#f()}set response(t){let e=t??"";if(this.options.length===0){this._pendingResponse=t;return}this.options=this.options.map(i=>({...i,selected:i.value===e})),this.#f()}get response(){let t=this.options.find(e=>e.selected)?.value??"";return t===""?null:t}#i(t){this.options=this.options.map(e=>({...e,selected:e.value===t})),this.#f(),this.validate(),this.reportValidity(),this.saveResponse(t),this.#r(!1)}#r(t){let e=this.#m();if(e){if(t){e.matches(":popover-open")||e.showPopover();return}e.matches(":popover-open")&&e.hidePopover()}}#n;#o;#s;#a;#c(){this.renderRoot.querySelector('button[part="trigger"]')?.focus()}#p(){let t=document.activeElement;for(;t&&t instanceof HTMLElement&&t.shadowRoot?.activeElement;)t=t.shadowRoot.activeElement;return t}#l(t){return t===this||this.contains(t)||this.renderRoot.contains(t)}#m(){return this.renderRoot.querySelector(`#${this._menuId}`)}#d(){this._slotObserver=new MutationObserver(()=>this.#e()),this._slotObserver.observe(this,{childList:!0,subtree:!0})}#u;#h;#b(){let t=Array.from(this.querySelectorAll("qti-inline-choice"));for(let e of t)e.removeEventListener("click",this.#h),e.removeAttribute("tabindex"),e.internals.role=null,e.internals.ariaSelected=null,e.internals.ariaChecked="false",e.internals.states.delete("checked")}async#f(){await this.updateComplete;let t=this.options.find(i=>i.selected)?.value??"",e=Array.from(this.querySelectorAll("qti-inline-choice"));for(let i of e){let r=(i.getAttribute("identifier")??"")===t;i.removeEventListener("click",this.#h),i.addEventListener("click",this.#h),i.disabled=this.disabled,i.readonly=this.readonly,i.internals.role="option",i.internals.ariaSelected=r?"true":"false",i.internals.ariaChecked=r?"true":"false",i.internals.ariaDisabled=this.disabled?"true":"false",i.internals.ariaReadOnly=this.readonly?"true":"false",r?i.internals.states.add("checked"):i.internals.states.delete("checked"),i.tabIndex=-1}}#y(){let t=this.renderRoot.querySelector('button[part~="option"]'),e=Array.from(this.querySelectorAll("qti-inline-choice"));return[...t?[t]:[],...e]}};ue([T()],ct.prototype,"options",void 0);ue([T()],ct.prototype,"_dropdownOpen",void 0);ue([_({context:xt,subscribe:!0}),p({attribute:!1})],ct.prototype,"configContext",void 0);ue([p({type:String,attribute:"data-prompt"})],ct.prototype,"dataPrompt",void 0);ue([L("dataPrompt",{waitUntilFirstUpdate:!0})],ct.prototype,"_handleDataPromptChange",void 0);ue([p({type:Boolean,reflect:!0,converter:{fromAttribute:o=>o==="true"||o==="",toAttribute:o=>o?"true":null}})],ct.prototype,"required",void 0);ue([p({type:Number,attribute:"min-choices"})],ct.prototype,"minChoices",void 0);ue([L(["required","minChoices"],{waitUntilFirstUpdate:!0})],ct.prototype,"_handleRequiredChange",void 0);ue([p({attribute:"response",reflect:!1,noAccessor:!0})],ct.prototype,"response",null);var hs=[{tag:"qti-inline-choice-interaction",ctor:ct}];var Sp=[P,W,q`
7871
+ `}renderValidationMessage(){return b`<div id="validation-message" part="message" role="alert" style="display:none;"></div>`}render(){return b` ${this.renderTrigger()} ${this.renderMenu()} ${this.renderValidationMessage()} `}async connectedCallback(){super.connectedCallback(),this.#e(),this.#d(),await this.updateComplete,this.isConnected&&this.updateMenuWidth()}disconnectedCallback(){super.disconnectedCallback(),this.#b(),this._slotObserver?.disconnect(),this._slotObserver=null}willUpdate(t){t.has("configContext")&&this.#e()}updated(t){t.has("_dropdownOpen")&&this._dropdownOpen&&(this.#f(),this.#y()[0]?.focus()),(t.has("disabled")||t.has("readonly"))&&this.#f()}#t(){return this.options.find(t=>t.selected)??this.options[0]}#e(){let t=Array.from(this.querySelectorAll("qti-inline-choice")),e=this.dataPrompt||this.configContext?.inlineChoicePrompt||"select",i=this._pendingResponse,n=i!==void 0?i??"":this.options.find(a=>a.selected)?.value??"",r=[{content:e,value:"",selected:n===""},...t.map(a=>{let l=a.getAttribute("identifier")??"";return{content:Array.from(a.childNodes).map(c=>c.cloneNode(!0)),value:l,selected:l!==""&&l===n}})],s=r.some(a=>a.selected);this.options=s?r:r.map((a,l)=>({...a,selected:l===0})),this._pendingResponse=void 0,this.#f(),this.updateMenuWidth()}shouldAutoSizeMenu(){return this.configContext?.inlineChoiceAutosize?!Array.from(this.classList).some(t=>t.startsWith("qti-input-width-")):!1}menuAutoSizeExtraWidth(){return this.renderRoot.querySelector('span[part~="dropdown-icon"]')?.offsetWidth??0}validate(){let t=this.options.find(s=>s.selected),e=t?t.value!=="":!1,i=this.required||this.minChoices>=1,n=e||!i,r=this.dataset.minChoicesMessage||"Please select an option.";return this.setInteractionValidity(n,n?"":r,this,{suppressInline:!0}),n}reportValidity(){return super.reportValidity()}reset(){this.#r(!1),this.options=this.options.map((t,e)=>({...t,selected:e===0})),this.#f()}set response(t){let e=t??"";if(this.options.length===0){this._pendingResponse=t;return}this.options=this.options.map(i=>({...i,selected:i.value===e})),this.#f()}get response(){let t=this.options.find(e=>e.selected)?.value??"";return t===""?null:t}#i(t){this.options=this.options.map(e=>({...e,selected:e.value===t})),this.#f(),this.validate(),this.reportValidity(),this.saveResponse(t),this.#r(!1)}#r(t){let e=this.#m();if(e){if(t){e.matches(":popover-open")||e.showPopover();return}e.matches(":popover-open")&&e.hidePopover()}}#n;#o;#s;#a;#c(){this.renderRoot.querySelector('button[part="trigger"]')?.focus()}#p(){let t=document.activeElement;for(;t&&t instanceof HTMLElement&&t.shadowRoot?.activeElement;)t=t.shadowRoot.activeElement;return t}#l(t){return t===this||this.contains(t)||this.renderRoot.contains(t)}#m(){return this.renderRoot.querySelector(`#${this._menuId}`)}#d(){this._slotObserver=new MutationObserver(()=>this.#e()),this._slotObserver.observe(this,{childList:!0,subtree:!0})}#u;#h;#b(){let t=Array.from(this.querySelectorAll("qti-inline-choice"));for(let e of t)e.removeEventListener("click",this.#h),e.removeAttribute("tabindex"),e.internals.role=null,e.internals.ariaSelected=null,e.internals.ariaChecked="false",e.internals.states.delete("checked")}async#f(){await this.updateComplete;let t=this.options.find(i=>i.selected)?.value??"",e=Array.from(this.querySelectorAll("qti-inline-choice"));for(let i of e){let r=(i.getAttribute("identifier")??"")===t;i.removeEventListener("click",this.#h),i.addEventListener("click",this.#h),i.disabled=this.disabled,i.readonly=this.readonly,i.internals.role="option",i.internals.ariaSelected=r?"true":"false",i.internals.ariaChecked=r?"true":"false",i.internals.ariaDisabled=this.disabled?"true":"false",i.internals.ariaReadOnly=this.readonly?"true":"false",r?i.internals.states.add("checked"):i.internals.states.delete("checked"),i.tabIndex=-1}}#y(){let t=this.renderRoot.querySelector('button[part~="option"]'),e=Array.from(this.querySelectorAll("qti-inline-choice"));return[...t?[t]:[],...e]}};ue([T()],ct.prototype,"options",void 0);ue([T()],ct.prototype,"_dropdownOpen",void 0);ue([_({context:xt,subscribe:!0}),p({attribute:!1})],ct.prototype,"configContext",void 0);ue([p({type:String,attribute:"data-prompt"})],ct.prototype,"dataPrompt",void 0);ue([L("dataPrompt",{waitUntilFirstUpdate:!0})],ct.prototype,"_handleDataPromptChange",void 0);ue([p({type:Boolean,reflect:!0,converter:{fromAttribute:o=>o==="true"||o==="",toAttribute:o=>o?"true":null}})],ct.prototype,"required",void 0);ue([p({type:Number,attribute:"min-choices"})],ct.prototype,"minChoices",void 0);ue([L(["required","minChoices"],{waitUntilFirstUpdate:!0})],ct.prototype,"_handleRequiredChange",void 0);ue([p({attribute:"response",reflect:!1,noAccessor:!0})],ct.prototype,"response",null);var hs=[{tag:"qti-inline-choice-interaction",ctor:ct}];var kp=[P,W,q`
7867
7872
  /*
7868
7873
  * A custom element is inline unless it says otherwise, and this one never did. Its shadow content
7869
7874
  * is block-level, so block-in-inline generated the anonymous block boxes and it looked correct —
@@ -8025,7 +8030,7 @@ CES.load();
8025
8030
  justify-content: center;
8026
8031
  flex-shrink: 0;
8027
8032
  }
8028
- `];var Bl=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},me=class extends jt(zt(D,"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"),'[qti-draggable="true"]'){constructor(){super(...arguments),this.autoSizeDropzones=!1,this.lastCheckedRadio=null,this.class="",this._response=[],this.responseIdentifier="",this.handleRadioClick=t=>{let e=t.target;this.lastCheckedRadio===e?(e.checked=!1,this.lastCheckedRadio=null,this.handleRadioChange(t)):this.lastCheckedRadio=e},this.handleRadioChange=t=>{let e=t.target,i=e.value,n=e.name,r=e.type;e.checked?(this.response?this.response.indexOf(i)===-1&&(r==="radio"&&(this.response=(this.response||[]).filter(s=>s.indexOf(n)===-1)),this.response=[...this.response,i]):this.response=[i],this.lastCheckedRadio=e):(this.response=(this.response||[]).filter(s=>s!==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}}))}}static{this.styles=[Sp,Ep]}get response(){return this.classList.contains("qti-match-tabular")?this._response:super.response}set response(t){this.classList.contains("qti-match-tabular")?this._response=t:super.response=t}isDragDropEnabled(){return!this.classList.contains("qti-match-tabular")}initiateDrag(...t){this.classList.contains("qti-match-tabular")||super.initiateDrag(...t)}afterCache(){this.classList.contains("qti-match-tabular")||super.afterCache()}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.syncTabularSlotting()}willUpdate(t){super.willUpdate?.(t),t.has("class")&&this.syncTabularSlotting()}syncTabularSlotting(){let t=this.classList.contains("qti-match-tabular"),e=this.querySelectorAll(":scope > qti-simple-match-set"),i=e[0],n=e[1],r=s=>{s.style.removeProperty("min-width"),s.style.removeProperty("min-height"),s.style.removeProperty("--qti-dropzone-min-height")};t?(i?.setAttribute("slot","match-rows"),n?.setAttribute("slot","match-cols"),this.sourceChoices?.forEach(s=>{r(s),s.setAttribute("role","rowheader")}),this.targetChoices?.forEach(s=>{r(s),s.setAttribute("role","columnheader")})):(i?.removeAttribute("slot"),n?.removeAttribute("slot"),this.sourceChoices?.forEach(s=>s.removeAttribute("role")),this.targetChoices?.forEach(s=>s.removeAttribute("role")))}validate(){return this.class.split(" ").includes("qti-match-tabular")?this.response?.length===this.sourceChoices.length:super.validate()}getCellStateVariant(t,e){return""}render(){let t=this.class.split(" ").includes("qti-match-tabular");return b`
8033
+ `];var Bl=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},me=class extends jt(zt(D,"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"),'[qti-draggable="true"]'){constructor(){super(...arguments),this.autoSizeDropzones=!1,this.lastCheckedRadio=null,this.class="",this._response=[],this.responseIdentifier="",this.handleRadioClick=t=>{let e=t.target;this.lastCheckedRadio===e?(e.checked=!1,this.lastCheckedRadio=null,this.handleRadioChange(t)):this.lastCheckedRadio=e},this.handleRadioChange=t=>{let e=t.target,i=e.value,n=e.name,r=e.type;e.checked?(this.response?this.response.indexOf(i)===-1&&(r==="radio"&&(this.response=(this.response||[]).filter(s=>s.indexOf(n)===-1)),this.response=[...this.response,i]):this.response=[i],this.lastCheckedRadio=e):(this.response=(this.response||[]).filter(s=>s!==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}}))}}static{this.styles=[kp,Ep]}get response(){return this.classList.contains("qti-match-tabular")?this._response:super.response}set response(t){this.classList.contains("qti-match-tabular")?this._response=t:super.response=t}isDragDropEnabled(){return!this.classList.contains("qti-match-tabular")}initiateDrag(...t){this.classList.contains("qti-match-tabular")||super.initiateDrag(...t)}afterCache(){this.classList.contains("qti-match-tabular")||super.afterCache()}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.syncTabularSlotting()}willUpdate(t){super.willUpdate?.(t),t.has("class")&&this.syncTabularSlotting()}syncTabularSlotting(){let t=this.classList.contains("qti-match-tabular"),e=this.querySelectorAll(":scope > qti-simple-match-set"),i=e[0],n=e[1],r=s=>{s.style.removeProperty("min-width"),s.style.removeProperty("min-height"),s.style.removeProperty("--qti-dropzone-min-height")};t?(i?.setAttribute("slot","match-rows"),n?.setAttribute("slot","match-cols"),this.sourceChoices?.forEach(s=>{r(s),s.setAttribute("role","rowheader")}),this.targetChoices?.forEach(s=>{r(s),s.setAttribute("role","columnheader")})):(i?.removeAttribute("slot"),n?.removeAttribute("slot"),this.sourceChoices?.forEach(s=>s.removeAttribute("role")),this.targetChoices?.forEach(s=>s.removeAttribute("role")))}validate(){return this.class.split(" ").includes("qti-match-tabular")?this.response?.length===this.sourceChoices.length:super.validate()}getCellStateVariant(t,e){return""}render(){let t=this.class.split(" ").includes("qti-match-tabular");return b`
8029
8034
  <slot name="prompt"></slot>
8030
8035
  <slot ?hidden=${t}></slot>
8031
8036
 
@@ -8285,7 +8290,7 @@ CES.load();
8285
8290
  :host([answer-key]) [part~='drags'] {
8286
8291
  display: none;
8287
8292
  }
8288
- `];var _p=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},pf=zt(D,"qti-simple-choice","[part~='drop']","slot[part~='drags']"),We=class extends jt(pf,'[qti-draggable="true"]'){constructor(){super(...arguments),this.nrChoices=0}static{this.styles=Ip}render(){let t=Array.from(this.querySelectorAll("qti-simple-choice"));return this.nrChoices<t.length&&(this.nrChoices=t.length),b` <slot name="prompt"> </slot>
8293
+ `];var _p=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},uf=zt(D,"qti-simple-choice","[part~='drop']","slot[part~='drags']"),We=class extends jt(uf,'[qti-draggable="true"]'){constructor(){super(...arguments),this.nrChoices=0}static{this.styles=Ip}render(){let t=Array.from(this.querySelectorAll("qti-simple-choice"));return this.nrChoices<t.length&&(this.nrChoices=t.length),b` <slot name="prompt"> </slot>
8289
8294
  <div part="container">
8290
8295
  <slot part="drags"> </slot>
8291
8296
  <div part="drops">
@@ -8304,13 +8309,13 @@ CES.load();
8304
8309
  ::slotted(qti-interaction-markup) {
8305
8310
  display: none;
8306
8311
  }
8307
- `];var At=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},uf=["solution","review"];function mf(o){return o==null?!1:Array.isArray(o)?o.length>0:o!==""}var G=class extends D{constructor(){super(...arguments),this._iframeLoaded=!1,this._interactionReady=!1,this._pendingMessages=[],this._iframeMessageOrigin=null,this.requirePathsJson="",this.requireShimJson="",this.requireJsUrl="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js",this.baseUrl="",this.useDefaultPaths=!1,this.status="interacting",this.#e=null,this._errorMessage=null,this.response=null,this.#r=null,this.#n=null,this.#o=null,this.#s="",this.handleIframeMessage=t=>{let{data:e}=t;if(!(!e||e.source!=="qti-pci-iframe")&&!(!this.iframe?.contentWindow||t.source!==this.iframe.contentWindow)&&!(e.responseIdentifier&&e.responseIdentifier!==this.responseIdentifier)){if(this._iframeMessageOrigin===null)this._iframeMessageOrigin=t.origin;else if(t.origin!==this._iframeMessageOrigin)return;switch(e.method){case"iframeReady":this._interactionReady=!0,this.#E(),this.#g(),this.dispatchEvent(new CustomEvent("qti-portable-custom-interaction-loaded",{bubbles:!0}));break;case"resize":typeof e.height=="number"&&this.iframe&&(this.iframe.style.height=`${e.height}px`,this.iframe.style.width=`${e.width}px`);break;case"console":this.dispatchEvent(new CustomEvent("qti-pci-console",{detail:{level:e.level,args:e.args},bubbles:!0}));break;case"interactionChanged":{let i=e?.params?.value,n=i&&typeof i=="object"?this.#m(i):null,r=typeof e?.params?.valid=="boolean"?e.params.valid:null,s=typeof e?.params?.customValidity=="string"?e.params.customValidity:null;r!==null&&(this.#o=r,r&&s===null&&(this.#s="")),s!==null&&(this.#s=s);let a=e?.params?.state,l;if(a===void 0)l=void 0;else if(a===null)l=null;else if(typeof a=="string")l=a;else try{l=`__qti_json__::${JSON.stringify(a)}`}catch{l=null}if(n===null){let c=this.responseVariable?.cardinality==="single"?"":[];this.response=c,this.validate(),this.saveResponse(c,l);break}this.response=n,this.validate(),this.saveResponse(n,l);break}case"error":this._errorMessage=e.params.message,console.error("Error from PCI iframe:",e.params.message);break}}},this.#w=null}#t;static{this.styles=[Tp,q`
8312
+ `];var At=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},mf=["solution","review"];function ff(o){return o==null?!1:Array.isArray(o)?o.length>0:o!==""}var X=class extends D{constructor(){super(...arguments),this._iframeLoaded=!1,this._interactionReady=!1,this._pendingMessages=[],this._iframeMessageOrigin=null,this.requirePathsJson="",this.requireShimJson="",this.requireJsUrl="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js",this.baseUrl="",this.useDefaultPaths=!1,this.status="interacting",this.#e=null,this._errorMessage=null,this.response=null,this.#r=null,this.#n=null,this.#o=null,this.#s="",this.handleIframeMessage=t=>{let{data:e}=t;if(!(!e||e.source!=="qti-pci-iframe")&&!(!this.iframe?.contentWindow||t.source!==this.iframe.contentWindow)&&!(e.responseIdentifier&&e.responseIdentifier!==this.responseIdentifier)){if(this._iframeMessageOrigin===null)this._iframeMessageOrigin=t.origin;else if(t.origin!==this._iframeMessageOrigin)return;switch(e.method){case"iframeReady":this._interactionReady=!0,this.#E(),this.#g(),this.dispatchEvent(new CustomEvent("qti-portable-custom-interaction-loaded",{bubbles:!0}));break;case"resize":typeof e.height=="number"&&this.iframe&&(this.iframe.style.height=`${e.height}px`,this.iframe.style.width=`${e.width}px`);break;case"console":this.dispatchEvent(new CustomEvent("qti-pci-console",{detail:{level:e.level,args:e.args},bubbles:!0}));break;case"interactionChanged":{let i=e?.params?.value,n=i&&typeof i=="object"?this.#m(i):null,r=typeof e?.params?.valid=="boolean"?e.params.valid:null,s=typeof e?.params?.customValidity=="string"?e.params.customValidity:null;r!==null&&(this.#o=r,r&&s===null&&(this.#s="")),s!==null&&(this.#s=s);let a=e?.params?.state,l;if(a===void 0)l=void 0;else if(a===null)l=null;else if(typeof a=="string")l=a;else try{l=`__qti_json__::${JSON.stringify(a)}`}catch{l=null}if(n===null){let c=this.responseVariable?.cardinality==="single"?"":[];this.response=c,this.validate(),this.saveResponse(c,l);break}this.response=n,this.validate(),this.saveResponse(n,l);break}case"error":this._errorMessage=e.params.message,console.error("Error from PCI iframe:",e.params.message);break}}},this.#w=null}#t;static{this.styles=[Tp,q`
8308
8313
  :host {
8309
8314
  display: block;
8310
8315
  width: 100%;
8311
8316
  min-height: 50px;
8312
8317
  }
8313
- `]}#e;set responseDeclaration(t){this.#e=t}get responseDeclaration(){if(this.#e)return this.#e;let t=this.responseVariable;if(!t)return null;let e={baseType:t.baseType,cardinality:t.cardinality},i=t.correctResponse;return mf(i)&&(e.correctResponse={value:i}),e}#i(){let t=this.responseDeclaration;if(!t?.correctResponse||uf.includes(this.status))return t;let{correctResponse:e,...i}=t;return i}#r;#n;#o;#s;#a(){if(this.#r===null&&this.requirePathsJson)try{let t=JSON.parse(this.requirePathsJson);if(Array.isArray(t)||!t||typeof t!="object")throw new Error("Require paths must be a JSON object.");this.#r=t}catch(t){console.error("Error parsing require paths JSON:",t),this._errorMessage=`Error parsing require paths JSON: ${t.message}`,this.#r={}}return this.#r||{}}#c(){if(this.#n===null&&this.requireShimJson)try{this.#n=JSON.parse(this.requireShimJson)}catch(t){console.error("Error parsing require shim JSON:",t),this._errorMessage=`Error parsing require shim JSON: ${t.message}`,this.#n={}}return this.#n||{}}#p(){return this.#a()}#l(){return this.#c()}#m(t){for(let e in t)if(t.hasOwnProperty(e)){let i=t[e];if(i){for(let n in i)if(i.hasOwnProperty(n)){let r=i[n];if(Array.isArray(r))return r.map(String);if(r!=null)return String(r)}}}return null}getDirectChildrenByTag(t){let e=t.toLowerCase();return Array.from(this.children).filter(i=>i.tagName.toLowerCase()===e)}coerceBaseValue(t,e){if(t==null)return t;switch(e){case"integer":{if(typeof t=="number")return t;let i=parseInt(String(t),10);return Number.isNaN(i)?t:i}case"float":case"duration":{if(typeof t=="number")return t;let i=parseFloat(String(t));return Number.isNaN(i)?t:i}case"boolean":{if(typeof t=="boolean")return t;if(typeof t=="string"){let i=t.toLowerCase();if(i==="true")return!0;if(i==="false")return!1}return t}default:return String(t)}}normalizeListValue(t){return t==null?[]:Array.isArray(t)?t:[t]}variableToQtiVariableJSON(t,e,i){if(e==="record"||i==="record")return this.recordToQtiVariableJSON(t);if(e!=="single"){let n=this.normalizeListValue(t).map(r=>this.coerceBaseValue(r,i));return{list:{[i]:n}}}return{base:{[i]:this.coerceBaseValue(t,i)}}}recordToQtiVariableJSON(t){if(!t||typeof t!="object")return{record:[]};let e=[];for(let[i,n]of Object.entries(t))e.push(this.recordEntryFromValue(i,n));return{record:e}}recordEntryFromValue(t,e){if(Array.isArray(e)){let i=e.filter(n=>n!=null);if(i.length&&i.every(n=>typeof n=="boolean"))return{name:t,list:{boolean:i}};if(i.length&&i.every(n=>typeof n=="number")){let n=i,r=n.every(s=>Number.isInteger(s));return{name:t,list:{[r?"integer":"float"]:n}}}return{name:t,list:{string:e.map(n=>n==null?"":String(n))}}}if(typeof e=="boolean")return{name:t,base:{boolean:e}};if(typeof e=="number")return Number.isInteger(e)?{name:t,base:{integer:e}}:{name:t,base:{float:e}};if(e==null)return{name:t,base:{string:""}};if(typeof e=="object")try{return{name:t,base:{string:JSON.stringify(e)}}}catch{return{name:t,base:{string:String(e)}}}return{name:t,base:{string:String(e)}}}getQtiContextDefaultsFromItem(){let t=this.closest("qti-assessment-item");if(!t)return{};let e={};return t.querySelectorAll('qti-context-declaration[identifier="QTI_CONTEXT"]').forEach(n=>{let r=n.querySelector("qti-default-value");if(!r)return;r.querySelectorAll("qti-value[field-identifier]").forEach(a=>{let l=a.getAttribute("field-identifier");if(!l)return;let c=a.getAttribute("base-type")||"string",d=a.textContent?.trim()||"";e[l]=this.coerceBaseValue(d,c)})}),e}getQtiContextRecord(){let t=this.getQtiContextDefaultsFromItem(),e=this.qtiContext?.QTI_CONTEXT||{},i={...t,...e};if(!Object.keys(i).length)return null;let n={candidateIdentifier:i.candidateIdentifier??"",testIdentifier:i.testIdentifier??"",environmentIdentifier:i.environmentIdentifier??"",...i};return this.recordToQtiVariableJSON(n)}getTemplateVariables(){let t={},e=this.getDirectChildrenByTag("qti-template-variable");return e.length&&e.forEach(i=>{let n=i.getAttribute("template-identifier")||i.getAttribute("identifier")||"";if(!n)return;let r=this.context?.variables?.find(l=>l.identifier===n);if(!r)return;let s=r.cardinality||"single",a=r.baseType||"string";t[n]=this.variableToQtiVariableJSON(r.value,s,a)}),t}getContextVariables(){let t={},e=this.getDirectChildrenByTag("qti-context-variable");return e.length&&e.forEach(i=>{let n=i.getAttribute("identifier")||"";if(!n)return;if(n==="QTI_CONTEXT"){let l=this.getQtiContextRecord();l&&(t[n]=l);return}let r=this.context?.variables?.find(l=>l.identifier===n);if(!r)return;let s=r.cardinality||"single",a=r.baseType||"string";t[n]=this.variableToQtiVariableJSON(r.value,s,a)}),t}#d(t){let e={...t};for(let i in t)if(Object.prototype.hasOwnProperty.call(t,i)){let n=i.replace(/[A-Z]/g,r=>`-${r.toLowerCase()}`);e[n]=t[i]}return e}#u(t){let e={...t},i=(n,r,s)=>{let a=n;for(let l=0;l<r.length;l+=1){let c=r[l];if(l===r.length-1){a[c]=s;return}(!a[c]||typeof a[c]!="object"||Array.isArray(a[c]))&&(a[c]={}),a=a[c]}};for(let[n,r]of Object.entries(t)){if(!n.includes("__"))continue;let s=n.split("__").filter(Boolean);s.length<2||i(e,s,r)}return e}responseVariablesToQtiVariableJSON(t,e,i){if(e!=="single"){let n={list:{}};return n.list[i]=t,n}else{let n={base:{}};return n.base[i]=t,n}}#h(){return this.response===null||this.response===void 0?!1:Array.isArray(this.response)?this.response.length===0?!1:this.response.some(t=>t!==""&&t!==null&&t!==void 0):this.response!==""}#b(t,e){let i=this.dataset.invalidresponsemessage||"Invalid response.",n=t?"":e&&e.trim().length>0?e:i;this._internals.setValidity(t?{}:{customError:!0},n)}validate(){let t=typeof this.#o=="boolean"?this.#o:this.#h();return this.#b(t,this.#s),t}set value(t){t===null?this.#t=[]:this.#t=Array.isArray(t)?t:t.split(",")}get value(){return this.#t===null||this.#t===void 0?null:Array.isArray(this.#t)?this.#t.join(","):String(this.#t)}set boundTo(t){if(!t||!t[this.responseIdentifier])return;let e=this.#m(t[this.responseIdentifier]);this.#t=e,this.saveResponse(e)}get boundTo(){let t={};if(this.context?.variables?.find(i=>i.identifier===this.responseIdentifier)){let i=this.context?.variables?.find(a=>a.identifier===this.responseIdentifier)?.cardinality||"single",n=this.context?.variables?.find(a=>a.identifier===this.responseIdentifier)?.baseType||"string",r=this.context?.variables?.find(a=>a.identifier===this.responseIdentifier)?.value||null,s=this.responseVariablesToQtiVariableJSON(r,i,n);t[this.responseIdentifier]=s}return t}#f(t){return t&&t.replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#x27;/g,"'").replace(/&#x2F;/g,"/").replace(/&#x60;/g,"`").replace(/&#x3D;/g,"=")}#y(t){let e={};for(let[i,n]of Object.entries(t))typeof n=="string"?e[i]=this.#f(n):e[i]=n;return e}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("message",this.handleIframeMessage)}sendMessageToIframe(t,e){let i=this.iframe?.contentWindow;if(!this._iframeLoaded||!i){this._pendingMessages.push({method:t,params:e});return}i.postMessage({source:"qti-portable-custom-interaction",responseIdentifier:this.responseIdentifier,method:t,params:e},"*")}#g(){this._pendingMessages.length&&(this._pendingMessages.forEach(t=>{this.sendMessageToIframe(t.method,t.params)}),this._pendingMessages=[])}createIframe(){this._interactionReady=!1,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.#C(),this.#v()};let t=`qti-pci-${this.responseIdentifier}-${Date.now()}`;this.iframe.name=t;let e=this.generateIframeContent();this.iframe.srcdoc=e,this.appendChild(this.iframe)}#v(){let t=this.#d(this.#u(this.#y({...this.dataset}))),e=this.context?.state?.[this.responseIdentifier],i=typeof e=="string"&&e.length>0?e:null,n={module:this.module,customInteractionTypeIdentifier:this.customInteractionTypeIdentifier,baseUrl:this.baseUrl?this.baseUrl.startsWith("http")||this.baseUrl.startsWith("blob")||this.baseUrl.startsWith("base64")?this.baseUrl:Zn(`${window.location.origin}${this.baseUrl}`):window.location.origin,responseIdentifier:this.responseIdentifier,properties:t,contextVariables:this.getContextVariables(),templateVariables:this.getTemplateVariables(),dataAttributes:{...this.dataset},interactionModules:this.#x(),boundTo:i?null:this.boundTo,responseDeclaration:this.#i(),status:this.status,state:i};this.sendMessageToIframe("initialize",n)}#x(){let t=[],e=this.querySelector("qti-interaction-modules");if(e){let i=e.querySelectorAll("qti-interaction-module");for(let n of i)t.push({id:n.getAttribute("id"),primaryPath:n.getAttribute("primary-path"),fallbackPath:n.getAttribute("fallback-path")})}return t}#C(){let t=this.querySelector("qti-interaction-markup");t&&this.sendMessageToIframe("setMarkup",t.innerHTML);let e=Array.from(this.querySelectorAll("qti-stylesheet"));if(e.length){let n=e.map(r=>r.outerHTML).join(`
8318
+ `]}#e;set responseDeclaration(t){this.#e=t}get responseDeclaration(){if(this.#e)return this.#e;let t=this.responseVariable;if(!t)return null;let e={baseType:t.baseType,cardinality:t.cardinality},i=t.correctResponse;return ff(i)&&(e.correctResponse={value:i}),e}#i(){let t=this.responseDeclaration;if(!t?.correctResponse||mf.includes(this.status))return t;let{correctResponse:e,...i}=t;return i}#r;#n;#o;#s;#a(){if(this.#r===null&&this.requirePathsJson)try{let t=JSON.parse(this.requirePathsJson);if(Array.isArray(t)||!t||typeof t!="object")throw new Error("Require paths must be a JSON object.");this.#r=t}catch(t){console.error("Error parsing require paths JSON:",t),this._errorMessage=`Error parsing require paths JSON: ${t.message}`,this.#r={}}return this.#r||{}}#c(){if(this.#n===null&&this.requireShimJson)try{this.#n=JSON.parse(this.requireShimJson)}catch(t){console.error("Error parsing require shim JSON:",t),this._errorMessage=`Error parsing require shim JSON: ${t.message}`,this.#n={}}return this.#n||{}}#p(){return this.#a()}#l(){return this.#c()}#m(t){for(let e in t)if(t.hasOwnProperty(e)){let i=t[e];if(i){for(let n in i)if(i.hasOwnProperty(n)){let r=i[n];if(Array.isArray(r))return r.map(String);if(r!=null)return String(r)}}}return null}getDirectChildrenByTag(t){let e=t.toLowerCase();return Array.from(this.children).filter(i=>i.tagName.toLowerCase()===e)}coerceBaseValue(t,e){if(t==null)return t;switch(e){case"integer":{if(typeof t=="number")return t;let i=parseInt(String(t),10);return Number.isNaN(i)?t:i}case"float":case"duration":{if(typeof t=="number")return t;let i=parseFloat(String(t));return Number.isNaN(i)?t:i}case"boolean":{if(typeof t=="boolean")return t;if(typeof t=="string"){let i=t.toLowerCase();if(i==="true")return!0;if(i==="false")return!1}return t}default:return String(t)}}normalizeListValue(t){return t==null?[]:Array.isArray(t)?t:[t]}variableToQtiVariableJSON(t,e,i){if(e==="record"||i==="record")return this.recordToQtiVariableJSON(t);if(e!=="single"){let n=this.normalizeListValue(t).map(r=>this.coerceBaseValue(r,i));return{list:{[i]:n}}}return{base:{[i]:this.coerceBaseValue(t,i)}}}recordToQtiVariableJSON(t){if(!t||typeof t!="object")return{record:[]};let e=[];for(let[i,n]of Object.entries(t))e.push(this.recordEntryFromValue(i,n));return{record:e}}recordEntryFromValue(t,e){if(Array.isArray(e)){let i=e.filter(n=>n!=null);if(i.length&&i.every(n=>typeof n=="boolean"))return{name:t,list:{boolean:i}};if(i.length&&i.every(n=>typeof n=="number")){let n=i,r=n.every(s=>Number.isInteger(s));return{name:t,list:{[r?"integer":"float"]:n}}}return{name:t,list:{string:e.map(n=>n==null?"":String(n))}}}if(typeof e=="boolean")return{name:t,base:{boolean:e}};if(typeof e=="number")return Number.isInteger(e)?{name:t,base:{integer:e}}:{name:t,base:{float:e}};if(e==null)return{name:t,base:{string:""}};if(typeof e=="object")try{return{name:t,base:{string:JSON.stringify(e)}}}catch{return{name:t,base:{string:String(e)}}}return{name:t,base:{string:String(e)}}}getQtiContextDefaultsFromItem(){let t=this.closest("qti-assessment-item");if(!t)return{};let e={};return t.querySelectorAll('qti-context-declaration[identifier="QTI_CONTEXT"]').forEach(n=>{let r=n.querySelector("qti-default-value");if(!r)return;r.querySelectorAll("qti-value[field-identifier]").forEach(a=>{let l=a.getAttribute("field-identifier");if(!l)return;let c=a.getAttribute("base-type")||"string",d=a.textContent?.trim()||"";e[l]=this.coerceBaseValue(d,c)})}),e}getQtiContextRecord(){let t=this.getQtiContextDefaultsFromItem(),e=this.qtiContext?.QTI_CONTEXT||{},i={...t,...e};if(!Object.keys(i).length)return null;let n={candidateIdentifier:i.candidateIdentifier??"",testIdentifier:i.testIdentifier??"",environmentIdentifier:i.environmentIdentifier??"",...i};return this.recordToQtiVariableJSON(n)}getTemplateVariables(){let t={},e=this.getDirectChildrenByTag("qti-template-variable");return e.length&&e.forEach(i=>{let n=i.getAttribute("template-identifier")||i.getAttribute("identifier")||"";if(!n)return;let r=this.context?.variables?.find(l=>l.identifier===n);if(!r)return;let s=r.cardinality||"single",a=r.baseType||"string";t[n]=this.variableToQtiVariableJSON(r.value,s,a)}),t}getContextVariables(){let t={},e=this.getDirectChildrenByTag("qti-context-variable");return e.length&&e.forEach(i=>{let n=i.getAttribute("identifier")||"";if(!n)return;if(n==="QTI_CONTEXT"){let l=this.getQtiContextRecord();l&&(t[n]=l);return}let r=this.context?.variables?.find(l=>l.identifier===n);if(!r)return;let s=r.cardinality||"single",a=r.baseType||"string";t[n]=this.variableToQtiVariableJSON(r.value,s,a)}),t}#d(t){let e={...t};for(let i in t)if(Object.prototype.hasOwnProperty.call(t,i)){let n=i.replace(/[A-Z]/g,r=>`-${r.toLowerCase()}`);e[n]=t[i]}return e}#u(t){let e={...t},i=(n,r,s)=>{let a=n;for(let l=0;l<r.length;l+=1){let c=r[l];if(l===r.length-1){a[c]=s;return}(!a[c]||typeof a[c]!="object"||Array.isArray(a[c]))&&(a[c]={}),a=a[c]}};for(let[n,r]of Object.entries(t)){if(!n.includes("__"))continue;let s=n.split("__").filter(Boolean);s.length<2||i(e,s,r)}return e}responseVariablesToQtiVariableJSON(t,e,i){if(e!=="single"){let n={list:{}};return n.list[i]=t,n}else{let n={base:{}};return n.base[i]=t,n}}#h(){return this.response===null||this.response===void 0?!1:Array.isArray(this.response)?this.response.length===0?!1:this.response.some(t=>t!==""&&t!==null&&t!==void 0):this.response!==""}#b(t,e){let i=this.dataset.invalidresponsemessage||"Invalid response.",n=t?"":e&&e.trim().length>0?e:i;this._internals.setValidity(t?{}:{customError:!0},n)}validate(){let t=typeof this.#o=="boolean"?this.#o:this.#h();return this.#b(t,this.#s),t}set value(t){t===null?this.#t=[]:this.#t=Array.isArray(t)?t:t.split(",")}get value(){return this.#t===null||this.#t===void 0?null:Array.isArray(this.#t)?this.#t.join(","):String(this.#t)}set boundTo(t){if(!t||!t[this.responseIdentifier])return;let e=this.#m(t[this.responseIdentifier]);this.#t=e,this.saveResponse(e)}get boundTo(){let t={};if(this.context?.variables?.find(i=>i.identifier===this.responseIdentifier)){let i=this.context?.variables?.find(a=>a.identifier===this.responseIdentifier)?.cardinality||"single",n=this.context?.variables?.find(a=>a.identifier===this.responseIdentifier)?.baseType||"string",r=this.context?.variables?.find(a=>a.identifier===this.responseIdentifier)?.value||null,s=this.responseVariablesToQtiVariableJSON(r,i,n);t[this.responseIdentifier]=s}return t}#f(t){return t&&t.replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#x27;/g,"'").replace(/&#x2F;/g,"/").replace(/&#x60;/g,"`").replace(/&#x3D;/g,"=")}#y(t){let e={};for(let[i,n]of Object.entries(t))typeof n=="string"?e[i]=this.#f(n):e[i]=n;return e}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("message",this.handleIframeMessage)}sendMessageToIframe(t,e){let i=this.iframe?.contentWindow;if(!this._iframeLoaded||!i){this._pendingMessages.push({method:t,params:e});return}i.postMessage({source:"qti-portable-custom-interaction",responseIdentifier:this.responseIdentifier,method:t,params:e},"*")}#g(){this._pendingMessages.length&&(this._pendingMessages.forEach(t=>{this.sendMessageToIframe(t.method,t.params)}),this._pendingMessages=[])}createIframe(){this._interactionReady=!1,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.#C(),this.#v()};let t=`qti-pci-${this.responseIdentifier}-${Date.now()}`;this.iframe.name=t;let e=this.generateIframeContent();this.iframe.srcdoc=e,this.appendChild(this.iframe)}#v(){let t=this.#d(this.#u(this.#y({...this.dataset}))),e=this.context?.state?.[this.responseIdentifier],i=typeof e=="string"&&e.length>0?e:null,n={module:this.module,customInteractionTypeIdentifier:this.customInteractionTypeIdentifier,baseUrl:this.baseUrl?this.baseUrl.startsWith("http")||this.baseUrl.startsWith("blob")||this.baseUrl.startsWith("base64")?this.baseUrl:Zn(`${window.location.origin}${this.baseUrl}`):window.location.origin,responseIdentifier:this.responseIdentifier,properties:t,contextVariables:this.getContextVariables(),templateVariables:this.getTemplateVariables(),dataAttributes:{...this.dataset},interactionModules:this.#x(),boundTo:i?null:this.boundTo,responseDeclaration:this.#i(),status:this.status,state:i};this.sendMessageToIframe("initialize",n)}#x(){let t=[],e=this.querySelector("qti-interaction-modules");if(e){let i=e.querySelectorAll("qti-interaction-module");for(let n of i)t.push({id:n.getAttribute("id"),primaryPath:n.getAttribute("primary-path"),fallbackPath:n.getAttribute("fallback-path")})}return t}#C(){let t=this.querySelector("qti-interaction-markup");t&&this.sendMessageToIframe("setMarkup",t.innerHTML);let e=Array.from(this.querySelectorAll("qti-stylesheet"));if(e.length){let n=e.map(r=>r.outerHTML).join(`
8314
8319
  `);this.sendMessageToIframe("setStylesheets",n)}let i=this.querySelector("properties");i&&this.sendMessageToIframe("setProperties",i.innerHTML)}#E(){}connectedCallback(){super.connectedCallback(),this.#o=null,this.#s="";let t=this.response;(Array.isArray(t)?t.length>0:t)||(this.response=this.responseVariable?.value??null),window.addEventListener("message",this.handleIframeMessage),this.createIframe()}generateIframeContent(){let t=window.getComputedStyle(document.body),e=JSON.stringify(this.#p()),i=JSON.stringify(this.#l()),n=this.dataset.baseUrl?this.dataset.baseUrl.startsWith("/")?`${window.location.origin}${this.dataset.baseUrl}`:this.dataset.baseUrl:"",r=n?n.endsWith("/")?n:`${n}/`:`${window.location.origin}/`,s=this.dataset.forwardConsole==="true",a=window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1",l=a?`${window.location.origin}/cdn/index.js`:"https://unpkg.com/@citolab/qti-components/cdn",c=a?`${window.location.origin}/dist/item.css`:"https://unpkg.com/@citolab/qti-components@latest/dist/item.css",d=this.dataset.componentsCdnUrl||l,h=this.dataset.componentsCssUrl||c,f=`
8315
8320
  font-family: ${t.getPropertyValue("font-family")};
8316
8321
  font-size: ${t.getPropertyValue("font-size")};
@@ -9208,7 +9213,7 @@ CES.load();
9208
9213
  <h1>Error</h1>
9209
9214
  ${this._errorMessage}
9210
9215
  </div>`:""}
9211
- `}};At([p({type:String,attribute:"module"})],G.prototype,"module",void 0);At([p({type:String,attribute:"custom-interaction-type-identifier"})],G.prototype,"customInteractionTypeIdentifier",void 0);At([p({type:String,attribute:"data-require-paths"})],G.prototype,"requirePathsJson",void 0);At([p({type:String,attribute:"data-require-shim"})],G.prototype,"requireShimJson",void 0);At([p({type:String,attribute:"data-require-js-url"})],G.prototype,"requireJsUrl",void 0);At([p({type:String,attribute:"data-base-url"})],G.prototype,"baseUrl",void 0);At([p({type:Boolean,attribute:"data-use-default-paths"})],G.prototype,"useDefaultPaths",void 0);At([p({type:String,attribute:"data-status"})],G.prototype,"status",void 0);At([T()],G.prototype,"_errorMessage",void 0);At([_({context:F,subscribe:!0}),T()],G.prototype,"context",void 0);At([_({context:qt,subscribe:!0}),T()],G.prototype,"qtiContext",void 0);At([p({attribute:"response",reflect:!1,converter:Xt({emptyAs:null})})],G.prototype,"response",void 0);var gs=class extends G{#t=!1;async waitForReady(t=5e3){this._interactionReady||await new Promise((e,i)=>{let n=()=>{window.clearTimeout(r),e()},r=window.setTimeout(()=>{this.removeEventListener("qti-portable-custom-interaction-loaded",n),i(new Error(`Portable custom interaction did not become ready within ${t}ms`))},t);this.addEventListener("qti-portable-custom-interaction-loaded",n,{once:!0})})}async getIFrameContent(){return new Promise(t=>{let e=`get-content-${Date.now()}`,i=n=>{let{data:r}=n;r?.source==="qti-pci-iframe"&&(!r?.responseIdentifier||r?.responseIdentifier===this.responseIdentifier)&&r?.method==="getContentResponse"&&r?.messageId===e&&(window.removeEventListener("message",i),t(r.content))};window.addEventListener("message",i),this.sendMessageToIframe("getContent",{messageId:e}),setTimeout(()=>{window.removeEventListener("message",i),t("")},5e3)})}setTestContext(t){this.context=t,this.updateComplete.then(()=>{this.value=t?.variables?.find(e=>e.identifier===this.responseIdentifier).value})}async recreateIframe(){this.#t=!0;try{this.iframe&&(this._iframeLoaded=!1,this.iframe.remove()),this._pendingMessages=[],this.createIframe(),await this.waitForReady()}finally{this.#t=!1}}disconnectedCallback(){this.#t||super.disconnectedCallback()}async iFrameMouseClick(t,e){return new Promise(i=>{let n=`click-${Date.now()}`,r=s=>{let{data:a}=s;a?.source==="qti-pci-iframe"&&(!a?.responseIdentifier||a?.responseIdentifier===this.responseIdentifier)&&a?.method==="clickResponse"&&a?.messageId===n&&(window.removeEventListener("message",r),i())};window.addEventListener("message",r),this.sendMessageToIframe("simulateClick",{x:t,y:e,messageId:n}),setTimeout(()=>{window.removeEventListener("message",r),i()},5e3)})}async iFrameClickOnElement(t){return new Promise(e=>{let i=`click-selector-${Date.now()}`,n=r=>{let{data:s}=r;s?.source==="qti-pci-iframe"&&(!s?.responseIdentifier||s?.responseIdentifier===this.responseIdentifier)&&s?.method==="clickSelectorResponse"&&s?.messageId===i&&(window.removeEventListener("message",n),e(s.success))};window.addEventListener("message",n),this.sendMessageToIframe("clickOnSelector",{selector:t,messageId:i}),setTimeout(()=>{window.removeEventListener("message",n),e(!1)},5e3)})}async iFrameClickOnElementByText(t){return new Promise(e=>{let i=`click-text-${Date.now()}`,n=r=>{let{data:s}=r;s?.source==="qti-pci-iframe"&&(!s?.responseIdentifier||s?.responseIdentifier===this.responseIdentifier)&&s?.method==="clickTextResponse"&&s?.messageId===i&&(window.removeEventListener("message",n),e(s.success))};window.addEventListener("message",n),this.sendMessageToIframe("clickOnElementByText",{text:t,messageId:i}),setTimeout(()=>{window.removeEventListener("message",n),e(!1)},5e3)})}async iFrameSetValueElement(t,e){return new Promise(i=>{let n=`set-value-${Date.now()}`,r=s=>{let{data:a}=s;a?.source==="qti-pci-iframe"&&(!a?.responseIdentifier||a?.responseIdentifier===this.responseIdentifier)&&a?.method==="setValueResponse"&&a?.messageId===n&&(window.removeEventListener("message",r),i(a.success))};window.addEventListener("message",r),this.sendMessageToIframe("setValueElement",{selector:t,value:e,messageId:n}),setTimeout(()=>{window.removeEventListener("message",r),i(!1)},5e3)})}async iFrameGetBoundingClientRect(t){return new Promise(e=>{let i=`get-bounding-rect-${Date.now()}`,n=r=>{let{data:s}=r;s?.source==="qti-pci-iframe"&&(!s?.responseIdentifier||s?.responseIdentifier===this.responseIdentifier)&&s?.method==="getBoundingRectResponse"&&s?.messageId===i&&(window.removeEventListener("message",n),e(s.rect??null))};window.addEventListener("message",n),this.sendMessageToIframe("getBoundingRect",{selector:t,messageId:i}),setTimeout(()=>{window.removeEventListener("message",n),e(null)},5e3)})}async iFrameSetValueElementByText(t,e){return new Promise(i=>{let n=`set-value-text-${Date.now()}`,r=s=>{let{data:a}=s;a?.source==="qti-pci-iframe"&&(!a?.responseIdentifier||a?.responseIdentifier===this.responseIdentifier)&&a?.method==="setValueByTextResponse"&&a?.messageId===n&&(window.removeEventListener("message",r),i(a.success))};window.addEventListener("message",r),this.sendMessageToIframe("setValueElementByText",{text:t,value:e,messageId:n}),setTimeout(()=>{window.removeEventListener("message",r),i(!1)},5e3)})}async iFrameMousedownOnElement(t){return new Promise(e=>{let i=`mousedown-selector-${Date.now()}`,n=r=>{let{data:s}=r;s?.source==="qti-pci-iframe"&&(!s?.responseIdentifier||s?.responseIdentifier===this.responseIdentifier)&&s?.method==="mousedownSelectorResponse"&&s?.messageId===i&&(window.removeEventListener("message",n),e(s.success))};window.addEventListener("message",n),this.sendMessageToIframe("mousedownOnSelector",{selector:t,messageId:i}),setTimeout(()=>{window.removeEventListener("message",n),e(!1)},5e3)})}generateIframeContent(){let t=super.generateIframeContent(),e=`
9216
+ `}};At([p({type:String,attribute:"module"})],X.prototype,"module",void 0);At([p({type:String,attribute:"custom-interaction-type-identifier"})],X.prototype,"customInteractionTypeIdentifier",void 0);At([p({type:String,attribute:"data-require-paths"})],X.prototype,"requirePathsJson",void 0);At([p({type:String,attribute:"data-require-shim"})],X.prototype,"requireShimJson",void 0);At([p({type:String,attribute:"data-require-js-url"})],X.prototype,"requireJsUrl",void 0);At([p({type:String,attribute:"data-base-url"})],X.prototype,"baseUrl",void 0);At([p({type:Boolean,attribute:"data-use-default-paths"})],X.prototype,"useDefaultPaths",void 0);At([p({type:String,attribute:"data-status"})],X.prototype,"status",void 0);At([T()],X.prototype,"_errorMessage",void 0);At([_({context:F,subscribe:!0}),T()],X.prototype,"context",void 0);At([_({context:qt,subscribe:!0}),T()],X.prototype,"qtiContext",void 0);At([p({attribute:"response",reflect:!1,converter:Gt({emptyAs:null})})],X.prototype,"response",void 0);var gs=class extends X{#t=!1;async waitForReady(t=5e3){this._interactionReady||await new Promise((e,i)=>{let n=()=>{window.clearTimeout(r),e()},r=window.setTimeout(()=>{this.removeEventListener("qti-portable-custom-interaction-loaded",n),i(new Error(`Portable custom interaction did not become ready within ${t}ms`))},t);this.addEventListener("qti-portable-custom-interaction-loaded",n,{once:!0})})}async getIFrameContent(){return new Promise(t=>{let e=`get-content-${Date.now()}`,i=n=>{let{data:r}=n;r?.source==="qti-pci-iframe"&&(!r?.responseIdentifier||r?.responseIdentifier===this.responseIdentifier)&&r?.method==="getContentResponse"&&r?.messageId===e&&(window.removeEventListener("message",i),t(r.content))};window.addEventListener("message",i),this.sendMessageToIframe("getContent",{messageId:e}),setTimeout(()=>{window.removeEventListener("message",i),t("")},5e3)})}setTestContext(t){this.context=t,this.updateComplete.then(()=>{this.value=t?.variables?.find(e=>e.identifier===this.responseIdentifier).value})}async recreateIframe(){this.#t=!0;try{this.iframe&&(this._iframeLoaded=!1,this.iframe.remove()),this._pendingMessages=[],this.createIframe(),await this.waitForReady()}finally{this.#t=!1}}disconnectedCallback(){this.#t||super.disconnectedCallback()}async iFrameMouseClick(t,e){return new Promise(i=>{let n=`click-${Date.now()}`,r=s=>{let{data:a}=s;a?.source==="qti-pci-iframe"&&(!a?.responseIdentifier||a?.responseIdentifier===this.responseIdentifier)&&a?.method==="clickResponse"&&a?.messageId===n&&(window.removeEventListener("message",r),i())};window.addEventListener("message",r),this.sendMessageToIframe("simulateClick",{x:t,y:e,messageId:n}),setTimeout(()=>{window.removeEventListener("message",r),i()},5e3)})}async iFrameClickOnElement(t){return new Promise(e=>{let i=`click-selector-${Date.now()}`,n=r=>{let{data:s}=r;s?.source==="qti-pci-iframe"&&(!s?.responseIdentifier||s?.responseIdentifier===this.responseIdentifier)&&s?.method==="clickSelectorResponse"&&s?.messageId===i&&(window.removeEventListener("message",n),e(s.success))};window.addEventListener("message",n),this.sendMessageToIframe("clickOnSelector",{selector:t,messageId:i}),setTimeout(()=>{window.removeEventListener("message",n),e(!1)},5e3)})}async iFrameClickOnElementByText(t){return new Promise(e=>{let i=`click-text-${Date.now()}`,n=r=>{let{data:s}=r;s?.source==="qti-pci-iframe"&&(!s?.responseIdentifier||s?.responseIdentifier===this.responseIdentifier)&&s?.method==="clickTextResponse"&&s?.messageId===i&&(window.removeEventListener("message",n),e(s.success))};window.addEventListener("message",n),this.sendMessageToIframe("clickOnElementByText",{text:t,messageId:i}),setTimeout(()=>{window.removeEventListener("message",n),e(!1)},5e3)})}async iFrameSetValueElement(t,e){return new Promise(i=>{let n=`set-value-${Date.now()}`,r=s=>{let{data:a}=s;a?.source==="qti-pci-iframe"&&(!a?.responseIdentifier||a?.responseIdentifier===this.responseIdentifier)&&a?.method==="setValueResponse"&&a?.messageId===n&&(window.removeEventListener("message",r),i(a.success))};window.addEventListener("message",r),this.sendMessageToIframe("setValueElement",{selector:t,value:e,messageId:n}),setTimeout(()=>{window.removeEventListener("message",r),i(!1)},5e3)})}async iFrameGetBoundingClientRect(t){return new Promise(e=>{let i=`get-bounding-rect-${Date.now()}`,n=r=>{let{data:s}=r;s?.source==="qti-pci-iframe"&&(!s?.responseIdentifier||s?.responseIdentifier===this.responseIdentifier)&&s?.method==="getBoundingRectResponse"&&s?.messageId===i&&(window.removeEventListener("message",n),e(s.rect??null))};window.addEventListener("message",n),this.sendMessageToIframe("getBoundingRect",{selector:t,messageId:i}),setTimeout(()=>{window.removeEventListener("message",n),e(null)},5e3)})}async iFrameSetValueElementByText(t,e){return new Promise(i=>{let n=`set-value-text-${Date.now()}`,r=s=>{let{data:a}=s;a?.source==="qti-pci-iframe"&&(!a?.responseIdentifier||a?.responseIdentifier===this.responseIdentifier)&&a?.method==="setValueByTextResponse"&&a?.messageId===n&&(window.removeEventListener("message",r),i(a.success))};window.addEventListener("message",r),this.sendMessageToIframe("setValueElementByText",{text:t,value:e,messageId:n}),setTimeout(()=>{window.removeEventListener("message",r),i(!1)},5e3)})}async iFrameMousedownOnElement(t){return new Promise(e=>{let i=`mousedown-selector-${Date.now()}`,n=r=>{let{data:s}=r;s?.source==="qti-pci-iframe"&&(!s?.responseIdentifier||s?.responseIdentifier===this.responseIdentifier)&&s?.method==="mousedownSelectorResponse"&&s?.messageId===i&&(window.removeEventListener("message",n),e(s.success))};window.addEventListener("message",n),this.sendMessageToIframe("mousedownOnSelector",{selector:t,messageId:i}),setTimeout(()=>{window.removeEventListener("message",n),e(!1)},5e3)})}generateIframeContent(){let t=super.generateIframeContent(),e=`
9212
9217
  // Test helper functions for QtiPortableCustomInteractionTest
9213
9218
  // Base iframe implementation already provides PCIManager.getContent
9214
9219
 
@@ -9401,7 +9406,7 @@ CES.load();
9401
9406
  }
9402
9407
  },
9403
9408
  true
9404
- );`,i=t.lastIndexOf("</script>");return t.substring(0,i)+e+t.substring(i)}};var bs=[{tag:"qti-portable-custom-interaction",ctor:G},{tag:"qti-portable-custom-interaction-test",ctor:gs}];var Rp=[P,q`
9409
+ );`,i=t.lastIndexOf("</script>");return t.substring(0,i)+e+t.substring(i)}};var bs=[{tag:"qti-portable-custom-interaction",ctor:X},{tag:"qti-portable-custom-interaction-test",ctor:gs}];var Rp=[P,q`
9405
9410
  :host {
9406
9411
  display: block;
9407
9412
  }
@@ -9417,7 +9422,7 @@ CES.load();
9417
9422
  display: inline-block;
9418
9423
  position: relative;
9419
9424
  }
9420
- `];var vs=class extends C{static{this.styles=Pp}render(){return b`<slot></slot>`}constructor(){super(),this.removeMoveListener=this.removeMoveListener.bind(this),this.dragElementHandler=this.dragElementHandler.bind(this)}dragElementHandler(t){t.preventDefault();let e=t.clientX-this.startX,i=t.clientY-this.startY;this.dragElement.style.left=this.dragElement.offsetLeft+e+"px",this.dragElement.style.top=this.dragElement.offsetTop+i+"px",this.startX=t.clientX,this.startY=t.clientY}firstUpdated(t){super.firstUpdated(t),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)}};var ws=[{tag:"qti-position-object-interaction",ctor:ys},{tag:"qti-position-object-stage",ctor:vs}];var Op="important",ff=" !"+Op,xs=Ot(class extends Ae{constructor(o){if(super(o),o.type!==Wi.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((t,e)=>{let i=o[e];return i==null?t:t+`${e=e.includes("-")?e:e.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${i};`},"")}update(o,[t]){let{style:e}=o.element;if(this.ft===void 0)return this.ft=new Set(Object.keys(t)),this.render(t);for(let i of this.ft)t[i]==null&&(this.ft.delete(i),i.includes("-")?e.removeProperty(i):e[i]=null);for(let i in t){let n=t[i];if(n!=null){this.ft.add(i);let r=typeof n=="string"&&n.endsWith(ff);i.includes("-")||r?e.setProperty(i,r?n.slice(0,-11):n,r?Op:""):e[i]=n}}return rt}});var Mp=[P,q`
9425
+ `];var vs=class extends C{static{this.styles=Pp}render(){return b`<slot></slot>`}constructor(){super(),this.removeMoveListener=this.removeMoveListener.bind(this),this.dragElementHandler=this.dragElementHandler.bind(this)}dragElementHandler(t){t.preventDefault();let e=t.clientX-this.startX,i=t.clientY-this.startY;this.dragElement.style.left=this.dragElement.offsetLeft+e+"px",this.dragElement.style.top=this.dragElement.offsetTop+i+"px",this.startX=t.clientX,this.startY=t.clientY}firstUpdated(t){super.firstUpdated(t),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)}};var ws=[{tag:"qti-position-object-interaction",ctor:ys},{tag:"qti-position-object-stage",ctor:vs}];var Op="important",gf=" !"+Op,xs=Ot(class extends Ae{constructor(o){if(super(o),o.type!==Qi.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((t,e)=>{let i=o[e];return i==null?t:t+`${e=e.includes("-")?e:e.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${i};`},"")}update(o,[t]){let{style:e}=o.element;if(this.ft===void 0)return this.ft=new Set(Object.keys(t)),this.render(t);for(let i of this.ft)t[i]==null&&(this.ft.delete(i),i.includes("-")?e.removeProperty(i):e[i]=null);for(let i in t){let n=t[i];if(n!=null){this.ft.add(i);let r=typeof n=="string"&&n.endsWith(gf);i.includes("-")||r?e.setProperty(i,r?n.slice(0,-11):n,r?Op:""):e[i]=n}}return rt}});var Mp=[P,q`
9421
9426
  :host {
9422
9427
  display: block;
9423
9428
  --qti-select-point-marker-size: 1.5rem;
@@ -9551,7 +9556,7 @@ CES.load();
9551
9556
  ${this.renderRailSupplement()}
9552
9557
  </div>
9553
9558
  </div>
9554
- `}#r(t){this.#o(t.pageX);let e=n=>this.#s(n.pageX),i=()=>{document.removeEventListener("mousemove",e),document.removeEventListener("mouseup",i),this.#a()};document.addEventListener("mousemove",e),document.addEventListener("mouseup",i)}#n(t){this.#o(t.touches[0].pageX);let e=n=>this.#s(n.touches[0].pageX),i=()=>{document.removeEventListener("touchmove",e),document.removeEventListener("touchend",i),this.#a()};document.addEventListener("touchmove",e,{passive:!1}),document.addEventListener("touchend",i)}#o(t){this.#s(t)}#s(t){let e=this._rail.getBoundingClientRect(),i=t-e.left,n=Math.min(1,Math.max(0,i/e.width)),r=this.min+Math.round(n*(this.max-this.min)/this.step)*this.step;this.#i(r)}#a(){this.dispatchEvent(new Event("change",{bubbles:!0}))}};gn([Ii("#rail")],It.prototype,"_rail",void 0);gn([p({type:Number,attribute:"lower-bound"})],It.prototype,"min",void 0);gn([p({type:Number,attribute:"upper-bound"})],It.prototype,"max",void 0);gn([p({type:Number,attribute:"step"})],It.prototype,"step",void 0);gn([p({attribute:"response",reflect:!1,noAccessor:!0})],It.prototype,"response",null);var Cs=[{tag:"qti-slider-interaction",ctor:It}];var Np=()=>new Hl,Hl=class{},Ul=new WeakMap,YM=Ot(class extends _e{render(o){return O}update(o,[t]){let e=t!==this.G;return e&&this.rt(void 0),(e||this.lt!==this.ct)&&(this.G=t,this.ht=o.options?.host,this.rt(this.ct=o.element)),O}rt(o){if(this.G!==void 0)if(this.isConnected||(o=void 0),typeof this.G=="function"){let t=this.ht??globalThis,e=Ul.get(t);e===void 0&&(e=new WeakMap,Ul.set(t,e)),e.get(this.G)!==void 0&&this.G.call(this.ht,void 0),e.set(this.G,o),o!==void 0&&this.G.call(this.ht,o)}else this.G.value=o}get lt(){return typeof this.G=="function"?Ul.get(this.ht??globalThis)?.get(this.G):this.G?.value}disconnected(){this.lt===this.ct&&this.rt(void 0)}reconnected(){this.rt(this.ct)}});var $p=[P,q`
9559
+ `}#r(t){this.#o(t.pageX);let e=n=>this.#s(n.pageX),i=()=>{document.removeEventListener("mousemove",e),document.removeEventListener("mouseup",i),this.#a()};document.addEventListener("mousemove",e),document.addEventListener("mouseup",i)}#n(t){this.#o(t.touches[0].pageX);let e=n=>this.#s(n.touches[0].pageX),i=()=>{document.removeEventListener("touchmove",e),document.removeEventListener("touchend",i),this.#a()};document.addEventListener("touchmove",e,{passive:!1}),document.addEventListener("touchend",i)}#o(t){this.#s(t)}#s(t){let e=this._rail.getBoundingClientRect(),i=t-e.left,n=Math.min(1,Math.max(0,i/e.width)),r=this.min+Math.round(n*(this.max-this.min)/this.step)*this.step;this.#i(r)}#a(){this.dispatchEvent(new Event("change",{bubbles:!0}))}};gn([_i("#rail")],It.prototype,"_rail",void 0);gn([p({type:Number,attribute:"lower-bound"})],It.prototype,"min",void 0);gn([p({type:Number,attribute:"upper-bound"})],It.prototype,"max",void 0);gn([p({type:Number,attribute:"step"})],It.prototype,"step",void 0);gn([p({attribute:"response",reflect:!1,noAccessor:!0})],It.prototype,"response",null);var Cs=[{tag:"qti-slider-interaction",ctor:It}];var Np=()=>new Hl,Hl=class{},Ul=new WeakMap,KM=Ot(class extends _e{render(o){return O}update(o,[t]){let e=t!==this.G;return e&&this.rt(void 0),(e||this.lt!==this.ct)&&(this.G=t,this.ht=o.options?.host,this.rt(this.ct=o.element)),O}rt(o){if(this.G!==void 0)if(this.isConnected||(o=void 0),typeof this.G=="function"){let t=this.ht??globalThis,e=Ul.get(t);e===void 0&&(e=new WeakMap,Ul.set(t,e)),e.get(this.G)!==void 0&&this.G.call(this.ht,void 0),e.set(this.G,o),o!==void 0&&this.G.call(this.ht,o)}else this.G.value=o}get lt(){return typeof this.G=="function"?Ul.get(this.ht??globalThis)?.get(this.G):this.G?.value}disconnected(){this.lt===this.ct&&this.rt(void 0)}reconnected(){this.rt(this.ct)}});var $p=[P,q`
9555
9560
  :host {
9556
9561
  display: inline-flex;
9557
9562
  align-items: center;
@@ -9640,7 +9645,7 @@ CES.load();
9640
9645
  :host(.qti-input-width-72) {
9641
9646
  --qti-input-width: 72;
9642
9647
  }
9643
- `];var qi=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},pt=class extends D{constructor(){super(...arguments),this.inputRef=Np(),this.response=null,this._handleValueChange=()=>{this._internals.setFormValue(this.value),this.validate()}}static{this.styles=$p}get value(){return this.response||null}set value(t){this.response=t||null}get isInline(){return!0}validate(){if(!this._input)return!1;let t="",e=!1;return this.patternMask&&this.dataPatternmaskMessage?(this._input.setCustomValidity(""),e=this._input.checkValidity(),e||(t=this.dataPatternmaskMessage,this._input.setCustomValidity(this.dataPatternmaskMessage))):e=this._input.checkValidity(),e&&this.response===""&&(e=!1),!e&&!t&&(t=this._input.validationMessage||"Invalid value."),this.setInteractionValidity(e,t,this._input,{suppressInline:!0}),e}renderAnswer(){return b`<div part="answer" aria-hidden="true"></div>`}renderInput(){return b`<input
9648
+ `];var Ci=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},pt=class extends D{constructor(){super(...arguments),this.inputRef=Np(),this.response=null,this._handleValueChange=()=>{this._internals.setFormValue(this.value),this.validate()}}static{this.styles=$p}get value(){return this.response||null}set value(t){this.response=t||null}get isInline(){return!0}validate(){if(!this._input)return!1;let t="",e=!1;return this.patternMask&&this.dataPatternmaskMessage?(this._input.setCustomValidity(""),e=this._input.checkValidity(),e||(t=this.dataPatternmaskMessage,this._input.setCustomValidity(this.dataPatternmaskMessage))):e=this._input.checkValidity(),e&&this.response===""&&(e=!1),!e&&!t&&(t=this._input.validationMessage||"Invalid value."),this.setInteractionValidity(e,t,this._input,{suppressInline:!0}),e}renderAnswer(){return b`<div part="answer" aria-hidden="true"></div>`}renderInput(){return b`<input
9644
9649
  part="input"
9645
9650
  name="${this.responseIdentifier}"
9646
9651
  spellcheck="false"
@@ -9656,7 +9661,7 @@ CES.load();
9656
9661
  maxlength=${1e3}
9657
9662
  ?disabled="${this.disabled}"
9658
9663
  ?readonly="${this.readonly}"
9659
- />`}renderValidationMessage(){return b`<div id="validation-message" part="message" role="alert" style="display:none;"></div>`}render(){return b` ${this.renderAnswer()} ${this.renderInput()} ${this.renderValidationMessage()} `}textChanged(t){if(this.disabled||this.readonly)return;let e=t.target;this.response!==e.value&&(this.value=e.value,this.saveResponse(e.value))}reportValidity(){return this.validate(),super.reportValidity()}reset(){this.response=""}};qi([p({type:Number,attribute:"expected-length"})],pt.prototype,"expectedLength",void 0);qi([p({type:String,attribute:"pattern-mask"})],pt.prototype,"patternMask",void 0);qi([p({type:String,attribute:"placeholder-text"})],pt.prototype,"placeholderText",void 0);qi([p({type:String,attribute:"data-patternmask-message"})],pt.prototype,"dataPatternmaskMessage",void 0);qi([p({type:String,attribute:"response",reflect:!1})],pt.prototype,"response",void 0);qi([Ii("input")],pt.prototype,"_input",void 0);qi([L("response",{waitUntilFirstUpdate:!0})],pt.prototype,"_handleValueChange",void 0);var ks=[{tag:"qti-text-entry-interaction",ctor:pt}];var Lp=[P,q`
9664
+ />`}renderValidationMessage(){return b`<div id="validation-message" part="message" role="alert" style="display:none;"></div>`}render(){return b` ${this.renderAnswer()} ${this.renderInput()} ${this.renderValidationMessage()} `}textChanged(t){if(this.disabled||this.readonly)return;let e=t.target;this.response!==e.value&&(this.value=e.value,this.saveResponse(e.value))}reportValidity(){return this.validate(),super.reportValidity()}reset(){this.response=""}};Ci([p({type:Number,attribute:"expected-length"})],pt.prototype,"expectedLength",void 0);Ci([p({type:String,attribute:"pattern-mask"})],pt.prototype,"patternMask",void 0);Ci([p({type:String,attribute:"placeholder-text"})],pt.prototype,"placeholderText",void 0);Ci([p({type:String,attribute:"data-patternmask-message"})],pt.prototype,"dataPatternmaskMessage",void 0);Ci([p({type:String,attribute:"response",reflect:!1})],pt.prototype,"response",void 0);Ci([_i("input")],pt.prototype,"_input",void 0);Ci([L("response",{waitUntilFirstUpdate:!0})],pt.prototype,"_handleValueChange",void 0);var Ss=[{tag:"qti-text-entry-interaction",ctor:pt}];var Lp=[P,q`
9660
9665
  :host {
9661
9666
  display: block;
9662
9667
  margin: 1em 0;
@@ -9665,12 +9670,12 @@ CES.load();
9665
9670
  display: block;
9666
9671
  margin-top: 0.5em;
9667
9672
  }
9668
- `];var Ss=class extends D{static{this.styles=Lp}#t=null;#e=null;reset(){this.#t=null,this.#e=null,this.saveResponse(null)}validate(){return this.#e!==null}get response(){return this.#e}set response(t){if(typeof t=="string")this.#e=t,this.saveResponse(t);else if(t===null)this.reset();else throw new Error("Value must be a Base64-encoded string or null")}static get properties(){return{...D.properties}}render(){return b`
9673
+ `];var ks=class extends D{static{this.styles=Lp}#t=null;#e=null;reset(){this.#t=null,this.#e=null,this.saveResponse(null)}validate(){return this.#e!==null}get response(){return this.#e}set response(t){if(typeof t=="string")this.#e=t,this.saveResponse(t);else if(t===null)this.reset();else throw new Error("Value must be a Base64-encoded string or null")}static get properties(){return{...D.properties}}render(){return b`
9669
9674
  <div>
9670
9675
  <slot name="prompt"></slot>
9671
9676
  <input type="file" @change="${this.#i}" ?disabled="${this.disabled}" ?readonly="${this.readonly}" />
9672
9677
  </div>
9673
- `}async#i(t){let e=t.target;e.files&&e.files.length>0&&(this.#t=e.files[0],this.#e=await this.#r(this.#t),this.saveResponse(this.#e),this.dispatchEvent(new CustomEvent("qti-interaction-response",{detail:{response:this.#e}})))}#r(t){return new Promise((e,i)=>{let n=new FileReader;n.onload=()=>e(n.result),n.onerror=()=>i(n.error),n.readAsDataURL(t)})}};var Es=[{tag:"qti-upload-interaction",ctor:Ss}];var Vp=[...Ko,...Zo,...ts,...is,...rs,...ns,...ss,...as,...ls,...cs,...ds,...hs,...ps,...ms,...fs,...bs,...ws,...qs,...Cs,...ks,...Es,...zh];for(let{tag:o,ctor:t}of Vp)customElements.get(o)||customElements.define(o,t);for(let{tag:o,ctor:t}of Ko)customElements.get(o)||customElements.define(o,t);for(let{tag:o,ctor:t}of Zo)customElements.get(o)||customElements.define(o,t);for(let{tag:o,ctor:t}of ts)customElements.get(o)||customElements.define(o,t);for(let{tag:o,ctor:t}of is)customElements.get(o)||customElements.define(o,t);for(let{tag:o,ctor:t}of rs)customElements.get(o)||customElements.define(o,t);for(let{tag:o,ctor:t}of ns)customElements.get(o)||customElements.define(o,t);for(let{tag:o,ctor:t}of ss)customElements.get(o)||customElements.define(o,t);for(let{tag:o,ctor:t}of as)customElements.get(o)||customElements.define(o,t);for(let{tag:o,ctor:t}of ls)customElements.get(o)||customElements.define(o,t);for(let{tag:o,ctor:t}of cs)customElements.get(o)||customElements.define(o,t);for(let{tag:o,ctor:t}of ds)customElements.get(o)||customElements.define(o,t);for(let{tag:o,ctor:t}of hs)customElements.get(o)||customElements.define(o,t);for(let{tag:o,ctor:t}of ps)customElements.get(o)||customElements.define(o,t);for(let{tag:o,ctor:t}of ms)customElements.get(o)||customElements.define(o,t);for(let{tag:o,ctor:t}of fs)customElements.get(o)||customElements.define(o,t);for(let{tag:o,ctor:t}of bs)customElements.get(o)||customElements.define(o,t);for(let{tag:o,ctor:t}of ws)customElements.get(o)||customElements.define(o,t);for(let{tag:o,ctor:t}of qs)customElements.get(o)||customElements.define(o,t);for(let{tag:o,ctor:t}of Cs)customElements.get(o)||customElements.define(o,t);for(let{tag:o,ctor:t}of ks)customElements.get(o)||customElements.define(o,t);for(let{tag:o,ctor:t}of Es)customElements.get(o)||customElements.define(o,t);var E3=async o=>{let t=o.substring(0,o.lastIndexOf("/")),e=await Td().load(`${o}`).then(a=>a.assessmentTest()),i=await Fi().load(`${t}/${e.href}`).then(a=>a.htmlDoc()),n=await Fi().load(`${t}/${e.href}`).then(a=>a.items()),r=`${t}/${e.href}`,s=`${t}/${e.href.substring(0,e.href.lastIndexOf("/"))}`;return{testHTMLDoc:i,testURI:s,testURL:r,items:n,testIdentifier:e.identifier}},A3=async o=>Gt().load(o).then(t=>t.htmlDoc().firstElementChild);var As=class extends gf(Qt){calculate(){return this.calculateChildren(Array.from(this.children))}};function gf(o){return class extends o{calculateChildren(e){return e.map(n=>{let r=n;if(!r.calculate)return console.error("Element doesn't implement QtiConditionExpression"),null;let s=r.calculate(),a=!1;if(typeof s=="string")if(s==="true")a=!0;else if(s==="false")a=!1;else return console.error("unexpected val in qti-or, expected boolean"),null;else typeof s=="boolean"&&(a=s);return a}).every(n=>typeof n=="boolean"&&n)}}}var zp=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},or=class extends E{constructor(){super(...arguments),this.min=0,this.max=1/0}getResult(){let t=this.getVariables();if(!t||t.length===0)return console.error("qti-any-n requires at least one child expression"),null;if(this.min<0||this.max<this.min)return console.error("qti-any-n requires 0 <= min <= max"),null;let e=0;for(let i of t){if(i.cardinality!=="single"||Array.isArray(i.value))return console.error("qti-any-n requires single cardinality boolean expressions"),null;if(i.baseType!=="boolean")return console.error("qti-any-n requires boolean base-type"),null;if(i.value===null||i.value===void 0)return null;i.value==="true"&&e++}return e>=this.min&&e<=this.max}};zp([p({type:Number})],or.prototype,"min",void 0);zp([p({type:Number})],or.prototype,"max",void 0);var bf=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},bn=class extends E{constructor(){super(...arguments),this.baseType="string"}getResult(){return this.textContent.trim()}};bf([p({type:String,attribute:"base-type"})],bn.prototype,"baseType",void 0);var Is=class extends E{get resultBaseType(){return"integer"}getResult(){if(this.children?.length!==1)return console.error("qti-container-size must have exactly one child expression"),0;let t=this.getVariables();if(!t||t?.length===0)return 0;let e=t[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)}};var _s=class extends E{getResult(){if(this.children.length!==2)return console.error("qti-contains takes two sub-expressions"),null;let[t,e]=this.getVariables();if(!t||!e||t.value===null||t.value===void 0||e.value===null||e.value===void 0)return null;t.baseType!==e.baseType&&console.warn("qti-contains: both sub-expressions should have the same base-type");let i=t.baseType??e.baseType;if(t.cardinality==="single"&&e.cardinality!=="single")return console.warn("qti-contains: first sub-expression is single; treating it as a membership test"),this.#t(e.value).some(s=>this.#e(s,t.value,i));let n=this.#t(t.value),r=this.#t(e.value);return r.length===0?!0:t.cardinality==="ordered"&&e.cardinality==="ordered"?this.#r(n,r,i):this.#i(n,r,i)}#t(t){return Array.isArray(t)?[...t]:[t]}#e(t,e,i){return J.compareSingleValues(t,e,i)||t===e}#i(t,e,i){let n=[...t];return e.every(r=>{let s=n.findIndex(a=>this.#e(a,r,i));return s===-1?!1:(n.splice(s,1),!0)})}#r(t,e,i){for(let n=0;n+e.length<=t.length;n++)if(e.every((r,s)=>this.#e(t[n+s],r,i)))return!0;return!1}};var Ts=class extends E{get interpretation(){return this.getAttribute("interpretation")||""}getResult(){let t=this.getAttribute("identifier")||"",e=this.context.variables.find(i=>i.identifier===t)||null;return e.cardinality!=="single"?e.correctResponse.length>0?e.correctResponse[0]:"":e.correctResponse}};var Wl=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},Ci=class extends E{constructor(){super(...arguments),this.identifier=""}getResult(){if(!this.identifier)return console.error("qti-default requires an identifier attribute"),null;let t=this.identifier.split("."),e=null,i;if(t.length===2)e=t[0],i=t[1];else if(t.length===1)i=t[0];else return console.error("qti-default: invalid identifier format"),null;if(e){let r=this._testContext.items.find(a=>a.identifier===e);if(!this._testContext||!r)return console.warn(`qti-default: item "${e}" not found in test context`),null;let s=this._testContext.items.find(a=>a.identifier===e)?.variables.find(a=>a.identifier===i);return s?s.defaultValue||null:(console.warn(`qti-default: variable "${i}" not found in item "${e}"`),null)}if(!this.context?.variables)return console.warn("qti-default: no variables found in item context"),null;let n=this.context.variables.find(r=>r.identifier===i);return n?n.defaultValue||null:(console.warn(`qti-default: variable "${i}" not found in item context`),null)}};Wl([p({type:String})],Ci.prototype,"identifier",void 0);Wl([_({context:F,subscribe:!0}),T()],Ci.prototype,"context",void 0);Wl([T(),_({context:nt,subscribe:!0})],Ci.prototype,"_testContext",void 0);var Rs=class extends E{getResult(){if(this.children.length===2){let t=this.getVariables(),e=t[0],i=t[1];return e.cardinality!=="single"||!Array.isArray(i.value)?(console.error("unexpected cardinality in qti equal"),null):t[0].baseType!==t[1].baseType?(console.error("The baseType of the two variables is different"),null):i.value.filter(r=>!e.value.includes(r))}return null}};var Ps=class extends E{get resultBaseType(){return"float"}getResult(){let t=this.#t(this.getVariables());return t.length!==2?(console.warn("qti-divide: expected exactly 2 numeric values"),null):t[1]===0?(console.warn("qti-divide: division by zero"),null):t[0]/t[1]}#t(t){let e=[];for(let i of t){if(!i)continue;let n=r=>{if(r==null)return;let s=parseFloat(r.toString());if(Number.isNaN(s)){console.warn("qti-divide: non-numeric value encountered");return}e.push(s)};if(Array.isArray(i.value)){i.value.forEach(r=>n(r));continue}n(i.value)}return e}};var Os=class extends E{getResult(){let t=this.#t();return t?t[0]>=t[1]:null}#t(){let t=this.getVariables();if(t.length!==2)return console.error("qti-duration-gte requires exactly 2 duration expressions"),null;let e=t.map(i=>this.#e(i));return e.some(i=>i===null)?null:e}#e(t){if(t.cardinality!=="single"||Array.isArray(t.value))return console.error("qti-duration-gte requires single cardinality"),null;if(t.baseType!=="duration")return console.error("qti-duration-gte requires duration base-type"),null;if(t.value===null||t.value===void 0)return null;let e=Number.parseFloat(t.value.toString());return Number.isNaN(e)?(console.error(`qti-duration-gte requires duration values expressed in seconds, got "${t.value.toString()}"`),null):e}};var Ms=class extends E{getResult(){let t=this.#t();return t?t[0]<t[1]:null}#t(){let t=this.getVariables();if(t.length!==2)return console.error("qti-duration-lt requires exactly 2 duration expressions"),null;let e=t.map(i=>this.#e(i));return e.some(i=>i===null)?null:e}#e(t){if(t.cardinality!=="single"||Array.isArray(t.value))return console.error("qti-duration-lt requires single cardinality"),null;if(t.baseType!=="duration")return console.error("qti-duration-lt requires duration base-type"),null;if(t.value===null||t.value===void 0)return null;let e=Number.parseFloat(t.value.toString());return Number.isNaN(e)?(console.error(`qti-duration-lt requires duration values expressed in seconds, got "${t.value.toString()}"`),null):e}};var yf=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},yn=class extends E{constructor(){super(...arguments),this.roundingMode="significantFigures"}get figures(){if(!this.getAttribute("figures"))return console.error("figures attribute is missing"),null;let e=parseInt(this.getAttribute("figures")||"0");return isNaN(e)?(console.error("figures attribute is not a number"),null):e<0?(console.error("figures attribute is negative"),null):e<1&&this.roundingMode==="significantFigures"?(console.error("figures cannot be smaller than 1 for RoundingMode significantFigures"),null):e}getResult(){if(this.children.length===2){let t=this.getVariables(),e=t[0],i=t[1];if(this.roundingMode===null)return null;if(e.cardinality!=="single"||i.cardinality!=="single"||Array.isArray(e.value)||Array.isArray(i.value))return console.error("unexpected cardinality in qti equal"),!1;switch(t[0].baseType){case"integer":case"float":{let n=parseFloat(e.value),r=parseFloat(i.value);if(!isNaN(n)&&!isNaN(r))return this.roundingMode==="significantFigures"?n.toPrecision(this.figures)===r.toPrecision(this.figures):Math.round(n*Math.pow(10,this.figures))/Math.pow(10,this.figures)===Math.round(r*Math.pow(10,this.figures))/Math.pow(10,this.figures);console.error(`value cannot be casted to numeric value in equalRounded operator: ${n}, ${r}`);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}};yf([p({type:String,attribute:"rounding-mode"})],yn.prototype,"roundingMode",void 0);var jp=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},sr=class extends E{constructor(){super(...arguments),this.toleranceMode="exact",this.tolerance=""}get includeLowerBound(){return this.getAttribute("include-lower-bound")!=="false"}get includeUpperBound(){return this.getAttribute("include-upper-bound")!=="false"}getResult(){if(this.children.length===2){let t=this.getVariables(),e=t[0],i=t[1];return!e||!i?null:e.cardinality!=="single"||i.cardinality!=="single"||Array.isArray(e.value)||Array.isArray(i.value)?(console.error("unexpected cardinality in qti equal"),!1):e.value===null||i.value===null||e.value===void 0||i.value===void 0?null:this.toleranceMode==="exact"?J.compareSingleValues(e.value,i.value,e.baseType):this.#t(parseFloat(e.value),parseFloat(i.value))}return console.error("unexpected number of children in qti-equal"),null}#t(t,e){if(Number.isNaN(t)||Number.isNaN(e))return console.error("qti-equal with a tolerance needs numeric values"),null;let i=this.tolerance.split(/\s+/).filter(Boolean).map(l=>parseFloat(l));if(i.length===0||i.some(l=>Number.isNaN(l)))return console.error(`qti-equal with tolerance-mode="${this.toleranceMode}" needs a numeric tolerance`),null;let[n,r=n]=i,[s,a]=this.toleranceMode==="absolute"?[e-n,e+r]:[e*(1-n/100),e*(1+r/100)];return(this.includeLowerBound?t>=s:t>s)&&(this.includeUpperBound?t<=a:t<a)}};jp([p({type:String,attribute:"tolerance-mode"})],sr.prototype,"toleranceMode",void 0);jp([p({type:String})],sr.prototype,"tolerance",void 0);var Y=class extends C{render(){return b`<slot></slot>`}process(){throw new Error("Not implemented")}};var Ds=class extends Y{process(){throw new Pi}};var Ns=class extends Y{process(){throw new Oi}};var $s=class extends E{getResult(){let t=this.getAttribute("field-identifier");if(!t)return console.error("qti-field-value requires a field-identifier attribute"),null;if(this.children.length!==1)return console.error("qti-field-value must have exactly one child expression"),null;let e=this.getVariables()[0];if(!e||e.baseType!=="record"||e.value===null||e.value===void 0)return console.warn("qti-field-value child expression must return a record"),null;let i=e.value[t];return i===void 0?null:i}};var Ls=class extends E{getResult(){if(this.children.length===0)return console.error("qti-gcd must have at least one child expression"),null;let t=this.getVariables();if(!t||t.length===0)return null;let e=[];for(let i of t){if(i.baseType!=="integer")return console.error("qti-gcd requires integer base-type"),null;if(i.value===null||i.value===void 0)return null;if(i.cardinality==="single"){if(Array.isArray(i.value))return console.error("qti-gcd unexpected array value for single cardinality"),null;let n=parseInt(i.value,10);if(isNaN(n))return console.error("qti-gcd non-numerical value"),null;e.push(n)}else if(i.cardinality==="multiple"||i.cardinality==="ordered"){if(!Array.isArray(i.value))return console.error("qti-gcd expected array value for multiple/ordered cardinality"),null;for(let n of i.value){if(n==null)return null;let r=parseInt(n,10);if(isNaN(r))return console.error("qti-gcd non-numerical value"),null;e.push(r)}}else return console.error("qti-gcd unsupported cardinality"),null}return e.length===0?null:this.#t(e)}#t(t){if(t.length===0)return 0;if(t.length===1)return Math.abs(t[0]);let e=Math.abs(t[0]);for(let i=1;i<t.length&&(e=this.#e(e,Math.abs(t[i])),e!==1);i++);return e}#e(t,e){if(t===0&&e===0)return 0;if(t===0)return e;if(e===0)return t;for(;e!==0;){let i=e;e=t%e,t=i}return t}};var Vs=class extends E{getResult(){if(this.children.length===2){let t=this.getVariables(),e=t[0],i=t[1];if((e.baseType==="integer"||e.baseType==="float")&&(i.baseType==="integer"||i.baseType==="float"))return+e.value>+i.value;console.error("unexpected baseType or cardinality in qti gt")}return console.error("unexpected number of children in qt"),null}};var zs=class extends Qt{getResult(){if(this.children.length===2){let t=this.getVariables(),e=t[0],i=t[1];return(e.baseType==="integer"||e.baseType==="float")&&(i.baseType==="integer"||i.baseType==="float")?+e.value>=+i.value:(console.error("unexpected baseType or cardinality in qti gte"),null)}return console.error("unexpected number of children in qti gte"),null}};var vf=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},vn=class extends E{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 t=this.getVariables()[0];if(!t)return console.error("qti-index: missing container"),null;let e;if(!isNaN(Number(this.n)))e=Number(this.n);else{let i=this.#t(this.n);if(i===null)return console.error(`qti-index: variable "${this.n}" is not a valid number`),null;e=Number(i)}if(e<=0||!Number.isInteger(e))return console.error("qti-index: index must be a positive integer"),null;if(t.cardinality==="ordered"){let i=Array.isArray(t.value)?t.value:[t.value];return t.value===null||e>i.length?null:i[e-1]}else return console.error("qti-index: child must have ordered cardinality"),null}#t(t){let e=this.context.variables.find(i=>i.identifier===t)?.value;return e===null||isNaN(Number(e))?null:Number(e)}};vf([p({type:String})],vn.prototype,"n",void 0);var Fp=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},ar=class extends E{constructor(){super(...arguments),this.shape="",this.coords=""}getResult(){let t=this.getVariables();if(t.length!==1)return console.error("qti-inside requires exactly one point expression"),null;let e=t[0];if(e.cardinality!=="single"||Array.isArray(e.value))return console.error("qti-inside requires single cardinality"),null;if(e.value===null||e.value===void 0)return null;if(!this.shape||!this.coords)return console.error("qti-inside requires shape and coords attributes"),null;let i=this.#t(e.value.toString()),n=this.#e(this.coords);if(!i||n.length===0)return null;switch(this.shape.toLowerCase()){case"circle":return this.#i(i,n);case"rect":return this.#r(i,n);case"ellipse":return this.#n(i,n);case"poly":case"polygon":return this.#o(i,n);default:return console.error(`qti-inside does not support shape "${this.shape}"`),null}}#t(t){let e=t.split(/[,\s]+/).map(r=>r.trim()).filter(Boolean);if(e.length!==2)return console.error('qti-inside requires a point value formatted as "x y" or "x,y"'),null;let i=Number.parseFloat(e[0]),n=Number.parseFloat(e[1]);return Number.isNaN(i)||Number.isNaN(n)?(console.error("qti-inside requires numeric point coordinates"),null):{x:i,y:n}}#e(t){let e=t.split(",").map(i=>i.trim()).filter(Boolean).map(i=>Number.parseFloat(i));return e.some(i=>Number.isNaN(i))?(console.error("qti-inside requires numeric coords"),[]):e}#i(t,e){if(e.length!==3)return console.error("qti-inside circle requires x,y,r"),null;let[i,n,r]=e;return(t.x-i)**2+(t.y-n)**2<=r**2}#r(t,e){if(e.length!==4)return console.error("qti-inside rect requires left,top,right,bottom"),null;let[i,n,r,s]=e,a=Math.min(i,r),l=Math.max(i,r),c=Math.min(n,s),d=Math.max(n,s);return t.x>=a&&t.x<=l&&t.y>=c&&t.y<=d}#n(t,e){if(e.length!==4)return console.error("qti-inside ellipse requires centerX,centerY,radiusX,radiusY"),null;let[i,n,r,s]=e;return r===0||s===0?!1:(t.x-i)**2/r**2+(t.y-n)**2/s**2<=1}#o(t,e){if(e.length<6||e.length%2!==0)return console.error("qti-inside polygon requires at least 3 coordinate pairs"),null;let i=!1;for(let n=0,r=e.length-2;n<e.length;n+=2){let s=e[n],a=e[n+1],l=e[r],c=e[r+1];a>t.y!=c>t.y&&t.x<(l-s)*(t.y-a)/(c-a||Number.EPSILON)+s&&(i=!i),r=n}return i}};Fp([p({type:String})],ar.prototype,"shape",void 0);Fp([p({type:String})],ar.prototype,"coords",void 0);var js=class extends E{get resultBaseType(){return"integer"}getResult(){let t=this.#t(this.getVariables());return t.length!==2?(console.error("qti-integer-divide requires exactly 2 integer values"),null):t[1]===0?(console.error("qti-integer-divide: division by zero"),null):Math.floor(t[0]/t[1])}#t(t){let e=[];for(let i of t){if(i.baseType!=="integer")return console.error("qti-integer-divide requires integer base-type"),[];if(i.cardinality!=="single"||Array.isArray(i.value))return console.error("qti-integer-divide requires single cardinality"),[];if(i.value===null||i.value===void 0)return[];let n=Number.parseInt(i.value,10);if(Number.isNaN(n))return console.error("qti-integer-divide requires integer values"),[];e.push(n)}return e}};var Fs=class extends E{get resultBaseType(){return"integer"}getResult(){let t=this.#t(this.getVariables());return t.length!==2?(console.error("qti-integer-modulus requires exactly 2 integer values"),null):t[1]===0?(console.error("qti-integer-modulus: division by zero"),null):t[0]-Math.floor(t[0]/t[1])*t[1]}#t(t){let e=[];for(let i of t){if(i.baseType!=="integer")return console.error("qti-integer-modulus requires integer base-type"),[];if(i.cardinality!=="single"||Array.isArray(i.value))return console.error("qti-integer-modulus requires single cardinality"),[];if(i.value===null||i.value===void 0)return[];let n=Number.parseInt(i.value,10);if(Number.isNaN(n))return console.error("qti-integer-modulus requires integer values"),[];e.push(n)}return e}};var Bs=class extends E{get resultBaseType(){return"float"}getResult(){let t=this.getVariables();if(t.length!==1)return console.error("qti-integer-to-float requires exactly one child expression"),null;let e=t[0];if(e.baseType!=="integer")return console.error("qti-integer-to-float requires integer base-type"),null;if(e.cardinality!=="single"||Array.isArray(e.value))return console.error("qti-integer-to-float requires single cardinality"),null;if(e.value===null||e.value===void 0)return null;let i=Number.parseInt(e.value,10);return Number.isNaN(i)?(console.error("qti-integer-to-float requires an integer value"),null):i}};var Us=class extends E{getResult(){if(this.children.length===1){let t=this.getVariables();if(!t?.length)return!0;let e=t[0].value;return e==null||e==null||e===""}return console.error("unexpected number of children in qti Null"),null}};var Hs=class extends E{getResult(){let t=this.#t(this.getVariables());return t.length===0?(console.error("qti-lcm requires at least one integer value"),null):t.reduce((e,i)=>this.#i(e,i))}#t(t){let e=[];for(let i of t){if(i.baseType!=="integer")return console.error("qti-lcm requires integer base-type"),[];if(i.value===null||i.value===void 0)return[];if(i.cardinality==="single"){if(Array.isArray(i.value))return console.error("qti-lcm unexpected array value for single cardinality"),[];let n=Number.parseInt(i.value,10);if(Number.isNaN(n))return console.error("qti-lcm requires integer values"),[];e.push(n);continue}if(i.cardinality!=="multiple"&&i.cardinality!=="ordered")return console.error("qti-lcm unsupported cardinality"),[];if(!Array.isArray(i.value))return console.error("qti-lcm expected array value for container cardinality"),[];for(let n of i.value){let r=Number.parseInt(n,10);if(Number.isNaN(r))return console.error("qti-lcm requires integer values"),[];e.push(r)}}return e}#e(t,e){let i=Math.abs(t),n=Math.abs(e);for(;n!==0;){let r=i%n;i=n,n=r}return i}#i(t,e){return t===0||e===0?0:Math.abs(t*e/this.#e(t,e))}};var Bp=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},lr=class extends Y{get childExpression(){return this.firstElementChild}process(){let t=this.getAttribute("identifier"),e=this.context?.variables.find(r=>r.identifier===t)||null;if(!e)return console.warn(`lookupOutcomeValue: no outcome declaration for "${t}"`),null;let i=parseFloat(this.childExpression.calculate()),n;return e.matchTable?.size?n=e.matchTable.get(i):e.interpolationTable&&(n=this.#t(i,e.interpolationTable)),n==null?(console.warn(`lookupOutcomeValue: no table entry matches ${i} for "${t}"`),null):(this.dispatchEvent(new CustomEvent("qti-set-outcome-value",{bubbles:!0,composed:!0,detail:{outcomeIdentifier:this.identifier,value:Rt(n)}})),n)}#t(t,e){if(!Number.isNaN(t))return e.find(i=>i.includeBoundary?t>=i.sourceValue:t>i.sourceValue)?.targetValue}};Bp([p({type:String})],lr.prototype,"identifier",void 0);Bp([_({context:F,subscribe:!0}),T()],lr.prototype,"context",void 0);var Ws=class extends E{getResult(){if(this.children.length===2){let t=this.getVariables(),e=t[0],i=t[1];if((e.baseType==="integer"||e.baseType==="float")&&(i.baseType==="integer"||i.baseType==="float"))return+e.value<+i.value;console.error("unexpected baseType or cardinality in qti lt")}return console.error("unexpected number of children in lt"),null}};var Qs=class extends Qt{getResult(){if(this.children.length===2){let t=this.getVariables(),e=t[0],i=t[1];return(e.baseType==="integer"||e.baseType==="float")&&(i.baseType==="integer"||i.baseType==="float")?+e.value<=+i.value:(console.error("unexpected baseType or cardinality in qti lte"),null)}return console.error("unexpected number of children in qti lte"),null}};var wf=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},wn=class extends E{getResult(){let t=this.context.variables.find(s=>s.identifier===this.identifier);if(!t)return console.warn(`Response ${this.identifier} cannot be found`),null;let e=t.areaMapping;if(!e)return console.warn(`Area mapping not found for response ${this.identifier}`),null;let i=Array.isArray(t.value)?t.value:[t.value];if(!i||i.length===0)return console.warn(`No candidate responses for response ${this.identifier}`),null;let n=0,r=new Set;for(let s of i)for(let a of e.areaMapEntries){if(r.has(a.coords))continue;if(J.isPointInArea(s,`${a.shape},${a.coords}`,t.baseType)){n+=a.mappedValue??0,r.add(a.coords);break}}return r.size<i.length&&(n+=e.defaultValue),e.lowerBound!=null&&(n=Math.max(e.lowerBound,n)),e.upperBound!=null&&(n=Math.min(e.upperBound,n)),n}};wf([p({type:String})],wn.prototype,"identifier",void 0);var xf=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},xn=class extends E{getResult(){let t=this.context.variables.find(r=>r.identifier===this.identifier);if(!t||!t.mapping)return console.error(`Response ${this.identifier} can not be found`),null;let e=t.mapping,i=Array.isArray(t.value)?t.value:[t.value],n=0;for(let r of i){let s=e.mapEntries.filter(l=>t.baseType==="string"&&!l.caseSensitive?J.compareSingleValues(l.mapKey.toLowerCase(),r.toLowerCase(),t.baseType):J.compareSingleValues(l.mapKey,r,t.baseType)),a=s.reduce((l,c)=>l.mappedValue>c.mappedValue?l:c,s.length>0?s[0]:{mapKey:null,mappedValue:null});a===null||a.mappedValue==null?n+=e.defaultValue:n+=a.mappedValue}return e?.lowerBound!==null&&e?.lowerBound!==void 0&&(n=Math.max(e.lowerBound,n)),e?.upperBound!==null&&e?.upperBound!==void 0&&(n=Math.min(e.upperBound,n)),n}};xf([p({type:String})],xn.prototype,"identifier",void 0);var Xs=class o extends E{getResult(){if(this.children.length===2){let t=this.getVariables(),e=t[0],i=t[1];return o.match(e,i)}return console.error("unexpected number of children in match"),null}static match(t,e){if(t.value===null)return!1;switch(e.cardinality){case"single":return Array.isArray(t.value)||Array.isArray(e.value)?(console.error("unexpected cardinality in qti match"),!1):J.compareSingleValues(t.value?.toString(),e.value.toString(),e.baseType);case"ordered":{if(!Array.isArray(t.value)||!Array.isArray(e.value))return console.error("unexpected cardinality in qti match"),!1;if(t.value.length!==e.value.length)return!1;for(let i=0;i<t.value.length;i++)if(!J.compareSingleValues(e.value[i],t.value[i],e.baseType))return!1;return!0}case"multiple":{if(!Array.isArray(t.value)||!Array.isArray(e.value))return console.error("unexpected cardinality in qti match"),!1;if(t.value.length!==e.value.length)return!1;let i=0;for(let n of e.value){let r=null,s=[...t.value];for(let a of s)if(J.compareSingleValues(n,a,e.baseType)){r=a;break}if(r!==null)s.splice(s.indexOf(r),1);else return!1;i++}return!0}default:return console.error("unexpected cardinality in qti match"),!1}}};var qf=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},qn=class extends E{constructor(){super(...arguments),this.name=""}get resultBaseType(){return"float"}getResult(){switch(this.name.toLowerCase()){case"pi":return Math.PI;case"e":return Math.E;default:return console.error(`qti-math-constant: unknown constant "${this.name}"`),null}}};qf([p({type:String})],qn.prototype,"name",void 0);var Cf=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},Cn=class extends E{constructor(){super(...arguments),this.name=""}get resultBaseType(){return["floor","ceil","signum"].includes(this.name?.toLowerCase())?"integer":"float"}getResult(){if(!this.name)return console.error("qti-math-operator requires a name attribute"),null;let t=this.getVariables();if(!t||t.length===0)return null;let e=[];for(let i of t){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 n=parseFloat(i.value);if(isNaN(n))return console.error("qti-math-operator non-numerical value"),null;e.push(n)}return this.#e(this.name,e)}#t(t){return Number.isFinite(t)?t:null}#e(t,e){try{switch(t.toLowerCase()){case"sin":return e.length!==1?null:Math.sin(e[0]);case"cos":return e.length!==1?null:Math.cos(e[0]);case"tan":return e.length!==1?null:Math.tan(e[0]);case"asin":return e.length!==1||e[0]<-1||e[0]>1?null:Math.asin(e[0]);case"acos":return e.length!==1||e[0]<-1||e[0]>1?null:Math.acos(e[0]);case"atan":return e.length!==1?null:Math.atan(e[0]);case"sinh":return e.length!==1?null:Math.sinh(e[0]);case"cosh":return e.length!==1?null:Math.cosh(e[0]);case"tanh":return e.length!==1?null:Math.tanh(e[0]);case"secant":case"sec":return e.length!==1?null:this.#t(1/Math.cos(e[0]));case"cosecant":case"csc":return e.length!==1?null:this.#t(1/Math.sin(e[0]));case"cotangent":case"cot":return e.length!==1?null:this.#t(Math.cos(e[0])/Math.sin(e[0]));case"todegrees":return e.length!==1?null:e[0]*180/Math.PI;case"toradians":return e.length!==1?null:e[0]*Math.PI/180;case"log":return e.length!==1||e[0]<=0?null:Math.log10(e[0]);case"ln":return e.length!==1||e[0]<=0?null:Math.log(e[0]);case"log10":return e.length!==1||e[0]<=0?null:Math.log10(e[0]);case"exp":return e.length!==1?null:Math.exp(e[0]);case"abs":return e.length!==1?null:Math.abs(e[0]);case"sqrt":return e.length!==1||e[0]<0?null:Math.sqrt(e[0]);case"signum":return e.length!==1?null:Math.sign(e[0]);case"floor":return e.length!==1?null:Math.floor(e[0]);case"ceil":return e.length!==1?null:Math.ceil(e[0]);case"round":return e.length!==1?null:Math.round(e[0]);case"atan2":return e.length!==2?null:Math.atan2(e[0],e[1]);case"pow":{if(e.length!==2)return null;let i=e[0],n=e[1];return i===0&&n<=0||i<0&&!Number.isInteger(n)?null:Math.pow(i,n)}case"log_base":{if(e.length!==2)return null;let i=e[0],n=e[1];return i<=0||n<=0||n===1?null:Math.log(i)/Math.log(n)}case"mod":return e.length!==2||e[1]===0?null:e[0]%e[1];case"max":return e.length<1?null:Math.max(...e);case"min":return e.length<1?null:Math.min(...e);default:return console.error(`qti-math-operator: unknown operation "${t}"`),null}}catch(i){return console.error(`qti-math-operator: error performing operation "${t}":`,i),null}}};Cf([p({type:String})],Cn.prototype,"name",void 0);var Gs=class extends E{getResult(){let t=this.#t(this.getVariables());return t.length===0?(console.warn("qti-max: no numeric values provided"),null):Math.max(...t)}#t(t){let e=[];for(let i of t){if(!i)continue;let n=r=>{if(r==null)return;let s=parseFloat(r.toString());if(Number.isNaN(s)){console.warn("qti-max: non-numeric value encountered");return}e.push(s)};if(Array.isArray(i.value)){i.value.forEach(r=>n(r));continue}n(i.value)}return e}};var Ys=class extends E{getResult(){let t=this.getVariables();this.children.length!==2&&console.warn("The member operator takes two sub-expressions");let[e,i]=t;if(e.baseType===i.baseType||e.baseType==="integer"&&i.baseType==="float"||e.baseType==="float"&&i.baseType==="integer"||console.warn("Which must both have the same base-type"),i.cardinality==="multiple"||i.cardinality==="ordered"||console.warn("and the second must be a multiple or ordered container"),(e.baseType==="float"||i.baseType==="float")&&console.warn("The member operator should not be used on sub-expressions with a base-type of float"),(e.baseType==="duration"||i.baseType==="duration")&&console.warn("It must not be used on sub-expressions with a base-type of duration"),e.value===null||i.value===null)return null;let n=e.value;return i.value.includes(n)}};var Js=class extends E{getResult(){let t=this.#t(this.getVariables());return t.length===0?(console.warn("qti-min: no numeric values provided"),null):Math.min(...t)}#t(t){let e=[];for(let i of t){if(!i)continue;let n=r=>{if(r==null)return;let s=parseFloat(r.toString());if(Number.isNaN(s)){console.warn("qti-min: non-numeric value encountered");return}e.push(s)};if(Array.isArray(i.value)){i.value.forEach(r=>n(r));continue}n(i.value)}return e}};var Ks=class extends E{getResult(){let t=this.getVariables();if(t.length===0)return console.error("unexpected number of children in qti multiple"),null;for(let e of t)if(e.cardinality!=="multiple"&&e.cardinality!=="single")return console.error("unexpected cardinality in qti multiple"),[];return t}};var Zs=class extends E{render(){return b`${super.render()}`}getResult(){return!this.firstElementChild.calculate()}};var ta=class extends E{getResult(){return null}};var ea=class extends Qt{getResult(){return Array.from(this.children).map(e=>{let i=e;if(!i.calculate)return console.error("Element doesn't implement QtiConditionExpression"),null;let n=i.calculate(),r=!1;if(typeof n=="string")if(n==="true")r=!0;else if(n==="false")r=!1;else return console.error("unexpected val in qti-or, expected boolean"),null;else typeof n=="boolean"&&(r=n);return r}).some(e=>typeof e=="boolean"&&e)}};var ia=class extends E{getResult(){let t=this.getVariables();if(t.length===0)return console.error("unexpected number of children in qti multiple"),null;for(let e of t)if(e.cardinality!=="ordered"&&e.cardinality!=="single")return console.error("unexpected cardinality in qti ordered"),[];return t}};var ra=class extends C{render(){return b`<slot></slot>`}process(){let t=this.getSubRules();for(let e=0;e<t.length;e++)t[e].process()}},cr=class extends ra{shouldProcess(){return!0}getSubRules(){return[...this.children]}},dr=class extends ra{shouldProcess(){return this.firstElementChild.calculate()}getSubRules(){let t=[];for(let e=1;e<this.children.length;e++)t.push(this.children[e]);return t}},hr=class extends Y{render(){return b`<slot></slot>`}process(){let t=[...this.children];for(let e of t)if(e.shouldProcess()){e.process();return}}};var na=class extends hr{};var pr=class extends dr{};var oa=class extends pr{};var sa=class extends cr{};var kf=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},kn=class extends E{constructor(){super(...arguments),this.pattern=""}getResult(){let t=this.getVariables();if(t.length!==1)return console.error("qti-pattern-match requires exactly one child expression"),null;if(!this.pattern)return console.error("qti-pattern-match requires a pattern attribute"),null;let e=t[0];if(e.cardinality!=="single"||Array.isArray(e.value))return console.error("qti-pattern-match requires single cardinality"),null;if(e.value===null||e.value===void 0)return null;let i=this.#t();return i?i.test(e.value.toString()):null}#t(){let t=`^(?:${this.pattern})$`;try{return new RegExp(t,"u")}catch{try{return new RegExp(t)}catch(e){return console.error("qti-pattern-match requires a valid regular expression",e),null}}}};kf([p({type:String})],kn.prototype,"pattern",void 0);var aa=class extends E{get resultBaseType(){return"float"}getResult(){if(this.children.length!==2)return console.error("qti-power must have exactly two child expressions"),null;let t=this.getVariables();if(!t||t.length!==2)return null;let[e,i]=t;if(e.cardinality!=="single"||i.cardinality!=="single")return console.error("qti-power requires single cardinality for both expressions"),null;if(Array.isArray(e.value)||Array.isArray(i.value))return console.error("qti-power unexpected array value for single cardinality"),null;if(e.value===null||e.value===void 0||i.value===null||i.value===void 0)return null;if(e.baseType!=="integer"&&e.baseType!=="float"||i.baseType!=="integer"&&i.baseType!=="float")return console.error("qti-power requires numerical base-types"),null;let n=parseFloat(e.value),r=parseFloat(i.value);if(isNaN(n)||isNaN(r))return console.error("qti-power: non-numerical values encountered"),null;if(n===0&&r<=0||n<0&&!Number.isInteger(r))return null;let s;try{s=Math.pow(n,r)}catch(a){return console.error("qti-power: error calculating power:",a),null}if(isNaN(s))return null;if(s===1/0||s===-1/0)return s;if(!isFinite(s)||Math.abs(s)>Number.MAX_VALUE||s!==0&&Math.abs(s)<Number.MIN_VALUE)return null;if(isFinite(s)&&s!==0){let a=Math.floor(Math.log10(Math.abs(s))),l=Math.max(0,14-a),c=Math.pow(10,l);s=Math.round(s*c)/c}return s}};var Sf=/%(?:(%)|([-+ 0#]*)(\d+)?(?:\.(\d+))?([diuoxXfFeEgGsc]))/g;function Ef(o){return o.replace(/e([+-])(\d)$/,"e$10$2")}function Sn(o,t){return Ef(t===void 0?o.toExponential():o.toExponential(t))}function Up(o){let[t,e]=o.split(/e/i),i=t.includes(".")?t.replace(/\.?0+$/,""):t,n=e===void 0?"":`e${e}`;return`${i}${n}`}function Hp(o,t){let e=t===0?1:t,i=o===0?0:Math.floor(Math.log10(o));return i<-4||i>=e?Up(Sn(o,e-1)):Up(o.toFixed(Math.max(0,e-1-i)))}function Af(o,t,e,i){if(o==="s"||o==="c"){let c=o==="c"?i.slice(0,1):i;return e===void 0?c:c.slice(0,e)}let n=Number(i);if(i.trim()===""||!Number.isFinite(n))return i;let r=Math.abs(n),s,a=n<0;switch(o){case"d":case"i":s=String(Math.trunc(r));break;case"u":s=String(Math.trunc(r)),a=!1;break;case"o":s=`${t.includes("#")?"0":""}${Math.trunc(r).toString(8)}`;break;case"x":s=`${t.includes("#")?"0x":""}${Math.trunc(r).toString(16)}`;break;case"X":s=`${t.includes("#")?"0X":""}${Math.trunc(r).toString(16).toUpperCase()}`;break;case"f":case"F":s=r.toFixed(e??6);break;case"e":s=Sn(r,e??6);break;case"E":s=Sn(r,e??6).toUpperCase();break;case"g":s=Hp(r,e??6);break;case"G":s=Hp(r,e??6).toUpperCase();break;default:return i}return`${a?"-":t.includes("+")?"+":t.includes(" ")?" ":""}${s}`}function If(o,t,e){if(o.length>=e)return o;let i=e-o.length;if(t.includes("-"))return`${o}${" ".repeat(i)}`;if(t.includes("0")){let[,n,r]=/^([-+ ]?)(.*)$/.exec(o);return`${n}${"0".repeat(i)}${r}`}return`${" ".repeat(i)}${o}`}function Wp(o,t){return o.replace(Sf,(e,i,n,r,s,a)=>i?"%":If(Af(a,n??"",s===void 0?void 0:Number(s),t),n??"",r===void 0?0:Number(r)))}var fe=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},vt=class extends C{constructor(){super(...arguments),this.base=10,this.powerForm=!1,this.delimiter=";",this.mappingIndicator="="}render(){let t=this.context?.variables.find(i=>i.identifier===this.identifier),e=t?this.#t(t):null;return e===null?O:b`${e}`}#t(t){let e=t.value;if(e==null)return null;if(Array.isArray(e)){if(e.length===0)return null;if(this.index!==void 0){let i=e[this.index-1];return i==null?null:this.#e(i,t.baseType)}return e.map(i=>this.#e(i,t.baseType)).join(this.delimiter)}if(typeof e=="object"){let i=e;if(this.field!==void 0){let r=i[this.field];return r==null?null:this.#e(r,t.baseType)}let n=Object.entries(i).filter(([,r])=>r!=null);return n.length===0?null:n.map(([r,s])=>`${r}${this.mappingIndicator}${this.#e(s,t.baseType)}`).join(this.delimiter)}return this.#e(e,t.baseType)}#e(t,e){let i=Array.isArray(t)?t.join(" "):String(t);if(this.format)return Wp(this.format,i);if(e==="integer"&&this.base!==10){let n=Number.parseInt(i,10);if(Number.isFinite(n))return n.toString(this.base)}if(this.powerForm){let n=Number(i);if(i.trim()!==""&&Number.isFinite(n))return Sn(n)}return i}calculate(){return this.context.variables.find(e=>e.identifier===this.identifier)||null}};fe([p({type:String})],vt.prototype,"identifier",void 0);fe([p({type:String})],vt.prototype,"format",void 0);fe([p({type:Number})],vt.prototype,"base",void 0);fe([p({type:Number})],vt.prototype,"index",void 0);fe([p({type:Boolean,attribute:"power-form"})],vt.prototype,"powerForm",void 0);fe([p({type:String})],vt.prototype,"field",void 0);fe([p({type:String})],vt.prototype,"delimiter",void 0);fe([p({type:String,attribute:"mapping-indicator"})],vt.prototype,"mappingIndicator",void 0);fe([_({context:F,subscribe:!0}),T()],vt.prototype,"context",void 0);var la=class extends E{getResult(){return this.getVariables().reduce((i,n)=>{if(n.baseType=="float"||n.baseType=="integer")try{return i*parseFloat(n.value.toString())}catch{console.warn("can not convert to number")}else console.warn(`has another baseType ${n.baseType}`);return i},1)}};var Ql=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},ki=class extends E{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 t=[],e=0;for(;;){let n=this.min+this.step*e;if(n>this.max)break;Number.isInteger(n)&&t.push(n),e++}if(t.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()*t.length);return t[i]}getPossibleValues(){let t=[];if(this.min>this.max||this.step<=0)return[Number.isInteger(this.min)?this.min:Math.floor(this.min)];let e=0;for(;;){let i=this.min+this.step*e;if(i>this.max)break;Number.isInteger(i)&&t.push(i),e++}return t.length>0?t:[Number.isInteger(this.min)?this.min:Math.floor(this.min)]}};Ql([p({type:Number})],ki.prototype,"min",void 0);Ql([p({type:Number})],ki.prototype,"max",void 0);Ql([p({type:Number})],ki.prototype,"step",void 0);var ca=class extends E{getResult(){let t=this.getVariables();if(t.length===1){let e=t[0].value;if(Array.isArray(e)){let i=Math.floor(Math.random()*e.length);return e[i]}return e}return console.error("unexpected number of children in match"),null}};var _f=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},Xl=1e3,En=class extends E{constructor(){super(...arguments),this.numberRepeats=""}getResult(){let t=this.#t();if(t<=0)return[];let e=this.firstElementChild;if(!e)return console.warn("qti-repeat: missing child expression"),[];let i=[];for(let n=0;n<t;n++){let r=e.calculate(),s=this.#i(r);s&&i.push(s)}return i}#t(){if(!this.numberRepeats)return console.warn("qti-repeat: missing number-repeats attribute"),0;let t=parseInt(this.numberRepeats,10);if(!Number.isNaN(t))return this.#e(t);let e=this.numberRepeats,i=this.context?.variables?.find(s=>s.identifier===e);if(!i)return console.warn(`qti-repeat: unknown identifier "${e}"`),0;let n=Array.isArray(i.value)?i.value[0]:i.value,r=parseInt(n?.toString()??"",10);return Number.isNaN(r)?(console.warn(`qti-repeat: invalid repeat count from "${e}"`),0):this.#e(r)}#e(t){return t>Xl?(console.warn(`qti-repeat: number-repeats ${t} exceeds the ${Xl} limit, truncating`),Xl):t}#i(t){if(t==null)return null;if(typeof t=="number")return{identifier:"",cardinality:"single",baseType:Number.isInteger(t)?"integer":"float",value:t.toString(),type:"response"};if(typeof t=="string"){let e=parseFloat(t);if(!Number.isNaN(e))return{identifier:"",cardinality:"single",baseType:Number.isInteger(e)?"integer":"float",value:t.toString(),type:"response"}}if(t&&typeof t=="object"&&"value"in t){let e=t.value;return{identifier:"",cardinality:"single",baseType:t.baseType??"string",value:e!=null?e.toString():null,type:"response"}}return{identifier:"",cardinality:"single",baseType:"string",value:t.toString(),type:"response"}}};_f([p({type:String,attribute:"number-repeats"})],En.prototype,"numberRepeats",void 0);var da=class extends hr{};var ur=class extends dr{};var ha=class extends ur{};var pa=class extends cr{};var ua=class extends Y{process(){for(let t of[...this.children])t.process()}};var Qp=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},mr=class extends E{constructor(){super(...arguments),this.roundingMode="significantFigures",this.figures=3}get resultBaseType(){return"float"}getResult(){if(this.children.length!==1)return console.error("qti-round-to must have exactly one child expression"),null;let t=this.getVariables();if(!t||t.length===0)return null;let e=t[0];if(e.cardinality!=="single")return console.error("qti-round-to requires single cardinality"),null;if(Array.isArray(e.value))return console.error("qti-round-to 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-to requires numerical base-type"),null;let i=parseFloat(e.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.#t(i,this.figures):this.#e(i,this.figures):i===1/0?1/0:i===-1/0?-1/0:null}#t(t,e){if(t===0)return 0;let i=Math.pow(10,e);return Math.round(t*i)/i}#e(t,e){if(t===0)return 0;let i=Math.floor(Math.log10(Math.abs(t))),n=Math.pow(10,e-i-1);return Math.round(t*n)/n}};Qp([p({type:String,attribute:"rounding-mode"})],mr.prototype,"roundingMode",void 0);Qp([p({type:Number})],mr.prototype,"figures",void 0);var ma=class extends E{get resultBaseType(){return"integer"}getResult(){if(this.children.length!==1)return console.error("qti-round must have exactly one child expression"),null;let t=this.getVariables();if(!t||t.length===0)return null;let e=t[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 i=parseFloat(e.value);return isNaN(i)?(console.warn("qti-round: NaN input results in NULL"),null):isFinite(i)?Math.floor(i+.5):i===1/0?1/0:i===-1/0?-1/0:null}};var fa=class extends Y{process(){let t=this.getAttribute("identifier");if(!t){console.warn('QtiSetCorrectResponse: Missing "identifier" attribute.');return}let e=this.firstElementChild;if(!e){console.warn("QtiSetCorrectResponse: No expression found.");return}let n=new Gl(e).process();this.dispatchEvent(new CustomEvent("qti-set-correct-response",{bubbles:!0,composed:!0,detail:{responseIdentifier:t,value:this.#t(n)}}))}#t(t){return t==null?null:Array.isArray(t)?t.map(e=>Rt(this.#e(e))):Rt(this.#e(t))}#e(t){if(t&&typeof t=="object"&&"value"in t){let e=t.value;return e!=null?e.toString():""}return t?.toString()??""}},Gl=class{constructor(t){this.expression=t}process(){let t=this.expression.calculate()??null;return t===null&&console.warn("QtiSetCorrectResponseRule: Evaluated value is null."),Array.isArray(t)?t.map(e=>this.#t(e)):this.#t(t)}#t(t){return t&&typeof t=="object"&&"value"in t?t.value:t}};var ga=class extends Y{process(){let t=this.getAttribute("identifier");if(!t){console.warn('QtiSetOutcomeValue: Missing "identifier" attribute.');return}let e=this.firstElementChild;if(!e){console.warn("QtiSetOutcomeValue: No expression found.");return}let n=new Yl(e).process();this.dispatchEvent(new CustomEvent("qti-set-outcome-value",{bubbles:!0,composed:!0,detail:{outcomeIdentifier:t,value:this.#t(n)}}))}#t(t){return Array.isArray(t)?t.map(Rt):t!==null?Rt(t):null}},Yl=class{constructor(t){this.expression=t}process(){let t=this.expression.calculate()??null;return t===null&&console.warn("QtiSetOutcomeValueRule: Evaluated value is null."),Array.isArray(t)?t.map(e=>e.value?e.value:e):t}};var ba=class extends Y{process(){let t=this.getAttribute("identifier");if(!t){console.warn('QtiSetTemplateValue: Missing "identifier" attribute.');return}let e=this.firstElementChild;if(!e){console.warn("QtiSetTemplateValue: No expression found.");return}let n=new Jl(e).process();this.dispatchEvent(new CustomEvent("qti-set-template-value",{bubbles:!0,composed:!0,detail:{templateIdentifier:t,value:this.#t(n)}}))}#t(t){return t==null?null:Array.isArray(t)?t.map(e=>Rt(this.#e(e))):Rt(this.#e(t))}#e(t){if(t&&typeof t=="object"&&"value"in t){let e=t.value;return e!=null?e.toString():""}return t?.toString()??""}},Jl=class{constructor(t){this.expression=t}process(){let t=this.expression.calculate()??null;return t===null&&console.warn("QtiSetTemplateValueRule: Evaluated value is null."),Array.isArray(t)?t.map(e=>this.#t(e)):this.#t(t)}#t(t){return t&&typeof t=="object"&&"value"in t?t.value:t}};var Tf=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},An=class extends E{constructor(){super(...arguments),this.name=""}get resultBaseType(){return"float"}getResult(){if(!this.name)return console.warn("qti-stats-operator: missing name attribute"),null;let t=this.#r(this.getVariables());if(t.length===0)return console.warn("qti-stats-operator: no numeric values provided"),null;switch(this.name.toLowerCase()){case"mean":return this.#t(t);case"median":return this.#e(t);case"popvariance":return this.#i(t,t.length);case"popsd":return Math.sqrt(this.#i(t,t.length));case"samplevariance":return t.length<2?null:this.#i(t,t.length-1);case"samplesd":return t.length<2?null:Math.sqrt(this.#i(t,t.length-1));default:return console.warn(`qti-stats-operator: unsupported operator "${this.name}"`),null}}#t(t){return t.reduce((e,i)=>e+i,0)/t.length}#e(t){let e=[...t].sort((n,r)=>n-r),i=Math.floor(e.length/2);return e.length%2===0?(e[i-1]+e[i])/2:e[i]}#i(t,e){let i=this.#t(t);return t.reduce((n,r)=>n+Math.pow(r-i,2),0)/e}#r(t){let e=[];for(let i of t){if(!i)continue;let n=r=>{if(r==null)return;let s=parseFloat(r.toString());if(Number.isNaN(s)){console.warn("qti-stats-operator: non-numeric value encountered");return}e.push(s)};if(Array.isArray(i.value)){i.value.forEach(r=>n(r));continue}n(i.value)}return e}};Tf([p({type:String})],An.prototype,"name",void 0);var Rf=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},In=class extends E{constructor(){super(...arguments),this.caseSensitive="true"}getResult(){if(this.children.length===2){let t=this.getVariables(),e=t[0],i=t[1];if(e.cardinality!=="single"||i.cardinality!=="single"||Array.isArray(e.value)||Array.isArray(i.value))return console.error("unexpected cardinality in qti string-match"),!1;let n=this.caseSensitive==="true"?e.value:e.value.toLowerCase(),r=this.caseSensitive==="true"?i.value:i.value.toLowerCase();return J.compareSingleValues(n,r,e.baseType)}return console.error("unexpected number of children in qti-string-match"),null}};Rf([p({type:String,attribute:"case-sensitive"})],In.prototype,"caseSensitive",void 0);var Pf=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},_n=class extends E{constructor(){super(...arguments),this.caseSensitive="true"}getResult(){let t=this.getVariables();if(t.length!==2)return console.error("qti-substring requires exactly 2 child expressions"),null;let[e,i]=t;if(e.cardinality!=="single"||i.cardinality!=="single"||Array.isArray(e.value)||Array.isArray(i.value))return console.error("qti-substring requires single cardinality"),null;if(e.value===null||i.value===null||e.value===void 0||i.value===void 0)return null;let n=e.value.toString(),r=i.value.toString();return this.caseSensitive!=="true"?r.toLowerCase().includes(n.toLowerCase()):r.includes(n)}};Pf([p({type:String,attribute:"case-sensitive"})],_n.prototype,"caseSensitive",void 0);var ya=class extends Of(E){getResult(){return this.calculateChildren(Array.from(this.children))}};function Of(o){return class extends o{calculateChildren(e){let i=e.map(n=>{if(!n.calculate)return console.error("Element doesn't implement QtiConditionExpression"),null;let r=n.calculate();return Number.isNaN(r)?(console.error("Unexpected value in qti-subtract, expected number"),null):Number(r)});return i.some(n=>n===null)?(console.error("One or more child expressions returned invalid values"),0):i[0]-i[1]}}}var va=class extends E{getResult(){return new Kl(Array.from(this.children)).calculate()}},Kl=class{constructor(t){this.expressions=t}calculate(){return this.expressions.filter(i=>i.calculate!==void 0).some(i=>i.calculate()===null)?null:this.expressions.map(i=>{let n=i.calculate();return Number.isNaN(n)?(console.error("unexpected value in qti-sum, expected number"),null):Number(n)}).reduce((i,n)=>i+n,0)}};var wa=class extends E{get resultBaseType(){return"integer"}getResult(){let t=this.getVariables();if(t.length!==1)return console.error("qti-truncate requires exactly one child expression"),null;let e=t[0];if(e.cardinality!=="single"||Array.isArray(e.value))return console.error("qti-truncate requires single cardinality"),null;if(e.baseType!=="integer"&&e.baseType!=="float")return console.error("qti-truncate requires numerical base-type"),null;if(e.value===null||e.value===void 0)return null;let i=Number.parseFloat(e.value);return Number.isNaN(i)?(console.error("qti-truncate requires a numerical value"),null):Math.trunc(i)}};var xa=class extends E{getResult(){let t=this.getAttribute("identifier")||"";return this.resolveVariable(t)?.value??null}};var Xp=[{tag:"qti-and",ctor:As},{tag:"qti-any-n",ctor:or},{tag:"qti-base-value",ctor:bn},{tag:"qti-container-size",ctor:Is},{tag:"qti-contains",ctor:_s},{tag:"qti-correct",ctor:Ts},{tag:"qti-default",ctor:Ci},{tag:"qti-delete",ctor:Rs},{tag:"qti-divide",ctor:Ps},{tag:"qti-duration-gte",ctor:Os},{tag:"qti-duration-lt",ctor:Ms},{tag:"qti-equal",ctor:sr},{tag:"qti-equal-rounded",ctor:yn},{tag:"qti-exit-response",ctor:Ds},{tag:"qti-exit-test",ctor:Ns},{tag:"qti-field-value",ctor:$s},{tag:"qti-gcd",ctor:Ls},{tag:"qti-gt",ctor:Vs},{tag:"qti-gte",ctor:zs},{tag:"qti-index",ctor:vn},{tag:"qti-inside",ctor:ar},{tag:"qti-integer-divide",ctor:js},{tag:"qti-integer-modulus",ctor:Fs},{tag:"qti-integer-to-float",ctor:Bs},{tag:"qti-is-null",ctor:Us},{tag:"qti-lcm",ctor:Hs},{tag:"qti-lookup-outcome-value",ctor:lr},{tag:"qti-lt",ctor:Ws},{tag:"qti-lte",ctor:Qs},{tag:"qti-map-response",ctor:xn},{tag:"qti-map-response-point",ctor:wn},{tag:"qti-match",ctor:Xs},{tag:"qti-math-constant",ctor:qn},{tag:"qti-math-operator",ctor:Cn},{tag:"qti-max",ctor:Gs},{tag:"qti-member",ctor:Ys},{tag:"qti-min",ctor:Js},{tag:"qti-multiple",ctor:Ks},{tag:"qti-not",ctor:Zs},{tag:"qti-null",ctor:ta},{tag:"qti-or",ctor:ea},{tag:"qti-ordered",ctor:ia},{tag:"qti-outcome-condition",ctor:na},{tag:"qti-outcome-else",ctor:sa},{tag:"qti-outcome-else-if",ctor:oa},{tag:"qti-outcome-if",ctor:pr},{tag:"qti-pattern-match",ctor:kn},{tag:"qti-power",ctor:aa},{tag:"qti-printed-variable",ctor:vt},{tag:"qti-product",ctor:la},{tag:"qti-random",ctor:ca},{tag:"qti-random-integer",ctor:ki},{tag:"qti-repeat",ctor:En},{tag:"qti-response-condition",ctor:da},{tag:"qti-response-else",ctor:pa},{tag:"qti-response-else-if",ctor:ha},{tag:"qti-response-if",ctor:ur},{tag:"qti-response-processing-fragment",ctor:ua},{tag:"qti-round",ctor:ma},{tag:"qti-round-to",ctor:mr},{tag:"qti-rule",ctor:Y},{tag:"qti-set-correct-response",ctor:fa},{tag:"qti-set-outcome-value",ctor:ga},{tag:"qti-set-template-value",ctor:ba},{tag:"qti-stats-operator",ctor:An},{tag:"qti-string-match",ctor:In},{tag:"qti-substring",ctor:_n},{tag:"qti-subtract",ctor:ya},{tag:"qti-sum",ctor:va},{tag:"qti-truncate",ctor:wa},{tag:"qti-variable",ctor:xa}];for(let{tag:o,ctor:t}of Xp)customElements.get(o)||customElements.define(o,t);var ge=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},tt;(function(o){o.Correct="correct",o.PartiallyCorrect="partially-correct",o.Incorrect="incorrect"})(tt||(tt={}));var Zl=o=>{class t extends o{constructor(){super(...arguments),this.showCorrectResponse=!1,this._handleShowCorrectResponseChange=(i,n)=>{this.toggleInternalCorrectResponse(n)},this.showFullCorrectResponse=!1,this._handleShowFullCorrectResponseChange=(i,n)=>{this.toggleFullCorrectResponse(n)},this.showCandidateCorrection=!1,this._handleShowCandidateCorrectionChange=(i,n)=>{this.toggleCandidateCorrection(n)},this._correctResponse=null}set correctResponseAttr(i){this._correctResponse=i}get correctResponseAttr(){return this._correctResponse}get isFullCorrectResponse(){return this._isFullCorrectResponse}get registersWithItem(){return!this.isFullCorrectResponse&&super.registersWithItem}set isFullCorrectResponse(i){this._isFullCorrectResponse=i,i&&(this.setAttribute("inert",""),this.setAttribute("response-identifier",this.responseIdentifier+"_cr"),this.setAttribute("answer-key",""))}get correctResponse(){let i=this.responseVariable;return i?.correctResponse?i.correctResponse:this._correctResponse}set correctResponse(i){let n=this._correctResponse;this._correctResponse=i,i==null?this.removeAttribute("correct-response"):this.setAttribute("correct-response",Array.isArray(i)?i.join(","):i),this.requestUpdate("_correctResponse",n)}get correctness(){let i=this.correctResponse;if(!i)return null;let n=this.response;if(n==null||n===""||Array.isArray(n)&&n.length===0)return null;let r=Array.isArray(i)?i:[i],a=(Array.isArray(n)?n:[n]).filter(d=>d!=="");if(a.length===0)return null;let l=a.filter(d=>r.includes(d)).length,c=a.filter(d=>!r.includes(d)).length;return l===r.length&&c===0&&a.length===r.length?tt.Correct:l>0&&(l<r.length||c>0)?tt.PartiallyCorrect:tt.Incorrect}get correctionPart(){return"correction"}toggleCorrectResponse(i){(this.configContext?.correctResponseMode||"internal")==="full"?this.toggleFullCorrectResponse(i):this.toggleInternalCorrectResponse(i)}get withholdsFullCorrectResponseWhenCorrect(){return this.configContext?.fullCorrectResponseOnlyWhenIncorrect!==!1}async toggleFullCorrectResponse(i){let n=this.nextSibling,r=n instanceof HTMLDivElement&&n?.classList.contains("full-correct-response"),s=this.correctResponse;if(!s)return;if(!(i&&(!this.withholdsFullCorrectResponseWhenCorrect||this.correctness!==tt.Correct))){if(!r)return;this.parentElement?.removeChild(n);return}if(r)return;let l=this.cloneNode(!0);l.removeAttribute("show-full-correct-response"),l.removeAttribute("show-correct-response"),l.removeAttribute("show-candidate-correction");let c=document.createElement("div");c.classList.add("full-correct-response"),this.isInline?c.classList.add("full-correct-response-inline"):c.classList.add("full-correct-response-block"),c.role="full-correct-response",c.appendChild(l),l.isFullCorrectResponse=!0,this.parentElement?.insertBefore(c,this.nextSibling),await l.updateComplete,l.response=Array.isArray(s)?[...s]:s}toggleInternalCorrectResponse(i){this._internals.states.delete("show-correct-response"),i&&this.correctResponse&&this._internals.states.add("show-correct-response")}toggleCandidateCorrection(i){}firstUpdated(){super.firstUpdated(),!this.isFullCorrectResponse&&(this.showCorrectResponse&&this.toggleInternalCorrectResponse(!0),this.showFullCorrectResponse&&this.toggleFullCorrectResponse(!0))}}return ge([p({attribute:"correct-response",reflect:!0,converter:Xt({emptyAs:null})})],t.prototype,"correctResponseAttr",null),ge([p({type:Boolean,attribute:"show-correct-response",reflect:!0})],t.prototype,"showCorrectResponse",void 0),ge([L("showCorrectResponse",{waitUntilFirstUpdate:!0})],t.prototype,"_handleShowCorrectResponseChange",void 0),ge([p({type:Boolean,attribute:"show-full-correct-response",reflect:!0})],t.prototype,"showFullCorrectResponse",void 0),ge([L("showFullCorrectResponse",{waitUntilFirstUpdate:!0})],t.prototype,"_handleShowFullCorrectResponseChange",void 0),ge([p({type:Boolean,attribute:"show-candidate-correction",reflect:!0})],t.prototype,"showCandidateCorrection",void 0),ge([L("showCandidateCorrection",{waitUntilFirstUpdate:!0})],t.prototype,"_handleShowCandidateCorrectionChange",void 0),ge([T()],t.prototype,"_isFullCorrectResponse",void 0),ge([T()],t.prototype,"_correctResponse",void 0),t};var ht=q`
9678
+ `}async#i(t){let e=t.target;e.files&&e.files.length>0&&(this.#t=e.files[0],this.#e=await this.#r(this.#t),this.saveResponse(this.#e),this.dispatchEvent(new CustomEvent("qti-interaction-response",{detail:{response:this.#e}})))}#r(t){return new Promise((e,i)=>{let n=new FileReader;n.onload=()=>e(n.result),n.onerror=()=>i(n.error),n.readAsDataURL(t)})}};var Es=[{tag:"qti-upload-interaction",ctor:ks}];var Vp=[...Ko,...Zo,...ts,...is,...rs,...ns,...ss,...as,...ls,...cs,...ds,...hs,...ps,...ms,...fs,...bs,...ws,...qs,...Cs,...Ss,...Es,...zh];for(let{tag:o,ctor:t}of Vp)customElements.get(o)||customElements.define(o,t);for(let{tag:o,ctor:t}of Ko)customElements.get(o)||customElements.define(o,t);for(let{tag:o,ctor:t}of Zo)customElements.get(o)||customElements.define(o,t);for(let{tag:o,ctor:t}of ts)customElements.get(o)||customElements.define(o,t);for(let{tag:o,ctor:t}of is)customElements.get(o)||customElements.define(o,t);for(let{tag:o,ctor:t}of rs)customElements.get(o)||customElements.define(o,t);for(let{tag:o,ctor:t}of ns)customElements.get(o)||customElements.define(o,t);for(let{tag:o,ctor:t}of ss)customElements.get(o)||customElements.define(o,t);for(let{tag:o,ctor:t}of as)customElements.get(o)||customElements.define(o,t);for(let{tag:o,ctor:t}of ls)customElements.get(o)||customElements.define(o,t);for(let{tag:o,ctor:t}of cs)customElements.get(o)||customElements.define(o,t);for(let{tag:o,ctor:t}of ds)customElements.get(o)||customElements.define(o,t);for(let{tag:o,ctor:t}of hs)customElements.get(o)||customElements.define(o,t);for(let{tag:o,ctor:t}of ps)customElements.get(o)||customElements.define(o,t);for(let{tag:o,ctor:t}of ms)customElements.get(o)||customElements.define(o,t);for(let{tag:o,ctor:t}of fs)customElements.get(o)||customElements.define(o,t);for(let{tag:o,ctor:t}of bs)customElements.get(o)||customElements.define(o,t);for(let{tag:o,ctor:t}of ws)customElements.get(o)||customElements.define(o,t);for(let{tag:o,ctor:t}of qs)customElements.get(o)||customElements.define(o,t);for(let{tag:o,ctor:t}of Cs)customElements.get(o)||customElements.define(o,t);for(let{tag:o,ctor:t}of Ss)customElements.get(o)||customElements.define(o,t);for(let{tag:o,ctor:t}of Es)customElements.get(o)||customElements.define(o,t);var I3=async o=>{let t=o.substring(0,o.lastIndexOf("/")),e=await Td().load(`${o}`).then(a=>a.assessmentTest()),i=await Bi().load(`${t}/${e.href}`).then(a=>a.htmlDoc()),n=await Bi().load(`${t}/${e.href}`).then(a=>a.items()),r=`${t}/${e.href}`,s=`${t}/${e.href.substring(0,e.href.lastIndexOf("/"))}`;return{testHTMLDoc:i,testURI:s,testURL:r,items:n,testIdentifier:e.identifier}},_3=async o=>Xt().load(o).then(t=>t.htmlDoc().firstElementChild);var As=class extends bf(Qt){calculate(){return this.calculateChildren(Array.from(this.children))}};function bf(o){return class extends o{calculateChildren(e){return e.map(n=>{let r=n;if(!r.calculate)return console.error("Element doesn't implement QtiConditionExpression"),null;let s=r.calculate(),a=!1;if(typeof s=="string")if(s==="true")a=!0;else if(s==="false")a=!1;else return console.error("unexpected val in qti-or, expected boolean"),null;else typeof s=="boolean"&&(a=s);return a}).every(n=>typeof n=="boolean"&&n)}}}var zp=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},or=class extends E{constructor(){super(...arguments),this.min=0,this.max=1/0}getResult(){let t=this.getVariables();if(!t||t.length===0)return console.error("qti-any-n requires at least one child expression"),null;if(this.min<0||this.max<this.min)return console.error("qti-any-n requires 0 <= min <= max"),null;let e=0;for(let i of t){if(i.cardinality!=="single"||Array.isArray(i.value))return console.error("qti-any-n requires single cardinality boolean expressions"),null;if(i.baseType!=="boolean")return console.error("qti-any-n requires boolean base-type"),null;if(i.value===null||i.value===void 0)return null;i.value==="true"&&e++}return e>=this.min&&e<=this.max}};zp([p({type:Number})],or.prototype,"min",void 0);zp([p({type:Number})],or.prototype,"max",void 0);var yf=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},bn=class extends E{constructor(){super(...arguments),this.baseType="string"}getResult(){return this.textContent.trim()}};yf([p({type:String,attribute:"base-type"})],bn.prototype,"baseType",void 0);var Is=class extends E{get resultBaseType(){return"integer"}getResult(){if(this.children?.length!==1)return console.error("qti-container-size must have exactly one child expression"),0;let t=this.getVariables();if(!t||t?.length===0)return 0;let e=t[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)}};var _s=class extends E{getResult(){if(this.children.length!==2)return console.error("qti-contains takes two sub-expressions"),null;let[t,e]=this.getVariables();if(!t||!e||t.value===null||t.value===void 0||e.value===null||e.value===void 0)return null;t.baseType!==e.baseType&&console.warn("qti-contains: both sub-expressions should have the same base-type");let i=t.baseType??e.baseType;if(t.cardinality==="single"&&e.cardinality!=="single")return console.warn("qti-contains: first sub-expression is single; treating it as a membership test"),this.#t(e.value).some(s=>this.#e(s,t.value,i));let n=this.#t(t.value),r=this.#t(e.value);return r.length===0?!0:t.cardinality==="ordered"&&e.cardinality==="ordered"?this.#r(n,r,i):this.#i(n,r,i)}#t(t){return Array.isArray(t)?[...t]:[t]}#e(t,e,i){return J.compareSingleValues(t,e,i)||t===e}#i(t,e,i){let n=[...t];return e.every(r=>{let s=n.findIndex(a=>this.#e(a,r,i));return s===-1?!1:(n.splice(s,1),!0)})}#r(t,e,i){for(let n=0;n+e.length<=t.length;n++)if(e.every((r,s)=>this.#e(t[n+s],r,i)))return!0;return!1}};var Ts=class extends E{get interpretation(){return this.getAttribute("interpretation")||""}getResult(){let t=this.getAttribute("identifier")||"",e=this.context.variables.find(i=>i.identifier===t)||null;return e.cardinality!=="single"?e.correctResponse.length>0?e.correctResponse[0]:"":e.correctResponse}};var Wl=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},Si=class extends E{constructor(){super(...arguments),this.identifier=""}getResult(){if(!this.identifier)return console.error("qti-default requires an identifier attribute"),null;let t=this.identifier.split("."),e=null,i;if(t.length===2)e=t[0],i=t[1];else if(t.length===1)i=t[0];else return console.error("qti-default: invalid identifier format"),null;if(e){let r=this._testContext.items.find(a=>a.identifier===e);if(!this._testContext||!r)return console.warn(`qti-default: item "${e}" not found in test context`),null;let s=this._testContext.items.find(a=>a.identifier===e)?.variables.find(a=>a.identifier===i);return s?s.defaultValue||null:(console.warn(`qti-default: variable "${i}" not found in item "${e}"`),null)}if(!this.context?.variables)return console.warn("qti-default: no variables found in item context"),null;let n=this.context.variables.find(r=>r.identifier===i);return n?n.defaultValue||null:(console.warn(`qti-default: variable "${i}" not found in item context`),null)}};Wl([p({type:String})],Si.prototype,"identifier",void 0);Wl([_({context:F,subscribe:!0}),T()],Si.prototype,"context",void 0);Wl([T(),_({context:nt,subscribe:!0})],Si.prototype,"_testContext",void 0);var Rs=class extends E{getResult(){if(this.children.length===2){let t=this.getVariables(),e=t[0],i=t[1];return e.cardinality!=="single"||!Array.isArray(i.value)?(console.error("unexpected cardinality in qti equal"),null):t[0].baseType!==t[1].baseType?(console.error("The baseType of the two variables is different"),null):i.value.filter(r=>!e.value.includes(r))}return null}};var Ps=class extends E{get resultBaseType(){return"float"}getResult(){let t=this.#t(this.getVariables());return t.length!==2?(console.warn("qti-divide: expected exactly 2 numeric values"),null):t[1]===0?(console.warn("qti-divide: division by zero"),null):t[0]/t[1]}#t(t){let e=[];for(let i of t){if(!i)continue;let n=r=>{if(r==null)return;let s=parseFloat(r.toString());if(Number.isNaN(s)){console.warn("qti-divide: non-numeric value encountered");return}e.push(s)};if(Array.isArray(i.value)){i.value.forEach(r=>n(r));continue}n(i.value)}return e}};var Os=class extends E{getResult(){let t=this.#t();return t?t[0]>=t[1]:null}#t(){let t=this.getVariables();if(t.length!==2)return console.error("qti-duration-gte requires exactly 2 duration expressions"),null;let e=t.map(i=>this.#e(i));return e.some(i=>i===null)?null:e}#e(t){if(t.cardinality!=="single"||Array.isArray(t.value))return console.error("qti-duration-gte requires single cardinality"),null;if(t.baseType!=="duration")return console.error("qti-duration-gte requires duration base-type"),null;if(t.value===null||t.value===void 0)return null;let e=Number.parseFloat(t.value.toString());return Number.isNaN(e)?(console.error(`qti-duration-gte requires duration values expressed in seconds, got "${t.value.toString()}"`),null):e}};var Ms=class extends E{getResult(){let t=this.#t();return t?t[0]<t[1]:null}#t(){let t=this.getVariables();if(t.length!==2)return console.error("qti-duration-lt requires exactly 2 duration expressions"),null;let e=t.map(i=>this.#e(i));return e.some(i=>i===null)?null:e}#e(t){if(t.cardinality!=="single"||Array.isArray(t.value))return console.error("qti-duration-lt requires single cardinality"),null;if(t.baseType!=="duration")return console.error("qti-duration-lt requires duration base-type"),null;if(t.value===null||t.value===void 0)return null;let e=Number.parseFloat(t.value.toString());return Number.isNaN(e)?(console.error(`qti-duration-lt requires duration values expressed in seconds, got "${t.value.toString()}"`),null):e}};var vf=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},yn=class extends E{constructor(){super(...arguments),this.roundingMode="significantFigures"}get figures(){if(!this.getAttribute("figures"))return console.error("figures attribute is missing"),null;let e=parseInt(this.getAttribute("figures")||"0");return isNaN(e)?(console.error("figures attribute is not a number"),null):e<0?(console.error("figures attribute is negative"),null):e<1&&this.roundingMode==="significantFigures"?(console.error("figures cannot be smaller than 1 for RoundingMode significantFigures"),null):e}getResult(){if(this.children.length===2){let t=this.getVariables(),e=t[0],i=t[1];if(this.roundingMode===null)return null;if(e.cardinality!=="single"||i.cardinality!=="single"||Array.isArray(e.value)||Array.isArray(i.value))return console.error("unexpected cardinality in qti equal"),!1;switch(t[0].baseType){case"integer":case"float":{let n=parseFloat(e.value),r=parseFloat(i.value);if(!isNaN(n)&&!isNaN(r))return this.roundingMode==="significantFigures"?n.toPrecision(this.figures)===r.toPrecision(this.figures):Math.round(n*Math.pow(10,this.figures))/Math.pow(10,this.figures)===Math.round(r*Math.pow(10,this.figures))/Math.pow(10,this.figures);console.error(`value cannot be casted to numeric value in equalRounded operator: ${n}, ${r}`);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}};vf([p({type:String,attribute:"rounding-mode"})],yn.prototype,"roundingMode",void 0);var jp=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},sr=class extends E{constructor(){super(...arguments),this.toleranceMode="exact",this.tolerance=""}get includeLowerBound(){return this.getAttribute("include-lower-bound")!=="false"}get includeUpperBound(){return this.getAttribute("include-upper-bound")!=="false"}getResult(){if(this.children.length===2){let t=this.getVariables(),e=t[0],i=t[1];return!e||!i?null:e.cardinality!=="single"||i.cardinality!=="single"||Array.isArray(e.value)||Array.isArray(i.value)?(console.error("unexpected cardinality in qti equal"),!1):e.value===null||i.value===null||e.value===void 0||i.value===void 0?null:this.toleranceMode==="exact"?J.compareSingleValues(e.value,i.value,e.baseType):this.#t(parseFloat(e.value),parseFloat(i.value))}return console.error("unexpected number of children in qti-equal"),null}#t(t,e){if(Number.isNaN(t)||Number.isNaN(e))return console.error("qti-equal with a tolerance needs numeric values"),null;let i=this.tolerance.split(/\s+/).filter(Boolean).map(l=>parseFloat(l));if(i.length===0||i.some(l=>Number.isNaN(l)))return console.error(`qti-equal with tolerance-mode="${this.toleranceMode}" needs a numeric tolerance`),null;let[n,r=n]=i,[s,a]=this.toleranceMode==="absolute"?[e-n,e+r]:[e*(1-n/100),e*(1+r/100)];return(this.includeLowerBound?t>=s:t>s)&&(this.includeUpperBound?t<=a:t<a)}};jp([p({type:String,attribute:"tolerance-mode"})],sr.prototype,"toleranceMode",void 0);jp([p({type:String})],sr.prototype,"tolerance",void 0);var Y=class extends C{render(){return b`<slot></slot>`}process(){throw new Error("Not implemented")}};var Ds=class extends Y{process(){throw new Oi}};var Ns=class extends Y{process(){throw new Mi}};var $s=class extends E{getResult(){let t=this.getAttribute("field-identifier");if(!t)return console.error("qti-field-value requires a field-identifier attribute"),null;if(this.children.length!==1)return console.error("qti-field-value must have exactly one child expression"),null;let e=this.getVariables()[0];if(!e||e.baseType!=="record"||e.value===null||e.value===void 0)return console.warn("qti-field-value child expression must return a record"),null;let i=e.value[t];return i===void 0?null:i}};var Ls=class extends E{getResult(){if(this.children.length===0)return console.error("qti-gcd must have at least one child expression"),null;let t=this.getVariables();if(!t||t.length===0)return null;let e=[];for(let i of t){if(i.baseType!=="integer")return console.error("qti-gcd requires integer base-type"),null;if(i.value===null||i.value===void 0)return null;if(i.cardinality==="single"){if(Array.isArray(i.value))return console.error("qti-gcd unexpected array value for single cardinality"),null;let n=parseInt(i.value,10);if(isNaN(n))return console.error("qti-gcd non-numerical value"),null;e.push(n)}else if(i.cardinality==="multiple"||i.cardinality==="ordered"){if(!Array.isArray(i.value))return console.error("qti-gcd expected array value for multiple/ordered cardinality"),null;for(let n of i.value){if(n==null)return null;let r=parseInt(n,10);if(isNaN(r))return console.error("qti-gcd non-numerical value"),null;e.push(r)}}else return console.error("qti-gcd unsupported cardinality"),null}return e.length===0?null:this.#t(e)}#t(t){if(t.length===0)return 0;if(t.length===1)return Math.abs(t[0]);let e=Math.abs(t[0]);for(let i=1;i<t.length&&(e=this.#e(e,Math.abs(t[i])),e!==1);i++);return e}#e(t,e){if(t===0&&e===0)return 0;if(t===0)return e;if(e===0)return t;for(;e!==0;){let i=e;e=t%e,t=i}return t}};var Vs=class extends E{getResult(){if(this.children.length===2){let t=this.getVariables(),e=t[0],i=t[1];if((e.baseType==="integer"||e.baseType==="float")&&(i.baseType==="integer"||i.baseType==="float"))return+e.value>+i.value;console.error("unexpected baseType or cardinality in qti gt")}return console.error("unexpected number of children in qt"),null}};var zs=class extends Qt{getResult(){if(this.children.length===2){let t=this.getVariables(),e=t[0],i=t[1];return(e.baseType==="integer"||e.baseType==="float")&&(i.baseType==="integer"||i.baseType==="float")?+e.value>=+i.value:(console.error("unexpected baseType or cardinality in qti gte"),null)}return console.error("unexpected number of children in qti gte"),null}};var wf=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},vn=class extends E{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 t=this.getVariables()[0];if(!t)return console.error("qti-index: missing container"),null;let e;if(!isNaN(Number(this.n)))e=Number(this.n);else{let i=this.#t(this.n);if(i===null)return console.error(`qti-index: variable "${this.n}" is not a valid number`),null;e=Number(i)}if(e<=0||!Number.isInteger(e))return console.error("qti-index: index must be a positive integer"),null;if(t.cardinality==="ordered"){let i=Array.isArray(t.value)?t.value:[t.value];return t.value===null||e>i.length?null:i[e-1]}else return console.error("qti-index: child must have ordered cardinality"),null}#t(t){let e=this.context.variables.find(i=>i.identifier===t)?.value;return e===null||isNaN(Number(e))?null:Number(e)}};wf([p({type:String})],vn.prototype,"n",void 0);var Fp=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},ar=class extends E{constructor(){super(...arguments),this.shape="",this.coords=""}getResult(){let t=this.getVariables();if(t.length!==1)return console.error("qti-inside requires exactly one point expression"),null;let e=t[0];if(e.cardinality!=="single"||Array.isArray(e.value))return console.error("qti-inside requires single cardinality"),null;if(e.value===null||e.value===void 0)return null;if(!this.shape||!this.coords)return console.error("qti-inside requires shape and coords attributes"),null;let i=this.#t(e.value.toString()),n=this.#e(this.coords);if(!i||n.length===0)return null;switch(this.shape.toLowerCase()){case"circle":return this.#i(i,n);case"rect":return this.#r(i,n);case"ellipse":return this.#n(i,n);case"poly":case"polygon":return this.#o(i,n);default:return console.error(`qti-inside does not support shape "${this.shape}"`),null}}#t(t){let e=t.split(/[,\s]+/).map(r=>r.trim()).filter(Boolean);if(e.length!==2)return console.error('qti-inside requires a point value formatted as "x y" or "x,y"'),null;let i=Number.parseFloat(e[0]),n=Number.parseFloat(e[1]);return Number.isNaN(i)||Number.isNaN(n)?(console.error("qti-inside requires numeric point coordinates"),null):{x:i,y:n}}#e(t){let e=t.split(",").map(i=>i.trim()).filter(Boolean).map(i=>Number.parseFloat(i));return e.some(i=>Number.isNaN(i))?(console.error("qti-inside requires numeric coords"),[]):e}#i(t,e){if(e.length!==3)return console.error("qti-inside circle requires x,y,r"),null;let[i,n,r]=e;return(t.x-i)**2+(t.y-n)**2<=r**2}#r(t,e){if(e.length!==4)return console.error("qti-inside rect requires left,top,right,bottom"),null;let[i,n,r,s]=e,a=Math.min(i,r),l=Math.max(i,r),c=Math.min(n,s),d=Math.max(n,s);return t.x>=a&&t.x<=l&&t.y>=c&&t.y<=d}#n(t,e){if(e.length!==4)return console.error("qti-inside ellipse requires centerX,centerY,radiusX,radiusY"),null;let[i,n,r,s]=e;return r===0||s===0?!1:(t.x-i)**2/r**2+(t.y-n)**2/s**2<=1}#o(t,e){if(e.length<6||e.length%2!==0)return console.error("qti-inside polygon requires at least 3 coordinate pairs"),null;let i=!1;for(let n=0,r=e.length-2;n<e.length;n+=2){let s=e[n],a=e[n+1],l=e[r],c=e[r+1];a>t.y!=c>t.y&&t.x<(l-s)*(t.y-a)/(c-a||Number.EPSILON)+s&&(i=!i),r=n}return i}};Fp([p({type:String})],ar.prototype,"shape",void 0);Fp([p({type:String})],ar.prototype,"coords",void 0);var js=class extends E{get resultBaseType(){return"integer"}getResult(){let t=this.#t(this.getVariables());return t.length!==2?(console.error("qti-integer-divide requires exactly 2 integer values"),null):t[1]===0?(console.error("qti-integer-divide: division by zero"),null):Math.floor(t[0]/t[1])}#t(t){let e=[];for(let i of t){if(i.baseType!=="integer")return console.error("qti-integer-divide requires integer base-type"),[];if(i.cardinality!=="single"||Array.isArray(i.value))return console.error("qti-integer-divide requires single cardinality"),[];if(i.value===null||i.value===void 0)return[];let n=Number.parseInt(i.value,10);if(Number.isNaN(n))return console.error("qti-integer-divide requires integer values"),[];e.push(n)}return e}};var Fs=class extends E{get resultBaseType(){return"integer"}getResult(){let t=this.#t(this.getVariables());return t.length!==2?(console.error("qti-integer-modulus requires exactly 2 integer values"),null):t[1]===0?(console.error("qti-integer-modulus: division by zero"),null):t[0]-Math.floor(t[0]/t[1])*t[1]}#t(t){let e=[];for(let i of t){if(i.baseType!=="integer")return console.error("qti-integer-modulus requires integer base-type"),[];if(i.cardinality!=="single"||Array.isArray(i.value))return console.error("qti-integer-modulus requires single cardinality"),[];if(i.value===null||i.value===void 0)return[];let n=Number.parseInt(i.value,10);if(Number.isNaN(n))return console.error("qti-integer-modulus requires integer values"),[];e.push(n)}return e}};var Bs=class extends E{get resultBaseType(){return"float"}getResult(){let t=this.getVariables();if(t.length!==1)return console.error("qti-integer-to-float requires exactly one child expression"),null;let e=t[0];if(e.baseType!=="integer")return console.error("qti-integer-to-float requires integer base-type"),null;if(e.cardinality!=="single"||Array.isArray(e.value))return console.error("qti-integer-to-float requires single cardinality"),null;if(e.value===null||e.value===void 0)return null;let i=Number.parseInt(e.value,10);return Number.isNaN(i)?(console.error("qti-integer-to-float requires an integer value"),null):i}};var Us=class extends E{getResult(){if(this.children.length===1){let t=this.getVariables();if(!t?.length)return!0;let e=t[0].value;return e==null||e==null||e===""}return console.error("unexpected number of children in qti Null"),null}};var Hs=class extends E{getResult(){let t=this.#t(this.getVariables());return t.length===0?(console.error("qti-lcm requires at least one integer value"),null):t.reduce((e,i)=>this.#i(e,i))}#t(t){let e=[];for(let i of t){if(i.baseType!=="integer")return console.error("qti-lcm requires integer base-type"),[];if(i.value===null||i.value===void 0)return[];if(i.cardinality==="single"){if(Array.isArray(i.value))return console.error("qti-lcm unexpected array value for single cardinality"),[];let n=Number.parseInt(i.value,10);if(Number.isNaN(n))return console.error("qti-lcm requires integer values"),[];e.push(n);continue}if(i.cardinality!=="multiple"&&i.cardinality!=="ordered")return console.error("qti-lcm unsupported cardinality"),[];if(!Array.isArray(i.value))return console.error("qti-lcm expected array value for container cardinality"),[];for(let n of i.value){let r=Number.parseInt(n,10);if(Number.isNaN(r))return console.error("qti-lcm requires integer values"),[];e.push(r)}}return e}#e(t,e){let i=Math.abs(t),n=Math.abs(e);for(;n!==0;){let r=i%n;i=n,n=r}return i}#i(t,e){return t===0||e===0?0:Math.abs(t*e/this.#e(t,e))}};var Bp=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},lr=class extends Y{get childExpression(){return this.firstElementChild}process(){let t=this.getAttribute("identifier"),e=this.context?.variables.find(r=>r.identifier===t)||null;if(!e)return console.warn(`lookupOutcomeValue: no outcome declaration for "${t}"`),null;let i=parseFloat(this.childExpression.calculate()),n;return e.matchTable?.size?n=e.matchTable.get(i):e.interpolationTable&&(n=this.#t(i,e.interpolationTable)),n==null?(console.warn(`lookupOutcomeValue: no table entry matches ${i} for "${t}"`),null):(this.dispatchEvent(new CustomEvent("qti-set-outcome-value",{bubbles:!0,composed:!0,detail:{outcomeIdentifier:this.identifier,value:Rt(n)}})),n)}#t(t,e){if(!Number.isNaN(t))return e.find(i=>i.includeBoundary?t>=i.sourceValue:t>i.sourceValue)?.targetValue}};Bp([p({type:String})],lr.prototype,"identifier",void 0);Bp([_({context:F,subscribe:!0}),T()],lr.prototype,"context",void 0);var Ws=class extends E{getResult(){if(this.children.length===2){let t=this.getVariables(),e=t[0],i=t[1];if((e.baseType==="integer"||e.baseType==="float")&&(i.baseType==="integer"||i.baseType==="float"))return+e.value<+i.value;console.error("unexpected baseType or cardinality in qti lt")}return console.error("unexpected number of children in lt"),null}};var Qs=class extends Qt{getResult(){if(this.children.length===2){let t=this.getVariables(),e=t[0],i=t[1];return(e.baseType==="integer"||e.baseType==="float")&&(i.baseType==="integer"||i.baseType==="float")?+e.value<=+i.value:(console.error("unexpected baseType or cardinality in qti lte"),null)}return console.error("unexpected number of children in qti lte"),null}};var xf=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},wn=class extends E{getResult(){let t=this.context.variables.find(s=>s.identifier===this.identifier);if(!t)return console.warn(`Response ${this.identifier} cannot be found`),null;let e=t.areaMapping;if(!e)return console.warn(`Area mapping not found for response ${this.identifier}`),null;let i=Array.isArray(t.value)?t.value:[t.value];if(!i||i.length===0)return console.warn(`No candidate responses for response ${this.identifier}`),null;let n=0,r=new Set;for(let s of i)for(let a of e.areaMapEntries){if(r.has(a.coords))continue;if(J.isPointInArea(s,`${a.shape},${a.coords}`,t.baseType)){n+=a.mappedValue??0,r.add(a.coords);break}}return r.size<i.length&&(n+=e.defaultValue),e.lowerBound!=null&&(n=Math.max(e.lowerBound,n)),e.upperBound!=null&&(n=Math.min(e.upperBound,n)),n}};xf([p({type:String})],wn.prototype,"identifier",void 0);var qf=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},xn=class extends E{getResult(){let t=this.context.variables.find(r=>r.identifier===this.identifier);if(!t||!t.mapping)return console.error(`Response ${this.identifier} can not be found`),null;let e=t.mapping,i=Array.isArray(t.value)?t.value:[t.value],n=0;for(let r of i){let s=e.mapEntries.filter(l=>t.baseType==="string"&&!l.caseSensitive?J.compareSingleValues(l.mapKey.toLowerCase(),r.toLowerCase(),t.baseType):J.compareSingleValues(l.mapKey,r,t.baseType)),a=s.reduce((l,c)=>l.mappedValue>c.mappedValue?l:c,s.length>0?s[0]:{mapKey:null,mappedValue:null});a===null||a.mappedValue==null?n+=e.defaultValue:n+=a.mappedValue}return e?.lowerBound!==null&&e?.lowerBound!==void 0&&(n=Math.max(e.lowerBound,n)),e?.upperBound!==null&&e?.upperBound!==void 0&&(n=Math.min(e.upperBound,n)),n}};qf([p({type:String})],xn.prototype,"identifier",void 0);var Gs=class o extends E{getResult(){if(this.children.length===2){let t=this.getVariables(),e=t[0],i=t[1];return o.match(e,i)}return console.error("unexpected number of children in match"),null}static match(t,e){if(t.value===null)return!1;switch(e.cardinality){case"single":return Array.isArray(t.value)||Array.isArray(e.value)?(console.error("unexpected cardinality in qti match"),!1):J.compareSingleValues(t.value?.toString(),e.value.toString(),e.baseType);case"ordered":{if(!Array.isArray(t.value)||!Array.isArray(e.value))return console.error("unexpected cardinality in qti match"),!1;if(t.value.length!==e.value.length)return!1;for(let i=0;i<t.value.length;i++)if(!J.compareSingleValues(e.value[i],t.value[i],e.baseType))return!1;return!0}case"multiple":{if(!Array.isArray(t.value)||!Array.isArray(e.value))return console.error("unexpected cardinality in qti match"),!1;if(t.value.length!==e.value.length)return!1;let i=0;for(let n of e.value){let r=null,s=[...t.value];for(let a of s)if(J.compareSingleValues(n,a,e.baseType)){r=a;break}if(r!==null)s.splice(s.indexOf(r),1);else return!1;i++}return!0}default:return console.error("unexpected cardinality in qti match"),!1}}};var Cf=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},qn=class extends E{constructor(){super(...arguments),this.name=""}get resultBaseType(){return"float"}getResult(){switch(this.name.toLowerCase()){case"pi":return Math.PI;case"e":return Math.E;default:return console.error(`qti-math-constant: unknown constant "${this.name}"`),null}}};Cf([p({type:String})],qn.prototype,"name",void 0);var Sf=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},Cn=class extends E{constructor(){super(...arguments),this.name=""}get resultBaseType(){return["floor","ceil","signum"].includes(this.name?.toLowerCase())?"integer":"float"}getResult(){if(!this.name)return console.error("qti-math-operator requires a name attribute"),null;let t=this.getVariables();if(!t||t.length===0)return null;let e=[];for(let i of t){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 n=parseFloat(i.value);if(isNaN(n))return console.error("qti-math-operator non-numerical value"),null;e.push(n)}return this.#e(this.name,e)}#t(t){return Number.isFinite(t)?t:null}#e(t,e){try{switch(t.toLowerCase()){case"sin":return e.length!==1?null:Math.sin(e[0]);case"cos":return e.length!==1?null:Math.cos(e[0]);case"tan":return e.length!==1?null:Math.tan(e[0]);case"asin":return e.length!==1||e[0]<-1||e[0]>1?null:Math.asin(e[0]);case"acos":return e.length!==1||e[0]<-1||e[0]>1?null:Math.acos(e[0]);case"atan":return e.length!==1?null:Math.atan(e[0]);case"sinh":return e.length!==1?null:Math.sinh(e[0]);case"cosh":return e.length!==1?null:Math.cosh(e[0]);case"tanh":return e.length!==1?null:Math.tanh(e[0]);case"secant":case"sec":return e.length!==1?null:this.#t(1/Math.cos(e[0]));case"cosecant":case"csc":return e.length!==1?null:this.#t(1/Math.sin(e[0]));case"cotangent":case"cot":return e.length!==1?null:this.#t(Math.cos(e[0])/Math.sin(e[0]));case"todegrees":return e.length!==1?null:e[0]*180/Math.PI;case"toradians":return e.length!==1?null:e[0]*Math.PI/180;case"log":return e.length!==1||e[0]<=0?null:Math.log10(e[0]);case"ln":return e.length!==1||e[0]<=0?null:Math.log(e[0]);case"log10":return e.length!==1||e[0]<=0?null:Math.log10(e[0]);case"exp":return e.length!==1?null:Math.exp(e[0]);case"abs":return e.length!==1?null:Math.abs(e[0]);case"sqrt":return e.length!==1||e[0]<0?null:Math.sqrt(e[0]);case"signum":return e.length!==1?null:Math.sign(e[0]);case"floor":return e.length!==1?null:Math.floor(e[0]);case"ceil":return e.length!==1?null:Math.ceil(e[0]);case"round":return e.length!==1?null:Math.round(e[0]);case"atan2":return e.length!==2?null:Math.atan2(e[0],e[1]);case"pow":{if(e.length!==2)return null;let i=e[0],n=e[1];return i===0&&n<=0||i<0&&!Number.isInteger(n)?null:Math.pow(i,n)}case"log_base":{if(e.length!==2)return null;let i=e[0],n=e[1];return i<=0||n<=0||n===1?null:Math.log(i)/Math.log(n)}case"mod":return e.length!==2||e[1]===0?null:e[0]%e[1];case"max":return e.length<1?null:Math.max(...e);case"min":return e.length<1?null:Math.min(...e);default:return console.error(`qti-math-operator: unknown operation "${t}"`),null}}catch(i){return console.error(`qti-math-operator: error performing operation "${t}":`,i),null}}};Sf([p({type:String})],Cn.prototype,"name",void 0);var Xs=class extends E{getResult(){let t=this.#t(this.getVariables());return t.length===0?(console.warn("qti-max: no numeric values provided"),null):Math.max(...t)}#t(t){let e=[];for(let i of t){if(!i)continue;let n=r=>{if(r==null)return;let s=parseFloat(r.toString());if(Number.isNaN(s)){console.warn("qti-max: non-numeric value encountered");return}e.push(s)};if(Array.isArray(i.value)){i.value.forEach(r=>n(r));continue}n(i.value)}return e}};var Ys=class extends E{getResult(){let t=this.getVariables();this.children.length!==2&&console.warn("The member operator takes two sub-expressions");let[e,i]=t;if(e.baseType===i.baseType||e.baseType==="integer"&&i.baseType==="float"||e.baseType==="float"&&i.baseType==="integer"||console.warn("Which must both have the same base-type"),i.cardinality==="multiple"||i.cardinality==="ordered"||console.warn("and the second must be a multiple or ordered container"),(e.baseType==="float"||i.baseType==="float")&&console.warn("The member operator should not be used on sub-expressions with a base-type of float"),(e.baseType==="duration"||i.baseType==="duration")&&console.warn("It must not be used on sub-expressions with a base-type of duration"),e.value===null||i.value===null)return null;let n=e.value;return i.value.includes(n)}};var Js=class extends E{getResult(){let t=this.#t(this.getVariables());return t.length===0?(console.warn("qti-min: no numeric values provided"),null):Math.min(...t)}#t(t){let e=[];for(let i of t){if(!i)continue;let n=r=>{if(r==null)return;let s=parseFloat(r.toString());if(Number.isNaN(s)){console.warn("qti-min: non-numeric value encountered");return}e.push(s)};if(Array.isArray(i.value)){i.value.forEach(r=>n(r));continue}n(i.value)}return e}};var Ks=class extends E{getResult(){let t=this.getVariables();if(t.length===0)return console.error("unexpected number of children in qti multiple"),null;for(let e of t)if(e.cardinality!=="multiple"&&e.cardinality!=="single")return console.error("unexpected cardinality in qti multiple"),[];return t}};var Zs=class extends E{render(){return b`${super.render()}`}getResult(){return!this.firstElementChild.calculate()}};var ta=class extends E{getResult(){return null}};var ea=class extends Qt{getResult(){return Array.from(this.children).map(e=>{let i=e;if(!i.calculate)return console.error("Element doesn't implement QtiConditionExpression"),null;let n=i.calculate(),r=!1;if(typeof n=="string")if(n==="true")r=!0;else if(n==="false")r=!1;else return console.error("unexpected val in qti-or, expected boolean"),null;else typeof n=="boolean"&&(r=n);return r}).some(e=>typeof e=="boolean"&&e)}};var ia=class extends E{getResult(){let t=this.getVariables();if(t.length===0)return console.error("unexpected number of children in qti multiple"),null;for(let e of t)if(e.cardinality!=="ordered"&&e.cardinality!=="single")return console.error("unexpected cardinality in qti ordered"),[];return t}};var ra=class extends C{render(){return b`<slot></slot>`}process(){let t=this.getSubRules();for(let e=0;e<t.length;e++)t[e].process()}},cr=class extends ra{shouldProcess(){return!0}getSubRules(){return[...this.children]}},dr=class extends ra{shouldProcess(){return this.firstElementChild.calculate()}getSubRules(){let t=[];for(let e=1;e<this.children.length;e++)t.push(this.children[e]);return t}},hr=class extends Y{render(){return b`<slot></slot>`}process(){let t=[...this.children];for(let e of t)if(e.shouldProcess()){e.process();return}}};var na=class extends hr{};var pr=class extends dr{};var oa=class extends pr{};var sa=class extends cr{};var kf=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},Sn=class extends E{constructor(){super(...arguments),this.pattern=""}getResult(){let t=this.getVariables();if(t.length!==1)return console.error("qti-pattern-match requires exactly one child expression"),null;if(!this.pattern)return console.error("qti-pattern-match requires a pattern attribute"),null;let e=t[0];if(e.cardinality!=="single"||Array.isArray(e.value))return console.error("qti-pattern-match requires single cardinality"),null;if(e.value===null||e.value===void 0)return null;let i=this.#t();return i?i.test(e.value.toString()):null}#t(){let t=`^(?:${this.pattern})$`;try{return new RegExp(t,"u")}catch{try{return new RegExp(t)}catch(e){return console.error("qti-pattern-match requires a valid regular expression",e),null}}}};kf([p({type:String})],Sn.prototype,"pattern",void 0);var aa=class extends E{get resultBaseType(){return"float"}getResult(){if(this.children.length!==2)return console.error("qti-power must have exactly two child expressions"),null;let t=this.getVariables();if(!t||t.length!==2)return null;let[e,i]=t;if(e.cardinality!=="single"||i.cardinality!=="single")return console.error("qti-power requires single cardinality for both expressions"),null;if(Array.isArray(e.value)||Array.isArray(i.value))return console.error("qti-power unexpected array value for single cardinality"),null;if(e.value===null||e.value===void 0||i.value===null||i.value===void 0)return null;if(e.baseType!=="integer"&&e.baseType!=="float"||i.baseType!=="integer"&&i.baseType!=="float")return console.error("qti-power requires numerical base-types"),null;let n=parseFloat(e.value),r=parseFloat(i.value);if(isNaN(n)||isNaN(r))return console.error("qti-power: non-numerical values encountered"),null;if(n===0&&r<=0||n<0&&!Number.isInteger(r))return null;let s;try{s=Math.pow(n,r)}catch(a){return console.error("qti-power: error calculating power:",a),null}if(isNaN(s))return null;if(s===1/0||s===-1/0)return s;if(!isFinite(s)||Math.abs(s)>Number.MAX_VALUE||s!==0&&Math.abs(s)<Number.MIN_VALUE)return null;if(isFinite(s)&&s!==0){let a=Math.floor(Math.log10(Math.abs(s))),l=Math.max(0,14-a),c=Math.pow(10,l);s=Math.round(s*c)/c}return s}};var Ef=/%(?:(%)|([-+ 0#]*)(\d+)?(?:\.(\d+))?([diuoxXfFeEgGsc]))/g;function Af(o){return o.replace(/e([+-])(\d)$/,"e$10$2")}function kn(o,t){return Af(t===void 0?o.toExponential():o.toExponential(t))}function Up(o){let[t,e]=o.split(/e/i),i=t.includes(".")?t.replace(/\.?0+$/,""):t,n=e===void 0?"":`e${e}`;return`${i}${n}`}function Hp(o,t){let e=t===0?1:t,i=o===0?0:Math.floor(Math.log10(o));return i<-4||i>=e?Up(kn(o,e-1)):Up(o.toFixed(Math.max(0,e-1-i)))}function If(o,t,e,i){if(o==="s"||o==="c"){let c=o==="c"?i.slice(0,1):i;return e===void 0?c:c.slice(0,e)}let n=Number(i);if(i.trim()===""||!Number.isFinite(n))return i;let r=Math.abs(n),s,a=n<0;switch(o){case"d":case"i":s=String(Math.trunc(r));break;case"u":s=String(Math.trunc(r)),a=!1;break;case"o":s=`${t.includes("#")?"0":""}${Math.trunc(r).toString(8)}`;break;case"x":s=`${t.includes("#")?"0x":""}${Math.trunc(r).toString(16)}`;break;case"X":s=`${t.includes("#")?"0X":""}${Math.trunc(r).toString(16).toUpperCase()}`;break;case"f":case"F":s=r.toFixed(e??6);break;case"e":s=kn(r,e??6);break;case"E":s=kn(r,e??6).toUpperCase();break;case"g":s=Hp(r,e??6);break;case"G":s=Hp(r,e??6).toUpperCase();break;default:return i}return`${a?"-":t.includes("+")?"+":t.includes(" ")?" ":""}${s}`}function _f(o,t,e){if(o.length>=e)return o;let i=e-o.length;if(t.includes("-"))return`${o}${" ".repeat(i)}`;if(t.includes("0")){let[,n,r]=/^([-+ ]?)(.*)$/.exec(o);return`${n}${"0".repeat(i)}${r}`}return`${" ".repeat(i)}${o}`}function Wp(o,t){return o.replace(Ef,(e,i,n,r,s,a)=>i?"%":_f(If(a,n??"",s===void 0?void 0:Number(s),t),n??"",r===void 0?0:Number(r)))}var fe=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},vt=class extends C{constructor(){super(...arguments),this.base=10,this.powerForm=!1,this.delimiter=";",this.mappingIndicator="="}render(){let t=this.context?.variables.find(i=>i.identifier===this.identifier),e=t?this.#t(t):null;return e===null?O:b`${e}`}#t(t){let e=t.value;if(e==null)return null;if(Array.isArray(e)){if(e.length===0)return null;if(this.index!==void 0){let i=e[this.index-1];return i==null?null:this.#e(i,t.baseType)}return e.map(i=>this.#e(i,t.baseType)).join(this.delimiter)}if(typeof e=="object"){let i=e;if(this.field!==void 0){let r=i[this.field];return r==null?null:this.#e(r,t.baseType)}let n=Object.entries(i).filter(([,r])=>r!=null);return n.length===0?null:n.map(([r,s])=>`${r}${this.mappingIndicator}${this.#e(s,t.baseType)}`).join(this.delimiter)}return this.#e(e,t.baseType)}#e(t,e){let i=Array.isArray(t)?t.join(" "):String(t);if(this.format)return Wp(this.format,i);if(e==="integer"&&this.base!==10){let n=Number.parseInt(i,10);if(Number.isFinite(n))return n.toString(this.base)}if(this.powerForm){let n=Number(i);if(i.trim()!==""&&Number.isFinite(n))return kn(n)}return i}calculate(){return this.context.variables.find(e=>e.identifier===this.identifier)||null}};fe([p({type:String})],vt.prototype,"identifier",void 0);fe([p({type:String})],vt.prototype,"format",void 0);fe([p({type:Number})],vt.prototype,"base",void 0);fe([p({type:Number})],vt.prototype,"index",void 0);fe([p({type:Boolean,attribute:"power-form"})],vt.prototype,"powerForm",void 0);fe([p({type:String})],vt.prototype,"field",void 0);fe([p({type:String})],vt.prototype,"delimiter",void 0);fe([p({type:String,attribute:"mapping-indicator"})],vt.prototype,"mappingIndicator",void 0);fe([_({context:F,subscribe:!0}),T()],vt.prototype,"context",void 0);var la=class extends E{getResult(){return this.getVariables().reduce((i,n)=>{if(n.baseType=="float"||n.baseType=="integer")try{return i*parseFloat(n.value.toString())}catch{console.warn("can not convert to number")}else console.warn(`has another baseType ${n.baseType}`);return i},1)}};var Ql=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},ki=class extends E{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 t=[],e=0;for(;;){let n=this.min+this.step*e;if(n>this.max)break;Number.isInteger(n)&&t.push(n),e++}if(t.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()*t.length);return t[i]}getPossibleValues(){let t=[];if(this.min>this.max||this.step<=0)return[Number.isInteger(this.min)?this.min:Math.floor(this.min)];let e=0;for(;;){let i=this.min+this.step*e;if(i>this.max)break;Number.isInteger(i)&&t.push(i),e++}return t.length>0?t:[Number.isInteger(this.min)?this.min:Math.floor(this.min)]}};Ql([p({type:Number})],ki.prototype,"min",void 0);Ql([p({type:Number})],ki.prototype,"max",void 0);Ql([p({type:Number})],ki.prototype,"step",void 0);var ca=class extends E{getResult(){let t=this.getVariables();if(t.length===1){let e=t[0].value;if(Array.isArray(e)){let i=Math.floor(Math.random()*e.length);return e[i]}return e}return console.error("unexpected number of children in match"),null}};var Tf=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},Gl=1e3,En=class extends E{constructor(){super(...arguments),this.numberRepeats=""}getResult(){let t=this.#t();if(t<=0)return[];let e=this.firstElementChild;if(!e)return console.warn("qti-repeat: missing child expression"),[];let i=[];for(let n=0;n<t;n++){let r=e.calculate(),s=this.#i(r);s&&i.push(s)}return i}#t(){if(!this.numberRepeats)return console.warn("qti-repeat: missing number-repeats attribute"),0;let t=parseInt(this.numberRepeats,10);if(!Number.isNaN(t))return this.#e(t);let e=this.numberRepeats,i=this.context?.variables?.find(s=>s.identifier===e);if(!i)return console.warn(`qti-repeat: unknown identifier "${e}"`),0;let n=Array.isArray(i.value)?i.value[0]:i.value,r=parseInt(n?.toString()??"",10);return Number.isNaN(r)?(console.warn(`qti-repeat: invalid repeat count from "${e}"`),0):this.#e(r)}#e(t){return t>Gl?(console.warn(`qti-repeat: number-repeats ${t} exceeds the ${Gl} limit, truncating`),Gl):t}#i(t){if(t==null)return null;if(typeof t=="number")return{identifier:"",cardinality:"single",baseType:Number.isInteger(t)?"integer":"float",value:t.toString(),type:"response"};if(typeof t=="string"){let e=parseFloat(t);if(!Number.isNaN(e))return{identifier:"",cardinality:"single",baseType:Number.isInteger(e)?"integer":"float",value:t.toString(),type:"response"}}if(t&&typeof t=="object"&&"value"in t){let e=t.value;return{identifier:"",cardinality:"single",baseType:t.baseType??"string",value:e!=null?e.toString():null,type:"response"}}return{identifier:"",cardinality:"single",baseType:"string",value:t.toString(),type:"response"}}};Tf([p({type:String,attribute:"number-repeats"})],En.prototype,"numberRepeats",void 0);var da=class extends hr{};var ur=class extends dr{};var ha=class extends ur{};var pa=class extends cr{};var ua=class extends Y{process(){for(let t of[...this.children])t.process()}};var Qp=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},mr=class extends E{constructor(){super(...arguments),this.roundingMode="significantFigures",this.figures=3}get resultBaseType(){return"float"}getResult(){if(this.children.length!==1)return console.error("qti-round-to must have exactly one child expression"),null;let t=this.getVariables();if(!t||t.length===0)return null;let e=t[0];if(e.cardinality!=="single")return console.error("qti-round-to requires single cardinality"),null;if(Array.isArray(e.value))return console.error("qti-round-to 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-to requires numerical base-type"),null;let i=parseFloat(e.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.#t(i,this.figures):this.#e(i,this.figures):i===1/0?1/0:i===-1/0?-1/0:null}#t(t,e){if(t===0)return 0;let i=Math.pow(10,e);return Math.round(t*i)/i}#e(t,e){if(t===0)return 0;let i=Math.floor(Math.log10(Math.abs(t))),n=Math.pow(10,e-i-1);return Math.round(t*n)/n}};Qp([p({type:String,attribute:"rounding-mode"})],mr.prototype,"roundingMode",void 0);Qp([p({type:Number})],mr.prototype,"figures",void 0);var ma=class extends E{get resultBaseType(){return"integer"}getResult(){if(this.children.length!==1)return console.error("qti-round must have exactly one child expression"),null;let t=this.getVariables();if(!t||t.length===0)return null;let e=t[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 i=parseFloat(e.value);return isNaN(i)?(console.warn("qti-round: NaN input results in NULL"),null):isFinite(i)?Math.floor(i+.5):i===1/0?1/0:i===-1/0?-1/0:null}};var fa=class extends Y{process(){let t=this.getAttribute("identifier");if(!t){console.warn('QtiSetCorrectResponse: Missing "identifier" attribute.');return}let e=this.firstElementChild;if(!e){console.warn("QtiSetCorrectResponse: No expression found.");return}let n=new Xl(e).process();this.dispatchEvent(new CustomEvent("qti-set-correct-response",{bubbles:!0,composed:!0,detail:{responseIdentifier:t,value:this.#t(n)}}))}#t(t){return t==null?null:Array.isArray(t)?t.map(e=>Rt(this.#e(e))):Rt(this.#e(t))}#e(t){if(t&&typeof t=="object"&&"value"in t){let e=t.value;return e!=null?e.toString():""}return t?.toString()??""}},Xl=class{constructor(t){this.expression=t}process(){let t=this.expression.calculate()??null;return t===null&&console.warn("QtiSetCorrectResponseRule: Evaluated value is null."),Array.isArray(t)?t.map(e=>this.#t(e)):this.#t(t)}#t(t){return t&&typeof t=="object"&&"value"in t?t.value:t}};var ga=class extends Y{process(){let t=this.getAttribute("identifier");if(!t){console.warn('QtiSetOutcomeValue: Missing "identifier" attribute.');return}let e=this.firstElementChild;if(!e){console.warn("QtiSetOutcomeValue: No expression found.");return}let n=new Yl(e).process();this.dispatchEvent(new CustomEvent("qti-set-outcome-value",{bubbles:!0,composed:!0,detail:{outcomeIdentifier:t,value:this.#t(n)}}))}#t(t){return Array.isArray(t)?t.map(Rt):t!==null?Rt(t):null}},Yl=class{constructor(t){this.expression=t}process(){let t=this.expression.calculate()??null;return t===null&&console.warn("QtiSetOutcomeValueRule: Evaluated value is null."),Array.isArray(t)?t.map(e=>e.value?e.value:e):t}};var ba=class extends Y{process(){let t=this.getAttribute("identifier");if(!t){console.warn('QtiSetTemplateValue: Missing "identifier" attribute.');return}let e=this.firstElementChild;if(!e){console.warn("QtiSetTemplateValue: No expression found.");return}let n=new Jl(e).process();this.dispatchEvent(new CustomEvent("qti-set-template-value",{bubbles:!0,composed:!0,detail:{templateIdentifier:t,value:this.#t(n)}}))}#t(t){return t==null?null:Array.isArray(t)?t.map(e=>Rt(this.#e(e))):Rt(this.#e(t))}#e(t){if(t&&typeof t=="object"&&"value"in t){let e=t.value;return e!=null?e.toString():""}return t?.toString()??""}},Jl=class{constructor(t){this.expression=t}process(){let t=this.expression.calculate()??null;return t===null&&console.warn("QtiSetTemplateValueRule: Evaluated value is null."),Array.isArray(t)?t.map(e=>this.#t(e)):this.#t(t)}#t(t){return t&&typeof t=="object"&&"value"in t?t.value:t}};var Rf=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},An=class extends E{constructor(){super(...arguments),this.name=""}get resultBaseType(){return"float"}getResult(){if(!this.name)return console.warn("qti-stats-operator: missing name attribute"),null;let t=this.#r(this.getVariables());if(t.length===0)return console.warn("qti-stats-operator: no numeric values provided"),null;switch(this.name.toLowerCase()){case"mean":return this.#t(t);case"median":return this.#e(t);case"popvariance":return this.#i(t,t.length);case"popsd":return Math.sqrt(this.#i(t,t.length));case"samplevariance":return t.length<2?null:this.#i(t,t.length-1);case"samplesd":return t.length<2?null:Math.sqrt(this.#i(t,t.length-1));default:return console.warn(`qti-stats-operator: unsupported operator "${this.name}"`),null}}#t(t){return t.reduce((e,i)=>e+i,0)/t.length}#e(t){let e=[...t].sort((n,r)=>n-r),i=Math.floor(e.length/2);return e.length%2===0?(e[i-1]+e[i])/2:e[i]}#i(t,e){let i=this.#t(t);return t.reduce((n,r)=>n+Math.pow(r-i,2),0)/e}#r(t){let e=[];for(let i of t){if(!i)continue;let n=r=>{if(r==null)return;let s=parseFloat(r.toString());if(Number.isNaN(s)){console.warn("qti-stats-operator: non-numeric value encountered");return}e.push(s)};if(Array.isArray(i.value)){i.value.forEach(r=>n(r));continue}n(i.value)}return e}};Rf([p({type:String})],An.prototype,"name",void 0);var Pf=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},In=class extends E{constructor(){super(...arguments),this.caseSensitive="true"}getResult(){if(this.children.length===2){let t=this.getVariables(),e=t[0],i=t[1];if(e.cardinality!=="single"||i.cardinality!=="single"||Array.isArray(e.value)||Array.isArray(i.value))return console.error("unexpected cardinality in qti string-match"),!1;let n=this.caseSensitive==="true"?e.value:e.value.toLowerCase(),r=this.caseSensitive==="true"?i.value:i.value.toLowerCase();return J.compareSingleValues(n,r,e.baseType)}return console.error("unexpected number of children in qti-string-match"),null}};Pf([p({type:String,attribute:"case-sensitive"})],In.prototype,"caseSensitive",void 0);var Of=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},_n=class extends E{constructor(){super(...arguments),this.caseSensitive="true"}getResult(){let t=this.getVariables();if(t.length!==2)return console.error("qti-substring requires exactly 2 child expressions"),null;let[e,i]=t;if(e.cardinality!=="single"||i.cardinality!=="single"||Array.isArray(e.value)||Array.isArray(i.value))return console.error("qti-substring requires single cardinality"),null;if(e.value===null||i.value===null||e.value===void 0||i.value===void 0)return null;let n=e.value.toString(),r=i.value.toString();return this.caseSensitive!=="true"?r.toLowerCase().includes(n.toLowerCase()):r.includes(n)}};Of([p({type:String,attribute:"case-sensitive"})],_n.prototype,"caseSensitive",void 0);var ya=class extends Mf(E){getResult(){return this.calculateChildren(Array.from(this.children))}};function Mf(o){return class extends o{calculateChildren(e){let i=e.map(n=>{if(!n.calculate)return console.error("Element doesn't implement QtiConditionExpression"),null;let r=n.calculate();return Number.isNaN(r)?(console.error("Unexpected value in qti-subtract, expected number"),null):Number(r)});return i.some(n=>n===null)?(console.error("One or more child expressions returned invalid values"),0):i[0]-i[1]}}}var va=class extends E{getResult(){return new Kl(Array.from(this.children)).calculate()}},Kl=class{constructor(t){this.expressions=t}calculate(){return this.expressions.filter(i=>i.calculate!==void 0).some(i=>i.calculate()===null)?null:this.expressions.map(i=>{let n=i.calculate();return Number.isNaN(n)?(console.error("unexpected value in qti-sum, expected number"),null):Number(n)}).reduce((i,n)=>i+n,0)}};var wa=class extends E{get resultBaseType(){return"integer"}getResult(){let t=this.getVariables();if(t.length!==1)return console.error("qti-truncate requires exactly one child expression"),null;let e=t[0];if(e.cardinality!=="single"||Array.isArray(e.value))return console.error("qti-truncate requires single cardinality"),null;if(e.baseType!=="integer"&&e.baseType!=="float")return console.error("qti-truncate requires numerical base-type"),null;if(e.value===null||e.value===void 0)return null;let i=Number.parseFloat(e.value);return Number.isNaN(i)?(console.error("qti-truncate requires a numerical value"),null):Math.trunc(i)}};var xa=class extends E{getResult(){let t=this.getAttribute("identifier")||"";return this.resolveVariable(t)?.value??null}};var Gp=[{tag:"qti-and",ctor:As},{tag:"qti-any-n",ctor:or},{tag:"qti-base-value",ctor:bn},{tag:"qti-container-size",ctor:Is},{tag:"qti-contains",ctor:_s},{tag:"qti-correct",ctor:Ts},{tag:"qti-default",ctor:Si},{tag:"qti-delete",ctor:Rs},{tag:"qti-divide",ctor:Ps},{tag:"qti-duration-gte",ctor:Os},{tag:"qti-duration-lt",ctor:Ms},{tag:"qti-equal",ctor:sr},{tag:"qti-equal-rounded",ctor:yn},{tag:"qti-exit-response",ctor:Ds},{tag:"qti-exit-test",ctor:Ns},{tag:"qti-field-value",ctor:$s},{tag:"qti-gcd",ctor:Ls},{tag:"qti-gt",ctor:Vs},{tag:"qti-gte",ctor:zs},{tag:"qti-index",ctor:vn},{tag:"qti-inside",ctor:ar},{tag:"qti-integer-divide",ctor:js},{tag:"qti-integer-modulus",ctor:Fs},{tag:"qti-integer-to-float",ctor:Bs},{tag:"qti-is-null",ctor:Us},{tag:"qti-lcm",ctor:Hs},{tag:"qti-lookup-outcome-value",ctor:lr},{tag:"qti-lt",ctor:Ws},{tag:"qti-lte",ctor:Qs},{tag:"qti-map-response",ctor:xn},{tag:"qti-map-response-point",ctor:wn},{tag:"qti-match",ctor:Gs},{tag:"qti-math-constant",ctor:qn},{tag:"qti-math-operator",ctor:Cn},{tag:"qti-max",ctor:Xs},{tag:"qti-member",ctor:Ys},{tag:"qti-min",ctor:Js},{tag:"qti-multiple",ctor:Ks},{tag:"qti-not",ctor:Zs},{tag:"qti-null",ctor:ta},{tag:"qti-or",ctor:ea},{tag:"qti-ordered",ctor:ia},{tag:"qti-outcome-condition",ctor:na},{tag:"qti-outcome-else",ctor:sa},{tag:"qti-outcome-else-if",ctor:oa},{tag:"qti-outcome-if",ctor:pr},{tag:"qti-pattern-match",ctor:Sn},{tag:"qti-power",ctor:aa},{tag:"qti-printed-variable",ctor:vt},{tag:"qti-product",ctor:la},{tag:"qti-random",ctor:ca},{tag:"qti-random-integer",ctor:ki},{tag:"qti-repeat",ctor:En},{tag:"qti-response-condition",ctor:da},{tag:"qti-response-else",ctor:pa},{tag:"qti-response-else-if",ctor:ha},{tag:"qti-response-if",ctor:ur},{tag:"qti-response-processing-fragment",ctor:ua},{tag:"qti-round",ctor:ma},{tag:"qti-round-to",ctor:mr},{tag:"qti-rule",ctor:Y},{tag:"qti-set-correct-response",ctor:fa},{tag:"qti-set-outcome-value",ctor:ga},{tag:"qti-set-template-value",ctor:ba},{tag:"qti-stats-operator",ctor:An},{tag:"qti-string-match",ctor:In},{tag:"qti-substring",ctor:_n},{tag:"qti-subtract",ctor:ya},{tag:"qti-sum",ctor:va},{tag:"qti-truncate",ctor:wa},{tag:"qti-variable",ctor:xa}];for(let{tag:o,ctor:t}of Gp)customElements.get(o)||customElements.define(o,t);var ge=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},tt;(function(o){o.Correct="correct",o.PartiallyCorrect="partially-correct",o.Incorrect="incorrect"})(tt||(tt={}));var Zl=o=>{class t extends o{constructor(){super(...arguments),this.showCorrectResponse=!1,this._handleShowCorrectResponseChange=(i,n)=>{this.toggleInternalCorrectResponse(n)},this.showFullCorrectResponse=!1,this._handleShowFullCorrectResponseChange=(i,n)=>{this.toggleFullCorrectResponse(n)},this.showCandidateCorrection=!1,this._handleShowCandidateCorrectionChange=(i,n)=>{this.toggleCandidateCorrection(n)},this._correctResponse=null}set correctResponseAttr(i){this._correctResponse=i}get correctResponseAttr(){return this._correctResponse}get isFullCorrectResponse(){return this._isFullCorrectResponse}get registersWithItem(){return!this.isFullCorrectResponse&&super.registersWithItem}set isFullCorrectResponse(i){this._isFullCorrectResponse=i,i&&(this.setAttribute("inert",""),this.setAttribute("response-identifier",this.responseIdentifier+"_cr"),this.setAttribute("answer-key",""))}get correctResponse(){let i=this.responseVariable;return i?.correctResponse?i.correctResponse:this._correctResponse}set correctResponse(i){let n=this._correctResponse;this._correctResponse=i,i==null?this.removeAttribute("correct-response"):this.setAttribute("correct-response",Array.isArray(i)?i.join(","):i),this.requestUpdate("_correctResponse",n)}get correctness(){let i=this.correctResponse;if(!i)return null;let n=this.response;if(n==null||n===""||Array.isArray(n)&&n.length===0)return null;let r=Array.isArray(i)?i:[i],a=(Array.isArray(n)?n:[n]).filter(d=>d!=="");if(a.length===0)return null;let l=a.filter(d=>r.includes(d)).length,c=a.filter(d=>!r.includes(d)).length;return l===r.length&&c===0&&a.length===r.length?tt.Correct:l>0&&(l<r.length||c>0)?tt.PartiallyCorrect:tt.Incorrect}get correctionPart(){return"correction"}toggleCorrectResponse(i){(this.configContext?.correctResponseMode||"internal")==="full"?this.toggleFullCorrectResponse(i):this.toggleInternalCorrectResponse(i)}get withholdsFullCorrectResponseWhenCorrect(){return this.configContext?.fullCorrectResponseOnlyWhenIncorrect!==!1}async toggleFullCorrectResponse(i){let n=this.nextSibling,r=n instanceof HTMLDivElement&&n?.classList.contains("full-correct-response"),s=this.correctResponse;if(!s)return;if(!(i&&(!this.withholdsFullCorrectResponseWhenCorrect||this.correctness!==tt.Correct))){if(!r)return;this.parentElement?.removeChild(n);return}if(r)return;let l=this.cloneNode(!0);l.removeAttribute("show-full-correct-response"),l.removeAttribute("show-correct-response"),l.removeAttribute("show-candidate-correction");let c=document.createElement("div");c.classList.add("full-correct-response"),this.isInline?c.classList.add("full-correct-response-inline"):c.classList.add("full-correct-response-block"),c.role="full-correct-response",c.appendChild(l),l.isFullCorrectResponse=!0,this.parentElement?.insertBefore(c,this.nextSibling),await l.updateComplete,l.response=Array.isArray(s)?[...s]:s}toggleInternalCorrectResponse(i){this._internals.states.delete("show-correct-response"),i&&this.correctResponse&&this._internals.states.add("show-correct-response")}toggleCandidateCorrection(i){}firstUpdated(){super.firstUpdated(),!this.isFullCorrectResponse&&(this.showCorrectResponse&&this.toggleInternalCorrectResponse(!0),this.showFullCorrectResponse&&this.toggleFullCorrectResponse(!0))}}return ge([p({attribute:"correct-response",reflect:!0,converter:Gt({emptyAs:null})})],t.prototype,"correctResponseAttr",null),ge([p({type:Boolean,attribute:"show-correct-response",reflect:!0})],t.prototype,"showCorrectResponse",void 0),ge([L("showCorrectResponse",{waitUntilFirstUpdate:!0})],t.prototype,"_handleShowCorrectResponseChange",void 0),ge([p({type:Boolean,attribute:"show-full-correct-response",reflect:!0})],t.prototype,"showFullCorrectResponse",void 0),ge([L("showFullCorrectResponse",{waitUntilFirstUpdate:!0})],t.prototype,"_handleShowFullCorrectResponseChange",void 0),ge([p({type:Boolean,attribute:"show-candidate-correction",reflect:!0})],t.prototype,"showCandidateCorrection",void 0),ge([L("showCandidateCorrection",{waitUntilFirstUpdate:!0})],t.prototype,"_handleShowCandidateCorrectionChange",void 0),ge([T()],t.prototype,"_isFullCorrectResponse",void 0),ge([T()],t.prototype,"_correctResponse",void 0),t};var ht=q`
9674
9679
  /* Nothing at all until the item judges this element. */
9675
9680
  [part~='correction'] {
9676
9681
  display: none;
@@ -9703,9 +9708,9 @@ CES.load();
9703
9708
 
9704
9709
  pointer-events: none;
9705
9710
  }
9706
- `;var Mf=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},K=o=>{class t extends Zl(o){constructor(){super(...arguments),this._candidateCorrection=null}get correctionPart(){return this._candidateCorrection?`correction correction-${this._candidateCorrection}`:"correction"}toggleCandidateCorrection(i){this.showCandidateCorrection!==i&&(this.showCandidateCorrection=i),super.toggleCandidateCorrection(i);let n=this._internals;n.states.delete("candidate-correct"),n.states.delete("candidate-partially-correct"),n.states.delete("candidate-incorrect");let r=null;i&&(this.correctness===tt.Correct&&(n.states.add("candidate-correct"),r="correct"),this.correctness===tt.PartiallyCorrect&&(n.states.add("candidate-partially-correct"),r="partially-correct"),this.correctness===tt.Incorrect&&(n.states.add("candidate-incorrect"),r="incorrect")),this._candidateCorrection!==r&&(this._candidateCorrection=r)}connectedCallback(){super.connectedCallback?.(),queueMicrotask(()=>{!this.isConnected||this.isFullCorrectResponse||this.showCandidateCorrection&&this.toggleCandidateCorrection(!0)})}}return Mf([T()],t.prototype,"_candidateCorrection",void 0),t};var Si=o=>{class t extends K(o){toggleInternalCorrectResponse(i){super.toggleInternalCorrectResponse(i);let n=this.correctResponse,r=n?Array.isArray(n)?n:[n]:[];for(let s of this._choiceElements)s.internals.states.delete("correct-response"),s.internals.states.delete("incorrect-response"),i&&r.length>0&&s.internals.states.add(r.includes(s.identifier)?"correct-response":"incorrect-response")}toggleCandidateCorrection(i){super.toggleCandidateCorrection(i);for(let s of this._choiceElements)s.candidateCorrection=null;if(!i||!this.correctResponse)return;let n=Array.isArray(this.correctResponse)?this.correctResponse:[this.correctResponse],r=Array.isArray(this.response)?this.response:this.response?[this.response]:[];for(let s of this._choiceElements)r.includes(s.identifier)&&(s.candidateCorrection=n.includes(s.identifier)?"correct":"incorrect")}}return t};var _t=o=>{class t extends o{#t=null;get candidateCorrection(){return this.#t}set candidateCorrection(i){if(this.#t===i)return;let n=this.#t;this.#t=i;let r=this.internals.states;r.delete("candidate-correct"),r.delete("candidate-incorrect"),r.delete("candidate-partially-correct"),i&&r.add(`candidate-${i}`),this.requestUpdate("candidateCorrection",n)}get correctionPart(){return this.#t?`correction correction-${this.#t}`:"correction"}}return t};var tc=class extends _t($e){static{this.styles=[$e.styles,ht]}render(){return b`<div part="control"></div>
9711
+ `;var Df=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},K=o=>{class t extends Zl(o){constructor(){super(...arguments),this._candidateCorrection=null}get correctionPart(){return this._candidateCorrection?`correction correction-${this._candidateCorrection}`:"correction"}toggleCandidateCorrection(i){this.showCandidateCorrection!==i&&(this.showCandidateCorrection=i),super.toggleCandidateCorrection(i);let n=this._internals;n.states.delete("candidate-correct"),n.states.delete("candidate-partially-correct"),n.states.delete("candidate-incorrect");let r=null;i&&(this.correctness===tt.Correct&&(n.states.add("candidate-correct"),r="correct"),this.correctness===tt.PartiallyCorrect&&(n.states.add("candidate-partially-correct"),r="partially-correct"),this.correctness===tt.Incorrect&&(n.states.add("candidate-incorrect"),r="incorrect")),this._candidateCorrection!==r&&(this._candidateCorrection=r)}connectedCallback(){super.connectedCallback?.(),queueMicrotask(()=>{!this.isConnected||this.isFullCorrectResponse||this.showCandidateCorrection&&this.toggleCandidateCorrection(!0)})}}return Df([T()],t.prototype,"_candidateCorrection",void 0),t};var Ei=o=>{class t extends K(o){toggleInternalCorrectResponse(i){super.toggleInternalCorrectResponse(i);let n=this.correctResponse,r=n?Array.isArray(n)?n:[n]:[];for(let s of this._choiceElements)s.internals.states.delete("correct-response"),s.internals.states.delete("incorrect-response"),i&&r.length>0&&s.internals.states.add(r.includes(s.identifier)?"correct-response":"incorrect-response")}toggleCandidateCorrection(i){super.toggleCandidateCorrection(i);for(let s of this._choiceElements)s.candidateCorrection=null;if(!i||!this.correctResponse)return;let n=Array.isArray(this.correctResponse)?this.correctResponse:[this.correctResponse],r=Array.isArray(this.response)?this.response:this.response?[this.response]:[];for(let s of this._choiceElements)r.includes(s.identifier)&&(s.candidateCorrection=n.includes(s.identifier)?"correct":"incorrect")}}return t};var _t=o=>{class t extends o{#t=null;get candidateCorrection(){return this.#t}set candidateCorrection(i){if(this.#t===i)return;let n=this.#t;this.#t=i;let r=this.internals.states;r.delete("candidate-correct"),r.delete("candidate-incorrect"),r.delete("candidate-partially-correct"),i&&r.add(`candidate-${i}`),this.requestUpdate("candidateCorrection",n)}get correctionPart(){return this.#t?`correction correction-${this.#t}`:"correction"}}return t};var tc=class extends _t($e){static{this.styles=[$e.styles,ht]}render(){return b`<div part="control"></div>
9707
9712
  <slot part="label"></slot>
9708
- <span part=${this.correctionPart} aria-hidden="true"></span>`}};var Df=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},qa=class extends _t(gi){constructor(){super(...arguments),this.orderCorrect=null}};Df([p({attribute:"aria-ordercorrectvalue",type:Number,reflect:!0})],qa.prototype,"orderCorrect",void 0);var ec=class extends _t(bi){static{this.styles=[bi.styles,ht]}render(){return b`<div part="control"><div part="control-mark"></div></div>
9713
+ <span part=${this.correctionPart} aria-hidden="true"></span>`}};var Nf=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},qa=class extends _t(gi){constructor(){super(...arguments),this.orderCorrect=null}};Nf([p({attribute:"aria-ordercorrectvalue",type:Number,reflect:!0})],qa.prototype,"orderCorrect",void 0);var ec=class extends _t(bi){static{this.styles=[bi.styles,ht]}render(){return b`<div part="control"><div part="control-mark"></div></div>
9709
9714
  <slot part="label"></slot>
9710
9715
  <span part=${this.correctionPart} aria-hidden="true"></span>`}};var ic=class extends _t($t){static{this.styles=[$t.styles,ht]}render(){return b`
9711
9716
  <div part="control"></div>
@@ -9717,7 +9722,7 @@ CES.load();
9717
9722
  `}};var rc=class extends _t(Lt){static{this.styles=[Lt.styles,ht]}render(){return b`<div part="control" tabindex="0"><div part="control-mark"></div></div>
9718
9723
  ${this.marker?b`<div id="label" part="marker">${this.marker}</div>`:O}
9719
9724
  <slot part="label"></slot>
9720
- <span part=${this.correctionPart} aria-hidden="true"></span>`}};var Gp=class extends ft{showCorrectResponse(t){for(let e of this.interactionElements)e.toggleCorrectResponse?.(t);this.updateControlState("item-show-correct-response",t)}showCandidateCorrection(t){for(let e of this.interactionElements)e.toggleCandidateCorrection?.(t);this.updateControlState("item-show-candidate-correction",t)}afterResponseVariableUpdated(){this.showCandidateCorrection(!1)}updateControlState(t,e){let i=this.getRootNode();for(;;){if(i.querySelectorAll(t).forEach(n=>n.shown=e),!(i instanceof ShadowRoot))return;i=i.host.getRootNode()}}};var Yp=class extends de{#t=t=>{let e=t.detail;this.assessmentItem?.showCorrectResponse?.(e),this.updateControlState("item-show-correct-response",e)};#e=t=>{let e=t.detail;this.assessmentItem?.showCandidateCorrection?.(e),this.updateControlState("item-show-candidate-correction",e)};#i=t=>{this.assessmentItem?.showCorrectResponse?.(!1),this.configContext={...this.configContext,correctResponseMode:t.detail}};updateAssessmentItemView(t,e){t?.showCorrectResponse?.(e==="scorer"),this.updateControlState("item-show-correct-response",e==="scorer")}constructor(){super(),this.addEventListener("item-show-correct-response",this.#t),this.addEventListener("item-show-candidate-correction",this.#e),this.addEventListener("item-switch-correct-response-mode",this.#i)}updateControlState(t,e){this.querySelectorAll(t).forEach(i=>i.shown=e)}disconnectedCallback(){this.removeEventListener("item-show-correct-response",this.#t),this.removeEventListener("item-show-candidate-correction",this.#e),this.removeEventListener("item-switch-correct-response-mode",this.#i),super.disconnectedCallback()}};var Jp=class extends gt{#t=t=>{this.activeAssessmentItem?.showCorrectResponse?.(t.detail)};#e=t=>{this.activeAssessmentItem?.showCandidateCorrection?.(t.detail)};constructor(){super(),this.addEventListener("test-show-correct-response",this.#t),this.addEventListener("test-show-candidate-correction",this.#e)}disconnectedCallback(){this.removeEventListener("test-show-correct-response",this.#t),this.removeEventListener("test-show-candidate-correction",this.#e),super.disconnectedCallback()}afterAttemptEnded(t,e,i){if(!t||!e?.showSolution)return;let n=t;n.showCandidateCorrection?.(!0),n.showCorrectResponse?.(i)}},Kp=class extends Re{updateAssessmentItemView(t,e){t.showCorrectResponse?.(e==="scorer")}},Zp=class extends ci{constructor(){super(),this.addEventListener("click",()=>{this.dispatchEvent(new CustomEvent("test-show-correct-response",{detail:!0,bubbles:!0}))})}};var nc=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},Tn=class extends C{constructor(){super(...arguments),this.label="Correct response mode",this._options={internal:"Internal",full:"Full (copy)"}}#t(t){this.dispatchEvent(new CustomEvent("item-switch-correct-response-mode",{detail:t,bubbles:!0}))}render(){return b`
9725
+ <span part=${this.correctionPart} aria-hidden="true"></span>`}};var Xp=class extends ft{showCorrectResponse(t){for(let e of this.interactionElements)e.toggleCorrectResponse?.(t);this.updateControlState("item-show-correct-response",t)}showCandidateCorrection(t){for(let e of this.interactionElements)e.toggleCandidateCorrection?.(t);this.updateControlState("item-show-candidate-correction",t)}afterResponseVariableUpdated(){this.showCandidateCorrection(!1)}updateControlState(t,e){let i=this.getRootNode();for(;;){if(i.querySelectorAll(t).forEach(n=>n.shown=e),!(i instanceof ShadowRoot))return;i=i.host.getRootNode()}}};var Yp=class extends de{#t=t=>{let e=t.detail;this.assessmentItem?.showCorrectResponse?.(e),this.updateControlState("item-show-correct-response",e)};#e=t=>{let e=t.detail;this.assessmentItem?.showCandidateCorrection?.(e),this.updateControlState("item-show-candidate-correction",e)};#i=t=>{this.assessmentItem?.showCorrectResponse?.(!1),this.configContext={...this.configContext,correctResponseMode:t.detail}};updateAssessmentItemView(t,e){t?.showCorrectResponse?.(e==="scorer"),this.updateControlState("item-show-correct-response",e==="scorer")}constructor(){super(),this.addEventListener("item-show-correct-response",this.#t),this.addEventListener("item-show-candidate-correction",this.#e),this.addEventListener("item-switch-correct-response-mode",this.#i)}updateControlState(t,e){this.querySelectorAll(t).forEach(i=>i.shown=e)}disconnectedCallback(){this.removeEventListener("item-show-correct-response",this.#t),this.removeEventListener("item-show-candidate-correction",this.#e),this.removeEventListener("item-switch-correct-response-mode",this.#i),super.disconnectedCallback()}};var Jp=class extends gt{#t=t=>{this.activeAssessmentItem?.showCorrectResponse?.(t.detail)};#e=t=>{this.activeAssessmentItem?.showCandidateCorrection?.(t.detail)};constructor(){super(),this.addEventListener("test-show-correct-response",this.#t),this.addEventListener("test-show-candidate-correction",this.#e)}disconnectedCallback(){this.removeEventListener("test-show-correct-response",this.#t),this.removeEventListener("test-show-candidate-correction",this.#e),super.disconnectedCallback()}afterAttemptEnded(t,e,i){if(!t||!e?.showSolution)return;let n=t;n.showCandidateCorrection?.(!0),n.showCorrectResponse?.(i)}},Kp=class extends Re{updateAssessmentItemView(t,e){t.showCorrectResponse?.(e==="scorer")}},Zp=class extends ci{constructor(){super(),this.addEventListener("click",()=>{this.dispatchEvent(new CustomEvent("test-show-correct-response",{detail:!0,bubbles:!0}))})}};var nc=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},Tn=class extends C{constructor(){super(...arguments),this.label="Correct response mode",this._options={internal:"Internal",full:"Full (copy)"}}#t(t){this.dispatchEvent(new CustomEvent("item-switch-correct-response-mode",{detail:t,bubbles:!0}))}render(){return b`
9721
9726
  <label part="label" for="modeSelect">${this.label}</label>
9722
9727
  <select
9723
9728
  part="select"
@@ -9741,7 +9746,7 @@ CES.load();
9741
9746
  `,gr=q`
9742
9747
  cursor: not-allowed;
9743
9748
  opacity: 0.8;
9744
- `,HF=q`
9749
+ `,QF=q`
9745
9750
  ${tu};
9746
9751
  border: 1px solid gray;
9747
9752
  `;var br=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},Qe=class extends C{static{this.styles=q`
@@ -9751,21 +9756,21 @@ CES.load();
9751
9756
  :host([disabled]) {
9752
9757
  ${gr};
9753
9758
  }
9754
- `}#t;#e;constructor(){super(),this.shown=!1,this.disabled=!1,this.showCandidateCorrectionText="Show candidate correction",this.hideCandidateCorrectionText="Hide candidate correction",this.noCorrectResponseText="No correct response specified",this.#t=!1,this.#e=""}updated(){if(!this.#t||this.#e!==this.computedContext?.identifier){this.#e=this.computedContext?.identifier;let t=!!this.computedContext?.variables.some(i=>i.correctResponse),e=!!this.computedContext?.variables.some(i=>i.mapping?.mapEntries?.length>0||i.areaMapping?.areaMapEntries?.length>0);this.#t=t||e}this.disabled=!this.#t}#i(){this.disabled||this.dispatchEvent(new CustomEvent("item-show-candidate-correction",{detail:!this.shown,bubbles:!0}))}#r(){return this.disabled?this.noCorrectResponseText:this.shown?this.hideCandidateCorrectionText:this.showCandidateCorrectionText}render(){return b` <div @click="${this.#i}">${this.#r()}</div> `}};br([_({context:xe,subscribe:!0})],Qe.prototype,"computedContext",void 0);br([p({type:Boolean,reflect:!0})],Qe.prototype,"shown",void 0);br([p({type:Boolean,reflect:!0})],Qe.prototype,"disabled",void 0);br([p({type:String})],Qe.prototype,"showCandidateCorrectionText",void 0);br([p({type:String})],Qe.prototype,"hideCandidateCorrectionText",void 0);br([p({type:String})],Qe.prototype,"noCorrectResponseText",void 0);var yr=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},Xe=class extends C{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.#t=!1,this.#e=""}static{this.styles=q`
9759
+ `}#t;#e;constructor(){super(),this.shown=!1,this.disabled=!1,this.showCandidateCorrectionText="Show candidate correction",this.hideCandidateCorrectionText="Hide candidate correction",this.noCorrectResponseText="No correct response specified",this.#t=!1,this.#e=""}updated(){if(!this.#t||this.#e!==this.computedContext?.identifier){this.#e=this.computedContext?.identifier;let t=!!this.computedContext?.variables.some(i=>i.correctResponse),e=!!this.computedContext?.variables.some(i=>i.mapping?.mapEntries?.length>0||i.areaMapping?.areaMapEntries?.length>0);this.#t=t||e}this.disabled=!this.#t}#i(){this.disabled||this.dispatchEvent(new CustomEvent("item-show-candidate-correction",{detail:!this.shown,bubbles:!0}))}#r(){return this.disabled?this.noCorrectResponseText:this.shown?this.hideCandidateCorrectionText:this.showCandidateCorrectionText}render(){return b` <div @click="${this.#i}">${this.#r()}</div> `}};br([_({context:xe,subscribe:!0})],Qe.prototype,"computedContext",void 0);br([p({type:Boolean,reflect:!0})],Qe.prototype,"shown",void 0);br([p({type:Boolean,reflect:!0})],Qe.prototype,"disabled",void 0);br([p({type:String})],Qe.prototype,"showCandidateCorrectionText",void 0);br([p({type:String})],Qe.prototype,"hideCandidateCorrectionText",void 0);br([p({type:String})],Qe.prototype,"noCorrectResponseText",void 0);var yr=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},Ge=class extends C{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.#t=!1,this.#e=""}static{this.styles=q`
9755
9760
  :host {
9756
9761
  ${fr};
9757
9762
  }
9758
9763
  :host([disabled]) {
9759
9764
  ${gr};
9760
9765
  }
9761
- `}#t;#e;updated(){if(!this.#t||this.#e!==this.computedContext?.identifier){this.#e=this.computedContext?.identifier;let t=!!this.computedContext?.variables.some(i=>i.correctResponse),e=!!this.computedContext?.variables.some(i=>i.mapping?.mapEntries?.length>0||i.areaMapping?.areaMapEntries?.length>0);this.#t=t||e}this.disabled=!this.#t}#i(){this.disabled||this.dispatchEvent(new CustomEvent("item-show-correct-response",{detail:!this.shown,bubbles:!0}))}#r(){return this.disabled?this.noCorrectResponseText:this.shown?this.hideCorrectText:this.showCorrectText}render(){return b` <div @click="${this.#i}">${this.#r()}</div> `}};yr([_({context:xe,subscribe:!0})],Xe.prototype,"computedContext",void 0);yr([p({type:Boolean,reflect:!0})],Xe.prototype,"shown",void 0);yr([p({type:Boolean,reflect:!0})],Xe.prototype,"disabled",void 0);yr([p({type:String})],Xe.prototype,"showCorrectText",void 0);yr([p({type:String})],Xe.prototype,"hideCorrectText",void 0);yr([p({type:String})],Xe.prototype,"noCorrectResponseText",void 0);var vr=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},Ge=class extends C{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"}static{this.styles=q`
9766
+ `}#t;#e;updated(){if(!this.#t||this.#e!==this.computedContext?.identifier){this.#e=this.computedContext?.identifier;let t=!!this.computedContext?.variables.some(i=>i.correctResponse),e=!!this.computedContext?.variables.some(i=>i.mapping?.mapEntries?.length>0||i.areaMapping?.areaMapEntries?.length>0);this.#t=t||e}this.disabled=!this.#t}#i(){this.disabled||this.dispatchEvent(new CustomEvent("item-show-correct-response",{detail:!this.shown,bubbles:!0}))}#r(){return this.disabled?this.noCorrectResponseText:this.shown?this.hideCorrectText:this.showCorrectText}render(){return b` <div @click="${this.#i}">${this.#r()}</div> `}};yr([_({context:xe,subscribe:!0})],Ge.prototype,"computedContext",void 0);yr([p({type:Boolean,reflect:!0})],Ge.prototype,"shown",void 0);yr([p({type:Boolean,reflect:!0})],Ge.prototype,"disabled",void 0);yr([p({type:String})],Ge.prototype,"showCorrectText",void 0);yr([p({type:String})],Ge.prototype,"hideCorrectText",void 0);yr([p({type:String})],Ge.prototype,"noCorrectResponseText",void 0);var vr=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},Xe=class extends C{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"}static{this.styles=q`
9762
9767
  :host {
9763
9768
  ${fr};
9764
9769
  }
9765
9770
  :host([disabled]) {
9766
9771
  ${gr};
9767
9772
  }
9768
- `}#t;willUpdate(t){let e=this.computedContext?.testParts.flatMap(i=>i.sections.flatMap(n=>n.items)).find(i=>i.active);if(this.#t!==e&&(this.shown=!1,this.#t=e),e){let i=!!e?.variables?.some(r=>r.correctResponse),n=!!e?.variables?.some(r=>r.mapping?.mapEntries?.length>0||r.areaMapping?.areaMapEntries?.length>0);this.disabled=!i&&!n}else this.disabled=!0}#e(){this.disabled||(this.shown=!this.shown,this.dispatchEvent(new CustomEvent("test-show-correct-response",{detail:this.shown,bubbles:!0})))}#i(){return this.disabled?this.noCorrectResponseText:this.shown?this.hideCorrectText:this.showCorrectText}render(){return b` <div @click="${this.#e}">${this.#i()}</div> `}};vr([_({context:j,subscribe:!0})],Ge.prototype,"computedContext",void 0);vr([p({type:Boolean,reflect:!0})],Ge.prototype,"shown",void 0);vr([p({type:Boolean,reflect:!0})],Ge.prototype,"disabled",void 0);vr([p({type:String})],Ge.prototype,"showCorrectText",void 0);vr([p({type:String})],Ge.prototype,"hideCorrectText",void 0);vr([p({type:String})],Ge.prototype,"noCorrectResponseText",void 0);var Zt=o=>{class t extends K(o){toggleInternalCorrectResponse(i){this.showFullCorrectResponse||this.toggleFullCorrectResponse(i)}afterCache(){super.afterCache(),this.showCorrectResponse&&this.toggleInternalCorrectResponse(!0),this.showCandidateCorrection&&this.toggleCandidateCorrection(!0),this.showFullCorrectResponse&&this.toggleFullCorrectResponse(!0)}}return t};var sc=class extends Zt(wi){};var ac=class extends Si(xi){};var Nf=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},Ca=class extends _t(X){static{this.styles=[X.styles,ht,q`
9773
+ `}#t;willUpdate(t){let e=this.computedContext?.testParts.flatMap(i=>i.sections.flatMap(n=>n.items)).find(i=>i.active);if(this.#t!==e&&(this.shown=!1,this.#t=e),e){let i=!!e?.variables?.some(r=>r.correctResponse),n=!!e?.variables?.some(r=>r.mapping?.mapEntries?.length>0||r.areaMapping?.areaMapEntries?.length>0);this.disabled=!i&&!n}else this.disabled=!0}#e(){this.disabled||(this.shown=!this.shown,this.dispatchEvent(new CustomEvent("test-show-correct-response",{detail:this.shown,bubbles:!0})))}#i(){return this.disabled?this.noCorrectResponseText:this.shown?this.hideCorrectText:this.showCorrectText}render(){return b` <div @click="${this.#e}">${this.#i()}</div> `}};vr([_({context:j,subscribe:!0})],Xe.prototype,"computedContext",void 0);vr([p({type:Boolean,reflect:!0})],Xe.prototype,"shown",void 0);vr([p({type:Boolean,reflect:!0})],Xe.prototype,"disabled",void 0);vr([p({type:String})],Xe.prototype,"showCorrectText",void 0);vr([p({type:String})],Xe.prototype,"hideCorrectText",void 0);vr([p({type:String})],Xe.prototype,"noCorrectResponseText",void 0);var Zt=o=>{class t extends K(o){toggleInternalCorrectResponse(i){this.showFullCorrectResponse||this.toggleFullCorrectResponse(i)}afterCache(){super.afterCache(),this.showCorrectResponse&&this.toggleInternalCorrectResponse(!0),this.showCandidateCorrection&&this.toggleCandidateCorrection(!0),this.showFullCorrectResponse&&this.toggleFullCorrectResponse(!0)}}return t};var sc=class extends Zt(wi){};var ac=class extends Ei(xi){};var $f=function(o,t,e,i){var n=arguments.length,r=n<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(s=o[a])&&(r=(n<3?s(r):n>3?s(t,e,r):s(t,e))||r);return n>3&&r&&Object.defineProperty(t,e,r),r},Ca=class extends _t(G){static{this.styles=[G.styles,ht,q`
9769
9774
  /*
9770
9775
  * Placement only — the glyph itself is the theme's, keyed on ::part(correction-*). That split
9771
9776
  * is the contract in correction.styles.ts, which deliberately leaves the shared badge in flow
@@ -9828,7 +9833,7 @@ CES.load();
9828
9833
  }
9829
9834
  `]}render(){return b`${this.renderPrompt()}${this.renderTextarea()}
9830
9835
  <span part=${this.correctionPart} aria-hidden="true"></span>
9831
- ${this.renderValidationMessage()}`}};Nf([p({attribute:"candidate-correction",reflect:!0,noAccessor:!0})],Ca.prototype,"candidateCorrection",void 0);var ka=o=>o?(Array.isArray(o)?o:[o]).map(e=>{let[i,n]=e.split(" ");return{source:i,target:n}}):[];var lc=class extends Zt(tr){toggleCandidateCorrection(t){super.toggleCandidateCorrection(t);let e=ka(this.correctResponse);for(let i of this.querySelectorAll("qti-gap")){let n=i.getAttribute("identifier"),r=i.drags;for(let s of r)s.candidateCorrection=null,t&&e.some(a=>a.source===s.identifier&&a.target===n)?s.candidateCorrection="correct":t&&(s.candidateCorrection="incorrect")}}};var cc=class extends K(Ft){#t=[];toggleInternalCorrectResponse(t){super.toggleInternalCorrectResponse(t);let e=this.correctResponse,i=this.#t;this.#t=t&&e?Array.isArray(e)?[...e]:[e]:[],this.requestUpdate("correctLines",i)}renderSupplementalLines(){return Q(this.#t,t=>t,t=>Mr`
9836
+ ${this.renderValidationMessage()}`}};$f([p({attribute:"candidate-correction",reflect:!0,noAccessor:!0})],Ca.prototype,"candidateCorrection",void 0);var Sa=o=>o?(Array.isArray(o)?o:[o]).map(e=>{let[i,n]=e.split(" ");return{source:i,target:n}}):[];var lc=class extends Zt(er){toggleCandidateCorrection(t){super.toggleCandidateCorrection(t);let e=Sa(this.correctResponse);for(let i of this.querySelectorAll("qti-gap")){let n=i.getAttribute("identifier"),r=i.drags;for(let s of r)s.candidateCorrection=null,t&&e.some(a=>a.source===s.identifier&&a.target===n)?s.candidateCorrection="correct":t&&(s.candidateCorrection="incorrect")}}};var cc=class extends K(Ft){#t=[];toggleInternalCorrectResponse(t){super.toggleInternalCorrectResponse(t);let e=this.correctResponse,i=this.#t;this.#t=t&&e?Array.isArray(e)?[...e]:[e]:[],this.requestUpdate("correctLines",i)}renderSupplementalLines(){return Q(this.#t,t=>t,t=>Mr`
9832
9837
  <line
9833
9838
  part="correct-line"
9834
9839
  x1=${parseInt(this.querySelector(`[identifier=${t.split(" ")[0]}]`).style.left)}
@@ -9839,7 +9844,7 @@ CES.load();
9839
9844
  stroke-width="3"
9840
9845
  stroke-dasharray="5,5"
9841
9846
  />
9842
- `)}};var dc=class extends Zt(er){};var hc=class extends K(He){resolvePinColor(t){let e=t;return e.matches(":state(candidate-incorrect)")?"var(--qti-incorrect)":e.matches(":state(candidate-correct)")?"var(--qti-correct)":e.matches(":state(correct-response)")?"var(--qti-answer-border)":super.resolvePinColor(t)}toggleInternalCorrectResponse(t){super.toggleInternalCorrectResponse(t);let e=this.correctResponse,i=e?Array.isArray(e)?e:[e]:[];for(let n of this._choiceElements){let r=i.indexOf(n.identifier);n.orderCorrect=t&&r>=0?r+1:null}this.refreshLocatorPins()}toggleCandidateCorrection(t){super.toggleCandidateCorrection(t);let e=this.correctResponse,i=e?Array.isArray(e)?e:[e]:[];for(let n of this._choiceElements)n.candidateCorrection=null,t&&n.order!=null&&(n.candidateCorrection=i[n.order-1]===n.identifier?"correct":"incorrect");this.refreshLocatorPins()}};var pc=class extends Si(ir){};var uc=class extends Si(rr){};var mc=class extends K(ct){static get styles(){return[ct.styles,ht,q`
9847
+ `)}};var dc=class extends Zt(qi){};var hc=class extends K(He){resolvePinColor(t){let e=t;return e.matches(":state(candidate-incorrect)")?"var(--qti-incorrect)":e.matches(":state(candidate-correct)")?"var(--qti-correct)":e.matches(":state(correct-response)")?"var(--qti-answer-border)":super.resolvePinColor(t)}toggleInternalCorrectResponse(t){super.toggleInternalCorrectResponse(t);let e=this.correctResponse,i=e?Array.isArray(e)?e:[e]:[];for(let n of this._choiceElements){let r=i.indexOf(n.identifier);n.orderCorrect=t&&r>=0?r+1:null}this.refreshLocatorPins()}toggleCandidateCorrection(t){super.toggleCandidateCorrection(t);let e=this.correctResponse,i=e?Array.isArray(e)?e:[e]:[];for(let n of this._choiceElements)n.candidateCorrection=null,t&&n.order!=null&&(n.candidateCorrection=i[n.order-1]===n.identifier?"correct":"incorrect");this.refreshLocatorPins()}};var pc=class extends Ei(ir){};var uc=class extends Ei(rr){};var mc=class extends K(ct){static get styles(){return[ct.styles,ht,q`
9843
9848
  /*
9844
9849
  * Only the TRAILING inset — the leading gap is the shared --qti-glyph-gap, like every other
9845
9850
  * badge. This used to set both margins to --qti-gap (1rem), twice everyone else's 0.5em, on
@@ -9858,7 +9863,7 @@ CES.load();
9858
9863
  `]}toggleInternalCorrectResponse(t){this.showFullCorrectResponse||this.toggleFullCorrectResponse(t)}get withholdsFullCorrectResponseWhenCorrect(){return!1}render(){return b`
9859
9864
  ${this.renderTrigger()} ${this.renderMenu()} ${this.renderValidationMessage()}
9860
9865
  <span part=${this.correctionPart} aria-hidden="true"></span>
9861
- `}};var fc=class extends Zt(me){#t=new Set;toggleCandidateCorrection(t){super.toggleCandidateCorrection(t);let e=ka(this.correctResponse);this.#t=t?new Set(e.map(i=>`${i.source} ${i.target}`)):new Set;for(let i of this.targetChoices){let n=i.getAttribute("identifier"),r=i.drags;for(let s of r)s.candidateCorrection=null,t&&(s.candidateCorrection=this.#t.has(`${s.identifier} ${n}`)?"correct":"incorrect")}this.requestUpdate()}getCellStateVariant(t,e){return!this.showCandidateCorrection||!e?"":this.#t.has(t)?"correct":"incorrect"}};function $f(o){if(o.length===0)return new Set;let t=new Array(o.length).fill(1),e=new Array(o.length).fill(-1);for(let r=0;r<o.length;r++)for(let s=0;s<r;s++)o[s]<o[r]&&t[s]+1>t[r]&&(t[r]=t[s]+1,e[r]=s);let i=0;for(let r=1;r<o.length;r++)t[r]>t[i]&&(i=r);let n=new Set;for(let r=i;r!==-1;r=e[r])n.add(r);return n}function eu(o,t){let e=new Map(t.map((a,l)=>[a,l])),i=o.filter(a=>e.has(a)),n=i.map(a=>e.get(a)),r=$f(n),s=new Set;return r.forEach(a=>s.add(i[a])),s}var gc=class extends Zt(We){toggleCandidateCorrection(t){super.toggleCandidateCorrection(t);let i=Array.from(this.shadowRoot.querySelectorAll("[part~='drop']")).flatMap(c=>this.chipsIn(c));for(let c of i)c.candidateCorrection=null;if(!t)return;let n=this.correctResponse,s=(n?Array.isArray(n)?n:[n]:[]).map((c,d)=>{let[h,f]=c.split(" "),m=f?.startsWith("droplist")?parseInt(f.slice(8),10):d;return{identifier:h,dropIndex:Number.isNaN(m)?d:m}}).filter(c=>c.identifier).sort((c,d)=>c.dropIndex-d.dropIndex).map(c=>c.identifier);if(s.length===0)return;let a=i.map(c=>({choice:c,identifier:c.getAttribute("identifier")})).filter(c=>!!c.identifier),l=eu(a.map(c=>c.identifier),s);for(let{choice:c,identifier:d}of a)c.candidateCorrection=l.has(d)?"correct":"incorrect"}};var bc=class extends K(G){toggleInternalCorrectResponse(t){super.toggleInternalCorrectResponse(t);let e=this.responseVariable,i=e?.correctResponse??this.correctResponse;this.correctResponse=t?i:e?.cardinality==="single"?"":[];let n=`correct-response-container-${this.responseIdentifier}`;if(this.parentElement?.querySelectorAll(`#${n}`).forEach(f=>f.remove()),!t){this.enable();return}if(this.disable(),!this.correctResponse)return;let r=document.createElement("div");r.id=n,r.className="pci-correct-response-container",Object.assign(r.style,{position:"relative",marginTop:"20px",border:"2px solid green",padding:"16px",borderRadius:"4px",backgroundColor:"rgba(0, 128, 0, 0.05)"});let s=document.createElement("div");s.textContent="Correct Response:",Object.assign(s.style,{fontWeight:"bold",marginBottom:"10px",color:"green"}),r.append(s);let a=this.cloneNode(!1);a.removeAttribute("id"),a.removeAttribute("show-correct-response"),a.removeAttribute("show-full-correct-response"),a.removeAttribute("show-candidate-correction"),a.isFullCorrectResponse=!0;let l=this.responseIdentifier;a.responseIdentifier=`${l}-correct`;for(let f of Array.from(this.children))f.tagName.startsWith("QTI-")&&a.append(f.cloneNode(!0));let c=this.correctResponse,d=e?.cardinality??(Array.isArray(c)?"multiple":"single"),h=e?.baseType??"string";a.status="solution",a.responseDeclaration={baseType:h,cardinality:d,correctResponse:{value:c}},a.addEventListener("qti-portable-custom-interaction-loaded",()=>{let f=a.responseVariablesToQtiVariableJSON(c,d,h);a.sendMessageToIframe("setBoundTo",{[l]:f}),a.sendMessageToIframe("setState",{state:"review"})},{once:!0}),a.style.pointerEvents="none",r.append(a),this.after(r)}};var yc=class extends K(yt){#t=[];#e=[];static{this.styles=[yt.styles,q`
9866
+ `}};var fc=class extends Zt(me){#t=new Set;toggleCandidateCorrection(t){super.toggleCandidateCorrection(t);let e=Sa(this.correctResponse);this.#t=t?new Set(e.map(i=>`${i.source} ${i.target}`)):new Set;for(let i of this.targetChoices){let n=i.getAttribute("identifier"),r=i.drags;for(let s of r)s.candidateCorrection=null,t&&(s.candidateCorrection=this.#t.has(`${s.identifier} ${n}`)?"correct":"incorrect")}this.requestUpdate()}getCellStateVariant(t,e){return!this.showCandidateCorrection||!e?"":this.#t.has(t)?"correct":"incorrect"}};function Lf(o){if(o.length===0)return new Set;let t=new Array(o.length).fill(1),e=new Array(o.length).fill(-1);for(let r=0;r<o.length;r++)for(let s=0;s<r;s++)o[s]<o[r]&&t[s]+1>t[r]&&(t[r]=t[s]+1,e[r]=s);let i=0;for(let r=1;r<o.length;r++)t[r]>t[i]&&(i=r);let n=new Set;for(let r=i;r!==-1;r=e[r])n.add(r);return n}function eu(o,t){let e=new Map(t.map((a,l)=>[a,l])),i=o.filter(a=>e.has(a)),n=i.map(a=>e.get(a)),r=Lf(n),s=new Set;return r.forEach(a=>s.add(i[a])),s}var gc=class extends Zt(We){toggleCandidateCorrection(t){super.toggleCandidateCorrection(t);let i=Array.from(this.shadowRoot.querySelectorAll("[part~='drop']")).flatMap(c=>this.chipsIn(c));for(let c of i)c.candidateCorrection=null;if(!t)return;let n=this.correctResponse,s=(n?Array.isArray(n)?n:[n]:[]).map((c,d)=>{let[h,f]=c.split(" "),m=f?.startsWith("droplist")?parseInt(f.slice(8),10):d;return{identifier:h,dropIndex:Number.isNaN(m)?d:m}}).filter(c=>c.identifier).sort((c,d)=>c.dropIndex-d.dropIndex).map(c=>c.identifier);if(s.length===0)return;let a=i.map(c=>({choice:c,identifier:c.getAttribute("identifier")})).filter(c=>!!c.identifier),l=eu(a.map(c=>c.identifier),s);for(let{choice:c,identifier:d}of a)c.candidateCorrection=l.has(d)?"correct":"incorrect"}};var bc=class extends K(X){toggleInternalCorrectResponse(t){super.toggleInternalCorrectResponse(t);let e=this.responseVariable,i=e?.correctResponse??this.correctResponse;this.correctResponse=t?i:e?.cardinality==="single"?"":[];let n=`correct-response-container-${this.responseIdentifier}`;if(this.parentElement?.querySelectorAll(`#${n}`).forEach(f=>f.remove()),!t){this.enable();return}if(this.disable(),!this.correctResponse)return;let r=document.createElement("div");r.id=n,r.className="pci-correct-response-container",Object.assign(r.style,{position:"relative",marginTop:"20px",border:"2px solid green",padding:"16px",borderRadius:"4px",backgroundColor:"rgba(0, 128, 0, 0.05)"});let s=document.createElement("div");s.textContent="Correct Response:",Object.assign(s.style,{fontWeight:"bold",marginBottom:"10px",color:"green"}),r.append(s);let a=this.cloneNode(!1);a.removeAttribute("id"),a.removeAttribute("show-correct-response"),a.removeAttribute("show-full-correct-response"),a.removeAttribute("show-candidate-correction"),a.isFullCorrectResponse=!0;let l=this.responseIdentifier;a.responseIdentifier=`${l}-correct`;for(let f of Array.from(this.children))f.tagName.startsWith("QTI-")&&a.append(f.cloneNode(!0));let c=this.correctResponse,d=e?.cardinality??(Array.isArray(c)?"multiple":"single"),h=e?.baseType??"string";a.status="solution",a.responseDeclaration={baseType:h,cardinality:d,correctResponse:{value:c}},a.addEventListener("qti-portable-custom-interaction-loaded",()=>{let f=a.responseVariablesToQtiVariableJSON(c,d,h);a.sendMessageToIframe("setBoundTo",{[l]:f}),a.sendMessageToIframe("setState",{state:"review"})},{once:!0}),a.style.pointerEvents="none",r.append(a),this.after(r)}};var yc=class extends K(yt){#t=[];#e=[];static{this.styles=[yt.styles,q`
9862
9867
  [part~='correct'] {
9863
9868
  --qti-select-point-marker-color: var(--qti-correct);
9864
9869
  }
@@ -9919,7 +9924,7 @@ CES.load();
9919
9924
  ${this.renderAnswer()} ${this.renderInput()}
9920
9925
  <span part=${this.correctionPart} aria-hidden="true"></span>
9921
9926
  ${this.renderValidationMessage()}
9922
- `}};export{K as CandidateCorrectionMixin,Si as ChoiceCorrectionMixin,Zl as CorrectResponseMixin,tt as Correctness,Ya as CustomStateSetShim,Ja as INITIAL_SESSION_CONTEXT,Ka as INITIAL_TEST_CONTEXT,D as Interaction,el as IsNullOrUndefined,Nt as ItemContainer,Tn as ItemCorrectResponseMode,an as ItemPrintVariables,Qe as ItemShowCandidateCorrection,Xe as ItemShowCorrectResponse,fh as ItemViewMixin,md as PUBLIC_ITEM_EVENTS,ko as QTI_TEST_STATE_VERSION,As as QtiAnd,or as QtiAnyN,ft as QtiAssessmentItem,Gp as QtiAssessmentItemCorrection,Ct as QtiAssessmentItemRef,kt as QtiAssessmentSection,no as QtiAssessmentStimulus,Bi as QtiAssessmentStimulusRef,gl as QtiAssessmentStimulusRefConnectedEvent,ii as QtiAssessmentTest,Yi as QtiAssociableHotspot,wi as QtiAssociateInteraction,sc as QtiAssociateInteractionCorrection,bn as QtiBaseValue,se as QtiBranchRule,xi as QtiChoiceInteraction,ac as QtiChoiceInteractionCorrection,co as QtiCompanionMaterialsInfo,Qt as QtiConditionExpression,Is as QtiContainerSize,_s as QtiContains,Ur as QtiContentBody,Ui as QtiContextDeclaration,Ts as QtiCorrect,pe as QtiCustomInteraction,Hr as QtiCustomOperator,Ci as QtiDefault,Rs as QtiDelete,Ps as QtiDivide,Os as QtiDurationGte,Ms as QtiDurationLt,Ue as QtiEndAttemptInteraction,sr as QtiEqual,yn as QtiEqualRounded,Ds as QtiExitResponse,Pi as QtiExitResponseSignal,Ns as QtiExitTest,Oi as QtiExitTestSignal,E as QtiExpression,X as QtiExtendedTextInteraction,Ca as QtiExtendedTextInteractionCorrection,mt as QtiFeedback,ho as QtiFeedbackBlock,po as QtiFeedbackInline,$s as QtiFieldValue,mi as QtiGap,ln as QtiGapImg,tr as QtiGapMatchInteraction,lc as QtiGapMatchInteractionCorrection,$e as QtiGapText,tc as QtiGapTextCorrection,Ls as QtiGcd,Ft as QtiGraphicAssociateInteraction,cc as QtiGraphicAssociateInteractionCorrection,er as QtiGraphicGapMatchInteraction,dc as QtiGraphicGapMatchInteractionCorrection,He as QtiGraphicOrderInteraction,hc as QtiGraphicOrderInteractionCorrection,Vs as QtiGt,zs as QtiGte,gi as QtiHotspotChoice,qa as QtiHotspotChoiceCorrection,ir as QtiHotspotInteraction,pc as QtiHotspotInteractionCorrection,bi as QtiHottext,ec as QtiHottextCorrection,rr as QtiHottextInteraction,uc as QtiHottextInteractionCorrection,vn as QtiIndex,cn as QtiInlineChoice,ct as QtiInlineChoiceInteraction,mc as QtiInlineChoiceInteractionCorrection,ar as QtiInside,js as QtiIntegerDivide,Fs as QtiIntegerModulus,Bs as QtiIntegerToFloat,Us as QtiIsNull,de as QtiItem,uo as QtiItemBody,Yp as QtiItemCorrection,Pt as QtiItemSessionControl,Hs as QtiLcm,lr as QtiLookupOutcomeValue,Ws as QtiLt,Qs as QtiLte,xn as QtiMapResponse,wn as QtiMapResponsePoint,Xs as QtiMatch,me as QtiMatchInteraction,fc as QtiMatchInteractionCorrection,qn as QtiMathConstant,Cn as QtiMathOperator,Gs as QtiMax,us as QtiMediaInteraction,Ys as QtiMember,Js as QtiMin,Hi as QtiModalFeedback,Ks as QtiMultiple,Zs as QtiNot,ta as QtiNull,jr as QtiNumberPresented,eo as QtiNumberSelected,ea as QtiOr,We as QtiOrderInteraction,gc as QtiOrderInteractionCorrection,ia as QtiOrdered,na as QtiOutcomeCondition,ae as QtiOutcomeDeclaration,sa as QtiOutcomeElse,oa as QtiOutcomeElseIf,pr as QtiOutcomeIf,ro as QtiOutcomeProcessing,hl as QtiOutcomeProcessingProcessor,kn as QtiPatternMatch,G as QtiPortableCustomInteraction,bc as QtiPortableCustomInteractionCorrection,ys as QtiPositionObjectInteraction,vs as QtiPositionObjectStage,aa as QtiPower,io as QtiPreCondition,vt as QtiPrintedVariable,la as QtiProduct,zo as QtiPrompt,ca as QtiRandom,ki as QtiRandomInteger,En as QtiRepeat,da as QtiResponseCondition,Ee as QtiResponseDeclaration,pa as QtiResponseElse,ha as QtiResponseElseIf,ur as QtiResponseIf,fo as QtiResponseProcessing,ua as QtiResponseProcessingFragment,ma as QtiRound,mr as QtiRoundTo,le as QtiRubricBlock,dd as QtiRuleElement,yt as QtiSelectPointInteraction,yc as QtiSelectPointInteractionCorrection,fa as QtiSetCorrectResponse,Gl as QtiSetCorrectResponseRule,ga as QtiSetOutcomeValue,Yl as QtiSetOutcomeValueRule,ba as QtiSetTemplateValue,Jl as QtiSetTemplateValueRule,$t as QtiSimpleAssociableChoice,ic as QtiSimpleAssociableChoiceCorrection,Lt as QtiSimpleChoice,rc as QtiSimpleChoiceCorrection,It as QtiSliderInteraction,vc as QtiSliderInteractionCorrection,An as QtiStatsOperator,In as QtiStringMatch,yo as QtiStylesheet,_n as QtiSubstring,ya as QtiSubtract,va as QtiSum,Kl as QtiSumExpression,vo as QtiTemplateConstraint,ce as QtiTemplateDeclaration,wo as QtiTemplateProcessing,Re as QtiTest,Kp as QtiTestCorrection,Yr as QtiTestFeedback,Te as QtiTestPart,Jr as QtiTestVariables,yl as QtiTestVariablesExpression,pt as QtiTextEntryInteraction,wc as QtiTextEntryInteractionCorrection,wa as QtiTruncate,Ss as QtiUploadInteraction,xa as QtiVariable,Ri as QtiVariableDeclaration,J as ScoringHelper,Me as TestBookmark,ci as TestCheckItem,Zp as TestCheckItemCorrection,St as TestContainer,oi as TestEndAttempt,Zr as TestItemLink,pi as TestItemToSpeech,gt as TestNavigation,Jp as TestNavigationCorrection,ai as TestNext,li as TestPrev,en as TestPrintContext,rn as TestPrintVariables,di as TestScoringButtons,Xi as TestScoringFeedback,tn as TestSectionLink,Ge as TestShowCorrectResponse,hi as TestStamp,Lo as TestTtsNext,Mo as TestTtsPause,Vo as TestTtsPick,sn as TestTtsPlay,$o as TestTtsPrev,Do as TestTtsResume,No as TestTtsStop,Yt as TestView,on as TestViewToggle,my as asSeed,Sl as bookmarkedItems,P as boxSizing,Lu as classifyCustomStateSupport,j as computedContext,xe as computedItemContext,xt as configContext,Rt as convertNumberToUniversalFormat,ht as correctionPart,By as decimalSeparator,sl as dispatchDeclared,Mi as dispatchPublic,Wt as dropRegion,hd as getCustomOperator,A3 as getItemByUri,E3 as getManifestInfo,ad as installCustomStateSetFallback,_i as interactionContext,zu as isSeed,F as itemContext,ld as itemContextVariables,Ky as iterResponseValues,al as listenDeclared,fd as listenPublic,Zy as parsePair,ev as parsePoint,il as parseResponseAttribute,uh as pluginElements,lh as pluginState,gf as qtiAndMixin,qt as qtiContext,Vp as qtiInteractionElements,Of as qtiSubtractMixin,Gt as qtiTransformItem,Td as qtiTransformManifest,Fi as qtiTransformTest,sv as registerCustomOperator,Zn as removeDoubleSlashes,Xt as responseAttributeConverter,tv as serializePair,iv as serializePoint,rl as serializeResponseAttribute,qe as sessionContext,nt as testContext,ph as ttsElements,av as unregisterCustomOperator,W as validationMessage};
9927
+ `}};export{K as CandidateCorrectionMixin,Ei as ChoiceCorrectionMixin,Zl as CorrectResponseMixin,tt as Correctness,Ya as CustomStateSetShim,Ja as INITIAL_SESSION_CONTEXT,Ka as INITIAL_TEST_CONTEXT,D as Interaction,el as IsNullOrUndefined,Nt as ItemContainer,Tn as ItemCorrectResponseMode,an as ItemPrintVariables,Qe as ItemShowCandidateCorrection,Ge as ItemShowCorrectResponse,fh as ItemViewMixin,md as PUBLIC_ITEM_EVENTS,So as QTI_TEST_STATE_VERSION,As as QtiAnd,or as QtiAnyN,ft as QtiAssessmentItem,Xp as QtiAssessmentItemCorrection,Ct as QtiAssessmentItemRef,St as QtiAssessmentSection,no as QtiAssessmentStimulus,Ui as QtiAssessmentStimulusRef,gl as QtiAssessmentStimulusRefConnectedEvent,ii as QtiAssessmentTest,Ji as QtiAssociableHotspot,wi as QtiAssociateInteraction,sc as QtiAssociateInteractionCorrection,bn as QtiBaseValue,se as QtiBranchRule,xi as QtiChoiceInteraction,ac as QtiChoiceInteractionCorrection,co as QtiCompanionMaterialsInfo,Qt as QtiConditionExpression,Is as QtiContainerSize,_s as QtiContains,Ur as QtiContentBody,Hi as QtiContextDeclaration,Ts as QtiCorrect,pe as QtiCustomInteraction,Hr as QtiCustomOperator,Si as QtiDefault,Rs as QtiDelete,Ps as QtiDivide,Os as QtiDurationGte,Ms as QtiDurationLt,Ue as QtiEndAttemptInteraction,sr as QtiEqual,yn as QtiEqualRounded,Ds as QtiExitResponse,Oi as QtiExitResponseSignal,Ns as QtiExitTest,Mi as QtiExitTestSignal,E as QtiExpression,G as QtiExtendedTextInteraction,Ca as QtiExtendedTextInteractionCorrection,mt as QtiFeedback,ho as QtiFeedbackBlock,po as QtiFeedbackInline,$s as QtiFieldValue,mi as QtiGap,ln as QtiGapImg,er as QtiGapMatchInteraction,lc as QtiGapMatchInteractionCorrection,$e as QtiGapText,tc as QtiGapTextCorrection,Ls as QtiGcd,Ft as QtiGraphicAssociateInteraction,cc as QtiGraphicAssociateInteractionCorrection,qi as QtiGraphicGapMatchInteraction,dc as QtiGraphicGapMatchInteractionCorrection,He as QtiGraphicOrderInteraction,hc as QtiGraphicOrderInteractionCorrection,Vs as QtiGt,zs as QtiGte,gi as QtiHotspotChoice,qa as QtiHotspotChoiceCorrection,ir as QtiHotspotInteraction,pc as QtiHotspotInteractionCorrection,bi as QtiHottext,ec as QtiHottextCorrection,rr as QtiHottextInteraction,uc as QtiHottextInteractionCorrection,vn as QtiIndex,cn as QtiInlineChoice,ct as QtiInlineChoiceInteraction,mc as QtiInlineChoiceInteractionCorrection,ar as QtiInside,js as QtiIntegerDivide,Fs as QtiIntegerModulus,Bs as QtiIntegerToFloat,Us as QtiIsNull,de as QtiItem,uo as QtiItemBody,Yp as QtiItemCorrection,Pt as QtiItemSessionControl,Hs as QtiLcm,lr as QtiLookupOutcomeValue,Ws as QtiLt,Qs as QtiLte,xn as QtiMapResponse,wn as QtiMapResponsePoint,Gs as QtiMatch,me as QtiMatchInteraction,fc as QtiMatchInteractionCorrection,qn as QtiMathConstant,Cn as QtiMathOperator,Xs as QtiMax,us as QtiMediaInteraction,Ys as QtiMember,Js as QtiMin,Wi as QtiModalFeedback,Ks as QtiMultiple,Zs as QtiNot,ta as QtiNull,jr as QtiNumberPresented,eo as QtiNumberSelected,ea as QtiOr,We as QtiOrderInteraction,gc as QtiOrderInteractionCorrection,ia as QtiOrdered,na as QtiOutcomeCondition,ae as QtiOutcomeDeclaration,sa as QtiOutcomeElse,oa as QtiOutcomeElseIf,pr as QtiOutcomeIf,ro as QtiOutcomeProcessing,hl as QtiOutcomeProcessingProcessor,Sn as QtiPatternMatch,X as QtiPortableCustomInteraction,bc as QtiPortableCustomInteractionCorrection,ys as QtiPositionObjectInteraction,vs as QtiPositionObjectStage,aa as QtiPower,io as QtiPreCondition,vt as QtiPrintedVariable,la as QtiProduct,zo as QtiPrompt,ca as QtiRandom,ki as QtiRandomInteger,En as QtiRepeat,da as QtiResponseCondition,Ee as QtiResponseDeclaration,pa as QtiResponseElse,ha as QtiResponseElseIf,ur as QtiResponseIf,fo as QtiResponseProcessing,ua as QtiResponseProcessingFragment,ma as QtiRound,mr as QtiRoundTo,le as QtiRubricBlock,dd as QtiRuleElement,yt as QtiSelectPointInteraction,yc as QtiSelectPointInteractionCorrection,fa as QtiSetCorrectResponse,Xl as QtiSetCorrectResponseRule,ga as QtiSetOutcomeValue,Yl as QtiSetOutcomeValueRule,ba as QtiSetTemplateValue,Jl as QtiSetTemplateValueRule,$t as QtiSimpleAssociableChoice,ic as QtiSimpleAssociableChoiceCorrection,Lt as QtiSimpleChoice,rc as QtiSimpleChoiceCorrection,It as QtiSliderInteraction,vc as QtiSliderInteractionCorrection,An as QtiStatsOperator,In as QtiStringMatch,yo as QtiStylesheet,_n as QtiSubstring,ya as QtiSubtract,va as QtiSum,Kl as QtiSumExpression,vo as QtiTemplateConstraint,ce as QtiTemplateDeclaration,wo as QtiTemplateProcessing,Re as QtiTest,Kp as QtiTestCorrection,Yr as QtiTestFeedback,Te as QtiTestPart,Jr as QtiTestVariables,yl as QtiTestVariablesExpression,pt as QtiTextEntryInteraction,wc as QtiTextEntryInteractionCorrection,wa as QtiTruncate,ks as QtiUploadInteraction,xa as QtiVariable,Pi as QtiVariableDeclaration,J as ScoringHelper,Me as TestBookmark,ci as TestCheckItem,Zp as TestCheckItemCorrection,kt as TestContainer,oi as TestEndAttempt,Zr as TestItemLink,pi as TestItemToSpeech,gt as TestNavigation,Jp as TestNavigationCorrection,ai as TestNext,li as TestPrev,en as TestPrintContext,rn as TestPrintVariables,di as TestScoringButtons,Xi as TestScoringFeedback,tn as TestSectionLink,Xe as TestShowCorrectResponse,hi as TestStamp,Lo as TestTtsNext,Mo as TestTtsPause,Vo as TestTtsPick,sn as TestTtsPlay,$o as TestTtsPrev,Do as TestTtsResume,No as TestTtsStop,Yt as TestView,on as TestViewToggle,fy as asSeed,kl as bookmarkedItems,P as boxSizing,Lu as classifyCustomStateSupport,j as computedContext,xe as computedItemContext,xt as configContext,Rt as convertNumberToUniversalFormat,ht as correctionPart,Uy as decimalSeparator,sl as dispatchDeclared,Di as dispatchPublic,Wt as dropRegion,hd as getCustomOperator,_3 as getItemByUri,I3 as getManifestInfo,ad as installCustomStateSetFallback,Ti as interactionContext,zu as isSeed,F as itemContext,ld as itemContextVariables,Zy as iterResponseValues,al as listenDeclared,fd as listenPublic,tv as parsePair,iv as parsePoint,il as parseResponseAttribute,uh as pluginElements,lh as pluginState,bf as qtiAndMixin,qt as qtiContext,Vp as qtiInteractionElements,Mf as qtiSubtractMixin,Xt as qtiTransformItem,Td as qtiTransformManifest,Bi as qtiTransformTest,av as registerCustomOperator,Zn as removeDoubleSlashes,Gt as responseAttributeConverter,ev as serializePair,rv as serializePoint,rl as serializeResponseAttribute,qe as sessionContext,nt as testContext,ph as ttsElements,lv as unregisterCustomOperator,W as validationMessage};
9923
9928
  /*! Bundled license information:
9924
9929
 
9925
9930
  @lit-labs/ssr-dom-shim/lib/element-internals.js: