import { _objectSpread2 } from "../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js";
import PisellPhoneKeyboard from "../../../../pro/pisellPhoneKeyboard/index.js";
import { getCountries } from "./serve.js";
import React, { useEffect } from "react";
import { Select, Space } from "antd";
import { useRequest } from "ahooks";
//#region src/plus/clinetSearch/Add/PhoneField/index.tsx
const defaultValue = {
	code: "+61",
	phone: ""
};
const PhoneField = ({ value, onChange }) => {
	const codes = useRequest(getCountries, { manual: true });
	useEffect(() => {
		codes.run();
	}, []);
	const _onChange = (key, val) => {
		onChange(_objectSpread2(_objectSpread2(_objectSpread2({}, defaultValue), value), {}, { [key]: val }));
	};
	return /* @__PURE__ */ React.createElement(Space.Compact, { style: { width: "100%" } }, /* @__PURE__ */ React.createElement(Select, {
		options: codes.data || [],
		onChange: (val) => {
			_onChange("code", val);
		},
		size: "large",
		style: { flex: "0 0 100px" },
		loading: codes.loading,
		optionLabelProp: "value",
		value: value === null || value === void 0 ? void 0 : value.code,
		dropdownMatchSelectWidth: false
	}), /* @__PURE__ */ React.createElement(PisellPhoneKeyboard, {
		value: (value === null || value === void 0 ? void 0 : value.phone) || "",
		onChange: (e) => {
			_onChange("phone", e);
		}
	}));
};
//#endregion
export { PhoneField as default };
