const require_rolldown_runtime = require('../../../../../../../_virtual/rolldown_runtime.js');
const require_constants$1 = require('../constants.js');

//#region ../../node_modules/.pnpm/libphonenumber-js@1.11.3/node_modules/libphonenumber-js/build/helpers/extractPhoneContext.js
var require_extractPhoneContext = /* @__PURE__ */ require_rolldown_runtime.__commonJS({ "../../node_modules/.pnpm/libphonenumber-js@1.11.3/node_modules/libphonenumber-js/build/helpers/extractPhoneContext.js": ((exports) => {
	Object.defineProperty(exports, "__esModule", { value: true });
	exports["default"] = extractPhoneContext;
	exports.isPhoneContextValid = isPhoneContextValid;
	var _constants = require_constants$1.require_constants();
	var PLUS_SIGN = "+";
	exports.PLUS_SIGN = PLUS_SIGN;
	var RFC3966_PHONE_DIGIT_ = "([" + _constants.VALID_DIGITS + "]|[\\-\\.\\(\\)]?)";
	var RFC3966_GLOBAL_NUMBER_DIGITS_ = "^\\" + PLUS_SIGN + RFC3966_PHONE_DIGIT_ + "*[" + _constants.VALID_DIGITS + "]" + RFC3966_PHONE_DIGIT_ + "*$";
	/**
	* Regular expression of valid global-number-digits for the phone-context
	* parameter, following the syntax defined in RFC3966.
	*/
	var RFC3966_GLOBAL_NUMBER_DIGITS_PATTERN_ = new RegExp(RFC3966_GLOBAL_NUMBER_DIGITS_, "g");
	var ALPHANUM_ = _constants.VALID_DIGITS;
	var RFC3966_DOMAINLABEL_ = "[" + ALPHANUM_ + "]+((\\-)*[" + ALPHANUM_ + "])*";
	var RFC3966_TOPLABEL_ = "[a-zA-Z]+((\\-)*[" + ALPHANUM_ + "])*";
	var RFC3966_DOMAINNAME_ = "^(" + RFC3966_DOMAINLABEL_ + "\\.)*" + RFC3966_TOPLABEL_ + "\\.?$";
	/**
	* Regular expression of valid domainname for the phone-context parameter,
	* following the syntax defined in RFC3966.
	*/
	var RFC3966_DOMAINNAME_PATTERN_ = new RegExp(RFC3966_DOMAINNAME_, "g");
	var RFC3966_PREFIX_ = "tel:";
	exports.RFC3966_PREFIX_ = RFC3966_PREFIX_;
	var RFC3966_PHONE_CONTEXT_ = ";phone-context=";
	exports.RFC3966_PHONE_CONTEXT_ = RFC3966_PHONE_CONTEXT_;
	var RFC3966_ISDN_SUBADDRESS_ = ";isub=";
	/**
	* Extracts the value of the phone-context parameter of `numberToExtractFrom`,
	* following the syntax defined in RFC3966.
	*
	* @param {string} numberToExtractFrom
	* @return {string|null} the extracted string (possibly empty), or `null` if no phone-context parameter is found.
	*/
	exports.RFC3966_ISDN_SUBADDRESS_ = RFC3966_ISDN_SUBADDRESS_;
	function extractPhoneContext(numberToExtractFrom) {
		var indexOfPhoneContext = numberToExtractFrom.indexOf(RFC3966_PHONE_CONTEXT_);
		if (indexOfPhoneContext < 0) return null;
		var phoneContextStart = indexOfPhoneContext + RFC3966_PHONE_CONTEXT_.length;
		if (phoneContextStart >= numberToExtractFrom.length) return "";
		var phoneContextEnd = numberToExtractFrom.indexOf(";", phoneContextStart);
		if (phoneContextEnd >= 0) return numberToExtractFrom.substring(phoneContextStart, phoneContextEnd);
		else return numberToExtractFrom.substring(phoneContextStart);
	}
	/**
	* Returns whether the value of phoneContext follows the syntax defined in RFC3966.
	*
	* @param {string|null} phoneContext
	* @return {boolean}
	*/
	function isPhoneContextValid(phoneContext) {
		if (phoneContext === null) return true;
		if (phoneContext.length === 0) return false;
		return RFC3966_GLOBAL_NUMBER_DIGITS_PATTERN_.test(phoneContext) || RFC3966_DOMAINNAME_PATTERN_.test(phoneContext);
	}
}) });

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