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/cartSkuCard/index.tsx
var cartSkuCard_exports = {};
__export(cartSkuCard_exports, {
  PREFIX: () => PREFIX,
  default: () => cartSkuCard_default
});
module.exports = __toCommonJS(cartSkuCard_exports);
var import_react = __toESM(require("react"));
var import_classnames = __toESM(require("classnames"));
var import_utils = require("@pisell/utils");
var import_locales = __toESM(require("./locales"));
var import_basicInfo = __toESM(require("./components/basicInfo"));
var import_discountReason = __toESM(require("./components/discountReason"));
var import_timeRange = __toESM(require("./components/timeRange"));
var import_resources = __toESM(require("./components/resources"));
var import_packages = __toESM(require("./components/packages"));
var import_sales = __toESM(require("./components/sales"));
var import_swipeAction = require("./components/swipeAction");
var import_Note = __toESM(require("./components/Note"));
var import_AmountFooter = __toESM(require("./components/AmountFooter"));
var import_MultiDay = __toESM(require("./components/MultiDay"));
var import_index = require("./index.less");
var import_iconfont = __toESM(require("../../iconfont"));
var import_useEngineContext = __toESM(require("../../../hooks/useEngineContext"));
var import_Action = __toESM(require("../components/Action"));
var import_status = require("../status");
var PREFIX = "pisell-cart-sku-card";
var CartSkuCard = (props) => {
  var _a, _b;
  const {
    dataSource = import_status.defaultValue.dataSource,
    isShowImage = import_status.defaultValue.isShowImage,
    isShowHolder = import_status.defaultValue.isShowHolder,
    isShowNote = import_status.defaultValue.isShowNote,
    isShowDelete = import_status.defaultValue.isShowDelete,
    isShowPackageNote = import_status.defaultValue.isShowPackageNote,
    isShowEditProduct = import_status.defaultValue.isShowEditProduct,
    onEditProduct,
    onAction,
    onDelete,
    onNote,
    onLike,
    onCard,
    onChangeResource,
    onChangeHolder,
    type,
    rightActions = [],
    escapeDom,
    ...other
  } = props;
  const useOpenNoteRef = (0, import_react.useRef)();
  const context = (0, import_useEngineContext.default)();
  import_utils.locales.init(
    import_locales.default,
    ((_b = (_a = context.appHelper.utils) == null ? void 0 : _a.storage) == null ? void 0 : _b.get("umi_locale")) || "en"
  );
  console.log("prodcut props", props);
  const { isShowAction, actionText } = dataSource;
  const _rightActions = (0, import_react.useMemo)(() => {
    const deleteAction = {
      key: "delete",
      text: /* @__PURE__ */ import_react.default.createElement(
        "div",
        {
          style: {
            display: "flex",
            justifyContent: "center",
            alignItems: "center",
            color: "white",
            cursor: "pointer",
            padding: "10px 0px"
          }
        },
        /* @__PURE__ */ import_react.default.createElement(
          import_iconfont.default,
          {
            type: "pisell2-trash-01",
            style: { fontSize: 20, marginRight: 4 }
          }
        ),
        /* @__PURE__ */ import_react.default.createElement("span", { style: { fontSize: 12, fontWeight: 500 } }, import_utils.locales.getText("pisell2.cart.sku-card.actions.delete"))
      ),
      color: "danger",
      onClick: (e) => {
        e.preventDefault();
        e.stopPropagation();
        onDelete == null ? void 0 : onDelete(dataSource);
      }
    };
    const actions = [...rightActions];
    if (isShowDelete) {
      actions.unshift(deleteAction);
    }
    return actions;
  }, [dataSource, onDelete, isShowDelete, rightActions]);
  const hideDivider = (0, import_react.useMemo)(() => {
    return false;
  }, [dataSource]);
  const renderA2 = () => {
    return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement(
      import_basicInfo.default,
      {
        isShowImage,
        dataSource,
        isMainProduct: true
      }
    ), /* @__PURE__ */ import_react.default.createElement(import_discountReason.default, { dataSource }), isShowNote ? /* @__PURE__ */ import_react.default.createElement(
      import_Note.default,
      {
        ...other,
        item: dataSource,
        openNote: () => {
          useOpenNoteRef.current.open({
            item: dataSource
          });
        }
      }
    ) : null);
  };
  const renderA5 = () => {
    var _a2, _b2;
    return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, isShowDelete ? /* @__PURE__ */ import_react.default.createElement(
      "div",
      {
        className: `${PREFIX}__delete-btn`,
        onClick: (e) => {
          e.preventDefault();
          e.stopPropagation();
          onDelete == null ? void 0 : onDelete(dataSource);
        }
      },
      /* @__PURE__ */ import_react.default.createElement(import_iconfont.default, { type: "pisell2-trash-01" })
    ) : null, /* @__PURE__ */ import_react.default.createElement(
      import_basicInfo.default,
      {
        isShowImage,
        dataSource,
        isMainProduct: true,
        type
      }
    ), /* @__PURE__ */ import_react.default.createElement(import_timeRange.default, { dataSource }), /* @__PURE__ */ import_react.default.createElement(import_resources.default, { dataSource }), /* @__PURE__ */ import_react.default.createElement(import_packages.default, { dataSource, isShowImage }), /* @__PURE__ */ import_react.default.createElement(
      import_sales.default,
      {
        dataSource,
        hideDivider: !!((_a2 = dataSource == null ? void 0 : dataSource.bundle) == null ? void 0 : _a2.length),
        isShowImage
      }
    ), ((_b2 = dataSource.items) == null ? void 0 : _b2.length) ? /* @__PURE__ */ import_react.default.createElement(import_MultiDay.default, { dataSource, hideDivider }) : /* @__PURE__ */ import_react.default.createElement(
      import_AmountFooter.default,
      {
        item: dataSource,
        hideDivider,
        type: "total"
      }
    ), isShowNote ? /* @__PURE__ */ import_react.default.createElement(
      import_Note.default,
      {
        ...other,
        item: dataSource,
        openNote: () => {
          useOpenNoteRef.current.open({
            item: dataSource
          });
        }
      }
    ) : null, isShowAction && actionText ? /* @__PURE__ */ import_react.default.createElement(import_Action.default, { item: dataSource, onAction: () => onAction == null ? void 0 : onAction(dataSource) }) : null);
  };
  const renderContent = () => {
    if (type === "a5") {
      return renderA5();
    }
    return renderA2();
  };
  return /* @__PURE__ */ import_react.default.createElement(
    import_swipeAction.SwipeAction,
    {
      closeOnAction: false,
      className: (0, import_classnames.default)(`${PREFIX}-wrapper`),
      rightActions: _rightActions,
      escapeDom
    },
    /* @__PURE__ */ import_react.default.createElement(
      "div",
      {
        className: (0, import_classnames.default)(PREFIX, `${PREFIX}--${type}`),
        onClick: (e) => {
          e.preventDefault();
          e.stopPropagation();
          onCard == null ? void 0 : onCard(dataSource);
        }
      },
      renderContent()
    )
  );
};
var cartSkuCard_default = CartSkuCard;
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  PREFIX
});
