"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=require("../../../../escape-string-regexp@5.0.0/node_modules/escape-string-regexp/index.cjs.js"),m=require("../../../../unist-util-is@6.0.1/node_modules/unist-util-is/lib/index.cjs.js"),q=require("../../../../unist-util-visit-parents@6.0.2/node_modules/unist-util-visit-parents/lib/index.cjs.js");function I(e,a,f){const d=f||{},h=m.convert(d.ignore||[]),x=P(a);let p=-1;for(;++p<x.length;)q.visitParents(e,"text",b);function b(t,l){let o=-1,n;for(;++o<l.length;){const u=l[o],r=n?n.children:void 0;if(h(u,r?r.indexOf(u):void 0,n))return;n=u}if(n)return A(t,l)}function A(t,l){const o=l[l.length-1],n=x[p][0],u=x[p][1];let r=0;const y=o.children.indexOf(t);let v=!1,s=[];n.lastIndex=0;let c=n.exec(t.value);for(;c;){const g=c.index,w={index:c.index,input:c.input,stack:[...l,t]};let i=u(...c,w);if(typeof i=="string"&&(i=i.length>0?{type:"text",value:i}:void 0),i===!1?n.lastIndex=g+1:(r!==g&&s.push({type:"text",value:t.value.slice(r,g)}),Array.isArray(i)?s.push(...i):i&&s.push(i),r=g+c[0].length,v=!0),!n.global)break;c=n.exec(t.value)}return v?(r<t.value.length&&s.push({type:"text",value:t.value.slice(r)}),o.children.splice(y,1,...s)):s=[t],y+s.length}}function P(e){const a=[];if(!Array.isArray(e))throw new TypeError("Expected find and replace tuple or list of tuples");const f=!e[0]||Array.isArray(e[0])?e:[e];let d=-1;for(;++d<f.length;){const h=f[d];a.push([R(h[0]),j(h[1])])}return a}function R(e){return typeof e=="string"?new RegExp(E(e),"g"):e}function j(e){return typeof e=="function"?e:function(){return e}}exports.findAndReplace=I;
//# sourceMappingURL=index.cjs.js.map
