var __create = Object.create;
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 __getProtoOf = Object.getPrototypeOf;
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 __objRest = (source, exclude) => {
  var target = {};
  for (var prop in source)
    if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
      target[prop] = source[prop];
  if (source != null && __getOwnPropSymbols)
    for (var prop of __getOwnPropSymbols(source)) {
      if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
        target[prop] = source[prop];
    }
  return target;
};
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);
var __async = (__this, __arguments, generator) => {
  return new Promise((resolve, reject) => {
    var fulfilled = (value) => {
      try {
        step(generator.next(value));
      } catch (e) {
        reject(e);
      }
    };
    var rejected = (value) => {
      try {
        step(generator.throw(value));
      } catch (e) {
        reject(e);
      }
    };
    var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
    step((generator = generator.apply(__this, __arguments)).next());
  });
};
var stdin_exports = {};
__export(stdin_exports, {
  ActionsContent: () => ActionsContent
});
module.exports = __toCommonJS(stdin_exports);
var import_vue = require("vue");
var import_pro_utils = require("@antdv/pro-utils");
var import_ant_design_vue = require("ant-design-vue");
var import_context = require("ant-design-vue/lib/config-provider/context");
var import_vc_resize_observer = __toESM(require("ant-design-vue/lib/vc-resize-observer"));
var import_vue2 = require("vue");
var import_props = require("../GlobalHeader/props");
var import_rightContentStyle = require("./rightContentStyle");
const ActionsContent = (0, import_vue2.defineComponent)({
  name: "ActionsContent",
  props: (0, import_props.globalHeaderProps)(),
  slots: Object,
  inheritAttrs: false,
  setup(props, {
    slots
  }) {
    const [rightSize, setRightSize] = (0, import_pro_utils.useState)("auto");
    const {
      getPrefixCls
    } = (0, import_context.useConfigContextInject)();
    const prefixCls = (0, import_vue2.computed)(() => `${getPrefixCls()}-pro-global-header`);
    const {
      wrapSSR,
      hashId
    } = (0, import_rightContentStyle.useStyle)(prefixCls);
    const avatarDom = (0, import_vue2.computed)(() => {
      var _a;
      if (!props.avatarProps) return null;
      const _b = props.avatarProps, {
        title = (_a = slots.avatarTitle) == null ? void 0 : _a.call(slots),
        render
      } = _b, rest = __objRest(_b, [
        "title",
        "render"
      ]);
      const domList = [(rest == null ? void 0 : rest.src) || (rest == null ? void 0 : rest.srcset) || rest.icon ? (0, import_vue.createVNode)(import_ant_design_vue.Avatar, (0, import_vue.mergeProps)(rest, {
        "size": 28,
        "key": "avatar"
      }), null) : null, title ? (0, import_vue.createVNode)("span", {
        "key": "name",
        "style": {
          marginInlineStart: `8px`
        }
      }, [title]) : void 0];
      if (render) {
        return render(props.avatarProps, (0, import_vue.createVNode)("div", null, [domList]), (0, import_pro_utils.omit)(props, ["avatarProps", "actionsRender", "headerContentRender"]));
      }
      ;
      return (0, import_vue.createVNode)("div", null, [domList]);
    });
    const setRightSizeDebounceFn = (0, import_pro_utils.useDebounceFn)((width) => __async(this, null, function* () {
      setRightSize(`${width}px`);
    }), 160);
    return () => {
      const _a = props, {
        avatarProps,
        actionsRender,
        headerContentRender
      } = _a, restProps = __objRest(_a, [
        "avatarProps",
        "actionsRender",
        "headerContentRender"
      ]);
      const rightActionsRender = actionsRender || avatarDom.value ? (restParams) => {
        const doms = actionsRender && (actionsRender == null ? void 0 : actionsRender(restParams));
        if (!doms && !avatarDom.value) return null;
        if (!Array.isArray(doms)) {
          return wrapSSR((0, import_vue.createVNode)("div", {
            "class": `${prefixCls.value}-header-actions ${hashId.value}`.trim()
          }, [doms, avatarDom.value && (0, import_vue.createVNode)("span", {
            "class": `${prefixCls.value}-header-actions-avatar ${hashId.value}`.trim()
          }, [avatarDom.value])]));
        }
        return wrapSSR((0, import_vue.createVNode)("div", {
          "class": `${prefixCls.value}-header-actions ${hashId.value}`.trim()
        }, [doms.filter(Boolean).map((dom, index) => {
          var _a2;
          let hideHover = false;
          if ((0, import_pro_utils.isValidElement)(dom)) {
            hideHover = !!((_a2 = dom == null ? void 0 : dom.props) == null ? void 0 : _a2["aria-hidden"]);
          }
          return (0, import_vue.createVNode)("div", {
            "key": index,
            "class": (0, import_pro_utils.classNames)(`${prefixCls.value}-header-actions-item ${hashId.value} `, {
              [`${prefixCls.value}-header-actions-hover`]: !hideHover
            })
          }, [dom]);
        }), avatarDom.value && (0, import_vue.createVNode)("span", {
          "class": `${prefixCls.value}-header-actions-avatar ${hashId.value} `.trim()
        }, [avatarDom.value])]));
      } : void 0;
      return (0, import_vue.createVNode)("div", {
        "class": `${prefixCls.value}-right-content ${hashId.value} `.trim(),
        "style": {
          minWidth: rightSize.value,
          height: "100%"
        }
      }, [(0, import_vue.createVNode)("div", {
        "style": {
          height: "100%"
        }
      }, [(0, import_vue.createVNode)(import_vc_resize_observer.default, {
        "onResize": ({
          width
        }) => {
          setRightSizeDebounceFn.run(width);
        }
      }, {
        default: () => [rightActionsRender ? (0, import_vue.createVNode)("div", {
          "style": {
            display: "flex",
            alignItems: "center",
            height: "100%",
            justifyContent: "flex-end"
          }
        }, [rightActionsRender(__spreadProps(__spreadValues({}, restProps), {
          rightContentSize: rightSize.value
        }))]) : null]
      })])]);
    };
  }
});
