import { Component, ElementRef, Input } from '@angular/core';
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/translate";
export class IconSelectEditComponent {
    constructor(_elementRef, _overlay) {
        this._elementRef = _elementRef;
        this._overlay = _overlay;
    }
    ngOnInit() {
        if (this.iconControl && !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.12", 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.12", 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.12", 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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaWNvbi1zZWxlY3QtZWRpdC5jb21wb25lbnQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIu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