const POPUP_WRAPPER_SELECTOR = '.popup_helper';
export const POPUP_SELECTOR = '#inline_popup';

export default ({ e, title, html, id } = {}) => {
  const popup = document.querySelector(POPUP_SELECTOR);
  if (popup) {
    popup.style.width = 'auto';
    popup.style.maxWidth = '1000px';
  }

  if (popup.classList.contains('show')) {
    popup.querySelector('#inline_popup_title').innerHTML = title;
    popup.querySelector('#inline_popup_content').innerHTML = html;
  } else {
    inlinePopup(e, id, null, { offset_x: 0, offset_y: 0 }, html, title);
  }

  const popupWrapper = document.querySelector(POPUP_WRAPPER_SELECTOR);
  if (popupWrapper) {
    popupWrapper.style.width = 'auto';
    popupWrapper.style.position = 'fixed';
    popupWrapper.style.zIndex = '50001';
  }
};
