import { identity } from "fp-ts-esm/function";
import { not } from "fp-ts-esm/Predicate";
import { and, or } from "./../../../../index.js";
import { partitionBy } from "../../../node-utils.js";
import { appendChild, hasChild, hasClass, hasTag, isRoot, isText } from "../core/parse5-utils.js";
const addParagraph = (parentNode, attrs = []) => () => ({
  nodeName: "p",
  tagName: "p",
  childNodes: [],
  parentNode,
  attrs: parentNode.attrs ? parentNode.attrs.concat(attrs) : attrs,
  namespaceURI: parentNode.namespaceURI
});
const rootTextToP = [
  // @ts-ignore $TSFixMe
  and([isRoot, or([hasChild(isText), hasChild(hasTag("a"))])]),
  // @ts-ignore $TSFixMe
  (node) => ({
    ...node,
    childNodes: partitionBy(
      // @ts-ignore $TSFixMe
      and([not(isText), not(hasTag("a")), not(hasClass((c) => c === "root-text-anchor"))]),
      // @ts-ignore $TSFixMe
      and([hasTag("p"), hasClass((c) => c === "root-text-anchor")]),
      identity,
      addParagraph(node, [{ name: "class", value: "root-text-anchor" }]),
      // @ts-ignore $TSFixMe
      appendChild
    )(node.childNodes)
  })
];
export {
  addParagraph,
  rootTextToP
};
//# sourceMappingURL=preprocess.js.map
