// packages/dom/src/dom/input-field-has-uncollapsed-selection.js
import isTextField from "./is-text-field.mjs";
import isHTMLInputElement from "./is-html-input-element.mjs";
function inputFieldHasUncollapsedSelection(element) {
  if (!isHTMLInputElement(element) && !isTextField(element)) {
    return false;
  }
  try {
    const { selectionStart, selectionEnd } = (
      /** @type {HTMLInputElement | HTMLTextAreaElement} */
      element
    );
    return (
      // `null` means the input type doesn't implement selection, thus we
      // cannot determine whether the selection is collapsed, so we
      // default to true.
      selectionStart === null || // when not null, compare the two points
      selectionStart !== selectionEnd
    );
  } catch (error) {
    return true;
  }
}
export {
  inputFieldHasUncollapsedSelection as default
};
//# sourceMappingURL=input-field-has-uncollapsed-selection.mjs.map
