import React, { useState, useEffect, useMemo, useRef } from "react";
import { useSelector } from "react-redux";
import { FaShareAlt } from "react-icons/fa";
import useTranslation from "../../utils/useTranslation";
import Share from "../../components/Share";
import MenuItem from "../../components/Menu/MenuItem";
function ShareMenu() {
  const activeTopic = useSelector(state => state.app.activeTopic);
  const menuOpen = useSelector(state => state.app.menuOpen);
  const collapsedOnLoad = useMemo(() => {
    var _activeTopic$elements;
    return ((_activeTopic$elements = activeTopic.elements.drawMenu) === null || _activeTopic$elements === void 0 ? void 0 : _activeTopic$elements.collapsedOnLoad) || false;
  }, [activeTopic]);
  const [collapsed, setCollapsed] = useState(false);
  const {
    t
  } = useTranslation();
  const ref = useRef();
  useEffect(() => {
    // Open menu item when loading/switching topic
    if (menuOpen) {
      setCollapsed(collapsedOnLoad);
    }
  }, [menuOpen, collapsedOnLoad]);
  return /*#__PURE__*/React.createElement("div", {
    ref: ref
  }, /*#__PURE__*/React.createElement(MenuItem, {
    open: true,
    fixedHeight: 375,
    className: "wkp-share-menu",
    title: t("Teilen"),
    icon: /*#__PURE__*/React.createElement(FaShareAlt, {
      focusable: false
    }),
    collapsed: collapsed,
    onCollapseToggle: c => setCollapsed(c)
  }, /*#__PURE__*/React.createElement(Share, null)));
}
export default /*#__PURE__*/React.memo(ShareMenu);
//# sourceMappingURL=ShareMenu.js.map