/* @license GPL-2.0-or-later https://www.drupal.org/licensing/faq */ (function(){const settingsElement=document.querySelector('head > script[type="application/json"][data-drupal-selector="drupal-settings-json"], body > script[type="application/json"][data-drupal-selector="drupal-settings-json"]');window.drupalSettings={};if(settingsElement!==null)window.drupalSettings=JSON.parse(settingsElement.textContent);})();; H5P.BranchingQuestion=(function(){function BranchingQuestion(parameters){var self=this;H5P.EventDispatcher.call(self);this.container=null;let answered;let timestamp;const getClosestParent=function(element,selector){if(!document.documentElement.contains(element))return null;if(!Element.prototype.matches)Element.prototype.matches=Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector;do{if(element.matches(selector))return element;element=element.parentElement||element.parentNode;}while(element!==null&&element.nodeType===1);return null;};var createWrapper=function(){var wrapper=document.createElement('div');wrapper.classList.add('h5p-branching-question');var icon=document.createElement('img');icon.classList.add('h5p-branching-question-icon');icon.src=self.getLibraryFilePath('branching-question-icon.svg');wrapper.appendChild(icon);return wrapper;};var appendMultiChoiceSection=function(parameters,wrapper){var questionWrapper=document.createElement('div');questionWrapper.classList.add('h5p-multichoice-wrapper');var title=document.createElement('div');title.classList.add('h5p-branching-question-title');if(parameters.branchingQuestion.question)title.innerHTML=parameters.branchingQuestion.question;questionWrapper.appendChild(title);const alternatives=parameters.branchingQuestion.alternatives||[];alternatives.forEach(function(altParams,index,array){const alternative=createAlternativeContainer(altParams.text,index);alternative.nextContentId=altParams.nextContentId;const hasFeedback=altParams.feedback&&!!(altParams.feedback.title&&altParams.feedback.title.trim()||altParams.feedback.subtitle&&altParams.feedback.subtitle.trim()||altParams.feedback.image);if(hasFeedback&&altParams.nextContentId!==-1){alternative.feedbackScreen=createFeedbackScreen(altParams.feedback,alternative.nextContentId,index);alternative.proceedButton=alternative.feedbackScreen.querySelectorAll('button')[0];}alternative.hasFeedback=altParams.feedback&&!!(hasFeedback||altParams.feedback.endScreenScore!==undefined);alternative.feedback=altParams.feedback;alternative.addEventListener('keyup',function(event){if(event.which===13||event.which===32)this.click();});alternative.onclick=function(e){if(this.feedbackScreen!==undefined){if(self.container)self.container.classList.add('h5p-branching-scenario-feedback-dialog');wrapper.innerHTML='';wrapper.appendChild(this.feedbackScreen);self.parent.trigger('resize');answered=index;timestamp=new Date().toISOString();const container=document.querySelector('.h5p-branching-question-container');if(container.hasAttribute('role')){container.removeAttribute('role');container.removeAttribute('aria-labelledby');}this.feedbackScreen.setAttribute('role','dialog');this.feedbackScreen.setAttribute('aria-labelledby','h5p-feedback-content-title');this.feedbackScreen.setAttribute('aria-describedby','h5p-feedback-content-content');this.proceedButton.focus();self.triggerXAPI('interacted');}else{var currentAlt=e.target.classList.contains('.h5p-branching-question-alternative')?e.target:getClosestParent(e.target,'.h5p-branching-question-alternative');var alts=questionWrapper.querySelectorAll('.h5p-branching-question-alternative');var index2;for(var i=0;i=0&¤tAltHasFeedback)nextScreen.feedback=currentAltParams.feedback;self.trigger('navigated',nextScreen);}};questionWrapper.appendChild(alternative);});if(parameters.branchingQuestion.randomize&&!questionWrapper.dataset.shuffled){const alternatives=questionWrapper.querySelectorAll('button.h5p-branching-question-alternative');const shuffledAlternatives=H5P.shuffleArray(Array.from(alternatives));shuffledAlternatives.forEach(function(alternative){questionWrapper.appendChild(alternative);});questionWrapper.setAttribute('data-shuffled',true);}wrapper.appendChild(questionWrapper);return wrapper;};var createAlternativeContainer=function(text,id){var wrapper=document.createElement('button');wrapper.classList.add('h5p-branching-question-alternative');wrapper.tabIndex=0;wrapper.setAttribute('data-id',id);var alternativeText=document.createElement('p');alternativeText.innerHTML=text;wrapper.appendChild(alternativeText);return wrapper;};var createFeedbackScreen=function(feedback,nextContentId,chosenAlternativeIndex){var wrapper=document.createElement('div');wrapper.classList.add('h5p-branching-question');wrapper.classList.add(feedback.image!==undefined?'h5p-feedback-has-image':'h5p-feedback-default');if(feedback.image!==undefined&&feedback.image.path!==undefined){var imageContainer=document.createElement('div');imageContainer.classList.add('h5p-branching-question');imageContainer.classList.add('h5p-feedback-image');var image=document.createElement('img');image.src=H5P.getPath(feedback.image.path,self.contentId);imageContainer.appendChild(image);wrapper.appendChild(imageContainer);}var feedbackContent=document.createElement('div');feedbackContent.classList.add('h5p-branching-question');feedbackContent.classList.add('h5p-feedback-content');var feedbackText=document.createElement('div');feedbackText.classList.add('h5p-feedback-content-content');feedbackContent.appendChild(feedbackText);var title=document.createElement('h1');title.innerHTML=feedback.title||'';title.id='h5p-feedback-content-title';feedbackText.appendChild(title);if(feedback.subtitle){var subtitle=document.createElement('div');subtitle.id='h5p-feedback-content-content';subtitle.innerHTML=feedback.subtitle||'';feedbackText.appendChild(subtitle);}var navButton=document.createElement('button');navButton.onclick=function(){self.trigger('navigated',{nextContentId,chosenAlternative:chosenAlternativeIndex});};var text=document.createTextNode(parameters.proceedButtonText);navButton.appendChild(text);feedbackContent.appendChild(navButton);wrapper.appendChild(feedbackContent);return wrapper;};self.getXAPIData=function(){var xAPIEvent=this.createXAPIEventTemplate('answered');addQuestionToXAPI(xAPIEvent);xAPIEvent.setScoredResult(undefined,undefined,self,true);xAPIEvent.data.statement.result.response=answered;xAPIEvent.data.statement.timestamp=timestamp;return {statement:xAPIEvent.data.statement};};var addFeedbackInfoExtension=function(extensions){const alternatives=parameters.branchingQuestion.alternatives;const chosen=alternatives[answered];const feedback=chosen.feedback;if(!feedback.title&&!feedback.subtitle&&!feedback.image)return;const xapiFeedback={};const converter=document.createElement('div');if(feedback.image)xapiFeedback.imageUrl=H5P.getPath(feedback.image.path,self.parent.contentId);if(feedback.title){converter.innerHTML=feedback.title;xapiFeedback.title=converter.innerText.trim();}if(feedback.subtitle){converter.innerHTML=feedback.subtitle;xapiFeedback.subtitle=converter.innerText.trim();}const key='https://h5p.org/x-api/branching-choice-feedback';extensions[key]=xapiFeedback;};var contentIsUsingDynamicScore=function(){return (self.parent&&self.parent.params&&self.parent.params.scoringOptionGroup&&self.parent.params.scoringOptionGroup.scoringOption==='dynamic-score');};var addScoringAndCorrectness=function(definition,alternatives){if(!contentIsUsingDynamicScore())return;const scoreMap=new Map();for(let i=0;i0)if(scoreMap.has(currentScore))scoreMap.get(currentScore).push(i);else scoreMap.set(currentScore,[i]);}if(scoreMap.size>0){const maxScore=Math.max(...scoreMap.keys());definition.correctResponsesPattern=scoreMap.get(maxScore);const extensionKey='https://h5p.org/x-api/alternatives-with-score';definition.extensions[extensionKey]={};scoreMap.forEach((alternatives,score)=>{alternatives.forEach((alternative)=>{definition.extensions[extensionKey][alternative]=score;});});delete definition.extensions['https://h5p.org/x-api/no-correct-answer'];}};var addQuestionToXAPI=function(xAPIEvent){const converter=document.createElement('div');var definition=xAPIEvent.getVerifiedStatementValue(['object','definition']);converter.innerHTML=parameters.branchingQuestion.question;definition.description={'en-US':converter.innerText};definition.type='http://adlnet.gov/expapi/activities/cmi.interaction';definition.interactionType='choice';definition.correctResponsesPattern=[];definition.choices=[];definition.extensions={'https://h5p.org/x-api/no-correct-answer':1};const alternatives=parameters.branchingQuestion.alternatives;for(let i=0;i{var e,t,r={734:(e,t,r)=>{"use strict";var n,i,a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e;}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e;},s=function(){return "object"===("undefined"==typeof window?"undefined":a(window));},o=s()?window:r.g,c=!!s()&&document.attachEvent,d=!1,l=null,h=null,p=null,u=null,b=function(e){var t=e.__resizeTriggers__,r=t.firstElementChild,n=t.lastElementChild,i=r.firstElementChild;n.scrollLeft=n.scrollWidth,n.scrollTop=n.scrollHeight,i.style.width=r.offsetWidth+1+"px",i.style.height=r.offsetHeight+1+"px",r.scrollLeft=r.scrollWidth,r.scrollTop=r.scrollHeight;},v=(n=o.requestAnimationFrame||o.mozRequestAnimationFrame||o.webkitRequestAnimationFrame||function(e){return setTimeout(e,20);},function(e){return n(e);}),y=(i=o.cancelAnimationFrame||o.mozCancelAnimationFrame||o.webkitCancelAnimationFrame||o.clearTimeout,function(e){return i(e);}),g=function(e){var t=this;b(this),this.__resizeRAF__&&y(this.__resizeRAF__),this.__resizeRAF__=v((function(){(function(e){return e.offsetWidth!=e.__resizeLast__.width||e.offsetHeight!=e.__resizeLast__.height;})(t)&&(t.__resizeLast__.width=t.offsetWidth,t.__resizeLast__.height=t.offsetHeight,t.__resizeListeners__.forEach((function(r){r.call(t,e);})));}));};if(s()&&!c){var m=!1,f="";u="animationstart";var S="Webkit Moz O ms".split(" "),L="webkitAnimationStart animationstart oAnimationStart MSAnimationStart".split(" "),x=document.createElement("fakeelement");if(void 0!==x.style.animationName&&(m=!0),!1===m)for(var B=0;B div, .contract-trigger:before { content: " "; display: block; position: absolute; top: 0; left: 0; height: 100%; width: 100%; overflow: hidden; } .resize-triggers > div { background: #eee; overflow: auto; } .contract-trigger:before { width: 200%; height: 200%; }',t=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",r.styleSheet?r.styleSheet.cssText=e:r.appendChild(document.createTextNode(e)),t.appendChild(r),d=!0;}}(),e.__resizeLast__={},e.__resizeListeners__=[],(e.__resizeTriggers__=document.createElement("div")).className="resize-triggers",e.__resizeTriggers__.innerHTML='
',e.appendChild(e.__resizeTriggers__),b(e),e.addEventListener("scroll",g,!0),u&&e.__resizeTriggers__.addEventListener(u,(function(t){t.animationName==l&&b(e);}))),e.__resizeListeners__.push(t));};}},n={};function i(e){var t=n[e];if(void 0!==t)return t.exports;var a=n[e]={exports:{}};return r[e](a,a.exports,i),a.exports;}i.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")();}catch(e){if("object"==typeof window)return window;}}(),(()=>{function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e;}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e;},e(t);}H5P=H5P||{},H5P.BranchingScenario=function(t,r){var n=this;H5P.EventDispatcher.call(n),n.contentId=r,n.startScreen={},n.libraryScreen={},n.endScreens={},n.navigating,n.currentHeight,n.currentId=-1,n.xAPIDataCollector=[],n.userPath=[],n.backwardsAllowedFlags=[],n.proceedButtonInProgress=!1,n.isReverseTransition=!1;var i=function t(){for(var r=1;r-1&&H5P.BranchingScenario.LibraryScreen.isBranching(n.getLibrary(n.currentId))&&n.$container.find('.h5p-back-button[isBQ="true"]').length&&n.$container.find('.h5p-back-button[isBQ="true"]').remove();var i=n.getLibrary(r),s=!0;if(n.libraryScreen){if(n.libraryScreen.stopPlayback(n.currentId),!this.params.preventXAPI){var o=n.libraryScreen.getXAPIData(n.currentId),c=H5P.BranchingScenario.LibraryScreen.isBranching(n.getLibrary(n.currentId)),d=c&&o.statement&&o.statement.result&&void 0!==o.statement.result.response;!o||c&&!d||n.xAPIDataCollector.push(o);}}else n.libraryScreen=new H5P.BranchingScenario.LibraryScreen(n,t.startScreen.startScreenTitle,i),n.libraryScreen.on("toggleFullScreen",(function(){n.toggleFullScreen();})),n.$container.append(n.libraryScreen.getElement()),n.currentId=r;if(H5P.BranchingScenario.LibraryScreen.isBranching(n.getLibrary(n.currentId))&&document.querySelector(".h5p-current-screen").setAttribute("aria-hidden",!0),n.currentEndScreen&&n.currentEndScreen.isShowing?i?H5P.BranchingScenario.LibraryScreen.isBranching(i)||(n.currentEndScreen.hide(),n.currentEndScreen=null,n.libraryScreen.show()):(n.libraryScreen.hideFeedbackDialogs(),n.currentEndScreen.hide(),n.currentEndScreen=null):n.startScreen&&n.startScreen.isShowing&&i?H5P.BranchingScenario.LibraryScreen.isBranching(i)||(n.startScreen.hide(),n.libraryScreen.show(),s=!1):n.libraryScreen.hideFeedbackDialogs(),s&&n.trigger("resize"),-1!==n.currentId){n.triggerXAPI("progressed");var l={};n.libraryScreen.currentLibraryInstance&&n.libraryScreen.currentLibraryInstance.getScore&&(l={score:n.libraryScreen.currentLibraryInstance.getScore(),maxScore:n.libraryScreen.currentLibraryInstance.getMaxScore()}),n.scoring.addLibraryScore(this.currentId,this.libraryScreen.currentLibraryId,e.data.chosenAlternative,l);}if(!1===i){if(n.currentEndScreen=n.endScreens[r],e.data.feedback){var h=a({endScreenTitle:e.data.feedback.title||"",endScreenSubtitle:e.data.feedback.subtitle||"",endScreenImage:e.data.feedback.image,endScreenScore:e.data.feedback.endScreenScore});n.$container.append(h.getElement()),n.currentEndScreen=h;}else n.scoring.isDynamicScoring()&&(n.currentEndScreen.setScore(n.getScore()),n.currentEndScreen.setMaxScore(n.getMaxScore()));n.startScreen.hide(),n.libraryScreen.hide(!0),n.currentEndScreen.show(),n.triggerXAPICompleted(n.scoring.getScore(n.currentEndScreen.getScore()),n.scoring.getMaxScore());}else n.libraryScreen.showNextLibrary(i,e.data.reverse),!1===n.canEnableBackButton(r)?n.disableBackButton():n.enableBackButton(),n.currentId=r;if(0!==e.data.nextContentId&&document.querySelector(".h5p-start-screen").classList.contains("h5p-current-screen")){var p=n.libraryScreen.wrapper.querySelector(".h5p-slide-in");p&&(p.classList.remove("h5p-next"),n.startScreen.hide(),n.libraryScreen.show());}})),n.on("restarted",(function(){n.currentEndScreen&&(n.currentEndScreen.hide(),n.currentEndScreen=null),n.scoring.restart(),n.xAPIDataCollector=[],n.startScreen.screenWrapper.style.height="",n.startScreen.screenWrapper.classList.remove("h5p-slide-out"),n.startScreen.show(n.isReverseTransition),n.isReverseTransition=!1,n.currentId=-1,n.userPath=[],n.libraryScreen&&n.libraryScreen.remove(),n.libraryScreen=new H5P.BranchingScenario.LibraryScreen(n,t.startScreen.startScreenTitle,n.getLibrary(0)),n.libraryScreen.on("toggleFullScreen",(function(){n.toggleFullScreen();})),n.$container.append(n.libraryScreen.getElement());})),n.on("resize",(function(t){if(!n.bubblingUpwards){n.changeLayoutToFitWidth(),n.libraryScreen&&"object"===e(n.libraryScreen)&&0!==Object.keys(n.libraryScreen).length&&n.libraryScreen.resize(t);var r=n.$container[0].getBoundingClientRect();r.width<=480?n.$container.addClass("h5p-phone-size"):n.$container.removeClass("h5p-phone-size"),r.width<768?n.$container.addClass("h5p-medium-tablet-size"):n.$container.removeClass("h5p-medium-tablet-size");}})),n.toggleFullScreen=function(){n.isFullScreen()?H5P.exitFullScreen&&H5P.exitFullScreen():H5P.fullScreen(n.$container,this);},n.isFullScreen=function(){return H5P.isFullscreen||n.$container&&n.$container[0].classList.contains("h5p-fullscreen")||n.$container&&n.$container[0].classList.contains("h5p-semi-fullscreen");},n.disableNavButton=function(){n.libraryScreen.navButton&&(n.libraryScreen.navButton.classList.add("h5p-disabled"),n.libraryScreen.navButton.setAttribute("disabled",!0),n.libraryScreen.navButton.setAttribute("title",t.l10n.disableProceedButtonText));},n.enableNavButton=function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];n.libraryScreen.navButton&&(n.libraryScreen.navButton.classList.remove("h5p-disabled"),n.libraryScreen.navButton.removeAttribute("disabled"),n.libraryScreen.navButton.removeAttribute("title"),e&&n.animateNavButton());},n.hideNavButton=function(){n.libraryScreen.navButton&&n.libraryScreen.navButton.classList.add("h5p-hidden");},n.showNavButton=function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(n.libraryScreen.navButton){n.libraryScreen.navButton.classList.remove("h5p-hidden"),document.activeElement.blur();var t=100;e&&n.animateNavButton(),setTimeout((function(){n.libraryScreen.navButton.focus();}),t);}},n.animateNavButton=function(){n.libraryScreen.navButton.classList.contains("h5p-animate")||n.libraryScreen.navButton.classList.add("h5p-animate");},n.unanimateNavButton=function(){n.libraryScreen.navButton.classList.remove("h5p-animate");},n.getScore=function(){return n.scoring.getScore();},n.getMaxScore=function(){return n.scoring.getMaxScore();},n.changeLayoutToFitWidth=function(){var e=parseInt(window.getComputedStyle(document.getElementsByTagName("body")[0]).fontSize,10);this.$container.width()/e>43?n.$container[0].classList.add("h5p-wide-screen"):n.$container[0].classList.add("h5p-mobile-screen");},n.disableBackButton=function(){n.libraryScreen&&n.libraryScreen.backButton&&(n.libraryScreen.backButton.classList.add("h5p-disabled"),n.libraryScreen.backButton.setAttribute("disabled",!0));},n.enableBackButton=function(){n.libraryScreen&&n.libraryScreen.backButton&&(n.libraryScreen.backButton.classList.remove("h5p-disabled"),n.libraryScreen.backButton.removeAttribute("disabled"));},n.getUserPath=function(){return n.userPath;},n.canEnableBackButton=function(e){return "number"==typeof e&&!(e<0||e>n.backwardsAllowedFlags.length-1)&&n.backwardsAllowedFlags[e];},n.attach=function(e){if(void 0!==this.isRoot&&this.isRoot()&&this.setActivityStarted(),n.$container=e,e.addClass("h5p-branching-scenario").html(""),!t.content||0===t.content.length){var r=document.createElement("div");return r.innerHTML="No content",void n.$container.append(r);}var i,s,o,c,d,l;n.startScreen=(!0,s=(i=t.startScreen).startScreenTitle,o=i.startScreenSubtitle,c=i.startScreenImage,d=i.startScreenAltText,(l=new H5P.BranchingScenario.GenericScreen(n,{isStartScreen:!0,titleText:s,subtitleText:o,image:c,altText:d,fullscreenAria:t.l10n.fullscreenAria,buttonText:t.l10n.startScreenButtonText,isCurrentScreen:true})).on("toggleFullScreen",(function(){n.toggleFullScreen();})),l),n.$container.append(n.startScreen.getElement()),n.currentId=-1,n.libraryScreen=new H5P.BranchingScenario.LibraryScreen(n,t.startScreen.startScreenTitle,n.getLibrary(0)),n.libraryScreen.on("toggleFullScreen",(function(){n.toggleFullScreen();})),n.$container.append(n.libraryScreen.getElement()),t.endScreens.forEach((function(e){n.endScreens[e.contentId]=a(e),n.$container.append(n.endScreens[e.contentId].getElement());}));},n.getXAPIData=function(){if(n.currentEndScreen){var e=n.createXAPIEventTemplate("answered"),t=e.getVerifiedStatementValue(["object","definition"]);H5P.jQuery.extend(t,{interactionType:"compound",type:"http://adlnet.gov/expapi/activities/cmi.interaction"}),t.extensions={"https://h5p.org/x-api/no-question-score":1};var r=n.scoring.getScore(n.currentEndScreen.getScore()),i=n.scoring.getMaxScore();return e.setScoredResult(r,i,this,!0,r===i),{statement:e.data.statement,children:n.xAPIDataCollector};}console.error("Called getXAPIData before finished.");};},H5P.BranchingScenario.prototype=Object.create(H5P.EventDispatcher.prototype),H5P.BranchingScenario.prototype.constructor=H5P.BranchingScenario;})(),H5P.BranchingScenario.GenericScreen=function(){function e(e,t){var r=this;H5P.EventDispatcher.call(this);var n=this;n.parent=e,n.isShowing=t.isStartScreen,n.isFeedbackAvailable=!1,n.screenWrapper=document.createElement("div"),n.screenWrapper.classList.add(t.isStartScreen?"h5p-start-screen":"h5p-end-screen"),n.screenWrapper.classList.add(t.isCurrentScreen?"h5p-current-screen":"h5p-next-screen"),t.isCurrentScreen?n.parent.currentHeight="45em":this.screenWrapper.classList.add("h5p-branching-hidden");var i=document.createElement("div");i.classList.add("h5p-branching-scenario-screen-content");var a=document.createElement("div");a.classList.add("h5p-feedback-content-content"),i.appendChild(a),n.feedbackText=a;var s=document.createElement("h1");s.className="h5p-branching-scenario-title-text",s.innerHTML=t.titleText;var o=document.createElement("div");o.className="h5p-branching-scenario-subtitle-text",o.innerHTML=t.subtitleText;var c=document.createElement("button");c.classList.add(t.isStartScreen?"h5p-start-button":"h5p-end-button"),c.classList.add("transition"),c.onclick=function(){t.isStartScreen?n.parent.trigger("started"):n.parent.trigger("restarted");var e=document.getElementsByClassName("h5p-start-screen")[0];t.isStartScreen||(e.style.height=""),n.parent.navigating=!0;},n.navButton=c;var d=document.createTextNode(t.buttonText);if(c.appendChild(d),a.appendChild(s),a.appendChild(o),i.appendChild(c),t.showScore&&void 0!==t.score&&(n.scoreWrapper=this.createResultContainer(t.scoreText,t.score,t.maxScore),i.insertBefore(n.scoreWrapper,i.firstChild)),H5P.canHasFullScreen){var l=document.createElement("button");l.className="h5p-branching-full-screen",l.setAttribute("aria-label",this.parent.params.l10n.fullscreenAria),l.addEventListener("click",(function(){r.trigger("toggleFullScreen");})),n.screenWrapper.appendChild(l);}n.screenWrapper.appendChild(n.createScreenBackground(t.isStartScreen,t.image,t.altText)),n.screenWrapper.appendChild(i),(t.showScore&&void 0!==t.score||""!==t.titleText||""!==t.subtitleText)&&(a.tabIndex=-1,n.isFeedbackAvailable=!0),n.getScore=function(){return t.score;},n.getMaxScore=function(){return t.maxScore;},n.checkIntroReset=function(){var e=document.getElementsByClassName("h5p-start-screen")[0];["h5p-end-screen","h5p-current-screen"].every((function(e){return n.screenWrapper.classList.contains(e);}))?e.classList.add("h5p-reset-start"):e.classList.contains("h5p-reset-start")&&e.classList.remove("h5p-reset-start");};}return e.prototype.getElement=function(){return this.screenWrapper;},e.prototype.setScore=function(e){this.scoreValue&&void 0!==e&&(this.scoreValue.textContent=e.toString());},e.prototype.setMaxScore=function(e){void 0!==e&&(this.maxScoreValue.textContent=e.toString());},e.prototype.createResultContainer=function(e,t,r){var n=document.createElement("div");n.classList.add("h5p-result-wrapper");var i=document.createElement("div");i.classList.add("h5p-result-container");var a=document.createElement("div");a.classList.add("h5p-score-text"),a.appendChild(document.createTextNode(e));var s=document.createElement("div");s.classList.add("h5p-score-circle");var o=document.createElement("span");o.className="h5p-score-value",this.scoreValue=document.createTextNode(t.toString()),o.appendChild(this.scoreValue),s.appendChild(o);var c=document.createElement("span");c.className="h5p-score-delimiter",c.textContent="/",s.appendChild(c);var d=document.createElement("span");return d.className="h5p-max-score",this.maxScoreValue=document.createTextNode(r.toString()),d.appendChild(this.maxScoreValue),s.appendChild(d),i.appendChild(a),i.appendChild(s),n.appendChild(i),n;},e.prototype.createScreenBackground=function(e,t,r){var n=this,i=document.createElement("div");i.classList.add("h5p-screen-background");var a=document.createElement("div");a.classList.add("h5p-screen-banner");var s=document.createElement("img");return s.classList.add("h5p-background-image"),t&&t.path?s.src=H5P.getPath(t.path,this.parent.contentId):s.src=e?this.parent.getLibraryFilePath("assets/start-screen-default.jpg"):this.parent.getLibraryFilePath("assets/end-screen-default.jpg"),r&&r.length&&s.setAttribute("aria-label",r),s.addEventListener("load",(function(){n.parent.trigger("resize");})),i.appendChild(a),i.appendChild(s),i;},e.prototype.show=function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=this;t.isShowing=!0,e&&t.screenWrapper.classList.add("h5p-previous"),t.screenWrapper.classList.add("h5p-slide-in"),t.screenWrapper.classList.remove("h5p-branching-hidden"),t.screenWrapper.addEventListener("animationend",(function(r){"slide-in"===r.animationName&&(e&&t.screenWrapper.classList.remove("h5p-previous"),t.screenWrapper.classList.remove("h5p-next-screen"),t.screenWrapper.classList.remove("h5p-slide-in"),t.screenWrapper.classList.add("h5p-current-screen"),t.screenWrapper.setAttribute("aria-hidden",!1),t.parent.trigger("resize"),t.isFeedbackAvailable?t.feedbackText.focus():t.navButton.focus(),t.checkIntroReset());}));},e.prototype.hide=function(){var e=this;e.isShowing=!1,e.screenWrapper.classList.add("h5p-slide-out"),e.screenWrapper.addEventListener("animationend",(function(t){"slide-out"===t.animationName&&(e.screenWrapper.classList.add("h5p-branching-hidden"),e.screenWrapper.classList.remove("h5p-current-screen"),e.screenWrapper.classList.add("h5p-next-screen"),e.screenWrapper.classList.remove("h5p-slide-out"));}));},e;}(),(()=>{"use strict";var e=i(734);H5P.BranchingScenario.LibraryScreen=function(t){function r(e,t,r){var n=this;H5P.EventDispatcher.call(this),this.parent=e,this.currentLibraryElement,this.currentLibraryInstance,this.currentLibraryId=0,this.nextLibraryId=r.nextContentId,this.libraryFeedback=r.feedback,this.nextLibraries={},this.libraryInstances={},this.libraryFinishingRequirements=[],this.libraryTitle,this.branchingQuestions=[],this.navButton,this.header,this.isShowing=!1,this.contentOverlays=[];var i=r.type&&r.type.metadata&&r.type.metadata.title?r.type.metadata.title:"";this.wrapper=this.createWrapper(t,i||"Untitled Content",r.showContentTitle&&i),this.wrapper.classList.add("h5p-next-screen"),this.wrapper.classList.add("h5p-branching-hidden");var a=this.createLibraryElement(r,!1);this.currentLibraryWrapper=a,this.currentLibraryElement=a.getElementsByClassName("h5p-branching-scenario-content")[0],this.currentLibraryInstance=this.libraryInstances[0],this.createNextLibraries(r),this.wrapper.appendChild(a),this.createNavButtons(),e.on("enterFullScreen",(function(){setTimeout((function(){n.currentLibraryInstance&&n.currentLibraryInstance.trigger("resize");}),500);}));}return r.prototype.handleLibraryResize=function(){if(this.parent.isFullScreen())return this.currentLibraryWrapper.style.height="",void (this.wrapper.style.minHeight="");this.currentLibraryWrapper.style.height=this.currentLibraryElement.clientHeight+40+"px",this.wrapper.style.minHeight=this.currentLibraryElement.clientHeight+40+70.17+"px",this.currentLibraryWrapper.offsetHeight500&&(i.wrapper.style.minHeight=i.wrapper.clientHeight+"px");})),o.addEventListener("animationend",(function(t){"slide-in"===t.animationName&&a.currentLibraryElement&&(s.trigger("resize"),setTimeout((function(){(0,e.kp)(a.currentLibraryElement,(function(){a.handleLibraryResize(),s.trigger("resize");}));}),100));})),o;},r.prototype.createBackButton=function(e){var t=this,r=this,n=document.createElement("button");return n.classList.add("transition"),n.classList.add("h5p-back-button"),n.addEventListener("click",(function(e){if(e.currentTarget.hasAttribute("isBQ"))return t.overlay&&(null!==t.overlay.parentNode&&t.overlay.parentNode.removeChild(t.overlay),t.overlay=void 0,t.branchingQuestions.forEach((function(e){null!==e.parentNode&&e.parentNode.removeChild(e);})),t.showBackgroundToReadspeaker()),"H5P.BranchingQuestion"===r.parent.params.content[0].type.library.split(" ")[0]&&0===r.parent.currentId?(r.parent.trigger("restarted"),n):void r.parent.trigger("navigated",{reverse:!0});if(!0!==r.parent.navigating){if(0===r.currentLibraryId&&"H5P.BranchingQuestion"!==r.parent.params.content[r.parent.currentId].type.library.split(" ")[0])return r.parent.isReverseTransition=!0,r.parent.trigger("restarted"),n;r.parent.trigger("navigated",{reverse:!0}),r.parent.navigating=!0;}})),n.appendChild(document.createTextNode(e)),n;},r.prototype.handleProceed=function(){var e=this,t=!0;if(!1===this.parent.navigating){var r=this.libraryFeedback.title&&this.libraryFeedback.title.trim(),n=this.libraryFeedback.subtitle&&this.libraryFeedback.subtitle.trim(),i=!!(r||n||this.libraryFeedback.image);if(i&&-1!==this.nextLibraryId){void 0===this.overlay&&(this.overlay=document.createElement("div"),this.overlay.className="h5p-branching-scenario-overlay",this.wrapper.appendChild(this.overlay),this.hideBackgroundFromReadspeaker());var a=document.createElement("div");a.classList.add("h5p-branching-question-wrapper"),a.classList.add("h5p-branching-scenario-feedback-dialog");var s=document.createElement("div");s.classList.add("h5p-branching-question-container"),a.appendChild(s);var o=this.createFeedbackScreen(this.libraryFeedback,this.nextLibraryId);s.appendChild(o),s.classList.add("h5p-start-outside"),s.classList.add("h5p-fly-in"),this.currentLibraryWrapper.style.zIndex=0,setTimeout((function(){e.wrapper.appendChild(a),parseInt(e.currentLibraryWrapper.style.height)0?n.parent.enableNavButton():n.handleVideoOver(),this.pause();}}));break;case "H5P.Video":e.on("stateChange",(function(e){e.data===H5P.Video.ENDED&&(n.nextIsBranching(n.currentLibraryId)||n.handleVideoOver());}));break;case "H5P.Audio":e.audio.on("ended",(function(){n.parent.enableNavButton();}));break;default:"function"==typeof e.getAnswerGiven&&e.on("xAPI",(function(e){"answered"!==e.data.statement.verb.display["en-US"]&&"completed"!==e.data.statement.verb.display["en-US"]||n.parent.enableNavButton();}));}},r.prototype.handleVideoOver=function(){this.nextIsBranching(this.currentLibraryId)?this.handleProceed():this.showContentOverlay(),this.parent.enableNavButton();},r.prototype.showContentOverlay=function(){this.contentOverlays[this.currentLibraryId].show();},r.prototype.hideContentOverlay=function(){this.contentOverlays[this.currentLibraryId].hide();},r.prototype.getXAPIData=function(e){if(this.libraryInstances[e]&&this.libraryInstances[e].getXAPIData)return this.libraryInstances[e].getXAPIData();},r.prototype.nextIsBranching=function(e){var t=void 0!==e?this.parent.params.content[e].nextContentId:void 0;return void 0!==t&&t>0&&r.isBranching(this.parent.params.content[t]);},r.prototype.createNextLibraries=function(e){this.removeNextLibraries(),this.nextLibraries={},this.loadLibrary(e);},r.prototype.createNextLibrary=function(e){this.removeNextLibraries(),this.nextLibraries={},this.loadLibrary(e,e.contentId);},r.prototype.loadLibrary=function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=null!==r?r:e.nextContentId;if("H5P.BranchingQuestion"!==e.type.library.split(" ")[0]){var i=this.parent.getLibrary(n);if(!1===i)return;i.type&&"H5P.BranchingQuestion"!==i.type.library.split(" ")[0]&&(this.nextLibraries[n]=this.createLibraryElement(i,!0),this.wrapper.appendChild(this.nextLibraries[n]));}else{var a=e.type.params.branchingQuestion.alternatives||[],s=a.map((function(e){return e.nextContentId;}));s.forEach((function(e){var r=t.parent.getLibrary(e);!1!==r&&r.type&&"H5P.BranchingQuestion"!==r.type.library.split(" ")[0]&&(t.nextLibraries[e]=t.createLibraryElement(r,!0),t.wrapper.appendChild(t.nextLibraries[e]));}));}},r.prototype.removeNextLibraries=function(){for(var e=this.wrapper.getElementsByClassName("h5p-next"),t=0;t0&&void 0!==arguments[0]&&arguments[0];if(this.questionContainer){var t=e?this.parent.startScreen.screenWrapper:this.wrapper,r=parseInt(window.getComputedStyle(this.questionContainer,null).getPropertyValue("padding-top"),10);t.style.height=this.questionContainer.offsetHeight+r+"px";}},r.prototype.showNextLibrary=function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(this.nextLibraryId=e.nextContentId,this.libraryFeedback=e.feedback,r.isBranching(e)){!0===this.parent.params.behaviour&&this.parent.disableNavButton(),this.branchingQuestions.forEach((function(e){null!==e.parentNode&&e.parentNode.removeChild(e);}));var n=document.querySelector(".h5p-current-screen");void 0===this.overlay&&(this.overlay=document.createElement("div"),this.overlay.className="h5p-branching-scenario-overlay",n.appendChild(this.overlay),this.hideBackgroundFromReadspeaker());var i=document.createElement("div");i.classList.add("h5p-nav-button-wrapper"),-1!==this.parent.backwardsAllowedFlags.indexOf(!0)&&(this.bqBackButton=this.createBackButton(this.parent.params.l10n.backButtonText),this.bqBackButton.setAttribute("isBQ",!0),!1===this.parent.canEnableBackButton(e.contentId)&&(this.bqBackButton.classList.add("h5p-disabled"),this.bqBackButton.setAttribute("disabled",!0)),i.appendChild(this.bqBackButton));var a=document.createElement("div");a.className="h5p-branching-question-wrapper",this.appendRunnable(a,e.type,e.contentId),n.appendChild(a),this.branchingQuestions.push(a);var s="h5p-branching-question-title-"+r.idCounter++,o=a.querySelector(".h5p-branching-question-container");this.questionContainer=o,o.setAttribute("role","dialog"),o.setAttribute("tabindex","-1"),o.setAttribute("aria-labelledby",s),o.classList.add("h5p-start-outside"),o.classList.add("h5p-fly-in"),a.querySelector(".h5p-branching-question-title").id=s;var c=a.querySelector(".h5p-multichoice-wrapper");c.setAttribute("role","group"),c.setAttribute("aria-labelledby",s),document.querySelector(".h5p-branching-question").appendChild(i),this.currentLibraryWrapper.style.zIndex=0;var d=this.parent.isFullScreen(),l=this.parent.$container[0].classList.contains("h5p-mobile-screen");""!==this.currentLibraryWrapper.style.height||this.parent.startScreen.isShowing||d||l?this.parent.startScreen.isShowing&&!d?this.resizeScreen(!0):parseInt(this.currentLibraryWrapper.style.height)y.height/y.width?a?v.style.maxWidth=y.height*(u/p)+"px":v.style.width=y.height*(u/p)+"px":(v.style.height=y.width*b+"px",d&&null!==r.querySelector("iframe")&&(r.querySelector("iframe").style.height=y.width*b+"px"));}}}else{this.parent.startScreen.isShowing?this.resizeScreen(!0):this.overlay?this.resizeScreen():this.wrapper.style.height="";var g=r.getElementsByClassName("h5p-video-wrapper");if(o&&g.length>0){var m=g[0].firstChild;m.style&&(m.style.height=t.videoHeight);}else d&&null!==r.querySelector("iframe")&&(r.querySelector("iframe").style.height="");r.classList.remove("h5p-fullscreen");}t&&(t.trigger("resize",e),this.handleLibraryResize());},r.isBranching=function(e){return !!(e&&e.type&&e.type.library)&&0===e.type.library.indexOf("H5P.BranchingQuestion ");},r.prototype.createNavButtons=function(){var e=this,t=this,r=this.parent,n=document.createElement("div");n.classList.add("h5p-nav-button-wrapper"),-1!==r.backwardsAllowedFlags.indexOf(!0)&&(this.backButton=this.createBackButton(r.params.l10n.backButtonText),n.appendChild(this.backButton));var i=document.createElement("button");i.classList.add("transition"),i.onclick=function(){if(!1===r.navigating){var e=t.libraryFeedback.title&&t.libraryFeedback.title.trim(),n=t.libraryFeedback.subtitle&&t.libraryFeedback.subtitle.trim(),i=!!(e||n||t.libraryFeedback.image);if(i&&-1!==t.nextLibraryId){void 0===t.overlay&&(t.overlay=document.createElement("div"),t.overlay.className="h5p-branching-scenario-overlay",t.wrapper.appendChild(t.overlay),t.hideBackgroundFromReadspeaker());var a=document.createElement("div");a.classList.add("h5p-branching-question-wrapper"),a.classList.add("h5p-branching-scenario-feedback-dialog");var s=document.createElement("div");s.classList.add("h5p-branching-question-container"),a.appendChild(s);var o=t.createFeedbackScreen(t.libraryFeedback,t.nextLibraryId);s.appendChild(o),s.classList.add("h5p-start-outside"),s.classList.add("h5p-fly-in"),t.currentLibraryWrapper.style.zIndex=0,t.wrapper.appendChild(a),o.focus();}else{var c={nextContentId:t.nextLibraryId};(i||void 0!==t.libraryFeedback.endScreenScore)&&(c.feedback=t.libraryFeedback),r.trigger("navigated",c);}r.navigating=!0;}},i.classList.add("h5p-nav-button"),this.navButton=document.createElement("button"),this.navButton.classList.add("transition"),this.navButton.addEventListener("animationend",(function(){e.parent.unanimateNavButton();})),this.navButton.addEventListener("click",(function(){if(!e.parent.proceedButtonInProgress){e.parent.proceedButtonInProgress=!0;var t=e;new Promise((function(e){t.handleProceed()&&e(!0);})).then((function(){t.parent.proceedButtonInProgress=!1;}));}})),this.navButton.classList.add("h5p-nav-button","h5p-proceed-button");var a=r.getLibrary(this.currentLibraryId).proceedButtonText;this.navButton.appendChild(document.createTextNode(a)),n.appendChild(this.navButton);var s=document.createElement("div");s.classList.add("h5p-screen-footer"),s.appendChild(n),t.wrapper.appendChild(s);},r.idCounter=0,r;}(H5P.jQuery);})(),H5P.BranchingScenario.LibraryScreenOverlay=function(){function e(e){this.hidden=!0,this.parent=e,this.overlay=document.createElement("div"),this.overlay.classList.add("h5p-content-overlay"),this.overlay.classList.add("h5p-hidden"),this.buttonsContainer=document.createElement("div"),this.buttonsContainer.classList.add("h5p-content-overlay-buttons-container"),this.overlay.appendChild(this.buttonsContainer),this.buttons={};}return e.prototype.getDOM=function(){return this.overlay;},e.prototype.show=function(){var e=this;this.overlay.classList.remove("h5p-hidden"),window.requestAnimationFrame((function(){e.buttonsContainer.classList.remove("h5p-hidden"),e.hidden=!1,Object.values(e.buttons)[Object.keys(e.buttons).length-1].focus();}));},e.prototype.hide=function(){this.hidden=!0,this.overlay.classList.add("h5p-hidden"),this.buttonsContainer.classList.add("h5p-hidden");},e.prototype.isVisible=function(){return !this.hidden;},e.prototype.addButton=function(e,t,r){if(!e&&0!==e||!t||"function"!=typeof r||this.buttons[e])return null;var n=document.createElement("button");return n.classList.add("transition"),n.classList.add("h5p-nav-button"),n.classList.add("h5p-nav-button-".concat(e)),n.innerText=t,n.addEventListener("click",(function(t){r(e);})),this.buttons[e]=n,this.buttonsContainer.appendChild(n),n;},e.prototype.removeButton=function(e){(e||0===e)&&this.buttons[e]&&(this.buttonsContainer.removeChild(this.buttons[e]),delete this.buttons[e]);},e;}(),H5P.BranchingScenario.Scoring=(e="static-end-score",t="dynamic-score",function(r){var n=this,i=[],a=0,s=function(e){return e&&e.feedback&&void 0!==e.feedback.endScreenScore;};this.getScore=function(n){return r.scoringOptionGroup.scoringOption===t?i.reduce((function(e,t){return e+t.score;}),0):r.scoringOptionGroup.scoringOption===e?n:0;},this.getMaxScore=function(){return r.scoringOptionGroup.scoringOption===e?(o=r.endScreens[0].endScreenScore,c=void 0!==o?o:0,r.content.reduce((function(e,t){var r=[t];return n.isBranchingQuestion(t)&&(r=t.type.params.branchingQuestion.alternatives),e.concat(r);}),[]).filter((function(e){return -1===e.nextContentId;})).reduce((function(e,t){var r=s(t)?t.feedback.endScreenScore:c;return e>=r?e:r;}),0)):r.scoringOptionGroup.scoringOption===t?(a=0,i.forEach((function(e){a+=e.maxScore;})),a):0;var a,o,c;},this.restart=function(){i=[],a=0;},this.addLibraryScore=function(e,t,n,o){a+=1;var c=r.content[e],d=0,l=0;e!==t||0===e&&this.isBranchingQuestion(c)?(d=function(e,t){if(!(t>=0))return 0;if(!(e&&e.type&&e.type.params&&e.type.params.branchingQuestion&&e.type.params.branchingQuestion.alternatives&&e.type.params.branchingQuestion.alternatives[t]))return 0;var r=e.type.params.branchingQuestion.alternatives[t];return !s(r)||void 0===r.nextContentId||r.nextContentId<0?0:r.feedback.endScreenScore;}(c,n),l=function(e,t){if(!(t>=0))return 0;var r=e.type.params.branchingQuestion.alternatives,n=0;return r.forEach((function(e,t){r[t].feedback.endScreenScore>n&&-1!==r[t].nextContentId&&(n=r[t].feedback.endScreenScore);})),n;}(c,n)):(s(c)&&c.nextContentId&&c.nextContentId>-1&&(d=c.feedback.endScreenScore,l=c.feedback.endScreenScore),r.scoringOptionGroup.includeInteractionsScores&&0!==Object.entries(o).length&&(d+=o.score,l+=o.maxScore));var h=!1,p=null,u=-1;i.forEach((function(t,n){t.id===e&&(t.score=d,t.visitedIndex=a,u=t.visitedIndex,i.length>n+1&&r.content[t.id].nextContentId===i[n+1].id?h=!0:p=n);})),h?(i=i.filter((function(e){return e.visitedIndex<=u;})),a=u):(null!==p&&i.splice(p,1),i.push({visitedIndex:a,id:e,score:d,maxScore:l}));},this.isBranchingQuestion=function(e){var t=e;return e&&e.type&&e.type.library&&(t=e.type.library),"H5P.BranchingQuestion"===t.split(" ")[0];},this.isDynamicScoring=function(){return r.scoringOptionGroup.scoringOption===t;},this.shouldShowScore=function(){return r.scoringOptionGroup.scoringOption===e||this.isDynamicScoring();};});})();; /* @license MIT https://h5p.org */ try{window.H5PIntegration=drupalSettings.h5p.H5PIntegration;}catch(err){console.error('Missing H5PIntegration settings.');};