import { jsx } from 'react/jsx-runtime';
import ReactMarkdown from 'react-markdown';
import remarkGfm from 'remark-gfm';
import remarkEmoji from 'remark-emoji';
import { chakra, Button, Box, Text, Table, Image, Heading, ListItem, OrderedList, UnorderedList } from '@chakra-ui/react';
import CodeBlock from '../CodeBlock/CodeBlock.js';

var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
  for (var prop in b || (b = {}))
    if (__hasOwnProp.call(b, prop))
      __defNormalProp(a, prop, b[prop]);
  if (__getOwnPropSymbols)
    for (var prop of __getOwnPropSymbols(b)) {
      if (__propIsEnum.call(b, prop))
        __defNormalProp(a, prop, b[prop]);
    }
  return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
var __objRest = (source, exclude) => {
  var target = {};
  for (var prop in source)
    if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
      target[prop] = source[prop];
  if (source != null && __getOwnPropSymbols)
    for (var prop of __getOwnPropSymbols(source)) {
      if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
        target[prop] = source[prop];
    }
  return target;
};
const intrinsicComponents = {
  a: (props) => /* @__PURE__ */ jsx(chakra.a, __spreadValues({}, props)),
  abbr: (props) => /* @__PURE__ */ jsx(chakra.abbr, __spreadValues({}, props)),
  address: (props) => /* @__PURE__ */ jsx(chakra.address, __spreadValues({}, props)),
  area: () => null,
  // Area has no markdown equivalent
  article: (props) => /* @__PURE__ */ jsx(chakra.article, __spreadValues({}, props)),
  aside: (props) => /* @__PURE__ */ jsx(chakra.aside, __spreadValues({}, props)),
  audio: ({ src, controls }) => /* @__PURE__ */ jsx(chakra.audio, { src, controls }),
  b: (props) => /* @__PURE__ */ jsx(chakra.b, __spreadValues({}, props)),
  base: () => null,
  // Base has no markdown equivalent
  bdi: (props) => /* @__PURE__ */ jsx(chakra.bdi, __spreadValues({}, props)),
  bdo: (props) => /* @__PURE__ */ jsx(chakra.bdo, __spreadValues({}, props)),
  big: (props) => /* @__PURE__ */ jsx(chakra.big, __spreadValues({}, props)),
  blockquote: (props) => /* @__PURE__ */ jsx(chakra.blockquote, __spreadValues({}, props)),
  body: (props) => /* @__PURE__ */ jsx(chakra.body, __spreadValues({}, props)),
  br: () => /* @__PURE__ */ jsx(chakra.br, {}),
  button: (props) => /* @__PURE__ */ jsx(Button, __spreadValues({}, props)),
  canvas: () => null,
  // Canvas has no markdown equivalent
  caption: (props) => /* @__PURE__ */ jsx(chakra.caption, __spreadValues({}, props)),
  cite: (props) => /* @__PURE__ */ jsx(chakra.cite, __spreadValues({}, props)),
  col: () => null,
  // Col has no markdown equivalent
  colgroup: () => null,
  // Colgroup has no markdown equivalent
  data: ({ value }) => /* @__PURE__ */ jsx(chakra.data, { value }),
  datalist: (props) => /* @__PURE__ */ jsx(chakra.datalist, __spreadValues({}, props)),
  dd: (props) => /* @__PURE__ */ jsx(chakra.dd, __spreadValues({}, props)),
  del: (props) => /* @__PURE__ */ jsx(chakra.del, __spreadValues({}, props)),
  details: (props) => /* @__PURE__ */ jsx(chakra.details, __spreadValues({}, props)),
  dfn: (props) => /* @__PURE__ */ jsx(chakra.dfn, __spreadValues({}, props)),
  dialog: (props) => /* @__PURE__ */ jsx(chakra.dialog, __spreadValues({}, props)),
  div: (props) => /* @__PURE__ */ jsx(Box, __spreadValues({}, props)),
  dl: (props) => /* @__PURE__ */ jsx(chakra.dl, __spreadValues({}, props)),
  dt: (props) => /* @__PURE__ */ jsx(chakra.dt, __spreadValues({}, props)),
  em: (props) => /* @__PURE__ */ jsx(chakra.em, __spreadValues({}, props)),
  embed: () => null,
  // Embed has no markdown equivalent
  fieldset: (props) => /* @__PURE__ */ jsx(chakra.fieldset, __spreadValues({}, props)),
  figcaption: (props) => /* @__PURE__ */ jsx(chakra.figcaption, __spreadValues({}, props)),
  figure: (props) => /* @__PURE__ */ jsx(chakra.figure, __spreadValues({}, props)),
  footer: (props) => /* @__PURE__ */ jsx(chakra.footer, __spreadValues({}, props)),
  head: () => null,
  // Head has no markdown equivalent
  header: (props) => /* @__PURE__ */ jsx(chakra.header, __spreadValues({}, props)),
  hr: () => /* @__PURE__ */ jsx(chakra.hr, {}),
  html: (props) => /* @__PURE__ */ jsx(chakra.html, __spreadValues({}, props)),
  strong: (props) => /* @__PURE__ */ jsx(Text, __spreadValues({ as: "strong" }, props)),
  table: (props) => /* @__PURE__ */ jsx(Table, __spreadValues({}, props)),
  thead: (props) => /* @__PURE__ */ jsx(chakra.thead, __spreadValues({}, props)),
  tbody: (props) => /* @__PURE__ */ jsx(chakra.tbody, __spreadValues({}, props)),
  tr: (props) => /* @__PURE__ */ jsx(chakra.tr, __spreadValues({}, props)),
  th: (props) => /* @__PURE__ */ jsx(chakra.th, __spreadValues({}, props)),
  td: (props) => /* @__PURE__ */ jsx(chakra.td, __spreadValues({}, props)),
  img: (props) => /* @__PURE__ */ jsx(Image, __spreadValues({}, props))
};
const specialComponents = {
  h1: (props) => /* @__PURE__ */ jsx(Heading, __spreadValues({ as: "h1", size: "xl" }, props)),
  h2: (props) => /* @__PURE__ */ jsx(Heading, __spreadValues({ as: "h2", size: "lg" }, props)),
  h3: (props) => /* @__PURE__ */ jsx(Heading, __spreadValues({ as: "h3", size: "md" }, props)),
  h4: (props) => /* @__PURE__ */ jsx(Heading, __spreadValues({ as: "h4", size: "sm" }, props)),
  h5: (props) => /* @__PURE__ */ jsx(Heading, __spreadValues({ as: "h5", size: "xs" }, props)),
  h6: (props) => /* @__PURE__ */ jsx(Text, __spreadValues({ as: "h6" }, props)),
  li: (props) => /* @__PURE__ */ jsx(ListItem, __spreadValues({}, props)),
  ol: (props) => /* @__PURE__ */ jsx(OrderedList, __spreadValues({}, props)),
  td: (props) => /* @__PURE__ */ jsx(chakra.td, __spreadValues({}, props)),
  th: (props) => /* @__PURE__ */ jsx(chakra.th, __spreadValues({}, props)),
  tr: (props) => /* @__PURE__ */ jsx(chakra.tr, __spreadValues({}, props)),
  ul: (props) => /* @__PURE__ */ jsx(UnorderedList, __spreadValues({}, props))
};
const Markdown = (_a) => {
  var _b = _a, { children, theme } = _b, otherProps = __objRest(_b, ["children", "theme"]);
  return /* @__PURE__ */ jsx(
    ReactMarkdown,
    {
      remarkPlugins: [remarkGfm, remarkEmoji],
      components: __spreadProps(__spreadValues(__spreadValues({}, intrinsicComponents), specialComponents), {
        code(_a2) {
          var _b2 = _a2, { node, inline, className, children: children2 } = _b2, props = __objRest(_b2, ["node", "inline", "className", "children"]);
          const match = /language-(\w+)/.exec(className || "");
          return !inline && match ? /* @__PURE__ */ jsx(
            CodeBlock,
            __spreadProps(__spreadValues({}, otherProps), {
              theme,
              language: match[1],
              codeString: String(children2).replace(/\n$/, "")
            })
          ) : /* @__PURE__ */ jsx(chakra.code, __spreadProps(__spreadValues({}, props), { className, children: children2 }));
        }
      }),
      children
    }
  );
};

export { Markdown as default };
//# sourceMappingURL=Markdown.js.map
