import { Col, Row } from 'antd';
import _ from 'lodash';
import { VmInfoCollection, VmMap, VmTitle, VmWrapper } from "../../../_components";
import { BaseInfo as DefaultBaseInfo } from "../../../vtx-default-modal/components";
import { LaneService } from "../../api";
import "./index.less";
import Rules from "./Rules";
import Work from "./Work";
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
var BaseInfo = function BaseInfo(_ref) {
  var _info$lngLats, _jcssInfo$geometryInf;
  var id = _ref.id,
    jcssInfo = _ref.jcssInfo,
    _ref$hasRule = _ref.hasRule,
    hasRule = _ref$hasRule === void 0 ? false : _ref$hasRule,
    setIframeModalInfo = _ref.setIframeModalInfo;
  var _LaneService$useBaseI = LaneService.useBaseInfo(jcssInfo === null || jcssInfo === void 0 ? void 0 : jcssInfo.id, hasRule),
    baseInfo = _LaneService$useBaseI.baseInfo,
    info = _LaneService$useBaseI.info;
  var _LaneService$useGetRu = LaneService.useGetRuleInfo(jcssInfo === null || jcssInfo === void 0 ? void 0 : jcssInfo.id, hasRule),
    _LaneService$useGetRu2 = _LaneService$useGetRu.rules,
    rules = _LaneService$useGetRu2 === void 0 ? [] : _LaneService$useGetRu2,
    workTypeColorMap = _LaneService$useGetRu.workTypeColorMap;
  var rings = (info === null || info === void 0 || (_info$lngLats = info.lngLats) === null || _info$lngLats === void 0 ? void 0 : _info$lngLats.wgs84) || (jcssInfo === null || jcssInfo === void 0 || (_jcssInfo$geometryInf = jcssInfo.geometryInfo) === null || _jcssInfo$geometryInf === void 0 ? void 0 : _jcssInfo$geometryInf.lngLats) || '';
  var mapPolygons = _.isEmpty(rings) ? [] : [{
    rings: rings
  }];
  return hasRule ? /*#__PURE__*/_jsxs(Row, {
    gutter: [16, 16],
    style: {
      height: '100%'
    },
    children: [/*#__PURE__*/_jsx(Col, {
      flex: '400px',
      children: /*#__PURE__*/_jsxs(VmWrapper, {
        title: '基本信息',
        children: [/*#__PURE__*/_jsx(VmInfoCollection, {
          data: baseInfo
        }), /*#__PURE__*/_jsx("div", {
          style: {
            height: 194
          },
          children: /*#__PURE__*/_jsx(VmMap, {
            mapPolygons: mapPolygons,
            mapType: 'wgs84',
            geometryType: 'polyline'
          })
        }), /*#__PURE__*/_jsx(VmTitle, {
          title: '作业规则',
          border: false
        }), /*#__PURE__*/_jsx(Rules, {
          rules: rules,
          workTypeColorMap: workTypeColorMap
        })]
      })
    }), /*#__PURE__*/_jsx(Col, {
      flex: '1',
      style: {
        minWidth: 0
      },
      children: /*#__PURE__*/_jsx(Work, {
        id: id,
        setIframeModalInfo: setIframeModalInfo,
        workTypeColorMap: workTypeColorMap,
        jcssInfo: jcssInfo
      })
    })]
  }) : /*#__PURE__*/_jsx(DefaultBaseInfo, {
    id: id,
    info: jcssInfo,
    data: [],
    geometryType: 'polyline',
    lineLayer: {
      id: 'roadLine',
      rings: rings,
      config: {}
    }
  });
};
export default BaseInfo;