"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var preprocess_exports = {};
__export(preprocess_exports, {
  addParagraph: () => addParagraph,
  rootTextToP: () => rootTextToP
});
module.exports = __toCommonJS(preprocess_exports);
var import_function = require("fp-ts-esm/function");
var import_Predicate = require("fp-ts-esm/Predicate");
var import__ = require("./../../../../index.js");
var import_node_utils = require("../../../node-utils.js");
var import_parse5_utils = require("../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
  (0, import__.and)([import_parse5_utils.isRoot, (0, import__.or)([(0, import_parse5_utils.hasChild)(import_parse5_utils.isText), (0, import_parse5_utils.hasChild)((0, import_parse5_utils.hasTag)("a"))])]),
  // @ts-ignore $TSFixMe
  (node) => ({
    ...node,
    childNodes: (0, import_node_utils.partitionBy)(
      // @ts-ignore $TSFixMe
      (0, import__.and)([(0, import_Predicate.not)(import_parse5_utils.isText), (0, import_Predicate.not)((0, import_parse5_utils.hasTag)("a")), (0, import_Predicate.not)((0, import_parse5_utils.hasClass)((c) => c === "root-text-anchor"))]),
      // @ts-ignore $TSFixMe
      (0, import__.and)([(0, import_parse5_utils.hasTag)("p"), (0, import_parse5_utils.hasClass)((c) => c === "root-text-anchor")]),
      import_function.identity,
      addParagraph(node, [{ name: "class", value: "root-text-anchor" }]),
      // @ts-ignore $TSFixMe
      import_parse5_utils.appendChild
    )(node.childNodes)
  })
];
//# sourceMappingURL=preprocess.js.map
