'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var vue = require('vue');
require('../../../utils/index.cjs');
var useConfigInject = require('../../config-provider/src/hooks/useConfigInject.cjs');
var index = require('../style/index.cjs');
var props = require('./props.cjs');
var props$1 = require('../../../utils/vue/props.cjs');

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

exports.default = AComment;
//# sourceMappingURL=Comment.cjs.map
