import { Facebook, Instagram, Pinterest, TikTok, XCorp } from "@wix/wix-ui-icons-common";
import lodash from "lodash";
import { Node_Type } from "./../ricos-types/index.js";
import { INSERT_PLUGIN_BUTTONS, TOOLBARS } from "./../editor-common/index.js";
import { socialModals } from "./consts.js";
import {
  INSERT_FACEBOOK_BUTTON,
  INSERT_INSTAGRAM_BUTTON,
  INSERT_PINTEREST_BUTTON,
  INSERT_TIKTOK_BUTTON,
  INSERT_TWITTER_BUTTON
} from "./data-hooks.js";
import { InsertModal } from "./modals/insert-modal.js";
const toolbarsToAddIn = [
  TOOLBARS.FOOTER,
  TOOLBARS.SIDE,
  TOOLBARS.MOBILE
];
const getAddButtons = (config, services) => {
  const { exposeEmbedButtons = [], fetchData } = config || {};
  const {
    modals,
    context: { isMobile }
  } = services;
  const toggleInsertModal = ({
    id,
    socialType,
    referenceElement
  }) => {
    modals?.togglePluginPanel({
      id,
      Component: InsertModal,
      componentProps: {
        fetchData,
        socialType
      },
      isMobile,
      positioning: {
        referenceElement,
        placement: "bottom"
      },
      mobileLayout: "drawer"
    });
  };
  const buttonsMap = {
    Instagram: {
      id: `${Node_Type.LINK_PREVIEW}.instagram`,
      label: INSERT_PLUGIN_BUTTONS.INSTAGRAM,
      dataHook: INSERT_INSTAGRAM_BUTTON,
      icon: Instagram,
      tooltip: "InstagramPlugin_InsertButton_Tooltip",
      toolbars: toolbarsToAddIn,
      command: ({ referenceElement }) => {
        toggleInsertModal({
          id: socialModals.instagram,
          socialType: "Instagram",
          referenceElement
        });
        return true;
      },
      menuConfig: {
        tags: "Instagram_plugin_search_tags",
        group: "embed"
      }
    },
    Twitter: {
      id: `${Node_Type.LINK_PREVIEW}.twitter`,
      label: INSERT_PLUGIN_BUTTONS.TWITTER,
      dataHook: INSERT_TWITTER_BUTTON,
      icon: XCorp,
      tooltip: "TwitterPlugin_InsertButton_Tooltip",
      toolbars: toolbarsToAddIn,
      command: ({ referenceElement }) => {
        toggleInsertModal({
          id: socialModals.twitter,
          socialType: "Twitter",
          referenceElement
        });
        return true;
      },
      menuConfig: {
        tags: "YouTube_plugin_search_tags",
        group: "embed"
      }
    },
    Pinterest: {
      id: `${Node_Type.LINK_PREVIEW}.pinterest`,
      label: INSERT_PLUGIN_BUTTONS.PINTEREST,
      dataHook: INSERT_PINTEREST_BUTTON,
      icon: Pinterest,
      tooltip: "PinterestPlugin_InsertButton_Tooltip",
      toolbars: toolbarsToAddIn,
      command: ({ referenceElement }) => {
        toggleInsertModal({
          id: socialModals.pinterest,
          socialType: "Pinterest",
          referenceElement
        });
        return true;
      },
      menuConfig: {
        tags: "Pinterestsearch_tags",
        group: "embed"
      }
    },
    Facebook: {
      id: `${Node_Type.LINK_PREVIEW}.facebook`,
      label: INSERT_PLUGIN_BUTTONS.FACEBOOK,
      dataHook: INSERT_FACEBOOK_BUTTON,
      icon: Facebook,
      tooltip: "FacebookPlugin_InsertButton_Tooltip",
      toolbars: toolbarsToAddIn,
      command: ({ referenceElement }) => {
        toggleInsertModal({
          id: socialModals.facebook,
          socialType: "Facebook",
          referenceElement
        });
        return true;
      },
      menuConfig: {
        tags: "Facebook_plugin_search_tags",
        group: "embed"
      }
    },
    TikTok: {
      id: `${Node_Type.LINK_PREVIEW}.tiktok`,
      label: INSERT_PLUGIN_BUTTONS.TIKTOK,
      dataHook: INSERT_TIKTOK_BUTTON,
      icon: TikTok,
      tooltip: "TikTokPlugin_InsertButton_Tooltip",
      toolbars: toolbarsToAddIn,
      command: ({ referenceElement }) => {
        toggleInsertModal({
          id: socialModals.tiktok,
          socialType: "TikTok",
          referenceElement
        });
        return true;
      },
      menuConfig: {
        tags: "YouTube_plugin_search_tags",
        group: "embed"
      }
    }
  };
  return lodash.compact(exposeEmbedButtons.map((buttonType) => buttonsMap[buttonType]));
};
export {
  getAddButtons,
  toolbarsToAddIn
};
//# sourceMappingURL=get-add-buttons.js.map
