var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
  for (var prop in b || (b = {}))
    if (__hasOwnProp.call(b, prop))
      __defNormalProp(a, prop, b[prop]);
  if (__getOwnPropSymbols)
    for (var prop of __getOwnPropSymbols(b)) {
      if (__propIsEnum.call(b, prop))
        __defNormalProp(a, prop, b[prop]);
    }
  return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
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 __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var stdin_exports = {};
__export(stdin_exports, {
  GlobalHeader: () => GlobalHeader
});
module.exports = __toCommonJS(stdin_exports);
var import_vue = require("vue");
var import_icons_vue = require("@ant-design/icons-vue");
var import_pro_utils = require("@antdv/pro-utils");
var import_context = require("ant-design-vue/lib/config-provider/context");
var import_vue2 = require("vue");
var import_utils = require("../../utils/utils");
var import_AppsLogoComponents = require("../AppsLogoComponents");
var import_SiderMenu = require("../SiderMenu/SiderMenu");
var import_TopNavHeader = require("../TopNavHeader");
var import_ActionsContent = require("./ActionsContent");
var import_props = require("./props");
var import_style = require("./style");
function renderLogo(menuHeaderRender, logoDom) {
  if (menuHeaderRender === false) {
    return null;
  }
  if (menuHeaderRender) {
    return menuHeaderRender(logoDom, null);
  }
  return logoDom;
}
const GlobalHeader = (0, import_vue2.defineComponent)({
  name: "GlobalHeader",
  props: __spreadValues(__spreadValues({}, (0, import_props.globalHeaderProps)()), (0, import_SiderMenu.privateSiderMenuProps)()),
  inheritAttrs: false,
  slots: Object,
  setup(props, {
    attrs,
    slots
  }) {
    const {
      getPrefixCls,
      direction
    } = (0, import_context.useConfigContextInject)();
    const baseClassName = (0, import_vue2.computed)(() => `${props.prefixCls || getPrefixCls("pro")}-global-header`);
    const {
      wrapSSR,
      hashId
    } = (0, import_style.useStyle)(baseClassName);
    const className = (0, import_pro_utils.classNames)(attrs.class || "", baseClassName.value, hashId.value);
    return () => {
      var _a, _b;
      const {
        isMobile,
        logo = (_a = slots.logo) == null ? void 0 : _a.call(slots),
        collapsed,
        onCollapse,
        menuHeaderRender,
        onMenuHeaderClick,
        layout,
        children = (_b = slots.default) == null ? void 0 : _b.call(slots),
        splitMenus,
        menuData
      } = props;
      const mergeProps = __spreadValues(__spreadValues({}, props), attrs);
      if (layout === "mix" && !isMobile && splitMenus) {
        const noChildrenMenuData = (menuData || []).map((item) => __spreadProps(__spreadValues({}, item), {
          children: void 0,
          routes: void 0
        }));
        const clearMenuData = (0, import_utils.clearMenuItem)(noChildrenMenuData);
        return (0, import_vue.createVNode)(import_TopNavHeader.TopNavHeader, (0, import_vue.mergeProps)({
          "mode": "horizontal"
        }, mergeProps, {
          "splitMenus": false,
          "menuData": clearMenuData
        }), null);
      }
      const logoClassNames = (0, import_pro_utils.classNames)(`${baseClassName.value}-logo`, hashId.value, {
        [`${baseClassName.value}-logo-rtl`]: (direction == null ? void 0 : direction.value) === "rtl",
        [`${baseClassName.value}-logo-mix`]: layout === "mix",
        [`${baseClassName.value}-logo-mobile`]: isMobile
      });
      const logoDom = (0, import_vue.createVNode)("span", {
        "class": logoClassNames,
        "key": "logo"
      }, [(0, import_vue.createVNode)("a", null, [(0, import_AppsLogoComponents.defaultRenderLogo)(logo)])]);
      return (0, import_vue.createVNode)(import_vue.Fragment, null, [wrapSSR((0, import_vue.createVNode)("div", {
        "class": className,
        "style": __spreadValues({}, attrs.style || {})
      }, [isMobile && (0, import_vue.createVNode)("span", {
        "class": `${baseClassName.value}-collapsed-button ${hashId.value}`.trim(),
        "onClick": () => {
          onCollapse == null ? void 0 : onCollapse(!collapsed);
        }
      }, [(0, import_vue.createVNode)(import_icons_vue.MenuOutlined, null, null)]), isMobile && renderLogo(menuHeaderRender, logoDom), layout === "mix" && !isMobile && (0, import_vue.createVNode)(import_vue.Fragment, null, [(0, import_vue.createVNode)(import_AppsLogoComponents.AppsLogoComponents, props, null), (0, import_vue.createVNode)("div", {
        "class": logoClassNames,
        "onClick": onMenuHeaderClick
      }, [(0, import_SiderMenu.renderLogoAndTitle)(__spreadProps(__spreadValues({}, props), {
        collapsed: false
      }), "headerTitleRender")])]), (0, import_vue.createVNode)("div", {
        "style": {
          flex: 1
        }
      }, [children]), (props.actionsRender || props.avatarProps) && (0, import_vue.createVNode)(import_ActionsContent.ActionsContent, props, null)]))]);
    };
  }
});
