"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("../util/encode-character-reference.cjs.js"),x=require("../util/format-heading-as-setext.cjs.js");function d(r,l,e,o){const i=Math.max(Math.min(6,r.depth||1),1),c=e.createTracker(o);if(x.formatHeadingAsSetext(r,e)){const f=e.enter("headingSetext"),u=e.enter("phrasing"),a=e.containerPhrasing(r,{...c.current(),before:`
`,after:`
`});return u(),f(),a+`
`+(i===1?"=":"-").repeat(a.length-(Math.max(a.lastIndexOf("\r"),a.lastIndexOf(`
`))+1))}const t="#".repeat(i),s=e.enter("headingAtx"),h=e.enter("phrasing");c.move(t+" ");let n=e.containerPhrasing(r,{before:"# ",after:`
`,...c.current()});return/^[\t ]/.test(n)&&(n=g.encodeCharacterReference(n.charCodeAt(0))+n.slice(1)),n=n?t+" "+n:t,e.options.closeAtx&&(n+=" "+t),h(),s(),n}exports.heading=d;
//# sourceMappingURL=heading.cjs.js.map
