"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const React = require("react");
const useForceUpdate = require("../use-force-update/use-force-update.cjs");
function useTextSelection() {
  const forceUpdate = useForceUpdate.useForceUpdate();
  const [selection, setSelection] = React.useState(null);
  const handleSelectionChange = () => {
    setSelection(document.getSelection());
    forceUpdate();
  };
  React.useEffect(() => {
    setSelection(document.getSelection());
    document.addEventListener("selectionchange", handleSelectionChange);
    return () => document.removeEventListener("selectionchange", handleSelectionChange);
  }, []);
  return selection;
}
exports.useTextSelection = useTextSelection;
