import { Component, Inject } from '@angular/core';
import { getCountryCallingCode, isSupportedCountry } from 'libphonenumber-js/min';
import { UI_COUNTRIES } from '../../../../../tokens';
import * as i0 from "@angular/core";
import * as i1 from "../input-phone.directive";
import * as i2 from "@angular/common";
import * as i3 from "../../../../select/select.component";
import * as i4 from "../../../../option/option-country/option-country.component";
import * as i5 from "../../../../option/option.directive";
import * as i6 from "@angular/forms";
import * as i7 from "../../../../../avatar/avatar-country/avatar-country.component";
export class InputPhoneCountriesComponent {
    constructor(inputPhone, countries) {
        this.inputPhone = inputPhone;
        this.countries = [];
        this.countries = countries
            .filter(({ code }) => isSupportedCountry(code))
            .map(country => ({
            ...country,
            callingCode: getCountryCallingCode(country.code),
        }))
            .sort((a, b) => a.name > b.name ? 1 : -1);
    }
    ngOnInit() {
    }
    get value() {
        return this.inputPhone.country;
    }
    set value(value) {
        this.inputPhone.updateCountry(value);
    }
}
InputPhoneCountriesComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.4", ngImport: i0, type: InputPhoneCountriesComponent, deps: [{ token: i1.InputPhoneDirective }, { token: UI_COUNTRIES }], target: i0.ɵɵFactoryTarget.Component });
InputPhoneCountriesComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.0.4", type: InputPhoneCountriesComponent, selector: "ui-input-phone-countries", ngImport: i0, template: "<ui-select [(ngModel)]=\"value\">\n  <ng-container *ngFor=\"let country of countries\">\n    <ng-template #value>\n      <ui-avatar-country size=\"s\" [code]=\"country.code\"></ui-avatar-country>\n    </ng-template>\n    <ng-template uiOption\n                 [value]=\"country.code\"\n                 [valueTemplate]=\"value\"\n                 [label]=\"country.name\">\n      <ui-option-country [code]=\"country.code\"\n                         [comment]=\"'+' + country.callingCode\" compact>{{country.name}}</ui-option-country>\n    </ng-template>\n  </ng-container>\n</ui-select>\n", styles: [":host .dropdown{display:flex}\n"], dependencies: [{ kind: "directive", type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "component", type: i3.SelectComponent, selector: "ui-select", inputs: ["name", "autocomplete", "searchable", "multiple", "placeholder", "required", "disabled"] }, { kind: "component", type: i4.OptionCountryComponent, selector: "ui-option-country", inputs: ["code", "comment", "compact"] }, { kind: "directive", type: i5.OptionDirective, selector: "[uiOption]", inputs: ["value", "label", "disabled", "valueTemplate"] }, { kind: "directive", type: i6.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i6.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "component", type: i7.AvatarCountryComponent, selector: "ui-avatar-country", inputs: ["size", "code"] }] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.4", ngImport: i0, type: InputPhoneCountriesComponent, decorators: [{
            type: Component,
            args: [{ selector: 'ui-input-phone-countries', template: "<ui-select [(ngModel)]=\"value\">\n  <ng-container *ngFor=\"let country of countries\">\n    <ng-template #value>\n      <ui-avatar-country size=\"s\" [code]=\"country.code\"></ui-avatar-country>\n    </ng-template>\n    <ng-template uiOption\n                 [value]=\"country.code\"\n                 [valueTemplate]=\"value\"\n                 [label]=\"country.name\">\n      <ui-option-country [code]=\"country.code\"\n                         [comment]=\"'+' + country.callingCode\" compact>{{country.name}}</ui-option-country>\n    </ng-template>\n  </ng-container>\n</ui-select>\n", styles: [":host .dropdown{display:flex}\n"] }]
        }], ctorParameters: function () { return [{ type: i1.InputPhoneDirective }, { type: undefined, decorators: [{
                    type: Inject,
                    args: [UI_COUNTRIES]
                }] }]; } });
//# sourceMappingURL=data:application/json;base64, 