function ready(fn) {
  if (document.readyState !== "loading") {
    fn();
    return;
  }
  document.addEventListener("DOMContentLoaded", fn());
}

ready(() => {
  document.querySelectorAll("form").forEach((e) => {
    e.setAttribute("hx-ext", "json-enc");
  });
});

ready(() => {
  document
    .getElementById("#layout_content")
    .addEventListener("htmx:responseError", function (event) {
      document.getElementById("#layout_content").innerHTML =
        event.detail.xhr.response;
    });
});
