import { Component, Input } from '@angular/core';
import { ConfirmDialogComponent } from '../confirm-dialog/confirm-dialog.component';
import * as i0 from "@angular/core";
import * as i1 from "@angular/material/legacy-dialog";
import * as i2 from "./../../../_services/widget-content.service";
import * as i3 from "@angular/common";
import * as i4 from "@angular/material/legacy-card";
import * as i5 from "@angular/material/icon";
import * as i6 from "@angular/material/divider";
import * as i7 from "@angular/router";
export class MarkAsCompleteComponent {
    constructor(dialog, 
    // private appTocSvc: AppTocService,
    contentSvc) {
        this.dialog = dialog;
        this.contentSvc = contentSvc;
        this.forPreview = false;
    }
    confirm() {
        if (!this.forPreview) {
            const dialogRef = this.dialog.open(ConfirmDialogComponent, {
                width: '450px',
                data: {
                    body: this.reqBody,
                    contentId: this.content.identifier,
                },
            });
            dialogRef.afterClosed().subscribe(result => {
                if (result === 'Marked' && this.content.progress) {
                    this.content.progress.progressStatus = 'completed';
                    this.content.progress.showMarkAsComplete = false;
                    this.content.progress.markAsCompleteReason = 'already.completed';
                }
            });
        }
    }
    get showStart() {
        return { show: true };
        // return this.appTocSvc.showStartButton(this.content)
    }
    ngOnInit() {
    }
    ngOnChanges(props) {
        for (const prop in props) {
            if (prop === 'content') {
                if (this.content) {
                    if (!this.forPreview) {
                        this.contentSvc
                            .fetchMarkAsCompleteMeta(this.content.identifier)
                            .then(progress => {
                            this.content.progress = progress;
                        })
                            .catch(() => { });
                        this.reqBody = {
                            content_type: this.content.contentType,
                            current: ['1'],
                            max_size: 1,
                            mime_type: this.content.mimeType,
                            user_id_type: 'uuid',
                        };
                    }
                }
            }
        }
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MarkAsCompleteComponent, deps: [{ token: i1.MatLegacyDialog }, { token: i2.WidgetContentService }], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: MarkAsCompleteComponent, selector: "ws-widget-mark-as-complete", inputs: { content: "content", forPreview: "forPreview" }, usesOnChanges: true, ngImport: i0, template: "<ng-container *ngIf=\"content?.progress?.progressSupported && showStart.show\">\n  <mat-card class=\"mb-4 block\">\n    <h2 class=\"margin-remove-bottom\"><span >Learning Progress </span>\n      <a i18n-aria-label aria-label=\"Learning Progress FAQ\" [routerLink]=\"'/app/info/faq'\"\n        [queryParams]=\"{tab: 'mark_as_complete'}\">\n        <mat-icon class=\"align-text-top ws-mat-primary-text\">help</mat-icon>\n      </a>\n    </h2>\n    <h3><span >Status: </span>\n      <ng-container *ngIf=\"content?.progress?.progressStatus; let status\">\n        <span *ngIf=\"status === 'open'\">Open</span>\n        <span *ngIf=\"status === 'started'\">Started</span>\n        <span *ngIf=\"status === 'completed'\">Completed</span>\n      </ng-container>\n    </h3>\n    <ng-container *ngIf=\"content?.progress?.markAsCompleteReason !== 'not.supported'\">\n      <mat-divider></mat-divider>\n      <!-- <ng-container *ngIf=\"content?.progress?.showMarkAsComplete\">\n        <h4 class=\"pt-3\">I confirm that I have gone through this content and want to mark it as complete.</h4>\n        <div class=\"flex justify-center\">\n          <button mat-raised-button color=\"primary\" (click)=\"confirm()\">Mark as Complete</button>\n        </div>\n      </ng-container> -->\n      <ng-container *ngIf=\"!content?.progress?.showMarkAsComplete\">\n        <h4 class=\"pt-3\" *ngIf=\"content?.progress?.markAsCompleteReason; let msg\">\n          <span *ngIf=\"msg === 'pass.required'\">Content will be marked as complete once you pass this\n            assessment.</span>\n          <span *ngIf=\"msg === 'submission.required'\">Content will be marked as complete once you submit this\n            quiz/exercise.</span>\n          <span i18n\n            *ngIf=\"msg === 'external.vendor.provided' && content?.progress?.progressStatus !== 'completed'\">Your\n            learning progress for this content is captured externally and will be updated in this portal once it is\n            received.</span>\n          <span i18n\n            *ngIf=\"msg === 'external.vendor.provided' && content?.progress?.progressStatus === 'completed'\">Your\n            progress was automatically captured from its source.</span>\n          <span *ngIf=\"msg === 'has.children'\">This content is hierarchical. Progress will be calculated on the\n            basis\n            of children resources</span>\n          <span *ngIf=\"msg === 'already.completed'\">Completed</span>\n          <span *ngIf=\"msg === 'instructor.led'\">Progress will be calculated based on your classroom\n            attendance.</span>\n        </h4>\n      </ng-container>\n    </ng-container>\n  </mat-card>\n</ng-container>", styles: [""], dependencies: [{ kind: "directive", type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i4.MatLegacyCard, selector: "mat-card", exportAs: ["matCard"] }, { kind: "component", type: i5.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "component", type: i6.MatDivider, selector: "mat-divider", inputs: ["vertical", "inset"] }, { kind: "directive", type: i7.RouterLink, selector: "[routerLink]", inputs: ["target", "queryParams", "fragment", "queryParamsHandling", "state", "relativeTo", "preserveFragment", "skipLocationChange", "replaceUrl", "routerLink"] }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MarkAsCompleteComponent, decorators: [{
            type: Component,
            args: [{ selector: 'ws-widget-mark-as-complete', template: "<ng-container *ngIf=\"content?.progress?.progressSupported && showStart.show\">\n  <mat-card class=\"mb-4 block\">\n    <h2 class=\"margin-remove-bottom\"><span >Learning Progress </span>\n      <a i18n-aria-label aria-label=\"Learning Progress FAQ\" [routerLink]=\"'/app/info/faq'\"\n        [queryParams]=\"{tab: 'mark_as_complete'}\">\n        <mat-icon class=\"align-text-top ws-mat-primary-text\">help</mat-icon>\n      </a>\n    </h2>\n    <h3><span >Status: </span>\n      <ng-container *ngIf=\"content?.progress?.progressStatus; let status\">\n        <span *ngIf=\"status === 'open'\">Open</span>\n        <span *ngIf=\"status === 'started'\">Started</span>\n        <span *ngIf=\"status === 'completed'\">Completed</span>\n      </ng-container>\n    </h3>\n    <ng-container *ngIf=\"content?.progress?.markAsCompleteReason !== 'not.supported'\">\n      <mat-divider></mat-divider>\n      <!-- <ng-container *ngIf=\"content?.progress?.showMarkAsComplete\">\n        <h4 class=\"pt-3\">I confirm that I have gone through this content and want to mark it as complete.</h4>\n        <div class=\"flex justify-center\">\n          <button mat-raised-button color=\"primary\" (click)=\"confirm()\">Mark as Complete</button>\n        </div>\n      </ng-container> -->\n      <ng-container *ngIf=\"!content?.progress?.showMarkAsComplete\">\n        <h4 class=\"pt-3\" *ngIf=\"content?.progress?.markAsCompleteReason; let msg\">\n          <span *ngIf=\"msg === 'pass.required'\">Content will be marked as complete once you pass this\n            assessment.</span>\n          <span *ngIf=\"msg === 'submission.required'\">Content will be marked as complete once you submit this\n            quiz/exercise.</span>\n          <span i18n\n            *ngIf=\"msg === 'external.vendor.provided' && content?.progress?.progressStatus !== 'completed'\">Your\n            learning progress for this content is captured externally and will be updated in this portal once it is\n            received.</span>\n          <span i18n\n            *ngIf=\"msg === 'external.vendor.provided' && content?.progress?.progressStatus === 'completed'\">Your\n            progress was automatically captured from its source.</span>\n          <span *ngIf=\"msg === 'has.children'\">This content is hierarchical. Progress will be calculated on the\n            basis\n            of children resources</span>\n          <span *ngIf=\"msg === 'already.completed'\">Completed</span>\n          <span *ngIf=\"msg === 'instructor.led'\">Progress will be calculated based on your classroom\n            attendance.</span>\n        </h4>\n      </ng-container>\n    </ng-container>\n  </mat-card>\n</ng-container>" }]
        }], ctorParameters: function () { return [{ type: i1.MatLegacyDialog }, { type: i2.WidgetContentService }]; }, propDecorators: { content: [{
                type: Input
            }], forPreview: [{
                type: Input
            }] } });
//# sourceMappingURL=data:application/json;base64, 