/**
 * ldesign v0.4.2
 * (c) 2023 ldesign
 * @license MIT
 */

'use strict';

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

var _defineProperty = require('@babel/runtime/helpers/defineProperty');
var vue = require('vue');
var hooks_tnode = require('../hooks/tnode.js');
var hooks_useConfig = require('../hooks/useConfig.js');
var avatar_avatarGroupProps = require('./avatar-group-props.js');
var avatar_avatar = require('./avatar.js');
require('lodash/isFunction');
require('lodash/camelCase');
require('lodash/kebabCase');
require('../utils/render-tnode.js');
require('lodash/isEmpty');
require('lodash/isString');
require('lodash/isObject');
require('../config-provider/useConfig.js');
require('lodash/cloneDeep');
require('../config-provider/context.js');
require('lodash/mergeWith');
require('lodash/merge');
require('lodash/isArray');
require('../_common/js/global-config/default-config.js');
require('../_common/js/global-config/locale/zh_CN.js');
require('@babel/runtime/helpers/typeof');
require('../_chunks/dep-7f0559c3.js');
require('dayjs');
require('../image/index.js');
require('../utils/withInstall.js');
require('../image/image.js');
require('@babel/runtime/helpers/slicedToArray');
require('lodash/omit');
require('@ldesign/icons-vue-next');
require('../_common/js/utils/observe.js');
require('../space/index.js');
require('../space/space.js');
require('lodash/isNumber');
require('../hooks/slot.js');
require('../space/props.js');
require('../image/props.js');
require('./props.js');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);

function _isSlot(s) {
  return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !vue.isVNode(s);
}
var _AvatarGroup = vue.defineComponent({
  name: "TAvatarGroup",
  props: avatar_avatarGroupProps["default"],
  setup: function setup(props2) {
    vue.provide("avatarGroup", props2);
    var renderTNodeJSX = hooks_tnode.useTNodeJSX();
    var AVATAR_NAME = hooks_useConfig.usePrefixClass("avatar");
    var COMPONENT_NAME = hooks_useConfig.usePrefixClass("avatar-group");
    var renderEllipsisAvatar = function renderEllipsisAvatar(children) {
      if ((children === null || children === void 0 ? void 0 : children.length) > props2.max) {
        var content = getEllipsisContent(children);
        var outAvatar = children.slice(0, props2.max);
        outAvatar.push(vue.createVNode(avatar_avatar["default"], {
          "class": "".concat(AVATAR_NAME.value, "__collapse"),
          "size": props2.size
        }, _isSlot(content) ? content : {
          "default": function _default() {
            return [content];
          }
        }));
        return [outAvatar];
      }
      return [children];
    };
    var getEllipsisContent = function getEllipsisContent(children) {
      return renderTNodeJSX("collapseAvatar") || "+".concat(children.length - props2.max);
    };
    return function () {
      var _ref;
      var children = renderTNodeJSX("default");
      var cascading = props2.cascading,
        max = props2.max;
      var groupClass = ["".concat(COMPONENT_NAME.value), (_ref = {}, _defineProperty__default["default"](_ref, "".concat(AVATAR_NAME.value, "--offset-right"), cascading === "right-up"), _defineProperty__default["default"](_ref, "".concat(AVATAR_NAME.value, "--offset-left"), cascading === "left-up"), _ref)];
      var content = max && max >= 0 ? [renderEllipsisAvatar(children)] : [children];
      return vue.createVNode("div", {
        "class": groupClass
      }, [content]);
    };
  }
});

exports["default"] = _AvatarGroup;
//# sourceMappingURL=group.js.map
