import { parsePhoneNumberFromString } from 'libphonenumber-js';
import { PHONE_NAME } from '../filter-names';
/**
 * Available formats:
 * NATIONAL — Example: "(213) 373-4253"
 * INTERNATIONAL — Example: "+1 213 373 4253"
 *
 * A ticket has been opened for Google in order to fix the National format. It shouldn't have parenthesis.
 * https://issuetracker.google.com/issues/153616208)
 */
export var PhoneNumberFormat;
(function (PhoneNumberFormat) {
    PhoneNumberFormat["INTERNATIONAL"] = "INTERNATIONAL";
    PhoneNumberFormat["NATIONAL"] = "NATIONAL";
})(PhoneNumberFormat || (PhoneNumberFormat = {}));
var PhoneFilter = /** @class */ (function () {
    function PhoneFilter() {
    }
    PhoneFilter.format = function (text, format) {
        if (format === void 0) { format = PhoneNumberFormat.INTERNATIONAL; }
        if (text.length > 0) {
            var phoneNumber = parsePhoneNumberFromString(text, 'CA');
            return phoneNumber ? phoneNumber.format(format) : '';
        }
        else {
            return '';
        }
    };
    return PhoneFilter;
}());
export { PhoneFilter };
var PhoneFilterPlugin = {
    install: function (v) {
        v.filter(PHONE_NAME, PhoneFilter.format);
    }
};
export default PhoneFilterPlugin;
//# sourceMappingURL=phone.js.map