const require_rolldown_runtime = require('../../../../../../_virtual/rolldown_runtime.js');
const require_metadata$1 = require('./metadata.js');
const require_isPossible$1 = require('./isPossible.js');
const require_getNumberType$1 = require('./helpers/getNumberType.js');
const require_isValid$1 = require('./isValid.js');
const require_getPossibleCountriesForNumber$1 = require('./helpers/getPossibleCountriesForNumber.js');
const require_format$1 = require('./format.js');

//#region ../../node_modules/.pnpm/libphonenumber-js@1.11.3/node_modules/libphonenumber-js/build/PhoneNumber.js
var require_PhoneNumber = /* @__PURE__ */ require_rolldown_runtime.__commonJS({ "../../node_modules/.pnpm/libphonenumber-js@1.11.3/node_modules/libphonenumber-js/build/PhoneNumber.js": ((exports) => {
	Object.defineProperty(exports, "__esModule", { value: true });
	var _metadata = _interopRequireDefault(require_metadata$1.require_metadata());
	var _isPossible = _interopRequireDefault(require_isPossible$1.require_isPossible());
	var _isValid = _interopRequireDefault(require_isValid$1.require_isValid());
	var _getNumberType = _interopRequireDefault(require_getNumberType$1.require_getNumberType());
	var _getPossibleCountriesForNumber = _interopRequireDefault(require_getPossibleCountriesForNumber$1.require_getPossibleCountriesForNumber());
	var _format2 = _interopRequireDefault(require_format$1.require_format());
	function _interopRequireDefault(obj) {
		return obj && obj.__esModule ? obj : { "default": obj };
	}
	function ownKeys(object, enumerableOnly) {
		var keys = Object.keys(object);
		if (Object.getOwnPropertySymbols) {
			var symbols = Object.getOwnPropertySymbols(object);
			enumerableOnly && (symbols = symbols.filter(function(sym) {
				return Object.getOwnPropertyDescriptor(object, sym).enumerable;
			})), keys.push.apply(keys, symbols);
		}
		return keys;
	}
	function _objectSpread(target) {
		for (var i = 1; i < arguments.length; i++) {
			var source = null != arguments[i] ? arguments[i] : {};
			i % 2 ? ownKeys(Object(source), !0).forEach(function(key) {
				_defineProperty(target, key, source[key]);
			}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function(key) {
				Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
			});
		}
		return target;
	}
	function _defineProperty(obj, key, value) {
		if (key in obj) Object.defineProperty(obj, key, {
			value,
			enumerable: true,
			configurable: true,
			writable: true
		});
		else obj[key] = value;
		return obj;
	}
	function _classCallCheck(instance, Constructor) {
		if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
	}
	function _defineProperties(target, props) {
		for (var i = 0; i < props.length; i++) {
			var descriptor = props[i];
			descriptor.enumerable = descriptor.enumerable || false;
			descriptor.configurable = true;
			if ("value" in descriptor) descriptor.writable = true;
			Object.defineProperty(target, descriptor.key, descriptor);
		}
	}
	function _createClass(Constructor, protoProps, staticProps) {
		if (protoProps) _defineProperties(Constructor.prototype, protoProps);
		if (staticProps) _defineProperties(Constructor, staticProps);
		Object.defineProperty(Constructor, "prototype", { writable: false });
		return Constructor;
	}
	var USE_NON_GEOGRAPHIC_COUNTRY_CODE = false;
	var PhoneNumber = /* @__PURE__ */ function() {
		/**
		* @param  {string} countryOrCountryCallingCode
		* @param  {string} nationalNumber
		* @param  {object} metadata — Metadata JSON
		* @return {PhoneNumber}
		*/
		function PhoneNumber$1(countryOrCountryCallingCode, nationalNumber, metadata) {
			_classCallCheck(this, PhoneNumber$1);
			if (!countryOrCountryCallingCode) throw new TypeError("`country` or `countryCallingCode` not passed");
			if (!nationalNumber) throw new TypeError("`nationalNumber` not passed");
			if (!metadata) throw new TypeError("`metadata` not passed");
			var _getCountryAndCountry = getCountryAndCountryCallingCode(countryOrCountryCallingCode, metadata), country = _getCountryAndCountry.country, countryCallingCode = _getCountryAndCountry.countryCallingCode;
			this.country = country;
			this.countryCallingCode = countryCallingCode;
			this.nationalNumber = nationalNumber;
			this.number = "+" + this.countryCallingCode + this.nationalNumber;
			this.getMetadata = function() {
				return metadata;
			};
		}
		_createClass(PhoneNumber$1, [
			{
				key: "setExt",
				value: function setExt(ext) {
					this.ext = ext;
				}
			},
			{
				key: "getPossibleCountries",
				value: function getPossibleCountries() {
					if (this.country) return [this.country];
					return (0, _getPossibleCountriesForNumber["default"])(this.countryCallingCode, this.nationalNumber, this.getMetadata());
				}
			},
			{
				key: "isPossible",
				value: function isPossible() {
					return (0, _isPossible["default"])(this, { v2: true }, this.getMetadata());
				}
			},
			{
				key: "isValid",
				value: function isValid() {
					return (0, _isValid["default"])(this, { v2: true }, this.getMetadata());
				}
			},
			{
				key: "isNonGeographic",
				value: function isNonGeographic() {
					return new _metadata["default"](this.getMetadata()).isNonGeographicCallingCode(this.countryCallingCode);
				}
			},
			{
				key: "isEqual",
				value: function isEqual(phoneNumber) {
					return this.number === phoneNumber.number && this.ext === phoneNumber.ext;
				}
			},
			{
				key: "getType",
				value: function getType() {
					return (0, _getNumberType["default"])(this, { v2: true }, this.getMetadata());
				}
			},
			{
				key: "format",
				value: function format(_format, options) {
					return (0, _format2["default"])(this, _format, options ? _objectSpread(_objectSpread({}, options), {}, { v2: true }) : { v2: true }, this.getMetadata());
				}
			},
			{
				key: "formatNational",
				value: function formatNational(options) {
					return this.format("NATIONAL", options);
				}
			},
			{
				key: "formatInternational",
				value: function formatInternational(options) {
					return this.format("INTERNATIONAL", options);
				}
			},
			{
				key: "getURI",
				value: function getURI(options) {
					return this.format("RFC3966", options);
				}
			}
		]);
		return PhoneNumber$1;
	}();
	exports["default"] = PhoneNumber;
	var isCountryCode = function isCountryCode$1(value) {
		return /^[A-Z]{2}$/.test(value);
	};
	function getCountryAndCountryCallingCode(countryOrCountryCallingCode, metadataJson) {
		var country;
		var countryCallingCode;
		var metadata = new _metadata["default"](metadataJson);
		if (isCountryCode(countryOrCountryCallingCode)) {
			country = countryOrCountryCallingCode;
			metadata.selectNumberingPlan(country);
			countryCallingCode = metadata.countryCallingCode();
		} else {
			countryCallingCode = countryOrCountryCallingCode;
			/* istanbul ignore if */
			if (USE_NON_GEOGRAPHIC_COUNTRY_CODE) {
				if (metadata.isNonGeographicCallingCode(countryCallingCode)) country = "001";
			}
		}
		return {
			country,
			countryCallingCode
		};
	}
}) });

//#endregion
Object.defineProperty(exports, 'default', {
  enumerable: true,
  get: function () {
    return require_PhoneNumber();
  }
});