import { getLocale } from "../../../../utils/locales.js";
import useToast$1 from "../../../../hooks/useToast.js";
import SendPaymentLinkModal from "../SendPaymentLinkModal/index.js";
import locales_default from "./locales.js";
import React from "react";
import { Button, Dropdown } from "antd";
import { locales } from "@pisell/utils";
import { Icon } from "@pisell/materials";
import { ClockCircleOutlined, LinkOutlined } from "@ant-design/icons";
import "./index.less";
//#region src/components/checkout/components/AdditionalModule/index.tsx
function AdditionalModule({ orderInfo, customAmount, handleButtonClick, hasOrderNote = false, disabled = false, showCashPayment = false, isFullWidth = false, showMore = true }) {
	locales.init(locales_default, getLocale());
	const sendLinkModal = SendPaymentLinkModal({
		balanceAmount: (orderInfo === null || orderInfo === void 0 ? void 0 : orderInfo.totalAmount) ? `$${orderInfo.totalAmount}` : "$15.1",
		customerEmail: "customer@email.com"
	});
	const moreMenuItems = [{
		key: "send-link",
		label: locales.getText("pisell2.text.send-link"),
		icon: /* @__PURE__ */ React.createElement(LinkOutlined, null)
	}, {
		key: "print-receipt",
		label: locales.getText("pisell2.text.print-receipt"),
		icon: /* @__PURE__ */ React.createElement(Icon, { type: "pisell2-printer" })
	}];
	const Toast = useToast$1();
	return /* @__PURE__ */ React.createElement("div", { className: "additional-module" }, showCashPayment && /* @__PURE__ */ React.createElement("div", { className: "additional-module-title" }, locales.getText("pisell2.text.others")), /* @__PURE__ */ React.createElement("div", { className: "additional-module-buttons-container" }, showCashPayment && !isFullWidth ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", { className: "additional-module-button-row" }, /* @__PURE__ */ React.createElement(Button, {
		className: `additional-module-button-base purple-theme ${hasOrderNote ? "note-button" : ""}`,
		onClick: () => {
			handleButtonClick("order-note");
		},
		icon: /* @__PURE__ */ React.createElement(Icon, {
			type: "pisell2-clipboard-minus",
			className: "additional-module-button-icon"
		}),
		size: "large"
	}, locales.getText("pisell2.text.order-note"), hasOrderNote && /* @__PURE__ */ React.createElement("span", { className: "note-indicator" }, /* @__PURE__ */ React.createElement(Icon, { type: "pisell2-info-circle2" }))), /* @__PURE__ */ React.createElement(Button, {
		className: "additional-module-button-base purple-theme",
		onClick: () => {
			handleButtonClick("split-payment");
		},
		icon: /* @__PURE__ */ React.createElement(Icon, {
			type: "pisell2-coins-01",
			className: "additional-module-button-icon"
		}),
		size: "large"
	}, locales.getText("split.payment"))), /* @__PURE__ */ React.createElement("div", { className: "additional-module-button-row" }, /* @__PURE__ */ React.createElement(Button, {
		className: "additional-module-button-base purple-theme",
		onClick: () => {
			handleButtonClick("manual-discount");
		},
		icon: /* @__PURE__ */ React.createElement(Icon, {
			type: "pisell2-sale-01",
			className: "additional-module-button-icon"
		}),
		size: "large"
	}, locales.getText("pisell2.text.additional-module.order-discount")), /* @__PURE__ */ React.createElement(Button, {
		className: `additional-module-button-base ${disabled ? "disabled-theme" : "orange-theme"}`,
		onClick: () => {
			handleButtonClick("save-pay-later");
		},
		disabled,
		size: "large",
		icon: /* @__PURE__ */ React.createElement(ClockCircleOutlined, { className: "additional-module-button-icon" })
	}, locales.getText("pisell2.text.save-pay-later")), showMore && /* @__PURE__ */ React.createElement(Dropdown, {
		menu: {
			items: moreMenuItems,
			onClick: ({ key }) => {
				console.log("Menu item clicked:", key);
				if (key === "send-link") if (!disabled) handleButtonClick("send-link");
				else Toast.fail(locales.getText("pisell2.text.order-no-payment-cannot-send-link"));
				else if (key === "print-receipt") handleButtonClick("print-receipt");
				else if (key === "split-payment") handleButtonClick("split-payment");
				else if (key === "print-receipt") handleButtonClick("print-receipt");
			}
		},
		trigger: ["click"],
		placement: "bottomLeft",
		overlayStyle: { zIndex: 9999 },
		mouseEnterDelay: .1,
		mouseLeaveDelay: .1,
		onOpenChange: (open) => {
			console.log("Dropdown state changed:", open);
		}
	}, /* @__PURE__ */ React.createElement(Button, {
		size: "large",
		className: "additional-module-button-base more-button",
		icon: /* @__PURE__ */ React.createElement(Icon, {
			type: "pisell2-dots-vertical",
			size: 20
		})
	}))), !showMore && /* @__PURE__ */ React.createElement("div", { className: "additional-module-button-row" }, /* @__PURE__ */ React.createElement(Button, {
		className: "additional-module-button-base purple-theme",
		onClick: () => {
			handleButtonClick("send-link");
		},
		disabled,
		size: "large",
		icon: /* @__PURE__ */ React.createElement(LinkOutlined, null)
	}, locales.getText("pisell2.text.send-link")), /* @__PURE__ */ React.createElement(Button, {
		className: "additional-module-button-base purple-theme",
		onClick: () => {
			handleButtonClick("print-receipt");
		},
		disabled,
		size: "large",
		icon: /* @__PURE__ */ React.createElement(Icon, { type: "pisell2-printer" })
	}, locales.getText("pisell2.text.print-receipt")))) : /* @__PURE__ */ React.createElement("div", { className: "additional-module-button-row" }, /* @__PURE__ */ React.createElement(Button, {
		className: `additional-module-button-base purple-theme ${hasOrderNote ? "note-button" : ""}`,
		onClick: () => {
			handleButtonClick("order-note");
		},
		size: "large",
		icon: /* @__PURE__ */ React.createElement(Icon, {
			type: "pisell2-clipboard-minus",
			className: "additional-module-button-icon"
		})
	}, locales.getText("pisell2.text.order-note"), hasOrderNote && /* @__PURE__ */ React.createElement("span", { className: "note-indicator" }, /* @__PURE__ */ React.createElement(Icon, { type: "pisell2-info-circle2" }))), /* @__PURE__ */ React.createElement(Button, {
		className: "additional-module-button-base purple-theme",
		onClick: () => {
			handleButtonClick("split-payment");
		},
		size: "large",
		icon: /* @__PURE__ */ React.createElement(Icon, {
			type: "pisell2-coins-01",
			className: "additional-module-button-icon"
		})
	}, locales.getText("split.payment")), /* @__PURE__ */ React.createElement(Button, {
		className: "additional-module-button-base purple-theme",
		onClick: () => {
			handleButtonClick("manual-discount");
		},
		icon: /* @__PURE__ */ React.createElement(Icon, {
			type: "pisell2-sale-01",
			className: "additional-module-button-icon"
		}),
		size: "large"
	}, locales.getText("pisell2.text.additional-module.order-discount")), /* @__PURE__ */ React.createElement(Button, {
		className: `additional-module-button-base ${disabled ? "disabled-theme" : "orange-theme"}`,
		onClick: () => {
			handleButtonClick("save-pay-later");
		},
		disabled,
		size: "large",
		icon: /* @__PURE__ */ React.createElement(ClockCircleOutlined, { className: "additional-module-button-icon" })
	}, locales.getText("pisell2.text.save-pay-later")), /* @__PURE__ */ React.createElement(Dropdown, {
		menu: {
			items: moreMenuItems,
			onClick: ({ key }) => {
				console.log("Menu item clicked:", key);
				if (key === "send-link") if (!disabled) handleButtonClick("send-link");
				else Toast.fail(locales.getText("pisell2.text.order-no-payment-cannot-send-link"));
				else if (key === "split-payment") handleButtonClick("split-payment");
				else if (key === "print-receipt") handleButtonClick("print-receipt");
			}
		},
		trigger: ["click"],
		placement: "bottomLeft",
		overlayStyle: { zIndex: 9999 },
		mouseEnterDelay: .1,
		mouseLeaveDelay: .1,
		onOpenChange: (open) => {
			console.log("Dropdown state changed:", open);
		}
	}, /* @__PURE__ */ React.createElement(Button, {
		className: "additional-module-button-base more-button",
		size: "large",
		icon: /* @__PURE__ */ React.createElement(Icon, {
			type: "pisell2-dots-vertical",
			size: 20
		})
	})))), sendLinkModal.content);
}
//#endregion
export { AdditionalModule as default };
