(self["webpackChunkingenium"] = self["webpackChunkingenium"] || []).push([["src_app_juego-palabras_juego-palabras_module_ts"],{

/***/ 9089:
/*!*****************************************************************!*\
  !*** ./src/app/juego-palabras/juego-palabras-routing.module.ts ***!
  \*****************************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "JuegoPalabrasPageRoutingModule": () => (/* binding */ JuegoPalabrasPageRoutingModule)
/* harmony export */ });
/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! tslib */ 4762);
/* harmony import */ var _angular_core__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @angular/core */ 7716);
/* harmony import */ var _angular_router__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @angular/router */ 9895);
/* harmony import */ var _juego_palabras_page__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./juego-palabras.page */ 4445);




const routes = [
    {
        path: '',
        component: _juego_palabras_page__WEBPACK_IMPORTED_MODULE_0__.JuegoPalabrasPage
    }
];
let JuegoPalabrasPageRoutingModule = class JuegoPalabrasPageRoutingModule {
};
JuegoPalabrasPageRoutingModule = (0,tslib__WEBPACK_IMPORTED_MODULE_1__.__decorate)([
    (0,_angular_core__WEBPACK_IMPORTED_MODULE_2__.NgModule)({
        imports: [_angular_router__WEBPACK_IMPORTED_MODULE_3__.RouterModule.forChild(routes)],
        exports: [_angular_router__WEBPACK_IMPORTED_MODULE_3__.RouterModule],
    })
], JuegoPalabrasPageRoutingModule);



/***/ }),

/***/ 1951:
/*!*********************************************************!*\
  !*** ./src/app/juego-palabras/juego-palabras.module.ts ***!
  \*********************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "JuegoPalabrasPageModule": () => (/* binding */ JuegoPalabrasPageModule)
/* harmony export */ });
/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! tslib */ 4762);
/* harmony import */ var _angular_core__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @angular/core */ 7716);
/* harmony import */ var _angular_common__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @angular/common */ 8583);
/* harmony import */ var _angular_forms__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @angular/forms */ 3679);
/* harmony import */ var _ionic_angular__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @ionic/angular */ 476);
/* harmony import */ var _juego_palabras_routing_module__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./juego-palabras-routing.module */ 9089);
/* harmony import */ var _juego_palabras_page__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./juego-palabras.page */ 4445);
/* harmony import */ var _camera_video_camera_video_module__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../camera-video/camera-video.module */ 4467);
/* harmony import */ var _ngx_translate_core__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! @ngx-translate/core */ 9790);
/* harmony import */ var _modal_figuras_modal_figuras_module__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../modal-figuras/modal-figuras.module */ 5436);










let JuegoPalabrasPageModule = class JuegoPalabrasPageModule {
};
JuegoPalabrasPageModule = (0,tslib__WEBPACK_IMPORTED_MODULE_4__.__decorate)([
    (0,_angular_core__WEBPACK_IMPORTED_MODULE_5__.NgModule)({
        imports: [
            _angular_common__WEBPACK_IMPORTED_MODULE_6__.CommonModule,
            _angular_forms__WEBPACK_IMPORTED_MODULE_7__.FormsModule,
            _ionic_angular__WEBPACK_IMPORTED_MODULE_8__.IonicModule,
            _juego_palabras_routing_module__WEBPACK_IMPORTED_MODULE_0__.JuegoPalabrasPageRoutingModule,
            _camera_video_camera_video_module__WEBPACK_IMPORTED_MODULE_2__.CameraVideoModule,
            _ngx_translate_core__WEBPACK_IMPORTED_MODULE_9__.TranslateModule,
            _modal_figuras_modal_figuras_module__WEBPACK_IMPORTED_MODULE_3__.ModalFigurasModule
        ],
        declarations: [_juego_palabras_page__WEBPACK_IMPORTED_MODULE_1__.JuegoPalabrasPage]
    })
], JuegoPalabrasPageModule);



/***/ }),

/***/ 4445:
/*!*******************************************************!*\
  !*** ./src/app/juego-palabras/juego-palabras.page.ts ***!
  \*******************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "JuegoPalabrasPage": () => (/* binding */ JuegoPalabrasPage)
/* harmony export */ });
/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! tslib */ 4762);
/* harmony import */ var _raw_loader_juego_palabras_page_html__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! !raw-loader!./juego-palabras.page.html */ 6611);
/* harmony import */ var _juego_palabras_page_scss__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./juego-palabras.page.scss */ 9787);
/* harmony import */ var _angular_core__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @angular/core */ 7716);
/* harmony import */ var _angular_router__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @angular/router */ 9895);
/* harmony import */ var _ionic_angular__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @ionic/angular */ 476);
/* harmony import */ var src_environments_environment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! src/environments/environment */ 2340);
/* harmony import */ var _services_games_service__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../services/games.service */ 1675);
/* harmony import */ var _ngx_translate_core__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @ngx-translate/core */ 9790);









let JuegoPalabrasPage = class JuegoPalabrasPage {
    constructor(router, gamesService, toastController, translate) {
        this.router = router;
        this.gamesService = gamesService;
        this.toastController = toastController;
        this.translate = translate;
        this.showResuls = false;
        this.showControls = true;
        this.numberWord = 0;
        this.limitWord = 6;
        this.level = 1;
        this.numbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
        this.counter = 0;
        this.setResults = false;
        this.hasClick = false;
        this.words_clicks = [];
        this.stopCounting = false;
        this.clickingGame = 0;
        this.last_word = 0;
        this.actual_word = 0;
    }
    ngOnInit() {
        this.times_level = src_environments_environment__WEBPACK_IMPORTED_MODULE_2__.environment.time;
        this.letterSelected = localStorage.getItem('letter_selected');
        console.log('=== LETRA RECUPERADA PARA EL JUEGO DE PALABRAS ===');
        console.log('Letra:', this.letterSelected);
        this.game_header_id = localStorage.getItem('game_header_id');
        const user = JSON.parse(localStorage.getItem('user'));
        this.level = user.level;
        if (this.level === 1) {
            this.position = ['word1', 'word2', 'word3', 'word4', 'word5', 'word6'];
            this.tipography = ['word-style1'];
            this.orientation = ['word-orientation1'];
            this.size = ['size_word1'];
        }
        if (this.level === 2) {
            this.position = ['word1', 'word2', 'word3', 'word4', 'word5', 'word6'];
            this.tipography = ['word-style1', 'word-style2', 'word-style3'];
            this.orientation = ['word-orientation1'];
            this.size = ['size_word1', 'size_word2', 'size_word3'];
        }
        if (this.level === 3) {
            this.position = ['word1', 'word2', 'word3', 'word4', 'word5', 'word6'];
            this.tipography = ['word-style1', 'word-style2', 'word-style3'];
            this.orientation = ['word-orientation1', 'word-orientation2'];
            this.size = ['size_word1', 'size_word2', 'size_word3'];
        }
        this.gamesService.gameWordsInit(this.game_header_id).subscribe((res) => {
            // console.log(res)
        }, (err) => {
            if (err.status === 401) {
                this.router.navigate(['/']);
                localStorage.clear();
            }
        });
        this.word_game_id = localStorage.getItem('word_game_id');
        this.words_array = JSON.parse(localStorage.getItem('words_array'));
        this.total_words_array = this.words_array.length;
        const words_array_custom1 = [];
        for (let j = 0; j < this.total_words_array; j++) {
            words_array_custom1[j] = {
                word: this.words_array[j]['word'],
                position: this.position[Math.floor(Math.random() * this.position.length)],
                tipography: this.words_array[j]['typography'],
                orientation: this.words_array[j]['orientation'],
                size: this.words_array[j]['size'],
            };
        }
        this.words_array2 = words_array_custom1;
        this.clickWordInterval();
        this.counting();
    }
    presentToast(messageKey) {
        return (0,tslib__WEBPACK_IMPORTED_MODULE_4__.__awaiter)(this, void 0, void 0, function* () {
            const toast = yield this.toastController.create({
                message: yield this.translate.get(messageKey).toPromise(),
                duration: 2000,
                position: 'middle',
                color: 'tertiary'
            });
            toast.present();
        });
    }
    presentToast2(messageKey) {
        return (0,tslib__WEBPACK_IMPORTED_MODULE_4__.__awaiter)(this, void 0, void 0, function* () {
            const toast = yield this.toastController.create({
                message: yield this.translate.get(messageKey).toPromise(),
                duration: 2000,
                position: 'bottom',
                color: 'danger'
            });
            toast.present();
        });
    }
    selectOverlay() {
        if (this.last_word < 1) {
            this.last_word = Date.now();
        }
        this.actual_word = Date.now();
        let result_time = this.actual_word - this.last_word;
        if (result_time > 5) {
            this.words_clicks[this.clickingGame] = {
                word: this.words_array2[this.numberWord].word,
                pulsation: -1,
                time_pulsation: this.actual_word,
                time: result_time
            };
            this.clickingGame = this.clickingGame + 1;
            this.words_clicks[this.clickingGame] = {
                word: this.words_array2[this.numberWord].word,
                pulsation: 0,
                time_pulsation: this.actual_word,
                time: result_time
            };
            this.last_word = Date.now();
        }
    }
    selectedWord() {
        clearInterval(this.words_interval);
        this.hasClick = true;
        this.clickWordInterval();
        this.loopFunction();
    }
    clickWordInterval() {
        this.words_interval = setInterval(() => {
            if (this.numberWord <= (12000 / this.times_level[this.level - 1])) {
                this.loopFunction();
            }
        }, this.times_level[this.level - 1]);
    }
    loopFunction() {
        if (this.last_word < 1) {
            this.last_word = Date.now();
        }
        this.actual_word = Date.now();
        let result_time = this.actual_word - this.last_word;
        if (result_time > 5) {
            if (this.hasClick) {
                this.words_clicks[this.clickingGame] = {
                    word: this.words_array2[this.numberWord].word,
                    pulsation: 1,
                    time_pulsation: this.actual_word,
                    time: result_time
                };
                this.clickingGame = this.clickingGame + 1;
                this.numberWord = this.numberWord + 1;
                this.hasClick = false;
            }
            else {
                this.words_clicks[this.clickingGame] = {
                    word: this.words_array2[this.numberWord].word,
                    pulsation: 0,
                    time_pulsation: this.actual_word,
                    time: result_time
                };
                this.clickingGame = this.clickingGame + 1;
                this.numberWord = this.numberWord + 1;
            }
            this.last_word = Date.now();
        }
    }
    counting() {
        console.log((12000 / this.times_level[this.level - 1]));
        const counterGame = setInterval(() => {
            this.counter = this.counter + 1;
            this.init_timestamp = Date.now();
            if (this.counter >= 12 || this.numberWord === (12000 / this.times_level[this.level - 1])) {
                clearInterval(counterGame);
                clearInterval(this.words_interval);
                this.numberWord = 1000;
                this.stopCounting = true;
                let time_final_counter = Date.now();
                let time_total = time_final_counter - this.init_timestamp;
                this.gamesService.gameWordsStop(time_total, this.word_game_id, JSON.stringify(this.words_clicks), 12).subscribe((res) => {
                    this.presentToast('WORD_GAME.MESSAGES.FINISH');
                    setTimeout(() => {
                        this.router.navigate(['/ingresa-contrasena']);
                    }, 3000);
                }, (err) => {
                    if (err.status === 401) {
                        this.router.navigate(['/']);
                        localStorage.clear();
                    }
                    else {
                        this.presentToast2('WORD_GAME.MESSAGES.SERVER_ERROR');
                    }
                });
            }
        }, 1000);
    }
    finishGame() {
        return (0,tslib__WEBPACK_IMPORTED_MODULE_4__.__awaiter)(this, void 0, void 0, function* () {
            clearInterval(this.words_interval);
            this.numberWord = 1000;
            this.stopCounting = true;
            const time_final_counter = Date.now();
            const time_total = time_final_counter - this.init_timestamp;
            try {
                yield this.gamesService.gameWordsStop(time_total, this.word_game_id, JSON.stringify(this.words_clicks), 12).toPromise();
                yield this.presentToast('WORD_GAME.MESSAGES.FINISH');
                setTimeout(() => {
                    this.router.navigate(['/ingresa-contrasena']);
                }, 3000);
            }
            catch (err) {
                if (err.status === 401) {
                    this.router.navigate(['/']);
                    localStorage.clear();
                }
                else {
                    yield this.presentToast2('WORD_GAME.MESSAGES.SERVER_ERROR');
                }
            }
        });
    }
};
JuegoPalabrasPage.ctorParameters = () => [
    { type: _angular_router__WEBPACK_IMPORTED_MODULE_5__.Router },
    { type: _services_games_service__WEBPACK_IMPORTED_MODULE_3__.GamesService },
    { type: _ionic_angular__WEBPACK_IMPORTED_MODULE_6__.ToastController },
    { type: _ngx_translate_core__WEBPACK_IMPORTED_MODULE_7__.TranslateService }
];
JuegoPalabrasPage = (0,tslib__WEBPACK_IMPORTED_MODULE_4__.__decorate)([
    (0,_angular_core__WEBPACK_IMPORTED_MODULE_8__.Component)({
        selector: 'app-juego-palabras',
        template: _raw_loader_juego_palabras_page_html__WEBPACK_IMPORTED_MODULE_0__.default,
        styles: [_juego_palabras_page_scss__WEBPACK_IMPORTED_MODULE_1__.default]
    })
], JuegoPalabrasPage);



/***/ }),

/***/ 9787:
/*!*********************************************************!*\
  !*** ./src/app/juego-palabras/juego-palabras.page.scss ***!
  \*********************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "default": () => (__WEBPACK_DEFAULT_EXPORT__)
/* harmony export */ });
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ("ion-button.btn-close {\n  --padding-start: 0;\n  --padding-end: 0;\n  --background: transparent;\n  margin-left: auto;\n  --box-shadow: none;\n}\n\nion-title.title-logo {\n  font-size: 35px;\n  padding-left: 0;\n  cursor: pointer;\n  color: #fff;\n}\n\n@media (max-width: 768px) {\n  ion-title.title-logo {\n    font-size: 25px;\n  }\n}\n\n@media (max-width: 576px) {\n  ion-title.title-logo {\n    font-size: 25px;\n  }\n}\n\nion-col.col-header-btn-close {\n  text-align: right;\n}\n\n.ion-page {\n  background-color: #1D1F33;\n}\n\nion-header ion-grid {\n  padding: 15px 30px;\n}\n\n.title1 {\n  font-size: 38px;\n  font-weight: 500;\n  line-height: 1;\n  margin-bottom: 20px;\n}\n\n@media (max-width: 768px) {\n  .title1 {\n    font-size: 25px;\n  }\n}\n\n@media (max-width: 576px) {\n  .title1 {\n    font-size: 25px;\n  }\n}\n\nion-content {\n  position: fixed;\n  left: 0;\n  width: 100%;\n  top: 0;\n  height: 100%;\n  z-index: 99999;\n}\n\n.modal-game-words {\n  height: 100%;\n}\n\n.word-item {\n  display: inline-block;\n  padding: 10px 20px;\n  line-height: 1;\n  background: #232541;\n  border: 1.58623px solid #494979;\n  border-radius: 9.51738px;\n  font-size: 70px;\n  position: absolute;\n  color: #fff;\n}\n\n@media (max-width: 768px) {\n  .word-item {\n    font-size: 25px;\n  }\n}\n\n@media (max-width: 576px) {\n  .word-item {\n    font-size: 25px;\n  }\n}\n\n.word-item.size_word1 {\n  font-size: 70px;\n}\n\n@media (max-width: 768px) {\n  .word-item.size_word1 {\n    font-size: 25px;\n  }\n}\n\n@media (max-width: 576px) {\n  .word-item.size_word1 {\n    font-size: 25px;\n  }\n}\n\n.word-item.size_word2 {\n  font-size: 50px;\n}\n\n@media (max-width: 768px) {\n  .word-item.size_word2 {\n    font-size: 25px;\n  }\n}\n\n@media (max-width: 576px) {\n  .word-item.size_word2 {\n    font-size: 25px;\n  }\n}\n\n.word-item.size_word3 {\n  font-size: 25px;\n}\n\n@media (max-width: 768px) {\n  .word-item.size_word3 {\n    font-size: 27px;\n  }\n}\n\n@media (max-width: 576px) {\n  .word-item.size_word3 {\n    font-size: 24px;\n  }\n}\n\n.word-style2 {\n  font-family: \"Playfair Display\", serif;\n  line-height: 0.5;\n  padding-top: 20px;\n  padding-bottom: 25px;\n}\n\n.word-style3 {\n  font-family: \"Bangers\", cursive;\n}\n\n.modal-game-words {\n  position: relative;\n  display: flex;\n  align-items: center;\n  justify-content: center;\n}\n\n.word2 {\n  right: 10%;\n  bottom: 10%;\n}\n\n.word-orientation2 {\n  transform: rotate(180deg);\n}\n\n.word4 {\n  top: 20%;\n}\n\n.word5 {\n  left: 10%;\n}\n\n.word6 {\n  bottom: 25%;\n  left: 25%;\n}\n\n.overlay-juego-palabras {\n  position: absolute;\n  left: 0;\n  right: 0;\n  bottom: 0;\n  background: transparent;\n  top: 0;\n}\n/*# sourceMappingURL=data:application/json;base64,  */");

/***/ }),

/***/ 6611:
/*!***********************************************************************************************!*\
  !*** ./node_modules/raw-loader/dist/cjs.js!./src/app/juego-palabras/juego-palabras.page.html ***!
  \***********************************************************************************************/
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */   "default": () => (__WEBPACK_DEFAULT_EXPORT__)
/* harmony export */ });
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ("<ion-header [translucent]=\"true\" class=\"ion-no-border\">\n  <ion-grid>\n    <ion-row>\n      <ion-col size=\"4\">\n        <ion-title class=\"title-logo\"  [routerLink]=\"['/']\">\n          <img src=\"assets/img/logo.png\" alt=\"Logo KOR\">\n        </ion-title>\n      </ion-col>\n      <ion-col size=\"8\" class=\"col-header-btn-close\">\n\n        <app-camera-video></app-camera-video>\n\n      </ion-col>\n    </ion-row>\n  </ion-grid>\n</ion-header>\n\n<ion-content>\n  <div class=\"modal-game-words\">\n    <div class=\"overlay-juego-palabras\" (click)=\"selectOverlay()\"></div>\n    <div *ngFor=\"let item of words_array2; let i = index\">\n      <p class=\"word-item {{orientation[item.orientation]}} {{item.position}} {{size[item.size]}} {{tipography[item.tipography]}}\" *ngIf=\"numberWord == i\" (click)=\"selectedWord()\" [attr.aria-label]=\"'WORD_GAME.WORD_ITEM' | translate\">\n        {{item.word}}\n      </p>\n    </div>\n  </div>\n  \n  <div class=\"game-controls\" *ngIf=\"showControls\">\n    <ion-button class=\"btn-design2\" (click)=\"finishGame()\">\n      {{ 'COMMON.FINISH' | translate }}\n    </ion-button>\n  </div>\n</ion-content>\n");

/***/ })

}]);
//# sourceMappingURL=src_app_juego-palabras_juego-palabras_module_ts.js.map