import "choerodon-ui/lib/spin/style";
import _Spin from "@hzero-front-ui/c7n-ui/lib/Spin";
import React from 'react';
import { FormattedMessage } from 'react-intl';
import { observer } from 'mobx-react-lite';
import map from 'lodash/map';
import ResourceTitle from "../../components/resource-title";
import { useResourceStore } from "../../../stores";
import { useMainStore } from "../../stores";
import { useSecretDetailStore } from "./stores";
import Modals from "./modals";
import "./index.less";
var Content = observer(function () {
  var _useResourceStore = useResourceStore(),
      prefixCls = _useResourceStore.prefixCls,
      intlPrefix = _useResourceStore.intlPrefix;

  var _useSecretDetailStore = useSecretDetailStore(),
      detailDs = _useSecretDetailStore.detailDs;

  var _useMainStore = useMainStore(),
      childrenStore = _useMainStore.childrenStore;

  childrenStore.setDetailDs(detailDs);

  function renderSecret(value, key) {
    return /*#__PURE__*/React.createElement("div", {
      className: "secret-detail-section"
    }, /*#__PURE__*/React.createElement("div", {
      className: "secret-detail-section-title"
    }, /*#__PURE__*/React.createElement("span", null, key)), /*#__PURE__*/React.createElement("div", {
      className: "secret-detail-section-content"
    }, /*#__PURE__*/React.createElement("span", null, value)));
  }

  function getContent() {
    var record = detailDs.current;
    return record ? map(record.get('value'), renderSecret) : '暂无数据';
  }

  return /*#__PURE__*/React.createElement("div", {
    className: "".concat(prefixCls, "-secret-detail")
  }, /*#__PURE__*/React.createElement(ResourceTitle, {
    record: detailDs.current,
    iconType: "vpn_key",
    statusKey: "commandStatus"
  }), /*#__PURE__*/React.createElement("div", {
    className: "".concat(prefixCls, "-detail-content-section-title")
  }, /*#__PURE__*/React.createElement(FormattedMessage, {
    id: "".concat(intlPrefix, ".key.value")
  })), /*#__PURE__*/React.createElement(_Spin, {
    spinning: detailDs.status === 'loading'
  }, getContent()), /*#__PURE__*/React.createElement(Modals, null));
});
export default Content;