const require_runtime = require("../../../_virtual/_rolldown/runtime.js");
const require_objectSpread2 = require("../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
const require_phoneFormatter = require("../utils/phoneFormatter.js");
let react = require("react");
react = require_runtime.__toESM(react);
let antd = require("antd");
let _ant_design_icons = require("@ant-design/icons");
//#region src/components/pisellPhone/components/ReadOnlyView.tsx
/**
* PisellPhone 只读态视图组件
* 
* 负责渲染只读态的电话号码展示和拨号功能
* 
* 功能：
* - 格式化或脱敏显示
* - 显示国旗图标（可选）
* - 移动端可点击拨号（tel: 协议）
* - 拨号图标（可选）
* 
* @param props 组件 Props
*/
const ReadOnlyView = (props) => {
	var _props$fontSize, _props$fontWeight;
	const isMobile = /iPhone|iPad|iPod|Android/i.test(navigator.userAgent);
	const countryCode = props.countryCode || "+86";
	let displayValue;
	if (props.enableMasking) if (props.maskPattern === "custom" && props.customMask) displayValue = props.customMask(props.value || "");
	else displayValue = require_phoneFormatter.maskPhone(props.value || "", props.maskPattern);
	else displayValue = require_phoneFormatter.formatPhone(props.value || "", countryCode);
	const handleDial = () => {
		if (props.enableDial !== false && isMobile) {
			var _props$onDial;
			const fullNumber = countryCode + (props.value || "").replace(/\D/g, "");
			(_props$onDial = props.onDial) === null || _props$onDial === void 0 || _props$onDial.call(props, fullNumber);
			window.location.href = `tel:${fullNumber}`;
		}
	};
	const canDial = props.enableDial !== false && isMobile;
	const textColor = canDial ? "#7F56DA" : props.color || "#101828";
	const textFontSize = (_props$fontSize = props.fontSize) !== null && _props$fontSize !== void 0 ? _props$fontSize : 16;
	const textFontWeight = (_props$fontWeight = props.fontWeight) !== null && _props$fontWeight !== void 0 ? _props$fontWeight : 500;
	return /* @__PURE__ */ react.default.createElement("div", { className: `pisell-phone-read ${props.className || ""}` }, /* @__PURE__ */ react.default.createElement(antd.Space, { size: "small" }, props.showFlag !== false && /* @__PURE__ */ react.default.createElement("span", {
		className: "pisell-phone-country-code",
		style: {
			fontSize: textFontSize,
			fontWeight: textFontWeight,
			color: textColor
		}
	}, countryCode), /* @__PURE__ */ react.default.createElement(antd.Typography.Text, {
		className: canDial ? "pisell-phone-clickable" : "",
		onClick: canDial ? handleDial : void 0,
		style: require_objectSpread2._objectSpread2({
			fontSize: textFontSize,
			fontWeight: textFontWeight,
			color: textColor,
			cursor: canDial ? "pointer" : "default",
			textDecoration: canDial ? "underline" : "none"
		}, props.style)
	}, displayValue), props.showDialIcon && canDial && /* @__PURE__ */ react.default.createElement(antd.Button, {
		type: "link",
		size: "small",
		icon: /* @__PURE__ */ react.default.createElement(_ant_design_icons.PhoneOutlined, null),
		onClick: handleDial
	})));
};
//#endregion
exports.default = ReadOnlyView;
