var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
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));
import { mergeProps as _mergeProps, createVNode as _createVNode } from "vue";
import { isNeedOpenHash, ProProvider } from "@antdv/pro-provider";
import { classNames } from "@antdv/pro-utils";
import { ConfigProvider } from "ant-design-vue";
import { useConfigContextInject } from "ant-design-vue/lib/config-provider/context";
import { omit } from "lodash-es";
import { computed, defineComponent, ref } from "vue";
import { AppsLogoComponents } from "../AppsLogoComponents/index.mjs";
import { ActionsContent } from "../GlobalHeader/ActionsContent.mjs";
import { globalHeaderProps } from "../GlobalHeader/props.mjs";
import { BaseMenu } from "../SiderMenu/BaseMenu.mjs";
import { privateSiderMenuProps, renderLogoAndTitle, siderMenuProps } from "../SiderMenu/SiderMenu.mjs";
import { useStyle } from "./style.mjs";
const topNavHeaderProps = __spreadValues(__spreadValues(__spreadValues({}, siderMenuProps), globalHeaderProps()), privateSiderMenuProps());
const TopNavHeader = defineComponent({
  name: "TopNavHeader",
  props: topNavHeaderProps,
  inheritAttrs: false,
  setup(props) {
    const devRef = ref(null);
    const {
      getPrefixCls
    } = useConfigContextInject();
    const {
      token: proToken,
      dark
    } = ProProvider.useContext();
    const prefixCls = computed(() => `${props.prefixCls || getPrefixCls("pro")}-top-nav-header`);
    const {
      wrapSSR,
      hashId
    } = useStyle(prefixCls);
    return () => {
      const {
        onMenuHeaderClick,
        contentWidth,
        className: propsClassName,
        style,
        headerContentRender,
        layout,
        actionsRender
      } = props;
      let renderKey;
      if (props.menuHeaderRender !== void 0) {
        renderKey = "menuHeaderRender";
      } else if (layout === "mix" || layout === "top") {
        renderKey = "headerTitleRender";
      }
      const headerDom = renderLogoAndTitle(__spreadProps(__spreadValues({}, props), {
        collapsed: false
      }), renderKey);
      const contentDom = () => {
        var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
        const defaultDom = _createVNode(ConfigProvider, {
          "theme": {
            hashed: isNeedOpenHash(),
            components: {
              Layout: {
                // @ts-expect-error
                headerBg: "transparent",
                bodyBg: "transparent"
              },
              Menu: __spreadValues({}, {
                colorItemBg: ((_b = (_a = proToken == null ? void 0 : proToken.layout) == null ? void 0 : _a.header) == null ? void 0 : _b.colorBgHeader) || "transparent",
                colorSubItemBg: ((_d = (_c = proToken == null ? void 0 : proToken.layout) == null ? void 0 : _c.header) == null ? void 0 : _d.colorBgHeader) || "transparent",
                radiusItem: proToken == null ? void 0 : proToken.borderRadius,
                colorItemBgSelected: ((_f = (_e = proToken == null ? void 0 : proToken.layout) == null ? void 0 : _e.header) == null ? void 0 : _f.colorBgMenuItemSelected) || (proToken == null ? void 0 : proToken.colorBgTextHover),
                itemHoverBg: ((_h = (_g = proToken == null ? void 0 : proToken.layout) == null ? void 0 : _g.header) == null ? void 0 : _h.colorBgMenuItemHover) || (proToken == null ? void 0 : proToken.colorBgTextHover),
                colorItemBgSelectedHorizontal: ((_j = (_i = proToken == null ? void 0 : proToken.layout) == null ? void 0 : _i.header) == null ? void 0 : _j.colorBgMenuItemSelected) || (proToken == null ? void 0 : proToken.colorBgTextHover),
                colorActiveBarWidth: 0,
                colorActiveBarHeight: 0,
                colorActiveBarBorderSize: 0,
                colorItemText: ((_l = (_k = proToken == null ? void 0 : proToken.layout) == null ? void 0 : _k.header) == null ? void 0 : _l.colorTextMenu) || (proToken == null ? void 0 : proToken.colorTextSecondary),
                colorItemTextHoverHorizontal: ((_n = (_m = proToken == null ? void 0 : proToken.layout) == null ? void 0 : _m.header) == null ? void 0 : _n.colorTextMenuActive) || (proToken == null ? void 0 : proToken.colorText),
                colorItemTextSelectedHorizontal: ((_p = (_o = proToken == null ? void 0 : proToken.layout) == null ? void 0 : _o.header) == null ? void 0 : _p.colorTextMenuSelected) || (proToken == null ? void 0 : proToken.colorTextBase),
                horizontalItemBorderRadius: 4,
                colorItemTextHover: ((_r = (_q = proToken == null ? void 0 : proToken.layout) == null ? void 0 : _q.header) == null ? void 0 : _r.colorTextMenuActive) || "rgba(0, 0, 0, 0.85)",
                horizontalItemHoverBg: ((_t = (_s = proToken == null ? void 0 : proToken.layout) == null ? void 0 : _s.header) == null ? void 0 : _t.colorBgMenuItemHover) || "rgba(0, 0, 0, 0.04)",
                colorItemTextSelected: ((_v = (_u = proToken == null ? void 0 : proToken.layout) == null ? void 0 : _u.header) == null ? void 0 : _v.colorTextMenuSelected) || "rgba(0, 0, 0, 1)",
                popupBg: proToken == null ? void 0 : proToken.colorBgElevated,
                subMenuItemBg: proToken == null ? void 0 : proToken.colorBgElevated,
                darkSubMenuItemBg: "transparent",
                darkPopupBg: proToken == null ? void 0 : proToken.colorBgElevated
              })
            },
            token: {
              colorBgElevated: ((_x = (_w = proToken == null ? void 0 : proToken.layout) == null ? void 0 : _w.header) == null ? void 0 : _x.colorBgHeader) || "transparent"
            }
          }
        }, {
          default: () => {
            var _a2;
            return [_createVNode(BaseMenu, _mergeProps({
              "theme": dark ? "dark" : "light"
            }, omit(props, ["actionsRender", "logo", "avatarProps", "appList", "menuExtraRender", "getContainer"]), {
              "className": `${prefixCls.value}-base-menu ${hashId.value}`
            }, props.menuProps, {
              "style": __spreadValues({
                width: "100%"
              }, (_a2 = props.menuProps) == null ? void 0 : _a2.style),
              "collapsed": false,
              "menuRenderType": "header",
              "mode": "horizontal"
            }), null)];
          }
        });
        if (headerContentRender) {
          return headerContentRender();
        }
        return defaultDom;
      };
      return wrapSSR(_createVNode("div", {
        "class": classNames(prefixCls.value, hashId.value, propsClassName, {
          [`${prefixCls.value}-light`]: true
        }),
        "style": style
      }, [_createVNode("div", {
        "ref": devRef,
        "class": classNames(`${prefixCls.value}-main`, hashId.value, {
          [`${prefixCls.value}-wide`]: contentWidth === "Fixed" && layout === "top"
        })
      }, [headerDom && _createVNode("div", {
        "class": classNames(`${prefixCls.value}-main-left ${hashId.value}`),
        "onClick": onMenuHeaderClick
      }, [_createVNode(AppsLogoComponents, props, null), _createVNode("div", {
        "class": `${prefixCls.value}-logo ${hashId.value}`.trim(),
        "key": "logo",
        "id": "logo"
      }, [headerDom])]), _createVNode("div", {
        "style": {
          flex: 1
        },
        "class": `${prefixCls.value}-menu ${hashId.value}`
      }, [contentDom()]), (actionsRender || props.avatarProps) && _createVNode(ActionsContent, _mergeProps(props, {
        "prefixCls": prefixCls.value
      }), null)])]));
    };
  }
});
export {
  TopNavHeader,
  topNavHeaderProps
};
