const require_runtime = require("../../_virtual/_rolldown/runtime.js");
let react = require("react");
react = require_runtime.__toESM(react);
let antd = require("antd");
let _pisell_materials = require("@pisell/materials");
let classnames = require("classnames");
classnames = require_runtime.__toESM(classnames);
require("./index.less");
//#region src/pro/pisellPriceRadio/index.tsx
const PisellPriceRadio = ({ checked = false, onSelect, value = "", onChange, title = "", currencySymbol = "$", theme = "purple", showMinus = false, disabled = false, placeholder = "Amount" }) => {
	const [showKeyboard, setShowKeyboard] = (0, react.useState)(false);
	(0, react.useEffect)(() => {
		if (checked) setShowKeyboard(true);
		else setShowKeyboard(false);
	}, [checked]);
	const handleInputClick = () => {
		if (!disabled) {
			onSelect === null || onSelect === void 0 || onSelect();
			setShowKeyboard(true);
		}
	};
	const handleRadioClick = () => {
		if (!disabled) onSelect === null || onSelect === void 0 || onSelect();
	};
	const handlePriceChange = (newValue) => {
		onChange === null || onChange === void 0 || onChange(newValue);
	};
	const renderInput = (props) => {
		const displayValue = showMinus && value ? `-${value}` : value;
		return /* @__PURE__ */ react.default.createElement("button", {
			type: "button",
			className: (0, classnames.default)("pisell-price-radio-input-container", {
				[`pisell-price-radio-input-container-${theme}`]: checked,
				"pisell-price-radio-input-container-disabled": disabled
			}),
			onClick: handleInputClick,
			disabled
		}, /* @__PURE__ */ react.default.createElement("span", { className: "pisell-price-radio-currency" }, currencySymbol), /* @__PURE__ */ react.default.createElement("div", { className: "pisell-price-radio-input-content" }, displayValue || /* @__PURE__ */ react.default.createElement("span", { className: "pisell-price-radio-placeholder" }, showMinus ? "-" : "", placeholder)));
	};
	return /* @__PURE__ */ react.default.createElement("div", { className: (0, classnames.default)("pisell-price-radio", {
		[`pisell-price-radio-${theme}`]: checked,
		"pisell-price-radio-checked": checked,
		"pisell-price-radio-disabled": disabled
	}) }, /* @__PURE__ */ react.default.createElement("div", { className: "pisell-price-radio-header" }, /* @__PURE__ */ react.default.createElement(antd.Radio, {
		checked,
		onChange: handleRadioClick,
		disabled,
		className: (0, classnames.default)("pisell-price-radio-button", { [`pisell-price-radio-button-${theme}`]: checked })
	}), /* @__PURE__ */ react.default.createElement("span", { className: "pisell-price-radio-title" }, title)), /* @__PURE__ */ react.default.createElement(_pisell_materials.VirtualKeyboard, {
		value,
		onChange: (e) => handlePriceChange(e.target.value),
		renderInput,
		showDelete: false,
		onValueSelect: (selected) => {
			if (selected && !checked) onSelect === null || onSelect === void 0 || onSelect();
		},
		defaultSelect: checked && showKeyboard,
		placeholder,
		disabled
	}));
};
//#endregion
exports.default = PisellPriceRadio;
