text: "use strict";
  Object.defineProperty(exports, "__esModule", { value: true });
  exports.Connector = void 0;
  const Utils_1 = require("../../../Utils");
  const Enums_1 = require("../../../Enums");
  const ExternalInteractorBase_1 = require("../../../Core/ExternalInteractorBase");
  class Connector extends ExternalInteractorBase_1.ExternalInteractorBase {
      constructor(container) {
          super(container);
      }
      isEnabled() {
          const container = this.container, mouse = container.interactivity.mouse, events = container.actualOptions.interactivity.events;
          if (!(events.onHover.enable && mouse.position)) {
              return false;
          }
          return (0, Utils_1.isInArray)(Enums_1.HoverMode.connect, events.onHover.mode);
      }
      reset() {
      }
      interact() {
          const container = this.container, options = container.actualOptions;
          if (options.interactivity.events.onHover.enable && container.interactivity.status === "mousemove") {
              const mousePos = container.interactivity.mouse.position;
              if (!mousePos) {
                  return;
              }
              const distance = Math.abs(container.retina.connectModeRadius), query = container.particles.quadTree.queryCircle(mousePos, distance);
              let i = 0;
              for (const p1 of query) {
                  const pos1 = p1.getPosition();
                  for (const p2 of query.slice(i + 1)) {
                      const pos2 = p2.getPosition(), distMax = Math.abs(container.retina.connectModeDistance), xDiff = Math.abs(pos1.x - pos2.x), yDiff = Math.abs(pos1.y - pos2.y);
                      if (xDiff < distMax && yDiff < distMax) {
                          container.canvas.drawConnectLine(p1, p2);
                      }
                  }
                  ++i;
              }
          }
      }
  }
  exports.Connector = Connector;
  