import i from "../../../../../../../@base-ui_utils@0.2.4_@types_react@18.3.27_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/utils/esm/formatErrorMessage.js";
class a {
  constructor() {
    this.elements = /* @__PURE__ */ new Set(), this.idMap = /* @__PURE__ */ new Map();
  }
  /**
   * Adds a trigger element with the given ID.
   *
   * Note: The provided element is assumed to not be registered under multiple IDs.
   */
  add(e, t) {
    const s = this.idMap.get(e);
    if (s !== t && (s !== void 0 && this.elements.delete(s), this.elements.add(t), this.idMap.set(e, t), process.env.NODE_ENV !== "production" && this.elements.size !== this.idMap.size))
      throw new Error(process.env.NODE_ENV !== "production" ? "Base UI: A trigger element cannot be registered under multiple IDs in PopupTriggerMap." : i(87));
  }
  /**
   * Removes the trigger element with the given ID.
   */
  delete(e) {
    const t = this.idMap.get(e);
    t && (this.elements.delete(t), this.idMap.delete(e));
  }
  /**
   * Whether the given element is registered as a trigger.
   */
  hasElement(e) {
    return this.elements.has(e);
  }
  /**
   * Whether there is a registered trigger element matching the given predicate.
   */
  hasMatchingElement(e) {
    for (const t of this.elements)
      if (e(t))
        return !0;
    return !1;
  }
  getById(e) {
    return this.idMap.get(e);
  }
  entries() {
    return this.idMap.entries();
  }
  get size() {
    return this.idMap.size;
  }
}
export {
  a as PopupTriggerMap
};
