const d = (r) => {
  const {
    overflowY: t
  } = getComputedStyle(r, null);
  return t !== "visible" && t !== "clip";
};
class c {
  constructor(t, i) {
    this.quill = t, this.boundsContainer = i || document.body, this.root = t.addContainer("ql-tooltip"), this.root.innerHTML = this.constructor.TEMPLATE, d(this.quill.root) && this.quill.root.addEventListener("scroll", () => {
      this.root.style.marginTop = `${-1 * this.quill.root.scrollTop}px`;
    }), this.hide();
  }
  hide() {
    this.root.classList.add("ql-hidden");
  }
  position(t) {
    const i = t.left + t.width / 2 - this.root.offsetWidth / 2, e = t.bottom + this.quill.root.scrollTop;
    this.root.style.left = `${i}px`, this.root.style.top = `${e}px`, this.root.classList.remove("ql-flip");
    const s = this.boundsContainer.getBoundingClientRect(), o = this.root.getBoundingClientRect();
    let l = 0;
    if (o.right > s.right && (l = s.right - o.right, this.root.style.left = `${i + l}px`), o.left < s.left && (l = s.left - o.left, this.root.style.left = `${i + l}px`), o.bottom > s.bottom) {
      const h = o.bottom - o.top, n = t.bottom - t.top + h;
      this.root.style.top = `${e - n}px`, this.root.classList.add("ql-flip");
    }
    return l;
  }
  show() {
    this.root.classList.remove("ql-editing"), this.root.classList.remove("ql-hidden");
  }
}
export {
  c as default
};
