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/booking/info/service/serviceItem/index.tsx
var serviceItem_exports = {};
__export(serviceItem_exports, {
  default: () => serviceItem_default
});
module.exports = __toCommonJS(serviceItem_exports);
var import_react = __toESM(require("react"));
var import_like = __toESM(require("../like"));
var import_utils = require("../../../utils");
var import_utils2 = require("@pisell/utils");
var import_collapsibleList = __toESM(require("../../../components/collapsibleList"));
var import_utils3 = require("../../../components/collapsibleList/utils");
var import_antd = require("antd");
var import_actions = __toESM(require("../actions"));
var import_index = require("./index.less");
var import_materials = require("@pisell/materials");
var ServiceItem = ({
  d,
  handleEditService,
  state,
  handleLike,
  resourceItem,
  errorMessage,
  handleDeleteService
}) => {
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
  let resourceName = (resourceItem == null ? void 0 : resourceItem.labelText) || d.relation_form_name;
  const isDiscount = (0, import_react.useMemo)(() => {
    var _a2, _b2;
    return Number((_a2 = d._extend) == null ? void 0 : _a2.total) != Number((_b2 = d._extend) == null ? void 0 : _b2.origin_total);
  }, [(_a = d._extend) == null ? void 0 : _a.total, (_b = d._extend) == null ? void 0 : _b.origin_total]);
  return /* @__PURE__ */ import_react.default.createElement(
    "div",
    {
      key: d._id,
      className: "pisell-lowcode__booking-service-item",
      onClick: () => {
        handleEditService(d);
      }
    },
    !state.channelDisabledEdit && /* @__PURE__ */ import_react.default.createElement(
      "div",
      {
        className: "pisell-lowcode__booking-service-item-delete",
        onClick: (e) => {
          e.stopPropagation();
          handleDeleteService(d);
        }
      },
      /* @__PURE__ */ import_react.default.createElement(import_antd.Button, { type: "text", icon: /* @__PURE__ */ import_react.default.createElement(import_materials.Iconfont, { type: "pisell2-trash-01" }) })
    ),
    d.id || d.isCustomItem ? /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__booking-service-item-title" }, d.title) : null,
    d._extend ? /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, state.renderType !== "eventBooking" && /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__booking-service-item-date" }, (0, import_utils.getServiceTime)(d, state.date.value)), /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__booking-service-item-technician" }, d._extend.resource ? /* @__PURE__ */ import_react.default.createElement(
      import_like.default,
      {
        style: { marginRight: 4 },
        status: d._extend.like_status,
        onChange: (e) => {
          handleLike(e, d);
        }
      }
    ) : null, resourceName)) : null,
    (((_d = (_c = d._extend) == null ? void 0 : _c.other) == null ? void 0 : _d.bundle) || []).length ? /* @__PURE__ */ import_react.default.createElement(
      import_collapsibleList.default,
      {
        border: true,
        list: ((_f = (_e = d._extend) == null ? void 0 : _e.other) == null ? void 0 : _f.bundle) || [],
        renderItem: (item) => (0, import_utils3.renderBundles)(item, state.amountSymbol)
      }
    ) : null,
    d.id || d.isCustomItem ? /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__booking-service-item-price-wrap" }, /* @__PURE__ */ import_react.default.createElement("span", { className: "pisell-lowcode__booking-service-item-price" }, (0, import_utils2.formatAmount)((_g = d._extend) == null ? void 0 : _g.total, 2, state.amountSymbol)), isDiscount ? /* @__PURE__ */ import_react.default.createElement("span", { className: "pisell-lowcode__booking-service-item-original-price" }, (0, import_utils2.formatAmount)(d._extend.origin_total, 2, state.amountSymbol)) : null)) : null,
    isDiscount && ((_h = d._extend) == null ? void 0 : _h.discount_reason) ? /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__booking-service-item-discount-reason" }, /* @__PURE__ */ import_react.default.createElement("span", null, import_utils2.locales.getText("pisell2.text.discount-reason"), ":"), " ", (_i = d._extend) == null ? void 0 : _i.discount_reason) : null,
    ((_j = d._extend.relation_details) == null ? void 0 : _j.length) ? /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__booking-service-item-relation-details" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__booking-service-item-title" }, import_utils2.locales.getText("page.booking.text.sales")), d._extend.relation_details.map((item, index) => {
      return /* @__PURE__ */ import_react.default.createElement(
        "div",
        {
          className: "pisell-lowcode__booking-service-item-relation-detail",
          key: item.id
        },
        /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__booking-service-item-relation-detail-title" }, item.product_title),
        /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__booking-service-item-relation-detail-info" }, /* @__PURE__ */ import_react.default.createElement("span", { className: "pisell-lowcode__booking-service-item-relation-detail-info-price" }, (0, import_utils2.formatAmount)(item.payment_price, 2, state.amountSymbol)), /* @__PURE__ */ import_react.default.createElement("span", { className: "pisell-lowcode__booking-service-item-relation-detail-info-unit" }, "x"), /* @__PURE__ */ import_react.default.createElement("span", { className: "pisell-lowcode__booking-service-item-relation-detail-info-quantity" }, item.product_quantity))
      );
    })) : null,
    /* @__PURE__ */ import_react.default.createElement(import_actions.default, { currentService: d }),
    errorMessage ? /* @__PURE__ */ import_react.default.createElement(
      import_antd.Alert,
      {
        message: errorMessage,
        type: "warning",
        showIcon: true,
        className: "pisell-lowcode__booking-service-item-error"
      }
    ) : null
  );
};
var serviceItem_default = ServiceItem;
