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ExCN,EAAAA,EAAAA,cAAcC,EAAAA,EAAAA,oBAAoB,MAAO,CACxCpC,IAAK,EACL0C,OAAOC,EAAAA,EAAAA,gBAAgB,CAAE,gBAAgB,EAAM,eAAe,EAAMvB,OAAQA,EAAOI,SAClF,EACDoB,EAAAA,EAAAA,YAAYb,EAAKc,OAAQ,YACxB,IACN7B,EAAQT,6BACJ4B,EAAAA,EAAAA,cAAcW,EAAAA,EAAAA,aAAaC,EAAAA,WAAmB,CAC7C/C,IAAK,EACLgD,iBAAkBtB,EAA2BF,MAC7CyB,mBAAmB,GAClB,KAAM,EAAG,CAAC,uBACbC,EAAAA,EAAAA,oBAAoB,IAAI,IAC3B,GAAG,CAER,ICxGA,MAAMC,EAAc,EAEpB,O","sources":["webpack://beliefnet-frontend/./src/stores/Quiz.ts","webpack://beliefnet-frontend/./src/stores/TriviaQuiz.ts","webpack://beliefnet-frontend/./src/components/quiz/Trivia.vue?08ff","webpack://beliefnet-frontend/./src/components/quiz/Trivia.vue"],"sourcesContent":["import { defineStore } from 'pinia';\n\nexport const useQuizStore = defineStore('QuizStore', {\n    state: () => {\n        return {\n            emailSent: false,\n            emailSent2: false\n        };\n    },\n    getters: {\n        isEmailSent: (state) => state.emailSent,\n        isEmailSent2: (state) => state.emailSent2\n    },\n    actions: {\n        setEmailSent(sent: boolean) {\n            this.emailSent = sent;\n        },\n        setEmailSent2(sent: boolean) {\n            this.emailSent2 = sent;\n        }\n    }\n});\n","import { defineStore } from 'pinia';\n\nexport const useTriviaQuizStore = defineStore('TriviaQuiz', {\n    state: () => {\n        return {\n            correctAnswer: [] as number[],\n            userAnswer: [] as number[]\n        };\n    },\n    getters: {\n        getNumberOfCorrectAnswers(state) {\n            let count = 0;\n\n            // count the number of correct answers\n            state.userAnswer.forEach((answer, index) => {\n                if (index + 1 <= state.correctAnswer.length) {\n                    if (answer == state.correctAnswer[index]) {\n                        count++;\n                    }\n                }\n            });\n\n            return count;\n        },\n        getUserAnswer(state) {\n            return (question: number) => state.userAnswer[question];\n        },\n        numberOfQuestions: (state) => state.correctAnswer.length,\n        canShowUserResult(state) {\n            // only show if there aren't any -1s in the user answer array\n            return state.userAnswer.filter((val) => val === -1).length === 0;\n        },\n        nextQuestion() {\n            return (currentQuestion: number) => {\n                const nextQuestion = ++currentQuestion;\n                if (nextQuestion < this.numberOfQuestions) {\n                    return nextQuestion;\n                }\n\n                return -1;\n            };\n        }\n    },\n    actions: {\n        reset(numberOfQuestions: number) {\n            this.correctAnswer = Array(numberOfQuestions).fill(-1);\n            this.userAnswer = Array(numberOfQuestions).fill(-1);\n        },\n        setCorrectAnswer(question: number, answer: number) {\n            this.correctAnswer[question] = answer;\n        },\n        setUserAnswer(question: number, answer: number) {\n            this.userAnswer[question] = answer;\n        }\n    }\n});\n","import { defineComponent as _defineComponent } from 'vue'\nimport { unref as _unref, resolveComponent as _resolveComponent, createVNode as _createVNode, openBlock as _openBlock, createElementBlock as _createElementBlock, createCommentVNode as _createCommentVNode, renderSlot as _renderSlot, normalizeClass as _normalizeClass, createBlock as _createBlock, Fragment as _Fragment } from \"vue\"\n\nconst _hoisted_1 = { key: 0 }\n\nimport { toRefs, watch, ref, onMounted } from 'vue';\nimport { useTriviaQuizStore } from '../../stores/TriviaQuiz';\nimport { useLogger } from 'vue-logger-plugin';\nimport CoRegInterstitial from '../pathfinder/CoRegInterstitial.vue';\nimport { useQuizStore } from '@/stores/Quiz';\n\n// Incoming props\n\nexport default /*#__PURE__*/_defineComponent({\n  __name: 'Trivia',\n  props: { \n    questionsCount: {\n        type: Number\n    }, \n    showInterstitialOnComplete: {\n        type: Boolean,\n        default: false\n    },\n    captureEmail: {\n        type: Boolean,\n        default: false\n    },\n    listId: {\n        type: Number\n    },\n    sourceDesc: {\n        type: String\n    },\n    newsletterName: {\n        type: String\n    }\n},\n  setup(__props) {\n\nconst props = __props;\n\n\n\n// get back prop values\nconst { questionsCount } = toRefs(props);\n\n// use the logger\nconst logger = useLogger();\nconst loaded = ref(false);\n\n// get quiz store \nconst quizStore = useQuizStore();\n// get the trivia quiz store\nconst triviaStore = useTriviaQuizStore();\n// we want to reset the number of questions being shown on this page\nif (questionsCount?.value) {\n    logger.debug('Resetting quiz question counter', questionsCount.value);\n    triviaStore.reset(questionsCount.value);\n}\n\n// display interstitial after completing quiz\nconst displayContentInterstitial = ref(false);\nif (props.showInterstitialOnComplete) {\n    logger.debug('Configuring CoReg Interstitial upon quiz completion');\n    const unwatch = watch(() => triviaStore.canShowUserResult, complete => {\n        if (complete) {\n            // quiz is complete, display interstitial\n            displayContentInterstitial.value = true;\n            // disconnect watcher\n            unwatch();\n        }\n    });\n}\n\nonMounted(() => loaded.value = true);\n\nreturn (_ctx: any,_cache: any) => {\n  const _component_rad_quiz_newsletter = _resolveComponent(\"rad-quiz-newsletter\")!\n\n  return (_openBlock(), _createElementBlock(_Fragment, null, [\n    (__props.captureEmail && _unref(quizStore).isEmailSent == false)\n      ? (_openBlock(), _createElementBlock(\"div\", _hoisted_1, [\n          _createVNode(_component_rad_quiz_newsletter, {\n            \"list-id\": __props.listId,\n            \"source-desc\": __props.sourceDesc,\n            partners: true,\n            \"newsletter-name\": __props.newsletterName,\n            header: \"Enter your email address to see your quiz.\",\n            \"button-text\": \"Get quiz\",\n            \"result-sent\": false\n          }, null, 8, [\"list-id\", \"source-desc\", \"newsletter-name\"])\n        ]))\n      : (_openBlock(), _createElementBlock(\"div\", {\n          key: 1,\n          class: _normalizeClass({ 'quiz-wrapper': true, 'trivia-quiz': true, loaded: loaded.value })\n        }, [\n          _renderSlot(_ctx.$slots, \"default\")\n        ], 2)),\n    (__props.showInterstitialOnComplete)\n      ? (_openBlock(), _createBlock(CoRegInterstitial, {\n          key: 2,\n          showInterstitial: displayContentInterstitial.value,\n          enableCloseButton: false\n        }, null, 8, [\"showInterstitial\"]))\n      : _createCommentVNode(\"\", true)\n  ], 64))\n}\n}\n\n})","import script from \"./Trivia.vue?vue&type=script&setup=true&lang=ts\"\nexport * from \"./Trivia.vue?vue&type=script&setup=true&lang=ts\"\n\nconst __exports__ = script;\n\nexport default __exports__"],"names":["useQuizStore","defineStore","state","emailSent","emailSent2","getters","isEmailSent","isEmailSent2","actions","setEmailSent","sent","this","setEmailSent2","useTriviaQuizStore","correctAnswer","userAnswer","getNumberOfCorrectAnswers","count","forEach","answer","index","length","getUserAnswer","question","numberOfQuestions","canShowUserResult","filter","val","nextQuestion","currentQuestion","reset","Array","fill","setCorrectAnswer","setUserAnswer","_hoisted_1","key","_defineComponent","__name","props","questionsCount","type","Number","showInterstitialOnComplete","Boolean","default","captureEmail","listId","sourceDesc","String","newsletterName","setup","__props","toRefs","logger","useLogger","loaded","ref","quizStore","triviaStore","value","debug","displayContentInterstitial","unwatch","watch","complete","onMounted","_ctx","_cache","_component_rad_quiz_newsletter","_resolveComponent","_openBlock","_createElementBlock","_Fragment","_unref","_createVNode","partners","header","class","_normalizeClass","_renderSlot","$slots","_createBlock","CoRegInterstitial","showInterstitial","enableCloseButton","_createCommentVNode","__exports__"],"sourceRoot":""}