import * as i0 from '@angular/core';
import { Pipe, output, input, viewChild, inject, Component, Input } from '@angular/core';
import * as i1$1 from 'ngx-bootstrap/modal';
import { DropAreaComponent, AlertService, LoadingComponent, C8yTranslateDirective, MessagesComponent, ListGroupComponent, ListItemComponent, ListItemIconComponent, ListItemBodyComponent, IconDirective, DatePipe, BytesPipe, C8yTranslatePipe, ModalComponent } from '@c8y/ngx-components';
import { gettext } from '@c8y/ngx-components/gettext';
import { NgForOf, NgIf, NgStyle, NgClass, NgSwitch, NgSwitchCase, NgSwitchDefault, AsyncPipe } from '@angular/common';
import * as i1 from 'ngx-bootstrap/collapse';
import { CollapseModule } from 'ngx-bootstrap/collapse';
import { PopoverDirective } from 'ngx-bootstrap/popover';
import { Subject, merge, combineLatest, firstValueFrom } from 'rxjs';
import { switchMap, shareReplay, map, tap, first } from 'rxjs/operators';
import { StaticAssetsService } from '@c8y/ngx-components/static-assets/data';
import { toObservable, takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { TranslateService } from '@ngx-translate/core';

class StaticAssetMainTypePipe {
    constructor() {
        this.supportedTypes = ['image', 'font'];
    }
    transform(value) {
        if (!value?.type) {
            return 'unknown';
        }
        const typePrefix = value.type.replace(/\/.*$/, '');
        if (this.supportedTypes.includes(typePrefix)) {
            return typePrefix;
        }
        return 'unknown';
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.25", ngImport: i0, type: StaticAssetMainTypePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
    static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "20.3.25", ngImport: i0, type: StaticAssetMainTypePipe, isStandalone: true, name: "staticAssetMainType" }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.25", ngImport: i0, type: StaticAssetMainTypePipe, decorators: [{
            type: Pipe,
            args: [{
                    name: 'staticAssetMainType',
                    pure: true,
                    standalone: true
                }]
        }] });

class StaticAssetsFileListComponent {
    constructor() {
        this.itemSelected = output();
        this.inModalView = input(false, ...(ngDevMode ? [{ debugName: "inModalView" }] : []));
        this.assetType = input('branding', ...(ngDevMode ? [{ debugName: "assetType" }] : []));
        this.supportedFileExtensions = input([], ...(ngDevMode ? [{ debugName: "supportedFileExtensions" }] : []));
        this.layout = input('grid', ...(ngDevMode ? [{ debugName: "layout" }] : []));
        this.isExpanded = false;
        this._filesUpdate$ = new Subject();
        this.styleTagId = `static-assets-font-faces`;
        this.dropArea = viewChild(DropAreaComponent, ...(ngDevMode ? [{ debugName: "dropArea" }] : []));
        this.alert = inject(AlertService);
        this.translate = inject(TranslateService);
        this.staticAssets = inject(StaticAssetsService);
        this._unfilteredFiles$ = merge(toObservable(this.assetType).pipe(switchMap(assetType => this.staticAssets.listFiles(assetType))), this._filesUpdate$).pipe(shareReplay({ bufferSize: 1, refCount: true }));
        this.files$ = combineLatest([
            this._unfilteredFiles$,
            toObservable(this.supportedFileExtensions)
        ]).pipe(map(([files, supportedFileExtensions]) => supportedFileExtensions?.length
            ? files.filter(tmp => supportedFileExtensions.includes(tmp.extension.toLowerCase()))
            : files), map(files => files.sort((a, b) => (a.addedAt < b.addedAt ? 1 : a.addedAt > b.addedAt ? -1 : 0))), tap(files => {
            if (!files.length) {
                this.isExpanded = true;
            }
        }), shareReplay({ bufferSize: 1, refCount: true }));
        this.accept$ = toObservable(this.supportedFileExtensions).pipe(map(exts => exts.join(',')));
        this.files$.pipe(takeUntilDestroyed()).subscribe(files => this.applyStylesForFiles(files));
    }
    ngOnDestroy() {
        this.removeStyleTag();
    }
    async addFiles(files) {
        if (!files?.length) {
            return;
        }
        this.dropArea().loading = true;
        try {
            const existingFiles = await firstValueFrom(this._unfilteredFiles$.pipe(first()));
            const updatedFiles = await this.staticAssets.addFilesToStaticAssets(this.assetType(), files, existingFiles);
            this._filesUpdate$.next(updatedFiles);
        }
        catch (e) {
            this.alert.danger(this.translate.instant(gettext('Failed to upload asset.')), e?.message);
        }
        this.dropArea().files = null;
        this.dropArea().loading = false;
    }
    select(asset) {
        this.itemSelected.emit(asset);
    }
    applyStylesForFiles(files) {
        this.removeStyleTag();
        const styles = files
            .filter(file => file.type.startsWith('font/'))
            .map(file => `@font-face { font-family: '${file.hashSum}'; src: url('${file.path}'); }`)
            .join('\n');
        if (!styles) {
            return;
        }
        const styleTag = document.createElement('style');
        styleTag.id = this.styleTagId;
        styleTag.innerHTML = styles;
        styleTag.type = 'text/css';
        document.body.appendChild(styleTag);
    }
    removeStyleTag() {
        document.getElementById(this.styleTagId)?.remove();
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.25", ngImport: i0, type: StaticAssetsFileListComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "20.3.25", type: StaticAssetsFileListComponent, isStandalone: true, selector: "c8y-static-assets-file-list", inputs: { inModalView: { classPropertyName: "inModalView", publicName: "inModalView", isSignal: true, isRequired: false, transformFunction: null }, assetType: { classPropertyName: "assetType", publicName: "assetType", isSignal: true, isRequired: false, transformFunction: null }, supportedFileExtensions: { classPropertyName: "supportedFileExtensions", publicName: "supportedFileExtensions", isSignal: true, isRequired: false, transformFunction: null }, layout: { classPropertyName: "layout", publicName: "layout", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { itemSelected: "itemSelected" }, viewQueries: [{ propertyName: "dropArea", first: true, predicate: DropAreaComponent, descendants: true, isSignal: true }], ngImport: i0, template: "<ng-container *ngIf=\"files$ | async as assets; else loading\">\n  <div\n    class=\"text-center sticky-top separator-bottom bg-component\"\n    style=\"z-index: 1001\"\n  >\n    <p\n      class=\"m-0 p-16\"\n      *ngIf=\"assets.length\"\n    >\n      {{ 'Select from the list below or`first part, followed by upload a new asset`' | translate }}\n      <button\n        class=\"btn-link\"\n        aria-controls=\"collapseUpload\"\n        [attr.aria-expanded]=\"isExpanded\"\n        (click)=\"isExpanded = !isExpanded\"\n      >\n        {{ 'upload a new asset' | translate }}\n      </button>\n    </p>\n    <div\n      class=\"collapse\"\n      id=\"collapseUpload\"\n      [isAnimated]=\"true\"\n      [collapse]=\"!isExpanded\"\n    >\n      <div class=\"p-t-24 p-l-24 p-r-24 bg-level-1 separator-top-bottom p-b-32\">\n        <c8y-drop-area\n          class=\"drop-area-sm m-b-8\"\n          [icon]=\"'upload'\"\n          [accept]=\"accept$ | async\"\n          (dropped)=\"addFiles($event)\"\n        ></c8y-drop-area>\n        <c8y-messages\n          [helpMessage]=\"\n            'After uploading, the asset will be visible in the list below.' | translate\n          \"\n        ></c8y-messages>\n      </div>\n    </div>\n  </div>\n  <div *ngIf=\"assets.length\">\n    <c8y-list-group\n      class=\"m-b-0\"\n      *ngIf=\"layout() != 'grid'\"\n    >\n      <c8y-list-item *ngFor=\"let asset of assets\">\n        <c8y-list-item-icon icon=\"file\"></c8y-list-item-icon>\n\n        <c8y-list-item-body>\n          <div class=\"row\">\n            <div class=\"col-md-3 col-xs-12 d-flex a-i-center\">\n              <div\n                class=\"text-truncate\"\n                title=\"{{ asset.fileName }}\"\n              >\n                {{ asset.fileName }}\n              </div>\n              <button\n                class=\"btn-dot m-l-4\"\n                [title]=\"'Preview' | translate\"\n                [popover]=\"preview\"\n                placement=\"end\"\n                triggers=\"focus\"\n                container=\"body\"\n                [adaptivePosition]=\"false\"\n              >\n                <i [c8yIcon]=\"'eye'\"></i>\n              </button>\n              <ng-template #preview>\n                <div class=\"bg-checkered\">\n                  <img\n                    class=\"fit-w\"\n                    [alt]=\"asset.fileName\"\n                    [src]=\"asset.path\"\n                  />\n                </div>\n              </ng-template>\n            </div>\n            <div class=\"col-md-3 col-xs-12 text-muted\">\n              <code class=\"text-10\">{{ asset.type }}</code>\n            </div>\n            <div class=\"col-md-2 col-xs-12 text-muted\">\n              <span class=\"small\">{{ asset.size | bytes }}</span>\n            </div>\n            <div\n              class=\"col-md-2 col-xs-12 text-muted\"\n              [title]=\"asset.addedAt | c8yDate\"\n            >\n              <div class=\"icon-flex small\">\n                <i\n                  class=\"m-r-4\"\n                  [c8yIcon]=\"'calendar'\"\n                ></i>\n                <span>{{ asset.addedAt | c8yDate }}</span>\n              </div>\n            </div>\n            <div class=\"col-md-2 col-xs-12 d-flex\">\n              <button\n                class=\"btn btn-default btn-sm m-l-auto showOnHover\"\n                (click)=\"select(asset)\"\n                translate\n              >\n                Select\n              </button>\n            </div>\n          </div>\n        </c8y-list-item-body>\n      </c8y-list-item>\n    </c8y-list-group>\n    <div\n      class=\"card-group-block interact-grid\"\n      *ngIf=\"layout() === 'grid'\"\n    >\n      <button\n        class=\"card btn-clean interact pointer\"\n        [ngClass]=\"{\n          'col-md-3 col-sm-4 col-xs-12': inModalView(),\n          'col-md-1 col-sm-3 col-xs-12': !inModalView()\n        }\"\n        *ngFor=\"let asset of assets\"\n        (click)=\"select(asset)\"\n      >\n        <div class=\"card-block\">\n          <ng-container [ngSwitch]=\"asset | staticAssetMainType\">\n            <div\n              class=\"bg-checkered\"\n              *ngSwitchCase=\"'image'\"\n            >\n              <img\n                class=\"img-responsive m-auto img-square\"\n                [alt]=\"asset.fileName\"\n                [src]=\"asset.path\"\n              />\n            </div>\n            <div\n              class=\"bg-checkered\"\n              *ngSwitchCase=\"'font'\"\n            >\n              <div\n                class=\"img-responsive m-auto img-square\"\n                [ngStyle]=\"{ 'font-family': asset.hashSum }\"\n              >\n                <p class=\"fit-h text-balance text-truncate-wrap\">\n                  <!-- intentionally not translated -->\n                  The quick brown fox jumps over the lazy dog.\n                </p>\n              </div>\n            </div>\n            <div\n              class=\"bg-checkered\"\n              *ngSwitchDefault\n            >\n              <div class=\"img-responsive m-auto img-square d-flex a-i-center j-c-center\">\n                <i\n                  class=\"icon-2x\"\n                  [c8yIcon]=\"'file'\"\n                ></i>\n              </div>\n            </div>\n          </ng-container>\n          <p\n            class=\"text-medium text-truncate-wrap m-t-8\"\n            [title]=\"asset.fileName\"\n          >\n            <a\n              [href]=\"asset.path\"\n              download\n              (click)=\"$event.stopPropagation()\"\n            >\n              <i [c8yIcon]=\"'download'\"></i>\n              {{ asset.fileName }}\n            </a>\n          </p>\n          <p class=\"m-b-4\">\n            <code class=\"text-10\">{{ asset.type }}</code>\n          </p>\n          <p class=\"small text-muted d-flex flex-wrap a-i-center\">\n            {{ asset.size | bytes }}\n            <span class=\"m-l-auto\">\n              <i\n                class=\"m-r-4\"\n                [c8yIcon]=\"'calendar'\"\n              ></i>\n              <span>{{ asset.addedAt | c8yDate }}</span>\n            </span>\n          </p>\n        </div>\n      </button>\n    </div>\n  </div>\n</ng-container>\n\n<ng-template #loading>\n  <div class=\"p-24\">\n    <c8y-loading></c8y-loading>\n  </div>\n</ng-template>\n", dependencies: [{ kind: "directive", type: NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: LoadingComponent, selector: "c8y-loading", inputs: ["layout", "progress", "message"] }, { kind: "component", type: DropAreaComponent, selector: "c8y-drop-area", inputs: ["formControl", "title", "message", "icon", "loadingMessage", "forceHideList", "alwaysShow", "clickToOpen", "loading", "progress", "maxAllowedFiles", "files", "maxFileSizeInMegaBytes", "accept"], outputs: ["dropped"] }, { kind: "directive", type: C8yTranslateDirective, selector: "[translate],[ngx-translate]" }, { kind: "component", type: MessagesComponent, selector: "c8y-messages", inputs: ["show", "defaults", "helpMessage", "additionalMessages"] }, { kind: "component", type: ListGroupComponent, selector: "c8y-list-group" }, { kind: "component", type: ListItemComponent, selector: "c8y-list-item, c8y-li", inputs: ["active", "highlighted", "emptyActions", "dense", "collapsed", "selectable"], outputs: ["collapsedChange"] }, { kind: "component", type: ListItemIconComponent, selector: "c8y-list-item-icon, c8y-li-icon", inputs: ["icon", "status"] }, { kind: "component", type: ListItemBodyComponent, selector: "c8y-list-item-body, c8y-li-body", inputs: ["body"] }, { kind: "directive", type: PopoverDirective, selector: "[popover]", inputs: ["adaptivePosition", "boundariesElement", "popover", "popoverContext", "popoverTitle", "placement", "outsideClick", "triggers", "container", "containerClass", "isOpen", "delay"], outputs: ["onShown", "onHidden"], exportAs: ["bs-popover"] }, { kind: "ngmodule", type: CollapseModule }, { kind: "directive", type: i1.CollapseDirective, selector: "[collapse]", inputs: ["display", "isAnimated", "collapse"], outputs: ["collapsed", "collapses", "expanded", "expands"], exportAs: ["bs-collapse"] }, { kind: "directive", type: NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: IconDirective, selector: "[c8yIcon]", inputs: ["c8yIcon"] }, { kind: "directive", type: NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { kind: "directive", type: NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }, { kind: "directive", type: NgSwitchDefault, selector: "[ngSwitchDefault]" }, { kind: "pipe", type: AsyncPipe, name: "async" }, { kind: "pipe", type: DatePipe, name: "c8yDate" }, { kind: "pipe", type: BytesPipe, name: "bytes" }, { kind: "pipe", type: C8yTranslatePipe, name: "translate" }, { kind: "pipe", type: StaticAssetMainTypePipe, name: "staticAssetMainType" }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.25", ngImport: i0, type: StaticAssetsFileListComponent, decorators: [{
            type: Component,
            args: [{ selector: 'c8y-static-assets-file-list', standalone: true, imports: [
                        NgForOf,
                        NgIf,
                        AsyncPipe,
                        DatePipe,
                        BytesPipe,
                        LoadingComponent,
                        DropAreaComponent,
                        C8yTranslatePipe,
                        C8yTranslateDirective,
                        MessagesComponent,
                        ListGroupComponent,
                        ListItemComponent,
                        ListItemIconComponent,
                        ListItemBodyComponent,
                        PopoverDirective,
                        CollapseModule,
                        NgStyle,
                        NgClass,
                        IconDirective,
                        StaticAssetMainTypePipe,
                        NgSwitch,
                        NgSwitchCase,
                        NgSwitchDefault
                    ], template: "<ng-container *ngIf=\"files$ | async as assets; else loading\">\n  <div\n    class=\"text-center sticky-top separator-bottom bg-component\"\n    style=\"z-index: 1001\"\n  >\n    <p\n      class=\"m-0 p-16\"\n      *ngIf=\"assets.length\"\n    >\n      {{ 'Select from the list below or`first part, followed by upload a new asset`' | translate }}\n      <button\n        class=\"btn-link\"\n        aria-controls=\"collapseUpload\"\n        [attr.aria-expanded]=\"isExpanded\"\n        (click)=\"isExpanded = !isExpanded\"\n      >\n        {{ 'upload a new asset' | translate }}\n      </button>\n    </p>\n    <div\n      class=\"collapse\"\n      id=\"collapseUpload\"\n      [isAnimated]=\"true\"\n      [collapse]=\"!isExpanded\"\n    >\n      <div class=\"p-t-24 p-l-24 p-r-24 bg-level-1 separator-top-bottom p-b-32\">\n        <c8y-drop-area\n          class=\"drop-area-sm m-b-8\"\n          [icon]=\"'upload'\"\n          [accept]=\"accept$ | async\"\n          (dropped)=\"addFiles($event)\"\n        ></c8y-drop-area>\n        <c8y-messages\n          [helpMessage]=\"\n            'After uploading, the asset will be visible in the list below.' | translate\n          \"\n        ></c8y-messages>\n      </div>\n    </div>\n  </div>\n  <div *ngIf=\"assets.length\">\n    <c8y-list-group\n      class=\"m-b-0\"\n      *ngIf=\"layout() != 'grid'\"\n    >\n      <c8y-list-item *ngFor=\"let asset of assets\">\n        <c8y-list-item-icon icon=\"file\"></c8y-list-item-icon>\n\n        <c8y-list-item-body>\n          <div class=\"row\">\n            <div class=\"col-md-3 col-xs-12 d-flex a-i-center\">\n              <div\n                class=\"text-truncate\"\n                title=\"{{ asset.fileName }}\"\n              >\n                {{ asset.fileName }}\n              </div>\n              <button\n                class=\"btn-dot m-l-4\"\n                [title]=\"'Preview' | translate\"\n                [popover]=\"preview\"\n                placement=\"end\"\n                triggers=\"focus\"\n                container=\"body\"\n                [adaptivePosition]=\"false\"\n              >\n                <i [c8yIcon]=\"'eye'\"></i>\n              </button>\n              <ng-template #preview>\n                <div class=\"bg-checkered\">\n                  <img\n                    class=\"fit-w\"\n                    [alt]=\"asset.fileName\"\n                    [src]=\"asset.path\"\n                  />\n                </div>\n              </ng-template>\n            </div>\n            <div class=\"col-md-3 col-xs-12 text-muted\">\n              <code class=\"text-10\">{{ asset.type }}</code>\n            </div>\n            <div class=\"col-md-2 col-xs-12 text-muted\">\n              <span class=\"small\">{{ asset.size | bytes }}</span>\n            </div>\n            <div\n              class=\"col-md-2 col-xs-12 text-muted\"\n              [title]=\"asset.addedAt | c8yDate\"\n            >\n              <div class=\"icon-flex small\">\n                <i\n                  class=\"m-r-4\"\n                  [c8yIcon]=\"'calendar'\"\n                ></i>\n                <span>{{ asset.addedAt | c8yDate }}</span>\n              </div>\n            </div>\n            <div class=\"col-md-2 col-xs-12 d-flex\">\n              <button\n                class=\"btn btn-default btn-sm m-l-auto showOnHover\"\n                (click)=\"select(asset)\"\n                translate\n              >\n                Select\n              </button>\n            </div>\n          </div>\n        </c8y-list-item-body>\n      </c8y-list-item>\n    </c8y-list-group>\n    <div\n      class=\"card-group-block interact-grid\"\n      *ngIf=\"layout() === 'grid'\"\n    >\n      <button\n        class=\"card btn-clean interact pointer\"\n        [ngClass]=\"{\n          'col-md-3 col-sm-4 col-xs-12': inModalView(),\n          'col-md-1 col-sm-3 col-xs-12': !inModalView()\n        }\"\n        *ngFor=\"let asset of assets\"\n        (click)=\"select(asset)\"\n      >\n        <div class=\"card-block\">\n          <ng-container [ngSwitch]=\"asset | staticAssetMainType\">\n            <div\n              class=\"bg-checkered\"\n              *ngSwitchCase=\"'image'\"\n            >\n              <img\n                class=\"img-responsive m-auto img-square\"\n                [alt]=\"asset.fileName\"\n                [src]=\"asset.path\"\n              />\n            </div>\n            <div\n              class=\"bg-checkered\"\n              *ngSwitchCase=\"'font'\"\n            >\n              <div\n                class=\"img-responsive m-auto img-square\"\n                [ngStyle]=\"{ 'font-family': asset.hashSum }\"\n              >\n                <p class=\"fit-h text-balance text-truncate-wrap\">\n                  <!-- intentionally not translated -->\n                  The quick brown fox jumps over the lazy dog.\n                </p>\n              </div>\n            </div>\n            <div\n              class=\"bg-checkered\"\n              *ngSwitchDefault\n            >\n              <div class=\"img-responsive m-auto img-square d-flex a-i-center j-c-center\">\n                <i\n                  class=\"icon-2x\"\n                  [c8yIcon]=\"'file'\"\n                ></i>\n              </div>\n            </div>\n          </ng-container>\n          <p\n            class=\"text-medium text-truncate-wrap m-t-8\"\n            [title]=\"asset.fileName\"\n          >\n            <a\n              [href]=\"asset.path\"\n              download\n              (click)=\"$event.stopPropagation()\"\n            >\n              <i [c8yIcon]=\"'download'\"></i>\n              {{ asset.fileName }}\n            </a>\n          </p>\n          <p class=\"m-b-4\">\n            <code class=\"text-10\">{{ asset.type }}</code>\n          </p>\n          <p class=\"small text-muted d-flex flex-wrap a-i-center\">\n            {{ asset.size | bytes }}\n            <span class=\"m-l-auto\">\n              <i\n                class=\"m-r-4\"\n                [c8yIcon]=\"'calendar'\"\n              ></i>\n              <span>{{ asset.addedAt | c8yDate }}</span>\n            </span>\n          </p>\n        </div>\n      </button>\n    </div>\n  </div>\n</ng-container>\n\n<ng-template #loading>\n  <div class=\"p-24\">\n    <c8y-loading></c8y-loading>\n  </div>\n</ng-template>\n" }]
        }], ctorParameters: () => [], propDecorators: { itemSelected: [{ type: i0.Output, args: ["itemSelected"] }], inModalView: [{ type: i0.Input, args: [{ isSignal: true, alias: "inModalView", required: false }] }], assetType: [{ type: i0.Input, args: [{ isSignal: true, alias: "assetType", required: false }] }], supportedFileExtensions: [{ type: i0.Input, args: [{ isSignal: true, alias: "supportedFileExtensions", required: false }] }], layout: [{ type: i0.Input, args: [{ isSignal: true, alias: "layout", required: false }] }], dropArea: [{ type: i0.ViewChild, args: [i0.forwardRef(() => DropAreaComponent), { isSignal: true }] }] } });

class StaticAssetsModalComponent {
    constructor(modalRef) {
        this.modalRef = modalRef;
        this.assetType = 'branding';
        this.supportedFileExtensions = [];
        this.modalTitle = gettext('Select asset');
        this.layout = 'grid';
        this.result = new Promise((resolve, reject) => {
            this.resolve = resolve;
            this.reject = reject;
        });
    }
    select(asset) {
        this.modalRef.hide();
        this.resolve(asset);
    }
    cancel() {
        this.modalRef.hide();
        this.reject();
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.25", ngImport: i0, type: StaticAssetsModalComponent, deps: [{ token: i1$1.BsModalRef }], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.25", type: StaticAssetsModalComponent, isStandalone: true, selector: "c8y-static-assets-modal", inputs: { assetType: "assetType", supportedFileExtensions: "supportedFileExtensions", modalTitle: "modalTitle", layout: "layout" }, ngImport: i0, template: "<c8y-modal\n  [title]=\"modalTitle\"\n  (onDismiss)=\"cancel()\"\n  [headerClasses]=\"'dialog-header'\"\n  [labels]=\"{ cancel: 'Cancel' }\"\n>\n  <ng-container c8y-modal-title>\n    <span [c8yIcon]=\"'select-all'\"></span>\n  </ng-container>\n  <c8y-static-assets-file-list\n    (itemSelected)=\"select($event)\"\n    [assetType]=\"assetType\"\n    [supportedFileExtensions]=\"supportedFileExtensions\"\n    [layout]=\"layout\"\n    [inModalView]=\"true\"\n  ></c8y-static-assets-file-list>\n</c8y-modal>\n", dependencies: [{ kind: "component", type: StaticAssetsFileListComponent, selector: "c8y-static-assets-file-list", inputs: ["inModalView", "assetType", "supportedFileExtensions", "layout"], outputs: ["itemSelected"] }, { kind: "component", type: ModalComponent, selector: "c8y-modal", inputs: ["disabled", "close", "dismiss", "title", "body", "customFooter", "headerClasses", "labels"], outputs: ["onDismiss", "onClose"] }, { kind: "directive", type: IconDirective, selector: "[c8yIcon]", inputs: ["c8yIcon"] }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.25", ngImport: i0, type: StaticAssetsModalComponent, decorators: [{
            type: Component,
            args: [{ selector: 'c8y-static-assets-modal', imports: [StaticAssetsFileListComponent, ModalComponent, IconDirective], standalone: true, template: "<c8y-modal\n  [title]=\"modalTitle\"\n  (onDismiss)=\"cancel()\"\n  [headerClasses]=\"'dialog-header'\"\n  [labels]=\"{ cancel: 'Cancel' }\"\n>\n  <ng-container c8y-modal-title>\n    <span [c8yIcon]=\"'select-all'\"></span>\n  </ng-container>\n  <c8y-static-assets-file-list\n    (itemSelected)=\"select($event)\"\n    [assetType]=\"assetType\"\n    [supportedFileExtensions]=\"supportedFileExtensions\"\n    [layout]=\"layout\"\n    [inModalView]=\"true\"\n  ></c8y-static-assets-file-list>\n</c8y-modal>\n" }]
        }], ctorParameters: () => [{ type: i1$1.BsModalRef }], propDecorators: { assetType: [{
                type: Input
            }], supportedFileExtensions: [{
                type: Input
            }], modalTitle: [{
                type: Input
            }], layout: [{
                type: Input
            }] } });

/**
 * Generated bundle index. Do not edit.
 */

export { StaticAssetsFileListComponent, StaticAssetsModalComponent };
//# sourceMappingURL=c8y-ngx-components-static-assets-modal.mjs.map
