"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const addDomEvent = require("./dist-es-events-add-dom-event.cjs");
const Feature = require("./dist-es-motion-features-Feature.cjs");
const pipe = require("./dist-es-utils-pipe.cjs");
class FocusGesture extends Feature.Feature {
  constructor() {
    super(...arguments);
    this.isActive = false;
  }
  onFocus() {
    let isFocusVisible = false;
    try {
      isFocusVisible = this.node.current.matches(":focus-visible");
    } catch (e) {
      isFocusVisible = true;
    }
    if (!isFocusVisible || !this.node.animationState)
      return;
    this.node.animationState.setActive("whileFocus", true);
    this.isActive = true;
  }
  onBlur() {
    if (!this.isActive || !this.node.animationState)
      return;
    this.node.animationState.setActive("whileFocus", false);
    this.isActive = false;
  }
  mount() {
    this.unmount = pipe.pipe(addDomEvent.addDomEvent(this.node.current, "focus", () => this.onFocus()), addDomEvent.addDomEvent(this.node.current, "blur", () => this.onBlur()));
  }
  unmount() {
  }
}
exports.FocusGesture = FocusGesture;
//# sourceMappingURL=dist-es-gestures-focus.cjs.map
