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 React from 'react';
import { JzljDfTpdContext } from "../..";
import { VmInfoCollection, VmMap, VmWrapper } from "../../../_components";
import { overviewApis, useUnit } from "../../api";
import CTL from "./CTL";
import CTYL from "./CTYL";
import CZZ from "./CZZ";
import "./index.less";
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
export default function Overview() {
  var _React$useContext = React.useContext(JzljDfTpdContext),
    id = _React$useContext.id,
    theme = _React$useContext.theme,
    _React$useContext$inf = _React$useContext.info,
    info = _React$useContext$inf === void 0 ? {} : _React$useContext$inf;
  var name = info.name,
    address = info.address,
    facilityClassName = info.facilityClassName,
    divisionName = info.divisionName,
    geometryInfo = info.geometryInfo;
  var _overviewApis$useJcss = overviewApis.useJcssBubble(id),
    jcssBubbleData = _overviewApis$useJcss.jcssBubbleData;
  var infoData = [{
    label: '名称',
    value: name
  }, {
    label: '类别',
    value: facilityClassName
  }, {
    label: '地址',
    value: address
  }];
  for (var key in jcssBubbleData === null || jcssBubbleData === void 0 ? void 0 : jcssBubbleData.otherWeight) {
    infoData.push({
      label: key,
      key: key,
      value: jcssBubbleData === null || jcssBubbleData === void 0 ? void 0 : jcssBubbleData.otherWeight[key]
    });
  }
  var _ref = geometryInfo || {},
    type = _ref.type,
    lngLats = _ref.lngLats;
  var mapProps = {
    geometryType: type,
    address: address
  };
  if (type === 'point' && lngLats) {
    var _lngLats$split, _lngLats$split2;
    mapProps.mapPoints = [{
      id: id,
      lng: lngLats === null || lngLats === void 0 || (_lngLats$split = lngLats.split(',')) === null || _lngLats$split === void 0 ? void 0 : _lngLats$split[0],
      lat: lngLats === null || lngLats === void 0 || (_lngLats$split2 = lngLats.split(',')) === null || _lngLats$split2 === void 0 ? void 0 : _lngLats$split2[1]
    }];
  }
  if (type === 'polygon' && lngLats) {
    mapProps.mapPolygons = [{
      id: id,
      rings: lngLats
    }];
  }
  var _useUnit = useUnit(),
    unitStr = _useUnit.unitStr;
  return /*#__PURE__*/_jsxs("div", {
    className: "df-tpd-overview",
    children: [/*#__PURE__*/_jsx("div", {
      className: "df-tpd-overview-left",
      children: /*#__PURE__*/_jsxs(VmWrapper, {
        title: "\u57FA\u672C\u4FE1\u606F",
        children: [/*#__PURE__*/_jsx(VmInfoCollection, {
          width: '100%',
          data: infoData
        }), /*#__PURE__*/_jsx("div", {
          className: "df-tpd-overview-left-map ".concat(theme),
          children: /*#__PURE__*/_jsx(VmMap, _objectSpread({}, mapProps))
        })]
      })
    }), /*#__PURE__*/_jsxs("div", {
      className: "df-tpd-overview-right",
      children: [/*#__PURE__*/_jsxs("div", {
        className: "df-tpd-overview-right-top",
        children: [/*#__PURE__*/_jsx(CZZ, {
          unitStr: unitStr
        }), /*#__PURE__*/_jsx(CTL, {
          unitStr: unitStr
        })]
      }), /*#__PURE__*/_jsx("div", {
        className: "df-tpd-overview-right-bottom",
        children: /*#__PURE__*/_jsx(CTYL, {
          unitStr: unitStr
        })
      })]
    })]
  });
}