From 607a8701052284598fc98f2cc584f21c2498aeb6 Mon Sep 17 00:00:00 2001 From: Ujstor <116409846+Ujstor@users.noreply.github.com> Date: Sun, 8 Nov 2026 00:22:09 +0000 Subject: [PATCH] update htmx version v4.0.1 --- .../advanced/files/htmx/htmx.min.js.tmpl | 5226 ++++++----------- 1 file changed, 1800 insertions(+), 3426 deletions(-) diff --git a/cmd/template/advanced/files/htmx/htmx.min.js.tmpl b/cmd/template/advanced/files/htmx/htmx.min.js.tmpl index 39250e01..750680d1 100644 --- a/cmd/template/advanced/files/htmx/htmx.min.js.tmpl +++ b/cmd/template/advanced/files/htmx/htmx.min.js.tmpl @@ -1,3521 +1,1895 @@ -var htmx = (function () { - "use strict"; - const Q = { - onLoad: null, - process: null, - on: null, - off: null, - trigger: null, - ajax: null, - find: null, - findAll: null, - closest: null, - values: function (e, t) { - const n = dn(e, t || "post"); - return n.values; - }, - remove: null, - addClass: null, - removeClass: null, - toggleClass: null, - takeClass: null, - swap: null, - defineExtension: null, - removeExtension: null, - logAll: null, - logNone: null, - logger: null, - config: { - historyEnabled: true, - historyCacheSize: 10, - refreshOnHistoryMiss: false, - defaultSwapStyle: "innerHTML", - defaultSwapDelay: 0, - defaultSettleDelay: 20, - includeIndicatorStyles: true, - indicatorClass: "htmx-indicator", - requestClass: "htmx-request", - addedClass: "htmx-added", - settlingClass: "htmx-settling", - swappingClass: "htmx-swapping", - allowEval: true, - allowScriptTags: true, - inlineScriptNonce: "", - inlineStyleNonce: "", - attributesToSettle: ["class", "style", "width", "height"], - withCredentials: false, - timeout: 0, - wsReconnectDelay: "full-jitter", - wsBinaryType: "blob", - disableSelector: "[hx-disable], [data-hx-disable]", - scrollBehavior: "instant", - defaultFocusScroll: false, - getCacheBusterParam: false, - globalViewTransitions: false, - methodsThatUseUrlParams: ["get", "delete"], - selfRequestsOnly: true, - ignoreTitle: false, - scrollIntoViewOnBoost: true, - triggerSpecsCache: null, - disableInheritance: false, - responseHandling: [ - { code: "204", swap: false }, - { code: "[23]..", swap: true }, - { code: "[45]..", swap: false, error: true }, - ], - allowNestedOobSwaps: true, - historyRestoreAsHxRequest: true, - }, - parseInterval: null, - location: location, - _: null, - version: "2.0.6", - }; - Q.onLoad = j; - Q.process = Ft; - Q.on = xe; - Q.off = be; - Q.trigger = ae; - Q.ajax = Ln; - Q.find = f; - Q.findAll = x; - Q.closest = g; - Q.remove = z; - Q.addClass = K; - Q.removeClass = G; - Q.toggleClass = W; - Q.takeClass = Z; - Q.swap = $e; - Q.defineExtension = zn; - Q.removeExtension = $n; - Q.logAll = V; - Q.logNone = _; - Q.parseInterval = d; - Q._ = e; - const n = { - addTriggerHandler: St, - bodyContains: se, - canAccessLocalStorage: B, - findThisElement: Se, - filterValues: yn, - swap: $e, - hasAttribute: s, - getAttributeValue: a, - getClosestAttributeValue: ne, - getClosestMatch: q, - getExpressionVars: Tn, - getHeaders: mn, - getInputValues: dn, - getInternalData: oe, - getSwapSpecification: bn, - getTriggerSpecs: st, - getTarget: Ee, - makeFragment: P, - mergeObjects: le, - makeSettleInfo: Sn, - oobSwap: He, - querySelectorExt: ue, - settleImmediately: Yt, - shouldCancel: ht, - triggerEvent: ae, - triggerErrorEvent: fe, - withExtensions: jt, - }; - const de = ["get", "post", "put", "delete", "patch"]; - const T = de - .map(function (e) { - return "[hx-" + e + "], [data-hx-" + e + "]"; - }) - .join(", "); - function d(e) { - if (e == undefined) { - return undefined; - } - let t = NaN; - if (e.slice(-2) == "ms") { - t = parseFloat(e.slice(0, -2)); - } else if (e.slice(-1) == "s") { - t = parseFloat(e.slice(0, -1)) * 1e3; - } else if (e.slice(-1) == "m") { - t = parseFloat(e.slice(0, -1)) * 1e3 * 60; - } else { - t = parseFloat(e); - } - return isNaN(t) ? undefined : t; - } - function ee(e, t) { - return e instanceof Element && e.getAttribute(t); - } - function s(e, t) { - return ( - !!e.hasAttribute && (e.hasAttribute(t) || e.hasAttribute("data-" + t)) - ); - } - function a(e, t) { - return ee(e, t) || ee(e, "data-" + t); - } - function u(e) { - const t = e.parentElement; - if (!t && e.parentNode instanceof ShadowRoot) return e.parentNode; - return t; - } - function te() { - return document; - } - function y(e, t) { - return e.getRootNode ? e.getRootNode({ composed: t }) : te(); - } - function q(e, t) { - while (e && !t(e)) { - e = u(e); - } - return e || null; - } - function o(e, t, n) { - const r = a(t, n); - const o = a(t, "hx-disinherit"); - var i = a(t, "hx-inherit"); - if (e !== t) { - if (Q.config.disableInheritance) { - if (i && (i === "*" || i.split(" ").indexOf(n) >= 0)) { - return r; - } else { - return null; - } +var htmx = (() => { + const e = { + parse(t) { + if (!t) return {}; + if (t.startsWith("{")) return JSON.parse(t); + let r = + /(?:"([^"]+)"|'([^']+)'|([^\s,:]+))(?:\s*:\s*(?:"([^"]*)"|'([^']*)'|<((?:[^/]|\/(?!>))+)\/>|([^\s,]+)))?(?=\s|,|$)/g, + i = {}; + for (let s of t.matchAll(r)) { + let [, t, r, n, o, a, l, h] = s, + c = t ?? r ?? n, + u = (o ?? a ?? l ?? h ?? "true").trim(); + try { + u = JSON.parse(u); + } catch {} + let d = n?.includes("."), + f = d + ? c.split(".").reduceRight((e, t) => ({ [t]: e }), u) + : { [c]: u }; + e.merge(f, i); } - if (o && (o === "*" || o.split(" ").indexOf(n) >= 0)) { - return "unset"; + return i; + }, + split: (e) => + e.split( + /,(?![^\[]*\])(?![^(]*\))(?![^<]*\/>)(?=(?:[^"']|"[^"]*"|'[^']*')*$)/, + ), + merge(t, r) { + "string" == typeof t && (t = e.parse(t)); + for (let [i, s] of Object.entries(t)) { + if (["__proto__", "constructor", "prototype"].includes(i)) continue; + let t = s?.constructor === Object, + n = r[i]?.constructor === Object; + t && n ? e.merge(s, r[i]) : (r[i] = s); } - } - return r; - } - function ne(t, n) { - let r = null; - q(t, function (e) { - return !!(r = o(t, ce(e), n)); - }); - if (r !== "unset") { return r; - } - } - function h(e, t) { - return e instanceof Element && e.matches(t); - } - function A(e) { - const t = /<([a-z][^\/\0>\x20\t\r\n\f]*)/i; - const n = t.exec(e); - if (n) { - return n[1].toLowerCase(); - } else { - return ""; - } - } - function L(e) { - const t = new DOMParser(); - return t.parseFromString(e, "text/html"); - } - function N(e, t) { - while (t.childNodes.length > 0) { - e.append(t.childNodes[0]); - } - } - function r(e) { - const t = te().createElement("script"); - ie(e.attributes, function (e) { - t.setAttribute(e.name, e.value); - }); - t.textContent = e.textContent; - t.async = false; - if (Q.config.inlineScriptNonce) { - t.nonce = Q.config.inlineScriptNonce; - } - return t; - } - function i(e) { - return ( - e.matches("script") && - (e.type === "text/javascript" || e.type === "module" || e.type === "") - ); - } - function I(e) { - Array.from(e.querySelectorAll("script")).forEach((e) => { - if (i(e)) { - const t = r(e); - const n = e.parentNode; + }, + }; + class t { + #e = null; + #t = []; + admit(e, t, r) { + if (!this.#e) return ((this.#e = { strategy: e, abort: r }), "run"); + if ("replace" === e || ("abort" !== e && "abort" === this.#e.strategy)) + return ( + (this.#t = []), + this.#e.abort?.(), + (this.#e = { strategy: e, abort: r }), + "run" + ); + if ("queue all" === e) this.#t.push(t); + else if ("queue last" === e) this.#t = [t]; + else { + if ("abort" === e || "drop" === e || 0 !== this.#t.length) + return "dropped"; + this.#t.push(t); + } + return "queued"; + } + continue(e) { + this.#e?.abort === e && ((this.#e = null), this.#t.shift()?.()); + } + abort() { + this.#e?.abort?.(); + } + } + return new (class { + #r = e; + #i = new Map(); + #s = ""; + #n = new Set(); + _loc = window.location; + #o; + #a = Function; + #l = Object.getPrototypeOf(async function () {}).constructor; + #h = { createHTML: (e) => e, createScript: (e) => e }; + #c; + #u = "a,form"; + #d = ["get", "post", "put", "patch", "delete", "query"]; + #f; + #m; + #p; + #g; + #x; + constructor() { + (this.#b(), + this.#y(), + (this.#c = this.#S( + "[hx-action],[hx-get],[hx-post],[hx-put],[hx-patch],[hx-delete],[hx-query]", + )), + (this.#f = new XPathEvaluator().createExpression( + `.//*[@*[${this.#v("hx-on") + .map((e) => `starts-with(name(), "${e}")`) + .join(" or ")}]]`, + )), + (this.#o = { + HCON: e, + attributeValue: this.#E.bind(this), + parseTriggerSpecs: this.#w.bind(this), + determineMethodAndAction: this.#A.bind(this), + createRequestContext: this.#T.bind(this), + collectFormData: this.#C.bind(this), + getAttributeObject: this.#q.bind(this), + insertContent: this.#N.bind(this), + morph: this.#I.bind(this), + isSoftMatch: this.#M.bind(this), + initSecurity: (e, t, r) => { + (e && (this.#h = e), t && (this.#a = t), r && (this.#l = r)); + }, + onTrigger: this.#O.bind(this), + htmxProp: this.#H.bind(this), + triggerHtmxEvent: this.#L.bind(this), + executeJavaScript: this.#k.bind(this), + })); + let t = () => this.initialize(); + "loading" === document.readyState + ? document.addEventListener("DOMContentLoaded", t) + : setTimeout(t); + } + #b() { + ((this.version = "4.0.1"), + (this.config = { + logAll: !1, + prefix: "data-hx-", + transitions: !1, + history: !0, + mode: "same-origin", + defaultSwap: "innerHTML", + defaultFocusScroll: !1, + indicatorClass: "htmx-indicator", + requestClass: "htmx-request", + includeIndicatorCSS: !0, + defaultTimeout: 6e4, + extensions: "", + morphIgnore: ["data-htmx-powered"], + morphSkip: "[hx-morph-skip]", + morphSkipChildren: "[hx-morph-skip-children]", + morphScanLimit: 10, + noSwap: [204, 304], + implicitInheritance: !1, + defaultSettleDelay: 1, + allowEmptySwapAfterOOB: !1, + })); + let t = document.querySelector('meta[name="htmx-config"]'); + (t && e.merge(t.content, this.config), + (this.#s = this.config.extensions)); + } + #y() { + if (!1 !== this.config.includeIndicatorCSS) { + let e = this.config.indicatorClass, + t = this.config.requestClass; try { - n.insertBefore(t, e); - } catch (e) { - R(e); - } finally { - e.remove(); - } - } - }); - } - function P(e) { - const t = e.replace(/
]*)?>[\s\S]*?<\/head>/i, ""); - const n = A(t); - let r; - if (n === "html") { - r = new DocumentFragment(); - const i = L(e); - N(r, i.body); - r.title = i.title; - } else if (n === "body") { - r = new DocumentFragment(); - const i = L(t); - N(r, i.body); - r.title = i.title; - } else { - const i = L( - '' + - t + - "", + ((this.indicatorStyleSheet = new CSSStyleSheet()), + this.indicatorStyleSheet.replaceSync( + `.${e}{opacity:0;visibility: hidden} .${t} .${e}, .${t}.${e}{opacity:1;visibility: visible;transition: opacity 200ms ease-in}`, + ), + document.adoptedStyleSheets.push(this.indicatorStyleSheet)); + } catch {} + } + } + registerExtension(e, t) { + return ( + !(this.#s && !this.#s.split(/,\s*/).includes(e)) && + !this.#n.has(e) && + (this.#n.add(e), + t.init && t.init(this.#o), + void Object.entries(t).forEach(([e, t]) => { + this.#i.get(e)?.push(t) || this.#i.set(e, [t]); + })) ); - r = i.querySelector("template").content; - r.title = i.title; - var o = r.querySelector("title"); - if (o && o.parentNode === r) { - o.remove(); - r.title = o.innerText; - } - } - if (r) { - if (Q.config.allowScriptTags) { - I(r); - } else { - r.querySelectorAll("script").forEach((e) => e.remove()); - } - } - return r; - } - function re(e) { - if (e) { - e(); - } - } - function t(e, t) { - return Object.prototype.toString.call(e) === "[object " + t + "]"; - } - function D(e) { - return typeof e === "function"; - } - function k(e) { - return t(e, "Object"); - } - function oe(e) { - const t = "htmx-internal-data"; - let n = e[t]; - if (!n) { - n = e[t] = {}; - } - return n; - } - function M(t) { - const n = []; - if (t) { - for (let e = 0; e < t.length; e++) { - n.push(t[e]); - } - } - return n; - } - function ie(t, n) { - if (t) { - for (let e = 0; e < t.length; e++) { - n(t[e]); - } - } - } - function F(e) { - const t = e.getBoundingClientRect(); - const n = t.top; - const r = t.bottom; - return n < window.innerHeight && r >= 0; - } - function se(e) { - return e.getRootNode({ composed: true }) === document; - } - function X(e) { - return e.trim().split(/\s+/); - } - function le(e, t) { - for (const n in t) { - if (t.hasOwnProperty(n)) { - e[n] = t[n]; - } - } - return e; - } - function v(e) { - try { - return JSON.parse(e); - } catch (e) { - R(e); - return null; - } - } - function B() { - const e = "htmx:sessionStorageTest"; - try { - sessionStorage.setItem(e, e); - sessionStorage.removeItem(e); - return true; - } catch (e) { - return false; - } - } - function U(e) { - const t = new URL(e, "http://x"); - if (t) { - e = t.pathname + t.search; - } - if (e != "/") { - e = e.replace(/\/+$/, ""); - } - return e; - } - function e(e) { - return On(te().body, function () { - return eval(e); - }); - } - function j(t) { - const e = Q.on("htmx:load", function (e) { - t(e.detail.elt); - }); - return e; - } - function V() { - Q.logger = function (e, t, n) { - if (console) { - console.log(t, e, n); - } - }; - } - function _() { - Q.logger = null; - } - function f(e, t) { - if (typeof e !== "string") { - return e.querySelector(t); - } else { - return f(te(), e); } - } - function x(e, t) { - if (typeof e !== "string") { - return e.querySelectorAll(t); - } else { - return x(te(), e); + #V(e) { + let t = this.config.prefix; + return ( + !e.closest || + null != e.closest("[hx-ignore]") || + (t && null != e.closest(`[${t}ignore]`)) + ); } - } - function b() { - return window; - } - function z(e, t) { - e = w(e); - if (t) { - b().setTimeout(function () { - z(e); - e = null; - }, t); - } else { - u(e).removeChild(e); + #P(e, t) { + let r = this.config.prefix; + return ( + e.getAttribute(t) ?? (r ? e.getAttribute(t.replace("hx-", r)) : null) + ); } - } - function ce(e) { - return e instanceof Element ? e : null; - } - function $(e) { - return e instanceof HTMLElement ? e : null; - } - function J(e) { - return typeof e === "string" ? e : null; - } - function p(e) { - return e instanceof Element || - e instanceof Document || - e instanceof DocumentFragment - ? e - : null; - } - function K(e, t, n) { - e = ce(w(e)); - if (!e) { - return; - } - if (n) { - b().setTimeout(function () { - K(e, t); - e = null; - }, n); - } else { - e.classList && e.classList.add(t); + #R(e, t) { + let r = this.config.prefix && t.replace("hx-", this.config.prefix); + return e.hasAttribute(t) ? t : r && e.hasAttribute(r) ? r : null; } - } - function G(e, t, n) { - let r = ce(w(e)); - if (!r) { - return; - } - if (n) { - b().setTimeout(function () { - G(r, t); - r = null; - }, n); - } else { - if (r.classList) { - r.classList.remove(t); - if (r.classList.length === 0) { - r.removeAttribute("class"); - } - } + #S(e) { + return this.#v(e).join(","); } - } - function W(e, t) { - e = w(e); - e.classList.toggle(t); - } - function Z(e, t) { - e = w(e); - ie(e.parentElement.children, function (e) { - G(e, t); - }); - K(ce(e), t); - } - function g(e, t) { - e = ce(w(e)); - if (e) { - return e.closest(t); + #v(e) { + let t = [e]; + return ( + this.config.prefix && t.push(e.replaceAll("hx-", this.config.prefix)), + t + ); } - return null; - } - function l(e, t) { - return e.substring(0, t.length) === t; - } - function Y(e, t) { - return e.substring(e.length - t.length) === t; - } - function pe(e) { - const t = e.trim(); - if (l(t, "<") && Y(t, "/>")) { - return t.substring(1, t.length - 2); - } else { - return t; + #j(e, t) { + let r = [...(e.querySelectorAll?.(t) ?? [])]; + return (e.matches?.(t) && r.unshift(e), r); + } + #B(e) { + return "before" === e + ? "beforebegin" + : "after" === e + ? "afterend" + : "prepend" === e + ? "afterbegin" + : "append" === e + ? "beforeend" + : e; + } + #z(e, t) { + let r = []; + return ( + this.#E(e, t, void 0, (e, t) => { + e?.split(/\s*[,:]\s*/).includes("this") && r.push(t); + }), + r + ); } - } - function m(t, r, n) { - if (r.indexOf("global ") === 0) { - return m(t, r.slice(7), true); - } - t = w(t); - const o = []; - { - let t = 0; - let n = 0; - for (let e = 0; e < r.length; e++) { - const l = r[e]; - if (l === "," && t === 0) { - o.push(r.substring(n, e)); - n = e + 1; - continue; - } - if (l === "<") { - t++; - } else if (l === "/" && e < r.length - 1 && r[e + 1] === ">") { - t--; + #E(e, t, r, i, s = this.config.implicitInheritance) { + t = this.#F(t); + let n = this.#F(":inherited"), + o = this.#F(":append"), + a = this.#P(e, t) ?? this.#P(e, t + n); + if (null != a) return i ? i(a, e) : a; + let l = CSS.escape(s ? t : t + n), + h = CSS.escape(t + n + o), + c = this.#S(`[${l}],[${h}]`), + u = this.#R(e, t + o) ?? this.#R(e, t + n + o); + if (u) { + let r = e.getAttribute(u), + n = e.parentNode?.closest?.(c); + if ((i && i(r, e), n)) { + let e = this.#E(n, t, void 0, i, s); + return e ? (e + "," + r).replace(/[{}]/g, "") : r; } + return r; } - if (n < r.length) { - o.push(r.substring(n)); - } - } - const i = []; - const s = []; - while (o.length > 0) { - const r = pe(o.shift()); - let e; - if (r.indexOf("closest ") === 0) { - e = g(ce(t), pe(r.slice(8))); - } else if (r.indexOf("find ") === 0) { - e = f(p(t), pe(r.slice(5))); - } else if (r === "next" || r === "nextElementSibling") { - e = ce(t).nextElementSibling; - } else if (r.indexOf("next ") === 0) { - e = ge(t, pe(r.slice(5)), !!n); - } else if (r === "previous" || r === "previousElementSibling") { - e = ce(t).previousElementSibling; - } else if (r.indexOf("previous ") === 0) { - e = me(t, pe(r.slice(9)), !!n); - } else if (r === "document") { - e = document; - } else if (r === "window") { - e = window; - } else if (r === "body") { - e = document.body; - } else if (r === "root") { - e = y(t, !!n); - } else if (r === "host") { - e = t.getRootNode().host; - } else { - s.push(r); - } - if (e) { - i.push(e); - } - } - if (s.length > 0) { - const e = s.join(","); - const c = p(y(t, !!n)); - i.push(...M(c.querySelectorAll(e))); - } - return i; - } - var ge = function (t, e, n) { - const r = p(y(t, n)).querySelectorAll(e); - for (let e = 0; e < r.length; e++) { - const o = r[e]; - if (o.compareDocumentPosition(t) === Node.DOCUMENT_POSITION_PRECEDING) { - return o; - } - } - }; - var me = function (t, e, n) { - const r = p(y(t, n)).querySelectorAll(e); - for (let e = r.length - 1; e >= 0; e--) { - const o = r[e]; - if (o.compareDocumentPosition(t) === Node.DOCUMENT_POSITION_FOLLOWING) { - return o; - } - } - }; - function ue(e, t) { - if (typeof e !== "string") { - return m(e, t)[0]; - } else { - return m(te().body, e)[0]; - } - } - function w(e, t) { - if (typeof e === "string") { - return f(p(t) || document, e); - } else { - return e; - } - } - function ye(e, t, n, r) { - if (D(t)) { - return { target: te().body, event: J(e), listener: t, options: n }; - } else { - return { target: w(e), event: J(t), listener: n, options: r }; - } - } - function xe(t, n, r, o) { - Gn(function () { - const e = ye(t, n, r, o); - e.target.addEventListener(e.event, e.listener, e.options); - }); - const e = D(n); - return e ? n : r; - } - function be(t, n, r) { - Gn(function () { - const e = ye(t, n, r); - e.target.removeEventListener(e.event, e.listener); - }); - return D(n) ? n : r; - } - const ve = te().createElement("output"); - function we(t, n) { - const e = ne(t, n); - if (e) { - if (e === "this") { - return [Se(t, n)]; - } else { - const r = m(t, e); - const o = /(^|,)(\s*)inherit(\s*)($|,)/.test(e); - if (o) { - const i = ce( - q(t, function (e) { - return e !== t && s(ce(e), n); + let d = e.parentNode?.closest?.(c); + return d + ? ((a = this.#E(d, t, void 0, i)), + !i && + a && + s && + this.#$(e, "htmx:after:implicitInheritance", { + elt: e, + name: t, + parent: d, }), - ); - if (i) { - r.push(...we(i, n)); - } - } - if (r.length === 0) { - R('The selector "' + e + '" on ' + n + " returned no matches!"); - return [ve]; - } else { - return r; - } - } - } - } - function Se(e, t) { - return ce( - q(e, function (e) { - return a(ce(e), t) != null; - }), - ); - } - function Ee(e) { - const t = ne(e, "hx-target"); - if (t) { - if (t === "this") { - return Se(e, "hx-target"); - } else { - return ue(e, t); - } - } else { - const n = oe(e); - if (n.boosted) { - return te().body; - } else { - return e; - } - } - } - function Ce(e) { - return Q.config.attributesToSettle.includes(e); - } - function Oe(t, n) { - ie(t.attributes, function (e) { - if (!n.hasAttribute(e.name) && Ce(e.name)) { - t.removeAttribute(e.name); - } - }); - ie(n.attributes, function (e) { - if (Ce(e.name)) { - t.setAttribute(e.name, e.value); - } - }); - } - function Re(t, e) { - const n = Jn(e); - for (let e = 0; e < n.length; e++) { - const r = n[e]; - try { - if (r.isInlineSwap(t)) { - return true; - } - } catch (e) { - R(e); - } - } - return t === "outerHTML"; - } - function He(e, o, i, t) { - t = t || te(); - let n = "#" + CSS.escape(ee(o, "id")); - let s = "outerHTML"; - if (e === "true") { - } else if (e.indexOf(":") > 0) { - s = e.substring(0, e.indexOf(":")); - n = e.substring(e.indexOf(":") + 1); - } else { - s = e; - } - o.removeAttribute("hx-swap-oob"); - o.removeAttribute("data-hx-swap-oob"); - const r = m(t, n, false); - if (r.length) { - ie(r, function (e) { - let t; - const n = o.cloneNode(true); - t = te().createDocumentFragment(); - t.appendChild(n); - if (!Re(s, e)) { - t = p(n); - } - const r = { shouldSwap: true, target: e, fragment: t }; - if (!ae(e, "htmx:oobBeforeSwap", r)) return; - e = r.target; - if (r.shouldSwap) { - qe(t); - _e(s, e, e, t, i); - Te(); - } - ie(i.elts, function (e) { - ae(e, "htmx:oobAfterSwap", r); - }); - }); - o.parentNode.removeChild(o); - } else { - o.parentNode.removeChild(o); - fe(te().body, "htmx:oobErrorNoTarget", { content: o }); - } - return e; - } - function Te() { - const e = f("#--htmx-preserve-pantry--"); - if (e) { - for (const t of [...e.children]) { - const n = f("#" + t.id); - n.parentNode.moveBefore(t, n); - n.remove(); - } - e.remove(); - } - } - function qe(e) { - ie(x(e, "[hx-preserve], [data-hx-preserve]"), function (e) { - const t = a(e, "id"); - const n = te().getElementById(t); - if (n != null) { - if (e.moveBefore) { - let e = f("#--htmx-preserve-pantry--"); - if (e == null) { - te().body.insertAdjacentHTML( - "afterend", - "", - ); - e = f("#--htmx-preserve-pantry--"); - } - e.moveBefore(n, null); - } else { - e.parentNode.replaceChild(n, e); - } - } - }); - } - function Ae(l, e, c) { - ie(e.querySelectorAll("[id]"), function (t) { - const n = ee(t, "id"); - if (n && n.length > 0) { - const r = n.replace("'", "\\'"); - const o = t.tagName.replace(":", "\\:"); - const e = p(l); - const i = e && e.querySelector(o + "[id='" + r + "']"); - if (i && i !== e) { - const s = t.cloneNode(); - Oe(t, i); - c.tasks.push(function () { - Oe(t, s); - }); - } - } - }); - } - function Le(e) { - return function () { - G(e, Q.config.addedClass); - Ft(ce(e)); - Ne(p(e)); - ae(e, "htmx:load"); - }; - } - function Ne(e) { - const t = "[autofocus]"; - const n = $(h(e, t) ? e : e.querySelector(t)); - if (n != null) { - n.focus(); - } - } - function c(e, t, n, r) { - Ae(e, n, r); - while (n.childNodes.length > 0) { - const o = n.firstChild; - K(ce(o), Q.config.addedClass); - e.insertBefore(o, t); - if (o.nodeType !== Node.TEXT_NODE && o.nodeType !== Node.COMMENT_NODE) { - r.tasks.push(Le(o)); - } - } - } - function Ie(e, t) { - let n = 0; - while (n < e.length) { - t = ((t << 5) - t + e.charCodeAt(n++)) | 0; - } - return t; - } - function Pe(t) { - let n = 0; - for (let e = 0; e < t.attributes.length; e++) { - const r = t.attributes[e]; - if (r.value) { - n = Ie(r.name, n); - n = Ie(r.value, n); - } - } - return n; - } - function De(t) { - const n = oe(t); - if (n.onHandlers) { - for (let e = 0; e < n.onHandlers.length; e++) { - const r = n.onHandlers[e]; - be(t, r.event, r.listener); - } - delete n.onHandlers; - } - } - function ke(e) { - const t = oe(e); - if (t.timeout) { - clearTimeout(t.timeout); - } - if (t.listenerInfos) { - ie(t.listenerInfos, function (e) { - if (e.on) { - be(e.on, e.trigger, e.listener); - } - }); - } - De(e); - ie(Object.keys(t), function (e) { - if (e !== "firstInitCompleted") delete t[e]; - }); - } - function S(e) { - ae(e, "htmx:beforeCleanupElement"); - ke(e); - ie(e.children, function (e) { - S(e); - }); - } - function Me(t, e, n) { - if (t.tagName === "BODY") { - return Ve(t, e, n); - } - let r; - const o = t.previousSibling; - const i = u(t); - if (!i) { - return; - } - c(i, t, e, n); - if (o == null) { - r = i.firstChild; - } else { - r = o.nextSibling; - } - n.elts = n.elts.filter(function (e) { - return e !== t; - }); - while (r && r !== t) { - if (r instanceof Element) { - n.elts.push(r); - } - r = r.nextSibling; - } - S(t); - t.remove(); - } - function Fe(e, t, n) { - return c(e, e.firstChild, t, n); - } - function Xe(e, t, n) { - return c(u(e), e, t, n); - } - function Be(e, t, n) { - return c(e, null, t, n); - } - function Ue(e, t, n) { - return c(u(e), e.nextSibling, t, n); - } - function je(e) { - S(e); - const t = u(e); - if (t) { - return t.removeChild(e); - } - } - function Ve(e, t, n) { - const r = e.firstChild; - c(e, r, t, n); - if (r) { - while (r.nextSibling) { - S(r.nextSibling); - e.removeChild(r.nextSibling); - } - S(r); - e.removeChild(r); - } - } - function _e(t, e, n, r, o) { - switch (t) { - case "none": - return; - case "outerHTML": - Me(n, r, o); - return; - case "afterbegin": - Fe(n, r, o); - return; - case "beforebegin": - Xe(n, r, o); - return; - case "beforeend": - Be(n, r, o); - return; - case "afterend": - Ue(n, r, o); - return; - case "delete": - je(n); - return; - default: - var i = Jn(e); - for (let e = 0; e < i.length; e++) { - const s = i[e]; - try { - const l = s.handleSwap(t, n, r, o); - if (l) { - if (Array.isArray(l)) { - for (let e = 0; e < l.length; e++) { - const c = l[e]; - if ( - c.nodeType !== Node.TEXT_NODE && - c.nodeType !== Node.COMMENT_NODE - ) { - o.tasks.push(Le(c)); - } - } - } - return; - } - } catch (e) { - R(e); - } - } - if (t === "innerHTML") { - Ve(n, r, o); - } else { - _e(Q.config.defaultSwapStyle, e, n, r, o); - } - } - } - function ze(e, n, r) { - var t = x(e, "[hx-swap-oob], [data-hx-swap-oob]"); - ie(t, function (e) { - if (Q.config.allowNestedOobSwaps || e.parentElement === null) { - const t = a(e, "hx-swap-oob"); - if (t != null) { - He(t, e, n, r); - } - } else { - e.removeAttribute("hx-swap-oob"); - e.removeAttribute("data-hx-swap-oob"); - } - }); - return t.length > 0; - } - function $e(h, d, p, g) { - if (!g) { - g = {}; - } - let m = null; - let n = null; - let e = function () { - re(g.beforeSwapCallback); - h = w(h); - const r = g.contextElement ? y(g.contextElement, false) : te(); - const e = document.activeElement; - let t = {}; - t = { - elt: e, - start: e ? e.selectionStart : null, - end: e ? e.selectionEnd : null, - }; - const o = Sn(h); - if (p.swapStyle === "textContent") { - h.textContent = d; - } else { - let n = P(d); - o.title = g.title || n.title; - if (g.historyRequest) { - n = n.querySelector("[hx-history-elt],[data-hx-history-elt]") || n; - } - if (g.selectOOB) { - const i = g.selectOOB.split(","); - for (let t = 0; t < i.length; t++) { - const s = i[t].split(":", 2); - let e = s[0].trim(); - if (e.indexOf("#") === 0) { - e = e.substring(1); - } - const l = s[1] || "true"; - const c = n.querySelector("#" + e); - if (c) { - He(l, c, o, r); - } - } - } - ze(n, o, r); - ie(x(n, "template"), function (e) { - if (e.content && ze(e.content, o, r)) { - e.remove(); - } - }); - if (g.select) { - const u = te().createDocumentFragment(); - ie(n.querySelectorAll(g.select), function (e) { - u.appendChild(e); - }); - n = u; - } - qe(n); - _e(p.swapStyle, g.contextElement, h, n, o); - Te(); - } - if (t.elt && !se(t.elt) && ee(t.elt, "id")) { - const f = document.getElementById(ee(t.elt, "id")); - const a = { - preventScroll: - p.focusScroll !== undefined - ? !p.focusScroll - : !Q.config.defaultFocusScroll, - }; - if (f) { - if (t.start && f.setSelectionRange) { - try { - f.setSelectionRange(t.start, t.end); - } catch (e) {} - } - f.focus(a); - } - } - h.classList.remove(Q.config.swappingClass); - ie(o.elts, function (e) { - if (e.classList) { - e.classList.add(Q.config.settlingClass); - } - ae(e, "htmx:afterSwap", g.eventInfo); - }); - re(g.afterSwapCallback); - if (!p.ignoreTitle) { - Bn(o.title); - } - const n = function () { - ie(o.tasks, function (e) { - e.call(); - }); - ie(o.elts, function (e) { - if (e.classList) { - e.classList.remove(Q.config.settlingClass); - } - ae(e, "htmx:afterSettle", g.eventInfo); - }); - if (g.anchor) { - const e = ce(w("#" + g.anchor)); - if (e) { - e.scrollIntoView({ block: "start", behavior: "auto" }); - } - } - En(o.elts, p); - re(g.afterSettleCallback); - re(m); - }; - if (p.settleDelay > 0) { - b().setTimeout(n, p.settleDelay); - } else { - n(); - } - }; - let t = Q.config.globalViewTransitions; - if (p.hasOwnProperty("transition")) { - t = p.transition; - } - const r = g.contextElement || te(); - if ( - t && - ae(r, "htmx:beforeTransition", g.eventInfo) && - typeof Promise !== "undefined" && - document.startViewTransition - ) { - const o = new Promise(function (e, t) { - m = e; - n = t; - }); - const i = e; - e = function () { - document.startViewTransition(function () { - i(); - return o; - }); - }; - } - try { - if (p?.swapDelay && p.swapDelay > 0) { - b().setTimeout(e, p.swapDelay); - } else { - e(); - } - } catch (e) { - fe(r, "htmx:swapError", g.eventInfo); - re(n); - throw e; - } - } - function Je(e, t, n) { - const r = e.getResponseHeader(t); - if (r.indexOf("{") === 0) { - const o = v(r); - for (const i in o) { - if (o.hasOwnProperty(i)) { - let e = o[i]; - if (k(e)) { - n = e.target !== undefined ? e.target : n; - } else { - e = { value: e }; - } - ae(n, i, e); - } - } - } else { - const s = r.split(","); - for (let e = 0; e < s.length; e++) { - ae(n, s[e].trim(), []); - } - } - } - const Ke = /\s/; - const E = /[\s,]/; - const Ge = /[_$a-zA-Z]/; - const We = /[_$a-zA-Z0-9]/; - const Ze = ['"', "'", "/"]; - const C = /[^\s]/; - const Ye = /[{(]/; - const Qe = /[})]/; - function et(e) { - const t = []; - let n = 0; - while (n < e.length) { - if (Ge.exec(e.charAt(n))) { - var r = n; - while (We.exec(e.charAt(n + 1))) { - n++; - } - t.push(e.substring(r, n + 1)); - } else if (Ze.indexOf(e.charAt(n)) !== -1) { - const o = e.charAt(n); - var r = n; - n++; - while (n < e.length && e.charAt(n) !== o) { - if (e.charAt(n) === "\\") { - n++; - } - n++; - } - t.push(e.substring(r, n + 1)); - } else { - const i = e.charAt(n); - t.push(i); - } - n++; - } - return t; - } - function tt(e, t, n) { - return ( - Ge.exec(e.charAt(0)) && - e !== "true" && - e !== "false" && - e !== "this" && - e !== n && - t !== "." - ); - } - function nt(r, o, i) { - if (o[0] === "[") { - o.shift(); - let e = 1; - let t = " return (function(" + i + "){ return ("; - let n = null; - while (o.length > 0) { - const s = o[0]; - if (s === "]") { - e--; - if (e === 0) { - if (n === null) { - t = t + "true"; - } - o.shift(); - t += ")})"; - try { - const l = On( - r, - function () { - return Function(t)(); - }, - function () { - return true; - }, - ); - l.source = t; - return l; - } catch (e) { - fe(te().body, "htmx:syntax:error", { error: e, source: t }); - return null; - } - } - } else if (s === "[") { - e++; - } - if (tt(s, n, i)) { - t += - "((" + - i + - "." + - s + - ") ? (" + - i + - "." + - s + - ") : (window." + - s + - "))"; - } else { - t = t + s; - } - n = o.shift(); - } - } - } - function O(e, t) { - let n = ""; - while (e.length > 0 && !t.test(e[0])) { - n += e.shift(); - } - return n; - } - function rt(e) { - let t; - if (e.length > 0 && Ye.test(e[0])) { - e.shift(); - t = O(e, Qe).trim(); - e.shift(); - } else { - t = O(e, E); - } - return t; - } - const ot = "input, textarea, select"; - function it(e, t, n) { - const r = []; - const o = et(t); - do { - O(o, C); - const l = o.length; - const c = O(o, /[,\[\s]/); - if (c !== "") { - if (c === "every") { - const u = { trigger: "every" }; - O(o, C); - u.pollInterval = d(O(o, /[,\[\s]/)); - O(o, C); - var i = nt(e, o, "event"); - if (i) { - u.eventFilter = i; - } - r.push(u); - } else { - const f = { trigger: c }; - var i = nt(e, o, "event"); - if (i) { - f.eventFilter = i; - } - O(o, C); - while (o.length > 0 && o[0] !== ",") { - const a = o.shift(); - if (a === "changed") { - f.changed = true; - } else if (a === "once") { - f.once = true; - } else if (a === "consume") { - f.consume = true; - } else if (a === "delay" && o[0] === ":") { - o.shift(); - f.delay = d(O(o, E)); - } else if (a === "from" && o[0] === ":") { - o.shift(); - if (Ye.test(o[0])) { - var s = rt(o); - } else { - var s = O(o, E); - if ( - s === "closest" || - s === "find" || - s === "next" || - s === "previous" - ) { - o.shift(); - const h = rt(o); - if (h.length > 0) { - s += " " + h; - } - } - } - f.from = s; - } else if (a === "target" && o[0] === ":") { - o.shift(); - f.target = rt(o); - } else if (a === "throttle" && o[0] === ":") { - o.shift(); - f.throttle = d(O(o, E)); - } else if (a === "queue" && o[0] === ":") { - o.shift(); - f.queue = O(o, E); - } else if (a === "root" && o[0] === ":") { - o.shift(); - f[a] = rt(o); - } else if (a === "threshold" && o[0] === ":") { - o.shift(); - f[a] = O(o, E); - } else { - fe(e, "htmx:syntax:error", { token: o.shift() }); - } - O(o, C); - } - r.push(f); - } - } - if (o.length === l) { - fe(e, "htmx:syntax:error", { token: o.shift() }); - } - O(o, C); - } while (o[0] === "," && o.shift()); - if (n) { - n[t] = r; - } - return r; - } - function st(e) { - const t = a(e, "hx-trigger"); - let n = []; - if (t) { - const r = Q.config.triggerSpecsCache; - n = (r && r[t]) || it(e, t, r); - } - if (n.length > 0) { - return n; - } else if (h(e, "form")) { - return [{ trigger: "submit" }]; - } else if (h(e, 'input[type="button"], input[type="submit"]')) { - return [{ trigger: "click" }]; - } else if (h(e, ot)) { - return [{ trigger: "change" }]; - } else { - return [{ trigger: "click" }]; - } - } - function lt(e) { - oe(e).cancelled = true; - } - function ct(e, t, n) { - const r = oe(e); - r.timeout = b().setTimeout(function () { - if (se(e) && r.cancelled !== true) { - if (!pt(n, e, Bt("hx:poll:trigger", { triggerSpec: n, target: e }))) { - t(e); - } - ct(e, t, n); - } - }, n.pollInterval); - } - function ut(e) { - return ( - location.hostname === e.hostname && - ee(e, "href") && - ee(e, "href").indexOf("#") !== 0 - ); - } - function ft(e) { - return g(e, Q.config.disableSelector); - } - function at(t, n, e) { - if ( - (t instanceof HTMLAnchorElement && - ut(t) && - (t.target === "" || t.target === "_self")) || - (t.tagName === "FORM" && - String(ee(t, "method")).toLowerCase() !== "dialog") - ) { - n.boosted = true; - let r, o; - if (t.tagName === "A") { - r = "get"; - o = ee(t, "href"); - } else { - const i = ee(t, "method"); - r = i ? i.toLowerCase() : "get"; - o = ee(t, "action"); - if (o == null || o === "") { - o = location.href; - } - if (r === "get" && o.includes("?")) { - o = o.replace(/\?[^#]+/, ""); - } - } - e.forEach(function (e) { - gt( - t, - function (e, t) { - const n = ce(e); - if (ft(n)) { - S(n); - return; - } - he(r, o, n, t); - }, - n, - e, - true, - ); - }); - } - } - function ht(e, t) { - if (e.type === "submit" || e.type === "click") { - t = ce(e.target) || t; - if (t.tagName === "FORM") { - return true; - } - if (t.form && t.type === "submit") { - return true; - } - t = t.closest("a"); - if ( - t && - t.href && - (t.getAttribute("href") === "#" || - t.getAttribute("href").indexOf("#") !== 0) - ) { - return true; - } - } - return false; - } - function dt(e, t) { - return ( - oe(e).boosted && - e instanceof HTMLAnchorElement && - t.type === "click" && - (t.ctrlKey || t.metaKey) - ); - } - function pt(e, t, n) { - const r = e.eventFilter; - if (r) { - try { - return r.call(t, n) !== true; - } catch (e) { - const o = r.source; - fe(te().body, "htmx:eventFilter:error", { error: e, source: o }); - return true; - } - } - return false; - } - function gt(l, c, e, u, f) { - const a = oe(l); - let t; - if (u.from) { - t = m(l, u.from); - } else { - t = [l]; - } - if (u.changed) { - if (!("lastValue" in a)) { - a.lastValue = new WeakMap(); - } - t.forEach(function (e) { - if (!a.lastValue.has(u)) { - a.lastValue.set(u, new WeakMap()); - } - a.lastValue.get(u).set(e, e.value); + a) + : r; + } + #w(t) { + return e.split(t).flatMap((t) => { + t = t.replace(/^\s*every\s+(\S+?)\s*(\[[^\]]*\])/, "every$2 $1"); + let [, r, i] = t.match(/^\s*(\S+\[[^\]]*\]|\S+)\s*(.*?)\s*$/) ?? []; + if (!r) return []; + if (/\[[^\]]*$/.test(r)) throw "unterminated:" + r; + return [{ name: r, ...e.parse(i) }]; }); } - ie(t, function (i) { - const s = function (e) { - if (!se(l)) { - i.removeEventListener(u.trigger, s); - return; - } - if (dt(l, e)) { - return; - } - if (f || ht(e, l)) { - e.preventDefault(); - } - if (pt(u, l, e)) { - return; - } - const t = oe(e); - t.triggerSpec = u; - if (t.handledFor == null) { - t.handledFor = []; - } - if (t.handledFor.indexOf(l) < 0) { - t.handledFor.push(l); - if (u.consume) { - e.stopPropagation(); - } - if (u.target && e.target) { - if (!h(ce(e.target), u.target)) { - return; - } - } - if (u.once) { - if (a.triggeredOnce) { - return; - } else { - a.triggeredOnce = true; - } - } - if (u.changed) { - const n = e.target; - const r = n.value; - const o = a.lastValue.get(u); - if (o.has(n) && o.get(n) === r) { - return; - } - o.set(n, r); - } - if (a.delayed) { - clearTimeout(a.delayed); - } - if (a.throttle) { - return; - } - if (u.throttle > 0) { - if (!a.throttle) { - ae(l, "htmx:trigger"); - c(l, e); - a.throttle = b().setTimeout(function () { - a.throttle = null; - }, u.throttle); - } - } else if (u.delay > 0) { - a.delayed = b().setTimeout(function () { - ae(l, "htmx:trigger"); - c(l, e); - }, u.delay); - } else { - ae(l, "htmx:trigger"); - c(l, e); - } - } - }; - if (e.listenerInfos == null) { - e.listenerInfos = []; - } - e.listenerInfos.push({ trigger: u.trigger, listener: s, on: i }); - i.addEventListener(u.trigger, s); - }); - } - let mt = false; - let yt = null; - function xt() { - if (!yt) { - yt = function () { - mt = true; - }; - window.addEventListener("scroll", yt); - window.addEventListener("resize", yt); - setInterval(function () { - if (mt) { - mt = false; - ie( - te().querySelectorAll( - "[hx-trigger*='revealed'],[data-hx-trigger*='revealed']", - ), - function (e) { - bt(e); - }, - ); - } - }, 200); - } - } - function bt(e) { - if (!s(e, "data-hx-revealed") && F(e)) { - e.setAttribute("data-hx-revealed", "true"); - const t = oe(e); - if (t.initHash) { - ae(e, "revealed"); - } else { - e.addEventListener( - "htmx:afterProcessNode", - function () { - ae(e, "revealed"); - }, - { once: true }, - ); - } - } - } - function vt(e, t, n, r) { - const o = function () { - if (!n.loaded) { - n.loaded = true; - ae(e, "htmx:trigger"); - t(e); - } - }; - if (r > 0) { - b().setTimeout(o, r); - } else { - o(); - } - } - function wt(t, n, e) { - let i = false; - ie(de, function (r) { - if (s(t, "hx-" + r)) { - const o = a(t, "hx-" + r); - i = true; - n.path = o; - n.verb = r; - e.forEach(function (e) { - St(t, e, n, function (e, t) { - const n = ce(e); - if (ft(n)) { - S(n); - return; - } - he(r, o, n, t); - }); - }); - } - }); - return i; - } - function St(r, e, t, n) { - if (e.trigger === "revealed") { - xt(); - gt(r, n, t, e); - bt(ce(r)); - } else if (e.trigger === "intersect") { - const o = {}; - if (e.root) { - o.root = ue(r, e.root); - } - if (e.threshold) { - o.threshold = parseFloat(e.threshold); - } - const i = new IntersectionObserver(function (t) { - for (let e = 0; e < t.length; e++) { - const n = t[e]; - if (n.isIntersecting) { - ae(r, "intersect"); + #A(e, t) { + let r = this.#E(e, "hx-method"), + i = this.#E(e, "hx-action", void 0, void 0, !1); + if (!i) + for (let t of this.#d) { + let s = this.#E(e, "hx-" + t, void 0, void 0, !1); + if (null != s) { + ((i = s), (r = t)); break; } } - }, o); - i.observe(ce(r)); - gt(ce(r), n, t, e); - } else if (!t.firstInitCompleted && e.trigger === "load") { - if (!pt(e, r, Bt("load", { elt: r }))) { - vt(ce(r), n, t, e.delay); - } - } else if (e.pollInterval > 0) { - t.polling = true; - ct(ce(r), n, e); - } else { - gt(r, n, t, e); - } - } - function Et(e) { - const t = ce(e); - if (!t) { - return false; - } - const n = t.attributes; - for (let e = 0; e < n.length; e++) { - const r = n[e].name; - if ( - l(r, "hx-on:") || - l(r, "data-hx-on:") || - l(r, "hx-on-") || - l(r, "data-hx-on-") - ) { - return true; - } - } - return false; - } - const Ct = 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 Ot(e, t) { - if (Et(e)) { - t.push(ce(e)); - } - const n = Ct.evaluate(e); - let r = null; - while ((r = n.iterateNext())) t.push(ce(r)); - } - function Rt(e) { - const t = []; - if (e instanceof DocumentFragment) { - for (const n of e.childNodes) { - Ot(n, t); - } - } else { - Ot(e, t); - } - return t; - } - function Ht(e) { - if (e.querySelectorAll) { - const n = - ", [hx-boost] a, [data-hx-boost] a, a[hx-boost], a[data-hx-boost]"; - const r = []; - for (const i in Vn) { - const s = Vn[i]; - if (s.getSelectors) { - var t = s.getSelectors(); - if (t) { - r.push(t); - } - } - } - const o = e.querySelectorAll( - T + - n + - ", form, [type='submit']," + - " [hx-ext], [data-hx-ext], [hx-trigger], [data-hx-trigger]" + - r - .flat() - .map((e) => ", " + e) - .join(""), + return ( + this.#D(e) && + (i ||= + t.submitter?.getAttribute?.("formAction") || + e.getAttribute(e.matches("a") ? "href" : "action")), + (r ||= + t.submitter?.getAttribute?.("formmethod") || + e.getAttribute("method") || + "GET"), + { action: i, method: r.toUpperCase() } ); - return o; - } else { - return []; - } - } - function Tt(e) { - const t = At(e.target); - const n = Nt(e); - if (n) { - n.lastButtonClicked = t; - } - } - function qt(e) { - const t = Nt(e); - if (t) { - t.lastButtonClicked = null; - } - } - function At(e) { - return g(ce(e), "button, input[type='submit']"); - } - function Lt(e) { - return e.form || g(e, "form"); - } - function Nt(e) { - const t = At(e.target); - if (!t) { - return; - } - const n = Lt(t); - return oe(n); - } - function It(e) { - e.addEventListener("click", Tt); - e.addEventListener("focusin", Tt); - e.addEventListener("focusout", qt); - } - function Pt(t, e, n) { - const r = oe(t); - if (!Array.isArray(r.onHandlers)) { - r.onHandlers = []; - } - let o; - const i = function (e) { - On(t, function () { - if (ft(t)) { - return; - } - if (!o) { - o = new Function("event", n); - } - o.call(t, e); - }); - }; - t.addEventListener(e, i); - r.onHandlers.push({ event: e, listener: i }); - } - function Dt(t) { - De(t); - for (let e = 0; e < t.attributes.length; e++) { - const n = t.attributes[e].name; - const r = t.attributes[e].value; - if (l(n, "hx-on") || l(n, "data-hx-on")) { - const o = n.indexOf("-on") + 3; - const i = n.slice(o, o + 1); - if (i === "-" || i === ":") { - let e = n.slice(o + 1); - if (l(e, ":")) { - e = "htmx" + e; - } else if (l(e, "-")) { - e = "htmx:" + e.slice(1); - } else if (l(e, "htmx-")) { - e = "htmx:" + e.slice(5); - } - Pt(t, e, r); - } - } - } - } - function kt(t) { - ae(t, "htmx:beforeProcessNode"); - const n = oe(t); - const e = st(t); - const r = wt(t, n, e); - if (!r) { - if (ne(t, "hx-boost") === "true") { - at(t, n, e); - } else if (s(t, "hx-trigger")) { - e.forEach(function (e) { - St(t, e, n, function () {}); - }); - } - } - if (t.tagName === "FORM" || (ee(t, "type") === "submit" && s(t, "form"))) { - It(t); - } - n.firstInitCompleted = true; - ae(t, "htmx:afterProcessNode"); - } - function Mt(e) { - if (!(e instanceof Element)) { - return false; - } - const t = oe(e); - const n = Pe(e); - if (t.initHash !== n) { - ke(e); - t.initHash = n; - return true; - } - return false; - } - function Ft(e) { - e = w(e); - if (ft(e)) { - S(e); - return; - } - const t = []; - if (Mt(e)) { - t.push(e); - } - ie(Ht(e), function (e) { - if (ft(e)) { - S(e); - return; - } - if (Mt(e)) { - t.push(e); - } - }); - ie(Rt(e), Dt); - ie(t, kt); - } - function Xt(e) { - return e.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(); - } - function Bt(e, t) { - return new CustomEvent(e, { - bubbles: true, - cancelable: true, - composed: true, - detail: t, - }); - } - function fe(e, t, n) { - ae(e, t, le({ error: t }, n)); - } - function Ut(e) { - return e === "htmx:afterProcessNode"; - } - function jt(e, t, n) { - ie(Jn(e, [], n), function (e) { - try { - t(e); - } catch (e) { - R(e); - } - }); - } - function R(e) { - console.error(e); - } - function ae(e, t, n) { - e = w(e); - if (n == null) { - n = {}; - } - n.elt = e; - const r = Bt(t, n); - if (Q.logger && !Ut(t)) { - Q.logger(e, t, n); - } - if (n.error) { - R(n.error); - ae(e, "htmx:error", { errorInfo: n }); - } - let o = e.dispatchEvent(r); - const i = Xt(t); - if (o && i !== t) { - const s = Bt(i, r.detail); - o = o && e.dispatchEvent(s); - } - jt(ce(e), function (e) { - o = o && e.onEvent(t, r) !== false && !r.defaultPrevented; - }); - return o; - } - let Vt = location.pathname + location.search; - function _t(e) { - Vt = e; - if (B()) { - sessionStorage.setItem("htmx-current-path-for-history", e); - } - } - function zt() { - const e = te().querySelector("[hx-history-elt],[data-hx-history-elt]"); - return e || te().body; - } - function $t(t, e) { - if (!B()) { - return; - } - const n = Kt(e); - const r = te().title; - const o = window.scrollY; - if (Q.config.historyCacheSize <= 0) { - sessionStorage.removeItem("htmx-history-cache"); - return; - } - t = U(t); - const i = v(sessionStorage.getItem("htmx-history-cache")) || []; - for (let e = 0; e < i.length; e++) { - if (i[e].url === t) { - i.splice(e, 1); - break; - } - } - const s = { url: t, content: n, title: r, scroll: o }; - ae(te().body, "htmx:historyItemCreated", { item: s, cache: i }); - i.push(s); - while (i.length > Q.config.historyCacheSize) { - i.shift(); - } - while (i.length > 0) { - try { - sessionStorage.setItem("htmx-history-cache", JSON.stringify(i)); - break; - } catch (e) { - fe(te().body, "htmx:historyCacheError", { cause: e, cache: i }); - i.shift(); - } - } - } - function Jt(t) { - if (!B()) { - return null; - } - t = U(t); - const n = v(sessionStorage.getItem("htmx-history-cache")) || []; - for (let e = 0; e < n.length; e++) { - if (n[e].url === t) { - return n[e]; - } - } - return null; - } - function Kt(e) { - const t = Q.config.requestClass; - const n = e.cloneNode(true); - ie(x(n, "." + t), function (e) { - G(e, t); - }); - ie(x(n, "[data-disabled-by-htmx]"), function (e) { - e.removeAttribute("disabled"); - }); - return n.innerHTML; - } - function Gt() { - const e = zt(); - let t = Vt; - if (B()) { - t = sessionStorage.getItem("htmx-current-path-for-history"); - } - t = t || location.pathname + location.search; - const n = te().querySelector( - '[hx-history="false" i],[data-hx-history="false" i]', - ); - if (!n) { - ae(te().body, "htmx:beforeHistorySave", { path: t, historyElt: e }); - $t(t, e); - } - if (Q.config.historyEnabled) - history.replaceState({ htmx: true }, te().title, location.href); - } - function Wt(e) { - if (Q.config.getCacheBusterParam) { - e = e.replace(/org\.htmx\.cache-buster=[^&]*&?/, ""); - if (Y(e, "&") || Y(e, "?")) { - e = e.slice(0, -1); - } - } - if (Q.config.historyEnabled) { - history.pushState({ htmx: true }, "", e); } - _t(e); - } - function Zt(e) { - if (Q.config.historyEnabled) history.replaceState({ htmx: true }, "", e); - _t(e); - } - function Yt(e) { - ie(e, function (e) { - e.call(undefined); - }); - } - function Qt(e) { - const t = new XMLHttpRequest(); - const n = { swapStyle: "innerHTML", swapDelay: 0, settleDelay: 0 }; - const r = { path: e, xhr: t, historyElt: zt(), swapSpec: n }; - t.open("GET", e, true); - if (Q.config.historyRestoreAsHxRequest) { - t.setRequestHeader("HX-Request", "true"); - } - t.setRequestHeader("HX-History-Restore-Request", "true"); - t.setRequestHeader("HX-Current-URL", location.href); - t.onload = function () { - if (this.status >= 200 && this.status < 400) { - r.response = this.response; - ae(te().body, "htmx:historyCacheMissLoad", r); - $e(r.historyElt, r.response, n, { - contextElement: r.historyElt, - historyRequest: true, - }); - _t(r.path); - ae(te().body, "htmx:historyRestore", { - path: e, - cacheMiss: true, - serverResponse: r.response, - }); - } else { - fe(te().body, "htmx:historyCacheMissLoadError", r); - } - }; - if (ae(te().body, "htmx:historyCacheMiss", r)) { - t.send(); - } - } - function en(e) { - Gt(); - e = e || location.pathname + location.search; - const t = Jt(e); - if (t) { - const n = { - swapStyle: "innerHTML", - swapDelay: 0, - settleDelay: 0, - scroll: t.scroll, - }; - const r = { path: e, item: t, historyElt: zt(), swapSpec: n }; - if (ae(te().body, "htmx:historyCacheHit", r)) { - $e(r.historyElt, t.content, n, { - contextElement: r.historyElt, - title: t.title, - }); - _t(r.path); - ae(te().body, "htmx:historyRestore", r); - } - } else { - if (Q.config.refreshOnHistoryMiss) { - Q.location.reload(true); - } else { - Qt(e); - } - } - } - function tn(e) { - let t = we(e, "hx-indicator"); - if (t == null) { - t = [e]; - } - ie(t, function (e) { - const t = oe(e); - t.requestCount = (t.requestCount || 0) + 1; - e.classList.add.call(e.classList, Q.config.requestClass); - }); - return t; - } - function nn(e) { - let t = we(e, "hx-disabled-elt"); - if (t == null) { - t = []; - } - ie(t, function (e) { - const t = oe(e); - t.requestCount = (t.requestCount || 0) + 1; - e.setAttribute("disabled", ""); - e.setAttribute("data-disabled-by-htmx", ""); - }); - return t; - } - function rn(e, t) { - ie(e.concat(t), function (e) { - const t = oe(e); - t.requestCount = (t.requestCount || 1) - 1; - }); - ie(e, function (e) { - const t = oe(e); - if (t.requestCount === 0) { - e.classList.remove.call(e.classList, Q.config.requestClass); - } - }); - ie(t, function (e) { - const t = oe(e); - if (t.requestCount === 0) { - e.removeAttribute("disabled"); - e.removeAttribute("data-disabled-by-htmx"); - } - }); - } - function on(t, n) { - for (let e = 0; e < t.length; e++) { - const r = t[e]; - if (r.isSameNode(n)) { - return true; - } - } - return false; - } - function sn(e) { - const t = e; - if ( - t.name === "" || - t.name == null || - t.disabled || - g(t, "fieldset[disabled]") - ) { - return false; - } - if ( - t.type === "button" || - t.type === "submit" || - t.tagName === "image" || - t.tagName === "reset" || - t.tagName === "file" - ) { - return false; - } - if (t.type === "checkbox" || t.type === "radio") { - return t.checked; - } - return true; - } - function ln(t, e, n) { - if (t != null && e != null) { - if (Array.isArray(e)) { - e.forEach(function (e) { - n.append(t, e); - }); - } else { - n.append(t, e); - } - } - } - function cn(t, n, r) { - if (t != null && n != null) { - let e = r.getAll(t); - if (Array.isArray(n)) { - e = e.filter((e) => n.indexOf(e) < 0); - } else { - e = e.filter((e) => e !== n); - } - r.delete(t); - ie(e, (e) => r.append(t, e)); - } - } - function un(e) { - if (e instanceof HTMLSelectElement && e.multiple) { - return M(e.querySelectorAll("option:checked")).map(function (e) { - return e.value; - }); - } - if (e instanceof HTMLInputElement && e.files) { - return M(e.files); - } - return e.value; - } - function fn(t, n, r, e, o) { - if (e == null || on(t, e)) { - return; - } else { - t.push(e); - } - if (sn(e)) { - const i = ee(e, "name"); - ln(i, un(e), n); - if (o) { - an(e, r); - } - } - if (e instanceof HTMLFormElement) { - ie(e.elements, function (e) { - if (t.indexOf(e) >= 0) { - cn(e.name, un(e), n); - } else { - t.push(e); - } - if (o) { - an(e, r); - } - }); - new FormData(e).forEach(function (e, t) { - if (e instanceof File && e.name === "") { - return; - } - ln(t, e, n); - }); - } - } - function an(e, t) { - const n = e; - if (n.willValidate) { - ae(n, "htmx:validation:validate"); - if (!n.checkValidity()) { - t.push({ elt: n, message: n.validationMessage, validity: n.validity }); - ae(n, "htmx:validation:failed", { - message: n.validationMessage, - validity: n.validity, - }); - } - } - } - function hn(n, e) { - for (const t of e.keys()) { - n.delete(t); - } - e.forEach(function (e, t) { - n.append(t, e); - }); - return n; - } - function dn(e, t) { - const n = []; - const r = new FormData(); - const o = new FormData(); - const i = []; - const s = oe(e); - if (s.lastButtonClicked && !se(s.lastButtonClicked)) { - s.lastButtonClicked = null; - } - let l = - (e instanceof HTMLFormElement && e.noValidate !== true) || - a(e, "hx-validate") === "true"; - if (s.lastButtonClicked) { - l = l && s.lastButtonClicked.formNoValidate !== true; - } - if (t !== "get") { - fn(n, o, i, Lt(e), l); - } - fn(n, r, i, e, l); - if ( - s.lastButtonClicked || - e.tagName === "BUTTON" || - (e.tagName === "INPUT" && ee(e, "type") === "submit") - ) { - const u = s.lastButtonClicked || e; - const f = ee(u, "name"); - ln(f, u.value, o); - } - const c = we(e, "hx-include"); - ie(c, function (e) { - fn(n, r, i, ce(e), l); - if (!h(e, "form")) { - ie(p(e).querySelectorAll(ot), function (e) { - fn(n, r, i, e, l); - }); - } - }); - hn(r, o); - return { errors: i, formData: r, values: kn(r) }; - } - function pn(e, t, n) { - if (e !== "") { - e += "&"; - } - if (String(n) === "[object Object]") { - n = JSON.stringify(n); - } - const r = encodeURIComponent(n); - e += encodeURIComponent(t) + "=" + r; - return e; - } - function gn(e) { - e = Pn(e); - let n = ""; - e.forEach(function (e, t) { - n = pn(n, t, e); - }); - return n; - } - function mn(e, t, n) { - const r = { - "HX-Request": "true", - "HX-Trigger": ee(e, "id"), - "HX-Trigger-Name": ee(e, "name"), - "HX-Target": a(t, "id"), - "HX-Current-URL": location.href, - }; - Cn(e, "hx-headers", false, r); - if (n !== undefined) { - r["HX-Prompt"] = n; - } - if (oe(e).boosted) { - r["HX-Boosted"] = "true"; - } - return r; - } - function yn(n, e) { - const t = ne(e, "hx-params"); - if (t) { - if (t === "none") { - return new FormData(); - } else if (t === "*") { - return n; - } else if (t.indexOf("not ") === 0) { - ie(t.slice(4).split(","), function (e) { - e = e.trim(); - n.delete(e); - }); - return n; - } else { - const r = new FormData(); - ie(t.split(","), function (t) { - t = t.trim(); - if (n.has(t)) { - n.getAll(t).forEach(function (e) { - r.append(t, e); - }); - } - }); - return r; - } - } else { - return n; - } - } - function xn(e) { - return !!ee(e, "href") && ee(e, "href").indexOf("#") >= 0; - } - function bn(e, t) { - const n = t || ne(e, "hx-swap"); - const r = { - swapStyle: oe(e).boosted ? "innerHTML" : Q.config.defaultSwapStyle, - swapDelay: Q.config.defaultSwapDelay, - settleDelay: Q.config.defaultSettleDelay, - }; - if (Q.config.scrollIntoViewOnBoost && oe(e).boosted && !xn(e)) { - r.show = "top"; - } - if (n) { - const s = X(n); - if (s.length > 0) { - for (let e = 0; e < s.length; e++) { - const l = s[e]; - if (l.indexOf("swap:") === 0) { - r.swapDelay = d(l.slice(5)); - } else if (l.indexOf("settle:") === 0) { - r.settleDelay = d(l.slice(7)); - } else if (l.indexOf("transition:") === 0) { - r.transition = l.slice(11) === "true"; - } else if (l.indexOf("ignoreTitle:") === 0) { - r.ignoreTitle = l.slice(12) === "true"; - } else if (l.indexOf("scroll:") === 0) { - const c = l.slice(7); - var o = c.split(":"); - const u = o.pop(); - var i = o.length > 0 ? o.join(":") : null; - r.scroll = u; - r.scrollTarget = i; - } else if (l.indexOf("show:") === 0) { - const f = l.slice(5); - var o = f.split(":"); - const a = o.pop(); - var i = o.length > 0 ? o.join(":") : null; - r.show = a; - r.showTarget = i; - } else if (l.indexOf("focus-scroll:") === 0) { - const h = l.slice("focus-scroll:".length); - r.focusScroll = h == "true"; - } else if (e == 0) { - r.swapStyle = l; - } else { - R("Unknown modifier in hx-swap: " + l); - } - } - } + #H(e) { + return ( + e._htmx || + ((e._htmx = { listeners: [], triggerSpecs: [] }), + e.setAttribute("data-htmx-powered", "true")), + e._htmx + ); } - return r; - } - function vn(e) { - return ( - ne(e, "hx-encoding") === "multipart/form-data" || - (h(e, "form") && ee(e, "enctype") === "multipart/form-data") - ); - } - function wn(t, n, r) { - let o = null; - jt(n, function (e) { - if (o == null) { - o = e.encodeParameters(t, r, n); - } - }); - if (o != null) { - return o; - } else { - if (vn(n)) { - return hn(new FormData(), Pn(r)); - } else { - return gn(r); - } + #W(e) { + return (e._htmx_state ||= {}); } - } - function Sn(e) { - return { tasks: [], elts: [e] }; - } - function En(e, t) { - const n = e[0]; - const r = e[e.length - 1]; - if (t.scroll) { - var o = null; - if (t.scrollTarget) { - o = ce(ue(n, t.scrollTarget)); - } - if (t.scroll === "top" && (n || o)) { - o = o || n; - o.scrollTop = 0; - } - if (t.scroll === "bottom" && (r || o)) { - o = o || r; - o.scrollTop = o.scrollHeight; - } - if (typeof t.scroll === "number") { - b().setTimeout(function () { - window.scrollTo(0, t.scroll); - }, 0); + #_(e) { + if (this.#U(e) && this.#L(e, "htmx:before:init", {}, !0)) { + let t = this.#H(e); + ((t.initialized = !0), + (t.eventHandler = this.#Q(e)), + this.#J(e), + this.#L(e, "htmx:after:init", {}, !0)); } } - if (t.show) { - var o = null; - if (t.showTarget) { - let e = t.showTarget; - if (t.showTarget === "window") { - e = "body"; + #Q(e) { + return async (t) => { + try { + let r = this.#T(e, t); + await this.#X(r); + } catch (t) { + this.#L(e, "htmx:error", { error: t }); } - o = ce(ue(n, e)); - } - if (t.show === "top" && (n || o)) { - o = o || n; - o.scrollIntoView({ block: "start", behavior: Q.config.scrollBehavior }); - } - if (t.show === "bottom" && (r || o)) { - o = o || r; - o.scrollIntoView({ block: "end", behavior: Q.config.scrollBehavior }); - } + }; } - } - function Cn(r, e, o, i, s) { - if (i == null) { - i = {}; + #T(t, r) { + let { action: i, method: s } = this.#A(t, r), + [n, o] = (i || "").split("#"), + a = new AbortController(), + l = { + sourceElement: t, + sourceEvent: r, + status: "created", + select: this.#E(t, "hx-select"), + selectOOB: this.#E(t, "hx-select-oob"), + target: this.#E(t, "hx-target"), + swap: this.#E(t, "hx-swap") ?? this.config.defaultSwap, + push: this.#E(t, "hx-push-url"), + replace: this.#E(t, "hx-replace-url"), + transition: this.config.transitions, + confirm: this.#E(t, "hx-confirm"), + request: { + validate: + "true" === + this.#E( + t, + "hx-validate", + !t.matches("form") || + t.noValidate || + r.submitter?.formNoValidate + ? "false" + : "true", + void 0, + !1, + ), + action: n, + anchor: o, + method: s, + headers: this.#G(t), + abort: a.abort.bind(a), + credentials: "same-origin", + signal: a.signal, + mode: this.config.mode, + }, + }; + (t._htmx?.boosted && e.merge(t._htmx.boosted, l), + (l.target = this.#K(t, l.target)), + l.target && (l.request.headers["HX-Target"] = this.#Y(l.target))); + let h = this.#E(t, "hx-config"); + return ( + h && (e.merge(h, l.request), (l.request.mode = this.config.mode)), + l + ); } - if (r == null) { - return i; + #Y(e) { + return `${e.tagName.toLowerCase()}${e.id ? "#" + encodeURI(e.id) : ""}`; } - const l = a(r, e); - if (l) { - let e = l.trim(); - let t = o; - if (e === "unset") { - return null; - } - if (e.indexOf("javascript:") === 0) { - e = e.slice(11); - t = true; - } else if (e.indexOf("js:") === 0) { - e = e.slice(3); - t = true; + #G(e) { + let t = { + "HX-Request": "true", + "HX-Source": this.#Y(e), + "HX-Current-URL": location.href, + Accept: "text/html", + }; + return (this.#D(e) && (t["HX-Boosted"] = "true"), t); + } + #Z(e, t) { + return this.#q( + e, + "hx-headers", + (e) => { + for (let r in e) t.request.headers[r] = String(e[r]); + }, + { ctx: t }, + ); + } + #K(e, t) { + return t instanceof Element + ? t + : null != t + ? this.#ee(e, t, "hx-target") + : this.#D(e) + ? document.body + : e; + } + #D(e) { + return e?._htmx?.boosted; + } + async #X(e) { + let t = e.sourceElement, + r = e.sourceEvent; + if (!t.isConnected) return; + if (this.#te(r)) return; + this.#re(r) && r.preventDefault(); + let i = /GET|DELETE/.test(e.request.method), + s = i ? (t.matches("form") ? t : null) : t.form || t.closest("form"), + n = this.#C(t, s, r.submitter, e.request.validate, i); + if (!n) return; + let o = this.#q( + t, + "hx-vals", + (t) => { + e.vals = t; + for (let e in t) n.set(e, t[e]); + }, + { ctx: e }, + ); + if ((o && (await o), e.values)) + for (let t in e.values) (n.delete(t), n.append(t, e.values[t])); + let a = this.#Z(t, e); + if ( + (a && (await a), + Object.assign(e.request, { form: s, submitter: r.submitter, body: n }), + !this.#L(t, "htmx:config:request", { ctx: e })) + ) + return; + if ("DIALOG" === e.request.method) return; + let l = this.#ie(e.request.action); + if (null != l) { + let t = Object.fromEntries(e.request.body); + return void (await this.#k(e.sourceElement, t, l, !1)); } - if (e.indexOf("{") !== 0) { - e = "{" + e + "}"; + if (i) { + let t = new URL(e.request.action, document.baseURI); + for (let r of e.request.body.keys()) t.searchParams.delete(r); + for (let [r, i] of e.request.body) t.searchParams.append(r, i); + (t.origin === location.origin + ? (e.request.action = t.pathname + t.search) + : (e.request.action = t.href), + (e.request.body = null)); + } else + "multipart/form-data" !== (this.#E(t, "hx-encoding") ?? s?.enctype) && + (e.request.body = new URLSearchParams(e.request.body)); + await this.#se(e); + } + async #se(e) { + let t = e.sourceElement, + r = this.#ne(t), + i = this.#oe(t); + this.#ae(t); + let s = () => e.request?.abort?.(); + if ("run" === i.admit(r, () => this.#se(e), s)) { + ((e.status = "issuing"), + (e.indicators ??= []), + (e.disabledElements ??= [])); + try { + if (e.confirm) { + if ( + !(await new Promise((r) => { + let i = { + ctx: e, + issueRequest: () => r(!0), + dropRequest: () => r(!1), + }; + if (this.#L(t, "htmx:confirm", i)) { + let i = this.#ie(e.confirm); + r( + i + ? this.#k(t, { ctx: e }, i, !0) + : window.confirm(e.confirm), + ); + } + })) + ) + return; + } + if ( + (this.#le(e), + this.#he(e), + this.#ce(e), + (e.fetch ||= window.fetch.bind(window)), + (e.request.headers["HX-Request-Type"] = + e.target === document.body || e.select ? "full" : "partial"), + !this.#L(t, "htmx:before:request", { ctx: e })) + ) + return; + let r = await e.fetch(e.request.action, e.request); + if ( + ((e.response = { raw: r, status: r.status, headers: r.headers }), + this.#ue(e), + !this.#L(t, "htmx:before:response", { ctx: e })) + ) + return; + if ( + ((e.text = await r.text()), + !this.#L(t, "htmx:after:request", { ctx: e })) + ) + return; + if ( + (e.response.status >= 400 && + this.#L(t, "htmx:response:error", { ctx: e }), + this.#de(e)) + ) + return void (e.keepIndicators = !0); + if ("issuing" === e.status) { + if ( + (e.hx.retarget && (e.target = e.hx.retarget), + e.hx.reswap && (e.swap = e.hx.reswap), + e.hx.reselect && (e.select = e.hx.reselect), + !1 === e.target?.isConnected) + ) + return; + ((e.status = "response received"), + this.#fe(e), + await this.swap(e), + (e.status = "swapped")); + } + } catch (r) { + ((e.status = "error: " + r), + ("AbortError" === r?.name && + "timeout" !== e.request.signal.reason) || + this.#L(t, "htmx:error", { ctx: e, error: r })); + } finally { + (await e.extensionPromise?.catch(() => {}), + clearTimeout(e.requestTimeout), + e.hx?.trigger && this.#me(e.hx.trigger, e.sourceElement), + this.#L(t, "htmx:finally:request", { ctx: e }), + e.keepIndicators || + (this.#pe(e.indicators), this.#ge(e.disabledElements)), + i.continue(s)); + } + } + } + #ue(e) { + e.hx = {}; + for (let [t, r] of e.response.raw.headers) + t.toLowerCase().startsWith("hx-") && + (e.hx[t.slice(3).toLowerCase().replace(/-/g, "")] = r); + } + #de(t) { + if ("true" === t.hx.refresh) return (this._loc.reload(), !0); + if (t.hx.redirect) return ((this._loc.href = t.hx.redirect), !0); + if (t.hx.location) { + let r = t.hx.location, + i = {}, + s = e.parse(r); + return ( + ("{" !== r[0] && null == s.path) || + ((i = s), (r = i.path), delete i.path), + null == i.push && null == i.replace && (i.push = "true"), + (i.indicators = t.indicators), + (i.disabledElements = t.disabledElements), + this.ajax("GET", r, i), + !0 + ); } - let n; - if (t) { - n = On( - r, - function () { - if (s) { - return Function("event", "return (" + e + ")").call(r, s); - } else { - return Function("return (" + e + ")").call(r); + } + #le(e) { + let t = + null != e.request.timeout + ? this.parseInterval(e.request.timeout) + : this.config.defaultTimeout; + t && + (e.requestTimeout = setTimeout(() => e.request?.abort?.("timeout"), t)); + } + #ne(e) { + let t = this.#E(e, "hx-sync"); + if (!t) return "queue first"; + let r = t.split(":").pop().trim(); + return /^(drop|abort|replace|queue)/.test(r) ? r : "queue first"; + } + #oe(e) { + let r = this.#E(e, "hx-sync"), + i = e; + if (r) { + let t = r.includes(":") + ? r.slice(0, r.lastIndexOf(":")).trim() + : /^(drop|abort|replace|queue)/.test(r) + ? null + : r; + t && (i = this.#ee(e, t, "hx-sync") || e); + } + return (this.#W(i).rq ||= new t()); + } + #te(e) { + return ( + "click" === e.type && + (e.ctrlKey || e.metaKey || e.shiftKey) && + !!e.currentTarget?.closest?.("a[href]") + ); + } + #re(e) { + let t = e.currentTarget; + if ("submit" === e.type && "FORM" === t?.tagName) return !0; + if (!("click" === e.type && 0 === e.button)) return !1; + let r = t?.closest?.('button, input[type="submit"], input[type="image"]'), + i = r?.form || r?.closest("form"); + if ( + r && + !r.disabled && + i && + ("submit" === r.type || + "image" === r.type || + (!r.type && "BUTTON" === r.tagName)) + ) + return !0; + let s = t?.closest?.("a"); + if (!s || !s.href) return !1; + let n = s.getAttribute("href"); + return !(n && n.startsWith("#") && n.length > 1); + } + #J(e, t = e._htmx.eventHandler) { + let r = + this.#E(e, "hx-trigger", void 0, void 0, !1) || + (e.matches("form") + ? "submit" + : e.matches( + "input:not([type=button]):not([type=submit]),select,textarea", + ) + ? "change" + : "click"); + this.#O(e, r, t); + } + #O(e, t, r) { + let i = this.#w(t); + this.#H(e).triggerSpecs.push(...i); + for (let t of i) { + t.listeners = []; + let [i, s] = this.#xe(t.name), + n = [e]; + "outside" === t.from + ? (n = [document]) + : t.from && "self" !== t.from && (n = this.#be(e, t.from)); + let o = (i) => { + if ( + ((t.halt || t.prevent) && i.preventDefault(), + (t.halt || t.stop || t.consume) && i.stopPropagation(), + t.changed) + ) { + let t = (this.#W(e).changedValues ??= new WeakMap()), + r = i.target; + if (!["checkbox", "radio"].includes(r?.type)) { + let e = r?.value; + if (t.has(r) && t.get(r) === e) return; + t.set(r, e); + } } + if (t.once) + for (let e of t.listeners) + e.fromElt.removeEventListener(e.eventName, e.handler, e); + r(i); }, - {}, - ); - } else { - n = v(e); - } - for (const c in n) { - if (n.hasOwnProperty(c)) { - if (i[c] == null) { - i[c] = n[c]; + a = o; + if ( + (t.delay + ? (a = (e) => { + (clearTimeout(t.timeout), + (t.timeout = setTimeout( + () => o(e), + this.parseInterval(t.delay), + ))); + }) + : t.throttle && + (a = (e) => { + t.throttled + ? (t.throttledEvent = e) + : ((t.throttled = !0), + o(e), + (t.throttleTimeout = setTimeout(() => { + if (((t.throttled = !1), t.throttledEvent)) { + let e = t.throttledEvent; + ((t.throttledEvent = null), a(e)); + } + }, this.parseInterval(t.throttle)))); + }), + (t.handler = (r) => { + if ( + (this.#re(r) && r.preventDefault(), + ("self" !== t.from || r.target === e) && + ("outside" !== t.from || !e.contains(r.target)) && + (!t.target || r.target?.matches?.(t.target))) + ) { + if (s) { + let t = {}; + for (let e in r) /^[a-z]+$/i.test(e) && (t[e] = r[e]); + if (!this.#k(e, t, s, !0, !1)) return; + } + if ("every" !== i) + for (let t of this.#H(e).triggerSpecs) + (clearTimeout(t.timeout), (t.throttledEvent = null)); + a(r); + } + }), + "intersect" === i || "revealed" === i) + ) { + let r = { rootMargin: t.rootMargin }; + (t.root && (r.root = this.#ee(e, t.root)), + t.threshold && (r.threshold = parseFloat(t.threshold))); + let s = "revealed" === i; + ((t.observer = new IntersectionObserver((e) => { + for (let r = 0; r < e.length; r++) + if (e[r].isIntersecting) { + (this.trigger(e[r].target, "intersect", {}, !1), + s && t.observer.disconnect()); + break; + } + }, r)), + (i = "intersect")); + for (let e of n) t.observer.observe(e); + } + if ("every" === i) { + let r = Object.keys(t).find((e) => "name" !== e); + t.interval = setInterval(() => { + e.isConnected + ? this.#L(e, "every", {}, !1) + : clearInterval(t.interval); + }, this.parseInterval(r)); + } + if ("load" !== i) + for (let r of n) { + let s = { + fromElt: r, + eventName: i, + handler: t.handler, + capture: !!t.capture, + passive: !!t.passive, + }; + (e._htmx.listeners.push(s), + t.listeners.push(s), + r.addEventListener(i, t.handler, s)); } - } - } - } - return Cn(ce(u(r)), e, o, i, s); - } - function On(e, t, n) { - if (Q.config.allowEval) { - return t(); - } else { - fe(e, "htmx:evalDisallowedError"); - return n; + else t.handler(new CustomEvent("load")); + } + } + #xe(e) { + let t = e.match(/^([^\[]*)\[([^\]]*)]/); + return t ? [t[1], t[2]] : [e, null]; + } + #me(t, r) { + if ("{" === t[0]) { + let i = e.parse(t); + for (let e in i) { + let t = i[e], + s = r; + (t?.target && (s = this.find(t.target)), + this.trigger(s, e, "object" == typeof t ? t : { value: t })); + } + } else t.split(",").forEach((e) => this.trigger(r, e.trim(), {})); + } + #ye(e) { + let t = {}, + r = Object.getPrototypeOf(this); + for (let i of Object.getOwnPropertyNames(r)) + "constructor" !== i && + "function" == typeof this[i] && + (["find", "findAll"].includes(i) + ? (t[i] = (t, r) => (void 0 === r ? this[i](e, t) : this[i](t, r))) + : (t[i] = this[i].bind(this))); + return t; } - } - function Rn(e, t, n) { - return Cn(e, "hx-vars", true, n, t); - } - function Hn(e, t, n) { - return Cn(e, "hx-vals", false, n, t); - } - function Tn(e, t) { - return le(Rn(e, t), Hn(e, t)); - } - function qn(t, n, r) { - if (r !== null) { - try { - t.setRequestHeader(n, r); - } catch (e) { - t.setRequestHeader(n, encodeURIComponent(r)); - t.setRequestHeader(n + "-URI-AutoEncoded", "true"); + #k(e, t, r, i = !0, s = !0, n = !1) { + let o = {}; + Object.assign(o, this.#ye(e)); + let a = {}, + l = { scope: a, code: r }; + (this.#$(e, "htmx:scope", l), + (r = l.code), + Object.assign(o, a), + Object.assign(o, t)); + let h = Object.keys(o), + c = Object.values(o), + u = new (s ? this.#l : this.#a)(...h, i ? `return (${r})` : r); + return n ? () => u.call(e, ...c) : u.call(e, ...c); + } + process(e, t) { + if (!e?.isConnected) return; + if (!(e instanceof Element)) { + for (let r of e.children || []) this.process(r, t); + return; } + if ((t && this.#Se(e, !0), this.#V(e))) return; + if (!this.#L(e, "htmx:before:process")) return; + let r = [e], + i = this.#f.evaluate(e), + s = null; + for (; (s = i.iterateNext());) r.push(s); + for (let e of r) + !this.#V(e) && this.#L(e, "htmx:before:on:init", {}, !0) && this.#ve(e); + for (let t of this.#j(e, this.#c)) this.#_(t); + for (let t of this.#j(e, this.#u)) this.#Ee(t); + this.#L(e, "htmx:after:process"); + } + #Ee(e) { + let t = this.#E(e, "hx-boost"); + if ( + t && + "false" !== t && + this.#we(e) && + this.#L(e, "htmx:before:init", {}, !0) + ) { + let r = this.#H(e); + ((r.initialized = !0), + (r.eventHandler = this.#Q(e)), + (r.boosted = t), + this.#J(e), + this.#L(e, "htmx:after:init", {}, !0)); + } + } + #we(e) { + if (this.#U(e)) + if ("A" === e.tagName) { + if ("" === e.target || "_self" === e.target) + return ( + !e.hasAttribute("download") && + !e.getAttribute("href")?.startsWith?.("#") && + this.#Ae(e.href) + ); + } else if ("FORM" === e.tagName) + return "dialog" !== e.method && this.#Ae(e.action); } - } - function An(t) { - if (t.responseURL) { + #Ae(e) { try { - const e = new URL(t.responseURL); - return e.pathname + e.search; + return ( + new URL(e, window.location.href).origin === window.location.origin + ); } catch (e) { - fe(te().body, "htmx:badResponseUrl", { url: t.responseURL }); + return !1; + } + } + #U(e) { + return !e._htmx?.initialized && !this.#V(e); + } + #Se(e, t) { + let r = [e, ...(e.querySelectorAll?.("[data-htmx-powered]") ?? [])]; + for (let e of r) + if (e._htmx) { + this.#L(e, "htmx:before:cleanup"); + for (let t of e._htmx.triggerSpecs || []) + (t.interval && clearInterval(t.interval), + t.timeout && clearTimeout(t.timeout), + t.throttleTimeout && clearTimeout(t.throttleTimeout), + t.observer?.disconnect()); + for (let t of e._htmx.listeners || []) + t.fromElt.removeEventListener(t.eventName, t.handler, t); + (e.removeAttribute("data-htmx-powered"), + this.#L(e, "htmx:after:cleanup"), + t && delete e._htmx); + } + } + #Te(e) { + let t = document.createElement("div"); + ((t.hidden = !0), document.body.insertAdjacentElement("afterend", t)); + let r = e.querySelectorAll?.(this.#S("[hx-preserve]")) || []; + for (let e of r) { + let r = document.getElementById(e.id); + r && this.#Ce(t, r, null); } + return t; } - } - function H(e, t) { - return t.test(e.getAllResponseHeaders()); - } - function Ln(t, n, r) { - t = t.toLowerCase(); - if (r) { - if (r instanceof Element || typeof r === "string") { - return he(t, n, null, null, { - targetOverride: w(r) || ve, - returnPromise: true, - }); - } else { - let e = w(r.target); - if ((r.target && !e) || (r.source && !e && !w(r.source))) { - e = ve; - } - return he(t, n, w(r.source), r.event, { - handler: r.handler, - headers: r.headers, - values: r.values, - targetOverride: e, - swapOverride: r.swap, - select: r.select, - returnPromise: true, - }); + #qe(e) { + for (let t of [...e.children]) { + let e = document.getElementById(t.id); + e && (this.#Ce(e.parentNode, t, e), this.#Se(e), e.remove()); } - } else { - return he(t, n, null, null, { returnPromise: true }); + e.remove(); } - } - function Nn(e) { - const t = []; - while (e) { - t.push(e); - e = e.parentElement; + #Ne(e) { + let t = this.#h.createHTML(e); + return ( + Document.parseHTMLUnsafe?.(t, {}) || + new DOMParser().parseFromString(t, "text/html") + ); } - return t; - } - function In(e, t, n) { - const r = new URL( - t, - location.protocol !== "about:" ? location.href : window.origin, - ); - const o = location.protocol !== "about:" ? location.origin : window.origin; - const i = o === r.origin; - if (Q.config.selfRequestsOnly) { - if (!i) { - return false; + #Ie(e) { + let t = e + .replace(/