var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/components/page/index.tsx
var page_exports = {};
__export(page_exports, {
  default: () => page_default
});
module.exports = __toCommonJS(page_exports);
var import_react = __toESM(require("react"));
var import_config_provider = __toESM(require("../config-provider"));
var import_AdapterDayjs = require("@pisell/date-picker/es/AdapterDayjs");
var import_VariablesProvider = __toESM(require("../dataSourceComponents/provider/variables/VariablesProvider"));
var import_date_picker = require("@pisell/date-picker");
var import_antd = require("antd");
var import_en_US = __toESM(require("antd/es/locale/en_US"));
var import_zh_CN = __toESM(require("antd/es/locale/zh_CN"));
var import_zh_TW = __toESM(require("antd/es/locale/zh_TW"));
var import_zh_HK = __toESM(require("antd/es/locale/zh_HK"));
var import_pisell_config_provider = __toESM(require("../pisell-config-provider"));
var import_useEngineContext = __toESM(require("../../hooks/useEngineContext"));
var localMap = {
  "zh-TW": import_zh_TW.default,
  "zh-CN": import_zh_CN.default,
  "zh-HK": import_zh_HK.default,
  "en-US": import_en_US.default,
  en: import_en_US.default
};
var localeDateMap = {
  "en-US": {
    adapterLocale: "en"
  },
  en: {
    adapterLocale: "en"
  },
  "zh-TW": {
    adapterLocale: "zh-tw"
  },
  "zh-HK": {
    adapterLocale: "zh-tw"
  },
  "zh-CN": {
    adapterLocale: "zh-cn"
  }
};
var Page = (props) => {
  var _a, _b, _c, _d, _e, _f;
  const { children, style, className, locale: propsLocale, ...others } = props;
  const context = (0, import_useEngineContext.default)();
  const { platform, themeColor } = ((_a = context.appHelper) == null ? void 0 : _a.constants) || {};
  const locale = propsLocale || ((_c = (_b = context == null ? void 0 : context.engine) == null ? void 0 : _b.props) == null ? void 0 : _c.locale) || "en";
  const theme = (0, import_react.useMemo)(() => {
    var _a2, _b2;
    if (props == null ? void 0 : props.theme) {
      return {
        ...props.theme,
        // cssVar: { key: 'app' },
        token: {
          ...props.theme.token,
          // 外部透传主题时，如果没有传入colorPrimary 默认使用主项目内主题色
          colorPrimary: ((_b2 = (_a2 = props == null ? void 0 : props.theme) == null ? void 0 : _a2.token) == null ? void 0 : _b2.colorPrimary) || themeColor || "#5D3F9F"
        }
      };
    }
    return {
      // cssVar: { key: 'app' },
      components: {
        Table: {
          colorFillContent: "#EAECF0",
          colorFillSecondary: "#F2F4F7",
          colorBorderSecondary: "#EAECF0",
          colorFillAlter: "#F9FAFB",
          controlItemBgHover: "#F9FAFB",
          colorTextHeading: "#475467",
          colorTextDescription: "#667085",
          colorText: "#101828",
          controlHeight: 32,
          padding: 24,
          margin: 16
        },
        Message: {
          contentBg: "#101828"
        },
        Button: {
          borderRadiusSM: 6,
          borderRadiusLG: 9,
          borderRadius: 8,
          controlHeight: 36,
          colorBgContainerDisabled: "#F2F4F7",
          colorBgTextHover: "#F9FAFB",
          colorBorder: "#D0D5DD",
          colorError: "#D92D20",
          colorErrorActive: "#D92D20",
          colorErrorHover: "#B42318",
          colorErrorBg: "#FEF3F2",
          colorErrorBorderHover: "#FDA29B",
          colorErrorOutline: "rgba(217, 45, 32, 0.06)",
          colorLink: "#7F56DA",
          colorLinkActive: "#5F3DA8",
          colorLinkHover: "#6D48C4",
          // colorPrimaryActive: '#5D3F9F',
          // colorPrimaryBorder: '#E9D7FE',
          colorText: "#344054",
          colorTextDisabled: "#D0D5DD",
          colorTextLightSolid: "#fff",
          colorBgTextActive: "#D0D5DD",
          controlOutline: "rgba(127, 86, 217, 0.04)",
          controlTmpOutline: "#F9FAFB",
          paddingContentHorizontal: 14,
          marginXS: 8
        },
        Divider: {
          colorSplit: "#EAECF0"
        },
        Breadcrumb: {
          itemColor: "#475467",
          colorTextDescription: "#475467",
          // lastItemColor: '#6941C6',
          separatorMargin: 12,
          separatorColor: "#D0D5DD",
          linkHoverColor: "#1D2939",
          linkColor: "#475467",
          colorBgTextHover: "#F9FAFB",
          paddingXXS: 8
        },
        Dropdown: {
          borderRadiusLG: 8,
          // "boxShadowPopoverArrow": "2px 2px 5px rgba(0, 0, 0, 0.05)",
          controlHeight: 42,
          fontSize: 14
        },
        DatePicker: {
          borderRadius: 8,
          colorTextPlaceholder: "#667085",
          colorIcon: "#667085",
          colorTextQuaternary: "#D0D5DD",
          colorBgContainerDisabled: "#F9FAFB",
          colorTextDisabled: "#98A2B3"
        },
        Input: {
          fontSizeIcon: 16,
          addonBg: "#fff"
          // "lineHeight": 1
        },
        Select: {
          fontSizeIcon: 16
          // "lineHeight": 1
        },
        Menu: {
          subMenuItemSelectedColor: "#9976e3"
        }
      },
      token: {
        colorPrimary: themeColor || "#5D3F9F",
        colorPrimaryBg: "#eee5ff",
        colorPrimaryBgHover: "#e4d9fc",
        colorPrimaryBorder: "#d4c3f7",
        colorSuccess: "#5f9e3f",
        colorInfo: "#5d3f9f",
        colorError: "#f5222d",
        colorSuccessBg: "#e5fcd9",
        colorSuccessBgHover: "#d5f7c3",
        // 链接色
        colorLink: "#7F56DA",
        colorLinkActive: "#5F3DA8",
        colorLinkHover: "#6D48C4",
        colorText: "#101828",
        colorTextSecondary: "#475467",
        colorTextTertiary: "#667085",
        colorTextQuaternary: "#D0D5DD",
        colorBorder: "#D0D5DD",
        colorBorderSecondary: "#EAECF0",
        colorFill: "#D0D5DD",
        colorFillSecondary: "#EAECF0",
        colorFillTertiary: "#F2F4F7",
        colorFillQuaternary: "#F9FAFB",
        colorBgLayout: "#F2F4F7",
        colorBgSpotlight: "#101828",
        colorBgMask: "rgba(0, 0, 0, 0.5)",
        wireframe: false,
        borderRadius: 8
      }
    };
  }, [platform, themeColor, props == null ? void 0 : props.theme]);
  const datePickerTheme = (0, import_react.useMemo)(() => {
    var _a2;
    return (0, import_date_picker.createTheme)({
      palette: {
        primary: { main: ((_a2 = theme.token) == null ? void 0 : _a2.colorPrimary) || "#5D3F9F" }
      }
    });
  }, [platform, themeColor]);
  return /* @__PURE__ */ import_react.default.createElement(
    import_config_provider.default,
    {
      ...others,
      locale: localMap[locale],
      prefixCls: props.prefixCls || "pisell-lowcode",
      theme
    },
    /* @__PURE__ */ import_react.default.createElement(
      import_antd.App,
      {
        component: false,
        message: {
          maxCount: 1
        }
      },
      /* @__PURE__ */ import_react.default.createElement(
        import_date_picker.LocalizationProvider,
        {
          dateAdapter: import_AdapterDayjs.AdapterDayjs,
          adapterLocale: ((_d = localeDateMap == null ? void 0 : localeDateMap[locale]) == null ? void 0 : _d.adapterLocale) || "en"
        },
        /* @__PURE__ */ import_react.default.createElement(import_date_picker.ThemeProvider, { theme: datePickerTheme }, /* @__PURE__ */ import_react.default.createElement(import_date_picker.LocaleProvider, { value: { locale } }, /* @__PURE__ */ import_react.default.createElement(import_pisell_config_provider.default, { locale }, /* @__PURE__ */ import_react.default.createElement(
          import_VariablesProvider.default,
          {
            variables: ((_f = (_e = context.engine) == null ? void 0 : _e.props) == null ? void 0 : _f.variables) || {}
          },
          /* @__PURE__ */ import_react.default.createElement(
            "div",
            {
              style: {
                ...style,
                "--theme-color": themeColor || "#5D3F9F"
              },
              className
            },
            children
          )
        ))))
      )
    )
  );
};
var page_default = Page;
