'use strict';

var jsxRuntime = require('react/jsx-runtime');
var ReactMarkdown = require('react-markdown');
var remarkGfm = require('remark-gfm');
var remarkEmoji = require('remark-emoji');
var react = require('@chakra-ui/react');
var CodeBlock = require('../CodeBlock/CodeBlock.cjs');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var ReactMarkdown__default = /*#__PURE__*/_interopDefaultLegacy(ReactMarkdown);
var remarkGfm__default = /*#__PURE__*/_interopDefaultLegacy(remarkGfm);
var remarkEmoji__default = /*#__PURE__*/_interopDefaultLegacy(remarkEmoji);

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__ */ jsxRuntime.jsx(react.chakra.a, __spreadValues({}, props)),
  abbr: (props) => /* @__PURE__ */ jsxRuntime.jsx(react.chakra.abbr, __spreadValues({}, props)),
  address: (props) => /* @__PURE__ */ jsxRuntime.jsx(react.chakra.address, __spreadValues({}, props)),
  area: () => null,
  // Area has no markdown equivalent
  article: (props) => /* @__PURE__ */ jsxRuntime.jsx(react.chakra.article, __spreadValues({}, props)),
  aside: (props) => /* @__PURE__ */ jsxRuntime.jsx(react.chakra.aside, __spreadValues({}, props)),
  audio: ({ src, controls }) => /* @__PURE__ */ jsxRuntime.jsx(react.chakra.audio, { src, controls }),
  b: (props) => /* @__PURE__ */ jsxRuntime.jsx(react.chakra.b, __spreadValues({}, props)),
  base: () => null,
  // Base has no markdown equivalent
  bdi: (props) => /* @__PURE__ */ jsxRuntime.jsx(react.chakra.bdi, __spreadValues({}, props)),
  bdo: (props) => /* @__PURE__ */ jsxRuntime.jsx(react.chakra.bdo, __spreadValues({}, props)),
  big: (props) => /* @__PURE__ */ jsxRuntime.jsx(react.chakra.big, __spreadValues({}, props)),
  blockquote: (props) => /* @__PURE__ */ jsxRuntime.jsx(react.chakra.blockquote, __spreadValues({}, props)),
  body: (props) => /* @__PURE__ */ jsxRuntime.jsx(react.chakra.body, __spreadValues({}, props)),
  br: () => /* @__PURE__ */ jsxRuntime.jsx(react.chakra.br, {}),
  button: (props) => /* @__PURE__ */ jsxRuntime.jsx(react.Button, __spreadValues({}, props)),
  canvas: () => null,
  // Canvas has no markdown equivalent
  caption: (props) => /* @__PURE__ */ jsxRuntime.jsx(react.chakra.caption, __spreadValues({}, props)),
  cite: (props) => /* @__PURE__ */ jsxRuntime.jsx(react.chakra.cite, __spreadValues({}, props)),
  col: () => null,
  // Col has no markdown equivalent
  colgroup: () => null,
  // Colgroup has no markdown equivalent
  data: ({ value }) => /* @__PURE__ */ jsxRuntime.jsx(react.chakra.data, { value }),
  datalist: (props) => /* @__PURE__ */ jsxRuntime.jsx(react.chakra.datalist, __spreadValues({}, props)),
  dd: (props) => /* @__PURE__ */ jsxRuntime.jsx(react.chakra.dd, __spreadValues({}, props)),
  del: (props) => /* @__PURE__ */ jsxRuntime.jsx(react.chakra.del, __spreadValues({}, props)),
  details: (props) => /* @__PURE__ */ jsxRuntime.jsx(react.chakra.details, __spreadValues({}, props)),
  dfn: (props) => /* @__PURE__ */ jsxRuntime.jsx(react.chakra.dfn, __spreadValues({}, props)),
  dialog: (props) => /* @__PURE__ */ jsxRuntime.jsx(react.chakra.dialog, __spreadValues({}, props)),
  div: (props) => /* @__PURE__ */ jsxRuntime.jsx(react.Box, __spreadValues({}, props)),
  dl: (props) => /* @__PURE__ */ jsxRuntime.jsx(react.chakra.dl, __spreadValues({}, props)),
  dt: (props) => /* @__PURE__ */ jsxRuntime.jsx(react.chakra.dt, __spreadValues({}, props)),
  em: (props) => /* @__PURE__ */ jsxRuntime.jsx(react.chakra.em, __spreadValues({}, props)),
  embed: () => null,
  // Embed has no markdown equivalent
  fieldset: (props) => /* @__PURE__ */ jsxRuntime.jsx(react.chakra.fieldset, __spreadValues({}, props)),
  figcaption: (props) => /* @__PURE__ */ jsxRuntime.jsx(react.chakra.figcaption, __spreadValues({}, props)),
  figure: (props) => /* @__PURE__ */ jsxRuntime.jsx(react.chakra.figure, __spreadValues({}, props)),
  footer: (props) => /* @__PURE__ */ jsxRuntime.jsx(react.chakra.footer, __spreadValues({}, props)),
  head: () => null,
  // Head has no markdown equivalent
  header: (props) => /* @__PURE__ */ jsxRuntime.jsx(react.chakra.header, __spreadValues({}, props)),
  hr: () => /* @__PURE__ */ jsxRuntime.jsx(react.chakra.hr, {}),
  html: (props) => /* @__PURE__ */ jsxRuntime.jsx(react.chakra.html, __spreadValues({}, props)),
  strong: (props) => /* @__PURE__ */ jsxRuntime.jsx(react.Text, __spreadValues({ as: "strong" }, props)),
  table: (props) => /* @__PURE__ */ jsxRuntime.jsx(react.Table, __spreadValues({}, props)),
  thead: (props) => /* @__PURE__ */ jsxRuntime.jsx(react.chakra.thead, __spreadValues({}, props)),
  tbody: (props) => /* @__PURE__ */ jsxRuntime.jsx(react.chakra.tbody, __spreadValues({}, props)),
  tr: (props) => /* @__PURE__ */ jsxRuntime.jsx(react.chakra.tr, __spreadValues({}, props)),
  th: (props) => /* @__PURE__ */ jsxRuntime.jsx(react.chakra.th, __spreadValues({}, props)),
  td: (props) => /* @__PURE__ */ jsxRuntime.jsx(react.chakra.td, __spreadValues({}, props)),
  img: (props) => /* @__PURE__ */ jsxRuntime.jsx(react.Image, __spreadValues({}, props))
};
const specialComponents = {
  h1: (props) => /* @__PURE__ */ jsxRuntime.jsx(react.Heading, __spreadValues({ as: "h1", size: "xl" }, props)),
  h2: (props) => /* @__PURE__ */ jsxRuntime.jsx(react.Heading, __spreadValues({ as: "h2", size: "lg" }, props)),
  h3: (props) => /* @__PURE__ */ jsxRuntime.jsx(react.Heading, __spreadValues({ as: "h3", size: "md" }, props)),
  h4: (props) => /* @__PURE__ */ jsxRuntime.jsx(react.Heading, __spreadValues({ as: "h4", size: "sm" }, props)),
  h5: (props) => /* @__PURE__ */ jsxRuntime.jsx(react.Heading, __spreadValues({ as: "h5", size: "xs" }, props)),
  h6: (props) => /* @__PURE__ */ jsxRuntime.jsx(react.Text, __spreadValues({ as: "h6" }, props)),
  li: (props) => /* @__PURE__ */ jsxRuntime.jsx(react.ListItem, __spreadValues({}, props)),
  ol: (props) => /* @__PURE__ */ jsxRuntime.jsx(react.OrderedList, __spreadValues({}, props)),
  td: (props) => /* @__PURE__ */ jsxRuntime.jsx(react.chakra.td, __spreadValues({}, props)),
  th: (props) => /* @__PURE__ */ jsxRuntime.jsx(react.chakra.th, __spreadValues({}, props)),
  tr: (props) => /* @__PURE__ */ jsxRuntime.jsx(react.chakra.tr, __spreadValues({}, props)),
  ul: (props) => /* @__PURE__ */ jsxRuntime.jsx(react.UnorderedList, __spreadValues({}, props))
};
const Markdown = (_a) => {
  var _b = _a, { children, theme } = _b, otherProps = __objRest(_b, ["children", "theme"]);
  return /* @__PURE__ */ jsxRuntime.jsx(
    ReactMarkdown__default["default"],
    {
      remarkPlugins: [remarkGfm__default["default"], remarkEmoji__default["default"]],
      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__ */ jsxRuntime.jsx(
            CodeBlock,
            __spreadProps(__spreadValues({}, otherProps), {
              theme,
              language: match[1],
              codeString: String(children2).replace(/\n$/, "")
            })
          ) : /* @__PURE__ */ jsxRuntime.jsx(react.chakra.code, __spreadProps(__spreadValues({}, props), { className, children: children2 }));
        }
      }),
      children
    }
  );
};

module.exports = Markdown;
//# sourceMappingURL=Markdown.cjs.map
