import {
    provinceAndCityData,
    pcTextArr,
    regionData,
    pcaTextArr,
    codeToText,
  } from "element-china-area-data";


  function removeDistricts(data) {
    return data.map(province => {
      // 过滤省下的所有市
      const filteredCities = province.children.filter(city => {
        // 如果市下没有区，或者区不包含市辖区，保留这个市
        const hasNoDistrictsOrNoDistrict = !city.children || city.children.length === 0;
        const noDistrictIsDistrict = city.children && city.children.every(district => district.name !== '市辖区');
        return hasNoDistrictsOrNoDistrict || noDistrictIsDistrict;
      });
      return {
        ...province,
        children: filteredCities,
      };
    }).filter(province => province.children && province.children.length > 0); // 过滤掉没有市的省
  }

const customAreaData = removeDistricts(regionData);
export default customAreaData;