"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const index = require("../micromark-util-chunked/index.cjs");
const hasOwnProperty = {}.hasOwnProperty;
function combineExtensions(extensions) {
  const all = {};
  let index2 = -1;
  while (++index2 < extensions.length) {
    syntaxExtension(all, extensions[index2]);
  }
  return all;
}
function syntaxExtension(all, extension) {
  let hook;
  for (hook in extension) {
    const maybe = hasOwnProperty.call(all, hook) ? all[hook] : void 0;
    const left = maybe || (all[hook] = {});
    const right = extension[hook];
    let code;
    if (right) {
      for (code in right) {
        if (!hasOwnProperty.call(left, code)) left[code] = [];
        const value = right[code];
        constructs(
          // @ts-expect-error Looks like a list.
          left[code],
          Array.isArray(value) ? value : value ? [value] : []
        );
      }
    }
  }
}
function constructs(existing, list) {
  let index$1 = -1;
  const before = [];
  while (++index$1 < list.length) {
    (list[index$1].add === "after" ? existing : before).push(list[index$1]);
  }
  index.splice(existing, 0, 0, before);
}
exports.combineExtensions = combineExtensions;
//# sourceMappingURL=index.cjs.map
