import { defineComponent, computed, createElementBlock, createCommentVNode, openBlock, Fragment, renderList, createBlock } from "vue";
import { splitContent, getHeadings, isHeading, textFromNode } from "@scalar/code-highlight/markdown";
import GitHubSlugger from "github-slugger";
import _sfc_main$1 from "./InfoMarkdownSection.vue.js";
const _hoisted_1 = {
  key: 0,
  class: "introduction-description mt-6 flex flex-col"
};
const _sfc_main = /* @__PURE__ */ defineComponent({
  __name: "InfoDescription",
  props: {
    eventBus: {},
    headingSlugGenerator: { type: Function },
    description: {}
  },
  setup(__props) {
    const sections = computed(() => {
      if (!__props.description) {
        return [];
      }
      const slugger = new GitHubSlugger();
      const items = splitContent(__props.description).map((markdown) => {
        const headings = getHeadings(markdown);
        const heading = headings[0];
        const id = heading ? __props.headingSlugGenerator({
          ...heading,
          slug: slugger.slug(heading.value)
        }) : void 0;
        return {
          id,
          content: markdown
        };
      });
      return items;
    });
    const transformHeading = (node) => {
      if (!isHeading(node)) {
        return node;
      }
      const slugger = new GitHubSlugger();
      const value = textFromNode(node);
      node.data = {
        hProperties: {
          id: __props.headingSlugGenerator({
            depth: node.depth,
            value,
            slug: slugger.slug(value)
          })
        }
      };
      return node;
    };
    return (_ctx, _cache) => {
      return __props.description ? (openBlock(), createElementBlock("div", _hoisted_1, [
        (openBlock(true), createElementBlock(Fragment, null, renderList(sections.value, (section) => {
          return openBlock(), createBlock(_sfc_main$1, {
            id: section.id,
            key: section.id,
            content: section.content,
            eventBus: __props.eventBus,
            transformHeading
          }, null, 8, ["id", "content", "eventBus"]);
        }), 128))
      ])) : createCommentVNode("", true);
    };
  }
});
export {
  _sfc_main as default
};
