{"version":3,"file":"findComment.cjs","sources":["../../src/utils/findComment.js"],"sourcesContent":["/**\n * Finds the first comment node whose text matches exactly the given `text`.\n * Uses manual DOM traversal. Skips entire subtrees if `shouldSkip(element)` returns true.\n * Starts searching from `startNode` if provided, otherwise from `root.firstChild`.\n * @param {Node} root - Root node or fragment that limits the search scope.\n * @param {string} text - Exact comment text to match.\n * @param {Function} [shouldSkip] - Function that receives an element and returns true if its subtree should be skipped.\n * @param {Node} [startNode] - Node to start searching from (defaults to root.firstChild).\n * @return {Comment|null} The first matching comment node, or null if not found.\n * @module\n * @private\n */\nexport default function findComment(\n    root,\n    text,\n    shouldSkip = () => false,\n    startNode\n) {\n    let node = startNode || root.firstChild;\n\n    while (node) {\n        // Check if current node is a comment with matching text.\n        if (node.nodeType === Node.COMMENT_NODE && node.data.trim() === text) {\n            return node;\n        }\n        // Descend into children if allowed and present.\n        if (node.nodeType === Node.ELEMENT_NODE && !shouldSkip(node) && node.firstChild) {\n            node = node.firstChild;\n            continue;\n        }\n        // Move to next sibling, or climb up until a sibling is found.\n        while (node && !node.nextSibling) {\n            node = node.parentNode;\n            if (!node || node === root) return null;\n        }\n        if (node) node = node.nextSibling;\n    }\n\n    return null;\n}\n"],"names":[],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAAS,WAAW;AACnC,IAAI,IAAI;AACR,IAAI,IAAI;AACR,IAAI,UAAU,GAAG,MAAM,KAAK;AAC5B,IAAI;AACJ,EAAE;AACF,IAAI,IAAI,IAAI,GAAG,SAAS,IAAI,IAAI,CAAC,UAAU;;AAE3C,IAAI,OAAO,IAAI,EAAE;AACjB;AACA,QAAQ,IAAI,IAAI,CAAC,QAAQ,KAAK,IAAI,CAAC,YAAY,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,IAAI,EAAE;AAC9E,YAAY,OAAO,IAAI;AACvB,QAAQ;AACR;AACA,QAAQ,IAAI,IAAI,CAAC,QAAQ,KAAK,IAAI,CAAC,YAAY,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,UAAU,EAAE;AACzF,YAAY,IAAI,GAAG,IAAI,CAAC,UAAU;AAClC,YAAY;AACZ,QAAQ;AACR;AACA,QAAQ,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;AAC1C,YAAY,IAAI,GAAG,IAAI,CAAC,UAAU;AAClC,YAAY,IAAI,CAAC,IAAI,IAAI,IAAI,KAAK,IAAI,EAAE,OAAO,IAAI;AACnD,QAAQ;AACR,QAAQ,IAAI,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC,WAAW;AACzC,IAAI;;AAEJ,IAAI,OAAO,IAAI;AACf;;;;"}