import * as i0 from '@angular/core';
import { Input, Component, NgModule } from '@angular/core';
import * as i1 from '@aztrix/helpers';
import * as i2 from '@angular/common';
import { CommonModule } from '@angular/common';
import * as i3 from '@aztrix/translate';
import { TranslatePipe } from '@aztrix/translate';

class FontSelectComponent {
    constructor(_fonts) {
        this._fonts = _fonts;
        this.fontsGrouped = this._fonts.fonts.reduce((prev, curr) => {
            const item = prev.find((i) => i.type === curr.type);
            if (item) {
                item.fonts.push(curr);
            }
            else {
                prev.push({ type: curr.type, fonts: [curr] });
            }
            return prev;
        }, []);
    }
    ngOnInit() {
        this._fonts.loadAllFonts().then();
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: FontSelectComponent, deps: [{ token: i1.FontsService }], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.12", type: FontSelectComponent, selector: "ax-font-select", inputs: { form: "form" }, ngImport: i0, template: "<div *ngFor=\"let fontGroup of fontsGrouped\">\n  <h3>{{ 'page.edit.appearance.font.type.' + fontGroup.type | translate }}</h3>\n  <div class=\"fonts\">\n    <div class=\"wrapper\" *ngFor=\"let font of fontGroup.fonts\" (click)=\"form?.setValue(font.value)\">\n      <button class=\"button\" [ngClass]=\"{selected: font.value === form?.value}\">\n        <span class=\"font-label\" [ngStyle]=\"{'font-family': font.value}\">Aa</span>\n      </button>\n      <span class=\"option-label\">{{ font.label }}</span>\n    </div>\n  </div>\n</div>\n", styles: [":host{display:flex;flex-direction:column;gap:2rem}.fonts{display:grid;grid-gap:1rem;grid-template-columns:repeat(auto-fill,minmax(90px,1fr))}.wrapper{width:100%;min-height:80px;display:flex;flex-direction:column;align-items:center;text-align:center}.button{position:relative;display:inline-block;width:100%;height:70px;overflow:hidden;background-color:#efefef;border-radius:10px;cursor:pointer;-webkit-user-select:none;user-select:none;border-width:0}.button.selected{background-color:var(--primary-color-500)}.font-label{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);font-size:2rem}.option-label{margin-top:.5rem}\n"], dependencies: [{ kind: "directive", type: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i2.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "pipe", type: i3.TranslatePipe, name: "translate" }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: FontSelectComponent, decorators: [{
            type: Component,
            args: [{ selector: 'ax-font-select', template: "<div *ngFor=\"let fontGroup of fontsGrouped\">\n  <h3>{{ 'page.edit.appearance.font.type.' + fontGroup.type | translate }}</h3>\n  <div class=\"fonts\">\n    <div class=\"wrapper\" *ngFor=\"let font of fontGroup.fonts\" (click)=\"form?.setValue(font.value)\">\n      <button class=\"button\" [ngClass]=\"{selected: font.value === form?.value}\">\n        <span class=\"font-label\" [ngStyle]=\"{'font-family': font.value}\">Aa</span>\n      </button>\n      <span class=\"option-label\">{{ font.label }}</span>\n    </div>\n  </div>\n</div>\n", styles: [":host{display:flex;flex-direction:column;gap:2rem}.fonts{display:grid;grid-gap:1rem;grid-template-columns:repeat(auto-fill,minmax(90px,1fr))}.wrapper{width:100%;min-height:80px;display:flex;flex-direction:column;align-items:center;text-align:center}.button{position:relative;display:inline-block;width:100%;height:70px;overflow:hidden;background-color:#efefef;border-radius:10px;cursor:pointer;-webkit-user-select:none;user-select:none;border-width:0}.button.selected{background-color:var(--primary-color-500)}.font-label{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);font-size:2rem}.option-label{margin-top:.5rem}\n"] }]
        }], ctorParameters: () => [{ type: i1.FontsService }], propDecorators: { form: [{
                type: Input
            }] } });

class FontSelectModule {
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: FontSelectModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
    static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.3.12", ngImport: i0, type: FontSelectModule, declarations: [FontSelectComponent], imports: [CommonModule, TranslatePipe], exports: [FontSelectComponent] }); }
    static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: FontSelectModule, imports: [CommonModule] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: FontSelectModule, decorators: [{
            type: NgModule,
            args: [{
                    declarations: [FontSelectComponent],
                    imports: [CommonModule, TranslatePipe],
                    exports: [FontSelectComponent],
                }]
        }] });

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

export { FontSelectComponent, FontSelectModule };
//# sourceMappingURL=aztrix-components-font-select.mjs.map
