import * as i0 from '@angular/core';
import { EventEmitter, Component, Output } from '@angular/core';
import * as i1 from '@angular/forms';
import { FormsModule } from '@angular/forms';

class MailBoxCounterComponent {
    constructor() {
        this.mailBoxsQuantityEvent = new EventEmitter();
        this.quantity = 1;
        this.maxQuantity = 30000;
        this.minQuantity = 1;
    }
    decreaseQuantity() {
        this.quantity--;
        this.mailBoxsQuantityEvent.emit(this.quantity);
    }
    increaseQuantity() {
        if (this.quantity < this.maxQuantity)
            this.quantity++;
        this.mailBoxsQuantityEvent.emit(this.quantity);
    }
    changeQuantity(event) {
        //TODO :this function need to be modefied >> we need the user just enter numbers and with limits.
        if (Number(event.currentTarget.value > this.maxQuantity)) {
            this.quantity = this.maxQuantity;
        }
        else if (Number(event.currentTarget.value <= 0)) {
            this.quantity = this.minQuantity;
        }
        else if (isNaN(Number(event.currentTarget.value))) {
            event.currentTarget.value = this.minQuantity;
            this.quantity = Number(event.currentTarget.value);
        }
        else {
            this.quantity = Number(event.currentTarget.value);
        }
        this.mailBoxsQuantityEvent.emit(this.quantity);
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MailBoxCounterComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: MailBoxCounterComponent, isStandalone: true, selector: "lib-mail-box-counter", outputs: { mailBoxsQuantityEvent: "mailBoxsQuantityEvent" }, ngImport: i0, template: "<section id=\"mail-box-counter\">\r\n    <div class=\"mail-icon text-center\">\r\n        <div class=\"text\">\r\n            <span>Number Of Mailboxes:</span>\r\n        </div>\r\n    </div>\r\n    <div class=\"d-flex\">\r\n        <span class=\"minus-icon\">\r\n            <button type=\"button\" class=\"btn btn-default\" [disabled]=\"quantity == minQuantity\" (click)=\"decreaseQuantity()\">\r\n            </button>\r\n        </span>\r\n        <input  type=\"text\" class=\"mt-1 form-control \" (change)=\"changeQuantity($event)\" [(ngModel)]=\"quantity\" \r\n            [min]=\"minQuantity\" [max]=\"maxQuantity\">\r\n        <span class=\"plus-icon\">\r\n            <button type=\"button\" class=\"btn btn-default\" (click)=\"increaseQuantity()\">\r\n            </button>\r\n        </span>\r\n    </div>\r\n</section>", styles: ["#mail-box-counter .mail-icon{color:#1e439a;font-size:16px}#mail-box-counter .mail-icon .text span{color:#969696;font-weight:600}#mail-box-counter input[type=text]{text-align:center}#mail-box-counter .minus-icon button,#mail-box-counter .plus-icon button{cursor:initial;color:#1e439a}\n"], dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: MailBoxCounterComponent, decorators: [{
            type: Component,
            args: [{ selector: 'lib-mail-box-counter', imports: [
                        FormsModule
                    ], standalone: true, template: "<section id=\"mail-box-counter\">\r\n    <div class=\"mail-icon text-center\">\r\n        <div class=\"text\">\r\n            <span>Number Of Mailboxes:</span>\r\n        </div>\r\n    </div>\r\n    <div class=\"d-flex\">\r\n        <span class=\"minus-icon\">\r\n            <button type=\"button\" class=\"btn btn-default\" [disabled]=\"quantity == minQuantity\" (click)=\"decreaseQuantity()\">\r\n            </button>\r\n        </span>\r\n        <input  type=\"text\" class=\"mt-1 form-control \" (change)=\"changeQuantity($event)\" [(ngModel)]=\"quantity\" \r\n            [min]=\"minQuantity\" [max]=\"maxQuantity\">\r\n        <span class=\"plus-icon\">\r\n            <button type=\"button\" class=\"btn btn-default\" (click)=\"increaseQuantity()\">\r\n            </button>\r\n        </span>\r\n    </div>\r\n</section>", styles: ["#mail-box-counter .mail-icon{color:#1e439a;font-size:16px}#mail-box-counter .mail-icon .text span{color:#969696;font-weight:600}#mail-box-counter input[type=text]{text-align:center}#mail-box-counter .minus-icon button,#mail-box-counter .plus-icon button{cursor:initial;color:#1e439a}\n"] }]
        }], propDecorators: { mailBoxsQuantityEvent: [{
                type: Output
            }] } });

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

export { MailBoxCounterComponent };
//# sourceMappingURL=testlocallibrary-shared-kernel-components-mail-box-counter.mjs.map
