/* esm.sh - mdast-util-gfm-footnote@2.1.0 */
import{ok as a}from"../../devlop@^1.1.0?target=es2022";import{normalizeIdentifier as s}from"../../micromark-util-normalize-identifier@^2.0.0?target=es2022";u.peek=S;function F(){this.buffer()}function b(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function k(){this.buffer()}function d(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function x(e){let o=this.resume(),t=this.stack[this.stack.length-1];a(t.type==="footnoteReference"),t.identifier=s(this.sliceSerialize(e)).toLowerCase(),t.label=o}function p(e){this.exit(e)}function D(e){let o=this.resume(),t=this.stack[this.stack.length-1];a(t.type==="footnoteDefinition"),t.identifier=s(this.sliceSerialize(e)).toLowerCase(),t.label=o}function C(e){this.exit(e)}function S(){return"["}function u(e,o,t,r){let l=t.createTracker(r),n=l.move("[^"),c=t.enter("footnoteReference"),i=t.enter("reference");return n+=l.move(t.safe(t.associationId(e),{after:"]",before:n})),i(),c(),n+=l.move("]"),n}function v(){return{enter:{gfmFootnoteCallString:F,gfmFootnoteCall:b,gfmFootnoteDefinitionLabelString:k,gfmFootnoteDefinition:d},exit:{gfmFootnoteCallString:x,gfmFootnoteCall:p,gfmFootnoteDefinitionLabelString:D,gfmFootnoteDefinition:C}}}function L(e){let o=!1;return e&&e.firstLineBlank&&(o=!0),{handlers:{footnoteDefinition:t,footnoteReference:u},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function t(r,l,n,c){let i=n.createTracker(c),f=i.move("[^"),g=n.enter("footnoteDefinition"),h=n.enter("label");return f+=i.move(n.safe(n.associationId(r),{before:f,after:"]"})),h(),f+=i.move("]:"),r.children&&r.children.length>0&&(i.shift(4),f+=i.move((o?`
`:" ")+n.indentLines(n.containerFlow(r,i.current()),o?m:w))),g(),f}}function w(e,o,t){return o===0?e:m(e,o,t)}function m(e,o,t){return(t?"":"    ")+e}export{v as gfmFootnoteFromMarkdown,L as gfmFootnoteToMarkdown};
//# sourceMappingURL=mdast-util-gfm-footnote.mjs.map