import * as i0 from '@angular/core';
import { InjectionToken, ElementRef, Directive, Optional, Inject, ViewChild, Input, HostBinding } from '@angular/core';

const LOADER_COMPONENT_TYPE_TOKEN = new InjectionToken('Loader Component Type Token');

const _c0 = ["customLoader"];
class LoaderBaseComponent {
    /** @internal */
    get loaderPosition() {
        return `position-${this.position}`;
    }
    constructor(elementRef, renderer, 
    /** @internal */
    componentType) {
        this.elementRef = elementRef;
        this.renderer = renderer;
        this.componentType = componentType;
        /** @internal */
        this.position = 'center';
        /** @internal */
        this.size = 'large';
        /** @internal */
        this.color = 'grey';
        this.size = this.size || 'large';
    }
    ngAfterViewInit() {
        const loaderEl = this.elementRef.nativeElement.querySelector('.is-loader');
        if (this.height && !!loaderEl) {
            this.renderer.setStyle(loaderEl, 'position', 'static');
            this.renderer.setStyle(loaderEl, 'min-height', this.height + 'px');
        }
        this.addCustomLoaderSizeClass();
    }
    addCustomLoaderSizeClass() {
        if (this.customLoader?.nativeElement?.previousSibling) {
            this.renderer.addClass(this.customLoader.nativeElement.previousSibling, this.size);
        }
    }
    static { this.ɵfac = function LoaderBaseComponent_Factory(t) { return new (t || LoaderBaseComponent)(i0.ɵɵdirectiveInject(i0.ElementRef), i0.ɵɵdirectiveInject(i0.Renderer2), i0.ɵɵdirectiveInject(LOADER_COMPONENT_TYPE_TOKEN, 8)); }; }
    static { this.ɵdir = /*@__PURE__*/ i0.ɵɵdefineDirective({ type: LoaderBaseComponent, viewQuery: function LoaderBaseComponent_Query(rf, ctx) { if (rf & 1) {
            i0.ɵɵviewQuery(_c0, 5, ElementRef);
        } if (rf & 2) {
            let _t;
            i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.customLoader = _t.first);
        } }, hostVars: 2, hostBindings: function LoaderBaseComponent_HostBindings(rf, ctx) { if (rf & 2) {
            i0.ɵɵstyleProp("top", ctx.top, "px");
        } }, inputs: { height: "height", status: "status", text: "text", position: "position", size: "size", color: "color" } }); }
}
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(LoaderBaseComponent, [{
        type: Directive
    }], () => [{ type: i0.ElementRef }, { type: i0.Renderer2 }, { type: undefined, decorators: [{
                type: Optional
            }, {
                type: Inject,
                args: [LOADER_COMPONENT_TYPE_TOKEN]
            }] }], { customLoader: [{
            type: ViewChild,
            args: ['customLoader', { read: ElementRef }]
        }], height: [{
            type: Input
        }], status: [{
            type: Input
        }], text: [{
            type: Input
        }], position: [{
            type: Input
        }], size: [{
            type: Input
        }], color: [{
            type: Input
        }], top: [{
            type: HostBinding,
            args: ['style.top.px']
        }] }); })();

/*
 * Created on 2020.4.19 By Andy Kononenko (andyk@ironsrc.com)
 */

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

export { LOADER_COMPONENT_TYPE_TOKEN, LoaderBaseComponent };
//# sourceMappingURL=ironsource-fusion-ui-components-loader-common-base.mjs.map
