var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/components/pisellPhone/utils/phoneFormatter.ts
var phoneFormatter_exports = {};
__export(phoneFormatter_exports, {
  detectPhoneType: () => detectPhoneType,
  formatChinaMobile: () => formatChinaMobile,
  formatPhone: () => formatPhone,
  formatUKPhone: () => formatUKPhone,
  formatUSPhone: () => formatUSPhone,
  maskPhone: () => maskPhone
});
module.exports = __toCommonJS(phoneFormatter_exports);
function formatChinaMobile(phone) {
  const cleaned = phone.replace(/\D/g, "");
  if (cleaned.length <= 3) return cleaned;
  if (cleaned.length <= 7) {
    return `${cleaned.slice(0, 3)} ${cleaned.slice(3)}`;
  }
  return `${cleaned.slice(0, 3)} ${cleaned.slice(3, 7)} ${cleaned.slice(7, 11)}`;
}
function formatUSPhone(phone) {
  const cleaned = phone.replace(/\D/g, "");
  if (cleaned.length <= 3) return cleaned;
  if (cleaned.length <= 6) {
    return `(${cleaned.slice(0, 3)}) ${cleaned.slice(3)}`;
  }
  return `(${cleaned.slice(0, 3)}) ${cleaned.slice(3, 6)}-${cleaned.slice(6, 10)}`;
}
function formatUKPhone(phone) {
  const cleaned = phone.replace(/\D/g, "");
  if (cleaned.length <= 4) return cleaned;
  if (cleaned.length <= 7) {
    return `${cleaned.slice(0, 4)} ${cleaned.slice(4)}`;
  }
  return `${cleaned.slice(0, 4)} ${cleaned.slice(4, 7)} ${cleaned.slice(7, 11)}`;
}
function formatPhone(phone, countryCode) {
  const cleaned = phone.replace(/\D/g, "");
  switch (countryCode) {
    case "+86":
      return formatChinaMobile(cleaned);
    case "+1":
      return formatUSPhone(cleaned);
    case "+44":
      return formatUKPhone(cleaned);
    default:
      return cleaned;
  }
}
function maskPhone(phone, pattern = "middle") {
  const cleaned = phone.replace(/\D/g, "");
  if (cleaned.length < 7) return cleaned;
  switch (pattern) {
    case "middle":
      if (cleaned.length === 11) {
        return cleaned.replace(/(\d{3})\d{4}(\d{4})/, "$1****$2");
      }
      return cleaned;
    case "last":
      if (cleaned.length >= 7) {
        return cleaned.slice(0, -4) + "****";
      }
      return cleaned;
    default:
      return cleaned;
  }
}
function detectPhoneType(phone) {
  const cleaned = phone.replace(/\D/g, "");
  if (/^1[3-9]\d{9}$/.test(cleaned)) {
    return "mobile";
  }
  if (/^0\d{2,3}\d{7,8}$/.test(cleaned)) {
    return "landline";
  }
  return "unknown";
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  detectPhoneType,
  formatChinaMobile,
  formatPhone,
  formatUKPhone,
  formatUSPhone,
  maskPhone
});
