(self["webpackChunkingenium"] = self["webpackChunkingenium"] || []).push([["src_app_rapidez-mental_rapidez-mental_module_ts"],{

/***/ 690:
/*!*****************************************************************!*\
  !*** ./src/app/rapidez-mental/rapidez-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 */   "RapidezMentalPageRoutingModule": () => (/* binding */ RapidezMentalPageRoutingModule)
/* 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 _rapidez_mental_page__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./rapidez-mental.page */ 9330);




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



/***/ }),

/***/ 9607:
/*!*********************************************************!*\
  !*** ./src/app/rapidez-mental/rapidez-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 */   "RapidezMentalPageModule": () => (/* binding */ RapidezMentalPageModule)
/* 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 _rapidez_mental_routing_module__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./rapidez-mental-routing.module */ 690);
/* harmony import */ var _rapidez_mental_page__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rapidez-mental.page */ 9330);
/* 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 RapidezMentalPageModule = class RapidezMentalPageModule {
};
RapidezMentalPageModule = (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,
            _rapidez_mental_routing_module__WEBPACK_IMPORTED_MODULE_0__.RapidezMentalPageRoutingModule,
            _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: [_rapidez_mental_page__WEBPACK_IMPORTED_MODULE_1__.RapidezMentalPage]
    })
], RapidezMentalPageModule);



/***/ }),

/***/ 9330:
/*!*******************************************************!*\
  !*** ./src/app/rapidez-mental/rapidez-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 */   "RapidezMentalPage": () => (/* binding */ RapidezMentalPage)
/* harmony export */ });
/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! tslib */ 4762);
/* harmony import */ var _raw_loader_rapidez_mental_page_html__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! !raw-loader!./rapidez-mental.page.html */ 6961);
/* harmony import */ var _rapidez_mental_page_scss__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rapidez-mental.page.scss */ 2466);
/* harmony import */ var _angular_core__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @angular/core */ 7716);
/* harmony import */ var _angular_router__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @angular/router */ 9895);
/* harmony import */ var _ionic_angular__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @ionic/angular */ 476);
/* 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_2__ = __webpack_require__(/*! ../services/games.service */ 1675);








let RapidezMentalPage = class RapidezMentalPage {
    constructor(router, renderer, elementRef, gamesService, toastController, translate) {
        this.router = router;
        this.renderer = renderer;
        this.elementRef = elementRef;
        this.gamesService = gamesService;
        this.toastController = toastController;
        this.translate = translate;
        this.initGame = false;
        this.valueExpected = 0;
        this.counter = 0;
        this.mainCounter = 0;
        this.results = [];
    }
    ngOnInit() {
        this.last_time = Date.now();
        const user = JSON.parse(localStorage.getItem('user'));
        const userId = user.id;
        const numbersArray = [];
        const numbersArrayUser = [];
        const numbersArrayExtra = [];
        this.level = user.level;
        this.mentalSpeedId = localStorage.getItem('mental_speed_id');
        this.gameHeaderId = localStorage.getItem('game_header_id');
        if (user) {
            if (this.level === 1) {
                this.cuadricula = '4x5';
                this.limitNumber = 99;
                this.totalCuadricula = 20;
                this.limitNumberExc = 15;
                this.ordenSelect = localStorage.getItem('order_rapidez_mental');
                this.numberSelectInit = Math.floor(Math.random() * this.limitNumber);
                this.valueExpected = this.numberSelectInit;
            }
            if (this.level === 2) {
                this.cuadricula = '5x5';
                this.limitNumber = 99;
                this.totalCuadricula = 25;
                this.limitNumberExc = 15;
                this.ordenSelect = localStorage.getItem('order_rapidez_mental');
                this.numberSelectInit = Math.floor(Math.random() * this.limitNumber);
                this.valueExpected = this.numberSelectInit;
            }
            if (this.level === 3) {
                this.cuadricula = '5x10';
                this.limitNumber = 999;
                this.totalCuadricula = 50;
                this.limitNumberExc = 15;
                this.ordenSelect = localStorage.getItem('order_rapidez_mental');
                this.numberSelectInit = Math.floor(Math.random() * this.limitNumber);
                this.valueExpected = this.numberSelectInit;
            }
            if (this.ordenSelect === 'asc') {
                if (this.numberSelectInit < 1) {
                    this.numberSelectInit = 1;
                }
                for (let i = 0; i < this.limitNumberExc; i++) {
                    const numberAddUser = this.numberSelectInit + i;
                    numbersArrayUser.push(numberAddUser);
                }
            }
            else {
                if (this.numberSelectInit < 15) {
                    this.numberSelectInit = 16;
                }
                for (let i = 0; i < this.limitNumberExc; i++) {
                    const numberAddUserDesc = this.numberSelectInit - i;
                    numbersArrayUser.push(numberAddUserDesc);
                }
            }
            for (let i = 0; i < this.totalCuadricula - this.limitNumberExc; i++) {
                for (let j = 0; j < this.limitNumberExc; j++) {
                    const numberAdd = Math.floor(Math.random() * this.limitNumber);
                    const valueAdd = true;
                    if (!numbersArrayUser.includes(numberAdd) && numberAdd !== 0) {
                        numbersArray.push(numberAdd);
                        break;
                    }
                }
            }
            this.completeArray = numbersArrayUser.concat(numbersArray).sort(() => Math.random() - 0.5);
            this.completeArrayTotal = [];
            for (let i = 0; i < this.totalCuadricula; i++) {
                for (let j = 0; j < this.limitNumber; j++) {
                    const numberAddExtra = Math.floor(Math.random() * this.limitNumber);
                    if (!this.completeArray.includes(numberAddExtra) && numberAddExtra !== 0) {
                        this.completeArrayTotal[i] = [];
                        this.completeArrayTotal[i][0] = this.completeArray[i];
                        this.completeArrayTotal[i][1] = numberAddExtra;
                        break;
                    }
                }
            }
            this.counting();
        }
        else {
            this.router.navigate(['/']).then();
            localStorage.clear();
            ;
        }
    }
    presentToast(messageKey) {
        return (0,tslib__WEBPACK_IMPORTED_MODULE_3__.__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_3__.__awaiter)(this, void 0, void 0, function* () {
            const toast = yield this.toastController.create({
                message: yield this.translate.get('MENTAL_SPEED_GAME.MESSAGES.SERVER_ERROR').toPromise(),
                duration: 2000,
                position: 'bottom',
                color: 'danger'
            });
            toast.present();
        });
    }
    counting() {
        const counterGame = setInterval(() => {
            this.counter = this.counter + 1;
            if (this.counter === 15) {
                clearInterval(counterGame);
                this.gamesService.mentalSpeedStop(this.mentalSpeedId, this.counter).subscribe((res) => {
                    this.presentToast('MENTAL_SPEED_GAME.MESSAGES.FINISH');
                    this.finalizeExercise();
                    setTimeout(() => {
                        this.router.navigate(['/instrucciones-calculo-mental']);
                    }, 3000);
                }, (err) => {
                    this.handleError(err);
                });
            }
        }, 1000);
    }
    selectOverlay() {
        let timestamp_now = Date.now();
        this.gamesService.mentalSpeedDetails(this.mentalSpeedId, this.valueExpected, -1, 0, timestamp_now).subscribe((res) => {
        }, (err) => {
            this.handleError(err);
        });
    }
    selectedNumberInit(elementID) {
        if (this.mainCounter !== this.limitNumberExc) {
            this.initGame = true;
            let timestamp_now = Date.now();
            let difference = timestamp_now - this.last_time;
            this.last_time = Date.now();
            this.results.push({
                mentalSpeedId: this.mentalSpeedId,
                valueExpected: this.valueExpected,
                value: this.valueExpected,
                counter: difference,
                timestamp_now: timestamp_now
            });
            if (this.ordenSelect === 'asc') {
                this.valueExpected = this.valueExpected + 1;
            }
            else {
                this.valueExpected = this.valueExpected - 1;
            }
            const element = document.getElementById(elementID);
            element.classList.add('item-correct');
            this.mainCounter = this.mainCounter + 1;
        }
    }
    selectedNumber(value, elementID) {
        if (this.mainCounter !== this.limitNumberExc) {
            if (this.initGame) {
                let timestamp_now = Date.now();
                let difference = timestamp_now - this.last_time;
                this.last_time = Date.now();
                this.results.push({
                    mentalSpeedId: this.mentalSpeedId,
                    valueExpected: this.valueExpected,
                    value,
                    counter: difference,
                    timestamp_now: timestamp_now
                });
                if (value === this.valueExpected) {
                    if (this.ordenSelect === 'asc') {
                        this.valueExpected = this.valueExpected + 1;
                    }
                    else {
                        this.valueExpected = this.valueExpected - 1;
                    }
                    const element = document.getElementById(elementID);
                    element.classList.add('item-correct');
                    this.mainCounter = this.mainCounter + 1;
                }
            }
        }
    }
    finalizeExercise() {
        this.results.forEach((answer) => {
            setTimeout(() => {
                this.gamesService.mentalSpeedDetails(answer.mentalSpeedId, answer.valueExpected, answer.value, answer.counter, answer.timestamp_now).subscribe(() => {
                });
            }, 250);
        });
    }
    handleError(err) {
        if (err.status === 401) {
            this.router.navigate(['/']);
            localStorage.clear();
        }
        else {
            this.presentErrorToast();
        }
    }
};
RapidezMentalPage.ctorParameters = () => [
    { type: _angular_router__WEBPACK_IMPORTED_MODULE_4__.Router },
    { type: _angular_core__WEBPACK_IMPORTED_MODULE_5__.Renderer2 },
    { type: _angular_core__WEBPACK_IMPORTED_MODULE_5__.ElementRef },
    { type: _services_games_service__WEBPACK_IMPORTED_MODULE_2__.GamesService },
    { type: _ionic_angular__WEBPACK_IMPORTED_MODULE_6__.ToastController },
    { type: _ngx_translate_core__WEBPACK_IMPORTED_MODULE_7__.TranslateService }
];
RapidezMentalPage = (0,tslib__WEBPACK_IMPORTED_MODULE_3__.__decorate)([
    (0,_angular_core__WEBPACK_IMPORTED_MODULE_5__.Component)({
        selector: 'app-rapidez-mental',
        template: _raw_loader_rapidez_mental_page_html__WEBPACK_IMPORTED_MODULE_0__.default,
        styles: [_rapidez_mental_page_scss__WEBPACK_IMPORTED_MODULE_1__.default]
    })
], RapidezMentalPage);



/***/ }),

/***/ 2466:
/*!*********************************************************!*\
  !*** ./src/app/rapidez-mental/rapidez-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-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\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.items-rapidez-mental {\n  display: flex;\n  flex-wrap: wrap;\n  width: 1100px;\n  margin: auto;\n  max-width: 100%;\n  z-index: 3;\n  position: relative;\n}\n\n.item-rapidez-mental span {\n  background: #232541;\n  border: 1px solid #494979;\n  box-sizing: border-box;\n  border-radius: 6px;\n  font-size: 45px;\n  text-align: center;\n  display: block;\n  cursor: pointer;\n  padding: 6px 0;\n  font-weight: 500;\n}\n\n.item-rapidez-mental {\n  width: 10%;\n  padding: 15px;\n  padding-top: 0;\n  margin-bottom: 35px;\n  position: relative;\n  z-index: 3;\n}\n\n.box-grid-rapidez-mental {\n  position: relative;\n  top: 50%;\n  transform: translateY(-50%);\n  z-index: 3;\n}\n\n.items-rapidez-mental-4x5 .item-rapidez-mental {\n  width: 20%;\n}\n\n.items-rapidez-mental-4x5 {\n  width: 600px !important;\n}\n\n.item-rapidez-mental span.active {\n  background: #232541 !important;\n  border: 3px solid #91EAE4 !important;\n  box-shadow: 0px 4px 33px #91EAE4;\n  margin-top: -4px;\n  position: relative;\n  top: 2px;\n  animation-name: parpadeo;\n  animation-duration: 1s;\n  animation-timing-function: linear;\n  animation-iteration-count: infinite;\n  -webkit-animation-name: parpadeo;\n  -webkit-animation-duration: 1s;\n  -webkit-animation-timing-function: linear;\n  -webkit-animation-iteration-count: infinite;\n}\n\n@keyframes parpadeo {\n  0% {\n    box-shadow: 0px 4px 33px #91EAE4;\n  }\n  50% {\n    box-shadow: 0px 0px 0px #91EAE4;\n  }\n  100% {\n    box-shadow: 0px 4px 33px #91EAE4;\n  }\n}\n\n.box-grid-rapidez-mental .item-rapidez-mental span {\n  font-size: 36px !important;\n  padding-top: 12px;\n  padding-bottom: 12px;\n  color: #fff;\n}\n\n.box-grid-rapidez-mental .item-rapidez-mental {\n  margin: 0 10px 20px 10px;\n  width: calc(20% - 20px );\n  padding: 0;\n}\n\n.box-grid-rapidez-mental .item-rapidez-mental span:last-child {\n  display: none;\n}\n\n.box-grid-rapidez-mental .item-rapidez-mental span.item-correct {\n  display: none;\n}\n\n.box-grid-rapidez-mental .item-rapidez-mental span.item-correct + span {\n  display: block !important;\n}\n\n.overlay-rapidez-mental {\n  position: absolute;\n  left: 0;\n  right: 0;\n  top: 0;\n  bottom: 0;\n  background: transparent;\n  z-index: 2;\n}\n\n.ion-content-rapidez-mental {\n  position: relative;\n  z-index: 3;\n}\n\n.items-rapidez-mental-5x5 {\n  width: 700px;\n}\n\n.items-rapidez-mental-5x10 {\n  width: 700px;\n  margin-top: -20px;\n}\n\n.items-rapidez-mental-5x10 .item-rapidez-mental span {\n  font-size: 20px !important;\n  padding: 5px;\n}\n\n.items-rapidez-mental-5x10 .item-rapidez-mental {\n  margin-bottom: 10px;\n}\n/*# sourceMappingURL=data:application/json;base64,  */");

/***/ }),

/***/ 6961:
/*!***********************************************************************************************!*\
  !*** ./node_modules/raw-loader/dist/cjs.js!./src/app/rapidez-mental/rapidez-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_SPEED_GAME.ARIA_LABELS.LOGO' | translate\">\n        </ion-title>\n      </ion-col>\n      <ion-col size=\"8\" class=\"col-header-btn-close\">\n        <app-camera-video></app-camera-video>\n      </ion-col>\n    </ion-row>\n  </ion-grid>\n  <div class=\"overlay-rapidez-mental\" (click)=\"selectOverlay()\" [attr.aria-label]=\"'MENTAL_SPEED_GAME.ARIA_LABELS.OVERLAY' | translate\"></div>\n</ion-header>\n\n<ion-content [fullscreen]=\"true\">\n  <div class=\"overlay-rapidez-mental\" (click)=\"selectOverlay()\" [attr.aria-label]=\"'MENTAL_SPEED_GAME.ARIA_LABELS.OVERLAY' | translate\"></div>\n  <div class=\"box-grid-rapidez-mental\">\n    <div class=\"overlay-rapidez-mental\" (click)=\"selectOverlay()\" [attr.aria-label]=\"'MENTAL_SPEED_GAME.ARIA_LABELS.OVERLAY' | translate\"></div>\n    <div class=\"items-rapidez-mental\" \n         [ngClass]=\"{'items-rapidez-mental-5x10': cuadricula === '5x10', 'items-rapidez-mental-5x5': cuadricula === '5x5', 'items-rapidez-mental-4x5': cuadricula === '4x5'}\"\n         [attr.aria-label]=\"'MENTAL_SPEED_GAME.ARIA_LABELS.GRID' | translate:{size: cuadricula}\">\n      <div class=\"overlay-rapidez-mental\" (click)=\"selectOverlay()\" [attr.aria-label]=\"'MENTAL_SPEED_GAME.ARIA_LABELS.OVERLAY' | translate\"></div>\n      <div class=\"item-rapidez-mental\" *ngFor=\"let item of completeArrayTotal; let i = index\">\n        <span (click)=\"selectedNumber(item[0],'item-rapidez'+i)\" \n              *ngIf=\"item[0] !== numberSelectInit\" \n              id=\"item-rapidez{{i}}\"\n              [attr.aria-label]=\"'MENTAL_SPEED_GAME.ARIA_LABELS.NUMBER' | translate:{number: item[0]}\">{{ item[0] }}</span>\n        <span class=\"active\" \n              (click)=\"selectedNumberInit('item-rapidez'+i)\" \n              *ngIf=\"item[0] === numberSelectInit\" \n              id=\"item-rapidez{{ i }}\"\n              [attr.aria-label]=\"'MENTAL_SPEED_GAME.ARIA_LABELS.NUMBER_SELECTED' | translate:{number: item[0]}\">{{ item[0] }}</span>\n        <span (click)=\"selectedNumber(item[1],'test')\"\n              [attr.aria-label]=\"'MENTAL_SPEED_GAME.ARIA_LABELS.NUMBER' | translate:{number: item[1]}\">{{ item[1] }}</span>\n      </div>\n    </div>\n  </div>\n</ion-content>\n");

/***/ })

}]);
//# sourceMappingURL=src_app_rapidez-mental_rapidez-mental_module_ts.js.map