import _extends from "@babel/runtime/helpers/esm/extends";

/**
 * 热门城市
 */
var HOT_CITY_LIST = [{
  districtID: 'XZ2-174',
  districtName: '北京-北京市',
  simpleName: '北京市'
}, {
  districtID: 'XZ2-040',
  districtName: '上海-上海市',
  simpleName: '上海市'
}, {
  districtID: 'XZ2-042',
  simpleName: '广州市',
  districtName: '广东省-广州市'
}, {
  districtID: 'XZ2-229',
  districtName: '广东省-深圳市',
  simpleName: '深圳市'
}, {
  districtID: 'XZ2-253',
  districtName: '广东省-东莞市',
  simpleName: '东莞市'
}, {
  districtID: 'XZ2-316',
  districtName: '广东省-佛山市',
  simpleName: '佛山市'
}, {
  districtID: 'XZ2-311',
  districtName: '广东省-中山市',
  simpleName: '中山市'
}];
var areaList = [{
  districtID: 'XZ0-01',
  districtName: '华南'
}, {
  districtID: 'XZ0-02',
  districtName: '华东'
}, {
  districtID: 'XZ0-03',
  districtName: '京津冀'
}, {
  districtID: 'XZ0-04',
  districtName: '华北'
}];
var provinceList = [{
  districtID: 'XZ1-06',
  districtName: '北京',
  adminCode: '110000'
}, {
  districtID: 'XZ1-05',
  districtName: '天津',
  adminCode: '120000'
}, {
  districtID: 'XZ1-16',
  districtName: '河北省',
  adminCode: '130000'
}, {
  districtID: 'XZ1-02',
  districtName: '山西省',
  adminCode: '140000'
}, {
  districtID: 'XZ1-29',
  districtName: '内蒙古自治区',
  adminCode: '150000'
}, {
  districtID: 'XZ1-33',
  districtName: '辽宁省',
  adminCode: '210000'
}, {
  districtID: 'XZ1-11',
  districtName: '吉林省',
  adminCode: '220000'
}, {
  districtID: 'XZ1-25',
  districtName: '黑龙江省',
  adminCode: '230000'
}, {
  districtID: 'XZ1-01',
  districtName: '上海',
  adminCode: '310000'
}, {
  districtID: 'XZ1-14',
  districtName: '江苏省',
  adminCode: '320000'
}, {
  districtID: 'XZ1-22',
  districtName: '浙江省',
  adminCode: '330000'
}, {
  districtID: 'XZ1-12',
  districtName: '安徽省',
  adminCode: '340000'
}, {
  districtID: 'XZ1-27',
  districtName: '福建省',
  adminCode: '350000'
}, {
  districtID: 'XZ1-13',
  districtName: '江西省',
  adminCode: '360000'
}, {
  districtID: 'XZ1-03',
  districtName: '山东省',
  adminCode: '370000'
}, {
  districtID: 'XZ1-17',
  districtName: '河南省',
  adminCode: '410000'
}, {
  districtID: 'XZ1-23',
  districtName: '湖北省',
  adminCode: '420000'
}, {
  districtID: 'XZ1-24',
  districtName: '湖南省',
  adminCode: '430000'
}, {
  districtID: 'XZ1-31',
  districtName: '广东省',
  adminCode: '440000'
}, {
  districtID: 'XZ1-30',
  districtName: '广西壮族自治区',
  adminCode: '450000'
}, {
  districtID: 'XZ1-21',
  districtName: '海南省',
  adminCode: '460000'
}, {
  districtID: 'XZ1-19',
  districtName: '重庆',
  adminCode: '500000'
}, {
  districtID: 'XZ1-08',
  districtName: '四川省',
  adminCode: '510000'
}, {
  districtID: 'XZ1-32',
  districtName: '贵州省',
  adminCode: '520000'
}, {
  districtID: 'XZ1-04',
  districtName: '云南省',
  adminCode: '530000'
}, {
  districtID: 'XZ1-15',
  districtName: '西藏自治区',
  adminCode: '540000'
}, {
  districtID: 'XZ1-34',
  districtName: '陕西省',
  adminCode: '610000'
}, {
  districtID: 'XZ1-09',
  districtName: '甘肃省',
  adminCode: '620000'
}, {
  districtID: 'XZ1-18',
  districtName: '青海省',
  adminCode: '630000'
}, {
  districtID: 'XZ1-10',
  districtName: '宁夏回族自治区',
  adminCode: '640000'
}, {
  districtID: 'XZ1-26',
  districtName: '新疆维吾尔自治区',
  adminCode: '650000'
}];

var getRegionTreeData = function getRegionTreeData(isArea) {
  var rootNode = {
    districtName: '全国',
    districtID: 'all',
    simpleName: '全国',
    index: 0,
    isChecked: false,
    isIndeterminate: false,
    _erpZoom: 0,
    districtLevel: 'china',
    childrenNode: []
  };

  if (isArea) {
    areaList.forEach(function (item, index) {
      rootNode.childrenNode.push(_extends({}, item, {
        simpleName: item.districtName,
        index: index + 1,
        isChecked: false,
        isIndeterminate: false,
        districtLevel: 'area',
        childrenNode: [],
        _erpZoom: 0
      }));
    });
  } else {
    provinceList.forEach(function (item, index) {
      rootNode.childrenNode.push(_extends({}, item, {
        index: index + 1,
        simpleName: item.districtName,
        isChecked: false,
        isIndeterminate: false,
        districtLevel: 'province',
        childrenNode: [],
        _erpZoom: 0
      }));
    });
  }

  return rootNode;
};

var cloneDeep = function cloneDeep(target, map) {
  if (map === void 0) {
    map = new WeakMap();
  }

  if (typeof target !== 'object') {
    return target;
  }

  if (map.has(target)) {
    return map.get(target);
  }

  var type = Object.prototype.toString.call(target).slice(8, -1);
  var cloneTarget;

  switch (type) {
    case 'Object':
    case 'Array':
      cloneTarget = type === 'Array' ? [] : {};
      map.set(target, cloneTarget);
      Object.getOwnPropertyNames(target).forEach(function (key) {
        cloneTarget[key] = cloneDeep(target[key], map);
      });
      break;

    case 'Map':
      cloneTarget = new Map();
      map.set(target, cloneTarget);
      target.forEach(function (value, key) {
        cloneTarget.set(cloneDeep(key, map), cloneDeep(value, map));
      });
      break;

    case 'Set':
      cloneTarget = new Set();
      map.set(target, cloneTarget);
      target.forEach(function (value) {
        cloneTarget.add(cloneDeep(value, map));
      });
      break;

    case 'RegExp':
    case 'Number':
    case 'String':
    case 'Boolean':
    case 'Date':
    case 'Error':
      cloneTarget = new target.constructor(target);
      break;

    case 'Symbol':
      cloneTarget = Object(Object.prototype.valueOf.call(target));
      break;

    case 'Null':
      cloneTarget = null;
      break;
  }

  return cloneTarget;
};

export { cloneDeep, getRegionTreeData, HOT_CITY_LIST };