{"version":3,"names":["contains","parent","child","rootNode","getRootNode","ShadowRoot","next","parentNode","host"],"sources":["contains.ts"],"sourcesContent":["/**\n * Shadow-DOM-safe containment check.\n *\n * `Node.contains` does not pierce shadow-root boundaries: a node inside a\n * shadow tree will report `parent.contains(child) === false` even when the\n * shadow host is itself a descendant of `parent`. This helper first tries\n * the native method (fast path) and, if the child is inside a shadow root,\n * walks back up through shadow-host boundaries to check containment.\n */\nexport function contains(\n\tparent?: Element | null,\n\tchild?: Element | null,\n): boolean {\n\tif (!parent || !child) {\n\t\treturn false;\n\t}\n\n\t// First, attempt with the faster native method.\n\tif (parent.contains(child)) {\n\t\treturn true;\n\t}\n\n\t// Then fall back to traversing out of shadow roots when needed.\n\tconst rootNode = child.getRootNode?.();\n\tif (rootNode && rootNode instanceof ShadowRoot) {\n\t\tlet next: Node | null = child;\n\t\twhile (next) {\n\t\t\tif (parent === next) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tnext = next.parentNode ?? (next as ShadowRoot).host ?? null;\n\t\t}\n\t}\n\n\treturn false;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,QAAQA,CACvBC,MAAuB,EACvBC,KAAsB,EACZ;EACV,IAAI,CAACD,MAAM,IAAI,CAACC,KAAK,EAAE;IACtB,OAAO,KAAK;EACb;;EAEA;EACA,IAAID,MAAM,CAACD,QAAQ,CAACE,KAAK,CAAC,EAAE;IAC3B,OAAO,IAAI;EACZ;;EAEA;EACA,MAAMC,QAAQ,GAAGD,KAAK,CAACE,WAAW,GAAG,CAAC;EACtC,IAAID,QAAQ,IAAIA,QAAQ,YAAYE,UAAU,EAAE;IAC/C,IAAIC,IAAiB,GAAGJ,KAAK;IAC7B,OAAOI,IAAI,EAAE;MACZ,IAAIL,MAAM,KAAKK,IAAI,EAAE;QACpB,OAAO,IAAI;MACZ;MACAA,IAAI,GAAGA,IAAI,CAACC,UAAU,IAAKD,IAAI,CAAgBE,IAAI,IAAI,IAAI;IAC5D;EACD;EAEA,OAAO,KAAK;AACb","ignoreList":[]}