import { _objectSpread2 } from "../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js";
import { _objectWithoutProperties } from "../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectWithoutProperties.js";
import { CheckboxGroup, RadioGroup } from "../group/index.js";
import React, { useMemo, useState } from "react";
import { Form } from "antd";
//#region src/components/eftpos/receipt/index.tsx
const _excluded = ["input"], _excluded2 = ["input"];
/**
* @title: 自定义组件设置
* @description: 自定义组件设置
* @param {any} commConfig 当前组件配置
* @param {string} name 上游name(用于嵌套 xxx:{yyy:''})
* @return {*}
* @Author: hongbing.wang
* @Date: 2024-08-20 11:10
*/
const getCommName = (commConfig, name) => {
	commConfig.receipts.__sourceName = commConfig.receipts.name;
	commConfig.receiptList.__sourceName = commConfig.receiptList.name;
	commConfig.receipts.name = name.length > 0 ? [...name, commConfig.receipts.name] : commConfig.receipts.name;
	commConfig.receiptList.name = name.length > 0 ? [...name, commConfig.receiptList.name] : commConfig.receiptList.name;
	return commConfig;
};
/**
* @title: 自定义组件结果设置
* @description: 自定义组件结果设置
* @param {any} commConfig 当前组件配置
* @return {*}
* @Author: hongbing.wang
* @Date: 2024-08-20 11:11
*/
const getCommDefaultVal = (commConfig) => {
	const receipts = commConfig.receipts.input.defaultValue;
	const receiptList = commConfig.receiptList.input.defaultValue;
	console.log("receipts = ", receipts);
	return {
		[commConfig.receipts.__sourceName]: typeof receipts === "undefined" ? true : receipts,
		[commConfig.receiptList.__sourceName]: typeof receiptList === "undefined" ? ["merchant", "customer"] : receiptList
	};
};
var receipt_default = (props) => {
	const { receipts, receiptList } = props;
	const [receiptsInput, receiptsOther] = useMemo(() => {
		const { input } = receipts;
		return [input, _objectWithoutProperties(receipts, _excluded)];
	}, [receipts]);
	const [receiptListInput, receiptListOther] = useMemo(() => {
		const { input } = receiptList;
		return [input, _objectWithoutProperties(receiptList, _excluded2)];
	}, [receipts]);
	const [type, setType] = useState(receiptsInput.defaultValue);
	return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Form.Item, _objectSpread2({ style: { marginBottom: "12px" } }, receiptsOther), /* @__PURE__ */ React.createElement(RadioGroup, _objectSpread2(_objectSpread2({}, receiptsInput), {}, { onChange: (event) => {
		setType(event.target.value);
	} }))), /* @__PURE__ */ React.createElement(Form.Item, _objectSpread2(_objectSpread2({}, receiptListOther), {}, { style: type ? {
		marginLeft: "24px",
		display: "none"
	} : { marginLeft: "24px" } }), /* @__PURE__ */ React.createElement(CheckboxGroup, receiptListInput)));
};
//#endregion
export { receipt_default as default, getCommDefaultVal, getCommName };
