/**
 * @fileoverview added by tsickle
 * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
 */
import * as tslib_1 from "tslib";
import { Component, Input, forwardRef } from '@angular/core';
import { NG_VALUE_ACCESSOR } from '@angular/forms';
import { Countries } from './countries';
var PhoneInputComponent = /** @class */ (function () {
    function PhoneInputComponent() {
        this._phoneData = {
            code: '',
            value: ''
        };
        this.COUNTRIES = Countries;
        this.propagateChange = function (val) { };
    }
    Object.defineProperty(PhoneInputComponent.prototype, "phoneData", {
        get: /**
         * @return {?}
         */
        function () {
            return this._phoneData;
        },
        set: /**
         * @param {?} val
         * @return {?}
         */
        function (val) {
            this._phoneData = val;
            this.propagateChange(this._phoneData);
        },
        enumerable: true,
        configurable: true
    });
    /**
     * @param {?} val
     * @return {?}
     */
    PhoneInputComponent.prototype.selectCountry = /**
     * @param {?} val
     * @return {?}
     */
    function (val) {
        this.phoneData = tslib_1.__assign({}, this.phoneData, { code: val });
    };
    /**
     * @param {?} val
     * @return {?}
     */
    PhoneInputComponent.prototype.enterPhone = /**
     * @param {?} val
     * @return {?}
     */
    function (val) {
        this.phoneData = tslib_1.__assign({}, this.phoneData, { value: val });
    };
    /**
     * @param {?} value
     * @return {?}
     */
    PhoneInputComponent.prototype.writeValue = /**
     * @param {?} value
     * @return {?}
     */
    function (value) {
        if (value !== undefined) {
            this.phoneData = value;
        }
    };
    /**
     * @param {?} fn
     * @return {?}
     */
    PhoneInputComponent.prototype.registerOnChange = /**
     * @param {?} fn
     * @return {?}
     */
    function (fn) {
        this.propagateChange = fn;
    };
    /**
     * @return {?}
     */
    PhoneInputComponent.prototype.registerOnTouched = /**
     * @return {?}
     */
    function () { };
    PhoneInputComponent.decorators = [
        { type: Component, args: [{
                    // tslint:disable-next-line:component-selector
                    selector: 'app-phone-input',
                    template: "<div class=\"phone-box form-group\">\n  <select #country (change)=\"selectCountry(country.value)\" class=\"phone-code\" [(ngModel)]=\"phoneData.code\">\n    <option value=\"{{ country.callingCodes[0] }}\" *ngFor=\"let country of COUNTRIES\">\n      <span>{{ country.name }}</span>\n    </option>\n  </select>\n  <div class=\"phone-number-box\">\n    <span class=\"plus-code\" *ngIf=\"phoneData.code\">(+{{ phoneData.code }}) </span>\n    <input type=\"text\" #phone (change)=\"enterPhone(phone.value)\" class=\"phone-value\" [(ngModel)]=\"phoneData.value\">\n  </div>\n</div>\n",
                    providers: [{
                            provide: NG_VALUE_ACCESSOR,
                            useExisting: forwardRef(function () { return PhoneInputComponent; }),
                            multi: true
                        }],
                    styles: [".phone-box{position:relative;clear:both;border:1px solid #ccc;height:31px}.phone-box .phone-code{-webkit-appearance:none;-moz-appearance:none;appearance:none;border:0;background-color:#333;color:#fff;border-radius:0;float:left;padding:5px;margin-right:10px;width:120px}.phone-box .phone-number-box{line-height:27px}.phone-box .phone-number-box .phone-value{border:0;background-color:transparent;width:125px}"]
                }] }
    ];
    PhoneInputComponent.propDecorators = {
        _phoneData: [{ type: Input }]
    };
    return PhoneInputComponent;
}());
export { PhoneInputComponent };
if (false) {
    /** @type {?} */
    PhoneInputComponent.prototype._phoneData;
    /** @type {?} */
    PhoneInputComponent.prototype.COUNTRIES;
    /** @type {?} */
    PhoneInputComponent.prototype.propagateChange;
}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicGhvbmUtaW5wdXQuY29tcG9uZW50LmpzIiwic291cmNlUm9vdCI6Im5nOi8vcmVhY3RpdmUtZm9ybS10ZXN0LyIsInNvdXJjZXMiOlsibGliL2RpcmVjdGl2ZXMvcGhvbmUtaW5wdXQvcGhvbmUtaW5wdXQuY29tcG9uZW50LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7O0FBQUEsT0FBTyxFQUFFLFNBQVMsRUFBVSxLQUFLLEVBQUUsVUFBVSxFQUFFLE1BQU0sZUFBZSxDQUFDO0FBQ3JFLE9BQU8sRUFBd0IsaUJBQWlCLEVBQUUsTUFBTSxnQkFBZ0IsQ0FBQztBQUN6R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