const require_runtime = require("../../_virtual/_rolldown/runtime.js");
const require_asyncToGenerator = require("../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js");
let react = require("react");
react = require_runtime.__toESM(react);
let antd = require("antd");
let antd_img_crop = require("antd-img-crop");
antd_img_crop = require_runtime.__toESM(antd_img_crop);
//#region src/components/cropPhoto/index.tsx
const CropPhoto = (props) => {
	const { cropShape } = props;
	const [fileList, setFileList] = (0, react.useState)([]);
	const onChange = ({ fileList: newFileList }) => {
		setFileList(newFileList);
	};
	const onPreview = function() {
		var _ref = require_asyncToGenerator._asyncToGenerator(function* (file) {
			let src = file.url;
			if (!src) src = yield new Promise((resolve) => {
				const reader = new FileReader();
				reader.readAsDataURL(file.originFileObj);
				reader.onload = () => resolve(reader.result);
			});
			const image = new Image();
			image.src = src;
			const imgWindow = window.open(src);
			imgWindow === null || imgWindow === void 0 || imgWindow.document.write(image.outerHTML);
		});
		return function onPreview(_x) {
			return _ref.apply(this, arguments);
		};
	}();
	return /* @__PURE__ */ react.default.createElement(antd_img_crop.default, {
		rotationSlider: true,
		aspectSlider: true,
		cropShape
	}, /* @__PURE__ */ react.default.createElement(antd.Upload, {
		action: "https://660d2bd96ddfa2943b33731c.mockapi.io/api/upload",
		listType: "picture-card",
		fileList,
		onChange,
		onPreview
	}, fileList.length < 5 && "+ Upload"));
};
//#endregion
exports.default = CropPhoto;
