// src/runtime/index.ts
import katex from "katex";
import "katex/dist/katex.css";
var jsonp = window.latexJsonp = window.latexJsonp || [];
var queue = jsonp.splice(0, jsonp.length);
var attr = (element, name) => decodeURIComponent(element.getAttribute(name) || "");
jsonp.push = function(...args) {
  args.forEach((callback) => {
    queue.push(callback);
    unqueue();
  });
  return queue.length;
};
var processing = false;
async function lock(action) {
  processing = true;
  await action();
  processing = false;
}
function unqueue() {
  if (!processing && queue.length) {
    call(queue.shift());
  }
}
function identity(content) {
  return content;
}
async function call(callback) {
  await lock(
    () => callback({
      run: async ({
        querySelector = ".yfm-latex",
        nodes,
        sanitize = identity,
        strict = "warn",
        trust = false,
        ...rest
      } = {}) => {
        const nodesList = Array.from(
          nodes || document.querySelectorAll(querySelector)
        );
        for (const element of nodesList) {
          const content = attr(element, "data-content");
          const options = JSON.parse(attr(element, "data-options") || "{}");
          element.innerHTML = sanitize(
            katex.renderToString(content, {
              ...options,
              strict,
              trust,
              ...rest
            })
          );
        }
      }
    })
  );
  unqueue();
}
unqueue();
//# sourceMappingURL=index-browser.js.map
