Sindbad~EG File Manager
(()=>{"use strict";var r=H5P.jQuery,e=function(){function e(e,t,a,i){var s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},n=arguments.length>5?arguments[5]:void 0;return this.card=e,this.params=t||{},this.id=a,this.contentId=i,this.callbacks=s,this.$cardWrapper=r("<div>",{class:"h5p-dialogcards-cardwrap",role:"group",tabindex:"-1"}),this.$cardWrapper.addClass("h5p-dialogcards-mode-"+this.params.mode),"repetition"!==this.params.mode&&this.$cardWrapper.attr("aria-labelledby","h5p-dialogcards-progress-"+n),this.$cardHolder=r("<div>",{class:"h5p-dialogcards-cardholder"}).appendTo(this.$cardWrapper),this.createCardContent(e).appendTo(this.$cardHolder),this}var t=e.prototype;return t.createCardContent=function(e){var t=r("<div>",{class:"h5p-dialogcards-card-content"});this.createCardImage(e).appendTo(t);var a=r("<div>",{class:"h5p-dialogcards-card-text-wrapper"}).appendTo(t),i=r("<div>",{class:"h5p-dialogcards-card-text-inner"}).appendTo(a),s=r("<div>",{class:"h5p-dialogcards-card-text-inner-content"}).appendTo(i);this.createCardAudio(e).appendTo(s);var n=r("<div>",{class:"h5p-dialogcards-card-text"}).appendTo(s);return this.$cardTextArea=r("<div>",{class:"h5p-dialogcards-card-text-area",tabindex:"-1",html:e.text}).appendTo(n),e.text&&e.text.length||n.addClass("hide"),this.createCardFooter().appendTo(a),t},t.massageAttributeOutput=function(r){var e=(new DOMParser).parseFromString(r,"text/html"),t=document.createElement("div");return t.innerHTML=e.documentElement.textContent,t.textContent||t.innerText||""},t.createCardImage=function(e){this.$image;var t=r("<div>",{class:"h5p-dialogcards-image-wrapper"});return void 0!==e.image?(this.image=e.image,this.$image=r('<img class="h5p-dialogcards-image" src="'+H5P.getPath(e.image.path,this.contentId)+'"/>'),e.imageAltText&&this.$image.attr("alt",this.massageAttributeOutput(e.imageAltText))):this.$image=r('<div class="h5p-dialogcards-image"></div>'),this.$image.appendTo(t),t},t.createCardAudio=function(e){if(this.audio,this.$audioWrapper=r("<div>",{class:"h5p-dialogcards-audio-wrapper"}),void 0!==e.audio){var t={files:e.audio,audioNotSupported:this.params.audioNotSupported};this.audio=new H5P.Audio(t,this.contentId),this.audio.attach(this.$audioWrapper),this.audio.audio&&this.audio.audio.preload&&(this.audio.audio.preload="none")}else this.$audioWrapper.addClass("hide");return this.$audioWrapper},t.createCardFooter=function(){var e=r("<div>",{class:"h5p-dialogcards-card-footer"}),t="h5p-dialogcards-button-hidden",a="-1";return"repetition"===this.params.mode&&(t="",this.params.behaviour.quickProgression&&(t="h5p-dialogcards-quick-progression",a="0")),this.$buttonTurn=H5P.JoubelUI.createButton({class:"h5p-dialogcards-turn",html:this.params.answer}).appendTo(e),"repetition"===this.params.mode&&(this.$buttonShowSummary=H5P.JoubelUI.createButton({class:"h5p-dialogcards-show-summary h5p-dialogcards-button-gone",html:this.params.showSummary}).appendTo(e),this.$buttonIncorrect=H5P.JoubelUI.createButton({class:"h5p-dialogcards-answer-button",html:this.params.incorrectAnswer}).addClass("incorrect").addClass(t).attr("tabindex",a).appendTo(e),this.$buttonCorrect=H5P.JoubelUI.createButton({class:"h5p-dialogcards-answer-button",html:this.params.correctAnswer}).addClass("correct").addClass(t).attr("tabindex",a).appendTo(e)),e},t.createButtonListeners=function(){var r=this;this.$buttonTurn.unbind("click").click((function(){r.turnCard()})),"repetition"===this.params.mode&&(this.$buttonIncorrect.unbind("click").click((function(e){e.target.classList.contains("h5p-dialogcards-quick-progression")&&r.callbacks.onNextCard({cardId:r.id,result:!1})})),this.$buttonCorrect.unbind("click").click((function(e){e.target.classList.contains("h5p-dialogcards-quick-progression")&&r.callbacks.onNextCard({cardId:r.id,result:!0})})))},t.showSummaryButton=function(r){this.getDOM().find(".h5p-dialogcards-answer-button").addClass("h5p-dialogcards-button-hidden").attr("tabindex","-1"),this.$buttonTurn.addClass("h5p-dialogcards-button-gone"),this.$buttonShowSummary.click((function(){return r()})).removeClass("h5p-dialogcards-button-gone").focus()},t.hideSummaryButton=function(){"normal"!==this.params.mode&&(this.getDOM().find(".h5p-dialogcards-answer-button").removeClass("h5p-dialogcards-button-hidden").attr("tabindex","0"),this.$buttonTurn.removeClass("h5p-dialogcards-button-gone"),this.$buttonShowSummary.addClass("h5p-dialogcards-button-gone").off("click"))},t.turnCard=function(){var r=this,e=this.getDOM(),t=e.find(".h5p-dialogcards-card-content"),a=e.find(".h5p-dialogcards-cardholder").addClass("h5p-dialogcards-collapse");t.find(".joubel-tip-container").remove();var i=t.hasClass("h5p-dialogcards-turned");t.toggleClass("h5p-dialogcards-turned",!i),this.isInTransition=!0,setTimeout((function(){if(a.removeClass("h5p-dialogcards-collapse"),r.changeText(i?r.getText():r.getAnswer()),i?a.find(".h5p-audio-inner").removeClass("hide"):r.removeAudio(a),"repetition"===r.params.mode&&!r.params.behaviour.quickProgression){var s=e.find(".h5p-dialogcards-answer-button");!1===s.hasClass("h5p-dialogcards-quick-progression")&&s.addClass("h5p-dialogcards-quick-progression").attr("tabindex",0)}setTimeout((function(){r.isInTransition=!1,r.addTipToCard(t,i?"front":"back"),"function"==typeof r.callbacks.onCardTurned&&r.callbacks.onCardTurned(i)}),200),r.resizeOverflowingText(),r.$cardTextArea.focus()}),200)},t.changeText=function(r){this.$cardTextArea.html(r),this.$cardTextArea.toggleClass("hide",!r||!r.length)},t.setProgressText=function(r,e){if("repetition"===this.params.mode){var t=this.params.progressText.replace("@card",r.toString()).replace("@total",e.toString());this.$cardWrapper.attr("aria-label",t)}},t.resizeOverflowingText=function(){if(this.params.behaviour.scaleTextNotCard){var r=this.getDOM().find(".h5p-dialogcards-card-text"),e=r.children();this.resizeTextToFitContainer(r,e)}},t.resizeTextToFitContainer=function(r,t){t.css("font-size","");var a=r.get(0).getBoundingClientRect().height,i=t.get(0).getBoundingClientRect().height,s=parseFloat(r.css("font-size")),n=parseFloat(t.css("font-size")),o=this.getDOM().closest(".h5p-container"),d=parseFloat(o.css("font-size"));if(i>a)for(var c=!0;c;){if((n-=e.SCALEINTERVAL)<e.MINSCALE){c=!1;break}t.css("font-size",n/s+"em"),(i=t.get(0).getBoundingClientRect().height)<=a&&(c=!1)}else for(var l=!0;l;){if((n+=e.SCALEINTERVAL)>d){l=!1;break}t.css("font-size",n/s+"em"),(i=t.get(0).getBoundingClientRect().height)>=a&&(l=!1,n-=e.SCALEINTERVAL,t.css("font-size",n/s+"em"))}},t.addTipToCard=function(r,e,t){"back"!==e&&(e="front"),void 0===t&&(t=this.id),r.find(".joubel-tip-container").remove();var a=this.card.tips;if(void 0!==a&&void 0!==a[e]){var i=a[e].trim();i.length&&r.find(".h5p-dialogcards-card-text-wrapper .h5p-dialogcards-card-text-inner").after(H5P.JoubelUI.createTip(i,{tipLabel:this.params.tipButtonLabel}))}},t.setCardFocus=function(r){if(!0===r)this.$cardTextArea.focus();else{var e=this.getDOM();e.one("transitionend",(function(){e.focus()}))}},t.stopAudio=function(){var r=this;if(this.audio&&this.audio.audio){var e=this.audio.audio.duration;e>0&&e<Number.MAX_SAFE_INTEGER&&this.audio.seekTo(e),this.audio.audio.load&&setTimeout((function(){r.audio.audio.load()}),100)}},t.removeAudio=function(){this.stopAudio(),this.getDOM().find(".h5p-audio-inner").addClass("hide")},t.getDOM=function(){return this.$cardWrapper},t.getText=function(){return this.card.text},t.getAnswer=function(){return this.card.answer},t.getImage=function(){return this.$image},t.getImageSize=function(){return this.image?{width:this.image.width,height:this.image.height}:this.image},t.getAudio=function(){return this.$audioWrapper},t.reset=function(){var r=this.getDOM();r.removeClass("h5p-dialogcards-previous"),r.removeClass("h5p-dialogcards-current"),this.changeText(this.getText());var e=r.find(".h5p-dialogcards-card-content");e.removeClass("h5p-dialogcards-turned"),this.addTipToCard(e,"front",this.id),this.params.behaviour.quickProgression||r.find(".h5p-dialogcards-answer-button").removeClass("h5p-dialogcards-quick-progression"),this.hideSummaryButton()},e}();e.SCALEINTERVAL=.2,e.MAXSCALE=16,e.MINSCALE=4;const t=e;const a=function(){function r(r,e,t,a){var i=this;return this.params=r,this.contentId=e,this.callbacks=t,this.idCounter=a,this.cards=[],this.params.dialogs.forEach((function(r,e){r.id=e,i.cards.push(e)})),this}var e=r.prototype;return e.getCard=function(r){if(!(r<0||r>this.cards.length))return"number"==typeof this.cards[r]&&this.loadCard(r),this.cards[r]},e.getCardIds=function(){return this.cards.map((function(r,e){return e}))},e.loadCard=function(r){r<0||r>this.cards.length||"number"==typeof this.cards[r]&&(this.cards[r]=new t(this.params.dialogs[r],this.params,r,this.contentId,this.callbacks,this.idCounter))},r}();function i(r){return function(r){if(Array.isArray(r))return s(r)}(r)||function(r){if("undefined"!=typeof Symbol&&null!=r[Symbol.iterator]||null!=r["@@iterator"])return Array.from(r)}(r)||function(r,e){if(r){if("string"==typeof r)return s(r,e);var t={}.toString.call(r).slice(8,-1);return"Object"===t&&r.constructor&&(t=r.constructor.name),"Map"===t||"Set"===t?Array.from(r):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?s(r,e):void 0}}(r)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function s(r,e){(null==e||e>r.length)&&(e=r.length);for(var t=0,a=Array(e);t<e;t++)a[t]=r[t];return a}const n=function(){function r(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return this.cards=r.filter((function(e,t){return r.indexOf(e)>=t})),this}var e=r.prototype;return e.getCards=function(){return this.cards},e.peek=function(r){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return e=Math.max(0,e),"top"===r&&(r=0),"bottom"===r&&(r=this.cards.length-e),r<0||r>this.cards.length-1?[]:this.cards.slice(r,r+e)},e.add=function(r){var e=this,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"top";"number"==typeof r&&(r=[r]),r.forEach((function(a){var s;-1===e.cards.indexOf(a)&&("top"===t?t=0:"bottom"===t?t=e.cards.length:"random"===t&&(t=Math.floor(Math.random()*e.cards.length)),(s=e.cards).splice.apply(s,[t,0].concat(i(r))))}))},e.push=function(r){this.add(r,"top")},e.pull=function(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"top";return r=Math.max(1,Math.min(r,this.cards.length)),"top"===e&&(e=0),"bottom"===e&&(e=-r),e=Math.max(0,Math.min(e,this.cards.length-1)),this.cards.splice(e,r)},e.remove=function(r){var e=this;"number"==typeof r&&(r=[r]),r.forEach((function(r){var t=e.cards.indexOf(r);t>-1&&e.cards.splice(t,1)}))},e.shuffle=function(){for(var r=this.cards.length-1;r>0;r--){var e=Math.floor(Math.random()*(r+1)),t=[this.cards[e],this.cards[r]];this.cards[r]=t[0],this.cards[e]=t[1]}return this.cards},e.contains=function(r){return-1!==this.cards.indexOf(r)},e.length=function(){return this.cards.length},r}();function o(r){return function(r){if(Array.isArray(r))return d(r)}(r)||function(r){if("undefined"!=typeof Symbol&&null!=r[Symbol.iterator]||null!=r["@@iterator"])return Array.from(r)}(r)||function(r,e){if(r){if("string"==typeof r)return d(r,e);var t={}.toString.call(r).slice(8,-1);return"Object"===t&&r.constructor&&(t=r.constructor.name),"Map"===t||"Set"===t?Array.from(r):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?d(r,e):void 0}}(r)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(r,e){(null==e||e>r.length)&&(e=r.length);for(var t=0,a=Array(e);t<e;t++)a[t]=r[t];return a}const c=function(){function r(r,e,t,i){return this.params=r,this.cardPool=new a(r,e,t,i),this.reset(r.cardPiles),this}var e=r.prototype;return e.createSelection=function(){var r=[];if("repetition"===this.params.mode)r=this.createSelectionRepetition();else r=this.cardPool.getCardIds();return r},e.createPiles=function(r){if(r)this.cardPiles=r.map((function(r){return new n(r.cards)}));else{this.cardPiles=[];var e=this.cardPool.getCardIds();switch(this.params.mode){case"repetition":for(var t=0;t<this.params.behaviour.maxProficiency+1;t++)0===t?this.cardPiles.push(new n(e)):this.cardPiles.push(new n);break;case"normal":this.cardPiles.push(new n(e))}}},e.updatePiles=function(r){var e=this;return r.forEach((function(r){var t=e.find(r.cardId);if(-1!==t){var a=!0===r.result?t+1:0;a=Math.max(0,Math.min(a,e.cardPiles.length-1)),e.cardPiles[t].remove(r.cardId),e.cardPiles[a].add(r.cardId,"bottom")}})),this.getPileSizes()},e.createSelectionRepetition=function(){for(var r=[],e=null,t=0;t<this.cardPiles.length-1;t++){var a,i=this.cardPiles[t].length();if(null!==e||0!==i){null===e&&(e=t);var s=Math.ceil(1*i/(1+t-e)),n=this.cardPiles[t].peek(0,s);r=(a=r).concat.apply(a,o(n))}}return r=this.shuffle(r)},e.shuffle=function(r){for(var e=r.slice(),t=e.length-1;t>0;t--){var a=Math.floor(Math.random()*(t+1)),i=[e[a],e[t]];e[t]=i[0],e[a]=i[1]}return e},e.find=function(r){var e=-1;return this.cardPiles.forEach((function(t,a){if(-1!==e)return e;t.contains(r)&&(e=a)})),e},e.reset=function(r){this.createPiles(r)},e.getCard=function(r){return this.cardPool.getCard(r)},e.getSize=function(){return this.cardPool.getCardIds().length},e.getPiles=function(){return this.cardPiles},e.getPileSizes=function(){return this.cardPiles.map((function(r){return r.length()}))},r}();const l=function(){function r(r,e){var t=this;this.params=r,this.callbacks=e,this.currentCallback=e.nextRound,this.fields=[],this.container=document.createElement("div"),this.container.classList.add("h5p-dialogcards-summary-screen");var a=this.createContainerDOM(r.summary);this.fields.round=a.getElementsByClassName("h5p-dialogcards-summary-subheader")[0],this.fields["h5p-dialogcards-round-cards-right"]=this.addTableRow(a,{category:this.params.summaryCardsRight,symbol:"h5p-dialogcards-check"}),this.fields["h5p-dialogcards-round-cards-wrong"]=this.addTableRow(a,{category:this.params.summaryCardsWrong,symbol:"h5p-dialogcards-times"}),this.fields["h5p-dialogcards-round-cards-not-shown"]=this.addTableRow(a,{category:this.params.summaryCardsNotShown});var i=this.createContainerDOM(r.summaryOverallScore);this.fields["h5p-dialogcards-overall-cards-completed"]=this.addTableRow(i,{category:this.params.summaryCardsCompleted,symbol:"h5p-dialogcards-check"}),this.fields["h5p-dialogcards-overall-completed-rounds"]=this.addTableRow(i,{category:this.params.summaryCompletedRounds,symbol:""});var s=document.createElement("div");s.classList.add("h5p-dialogcards-summary-message"),this.fields.message=s;var n=H5P.JoubelUI.createButton({class:"h5p-dialogcards-buttonNextRound",title:this.params.nextRound.replace("@round",2),html:this.params.nextRound.replace("@round",2)}).click(this.currentCallback).get(0);this.fields.button=n;var o=H5P.JoubelUI.createButton({class:"h5p-dialogcards-button-restart",title:this.params.startOver,html:this.params.startOver}).get(0),d=this.createConfirmationDialog({l10n:this.params.confirmStartingOver,instance:this},(function(){setTimeout((function(){t.callbacks.retry()}),100)}));o.addEventListener("click",(function(r){d.show(r.target.offsetTop)})),this.fields.buttonStartOver=o;var c=document.createElement("div");return c.classList.add("h5p-dialogcards-summary-footer"),c.appendChild(o),c.appendChild(n),this.container.appendChild(a),this.container.appendChild(i),this.container.appendChild(s),this.container.appendChild(c),this.hide(),this}var e=r.prototype;return e.getDOM=function(){return this.container},e.createContainerDOM=function(r){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",t=document.createElement("div");t.classList.add("h5p-dialogcards-summary-container");var a=document.createElement("div");a.classList.add("h5p-dialogcards-summary-header"),a.innerHTML=r,t.appendChild(a);var i=document.createElement("div");i.classList.add("h5p-dialogcards-summary-subheader"),i.innerHTML=e,t.appendChild(i);var s=document.createElement("table");return s.classList.add("h5p-dialogcards-summary-table"),t.appendChild(s),t},e.addTableRow=function(r,e){var t=r.getElementsByClassName("h5p-dialogcards-summary-table")[0],a=document.createElement("tr"),i=document.createElement("td");i.classList.add("h5p-dialogcards-summary-table-row-category"),i.innerHTML=e.category,a.appendChild(i);var s=document.createElement("td");s.classList.add("h5p-dialogcards-summary-table-row-symbol"),void 0!==e.symbol&&""!==e.symbol&&s.classList.add(e.symbol),a.appendChild(s);var n=document.createElement("td");return n.classList.add("h5p-dialogcards-summary-table-row-score"),a.appendChild(n),t.appendChild(a),n},e.update=function(){var r=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.done,a=void 0!==t&&t,i=e.round,s=void 0===i?void 0:i,n=e.message,o=void 0===n?void 0:n,d=e.results,c=void 0===d?[]:d;!0===a?(this.fields.buttonStartOver.classList.add("h5p-dialogcards-button-gone"),this.params.behaviour.enableRetry?(this.fields.button.classList.remove("h5p-dialogcards-button-next-round"),this.fields.button.classList.add("h5p-dialogcards-button-restart"),this.fields.button.innerHTML=this.params.retry,this.fields.button.title=this.params.retry,this.currentCallback=this.callbacks.retry):this.fields.button.classList.add("h5p-dialogcards-button-gone")):(this.fields.buttonStartOver.classList.remove("h5p-dialogcards-button-gone"),this.fields.button.classList.add("h5p-dialogcards-button-next-round"),this.fields.button.classList.remove("h5p-dialogcards-button-restart"),this.fields.button.innerHTML=this.params.nextRound,this.fields.button.title=this.params.nextRound,this.currentCallback=this.callbacks.nextRound),H5P.jQuery(this.fields.button).unbind("click").click(this.currentCallback),this.fields.round.innerHTML=this.params.round.replace("@round",s),a||void 0===s||(this.fields.button.innerHTML=this.params.nextRound.replace("@round",s+1),this.fields.button.title=this.params.nextRound.replace("@round",s+1)),a&&void 0!==o&&""!==o?(this.fields.message.classList.remove("h5p-dialogcards-gone"),this.fields.message.innerHTML=o):this.fields.message.classList.add("h5p-dialogcards-gone"),c.forEach((function(e){var t=void 0!==e.score.value?e.score.value:"";void 0!==e.score.max&&(t="".concat(t,' <span class="h5p-dialogcards-summary-table-row-score-divider">/</span> ').concat(e.score.max)),r.fields[e.field].innerHTML=t}))},e.show=function(){var r=this;this.container.classList.remove("h5p-dialogcards-gone"),setTimeout((function(){r.fields.button.focus()}),0)},e.hide=function(){this.container.classList.add("h5p-dialogcards-gone")},e.createConfirmationDialog=function(r,e){r=r||{};var t=new H5P.ConfirmationDialog({instance:r.instance,headerText:r.l10n.header,dialogText:r.l10n.body,cancelText:r.l10n.cancelLabel,confirmText:r.l10n.confirmLabel});return t.on("confirmed",(function(){e()})),t.appendTo(this.getContainer()),t},e.getContainer=function(){var r=H5P.jQuery('[data-content-id="'+self.contentId+'"].h5p-content'),e=r.parents(".h5p-container");return(0!==e.length?e.last():0!==r.length?r:H5P.jQuery(document.body)).get(0)},r}();function u(r){if(void 0===r)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return r}function h(r,e){return h=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,e){return r.__proto__=e,r},h(r,e)}var p=H5P.jQuery,g=H5P.JoubelUI,m=function(r){var e,t;function a(e,t,i){var s;return(s=r.call(this)||this).idCounter=a.idCounter++,s.contentId=s.id=t,s.previousState=i.previousState||{},s.contentData=i||{},s.params=p.extend({title:"",mode:"normal",description:"",next:"Next",prev:"Previous",retry:"Retry",answer:"Turn",correctAnswer:"I got it right!",incorrectAnswer:"I got it wrong",round:"Round @round",cardsLeft:"Cards left: @number",nextRound:"Proceed to round @round",startOver:"Start over",showSummary:"Next",summary:"Summary",summaryCardsRight:"Cards you got right:",summaryCardsWrong:"Cards you got wrong:",summaryCardsNotShown:"Cards in pool not shown:",summaryOverallScore:"Overall Score",summaryCardsCompleted:"Cards you have completed learning:",summaryCompletedRounds:"Completed rounds:",summaryAllDone:"Well done! You have mastered all @cards cards by getting them correct @max times!",progressText:"Card @card of @total",cardFrontLabel:"Card front",cardBackLabel:"Card back",tipButtonLabel:"Show tip",audioNotSupported:"Your browser does not support this audio",confirmStartingOver:{header:"Start over?",body:"All progress will be lost. Are you sure you want to start over?",cancelLabel:"Cancel",confirmLabel:"Start over"},dialogs:[{text:"Horse",answer:"Hest"},{text:"Cow",answer:"Ku"}],behaviour:{enableRetry:!0,disableBackwardsNavigation:!1,scaleTextNotCard:!1,randomCards:!1,maxProficiency:5,quickProgression:!1}},e),s.cards=[],s.currentCardId=0,s.round=0,s.results=s.previousState.results||[],s.attach=function(r){s.$inner=r.addClass("h5p-dialogcards"),s.params.behaviour.scaleTextNotCard&&r.addClass("h5p-text-scaling");var e={mode:s.params.mode,dialogs:s.params.dialogs,audioNotSupported:s.params.audioNotSupported,answer:s.params.answer,showSummary:s.params.showSummary,incorrectAnswer:s.params.incorrectAnswer,correctAnswer:s.params.correctAnswer,progressText:s.params.progressText,tipButtonLabel:s.params.tipButtonLabel,behaviour:{scaleTextNotCard:s.params.behaviour.scaleTextNotCard,maxProficiency:s.params.behaviour.maxProficiency,quickProgression:s.params.behaviour.quickProgression},cardPiles:s.previousState.cardPiles};s.cardManager=new c(e,s.id,{onCardTurned:s.handleCardTurned,onNextCard:s.nextCard},s.idCounter),s.createDOM(0===s.round),void 0!==s.previousState.currentCardId&&(s.gotoCard(s.previousState.currentCardId),"repetition"===s.params.mode&&s.results.length===s.cardIds.length&&s.showSummary(!0)),s.updateNavigation(),s.trigger("resize")},s.createDOM=function(r){if(s.cardIds=r&&s.previousState.cardIds?s.previousState.cardIds:s.cardManager.createSelection(),s.cardPoolSize=s.cardPoolSize||s.cardManager.getSize(),!0===r){var e=p("<div>"+s.params.title+"</div>").text().trim();s.$header=p((e?'<div class="h5p-dialogcards-title"><div class="h5p-dialogcards-title-inner">'+s.params.title+"</div></div>":"")+'<div class="h5p-dialogcards-description">'+s.params.description+"</div>"),s.summaryScreen=new l(s.params,{nextRound:s.nextRound,retry:s.restartRepetition})}!0===r?s.$cardwrapperSet=s.initCards(s.cardIds):(s.$cardwrapperSet.detach(),s.$cardwrapperSet=s.initCards(s.cardIds),s.$cardSideAnnouncer.before(s.$cardwrapperSet)),s.$cardwrapperSet.prepend(s.summaryScreen.getDOM()),!0===r&&(s.$cardSideAnnouncer=p("<div>",{html:s.params.cardFrontLabel,class:"h5p-dialogcards-card-side-announcer","aria-live":"polite"}),s.$footer=s.createFooter(),s.$mainContent=p("<div>").append(s.$header).append(s.$cardwrapperSet).append(s.$cardSideAnnouncer).append(s.$footer).appendTo(s.$inner),s.on("reset",(function(){this.reset()})),s.on("resize",s.resize),s.round=void 0!==s.previousState.round?s.previousState.round:1)},s.createFooter=function(){var r=p("<nav>",{class:"h5p-dialogcards-footer",role:"navigation"}),e=function(r,e){p(r).append('<span class="button-tooltip">'+e+"</span>"),p(r).find(".button-tooltip").hide().fadeIn("fast")},t=function(r){p(r).find(".button-tooltip").remove()};if("normal"===s.params.mode){var a=u(s);s.$prev=g.createButton({class:"h5p-dialogcards-footer-button h5p-dialogcards-prev truncated","aria-label":s.params.prev}).click((function(){s.prevCard()})).appendTo(r),s.$prev.hover((function(r){e(a.$prev,a.params.prev)}),(function(){t(a.$prev)})),s.$next=g.createButton({class:"h5p-dialogcards-footer-button h5p-dialogcards-next truncated","aria-label":s.params.next}).click((function(){s.nextCard()})).appendTo(r),s.$next.hover((function(r){e(a.$next,a.params.next)}),(function(){t(a.$next)})),s.$retry=g.createButton({class:"h5p-dialogcards-footer-button h5p-dialogcards-retry h5p-dialogcards-disabled",html:s.params.retry}).click((function(){s.trigger("reset")})).appendTo(r),s.$retry.hover((function(r){e(a.$retry,a.params.retry)}),(function(){t(a.$retry)})),s.$progress=p("<div>",{id:"h5p-dialogcards-progress-"+s.idCounter,class:"h5p-dialogcards-progress","aria-live":"assertive"}).appendTo(r)}else s.$round=p("<div>",{class:"h5p-dialogcards-round"}).appendTo(r),s.$progress=p("<div>",{class:"h5p-dialogcards-cards-left","aria-live":"assertive"}).appendTo(r);return r},s.updateImageSize=function(){var r=0,e=s.cards[s.currentCardId].getDOM().find(".h5p-dialogcards-card-content");if(s.params.dialogs.forEach((function(t){if(t.image){var a=t.image.height/t.image.width*e.get(0).getBoundingClientRect().width;a>r&&(r=a)}})),r>0){var t=r/parseFloat(s.$inner.css("font-size"));t>15&&(t=15),s.cards.forEach((function(r){r.getImage().parent().css("height",t+"em")}))}},s.initCards=function(r){s.cards=[],s.currentCardId=0,s.params.behaviour.randomCards&&(r=H5P.shuffleArray(r));for(var e=p("<div>",{class:"h5p-dialogcards-cardwrap-set"}),t=0;t<r.length&&!(t>=2);t++){var a=s.getCard(r[t]);a.setProgressText(t+1,r.length),s.cards.push(a);var i=a.getDOM();t===s.currentCardId&&(i.addClass("h5p-dialogcards-current"),s.$current=i),a.addTipToCard(i.find(".h5p-dialogcards-card-content"),"front",t),e.append(i)}return e},s.handleCardTurned=function(r){s.$cardSideAnnouncer.html(r?s.params.cardFrontLabel:s.params.cardBackLabel),s.params.behaviour.enableRetry&&s.currentCardId+1===s.cardIds.length&&s.$retry&&(s.$retry.removeClass("h5p-dialogcards-disabled"),s.truncateRetryButton())},s.updateNavigation=function(){if("normal"===s.params.mode)s.getCurrentSelectionIndex()<s.cardIds.length-1?(s.$next.removeClass("h5p-dialogcards-disabled"),s.$retry.addClass("h5p-dialogcards-disabled")):s.$next.addClass("h5p-dialogcards-disabled"),s.currentCardId>0&&!s.params.behaviour.disableBackwardsNavigation?s.$prev.removeClass("h5p-dialogcards-disabled"):s.$prev.addClass("h5p-dialogcards-disabled"),s.$progress.text(s.params.progressText.replace("@card",s.getCurrentSelectionIndex()+1).replace("@total",s.cardIds.length)),s.cards[s.findCardPosition(s.cards[s.currentCardId].id)].resizeOverflowingText();else{s.$round.text(s.params.round.replace("@round",s.round));var r=s.getCurrentSelectionIndex();s.$progress.text(s.params.cardsLeft.replace("@number",s.cardIds.length-r))}s.trigger("resize")},s.showSummary=function(){var r=arguments.length>0&&void 0!==arguments[0]&&arguments[0]?s.cardManager.getPileSizes():s.cardManager.updatePiles(s.results),e=s.results.filter((function(r){return!0===r.result})).length,t=s.results.length-e,a=s.cardPoolSize-e-t,i=r.slice(-1)[0],n=i===s.cardPoolSize,o={round:s.round,results:[{field:"h5p-dialogcards-round-cards-right",score:{value:e,max:t+e}},{field:"h5p-dialogcards-round-cards-wrong",score:{value:t,max:t+e}},{field:"h5p-dialogcards-round-cards-not-shown",score:{value:a}},{field:"h5p-dialogcards-overall-cards-completed",score:{value:i,max:s.cardPoolSize}},{field:"h5p-dialogcards-overall-completed-rounds",score:{value:s.round}}]};n&&(o.done=!0,o.message=s.params.summaryAllDone.replace("@cards",s.cardPoolSize).replace("@max",s.params.behaviour.maxProficiency)),s.summaryScreen.update(o),s.summaryScreen.show(),s.hideCards(),s.trigger("resize")},s.showCards=function(){s.$cardwrapperSet.find(".h5p-dialogcards-cardwrap").removeClass("h5p-dialogcards-gone"),s.$footer.removeClass("h5p-dialogcards-gone"),s.cardsShown=!0},s.hideCards=function(){s.$cardwrapperSet.find(".h5p-dialogcards-cardwrap").addClass("h5p-dialogcards-gone"),s.$footer.addClass("h5p-dialogcards-gone"),s.cardsShown=!1},s.nextCard=function(r){void 0!==r&&s.results.push(r),s.cards[s.currentCardId].stopAudio(),s.cardIds.length-s.getCurrentSelectionIndex()!=1?s.gotoCard(s.getCurrentSelectionIndex()+1):"repetition"===s.params.mode&&(s.$progress.text(s.params.cardsLeft.replace("@number",0)),s.cards[s.currentCardId].showSummaryButton(s.showSummary))},s.getCard=function(r){var e=s.cardManager.getCard(r);return e.createButtonListeners(),e},s.findCardPosition=function(r){var e;return s.cards.forEach((function(t,a){e||t.id!==r||(e=a)})),e},s.insertCardToDOM=function(r,e){var t=r.getDOM();void 0===e?t.appendTo(s.$cardwrapperSet):0===e?s.$cardwrapperSet.prepend(t):s.$cardwrapperSet.children().eq(e).after(t),r.addTipToCard(t.find(".h5p-dialogcards-card-content"),"front",e)},s.gotoCard=function(r){if(!(r<0||r>=s.cardIds.length)){var e=s.cards[s.currentCardId];e.stopAudio(),e.getDOM().removeClass("h5p-dialogcards-current");var t=[];r>0&&t.push(r-1),t.push(r),r+1<s.cardIds.length&&t.push(r+1),t.forEach((function(r){if(void 0===s.findCardPosition(s.cardIds[r])){var e=s.getCard(s.cardIds[r]);e.setProgressText(r+1,s.cardIds.length);var t=Math.min(r+1,s.cardIds.length-1),a=s.findCardPosition(s.cardIds[t])||s.cards.length;s.cards.splice(a,0,e),s.insertCardToDOM(e,a)}})),s.resize(),r=s.findCardPosition(s.cardIds[r]),s.cards.forEach((function(e,t){t<r?e.getDOM().addClass("h5p-dialogcards-previous"):(e.getDOM().removeClass("h5p-dialogcards-previous"),t===r&&e.getDOM().addClass("h5p-dialogcards-current"))})),s.currentCardId=r,s.updateNavigation(),s.cards[s.currentCardId].setCardFocus()}},s.prevCard=function(){s.gotoCard(s.getCurrentSelectionIndex()-1)},s.showAllAudio=function(){s.$cardwrapperSet.find(".h5p-audio-inner").removeClass("hide")},s.restartRepetition=function(){s.cardManager.reset(),s.round=0,s.nextRound()},s.nextRound=function(){var r=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];s.round++,s.summaryScreen.hide(),s.showCards(),s.reset(),s.createDOM(),s.updateNavigation(),(s.isRoot()||r)&&s.cards[s.currentCardId].setCardFocus(!0),s.trigger("resize")},s.reset=function(){s.results=[],s.cards[s.currentCardId].stopAudio(s.$current.index()),s.cards.forEach((function(r){r.reset()})),s.currentCardId=0,"normal"===s.params.mode&&s.cards[s.currentCardId].getDOM().addClass("h5p-dialogcards-current"),s.updateNavigation(),s.$retry&&s.$retry.addClass("h5p-dialogcards-disabled"),s.showAllAudio(),s.cards[s.currentCardId].resizeOverflowingText(),s.cards[s.currentCardId].setCardFocus()},s.resize=function(){if(s.cards[s.currentCardId].isInTransition||s.resizeTimeout)s.resizeTimeout=setTimeout((function(){delete s.resizeTimeout,s.resize()}),400);else{var r=0;s.updateImageSize(),s.params.behaviour.scaleTextNotCard||!1===s.cardsShown||s.determineCardSizes(),s.$cardwrapperSet.css("height","auto"),s.$cardwrapperSet.children(":not(.h5p-dialogcards-gone)").each((function(){var e=p(this).css("height","initial").outerHeight();if(p(this).css("height","inherit"),r=e>r?e:r,!p(this).next(".h5p-dialogcards-cardwrap").length){var t=p(this).find(".h5p-dialogcards-cardholder").css("height","initial").outerHeight();r=t>r?t:r,p(this).find(".h5p-dialogcards-cardholder").css("height","inherit")}}));var e=r/parseFloat(s.$cardwrapperSet.css("font-size"));s.$cardwrapperSet.css("height",e+"em"),s.scaleToFitHeight(),s.truncateRetryButton(),s.cards[s.currentCardId].resizeOverflowingText()}},s.determineCardSizes=function(){var r=u(s);void 0===s.cardSizeDetermined&&(s.cardSizeDetermined=[]),s.$cardwrapperSet.children(":visible").each((function(e){var t=r.cards[e].id;if(-1===r.cardSizeDetermined.indexOf(t)){r.cardSizeDetermined.push(t);var a=p(".h5p-dialogcards-card-content",this),i=p(".h5p-dialogcards-card-text-inner-content",a),s=i[0].getBoundingClientRect().height,n=r.cards[e];n.changeText(n.getAnswer());var o=i[0].getBoundingClientRect().height,d=s>o?s:o,c=parseFloat(i.parent().parent().css("minHeight"));d<c&&(d=c),d/=parseFloat(a.css("fontSize")),i.parent().css("height",d+"em"),n.changeText(n.getText())}}))},s.scaleToFitHeight=function(){if(s.$cardwrapperSet&&s.$cardwrapperSet.is(":visible")&&s.params.behaviour.scaleTextNotCard)if(s.$inner.parents(".h5p-course-presentation").length){var r=s.$inner.parent();s.$inner.parents(".h5p-popup-container").length&&(r=s.$inner.parents(".h5p-popup-container"));var e=r.get(0).getBoundingClientRect().height,t=function(){var r=0;return s.$inner.children().each((function(){var e=p(this);r+=this.getBoundingClientRect().height+parseFloat(e.css("margin-top"))+parseFloat(e.css("margin-bottom"))})),r},i=t(),n=parseFloat(s.$inner.parent().css("font-size")),o=parseFloat(s.$inner.css("font-size"));if(e<i)for(;e<i&&!((o-=a.SCALEINTERVAL)<a.MINSCALE);)s.$inner.css("font-size",o/n+"em"),i=t();else for(var d=!0;d;){if((o+=a.SCALEINTERVAL)>a.MAXSCALE){d=!1;break}var c=o/n;s.$inner.css("font-size",c+"em"),e<=(i=t())&&(d=!1,c=(o-a.SCALEINTERVAL)/n,s.$inner.css("font-size",c+"em"))}}else s.cards[s.currentCardId].resizeOverflowingText()},s.truncateRetryButton=function(){if(s.$retry){s.$retry.removeClass("truncated"),s.$retry.html(s.params.retry);(s.$retry.get(0).getBoundingClientRect().width+parseFloat(s.$retry.css("margin-left"))+parseFloat(s.$retry.css("margin-right")))/s.$retry.parent().get(0).getBoundingClientRect().width>.3&&(s.$retry.addClass("truncated"),s.$retry.html(""))}},s.getCurrentSelectionIndex=function(){return s.cardIds.indexOf(s.cards[s.currentCardId].id)},s.getTitle=function(){return H5P.createTitle(s.contentData&&s.contentData.metadata&&s.contentData.metadata.title?s.contentData.metadata.title:"Dialog Cards")},s.getCurrentState=function(){if(s.cardManager)return s.isProgressStarted()?{cardPiles:s.cardManager.getPiles(),cardIds:s.cardIds,round:s.round,currentCardId:s.getCurrentSelectionIndex(),results:s.results}:void 0},s.isProgressStarted=function(){return!H5P.isEmpty(s.previousState)||0!==s.getCurrentSelectionIndex()||0!==s.results.length||1!==s.round},s.resetTask=function(){var r=arguments.length>0&&void 0!==arguments[0]&&arguments[0];s.cardManager&&(s.previousState={},s.round=0,s.nextRound(r))},s}return t=r,(e=a).prototype=Object.create(t.prototype),e.prototype.constructor=e,h(e,t),a}(H5P.EventDispatcher);m.idCounter=0,m.SCALEINTERVAL=.2,m.MAXSCALE=16,m.MINSCALE=4;const f=m;H5P.Dialogcards=f})();
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists