import { CdkVirtualScrollViewport } from '@angular/cdk/scrolling';
import { Component, DestroyRef, inject, Input, TemplateRef, ViewChild } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { of, pipe, Subject } from 'rxjs';
import { debounceTime, map, tap } from 'rxjs/operators';
import * as i0 from "@angular/core";
import * as i1 from "@angular/common";
import * as i2 from "@angular/cdk/scrolling";
import * as i3 from "./virtual-scroll-window.directive";
export class VirtualScrollerWrapperComponent {
    constructor() {
        this.filterPipe = pipe(tap());
        this.checkViewportSize$ = new Subject();
        this.destroyRef = inject(DestroyRef);
        this.trackByFn = (i, item) => {
            return item.id;
        };
        this.checkViewportSize$
            .pipe(debounceTime(25), takeUntilDestroyed(this.destroyRef))
            .subscribe(() => {
            if (this.virtualScrollViewport) {
                this.virtualScrollViewport.checkViewportSize();
            }
        });
    }
    ngAfterViewChecked() {
        if (this.virtualScrollViewport) {
            this.checkViewportSize$.next();
        }
    }
    apply() {
        this.items$ = of(this.items).pipe(src => this.filterPipe(src), map(item => item));
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.9", ngImport: i0, type: VirtualScrollerWrapperComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.9", type: VirtualScrollerWrapperComponent, selector: "c8y-virtual-scroller-wrapper", inputs: { items: "items", itemHeight: "itemHeight", containerHeight: "containerHeight", template: "template", filterPipe: "filterPipe", strategy: "strategy", trackByFn: "trackByFn" }, viewQueries: [{ propertyName: "virtualScrollViewport", first: true, predicate: CdkVirtualScrollViewport, descendants: true }], ngImport: i0, template: "<ng-container *ngIf=\"items$ |async as items\" [ngSwitch]=\"strategy\">\n    <ng-container *ngSwitchCase=\"'window'\">\n      <cdk-virtual-scroll-viewport windowVirtualScrollStrategy [itemSizePx]=\"itemHeight\" class=\"inner-scroll\">\n        <div *cdkVirtualFor=\"let item of items; index as i; trackBy: trackByFn\">\n          <ng-container *ngTemplateOutlet=\"template; context: {$implicit: item, index: i}\"></ng-container>\n        </div>\n      </cdk-virtual-scroll-viewport>\n    </ng-container>\n\n    <ng-container *ngSwitchCase=\"'fixed'\">\n      <cdk-virtual-scroll-viewport [itemSize]=\"itemHeight\" [style.height]=\"containerHeight + 'px'\" class=\"inner-scroll\">\n        <div *cdkVirtualFor=\"let item of items; index as i; trackBy: trackByFn\" >\n          <ng-container *ngTemplateOutlet=\"template; context: {$implicit: item, index: i}\"></ng-container>\n        </div>\n      </cdk-virtual-scroll-viewport>\n    </ng-container>\n</ng-container>\n", dependencies: [{ kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: i1.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { kind: "directive", type: i1.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }, { kind: "directive", type: i2.CdkFixedSizeVirtualScroll, selector: "cdk-virtual-scroll-viewport[itemSize]", inputs: ["itemSize", "minBufferPx", "maxBufferPx"] }, { kind: "directive", type: i2.CdkVirtualForOf, selector: "[cdkVirtualFor][cdkVirtualForOf]", inputs: ["cdkVirtualForOf", "cdkVirtualForTrackBy", "cdkVirtualForTemplate", "cdkVirtualForTemplateCacheSize"] }, { kind: "component", type: i2.CdkVirtualScrollViewport, selector: "cdk-virtual-scroll-viewport", inputs: ["orientation", "appendOnly"], outputs: ["scrolledIndexChange"] }, { kind: "directive", type: i3.VirtualScrollWindowDirective, selector: "cdk-virtual-scroll-viewport[windowVirtualScrollStrategy]", inputs: ["itemSizePx", "minBufferPx", "maxBufferPx", "offsetSizePx"] }, { kind: "pipe", type: i1.AsyncPipe, name: "async" }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.9", ngImport: i0, type: VirtualScrollerWrapperComponent, decorators: [{
            type: Component,
            args: [{ selector: 'c8y-virtual-scroller-wrapper', template: "<ng-container *ngIf=\"items$ |async as items\" [ngSwitch]=\"strategy\">\n    <ng-container *ngSwitchCase=\"'window'\">\n      <cdk-virtual-scroll-viewport windowVirtualScrollStrategy [itemSizePx]=\"itemHeight\" class=\"inner-scroll\">\n        <div *cdkVirtualFor=\"let item of items; index as i; trackBy: trackByFn\">\n          <ng-container *ngTemplateOutlet=\"template; context: {$implicit: item, index: i}\"></ng-container>\n        </div>\n      </cdk-virtual-scroll-viewport>\n    </ng-container>\n\n    <ng-container *ngSwitchCase=\"'fixed'\">\n      <cdk-virtual-scroll-viewport [itemSize]=\"itemHeight\" [style.height]=\"containerHeight + 'px'\" class=\"inner-scroll\">\n        <div *cdkVirtualFor=\"let item of items; index as i; trackBy: trackByFn\" >\n          <ng-container *ngTemplateOutlet=\"template; context: {$implicit: item, index: i}\"></ng-container>\n        </div>\n      </cdk-virtual-scroll-viewport>\n    </ng-container>\n</ng-container>\n" }]
        }], ctorParameters: () => [], propDecorators: { virtualScrollViewport: [{
                type: ViewChild,
                args: [CdkVirtualScrollViewport]
            }], items: [{
                type: Input
            }], itemHeight: [{
                type: Input
            }], containerHeight: [{
                type: Input
            }], template: [{
                type: Input
            }], filterPipe: [{
                type: Input
            }], strategy: [{
                type: Input
            }], trackByFn: [{
                type: Input
            }] } });
//# sourceMappingURL=data:application/json;base64, 