text: /**
   * @license jq-cards-quiz v1.0.2
   * (c) 2018 Finsi, Inc.
   */
  
  !function(t,s){"object"==typeof exports&&"undefined"!=typeof module?s(exports,require("flip")):"function"==typeof define&&define.amd?define(["exports","flip"],s):s(t.jqCardsQuiz={})}(this,function(t){"use strict";var s;(s=t.CardsQuizEvents||(t.CardsQuizEvents={})).onCardFlip="cardsQuiz:cardFlip",s.onQuestionChange="cardsQuiz:questionChange",s.onEnd="cardsQuiz:end";var i=function(){function t(t){void 0===t&&(t={}),this.answersIds=[],this.answersValues=[],void 0!=t.element&&(this.element=t.element),void 0!=t.question&&(this.question=t.question),void 0!=t.answersIds&&(this.answersIds=t.answersIds),void 0!=t.answersValues&&(this.answersValues=t.answersValues),void 0!=t.isCorrect&&(this.isCorrect=t.isCorrect),void 0!=t.flipOptions&&(this.flipOptions=t.flipOptions),this.init()}return t.prototype.flip=function(){this.instance.flip()},t.prototype.unflip=function(){this.instance.unflip()},t.prototype.detachFlip=function(){this.element.off(".flip")},Object.defineProperty(t.prototype,"isFlipped",{get:function(){return this.instance.isFlipped},enumerable:!0,configurable:!0}),t.prototype.init=function(){this.element&&(this.detachFlip(),this.element.flip(this.flipOptions),this.instance=this.element.data("flipModel"))},t}(),e=function(){function s(){}return s.prototype.disable=function(){this._super(),this.element.addClass(this.options.classes.disabled),this.quizInstance.disable()},s.prototype.enable=function(){this._super(),this.element.removeClass(this.options.classes.disabled),this.quizInstance.enable()},s.prototype.activateCard=function(t){if(!this.options.disabled&&!this.isCardInTransition)if(void 0!=t){var s=this.cardsRegistry[t];s&&(this.isCardInTransition=!0,void 0!=this.currentCard&&this.currentCard!=s&&(this.currentCard.element.removeClass(this.options.classes.cardActive),void 0!=this.currentCard.answersIds&&0!=this.currentCard.answersIds.length||(this.quizInstance.goTo(null),this.currentCard.unflip())),void 0==this.currentCard||this.currentCard!=s?(this.currentCard=s,s.element.addClass(this.options.classes.cardActive),s.instance.isFlipped?this.quizInstance.goTo(t):s.flip()):this.isCardInTransition=!1)}else this.currentCard&&(this.isCardInTransition=!0,this.quizInstance.goTo(null),this.currentCard.element.removeClass(this.options.classes.cardActive),this.currentCard.unflip())},s.prototype._getCreateOptions=function(){return{namespace:"jq-cards-quiz",questionAttribute:"data-cq-question",classes:{root:"c-cards-quiz",disabled:"c-cards-quiz--disabled",quiz:"c-cards-quiz__quiz",cardsWrapper:"c-cards-quiz__cards",card:"c-cards-quiz__card",cardIsCorrect:"c-cards-quiz__card--correct",cardIsIncorrect:"c-cards-quiz__card--incorrect",cardActive:"c-cards-quiz__card--active"},selectors:{cardsWrapper:"[data-cq-cards]",card:"[data-cq-card]",quiz:"[data-cq-quiz]"},flip:{},jqQuiz:{}}},s.prototype._create=function(){this.element.addClass(this.options.classes.root),this._init(),this._assignEvents()},s.prototype._init=function(){this.cardsWrapper=this.element.find(this.options.selectors.cardsWrapper).addClass(this.options.classes.cardsWrapper),this.cards=this.cardsWrapper.find(this.options.selectors.card).addClass(this.options.classes.card),this.quiz=this.element.find(this.options.selectors.quiz).addClass(this.options.classes.quiz);var t=$.extend(!0,{},this.options.jqQuiz,{autoStart:!0,initialQuestion:null,autoGoNext:!1});this.quiz.jqQuiz(t),this.quizInstance=this.quiz.jqQuiz("instance"),this.cardsRegistry={};for(var s=0,e=this.cards.length;s<e;s++){var r=this.cards.eq(s),n=r.attr(this.options.questionAttribute);if(void 0==n)throw"[CardsQuizGame] The card must have a question";var a,o=this._getDataOptions(r,"flip");(o=Object.keys(this._getDataOptions(r,"flip")).length>0?o:this.options.flip).trigger="manual",a=new i({element:r,question:n,flipOptions:o}),this.cardsRegistry[n]=a}},s.prototype._onQuizChange=function(s,i,e,r,n,a){var o,c;this.currentCard.answersIds=a.options,this.currentCard.answersValues=a.optionsValues,this.currentCard.isCorrect=a.isCorrect,this.currentCard.isCorrect?(o=this.options.classes.cardIsCorrect,c=this.options.classes.cardIsIncorrect):(o=this.options.classes.cardIsIncorrect,c=this.options.classes.cardIsCorrect),this.currentCard.element.removeClass(c).addClass(o),this.element.triggerHandler(t.CardsQuizEvents.onQuestionChange,[{instance:this,card:this.currentCard,questionChange:{questionId:e,optionId:r,optionValue:n}}])},s.prototype._onQuizEnd=function(s,i,e){this.quizInstance.disable(),this.disable(),this.element.triggerHandler(t.CardsQuizEvents.onEnd,[{instance:this,calification:e}])},s.prototype._onCardClick=function(t){if(!this.options.disabled&&!this.isCardInTransition){var s=$(t.currentTarget).attr(this.options.questionAttribute);this.activateCard(s)}},s.prototype._assignEvents=function(){this.cardsWrapper.off("."+this.options.namespace),this.quiz.off("."+this.options.namespace),this.cardsWrapper.on("flip:done."+this.options.namespace,this.options.selectors.card,this._onCardFlip.bind(this)),this.cardsWrapper.on("click."+this.options.namespace,this.options.selectors.card,this._onCardClick.bind(this)),this.quiz.on($.ui.jqQuiz.prototype.ON_OPTION_CHANGE+"."+this.options.namespace,this._onQuizChange.bind(this)),this.quiz.on($.ui.jqQuiz.prototype.ON_END+"."+this.options.namespace,this._onQuizEnd.bind(this)),this.quiz.on($.ui.jqQuiz.prototype.ON_QUESTION_SHOW+"."+this.options.namespace,this._onQuestionShown.bind(this))},s.prototype._onQuestionShown=function(){this.isCardInTransition=!1},s.prototype._onCardFlip=function(s){var i=$(s.currentTarget).attr(this.options.questionAttribute),e=this.cardsRegistry[i];e&&e==this.currentCard&&this.quizInstance.goTo(i),this.element.triggerHandler(t.CardsQuizEvents.onCardFlip,[{instance:this,card:e}])},s.prototype._getDataOptions=function(t,s){var i=$(t).data(),e={};for(var r in i)if(-1!==r.search(s)){var n=r.replace(s,"");n=n.charAt(0).toLowerCase().concat(n.substring(1));var a=i[r];try{a=JSON.parse(a)}catch(t){}e[n]=a}return e},s}();if(Object.hasOwnProperty("getOwnPropertyDescriptors")){for(var r={},n=Object.getOwnPropertyNames(e.prototype),a=0,o=n.length;a<o;a++){var c=n[a];r[c]=Object.getOwnPropertyDescriptor(e.prototype,c).value}$.widget("ui.cardsQuiz",r)}else $.widget("ui.cardsQuiz",e.prototype);t.CardsQuizCardRegistry=i,t.CardsQuizGame=e,Object.defineProperty(t,"__esModule",{value:!0})});
  