import { Component, Input } from '@angular/core';
import { FontsService } from '@aztrix/helpers';
import * as i0 from "@angular/core";
import * as i1 from "@aztrix/helpers";
import * as i2 from "@angular/common";
export 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: i1.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
            }] } });
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZm9udC1zZWxlY3QuY29tcG9uZW50LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJ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