import countries from '../../data/countries.mjs';
import { longestMatchingPrefix } from '../longestMatchingPrefix/index.mjs';

const findCountryByPrefix = number => {
  if (number.length > 1) {
    const matchingCodes = countries.filter(country => number.startsWith(country.phone));
    if (matchingCodes.length > 0) {
      return longestMatchingPrefix(matchingCodes);
    }
  }
  return null;
};

export { findCountryByPrefix };
//# sourceMappingURL=index.mjs.map
