import { Component, ElementRef, Input } from '@angular/core';
import { AbstractControl } from '@angular/forms';
import { IconSelectComponent } from '@aztrix/components/icon-select';
import { OverlayService } from '@aztrix/components/overlay';
import * as i0 from "@angular/core";
import * as i1 from "@aztrix/components/overlay";
import * as i2 from "@angular/common";
import * as i3 from "@aztrix/icons";
import * as i4 from "@aztrix/components/button";
import * as i5 from "@aztrix/helpers";
export class IconSelectEditComponent {
    constructor(_elementRef, _overlay) {
        this._elementRef = _elementRef;
        this._overlay = _overlay;
    }
    ngOnInit() {
        if (!this.iconControl.value) {
            this.iconControl.setValue(this.defaultIcon, { emitEvent: false });
        }
    }
    changeIcon() {
        const modalRef = this._overlay.createModal(this._elementRef, IconSelectComponent, {
            title: 'label.icon.change',
            init: (modal) => {
                modal.form = this.iconControl;
                modal.form.valueChanges.subscribe(() => {
                    this._overlay.closeModal(modalRef);
                });
            },
        });
    }
    resetIcon() {
        this.iconControl.setValue(this.defaultIcon);
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.11", ngImport: i0, type: IconSelectEditComponent, deps: [{ token: i0.ElementRef }, { token: i1.OverlayService }], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.11", type: IconSelectEditComponent, selector: "ax-icon-select-edit", inputs: { defaultIcon: "defaultIcon", iconControl: "iconControl" }, ngImport: i0, template: "<h3 class=\"small-label\">{{ 'label.icon.change' | translate }}</h3>\n<div class=\"icon-change-wrapper\">\n  <ax-icon class=\"icon custom-icon\" [name]=\"iconControl.value\"></ax-icon>\n  <div class=\"actions\">\n    <button axButton filled color=\"primary\" (click)=\"changeIcon()\">\n      {{ 'label.edit' | translate }}\n    </button>\n    <button *ngIf=\"iconControl?.value !== defaultIcon\" axButton (click)=\"resetIcon()\">\n      {{ 'label.reset' | translate }}\n    </button>\n  </div>\n</div>\n", styles: [".small-label{margin-bottom:.5rem}.icon-change-wrapper{display:flex;gap:.5rem;align-items:center;margin-bottom:.75rem}.custom-icon{background-color:#ebebeb;padding:7px;border-radius:20px;width:120px;height:120px}.actions{display:flex;flex-direction:column}\n"], dependencies: [{ kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i3.IconComponent, selector: "ax-icon", inputs: ["name", "inline"] }, { kind: "directive", type: i4.ButtonDirective, selector: "[axButton]", inputs: ["color", "labelHideMobile", "smallButton", "bigButton", "fullWidth", "filled", "outline", "icon-button", "hoverLabel", "hover", "lowercase", "disabled"] }, { kind: "pipe", type: i5.TranslatePipe, name: "translate" }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.11", ngImport: i0, type: IconSelectEditComponent, decorators: [{
            type: Component,
            args: [{ selector: 'ax-icon-select-edit', template: "<h3 class=\"small-label\">{{ 'label.icon.change' | translate }}</h3>\n<div class=\"icon-change-wrapper\">\n  <ax-icon class=\"icon custom-icon\" [name]=\"iconControl.value\"></ax-icon>\n  <div class=\"actions\">\n    <button axButton filled color=\"primary\" (click)=\"changeIcon()\">\n      {{ 'label.edit' | translate }}\n    </button>\n    <button *ngIf=\"iconControl?.value !== defaultIcon\" axButton (click)=\"resetIcon()\">\n      {{ 'label.reset' | translate }}\n    </button>\n  </div>\n</div>\n", styles: [".small-label{margin-bottom:.5rem}.icon-change-wrapper{display:flex;gap:.5rem;align-items:center;margin-bottom:.75rem}.custom-icon{background-color:#ebebeb;padding:7px;border-radius:20px;width:120px;height:120px}.actions{display:flex;flex-direction:column}\n"] }]
        }], ctorParameters: () => [{ type: i0.ElementRef }, { type: i1.OverlayService }], propDecorators: { defaultIcon: [{
                type: Input
            }], iconControl: [{
                type: Input
            }] } });
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaWNvbi1zZWxlY3QtZWRpdC5jb21wb25lbnQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNl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