import u from "./index-metadata.js";
import f from "./index-isPossible.js";
import c from "./index-isValid.js";
import m from "./index-getNumberType.js";
import y from "./index-getPossibleCountriesForNumber.js";
import h from "./index-format.js";
function i(r, t) {
  var e = Object.keys(r);
  if (Object.getOwnPropertySymbols) {
    var n = Object.getOwnPropertySymbols(r);
    t && (n = n.filter(function(a) {
      return Object.getOwnPropertyDescriptor(r, a).enumerable;
    })), e.push.apply(e, n);
  }
  return e;
}
function o(r) {
  for (var t = 1; t < arguments.length; t++) {
    var e = arguments[t] != null ? arguments[t] : {};
    t % 2 ? i(Object(e), !0).forEach(function(n) {
      b(r, n, e[n]);
    }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(r, Object.getOwnPropertyDescriptors(e)) : i(Object(e)).forEach(function(n) {
      Object.defineProperty(r, n, Object.getOwnPropertyDescriptor(e, n));
    });
  }
  return r;
}
function b(r, t, e) {
  return t in r ? Object.defineProperty(r, t, { value: e, enumerable: !0, configurable: !0, writable: !0 }) : r[t] = e, r;
}
function p(r, t) {
  if (!(r instanceof t))
    throw new TypeError("Cannot call a class as a function");
}
function g(r, t) {
  for (var e = 0; e < t.length; e++) {
    var n = t[e];
    n.enumerable = n.enumerable || !1, n.configurable = !0, "value" in n && (n.writable = !0), Object.defineProperty(r, n.key, n);
  }
}
function d(r, t, e) {
  return t && g(r.prototype, t), Object.defineProperty(r, "prototype", { writable: !1 }), r;
}
var j = /* @__PURE__ */ (function() {
  function r(t, e, n) {
    if (p(this, r), !t)
      throw new TypeError("`country` or `countryCallingCode` not passed");
    if (!e)
      throw new TypeError("`nationalNumber` not passed");
    if (!n)
      throw new TypeError("`metadata` not passed");
    var a = C(t, n), s = a.country, l = a.countryCallingCode;
    this.country = s, this.countryCallingCode = l, this.nationalNumber = e, this.number = "+" + this.countryCallingCode + this.nationalNumber, this.metadata = n;
  }
  return d(r, [{
    key: "setExt",
    value: function(e) {
      this.ext = e;
    }
  }, {
    key: "getPossibleCountries",
    value: function() {
      return this.country ? [this.country] : y(this.countryCallingCode, this.nationalNumber, this.metadata);
    }
  }, {
    key: "isPossible",
    value: function() {
      return f(this, {
        v2: !0
      }, this.metadata);
    }
  }, {
    key: "isValid",
    value: function() {
      return c(this, {
        v2: !0
      }, this.metadata);
    }
  }, {
    key: "isNonGeographic",
    value: function() {
      var e = new u(this.metadata);
      return e.isNonGeographicCallingCode(this.countryCallingCode);
    }
  }, {
    key: "isEqual",
    value: function(e) {
      return this.number === e.number && this.ext === e.ext;
    }
    // This function was originally meant to be an equivalent for `validatePhoneNumberLength()`,
    // but later it was found out that it doesn't include the possible `TOO_SHORT` result
    // returned from `parsePhoneNumberWithError()` in the original `validatePhoneNumberLength()`,
    // so eventually I simply commented out this method from the `PhoneNumber` class
    // and just left the `validatePhoneNumberLength()` function, even though that one would require
    // and additional step to also validate the actual country / calling code of the phone number.
    // validateLength() {
    // 	const metadata = new Metadata(this.metadata)
    // 	metadata.selectNumberingPlan(this.countryCallingCode)
    // 	const result = checkNumberLength(this.nationalNumber, metadata)
    // 	if (result !== 'IS_POSSIBLE') {
    // 		return result
    // 	}
    // }
  }, {
    key: "getType",
    value: function() {
      return m(this, {
        v2: !0
      }, this.metadata);
    }
  }, {
    key: "format",
    value: function(e, n) {
      return h(this, e, n ? o(o({}, n), {}, {
        v2: !0
      }) : {
        v2: !0
      }, this.metadata);
    }
  }, {
    key: "formatNational",
    value: function(e) {
      return this.format("NATIONAL", e);
    }
  }, {
    key: "formatInternational",
    value: function(e) {
      return this.format("INTERNATIONAL", e);
    }
  }, {
    key: "getURI",
    value: function(e) {
      return this.format("RFC3966", e);
    }
  }]), r;
})(), v = function(t) {
  return /^[A-Z]{2}$/.test(t);
};
function C(r, t) {
  var e, n, a = new u(t);
  return v(r) ? (e = r, a.selectNumberingPlan(e), n = a.countryCallingCode()) : n = r, {
    country: e,
    countryCallingCode: n
  };
}
export {
  j as default
};
