{"version":3,"sources":["../../../src/context/mountPointScopes.ts"],"sourcesContent":["import type { OutletStore } from './OutletStore';\n\nconst scopes = new WeakMap<Element, OutletStore>();\n\n/** Remembers which outlet scope a mount point belongs to, so outlets the engine opens inside it can find their host. */\nexport const registerMountPoint = (element: Element, outlets: OutletStore) => {\n  scopes.set(element, outlets);\n\n  return () => {\n    scopes.delete(element);\n  };\n};\n\n/**\n * The scope that owns an outlet the engine rendered at `element`: the one of the nearest mount point around it.\n *\n * Icon overrides are adapted once, in `NovuUI`, so they cannot know which component the engine will render them\n * for; an icon inside `<Bell />` must still be hosted beneath `Bell`, or a wrapper around the bell never sees its\n * clicks. Outlets outside every mount point, such as those inside the engine's own popover, use `fallback`.\n */\nexport const outletScopeFor = (element: Element, fallback: OutletStore): OutletStore => {\n  let node: Node | null = element;\n\n  while (node) {\n    if (node instanceof Element) {\n      const scope = scopes.get(node);\n      if (scope) {\n        return scope;\n      }\n    }\n\n    node = node instanceof ShadowRoot ? node.host : node.parentNode;\n  }\n\n  return fallback;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,IAAM,SAAS,oBAAI,QAA8B;AAG1C,IAAM,qBAAqB,CAAC,SAAkB,YAAyB;AAC5E,SAAO,IAAI,SAAS,OAAO;AAE3B,SAAO,MAAM;AACX,WAAO,OAAO,OAAO;AAAA,EACvB;AACF;AASO,IAAM,iBAAiB,CAAC,SAAkB,aAAuC;AACtF,MAAI,OAAoB;AAExB,SAAO,MAAM;AACX,QAAI,gBAAgB,SAAS;AAC3B,YAAM,QAAQ,OAAO,IAAI,IAAI;AAC7B,UAAI,OAAO;AACT,eAAO;AAAA,MACT;AAAA,IACF;AAEA,WAAO,gBAAgB,aAAa,KAAK,OAAO,KAAK;AAAA,EACvD;AAEA,SAAO;AACT;","names":[]}