'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

const index = require('./index-51e8292e.js');
const environmentConfig_service = require('./environment-config.service-c8ff1f3d.js');
const assets_service = require('./assets.service-bfa75092.js');
require('./auth.store-1e630a7d.js');

const sparkleDiscussionCss = "sparkle-discussion{border:1px solid var(--line-rule-color);display:block;padding:12px}";

const SparkleDiscussion = class {
  constructor(hostRef) {
    index.registerInstance(this, hostRef);
    this.allowPostToFeed = false;
    this.feedStartingText = 'My suggestions are:';
    this.isTeacherMode = false;
    this.quizData = [];
  }
  async componentDidLoad() {
    this.isTeacherMode = this.isTeacherMode == false ? window.location.href.indexOf('/presentation/course') > -1 : this.isTeacherMode;
    const config = environmentConfig_service.EnvironmentConfigService.getInstance().get('sparkle');
    let allQuizData = await assets_service.AssetsService.getInstance().loadJsonFile(config.quizPath);
    if (allQuizData) {
      if (this.questionIds) {
        let questionIds = this.questionIds.split(',');
        this.quizData = [];
        questionIds.forEach(id => {
          this.quizData = [...this.quizData, allQuizData[+id]];
        });
        console.log('QUIZ Data', this.quizData);
      }
    }
  }
  render() {
    return this.isTeacherMode ? (index.h("sparkle-discussion-results", { allowPostToFeed: this.allowPostToFeed, feedStartingText: this.feedStartingText, isTeacherMode: this.isTeacherMode, questions: this.quizData })) : (index.h("sparkle-discussion-questions", { allowPostToFeed: this.allowPostToFeed, feedStartingText: this.feedStartingText, isTeacherMode: this.isTeacherMode, questions: this.quizData }));
  }
  get el() { return index.getElement(this); }
};
SparkleDiscussion.style = sparkleDiscussionCss;

exports.sparkle_discussion = SparkleDiscussion;
