qti3-item-player-vue3 0.2.12 → 0.2.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/pci/css/styles.css +70 -3
- package/dist/assets/pci/pci.html +280 -211
- package/dist/qti3-item-player-vue3.js +241 -159
- package/dist/qti3-item-player-vue3.umd.cjs +2 -2
- package/dist/qti3Player.css +1 -1
- package/package.json +1 -1
@@ -1,4 +1,4 @@
|
|
1
|
-
(function(l,Xe){typeof exports=="object"&&typeof module<"u"?module.exports=Xe(require("vue")):typeof define=="function"&&define.amd?define(["vue"],Xe):(l=typeof globalThis<"u"?globalThis:l||self,l.Qti3Player=Xe(l.Vue))})(this,function(l){"use strict";var y4=Object.defineProperty;var w4=(l,Xe,Ds)=>Xe in l?y4(l,Xe,{enumerable:!0,configurable:!0,writable:!0,value:Ds}):l[Xe]=Ds;var ee=(l,Xe,Ds)=>w4(l,typeof Xe!="symbol"?Xe+"":Xe,Ds);class Xe{constructor(t,i,s){this.fieldIdentifier=t,this.value=s,this.baseType=i,this.cardinality="single"}getValue(){return this.value}setValue(t){this.value=t}getBaseType(){return this.baseType}setBaseType(t){this.baseType=t}getCardinality(){return this.cardinality}getFieldIdentifier(){return this.fieldIdentifier}setFieldIdentifier(t){this.fieldIdentifier=t}}class Ds{constructor(){ee(this,"constants",{COLOR_DEFAULT:"qti3-player-color-default",COLOR_DEFAULT_REVERSE:"qti3-player-color-defaultreverse",COLOR_BLACK_WHITE:"qti3-player-color-blackwhite",COLOR_WHITE_BLACK:"qti3-player-color-whiteblack",COLOR_BLACK_ROSE:"qti3-player-color-blackrose",COLOR_ROSE_BLACK:"qti3-player-color-roseblack",COLOR_YELLOW_BLUE:"qti3-player-color-yellowblue",COLOR_BLUE_YELLOW:"qti3-player-color-blueyellow",COLOR_MGRAY_DGRAY:"qti3-player-color-mgraydgray",COLOR_DGRAY_MGRAY:"qti3-player-color-dgraymgray",COLOR_BLACK_CYAN:"qti3-player-color-blackcyan",COLOR_CYAN_BLACK:"qti3-player-color-cyanblack",COLOR_BLACK_CREAM:"qti3-player-color-blackcream",COLOR_CREAM_BLACK:"qti3-player-color-creamblack",GLOSSARY_ON:"glossary-on",GLOSSARY_OFF:"glossary-off",KEYWORD_TRANS_OFF:"ktlang-off",KEYWORD_TRANS_AR:"ktlang-ar",KEYWORD_TRANS_CMN:"ktlang-cmn",KEYWORD_TRANS_DE:"ktlang-de",KEYWORD_TRANS_EN:"ktlang-en",KEYWORD_TRANS_ES:"ktlang-es",KEYWORD_TRANS_FR:"ktlang-fr",KEYWORD_TRANS_HMN:"ktlang-hmn",KEYWORD_TRANS_IT:"ktlang-it",KEYWORD_TRANS_JA:"ktlang-ja",KEYWORD_TRANS_KO:"ktlang-ko",KEYWORD_TRANS_MY:"ktlang-my",KEYWORD_TRANS_NL:"ktlang-nl",KEYWORD_TRANS_PA:"ktlang-pa",KEYWORD_TRANS_RU:"ktlang-ru",KEYWORD_TRANS_SO:"ktlang-so",KEYWORD_TRANS_TL:"ktlang-tl",KEYWORD_TRANS_UK:"ktlang-uk",KEYWORD_TRANS_VI:"ktlang-vi",KEYWORD_TRANS_YUE:"ktlang-yue",KEYWORD_TRANS_ZH:"ktlang-zh",EXT_SBAC_GLOSSARY_ILLUSTRATION_ON:"sbacGlossaryIllustration-on",EXT_SBAC_GLOSSARY_ILLUSTRATION_OFF:"sbacGlossaryIllustration-off"});return this.pnp=this.defaultPnp(),this}defaultPnp(){return{textAppearance:{colorStyle:this.constants.COLOR_DEFAULT},glossaryOnScreen:!0,keywordTranslationLanguage:"",extSbacGlossaryIllustration:!1,layoutSingleColumn:!1}}setPnp(t){typeof t>"u"||(t===null&&(this.pnp=this.defaultPnp()),"textAppearance"in t&&t.textAppearance!==null&&"colorStyle"in t.textAppearance&&this.setColorStyle(t.textAppearance.colorStyle),"glossaryOnScreen"in t&&t.glossaryOnScreen!==null&&this.setGlossaryOnScreen(t.glossaryOnScreen),"keywordTranslationLanguage"in t&&this.setKeywordTranslationLanguage(t.keywordTranslationLanguage),"extSbacGlossaryIllustration"in t&&t.extSbacGlossaryIllustration!==null&&this.setExtSbacGlossaryIllustration(t.extSbacGlossaryIllustration),"layoutSingleColumn"in t&&t.layoutSingleColumn!==null&&this.setLayoutSingleColumn(t.layoutSingleColumn))}getPnp(){return this.pnp}getColorStyle(){return this.pnp.textAppearance.colorStyle}setColorStyle(t){this.pnp.textAppearance.colorStyle=t}getGlossaryOnScreen(){return this.pnp.glossaryOnScreen}setGlossaryOnScreen(t){this.pnp.glossaryOnScreen=t}getKeywordTranslationLanguage(){return this.pnp.keywordTranslationLanguage}setKeywordTranslationLanguage(t){this.pnp.keywordTranslationLanguage=t}getExtSbacGlossaryIllustration(){return this.pnp.extSbacGlossaryIllustration}setExtSbacGlossaryIllustration(t){this.pnp.extSbacGlossaryIllustration=t}getLayoutSingleColumn(){return this.pnp.layoutSingleColumn}setLayoutSingleColumn(t){this.pnp.layoutSingleColumn=t}evaluatePnpEvent(t){let i=!1;switch(t){case this.constants.GLOSSARY_ON:this.getGlossaryOnScreen()===!1&&(this.setGlossaryOnScreen(!0),i=!0);break;case this.constants.GLOSSARY_OFF:this.getGlossaryOnScreen()===!0&&(this.setGlossaryOnScreen(!1),i=!0);break;case this.constants.KEYWORD_TRANS_OFF:this.getKeywordTranslationLanguage()!==""&&(this.setKeywordTranslationLanguage(""),i=!0);break;case this.constants.KEYWORD_TRANS_AR:this.getKeywordTranslationLanguage()!=="ar"&&(this.setKeywordTranslationLanguage("ar"),i=!0);break;case this.constants.KEYWORD_TRANS_CMN:this.getKeywordTranslationLanguage()!=="cmn"&&(this.setKeywordTranslationLanguage("cmn"),i=!0);break;case this.constants.KEYWORD_TRANS_DE:this.getKeywordTranslationLanguage()!=="de"&&(this.setKeywordTranslationLanguage("de"),i=!0);break;case this.constants.KEYWORD_TRANS_EN:this.getKeywordTranslationLanguage()!=="en"&&(this.setKeywordTranslationLanguage("en"),i=!0);break;case this.constants.KEYWORD_TRANS_ES:this.getKeywordTranslationLanguage()!=="es"&&(this.setKeywordTranslationLanguage("es"),i=!0);break;case this.constants.KEYWORD_TRANS_FR:this.getKeywordTranslationLanguage()!=="fr"&&(this.setKeywordTranslationLanguage("fr"),i=!0);break;case this.constants.KEYWORD_TRANS_HMN:this.getKeywordTranslationLanguage()!=="hmn"&&(this.setKeywordTranslationLanguage("hmn"),i=!0);break;case this.constants.KEYWORD_TRANS_IT:this.getKeywordTranslationLanguage()!=="it"&&(this.setKeywordTranslationLanguage("it"),i=!0);break;case this.constants.KEYWORD_TRANS_JA:this.getKeywordTranslationLanguage()!=="ja"&&(this.setKeywordTranslationLanguage("ja"),i=!0);break;case this.constants.KEYWORD_TRANS_KO:this.getKeywordTranslationLanguage()!=="ko"&&(this.setKeywordTranslationLanguage("ko"),i=!0);break;case this.constants.KEYWORD_TRANS_MY:this.getKeywordTranslationLanguage()!=="my"&&(this.setKeywordTranslationLanguage("my"),i=!0);break;case this.constants.KEYWORD_TRANS_NL:this.getKeywordTranslationLanguage()!=="nl"&&(this.setKeywordTranslationLanguage("nl"),i=!0);break;case this.constants.KEYWORD_TRANS_PA:this.getKeywordTranslationLanguage()!=="pa"&&(this.setKeywordTranslationLanguage("pa"),i=!0);break;case this.constants.KEYWORD_TRANS_RU:this.getKeywordTranslationLanguage()!=="ru"&&(this.setKeywordTranslationLanguage("ru"),i=!0);break;case this.constants.KEYWORD_TRANS_SO:this.getKeywordTranslationLanguage()!=="so"&&(this.setKeywordTranslationLanguage("so"),i=!0);break;case this.constants.KEYWORD_TRANS_TL:this.getKeywordTranslationLanguage()!=="tl"&&(this.setKeywordTranslationLanguage("tl"),i=!0);break;case this.constants.KEYWORD_TRANS_UK:this.getKeywordTranslationLanguage()!=="uk"&&(this.setKeywordTranslationLanguage("uk"),i=!0);break;case this.constants.KEYWORD_TRANS_VI:this.getKeywordTranslationLanguage()!=="vi"&&(this.setKeywordTranslationLanguage("vi"),i=!0);break;case this.constants.KEYWORD_TRANS_YUE:this.getKeywordTranslationLanguage()!=="yue"&&(this.setKeywordTranslationLanguage("yue"),i=!0);break;case this.constants.KEYWORD_TRANS_ZH:this.getKeywordTranslationLanguage()!=="zh"&&(this.setKeywordTranslationLanguage("zh"),i=!0);break;case this.constants.EXT_SBAC_GLOSSARY_ILLUSTRATION_ON:this.getExtSbacGlossaryIllustration()===!1&&(this.setExtSbacGlossaryIllustration(!0),i=!0);break;case this.constants.EXT_SBAC_GLOSSARY_ILLUSTRATION_OFF:this.getExtSbacGlossaryIllustration()===!0&&(this.setExtSbacGlossaryIllustration(!1),i=!0);break}return i}}class jb{constructor(){ee(this,"constants",{TIME_LIMITS_DEFAULT:{min_time:null,max_time:null,allow_late_submission:!1},ATTEMPTS_UNLIMITED:0});return this.sc=this.defaultSessionControl(),this}defaultSessionControl(){return this.sc={allow_comment:!1,allow_review:!0,allow_skipping:!0,max_attempts:this.constants.ATTEMPTS_UNLIMITED,show_feedback:!1,show_solution:!1,time_limits:this.constants.TIME_LIMITS_DEFAULT,validate_responses:!1},this.sc}setSessionControl(t){if(!(typeof t>"u")){if(t===null)return this.sc=this.defaultSessionControl();"allow_comment"in t&&t.allow_comment!==null&&this.setAllowComment(t.allow_comment),"allow_review"in t&&t.allow_review!==null&&this.setAllowReview(t.allow_review),"allow_skipping"in t&&t.allow_skipping!==null&&this.setAllowSkipping(t.allow_skipping),"max_attempts"in t&&t.max_attempts!==null&&this.setMaxAttempts(t.max_attempts),"show_feedback"in t&&t.show_feedback!==null&&this.setShowFeedback(t.show_feedback),"show_solution"in t&&t.show_solution!==null&&this.setShowSolution(t.show_solution),"time_limits"in t&&t.time_limits!==null&&("min_time"in t.time_limits&&this.setTimeLimitsMinTime(t.time_limits.min_time),"max_time"in t.time_limits&&this.setTimeLimitsMaxTime(t.time_limits.max_time),"allow_late_submission"in t.time_limits&&this.setTimeLimitsAllowLateSubmission(t.time_limits.allow_late_submission)),"validate_responses"in t&&t.validate_responses!==null&&this.setValidateResponses(t.validate_responses)}}getSessionControl(){return{allow_comment:this.getAllowComment(),allow_review:this.getAllowReview(),allow_skipping:this.getAllowSkipping(),max_attempts:this.getMaxAttempts(),show_feedback:this.getShowFeedback(),show_solution:this.getShowSolution(),time_limits:this.getTimeLimits(),validate_responses:this.getValidateResponses()}}getAllowComment(){return this.sc.allow_comment}setAllowComment(t){this.sc.allow_comment=t}getAllowReview(){return this.sc.allow_review}setAllowReview(t){this.sc.allow_review=t}getAllowSkipping(){return this.sc.allow_skipping}setAllowSkipping(t){this.sc.allow_skipping=t}getMaxAttempts(){return this.sc.max_attempts}setMaxAttempts(t){this.sc.max_attempts=t}getShowFeedback(){return this.sc.show_feedback}setShowFeedback(t){this.sc.show_feedback=t}getShowSolution(){return this.sc.show_solution}setShowSolution(t){this.sc.show_solution=t}getTimeLimits(){return this.sc.time_limits}setTimeLimits(t=null,i=null,s=!1){this.setTimeLimitsMinTime(t),this.setTimeLimitsMaxTime(i),this.setTimeLimitsAllowLateSubmission(s)}getTimeLimitsMinTime(){return this.sc.time_limits.min_time}setTimeLimitsMinTime(t){this.sc.time_limits.min_time=t}getTimeLimitsMaxTime(){return this.sc.time_limits.max_time}setTimeLimitsMaxTime(t){this.sc.time_limits.max_time=t}getTimeLimitsAllowLateSubmission(){return this.sc.time_limits.allow_late_submission}setTimeLimitsAllowLateSubmission(t){this.sc.time_limits.allow_late_submission=t}getValidateResponses(){return this.sc.validate_responses}setValidateResponses(t){this.sc.validate_responses=t}}class Cc{constructor(t,i){return typeof t>"u"?this:(this.identifier=t,this.guid=i.getItemContextGuid(),this.contextVariables=i.getContextDeclarations(),this.responseVariables=i.getResponseDeclarations(),this.templateVariables=i.getTemplateDeclarations(),this.outcomeVariables=i.getOutcomeDeclarations(),this.validationMessages=i.getItemContextValidationMessages(),this)}createStateFromState(t){return this.identifier=t.identifier,this.guid=t.guid,this.contextVariables=t.contextVariables,this.responseVariables=t.responseVariables,this.templateVariables=t.templateVariables,this.outcomeVariables=t.outcomeVariables,this.validationMessages=t.validationMessages,this.getSerializedState()}getSerializedState(){return{identifier:this.identifier,guid:this.guid,contextVariables:this.serializeVariables(this.contextVariables),responseVariables:this.serializeResponseVariables(this.responseVariables),outcomeVariables:this.serializeOutcomeVariables(this.outcomeVariables),templateVariables:this.serializeVariables(this.templateVariables),validationMessages:this.serializeValidationMessages(this.validationMessages)}}serializeResponseVariables(t){let i=[];return t.forEach(s=>{let n={identifier:s.identifier,cardinality:s.cardinality,baseType:this.resolveBaseType(s.baseType),value:this.serializeVariableValue(s.cardinality,s.value),state:this.serializeVariableState(s.state)};"correctResponse"in s&&(n.correctResponse=this.serializeVariableValue(s.cardinality,s.correctResponse)),i.push(n)}),i}serializeOutcomeVariables(t){let i=[];return t.forEach(s=>{i.push({identifier:s.identifier,cardinality:s.cardinality,baseType:this.resolveBaseType(s.baseType),value:this.serializeVariableValue(s.cardinality,s.value),view:s.view,interpretation:s.interpretation,longInterpretation:s.longInterpretation,normalMaximum:s.normalMaximum,normalMinimum:s.normalMinimum,masteryValue:s.masteryValue,externalScored:s.externalScored,variableIdentifierRef:s.variableIdentifierRef})}),i}serializeVariables(t){let i=[];return t.forEach(s=>{i.push({identifier:s.identifier,cardinality:s.cardinality,baseType:this.resolveBaseType(s.baseType),value:this.serializeVariableValue(s.cardinality,s.value)})}),i}serializeValidationMessages(t){let i=[];return t.forEach(s=>{i.push({identifier:s.identifier,message:s.message})}),i}serializeVariableValue(t,i){return t!=="record"?JSON.parse(JSON.stringify(i)):this.serializeRecordVariableValue(i)}serializeVariableState(t){return JSON.parse(JSON.stringify(t))}resolveBaseType(t){return typeof t>"u"?null:t}serializeRecordVariableValue(t){const i=this.strMapToJson(t);return this.jsonToStrMap(i)}strMapToJson(t){return JSON.stringify(this.strMapToObj(t))}jsonToStrMap(t){return this.objToStrMap(JSON.parse(t))}strMapToObj(t){let i=Object.create(null);for(let[s,n]of t)i[s]=typeof n=="object"&&n!==null?n.getValue():n;return i}objToStrMap(t){let i=new Map;for(let s of Object.keys(t))i.set(s,t[s]);return i}}class Wb{constructor(){ee(this,"itemTimer");ee(this,"itemDuration");this.setTime(0)}getTime(){return this.itemDuration}setTime(t){this.itemDuration=t}startTimer(){this.clearTimer(),this.setTime(0),this.itemTimer=setInterval(this.updateTime.bind(this),1e3)}updateTime(){++this.itemDuration}resetTimer(){this.clearTimer(),this.setTime(0)}clearTimer(){clearInterval(this.itemTimer)}}var zb=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,Tc=Math.ceil,Yt=Math.floor,Ct="[BigNumber Error] ",yf=Ct+"Number primitive has more than 15 significant digits: ",fi=1e14,ye=14,wf=9007199254740991,Sc=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],ws=1e7,Ot=1e9;function bf(e){var t,i,s,n=x.prototype={constructor:x,toString:null,valueOf:null},r=new x(1),a=20,o=4,u=-7,h=21,f=-1e7,p=1e7,y=!1,w=1,b=0,C={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},S="0123456789abcdefghijklmnopqrstuvwxyz",$=!0;function x(m,v){var T,N,V,L,q,A,M,k,R=this;if(!(R instanceof x))return new x(m,v);if(v==null){if(m&&m._isBigNumber===!0){R.s=m.s,!m.c||m.e>p?R.c=R.e=null:m.e<f?R.c=[R.e=0]:(R.e=m.e,R.c=m.c.slice());return}if((A=typeof m=="number")&&m*0==0){if(R.s=1/m<0?(m=-m,-1):1,m===~~m){for(L=0,q=m;q>=10;q/=10,L++);L>p?R.c=R.e=null:(R.e=L,R.c=[m]);return}k=String(m)}else{if(!zb.test(k=String(m)))return s(R,k,A);R.s=k.charCodeAt(0)==45?(k=k.slice(1),-1):1}(L=k.indexOf("."))>-1&&(k=k.replace(".","")),(q=k.search(/e/i))>0?(L<0&&(L=q),L+=+k.slice(q+1),k=k.substring(0,q)):L<0&&(L=k.length)}else{if(De(v,2,S.length,"Base"),v==10&&$)return R=new x(m),Q(R,a+R.e+1,o);if(k=String(m),A=typeof m=="number"){if(m*0!=0)return s(R,k,A,v);if(R.s=1/m<0?(k=k.slice(1),-1):1,x.DEBUG&&k.replace(/^0\.0*|\./,"").length>15)throw Error(yf+m)}else R.s=k.charCodeAt(0)===45?(k=k.slice(1),-1):1;for(T=S.slice(0,v),L=q=0,M=k.length;q<M;q++)if(T.indexOf(N=k.charAt(q))<0){if(N=="."){if(q>L){L=M;continue}}else if(!V&&(k==k.toUpperCase()&&(k=k.toLowerCase())||k==k.toLowerCase()&&(k=k.toUpperCase()))){V=!0,q=-1,L=0;continue}return s(R,String(m),A,v)}A=!1,k=i(k,v,10,R.s),(L=k.indexOf("."))>-1?k=k.replace(".",""):L=k.length}for(q=0;k.charCodeAt(q)===48;q++);for(M=k.length;k.charCodeAt(--M)===48;);if(k=k.slice(q,++M)){if(M-=q,A&&x.DEBUG&&M>15&&(m>wf||m!==Yt(m)))throw Error(yf+R.s*m);if((L=L-q-1)>p)R.c=R.e=null;else if(L<f)R.c=[R.e=0];else{if(R.e=L,R.c=[],q=(L+1)%ye,L<0&&(q+=ye),q<M){for(q&&R.c.push(+k.slice(0,q)),M-=ye;q<M;)R.c.push(+k.slice(q,q+=ye));q=ye-(k=k.slice(q)).length}else q-=M;for(;q--;k+="0");R.c.push(+k)}}else R.c=[R.e=0]}x.clone=bf,x.ROUND_UP=0,x.ROUND_DOWN=1,x.ROUND_CEIL=2,x.ROUND_FLOOR=3,x.ROUND_HALF_UP=4,x.ROUND_HALF_DOWN=5,x.ROUND_HALF_EVEN=6,x.ROUND_HALF_CEIL=7,x.ROUND_HALF_FLOOR=8,x.EUCLID=9,x.config=x.set=function(m){var v,T;if(m!=null)if(typeof m=="object"){if(m.hasOwnProperty(v="DECIMAL_PLACES")&&(T=m[v],De(T,0,Ot,v),a=T),m.hasOwnProperty(v="ROUNDING_MODE")&&(T=m[v],De(T,0,8,v),o=T),m.hasOwnProperty(v="EXPONENTIAL_AT")&&(T=m[v],T&&T.pop?(De(T[0],-1e9,0,v),De(T[1],0,Ot,v),u=T[0],h=T[1]):(De(T,-1e9,Ot,v),u=-(h=T<0?-T:T))),m.hasOwnProperty(v="RANGE"))if(T=m[v],T&&T.pop)De(T[0],-1e9,-1,v),De(T[1],1,Ot,v),f=T[0],p=T[1];else if(De(T,-1e9,Ot,v),T)f=-(p=T<0?-T:T);else throw Error(Ct+v+" cannot be zero: "+T);if(m.hasOwnProperty(v="CRYPTO"))if(T=m[v],T===!!T)if(T)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))y=T;else throw y=!T,Error(Ct+"crypto unavailable");else y=T;else throw Error(Ct+v+" not true or false: "+T);if(m.hasOwnProperty(v="MODULO_MODE")&&(T=m[v],De(T,0,9,v),w=T),m.hasOwnProperty(v="POW_PRECISION")&&(T=m[v],De(T,0,Ot,v),b=T),m.hasOwnProperty(v="FORMAT"))if(T=m[v],typeof T=="object")C=T;else throw Error(Ct+v+" not an object: "+T);if(m.hasOwnProperty(v="ALPHABET"))if(T=m[v],typeof T=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(T))$=T.slice(0,10)=="0123456789",S=T;else throw Error(Ct+v+" invalid: "+T)}else throw Error(Ct+"Object expected: "+m);return{DECIMAL_PLACES:a,ROUNDING_MODE:o,EXPONENTIAL_AT:[u,h],RANGE:[f,p],CRYPTO:y,MODULO_MODE:w,POW_PRECISION:b,FORMAT:C,ALPHABET:S}},x.isBigNumber=function(m){if(!m||m._isBigNumber!==!0)return!1;if(!x.DEBUG)return!0;var v,T,N=m.c,V=m.e,L=m.s;e:if({}.toString.call(N)=="[object Array]"){if((L===1||L===-1)&&V>=-1e9&&V<=Ot&&V===Yt(V)){if(N[0]===0){if(V===0&&N.length===1)return!0;break e}if(v=(V+1)%ye,v<1&&(v+=ye),String(N[0]).length==v){for(v=0;v<N.length;v++)if(T=N[v],T<0||T>=fi||T!==Yt(T))break e;if(T!==0)return!0}}}else if(N===null&&V===null&&(L===null||L===1||L===-1))return!0;throw Error(Ct+"Invalid BigNumber: "+m)},x.maximum=x.max=function(){return E(arguments,-1)},x.minimum=x.min=function(){return E(arguments,1)},x.random=function(){var m=9007199254740992,v=Math.random()*m&2097151?function(){return Yt(Math.random()*m)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(T){var N,V,L,q,A,M=0,k=[],R=new x(r);if(T==null?T=a:De(T,0,Ot),q=Tc(T/ye),y)if(crypto.getRandomValues){for(N=crypto.getRandomValues(new Uint32Array(q*=2));M<q;)A=N[M]*131072+(N[M+1]>>>11),A>=9e15?(V=crypto.getRandomValues(new Uint32Array(2)),N[M]=V[0],N[M+1]=V[1]):(k.push(A%1e14),M+=2);M=q/2}else if(crypto.randomBytes){for(N=crypto.randomBytes(q*=7);M<q;)A=(N[M]&31)*281474976710656+N[M+1]*1099511627776+N[M+2]*4294967296+N[M+3]*16777216+(N[M+4]<<16)+(N[M+5]<<8)+N[M+6],A>=9e15?crypto.randomBytes(7).copy(N,M):(k.push(A%1e14),M+=7);M=q/7}else throw y=!1,Error(Ct+"crypto unavailable");if(!y)for(;M<q;)A=v(),A<9e15&&(k[M++]=A%1e14);for(q=k[--M],T%=ye,q&&T&&(A=Sc[ye-T],k[M]=Yt(q/A)*A);k[M]===0;k.pop(),M--);if(M<0)k=[L=0];else{for(L=-1;k[0]===0;k.splice(0,1),L-=ye);for(M=1,A=k[0];A>=10;A/=10,M++);M<ye&&(L-=ye-M)}return R.e=L,R.c=k,R}}(),x.sum=function(){for(var m=1,v=arguments,T=new x(v[0]);m<v.length;)T=T.plus(v[m++]);return T},i=function(){var m="0123456789";function v(T,N,V,L){for(var q,A=[0],M,k=0,R=T.length;k<R;){for(M=A.length;M--;A[M]*=N);for(A[0]+=L.indexOf(T.charAt(k++)),q=0;q<A.length;q++)A[q]>V-1&&(A[q+1]==null&&(A[q+1]=0),A[q+1]+=A[q]/V|0,A[q]%=V)}return A.reverse()}return function(T,N,V,L,q){var A,M,k,R,Y,Z,ne,de,ge=T.indexOf("."),Ee=a,D=o;for(ge>=0&&(R=b,b=0,T=T.replace(".",""),de=new x(N),Z=de.pow(T.length-ge),b=R,de.c=v(Ji(Zt(Z.c),Z.e,"0"),10,V,m),de.e=de.c.length),ne=v(T,N,V,q?(A=S,m):(A=m,S)),k=R=ne.length;ne[--R]==0;ne.pop());if(!ne[0])return A.charAt(0);if(ge<0?--k:(Z.c=ne,Z.e=k,Z.s=L,Z=t(Z,de,Ee,D,V),ne=Z.c,Y=Z.r,k=Z.e),M=k+Ee+1,ge=ne[M],R=V/2,Y=Y||M<0||ne[M+1]!=null,Y=D<4?(ge!=null||Y)&&(D==0||D==(Z.s<0?3:2)):ge>R||ge==R&&(D==4||Y||D==6&&ne[M-1]&1||D==(Z.s<0?8:7)),M<1||!ne[0])T=Y?Ji(A.charAt(1),-Ee,A.charAt(0)):A.charAt(0);else{if(ne.length=M,Y)for(--V;++ne[--M]>V;)ne[M]=0,M||(++k,ne=[1].concat(ne));for(R=ne.length;!ne[--R];);for(ge=0,T="";ge<=R;T+=A.charAt(ne[ge++]));T=Ji(T,k,A.charAt(0))}return T}}(),t=function(){function m(N,V,L){var q,A,M,k,R=0,Y=N.length,Z=V%ws,ne=V/ws|0;for(N=N.slice();Y--;)M=N[Y]%ws,k=N[Y]/ws|0,q=ne*M+k*Z,A=Z*M+q%ws*ws+R,R=(A/L|0)+(q/ws|0)+ne*k,N[Y]=A%L;return R&&(N=[R].concat(N)),N}function v(N,V,L,q){var A,M;if(L!=q)M=L>q?1:-1;else for(A=M=0;A<L;A++)if(N[A]!=V[A]){M=N[A]>V[A]?1:-1;break}return M}function T(N,V,L,q){for(var A=0;L--;)N[L]-=A,A=N[L]<V[L]?1:0,N[L]=A*q+N[L]-V[L];for(;!N[0]&&N.length>1;N.splice(0,1));}return function(N,V,L,q,A){var M,k,R,Y,Z,ne,de,ge,Ee,D,z,Me,qe,vt,rt,He,dt,Fe=N.s==V.s?1:-1,Oe=N.c,Ie=V.c;if(!Oe||!Oe[0]||!Ie||!Ie[0])return new x(!N.s||!V.s||(Oe?Ie&&Oe[0]==Ie[0]:!Ie)?NaN:Oe&&Oe[0]==0||!Ie?Fe*0:Fe/0);for(ge=new x(Fe),Ee=ge.c=[],k=N.e-V.e,Fe=L+k+1,A||(A=fi,k=Xt(N.e/ye)-Xt(V.e/ye),Fe=Fe/ye|0),R=0;Ie[R]==(Oe[R]||0);R++);if(Ie[R]>(Oe[R]||0)&&k--,Fe<0)Ee.push(1),Y=!0;else{for(vt=Oe.length,He=Ie.length,R=0,Fe+=2,Z=Yt(A/(Ie[0]+1)),Z>1&&(Ie=m(Ie,Z,A),Oe=m(Oe,Z,A),He=Ie.length,vt=Oe.length),qe=He,D=Oe.slice(0,He),z=D.length;z<He;D[z++]=0);dt=Ie.slice(),dt=[0].concat(dt),rt=Ie[0],Ie[1]>=A/2&&rt++;do{if(Z=0,M=v(Ie,D,He,z),M<0){if(Me=D[0],He!=z&&(Me=Me*A+(D[1]||0)),Z=Yt(Me/rt),Z>1)for(Z>=A&&(Z=A-1),ne=m(Ie,Z,A),de=ne.length,z=D.length;v(ne,D,de,z)==1;)Z--,T(ne,He<de?dt:Ie,de,A),de=ne.length,M=1;else Z==0&&(M=Z=1),ne=Ie.slice(),de=ne.length;if(de<z&&(ne=[0].concat(ne)),T(D,ne,z,A),z=D.length,M==-1)for(;v(Ie,D,He,z)<1;)Z++,T(D,He<z?dt:Ie,z,A),z=D.length}else M===0&&(Z++,D=[0]);Ee[R++]=Z,D[0]?D[z++]=Oe[qe]||0:(D=[Oe[qe]],z=1)}while((qe++<vt||D[0]!=null)&&Fe--);Y=D[0]!=null,Ee[0]||Ee.splice(0,1)}if(A==fi){for(R=1,Fe=Ee[0];Fe>=10;Fe/=10,R++);Q(ge,L+(ge.e=R+k*ye-1)+1,q,Y)}else ge.e=k,ge.r=+Y;return ge}}();function B(m,v,T,N){var V,L,q,A,M;if(T==null?T=o:De(T,0,8),!m.c)return m.toString();if(V=m.c[0],q=m.e,v==null)M=Zt(m.c),M=N==1||N==2&&(q<=u||q>=h)?Eo(M,q):Ji(M,q,"0");else if(m=Q(new x(m),v,T),L=m.e,M=Zt(m.c),A=M.length,N==1||N==2&&(v<=L||L<=u)){for(;A<v;M+="0",A++);M=Eo(M,L)}else if(v-=q,M=Ji(M,L,"0"),L+1>A){if(--v>0)for(M+=".";v--;M+="0");}else if(v+=L-A,v>0)for(L+1==A&&(M+=".");v--;M+="0");return m.s<0&&V?"-"+M:M}function E(m,v){for(var T,N,V=1,L=new x(m[0]);V<m.length;V++)N=new x(m[V]),(!N.s||(T=Qs(L,N))===v||T===0&&L.s===v)&&(L=N);return L}function G(m,v,T){for(var N=1,V=v.length;!v[--V];v.pop());for(V=v[0];V>=10;V/=10,N++);return(T=N+T*ye-1)>p?m.c=m.e=null:T<f?m.c=[m.e=0]:(m.e=T,m.c=v),m}s=function(){var m=/^(-?)0([xbo])(?=\w[\w.]*$)/i,v=/^([^.]+)\.$/,T=/^\.([^.]+)$/,N=/^-?(Infinity|NaN)$/,V=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(L,q,A,M){var k,R=A?q:q.replace(V,"");if(N.test(R))L.s=isNaN(R)?null:R<0?-1:1;else{if(!A&&(R=R.replace(m,function(Y,Z,ne){return k=(ne=ne.toLowerCase())=="x"?16:ne=="b"?2:8,!M||M==k?Z:Y}),M&&(k=M,R=R.replace(v,"$1").replace(T,"0.$1")),q!=R))return new x(R,k);if(x.DEBUG)throw Error(Ct+"Not a"+(M?" base "+M:"")+" number: "+q);L.s=null}L.c=L.e=null}}();function Q(m,v,T,N){var V,L,q,A,M,k,R,Y=m.c,Z=Sc;if(Y){e:{for(V=1,A=Y[0];A>=10;A/=10,V++);if(L=v-V,L<0)L+=ye,q=v,M=Y[k=0],R=Yt(M/Z[V-q-1]%10);else if(k=Tc((L+1)/ye),k>=Y.length)if(N){for(;Y.length<=k;Y.push(0));M=R=0,V=1,L%=ye,q=L-ye+1}else break e;else{for(M=A=Y[k],V=1;A>=10;A/=10,V++);L%=ye,q=L-ye+V,R=q<0?0:Yt(M/Z[V-q-1]%10)}if(N=N||v<0||Y[k+1]!=null||(q<0?M:M%Z[V-q-1]),N=T<4?(R||N)&&(T==0||T==(m.s<0?3:2)):R>5||R==5&&(T==4||N||T==6&&(L>0?q>0?M/Z[V-q]:0:Y[k-1])%10&1||T==(m.s<0?8:7)),v<1||!Y[0])return Y.length=0,N?(v-=m.e+1,Y[0]=Z[(ye-v%ye)%ye],m.e=-v||0):Y[0]=m.e=0,m;if(L==0?(Y.length=k,A=1,k--):(Y.length=k+1,A=Z[ye-L],Y[k]=q>0?Yt(M/Z[V-q]%Z[q])*A:0),N)for(;;)if(k==0){for(L=1,q=Y[0];q>=10;q/=10,L++);for(q=Y[0]+=A,A=1;q>=10;q/=10,A++);L!=A&&(m.e++,Y[0]==fi&&(Y[0]=1));break}else{if(Y[k]+=A,Y[k]!=fi)break;Y[k--]=0,A=1}for(L=Y.length;Y[--L]===0;Y.pop());}m.e>p?m.c=m.e=null:m.e<f&&(m.c=[m.e=0])}return m}function J(m){var v,T=m.e;return T===null?m.toString():(v=Zt(m.c),v=T<=u||T>=h?Eo(v,T):Ji(v,T,"0"),m.s<0?"-"+v:v)}return n.absoluteValue=n.abs=function(){var m=new x(this);return m.s<0&&(m.s=1),m},n.comparedTo=function(m,v){return Qs(this,new x(m,v))},n.decimalPlaces=n.dp=function(m,v){var T,N,V,L=this;if(m!=null)return De(m,0,Ot),v==null?v=o:De(v,0,8),Q(new x(L),m+L.e+1,v);if(!(T=L.c))return null;if(N=((V=T.length-1)-Xt(this.e/ye))*ye,V=T[V])for(;V%10==0;V/=10,N--);return N<0&&(N=0),N},n.dividedBy=n.div=function(m,v){return t(this,new x(m,v),a,o)},n.dividedToIntegerBy=n.idiv=function(m,v){return t(this,new x(m,v),0,1)},n.exponentiatedBy=n.pow=function(m,v){var T,N,V,L,q,A,M,k,R,Y=this;if(m=new x(m),m.c&&!m.isInteger())throw Error(Ct+"Exponent not an integer: "+J(m));if(v!=null&&(v=new x(v)),A=m.e>14,!Y.c||!Y.c[0]||Y.c[0]==1&&!Y.e&&Y.c.length==1||!m.c||!m.c[0])return R=new x(Math.pow(+J(Y),A?m.s*(2-vo(m)):+J(m))),v?R.mod(v):R;if(M=m.s<0,v){if(v.c?!v.c[0]:!v.s)return new x(NaN);N=!M&&Y.isInteger()&&v.isInteger(),N&&(Y=Y.mod(v))}else{if(m.e>9&&(Y.e>0||Y.e<-1||(Y.e==0?Y.c[0]>1||A&&Y.c[1]>=24e7:Y.c[0]<8e13||A&&Y.c[0]<=9999975e7)))return L=Y.s<0&&vo(m)?-0:0,Y.e>-1&&(L=1/L),new x(M?1/L:L);b&&(L=Tc(b/ye+2))}for(A?(T=new x(.5),M&&(m.s=1),k=vo(m)):(V=Math.abs(+J(m)),k=V%2),R=new x(r);;){if(k){if(R=R.times(Y),!R.c)break;L?R.c.length>L&&(R.c.length=L):N&&(R=R.mod(v))}if(V){if(V=Yt(V/2),V===0)break;k=V%2}else if(m=m.times(T),Q(m,m.e+1,1),m.e>14)k=vo(m);else{if(V=+J(m),V===0)break;k=V%2}Y=Y.times(Y),L?Y.c&&Y.c.length>L&&(Y.c.length=L):N&&(Y=Y.mod(v))}return N?R:(M&&(R=r.div(R)),v?R.mod(v):L?Q(R,b,o,q):R)},n.integerValue=function(m){var v=new x(this);return m==null?m=o:De(m,0,8),Q(v,v.e+1,m)},n.isEqualTo=n.eq=function(m,v){return Qs(this,new x(m,v))===0},n.isFinite=function(){return!!this.c},n.isGreaterThan=n.gt=function(m,v){return Qs(this,new x(m,v))>0},n.isGreaterThanOrEqualTo=n.gte=function(m,v){return(v=Qs(this,new x(m,v)))===1||v===0},n.isInteger=function(){return!!this.c&&Xt(this.e/ye)>this.c.length-2},n.isLessThan=n.lt=function(m,v){return Qs(this,new x(m,v))<0},n.isLessThanOrEqualTo=n.lte=function(m,v){return(v=Qs(this,new x(m,v)))===-1||v===0},n.isNaN=function(){return!this.s},n.isNegative=function(){return this.s<0},n.isPositive=function(){return this.s>0},n.isZero=function(){return!!this.c&&this.c[0]==0},n.minus=function(m,v){var T,N,V,L,q=this,A=q.s;if(m=new x(m,v),v=m.s,!A||!v)return new x(NaN);if(A!=v)return m.s=-v,q.plus(m);var M=q.e/ye,k=m.e/ye,R=q.c,Y=m.c;if(!M||!k){if(!R||!Y)return R?(m.s=-v,m):new x(Y?q:NaN);if(!R[0]||!Y[0])return Y[0]?(m.s=-v,m):new x(R[0]?q:o==3?-0:0)}if(M=Xt(M),k=Xt(k),R=R.slice(),A=M-k){for((L=A<0)?(A=-A,V=R):(k=M,V=Y),V.reverse(),v=A;v--;V.push(0));V.reverse()}else for(N=(L=(A=R.length)<(v=Y.length))?A:v,A=v=0;v<N;v++)if(R[v]!=Y[v]){L=R[v]<Y[v];break}if(L&&(V=R,R=Y,Y=V,m.s=-m.s),v=(N=Y.length)-(T=R.length),v>0)for(;v--;R[T++]=0);for(v=fi-1;N>A;){if(R[--N]<Y[N]){for(T=N;T&&!R[--T];R[T]=v);--R[T],R[N]+=fi}R[N]-=Y[N]}for(;R[0]==0;R.splice(0,1),--k);return R[0]?G(m,R,k):(m.s=o==3?-1:1,m.c=[m.e=0],m)},n.modulo=n.mod=function(m,v){var T,N,V=this;return m=new x(m,v),!V.c||!m.s||m.c&&!m.c[0]?new x(NaN):!m.c||V.c&&!V.c[0]?new x(V):(w==9?(N=m.s,m.s=1,T=t(V,m,0,3),m.s=N,T.s*=N):T=t(V,m,0,w),m=V.minus(T.times(m)),!m.c[0]&&w==1&&(m.s=V.s),m)},n.multipliedBy=n.times=function(m,v){var T,N,V,L,q,A,M,k,R,Y,Z,ne,de,ge,Ee,D=this,z=D.c,Me=(m=new x(m,v)).c;if(!z||!Me||!z[0]||!Me[0])return!D.s||!m.s||z&&!z[0]&&!Me||Me&&!Me[0]&&!z?m.c=m.e=m.s=null:(m.s*=D.s,!z||!Me?m.c=m.e=null:(m.c=[0],m.e=0)),m;for(N=Xt(D.e/ye)+Xt(m.e/ye),m.s*=D.s,M=z.length,Y=Me.length,M<Y&&(de=z,z=Me,Me=de,V=M,M=Y,Y=V),V=M+Y,de=[];V--;de.push(0));for(ge=fi,Ee=ws,V=Y;--V>=0;){for(T=0,Z=Me[V]%Ee,ne=Me[V]/Ee|0,q=M,L=V+q;L>V;)k=z[--q]%Ee,R=z[q]/Ee|0,A=ne*k+R*Z,k=Z*k+A%Ee*Ee+de[L]+T,T=(k/ge|0)+(A/Ee|0)+ne*R,de[L--]=k%ge;de[L]=T}return T?++N:de.splice(0,1),G(m,de,N)},n.negated=function(){var m=new x(this);return m.s=-m.s||null,m},n.plus=function(m,v){var T,N=this,V=N.s;if(m=new x(m,v),v=m.s,!V||!v)return new x(NaN);if(V!=v)return m.s=-v,N.minus(m);var L=N.e/ye,q=m.e/ye,A=N.c,M=m.c;if(!L||!q){if(!A||!M)return new x(V/0);if(!A[0]||!M[0])return M[0]?m:new x(A[0]?N:V*0)}if(L=Xt(L),q=Xt(q),A=A.slice(),V=L-q){for(V>0?(q=L,T=M):(V=-V,T=A),T.reverse();V--;T.push(0));T.reverse()}for(V=A.length,v=M.length,V-v<0&&(T=M,M=A,A=T,v=V),V=0;v;)V=(A[--v]=A[v]+M[v]+V)/fi|0,A[v]=fi===A[v]?0:A[v]%fi;return V&&(A=[V].concat(A),++q),G(m,A,q)},n.precision=n.sd=function(m,v){var T,N,V,L=this;if(m!=null&&m!==!!m)return De(m,1,Ot),v==null?v=o:De(v,0,8),Q(new x(L),m,v);if(!(T=L.c))return null;if(V=T.length-1,N=V*ye+1,V=T[V]){for(;V%10==0;V/=10,N--);for(V=T[0];V>=10;V/=10,N++);}return m&&L.e+1>N&&(N=L.e+1),N},n.shiftedBy=function(m){return De(m,-9007199254740991,wf),this.times("1e"+m)},n.squareRoot=n.sqrt=function(){var m,v,T,N,V,L=this,q=L.c,A=L.s,M=L.e,k=a+4,R=new x("0.5");if(A!==1||!q||!q[0])return new x(!A||A<0&&(!q||q[0])?NaN:q?L:1/0);if(A=Math.sqrt(+J(L)),A==0||A==1/0?(v=Zt(q),(v.length+M)%2==0&&(v+="0"),A=Math.sqrt(+v),M=Xt((M+1)/2)-(M<0||M%2),A==1/0?v="5e"+M:(v=A.toExponential(),v=v.slice(0,v.indexOf("e")+1)+M),T=new x(v)):T=new x(A+""),T.c[0]){for(M=T.e,A=M+k,A<3&&(A=0);;)if(V=T,T=R.times(V.plus(t(L,V,k,1))),Zt(V.c).slice(0,A)===(v=Zt(T.c)).slice(0,A))if(T.e<M&&--A,v=v.slice(A-3,A+1),v=="9999"||!N&&v=="4999"){if(!N&&(Q(V,V.e+a+2,0),V.times(V).eq(L))){T=V;break}k+=4,A+=4,N=1}else{(!+v||!+v.slice(1)&&v.charAt(0)=="5")&&(Q(T,T.e+a+2,1),m=!T.times(T).eq(L));break}}return Q(T,T.e+a+1,o,m)},n.toExponential=function(m,v){return m!=null&&(De(m,0,Ot),m++),B(this,m,v,1)},n.toFixed=function(m,v){return m!=null&&(De(m,0,Ot),m=m+this.e+1),B(this,m,v)},n.toFormat=function(m,v,T){var N,V=this;if(T==null)m!=null&&v&&typeof v=="object"?(T=v,v=null):m&&typeof m=="object"?(T=m,m=v=null):T=C;else if(typeof T!="object")throw Error(Ct+"Argument not an object: "+T);if(N=V.toFixed(m,v),V.c){var L,q=N.split("."),A=+T.groupSize,M=+T.secondaryGroupSize,k=T.groupSeparator||"",R=q[0],Y=q[1],Z=V.s<0,ne=Z?R.slice(1):R,de=ne.length;if(M&&(L=A,A=M,M=L,de-=L),A>0&&de>0){for(L=de%A||A,R=ne.substr(0,L);L<de;L+=A)R+=k+ne.substr(L,A);M>0&&(R+=k+ne.slice(L)),Z&&(R="-"+R)}N=Y?R+(T.decimalSeparator||"")+((M=+T.fractionGroupSize)?Y.replace(new RegExp("\\d{"+M+"}\\B","g"),"$&"+(T.fractionGroupSeparator||"")):Y):R}return(T.prefix||"")+N+(T.suffix||"")},n.toFraction=function(m){var v,T,N,V,L,q,A,M,k,R,Y,Z,ne=this,de=ne.c;if(m!=null&&(A=new x(m),!A.isInteger()&&(A.c||A.s!==1)||A.lt(r)))throw Error(Ct+"Argument "+(A.isInteger()?"out of range: ":"not an integer: ")+J(A));if(!de)return new x(ne);for(v=new x(r),k=T=new x(r),N=M=new x(r),Z=Zt(de),L=v.e=Z.length-ne.e-1,v.c[0]=Sc[(q=L%ye)<0?ye+q:q],m=!m||A.comparedTo(v)>0?L>0?v:k:A,q=p,p=1/0,A=new x(Z),M.c[0]=0;R=t(A,v,0,1),V=T.plus(R.times(N)),V.comparedTo(m)!=1;)T=N,N=V,k=M.plus(R.times(V=k)),M=V,v=A.minus(R.times(V=v)),A=V;return V=t(m.minus(T),N,0,1),M=M.plus(V.times(k)),T=T.plus(V.times(N)),M.s=k.s=ne.s,L=L*2,Y=t(k,N,L,o).minus(ne).abs().comparedTo(t(M,T,L,o).minus(ne).abs())<1?[k,N]:[M,T],p=q,Y},n.toNumber=function(){return+J(this)},n.toPrecision=function(m,v){return m!=null&&De(m,1,Ot),B(this,m,v,2)},n.toString=function(m){var v,T=this,N=T.s,V=T.e;return V===null?N?(v="Infinity",N<0&&(v="-"+v)):v="NaN":(m==null?v=V<=u||V>=h?Eo(Zt(T.c),V):Ji(Zt(T.c),V,"0"):m===10&&$?(T=Q(new x(T),a+V+1,o),v=Ji(Zt(T.c),T.e,"0")):(De(m,2,S.length,"Base"),v=i(Ji(Zt(T.c),V,"0"),10,m,N,!0)),N<0&&T.c[0]&&(v="-"+v)),v},n.valueOf=n.toJSON=function(){return J(this)},n._isBigNumber=!0,n[Symbol.toStringTag]="BigNumber",n[Symbol.for("nodejs.util.inspect.custom")]=n.valueOf,e!=null&&x.set(e),x}function Xt(e){var t=e|0;return e>0||e===t?t:t-1}function Zt(e){for(var t,i,s=1,n=e.length,r=e[0]+"";s<n;){for(t=e[s++]+"",i=ye-t.length;i--;t="0"+t);r+=t}for(n=r.length;r.charCodeAt(--n)===48;);return r.slice(0,n+1||1)}function Qs(e,t){var i,s,n=e.c,r=t.c,a=e.s,o=t.s,u=e.e,h=t.e;if(!a||!o)return null;if(i=n&&!n[0],s=r&&!r[0],i||s)return i?s?0:-o:a;if(a!=o)return a;if(i=a<0,s=u==h,!n||!r)return s?0:!n^i?1:-1;if(!s)return u>h^i?1:-1;for(o=(u=n.length)<(h=r.length)?u:h,a=0;a<o;a++)if(n[a]!=r[a])return n[a]>r[a]^i?1:-1;return u==h?0:u>h^i?1:-1}function De(e,t,i,s){if(e<t||e>i||e!==Yt(e))throw Error(Ct+(s||"Argument")+(typeof e=="number"?e<t||e>i?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e))}function vo(e){var t=e.c.length-1;return Xt(e.e/ye)==t&&e.c[t]%2!=0}function Eo(e,t){return(e.length>1?e.charAt(0)+"."+e.slice(1):e)+(t<0?"e":"e+")+t}function Ji(e,t,i){var s,n;if(t<0){for(n=i+".";++t;n+=i);e=n+e}else if(s=e.length,++t>s){for(n=i,t-=s;--t;n+=i);e+=n}else t<s&&(e=e.slice(0,t)+"."+e.slice(t));return e}var j=bf();class O extends Error{constructor(t){super(t),this.name="QtiEvaluationException"}}class te{QTI_RESPONSE_RULES(){return["qti-response-processing-fragment","qti-response-condition","qti-set-outcome-value","qti-lookup-outcome-value","qti-get-outcome-value","qti-exit-response"]}QTI_TEMPLATE_RULES(){return["qti-set-template-value","qti-exit-template","qti-template-condition","qti-set-default-value","qti-set-correct-response","qti-template-constraint"]}QTI_EXPRESSIONS(){return["qti-base-value","qti-variable","qti-correct","qti-default","qti-is-null","qti-null","qti-and","qti-or","qti-not","qti-match","qti-map-response","qti-member","qti-subtract","qti-sum","qti-random","qti-random-float","qti-random-integer","qti-index","qti-integer-divide","qti-integer-modulus","qti-integer-to-float","qti-equal","qti-equal-rounded","qti-field-value","qti-multiple","qti-ordered","qti-map-response-point","qti-product","qti-delete","qti-string-match","qti-pattern-match","qti-substring","qti-round","qti-round-to","qti-truncate","qti-divide","qti-gt","qti-gte","qti-lt","qti-lte","qti-max","qti-min","qti-custom-operator","qti-math-operator","qti-math-constant","qti-repeat","qti-gcd","qti-lcm","qti-stats-operator","qti-power","qti-any-n","qti-inside","qti-test-variables"]}constructor(){}isExpressionNode(t){return this.QTI_EXPRESSIONS().includes(t)}isResponseRuleNode(t){return this.QTI_RESPONSE_RULES().includes(t)}isTemplateRuleNode(t){return this.QTI_TEMPLATE_RULES().includes(t)}nullValue(){return null}isNullValue(t){return typeof t>"u"||t===null}isBaseTypeNumeric(t){return t==="float"||t==="integer"}isSingleValuesMatch(t,i,s){if(this.isBaseTypeNumeric(t)){let n=new j(i),r=new j(s);return n.comparedTo(r)==0}return i===s}isMultipleValuesMatch(t,i,s){if(!Array.isArray(i)||!Array.isArray(s)||i.length!==s.length)return!1;const n=i.concat().sort(),r=s.concat().sort();if(this.isBaseTypeNumeric(t)){for(let a=0;a<n.length;a++)if(!this.isSingleValuesMatch(t,n[a],r[a]))return!1}else for(let a=0;a<n.length;a++)if(n[a]!==r[a])return!1;return!0}isOrderedValuesMatch(t,i,s){if(!Array.isArray(i)||!Array.isArray(s)||i.length!==s.length)return!1;if(this.isBaseTypeNumeric(t)){for(let n=0;n<i.length;n++)if(!this.isSingleValuesMatch(t,i[n],s[n]))return!1}else for(let n=0;n<i.length;n++)if(i[n]!==s[n])return!1;return!0}mapResponse(t){if(this.isNullValue(t.value))return t.mapping.getDefaultValue();const i=t.mapping.getValue(),s=i.length;if(t.cardinality==="single"){let n=this.isBaseTypeNumeric(t.baseType)?new j(t.value).toString():t.value;for(let r=0;r<s;r++){const a=i[r];if(this.isSingleValuesMatch("string",a.caseSensitive?a.mapKey:a.mapKey.toLowerCase(),a.caseSensitive?n:n.toLowerCase()))return t.mapping.applyConstraints(new j(a.mappedValue))}}else if(t.cardinality==="multiple"||t.cardinality==="ordered"){let n=new j(0),r=t.value;if(this.isBaseTypeNumeric(t.baseType))for(let a=0;a<r.length;a++)r[a]!==null&&(r[a]=new j(r[a]).toString());r=this.mappingEliminateNullsAndDuplicates(r);for(let a=0;a<s;a++){const o=i[a];for(let u=0;u<r.length;u++)this.isSingleValuesMatch("string",o.caseSensitive?o.mapKey:o.mapKey.toLowerCase(),o.caseSensitive?r[u]:r[u].toLowerCase())&&(n=n.plus(o.mappedValue))}return t.mapping.applyConstraints(n)}return t.mapping.getDefaultValue()}mappingEliminateNullsAndDuplicates(t){let i=t.length,s=[],n={};for(let r=0;r<i;r++)t[r]!==null&&(n[t[r]]=0);for(let r in n)s.push(r);return s}mapValueFromLookupTable(t,i){if(this.isNullValue(t.lookupTable))return this.nullValue();if(this.isNullValue(i))return t.lookupTable.getDefaultValue();const s=t.lookupTable.getValue(),n=t.lookupTable.getTableType();if(i=new j(i),n==="interpolation"){s.sort(function(r,a){return r.sourceValue-a.sourceValue});for(let r=0;r<s.length;r++){let a=s[r];const o=new j(a.sourceValue);if(i.comparedTo(o)<0||a.includeBoundary&&i.comparedTo(o)===0)return a.targetValue}}else if(n==="match"){i=new j(i);for(let r=0;r<s.length;r++){let a=s[r];const o=new j(a.sourceValue);if(i.comparedTo(o)===0)return a.targetValue}}return t.lookupTable.getDefaultValue()}mapResponsePoint(t){if(this.isNullValue(t.value))return t.areaMapping.getDefaultValue();const i=t.areaMapping.getValue(),s=i.length;if(t.cardinality==="single"){let n=this.toPointObject(t.value);for(let r=0;r<s;r++){const a=i[r];if(this.isPointInside(a.mapShape,a.mapCoords,n))return t.areaMapping.applyConstraints(new j(a.mappedValue))}}else if(t.cardinality==="multiple"){let n=new j(0),r=t.value,a=Array.from(r);for(let o=0;o<s;o++){const u=i[o];let h=!0;for(let f=0;f<r.length;f++){let p=this.toPointObject(r[f]);if(this.isPointInside(u.mapShape,u.mapCoords,p)){h&&(n=n.plus(u.mappedValue),h=!1);const y=a.indexOf(r[f]);y>-1&&a.splice(y,1)}}}return n=n.plus(new j(t.areaMapping.getDefaultValue()).times(a.length)),t.areaMapping.applyConstraints(n)}return t.areaMapping.getDefaultValue()}toPointObject(t){if(t===null||typeof t!="string")return null;const i=t.split(" ");if(i.length!=2)return null;const s=new j(i[0]).toNumber(),n=new j(i[1]).toNumber();return{x:s,y:n}}shuffleArray(t){for(let i=t.length-1;i>0;i--){let s=Math.floor(Math.random()*(i+1)),n=t[i];t[i]=t[s],t[s]=n}}shuffleArrayFixed(t){for(let i=t.length-1;i>0;i--){let s=Math.floor(Math.random()*(i+1));if(t[i].fixed||t[s].fixed)continue;let n=t[i];t[i]=t[s],t[s]=n}}generalizedLcm(t,i){let s=i[0];for(let n=1;n<t;n++){if(s===0||i[n]===0)return 0;s=this.lcm(s,i[n])}return s}lcm(t,i){return new j(t).multipliedBy(i).dividedBy(this.gcd(t,i)).toNumber()}generalizedGcd(t,i){let s=i[0];for(let n=1;n<t;n++)s=this.gcd(s,i[n]);return s}gcd(t,i){return i=new j(i),i.isZero()?t:this.gcd(i.toNumber(),new j(t).modulo(i).toNumber())}getParametersFromDefinition(t){let i=new Map;if(typeof t>"u"||(t=t.trim(),t.length===0))return i;let s=t.split("|||");for(let n=0;n<s.length;n++){const r=s[n].split("=");i.set(r[0],r.length<2?"":r[1].replaceAll("=","="))}return i}computeWordCount(t){const i=t.match(/\S+/g);return i===null?0:i.length}isPointInside(t,i,s){const n={COORDS_LENGTH:3,CENTER_X:0,CENTER_Y:1,RADIUS:2,isInside(u,h){const f=Math.pow(h.x-u[this.CENTER_X],2),p=Math.pow(h.y-u[this.CENTER_Y],2);return f+p<=Math.pow(u[this.RADIUS],2)}},r={COORDS_LENGTH:4,LEFT_X:0,TOP_Y:1,RIGHT_X:2,BOTTOM_Y:3,isInside(u,h){return h.x>=u[this.LEFT_X]&&h.x<=u[this.RIGHT_X]&&h.y>=u[this.TOP_Y]&&h.y<=u[this.BOTTOM_Y]}},a={COORDS_LENGTH:4,CENTER_X:0,CENTER_Y:1,H_RADIUS:2,V_RADIUS:3,isInside(u,h){const f=new j(Math.pow(h.x-u[this.CENTER_X],2)/Math.pow(u[this.H_RADIUS],2)),p=new j(Math.pow(h.y-u[this.CENTER_Y],2)/Math.pow(u[this.V_RADIUS],2));return f.plus(p).lte(new j(1))}},o={MINIMUM_COORDS_LENGTH:6,LEFT_X:0,TOP_Y:1,RIGHT_X:2,BOTTOM_Y:3,isInside(u,h){let f=u;if(f[0]!=f[f.length-2]||f[1]!=f[f.length-1]){let C=f;C.push(f[0]),C.push(f[1]),f=C}let p=new j(0);const y=new j(h.x).integerValue(),w=new j(h.y).integerValue();for(let C=0;C<f.length-3;C+=2){const S=new j(f[C]).integerValue(),$=new j(f[C+1]).integerValue(),x=new j(f[C+2]).integerValue(),B=new j(f[C+3]).integerValue(),E=y.minus(x).pow(2).plus(w.minus(B).pow(2)).sqrt(),G=x.minus(S).pow(2).plus(B.minus($).pow(2)).sqrt(),Q=S.minus(y).pow(2).plus($.minus(w).pow(2)).sqrt(),J=new j(Math.acos((Math.pow(E.toNumber(),2)-Math.pow(G.toNumber(),2)+Math.pow(Q.toNumber(),2))/(2*E.toNumber()*Q.toNumber()))*180/Math.PI),m=x.minus(y).times(w.minus($)),v=B.minus(w).times(y.minus(S)),T=m.minus(v);if(J.isNaN())return!0;T.gte(new j(0))?p=p.plus(J):p=p.minus(J)}let b=new j(p);return b=b.dp(6,j.ROUND_HALF_UP),!b.isZero()}};return t==="circle"?n.isInside(i,s):t==="rect"?r.isInside(i,s):t==="poly"?o.isInside(i,s):t==="ellipse"?a.isInside(i,s):t==="default"}valueToPciJson(t,i,s){return t===null?{base:null}:s==="single"?{base:this.baseValueToPciJson(t,i)}:s==="multiple"||s==="ordered"?{list:this.baseValueToPciJson(t,i)}:s==="record"?{record:this.recordValueToPciJson(t)}:{base:null}}baseValueToPciJson(t,i){let s={};switch(i){case"string":case"identifier":case"integer":case"float":case"duration":case"boolean":case"uri":case"file":return s[i]=t,s;case"point":s[i]=n=>n.split(" ").map(Number);return;case"directedPair":case"pair":return s[i]=t.split(" "),s;case"intOrIdentifier":return s[i]=null,s;default:return s[i]=null,s}}recordValueToPciJson(t){let i=[];for(let s of t.values())i.push({name:s.fieldIdentifier,base:s.value===null?null:this.valueToPciJson(s.value,s.baseType,s.cardinality)});return i}processInteractionResponse(t,i){return t.interactionType==="PortableCustom"?this.getValueFromPciJson(t.node.getResponse(),i):t.node.getResponse()}getValueFromPciJson(t,i){if(console.log("[GetValueFromPciJson][Value]",t,i),t===null||typeof i>"u")return this.nullValue();try{if(typeof t!="object")throw new O("Improper value encoding. Must be an Object.");if(Array.isArray(t))throw new O("Improper value encoding. Found Array. Must be an Object.");if(t.base!==void 0){if(i.cardinality==="single")return this.baseValueFromPciJson(t.base,i.baseType);throw new O("Inconsistent value cardinality [base] for this variable. Variable must be single cardinality.")}if(t.list!==void 0){if(i.cardinality==="multiple"||i.cardinality==="ordered")return this.baseValueFromPciJson(t.list,i.baseType);throw new O("Inconsistent value cardinality [list] for this variable. Variable must be multiple or ordered cardinality.")}if(t.record!==void 0){if(i.cardinality==="record")return this.recordValueFromPciJson(t.record,i);throw new O("Inconsistent value cardinality [record] for this variable. Variable must be record cardinality.")}throw new O('Improper value encoding. Must be one of "base", "list", "record".')}catch({name:s,message:n}){return console.log("[PciDecodingException][ValueFromJson] ",n),this.nullValue()}}baseValueFromPciJson(t,i){if(t===null)return this.nullValue();try{if(typeof t!="object")throw new O("Invalid value. Must be an Object.");if(Array.isArray(t))throw new O("Invalid value. Found Array. Must be an Object.");if(t[i]!==void 0){if(i==="point"||i==="directedPair"||i==="pair"){if(!Array.isArray(t[i]))throw new O(`Invalid value. For baseType "${i}", must be an Array`);if(t[i].length!==2)throw new O(`Invalid value. For baseType "${i}", Array must have 2 elements`);return`${t[i][0]} ${t[i][1]}`}return t[i]}throw new O(`Value does not have the required base-type. Expecting ${i}.`)}catch({name:s,message:n}){return console.log("[PciDecodingException][BaseValueFromJson] ",n,t),this.nullValue()}}recordValueFromPciJson(t,i){try{let s=this.getRecordVariableFieldDefinition(i);if(s===null)throw new O(`Unable to retrieve ${i.identifier} record field definition.`);if(typeof t!="object")throw new O("Improper record value encoding. Must be an Array.");if(!Array.isArray(t))throw new O("Improper record value encoding. Must be an Array.");const n=new Map;for(let[r,a]of s)for(let o=0;o<t.length;o++)if(t[o].name!==void 0&&t[o].base!==void 0&&t[o].name===r){const u=this.baseValueFromPciJson(t[o].base,a.getBaseType()),h=new Xe(r,a.getBaseType(),u);n.set(r,h);break}return n}catch({name:s,message:n}){return console.log("[VariableDecodingException][RecordValueFromJson] ",n),new Map}}getRecordVariableFieldDefinition(t){return t==null?null:t.defaultValue!==null?t.defaultValue:t.correctResponse}computeProcessingContext(t){return this.computeProcessingType(t)==="OUTCOME"?"TEST":"ITEM"}computeProcessingType(t){return t===null?"UNKNOWN":t.$options.name==="QtiOutcomeProcessing"?"OUTCOME":t.$options.name==="QtiResponseProcessing"?"RESPONSE":t.$options.name==="QtiTemplateProcessing"?"TEMPLATE":t.$options.name==="QtiBranchRule"?"OUTCOME":this.computeProcessingType(t.$parent)}computeNodeContext(t){return t===null||t.$options.name==="QtiAssessmentItem"?"ITEM":t.$options.name==="QtiAssessmentTest"?"TEST":this.computeNodeContext(t.$parent)}base64ToBytes(t){const i=atob(t);return Uint8Array.from(i,s=>s.codePointAt(0))}bytesToBase64(t){const i=Array.from(t,s=>String.fromCodePoint(s)).join("");return btoa(i)}encodeBytesToBase64(t){const i=new TextEncoder;return this.bytesToBase64(i.encode(t))}decodeBase64ToBytes(t){return new TextDecoder().decode(this.base64ToBytes(t))}}const Kb=new te,I={player:null,state:{item:null,itemBody:null,identifier:"",title:"",responseDeclarations:[],outcomeDeclarations:[],templateDeclarations:[],contextDeclarations:[],stimulusRefs:[],interactions:[],processing:[],feedbacks:[],templates:[],printedVariables:[],catalogs:[],scoringRubricBlocks:[],asyncStateMap:new Map},itemContext:{guid:null,pnp:null,sc:null,state:null,validationMessages:[],lifecycleStatus:null},itemTimer:new Wb,pciContext:{renderer2p0:"assets/pci/pci.html"},pciMessageHandler:null,windowResizeHandler:null,getResponseDeclarations(){return this.state.responseDeclarations},getResponseDeclaration(e){return this.state.responseDeclarations.find(t=>t.identifier===e)},getOutcomeDeclarations(){return this.state.outcomeDeclarations},getOutcomeDeclaration(e){return this.state.outcomeDeclarations.find(t=>t.identifier===e)},getTemplateDeclarations(){return this.state.templateDeclarations},getTemplateMathParameterVariables(){return this.state.templateDeclarations.filter(e=>e.mathVariable===!0)},getTemplateDeclaration(e){return this.state.templateDeclarations.find(t=>t.identifier===e)},getContextDeclarations(){return this.state.contextDeclarations},getContextDeclaration(e){return this.state.contextDeclarations.find(t=>t.identifier===e)},getStimulusRefs(){return this.state.stimulusRefs},getStimulusRef(e){return this.state.stimulusRefs.find(t=>t.identifier===e)},getVariableDeclaration(e){let t=this.state.outcomeDeclarations.find(i=>i.identifier===e);return typeof t<"u"||(t=this.state.responseDeclarations.find(i=>i.identifier===e),typeof t<"u")||(t=this.state.templateDeclarations.find(i=>i.identifier===e),typeof t<"u")||(t=this.state.contextDeclarations.find(i=>i.identifier===e),typeof t<"u")?t:null},getInteraction(e){return this.state.interactions.find(t=>t.identifier===e)},getInteractions(){return this.state.interactions},getProcessing(e){return this.state.processing.find(t=>t.processingType===e)},getFeedbacks(){return this.state.feedbacks},getTemplates(){return this.state.templates},getPrintedVariables(){return this.state.printedVariables},getCatalog(e){return this.state.catalogs.find(t=>t.id===e)},getCatalogs(){return this.state.catalogs},getScoringRubricBlocks(){return this.state.scoringRubricBlocks},getItem(){return this.state.item},setItem(e){this.state.item=e.item},getItemBody(){return this.state.itemBody},setItemBody(e){this.state.itemBody=e},defineResponseDeclaration(e){let t=this.state.responseDeclarations.findIndex(i=>i.identifier==e.identifier);t>-1?this.state.responseDeclarations[t]=e:this.state.responseDeclarations.push(e)},defineOutcomeDeclaration(e){let t=this.state.outcomeDeclarations.findIndex(i=>i.identifier==e.identifier);t>-1?this.state.outcomeDeclarations[t]=e:this.state.outcomeDeclarations.push(e)},defineTemplateDeclaration(e){let t=this.state.templateDeclarations.findIndex(i=>i.identifier==e.identifier);t>-1?this.state.templateDeclarations[t]=e:this.state.templateDeclarations.push(e)},defineContextDeclaration(e){let t=this.state.contextDeclarations.findIndex(i=>i.identifier==e.identifier);t>-1?this.state.contextDeclarations[t]=e:this.state.contextDeclarations.push(e)},defineStimulusRef(e){let t=this.state.stimulusRefs.findIndex(i=>i.identifier==e.identifier);t>-1?this.state.stimulusRefs[t]=e:this.state.stimulusRefs.push(e)},defineInteraction(e){let t=this.state.interactions.findIndex(s=>s.identifier==e.identifier);if(t<0){console.log("[DefineInteraction]["+e.identifier+"]"),this.state.interactions.push(e);return}let i=this.state.interactions[t];i.interactionType=e.interactionType,i.isValidResponse=e.isValidResponse,i.invalidResponseMessage=e.invalidResponseMessage,i.maxSelectionsMessage=e.maxSelectionsMessage,i.node=e.node,i.resetValue=e.resetValue},defineProcessing(e){let t=e.processingType,i=this.state.processing.findIndex(s=>s.processingType==t);i>-1?this.state.processing[i]=e:this.state.processing.push(e),t=="response"?console.log("[QtiResponseProcessing][Defined]",e):t=="template"?console.log("[QtiTemplateProcessing][Defined]",e):t=="outcome"&&console.log("[QtiOutcomeProcessing][Defined]",e)},defineResponseProcessing(e){this.defineProcessing({processingType:"response",node:e.node})},defineTemplateProcessing(e){this.defineProcessing({processingType:"template",node:e.node})},defineItemBody(e){this.setItemBody(e.node)},defineFeedback(e){this.state.feedbacks.push(e),console.log("[DefineFeedback]["+e.outcomeIdentifier+"]["+e.identifier+"]")},defineTemplate(e){this.state.templates.push(e)},definePrintedVariable(e){this.state.printedVariables.push(e)},defineCatalog(e){let t=this.state.catalogs.findIndex(i=>i.id==e.id);if(t<0){this.state.catalogs.push(e);return}this.state.catalogs[t]=e},defineScoringRubricBlock(e){this.state.scoringRubricBlocks.push(e)},resetAll(){this.state.item=null,this.state.itemBody=null,this.state.identifier="",this.state.title="",this.state.responseDeclarations.splice(0,this.state.responseDeclarations.length),this.state.outcomeDeclarations.splice(0,this.state.outcomeDeclarations.length),this.state.templateDeclarations.splice(0,this.state.templateDeclarations.length),this.state.contextDeclarations.splice(0,this.state.contextDeclarations.length),this.state.stimulusRefs.splice(0,this.state.stimulusRefs.length),this.state.interactions.splice(0,this.state.interactions.length),this.state.processing.splice(0,this.state.processing.length),this.state.feedbacks.splice(0,this.state.feedbacks.length),this.state.templates.splice(0,this.state.templates.length),this.state.printedVariables.splice(0,this.state.printedVariables.length),this.state.catalogs.splice(0,this.state.catalogs.length),this.state.scoringRubricBlocks.splice(0,this.state.scoringRubricBlocks.length),this.state.asyncStateMap.clear(),this.resetItemTimer(),this.itemContext.guid=null,this.itemContext.state=null,this.itemContext.validationMessages.splice(0,this.itemContext.validationMessages.length),this.itemContext.lifecycleStatus=null},initializeBuiltInDeclarations(){function e(){return 0}const t=new Map;t.set("candidateIdentifier",new Xe("candidateIdentifier","string",null)),t.set("testIdentifier",new Xe("testIdentifier","string",null)),t.set("environmentIdentifier",new Xe("environmentIdentifier","string",null)),this.defineContextDeclaration({identifier:"QTI_CONTEXT",baseType:null,cardinality:"record",value:t,defaultValue:t}),console.log("[QtiAssessmentItem][QTI_CONTEXT] initialized"),this.defineOutcomeDeclaration({identifier:"SCORE",baseType:"float",cardinality:"single",value:0,defaultValue:0,lookupTable:null,lookupTableType:null,view:null,interpretation:null,longInterpretation:null,normalMaximum:null,normalMinimum:null,masteryValue:null,externalScored:null,variableIdentifierRef:null}),console.log("[QtiAssessmentItem][SCORE] initialized"),this.defineOutcomeDeclaration({identifier:"MAXSCORE",baseType:"float",cardinality:"single",value:0,defaultValue:0,lookupTable:null,lookupTableType:null,view:null,interpretation:null,longInterpretation:null,normalMaximum:null,normalMinimum:null,masteryValue:null,externalScored:null,variableIdentifierRef:null}),console.log("[QtiAssessmentItem][MAXSCORE] initialized"),this.defineOutcomeDeclaration({identifier:"completionStatus",baseType:"identifier",cardinality:"single",value:"not_attempted",defaultValue:"not_attempted",lookupTable:null,lookupTableType:null,normalMaximum:null,normalMinimum:null,externalScored:null,interpretation:null}),console.log("[QtiAssessmentItem][completionStatus] initialized"),this.defineResponseDeclaration({identifier:"numAttempts",baseType:"integer",cardinality:"single",value:0,resetValue:e,defaultValue:0,state:null}),console.log("[QtiAssessmentItem][numAttempts] initialized"),this.defineResponseDeclaration({identifier:"duration",baseType:"duration",cardinality:"single",value:0,resetValue:e,defaultValue:0,state:null}),console.log("[QtiAssessmentItem][duration] initialized")},restoreContextVariables(){if(!this.hasItemContextState())return null;const e=this.getItemContextState();"contextVariables"in e&&e.contextVariables!==null&&e.contextVariables.forEach(t=>{let i=this.state.contextDeclarations.findIndex(s=>s.identifier==t.identifier);i<0||(this.state.contextDeclarations[i].value=t.value)},this)},restoreOutcomeVariables(){if(!this.hasItemContextState())return null;const e=this.getItemContextState();"outcomeVariables"in e&&e.outcomeVariables!==null&&e.outcomeVariables.forEach(t=>{this.setOutcomeVariableValue({identifier:t.identifier,value:t.value})},this)},setOutcomeVariableValue(e){let t=this.state.outcomeDeclarations.findIndex(i=>i.identifier==e.identifier);t<0||(this.state.outcomeDeclarations[t].value=e.value)},resetOutcomeVariableValue(e){let t=this.state.outcomeDeclarations.findIndex(s=>s.identifier==e.identifier);if(t<0)return;let i=this.state.outcomeDeclarations[t];if(i.defaultValue!==null){i.value=this.defaultValue;return}if(i.cardinality==="record"||i.cardinality==="multiple"||i.cardinality==="ordered"){i.value=null;return}if(i.baseType==="integer"||i.baseType==="float"){i.value=0;return}i.value=null},getResponseVariableCorrectResponse(e){let t=this.state.responseDeclarations.findIndex(i=>i.identifier==e);return t<0?null:this.state.responseDeclarations[t].correctResponse},setResponseVariableCorrectResponse(e){let t=this.state.responseDeclarations.findIndex(s=>s.identifier==e.identifier);if(t<0)return;let i=this.state.responseDeclarations[t];i.correctResponse=e.value},setInteractionIsValidResponse(e){let t=this.state.interactions.findIndex(i=>i.identifier==e.identifier);t<0||(this.state.interactions[t].isValidResponse=e.isValidResponse)},resetInteractionStateIsValidResponse(){this.state.interactions.forEach(e=>{e.interactionType!=="EndAttemptInteraction"&&(e.isValidResponse=!1)})},restoreResponseVariables(){if(!this.hasItemContextState())return null;const e=this.getItemContextState();"responseVariables"in e&&e.responseVariables!==null&&e.responseVariables.forEach(t=>{this.setResponseVariableValue({identifier:t.identifier,value:t.value,state:t.state}),"correctResponse"in t&&this.setResponseVariableCorrectResponse({identifier:t.identifier,value:t.correctResponse})},this)},setResponseVariableValue(e){let t=this.state.responseDeclarations.findIndex(s=>s.identifier==e.identifier);if(t<0)return;let i=this.state.responseDeclarations[t];i.value=e.value,i.state=e.state},resetResponseVariableValue(e){let t=this.state.responseDeclarations.findIndex(s=>s.identifier==e.identifier);if(t<0)return;let i=this.state.responseDeclarations[t];i.value=i.defaultValue!==null?i.defaultValue:null},incrementNumAttempts(){let e=this.state.responseDeclarations.findIndex(t=>t.identifier=="numAttempts");this.state.responseDeclarations[e].value+=1},updateItemDuration(){const e=this.getResponseDeclaration("duration");e.value+=this.itemTimer.getTime(),this.restartItemTimer()},restartItemTimer(){this.itemTimer.startTimer()},resetItemTimer(){this.itemTimer.resetTimer()},setTemplateVariableValue(e){let t=this.state.templateDeclarations.findIndex(i=>i.identifier==e.identifier);t<0||(this.state.templateDeclarations[t].value=e.value)},resetTemplateVariables(){this.state.templateDeclarations.forEach(e=>{e.node.reset()})},setVariableDefaultValue(e){let t=this.state.responseDeclarations.findIndex(i=>i.identifier==e.identifier);if(t>-1){let i=this.state.responseDeclarations[t];i.defaultValue=e.value;return}if(t=this.state.outcomeDeclarations.findIndex(i=>i.identifier==e.identifier),t>-1){let i=this.state.responseDeclarations[t];i.defaultValue=e.value;return}},getPciContext(){return this.pciContext},setPciContext(e){this.pciContext=e},getPciContextRenderer(){return this.pciContext.renderer2p0},setPciContextRenderer(e){this.pciContext.renderer2p0=e},initializePciMessageListener(){this.pciMessageHandler=this.PciMessageListener.bind(this),this.windowResizeHandler=this.WindowResize.bind(this),window.addEventListener("message",this.pciMessageHandler),window.addEventListener("resize",this.windowResizeHandler)},removePciMessageListener(){this.pciMessageHandler!==null&&window.removeEventListener("message",this.pciMessageHandler),this.windowResizeHandler!==null&&window.removeEventListener("resize",this.windowResizeHandler)},PciMessageListener(e){switch(e.data.message){case"PciChildLoaded":console.log("[PCI Parent] PCI Frame Loaded: "+e.data.identifier),this.pciInitialize(e.data.identifier);break;case"PciReady":console.log("[PCI Parent] PCI Ready: "+e.data.identifier+", height: "+e.data.height+", width: "+e.data.width),this.pciReady(e.data.identifier),this.pciResizeIframe(e.data.identifier,e.data.height,e.data.width,!0);break;case"PciResize":console.log("[PCI Parent] PCI Resize: "+e.data.identifier+", height: "+e.data.height+", width: "+e.data.width),this.pciResizeIframe(e.data.identifier,e.data.height,e.data.width,!1);break;case"PciGetState_Reply":console.log("[PCI Parent] PCI GetState Reply: "+e.data.identifier+", state:",e.data.state),this.pciSaveState(e.data.identifier,e.data.state);break}},WindowResize(){this.getInteractions().forEach(e=>{e.interactionType==="PortableCustom"&&e.node.pciResizeIframeWidthToContainer()})},pciInitialize(e){let t=I.getInteraction(e);typeof t>"u"||t.interactionType!=="PortableCustom"||t.node.pciInitialize()},pciReady(e){let t=I.getInteraction(e);typeof t>"u"||t.interactionType!=="PortableCustom"||t.node.pciSetReady()},pciResizeIframe(e,t,i,s){let n=I.getInteraction(e);typeof n>"u"||n.interactionType!=="PortableCustom"||(s?n.node.pciResizeIframe(t,n.node.initialWidth):n.node.pciResizeIframe(t,i))},pciSaveState(e,t){let i=I.getInteraction(e);typeof i>"u"||i.interactionType!=="PortableCustom"||i.node.pciSaveState(t)},getAsyncStateMap(){return this.state.asyncStateMap},getItemContextGuid(){return this.itemContext.guid},setItemContextGuid(e){this.itemContext.guid=e},initializeItemContextPnp(){this.itemContext.pnp=new Ds},getItemContextPnp(){return this.itemContext.pnp},setItemContextPnp(e){this.itemContext.pnp===null&&this.initializeItemContextPnp(),this.itemContext.pnp.setPnp(e)},initializeItemContextSessionControl(){this.itemContext.sc=new jb},getItemContextSessionControl(){return this.itemContext.sc},setItemContextSessionControl(e){this.itemContext.sc===null&&this.initializeItemContextSessionControl(),this.itemContext.sc.setSessionControl(e)},getItemContextState(){return this.itemContext.state},setItemContextState(e){const t=new Cc,i=e===null?e:t.createStateFromState(e);this.itemContext.state=i},getItemContextStateVariable(e){if(!this.hasItemContextState())return null;const t=this.getItemContextState();let i=t.outcomeVariables.find(s=>s.identifier===e);return typeof i<"u"||(i=t.responseVariables.find(s=>s.identifier===e),typeof i<"u")||(i=t.templateVariables.find(s=>s.identifier===e),typeof i<"u")||(i=t.contextDeclarations.find(s=>s.identifier===e),typeof i<"u")?i:null},hasItemContextState(){return this.getItemContextState()!==null},getItemContextValidationMessages(){return this.itemContext.validationMessages},addItemContextValidationMessage(e){this.itemContext.validationMessages.push(e)},resetItemContextValidationMessages(){this.itemContext.validationMessages.splice(0,this.itemContext.validationMessages.length)},getItemLifecycleStatus(){return this.lifecycleStatus},setItemLifecycleStatus(e){this.lifecycleStatus=e},NotifyPlayerReady(e){this.player=e.player},NotifyEndAttempt(e){this.state.item.endAttempt(e,(function(){this.state.item.notifyEndAttemptInteractionResults("itemEndAttemptReady")}).bind(this))},NotifyNewTemplate(e){this.state.item.newTemplate(e)},NotifyItemReady(e){this.setItem(e),this.getItem().isAdaptive||this.restartItemTimer(),this.getItem().isAdaptiveItemCompleted()||this.restartItemTimer()},NotifyInteractionSelectionsLimit(e){const t={icon:"warning",message:e};this.player.displayAlertMessage(t)},NotifyInteractionStateReady(e){console.log("[InteractionStateReady][Interaction]",e.identifier);const t=this.getInteraction(e.identifier);typeof t>"u"||typeof this.getAsyncStateMap().get(t.identifier)>"u"||(this.setResponseVariableValue({identifier:t.identifier,value:Kb.processInteractionResponse(t,this.getResponseDeclaration(t.identifier)),state:t.node.getState()}),this.getAsyncStateMap().delete(t.identifier),this.getAsyncStateMap().size===0&&this.getItem().triggerGetResponsesComplete())}},Ze={player:null,state:{test:null,identifier:"",title:"",responseDeclarations:[],contextDeclarations:[],outcomeDeclarations:[],timeLimit:null,testParts:[],outcomeProcessing:null,feedbacks:[],printedVariables:[],catalogs:[],scoringRubricBlocks:[]},testContext:{guid:null,pnp:null},sectionItemStates:new Map,getTest(){return this.state.test},setTest(e){this.state.test=e.test},getResponseDeclarations(){return this.state.responseDeclarations},getResponseDeclaration(e){return this.state.responseDeclarations.find(t=>t.identifier===e)},getOutcomeDeclarations(){return this.state.outcomeDeclarations},getOutcomeDeclaration(e){return this.state.outcomeDeclarations.find(t=>t.identifier===e)},getContextDeclarations(){return this.state.contextDeclarations},getContextDeclaration(e){return this.state.contextDeclarations.find(t=>t.identifier===e)},getVariableDeclaration(e){let t=this.state.outcomeDeclarations.find(i=>i.identifier===e);return typeof t<"u"||(t=this.state.contextDeclarations.find(i=>i.identifier===e),typeof t<"u")||(t=this.state.responseDeclarations.find(i=>i.identifier===e),typeof t<"u")?t:null},getTimeLimit(){return this.timeLimit},getTestParts(){return this.state.testParts},getTestPart(e){return this.state.testParts.find(t=>t.identifier===e)},getOutcomeProcessing(){return this.state.outcomeProcessing},getFeedbacks(){return this.state.feedbacks},getPrintedVariables(){return this.state.printedVariables},getCatalog(e){return this.state.catalogs.find(t=>t.id===e)},getCatalogs(){return this.state.catalogs},getScoringRubricBlocks(){return this.state.scoringRubricBlocks},defineContextDeclaration(e){let t=this.state.contextDeclarations.findIndex(i=>i.identifier==e.identifier);t>-1?this.state.contextDeclarations[t]=e:this.state.contextDeclarations.push(e)},defineResponseDeclaration(e){let t=this.state.responseDeclarations.findIndex(i=>i.identifier==e.identifier);t>-1?this.state.responseDeclarations[t]=e:this.state.responseDeclarations.push(e)},defineOutcomeDeclaration(e){let t=this.state.outcomeDeclarations.findIndex(i=>i.identifier==e.identifier);t>-1?this.state.outcomeDeclarations[t]=e:this.state.outcomeDeclarations.push(e)},defineTimeLimit(e){this.state.timeLimit=e.node},defineTestPart(e){let t=this.state.testParts.findIndex(i=>i.identifier==e.identifier);if(t<0){this.state.testParts.push(e.testPart);return}this.state.testParts[t]=e.testPart},defineProcessing(e){this.state.processing=e,console.log("[QtiOutcomeProcessing][Defined]",e)},defineOutcomeProcessing(e){const t={processingType:"outcome",node:e.node};this.state.outcomeProcessing=t,console.log("[QtiOutcomeProcessing][Defined]",t)},defineFeedback(e){this.state.feedbacks.push(e),console.log("[DefineFeedback]["+e.outcomeIdentifier+"]["+e.identifier+"]")},definePrintedVariable(e){this.state.printedVariables.push(e)},defineCatalog(e){let t=this.state.catalogs.findIndex(i=>i.id==e.id);if(t<0){this.state.catalogs.push(e);return}this.state.catalogs[t]=e},defineScoringRubricBlock(e){this.state.scoringRubricBlocks.push(e)},resetAll(){this.state.test=null,this.state.identifier="",this.state.title="",this.state.responseDeclarations.splice(0,this.state.responseDeclarations.length),this.state.outcomeDeclarations.splice(0,this.state.outcomeDeclarations.length),this.state.contextDeclarations.splice(0,this.state.contextDeclarations.length),this.state.timeLimit=null,this.state.testParts.splice(0,this.state.testParts.length),this.state.outcomeProcessing=null,this.state.feedbacks.splice(0,this.state.feedbacks.length),this.state.printedVariables.splice(0,this.state.printedVariables.length),this.state.catalogs.splice(0,this.state.catalogs.length),this.state.scoringRubricBlocks.splice(0,this.state.scoringRubricBlocks.length),this.testContext.guid=null,this.testContext.state=null},initializeBuiltInDeclarations(){function e(){return 0}const t=new Map;t.set("candidateIdentifier",new Xe("candidateIdentifier","string",null)),t.set("testIdentifier",new Xe("testIdentifier","string",null)),t.set("environmentIdentifier",new Xe("environmentIdentifier","string",null)),this.defineContextDeclaration({identifier:"QTI_CONTEXT",baseType:null,cardinality:"record",value:t,defaultValue:t}),console.log("[QtiAssessmentTest][QTI_CONTEXT] initialized"),this.defineResponseDeclaration({identifier:"duration",baseType:"duration",cardinality:"single",value:0,resetValue:e,defaultValue:0,state:null}),console.log("[QtiAssessmentTest][duration] initialized")},setOutcomeVariableValue(e){let t=this.state.outcomeDeclarations.findIndex(i=>i.identifier==e.identifier);t<0||(this.state.outcomeDeclarations[t].value=e.value)},resetOutcomeVariableValue(e){let t=this.state.outcomeDeclarations.findIndex(s=>s.identifier==e.identifier);if(t<0)return;let i=this.state.outcomeDeclarations[t];if(i.defaultValue!==null){i.value=this.defaultValue;return}if(i.cardinality==="record"||i.cardinality==="multiple"||i.cardinality==="ordered"){i.value=null;return}if(i.baseType==="integer"||i.baseType==="float"){i.value=0;return}i.value=null},getTestContextGuid(){return this.testContext.guid},setTestContextGuid(e){this.testContext.guid=e},initializeTestContextPnp(){this.testContext.pnp=new Ds},getTestContextPnp(){return this.testContext.pnp},setTestContextPnp(e){this.testContext.pnp===null&&this.initializeTestContextPnp(),this.testContext.pnp.setPnp(e)},getAllTestStateItemStatesMap(){return this.sectionItemStates},setTestStateItemState(e,t,i,s){console.log("[TestStore][SetState][Part:"+e+"][Section:"+t+"][Item:"+i+"]",s);const n=`${e}~~${t}`;let r=this.getItemStateMapBySectionIdentifier(n);r!=null&&r.set(i,s)},getItemStateMapBySectionIdentifier(e){return this.sectionItemStates.has(e)?this.sectionItemStates.get(e):this.initializePartSectionItemStateMap(e)},getPartSectionMapBySectionIdentifier(e){for(let[t,i]of this.sectionItemStates)if(t.endsWith(e))return i;return null},initializePartSectionItemStateMap(e){return this.sectionItemStates.set(e,new Map),this.sectionItemStates.get(e)},findItemVariableValueByIdentifier(e,t){const i=this.findVariableByIdentifier(e.contextVariables,t);if(typeof i<"u")return i;const s=this.findVariableByIdentifier(e.outcomeVariables,t);if(typeof s<"u")return s;const n=this.findVariableByIdentifier(e.responseVariables,t);if(typeof n<"u")return n;const r=this.findVariableByIdentifier(e.templateVariables,t);return typeof r<"u"?r:null},findVariableByIdentifier(e,t){return e.find(i=>i.identifier===t)},getSerializedState(){return{contextVariables:this.serializeVariables(this.getContextDeclarations()),outcomeVariables:this.serializeVariables(this.getOutcomeDeclarations())}},serializeVariables(e){let t=[];return e.forEach(i=>{t.push({identifier:i.identifier,cardinality:i.cardinality,baseType:i.baseType,value:this.serializeVariableValue(i.cardinality,i.value)})}),t},serializeVariableValue(e,t){return e!=="record"?JSON.parse(JSON.stringify(t)):this.serializeRecordVariableValue(t)},serializeVariableState(e){return JSON.parse(JSON.stringify(e))},serializeRecordVariableValue(e){const t=this.strMapToJson(e);return this.jsonToStrMap(t)},strMapToJson(e){return JSON.stringify(this.strMapToObj(e))},jsonToStrMap(e){return this.objToStrMap(JSON.parse(e))},strMapToObj(e){let t=Object.create(null);for(let[i,s]of e)t[i]=s;return t},objToStrMap(e){let t=new Map;for(let i of Object.keys(e))t.set(i,e[i]);return t},NotifyTestPlayerReady(e){this.player=e.player},NotifyTestReady(e){this.setTest(e)}};class Yb{constructor(){ee(this,"xmlDeclaration",null);ee(this,"rxTrackSource",null);this.xmlDeclaration=new RegExp(/<\?xml.*?\?>/s),this.rxTrackSource=new RegExp(/<(track|source)[^>]+?\/>/g)}filterXmlDeclaration(t){return t.replace(this.xmlDeclaration,"")}filterCdata(t){return t.replaceAll("<![CDATA[","").replaceAll("]]>","")}filterStyle(t){return t.replaceAll("<style>","<amp-style>").replaceAll("</style>","</amp-style>")}filterMedia(t){return t=t.replaceAll("<video>","<amp-video>").replaceAll("<video ","<amp-video ").replaceAll("</video>","</amp-video>").replaceAll("<audio>","<amp-audio>").replaceAll("<audio ","<amp-audio ").replaceAll("</audio>","</amp-audio>"),this.filterTrackSource(t)}filterTrackSource(t){return t.replace(this.rxTrackSource,i=>i.replace(/\/>/g,">"))}}/*!
|
1
|
+
(function(l,Xe){typeof exports=="object"&&typeof module<"u"?module.exports=Xe(require("vue")):typeof define=="function"&&define.amd?define(["vue"],Xe):(l=typeof globalThis<"u"?globalThis:l||self,l.Qti3Player=Xe(l.Vue))})(this,function(l){"use strict";var y4=Object.defineProperty;var w4=(l,Xe,Ds)=>Xe in l?y4(l,Xe,{enumerable:!0,configurable:!0,writable:!0,value:Ds}):l[Xe]=Ds;var ee=(l,Xe,Ds)=>w4(l,typeof Xe!="symbol"?Xe+"":Xe,Ds);class Xe{constructor(t,i,s){this.fieldIdentifier=t,this.value=s,this.baseType=i,this.cardinality="single"}getValue(){return this.value}setValue(t){this.value=t}getBaseType(){return this.baseType}setBaseType(t){this.baseType=t}getCardinality(){return this.cardinality}getFieldIdentifier(){return this.fieldIdentifier}setFieldIdentifier(t){this.fieldIdentifier=t}}class Ds{constructor(){ee(this,"constants",{COLOR_DEFAULT:"qti3-player-color-default",COLOR_DEFAULT_REVERSE:"qti3-player-color-defaultreverse",COLOR_BLACK_WHITE:"qti3-player-color-blackwhite",COLOR_WHITE_BLACK:"qti3-player-color-whiteblack",COLOR_BLACK_ROSE:"qti3-player-color-blackrose",COLOR_ROSE_BLACK:"qti3-player-color-roseblack",COLOR_YELLOW_BLUE:"qti3-player-color-yellowblue",COLOR_BLUE_YELLOW:"qti3-player-color-blueyellow",COLOR_MGRAY_DGRAY:"qti3-player-color-mgraydgray",COLOR_DGRAY_MGRAY:"qti3-player-color-dgraymgray",COLOR_BLACK_CYAN:"qti3-player-color-blackcyan",COLOR_CYAN_BLACK:"qti3-player-color-cyanblack",COLOR_BLACK_CREAM:"qti3-player-color-blackcream",COLOR_CREAM_BLACK:"qti3-player-color-creamblack",GLOSSARY_ON:"glossary-on",GLOSSARY_OFF:"glossary-off",KEYWORD_TRANS_OFF:"ktlang-off",KEYWORD_TRANS_AR:"ktlang-ar",KEYWORD_TRANS_CMN:"ktlang-cmn",KEYWORD_TRANS_DE:"ktlang-de",KEYWORD_TRANS_EN:"ktlang-en",KEYWORD_TRANS_ES:"ktlang-es",KEYWORD_TRANS_FR:"ktlang-fr",KEYWORD_TRANS_HMN:"ktlang-hmn",KEYWORD_TRANS_IT:"ktlang-it",KEYWORD_TRANS_JA:"ktlang-ja",KEYWORD_TRANS_KO:"ktlang-ko",KEYWORD_TRANS_MY:"ktlang-my",KEYWORD_TRANS_NL:"ktlang-nl",KEYWORD_TRANS_PA:"ktlang-pa",KEYWORD_TRANS_RU:"ktlang-ru",KEYWORD_TRANS_SO:"ktlang-so",KEYWORD_TRANS_TL:"ktlang-tl",KEYWORD_TRANS_UK:"ktlang-uk",KEYWORD_TRANS_VI:"ktlang-vi",KEYWORD_TRANS_YUE:"ktlang-yue",KEYWORD_TRANS_ZH:"ktlang-zh",EXT_SBAC_GLOSSARY_ILLUSTRATION_ON:"sbacGlossaryIllustration-on",EXT_SBAC_GLOSSARY_ILLUSTRATION_OFF:"sbacGlossaryIllustration-off"});return this.pnp=this.defaultPnp(),this}defaultPnp(){return{textAppearance:{colorStyle:this.constants.COLOR_DEFAULT},glossaryOnScreen:!0,keywordTranslationLanguage:"",extSbacGlossaryIllustration:!1,layoutSingleColumn:!1}}setPnp(t){typeof t>"u"||(t===null&&(this.pnp=this.defaultPnp()),"textAppearance"in t&&t.textAppearance!==null&&"colorStyle"in t.textAppearance&&this.setColorStyle(t.textAppearance.colorStyle),"glossaryOnScreen"in t&&t.glossaryOnScreen!==null&&this.setGlossaryOnScreen(t.glossaryOnScreen),"keywordTranslationLanguage"in t&&this.setKeywordTranslationLanguage(t.keywordTranslationLanguage),"extSbacGlossaryIllustration"in t&&t.extSbacGlossaryIllustration!==null&&this.setExtSbacGlossaryIllustration(t.extSbacGlossaryIllustration),"layoutSingleColumn"in t&&t.layoutSingleColumn!==null&&this.setLayoutSingleColumn(t.layoutSingleColumn))}getPnp(){return this.pnp}getAfaPnp(){const t={"ext:sbac-illustrated-glossary":this.getExtSbacGlossaryIllustration()?"on":"off","keyword-translation":this.getKeywordTranslationLanguage(),"text-appearance":{"color-theme":this.convertColorStyleToTheme()}},i=this.getProhibitSet();return i!==null&&(t["prohibit-set"]=i),{"access-for-all-pnp":t}}getColorStyle(){return this.pnp.textAppearance.colorStyle}setColorStyle(t){this.pnp.textAppearance.colorStyle=t}getGlossaryOnScreen(){return this.pnp.glossaryOnScreen}setGlossaryOnScreen(t){this.pnp.glossaryOnScreen=t}getKeywordTranslationLanguage(){return this.pnp.keywordTranslationLanguage}setKeywordTranslationLanguage(t){this.pnp.keywordTranslationLanguage=t}getExtSbacGlossaryIllustration(){return this.pnp.extSbacGlossaryIllustration}setExtSbacGlossaryIllustration(t){this.pnp.extSbacGlossaryIllustration=t}getLayoutSingleColumn(){return this.pnp.layoutSingleColumn}setLayoutSingleColumn(t){this.pnp.layoutSingleColumn=t}convertColorStyleToTheme(){const t=this.getColorStyle().split("-");if(t.length!==4)return"default";switch(t[3]){case"default":return"default";case"defaultreverse":return"default-reverse";case"blackwhite":return"high-contrast";case"whiteblack":return"high-contrast-reverse";case"blackrose":return"black-rose";case"roseblack":return"rose-black";case"yellowblue":return"yellow-blue";case"blueyellow":return"blue-yellow";case"mgraydgray":return"medgray-darkgray";case"dgraymgray":return"darkgray-medgray";case"blackcyan":return"black-cyan";case"cyanblack":return"cyan-black";case"blackcream":return"black-cream";case"creamblack":return"cream-black";default:return"default"}}getProhibitSet(){return this.getGlossaryOnScreen()?null:{"glossary-on-screen":"active"}}evaluatePnpEvent(t){let i=!1;switch(t){case this.constants.GLOSSARY_ON:this.getGlossaryOnScreen()===!1&&(this.setGlossaryOnScreen(!0),i=!0);break;case this.constants.GLOSSARY_OFF:this.getGlossaryOnScreen()===!0&&(this.setGlossaryOnScreen(!1),i=!0);break;case this.constants.KEYWORD_TRANS_OFF:this.getKeywordTranslationLanguage()!==""&&(this.setKeywordTranslationLanguage(""),i=!0);break;case this.constants.KEYWORD_TRANS_AR:this.getKeywordTranslationLanguage()!=="ar"&&(this.setKeywordTranslationLanguage("ar"),i=!0);break;case this.constants.KEYWORD_TRANS_CMN:this.getKeywordTranslationLanguage()!=="cmn"&&(this.setKeywordTranslationLanguage("cmn"),i=!0);break;case this.constants.KEYWORD_TRANS_DE:this.getKeywordTranslationLanguage()!=="de"&&(this.setKeywordTranslationLanguage("de"),i=!0);break;case this.constants.KEYWORD_TRANS_EN:this.getKeywordTranslationLanguage()!=="en"&&(this.setKeywordTranslationLanguage("en"),i=!0);break;case this.constants.KEYWORD_TRANS_ES:this.getKeywordTranslationLanguage()!=="es"&&(this.setKeywordTranslationLanguage("es"),i=!0);break;case this.constants.KEYWORD_TRANS_FR:this.getKeywordTranslationLanguage()!=="fr"&&(this.setKeywordTranslationLanguage("fr"),i=!0);break;case this.constants.KEYWORD_TRANS_HMN:this.getKeywordTranslationLanguage()!=="hmn"&&(this.setKeywordTranslationLanguage("hmn"),i=!0);break;case this.constants.KEYWORD_TRANS_IT:this.getKeywordTranslationLanguage()!=="it"&&(this.setKeywordTranslationLanguage("it"),i=!0);break;case this.constants.KEYWORD_TRANS_JA:this.getKeywordTranslationLanguage()!=="ja"&&(this.setKeywordTranslationLanguage("ja"),i=!0);break;case this.constants.KEYWORD_TRANS_KO:this.getKeywordTranslationLanguage()!=="ko"&&(this.setKeywordTranslationLanguage("ko"),i=!0);break;case this.constants.KEYWORD_TRANS_MY:this.getKeywordTranslationLanguage()!=="my"&&(this.setKeywordTranslationLanguage("my"),i=!0);break;case this.constants.KEYWORD_TRANS_NL:this.getKeywordTranslationLanguage()!=="nl"&&(this.setKeywordTranslationLanguage("nl"),i=!0);break;case this.constants.KEYWORD_TRANS_PA:this.getKeywordTranslationLanguage()!=="pa"&&(this.setKeywordTranslationLanguage("pa"),i=!0);break;case this.constants.KEYWORD_TRANS_RU:this.getKeywordTranslationLanguage()!=="ru"&&(this.setKeywordTranslationLanguage("ru"),i=!0);break;case this.constants.KEYWORD_TRANS_SO:this.getKeywordTranslationLanguage()!=="so"&&(this.setKeywordTranslationLanguage("so"),i=!0);break;case this.constants.KEYWORD_TRANS_TL:this.getKeywordTranslationLanguage()!=="tl"&&(this.setKeywordTranslationLanguage("tl"),i=!0);break;case this.constants.KEYWORD_TRANS_UK:this.getKeywordTranslationLanguage()!=="uk"&&(this.setKeywordTranslationLanguage("uk"),i=!0);break;case this.constants.KEYWORD_TRANS_VI:this.getKeywordTranslationLanguage()!=="vi"&&(this.setKeywordTranslationLanguage("vi"),i=!0);break;case this.constants.KEYWORD_TRANS_YUE:this.getKeywordTranslationLanguage()!=="yue"&&(this.setKeywordTranslationLanguage("yue"),i=!0);break;case this.constants.KEYWORD_TRANS_ZH:this.getKeywordTranslationLanguage()!=="zh"&&(this.setKeywordTranslationLanguage("zh"),i=!0);break;case this.constants.EXT_SBAC_GLOSSARY_ILLUSTRATION_ON:this.getExtSbacGlossaryIllustration()===!1&&(this.setExtSbacGlossaryIllustration(!0),i=!0);break;case this.constants.EXT_SBAC_GLOSSARY_ILLUSTRATION_OFF:this.getExtSbacGlossaryIllustration()===!0&&(this.setExtSbacGlossaryIllustration(!1),i=!0);break}return i}}class jb{constructor(){ee(this,"constants",{TIME_LIMITS_DEFAULT:{min_time:null,max_time:null,allow_late_submission:!1},ATTEMPTS_UNLIMITED:0});return this.sc=this.defaultSessionControl(),this}defaultSessionControl(){return this.sc={allow_comment:!1,allow_review:!0,allow_skipping:!0,max_attempts:this.constants.ATTEMPTS_UNLIMITED,show_feedback:!1,show_solution:!1,time_limits:this.constants.TIME_LIMITS_DEFAULT,validate_responses:!1},this.sc}setSessionControl(t){if(!(typeof t>"u")){if(t===null)return this.sc=this.defaultSessionControl();"allow_comment"in t&&t.allow_comment!==null&&this.setAllowComment(t.allow_comment),"allow_review"in t&&t.allow_review!==null&&this.setAllowReview(t.allow_review),"allow_skipping"in t&&t.allow_skipping!==null&&this.setAllowSkipping(t.allow_skipping),"max_attempts"in t&&t.max_attempts!==null&&this.setMaxAttempts(t.max_attempts),"show_feedback"in t&&t.show_feedback!==null&&this.setShowFeedback(t.show_feedback),"show_solution"in t&&t.show_solution!==null&&this.setShowSolution(t.show_solution),"time_limits"in t&&t.time_limits!==null&&("min_time"in t.time_limits&&this.setTimeLimitsMinTime(t.time_limits.min_time),"max_time"in t.time_limits&&this.setTimeLimitsMaxTime(t.time_limits.max_time),"allow_late_submission"in t.time_limits&&this.setTimeLimitsAllowLateSubmission(t.time_limits.allow_late_submission)),"validate_responses"in t&&t.validate_responses!==null&&this.setValidateResponses(t.validate_responses)}}getSessionControl(){return{allow_comment:this.getAllowComment(),allow_review:this.getAllowReview(),allow_skipping:this.getAllowSkipping(),max_attempts:this.getMaxAttempts(),show_feedback:this.getShowFeedback(),show_solution:this.getShowSolution(),time_limits:this.getTimeLimits(),validate_responses:this.getValidateResponses()}}getAllowComment(){return this.sc.allow_comment}setAllowComment(t){this.sc.allow_comment=t}getAllowReview(){return this.sc.allow_review}setAllowReview(t){this.sc.allow_review=t}getAllowSkipping(){return this.sc.allow_skipping}setAllowSkipping(t){this.sc.allow_skipping=t}getMaxAttempts(){return this.sc.max_attempts}setMaxAttempts(t){this.sc.max_attempts=t}getShowFeedback(){return this.sc.show_feedback}setShowFeedback(t){this.sc.show_feedback=t}getShowSolution(){return this.sc.show_solution}setShowSolution(t){this.sc.show_solution=t}getTimeLimits(){return this.sc.time_limits}setTimeLimits(t=null,i=null,s=!1){this.setTimeLimitsMinTime(t),this.setTimeLimitsMaxTime(i),this.setTimeLimitsAllowLateSubmission(s)}getTimeLimitsMinTime(){return this.sc.time_limits.min_time}setTimeLimitsMinTime(t){this.sc.time_limits.min_time=t}getTimeLimitsMaxTime(){return this.sc.time_limits.max_time}setTimeLimitsMaxTime(t){this.sc.time_limits.max_time=t}getTimeLimitsAllowLateSubmission(){return this.sc.time_limits.allow_late_submission}setTimeLimitsAllowLateSubmission(t){this.sc.time_limits.allow_late_submission=t}getValidateResponses(){return this.sc.validate_responses}setValidateResponses(t){this.sc.validate_responses=t}}class Cc{constructor(t,i){return typeof t>"u"?this:(this.identifier=t,this.guid=i.getItemContextGuid(),this.contextVariables=i.getContextDeclarations(),this.responseVariables=i.getResponseDeclarations(),this.templateVariables=i.getTemplateDeclarations(),this.outcomeVariables=i.getOutcomeDeclarations(),this.validationMessages=i.getItemContextValidationMessages(),this)}createStateFromState(t){return this.identifier=t.identifier,this.guid=t.guid,this.contextVariables=t.contextVariables,this.responseVariables=t.responseVariables,this.templateVariables=t.templateVariables,this.outcomeVariables=t.outcomeVariables,this.validationMessages=t.validationMessages,this.getSerializedState()}getSerializedState(){return{identifier:this.identifier,guid:this.guid,contextVariables:this.serializeVariables(this.contextVariables),responseVariables:this.serializeResponseVariables(this.responseVariables),outcomeVariables:this.serializeOutcomeVariables(this.outcomeVariables),templateVariables:this.serializeVariables(this.templateVariables),validationMessages:this.serializeValidationMessages(this.validationMessages)}}serializeResponseVariables(t){let i=[];return t.forEach(s=>{let n={identifier:s.identifier,cardinality:s.cardinality,baseType:this.resolveBaseType(s.baseType),value:this.serializeVariableValue(s.cardinality,s.value),state:this.serializeVariableState(s.state)};"correctResponse"in s&&(n.correctResponse=this.serializeVariableValue(s.cardinality,s.correctResponse)),i.push(n)}),i}serializeOutcomeVariables(t){let i=[];return t.forEach(s=>{i.push({identifier:s.identifier,cardinality:s.cardinality,baseType:this.resolveBaseType(s.baseType),value:this.serializeVariableValue(s.cardinality,s.value),view:s.view,interpretation:s.interpretation,longInterpretation:s.longInterpretation,normalMaximum:s.normalMaximum,normalMinimum:s.normalMinimum,masteryValue:s.masteryValue,externalScored:s.externalScored,variableIdentifierRef:s.variableIdentifierRef})}),i}serializeVariables(t){let i=[];return t.forEach(s=>{i.push({identifier:s.identifier,cardinality:s.cardinality,baseType:this.resolveBaseType(s.baseType),value:this.serializeVariableValue(s.cardinality,s.value)})}),i}serializeValidationMessages(t){let i=[];return t.forEach(s=>{i.push({identifier:s.identifier,message:s.message})}),i}serializeVariableValue(t,i){return t!=="record"?JSON.parse(JSON.stringify(i)):this.serializeRecordVariableValue(i)}serializeVariableState(t){return JSON.parse(JSON.stringify(t))}resolveBaseType(t){return typeof t>"u"?null:t}serializeRecordVariableValue(t){const i=this.strMapToJson(t);return this.jsonToStrMap(i)}strMapToJson(t){return JSON.stringify(this.strMapToObj(t))}jsonToStrMap(t){return this.objToStrMap(JSON.parse(t))}strMapToObj(t){let i=Object.create(null);for(let[s,n]of t)i[s]=typeof n=="object"&&n!==null?n.getValue():n;return i}objToStrMap(t){let i=new Map;for(let s of Object.keys(t))i.set(s,t[s]);return i}}class Wb{constructor(){ee(this,"itemTimer");ee(this,"itemDuration");this.setTime(0)}getTime(){return this.itemDuration}setTime(t){this.itemDuration=t}startTimer(){this.clearTimer(),this.setTime(0),this.itemTimer=setInterval(this.updateTime.bind(this),1e3)}updateTime(){++this.itemDuration}resetTimer(){this.clearTimer(),this.setTime(0)}clearTimer(){clearInterval(this.itemTimer)}}var zb=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,Tc=Math.ceil,Yt=Math.floor,Ct="[BigNumber Error] ",yf=Ct+"Number primitive has more than 15 significant digits: ",fi=1e14,ye=14,wf=9007199254740991,Sc=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],ws=1e7,Ot=1e9;function bf(e){var t,i,s,n=x.prototype={constructor:x,toString:null,valueOf:null},r=new x(1),a=20,o=4,u=-7,h=21,f=-1e7,p=1e7,y=!1,w=1,b=0,C={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},S="0123456789abcdefghijklmnopqrstuvwxyz",$=!0;function x(m,v){var T,N,V,L,q,A,M,k,R=this;if(!(R instanceof x))return new x(m,v);if(v==null){if(m&&m._isBigNumber===!0){R.s=m.s,!m.c||m.e>p?R.c=R.e=null:m.e<f?R.c=[R.e=0]:(R.e=m.e,R.c=m.c.slice());return}if((A=typeof m=="number")&&m*0==0){if(R.s=1/m<0?(m=-m,-1):1,m===~~m){for(L=0,q=m;q>=10;q/=10,L++);L>p?R.c=R.e=null:(R.e=L,R.c=[m]);return}k=String(m)}else{if(!zb.test(k=String(m)))return s(R,k,A);R.s=k.charCodeAt(0)==45?(k=k.slice(1),-1):1}(L=k.indexOf("."))>-1&&(k=k.replace(".","")),(q=k.search(/e/i))>0?(L<0&&(L=q),L+=+k.slice(q+1),k=k.substring(0,q)):L<0&&(L=k.length)}else{if(De(v,2,S.length,"Base"),v==10&&$)return R=new x(m),Q(R,a+R.e+1,o);if(k=String(m),A=typeof m=="number"){if(m*0!=0)return s(R,k,A,v);if(R.s=1/m<0?(k=k.slice(1),-1):1,x.DEBUG&&k.replace(/^0\.0*|\./,"").length>15)throw Error(yf+m)}else R.s=k.charCodeAt(0)===45?(k=k.slice(1),-1):1;for(T=S.slice(0,v),L=q=0,M=k.length;q<M;q++)if(T.indexOf(N=k.charAt(q))<0){if(N=="."){if(q>L){L=M;continue}}else if(!V&&(k==k.toUpperCase()&&(k=k.toLowerCase())||k==k.toLowerCase()&&(k=k.toUpperCase()))){V=!0,q=-1,L=0;continue}return s(R,String(m),A,v)}A=!1,k=i(k,v,10,R.s),(L=k.indexOf("."))>-1?k=k.replace(".",""):L=k.length}for(q=0;k.charCodeAt(q)===48;q++);for(M=k.length;k.charCodeAt(--M)===48;);if(k=k.slice(q,++M)){if(M-=q,A&&x.DEBUG&&M>15&&(m>wf||m!==Yt(m)))throw Error(yf+R.s*m);if((L=L-q-1)>p)R.c=R.e=null;else if(L<f)R.c=[R.e=0];else{if(R.e=L,R.c=[],q=(L+1)%ye,L<0&&(q+=ye),q<M){for(q&&R.c.push(+k.slice(0,q)),M-=ye;q<M;)R.c.push(+k.slice(q,q+=ye));q=ye-(k=k.slice(q)).length}else q-=M;for(;q--;k+="0");R.c.push(+k)}}else R.c=[R.e=0]}x.clone=bf,x.ROUND_UP=0,x.ROUND_DOWN=1,x.ROUND_CEIL=2,x.ROUND_FLOOR=3,x.ROUND_HALF_UP=4,x.ROUND_HALF_DOWN=5,x.ROUND_HALF_EVEN=6,x.ROUND_HALF_CEIL=7,x.ROUND_HALF_FLOOR=8,x.EUCLID=9,x.config=x.set=function(m){var v,T;if(m!=null)if(typeof m=="object"){if(m.hasOwnProperty(v="DECIMAL_PLACES")&&(T=m[v],De(T,0,Ot,v),a=T),m.hasOwnProperty(v="ROUNDING_MODE")&&(T=m[v],De(T,0,8,v),o=T),m.hasOwnProperty(v="EXPONENTIAL_AT")&&(T=m[v],T&&T.pop?(De(T[0],-1e9,0,v),De(T[1],0,Ot,v),u=T[0],h=T[1]):(De(T,-1e9,Ot,v),u=-(h=T<0?-T:T))),m.hasOwnProperty(v="RANGE"))if(T=m[v],T&&T.pop)De(T[0],-1e9,-1,v),De(T[1],1,Ot,v),f=T[0],p=T[1];else if(De(T,-1e9,Ot,v),T)f=-(p=T<0?-T:T);else throw Error(Ct+v+" cannot be zero: "+T);if(m.hasOwnProperty(v="CRYPTO"))if(T=m[v],T===!!T)if(T)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))y=T;else throw y=!T,Error(Ct+"crypto unavailable");else y=T;else throw Error(Ct+v+" not true or false: "+T);if(m.hasOwnProperty(v="MODULO_MODE")&&(T=m[v],De(T,0,9,v),w=T),m.hasOwnProperty(v="POW_PRECISION")&&(T=m[v],De(T,0,Ot,v),b=T),m.hasOwnProperty(v="FORMAT"))if(T=m[v],typeof T=="object")C=T;else throw Error(Ct+v+" not an object: "+T);if(m.hasOwnProperty(v="ALPHABET"))if(T=m[v],typeof T=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(T))$=T.slice(0,10)=="0123456789",S=T;else throw Error(Ct+v+" invalid: "+T)}else throw Error(Ct+"Object expected: "+m);return{DECIMAL_PLACES:a,ROUNDING_MODE:o,EXPONENTIAL_AT:[u,h],RANGE:[f,p],CRYPTO:y,MODULO_MODE:w,POW_PRECISION:b,FORMAT:C,ALPHABET:S}},x.isBigNumber=function(m){if(!m||m._isBigNumber!==!0)return!1;if(!x.DEBUG)return!0;var v,T,N=m.c,V=m.e,L=m.s;e:if({}.toString.call(N)=="[object Array]"){if((L===1||L===-1)&&V>=-1e9&&V<=Ot&&V===Yt(V)){if(N[0]===0){if(V===0&&N.length===1)return!0;break e}if(v=(V+1)%ye,v<1&&(v+=ye),String(N[0]).length==v){for(v=0;v<N.length;v++)if(T=N[v],T<0||T>=fi||T!==Yt(T))break e;if(T!==0)return!0}}}else if(N===null&&V===null&&(L===null||L===1||L===-1))return!0;throw Error(Ct+"Invalid BigNumber: "+m)},x.maximum=x.max=function(){return E(arguments,-1)},x.minimum=x.min=function(){return E(arguments,1)},x.random=function(){var m=9007199254740992,v=Math.random()*m&2097151?function(){return Yt(Math.random()*m)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(T){var N,V,L,q,A,M=0,k=[],R=new x(r);if(T==null?T=a:De(T,0,Ot),q=Tc(T/ye),y)if(crypto.getRandomValues){for(N=crypto.getRandomValues(new Uint32Array(q*=2));M<q;)A=N[M]*131072+(N[M+1]>>>11),A>=9e15?(V=crypto.getRandomValues(new Uint32Array(2)),N[M]=V[0],N[M+1]=V[1]):(k.push(A%1e14),M+=2);M=q/2}else if(crypto.randomBytes){for(N=crypto.randomBytes(q*=7);M<q;)A=(N[M]&31)*281474976710656+N[M+1]*1099511627776+N[M+2]*4294967296+N[M+3]*16777216+(N[M+4]<<16)+(N[M+5]<<8)+N[M+6],A>=9e15?crypto.randomBytes(7).copy(N,M):(k.push(A%1e14),M+=7);M=q/7}else throw y=!1,Error(Ct+"crypto unavailable");if(!y)for(;M<q;)A=v(),A<9e15&&(k[M++]=A%1e14);for(q=k[--M],T%=ye,q&&T&&(A=Sc[ye-T],k[M]=Yt(q/A)*A);k[M]===0;k.pop(),M--);if(M<0)k=[L=0];else{for(L=-1;k[0]===0;k.splice(0,1),L-=ye);for(M=1,A=k[0];A>=10;A/=10,M++);M<ye&&(L-=ye-M)}return R.e=L,R.c=k,R}}(),x.sum=function(){for(var m=1,v=arguments,T=new x(v[0]);m<v.length;)T=T.plus(v[m++]);return T},i=function(){var m="0123456789";function v(T,N,V,L){for(var q,A=[0],M,k=0,R=T.length;k<R;){for(M=A.length;M--;A[M]*=N);for(A[0]+=L.indexOf(T.charAt(k++)),q=0;q<A.length;q++)A[q]>V-1&&(A[q+1]==null&&(A[q+1]=0),A[q+1]+=A[q]/V|0,A[q]%=V)}return A.reverse()}return function(T,N,V,L,q){var A,M,k,R,Y,Z,ne,de,ge=T.indexOf("."),Ee=a,D=o;for(ge>=0&&(R=b,b=0,T=T.replace(".",""),de=new x(N),Z=de.pow(T.length-ge),b=R,de.c=v(Ji(Zt(Z.c),Z.e,"0"),10,V,m),de.e=de.c.length),ne=v(T,N,V,q?(A=S,m):(A=m,S)),k=R=ne.length;ne[--R]==0;ne.pop());if(!ne[0])return A.charAt(0);if(ge<0?--k:(Z.c=ne,Z.e=k,Z.s=L,Z=t(Z,de,Ee,D,V),ne=Z.c,Y=Z.r,k=Z.e),M=k+Ee+1,ge=ne[M],R=V/2,Y=Y||M<0||ne[M+1]!=null,Y=D<4?(ge!=null||Y)&&(D==0||D==(Z.s<0?3:2)):ge>R||ge==R&&(D==4||Y||D==6&&ne[M-1]&1||D==(Z.s<0?8:7)),M<1||!ne[0])T=Y?Ji(A.charAt(1),-Ee,A.charAt(0)):A.charAt(0);else{if(ne.length=M,Y)for(--V;++ne[--M]>V;)ne[M]=0,M||(++k,ne=[1].concat(ne));for(R=ne.length;!ne[--R];);for(ge=0,T="";ge<=R;T+=A.charAt(ne[ge++]));T=Ji(T,k,A.charAt(0))}return T}}(),t=function(){function m(N,V,L){var q,A,M,k,R=0,Y=N.length,Z=V%ws,ne=V/ws|0;for(N=N.slice();Y--;)M=N[Y]%ws,k=N[Y]/ws|0,q=ne*M+k*Z,A=Z*M+q%ws*ws+R,R=(A/L|0)+(q/ws|0)+ne*k,N[Y]=A%L;return R&&(N=[R].concat(N)),N}function v(N,V,L,q){var A,M;if(L!=q)M=L>q?1:-1;else for(A=M=0;A<L;A++)if(N[A]!=V[A]){M=N[A]>V[A]?1:-1;break}return M}function T(N,V,L,q){for(var A=0;L--;)N[L]-=A,A=N[L]<V[L]?1:0,N[L]=A*q+N[L]-V[L];for(;!N[0]&&N.length>1;N.splice(0,1));}return function(N,V,L,q,A){var M,k,R,Y,Z,ne,de,ge,Ee,D,z,Me,qe,vt,rt,He,dt,Fe=N.s==V.s?1:-1,Oe=N.c,Ie=V.c;if(!Oe||!Oe[0]||!Ie||!Ie[0])return new x(!N.s||!V.s||(Oe?Ie&&Oe[0]==Ie[0]:!Ie)?NaN:Oe&&Oe[0]==0||!Ie?Fe*0:Fe/0);for(ge=new x(Fe),Ee=ge.c=[],k=N.e-V.e,Fe=L+k+1,A||(A=fi,k=Xt(N.e/ye)-Xt(V.e/ye),Fe=Fe/ye|0),R=0;Ie[R]==(Oe[R]||0);R++);if(Ie[R]>(Oe[R]||0)&&k--,Fe<0)Ee.push(1),Y=!0;else{for(vt=Oe.length,He=Ie.length,R=0,Fe+=2,Z=Yt(A/(Ie[0]+1)),Z>1&&(Ie=m(Ie,Z,A),Oe=m(Oe,Z,A),He=Ie.length,vt=Oe.length),qe=He,D=Oe.slice(0,He),z=D.length;z<He;D[z++]=0);dt=Ie.slice(),dt=[0].concat(dt),rt=Ie[0],Ie[1]>=A/2&&rt++;do{if(Z=0,M=v(Ie,D,He,z),M<0){if(Me=D[0],He!=z&&(Me=Me*A+(D[1]||0)),Z=Yt(Me/rt),Z>1)for(Z>=A&&(Z=A-1),ne=m(Ie,Z,A),de=ne.length,z=D.length;v(ne,D,de,z)==1;)Z--,T(ne,He<de?dt:Ie,de,A),de=ne.length,M=1;else Z==0&&(M=Z=1),ne=Ie.slice(),de=ne.length;if(de<z&&(ne=[0].concat(ne)),T(D,ne,z,A),z=D.length,M==-1)for(;v(Ie,D,He,z)<1;)Z++,T(D,He<z?dt:Ie,z,A),z=D.length}else M===0&&(Z++,D=[0]);Ee[R++]=Z,D[0]?D[z++]=Oe[qe]||0:(D=[Oe[qe]],z=1)}while((qe++<vt||D[0]!=null)&&Fe--);Y=D[0]!=null,Ee[0]||Ee.splice(0,1)}if(A==fi){for(R=1,Fe=Ee[0];Fe>=10;Fe/=10,R++);Q(ge,L+(ge.e=R+k*ye-1)+1,q,Y)}else ge.e=k,ge.r=+Y;return ge}}();function B(m,v,T,N){var V,L,q,A,M;if(T==null?T=o:De(T,0,8),!m.c)return m.toString();if(V=m.c[0],q=m.e,v==null)M=Zt(m.c),M=N==1||N==2&&(q<=u||q>=h)?Eo(M,q):Ji(M,q,"0");else if(m=Q(new x(m),v,T),L=m.e,M=Zt(m.c),A=M.length,N==1||N==2&&(v<=L||L<=u)){for(;A<v;M+="0",A++);M=Eo(M,L)}else if(v-=q,M=Ji(M,L,"0"),L+1>A){if(--v>0)for(M+=".";v--;M+="0");}else if(v+=L-A,v>0)for(L+1==A&&(M+=".");v--;M+="0");return m.s<0&&V?"-"+M:M}function E(m,v){for(var T,N,V=1,L=new x(m[0]);V<m.length;V++)N=new x(m[V]),(!N.s||(T=Qs(L,N))===v||T===0&&L.s===v)&&(L=N);return L}function G(m,v,T){for(var N=1,V=v.length;!v[--V];v.pop());for(V=v[0];V>=10;V/=10,N++);return(T=N+T*ye-1)>p?m.c=m.e=null:T<f?m.c=[m.e=0]:(m.e=T,m.c=v),m}s=function(){var m=/^(-?)0([xbo])(?=\w[\w.]*$)/i,v=/^([^.]+)\.$/,T=/^\.([^.]+)$/,N=/^-?(Infinity|NaN)$/,V=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(L,q,A,M){var k,R=A?q:q.replace(V,"");if(N.test(R))L.s=isNaN(R)?null:R<0?-1:1;else{if(!A&&(R=R.replace(m,function(Y,Z,ne){return k=(ne=ne.toLowerCase())=="x"?16:ne=="b"?2:8,!M||M==k?Z:Y}),M&&(k=M,R=R.replace(v,"$1").replace(T,"0.$1")),q!=R))return new x(R,k);if(x.DEBUG)throw Error(Ct+"Not a"+(M?" base "+M:"")+" number: "+q);L.s=null}L.c=L.e=null}}();function Q(m,v,T,N){var V,L,q,A,M,k,R,Y=m.c,Z=Sc;if(Y){e:{for(V=1,A=Y[0];A>=10;A/=10,V++);if(L=v-V,L<0)L+=ye,q=v,M=Y[k=0],R=Yt(M/Z[V-q-1]%10);else if(k=Tc((L+1)/ye),k>=Y.length)if(N){for(;Y.length<=k;Y.push(0));M=R=0,V=1,L%=ye,q=L-ye+1}else break e;else{for(M=A=Y[k],V=1;A>=10;A/=10,V++);L%=ye,q=L-ye+V,R=q<0?0:Yt(M/Z[V-q-1]%10)}if(N=N||v<0||Y[k+1]!=null||(q<0?M:M%Z[V-q-1]),N=T<4?(R||N)&&(T==0||T==(m.s<0?3:2)):R>5||R==5&&(T==4||N||T==6&&(L>0?q>0?M/Z[V-q]:0:Y[k-1])%10&1||T==(m.s<0?8:7)),v<1||!Y[0])return Y.length=0,N?(v-=m.e+1,Y[0]=Z[(ye-v%ye)%ye],m.e=-v||0):Y[0]=m.e=0,m;if(L==0?(Y.length=k,A=1,k--):(Y.length=k+1,A=Z[ye-L],Y[k]=q>0?Yt(M/Z[V-q]%Z[q])*A:0),N)for(;;)if(k==0){for(L=1,q=Y[0];q>=10;q/=10,L++);for(q=Y[0]+=A,A=1;q>=10;q/=10,A++);L!=A&&(m.e++,Y[0]==fi&&(Y[0]=1));break}else{if(Y[k]+=A,Y[k]!=fi)break;Y[k--]=0,A=1}for(L=Y.length;Y[--L]===0;Y.pop());}m.e>p?m.c=m.e=null:m.e<f&&(m.c=[m.e=0])}return m}function J(m){var v,T=m.e;return T===null?m.toString():(v=Zt(m.c),v=T<=u||T>=h?Eo(v,T):Ji(v,T,"0"),m.s<0?"-"+v:v)}return n.absoluteValue=n.abs=function(){var m=new x(this);return m.s<0&&(m.s=1),m},n.comparedTo=function(m,v){return Qs(this,new x(m,v))},n.decimalPlaces=n.dp=function(m,v){var T,N,V,L=this;if(m!=null)return De(m,0,Ot),v==null?v=o:De(v,0,8),Q(new x(L),m+L.e+1,v);if(!(T=L.c))return null;if(N=((V=T.length-1)-Xt(this.e/ye))*ye,V=T[V])for(;V%10==0;V/=10,N--);return N<0&&(N=0),N},n.dividedBy=n.div=function(m,v){return t(this,new x(m,v),a,o)},n.dividedToIntegerBy=n.idiv=function(m,v){return t(this,new x(m,v),0,1)},n.exponentiatedBy=n.pow=function(m,v){var T,N,V,L,q,A,M,k,R,Y=this;if(m=new x(m),m.c&&!m.isInteger())throw Error(Ct+"Exponent not an integer: "+J(m));if(v!=null&&(v=new x(v)),A=m.e>14,!Y.c||!Y.c[0]||Y.c[0]==1&&!Y.e&&Y.c.length==1||!m.c||!m.c[0])return R=new x(Math.pow(+J(Y),A?m.s*(2-vo(m)):+J(m))),v?R.mod(v):R;if(M=m.s<0,v){if(v.c?!v.c[0]:!v.s)return new x(NaN);N=!M&&Y.isInteger()&&v.isInteger(),N&&(Y=Y.mod(v))}else{if(m.e>9&&(Y.e>0||Y.e<-1||(Y.e==0?Y.c[0]>1||A&&Y.c[1]>=24e7:Y.c[0]<8e13||A&&Y.c[0]<=9999975e7)))return L=Y.s<0&&vo(m)?-0:0,Y.e>-1&&(L=1/L),new x(M?1/L:L);b&&(L=Tc(b/ye+2))}for(A?(T=new x(.5),M&&(m.s=1),k=vo(m)):(V=Math.abs(+J(m)),k=V%2),R=new x(r);;){if(k){if(R=R.times(Y),!R.c)break;L?R.c.length>L&&(R.c.length=L):N&&(R=R.mod(v))}if(V){if(V=Yt(V/2),V===0)break;k=V%2}else if(m=m.times(T),Q(m,m.e+1,1),m.e>14)k=vo(m);else{if(V=+J(m),V===0)break;k=V%2}Y=Y.times(Y),L?Y.c&&Y.c.length>L&&(Y.c.length=L):N&&(Y=Y.mod(v))}return N?R:(M&&(R=r.div(R)),v?R.mod(v):L?Q(R,b,o,q):R)},n.integerValue=function(m){var v=new x(this);return m==null?m=o:De(m,0,8),Q(v,v.e+1,m)},n.isEqualTo=n.eq=function(m,v){return Qs(this,new x(m,v))===0},n.isFinite=function(){return!!this.c},n.isGreaterThan=n.gt=function(m,v){return Qs(this,new x(m,v))>0},n.isGreaterThanOrEqualTo=n.gte=function(m,v){return(v=Qs(this,new x(m,v)))===1||v===0},n.isInteger=function(){return!!this.c&&Xt(this.e/ye)>this.c.length-2},n.isLessThan=n.lt=function(m,v){return Qs(this,new x(m,v))<0},n.isLessThanOrEqualTo=n.lte=function(m,v){return(v=Qs(this,new x(m,v)))===-1||v===0},n.isNaN=function(){return!this.s},n.isNegative=function(){return this.s<0},n.isPositive=function(){return this.s>0},n.isZero=function(){return!!this.c&&this.c[0]==0},n.minus=function(m,v){var T,N,V,L,q=this,A=q.s;if(m=new x(m,v),v=m.s,!A||!v)return new x(NaN);if(A!=v)return m.s=-v,q.plus(m);var M=q.e/ye,k=m.e/ye,R=q.c,Y=m.c;if(!M||!k){if(!R||!Y)return R?(m.s=-v,m):new x(Y?q:NaN);if(!R[0]||!Y[0])return Y[0]?(m.s=-v,m):new x(R[0]?q:o==3?-0:0)}if(M=Xt(M),k=Xt(k),R=R.slice(),A=M-k){for((L=A<0)?(A=-A,V=R):(k=M,V=Y),V.reverse(),v=A;v--;V.push(0));V.reverse()}else for(N=(L=(A=R.length)<(v=Y.length))?A:v,A=v=0;v<N;v++)if(R[v]!=Y[v]){L=R[v]<Y[v];break}if(L&&(V=R,R=Y,Y=V,m.s=-m.s),v=(N=Y.length)-(T=R.length),v>0)for(;v--;R[T++]=0);for(v=fi-1;N>A;){if(R[--N]<Y[N]){for(T=N;T&&!R[--T];R[T]=v);--R[T],R[N]+=fi}R[N]-=Y[N]}for(;R[0]==0;R.splice(0,1),--k);return R[0]?G(m,R,k):(m.s=o==3?-1:1,m.c=[m.e=0],m)},n.modulo=n.mod=function(m,v){var T,N,V=this;return m=new x(m,v),!V.c||!m.s||m.c&&!m.c[0]?new x(NaN):!m.c||V.c&&!V.c[0]?new x(V):(w==9?(N=m.s,m.s=1,T=t(V,m,0,3),m.s=N,T.s*=N):T=t(V,m,0,w),m=V.minus(T.times(m)),!m.c[0]&&w==1&&(m.s=V.s),m)},n.multipliedBy=n.times=function(m,v){var T,N,V,L,q,A,M,k,R,Y,Z,ne,de,ge,Ee,D=this,z=D.c,Me=(m=new x(m,v)).c;if(!z||!Me||!z[0]||!Me[0])return!D.s||!m.s||z&&!z[0]&&!Me||Me&&!Me[0]&&!z?m.c=m.e=m.s=null:(m.s*=D.s,!z||!Me?m.c=m.e=null:(m.c=[0],m.e=0)),m;for(N=Xt(D.e/ye)+Xt(m.e/ye),m.s*=D.s,M=z.length,Y=Me.length,M<Y&&(de=z,z=Me,Me=de,V=M,M=Y,Y=V),V=M+Y,de=[];V--;de.push(0));for(ge=fi,Ee=ws,V=Y;--V>=0;){for(T=0,Z=Me[V]%Ee,ne=Me[V]/Ee|0,q=M,L=V+q;L>V;)k=z[--q]%Ee,R=z[q]/Ee|0,A=ne*k+R*Z,k=Z*k+A%Ee*Ee+de[L]+T,T=(k/ge|0)+(A/Ee|0)+ne*R,de[L--]=k%ge;de[L]=T}return T?++N:de.splice(0,1),G(m,de,N)},n.negated=function(){var m=new x(this);return m.s=-m.s||null,m},n.plus=function(m,v){var T,N=this,V=N.s;if(m=new x(m,v),v=m.s,!V||!v)return new x(NaN);if(V!=v)return m.s=-v,N.minus(m);var L=N.e/ye,q=m.e/ye,A=N.c,M=m.c;if(!L||!q){if(!A||!M)return new x(V/0);if(!A[0]||!M[0])return M[0]?m:new x(A[0]?N:V*0)}if(L=Xt(L),q=Xt(q),A=A.slice(),V=L-q){for(V>0?(q=L,T=M):(V=-V,T=A),T.reverse();V--;T.push(0));T.reverse()}for(V=A.length,v=M.length,V-v<0&&(T=M,M=A,A=T,v=V),V=0;v;)V=(A[--v]=A[v]+M[v]+V)/fi|0,A[v]=fi===A[v]?0:A[v]%fi;return V&&(A=[V].concat(A),++q),G(m,A,q)},n.precision=n.sd=function(m,v){var T,N,V,L=this;if(m!=null&&m!==!!m)return De(m,1,Ot),v==null?v=o:De(v,0,8),Q(new x(L),m,v);if(!(T=L.c))return null;if(V=T.length-1,N=V*ye+1,V=T[V]){for(;V%10==0;V/=10,N--);for(V=T[0];V>=10;V/=10,N++);}return m&&L.e+1>N&&(N=L.e+1),N},n.shiftedBy=function(m){return De(m,-9007199254740991,wf),this.times("1e"+m)},n.squareRoot=n.sqrt=function(){var m,v,T,N,V,L=this,q=L.c,A=L.s,M=L.e,k=a+4,R=new x("0.5");if(A!==1||!q||!q[0])return new x(!A||A<0&&(!q||q[0])?NaN:q?L:1/0);if(A=Math.sqrt(+J(L)),A==0||A==1/0?(v=Zt(q),(v.length+M)%2==0&&(v+="0"),A=Math.sqrt(+v),M=Xt((M+1)/2)-(M<0||M%2),A==1/0?v="5e"+M:(v=A.toExponential(),v=v.slice(0,v.indexOf("e")+1)+M),T=new x(v)):T=new x(A+""),T.c[0]){for(M=T.e,A=M+k,A<3&&(A=0);;)if(V=T,T=R.times(V.plus(t(L,V,k,1))),Zt(V.c).slice(0,A)===(v=Zt(T.c)).slice(0,A))if(T.e<M&&--A,v=v.slice(A-3,A+1),v=="9999"||!N&&v=="4999"){if(!N&&(Q(V,V.e+a+2,0),V.times(V).eq(L))){T=V;break}k+=4,A+=4,N=1}else{(!+v||!+v.slice(1)&&v.charAt(0)=="5")&&(Q(T,T.e+a+2,1),m=!T.times(T).eq(L));break}}return Q(T,T.e+a+1,o,m)},n.toExponential=function(m,v){return m!=null&&(De(m,0,Ot),m++),B(this,m,v,1)},n.toFixed=function(m,v){return m!=null&&(De(m,0,Ot),m=m+this.e+1),B(this,m,v)},n.toFormat=function(m,v,T){var N,V=this;if(T==null)m!=null&&v&&typeof v=="object"?(T=v,v=null):m&&typeof m=="object"?(T=m,m=v=null):T=C;else if(typeof T!="object")throw Error(Ct+"Argument not an object: "+T);if(N=V.toFixed(m,v),V.c){var L,q=N.split("."),A=+T.groupSize,M=+T.secondaryGroupSize,k=T.groupSeparator||"",R=q[0],Y=q[1],Z=V.s<0,ne=Z?R.slice(1):R,de=ne.length;if(M&&(L=A,A=M,M=L,de-=L),A>0&&de>0){for(L=de%A||A,R=ne.substr(0,L);L<de;L+=A)R+=k+ne.substr(L,A);M>0&&(R+=k+ne.slice(L)),Z&&(R="-"+R)}N=Y?R+(T.decimalSeparator||"")+((M=+T.fractionGroupSize)?Y.replace(new RegExp("\\d{"+M+"}\\B","g"),"$&"+(T.fractionGroupSeparator||"")):Y):R}return(T.prefix||"")+N+(T.suffix||"")},n.toFraction=function(m){var v,T,N,V,L,q,A,M,k,R,Y,Z,ne=this,de=ne.c;if(m!=null&&(A=new x(m),!A.isInteger()&&(A.c||A.s!==1)||A.lt(r)))throw Error(Ct+"Argument "+(A.isInteger()?"out of range: ":"not an integer: ")+J(A));if(!de)return new x(ne);for(v=new x(r),k=T=new x(r),N=M=new x(r),Z=Zt(de),L=v.e=Z.length-ne.e-1,v.c[0]=Sc[(q=L%ye)<0?ye+q:q],m=!m||A.comparedTo(v)>0?L>0?v:k:A,q=p,p=1/0,A=new x(Z),M.c[0]=0;R=t(A,v,0,1),V=T.plus(R.times(N)),V.comparedTo(m)!=1;)T=N,N=V,k=M.plus(R.times(V=k)),M=V,v=A.minus(R.times(V=v)),A=V;return V=t(m.minus(T),N,0,1),M=M.plus(V.times(k)),T=T.plus(V.times(N)),M.s=k.s=ne.s,L=L*2,Y=t(k,N,L,o).minus(ne).abs().comparedTo(t(M,T,L,o).minus(ne).abs())<1?[k,N]:[M,T],p=q,Y},n.toNumber=function(){return+J(this)},n.toPrecision=function(m,v){return m!=null&&De(m,1,Ot),B(this,m,v,2)},n.toString=function(m){var v,T=this,N=T.s,V=T.e;return V===null?N?(v="Infinity",N<0&&(v="-"+v)):v="NaN":(m==null?v=V<=u||V>=h?Eo(Zt(T.c),V):Ji(Zt(T.c),V,"0"):m===10&&$?(T=Q(new x(T),a+V+1,o),v=Ji(Zt(T.c),T.e,"0")):(De(m,2,S.length,"Base"),v=i(Ji(Zt(T.c),V,"0"),10,m,N,!0)),N<0&&T.c[0]&&(v="-"+v)),v},n.valueOf=n.toJSON=function(){return J(this)},n._isBigNumber=!0,n[Symbol.toStringTag]="BigNumber",n[Symbol.for("nodejs.util.inspect.custom")]=n.valueOf,e!=null&&x.set(e),x}function Xt(e){var t=e|0;return e>0||e===t?t:t-1}function Zt(e){for(var t,i,s=1,n=e.length,r=e[0]+"";s<n;){for(t=e[s++]+"",i=ye-t.length;i--;t="0"+t);r+=t}for(n=r.length;r.charCodeAt(--n)===48;);return r.slice(0,n+1||1)}function Qs(e,t){var i,s,n=e.c,r=t.c,a=e.s,o=t.s,u=e.e,h=t.e;if(!a||!o)return null;if(i=n&&!n[0],s=r&&!r[0],i||s)return i?s?0:-o:a;if(a!=o)return a;if(i=a<0,s=u==h,!n||!r)return s?0:!n^i?1:-1;if(!s)return u>h^i?1:-1;for(o=(u=n.length)<(h=r.length)?u:h,a=0;a<o;a++)if(n[a]!=r[a])return n[a]>r[a]^i?1:-1;return u==h?0:u>h^i?1:-1}function De(e,t,i,s){if(e<t||e>i||e!==Yt(e))throw Error(Ct+(s||"Argument")+(typeof e=="number"?e<t||e>i?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e))}function vo(e){var t=e.c.length-1;return Xt(e.e/ye)==t&&e.c[t]%2!=0}function Eo(e,t){return(e.length>1?e.charAt(0)+"."+e.slice(1):e)+(t<0?"e":"e+")+t}function Ji(e,t,i){var s,n;if(t<0){for(n=i+".";++t;n+=i);e=n+e}else if(s=e.length,++t>s){for(n=i,t-=s;--t;n+=i);e+=n}else t<s&&(e=e.slice(0,t)+"."+e.slice(t));return e}var j=bf();class O extends Error{constructor(t){super(t),this.name="QtiEvaluationException"}}class te{QTI_RESPONSE_RULES(){return["qti-response-processing-fragment","qti-response-condition","qti-set-outcome-value","qti-lookup-outcome-value","qti-get-outcome-value","qti-exit-response"]}QTI_TEMPLATE_RULES(){return["qti-set-template-value","qti-exit-template","qti-template-condition","qti-set-default-value","qti-set-correct-response","qti-template-constraint"]}QTI_EXPRESSIONS(){return["qti-base-value","qti-variable","qti-correct","qti-default","qti-is-null","qti-null","qti-and","qti-or","qti-not","qti-match","qti-map-response","qti-member","qti-subtract","qti-sum","qti-random","qti-random-float","qti-random-integer","qti-index","qti-integer-divide","qti-integer-modulus","qti-integer-to-float","qti-equal","qti-equal-rounded","qti-field-value","qti-multiple","qti-ordered","qti-map-response-point","qti-product","qti-delete","qti-string-match","qti-pattern-match","qti-substring","qti-round","qti-round-to","qti-truncate","qti-divide","qti-gt","qti-gte","qti-lt","qti-lte","qti-max","qti-min","qti-custom-operator","qti-math-operator","qti-math-constant","qti-repeat","qti-gcd","qti-lcm","qti-stats-operator","qti-power","qti-any-n","qti-inside","qti-test-variables"]}constructor(){}isExpressionNode(t){return this.QTI_EXPRESSIONS().includes(t)}isResponseRuleNode(t){return this.QTI_RESPONSE_RULES().includes(t)}isTemplateRuleNode(t){return this.QTI_TEMPLATE_RULES().includes(t)}nullValue(){return null}isNullValue(t){return typeof t>"u"||t===null}isBaseTypeNumeric(t){return t==="float"||t==="integer"}isSingleValuesMatch(t,i,s){if(this.isBaseTypeNumeric(t)){let n=new j(i),r=new j(s);return n.comparedTo(r)==0}return i===s}isMultipleValuesMatch(t,i,s){if(!Array.isArray(i)||!Array.isArray(s)||i.length!==s.length)return!1;const n=i.concat().sort(),r=s.concat().sort();if(this.isBaseTypeNumeric(t)){for(let a=0;a<n.length;a++)if(!this.isSingleValuesMatch(t,n[a],r[a]))return!1}else for(let a=0;a<n.length;a++)if(n[a]!==r[a])return!1;return!0}isOrderedValuesMatch(t,i,s){if(!Array.isArray(i)||!Array.isArray(s)||i.length!==s.length)return!1;if(this.isBaseTypeNumeric(t)){for(let n=0;n<i.length;n++)if(!this.isSingleValuesMatch(t,i[n],s[n]))return!1}else for(let n=0;n<i.length;n++)if(i[n]!==s[n])return!1;return!0}mapResponse(t){if(this.isNullValue(t.value))return t.mapping.getDefaultValue();const i=t.mapping.getValue(),s=i.length;if(t.cardinality==="single"){let n=this.isBaseTypeNumeric(t.baseType)?new j(t.value).toString():t.value;for(let r=0;r<s;r++){const a=i[r];if(this.isSingleValuesMatch("string",a.caseSensitive?a.mapKey:a.mapKey.toLowerCase(),a.caseSensitive?n:n.toLowerCase()))return t.mapping.applyConstraints(new j(a.mappedValue))}}else if(t.cardinality==="multiple"||t.cardinality==="ordered"){let n=new j(0),r=t.value;if(this.isBaseTypeNumeric(t.baseType))for(let a=0;a<r.length;a++)r[a]!==null&&(r[a]=new j(r[a]).toString());r=this.mappingEliminateNullsAndDuplicates(r);for(let a=0;a<s;a++){const o=i[a];for(let u=0;u<r.length;u++)this.isSingleValuesMatch("string",o.caseSensitive?o.mapKey:o.mapKey.toLowerCase(),o.caseSensitive?r[u]:r[u].toLowerCase())&&(n=n.plus(o.mappedValue))}return t.mapping.applyConstraints(n)}return t.mapping.getDefaultValue()}mappingEliminateNullsAndDuplicates(t){let i=t.length,s=[],n={};for(let r=0;r<i;r++)t[r]!==null&&(n[t[r]]=0);for(let r in n)s.push(r);return s}mapValueFromLookupTable(t,i){if(this.isNullValue(t.lookupTable))return this.nullValue();if(this.isNullValue(i))return t.lookupTable.getDefaultValue();const s=t.lookupTable.getValue(),n=t.lookupTable.getTableType();if(i=new j(i),n==="interpolation"){s.sort(function(r,a){return r.sourceValue-a.sourceValue});for(let r=0;r<s.length;r++){let a=s[r];const o=new j(a.sourceValue);if(i.comparedTo(o)<0||a.includeBoundary&&i.comparedTo(o)===0)return a.targetValue}}else if(n==="match"){i=new j(i);for(let r=0;r<s.length;r++){let a=s[r];const o=new j(a.sourceValue);if(i.comparedTo(o)===0)return a.targetValue}}return t.lookupTable.getDefaultValue()}mapResponsePoint(t){if(this.isNullValue(t.value))return t.areaMapping.getDefaultValue();const i=t.areaMapping.getValue(),s=i.length;if(t.cardinality==="single"){let n=this.toPointObject(t.value);for(let r=0;r<s;r++){const a=i[r];if(this.isPointInside(a.mapShape,a.mapCoords,n))return t.areaMapping.applyConstraints(new j(a.mappedValue))}}else if(t.cardinality==="multiple"){let n=new j(0),r=t.value,a=Array.from(r);for(let o=0;o<s;o++){const u=i[o];let h=!0;for(let f=0;f<r.length;f++){let p=this.toPointObject(r[f]);if(this.isPointInside(u.mapShape,u.mapCoords,p)){h&&(n=n.plus(u.mappedValue),h=!1);const y=a.indexOf(r[f]);y>-1&&a.splice(y,1)}}}return n=n.plus(new j(t.areaMapping.getDefaultValue()).times(a.length)),t.areaMapping.applyConstraints(n)}return t.areaMapping.getDefaultValue()}toPointObject(t){if(t===null||typeof t!="string")return null;const i=t.split(" ");if(i.length!=2)return null;const s=new j(i[0]).toNumber(),n=new j(i[1]).toNumber();return{x:s,y:n}}shuffleArray(t){for(let i=t.length-1;i>0;i--){let s=Math.floor(Math.random()*(i+1)),n=t[i];t[i]=t[s],t[s]=n}}shuffleArrayFixed(t){for(let i=t.length-1;i>0;i--){let s=Math.floor(Math.random()*(i+1));if(t[i].fixed||t[s].fixed)continue;let n=t[i];t[i]=t[s],t[s]=n}}generalizedLcm(t,i){let s=i[0];for(let n=1;n<t;n++){if(s===0||i[n]===0)return 0;s=this.lcm(s,i[n])}return s}lcm(t,i){return new j(t).multipliedBy(i).dividedBy(this.gcd(t,i)).toNumber()}generalizedGcd(t,i){let s=i[0];for(let n=1;n<t;n++)s=this.gcd(s,i[n]);return s}gcd(t,i){return i=new j(i),i.isZero()?t:this.gcd(i.toNumber(),new j(t).modulo(i).toNumber())}getParametersFromDefinition(t){let i=new Map;if(typeof t>"u"||(t=t.trim(),t.length===0))return i;let s=t.split("|||");for(let n=0;n<s.length;n++){const r=s[n].split("=");i.set(r[0],r.length<2?"":r[1].replaceAll("=","="))}return i}computeWordCount(t){const i=t.match(/\S+/g);return i===null?0:i.length}isPointInside(t,i,s){const n={COORDS_LENGTH:3,CENTER_X:0,CENTER_Y:1,RADIUS:2,isInside(u,h){const f=Math.pow(h.x-u[this.CENTER_X],2),p=Math.pow(h.y-u[this.CENTER_Y],2);return f+p<=Math.pow(u[this.RADIUS],2)}},r={COORDS_LENGTH:4,LEFT_X:0,TOP_Y:1,RIGHT_X:2,BOTTOM_Y:3,isInside(u,h){return h.x>=u[this.LEFT_X]&&h.x<=u[this.RIGHT_X]&&h.y>=u[this.TOP_Y]&&h.y<=u[this.BOTTOM_Y]}},a={COORDS_LENGTH:4,CENTER_X:0,CENTER_Y:1,H_RADIUS:2,V_RADIUS:3,isInside(u,h){const f=new j(Math.pow(h.x-u[this.CENTER_X],2)/Math.pow(u[this.H_RADIUS],2)),p=new j(Math.pow(h.y-u[this.CENTER_Y],2)/Math.pow(u[this.V_RADIUS],2));return f.plus(p).lte(new j(1))}},o={MINIMUM_COORDS_LENGTH:6,LEFT_X:0,TOP_Y:1,RIGHT_X:2,BOTTOM_Y:3,isInside(u,h){let f=u;if(f[0]!=f[f.length-2]||f[1]!=f[f.length-1]){let C=f;C.push(f[0]),C.push(f[1]),f=C}let p=new j(0);const y=new j(h.x).integerValue(),w=new j(h.y).integerValue();for(let C=0;C<f.length-3;C+=2){const S=new j(f[C]).integerValue(),$=new j(f[C+1]).integerValue(),x=new j(f[C+2]).integerValue(),B=new j(f[C+3]).integerValue(),E=y.minus(x).pow(2).plus(w.minus(B).pow(2)).sqrt(),G=x.minus(S).pow(2).plus(B.minus($).pow(2)).sqrt(),Q=S.minus(y).pow(2).plus($.minus(w).pow(2)).sqrt(),J=new j(Math.acos((Math.pow(E.toNumber(),2)-Math.pow(G.toNumber(),2)+Math.pow(Q.toNumber(),2))/(2*E.toNumber()*Q.toNumber()))*180/Math.PI),m=x.minus(y).times(w.minus($)),v=B.minus(w).times(y.minus(S)),T=m.minus(v);if(J.isNaN())return!0;T.gte(new j(0))?p=p.plus(J):p=p.minus(J)}let b=new j(p);return b=b.dp(6,j.ROUND_HALF_UP),!b.isZero()}};return t==="circle"?n.isInside(i,s):t==="rect"?r.isInside(i,s):t==="poly"?o.isInside(i,s):t==="ellipse"?a.isInside(i,s):t==="default"}valueToPciJson(t,i,s){return t===null?{base:null}:s==="single"?{base:this.baseValueToPciJson(t,i)}:s==="multiple"||s==="ordered"?{list:this.baseValueToPciJson(t,i)}:s==="record"?{record:this.recordValueToPciJson(t)}:{base:null}}baseValueToPciJson(t,i){let s={};switch(i){case"string":case"identifier":case"integer":case"float":case"duration":case"boolean":case"uri":case"file":return s[i]=t,s;case"point":s[i]=n=>n.split(" ").map(Number);return;case"directedPair":case"pair":return s[i]=t.split(" "),s;case"intOrIdentifier":return s[i]=null,s;default:return s[i]=null,s}}recordValueToPciJson(t){let i=[];for(let s of t.values())i.push({name:s.fieldIdentifier,base:s.value===null?null:this.valueToPciJson(s.value,s.baseType,s.cardinality)});return i}processInteractionResponse(t,i){return t.interactionType==="PortableCustom"?this.getValueFromPciJson(t.node.getResponse(),i):t.node.getResponse()}getValueFromPciJson(t,i){if(console.log("[GetValueFromPciJson][Value]",t,i),t===null||typeof i>"u")return this.nullValue();try{if(typeof t!="object")throw new O("Improper value encoding. Must be an Object.");if(Array.isArray(t))throw new O("Improper value encoding. Found Array. Must be an Object.");if(t.base!==void 0){if(i.cardinality==="single")return this.baseValueFromPciJson(t.base,i.baseType,!0);throw new O("Inconsistent value cardinality [base] for this variable. Variable must be single cardinality.")}if(t.list!==void 0){if(i.cardinality==="multiple"||i.cardinality==="ordered")return this.baseValueFromPciJson(t.list,i.baseType,!1);throw new O("Inconsistent value cardinality [list] for this variable. Variable must be multiple or ordered cardinality.")}if(t.record!==void 0){if(i.cardinality==="record")return this.recordValueFromPciJson(t.record,i);throw new O("Inconsistent value cardinality [record] for this variable. Variable must be record cardinality.")}throw new O('Improper value encoding. Must be one of "base", "list", "record".')}catch({name:s,message:n}){return console.log("[PciDecodingException][ValueFromJson] ",n),this.nullValue()}}baseValueFromPciJson(t,i,s){if(t===null)return this.nullValue();try{if(typeof t!="object")throw new O("Invalid value. Must be an Object.");if(Array.isArray(t))throw new O("Invalid value. Found Array. Must be an Object.");if(t[i]!==void 0){if(i==="point"||i==="directedPair"||i==="pair"){if(!Array.isArray(t[i]))throw new O(`Invalid value. For baseType "${i}", must be an Array`);if(s){if(t[i].length!==2)throw new O(`Invalid value. For baseType "${i}", Array must have 2 elements`);return`${t[i][0]} ${t[i][1]}`}let n=[];return t[i].forEach(r=>{if(r.length!==2)throw new O(`Invalid value. For baseType "${i}", Array must have 2 elements`);n.push(`${r[0]} ${r[1]}`)}),n}return t[i]}throw new O(`Value does not have the required base-type. Expecting ${i}.`)}catch({name:n,message:r}){return console.log("[PciDecodingException][BaseValueFromJson] ",r,t),this.nullValue()}}recordValueFromPciJson(t,i){try{let s=this.getRecordVariableFieldDefinition(i);if(s===null)throw new O(`Unable to retrieve ${i.identifier} record field definition.`);if(typeof t!="object")throw new O("Improper record value encoding. Must be an Array.");if(!Array.isArray(t))throw new O("Improper record value encoding. Must be an Array.");const n=new Map;for(let[r,a]of s)for(let o=0;o<t.length;o++)if(t[o].name!==void 0&&t[o].base!==void 0&&t[o].name===r){const u=this.baseValueFromPciJson(t[o].base,a.getBaseType(),!0),h=new Xe(r,a.getBaseType(),u);n.set(r,h);break}return n}catch({name:s,message:n}){return console.log("[VariableDecodingException][RecordValueFromJson] ",n),new Map}}getRecordVariableFieldDefinition(t){return t==null?null:t.defaultValue!==null?t.defaultValue:t.correctResponse}computeProcessingContext(t){return this.computeProcessingType(t)==="OUTCOME"?"TEST":"ITEM"}computeProcessingType(t){return t===null?"UNKNOWN":t.$options.name==="QtiOutcomeProcessing"?"OUTCOME":t.$options.name==="QtiResponseProcessing"?"RESPONSE":t.$options.name==="QtiTemplateProcessing"?"TEMPLATE":t.$options.name==="QtiBranchRule"?"OUTCOME":this.computeProcessingType(t.$parent)}computeNodeContext(t){return t===null||t.$options.name==="QtiAssessmentItem"?"ITEM":t.$options.name==="QtiAssessmentTest"?"TEST":this.computeNodeContext(t.$parent)}base64ToBytes(t){const i=atob(t);return Uint8Array.from(i,s=>s.codePointAt(0))}bytesToBase64(t){const i=Array.from(t,s=>String.fromCodePoint(s)).join("");return btoa(i)}encodeBytesToBase64(t){const i=new TextEncoder;return this.bytesToBase64(i.encode(t))}decodeBase64ToBytes(t){return new TextDecoder().decode(this.base64ToBytes(t))}}const Kb=new te,I={player:null,state:{item:null,itemBody:null,identifier:"",title:"",responseDeclarations:[],outcomeDeclarations:[],templateDeclarations:[],contextDeclarations:[],stimulusRefs:[],interactions:[],processing:[],feedbacks:[],templates:[],printedVariables:[],catalogs:[],scoringRubricBlocks:[],asyncStateMap:new Map},itemContext:{guid:null,pnp:null,sc:null,state:null,validationMessages:[],lifecycleStatus:null},itemTimer:new Wb,pciContext:{renderer2p0:"assets/pci/pci.html"},pciMessageHandler:null,windowResizeHandler:null,getResponseDeclarations(){return this.state.responseDeclarations},getResponseDeclaration(e){return this.state.responseDeclarations.find(t=>t.identifier===e)},getOutcomeDeclarations(){return this.state.outcomeDeclarations},getOutcomeDeclaration(e){return this.state.outcomeDeclarations.find(t=>t.identifier===e)},getTemplateDeclarations(){return this.state.templateDeclarations},getTemplateMathParameterVariables(){return this.state.templateDeclarations.filter(e=>e.mathVariable===!0)},getTemplateDeclaration(e){return this.state.templateDeclarations.find(t=>t.identifier===e)},getContextDeclarations(){return this.state.contextDeclarations},getContextDeclaration(e){return this.state.contextDeclarations.find(t=>t.identifier===e)},getStimulusRefs(){return this.state.stimulusRefs},getStimulusRef(e){return this.state.stimulusRefs.find(t=>t.identifier===e)},getVariableDeclaration(e){let t=this.state.outcomeDeclarations.find(i=>i.identifier===e);return typeof t<"u"||(t=this.state.responseDeclarations.find(i=>i.identifier===e),typeof t<"u")||(t=this.state.templateDeclarations.find(i=>i.identifier===e),typeof t<"u")||(t=this.state.contextDeclarations.find(i=>i.identifier===e),typeof t<"u")?t:null},getInteraction(e){return this.state.interactions.find(t=>t.identifier===e)},getInteractions(){return this.state.interactions},getProcessing(e){return this.state.processing.find(t=>t.processingType===e)},getFeedbacks(){return this.state.feedbacks},getTemplates(){return this.state.templates},getPrintedVariables(){return this.state.printedVariables},getCatalog(e){return this.state.catalogs.find(t=>t.id===e)},getCatalogs(){return this.state.catalogs},getScoringRubricBlocks(){return this.state.scoringRubricBlocks},getItem(){return this.state.item},setItem(e){this.state.item=e.item},getItemBody(){return this.state.itemBody},setItemBody(e){this.state.itemBody=e},defineResponseDeclaration(e){let t=this.state.responseDeclarations.findIndex(i=>i.identifier==e.identifier);t>-1?this.state.responseDeclarations[t]=e:this.state.responseDeclarations.push(e)},defineOutcomeDeclaration(e){let t=this.state.outcomeDeclarations.findIndex(i=>i.identifier==e.identifier);t>-1?this.state.outcomeDeclarations[t]=e:this.state.outcomeDeclarations.push(e)},defineTemplateDeclaration(e){let t=this.state.templateDeclarations.findIndex(i=>i.identifier==e.identifier);t>-1?this.state.templateDeclarations[t]=e:this.state.templateDeclarations.push(e)},defineContextDeclaration(e){let t=this.state.contextDeclarations.findIndex(i=>i.identifier==e.identifier);t>-1?this.state.contextDeclarations[t]=e:this.state.contextDeclarations.push(e)},defineStimulusRef(e){let t=this.state.stimulusRefs.findIndex(i=>i.identifier==e.identifier);t>-1?this.state.stimulusRefs[t]=e:this.state.stimulusRefs.push(e)},defineInteraction(e){let t=this.state.interactions.findIndex(s=>s.identifier==e.identifier);if(t<0){console.log("[DefineInteraction]["+e.identifier+"]"),this.state.interactions.push(e);return}let i=this.state.interactions[t];i.interactionType=e.interactionType,i.isValidResponse=e.isValidResponse,i.invalidResponseMessage=e.invalidResponseMessage,i.maxSelectionsMessage=e.maxSelectionsMessage,i.node=e.node,i.resetValue=e.resetValue},defineProcessing(e){let t=e.processingType,i=this.state.processing.findIndex(s=>s.processingType==t);i>-1?this.state.processing[i]=e:this.state.processing.push(e),t=="response"?console.log("[QtiResponseProcessing][Defined]",e):t=="template"?console.log("[QtiTemplateProcessing][Defined]",e):t=="outcome"&&console.log("[QtiOutcomeProcessing][Defined]",e)},defineResponseProcessing(e){this.defineProcessing({processingType:"response",node:e.node})},defineTemplateProcessing(e){this.defineProcessing({processingType:"template",node:e.node})},defineItemBody(e){this.setItemBody(e.node)},defineFeedback(e){this.state.feedbacks.push(e),console.log("[DefineFeedback]["+e.outcomeIdentifier+"]["+e.identifier+"]")},defineTemplate(e){this.state.templates.push(e)},definePrintedVariable(e){this.state.printedVariables.push(e)},defineCatalog(e){let t=this.state.catalogs.findIndex(i=>i.id==e.id);if(t<0){this.state.catalogs.push(e);return}this.state.catalogs[t]=e},defineScoringRubricBlock(e){this.state.scoringRubricBlocks.push(e)},resetAll(){this.state.item=null,this.state.itemBody=null,this.state.identifier="",this.state.title="",this.state.responseDeclarations.splice(0,this.state.responseDeclarations.length),this.state.outcomeDeclarations.splice(0,this.state.outcomeDeclarations.length),this.state.templateDeclarations.splice(0,this.state.templateDeclarations.length),this.state.contextDeclarations.splice(0,this.state.contextDeclarations.length),this.state.stimulusRefs.splice(0,this.state.stimulusRefs.length),this.state.interactions.splice(0,this.state.interactions.length),this.state.processing.splice(0,this.state.processing.length),this.state.feedbacks.splice(0,this.state.feedbacks.length),this.state.templates.splice(0,this.state.templates.length),this.state.printedVariables.splice(0,this.state.printedVariables.length),this.state.catalogs.splice(0,this.state.catalogs.length),this.state.scoringRubricBlocks.splice(0,this.state.scoringRubricBlocks.length),this.state.asyncStateMap.clear(),this.resetItemTimer(),this.itemContext.guid=null,this.itemContext.state=null,this.itemContext.validationMessages.splice(0,this.itemContext.validationMessages.length),this.itemContext.lifecycleStatus=null},initializeBuiltInDeclarations(){function e(){return 0}const t=new Map;t.set("candidateIdentifier",new Xe("candidateIdentifier","string",null)),t.set("testIdentifier",new Xe("testIdentifier","string",null)),t.set("environmentIdentifier",new Xe("environmentIdentifier","string",null)),this.defineContextDeclaration({identifier:"QTI_CONTEXT",baseType:null,cardinality:"record",value:t,defaultValue:t}),console.log("[QtiAssessmentItem][QTI_CONTEXT] initialized"),this.defineOutcomeDeclaration({identifier:"SCORE",baseType:"float",cardinality:"single",value:0,defaultValue:0,lookupTable:null,lookupTableType:null,view:null,interpretation:null,longInterpretation:null,normalMaximum:null,normalMinimum:null,masteryValue:null,externalScored:null,variableIdentifierRef:null}),console.log("[QtiAssessmentItem][SCORE] initialized"),this.defineOutcomeDeclaration({identifier:"MAXSCORE",baseType:"float",cardinality:"single",value:0,defaultValue:0,lookupTable:null,lookupTableType:null,view:null,interpretation:null,longInterpretation:null,normalMaximum:null,normalMinimum:null,masteryValue:null,externalScored:null,variableIdentifierRef:null}),console.log("[QtiAssessmentItem][MAXSCORE] initialized"),this.defineOutcomeDeclaration({identifier:"completionStatus",baseType:"identifier",cardinality:"single",value:"not_attempted",defaultValue:"not_attempted",lookupTable:null,lookupTableType:null,normalMaximum:null,normalMinimum:null,externalScored:null,interpretation:null}),console.log("[QtiAssessmentItem][completionStatus] initialized"),this.defineResponseDeclaration({identifier:"numAttempts",baseType:"integer",cardinality:"single",value:0,resetValue:e,defaultValue:0,state:null}),console.log("[QtiAssessmentItem][numAttempts] initialized"),this.defineResponseDeclaration({identifier:"duration",baseType:"duration",cardinality:"single",value:0,resetValue:e,defaultValue:0,state:null}),console.log("[QtiAssessmentItem][duration] initialized")},restoreContextVariables(){if(!this.hasItemContextState())return null;const e=this.getItemContextState();"contextVariables"in e&&e.contextVariables!==null&&e.contextVariables.forEach(t=>{let i=this.state.contextDeclarations.findIndex(s=>s.identifier==t.identifier);i<0||(this.state.contextDeclarations[i].value=t.value)},this)},restoreOutcomeVariables(){if(!this.hasItemContextState())return null;const e=this.getItemContextState();"outcomeVariables"in e&&e.outcomeVariables!==null&&e.outcomeVariables.forEach(t=>{this.setOutcomeVariableValue({identifier:t.identifier,value:t.value})},this)},setOutcomeVariableValue(e){let t=this.state.outcomeDeclarations.findIndex(i=>i.identifier==e.identifier);t<0||(this.state.outcomeDeclarations[t].value=e.value)},resetOutcomeVariableValue(e){let t=this.state.outcomeDeclarations.findIndex(s=>s.identifier==e.identifier);if(t<0)return;let i=this.state.outcomeDeclarations[t];if(i.defaultValue!==null){i.value=this.defaultValue;return}if(i.cardinality==="record"||i.cardinality==="multiple"||i.cardinality==="ordered"){i.value=null;return}if(i.baseType==="integer"||i.baseType==="float"){i.value=0;return}i.value=null},getResponseVariableCorrectResponse(e){let t=this.state.responseDeclarations.findIndex(i=>i.identifier==e);return t<0?null:this.state.responseDeclarations[t].correctResponse},setResponseVariableCorrectResponse(e){let t=this.state.responseDeclarations.findIndex(s=>s.identifier==e.identifier);if(t<0)return;let i=this.state.responseDeclarations[t];i.correctResponse=e.value},setInteractionIsValidResponse(e){let t=this.state.interactions.findIndex(i=>i.identifier==e.identifier);t<0||(this.state.interactions[t].isValidResponse=e.isValidResponse)},resetInteractionStateIsValidResponse(){this.state.interactions.forEach(e=>{e.interactionType!=="EndAttemptInteraction"&&(e.isValidResponse=!1)})},restoreResponseVariables(){if(!this.hasItemContextState())return null;const e=this.getItemContextState();"responseVariables"in e&&e.responseVariables!==null&&e.responseVariables.forEach(t=>{this.setResponseVariableValue({identifier:t.identifier,value:t.value,state:t.state}),"correctResponse"in t&&this.setResponseVariableCorrectResponse({identifier:t.identifier,value:t.correctResponse})},this)},setResponseVariableValue(e){let t=this.state.responseDeclarations.findIndex(s=>s.identifier==e.identifier);if(t<0)return;let i=this.state.responseDeclarations[t];i.value=e.value,i.state=e.state},resetResponseVariableValue(e){let t=this.state.responseDeclarations.findIndex(s=>s.identifier==e.identifier);if(t<0)return;let i=this.state.responseDeclarations[t];i.value=i.defaultValue!==null?i.defaultValue:null},incrementNumAttempts(){let e=this.state.responseDeclarations.findIndex(t=>t.identifier=="numAttempts");this.state.responseDeclarations[e].value+=1},updateItemDuration(){const e=this.getResponseDeclaration("duration");e.value+=this.itemTimer.getTime(),this.restartItemTimer()},restartItemTimer(){this.itemTimer.startTimer()},resetItemTimer(){this.itemTimer.resetTimer()},setTemplateVariableValue(e){let t=this.state.templateDeclarations.findIndex(i=>i.identifier==e.identifier);t<0||(this.state.templateDeclarations[t].value=e.value)},resetTemplateVariables(){this.state.templateDeclarations.forEach(e=>{e.node.reset()})},setVariableDefaultValue(e){let t=this.state.responseDeclarations.findIndex(i=>i.identifier==e.identifier);if(t>-1){let i=this.state.responseDeclarations[t];i.defaultValue=e.value;return}if(t=this.state.outcomeDeclarations.findIndex(i=>i.identifier==e.identifier),t>-1){let i=this.state.responseDeclarations[t];i.defaultValue=e.value;return}},getPciContext(){return this.pciContext},setPciContext(e){this.pciContext=e},getPciContextRenderer(){return this.pciContext.renderer2p0},setPciContextRenderer(e){this.pciContext.renderer2p0=e},initializePciMessageListener(){this.pciMessageHandler=this.PciMessageListener.bind(this),this.windowResizeHandler=this.WindowResize.bind(this),window.addEventListener("message",this.pciMessageHandler),window.addEventListener("resize",this.windowResizeHandler)},removePciMessageListener(){this.pciMessageHandler!==null&&window.removeEventListener("message",this.pciMessageHandler),this.windowResizeHandler!==null&&window.removeEventListener("resize",this.windowResizeHandler)},PciMessageListener(e){switch(e.data.message){case"PciChildLoaded":console.log("[PCI Parent] PCI Frame Loaded: "+e.data.identifier),this.pciInitialize(e.data.identifier);break;case"PciReady":console.log("[PCI Parent] PCI Ready: "+e.data.identifier+", height: "+e.data.height+", width: "+e.data.width),this.pciReady(e.data.identifier),this.pciResizeIframe(e.data.identifier,e.data.height,e.data.width,!0);break;case"PciResize":console.log("[PCI Parent] PCI Resize: "+e.data.identifier+", height: "+e.data.height+", width: "+e.data.width),this.pciResizeIframe(e.data.identifier,e.data.height,e.data.width,!1);break;case"PciGetState_Reply":console.log("[PCI Parent] PCI GetState Reply: "+e.data.identifier+", state:",e.data.state),this.pciSaveState(e.data.identifier,e.data.state);break;case"PciInteractionChanged":console.log("[PCI Parent] PCI InteractionChanged: "+e.data.identifier+", state: "+e.data.state),this.pciInteractionChanged(e.data.identifier,e.data.state);break}},WindowResize(){this.getInteractions().forEach(e=>{e.interactionType==="PortableCustom"&&e.node.pciResizeIframeWidthToContainer()})},pciSetRenderingProperties(){this.getInteractions().forEach(e=>{e.interactionType==="PortableCustom"&&e.node.pciSetRenderingProperties()})},pciInitialize(e){let t=I.getInteraction(e);typeof t>"u"||t.interactionType!=="PortableCustom"||t.node.pciInitialize()},pciReady(e){let t=I.getInteraction(e);typeof t>"u"||t.interactionType!=="PortableCustom"||t.node.pciSetReady()},pciResizeIframe(e,t,i,s){let n=I.getInteraction(e);typeof n>"u"||n.interactionType!=="PortableCustom"||(s?n.node.pciResizeIframe(t,n.node.initialWidth):n.node.pciResizeIframe(t,i))},pciSaveState(e,t){let i=I.getInteraction(e);typeof i>"u"||i.interactionType!=="PortableCustom"||i.node.pciSaveState(t)},pciInteractionChanged(e,t){let i=I.getInteraction(e);if(typeof i>"u"||i.interactionType!=="PortableCustom")return;const s=JSON.parse(t);typeof s.valid<"u"&&i.node.pciUpdateValidity(s.valid),typeof s.value<"u"&&i.node.pciUpdateResponse(s.value)},getAsyncStateMap(){return this.state.asyncStateMap},getItemContextGuid(){return this.itemContext.guid},setItemContextGuid(e){this.itemContext.guid=e},initializeItemContextPnp(){this.itemContext.pnp=new Ds},getItemContextPnp(){return this.itemContext.pnp},setItemContextPnp(e){this.itemContext.pnp===null&&this.initializeItemContextPnp(),this.itemContext.pnp.setPnp(e)},initializeItemContextSessionControl(){this.itemContext.sc=new jb},getItemContextSessionControl(){return this.itemContext.sc},setItemContextSessionControl(e){this.itemContext.sc===null&&this.initializeItemContextSessionControl(),this.itemContext.sc.setSessionControl(e)},getItemContextState(){return this.itemContext.state},setItemContextState(e){const t=new Cc,i=e===null?e:t.createStateFromState(e);this.itemContext.state=i},getItemContextStateVariable(e){if(!this.hasItemContextState())return null;const t=this.getItemContextState();let i=t.outcomeVariables.find(s=>s.identifier===e);return typeof i<"u"||(i=t.responseVariables.find(s=>s.identifier===e),typeof i<"u")||(i=t.templateVariables.find(s=>s.identifier===e),typeof i<"u")||(i=t.contextDeclarations.find(s=>s.identifier===e),typeof i<"u")?i:null},hasItemContextState(){return this.getItemContextState()!==null},getItemContextValidationMessages(){return this.itemContext.validationMessages},addItemContextValidationMessage(e){this.itemContext.validationMessages.push(e)},resetItemContextValidationMessages(){this.itemContext.validationMessages.splice(0,this.itemContext.validationMessages.length)},getItemLifecycleStatus(){return this.lifecycleStatus},setItemLifecycleStatus(e){this.lifecycleStatus=e},NotifyPlayerReady(e){this.player=e.player},NotifyEndAttempt(e){this.state.item.endAttempt(e,(function(){this.state.item.notifyEndAttemptInteractionResults("itemEndAttemptReady")}).bind(this))},NotifyNewTemplate(e){this.state.item.newTemplate(e)},NotifyItemReady(e){this.setItem(e),this.getItem().isAdaptive||this.restartItemTimer(),this.getItem().isAdaptiveItemCompleted()||this.restartItemTimer()},NotifyInteractionSelectionsLimit(e){const t={icon:"warning",message:e};this.player.displayAlertMessage(t)},NotifyInteractionStateReady(e){console.log("[InteractionStateReady][Interaction]",e.identifier);const t=this.getInteraction(e.identifier);typeof t>"u"||typeof this.getAsyncStateMap().get(t.identifier)>"u"||(this.setResponseVariableValue({identifier:t.identifier,value:Kb.processInteractionResponse(t,this.getResponseDeclaration(t.identifier)),state:t.node.getState()}),this.getAsyncStateMap().delete(t.identifier),this.getAsyncStateMap().size===0&&this.getItem().triggerGetResponsesComplete())}},Ze={player:null,state:{test:null,identifier:"",title:"",responseDeclarations:[],contextDeclarations:[],outcomeDeclarations:[],timeLimit:null,testParts:[],outcomeProcessing:null,feedbacks:[],printedVariables:[],catalogs:[],scoringRubricBlocks:[]},testContext:{guid:null,pnp:null},sectionItemStates:new Map,getTest(){return this.state.test},setTest(e){this.state.test=e.test},getResponseDeclarations(){return this.state.responseDeclarations},getResponseDeclaration(e){return this.state.responseDeclarations.find(t=>t.identifier===e)},getOutcomeDeclarations(){return this.state.outcomeDeclarations},getOutcomeDeclaration(e){return this.state.outcomeDeclarations.find(t=>t.identifier===e)},getContextDeclarations(){return this.state.contextDeclarations},getContextDeclaration(e){return this.state.contextDeclarations.find(t=>t.identifier===e)},getVariableDeclaration(e){let t=this.state.outcomeDeclarations.find(i=>i.identifier===e);return typeof t<"u"||(t=this.state.contextDeclarations.find(i=>i.identifier===e),typeof t<"u")||(t=this.state.responseDeclarations.find(i=>i.identifier===e),typeof t<"u")?t:null},getTimeLimit(){return this.timeLimit},getTestParts(){return this.state.testParts},getTestPart(e){return this.state.testParts.find(t=>t.identifier===e)},getOutcomeProcessing(){return this.state.outcomeProcessing},getFeedbacks(){return this.state.feedbacks},getPrintedVariables(){return this.state.printedVariables},getCatalog(e){return this.state.catalogs.find(t=>t.id===e)},getCatalogs(){return this.state.catalogs},getScoringRubricBlocks(){return this.state.scoringRubricBlocks},defineContextDeclaration(e){let t=this.state.contextDeclarations.findIndex(i=>i.identifier==e.identifier);t>-1?this.state.contextDeclarations[t]=e:this.state.contextDeclarations.push(e)},defineResponseDeclaration(e){let t=this.state.responseDeclarations.findIndex(i=>i.identifier==e.identifier);t>-1?this.state.responseDeclarations[t]=e:this.state.responseDeclarations.push(e)},defineOutcomeDeclaration(e){let t=this.state.outcomeDeclarations.findIndex(i=>i.identifier==e.identifier);t>-1?this.state.outcomeDeclarations[t]=e:this.state.outcomeDeclarations.push(e)},defineTimeLimit(e){this.state.timeLimit=e.node},defineTestPart(e){let t=this.state.testParts.findIndex(i=>i.identifier==e.identifier);if(t<0){this.state.testParts.push(e.testPart);return}this.state.testParts[t]=e.testPart},defineProcessing(e){this.state.processing=e,console.log("[QtiOutcomeProcessing][Defined]",e)},defineOutcomeProcessing(e){const t={processingType:"outcome",node:e.node};this.state.outcomeProcessing=t,console.log("[QtiOutcomeProcessing][Defined]",t)},defineFeedback(e){this.state.feedbacks.push(e),console.log("[DefineFeedback]["+e.outcomeIdentifier+"]["+e.identifier+"]")},definePrintedVariable(e){this.state.printedVariables.push(e)},defineCatalog(e){let t=this.state.catalogs.findIndex(i=>i.id==e.id);if(t<0){this.state.catalogs.push(e);return}this.state.catalogs[t]=e},defineScoringRubricBlock(e){this.state.scoringRubricBlocks.push(e)},resetAll(){this.state.test=null,this.state.identifier="",this.state.title="",this.state.responseDeclarations.splice(0,this.state.responseDeclarations.length),this.state.outcomeDeclarations.splice(0,this.state.outcomeDeclarations.length),this.state.contextDeclarations.splice(0,this.state.contextDeclarations.length),this.state.timeLimit=null,this.state.testParts.splice(0,this.state.testParts.length),this.state.outcomeProcessing=null,this.state.feedbacks.splice(0,this.state.feedbacks.length),this.state.printedVariables.splice(0,this.state.printedVariables.length),this.state.catalogs.splice(0,this.state.catalogs.length),this.state.scoringRubricBlocks.splice(0,this.state.scoringRubricBlocks.length),this.testContext.guid=null,this.testContext.state=null},initializeBuiltInDeclarations(){function e(){return 0}const t=new Map;t.set("candidateIdentifier",new Xe("candidateIdentifier","string",null)),t.set("testIdentifier",new Xe("testIdentifier","string",null)),t.set("environmentIdentifier",new Xe("environmentIdentifier","string",null)),this.defineContextDeclaration({identifier:"QTI_CONTEXT",baseType:null,cardinality:"record",value:t,defaultValue:t}),console.log("[QtiAssessmentTest][QTI_CONTEXT] initialized"),this.defineResponseDeclaration({identifier:"duration",baseType:"duration",cardinality:"single",value:0,resetValue:e,defaultValue:0,state:null}),console.log("[QtiAssessmentTest][duration] initialized")},setOutcomeVariableValue(e){let t=this.state.outcomeDeclarations.findIndex(i=>i.identifier==e.identifier);t<0||(this.state.outcomeDeclarations[t].value=e.value)},resetOutcomeVariableValue(e){let t=this.state.outcomeDeclarations.findIndex(s=>s.identifier==e.identifier);if(t<0)return;let i=this.state.outcomeDeclarations[t];if(i.defaultValue!==null){i.value=this.defaultValue;return}if(i.cardinality==="record"||i.cardinality==="multiple"||i.cardinality==="ordered"){i.value=null;return}if(i.baseType==="integer"||i.baseType==="float"){i.value=0;return}i.value=null},getTestContextGuid(){return this.testContext.guid},setTestContextGuid(e){this.testContext.guid=e},initializeTestContextPnp(){this.testContext.pnp=new Ds},getTestContextPnp(){return this.testContext.pnp},setTestContextPnp(e){this.testContext.pnp===null&&this.initializeTestContextPnp(),this.testContext.pnp.setPnp(e)},getAllTestStateItemStatesMap(){return this.sectionItemStates},setTestStateItemState(e,t,i,s){console.log("[TestStore][SetState][Part:"+e+"][Section:"+t+"][Item:"+i+"]",s);const n=`${e}~~${t}`;let r=this.getItemStateMapBySectionIdentifier(n);r!=null&&r.set(i,s)},getItemStateMapBySectionIdentifier(e){return this.sectionItemStates.has(e)?this.sectionItemStates.get(e):this.initializePartSectionItemStateMap(e)},getPartSectionMapBySectionIdentifier(e){for(let[t,i]of this.sectionItemStates)if(t.endsWith(e))return i;return null},initializePartSectionItemStateMap(e){return this.sectionItemStates.set(e,new Map),this.sectionItemStates.get(e)},findItemVariableValueByIdentifier(e,t){const i=this.findVariableByIdentifier(e.contextVariables,t);if(typeof i<"u")return i;const s=this.findVariableByIdentifier(e.outcomeVariables,t);if(typeof s<"u")return s;const n=this.findVariableByIdentifier(e.responseVariables,t);if(typeof n<"u")return n;const r=this.findVariableByIdentifier(e.templateVariables,t);return typeof r<"u"?r:null},findVariableByIdentifier(e,t){return e.find(i=>i.identifier===t)},getSerializedState(){return{contextVariables:this.serializeVariables(this.getContextDeclarations()),outcomeVariables:this.serializeVariables(this.getOutcomeDeclarations())}},serializeVariables(e){let t=[];return e.forEach(i=>{t.push({identifier:i.identifier,cardinality:i.cardinality,baseType:i.baseType,value:this.serializeVariableValue(i.cardinality,i.value)})}),t},serializeVariableValue(e,t){return e!=="record"?JSON.parse(JSON.stringify(t)):this.serializeRecordVariableValue(t)},serializeVariableState(e){return JSON.parse(JSON.stringify(e))},serializeRecordVariableValue(e){const t=this.strMapToJson(e);return this.jsonToStrMap(t)},strMapToJson(e){return JSON.stringify(this.strMapToObj(e))},jsonToStrMap(e){return this.objToStrMap(JSON.parse(e))},strMapToObj(e){let t=Object.create(null);for(let[i,s]of e)t[i]=s;return t},objToStrMap(e){let t=new Map;for(let i of Object.keys(e))t.set(i,e[i]);return t},NotifyTestPlayerReady(e){this.player=e.player},NotifyTestReady(e){this.setTest(e)}};class Yb{constructor(){ee(this,"xmlDeclaration",null);ee(this,"rxTrackSource",null);this.xmlDeclaration=new RegExp(/<\?xml.*?\?>/s),this.rxTrackSource=new RegExp(/<(track|source)[^>]+?\/>/g)}filterXmlDeclaration(t){return t.replace(this.xmlDeclaration,"")}filterCdata(t){return t.replaceAll("<![CDATA[","").replaceAll("]]>","")}filterStyle(t){return t.replaceAll("<style>","<amp-style>").replaceAll("</style>","</amp-style>")}filterMedia(t){return t=t.replaceAll("<video>","<amp-video>").replaceAll("<video ","<amp-video ").replaceAll("</video>","</amp-video>").replaceAll("<audio>","<amp-audio>").replaceAll("<audio ","<amp-audio ").replaceAll("</audio>","</amp-audio>"),this.filterTrackSource(t)}filterTrackSource(t){return t.replace(this.rxTrackSource,i=>i.replace(/\/>/g,">"))}}/*!
|
2
2
|
* sweetalert2 v11.14.0
|
3
3
|
* Released under the MIT License.
|
4
4
|
*/function vf(e,t,i){if(typeof e=="function"?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}function Xb(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function Ef(e,t){return e.get(vf(e,t))}function Zb(e,t,i){Xb(e,t),t.set(e,i)}function Jb(e,t,i){return e.set(vf(e,t),i),i}const ev=100,he={},tv=()=>{he.previousActiveElement instanceof HTMLElement?(he.previousActiveElement.focus(),he.previousActiveElement=null):document.body&&document.body.focus()},iv=e=>new Promise(t=>{if(!e)return t();const i=window.scrollX,s=window.scrollY;he.restoreFocusTimeout=setTimeout(()=>{tv(),t()},ev),window.scrollTo(i,s)}),Cf="swal2-",H=["container","shown","height-auto","iosfix","popup","modal","no-backdrop","no-transition","toast","toast-shown","show","hide","close","title","html-container","actions","confirm","deny","cancel","default-outline","footer","icon","icon-content","image","input","file","range","select","radio","checkbox","label","textarea","inputerror","input-label","validation-message","progress-steps","active-progress-step","progress-step","progress-step-line","loader","loading","styled","top","top-start","top-end","top-left","top-right","center","center-start","center-end","center-left","center-right","bottom","bottom-start","bottom-end","bottom-left","bottom-right","grow-row","grow-column","grow-fullscreen","rtl","timer-progress-bar","timer-progress-bar-container","scrollbar-measure","icon-success","icon-warning","icon-info","icon-question","icon-error"].reduce((e,t)=>(e[t]=Cf+t,e),{}),Co=["success","warning","info","question","error"].reduce((e,t)=>(e[t]=Cf+t,e),{}),Tf="SweetAlert2:",xc=e=>e.charAt(0).toUpperCase()+e.slice(1),Tt=e=>{console.warn(`${Tf} ${typeof e=="object"?e.join(" "):e}`)},Hs=e=>{console.error(`${Tf} ${e}`)},Sf=[],sv=e=>{Sf.includes(e)||(Sf.push(e),Tt(e))},xf=function(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null;sv(`"${e}" is deprecated and will be removed in the next major release.${t?` Use "${t}" instead.`:""}`)},To=e=>typeof e=="function"?e():e,Ic=e=>e&&typeof e.toPromise=="function",Nr=e=>Ic(e)?e.toPromise():Promise.resolve(e),_c=e=>e&&Promise.resolve(e)===e,St=()=>document.body.querySelector(`.${H.container}`),Rr=e=>{const t=St();return t?t.querySelector(e):null},Pt=e=>Rr(`.${e}`),Le=()=>Pt(H.popup),kr=()=>Pt(H.icon),nv=()=>Pt(H["icon-content"]),If=()=>Pt(H.title),Vc=()=>Pt(H["html-container"]),_f=()=>Pt(H.image),Ac=()=>Pt(H["progress-steps"]),So=()=>Pt(H["validation-message"]),Li=()=>Rr(`.${H.actions} .${H.confirm}`),_n=()=>Rr(`.${H.actions} .${H.cancel}`),Fs=()=>Rr(`.${H.actions} .${H.deny}`),rv=()=>Pt(H["input-label"]),Vn=()=>Rr(`.${H.loader}`),qr=()=>Pt(H.actions),Vf=()=>Pt(H.footer),xo=()=>Pt(H["timer-progress-bar"]),$c=()=>Pt(H.close),av=`
|
@@ -164,7 +164,7 @@ ${Tl(this.code(t,i))}
|
|
164
164
|
</svg>`,e.redo=`<svg viewbox="0 0 18 18">
|
165
165
|
<polygon class="ql-fill ql-stroke" points="12 10 14 12 16 10 12 10"></polygon>
|
166
166
|
<path class="ql-stroke" d="M9.91,13.91A4.6,4.6,0,0,1,9,14a5,5,0,1,1,5-5"></path>
|
167
|
-
</svg>`;const t={theme:"snow",boundary:"div.qti-extended-text-interaction",modules:{toolbar:{container:[["undo","redo"],["bold","italic","underline"],["blockquote"],[{list:"ordered"},{list:"bullet"}]],handlers:{redo(){this.quill.history.redo()},undo(){this.quill.history.undo()}}},history:{delay:2e3,maxStack:100,userOnly:!1},keyboard:{bindings:{tab:{key:9,handler:function(){return!0}}}}},placeholder:this.placeholder,readOnly:!1};this.quill=new X(this.$refs.editor,t),this.quill.root.setAttribute("spellcheck",!1),this.quill.on("text-change",this.textChangeHandler),this.updateCounter(this.getLength()),this.quill.enable(!0)}},setQuillEditorStyleProperties(){this.$refs.editor!=null&&this.$refs.editor.children!=null&&this.$refs.editor.children.length>0&&(this.$refs.editor.children[0].style=`width:${this.editorHeight};overflow-x:auto;`)},textChangeHandler(){let e=this.getText(),t=this.$refs.editor.children[0].innerHTML,i=this.getLength();if(this.expectedLength&&i>this.expectedLength){this.quill.deleteText(this.expectedLength,i);return}t==="<p><br></p>"&&(t=""),this.updateCounter(this.getLength()),this.$emit("input",{html:t,text:e})},updateCounter(e){if(this.showCounter){if(this.isCounterUp){this.counter=e;return}this.counter=this.computedExpectedLength-e}},getLength(){return this.quill.getLength()-1},getText(){return this.quill.getText()}},mounted(){this.initialize(),this.setQuillEditorStyleProperties(),this.$emit("editorReady",{node:this})},beforeUnmount(){this.$el&&this.quill.off("text-change",this.textChangeHandler),this.$el.remove(),this.quill=void 0}},zR={ref:"root",class:"quill-editor vertical-rl"},KR={key:0,"aria-hidden":"true",class:"ext-text-xhtml-vert-rl-counter"},YR={key:0};function XR(e,t,i,s,n,r){return l.openBlock(),l.createElementBlock("div",zR,[l.createElementVNode("div",{ref:"label",style:l.normalizeStyle(r.styleLabel),class:"ext-text-xhtml-vert-label qti-hidden"},null,4),l.createElementVNode("div",{ref:"editor",style:l.normalizeStyle(r.style)},null,4),r.showCounter?(l.openBlock(),l.createElementBlock("div",KR,[l.createTextVNode(l.toDisplayString(n.counter),1),r.isCounterUp?(l.openBlock(),l.createElementBlock("span",YR," / "+l.toDisplayString(i.expectedLength),1)):l.createCommentVNode("",!0)])):l.createCommentVNode("",!0)],512)}const ZR={name:"ExtendedTextXhtmlVerticalRl",components:{EditorQuillVerticalRl:P(WR,[["render",XR]])},props:{responseIdentifier:{required:!0,type:String},expectedLength:{required:!1,type:String},placeholder:{required:!1,type:String,default:""},heightClass:{required:!1,type:String,default:""},counterStyle:{required:!1,type:String,default:"none"}},computed:{computedExpectedLength(){return typeof this.expectedLength<"u"?this.expectedLength:"400"},colorStyle(){return I.getItemContextPnp().getColorStyle()},editorHeight(){return this.heightClass==="qti-height-lines-15"?"25.9rem":this.heightClass==="qti-height-lines-6"?"11.5rem":"6.7rem"},labelHeight(){return this.heightClass==="qti-height-lines-15"?"29.7rem":this.heightClass==="qti-height-lines-6"?"12.3rem":"6.6rem"},maxLength(){return 1e4},disabled(){return this.isDisabled}},data(){return{response:"",content:"",state:null,editor:null,isDisabled:!1}},inheritAttrs:!1,methods:{getResponse(){return this.response},setResponse(e){if(e===null){this.response="",this.setContent("");return}this.setContent(e),this.response=e},updateResponse(e){this.response=e},getState(){return this.state},setState(e){this.state=e},getContent(){return this.content},setContent(e){this.content=e},computeState(e){return{text:e}},setIsDisabled(e){this.isDisabled=e},handleInput(e){e.html&&(this.updateResponse(e.html),this.setState(this.computeState(e.text)),this.$parent.$emit("extendedTextUpdate",{response:this.getResponse()}))},handleEditorReady(e){this.node=e.node,this.$parent.$emit("extendedTextReady",{node:this})}},mounted(){}},JR={ref:"root"};function ek(e,t,i,s,n,r){const a=l.resolveComponent("EditorQuillVerticalRl");return l.openBlock(),l.createElementBlock("div",JR,[l.createVNode(a,{content:n.content,placeholder:i.placeholder,editorHeight:r.editorHeight,labelHeight:r.labelHeight,counterStyle:i.counterStyle,expectedLength:r.computedExpectedLength,disabled:r.disabled,onInput:r.handleInput,onEditorReady:r.handleEditorReady},null,8,["content","placeholder","editorHeight","labelHeight","counterStyle","expectedLength","disabled","onInput","onEditorReady"])],512)}const tk=P(ZR,[["render",ek]]),jt={DEFAULT:"default-plain",DEFAULT_SBAC:"sbac-plain",DEFAULT_LRN:"lrn-plain",DEFAULT_VERTICAL_RL:"vertical-rl-plain",XHTML_DEFAULT:"default-xhtml",XHTML_SBAC:"sbac-xhtml",XHTML_VERTICAL_RL:"vertical-rl-xhtml"};function ik(e,t,i){switch(e){case jt.XHTML_DEFAULT:case jt.XHTML_SBAC:return{template:'<extended-text-xhtml-default response-identifier="'+t.responseIdentifier+'" '+Aa(t)+Ia(t)+_a(t)+Va(t)+$a(t)+La(t)+Ma(i)+" />",components:{ExtendedTextXhtmlDefault:jR}};case jt.DEFAULT_LRN:return{template:'<extended-text-plain-lrn response-identifier="'+t.responseIdentifier+'" '+Aa(t)+Ia(t)+_a(t)+Va(t)+$a(t)+La(t)+Ma(i)+" />",components:{ExtendedTextPlainLrn:uV}};case jt.DEFAULT_VERTICAL_RL:return{template:'<extended-text-plain-vertical-rl response-identifier="'+t.responseIdentifier+'" '+Aa(t)+Ia(t)+_a(t)+Va(t)+$a(t)+La(t)+Ma(i)+" />",components:{ExtendedTextPlainVerticalRl:bV}};case jt.XHTML_VERTICAL_RL:return{template:'<extended-text-xhtml-vertical-rl response-identifier="'+t.responseIdentifier+'" '+Aa(t)+Ia(t)+_a(t)+Va(t)+$a(t)+La(t)+Ma(i)+" />",components:{ExtendedTextXhtmlVerticalRl:tk}};default:return{template:'<extended-text-plain-default response-identifier="'+t.responseIdentifier+'" '+Aa(t)+Ia(t)+_a(t)+Va(t)+$a(t)+La(t)+Ma(i)+" />",components:{ExtendedTextPlainDefault:J_}}}}function sk(e,t){const i=nk(e);if(i&&t==="plain")return jt.DEFAULT_SBAC;if(i&&t==="xhtml")return jt.XHTML_DEFAULT;if(rk(e)&&t==="plain")return jt.DEFAULT_LRN;const n=ak(e);return n&&t==="plain"?jt.DEFAULT_VERTICAL_RL:n&&t==="xhtml"?jt.XHTML_VERTICAL_RL:t==="plain"?jt.DEFAULT:t==="xhtml"?jt.XHTML_DEFAULT:jt.DEFAULT}function Ia(e){return typeof e.patternMask>"u"?"":'pattern-mask="'+e.patternMask+'" '}function _a(e){return'pattern-mask-message="'+e.patternMaskMessage+'" '}function Va(e){return'placeholder="'+e.placeholder+'" '}function Aa(e){return typeof e.expectedLength>"u"?"":'expected-length="'+e.expectedLength+'" '}function $a(e){return typeof e.heightClass>"u"?"":'height-class="'+e.heightClass+'" '}function La(e){return typeof e.counterStyle>"u"?"none":'counter-style="'+e.counterStyle+'" '}function Ma(e){let t="";for(const[i,s]of Object.entries(e))t+=`${i}="${s}" `;return t}function nk(e){return typeof e>"u"||e===null||e.length==0?!1:Ph("sbac",e)}function rk(e){return typeof e>"u"||e===null||e.length==0?!1:Ph("lrn",e)}function ak(e){return typeof e>"u"||e===null||e.length==0?!1:Ph("qti-writing-orientation-vertical-rl",e)}function Ph(e,t){const i=t.split(" ");for(let s=0;s<i.length;s++)if(i[s]===e)return!0;return!1}const Na=new F,ok=new te,lk={name:"QtiExtendedTextInteraction",props:{responseIdentifier:{required:!0,type:String},expectedLength:{required:!1,type:String},patternMask:{required:!1,type:String},placeholderText:{required:!1,type:String},format:{required:!1,type:String,default:"plain"},dataPatternmaskMessage:{required:!1,type:String},minStrings:{required:!1,type:String,default:"0"},maxStrings:{required:!1,type:String,default:"0"}},computed:{interactionTemplate(){return ik(this.interactionSubType,this.createComponentProperties(),this.$attrs)},placeholder(){return Na.validatePlaceholderText(this.placeholderText,"")},hasPatternMask(){return typeof this.patternMask<"u"},patternMaskMessage(){return Na.validatePatternmaskMessage(this.dataPatternmaskMessage,"Invalid Input")}},data(){return{response:"",state:null,baseType:"string",cardinality:"single",interactionSubType:null,isValidResponse:!1,invalidResponseMessage:"Input Required",classAttribute:"",isDisabled:!1,isQtiValid:!0,hasPrompts:!1,presentationFactory:null,node:null,priorState:null}},methods:{getResponse(){return this.response.length===0?null:this.response},setResponse(e){e===null?this.response="":this.response=e,this.node.setResponse(this.response,!0)},updateResponse(e){e===null?this.response="":this.response=e},getState(){return this.state},setState(e){this.state=e,this.node.setState(this.state,!0)},updateState(e){this.state=e},getIsValid(){return this.isValidResponse},setIsValid(e){this.isValidResponse=e},setInteractionSubType(e){this.interactionSubType=e},getInteractionSubType(){return this.interactionSubType},disable(){this.toggleDisable(!0)},enable(){this.toggleDisable(!1)},toggleDisable(e){this.isDisabled=e,this.node.setIsDisabled(e)},getInvalidResponseMessage(){return this.invalidResponseMessage},initializeValue(){this.setResponse(null),this.setState(this.computeState()),this.setIsValid(this.computeIsValid())},resetValue(){console.log("[ResetValue][identifier]",this.responseIdentifier),this.setResponse(null),this.setState(this.computeState()),this.setIsValid(this.computeIsValid())},restoreValue(e){this.setResponse(e.value),this.setState(e.state),this.updateValidity(this.computeIsValid())},getCardinality(){return this.cardinality},computeState(){return{}},computeIsValid(){const e=this.minStrings*1;if(e===0)return!0;if(this.response===null)return!1;const t=this.response.trim();return!(t.length<1||ok.computeWordCount(t)<e)},evaluateValidity(){const e=this.getIsValid(),t=this.computeIsValid();e!==t&&this.updateValidity(t)},updateValidity(e){this.setIsValid(e),I.setInteractionIsValidResponse({identifier:this.responseIdentifier,isValidResponse:e})},getPrompts(e){let t=[];return e.default&&e.default().forEach(i=>{typeof i.type<"u"&&i.type.name==="QtiPrompt"&&t.push(i)}),t},detectInteractionSubType(e,t){return sk(e,t)},createComponentProperties(){return{responseIdentifier:this.responseIdentifier,expectedLength:this.presentationFactory.getExpectedLength(),placeholder:this.placeholder,patternMask:this.patternMask,patternMaskMessage:this.patternMaskMessage,heightClass:this.presentationFactory.getHeightClass(),counterStyle:this.presentationFactory.getCounterStyle()}},handleExtendedTextUpdate(e){this.updateResponse(e.response),"state"in e&&this.updateState(e.state),this.evaluateValidity()},handleExtendedTextReady(e){this.node=e.node,this.priorState===null?this.initializeValue():this.restoreValue(this.priorState)},getPriorState(e){const t=I.getItemContextStateVariable(e);if(t===null)return null;if(!("value"in t))throw new O('Extended Text Interaction State Invalid. "value" property not found.');if(!("state"in t))throw new O('Extended Text Interaction State Invalid. "state" property not found.');return t}},created(){try{this.responseDeclaration=Na.validateResponseIdentifierAttribute(I,this.responseIdentifier),this.setInteractionSubType(this.detectInteractionSubType(this.$.vnode.props.class,this.format)),this.presentationFactory=new lI(this.$.vnode.props.class,this.expectedLength),Na.validateMaxMinStrings(this.maxStrings,this.minStrings),this.priorState=this.getPriorState(this.responseIdentifier),this.cardinality=this.getCardinality(),this.hasPrompts=this.getPrompts(this.$slots).length>0,this.appliedRegex=Na.validatePattern("pattern-mask",this.patternMask)}catch(e){throw this.isQtiValid=!1,e.name==="QtiValidationException"?new c(e.message):e.name==="QtiParseException"?new ie(e.message):new Error(e.message)}},mounted(){if(this.isQtiValid)try{I.defineInteraction({identifier:this.responseIdentifier,interactionType:"ExtendedText",interactionSubType:this.interactionSubType,node:this,resetValue:this.resetValue,isValidResponse:this.isValidResponse,invalidResponseMessage:this.getInvalidResponseMessage()}),console.log("["+this.$options.name+"][Identifier]",this.responseIdentifier)}catch(e){throw this.isQtiValid=!1,console.log("["+this.$options.name+"][ValidationError]",e.name,e.message),new c(e.message)}}},ck={ref:"root",class:"qti-extended-text-interaction"},uk={ref:"prompt",class:"qti-prompt-wrapper"};function hk(e,t,i,s,n,r){return l.openBlock(),l.createElementBlock("div",ck,[l.createElementVNode("div",uk,[l.renderSlot(e.$slots,"default")],512),(l.openBlock(),l.createBlock(l.resolveDynamicComponent(r.interactionTemplate),{ref:"textarea",onExtendedTextUpdate:r.handleExtendedTextUpdate,onExtendedTextReady:r.handleExtendedTextReady},null,40,["onExtendedTextUpdate","onExtendedTextReady"]))],512)}const dk=P(lk,[["render",hk]]);class fk{constructor(t){return this.constants={QTI_ORIENTATION_HORIZONTAL:"qti-orientation-horizontal",QTI_ORIENTATION_VERTICAL:"qti-orientation-vertical",QTI_INPUT_WIDTH_DEFAULT:"",QTI_INPUT_WIDTH_1:"qti-input-width-1",QTI_INPUT_WIDTH_2:"qti-input-width-2",QTI_INPUT_WIDTH_3:"qti-input-width-3",QTI_INPUT_WIDTH_4:"qti-input-width-4",QTI_INPUT_WIDTH_5:"qti-input-width-5",QTI_INPUT_WIDTH_6:"qti-input-width-6",QTI_INPUT_WIDTH_10:"qti-input-width-10",QTI_INPUT_WIDTH_15:"qti-input-width-15",QTI_INPUT_WIDTH_20:"qti-input-width-20",QTI_INPUT_WIDTH_25:"qti-input-width-25",QTI_INPUT_WIDTH_30:"qti-input-width-30",QTI_INPUT_WIDTH_35:"qti-input-width-35",QTI_INPUT_WIDTH_40:"qti-input-width-40",QTI_INPUT_WIDTH_45:"qti-input-width-45",QTI_INPUT_WIDTH_50:"qti-input-width-50",QTI_INPUT_WIDTH_72:"qti-input-width-72"},this.classList=t,this.presentation_OrientationClass=this.constants.QTI_ORIENTATION_HORIZONTAL,this.presentation_WidthClass=this.constants.QTI_INPUT_WIDTH_DEFAULT,this.presentation_MaxLength=8,this.processClassAttribute(),this}processClassAttribute(){if(typeof this.classList>"u"||this.classList===null||this.classList.length==0)return;const t=this.classList.split(" ");for(let i=0;i<t.length;i++)switch(t[i]){case this.constants.QTI_ORIENTATION_VERTICAL:this.presentation_OrientationClass=this.constants.QTI_ORIENTATION_VERTICAL;break;case this.constants.QTI_ORIENTATION_HORIZONTAL:this.presentation_OrientationClass=this.constants.QTI_ORIENTATION_HORIZONTAL;break;case this.constants.QTI_INPUT_WIDTH_1:this.presentation_WidthClass=this.constants.QTI_INPUT_WIDTH_1,this.presentation_MaxLength=1;break;case this.constants.QTI_INPUT_WIDTH_2:this.presentation_WidthClass=this.constants.QTI_INPUT_WIDTH_2,this.presentation_MaxLength=2;break;case this.constants.QTI_INPUT_WIDTH_3:this.presentation_WidthClass=this.constants.QTI_INPUT_WIDTH_3,this.presentation_MaxLength=3;break;case this.constants.QTI_INPUT_WIDTH_4:this.presentation_WidthClass=this.constants.QTI_INPUT_WIDTH_4,this.presentation_MaxLength=4;break;case this.constants.QTI_INPUT_WIDTH_5:this.presentation_WidthClass=this.constants.QTI_INPUT_WIDTH_5,this.presentation_MaxLength=5;break;case this.constants.QTI_INPUT_WIDTH_6:this.presentation_WidthClass=this.constants.QTI_INPUT_WIDTH_6,this.presentation_MaxLength=6;break;case this.constants.QTI_INPUT_WIDTH_10:this.presentation_WidthClass=this.constants.QTI_INPUT_WIDTH_10,this.presentation_MaxLength=10;break;case this.constants.QTI_INPUT_WIDTH_15:this.presentation_WidthClass=this.constants.QTI_INPUT_WIDTH_15,this.presentation_MaxLength=15;break;case this.constants.QTI_INPUT_WIDTH_20:this.presentation_WidthClass=this.constants.QTI_INPUT_WIDTH_20,this.presentation_MaxLength=20;break;case this.constants.QTI_INPUT_WIDTH_25:this.presentation_WidthClass=this.constants.QTI_INPUT_WIDTH_25,this.presentation_MaxLength=25;break;case this.constants.QTI_INPUT_WIDTH_30:this.presentation_WidthClass=this.constants.QTI_INPUT_WIDTH_30,this.presentation_MaxLength=30;break;case this.constants.QTI_INPUT_WIDTH_35:this.presentation_WidthClass=this.constants.QTI_INPUT_WIDTH_35,this.presentation_MaxLength=35;break;case this.constants.QTI_INPUT_WIDTH_40:this.presentation_WidthClass=this.constants.QTI_INPUT_WIDTH_40,this.presentation_MaxLength=40;break;case this.constants.QTI_INPUT_WIDTH_45:this.presentation_WidthClass=this.constants.QTI_INPUT_WIDTH_45,this.presentation_MaxLength=45;break;case this.constants.QTI_INPUT_WIDTH_50:this.presentation_WidthClass=this.constants.QTI_INPUT_WIDTH_50,this.presentation_MaxLength=50;break;case this.constants.QTI_INPUT_WIDTH_72:this.presentation_WidthClass=this.constants.QTI_INPUT_WIDTH_72,this.presentation_MaxLength=500;break}}getOrientationClass(){return this.presentation_OrientationClass}isOrientationVertical(){return this.presentation_OrientationClass==this.constants.QTI_ORIENTATION_VERTICAL}getWidthClass(){return this.presentation_WidthClass}getVerticalMaxLength(){return this.presentation_MaxLength}}const pk=new F,mk={name:"TextEntryPlainDefault",emits:["textEntryReady","textEntryUpdate"],components:{Tooltip:ra},props:{responseIdentifier:{required:!0,type:String},expectedLength:{required:!1,type:String},placeholder:{required:!1,type:String,default:""},patternMask:{required:!1,type:String},patternMaskMessage:{required:!1,type:String,default:"Invalid Input"},spellcheck:{required:!1,type:String,default:"false"},maxlength:{required:!1,type:String,default:"500"}},computed:{computedExpectedLength(){return typeof this.expectedLength<"u"?this.expectedLength*1:400},hasPatternMask(){return typeof this.patternMask<"u"},colorStyle(){return I.getItemContextPnp().getColorStyle()},disabled(){return this.isDisabled}},data(){return{response:"",priorResponse:"",appliedRegex:null,displayMessage:!1,isDisabled:!1}},methods:{getResponse(){return this.response},setResponse(e){if(e===null){this.response="";return}this.response=e},getState(){return this.state},setState(e){this.state=e},setIsDisabled(e){if(this.isDisabled=e,e){const t=this.getResponse();this.$refs.label.innerHTML=t===null?"":t,this.$refs.label.classList.remove("qti-hidden"),this.$refs.label.setAttribute("tabIndex",0),this.$refs.input.classList.add("qti-hidden"),(t===null||t.length===0)&&(this.$refs.label.style.paddingRight="1.1rem")}else this.$refs.label.classList.add("qti-hidden"),this.$refs.label.setAttribute("tabIndex",-1),this.$refs.input.classList.remove("qti-hidden")},handleInput(e){e.preventDefault();let t=!0;this.appliedRegex!==null?t=this.applyPatternMask(this.$refs.input.value):this.setResponse(this.$refs.input.value),t&&(this.priorResponse=this.$refs.input.value,this.$parent.$emit("textEntryUpdate",{response:this.getResponse()}))},getLength(){return this.response.length},applyPatternMask(e){return this.appliedRegex.test(e)?(this.setResponse(e),this.priorResponse=e,!0):(this.showPatternMaskMessage(),this.setResponse(this.priorResponse),!1)},showPatternMaskMessage(){this.$refs.tooltip.show(),this.hidePatternMaskMessage()},hidePatternMaskMessage(e=3e3){setTimeout(()=>{this.$refs.tooltip.hide()},e)}},created(){this.appliedRegex=pk.validatePattern("pattern-mask",this.patternMask)},mounted(){this.$parent.$emit("textEntryReady",{node:this})}},gk={ref:"root"},yk={ref:"label",class:"text-entry-default-label qti-hidden"},wk=["placeholder","disabled","spellcheck","maxlength"];function bk(e,t,i,s,n,r){const a=l.resolveComponent("tooltip");return l.openBlock(),l.createElementBlock("span",gk,[l.createElementVNode("span",yk,null,512),l.withDirectives(l.createElementVNode("input",l.mergeProps({ref:"input",class:"text-entry-default"},e.$attrs,{"onUpdate:modelValue":t[0]||(t[0]=o=>n.response=o),type:"text",placeholder:i.placeholder,disabled:r.disabled,autocapitalize:"none",spellcheck:i.spellcheck,maxlength:i.maxlength,onInput:t[1]||(t[1]=(...o)=>r.handleInput&&r.handleInput(...o))}),null,16,wk),[[l.vModelText,n.response]]),r.hasPatternMask?(l.openBlock(),l.createBlock(a,{key:0,ref:"tooltip",target:()=>e.$refs.input,message:i.patternMaskMessage,"color-style":r.colorStyle},null,8,["target","message","color-style"])):l.createCommentVNode("",!0)],512)}const pw=P(mk,[["render",bk]]),vk=new F,Ek={name:"TextEntryPlainDefaultVertical",emits:["textEntryReady","textEntryUpdate"],components:{Tooltip:ra},props:{responseIdentifier:{required:!0,type:String},expectedLength:{required:!1,type:String},placeholder:{required:!1,type:String,default:""},patternMask:{required:!1,type:String},patternMaskMessage:{required:!1,type:String,default:"Invalid Input"},spellcheck:{required:!1,type:String,default:"false"},widthClass:{required:!1,type:String,default:""},maxlength:{required:!1,type:String,default:"8"}},computed:{computedExpectedLength(){return typeof this.expectedLength<"u"?this.expectedLength*1:400},hasPatternMask(){return typeof this.patternMask<"u"},colorStyle(){return I.getItemContextPnp().getColorStyle()},disabled(){return this.isDisabled}},data(){return{response:"",priorResponse:"",appliedRegex:null,displayMessage:!1,caretIndex:0,maxlengthMessage:"",isDisabled:!1}},inheritAttrs:!1,methods:{getResponse(){return this.response},setResponse(e,t=!1){e===null?this.response="":this.response=e,t&&this.updateContent(this.response)},getState(){return this.state},setState(e){this.state=e},setIsDisabled(e){if(this.isDisabled=e,e){const t=this.getResponse();this.$refs.label.innerHTML=t===null?"":t,this.$refs.label.classList.remove("qti-hidden"),this.$refs.label.setAttribute("tabIndex",0),this.$refs.input.classList.add("qti-hidden"),this.hidePlaceholder()}else this.$refs.label.classList.add("qti-hidden"),this.$refs.label.setAttribute("tabIndex",-1),this.$refs.input.classList.remove("qti-hidden"),this.getContent().length===0?this.showPlaceholder():this.hidePlaceholder()},getContent(){return this.$refs.input.innerText},updateContent(e){this.$refs.input.innerText=e,e.length>0?this.hidePlaceholder():this.showPlaceholder()},getCaretIndex(){return this.caretIndex},setCaretIndex(e){this.caretIndex=e},handleInput(e){e.preventDefault();let t=!0;this.setCaretIndex(this.getCaretPos(this.$refs.input)-1);const i=this.getContent();i.length>0&&this.hidePlaceholder(),this.applyLimitCheck(i)&&(this.appliedRegex!==null?t=this.applyPatternMask(i):this.setResponse(i),t&&(i.length==0&&this.showPlaceholder(),this.priorResponse=i,this.$parent.$emit("textEntryUpdate",{response:this.getResponse()})))},handlePaste(e){e.preventDefault();const t=this.getRange();if(t===null)return;const i=this.getContent(),s=t.startOffset,n=t.endOffset;let r=e.clipboardData.getData("text/plain"),a=i.substring(0,s)+r+i.substring(n),o=!0;if(a.length>0&&this.hidePlaceholder(),a.length>this.maxlength){this.showMaxlengthMessage(),this.setResponse(this.priorResponse,!0),this.setCaretPos(this.$refs.input,s);return}this.appliedRegex!==null?o=this.applyPatternMask(a):this.setResponse(a,!0),o&&(this.setCaretIndex(s+r.length),this.setCaretPos(this.$refs.input,this.getCaretIndex()),this.priorResponse=a,this.$parent.$emit("textEntryUpdate",{response:this.getResponse()}))},handleDrop(e){e.preventDefault()},handleKeydown(e){switch(this.setCaretIndex(this.getCaretPos(this.$refs.input)),e.code){case"Enter":e.preventDefault();return;case"KeyI":case"KeyB":case"KeyU":e.ctrlKey&&e.preventDefault();return}},newDownRange(e){const t=e.firstChild,i=this.getRange();if(i===null)return;const s=i.startOffset,n=i.endOffset;if(n===this.getResponse().length)return;const r=window.getSelection();r.removeAllRanges();const a=document.createRange();a.setStart(t,s),a.setEnd(t,n+1),r.addRange(a)},newUpRange(e){const t=e.firstChild,i=this.getRange();if(i===null)return;const s=i.startOffset,n=i.endOffset;if(s===0)return;const r=window.getSelection();r.removeAllRanges();const a=document.createRange();a.setStart(t,s-1),a.setEnd(t,n),r.addRange(a)},getRange(){const e=document.getSelection();return e.rangeCount===0?null:e.getRangeAt(0)},getCaretPos(e){let t=0;if(typeof window.getSelection<"u"&&window.getSelection().rangeCount!==0){const n=window.getSelection().getRangeAt(0),r=n.cloneRange();r.selectNodeContents(e),r.setEnd(n.endContainer,n.endOffset),t=r.toString().length}return t},setCaretPos(e,t){e.focus(),e.childNodes.length===1&&document.getSelection().collapse(e.childNodes[0],t)},showPlaceholder(){this.$refs.placeholder.classList.remove("text-entry-ph-hidden")},hidePlaceholder(){this.$refs.placeholder.classList.add("text-entry-ph-hidden")},handleBlur(){this.$refs.root.classList.remove("focused")},handleFocus(){this.$refs.root.classList.add("focused")},getLength(){return this.response.length},applyLimitCheck(e){return e.length>this.maxlength?(this.showMaxlengthMessage(),this.setResponse(this.priorResponse,!0),this.setCaretPos(this.$refs.input,this.getCaretIndex()),!1):!0},applyPatternMask(e){return this.appliedRegex.test(e)?(this.setResponse(e),this.priorResponse=e,!0):(this.showPatternMaskMessage(),this.setResponse(this.priorResponse,!0),this.setCaretPos(this.$refs.input,this.getCaretIndex()),!1)},showPatternMaskMessage(){this.$refs.tooltip.show(),this.hidePatternMaskMessage()},hidePatternMaskMessage(e=3e3){setTimeout(()=>{this.$refs.tooltip.hide()},e)},showMaxlengthMessage(){this.$refs.tooltipMaxlength.show(),this.hideMaxlengthMessage()},hideMaxlengthMessage(e=1e3){setTimeout(()=>{this.$refs.tooltipMaxlength.hide()},e)},computeMaxlengthMessage(){this.maxlengthMessage=`Maximum of ${this.maxlength} character`+(this.maxlength==="1"?"":"s")}},created(){this.appliedRegex=vk.validatePattern("pattern-mask",this.patternMask),this.computeMaxlengthMessage()},mounted(){this.$parent.$emit("textEntryReady",{node:this})}},Ck=["spellcheck","maxlength","disabled"];function Tk(e,t,i,s,n,r){const a=l.resolveComponent("tooltip");return l.openBlock(),l.createElementBlock("div",l.mergeProps({ref:"root",class:"text-entry-default-vert-wrapper"},e.$attrs),[l.createElementVNode("div",{ref:"label",class:"text-entry-default-vert-label qti-hidden",onFocus:t[0]||(t[0]=(...o)=>r.handleFocus&&r.handleFocus(...o)),onBlur:t[1]||(t[1]=(...o)=>r.handleBlur&&r.handleBlur(...o))},null,544),l.createElementVNode("div",{ref:"input",class:"text-entry-default-vert",tabindex:"0",contenteditable:"true",autocapitalize:"false",spellcheck:i.spellcheck,maxlength:i.maxlength,disabled:r.disabled,onInput:t[2]||(t[2]=(...o)=>r.handleInput&&r.handleInput(...o)),onBlur:t[3]||(t[3]=(...o)=>r.handleBlur&&r.handleBlur(...o)),onFocus:t[4]||(t[4]=(...o)=>r.handleFocus&&r.handleFocus(...o)),onKeydown:t[5]||(t[5]=(...o)=>r.handleKeydown&&r.handleKeydown(...o)),onPaste:t[6]||(t[6]=(...o)=>r.handlePaste&&r.handlePaste(...o)),onDrop:t[7]||(t[7]=(...o)=>r.handleDrop&&r.handleDrop(...o))},null,40,Ck),l.createElementVNode("label",{ref:"placeholder",class:"text-entry-default-vert-ph","aria-hidden":"true"},l.toDisplayString(i.placeholder),513),r.hasPatternMask?(l.openBlock(),l.createBlock(a,{key:0,ref:"tooltip",target:()=>e.$refs.input,message:i.patternMaskMessage,"color-style":r.colorStyle},null,8,["target","message","color-style"])):l.createCommentVNode("",!0),l.createVNode(a,{ref:"tooltipMaxlength",target:()=>e.$refs.input,message:n.maxlengthMessage,"color-style":r.colorStyle},null,8,["target","message","color-style"])],16)}const Sk=P(Ek,[["render",Tk]]),Nl={DEFAULT:"default-plain-horizontal",DEFAULT_VERTICAL:"default-plain-vertical"};function xk(e,t,i){switch(e){case Nl.DEFAULT:return{template:'<text-entry-plain-default response-identifier="'+t.responseIdentifier+'" '+Hh(t)+Bh(t)+Dh(t)+Qh(t)+Fh(t)+Uh(t)+mw(t)+Gh(i)+" />",components:{TextEntryPlainDefault:pw}};case Nl.DEFAULT_VERTICAL:return{template:'<text-entry-plain-default-vertical response-identifier="'+t.responseIdentifier+'" '+Hh(t)+Bh(t)+Dh(t)+Qh(t)+Fh(t)+Uh(t)+_k(t)+Vk(t)+Gh(i)+" />",components:{TextEntryPlainDefaultVertical:Sk}};default:return{template:'<text-entry-plain-default response-identifier="'+t.responseIdentifier+'" '+Hh(t)+Bh(t)+Dh(t)+Qh(t)+Fh(t)+Uh(t)+mw(t)+Gh(i)+" />",components:{TextEntryPlainDefault:pw}}}}function Ik(e){return Ak(e)?Nl.DEFAULT_VERTICAL:Nl.DEFAULT}function Bh(e){return typeof e.patternMask>"u"?"":'pattern-mask="'+e.patternMask+'" '}function Dh(e){return'pattern-mask-message="'+e.patternMaskMessage+'" '}function Qh(e){return'placeholder="'+e.placeholder+'" '}function Hh(e){return typeof e.expectedLength>"u"?"":'expected-length="'+e.expectedLength+'" '}function Fh(e){return typeof e.format>"u"||e.format.length==0?"":'format="'+e.format+'" '}function Uh(e){return typeof e.spellcheck>"u"?"":'spellcheck="'+e.spellcheck+'" '}function mw(e){return typeof e.maxlength>"u"?"":'maxlength="'+e.maxlength+'" '}function _k(e){return typeof e.widthClass>"u"?"":'width-class="'+e.widthClass+'" '}function Vk(e){return typeof e.verticalMaxlength>"u"?"":'maxlength="'+e.verticalMaxlength+'" '}function Gh(e){let t="";for(const[i,s]of Object.entries(e))t+=`${i}="${s}" `;return t}function Ak(e){return typeof e>"u"||e===null||e.length==0?!1:gw("qti-writing-orientation-vertical-rl",e)?!0:gw("qti-orientation-vertical",e)}function gw(e,t){const i=t.split(" ");for(let s=0;s<i.length;s++)if(i[s]===e)return!0;return!1}const Rl=new F,$k={name:"QtiTextEntryInteraction",props:{responseIdentifier:{required:!0,type:String},expectedLength:{required:!1,type:String},patternMask:{required:!1,type:String},placeholderText:{required:!1,type:String},format:{required:!1,type:String,default:""},dataPatternmaskMessage:{required:!1,type:String},dataMaxlength:{required:!1,type:String},dataSpellcheck:{required:!1,type:String}},computed:{interactionTemplate(){return xk(this.interactionSubType,this.createComponentProperties(),this.$attrs)},placeholder(){return Rl.validatePlaceholderText(this.placeholderText,"")},hasPatternMask(){return typeof this.patternMask<"u"},patternMaskMessage(){return Rl.validatePatternmaskMessage(this.dataPatternmaskMessage,"Invalid Input")},colorStyle(){return I.getItemContextPnp().getColorStyle()},computeMaxlength(){return typeof this.dataMaxlength<"u"?this.dataMaxlength:500},computeSpellcheck(){return typeof this.dataSpellcheck<"u"?this.dataSpellcheck:!1}},data(){return{response:"",state:null,baseType:"string",cardinality:"single",interactionSubType:null,isValidResponse:!1,invalidResponseMessage:"Input Required",classAttribute:"",isDisabled:!1,isQtiValid:!0,presentationFactory:null,node:null,priorState:null}},methods:{getResponse(){return this.response.length===0?null:this.response},setResponse(e){e===null?this.response="":this.response=e,this.node.setResponse(this.response,!0)},updateResponse(e){e===null?this.response="":this.response=e},getState(){return this.state},setState(e){this.state=e},getIsValid(){return this.isValidResponse},setIsValid(e){this.isValidResponse=e},setInteractionSubType(e){this.interactionSubType=e},getInteractionSubType(){return this.interactionSubType},disable(){this.toggleDisable(!0)},enable(){this.toggleDisable(!1)},toggleDisable(e){this.isDisabled=e,this.node.setIsDisabled(e)},getInvalidResponseMessage(){return this.invalidResponseMessage},initializeValue(){this.setResponse(null),this.setState(this.computeState()),this.setIsValid(!1)},resetValue(){console.log("[ResetValue][identifier]",this.responseIdentifier),this.setResponse(null),this.setState(this.computeState()),this.setIsValid(!1)},restoreValue(e){this.setResponse(e.value),this.setState(e.state),this.updateValidity(this.computeIsValid())},getCardinality(){return this.cardinality},computeState(){return{}},computeIsValid(){return!(this.response===null||this.response.length<1)},evaluateValidity(){const e=this.getIsValid(),t=this.computeIsValid();e!==t&&this.updateValidity(t)},updateValidity(e){this.setIsValid(e),I.setInteractionIsValidResponse({identifier:this.responseIdentifier,isValidResponse:e})},detectInteractionSubType(e){return Ik(e)},createComponentProperties(){return{responseIdentifier:this.responseIdentifier,placeholder:this.placeholder,patternMask:this.patternMask,patternMaskMessage:this.patternMaskMessage,spellcheck:this.computeSpellcheck,maxlength:this.computeMaxlength,widthClass:this.presentationFactory.getWidthClass(),verticalMaxlength:this.presentationFactory.getVerticalMaxLength(),format:this.format}},handleTextEntryUpdate(e){this.updateResponse(e.response),this.evaluateValidity()},handleTextEntryReady(e){this.node=e.node,this.priorState===null?this.initializeValue():this.restoreValue(this.priorState)},getPriorState(e){const t=I.getItemContextStateVariable(e);if(t===null)return null;if(!("value"in t))throw new O('Text Entry Interaction State Invalid. "value" property not found.');if(!("state"in t))throw new O('Text Entry Interaction State Invalid. "state" property not found.');return t}},created(){try{this.responseDeclaration=Rl.validateResponseIdentifierAttribute(I,this.responseIdentifier),this.setInteractionSubType(this.detectInteractionSubType(this.$.vnode.props.class)),this.presentationFactory=new fk(this.$.vnode.props.class),this.priorState=this.getPriorState(this.responseIdentifier),this.cardinality=this.getCardinality(),this.appliedRegex=Rl.validatePattern("pattern-mask",this.patternMask)}catch(e){throw this.isQtiValid=!1,e.name==="QtiValidationException"?new c(e.message):e.name==="QtiParseException"?new ie(e.message):new Error(e.message)}},mounted(){if(this.isQtiValid)try{this.priorState===null?this.initializeValue():this.restoreValue(this.priorState),I.defineInteraction({identifier:this.responseIdentifier,interactionType:"TextEntry",node:this,resetValue:this.resetValue,isValidResponse:this.isValidResponse,invalidResponseMessage:this.getInvalidResponseMessage()}),console.log("["+this.$options.name+"][Identifier]",this.responseIdentifier)}catch(e){throw this.isQtiValid=!1,console.log("["+this.$options.name+"][ValidationError]",e.name,e.message),new c(e.message)}}};function Lk(e,t,i,s,n,r){return l.openBlock(),l.createBlock(l.resolveDynamicComponent(r.interactionTemplate),{ref:"input",class:"qti-text-entry-interaction",onTextEntryUpdate:r.handleTextEntryUpdate,onTextEntryReady:r.handleTextEntryReady},null,40,["onTextEntryUpdate","onTextEntryReady"])}const Mk=P($k,[["render",Lk]]),Nk=new F,Rk={name:"QtiMatchInteraction",props:{responseIdentifier:{required:!0,type:String},minAssociations:{required:!1,type:String,default:"0"},maxAssociations:{required:!1,type:String,default:"1"},shuffle:{required:!1,type:String,default:"false"},dataMaxSelectionsMessage:{required:!1,type:String},dataMinSelectionsMessage:{required:!1,type:String},dataFirstColumnHeader:{required:!1,type:String,default:null}},data(){return{response:null,state:null,isValidResponse:!1,matchsets:[],orders:[],cardinality:"single",minSelectionsMessage:"",maxSelectionsMessage:"",responseDeclaration:null,hasPrompts:!1,matchInteractionStaticClass:"",interactionSubType:"default",headerHidden:"false",rowCentric:"false",isQtiValid:!0,priorState:null}},methods:{getResponse(){return this.response},setResponse(e){this.response=e},getState(){return this.state},setState(e){this.state=e},setInteractionSubType(e){this.interactionSubType=e},getInteractionSubType(){return this.interactionSubType},getIsValid(){return this.isValidResponse},setIsValid(e){this.isValidResponse=e},getInvalidResponseMessage(){return this.minSelectionsMessage},disable(){this.$refs.matchgroup.disable()},enable(){this.$refs.matchgroup.enable()},initializeValue(e){this.setResponse(e),this.setState(this.computeState()),this.updateValidity(this.computeIsValid())},resetValue(){console.log("[ResetValue][identifier]",this.responseIdentifier),this.setResponse(null),this.setState(null),this.priorState=null,this.$refs.matchgroup.resetGroupUI()},restoreValue(e){this.setResponse(e),this.setState(this.computeState()),this.updateValidity(this.computeIsValid())},getCardinality(){let e=I.getResponseDeclaration(this.responseIdentifier);return this.cardinality=typeof e<"u"?e.cardinality:"single",this.cardinality},getPrompts(e){let t=[];return e.default&&e.default().forEach(i=>{typeof i.type<"u"&&i.type.name==="QtiPrompt"&&t.push(i)}),t},movePrompt(){if(!this.hasPrompts)return;const e=this.$refs.root.querySelector(".qti-prompt");e!==null&&this.$refs.prompt.appendChild(e)},handleMatchGroupReady(e){this.matchsets=e.matchsets,this.orders=e.orders,this.initializeValue(e.response)},handleMatchGroupUpdate(e){this.setResponse(e.response),this.updateValidity(this.computeIsValid())},handleAssociationsLimit(){I.NotifyInteractionSelectionsLimit(this.maxSelectionsMessage)},computeState(){return this.priorState!==null?this.priorState.state:{orders:this.orders}},computeIsValid(){const e=this.getResponse(),t=this.minAssociations*1;return t===0?!0:e===null?!1:this.cardinality==="single"||e.length>=t},evaluateValidity(){const e=this.getIsValid(),t=this.computeIsValid();e!==t&&this.updateValidity(t)},updateValidity(e){this.setIsValid(e),I.setInteractionIsValidResponse({identifier:this.responseIdentifier,isValidResponse:e})},computeMaxSelectionsMessage(){if(typeof this.dataMaxSelectionsMessage<"u"){this.maxSelectionsMessage=this.dataMaxSelectionsMessage;return}this.maxSelectionsMessage=this.maxAssociations*1==0?"":"You may make a maximum of "+this.maxAssociations+" match"+(this.maxAssociations*1>1?"es":"")+" for this question."},computeMinSelectionsMessage(){if(typeof this.dataMinSelectionsMessage<"u"){this.minSelectionsMessage=this.dataMinSelectionsMessage;return}this.minAssociations*1!=0&&(this.minSelectionsMessage="You must make at least "+this.minAssociations+" match"+(this.minAssociations*1>1?"es":"")+" for this question.")},detectInteractionSubType(e){return this.getMatchInteractionSubType(e)},getMatchInteractionSubType(e){let t="default";if(typeof e>"u"||e===null||e.length==0)return t;this.matchInteractionStaticClass=e;const i=e.split(" ");for(let s=0;s<i.length;s++)switch(i[s]){case"qti-match-tabular":t="matchtabular";break;case"qti-header-hidden":this.headerHidden="true";break;case"row-centric":this.rowCentric="true";break}return t},getPriorState(e){const t=I.getItemContextStateVariable(e);if(t===null)return null;if(!("value"in t))throw new O('Match Interaction State Invalid. "value" property not found.');if(!("state"in t))throw new O('Match Interaction State Invalid. "state" property not found.');if(!("orders"in t.state))throw new O('Match Interaction State Invalid. "orders" property not found.');return t}},created(){try{if(this.responseDeclaration=Nk.validateResponseIdentifierAttribute(I,this.responseIdentifier),this.setInteractionSubType(this.detectInteractionSubType(this.$.vnode.props.class)),this.priorState=this.getPriorState(this.responseIdentifier),this.cardinality=this.getCardinality(),this.cardinality!=="single"&&this.cardinality!=="multiple")throw new c('qti-match-interaction cardinality must be "single" or "multiple"');if(this.maxAssociations*1!=1&&this.cardinality!=="multiple")throw new c('qti-match-interaction response variable must have "multiple" cardinality because max-associations is '+this.maxAssociations);if(this.minAssociations*1>1&&this.cardinality==="single")throw new c('qti-match-interaction response variable must have "multiple" cardinality because min-associations is '+this.minAssociations);this.hasPrompts=this.getPrompts(this.$slots).length>0,this.computeMinSelectionsMessage(),this.computeMaxSelectionsMessage()}catch(e){throw this.isQtiValid=!1,e.name==="QtiValidationException"?new c(e.message):e.name==="QtiParseException"?new ie(e.message):new Error(e.message)}},mounted(){if(this.isQtiValid)try{this.movePrompt(),I.defineInteraction({identifier:this.responseIdentifier,interactionType:"Match",interactionSubType:this.interactionSubType,node:this,resetValue:this.resetValue,isValidResponse:this.getIsValid(),invalidResponseMessage:this.getInvalidResponseMessage(),maxSelectionsMessage:this.maxSelectionsMessage}),console.log("["+this.$options.name+"][Identifier]",this.responseIdentifier)}catch(e){throw this.isQtiValid=!1,console.log("["+this.$options.name+"][ValidationError]",e.name,e.message),new c(e.message)}}},kk={ref:"root",class:"qti-match-interaction"},qk={ref:"prompt",class:"qti-prompt-wrapper"};function Ok(e,t,i,s,n,r){const a=l.resolveComponent("MatchGroup");return l.openBlock(),l.createElementBlock("div",kk,[l.createElementVNode("div",qk,null,512),l.createVNode(a,l.mergeProps({ref:"matchgroup",cardinality:n.cardinality,shuffle:i.shuffle,responseIdentifier:i.responseIdentifier,maxAssociations:i.maxAssociations,minAssociations:i.minAssociations,interactionSubType:n.interactionSubType,matchInteractionStaticClass:n.matchInteractionStaticClass,headerHidden:n.headerHidden,rowCentric:n.rowCentric,dataFirstColumnHeader:i.dataFirstColumnHeader,priorState:n.priorState,onMatchGroupReady:r.handleMatchGroupReady,onMatchGroupUpdate:r.handleMatchGroupUpdate,onMatchGroupAssociationsLimit:r.handleAssociationsLimit},e.$attrs),{default:l.withCtx(()=>[l.renderSlot(e.$slots,"default")]),_:3},16,["cardinality","shuffle","responseIdentifier","maxAssociations","minAssociations","interactionSubType","matchInteractionStaticClass","headerHidden","rowCentric","dataFirstColumnHeader","priorState","onMatchGroupReady","onMatchGroupUpdate","onMatchGroupAssociationsLimit"])],512)}const Pk=P(Rk,[["render",Ok]]),Bk=new F,Dk={name:"QtiGapMatchInteraction",props:{responseIdentifier:{required:!0,type:String},minAssociations:{required:!1,type:String,default:"0"},maxAssociations:{required:!1,type:String,default:"1"},shuffle:{required:!1,type:String,default:"false"},dataMaxSelectionsMessage:{required:!1,type:String},dataMinSelectionsMessage:{required:!1,type:String},dataChoicesContainerWidth:{required:!1,type:String,default:null}},data(){return{response:null,state:null,isValidResponse:!1,choices:[],order:[],cardinality:"single",minSelectionsMessage:"",maxSelectionsMessage:"",responseDeclaration:null,hasPrompts:!1,gapMatchInteractionStaticClass:"",interactionSubType:"default",isQtiValid:!0,priorState:null}},methods:{getResponse(){return this.response},setResponse(e){this.response=e},getState(){return this.state},setState(e){this.state=e},setInteractionSubType(e){this.interactionSubType=e},getInteractionSubType(){return this.interactionSubType},getIsValid(){return this.isValidResponse},setIsValid(e){this.isValidResponse=e},getInvalidResponseMessage(){return this.minSelectionsMessage},disable(){this.$refs.gapmatchgroup.disable()},enable(){this.$refs.gapmatchgroup.enable()},initializeValue(e){this.setResponse(e),this.setState(this.computeState()),this.updateValidity(this.computeIsValid())},resetValue(){console.log("[ResetValue][identifier]",this.responseIdentifier),this.setResponse(null),this.setState(null),this.priorState=null,this.$refs.matchgroup.resetGroupUI()},restoreValue(e){this.setResponse(e),this.setState(this.computeState()),this.updateValidity(this.computeIsValid())},getCardinality(){let e=I.getResponseDeclaration(this.responseIdentifier);return this.cardinality=typeof e<"u"?e.cardinality:"single",this.cardinality},getPrompts(e){let t=[];return e.default&&e.default().forEach(i=>{typeof i.type<"u"&&i.type.name==="QtiPrompt"&&t.push(i)}),t},movePrompt(){if(!this.hasPrompts)return;const e=this.$refs.root.querySelector(".qti-prompt");e!==null&&this.$refs.prompt.appendChild(e)},handleGapMatchGroupReady(e){this.choices=e.choices,this.order=e.order,this.initializeValue(e.response)},handleGapMatchGroupUpdate(e){this.setResponse(e.response),this.updateValidity(this.computeIsValid())},handleAssociationsLimit(){I.NotifyInteractionSelectionsLimit(this.maxSelectionsMessage)},computeState(){return this.priorState!==null?this.priorState.state:{order:this.order}},computeIsValid(){const e=this.getResponse(),t=this.minAssociations*1;return t===0?!0:e===null?!1:this.cardinality==="single"||e.length>=t},evaluateValidity(){const e=this.getIsValid(),t=this.computeIsValid();e!==t&&this.updateValidity(t)},updateValidity(e){this.setIsValid(e),I.setInteractionIsValidResponse({identifier:this.responseIdentifier,isValidResponse:e})},computeMaxSelectionsMessage(){if(typeof this.dataMaxSelectionsMessage<"u"){this.maxSelectionsMessage=this.dataMaxSelectionsMessage;return}this.maxSelectionsMessage=this.maxAssociations*1==0?"":"You may make a maximum of "+this.maxAssociations+" match"+(this.maxAssociations*1>1?"es":"")+" for this question."},computeMinSelectionsMessage(){if(typeof this.dataMinSelectionsMessage<"u"){this.minSelectionsMessage=this.dataMinSelectionsMessage;return}this.minAssociations*1!=0&&(this.minSelectionsMessage="You must make at least "+this.minAssociations+" match"+(this.minAssociations*1>1?"es":"")+" for this question.")},detectInteractionSubType(e){return this.computeInteractionSubType(e)},computeInteractionSubType(e){let t="default";return typeof e>"u"||e===null||e.length==0||(this.gapMatchInteractionStaticClass=e),t},getPriorState(e){const t=I.getItemContextStateVariable(e);if(t===null)return null;if(!("value"in t))throw new O('Gap Match Interaction State Invalid. "value" property not found.');if(!("state"in t))throw new O('Gap Match Interaction State Invalid. "state" property not found.');if(!("order"in t.state))throw new O('Gap Match Interaction State Invalid. "order" property not found.');return t}},created(){try{if(this.responseDeclaration=Bk.validateResponseIdentifierAttribute(I,this.responseIdentifier),this.setInteractionSubType(this.detectInteractionSubType(this.$.vnode.props.class)),this.priorState=this.getPriorState(this.responseIdentifier),this.cardinality=this.getCardinality(),this.cardinality!=="single"&&this.cardinality!=="multiple")throw new c('qti-gap-match-interaction cardinality must be "single" or "multiple"');if(this.maxAssociations*1!=1&&this.cardinality!=="multiple")throw new c('qti-gap-match-interaction response variable must have "multiple" cardinality because max-associations is '+this.maxAssociations);if(this.minAssociations*1>1&&this.cardinality==="single")throw new c('qti-gap-match-interaction response variable must have "multiple" cardinality because min-associations is '+this.minAssociations);this.hasPrompts=this.getPrompts(this.$slots).length>0,this.computeMinSelectionsMessage(),this.computeMaxSelectionsMessage()}catch(e){throw this.isQtiValid=!1,e.name==="QtiValidationException"?new c(e.message):e.name==="QtiParseException"?new ie(e.message):new Error(e.message)}},mounted(){if(this.isQtiValid)try{this.movePrompt(),I.defineInteraction({identifier:this.responseIdentifier,interactionType:"GapMatch",interactionSubType:this.interactionSubType,node:this,resetValue:this.resetValue,isValidResponse:this.getIsValid(),invalidResponseMessage:this.getInvalidResponseMessage(),maxSelectionsMessage:this.maxSelectionsMessage}),console.log("["+this.$options.name+"][Identifier]",this.responseIdentifier)}catch(e){throw this.isQtiValid=!1,console.log("["+this.$options.name+"][ValidationError]",e.name,e.message),new c(e.message)}}},Qk={ref:"root",class:"qti-gap-match-interaction"},Hk={ref:"prompt",class:"qti-prompt-wrapper"};function Fk(e,t,i,s,n,r){const a=l.resolveComponent("GapMatchGroup");return l.openBlock(),l.createElementBlock("div",Qk,[l.createElementVNode("div",Hk,null,512),l.createVNode(a,l.mergeProps({ref:"gapmatchgroup",cardinality:n.cardinality,shuffle:i.shuffle,responseIdentifier:i.responseIdentifier,maxAssociations:i.maxAssociations,minAssociations:i.minAssociations,interactionSubType:n.interactionSubType,gapMatchInteractionStaticClass:n.gapMatchInteractionStaticClass,dataChoicesContainerWidth:i.dataChoicesContainerWidth,priorState:n.priorState,onGapMatchGroupReady:r.handleGapMatchGroupReady,onGapMatchGroupUpdate:r.handleGapMatchGroupUpdate,onGapMatchGroupAssociationsLimit:r.handleAssociationsLimit},e.$attrs),{default:l.withCtx(()=>[l.renderSlot(e.$slots,"default")]),_:3},16,["cardinality","shuffle","responseIdentifier","maxAssociations","minAssociations","interactionSubType","gapMatchInteractionStaticClass","dataChoicesContainerWidth","priorState","onGapMatchGroupReady","onGapMatchGroupUpdate","onGapMatchGroupAssociationsLimit"])],512)}const Uk=P(Dk,[["render",Fk]]),Gk=new F,jk={name:"QtiGraphicGapMatchInteraction",props:{responseIdentifier:{required:!0,type:String},minAssociations:{required:!1,type:String,default:"0"},maxAssociations:{required:!1,type:String,default:"1"},shuffle:{required:!1,type:String,default:"false"},dataMaxSelectionsMessage:{required:!1,type:String},dataMinSelectionsMessage:{required:!1,type:String},dataChoicesContainerWidth:{required:!1,type:String,default:null}},data(){return{response:null,state:null,isValidResponse:!1,choices:[],order:[],cardinality:"multiple",minSelectionsMessage:"",maxSelectionsMessage:"",responseDeclaration:null,hasPrompts:!1,interactionStaticClass:"",interactionSubType:"default",isQtiValid:!0,priorState:null}},methods:{getResponse(){return this.response},setResponse(e){this.response=e},getState(){return this.state},setState(e){this.state=e},setInteractionSubType(e){this.interactionSubType=e},getInteractionSubType(){return this.interactionSubType},getIsValid(){return this.isValidResponse},setIsValid(e){this.isValidResponse=e},getInvalidResponseMessage(){return this.minSelectionsMessage},disable(){this.$refs.ggmgroup.disable()},enable(){this.$refs.ggmgroup.enable()},initializeValue(e){this.setResponse(e),this.setState(this.computeState()),this.updateValidity(this.computeIsValid())},resetValue(){console.log("[ResetValue][identifier]",this.responseIdentifier),this.setResponse(null),this.setState(null),this.priorState=null,this.$refs.matchgroup.resetGroupUI()},restoreValue(e){this.setResponse(e),this.setState(this.computeState()),this.updateValidity(this.computeIsValid())},getCardinality(){let e=I.getResponseDeclaration(this.responseIdentifier);return this.cardinality=typeof e<"u"?e.cardinality:"single",this.cardinality},getPrompts(e){let t=[];return e.default&&e.default().forEach(i=>{typeof i.type<"u"&&i.type.name==="QtiPrompt"&&t.push(i)}),t},movePrompt(){if(!this.hasPrompts)return;const e=this.$refs.root.querySelector(".qti-prompt");e!==null&&this.$refs.prompt.appendChild(e)},handleGraphicGapMatchGroupReady(e){this.choices=e.choices,this.order=e.order,this.initializeValue(e.response)},handleGraphicGapMatchGroupUpdate(e){this.setResponse(e.response),this.updateValidity(this.computeIsValid())},handleAssociationsLimit(){I.NotifyInteractionSelectionsLimit(this.maxSelectionsMessage)},computeState(){return this.priorState!==null?this.priorState.state:{order:this.order}},computeIsValid(){const e=this.getResponse(),t=this.minAssociations*1;return t===0?!0:e===null?!1:this.cardinality==="single"||e.length>=t},evaluateValidity(){const e=this.getIsValid(),t=this.computeIsValid();e!==t&&this.updateValidity(t)},updateValidity(e){this.setIsValid(e),I.setInteractionIsValidResponse({identifier:this.responseIdentifier,isValidResponse:e})},computeMaxSelectionsMessage(){if(typeof this.dataMaxSelectionsMessage<"u"){this.maxSelectionsMessage=this.dataMaxSelectionsMessage;return}this.maxSelectionsMessage=this.maxAssociations*1==0?"":"You may make a maximum of "+this.maxAssociations+" match"+(this.maxAssociations*1>1?"es":"")+" for this question."},computeMinSelectionsMessage(){if(typeof this.dataMinSelectionsMessage<"u"){this.minSelectionsMessage=this.dataMinSelectionsMessage;return}this.minAssociations*1!=0&&(this.minSelectionsMessage="You must make at least "+this.minAssociations+" match"+(this.minAssociations*1>1?"es":"")+" for this question.")},detectInteractionSubType(e){return this.computeInteractionSubType(e)},computeInteractionSubType(e){let t="default";return typeof e>"u"||e===null||e.length==0||(this.interactionStaticClass=e),t},getPriorState(e){const t=I.getItemContextStateVariable(e);if(t===null)return null;if(!("value"in t))throw new O('Gap Match Interaction State Invalid. "value" property not found.');if(!("state"in t))throw new O('Gap Match Interaction State Invalid. "state" property not found.');if(!("order"in t.state))throw new O('Gap Match Interaction State Invalid. "order" property not found.');return t}},created(){try{if(this.responseDeclaration=Gk.validateResponseIdentifierAttribute(I,this.responseIdentifier),this.setInteractionSubType(this.detectInteractionSubType(this.$.vnode.props.class)),this.priorState=this.getPriorState(this.responseIdentifier),this.cardinality=this.getCardinality(),this.cardinality!=="multiple")throw new c('qti-graphic-gap-match-interaction cardinality must be "multiple"');this.hasPrompts=this.getPrompts(this.$slots).length>0,this.computeMinSelectionsMessage(),this.computeMaxSelectionsMessage()}catch(e){throw this.isQtiValid=!1,e.name==="QtiValidationException"?new c(e.message):e.name==="QtiParseException"?new ie(e.message):new Error(e.message)}},mounted(){if(this.isQtiValid)try{this.movePrompt(),I.defineInteraction({identifier:this.responseIdentifier,interactionType:"GraphicGapMatch",interactionSubType:this.interactionSubType,node:this,resetValue:this.resetValue,isValidResponse:this.getIsValid(),invalidResponseMessage:this.getInvalidResponseMessage(),maxSelectionsMessage:this.maxSelectionsMessage}),console.log("["+this.$options.name+"][Identifier]",this.responseIdentifier)}catch(e){throw this.isQtiValid=!1,console.log("["+this.$options.name+"][ValidationError]",e.name,e.message),new c(e.message)}}},Wk={ref:"root",class:"qti-graphic-gap-match-interaction"},zk={ref:"prompt",class:"qti-prompt-wrapper"};function Kk(e,t,i,s,n,r){const a=l.resolveComponent("GraphicGapMatchGroup");return l.openBlock(),l.createElementBlock("div",Wk,[l.createElementVNode("div",zk,null,512),l.createVNode(a,l.mergeProps({ref:"ggmgroup",cardinality:n.cardinality,shuffle:i.shuffle,responseIdentifier:i.responseIdentifier,maxAssociations:i.maxAssociations,minAssociations:i.minAssociations,interactionSubType:n.interactionSubType,interactionStaticClass:n.interactionStaticClass,dataChoicesContainerWidth:i.dataChoicesContainerWidth,priorState:n.priorState,onGgmGroupReady:r.handleGraphicGapMatchGroupReady,onGgmGroupUpdate:r.handleGraphicGapMatchGroupUpdate,onGgmGroupAssociationsLimit:r.handleAssociationsLimit},e.$attrs),{default:l.withCtx(()=>[l.renderSlot(e.$slots,"default")]),_:3},16,["cardinality","shuffle","responseIdentifier","maxAssociations","minAssociations","interactionSubType","interactionStaticClass","dataChoicesContainerWidth","priorState","onGgmGroupReady","onGgmGroupUpdate","onGgmGroupAssociationsLimit"])],512)}const Yk=P(jk,[["render",Kk]]),Xk={},Zk={ref:"root",class:"qti3-player-media-group"};function Jk(e,t){return l.openBlock(),l.createElementBlock("div",Zk,[l.renderSlot(e.$slots,"default")],512)}const yw=P(Xk,[["render",Jk]]),ww=new F,e2={name:"QtiMediaInteraction",components:[yw],props:{responseIdentifier:{required:!0,type:String},autostart:{required:!0,type:String},minPlays:{required:!1,type:String,default:"0"},maxPlays:{required:!1,type:String,default:"0"},loop:{required:!1,type:String,default:"false"},coords:{required:!1,type:String},dataMaxPlaysMessage:{required:!1,type:String},dataMinPlaysMessage:{required:!1,type:String}},data(){return{response:null,state:null,isValidResponse:!1,cardinality:"single",minPlaysMessage:"",maxPlaysMessage:"",responseDeclaration:null,mediaType:"media",isAutostart:!1,isLoop:!1,isDisabled:!1,isQtiValid:!0,hasPrompts:!1,node:null,priorState:null}},methods:{getResponse(){return this.response},setResponse(e){this.response=e},incrementPlays(){let e=this.getResponse();this.setResponse(e===null?1:e+1)},getState(){return this.state},setState(e){this.state=e},getIsValid(){return this.isValidResponse},setIsValid(e){this.isValidResponse=e},disable(){this.node!==null&&this.node.disable()},enable(){this.node!==null&&this.node.enable()},getInvalidResponseMessage(){return this.computeMinPlaysMessage(),this.minPlaysMessage},resetValue(){console.log("[ResetValue][identifier]",this.responseIdentifier),this.priorState=null,this.setResponse(null),this.setState(this.computeState()),this.updateValidity(this.computeIsValid())},restoreValue(e){e!==null&&(this.setResponse(e),this.setState(this.computeState()),this.updateValidity(this.computeIsValid()),this.evaluateMaxPlays())},getCardinality(){return this.cardinality},getPrompts(e){let t=[];return e.default&&e.default().forEach(i=>{typeof i.type<"u"&&i.type.name==="QtiPrompt"&&t.push(i)}),t},movePrompt(){if(!this.hasPrompts)return;const e=this.$refs.root.querySelector(".qti-prompt");e!==null&&this.$refs.prompt.appendChild(e)},handleMediaMounted(e){this.node=e.node,this.mediaType=e.mediaType,e.mediaType==="audio"&&this.node.setAudioSubType("audioprogress"),this.evaluateMaxPlays()},handleMediaLoaded(e){this.node=e.node,this.evaluateMaxPlays(),this.evaluateAutostart()},handleMediaEnded(){this.incrementPlays(),this.evaluateValidity(),this.evaluateMaxPlays(),this.evaluateLoop()},computeState(){return{}},computeIsValid(){const e=this.minPlays*1;if(e===0)return!0;const t=this.getResponse();return t===null?!1:t>=e},evaluateValidity(){const e=this.getIsValid(),t=this.computeIsValid();e!==t&&this.updateValidity(t)},updateValidity(e){this.setIsValid(e),I.setInteractionIsValidResponse({identifier:this.responseIdentifier,isValidResponse:e})},evaluateMaxPlays(){this.checkMaxPlaysLimit()?this.disable():this.enable()},evaluateLoop(){this.isLoop&&(this.checkMaxPlaysLimit()||this.isDisabled||this.playMedia())},evaluateAutostart(){this.isAutostart&&(this.checkMaxPlaysLimit()||this.isDisabled||(console.log(`[${this.$options.name}][Identifier=${this.responseIdentifier}][AutoStart]`),this.playMedia()))},playMedia(){if(this.node!=null){if(this.mediaType==="audio")return this.node.playAudio();this.node.playVideo()}},checkMaxPlaysLimit(){if(this.maxPlays*1===0)return!1;const e=this.getResponse();return e!==null&&e==this.maxPlays*1},computeMaxPlaysMessage(){if(typeof this.dataMaxPlaysMessage<"u"){this.maxPlaysMessage=this.dataMaxPlaysMessage;return}const e=this.maxPlays*1;this.maxPlaysMessage=e===0?"":`You are permitted a maximum of ${this.maxPlays} play${e>1?"s":""} for this ${this.mediaType}.`},computeMinPlaysMessage(){if(typeof this.dataMinPlaysMessage<"u"){this.minPlaysMessage=this.dataMinPlaysMessage;return}const e=this.minPlays*1;this.minPlaysMessage=e===0?"":`You must play this ${this.mediaType} to the end at least ${this.minPlays} time${e>1?"s":""}.`},validateChildren(){},processChildren(){this.processMedia(),this.setIsValid(this.computeIsValid()),this.priorState!==null&&this.restoreValue(this.priorState.value)},processMedia(){let e=this.$refs.mediagroup.$el.getElementsByTagName("object");if(e.length!==0)throw new c("Unsupported Media Interaction element. The <object> elemnt is deprecated. Use <video> or <audio> instead.");if(e=this.$refs.mediagroup.$el.getElementsByTagName("video"),e.length===0&&(e=this.$refs.mediagroup.$el.getElementsByTagName("audio")),e.length!==1)throw new c("Media Interaction must have exactly one <video> or <audio> node.")},getPriorState(e){const t=I.getItemContextStateVariable(e);if(t===null)return null;if(!("value"in t))throw new O('Media Interaction State Invalid. "value" property not found.');if(!("state"in t))throw new O('Media Interaction State Invalid. "state" property not found.');return t}},created(){try{this.responseDeclaration=ww.validateResponseIdentifierAttribute(I,this.responseIdentifier),this.validateChildren(),this.priorState=this.getPriorState(this.responseIdentifier),ww.validateMaxMinPlays(this.maxPlays,this.minPlays),this.hasPrompts=this.getPrompts(this.$slots).length>0,this.isAutostart=this.autostart==="true",this.isLoop=this.loop==="true",this.computeMaxPlaysMessage()}catch(e){throw this.isQtiValid=!1,e.name==="QtiValidationException"?new c(e.message):e.name==="QtiParseException"?new ie(e.message):new Error(e.message)}},mounted(){if(this.isQtiValid)try{this.movePrompt(),this.processChildren(),I.defineInteraction({identifier:this.responseIdentifier,interactionType:"Media",node:this,resetValue:this.resetValue,disable:this.disable,isValidResponse:this.getIsValid(),invalidResponseMessage:this.getInvalidResponseMessage(),maxSelectionsMessage:this.maxPlaysMessage}),console.log("["+this.$options.name+"][Identifier]",this.responseIdentifier)}catch(e){throw this.isQtiValid=!1,console.log("["+this.$options.name+"][ValidationError]",e.name,e.message),new c(e.message)}}},t2={ref:"root",class:"qti-media-interaction"},i2={ref:"prompt",class:"qti-prompt-wrapper"};function s2(e,t,i,s,n,r){const a=l.resolveComponent("MediaGroup");return l.openBlock(),l.createElementBlock("div",t2,[l.createElementVNode("div",i2,null,512),l.createVNode(a,{ref:"mediagroup",onMediaMounted:r.handleMediaMounted,onMediaLoaded:r.handleMediaLoaded,onMediaEnded:r.handleMediaEnded},{default:l.withCtx(()=>[l.renderSlot(e.$slots,"default")]),_:3},8,["onMediaMounted","onMediaLoaded","onMediaEnded"])],512)}const n2=P(e2,[["render",s2]]),jh=new F,r2={name:"QtiOrderInteraction",props:{responseIdentifier:{required:!0,type:String},minChoices:{required:!1,type:String},maxChoices:{required:!1,type:String},shuffle:{required:!1,type:String,default:"false"},orientation:{required:!1,type:String,default:"horizontal"},dataMaxSelectionsMessage:{required:!1,type:String},dataMinSelectionsMessage:{required:!1,type:String},dataChoicesContainerWidth:{required:!1,type:String,default:null}},data(){return{response:null,state:null,isValidResponse:!1,cardinality:"ordered",minSelectionsMessage:"",maxSelectionsMessage:"",responseDeclaration:null,interactionSubType:"default",choices:[],isShuffle:!1,hasPrompts:!1,minChoicesValue:null,maxChoicesValue:null,isMinChoicesSpecified:!1,isMaxChoicesSpecified:!1,isQtiValid:!0,priorState:null,originalOrder:null}},methods:{getResponse(){return this.response},setResponse(e){this.response=e},getState(){return this.state},setState(e){this.state=e},setInteractionSubType(e){this.interactionSubType=e},getInteractionSubType(){return this.interactionSubType},getIsValid(){return this.isValidResponse},setIsValid(e){this.isValidResponse=e},getInvalidResponseMessage(){return this.minSelectionsMessage},disable(){this.$refs.ordergroup.disable()},enable(){this.$refs.ordergroup.enable()},initializeValue(e){this.setResponse(this.computeResponse(e)),this.setState(this.computeState()),this.updateValidity(this.computeIsValid())},initializeOriginalOrder(){if(this.originalOrder!==null)return;let e=[];this.choices.forEach(t=>{e.push(t.identifier)}),this.originalOrder=e},resetValue(){console.log("[ResetValue][identifier]",this.responseIdentifier),this.setResponse(null),this.setState(null),this.priorState=null,this.$refs.ordergroup.resetGroupUI()},restoreValue(e){this.setResponse(e),this.setState(this.computeState()),this.updateValidity(this.computeIsValid())},getCardinality(){let e=I.getResponseDeclaration(this.responseIdentifier);return this.cardinality=typeof e<"u"?e.cardinality:"ordered",this.cardinality},getPrompts(e){let t=[];return e.default&&e.default().forEach(i=>{typeof i.type<"u"&&i.type.name==="QtiPrompt"&&t.push(i)}),t},movePrompt(){this.hasPrompts&&this.$refs.prompt.appendChild(this.$refs.ordergroup.getPromptElement())},handleOrderGroupReady(e){this.choices=e.choices,this.isMinChoicesSpecified||(this.minChoicesValue=this.choices.length),this.originalOrder===null&&this.initializeOriginalOrder(),this.initializeValue(e.response)},handleOrderGroupUpdate(e){this.setResponse(this.computeResponse(e.response)),this.setState({order:e.response,oorder:this.originalOrder}),this.updateValidity(this.computeIsValid())},handleSelectionsLimit(){I.NotifyInteractionSelectionsLimit(this.maxSelectionsMessage)},computeResponse(e){let t=[];typeof e>"u"?this.choices.forEach(s=>{t.push(s.identifier)}):t=e;let i=0;switch(this.interactionSubType){case"default":for(let s=0;s<t.length;s++)t[s]!==this.originalOrder[s]&&(i+=1);break;case"ordermatch":for(let s=0;s<t.length;s++)t[s]!==null&&(i+=1);break}return i===0?null:t},computeOrder(){const e=[];return this.choices.forEach(t=>{e.push(t.identifier)}),e},computeState(){return this.priorState!==null?this.priorState.state:{order:this.computeOrder(),oorder:this.originalOrder}},computeIsValid(){const e=this.getResponse(),t=this.minChoicesValue;if(e===null||e.length!==this.originalOrder.length)return!1;let i=0;switch(this.interactionSubType){case"default":for(let s=0;s<e.length;s++)e[s]!==this.originalOrder[s]&&(i+=1);return this.isMinChoicesSpecified?i>=t:i===t;case"ordermatch":for(let s=0;s<e.length;s++)e[s]!==null&&(i+=1);return this.isMinChoicesSpecified?i>=t:i===e.length}return!1},evaluateValidity(){const e=this.getIsValid(),t=this.computeIsValid();e!==t&&this.updateValidity(t)},updateValidity(e){this.setIsValid(e),I.setInteractionIsValidResponse({identifier:this.responseIdentifier,isValidResponse:e})},computeMaxSelectionsMessage(){if(typeof this.dataMaxSelectionsMessage<"u"){this.maxSelectionsMessage=this.dataMaxSelectionsMessage;return}this.maxSelectionsMessage=this.maxChoicesValue===null?"":"You may set an order for a maximum of "+this.maxChoicesValue+" choice"+(this.maxChoicesValue>1?"s":"")+" for this question."},computeMinSelectionsMessage(){if(typeof this.dataMinSelectionsMessage<"u"){this.minSelectionsMessage=this.dataMinSelectionsMessage;return}this.isMinChoicesSpecified?this.minSelectionsMessage="You must set the order for at least "+this.minChoicesValue+" choice"+(this.minChoicesValue>1?"s":"")+" for this question.":this.minSelectionsMessage="You must set the order for all choices for this question."},detectInteractionSubType(e){return this.getOrderInteractionSubType(e)},getOrderInteractionSubType(e){if(typeof e>"u"||e===null||e.length==0)return"default";const t=e.split(" ");for(let i=0;i<t.length;i++)switch(t[i]){case"qti-choices-top":case"qti-choices-bottom":case"qti-choices-left":case"qti-choices-right":return"ordermatch"}return"default"},getPriorState(e){const t=I.getItemContextStateVariable(e);if(t===null)return null;if(!("value"in t))throw new O('Order Interaction State Invalid. "value" property not found.');if(!("state"in t))throw new O('Order Interaction State Invalid. "state" property not found.');if(!("order"in t.state))throw new O('Order Interaction State Invalid. "order" property not found.');if(!("oorder"in t.state))throw new O('Order Interaction State Invalid. "oorder" property not found.');return this.originalOrder=t.state.oorder,t}},created(){try{if(this.responseDeclaration=jh.validateResponseIdentifierAttribute(I,this.responseIdentifier),this.setInteractionSubType(this.detectInteractionSubType(this.$.vnode.props.class)),this.priorState=this.getPriorState(this.responseIdentifier),this.cardinality=this.getCardinality(),this.cardinality!=="ordered")throw new c('qti-order-interaction cardinality must be "ordered"');if(this.isShuffle=this.shuffle==="true",this.hasPrompts=this.getPrompts(this.$slots).length>0,typeof this.minChoices<"u"&&(this.isMinChoicesSpecified=!0),this.minChoicesValue=jh.validateIntegerAttribute("min-choices",this.minChoices,!1,null),this.minChoicesValue===0)throw new c('qti-order-interaction "min-choices", when specified, must not be 0');if(this.isMinChoicesSpecified?(typeof this.maxChoices<"u"&&(this.isMaxChoicesSpecified=!0),this.maxChoicesValue=jh.validateIntegerAttribute("max-choices",this.maxChoices,!1,null)):this.maxChoicesValue=null,this.isMinChoicesSpecified&&this.isMaxChoicesSpecified&&this.minChoicesValue>this.maxChoicesValue)throw new c('qti-order-interaction "min-choices" must not be greater than "max-choices"');this.computeMinSelectionsMessage(),this.computeMaxSelectionsMessage()}catch(e){throw this.isQtiValid=!1,e.name==="QtiValidationException"?new c(e.message):e.name==="QtiParseException"?new ie(e.message):new Error(e.message)}},mounted(){if(this.isQtiValid)try{this.movePrompt(),I.defineInteraction({identifier:this.responseIdentifier,interactionType:"Order",node:this,resetValue:this.resetValue,isValidResponse:this.getIsValid(),invalidResponseMessage:this.getInvalidResponseMessage(),maxSelectionsMessage:this.maxSelectionsMessage}),console.log("["+this.$options.name+"][Identifier]",this.responseIdentifier)}catch(e){throw this.isQtiValid=!1,console.log("["+this.$options.name+"][ValidationError]",e.name,e.message),new c(e.message)}}},a2={ref:"root",class:"qti-order-interaction"},o2={ref:"prompt",class:"qti-prompt-wrapper"};function l2(e,t,i,s,n,r){const a=l.resolveComponent("OrderGroup");return l.openBlock(),l.createElementBlock("div",a2,[l.createElementVNode("div",o2,null,512),l.createVNode(a,l.mergeProps({ref:"ordergroup",cardinality:n.cardinality,shuffle:i.shuffle,responseIdentifier:i.responseIdentifier,orientation:i.orientation,maxChoices:n.maxChoicesValue,minChoices:n.minChoicesValue,interactionSubType:n.interactionSubType,dataChoicesContainerWidth:i.dataChoicesContainerWidth,priorState:n.priorState,onOrderGroupReady:r.handleOrderGroupReady,onOrderGroupUpdate:r.handleOrderGroupUpdate,onOrderGroupSelectionsLimit:r.handleSelectionsLimit},e.$attrs),{default:l.withCtx(()=>[l.renderSlot(e.$slots,"default")]),_:3},16,["cardinality","shuffle","responseIdentifier","orientation","maxChoices","minChoices","interactionSubType","dataChoicesContainerWidth","priorState","onOrderGroupReady","onOrderGroupUpdate","onOrderGroupSelectionsLimit"])],512)}const c2=P(r2,[["render",l2]]);class u2{constructor(){this.nodes=[]}find(t,i){if(Array.isArray(t))return t.forEach(s=>{var n;if(s.component!==null&&((n=s.component.type)==null?void 0:n.name)===i){this.nodes.push(s.component.proxy);return}Array.isArray(s==null?void 0:s.children)&&this.find(s.children,i)}),this.nodes}findNodes(t,{within:i}){return this.find(i,t)}}class h2{constructor(t){return this.constants={QTI_UNSELECTED_HIDDEN:"qti-unselected-hidden"},this.classList=t,this.presentation_UnselectedHidden=!1,this.processClassAttribute(),this}processClassAttribute(){if(typeof this.classList>"u"||this.classList===null||this.classList.length==0)return;const t=this.classList.split(" ");for(let i=0;i<t.length;i++)switch(t[i]){case this.constants.QTI_UNSELECTED_HIDDEN:this.presentation_UnselectedHidden=!0;break}}getUnselectedHidden(){return this.presentation_UnselectedHidden}}const bw=new F,d2=new u2,f2={name:"QtiHottextInteraction",props:{responseIdentifier:{required:!0,type:String},minChoices:{required:!1,type:String,default:"0"},maxChoices:{required:!1,type:String,default:"1"},dataMaxSelectionsMessage:{required:!1,type:String},dataMinSelectionsMessage:{required:!1,type:String}},inheritAttrs:!0,data(){return{response:null,state:null,isValidResponse:!1,cardinality:"single",minSelectionsMessage:"",maxSelectionsMessage:"",responseDeclaration:null,choices:[],currentChoice:null,isRadio:!0,isDisabled:!1,isQtiValid:!0,hasPrompts:!1,presentationFactory:null,priorState:null}},methods:{getResponse(){return this.response},setResponse(e){this.response=e},getState(){return this.state},setState(e){this.state=e},getIsValid(){return this.isValidResponse},setIsValid(e){this.isValidResponse=e},disable(){this.toggleDisableChoices(!0)},enable(){this.toggleDisableChoices(!1)},toggleDisableChoices(e){this.isDisabled=e,this.choices.forEach(t=>{t.setIsDisabled(e)})},getInvalidResponseMessage(){return this.minSelectionsMessage},resetValue(){console.log("[ResetValue][identifier]",this.responseIdentifier),this.choices.forEach(e=>{e.setChecked(!1)}),this.currentChoice=null,this.priorState=null},restoreValue(e){e!==null&&(this.isRadio?this.handleSetChecked(new CustomEvent("setChecked",{bubbles:!1,detail:{identifier:e,checked:"true"}}),!0):e.forEach(t=>{this.handleSetChecked(new CustomEvent("setChecked",{bubbles:!1,detail:{identifier:t,checked:"true"}}),!0)},this),this.setResponse(this.computeResponse()),this.setState(this.computeState()),this.updateValidity(this.computeIsValid()))},getCardinality(){let e=I.getResponseDeclaration(this.responseIdentifier);return this.cardinality=typeof e<"u"?e.cardinality!=="multiple"?"single":"multiple":"single",this.cardinality},getPrompts(e){let t=[];return e.default&&e.default().forEach(i=>{typeof i.type<"u"&&i.type.name==="QtiPrompt"&&t.push(i)}),t},movePrompt(){if(!this.hasPrompts)return;const e=this.$refs.root.querySelector(".qti-prompt");e!==null&&this.$refs.prompt.appendChild(e)},handleSetChecked(e,t=!1){const i=e.detail;this.choices.forEach(s=>{this.isRadio&&s.setChecked(!1),s.identifier===i.identifier&&(this.currentChoice=s)}),i.checked==="true"?this.checkMaxChoicesLimit()?this.currentChoice.setChecked(!1):this.currentChoice.setChecked(!0):this.currentChoice.setChecked(!1),t||(this.setResponse(this.computeResponse()),this.currentChoice.setFocus(),this.evaluateValidity())},computeResponse(){let e=this.isRadio?null:[];return this.choices.forEach(t=>{t.isChecked()&&(this.isRadio?e=t.identifier:e.push(t.identifier))}),this.isRadio?e:e.length===0?null:e},computeState(){return{}},computeIsValid(){return this.minChoices*1===0?!0:this.response===null?!1:this.cardinality==="single"||this.cardinality==="multiple"&&this.response.length>=this.minChoices*1},evaluateValidity(){const e=this.getIsValid(),t=this.computeIsValid();e!==t&&this.updateValidity(t)},updateValidity(e){this.setIsValid(e),I.setInteractionIsValidResponse({identifier:this.responseIdentifier,isValidResponse:e})},checkMaxChoicesLimit(){if(this.isRadio||this.maxChoices==0)return!1;const e=this.getResponse();return e!==null&&e.length==this.maxChoices?(I.NotifyInteractionSelectionsLimit(this.maxSelectionsMessage),!0):!1},computeMaxSelectionsMessage(){if(typeof this.dataMaxSelectionsMessage<"u"){this.maxSelectionsMessage=this.dataMaxSelectionsMessage;return}this.maxSelectionsMessage=this.maxChoices==0?"":"You are permitted a maximum of "+this.maxChoices+" selection"+(this.maxChoices>1?"s":"")+" for this question.<br/><br/>Please unselect one of your selections before making another selection."},computeMinSelectionsMessage(){if(typeof this.dataMinSelectionsMessage<"u"){this.minSelectionsMessage=this.dataMinSelectionsMessage;return}this.minSelectionsMessage=this.minChoices==0?"":"You must make at least "+this.minChoices+" selection"+(this.minChoices>1?"s":"")+" for this question."},validateChildren(){},processChildren(){const e=this.$.subTree===null?null:this.$.subTree.children[1].children;this.choices=d2.findNodes("QtiHottext",{within:e}),this.processGroupUI(),this.priorState!==null&&this.restoreValue(this.priorState.value)},processGroupUI(){this.setUnselectedHidden(),this.setResponse(null),this.setState(this.computeState()),this.setIsValid(this.computeIsValid())},setUnselectedHidden(){this.presentationFactory.getUnselectedHidden()&&this.$refs.hottextgroup.setAttribute("class","qti3-player-hottext-group qti-unselected-hidden")},getPriorState(e){const t=I.getItemContextStateVariable(e);if(t===null)return null;if(!("value"in t))throw new O('Hottext Interaction State Invalid. "value" property not found.');if(!("state"in t))throw new O('Hottext Interaction State Invalid. "state" property not found.');return t}},created(){try{this.responseDeclaration=bw.validateResponseIdentifierAttribute(I,this.responseIdentifier),this.presentationFactory=new h2(this.$.vnode.props.class),this.validateChildren(),this.priorState=this.getPriorState(this.responseIdentifier),bw.validateMaxMinChoices(this.maxChoices,this.minChoices),this.isRadio=this.getCardinality()!=="multiple",this.hasPrompts=this.getPrompts(this.$slots).length>0,this.computeMinSelectionsMessage(),this.computeMaxSelectionsMessage()}catch(e){throw this.isQtiValid=!1,e.name==="QtiValidationException"?new c(e.message):e.name==="QtiParseException"?new ie(e.message):new Error(e.message)}},mounted(){if(this.isQtiValid)try{this.movePrompt(),this.processChildren(),I.defineInteraction({identifier:this.responseIdentifier,interactionType:"Hottext",node:this,resetValue:this.resetValue,disable:this.disable,isValidResponse:this.getIsValid(),invalidResponseMessage:this.getInvalidResponseMessage(),maxSelectionsMessage:this.maxSelectionsMessage}),console.log("["+this.$options.name+"][Identifier]",this.responseIdentifier)}catch(e){throw this.isQtiValid=!1,console.log("["+this.$options.name+"][ValidationError]",e.name,e.message),new c(e.message)}}},p2={ref:"root",class:"qti-hottext-interaction"},m2={ref:"prompt",class:"qti-prompt-wrapper"};function g2(e,t,i,s,n,r){return l.openBlock(),l.createElementBlock("div",p2,[l.createElementVNode("div",m2,null,512),l.createElementVNode("div",{ref:"hottextgroup","on:setChecked":t[0]||(t[0]=(...a)=>r.handleSetChecked&&r.handleSetChecked(...a)),class:"qti3-player-hottext-group"},[l.renderSlot(e.$slots,"default")],544)],512)}const y2=P(f2,[["render",g2]]);class w2{constructor(t){return this.constants={QTI_SELECTIONS_LIGHT:"qti-selections-light",QTI_SELECTIONS_DARK:"qti-selections-dark",QTI_UNSELECTED_HIDDEN:"qti-unselected-hidden",THEME_LIGHT:{selectedOpacity:"1.0",unselectedOpacity:"0.5",fillColor:"orange",fillOpacity:"0",strokeColor:"orange",strokeWidth:2,selectedStrokeWidth:4},THEME_DARK:{selectedOpacity:"1.0",unselectedOpacity:"0.5",fillColor:"#0088CC",fillOpacity:"0",strokeColor:"blue",strokeWidth:2,selectedStrokeWidth:4},THEME_HIDDEN_LIGHT:{selectedOpacity:"1.0",unselectedOpacity:"0",fillColor:"orange",fillOpacity:"0",strokeColor:"orange",strokeWidth:2,selectedStrokeWidth:4},THEME_HIDDEN_DARK:{selectedOpacity:"1.0",unselectedOpacity:"0",fillColor:"blue",fillOpacity:"0",strokeColor:"blue",strokeWidth:2,selectedStrokeWidth:4}},this.classList=t,this.presentation_Theme=this.constants.QTI_SELECTIONS_DARK,this.theme=this.constants.THEME_DARK,this.presentation_UnselectedHidden=!1,this.processClassAttribute(),this}processClassAttribute(){if(typeof this.classList>"u"||this.classList===null||this.classList.length==0)return;const t=this.classList.split(" ");for(let i=0;i<t.length;i++)switch(t[i]){case this.constants.QTI_SELECTIONS_DARK:this.presentation_Theme=this.constants.QTI_SELECTIONS_DARK;break;case this.constants.QTI_SELECTIONS_LIGHT:this.presentation_Theme=this.constants.QTI_SELECTIONS_LIGHT;break;case this.constants.QTI_UNSELECTED_HIDDEN:this.presentation_UnselectedHidden=!0;break}switch(this.presentation_Theme){case this.constants.QTI_SELECTIONS_DARK:this.presentation_UnselectedHidden&&(this.theme=this.constants.THEME_HIDDEN_DARK);break;case this.constants.QTI_SELECTIONS_LIGHT:this.presentation_UnselectedHidden?this.theme=this.constants.THEME_HIDDEN_LIGHT:this.theme=this.constants.THEME_LIGHT;break}}getThemeColors(){return this.theme}}const vw=new F,b2={name:"QtiHotspotInteraction",props:{responseIdentifier:{required:!0,type:String},minChoices:{required:!1,type:String,default:"0"},maxChoices:{required:!1,type:String,default:"1"},dataMaxSelectionsMessage:{required:!1,type:String},dataMinSelectionsMessage:{required:!1,type:String}},data(){return{response:null,state:null,isValidResponse:!1,cardinality:"single",minSelectionsMessage:"",maxSelectionsMessage:"",responseDeclaration:null,choices:[],currentChoice:null,shapeElements:[],currentElement:null,backgroundImage:null,backgroundImageWidth:"0",backgroundImageHeight:"0",isRadio:!0,isDisabled:!1,isQtiValid:!0,hasPrompts:!1,presentationFactory:null,shapeColorProperties:null,priorState:null}},methods:{getResponse(){return this.response},setResponse(e){this.response=e},getState(){return this.state},setState(e){this.state=e},getIsValid(){return this.isValidResponse},setIsValid(e){this.isValidResponse=e},disable(){this.toggleDisableChoices(!0)},enable(){this.toggleDisableChoices(!1)},toggleDisableChoices(e){this.isDisabled=e},getInvalidResponseMessage(){return this.minSelectionsMessage},resetValue(){console.log("[ResetValue][identifier]",this.responseIdentifier);for(let e=0;e<this.choices.length;e++)this.setChoiceUnChecked(this.choices[e],this.shapeElements[e]);this.currentChoice=null,this.currentElement=null,this.priorState=null,this.setResponse(null),this.setState(this.computeState()),this.updateValidity(this.computeIsValid())},restoreValue(e){e!==null&&(this.isRadio?this.handleSetChecked(new CustomEvent("setChecked",{bubbles:!1,detail:{identifier:e,checked:"true"}}),!0):e.forEach(t=>{this.handleSetChecked(new CustomEvent("setChecked",{bubbles:!1,detail:{identifier:t,checked:"true"}}),!0)},this),this.setResponse(this.computeResponse()),this.setState(this.computeState()),this.updateValidity(this.computeIsValid()))},getCardinality(){let e=I.getResponseDeclaration(this.responseIdentifier);return this.cardinality=typeof e<"u"?e.cardinality!=="multiple"?"single":"multiple":"single",this.cardinality},getPrompts(e){let t=[];return e.default&&e.default().forEach(i=>{typeof i.type<"u"&&i.type.name==="QtiPrompt"&&t.push(i)}),t},movePrompt(){if(!this.hasPrompts)return;const e=this.$refs.root.querySelector(".qti-prompt");e!==null&&this.$refs.prompt.appendChild(e)},handleSetChecked(e,t=!1){const i=e.detail;for(let s=0;s<this.choices.length;s++)this.isRadio&&this.setChoiceUnChecked(this.choices[s],this.shapeElements[s]),this.choices[s].identifier===i.identifier&&(this.currentChoice=this.choices[s],this.currentElement=this.shapeElements[s]);i.checked==="true"?this.checkMaxChoicesLimit()?this.setChoiceUnChecked(this.currentChoice,this.currentElement):this.setChoiceChecked(this.currentChoice,this.currentElement):this.setChoiceUnChecked(this.currentChoice,this.currentElement),t||(this.setResponse(this.computeResponse()),this.currentElement.focus(),this.evaluateValidity())},computeResponse(){let e=this.isRadio?null:[];return this.choices.forEach(t=>{t.isChecked()&&(this.isRadio?e=t.identifier:e.push(t.identifier))}),this.isRadio?e:e.length===0?null:e},computeState(){return{}},computeIsValid(){return this.minChoices*1===0?!0:this.response===null?!1:this.cardinality==="single"||this.cardinality==="multiple"&&this.response.length>=this.minChoices*1},evaluateValidity(){const e=this.getIsValid(),t=this.computeIsValid();e!==t&&this.updateValidity(t)},updateValidity(e){this.setIsValid(e),I.setInteractionIsValidResponse({identifier:this.responseIdentifier,isValidResponse:e})},checkMaxChoicesLimit(){if(this.isRadio||this.maxChoices==0)return!1;const e=this.getResponse();return e!==null&&e.length==this.maxChoices?(I.NotifyInteractionSelectionsLimit(this.maxSelectionsMessage),!0):!1},computeMaxSelectionsMessage(){if(typeof this.dataMaxSelectionsMessage<"u"){this.maxSelectionsMessage=this.dataMaxSelectionsMessage;return}this.maxSelectionsMessage=this.maxChoices==0?"":"You are permitted a maximum of "+this.maxChoices+" selection"+(this.maxChoices>1?"s":"")+" for this question.<br/><br/>Please unselect one of your selections before making another selection."},computeMinSelectionsMessage(){if(typeof this.dataMinSelectionsMessage<"u"){this.minSelectionsMessage=this.dataMinSelectionsMessage;return}this.minSelectionsMessage=this.minChoices==0?"":"You must make at least "+this.minChoices+" selection"+(this.minChoices>1?"s":"")+" for this question."},validateChildren(){},processChildren(){this.processBackgroundImage(),this.$.subTree.children[1].children[0].children.forEach(t=>{if(t.component!==null&&t.type.name==="QtiHotspotChoice"){const i=t.component.proxy;this.choices.push(i);const s=i.getShapeElement();s!==null&&(this.addHotspotListeners(s),this.shapeElements.push(s),this.$refs.overlay.appendChild(s))}}),this.processGroupUI(),this.priorState!==null&&this.restoreValue(this.priorState.value)},addHotspotListeners(e){e.addEventListener("click",this.handleHotspotClick),e.addEventListener("keydown",this.handleHotspotKeydown)},removeHotspotListeners(e){e.removeEventListener("click",this.handleHotspotClick),e.removeEventListener("keydown",this.handleHotspotKeydown)},handleHotspotClick(e){if(e.preventDefault(),this.isDisabled)return;const t=e.target.getAttribute("data-identifier"),i=this.findChoiceByIdentifier(t);this.isRadio?this.triggerChecked(e.target.getAttribute("data-identifier"),"true"):(this.toggleChecked(i,e.target),this.triggerChecked(t,i.getChecked()))},handleHotspotKeydown(e){const t=e.target.getAttribute("data-identifier"),i=this.findChoiceByIdentifier(t);switch(e.code){case"Space":case"Enter":if(e.stopPropagation(),e.preventDefault(),this.isDisabled||i==null)return;this.toggleChecked(i,e.target),this.triggerChecked(t,i.getChecked());break}},findChoiceByIdentifier(e){for(let t=0;t<this.choices.length;t++)if(this.choices[t].identifier===e)return this.choices[t];return null},toggleChecked(e,t){if(e.toggleChecked(),t===null)return;const i=t.getAttribute("aria-checked");t.setAttribute("aria-checked",i==="true"?"false":"true")},triggerChecked(e,t){const i=new CustomEvent("setChecked",{bubbles:!0,cancelable:!0,detail:{identifier:e,checked:t}});this.$refs.hotspotgroup.dispatchEvent(i)},setChoiceUnChecked(e,t){e.setChecked(!1),t.setAttribute("aria-checked","false");const i=e.getShapeColorProperties();t.setAttribute("fill",`${i.fillColor}`),t.setAttribute("fill-opacity",`${i.fillOpacity}`),t.setAttribute("opacity",`${i.unselectedOpacity}`),t.setAttribute("stroke",`${i.strokeColor}`),t.setAttribute("stroke-width",`${i.strokeWidth}`)},setChoiceChecked(e,t){e.setChecked(!0),t.setAttribute("aria-checked","true");const i=e.getShapeColorProperties();t.setAttribute("fill",`${i.fillColor}`),t.setAttribute("fill-opacity",`${i.fillOpacity}`),t.setAttribute("opacity",`${i.selectedOpacity}`),t.setAttribute("stroke",`${i.strokeColor}`),t.setAttribute("stroke-width",`${i.selectedStrokeWidth}`)},processGroupUI(){this.setResponse(null),this.setState(this.computeState()),this.setIsValid(this.computeIsValid())},processBackgroundImage(){let e=this.$refs.hotspotgroup.getElementsByTagName("object");if(e.length===0&&(e=this.$refs.hotspotgroup.getElementsByTagName("img")),e.length===0&&(e=this.$refs.hotspotgroup.getElementsByTagName("picture")),e.length!==1)throw new c("Hotspot interaction must have exactly one <img>, <object>, or <picture> node");this.backgroundImage=e[0],this.backgroundImage.setAttribute("draggable","false"),this.backgroundImageWidth=`${e[0].clientWidth}`,this.backgroundImageHeight=`${e[0].clientHeight}`,this.$refs.overlay.setAttribute("viewBox",`0 0 ${this.backgroundImageWidth} ${this.backgroundImageHeight}`),this.$refs.overlay.setAttribute("tabindex","-1"),this.$refs.overlay.setAttribute("role","application"),this.$refs.overlay.setAttribute("focusable","false"),this.$refs.hotspotgroup.setAttribute("style",`width:${e[0].clientWidth};height:${e[0].clientHeight}`)},getShapeColorProperties(){return this.shapeColorProperties},setShapeColorProperties(e){this.shapeColorProperties=e},getPriorState(e){const t=I.getItemContextStateVariable(e);if(t===null)return null;if(!("value"in t))throw new O('Hotspot Interaction State Invalid. "value" property not found.');if(!("state"in t))throw new O('Hotspot Interaction State Invalid. "state" property not found.');return t}},created(){try{this.responseDeclaration=vw.validateResponseIdentifierAttribute(I,this.responseIdentifier),this.presentationFactory=new w2(this.$.vnode.props.class),this.setShapeColorProperties(this.presentationFactory.getThemeColors()),this.validateChildren(),this.priorState=this.getPriorState(this.responseIdentifier),vw.validateMaxMinChoices(this.maxChoices,this.minChoices),this.isRadio=this.getCardinality()!=="multiple",this.hasPrompts=this.getPrompts(this.$slots).length>0,this.computeMinSelectionsMessage(),this.computeMaxSelectionsMessage()}catch(e){throw this.isQtiValid=!1,e.name==="QtiValidationException"?new c(e.message):e.name==="QtiParseException"?new ie(e.message):new Error(e.message)}},mounted(){if(this.isQtiValid)try{this.movePrompt(),this.processChildren(),I.defineInteraction({identifier:this.responseIdentifier,interactionType:"Hotspot",node:this,resetValue:this.resetValue,disable:this.disable,isValidResponse:this.getIsValid(),invalidResponseMessage:this.getInvalidResponseMessage(),maxSelectionsMessage:this.maxSelectionsMessage}),console.log("["+this.$options.name+"][Identifier]",this.responseIdentifier)}catch(e){throw this.isQtiValid=!1,console.log("["+this.$options.name+"][ValidationError]",e.name,e.message),new c(e.message)}},beforeUnmount(){this.shapeElements.forEach(e=>{this.removeHotspotListeners(e)})}},v2={ref:"root",class:"qti-hotspot-interaction"},E2={ref:"prompt",class:"qti-prompt-wrapper"},C2={ref:"overlay",class:"qti3-player-hotspot-overlay"};function T2(e,t,i,s,n,r){return l.openBlock(),l.createElementBlock("div",v2,[l.createElementVNode("div",E2,null,512),l.createElementVNode("div",{ref:"hotspotgroup","on:setChecked":t[0]||(t[0]=(...a)=>r.handleSetChecked&&r.handleSetChecked(...a)),class:"qti3-player-hotspot-group"},[l.renderSlot(e.$slots,"default"),(l.openBlock(),l.createElementBlock("svg",C2,null,512))],544)],512)}const S2=P(b2,[["render",T2]]);class x2{constructor(t,i,s){ee(this,"moduleAttribute","");ee(this,"modulesNode",null);ee(this,"itemPathUri","");ee(this,"modules",null);ee(this,"constants",{BASE_CONFIG:{waitSeconds:60,paths:{}}});return this.moduleAttribute=t,this.modulesNode=i,this.itemPathUri=s,this}async getConfiguration(t){this.setModules(this.getInteractionModules());let i=null;this.moduleAttribute.length>0&&this.modulesNode===null?i=await this.getConfigurationFromUrl(this.getModules()):i=await this.resolveModules(this.getModules()),t&&t(i)}async resolveModules(t){let i=null;if(t===null)return i;let s=this.constants.BASE_CONFIG;return s=await this.initBaseConfiguration(s,t),i=await this.resolvePrimaryConfigurationModules(s,t),i!==null||(i=await this.resolveSecondaryConfigurationModules(s,t)),i}async initBaseConfiguration(t,i){const s=`${this.getItemPathUri()}modules/module_resolution.js`;if(typeof i.primaryconfiguration>"u"&&typeof i.secondaryConfiguration>"u"){const n=await this.fetchDefaultModuleResolution(s,!1);if(n!==null)return n}return t}async resolvePrimaryConfigurationModules(t,i){let s=[];if(typeof i.primaryconfiguration>"u"){for(let o=0;o<i.module.length;o++){if(typeof i.module[o].primarypath>"u")return null;s.push(this.addPathJs(i.module[o].primarypath)),t.paths[i.module[o].id]=this.stripPathJs(i.module[o].primarypath)}return await this.resolveConfigurationModules(s)?t:null}const n=await this.fetchConfiguration(i.primaryconfiguration,!0,!0);if(n===null)return null;for(const a in n.paths)n.paths[a]=this.stripPathJs(n.paths[a]);for(let a=0;a<i.module.length;a++)typeof i.module[a].primarypath<"u"&&(n.paths[i.module[a].id]=this.stripPathJs(this.addPathJs(i.module[a].primarypath)));return await this.resolveConfigurationPathUrls(n.paths)?n:null}async resolveSecondaryConfigurationModules(t,i){let s=[];if(typeof i.secondaryconfiguration>"u"){for(let o=0;o<i.module.length;o++){if(typeof i.module[o].fallbackpath>"u")return null;s.push(this.addPathJs(i.module[o].fallbackpath)),t.paths[i.module[o].id]=this.stripPathJs(i.module[o].fallbackpath)}return await this.resolveConfigurationModules(s)?t:null}const n=await this.fetchConfiguration(i.secondaryconfiguration,!1,!0);if(n===null)return null;for(const a in n.paths)n.paths[a]=this.stripPathJs(n.paths[a]);for(let a=0;a<i.module.length;a++)typeof i.module[a].fallbackpath<"u"&&(n.paths[i.module[a].id]=this.stripPathJs(this.addPathJs(i.module[a].fallbackpath)));return await this.resolveConfigurationPathUrls(n.paths)?n:null}async resolveConfigurationPathUrls(t){let i=[];for(let n=0;n<t.length;n++)i.push(t[n]);return await this.resolveConfigurationModules(i)}async resolveConfigurationModules(t){return await Promise.all(t.map(s=>fetch(s).then(n=>{if(n.ok)return console.log("[PCI Parent] Module Loader Success:",s),n;throw new Error(s)}))).catch(s=>(console.log("[PCI Parent] Module Loader Failure:",s.message),null))!==null}async getConfigurationFromUrl(t){let i=null;return t===null||(typeof t.primaryconfiguration<"u"&&(i=await this.fetchConfiguration(t.primaryconfiguration,!0,!1)),i!==null)||typeof t.secondaryconfiguration<"u"&&(i=await this.fetchConfiguration(t.secondaryconfiguration,!1,!1)),i}async fetchConfiguration(t,i,s){try{const n=await fetch(t);if(!n.ok)throw new Error(`HTTP error: ${n.status}`);const r=await n.json();let a=r.paths;for(let o in a)a[o]!==null&&!a[o].startsWith("http")&&(s?a[o]=`${this.getConfigurationRelativePath(t)}${a[o]}`:a[o]=`${this.getItemPathUri()}${a[o]}`);return r}catch(n){return console.log((i?"Primary":"Fallback")+" Configuration Fetch error:",n),null}}async fetchDefaultModuleResolution(t,i){try{const s=await fetch(t);if(!s.ok)throw new Error(`HTTP error: ${s.status}`);const n=await s.json();let r=n.paths;for(let a in r)r[a]!==null&&!r[a].startsWith("http")&&(i?r[a]=`${this.getConfigurationRelativePath(t)}${r[a]}`:r[a]=`${this.getItemPathUri()}${r[a]}`);return n}catch(s){return console.log("module_resolution.js Fetch error:",s),null}}getItemPathUri(){return this.itemPathUri}getModules(){return this.modules}setModules(t){this.modules=t}getInteractionModules(){let t={};if(this.modulesNode===null)return t={primaryconfiguration:"modules/module_resolution.js",secondaryconfiguration:"modules/fallback_module_resolution.js"},this.addPackagePath(t);const i=this.modulesNode.getPrimaryConfiguration();i.length>0&&(t.primaryconfiguration=i);const s=this.modulesNode.getSecondaryConfiguration();s.length>0&&(t.secondaryconfiguration=s),t.module=[];let n=this.modulesNode.getModules();for(let r=0;r<n.length;r++){let a={id:n[r].getId()};n[r].getPrimaryPath().length>0&&(a.primarypath=n[r].getPrimaryPath()),n[r].getFallbackPath().length>0&&(a.fallbackpath=n[r].getFallbackPath()),t.module.push(a)}return this.addPackagePath(t)}addPackagePath(t){for(let s in{primaryconfiguration:"",secondaryconfiguration:""})s in t&&t[s]!==null&&!t[s].startsWith("http")&&(t[s]=this.getAbsolutePath(this.getItemPathUri(),t[s]));let i=t.module;if(i!=null)for(let s=0;s<i.length;s++){let n=i[s];for(let r in{primarypath:"",fallbackpath:""})r in n&&n[r]!==null&&!n[r].startsWith("http")&&(n[r]=this.getAbsolutePath(this.getItemPathUri(),n[r]))}return t}getAbsolutePath(t,i){let s=t.split("/"),n=i.split("/");s.pop();for(var r=0;r<n.length;r++)n[r]!="."&&(n[r]==".."?s.pop():s.push(n[r]));return s.join("/")}getConfigurationRelativePath(t){if(t===null||t.length===0)return"";const i=t.lastIndexOf("/");return i<0?"":t.substring(0,i+1)}stripPathJs(t){return t===null?null:t.endsWith(".js")?t.slice(0,t.lastIndexOf(".")):t}addPathJs(t){return t===null?null:t.length>0&&!t.endsWith(".js")?`${t}.js`:t}}const Wh=new F,kl=new te,I2={name:"QtiPortableCustomInteraction",props:{responseIdentifier:{required:!0,type:String},customInteractionTypeIdentifier:{required:!0,type:String},module:{required:!1,type:String,default:""},dataItemPathUri:{required:!1,type:String,default:""}},inheritAttrs:!0,data(){return{response:null,state:null,baseType:null,cardinality:null,isValidResponse:!0,isQtiValid:!0,hasPrompts:!1,pciModuleResolver:null,loadIframeHandler:null,renderer:"",classAttribute:"",properties:{},modulesNode:null,modules:null,configuration:null,templateVariables:[],contextVariables:[],stylesheets:[],catalogInfoNode:null,uniqueId:null,pciIframe:null,isReady:!1,initialWidth:0,priorState:null}},methods:{getResponse(){return this.response},setResponse(e){this.response=e},getState(){return this.state},setState(e){this.state=e},getStateRequest(){this.pciIframe.contentWindow.postMessage({message:"PciGetState_Request"},"*")},getIsValid(){return this.isValidResponse},setIsValid(e){this.isValidResponse=e},getInvalidResponseMessage(){return""},resetValue(){console.log("[ResetValue][identifier]",this.responseIdentifier),this.priorState=null},restoreValue(e,t){this.setResponse(e),this.setState(t)},getCardinality(){let e=I.getResponseDeclaration(this.responseIdentifier);return this.cardinality=e.cardinality,this.cardinality},getBaseType(){let e=I.getResponseDeclaration(this.responseIdentifier);return this.baseType=e.baseType,this.baseType},getPrompts(e){let t=[];return e.default().forEach(i=>{typeof i.type<"u"&&i.type.name==="QtiPrompt"&&t.push(i)}),t},movePrompt(){if(!this.hasPrompts)return;const e=this.$refs.root.querySelector(".qti-prompt");e!==null&&this.$refs.prompt.appendChild(e)},computeState(){return{}},computeIsValid(){return!0},evaluateValidity(){const e=this.getIsValid(),t=this.computeIsValid();e!==t&&this.updateValidity(t)},updateValidity(e){this.setIsValid(e),I.setInteractionIsValidResponse({identifier:this.responseIdentifier,isValidResponse:e})},validateChildren(){if(!this.$slots.default)return;let e=!1,t=!1,i=!1,s=!1,n=!1,r=!1,a=!1;this.$slots.default().forEach(o=>{if(Wh.isValidSlot(o)){if(o.type.name==="QtiPrompt"){if(t||i||s||n||r||a)throw new c("Invalid element order. qti-prompt must be the first element");if(!e)return e=!0;throw new c("Maximum of 1 qti-prompt element permitted")}if(o.type.name==="QtiInteractionModules"){if(t||s||n||r||a)throw new c("Invalid element order: qti-interaction-modules");if(!i)return i=!0;throw new c("Maximum of 1 qti-interaction-modules element permitted")}if(o.type.name==="QtiInteractionMarkup"){if(s||n||r||a)throw new c("Invalid element order: qti-interaction-markup");if(!t)return t=!0;throw new c("Maximum of 1 qti-interaction-markup element permitted")}if(o.type.name==="QtiTemplateVariable"){if(s||r||a)throw new c("Invalid element order: qti-template-variable");return n=!0}if(o.type.name==="QtiContextVariable"){if(r||a)throw new c("Invalid element order: qti-context-variable");return s=!0}if(o.type.name==="QtiStylesheet"){if(a)throw new c("Invalid element order: qti-stylesheet");return r=!0}if(o.type.name==="QtiCatalogInfo"){if(!a)return a=!0;throw new c("Maximum of 1 qti-catalog-info element permitted")}throw new c('Node is not permitted inside QtiPortableCustomInteraction: "'+o.type.name+'"')}})},processChildren(){const e=this.$.subTree.children[1].children[0].children;e!==null&&(e.forEach(t=>{if(t.component===null)return;const i=t.component.proxy;switch(t.type.name){case"QtiInteractionMarkup":this.markup=i.getMarkup();break;case"QtiInteractionModules":this.modulesNode=i;break;case"QtiTemplateVariable":this.templateVariables.push(i);break;case"QtiContextVariable":this.contextVariables.push(i);break;case"QtiStylesheet":this.stylesheets.push(i);break;case"QtiCatalogInfo":this.catalogInfoNode=i;break}}),this.priorState!==null&&this.restoreValue(this.priorState.value,this.priorState.state),this.initialWidth=this.$refs.root.clientWidth)},disable(){},enable(){},getPriorState(e){const t=I.getItemContextStateVariable(e);if(t===null)return null;if(!("value"in t))throw new O('PCI State Invalid. "value" property not found.');if(!("state"in t))throw new O('PCI State Invalid. "state" property not found.');return t},createId(){return"pci_"+Wh.randomString(5,"a")},initialize(){this.setProperties(this.getPciProperties()),this.pciModuleResolver=new x2(this.module,this.modulesNode,this.dataItemPathUri),this.pciModuleResolver.getConfiguration((function(e){this.setConfiguration(e),console.log("[PCI Parent] PCI Configuration:",e),e!==null&&this.loadPciIframe(this.initialWidth)}).bind(this))},loadPciIframe(e){const t=document.createElement("iframe");t.name=this.uniqueId,t.id=this.uniqueId,t.setAttribute("scrolling","no"),t.style.border="none",t.style.width=`${e}px`,t.addEventListener("load",this.loadIframeHandler),t.src=`${this.renderer}?identifier=${this.responseIdentifier}&uniqueId=${this.uniqueId}`,this.$refs.ic.appendChild(t)},handleLoadIframe(e){this.pciIframe=e.target},getItemPathUri(){return this.dataItemPathUri},getPciProperties(){let e=this.$refs.root;const t={};for(let i in e.dataset)i!=="uniqueId"&&(t[i]=kl.encodeBytesToBase64(e.dataset[i]));return t},getProperties(){return this.properties},setProperties(e){this.properties=e},getContextVariables(){let e={};for(let t=0;t<this.contextVariables.length;t++)e[this.contextVariables[t].getIdentifier()]=this.contextVariables[t].evaluate();return e},getTemplateVariables(){let e={};for(let t=0;t<this.templateVariables.length;t++)e[this.templateVariables[t].getIdentifier()]=this.templateVariables[t].evaluate();return e},getStylesheets(){let e=[];for(let t=0;t<this.stylesheets.length;t++){const i=this.stylesheets[t],s=kl.encodeBytesToBase64(i.getRawCss());e.push({href:i.getHref(),type:i.getType(),css:`${s}`})}return e},getCatalogInfo(){return this.catalogInfoNode},getModules(){return this.modules},setModules(e){this.modules=e},getConfiguration(){return this.configuration},setConfiguration(e){this.configuration=e},getClassAttribute(){return this.classAttribute},setClassAttribute(e){this.classAttribute=e},copyAttributes(e,t,i){return e.forEach(function(s){let n=s.replace("-","");t[n]=i.getAttribute(s)}),t},getResponseVariable(){let e=kl.valueToPciJson(this.getResponse(),this.baseType,this.cardinality),t={};return t[this.responseIdentifier]=e,t},pciInitialize(){let e={typeIdentifier:this.customInteractionTypeIdentifier,classAttribute:this.getClassAttribute(),markup:this.markup,properties:this.getProperties(),boundTo:this.getResponseVariable(),templateVariables:this.getTemplateVariables(),contextVariables:this.getContextVariables(),stylesheets:this.getStylesheets(),catalogInfo:this.getCatalogInfo(),module:this.module,modules:this.getModules(),moduleResolution:this.getConfiguration(),status:I.getItemLifecycleStatus()},t={message:"PciLoadInteraction",pci:JSON.stringify(e)};this.priorState!==null&&(t.state=JSON.stringify({response:kl.valueToPciJson(this.getResponse(),this.baseType,this.cardinality),state:this.getState()})),this.pciIframe.contentWindow.postMessage(t,"*")},pciResizeIframe(e,t){this.pciIframe!==null&&(this.pciIframe.style.height=`${e}px`,this.pciIframe.style.width=`${t}px`)},pciResizeIframeWidthToContainer(){this.pciIframe!==null&&(this.pciIframe.style.width=`${this.$refs.ic.clientWidth}px`)},pciSaveState(e){const t=JSON.parse(e);typeof t.response<"u"?this.setResponse(t.response):this.setResponse(null),typeof t.state<"u"?this.setState(t.state):this.setState(null),this.notifyInteractionStateReady()},pciSetReady(){this.isReady=!0},pciIsReady(){return this.pciIframe!==null&&this.isReady},notifyInteractionStateReady(){I.NotifyInteractionStateReady({identifier:this.responseIdentifier})}},created(){try{this.responseDeclaration=Wh.validateResponseIdentifierAttribute(I,this.responseIdentifier),this.validateChildren(),this.renderer=I.getPciContextRenderer(),this.loadIframeHandler=this.handleLoadIframe.bind(this);const e=typeof this.$.vnode.props.class<"u"?this.$.vnode.props.class:"";this.setClassAttribute(e),this.priorState=this.getPriorState(this.responseIdentifier),this.hasPrompts=this.getPrompts(this.$slots).length>0,this.cardinality=this.getCardinality(),this.baseType=this.getBaseType(),this.uniqueId=this.createId()}catch(e){throw this.isQtiValid=!1,e.name==="QtiValidationException"?new c(e.message):e.name==="QtiParseException"?new ie(e.message):new Error(e.message)}},mounted(){if(this.isQtiValid)try{this.movePrompt(),this.processChildren(),I.defineInteraction({identifier:this.responseIdentifier,interactionType:"PortableCustom",node:this,resetValue:this.resetValue,disable:this.disable,isValidResponse:this.getIsValid(),invalidResponseMessage:this.getInvalidResponseMessage(),maxSelectionsMessage:""}),this.initialize(),console.log("["+this.$options.name+"][Identifier]",this.responseIdentifier)}catch(e){throw this.isQtiValid=!1,console.log("["+this.$options.name+"][ValidationError]",e.name,e.message),new c(e.message)}},beforeUnmount(){this.pciIframe!==null&&this.pciIframe.removeEventListener("load",this.loadIframeHandler)}},_2={ref:"root",class:"qti-portable-custom-interaction"},V2={ref:"prompt",class:"qti-prompt-wrapper"},A2={ref:"pcigroup",class:"qti3-player-pci-group"},$2={ref:"ic",class:"qti3-player-pci-iframe-container"};function L2(e,t,i,s,n,r){return l.openBlock(),l.createElementBlock("div",_2,[l.createElementVNode("div",V2,null,512),l.createElementVNode("div",A2,[l.renderSlot(e.$slots,"default")],512),l.createElementVNode("div",$2,null,512)],512)}const M2=P(I2,[["render",L2]]),zh=new F,N2={name:"QtiSelectPointInteraction",props:{responseIdentifier:{required:!0,type:String},minChoices:{required:!1,type:String,default:"0"},maxChoices:{required:!1,type:String,default:"0"},dataMaxSelectionsMessage:{required:!1,type:String},dataMinSelectionsMessage:{required:!1,type:String}},data(){return{response:null,state:null,isValidResponse:!1,cardinality:"single",minSelectionsMessage:"",maxSelectionsMessage:"",responseDeclaration:null,pointElements:new Map,backgroundImage:null,backgroundImageWidth:"0",backgroundImageHeight:"0",bgImageProperties:null,overlayId:"",markerType:"default",isResponsive:!1,interactionClassAttribute:null,pointRadius:9,isSingle:!0,isDisabled:!1,isQtiValid:!0,hasPrompts:!1,priorState:null}},methods:{getResponse(){return this.response},setResponse(e){this.response=e},getState(){return this.state},setState(e){this.state=e},getIsValid(){return this.isValidResponse},setIsValid(e){this.isValidResponse=e},disable(){this.toggleDisablePoints(!0)},enable(){this.toggleDisablePoints(!1)},toggleDisablePoints(e){this.isDisabled=e},getInvalidResponseMessage(){return this.minSelectionsMessage},resetValue(){console.log("[ResetValue][identifier]",this.responseIdentifier),this.priorState=null,this.setResponse(null),this.deleteAllPoints(),this.setState(this.computeState()),this.updateValidity(this.computeIsValid())},restoreValue(e){if(e===null)return;e.state.points.forEach(i=>{this.restorePointElement(i)}),this.setState(e.state),this.setResponse(this.computeResponse()),this.updateValidity(this.computeIsValid())},getCardinality(){let e=I.getResponseDeclaration(this.responseIdentifier);return this.cardinality=typeof e<"u"?e.cardinality!=="multiple"?"single":"multiple":"single",this.cardinality},getPrompts(e){let t=[];return e.default&&e.default().forEach(i=>{typeof i.type<"u"&&i.type.name==="QtiPrompt"&&t.push(i)}),t},movePrompt(){if(!this.hasPrompts)return;const e=this.$refs.root.querySelector(".qti-prompt");e!==null&&this.$refs.prompt.appendChild(e)},computeResponse(){let e=this.isSingle?null:[];for(const t of this.pointElements.values()){const i=`${t.getAttribute("data-point")}`;this.isSingle?e=i:e.push(i)}return this.isSingle?e:e.length===0?null:e},computeState(){const e=[];for(const[t,i]of this.pointElements)e.push({id:t,marker:i.getAttribute("data-marker-type"),point:i.getAttribute("data-point"),static:i.getAttribute("class").includes("static")});return{points:e}},computeIsValid(){return this.minChoices*1===0?!0:this.response===null?!1:this.cardinality==="single"||this.cardinality==="multiple"&&this.response.length>=this.minChoices*1},evaluateValidity(){const e=this.getIsValid(),t=this.computeIsValid();e!==t&&this.updateValidity(t)},updateValidity(e){this.setIsValid(e),I.setInteractionIsValidResponse({identifier:this.responseIdentifier,isValidResponse:e})},checkMaxChoicesLimit(){return this.isSingle&&this.pointElements.size==0||!this.isSingle&&this.maxChoices==0||!this.isSingle&&this.pointElements.size<this.maxChoices?!1:(I.NotifyInteractionSelectionsLimit(this.maxSelectionsMessage),!0)},computeMaxSelectionsMessage(){if(typeof this.dataMaxSelectionsMessage<"u"){this.maxSelectionsMessage=this.dataMaxSelectionsMessage;return}this.maxSelectionsMessage=this.maxChoices==0?"":"You are permitted a maximum of "+this.maxChoices+" point"+(this.maxChoices>1?"s":"")+" for this question.<br/><br/>Please remove one of your points before making another point."},computeMinSelectionsMessage(){if(typeof this.dataMinSelectionsMessage<"u"){this.minSelectionsMessage=this.dataMinSelectionsMessage;return}this.minSelectionsMessage=this.minChoices==0?"":"You must make at least "+this.minChoices+" point"+(this.minChoices>1?"s":"")+" for this question."},createId(e){return`${e}${zh.randomString(5,"a")}`},processChildren(){this.processBackgroundImage(),this.processGroupUI(),this.priorState!==null&&this.restoreValue(this.priorState)},addPointFromClick(e){const t=this.createId("p_"),i=this.createPointElement(e,this.markerType,t);this.addPointListeners(i),this.pointElements.set(t,i),this.$refs.overlay.appendChild(i),this.setState(this.computeState()),this.setResponse(this.computeResponse()),this.evaluateValidity()},deleteAllPoints(){for(const[e,t]of this.pointElements.values())this.deletePoint(e,t)},deletePoint(e,t){this.removePointListeners(t),this.pointElements.delete(e),t.remove()},createPointElement(e,t,i){const s=this.convertPoint(e.x,e.y,!1);return this.newPointElement(i,e,s,t,!0)},restorePointElement(e){const t=e.point.split(" ");if(t.length!==2)return;const i=this.convertPoint(t[0],t[1],!0),s={x:t[0],y:t[1]},n=this.newPointElement(e.id,i,s,e.marker,e.static);this.addPointListeners(n),this.pointElements.set(e.id,n),this.$refs.overlay.appendChild(n)},convertPoint(e,t,i){const s=this.getScalingFactor();let n,r;return i?(n=Math.round(e/s),r=Math.round(t/s)):(n=Math.round(e*s),r=Math.round(t*s)),n<0&&(n=0),n>this.bgImageProperties.w&&(n=this.bgImageProperties.w),r<0&&(r=0),r>this.bgImageProperties.h&&(r=this.bgImageProperties.h),{x:n,y:r}},getScalingFactor(){return this.isResponsive?this.bgImageProperties.w/this.backgroundImageWidth:1},newPointElement(e,t,i,s,n){const r=document.createElementNS("http://www.w3.org/2000/svg","circle");return r.setAttribute("cx",t.x),r.setAttribute("cy",t.y),r.setAttribute("r",this.pointRadius),s==="default-light"?(r.setAttribute("fill","orange"),r.setAttribute("fill-opacity",".5"),r.setAttribute("stroke","orange")):(r.setAttribute("fill","#0088CC"),r.setAttribute("fill-opacity",".5"),r.setAttribute("stroke","blue")),r.setAttribute("opacity","1"),r.setAttribute("stroke-width","1"),r.setAttribute("data-marker-type",s),r.setAttribute("id",`${e}`),r.setAttribute("class",`qti3-player-select-point ${n?"static":""}`),r.setAttribute("tabindex","0"),r.setAttribute("data-point",`${i.x} ${i.y}`),r},handleOverlayClick(e){e.preventDefault(),this.checkMaxChoicesLimit()||this.addPointFromClick(this.getMousePosition(e))},handlePointClick(e){if(e.preventDefault(),e.stopPropagation(),this.isDisabled)return;const t=e.target,i=t.getAttribute("id");this.deletePoint(i,t),this.setState(this.computeState()),this.setResponse(this.computeResponse()),this.evaluateValidity()},getMousePosition(e){const t=this.$refs.overlay.getScreenCTM();e.touches&&(e=e.touches[0]);const i=(e.clientX-t.e)/t.a,s=(e.clientY-t.f)/t.d;return{x:i,y:s}},processGroupUI(){this.setResponse(null),this.setState(this.computeState()),this.setIsValid(this.computeIsValid())},processBackgroundImage(){if(this.bgImageProperties=this.computeBackgroundImageProperties(),this.bgImageProperties===null)throw new c("Select Point interaction must have exactly one <img>, <object>, or <picture> node");this.isResponsive?(this.backgroundImageWidth=`${this.bgImageProperties.element.offsetWidth}`,this.backgroundImageHeight=`${this.bgImageProperties.element.offsetHeight}`):(this.backgroundImageWidth=`${this.bgImageProperties.w}`,this.backgroundImageHeight=`${this.bgImageProperties.h}`,this.$refs.selectpointgroup.setAttribute("style",`width:${this.backgroundImageWidth};height:${this.backgroundImageHeight}`)),this.overlayId=this.createId("spi_"),this.$refs.overlay.setAttribute("id",this.overlayId),this.$refs.overlay.setAttribute("width",`${this.backgroundImageWidth}`),this.$refs.overlay.setAttribute("height",`${this.backgroundImageHeight}`),this.$refs.overlay.setAttribute("viewBox",`0 0 ${this.backgroundImageWidth} ${this.backgroundImageHeight}`),this.$refs.overlay.setAttribute("tabindex","-1"),this.$refs.overlay.setAttribute("role","application"),this.$refs.overlay.setAttribute("focusable","false"),this.createSvgImage(this.bgImageProperties,this.backgroundImageWidth,this.backgroundImageHeight),this.addOverlayListeners()},handleResize(){this.backgroundImageWidth=this.$refs.overlay.parentNode.offsetWidth,this.backgroundImageHeight=this.$refs.overlay.parentNode.offsetHeight,this.$refs.overlay.setAttribute("width",`${this.backgroundImageWidth}`),this.$refs.overlay.setAttribute("height",`${this.backgroundImageHeight}`)},computeBackgroundImageProperties(){let e=this.$refs.selectpointgroup.getElementsByTagName("img");if(e.length===1){const t=e[0].getAttribute("width"),i=e[0].getAttribute("height");return this.createImageProperties(e[0],e[0].src,"img",t,i)}if(e=this.$refs.selectpointgroup.getElementsByTagName("object"),e.length===1){const t=e[0].getAttribute("width"),i=e[0].getAttribute("height");return this.createImageProperties(e[0],e[0].data,"object",t,i)}return null},createImageProperties(e,t,i,s,n){let r=s===null||n===null?1:s/n;return{element:e,src:t,tag:i,w:s,h:n,ar:r}},createSvgImage(e,t,i){let s=document.createElementNS("http://www.w3.org/2000/svg","image");s.setAttribute("href",e.src),s.setAttribute("width",t),s.setAttribute("height",i),s.setAttribute("draggable",!1),this.$refs.overlay.appendChild(s),e.element.remove()},addOverlayListeners(){this.$refs.overlay.addEventListener("click",this.handleOverlayClick.bind(this))},removeOverlayListeners(){this.$refs.overlay.removeEventListener("click",this.handleOverlayClick)},addPointListeners(e){e.addEventListener("click",this.handlePointClick.bind(this))},removePointListeners(e){e.removeEventListener("click",this.handlePointClick)},processClassAttribute(e){if(typeof e>"u"||e===null||e.length==0)return;const t=e.split(" ");for(let i=0;i<t.length;i++)switch(t[i]){case"responsive":this.isResponsive=!0;break;case"marker-crosshair":this.markerType="crosshair";break;case"marker-default":this.markerType="default";break;case"marker-default-light":this.markerType="default-light";break}},getPriorState(e){const t=I.getItemContextStateVariable(e);if(t===null)return null;if(!("value"in t))throw new O('Select Point Interaction State Invalid. "value" property not found.');if(!("state"in t))throw new O('Select Point Interaction State Invalid. "state" property not found.');if(!("points"in t.state))throw new O('Select Point Interaction State Invalid. "points" property not found in State.');return t}},created(){try{if(this.responseDeclaration=zh.validateResponseIdentifierAttribute(I,this.responseIdentifier),this.processClassAttribute(this.$.vnode.props.class),this.priorState=this.getPriorState(this.responseIdentifier),zh.validateMaxMinChoices(this.maxChoices,this.minChoices),this.isSingle=this.getCardinality()!=="multiple",this.isSingle&&this.maxChoices!=1)throw new c('Invalid qti-select-point-interaction. cardinality: "single", max-choices attribute: "'+this.maxChoices+'"');this.hasPrompts=this.getPrompts(this.$slots).length>0,this.computeMinSelectionsMessage(),this.computeMaxSelectionsMessage()}catch(e){throw this.isQtiValid=!1,e.name==="QtiValidationException"?new c(e.message):e.name==="QtiParseException"?new ie(e.message):new Error(e.message)}},mounted(){if(this.isQtiValid)try{this.movePrompt(),this.processChildren(),I.defineInteraction({identifier:this.responseIdentifier,interactionType:"SelectPoint",node:this,resetValue:this.resetValue,disable:this.disable,isValidResponse:this.getIsValid(),invalidResponseMessage:this.getInvalidResponseMessage(),maxSelectionsMessage:this.maxSelectionsMessage}),console.log("["+this.$options.name+"][Identifier]",this.responseIdentifier)}catch(e){throw this.isQtiValid=!1,console.log("["+this.$options.name+"][ValidationError]",e.name,e.message),new c(e.message)}},beforeUnmount(){this.removeOverlayListeners();for(const e of this.pointElements.values())this.removePointListeners(e)}},R2={ref:"root",class:"qti-select-point-interaction"},k2={ref:"prompt",class:"qti-prompt-wrapper"},q2={ref:"selectpointgroup",class:"select-point-group"},O2={ref:"overlay",class:"select-point-overlay"};function P2(e,t,i,s,n,r){return l.openBlock(),l.createElementBlock("div",R2,[l.createElementVNode("div",k2,null,512),l.createElementVNode("div",q2,[l.renderSlot(e.$slots,"default"),(l.openBlock(),l.createElementBlock("svg",O2,null,512))],512)],512)}const B2=P(N2,[["render",P2]]),D2={name:"QtiPrompt"},Q2={class:"qti-prompt"};function H2(e,t,i,s,n,r){return l.openBlock(),l.createElementBlock("div",Q2,[l.renderSlot(e.$slots,"default")])}const F2=P(D2,[["render",H2]]),U2=new F,G2={name:"QtiInlineChoice",props:{identifier:{required:!0,type:String},fixed:{required:!1,type:String,default:"false"},templateIdentifier:{required:!1,type:String},showHide:{required:!1,type:String,default:"show"}},data(){return{id:null}},inheritAttrs:!0,methods:{createId(){if(this.$refs.choice.hasAttribute("id")){this.id=this.$refs.choice.getAttribute("id");return}this.id="inlinechoice_"+U2.randomString(5,"a")+"_"+this.identifier,this.$refs.choice.setAttribute("id",this.id)}},created(){},mounted(){this.createId()}},j2=["data-identifier"];function W2(e,t,i,s,n,r){return l.openBlock(),l.createElementBlock("li",{ref:"choice",role:"option","data-identifier":i.identifier,class:"qti-inline-choice"},[l.renderSlot(e.$slots,"default")],8,j2)}const z2=P(G2,[["render",W2]]),K2=new F,Y2={name:"QtiSimpleChoice",emits:["setChecked","setFocusPreviousChoice","setFocusNextChoice","setActiveDescendant"],props:{identifier:{required:!0,type:String},fixed:{required:!1,type:String,default:"false"},templateIdentifier:{required:!1,type:String},showHide:{required:!1,type:String,default:"show"}},data(){return{id:null,checked:"false",isRadio:!0,role:"radio",tabIndex:"-1",hasMath:!1,isDisabled:!1,parentCardinality:"single"}},inheritAttrs:!0,methods:{handleClick(){if(!this.isDisabled)if(this.isRadio)this.$parent.$emit("setChecked",{identifier:this.identifier,checked:"true"});else{if(this.toggleChecked(),this.parentCardinality==="ordered")return;this.$parent.$emit("setChecked",{identifier:this.identifier,checked:this.checked})}},handleKeydown(e){let t=!1;switch(e.code){case"Space":if(!this.isDisabled){if(this.toggleChecked(),this.parentCardinality==="ordered")return;this.$parent.$emit("setChecked",{identifier:this.identifier,checked:this.checked})}t=!0;break;case"Enter":if(!this.isDisabled){if(this.toggleChecked(),this.parentCardinality==="ordered")return;this.$parent.$emit("setChecked",{identifier:this.identifier,checked:this.checked})}t=!0;break;case"ArrowUp":case"ArrowLeft":this.isRadio&&(this.$parent.$emit("setFocusPreviousChoice",this.identifier),t=!0);break;case"ArrowDown":case"ArrowRight":this.isRadio&&(this.$parent.$emit("setFocusNextChoice",this.identifier),t=!0);break}t&&(e.stopPropagation(),e.preventDefault())},handleFocus(){this.parentCardinality!=="ordered"&&this.$parent.$emit("setActiveDescendant",this.id)},handleBlur(){},setChecked(e){this.checked=e?"true":"false"},isChecked(){return this.checked==="true"},setTabIndex(e){this.tabIndex=e},setFocus(){this.$refs.choice.focus()},setBlur(){this.$refs.choice.blur()},toggleChecked(){this.checked=this.checked==="true"?"false":"true"},setLabel(e){this.$refs.label.innerText=e},hideLabel(){this.$refs.label.classList.add("qti-hidden")},showLabel(){this.$refs.label.classList.remove("qti-hidden")},setLabelSbac(e){this.$refs.choice.classList.add("sbac"),this.$refs.choice.setAttribute("data-label",e),this.$refs.label.innerText=e,this.$refs.label.classList.add("qti-visually-hidden")},setChoiceLrn(){this.$refs.choice.classList.add("lrn")},hideControl(){this.$refs.choice.classList.add("control-hidden")},setIsDisabled(e){this.isDisabled=e},initializeChoice(){switch(this.parentCardinality=this.$parent.cardinality,this.parentCardinality){case"ordered":this.role="button",this.isRadio=!1,this.tabIndex=0;break;case"multiple":this.role="checkbox",this.isRadio=!1,this.tabIndex=0;break;default:this.role="radio",this.isRadio=!0,this.tabIndex=-1;break}},initializeOrderChoice(){this.role==="button"&&(this.hideLabel(),this.hideControl())},createId(){if(this.$refs.choice.hasAttribute("id")){this.id=this.$refs.choice.getAttribute("id");return}this.id="choice_"+K2.randomString(5,"a")+"_"+this.identifier,this.$refs.choice.setAttribute("id",this.id)},setExpectedSolution(){this.$refs.choice.classList.add("player-show-solution","player-choice-expected")},setCorrectSolution(){this.$refs.choice.classList.add("player-show-solution","player-choice-correct")},setIncorrectSolution(){this.$refs.choice.classList.add("player-show-solution","player-choice-incorrect")},setIgnoreSolution(){this.$refs.choice.classList.remove("player-show-solution","player-choice-incorrect","player-choice-correct","player-choice-expected")}},created(){this.initializeChoice()},mounted(){this.initializeOrderChoice(),this.createId()}},X2=["role","aria-checked","tabindex","data-identifier"],Z2={ref:"label",class:"qti-choice-label"},J2={ref:"description",class:"qti-choice-description"};function eq(e,t,i,s,n,r){return l.openBlock(),l.createElementBlock("li",{ref:"choice",role:n.role,"aria-checked":n.checked,tabindex:n.tabIndex,"data-identifier":i.identifier,onFocus:t[0]||(t[0]=(...a)=>r.handleFocus&&r.handleFocus(...a)),onBlur:t[1]||(t[1]=(...a)=>r.handleBlur&&r.handleBlur(...a)),onClick:t[2]||(t[2]=(...a)=>r.handleClick&&r.handleClick(...a)),onKeydown:t[3]||(t[3]=(...a)=>r.handleKeydown&&r.handleKeydown(...a)),class:l.normalizeClass(["qti-simple-choice",{source:n.role=="button"}])},[l.createElementVNode("div",{class:l.normalizeClass(["qti-simple-choice-wrapper",{draggable:n.role=="button"}]),style:{width:"100%"}},[l.createElementVNode("div",Z2,null,512),l.createElementVNode("div",J2,[l.renderSlot(e.$slots,"default")],512)],2)],42,X2)}const tq=P(Y2,[["render",eq]]),iq=new F,sq={name:"QtiSimpleAssociableChoice",props:{identifier:{required:!0,type:String},fixed:{required:!1,type:String,default:"false"},templateIdentifier:{required:!1,type:String},showHide:{required:!1,type:String,default:"show"},matchGroup:{required:!1,type:String,default:""},matchMax:{required:!0,type:String},matchMin:{required:!1,type:String,default:"0"}},data(){return{id:null}},methods:{createId(){if(this.$refs.choice.hasAttribute("id")){this.id=this.$refs.choice.getAttribute("id");return}this.id="choice_"+iq.randomString(5,"a")+"_"+this.identifier,this.$refs.choice.setAttribute("id",this.id)}},mounted(){this.createId()}},nq=["data-identifier","data-match-max","data-match-min","data-match-group"],rq={ref:"description",class:"choice-description"};function aq(e,t,i,s,n,r){return l.openBlock(),l.createElementBlock("li",{ref:"choice","data-identifier":i.identifier,"data-match-max":i.matchMax,"data-match-min":i.matchMin,"data-match-group":i.matchGroup,class:"qti-simple-associable-choice"},[l.createElementVNode("div",rq,[l.renderSlot(e.$slots,"default")],512)],8,nq)}const oq=P(sq,[["render",aq]]),lq=new F,cq={name:"QtiAssociableHotspot",props:{identifier:{required:!0,type:String},templateIdentifier:{required:!1,type:String},showHide:{required:!1,type:String,default:"show"},matchGroup:{required:!1,type:String,default:""},shape:{required:!0,type:String},coords:{required:!0,type:String},hotspotLabel:{required:!1,type:String,default:""},ariaLabel:{required:!1,type:String,default:""},matchMax:{required:!0,type:String},matchMin:{required:!1,type:String,default:"0"}},data(){return{shapeData:null,shapeColorProperties:null,isQtiValid:!0}},inheritAttrs:!0,methods:{getIdentifier(){return this.identifier},getShape(){return this.shape},getShapeData(){return this.shapeData},setShapeData(){const e=this.coords.split(",");switch(this.getShape()){case"circle":if(e.length!=3)return;this.shapeData=e;return;case"rect":if(e.length!==4)return;e[2]=parseInt(e[2])-parseInt(e[0]),e[3]=parseInt(e[3])-parseInt(e[1]),this.shapeData=e;return;case"poly":this.shapeData=this.transformPolyCoords(e);return;case"ellipse":if(e.length!=4)return;this.shapeData=e;return;case"default":this.shapeData="";return}},transformPolyCoords(e){let t=[];if(e.length%2!=0)return t;for(let i=0;i<e.length;i+=2)t.push(`${e[i]} ${e[i+1]}`);return t},initialize(){lq.validateShapeAttribute(this.shape),this.setShapeData()}},created(){try{this.initialize()}catch(e){if(this.isQtiValid=!1,e.name==="QtiValidationException")throw new c(e.message)}},mounted(){if(this.isQtiValid)try{console.log("["+this.$options.name+"][Identifier]",this.identifier)}catch(e){throw this.isQtiValid=!1,console.log("["+this.$options.name+"][ValidationError]",e.name,e.message),new c(e.message)}}},uq=["data-identifier","data-match-max","data-match-min","data-match-group"];function hq(e,t,i,s,n,r){return l.openBlock(),l.createElementBlock("div",{ref:"gap","data-identifier":i.identifier,"data-match-max":i.matchMax,"data-match-min":i.matchMin,"data-match-group":i.matchGroup,class:"ggm-gap"},null,8,uq)}const dq=P(cq,[["render",hq]]),fq=new F,pq=new te,mq={name:"QtiSimpleMatchSet",data(){return{choices:[],isShuffle:!1,isQtiValid:!0}},methods:{getChoices(){return this.choices},setIsShuffle(e){this.isShuffle=e},createContainer(e,t){let i=[];return e===null?(this.choices.forEach(n=>{i.push({fixed:n.fixed==="true",node:n})}),this.isShuffle&&pq.shuffleArrayFixed(i),i):(e.state.orders[t].forEach(n=>{const r=this.findChoiceByIdentifier(n,this.choices);r!==null&&i.push({fixed:r.fixed==="true",node:r})},this),i)},processContainerChoices(e){this.choices.splice(0,this.choices.length),this.$refs.matchset.innerHTML="",e.forEach(t=>{this.$refs.matchset.appendChild(t.node.$el),this.choices.push(t.node)},this)},validateChildren(){let e=0;if(!this.$slots.default)throw new c("Must have at least 1 qti-simple-associable-choice");if(this.$slots.default().forEach(t=>{if(fq.isValidSlot(t)){if(t.type.name==="QtiSimpleAssociableChoice")return e+=1;throw new c('Node is not a qti-simple-associable-choice: "'+t.type.name+'"')}}),e===0)throw new c("Must have at least 1 qti-simple-associable-choice")},processChildren(){this.$.subTree.children[0].children.forEach(t=>{t.component!==null&&this.choices.push(t.component.proxy)})},findChoiceByIdentifier(e,t){for(let i=0;i<t.length;i++)if(t[i].$el.getAttribute("data-identifier")===e)return t[i];throw new O('Match Interaction State Invalid. Choice identifier "'+e+'" not found.')}},created(){try{this.validateChildren()}catch(e){throw this.isQtiValid=!1,e.name==="QtiValidationException"?new c(e.message):new Error(e.message)}},mounted(){if(this.isQtiValid)try{this.processChildren(),console.log("["+this.$options.name+"]")}catch(e){throw this.isQtiValid=!1,console.log("["+this.$options.name+"][ValidationError]",e.name,e.message),new c(e.message)}}},gq={ref:"matchset",class:"qti-simple-match-set"};function yq(e,t,i,s,n,r){return l.openBlock(),l.createElementBlock("ul",gq,[l.renderSlot(e.$slots,"default")],512)}const wq=P(mq,[["render",yq]]);class bq{constructor(t){this.constants={QTI_CHOICES_TOP:"qti-choices-top",QTI_CHOICES_BOTTOM:"qti-choices-bottom",QTI_CHOICES_LEFT:"qti-choices-left",QTI_CHOICES_RIGHT:"qti-choices-right",DATA_MAX_SELECTIONS_MESSAGE:"data-max-selections-message",DATA_MIN_SELECTIONS_MESSAGE:"data-min-selections-message",DATA_CHOICES_CONTAINER_WIDTH:null},this.parentClass=t,this.clazzTokens=[],this.gapMatchGroupElement=null,this.gapChoiceWrapperElement=null,this.gapTargetWrapperElement=null,this.choicesContainerWidth=null,this.gapChoices=[],this.gaps=[],this.presentation_Choices_Orientation=null,this.presentation_MaxSelectionsMessage="",this.presentation_MinSelectionsMessage=""}initialize(t,i,s,n,r,a){this.gapMatchGroupElement=t,this.gapChoiceWrapperElement=i,this.gapTargetWrapperElement=s,this.choicesContainerWidth=n,this.gapChoices=r,this.gaps=a,this.processRootClassAttribute(this.parentClass),this.processPresentation()}processRootClassAttribute(t){const i=t.split(" ");for(let s=0;s<i.length;s++)switch(i[s]){case this.constants.QTI_CHOICES_TOP:case this.constants.QTI_CHOICES_BOTTOM:case this.constants.QTI_CHOICES_LEFT:case this.constants.QTI_CHOICES_RIGHT:this.presentation_Choices_Orientation=i[s];break}this.clazzTokens=i}processPresentation(){this.presentation_Choices_Orientation===null&&(this.presentation_Choices_Orientation=this.constants.QTI_CHOICES_TOP),this.presentation_Choices_Orientation===this.constants.QTI_CHOICES_LEFT?(this.gapChoiceWrapperElement.classList.add(this.constants.QTI_CHOICES_LEFT),this.gapTargetWrapperElement.classList.add(this.constants.QTI_CHOICES_LEFT),this.gapMatchGroupElement.classList.add(this.constants.QTI_CHOICES_LEFT)):this.presentation_Choices_Orientation===this.constants.QTI_CHOICES_TOP?(this.gapChoiceWrapperElement.classList.add(this.constants.QTI_CHOICES_TOP),this.gapTargetWrapperElement.classList.add(this.constants.QTI_CHOICES_TOP)):this.presentation_Choices_Orientation===this.constants.QTI_CHOICES_RIGHT?(this.gapChoiceWrapperElement.classList.add(this.constants.QTI_CHOICES_RIGHT),this.gapTargetWrapperElement.classList.add(this.constants.QTI_CHOICES_RIGHT),this.gapMatchGroupElement.classList.add(this.constants.QTI_CHOICES_RIGHT),this.gapMatchGroupElement.insertBefore(this.gapTargetWrapperElement,this.gapChoiceWrapperElement)):this.presentation_Choices_Orientation===this.constants.QTI_CHOICES_BOTTOM&&(this.gapChoiceWrapperElement.classList.add(this.constants.QTI_CHOICES_BOTTOM),this.gapTargetWrapperElement.classList.add(this.constants.QTI_CHOICES_BOTTOM),this.gapMatchGroupElement.insertBefore(this.gapTargetWrapperElement,this.gapChoiceWrapperElement)),this.processChoicesContainerWidth(),this.processGaps()}processChoicesContainerWidth(){this.choicesContainerWidth!==null&&(this.gapChoiceWrapperElement.style.width=`${this.choicesContainerWidth}px`)}processGaps(){for(let t=0;t<this.gaps.length;t++)this.gaps[t].classList.add("target")}}class vq{constructor(t,i){ee(this,"options",{interactionSubType:"default",cardinality:"single",maxAssociations:0,response:null,onReady:null,onUpdate:null,onSelectionsLimit:null});return this.qtiAttributeValidation=new F,this.wrapper=t,this.sourcewrapper=this.wrapper.querySelector(".qti-gap-match-source-wrapper"),this.targetwrapper=this.wrapper.querySelector(".qti-gap-match-target-wrapper"),this.processOptions(i),this.handleDragStart=this.handleDragStart.bind(this),this.handleDragMove=this.handleDragMove.bind(this),this.handleDragEnd=this.handleDragEnd.bind(this),this.handleTouchStart=this.handleTouchStart.bind(this),this.handleTouchMove=this.handleTouchMove.bind(this),this.handleTouchEnd=this.handleTouchEnd.bind(this),this.itemTarget=null,this.itemStart=null,this.isItemStartSource=!0,this.initialX=0,this.initialY=0,this.offsetX=0,this.offsetY=0,this.startingX=0,this.startingY=0,this.currentAssociationsCount=0,this.isDisabled=!1,this.currentDragger=null,this.initializeSources(this.sourcewrapper),this.initializeTargets(this.targetwrapper),this.restoreResponse(this.options.response),this.notifyReady(),this}processOptions(t){"interactionSubType"in t&&(this.options.interactionSubType=t.interactionSubType),"cardinality"in t&&(this.options.cardinality=t.cardinality),"response"in t&&(this.options.response=t.response),"maxAssociations"in t&&(this.options.maxAssociations=t.maxAssociations),"onReady"in t&&(this.options.onReady=t.onReady),"onUpdate"in t&&(this.options.onUpdate=t.onUpdate),"onAssociationsLimit"in t&&(this.options.onAssociationsLimit=t.onAssociationsLimit)}notifyReady(){this.options.onReady!==null&&this.options.onReady({response:this.getResponse()})}notifyUpdate(){this.options.onUpdate!==null&&this.options.onUpdate({response:this.computeResponse()})}notifyAssociationsLimit(){this.options.onAssociationsLimit!==null&&this.options.onAssociationsLimit()}toggleDisable(t){this.isDisabled=t,this.draggers.forEach(i=>{t?i.classList.add("disabled"):i.classList.remove("disabled")})}handleDragStart(t){if(t.preventDefault(),!this.isDisabled&&t.button==0)return this.interactionStart(t.target,t.clientX,t.clientY,!1),!1}handleTouchStart(t){if(t.preventDefault(),!this.isDisabled)return t.targetTouches.length!=1||this.interactionStart(t.target,t.touches[0].pageX,t.touches[0].pageY,!0),!1}interactionStart(t,i,s,n){const r=this.getClosestElement(t,"draggable");this.itemStart=r.parentNode,this.isItemStartSource=this.itemStart.classList.contains("source"),this.identifyTargets(this.itemStart,!0),this.itemTarget=null;const a=r.getBoundingClientRect();this.initialX=i,this.initialY=s,this.startingX=a.left,this.startingY=a.top,this.offsetX=i-this.startingX,this.offsetY=s-this.startingY,this.addPlaceholder(r),r.style.userSelect="none",r.style.width=a.width+"px",r.style.height=a.height+"px",r.style.transform=`translateX(${a.left}px) translateY(${a.top}px) translateZ(0)`,r.classList.add("dragging"),this.setCurrentDragger(r),this.addListeners(r,n)}handleDragMove(t){t.preventDefault(),!this.isDisabled&&this.interactionMove(t.clientX,t.clientY)}handleTouchMove(t){t.preventDefault(),!this.isDisabled&&t.targetTouches.length==1&&this.interactionMove(t.touches[0].clientX,t.touches[0].clientY)}interactionMove(t,i){const s=this.currentDragger;this.offsetX=t-this.initialX,this.offsetY=i-this.initialY,this.constrainDraggerToWrapper(s,this.wrapper),s.style.transform=`translateX(${this.startingX+this.offsetX}px) translateY(${this.startingY+this.offsetY}px) translateZ(0) scale(1)`;const n=s.getBoundingClientRect();this.findDraggerItemTarget(s,n,this.targets),this.isItemStartSource||this.findSourceDraggerTarget(s,n)}constrainDraggerToWrapper(t,i){const s=t.getBoundingClientRect(),n=i.getBoundingClientRect(),r=this.startingX+this.offsetX-n.x,a=this.startingY+this.offsetY-n.y,o=this.startingX+s.width+this.offsetX-(n.x+n.width),u=this.startingY+s.height+this.offsetY-(n.y+n.height);r<0&&(this.offsetX=this.offsetX-r),o>0&&(this.offsetX=this.offsetX-o),a<0&&(this.offsetY=this.offsetY-a),u>0&&(this.offsetY=this.offsetY-u)}handleDragEnd(t){this.isDisabled||this.interactionEnd(t.clientX,t.clientY,!1)}handleTouchEnd(t){this.isDisabled||this.interactionEnd(t.changedTouches[0].clientX,t.changedTouches[0].clientY,!0)}interactionEnd(t,i,s){const n=this.currentDragger;if(this.itemTarget===null?n.style.transform=`translateX(${this.startingX}px) translateY(${this.startingY}px) translateZ(0)`:n.style.transform=`translateX(${this.startingX+this.offsetX}px) translateY(${this.startingY+this.offsetY}px) translateZ(0)`,n.removeAttribute("style"),n.classList.remove("dragging"),this.clearTargetHighlights(),this.itemTarget===null){this.resetDraggerToItemStart(this.itemStart,n),this.setCurrentDragger(null),this.removeListeners(n,s);return}if(this.itemTarget.classList.contains("active")){if(this.itemTarget.classList.remove("active"),this.isExceedingMaxAssociations(this.itemStart,this.itemTarget,n)){this.resetDraggerToItemStart(this.itemStart,n),this.notifyAssociationsLimit(),this.setCurrentDragger(null),this.removeListeners(n,s);return}if(this.itemStart.getAttribute("data-identifier")===this.itemTarget.getAttribute("data-identifier")){this.resetDraggerToItemStart(this.itemStart,n),this.setCurrentDragger(null),this.removeListeners(n,s);return}this.removePlaceholder(n),this.setDraggerToItemTarget(this.itemTarget,n),this.itemTarget.classList.contains("source")&&(this.itemTarget.classList.add("full"),this.itemTarget.dataset.matchMax*1>0&&this.incrementRemaining(this.itemTarget),this.decrementAssociationsCount(),this.sortContainerElements(this.sourcewrapper)),this.itemStart.classList.contains("source")&&(this.itemStart.dataset.matchMax*1>0&&this.decrementRemaining(this.itemStart)===0&&this.itemStart.classList.remove("full"),this.incrementAssociationsCount()),this.itemStart.classList.contains("target")&&(this.isTargetFull(this.itemStart)?this.itemStart.classList.add("full"):this.itemStart.classList.remove("full")),this.notifyUpdate()}this.setCurrentDragger(null),this.removeListeners(n,s)}setCurrentDragger(t){this.currentDragger=t}resetDraggerToItemStart(t,i){this.replacePlaceholder(i),t.classList.contains("source")||i.setAttribute("style","width:100%")}setDraggerToItemTarget(t,i){if(t.classList.contains("source")){if(t.classList.contains("full")){const s=t.querySelector(".draggable");s!=null&&t.replaceChild(i,s);return}t.append(i);return}t.append(i),i.setAttribute("style","width:100%"),this.isTargetFull(t)?t.classList.add("full"):t.classList.remove("full")}findDraggerItemTarget(t,i,s){this.itemTarget=null,s.forEach(n=>{const r=n.getBoundingClientRect();if(i.top+t.offsetHeight/2<r.bottom&&i.right-t.offsetWidth/2>r.left&&i.bottom-t.offsetHeight/2>r.top&&i.left+t.offsetWidth/2<r.right){if(this.isItemStartSource&&n.classList.contains("source")||n.classList.contains("full")||!this.hasMatchingMatchGroup(t.parentNode,n))return;n.classList.add("active"),this.itemTarget=n}else n.classList.remove("active")},this)}findSourceDraggerTarget(t,i){const s=this.sourcewrapper.getBoundingClientRect();if(i.top+t.offsetHeight/2<s.bottom&&i.right-t.offsetWidth/2>s.left&&i.bottom-t.offsetHeight/2>s.top&&i.left+t.offsetWidth/2<s.right){for(let n=0;n<this.sources.length;n++)if(this.sources[n].dataset.identifier===t.dataset.identifier){this.sources[n].classList.add("active"),this.itemTarget=this.sources[n];break}}else for(let n=0;n<this.sources.length;n++)this.sources[n].classList.contains("active")&&this.sources[n].classList.remove("active")}addPlaceholder(t){if(!t.parentNode.classList.contains("source")){this.addPlaceholderElement(t,!1);return}const i=t.parentNode.dataset.matchMax*1;if(i===1){this.addPlaceholderElement(t,!1);return}if(i===0){this.addPlaceholderElement(t,!0);return}if(this.getRemaining(t.parentNode)===1){this.addPlaceholderElement(t,!1);return}this.addPlaceholderElement(t,!0)}addPlaceholderElement(t,i){const s=t.cloneNode(!0);this.deepCloneId(s),i?(s.classList.add("clone"),s.addEventListener("mousedown",this.handleDragStart),s.addEventListener("touchstart",this.handleTouchStart)):s.classList.add("gm-dragger-placeholder"),s.classList.add("placeholder-fade"),t.parentNode.insertBefore(s,t)}removePlaceholder(t){if(t.parentNode.classList.contains("target")){const n=t.parentNode.querySelector(".gm-dragger-placeholder");if(n===null)return;t.parentNode.removeChild(n);return}const i=t.parentNode.dataset.matchMax*1,s=t.parentNode.querySelector(".gm-dragger-placeholder");if(s===null){const n=t.parentNode.querySelector(".clone");if(n===null)return;n.classList.remove("placeholder-fade");return}i!==0&&t.parentNode.removeChild(s)}replacePlaceholder(t){const i=t.parentNode;let s=i.querySelector(".gm-dragger-placeholder");if(i.classList.contains("source")){if(s==null&&(s=i.querySelector(".draggable")),s===null)return;i.replaceChild(t,s);return}s!==null&&i.replaceChild(t,s)}addClonePlaceholder(t){const i=t.cloneNode(!0);this.deepCloneId(i),i.classList.add("clone"),t.parentNode.insertBefore(i,t),i.addEventListener("mousedown",this.handleDragStart),i.addEventListener("touchstart",this.handleTouchStart)}initializeSources(t){this.sources=t.querySelectorAll(".source"),this.sources.forEach(i=>{i.classList.add("full");const s=i.dataset.matchMax*1;this.setRemaining(i,s===0?1e3:s)},this),this.draggers=t.querySelectorAll(".draggable"),this.draggers.forEach((i,s)=>{const n=i.parentNode.getAttribute("data-identifier");i.setAttribute("data-identifier",n),i.setAttribute("data-order",s),i.setAttribute("tabindex",0),i.addEventListener("mousedown",this.handleDragStart),i.addEventListener("touchstart",this.handleTouchStart)},this)}initializeTargets(t){this.targets=t.querySelectorAll(".target"),this.targets.forEach(i=>{i.setAttribute("tabindex",0)})}identifyTargets(t,i){this.targets.forEach(s=>{i&&!s.classList.contains("full")&&this.hasMatchingMatchGroup(t,s)&&s.classList.add("target-active")},this),i&&!this.isItemStartSource&&this.sourcewrapper.classList.add("target-active")}addListeners(t,i){i?(this.removeListeners(t,i),t.addEventListener("touchmove",this.handleTouchMove),t.addEventListener("touchend",this.handleTouchEnd)):(this.removeListeners(t,i),document.addEventListener("mousemove",this.handleDragMove),document.addEventListener("mouseup",this.handleDragEnd))}removeListeners(t,i){i?(t.removeEventListener("touchmove",this.handleTouchMove),t.removeEventListener("touchend",this.handleTouchEnd)):(document.removeEventListener("mousemove",this.handleDragMove),document.removeEventListener("mouseup",this.handleDragEnd))}clearTargetHighlights(){this.targets.forEach(t=>{t.classList.remove("target-active")},this),this.sourcewrapper.classList.remove("target-active")}getClosestElement(t,i){return t?t&&t.classList.contains(i)?t:this.getClosestElement(t.parentElement,i):!1}sortContainerElements(t){let i=[],s=t.children;for(let n=0;n<s.length;n++){const r=s[n].querySelector("div.draggable");r&&i.push([1*r.dataset.order,s[n]])}i.sort(function(n,r){return n[0]-r[0]});for(let n=0;n<i.length;n++)t.appendChild(i[n][1])}getResponse(){return this.computeResponse()}computeResponse(){let t=[];return this.targets.forEach(i=>{i.querySelectorAll(".draggable").forEach(s=>{t.push(`${s.dataset.identifier} ${i.dataset.identifier}`)})}),t.length===0?null:this.options.cardinality==="single"?t[0]:t}restoreResponse(t){t!==null&&(this.options.cardinality==="single"?this.restoreResponsePair(t):t.forEach(i=>{this.restoreResponsePair(i)},this))}restoreResponsePair(t){const i=this.getPair(t);if(i===null)return;const s=this.findSourceByIdentifier(i.source),n=this.findTargetGapByIdentifier(i.target);if(s===null||n===null)return;const r=s.querySelector(".draggable");r!==null&&(this.cloneOrEmptySourceDragger(s,r),this.restoreSourceDraggerToTarget(n,r))}cloneOrEmptySourceDragger(t,i){const s=t.dataset.matchMax*1;if(s===1){t.classList.remove("full"),this.decrementRemaining(t);return}if(s===0){this.addClonePlaceholder(i);return}if(this.getRemaining(t)===1){t.classList.remove("full"),this.decrementRemaining(t);return}this.decrementRemaining(t),this.addClonePlaceholder(i)}findSourceByIdentifier(t){for(let i=0;i<this.sources.length;i++)if(t===this.sources[i].dataset.identifier)return this.sources[i];return null}findTargetGapByIdentifier(t){for(let i=0;i<this.targets.length;i++)if(t===this.targets[i].dataset.identifier)return this.targets[i];return null}getPair(t){if(t===null)return null;const i=t.split(" ");return i.length!=2?null:{source:i[0],target:i[1]}}restoreSourceDraggerToTarget(t,i){t===null||i===null||(t.append(i),i.setAttribute("style","width:100%"),this.incrementAssociationsCount(),this.isTargetFull(t)&&t.classList.add("full"))}hasMatchingMatchGroup(t,i){return t===null||i===null?!1:t.dataset.matchGroup===i.dataset.matchGroup}isTargetFull(t){if(t==null)return!1;const i=t.querySelectorAll(".draggable"),s=t.dataset.matchMax*1;return s===0?!1:i.length>=s}isExceedingMaxAssociations(t,i){return!(this.options.maxAssociations===0||i.classList.contains("source")||t.classList.contains("target")||this.currentAssociationsCount<this.options.maxAssociations)}initializeAssociationsCount(){this.currentAssociationsCount=0}incrementAssociationsCount(){this.currentAssociationsCount+=1}decrementAssociationsCount(){this.currentAssociationsCount!==0&&(this.currentAssociationsCount-=1)}getRemaining(t){return t.dataset.remaining*1}setRemaining(t,i){t.setAttribute("data-remaining",i)}incrementRemaining(t){const i=t.dataset.remaining*1+1;return t.setAttribute("data-remaining",i),i}decrementRemaining(t){let i=t.dataset.remaining*1-1;return i=i>=0?i:0,t.setAttribute("data-remaining",i),i}deepCloneId(t){t.id&&(t.id=`clone_${this.qtiAttributeValidation.randomString(5,"a")}`);for(let i=0;i<t.children.length;i++)this.deepCloneId(t.children[i])}reset(){this.resetDraggersToSources(),this.initializeAssociationsCount(),this.destroy()}resetDraggersToSources(){this.targets.forEach(t=>{t.querySelectorAll(".draggable").forEach(s=>{const n=this.findSourceByIdentifier(s.getAttribute("data-identifier"));n.classList.contains("full")||(t.classList.remove("full"),n.classList.contains("full")?t.removeChild(s):(n.append(s),n.classList.add("full")))},this)},this)}destroy(){this.currentDragger!==null&&(document.removeEventListener("mousemove",this.handleDragMove),document.removeEventListener("mouseup",this.handleDragEnd)),this.wrapper.querySelectorAll(".draggable").forEach(i=>{i.removeEventListener("touchstart",this.handleTouchStart),i.removeEventListener("touchmove",this.handleTouchMove),i.removeEventListener("touchend",this.handleTouchEnd),i.removeEventListener("mousedown",this.handleDragStart)},this)}}const Eq=new F,Cq=new te,Tq={emits:["gapMatchGroupReady","gapMatchGroupUpdate","gapMatchGroupAssociationsLimit"],props:{responseIdentifier:{required:!0,type:String},cardinality:{required:!0,type:String},shuffle:{required:!1,type:String,default:"false"},maxAssociations:{required:!1,type:String,default:"1"},minAssociations:{required:!1,type:String,default:"0"},dataChoicesContainerWidth:{required:!1,type:String,default:null},interactionSubType:{required:!1,type:String,default:"default"},gapMatchInteractionStaticClass:{required:!0,type:String},priorState:{required:!1,type:Object,default:null}},data(){return{choices:[],order:[],gaps:[],response:null,isShuffle:null,hasPrompt:!1,gapMatchInteractionClassAttribute:null,presentationFactory:null,matchable:null,isQtiValid:!0}},computed:{computedMaxAssociations(){return this.maxAssociations*1}},methods:{getResponse(){return this.response},setResponse(e){this.response=e},disable(){this.matchable!==null&&this.matchable.toggleDisable(!0)},enable(){this.matchable!==null&&this.matchable.toggleDisable(!1)},getChoices(){return this.choices},setIsShuffle(e){this.isShuffle=e},validateChildren(){let e=0;this.$slots.default()[0].children.forEach(t=>{if(Eq.isValidSlot(t)){if(t.type.name==="QtiPrompt"){if(e>0)throw new c("Invalid element order. qti-prompt must come before qti-gap-text's, qti-gap-img's, or qti-gap's");if(!this.hasPrompt)return this.hasPrompt=!0;throw new c("Maximum of 1 qti-prompt element permitted")}if(t.type.name==="QtiGapText"||t.type.name==="QtiGapImg")return e+=1;throw new c('Node is not one of qti-gap-text or qti-gap-img: "'+t.type.name+'"')}})},processChildren(){this.$.subTree.children[0].children[0].children.forEach(i=>{i.component!==null&&(i.type.name==="QtiGapText"||i.type.name==="QtiGapImg")&&this.choices.push(i.component.proxy)}),this.$refs.root.querySelectorAll(".gap-match-gap").forEach(i=>{this.gaps.push(i)})},insertAfter(e,t){t.parentNode.insertBefore(e,t.nextSibling)},processGroupUI(e){let t=this.createGapChoiceWrapper();if(t==null)return;let i=this.createContainer(this.priorState);this.processContainerChoices(i,t),this.saveContainerOrder(i);let s=this.createGapTargetWrapper(t);this.presentationFactory.initialize(this.$refs.root,t,s,this.dataChoicesContainerWidth,this.choices,this.gaps),this.matchable=new vq(this.$refs.root,{interactionSubType:this.interactionSubType,cardinality:this.cardinality,maxAssociations:this.computedMaxAssociations,response:e,onReady:this.handleWidgetReady,onUpdate:this.handleWidgetUpdate,onAssociationsLimit:this.handleAssociationsLimit})},createGapChoiceWrapper(){let e=this.$refs.root.querySelector(".qti-gap-choice");if(e===null)return null;let t=document.createElement("ul");return t.classList.add("qti-gap-match-source-wrapper"),this.$refs.root.insertBefore(t,e),t},createGapTargetWrapper(e){const t=document.createElement("div");t.classList.add("qti-gap-match-target-wrapper"),this.insertAfter(t,e);const i=t.nextElementSibling;return i!=null&&t.append(i),t},createContainer(e){let t=[];return e===null?(this.choices.forEach(s=>{t.push({fixed:s.fixed==="true",node:s})}),this.isShuffle&&Cq.shuffleArrayFixed(t),t):(e.state.order.forEach(s=>{const n=this.findChoiceByIdentifier(s,this.choices);n!==null&&t.push({fixed:n.fixed==="true",node:n})},this),t)},processContainerChoices(e,t){this.choices.splice(0,this.choices.length),t.innerHTML="",e.forEach(i=>{t.appendChild(i.node.$el),this.choices.push(i.node)},this)},saveContainerOrder(e){const t=[];e.forEach(i=>{t.push(i.node.identifier)}),this.order=t},findChoiceByIdentifier(e,t){for(let i=0;i<t.length;i++)if(t[i].$el.getAttribute("data-identifier")===e)return t[i];throw new O('Gap Match Interaction State Invalid. Choice identifier "'+e+'" not found.')},resetGroupUI(){this.processGroupUI(null)},handleWidgetReady(e){this.setResponse(e.response),this.$emit("gapMatchGroupReady",{response:this.getResponse(),order:this.order})},handleWidgetUpdate(e){this.setResponse(e.response),this.$emit("gapMatchGroupUpdate",{response:this.getResponse()})},handleAssociationsLimit(){this.$emit("gapMatchGroupAssociationsLimit")},initializeGapMatchGroup(){this.presentationFactory=new bq(this.gapMatchInteractionStaticClass)}},created(){try{if(typeof this.cardinality>"u")throw new c("Undefined qti-gap-match-interaction cardinality");if(this.cardinality!=="single"&&this.cardinality!=="multiple")throw new c('qti-gap-match-interaction cardinality must be "single" or "multiple"');this.setIsShuffle(this.shuffle==="true"),this.initializeGapMatchGroup(),this.validateChildren()}catch(e){throw this.isQtiValid=!1,console.log("[QtiGapMatchInteraction][ValidationError]",e.name,e.message),new c(e.message)}},mounted(){if(this.isQtiValid)try{this.processChildren(),this.processGroupUI(this.priorState===null?null:this.priorState.value)}catch(e){if(this.isQtiValid=!1,e.name==="QtiValidationException")throw console.log("[QtiGapMatchInteraction][ValidationException]",e.message),new c(e.message);if(e.name==="QtiEvaluationException")throw console.log("[QtiGapMatchInteraction][EvaluationException]",e.message),new O(e.message)}},beforeUnmount(){this.matchable!==null&&(this.matchable.destroy(),this.matchable=null)}},Sq={ref:"root",class:"qti-gap-match-group-wrapper"};function xq(e,t,i,s,n,r){return l.openBlock(),l.createElementBlock("div",Sq,[l.renderSlot(e.$slots,"default")],512)}const Iq=P(Tq,[["render",xq]]);class _q{constructor(t){this.constants={QTI_SELECTIONS_LIGHT:"qti-selections-light",QTI_SELECTIONS_DARK:"qti-selections-dark",QTI_UNSELECTED_HIDDEN:"qti-unselected-hidden",QTI_CHOICES_TOP:"qti-choices-top",QTI_CHOICES_BOTTOM:"qti-choices-bottom",QTI_CHOICES_LEFT:"qti-choices-left",QTI_CHOICES_RIGHT:"qti-choices-right",DATA_MAX_SELECTIONS_MESSAGE:"data-max-selections-message",DATA_MIN_SELECTIONS_MESSAGE:"data-min-selections-message",DATA_CHOICES_CONTAINER_WIDTH:null},this.parentClass=t,this.clazzTokens=[],this.ggmGroupElement=null,this.ggmChoiceWrapperElement=null,this.ggmTargetWrapperElement=null,this.image=null,this.choicesContainerWidth=null,this.gapChoices=[],this.gaps=[],this.presentation_Choices_Orientation=null,this.presentation_Theme=this.constants.QTI_SELECTIONS_DARK,this.presentation_UnselectedHidden=!1,this.presentation_MaxSelectionsMessage="",this.presentation_MinSelectionsMessage=""}initialize(t,i,s,n,r,a,o){this.ggmGroupElement=t,this.ggmChoiceWrapperElement=i,this.ggmTargetWrapperElement=s,this.image=n,this.choicesContainerWidth=r,this.gapChoices=a,this.gaps=o,this.processRootClassAttribute(this.parentClass),this.processPresentation()}processRootClassAttribute(t){const i=t.split(" ");for(let s=0;s<i.length;s++)switch(i[s]){case this.constants.QTI_CHOICES_TOP:case this.constants.QTI_CHOICES_BOTTOM:case this.constants.QTI_CHOICES_LEFT:case this.constants.QTI_CHOICES_RIGHT:this.presentation_Choices_Orientation=i[s];break;case this.constants.QTI_SELECTIONS_DARK:case this.constants.QTI_SELECTIONS_LIGHT:this.presentation_Theme=i[s];break;case this.constants.QTI_UNSELECTED_HIDDEN:this.presentation_UnselectedHidden=!0;break}this.clazzTokens=i}processPresentation(){this.presentation_Choices_Orientation===null&&(this.presentation_Choices_Orientation=this.constants.QTI_CHOICES_TOP),this.presentation_Choices_Orientation===this.constants.QTI_CHOICES_LEFT?(this.ggmChoiceWrapperElement.classList.add(this.constants.QTI_CHOICES_LEFT),this.ggmTargetWrapperElement.classList.add(this.constants.QTI_CHOICES_LEFT),this.ggmGroupElement.classList.add(this.constants.QTI_CHOICES_LEFT)):this.presentation_Choices_Orientation===this.constants.QTI_CHOICES_TOP?(this.ggmChoiceWrapperElement.classList.add(this.constants.QTI_CHOICES_TOP),this.ggmTargetWrapperElement.classList.add(this.constants.QTI_CHOICES_TOP)):this.presentation_Choices_Orientation===this.constants.QTI_CHOICES_RIGHT?(this.ggmChoiceWrapperElement.classList.add(this.constants.QTI_CHOICES_RIGHT),this.ggmTargetWrapperElement.classList.add(this.constants.QTI_CHOICES_RIGHT),this.ggmGroupElement.classList.add(this.constants.QTI_CHOICES_RIGHT),this.ggmGroupElement.insertBefore(this.ggmTargetWrapperElement,this.ggmChoiceWrapperElement)):this.presentation_Choices_Orientation===this.constants.QTI_CHOICES_BOTTOM&&(this.ggmChoiceWrapperElement.classList.add(this.constants.QTI_CHOICES_BOTTOM),this.ggmTargetWrapperElement.classList.add(this.constants.QTI_CHOICES_BOTTOM),this.ggmGroupElement.insertBefore(this.ggmTargetWrapperElement,this.ggmChoiceWrapperElement)),this.processBackgroundImage(),this.processChoicesContainerWidth(),this.processGaps()}processBackgroundImage(){if(this.image===null)return;this.image.setAttribute("draggable","false");const t=this.image.getBoundingClientRect();this.ggmTargetWrapperElement.style.width=`${t.width}px`,this.ggmTargetWrapperElement.style.height=`${t.height}px`}processChoicesContainerWidth(){this.choicesContainerWidth!==null&&(this.ggmChoiceWrapperElement.style.width=`${this.choicesContainerWidth}px`,this.ggmChoiceWrapperElement.style.textAlign="center")}processGaps(){for(let t=0;t<this.gaps.length;t++){const i=this.gaps[t];this.setGapStyle(i,i.getShape(),i.getShapeData()),this.gaps[t].$refs.gap.classList.add("target",this.presentation_Theme),this.presentation_UnselectedHidden&&this.gaps[t].$refs.gap.classList.add(this.constants.QTI_UNSELECTED_HIDDEN)}}setGapStyle(t,i,s){switch(i){case"rect":t.$refs.gap.style.left=`${s[0]}px`,t.$refs.gap.style.top=`${s[1]}px`,t.$refs.gap.style.width=`${s[2]}px`,t.$refs.gap.style.height=`${s[3]}px`;break}}}class Vq{constructor(t,i){ee(this,"options",{interactionSubType:"default",cardinality:"multiple",maxAssociations:0,response:null,onReady:null,onUpdate:null,onSelectionsLimit:null,zindex:1e3});return this.qtiAttributeValidation=new F,this.wrapper=t,this.sourcewrapper=this.wrapper.querySelector(".qti-ggm-source-wrapper"),this.targetwrapper=this.wrapper.querySelector(".qti-ggm-target-wrapper"),this.processOptions(i),this.handleDragStart=this.handleDragStart.bind(this),this.handleDragMove=this.handleDragMove.bind(this),this.handleDragEnd=this.handleDragEnd.bind(this),this.handleTouchStart=this.handleTouchStart.bind(this),this.handleTouchMove=this.handleTouchMove.bind(this),this.handleTouchEnd=this.handleTouchEnd.bind(this),this.itemTarget=null,this.itemStart=null,this.isItemStartSource=!0,this.savedGapZindex="",this.initialX=0,this.initialY=0,this.offsetX=0,this.offsetY=0,this.startingX=0,this.startingY=0,this.currentAssociationsCount=0,this.isDisabled=!1,this.currentDragger=null,this.initializeSources(this.sourcewrapper),this.initializeTargets(this.targetwrapper),this.restoreResponse(this.options.response),this.notifyReady(),this}processOptions(t){"interactionSubType"in t&&(this.options.interactionSubType=t.interactionSubType),"cardinality"in t&&(this.options.cardinality=t.cardinality),"response"in t&&(this.options.response=t.response),"maxAssociations"in t&&(this.options.maxAssociations=t.maxAssociations),"onReady"in t&&(this.options.onReady=t.onReady),"onUpdate"in t&&(this.options.onUpdate=t.onUpdate),"onAssociationsLimit"in t&&(this.options.onAssociationsLimit=t.onAssociationsLimit)}notifyReady(){this.options.onReady!==null&&this.options.onReady({response:this.getResponse()})}notifyUpdate(){this.options.onUpdate!==null&&this.options.onUpdate({response:this.computeResponse()})}notifyAssociationsLimit(){this.options.onAssociationsLimit!==null&&this.options.onAssociationsLimit()}toggleDisable(t){this.isDisabled=t,this.draggers.forEach(i=>{t?i.classList.add("disabled"):i.classList.remove("disabled")})}handleDragStart(t){if(t.preventDefault(),!this.isDisabled&&t.button==0)return this.interactionStart(t.target,t.clientX,t.clientY,!1),!1}handleTouchStart(t){if(t.preventDefault(),!this.isDisabled)return t.targetTouches.length!=1||this.interactionStart(t.target,t.touches[0].pageX,t.touches[0].pageY,!0),!1}interactionStart(t,i,s,n){const r=this.getClosestElement(t,"draggable");this.itemStart=r.parentNode,this.isItemStartSource=this.itemStart.classList.contains("source"),this.isItemStartSource||this.saveGapZindex(this.itemStart),this.identifyTargets(this.itemStart,!0),this.itemTarget=null;const a=r.getBoundingClientRect();this.initialX=i,this.initialY=s,this.startingX=a.left,this.startingY=a.top,this.offsetX=i-this.startingX,this.offsetY=s-this.startingY,this.addPlaceholder(r),r.classList.add("dragging"),r.style.userSelect="none",r.style.width=a.width+"px",r.style.height=a.height+"px",r.style.transform=`translateX(${a.left}px) translateY(${a.top}px) translateZ(0)`,this.setCurrentDragger(r),this.addListeners(r,n)}handleDragMove(t){t.preventDefault(),!this.isDisabled&&this.interactionMove(t.clientX,t.clientY)}handleTouchMove(t){t.preventDefault(),!this.isDisabled&&t.targetTouches.length==1&&this.interactionMove(t.touches[0].clientX,t.touches[0].clientY)}interactionMove(t,i){const s=this.currentDragger;this.offsetX=t-this.initialX,this.offsetY=i-this.initialY,this.constrainDraggerToWrapper(s,this.wrapper),s.style.transform=`translateX(${this.startingX+this.offsetX}px) translateY(${this.startingY+this.offsetY}px) translateZ(0) scale(1)`;const n=s.getBoundingClientRect();this.findDraggerItemTarget(s,n,this.targets),this.isItemStartSource||this.findSourceDraggerTarget(s,n)}constrainDraggerToWrapper(t,i){const s=t.getBoundingClientRect(),n=i.getBoundingClientRect(),r=this.startingX+this.offsetX-n.x,a=this.startingY+this.offsetY-n.y,o=this.startingX+s.width+this.offsetX-(n.x+n.width),u=this.startingY+s.height+this.offsetY-(n.y+n.height);r<0&&(this.offsetX=this.offsetX-r),o>0&&(this.offsetX=this.offsetX-o),a<0&&(this.offsetY=this.offsetY-a),u>0&&(this.offsetY=this.offsetY-u)}handleDragEnd(t){this.isDisabled||this.interactionEnd(t.clientX,t.clientY,!1)}handleTouchEnd(t){this.isDisabled||this.interactionEnd(t.changedTouches[0].clientX,t.changedTouches[0].clientY,!0)}interactionEnd(t,i,s){const n=this.currentDragger;if(this.itemTarget===null?n.style.transform=`translateX(${this.startingX}px) translateY(${this.startingY}px) translateZ(0)`:n.style.transform=`translateX(${this.startingX+this.offsetX}px) translateY(${this.startingY+this.offsetY}px) translateZ(0)`,n.removeAttribute("style"),n.classList.remove("dragging"),this.clearTargetHighlights(),this.itemTarget===null){this.resetDraggerToItemStart(this.itemStart,n),this.setCurrentDragger(null),this.removeListeners(n,s);return}if(this.itemTarget.classList.contains("active")){if(this.itemTarget.classList.remove("active"),this.isExceedingMaxAssociations(this.itemStart,this.itemTarget,n)){this.resetDraggerToItemStart(this.itemStart,n),this.notifyAssociationsLimit(),this.setCurrentDragger(null),this.removeListeners(n,s);return}if(this.itemStart.getAttribute("data-identifier")===this.itemTarget.getAttribute("data-identifier")){this.resetDraggerToItemStart(this.itemStart,n),this.setCurrentDragger(null),this.removeListeners(n,s);return}this.removePlaceholder(n),this.setDraggerToItemTarget(this.itemTarget,n),this.itemTarget.classList.contains("source")&&(this.itemTarget.classList.add("full"),this.itemTarget.dataset.matchMax*1>0&&this.incrementRemaining(this.itemTarget),this.decrementAssociationsCount(),this.sortContainerElements(this.sourcewrapper)),this.itemStart.classList.contains("source")&&(this.itemStart.dataset.matchMax*1>0&&this.decrementRemaining(this.itemStart)===0&&this.itemStart.classList.remove("full"),this.incrementAssociationsCount()),this.itemStart.classList.contains("target")&&(this.restoreGapZindex(this.itemStart),this.isTargetFull(this.itemStart)?this.itemStart.classList.add("full","contains-choice"):(this.itemStart.classList.remove("full"),this.containsChoices(this.itemStart)?this.itemStart.classList.add("contains-choice"):this.itemStart.classList.remove("contains-choice"))),this.notifyUpdate()}this.setCurrentDragger(null),this.removeListeners(n,s)}setCurrentDragger(t){this.currentDragger=t}resetDraggerToItemStart(t,i){t.classList.contains("target")&&this.restoreGapZindex(t),this.replacePlaceholder(i)}setDraggerToItemTarget(t,i){if(t.classList.contains("source")){this.appendDraggerToSourceTarget(t,i);return}this.appendDraggerToGapTarget(t,i),this.isTargetFull(t)?t.classList.add("full"):t.classList.remove("full")}appendDraggerToSourceTarget(t,i){if(t.classList.contains("full")){const s=t.querySelector(".draggable");s!=null&&t.replaceChild(i,s);return}t.append(i)}appendDraggerToGapTarget(t,i){t.classList.add("contains-choice"),t.append(i)}findDraggerItemTarget(t,i,s){this.itemTarget=null,s.forEach(n=>{const r=n.getBoundingClientRect();if(i.top+t.offsetHeight/2<r.bottom&&i.right-t.offsetWidth/2>r.left&&i.bottom-t.offsetHeight/2>r.top&&i.left+t.offsetWidth/2<r.right){if(this.isItemStartSource&&n.classList.contains("source")||n.classList.contains("full")||!this.hasMatchingMatchGroup(t.parentNode,n))return;n.classList.add("active"),this.itemTarget=n}else n.classList.remove("active")},this)}findSourceDraggerTarget(t,i){const s=this.sourcewrapper.getBoundingClientRect();if(i.top+t.offsetHeight/2<s.bottom&&i.right-t.offsetWidth/2>s.left&&i.bottom-t.offsetHeight/2>s.top&&i.left+t.offsetWidth/2<s.right){for(let n=0;n<this.sources.length;n++)if(this.sources[n].dataset.identifier===t.dataset.identifier){this.sources[n].classList.add("active"),this.itemTarget=this.sources[n];break}}else for(let n=0;n<this.sources.length;n++)this.sources[n].classList.contains("active")&&this.sources[n].classList.remove("active")}addPlaceholder(t){if(!t.parentNode.classList.contains("source")){this.addPlaceholderElement(t,!1);return}const i=t.parentNode.dataset.matchMax*1;if(i===1){this.addPlaceholderElement(t,!1);return}if(i===0){this.addPlaceholderElement(t,!0);return}if(this.getRemaining(t.parentNode)===1){this.addPlaceholderElement(t,!1);return}this.addPlaceholderElement(t,!0)}addPlaceholderElement(t,i){const s=t.cloneNode(!0);this.deepCloneId(s),i?(s.classList.add("clone"),s.addEventListener("mousedown",this.handleDragStart),s.addEventListener("touchstart",this.handleTouchStart)):s.classList.add("ggm-dragger-placeholder"),s.classList.add("placeholder-fade"),t.parentNode.insertBefore(s,t)}removePlaceholder(t){if(t.parentNode.classList.contains("target")){const n=t.parentNode.querySelector(".ggm-dragger-placeholder");if(n===null)return;t.parentNode.removeChild(n);return}const i=t.parentNode.dataset.matchMax*1,s=t.parentNode.querySelector(".ggm-dragger-placeholder");if(s===null){const n=t.parentNode.querySelector(".clone");if(n===null)return;n.classList.remove("placeholder-fade");return}i!==0&&t.parentNode.removeChild(s)}replacePlaceholder(t){const i=t.parentNode;let s=i.querySelector(".ggm-dragger-placeholder");if(i.classList.contains("source")){if(s==null&&(s=i.querySelector(".draggable")),s===null)return;i.replaceChild(t,s);return}s!==null&&i.replaceChild(t,s)}addClonePlaceholder(t){const i=t.cloneNode(!0);this.deepCloneId(i),i.classList.add("clone"),t.parentNode.insertBefore(i,t),i.addEventListener("mousedown",this.handleDragStart),i.addEventListener("touchstart",this.handleTouchStart)}initializeSources(t){this.sources=t.querySelectorAll(".source"),this.sources.forEach(i=>{i.classList.add("full");const s=i.dataset.matchMax*1;this.setRemaining(i,s===0?1e3:s)},this),this.draggers=t.querySelectorAll(".draggable"),this.draggers.forEach((i,s)=>{const n=i.parentNode.getAttribute("data-identifier");i.setAttribute("data-identifier",n),i.setAttribute("data-order",s),i.setAttribute("tabindex",0),i.addEventListener("mousedown",this.handleDragStart),i.addEventListener("touchstart",this.handleTouchStart)},this)}initializeTargets(t){this.targets=t.querySelectorAll(".target"),this.targets.forEach(i=>{i.setAttribute("tabindex",0)})}identifyTargets(t,i){this.targets.forEach(s=>{i&&!s.classList.contains("full")&&this.hasMatchingMatchGroup(t,s)&&s.classList.add("target-active")},this),i&&!this.isItemStartSource&&this.sourcewrapper.classList.add("target-active")}addListeners(t,i){i?(this.removeListeners(t,i),t.addEventListener("touchmove",this.handleTouchMove),t.addEventListener("touchend",this.handleTouchEnd)):(this.removeListeners(t,i),document.addEventListener("mousemove",this.handleDragMove),document.addEventListener("mouseup",this.handleDragEnd))}removeListeners(t,i){i?(t.removeEventListener("touchmove",this.handleTouchMove),t.removeEventListener("touchend",this.handleTouchEnd)):(document.removeEventListener("mousemove",this.handleDragMove),document.removeEventListener("mouseup",this.handleDragEnd))}clearTargetHighlights(){this.targets.forEach(t=>{t.classList.remove("target-active")},this),this.sourcewrapper.classList.remove("target-active")}getClosestElement(t,i){return t?t&&t.classList.contains(i)?t:this.getClosestElement(t.parentElement,i):!1}sortContainerElements(t){let i=[],s=t.children;for(let n=0;n<s.length;n++){const r=s[n].querySelector("div.draggable");r&&i.push([1*r.dataset.order,s[n]])}i.sort(function(n,r){return n[0]-r[0]});for(let n=0;n<i.length;n++)t.appendChild(i[n][1])}saveGapZindex(t){this.savedGapZindex=t.style.zIndex,t.style.zIndex=this.options.zindex}restoreGapZindex(t){t.style.zIndex=this.savedGapZindex}getResponse(){return this.computeResponse()}computeResponse(){let t=[];return this.targets.forEach(i=>{i.querySelectorAll(".draggable").forEach(s=>{t.push(`${s.dataset.identifier} ${i.dataset.identifier}`)})}),t.length===0?null:this.options.cardinality==="single"?t[0]:t}restoreResponse(t){t!==null&&(this.options.cardinality==="single"?this.restoreResponsePair(t):t.forEach(i=>{this.restoreResponsePair(i)},this))}restoreResponsePair(t){const i=this.getPair(t);if(i===null)return;const s=this.findSourceByIdentifier(i.source),n=this.findTargetGapByIdentifier(i.target);if(s===null||n===null)return;const r=s.querySelector(".draggable");r!==null&&(this.cloneOrEmptySourceDragger(s,r),this.restoreSourceDraggerToTarget(n,r))}cloneOrEmptySourceDragger(t,i){const s=t.dataset.matchMax*1;if(s===1){t.classList.remove("full"),this.decrementRemaining(t);return}if(s===0){this.addClonePlaceholder(i);return}if(this.getRemaining(t)===1){t.classList.remove("full"),this.decrementRemaining(t);return}this.decrementRemaining(t),this.addClonePlaceholder(i)}findSourceByIdentifier(t){for(let i=0;i<this.sources.length;i++)if(t===this.sources[i].dataset.identifier)return this.sources[i];return null}findTargetGapByIdentifier(t){for(let i=0;i<this.targets.length;i++)if(t===this.targets[i].dataset.identifier)return this.targets[i];return null}getPair(t){if(t===null)return null;const i=t.split(" ");return i.length!=2?null:{source:i[0],target:i[1]}}restoreSourceDraggerToTarget(t,i){t===null||i===null||(this.appendDraggerToGapTarget(t,i),this.incrementAssociationsCount(),this.isTargetFull(t)&&t.classList.add("full"))}hasMatchingMatchGroup(t,i){return t===null||i===null?!1:t.dataset.matchGroup===i.dataset.matchGroup}isTargetFull(t){if(t==null)return!1;const i=t.querySelectorAll(".draggable"),s=t.dataset.matchMax*1;return s===0?!1:i.length>=s}containsChoices(t){return t==null?!1:t.querySelectorAll(".draggable").length!==0}isExceedingMaxAssociations(t,i){return!(this.options.maxAssociations===0||i.classList.contains("source")||t.classList.contains("target")||this.currentAssociationsCount<this.options.maxAssociations)}initializeAssociationsCount(){this.currentAssociationsCount=0}incrementAssociationsCount(){this.currentAssociationsCount+=1}decrementAssociationsCount(){this.currentAssociationsCount!==0&&(this.currentAssociationsCount-=1)}getRemaining(t){return t.dataset.remaining*1}setRemaining(t,i){t.setAttribute("data-remaining",i)}incrementRemaining(t){const i=t.dataset.remaining*1+1;return t.setAttribute("data-remaining",i),i}decrementRemaining(t){let i=t.dataset.remaining*1-1;return i=i>=0?i:0,t.setAttribute("data-remaining",i),i}deepCloneId(t){t.id&&(t.id=`clone_${this.qtiAttributeValidation.randomString(5,"a")}`);for(let i=0;i<t.children.length;i++)this.deepCloneId(t.children[i])}reset(){this.resetDraggersToSources(),this.initializeAssociationsCount(),this.destroy()}resetDraggersToSources(){this.targets.forEach(t=>{t.querySelectorAll(".draggable").forEach(s=>{const n=this.findSourceByIdentifier(s.getAttribute("data-identifier"));n.classList.contains("full")||(n.classList.contains("full")?t.removeChild(s):(n.append(s),n.classList.add("full")))},this),t.classList.remove("full","contains-choice")},this)}destroy(){this.currentDragger!==null&&(document.removeEventListener("mousemove",this.handleDragMove),document.removeEventListener("mouseup",this.handleDragEnd)),this.wrapper.querySelectorAll(".draggable").forEach(i=>{i.removeEventListener("touchstart",this.handleTouchStart),i.removeEventListener("touchmove",this.handleTouchMove),i.removeEventListener("touchend",this.handleTouchEnd),i.removeEventListener("mousedown",this.handleDragStart)},this)}}const Aq=new F,$q=new te,Lq={emits:["ggmGroupReady","ggmGroupUpdate","ggmGroupAssociationsLimit"],props:{responseIdentifier:{required:!0,type:String},cardinality:{required:!0,type:String},shuffle:{required:!1,type:String,default:"false"},maxAssociations:{required:!1,type:String,default:"1"},minAssociations:{required:!1,type:String,default:"0"},dataChoicesContainerWidth:{required:!1,type:String,default:null},interactionSubType:{required:!1,type:String,default:"default"},interactionStaticClass:{required:!0,type:String},priorState:{required:!1,type:Object,default:null}},data(){return{image:null,choices:[],order:[],gaps:[],response:null,isShuffle:null,hasPrompt:!1,interactionClassAttribute:null,presentationFactory:null,matchable:null,isQtiValid:!0}},computed:{computedMaxAssociations(){return this.maxAssociations*1}},methods:{getResponse(){return this.response},setResponse(e){this.response=e},disable(){this.matchable!==null&&this.matchable.toggleDisable(!0)},enable(){this.matchable!==null&&this.matchable.toggleDisable(!1)},getChoices(){return this.choices},setIsShuffle(e){this.isShuffle=e},validateChildren(){let e=0,t=0,i=!1;this.$slots.default()[0].children.forEach(s=>{if(Aq.isValidSlot(s)){if(s.type.name==="QtiPrompt"){if(e>0||t>0||i)throw new c("Invalid element order. qti-prompt must come before the background image, qti-gap-text's, qti-gap-img's, or qti-associable-hotspot's");if(!this.hasPrompt)return this.hasPrompt=!0;throw new c("Maximum of 1 qti-prompt element permitted")}if(s.type.name==="QtiGapText"||s.type.name==="QtiGapImg"){if(t>0)throw new c("Invalid element order. qti-gap-text's and qti-gap-img's must come before qti-associable-hotspot's");return e+=1}if(s.type.name==="QtiAssociableHotspot")return t+=1;throw new c('Node is not one of qti-gap-text, qti-gap-img, or qti-associable-hotspot: "'+s.type.name+'"')}else if(s.type==="img"||s.type==="object"||s.type==="picture"){if(e>0||t>0)throw new c("Invalid element order. Background image must preceed qti-gap-text's, qti-gap-img's and qti-associable-hotspot's");i=!0}})},processChildren(){this.$.subTree.children[0].children[0].children.forEach(t=>{if(t.type==="img"||t.type==="object"||t.type==="picture"){this.image=t.el;return}t.component!==null&&(t.type.name==="QtiGapText"||t.type.name==="QtiGapImg"?this.choices.push(t.component.proxy):t.type.name==="QtiAssociableHotspot"&&this.gaps.push(t.component.proxy))})},insertAfter(e,t){t.parentNode.insertBefore(e,t.nextSibling)},processGroupUI(e){let t=this.createGapChoiceWrapper();if(t==null)return;let i=this.createGapTargetWrapper(),s=this.createContainer(this.priorState);this.processContainerChoices(s,t),this.saveContainerOrder(s),this.presentationFactory.initialize(this.$refs.root,t,i,this.image,this.dataChoicesContainerWidth,this.choices,this.gaps),this.matchable=new Vq(this.$refs.root,{interactionSubType:this.interactionSubType,cardinality:this.cardinality,maxAssociations:this.computedMaxAssociations,response:e,onReady:this.handleWidgetReady,onUpdate:this.handleWidgetUpdate,onAssociationsLimit:this.handleAssociationsLimit})},createGapChoiceWrapper(){let e=this.$refs.root.querySelector(".qti-gap-choice");if(e===null)return null;let t=document.createElement("ul");return t.classList.add("qti-ggm-source-wrapper"),this.$refs.root.insertBefore(t,e),t},createGapTargetWrapper(){let e=document.createElement("div");e.classList.add("qti-ggm-target-wrapper"),e.append(this.image);for(let t=0;t<this.gaps.length;t++)e.append(this.gaps[t].$el);return this.$refs.root.append(e),e},createContainer(e){let t=[];return e===null?(this.choices.forEach(s=>{t.push({fixed:s.fixed==="true",node:s})}),this.isShuffle&&$q.shuffleArrayFixed(t),t):(e.state.order.forEach(s=>{const n=this.findChoiceByIdentifier(s,this.choices);n!==null&&t.push({fixed:n.fixed==="true",node:n})},this),t)},processContainerChoices(e,t){this.choices.splice(0,this.choices.length),t.innerHTML="",e.forEach(i=>{t.appendChild(i.node.$el),this.choices.push(i.node)},this)},saveContainerOrder(e){const t=[];e.forEach(i=>{t.push(i.node.identifier)}),this.order=t},findChoiceByIdentifier(e,t){for(let i=0;i<t.length;i++)if(t[i].$el.getAttribute("data-identifier")===e)return t[i];throw new O('Gap Match Interaction State Invalid. Choice identifier "'+e+'" not found.')},resetGroupUI(){this.processGroupUI(null)},handleWidgetReady(e){this.setResponse(e.response),this.$emit("ggmGroupReady",{response:this.getResponse(),order:this.order})},handleWidgetUpdate(e){this.setResponse(e.response),this.$emit("ggmGroupUpdate",{response:this.getResponse()})},handleAssociationsLimit(){this.$emit("ggmGroupAssociationsLimit")},initializeGraphicGapMatchGroup(){this.presentationFactory=new _q(this.interactionStaticClass)}},created(){try{if(typeof this.cardinality>"u")throw new c("Undefined qti-graphic-gap-match-interaction cardinality");if(this.cardinality!=="multiple")throw new c('qti-graphic-gap-match-interaction cardinality must be "multiple"');this.setIsShuffle(this.shuffle==="true"),this.initializeGraphicGapMatchGroup(),this.validateChildren()}catch(e){throw this.isQtiValid=!1,console.log("[QtiGapMatchInteraction][ValidationError]",e.name,e.message),new c(e.message)}},mounted(){if(this.isQtiValid)try{this.processChildren(),this.processGroupUI(this.priorState===null?null:this.priorState.value)}catch(e){if(this.isQtiValid=!1,e.name==="QtiValidationException")throw console.log("[QtiGapMatchInteraction][ValidationException]",e.message),new c(e.message);if(e.name==="QtiEvaluationException")throw console.log("[QtiGapMatchInteraction][EvaluationException]",e.message),new O(e.message)}},beforeUnmount(){this.matchable!==null&&(this.matchable.destroy(),this.matchable=null)}},Mq={ref:"root",class:"qti-ggm-group-wrapper"};function Nq(e,t,i,s,n,r){return l.openBlock(),l.createElementBlock("div",Mq,[l.renderSlot(e.$slots,"default")],512)}const Rq=P(Lq,[["render",Nq]]);class kq{constructor(){this.constants={QTI_CHOICES_TOP:"qti-choices-top",QTI_CHOICES_BOTTOM:"qti-choices-bottom",QTI_CHOICES_LEFT:"qti-choices-left",QTI_CHOICES_RIGHT:"qti-choices-right",QTI_MATCH_TABULAR:"qti-match-tabular",QTI_HEADER_HIDDEN:"qti-header-hidden",ROW_CENTRIC:"row-centric",DATA_MAX_SELECTIONS_MESSAGE:"data-max-selections-message",DATA_MIN_SELECTIONS_MESSAGE:"data-min-selections-message",DATA_FIRST_COLUMN_HEADER:""},this.interactionSubType="default",this.parentClass="",this.clazzTokens=[],this.matchWrapperElement=null,this.matchGroupNode=null,this.matchSetNode1=null,this.matchSetNode2=null,this.choices1=[],this.choices2=[],this.presentation_Choices_Orientation=null,this.presentation_Header_Hidden=!1,this.presentation_Row_Centric=!1,this.presentation_MaxSelectionsMessage="",this.presentation_MinSelectionsMessage=""}initialize(t,i,s,n,r){this.interactionSubType=t,this.matchWrapperElement=i,this.matchGroupNode=s,this.parentClass=s.matchInteractionStaticClass,this.matchSetNode1=n,this.matchSetNode2=r,this.choices1=this.matchSetNode1.getChoices(),this.choices2=this.matchSetNode2.getChoices(),this.processRootClassAttribute(this.parentClass),this.processPresentation()}processRootClassAttribute(t){const i=t.split(" ");for(let s=0;s<i.length;s++)switch(i[s]){case this.constants.QTI_CHOICES_TOP:case this.constants.QTI_CHOICES_BOTTOM:case this.constants.QTI_CHOICES_LEFT:case this.constants.QTI_CHOICES_RIGHT:this.presentation_Choices_Orientation=i[s];break;case this.constants.QTI_MATCH_TABULAR:break;case this.constants.QTI_HEADER_HIDDEN:this.presentation_Header_Hidden=!0;break;case this.constants.ROW_CENTRIC:this.presentation_Row_Centric=!0;break}this.clazzTokens=i}processPresentation(){this.matchSetNode1.$refs.matchset.classList.add("qti-match-source-wrapper"),this.matchSetNode2.$refs.matchset.classList.add("qti-match-target-wrapper"),this.interactionSubType==="default"?(this.presentation_Choices_Orientation===null&&(this.presentation_Choices_Orientation=this.constants.QTI_CHOICES_TOP),this.presentation_Choices_Orientation===this.constants.QTI_CHOICES_LEFT?(this.matchSetNode1.$refs.matchset.classList.add(this.constants.QTI_CHOICES_LEFT),this.matchSetNode2.$refs.matchset.classList.add(this.constants.QTI_CHOICES_LEFT)):this.presentation_Choices_Orientation===this.constants.QTI_CHOICES_TOP?(this.matchSetNode1.$refs.matchset.classList.add(this.constants.QTI_CHOICES_TOP),this.matchSetNode2.$refs.matchset.classList.add(this.constants.QTI_CHOICES_TOP)):this.presentation_Choices_Orientation===this.constants.QTI_CHOICES_RIGHT?(this.matchSetNode1.$refs.matchset.classList.add(this.constants.QTI_CHOICES_RIGHT),this.matchSetNode2.$refs.matchset.classList.add(this.constants.QTI_CHOICES_RIGHT),this.matchWrapperElement.insertBefore(this.matchSetNode2.$refs.matchset,this.matchSetNode1.$refs.matchset)):this.presentation_Choices_Orientation===this.constants.QTI_CHOICES_BOTTOM&&(this.matchSetNode1.$refs.matchset.classList.add(this.constants.QTI_CHOICES_BOTTOM),this.matchSetNode2.$refs.matchset.classList.add(this.constants.QTI_CHOICES_BOTTOM),this.matchWrapperElement.insertBefore(this.matchSetNode2.$refs.matchset,this.matchSetNode1.$refs.matchset)),this.updateMatchSetChoices(this.matchSetNode1,!0),this.updateMatchSetChoices(this.matchSetNode2,!1)):this.interactionSubType==="matchtabular"&&(this.createMatchTable(),this.matchSetNode1.$refs.matchset.classList.add("matchset-hidden"),this.matchSetNode2.$refs.matchset.classList.add("matchset-hidden"))}updateMatchSetChoices(t,i){const s=t.getChoices();for(let n=0;n<s.length;n++)i?(s[n].$refs.choice.classList.add("source"),s[n].$refs.description.classList.add("draggable")):(s[n].$refs.choice.classList.add("target"),s[n].$refs.description.classList.add("match-target-label"))}createMatchTable(){const t=document.createElement("table");this.clazzTokens.forEach(i=>{t.classList.add(i)}),t.classList.add("matchtabular","table","table-bordered"),this.matchWrapperElement.insertBefore(t,this.matchSetNode1.$refs.matchset)}}class qq{constructor(t,i){ee(this,"options",{interactionSubType:"default",cardinality:"single",maxAssociations:0,response:null,onReady:null,onUpdate:null,onSelectionsLimit:null});return this.qtiAttributeValidation=new F,this.wrapper=t,this.sourcewrapper=this.wrapper.querySelector(".qti-match-source-wrapper"),this.targetwrapper=this.wrapper.querySelector(".qti-match-target-wrapper"),this.processOptions(i),this.handleDragStart=this.handleDragStart.bind(this),this.handleDragMove=this.handleDragMove.bind(this),this.handleDragEnd=this.handleDragEnd.bind(this),this.handleTouchStart=this.handleTouchStart.bind(this),this.handleTouchMove=this.handleTouchMove.bind(this),this.handleTouchEnd=this.handleTouchEnd.bind(this),this.itemTarget=null,this.itemStart=null,this.isItemStartSource=!0,this.initialX=0,this.initialY=0,this.offsetX=0,this.offsetY=0,this.startingX=0,this.startingY=0,this.currentAssociationsCount=0,this.isDisabled=!1,this.currentDragger=null,this.initializeSources(this.sourcewrapper),this.initializeTargets(this.targetwrapper),this.restoreResponse(this.options.response),this.notifyReady(),this}processOptions(t){"interactionSubType"in t&&(this.options.interactionSubType=t.interactionSubType),"cardinality"in t&&(this.options.cardinality=t.cardinality),"response"in t&&(this.options.response=t.response),"maxAssociations"in t&&(this.options.maxAssociations=t.maxAssociations),"onReady"in t&&(this.options.onReady=t.onReady),"onUpdate"in t&&(this.options.onUpdate=t.onUpdate),"onAssociationsLimit"in t&&(this.options.onAssociationsLimit=t.onAssociationsLimit)}notifyReady(){this.options.onReady!==null&&this.options.onReady({response:this.getResponse()})}notifyUpdate(){this.options.onUpdate!==null&&this.options.onUpdate({response:this.computeResponse()})}notifyAssociationsLimit(){this.options.onAssociationsLimit!==null&&this.options.onAssociationsLimit()}toggleDisable(t){this.isDisabled=t,this.draggers.forEach(i=>{t?i.classList.add("disabled"):i.classList.remove("disabled")})}handleDragStart(t){if(t.preventDefault(),!this.isDisabled&&t.button==0)return this.interactionStart(t.target,t.clientX,t.clientY,!1),!1}handleTouchStart(t){if(t.preventDefault(),!this.isDisabled)return t.targetTouches.length!=1||this.interactionStart(t.target,t.touches[0].pageX,t.touches[0].pageY,!0),!1}interactionStart(t,i,s,n){const r=this.getClosestElement(t,"draggable");this.itemStart=r.parentNode,this.isItemStartSource=this.itemStart.classList.contains("source"),this.identifyTargets(this.itemStart,!0),this.itemTarget=null;const a=r.getBoundingClientRect();this.initialX=i,this.initialY=s,this.startingX=a.left,this.startingY=a.top,this.offsetX=i-this.startingX,this.offsetY=s-this.startingY,this.addPlaceholder(r),r.style.userSelect="none",r.style.width=a.width+"px",r.style.height=a.height+"px",r.style.transform=`translateX(${a.left}px) translateY(${a.top}px) translateZ(0)`,r.classList.add("dragging"),this.setCurrentDragger(r),this.addListeners(r,n)}handleDragMove(t){t.preventDefault(),!this.isDisabled&&this.interactionMove(t.clientX,t.clientY)}handleTouchMove(t){t.preventDefault(),!this.isDisabled&&t.targetTouches.length==1&&this.interactionMove(t.touches[0].clientX,t.touches[0].clientY)}interactionMove(t,i){const s=this.currentDragger;this.offsetX=t-this.initialX,this.offsetY=i-this.initialY,this.constrainDraggerToWrapper(s,this.wrapper),s.style.transform=`translateX(${this.startingX+this.offsetX}px) translateY(${this.startingY+this.offsetY}px) translateZ(0) scale(1)`;const n=s.getBoundingClientRect();this.findDraggerItemTarget(s,n,this.targets),this.isItemStartSource||this.findSourceDraggerTarget(s,n)}constrainDraggerToWrapper(t,i){const s=t.getBoundingClientRect(),n=i.getBoundingClientRect(),r=this.startingX+this.offsetX-n.x,a=this.startingY+this.offsetY-n.y,o=this.startingX+s.width+this.offsetX-(n.x+n.width),u=this.startingY+s.height+this.offsetY-(n.y+n.height);r<0&&(this.offsetX=this.offsetX-r),o>0&&(this.offsetX=this.offsetX-o),a<0&&(this.offsetY=this.offsetY-a),u>0&&(this.offsetY=this.offsetY-u)}handleDragEnd(t){this.isDisabled||this.interactionEnd(t.clientX,t.clientY,!1)}handleTouchEnd(t){this.isDisabled||this.interactionEnd(t.changedTouches[0].clientX,t.changedTouches[0].clientY,!0)}interactionEnd(t,i,s){const n=this.currentDragger;if(this.itemTarget===null?n.style.transform=`translateX(${this.startingX}px) translateY(${this.startingY}px) translateZ(0)`:n.style.transform=`translateX(${this.startingX+this.offsetX}px) translateY(${this.startingY+this.offsetY}px) translateZ(0)`,n.removeAttribute("style"),n.classList.remove("dragging"),this.clearTargetHighlights(),this.itemTarget===null){this.resetDraggerToItemStart(this.itemStart,n),this.setCurrentDragger(null),this.removeListeners(n,s);return}if(this.itemTarget.classList.contains("active")){if(this.itemTarget.classList.remove("active"),this.isExceedingMaxAssociations(this.itemStart,this.itemTarget,n)){this.resetDraggerToItemStart(this.itemStart,n),this.notifyAssociationsLimit(),this.setCurrentDragger(null),this.removeListeners(n,s);return}if(this.itemStart.getAttribute("data-identifier")===this.itemTarget.getAttribute("data-identifier")){this.resetDraggerToItemStart(this.itemStart,n),this.setCurrentDragger(null),this.removeListeners(n,s);return}this.removePlaceholder(n),this.setDraggerToItemTarget(this.itemTarget,n),this.itemTarget.classList.contains("source")&&(this.itemTarget.classList.add("full"),this.itemTarget.dataset.matchMax*1>0&&this.incrementRemaining(this.itemTarget),this.decrementAssociationsCount(),this.sortContainerElements(this.sourcewrapper)),this.itemStart.classList.contains("source")&&(this.itemStart.dataset.matchMax*1>0&&this.decrementRemaining(this.itemStart)===0&&this.itemStart.classList.remove("full"),this.incrementAssociationsCount()),this.itemStart.classList.contains("target")&&(this.isTargetFull(this.itemStart)?this.itemStart.classList.add("full"):this.itemStart.classList.remove("full")),this.notifyUpdate()}this.setCurrentDragger(null),this.removeListeners(n,s)}setCurrentDragger(t){this.currentDragger=t}resetDraggerToItemStart(t,i){this.replacePlaceholder(i),t.classList.contains("source")||i.setAttribute("style","width:100%")}setDraggerToItemTarget(t,i){if(t.classList.contains("source")){if(t.classList.contains("full")){const s=t.querySelector(".draggable");s!=null&&t.replaceChild(i,s);return}t.append(i);return}t.append(i),i.setAttribute("style","width:100%"),this.isTargetFull(t)?t.classList.add("full"):t.classList.remove("full")}findDraggerItemTarget(t,i,s){this.itemTarget=null,s.forEach(n=>{const r=n.getBoundingClientRect();if(i.top+t.offsetHeight/2<r.bottom&&i.right-t.offsetWidth/2>r.left&&i.bottom-t.offsetHeight/2>r.top&&i.left+t.offsetWidth/2<r.right){if(this.isItemStartSource&&n.classList.contains("source")||n.classList.contains("full")||!this.hasMatchingMatchGroup(t.parentNode,n))return;n.classList.add("active"),this.itemTarget=n}else n.classList.remove("active")},this)}findSourceDraggerTarget(t,i){const s=this.sourcewrapper.getBoundingClientRect();if(i.top+t.offsetHeight/2<s.bottom&&i.right-t.offsetWidth/2>s.left&&i.bottom-t.offsetHeight/2>s.top&&i.left+t.offsetWidth/2<s.right){for(let n=0;n<this.sources.length;n++)if(this.sources[n].dataset.identifier===t.dataset.identifier){this.sources[n].classList.add("active"),this.itemTarget=this.sources[n];break}}else for(let n=0;n<this.sources.length;n++)this.sources[n].classList.contains("active")&&this.sources[n].classList.remove("active")}addPlaceholder(t){if(!t.parentNode.classList.contains("source")){this.addPlaceholderElement(t,!1);return}const i=t.parentNode.dataset.matchMax*1;if(i===1){this.addPlaceholderElement(t,!1);return}if(i===0){this.addPlaceholderElement(t,!0);return}if(this.getRemaining(t.parentNode)===1){this.addPlaceholderElement(t,!1);return}this.addPlaceholderElement(t,!0)}addPlaceholderElement(t,i){const s=t.cloneNode(!0);this.deepCloneId(s),i?(s.classList.add("clone"),s.addEventListener("mousedown",this.handleDragStart),s.addEventListener("touchstart",this.handleTouchStart)):s.classList.add("match-dragger-placeholder"),s.classList.add("placeholder-fade"),t.parentNode.insertBefore(s,t)}removePlaceholder(t){if(t.parentNode.classList.contains("target")){const n=t.parentNode.querySelector(".match-dragger-placeholder");if(n===null)return;t.parentNode.removeChild(n);return}const i=t.parentNode.dataset.matchMax*1,s=t.parentNode.querySelector(".match-dragger-placeholder");if(s===null){const n=t.parentNode.querySelector(".clone");if(n===null)return;n.classList.remove("placeholder-fade");return}i!==0&&t.parentNode.removeChild(s)}replacePlaceholder(t){const i=t.parentNode;let s=i.querySelector(".match-dragger-placeholder");if(i.classList.contains("source")){if(s==null&&(s=i.querySelector(".draggable")),s===null)return;i.replaceChild(t,s);return}s!==null&&i.replaceChild(t,s)}addClonePlaceholder(t){const i=t.cloneNode(!0);this.deepCloneId(i),i.classList.add("clone"),t.parentNode.insertBefore(i,t),i.addEventListener("mousedown",this.handleDragStart),i.addEventListener("touchstart",this.handleTouchStart)}initializeSources(t){this.sources=t.querySelectorAll(".source"),this.sources.forEach(i=>{i.classList.add("full");const s=i.dataset.matchMax*1;this.setRemaining(i,s===0?1e3:s)},this),this.draggers=t.querySelectorAll(".draggable"),this.draggers.forEach((i,s)=>{const n=i.parentNode.getAttribute("data-identifier");i.setAttribute("data-identifier",n),i.setAttribute("data-order",s),i.setAttribute("tabindex",0),i.addEventListener("mousedown",this.handleDragStart),i.addEventListener("touchstart",this.handleTouchStart)},this)}initializeTargets(t){this.targets=t.querySelectorAll(".target"),this.targets.forEach(i=>{i.setAttribute("tabindex",0)})}identifyTargets(t,i){this.targets.forEach(s=>{i&&!s.classList.contains("full")&&this.hasMatchingMatchGroup(t,s)&&s.classList.add("target-active")},this),i&&!this.isItemStartSource&&this.sourcewrapper.classList.add("target-active")}addListeners(t,i){i?(this.removeListeners(t,i),t.addEventListener("touchmove",this.handleTouchMove),t.addEventListener("touchend",this.handleTouchEnd)):(this.removeListeners(t,i),document.addEventListener("mousemove",this.handleDragMove),document.addEventListener("mouseup",this.handleDragEnd))}removeListeners(t,i){i?(t.removeEventListener("touchmove",this.handleTouchMove),t.removeEventListener("touchend",this.handleTouchEnd)):(document.removeEventListener("mousemove",this.handleDragMove),document.removeEventListener("mouseup",this.handleDragEnd))}clearTargetHighlights(){this.targets.forEach(t=>{t.classList.remove("target-active")},this),this.sourcewrapper.classList.remove("target-active")}getClosestElement(t,i){return t?t&&t.classList.contains(i)?t:this.getClosestElement(t.parentElement,i):!1}sortContainerElements(t){let i=[],s=t.children;for(let n=0;n<s.length;n++){const r=s[n].querySelector("div.draggable");r&&i.push([1*r.dataset.order,s[n]])}i.sort(function(n,r){return n[0]-r[0]});for(let n=0;n<i.length;n++)t.appendChild(i[n][1])}getResponse(){return this.computeResponse()}computeResponse(){let t=[];return this.targets.forEach(i=>{i.querySelectorAll(".draggable").forEach(s=>{t.push(`${s.dataset.identifier} ${i.dataset.identifier}`)})}),t.length===0?null:this.options.cardinality==="single"?t[0]:t}restoreResponse(t){t!==null&&(this.options.cardinality==="single"?this.restoreResponsePair(t):t.forEach(i=>{this.restoreResponsePair(i)},this))}restoreResponsePair(t){const i=this.getPair(t);if(i===null)return;const s=this.findSourceByIdentifier(i.source),n=this.findTargetGapByIdentifier(i.target);if(s===null||n===null)return;const r=s.querySelector(".draggable");r!==null&&(this.cloneOrEmptySourceDragger(s,r),this.restoreSourceDraggerToTarget(n,r))}cloneOrEmptySourceDragger(t,i){const s=t.dataset.matchMax*1;if(s===1){t.classList.remove("full"),this.decrementRemaining(t);return}if(s===0){this.addClonePlaceholder(i);return}if(this.getRemaining(t)===1){t.classList.remove("full"),this.decrementRemaining(t);return}this.decrementRemaining(t),this.addClonePlaceholder(i)}findSourceByIdentifier(t){for(let i=0;i<this.sources.length;i++)if(t===this.sources[i].dataset.identifier)return this.sources[i];return null}findTargetGapByIdentifier(t){for(let i=0;i<this.targets.length;i++)if(t===this.targets[i].dataset.identifier)return this.targets[i];return null}getPair(t){if(t===null)return null;const i=t.split(" ");return i.length!=2?null:{source:i[0],target:i[1]}}restoreSourceDraggerToTarget(t,i){t===null||i===null||(t.append(i),i.setAttribute("style","width:100%"),this.incrementAssociationsCount(),this.isTargetFull(t)&&t.classList.add("full"))}hasMatchingMatchGroup(t,i){return t===null||i===null?!1:t.dataset.matchGroup===i.dataset.matchGroup}isTargetFull(t){if(t==null)return!1;const i=t.querySelectorAll(".draggable"),s=t.dataset.matchMax*1;return s===0?!1:i.length>=s}isExceedingMaxAssociations(t,i){return!(this.options.maxAssociations===0||i.classList.contains("source")||t.classList.contains("target")||this.currentAssociationsCount<this.options.maxAssociations)}initializeAssociationsCount(){this.currentAssociationsCount=0}incrementAssociationsCount(){this.currentAssociationsCount+=1}decrementAssociationsCount(){this.currentAssociationsCount!==0&&(this.currentAssociationsCount-=1)}getRemaining(t){return t.dataset.remaining*1}setRemaining(t,i){t.setAttribute("data-remaining",i)}incrementRemaining(t){const i=t.dataset.remaining*1+1;return t.setAttribute("data-remaining",i),i}decrementRemaining(t){let i=t.dataset.remaining*1-1;return i=i>=0?i:0,t.setAttribute("data-remaining",i),i}deepCloneId(t){t.id&&(t.id=`clone_${this.qtiAttributeValidation.randomString(5,"a")}`);for(let i=0;i<t.children.length;i++)this.deepCloneId(t.children[i])}reset(){this.resetDraggersToSources(),this.initializeAssociationsCount(),this.destroy()}resetDraggersToSources(){this.targets.forEach(t=>{t.querySelectorAll(".draggable").forEach(s=>{const n=this.findSourceByIdentifier(s.getAttribute("data-identifier"));n.classList.contains("full")||(t.classList.remove("full"),n.classList.contains("full")?t.removeChild(s):(n.append(s),n.classList.add("full")))},this)},this)}destroy(){this.currentDragger!==null&&(document.removeEventListener("mousemove",this.handleDragMove),document.removeEventListener("mouseup",this.handleDragEnd)),this.wrapper.querySelectorAll(".draggable").forEach(i=>{i.removeEventListener("touchstart",this.handleTouchStart),i.removeEventListener("touchmove",this.handleTouchMove),i.removeEventListener("touchend",this.handleTouchEnd),i.removeEventListener("mousedown",this.handleDragStart)},this)}}class Oq{constructor(t,i){ee(this,"options",{interactionSubType:"matchtabular",isHeaderHidden:!1,isRowCentric:!1,firstColumnHeader:null,cardinality:"single",maxAssociations:0,response:null,onReady:null,onUpdate:null,onSelectionsLimit:null});ee(this,"keyCodes",{Enter:13,Space:32,End:35,Home:36,ArrowLeft:37,ArrowUp:38,ArrowRight:39,ArrowDown:40});return this.wrapper=t,this.table=this.wrapper.querySelector("table.matchtabular"),this.sourcewrapper=this.wrapper.querySelector(".qti-match-source-wrapper"),this.targetwrapper=this.wrapper.querySelector(".qti-match-target-wrapper"),this.currentAssociationsCount=0,this.isDisabled=!1,this.processOptions(i),this.handleClick=this.handleClick.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.handleFocus=this.handleFocus.bind(this),this.handleBlur=this.handleBlur.bind(this),this.state=new Map,this.initializeTable(this.sourcewrapper,this.targetwrapper),this.restoreResponse(),this.notifyReady(),this}processOptions(t){"interactionSubType"in t&&(this.options.interactionSubType=t.interactionSubType),"isHeaderHidden"in t&&(this.options.isHeaderHidden=t.isHeaderHidden),"isRowCentric"in t&&(this.options.isRowCentric=t.isRowCentric),"firstColumnHeader"in t&&(this.options.firstColumnHeader=t.firstColumnHeader),"cardinality"in t&&(this.options.cardinality=t.cardinality),"response"in t&&(this.options.response=t.response),"maxAssociations"in t&&(this.options.maxAssociations=t.maxAssociations),"onReady"in t&&(this.options.onReady=t.onReady),"onUpdate"in t&&(this.options.onUpdate=t.onUpdate),"onAssociationsLimit"in t&&(this.options.onAssociationsLimit=t.onAssociationsLimit)}notifyReady(){this.options.onReady!==null&&this.options.onReady({response:this.getResponse()})}notifyUpdate(){this.options.onUpdate!==null&&this.options.onUpdate({response:this.computeResponse()})}notifyAssociationsLimit(){this.options.onAssociationsLimit!==null&&this.options.onAssociationsLimit()}toggleDisable(t){this.isDisabled=t,this.controls.forEach(i=>{t?i.classList.add("disabled"):i.classList.remove("disabled")})}handleClick(t){if(!this.isDisabled){if(this.isRadio(t.target)){this.setControlChecked(t.target);return}this.toggleControl(t.target)}}handleKeydown(t){let i=!1;switch(t.code){case"Space":case"Enter":this.isDisabled||this.toggleControl(t.target),i=!0;break;case"ArrowUp":case"ArrowLeft":i=!0;break;case"ArrowDown":case"ArrowRight":i=!0;break}i&&(t.stopPropagation(),t.preventDefault())}handleFocus(){}handleBlur(){}toggleControl(t){if(!this.isChecked(t)){if(this.isExceedingMaxAssociations()){this.notifyAssociationsLimit();return}if(this.isExceedingMatchMax(t.dataset.pair,t.dataset.sourceMax*1,!0)||this.isExceedingMatchMax(t.dataset.pair,t.dataset.targetMax*1,!1))return;this.updateState(t.dataset.pair,this.toggleChecked(t)),this.notifyUpdate();return}this.updateState(t.dataset.pair,this.toggleChecked(t)),this.notifyUpdate()}setControlChecked(t){if(!this.isChecked(t)){if(this.isExceedingMaxAssociations()){this.notifyAssociationsLimit();return}if(this.isExceedingMatchMax(t.dataset.pair,t.dataset.sourceMax*1,!0)||this.isExceedingMatchMax(t.dataset.pair,t.dataset.targetMax*1,!1))return;this.updateState(t.dataset.pair,this.setChecked(t,!0)),this.notifyUpdate();return}this.updateState(t.dataset.pair,this.setChecked(t,!0)),this.notifyUpdate()}setChecked(t,i){const s=i?"true":"false";return t.setAttribute("aria-checked",s),s}toggleChecked(t){const s=t.getAttribute("aria-checked")==="true"?"false":"true";return t.setAttribute("aria-checked",s),s}isRadio(t){return t===null?!1:t.getAttribute("role")==="radio"}isChecked(t){return t===null?!1:t.getAttribute("aria-checked")==="true"}setTabIndex(t){this.tabIndex=t}setFocus(){}setBlur(){}updateState(t,i){this.state.set(t,i),this.currentAssociationsCount=0;for(let s of this.state.values())s==="true"&&(this.currentAssociationsCount+=1)}initializeTable(t,i){this.sources=this.getChoices(t),this.targets=this.getChoices(i);const s=`width:${this.getColumnWidthPercentage(this.targets.length)}%`;this.table.innerHTML=`${this.getHeader(s)}${this.getBody(s)}`,this.controls=this.table.querySelectorAll(".control-cell"),this.controls.forEach(n=>{const r=n.getAttribute("data-pair");this.updateState(r,"false"),n.addEventListener("click",this.handleClick),n.addEventListener("keydown",this.handleKeydown),n.addEventListener("focus",this.handleFocus),n.addEventListener("blur",this.handleBlur)},this)}getHeader(t){if(this.options.isHeaderHidden)return"";let i=`<th scope="col" class="header-cell">${this.options.firstColumnHeader==null?"":this.options.firstColumnHeader}</th>`;return this.options.isRowCentric?(i+=this.getSourceHeader(t),`<thead>${i}</thead>`):(i+=this.getTargetHeader(t),`<thead>${i}</thead>`)}getTargetHeader(t){let i="";return this.targets.forEach(s=>{i+=`<th scope="col" class="header-cell" style="${t}">${s.innerHTML}</th>`}),i}getSourceHeader(t){let i="";return this.sources.forEach(s=>{i+=`<th scope="col" class="header-cell" style="${t}">${s.innerHTML}</th>`}),i}getBody(t){let i="";return this.options.isRowCentric?(this.targets.forEach(s=>{i+=`<tr><th scope="row" class="row-header-cell">${s.innerHTML}</th>`;const n=s.getAttribute("data-match-max");this.sources.forEach(r=>{const a=r.getAttribute("data-match-max"),o=r.getAttribute("data-identifier"),u=s.getAttribute("data-identifier"),h=`${o} ${u}`;i+=`<td class="table-cell" style="${t}">
|
167
|
+
</svg>`;const t={theme:"snow",boundary:"div.qti-extended-text-interaction",modules:{toolbar:{container:[["undo","redo"],["bold","italic","underline"],["blockquote"],[{list:"ordered"},{list:"bullet"}]],handlers:{redo(){this.quill.history.redo()},undo(){this.quill.history.undo()}}},history:{delay:2e3,maxStack:100,userOnly:!1},keyboard:{bindings:{tab:{key:9,handler:function(){return!0}}}}},placeholder:this.placeholder,readOnly:!1};this.quill=new X(this.$refs.editor,t),this.quill.root.setAttribute("spellcheck",!1),this.quill.on("text-change",this.textChangeHandler),this.updateCounter(this.getLength()),this.quill.enable(!0)}},setQuillEditorStyleProperties(){this.$refs.editor!=null&&this.$refs.editor.children!=null&&this.$refs.editor.children.length>0&&(this.$refs.editor.children[0].style=`width:${this.editorHeight};overflow-x:auto;`)},textChangeHandler(){let e=this.getText(),t=this.$refs.editor.children[0].innerHTML,i=this.getLength();if(this.expectedLength&&i>this.expectedLength){this.quill.deleteText(this.expectedLength,i);return}t==="<p><br></p>"&&(t=""),this.updateCounter(this.getLength()),this.$emit("input",{html:t,text:e})},updateCounter(e){if(this.showCounter){if(this.isCounterUp){this.counter=e;return}this.counter=this.computedExpectedLength-e}},getLength(){return this.quill.getLength()-1},getText(){return this.quill.getText()}},mounted(){this.initialize(),this.setQuillEditorStyleProperties(),this.$emit("editorReady",{node:this})},beforeUnmount(){this.$el&&this.quill.off("text-change",this.textChangeHandler),this.$el.remove(),this.quill=void 0}},zR={ref:"root",class:"quill-editor vertical-rl"},KR={key:0,"aria-hidden":"true",class:"ext-text-xhtml-vert-rl-counter"},YR={key:0};function XR(e,t,i,s,n,r){return l.openBlock(),l.createElementBlock("div",zR,[l.createElementVNode("div",{ref:"label",style:l.normalizeStyle(r.styleLabel),class:"ext-text-xhtml-vert-label qti-hidden"},null,4),l.createElementVNode("div",{ref:"editor",style:l.normalizeStyle(r.style)},null,4),r.showCounter?(l.openBlock(),l.createElementBlock("div",KR,[l.createTextVNode(l.toDisplayString(n.counter),1),r.isCounterUp?(l.openBlock(),l.createElementBlock("span",YR," / "+l.toDisplayString(i.expectedLength),1)):l.createCommentVNode("",!0)])):l.createCommentVNode("",!0)],512)}const ZR={name:"ExtendedTextXhtmlVerticalRl",components:{EditorQuillVerticalRl:P(WR,[["render",XR]])},props:{responseIdentifier:{required:!0,type:String},expectedLength:{required:!1,type:String},placeholder:{required:!1,type:String,default:""},heightClass:{required:!1,type:String,default:""},counterStyle:{required:!1,type:String,default:"none"}},computed:{computedExpectedLength(){return typeof this.expectedLength<"u"?this.expectedLength:"400"},colorStyle(){return I.getItemContextPnp().getColorStyle()},editorHeight(){return this.heightClass==="qti-height-lines-15"?"25.9rem":this.heightClass==="qti-height-lines-6"?"11.5rem":"6.7rem"},labelHeight(){return this.heightClass==="qti-height-lines-15"?"29.7rem":this.heightClass==="qti-height-lines-6"?"12.3rem":"6.6rem"},maxLength(){return 1e4},disabled(){return this.isDisabled}},data(){return{response:"",content:"",state:null,editor:null,isDisabled:!1}},inheritAttrs:!1,methods:{getResponse(){return this.response},setResponse(e){if(e===null){this.response="",this.setContent("");return}this.setContent(e),this.response=e},updateResponse(e){this.response=e},getState(){return this.state},setState(e){this.state=e},getContent(){return this.content},setContent(e){this.content=e},computeState(e){return{text:e}},setIsDisabled(e){this.isDisabled=e},handleInput(e){e.html&&(this.updateResponse(e.html),this.setState(this.computeState(e.text)),this.$parent.$emit("extendedTextUpdate",{response:this.getResponse()}))},handleEditorReady(e){this.node=e.node,this.$parent.$emit("extendedTextReady",{node:this})}},mounted(){}},JR={ref:"root"};function ek(e,t,i,s,n,r){const a=l.resolveComponent("EditorQuillVerticalRl");return l.openBlock(),l.createElementBlock("div",JR,[l.createVNode(a,{content:n.content,placeholder:i.placeholder,editorHeight:r.editorHeight,labelHeight:r.labelHeight,counterStyle:i.counterStyle,expectedLength:r.computedExpectedLength,disabled:r.disabled,onInput:r.handleInput,onEditorReady:r.handleEditorReady},null,8,["content","placeholder","editorHeight","labelHeight","counterStyle","expectedLength","disabled","onInput","onEditorReady"])],512)}const tk=P(ZR,[["render",ek]]),jt={DEFAULT:"default-plain",DEFAULT_SBAC:"sbac-plain",DEFAULT_LRN:"lrn-plain",DEFAULT_VERTICAL_RL:"vertical-rl-plain",XHTML_DEFAULT:"default-xhtml",XHTML_SBAC:"sbac-xhtml",XHTML_VERTICAL_RL:"vertical-rl-xhtml"};function ik(e,t,i){switch(e){case jt.XHTML_DEFAULT:case jt.XHTML_SBAC:return{template:'<extended-text-xhtml-default response-identifier="'+t.responseIdentifier+'" '+Aa(t)+Ia(t)+_a(t)+Va(t)+$a(t)+La(t)+Ma(i)+" />",components:{ExtendedTextXhtmlDefault:jR}};case jt.DEFAULT_LRN:return{template:'<extended-text-plain-lrn response-identifier="'+t.responseIdentifier+'" '+Aa(t)+Ia(t)+_a(t)+Va(t)+$a(t)+La(t)+Ma(i)+" />",components:{ExtendedTextPlainLrn:uV}};case jt.DEFAULT_VERTICAL_RL:return{template:'<extended-text-plain-vertical-rl response-identifier="'+t.responseIdentifier+'" '+Aa(t)+Ia(t)+_a(t)+Va(t)+$a(t)+La(t)+Ma(i)+" />",components:{ExtendedTextPlainVerticalRl:bV}};case jt.XHTML_VERTICAL_RL:return{template:'<extended-text-xhtml-vertical-rl response-identifier="'+t.responseIdentifier+'" '+Aa(t)+Ia(t)+_a(t)+Va(t)+$a(t)+La(t)+Ma(i)+" />",components:{ExtendedTextXhtmlVerticalRl:tk}};default:return{template:'<extended-text-plain-default response-identifier="'+t.responseIdentifier+'" '+Aa(t)+Ia(t)+_a(t)+Va(t)+$a(t)+La(t)+Ma(i)+" />",components:{ExtendedTextPlainDefault:J_}}}}function sk(e,t){const i=nk(e);if(i&&t==="plain")return jt.DEFAULT_SBAC;if(i&&t==="xhtml")return jt.XHTML_DEFAULT;if(rk(e)&&t==="plain")return jt.DEFAULT_LRN;const n=ak(e);return n&&t==="plain"?jt.DEFAULT_VERTICAL_RL:n&&t==="xhtml"?jt.XHTML_VERTICAL_RL:t==="plain"?jt.DEFAULT:t==="xhtml"?jt.XHTML_DEFAULT:jt.DEFAULT}function Ia(e){return typeof e.patternMask>"u"?"":'pattern-mask="'+e.patternMask+'" '}function _a(e){return'pattern-mask-message="'+e.patternMaskMessage+'" '}function Va(e){return'placeholder="'+e.placeholder+'" '}function Aa(e){return typeof e.expectedLength>"u"?"":'expected-length="'+e.expectedLength+'" '}function $a(e){return typeof e.heightClass>"u"?"":'height-class="'+e.heightClass+'" '}function La(e){return typeof e.counterStyle>"u"?"none":'counter-style="'+e.counterStyle+'" '}function Ma(e){let t="";for(const[i,s]of Object.entries(e))t+=`${i}="${s}" `;return t}function nk(e){return typeof e>"u"||e===null||e.length==0?!1:Ph("sbac",e)}function rk(e){return typeof e>"u"||e===null||e.length==0?!1:Ph("lrn",e)}function ak(e){return typeof e>"u"||e===null||e.length==0?!1:Ph("qti-writing-orientation-vertical-rl",e)}function Ph(e,t){const i=t.split(" ");for(let s=0;s<i.length;s++)if(i[s]===e)return!0;return!1}const Na=new F,ok=new te,lk={name:"QtiExtendedTextInteraction",props:{responseIdentifier:{required:!0,type:String},expectedLength:{required:!1,type:String},patternMask:{required:!1,type:String},placeholderText:{required:!1,type:String},format:{required:!1,type:String,default:"plain"},dataPatternmaskMessage:{required:!1,type:String},minStrings:{required:!1,type:String,default:"0"},maxStrings:{required:!1,type:String,default:"0"}},computed:{interactionTemplate(){return ik(this.interactionSubType,this.createComponentProperties(),this.$attrs)},placeholder(){return Na.validatePlaceholderText(this.placeholderText,"")},hasPatternMask(){return typeof this.patternMask<"u"},patternMaskMessage(){return Na.validatePatternmaskMessage(this.dataPatternmaskMessage,"Invalid Input")}},data(){return{response:"",state:null,baseType:"string",cardinality:"single",interactionSubType:null,isValidResponse:!1,invalidResponseMessage:"Input Required",classAttribute:"",isDisabled:!1,isQtiValid:!0,hasPrompts:!1,presentationFactory:null,node:null,priorState:null}},methods:{getResponse(){return this.response.length===0?null:this.response},setResponse(e){e===null?this.response="":this.response=e,this.node.setResponse(this.response,!0)},updateResponse(e){e===null?this.response="":this.response=e},getState(){return this.state},setState(e){this.state=e,this.node.setState(this.state,!0)},updateState(e){this.state=e},getIsValid(){return this.isValidResponse},setIsValid(e){this.isValidResponse=e},setInteractionSubType(e){this.interactionSubType=e},getInteractionSubType(){return this.interactionSubType},disable(){this.toggleDisable(!0)},enable(){this.toggleDisable(!1)},toggleDisable(e){this.isDisabled=e,this.node.setIsDisabled(e)},getInvalidResponseMessage(){return this.invalidResponseMessage},initializeValue(){this.setResponse(null),this.setState(this.computeState()),this.setIsValid(this.computeIsValid())},resetValue(){console.log("[ResetValue][identifier]",this.responseIdentifier),this.setResponse(null),this.setState(this.computeState()),this.setIsValid(this.computeIsValid())},restoreValue(e){this.setResponse(e.value),this.setState(e.state),this.updateValidity(this.computeIsValid())},getCardinality(){return this.cardinality},computeState(){return{}},computeIsValid(){const e=this.minStrings*1;if(e===0)return!0;if(this.response===null)return!1;const t=this.response.trim();return!(t.length<1||ok.computeWordCount(t)<e)},evaluateValidity(){const e=this.getIsValid(),t=this.computeIsValid();e!==t&&this.updateValidity(t)},updateValidity(e){this.setIsValid(e),I.setInteractionIsValidResponse({identifier:this.responseIdentifier,isValidResponse:e})},getPrompts(e){let t=[];return e.default&&e.default().forEach(i=>{typeof i.type<"u"&&i.type.name==="QtiPrompt"&&t.push(i)}),t},detectInteractionSubType(e,t){return sk(e,t)},createComponentProperties(){return{responseIdentifier:this.responseIdentifier,expectedLength:this.presentationFactory.getExpectedLength(),placeholder:this.placeholder,patternMask:this.patternMask,patternMaskMessage:this.patternMaskMessage,heightClass:this.presentationFactory.getHeightClass(),counterStyle:this.presentationFactory.getCounterStyle()}},handleExtendedTextUpdate(e){this.updateResponse(e.response),"state"in e&&this.updateState(e.state),this.evaluateValidity()},handleExtendedTextReady(e){this.node=e.node,this.priorState===null?this.initializeValue():this.restoreValue(this.priorState)},getPriorState(e){const t=I.getItemContextStateVariable(e);if(t===null)return null;if(!("value"in t))throw new O('Extended Text Interaction State Invalid. "value" property not found.');if(!("state"in t))throw new O('Extended Text Interaction State Invalid. "state" property not found.');return t}},created(){try{this.responseDeclaration=Na.validateResponseIdentifierAttribute(I,this.responseIdentifier),this.setInteractionSubType(this.detectInteractionSubType(this.$.vnode.props.class,this.format)),this.presentationFactory=new lI(this.$.vnode.props.class,this.expectedLength),Na.validateMaxMinStrings(this.maxStrings,this.minStrings),this.priorState=this.getPriorState(this.responseIdentifier),this.cardinality=this.getCardinality(),this.hasPrompts=this.getPrompts(this.$slots).length>0,this.appliedRegex=Na.validatePattern("pattern-mask",this.patternMask)}catch(e){throw this.isQtiValid=!1,e.name==="QtiValidationException"?new c(e.message):e.name==="QtiParseException"?new ie(e.message):new Error(e.message)}},mounted(){if(this.isQtiValid)try{I.defineInteraction({identifier:this.responseIdentifier,interactionType:"ExtendedText",interactionSubType:this.interactionSubType,node:this,resetValue:this.resetValue,isValidResponse:this.isValidResponse,invalidResponseMessage:this.getInvalidResponseMessage()}),console.log("["+this.$options.name+"][Identifier]",this.responseIdentifier)}catch(e){throw this.isQtiValid=!1,console.log("["+this.$options.name+"][ValidationError]",e.name,e.message),new c(e.message)}}},ck={ref:"root",class:"qti-extended-text-interaction"},uk={ref:"prompt",class:"qti-prompt-wrapper"};function hk(e,t,i,s,n,r){return l.openBlock(),l.createElementBlock("div",ck,[l.createElementVNode("div",uk,[l.renderSlot(e.$slots,"default")],512),(l.openBlock(),l.createBlock(l.resolveDynamicComponent(r.interactionTemplate),{ref:"textarea",onExtendedTextUpdate:r.handleExtendedTextUpdate,onExtendedTextReady:r.handleExtendedTextReady},null,40,["onExtendedTextUpdate","onExtendedTextReady"]))],512)}const dk=P(lk,[["render",hk]]);class fk{constructor(t){return this.constants={QTI_ORIENTATION_HORIZONTAL:"qti-orientation-horizontal",QTI_ORIENTATION_VERTICAL:"qti-orientation-vertical",QTI_INPUT_WIDTH_DEFAULT:"",QTI_INPUT_WIDTH_1:"qti-input-width-1",QTI_INPUT_WIDTH_2:"qti-input-width-2",QTI_INPUT_WIDTH_3:"qti-input-width-3",QTI_INPUT_WIDTH_4:"qti-input-width-4",QTI_INPUT_WIDTH_5:"qti-input-width-5",QTI_INPUT_WIDTH_6:"qti-input-width-6",QTI_INPUT_WIDTH_10:"qti-input-width-10",QTI_INPUT_WIDTH_15:"qti-input-width-15",QTI_INPUT_WIDTH_20:"qti-input-width-20",QTI_INPUT_WIDTH_25:"qti-input-width-25",QTI_INPUT_WIDTH_30:"qti-input-width-30",QTI_INPUT_WIDTH_35:"qti-input-width-35",QTI_INPUT_WIDTH_40:"qti-input-width-40",QTI_INPUT_WIDTH_45:"qti-input-width-45",QTI_INPUT_WIDTH_50:"qti-input-width-50",QTI_INPUT_WIDTH_72:"qti-input-width-72"},this.classList=t,this.presentation_OrientationClass=this.constants.QTI_ORIENTATION_HORIZONTAL,this.presentation_WidthClass=this.constants.QTI_INPUT_WIDTH_DEFAULT,this.presentation_MaxLength=8,this.processClassAttribute(),this}processClassAttribute(){if(typeof this.classList>"u"||this.classList===null||this.classList.length==0)return;const t=this.classList.split(" ");for(let i=0;i<t.length;i++)switch(t[i]){case this.constants.QTI_ORIENTATION_VERTICAL:this.presentation_OrientationClass=this.constants.QTI_ORIENTATION_VERTICAL;break;case this.constants.QTI_ORIENTATION_HORIZONTAL:this.presentation_OrientationClass=this.constants.QTI_ORIENTATION_HORIZONTAL;break;case this.constants.QTI_INPUT_WIDTH_1:this.presentation_WidthClass=this.constants.QTI_INPUT_WIDTH_1,this.presentation_MaxLength=1;break;case this.constants.QTI_INPUT_WIDTH_2:this.presentation_WidthClass=this.constants.QTI_INPUT_WIDTH_2,this.presentation_MaxLength=2;break;case this.constants.QTI_INPUT_WIDTH_3:this.presentation_WidthClass=this.constants.QTI_INPUT_WIDTH_3,this.presentation_MaxLength=3;break;case this.constants.QTI_INPUT_WIDTH_4:this.presentation_WidthClass=this.constants.QTI_INPUT_WIDTH_4,this.presentation_MaxLength=4;break;case this.constants.QTI_INPUT_WIDTH_5:this.presentation_WidthClass=this.constants.QTI_INPUT_WIDTH_5,this.presentation_MaxLength=5;break;case this.constants.QTI_INPUT_WIDTH_6:this.presentation_WidthClass=this.constants.QTI_INPUT_WIDTH_6,this.presentation_MaxLength=6;break;case this.constants.QTI_INPUT_WIDTH_10:this.presentation_WidthClass=this.constants.QTI_INPUT_WIDTH_10,this.presentation_MaxLength=10;break;case this.constants.QTI_INPUT_WIDTH_15:this.presentation_WidthClass=this.constants.QTI_INPUT_WIDTH_15,this.presentation_MaxLength=15;break;case this.constants.QTI_INPUT_WIDTH_20:this.presentation_WidthClass=this.constants.QTI_INPUT_WIDTH_20,this.presentation_MaxLength=20;break;case this.constants.QTI_INPUT_WIDTH_25:this.presentation_WidthClass=this.constants.QTI_INPUT_WIDTH_25,this.presentation_MaxLength=25;break;case this.constants.QTI_INPUT_WIDTH_30:this.presentation_WidthClass=this.constants.QTI_INPUT_WIDTH_30,this.presentation_MaxLength=30;break;case this.constants.QTI_INPUT_WIDTH_35:this.presentation_WidthClass=this.constants.QTI_INPUT_WIDTH_35,this.presentation_MaxLength=35;break;case this.constants.QTI_INPUT_WIDTH_40:this.presentation_WidthClass=this.constants.QTI_INPUT_WIDTH_40,this.presentation_MaxLength=40;break;case this.constants.QTI_INPUT_WIDTH_45:this.presentation_WidthClass=this.constants.QTI_INPUT_WIDTH_45,this.presentation_MaxLength=45;break;case this.constants.QTI_INPUT_WIDTH_50:this.presentation_WidthClass=this.constants.QTI_INPUT_WIDTH_50,this.presentation_MaxLength=50;break;case this.constants.QTI_INPUT_WIDTH_72:this.presentation_WidthClass=this.constants.QTI_INPUT_WIDTH_72,this.presentation_MaxLength=500;break}}getOrientationClass(){return this.presentation_OrientationClass}isOrientationVertical(){return this.presentation_OrientationClass==this.constants.QTI_ORIENTATION_VERTICAL}getWidthClass(){return this.presentation_WidthClass}getVerticalMaxLength(){return this.presentation_MaxLength}}const pk=new F,mk={name:"TextEntryPlainDefault",emits:["textEntryReady","textEntryUpdate"],components:{Tooltip:ra},props:{responseIdentifier:{required:!0,type:String},expectedLength:{required:!1,type:String},placeholder:{required:!1,type:String,default:""},patternMask:{required:!1,type:String},patternMaskMessage:{required:!1,type:String,default:"Invalid Input"},spellcheck:{required:!1,type:String,default:"false"},maxlength:{required:!1,type:String,default:"500"}},computed:{computedExpectedLength(){return typeof this.expectedLength<"u"?this.expectedLength*1:400},hasPatternMask(){return typeof this.patternMask<"u"},colorStyle(){return I.getItemContextPnp().getColorStyle()},disabled(){return this.isDisabled}},data(){return{response:"",priorResponse:"",appliedRegex:null,displayMessage:!1,isDisabled:!1}},methods:{getResponse(){return this.response},setResponse(e){if(e===null){this.response="";return}this.response=e},getState(){return this.state},setState(e){this.state=e},setIsDisabled(e){if(this.isDisabled=e,e){const t=this.getResponse();this.$refs.label.innerHTML=t===null?"":t,this.$refs.label.classList.remove("qti-hidden"),this.$refs.label.setAttribute("tabIndex",0),this.$refs.input.classList.add("qti-hidden"),(t===null||t.length===0)&&(this.$refs.label.style.paddingRight="1.1rem")}else this.$refs.label.classList.add("qti-hidden"),this.$refs.label.setAttribute("tabIndex",-1),this.$refs.input.classList.remove("qti-hidden")},handleInput(e){e.preventDefault();let t=!0;this.appliedRegex!==null?t=this.applyPatternMask(this.$refs.input.value):this.setResponse(this.$refs.input.value),t&&(this.priorResponse=this.$refs.input.value,this.$parent.$emit("textEntryUpdate",{response:this.getResponse()}))},getLength(){return this.response.length},applyPatternMask(e){return this.appliedRegex.test(e)?(this.setResponse(e),this.priorResponse=e,!0):(this.showPatternMaskMessage(),this.setResponse(this.priorResponse),!1)},showPatternMaskMessage(){this.$refs.tooltip.show(),this.hidePatternMaskMessage()},hidePatternMaskMessage(e=3e3){setTimeout(()=>{this.$refs.tooltip.hide()},e)}},created(){this.appliedRegex=pk.validatePattern("pattern-mask",this.patternMask)},mounted(){this.$parent.$emit("textEntryReady",{node:this})}},gk={ref:"root"},yk={ref:"label",class:"text-entry-default-label qti-hidden"},wk=["placeholder","disabled","spellcheck","maxlength"];function bk(e,t,i,s,n,r){const a=l.resolveComponent("tooltip");return l.openBlock(),l.createElementBlock("span",gk,[l.createElementVNode("span",yk,null,512),l.withDirectives(l.createElementVNode("input",l.mergeProps({ref:"input",class:"text-entry-default"},e.$attrs,{"onUpdate:modelValue":t[0]||(t[0]=o=>n.response=o),type:"text",placeholder:i.placeholder,disabled:r.disabled,autocapitalize:"none",spellcheck:i.spellcheck,maxlength:i.maxlength,onInput:t[1]||(t[1]=(...o)=>r.handleInput&&r.handleInput(...o))}),null,16,wk),[[l.vModelText,n.response]]),r.hasPatternMask?(l.openBlock(),l.createBlock(a,{key:0,ref:"tooltip",target:()=>e.$refs.input,message:i.patternMaskMessage,"color-style":r.colorStyle},null,8,["target","message","color-style"])):l.createCommentVNode("",!0)],512)}const pw=P(mk,[["render",bk]]),vk=new F,Ek={name:"TextEntryPlainDefaultVertical",emits:["textEntryReady","textEntryUpdate"],components:{Tooltip:ra},props:{responseIdentifier:{required:!0,type:String},expectedLength:{required:!1,type:String},placeholder:{required:!1,type:String,default:""},patternMask:{required:!1,type:String},patternMaskMessage:{required:!1,type:String,default:"Invalid Input"},spellcheck:{required:!1,type:String,default:"false"},widthClass:{required:!1,type:String,default:""},maxlength:{required:!1,type:String,default:"8"}},computed:{computedExpectedLength(){return typeof this.expectedLength<"u"?this.expectedLength*1:400},hasPatternMask(){return typeof this.patternMask<"u"},colorStyle(){return I.getItemContextPnp().getColorStyle()},disabled(){return this.isDisabled}},data(){return{response:"",priorResponse:"",appliedRegex:null,displayMessage:!1,caretIndex:0,maxlengthMessage:"",isDisabled:!1}},inheritAttrs:!1,methods:{getResponse(){return this.response},setResponse(e,t=!1){e===null?this.response="":this.response=e,t&&this.updateContent(this.response)},getState(){return this.state},setState(e){this.state=e},setIsDisabled(e){if(this.isDisabled=e,e){const t=this.getResponse();this.$refs.label.innerHTML=t===null?"":t,this.$refs.label.classList.remove("qti-hidden"),this.$refs.label.setAttribute("tabIndex",0),this.$refs.input.classList.add("qti-hidden"),this.hidePlaceholder()}else this.$refs.label.classList.add("qti-hidden"),this.$refs.label.setAttribute("tabIndex",-1),this.$refs.input.classList.remove("qti-hidden"),this.getContent().length===0?this.showPlaceholder():this.hidePlaceholder()},getContent(){return this.$refs.input.innerText},updateContent(e){this.$refs.input.innerText=e,e.length>0?this.hidePlaceholder():this.showPlaceholder()},getCaretIndex(){return this.caretIndex},setCaretIndex(e){this.caretIndex=e},handleInput(e){e.preventDefault();let t=!0;this.setCaretIndex(this.getCaretPos(this.$refs.input)-1);const i=this.getContent();i.length>0&&this.hidePlaceholder(),this.applyLimitCheck(i)&&(this.appliedRegex!==null?t=this.applyPatternMask(i):this.setResponse(i),t&&(i.length==0&&this.showPlaceholder(),this.priorResponse=i,this.$parent.$emit("textEntryUpdate",{response:this.getResponse()})))},handlePaste(e){e.preventDefault();const t=this.getRange();if(t===null)return;const i=this.getContent(),s=t.startOffset,n=t.endOffset;let r=e.clipboardData.getData("text/plain"),a=i.substring(0,s)+r+i.substring(n),o=!0;if(a.length>0&&this.hidePlaceholder(),a.length>this.maxlength){this.showMaxlengthMessage(),this.setResponse(this.priorResponse,!0),this.setCaretPos(this.$refs.input,s);return}this.appliedRegex!==null?o=this.applyPatternMask(a):this.setResponse(a,!0),o&&(this.setCaretIndex(s+r.length),this.setCaretPos(this.$refs.input,this.getCaretIndex()),this.priorResponse=a,this.$parent.$emit("textEntryUpdate",{response:this.getResponse()}))},handleDrop(e){e.preventDefault()},handleKeydown(e){switch(this.setCaretIndex(this.getCaretPos(this.$refs.input)),e.code){case"Enter":e.preventDefault();return;case"KeyI":case"KeyB":case"KeyU":e.ctrlKey&&e.preventDefault();return}},newDownRange(e){const t=e.firstChild,i=this.getRange();if(i===null)return;const s=i.startOffset,n=i.endOffset;if(n===this.getResponse().length)return;const r=window.getSelection();r.removeAllRanges();const a=document.createRange();a.setStart(t,s),a.setEnd(t,n+1),r.addRange(a)},newUpRange(e){const t=e.firstChild,i=this.getRange();if(i===null)return;const s=i.startOffset,n=i.endOffset;if(s===0)return;const r=window.getSelection();r.removeAllRanges();const a=document.createRange();a.setStart(t,s-1),a.setEnd(t,n),r.addRange(a)},getRange(){const e=document.getSelection();return e.rangeCount===0?null:e.getRangeAt(0)},getCaretPos(e){let t=0;if(typeof window.getSelection<"u"&&window.getSelection().rangeCount!==0){const n=window.getSelection().getRangeAt(0),r=n.cloneRange();r.selectNodeContents(e),r.setEnd(n.endContainer,n.endOffset),t=r.toString().length}return t},setCaretPos(e,t){e.focus(),e.childNodes.length===1&&document.getSelection().collapse(e.childNodes[0],t)},showPlaceholder(){this.$refs.placeholder.classList.remove("text-entry-ph-hidden")},hidePlaceholder(){this.$refs.placeholder.classList.add("text-entry-ph-hidden")},handleBlur(){this.$refs.root.classList.remove("focused")},handleFocus(){this.$refs.root.classList.add("focused")},getLength(){return this.response.length},applyLimitCheck(e){return e.length>this.maxlength?(this.showMaxlengthMessage(),this.setResponse(this.priorResponse,!0),this.setCaretPos(this.$refs.input,this.getCaretIndex()),!1):!0},applyPatternMask(e){return this.appliedRegex.test(e)?(this.setResponse(e),this.priorResponse=e,!0):(this.showPatternMaskMessage(),this.setResponse(this.priorResponse,!0),this.setCaretPos(this.$refs.input,this.getCaretIndex()),!1)},showPatternMaskMessage(){this.$refs.tooltip.show(),this.hidePatternMaskMessage()},hidePatternMaskMessage(e=3e3){setTimeout(()=>{this.$refs.tooltip.hide()},e)},showMaxlengthMessage(){this.$refs.tooltipMaxlength.show(),this.hideMaxlengthMessage()},hideMaxlengthMessage(e=1e3){setTimeout(()=>{this.$refs.tooltipMaxlength.hide()},e)},computeMaxlengthMessage(){this.maxlengthMessage=`Maximum of ${this.maxlength} character`+(this.maxlength==="1"?"":"s")}},created(){this.appliedRegex=vk.validatePattern("pattern-mask",this.patternMask),this.computeMaxlengthMessage()},mounted(){this.$parent.$emit("textEntryReady",{node:this})}},Ck=["spellcheck","maxlength","disabled"];function Tk(e,t,i,s,n,r){const a=l.resolveComponent("tooltip");return l.openBlock(),l.createElementBlock("div",l.mergeProps({ref:"root",class:"text-entry-default-vert-wrapper"},e.$attrs),[l.createElementVNode("div",{ref:"label",class:"text-entry-default-vert-label qti-hidden",onFocus:t[0]||(t[0]=(...o)=>r.handleFocus&&r.handleFocus(...o)),onBlur:t[1]||(t[1]=(...o)=>r.handleBlur&&r.handleBlur(...o))},null,544),l.createElementVNode("div",{ref:"input",class:"text-entry-default-vert",tabindex:"0",contenteditable:"true",autocapitalize:"false",spellcheck:i.spellcheck,maxlength:i.maxlength,disabled:r.disabled,onInput:t[2]||(t[2]=(...o)=>r.handleInput&&r.handleInput(...o)),onBlur:t[3]||(t[3]=(...o)=>r.handleBlur&&r.handleBlur(...o)),onFocus:t[4]||(t[4]=(...o)=>r.handleFocus&&r.handleFocus(...o)),onKeydown:t[5]||(t[5]=(...o)=>r.handleKeydown&&r.handleKeydown(...o)),onPaste:t[6]||(t[6]=(...o)=>r.handlePaste&&r.handlePaste(...o)),onDrop:t[7]||(t[7]=(...o)=>r.handleDrop&&r.handleDrop(...o))},null,40,Ck),l.createElementVNode("label",{ref:"placeholder",class:"text-entry-default-vert-ph","aria-hidden":"true"},l.toDisplayString(i.placeholder),513),r.hasPatternMask?(l.openBlock(),l.createBlock(a,{key:0,ref:"tooltip",target:()=>e.$refs.input,message:i.patternMaskMessage,"color-style":r.colorStyle},null,8,["target","message","color-style"])):l.createCommentVNode("",!0),l.createVNode(a,{ref:"tooltipMaxlength",target:()=>e.$refs.input,message:n.maxlengthMessage,"color-style":r.colorStyle},null,8,["target","message","color-style"])],16)}const Sk=P(Ek,[["render",Tk]]),Nl={DEFAULT:"default-plain-horizontal",DEFAULT_VERTICAL:"default-plain-vertical"};function xk(e,t,i){switch(e){case Nl.DEFAULT:return{template:'<text-entry-plain-default response-identifier="'+t.responseIdentifier+'" '+Hh(t)+Bh(t)+Dh(t)+Qh(t)+Fh(t)+Uh(t)+mw(t)+Gh(i)+" />",components:{TextEntryPlainDefault:pw}};case Nl.DEFAULT_VERTICAL:return{template:'<text-entry-plain-default-vertical response-identifier="'+t.responseIdentifier+'" '+Hh(t)+Bh(t)+Dh(t)+Qh(t)+Fh(t)+Uh(t)+_k(t)+Vk(t)+Gh(i)+" />",components:{TextEntryPlainDefaultVertical:Sk}};default:return{template:'<text-entry-plain-default response-identifier="'+t.responseIdentifier+'" '+Hh(t)+Bh(t)+Dh(t)+Qh(t)+Fh(t)+Uh(t)+mw(t)+Gh(i)+" />",components:{TextEntryPlainDefault:pw}}}}function Ik(e){return Ak(e)?Nl.DEFAULT_VERTICAL:Nl.DEFAULT}function Bh(e){return typeof e.patternMask>"u"?"":'pattern-mask="'+e.patternMask+'" '}function Dh(e){return'pattern-mask-message="'+e.patternMaskMessage+'" '}function Qh(e){return'placeholder="'+e.placeholder+'" '}function Hh(e){return typeof e.expectedLength>"u"?"":'expected-length="'+e.expectedLength+'" '}function Fh(e){return typeof e.format>"u"||e.format.length==0?"":'format="'+e.format+'" '}function Uh(e){return typeof e.spellcheck>"u"?"":'spellcheck="'+e.spellcheck+'" '}function mw(e){return typeof e.maxlength>"u"?"":'maxlength="'+e.maxlength+'" '}function _k(e){return typeof e.widthClass>"u"?"":'width-class="'+e.widthClass+'" '}function Vk(e){return typeof e.verticalMaxlength>"u"?"":'maxlength="'+e.verticalMaxlength+'" '}function Gh(e){let t="";for(const[i,s]of Object.entries(e))t+=`${i}="${s}" `;return t}function Ak(e){return typeof e>"u"||e===null||e.length==0?!1:gw("qti-writing-orientation-vertical-rl",e)?!0:gw("qti-orientation-vertical",e)}function gw(e,t){const i=t.split(" ");for(let s=0;s<i.length;s++)if(i[s]===e)return!0;return!1}const Rl=new F,$k={name:"QtiTextEntryInteraction",props:{responseIdentifier:{required:!0,type:String},expectedLength:{required:!1,type:String},patternMask:{required:!1,type:String},placeholderText:{required:!1,type:String},format:{required:!1,type:String,default:""},dataPatternmaskMessage:{required:!1,type:String},dataMaxlength:{required:!1,type:String},dataSpellcheck:{required:!1,type:String}},computed:{interactionTemplate(){return xk(this.interactionSubType,this.createComponentProperties(),this.$attrs)},placeholder(){return Rl.validatePlaceholderText(this.placeholderText,"")},hasPatternMask(){return typeof this.patternMask<"u"},patternMaskMessage(){return Rl.validatePatternmaskMessage(this.dataPatternmaskMessage,"Invalid Input")},colorStyle(){return I.getItemContextPnp().getColorStyle()},computeMaxlength(){return typeof this.dataMaxlength<"u"?this.dataMaxlength:500},computeSpellcheck(){return typeof this.dataSpellcheck<"u"?this.dataSpellcheck:!1}},data(){return{response:"",state:null,baseType:"string",cardinality:"single",interactionSubType:null,isValidResponse:!1,invalidResponseMessage:"Input Required",classAttribute:"",isDisabled:!1,isQtiValid:!0,presentationFactory:null,node:null,priorState:null}},methods:{getResponse(){return this.response.length===0?null:this.response},setResponse(e){e===null?this.response="":this.response=e,this.node.setResponse(this.response,!0)},updateResponse(e){e===null?this.response="":this.response=e},getState(){return this.state},setState(e){this.state=e},getIsValid(){return this.isValidResponse},setIsValid(e){this.isValidResponse=e},setInteractionSubType(e){this.interactionSubType=e},getInteractionSubType(){return this.interactionSubType},disable(){this.toggleDisable(!0)},enable(){this.toggleDisable(!1)},toggleDisable(e){this.isDisabled=e,this.node.setIsDisabled(e)},getInvalidResponseMessage(){return this.invalidResponseMessage},initializeValue(){this.setResponse(null),this.setState(this.computeState()),this.setIsValid(!1)},resetValue(){console.log("[ResetValue][identifier]",this.responseIdentifier),this.setResponse(null),this.setState(this.computeState()),this.setIsValid(!1)},restoreValue(e){this.setResponse(e.value),this.setState(e.state),this.updateValidity(this.computeIsValid())},getCardinality(){return this.cardinality},computeState(){return{}},computeIsValid(){return!(this.response===null||this.response.length<1)},evaluateValidity(){const e=this.getIsValid(),t=this.computeIsValid();e!==t&&this.updateValidity(t)},updateValidity(e){this.setIsValid(e),I.setInteractionIsValidResponse({identifier:this.responseIdentifier,isValidResponse:e})},detectInteractionSubType(e){return Ik(e)},createComponentProperties(){return{responseIdentifier:this.responseIdentifier,placeholder:this.placeholder,patternMask:this.patternMask,patternMaskMessage:this.patternMaskMessage,spellcheck:this.computeSpellcheck,maxlength:this.computeMaxlength,widthClass:this.presentationFactory.getWidthClass(),verticalMaxlength:this.presentationFactory.getVerticalMaxLength(),format:this.format}},handleTextEntryUpdate(e){this.updateResponse(e.response),this.evaluateValidity()},handleTextEntryReady(e){this.node=e.node,this.priorState===null?this.initializeValue():this.restoreValue(this.priorState)},getPriorState(e){const t=I.getItemContextStateVariable(e);if(t===null)return null;if(!("value"in t))throw new O('Text Entry Interaction State Invalid. "value" property not found.');if(!("state"in t))throw new O('Text Entry Interaction State Invalid. "state" property not found.');return t}},created(){try{this.responseDeclaration=Rl.validateResponseIdentifierAttribute(I,this.responseIdentifier),this.setInteractionSubType(this.detectInteractionSubType(this.$.vnode.props.class)),this.presentationFactory=new fk(this.$.vnode.props.class),this.priorState=this.getPriorState(this.responseIdentifier),this.cardinality=this.getCardinality(),this.appliedRegex=Rl.validatePattern("pattern-mask",this.patternMask)}catch(e){throw this.isQtiValid=!1,e.name==="QtiValidationException"?new c(e.message):e.name==="QtiParseException"?new ie(e.message):new Error(e.message)}},mounted(){if(this.isQtiValid)try{this.priorState===null?this.initializeValue():this.restoreValue(this.priorState),I.defineInteraction({identifier:this.responseIdentifier,interactionType:"TextEntry",node:this,resetValue:this.resetValue,isValidResponse:this.isValidResponse,invalidResponseMessage:this.getInvalidResponseMessage()}),console.log("["+this.$options.name+"][Identifier]",this.responseIdentifier)}catch(e){throw this.isQtiValid=!1,console.log("["+this.$options.name+"][ValidationError]",e.name,e.message),new c(e.message)}}};function Lk(e,t,i,s,n,r){return l.openBlock(),l.createBlock(l.resolveDynamicComponent(r.interactionTemplate),{ref:"input",class:"qti-text-entry-interaction",onTextEntryUpdate:r.handleTextEntryUpdate,onTextEntryReady:r.handleTextEntryReady},null,40,["onTextEntryUpdate","onTextEntryReady"])}const Mk=P($k,[["render",Lk]]),Nk=new F,Rk={name:"QtiMatchInteraction",props:{responseIdentifier:{required:!0,type:String},minAssociations:{required:!1,type:String,default:"0"},maxAssociations:{required:!1,type:String,default:"1"},shuffle:{required:!1,type:String,default:"false"},dataMaxSelectionsMessage:{required:!1,type:String},dataMinSelectionsMessage:{required:!1,type:String},dataFirstColumnHeader:{required:!1,type:String,default:null}},data(){return{response:null,state:null,isValidResponse:!1,matchsets:[],orders:[],cardinality:"single",minSelectionsMessage:"",maxSelectionsMessage:"",responseDeclaration:null,hasPrompts:!1,matchInteractionStaticClass:"",interactionSubType:"default",headerHidden:"false",rowCentric:"false",isQtiValid:!0,priorState:null}},methods:{getResponse(){return this.response},setResponse(e){this.response=e},getState(){return this.state},setState(e){this.state=e},setInteractionSubType(e){this.interactionSubType=e},getInteractionSubType(){return this.interactionSubType},getIsValid(){return this.isValidResponse},setIsValid(e){this.isValidResponse=e},getInvalidResponseMessage(){return this.minSelectionsMessage},disable(){this.$refs.matchgroup.disable()},enable(){this.$refs.matchgroup.enable()},initializeValue(e){this.setResponse(e),this.setState(this.computeState()),this.updateValidity(this.computeIsValid())},resetValue(){console.log("[ResetValue][identifier]",this.responseIdentifier),this.setResponse(null),this.setState(null),this.priorState=null,this.$refs.matchgroup.resetGroupUI()},restoreValue(e){this.setResponse(e),this.setState(this.computeState()),this.updateValidity(this.computeIsValid())},getCardinality(){let e=I.getResponseDeclaration(this.responseIdentifier);return this.cardinality=typeof e<"u"?e.cardinality:"single",this.cardinality},getPrompts(e){let t=[];return e.default&&e.default().forEach(i=>{typeof i.type<"u"&&i.type.name==="QtiPrompt"&&t.push(i)}),t},movePrompt(){if(!this.hasPrompts)return;const e=this.$refs.root.querySelector(".qti-prompt");e!==null&&this.$refs.prompt.appendChild(e)},handleMatchGroupReady(e){this.matchsets=e.matchsets,this.orders=e.orders,this.initializeValue(e.response)},handleMatchGroupUpdate(e){this.setResponse(e.response),this.updateValidity(this.computeIsValid())},handleAssociationsLimit(){I.NotifyInteractionSelectionsLimit(this.maxSelectionsMessage)},computeState(){return this.priorState!==null?this.priorState.state:{orders:this.orders}},computeIsValid(){const e=this.getResponse(),t=this.minAssociations*1;return t===0?!0:e===null?!1:this.cardinality==="single"||e.length>=t},evaluateValidity(){const e=this.getIsValid(),t=this.computeIsValid();e!==t&&this.updateValidity(t)},updateValidity(e){this.setIsValid(e),I.setInteractionIsValidResponse({identifier:this.responseIdentifier,isValidResponse:e})},computeMaxSelectionsMessage(){if(typeof this.dataMaxSelectionsMessage<"u"){this.maxSelectionsMessage=this.dataMaxSelectionsMessage;return}this.maxSelectionsMessage=this.maxAssociations*1==0?"":"You may make a maximum of "+this.maxAssociations+" match"+(this.maxAssociations*1>1?"es":"")+" for this question."},computeMinSelectionsMessage(){if(typeof this.dataMinSelectionsMessage<"u"){this.minSelectionsMessage=this.dataMinSelectionsMessage;return}this.minAssociations*1!=0&&(this.minSelectionsMessage="You must make at least "+this.minAssociations+" match"+(this.minAssociations*1>1?"es":"")+" for this question.")},detectInteractionSubType(e){return this.getMatchInteractionSubType(e)},getMatchInteractionSubType(e){let t="default";if(typeof e>"u"||e===null||e.length==0)return t;this.matchInteractionStaticClass=e;const i=e.split(" ");for(let s=0;s<i.length;s++)switch(i[s]){case"qti-match-tabular":t="matchtabular";break;case"qti-header-hidden":this.headerHidden="true";break;case"row-centric":this.rowCentric="true";break}return t},getPriorState(e){const t=I.getItemContextStateVariable(e);if(t===null)return null;if(!("value"in t))throw new O('Match Interaction State Invalid. "value" property not found.');if(!("state"in t))throw new O('Match Interaction State Invalid. "state" property not found.');if(!("orders"in t.state))throw new O('Match Interaction State Invalid. "orders" property not found.');return t}},created(){try{if(this.responseDeclaration=Nk.validateResponseIdentifierAttribute(I,this.responseIdentifier),this.setInteractionSubType(this.detectInteractionSubType(this.$.vnode.props.class)),this.priorState=this.getPriorState(this.responseIdentifier),this.cardinality=this.getCardinality(),this.cardinality!=="single"&&this.cardinality!=="multiple")throw new c('qti-match-interaction cardinality must be "single" or "multiple"');if(this.maxAssociations*1!=1&&this.cardinality!=="multiple")throw new c('qti-match-interaction response variable must have "multiple" cardinality because max-associations is '+this.maxAssociations);if(this.minAssociations*1>1&&this.cardinality==="single")throw new c('qti-match-interaction response variable must have "multiple" cardinality because min-associations is '+this.minAssociations);this.hasPrompts=this.getPrompts(this.$slots).length>0,this.computeMinSelectionsMessage(),this.computeMaxSelectionsMessage()}catch(e){throw this.isQtiValid=!1,e.name==="QtiValidationException"?new c(e.message):e.name==="QtiParseException"?new ie(e.message):new Error(e.message)}},mounted(){if(this.isQtiValid)try{this.movePrompt(),I.defineInteraction({identifier:this.responseIdentifier,interactionType:"Match",interactionSubType:this.interactionSubType,node:this,resetValue:this.resetValue,isValidResponse:this.getIsValid(),invalidResponseMessage:this.getInvalidResponseMessage(),maxSelectionsMessage:this.maxSelectionsMessage}),console.log("["+this.$options.name+"][Identifier]",this.responseIdentifier)}catch(e){throw this.isQtiValid=!1,console.log("["+this.$options.name+"][ValidationError]",e.name,e.message),new c(e.message)}}},kk={ref:"root",class:"qti-match-interaction"},qk={ref:"prompt",class:"qti-prompt-wrapper"};function Ok(e,t,i,s,n,r){const a=l.resolveComponent("MatchGroup");return l.openBlock(),l.createElementBlock("div",kk,[l.createElementVNode("div",qk,null,512),l.createVNode(a,l.mergeProps({ref:"matchgroup",cardinality:n.cardinality,shuffle:i.shuffle,responseIdentifier:i.responseIdentifier,maxAssociations:i.maxAssociations,minAssociations:i.minAssociations,interactionSubType:n.interactionSubType,matchInteractionStaticClass:n.matchInteractionStaticClass,headerHidden:n.headerHidden,rowCentric:n.rowCentric,dataFirstColumnHeader:i.dataFirstColumnHeader,priorState:n.priorState,onMatchGroupReady:r.handleMatchGroupReady,onMatchGroupUpdate:r.handleMatchGroupUpdate,onMatchGroupAssociationsLimit:r.handleAssociationsLimit},e.$attrs),{default:l.withCtx(()=>[l.renderSlot(e.$slots,"default")]),_:3},16,["cardinality","shuffle","responseIdentifier","maxAssociations","minAssociations","interactionSubType","matchInteractionStaticClass","headerHidden","rowCentric","dataFirstColumnHeader","priorState","onMatchGroupReady","onMatchGroupUpdate","onMatchGroupAssociationsLimit"])],512)}const Pk=P(Rk,[["render",Ok]]),Bk=new F,Dk={name:"QtiGapMatchInteraction",props:{responseIdentifier:{required:!0,type:String},minAssociations:{required:!1,type:String,default:"0"},maxAssociations:{required:!1,type:String,default:"1"},shuffle:{required:!1,type:String,default:"false"},dataMaxSelectionsMessage:{required:!1,type:String},dataMinSelectionsMessage:{required:!1,type:String},dataChoicesContainerWidth:{required:!1,type:String,default:null}},data(){return{response:null,state:null,isValidResponse:!1,choices:[],order:[],cardinality:"single",minSelectionsMessage:"",maxSelectionsMessage:"",responseDeclaration:null,hasPrompts:!1,gapMatchInteractionStaticClass:"",interactionSubType:"default",isQtiValid:!0,priorState:null}},methods:{getResponse(){return this.response},setResponse(e){this.response=e},getState(){return this.state},setState(e){this.state=e},setInteractionSubType(e){this.interactionSubType=e},getInteractionSubType(){return this.interactionSubType},getIsValid(){return this.isValidResponse},setIsValid(e){this.isValidResponse=e},getInvalidResponseMessage(){return this.minSelectionsMessage},disable(){this.$refs.gapmatchgroup.disable()},enable(){this.$refs.gapmatchgroup.enable()},initializeValue(e){this.setResponse(e),this.setState(this.computeState()),this.updateValidity(this.computeIsValid())},resetValue(){console.log("[ResetValue][identifier]",this.responseIdentifier),this.setResponse(null),this.setState(null),this.priorState=null,this.$refs.matchgroup.resetGroupUI()},restoreValue(e){this.setResponse(e),this.setState(this.computeState()),this.updateValidity(this.computeIsValid())},getCardinality(){let e=I.getResponseDeclaration(this.responseIdentifier);return this.cardinality=typeof e<"u"?e.cardinality:"single",this.cardinality},getPrompts(e){let t=[];return e.default&&e.default().forEach(i=>{typeof i.type<"u"&&i.type.name==="QtiPrompt"&&t.push(i)}),t},movePrompt(){if(!this.hasPrompts)return;const e=this.$refs.root.querySelector(".qti-prompt");e!==null&&this.$refs.prompt.appendChild(e)},handleGapMatchGroupReady(e){this.choices=e.choices,this.order=e.order,this.initializeValue(e.response)},handleGapMatchGroupUpdate(e){this.setResponse(e.response),this.updateValidity(this.computeIsValid())},handleAssociationsLimit(){I.NotifyInteractionSelectionsLimit(this.maxSelectionsMessage)},computeState(){return this.priorState!==null?this.priorState.state:{order:this.order}},computeIsValid(){const e=this.getResponse(),t=this.minAssociations*1;return t===0?!0:e===null?!1:this.cardinality==="single"||e.length>=t},evaluateValidity(){const e=this.getIsValid(),t=this.computeIsValid();e!==t&&this.updateValidity(t)},updateValidity(e){this.setIsValid(e),I.setInteractionIsValidResponse({identifier:this.responseIdentifier,isValidResponse:e})},computeMaxSelectionsMessage(){if(typeof this.dataMaxSelectionsMessage<"u"){this.maxSelectionsMessage=this.dataMaxSelectionsMessage;return}this.maxSelectionsMessage=this.maxAssociations*1==0?"":"You may make a maximum of "+this.maxAssociations+" match"+(this.maxAssociations*1>1?"es":"")+" for this question."},computeMinSelectionsMessage(){if(typeof this.dataMinSelectionsMessage<"u"){this.minSelectionsMessage=this.dataMinSelectionsMessage;return}this.minAssociations*1!=0&&(this.minSelectionsMessage="You must make at least "+this.minAssociations+" match"+(this.minAssociations*1>1?"es":"")+" for this question.")},detectInteractionSubType(e){return this.computeInteractionSubType(e)},computeInteractionSubType(e){let t="default";return typeof e>"u"||e===null||e.length==0||(this.gapMatchInteractionStaticClass=e),t},getPriorState(e){const t=I.getItemContextStateVariable(e);if(t===null)return null;if(!("value"in t))throw new O('Gap Match Interaction State Invalid. "value" property not found.');if(!("state"in t))throw new O('Gap Match Interaction State Invalid. "state" property not found.');if(!("order"in t.state))throw new O('Gap Match Interaction State Invalid. "order" property not found.');return t}},created(){try{if(this.responseDeclaration=Bk.validateResponseIdentifierAttribute(I,this.responseIdentifier),this.setInteractionSubType(this.detectInteractionSubType(this.$.vnode.props.class)),this.priorState=this.getPriorState(this.responseIdentifier),this.cardinality=this.getCardinality(),this.cardinality!=="single"&&this.cardinality!=="multiple")throw new c('qti-gap-match-interaction cardinality must be "single" or "multiple"');if(this.maxAssociations*1!=1&&this.cardinality!=="multiple")throw new c('qti-gap-match-interaction response variable must have "multiple" cardinality because max-associations is '+this.maxAssociations);if(this.minAssociations*1>1&&this.cardinality==="single")throw new c('qti-gap-match-interaction response variable must have "multiple" cardinality because min-associations is '+this.minAssociations);this.hasPrompts=this.getPrompts(this.$slots).length>0,this.computeMinSelectionsMessage(),this.computeMaxSelectionsMessage()}catch(e){throw this.isQtiValid=!1,e.name==="QtiValidationException"?new c(e.message):e.name==="QtiParseException"?new ie(e.message):new Error(e.message)}},mounted(){if(this.isQtiValid)try{this.movePrompt(),I.defineInteraction({identifier:this.responseIdentifier,interactionType:"GapMatch",interactionSubType:this.interactionSubType,node:this,resetValue:this.resetValue,isValidResponse:this.getIsValid(),invalidResponseMessage:this.getInvalidResponseMessage(),maxSelectionsMessage:this.maxSelectionsMessage}),console.log("["+this.$options.name+"][Identifier]",this.responseIdentifier)}catch(e){throw this.isQtiValid=!1,console.log("["+this.$options.name+"][ValidationError]",e.name,e.message),new c(e.message)}}},Qk={ref:"root",class:"qti-gap-match-interaction"},Hk={ref:"prompt",class:"qti-prompt-wrapper"};function Fk(e,t,i,s,n,r){const a=l.resolveComponent("GapMatchGroup");return l.openBlock(),l.createElementBlock("div",Qk,[l.createElementVNode("div",Hk,null,512),l.createVNode(a,l.mergeProps({ref:"gapmatchgroup",cardinality:n.cardinality,shuffle:i.shuffle,responseIdentifier:i.responseIdentifier,maxAssociations:i.maxAssociations,minAssociations:i.minAssociations,interactionSubType:n.interactionSubType,gapMatchInteractionStaticClass:n.gapMatchInteractionStaticClass,dataChoicesContainerWidth:i.dataChoicesContainerWidth,priorState:n.priorState,onGapMatchGroupReady:r.handleGapMatchGroupReady,onGapMatchGroupUpdate:r.handleGapMatchGroupUpdate,onGapMatchGroupAssociationsLimit:r.handleAssociationsLimit},e.$attrs),{default:l.withCtx(()=>[l.renderSlot(e.$slots,"default")]),_:3},16,["cardinality","shuffle","responseIdentifier","maxAssociations","minAssociations","interactionSubType","gapMatchInteractionStaticClass","dataChoicesContainerWidth","priorState","onGapMatchGroupReady","onGapMatchGroupUpdate","onGapMatchGroupAssociationsLimit"])],512)}const Uk=P(Dk,[["render",Fk]]),Gk=new F,jk={name:"QtiGraphicGapMatchInteraction",props:{responseIdentifier:{required:!0,type:String},minAssociations:{required:!1,type:String,default:"0"},maxAssociations:{required:!1,type:String,default:"1"},shuffle:{required:!1,type:String,default:"false"},dataMaxSelectionsMessage:{required:!1,type:String},dataMinSelectionsMessage:{required:!1,type:String},dataChoicesContainerWidth:{required:!1,type:String,default:null}},data(){return{response:null,state:null,isValidResponse:!1,choices:[],order:[],cardinality:"multiple",minSelectionsMessage:"",maxSelectionsMessage:"",responseDeclaration:null,hasPrompts:!1,interactionStaticClass:"",interactionSubType:"default",isQtiValid:!0,priorState:null}},methods:{getResponse(){return this.response},setResponse(e){this.response=e},getState(){return this.state},setState(e){this.state=e},setInteractionSubType(e){this.interactionSubType=e},getInteractionSubType(){return this.interactionSubType},getIsValid(){return this.isValidResponse},setIsValid(e){this.isValidResponse=e},getInvalidResponseMessage(){return this.minSelectionsMessage},disable(){this.$refs.ggmgroup.disable()},enable(){this.$refs.ggmgroup.enable()},initializeValue(e){this.setResponse(e),this.setState(this.computeState()),this.updateValidity(this.computeIsValid())},resetValue(){console.log("[ResetValue][identifier]",this.responseIdentifier),this.setResponse(null),this.setState(null),this.priorState=null,this.$refs.matchgroup.resetGroupUI()},restoreValue(e){this.setResponse(e),this.setState(this.computeState()),this.updateValidity(this.computeIsValid())},getCardinality(){let e=I.getResponseDeclaration(this.responseIdentifier);return this.cardinality=typeof e<"u"?e.cardinality:"single",this.cardinality},getPrompts(e){let t=[];return e.default&&e.default().forEach(i=>{typeof i.type<"u"&&i.type.name==="QtiPrompt"&&t.push(i)}),t},movePrompt(){if(!this.hasPrompts)return;const e=this.$refs.root.querySelector(".qti-prompt");e!==null&&this.$refs.prompt.appendChild(e)},handleGraphicGapMatchGroupReady(e){this.choices=e.choices,this.order=e.order,this.initializeValue(e.response)},handleGraphicGapMatchGroupUpdate(e){this.setResponse(e.response),this.updateValidity(this.computeIsValid())},handleAssociationsLimit(){I.NotifyInteractionSelectionsLimit(this.maxSelectionsMessage)},computeState(){return this.priorState!==null?this.priorState.state:{order:this.order}},computeIsValid(){const e=this.getResponse(),t=this.minAssociations*1;return t===0?!0:e===null?!1:this.cardinality==="single"||e.length>=t},evaluateValidity(){const e=this.getIsValid(),t=this.computeIsValid();e!==t&&this.updateValidity(t)},updateValidity(e){this.setIsValid(e),I.setInteractionIsValidResponse({identifier:this.responseIdentifier,isValidResponse:e})},computeMaxSelectionsMessage(){if(typeof this.dataMaxSelectionsMessage<"u"){this.maxSelectionsMessage=this.dataMaxSelectionsMessage;return}this.maxSelectionsMessage=this.maxAssociations*1==0?"":"You may make a maximum of "+this.maxAssociations+" match"+(this.maxAssociations*1>1?"es":"")+" for this question."},computeMinSelectionsMessage(){if(typeof this.dataMinSelectionsMessage<"u"){this.minSelectionsMessage=this.dataMinSelectionsMessage;return}this.minAssociations*1!=0&&(this.minSelectionsMessage="You must make at least "+this.minAssociations+" match"+(this.minAssociations*1>1?"es":"")+" for this question.")},detectInteractionSubType(e){return this.computeInteractionSubType(e)},computeInteractionSubType(e){let t="default";return typeof e>"u"||e===null||e.length==0||(this.interactionStaticClass=e),t},getPriorState(e){const t=I.getItemContextStateVariable(e);if(t===null)return null;if(!("value"in t))throw new O('Gap Match Interaction State Invalid. "value" property not found.');if(!("state"in t))throw new O('Gap Match Interaction State Invalid. "state" property not found.');if(!("order"in t.state))throw new O('Gap Match Interaction State Invalid. "order" property not found.');return t}},created(){try{if(this.responseDeclaration=Gk.validateResponseIdentifierAttribute(I,this.responseIdentifier),this.setInteractionSubType(this.detectInteractionSubType(this.$.vnode.props.class)),this.priorState=this.getPriorState(this.responseIdentifier),this.cardinality=this.getCardinality(),this.cardinality!=="multiple")throw new c('qti-graphic-gap-match-interaction cardinality must be "multiple"');this.hasPrompts=this.getPrompts(this.$slots).length>0,this.computeMinSelectionsMessage(),this.computeMaxSelectionsMessage()}catch(e){throw this.isQtiValid=!1,e.name==="QtiValidationException"?new c(e.message):e.name==="QtiParseException"?new ie(e.message):new Error(e.message)}},mounted(){if(this.isQtiValid)try{this.movePrompt(),I.defineInteraction({identifier:this.responseIdentifier,interactionType:"GraphicGapMatch",interactionSubType:this.interactionSubType,node:this,resetValue:this.resetValue,isValidResponse:this.getIsValid(),invalidResponseMessage:this.getInvalidResponseMessage(),maxSelectionsMessage:this.maxSelectionsMessage}),console.log("["+this.$options.name+"][Identifier]",this.responseIdentifier)}catch(e){throw this.isQtiValid=!1,console.log("["+this.$options.name+"][ValidationError]",e.name,e.message),new c(e.message)}}},Wk={ref:"root",class:"qti-graphic-gap-match-interaction"},zk={ref:"prompt",class:"qti-prompt-wrapper"};function Kk(e,t,i,s,n,r){const a=l.resolveComponent("GraphicGapMatchGroup");return l.openBlock(),l.createElementBlock("div",Wk,[l.createElementVNode("div",zk,null,512),l.createVNode(a,l.mergeProps({ref:"ggmgroup",cardinality:n.cardinality,shuffle:i.shuffle,responseIdentifier:i.responseIdentifier,maxAssociations:i.maxAssociations,minAssociations:i.minAssociations,interactionSubType:n.interactionSubType,interactionStaticClass:n.interactionStaticClass,dataChoicesContainerWidth:i.dataChoicesContainerWidth,priorState:n.priorState,onGgmGroupReady:r.handleGraphicGapMatchGroupReady,onGgmGroupUpdate:r.handleGraphicGapMatchGroupUpdate,onGgmGroupAssociationsLimit:r.handleAssociationsLimit},e.$attrs),{default:l.withCtx(()=>[l.renderSlot(e.$slots,"default")]),_:3},16,["cardinality","shuffle","responseIdentifier","maxAssociations","minAssociations","interactionSubType","interactionStaticClass","dataChoicesContainerWidth","priorState","onGgmGroupReady","onGgmGroupUpdate","onGgmGroupAssociationsLimit"])],512)}const Yk=P(jk,[["render",Kk]]),Xk={},Zk={ref:"root",class:"qti3-player-media-group"};function Jk(e,t){return l.openBlock(),l.createElementBlock("div",Zk,[l.renderSlot(e.$slots,"default")],512)}const yw=P(Xk,[["render",Jk]]),ww=new F,e2={name:"QtiMediaInteraction",components:[yw],props:{responseIdentifier:{required:!0,type:String},autostart:{required:!0,type:String},minPlays:{required:!1,type:String,default:"0"},maxPlays:{required:!1,type:String,default:"0"},loop:{required:!1,type:String,default:"false"},coords:{required:!1,type:String},dataMaxPlaysMessage:{required:!1,type:String},dataMinPlaysMessage:{required:!1,type:String}},data(){return{response:null,state:null,isValidResponse:!1,cardinality:"single",minPlaysMessage:"",maxPlaysMessage:"",responseDeclaration:null,mediaType:"media",isAutostart:!1,isLoop:!1,isDisabled:!1,isQtiValid:!0,hasPrompts:!1,node:null,priorState:null}},methods:{getResponse(){return this.response},setResponse(e){this.response=e},incrementPlays(){let e=this.getResponse();this.setResponse(e===null?1:e+1)},getState(){return this.state},setState(e){this.state=e},getIsValid(){return this.isValidResponse},setIsValid(e){this.isValidResponse=e},disable(){this.node!==null&&this.node.disable()},enable(){this.node!==null&&this.node.enable()},getInvalidResponseMessage(){return this.computeMinPlaysMessage(),this.minPlaysMessage},resetValue(){console.log("[ResetValue][identifier]",this.responseIdentifier),this.priorState=null,this.setResponse(null),this.setState(this.computeState()),this.updateValidity(this.computeIsValid())},restoreValue(e){e!==null&&(this.setResponse(e),this.setState(this.computeState()),this.updateValidity(this.computeIsValid()),this.evaluateMaxPlays())},getCardinality(){return this.cardinality},getPrompts(e){let t=[];return e.default&&e.default().forEach(i=>{typeof i.type<"u"&&i.type.name==="QtiPrompt"&&t.push(i)}),t},movePrompt(){if(!this.hasPrompts)return;const e=this.$refs.root.querySelector(".qti-prompt");e!==null&&this.$refs.prompt.appendChild(e)},handleMediaMounted(e){this.node=e.node,this.mediaType=e.mediaType,e.mediaType==="audio"&&this.node.setAudioSubType("audioprogress"),this.evaluateMaxPlays()},handleMediaLoaded(e){this.node=e.node,this.evaluateMaxPlays(),this.evaluateAutostart()},handleMediaEnded(){this.incrementPlays(),this.evaluateValidity(),this.evaluateMaxPlays(),this.evaluateLoop()},computeState(){return{}},computeIsValid(){const e=this.minPlays*1;if(e===0)return!0;const t=this.getResponse();return t===null?!1:t>=e},evaluateValidity(){const e=this.getIsValid(),t=this.computeIsValid();e!==t&&this.updateValidity(t)},updateValidity(e){this.setIsValid(e),I.setInteractionIsValidResponse({identifier:this.responseIdentifier,isValidResponse:e})},evaluateMaxPlays(){this.checkMaxPlaysLimit()?this.disable():this.enable()},evaluateLoop(){this.isLoop&&(this.checkMaxPlaysLimit()||this.isDisabled||this.playMedia())},evaluateAutostart(){this.isAutostart&&(this.checkMaxPlaysLimit()||this.isDisabled||(console.log(`[${this.$options.name}][Identifier=${this.responseIdentifier}][AutoStart]`),this.playMedia()))},playMedia(){if(this.node!=null){if(this.mediaType==="audio")return this.node.playAudio();this.node.playVideo()}},checkMaxPlaysLimit(){if(this.maxPlays*1===0)return!1;const e=this.getResponse();return e!==null&&e==this.maxPlays*1},computeMaxPlaysMessage(){if(typeof this.dataMaxPlaysMessage<"u"){this.maxPlaysMessage=this.dataMaxPlaysMessage;return}const e=this.maxPlays*1;this.maxPlaysMessage=e===0?"":`You are permitted a maximum of ${this.maxPlays} play${e>1?"s":""} for this ${this.mediaType}.`},computeMinPlaysMessage(){if(typeof this.dataMinPlaysMessage<"u"){this.minPlaysMessage=this.dataMinPlaysMessage;return}const e=this.minPlays*1;this.minPlaysMessage=e===0?"":`You must play this ${this.mediaType} to the end at least ${this.minPlays} time${e>1?"s":""}.`},validateChildren(){},processChildren(){this.processMedia(),this.setIsValid(this.computeIsValid()),this.priorState!==null&&this.restoreValue(this.priorState.value)},processMedia(){let e=this.$refs.mediagroup.$el.getElementsByTagName("object");if(e.length!==0)throw new c("Unsupported Media Interaction element. The <object> elemnt is deprecated. Use <video> or <audio> instead.");if(e=this.$refs.mediagroup.$el.getElementsByTagName("video"),e.length===0&&(e=this.$refs.mediagroup.$el.getElementsByTagName("audio")),e.length!==1)throw new c("Media Interaction must have exactly one <video> or <audio> node.")},getPriorState(e){const t=I.getItemContextStateVariable(e);if(t===null)return null;if(!("value"in t))throw new O('Media Interaction State Invalid. "value" property not found.');if(!("state"in t))throw new O('Media Interaction State Invalid. "state" property not found.');return t}},created(){try{this.responseDeclaration=ww.validateResponseIdentifierAttribute(I,this.responseIdentifier),this.validateChildren(),this.priorState=this.getPriorState(this.responseIdentifier),ww.validateMaxMinPlays(this.maxPlays,this.minPlays),this.hasPrompts=this.getPrompts(this.$slots).length>0,this.isAutostart=this.autostart==="true",this.isLoop=this.loop==="true",this.computeMaxPlaysMessage()}catch(e){throw this.isQtiValid=!1,e.name==="QtiValidationException"?new c(e.message):e.name==="QtiParseException"?new ie(e.message):new Error(e.message)}},mounted(){if(this.isQtiValid)try{this.movePrompt(),this.processChildren(),I.defineInteraction({identifier:this.responseIdentifier,interactionType:"Media",node:this,resetValue:this.resetValue,disable:this.disable,isValidResponse:this.getIsValid(),invalidResponseMessage:this.getInvalidResponseMessage(),maxSelectionsMessage:this.maxPlaysMessage}),console.log("["+this.$options.name+"][Identifier]",this.responseIdentifier)}catch(e){throw this.isQtiValid=!1,console.log("["+this.$options.name+"][ValidationError]",e.name,e.message),new c(e.message)}}},t2={ref:"root",class:"qti-media-interaction"},i2={ref:"prompt",class:"qti-prompt-wrapper"};function s2(e,t,i,s,n,r){const a=l.resolveComponent("MediaGroup");return l.openBlock(),l.createElementBlock("div",t2,[l.createElementVNode("div",i2,null,512),l.createVNode(a,{ref:"mediagroup",onMediaMounted:r.handleMediaMounted,onMediaLoaded:r.handleMediaLoaded,onMediaEnded:r.handleMediaEnded},{default:l.withCtx(()=>[l.renderSlot(e.$slots,"default")]),_:3},8,["onMediaMounted","onMediaLoaded","onMediaEnded"])],512)}const n2=P(e2,[["render",s2]]),jh=new F,r2={name:"QtiOrderInteraction",props:{responseIdentifier:{required:!0,type:String},minChoices:{required:!1,type:String},maxChoices:{required:!1,type:String},shuffle:{required:!1,type:String,default:"false"},orientation:{required:!1,type:String,default:"horizontal"},dataMaxSelectionsMessage:{required:!1,type:String},dataMinSelectionsMessage:{required:!1,type:String},dataChoicesContainerWidth:{required:!1,type:String,default:null}},data(){return{response:null,state:null,isValidResponse:!1,cardinality:"ordered",minSelectionsMessage:"",maxSelectionsMessage:"",responseDeclaration:null,interactionSubType:"default",choices:[],isShuffle:!1,hasPrompts:!1,minChoicesValue:null,maxChoicesValue:null,isMinChoicesSpecified:!1,isMaxChoicesSpecified:!1,isQtiValid:!0,priorState:null,originalOrder:null}},methods:{getResponse(){return this.response},setResponse(e){this.response=e},getState(){return this.state},setState(e){this.state=e},setInteractionSubType(e){this.interactionSubType=e},getInteractionSubType(){return this.interactionSubType},getIsValid(){return this.isValidResponse},setIsValid(e){this.isValidResponse=e},getInvalidResponseMessage(){return this.minSelectionsMessage},disable(){this.$refs.ordergroup.disable()},enable(){this.$refs.ordergroup.enable()},initializeValue(e){this.setResponse(this.computeResponse(e)),this.setState(this.computeState()),this.updateValidity(this.computeIsValid())},initializeOriginalOrder(){if(this.originalOrder!==null)return;let e=[];this.choices.forEach(t=>{e.push(t.identifier)}),this.originalOrder=e},resetValue(){console.log("[ResetValue][identifier]",this.responseIdentifier),this.setResponse(null),this.setState(null),this.priorState=null,this.$refs.ordergroup.resetGroupUI()},restoreValue(e){this.setResponse(e),this.setState(this.computeState()),this.updateValidity(this.computeIsValid())},getCardinality(){let e=I.getResponseDeclaration(this.responseIdentifier);return this.cardinality=typeof e<"u"?e.cardinality:"ordered",this.cardinality},getPrompts(e){let t=[];return e.default&&e.default().forEach(i=>{typeof i.type<"u"&&i.type.name==="QtiPrompt"&&t.push(i)}),t},movePrompt(){this.hasPrompts&&this.$refs.prompt.appendChild(this.$refs.ordergroup.getPromptElement())},handleOrderGroupReady(e){this.choices=e.choices,this.isMinChoicesSpecified||(this.minChoicesValue=this.choices.length),this.originalOrder===null&&this.initializeOriginalOrder(),this.initializeValue(e.response)},handleOrderGroupUpdate(e){this.setResponse(this.computeResponse(e.response)),this.setState({order:e.response,oorder:this.originalOrder}),this.updateValidity(this.computeIsValid())},handleSelectionsLimit(){I.NotifyInteractionSelectionsLimit(this.maxSelectionsMessage)},computeResponse(e){let t=[];typeof e>"u"?this.choices.forEach(s=>{t.push(s.identifier)}):t=e;let i=0;switch(this.interactionSubType){case"default":for(let s=0;s<t.length;s++)t[s]!==this.originalOrder[s]&&(i+=1);break;case"ordermatch":for(let s=0;s<t.length;s++)t[s]!==null&&(i+=1);break}return i===0?null:t},computeOrder(){const e=[];return this.choices.forEach(t=>{e.push(t.identifier)}),e},computeState(){return this.priorState!==null?this.priorState.state:{order:this.computeOrder(),oorder:this.originalOrder}},computeIsValid(){const e=this.getResponse(),t=this.minChoicesValue;if(e===null||e.length!==this.originalOrder.length)return!1;let i=0;switch(this.interactionSubType){case"default":for(let s=0;s<e.length;s++)e[s]!==this.originalOrder[s]&&(i+=1);return this.isMinChoicesSpecified?i>=t:i===t;case"ordermatch":for(let s=0;s<e.length;s++)e[s]!==null&&(i+=1);return this.isMinChoicesSpecified?i>=t:i===e.length}return!1},evaluateValidity(){const e=this.getIsValid(),t=this.computeIsValid();e!==t&&this.updateValidity(t)},updateValidity(e){this.setIsValid(e),I.setInteractionIsValidResponse({identifier:this.responseIdentifier,isValidResponse:e})},computeMaxSelectionsMessage(){if(typeof this.dataMaxSelectionsMessage<"u"){this.maxSelectionsMessage=this.dataMaxSelectionsMessage;return}this.maxSelectionsMessage=this.maxChoicesValue===null?"":"You may set an order for a maximum of "+this.maxChoicesValue+" choice"+(this.maxChoicesValue>1?"s":"")+" for this question."},computeMinSelectionsMessage(){if(typeof this.dataMinSelectionsMessage<"u"){this.minSelectionsMessage=this.dataMinSelectionsMessage;return}this.isMinChoicesSpecified?this.minSelectionsMessage="You must set the order for at least "+this.minChoicesValue+" choice"+(this.minChoicesValue>1?"s":"")+" for this question.":this.minSelectionsMessage="You must set the order for all choices for this question."},detectInteractionSubType(e){return this.getOrderInteractionSubType(e)},getOrderInteractionSubType(e){if(typeof e>"u"||e===null||e.length==0)return"default";const t=e.split(" ");for(let i=0;i<t.length;i++)switch(t[i]){case"qti-choices-top":case"qti-choices-bottom":case"qti-choices-left":case"qti-choices-right":return"ordermatch"}return"default"},getPriorState(e){const t=I.getItemContextStateVariable(e);if(t===null)return null;if(!("value"in t))throw new O('Order Interaction State Invalid. "value" property not found.');if(!("state"in t))throw new O('Order Interaction State Invalid. "state" property not found.');if(!("order"in t.state))throw new O('Order Interaction State Invalid. "order" property not found.');if(!("oorder"in t.state))throw new O('Order Interaction State Invalid. "oorder" property not found.');return this.originalOrder=t.state.oorder,t}},created(){try{if(this.responseDeclaration=jh.validateResponseIdentifierAttribute(I,this.responseIdentifier),this.setInteractionSubType(this.detectInteractionSubType(this.$.vnode.props.class)),this.priorState=this.getPriorState(this.responseIdentifier),this.cardinality=this.getCardinality(),this.cardinality!=="ordered")throw new c('qti-order-interaction cardinality must be "ordered"');if(this.isShuffle=this.shuffle==="true",this.hasPrompts=this.getPrompts(this.$slots).length>0,typeof this.minChoices<"u"&&(this.isMinChoicesSpecified=!0),this.minChoicesValue=jh.validateIntegerAttribute("min-choices",this.minChoices,!1,null),this.minChoicesValue===0)throw new c('qti-order-interaction "min-choices", when specified, must not be 0');if(this.isMinChoicesSpecified?(typeof this.maxChoices<"u"&&(this.isMaxChoicesSpecified=!0),this.maxChoicesValue=jh.validateIntegerAttribute("max-choices",this.maxChoices,!1,null)):this.maxChoicesValue=null,this.isMinChoicesSpecified&&this.isMaxChoicesSpecified&&this.minChoicesValue>this.maxChoicesValue)throw new c('qti-order-interaction "min-choices" must not be greater than "max-choices"');this.computeMinSelectionsMessage(),this.computeMaxSelectionsMessage()}catch(e){throw this.isQtiValid=!1,e.name==="QtiValidationException"?new c(e.message):e.name==="QtiParseException"?new ie(e.message):new Error(e.message)}},mounted(){if(this.isQtiValid)try{this.movePrompt(),I.defineInteraction({identifier:this.responseIdentifier,interactionType:"Order",node:this,resetValue:this.resetValue,isValidResponse:this.getIsValid(),invalidResponseMessage:this.getInvalidResponseMessage(),maxSelectionsMessage:this.maxSelectionsMessage}),console.log("["+this.$options.name+"][Identifier]",this.responseIdentifier)}catch(e){throw this.isQtiValid=!1,console.log("["+this.$options.name+"][ValidationError]",e.name,e.message),new c(e.message)}}},a2={ref:"root",class:"qti-order-interaction"},o2={ref:"prompt",class:"qti-prompt-wrapper"};function l2(e,t,i,s,n,r){const a=l.resolveComponent("OrderGroup");return l.openBlock(),l.createElementBlock("div",a2,[l.createElementVNode("div",o2,null,512),l.createVNode(a,l.mergeProps({ref:"ordergroup",cardinality:n.cardinality,shuffle:i.shuffle,responseIdentifier:i.responseIdentifier,orientation:i.orientation,maxChoices:n.maxChoicesValue,minChoices:n.minChoicesValue,interactionSubType:n.interactionSubType,dataChoicesContainerWidth:i.dataChoicesContainerWidth,priorState:n.priorState,onOrderGroupReady:r.handleOrderGroupReady,onOrderGroupUpdate:r.handleOrderGroupUpdate,onOrderGroupSelectionsLimit:r.handleSelectionsLimit},e.$attrs),{default:l.withCtx(()=>[l.renderSlot(e.$slots,"default")]),_:3},16,["cardinality","shuffle","responseIdentifier","orientation","maxChoices","minChoices","interactionSubType","dataChoicesContainerWidth","priorState","onOrderGroupReady","onOrderGroupUpdate","onOrderGroupSelectionsLimit"])],512)}const c2=P(r2,[["render",l2]]);class u2{constructor(){this.nodes=[]}find(t,i){if(Array.isArray(t))return t.forEach(s=>{var n;if(s.component!==null&&((n=s.component.type)==null?void 0:n.name)===i){this.nodes.push(s.component.proxy);return}Array.isArray(s==null?void 0:s.children)&&this.find(s.children,i)}),this.nodes}findNodes(t,{within:i}){return this.find(i,t)}}class h2{constructor(t){return this.constants={QTI_UNSELECTED_HIDDEN:"qti-unselected-hidden"},this.classList=t,this.presentation_UnselectedHidden=!1,this.processClassAttribute(),this}processClassAttribute(){if(typeof this.classList>"u"||this.classList===null||this.classList.length==0)return;const t=this.classList.split(" ");for(let i=0;i<t.length;i++)switch(t[i]){case this.constants.QTI_UNSELECTED_HIDDEN:this.presentation_UnselectedHidden=!0;break}}getUnselectedHidden(){return this.presentation_UnselectedHidden}}const bw=new F,d2=new u2,f2={name:"QtiHottextInteraction",props:{responseIdentifier:{required:!0,type:String},minChoices:{required:!1,type:String,default:"0"},maxChoices:{required:!1,type:String,default:"1"},dataMaxSelectionsMessage:{required:!1,type:String},dataMinSelectionsMessage:{required:!1,type:String}},inheritAttrs:!0,data(){return{response:null,state:null,isValidResponse:!1,cardinality:"single",minSelectionsMessage:"",maxSelectionsMessage:"",responseDeclaration:null,choices:[],currentChoice:null,isRadio:!0,isDisabled:!1,isQtiValid:!0,hasPrompts:!1,presentationFactory:null,priorState:null}},methods:{getResponse(){return this.response},setResponse(e){this.response=e},getState(){return this.state},setState(e){this.state=e},getIsValid(){return this.isValidResponse},setIsValid(e){this.isValidResponse=e},disable(){this.toggleDisableChoices(!0)},enable(){this.toggleDisableChoices(!1)},toggleDisableChoices(e){this.isDisabled=e,this.choices.forEach(t=>{t.setIsDisabled(e)})},getInvalidResponseMessage(){return this.minSelectionsMessage},resetValue(){console.log("[ResetValue][identifier]",this.responseIdentifier),this.choices.forEach(e=>{e.setChecked(!1)}),this.currentChoice=null,this.priorState=null},restoreValue(e){e!==null&&(this.isRadio?this.handleSetChecked(new CustomEvent("setChecked",{bubbles:!1,detail:{identifier:e,checked:"true"}}),!0):e.forEach(t=>{this.handleSetChecked(new CustomEvent("setChecked",{bubbles:!1,detail:{identifier:t,checked:"true"}}),!0)},this),this.setResponse(this.computeResponse()),this.setState(this.computeState()),this.updateValidity(this.computeIsValid()))},getCardinality(){let e=I.getResponseDeclaration(this.responseIdentifier);return this.cardinality=typeof e<"u"?e.cardinality!=="multiple"?"single":"multiple":"single",this.cardinality},getPrompts(e){let t=[];return e.default&&e.default().forEach(i=>{typeof i.type<"u"&&i.type.name==="QtiPrompt"&&t.push(i)}),t},movePrompt(){if(!this.hasPrompts)return;const e=this.$refs.root.querySelector(".qti-prompt");e!==null&&this.$refs.prompt.appendChild(e)},handleSetChecked(e,t=!1){const i=e.detail;this.choices.forEach(s=>{this.isRadio&&s.setChecked(!1),s.identifier===i.identifier&&(this.currentChoice=s)}),i.checked==="true"?this.checkMaxChoicesLimit()?this.currentChoice.setChecked(!1):this.currentChoice.setChecked(!0):this.currentChoice.setChecked(!1),t||(this.setResponse(this.computeResponse()),this.currentChoice.setFocus(),this.evaluateValidity())},computeResponse(){let e=this.isRadio?null:[];return this.choices.forEach(t=>{t.isChecked()&&(this.isRadio?e=t.identifier:e.push(t.identifier))}),this.isRadio?e:e.length===0?null:e},computeState(){return{}},computeIsValid(){return this.minChoices*1===0?!0:this.response===null?!1:this.cardinality==="single"||this.cardinality==="multiple"&&this.response.length>=this.minChoices*1},evaluateValidity(){const e=this.getIsValid(),t=this.computeIsValid();e!==t&&this.updateValidity(t)},updateValidity(e){this.setIsValid(e),I.setInteractionIsValidResponse({identifier:this.responseIdentifier,isValidResponse:e})},checkMaxChoicesLimit(){if(this.isRadio||this.maxChoices==0)return!1;const e=this.getResponse();return e!==null&&e.length==this.maxChoices?(I.NotifyInteractionSelectionsLimit(this.maxSelectionsMessage),!0):!1},computeMaxSelectionsMessage(){if(typeof this.dataMaxSelectionsMessage<"u"){this.maxSelectionsMessage=this.dataMaxSelectionsMessage;return}this.maxSelectionsMessage=this.maxChoices==0?"":"You are permitted a maximum of "+this.maxChoices+" selection"+(this.maxChoices>1?"s":"")+" for this question.<br/><br/>Please unselect one of your selections before making another selection."},computeMinSelectionsMessage(){if(typeof this.dataMinSelectionsMessage<"u"){this.minSelectionsMessage=this.dataMinSelectionsMessage;return}this.minSelectionsMessage=this.minChoices==0?"":"You must make at least "+this.minChoices+" selection"+(this.minChoices>1?"s":"")+" for this question."},validateChildren(){},processChildren(){const e=this.$.subTree===null?null:this.$.subTree.children[1].children;this.choices=d2.findNodes("QtiHottext",{within:e}),this.processGroupUI(),this.priorState!==null&&this.restoreValue(this.priorState.value)},processGroupUI(){this.setUnselectedHidden(),this.setResponse(null),this.setState(this.computeState()),this.setIsValid(this.computeIsValid())},setUnselectedHidden(){this.presentationFactory.getUnselectedHidden()&&this.$refs.hottextgroup.setAttribute("class","qti3-player-hottext-group qti-unselected-hidden")},getPriorState(e){const t=I.getItemContextStateVariable(e);if(t===null)return null;if(!("value"in t))throw new O('Hottext Interaction State Invalid. "value" property not found.');if(!("state"in t))throw new O('Hottext Interaction State Invalid. "state" property not found.');return t}},created(){try{this.responseDeclaration=bw.validateResponseIdentifierAttribute(I,this.responseIdentifier),this.presentationFactory=new h2(this.$.vnode.props.class),this.validateChildren(),this.priorState=this.getPriorState(this.responseIdentifier),bw.validateMaxMinChoices(this.maxChoices,this.minChoices),this.isRadio=this.getCardinality()!=="multiple",this.hasPrompts=this.getPrompts(this.$slots).length>0,this.computeMinSelectionsMessage(),this.computeMaxSelectionsMessage()}catch(e){throw this.isQtiValid=!1,e.name==="QtiValidationException"?new c(e.message):e.name==="QtiParseException"?new ie(e.message):new Error(e.message)}},mounted(){if(this.isQtiValid)try{this.movePrompt(),this.processChildren(),I.defineInteraction({identifier:this.responseIdentifier,interactionType:"Hottext",node:this,resetValue:this.resetValue,disable:this.disable,isValidResponse:this.getIsValid(),invalidResponseMessage:this.getInvalidResponseMessage(),maxSelectionsMessage:this.maxSelectionsMessage}),console.log("["+this.$options.name+"][Identifier]",this.responseIdentifier)}catch(e){throw this.isQtiValid=!1,console.log("["+this.$options.name+"][ValidationError]",e.name,e.message),new c(e.message)}}},p2={ref:"root",class:"qti-hottext-interaction"},m2={ref:"prompt",class:"qti-prompt-wrapper"};function g2(e,t,i,s,n,r){return l.openBlock(),l.createElementBlock("div",p2,[l.createElementVNode("div",m2,null,512),l.createElementVNode("div",{ref:"hottextgroup","on:setChecked":t[0]||(t[0]=(...a)=>r.handleSetChecked&&r.handleSetChecked(...a)),class:"qti3-player-hottext-group"},[l.renderSlot(e.$slots,"default")],544)],512)}const y2=P(f2,[["render",g2]]);class w2{constructor(t){return this.constants={QTI_SELECTIONS_LIGHT:"qti-selections-light",QTI_SELECTIONS_DARK:"qti-selections-dark",QTI_UNSELECTED_HIDDEN:"qti-unselected-hidden",THEME_LIGHT:{selectedOpacity:"1.0",unselectedOpacity:"0.5",fillColor:"orange",fillOpacity:"0",strokeColor:"orange",strokeWidth:2,selectedStrokeWidth:4},THEME_DARK:{selectedOpacity:"1.0",unselectedOpacity:"0.5",fillColor:"#0088CC",fillOpacity:"0",strokeColor:"blue",strokeWidth:2,selectedStrokeWidth:4},THEME_HIDDEN_LIGHT:{selectedOpacity:"1.0",unselectedOpacity:"0",fillColor:"orange",fillOpacity:"0",strokeColor:"orange",strokeWidth:2,selectedStrokeWidth:4},THEME_HIDDEN_DARK:{selectedOpacity:"1.0",unselectedOpacity:"0",fillColor:"blue",fillOpacity:"0",strokeColor:"blue",strokeWidth:2,selectedStrokeWidth:4}},this.classList=t,this.presentation_Theme=this.constants.QTI_SELECTIONS_DARK,this.theme=this.constants.THEME_DARK,this.presentation_UnselectedHidden=!1,this.processClassAttribute(),this}processClassAttribute(){if(typeof this.classList>"u"||this.classList===null||this.classList.length==0)return;const t=this.classList.split(" ");for(let i=0;i<t.length;i++)switch(t[i]){case this.constants.QTI_SELECTIONS_DARK:this.presentation_Theme=this.constants.QTI_SELECTIONS_DARK;break;case this.constants.QTI_SELECTIONS_LIGHT:this.presentation_Theme=this.constants.QTI_SELECTIONS_LIGHT;break;case this.constants.QTI_UNSELECTED_HIDDEN:this.presentation_UnselectedHidden=!0;break}switch(this.presentation_Theme){case this.constants.QTI_SELECTIONS_DARK:this.presentation_UnselectedHidden&&(this.theme=this.constants.THEME_HIDDEN_DARK);break;case this.constants.QTI_SELECTIONS_LIGHT:this.presentation_UnselectedHidden?this.theme=this.constants.THEME_HIDDEN_LIGHT:this.theme=this.constants.THEME_LIGHT;break}}getThemeColors(){return this.theme}}const vw=new F,b2={name:"QtiHotspotInteraction",props:{responseIdentifier:{required:!0,type:String},minChoices:{required:!1,type:String,default:"0"},maxChoices:{required:!1,type:String,default:"1"},dataMaxSelectionsMessage:{required:!1,type:String},dataMinSelectionsMessage:{required:!1,type:String}},data(){return{response:null,state:null,isValidResponse:!1,cardinality:"single",minSelectionsMessage:"",maxSelectionsMessage:"",responseDeclaration:null,choices:[],currentChoice:null,shapeElements:[],currentElement:null,backgroundImage:null,backgroundImageWidth:"0",backgroundImageHeight:"0",isRadio:!0,isDisabled:!1,isQtiValid:!0,hasPrompts:!1,presentationFactory:null,shapeColorProperties:null,priorState:null}},methods:{getResponse(){return this.response},setResponse(e){this.response=e},getState(){return this.state},setState(e){this.state=e},getIsValid(){return this.isValidResponse},setIsValid(e){this.isValidResponse=e},disable(){this.toggleDisableChoices(!0)},enable(){this.toggleDisableChoices(!1)},toggleDisableChoices(e){this.isDisabled=e},getInvalidResponseMessage(){return this.minSelectionsMessage},resetValue(){console.log("[ResetValue][identifier]",this.responseIdentifier);for(let e=0;e<this.choices.length;e++)this.setChoiceUnChecked(this.choices[e],this.shapeElements[e]);this.currentChoice=null,this.currentElement=null,this.priorState=null,this.setResponse(null),this.setState(this.computeState()),this.updateValidity(this.computeIsValid())},restoreValue(e){e!==null&&(this.isRadio?this.handleSetChecked(new CustomEvent("setChecked",{bubbles:!1,detail:{identifier:e,checked:"true"}}),!0):e.forEach(t=>{this.handleSetChecked(new CustomEvent("setChecked",{bubbles:!1,detail:{identifier:t,checked:"true"}}),!0)},this),this.setResponse(this.computeResponse()),this.setState(this.computeState()),this.updateValidity(this.computeIsValid()))},getCardinality(){let e=I.getResponseDeclaration(this.responseIdentifier);return this.cardinality=typeof e<"u"?e.cardinality!=="multiple"?"single":"multiple":"single",this.cardinality},getPrompts(e){let t=[];return e.default&&e.default().forEach(i=>{typeof i.type<"u"&&i.type.name==="QtiPrompt"&&t.push(i)}),t},movePrompt(){if(!this.hasPrompts)return;const e=this.$refs.root.querySelector(".qti-prompt");e!==null&&this.$refs.prompt.appendChild(e)},handleSetChecked(e,t=!1){const i=e.detail;for(let s=0;s<this.choices.length;s++)this.isRadio&&this.setChoiceUnChecked(this.choices[s],this.shapeElements[s]),this.choices[s].identifier===i.identifier&&(this.currentChoice=this.choices[s],this.currentElement=this.shapeElements[s]);i.checked==="true"?this.checkMaxChoicesLimit()?this.setChoiceUnChecked(this.currentChoice,this.currentElement):this.setChoiceChecked(this.currentChoice,this.currentElement):this.setChoiceUnChecked(this.currentChoice,this.currentElement),t||(this.setResponse(this.computeResponse()),this.currentElement.focus(),this.evaluateValidity())},computeResponse(){let e=this.isRadio?null:[];return this.choices.forEach(t=>{t.isChecked()&&(this.isRadio?e=t.identifier:e.push(t.identifier))}),this.isRadio?e:e.length===0?null:e},computeState(){return{}},computeIsValid(){return this.minChoices*1===0?!0:this.response===null?!1:this.cardinality==="single"||this.cardinality==="multiple"&&this.response.length>=this.minChoices*1},evaluateValidity(){const e=this.getIsValid(),t=this.computeIsValid();e!==t&&this.updateValidity(t)},updateValidity(e){this.setIsValid(e),I.setInteractionIsValidResponse({identifier:this.responseIdentifier,isValidResponse:e})},checkMaxChoicesLimit(){if(this.isRadio||this.maxChoices==0)return!1;const e=this.getResponse();return e!==null&&e.length==this.maxChoices?(I.NotifyInteractionSelectionsLimit(this.maxSelectionsMessage),!0):!1},computeMaxSelectionsMessage(){if(typeof this.dataMaxSelectionsMessage<"u"){this.maxSelectionsMessage=this.dataMaxSelectionsMessage;return}this.maxSelectionsMessage=this.maxChoices==0?"":"You are permitted a maximum of "+this.maxChoices+" selection"+(this.maxChoices>1?"s":"")+" for this question.<br/><br/>Please unselect one of your selections before making another selection."},computeMinSelectionsMessage(){if(typeof this.dataMinSelectionsMessage<"u"){this.minSelectionsMessage=this.dataMinSelectionsMessage;return}this.minSelectionsMessage=this.minChoices==0?"":"You must make at least "+this.minChoices+" selection"+(this.minChoices>1?"s":"")+" for this question."},validateChildren(){},processChildren(){this.processBackgroundImage(),this.$.subTree.children[1].children[0].children.forEach(t=>{if(t.component!==null&&t.type.name==="QtiHotspotChoice"){const i=t.component.proxy;this.choices.push(i);const s=i.getShapeElement();s!==null&&(this.addHotspotListeners(s),this.shapeElements.push(s),this.$refs.overlay.appendChild(s))}}),this.processGroupUI(),this.priorState!==null&&this.restoreValue(this.priorState.value)},addHotspotListeners(e){e.addEventListener("click",this.handleHotspotClick),e.addEventListener("keydown",this.handleHotspotKeydown)},removeHotspotListeners(e){e.removeEventListener("click",this.handleHotspotClick),e.removeEventListener("keydown",this.handleHotspotKeydown)},handleHotspotClick(e){if(e.preventDefault(),this.isDisabled)return;const t=e.target.getAttribute("data-identifier"),i=this.findChoiceByIdentifier(t);this.isRadio?this.triggerChecked(e.target.getAttribute("data-identifier"),"true"):(this.toggleChecked(i,e.target),this.triggerChecked(t,i.getChecked()))},handleHotspotKeydown(e){const t=e.target.getAttribute("data-identifier"),i=this.findChoiceByIdentifier(t);switch(e.code){case"Space":case"Enter":if(e.stopPropagation(),e.preventDefault(),this.isDisabled||i==null)return;this.toggleChecked(i,e.target),this.triggerChecked(t,i.getChecked());break}},findChoiceByIdentifier(e){for(let t=0;t<this.choices.length;t++)if(this.choices[t].identifier===e)return this.choices[t];return null},toggleChecked(e,t){if(e.toggleChecked(),t===null)return;const i=t.getAttribute("aria-checked");t.setAttribute("aria-checked",i==="true"?"false":"true")},triggerChecked(e,t){const i=new CustomEvent("setChecked",{bubbles:!0,cancelable:!0,detail:{identifier:e,checked:t}});this.$refs.hotspotgroup.dispatchEvent(i)},setChoiceUnChecked(e,t){e.setChecked(!1),t.setAttribute("aria-checked","false");const i=e.getShapeColorProperties();t.setAttribute("fill",`${i.fillColor}`),t.setAttribute("fill-opacity",`${i.fillOpacity}`),t.setAttribute("opacity",`${i.unselectedOpacity}`),t.setAttribute("stroke",`${i.strokeColor}`),t.setAttribute("stroke-width",`${i.strokeWidth}`)},setChoiceChecked(e,t){e.setChecked(!0),t.setAttribute("aria-checked","true");const i=e.getShapeColorProperties();t.setAttribute("fill",`${i.fillColor}`),t.setAttribute("fill-opacity",`${i.fillOpacity}`),t.setAttribute("opacity",`${i.selectedOpacity}`),t.setAttribute("stroke",`${i.strokeColor}`),t.setAttribute("stroke-width",`${i.selectedStrokeWidth}`)},processGroupUI(){this.setResponse(null),this.setState(this.computeState()),this.setIsValid(this.computeIsValid())},processBackgroundImage(){let e=this.$refs.hotspotgroup.getElementsByTagName("object");if(e.length===0&&(e=this.$refs.hotspotgroup.getElementsByTagName("img")),e.length===0&&(e=this.$refs.hotspotgroup.getElementsByTagName("picture")),e.length!==1)throw new c("Hotspot interaction must have exactly one <img>, <object>, or <picture> node");this.backgroundImage=e[0],this.backgroundImage.setAttribute("draggable","false"),this.backgroundImageWidth=`${e[0].clientWidth}`,this.backgroundImageHeight=`${e[0].clientHeight}`,this.$refs.overlay.setAttribute("viewBox",`0 0 ${this.backgroundImageWidth} ${this.backgroundImageHeight}`),this.$refs.overlay.setAttribute("tabindex","-1"),this.$refs.overlay.setAttribute("role","application"),this.$refs.overlay.setAttribute("focusable","false"),this.$refs.hotspotgroup.setAttribute("style",`width:${e[0].clientWidth};height:${e[0].clientHeight}`)},getShapeColorProperties(){return this.shapeColorProperties},setShapeColorProperties(e){this.shapeColorProperties=e},getPriorState(e){const t=I.getItemContextStateVariable(e);if(t===null)return null;if(!("value"in t))throw new O('Hotspot Interaction State Invalid. "value" property not found.');if(!("state"in t))throw new O('Hotspot Interaction State Invalid. "state" property not found.');return t}},created(){try{this.responseDeclaration=vw.validateResponseIdentifierAttribute(I,this.responseIdentifier),this.presentationFactory=new w2(this.$.vnode.props.class),this.setShapeColorProperties(this.presentationFactory.getThemeColors()),this.validateChildren(),this.priorState=this.getPriorState(this.responseIdentifier),vw.validateMaxMinChoices(this.maxChoices,this.minChoices),this.isRadio=this.getCardinality()!=="multiple",this.hasPrompts=this.getPrompts(this.$slots).length>0,this.computeMinSelectionsMessage(),this.computeMaxSelectionsMessage()}catch(e){throw this.isQtiValid=!1,e.name==="QtiValidationException"?new c(e.message):e.name==="QtiParseException"?new ie(e.message):new Error(e.message)}},mounted(){if(this.isQtiValid)try{this.movePrompt(),this.processChildren(),I.defineInteraction({identifier:this.responseIdentifier,interactionType:"Hotspot",node:this,resetValue:this.resetValue,disable:this.disable,isValidResponse:this.getIsValid(),invalidResponseMessage:this.getInvalidResponseMessage(),maxSelectionsMessage:this.maxSelectionsMessage}),console.log("["+this.$options.name+"][Identifier]",this.responseIdentifier)}catch(e){throw this.isQtiValid=!1,console.log("["+this.$options.name+"][ValidationError]",e.name,e.message),new c(e.message)}},beforeUnmount(){this.shapeElements.forEach(e=>{this.removeHotspotListeners(e)})}},v2={ref:"root",class:"qti-hotspot-interaction"},E2={ref:"prompt",class:"qti-prompt-wrapper"},C2={ref:"overlay",class:"qti3-player-hotspot-overlay"};function T2(e,t,i,s,n,r){return l.openBlock(),l.createElementBlock("div",v2,[l.createElementVNode("div",E2,null,512),l.createElementVNode("div",{ref:"hotspotgroup","on:setChecked":t[0]||(t[0]=(...a)=>r.handleSetChecked&&r.handleSetChecked(...a)),class:"qti3-player-hotspot-group"},[l.renderSlot(e.$slots,"default"),(l.openBlock(),l.createElementBlock("svg",C2,null,512))],544)],512)}const S2=P(b2,[["render",T2]]);class x2{constructor(t,i,s){ee(this,"moduleAttribute","");ee(this,"modulesNode",null);ee(this,"itemPathUri","");ee(this,"modules",null);ee(this,"constants",{BASE_CONFIG:{waitSeconds:60,paths:{}}});return this.moduleAttribute=t,this.modulesNode=i,this.itemPathUri=s,this}async getConfiguration(t){this.setModules(this.getInteractionModules());let i=null;this.moduleAttribute.length>0&&this.modulesNode===null?i=await this.getConfigurationFromUrl(this.getModules()):i=await this.resolveModules(this.getModules()),t&&t(i)}async resolveModules(t){let i=null;if(t===null)return i;let s=this.constants.BASE_CONFIG;return s=await this.initBaseConfiguration(s,t),i=await this.resolvePrimaryConfigurationModules(s,t),i!==null||(i=await this.resolveSecondaryConfigurationModules(s,t)),i}async initBaseConfiguration(t,i){const s=`${this.getItemPathUri()}modules/module_resolution.js`;if(typeof i.primaryconfiguration>"u"&&typeof i.secondaryConfiguration>"u"){const n=await this.fetchDefaultModuleResolution(s,!1);if(n!==null)return n}return t}async resolvePrimaryConfigurationModules(t,i){let s=[];if(typeof i.primaryconfiguration>"u"){for(let o=0;o<i.module.length;o++){if(typeof i.module[o].primarypath>"u")return null;s.push(this.addPathJs(i.module[o].primarypath)),t.paths[i.module[o].id]=this.stripPathJs(i.module[o].primarypath)}return await this.resolveConfigurationModules(s)?t:null}const n=await this.fetchConfiguration(i.primaryconfiguration,!0,!0);if(n===null)return null;for(const a in n.paths)n.paths[a]=this.stripPathJs(n.paths[a]);for(let a=0;a<i.module.length;a++)typeof i.module[a].primarypath<"u"&&(n.paths[i.module[a].id]=this.stripPathJs(this.addPathJs(i.module[a].primarypath)));return await this.resolveConfigurationPathUrls(n.paths)?n:null}async resolveSecondaryConfigurationModules(t,i){let s=[];if(typeof i.secondaryconfiguration>"u"){for(let o=0;o<i.module.length;o++){if(typeof i.module[o].fallbackpath>"u")return null;s.push(this.addPathJs(i.module[o].fallbackpath)),t.paths[i.module[o].id]=this.stripPathJs(i.module[o].fallbackpath)}return await this.resolveConfigurationModules(s)?t:null}const n=await this.fetchConfiguration(i.secondaryconfiguration,!1,!0);if(n===null)return null;for(const a in n.paths)n.paths[a]=this.stripPathJs(n.paths[a]);for(let a=0;a<i.module.length;a++)typeof i.module[a].fallbackpath<"u"&&(n.paths[i.module[a].id]=this.stripPathJs(this.addPathJs(i.module[a].fallbackpath)));return await this.resolveConfigurationPathUrls(n.paths)?n:null}async resolveConfigurationPathUrls(t){let i=[];for(let n=0;n<t.length;n++)i.push(t[n]);return await this.resolveConfigurationModules(i)}async resolveConfigurationModules(t){return await Promise.all(t.map(s=>fetch(s).then(n=>{if(n.ok)return console.log("[PCI Parent] Module Loader Success:",s),n;throw new Error(s)}))).catch(s=>(console.log("[PCI Parent] Module Loader Failure:",s.message),null))!==null}async getConfigurationFromUrl(t){let i=null;return t===null||(typeof t.primaryconfiguration<"u"&&(i=await this.fetchConfiguration(t.primaryconfiguration,!0,!1)),i!==null)||typeof t.secondaryconfiguration<"u"&&(i=await this.fetchConfiguration(t.secondaryconfiguration,!1,!1)),i}async fetchConfiguration(t,i,s){try{const n=await fetch(t);if(!n.ok)throw new Error(`HTTP error: ${n.status}`);const r=await n.json();let a=r.paths;for(let o in a)a[o]!==null&&!a[o].startsWith("http")&&(s?a[o]=`${this.getConfigurationRelativePath(t)}${a[o]}`:a[o]=`${this.getItemPathUri()}${a[o]}`);return r}catch(n){return console.log((i?"Primary":"Fallback")+" Configuration Fetch error:",n),null}}async fetchDefaultModuleResolution(t,i){try{const s=await fetch(t);if(!s.ok)throw new Error(`HTTP error: ${s.status}`);const n=await s.json();let r=n.paths;for(let a in r)r[a]!==null&&!r[a].startsWith("http")&&(i?r[a]=`${this.getConfigurationRelativePath(t)}${r[a]}`:r[a]=`${this.getItemPathUri()}${r[a]}`);return n}catch(s){return console.log("module_resolution.js Fetch error:",s),null}}getItemPathUri(){return this.itemPathUri}getModules(){return this.modules}setModules(t){this.modules=t}getInteractionModules(){let t={};if(this.modulesNode===null)return t={primaryconfiguration:"modules/module_resolution.js",secondaryconfiguration:"modules/fallback_module_resolution.js"},this.addPackagePath(t);const i=this.modulesNode.getPrimaryConfiguration();i.length>0&&(t.primaryconfiguration=i);const s=this.modulesNode.getSecondaryConfiguration();s.length>0&&(t.secondaryconfiguration=s),t.module=[];let n=this.modulesNode.getModules();for(let r=0;r<n.length;r++){let a={id:n[r].getId()};n[r].getPrimaryPath().length>0&&(a.primarypath=n[r].getPrimaryPath()),n[r].getFallbackPath().length>0&&(a.fallbackpath=n[r].getFallbackPath()),t.module.push(a)}return this.addPackagePath(t)}addPackagePath(t){for(let s in{primaryconfiguration:"",secondaryconfiguration:""})s in t&&t[s]!==null&&!t[s].startsWith("http")&&(t[s]=this.getAbsolutePath(this.getItemPathUri(),t[s]));let i=t.module;if(i!=null)for(let s=0;s<i.length;s++){let n=i[s];for(let r in{primarypath:"",fallbackpath:""})r in n&&n[r]!==null&&!n[r].startsWith("http")&&(n[r]=this.getAbsolutePath(this.getItemPathUri(),n[r]))}return t}getAbsolutePath(t,i){let s=t.split("/"),n=i.split("/");s.pop();for(var r=0;r<n.length;r++)n[r]!="."&&(n[r]==".."?s.pop():s.push(n[r]));return s.join("/")}getConfigurationRelativePath(t){if(t===null||t.length===0)return"";const i=t.lastIndexOf("/");return i<0?"":t.substring(0,i+1)}stripPathJs(t){return t===null?null:t.endsWith(".js")?t.slice(0,t.lastIndexOf(".")):t}addPathJs(t){return t===null?null:t.length>0&&!t.endsWith(".js")?`${t}.js`:t}}const Wh=new F,kl=new te,I2={name:"QtiPortableCustomInteraction",props:{responseIdentifier:{required:!0,type:String},customInteractionTypeIdentifier:{required:!0,type:String},module:{required:!1,type:String,default:""},dataItemPathUri:{required:!1,type:String,default:""}},inheritAttrs:!0,data(){return{response:null,state:null,baseType:null,cardinality:null,isValidResponse:!0,invalidResponseMessage:"Input Required",isQtiValid:!0,hasPrompts:!1,pciModuleResolver:null,loadIframeHandler:null,renderer:"",classAttribute:"",properties:{},modulesNode:null,modules:null,configuration:null,templateVariables:[],contextVariables:[],stylesheets:[],catalogInfoNode:null,uniqueId:null,pciIframe:null,isReady:!1,initialWidth:0,priorState:null}},methods:{getResponse(){return this.response},setResponse(e){this.response=e},getState(){return this.state},setState(e){this.state=e},getStateRequest(){this.pciIframe.contentWindow.postMessage({message:"PciGetState_Request"},"*")},getIsValid(){return this.isValidResponse},setIsValid(e){this.isValidResponse=e},getInvalidResponseMessage(){return this.invalidResponseMessage},resetValue(){console.log("[ResetValue][identifier]",this.responseIdentifier),this.priorState=null},restoreValue(e,t){this.setResponse(e),this.setState(t)},getCardinality(){let e=I.getResponseDeclaration(this.responseIdentifier);return this.cardinality=e.cardinality,this.cardinality},getBaseType(){let e=I.getResponseDeclaration(this.responseIdentifier);return this.baseType=e.baseType,this.baseType},getPrompts(e){let t=[];return e.default().forEach(i=>{typeof i.type<"u"&&i.type.name==="QtiPrompt"&&t.push(i)}),t},movePrompt(){if(!this.hasPrompts)return;const e=this.$refs.root.querySelector(".qti-prompt");e!==null&&this.$refs.prompt.appendChild(e)},computeState(){return{}},validateChildren(){if(!this.$slots.default)return;let e=!1,t=!1,i=!1,s=!1,n=!1,r=!1,a=!1;this.$slots.default().forEach(o=>{if(Wh.isValidSlot(o)){if(o.type.name==="QtiPrompt"){if(t||i||s||n||r||a)throw new c("Invalid element order. qti-prompt must be the first element");if(!e)return e=!0;throw new c("Maximum of 1 qti-prompt element permitted")}if(o.type.name==="QtiInteractionModules"){if(t||s||n||r||a)throw new c("Invalid element order: qti-interaction-modules");if(!i)return i=!0;throw new c("Maximum of 1 qti-interaction-modules element permitted")}if(o.type.name==="QtiInteractionMarkup"){if(s||n||r||a)throw new c("Invalid element order: qti-interaction-markup");if(!t)return t=!0;throw new c("Maximum of 1 qti-interaction-markup element permitted")}if(o.type.name==="QtiTemplateVariable"){if(s||r||a)throw new c("Invalid element order: qti-template-variable");return n=!0}if(o.type.name==="QtiContextVariable"){if(r||a)throw new c("Invalid element order: qti-context-variable");return s=!0}if(o.type.name==="QtiStylesheet"){if(a)throw new c("Invalid element order: qti-stylesheet");return r=!0}if(o.type.name==="QtiCatalogInfo"){if(!a)return a=!0;throw new c("Maximum of 1 qti-catalog-info element permitted")}throw new c('Node is not permitted inside QtiPortableCustomInteraction: "'+o.type.name+'"')}})},processChildren(){const e=this.$.subTree.children[1].children[0].children;e!==null&&(e.forEach(t=>{if(t.component===null)return;const i=t.component.proxy;switch(t.type.name){case"QtiInteractionMarkup":this.markup=i.getMarkup();break;case"QtiInteractionModules":this.modulesNode=i;break;case"QtiTemplateVariable":this.templateVariables.push(i);break;case"QtiContextVariable":this.contextVariables.push(i);break;case"QtiStylesheet":this.stylesheets.push(i);break;case"QtiCatalogInfo":this.catalogInfoNode=i;break}}),this.priorState!==null&&this.restoreValue(this.priorState.value,this.priorState.state),this.initialWidth=this.$refs.root.clientWidth)},disable(){},enable(){},getPriorState(e){const t=I.getItemContextStateVariable(e);if(t===null)return null;if(!("value"in t))throw new O('PCI State Invalid. "value" property not found.');if(!("state"in t))throw new O('PCI State Invalid. "state" property not found.');return t},createId(){return"pci_"+Wh.randomString(5,"a")},initialize(){this.setProperties(this.getPciProperties()),this.pciModuleResolver=new x2(this.module,this.modulesNode,this.dataItemPathUri),this.pciModuleResolver.getConfiguration((function(e){this.setConfiguration(e),console.log("[PCI Parent] PCI Configuration:",e),e!==null&&this.loadPciIframe(this.initialWidth)}).bind(this))},loadPciIframe(e){const t=document.createElement("iframe");t.name=this.uniqueId,t.id=this.uniqueId,t.setAttribute("scrolling","no"),t.style.border="none",t.style.width=`${e}px`,t.addEventListener("load",this.loadIframeHandler),t.src=`${this.renderer}?identifier=${this.responseIdentifier}&uniqueId=${this.uniqueId}`,this.$refs.ic.appendChild(t)},handleLoadIframe(e){this.pciIframe=e.target},getItemPathUri(){return this.dataItemPathUri},getPciProperties(){let e=this.$refs.root;const t={};for(let i in e.dataset)i!=="uniqueId"&&(t[i]=kl.encodeBytesToBase64(e.dataset[i]));return t},getProperties(){return this.properties},setProperties(e){this.properties=e},getContextVariables(){let e={};for(let t=0;t<this.contextVariables.length;t++)e[this.contextVariables[t].getIdentifier()]=this.contextVariables[t].evaluate();return e},getTemplateVariables(){let e={};for(let t=0;t<this.templateVariables.length;t++)e[this.templateVariables[t].getIdentifier()]=this.templateVariables[t].evaluate();return e},getStylesheets(){let e=[];for(let t=0;t<this.stylesheets.length;t++){const i=this.stylesheets[t],s=kl.encodeBytesToBase64(i.getRawCss());e.push({href:i.getHref(),type:i.getType(),css:`${s}`})}return e},getCatalogInfo(){return this.catalogInfoNode},getModules(){return this.modules},setModules(e){this.modules=e},getConfiguration(){return this.configuration},setConfiguration(e){this.configuration=e},getClassAttribute(){return this.classAttribute},setClassAttribute(e){this.classAttribute=e},copyAttributes(e,t,i){return e.forEach(function(s){let n=s.replace("-","");t[n]=i.getAttribute(s)}),t},getResponseVariable(){let e=kl.valueToPciJson(this.getResponse(),this.baseType,this.cardinality),t={};return t[this.responseIdentifier]=e,t},getAfaPnp(){return I.getItemContextPnp().getAfaPnp()},pciInitialize(){let e={typeIdentifier:this.customInteractionTypeIdentifier,classAttribute:this.getClassAttribute(),markup:this.markup,properties:this.getProperties(),boundTo:this.getResponseVariable(),templateVariables:this.getTemplateVariables(),contextVariables:this.getContextVariables(),stylesheets:this.getStylesheets(),catalogInfo:this.getCatalogInfo(),pnp:this.getAfaPnp(),module:this.module,modules:this.getModules(),moduleResolution:this.getConfiguration(),status:I.getItemLifecycleStatus()},t={message:"PciLoadInteraction",pci:JSON.stringify(e)};this.priorState!==null&&(t.state=JSON.stringify({response:kl.valueToPciJson(this.getResponse(),this.baseType,this.cardinality),state:this.getState()})),this.pciIframe.contentWindow.postMessage(t,"*")},pciResizeIframe(e,t){this.pciIframe!==null&&(this.pciIframe.style.height=`${e}px`,this.pciIframe.style.width=`${t}px`)},pciResizeIframeWidthToContainer(){this.pciIframe!==null&&(this.pciIframe.style.width=`${this.$refs.ic.clientWidth}px`)},pciSaveState(e){const t=JSON.parse(e);typeof t.response<"u"?this.setResponse(t.response):this.setResponse(null),typeof t.state<"u"?this.setState(t.state):this.setState(null),this.notifyInteractionStateReady()},pciUpdateValidity(e){this.setIsValid(e),I.setInteractionIsValidResponse({identifier:this.responseIdentifier,isValidResponse:e})},pciUpdateResponse(e){this.setResponse(e)},pciSetReady(){this.isReady=!0},pciIsReady(){return this.pciIframe!==null&&this.isReady},pciSetRenderingProperties(){const e={message:"PciSetRenderingProperties",properties:{pnp:this.getAfaPnp(),status:I.getItemLifecycleStatus()}};this.pciIframe.contentWindow.postMessage(e,"*")},notifyInteractionStateReady(){I.NotifyInteractionStateReady({identifier:this.responseIdentifier})}},created(){try{this.responseDeclaration=Wh.validateResponseIdentifierAttribute(I,this.responseIdentifier),this.validateChildren(),this.renderer=I.getPciContextRenderer(),this.loadIframeHandler=this.handleLoadIframe.bind(this);const e=typeof this.$.vnode.props.class<"u"?this.$.vnode.props.class:"";this.setClassAttribute(e),this.priorState=this.getPriorState(this.responseIdentifier),this.hasPrompts=this.getPrompts(this.$slots).length>0,this.cardinality=this.getCardinality(),this.baseType=this.getBaseType(),this.uniqueId=this.createId()}catch(e){throw this.isQtiValid=!1,e.name==="QtiValidationException"?new c(e.message):e.name==="QtiParseException"?new ie(e.message):new Error(e.message)}},mounted(){if(this.isQtiValid)try{this.movePrompt(),this.processChildren(),I.defineInteraction({identifier:this.responseIdentifier,interactionType:"PortableCustom",node:this,resetValue:this.resetValue,disable:this.disable,isValidResponse:this.getIsValid(),invalidResponseMessage:this.getInvalidResponseMessage(),maxSelectionsMessage:""}),this.initialize(),console.log("["+this.$options.name+"][Identifier]",this.responseIdentifier)}catch(e){throw this.isQtiValid=!1,console.log("["+this.$options.name+"][ValidationError]",e.name,e.message),new c(e.message)}},beforeUnmount(){this.pciIframe!==null&&this.pciIframe.removeEventListener("load",this.loadIframeHandler)}},_2={ref:"root",class:"qti-portable-custom-interaction"},V2={ref:"prompt",class:"qti-prompt-wrapper"},A2={ref:"pcigroup",class:"qti3-player-pci-group"},$2={ref:"ic",class:"qti3-player-pci-iframe-container"};function L2(e,t,i,s,n,r){return l.openBlock(),l.createElementBlock("div",_2,[l.createElementVNode("div",V2,null,512),l.createElementVNode("div",A2,[l.renderSlot(e.$slots,"default")],512),l.createElementVNode("div",$2,null,512)],512)}const M2=P(I2,[["render",L2]]),zh=new F,N2={name:"QtiSelectPointInteraction",props:{responseIdentifier:{required:!0,type:String},minChoices:{required:!1,type:String,default:"0"},maxChoices:{required:!1,type:String,default:"0"},dataMaxSelectionsMessage:{required:!1,type:String},dataMinSelectionsMessage:{required:!1,type:String}},data(){return{response:null,state:null,isValidResponse:!1,cardinality:"single",minSelectionsMessage:"",maxSelectionsMessage:"",responseDeclaration:null,pointElements:new Map,backgroundImage:null,backgroundImageWidth:"0",backgroundImageHeight:"0",bgImageProperties:null,overlayId:"",markerType:"default",isResponsive:!1,interactionClassAttribute:null,pointRadius:9,isSingle:!0,isDisabled:!1,isQtiValid:!0,hasPrompts:!1,priorState:null}},methods:{getResponse(){return this.response},setResponse(e){this.response=e},getState(){return this.state},setState(e){this.state=e},getIsValid(){return this.isValidResponse},setIsValid(e){this.isValidResponse=e},disable(){this.toggleDisable(!0)},enable(){this.toggleDisable(!1)},toggleDisable(e){this.isDisabled=e,e?this.$refs.overlay.classList.add("disabled"):this.$refs.overlay.classList.remove("disabled")},getInvalidResponseMessage(){return this.minSelectionsMessage},resetValue(){console.log("[ResetValue][identifier]",this.responseIdentifier),this.priorState=null,this.setResponse(null),this.deleteAllPoints(),this.setState(this.computeState()),this.updateValidity(this.computeIsValid())},restoreValue(e){if(e===null)return;e.state.points.forEach(i=>{this.restorePointElement(i)}),this.setState(e.state),this.setResponse(this.computeResponse()),this.updateValidity(this.computeIsValid())},getCardinality(){let e=I.getResponseDeclaration(this.responseIdentifier);return this.cardinality=typeof e<"u"?e.cardinality!=="multiple"?"single":"multiple":"single",this.cardinality},getPrompts(e){let t=[];return e.default&&e.default().forEach(i=>{typeof i.type<"u"&&i.type.name==="QtiPrompt"&&t.push(i)}),t},movePrompt(){if(!this.hasPrompts)return;const e=this.$refs.root.querySelector(".qti-prompt");e!==null&&this.$refs.prompt.appendChild(e)},computeResponse(){let e=this.isSingle?null:[];for(const t of this.pointElements.values()){const i=`${t.getAttribute("data-point")}`;this.isSingle?e=i:e.push(i)}return this.isSingle?e:e.length===0?null:e},computeState(){const e=[];for(const[t,i]of this.pointElements)e.push({id:t,marker:i.getAttribute("data-marker-type"),point:i.getAttribute("data-point"),static:i.getAttribute("class").includes("static")});return{points:e}},computeIsValid(){return this.minChoices*1===0?!0:this.response===null?!1:this.cardinality==="single"||this.cardinality==="multiple"&&this.response.length>=this.minChoices*1},evaluateValidity(){const e=this.getIsValid(),t=this.computeIsValid();e!==t&&this.updateValidity(t)},updateValidity(e){this.setIsValid(e),I.setInteractionIsValidResponse({identifier:this.responseIdentifier,isValidResponse:e})},checkMaxChoicesLimit(){return this.isSingle&&this.pointElements.size==0||!this.isSingle&&this.maxChoices==0||!this.isSingle&&this.pointElements.size<this.maxChoices?!1:(I.NotifyInteractionSelectionsLimit(this.maxSelectionsMessage),!0)},computeMaxSelectionsMessage(){if(typeof this.dataMaxSelectionsMessage<"u"){this.maxSelectionsMessage=this.dataMaxSelectionsMessage;return}this.maxSelectionsMessage=this.maxChoices==0?"":"You are permitted a maximum of "+this.maxChoices+" point"+(this.maxChoices>1?"s":"")+" for this question.<br/><br/>Please remove one of your points before making another point."},computeMinSelectionsMessage(){if(typeof this.dataMinSelectionsMessage<"u"){this.minSelectionsMessage=this.dataMinSelectionsMessage;return}this.minSelectionsMessage=this.minChoices==0?"":"You must make at least "+this.minChoices+" point"+(this.minChoices>1?"s":"")+" for this question."},createId(e){return`${e}${zh.randomString(5,"a")}`},processChildren(){this.processBackgroundImage(),this.processGroupUI(),this.priorState!==null&&this.restoreValue(this.priorState)},addPointFromClick(e){const t=this.createId("p_"),i=this.createPointElement(e,this.markerType,t);this.addPointListeners(i),this.pointElements.set(t,i),this.$refs.overlay.appendChild(i),this.setState(this.computeState()),this.setResponse(this.computeResponse()),this.evaluateValidity()},deleteAllPoints(){for(const[e,t]of this.pointElements.values())this.deletePoint(e,t)},deletePoint(e,t){this.removePointListeners(t),this.pointElements.delete(e),t.remove()},createPointElement(e,t,i){const s=this.convertPoint(e.x,e.y,!1);return this.newPointElement(i,e,s,t,!0)},restorePointElement(e){const t=e.point.split(" ");if(t.length!==2)return;const i=this.convertPoint(t[0],t[1],!0),s={x:t[0],y:t[1]},n=this.newPointElement(e.id,i,s,e.marker,e.static);this.addPointListeners(n),this.pointElements.set(e.id,n),this.$refs.overlay.appendChild(n)},convertPoint(e,t,i){const s=this.getScalingFactor();let n,r;return i?(n=Math.round(e/s),r=Math.round(t/s)):(n=Math.round(e*s),r=Math.round(t*s)),n<0&&(n=0),n>this.bgImageProperties.w&&(n=this.bgImageProperties.w),r<0&&(r=0),r>this.bgImageProperties.h&&(r=this.bgImageProperties.h),{x:n,y:r}},getScalingFactor(){return this.isResponsive?this.bgImageProperties.w/this.backgroundImageWidth:1},newPointElement(e,t,i,s,n){const r=document.createElementNS("http://www.w3.org/2000/svg","circle");return r.setAttribute("cx",t.x),r.setAttribute("cy",t.y),r.setAttribute("r",this.pointRadius),s==="default-light"?(r.setAttribute("fill","orange"),r.setAttribute("fill-opacity",".5"),r.setAttribute("stroke","orange")):(r.setAttribute("fill","#0088CC"),r.setAttribute("fill-opacity",".5"),r.setAttribute("stroke","blue")),r.setAttribute("opacity","1"),r.setAttribute("stroke-width","1"),r.setAttribute("data-marker-type",s),r.setAttribute("id",`${e}`),r.setAttribute("class",`qti3-player-select-point ${n?"static":""}`),r.setAttribute("tabindex","0"),r.setAttribute("data-point",`${i.x} ${i.y}`),r},handleOverlayClick(e){e.preventDefault(),!this.isDisabled&&(this.checkMaxChoicesLimit()||this.addPointFromClick(this.getMousePosition(e)))},handlePointClick(e){if(e.preventDefault(),e.stopPropagation(),this.isDisabled)return;const t=e.target,i=t.getAttribute("id");this.deletePoint(i,t),this.setState(this.computeState()),this.setResponse(this.computeResponse()),this.evaluateValidity()},getMousePosition(e){const t=this.$refs.overlay.getScreenCTM();e.touches&&(e=e.touches[0]);const i=(e.clientX-t.e)/t.a,s=(e.clientY-t.f)/t.d;return{x:i,y:s}},processGroupUI(){this.setResponse(null),this.setState(this.computeState()),this.setIsValid(this.computeIsValid())},processBackgroundImage(){if(this.bgImageProperties=this.computeBackgroundImageProperties(),this.bgImageProperties===null)throw new c("Select Point interaction must have exactly one <img>, <object>, or <picture> node");this.isResponsive?(this.backgroundImageWidth=`${this.bgImageProperties.element.offsetWidth}`,this.backgroundImageHeight=`${this.bgImageProperties.element.offsetHeight}`):(this.backgroundImageWidth=`${this.bgImageProperties.w}`,this.backgroundImageHeight=`${this.bgImageProperties.h}`,this.$refs.selectpointgroup.setAttribute("style",`width:${this.backgroundImageWidth};height:${this.backgroundImageHeight}`)),this.overlayId=this.createId("spi_"),this.$refs.overlay.setAttribute("id",this.overlayId),this.$refs.overlay.setAttribute("width",`${this.backgroundImageWidth}`),this.$refs.overlay.setAttribute("height",`${this.backgroundImageHeight}`),this.$refs.overlay.setAttribute("viewBox",`0 0 ${this.backgroundImageWidth} ${this.backgroundImageHeight}`),this.$refs.overlay.setAttribute("tabindex","-1"),this.$refs.overlay.setAttribute("role","application"),this.$refs.overlay.setAttribute("focusable","false"),this.createSvgImage(this.bgImageProperties,this.backgroundImageWidth,this.backgroundImageHeight),this.addOverlayListeners()},handleResize(){this.backgroundImageWidth=this.$refs.overlay.parentNode.offsetWidth,this.backgroundImageHeight=this.$refs.overlay.parentNode.offsetHeight,this.$refs.overlay.setAttribute("width",`${this.backgroundImageWidth}`),this.$refs.overlay.setAttribute("height",`${this.backgroundImageHeight}`)},computeBackgroundImageProperties(){let e=this.$refs.selectpointgroup.getElementsByTagName("img");if(e.length===1){const t=e[0].getAttribute("width"),i=e[0].getAttribute("height");return this.createImageProperties(e[0],e[0].src,"img",t,i)}if(e=this.$refs.selectpointgroup.getElementsByTagName("object"),e.length===1){const t=e[0].getAttribute("width"),i=e[0].getAttribute("height");return this.createImageProperties(e[0],e[0].data,"object",t,i)}return null},createImageProperties(e,t,i,s,n){let r=s===null||n===null?1:s/n;return{element:e,src:t,tag:i,w:s,h:n,ar:r}},createSvgImage(e,t,i){let s=document.createElementNS("http://www.w3.org/2000/svg","image");s.setAttribute("href",e.src),s.setAttribute("width",t),s.setAttribute("height",i),s.setAttribute("draggable",!1),this.$refs.overlay.appendChild(s),e.element.remove()},addOverlayListeners(){this.$refs.overlay.addEventListener("click",this.handleOverlayClick.bind(this))},removeOverlayListeners(){this.$refs.overlay.removeEventListener("click",this.handleOverlayClick)},addPointListeners(e){e.addEventListener("click",this.handlePointClick.bind(this))},removePointListeners(e){e.removeEventListener("click",this.handlePointClick)},processClassAttribute(e){if(typeof e>"u"||e===null||e.length==0)return;const t=e.split(" ");for(let i=0;i<t.length;i++)switch(t[i]){case"responsive":this.isResponsive=!0;break;case"marker-crosshair":this.markerType="crosshair";break;case"marker-default":this.markerType="default";break;case"marker-default-light":this.markerType="default-light";break}},getPriorState(e){const t=I.getItemContextStateVariable(e);if(t===null)return null;if(!("value"in t))throw new O('Select Point Interaction State Invalid. "value" property not found.');if(!("state"in t))throw new O('Select Point Interaction State Invalid. "state" property not found.');if(!("points"in t.state))throw new O('Select Point Interaction State Invalid. "points" property not found in State.');return t}},created(){try{if(this.responseDeclaration=zh.validateResponseIdentifierAttribute(I,this.responseIdentifier),this.processClassAttribute(this.$.vnode.props.class),this.priorState=this.getPriorState(this.responseIdentifier),zh.validateMaxMinChoices(this.maxChoices,this.minChoices),this.isSingle=this.getCardinality()!=="multiple",this.isSingle&&this.maxChoices!=1)throw new c('Invalid qti-select-point-interaction. cardinality: "single", max-choices attribute: "'+this.maxChoices+'"');this.hasPrompts=this.getPrompts(this.$slots).length>0,this.computeMinSelectionsMessage(),this.computeMaxSelectionsMessage()}catch(e){throw this.isQtiValid=!1,e.name==="QtiValidationException"?new c(e.message):e.name==="QtiParseException"?new ie(e.message):new Error(e.message)}},mounted(){if(this.isQtiValid)try{this.movePrompt(),this.processChildren(),I.defineInteraction({identifier:this.responseIdentifier,interactionType:"SelectPoint",node:this,resetValue:this.resetValue,disable:this.disable,isValidResponse:this.getIsValid(),invalidResponseMessage:this.getInvalidResponseMessage(),maxSelectionsMessage:this.maxSelectionsMessage}),console.log("["+this.$options.name+"][Identifier]",this.responseIdentifier)}catch(e){throw this.isQtiValid=!1,console.log("["+this.$options.name+"][ValidationError]",e.name,e.message),new c(e.message)}},beforeUnmount(){this.removeOverlayListeners();for(const e of this.pointElements.values())this.removePointListeners(e)}},R2={ref:"root",class:"qti-select-point-interaction"},k2={ref:"prompt",class:"qti-prompt-wrapper"},q2={ref:"selectpointgroup",class:"select-point-group"},O2={ref:"overlay",class:"select-point-overlay"};function P2(e,t,i,s,n,r){return l.openBlock(),l.createElementBlock("div",R2,[l.createElementVNode("div",k2,null,512),l.createElementVNode("div",q2,[l.renderSlot(e.$slots,"default"),(l.openBlock(),l.createElementBlock("svg",O2,null,512))],512)],512)}const B2=P(N2,[["render",P2]]),D2={name:"QtiPrompt"},Q2={class:"qti-prompt"};function H2(e,t,i,s,n,r){return l.openBlock(),l.createElementBlock("div",Q2,[l.renderSlot(e.$slots,"default")])}const F2=P(D2,[["render",H2]]),U2=new F,G2={name:"QtiInlineChoice",props:{identifier:{required:!0,type:String},fixed:{required:!1,type:String,default:"false"},templateIdentifier:{required:!1,type:String},showHide:{required:!1,type:String,default:"show"}},data(){return{id:null}},inheritAttrs:!0,methods:{createId(){if(this.$refs.choice.hasAttribute("id")){this.id=this.$refs.choice.getAttribute("id");return}this.id="inlinechoice_"+U2.randomString(5,"a")+"_"+this.identifier,this.$refs.choice.setAttribute("id",this.id)}},created(){},mounted(){this.createId()}},j2=["data-identifier"];function W2(e,t,i,s,n,r){return l.openBlock(),l.createElementBlock("li",{ref:"choice",role:"option","data-identifier":i.identifier,class:"qti-inline-choice"},[l.renderSlot(e.$slots,"default")],8,j2)}const z2=P(G2,[["render",W2]]),K2=new F,Y2={name:"QtiSimpleChoice",emits:["setChecked","setFocusPreviousChoice","setFocusNextChoice","setActiveDescendant"],props:{identifier:{required:!0,type:String},fixed:{required:!1,type:String,default:"false"},templateIdentifier:{required:!1,type:String},showHide:{required:!1,type:String,default:"show"}},data(){return{id:null,checked:"false",isRadio:!0,role:"radio",tabIndex:"-1",hasMath:!1,isDisabled:!1,parentCardinality:"single"}},inheritAttrs:!0,methods:{handleClick(){if(!this.isDisabled)if(this.isRadio)this.$parent.$emit("setChecked",{identifier:this.identifier,checked:"true"});else{if(this.toggleChecked(),this.parentCardinality==="ordered")return;this.$parent.$emit("setChecked",{identifier:this.identifier,checked:this.checked})}},handleKeydown(e){let t=!1;switch(e.code){case"Space":if(!this.isDisabled){if(this.toggleChecked(),this.parentCardinality==="ordered")return;this.$parent.$emit("setChecked",{identifier:this.identifier,checked:this.checked})}t=!0;break;case"Enter":if(!this.isDisabled){if(this.toggleChecked(),this.parentCardinality==="ordered")return;this.$parent.$emit("setChecked",{identifier:this.identifier,checked:this.checked})}t=!0;break;case"ArrowUp":case"ArrowLeft":this.isRadio&&(this.$parent.$emit("setFocusPreviousChoice",this.identifier),t=!0);break;case"ArrowDown":case"ArrowRight":this.isRadio&&(this.$parent.$emit("setFocusNextChoice",this.identifier),t=!0);break}t&&(e.stopPropagation(),e.preventDefault())},handleFocus(){this.parentCardinality!=="ordered"&&this.$parent.$emit("setActiveDescendant",this.id)},handleBlur(){},setChecked(e){this.checked=e?"true":"false"},isChecked(){return this.checked==="true"},setTabIndex(e){this.tabIndex=e},setFocus(){this.$refs.choice.focus()},setBlur(){this.$refs.choice.blur()},toggleChecked(){this.checked=this.checked==="true"?"false":"true"},setLabel(e){this.$refs.label.innerText=e},hideLabel(){this.$refs.label.classList.add("qti-hidden")},showLabel(){this.$refs.label.classList.remove("qti-hidden")},setLabelSbac(e){this.$refs.choice.classList.add("sbac"),this.$refs.choice.setAttribute("data-label",e),this.$refs.label.innerText=e,this.$refs.label.classList.add("qti-visually-hidden")},setChoiceLrn(){this.$refs.choice.classList.add("lrn")},hideControl(){this.$refs.choice.classList.add("control-hidden")},setIsDisabled(e){this.isDisabled=e},initializeChoice(){switch(this.parentCardinality=this.$parent.cardinality,this.parentCardinality){case"ordered":this.role="button",this.isRadio=!1,this.tabIndex=0;break;case"multiple":this.role="checkbox",this.isRadio=!1,this.tabIndex=0;break;default:this.role="radio",this.isRadio=!0,this.tabIndex=-1;break}},initializeOrderChoice(){this.role==="button"&&(this.hideLabel(),this.hideControl())},createId(){if(this.$refs.choice.hasAttribute("id")){this.id=this.$refs.choice.getAttribute("id");return}this.id="choice_"+K2.randomString(5,"a")+"_"+this.identifier,this.$refs.choice.setAttribute("id",this.id)},setExpectedSolution(){this.$refs.choice.classList.add("player-show-solution","player-choice-expected")},setCorrectSolution(){this.$refs.choice.classList.add("player-show-solution","player-choice-correct")},setIncorrectSolution(){this.$refs.choice.classList.add("player-show-solution","player-choice-incorrect")},setIgnoreSolution(){this.$refs.choice.classList.remove("player-show-solution","player-choice-incorrect","player-choice-correct","player-choice-expected")}},created(){this.initializeChoice()},mounted(){this.initializeOrderChoice(),this.createId()}},X2=["role","aria-checked","tabindex","data-identifier"],Z2={ref:"label",class:"qti-choice-label"},J2={ref:"description",class:"qti-choice-description"};function eq(e,t,i,s,n,r){return l.openBlock(),l.createElementBlock("li",{ref:"choice",role:n.role,"aria-checked":n.checked,tabindex:n.tabIndex,"data-identifier":i.identifier,onFocus:t[0]||(t[0]=(...a)=>r.handleFocus&&r.handleFocus(...a)),onBlur:t[1]||(t[1]=(...a)=>r.handleBlur&&r.handleBlur(...a)),onClick:t[2]||(t[2]=(...a)=>r.handleClick&&r.handleClick(...a)),onKeydown:t[3]||(t[3]=(...a)=>r.handleKeydown&&r.handleKeydown(...a)),class:l.normalizeClass(["qti-simple-choice",{source:n.role=="button"}])},[l.createElementVNode("div",{class:l.normalizeClass(["qti-simple-choice-wrapper",{draggable:n.role=="button"}]),style:{width:"100%"}},[l.createElementVNode("div",Z2,null,512),l.createElementVNode("div",J2,[l.renderSlot(e.$slots,"default")],512)],2)],42,X2)}const tq=P(Y2,[["render",eq]]),iq=new F,sq={name:"QtiSimpleAssociableChoice",props:{identifier:{required:!0,type:String},fixed:{required:!1,type:String,default:"false"},templateIdentifier:{required:!1,type:String},showHide:{required:!1,type:String,default:"show"},matchGroup:{required:!1,type:String,default:""},matchMax:{required:!0,type:String},matchMin:{required:!1,type:String,default:"0"}},data(){return{id:null}},methods:{createId(){if(this.$refs.choice.hasAttribute("id")){this.id=this.$refs.choice.getAttribute("id");return}this.id="choice_"+iq.randomString(5,"a")+"_"+this.identifier,this.$refs.choice.setAttribute("id",this.id)}},mounted(){this.createId()}},nq=["data-identifier","data-match-max","data-match-min","data-match-group"],rq={ref:"description",class:"choice-description"};function aq(e,t,i,s,n,r){return l.openBlock(),l.createElementBlock("li",{ref:"choice","data-identifier":i.identifier,"data-match-max":i.matchMax,"data-match-min":i.matchMin,"data-match-group":i.matchGroup,class:"qti-simple-associable-choice"},[l.createElementVNode("div",rq,[l.renderSlot(e.$slots,"default")],512)],8,nq)}const oq=P(sq,[["render",aq]]),lq=new F,cq={name:"QtiAssociableHotspot",props:{identifier:{required:!0,type:String},templateIdentifier:{required:!1,type:String},showHide:{required:!1,type:String,default:"show"},matchGroup:{required:!1,type:String,default:""},shape:{required:!0,type:String},coords:{required:!0,type:String},hotspotLabel:{required:!1,type:String,default:""},ariaLabel:{required:!1,type:String,default:""},matchMax:{required:!0,type:String},matchMin:{required:!1,type:String,default:"0"}},data(){return{shapeData:null,shapeColorProperties:null,isQtiValid:!0}},inheritAttrs:!0,methods:{getIdentifier(){return this.identifier},getShape(){return this.shape},getShapeData(){return this.shapeData},setShapeData(){const e=this.coords.split(",");switch(this.getShape()){case"circle":if(e.length!=3)return;this.shapeData=e;return;case"rect":if(e.length!==4)return;e[2]=parseInt(e[2])-parseInt(e[0]),e[3]=parseInt(e[3])-parseInt(e[1]),this.shapeData=e;return;case"poly":this.shapeData=this.transformPolyCoords(e);return;case"ellipse":if(e.length!=4)return;this.shapeData=e;return;case"default":this.shapeData="";return}},transformPolyCoords(e){let t=[];if(e.length%2!=0)return t;for(let i=0;i<e.length;i+=2)t.push(`${e[i]} ${e[i+1]}`);return t},initialize(){lq.validateShapeAttribute(this.shape),this.setShapeData()}},created(){try{this.initialize()}catch(e){if(this.isQtiValid=!1,e.name==="QtiValidationException")throw new c(e.message)}},mounted(){if(this.isQtiValid)try{console.log("["+this.$options.name+"][Identifier]",this.identifier)}catch(e){throw this.isQtiValid=!1,console.log("["+this.$options.name+"][ValidationError]",e.name,e.message),new c(e.message)}}},uq=["data-identifier","data-match-max","data-match-min","data-match-group"];function hq(e,t,i,s,n,r){return l.openBlock(),l.createElementBlock("div",{ref:"gap","data-identifier":i.identifier,"data-match-max":i.matchMax,"data-match-min":i.matchMin,"data-match-group":i.matchGroup,class:"ggm-gap"},null,8,uq)}const dq=P(cq,[["render",hq]]),fq=new F,pq=new te,mq={name:"QtiSimpleMatchSet",data(){return{choices:[],isShuffle:!1,isQtiValid:!0}},methods:{getChoices(){return this.choices},setIsShuffle(e){this.isShuffle=e},createContainer(e,t){let i=[];return e===null?(this.choices.forEach(n=>{i.push({fixed:n.fixed==="true",node:n})}),this.isShuffle&&pq.shuffleArrayFixed(i),i):(e.state.orders[t].forEach(n=>{const r=this.findChoiceByIdentifier(n,this.choices);r!==null&&i.push({fixed:r.fixed==="true",node:r})},this),i)},processContainerChoices(e){this.choices.splice(0,this.choices.length),this.$refs.matchset.innerHTML="",e.forEach(t=>{this.$refs.matchset.appendChild(t.node.$el),this.choices.push(t.node)},this)},validateChildren(){let e=0;if(!this.$slots.default)throw new c("Must have at least 1 qti-simple-associable-choice");if(this.$slots.default().forEach(t=>{if(fq.isValidSlot(t)){if(t.type.name==="QtiSimpleAssociableChoice")return e+=1;throw new c('Node is not a qti-simple-associable-choice: "'+t.type.name+'"')}}),e===0)throw new c("Must have at least 1 qti-simple-associable-choice")},processChildren(){this.$.subTree.children[0].children.forEach(t=>{t.component!==null&&this.choices.push(t.component.proxy)})},findChoiceByIdentifier(e,t){for(let i=0;i<t.length;i++)if(t[i].$el.getAttribute("data-identifier")===e)return t[i];throw new O('Match Interaction State Invalid. Choice identifier "'+e+'" not found.')}},created(){try{this.validateChildren()}catch(e){throw this.isQtiValid=!1,e.name==="QtiValidationException"?new c(e.message):new Error(e.message)}},mounted(){if(this.isQtiValid)try{this.processChildren(),console.log("["+this.$options.name+"]")}catch(e){throw this.isQtiValid=!1,console.log("["+this.$options.name+"][ValidationError]",e.name,e.message),new c(e.message)}}},gq={ref:"matchset",class:"qti-simple-match-set"};function yq(e,t,i,s,n,r){return l.openBlock(),l.createElementBlock("ul",gq,[l.renderSlot(e.$slots,"default")],512)}const wq=P(mq,[["render",yq]]);class bq{constructor(t){this.constants={QTI_CHOICES_TOP:"qti-choices-top",QTI_CHOICES_BOTTOM:"qti-choices-bottom",QTI_CHOICES_LEFT:"qti-choices-left",QTI_CHOICES_RIGHT:"qti-choices-right",DATA_MAX_SELECTIONS_MESSAGE:"data-max-selections-message",DATA_MIN_SELECTIONS_MESSAGE:"data-min-selections-message",DATA_CHOICES_CONTAINER_WIDTH:null},this.parentClass=t,this.clazzTokens=[],this.gapMatchGroupElement=null,this.gapChoiceWrapperElement=null,this.gapTargetWrapperElement=null,this.choicesContainerWidth=null,this.gapChoices=[],this.gaps=[],this.presentation_Choices_Orientation=null,this.presentation_MaxSelectionsMessage="",this.presentation_MinSelectionsMessage=""}initialize(t,i,s,n,r,a){this.gapMatchGroupElement=t,this.gapChoiceWrapperElement=i,this.gapTargetWrapperElement=s,this.choicesContainerWidth=n,this.gapChoices=r,this.gaps=a,this.processRootClassAttribute(this.parentClass),this.processPresentation()}processRootClassAttribute(t){const i=t.split(" ");for(let s=0;s<i.length;s++)switch(i[s]){case this.constants.QTI_CHOICES_TOP:case this.constants.QTI_CHOICES_BOTTOM:case this.constants.QTI_CHOICES_LEFT:case this.constants.QTI_CHOICES_RIGHT:this.presentation_Choices_Orientation=i[s];break}this.clazzTokens=i}processPresentation(){this.presentation_Choices_Orientation===null&&(this.presentation_Choices_Orientation=this.constants.QTI_CHOICES_TOP),this.presentation_Choices_Orientation===this.constants.QTI_CHOICES_LEFT?(this.gapChoiceWrapperElement.classList.add(this.constants.QTI_CHOICES_LEFT),this.gapTargetWrapperElement.classList.add(this.constants.QTI_CHOICES_LEFT),this.gapMatchGroupElement.classList.add(this.constants.QTI_CHOICES_LEFT)):this.presentation_Choices_Orientation===this.constants.QTI_CHOICES_TOP?(this.gapChoiceWrapperElement.classList.add(this.constants.QTI_CHOICES_TOP),this.gapTargetWrapperElement.classList.add(this.constants.QTI_CHOICES_TOP)):this.presentation_Choices_Orientation===this.constants.QTI_CHOICES_RIGHT?(this.gapChoiceWrapperElement.classList.add(this.constants.QTI_CHOICES_RIGHT),this.gapTargetWrapperElement.classList.add(this.constants.QTI_CHOICES_RIGHT),this.gapMatchGroupElement.classList.add(this.constants.QTI_CHOICES_RIGHT),this.gapMatchGroupElement.insertBefore(this.gapTargetWrapperElement,this.gapChoiceWrapperElement)):this.presentation_Choices_Orientation===this.constants.QTI_CHOICES_BOTTOM&&(this.gapChoiceWrapperElement.classList.add(this.constants.QTI_CHOICES_BOTTOM),this.gapTargetWrapperElement.classList.add(this.constants.QTI_CHOICES_BOTTOM),this.gapMatchGroupElement.insertBefore(this.gapTargetWrapperElement,this.gapChoiceWrapperElement)),this.processChoicesContainerWidth(),this.processGaps()}processChoicesContainerWidth(){this.choicesContainerWidth!==null&&(this.gapChoiceWrapperElement.style.width=`${this.choicesContainerWidth}px`)}processGaps(){for(let t=0;t<this.gaps.length;t++)this.gaps[t].classList.add("target")}}class vq{constructor(t,i){ee(this,"options",{interactionSubType:"default",cardinality:"single",maxAssociations:0,response:null,onReady:null,onUpdate:null,onSelectionsLimit:null});return this.qtiAttributeValidation=new F,this.wrapper=t,this.sourcewrapper=this.wrapper.querySelector(".qti-gap-match-source-wrapper"),this.targetwrapper=this.wrapper.querySelector(".qti-gap-match-target-wrapper"),this.processOptions(i),this.handleDragStart=this.handleDragStart.bind(this),this.handleDragMove=this.handleDragMove.bind(this),this.handleDragEnd=this.handleDragEnd.bind(this),this.handleTouchStart=this.handleTouchStart.bind(this),this.handleTouchMove=this.handleTouchMove.bind(this),this.handleTouchEnd=this.handleTouchEnd.bind(this),this.itemTarget=null,this.itemStart=null,this.isItemStartSource=!0,this.initialX=0,this.initialY=0,this.offsetX=0,this.offsetY=0,this.startingX=0,this.startingY=0,this.currentAssociationsCount=0,this.isDisabled=!1,this.currentDragger=null,this.initializeSources(this.sourcewrapper),this.initializeTargets(this.targetwrapper),this.restoreResponse(this.options.response),this.notifyReady(),this}processOptions(t){"interactionSubType"in t&&(this.options.interactionSubType=t.interactionSubType),"cardinality"in t&&(this.options.cardinality=t.cardinality),"response"in t&&(this.options.response=t.response),"maxAssociations"in t&&(this.options.maxAssociations=t.maxAssociations),"onReady"in t&&(this.options.onReady=t.onReady),"onUpdate"in t&&(this.options.onUpdate=t.onUpdate),"onAssociationsLimit"in t&&(this.options.onAssociationsLimit=t.onAssociationsLimit)}notifyReady(){this.options.onReady!==null&&this.options.onReady({response:this.getResponse()})}notifyUpdate(){this.options.onUpdate!==null&&this.options.onUpdate({response:this.computeResponse()})}notifyAssociationsLimit(){this.options.onAssociationsLimit!==null&&this.options.onAssociationsLimit()}toggleDisable(t){this.isDisabled=t,this.draggers.forEach(i=>{t?i.classList.add("disabled"):i.classList.remove("disabled")})}handleDragStart(t){if(t.preventDefault(),!this.isDisabled&&t.button==0)return this.interactionStart(t.target,t.clientX,t.clientY,!1),!1}handleTouchStart(t){if(t.preventDefault(),!this.isDisabled)return t.targetTouches.length!=1||this.interactionStart(t.target,t.touches[0].pageX,t.touches[0].pageY,!0),!1}interactionStart(t,i,s,n){const r=this.getClosestElement(t,"draggable");this.itemStart=r.parentNode,this.isItemStartSource=this.itemStart.classList.contains("source"),this.identifyTargets(this.itemStart,!0),this.itemTarget=null;const a=r.getBoundingClientRect();this.initialX=i,this.initialY=s,this.startingX=a.left,this.startingY=a.top,this.offsetX=i-this.startingX,this.offsetY=s-this.startingY,this.addPlaceholder(r),r.style.userSelect="none",r.style.width=a.width+"px",r.style.height=a.height+"px",r.style.transform=`translateX(${a.left}px) translateY(${a.top}px) translateZ(0)`,r.classList.add("dragging"),this.setCurrentDragger(r),this.addListeners(r,n)}handleDragMove(t){t.preventDefault(),!this.isDisabled&&this.interactionMove(t.clientX,t.clientY)}handleTouchMove(t){t.preventDefault(),!this.isDisabled&&t.targetTouches.length==1&&this.interactionMove(t.touches[0].clientX,t.touches[0].clientY)}interactionMove(t,i){const s=this.currentDragger;this.offsetX=t-this.initialX,this.offsetY=i-this.initialY,this.constrainDraggerToWrapper(s,this.wrapper),s.style.transform=`translateX(${this.startingX+this.offsetX}px) translateY(${this.startingY+this.offsetY}px) translateZ(0) scale(1)`;const n=s.getBoundingClientRect();this.findDraggerItemTarget(s,n,this.targets),this.isItemStartSource||this.findSourceDraggerTarget(s,n)}constrainDraggerToWrapper(t,i){const s=t.getBoundingClientRect(),n=i.getBoundingClientRect(),r=this.startingX+this.offsetX-n.x,a=this.startingY+this.offsetY-n.y,o=this.startingX+s.width+this.offsetX-(n.x+n.width),u=this.startingY+s.height+this.offsetY-(n.y+n.height);r<0&&(this.offsetX=this.offsetX-r),o>0&&(this.offsetX=this.offsetX-o),a<0&&(this.offsetY=this.offsetY-a),u>0&&(this.offsetY=this.offsetY-u)}handleDragEnd(t){this.isDisabled||this.interactionEnd(t.clientX,t.clientY,!1)}handleTouchEnd(t){this.isDisabled||this.interactionEnd(t.changedTouches[0].clientX,t.changedTouches[0].clientY,!0)}interactionEnd(t,i,s){const n=this.currentDragger;if(this.itemTarget===null?n.style.transform=`translateX(${this.startingX}px) translateY(${this.startingY}px) translateZ(0)`:n.style.transform=`translateX(${this.startingX+this.offsetX}px) translateY(${this.startingY+this.offsetY}px) translateZ(0)`,n.removeAttribute("style"),n.classList.remove("dragging"),this.clearTargetHighlights(),this.itemTarget===null){this.resetDraggerToItemStart(this.itemStart,n),this.setCurrentDragger(null),this.removeListeners(n,s);return}if(this.itemTarget.classList.contains("active")){if(this.itemTarget.classList.remove("active"),this.isExceedingMaxAssociations(this.itemStart,this.itemTarget,n)){this.resetDraggerToItemStart(this.itemStart,n),this.notifyAssociationsLimit(),this.setCurrentDragger(null),this.removeListeners(n,s);return}if(this.itemStart.getAttribute("data-identifier")===this.itemTarget.getAttribute("data-identifier")){this.resetDraggerToItemStart(this.itemStart,n),this.setCurrentDragger(null),this.removeListeners(n,s);return}this.removePlaceholder(n),this.setDraggerToItemTarget(this.itemTarget,n),this.itemTarget.classList.contains("source")&&(this.itemTarget.classList.add("full"),this.itemTarget.dataset.matchMax*1>0&&this.incrementRemaining(this.itemTarget),this.decrementAssociationsCount(),this.sortContainerElements(this.sourcewrapper)),this.itemStart.classList.contains("source")&&(this.itemStart.dataset.matchMax*1>0&&this.decrementRemaining(this.itemStart)===0&&this.itemStart.classList.remove("full"),this.incrementAssociationsCount()),this.itemStart.classList.contains("target")&&(this.isTargetFull(this.itemStart)?this.itemStart.classList.add("full"):this.itemStart.classList.remove("full")),this.notifyUpdate()}this.setCurrentDragger(null),this.removeListeners(n,s)}setCurrentDragger(t){this.currentDragger=t}resetDraggerToItemStart(t,i){this.replacePlaceholder(i),t.classList.contains("source")||i.setAttribute("style","width:100%")}setDraggerToItemTarget(t,i){if(t.classList.contains("source")){if(t.classList.contains("full")){const s=t.querySelector(".draggable");s!=null&&t.replaceChild(i,s);return}t.append(i);return}t.append(i),i.setAttribute("style","width:100%"),this.isTargetFull(t)?t.classList.add("full"):t.classList.remove("full")}findDraggerItemTarget(t,i,s){this.itemTarget=null,s.forEach(n=>{const r=n.getBoundingClientRect();if(i.top+t.offsetHeight/2<r.bottom&&i.right-t.offsetWidth/2>r.left&&i.bottom-t.offsetHeight/2>r.top&&i.left+t.offsetWidth/2<r.right){if(this.isItemStartSource&&n.classList.contains("source")||n.classList.contains("full")||!this.hasMatchingMatchGroup(t.parentNode,n))return;n.classList.add("active"),this.itemTarget=n}else n.classList.remove("active")},this)}findSourceDraggerTarget(t,i){const s=this.sourcewrapper.getBoundingClientRect();if(i.top+t.offsetHeight/2<s.bottom&&i.right-t.offsetWidth/2>s.left&&i.bottom-t.offsetHeight/2>s.top&&i.left+t.offsetWidth/2<s.right){for(let n=0;n<this.sources.length;n++)if(this.sources[n].dataset.identifier===t.dataset.identifier){this.sources[n].classList.add("active"),this.itemTarget=this.sources[n];break}}else for(let n=0;n<this.sources.length;n++)this.sources[n].classList.contains("active")&&this.sources[n].classList.remove("active")}addPlaceholder(t){if(!t.parentNode.classList.contains("source")){this.addPlaceholderElement(t,!1);return}const i=t.parentNode.dataset.matchMax*1;if(i===1){this.addPlaceholderElement(t,!1);return}if(i===0){this.addPlaceholderElement(t,!0);return}if(this.getRemaining(t.parentNode)===1){this.addPlaceholderElement(t,!1);return}this.addPlaceholderElement(t,!0)}addPlaceholderElement(t,i){const s=t.cloneNode(!0);this.deepCloneId(s),i?(s.classList.add("clone"),s.addEventListener("mousedown",this.handleDragStart),s.addEventListener("touchstart",this.handleTouchStart)):s.classList.add("gm-dragger-placeholder"),s.classList.add("placeholder-fade"),t.parentNode.insertBefore(s,t)}removePlaceholder(t){if(t.parentNode.classList.contains("target")){const n=t.parentNode.querySelector(".gm-dragger-placeholder");if(n===null)return;t.parentNode.removeChild(n);return}const i=t.parentNode.dataset.matchMax*1,s=t.parentNode.querySelector(".gm-dragger-placeholder");if(s===null){const n=t.parentNode.querySelector(".clone");if(n===null)return;n.classList.remove("placeholder-fade");return}i!==0&&t.parentNode.removeChild(s)}replacePlaceholder(t){const i=t.parentNode;let s=i.querySelector(".gm-dragger-placeholder");if(i.classList.contains("source")){if(s==null&&(s=i.querySelector(".draggable")),s===null)return;i.replaceChild(t,s);return}s!==null&&i.replaceChild(t,s)}addClonePlaceholder(t){const i=t.cloneNode(!0);this.deepCloneId(i),i.classList.add("clone"),t.parentNode.insertBefore(i,t),i.addEventListener("mousedown",this.handleDragStart),i.addEventListener("touchstart",this.handleTouchStart)}initializeSources(t){this.sources=t.querySelectorAll(".source"),this.sources.forEach(i=>{i.classList.add("full");const s=i.dataset.matchMax*1;this.setRemaining(i,s===0?1e3:s)},this),this.draggers=t.querySelectorAll(".draggable"),this.draggers.forEach((i,s)=>{const n=i.parentNode.getAttribute("data-identifier");i.setAttribute("data-identifier",n),i.setAttribute("data-order",s),i.setAttribute("tabindex",0),i.addEventListener("mousedown",this.handleDragStart),i.addEventListener("touchstart",this.handleTouchStart)},this)}initializeTargets(t){this.targets=t.querySelectorAll(".target"),this.targets.forEach(i=>{i.setAttribute("tabindex",0)})}identifyTargets(t,i){this.targets.forEach(s=>{i&&!s.classList.contains("full")&&this.hasMatchingMatchGroup(t,s)&&s.classList.add("target-active")},this),i&&!this.isItemStartSource&&this.sourcewrapper.classList.add("target-active")}addListeners(t,i){i?(this.removeListeners(t,i),t.addEventListener("touchmove",this.handleTouchMove),t.addEventListener("touchend",this.handleTouchEnd)):(this.removeListeners(t,i),document.addEventListener("mousemove",this.handleDragMove),document.addEventListener("mouseup",this.handleDragEnd))}removeListeners(t,i){i?(t.removeEventListener("touchmove",this.handleTouchMove),t.removeEventListener("touchend",this.handleTouchEnd)):(document.removeEventListener("mousemove",this.handleDragMove),document.removeEventListener("mouseup",this.handleDragEnd))}clearTargetHighlights(){this.targets.forEach(t=>{t.classList.remove("target-active")},this),this.sourcewrapper.classList.remove("target-active")}getClosestElement(t,i){return t?t&&t.classList.contains(i)?t:this.getClosestElement(t.parentElement,i):!1}sortContainerElements(t){let i=[],s=t.children;for(let n=0;n<s.length;n++){const r=s[n].querySelector("div.draggable");r&&i.push([1*r.dataset.order,s[n]])}i.sort(function(n,r){return n[0]-r[0]});for(let n=0;n<i.length;n++)t.appendChild(i[n][1])}getResponse(){return this.computeResponse()}computeResponse(){let t=[];return this.targets.forEach(i=>{i.querySelectorAll(".draggable").forEach(s=>{t.push(`${s.dataset.identifier} ${i.dataset.identifier}`)})}),t.length===0?null:this.options.cardinality==="single"?t[0]:t}restoreResponse(t){t!==null&&(this.options.cardinality==="single"?this.restoreResponsePair(t):t.forEach(i=>{this.restoreResponsePair(i)},this))}restoreResponsePair(t){const i=this.getPair(t);if(i===null)return;const s=this.findSourceByIdentifier(i.source),n=this.findTargetGapByIdentifier(i.target);if(s===null||n===null)return;const r=s.querySelector(".draggable");r!==null&&(this.cloneOrEmptySourceDragger(s,r),this.restoreSourceDraggerToTarget(n,r))}cloneOrEmptySourceDragger(t,i){const s=t.dataset.matchMax*1;if(s===1){t.classList.remove("full"),this.decrementRemaining(t);return}if(s===0){this.addClonePlaceholder(i);return}if(this.getRemaining(t)===1){t.classList.remove("full"),this.decrementRemaining(t);return}this.decrementRemaining(t),this.addClonePlaceholder(i)}findSourceByIdentifier(t){for(let i=0;i<this.sources.length;i++)if(t===this.sources[i].dataset.identifier)return this.sources[i];return null}findTargetGapByIdentifier(t){for(let i=0;i<this.targets.length;i++)if(t===this.targets[i].dataset.identifier)return this.targets[i];return null}getPair(t){if(t===null)return null;const i=t.split(" ");return i.length!=2?null:{source:i[0],target:i[1]}}restoreSourceDraggerToTarget(t,i){t===null||i===null||(t.append(i),i.setAttribute("style","width:100%"),this.incrementAssociationsCount(),this.isTargetFull(t)&&t.classList.add("full"))}hasMatchingMatchGroup(t,i){return t===null||i===null?!1:t.dataset.matchGroup===i.dataset.matchGroup}isTargetFull(t){if(t==null)return!1;const i=t.querySelectorAll(".draggable"),s=t.dataset.matchMax*1;return s===0?!1:i.length>=s}isExceedingMaxAssociations(t,i){return!(this.options.maxAssociations===0||i.classList.contains("source")||t.classList.contains("target")||this.currentAssociationsCount<this.options.maxAssociations)}initializeAssociationsCount(){this.currentAssociationsCount=0}incrementAssociationsCount(){this.currentAssociationsCount+=1}decrementAssociationsCount(){this.currentAssociationsCount!==0&&(this.currentAssociationsCount-=1)}getRemaining(t){return t.dataset.remaining*1}setRemaining(t,i){t.setAttribute("data-remaining",i)}incrementRemaining(t){const i=t.dataset.remaining*1+1;return t.setAttribute("data-remaining",i),i}decrementRemaining(t){let i=t.dataset.remaining*1-1;return i=i>=0?i:0,t.setAttribute("data-remaining",i),i}deepCloneId(t){t.id&&(t.id=`clone_${this.qtiAttributeValidation.randomString(5,"a")}`);for(let i=0;i<t.children.length;i++)this.deepCloneId(t.children[i])}reset(){this.resetDraggersToSources(),this.initializeAssociationsCount(),this.destroy()}resetDraggersToSources(){this.targets.forEach(t=>{t.querySelectorAll(".draggable").forEach(s=>{const n=this.findSourceByIdentifier(s.getAttribute("data-identifier"));n.classList.contains("full")||(t.classList.remove("full"),n.classList.contains("full")?t.removeChild(s):(n.append(s),n.classList.add("full")))},this)},this)}destroy(){this.currentDragger!==null&&(document.removeEventListener("mousemove",this.handleDragMove),document.removeEventListener("mouseup",this.handleDragEnd)),this.wrapper.querySelectorAll(".draggable").forEach(i=>{i.removeEventListener("touchstart",this.handleTouchStart),i.removeEventListener("touchmove",this.handleTouchMove),i.removeEventListener("touchend",this.handleTouchEnd),i.removeEventListener("mousedown",this.handleDragStart)},this)}}const Eq=new F,Cq=new te,Tq={emits:["gapMatchGroupReady","gapMatchGroupUpdate","gapMatchGroupAssociationsLimit"],props:{responseIdentifier:{required:!0,type:String},cardinality:{required:!0,type:String},shuffle:{required:!1,type:String,default:"false"},maxAssociations:{required:!1,type:String,default:"1"},minAssociations:{required:!1,type:String,default:"0"},dataChoicesContainerWidth:{required:!1,type:String,default:null},interactionSubType:{required:!1,type:String,default:"default"},gapMatchInteractionStaticClass:{required:!0,type:String},priorState:{required:!1,type:Object,default:null}},data(){return{choices:[],order:[],gaps:[],response:null,isShuffle:null,hasPrompt:!1,gapMatchInteractionClassAttribute:null,presentationFactory:null,matchable:null,isQtiValid:!0}},computed:{computedMaxAssociations(){return this.maxAssociations*1}},methods:{getResponse(){return this.response},setResponse(e){this.response=e},disable(){this.matchable!==null&&this.matchable.toggleDisable(!0)},enable(){this.matchable!==null&&this.matchable.toggleDisable(!1)},getChoices(){return this.choices},setIsShuffle(e){this.isShuffle=e},validateChildren(){let e=0;this.$slots.default()[0].children.forEach(t=>{if(Eq.isValidSlot(t)){if(t.type.name==="QtiPrompt"){if(e>0)throw new c("Invalid element order. qti-prompt must come before qti-gap-text's, qti-gap-img's, or qti-gap's");if(!this.hasPrompt)return this.hasPrompt=!0;throw new c("Maximum of 1 qti-prompt element permitted")}if(t.type.name==="QtiGapText"||t.type.name==="QtiGapImg")return e+=1;throw new c('Node is not one of qti-gap-text or qti-gap-img: "'+t.type.name+'"')}})},processChildren(){this.$.subTree.children[0].children[0].children.forEach(i=>{i.component!==null&&(i.type.name==="QtiGapText"||i.type.name==="QtiGapImg")&&this.choices.push(i.component.proxy)}),this.$refs.root.querySelectorAll(".gap-match-gap").forEach(i=>{this.gaps.push(i)})},insertAfter(e,t){t.parentNode.insertBefore(e,t.nextSibling)},processGroupUI(e){let t=this.createGapChoiceWrapper();if(t==null)return;let i=this.createContainer(this.priorState);this.processContainerChoices(i,t),this.saveContainerOrder(i);let s=this.createGapTargetWrapper(t);this.presentationFactory.initialize(this.$refs.root,t,s,this.dataChoicesContainerWidth,this.choices,this.gaps),this.matchable=new vq(this.$refs.root,{interactionSubType:this.interactionSubType,cardinality:this.cardinality,maxAssociations:this.computedMaxAssociations,response:e,onReady:this.handleWidgetReady,onUpdate:this.handleWidgetUpdate,onAssociationsLimit:this.handleAssociationsLimit})},createGapChoiceWrapper(){let e=this.$refs.root.querySelector(".qti-gap-choice");if(e===null)return null;let t=document.createElement("ul");return t.classList.add("qti-gap-match-source-wrapper"),this.$refs.root.insertBefore(t,e),t},createGapTargetWrapper(e){const t=document.createElement("div");t.classList.add("qti-gap-match-target-wrapper"),this.insertAfter(t,e);const i=t.nextElementSibling;return i!=null&&t.append(i),t},createContainer(e){let t=[];return e===null?(this.choices.forEach(s=>{t.push({fixed:s.fixed==="true",node:s})}),this.isShuffle&&Cq.shuffleArrayFixed(t),t):(e.state.order.forEach(s=>{const n=this.findChoiceByIdentifier(s,this.choices);n!==null&&t.push({fixed:n.fixed==="true",node:n})},this),t)},processContainerChoices(e,t){this.choices.splice(0,this.choices.length),t.innerHTML="",e.forEach(i=>{t.appendChild(i.node.$el),this.choices.push(i.node)},this)},saveContainerOrder(e){const t=[];e.forEach(i=>{t.push(i.node.identifier)}),this.order=t},findChoiceByIdentifier(e,t){for(let i=0;i<t.length;i++)if(t[i].$el.getAttribute("data-identifier")===e)return t[i];throw new O('Gap Match Interaction State Invalid. Choice identifier "'+e+'" not found.')},resetGroupUI(){this.processGroupUI(null)},handleWidgetReady(e){this.setResponse(e.response),this.$emit("gapMatchGroupReady",{response:this.getResponse(),order:this.order})},handleWidgetUpdate(e){this.setResponse(e.response),this.$emit("gapMatchGroupUpdate",{response:this.getResponse()})},handleAssociationsLimit(){this.$emit("gapMatchGroupAssociationsLimit")},initializeGapMatchGroup(){this.presentationFactory=new bq(this.gapMatchInteractionStaticClass)}},created(){try{if(typeof this.cardinality>"u")throw new c("Undefined qti-gap-match-interaction cardinality");if(this.cardinality!=="single"&&this.cardinality!=="multiple")throw new c('qti-gap-match-interaction cardinality must be "single" or "multiple"');this.setIsShuffle(this.shuffle==="true"),this.initializeGapMatchGroup(),this.validateChildren()}catch(e){throw this.isQtiValid=!1,console.log("[QtiGapMatchInteraction][ValidationError]",e.name,e.message),new c(e.message)}},mounted(){if(this.isQtiValid)try{this.processChildren(),this.processGroupUI(this.priorState===null?null:this.priorState.value)}catch(e){if(this.isQtiValid=!1,e.name==="QtiValidationException")throw console.log("[QtiGapMatchInteraction][ValidationException]",e.message),new c(e.message);if(e.name==="QtiEvaluationException")throw console.log("[QtiGapMatchInteraction][EvaluationException]",e.message),new O(e.message)}},beforeUnmount(){this.matchable!==null&&(this.matchable.destroy(),this.matchable=null)}},Sq={ref:"root",class:"qti-gap-match-group-wrapper"};function xq(e,t,i,s,n,r){return l.openBlock(),l.createElementBlock("div",Sq,[l.renderSlot(e.$slots,"default")],512)}const Iq=P(Tq,[["render",xq]]);class _q{constructor(t){this.constants={QTI_SELECTIONS_LIGHT:"qti-selections-light",QTI_SELECTIONS_DARK:"qti-selections-dark",QTI_UNSELECTED_HIDDEN:"qti-unselected-hidden",QTI_CHOICES_TOP:"qti-choices-top",QTI_CHOICES_BOTTOM:"qti-choices-bottom",QTI_CHOICES_LEFT:"qti-choices-left",QTI_CHOICES_RIGHT:"qti-choices-right",DATA_MAX_SELECTIONS_MESSAGE:"data-max-selections-message",DATA_MIN_SELECTIONS_MESSAGE:"data-min-selections-message",DATA_CHOICES_CONTAINER_WIDTH:null},this.parentClass=t,this.clazzTokens=[],this.ggmGroupElement=null,this.ggmChoiceWrapperElement=null,this.ggmTargetWrapperElement=null,this.image=null,this.choicesContainerWidth=null,this.gapChoices=[],this.gaps=[],this.presentation_Choices_Orientation=null,this.presentation_Theme=this.constants.QTI_SELECTIONS_DARK,this.presentation_UnselectedHidden=!1,this.presentation_MaxSelectionsMessage="",this.presentation_MinSelectionsMessage=""}initialize(t,i,s,n,r,a,o){this.ggmGroupElement=t,this.ggmChoiceWrapperElement=i,this.ggmTargetWrapperElement=s,this.image=n,this.choicesContainerWidth=r,this.gapChoices=a,this.gaps=o,this.processRootClassAttribute(this.parentClass),this.processPresentation()}processRootClassAttribute(t){const i=t.split(" ");for(let s=0;s<i.length;s++)switch(i[s]){case this.constants.QTI_CHOICES_TOP:case this.constants.QTI_CHOICES_BOTTOM:case this.constants.QTI_CHOICES_LEFT:case this.constants.QTI_CHOICES_RIGHT:this.presentation_Choices_Orientation=i[s];break;case this.constants.QTI_SELECTIONS_DARK:case this.constants.QTI_SELECTIONS_LIGHT:this.presentation_Theme=i[s];break;case this.constants.QTI_UNSELECTED_HIDDEN:this.presentation_UnselectedHidden=!0;break}this.clazzTokens=i}processPresentation(){this.presentation_Choices_Orientation===null&&(this.presentation_Choices_Orientation=this.constants.QTI_CHOICES_TOP),this.presentation_Choices_Orientation===this.constants.QTI_CHOICES_LEFT?(this.ggmChoiceWrapperElement.classList.add(this.constants.QTI_CHOICES_LEFT),this.ggmTargetWrapperElement.classList.add(this.constants.QTI_CHOICES_LEFT),this.ggmGroupElement.classList.add(this.constants.QTI_CHOICES_LEFT)):this.presentation_Choices_Orientation===this.constants.QTI_CHOICES_TOP?(this.ggmChoiceWrapperElement.classList.add(this.constants.QTI_CHOICES_TOP),this.ggmTargetWrapperElement.classList.add(this.constants.QTI_CHOICES_TOP)):this.presentation_Choices_Orientation===this.constants.QTI_CHOICES_RIGHT?(this.ggmChoiceWrapperElement.classList.add(this.constants.QTI_CHOICES_RIGHT),this.ggmTargetWrapperElement.classList.add(this.constants.QTI_CHOICES_RIGHT),this.ggmGroupElement.classList.add(this.constants.QTI_CHOICES_RIGHT),this.ggmGroupElement.insertBefore(this.ggmTargetWrapperElement,this.ggmChoiceWrapperElement)):this.presentation_Choices_Orientation===this.constants.QTI_CHOICES_BOTTOM&&(this.ggmChoiceWrapperElement.classList.add(this.constants.QTI_CHOICES_BOTTOM),this.ggmTargetWrapperElement.classList.add(this.constants.QTI_CHOICES_BOTTOM),this.ggmGroupElement.insertBefore(this.ggmTargetWrapperElement,this.ggmChoiceWrapperElement)),this.processBackgroundImage(),this.processChoicesContainerWidth(),this.processGaps()}processBackgroundImage(){if(this.image===null)return;this.image.setAttribute("draggable","false");const t=this.image.getBoundingClientRect();this.ggmTargetWrapperElement.style.width=`${t.width}px`,this.ggmTargetWrapperElement.style.height=`${t.height}px`}processChoicesContainerWidth(){this.choicesContainerWidth!==null&&(this.ggmChoiceWrapperElement.style.width=`${this.choicesContainerWidth}px`,this.ggmChoiceWrapperElement.style.textAlign="center")}processGaps(){for(let t=0;t<this.gaps.length;t++){const i=this.gaps[t];this.setGapStyle(i,i.getShape(),i.getShapeData()),this.gaps[t].$refs.gap.classList.add("target",this.presentation_Theme),this.presentation_UnselectedHidden&&this.gaps[t].$refs.gap.classList.add(this.constants.QTI_UNSELECTED_HIDDEN)}}setGapStyle(t,i,s){switch(i){case"rect":t.$refs.gap.style.left=`${s[0]}px`,t.$refs.gap.style.top=`${s[1]}px`,t.$refs.gap.style.width=`${s[2]}px`,t.$refs.gap.style.height=`${s[3]}px`;break}}}class Vq{constructor(t,i){ee(this,"options",{interactionSubType:"default",cardinality:"multiple",maxAssociations:0,response:null,onReady:null,onUpdate:null,onSelectionsLimit:null,zindex:1e3});return this.qtiAttributeValidation=new F,this.wrapper=t,this.sourcewrapper=this.wrapper.querySelector(".qti-ggm-source-wrapper"),this.targetwrapper=this.wrapper.querySelector(".qti-ggm-target-wrapper"),this.processOptions(i),this.handleDragStart=this.handleDragStart.bind(this),this.handleDragMove=this.handleDragMove.bind(this),this.handleDragEnd=this.handleDragEnd.bind(this),this.handleTouchStart=this.handleTouchStart.bind(this),this.handleTouchMove=this.handleTouchMove.bind(this),this.handleTouchEnd=this.handleTouchEnd.bind(this),this.itemTarget=null,this.itemStart=null,this.isItemStartSource=!0,this.savedGapZindex="",this.initialX=0,this.initialY=0,this.offsetX=0,this.offsetY=0,this.startingX=0,this.startingY=0,this.currentAssociationsCount=0,this.isDisabled=!1,this.currentDragger=null,this.initializeSources(this.sourcewrapper),this.initializeTargets(this.targetwrapper),this.restoreResponse(this.options.response),this.notifyReady(),this}processOptions(t){"interactionSubType"in t&&(this.options.interactionSubType=t.interactionSubType),"cardinality"in t&&(this.options.cardinality=t.cardinality),"response"in t&&(this.options.response=t.response),"maxAssociations"in t&&(this.options.maxAssociations=t.maxAssociations),"onReady"in t&&(this.options.onReady=t.onReady),"onUpdate"in t&&(this.options.onUpdate=t.onUpdate),"onAssociationsLimit"in t&&(this.options.onAssociationsLimit=t.onAssociationsLimit)}notifyReady(){this.options.onReady!==null&&this.options.onReady({response:this.getResponse()})}notifyUpdate(){this.options.onUpdate!==null&&this.options.onUpdate({response:this.computeResponse()})}notifyAssociationsLimit(){this.options.onAssociationsLimit!==null&&this.options.onAssociationsLimit()}toggleDisable(t){this.isDisabled=t,this.draggers.forEach(i=>{t?i.classList.add("disabled"):i.classList.remove("disabled")})}handleDragStart(t){if(t.preventDefault(),!this.isDisabled&&t.button==0)return this.interactionStart(t.target,t.clientX,t.clientY,!1),!1}handleTouchStart(t){if(t.preventDefault(),!this.isDisabled)return t.targetTouches.length!=1||this.interactionStart(t.target,t.touches[0].pageX,t.touches[0].pageY,!0),!1}interactionStart(t,i,s,n){const r=this.getClosestElement(t,"draggable");this.itemStart=r.parentNode,this.isItemStartSource=this.itemStart.classList.contains("source"),this.isItemStartSource||this.saveGapZindex(this.itemStart),this.identifyTargets(this.itemStart,!0),this.itemTarget=null;const a=r.getBoundingClientRect();this.initialX=i,this.initialY=s,this.startingX=a.left,this.startingY=a.top,this.offsetX=i-this.startingX,this.offsetY=s-this.startingY,this.addPlaceholder(r),r.classList.add("dragging"),r.style.userSelect="none",r.style.width=a.width+"px",r.style.height=a.height+"px",r.style.transform=`translateX(${a.left}px) translateY(${a.top}px) translateZ(0)`,this.setCurrentDragger(r),this.addListeners(r,n)}handleDragMove(t){t.preventDefault(),!this.isDisabled&&this.interactionMove(t.clientX,t.clientY)}handleTouchMove(t){t.preventDefault(),!this.isDisabled&&t.targetTouches.length==1&&this.interactionMove(t.touches[0].clientX,t.touches[0].clientY)}interactionMove(t,i){const s=this.currentDragger;this.offsetX=t-this.initialX,this.offsetY=i-this.initialY,this.constrainDraggerToWrapper(s,this.wrapper),s.style.transform=`translateX(${this.startingX+this.offsetX}px) translateY(${this.startingY+this.offsetY}px) translateZ(0) scale(1)`;const n=s.getBoundingClientRect();this.findDraggerItemTarget(s,n,this.targets),this.isItemStartSource||this.findSourceDraggerTarget(s,n)}constrainDraggerToWrapper(t,i){const s=t.getBoundingClientRect(),n=i.getBoundingClientRect(),r=this.startingX+this.offsetX-n.x,a=this.startingY+this.offsetY-n.y,o=this.startingX+s.width+this.offsetX-(n.x+n.width),u=this.startingY+s.height+this.offsetY-(n.y+n.height);r<0&&(this.offsetX=this.offsetX-r),o>0&&(this.offsetX=this.offsetX-o),a<0&&(this.offsetY=this.offsetY-a),u>0&&(this.offsetY=this.offsetY-u)}handleDragEnd(t){this.isDisabled||this.interactionEnd(t.clientX,t.clientY,!1)}handleTouchEnd(t){this.isDisabled||this.interactionEnd(t.changedTouches[0].clientX,t.changedTouches[0].clientY,!0)}interactionEnd(t,i,s){const n=this.currentDragger;if(this.itemTarget===null?n.style.transform=`translateX(${this.startingX}px) translateY(${this.startingY}px) translateZ(0)`:n.style.transform=`translateX(${this.startingX+this.offsetX}px) translateY(${this.startingY+this.offsetY}px) translateZ(0)`,n.removeAttribute("style"),n.classList.remove("dragging"),this.clearTargetHighlights(),this.itemTarget===null){this.resetDraggerToItemStart(this.itemStart,n),this.setCurrentDragger(null),this.removeListeners(n,s);return}if(this.itemTarget.classList.contains("active")){if(this.itemTarget.classList.remove("active"),this.isExceedingMaxAssociations(this.itemStart,this.itemTarget,n)){this.resetDraggerToItemStart(this.itemStart,n),this.notifyAssociationsLimit(),this.setCurrentDragger(null),this.removeListeners(n,s);return}if(this.itemStart.getAttribute("data-identifier")===this.itemTarget.getAttribute("data-identifier")){this.resetDraggerToItemStart(this.itemStart,n),this.setCurrentDragger(null),this.removeListeners(n,s);return}this.removePlaceholder(n),this.setDraggerToItemTarget(this.itemTarget,n),this.itemTarget.classList.contains("source")&&(this.itemTarget.classList.add("full"),this.itemTarget.dataset.matchMax*1>0&&this.incrementRemaining(this.itemTarget),this.decrementAssociationsCount(),this.sortContainerElements(this.sourcewrapper)),this.itemStart.classList.contains("source")&&(this.itemStart.dataset.matchMax*1>0&&this.decrementRemaining(this.itemStart)===0&&this.itemStart.classList.remove("full"),this.incrementAssociationsCount()),this.itemStart.classList.contains("target")&&(this.restoreGapZindex(this.itemStart),this.isTargetFull(this.itemStart)?this.itemStart.classList.add("full","contains-choice"):(this.itemStart.classList.remove("full"),this.containsChoices(this.itemStart)?this.itemStart.classList.add("contains-choice"):this.itemStart.classList.remove("contains-choice"))),this.notifyUpdate()}this.setCurrentDragger(null),this.removeListeners(n,s)}setCurrentDragger(t){this.currentDragger=t}resetDraggerToItemStart(t,i){t.classList.contains("target")&&this.restoreGapZindex(t),this.replacePlaceholder(i)}setDraggerToItemTarget(t,i){if(t.classList.contains("source")){this.appendDraggerToSourceTarget(t,i);return}this.appendDraggerToGapTarget(t,i),this.isTargetFull(t)?t.classList.add("full"):t.classList.remove("full")}appendDraggerToSourceTarget(t,i){if(t.classList.contains("full")){const s=t.querySelector(".draggable");s!=null&&t.replaceChild(i,s);return}t.append(i)}appendDraggerToGapTarget(t,i){t.classList.add("contains-choice"),t.append(i)}findDraggerItemTarget(t,i,s){this.itemTarget=null,s.forEach(n=>{const r=n.getBoundingClientRect();if(i.top+t.offsetHeight/2<r.bottom&&i.right-t.offsetWidth/2>r.left&&i.bottom-t.offsetHeight/2>r.top&&i.left+t.offsetWidth/2<r.right){if(this.isItemStartSource&&n.classList.contains("source")||n.classList.contains("full")||!this.hasMatchingMatchGroup(t.parentNode,n))return;n.classList.add("active"),this.itemTarget=n}else n.classList.remove("active")},this)}findSourceDraggerTarget(t,i){const s=this.sourcewrapper.getBoundingClientRect();if(i.top+t.offsetHeight/2<s.bottom&&i.right-t.offsetWidth/2>s.left&&i.bottom-t.offsetHeight/2>s.top&&i.left+t.offsetWidth/2<s.right){for(let n=0;n<this.sources.length;n++)if(this.sources[n].dataset.identifier===t.dataset.identifier){this.sources[n].classList.add("active"),this.itemTarget=this.sources[n];break}}else for(let n=0;n<this.sources.length;n++)this.sources[n].classList.contains("active")&&this.sources[n].classList.remove("active")}addPlaceholder(t){if(!t.parentNode.classList.contains("source")){this.addPlaceholderElement(t,!1);return}const i=t.parentNode.dataset.matchMax*1;if(i===1){this.addPlaceholderElement(t,!1);return}if(i===0){this.addPlaceholderElement(t,!0);return}if(this.getRemaining(t.parentNode)===1){this.addPlaceholderElement(t,!1);return}this.addPlaceholderElement(t,!0)}addPlaceholderElement(t,i){const s=t.cloneNode(!0);this.deepCloneId(s),i?(s.classList.add("clone"),s.addEventListener("mousedown",this.handleDragStart),s.addEventListener("touchstart",this.handleTouchStart)):s.classList.add("ggm-dragger-placeholder"),s.classList.add("placeholder-fade"),t.parentNode.insertBefore(s,t)}removePlaceholder(t){if(t.parentNode.classList.contains("target")){const n=t.parentNode.querySelector(".ggm-dragger-placeholder");if(n===null)return;t.parentNode.removeChild(n);return}const i=t.parentNode.dataset.matchMax*1,s=t.parentNode.querySelector(".ggm-dragger-placeholder");if(s===null){const n=t.parentNode.querySelector(".clone");if(n===null)return;n.classList.remove("placeholder-fade");return}i!==0&&t.parentNode.removeChild(s)}replacePlaceholder(t){const i=t.parentNode;let s=i.querySelector(".ggm-dragger-placeholder");if(i.classList.contains("source")){if(s==null&&(s=i.querySelector(".draggable")),s===null)return;i.replaceChild(t,s);return}s!==null&&i.replaceChild(t,s)}addClonePlaceholder(t){const i=t.cloneNode(!0);this.deepCloneId(i),i.classList.add("clone"),t.parentNode.insertBefore(i,t),i.addEventListener("mousedown",this.handleDragStart),i.addEventListener("touchstart",this.handleTouchStart)}initializeSources(t){this.sources=t.querySelectorAll(".source"),this.sources.forEach(i=>{i.classList.add("full");const s=i.dataset.matchMax*1;this.setRemaining(i,s===0?1e3:s)},this),this.draggers=t.querySelectorAll(".draggable"),this.draggers.forEach((i,s)=>{const n=i.parentNode.getAttribute("data-identifier");i.setAttribute("data-identifier",n),i.setAttribute("data-order",s),i.setAttribute("tabindex",0),i.addEventListener("mousedown",this.handleDragStart),i.addEventListener("touchstart",this.handleTouchStart)},this)}initializeTargets(t){this.targets=t.querySelectorAll(".target"),this.targets.forEach(i=>{i.setAttribute("tabindex",0)})}identifyTargets(t,i){this.targets.forEach(s=>{i&&!s.classList.contains("full")&&this.hasMatchingMatchGroup(t,s)&&s.classList.add("target-active")},this),i&&!this.isItemStartSource&&this.sourcewrapper.classList.add("target-active")}addListeners(t,i){i?(this.removeListeners(t,i),t.addEventListener("touchmove",this.handleTouchMove),t.addEventListener("touchend",this.handleTouchEnd)):(this.removeListeners(t,i),document.addEventListener("mousemove",this.handleDragMove),document.addEventListener("mouseup",this.handleDragEnd))}removeListeners(t,i){i?(t.removeEventListener("touchmove",this.handleTouchMove),t.removeEventListener("touchend",this.handleTouchEnd)):(document.removeEventListener("mousemove",this.handleDragMove),document.removeEventListener("mouseup",this.handleDragEnd))}clearTargetHighlights(){this.targets.forEach(t=>{t.classList.remove("target-active")},this),this.sourcewrapper.classList.remove("target-active")}getClosestElement(t,i){return t?t&&t.classList.contains(i)?t:this.getClosestElement(t.parentElement,i):!1}sortContainerElements(t){let i=[],s=t.children;for(let n=0;n<s.length;n++){const r=s[n].querySelector("div.draggable");r&&i.push([1*r.dataset.order,s[n]])}i.sort(function(n,r){return n[0]-r[0]});for(let n=0;n<i.length;n++)t.appendChild(i[n][1])}saveGapZindex(t){this.savedGapZindex=t.style.zIndex,t.style.zIndex=this.options.zindex}restoreGapZindex(t){t.style.zIndex=this.savedGapZindex}getResponse(){return this.computeResponse()}computeResponse(){let t=[];return this.targets.forEach(i=>{i.querySelectorAll(".draggable").forEach(s=>{t.push(`${s.dataset.identifier} ${i.dataset.identifier}`)})}),t.length===0?null:this.options.cardinality==="single"?t[0]:t}restoreResponse(t){t!==null&&(this.options.cardinality==="single"?this.restoreResponsePair(t):t.forEach(i=>{this.restoreResponsePair(i)},this))}restoreResponsePair(t){const i=this.getPair(t);if(i===null)return;const s=this.findSourceByIdentifier(i.source),n=this.findTargetGapByIdentifier(i.target);if(s===null||n===null)return;const r=s.querySelector(".draggable");r!==null&&(this.cloneOrEmptySourceDragger(s,r),this.restoreSourceDraggerToTarget(n,r))}cloneOrEmptySourceDragger(t,i){const s=t.dataset.matchMax*1;if(s===1){t.classList.remove("full"),this.decrementRemaining(t);return}if(s===0){this.addClonePlaceholder(i);return}if(this.getRemaining(t)===1){t.classList.remove("full"),this.decrementRemaining(t);return}this.decrementRemaining(t),this.addClonePlaceholder(i)}findSourceByIdentifier(t){for(let i=0;i<this.sources.length;i++)if(t===this.sources[i].dataset.identifier)return this.sources[i];return null}findTargetGapByIdentifier(t){for(let i=0;i<this.targets.length;i++)if(t===this.targets[i].dataset.identifier)return this.targets[i];return null}getPair(t){if(t===null)return null;const i=t.split(" ");return i.length!=2?null:{source:i[0],target:i[1]}}restoreSourceDraggerToTarget(t,i){t===null||i===null||(this.appendDraggerToGapTarget(t,i),this.incrementAssociationsCount(),this.isTargetFull(t)&&t.classList.add("full"))}hasMatchingMatchGroup(t,i){return t===null||i===null?!1:t.dataset.matchGroup===i.dataset.matchGroup}isTargetFull(t){if(t==null)return!1;const i=t.querySelectorAll(".draggable"),s=t.dataset.matchMax*1;return s===0?!1:i.length>=s}containsChoices(t){return t==null?!1:t.querySelectorAll(".draggable").length!==0}isExceedingMaxAssociations(t,i){return!(this.options.maxAssociations===0||i.classList.contains("source")||t.classList.contains("target")||this.currentAssociationsCount<this.options.maxAssociations)}initializeAssociationsCount(){this.currentAssociationsCount=0}incrementAssociationsCount(){this.currentAssociationsCount+=1}decrementAssociationsCount(){this.currentAssociationsCount!==0&&(this.currentAssociationsCount-=1)}getRemaining(t){return t.dataset.remaining*1}setRemaining(t,i){t.setAttribute("data-remaining",i)}incrementRemaining(t){const i=t.dataset.remaining*1+1;return t.setAttribute("data-remaining",i),i}decrementRemaining(t){let i=t.dataset.remaining*1-1;return i=i>=0?i:0,t.setAttribute("data-remaining",i),i}deepCloneId(t){t.id&&(t.id=`clone_${this.qtiAttributeValidation.randomString(5,"a")}`);for(let i=0;i<t.children.length;i++)this.deepCloneId(t.children[i])}reset(){this.resetDraggersToSources(),this.initializeAssociationsCount(),this.destroy()}resetDraggersToSources(){this.targets.forEach(t=>{t.querySelectorAll(".draggable").forEach(s=>{const n=this.findSourceByIdentifier(s.getAttribute("data-identifier"));n.classList.contains("full")||(n.classList.contains("full")?t.removeChild(s):(n.append(s),n.classList.add("full")))},this),t.classList.remove("full","contains-choice")},this)}destroy(){this.currentDragger!==null&&(document.removeEventListener("mousemove",this.handleDragMove),document.removeEventListener("mouseup",this.handleDragEnd)),this.wrapper.querySelectorAll(".draggable").forEach(i=>{i.removeEventListener("touchstart",this.handleTouchStart),i.removeEventListener("touchmove",this.handleTouchMove),i.removeEventListener("touchend",this.handleTouchEnd),i.removeEventListener("mousedown",this.handleDragStart)},this)}}const Aq=new F,$q=new te,Lq={emits:["ggmGroupReady","ggmGroupUpdate","ggmGroupAssociationsLimit"],props:{responseIdentifier:{required:!0,type:String},cardinality:{required:!0,type:String},shuffle:{required:!1,type:String,default:"false"},maxAssociations:{required:!1,type:String,default:"1"},minAssociations:{required:!1,type:String,default:"0"},dataChoicesContainerWidth:{required:!1,type:String,default:null},interactionSubType:{required:!1,type:String,default:"default"},interactionStaticClass:{required:!0,type:String},priorState:{required:!1,type:Object,default:null}},data(){return{image:null,choices:[],order:[],gaps:[],response:null,isShuffle:null,hasPrompt:!1,interactionClassAttribute:null,presentationFactory:null,matchable:null,isQtiValid:!0}},computed:{computedMaxAssociations(){return this.maxAssociations*1}},methods:{getResponse(){return this.response},setResponse(e){this.response=e},disable(){this.matchable!==null&&this.matchable.toggleDisable(!0)},enable(){this.matchable!==null&&this.matchable.toggleDisable(!1)},getChoices(){return this.choices},setIsShuffle(e){this.isShuffle=e},validateChildren(){let e=0,t=0,i=!1;this.$slots.default()[0].children.forEach(s=>{if(Aq.isValidSlot(s)){if(s.type.name==="QtiPrompt"){if(e>0||t>0||i)throw new c("Invalid element order. qti-prompt must come before the background image, qti-gap-text's, qti-gap-img's, or qti-associable-hotspot's");if(!this.hasPrompt)return this.hasPrompt=!0;throw new c("Maximum of 1 qti-prompt element permitted")}if(s.type.name==="QtiGapText"||s.type.name==="QtiGapImg"){if(t>0)throw new c("Invalid element order. qti-gap-text's and qti-gap-img's must come before qti-associable-hotspot's");return e+=1}if(s.type.name==="QtiAssociableHotspot")return t+=1;throw new c('Node is not one of qti-gap-text, qti-gap-img, or qti-associable-hotspot: "'+s.type.name+'"')}else if(s.type==="img"||s.type==="object"||s.type==="picture"){if(e>0||t>0)throw new c("Invalid element order. Background image must preceed qti-gap-text's, qti-gap-img's and qti-associable-hotspot's");i=!0}})},processChildren(){this.$.subTree.children[0].children[0].children.forEach(t=>{if(t.type==="img"||t.type==="object"||t.type==="picture"){this.image=t.el;return}t.component!==null&&(t.type.name==="QtiGapText"||t.type.name==="QtiGapImg"?this.choices.push(t.component.proxy):t.type.name==="QtiAssociableHotspot"&&this.gaps.push(t.component.proxy))})},insertAfter(e,t){t.parentNode.insertBefore(e,t.nextSibling)},processGroupUI(e){let t=this.createGapChoiceWrapper();if(t==null)return;let i=this.createGapTargetWrapper(),s=this.createContainer(this.priorState);this.processContainerChoices(s,t),this.saveContainerOrder(s),this.presentationFactory.initialize(this.$refs.root,t,i,this.image,this.dataChoicesContainerWidth,this.choices,this.gaps),this.matchable=new Vq(this.$refs.root,{interactionSubType:this.interactionSubType,cardinality:this.cardinality,maxAssociations:this.computedMaxAssociations,response:e,onReady:this.handleWidgetReady,onUpdate:this.handleWidgetUpdate,onAssociationsLimit:this.handleAssociationsLimit})},createGapChoiceWrapper(){let e=this.$refs.root.querySelector(".qti-gap-choice");if(e===null)return null;let t=document.createElement("ul");return t.classList.add("qti-ggm-source-wrapper"),this.$refs.root.insertBefore(t,e),t},createGapTargetWrapper(){let e=document.createElement("div");e.classList.add("qti-ggm-target-wrapper"),e.append(this.image);for(let t=0;t<this.gaps.length;t++)e.append(this.gaps[t].$el);return this.$refs.root.append(e),e},createContainer(e){let t=[];return e===null?(this.choices.forEach(s=>{t.push({fixed:s.fixed==="true",node:s})}),this.isShuffle&&$q.shuffleArrayFixed(t),t):(e.state.order.forEach(s=>{const n=this.findChoiceByIdentifier(s,this.choices);n!==null&&t.push({fixed:n.fixed==="true",node:n})},this),t)},processContainerChoices(e,t){this.choices.splice(0,this.choices.length),t.innerHTML="",e.forEach(i=>{t.appendChild(i.node.$el),this.choices.push(i.node)},this)},saveContainerOrder(e){const t=[];e.forEach(i=>{t.push(i.node.identifier)}),this.order=t},findChoiceByIdentifier(e,t){for(let i=0;i<t.length;i++)if(t[i].$el.getAttribute("data-identifier")===e)return t[i];throw new O('Gap Match Interaction State Invalid. Choice identifier "'+e+'" not found.')},resetGroupUI(){this.processGroupUI(null)},handleWidgetReady(e){this.setResponse(e.response),this.$emit("ggmGroupReady",{response:this.getResponse(),order:this.order})},handleWidgetUpdate(e){this.setResponse(e.response),this.$emit("ggmGroupUpdate",{response:this.getResponse()})},handleAssociationsLimit(){this.$emit("ggmGroupAssociationsLimit")},initializeGraphicGapMatchGroup(){this.presentationFactory=new _q(this.interactionStaticClass)}},created(){try{if(typeof this.cardinality>"u")throw new c("Undefined qti-graphic-gap-match-interaction cardinality");if(this.cardinality!=="multiple")throw new c('qti-graphic-gap-match-interaction cardinality must be "multiple"');this.setIsShuffle(this.shuffle==="true"),this.initializeGraphicGapMatchGroup(),this.validateChildren()}catch(e){throw this.isQtiValid=!1,console.log("[QtiGapMatchInteraction][ValidationError]",e.name,e.message),new c(e.message)}},mounted(){if(this.isQtiValid)try{this.processChildren(),this.processGroupUI(this.priorState===null?null:this.priorState.value)}catch(e){if(this.isQtiValid=!1,e.name==="QtiValidationException")throw console.log("[QtiGapMatchInteraction][ValidationException]",e.message),new c(e.message);if(e.name==="QtiEvaluationException")throw console.log("[QtiGapMatchInteraction][EvaluationException]",e.message),new O(e.message)}},beforeUnmount(){this.matchable!==null&&(this.matchable.destroy(),this.matchable=null)}},Mq={ref:"root",class:"qti-ggm-group-wrapper"};function Nq(e,t,i,s,n,r){return l.openBlock(),l.createElementBlock("div",Mq,[l.renderSlot(e.$slots,"default")],512)}const Rq=P(Lq,[["render",Nq]]);class kq{constructor(){this.constants={QTI_CHOICES_TOP:"qti-choices-top",QTI_CHOICES_BOTTOM:"qti-choices-bottom",QTI_CHOICES_LEFT:"qti-choices-left",QTI_CHOICES_RIGHT:"qti-choices-right",QTI_MATCH_TABULAR:"qti-match-tabular",QTI_HEADER_HIDDEN:"qti-header-hidden",ROW_CENTRIC:"row-centric",DATA_MAX_SELECTIONS_MESSAGE:"data-max-selections-message",DATA_MIN_SELECTIONS_MESSAGE:"data-min-selections-message",DATA_FIRST_COLUMN_HEADER:""},this.interactionSubType="default",this.parentClass="",this.clazzTokens=[],this.matchWrapperElement=null,this.matchGroupNode=null,this.matchSetNode1=null,this.matchSetNode2=null,this.choices1=[],this.choices2=[],this.presentation_Choices_Orientation=null,this.presentation_Header_Hidden=!1,this.presentation_Row_Centric=!1,this.presentation_MaxSelectionsMessage="",this.presentation_MinSelectionsMessage=""}initialize(t,i,s,n,r){this.interactionSubType=t,this.matchWrapperElement=i,this.matchGroupNode=s,this.parentClass=s.matchInteractionStaticClass,this.matchSetNode1=n,this.matchSetNode2=r,this.choices1=this.matchSetNode1.getChoices(),this.choices2=this.matchSetNode2.getChoices(),this.processRootClassAttribute(this.parentClass),this.processPresentation()}processRootClassAttribute(t){const i=t.split(" ");for(let s=0;s<i.length;s++)switch(i[s]){case this.constants.QTI_CHOICES_TOP:case this.constants.QTI_CHOICES_BOTTOM:case this.constants.QTI_CHOICES_LEFT:case this.constants.QTI_CHOICES_RIGHT:this.presentation_Choices_Orientation=i[s];break;case this.constants.QTI_MATCH_TABULAR:break;case this.constants.QTI_HEADER_HIDDEN:this.presentation_Header_Hidden=!0;break;case this.constants.ROW_CENTRIC:this.presentation_Row_Centric=!0;break}this.clazzTokens=i}processPresentation(){this.matchSetNode1.$refs.matchset.classList.add("qti-match-source-wrapper"),this.matchSetNode2.$refs.matchset.classList.add("qti-match-target-wrapper"),this.interactionSubType==="default"?(this.presentation_Choices_Orientation===null&&(this.presentation_Choices_Orientation=this.constants.QTI_CHOICES_TOP),this.presentation_Choices_Orientation===this.constants.QTI_CHOICES_LEFT?(this.matchSetNode1.$refs.matchset.classList.add(this.constants.QTI_CHOICES_LEFT),this.matchSetNode2.$refs.matchset.classList.add(this.constants.QTI_CHOICES_LEFT)):this.presentation_Choices_Orientation===this.constants.QTI_CHOICES_TOP?(this.matchSetNode1.$refs.matchset.classList.add(this.constants.QTI_CHOICES_TOP),this.matchSetNode2.$refs.matchset.classList.add(this.constants.QTI_CHOICES_TOP)):this.presentation_Choices_Orientation===this.constants.QTI_CHOICES_RIGHT?(this.matchSetNode1.$refs.matchset.classList.add(this.constants.QTI_CHOICES_RIGHT),this.matchSetNode2.$refs.matchset.classList.add(this.constants.QTI_CHOICES_RIGHT),this.matchWrapperElement.insertBefore(this.matchSetNode2.$refs.matchset,this.matchSetNode1.$refs.matchset)):this.presentation_Choices_Orientation===this.constants.QTI_CHOICES_BOTTOM&&(this.matchSetNode1.$refs.matchset.classList.add(this.constants.QTI_CHOICES_BOTTOM),this.matchSetNode2.$refs.matchset.classList.add(this.constants.QTI_CHOICES_BOTTOM),this.matchWrapperElement.insertBefore(this.matchSetNode2.$refs.matchset,this.matchSetNode1.$refs.matchset)),this.updateMatchSetChoices(this.matchSetNode1,!0),this.updateMatchSetChoices(this.matchSetNode2,!1)):this.interactionSubType==="matchtabular"&&(this.createMatchTable(),this.matchSetNode1.$refs.matchset.classList.add("matchset-hidden"),this.matchSetNode2.$refs.matchset.classList.add("matchset-hidden"))}updateMatchSetChoices(t,i){const s=t.getChoices();for(let n=0;n<s.length;n++)i?(s[n].$refs.choice.classList.add("source"),s[n].$refs.description.classList.add("draggable")):(s[n].$refs.choice.classList.add("target"),s[n].$refs.description.classList.add("match-target-label"))}createMatchTable(){const t=document.createElement("table");this.clazzTokens.forEach(i=>{t.classList.add(i)}),t.classList.add("matchtabular","table","table-bordered"),this.matchWrapperElement.insertBefore(t,this.matchSetNode1.$refs.matchset)}}class qq{constructor(t,i){ee(this,"options",{interactionSubType:"default",cardinality:"single",maxAssociations:0,response:null,onReady:null,onUpdate:null,onSelectionsLimit:null});return this.qtiAttributeValidation=new F,this.wrapper=t,this.sourcewrapper=this.wrapper.querySelector(".qti-match-source-wrapper"),this.targetwrapper=this.wrapper.querySelector(".qti-match-target-wrapper"),this.processOptions(i),this.handleDragStart=this.handleDragStart.bind(this),this.handleDragMove=this.handleDragMove.bind(this),this.handleDragEnd=this.handleDragEnd.bind(this),this.handleTouchStart=this.handleTouchStart.bind(this),this.handleTouchMove=this.handleTouchMove.bind(this),this.handleTouchEnd=this.handleTouchEnd.bind(this),this.itemTarget=null,this.itemStart=null,this.isItemStartSource=!0,this.initialX=0,this.initialY=0,this.offsetX=0,this.offsetY=0,this.startingX=0,this.startingY=0,this.currentAssociationsCount=0,this.isDisabled=!1,this.currentDragger=null,this.initializeSources(this.sourcewrapper),this.initializeTargets(this.targetwrapper),this.restoreResponse(this.options.response),this.notifyReady(),this}processOptions(t){"interactionSubType"in t&&(this.options.interactionSubType=t.interactionSubType),"cardinality"in t&&(this.options.cardinality=t.cardinality),"response"in t&&(this.options.response=t.response),"maxAssociations"in t&&(this.options.maxAssociations=t.maxAssociations),"onReady"in t&&(this.options.onReady=t.onReady),"onUpdate"in t&&(this.options.onUpdate=t.onUpdate),"onAssociationsLimit"in t&&(this.options.onAssociationsLimit=t.onAssociationsLimit)}notifyReady(){this.options.onReady!==null&&this.options.onReady({response:this.getResponse()})}notifyUpdate(){this.options.onUpdate!==null&&this.options.onUpdate({response:this.computeResponse()})}notifyAssociationsLimit(){this.options.onAssociationsLimit!==null&&this.options.onAssociationsLimit()}toggleDisable(t){this.isDisabled=t,this.draggers.forEach(i=>{t?i.classList.add("disabled"):i.classList.remove("disabled")})}handleDragStart(t){if(t.preventDefault(),!this.isDisabled&&t.button==0)return this.interactionStart(t.target,t.clientX,t.clientY,!1),!1}handleTouchStart(t){if(t.preventDefault(),!this.isDisabled)return t.targetTouches.length!=1||this.interactionStart(t.target,t.touches[0].pageX,t.touches[0].pageY,!0),!1}interactionStart(t,i,s,n){const r=this.getClosestElement(t,"draggable");this.itemStart=r.parentNode,this.isItemStartSource=this.itemStart.classList.contains("source"),this.identifyTargets(this.itemStart,!0),this.itemTarget=null;const a=r.getBoundingClientRect();this.initialX=i,this.initialY=s,this.startingX=a.left,this.startingY=a.top,this.offsetX=i-this.startingX,this.offsetY=s-this.startingY,this.addPlaceholder(r),r.style.userSelect="none",r.style.width=a.width+"px",r.style.height=a.height+"px",r.style.transform=`translateX(${a.left}px) translateY(${a.top}px) translateZ(0)`,r.classList.add("dragging"),this.setCurrentDragger(r),this.addListeners(r,n)}handleDragMove(t){t.preventDefault(),!this.isDisabled&&this.interactionMove(t.clientX,t.clientY)}handleTouchMove(t){t.preventDefault(),!this.isDisabled&&t.targetTouches.length==1&&this.interactionMove(t.touches[0].clientX,t.touches[0].clientY)}interactionMove(t,i){const s=this.currentDragger;this.offsetX=t-this.initialX,this.offsetY=i-this.initialY,this.constrainDraggerToWrapper(s,this.wrapper),s.style.transform=`translateX(${this.startingX+this.offsetX}px) translateY(${this.startingY+this.offsetY}px) translateZ(0) scale(1)`;const n=s.getBoundingClientRect();this.findDraggerItemTarget(s,n,this.targets),this.isItemStartSource||this.findSourceDraggerTarget(s,n)}constrainDraggerToWrapper(t,i){const s=t.getBoundingClientRect(),n=i.getBoundingClientRect(),r=this.startingX+this.offsetX-n.x,a=this.startingY+this.offsetY-n.y,o=this.startingX+s.width+this.offsetX-(n.x+n.width),u=this.startingY+s.height+this.offsetY-(n.y+n.height);r<0&&(this.offsetX=this.offsetX-r),o>0&&(this.offsetX=this.offsetX-o),a<0&&(this.offsetY=this.offsetY-a),u>0&&(this.offsetY=this.offsetY-u)}handleDragEnd(t){this.isDisabled||this.interactionEnd(t.clientX,t.clientY,!1)}handleTouchEnd(t){this.isDisabled||this.interactionEnd(t.changedTouches[0].clientX,t.changedTouches[0].clientY,!0)}interactionEnd(t,i,s){const n=this.currentDragger;if(this.itemTarget===null?n.style.transform=`translateX(${this.startingX}px) translateY(${this.startingY}px) translateZ(0)`:n.style.transform=`translateX(${this.startingX+this.offsetX}px) translateY(${this.startingY+this.offsetY}px) translateZ(0)`,n.removeAttribute("style"),n.classList.remove("dragging"),this.clearTargetHighlights(),this.itemTarget===null){this.resetDraggerToItemStart(this.itemStart,n),this.setCurrentDragger(null),this.removeListeners(n,s);return}if(this.itemTarget.classList.contains("active")){if(this.itemTarget.classList.remove("active"),this.isExceedingMaxAssociations(this.itemStart,this.itemTarget,n)){this.resetDraggerToItemStart(this.itemStart,n),this.notifyAssociationsLimit(),this.setCurrentDragger(null),this.removeListeners(n,s);return}if(this.itemStart.getAttribute("data-identifier")===this.itemTarget.getAttribute("data-identifier")){this.resetDraggerToItemStart(this.itemStart,n),this.setCurrentDragger(null),this.removeListeners(n,s);return}this.removePlaceholder(n),this.setDraggerToItemTarget(this.itemTarget,n),this.itemTarget.classList.contains("source")&&(this.itemTarget.classList.add("full"),this.itemTarget.dataset.matchMax*1>0&&this.incrementRemaining(this.itemTarget),this.decrementAssociationsCount(),this.sortContainerElements(this.sourcewrapper)),this.itemStart.classList.contains("source")&&(this.itemStart.dataset.matchMax*1>0&&this.decrementRemaining(this.itemStart)===0&&this.itemStart.classList.remove("full"),this.incrementAssociationsCount()),this.itemStart.classList.contains("target")&&(this.isTargetFull(this.itemStart)?this.itemStart.classList.add("full"):this.itemStart.classList.remove("full")),this.notifyUpdate()}this.setCurrentDragger(null),this.removeListeners(n,s)}setCurrentDragger(t){this.currentDragger=t}resetDraggerToItemStart(t,i){this.replacePlaceholder(i),t.classList.contains("source")||i.setAttribute("style","width:100%")}setDraggerToItemTarget(t,i){if(t.classList.contains("source")){if(t.classList.contains("full")){const s=t.querySelector(".draggable");s!=null&&t.replaceChild(i,s);return}t.append(i);return}t.append(i),i.setAttribute("style","width:100%"),this.isTargetFull(t)?t.classList.add("full"):t.classList.remove("full")}findDraggerItemTarget(t,i,s){this.itemTarget=null,s.forEach(n=>{const r=n.getBoundingClientRect();if(i.top+t.offsetHeight/2<r.bottom&&i.right-t.offsetWidth/2>r.left&&i.bottom-t.offsetHeight/2>r.top&&i.left+t.offsetWidth/2<r.right){if(this.isItemStartSource&&n.classList.contains("source")||n.classList.contains("full")||!this.hasMatchingMatchGroup(t.parentNode,n))return;n.classList.add("active"),this.itemTarget=n}else n.classList.remove("active")},this)}findSourceDraggerTarget(t,i){const s=this.sourcewrapper.getBoundingClientRect();if(i.top+t.offsetHeight/2<s.bottom&&i.right-t.offsetWidth/2>s.left&&i.bottom-t.offsetHeight/2>s.top&&i.left+t.offsetWidth/2<s.right){for(let n=0;n<this.sources.length;n++)if(this.sources[n].dataset.identifier===t.dataset.identifier){this.sources[n].classList.add("active"),this.itemTarget=this.sources[n];break}}else for(let n=0;n<this.sources.length;n++)this.sources[n].classList.contains("active")&&this.sources[n].classList.remove("active")}addPlaceholder(t){if(!t.parentNode.classList.contains("source")){this.addPlaceholderElement(t,!1);return}const i=t.parentNode.dataset.matchMax*1;if(i===1){this.addPlaceholderElement(t,!1);return}if(i===0){this.addPlaceholderElement(t,!0);return}if(this.getRemaining(t.parentNode)===1){this.addPlaceholderElement(t,!1);return}this.addPlaceholderElement(t,!0)}addPlaceholderElement(t,i){const s=t.cloneNode(!0);this.deepCloneId(s),i?(s.classList.add("clone"),s.addEventListener("mousedown",this.handleDragStart),s.addEventListener("touchstart",this.handleTouchStart)):s.classList.add("match-dragger-placeholder"),s.classList.add("placeholder-fade"),t.parentNode.insertBefore(s,t)}removePlaceholder(t){if(t.parentNode.classList.contains("target")){const n=t.parentNode.querySelector(".match-dragger-placeholder");if(n===null)return;t.parentNode.removeChild(n);return}const i=t.parentNode.dataset.matchMax*1,s=t.parentNode.querySelector(".match-dragger-placeholder");if(s===null){const n=t.parentNode.querySelector(".clone");if(n===null)return;n.classList.remove("placeholder-fade");return}i!==0&&t.parentNode.removeChild(s)}replacePlaceholder(t){const i=t.parentNode;let s=i.querySelector(".match-dragger-placeholder");if(i.classList.contains("source")){if(s==null&&(s=i.querySelector(".draggable")),s===null)return;i.replaceChild(t,s);return}s!==null&&i.replaceChild(t,s)}addClonePlaceholder(t){const i=t.cloneNode(!0);this.deepCloneId(i),i.classList.add("clone"),t.parentNode.insertBefore(i,t),i.addEventListener("mousedown",this.handleDragStart),i.addEventListener("touchstart",this.handleTouchStart)}initializeSources(t){this.sources=t.querySelectorAll(".source"),this.sources.forEach(i=>{i.classList.add("full");const s=i.dataset.matchMax*1;this.setRemaining(i,s===0?1e3:s)},this),this.draggers=t.querySelectorAll(".draggable"),this.draggers.forEach((i,s)=>{const n=i.parentNode.getAttribute("data-identifier");i.setAttribute("data-identifier",n),i.setAttribute("data-order",s),i.setAttribute("tabindex",0),i.addEventListener("mousedown",this.handleDragStart),i.addEventListener("touchstart",this.handleTouchStart)},this)}initializeTargets(t){this.targets=t.querySelectorAll(".target"),this.targets.forEach(i=>{i.setAttribute("tabindex",0)})}identifyTargets(t,i){this.targets.forEach(s=>{i&&!s.classList.contains("full")&&this.hasMatchingMatchGroup(t,s)&&s.classList.add("target-active")},this),i&&!this.isItemStartSource&&this.sourcewrapper.classList.add("target-active")}addListeners(t,i){i?(this.removeListeners(t,i),t.addEventListener("touchmove",this.handleTouchMove),t.addEventListener("touchend",this.handleTouchEnd)):(this.removeListeners(t,i),document.addEventListener("mousemove",this.handleDragMove),document.addEventListener("mouseup",this.handleDragEnd))}removeListeners(t,i){i?(t.removeEventListener("touchmove",this.handleTouchMove),t.removeEventListener("touchend",this.handleTouchEnd)):(document.removeEventListener("mousemove",this.handleDragMove),document.removeEventListener("mouseup",this.handleDragEnd))}clearTargetHighlights(){this.targets.forEach(t=>{t.classList.remove("target-active")},this),this.sourcewrapper.classList.remove("target-active")}getClosestElement(t,i){return t?t&&t.classList.contains(i)?t:this.getClosestElement(t.parentElement,i):!1}sortContainerElements(t){let i=[],s=t.children;for(let n=0;n<s.length;n++){const r=s[n].querySelector("div.draggable");r&&i.push([1*r.dataset.order,s[n]])}i.sort(function(n,r){return n[0]-r[0]});for(let n=0;n<i.length;n++)t.appendChild(i[n][1])}getResponse(){return this.computeResponse()}computeResponse(){let t=[];return this.targets.forEach(i=>{i.querySelectorAll(".draggable").forEach(s=>{t.push(`${s.dataset.identifier} ${i.dataset.identifier}`)})}),t.length===0?null:this.options.cardinality==="single"?t[0]:t}restoreResponse(t){t!==null&&(this.options.cardinality==="single"?this.restoreResponsePair(t):t.forEach(i=>{this.restoreResponsePair(i)},this))}restoreResponsePair(t){const i=this.getPair(t);if(i===null)return;const s=this.findSourceByIdentifier(i.source),n=this.findTargetGapByIdentifier(i.target);if(s===null||n===null)return;const r=s.querySelector(".draggable");r!==null&&(this.cloneOrEmptySourceDragger(s,r),this.restoreSourceDraggerToTarget(n,r))}cloneOrEmptySourceDragger(t,i){const s=t.dataset.matchMax*1;if(s===1){t.classList.remove("full"),this.decrementRemaining(t);return}if(s===0){this.addClonePlaceholder(i);return}if(this.getRemaining(t)===1){t.classList.remove("full"),this.decrementRemaining(t);return}this.decrementRemaining(t),this.addClonePlaceholder(i)}findSourceByIdentifier(t){for(let i=0;i<this.sources.length;i++)if(t===this.sources[i].dataset.identifier)return this.sources[i];return null}findTargetGapByIdentifier(t){for(let i=0;i<this.targets.length;i++)if(t===this.targets[i].dataset.identifier)return this.targets[i];return null}getPair(t){if(t===null)return null;const i=t.split(" ");return i.length!=2?null:{source:i[0],target:i[1]}}restoreSourceDraggerToTarget(t,i){t===null||i===null||(t.append(i),i.setAttribute("style","width:100%"),this.incrementAssociationsCount(),this.isTargetFull(t)&&t.classList.add("full"))}hasMatchingMatchGroup(t,i){return t===null||i===null?!1:t.dataset.matchGroup===i.dataset.matchGroup}isTargetFull(t){if(t==null)return!1;const i=t.querySelectorAll(".draggable"),s=t.dataset.matchMax*1;return s===0?!1:i.length>=s}isExceedingMaxAssociations(t,i){return!(this.options.maxAssociations===0||i.classList.contains("source")||t.classList.contains("target")||this.currentAssociationsCount<this.options.maxAssociations)}initializeAssociationsCount(){this.currentAssociationsCount=0}incrementAssociationsCount(){this.currentAssociationsCount+=1}decrementAssociationsCount(){this.currentAssociationsCount!==0&&(this.currentAssociationsCount-=1)}getRemaining(t){return t.dataset.remaining*1}setRemaining(t,i){t.setAttribute("data-remaining",i)}incrementRemaining(t){const i=t.dataset.remaining*1+1;return t.setAttribute("data-remaining",i),i}decrementRemaining(t){let i=t.dataset.remaining*1-1;return i=i>=0?i:0,t.setAttribute("data-remaining",i),i}deepCloneId(t){t.id&&(t.id=`clone_${this.qtiAttributeValidation.randomString(5,"a")}`);for(let i=0;i<t.children.length;i++)this.deepCloneId(t.children[i])}reset(){this.resetDraggersToSources(),this.initializeAssociationsCount(),this.destroy()}resetDraggersToSources(){this.targets.forEach(t=>{t.querySelectorAll(".draggable").forEach(s=>{const n=this.findSourceByIdentifier(s.getAttribute("data-identifier"));n.classList.contains("full")||(t.classList.remove("full"),n.classList.contains("full")?t.removeChild(s):(n.append(s),n.classList.add("full")))},this)},this)}destroy(){this.currentDragger!==null&&(document.removeEventListener("mousemove",this.handleDragMove),document.removeEventListener("mouseup",this.handleDragEnd)),this.wrapper.querySelectorAll(".draggable").forEach(i=>{i.removeEventListener("touchstart",this.handleTouchStart),i.removeEventListener("touchmove",this.handleTouchMove),i.removeEventListener("touchend",this.handleTouchEnd),i.removeEventListener("mousedown",this.handleDragStart)},this)}}class Oq{constructor(t,i){ee(this,"options",{interactionSubType:"matchtabular",isHeaderHidden:!1,isRowCentric:!1,firstColumnHeader:null,cardinality:"single",maxAssociations:0,response:null,onReady:null,onUpdate:null,onSelectionsLimit:null});ee(this,"keyCodes",{Enter:13,Space:32,End:35,Home:36,ArrowLeft:37,ArrowUp:38,ArrowRight:39,ArrowDown:40});return this.wrapper=t,this.table=this.wrapper.querySelector("table.matchtabular"),this.sourcewrapper=this.wrapper.querySelector(".qti-match-source-wrapper"),this.targetwrapper=this.wrapper.querySelector(".qti-match-target-wrapper"),this.currentAssociationsCount=0,this.isDisabled=!1,this.processOptions(i),this.handleClick=this.handleClick.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.handleFocus=this.handleFocus.bind(this),this.handleBlur=this.handleBlur.bind(this),this.state=new Map,this.initializeTable(this.sourcewrapper,this.targetwrapper),this.restoreResponse(),this.notifyReady(),this}processOptions(t){"interactionSubType"in t&&(this.options.interactionSubType=t.interactionSubType),"isHeaderHidden"in t&&(this.options.isHeaderHidden=t.isHeaderHidden),"isRowCentric"in t&&(this.options.isRowCentric=t.isRowCentric),"firstColumnHeader"in t&&(this.options.firstColumnHeader=t.firstColumnHeader),"cardinality"in t&&(this.options.cardinality=t.cardinality),"response"in t&&(this.options.response=t.response),"maxAssociations"in t&&(this.options.maxAssociations=t.maxAssociations),"onReady"in t&&(this.options.onReady=t.onReady),"onUpdate"in t&&(this.options.onUpdate=t.onUpdate),"onAssociationsLimit"in t&&(this.options.onAssociationsLimit=t.onAssociationsLimit)}notifyReady(){this.options.onReady!==null&&this.options.onReady({response:this.getResponse()})}notifyUpdate(){this.options.onUpdate!==null&&this.options.onUpdate({response:this.computeResponse()})}notifyAssociationsLimit(){this.options.onAssociationsLimit!==null&&this.options.onAssociationsLimit()}toggleDisable(t){this.isDisabled=t,this.controls.forEach(i=>{t?i.classList.add("disabled"):i.classList.remove("disabled")})}handleClick(t){if(!this.isDisabled){if(this.isRadio(t.target)){this.setControlChecked(t.target);return}this.toggleControl(t.target)}}handleKeydown(t){let i=!1;switch(t.code){case"Space":case"Enter":this.isDisabled||this.toggleControl(t.target),i=!0;break;case"ArrowUp":case"ArrowLeft":i=!0;break;case"ArrowDown":case"ArrowRight":i=!0;break}i&&(t.stopPropagation(),t.preventDefault())}handleFocus(){}handleBlur(){}toggleControl(t){if(!this.isChecked(t)){if(this.isExceedingMaxAssociations()){this.notifyAssociationsLimit();return}if(this.isExceedingMatchMax(t.dataset.pair,t.dataset.sourceMax*1,!0)||this.isExceedingMatchMax(t.dataset.pair,t.dataset.targetMax*1,!1))return;this.updateState(t.dataset.pair,this.toggleChecked(t)),this.notifyUpdate();return}this.updateState(t.dataset.pair,this.toggleChecked(t)),this.notifyUpdate()}setControlChecked(t){if(!this.isChecked(t)){if(this.isExceedingMaxAssociations()){this.notifyAssociationsLimit();return}if(this.isExceedingMatchMax(t.dataset.pair,t.dataset.sourceMax*1,!0)||this.isExceedingMatchMax(t.dataset.pair,t.dataset.targetMax*1,!1))return;this.updateState(t.dataset.pair,this.setChecked(t,!0)),this.notifyUpdate();return}this.updateState(t.dataset.pair,this.setChecked(t,!0)),this.notifyUpdate()}setChecked(t,i){const s=i?"true":"false";return t.setAttribute("aria-checked",s),s}toggleChecked(t){const s=t.getAttribute("aria-checked")==="true"?"false":"true";return t.setAttribute("aria-checked",s),s}isRadio(t){return t===null?!1:t.getAttribute("role")==="radio"}isChecked(t){return t===null?!1:t.getAttribute("aria-checked")==="true"}setTabIndex(t){this.tabIndex=t}setFocus(){}setBlur(){}updateState(t,i){this.state.set(t,i),this.currentAssociationsCount=0;for(let s of this.state.values())s==="true"&&(this.currentAssociationsCount+=1)}initializeTable(t,i){this.sources=this.getChoices(t),this.targets=this.getChoices(i);const s=`width:${this.getColumnWidthPercentage(this.targets.length)}%`;this.table.innerHTML=`${this.getHeader(s)}${this.getBody(s)}`,this.controls=this.table.querySelectorAll(".control-cell"),this.controls.forEach(n=>{const r=n.getAttribute("data-pair");this.updateState(r,"false"),n.addEventListener("click",this.handleClick),n.addEventListener("keydown",this.handleKeydown),n.addEventListener("focus",this.handleFocus),n.addEventListener("blur",this.handleBlur)},this)}getHeader(t){if(this.options.isHeaderHidden)return"";let i=`<th scope="col" class="header-cell">${this.options.firstColumnHeader==null?"":this.options.firstColumnHeader}</th>`;return this.options.isRowCentric?(i+=this.getSourceHeader(t),`<thead>${i}</thead>`):(i+=this.getTargetHeader(t),`<thead>${i}</thead>`)}getTargetHeader(t){let i="";return this.targets.forEach(s=>{i+=`<th scope="col" class="header-cell" style="${t}">${s.innerHTML}</th>`}),i}getSourceHeader(t){let i="";return this.sources.forEach(s=>{i+=`<th scope="col" class="header-cell" style="${t}">${s.innerHTML}</th>`}),i}getBody(t){let i="";return this.options.isRowCentric?(this.targets.forEach(s=>{i+=`<tr><th scope="row" class="row-header-cell">${s.innerHTML}</th>`;const n=s.getAttribute("data-match-max");this.sources.forEach(r=>{const a=r.getAttribute("data-match-max"),o=r.getAttribute("data-identifier"),u=s.getAttribute("data-identifier"),h=`${o} ${u}`;i+=`<td class="table-cell" style="${t}">
|
168
168
|
<div class="control-cell" aria-checked="false" tabindex="0" role="checkbox"
|
169
169
|
data-source-max="${a}" data-target-max="${n}" data-pair="${h}"></div>
|
170
170
|
</td>`}),i+="</tr>"}),`<tbody>${i}</tbody>`):(this.sources.forEach(s=>{i+=`<tr><th scope="row" class="row-header-cell">${s.innerHTML}</th>`;const n=s.getAttribute("data-match-max");this.targets.forEach(r=>{const a=r.getAttribute("data-match-max"),o=s.getAttribute("data-identifier"),u=r.getAttribute("data-identifier"),h=`${o} ${u}`;i+=`<td class="table-cell" style="${t}">
|