var _excluded = ["className", "style", "title", "engine", "description", "image", "imageStyle", "githubUrl", "showGithubStars", "buttons", "news"];
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
import cx from 'classnames';
import { useLocale } from 'dumi/dist/client/theme-api';
import gh from 'parse-github-url';
import React, { useEffect, useState } from 'react';
import GitHubButton from 'react-github-button';
import { News } from "./News";
import { ic } from "../hooks";
import styles from "./index.module.less";
import { HomeDialog } from "../../components/AI/HomeDialog";
import { getBaseSiteDataUrl } from "../../utils/env";
/**
 * Index.技术栈的描述区域！
 * 各自配置
 */
export var Detail = function Detail(_ref) {
  var className = _ref.className,
    style = _ref.style,
    title = _ref.title,
    engine = _ref.engine,
    description = _ref.description,
    image = _ref.image,
    imageStyle = _ref.imageStyle,
    githubUrl = _ref.githubUrl,
    _ref$showGithubStars = _ref.showGithubStars,
    showGithubStars = _ref$showGithubStars === void 0 ? true : _ref$showGithubStars,
    _ref$buttons = _ref.buttons,
    buttons = _ref$buttons === void 0 ? [] : _ref$buttons,
    news = _ref.news,
    v = _objectWithoutProperties(_ref, _excluded);
  var _useState = useState([]),
    _useState2 = _slicedToArray(_useState, 2),
    remoteNews = _useState2[0],
    setRemoteNews = _useState2[1];
  var lang = useLocale().id;
  useEffect(function () {
    fetch("".concat(getBaseSiteDataUrl(), "/antv/banner-messages.json") // 生产环境
    // 'https://site-data-pre.alipay.com/antv/banner-messages.json', // 预发测试
    ).then(function (res) {
      return res.json();
    }).then(function (data) {
      setRemoteNews(data);
    }).catch(function (e) {
      setRemoteNews([]);
    });
  }, []);
  var githubObj = gh(githubUrl);
  var showGitHubStarsButton = showGithubStars && githubObj && githubObj.owner && githubObj.name;
  var engineText = ic(engine);
  return /*#__PURE__*/React.createElement("section", {
    className: cx(styles.wrapper, className),
    style: style
  }, /*#__PURE__*/React.createElement("div", {
    className: styles.content
  }, /*#__PURE__*/React.createElement("div", {
    className: styles.text
  }, /*#__PURE__*/React.createElement("div", {
    className: styles.titleButtons
  }, /*#__PURE__*/React.createElement("div", {
    className: cx(styles.title, 'detail-title')
  }, /*#__PURE__*/React.createElement("span", {
    className: cx(styles.engine, 'detail-engine')
  }, engineText), ic(title).replace(engineText, '')), /*#__PURE__*/React.createElement("div", {
    className: cx(styles.buttons, 'detail-buttons')
  }, showGitHubStarsButton && /*#__PURE__*/React.createElement("div", {
    key: "github",
    className: styles.githubWrapper
  }, /*#__PURE__*/React.createElement(GitHubButton, {
    type: "stargazers",
    size: "large",
    namespace: githubObj.owner,
    repo: githubObj.name
  }))))), /*#__PURE__*/React.createElement(HomeDialog, {
    className: styles.homeDialog
  }), /*#__PURE__*/React.createElement("div", {
    className: cx(styles.news, 'news')
  }, (news || remoteNews).slice(0, 3).map(function (n, i) {
    return /*#__PURE__*/React.createElement(News, _extends({
      key: i,
      index: i
    }, n));
  })), /*#__PURE__*/React.createElement("div", {
    className: cx(styles.teaser, 'teaser')
  }, /*#__PURE__*/React.createElement("div", {
    className: cx(styles.teaserimg, 'teaser-img')
  }, /*#__PURE__*/React.createElement("img", {
    className: styles.teaserImage,
    width: "100%",
    style: imageStyle,
    src: image
  }))), /*#__PURE__*/React.createElement("img", {
    className: styles.backLeftBottom,
    src: "https://gw.alipayobjects.com/zos/basement_prod/441d5eaf-e623-47cd-b9b9-2a581d9ce1e3.svg",
    alt: "back"
  })));
};