(self["webpackChunkingenium"] = self["webpackChunkingenium"] || []).push([["src_app_calculo-mental_calculo-mental_module_ts"],{

/***/ 6974:
/*!*****************************************************************!*\
  !*** ./src/app/calculo-mental/calculo-mental-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 */   "CalculoMentalPageRoutingModule": () => (/* binding */ CalculoMentalPageRoutingModule)
/* 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 _calculo_mental_page__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./calculo-mental.page */ 1242);




const routes = [
    {
        path: '',
        component: _calculo_mental_page__WEBPACK_IMPORTED_MODULE_0__.CalculoMentalPage
    }
];
let CalculoMentalPageRoutingModule = class CalculoMentalPageRoutingModule {
};
CalculoMentalPageRoutingModule = (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],
    })
], CalculoMentalPageRoutingModule);



/***/ }),

/***/ 1659:
/*!*********************************************************!*\
  !*** ./src/app/calculo-mental/calculo-mental.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 */   "CalculoMentalPageModule": () => (/* binding */ CalculoMentalPageModule)
/* 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 _calculo_mental_routing_module__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./calculo-mental-routing.module */ 6974);
/* harmony import */ var _calculo_mental_page__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./calculo-mental.page */ 1242);
/* harmony import */ var _camera_video_camera_video_module__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../camera-video/camera-video.module */ 4467);
/* harmony import */ var _modal_figuras_modal_figuras_module__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../modal-figuras/modal-figuras.module */ 5436);
/* harmony import */ var _ngx_translate_core__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! @ngx-translate/core */ 9790);










let CalculoMentalPageModule = class CalculoMentalPageModule {
};
CalculoMentalPageModule = (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,
            _calculo_mental_routing_module__WEBPACK_IMPORTED_MODULE_0__.CalculoMentalPageRoutingModule,
            _camera_video_camera_video_module__WEBPACK_IMPORTED_MODULE_2__.CameraVideoModule,
            _modal_figuras_modal_figuras_module__WEBPACK_IMPORTED_MODULE_3__.ModalFigurasModule,
            _ngx_translate_core__WEBPACK_IMPORTED_MODULE_9__.TranslateModule
        ],
        declarations: [_calculo_mental_page__WEBPACK_IMPORTED_MODULE_1__.CalculoMentalPage]
    })
], CalculoMentalPageModule);



/***/ }),

/***/ 1242:
/*!*******************************************************!*\
  !*** ./src/app/calculo-mental/calculo-mental.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 */   "CalculoMentalPage": () => (/* binding */ CalculoMentalPage)
/* harmony export */ });
/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! tslib */ 4762);
/* harmony import */ var _raw_loader_calculo_mental_page_html__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! !raw-loader!./calculo-mental.page.html */ 9328);
/* harmony import */ var _calculo_mental_page_scss__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./calculo-mental.page.scss */ 3691);
/* 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 _environments_environment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../environments/environment */ 2340);
/* harmony import */ var _ngx_translate_core__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @ngx-translate/core */ 9790);
/* harmony import */ var _services_games_service__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../services/games.service */ 1675);









let CalculoMentalPage = class CalculoMentalPage {
    constructor(router, gamesService, toastController, translate) {
        this.router = router;
        this.gamesService = gamesService;
        this.toastController = toastController;
        this.translate = translate;
        this.shouldDisable = false;
        this.showResuls = false;
        this.numberOperation = 0;
        this.limitOperation = 6;
        this.level = 1;
        this.numbers = [0, 1, 2, 3, 4, 5];
        this.numbers2 = [6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19];
        this.counter = 0;
        this.setResults = false;
    }
    ngOnInit() {
        this.times_level = _environments_environment__WEBPACK_IMPORTED_MODULE_2__.environment.time;
        this.game_header_id = localStorage.getItem('game_header_id');
        this.mental_calculation_id = localStorage.getItem('mental_calculation_id');
        this.mental_calculation_result = localStorage.getItem('mental_calculation_result');
        this.mental_calculation_array = JSON.parse(localStorage.getItem('mental_calculation_array'));
        const user = JSON.parse(localStorage.getItem('user'));
        this.level = user.level;
        if (this.level == 1) {
            this.limitOperation = 6;
            this.signos = ['-', '+'];
            this.numberArray = [
                this.numberArray1(),
                this.numberArray1(),
                this.numberArray1(),
                this.numberArray1(),
                this.numberArray1(),
                this.numberArray2()
            ];
        }
        if (this.level == 2) {
            this.limitOperation = 8;
            this.signos = ['-', '+'];
            this.numberArray = [
                this.numberArray1(),
                this.numberArray1(),
                this.numberArray1(),
                this.numberArray1(),
                this.numberArray1(),
                this.numberArray1(),
                this.numberArray2(),
                this.numberArray2()
            ];
        }
        if (this.level == 3) {
            this.limitOperation = 10;
            this.signos = ['-', '+'];
            this.numberArray = [
                this.numberArray2(),
                this.numberArray2(),
                this.numberArray2(),
                this.numberArray2(),
                this.numberArray2(),
                this.numberArray2(),
                this.numberArray2(),
                this.numberArray2(),
                this.numberArray2(),
                this.numberArray2(),
            ];
        }
        const araryOperations = [];
        let resultOperation = 0;
        for (var i = 0; i < this.limitOperation; i++) {
            const number_select = this.numberArray[i];
            const signo_select = this.signos[Math.floor(Math.random() * this.signos.length)];
            araryOperations[i] = { number: number_select, signo: signo_select };
            this.listOperations = araryOperations;
            if (i == 0) {
                resultOperation = number_select;
            }
            else {
                switch (signo_select) {
                    case '+':
                        resultOperation = resultOperation + number_select;
                        break;
                    case '-':
                        resultOperation = resultOperation - number_select;
                        break;
                    case 'x':
                        resultOperation = resultOperation * number_select;
                        break;
                }
            }
        }
        this.listOperations = this.mental_calculation_array;
        this.resultCorrect = this.mental_calculation_result;
        const operations = setInterval(() => {
            if (this.numberOperation == this.limitOperation) {
                clearInterval(operations);
                this.numberOperation = 1000;
                this.showResuls = true;
                setTimeout(() => {
                    this.sInput.setFocus();
                }, 800);
            }
            else {
                this.numberOperation = this.numberOperation + 1;
                i = i + 1;
            }
        }, 1000);
        this.counting();
    }
    numberArray1() {
        return this.numbers[Math.floor(Math.random() * this.numbers.length)];
    }
    numberArray2() {
        return this.numbers2[Math.floor(Math.random() * this.numbers2.length)];
    }
    counting() {
        this.timestamp_initial = Date.now();
        const counterGame = setInterval(() => {
            this.counter = this.counter + 1;
            if (this.counter === 10 + this.limitOperation) {
                if (this.setResults) {
                    clearInterval(counterGame);
                    this.gamesService.mentalCalculationStop(this.mental_calculation_id).subscribe((res) => {
                        this.presentToast('MENTAL_CALC.MESSAGES.FINISH');
                        setTimeout(() => {
                            this.router.navigate(['/instrucciones-juego-palabras']);
                        }, 3000);
                    }, (err) => this.handleError(err));
                }
                else {
                    this.shouldDisable = true;
                    clearInterval(counterGame);
                    this.gamesService.mentalCalculationDetails(this.mental_calculation_id, this.resultCorrect, this.result, this.counter).subscribe((res) => {
                        this.gamesService.mentalCalculationStop(this.mental_calculation_id).subscribe((res) => {
                            this.presentToast('MENTAL_CALC.MESSAGES.FINISH');
                            setTimeout(() => {
                                this.router.navigate(['/instrucciones-juego-palabras']);
                            }, 3000);
                        }, (err) => this.handleError(err));
                    }, (err) => this.handleError(err));
                }
            }
            else if (this.setResults) {
                clearInterval(counterGame);
                this.gamesService.mentalCalculationStop(this.mental_calculation_id).subscribe((res) => {
                    this.presentToast('MENTAL_CALC.MESSAGES.FINISH');
                    setTimeout(() => {
                        this.router.navigate(['/instrucciones-juego-palabras']);
                    }, 3000);
                }, (err) => this.handleError(err));
            }
        }, 1000);
    }
    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();
        });
    }
    presentErrorToast() {
        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('MENTAL_CALC.MESSAGES.SERVER_ERROR').toPromise(),
                duration: 2000,
                position: 'bottom',
                color: 'danger'
            });
            toast.present();
        });
    }
    handleError(err) {
        if (err.status === 401) {
            this.router.navigate(['/']);
            localStorage.clear();
        }
        else {
            this.presentErrorToast();
        }
    }
    onSubmit() {
        const result = parseInt(this.result);
        this.shouldDisable = true;
        if (!this.setResults) {
            const timestamp_final = Date.now();
            const result_timestamp = timestamp_final - this.timestamp_initial;
            this.gamesService.mentalCalculationDetails(this.mental_calculation_id, this.resultCorrect, result, result_timestamp).subscribe((res) => {
                this.setResults = true;
                this.presentToast('MENTAL_CALC.MESSAGES.FINISH');
                setTimeout(() => {
                    this.router.navigate(['/instrucciones-juego-palabras']);
                }, 3000);
            }, (err) => this.handleError(err));
        }
    }
};
CalculoMentalPage.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 }
];
CalculoMentalPage.propDecorators = {
    sInput: [{ type: _angular_core__WEBPACK_IMPORTED_MODULE_8__.ViewChild, args: ['inputResult', { static: false },] }]
};
CalculoMentalPage = (0,tslib__WEBPACK_IMPORTED_MODULE_4__.__decorate)([
    (0,_angular_core__WEBPACK_IMPORTED_MODULE_8__.Component)({
        selector: 'app-calculo-mental',
        template: _raw_loader_calculo_mental_page_html__WEBPACK_IMPORTED_MODULE_0__.default,
        styles: [_calculo_mental_page_scss__WEBPACK_IMPORTED_MODULE_1__.default]
    })
], CalculoMentalPage);



/***/ }),

/***/ 3691:
/*!*********************************************************!*\
  !*** ./src/app/calculo-mental/calculo-mental.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-title.title-logo {\n  font-size: 35px;\n  padding-left: 0;\n  cursor: pointer;\n  color: #fff;\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.calculo-mental-item {\n  background: #232541;\n  border: 2.5px solid #494979;\n  box-sizing: border-box;\n  border-radius: 13.6154px;\n  width: 180px;\n  height: 160px;\n  text-align: center;\n  margin: auto;\n  display: flex;\n  align-items: center;\n  justify-content: center;\n  cursor: pointer;\n  position: absolute;\n  left: 0;\n  right: 0;\n  top: 0;\n  bottom: 0;\n  opacity: 0;\n  transform: translateY(-500px);\n  transition: all 0.3s ease;\n}\n\n.calculo-mental-item.active {\n  opacity: 1;\n  transform: translateY(0px);\n}\n\n.calculo-mental-item h5 {\n  font-style: normal;\n  font-weight: 500;\n  font-size: 105px;\n  margin: 0;\n  color: #fff;\n}\n\n.box-number-calculo-mental {\n  position: relative;\n  top: 50%;\n  transform: translateY(-50%);\n  margin-top: -50px;\n  height: 180px;\n}\n\n.calculo-mental-results {\n  margin: 0 auto;\n  position: absolute;\n  text-align: center;\n  top: 0;\n  left: 0;\n  right: 0;\n  transform: translateY(-50px);\n  opacity: 0;\n  transition: all 0.3s ease;\n}\n\n.calculo-mental-results.active {\n  opacity: 1;\n  transform: translateY(0px);\n}\n\n.title-calculo-mental {\n  font-size: 30px;\n  color: #fff;\n}\n\n.calculo-mental-results .input-custom ion-input {\n  background: #D5D5D8;\n  border: 1px solid #494979;\n  border-radius: 6px;\n  font-size: 18px;\n  --padding-top: 20px;\n  --padding-end: 30px;\n  --padding-bottom: 20px;\n  --padding-start: 20px;\n  --background: #D5D5D8;\n  --color: #000;\n}\n\n.btn-design2 {\n  --background: #6FCF97;\n  --border-width: 1px;\n  --border-style: solid;\n  --border-radius: 6px;\n  --border-color: #494979;\n  --padding-bottom: 27px;\n  --padding-end: 40px;\n  --padding-start: 40px;\n  --padding-top: 27px;\n  --color: #fff;\n  height: auto;\n  width: 100%;\n  margin: 0;\n  font-size: 15px;\n  margin-top: 10px;\n}\n/*# sourceMappingURL=data:application/json;base64,  */");

/***/ }),

/***/ 9328:
/*!***********************************************************************************************!*\
  !*** ./node_modules/raw-loader/dist/cjs.js!./src/app/calculo-mental/calculo-mental.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\" [attr.alt]=\"'MENTAL_CALC.TITLE' | translate\">\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<ion-content [fullscreen]=\"true\">\n    <div class=\"box-number-calculo-mental\">\n        <div class=\"calculo-mental-item\" *ngFor=\"let item of listOperations; let i = index\" id=\"calculo-mental-item{{ i }}\" [ngClass]=\"{'active': numberOperation === i}\">\n            <h5 class=\"simbolo\" *ngIf=\"i !== 0\">{{ item.operation }}</h5>\n            <h5 class=\"number\">{{ item.number }}</h5>\n        </div>\n        <div class=\"calculo-mental-results\" [ngClass]=\"{'active': showResuls}\" id=\"calculo-mental-item{{ listOperations.length }}\">\n            <h3 class=\"title-calculo-mental\">{{ 'MENTAL_CALC.FINAL_RESULT_QUESTION' | translate }}</h3>\n            <form (ngSubmit)=\"onSubmit()\">\n                <div class=\"input-custom\">\n                    <ion-input [placeholder]=\"'MENTAL_CALC.RESULT_PLACEHOLDER' | translate\" [(ngModel)]=\"result\" #inputResult type=\"number\" name=\"results\"></ion-input>\n                </div>\n                <ion-button class=\"btn-design2\" type=\"submit\" [disabled]=\"shouldDisable\">\n                    {{ 'COMMON.CONTINUE' | translate }}\n                </ion-button>\n            </form>\n        </div>\n    </div>\n</ion-content>\n");

/***/ })

}]);
//# sourceMappingURL=src_app_calculo-mental_calculo-mental_module_ts.js.map