import { Component, Input } from '@angular/core';
import * as i0 from "@angular/core";
import * as i1 from "../../_services/rating.service";
import * as i2 from "@angular/common";
import * as i3 from "@angular/material/icon";
import * as i4 from "../_common/avatar-photo/avatar-photo.component";
import * as i5 from "@angular/material/legacy-card";
import * as i6 from "@sunbird-cb/utils-v2";
import * as i7 from "@ngx-translate/core";
export class CardRatingCommentComponent {
    constructor(ratingService) {
        this.ratingService = ratingService;
        this.review = null;
        this.showauthreply = false;
    }
    ngOnInit() {
        if (this.review && this.review.review !== null) {
            this.getAuthorReply(this.review);
        }
    }
    getAuthorReply(review) {
        this.authorReply = review.comment;
        // const uID =  review.userId  ?  review.userId :  review.user_id
        // const contentid = review.activityId ? review.activityId : this.contentid
        // this.ratingService.getAuthorReply(contentid, uID).subscribe(
        //     (res: any) => {
        //       if (res.result.response && res.result.response.comment && res.result.response.comment !== null) {
        //         this.authorReply = res.result.response.comment
        //       }
        // })
    }
    showAuthReply() {
        this.showauthreply = !this.showauthreply;
    }
    getRatingIcon(ratingIndex, avg) {
        return this.ratingService.getRatingIcon(ratingIndex, avg);
    }
    getRatingIconClass(ratingIndex, avg) {
        return this.ratingService.getRatingIconClass(ratingIndex, avg);
    }
    getFullName(review) {
        if (!review && !review.firstName) {
            return '';
        }
        return `${review.firstName}`;
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: CardRatingCommentComponent, deps: [{ token: i1.RatingService }], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: CardRatingCommentComponent, selector: "ws-widget-card-rating-comment", inputs: { review: "review", contentid: "contentid" }, ngImport: i0, template: "<mat-card class=\"comments-card margin-bottom-m position-relative mat-card\">\n    <a href=\"javascript:void(0)\" role=\"button\">\n        <mat-card-content>\n            <div class=\"card_inner_content flex\">\n                <div class=\"margin-right-m\">\n                    <ng-container *ngIf=\"review?.firstName\">\n                        <ws-widget-avatar-photo [name]=\"getFullName(review)\" [size]=\"'round-m'\"\n                            [photoUrl]=\"\"></ws-widget-avatar-photo>\n                    </ng-container>\n                    <ng-container *ngIf=\"!review?.firstName\">\n                        <ws-widget-avatar-photo [name]=\"review?.user_id\" [size]=\"'round-m'\"\n                            [photoUrl]=\"\"></ws-widget-avatar-photo>\n                    </ng-container>\n                </div>\n\n                <div class=\"flex-col align-left\">\n                    <div class=\"name margin-bottom-xs\">\n                        <ng-container *ngIf=\"review?.firstName\">\n                            {{getFullName(review)}}\n                        </ng-container>\n                        <ng-container *ngIf=\"!review?.firstName\">\n                            {{review.user_id}}\n                        </ng-container>\n                    </div>\n                    <div class=\"flex items-center \">\n                        <span class=\"margin-right-xs ws-mat-orange-text mat-body-1\"> {{review.rating}} </span>\n                        <mat-icon\n                            class=\"comments-rating mr-1 mat-icon material-icons ws-mat-black16-text\"\n                            [ngClass]=\"{'ws-mat-orange-text': getRatingIconClass(rating, review.rating )}\"\n                            *ngFor=\"let rating of [1, 2, 3, 4, 5]\">\n                            {{ getRatingIcon(rating, review.rating) }}</mat-icon>\n                        <!--  <span >from</span> -->\n                        <span *ngIf=\"review?.date\" class=\"margin-left-s  ws-mat-black60-text mat-body-1\"> {{review.date | pipeRelativeTime}}\n                        </span>\n                        <span *ngIf=\"review?.updatedon\" class=\"margin-left-s  ws-mat-black60-text mat-body-1\"> {{review.updatedon | pipeRelativeTime}}\n                        </span>\n                    </div>\n                    <div class=\"margin-top-m mat-body-1 break-all\">\n                        {{review.review}}\n                    </div>\n                    <div *ngIf=\"review?.comment\" class=\"margin-top-m\">\n                        <a class=\"custom-link\" (click)=\"showAuthReply()\">{{ 'cardratingcommet.viewReply' | translate }}</a>\n                        <div class=\"margin-top-m mat-body-1 break-all\" *ngIf=\"showauthreply\">\n                            {{review?.comment}}\n                        </div>\n                    </div>\n                </div>\n            </div>\n        </mat-card-content>\n    </a>\n</mat-card>", styles: [".comments-card{padding:24px 16px}.comments-card .comments-rating{height:16px;width:16px;font-size:16px}.comments-card .name{font:600 16px/21px Lato}.blue-border{border:2px solid #00A9F4!important}.mat-stroked-button{line-height:24px;color:#00a9f4!important;font-size:12px!important;padding:0 10px!important}.custom-link{font:600 14px/21px Lato!important;color:#0074b6!important}\n"], dependencies: [{ kind: "directive", type: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i3.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "component", type: i4.AvatarPhotoComponent, selector: "ws-widget-avatar-photo", inputs: ["datalen", "photoUrl", "name", "size", "randomColor", "initials", "showBadge"] }, { kind: "component", type: i5.MatLegacyCard, selector: "mat-card", exportAs: ["matCard"] }, { kind: "directive", type: i5.MatLegacyCardContent, selector: "mat-card-content, [mat-card-content], [matCardContent]" }, { kind: "pipe", type: i6.PipeRelativeTimePipe, name: "pipeRelativeTime" }, { kind: "pipe", type: i7.TranslatePipe, name: "translate" }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: CardRatingCommentComponent, decorators: [{
            type: Component,
            args: [{ selector: 'ws-widget-card-rating-comment', template: "<mat-card class=\"comments-card margin-bottom-m position-relative mat-card\">\n    <a href=\"javascript:void(0)\" role=\"button\">\n        <mat-card-content>\n            <div class=\"card_inner_content flex\">\n                <div class=\"margin-right-m\">\n                    <ng-container *ngIf=\"review?.firstName\">\n                        <ws-widget-avatar-photo [name]=\"getFullName(review)\" [size]=\"'round-m'\"\n                            [photoUrl]=\"\"></ws-widget-avatar-photo>\n                    </ng-container>\n                    <ng-container *ngIf=\"!review?.firstName\">\n                        <ws-widget-avatar-photo [name]=\"review?.user_id\" [size]=\"'round-m'\"\n                            [photoUrl]=\"\"></ws-widget-avatar-photo>\n                    </ng-container>\n                </div>\n\n                <div class=\"flex-col align-left\">\n                    <div class=\"name margin-bottom-xs\">\n                        <ng-container *ngIf=\"review?.firstName\">\n                            {{getFullName(review)}}\n                        </ng-container>\n                        <ng-container *ngIf=\"!review?.firstName\">\n                            {{review.user_id}}\n                        </ng-container>\n                    </div>\n                    <div class=\"flex items-center \">\n                        <span class=\"margin-right-xs ws-mat-orange-text mat-body-1\"> {{review.rating}} </span>\n                        <mat-icon\n                            class=\"comments-rating mr-1 mat-icon material-icons ws-mat-black16-text\"\n                            [ngClass]=\"{'ws-mat-orange-text': getRatingIconClass(rating, review.rating )}\"\n                            *ngFor=\"let rating of [1, 2, 3, 4, 5]\">\n                            {{ getRatingIcon(rating, review.rating) }}</mat-icon>\n                        <!--  <span >from</span> -->\n                        <span *ngIf=\"review?.date\" class=\"margin-left-s  ws-mat-black60-text mat-body-1\"> {{review.date | pipeRelativeTime}}\n                        </span>\n                        <span *ngIf=\"review?.updatedon\" class=\"margin-left-s  ws-mat-black60-text mat-body-1\"> {{review.updatedon | pipeRelativeTime}}\n                        </span>\n                    </div>\n                    <div class=\"margin-top-m mat-body-1 break-all\">\n                        {{review.review}}\n                    </div>\n                    <div *ngIf=\"review?.comment\" class=\"margin-top-m\">\n                        <a class=\"custom-link\" (click)=\"showAuthReply()\">{{ 'cardratingcommet.viewReply' | translate }}</a>\n                        <div class=\"margin-top-m mat-body-1 break-all\" *ngIf=\"showauthreply\">\n                            {{review?.comment}}\n                        </div>\n                    </div>\n                </div>\n            </div>\n        </mat-card-content>\n    </a>\n</mat-card>", styles: [".comments-card{padding:24px 16px}.comments-card .comments-rating{height:16px;width:16px;font-size:16px}.comments-card .name{font:600 16px/21px Lato}.blue-border{border:2px solid #00A9F4!important}.mat-stroked-button{line-height:24px;color:#00a9f4!important;font-size:12px!important;padding:0 10px!important}.custom-link{font:600 14px/21px Lato!important;color:#0074b6!important}\n"] }]
        }], ctorParameters: function () { return [{ type: i1.RatingService }]; }, propDecorators: { review: [{
                type: Input
            }], contentid: [{
                type: Input
            }] } });
//# sourceMappingURL=data:application/json;base64, 