import { defineComponent, createVNode } from 'vue';
import '../../../utils/index.mjs';
import useConfigInject from '../../config-provider/src/hooks/useConfigInject.mjs';
import useStyle from '../style/index.mjs';
import { commentProps } from './props.mjs';
import { flattenChildren } from '../../../utils/vue/props.mjs';

var AComment = /* @__PURE__ */ defineComponent({
  compatConfig: {
    MODE: 3
  },
  name: "AComment",
  inheritAttrs: false,
  props: commentProps(),
  slots: Object,
  setup(props, {
    slots,
    attrs
  }) {
    const {
      prefixCls,
      direction
    } = useConfigInject("comment", props);
    const [wrapSSR, hashId] = useStyle(prefixCls);
    const renderNested = (prefix, children) => {
      return createVNode("div", {
        "class": `${prefix}-nested`
      }, [children]);
    };
    const getAction = (actions) => {
      if (!actions || !actions.length)
        return null;
      const actionList = actions.map((action, index) => createVNode("li", {
        "key": `action-${index}`
      }, [action]));
      return actionList;
    };
    return () => {
      var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
      const pre = prefixCls.value;
      const actions = (_b = props.actions) != null ? _b : (_a = slots.actions) == null ? void 0 : _a.call(slots);
      const author = (_d = props.author) != null ? _d : (_c = slots.author) == null ? void 0 : _c.call(slots);
      const avatar = (_f = props.avatar) != null ? _f : (_e = slots.avatar) == null ? void 0 : _e.call(slots);
      const content = (_h = props.content) != null ? _h : (_g = slots.content) == null ? void 0 : _g.call(slots);
      const datetime = (_j = props.datetime) != null ? _j : (_i = slots.datetime) == null ? void 0 : _i.call(slots);
      const avatarDom = createVNode("div", {
        "class": `${pre}-avatar`
      }, [typeof avatar === "string" ? createVNode("img", {
        "src": avatar,
        "alt": "comment-avatar"
      }, null) : avatar]);
      const actionDom = actions ? createVNode("ul", {
        "class": `${pre}-actions`
      }, [getAction(Array.isArray(actions) ? actions : [actions])]) : null;
      const authorContent = createVNode("div", {
        "class": `${pre}-content-author`
      }, [author && createVNode("span", {
        "class": `${pre}-content-author-name`
      }, [author]), datetime && createVNode("span", {
        "class": `${pre}-content-author-time`
      }, [datetime])]);
      const contentDom = createVNode("div", {
        "class": `${pre}-content`
      }, [authorContent, createVNode("div", {
        "class": `${pre}-content-detail`
      }, [content]), actionDom]);
      const comment = createVNode("div", {
        "class": `${pre}-inner`
      }, [avatarDom, contentDom]);
      const children = flattenChildren((_k = slots.default) == null ? void 0 : _k.call(slots));
      return wrapSSR(createVNode("div", {
        ...attrs,
        "class": [pre, {
          [`${pre}-rtl`]: direction.value === "rtl"
        }, attrs.class, hashId.value]
      }, [comment, children && children.length ? renderNested(pre, children) : null]));
    };
  }
});

export { AComment as default };
//# sourceMappingURL=Comment.mjs.map
