var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/components/PisellCards/components/TextCard/TextCard.tsx
var TextCard_exports = {};
__export(TextCard_exports, {
  default: () => TextCard_default
});
module.exports = __toCommonJS(TextCard_exports);
var import_react = __toESM(require("react"));
var import_classnames = __toESM(require("classnames"));
var import_components = require("./components");
var import_TextCard = require("./TextCard.less");
var TextCard = (props) => {
  const {
    text,
    variant = "text",
    size = "default",
    clickable = true,
    prefixIcon,
    suffixIcon,
    iconConfig,
    tag,
    tagConfig,
    badge,
    prefixSlot,
    suffixSlot,
    textConfig,
    widthMode = "auto",
    width,
    maxWidth = 400,
    onClick,
    render,
    active,
    disabled,
    loading,
    className,
    style,
    children,
    dataSource,
    textAlign,
    ...restProps
  } = props;
  const mergedStyle = (0, import_react.useMemo)(() => {
    let finalStyle = { ...style };
    if (widthMode === "auto") {
      finalStyle.width = "auto";
      finalStyle.maxWidth = maxWidth;
    } else if (widthMode === "fixed" && width) {
      finalStyle.width = width;
    } else if (widthMode === "full") {
      finalStyle.width = "100%";
      finalStyle.minWidth = 28;
    }
    if ((loading == null ? void 0 : loading.value) && (loading == null ? void 0 : loading.style)) {
      finalStyle = { ...finalStyle, ...loading.style };
    } else if ((disabled == null ? void 0 : disabled.value) && (disabled == null ? void 0 : disabled.style)) {
      finalStyle = { ...finalStyle, ...disabled.style };
    } else if ((active == null ? void 0 : active.value) && (active == null ? void 0 : active.style)) {
      finalStyle = { ...finalStyle, ...active.style };
    }
    return finalStyle;
  }, [style, active, disabled, loading, widthMode, width, maxWidth]);
  const mergedClassName = (0, import_react.useMemo)(() => {
    return (0, import_classnames.default)(
      "text-card",
      `text-card--${variant}`,
      `text-card--${size}`,
      className,
      {
        "text-card--active": active == null ? void 0 : active.value,
        "text-card--disabled": disabled == null ? void 0 : disabled.value,
        "text-card--loading": loading == null ? void 0 : loading.value,
        "text-card--clickable": clickable && !(disabled == null ? void 0 : disabled.value) && !(loading == null ? void 0 : loading.value)
      },
      (active == null ? void 0 : active.value) && (active == null ? void 0 : active.className),
      (disabled == null ? void 0 : disabled.value) && (disabled == null ? void 0 : disabled.className),
      (loading == null ? void 0 : loading.value) && (loading == null ? void 0 : loading.className)
    );
  }, [className, variant, size, active, disabled, loading, clickable]);
  const handleClick = (0, import_react.useCallback)(
    (event) => {
      if ((disabled == null ? void 0 : disabled.value) || (loading == null ? void 0 : loading.value) || !clickable) {
        event.preventDefault();
        return;
      }
      if ((active == null ? void 0 : active.onChange) && !active.value) {
        active.onChange(true);
      }
      if (onClick) {
        onClick(event);
      }
    },
    [onClick, active, disabled, loading, clickable]
  );
  const renderExtra = (0, import_react.useCallback)(() => {
    if ((loading == null ? void 0 : loading.value) && (loading == null ? void 0 : loading.extra)) {
      return /* @__PURE__ */ import_react.default.createElement("div", { className: "text-card__extra" }, loading.extra);
    }
    if ((disabled == null ? void 0 : disabled.value) && (disabled == null ? void 0 : disabled.extra)) {
      return /* @__PURE__ */ import_react.default.createElement("div", { className: "text-card__extra" }, disabled.extra);
    }
    if ((active == null ? void 0 : active.value) && (active == null ? void 0 : active.extra)) {
      return /* @__PURE__ */ import_react.default.createElement("div", { className: "text-card__extra" }, active.extra);
    }
    return null;
  }, [active, disabled, loading]);
  (0, import_react.useEffect)(() => {
    document.body.id = "body";
  }, []);
  const renderContent = (0, import_react.useCallback)(() => {
    if (render) {
      return render(props);
    }
    return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, prefixSlot || prefixIcon && /* @__PURE__ */ import_react.default.createElement(
      import_components.IconWrapper,
      {
        icon: prefixIcon,
        config: iconConfig,
        position: "prefix"
      }
    ), /* @__PURE__ */ import_react.default.createElement(import_components.TextContent, { text, textConfig, active }), suffixSlot || /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, tag && /* @__PURE__ */ import_react.default.createElement("div", { className: "text-card__tag", style: tagConfig == null ? void 0 : tagConfig.style }, tag), suffixIcon && /* @__PURE__ */ import_react.default.createElement(
      import_components.IconWrapper,
      {
        icon: suffixIcon,
        config: iconConfig,
        position: "suffix"
      }
    )));
  }, [
    render,
    props,
    prefixSlot,
    prefixIcon,
    iconConfig,
    text,
    textConfig,
    suffixSlot,
    tag,
    tagConfig,
    suffixIcon,
    active
  ]);
  return /* @__PURE__ */ import_react.default.createElement(import_components.BadgeWrapper, { badge }, /* @__PURE__ */ import_react.default.createElement(
    "div",
    {
      className: mergedClassName,
      style: mergedStyle,
      onClick: handleClick,
      "data-active": active == null ? void 0 : active.value,
      "data-disabled": disabled == null ? void 0 : disabled.value,
      "data-loading": loading == null ? void 0 : loading.value,
      role: "button",
      "aria-disabled": disabled == null ? void 0 : disabled.value,
      tabIndex: (disabled == null ? void 0 : disabled.value) ? -1 : 0,
      ...restProps
    },
    renderContent(),
    renderExtra(),
    children
  ));
};
var Provider = (props) => /* @__PURE__ */ import_react.default.createElement(TextCard, { ...props == null ? void 0 : props.props, ...props });
var TextCard_default = Provider;
