import * as i0 from '@angular/core';
import { input, output, inject, ElementRef, Injector, runInInjectionContext, effect, ChangeDetectionStrategy, Component } from '@angular/core';
import '@ui5/webcomponents/dist/TableVirtualizer.js';

class TableVirtualizer {
    constructor() {
        /**
         * Defines the height of the rows in the table.
      
      **Note:** For virtualization to work properly, this property is mandatory.
         */
        this.rowHeight = input(45, ...(ngDevMode ? [{ debugName: "rowHeight" }] : []));
        /**
         * Defines the total count of rows in the table.
      
      **Note:** For virtualization to work properly, this property is mandatory.
         */
        this.rowCount = input(100, ...(ngDevMode ? [{ debugName: "rowCount" }] : []));
        /**
         * Defines the count of extra rows to be rendered at the top and bottom of the table.
      
      **Note:** This property is experimental and may be changed or deleted in the future.
         */
        this.extraRows = input(0, ...(ngDevMode ? [{ debugName: "extraRows" }] : [])); // className is now passed
        /**
         * Fired when the virtualizer is changed by user interaction e.g. on scrolling.
         */
        this.ui5RangeChange = output();
        this.elementRef = inject(ElementRef);
        this.injector = inject(Injector);
    }
    get element() {
        return this.elementRef.nativeElement;
    }
    ngAfterViewInit() {
        const wcElement = this.element;
        const inputsToSync = [
            'rowHeight',
            'rowCount',
            'extraRows',
        ];
        // Synchronize inputs (properties)
        for (const inputName of inputsToSync) {
            // Find the corresponding camelCase signal property on the Angular component
            const signalName = inputName.replace(/-./g, (x) => x[1].toUpperCase());
            // Use the Injector to run the effect in the correct context
            if (this[signalName] && typeof this[signalName] === 'function') {
                runInInjectionContext(this.injector, () => {
                    effect(() => {
                        // Read the signal value
                        const value = this[signalName]();
                        if (wcElement) {
                            // Write the value to the Web Component's property
                            wcElement[inputName] = value;
                        }
                    });
                });
            }
        }
        const outputsToSync = [
            'ui5RangeChange',
        ];
        // Synchronize outputs (events)
        for (const outputName of outputsToSync) {
            // Map Angular output name to UI5 web component event name
            const eventName = outputName.replace('ui5', '').replace(/([A-Z])/g, '-$1').toLowerCase().substring(1);
            // Ensure the output property exists and has an emit function before adding listener
            if (this[outputName] && typeof this[outputName].emit === 'function' && wcElement.addEventListener) {
                // Cast the listener to the correct type to satisfy TypeScript
                wcElement.addEventListener(eventName, (e) => {
                    this[outputName].emit(e);
                });
            }
        }
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.4", ngImport: i0, type: TableVirtualizer, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "20.1.4", type: TableVirtualizer, isStandalone: true, selector: "ui5-table-virtualizer, [ui5-table-virtualizer]", inputs: { rowHeight: { classPropertyName: "rowHeight", publicName: "rowHeight", isSignal: true, isRequired: false, transformFunction: null }, rowCount: { classPropertyName: "rowCount", publicName: "rowCount", isSignal: true, isRequired: false, transformFunction: null }, extraRows: { classPropertyName: "extraRows", publicName: "extraRows", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { ui5RangeChange: "ui5RangeChange" }, exportAs: ["ui5TableVirtualizer"], ngImport: i0, template: '<ng-content></ng-content>', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.4", ngImport: i0, type: TableVirtualizer, decorators: [{
            type: Component,
            args: [{
                    standalone: true,
                    selector: 'ui5-table-virtualizer, [ui5-table-virtualizer]',
                    template: '<ng-content></ng-content>',
                    exportAs: 'ui5TableVirtualizer',
                    changeDetection: ChangeDetectionStrategy.OnPush,
                }]
        }] });

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

export { TableVirtualizer };
//# sourceMappingURL=fundamental-ngx-ui5-webcomponents-table-virtualizer.mjs.map
