UNPKG

mx-ui-components

Version:

mobius ui library

2,283 lines • 89.2 kB
(function() {
  const htmx = {
    // Tsc madness here, assigning the functions directly results in an invalid TypeScript output, but reassigning is fine
    /* Event processing */
    /** @type {typeof onLoadHelper} */
    onLoad: null,
    /** @type {typeof processNode} */
    process: null,
    /** @type {typeof addEventListenerImpl} */
    on: null,
    /** @type {typeof removeEventListenerImpl} */
    off: null,
    /** @type {typeof triggerEvent} */
    trigger: null,
    /** @type {typeof ajaxHelper} */
    ajax: null,
    /* DOM querying helpers */
    /** @type {typeof find} */
    find: null,
    /** @type {typeof findAll} */
    findAll: null,
    /** @type {typeof closest} */
    closest: null,
    /**
     * Returns the input values that would resolve for a given element via the htmx value resolution mechanism
     *
     * @see https://htmx.org/api/#values
     *
     * @param {Element} elt the element to resolve values on
     * @param {HttpVerb} type the request type (e.g. **get** or **post**) non-GET's will include the enclosing form of the element. Defaults to **post**
     * @returns {Object}
     */
    values: function(e, t) {
      return getInputValues(e, t || "post").values;
    },
    /* DOM manipulation helpers */
    /** @type {typeof removeElement} */
    remove: null,
    /** @type {typeof addClassToElement} */
    addClass: null,
    /** @type {typeof removeClassFromElement} */
    removeClass: null,
    /** @type {typeof toggleClassOnElement} */
    toggleClass: null,
    /** @type {typeof takeClassForElement} */
    takeClass: null,
    /** @type {typeof swap} */
    swap: null,
    /* Extension entrypoints */
    /** @type {typeof defineExtension} */
    defineExtension: null,
    /** @type {typeof removeExtension} */
    removeExtension: null,
    /* Debugging */
    /** @type {typeof logAll} */
    logAll: null,
    /** @type {typeof logNone} */
    logNone: null,
    /* Debugging */
    /**
     * The logger htmx uses to log with
     *
     * @see https://htmx.org/api/#logger
     */
    logger: null,
    /**
     * A property holding the configuration htmx uses at runtime.
     *
     * Note that using a [meta tag](https://htmx.org/docs/#config) is the preferred mechanism for setting these properties.
     *
     * @see https://htmx.org/api/#config
     */
    config: {
      /**
       * Whether to use history.
       * @type boolean
       * @default true
       */
      historyEnabled: !0,
      /**
       * The number of pages to keep in **sessionStorage** for history support.
       * @type number
       * @default 10
       */
      historyCacheSize: 10,
      /**
       * @type boolean
       * @default false
       */
      refreshOnHistoryMiss: !1,
      /**
       * The default swap style to use if **[hx-swap](https://htmx.org/attributes/hx-swap)** is omitted.
       * @type HtmxSwapStyle
       * @default 'innerHTML'
       */
      defaultSwapStyle: "innerHTML",
      /**
       * The default delay between receiving a response from the server and doing the swap.
       * @type number
       * @default 0
       */
      defaultSwapDelay: 0,
      /**
       * The default delay between completing the content swap and settling attributes.
       * @type number
       * @default 20
       */
      defaultSettleDelay: 20,
      /**
       * If true, htmx will inject a small amount of CSS into the page to make indicators invisible unless the **htmx-indicator** class is present.
       * @type boolean
       * @default true
       */
      includeIndicatorStyles: !0,
      /**
       * The class to place on indicators when a request is in flight.
       * @type string
       * @default 'htmx-indicator'
       */
      indicatorClass: "htmx-indicator",
      /**
       * The class to place on triggering elements when a request is in flight.
       * @type string
       * @default 'htmx-request'
       */
      requestClass: "htmx-request",
      /**
       * The class to temporarily place on elements that htmx has added to the DOM.
       * @type string
       * @default 'htmx-added'
       */
      addedClass: "htmx-added",
      /**
       * The class to place on target elements when htmx is in the settling phase.
       * @type string
       * @default 'htmx-settling'
       */
      settlingClass: "htmx-settling",
      /**
       * The class to place on target elements when htmx is in the swapping phase.
       * @type string
       * @default 'htmx-swapping'
       */
      swappingClass: "htmx-swapping",
      /**
       * Allows the use of eval-like functionality in htmx, to enable **hx-vars**, trigger conditions & script tag evaluation. Can be set to **false** for CSP compatibility.
       * @type boolean
       * @default true
       */
      allowEval: !0,
      /**
       * If set to false, disables the interpretation of script tags.
       * @type boolean
       * @default true
       */
      allowScriptTags: !0,
      /**
       * If set, the nonce will be added to inline scripts.
       * @type string
       * @default ''
       */
      inlineScriptNonce: "",
      /**
       * If set, the nonce will be added to inline styles.
       * @type string
       * @default ''
       */
      inlineStyleNonce: "",
      /**
       * The attributes to settle during the settling phase.
       * @type string[]
       * @default ['class', 'style', 'width', 'height']
       */
      attributesToSettle: ["class", "style", "width", "height"],
      /**
       * Allow cross-site Access-Control requests using credentials such as cookies, authorization headers or TLS client certificates.
       * @type boolean
       * @default false
       */
      withCredentials: !1,
      /**
       * @type number
       * @default 0
       */
      timeout: 0,
      /**
       * The default implementation of **getWebSocketReconnectDelay** for reconnecting after unexpected connection loss by the event code **Abnormal Closure**, **Service Restart** or **Try Again Later**.
       * @type {'full-jitter' | ((retryCount:number) => number)}
       * @default "full-jitter"
       */
      wsReconnectDelay: "full-jitter",
      /**
       * The type of binary data being received over the WebSocket connection
       * @type BinaryType
       * @default 'blob'
       */
      wsBinaryType: "blob",
      /**
       * @type string
       * @default '[hx-disable], [data-hx-disable]'
       */
      disableSelector: "[hx-disable], [data-hx-disable]",
      /**
       * @type {'auto' | 'instant' | 'smooth'}
       * @default 'instant'
       */
      scrollBehavior: "instant",
      /**
       * If the focused element should be scrolled into view.
       * @type boolean
       * @default false
       */
      defaultFocusScroll: !1,
      /**
       * If set to true htmx will include a cache-busting parameter in GET requests to avoid caching partial responses by the browser
       * @type boolean
       * @default false
       */
      getCacheBusterParam: !1,
      /**
       * If set to true, htmx will use the View Transition API when swapping in new content.
       * @type boolean
       * @default false
       */
      globalViewTransitions: !1,
      /**
       * htmx will format requests with these methods by encoding their parameters in the URL, not the request body
       * @type {(HttpVerb)[]}
       * @default ['get', 'delete']
       */
      methodsThatUseUrlParams: ["get", "delete"],
      /**
       * If set to true, disables htmx-based requests to non-origin hosts.
       * @type boolean
       * @default false
       */
      selfRequestsOnly: !0,
      /**
       * If set to true htmx will not update the title of the document when a title tag is found in new content
       * @type boolean
       * @default false
       */
      ignoreTitle: !1,
      /**
       * Whether the target of a boosted element is scrolled into the viewport.
       * @type boolean
       * @default true
       */
      scrollIntoViewOnBoost: !0,
      /**
       * The cache to store evaluated trigger specifications into.
       * You may define a simple object to use a never-clearing cache, or implement your own system using a [proxy object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Proxy)
       * @type {Object|null}
       * @default null
       */
      triggerSpecsCache: null,
      /** @type boolean */
      disableInheritance: !1,
      /** @type HtmxResponseHandlingConfig[] */
      responseHandling: [
        { code: "204", swap: !1 },
        { code: "[23]..", swap: !0 },
        { code: "[45]..", swap: !1, error: !0 }
      ],
      /**
       * Whether to process OOB swaps on elements that are nested within the main response element.
       * @type boolean
       * @default true
       */
      allowNestedOobSwaps: !0,
      /**
       * Whether to treat history cache miss full page reload requests as a "HX-Request" by returning this response header
       * This should always be disabled when using HX-Request header to optionally return partial responses
       * @type boolean
       * @default true
       */
      historyRestoreAsHxRequest: !0
    },
    /** @type {typeof parseInterval} */
    parseInterval: null,
    /**
     * proxy of window.location used for page reload functions
     * @type location
     */
    location,
    /** @type {typeof internalEval} */
    _: null,
    version: "2.0.6"
  };
  htmx.onLoad = onLoadHelper, htmx.process = processNode, htmx.on = addEventListenerImpl, htmx.off = removeEventListenerImpl, htmx.trigger = triggerEvent, htmx.ajax = ajaxHelper, htmx.find = find, htmx.findAll = findAll, htmx.closest = closest, htmx.remove = removeElement, htmx.addClass = addClassToElement, htmx.removeClass = removeClassFromElement, htmx.toggleClass = toggleClassOnElement, htmx.takeClass = takeClassForElement, htmx.swap = swap, htmx.defineExtension = defineExtension, htmx.removeExtension = removeExtension, htmx.logAll = logAll, htmx.logNone = logNone, htmx.parseInterval = parseInterval, htmx._ = internalEval;
  const internalAPI = {
    addTriggerHandler,
    bodyContains,
    canAccessLocalStorage,
    findThisElement,
    filterValues,
    swap,
    hasAttribute,
    getAttributeValue,
    getClosestAttributeValue,
    getClosestMatch,
    getExpressionVars,
    getHeaders,
    getInputValues,
    getInternalData,
    getSwapSpecification,
    getTriggerSpecs,
    getTarget,
    makeFragment,
    mergeObjects,
    makeSettleInfo,
    oobSwap,
    querySelectorExt,
    settleImmediately,
    shouldCancel,
    triggerEvent,
    triggerErrorEvent,
    withExtensions
  }, VERBS = ["get", "post", "put", "delete", "patch"], VERB_SELECTOR = VERBS.map(function(e) {
    return "[hx-" + e + "], [data-hx-" + e + "]";
  }).join(", ");
  function parseInterval(e) {
    if (e == null)
      return;
    let t = NaN;
    return e.slice(-2) == "ms" ? t = parseFloat(e.slice(0, -2)) : e.slice(-1) == "s" ? t = parseFloat(e.slice(0, -1)) * 1e3 : e.slice(-1) == "m" ? t = parseFloat(e.slice(0, -1)) * 1e3 * 60 : t = parseFloat(e), isNaN(t) ? void 0 : t;
  }
  function getRawAttribute(e, t) {
    return e instanceof Element && e.getAttribute(t);
  }
  function hasAttribute(e, t) {
    return !!e.hasAttribute && (e.hasAttribute(t) || e.hasAttribute("data-" + t));
  }
  function getAttributeValue(e, t) {
    return getRawAttribute(e, t) || getRawAttribute(e, "data-" + t);
  }
  function parentElt(e) {
    const t = e.parentElement;
    return !t && e.parentNode instanceof ShadowRoot ? e.parentNode : t;
  }
  function getDocument() {
    return document;
  }
  function getRootNode(e, t) {
    return e.getRootNode ? e.getRootNode({ composed: t }) : getDocument();
  }
  function getClosestMatch(e, t) {
    for (; e && !t(e); )
      e = parentElt(e);
    return e || null;
  }
  function getAttributeValueWithDisinheritance(e, t, n) {
    const r = getAttributeValue(t, n), o = getAttributeValue(t, "hx-disinherit");
    var i = getAttributeValue(t, "hx-inherit");
    if (e !== t) {
      if (htmx.config.disableInheritance)
        return i && (i === "*" || i.split(" ").indexOf(n) >= 0) ? r : null;
      if (o && (o === "*" || o.split(" ").indexOf(n) >= 0))
        return "unset";
    }
    return r;
  }
  function getClosestAttributeValue(e, t) {
    let n = null;
    if (getClosestMatch(e, function(r) {
      return !!(n = getAttributeValueWithDisinheritance(e, asElement(r), t));
    }), n !== "unset")
      return n;
  }
  function matches(e, t) {
    return e instanceof Element && e.matches(t);
  }
  function getStartTag(e) {
    const n = /<([a-z][^\/\0>\x20\t\r\n\f]*)/i.exec(e);
    return n ? n[1].toLowerCase() : "";
  }
  function parseHTML(e) {
    return new DOMParser().parseFromString(e, "text/html");
  }
  function takeChildrenFor(e, t) {
    for (; t.childNodes.length > 0; )
      e.append(t.childNodes[0]);
  }
  function duplicateScript(e) {
    const t = getDocument().createElement("script");
    return forEach(e.attributes, function(n) {
      t.setAttribute(n.name, n.value);
    }), t.textContent = e.textContent, t.async = !1, htmx.config.inlineScriptNonce && (t.nonce = htmx.config.inlineScriptNonce), t;
  }
  function isJavaScriptScriptNode(e) {
    return e.matches("script") && (e.type === "text/javascript" || e.type === "module" || e.type === "");
  }
  function normalizeScriptTags(e) {
    Array.from(e.querySelectorAll("script")).forEach(
      /** @param {HTMLScriptElement} script */
      (t) => {
        if (isJavaScriptScriptNode(t)) {
          const n = duplicateScript(t), r = t.parentNode;
          try {
            r.insertBefore(n, t);
          } catch (o) {
            logError(o);
          } finally {
            t.remove();
          }
        }
      }
    );
  }
  function makeFragment(e) {
    const t = e.replace(/<head(\s[^>]*)?>[\s\S]*?<\/head>/i, ""), n = getStartTag(t);
    let r;
    if (n === "html") {
      r = /** @type DocumentFragmentWithTitle */
      new DocumentFragment();
      const i = parseHTML(e);
      takeChildrenFor(r, i.body), r.title = i.title;
    } else if (n === "body") {
      r = /** @type DocumentFragmentWithTitle */
      new DocumentFragment();
      const i = parseHTML(t);
      takeChildrenFor(r, i.body), r.title = i.title;
    } else {
      const i = parseHTML('<body><template class="internal-htmx-wrapper">' + t + "</template></body>");
      r = /** @type DocumentFragmentWithTitle */
      i.querySelector("template").content, r.title = i.title;
      var o = r.querySelector("title");
      o && o.parentNode === r && (o.remove(), r.title = o.innerText);
    }
    return r && (htmx.config.allowScriptTags ? normalizeScriptTags(r) : r.querySelectorAll("script").forEach((i) => i.remove())), r;
  }
  function maybeCall(e) {
    e && e();
  }
  function isType(e, t) {
    return Object.prototype.toString.call(e) === "[object " + t + "]";
  }
  function isFunction(e) {
    return typeof e == "function";
  }
  function isRawObject(e) {
    return isType(e, "Object");
  }
  function getInternalData(e) {
    const t = "htmx-internal-data";
    let n = e[t];
    return n || (n = e[t] = {}), n;
  }
  function toArray(e) {
    const t = [];
    if (e)
      for (let n = 0; n < e.length; n++)
        t.push(e[n]);
    return t;
  }
  function forEach(e, t) {
    if (e)
      for (let n = 0; n < e.length; n++)
        t(e[n]);
  }
  function isScrolledIntoView(e) {
    const t = e.getBoundingClientRect(), n = t.top, r = t.bottom;
    return n < window.innerHeight && r >= 0;
  }
  function bodyContains(e) {
    return e.getRootNode({ composed: !0 }) === document;
  }
  function splitOnWhitespace(e) {
    return e.trim().split(/\s+/);
  }
  function mergeObjects(e, t) {
    for (const n in t)
      t.hasOwnProperty(n) && (e[n] = t[n]);
    return e;
  }
  function parseJSON(e) {
    try {
      return JSON.parse(e);
    } catch (t) {
      return logError(t), null;
    }
  }
  function canAccessLocalStorage() {
    const e = "htmx:sessionStorageTest";
    try {
      return sessionStorage.setItem(e, e), sessionStorage.removeItem(e), !0;
    } catch {
      return !1;
    }
  }
  function normalizePath(e) {
    const t = new URL(e, "http://x");
    return t && (e = t.pathname + t.search), e != "/" && (e = e.replace(/\/+$/, "")), e;
  }
  function internalEval(str) {
    return maybeEval(getDocument().body, function() {
      return eval(str);
    });
  }
  function onLoadHelper(e) {
    return htmx.on(
      "htmx:load",
      /** @param {CustomEvent} evt */
      function(n) {
        e(n.detail.elt);
      }
    );
  }
  function logAll() {
    htmx.logger = function(e, t, n) {
      console && console.log(t, e, n);
    };
  }
  function logNone() {
    htmx.logger = null;
  }
  function find(e, t) {
    return typeof e != "string" ? e.querySelector(t) : find(getDocument(), e);
  }
  function findAll(e, t) {
    return typeof e != "string" ? e.querySelectorAll(t) : findAll(getDocument(), e);
  }
  function getWindow() {
    return window;
  }
  function removeElement(e, t) {
    e = resolveTarget(e), t ? getWindow().setTimeout(function() {
      removeElement(e), e = null;
    }, t) : parentElt(e).removeChild(e);
  }
  function asElement(e) {
    return e instanceof Element ? e : null;
  }
  function asHtmlElement(e) {
    return e instanceof HTMLElement ? e : null;
  }
  function asString(e) {
    return typeof e == "string" ? e : null;
  }
  function asParentNode(e) {
    return e instanceof Element || e instanceof Document || e instanceof DocumentFragment ? e : null;
  }
  function addClassToElement(e, t, n) {
    e = asElement(resolveTarget(e)), e && (n ? getWindow().setTimeout(function() {
      addClassToElement(e, t), e = null;
    }, n) : e.classList && e.classList.add(t));
  }
  function removeClassFromElement(e, t, n) {
    let r = asElement(resolveTarget(e));
    r && (n ? getWindow().setTimeout(function() {
      removeClassFromElement(r, t), r = null;
    }, n) : r.classList && (r.classList.remove(t), r.classList.length === 0 && r.removeAttribute("class")));
  }
  function toggleClassOnElement(e, t) {
    e = resolveTarget(e), e.classList.toggle(t);
  }
  function takeClassForElement(e, t) {
    e = resolveTarget(e), forEach(e.parentElement.children, function(n) {
      removeClassFromElement(n, t);
    }), addClassToElement(asElement(e), t);
  }
  function closest(e, t) {
    return e = asElement(resolveTarget(e)), e ? e.closest(t) : null;
  }
  function startsWith(e, t) {
    return e.substring(0, t.length) === t;
  }
  function endsWith(e, t) {
    return e.substring(e.length - t.length) === t;
  }
  function normalizeSelector(e) {
    const t = e.trim();
    return startsWith(t, "<") && endsWith(t, "/>") ? t.substring(1, t.length - 2) : t;
  }
  function querySelectorAllExt(e, t, n) {
    if (t.indexOf("global ") === 0)
      return querySelectorAllExt(e, t.slice(7), !0);
    e = resolveTarget(e);
    const r = [];
    {
      let s = 0, l = 0;
      for (let a = 0; a < t.length; a++) {
        const u = t[a];
        if (u === "," && s === 0) {
          r.push(t.substring(l, a)), l = a + 1;
          continue;
        }
        u === "<" ? s++ : u === "/" && a < t.length - 1 && t[a + 1] === ">" && s--;
      }
      l < t.length && r.push(t.substring(l));
    }
    const o = [], i = [];
    for (; r.length > 0; ) {
      const s = normalizeSelector(r.shift());
      let l;
      s.indexOf("closest ") === 0 ? l = closest(asElement(e), normalizeSelector(s.slice(8))) : s.indexOf("find ") === 0 ? l = find(asParentNode(e), normalizeSelector(s.slice(5))) : s === "next" || s === "nextElementSibling" ? l = asElement(e).nextElementSibling : s.indexOf("next ") === 0 ? l = scanForwardQuery(e, normalizeSelector(s.slice(5)), !!n) : s === "previous" || s === "previousElementSibling" ? l = asElement(e).previousElementSibling : s.indexOf("previous ") === 0 ? l = scanBackwardsQuery(e, normalizeSelector(s.slice(9)), !!n) : s === "document" ? l = document : s === "window" ? l = window : s === "body" ? l = document.body : s === "root" ? l = getRootNode(e, !!n) : s === "host" ? l = /** @type ShadowRoot */
      e.getRootNode().host : i.push(s), l && o.push(l);
    }
    if (i.length > 0) {
      const s = i.join(","), l = asParentNode(getRootNode(e, !!n));
      o.push(...toArray(l.querySelectorAll(s)));
    }
    return o;
  }
  var scanForwardQuery = function(e, t, n) {
    const r = asParentNode(getRootNode(e, n)).querySelectorAll(t);
    for (let o = 0; o < r.length; o++) {
      const i = r[o];
      if (i.compareDocumentPosition(e) === Node.DOCUMENT_POSITION_PRECEDING)
        return i;
    }
  }, scanBackwardsQuery = function(e, t, n) {
    const r = asParentNode(getRootNode(e, n)).querySelectorAll(t);
    for (let o = r.length - 1; o >= 0; o--) {
      const i = r[o];
      if (i.compareDocumentPosition(e) === Node.DOCUMENT_POSITION_FOLLOWING)
        return i;
    }
  };
  function querySelectorExt(e, t) {
    return typeof e != "string" ? querySelectorAllExt(e, t)[0] : querySelectorAllExt(getDocument().body, e)[0];
  }
  function resolveTarget(e, t) {
    return typeof e == "string" ? find(asParentNode(t) || document, e) : e;
  }
  function processEventArgs(e, t, n, r) {
    return isFunction(t) ? {
      target: getDocument().body,
      event: asString(e),
      listener: t,
      options: n
    } : {
      target: resolveTarget(e),
      event: asString(t),
      listener: n,
      options: r
    };
  }
  function addEventListenerImpl(e, t, n, r) {
    return ready(function() {
      const i = processEventArgs(e, t, n, r);
      i.target.addEventListener(i.event, i.listener, i.options);
    }), isFunction(t) ? t : n;
  }
  function removeEventListenerImpl(e, t, n) {
    return ready(function() {
      const r = processEventArgs(e, t, n);
      r.target.removeEventListener(r.event, r.listener);
    }), isFunction(t) ? t : n;
  }
  const DUMMY_ELT = getDocument().createElement("output");
  function findAttributeTargets(e, t) {
    const n = getClosestAttributeValue(e, t);
    if (n) {
      if (n === "this")
        return [findThisElement(e, t)];
      {
        const r = querySelectorAllExt(e, n);
        if (/(^|,)(\s*)inherit(\s*)($|,)/.test(n)) {
          const i = asElement(getClosestMatch(e, function(s) {
            return s !== e && hasAttribute(asElement(s), t);
          }));
          i && r.push(...findAttributeTargets(i, t));
        }
        return r.length === 0 ? (logError('The selector "' + n + '" on ' + t + " returned no matches!"), [DUMMY_ELT]) : r;
      }
    }
  }
  function findThisElement(e, t) {
    return asElement(getClosestMatch(e, function(n) {
      return getAttributeValue(asElement(n), t) != null;
    }));
  }
  function getTarget(e) {
    const t = getClosestAttributeValue(e, "hx-target");
    return t ? t === "this" ? findThisElement(e, "hx-target") : querySelectorExt(e, t) : getInternalData(e).boosted ? getDocument().body : e;
  }
  function shouldSettleAttribute(e) {
    return htmx.config.attributesToSettle.includes(e);
  }
  function cloneAttributes(e, t) {
    forEach(e.attributes, function(n) {
      !t.hasAttribute(n.name) && shouldSettleAttribute(n.name) && e.removeAttribute(n.name);
    }), forEach(t.attributes, function(n) {
      shouldSettleAttribute(n.name) && e.setAttribute(n.name, n.value);
    });
  }
  function isInlineSwap(e, t) {
    const n = getExtensions(t);
    for (let r = 0; r < n.length; r++) {
      const o = n[r];
      try {
        if (o.isInlineSwap(e))
          return !0;
      } catch (i) {
        logError(i);
      }
    }
    return e === "outerHTML";
  }
  function oobSwap(e, t, n, r) {
    r = r || getDocument();
    let o = "#" + CSS.escape(getRawAttribute(t, "id")), i = "outerHTML";
    e === "true" || (e.indexOf(":") > 0 ? (i = e.substring(0, e.indexOf(":")), o = e.substring(e.indexOf(":") + 1)) : i = e), t.removeAttribute("hx-swap-oob"), t.removeAttribute("data-hx-swap-oob");
    const s = querySelectorAllExt(r, o, !1);
    return s.length ? (forEach(
      s,
      function(l) {
        let a;
        const u = t.cloneNode(!0);
        a = getDocument().createDocumentFragment(), a.appendChild(u), isInlineSwap(i, l) || (a = asParentNode(u));
        const h = { shouldSwap: !0, target: l, fragment: a };
        triggerEvent(l, "htmx:oobBeforeSwap", h) && (l = h.target, h.shouldSwap && (handlePreservedElements(a), swapWithStyle(i, l, l, a, n), restorePreservedElements()), forEach(n.elts, function(c) {
          triggerEvent(c, "htmx:oobAfterSwap", h);
        }));
      }
    ), t.parentNode.removeChild(t)) : (t.parentNode.removeChild(t), triggerErrorEvent(getDocument().body, "htmx:oobErrorNoTarget", { content: t })), e;
  }
  function restorePreservedElements() {
    const e = find("#--htmx-preserve-pantry--");
    if (e) {
      for (const t of [...e.children]) {
        const n = find("#" + t.id);
        n.parentNode.moveBefore(t, n), n.remove();
      }
      e.remove();
    }
  }
  function handlePreservedElements(e) {
    forEach(findAll(e, "[hx-preserve], [data-hx-preserve]"), function(t) {
      const n = getAttributeValue(t, "id"), r = getDocument().getElementById(n);
      if (r != null)
        if (t.moveBefore) {
          let o = find("#--htmx-preserve-pantry--");
          o == null && (getDocument().body.insertAdjacentHTML("afterend", "<div id='--htmx-preserve-pantry--'></div>"), o = find("#--htmx-preserve-pantry--")), o.moveBefore(r, null);
        } else
          t.parentNode.replaceChild(r, t);
    });
  }
  function handleAttributes(e, t, n) {
    forEach(t.querySelectorAll("[id]"), function(r) {
      const o = getRawAttribute(r, "id");
      if (o && o.length > 0) {
        const i = o.replace("'", "\\'"), s = r.tagName.replace(":", "\\:"), l = asParentNode(e), a = l && l.querySelector(s + "[id='" + i + "']");
        if (a && a !== l) {
          const u = r.cloneNode();
          cloneAttributes(r, a), n.tasks.push(function() {
            cloneAttributes(r, u);
          });
        }
      }
    });
  }
  function makeAjaxLoadTask(e) {
    return function() {
      removeClassFromElement(e, htmx.config.addedClass), processNode(asElement(e)), processFocus(asParentNode(e)), triggerEvent(e, "htmx:load");
    };
  }
  function processFocus(e) {
    const t = "[autofocus]", n = asHtmlElement(matches(e, t) ? e : e.querySelector(t));
    n != null && n.focus();
  }
  function insertNodesBefore(e, t, n, r) {
    for (handleAttributes(e, n, r); n.childNodes.length > 0; ) {
      const o = n.firstChild;
      addClassToElement(asElement(o), htmx.config.addedClass), e.insertBefore(o, t), o.nodeType !== Node.TEXT_NODE && o.nodeType !== Node.COMMENT_NODE && r.tasks.push(makeAjaxLoadTask(o));
    }
  }
  function stringHash(e, t) {
    let n = 0;
    for (; n < e.length; )
      t = (t << 5) - t + e.charCodeAt(n++) | 0;
    return t;
  }
  function attributeHash(e) {
    let t = 0;
    for (let n = 0; n < e.attributes.length; n++) {
      const r = e.attributes[n];
      r.value && (t = stringHash(r.name, t), t = stringHash(r.value, t));
    }
    return t;
  }
  function deInitOnHandlers(e) {
    const t = getInternalData(e);
    if (t.onHandlers) {
      for (let n = 0; n < t.onHandlers.length; n++) {
        const r = t.onHandlers[n];
        removeEventListenerImpl(e, r.event, r.listener);
      }
      delete t.onHandlers;
    }
  }
  function deInitNode(e) {
    const t = getInternalData(e);
    t.timeout && clearTimeout(t.timeout), t.listenerInfos && forEach(t.listenerInfos, function(n) {
      n.on && removeEventListenerImpl(n.on, n.trigger, n.listener);
    }), deInitOnHandlers(e), forEach(Object.keys(t), function(n) {
      n !== "firstInitCompleted" && delete t[n];
    });
  }
  function cleanUpElement(e) {
    triggerEvent(e, "htmx:beforeCleanupElement"), deInitNode(e), forEach(e.children, function(t) {
      cleanUpElement(t);
    });
  }
  function swapOuterHTML(e, t, n) {
    if (e.tagName === "BODY")
      return swapInnerHTML(e, t, n);
    let r;
    const o = e.previousSibling, i = parentElt(e);
    if (i) {
      for (insertNodesBefore(i, e, t, n), o == null ? r = i.firstChild : r = o.nextSibling, n.elts = n.elts.filter(function(s) {
        return s !== e;
      }); r && r !== e; )
        r instanceof Element && n.elts.push(r), r = r.nextSibling;
      cleanUpElement(e), e.remove();
    }
  }
  function swapAfterBegin(e, t, n) {
    return insertNodesBefore(e, e.firstChild, t, n);
  }
  function swapBeforeBegin(e, t, n) {
    return insertNodesBefore(parentElt(e), e, t, n);
  }
  function swapBeforeEnd(e, t, n) {
    return insertNodesBefore(e, null, t, n);
  }
  function swapAfterEnd(e, t, n) {
    return insertNodesBefore(parentElt(e), e.nextSibling, t, n);
  }
  function swapDelete(e) {
    cleanUpElement(e);
    const t = parentElt(e);
    if (t)
      return t.removeChild(e);
  }
  function swapInnerHTML(e, t, n) {
    const r = e.firstChild;
    if (insertNodesBefore(e, r, t, n), r) {
      for (; r.nextSibling; )
        cleanUpElement(r.nextSibling), e.removeChild(r.nextSibling);
      cleanUpElement(r), e.removeChild(r);
    }
  }
  function swapWithStyle(e, t, n, r, o) {
    switch (e) {
      case "none":
        return;
      case "outerHTML":
        swapOuterHTML(n, r, o);
        return;
      case "afterbegin":
        swapAfterBegin(n, r, o);
        return;
      case "beforebegin":
        swapBeforeBegin(n, r, o);
        return;
      case "beforeend":
        swapBeforeEnd(n, r, o);
        return;
      case "afterend":
        swapAfterEnd(n, r, o);
        return;
      case "delete":
        swapDelete(n);
        return;
      default:
        var i = getExtensions(t);
        for (let s = 0; s < i.length; s++) {
          const l = i[s];
          try {
            const a = l.handleSwap(e, n, r, o);
            if (a) {
              if (Array.isArray(a))
                for (let u = 0; u < a.length; u++) {
                  const h = a[u];
                  h.nodeType !== Node.TEXT_NODE && h.nodeType !== Node.COMMENT_NODE && o.tasks.push(makeAjaxLoadTask(h));
                }
              return;
            }
          } catch (a) {
            logError(a);
          }
        }
        e === "innerHTML" ? swapInnerHTML(n, r, o) : swapWithStyle(htmx.config.defaultSwapStyle, t, n, r, o);
    }
  }
  function findAndSwapOobElements(e, t, n) {
    var r = findAll(e, "[hx-swap-oob], [data-hx-swap-oob]");
    return forEach(r, function(o) {
      if (htmx.config.allowNestedOobSwaps || o.parentElement === null) {
        const i = getAttributeValue(o, "hx-swap-oob");
        i != null && oobSwap(i, o, t, n);
      } else
        o.removeAttribute("hx-swap-oob"), o.removeAttribute("data-hx-swap-oob");
    }), r.length > 0;
  }
  function swap(e, t, n, r) {
    r || (r = {});
    let o = null, i = null, s = function() {
      maybeCall(r.beforeSwapCallback), e = resolveTarget(e);
      const u = r.contextElement ? getRootNode(r.contextElement, !1) : getDocument(), h = document.activeElement;
      let c = {};
      c = {
        elt: h,
        // @ts-ignore
        start: h ? h.selectionStart : null,
        // @ts-ignore
        end: h ? h.selectionEnd : null
      };
      const f = makeSettleInfo(e);
      if (n.swapStyle === "textContent")
        e.textContent = t;
      else {
        let d = makeFragment(t);
        if (f.title = r.title || d.title, r.historyRequest && (d = d.querySelector("[hx-history-elt],[data-hx-history-elt]") || d), r.selectOOB) {
          const E = r.selectOOB.split(",");
          for (let m = 0; m < E.length; m++) {
            const C = E[m].split(":", 2);
            let w = C[0].trim();
            w.indexOf("#") === 0 && (w = w.substring(1));
            const x = C[1] || "true", p = d.querySelector("#" + w);
            p && oobSwap(x, p, f, u);
          }
        }
        if (findAndSwapOobElements(d, f, u), forEach(
          findAll(d, "template"),
          /** @param {HTMLTemplateElement} template */
          function(E) {
            E.content && findAndSwapOobElements(E.content, f, u) && E.remove();
          }
        ), r.select) {
          const E = getDocument().createDocumentFragment();
          forEach(d.querySelectorAll(r.select), function(m) {
            E.appendChild(m);
          }), d = E;
        }
        handlePreservedElements(d), swapWithStyle(n.swapStyle, r.contextElement, e, d, f), restorePreservedElements();
      }
      if (c.elt && !bodyContains(c.elt) && getRawAttribute(c.elt, "id")) {
        const d = document.getElementById(getRawAttribute(c.elt, "id")), E = { preventScroll: n.focusScroll !== void 0 ? !n.focusScroll : !htmx.config.defaultFocusScroll };
        if (d) {
          if (c.start && d.setSelectionRange)
            try {
              d.setSelectionRange(c.start, c.end);
            } catch {
            }
          d.focus(E);
        }
      }
      e.classList.remove(htmx.config.swappingClass), forEach(f.elts, function(d) {
        d.classList && d.classList.add(htmx.config.settlingClass), triggerEvent(d, "htmx:afterSwap", r.eventInfo);
      }), maybeCall(r.afterSwapCallback), n.ignoreTitle || handleTitle(f.title);
      const y = function() {
        if (forEach(f.tasks, function(d) {
          d.call();
        }), forEach(f.elts, function(d) {
          d.classList && d.classList.remove(htmx.config.settlingClass), triggerEvent(d, "htmx:afterSettle", r.eventInfo);
        }), r.anchor) {
          const d = asElement(resolveTarget("#" + r.anchor));
          d && d.scrollIntoView({ block: "start", behavior: "auto" });
        }
        updateScrollState(f.elts, n), maybeCall(r.afterSettleCallback), maybeCall(o);
      };
      n.settleDelay > 0 ? getWindow().setTimeout(y, n.settleDelay) : y();
    }, l = htmx.config.globalViewTransitions;
    n.hasOwnProperty("transition") && (l = n.transition);
    const a = r.contextElement || getDocument();
    if (l && triggerEvent(a, "htmx:beforeTransition", r.eventInfo) && typeof Promise < "u" && // @ts-ignore experimental feature atm
    document.startViewTransition) {
      const u = new Promise(function(c, f) {
        o = c, i = f;
      }), h = s;
      s = function() {
        document.startViewTransition(function() {
          return h(), u;
        });
      };
    }
    try {
      n != null && n.swapDelay && n.swapDelay > 0 ? getWindow().setTimeout(s, n.swapDelay) : s();
    } catch (u) {
      throw triggerErrorEvent(a, "htmx:swapError", r.eventInfo), maybeCall(i), u;
    }
  }
  function handleTriggerHeader(e, t, n) {
    const r = e.getResponseHeader(t);
    if (r.indexOf("{") === 0) {
      const o = parseJSON(r);
      for (const i in o)
        if (o.hasOwnProperty(i)) {
          let s = o[i];
          isRawObject(s) ? n = s.target !== void 0 ? s.target : n : s = { value: s }, triggerEvent(n, i, s);
        }
    } else {
      const o = r.split(",");
      for (let i = 0; i < o.length; i++)
        triggerEvent(n, o[i].trim(), []);
    }
  }
  const WHITESPACE_OR_COMMA = /[\s,]/, SYMBOL_START = /[_$a-zA-Z]/, SYMBOL_CONT = /[_$a-zA-Z0-9]/, STRINGISH_START = ['"', "'", "/"], NOT_WHITESPACE = /[^\s]/, COMBINED_SELECTOR_START = /[{(]/, COMBINED_SELECTOR_END = /[})]/;
  function tokenizeString(e) {
    const t = [];
    let n = 0;
    for (; n < e.length; ) {
      if (SYMBOL_START.exec(e.charAt(n))) {
        for (var r = n; SYMBOL_CONT.exec(e.charAt(n + 1)); )
          n++;
        t.push(e.substring(r, n + 1));
      } else if (STRINGISH_START.indexOf(e.charAt(n)) !== -1) {
        const o = e.charAt(n);
        var r = n;
        for (n++; n < e.length && e.charAt(n) !== o; )
          e.charAt(n) === "\\" && n++, n++;
        t.push(e.substring(r, n + 1));
      } else {
        const o = e.charAt(n);
        t.push(o);
      }
      n++;
    }
    return t;
  }
  function isPossibleRelativeReference(e, t, n) {
    return SYMBOL_START.exec(e.charAt(0)) && e !== "true" && e !== "false" && e !== "this" && e !== n && t !== ".";
  }
  function maybeGenerateConditional(e, t, n) {
    if (t[0] === "[") {
      t.shift();
      let r = 1, o = " return (function(" + n + "){ return (", i = null;
      for (; t.length > 0; ) {
        const s = t[0];
        if (s === "]") {
          if (r--, r === 0) {
            i === null && (o = o + "true"), t.shift(), o += ")})";
            try {
              const l = maybeEval(
                e,
                function() {
                  return Function(o)();
                },
                function() {
                  return !0;
                }
              );
              return l.source = o, l;
            } catch (l) {
              return triggerErrorEvent(getDocument().body, "htmx:syntax:error", { error: l, source: o }), null;
            }
          }
        } else s === "[" && r++;
        isPossibleRelativeReference(s, i, n) ? o += "((" + n + "." + s + ") ? (" + n + "." + s + ") : (window." + s + "))" : o = o + s, i = t.shift();
      }
    }
  }
  function consumeUntil(e, t) {
    let n = "";
    for (; e.length > 0 && !t.test(e[0]); )
      n += e.shift();
    return n;
  }
  function consumeCSSSelector(e) {
    let t;
    return e.length > 0 && COMBINED_SELECTOR_START.test(e[0]) ? (e.shift(), t = consumeUntil(e, COMBINED_SELECTOR_END).trim(), e.shift()) : t = consumeUntil(e, WHITESPACE_OR_COMMA), t;
  }
  const INPUT_SELECTOR = "input, textarea, select";
  function parseAndCacheTrigger(e, t, n) {
    const r = [], o = tokenizeString(t);
    do {
      consumeUntil(o, NOT_WHITESPACE);
      const l = o.length, a = consumeUntil(o, /[,\[\s]/);
      if (a !== "")
        if (a === "every") {
          const u = { trigger: "every" };
          consumeUntil(o, NOT_WHITESPACE), u.pollInterval = parseInterval(consumeUntil(o, /[,\[\s]/)), consumeUntil(o, NOT_WHITESPACE);
          var i = maybeGenerateConditional(e, o, "event");
          i && (u.eventFilter = i), r.push(u);
        } else {
          const u = { trigger: a };
          var i = maybeGenerateConditional(e, o, "event");
          for (i && (u.eventFilter = i), consumeUntil(o, NOT_WHITESPACE); o.length > 0 && o[0] !== ","; ) {
            const c = o.shift();
            if (c === "changed")
              u.changed = !0;
            else if (c === "once")
              u.once = !0;
            else if (c === "consume")
              u.consume = !0;
            else if (c === "delay" && o[0] === ":")
              o.shift(), u.delay = parseInterval(consumeUntil(o, WHITESPACE_OR_COMMA));
            else if (c === "from" && o[0] === ":") {
              if (o.shift(), COMBINED_SELECTOR_START.test(o[0]))
                var s = consumeCSSSelector(o);
              else {
                var s = consumeUntil(o, WHITESPACE_OR_COMMA);
                if (s === "closest" || s === "find" || s === "next" || s === "previous") {
                  o.shift();
                  const y = consumeCSSSelector(o);
                  y.length > 0 && (s += " " + y);
                }
              }
              u.from = s;
            } else c === "target" && o[0] === ":" ? (o.shift(), u.target = consumeCSSSelector(o)) : c === "throttle" && o[0] === ":" ? (o.shift(), u.throttle = parseInterval(consumeUntil(o, WHITESPACE_OR_COMMA))) : c === "queue" && o[0] === ":" ? (o.shift(), u.queue = consumeUntil(o, WHITESPACE_OR_COMMA)) : c === "root" && o[0] === ":" ? (o.shift(), u[c] = consumeCSSSelector(o)) : c === "threshold" && o[0] === ":" ? (o.shift(), u[c] = consumeUntil(o, WHITESPACE_OR_COMMA)) : triggerErrorEvent(e, "htmx:syntax:error", { token: o.shift() });
            consumeUntil(o, NOT_WHITESPACE);
          }
          r.push(u);
        }
      o.length === l && triggerErrorEvent(e, "htmx:syntax:error", { token: o.shift() }), consumeUntil(o, NOT_WHITESPACE);
    } while (o[0] === "," && o.shift());
    return n && (n[t] = r), r;
  }
  function getTriggerSpecs(e) {
    const t = getAttributeValue(e, "hx-trigger");
    let n = [];
    if (t) {
      const r = htmx.config.triggerSpecsCache;
      n = r && r[t] || parseAndCacheTrigger(e, t, r);
    }
    return n.length > 0 ? n : matches(e, "form") ? [{ trigger: "submit" }] : matches(e, 'input[type="button"], input[type="submit"]') ? [{ trigger: "click" }] : matches(e, INPUT_SELECTOR) ? [{ trigger: "change" }] : [{ trigger: "click" }];
  }
  function cancelPolling(e) {
    getInternalData(e).cancelled = !0;
  }
  function processPolling(e, t, n) {
    const r = getInternalData(e);
    r.timeout = getWindow().setTimeout(function() {
      bodyContains(e) && r.cancelled !== !0 && (maybeFilterEvent(n, e, makeEvent("hx:poll:trigger", {
        triggerSpec: n,
        target: e
      })) || t(e), processPolling(e, t, n));
    }, n.pollInterval);
  }
  function isLocalLink(e) {
    return location.hostname === e.hostname && getRawAttribute(e, "href") && getRawAttribute(e, "href").indexOf("#") !== 0;
  }
  function eltIsDisabled(e) {
    return closest(e, htmx.config.disableSelector);
  }
  function boostElement(e, t, n) {
    if (e instanceof HTMLAnchorElement && isLocalLink(e) && (e.target === "" || e.target === "_self") || e.tagName === "FORM" && String(getRawAttribute(e, "method")).toLowerCase() !== "dialog") {
      t.boosted = !0;
      let r, o;
      if (e.tagName === "A")
        r = /** @type HttpVerb */
        "get", o = getRawAttribute(e, "href");
      else {
        const i = getRawAttribute(e, "method");
        r = /** @type HttpVerb */
        i ? i.toLowerCase() : "get", o = getRawAttribute(e, "action"), (o == null || o === "") && (o = location.href), r === "get" && o.includes("?") && (o = o.replace(/\?[^#]+/, ""));
      }
      n.forEach(function(i) {
        addEventListener(e, function(s, l) {
          const a = asElement(s);
          if (eltIsDisabled(a)) {
            cleanUpElement(a);
            return;
          }
          issueAjaxRequest(r, o, a, l);
        }, t, i, !0);
      });
    }
  }
  function shouldCancel(e, t) {
    return !!((e.type === "submit" || e.type === "click") && (t = asElement(e.target) || t, t.tagName === "FORM" || t.form && t.type === "submit" || (t = t.closest("a"), t && t.href && (t.getAttribute("href") === "#" || t.getAttribute("href").indexOf("#") !== 0))));
  }
  function ignoreBoostedAnchorCtrlClick(e, t) {
    return getInternalData(e).boosted && e instanceof HTMLAnchorElement && t.type === "click" && // @ts-ignore this will resolve to undefined for events that don't define those properties, which is fine
    (t.ctrlKey || t.metaKey);
  }
  function maybeFilterEvent(e, t, n) {
    const r = e.eventFilter;
    if (r)
      try {
        return r.call(t, n) !== !0;
      } catch (o) {
        const i = r.source;
        return triggerErrorEvent(getDocument().body, "htmx:eventFilter:error", { error: o, source: i }), !0;
      }
    return !1;
  }
  function addEventListener(e, t, n, r, o) {
    const i = getInternalData(e);
    let s;
    r.from ? s = querySelectorAllExt(e, r.from) : s = [e], r.changed && ("lastValue" in i || (i.lastValue = /* @__PURE__ */ new WeakMap()), s.forEach(function(l) {
      i.lastValue.has(r) || i.lastValue.set(r, /* @__PURE__ */ new WeakMap()), i.lastValue.get(r).set(l, l.value);
    })), forEach(s, function(l) {
      const a = function(u) {
        if (!bodyContains(e)) {
          l.removeEventListener(r.trigger, a);
          return;
        }
        if (ignoreBoostedAnchorCtrlClick(e, u) || ((o || shouldCancel(u, e)) && u.preventDefault(), maybeFilterEvent(r, e, u)))
          return;
        const h = getInternalData(u);
        if (h.triggerSpec = r, h.handledFor == null && (h.handledFor = []), h.handledFor.indexOf(e) < 0) {
          if (h.handledFor.push(e), r.consume && u.stopPropagation(), r.target && u.target && !matches(asElement(u.target), r.target))
            return;
          if (r.once) {
            if (i.triggeredOnce)
              return;
            i.triggeredOnce = !0;
          }
          if (r.changed) {
            const c = u.target, f = c.value, y = i.lastValue.get(r);
            if (y.has(c) && y.get(c) === f)
              return;
            y.set(c, f);
          }
          if (i.delayed && clearTimeout(i.delayed), i.throttle)
            return;
          r.throttle > 0 ? i.throttle || (triggerEvent(e, "htmx:trigger"), t(e, u), i.throttle = getWindow().setTimeout(function() {
            i.throttle = null;
          }, r.throttle)) : r.delay > 0 ? i.delayed = getWindow().setTimeout(function() {
            triggerEvent(e, "htmx:trigger"), t(e, u);
          }, r.delay) : (triggerEvent(e, "htmx:trigger"), t(e, u));
        }
      };
      n.listenerInfos == null && (n.listenerInfos = []), n.listenerInfos.push({
        trigger: r.trigger,
        listener: a,
        on: l
      }), l.addEventListener(r.trigger, a);
    });
  }
  let windowIsScrolling = !1, scrollHandler = null;
  function initScrollHandler() {
    scrollHandler || (scrollHandler = function() {
      windowIsScrolling = !0;
    }, window.addEventListener("scroll", scrollHandler), window.addEventListener("resize", scrollHandler), setInterval(function() {
      windowIsScrolling && (windowIsScrolling = !1, forEach(getDocument().querySelectorAll("[hx-trigger*='revealed'],[data-hx-trigger*='revealed']"), function(e) {
        maybeReveal(e);
      }));
    }, 200));
  }
  function maybeReveal(e) {
    !hasAttribute(e, "data-hx-revealed") && isScrolledIntoView(e) && (e.setAttribute("data-hx-revealed", "true"), getInternalData(e).initHash ? triggerEvent(e, "revealed") : e.addEventListener("htmx:afterProcessNode", function() {
      triggerEvent(e, "revealed");
    }, { once: !0 }));
  }
  function loadImmediately(e, t, n, r) {
    const o = function() {
      n.loaded || (n.loaded = !0, triggerEvent(e, "htmx:trigger"), t(e));
    };
    r > 0 ? getWindow().setTimeout(o, r) : o();
  }
  function processVerbs(e, t, n) {
    let r = !1;
    return forEach(VERBS, function(o) {
      if (hasAttribute(e, "hx-" + o)) {
        const i = getAttributeValue(e, "hx-" + o);
        r = !0, t.path = i, t.verb = o, n.forEach(function(s) {
          addTriggerHandler(e, s, t, function(l, a) {
            const u = asElement(l);
            if (eltIsDisabled(u)) {
              cleanUpElement(u);
              return;
            }
            issueAjaxRequest(o, i, u, a);
          });
        });
      }
    }), r;
  }
  function addTriggerHandler(e, t, n, r) {
    if (t.trigger === "revealed")
      initScrollHandler(), addEventListener(e, r, n, t), maybeReveal(asElement(e));
    else if (t.trigger === "intersect") {
      const o = {};
      t.root && (o.root = querySelectorExt(e, t.root)), t.threshold && (o.threshold = parseFloat(t.threshold)), new IntersectionObserver(function(s) {
        for (let l = 0; l < s.length; l++)
          if (s[l].isIntersecting) {
            triggerEvent(e, "intersect");
            break;
          }
      }, o).observe(asElement(e)), addEventListener(asElement(e), r, n, t);
    } else !n.firstInitCompleted && t.trigger === "load" ? maybeFilterEvent(t, e, makeEvent("load", { elt: e })) || loadImmediately(asElement(e), r, n, t.delay) : t.pollInterval > 0 ? (n.polling = !0, processPolling(asElement(e), r, t)) : addEventListener(e, r, n, t);
  }
  function shouldProcessHxOn(e) {
    const t = asElement(e);
    if (!t)
      return !1;
    const n = t.attributes;
    for (let r = 0; r < n.length; r++) {
      const o = n[r].name;
      if (startsWith(o, "hx-on:") || startsWith(o, "data-hx-on:") || startsWith(o, "hx-on-") || startsWith(o, "data-hx-on-"))
        return !0;
    }
    return !1;
  }
  const HX_ON_QUERY = new XPathEvaluator().createExpression('.//*[@*[ starts-with(name(), "hx-on:") or starts-with(name(), "data-hx-on:") or starts-with(name(), "hx-on-") or starts-with(name(), "data-hx-on-") ]]');
  function processHXOnRoot(e, t) {
    shouldProcessHxOn(e) && t.push(asElement(e));
    const n = HX_ON_QUERY.evaluate(e);
    let r = null;
    for (; r = n.iterateNext(); ) t.push(asElement(r));
  }
  function findHxOnWildcardElements(e) {
    const t = [];
    if (e instanceof DocumentFragment)
      for (const n of e.childNodes)
        processHXOnRoot(n, t);
    else
      processHXOnRoot(e, t);
    return t;
  }
  function findElementsToProcess(e) {
    if (e.querySelectorAll) {
      const n = ", [hx-boost] a, [data-hx-boost] a, a[hx-boost], a[data-hx-boost]", r = [];
      for (const i in extensions) {
        const s = extensions[i];
        if (s.getSelectors) {
          var t = s.getSelectors();
          t && r.push(t);
        }
      }
      return e.querySelectorAll(VERB_SELECTOR + n + ", form, [type='submit'], [hx-ext], [data-hx-ext], [hx-trigger], [data-hx-trigger]" + r.flat().map((i) => ", " + i).join(""));
    } else
      return [];
  }
  function maybeSetLastButtonClicked(e) {
    const t = getTargetButton(e.target), n = getRelatedFormData(e);
    n && (n.lastButtonClicked = t);
  }
  function maybeUnsetLastButtonClicked(e) {
    const t = getRelatedFormData(e);
    t && (t.lastButtonClicked = null);
  }
  function getTargetButton(e) {
    return (
      /** @type {HTMLButtonElement|HTMLInputElement|null} */
      closest(asElement(e), "button, input[type='submit']")
    );
  }
  function getRelatedForm(e) {
    return e.form || closest(e, "form");
  }
  function getRelatedFormData(e) {
    const t = getTargetButton(e.target);
    if (!t)
      return;
    const n = getRelatedForm(t);
    return getInternalData(n);
  }
  function initButtonTracking(e) {
    e.addEventListener("click", maybeSetLastButtonClicked), e.addEventListener("focusin", maybeSetLastButtonClicked), e.addEventListener("focusout", maybeUnsetLastButtonClicked);
  }
  function addHxOnEventHandler(e, t, n) {
    const r = getInternalData(e);
    Array.isArray(r.onHandlers) || (r.onHandlers = []);
    let o;
    const i = function(s) {
      maybeEval(e, function() {
        eltIsDisabled(e) || (o || (o = new Function("event", n)), o.call(e, s));
      });
    };
    e.addEventListener(t, i), r.onHandlers.push({ event: t, listener: i });
  }
  function processHxOnWildcard(e) {
    deInitOnHandlers(e);
    for (let t = 0; t < e.attributes.length; t++) {
      const n = e.attributes[t].name, r = e.attributes[t].value;
      if (startsWith(n, "hx-on") || startsWith(n, "data-hx-on")) {
        const o = n.indexOf("-on") + 3, i = n.slice(o, o + 1);
        if (i === "-" || i === ":") {
          let s = n.slice(o + 1);
          startsWith(s, ":") ? s = "htmx" + s : startsWith(s, "-") ? s = "htmx:" + s.slice(1) : startsWith(s, "htmx-") && (s = "htmx:" + s.slice(5)), addHxOnEventHandler(e, s, r);
        }
      }
    }
  }
  function initNode(e) {
    triggerEvent(e, "htmx:beforeProcessNode");
    const t = getInternalData(e), n = getTriggerSpecs(e);
    processVerbs(e, t, n) || (getClosestAttributeValue(e, "hx-boost") === "true" ? boostElement(e, t, n) : hasAttribute(e, "hx-trigger") && n.forEach(function(o) {
      addTriggerHandler(e, o, t, function() {
      });
    })), (e.tagName === "FORM" || getRawAttribute(e, "type") === "submit" && hasAttribute(e, "form")) && initButtonTracking(e), t.firstInitCompleted = !0, triggerEvent(e, "htmx:afterProcessNode");
  }
  function maybeDeInitAndHash(e) {
    if (!(e instanceof Element))
      return !1;
    const t = getInternalData(e), n = attributeHash(e);
    return t.initHash !== n ? (deInitNode(e), t.initHash = n, !0) : !1;
  }
  function processNode(e) {
    if (e = resolveTarget(e), eltIsDisabled(e)) {
      cleanUpElement(e);
      return;
    }
    const t = [];
    maybeDeInitAndHash(e) && t.push(e), forEach(findElementsToProcess(e), function(n) {
      if (eltIsDisabled(n)) {
        cleanUpElement(n);
        return;
      }
      maybeDeInitAndHash(n) && t.push(n);
    }), forEach(findHxOnWildcardElements(e), processHxOnWildcard), forEach(t, initNode);
  }
  function kebabEventName(e) {
    return e.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
  }
  function makeEvent(e, t) {
    return new CustomEvent(e, { bubbles: !0, cancelable: !0, composed: !0, detail: t });
  }
  function triggerErrorEvent(e, t, n) {
    triggerEvent(e, t, mergeObjects({ error: t }, n));
  }
  function ignoreEventForLogging(e) {
    return e === "htmx:afterProcessNode";
  }
  function withExtensions(e, t, n) {
    forEach(getExtensions(e, [], n), function(r) {
      try {
        t(r);
      } catch (o) {
        logError(o);
      }
    });
  }
  function logError(e) {
    console.error(e);
  }
  function triggerEvent(e, t, n) {
    e = resolveTarget(e), n == null && (n = {}), n.elt = e;
    const r = makeEvent(t, n);
    htmx.logger && !ignoreEventForLogging(t) && htmx.logger(e, t, n), n.error && (logError(n.error), triggerEvent(e, "htmx:error", { errorInfo: n }));
    let o = e.dispatchEvent(r);
    const i = kebabEventName(t);
    if (o && i !== t) {
      const s = makeEvent(i, r.detail);
      o = o && e.dispatchEvent(s);
    }
    return withExtensions(asElement(e), function(s) {
      o = o && s.onEvent(t, r) !== !1 && !r.defaultPrevented;
    }), o;
  }
  let currentPathForHistory = location.pathname + location.search;
  function setCurrentPathForHistory(e) {
    currentPathForHistory = e, canAccessLocalStorage() && sessionStorage.setItem("htmx-current-path-for-history", e);
  }
  function getHistoryElement() {
    return getDocument().querySelector("[hx-history-elt],[data-hx-history-elt]") || getDocument().body;
  }
  function saveToHistoryCache(e, t) {
    if (!canAccessLocalStorage())
      return;
    const n = cleanInnerHtmlForHistory(t), r = getDocument().title, o = window.scrollY;
    if (htmx.config.historyCacheSize <= 0) {
      sessionStorage.removeItem("htmx-history-cache");
      return;
    }
    e = normalizePath(e);
    const i = parseJSON(sessionStorage.getItem("htmx-history-cache")) || [];
    for (let l = 0; l < i.length; l++)
      if (i[l].url === e) {
        i.splice(l, 1);
        break;
      }
    const s = { url: e, content: n, title: r, scroll: o };
    for (triggerEvent(getDocument().body, "htmx:historyItemCreated", { item: s, cache: i }), i.push(s); i.length > htmx.config.historyCacheSize; )
      i.shift();
    for (; i.length > 0; )
      try {
        sessionStorage.setItem("htmx-history-cache", JSON.stringify(i));
        break;
      } catch (l) {
        triggerErrorEvent(getDocument().body, "htmx:historyCacheError", { cause: l, cache: i }), i.shift();
      }
  }
  function getCachedHistory(e) {
    if (!canAccessLocalStorage())
      return null;
    e = normalizePath(e);
    const t = parseJSON(sessionStorage.getItem("htmx-history-cache")) || [];
    for (let n = 0; n < t.length; n++)
      if (t[n].url === e)
        return t[n];
    return null;
  }
  function cleanInnerHtmlForHistory(e) {
    const t = htmx.config.requestClass, n = (
      /** @type Element */
      e.cloneNode(!0)
    );
    return forEach(findAll(n, "." + t), function(r) {
      removeClassFromElement(r, t);
    }), forEach(findAll(n, "[data-disabled-by-htmx]"), function(r) {
      r.removeAttribute("disabled");
    }), n.innerHTML;
  }
  function saveCurrentPageToHistory() {
    const e = getHistoryElement();
    let t = currentPathForHistory;
    canAccessLocalStorage() && (t = sessionStorage.getItem("htmx-current-path-for-history")), t = t || location.pathname + location.search, getDocument().querySelector('[hx-history="false" i],[data-hx-history="false" i]') || (triggerEvent(getDocument().body, "htmx:beforeHistorySave", { path: t, historyElt: e }), saveToHistoryCache(t, e)), htmx.config.historyEnabled && history.replaceState({ htmx: !0 }, getDocument().title, location.href);
  }
  function pushUrlIntoHistory(e) {
    htmx.config.getCacheBusterParam && (e = e.replace(/org\.htmx\.cache-buster=[^&]*&?/, ""), (endsWith(e, "&") || endsWith(e, "?")) && (e = e.slice(0, -1))), htmx.config.historyEnabled && history.pushState({ htmx: !0 }, "", e), setCurrentPathForHistory(e);
  }
  function replaceUrlInHistory(e) {
    htmx.config.historyEnabled && history.replaceState({ htmx: !0 }, "", e), setCurrentPathForHistory(e);
  }
  function settleImmediately(e) {
    forEach(e, function(t) {
      t.call(void 0);
    });
  }
  function loadHistoryFromServer(e) {
    const t = new XMLHttpRequest(), n = { swapStyle: "innerHTML", swapDelay: 0, settleDelay: 0 }, r = { path: e, xhr: t, historyElt: getHistoryElement(), swapSpec: n };
    t.open("GET", e, !0), htmx.config.historyRestoreAsHxRequest && t.setRequestHeader("HX-Request", "true"), t.setRequestHeader("HX-History-Restore-Request", "true"), t.setRequestHeader("HX-Current-URL", location.href), t.onload = function() {
      this.status >= 200 && this.status < 400 ? (r.response = this.response, triggerEvent(getDocument().body, "htmx:historyCacheMissLoad", r), swap(r.historyElt, r.response, n, {
        contextElement: r.historyElt,
        historyRequest: !0
      }), setCurrentPathForHistory(r.path), triggerEvent(getDocument().body, "htmx:historyRestore", { path: e, cacheMiss: !0, serverResponse: r.response })) : triggerErrorEvent(getDocument().body, "htmx:historyCacheMissLoadError", r);
    }, triggerEvent(getDocument().body, "htmx:historyCacheMiss", r) && t.send();
  }
  function restoreHistory(e) {
    saveCurrentPageToHistory(), e = e || location.pathname + location.search;
    const t = getCachedHistory(e);
    if (t) {
      const n = { swapStyle: "innerHTML", swapDelay: 0, settleDelay: 0, scroll: t.scroll }, r = { path: e, item: t, historyElt: getHistoryElement(), swapSpec: n };
      triggerEvent(getDocument().body, "htmx:historyCacheHit", r) && (swap(r.historyElt, t.content, n, {
        contextElement: r.historyElt,
        title: t.title
      }), setCurrentPathForHistory(r.path), triggerEvent(getDocument().body, "htmx:historyRestore", r));
    } else
      htmx.config.refreshOnHistoryMiss ? htmx.location.reload(!0) : loadHistoryFromServer(e);
  }
  function addRequestIndicatorClasses(e) {
    let t = (
      /** @type Element[] */
      findAttributeTargets(e, "hx-indicator")
    );
    return t == null && (t = [e]), forEach(t, function(n) {
      const r = getInternalData(n);
      r.requestCount = (r.requestCount || 0) + 1, n.classList.add.call(n.classList, htmx.config.requestClass);
    }), t;
  }
  function disableElements(e) {
    let t = (
      /** @type Element[] */
      findAttributeTargets(e, "hx-disabled-elt")
    );
    return t == null && (t = []), forEach(t, function(n) {
      const r = getInternalData(n);
      r.requestCount = (r.requestCount || 0) + 1, n.setAttribute("disabled", ""), n.setAttribute("data-disabled-by-htmx", "");
    }), t;
  }
  function removeRequestIndicators(e, t) {
    forEach(e.concat(t), function(n) {
      const r = getInternalData(n);
      r.requestCount = (r.requestCount || 1) - 1;
    }), forEach(e, function(n) {
      getInternalData(n).requestCount === 0 && n.classList.remove.call(n.classList, htmx.config.requestClass);
    }), forEach(t, function(n) {
      getInternalData(n).requestCount === 0 && (n.removeAttribute("disabled"), n.removeAttribute("data-disabled-by-htmx"));
    });
  }
  function haveSeenNode(e, t) {
    for (let n = 0; n < e.length; n++)
      if (e[n].isSameNode(t))
        return !0;
    return !1;
  }
  function shouldInclude(e) {
    const t = (
      /** @type {HTMLInputElement} */
      e
    );
    return t.name === "" || t.name == null || t.disabled || closest(t, "fieldset[disabled]") || t.type === "button" || t.type === "submit" || t.tagName === "image" || t.tagName === "reset" || t.tagName === "file" ? !1 : t.type === "checkbox" || t.type === "radio" ? t.checked : !0;
  }
  function addValueToFormData(e, t, n) {
    e != null && t != null && (Array.isArray(t) ? t.forEach(function(r) {
      n.append(e, r);
    }) : n.append(e, t));
  }
  function removeValueFromFormData(e, t, n) {
    if (e != null && t != null) {
      let r = n.getAll(e);
      Array.isArray(t) ? r = r.filter((o) => t.indexOf(o) < 0) : r = r.filter((o) => o !== t), n.delete(e), forEach(r, (o) => n.append(e, o));
    }
  }
  function getValueFromInput(e) {
    return e instanceof HTMLSelectElement && e.multiple ? toArray(e.querySelectorAll("option:checked")).map(function(t) {
      return (
        /** @type HTMLOptionElement */
        t.value
      );
    }) : e instanceof HTMLInputElement && e.files ? toArray(e.files) : e.value;
  }
  function processInputValue(e, t, n, r, o) {
    if (!(r == null || haveSeenNode(e, r))) {
      if (e.push(r), shouldInclude(r)) {
        const i = getRawAttribute(r, "name");
        addValueToFormData(i, getValueFromInput(r), t), o && validateElement(r, n);
      }
      r instanceof HTMLFormElement && (forEach(r.elements, function(i) {
        e.indexOf(i) >= 0 ? removeValueFromFormData(i.name, getValueFromInput(i), t) : e.push(i), o && validateElement(i, n);
      }), new FormData(r).forEach(function(i, s) {
        i instanceof File && i.name === "" || addValueToFormData(s, i, t);
      }));
    }
  }
  function validateElement(e, t) {
    const n = (
      /** @type {HTMLElement & ElementInternals} */
      e
    );
    n.willValidate && (triggerEvent(n, "htmx:validation:validate"), n.checkValidity() || (t.push({ elt: n, message: n.validationMessage, validity: n.validity }), triggerEvent(n, "htmx:validation:failed", { message: n.validationMessage, validity: n.validity })));
  }
  function overrideFormData(e, t) {
    for (const n of t.keys())
      e.delete(n);
    return t.forEach(function(n, r) {
      e.append(r, n);
    }), e;
  }
  function getInputValues(e, t) {
    const n = [], r = new FormData(), o = new FormData(), i = [], s = getInternalData(e);
    s.lastButtonClicked && !bodyContains(s.lastButtonClicked) && (s.lastButtonClicked = null);
    let l = e instanceof HTMLFormElement && e.noValidate !== !0 || getAttributeValue(e, "hx-validate") === "true";
    if (s.lastButtonClicked && (l = l && s.lastButtonClicked.formNoValidate !== !0), t !== "get" && processInputValue(n, o, i, getRelatedForm(e), l), processInputValue(n, r, i, e, l), s.lastButtonClicked || e.tagName === "BUTTON" || e.tagName === "INPUT" && getRawAttribute(e, "type") === "submit") {
      const u = s.lastButtonClicked || /** @type HTMLInputElement|HTMLButtonElement */
      e, h = getRawAttribute(u, "name");
      addValueToFormData(h, u.value, o);
    }
    const a = findAttributeTargets(e, "hx-include");
    return forEach(a, function(u) {
      processInputValue(n, r, i, asElement(u), l), matches(u, "form") || forEach(asParentNode(u).querySelectorAll(INPUT_SELECTOR), function(h) {
        processInputValue(n, r, i, h, l);
      });
    }), overrideFormData(r, o), { errors: i, formData: r, values: formDataProxy(r) };
  }
  function appendParam(e, t, n) {
    e !== "" && (e += "&"), String(n) === "[object Object]" && (n = JSON.stringify(n));
    const r = encodeURIComponent(n);
    return e += encodeURIComponent(t) + "=" + r, e;
  }
  function urlEncode(e) {
    e = formDataFromObject(e);
    let t = "";
    return e.forEach(function(n, r) {
      t = appendParam(t, r, n);
    }), t;
  }
  function getHeaders(e, t, n) {
    const r = {
      "HX-Request": "true",
      "HX-Trigger": getRawAttribute(e, "id"),
      "HX-Trigger-Name": getRawAttribute(e, "name"),
      "HX-Target": getAttributeValue(t, "id"),
      "HX-Current-URL": location.href
    };
    return getValuesForElement(e, "hx-headers", !1, r), n !== void 0 && (r["HX-Prompt"] = n), getInternalData(e).boosted && (r["HX-Boosted"] = "true"), r;
  }
  function filterValues(e, t) {
    const n = getClosestAttributeValue(t, "hx-params");
    if (n) {
      if (n === "none")
        return new FormData();
      if (n === "*")
        return e;
      if (n.indexOf("not ") === 0)
        return forEach(n.slice(4).split(","), function(r) {
          r = r.trim(), e.delete(r);
        }), e;
      {
        const r = new FormData();
        return forEach(n.split(","), function(o) {
          o = o.trim(), e.has(o) && e.getAll(o).forEach(function(i) {
            r.append(o, i);
          });
        }), r;
      }
    } else
      return e;
  }
  function isAnchorLink(e) {
    return !!getRawAttribute(e, "href") && getRawAttribute(e, "href").indexOf("#") >= 0;
  }
  function getSwapSpecification(e, t) {
    const n = t || getClosestAttributeValue(e, "hx-swap"), r = {
      swapStyle: getInternalData(e).boosted ? "innerHTML" : htmx.config.defaultSwapStyle,
      swapDelay: htmx.config.defaultSwapDelay,
      settleDelay: htmx.config.defaultSettleDelay
    };
    if (htmx.config.scrollIntoViewOnBoost && getInternalData(e).boosted && !isAnchorLink(e) && (r.show = "top"), n) {
      const s = splitOnWhitespace(n);
      if (s.length > 0)
        for (let l = 0; l < s.length; l++) {
          const a = s[l];
          if (a.indexOf("swap:") === 0)
            r.swapDelay = parseInterval(a.slice(5));
          else if (a.indexOf("settle:") === 0)
            r.settleDelay = parseInterval(a.slice(7));
          else if (a.indexOf("transition:") === 0)
            r.transition = a.slice(11) === "true";
          else if (a.indexOf("ignoreTitle:") === 0)
            r.ignoreTitle = a.slice(12) === "true";
          else if (a.indexOf("scroll:") === 0) {
            var o = a.slice(7).split(":");
            const h = o.pop();
            var i = o.length > 0 ? o.join(":") : null;
            r.scroll = h, r.scrollTarget = i;
          } else if (a.indexOf("show:") === 0) {
            var o = a.slice(5).split(":");
            const c = o.pop();
            var i = o.length > 0 ? o.join(":") : null;
            r.show = c, r.showTarget = i;
          } else if (a.indexOf("focus-scroll:") === 0) {
            const u = a.slice(13);
            r.focusScroll = u == "true";
          } else l == 0 ? r.swapStyle = a : logError("Unknown modifier in hx-swap: " + a);
        }
    }
    return r;
  }
  function usesFormData(e) {
    return getClosestAttributeValue(e, "hx-encoding") === "multipart/form-data" || matches(e, "form") && getRawAttribute(e, "enctype") === "multipart/form-data";
  }
  function encodeParamsForBody(e, t, n) {
    let r = null;
    return withExtensions(t, function(o) {
      r == null && (r = o.encodeParameters(e, n, t));
    }), r ?? (usesFormData(t) ? overrideFormData(new FormData(), formDataFromObject(n)) : urlEncode(n));
  }
  function makeSettleInfo(e) {
    return { tasks: [], elts: [e] };
  }
  function updateScrollState(e, t) {
    const n = e[0], r = e[e.length - 1];
    if (t.scroll) {
      var o = null;
      t.scrollTarget && (o = asElement(querySelectorExt(n, t.scrollTarget))), t.scroll === "top" && (n || o) && (o = o || n, o.scrollTop = 0), t.scroll === "bottom" && (r || o) && (o = o || r, o.scrollTop = o.scrollHeight), typeof t.scroll == "number" && getWindow().setTimeout(function() {
        window.scrollTo(
          0,
          /** @type number */
          t.scroll
        );
      }, 0);
    }
    if (t.show) {
      var o = null;
      if (t.showTarget) {
        let s = t.showTarget;
        t.showTarget === "window" && (s = "body"), o = asElement(querySelectorExt(n, s));
      }
      t.show === "top" && (n || o) && (o = o || n, o.scrollIntoView({ block: "start", behavior: htmx.config.scrollBehavior })), t.show === "bottom" && (r || o) && (o = o || r, o.scrollIntoView({ block: "end", behavior: htmx.config.scrollBehavior }));
    }
  }
  function getValuesForElement(e, t, n, r, o) {
    if (r == null && (r = {}), e == null)
      return r;
    const i = getAttributeValue(e, t);
    if (i) {
      let s = i.trim(), l = n;
      if (s === "unset")
        return null;
      s.indexOf("javascript:") === 0 ? (s = s.slice(11), l = !0) : s.indexOf("js:") === 0 && (s = s.slice(3), l = !0), s.indexOf("{") !== 0 && (s = "{" + s + "}");
      let a;
      l ? a = maybeEval(e, function() {
        return o ? Function("event", "return (" + s + ")").call(e, o) : Function("return (" + s + ")").call(e);
      }, {}) : a = parseJSON(s);
      for (const u in a)
        a.hasOwnProperty(u) && r[u] == null && (r[u] = a[u]);
    }
    return getValuesForElement(asElement(parentElt(e)), t, n, r, o);
  }
  function maybeEval(e, t, n) {
    return htmx.config.allowEval ? t() : (triggerErrorEvent(e, "htmx:evalDisallowedError"), n);
  }
  function getHXVarsForElement(e, t, n) {
    return getValuesForElement(e, "hx-vars", !0, n, t);
  }
  function getHXValsForElement(e, t, n) {
    return getValuesForElement(e, "hx-vals", !1, n, t);
  }
  function getExpressionVars(e, t) {
    return mergeObjects(getHXVarsForElement(e, t), getHXValsForElement(e, t));
  }
  function safelySetHeaderValue(e, t, n) {
    if (n !== null)
      try {
        e.setRequestHeader(t, n);
      } catch {
        e.setRequestHeader(t, encodeURIComponent(n)), e.setRequestHeader(t + "-URI-AutoEncoded", "true");
      }
  }
  function getPathFromResponse(e) {
    if (e.responseURL)
      try {
        const t = new URL(e.responseURL);
        return t.pathname + t.search;
      } catch {
        triggerErrorEvent(getDocument().body, "htmx:badResponseUrl", { url: e.responseURL });
      }
  }
  function hasHeader(e, t) {
    return t.test(e.getAllResponseHeaders());
  }
  function ajaxHelper(e, t, n) {
    if (e = /** @type HttpVerb */
    e.toLowerCase(), n) {
      if (n instanceof Element || typeof n == "string")
        return issueAjaxRequest(e, t, null, null, {
          targetOverride: resolveTarget(n) || DUMMY_ELT,
          returnPromise: !0
        });
      {
        let r = resolveTarget(n.target);
        return (n.target && !r || n.source && !r && !resolveTarget(n.source)) && (r = DUMMY_ELT), issueAjaxRequest(
          e,
          t,
          resolveTarget(n.source),
          n.event,
          {
            handler: n.handler,
            headers: n.headers,
            values: n.values,
            targetOverride: r,
            swapOverride: n.swap,
            select: n.select,
            returnPromise: !0
          }
        );
      }
    } else
      return issueAjaxRequest(e, t, null, null, {
        returnPromise: !0
      });
  }
  function hierarchyForElt(e) {
    const t = [];
    for (; e; )
      t.push(e), e = e.parentElement;
    return t;
  }
  function verifyPath(e, t, n) {
    const r = new URL(t, location.protocol !== "about:" ? location.href : window.origin), i = (location.protocol !== "about:" ? location.origin : window.origin) === r.origin;
    return htmx.config.selfRequestsOnly && !i ? !1 : triggerEvent(e, "htmx:validateUrl", mergeObjects({ url: r, sameHost: i }, n));
  }
  function formDataFromObject(e) {
    if (e instanceof FormData) return e;
    const t = new FormData();
    for (const n in e)
      e.hasOwnProperty(n) && (e[n] && typeof e[n].forEach == "function" ? e[n].forEach(function(r) {
        t.append(n, r);
      }) : typeof e[n] == "object" && !(e[n] instanceof Blob) ? t.append(n, JSON.stringify(e[n])) : t.append(n, e[n]));
    return t;
  }
  function formDataArrayProxy(e, t, n) {
    return new Proxy(n, {
      get: function(r, o) {
        return typeof o == "number" ? r[o] : o === "length" ? r.length : o === "push" ? function(i) {
          r.push(i), e.append(t, i);
        } : typeof r[o] == "function" ? function() {
          r[o].apply(r, arguments), e.delete(t), r.forEach(function(i) {
            e.append(t, i);
          });
        } : r[o] && r[o].length === 1 ? r[o][0] : r[o];
      },
      set: function(r, o, i) {
        return r[o] = i, e.delete(t), r.forEach(function(s) {
          e.append(t, s);
        }), !0;
      }
    });
  }
  function formDataProxy(e) {
    return new Proxy(e, {
      get: function(t, n) {
        if (typeof n == "symbol") {
          const o = Reflect.get(t, n);
          return typeof o == "function" ? function() {
            return o.apply(e, arguments);
          } : o;
        }
        if (n === "toJSON")
          return () => Object.fromEntries(e);
        if (n in t && typeof t[n] == "function")
          return function() {
            return e[n].apply(e, arguments);
          };
        const r = e.getAll(n);
        if (r.length !== 0)
          return r.length === 1 ? r[0] : formDataArrayProxy(t, n, r);
      },
      set: function(t, n, r) {
        return typeof n != "string" ? !1 : (t.delete(n), r && typeof r.forEach == "function" ? r.forEach(function(o) {
          t.append(n, o);
        }) : typeof r == "object" && !(r instanceof Blob) ? t.append(n, JSON.stringify(r)) : t.append(n, r), !0);
      },
      deleteProperty: function(t, n) {
        return typeof n == "string" && t.delete(n), !0;
      },
      // Support Object.assign call from proxy
      ownKeys: function(t) {
        return Reflect.ownKeys(Object.fromEntries(t));
      },
      getOwnPropertyDescriptor: function(t, n) {
        return Reflect.getOwnPropertyDescriptor(Object.fromEntries(t), n);
      }
    });
  }
  function issueAjaxRequest(e, t, n, r, o, i) {
    let s = null, l = null;
    if (o = o ?? {}, o.returnPromise && typeof Promise < "u")
      var a = new Promise(function(g, b) {
        s = g, l = b;
      });
    n == null && (n = getDocument().body);
    const u = o.handler || handleAjaxResponse, h = o.select || null;
    if (!bodyContains(n))
      return maybeCall(s), a;
    const c = o.targetOverride || asElement(getTarget(n));
    if (c == null || c == DUMMY_ELT)
      return triggerErrorEvent(n, "htmx:targetError", { target: getClosestAttributeValue(n, "hx-target") }), maybeCall(l), a;
    let f = getInternalData(n);
    const y = f.lastButtonClicked;
    if (y) {
      const g = getRawAttribute(y, "formaction");
      g != null && (t = g);
      const b = getRawAttribute(y, "formmethod");
      if (b != null)
        if (VERBS.includes(b.toLowerCase()))
          e = /** @type HttpVerb */
          b;
        else
          return maybeCall(s), a;
    }
    const d = getClosestAttributeValue(n, "hx-confirm");
    if (i === void 0 && triggerEvent(n, "htmx:confirm", { target: c, elt: n, path: t, verb: e, triggeringEvent: r, etc: o, issueRequest: function(H) {
      return issueAjaxRequest(e, t, n, r, o, !!H);
    }, question: d }) === !1)
      return maybeCall(s), a;
    let E = n, m = getClosestAttributeValue(n, "hx-sync"), C = null, w = !1;
    if (m) {
      const g = m.split(":"), b = g[0].trim();
      if (b === "this" ? E = findThisElement(n, "hx-sync") : E = asElement(querySelectorExt(n, b)), m = (g[1] || "drop").trim(), f = getInternalData(E), m === "drop" && f.xhr && f.abortable !== !0)
        return maybeCall(s), a;
      if (m === "abort") {
        if (f.xhr)
          return maybeCall(s), a;
        w = !0;
      } else m === "replace" ? triggerEvent(E, "htmx:abort") : m.indexOf("queue") === 0 && (C = (m.split(" ")[1] || "last").trim());
    }
    if (f.xhr)
      if (f.abortable)
        triggerEvent(E, "htmx:abort");
      else {
        if (C == null) {
          if (r) {
            const g = getInternalData(r);
            g && g.triggerSpec && g.triggerSpec.queue && (C = g.triggerSpec.queue);
          }
          C == null && (C = "last");
        }
        return f.queuedRequests == null && (f.queuedRequests = []), C === "first" && f.queuedRequests.length === 0 ? f.queuedRequests.push(function() {
          issueAjaxRequest(e, t, n, r, o);
        }) : C === "all" ? f.queuedRequests.push(function() {
          issueAjaxRequest(e, t, n, r, o);
        }) : C === "last" && (f.queuedRequests = [], f.queuedRequests.push(function() {
          issueAjaxRequest(e, t, n, r, o);
        })), maybeCall(s), a;
      }
    const x = new XMLHttpRequest();
    f.xhr = x, f.abortable = w;
    const p = function() {
      f.xhr = null, f.abortable = !1, f.queuedRequests != null && f.queuedRequests.length > 0 && f.queuedRequests.shift()();
    }, V = getClosestAttributeValue(n, "hx-prompt");
    if (V) {
      var P = prompt(V);
      if (P === null || !triggerEvent(n, "htmx:prompt", { prompt: P, target: c }))
        return maybeCall(s), p(), a;
    }
    if (d && !i && !confirm(d))
      return maybeCall(s), p(), a;
    let T = getHeaders(n, c, P);
    e !== "get" && !usesFormData(n) && (T["Content-Type"] = "application/x-www-form-urlencoded"), o.headers && (T = mergeObjects(T, o.headers));
    const M = getInputValues(n, e);
    let D = M.errors;
    const B = M.formData;
    o.values && overrideFormData(B, formDataFromObject(o.values));
    const _ = formDataFromObject(getExpressionVars(n, r)), F = overrideFormData(B, _);
    let R = filterValues(F, n);
    htmx.config.getCacheBusterParam && e === "get" && R.set("org.htmx.cache-buster", getRawAttribute(c, "id") || "true"), (t == null || t === "") && (t = location.href);
    const q = getValuesForElement(n, "hx-request"), U = getInternalData(n).boosted;
    let O = htmx.config.methodsThatUseUrlParams.indexOf(e) >= 0;
    const A = {
      boosted: U,
      useUrlParams: O,
      formData: R,
      parameters: formDataProxy(R),
      unfilteredFormData: F,
      unfilteredParameters: formDataProxy(F),
      headers: T,
      elt: n,
      target: c,
      verb: e,
      errors: D,
      withCredentials: o.credentials || q.credentials || htmx.config.withCredentials,
      timeout: o.timeout || q.timeout || htmx.config.timeout,
      path: t,
      triggeringEvent: r
    };
    if (!triggerEvent(n, "htmx:configRequest", A))
      return maybeCall(s), p(), a;
    if (t = A.path, e = A.verb, T = A.headers, R = formDataFromObject(A.parameters), D = A.errors, O = A.useUrlParams, D && D.length > 0)
      return triggerEvent(n, "htmx:validation:halted", A), maybeCall(s), p(), a;
    const k = t.split("#"), W = k[0], N = k[1];
    let S = t;
    if (O && (S = W, !R.keys().next().done && (S.indexOf("?") < 0 ? S += "?" : S += "&", S += urlEncode(R), N && (S += "#" + N))), !verifyPath(n, S, A))
      return triggerErrorEvent(n, "htmx:invalidPath", A), maybeCall(l), p(), a;
    if (x.open(e.toUpperCase(), S, !0), x.overrideMimeType("text/html"), x.withCredentials = A.withCredentials, x.timeout = A.timeout, !q.noHeaders) {
      for (const g in T)
        if (T.hasOwnProperty(g)) {
          const b = T[g];
          safelySetHeaderValue(x, g, b);
        }
    }
    const v = {
      xhr: x,
      target: c,
      requestConfig: A,
      etc: o,
      boosted: U,
      select: h,
      pathInfo: {
        requestPath: t,
        finalRequestPath: S,
        responsePath: null,
        anchor: N
      }
    };
    if (x.onload = function() {
      try {
        const g = hierarchyForElt(n);
        if (v.pathInfo.responsePath = getPathFromResponse(x), u(n, v), v.keepIndicators !== !0 && removeRequestIndicators(I, L), triggerEvent(n, "htmx:afterRequest", v), triggerEvent(n, "htmx:afterOnLoad", v), !bodyContains(n)) {
          let b = null;
          for (; g.length > 0 && b == null; ) {
            const H = g.shift();
            bodyContains(H) && (b = H);
          }
          b && (triggerEvent(b, "htmx:afterRequest", v), triggerEvent(b, "htmx:afterOnLoad", v));
        }
        maybeCall(s);
      } catch (g) {
        throw triggerErrorEvent(n, "htmx:onLoadError", mergeObjects({ error: g }, v)), g;
      } finally {
        p();
      }
    }, x.onerror = function() {
      removeRequestIndicators(I, L), triggerErrorEvent(n, "htmx:afterRequest", v), triggerErrorEvent(n, "htmx:sendError", v), maybeCall(l), p();
    }, x.onabort = function() {
      removeRequestIndicators(I, L), triggerErrorEvent(n, "htmx:afterRequest", v), triggerErrorEvent(n, "htmx:sendAbort", v), maybeCall(l), p();
    }, x.ontimeout = function() {
      removeRequestIndicators(I, L), triggerErrorEvent(n, "htmx:afterRequest", v), triggerErrorEvent(n, "htmx:timeout", v), maybeCall(l), p();
    }, !triggerEvent(n, "htmx:beforeRequest", v))
      return maybeCall(s), p(), a;
    var I = addRequestIndicatorClasses(n), L = disableElements(n);
    forEach(["loadstart", "loadend", "progress", "abort"], function(g) {
      forEach([x, x.upload], function(b) {
        b.addEventListener(g, function(H) {
          triggerEvent(n, "htmx:xhr:" + g, {
            lengthComputable: H.lengthComputable,
            loaded: H.loaded,
            total: H.total
          });
        });
      });
    }), triggerEvent(n, "htmx:beforeSend", v);
    const j = O ? null : encodeParamsForBody(x, n, R);
    return x.send(j), a;
  }
  function determineHistoryUpdates(e, t) {
    const n = t.xhr;
    let r = null, o = null;
    if (hasHeader(n, /HX-Push:/i) ? (r = n.getResponseHeader("HX-Push"), o = "push") : hasHeader(n, /HX-Push-Url:/i) ? (r = n.getResponseHeader("HX-Push-Url"), o = "push") : hasHeader(n, /HX-Replace-Url:/i) && (r = n.getResponseHeader("HX-Replace-Url"), o = "replace"), r)
      return r === "false" ? {} : {
        type: o,
        path: r
      };
    const i = t.pathInfo.finalRequestPath, s = t.pathInfo.responsePath, l = getClosestAttributeValue(e, "hx-push-url"), a = getClosestAttributeValue(e, "hx-replace-url"), u = getInternalData(e).boosted;
    let h = null, c = null;
    return l ? (h = "push", c = l) : a ? (h = "replace", c = a) : u && (h = "push", c = s || i), c ? c === "false" ? {} : (c === "true" && (c = s || i), t.pathInfo.anchor && c.indexOf("#") === -1 && (c = c + "#" + t.pathInfo.anchor), {
      type: h,
      path: c
    }) : {};
  }
  function codeMatches(e, t) {
    var n = new RegExp(e.code);
    return n.test(t.toString(10));
  }
  function resolveResponseHandling(e) {
    for (var t = 0; t < htmx.config.responseHandling.length; t++) {
      var n = htmx.config.responseHandling[t];
      if (codeMatches(n, e.status))
        return n;
    }
    return {
      swap: !1
    };
  }
  function handleTitle(e) {
    if (e) {
      const t = find("title");
      t ? t.textContent = e : window.document.title = e;
    }
  }
  function resolveRetarget(e, t) {
    if (t === "this")
      return e;
    const n = asElement(querySelectorExt(e, t));
    if (n == null)
      throw triggerErrorEvent(e, "htmx:targetError", { target: t }), new Error(`Invalid re-target ${t}`);
    return n;
  }
  function handleAjaxResponse(e, t) {
    const n = t.xhr;
    let r = t.target;
    const o = t.etc, i = t.select;
    if (!triggerEvent(e, "htmx:beforeOnLoad", t)) return;
    if (hasHeader(n, /HX-Trigger:/i) && handleTriggerHeader(n, "HX-Trigger", e), hasHeader(n, /HX-Location:/i)) {
      saveCurrentPageToHistory();
      let w = n.getResponseHeader("HX-Location");
      var s;
      w.indexOf("{") === 0 && (s = parseJSON(w), w = s.path, delete s.path), ajaxHelper("get", w, s).then(function() {
        pushUrlIntoHistory(w);
      });
      return;
    }
    const l = hasHeader(n, /HX-Refresh:/i) && n.getResponseHeader("HX-Refresh") === "true";
    if (hasHeader(n, /HX-Redirect:/i)) {
      t.keepIndicators = !0, htmx.location.href = n.getResponseHeader("HX-Redirect"), l && htmx.location.reload();
      return;
    }
    if (l) {
      t.keepIndicators = !0, htmx.location.reload();
      return;
    }
    const a = determineHistoryUpdates(e, t), u = resolveResponseHandling(n), h = u.swap;
    let c = !!u.error, f = htmx.config.ignoreTitle || u.ignoreTitle, y = u.select;
    u.target && (t.target = resolveRetarget(e, u.target));
    var d = o.swapOverride;
    d == null && u.swapOverride && (d = u.swapOverride), hasHeader(n, /HX-Retarget:/i) && (t.target = resolveRetarget(e, n.getResponseHeader("HX-Retarget"))), hasHeader(n, /HX-Reswap:/i) && (d = n.getResponseHeader("HX-Reswap"));
    var E = n.response, m = mergeObjects({
      shouldSwap: h,
      serverResponse: E,
      isError: c,
      ignoreTitle: f,
      selectOverride: y,
      swapOverride: d
    }, t);
    if (!(u.event && !triggerEvent(r, u.event, m)) && triggerEvent(r, "htmx:beforeSwap", m)) {
      if (r = m.target, E = m.serverResponse, c = m.isError, f = m.ignoreTitle, y = m.selectOverride, d = m.swapOverride, t.target = r, t.failed = c, t.successful = !c, m.shouldSwap) {
        n.status === 286 && cancelPolling(e), withExtensions(e, function(p) {
          E = p.transformResponse(E, n, e);
        }), a.type && saveCurrentPageToHistory();
        var C = getSwapSpecification(e, d);
        C.hasOwnProperty("ignoreTitle") || (C.ignoreTitle = f), r.classList.add(htmx.config.swappingClass), i && (y = i), hasHeader(n, /HX-Reselect:/i) && (y = n.getResponseHeader("HX-Reselect"));
        const w = getClosestAttributeValue(e, "hx-select-oob"), x = getClosestAttributeValue(e, "hx-select");
        swap(r, E, C, {
          select: y === "unset" ? null : y || x,
          selectOOB: w,
          eventInfo: t,
          anchor: t.pathInfo.anchor,
          contextElement: e,
          afterSwapCallback: function() {
            if (hasHeader(n, /HX-Trigger-After-Swap:/i)) {
              let p = e;
              bodyContains(e) || (p = getDocument().body), handleTriggerHeader(n, "HX-Trigger-After-Swap", p);
            }
          },
          afterSettleCallback: function() {
            if (hasHeader(n, /HX-Trigger-After-Settle:/i)) {
              let p = e;
              bodyContains(e) || (p = getDocument().body), handleTriggerHeader(n, "HX-Trigger-After-Settle", p);
            }
          },
          beforeSwapCallback: function() {
            a.type && (triggerEvent(getDocument().body, "htmx:beforeHistoryUpdate", mergeObjects({ history: a }, t)), a.type === "push" ? (pushUrlIntoHistory(a.path), triggerEvent(getDocument().body, "htmx:pushedIntoHistory", { path: a.path })) : (replaceUrlInHistory(a.path), triggerEvent(getDocument().body, "htmx:replacedInHistory", { path: a.path })));
          }
        });
      }
      c && triggerErrorEvent(e, "htmx:responseError", mergeObjects({ error: "Response Status Error Code " + n.status + " from " + t.pathInfo.requestPath }, t));
    }
  }
  const extensions = {};
  function extensionBase() {
    return {
      init: function(e) {
        return null;
      },
      getSelectors: function() {
        return null;
      },
      onEvent: function(e, t) {
        return !0;
      },
      transformResponse: function(e, t, n) {
        return e;
      },
      isInlineSwap: function(e) {
        return !1;
      },
      handleSwap: function(e, t, n, r) {
        return !1;
      },
      encodeParameters: function(e, t, n) {
        return null;
      }
    };
  }
  function defineExtension(e, t) {
    t.init && t.init(internalAPI), extensions[e] = mergeObjects(extensionBase(), t);
  }
  function removeExtension(e) {
    delete extensions[e];
  }
  function getExtensions(e, t, n) {
    if (t == null && (t = []), e == null)
      return t;
    n == null && (n = []);
    const r = getAttributeValue(e, "hx-ext");
    return r && forEach(r.split(","), function(o) {
      if (o = o.replace(/ /g, ""), o.slice(0, 7) == "ignore:") {
        n.push(o.slice(7));
        return;
      }
      if (n.indexOf(o) < 0) {
        const i = extensions[o];
        i && t.indexOf(i) < 0 && t.push(i);
      }
    }), getExtensions(asElement(parentElt(e)), t, n);
  }
  var isReady = !1;
  getDocument().addEventListener("DOMContentLoaded", function() {
    isReady = !0;
  });
  function ready(e) {
    isReady || getDocument().readyState === "complete" ? e() : getDocument().addEventListener("DOMContentLoaded", e);
  }
  function insertIndicatorStyles() {
    if (htmx.config.includeIndicatorStyles !== !1) {
      const e = htmx.config.inlineStyleNonce ? ` nonce="${htmx.config.inlineStyleNonce}"` : "";
      getDocument().head.insertAdjacentHTML(
        "beforeend",
        "<style" + e + ">      ." + htmx.config.indicatorClass + "{opacity:0}      ." + htmx.config.requestClass + " ." + htmx.config.indicatorClass + "{opacity:1; transition: opacity 200ms ease-in;}      ." + htmx.config.requestClass + "." + htmx.config.indicatorClass + "{opacity:1; transition: opacity 200ms ease-in;}      </style>"
      );
    }
  }
  function getMetaConfig() {
    const e = getDocument().querySelector('meta[name="htmx-config"]');
    return e ? parseJSON(e.content) : null;
  }
  function mergeMetaConfig() {
    const e = getMetaConfig();
    e && (htmx.config = mergeObjects(htmx.config, e));
  }
  return ready(function() {
    mergeMetaConfig(), insertIndicatorStyles();
    let e = getDocument().body;
    processNode(e);
    const t = getDocument().querySelectorAll(
      "[hx-trigger='restored'],[data-hx-trigger='restored']"
    );
    e.addEventListener("htmx:abort", function(r) {
      const o = r.target, i = getInternalData(o);
      i && i.xhr && i.xhr.abort();
    });
    const n = window.onpopstate ? window.onpopstate.bind(window) : null;
    window.onpopstate = function(r) {
      r.state && r.state.htmx ? (restoreHistory(), forEach(t, function(o) {
        triggerEvent(o, "htmx:restored", {
          document: getDocument(),
          triggerEvent
        });
      })) : n && n(r);
    }, getWindow().setTimeout(function() {
      triggerEvent(e, "htmx:load", {}), e = null;
    }, 0);
  }), htmx;
})();