"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _react = require("react");
var _enumUIKitID = require("../../enums/enumUIKitID");
var _hooks = require("../../hooks");
var _Button = require("../../components/Button/Button");
var _icons = require("../../../core/assets/icons");
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
const CommunityJoinedButton = ({
  pageId = _enumUIKitID.PageID.WildCardPage,
  componentId = _enumUIKitID.ComponentID.WildCardComponent,
  communityId,
  ...props
}) => {
  const {
    config,
    accessibilityId,
    isExcluded,
    themeStyles
  } = (0, _hooks.useAmityElement)({
    pageId,
    componentId,
    elementId: _enumUIKitID.ElementID.community_joined_button
  });
  const {
    leaveCommunity,
    isPending
  } = (0, _hooks.useLeaveCommunity)();
  const handleLeaveCommunity = () => {
    if (!communityId) return;
    leaveCommunity(communityId);
  };
  if (isExcluded) return null;
  return /*#__PURE__*/React.createElement(_Button.Button, _extends({
    testID: accessibilityId,
    type: "secondary",
    icon: (0, _icons.check)(themeStyles.isDarkTheme ? themeStyles.colors.baseShade1 : undefined),
    onPress: handleLeaveCommunity,
    disabled: isPending,
    size: _Button.BUTTON_SIZE.SMALL
  }, props), (config === null || config === void 0 ? void 0 : config.text) || 'Joined');
};
var _default = exports.default = /*#__PURE__*/(0, _react.memo)(CommunityJoinedButton);
//# sourceMappingURL=CommunityJoinedButtonElement.js.map