const require_runtime = require("../../../_virtual/_rolldown/runtime.js");
let dayjs = require("dayjs");
dayjs = require_runtime.__toESM(dayjs);
//#region src/plus/pisellSalesManagement/hooks/perspectiveUtils.ts
const Tag = require("antd").Tag;
const formatAmount = (value, currencySymbol) => {
	const num = Number(value || 0);
	return `${currencySymbol || "$"}${num.toLocaleString(void 0, {
		minimumFractionDigits: 2,
		maximumFractionDigits: 2
	})}`;
};
const getDisplayLines = (items) => {
	return items.filter((item) => item != null && item !== "");
};
const textStyles = { text: {
	fontSize: 12,
	color: "#475467",
	lineHeight: "18px"
} };
const buildDateTime = (date, time) => {
	if (date && time) return `${date} ${time}`;
	return date || time || "";
};
const normalizeList = (value) => {
	if (Array.isArray(value)) return value;
	if (value == null) return [];
	return [value];
};
const parseJson = (value) => {
	if (typeof value !== "string") return value;
	try {
		return JSON.parse(value);
	} catch (_unused) {
		return value;
	}
};
const formatPhone = (value, countryCallingCode) => {
	if (value == null || value === "") return "";
	if (typeof value === "string" || typeof value === "number") {
		const text = String(value).trim();
		if (!text) return "";
		const code = countryCallingCode != null && countryCallingCode !== "" ? String(countryCallingCode).trim() : "";
		if (code && !text.startsWith("+") && !text.startsWith(code)) return `${code.startsWith("+") ? code : `+${code}`} ${text}`;
		return text;
	}
	if (typeof value === "object") {
		const phoneValue = (value === null || value === void 0 ? void 0 : value.phone) || (value === null || value === void 0 ? void 0 : value.number);
		const code = (value === null || value === void 0 ? void 0 : value.country_calling_code) || (value === null || value === void 0 ? void 0 : value.countryCallingCode);
		return formatPhone(phoneValue, code !== null && code !== void 0 ? code : countryCallingCode);
	}
	return "";
};
//#endregion
exports.Tag = Tag;
exports.buildDateTime = buildDateTime;
exports.formatAmount = formatAmount;
exports.formatPhone = formatPhone;
exports.getDisplayLines = getDisplayLines;
exports.normalizeList = normalizeList;
exports.parseJson = parseJson;
exports.textStyles = textStyles;
