import { unreachable as b } from "../../../../devlop@1.1.0/node_modules/devlop/lib/default.js";
import { j as a } from "../../../../../../_virtual/jsx-runtime.js";
import "react";
import { unified as O } from "../../../../unified@11.0.5/node_modules/unified/lib/index.js";
import P from "../../../../remark-parse@11.0.0/node_modules/remark-parse/lib/index.js";
import v from "../../../../remark-rehype@11.1.2/node_modules/remark-rehype/lib/index.js";
import { VFile as x } from "../../../../vfile@6.0.3/node_modules/vfile/lib/index.js";
import { visit as E } from "../../../../unist-util-visit@5.0.0/node_modules/unist-util-visit/lib/index.js";
import { toJsxRuntime as j } from "../../../../hast-util-to-jsx-runtime@2.3.6/node_modules/hast-util-to-jsx-runtime/lib/index.js";
import { urlAttributes as c } from "../../../../html-url-attributes@3.0.1/node_modules/html-url-attributes/lib/index.js";
const R = "https://github.com/remarkjs/react-markdown/blob/main/changelog.md", u = [], p = { allowDangerousHtml: !0 }, T = /^(https?|ircs?|mailto|xmpp)$/i, N = [
  { from: "astPlugins", id: "remove-buggy-html-in-markdown-parser" },
  { from: "allowDangerousHtml", id: "remove-buggy-html-in-markdown-parser" },
  {
    from: "allowNode",
    id: "replace-allownode-allowedtypes-and-disallowedtypes",
    to: "allowElement"
  },
  {
    from: "allowedTypes",
    id: "replace-allownode-allowedtypes-and-disallowedtypes",
    to: "allowedElements"
  },
  { from: "className", id: "remove-classname" },
  {
    from: "disallowedTypes",
    id: "replace-allownode-allowedtypes-and-disallowedtypes",
    to: "disallowedElements"
  },
  { from: "escapeHtml", id: "remove-buggy-html-in-markdown-parser" },
  { from: "includeElementIndex", id: "#remove-includeelementindex" },
  {
    from: "includeNodeIndex",
    id: "change-includenodeindex-to-includeelementindex"
  },
  { from: "linkTarget", id: "remove-linktarget" },
  { from: "plugins", id: "change-plugins-to-remarkplugins", to: "remarkPlugins" },
  { from: "rawSourcePos", id: "#remove-rawsourcepos" },
  { from: "renderers", id: "change-renderers-to-components", to: "components" },
  { from: "source", id: "change-source-to-children", to: "children" },
  { from: "sourcePos", id: "#remove-sourcepos" },
  { from: "transformImageUri", id: "#add-urltransform", to: "urlTransform" },
  { from: "transformLinkUri", id: "#add-urltransform", to: "urlTransform" }
];
function z(r) {
  const e = H(r), t = S(r);
  return D(e.runSync(e.parse(t), t), r);
}
function H(r) {
  const e = r.rehypePlugins || u, t = r.remarkPlugins || u, l = r.remarkRehypeOptions ? { ...r.remarkRehypeOptions, ...p } : p;
  return O().use(P).use(t).use(v, l).use(e);
}
function S(r) {
  const e = r.children || "", t = new x();
  return typeof e == "string" && (t.value = e), t;
}
function D(r, e) {
  const t = e.allowedElements, l = e.allowElement, i = e.components, d = e.disallowedElements, g = e.skipHtml, w = e.unwrapDisallowed, h = e.urlTransform || F;
  for (const o of N)
    Object.hasOwn(e, o.from) && b(
      "Unexpected `" + o.from + "` prop, " + (o.to ? "use `" + o.to + "` instead" : "remove it") + " (see <" + R + "#" + o.id + "> for more info)"
    );
  return E(r, y), j(r, {
    Fragment: a.Fragment,
    components: i,
    ignoreInvalidStyle: !0,
    jsx: a.jsx,
    jsxs: a.jsxs,
    passKeys: !0,
    passNode: !0
  });
  function y(o, n, m) {
    if (o.type === "raw" && m && typeof n == "number")
      return g ? m.children.splice(n, 1) : m.children[n] = { type: "text", value: o.value }, n;
    if (o.type === "element") {
      let s;
      for (s in c)
        if (Object.hasOwn(c, s) && Object.hasOwn(o.properties, s)) {
          const k = o.properties[s], f = c[s];
          (f === null || f.includes(o.tagName)) && (o.properties[s] = h(String(k || ""), s, o));
        }
    }
    if (o.type === "element") {
      let s = t ? !t.includes(o.tagName) : d ? d.includes(o.tagName) : !1;
      if (!s && l && typeof n == "number" && (s = !l(o, n, m)), s && m && typeof n == "number")
        return w && o.children ? m.children.splice(n, 1, ...o.children) : m.children.splice(n, 1), n;
    }
  }
}
function F(r) {
  const e = r.indexOf(":"), t = r.indexOf("?"), l = r.indexOf("#"), i = r.indexOf("/");
  return (
    // If there is no protocol, it’s relative.
    e === -1 || // If the first colon is after a `?`, `#`, or `/`, it’s not a protocol.
    i !== -1 && e > i || t !== -1 && e > t || l !== -1 && e > l || // It is a protocol, it should be allowed.
    T.test(r.slice(0, e)) ? r : ""
  );
}
export {
  z as Markdown,
  F as defaultUrlTransform
};
//# sourceMappingURL=index.js.map
