"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// packages/editor/src/components/collaborators-overlay/cursor-registry.ts
var cursor_registry_exports = {};
__export(cursor_registry_exports, {
  createCursorRegistry: () => createCursorRegistry
});
module.exports = __toCommonJS(cursor_registry_exports);
function highlightCursor(element, duration) {
  element.classList.add("collaborators-overlay-cursor-highlighted");
  setTimeout(() => {
    element.classList.remove("collaborators-overlay-cursor-highlighted");
  }, duration);
}
function createCursorRegistry() {
  const cursorMap = /* @__PURE__ */ new Map();
  return {
    /**
     * Register a cursor element when it's created.
     *
     * @param clientId - The clientId of the cursor to register.
     * @param element  - The cursor element to register.
     */
    registerCursor(clientId, element) {
      cursorMap.set(clientId, element);
    },
    /**
     * Unregister a cursor element when it's removed.
     *
     * @param clientId - The clientId of the cursor to unregister.
     */
    unregisterCursor(clientId) {
      cursorMap.delete(clientId);
    },
    /**
     * Scroll to a cursor by clientId.
     *
     * @param clientId - The clientId of the cursor to scroll to.
     * @param options  - The options for the scroll.
     * @return true if cursor was found and scrolled to, false otherwise.
     */
    scrollToCursor(clientId, options) {
      const cursorElement = cursorMap.get(clientId);
      if (!cursorElement) {
        return false;
      }
      cursorElement.scrollIntoView({
        behavior: options?.behavior ?? "smooth",
        block: options?.block ?? "center",
        inline: options?.inline ?? "nearest"
      });
      if (options?.highlightDuration) {
        highlightCursor(cursorElement, options.highlightDuration);
      }
      return true;
    },
    /**
     * Clear the registry.
     */
    removeAll() {
      cursorMap.clear();
    }
  };
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  createCursorRegistry
});
//# sourceMappingURL=cursor-registry.cjs.map
