"use strict";Object.defineProperty(exports, "__esModule", {value: true});

var _chunkADSB4RKLjs = require('./chunk-ADSB4RKL.js');


var _chunk25CJDQG6js = require('./chunk-25CJDQG6.js');

// tmp-babel/messages/web/__shared__/GroupChatMembersList/ProfilesList/index.js
var _buttons = require('@baseapp-frontend/design-system/components/web/buttons');
var _displays = require('@baseapp-frontend/design-system/components/web/displays');
var _material = require('@mui/material');
var _reactvirtuoso = require('react-virtuoso');
var _jsxruntime = require('react/jsx-runtime');
function _typeof(o) {
  "@babel/helpers - typeof";
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o2) {
    return typeof o2;
  } : function(o2) {
    return o2 && "function" == typeof Symbol && o2.constructor === Symbol && o2 !== Symbol.prototype ? "symbol" : typeof o2;
  }, _typeof(o);
}
function ownKeys(e, r) {
  var t = Object.keys(e);
  if (Object.getOwnPropertySymbols) {
    var o = Object.getOwnPropertySymbols(e);
    r && (o = o.filter(function(r2) {
      return Object.getOwnPropertyDescriptor(e, r2).enumerable;
    })), t.push.apply(t, o);
  }
  return t;
}
function _objectSpread(e) {
  for (var r = 1; r < arguments.length; r++) {
    var t = null != arguments[r] ? arguments[r] : {};
    r % 2 ? ownKeys(Object(t), true).forEach(function(r2) {
      _defineProperty(e, r2, t[r2]);
    }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r2) {
      Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
    });
  }
  return e;
}
function _defineProperty(e, r, t) {
  return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
}
function _toPropertyKey(t) {
  var i = _toPrimitive(t, "string");
  return "symbol" == _typeof(i) ? i : i + "";
}
function _toPrimitive(t, r) {
  if ("object" != _typeof(t) || !t) return t;
  var e = t[Symbol.toPrimitive];
  if (void 0 !== e) {
    var i = e.call(t, r || "default");
    if ("object" != _typeof(i)) return i;
    throw new TypeError("@@toPrimitive must return a primitive value.");
  }
  return ("string" === r ? String : Number)(t);
}
var ProfilesList = function ProfilesList2(_ref) {
  var searchValue = _ref.searchValue, _ref$profiles = _ref.profiles, profiles = _ref$profiles === void 0 ? [] : _ref$profiles, isPending = _ref.isPending, isLoadingNext = _ref.isLoadingNext, hasNext = _ref.hasNext, loadNext = _ref.loadNext, renderItem = _ref.renderItem, _ref$VirtuosoProps = _ref.VirtuosoProps, VirtuosoProps = _ref$VirtuosoProps === void 0 ? {} : _ref$VirtuosoProps, _ref$NormalListProps = _ref.NormalListProps, NormalListProps = _ref$NormalListProps === void 0 ? {} : _ref$NormalListProps, _ref$label = _ref.label, label = _ref$label === void 0 ? "Available connections" : _ref$label, _ref$title = _ref.title, title = _ref$title === void 0 ? "Connections" : _ref$title, _ref$EmptyProfilesLis = _ref.EmptyProfilesListState, EmptyProfilesListState = _ref$EmptyProfilesLis === void 0 ? _chunkADSB4RKLjs.EmptyProfilesListState_default : _ref$EmptyProfilesLis, _ref$SearchNotFoundSt = _ref.SearchNotFoundState, SearchNotFoundState = _ref$SearchNotFoundSt === void 0 ? _chunk25CJDQG6js.SearchNotFoundState_default : _ref$SearchNotFoundSt, _ref$allowAddMember = _ref.allowAddMember, allowAddMember = _ref$allowAddMember === void 0 ? false : _ref$allowAddMember, _ref$onAddMemberClick = _ref.onAddMemberClick, onAddMemberClick = _ref$onAddMemberClick === void 0 ? function() {
  } : _ref$onAddMemberClick, _ref$removeTitle = _ref.removeTitle, removeTitle = _ref$removeTitle === void 0 ? false : _ref$removeTitle;
  var theme = _material.useTheme.call(void 0, );
  var renderLoadingState = function renderLoadingState2() {
    if (!isLoadingNext) return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Box, {
      sx: {
        paddingTop: 3
      }
    });
    return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _displays.LoadingState, {
      sx: {
        paddingTop: 3,
        paddingBottom: 1
      },
      CircularProgressProps: {
        size: 15
      },
      "aria-label": "loading more profiles"
    });
  };
  var isPaginated = loadNext;
  var emptyProfilesList = profiles.length === 0;
  if (!isPending && searchValue && emptyProfilesList && isPaginated) return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SearchNotFoundState, {});
  if (!isPending && emptyProfilesList && isPaginated) return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, EmptyProfilesListState, {});
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, {
    children: [/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "menu", {
      "aria-label": label,
      children: !removeTitle && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Typography, {
        variant: "subtitle2",
        color: "text.primary",
        sx: {
          padding: title === "" ? 0 : theme.spacing(2),
          borderBottom: "1px solid ".concat(theme.palette.divider)
        },
        children: title
      })
    }), allowAddMember && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _buttons.AvatarButton, {
      onClick: onAddMemberClick,
      caption: "Add Member"
    }), isPaginated ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactvirtuoso.Virtuoso, _objectSpread({
      data: profiles,
      itemContent: function itemContent(_index, item) {
        return renderItem(item);
      },
      style: {
        scrollbarWidth: "none",
        maxHeight: "250px"
      },
      components: {
        Footer: renderLoadingState
      },
      endReached: function endReached() {
        if (hasNext) {
          loadNext === null || loadNext === void 0 || loadNext(5);
        }
      }
    }, VirtuosoProps)) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Box, _objectSpread(_objectSpread({
      maxHeight: 250,
      overflow: "auto",
      sx: {
        scrollbarWidth: "none"
      }
    }, NormalListProps), {}, {
      children: profiles.map(function(member) {
        return renderItem(member, true);
      })
    }))]
  });
};
var ProfilesList_default = ProfilesList;



exports.ProfilesList_default = ProfilesList_default;
//# sourceMappingURL=chunk-A6E7VFHN.js.map