import { Component, Input, ViewEncapsulation } from '@angular/core';
import { AxDocument } from '../../../../forms/page/widgets/ax-document';
import { AxoUtils } from '../../../../axo-utils/axo-utils';
import _ from 'lodash';
import { DocumentExtensionType } from '../../../../forms/page/common/widget-enums';
import * as i0 from "@angular/core";
import * as i1 from "@angular/common";
import * as i2 from "@angular/material/icon";
function DocumentWidgetViewComponent_div_0_span_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "span");
    i0.ɵɵtext(1);
    i0.ɵɵelementStart(2, "span", 9);
    i0.ɵɵtext(3, ":");
    i0.ɵɵelementEnd();
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r2 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate(ctx_r2.widget.prompt);
} }
function DocumentWidgetViewComponent_div_0_mat_icon_5_Template(rf, ctx) { if (rf & 1) {
    const _r14 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "mat-icon", 10);
    i0.ɵɵlistener("click", function DocumentWidgetViewComponent_div_0_mat_icon_5_Template_mat_icon_click_0_listener() { i0.ɵɵrestoreView(_r14); const ctx_r13 = i0.ɵɵnextContext(2); return ctx_r13.downloadDocument(); });
    i0.ɵɵelementEnd();
} if (rf & 2) {
    i0.ɵɵproperty("svgIcon", "axo_pdf1");
} }
function DocumentWidgetViewComponent_div_0_mat_icon_6_Template(rf, ctx) { if (rf & 1) {
    const _r16 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "mat-icon", 10);
    i0.ɵɵlistener("click", function DocumentWidgetViewComponent_div_0_mat_icon_6_Template_mat_icon_click_0_listener() { i0.ɵɵrestoreView(_r16); const ctx_r15 = i0.ɵɵnextContext(2); return ctx_r15.downloadDocument(); });
    i0.ɵɵelementEnd();
} if (rf & 2) {
    i0.ɵɵproperty("svgIcon", "axo_ppt");
} }
function DocumentWidgetViewComponent_div_0_mat_icon_7_Template(rf, ctx) { if (rf & 1) {
    const _r18 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "mat-icon", 10);
    i0.ɵɵlistener("click", function DocumentWidgetViewComponent_div_0_mat_icon_7_Template_mat_icon_click_0_listener() { i0.ɵɵrestoreView(_r18); const ctx_r17 = i0.ɵɵnextContext(2); return ctx_r17.downloadDocument(); });
    i0.ɵɵelementEnd();
} if (rf & 2) {
    i0.ɵɵproperty("svgIcon", "axo_pptx");
} }
function DocumentWidgetViewComponent_div_0_mat_icon_8_Template(rf, ctx) { if (rf & 1) {
    const _r20 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "mat-icon", 10);
    i0.ɵɵlistener("click", function DocumentWidgetViewComponent_div_0_mat_icon_8_Template_mat_icon_click_0_listener() { i0.ɵɵrestoreView(_r20); const ctx_r19 = i0.ɵɵnextContext(2); return ctx_r19.downloadDocument(); });
    i0.ɵɵelementEnd();
} if (rf & 2) {
    i0.ɵɵproperty("svgIcon", "axo_doc");
} }
function DocumentWidgetViewComponent_div_0_mat_icon_9_Template(rf, ctx) { if (rf & 1) {
    const _r22 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "mat-icon", 10);
    i0.ɵɵlistener("click", function DocumentWidgetViewComponent_div_0_mat_icon_9_Template_mat_icon_click_0_listener() { i0.ɵɵrestoreView(_r22); const ctx_r21 = i0.ɵɵnextContext(2); return ctx_r21.downloadDocument(); });
    i0.ɵɵelementEnd();
} if (rf & 2) {
    i0.ɵɵproperty("svgIcon", "axo_txt");
} }
function DocumentWidgetViewComponent_div_0_mat_icon_10_Template(rf, ctx) { if (rf & 1) {
    const _r24 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "mat-icon", 10);
    i0.ɵɵlistener("click", function DocumentWidgetViewComponent_div_0_mat_icon_10_Template_mat_icon_click_0_listener() { i0.ɵɵrestoreView(_r24); const ctx_r23 = i0.ɵɵnextContext(2); return ctx_r23.downloadDocument(); });
    i0.ɵɵelementEnd();
} if (rf & 2) {
    i0.ɵɵproperty("svgIcon", "axo_xls");
} }
function DocumentWidgetViewComponent_div_0_mat_icon_11_Template(rf, ctx) { if (rf & 1) {
    const _r26 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "mat-icon", 10);
    i0.ɵɵlistener("click", function DocumentWidgetViewComponent_div_0_mat_icon_11_Template_mat_icon_click_0_listener() { i0.ɵɵrestoreView(_r26); const ctx_r25 = i0.ɵɵnextContext(2); return ctx_r25.downloadDocument(); });
    i0.ɵɵelementEnd();
} if (rf & 2) {
    i0.ɵɵproperty("svgIcon", "axo_xlsx");
} }
function DocumentWidgetViewComponent_div_0_mat_icon_12_Template(rf, ctx) { if (rf & 1) {
    const _r28 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "mat-icon", 10);
    i0.ɵɵlistener("click", function DocumentWidgetViewComponent_div_0_mat_icon_12_Template_mat_icon_click_0_listener() { i0.ɵɵrestoreView(_r28); const ctx_r27 = i0.ɵɵnextContext(2); return ctx_r27.downloadDocument(); });
    i0.ɵɵelementEnd();
} if (rf & 2) {
    i0.ɵɵproperty("svgIcon", "axo_docx");
} }
function DocumentWidgetViewComponent_div_0_mat_icon_13_Template(rf, ctx) { if (rf & 1) {
    const _r30 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "mat-icon", 10);
    i0.ɵɵlistener("click", function DocumentWidgetViewComponent_div_0_mat_icon_13_Template_mat_icon_click_0_listener() { i0.ɵɵrestoreView(_r30); const ctx_r29 = i0.ɵɵnextContext(2); return ctx_r29.downloadDocument(); });
    i0.ɵɵelementEnd();
} if (rf & 2) {
    i0.ɵɵproperty("svgIcon", "axo_html");
} }
function DocumentWidgetViewComponent_div_0_mat_icon_14_Template(rf, ctx) { if (rf & 1) {
    const _r32 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "mat-icon", 10);
    i0.ɵɵlistener("click", function DocumentWidgetViewComponent_div_0_mat_icon_14_Template_mat_icon_click_0_listener() { i0.ɵɵrestoreView(_r32); const ctx_r31 = i0.ɵɵnextContext(2); return ctx_r31.downloadDocument(); });
    i0.ɵɵelementEnd();
} if (rf & 2) {
    i0.ɵɵproperty("svgIcon", "axo_file");
} }
function DocumentWidgetViewComponent_div_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 2);
    i0.ɵɵelementStart(1, "div", 3);
    i0.ɵɵelement(2, "mat-icon", 4);
    i0.ɵɵtemplate(3, DocumentWidgetViewComponent_div_0_span_3_Template, 4, 1, "span", 5);
    i0.ɵɵelementEnd();
    i0.ɵɵelementContainerStart(4, 6);
    i0.ɵɵtemplate(5, DocumentWidgetViewComponent_div_0_mat_icon_5_Template, 1, 1, "mat-icon", 7);
    i0.ɵɵtemplate(6, DocumentWidgetViewComponent_div_0_mat_icon_6_Template, 1, 1, "mat-icon", 7);
    i0.ɵɵtemplate(7, DocumentWidgetViewComponent_div_0_mat_icon_7_Template, 1, 1, "mat-icon", 7);
    i0.ɵɵtemplate(8, DocumentWidgetViewComponent_div_0_mat_icon_8_Template, 1, 1, "mat-icon", 7);
    i0.ɵɵtemplate(9, DocumentWidgetViewComponent_div_0_mat_icon_9_Template, 1, 1, "mat-icon", 7);
    i0.ɵɵtemplate(10, DocumentWidgetViewComponent_div_0_mat_icon_10_Template, 1, 1, "mat-icon", 7);
    i0.ɵɵtemplate(11, DocumentWidgetViewComponent_div_0_mat_icon_11_Template, 1, 1, "mat-icon", 7);
    i0.ɵɵtemplate(12, DocumentWidgetViewComponent_div_0_mat_icon_12_Template, 1, 1, "mat-icon", 7);
    i0.ɵɵtemplate(13, DocumentWidgetViewComponent_div_0_mat_icon_13_Template, 1, 1, "mat-icon", 7);
    i0.ɵɵtemplate(14, DocumentWidgetViewComponent_div_0_mat_icon_14_Template, 1, 1, "mat-icon", 8);
    i0.ɵɵelementContainerEnd();
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance(3);
    i0.ɵɵproperty("ngIf", ctx_r0.section.showPrompt);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngSwitch", ctx_r0.extension);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngSwitchCase", ctx_r0.documentType.pdf);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngSwitchCase", ctx_r0.documentType.ppt);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngSwitchCase", ctx_r0.documentType.pptx);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngSwitchCase", ctx_r0.documentType.document);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngSwitchCase", ctx_r0.documentType.txt);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngSwitchCase", ctx_r0.documentType.xls);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngSwitchCase", ctx_r0.documentType.xlsx);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngSwitchCase", ctx_r0.documentType.docx);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngSwitchCase", ctx_r0.documentType.html);
} }
function DocumentWidgetViewComponent_div_1_span_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "span");
    i0.ɵɵtext(1);
    i0.ɵɵelementStart(2, "span", 9);
    i0.ɵɵtext(3, ":");
    i0.ɵɵelementEnd();
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r33 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate(ctx_r33.widget.prompt);
} }
function DocumentWidgetViewComponent_div_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 11);
    i0.ɵɵelementStart(1, "div", 12);
    i0.ɵɵelement(2, "mat-icon", 13);
    i0.ɵɵtemplate(3, DocumentWidgetViewComponent_div_1_span_3_Template, 4, 1, "span", 5);
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(4, "span", 14);
    i0.ɵɵtext(5, "-");
    i0.ɵɵelementEnd();
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext();
    i0.ɵɵadvance(3);
    i0.ɵɵproperty("ngIf", ctx_r1.section.showPrompt);
} }
export class DocumentWidgetViewComponent {
    constructor() {
        this.documentType = Object.assign({}, DocumentExtensionType);
    }
    ngOnInit() {
        if (this.widget.values && !_.isEmpty(this.widget.values[0]?.path)) {
            this.widgetValue = this.widget.values[0];
            this.extension = this.widget.values[0].extension;
            this.widgetValue.path = AxoUtils.removeSlashFromImageUrl(this.widget.values[0]?.path);
        }
        else if (this.widget.value && !_.isEmpty(this.widget.value[0]?.name)) {
            this.widgetValue = this.widget.value[0];
            this.widgetValue.name = AxoUtils.removeSlashFromImageUrl(this.widget.value[0]?.name);
            this.extension = AxoUtils.getDocumentExtension(this.widgetValue.name);
            this.widgetValue.path = '/images/media/app_data/' + this.widgetValue.name;
        }
    }
    downloadDocument() {
        window.open(this.baseUrl + this.widgetValue.path);
    }
}
DocumentWidgetViewComponent.ɵfac = function DocumentWidgetViewComponent_Factory(t) { return new (t || DocumentWidgetViewComponent)(); };
DocumentWidgetViewComponent.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: DocumentWidgetViewComponent, selectors: [["lib-document-widget-view"]], inputs: { widget: "widget", baseUrl: "baseUrl" }, decls: 2, vars: 2, consts: [["class", "data-detail-info", 4, "ngIf"], ["class", "flex gap-3", 4, "ngIf"], [1, "data-detail-info"], [1, "data-detail-title", "flex", "text-sm"], ["svgIcon", "axo_document", 1, "add-text"], [4, "ngIf"], [3, "ngSwitch"], ["class", "full-width h-5 w-4 cursor-pointer", 3, "svgIcon", "click", 4, "ngSwitchCase"], ["class", "full-width h-5 w-4 cursor-pointer", 3, "svgIcon", "click", 4, "ngSwitchDefault"], [1, "colon"], [1, "full-width", "h-5", "w-4", "cursor-pointer", 3, "svgIcon", "click"], [1, "flex", "gap-3"], [1, "data-detail-title", "flex", "m-0"], ["svgIcon", "axo_document", 1, "doc-icon"], [1, "flex", "justify-start", "items-center"]], template: function DocumentWidgetViewComponent_Template(rf, ctx) { if (rf & 1) {
        i0.ɵɵtemplate(0, DocumentWidgetViewComponent_div_0_Template, 15, 11, "div", 0);
        i0.ɵɵtemplate(1, DocumentWidgetViewComponent_div_1_Template, 6, 1, "div", 1);
    } if (rf & 2) {
        i0.ɵɵproperty("ngIf", ctx.widgetValue);
        i0.ɵɵadvance(1);
        i0.ɵɵproperty("ngIf", ctx.widgetValue === undefined);
    } }, directives: [i1.NgIf, i2.MatIcon, i1.NgSwitch, i1.NgSwitchCase, i1.NgSwitchDefault], styles: ["lib-document-widget-view .doc-icon{height:18px;width:18px;min-width:18px;min-height:18px}\n"], encapsulation: 2 });
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(DocumentWidgetViewComponent, [{
        type: Component,
        args: [{ selector: 'lib-document-widget-view', encapsulation: ViewEncapsulation.None, template: "<div class=\"data-detail-info\" *ngIf=\"widgetValue;\">\n        <div class=\"data-detail-title flex text-sm\">\n            <mat-icon class=\"add-text\" svgIcon=\"axo_document\"></mat-icon>\n            <span *ngIf=\"section.showPrompt\">{{widget.prompt}}<span class=\"colon\">:</span></span>\n        </div>\n\n        <ng-container [ngSwitch]=\"extension\">\n\n            <mat-icon (click)=\"downloadDocument()\" *ngSwitchCase=documentType.pdf class=\"full-width h-5 w-4 cursor-pointer\"\n                [svgIcon]=\"'axo_pdf1'\">\n            </mat-icon>\n\n            <mat-icon (click)=\"downloadDocument()\" *ngSwitchCase=documentType.ppt class=\"full-width h-5 w-4 cursor-pointer\"\n                [svgIcon]=\"'axo_ppt'\">\n            </mat-icon>\n\n            <mat-icon (click)=\"downloadDocument()\" *ngSwitchCase=documentType.pptx class=\"full-width h-5 w-4 cursor-pointer\"\n                [svgIcon]=\"'axo_pptx'\">\n            </mat-icon>\n\n            <mat-icon (click)=\"downloadDocument()\" *ngSwitchCase=documentType.document\n                class=\"full-width h-5 w-4 cursor-pointer\" [svgIcon]=\"'axo_doc'\">\n            </mat-icon>\n\n            <mat-icon (click)=\"downloadDocument()\" *ngSwitchCase=documentType.txt class=\"full-width h-5 w-4 cursor-pointer\"\n                [svgIcon]=\"'axo_txt'\">\n            </mat-icon>\n\n            <mat-icon (click)=\"downloadDocument()\" *ngSwitchCase=documentType.xls class=\"full-width h-5 w-4 cursor-pointer\"\n                [svgIcon]=\"'axo_xls'\">\n            </mat-icon>\n\n            <mat-icon (click)=\"downloadDocument()\" *ngSwitchCase=documentType.xlsx class=\"full-width h-5 w-4 cursor-pointer\"\n                [svgIcon]=\"'axo_xlsx'\">\n            </mat-icon>\n\n            <mat-icon (click)=\"downloadDocument()\" *ngSwitchCase=documentType.docx class=\"full-width h-5 w-4 cursor-pointer\"\n                [svgIcon]=\"'axo_docx'\">\n            </mat-icon>\n\n            <mat-icon (click)=\"downloadDocument()\" *ngSwitchCase=documentType.html class=\"full-width h-5 w-4 cursor-pointer\"\n                [svgIcon]=\"'axo_html'\">\n            </mat-icon>\n\n            <mat-icon (click)=\"downloadDocument()\" *ngSwitchDefault class=\"full-width h-5 w-4 cursor-pointer\"\n                [svgIcon]=\"'axo_file'\">\n            </mat-icon>\n        </ng-container>\n</div>\n\n\n    <div class=\"flex gap-3\" *ngIf=\"widgetValue === undefined\">\n        <div class=\"data-detail-title flex m-0\">\n            <mat-icon class=\"doc-icon\" svgIcon=\"axo_document\"></mat-icon>\n            <span *ngIf=\"section.showPrompt\">{{widget.prompt}}<span class=\"colon\">:</span></span>\n        </div>\n        <span class=\"flex justify-start items-center\">-</span>\n    </div>\n\n", styles: ["lib-document-widget-view .doc-icon{height:18px;width:18px;min-width:18px;min-height:18px}\n"] }]
    }], function () { return []; }, { widget: [{
            type: Input
        }], baseUrl: [{
            type: Input
        }] }); })();
//# sourceMappingURL=data:application/json;base64, 