import { Statistics, StatisticsSmall } from "@wix/wix-ui-icons-common";
import {
  Node_Type,
  RicosPluginToolbarNames,
  quickActionsModalSections
} from "./../ricos-types/index.js";
import { posToDOMRect } from "./../tiptap/index.js";
import { InsertModal } from "./components/insert-modal/insert-modal.js";
import { INSERT_POLL_MODAL_ID } from "./consts.js";
import { getAddButtons } from "./get-add-buttons.js";
import { getToolbarButtons } from "./get-toolbar-buttons.js";
import { pollConverter } from "./poll-converter.js";
import { tiptapExtensions } from "./tiptap/tiptap.js";
import { POLL_TYPE } from "./types.js";
const pluginPoll = (config) => {
  return {
    config: { type: "poll", ...config },
    pmMarkConverters: [],
    pmNodeConverters: [pollConverter],
    type: POLL_TYPE,
    tiptapExtensions,
    getAddButtons: (config2, services) => getAddButtons(config2, services),
    toolbar: {
      names: [RicosPluginToolbarNames.POLL],
      getButtons: (config2, services) => getToolbarButtons(config2, services)
    },
    getQuickActions: ({ pluginServices }) => {
      const isMobile = pluginServices?.context.isMobile;
      return [
        {
          id: Node_Type.POLL,
          title: "QuickActionsPlugin_ActionTitle_Poll",
          icon: isMobile ? Statistics : StatisticsSmall,
          section: quickActionsModalSections.FormatLayout,
          tags: ["vote", "survey", "questionnaire", "feedback", "voting", "opinion", "form"],
          command: ({ modalService, editor }) => {
            modalService.togglePluginPanel({
              id: INSERT_POLL_MODAL_ID,
              Component: InsertModal,
              componentProps: {
                config: { type: "poll", ...config }
              },
              isMobile,
              positioning: {
                referenceElement: {
                  getBoundingClientRect: () => posToDOMRect(
                    editor.view,
                    editor.view.state.selection.from,
                    editor.view.state.selection.to
                  )
                },
                placement: isMobile ? "bottom" : "bottom-start"
              },
              mobileLayout: "drawer"
            });
          }
        }
      ];
    }
  };
};
export {
  pluginPoll
};
//# sourceMappingURL=editor.js.map

import { injectCss } from "./viewer-styles-inject.js";
injectCss();
