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/GraphicTextCard/GraphicTextCard.tsx
var GraphicTextCard_exports = {};
__export(GraphicTextCard_exports, {
  default: () => GraphicTextCard_default
});
module.exports = __toCommonJS(GraphicTextCard_exports);
var import_react = __toESM(require("react"));
var import_components = require("./components");
var import_hooks = require("./hooks");
var import_utils = require("./utils");
var import_GraphicTextCard = require("./GraphicTextCard.less");
var GraphicTextCard = (props) => {
  const {
    text,
    variant = "vertical-image",
    size = "default",
    image,
    icon,
    graphicConfig = {},
    graphicSlot,
    badge,
    prefixSlot,
    suffixSlot,
    textConfig,
    active,
    disabled,
    loading,
    children,
    render,
    dataSource,
    ...restProps
  } = props;
  const { mergedStyle, mergedClassName } = (0, import_hooks.useGraphicTextCardStyle)(props);
  const handleClick = (0, import_hooks.useGraphicTextCardClick)(props);
  (0, import_react.useEffect)(() => {
    document.body.id = "body";
  }, []);
  const graphicSize = (0, import_react.useMemo)(() => {
    const defaultSize = (0, import_utils.getDefaultGraphicSize)(variant, size);
    return {
      width: graphicConfig.width ?? defaultSize.width,
      height: graphicConfig.height ?? defaultSize.height
    };
  }, [variant, size, graphicConfig.width, graphicConfig.height]);
  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: "graphic-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: "graphic-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: "graphic-text-card__extra" }, active.extra);
    }
    return null;
  }, [active, disabled, loading]);
  const renderContent = (0, import_react.useCallback)(() => {
    if (render) {
      return render(props);
    }
    console.log("graphicSize.width", graphicSize.width);
    return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, prefixSlot, graphicSlot || /* @__PURE__ */ import_react.default.createElement(
      import_components.GraphicArea,
      {
        image,
        icon,
        config: {
          width: graphicSize.width,
          height: graphicSize.height,
          ...graphicConfig
        }
      }
    ), /* @__PURE__ */ import_react.default.createElement(import_components.TextContent, { text, textConfig, active }), suffixSlot);
  }, [
    render,
    props,
    prefixSlot,
    graphicSlot,
    image,
    icon,
    graphicConfig,
    graphicSize,
    text,
    textConfig,
    suffixSlot,
    active
  ]);
  return /* @__PURE__ */ import_react.default.createElement(import_components.BadgeWrapper, { badge }, /* @__PURE__ */ import_react.default.createElement(
    "div",
    {
      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,
      className: mergedClassName,
      style: mergedStyle
    },
    renderContent(),
    renderExtra(),
    children
  ));
};
var Provider = (props) => /* @__PURE__ */ import_react.default.createElement(GraphicTextCard, { ...props == null ? void 0 : props.props, ...props });
var GraphicTextCard_default = Provider;
