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/plus/saleDetail/tmpl/A/index.tsx
var A_exports = {};
__export(A_exports, {
  SaleDetailTemplateA: () => SaleDetailTemplateA
});
module.exports = __toCommonJS(A_exports);
var import_react = __toESM(require("react"));
var import_classnames = __toESM(require("classnames"));
var import_components = require("../../components");
var import_Editable = require("../../components/CartItems/Editable");
var import_DetailActions = require("../../components/DetailActions");
var import_shared = require("../../shared");
var import_index = require("./index.less");
var import_ahooks = require("ahooks");
function SaleDetailTemplateAMain({
  context,
  moduleConfig
}) {
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
  const bookingConfig = (_a = context.booking) == null ? void 0 : _a.getBookingConfig();
  const _showContactFromConfig = (_d = (_c = (_b = bookingConfig == null ? void 0 : bookingConfig.config) == null ? void 0 : _b.cart_settings_tab) == null ? void 0 : _c.display_contact_info) == null ? void 0 : _d.show_contact_info;
  const hiddenModules = (moduleConfig == null ? void 0 : moduleConfig.hidden) || [];
  const showCustomer = !hiddenModules.includes("customer");
  const showContact = !hiddenModules.includes("contact") && !!_showContactFromConfig;
  const showCartItems = !hiddenModules.includes("cartItems");
  const showCartActions = !hiddenModules.includes("cartActions");
  const showPromotionAlert = !hiddenModules.includes("promotionAlert");
  const hasCartItems = (0, import_react.useMemo)(
    () => {
      var _a2, _b2, _c2, _d2;
      return Boolean((_b2 = (_a2 = context.cart) == null ? void 0 : _a2.bookings) == null ? void 0 : _b2.length) || Boolean((_d2 = (_c2 = context.cart) == null ? void 0 : _c2.items) == null ? void 0 : _d2.length);
    },
    [(_f = (_e = context.cart) == null ? void 0 : _e.bookings) == null ? void 0 : _f.length, (_h = (_g = context.cart) == null ? void 0 : _g.items) == null ? void 0 : _h.length]
  );
  const clientContext = (0, import_react.useMemo)(() => ({
    customer: context.customer,
    sales: context.sales
  }), [context.customer, (_i = context.sales) == null ? void 0 : _i.setContactsInfo]);
  const saleQrButtonClick = (0, import_ahooks.useMemoizedFn)(() => {
    context.sales.activateCamera();
  });
  const clientEntryContent = (0, import_react.useMemo)(() => {
    return /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-sale-detail-client-entry" }, /* @__PURE__ */ import_react.default.createElement(import_components.Client, { context: clientContext, isShowAvatar: true }), /* @__PURE__ */ import_react.default.createElement(import_components.SaleQrButton, { onClick: saleQrButtonClick }));
  }, [clientContext]);
  const contactContext = (0, import_react.useMemo)(() => ({
    sales: context.sales
  }), [(_j = context.sales) == null ? void 0 : _j.setContactsInfo]);
  const contactContent = (0, import_react.useMemo)(() => {
    var _a2;
    return /* @__PURE__ */ import_react.default.createElement(
      import_components.Contact,
      {
        dataSource: (_a2 = context.sales.tempOrder) == null ? void 0 : _a2.contacts_info,
        context: contactContext,
        showAction: true,
        showEmpty: true
      }
    );
  }, [(_k = context.sales.tempOrder) == null ? void 0 : _k.contacts_info, contactContext]);
  const promotionAlertContext = (0, import_react.useMemo)(() => ({
    cart: context.cart,
    sales: context.sales
  }), [context.cart, context.sales]);
  const cartActionsContext = (0, import_react.useMemo)(() => ({
    cart: context.cart,
    sales: context.sales,
    summary: context.summary
  }), [context.cart, context.sales, context.summary]);
  const cartItemsContext = (0, import_react.useMemo)(() => ({
    cart: context.cart,
    sales: context.sales,
    booking: context.booking
  }), [context.cart, context.sales, context.booking]);
  const CartItemsInteractionPolicy = (0, import_react.useMemo)(() => ({
    cardAction: "edit",
    disabledEdit: true,
    isShowDelete: true,
    isShowRightActions: true
  }), []);
  const cartItemContent = (0, import_react.useMemo)(() => {
    var _a2;
    return /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-sale-detail-cart-scroll-panel" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-sale-detail-scroll-content" }, /* @__PURE__ */ import_react.default.createElement(
      import_Editable.CartItems,
      {
        context: cartItemsContext,
        layout: (_a2 = moduleConfig == null ? void 0 : moduleConfig.cartItems) == null ? void 0 : _a2.layout,
        interactionPolicy: CartItemsInteractionPolicy,
        showEmpty: true
      }
    )), showPromotionAlert ? /* @__PURE__ */ import_react.default.createElement(
      import_components.PromotionAlert,
      {
        context: promotionAlertContext
      }
    ) : null);
  }, [cartItemsContext, (_l = moduleConfig == null ? void 0 : moduleConfig.cartItems) == null ? void 0 : _l.layout, CartItemsInteractionPolicy, promotionAlertContext]);
  const cartActionsContent = (0, import_react.useMemo)(() => {
    return /* @__PURE__ */ import_react.default.createElement(
      import_components.CartActions,
      {
        context: cartActionsContext,
        hasCartItems
      }
    );
  }, [cartActionsContext, hasCartItems]);
  return /* @__PURE__ */ import_react.default.createElement("main", { className: "pisell-sale-detail-main" }, showCustomer ? clientEntryContent : null, showContact ? contactContent : null, showCartItems ? cartItemContent : null, showCartActions ? cartActionsContent : null);
}
function SaleDetailTemplateAFooter({
  amountDetailsDefaultExpanded,
  context,
  onOrderComplete,
  orderActions = import_DetailActions.TEMPLATE_A_ACTIONS,
  showAmountDetails,
  showOrderActions
}) {
  const hasOrderActions = showOrderActions && orderActions.length > 0;
  const hasFloorResourceAction = orderActions.some(
    (action) => action.key === "select-floor-resource"
  );
  if (!showAmountDetails && !hasOrderActions) {
    return null;
  }
  return /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-sale-detail-footer" }, showAmountDetails ? /* @__PURE__ */ import_react.default.createElement(
    import_components.AmountDetails,
    {
      defaultExpanded: amountDetailsDefaultExpanded,
      context: {
        sales: context.sales,
        summary: context.summary
      }
    }
  ) : null, hasOrderActions ? /* @__PURE__ */ import_react.default.createElement(
    "div",
    {
      className: (0, import_classnames.default)(
        "pisell-sale-detail-button-actions",
        "pisell-sale-detail-button-actions--template-a",
        {
          "pisell-sale-detail-button-actions--with-floor-resource": hasFloorResourceAction
        }
      )
    },
    /* @__PURE__ */ import_react.default.createElement(
      import_DetailActions.DetailActions,
      {
        actions: orderActions,
        onOrderComplete
      }
    )
  ) : null);
}
function SaleDetailTemplateA({
  context,
  mobilePresentation,
  moduleConfig,
  renderType,
  variant
}) {
  var _a;
  const hiddenModules = (moduleConfig == null ? void 0 : moduleConfig.hidden) || [];
  const showAmountDetails = !hiddenModules.includes("amountDetails");
  const showOrderActions = !hiddenModules.includes("orderActions");
  const isMobileBottomSheet = variant === "phone" && renderType === "current" && mobilePresentation === "bottomSheet";
  const bodyContent = /* @__PURE__ */ import_react.default.createElement("main", { className: "pisell-sale-detail-tmpl-body" }, /* @__PURE__ */ import_react.default.createElement("section", { className: "pisell-sale-detail-tmpl-content" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-sale-detail-inline-layout" }, /* @__PURE__ */ import_react.default.createElement(
    SaleDetailTemplateAMain,
    {
      context,
      moduleConfig
    }
  ))));
  const footerContent = /* @__PURE__ */ import_react.default.createElement(
    SaleDetailTemplateAFooter,
    {
      context: {
        sales: context.sales,
        summary: context.summary
      },
      onOrderComplete: context.onOrderComplete,
      orderActions: moduleConfig == null ? void 0 : moduleConfig.orderActions,
      showAmountDetails,
      showOrderActions,
      amountDetailsDefaultExpanded: (_a = moduleConfig == null ? void 0 : moduleConfig.amountDetails) == null ? void 0 : _a.defaultExpanded
    }
  );
  if (isMobileBottomSheet) {
    return /* @__PURE__ */ import_react.default.createElement(
      import_shared.MobileSheetFrame,
      {
        className: (0, import_classnames.default)(
          "pisell-sale-detail-tmpl-a",
          "pisell-sale-detail-tmpl-a--mobile-sheet"
        ),
        footer: footerContent
      },
      bodyContent
    );
  }
  return /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-sale-detail-tmpl-a" }, /* @__PURE__ */ import_react.default.createElement("main", { className: "pisell-sale-detail-tmpl-body" }, /* @__PURE__ */ import_react.default.createElement("section", { className: "pisell-sale-detail-tmpl-content" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-sale-detail-inline-layout" }, /* @__PURE__ */ import_react.default.createElement(
    SaleDetailTemplateAMain,
    {
      context,
      moduleConfig
    }
  ), footerContent))));
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  SaleDetailTemplateA
});
