import './ai-popup.js';

import type { InlineRange } from '@blockeditor/inline';

import type { AffineInlineEditor } from '../../../affine-inline-specs.js';
import { AIPopup } from './ai-popup.js';

export function toggleAIPopup(
  inlineEditors: AffineInlineEditor[],
  type: AIPopup['type'],
  targetInlineRanges: InlineRange[]
): AIPopup {
  const popup = new AIPopup();
  popup.inlineEditors = inlineEditors;
  popup.type = type;
  popup.targetInlineRanges = targetInlineRanges;

  const docPageEle = document.querySelectorAll('.doc-editor-container')[0];
  if (docPageEle) {
    docPageEle.appendChild(popup);
  }

  // document.body.appendChild(popup);

  return popup;
}
