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/productCard/components/Header/index.tsx
var Header_exports = {};
__export(Header_exports, {
  default: () => Header_default
});
module.exports = __toCommonJS(Header_exports);
var import_react = __toESM(require("react"));
var import_classnames = __toESM(require("classnames"));
var import_utils = require("@pisell/utils");
var import_options = __toESM(require("../Packages/components/options"));
var import_DeleteButton = __toESM(require("./DeleteButton"));
var import_EditButton = __toESM(require("./EditButton"));
var import_index = require("./index.less");
var prefix = "pisell-lowcode-";
var Header = (props) => {
  const {
    isShowDelete,
    item,
    isShowImage,
    onDelete,
    disabledEdit,
    onEditProduct,
    isShowEditProduct
  } = props;
  const {
    id,
    options,
    bundle,
    product_option_string,
    image,
    name,
    price,
    symbol,
    disabled,
    relation_products,
    num = 1
  } = item;
  const showPrice = (0, import_react.useMemo)(() => {
    return (bundle == null ? void 0 : bundle.length) > 0 || (options == null ? void 0 : options.length) > 0 || ((relation_products == null ? void 0 : relation_products.length) || 0) > 0;
  }, [bundle, options, relation_products]);
  const headerCenterStyle = (0, import_react.useMemo)(() => {
    return (options == null ? void 0 : options.length) > 0 || product_option_string;
  }, [options, product_option_string]);
  const showDelete = (0, import_react.useMemo)(() => {
    return isShowDelete && !disabledEdit && !disabled;
  }, [isShowDelete, disabledEdit, disabled]);
  const renderImage = () => {
    if (!isShowImage) return null;
    if (image) {
      return /* @__PURE__ */ import_react.default.createElement(
        "img",
        {
          src: import_utils.image.ali(image, 64),
          className: `${prefix}product-header-cover`
        }
      );
    }
    const displayText = name ? name.slice(0, 2) : "";
    return /* @__PURE__ */ import_react.default.createElement("div", { className: `${prefix}product-header-cover-text` }, displayText);
  };
  return /* @__PURE__ */ import_react.default.createElement(
    "div",
    {
      className: (0, import_classnames.default)(
        `${prefix}product-header`,
        headerCenterStyle && `${prefix}product-options-header`
      )
    },
    showDelete ? /* @__PURE__ */ import_react.default.createElement(import_DeleteButton.default, { onDelete }) : null,
    renderImage(),
    id ? /* @__PURE__ */ import_react.default.createElement(
      "div",
      {
        className: (0, import_classnames.default)(`${prefix}product-right-wrap`, {
          [`${prefix}product-right-wrap-stretch`]: isShowEditProduct
        })
      },
      /* @__PURE__ */ import_react.default.createElement("div", { className: `${prefix}product-title` }, /* @__PURE__ */ import_react.default.createElement("span", { style: { paddingRight: showDelete ? "18px" : "0" } }, name), showPrice ? /* @__PURE__ */ import_react.default.createElement("span", { className: `${prefix}product-title-price` }, (0, import_utils.formatAmount)(price, 2, symbol)) : null),
      product_option_string ? /* @__PURE__ */ import_react.default.createElement("span", { className: `${prefix}product-title-variant` }, product_option_string) : null,
      /* @__PURE__ */ import_react.default.createElement(import_options.default, { options, amountSymbol: symbol }),
      isShowEditProduct && !disabledEdit && !disabled ? /* @__PURE__ */ import_react.default.createElement(import_EditButton.default, { onEdit: onEditProduct }) : null
    ) : null
  );
};
var Header_default = Header;
