import "antd/es/typography/style";
import _Typography from "antd/es/typography";
import React from 'react';
import { jsx as _jsx } from "react/jsx-runtime";
const isNeedTranText = item => {
  var _item$valueType;
  if (item !== null && item !== void 0 && (_item$valueType = item.valueType) !== null && _item$valueType !== void 0 && _item$valueType.toString().startsWith('date')) {
    return true;
  }
  if ((item === null || item === void 0 ? void 0 : item.valueType) === 'select' || item !== null && item !== void 0 && item.valueEnum) {
    return true;
  }
  return false;
};

/**
 * 生成 Copyable 或 Ellipsis 的 dom
 *
 * @param dom
 * @param item
 * @param text
 */
export const genCopyable = (dom, item, text) => {
  if (item.copyable || item.ellipsis) {
    const copyable = item.copyable && text ? {
      text,
      tooltips: ['', '']
    } : undefined;

    /** 有些 valueType 需要设置copy的为string */
    const needTranText = isNeedTranText(item);
    const ellipsis = item.ellipsis && text ? {
      tooltip: needTranText ? /*#__PURE__*/_jsx("div", {
        className: "pro-table-tooltip-text",
        children: dom
      }) : text
    } : false;
    return /*#__PURE__*/_jsx(_Typography.Text, {
      style: {
        width: '100%',
        margin: 0,
        padding: 0
      },
      title: "",
      copyable: copyable,
      ellipsis: ellipsis,
      children: dom
    });
  }
  return dom;
};