Browse Source

Fix for ExactlySameAs (c++) and IsNumberMatch (#1567)

* isNumberMatch fix for numbers with italian leading zero fields set. Only
affects people who haven't correctly constructed phone numbers using
methods like 'parse'.
* Adding C++ tests and fixing bug in ExactlySameAs method, which wasn't
updated to handle the number_of_leading_zeros field when that was added
to the phone number proto.

See pending_code_changes.txt for more details.
pull/1571/head
lararennie 9 years ago
committed by GitHub
parent
commit
285fc577d2
9 changed files with 373 additions and 127 deletions
  1. +6
    -0
      cpp/src/phonenumbers/phonenumber.cc
  2. +28
    -19
      cpp/src/phonenumbers/phonenumberutil.cc
  3. +65
    -0
      cpp/test/phonenumbers/phonenumberutil_test.cc
  4. +27
    -21
      java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java
  5. +49
    -0
      java/libphonenumber/test/com/google/i18n/phonenumbers/PhoneNumberUtilTest.java
  6. +8
    -0
      java/pending_code_changes.txt
  7. +57
    -56
      javascript/i18n/phonenumbers/demo-compiled.js
  8. +58
    -31
      javascript/i18n/phonenumbers/phonenumberutil.js
  9. +75
    -0
      javascript/i18n/phonenumbers/phonenumberutil_test.js

+ 6
- 0
cpp/src/phonenumbers/phonenumber.cc View File

@ -41,6 +41,12 @@ bool ExactlySameAs(const PhoneNumber& first_number,
second_number.italian_leading_zero()) { second_number.italian_leading_zero()) {
return false; return false;
} }
if (first_number.has_number_of_leading_zeros() !=
second_number.has_number_of_leading_zeros() ||
first_number.number_of_leading_zeros() !=
second_number.number_of_leading_zeros()) {
return false;
}
if (first_number.has_raw_input() != second_number.has_raw_input() || if (first_number.has_raw_input() != second_number.has_raw_input() ||
first_number.raw_input() != second_number.raw_input()) { first_number.raw_input() != second_number.raw_input()) {
return false; return false;


+ 28
- 19
cpp/src/phonenumbers/phonenumberutil.cc View File

@ -300,6 +300,25 @@ PhoneNumberUtil::ValidationResult TestNumberLength(
? PhoneNumberUtil::IS_POSSIBLE : PhoneNumberUtil::TOO_LONG; ? PhoneNumberUtil::IS_POSSIBLE : PhoneNumberUtil::TOO_LONG;
} }
// Returns a new phone number containing only the fields needed to uniquely
// identify a phone number, rather than any fields that capture the context in
// which the phone number was created.
// These fields correspond to those set in Parse() rather than
// ParseAndKeepRawInput().
void CopyCoreFieldsOnly(const PhoneNumber& number, PhoneNumber* pruned_number) {
pruned_number->set_country_code(number.country_code());
pruned_number->set_national_number(number.national_number());
if (!number.extension().empty()) {
pruned_number->set_extension(number.extension());
}
if (number.italian_leading_zero()) {
pruned_number->set_italian_leading_zero(true);
// This field is only relevant if there are leading zeros at all.
pruned_number->set_number_of_leading_zeros(
number.number_of_leading_zeros());
}
}
} // namespace } // namespace
void PhoneNumberUtil::SetLogger(Logger* logger) { void PhoneNumberUtil::SetLogger(Logger* logger) {
@ -1937,6 +1956,9 @@ void PhoneNumberUtil::BuildNationalNumberForParsing(
// RFC3966. // RFC3966.
} }
// Note if any new field is added to this method that should always be filled
// in, even when keepRawInput is false, it should also be handled in the
// CopyCoreFieldsOnly() method.
PhoneNumberUtil::ErrorType PhoneNumberUtil::ParseHelper( PhoneNumberUtil::ErrorType PhoneNumberUtil::ParseHelper(
const string& number_to_parse, const string& number_to_parse,
const string& default_region, const string& default_region,
@ -2790,25 +2812,12 @@ PhoneNumberUtil::ErrorType PhoneNumberUtil::MaybeExtractCountryCode(
PhoneNumberUtil::MatchType PhoneNumberUtil::IsNumberMatch( PhoneNumberUtil::MatchType PhoneNumberUtil::IsNumberMatch(
const PhoneNumber& first_number_in, const PhoneNumber& first_number_in,
const PhoneNumber& second_number_in) const { const PhoneNumber& second_number_in) const {
// Make copies of the phone number so that the numbers passed in are not
// edited.
PhoneNumber first_number(first_number_in);
PhoneNumber second_number(second_number_in);
// First clear raw_input and country_code_source and
// preferred_domestic_carrier_code fields and any empty-string extensions so
// that we can use the proto-buffer equality method.
first_number.clear_raw_input();
first_number.clear_country_code_source();
first_number.clear_preferred_domestic_carrier_code();
second_number.clear_raw_input();
second_number.clear_country_code_source();
second_number.clear_preferred_domestic_carrier_code();
if (first_number.extension().empty()) {
first_number.clear_extension();
}
if (second_number.extension().empty()) {
second_number.clear_extension();
}
// We only are about the fields that uniquely define a number, so we copy
// these across explicitly.
PhoneNumber first_number;
CopyCoreFieldsOnly(first_number_in, &first_number);
PhoneNumber second_number;
CopyCoreFieldsOnly(second_number_in, &second_number);
// Early exit if both had extensions and these are different. // Early exit if both had extensions and these are different.
if (first_number.has_extension() && second_number.has_extension() && if (first_number.has_extension() && second_number.has_extension() &&
first_number.extension() != second_number.extension()) { first_number.extension() != second_number.extension()) {


+ 65
- 0
cpp/test/phonenumbers/phonenumberutil_test.cc View File

@ -2835,7 +2835,72 @@ TEST_F(PhoneNumberUtilTest, IsNumberMatchMatches) {
nz_number_2.set_national_number(33316005ULL); nz_number_2.set_national_number(33316005ULL);
EXPECT_EQ(PhoneNumberUtil::EXACT_MATCH, EXPECT_EQ(PhoneNumberUtil::EXACT_MATCH,
phone_util_.IsNumberMatch(nz_number, nz_number_2)); phone_util_.IsNumberMatch(nz_number, nz_number_2));
}
TEST_F(PhoneNumberUtilTest, IsNumberMatchShortMatchIfDiffNumLeadingZeros) {
PhoneNumber nz_number_one;
nz_number_one.set_country_code(64);
nz_number_one.set_national_number(33316005ULL);
nz_number_one.set_italian_leading_zero(true);
PhoneNumber nz_number_two;
nz_number_two.set_country_code(64);
nz_number_two.set_national_number(33316005ULL);
nz_number_two.set_italian_leading_zero(true);
nz_number_two.set_number_of_leading_zeros(2);
EXPECT_EQ(PhoneNumberUtil::SHORT_NSN_MATCH,
phone_util_.IsNumberMatch(nz_number_one, nz_number_two));
nz_number_one.set_italian_leading_zero(false);
nz_number_one.set_number_of_leading_zeros(1);
nz_number_two.set_italian_leading_zero(true);
nz_number_two.set_number_of_leading_zeros(1);
// Since one doesn't have the "italian_leading_zero" set to true, we ignore
// the number of leading zeros present (1 is in any case the default value).
EXPECT_EQ(PhoneNumberUtil::SHORT_NSN_MATCH,
phone_util_.IsNumberMatch(nz_number_one, nz_number_two));
}
TEST_F(PhoneNumberUtilTest, IsNumberMatchAcceptsProtoDefaultsAsMatch) {
PhoneNumber nz_number_one;
nz_number_one.set_country_code(64);
nz_number_one.set_national_number(33316005ULL);
nz_number_one.set_italian_leading_zero(true);
PhoneNumber nz_number_two;
nz_number_two.set_country_code(64);
nz_number_two.set_national_number(33316005ULL);
nz_number_two.set_italian_leading_zero(true);
// The default for number_of_leading_zeros is 1, so it shouldn't normally be
// set, however if it is it should be considered equivalent.
nz_number_two.set_number_of_leading_zeros(1);
EXPECT_EQ(PhoneNumberUtil::EXACT_MATCH,
phone_util_.IsNumberMatch(nz_number_one, nz_number_two));
}
TEST_F(PhoneNumberUtilTest,
IsNumberMatchMatchesDiffLeadingZerosIfItalianLeadingZeroFalse) {
PhoneNumber nz_number_one;
nz_number_one.set_country_code(64);
nz_number_one.set_national_number(33316005ULL);
PhoneNumber nz_number_two;
nz_number_two.set_country_code(64);
nz_number_two.set_national_number(33316005ULL);
// The default for number_of_leading_zeros is 1, so it shouldn't normally be
// set, however if it is it should be considered equivalent.
nz_number_two.set_number_of_leading_zeros(1);
EXPECT_EQ(PhoneNumberUtil::EXACT_MATCH,
phone_util_.IsNumberMatch(nz_number_one, nz_number_two));
// Even if it is set to ten, it is still equivalent because in both cases
// italian_leading_zero is not true.
nz_number_two.set_number_of_leading_zeros(10);
EXPECT_EQ(PhoneNumberUtil::EXACT_MATCH,
phone_util_.IsNumberMatch(nz_number_one, nz_number_two));
}
TEST_F(PhoneNumberUtilTest, IsNumberMatchIgnoresSomeFields) {
// Check raw_input, country_code_source and preferred_domestic_carrier_code // Check raw_input, country_code_source and preferred_domestic_carrier_code
// are ignored. // are ignored.
PhoneNumber br_number_1; PhoneNumber br_number_1;


+ 27
- 21
java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java View File

@ -2943,6 +2943,9 @@ public class PhoneNumberUtil {
* parse() method, with the exception that it allows the default region to be null, for use by * parse() method, with the exception that it allows the default region to be null, for use by
* isNumberMatch(). checkRegion should be set to false if it is permitted for the default region * isNumberMatch(). checkRegion should be set to false if it is permitted for the default region
* to be null or unknown ("ZZ"). * to be null or unknown ("ZZ").
*
* Note if any new field is added to this method that should always be filled in, even when
* keepRawInput is false, it should also be handled in the copyCoreFieldsOnly() method.
*/ */
private void parseHelper(String numberToParse, String defaultRegion, boolean keepRawInput, private void parseHelper(String numberToParse, String defaultRegion, boolean keepRawInput,
boolean checkRegion, PhoneNumber phoneNumber) boolean checkRegion, PhoneNumber phoneNumber)
@ -3105,6 +3108,26 @@ public class PhoneNumberUtil {
// actually written in RFC3966. // actually written in RFC3966.
} }
/**
* Returns a new phone number containing only the fields needed to uniquely identify a phone
* number, rather than any fields that capture the context in which the phone number was created.
* These fields correspond to those set in parse() rather than parseHelper().
*/
private static PhoneNumber copyCoreFieldsOnly(PhoneNumber phoneNumberIn) {
PhoneNumber phoneNumber = new PhoneNumber();
phoneNumber.setCountryCode(phoneNumberIn.getCountryCode());
phoneNumber.setNationalNumber(phoneNumberIn.getNationalNumber());
if (phoneNumberIn.getExtension().length() > 0) {
phoneNumber.setExtension(phoneNumberIn.getExtension());
}
if (phoneNumberIn.isItalianLeadingZero()) {
phoneNumber.setItalianLeadingZero(true);
// This field is only relevant if there are leading zeros at all.
phoneNumber.setNumberOfLeadingZeros(phoneNumberIn.getNumberOfLeadingZeros());
}
return phoneNumber;
}
/** /**
* Takes two phone numbers and compares them for equality. * Takes two phone numbers and compares them for equality.
* *
@ -3126,27 +3149,10 @@ public class PhoneNumberUtil {
* of the two numbers, described in the method definition. * of the two numbers, described in the method definition.
*/ */
public MatchType isNumberMatch(PhoneNumber firstNumberIn, PhoneNumber secondNumberIn) { public MatchType isNumberMatch(PhoneNumber firstNumberIn, PhoneNumber secondNumberIn) {
// Make copies of the phone number so that the numbers passed in are not edited.
PhoneNumber firstNumber = new PhoneNumber();
firstNumber.mergeFrom(firstNumberIn);
PhoneNumber secondNumber = new PhoneNumber();
secondNumber.mergeFrom(secondNumberIn);
// First clear raw_input, country_code_source and preferred_domestic_carrier_code fields and any
// empty-string extensions so that we can use the proto-buffer equality method.
firstNumber.clearRawInput();
firstNumber.clearCountryCodeSource();
firstNumber.clearPreferredDomesticCarrierCode();
secondNumber.clearRawInput();
secondNumber.clearCountryCodeSource();
secondNumber.clearPreferredDomesticCarrierCode();
if (firstNumber.hasExtension()
&& firstNumber.getExtension().length() == 0) {
firstNumber.clearExtension();
}
if (secondNumber.hasExtension()
&& secondNumber.getExtension().length() == 0) {
secondNumber.clearExtension();
}
// We only care about the fields that uniquely define a number, so we copy these across
// explicitly.
PhoneNumber firstNumber = copyCoreFieldsOnly(firstNumberIn);
PhoneNumber secondNumber = copyCoreFieldsOnly(secondNumberIn);
// Early exit if both had extensions and these are different. // Early exit if both had extensions and these are different.
if (firstNumber.hasExtension() && secondNumber.hasExtension() if (firstNumber.hasExtension() && secondNumber.hasExtension()
&& !firstNumber.getExtension().equals(secondNumber.getExtension())) { && !firstNumber.getExtension().equals(secondNumber.getExtension())) {


+ 49
- 0
java/libphonenumber/test/com/google/i18n/phonenumbers/PhoneNumberUtilTest.java View File

@ -2426,6 +2426,55 @@ public class PhoneNumberUtilTest extends TestMetadataTestCase {
PhoneNumberUtil.MatchType.EXACT_MATCH, PhoneNumberUtil.MatchType.EXACT_MATCH,
phoneUtil.isNumberMatch(nzNumber, NZ_NUMBER)); phoneUtil.isNumberMatch(nzNumber, NZ_NUMBER));
}
public void testIsNumberMatchShortMatchIfDiffNumLeadingZeros() throws Exception {
PhoneNumber nzNumberOne = new PhoneNumber();
PhoneNumber nzNumberTwo = new PhoneNumber();
nzNumberOne.setCountryCode(64).setNationalNumber(33316005L).setItalianLeadingZero(true);
nzNumberTwo.setCountryCode(64).setNationalNumber(33316005L).setItalianLeadingZero(true)
.setNumberOfLeadingZeros(2);
assertEquals(PhoneNumberUtil.MatchType.SHORT_NSN_MATCH,
phoneUtil.isNumberMatch(nzNumberOne, nzNumberTwo));
nzNumberOne.setItalianLeadingZero(false).setNumberOfLeadingZeros(1);
nzNumberTwo.setItalianLeadingZero(true).setNumberOfLeadingZeros(1);
// Since one doesn't have the "italian_leading_zero" set to true, we ignore the number of
// leading zeros present (1 is in any case the default value).
assertEquals(PhoneNumberUtil.MatchType.SHORT_NSN_MATCH,
phoneUtil.isNumberMatch(nzNumberOne, nzNumberTwo));
}
public void testIsNumberMatchAcceptsProtoDefaultsAsMatch() throws Exception {
PhoneNumber nzNumberOne = new PhoneNumber();
PhoneNumber nzNumberTwo = new PhoneNumber();
nzNumberOne.setCountryCode(64).setNationalNumber(33316005L).setItalianLeadingZero(true);
// The default for number_of_leading_zeros is 1, so it shouldn't normally be set, however if it
// is it should be considered equivalent.
nzNumberTwo.setCountryCode(64).setNationalNumber(33316005L).setItalianLeadingZero(true)
.setNumberOfLeadingZeros(1);
assertEquals(PhoneNumberUtil.MatchType.EXACT_MATCH,
phoneUtil.isNumberMatch(nzNumberOne, nzNumberTwo));
}
public void testIsNumberMatchMatchesDiffLeadingZerosIfItalianLeadingZeroFalse() throws Exception {
PhoneNumber nzNumberOne = new PhoneNumber();
PhoneNumber nzNumberTwo = new PhoneNumber();
nzNumberOne.setCountryCode(64).setNationalNumber(33316005L);
// The default for number_of_leading_zeros is 1, so it shouldn't normally be set, however if it
// is it should be considered equivalent.
nzNumberTwo.setCountryCode(64).setNationalNumber(33316005L).setNumberOfLeadingZeros(1);
assertEquals(PhoneNumberUtil.MatchType.EXACT_MATCH,
phoneUtil.isNumberMatch(nzNumberOne, nzNumberTwo));
// Even if it is set to ten, it is still equivalent because in both cases
// italian_leading_zero is not true.
nzNumberTwo.setNumberOfLeadingZeros(10);
assertEquals(PhoneNumberUtil.MatchType.EXACT_MATCH,
phoneUtil.isNumberMatch(nzNumberOne, nzNumberTwo));
}
public void testIsNumberMatchIgnoresSomeFields() throws Exception {
// Check raw_input, country_code_source and preferred_domestic_carrier_code are ignored. // Check raw_input, country_code_source and preferred_domestic_carrier_code are ignored.
PhoneNumber brNumberOne = new PhoneNumber(); PhoneNumber brNumberOne = new PhoneNumber();
PhoneNumber brNumberTwo = new PhoneNumber(); PhoneNumber brNumberTwo = new PhoneNumber();


+ 8
- 0
java/pending_code_changes.txt View File

@ -6,3 +6,11 @@ Code changes:
IS_POSSIBLE_LOCAL_ONLY will be returned for some values which currently IS_POSSIBLE_LOCAL_ONLY will be returned for some values which currently
return IS_POSSIBLE, and INVALID_LENGTH will be returned for some values which return IS_POSSIBLE, and INVALID_LENGTH will be returned for some values which
currently return TOO_LONG. currently return TOO_LONG.
- Fix for isNumberMatch to ignore the numberOfLeadingZeros field when comparing
numbers unless hasItalianLeadingZero is true, and to consider default values
to match the same value when explicitly set for these two fields. This fix
shouldn't be needed for anyone correctly creating phone numbers using "parse"
as recommended.
- C++ only: Fix for ExactlySameAs when comparing phone numbers to include
comparison of the number_of_leading_zeros field.
- C++ only: Updating maximum length for NSN to be 17 (matches Java and JS)

+ 57
- 56
javascript/i18n/phonenumbers/demo-compiled.js View File

@ -1,15 +1,16 @@
(function(){for(var aa="function"==typeof Object.defineProperties?Object.defineProperty:function(a,b,c){if(c.get||c.set)throw new TypeError("ES3 does not support getters and setters.");a!=Array.prototype&&a!=Object.prototype&&(a[b]=c.value)},k="undefined"!=typeof window&&window===this?this:"undefined"!=typeof global&&null!=global?global:this,l=["String","prototype","repeat"],ba=0;ba<l.length-1;ba++){var ca=l[ba];ca in k||(k[ca]={});k=k[ca]}
var da=l[l.length-1],ea=k[da],fa=ea?ea:function(a){var b;if(null==this)throw new TypeError("The 'this' value for String.prototype.repeat must not be null or undefined");b=this+"";if(0>a||1342177279<a)throw new RangeError("Invalid count value");a|=0;for(var c="";a;)if(a&1&&(c+=b),a>>>=1)b+=b;return c};fa!=ea&&null!=fa&&aa(k,da,{configurable:!0,writable:!0,value:fa});
function ga(a){var b=typeof a;if("object"==b)if(a){if(a instanceof Array)return"array";if(a instanceof Object)return b;var c=Object.prototype.toString.call(a);if("[object Window]"==c)return"object";if("[object Array]"==c||"number"==typeof a.length&&"undefined"!=typeof a.splice&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("splice"))return"array";if("[object Function]"==c||"undefined"!=typeof a.call&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("call"))return"function"}else return"null";
else if("function"==b&&"undefined"==typeof a.call)return"object";return b}function n(a){return"string"==typeof a}function p(a,b){function c(){}c.prototype=b.prototype;a.ca=b.prototype;a.prototype=new c;a.prototype.constructor=a;a.ma=function(a,c,f){for(var d=Array(arguments.length-2),e=2;e<arguments.length;e++)d[e-2]=arguments[e];return b.prototype[c].apply(a,d)}};function q(a){if(Error.captureStackTrace)Error.captureStackTrace(this,q);else{var b=Error().stack;b&&(this.stack=b)}a&&(this.message=String(a))}p(q,Error);q.prototype.name="CustomError";function ha(a,b){for(var c=a.split("%s"),d="",e=Array.prototype.slice.call(arguments,1);e.length&&1<c.length;)d+=c.shift()+e.shift();return d+c.join("%s")};function ia(a,b){b.unshift(a);q.call(this,ha.apply(null,b));b.shift()}p(ia,q);ia.prototype.name="AssertionError";function ja(a,b){throw new ia("Failure"+(a?": "+a:""),Array.prototype.slice.call(arguments,1));};var ka=Array.prototype.indexOf?function(a,b,c){return Array.prototype.indexOf.call(a,b,c)}:function(a,b,c){c=null==c?0:0>c?Math.max(0,a.length+c):c;if(n(a))return n(b)&&1==b.length?a.indexOf(b,c):-1;for(;c<a.length;c++)if(c in a&&a[c]===b)return c;return-1};function la(a,b){a.sort(b||ma)}function ma(a,b){return a>b?1:a<b?-1:0};function na(a){var b=[],c=0,d;for(d in a)b[c++]=a[d];return b}function oa(a,b){var c;a:{for(c in a)if(b.call(void 0,a[c],c,a))break a;c=void 0}return c&&a[c]};function pa(a){var b=document;return n(a)?b.getElementById(a):a};function qa(a){var b=[];ra(new sa,a,b);return b.join("")}function sa(){}
function ra(a,b,c){if(null==b)c.push("null");else{if("object"==typeof b){if("array"==ga(b)){var d=b;b=d.length;c.push("[");for(var e="",f=0;f<b;f++)c.push(e),e=d[f],ra(a,e,c),e=",";c.push("]");return}if(b instanceof String||b instanceof Number||b instanceof Boolean)b=b.valueOf();else{c.push("{");f="";for(d in b)Object.prototype.hasOwnProperty.call(b,d)&&(e=b[d],"function"!=typeof e&&(c.push(f),ta(d,c),c.push(":"),ra(a,e,c),f=","));c.push("}");return}}switch(typeof b){case "string":ta(b,c);break;case "number":c.push(isFinite(b)&&
!isNaN(b)?String(b):"null");break;case "boolean":c.push(String(b));break;case "function":c.push("null");break;default:throw Error("Unknown type: "+typeof b);}}}var ua={'"':'\\"',"\\":"\\\\","/":"\\/","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t","\x0B":"\\u000b"},va=/\uffff/.test("\uffff")?/[\\\"\x00-\x1f\x7f-\uffff]/g:/[\\\"\x00-\x1f\x7f-\xff]/g;
function ta(a,b){b.push('"',a.replace(va,function(a){var b=ua[a];b||(b="\\u"+(a.charCodeAt(0)|65536).toString(16).substr(1),ua[a]=b);return b}),'"')};function wa(a,b){this.a=a;this.l=b.name;this.f=!!b.u;this.b=b.c;this.j=b.type;this.i=!1;switch(this.b){case xa:case ya:case za:case Aa:case Ba:case Ca:case Da:this.i=!0}this.g=b.defaultValue}var Da=1,Ca=2,xa=3,ya=4,za=6,Aa=16,Ba=18;function Ea(a,b){this.b=a;this.a={};for(var c=0;c<b.length;c++){var d=b[c];this.a[d.a]=d}}function Fa(a){a=na(a.a);la(a,function(a,c){return a.a-c.a});return a}function Ga(a,b){return oa(a.a,function(a){return a.l==b})||null};function r(){this.b={};this.f=this.h().a;this.a=this.g=null}function Ha(a,b){for(var c in a.b){var d=Number(c);a.f[d]||b.call(a,d,a.b[c])}}r.prototype.has=function(a){return t(this,a.a)};r.prototype.get=function(a,b){return u(this,a.a,b)};r.prototype.set=function(a,b){v(this,a.a,b)};
function Ia(a,b){for(var c=Fa(a.h()),d=0;d<c.length;d++){var e=c[d],f=e.a;if(t(b,f)){a.a&&delete a.a[e.a];var g=11==e.b||10==e.b;if(e.f)for(var e=w(b,f),h=0;h<e.length;h++)Ja(a,f,g?e[h].clone():e[h]);else e=Ka(b,f),g?(g=Ka(a,f))?Ia(g,e):v(a,f,e.clone()):v(a,f,e)}}}r.prototype.clone=function(){var a=new this.constructor;a!=this&&(a.b={},a.a&&(a.a={}),Ia(a,this));return a};function t(a,b){return null!=a.b[b]}
function Ka(a,b){var c=a.b[b];if(null==c)return null;if(a.g){if(!(b in a.a)){var d=a.g,e=a.f[b];if(null!=c)if(e.f){for(var f=[],g=0;g<c.length;g++)f[g]=d.a(e,c[g]);c=f}else c=d.a(e,c);return a.a[b]=c}return a.a[b]}return c}function u(a,b,c){var d=Ka(a,b);return a.f[b].f?d[c||0]:d}function x(a,b){var c;if(t(a,b))c=u(a,b,void 0);else a:{c=a.f[b];if(void 0===c.g){var d=c.j;if(d===Boolean)c.g=!1;else if(d===Number)c.g=0;else if(d===String)c.g=c.i?"0":"";else{c=new d;break a}}c=c.g}return c}
function w(a,b){return Ka(a,b)||[]}function y(a,b){return a.f[b].f?t(a,b)?a.b[b].length:0:t(a,b)?1:0}function v(a,b,c){a.b[b]=c;a.a&&(a.a[b]=c)}function Ja(a,b,c){a.b[b]||(a.b[b]=[]);a.b[b].push(c);a.a&&delete a.a[b]}function La(a,b){delete a.b[b];a.a&&delete a.a[b]}function Ma(a,b){var c=[],d;for(d in b)0!=d&&c.push(new wa(d,b[d]));return new Ea(a,c)};function z(){}z.prototype.b=function(a,b){return 11==a.b||10==a.b?this.g(b):"number"!=typeof b||isFinite(b)?b:b.toString()};z.prototype.f=function(a,b){var c=new a.b;this.i(c,b);return c};
z.prototype.a=function(a,b){if(11==a.b||10==a.b)return b instanceof r?b:this.f(a.j.prototype.h(),b);if(14==a.b){if(n(b)&&Na.test(b)){var c=Number(b);if(0<c)return c}return b}if(!a.i)return b;c=a.j;if(c===String){if("number"==typeof b)return String(b)}else if(c===Number&&n(b)&&("Infinity"===b||"-Infinity"===b||"NaN"===b||Na.test(b)))return Number(b);return b};var Na=/^-?[0-9]+$/;function A(a,b){this.j=a;this.l=b}p(A,z);A.prototype.g=function(a){for(var b=Fa(a.h()),c={},d=0;d<b.length;d++){var e=b[d],f=1==this.j?e.l:e.a;if(a.has(e))if(e.f){var g=[];c[f]=g;for(f=0;f<y(a,e.a);f++)g.push(this.b(e,a.get(e,f)))}else c[f]=this.b(e,a.get(e))}Ha(a,function(a,b){c[a]=b});return c};A.prototype.b=function(a,b){return this.l&&8==a.b&&"boolean"==typeof b?b?1:0:A.ca.b.call(this,a,b)};A.prototype.a=function(a,b){return 8==a.b&&"number"==typeof b?!!b:A.ca.a.call(this,a,b)};
A.prototype.i=function(a,b){var c=a.h(),d;for(d in b){var e,f=b[d],g=!/[^0-9]/.test(d);if(e=g?c.a[parseInt(d,10)]||null:Ga(c,d))if(e.f)for(g=0;g<f.length;g++){var h=this.a(e,f[g]);Ja(a,e.a,h)}else a.set(e,this.a(e,f));else g?(e=a,g=Number(d),e.b[g]=f,e.a&&delete e.a[g]):ja("Failed to find field: "+d)}};function B(a,b){null!=a&&this.a.apply(this,arguments)}B.prototype.b="";B.prototype.set=function(a){this.b=""+a};B.prototype.a=function(a,b,c){this.b+=String(a);if(null!=b)for(var d=1;d<arguments.length;d++)this.b+=arguments[d];return this};function C(a){a.b=""}B.prototype.toString=function(){return this.b};/*
(function(){var aa="function"==typeof Object.defineProperties?Object.defineProperty:function(a,b,c){if(c.get||c.set)throw new TypeError("ES3 does not support getters and setters.");a!=Array.prototype&&a!=Object.prototype&&(a[b]=c.value)},ba="undefined"!=typeof window&&window===this?this:"undefined"!=typeof global?global:this;
function ca(a,b){if(b){for(var c=ba,d=a.split("."),e=0;e<d.length-1;e++){var f=d[e];f in c||(c[f]={});c=c[f]}d=d[d.length-1];e=c[d];f=b(e);f!=e&&null!=f&&aa(c,d,{configurable:!0,writable:!0,value:f})}}
ca("String.prototype.repeat",function(a){return a?a:function(a){var b;if(null==this)throw new TypeError("The 'this' value for String.prototype.repeat must not be null or undefined");b=this+"";if(0>a||1342177279<a)throw new RangeError("Invalid count value");a|=0;for(var d="";a;)if(a&1&&(d+=b),a>>>=1)b+=b;return d}});ca("Math.sign",function(a){return a?a:function(a){a=Number(a);return!a||isNaN(a)?a:0<a?1:-1}});
function da(a){var b=typeof a;if("object"==b)if(a){if(a instanceof Array)return"array";if(a instanceof Object)return b;var c=Object.prototype.toString.call(a);if("[object Window]"==c)return"object";if("[object Array]"==c||"number"==typeof a.length&&"undefined"!=typeof a.splice&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("splice"))return"array";if("[object Function]"==c||"undefined"!=typeof a.call&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("call"))return"function"}else return"null";
else if("function"==b&&"undefined"==typeof a.call)return"object";return b}function k(a){return"string"==typeof a}function l(a,b){function c(){}c.prototype=b.prototype;a.ha=b.prototype;a.prototype=new c;a.prototype.constructor=a;a.ma=function(a,c,f){for(var d=Array(arguments.length-2),e=2;e<arguments.length;e++)d[e-2]=arguments[e];return b.prototype[c].apply(a,d)}};function n(a){if(Error.captureStackTrace)Error.captureStackTrace(this,n);else{var b=Error().stack;b&&(this.stack=b)}a&&(this.message=String(a))}l(n,Error);n.prototype.name="CustomError";function ea(a,b){for(var c=a.split("%s"),d="",e=Array.prototype.slice.call(arguments,1);e.length&&1<c.length;)d+=c.shift()+e.shift();return d+c.join("%s")};function fa(a,b){b.unshift(a);n.call(this,ea.apply(null,b));b.shift()}l(fa,n);fa.prototype.name="AssertionError";function ga(a,b){throw new fa("Failure"+(a?": "+a:""),Array.prototype.slice.call(arguments,1));};var p=Array.prototype.indexOf?function(a,b,c){return Array.prototype.indexOf.call(a,b,c)}:function(a,b,c){c=null==c?0:0>c?Math.max(0,a.length+c):c;if(k(a))return k(b)&&1==b.length?a.indexOf(b,c):-1;for(;c<a.length;c++)if(c in a&&a[c]===b)return c;return-1};function ha(a,b){a.sort(b||ia)}function ia(a,b){return a>b?1:a<b?-1:0};function ja(a){var b=[],c=0,d;for(d in a)b[c++]=a[d];return b}function ka(a,b){var c;a:{for(c in a)if(b.call(void 0,a[c],c,a))break a;c=void 0}return c&&a[c]};function q(a){var b=document;return k(a)?b.getElementById(a):a};function la(a){var b=[];ma(new na,a,b);return b.join("")}function na(){}
function ma(a,b,c){if(null==b)c.push("null");else{if("object"==typeof b){if("array"==da(b)){var d=b;b=d.length;c.push("[");for(var e="",f=0;f<b;f++)c.push(e),ma(a,d[f],c),e=",";c.push("]");return}if(b instanceof String||b instanceof Number||b instanceof Boolean)b=b.valueOf();else{c.push("{");e="";for(d in b)Object.prototype.hasOwnProperty.call(b,d)&&(f=b[d],"function"!=typeof f&&(c.push(e),oa(d,c),c.push(":"),ma(a,f,c),e=","));c.push("}");return}}switch(typeof b){case "string":oa(b,c);break;case "number":c.push(isFinite(b)&&
!isNaN(b)?String(b):"null");break;case "boolean":c.push(String(b));break;case "function":c.push("null");break;default:throw Error("Unknown type: "+typeof b);}}}var pa={'"':'\\"',"\\":"\\\\","/":"\\/","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t","\x0B":"\\u000b"},qa=/\uffff/.test("\uffff")?/[\\\"\x00-\x1f\x7f-\uffff]/g:/[\\\"\x00-\x1f\x7f-\xff]/g;
function oa(a,b){b.push('"',a.replace(qa,function(a){var b=pa[a];b||(b="\\u"+(a.charCodeAt(0)|65536).toString(16).substr(1),pa[a]=b);return b}),'"')};function ra(a,b){this.a=a;this.l=b.name;this.f=!!b.u;this.b=b.c;this.j=b.type;this.i=!1;switch(this.b){case sa:case ta:case ua:case va:case wa:case xa:case ya:this.i=!0}this.g=b.defaultValue}var ya=1,xa=2,sa=3,ta=4,ua=6,va=16,wa=18;function za(a,b){this.b=a;this.a={};for(var c=0;c<b.length;c++){var d=b[c];this.a[d.a]=d}}function Aa(a){a=ja(a.a);ha(a,function(a,c){return a.a-c.a});return a}function Ba(a,b){return ka(a.a,function(a){return a.l==b})||null};function r(){this.b={};this.f=this.h().a;this.a=this.g=null}function Ca(a,b){for(var c in a.b){var d=Number(c);a.f[d]||b.call(a,d,a.b[c])}}r.prototype.has=function(a){return t(this,a.a)};r.prototype.get=function(a,b){return u(this,a.a,b)};r.prototype.set=function(a,b){v(this,a.a,b)};
function Da(a,b){for(var c=Aa(a.h()),d=0;d<c.length;d++){var e=c[d],f=e.a;if(t(b,f)){a.a&&delete a.a[e.a];var g=11==e.b||10==e.b;if(e.f)for(var e=w(b,f),h=0;h<e.length;h++)Ea(a,f,g?e[h].clone():e[h]);else e=Fa(b,f),g?(g=Fa(a,f))?Da(g,e):v(a,f,e.clone()):v(a,f,e)}}}r.prototype.clone=function(){var a=new this.constructor;a!=this&&(a.b={},a.a&&(a.a={}),Da(a,this));return a};function t(a,b){return null!=a.b[b]}
function Fa(a,b){var c=a.b[b];if(null==c)return null;if(a.g){if(!(b in a.a)){var d=a.g,e=a.f[b];if(null!=c)if(e.f){for(var f=[],g=0;g<c.length;g++)f[g]=d.a(e,c[g]);c=f}else c=d.a(e,c);return a.a[b]=c}return a.a[b]}return c}function u(a,b,c){var d=Fa(a,b);return a.f[b].f?d[c||0]:d}function x(a,b){var c;if(t(a,b))c=u(a,b,void 0);else a:{c=a.f[b];if(void 0===c.g){var d=c.j;if(d===Boolean)c.g=!1;else if(d===Number)c.g=0;else if(d===String)c.g=c.i?"0":"";else{c=new d;break a}}c=c.g}return c}
function w(a,b){return Fa(a,b)||[]}function y(a,b){return a.f[b].f?t(a,b)?a.b[b].length:0:t(a,b)?1:0}function v(a,b,c){a.b[b]=c;a.a&&(a.a[b]=c)}function Ea(a,b,c){a.b[b]||(a.b[b]=[]);a.b[b].push(c);a.a&&delete a.a[b]}function Ga(a,b){delete a.b[b];a.a&&delete a.a[b]}function Ha(a,b){var c=[],d;for(d in b)0!=d&&c.push(new ra(d,b[d]));return new za(a,c)};function z(){}z.prototype.b=function(a,b){return 11==a.b||10==a.b?this.g(b):"number"!=typeof b||isFinite(b)?b:b.toString()};z.prototype.f=function(a,b){var c=new a.b;this.i(c,b);return c};
z.prototype.a=function(a,b){if(11==a.b||10==a.b)return b instanceof r?b:this.f(a.j.prototype.h(),b);if(14==a.b){if(k(b)&&Ia.test(b)){var c=Number(b);if(0<c)return c}return b}if(!a.i)return b;c=a.j;if(c===String){if("number"==typeof b)return String(b)}else if(c===Number&&k(b)&&("Infinity"===b||"-Infinity"===b||"NaN"===b||Ia.test(b)))return Number(b);return b};var Ia=/^-?[0-9]+$/;function A(a,b){this.j=a;this.l=b}l(A,z);A.prototype.g=function(a){for(var b=Aa(a.h()),c={},d=0;d<b.length;d++){var e=b[d],f=1==this.j?e.l:e.a;if(a.has(e))if(e.f){var g=[];c[f]=g;for(f=0;f<y(a,e.a);f++)g.push(this.b(e,a.get(e,f)))}else c[f]=this.b(e,a.get(e))}Ca(a,function(a,b){c[a]=b});return c};A.prototype.b=function(a,b){return this.l&&8==a.b&&"boolean"==typeof b?b?1:0:A.ha.b.call(this,a,b)};A.prototype.a=function(a,b){return 8==a.b&&"number"==typeof b?!!b:A.ha.a.call(this,a,b)};
A.prototype.i=function(a,b){var c=a.h(),d;for(d in b){var e,f=b[d],g=!/[^0-9]/.test(d);if(e=g?c.a[parseInt(d,10)]||null:Ba(c,d))if(e.f)for(g=0;g<f.length;g++){var h=this.a(e,f[g]);Ea(a,e.a,h)}else a.set(e,this.a(e,f));else g?(e=a,g=Number(d),e.b[g]=f,e.a&&delete e.a[g]):ga("Failed to find field: "+e)}};function B(a,b){null!=a&&this.a.apply(this,arguments)}B.prototype.b="";B.prototype.set=function(a){this.b=""+a};B.prototype.a=function(a,b,c){this.b+=String(a);if(null!=b)for(var d=1;d<arguments.length;d++)this.b+=arguments[d];return this};function C(a){a.b=""}B.prototype.toString=function(){return this.b};/*
Protocol Buffer 2 Copyright 2008 Google Inc. Protocol Buffer 2 Copyright 2008 Google Inc.
All other code copyright its respective owners. All other code copyright its respective owners.
@ -27,14 +28,14 @@ A.prototype.i=function(a,b){var c=a.h(),d;for(d in b){var e,f=b[d],g=!/[^0-9]/.t
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
function E(){r.call(this)}p(E,r);var Oa=null;function F(){r.call(this)}p(F,r);var Pa=null;function G(){r.call(this)}p(G,r);var Qa=null;
E.prototype.h=function(){var a=Oa;a||(Oa=a=Ma(E,{0:{name:"NumberFormat",ba:"i18n.phonenumbers.NumberFormat"},1:{name:"pattern",required:!0,c:9,type:String},2:{name:"format",required:!0,c:9,type:String},3:{name:"leading_digits_pattern",u:!0,c:9,type:String},4:{name:"national_prefix_formatting_rule",c:9,type:String},6:{name:"national_prefix_optional_when_formatting",c:8,type:Boolean},5:{name:"domestic_carrier_code_formatting_rule",c:9,type:String}}));return a};E.h=E.prototype.h;
F.prototype.h=function(){var a=Pa;a||(Pa=a=Ma(F,{0:{name:"PhoneNumberDesc",ba:"i18n.phonenumbers.PhoneNumberDesc"},2:{name:"national_number_pattern",c:9,type:String},3:{name:"possible_number_pattern",c:9,type:String},9:{name:"possible_length",u:!0,c:5,type:Number},10:{name:"possible_length_local_only",u:!0,c:5,type:Number},6:{name:"example_number",c:9,type:String},7:{name:"national_number_matcher_data",c:12,type:String},8:{name:"possible_number_matcher_data",c:12,type:String}}));return a};F.h=F.prototype.h;
G.prototype.h=function(){var a=Qa;a||(Qa=a=Ma(G,{0:{name:"PhoneMetadata",ba:"i18n.phonenumbers.PhoneMetadata"},1:{name:"general_desc",c:11,type:F},2:{name:"fixed_line",c:11,type:F},3:{name:"mobile",c:11,type:F},4:{name:"toll_free",c:11,type:F},5:{name:"premium_rate",c:11,type:F},6:{name:"shared_cost",c:11,type:F},7:{name:"personal_number",c:11,type:F},8:{name:"voip",c:11,type:F},21:{name:"pager",c:11,type:F},25:{name:"uan",c:11,type:F},27:{name:"emergency",c:11,type:F},28:{name:"voicemail",c:11,type:F},
function E(){r.call(this)}l(E,r);var Ja=null;function F(){r.call(this)}l(F,r);var Ka=null;function G(){r.call(this)}l(G,r);var La=null;
E.prototype.h=function(){var a=Ja;a||(Ja=a=Ha(E,{0:{name:"NumberFormat",ba:"i18n.phonenumbers.NumberFormat"},1:{name:"pattern",required:!0,c:9,type:String},2:{name:"format",required:!0,c:9,type:String},3:{name:"leading_digits_pattern",u:!0,c:9,type:String},4:{name:"national_prefix_formatting_rule",c:9,type:String},6:{name:"national_prefix_optional_when_formatting",c:8,type:Boolean},5:{name:"domestic_carrier_code_formatting_rule",c:9,type:String}}));return a};E.h=E.prototype.h;
F.prototype.h=function(){var a=Ka;a||(Ka=a=Ha(F,{0:{name:"PhoneNumberDesc",ba:"i18n.phonenumbers.PhoneNumberDesc"},2:{name:"national_number_pattern",c:9,type:String},3:{name:"possible_number_pattern",c:9,type:String},9:{name:"possible_length",u:!0,c:5,type:Number},10:{name:"possible_length_local_only",u:!0,c:5,type:Number},6:{name:"example_number",c:9,type:String},7:{name:"national_number_matcher_data",c:12,type:String},8:{name:"possible_number_matcher_data",c:12,type:String}}));return a};F.h=F.prototype.h;
G.prototype.h=function(){var a=La;a||(La=a=Ha(G,{0:{name:"PhoneMetadata",ba:"i18n.phonenumbers.PhoneMetadata"},1:{name:"general_desc",c:11,type:F},2:{name:"fixed_line",c:11,type:F},3:{name:"mobile",c:11,type:F},4:{name:"toll_free",c:11,type:F},5:{name:"premium_rate",c:11,type:F},6:{name:"shared_cost",c:11,type:F},7:{name:"personal_number",c:11,type:F},8:{name:"voip",c:11,type:F},21:{name:"pager",c:11,type:F},25:{name:"uan",c:11,type:F},27:{name:"emergency",c:11,type:F},28:{name:"voicemail",c:11,type:F},
24:{name:"no_international_dialling",c:11,type:F},9:{name:"id",required:!0,c:9,type:String},10:{name:"country_code",c:5,type:Number},11:{name:"international_prefix",c:9,type:String},17:{name:"preferred_international_prefix",c:9,type:String},12:{name:"national_prefix",c:9,type:String},13:{name:"preferred_extn_prefix",c:9,type:String},15:{name:"national_prefix_for_parsing",c:9,type:String},16:{name:"national_prefix_transform_rule",c:9,type:String},18:{name:"same_mobile_and_fixed_line_pattern",c:8,defaultValue:!1, 24:{name:"no_international_dialling",c:11,type:F},9:{name:"id",required:!0,c:9,type:String},10:{name:"country_code",c:5,type:Number},11:{name:"international_prefix",c:9,type:String},17:{name:"preferred_international_prefix",c:9,type:String},12:{name:"national_prefix",c:9,type:String},13:{name:"preferred_extn_prefix",c:9,type:String},15:{name:"national_prefix_for_parsing",c:9,type:String},16:{name:"national_prefix_transform_rule",c:9,type:String},18:{name:"same_mobile_and_fixed_line_pattern",c:8,defaultValue:!1,
type:Boolean},19:{name:"number_format",u:!0,c:11,type:E},20:{name:"intl_number_format",u:!0,c:11,type:E},22:{name:"main_country_for_code",c:8,defaultValue:!1,type:Boolean},23:{name:"leading_digits",c:9,type:String},26:{name:"leading_zero_possible",c:8,defaultValue:!1,type:Boolean}}));return a};G.h=G.prototype.h;function H(){r.call(this)}var Ra;p(H,r);var Sa={la:1,ka:5,ja:10,ia:20};
H.prototype.h=function(){Ra||(Ra=Ma(H,{0:{name:"PhoneNumber",ba:"i18n.phonenumbers.PhoneNumber"},1:{name:"country_code",required:!0,c:5,type:Number},2:{name:"national_number",required:!0,c:4,type:Number},3:{name:"extension",c:9,type:String},4:{name:"italian_leading_zero",c:8,type:Boolean},8:{name:"number_of_leading_zeros",c:5,defaultValue:1,type:Number},5:{name:"raw_input",c:9,type:String},6:{name:"country_code_source",c:14,defaultValue:1,type:Sa},7:{name:"preferred_domestic_carrier_code",c:9,type:String}}));
return Ra};H.ctor=H;H.ctor.h=H.prototype.h;function Ta(){}p(Ta,z);Ta.prototype.f=function(a,b){var c=new a.b;c.g=this;c.b=b;c.a={};return c};Ta.prototype.i=function(){throw Error("Unimplemented");};function I(){}p(I,Ta);I.prototype.g=function(a){for(var b=Fa(a.h()),c=[],d=0;d<b.length;d++){var e=b[d];if(a.has(e)){var f=e.a;if(e.f){c[f]=[];for(var g=0;g<y(a,e.a);g++)c[f][g]=this.b(e,a.get(e,g))}else c[f]=this.b(e,a.get(e))}}Ha(a,function(a,b){c[a]=b});return c};I.prototype.b=function(a,b){return 8==a.b?b?1:0:z.prototype.b.apply(this,arguments)};I.prototype.a=function(a,b){return 8==a.b?!!b:z.prototype.a.apply(this,arguments)};I.prototype.f=function(a,b){return I.ca.f.call(this,a,b)};/*
type:Boolean},19:{name:"number_format",u:!0,c:11,type:E},20:{name:"intl_number_format",u:!0,c:11,type:E},22:{name:"main_country_for_code",c:8,defaultValue:!1,type:Boolean},23:{name:"leading_digits",c:9,type:String},26:{name:"leading_zero_possible",c:8,defaultValue:!1,type:Boolean}}));return a};G.h=G.prototype.h;function H(){r.call(this)}var Ma;l(H,r);var Na={la:1,ka:5,ja:10,ia:20};
H.prototype.h=function(){Ma||(Ma=Ha(H,{0:{name:"PhoneNumber",ba:"i18n.phonenumbers.PhoneNumber"},1:{name:"country_code",required:!0,c:5,type:Number},2:{name:"national_number",required:!0,c:4,type:Number},3:{name:"extension",c:9,type:String},4:{name:"italian_leading_zero",c:8,type:Boolean},8:{name:"number_of_leading_zeros",c:5,defaultValue:1,type:Number},5:{name:"raw_input",c:9,type:String},6:{name:"country_code_source",c:14,defaultValue:1,type:Na},7:{name:"preferred_domestic_carrier_code",c:9,type:String}}));
return Ma};H.ctor=H;H.ctor.h=H.prototype.h;function Oa(){}l(Oa,z);Oa.prototype.f=function(a,b){var c=new a.b;c.g=this;c.b=b;c.a={};return c};Oa.prototype.i=function(){throw Error("Unimplemented");};function I(){}l(I,Oa);I.prototype.g=function(a){for(var b=Aa(a.h()),c=[],d=0;d<b.length;d++){var e=b[d];if(a.has(e)){var f=e.a;if(e.f){c[f]=[];for(var g=0;g<y(a,e.a);g++)c[f][g]=this.b(e,a.get(e,g))}else c[f]=this.b(e,a.get(e))}}Ca(a,function(a,b){c[a]=b});return c};I.prototype.b=function(a,b){return 8==a.b?b?1:0:z.prototype.b.apply(this,arguments)};I.prototype.a=function(a,b){return 8==a.b?!!b:z.prototype.a.apply(this,arguments)};/*
Copyright (C) 2010 The Libphonenumber Authors Copyright (C) 2010 The Libphonenumber Authors
@ -54,7 +55,7 @@ var J={1:"US AG AI AS BB BM BS CA DM DO GD GU JM KN KY LC MP MS PR SX TC TT VC V
86:["CN"],90:["TR"],91:["IN"],92:["PK"],93:["AF"],94:["LK"],95:["MM"],98:["IR"],211:["SS"],212:["MA","EH"],213:["DZ"],216:["TN"],218:["LY"],220:["GM"],221:["SN"],222:["MR"],223:["ML"],224:["GN"],225:["CI"],226:["BF"],227:["NE"],228:["TG"],229:["BJ"],230:["MU"],231:["LR"],232:["SL"],233:["GH"],234:["NG"],235:["TD"],236:["CF"],237:["CM"],238:["CV"],239:["ST"],240:["GQ"],241:["GA"],242:["CG"],243:["CD"],244:["AO"],245:["GW"],246:["IO"],247:["AC"],248:["SC"],249:["SD"],250:["RW"],251:["ET"],252:["SO"], 86:["CN"],90:["TR"],91:["IN"],92:["PK"],93:["AF"],94:["LK"],95:["MM"],98:["IR"],211:["SS"],212:["MA","EH"],213:["DZ"],216:["TN"],218:["LY"],220:["GM"],221:["SN"],222:["MR"],223:["ML"],224:["GN"],225:["CI"],226:["BF"],227:["NE"],228:["TG"],229:["BJ"],230:["MU"],231:["LR"],232:["SL"],233:["GH"],234:["NG"],235:["TD"],236:["CF"],237:["CM"],238:["CV"],239:["ST"],240:["GQ"],241:["GA"],242:["CG"],243:["CD"],244:["AO"],245:["GW"],246:["IO"],247:["AC"],248:["SC"],249:["SD"],250:["RW"],251:["ET"],252:["SO"],
253:["DJ"],254:["KE"],255:["TZ"],256:["UG"],257:["BI"],258:["MZ"],260:["ZM"],261:["MG"],262:["RE","YT"],263:["ZW"],264:["NA"],265:["MW"],266:["LS"],267:["BW"],268:["SZ"],269:["KM"],290:["SH","TA"],291:["ER"],297:["AW"],298:["FO"],299:["GL"],350:["GI"],351:["PT"],352:["LU"],353:["IE"],354:["IS"],355:["AL"],356:["MT"],357:["CY"],358:["FI","AX"],359:["BG"],370:["LT"],371:["LV"],372:["EE"],373:["MD"],374:["AM"],375:["BY"],376:["AD"],377:["MC"],378:["SM"],380:["UA"],381:["RS"],382:["ME"],385:["HR"],386:["SI"], 253:["DJ"],254:["KE"],255:["TZ"],256:["UG"],257:["BI"],258:["MZ"],260:["ZM"],261:["MG"],262:["RE","YT"],263:["ZW"],264:["NA"],265:["MW"],266:["LS"],267:["BW"],268:["SZ"],269:["KM"],290:["SH","TA"],291:["ER"],297:["AW"],298:["FO"],299:["GL"],350:["GI"],351:["PT"],352:["LU"],353:["IE"],354:["IS"],355:["AL"],356:["MT"],357:["CY"],358:["FI","AX"],359:["BG"],370:["LT"],371:["LV"],372:["EE"],373:["MD"],374:["AM"],375:["BY"],376:["AD"],377:["MC"],378:["SM"],380:["UA"],381:["RS"],382:["ME"],385:["HR"],386:["SI"],
387:["BA"],389:["MK"],420:["CZ"],421:["SK"],423:["LI"],500:["FK"],501:["BZ"],502:["GT"],503:["SV"],504:["HN"],505:["NI"],506:["CR"],507:["PA"],508:["PM"],509:["HT"],590:["GP","BL","MF"],591:["BO"],592:["GY"],593:["EC"],594:["GF"],595:["PY"],596:["MQ"],597:["SR"],598:["UY"],599:["CW","BQ"],670:["TL"],672:["NF"],673:["BN"],674:["NR"],675:["PG"],676:["TO"],677:["SB"],678:["VU"],679:["FJ"],680:["PW"],681:["WF"],682:["CK"],683:["NU"],685:["WS"],686:["KI"],687:["NC"],688:["TV"],689:["PF"],690:["TK"],691:["FM"], 387:["BA"],389:["MK"],420:["CZ"],421:["SK"],423:["LI"],500:["FK"],501:["BZ"],502:["GT"],503:["SV"],504:["HN"],505:["NI"],506:["CR"],507:["PA"],508:["PM"],509:["HT"],590:["GP","BL","MF"],591:["BO"],592:["GY"],593:["EC"],594:["GF"],595:["PY"],596:["MQ"],597:["SR"],598:["UY"],599:["CW","BQ"],670:["TL"],672:["NF"],673:["BN"],674:["NR"],675:["PG"],676:["TO"],677:["SB"],678:["VU"],679:["FJ"],680:["PW"],681:["WF"],682:["CK"],683:["NU"],685:["WS"],686:["KI"],687:["NC"],688:["TV"],689:["PF"],690:["TK"],691:["FM"],
692:["MH"],800:["001"],808:["001"],850:["KP"],852:["HK"],853:["MO"],855:["KH"],856:["LA"],870:["001"],878:["001"],880:["BD"],881:["001"],882:["001"],883:["001"],886:["TW"],888:["001"],960:["MV"],961:["LB"],962:["JO"],963:["SY"],964:["IQ"],965:["KW"],966:["SA"],967:["YE"],968:["OM"],970:["PS"],971:["AE"],972:["IL"],973:["BH"],974:["QA"],975:["BT"],976:["MN"],977:["NP"],979:["001"],992:["TJ"],993:["TM"],994:["AZ"],995:["GE"],996:["KG"],998:["UZ"]},Ua={AC:[,[,,"[46]\\d{4}|[01589]\\d{5}",,,,,,,[5,6]],
692:["MH"],800:["001"],808:["001"],850:["KP"],852:["HK"],853:["MO"],855:["KH"],856:["LA"],870:["001"],878:["001"],880:["BD"],881:["001"],882:["001"],883:["001"],886:["TW"],888:["001"],960:["MV"],961:["LB"],962:["JO"],963:["SY"],964:["IQ"],965:["KW"],966:["SA"],967:["YE"],968:["OM"],970:["PS"],971:["AE"],972:["IL"],973:["BH"],974:["QA"],975:["BT"],976:["MN"],977:["NP"],979:["001"],992:["TJ"],993:["TM"],994:["AZ"],995:["GE"],996:["KG"],998:["UZ"]},Pa={AC:[,[,,"[46]\\d{4}|[01589]\\d{5}",,,,,,,[5,6]],
[,,"6[2-467]\\d{3}",,,,"62889",,,[5]],[,,"4\\d{4}",,,,"40123",,,[5]],[,,"NA",,,,,,,[-1]],[,,"NA",,,,,,,[-1]],[,,"NA",,,,,,,[-1]],[,,"NA",,,,,,,[-1]],[,,"NA",,,,,,,[-1]],"AC",247,"00",,,,,,,,,,[,,"NA",,,,,,,[-1]],,,[,,"NA",,,,,,,[-1]],[,,"[01589]\\d{5}",,,,"542011",,,[6]],,,[,,"NA",,,,,,,[-1]]],AD:[,[,,"[16]\\d{5,8}|[37-9]\\d{5}",,,,,,,[6,8,9]],[,,"[78]\\d{5}",,,,"712345",,,[6]],[,,"(?:3\\d|6(?:[0-8]|90\\d{2}))\\d{4}",,,,"312345",,,[6,9]],[,,"180[02]\\d{4}",,,,"18001234",,,[8]],[,,"[19]\\d{5}",,,, [,,"6[2-467]\\d{3}",,,,"62889",,,[5]],[,,"4\\d{4}",,,,"40123",,,[5]],[,,"NA",,,,,,,[-1]],[,,"NA",,,,,,,[-1]],[,,"NA",,,,,,,[-1]],[,,"NA",,,,,,,[-1]],[,,"NA",,,,,,,[-1]],"AC",247,"00",,,,,,,,,,[,,"NA",,,,,,,[-1]],,,[,,"NA",,,,,,,[-1]],[,,"[01589]\\d{5}",,,,"542011",,,[6]],,,[,,"NA",,,,,,,[-1]]],AD:[,[,,"[16]\\d{5,8}|[37-9]\\d{5}",,,,,,,[6,8,9]],[,,"[78]\\d{5}",,,,"712345",,,[6]],[,,"(?:3\\d|6(?:[0-8]|90\\d{2}))\\d{4}",,,,"312345",,,[6,9]],[,,"180[02]\\d{4}",,,,"18001234",,,[8]],[,,"[19]\\d{5}",,,,
"912345",,,[6]],[,,"NA",,,,,,,[-1]],[,,"NA",,,,,,,[-1]],[,,"NA",,,,,,,[-1]],"AD",376,"00",,,,,,,,[[,"(\\d{3})(\\d{3})","$1 $2",["[137-9]|6[0-8]"]],[,"(\\d{4})(\\d{4})","$1 $2",["180","180[02]"]],[,"(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["690"]]],,[,,"NA",,,,,,,[-1]],,,[,,"1800\\d{4}",,,,"18000000",,,[8]],[,,"NA",,,,,,,[-1]],,,[,,"NA",,,,,,,[-1]]],AE:[,[,,"[2-79]\\d{7,8}|800\\d{2,9}",,,,,,,[5,6,7,8,9,10,11,12]],[,,"[2-4679][2-8]\\d{6}",,,,"22345678",,,[8]],[,,"5[024-68]\\d{7}",,,,"501234567",,,[9]], "912345",,,[6]],[,,"NA",,,,,,,[-1]],[,,"NA",,,,,,,[-1]],[,,"NA",,,,,,,[-1]],"AD",376,"00",,,,,,,,[[,"(\\d{3})(\\d{3})","$1 $2",["[137-9]|6[0-8]"]],[,"(\\d{4})(\\d{4})","$1 $2",["180","180[02]"]],[,"(\\d{3})(\\d{3})(\\d{3})","$1 $2 $3",["690"]]],,[,,"NA",,,,,,,[-1]],,,[,,"1800\\d{4}",,,,"18000000",,,[8]],[,,"NA",,,,,,,[-1]],,,[,,"NA",,,,,,,[-1]]],AE:[,[,,"[2-79]\\d{7,8}|800\\d{2,9}",,,,,,,[5,6,7,8,9,10,11,12]],[,,"[2-4679][2-8]\\d{6}",,,,"22345678",,,[8]],[,,"5[024-68]\\d{7}",,,,"501234567",,,[9]],
[,,"400\\d{6}|800\\d{2,9}",,,,"800123456"],[,,"900[02]\\d{5}",,,,"900234567",,,[9]],[,,"700[05]\\d{5}",,,,"700012345",,,[9]],[,,"NA",,,,,,,[-1]],[,,"NA",,,,,,,[-1]],"AE",971,"00","0",,,"0",,,,[[,"([2-4679])(\\d{3})(\\d{4})","$1 $2 $3",["[2-4679][2-8]"],"0$1"],[,"(5\\d)(\\d{3})(\\d{4})","$1 $2 $3",["5"],"0$1"],[,"([479]00)(\\d)(\\d{5})","$1 $2 $3",["[479]0"],"$1"],[,"([68]00)(\\d{2,9})","$1 $2",["60|8"],"$1"]],,[,,"NA",,,,,,,[-1]],,,[,,"NA",,,,,,,[-1]],[,,"600[25]\\d{5}",,,,"600212345",,,[9]],,,[, [,,"400\\d{6}|800\\d{2,9}",,,,"800123456"],[,,"900[02]\\d{5}",,,,"900234567",,,[9]],[,,"700[05]\\d{5}",,,,"700012345",,,[9]],[,,"NA",,,,,,,[-1]],[,,"NA",,,,,,,[-1]],"AE",971,"00","0",,,"0",,,,[[,"([2-4679])(\\d{3})(\\d{4})","$1 $2 $3",["[2-4679][2-8]"],"0$1"],[,"(5\\d)(\\d{3})(\\d{4})","$1 $2 $3",["5"],"0$1"],[,"([479]00)(\\d)(\\d{5})","$1 $2 $3",["[479]0"],"$1"],[,"([68]00)(\\d{2,9})","$1 $2",["60|8"],"$1"]],,[,,"NA",,,,,,,[-1]],,,[,,"NA",,,,,,,[-1]],[,,"600[25]\\d{5}",,,,"600212345",,,[9]],,,[,
@ -432,39 +433,39 @@ SL:[,[,,"[2-9]\\d{7}",,,,,,,[8],[6]],[,,"[235]2[2-4][2-9]\\d{4}",,,,"22221234"],
limitations under the License. limitations under the License.
*/ */
function K(){this.a={}}K.a=function(){return K.b?K.b:K.b=new K}; function K(){this.a={}}K.a=function(){return K.b?K.b:K.b=new K};
var L={0:"0",1:"1",2:"2",3:"3",4:"4",5:"5",6:"6",7:"7",8:"8",9:"9","\uff10":"0","\uff11":"1","\uff12":"2","\uff13":"3","\uff14":"4","\uff15":"5","\uff16":"6","\uff17":"7","\uff18":"8","\uff19":"9","\u0660":"0","\u0661":"1","\u0662":"2","\u0663":"3","\u0664":"4","\u0665":"5","\u0666":"6","\u0667":"7","\u0668":"8","\u0669":"9","\u06f0":"0","\u06f1":"1","\u06f2":"2","\u06f3":"3","\u06f4":"4","\u06f5":"5","\u06f6":"6","\u06f7":"7","\u06f8":"8","\u06f9":"9"},Va={0:"0",1:"1",2:"2",3:"3",4:"4",5:"5",6:"6",
7:"7",8:"8",9:"9","+":"+","*":"*","#":"#"},Wa={0:"0",1:"1",2:"2",3:"3",4:"4",5:"5",6:"6",7:"7",8:"8",9:"9","\uff10":"0","\uff11":"1","\uff12":"2","\uff13":"3","\uff14":"4","\uff15":"5","\uff16":"6","\uff17":"7","\uff18":"8","\uff19":"9","\u0660":"0","\u0661":"1","\u0662":"2","\u0663":"3","\u0664":"4","\u0665":"5","\u0666":"6","\u0667":"7","\u0668":"8","\u0669":"9","\u06f0":"0","\u06f1":"1","\u06f2":"2","\u06f3":"3","\u06f4":"4","\u06f5":"5","\u06f6":"6","\u06f7":"7","\u06f8":"8","\u06f9":"9",A:"2",
B:"2",C:"2",D:"3",E:"3",F:"3",G:"4",H:"4",I:"4",J:"5",K:"5",L:"5",M:"6",N:"6",O:"6",P:"7",Q:"7",R:"7",S:"7",T:"8",U:"8",V:"8",W:"9",X:"9",Y:"9",Z:"9"},Xa=/[\d]+(?:[~\u2053\u223C\uFF5E][\d]+)?/,Ya=RegExp("[+\uff0b]+"),M=RegExp("^[+\uff0b]+"),Za=RegExp("([0-9\uff10-\uff19\u0660-\u0669\u06f0-\u06f9])"),$a=RegExp("[+\uff0b0-9\uff10-\uff19\u0660-\u0669\u06f0-\u06f9]"),ab=/[\\\/] *x/,bb=RegExp("[^0-9\uff10-\uff19\u0660-\u0669\u06f0-\u06f9A-Za-z#]+$"),cb=/(?:.*?[A-Za-z]){3}.*/,db=RegExp("(?:;ext=([0-9\uff10-\uff19\u0660-\u0669\u06f0-\u06f9]{1,7})|[ \u00a0\\t,]*(?:e?xt(?:ensi(?:o\u0301?|\u00f3))?n?|\uff45?\uff58\uff54\uff4e?|[;,x\uff58#\uff03~\uff5e]|int|anexo|\uff49\uff4e\uff54)[:\\.\uff0e]?[ \u00a0\\t,-]*([0-9\uff10-\uff19\u0660-\u0669\u06f0-\u06f9]{1,7})#?|[- ]+([0-9\uff10-\uff19\u0660-\u0669\u06f0-\u06f9]{1,5})#)$",
"i"),eb=RegExp("^[0-9\uff10-\uff19\u0660-\u0669\u06f0-\u06f9]{2}$|^[+\uff0b]*(?:[-x\u2010-\u2015\u2212\u30fc\uff0d-\uff0f \u00a0\u00ad\u200b\u2060\u3000()\uff08\uff09\uff3b\uff3d.\\[\\]/~\u2053\u223c\uff5e*]*[0-9\uff10-\uff19\u0660-\u0669\u06f0-\u06f9]){3,}[-x\u2010-\u2015\u2212\u30fc\uff0d-\uff0f \u00a0\u00ad\u200b\u2060\u3000()\uff08\uff09\uff3b\uff3d.\\[\\]/~\u2053\u223c\uff5e*A-Za-z0-9\uff10-\uff19\u0660-\u0669\u06f0-\u06f9]*(?:;ext=([0-9\uff10-\uff19\u0660-\u0669\u06f0-\u06f9]{1,7})|[ \u00a0\\t,]*(?:e?xt(?:ensi(?:o\u0301?|\u00f3))?n?|\uff45?\uff58\uff54\uff4e?|[;,x\uff58#\uff03~\uff5e]|int|anexo|\uff49\uff4e\uff54)[:\\.\uff0e]?[ \u00a0\\t,-]*([0-9\uff10-\uff19\u0660-\u0669\u06f0-\u06f9]{1,7})#?|[- ]+([0-9\uff10-\uff19\u0660-\u0669\u06f0-\u06f9]{1,5})#)?$",
"i"),fb=/(\$\d)/,gb=/\$NP/,hb=/\$FG/,ib=/\$CC/,jb=/^\(?\$1\)?$/;function kb(a){var b=a.search($a);0<=b?(a=a.substring(b),a=a.replace(bb,""),b=a.search(ab),0<=b&&(a=a.substring(0,b))):a="";return a}function lb(a){return 2>a.length?!1:N(eb,a)}function nb(a){return N(cb,a)?O(a,Wa):O(a,L)}function ob(a){var b=nb(a.toString());C(a);a.a(b)}function O(a,b){for(var c=new B,d,e=a.length,f=0;f<e;++f)d=a.charAt(f),d=b[d.toUpperCase()],null!=d&&c.a(d);return c.toString()}
function pb(a){return null!=a&&isNaN(a)&&a.toUpperCase()in Ua}function P(a,b,c){if(0==u(b,2)&&t(b,5)){var d=x(b,5);if(0<d.length)return d}var d=x(b,1),e=Q(b);if(0==c)return S(d,0,e,"");if(!(d in J))return e;a=T(a,d,U(d));b=qb(b,a,c);e=rb(e,a,c);return S(d,c,e,b)}function sb(a,b,c){var d=x(b,1),e=Q(b);if(!(d in J))return e;a=T(a,d,U(d));b=qb(b,a,2);c=rb(e,a,2,c);return S(d,2,c,b)}function T(a,b,c){return"001"==c?V(a,""+b):V(a,c)}
function tb(a,b,c){if(!pb(c))return P(a,b,1);var d=x(b,1),e=Q(b);if(!(d in J))return e;if(1==d){if(null!=c&&0<=ka(J[1],c.toUpperCase()))return d+" "+P(a,b,2)}else if(d==ub(a,c))return P(a,b,2);var f=V(a,c),g=x(f,11);c="";N(Xa,g)?c=g:t(f,17)&&(c=x(f,17));a=T(a,d,U(d));e=rb(e,a,1);b=qb(b,a,1);return 0<c.length?c+" "+d+" "+e+b:S(d,1,e,b)}
function vb(a,b,c){var d;if(d=t(b,5)){if(d=t(b,4))d=x(b,1),d=T(a,d,U(d)),d=!(d&&x(d,26));if(!d){d=x(b,1);if(d=T(a,d,U(d))){var e=Q(b);d=!!wb(w(d,19),e)}else d=!1;d=!d}}if(d)return x(b,5);if(!t(b,6))return P(a,b,2);switch(u(b,6)){case 1:a=P(a,b,1);break;case 5:a=tb(a,b,c);break;case 10:a=P(a,b,1).substring(1);break;default:d=U(x(b,1));var f;(c=V(a,d))?(c=x(c,12),f=c.length?c=c.replace("~",""):null):f=null;c=P(a,b,2);if(null!=f&&f.length){var g;a:{e=x(b,5);e=O(e,L);if(!e.lastIndexOf(f,0))try{g=xb(a,
yb(a,e.substring(f.length),d,!1));break a}catch(h){}g=!1}if(g)a=c;else if(g=V(a,d),d=Q(b),g=wb(w(g,19),d))if(d=x(g,4),e=d.indexOf("$1"),0>=e)a=c;else if(d=d.substring(0,e),d=O(d,L),d.length)if(g=g.clone(),La(g,4),d=[g],g=x(b,1),c=Q(b),g in J){a=T(a,g,U(g));if(e=wb(d,c))d=e.clone(),e=x(e,4),0<e.length&&(f=x(a,12),0<f.length?(e=e.replace(gb,f).replace(hb,"$1"),v(d,4,e)):La(d,4)),c=zb(c,d,2);a=qb(b,a,2);a=S(g,2,c,a)}else a=c;else a=c;else a=c}else a=c}b=x(b,5);null!=a&&0<b.length&&(g=O(a,Va),c=O(b,Va),
g!=c&&(a=b));return a}function Q(a){var b=""+u(a,2);return t(a,4)&&u(a,4)?Array(x(a,8)+1).join("0")+b:b}function S(a,b,c,d){switch(b){case 0:return"+"+a+c+d;case 1:return"+"+a+" "+c+d;case 3:return"tel:+"+a+"-"+c+d;default:return c+d}}function rb(a,b,c,d){b=w(b,20).length&&2!=c?w(b,20):w(b,19);return(b=wb(b,a))?zb(a,b,c,d):a}function wb(a,b){for(var c,d=a.length,e=0;e<d;++e){c=a[e];var f=y(c,3);if(!f||!b.search(u(c,3,f-1)))if(f=new RegExp(u(c,1)),N(f,b))return c}return null}
function zb(a,b,c,d){var e=x(b,2),f=new RegExp(u(b,1)),g=x(b,5);2==c&&null!=d&&0<d.length&&0<g.length?(b=g.replace(ib,d),e=e.replace(fb,b),a=a.replace(f,e)):(b=x(b,4),a=2==c&&null!=b&&0<b.length?a.replace(f,e.replace(fb,b)):a.replace(f,e));3==c&&(a=a.replace(RegExp("^[-x\u2010-\u2015\u2212\u30fc\uff0d-\uff0f \u00a0\u00ad\u200b\u2060\u3000()\uff08\uff09\uff3b\uff3d.\\[\\]/~\u2053\u223c\uff5e]+"),""),a=a.replace(RegExp("[-x\u2010-\u2015\u2212\u30fc\uff0d-\uff0f \u00a0\u00ad\u200b\u2060\u3000()\uff08\uff09\uff3b\uff3d.\\[\\]/~\u2053\u223c\uff5e]+",
"g"),"-"));return a}function qb(a,b,c){return t(a,3)&&u(a,3).length?3==c?";ext="+u(a,3):t(b,13)?u(b,13)+x(a,3):" ext. "+x(a,3):""}function Ab(a,b){return W(a,u(b,1))?W(a,u(b,5))?4:W(a,u(b,4))?3:W(a,u(b,6))?5:W(a,u(b,8))?6:W(a,u(b,7))?7:W(a,u(b,21))?8:W(a,u(b,25))?9:W(a,u(b,28))?10:W(a,u(b,2))?u(b,18)||W(a,u(b,3))?2:0:!u(b,18)&&W(a,u(b,3))?1:-1:-1}function V(a,b){if(null==b)return null;b=b.toUpperCase();var c=a.a[b];if(!c){c=Ua[b];if(!c)return null;c=(new I).f(G.h(),c);a.a[b]=c}return c}
function W(a,b){var c=a.length;return 0<y(b,9)&&-1==ka(w(b,9),c)?!1:N(x(b,2),a)}function xb(a,b){var c=Bb(a,b);return Cb(a,b,c)}function Cb(a,b,c){var d=x(b,1),e=T(a,d,c);if(!e||"001"!=c&&d!=ub(a,c))return!1;a=Q(b);return-1!=Ab(a,e)}function Bb(a,b){if(!b)return null;var c=x(b,1);if(c=J[c])if(1==c.length)c=c[0];else a:{for(var d=Q(b),e,f=c.length,g=0;g<f;g++){e=c[g];var h=V(a,e);if(t(h,23)){if(!d.search(u(h,23))){c=e;break a}}else if(-1!=Ab(d,h)){c=e;break a}}c=null}else c=null;return c}
function U(a){return(a=J[a])?a[0]:"ZZ"}function ub(a,b){var c=V(a,b);if(!c)throw Error("Invalid region code: "+b);return x(c,10)}function Db(a,b){var c=w(b,9),d=w(b,10),e=a.length;if(-1<ka(d,e))return 0;d=c[0];return d==e?0:d>e?2:c[c.length-1]<e?3:-1<ka(c,e,1)?0:3}function Eb(a,b){var c=Q(b),d=x(b,1);if(!(d in J))return 1;d=T(a,d,U(d));return Db(c,u(d,1))}
function Fb(a,b){var c=a.toString();if(!c.length||"0"==c.charAt(0))return 0;for(var d,e=c.length,f=1;3>=f&&f<=e;++f)if(d=parseInt(c.substring(0,f),10),d in J)return b.a(c.substring(f)),d;return 0}
function Gb(a,b,c,d,e){if(!a.length)return 0;a=new B(a);var f;b&&(f=u(b,11));null==f&&(f="NonMatch");var g=a.toString();if(g.length)if(M.test(g))g=g.replace(M,""),C(a),a.a(nb(g)),f=1;else{g=new RegExp(f);ob(a);f=a.toString();if(f.search(g))f=!1;else{var g=f.match(g)[0].length,h=f.substring(g).match(Za);h&&null!=h[1]&&0<h[1].length&&"0"==O(h[1],L)?f=!1:(C(a),a.a(f.substring(g)),f=!0)}f=f?5:20}else f=20;d&&v(e,6,f);if(20!=f){if(2>=a.b.length)throw Error("Phone number too short after IDD");if(c=Fb(a,
c))return v(e,1,c),c;throw Error("Invalid country calling code");}if(b&&(f=x(b,10),g=""+f,h=a.toString(),!h.lastIndexOf(g,0))){var m=new B(h.substring(g.length)),g=u(b,1),h=new RegExp(x(g,2));Hb(m,b,null);b=m.toString();if(!N(h,a.toString())&&N(h,b)||3==Db(a.toString(),g))return c.a(b),d&&v(e,6,10),v(e,1,f),f}v(e,1,0);return 0}
function Hb(a,b,c){var d=a.toString(),e=d.length,f=u(b,15);if(e&&null!=f&&f.length){var g=new RegExp("^(?:"+f+")");if(e=g.exec(d)){var f=new RegExp(x(u(b,1),2)),h=N(f,d),m=e.length-1;b=u(b,16);if(null!=b&&b.length&&null!=e[m]&&e[m].length){if(d=d.replace(g,b),!h||N(f,d))c&&0<m&&c.a(e[1]),a.set(d)}else if(!h||N(f,d.substring(e[0].length)))c&&0<m&&null!=e[m]&&c.a(e[1]),a.set(d.substring(e[0].length))}}}
function yb(a,b,c,d){if(null==b)throw Error("The string supplied did not seem to be a phone number");if(250<b.length)throw Error("The string supplied is too long to be a phone number");var e=new B,f=b.indexOf(";phone-context=");if(0<f){var g=f+15;if("+"==b.charAt(g)){var h=b.indexOf(";",g);0<h?e.a(b.substring(g,h)):e.a(b.substring(g))}g=b.indexOf("tel:");e.a(b.substring(0<=g?g+4:0,f))}else e.a(kb(b));f=e.toString();g=f.indexOf(";isub=");0<g&&(C(e),e.a(f.substring(0,g)));if(!lb(e.toString()))throw Error("The string supplied did not seem to be a phone number");
f=e.toString();if(!(pb(c)||null!=f&&0<f.length&&M.test(f)))throw Error("Invalid country calling code");f=new H;d&&v(f,5,b);a:{b=e.toString();g=b.search(db);if(0<=g&&lb(b.substring(0,g)))for(var h=b.match(db),m=h.length,D=1;D<m;++D)if(null!=h[D]&&0<h[D].length){C(e);e.a(b.substring(0,g));b=h[D];break a}b=""}0<b.length&&v(f,3,b);b=V(a,c);g=new B;h=0;m=e.toString();try{h=Gb(m,b,g,d,f)}catch(R){if("Invalid country calling code"==R.message&&M.test(m)){if(m=m.replace(M,""),h=Gb(m,b,g,d,f),!h)throw R;}else throw R;
}h?(e=U(h),e!=c&&(b=T(a,h,e))):(ob(e),g.a(e.toString()),null!=c?(h=x(b,10),v(f,1,h)):d&&La(f,6));if(2>g.b.length)throw Error("The string supplied is too short to be a phone number");b&&(a=new B,c=new B(g.toString()),Hb(c,b,a),2!=Db(c.toString(),u(b,1))&&(g=c,d&&0<a.toString().length&&v(f,7,a.toString())));d=g.toString();a=d.length;if(2>a)throw Error("The string supplied is too short to be a phone number");if(17<a)throw Error("The string supplied is too long to be a phone number");if(1<d.length&&"0"==
d.charAt(0)){v(f,4,!0);for(a=1;a<d.length-1&&"0"==d.charAt(a);)a++;1!=a&&v(f,8,a)}v(f,2,parseInt(d,10));return f}function N(a,b){var c="string"==typeof a?b.match("^(?:"+a+")$"):b.match(a);return c&&c[0].length==b.length?!0:!1};function Ib(a){this.da=RegExp("\u2008");this.fa="";this.m=new B;this.w="";this.i=new B;this.v=new B;this.j=!0;this.$=this.o=this.ha=!1;this.ea=K.a();this.s=0;this.b=new B;this.aa=!1;this.l="";this.a=new B;this.f=[];this.ga=a;this.g=Jb(this,this.ga)}var Kb=new G;v(Kb,11,"NA");
var Lb=/\[([^\[\]])*\]/g,Mb=/\d(?=[^,}][^,}])/g,Nb=RegExp("^[-x\u2010-\u2015\u2212\u30fc\uff0d-\uff0f \u00a0\u00ad\u200b\u2060\u3000()\uff08\uff09\uff3b\uff3d.\\[\\]/~\u2053\u223c\uff5e]*(\\$\\d[-x\u2010-\u2015\u2212\u30fc\uff0d-\uff0f \u00a0\u00ad\u200b\u2060\u3000()\uff08\uff09\uff3b\uff3d.\\[\\]/~\u2053\u223c\uff5e]*)+$"),Ob=/[- ]/;function Jb(a,b){var c=pb(b)?ub(a.ea,b):0;return(c=V(a.ea,U(c)))?c:Kb}
function Pb(a){for(var b=a.f.length,c=0;c<b;++c){var d=a.f[c],e=x(d,1);if(a.w==e)return!1;var f;f=a;var g=d,h=x(g,1);if(-1!=h.indexOf("|"))f=!1;else{h=h.replace(Lb,"\\d");h=h.replace(Mb,"\\d");C(f.m);var m;m=f;var g=x(g,2),D="999999999999999".match(h)[0];D.length<m.a.b.length?m="":(m=D.replace(new RegExp(h,"g"),g),m=m.replace(RegExp("9","g"),"\u2008"));0<m.length?(f.m.a(m),f=!0):f=!1}if(f)return a.w=e,a.aa=Ob.test(u(d,4)),a.s=0,!0}return a.j=!1}
function Qb(a,b){for(var c=[],d=b.length-3,e=a.f.length,f=0;f<e;++f){var g=a.f[f];y(g,3)?(g=u(g,3,Math.min(d,y(g,3)-1)),b.search(g)||c.push(a.f[f])):c.push(a.f[f])}a.f=c}function Rb(a,b){a.fa=Sb(a,b);return a.fa}
function Sb(a,b){a.i.a(b);var c=b;if(Za.test(c)||1==a.i.b.length&&Ya.test(c)){var c=b,d;"+"==c?(d=c,a.v.a(c)):(d=L[c],a.v.a(d),a.a.a(d));b=d}else a.j=!1,a.ha=!0;if(!a.j){if(!a.ha)if(Tb(a)){if(Ub(a))return Vb(a)}else if(0<a.l.length&&(c=a.a.toString(),C(a.a),a.a.a(a.l),a.a.a(c),c=a.b.toString(),d=c.lastIndexOf(a.l),C(a.b),a.b.a(c.substring(0,d))),a.l!=Wb(a))return a.b.a(" "),Vb(a);return a.i.toString()}switch(a.v.b.length){case 0:case 1:case 2:return a.i.toString();case 3:if(Tb(a))a.$=!0;else return a.l=
Wb(a),Xb(a);default:if(a.$)return Ub(a)&&(a.$=!1),a.b.toString()+a.a.toString();if(0<a.f.length){c=Yb(a,b);d=Zb(a);if(0<d.length)return d;Qb(a,a.a.toString());return Pb(a)?$b(a):a.j?ac(a,c):a.i.toString()}return Xb(a)}}function Vb(a){a.j=!0;a.$=!1;a.f=[];a.s=0;C(a.m);a.w="";return Xb(a)}function Zb(a){for(var b=a.a.toString(),c=a.f.length,d=0;d<c;++d){var e=a.f[d],f=x(e,1);if((new RegExp("^(?:"+f+")$")).test(b))return a.aa=Ob.test(u(e,4)),b=b.replace(new RegExp(f,"g"),u(e,2)),ac(a,b)}return""}
function ac(a,b){var c=a.b.b.length;return a.aa&&0<c&&" "!=a.b.toString().charAt(c-1)?a.b+" "+b:a.b+b}function Xb(a){var b=a.a.toString();if(3<=b.length){for(var c=a.o&&0<y(a.g,20)?w(a.g,20):w(a.g,19),d=c.length,e=0;e<d;++e){var f=c[e],g;(g=!t(a.g,12)||a.o||u(f,6))||(g=x(f,4),g=!g.length||jb.test(g));g&&Nb.test(x(f,2))&&a.f.push(f)}Qb(a,b);b=Zb(a);return 0<b.length?b:Pb(a)?$b(a):a.i.toString()}return ac(a,b)}
function $b(a){var b=a.a.toString(),c=b.length;if(0<c){for(var d="",e=0;e<c;e++)d=Yb(a,b.charAt(e));return a.j?ac(a,d):a.i.toString()}return a.b.toString()}
function Wb(a){var b=a.a.toString(),c=0,d;1!=u(a.g,10)?d=!1:(d=a.a.toString(),d="1"==d.charAt(0)&&"0"!=d.charAt(1)&&"1"!=d.charAt(1));d?(c=1,a.b.a("1").a(" "),a.o=!0):t(a.g,15)&&(d=new RegExp("^(?:"+u(a.g,15)+")"),(d=b.match(d))&&null!=d[0]&&0<d[0].length&&(a.o=!0,c=d[0].length,a.b.a(b.substring(0,c))));C(a.a);a.a.a(b.substring(c));return b.substring(0,c)}
function Tb(a){var b=a.v.toString(),c=new RegExp("^(?:\\+|"+u(a.g,11)+")");return(c=b.match(c))&&null!=c[0]&&0<c[0].length?(a.o=!0,c=c[0].length,C(a.a),a.a.a(b.substring(c)),C(a.b),a.b.a(b.substring(0,c)),"+"!=b.charAt(0)&&a.b.a(" "),!0):!1}function Ub(a){if(!a.a.b.length)return!1;var b=new B,c=Fb(a.a,b);if(!c)return!1;C(a.a);a.a.a(b.toString());b=U(c);"001"==b?a.g=V(a.ea,""+c):b!=a.ga&&(a.g=Jb(a,b));a.b.a(""+c).a(" ");a.l="";return!0}
function Yb(a,b){var c=a.m.toString();if(0<=c.substring(a.s).search(a.da)){var d=c.search(a.da),c=c.replace(a.da,b);C(a.m);a.m.a(c);a.s=d;return c.substring(0,a.s+1)}1==a.f.length&&(a.j=!1);a.w="";return a.i.toString()};function bc(){var a=pa("phoneNumber").value,b=pa("defaultCountry").value,c=pa("carrierCode").value,d=new B;try{var e=K.a(),f;if(!pb(b)&&0<a.length&&"+"!=a.charAt(0))throw Error("Invalid country calling code");f=yb(e,a,b,!0);d.a("****Parsing Result:****\n");d.a(qa((new A(1)).g(f)));d.a("\n\n****Validation Results:****");var g=0==Eb(e,f);d.a("\nResult from isPossibleNumber(): ");d.a(g);if(g){var h=xb(e,f);d.a("\nResult from isValidNumber(): ");d.a(h);h&&b&&"ZZ"!=b&&(d.a("\nResult from isValidNumberForRegion(): "),
d.a(Cb(e,f,b)));d.a("\nPhone Number region: ");d.a(Bb(e,f));d.a("\nResult from getNumberType(): ");var m;var D=Bb(e,f),R=T(e,x(f,1),D);if(R){var dc=Q(f);m=Ab(dc,R)}else m=-1;switch(m){case 0:d.a("FIXED_LINE");break;case 1:d.a("MOBILE");break;case 2:d.a("FIXED_LINE_OR_MOBILE");break;case 3:d.a("TOLL_FREE");break;case 4:d.a("PREMIUM_RATE");break;case 5:d.a("SHARED_COST");break;case 6:d.a("VOIP");break;case 7:d.a("PERSONAL_NUMBER");break;case 8:d.a("PAGER");break;case 9:d.a("UAN");break;case -1:d.a("UNKNOWN")}}else{d.a("\nResult from isPossibleNumberWithReason(): ");
switch(Eb(e,f)){case 1:d.a("INVALID_COUNTRY_CODE");break;case 2:d.a("TOO_SHORT");break;case 3:d.a("TOO_LONG")}d.a("\nNote: numbers that are not possible have type UNKNOWN, an unknown region, and are considered invalid.")}d.a("\n\n****Formatting Results:**** ");d.a("\nE164 format: ");d.a(h?P(e,f,0):"invalid");d.a("\nOriginal format: ");d.a(vb(e,f,b));d.a("\nNational format: ");d.a(P(e,f,2));d.a("\nInternational format: ");d.a(h?P(e,f,1):"invalid");d.a("\nOut-of-country format from US: ");d.a(h?tb(e,
f,"US"):"invalid");d.a("\nOut-of-country format from Switzerland: ");d.a(h?tb(e,f,"CH"):"invalid");0<c.length&&(d.a("\nNational format with carrier code: "),d.a(sb(e,f,c)));d.a("\n\n****AsYouTypeFormatter Results****");for(var ec=new Ib(b),fc=a.length,b=0;b<fc;++b){var mb=a.charAt(b);d.a("\nChar entered: ");d.a(mb);d.a(" Output: ");d.a(Rb(ec,mb))}}catch(gc){d.a("\n"+gc.toString())}pa("output").value=d.toString();return!1}var X=["phoneNumberParser"],Y=this;
X[0]in Y||!Y.execScript||Y.execScript("var "+X[0]);for(var Z;X.length&&(Z=X.shift());){var cc;if(cc=!X.length)cc=void 0!==bc;cc?Y[Z]=bc:Y[Z]?Y=Y[Z]:Y=Y[Z]={}};})();
var L={0:"0",1:"1",2:"2",3:"3",4:"4",5:"5",6:"6",7:"7",8:"8",9:"9","\uff10":"0","\uff11":"1","\uff12":"2","\uff13":"3","\uff14":"4","\uff15":"5","\uff16":"6","\uff17":"7","\uff18":"8","\uff19":"9","\u0660":"0","\u0661":"1","\u0662":"2","\u0663":"3","\u0664":"4","\u0665":"5","\u0666":"6","\u0667":"7","\u0668":"8","\u0669":"9","\u06f0":"0","\u06f1":"1","\u06f2":"2","\u06f3":"3","\u06f4":"4","\u06f5":"5","\u06f6":"6","\u06f7":"7","\u06f8":"8","\u06f9":"9"},Qa={0:"0",1:"1",2:"2",3:"3",4:"4",5:"5",6:"6",
7:"7",8:"8",9:"9","+":"+","*":"*","#":"#"},Ra={0:"0",1:"1",2:"2",3:"3",4:"4",5:"5",6:"6",7:"7",8:"8",9:"9","\uff10":"0","\uff11":"1","\uff12":"2","\uff13":"3","\uff14":"4","\uff15":"5","\uff16":"6","\uff17":"7","\uff18":"8","\uff19":"9","\u0660":"0","\u0661":"1","\u0662":"2","\u0663":"3","\u0664":"4","\u0665":"5","\u0666":"6","\u0667":"7","\u0668":"8","\u0669":"9","\u06f0":"0","\u06f1":"1","\u06f2":"2","\u06f3":"3","\u06f4":"4","\u06f5":"5","\u06f6":"6","\u06f7":"7","\u06f8":"8","\u06f9":"9",A:"2",
B:"2",C:"2",D:"3",E:"3",F:"3",G:"4",H:"4",I:"4",J:"5",K:"5",L:"5",M:"6",N:"6",O:"6",P:"7",Q:"7",R:"7",S:"7",T:"8",U:"8",V:"8",W:"9",X:"9",Y:"9",Z:"9"},Sa=/[\d]+(?:[~\u2053\u223C\uFF5E][\d]+)?/,Ta=RegExp("[+\uff0b]+"),M=RegExp("^[+\uff0b]+"),Ua=RegExp("([0-9\uff10-\uff19\u0660-\u0669\u06f0-\u06f9])"),Va=RegExp("[+\uff0b0-9\uff10-\uff19\u0660-\u0669\u06f0-\u06f9]"),Wa=/[\\\/] *x/,Xa=RegExp("[^0-9\uff10-\uff19\u0660-\u0669\u06f0-\u06f9A-Za-z#]+$"),Ya=/(?:.*?[A-Za-z]){3}.*/,Za=RegExp("(?:;ext=([0-9\uff10-\uff19\u0660-\u0669\u06f0-\u06f9]{1,7})|[ \u00a0\\t,]*(?:e?xt(?:ensi(?:o\u0301?|\u00f3))?n?|\uff45?\uff58\uff54\uff4e?|[;,x\uff58#\uff03~\uff5e]|int|anexo|\uff49\uff4e\uff54)[:\\.\uff0e]?[ \u00a0\\t,-]*([0-9\uff10-\uff19\u0660-\u0669\u06f0-\u06f9]{1,7})#?|[- ]+([0-9\uff10-\uff19\u0660-\u0669\u06f0-\u06f9]{1,5})#)$",
"i"),$a=RegExp("^[0-9\uff10-\uff19\u0660-\u0669\u06f0-\u06f9]{2}$|^[+\uff0b]*(?:[-x\u2010-\u2015\u2212\u30fc\uff0d-\uff0f \u00a0\u00ad\u200b\u2060\u3000()\uff08\uff09\uff3b\uff3d.\\[\\]/~\u2053\u223c\uff5e*]*[0-9\uff10-\uff19\u0660-\u0669\u06f0-\u06f9]){3,}[-x\u2010-\u2015\u2212\u30fc\uff0d-\uff0f \u00a0\u00ad\u200b\u2060\u3000()\uff08\uff09\uff3b\uff3d.\\[\\]/~\u2053\u223c\uff5e*A-Za-z0-9\uff10-\uff19\u0660-\u0669\u06f0-\u06f9]*(?:;ext=([0-9\uff10-\uff19\u0660-\u0669\u06f0-\u06f9]{1,7})|[ \u00a0\\t,]*(?:e?xt(?:ensi(?:o\u0301?|\u00f3))?n?|\uff45?\uff58\uff54\uff4e?|[;,x\uff58#\uff03~\uff5e]|int|anexo|\uff49\uff4e\uff54)[:\\.\uff0e]?[ \u00a0\\t,-]*([0-9\uff10-\uff19\u0660-\u0669\u06f0-\u06f9]{1,7})#?|[- ]+([0-9\uff10-\uff19\u0660-\u0669\u06f0-\u06f9]{1,5})#)?$",
"i"),ab=/(\$\d)/,bb=/\$NP/,cb=/\$FG/,db=/\$CC/,eb=/^\(?\$1\)?$/;function fb(a){var b=a.search(Va);0<=b?(a=a.substring(b),a=a.replace(Xa,""),b=a.search(Wa),0<=b&&(a=a.substring(0,b))):a="";return a}function hb(a){return 2>a.length?!1:N($a,a)}function ib(a){return N(Ya,a)?O(a,Ra):O(a,L)}function jb(a){var b=ib(a.toString());C(a);a.a(b)}function O(a,b){for(var c=new B,d,e=a.length,f=0;f<e;++f)d=a.charAt(f),d=b[d.toUpperCase()],null!=d&&c.a(d);return c.toString()}
function kb(a){return null!=a&&isNaN(a)&&a.toUpperCase()in Pa}function Q(a,b,c){if(0==u(b,2)&&t(b,5)){var d=x(b,5);if(0<d.length)return d}var d=x(b,1),e=R(b);if(0==c)return S(d,0,e,"");if(!(d in J))return e;a=T(a,d,U(d));b=lb(b,a,c);e=mb(e,a,c);return S(d,c,e,b)}function nb(a,b,c){var d=x(b,1),e=R(b);if(!(d in J))return e;a=T(a,d,U(d));b=lb(b,a,2);c=mb(e,a,2,c);return S(d,2,c,b)}function T(a,b,c){return"001"==c?V(a,""+b):V(a,c)}
function ob(a,b,c){if(!kb(c))return Q(a,b,1);var d=x(b,1),e=R(b);if(!(d in J))return e;if(1==d){if(null!=c&&0<=p(J[1],c.toUpperCase()))return d+" "+Q(a,b,2)}else if(d==pb(a,c))return Q(a,b,2);var f=V(a,c),g=x(f,11);c="";N(Sa,g)?c=g:t(f,17)&&(c=x(f,17));a=T(a,d,U(d));e=mb(e,a,1);b=lb(b,a,1);return 0<c.length?c+" "+d+" "+e+b:S(d,1,e,b)}
function qb(a,b,c){var d;if(d=t(b,5)){if(d=t(b,4))d=x(b,1),d=T(a,d,U(d)),d=!(d&&x(d,26));if(!d){d=x(b,1);if(d=T(a,d,U(d))){var e=R(b);d=!!rb(w(d,19),e)}else d=!1;d=!d}}if(d)return x(b,5);if(!t(b,6))return Q(a,b,2);switch(u(b,6)){case 1:a=Q(a,b,1);break;case 5:a=ob(a,b,c);break;case 10:a=Q(a,b,1).substring(1);break;default:d=U(x(b,1));var f;(c=V(a,d))?(c=x(c,12),f=c.length?c=c.replace("~",""):null):f=null;c=Q(a,b,2);if(null!=f&&f.length){var g;a:{e=x(b,5);e=O(e,L);if(!e.lastIndexOf(f,0))try{g=sb(a,
tb(a,e.substring(f.length),d,!1));break a}catch(h){}g=!1}if(g)a=c;else if(g=V(a,d),d=R(b),g=rb(w(g,19),d))if(d=x(g,4),e=d.indexOf("$1"),0>=e)a=c;else if(d=d.substring(0,e),d=O(d,L),d.length)if(g=g.clone(),Ga(g,4),d=[g],g=x(b,1),c=R(b),g in J){a=T(a,g,U(g));if(e=rb(d,c))d=e.clone(),e=x(e,4),0<e.length&&(f=x(a,12),0<f.length?(e=e.replace(bb,f).replace(cb,"$1"),v(d,4,e)):Ga(d,4)),c=ub(c,d,2);a=lb(b,a,2);a=S(g,2,c,a)}else a=c;else a=c;else a=c}else a=c}b=x(b,5);null!=a&&0<b.length&&(g=O(a,Qa),c=O(b,Qa),
g!=c&&(a=b));return a}function R(a){var b=""+u(a,2);return t(a,4)&&u(a,4)?Array(x(a,8)+1).join("0")+b:b}function S(a,b,c,d){switch(b){case 0:return"+"+a+c+d;case 1:return"+"+a+" "+c+d;case 3:return"tel:+"+a+"-"+c+d;default:return c+d}}function mb(a,b,c,d){b=w(b,20).length&&2!=c?w(b,20):w(b,19);return(b=rb(b,a))?ub(a,b,c,d):a}function rb(a,b){for(var c,d=a.length,e=0;e<d;++e){c=a[e];var f=y(c,3);if(!f||!b.search(u(c,3,f-1)))if(f=new RegExp(u(c,1)),N(f,b))return c}return null}
function ub(a,b,c,d){var e=x(b,2),f=new RegExp(u(b,1)),g=x(b,5);2==c&&null!=d&&0<d.length&&0<g.length?(b=g.replace(db,d),e=e.replace(ab,b),a=a.replace(f,e)):(b=x(b,4),a=2==c&&null!=b&&0<b.length?a.replace(f,e.replace(ab,b)):a.replace(f,e));3==c&&(a=a.replace(RegExp("^[-x\u2010-\u2015\u2212\u30fc\uff0d-\uff0f \u00a0\u00ad\u200b\u2060\u3000()\uff08\uff09\uff3b\uff3d.\\[\\]/~\u2053\u223c\uff5e]+"),""),a=a.replace(RegExp("[-x\u2010-\u2015\u2212\u30fc\uff0d-\uff0f \u00a0\u00ad\u200b\u2060\u3000()\uff08\uff09\uff3b\uff3d.\\[\\]/~\u2053\u223c\uff5e]+",
"g"),"-"));return a}function lb(a,b,c){return t(a,3)&&u(a,3).length?3==c?";ext="+u(a,3):t(b,13)?u(b,13)+x(a,3):" ext. "+x(a,3):""}function vb(a,b){return W(a,u(b,1))?W(a,u(b,5))?4:W(a,u(b,4))?3:W(a,u(b,6))?5:W(a,u(b,8))?6:W(a,u(b,7))?7:W(a,u(b,21))?8:W(a,u(b,25))?9:W(a,u(b,28))?10:W(a,u(b,2))?u(b,18)||W(a,u(b,3))?2:0:!u(b,18)&&W(a,u(b,3))?1:-1:-1}function V(a,b){if(null==b)return null;b=b.toUpperCase();var c=a.a[b];if(!c){c=Pa[b];if(!c)return null;c=(new I).f(G.h(),c);a.a[b]=c}return c}
function W(a,b){var c=a.length;return 0<y(b,9)&&-1==p(w(b,9),c)?!1:N(x(b,2),a)}function sb(a,b){var c=wb(a,b);return xb(a,b,c)}function xb(a,b,c){var d=x(b,1),e=T(a,d,c);if(!e||"001"!=c&&d!=pb(a,c))return!1;a=R(b);return-1!=vb(a,e)}function wb(a,b){if(!b)return null;var c=x(b,1);if(c=J[c])if(1==c.length)c=c[0];else a:{for(var d=R(b),e,f=c.length,g=0;g<f;g++){e=c[g];var h=V(a,e);if(t(h,23)){if(!d.search(u(h,23))){c=e;break a}}else if(-1!=vb(d,h)){c=e;break a}}c=null}else c=null;return c}
function U(a){return(a=J[a])?a[0]:"ZZ"}function pb(a,b){var c=V(a,b);if(!c)throw Error("Invalid region code: "+b);return x(c,10)}function yb(a,b){var c=w(b,9),d=w(b,10),e=a.length;if(-1<p(d,e))return 0;d=c[0];return d==e?0:d>e?2:c[c.length-1]<e?3:-1<p(c,e,1)?0:3}function zb(a,b){var c=R(b),d=x(b,1);if(!(d in J))return 1;d=T(a,d,U(d));return yb(c,u(d,1))}
function Ab(a,b){var c=a.toString();if(!c.length||"0"==c.charAt(0))return 0;for(var d,e=c.length,f=1;3>=f&&f<=e;++f)if(d=parseInt(c.substring(0,f),10),d in J)return b.a(c.substring(f)),d;return 0}
function Bb(a,b,c,d,e){if(!a.length)return 0;a=new B(a);var f;b&&(f=u(b,11));null==f&&(f="NonMatch");var g=a.toString();if(g.length)if(M.test(g))g=g.replace(M,""),C(a),a.a(ib(g)),f=1;else{g=new RegExp(f);jb(a);f=a.toString();if(f.search(g))f=!1;else{var g=f.match(g)[0].length,h=f.substring(g).match(Ua);h&&null!=h[1]&&0<h[1].length&&"0"==O(h[1],L)?f=!1:(C(a),a.a(f.substring(g)),f=!0)}f=f?5:20}else f=20;d&&v(e,6,f);if(20!=f){if(2>=a.b.length)throw Error("Phone number too short after IDD");if(c=Ab(a,
c))return v(e,1,c),c;throw Error("Invalid country calling code");}if(b&&(f=x(b,10),g=""+f,h=a.toString(),!h.lastIndexOf(g,0))){var m=new B(h.substring(g.length)),g=u(b,1),h=new RegExp(x(g,2));Cb(m,b,null);b=m.toString();if(!N(h,a.toString())&&N(h,b)||3==yb(a.toString(),g))return c.a(b),d&&v(e,6,10),v(e,1,f),f}v(e,1,0);return 0}
function Cb(a,b,c){var d=a.toString(),e=d.length,f=u(b,15);if(e&&null!=f&&f.length){var g=new RegExp("^(?:"+f+")");if(e=g.exec(d)){var f=new RegExp(x(u(b,1),2)),h=N(f,d),m=e.length-1;b=u(b,16);if(null!=b&&b.length&&null!=e[m]&&e[m].length){if(d=d.replace(g,b),!h||N(f,d))c&&0<m&&c.a(e[1]),a.set(d)}else if(!h||N(f,d.substring(e[0].length)))c&&0<m&&null!=e[m]&&c.a(e[1]),a.set(d.substring(e[0].length))}}}
function tb(a,b,c,d){if(null==b)throw Error("The string supplied did not seem to be a phone number");if(250<b.length)throw Error("The string supplied is too long to be a phone number");var e=new B,f=b.indexOf(";phone-context=");if(0<f){var g=f+15;if("+"==b.charAt(g)){var h=b.indexOf(";",g);0<h?e.a(b.substring(g,h)):e.a(b.substring(g))}g=b.indexOf("tel:");e.a(b.substring(0<=g?g+4:0,f))}else e.a(fb(b));f=e.toString();g=f.indexOf(";isub=");0<g&&(C(e),e.a(f.substring(0,g)));if(!hb(e.toString()))throw Error("The string supplied did not seem to be a phone number");
f=e.toString();if(!(kb(c)||null!=f&&0<f.length&&M.test(f)))throw Error("Invalid country calling code");f=new H;d&&v(f,5,b);a:{b=e.toString();g=b.search(Za);if(0<=g&&hb(b.substring(0,g)))for(var h=b.match(Za),m=h.length,D=1;D<m;++D)if(null!=h[D]&&0<h[D].length){C(e);e.a(b.substring(0,g));b=h[D];break a}b=""}0<b.length&&v(f,3,b);b=V(a,c);g=new B;h=0;m=e.toString();try{h=Bb(m,b,g,d,f)}catch(P){if("Invalid country calling code"==P.message&&M.test(m)){if(m=m.replace(M,""),h=Bb(m,b,g,d,f),!h)throw P;}else throw P;
}h?(e=U(h),e!=c&&(b=T(a,h,e))):(jb(e),g.a(e.toString()),null!=c?(h=x(b,10),v(f,1,h)):d&&Ga(f,6));if(2>g.b.length)throw Error("The string supplied is too short to be a phone number");b&&(a=new B,c=new B(g.toString()),Cb(c,b,a),2!=yb(c.toString(),u(b,1))&&(g=c,d&&0<a.toString().length&&v(f,7,a.toString())));d=g.toString();a=d.length;if(2>a)throw Error("The string supplied is too short to be a phone number");if(17<a)throw Error("The string supplied is too long to be a phone number");if(1<d.length&&"0"==
d.charAt(0)){v(f,4,!0);for(a=1;a<d.length-1&&"0"==d.charAt(a);)a++;1!=a&&v(f,8,a)}v(f,2,parseInt(d,10));return f}function N(a,b){var c="string"==typeof a?b.match("^(?:"+a+")$"):b.match(a);return c&&c[0].length==b.length?!0:!1};function Db(a){this.ca=RegExp("\u2008");this.ea="";this.m=new B;this.w="";this.i=new B;this.v=new B;this.j=!0;this.$=this.o=this.ga=!1;this.da=K.a();this.s=0;this.b=new B;this.aa=!1;this.l="";this.a=new B;this.f=[];this.fa=a;this.g=Eb(this,this.fa)}var Fb=new G;v(Fb,11,"NA");
var Gb=/\[([^\[\]])*\]/g,Hb=/\d(?=[^,}][^,}])/g,Ib=RegExp("^[-x\u2010-\u2015\u2212\u30fc\uff0d-\uff0f \u00a0\u00ad\u200b\u2060\u3000()\uff08\uff09\uff3b\uff3d.\\[\\]/~\u2053\u223c\uff5e]*(\\$\\d[-x\u2010-\u2015\u2212\u30fc\uff0d-\uff0f \u00a0\u00ad\u200b\u2060\u3000()\uff08\uff09\uff3b\uff3d.\\[\\]/~\u2053\u223c\uff5e]*)+$"),Jb=/[- ]/;function Eb(a,b){var c=kb(b)?pb(a.da,b):0;return(c=V(a.da,U(c)))?c:Fb}
function Kb(a){for(var b=a.f.length,c=0;c<b;++c){var d=a.f[c],e=x(d,1);if(a.w==e)return!1;var f;f=a;var g=d,h=x(g,1);if(-1!=h.indexOf("|"))f=!1;else{h=h.replace(Gb,"\\d");h=h.replace(Hb,"\\d");C(f.m);var m;m=f;var g=x(g,2),D="999999999999999".match(h)[0];D.length<m.a.b.length?m="":(m=D.replace(new RegExp(h,"g"),g),m=m.replace(RegExp("9","g"),"\u2008"));0<m.length?(f.m.a(m),f=!0):f=!1}if(f)return a.w=e,a.aa=Jb.test(u(d,4)),a.s=0,!0}return a.j=!1}
function Lb(a,b){for(var c=[],d=b.length-3,e=a.f.length,f=0;f<e;++f){var g=a.f[f];y(g,3)?(g=u(g,3,Math.min(d,y(g,3)-1)),b.search(g)||c.push(a.f[f])):c.push(a.f[f])}a.f=c}function Mb(a,b){a.ea=Nb(a,b);return a.ea}
function Nb(a,b){a.i.a(b);var c=b;if(Ua.test(c)||1==a.i.b.length&&Ta.test(c)){var c=b,d;"+"==c?(d=c,a.v.a(c)):(d=L[c],a.v.a(d),a.a.a(d));b=d}else a.j=!1,a.ga=!0;if(!a.j){if(!a.ga)if(Ob(a)){if(Pb(a))return Qb(a)}else if(0<a.l.length&&(c=a.a.toString(),C(a.a),a.a.a(a.l),a.a.a(c),c=a.b.toString(),d=c.lastIndexOf(a.l),C(a.b),a.b.a(c.substring(0,d))),a.l!=Rb(a))return a.b.a(" "),Qb(a);return a.i.toString()}switch(a.v.b.length){case 0:case 1:case 2:return a.i.toString();case 3:if(Ob(a))a.$=!0;else return a.l=
Rb(a),Sb(a);default:if(a.$)return Pb(a)&&(a.$=!1),a.b.toString()+a.a.toString();if(0<a.f.length){c=Tb(a,b);d=Ub(a);if(0<d.length)return d;Lb(a,a.a.toString());return Kb(a)?Vb(a):a.j?Wb(a,c):a.i.toString()}return Sb(a)}}function Qb(a){a.j=!0;a.$=!1;a.f=[];a.s=0;C(a.m);a.w="";return Sb(a)}function Ub(a){for(var b=a.a.toString(),c=a.f.length,d=0;d<c;++d){var e=a.f[d],f=x(e,1);if((new RegExp("^(?:"+f+")$")).test(b))return a.aa=Jb.test(u(e,4)),b=b.replace(new RegExp(f,"g"),u(e,2)),Wb(a,b)}return""}
function Wb(a,b){var c=a.b.b.length;return a.aa&&0<c&&" "!=a.b.toString().charAt(c-1)?a.b+" "+b:a.b+b}function Sb(a){var b=a.a.toString();if(3<=b.length){for(var c=a.o&&0<y(a.g,20)?w(a.g,20):w(a.g,19),d=c.length,e=0;e<d;++e){var f=c[e],g;(g=!t(a.g,12)||a.o||u(f,6))||(g=x(f,4),g=!g.length||eb.test(g));g&&Ib.test(x(f,2))&&a.f.push(f)}Lb(a,b);b=Ub(a);return 0<b.length?b:Kb(a)?Vb(a):a.i.toString()}return Wb(a,b)}
function Vb(a){var b=a.a.toString(),c=b.length;if(0<c){for(var d="",e=0;e<c;e++)d=Tb(a,b.charAt(e));return a.j?Wb(a,d):a.i.toString()}return a.b.toString()}
function Rb(a){var b=a.a.toString(),c=0,d;1!=u(a.g,10)?d=!1:(d=a.a.toString(),d="1"==d.charAt(0)&&"0"!=d.charAt(1)&&"1"!=d.charAt(1));d?(c=1,a.b.a("1").a(" "),a.o=!0):t(a.g,15)&&(d=new RegExp("^(?:"+u(a.g,15)+")"),(d=b.match(d))&&null!=d[0]&&0<d[0].length&&(a.o=!0,c=d[0].length,a.b.a(b.substring(0,c))));C(a.a);a.a.a(b.substring(c));return b.substring(0,c)}
function Ob(a){var b=a.v.toString(),c=new RegExp("^(?:\\+|"+u(a.g,11)+")");return(c=b.match(c))&&null!=c[0]&&0<c[0].length?(a.o=!0,c=c[0].length,C(a.a),a.a.a(b.substring(c)),C(a.b),a.b.a(b.substring(0,c)),"+"!=b.charAt(0)&&a.b.a(" "),!0):!1}function Pb(a){if(!a.a.b.length)return!1;var b=new B,c=Ab(a.a,b);if(!c)return!1;C(a.a);a.a.a(b.toString());b=U(c);"001"==b?a.g=V(a.da,""+c):b!=a.fa&&(a.g=Eb(a,b));a.b.a(""+c).a(" ");a.l="";return!0}
function Tb(a,b){var c=a.m.toString();if(0<=c.substring(a.s).search(a.ca)){var d=c.search(a.ca),c=c.replace(a.ca,b);C(a.m);a.m.a(c);a.s=d;return c.substring(0,a.s+1)}1==a.f.length&&(a.j=!1);a.w="";return a.i.toString()};function Xb(){var a=q("phoneNumber").value,b=q("defaultCountry").value,c=q("carrierCode").value,d=new B;try{var e=K.a(),f;if(!kb(b)&&0<a.length&&"+"!=a.charAt(0))throw Error("Invalid country calling code");f=tb(e,a,b,!0);d.a("****Parsing Result:****\n");d.a(la((new A(1)).g(f)));d.a("\n\n****Validation Results:****");var g=0==zb(e,f);d.a("\nResult from isPossibleNumber(): ");d.a(g);if(g){var h=sb(e,f);d.a("\nResult from isValidNumber(): ");d.a(h);h&&b&&"ZZ"!=b&&(d.a("\nResult from isValidNumberForRegion(): "),
d.a(xb(e,f,b)));d.a("\nPhone Number region: ");d.a(wb(e,f));d.a("\nResult from getNumberType(): ");var m;var D=wb(e,f),P=T(e,x(f,1),D);if(P){var Zb=R(f);m=vb(Zb,P)}else m=-1;switch(m){case 0:d.a("FIXED_LINE");break;case 1:d.a("MOBILE");break;case 2:d.a("FIXED_LINE_OR_MOBILE");break;case 3:d.a("TOLL_FREE");break;case 4:d.a("PREMIUM_RATE");break;case 5:d.a("SHARED_COST");break;case 6:d.a("VOIP");break;case 7:d.a("PERSONAL_NUMBER");break;case 8:d.a("PAGER");break;case 9:d.a("UAN");break;case -1:d.a("UNKNOWN")}}else{d.a("\nResult from isPossibleNumberWithReason(): ");
switch(zb(e,f)){case 1:d.a("INVALID_COUNTRY_CODE");break;case 2:d.a("TOO_SHORT");break;case 3:d.a("TOO_LONG")}d.a("\nNote: numbers that are not possible have type UNKNOWN, an unknown region, and are considered invalid.")}d.a("\n\n****Formatting Results:**** ");d.a("\nE164 format: ");d.a(h?Q(e,f,0):"invalid");d.a("\nOriginal format: ");d.a(qb(e,f,b));d.a("\nNational format: ");d.a(Q(e,f,2));d.a("\nInternational format: ");d.a(h?Q(e,f,1):"invalid");d.a("\nOut-of-country format from US: ");d.a(h?ob(e,
f,"US"):"invalid");d.a("\nOut-of-country format from Switzerland: ");d.a(h?ob(e,f,"CH"):"invalid");0<c.length&&(d.a("\nNational format with carrier code: "),d.a(nb(e,f,c)));d.a("\n\n****AsYouTypeFormatter Results****");for(var $b=new Db(b),ac=a.length,b=0;b<ac;++b){var gb=a.charAt(b);d.a("\nChar entered: ");d.a(gb);d.a(" Output: ");d.a(Mb($b,gb))}}catch(bc){d.a("\n"+bc.toString())}q("output").value=d.toString();return!1}var X=["phoneNumberParser"],Y=this;
X[0]in Y||!Y.execScript||Y.execScript("var "+X[0]);for(var Z;X.length&&(Z=X.shift());){var Yb;if(Yb=!X.length)Yb=void 0!==Xb;Yb?Y[Z]=Xb:Y[Z]?Y=Y[Z]:Y=Y[Z]={}};})();

+ 58
- 31
javascript/i18n/phonenumbers/phonenumberutil.js View File

@ -966,9 +966,9 @@ i18n.phonenumbers.PhoneNumberUtil.ValidationResult = {
/** The number length matches that of valid numbers for this region. */ /** The number length matches that of valid numbers for this region. */
IS_POSSIBLE: 0, IS_POSSIBLE: 0,
/** /**
* The number length matches that of local numbers for this region only (i.e. numbers that may
* be able to be dialled within an area, but do not have all the information to be dialled from
* anywhere inside or outside the country).
* The number length matches that of local numbers for this region only (i.e.
* numbers that may be able to be dialled within an area, but do not have all
* the information to be dialled from anywhere inside or outside the country).
*/ */
IS_POSSIBLE_LOCAL_ONLY: 4, IS_POSSIBLE_LOCAL_ONLY: 4,
/** The number has an invalid country calling code. */ /** The number has an invalid country calling code. */
@ -976,9 +976,9 @@ i18n.phonenumbers.PhoneNumberUtil.ValidationResult = {
/** The number is shorter than all valid numbers for this region. */ /** The number is shorter than all valid numbers for this region. */
TOO_SHORT: 2, TOO_SHORT: 2,
/** /**
* The number is longer than the shortest valid numbers for this region, shorter than the
* longest valid numbers for this region, and does not itself have a number length that matches
* valid numbers for this region.
* The number is longer than the shortest valid numbers for this region,
* shorter than the longest valid numbers for this region, and does not itself
* have a number length that matches valid numbers for this region.
*/ */
INVALID_LENGTH: 5, INVALID_LENGTH: 5,
/** The number is longer than all valid numbers for this region. */ /** The number is longer than all valid numbers for this region. */
@ -3832,6 +3832,10 @@ i18n.phonenumbers.PhoneNumberUtil.prototype.setItalianLeadingZerosForPhoneNumber
* same as the public {@link #parse} method, with the exception that it allows * same as the public {@link #parse} method, with the exception that it allows
* the default region to be null, for use by {@link #isNumberMatch}. * the default region to be null, for use by {@link #isNumberMatch}.
* *
* Note if any new field is added to this method that should always be filled
* in, even when keepRawInput is false, it should also be handled in the
* copyCoreFieldsOnly method.
*
* @param {?string} numberToParse number that we are attempting to parse. This * @param {?string} numberToParse number that we are attempting to parse. This
* can contain formatting such as +, ( and -, as well as a phone number * can contain formatting such as +, ( and -, as well as a phone number
* extension. * extension.
@ -4057,6 +4061,36 @@ i18n.phonenumbers.PhoneNumberUtil.prototype.buildNationalNumberForParsing_ =
}; };
/**
* Returns a new phone number containing only the fields needed to uniquely
* identify a phone number, rather than any fields that capture the context in
* which the phone number was created.
* These fields correspond to those set in parse() rather than
* parseAndKeepRawInput().
*
* @param {i18n.phonenumbers.PhoneNumber} numberIn number that we want to copy
* fields from.
* @return {i18n.phonenumbers.PhoneNumber} number with core fields only.
* @private
*/
i18n.phonenumbers.PhoneNumberUtil.copyCoreFieldsOnly_ = function(numberIn) {
/** @type {i18n.phonenumbers.PhoneNumber} */
var phoneNumber = new i18n.phonenumbers.PhoneNumber();
phoneNumber.setCountryCode(numberIn.getCountryCodeOrDefault());
phoneNumber.setNationalNumber(numberIn.getNationalNumberOrDefault());
if (numberIn.getExtensionOrDefault().length > 0) {
phoneNumber.setExtension(numberIn.getExtensionOrDefault());
}
if (numberIn.getItalianLeadingZero()) {
phoneNumber.setItalianLeadingZero(true);
// This field is only relevant if there are leading zeros at all.
phoneNumber.setNumberOfLeadingZeros(
numberIn.getNumberOfLeadingZerosOrDefault());
}
return phoneNumber;
};
/** /**
* Takes two phone numbers and compares them for equality. * Takes two phone numbers and compares them for equality.
* *
@ -4149,37 +4183,29 @@ i18n.phonenumbers.PhoneNumberUtil.prototype.isNumberMatch =
} else { } else {
secondNumber = secondNumberIn.clone(); secondNumber = secondNumberIn.clone();
} }
// First clear raw_input, country_code_source and
// preferred_domestic_carrier_code fields and any empty-string extensions so
// that we can use the proto-buffer equality method.
firstNumber.clearRawInput();
firstNumber.clearCountryCodeSource();
firstNumber.clearPreferredDomesticCarrierCode();
secondNumber.clearRawInput();
secondNumber.clearCountryCodeSource();
secondNumber.clearPreferredDomesticCarrierCode();
if (firstNumber.hasExtension() && firstNumber.getExtension().length == 0) {
firstNumber.clearExtension();
}
if (secondNumber.hasExtension() && secondNumber.getExtension().length == 0) {
secondNumber.clearExtension();
}
var firstNumberToCompare =
i18n.phonenumbers.PhoneNumberUtil.copyCoreFieldsOnly_(firstNumber);
var secondNumberToCompare =
i18n.phonenumbers.PhoneNumberUtil.copyCoreFieldsOnly_(secondNumber);
// Early exit if both had extensions and these are different. // Early exit if both had extensions and these are different.
if (firstNumber.hasExtension() && secondNumber.hasExtension() &&
firstNumber.getExtension() != secondNumber.getExtension()) {
if (firstNumberToCompare.hasExtension() &&
secondNumberToCompare.hasExtension() &&
firstNumberToCompare.getExtension() !=
secondNumberToCompare.getExtension()) {
return i18n.phonenumbers.PhoneNumberUtil.MatchType.NO_MATCH; return i18n.phonenumbers.PhoneNumberUtil.MatchType.NO_MATCH;
} }
/** @type {number} */ /** @type {number} */
var firstNumberCountryCode = firstNumber.getCountryCodeOrDefault();
var firstNumberCountryCode = firstNumberToCompare.getCountryCodeOrDefault();
/** @type {number} */ /** @type {number} */
var secondNumberCountryCode = secondNumber.getCountryCodeOrDefault();
var secondNumberCountryCode = secondNumberToCompare.getCountryCodeOrDefault();
// Both had country_code specified. // Both had country_code specified.
if (firstNumberCountryCode != 0 && secondNumberCountryCode != 0) { if (firstNumberCountryCode != 0 && secondNumberCountryCode != 0) {
if (firstNumber.equals(secondNumber)) {
if (firstNumberToCompare.equals(secondNumberToCompare)) {
return i18n.phonenumbers.PhoneNumberUtil.MatchType.EXACT_MATCH; return i18n.phonenumbers.PhoneNumberUtil.MatchType.EXACT_MATCH;
} else if (firstNumberCountryCode == secondNumberCountryCode && } else if (firstNumberCountryCode == secondNumberCountryCode &&
this.isNationalNumberSuffixOfTheOther_(firstNumber, secondNumber)) {
this.isNationalNumberSuffixOfTheOther_(
firstNumberToCompare, secondNumberToCompare)) {
// A SHORT_NSN_MATCH occurs if there is a difference because of the // A SHORT_NSN_MATCH occurs if there is a difference because of the
// presence or absence of an 'Italian leading zero', the presence or // presence or absence of an 'Italian leading zero', the presence or
// absence of an extension, or one NSN being a shorter variant of the // absence of an extension, or one NSN being a shorter variant of the
@ -4192,13 +4218,14 @@ i18n.phonenumbers.PhoneNumberUtil.prototype.isNumberMatch =
// Checks cases where one or both country_code fields were not specified. To // Checks cases where one or both country_code fields were not specified. To
// make equality checks easier, we first set the country_code fields to be // make equality checks easier, we first set the country_code fields to be
// equal. // equal.
firstNumber.setCountryCode(0);
secondNumber.setCountryCode(0);
firstNumberToCompare.setCountryCode(0);
secondNumberToCompare.setCountryCode(0);
// If all else was the same, then this is an NSN_MATCH. // If all else was the same, then this is an NSN_MATCH.
if (firstNumber.equals(secondNumber)) {
if (firstNumberToCompare.equals(secondNumberToCompare)) {
return i18n.phonenumbers.PhoneNumberUtil.MatchType.NSN_MATCH; return i18n.phonenumbers.PhoneNumberUtil.MatchType.NSN_MATCH;
} }
if (this.isNationalNumberSuffixOfTheOther_(firstNumber, secondNumber)) {
if (this.isNationalNumberSuffixOfTheOther_(firstNumberToCompare,
secondNumberToCompare)) {
return i18n.phonenumbers.PhoneNumberUtil.MatchType.SHORT_NSN_MATCH; return i18n.phonenumbers.PhoneNumberUtil.MatchType.SHORT_NSN_MATCH;
} }
return i18n.phonenumbers.PhoneNumberUtil.MatchType.NO_MATCH; return i18n.phonenumbers.PhoneNumberUtil.MatchType.NO_MATCH;


+ 75
- 0
javascript/i18n/phonenumbers/phonenumberutil_test.js View File

@ -3156,7 +3156,82 @@ function testIsNumberMatchMatches() {
assertEquals('Numbers did not match', assertEquals('Numbers did not match',
i18n.phonenumbers.PhoneNumberUtil.MatchType.EXACT_MATCH, i18n.phonenumbers.PhoneNumberUtil.MatchType.EXACT_MATCH,
phoneUtil.isNumberMatch(nzNumber, NZ_NUMBER)); phoneUtil.isNumberMatch(nzNumber, NZ_NUMBER));
}
function testIsNumberMatchShortMatchIfDiffNumLeadingZeros() {
/** @type {i18n.phonenumbers.PhoneNumber} */
var nzNumberOne = new i18n.phonenumbers.PhoneNumber();
/** @type {i18n.phonenumbers.PhoneNumber} */
var nzNumberTwo = new i18n.phonenumbers.PhoneNumber();
nzNumberOne.setCountryCode(64);
nzNumberOne.setNationalNumber(33316005);
nzNumberOne.setItalianLeadingZero(true);
nzNumberTwo.setCountryCode(64);
nzNumberTwo.setNationalNumber(33316005);
nzNumberTwo.setItalianLeadingZero(true);
nzNumberTwo.setNumberOfLeadingZeros(2);
assertEquals(i18n.phonenumbers.PhoneNumberUtil.MatchType.SHORT_NSN_MATCH,
phoneUtil.isNumberMatch(nzNumberOne, nzNumberTwo));
nzNumberOne.setItalianLeadingZero(false);
nzNumberOne.setNumberOfLeadingZeros(1);
nzNumberTwo.setItalianLeadingZero(true);
nzNumberTwo.setNumberOfLeadingZeros(1);
// Since one doesn't have the "italian_leading_zero" set to true, we ignore
// the number of leading zeros present (1 is in any case the default value).
assertEquals(i18n.phonenumbers.PhoneNumberUtil.MatchType.SHORT_NSN_MATCH,
phoneUtil.isNumberMatch(nzNumberOne, nzNumberTwo));
}
function testIsNumberMatchAcceptsProtoDefaultsAsMatch() {
/** @type {i18n.phonenumbers.PhoneNumber} */
var nzNumberOne = new i18n.phonenumbers.PhoneNumber();
/** @type {i18n.phonenumbers.PhoneNumber} */
var nzNumberTwo = new i18n.phonenumbers.PhoneNumber();
nzNumberOne.setCountryCode(64);
nzNumberOne.setNationalNumber(33316005);
nzNumberOne.setItalianLeadingZero(true);
// The default for number_of_leading_zeros is 1, so it shouldn't normally be
// set, however if it is it should be considered equivalent.
nzNumberTwo.setCountryCode(64);
nzNumberTwo.setNationalNumber(33316005);
nzNumberTwo.setItalianLeadingZero(true);
nzNumberTwo.setNumberOfLeadingZeros(1);
assertEquals(i18n.phonenumbers.PhoneNumberUtil.MatchType.EXACT_MATCH,
phoneUtil.isNumberMatch(nzNumberOne, nzNumberTwo));
}
function testIsNumberMatchMatchesDiffLeadingZerosIfItalianLeadingZeroFalse() {
/** @type {i18n.phonenumbers.PhoneNumber} */
var nzNumberOne = new i18n.phonenumbers.PhoneNumber();
/** @type {i18n.phonenumbers.PhoneNumber} */
var nzNumberTwo = new i18n.phonenumbers.PhoneNumber();
nzNumberOne.setCountryCode(64);
nzNumberOne.setNationalNumber(33316005);
// The default for number_of_leading_zeros is 1, so it shouldn't normally be
// set, however if it is it should be considered equivalent.
nzNumberTwo.setCountryCode(64);
nzNumberTwo.setNationalNumber(33316005);
nzNumberTwo.setNumberOfLeadingZeros(1);
assertEquals(i18n.phonenumbers.PhoneNumberUtil.MatchType.EXACT_MATCH,
phoneUtil.isNumberMatch(nzNumberOne, nzNumberTwo));
// Even if it is set to ten, it is still equivalent because in both cases
// italian_leading_zero is not true.
assertEquals(i18n.phonenumbers.PhoneNumberUtil.MatchType.EXACT_MATCH,
phoneUtil.isNumberMatch(nzNumberOne, nzNumberTwo));
}
function testIsNumberMatchIgnoresSomeFields() {
var CCS = i18n.phonenumbers.PhoneNumber.CountryCodeSource; var CCS = i18n.phonenumbers.PhoneNumber.CountryCodeSource;
// Check raw_input, country_code_source and preferred_domestic_carrier_code // Check raw_input, country_code_source and preferred_domestic_carrier_code
// are ignored. // are ignored.


Loading…
Cancel
Save