function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
import { MapIcon } from '@vtx/map-icon';
import { getVtxToken, request } from '@vtx/utils';
import { useRequest } from 'ahooks';
import useSettings from "../_hooks/useSettings";
var BaseService = {
  useBaseInfo: function useBaseInfo(id) {
    var _useRequest = useRequest(function () {
        return request.get('/cloud/rygl/api/v101/cleaner/get', {
          data: {
            id: id,
            desensitization: true
          }
        });
      }, {
        ready: !!id,
        refreshDeps: [id]
      }),
      baseInfoRes = _useRequest.data;
    var info = baseInfoRes ? baseInfoRes.data : {};
    var baseInfo = [{
      label: '编号',
      key: 'staffCode',
      value: info === null || info === void 0 ? void 0 : info.staffCode
    }, {
      label: '所属单位',
      key: 'unitName',
      value: info === null || info === void 0 ? void 0 : info.unitName
    }, {
      label: '性别',
      key: 'genderName',
      value: info === null || info === void 0 ? void 0 : info.genderName
    }, {
      label: '入职日期',
      key: 'entryDay',
      value: info === null || info === void 0 ? void 0 : info.entryDay
    }, {
      label: '在职状态',
      key: 'jobStatusName',
      value: info === null || info === void 0 ? void 0 : info.jobStatusName
    }, {
      label: '所属标段',
      key: 'tenderName',
      value: info === null || info === void 0 ? void 0 : info.tenderName
    }, {
      label: '行政区划',
      key: 'divisionName',
      value: info === null || info === void 0 ? void 0 : info.divisionName
    }];
    return {
      baseInfo: baseInfo,
      detail: info || {}
    };
  },
  // 实时信息
  useMapInfo: function useMapInfo(id, coordType) {
    var _mapInfoRes$data, _mapInfoRes$data2, _mapInfoRes$data3, _mapInfoRes$data4, _mapInfoRes$data5, _mapInfoRes$data6, _areas$data, _areas$data2;
    var _useRequest2 = useRequest(function () {
        return request.get('/cloud/rykq/api/v101/realtime/getStaffDetail', {
          data: {
            staffId: id,
            coordType: coordType || 'wgs84'
          }
        });
      }, {
        ready: !!id,
        refreshDeps: [id]
      }),
      mapInfoRes = _useRequest2.data;
    var _useRequest3 = useRequest(function () {
        return request.get('/cloud/rygl/workElementCleaner/getByStaffId', {
          data: {
            staffId: id,
            coordType: coordType || 'wgs84'
          }
        });
      }, {
        ready: !!id,
        refreshDeps: [id]
      }),
      areas = _useRequest3.data;
    var _useSettings = useSettings(),
      isDark = _useSettings.isDark;
    return {
      info: mapInfoRes === null || mapInfoRes === void 0 ? void 0 : mapInfoRes.data,
      mapPoints: mapInfoRes !== null && mapInfoRes !== void 0 && (_mapInfoRes$data = mapInfoRes.data) !== null && _mapInfoRes$data !== void 0 && _mapInfoRes$data.lngDone ? [{
        id: 'reaiPoint',
        name: mapInfoRes.data.staffName,
        canShowLabel: true,
        config: {
          labelContent: mapInfoRes.data.staffName
        },
        lng: mapInfoRes.data.lngDone,
        lat: mapInfoRes.data.latDone,
        url: mapInfoRes !== null && mapInfoRes !== void 0 && (_mapInfoRes$data2 = mapInfoRes.data) !== null && _mapInfoRes$data2 !== void 0 && _mapInfoRes$data2.icon ? "/cloudFile/common/downloadFile?id=".concat(mapInfoRes === null || mapInfoRes === void 0 || (_mapInfoRes$data3 = mapInfoRes.data) === null || _mapInfoRes$data3 === void 0 ? void 0 : _mapInfoRes$data3.icon, "&token=").concat(getVtxToken('token')) : isDark ? new MapIcon.CommonIcon({
          canvasIcon: 'PERSONNEL',
          color: (mapInfoRes === null || mapInfoRes === void 0 || (_mapInfoRes$data4 = mapInfoRes.data) === null || _mapInfoRes$data4 === void 0 ? void 0 : _mapInfoRes$data4.statusCode) === 'Normal' ? '#119FFB' : '#999999'
        }).getImgUrl() : new MapIcon.CommonIcon({
          canvasIcon: 'PERSONNEL',
          color: (mapInfoRes === null || mapInfoRes === void 0 || (_mapInfoRes$data5 = mapInfoRes.data) === null || _mapInfoRes$data5 === void 0 ? void 0 : _mapInfoRes$data5.statusCode) === 'Normal' ? '#119FFB' : '#999999'
        }).getImgUrl()
      }] : [],
      pointLngLat: mapInfoRes !== null && mapInfoRes !== void 0 && (_mapInfoRes$data6 = mapInfoRes.data) !== null && _mapInfoRes$data6 !== void 0 && _mapInfoRes$data6.lngDone ? [mapInfoRes.data.lngDone, mapInfoRes.data.latDone] : [],
      mapPolygons: areas !== null && areas !== void 0 && areas.data ? (_areas$data = areas.data) === null || _areas$data === void 0 || (_areas$data = _areas$data.filter(function (ele) {
        return ele.shape !== 'circle';
      })) === null || _areas$data === void 0 ? void 0 : _areas$data.map(function (item) {
        return _objectSpread(_objectSpread({}, item), {}, {
          rings: item.paramsDone,
          type: item.shape
        });
      }) : [],
      mapCircles: areas === null || areas === void 0 || (_areas$data2 = areas.data) === null || _areas$data2 === void 0 || (_areas$data2 = _areas$data2.filter(function (ele) {
        return ele.shape === 'circle';
      })) === null || _areas$data2 === void 0 ? void 0 : _areas$data2.map(function (item) {
        return {
          id: item.id,
          data: item.paramsDone.split(',').map(function (ele) {
            return Number(ele);
          }).concat([item.radius]),
          type: item.shape
        };
      })
    };
  }
};
export { BaseService };