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/scanOrder/components/Footer/index.tsx
var Footer_exports = {};
__export(Footer_exports, {
  default: () => Footer
});
module.exports = __toCommonJS(Footer_exports);
var import_react = __toESM(require("react"));
var import_materials = require("@pisell/materials");
var import_utils = require("@pisell/utils");
var import_Cart = __toESM(require("../Cart"));
var import_shopping_cart = __toESM(require("../../../appointmentBooking/assets/shopping-cart.svg"));
var import_index = require("./index.less");
function Footer(props) {
  const { cartItems, summary, actionText, onAction, disabled = false } = props;
  const [cartOpen, setCartOpen] = (0, import_react.useState)(false);
  const totalAmount = (0, import_react.useMemo)(() => {
    const rawAmount = (summary == null ? void 0 : summary.total_amount) ?? (summary == null ? void 0 : summary.expect_amount) ?? (summary == null ? void 0 : summary.amount) ?? (summary == null ? void 0 : summary.total) ?? (summary == null ? void 0 : summary.totalAmount) ?? (summary == null ? void 0 : summary.payable_amount) ?? 0;
    const parsedAmount = Number(rawAmount);
    if (Number.isNaN(parsedAmount)) return "0.00";
    return parsedAmount.toFixed(2);
  }, [summary]);
  return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-scan-order-footer" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-scan-order-footer-left" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-scan-order-footer-total-label" }, import_utils.locales.getText("pisell2.event.total")), /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-scan-order-footer-total-amount" }, "$", totalAmount)), /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-scan-order-footer-right" }, /* @__PURE__ */ import_react.default.createElement(import_materials.Badge, { count: (cartItems == null ? void 0 : cartItems.length) || 0, id: "scan-order-v2-cart-btn" }, /* @__PURE__ */ import_react.default.createElement(
    import_materials.Button,
    {
      size: "large",
      className: "pisell-scan-order-footer-cart-btn",
      onClick: () => setCartOpen(true)
    },
    /* @__PURE__ */ import_react.default.createElement(import_materials.Image, { src: import_shopping_cart.default, preview: false })
  )), /* @__PURE__ */ import_react.default.createElement(
    import_materials.Button,
    {
      type: "primary",
      size: "large",
      className: `pisell-scan-order-footer-btn${disabled ? " pisell-scan-order-footer-btn-disabled" : ""}`,
      onClick: onAction
    },
    actionText
  ))), /* @__PURE__ */ import_react.default.createElement(
    import_Cart.default,
    {
      open: cartOpen,
      items: cartItems || [],
      summary: summary || {},
      onCancel: () => {
        setCartOpen(false);
      },
      onNext: () => {
        setCartOpen(false);
        onAction();
      }
    }
  ));
}
