import{r as i,i as e,h as s,e as t}from"./p-ee1e0eb4.js";const n=class{constructor(s){i(this,s),this.quizAnswerChanged=e(this,"quizAnswerChanged",7),this.type="TEXT",this.scale="FIVE-POINTS",this.options=[]}async componentWillLoad(){}async componentDidLoad(){this.options=[],this.el.querySelector("[slot='options']")&&(Array.from(this.el.querySelector("[slot='options']").querySelectorAll("option")).forEach((i=>{this.options=[...this.options,{option:i.innerText}]})),console.log(this.questionText,this.options)),this.quizAnswerChanged.emit({question:null,answer:"1"})}quizInputChangeHandler(i){this.quizAnswerChanged.emit({question:i.detail.question,answer:i.detail.value})}quizFeedbackChangeHandler(i){this.quizAnswerChanged.emit({question:i.detail.question,answer:i.detail.value})}quizSelectChangeHandler(i){this.quizAnswerChanged.emit({question:i.detail.question,answer:i.detail.value})}quizOpinionChangeHandler(i){this.quizAnswerChanged.emit({question:i.detail.question,answer:i.detail.value})}getQuestionFeedback(){return"MULTIPLE-CHOICE"==this.type?s("small",null):"FEEDBACK"==this.type||"TEXT"==this.type?this.feedback&&s("small",null," ",this.feedback):void 0}showAnswerStatus(){return s("div",null,s("strong",null,this.correct?"Good job!":"Incorrect answer, please try again."))}renderQuestion(){var i={questionId:this.questionId,questionText:this.questionText,questionType:this.type,scale:this.scale,showOptionNumber:this.showOptionNumber,options:this.options,feedback:this.feedback};return"MULTIPLE-CHOICE"==this.type?s("sparkle-quiz-select",{question:i,allowMultiple:!0}):"FEEDBACK"==this.type?s("sparkle-quiz-feedback",{question:i}):"TEXT"==this.type?s("sparkle-quiz-input",{question:i}):"OPINION"==this.type?s("sparkle-quiz-opinion",{question:i}):"POLL"==this.type?s("sparkle-quiz-poll",{question:i}):void 0}render(){return this.questionText?s("div",{class:{correct:this.submitted&&this.correct,incorrect:this.submitted&&!this.correct},ref:i=>this.containerRef=i},s("div",{hidden:!0},s("slot",null)),this.renderQuestion(),this.submitted&&this.showInstantResult&&s("div",{class:"feedback-container"},[this.showAnswerStatus(),this.getQuestionFeedback()])):s("p",null,"No question found.")}get el(){return t(this)}};n.style="sparkle-quiz{display:block;font-family:var(--font-family);--sparkle-quiz-question-container-padding:10px 0px;--sparkle-quiz-question-container-margin:0px;--sparkle-quiz-question-text-padding:10px 0px;--sparkle-quiz-option-border:2px solid var(--line-rule-color);--sparkle-quiz-selected-option-border:2px solid var(--text-color--dark);--sparkle-quiz-option-border-radius:4px;--sparkle-quiz-option-padding:5px 10px;--sparkle-quiz-option-width:100%;--sparkle-quiz-error-bg-color:#fbaeae;--sparkle-quiz-success-bg-color:#fbaeae;padding:var(--sparkle-quiz-question-container-padding);margin:var(--sparkle-quiz-question-container-margin)}.question-text{padding:var(--sparkle-quiz-question-text-padding)}.option{padding:5px 0px}.number{padding:0px 14px;border:1px solid #ebebeb;border-radius:4px;margin-right:10px;font-size:14px;width:14px;display:inline-flex;justify-content:center}.feedback-container{padding:10px;border-radius:4px}.incorrect .feedback-container{background-color:var(--sparkle-quiz-error-bg-color, #fbaeae)}.correct .feedback-container{background-color:var(--sparkle-quiz-success-bg-color, #fbaeae)}";export{n as sparkle_quiz}