import React from 'react';
import { getText } from "../../../locales";

/**
 * HotWords 组件
 * 展示热门搜索
 */
export var HotWords = function HotWords(props) {
  var hotWords = props.hotWords,
    onSelect = props.onSelect,
    render = props.render,
    className = props.className,
    style = props.style;

  // 如果没有热门搜索，不显示
  if (!hotWords || hotWords.length === 0) {
    return null;
  }

  // 使用自定义渲染
  if (render) {
    return /*#__PURE__*/React.createElement(React.Fragment, null, render(hotWords, onSelect));
  }

  /**
   * 处理点击热门搜索
   */
  var handleClick = function handleClick(keyword) {
    onSelect(keyword);
  };
  return /*#__PURE__*/React.createElement("div", {
    className: "pisell-lookup-hotwords ".concat(className || ''),
    style: style
  }, /*#__PURE__*/React.createElement("div", {
    className: "pisell-lookup-hotwords-title"
  }, getText('pisell-lookup-popular-search')), /*#__PURE__*/React.createElement("div", {
    className: "pisell-lookup-hotwords-list"
  }, hotWords.map(function (item, index) {
    return /*#__PURE__*/React.createElement("div", {
      key: "".concat(item, "-").concat(index),
      className: "pisell-lookup-hotwords-item",
      onClick: function onClick() {
        return handleClick(item);
      },
      title: item
    }, item);
  })));
};
HotWords.displayName = 'HotWords';