const require_objectSpread2 = require("../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
//#region src/plus/saasDevice/devicePlanning/model/types.ts
const EMPTY_I18N = {
	original: "",
	en: "",
	"zh-CN": "",
	"zh-HK": "",
	ja: "",
	pt: ""
};
const DEVICE_KIND_OPTIONS = [
	"smart",
	"dumb",
	"integrated"
];
/** 统一把后端多语言值转成可编辑表单需要的语言字典。 */
const toLangDict = (val) => {
	if (!val) return require_objectSpread2._objectSpread2({}, EMPTY_I18N);
	if (typeof val === "string") return require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, EMPTY_I18N), {}, {
		original: val,
		en: val
	});
	return require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, EMPTY_I18N), val);
};
/** 校验 BaseTranslation 字段是否至少填写 original 或任一语言值。 */
const validateI18nRequired = (message) => (_rule, value) => {
	if (!value) return Promise.reject(new Error(message));
	if (typeof value === "string") return value.trim() ? Promise.resolve() : Promise.reject(new Error(message));
	const filled = Object.entries(value).some(([key, val]) => key !== "original" && typeof val === "string" && val.trim() !== "");
	const original = typeof (value === null || value === void 0 ? void 0 : value.original) === "string" && value.original.trim() !== "";
	return filled || original ? Promise.resolve() : Promise.reject(new Error(message));
};
//#endregion
exports.DEVICE_KIND_OPTIONS = DEVICE_KIND_OPTIONS;
exports.EMPTY_I18N = EMPTY_I18N;
exports.toLangDict = toLangDict;
exports.validateI18nRequired = validateI18nRequired;
