!function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=11)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=t.curry=function(e){var t=e.length;return function n(){var r=Array.prototype.slice.call(arguments,0);return r.length>=t?e.apply(null,r):function(){var e=Array.prototype.slice.call(arguments,0);return n.apply(null,r.concat(e))}}},o=(t.compose=function(){for(var e=arguments.length,t=Array(e),n=0;n=t?e.apply(null,r):function(){var e=Array.prototype.slice.call(arguments,0);return n.apply(null,r.concat(e))}}},o=function(e,t){return t.substr(0,1)===e},a=function(e,t){return t.substr(-1)===e},i=r(function(e,t){return o(e,t)&&(t=t.slice(1)),a(e,t)&&(t=t.slice(0,-1)),t}),s=function(e){for(var t=e.length;t>0;){var n=Math.floor(Math.random()*t);t--;var r=e[t];e[t]=e[n],e[n]=r}return e},l=function(e){var t=document.createElement("span");return t.innerHTML=e,t};t.default={curry:r,cleanCharacter:i,startsWith:o,endsWith:a,shuffle:s,createElementWithTextPart:l}},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var o=n(14),a=n(15),i=r(a),s=n(2),l=r(s),c=n(12),u=r(c),d=n(13),h=r(d),p=n(7),g=r(p),b=n(5),f=r(b),m=n(6),v=r(m),y=n(9),D=r(y),E=n(10),w=r(E);H5P.DragText=function(e,t,n){function r(n,r,o){var a=this;this.$=e(this),this.contentId=r,this.contentData=o,t.call(this,"drag-text"),this.params=e.extend(!0,{taskDescription:"Set in adjectives in the following sentence",textField:"This is a *nice*, *flexible* content type, which allows you to highlight all the *wonderful* words in this *exciting* sentence.\nThis is another line of *fantastic* text.",overallFeedback:[],checkAnswer:"Check",tryAgain:"Retry",behaviour:{enableRetry:!0,enableSolutionsButton:!0,enableCheckButton:!0,instantFeedback:!1},showSolution:"Show solution",dropZoneIndex:"Drop Zone @index.",empty:"Empty.",contains:"Drop Zone @index contains draggable @draggable.",ariaDraggableIndex:"@index of @count.",tipLabel:"Show tip",correctText:"Correct!",incorrectText:"Incorrect!",resetDropTitle:"Reset drop",resetDropDescription:"Are you sure you want to reset this drop zone?",grabbed:"Draggable is grabbed.",cancelledDragging:"Cancelled dragging.",correctAnswer:"Correct answer:",scoreBarLabel:"You got :num out of :total points"},n),this.contentData=o,void 0!==this.contentData&&void 0!==this.contentData.previousState&&void 0!==this.contentData.previousState.length&&(this.previousState=this.contentData.previousState),this.answered=!1,this.instantFeedbackEvaluationFilled=!1,this.textFieldHtml=this.params.textField.replace(/(\r\n|\n|\r)/gm,"
"),this.introductionId="h5p-drag-text-"+r+"-introduction",this.selectedElement=void 0,this.ariaDragControls=new f.default,this.ariaDropControls=new v.default,this.dragControls=new g.default([new D.default,new w.default,this.ariaDragControls]),this.dragControls.useNegativeTabIndex(),this.dropControls=new g.default([new D.default,new w.default,this.ariaDropControls]),this.dropControls.useNegativeTabIndex(),this.dragControls.on("before-select",function(e){return!a.isElementDisabled(e.element)}),this.dragControls.on("select",this.keyboardDraggableSelected,this),this.dropControls.on("select",this.keyboardDroppableSelected,this),this.on("start",this.addAllDroppablesToControls,this),this.on("revert",this.removeControlsFromEmptyDropZones,this),this.on("stop",function(e){e.data.target||a.removeControlsFromDropZonesIfAllEmpty()},this),this.on("drop",this.removeControlsFromEmptyDropZones,this),this.on("start",function(e){var t=e.data.element,n=a.getDraggableByElement(t);a.toggleDropEffect(),t.setAttribute("aria-grabbed","true"),a.setDraggableAriaLabel(n)}),this.on("stop",function(e){var t=e.data.element,n=a.getDraggableByElement(t);a.toggleDropEffect(),t.setAttribute("aria-grabbed","false"),a.setDraggableAriaLabel(n)}),this.on("drop",this.ariaDropControls.setAllToNone,this.ariaDropControls),this.on("drop",function(e){this.dragControls.removeElement(e.data.element)},this),this.on("revert",function(e){this.dragControls.insertElementAt(e.data.element,0)},this),this.on("drop",this.updateDroppableElement,this),this.on("revert",this.updateDroppableElement,this),this.initDragText(),this.stopWatch=new i.default,this.stopWatch.start(),this.on("resize",this.resize,this),this.on("revert",this.toggleDraggablesContainer,this),this.on("drop",this.toggleDraggablesContainer,this),this.on("stop",function(e){e.data.target||a.read(a.params.cancelledDragging)}),this.params.behaviour.instantFeedback&&this.on("revert",function(){return a.instantFeedbackEvaluation()})}return r.prototype=Object.create(t.prototype),r.prototype.constructor=r,r.prototype.updateDroppableElement=function(e){var t=e.data.target,n=e.data.element,r=this.getDroppableByElement(t);t&&this.setDroppableLabel(t,n.textContent,r.getIndex())},r.prototype.removeControlsFromDropZonesIfAllEmpty=function(){this.anyDropZoneHasDraggable()||this.removeAllDroppablesFromControls()},r.prototype.removeControlsFromEmptyDropZones=function(){var e=this;this.droppables.filter(function(e){return!e.hasDraggable()}).map(function(e){return e.getElement()}).forEach(function(t){e.dropControls.removeElement(t)})},r.prototype.addAllDroppablesToControls=function(){var e=this;this.dropControls.count()>0&&this.removeAllDroppablesFromControls(),this.droppables.map(function(e){return e.getElement()}).forEach(function(t){return e.dropControls.addElement(t)})},r.prototype.removeAllDroppablesFromControls=function(){var e=this;this.droppables.map(function(e){return e.getElement()}).forEach(function(t){return e.dropControls.removeElement(t)})},r.prototype.anyDropZoneHasDraggable=function(){return this.droppables.some(function(e){return e.hasDraggable()})},r.prototype.setDroppableLabel=function(e,t,n){var r=this.params.dropZoneIndex.replace("@index",n.toString()),o=e.classList.contains("h5p-drag-correct-feedback"),a=e.classList.contains("h5p-drag-wrong-feedback"),i=o||a,s=e.childNodes.length>0;if(e)if(i){var l=this.getDroppableByElement(e),c="";c=o?l.correctFeedback?l.correctFeedback:this.params.correctText:l.incorrectFeedback?l.incorrectFeedback:this.params.incorrectText,e.setAttribute("aria-label",r+" "+this.params.contains.replace("@index",n.toString()).replace("@draggable",t)+" "+c+".")}else s?e.setAttribute("aria-label",r+" "+this.params.contains.replace("@index",n.toString()).replace("@draggable",t)):e.setAttribute("aria-label",r+" "+this.params.empty.replace("@index",n.toString()))},r.prototype.registerDomElements=function(){this.$introduction=e('

'+this.params.taskDescription+"

"),this.setIntroduction(this.$introduction),this.$introduction.parent().attr("tabindex","-1"),this.setContent(this.$inner),this.addButtons()},r.prototype.initDragText=function(){return this.$inner=e("
",{"aria-describedby":this.introductionId,class:"h5p-drag-inner"}),this.addTaskTo(this.$inner),this.setH5PUserState(),this.$inner},r.prototype.resize=function(){this.changeLayoutToFitWidth()},r.prototype.changeLayoutToFitWidth=function(){var e=this;e.addDropzoneWidth(),e.$inner.width()/parseFloat(e.$inner.css("font-size"),10)>43&&e.widestDraggable<=e.$inner.width()/3?(e.$draggables.addClass("h5p-drag-wide-screen"),e.$wordContainer.detach().appendTo(e.$taskContainer),e.draggables.forEach(function(e){e.getDraggableElement().addClass("h5p-drag-draggable-wide-screen")}),e.$wordContainer.css({"margin-right":e.$draggables.width()})):(e.$wordContainer.css({"margin-right":0}),e.$draggables.removeClass("h5p-drag-wide-screen"),e.$draggables.detach().appendTo(e.$taskContainer),e.draggables.forEach(function(e){e.getDraggableElement().removeClass("h5p-drag-draggable-wide-screen")}))},r.prototype.addButtons=function(){var e=this;e.params.behaviour.enableCheckButton&&e.addButton("check-answer",e.params.checkAnswer,function(){e.answered=!0,e.removeAllElementsFromDragControl(),e.showEvaluation()?(e.hideButton("show-solution"),e.hideButton("try-again"),e.hideButton("check-answer")):(e.params.behaviour.enableRetry&&e.showButton("try-again"),e.params.behaviour.enableSolutionsButton&&e.showButton("show-solution"),e.hideButton("check-answer"),e.disableDraggables()),e.$introduction.parent().focus()},!e.params.behaviour.instantFeedback),e.addButton("show-solution",e.params.showSolution,function(){e.droppables.forEach(function(e){e.showSolution()}),e.draggables.forEach(function(t){return e.setDraggableAriaLabel(t)}),e.disableDraggables(),e.removeAllDroppablesFromControls(),e.hideButton("show-solution")},e.initShowShowSolutionButton||!1),e.addButton("try-again",e.params.tryAgain,function(){e.answered&&e.resetDraggables(),e.answered=!1,e.hideEvaluation(),e.hideExplanation(),e.hideButton("try-again"),e.hideButton("show-solution"),e.params.behaviour.instantFeedback?e.enableAllDropzonesAndDraggables():(e.showButton("check-answer"),e.enableDraggables()),e.hideAllSolutions(),e.stopWatch.reset(),e.read(e.params.taskDescription)},e.initShowTryAgainButton||!1)},r.prototype.removeAllElementsFromDragControl=function(){var e=this;this.dragControls.elements.forEach(function(t){return e.dragControls.removeElement(t)})},r.prototype.keyboardDraggableSelected=function(e){var t=this.selectedElement,n=void 0!==this.selectedElement,r=this.selectedElement===e.element;n&&(this.selectedElement=void 0,this.trigger("stop",{element:t})),n&&r||this.isElementDisabled(e.element)||(this.selectedElement=e.element,this.trigger("start",{element:e.element}),this.focusOnFirstEmptyDropZone())},r.prototype.focusOnFirstEmptyDropZone=function(){var e=this.droppables.filter(function(e){return!e.hasDraggable()})[0],t=e.getElement();this.dropControls.setTabbable(t),t.focus()},r.prototype.isElementDisabled=function(e){return"true"===e.getAttribute("aria-disabled")},r.prototype.keyboardDroppableSelected=function(e){var t=this,n=e.element,r=t.getDroppableByElement(n),o=t.getDraggableByElement(this.selectedElement),a=this.params.behaviour.instantFeedback&&r&&r.isCorrect(),i=!this.params.behaviour.instantFeedback&&r.hasFeedback();if(o&&r&&!a){var s=t.selectedElement;t.drop(o,r),t.selectedElement=void 0,this.trigger("stop",{element:s,target:r.getElement()})}else if(r&&r.hasDraggable()&&!i&&!a){var l=n.querySelector("[aria-grabbed]");this.createConfirmResetDialog(function(){t.revert(t.getDraggableByElement(l))}).show()}},r.prototype.toggleDraggablesContainer=function(){var e=0===this.$draggables.children().length;this.$draggables.toggleClass("hide",e)},r.prototype.createConfirmResetDialog=function(e,t){var r=this,o=new n({headerText:r.params.resetDropTitle,dialogText:r.params.resetDropDescription});return o.appendTo(document.body),o.on("confirmed",e,t||this),o},r.prototype.showDropzoneFeedback=function(){var e=this;this.droppables.forEach(function(t){t.addFeedback();var n=t.containedDraggable;t&&n&&(e.setDroppableLabel(t.getElement(),n.getElement().textContent,t.getIndex()),e.setDraggableAriaLabel(n))})},r.prototype.showExplanation=function(){var e=this,t=[];this.droppables.forEach(function(e){var n=e.containedDraggable;e&&n&&(e.isCorrect()&&e.correctFeedback&&t.push({correct:n.text,text:e.correctFeedback}),!e.isCorrect()&&e.incorrectFeedback&&t.push({correct:e.text,wrong:n.text,text:e.incorrectFeedback}))}),0!==t.length&&this.setExplanation(t,e.params.feedbackHeader)},r.prototype.showEvaluation=function(e){this.hideEvaluation(),this.showDropzoneFeedback(),this.showExplanation();var t=this.calculateScore(),n=this.droppables.length;if(!e){var r=this.createXAPIEventTemplate("answered");this.addQuestionToXAPI(r),this.addResponseToXAPI(r),this.trigger(r)}var o=H5P.Question.determineOverallFeedback(this.params.overallFeedback,t/n).replace(/@score/g,t.toString()).replace(/@total/g,n.toString());return t===n&&(this.hideButton("check-answer"),this.hideButton("show-solution"),this.hideButton("try-again"),this.disableDraggables()),this.trigger("resize"),this.setFeedback(o,t,n,this.params.scoreBarLabel),t===n},r.prototype.calculateScore=function(){return this.droppables.reduce(function(e,t){return e+(t.isCorrect()?1:0)},0)},r.prototype.hideEvaluation=function(){this.removeFeedback(),this.trigger("resize")},r.prototype.hideExplanation=function(){this.setExplanation(),this.trigger("resize")},r.prototype.hideAllSolutions=function(){this.droppables.forEach(function(e){e.hideSolution()}),this.trigger("resize")},r.prototype.addTaskTo=function(t){var n=this;n.widest=0,n.widestDraggable=0,n.droppables=[],n.draggables=[],n.$taskContainer=e("
",{class:"h5p-drag-task"}),n.$draggables=e("
",{class:"h5p-drag-draggables-container"}),n.$wordContainer=e("
",{class:"h5p-drag-droppable-words"}),(0,o.parseText)(n.textFieldHtml).forEach(function(e){if(n.isAnswerPart(e)){var t=(0,o.lex)(e),r=n.createDraggable(t.text),a=n.createDroppable(t.text,t.tip,t.correctFeedback,t.incorrectFeedback);n.params.behaviour.instantFeedback&&r.getDraggableElement().on("dragstop",function(){a.addFeedback(),n.instantFeedbackEvaluation()})}else{var i=l.default.createElementWithTextPart(e);n.$wordContainer.append(i)}}),n.shuffleAndAddDraggables(n.$draggables),n.$draggables.appendTo(n.$taskContainer),n.$wordContainer.appendTo(n.$taskContainer),n.$taskContainer.appendTo(t),n.addDropzoneWidth()},r.prototype.isAnswerPart=function(e){return l.default.startsWith("*",e)&&l.default.endsWith("*",e)},r.prototype.addDropzoneWidth=function(){var e=this,t=0,n=0,r=parseInt(this.$inner.css("font-size"),10),o=3*r,a=r;this.draggables.forEach(function(e){var r=e.getDraggableElement(),o=r.clone().css({position:"absolute","white-space":"nowrap",width:"auto",padding:0,margin:0}).html(e.getAnswerText()).appendTo(r.parent()),i=o.outerWidth();n=i>n?i:n,o.text().length>=20&&(o.html(e.getShortFormat()),i=o.width()),i+a>t&&(t=i+a),o.remove()}),t",{html:""+t+"",role:"button","aria-grabbed":"false",tabindex:"-1"}).draggable({revert:function(e){return e||n.revert(o),!1},drag:n.propagateDragEvent("drag",n),start:n.propagateDragEvent("start",n),stop:function(e){n.trigger("stop",{element:o.getElement(),target:e.target})},containment:n.$taskContainer}).append(e("",{class:"h5p-hidden-read"})),o=new u.default(t,r,n.draggables.length);return o.on("addedToZone",function(){n.triggerXAPI("interacted")}),n.draggables.push(o),o},r.prototype.createDroppable=function(t,n,r,o){var a=this,i=this.draggables.length,s=e("
",{class:"h5p-drag-dropzone-container"}),l=e("
",{"aria-dropeffect":"none","aria-label":this.params.dropZoneIndex.replace("@index",i.toString())+" "+this.params.empty.replace("@index",i.toString()),tabindex:"-1"}).appendTo(s).droppable({tolerance:"pointer",drop:function(e,t){var n=a.getDraggableByElement(t.draggable[0]),r=a.getDroppableByElement(e.target);n&&r&&a.drop(n,r)}}),c=new h.default(t,n,r,o,l,s,i,a.params);return c.appendDroppableTo(a.$wordContainer),a.droppables.push(c),c},r.prototype.propagateDragEvent=l.default.curry(function(e,t,n){t.trigger(e,{element:n.target})}),r.prototype.revert=function(e){var t=e.removeFromZone(),n=t?t.getElement():void 0;e.revertDraggableTo(this.$draggables),this.setDraggableAriaLabel(e),this.trigger("revert",{element:e.getElement(),target:n}),this.trigger("resize")},r.prototype.drop=function(e,t){var n=this;n.answered=!0,e.removeFromZone();var r=t.appendInsideDroppableTo(this.$draggables);r&&n.trigger("revert",{element:r.getElement(),target:t.getElement()}),t.setDraggable(e),e.appendDraggableTo(t.getDropzone()),n.params.behaviour.instantFeedback&&(t.addFeedback(),n.instantFeedbackEvaluation(),n.params.behaviour.enableRetry&&!t.isCorrect()||t.disableDropzoneAndContainedDraggable()),this.trigger("drop",{element:e.getElement(),target:t.getElement()}),this.trigger("resize"),t.getElement().focus()},r.prototype.shuffleAndAddDraggables=function(e){var t=this;return l.default.shuffle(this.draggables).map(function(e,t){return e.setIndex(t)}).map(function(n){return t.addDraggableToContainer(e,n)}).map(function(e){return t.setDraggableAriaLabel(e)}).map(function(e){return t.addDraggableToControls(t.dragControls,e)})},r.prototype.setDraggableAriaLabel=function(e){return e.updateAriaLabel(this.params.ariaDraggableIndex.replace("@index",(e.getIndex()+1).toString()).replace("@count",this.draggables.length.toString())),e},r.prototype.isGrabbed=function(e){return"true"===e.getAttribute("aria-grabbed")},r.prototype.addDraggableToContainer=function(e,t){return t.appendDraggableTo(e),t},r.prototype.addDraggableToControls=function(e,t){return e.addElement(t.getElement()),t},r.prototype.instantFeedbackEvaluation=function(){var e=this;e.isAllAnswersFilled()?(e.params.behaviour.enableSolutionsButton&&e.showButton("show-solution"),e.params.behaviour.enableRetry&&e.showButton("try-again"),e.showEvaluation(!e.instantFeedbackEvaluationFilled),e.instantFeedbackEvaluationFilled=!0):(e.instantFeedbackEvaluationFilled=!1,e.hideButton("try-again"),e.hideButton("show-solution"),e.hideEvaluation())},r.prototype.isAllAnswersFilled=function(){return this.draggables.every(function(e){return e.isInsideDropZone()})},r.prototype.enableAllDropzonesAndDraggables=function(){this.enableDraggables(),this.droppables.forEach(function(e){e.enableDropzone()})},r.prototype.disableDraggables=function(){this.draggables.forEach(function(e){e.disableDraggable()})},r.prototype.enableDraggables=function(){this.draggables.forEach(function(e){e.enableDraggable()})},r.prototype.getAnswerGiven=function(){return this.answered},r.prototype.getScore=function(){return this.calculateScore()},r.prototype.getMaxScore=function(){return this.droppables.length},r.prototype.getTitle=function(){return H5P.createTitle(this.contentData&&this.contentData.metadata&&this.contentData.metadata.title?this.contentData.metadata.title:"Drag the Words")},r.prototype.toggleDropEffect=function(){var e=void 0!==this.selectedElement;this.ariaDropControls[e?"setAllToMove":"setAllToNone"]()},r.prototype.getDraggableByElement=function(e){return this.draggables.filter(function(t){return t.$draggable.get(0)===e},this)[0]},r.prototype.getDroppableByElement=function(e){return this.droppables.filter(function(t){return t.$dropzone.get(0)===e},this)[0]},r.prototype.showSolutions=function(){this.showEvaluation(!0),this.droppables.forEach(function(e){e.addFeedback(),e.showSolution()}),this.removeAllDroppablesFromControls(),this.disableDraggables(),this.hideButton("try-again"),this.hideButton("show-solution"),this.hideButton("check-answer"),this.trigger("resize")},r.prototype.resetTask=function(){var e=this;e.answered=!1,e.instantFeedbackEvaluationFilled=!1,e.resetDraggables(),e.hideEvaluation(),e.enableAllDropzonesAndDraggables(),e.hideButton("try-again"),e.hideButton("show-solution"),e.params.behaviour.instantFeedback||e.showButton("check-answer"),e.hideAllSolutions(),this.trigger("resize")},r.prototype.resetDraggables=function(){l.default.shuffle(this.draggables).forEach(this.revert,this)},r.prototype.getCurrentState=function(){var e=this;if(void 0!==this.draggables)return this.draggables.filter(function(e){return null!==e.getInsideDropzone()}).map(function(t){return{draggable:t.getInitialIndex(),droppable:e.droppables.indexOf(t.getInsideDropzone())}})},r.prototype.setH5PUserState=function(){var e=this,t=this;void 0!==this.previousState&&(this.previousState.forEach(function(n){if(!t.isValidIndex(n.draggable)||!t.isValidIndex(n.droppable))throw new Error("Stored user state is invalid");var r=e.getDraggableByInitialIndex(n.draggable),o=t.droppables[n.droppable];t.drop(r,o),t.params.behaviour.instantFeedback&&(null!==o&&o.addFeedback(),o.isCorrect()&&o.disableDropzoneAndContainedDraggable())}),t.params.behaviour.instantFeedback&&t.isAllAnswersFilled()&&!t.showEvaluation()&&(t.params.behaviour.enableSolutionsButton&&(t.initShowShowSolutionButton=!0),t.params.behaviour.enableRetry&&(t.initShowTryAgainButton=!0)))},r.prototype.isValidIndex=function(e){return!isNaN(e)&&e=0},r.prototype.getDraggableByInitialIndex=function(e){return this.draggables.filter(function(t){return t.hasInitialIndex(e)})[0]},r.prototype.getXAPIData=function(){var e=this.createXAPIEventTemplate("answered");return this.addQuestionToXAPI(e),this.addResponseToXAPI(e),{statement:e.data.statement}},r.prototype.addQuestionToXAPI=function(t){var n=t.getVerifiedStatementValue(["object","definition"]);e.extend(n,this.getxAPIDefinition())},r.prototype.getxAPIDefinition=function(){var e={};e.interactionType="fill-in",e.type="http://adlnet.gov/expapi/activities/cmi.interaction";var t=this.textFieldHtml,n=this.params.taskDescription+"
";return e.description={"en-US":n+this.replaceSolutionsWithBlanks(t)},e.correctResponsesPattern=[this.getSolutionsFromQuestion(t)],e},r.prototype.addResponseToXAPI=function(e){var t,n=this,r=n.getScore(),o=n.droppables.length;e.setScoredResult(r,o,n);var a={min:0,raw:r,max:o,scaled:Math.round(r/o*1e4)/1e4};n.stopWatch&&(t="PT"+n.stopWatch.stop()+"S"),e.data.statement.result={response:n.getXAPIResponse(),score:a,duration:t,completion:!0}},r.prototype.getXAPIResponse=function(){return this.droppables.map(function(e){return e.hasDraggable()?e.containedDraggable.text:""}).join("[,]")},r.prototype.replaceSolutionsWithBlanks=function(e){var t=this;return(0,o.parseText)(e).map(function(e){return t.isAnswerPart(e)?"__________":e}).join("")},r.prototype.getSolutionsFromQuestion=function(e){return(0,o.parseText)(e).filter(this.isAnswerPart).map(function(e){return(0,o.lex)(e)}).map(function(e){return e.text}).join("[,]")},r}(H5P.jQuery,H5P.Question,H5P.ConfirmationDialog),t.default=H5P.DragText},function(e,t){},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var o=function(){function e(e,t){for(var n=0;n20&&(o.shortFormat=o.shortFormat.slice(0,17)+"...")}return t.prototype=Object.create(H5P.EventDispatcher.prototype),t.prototype.constructor=t,t.prototype.getIndex=function(){return this.index},t.prototype.setIndex=function(e){return this.index=e,this},t.prototype.getInitialIndex=function(){return this.initialIndex},t.prototype.hasInitialIndex=function(e){return this.initialIndex===e},t.prototype.appendDraggableTo=function(e){this.$draggable.detach().css({left:0,top:0}).appendTo(e)},t.prototype.revertDraggableTo=function(e){var t=this.$draggable.offset().left-e.offset().left,n=this.$draggable.offset().top-e.offset().top;this.$draggable.detach().prependTo(e).css({left:t,top:n}).animate({left:0,top:0})},t.prototype.toggleDroppedFeedback=function(e){e?this.$draggable.addClass("h5p-drag-dropped"):this.$draggable.removeClass("h5p-drag-dropped")},t.prototype.disableDraggable=function(){this.$draggable.draggable({disabled:!0})},t.prototype.enableDraggable=function(){this.$draggable.draggable({disabled:!1})},t.prototype.getDraggableElement=function(){return this.$draggable},t.prototype.updateAriaLabel=function(e){this.$ariaLabel.html(e)},t.prototype.getElement=function(){return this.$draggable.get(0)},t.prototype.removeFromZone=function(){var e=this.insideDropzone;return null!==this.insideDropzone&&(this.insideDropzone.removeFeedback(),this.insideDropzone.removeDraggable()),this.toggleDroppedFeedback(!1),this.removeShortFormat(),this.insideDropzone=null,e},t.prototype.addToZone=function(e){null!==this.insideDropzone&&this.insideDropzone.removeDraggable(),this.toggleDroppedFeedback(!0),this.insideDropzone=e,this.setShortFormat(),this.trigger("addedToZone")},t.prototype.getAnswerText=function(){return this.text},t.prototype.setShortFormat=function(){this.$draggable.html(this.shortFormat)},t.prototype.getShortFormat=function(){return this.shortFormat},t.prototype.removeShortFormat=function(){this.$draggable.html(this.text)},t.prototype.getInsideDropzone=function(){return this.insideDropzone},t.prototype.isInsideDropZone=function(){return!!this.insideDropzone},t}(H5P.jQuery),t.default=H5P.TextDraggable},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),H5P.TextDroppable=function(e){function t(t,r,o,a,i,s,l,c){var u=this;u.text=t,u.tip=r,u.correctFeedback=o,u.incorrectFeedback=a,u.index=l,u.params=c,u.containedDraggable=null,u.$dropzone=e(i),u.$dropzoneContainer=e(s),u.tip&&(u.$tip=H5P.JoubelUI.createTip(u.tip,{tipLabel:u.params.tipLabel,tabcontrol:!0}),u.$dropzoneContainer.append(u.$tip),u.$dropzone.focus(function(){return u.$tip.attr("tabindex","0")}),u.$dropzone.blur(function(){return u.removeTipTabIndexIfNoFocus()}),u.$tip.blur(function(){return u.removeTipTabIndexIfNoFocus()})),u.$incorrectText=e("
",{html:u.params.incorrectText+" "+u.params.correctAnswer,class:"correct-answer"}),u.$correctText=e("
",{html:u.params.correctText,class:"correct-answer"}),u.$showSolution=e("
",{class:n}).appendTo(u.$dropzoneContainer).hide()}var n="h5p-drag-show-solution-container",r="h5p-drag-correct-feedback",o="h5p-drag-wrong-feedback";return t.prototype.removeTipTabIndexIfNoFocus=function(){var e=this;setTimeout(function(){e.$dropzone.is(":focus")||e.$tip.is(":focus")||e.$tip.attr("tabindex","-1")},0)},t.prototype.showSolution=function(){var e=null!==this.containedDraggable&&this.containedDraggable.getAnswerText()===this.text;e||this.$showSolution.html(this.text),this.$showSolution.prepend(e?this.$correctText:this.$incorrectText),this.$showSolution.toggleClass("incorrect",!e),this.$showSolution.show()},t.prototype.hideSolution=function(){this.$showSolution.html(""),this.$showSolution.hide()},t.prototype.getElement=function(){return this.$dropzone.get(0)},t.prototype.appendDroppableTo=function(e){this.$dropzoneContainer.appendTo(e)},t.prototype.appendInsideDroppableTo=function(e){if(null!==this.containedDraggable)return this.containedDraggable.revertDraggableTo(e),this.containedDraggable},t.prototype.setDraggable=function(e){var t=this;t.containedDraggable!==e&&(null!==t.containedDraggable&&t.containedDraggable.removeFromZone(),t.containedDraggable=e,e.addToZone(t))},t.prototype.hasDraggable=function(){return!!this.containedDraggable},t.prototype.removeDraggable=function(){null!==this.containedDraggable&&(this.containedDraggable=null)},t.prototype.isCorrect=function(){return null!==this.containedDraggable&&this.containedDraggable.getAnswerText()===this.text},t.prototype.addFeedback=function(){this.isCorrect()?(this.$dropzone.removeClass(o).addClass(r),this.containedDraggable.getDraggableElement().removeClass("h5p-drag-draggable-wrong").addClass("h5p-drag-draggable-correct")):null===this.containedDraggable?this.$dropzone.removeClass(o).removeClass(r):(this.$dropzone.removeClass(r).addClass(o),null!==this.containedDraggable&&this.containedDraggable.getDraggableElement().addClass("h5p-drag-draggable-wrong").removeClass("h5p-drag-draggable-correct"))},t.prototype.removeFeedback=function(){this.$dropzone.removeClass(o).removeClass(r),null!==this.containedDraggable&&this.containedDraggable.getDraggableElement().removeClass("h5p-drag-draggable-wrong").removeClass("h5p-drag-draggable-correct")},t.prototype.hasFeedback=function(){return this.$dropzone.hasClass(o)||this.$dropzone.hasClass(r)},t.prototype.setShortFormat=function(){null!==this.containedDraggable&&this.containedDraggable.setShortFormat()},t.prototype.disableDropzoneAndContainedDraggable=function(){null!==this.containedDraggable&&this.containedDraggable.disableDraggable(),this.$dropzone.droppable({disabled:!0})},t.prototype.enableDropzone=function(){this.$dropzone.droppable({disabled:!1})},t.prototype.removeShortFormat=function(){null!==this.containedDraggable&&this.containedDraggable.removeShortFormat()},t.prototype.getDropzone=function(){return this.$dropzone},t.prototype.getIndex=function(){return this.index},t}(H5P.jQuery),t.default=H5P.TextDroppable},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.lex=t.parseText=void 0;var r=n(2),o=function(e){return e&&e.__esModule?e:{default:e}}(r),a=function(e){return e.split(/(\*.*?\*)/).filter(function(e){return e.length>0})},i=function(e){var t=e.match(/(:([^\\*]+))/g),n=e.match(/(\\\+([^\\*:]+))/g),r=e.match(/(\\\-([^\\*:]+))/g),a=o.default.cleanCharacter("*",e);return t&&(a=a.replace(t,""),t=t[0].replace(":",""),t=t.replace(/\s+$/,"")),n&&(a=a.replace(n,""),n=n[0].replace("\\+",""),n=n.replace(/\s+$/,"")),r&&(a=a.replace(r,""),r=r[0].replace("\\-",""),r=r.replace(/\s+$/,"")),a=a.replace(/\s+$/,""),{tip:t,correctFeedback:n,incorrectFeedback:r,text:a}};t.parseText=a,t.lex=i},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=r||{};r.DragText=r.DragText||{},r.DragText.StopWatch=function(){function e(){this.duration=0}return e.prototype.start=function(){return this.startTime=Date.now(),this},e.prototype.stop=function(){return this.duration=this.duration+Date.now()-this.startTime,this.passedTime()},e.prototype.reset=function(){this.duration=0,this.startTime=Date.now()},e.prototype.passedTime=function(){return Math.round(this.duration/10)/100},e}(),t.default=r.DragText.StopWatch}]);