import useEngineContext from "../../hooks/useEngineContext.js";
import "dayjs";
//#region src/components/eventBooking/utils.ts
/**
* @title: 获取背景色
* @description:
* @param {string} colors
* @return {*}
* @Author: WangHan
* @Date: 2025-01-11 22:44
*/
const formatBackgroundColors = (colors) => {
	let _colors = Array.from(new Set(colors.map((color) => color === null || color === void 0 ? void 0 : color.toLocaleLowerCase()) || [])).filter((d) => !!d);
	let colorStr = _colors.map((color, index) => {
		return `${color} ${index * 100 / _colors.length}% ${(index + 1) * 100 / _colors.length}%`;
	}).join(", ");
	if (colorStr) return `conic-gradient(${colorStr})`;
	return "";
};
/**
* @title: 格式化日期头部日期显示
* @description:
* @param {string} dateString
* @return {*}
* @Author: WangHan
* @Date: 2025-01-12 11:55
*/
const formatMonthDisplay = (dateString) => {
	var _utils$storage;
	const utils = useEngineContext().appHelper.utils || {};
	const locale = (utils === null || utils === void 0 || (_utils$storage = utils.storage) === null || _utils$storage === void 0 ? void 0 : _utils$storage.get("umi_locale")) || "en-US";
	return (/* @__PURE__ */ new Date(dateString + "-01")).toLocaleString(locale, {
		month: "long",
		year: "numeric"
	});
};
/**
* @title: 资源名称
* @description:
* @param {any} data
* @return {*}
* @Author: WangHan
* @Date: 2025-02-11 13:39
*/
const resourceTitle = (data) => {
	var _data$initData, _form$setting, _context$appHelper;
	const context = useEngineContext();
	const form = data === null || data === void 0 || (_data$initData = data.initData) === null || _data$initData === void 0 || (_data$initData = _data$initData.boardSetting) === null || _data$initData === void 0 || (_data$initData = _data$initData.event_v2_form) === null || _data$initData === void 0 ? void 0 : _data$initData.form;
	const title = (form === null || form === void 0 || (_form$setting = form.setting) === null || _form$setting === void 0 ? void 0 : _form$setting.title) || (form === null || form === void 0 ? void 0 : form.title);
	return (context === null || context === void 0 || (_context$appHelper = context.appHelper) === null || _context$appHelper === void 0 || (_context$appHelper = _context$appHelper.utils) === null || _context$appHelper === void 0 ? void 0 : _context$appHelper.translation)(title);
};
//#endregion
export { formatBackgroundColors, formatMonthDisplay, resourceTitle };
