/**
 * @fileoverview added by tsickle
 * @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
import { Component, Input } from '@angular/core';
import { AuthService, RmService } from '@bidi/common-services';
import * as es from 'date-fns/locale/es';
import { RatingsService } from './../ratings.service';
import { createFeatureSelector, select, Store } from '@ngrx/store';
import { SetRatings } from './../ngrx/actions';
/** @type {?} */
const locales = { es };
/** @type {?} */
const placeholders = {
    es: 'Selecciona fecha'
};
/** @type {?} */
const defaultFormat = {
    es: 'D/MM/YYYY'
};
export class RankComponent {
    /**
     * @param {?} rm
     * @param {?} auth
     * @param {?} ratingsService
     * @param {?} store
     */
    constructor(rm, auth, ratingsService, store) {
        this.rm = rm;
        this.auth = auth;
        this.ratingsService = ratingsService;
        this.store = store;
        this.voteC = false;
        this.flagUser = true;
        this.userName = '';
        this.state$ = this.store.pipe(select(createFeatureSelector('@bidi/common-components Ratings')));
    }
    /**
     * @return {?}
     */
    ngOnInit() {
        /** @type {?} */
        let userName = '';
        this.auth.userInfo$.subscribe(user => {
            if (user) {
                this.userName = user.preferred_username;
                userName = this.userName;
            }
        });
        userName = this.userName;
        /*if (this.resourceId) {
          this.ratingsService.getRatings(this.resourceId);
          const resourceId = this.resourceId;
          let flagUser = true;
          this.ratingsService.ratings$.subscribe(
            data => {
              data.map(function (d) {
                if (d.id === resourceId) {
                  if (d.ratings && d.ratings.length > 0) {
                    d.ratings.map(function (r) {
                      if (userName === r.preferred_username) {
                        flagUser = false;
                      }
                    });
                  }
                }
              });
            }
          );
          this.flagUser = flagUser;
        }*/
    }
    /**
     * @return {?}
     */
    voteContentShow() {
        this.voteC = !this.voteC;
    }
    /**
     * @param {?} val
     * @return {?}
     */
    voteContent(val) {
        /** @type {?} */
        const data = {
            'resource': this.resourceId,
            'range': val,
            'type': this.role
        };
        this.store.dispatch(new SetRatings(data));
        this.voteC = !this.voteC;
    }
}
RankComponent.decorators = [
    { type: Component, args: [{
                selector: 'bidi-rank',
                template: "\n<div *ngIf=\"flagUser\" class=\"vote\">\n  <a  (click)=\"voteContentShow()\">\n      <svg class=\"icon-heart icon\">\n        <use xlink:href=\"#icon-heart\"></use>\n      </svg>\n  </a>\n</div>\n\n<!--<div class=\"vote-start active-vote\" *ngIf=\"flagUser && voteC\">-->\n<div class=\"vote-start active-vote\" *ngIf=\"voteC\">\n    <div class=\"ec-stars-wrapper-vote\">\n        <a (click)=\"voteContent(1)\" data-value=\"1\" title=\"Votar con 1 estrellas\">\n            <svg class=\"icon-heart icon\">\n                <use xlink:href=\"#icon-heart\"></use>\n              </svg>\n      </a>\n        <a (click)=\"voteContent(2)\" data-value=\"2\" title=\"Votar con 2 estrellas\">\n          <svg class=\"icon-heart icon\">\n          <use xlink:href=\"#icon-heart\"></use>\n        </svg></a>\n        <a (click)=\"voteContent(3)\" data-value=\"3\" title=\"Votar con 3 estrellas\"><svg class=\"icon-heart icon\">\n          <use xlink:href=\"#icon-heart\"></use>\n        </svg></a>\n        <a (click)=\"voteContent(4)\" data-value=\"4\" title=\"Votar con 4 estrellas\"><svg class=\"icon-heart icon\">\n          <use xlink:href=\"#icon-heart\"></use>\n        </svg></a>\n        <a (click)=\"voteContent(5)\" data-value=\"5\" title=\"Votar con 5 estrellas\"><svg class=\"icon-heart icon\">\n          <use xlink:href=\"#icon-heart\"></use>\n        </svg></a>\n    </div>\n</div>\n",
                styles: [".vote{margin-left:5px}.vote-start{margin-top:-15%}.active-vote{bottom:-19px;position:absolute;width:118px;right:21px}.ec-stars-wrapper-vote a{text-decoration:none;display:inline-block;font-size:1rem;color:#ccc}.ec-stars-wrapper-vote a svg{width:25px;height:18px;margin-right:2px;fill:purple}.ec-stars-wrapper-vote>a:hover~a svg{fill:#ccc}"]
            }] }
];
/** @nocollapse */
RankComponent.ctorParameters = () => [
    { type: RmService },
    { type: AuthService },
    { type: RatingsService },
    { type: Store }
];
RankComponent.propDecorators = {
    role: [{ type: Input }],
    resourceId: [{ type: Input }]
};
if (false) {
    /** @type {?} */
    RankComponent.prototype.role;
    /** @type {?} */
    RankComponent.prototype.resourceId;
    /** @type {?} */
    RankComponent.prototype.voteC;
    /** @type {?} */
    RankComponent.prototype.flagUser;
    /** @type {?} */
    RankComponent.prototype.userName;
    /**
     * @type {?}
     * @private
     */
    RankComponent.prototype.state$;
    /**
     * @type {?}
     * @private
     */
    RankComponent.prototype.rm;
    /** @type {?} */
    RankComponent.prototype.auth;
    /** @type {?} */
    RankComponent.prototype.ratingsService;
    /**
     * @type {?}
     * @private
     */
    RankComponent.prototype.store;
}
//# sourceMappingURL=data:application/json;base64, 