const require_runtime = require("../../_virtual/_rolldown/runtime.js");
const require_objectSpread2 = require("../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
const require_objectWithoutProperties = require("../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectWithoutProperties.js");
const require_useEngineContext = require("../../hooks/useEngineContext.js");
const require_index = require("../config-provider/index.js");
const require_VariablesProvider = require("../dataSourceComponents/provider/variables/VariablesProvider.js");
const require_index$1 = require("../pisell-config-provider/index.js");
const require_tokens = require("../../theme/tokens.js");
let react = require("react");
react = require_runtime.__toESM(react);
let antd = require("antd");
let antd_es_locale_zh_CN = require("antd/es/locale/zh_CN");
antd_es_locale_zh_CN = require_runtime.__toESM(antd_es_locale_zh_CN);
let _pisell_date_picker = require("@pisell/date-picker");
let _pisell_date_picker_es_AdapterDayjs = require("@pisell/date-picker/es/AdapterDayjs");
let antd_es_locale_en_US = require("antd/es/locale/en_US");
antd_es_locale_en_US = require_runtime.__toESM(antd_es_locale_en_US);
let antd_es_locale_zh_TW = require("antd/es/locale/zh_TW");
antd_es_locale_zh_TW = require_runtime.__toESM(antd_es_locale_zh_TW);
let antd_es_locale_zh_HK = require("antd/es/locale/zh_HK");
antd_es_locale_zh_HK = require_runtime.__toESM(antd_es_locale_zh_HK);
let antd_es_locale_ja_JP = require("antd/es/locale/ja_JP");
antd_es_locale_ja_JP = require_runtime.__toESM(antd_es_locale_ja_JP);
let antd_es_locale_pt_PT = require("antd/es/locale/pt_PT");
antd_es_locale_pt_PT = require_runtime.__toESM(antd_es_locale_pt_PT);
//#region src/components/page/index.tsx
const _excluded = [
	"children",
	"style",
	"className",
	"locale",
	"variablesConfig",
	"isRenderPisellConfigProvider"
];
const localMap = {
	"zh-TW": antd_es_locale_zh_TW.default,
	"zh-CN": antd_es_locale_zh_CN.default,
	"zh-HK": antd_es_locale_zh_HK.default,
	"en-US": antd_es_locale_en_US.default,
	en: antd_es_locale_en_US.default,
	"ja": antd_es_locale_ja_JP.default,
	"pt": antd_es_locale_pt_PT.default
};
const localeDateMap = {
	"en-US": { adapterLocale: "en" },
	en: { adapterLocale: "en" },
	"zh-TW": { adapterLocale: "zh-tw" },
	"zh-HK": { adapterLocale: "zh-tw" },
	"zh-CN": { adapterLocale: "zh-cn" },
	"ja": { adapterLocale: "ja" },
	"pt": { adapterLocale: "pt" }
};
const Page = (props) => {
	var _context$appHelper, _context$engine, _localeDateMap, _context$engine2;
	const { children, style, className, locale: propsLocale, variablesConfig, isRenderPisellConfigProvider = true } = props, others = require_objectWithoutProperties._objectWithoutProperties(props, _excluded);
	const context = require_useEngineContext.default();
	const { platform, themeColor } = ((_context$appHelper = context.appHelper) === null || _context$appHelper === void 0 ? void 0 : _context$appHelper.constants) || {};
	const locale = propsLocale || (context === null || context === void 0 || (_context$engine = context.engine) === null || _context$engine === void 0 || (_context$engine = _context$engine.props) === null || _context$engine === void 0 ? void 0 : _context$engine.locale) || "en";
	const theme = (0, react.useMemo)(() => {
		if (props === null || props === void 0 ? void 0 : props.theme) {
			var _props$theme;
			return require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, props.theme), {}, { token: require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, props.theme.token), {}, { colorPrimary: (props === null || props === void 0 || (_props$theme = props.theme) === null || _props$theme === void 0 || (_props$theme = _props$theme.token) === null || _props$theme === void 0 ? void 0 : _props$theme.colorPrimary) || themeColor || "#5D3F9F" }) });
		}
		return require_tokens.getThemeConfig(themeColor);
	}, [themeColor, props === null || props === void 0 ? void 0 : props.theme]);
	const datePickerTheme = (0, react.useMemo)(() => {
		var _theme$token;
		return (0, _pisell_date_picker.createTheme)({ palette: { primary: { main: ((_theme$token = theme.token) === null || _theme$token === void 0 ? void 0 : _theme$token.colorPrimary) || "#5D3F9F" } } });
	}, [platform, themeColor]);
	const PisellConfigProvid = isRenderPisellConfigProvider ? require_index$1.default : react.default.Fragment;
	(0, react.useEffect)(() => {
		document.body.id = "body";
	}, []);
	return /* @__PURE__ */ react.default.createElement(require_index.default, require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, others), {}, {
		locale: localMap[locale],
		prefixCls: props.prefixCls || "pisell-lowcode",
		theme
	}), /* @__PURE__ */ react.default.createElement(antd.App, {
		component: false,
		message: { maxCount: 1 }
	}, /* @__PURE__ */ react.default.createElement(_pisell_date_picker.LocalizationProvider, {
		dateAdapter: _pisell_date_picker_es_AdapterDayjs.AdapterDayjs,
		adapterLocale: (localeDateMap === null || localeDateMap === void 0 || (_localeDateMap = localeDateMap[locale]) === null || _localeDateMap === void 0 ? void 0 : _localeDateMap.adapterLocale) || "en"
	}, /* @__PURE__ */ react.default.createElement(_pisell_date_picker.ThemeProvider, { theme: datePickerTheme }, /* @__PURE__ */ react.default.createElement(_pisell_date_picker.LocaleProvider, { value: { locale } }, /* @__PURE__ */ react.default.createElement(PisellConfigProvid, { locale }, /* @__PURE__ */ react.default.createElement(require_VariablesProvider.default, {
		variables: ((_context$engine2 = context.engine) === null || _context$engine2 === void 0 || (_context$engine2 = _context$engine2.props) === null || _context$engine2 === void 0 ? void 0 : _context$engine2.variables) || {},
		config: variablesConfig
	}, /* @__PURE__ */ react.default.createElement("div", {
		style: require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, style), {}, { "--theme-color": themeColor || "#5D3F9F" }),
		className
	}, children))))))));
};
//#endregion
exports.default = Page;
