/**
 * @fileoverview added by tsickle
 * @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { RmService } from '@bidi/common-services';
import { createFeatureSelector, select, Store } from '@ngrx/store';
import { CommentsResourcesService } from './comments-resources.service';
import { LoadingComments, SetCommentsResources } from './ngrx/actions';
var CommentsResourcesComponent = /** @class */ (function () {
    function CommentsResourcesComponent(rm, commentsService, store) {
        this.rm = rm;
        this.commentsService = commentsService;
        this.store = store;
        this.close = new EventEmitter();
        this.state$ = this.store.pipe(select(createFeatureSelector('@bidi/common-components Ratings')));
    }
    /**
     * @return {?}
     */
    CommentsResourcesComponent.prototype.ngOnInit = /**
     * @return {?}
     */
    function () {
        this.store.dispatch(new LoadingComments(true));
        this.commentsService.getComments(this.resourceId);
    };
    /**
     * @return {?}
     */
    CommentsResourcesComponent.prototype.saveComment = /**
     * @return {?}
     */
    function () {
        /** @type {?} */
        var data = {
            'resource': this.resourceId,
            'comment': this.comment,
            'type': this.role
        };
        this.store.dispatch(new LoadingComments(true));
        this.store.dispatch(new SetCommentsResources(data));
        this.comment = '';
    };
    CommentsResourcesComponent.decorators = [
        { type: Component, args: [{
                    selector: 'bidi-comments-resources',
                    template: "<div class=\"contents-comments is-flex has-column-direction\">\n  <div class=\"close-button\">\n    <button (click)=\"close.emit()\" class=\"button is-text\">\n      <svg class=\"icon-svg-tt-angle-right\">\n        <use :xlink:href=\"#icon-svg-tt-angle-right\"></use>\n      </svg>\n    </button>\n  </div>\n\n  <h2 class=\"is-size-6 is-ff-light\">Comentarios:</h2>\n  <div class=\"contents-list\">\n    <div class=\"comment\" *ngFor=\"let comment of (commentsService.comments$ | async)\">\n      <p class=\"user_comment is-pulled-left is-size-7\">{{ comment.user.given_name }} {{comment.user.family_name}}</p>\n      <p class=\"time is-pulled-right\">{{ comment.date | date:\"EEEE, d 'de' MMMM\" }}</p>\n      <p class=\"text-comment\">\n        {{ comment.comment }}\n      </p>\n    </div>\n  </div>\n  <div class=\"save-comment\">\n    <textarea [(ngModel)]=\"comment\"\n              placeholder=\"Escribe aqui comentarios sobre este contenido\"></textarea>\n    <div class=\"buttons is-slide-right is-pulled-right\">\n      <button (click)=\"saveComment()\"\n      class=\"button is-pulled-right is-tt-secondary \">\n        <svg width=\"24\" height=\"24\" xmlns=\"http://www.w3.org/2000/svg\" fill-rule=\"evenodd\" clip-rule=\"evenodd\"><path d=\"M21 6.285l-11.16 12.733-6.84-6.018 1.319-1.49 5.341 4.686 9.865-11.196 1.475 1.285z\"/></svg>\n      </button>\n    </div>\n  </div>\n  <bidi-loading *ngIf=\"commentsService.loading$ | async\"></bidi-loading>\n</div>\n",
                    styles: [".contents-comments{height:100%;position:relative;padding:1rem;justify-content:space-between}.close-button{position:absolute;left:0}.close-button .button{padding:0;background:0 0}.contents-list{overflow:auto}.comment{position:relative;border-bottom:1px solid #e5e5e5;border-radius:5px;padding:12px 10px 10px}.comment .user_comment{margin:0 10px;font-weight:700;color:#2d4254}.comment .time{color:#666;font-size:.6875rem}.comment .text-comment{margin:7px;padding:3px;color:#333;border:1px solid #fafafa;clear:both}.comment .text-comment.editable{background:#fff;border-color:#e5e5e5}.save-comment{padding:15px}textarea{width:87%;padding:7px}textarea::-webkit-input-placeholder{color:#777;font-style:italic}textarea::-moz-placeholder{color:#777;font-style:italic}textarea:-ms-input-placeholder{color:#777;font-style:italic}textarea:-moz-placeholder{color:#777;font-style:italic}button.button{padding:.5rem!important;margin-bottom:0!important;min-height:45px!important;border:none!important;background:0 0!important}button.button svg{fill:#23d160!important}"]
                }] }
    ];
    /** @nocollapse */
    CommentsResourcesComponent.ctorParameters = function () { return [
        { type: RmService },
        { type: CommentsResourcesService },
        { type: Store }
    ]; };
    CommentsResourcesComponent.propDecorators = {
        resourceId: [{ type: Input }],
        role: [{ type: Input }],
        title: [{ type: Input }],
        close: [{ type: Output }]
    };
    return CommentsResourcesComponent;
}());
export { CommentsResourcesComponent };
if (false) {
    /** @type {?} */
    CommentsResourcesComponent.prototype.resourceId;
    /** @type {?} */
    CommentsResourcesComponent.prototype.role;
    /** @type {?} */
    CommentsResourcesComponent.prototype.title;
    /** @type {?} */
    CommentsResourcesComponent.prototype.close;
    /** @type {?} */
    CommentsResourcesComponent.prototype.comment;
    /**
     * @type {?}
     * @private
     */
    CommentsResourcesComponent.prototype.state$;
    /**
     * @type {?}
     * @private
     */
    CommentsResourcesComponent.prototype.rm;
    /** @type {?} */
    CommentsResourcesComponent.prototype.commentsService;
    /**
     * @type {?}
     * @private
     */
    CommentsResourcesComponent.prototype.store;
}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29tbWVudHMtcmVzb3VyY2VzLmNvbXBvbmVudC5qcyIsInNvdXJjZVJvb3QiOiJuZzovL0BiaWRpL2NvbW1vbi1jb21wb25lbnRzLyIsInNvdXJjZXMiOlsibGliL21vZHVsZXMvY29tbWVudHMtcmVzb3VyY2VzL2NvbW1lbnRzLXJlc291cmNlcy5jb21wb25lbnQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7OztBQUFBLE9BQU8sRUFBQyxTQUFTLEVBQUUsWUFBWSxFQUFFLEtBQUssRUFBVSxNQUFNLEVBQUMsTUFBTSxlQUFlLENBQUM7QUFDN0UsT0FBTyxFQUFFLFNBQVMsRUFBRSxNQUFNLHVCQUF1QixDQUFDO0FBQ2xELE9BQU8sRUFBRSxxQkFBcUIsRUFBRSxNQUFNLEVBQUUsS0FBSyxFQUFFLE1BQU0sYUFBYSxDQUFDO0FBRW5FLE9BQU8sRUFBRSx3QkFBd0IsRUFBRSxNQUFNLDhCQUE4QixDQUFDO0FBQ3hFLE9BQU8sRUFBQyxlQUFlLEVBQUUsb0JBQW9CLEVBQUMsTUFBTSxnQkFBZ0IsQ0FBQztBQUdyRTtJQWNFLG9DQUNVLEVBQWEsRUFDZCxlQUF5QyxFQUN4QyxLQUFpQjtRQUZqQixPQUFFLEdB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