import {
  supportsDialog
} from "./chunk-74GPBJTH.js";

// src/hooks/useDialogPolyfill/useDialogPolyfill.ts
import { useEffect, useRef, useState } from "react";
var useDialogPolyfill = () => {
  const [hasDialogSupport, setHasDialogSupport] = useState(false);
  const hasAlreadyLoaded = useRef(false);
  useEffect(() => {
    setHasDialogSupport(supportsDialog());
  }, []);
  const polyfillDialog = async (ref) => {
    if (!hasAlreadyLoaded.current && !hasDialogSupport && typeof window !== "undefined" && ref.current !== null) {
      const { default: dialogPolyfill } = await import("dialog-polyfill");
      hasAlreadyLoaded.current = true;
      try {
        if (ref.current) {
          dialogPolyfill.registerDialog(ref.current);
        }
      } catch (error) {
        console.error("Failed to load dialog-polyfill", error);
      }
    }
  };
  return {
    polyfillDialog
  };
};

export {
  useDialogPolyfill
};
//# sourceMappingURL=chunk-RQJCLQZI.js.map
