const require_rolldown_runtime = require('../../../../../../../_virtual/rolldown_runtime.js');
const require_metadata$1 = require('../metadata.js');
const require_matchesEntirely$1 = require('./matchesEntirely.js');

//#region ../../node_modules/.pnpm/libphonenumber-js@1.11.3/node_modules/libphonenumber-js/build/helpers/getNumberType.js
var require_getNumberType = /* @__PURE__ */ require_rolldown_runtime.__commonJS({ "../../node_modules/.pnpm/libphonenumber-js@1.11.3/node_modules/libphonenumber-js/build/helpers/getNumberType.js": ((exports) => {
	Object.defineProperty(exports, "__esModule", { value: true });
	exports["default"] = getNumberType;
	exports.isNumberTypeEqualTo = isNumberTypeEqualTo;
	var _metadata = _interopRequireDefault(require_metadata$1.require_metadata());
	var _matchesEntirely = _interopRequireDefault(require_matchesEntirely$1.require_matchesEntirely());
	function _interopRequireDefault(obj) {
		return obj && obj.__esModule ? obj : { "default": obj };
	}
	function _createForOfIteratorHelperLoose(o, allowArrayLike) {
		var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
		if (it) return (it = it.call(o)).next.bind(it);
		if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
			if (it) o = it;
			var i = 0;
			return function() {
				if (i >= o.length) return { done: true };
				return {
					done: false,
					value: o[i++]
				};
			};
		}
		throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
	}
	function _unsupportedIterableToArray(o, minLen) {
		if (!o) return;
		if (typeof o === "string") return _arrayLikeToArray(o, minLen);
		var n = Object.prototype.toString.call(o).slice(8, -1);
		if (n === "Object" && o.constructor) n = o.constructor.name;
		if (n === "Map" || n === "Set") return Array.from(o);
		if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
	}
	function _arrayLikeToArray(arr, len) {
		if (len == null || len > arr.length) len = arr.length;
		for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
		return arr2;
	}
	var NON_FIXED_LINE_PHONE_TYPES = [
		"MOBILE",
		"PREMIUM_RATE",
		"TOLL_FREE",
		"SHARED_COST",
		"VOIP",
		"PERSONAL_NUMBER",
		"PAGER",
		"UAN",
		"VOICEMAIL"
	];
	function getNumberType(input, options, metadata) {
		options = options || {};
		if (!input.country && !input.countryCallingCode) return;
		metadata = new _metadata["default"](metadata);
		metadata.selectNumberingPlan(input.country, input.countryCallingCode);
		var nationalNumber = options.v2 ? input.nationalNumber : input.phone;
		if (!(0, _matchesEntirely["default"])(nationalNumber, metadata.nationalNumberPattern())) return;
		if (isNumberTypeEqualTo(nationalNumber, "FIXED_LINE", metadata)) {
			if (metadata.type("MOBILE") && metadata.type("MOBILE").pattern() === "") return "FIXED_LINE_OR_MOBILE";
			if (!metadata.type("MOBILE")) return "FIXED_LINE_OR_MOBILE";
			/* istanbul ignore if */
			if (isNumberTypeEqualTo(nationalNumber, "MOBILE", metadata)) return "FIXED_LINE_OR_MOBILE";
			return "FIXED_LINE";
		}
		for (var _iterator = _createForOfIteratorHelperLoose(NON_FIXED_LINE_PHONE_TYPES), _step; !(_step = _iterator()).done;) {
			var type = _step.value;
			if (isNumberTypeEqualTo(nationalNumber, type, metadata)) return type;
		}
	}
	function isNumberTypeEqualTo(nationalNumber, type, metadata) {
		type = metadata.type(type);
		if (!type || !type.pattern()) return false;
		if (type.possibleLengths() && type.possibleLengths().indexOf(nationalNumber.length) < 0) return false;
		return (0, _matchesEntirely["default"])(nationalNumber, type.pattern());
	}
}) });

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