import { DateChecked, Order, WixBooking } from "@wix/wix-ui-icons-common";
import { AppEmbedData_AppType } from "./../ricos-schema/legacy/wix/rich_content/v1/index.js";
import { Node_Type } from "./../ricos-types/index.js";
import { INSERT_PLUGIN_BUTTONS, TOOLBARS } from "./../editor-common/index.js";
import { verticalEmbedModals } from "./constants.js";
import { INSERT_BOOKINGS_BUTTON, INSERT_EVENT_BUTTON, INSERT_STORES_BUTTON } from "./data-hooks.js";
import { InsertModal } from "./modals/insert-modal.js";
const toolbarsToAddIn = [
  TOOLBARS.MOBILE,
  TOOLBARS.FOOTER,
  TOOLBARS.SIDE
];
const getAddButtons = (config, services) => {
  const { exposeEmbedButtons = [] } = config || {};
  const {
    modals,
    context: { isMobile }
  } = services;
  const toggleInsertModal = ({
    id,
    type,
    referenceElement
  }) => {
    modals?.togglePluginPanel({
      id,
      Component: InsertModal,
      componentProps: {
        componentData: { type },
        modalId: id
      },
      isMobile,
      positioning: {
        referenceElement,
        placement: "bottom"
      }
    });
  };
  const buttonsMap = {
    event: {
      id: `${Node_Type.APP_EMBED}.event`,
      label: INSERT_PLUGIN_BUTTONS.EVENTS,
      dataHook: INSERT_EVENT_BUTTON,
      icon: DateChecked,
      tooltip: "EventsPlugin_InsertButton_Tooltip",
      toolbars: toolbarsToAddIn,
      command: ({ referenceElement }) => {
        toggleInsertModal({
          id: verticalEmbedModals.insertEvent,
          type: AppEmbedData_AppType.EVENT,
          referenceElement
        });
        return true;
      },
      menuConfig: {
        tags: "Events_plugin_search_tags",
        group: "embed_wix"
      }
    },
    booking: {
      id: `${Node_Type.APP_EMBED}.booking`,
      label: INSERT_PLUGIN_BUTTONS.BOOKINGS,
      dataHook: INSERT_BOOKINGS_BUTTON,
      icon: WixBooking,
      tooltip: "BookingsPlugin_InsertButton_Tooltip",
      toolbars: toolbarsToAddIn,
      command: ({ referenceElement }) => {
        toggleInsertModal({
          id: verticalEmbedModals.insertBooking,
          type: AppEmbedData_AppType.BOOKING,
          referenceElement
        });
        return true;
      },
      menuConfig: {
        tags: "Bookings_plugin_search_tags",
        group: "embed_wix"
      }
    },
    product: {
      id: `${Node_Type.APP_EMBED}.product`,
      label: INSERT_PLUGIN_BUTTONS.STORES,
      dataHook: INSERT_STORES_BUTTON,
      icon: Order,
      tooltip: "StoresPlugin_InsertButton_Tooltip",
      toolbars: toolbarsToAddIn,
      command: ({ referenceElement }) => {
        toggleInsertModal({
          id: verticalEmbedModals.insertProduct,
          type: AppEmbedData_AppType.PRODUCT,
          referenceElement
        });
        return true;
      },
      menuConfig: {
        tags: "Stores_plugin_search_tags",
        group: "embed_wix"
      }
    }
  };
  return exposeEmbedButtons.map((buttonType) => buttonsMap[buttonType]);
};
export {
  getAddButtons,
  toolbarsToAddIn
};
//# sourceMappingURL=get-add-buttons.js.map
