import * as i0 from '@angular/core';
import { Component, Inject, Input, NgModule, Optional } from '@angular/core';

class Icons {
    constructor(icons) {
        this.icons = icons;
    }
}

function uppercamelcase(str) {
    return str.toLowerCase().replace(/(?:^\w|[A-Z]|\b\w)/g, (firstLetter) => {
        return firstLetter.toUpperCase();
    }).replace(/[-_]/g, '');
}

class BootstrapIcons {
    constructor(elem, changeDetector, icons) {
        this.elem = elem;
        this.changeDetector = changeDetector;
        this.icons = icons;
    }
    ngOnChanges(changes) {
        // icons are provided as an array of objects because of "multi: true"
        const icons = Object.assign({}, ...this.icons);
        const svg = icons[uppercamelcase(changes.name.currentValue)] || "";
        if (!svg) {
            console.warn(`Icon not found: ${changes.name.currentValue}\n` +
                `Refer to documentation on https://github.com/biutas/ng-bootstrap-icons/issues`);
        }
        this.elem.nativeElement.innerHTML = svg;
        this.changeDetector.markForCheck();
    }
}
BootstrapIcons.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: BootstrapIcons, deps: [{ token: i0.ElementRef }, { token: i0.ChangeDetectorRef }, { token: Icons }], target: i0.ɵɵFactoryTarget.Component });
BootstrapIcons.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.1.1", type: BootstrapIcons, selector: "bt-icon, bootstrap-icon, bi", inputs: { name: "name" }, usesOnChanges: true, ngImport: i0, template: "<ng-content></ng-content>\n", styles: [":host{display:flex;justify-content:center;align-items:center;width:100%;height:100%;fill:none;stroke-linecap:round;stroke-linejoin:round}:host svg{width:100%!important;height:100%!important}\n"] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: BootstrapIcons, decorators: [{
            type: Component,
            args: [{ selector: "bt-icon, bootstrap-icon, bi", template: "<ng-content></ng-content>\n", styles: [":host{display:flex;justify-content:center;align-items:center;width:100%;height:100%;fill:none;stroke-linecap:round;stroke-linejoin:round}:host svg{width:100%!important;height:100%!important}\n"] }]
        }], ctorParameters: function () {
        return [{ type: i0.ElementRef }, { type: i0.ChangeDetectorRef }, { type: Icons, decorators: [{
                        type: Inject,
                        args: [Icons]
                    }] }];
    }, propDecorators: { name: [{
                type: Input
            }] } });

class BootstrapIconsModule {
    constructor(icons) {
        this.icons = icons;
        if (!this.icons) {
            throw new Error(`No icon provided. Make sure to use 'BootstrapIconsModule.pick({ ... })' when importing the module\n` +
                `Refer to documentation on https://github.com/biutas/ng-bootstrap-icons/issues`);
        }
    }
    static pick(icons) {
        return {
            ngModule: BootstrapIconsModule,
            providers: [{ provide: Icons, multi: true, useValue: icons }],
        };
    }
}
BootstrapIconsModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: BootstrapIconsModule, deps: [{ token: Icons, optional: true }], target: i0.ɵɵFactoryTarget.NgModule });
BootstrapIconsModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: BootstrapIconsModule, declarations: [BootstrapIcons], exports: [BootstrapIcons] });
BootstrapIconsModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: BootstrapIconsModule });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.1", ngImport: i0, type: BootstrapIconsModule, decorators: [{
            type: NgModule,
            args: [{
                    declarations: [BootstrapIcons],
                    exports: [BootstrapIcons],
                }]
        }], ctorParameters: function () {
        return [{ type: Icons, decorators: [{
                        type: Optional
                    }] }];
    } });

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

export { BootstrapIcons, BootstrapIconsModule };
//# sourceMappingURL=ng-bootstrap-icons.mjs.map
