const e={false:"push",true:"unshift"},n=Object.prototype.hasOwnProperty,t=(e,t,r)=>{let i=e,l=2;if(r&&n.call(t,i))throw Error(`User defined id attribute '${e}' is NOT unique. Please fix it in your markdown to continue.`);for(;n.call(t,i);)i=`${e}-${l++}`;return t[i]=!0,i},r=(e,n)=>{n=Object.assign({},r.defaults,n),e.core.ruler.push("anchor",e=>{const r={},i=e.tokens,l=Array.isArray(n.level)?(o=n.level,e=>o.includes(e)):(e=>n=>n>=e)(n.level);var o;i.filter(e=>"heading_open"===e.type).filter(e=>l(Number(e.tag.substr(1)))).forEach(l=>{const o=i[i.indexOf(l)+1].children.filter(e=>"text"===e.type||"code_inline"===e.type).reduce((e,n)=>e+n.content,"");let a=l.attrGet("id");a=null==a?t(n.slugify(o),r,!1):t(a,r,!0),l.attrSet("id",a),n.permalink&&n.renderPermalink(a,n,e,i.indexOf(l)),n.callback&&n.callback(l,{slug:a,title:o})})})};r.defaults={level:1,slugify:e=>encodeURIComponent(String(e).trim().toLowerCase().replace(/\s+/g,"-")),permalink:!1,renderPermalink:(n,t,r,i)=>{const l=[Object.assign(new r.Token("link_open","a",1),{attrs:[["class",t.permalinkClass],["href",t.permalinkHref(n,r)],...Object.entries(t.permalinkAttrs(n,r))]}),Object.assign(new r.Token("html_block","",0),{content:t.permalinkSymbol}),new r.Token("link_close","a",-1)];t.permalinkSpace&&l[e[!t.permalinkBefore]](Object.assign(new r.Token("text","",0),{content:" "})),r.tokens[i+1].children[e[t.permalinkBefore]](...l)},permalinkClass:"header-anchor",permalinkSpace:!0,permalinkSymbol:"¶",permalinkBefore:!1,permalinkHref:e=>"#"+e,permalinkAttrs:e=>({})};export default r;
//# sourceMappingURL=markdownItAnchor.modern.js.map
