import { Component, Input, EventEmitter, Output } from '@angular/core';
import * as i0 from "@angular/core";
import * as i1 from "@angular/common";
import * as i2 from "@angular/flex-layout/extended";
import * as i3 from "ngx-doc-viewer";
import * as i4 from "@angular/material/button";
import * as i5 from "@angular/material/card";
export class DocumentViewerComponent {
    constructor() {
        this.remove = new EventEmitter();
    }
    ngOnInit() {
        this.initData();
    }
    removeFile() {
        this.remove.emit();
    }
    initData() {
        if (this.file) {
            var ext = this.getFileExtension(this.file);
            if (ext === 'ppt' || ext === 'pptx' || ext === 'doc' || ext === 'docx' || ext === 'xls' || ext === 'xlsx') {
                this.viewerType = "office";
            }
            else if (ext === 'jpg' || ext === 'jpeg' || ext === 'png' || ext === 'gif') {
                this.viewerType = "image";
            }
            else if (ext === 'pdf') {
                this.viewerType = "pdf";
            }
            else {
                this.viewerType = null;
            }
        }
    }
    get fileName() {
        if (this.file) {
            let nameArray = this.file.split('/');
            if (nameArray.length === 2) {
                return nameArray[1];
            }
            return nameArray[0];
        }
        return '';
    }
    getFileExtension(file) {
        return file.split('.').pop();
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: DocumentViewerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.13", type: DocumentViewerComponent, selector: "app-document-viewer", inputs: { config: "config", file: "file", fileUrl: "fileUrl", disableEdit: "disableEdit" }, outputs: { remove: "remove" }, ngImport: i0, template: "<mat-card *ngIf=\"viewerType === 'image'\">\n    <img [ngStyle]=\"config.imageStyle\" mat-card-image [src]=\"fileUrl\" />\n    <mat-card-actions>\n        <button type=\"button\" mat-raised-button (click)=\"removeFile()\" *ngIf=\"!disableEdit && !config.hideRemove\">\n            Remove\n        </button>\n    </mat-card-actions>\n</mat-card>\n\n<div class=\"mat-elevation-z1 p-4\" *ngIf=\"viewerType !== 'image'\">\n    <a [href]=\"fileUrl\" target=\"_blank\">{{fileName}}</a>\n    <ngx-doc-viewer [ngStyle]=\"config.viewerStyle\" *ngIf=\"viewerType !== null\" [url]=\"fileUrl\" [viewer]=\"viewerType\">\n    </ngx-doc-viewer>\n    <div class=\"mt-2\" *ngIf=\"!config.hideRemove\">\n        <button type=\"button\" mat-raised-button (click)=\"removeFile()\" *ngIf=\"!disableEdit\">\n            Remove\n        </button>\n    </div>\n</div>", styles: [".image-fit{height:100%;width:100%;object-fit:cover}\n"], dependencies: [{ kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "directive", type: i2.DefaultStyleDirective, selector: "  [ngStyle],  [ngStyle.xs], [ngStyle.sm], [ngStyle.md], [ngStyle.lg], [ngStyle.xl],  [ngStyle.lt-sm], [ngStyle.lt-md], [ngStyle.lt-lg], [ngStyle.lt-xl],  [ngStyle.gt-xs], [ngStyle.gt-sm], [ngStyle.gt-md], [ngStyle.gt-lg]", inputs: ["ngStyle", "ngStyle.xs", "ngStyle.sm", "ngStyle.md", "ngStyle.lg", "ngStyle.xl", "ngStyle.lt-sm", "ngStyle.lt-md", "ngStyle.lt-lg", "ngStyle.lt-xl", "ngStyle.gt-xs", "ngStyle.gt-sm", "ngStyle.gt-md", "ngStyle.gt-lg"] }, { kind: "component", type: i3.NgxDocViewerComponent, selector: "ngx-doc-viewer", inputs: ["url", "queryParams", "viewerUrl", "googleCheckInterval", "googleMaxChecks", "disableContent", "googleCheckContentLoaded", "viewer", "overrideLocalhost"], outputs: ["loaded"] }, { kind: "component", type: i4.MatButton, selector: "    button[mat-button], button[mat-raised-button], button[mat-flat-button],    button[mat-stroked-button]  ", exportAs: ["matButton"] }, { kind: "component", type: i5.MatCard, selector: "mat-card", inputs: ["appearance"], exportAs: ["matCard"] }, { kind: "directive", type: i5.MatCardActions, selector: "mat-card-actions", inputs: ["align"], exportAs: ["matCardActions"] }, { kind: "directive", type: i5.MatCardImage, selector: "[mat-card-image], [matCardImage]" }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: DocumentViewerComponent, decorators: [{
            type: Component,
            args: [{ selector: 'app-document-viewer', template: "<mat-card *ngIf=\"viewerType === 'image'\">\n    <img [ngStyle]=\"config.imageStyle\" mat-card-image [src]=\"fileUrl\" />\n    <mat-card-actions>\n        <button type=\"button\" mat-raised-button (click)=\"removeFile()\" *ngIf=\"!disableEdit && !config.hideRemove\">\n            Remove\n        </button>\n    </mat-card-actions>\n</mat-card>\n\n<div class=\"mat-elevation-z1 p-4\" *ngIf=\"viewerType !== 'image'\">\n    <a [href]=\"fileUrl\" target=\"_blank\">{{fileName}}</a>\n    <ngx-doc-viewer [ngStyle]=\"config.viewerStyle\" *ngIf=\"viewerType !== null\" [url]=\"fileUrl\" [viewer]=\"viewerType\">\n    </ngx-doc-viewer>\n    <div class=\"mt-2\" *ngIf=\"!config.hideRemove\">\n        <button type=\"button\" mat-raised-button (click)=\"removeFile()\" *ngIf=\"!disableEdit\">\n            Remove\n        </button>\n    </div>\n</div>", styles: [".image-fit{height:100%;width:100%;object-fit:cover}\n"] }]
        }], ctorParameters: () => [], propDecorators: { config: [{
                type: Input
            }], file: [{
                type: Input
            }], fileUrl: [{
                type: Input
            }], disableEdit: [{
                type: Input
            }], remove: [{
                type: Output
            }] } });
//# sourceMappingURL=data:application/json;base64, 