const getActiveElement = (activeDocument) => {
  const activeElement = activeDocument.activeElement;
  if (!activeElement) {
    return activeElement;
  }
  if (activeElement.tagName === "IFRAME") {
    const iframes = Array.from(document.getElementsByTagName("iframe"));
    if (iframes.includes(activeElement)) {
      const iframeActiveElement = activeElement;
      const iframeActiveDocument = iframeActiveElement.contentDocument || iframeActiveElement.contentWindow?.document;
      if (!iframeActiveDocument) return activeElement;
      return getActiveElement(iframeActiveDocument);
    }
  }
  if (!activeElement.shadowRoot) {
    return activeElement;
  }
  if (activeElement.shadowRoot) {
    return getActiveElement(activeElement.shadowRoot);
  }
  return activeElement;
};

export { getActiveElement as g };
//# sourceMappingURL=getActiveElement-BcSyVE7S.js.map
