From bf692737011b40316397d55c3ee756fde6c502cf Mon Sep 17 00:00:00 2001 From: Carson Gross Date: Thu, 21 Mar 2024 16:02:23 -0600 Subject: [PATCH] beta2 --- dist/ext/README.md | 9 - dist/ext/_WARNING_DEPRECATED_FILES_.txt | 5 - dist/ext/ajax-header.js | 11 - dist/ext/alpine-morph.js | 20 - dist/ext/class-tools.js | 97 ---- dist/ext/client-side-templates.js | 100 ---- dist/ext/debug.js | 15 - dist/ext/disable-element.js | 20 - dist/ext/event-header.js | 41 -- dist/ext/head-support.js | 146 ------ dist/ext/include-vals.js | 28 -- dist/ext/json-enc.js | 16 - dist/ext/loading-states.js | 189 -------- dist/ext/method-override.js | 15 - dist/ext/morphdom-swap.js | 21 - dist/ext/multi-swap.js | 50 -- dist/ext/path-deps.js | 63 --- dist/ext/path-params.js | 15 - dist/ext/preload.js | 151 ------ dist/ext/rails-method.js | 14 - dist/ext/remove-me.js | 31 -- dist/ext/response-targets.js | 135 ------ dist/ext/restored.js | 19 - dist/ext/sse.js | 374 --------------- dist/ext/ws.js | 481 -------------------- dist/htmx.amd.js | 4 +- dist/htmx.cjs.js | 4 +- dist/htmx.esm.js | 4 +- dist/htmx.js | 4 +- dist/htmx.min.js | 2 +- dist/htmx.min.js.gz | Bin 15576 -> 15576 bytes package.json | 2 +- www/static/src/ext/ajax-header.js | 7 - www/static/src/ext/class-tools.js | 92 ---- www/static/src/ext/client-side-templates.js | 96 ---- www/static/src/ext/debug.js | 11 - www/static/src/ext/disable-element.js | 18 - www/static/src/ext/event-header.js | 37 -- www/static/src/ext/head-support.js | 141 ------ www/static/src/ext/include-vals.js | 24 - www/static/src/ext/json-enc.js | 12 - www/static/src/ext/loading-states.js | 183 -------- www/static/src/ext/method-override.js | 11 - www/static/src/ext/morphdom-swap.js | 17 - www/static/src/ext/multi-swap.js | 45 -- www/static/src/ext/path-deps.js | 60 --- www/static/src/ext/path-params.js | 11 - www/static/src/ext/remove-me.js | 27 -- www/static/src/ext/response-targets.js | 130 ------ www/static/src/ext/sse.js | 313 ------------- www/static/src/ext/ws.js | 476 ------------------- www/static/src/htmx.js | 4 +- www/themes/htmx-theme/static/js/htmx.js | 4 +- 53 files changed, 14 insertions(+), 3791 deletions(-) delete mode 100644 dist/ext/README.md delete mode 100644 dist/ext/_WARNING_DEPRECATED_FILES_.txt delete mode 100644 dist/ext/ajax-header.js delete mode 100644 dist/ext/alpine-morph.js delete mode 100644 dist/ext/class-tools.js delete mode 100644 dist/ext/client-side-templates.js delete mode 100644 dist/ext/debug.js delete mode 100644 dist/ext/disable-element.js delete mode 100644 dist/ext/event-header.js delete mode 100644 dist/ext/head-support.js delete mode 100644 dist/ext/include-vals.js delete mode 100644 dist/ext/json-enc.js delete mode 100644 dist/ext/loading-states.js delete mode 100644 dist/ext/method-override.js delete mode 100644 dist/ext/morphdom-swap.js delete mode 100644 dist/ext/multi-swap.js delete mode 100644 dist/ext/path-deps.js delete mode 100644 dist/ext/path-params.js delete mode 100644 dist/ext/preload.js delete mode 100644 dist/ext/rails-method.js delete mode 100644 dist/ext/remove-me.js delete mode 100644 dist/ext/response-targets.js delete mode 100644 dist/ext/restored.js delete mode 100644 dist/ext/sse.js delete mode 100644 dist/ext/ws.js delete mode 100644 www/static/src/ext/ajax-header.js delete mode 100644 www/static/src/ext/class-tools.js delete mode 100644 www/static/src/ext/client-side-templates.js delete mode 100644 www/static/src/ext/debug.js delete mode 100644 www/static/src/ext/disable-element.js delete mode 100644 www/static/src/ext/event-header.js delete mode 100644 www/static/src/ext/head-support.js delete mode 100644 www/static/src/ext/include-vals.js delete mode 100644 www/static/src/ext/json-enc.js delete mode 100644 www/static/src/ext/loading-states.js delete mode 100644 www/static/src/ext/method-override.js delete mode 100644 www/static/src/ext/morphdom-swap.js delete mode 100644 www/static/src/ext/multi-swap.js delete mode 100644 www/static/src/ext/path-deps.js delete mode 100644 www/static/src/ext/path-params.js delete mode 100644 www/static/src/ext/remove-me.js delete mode 100644 www/static/src/ext/response-targets.js delete mode 100644 www/static/src/ext/sse.js delete mode 100644 www/static/src/ext/ws.js diff --git a/dist/ext/README.md b/dist/ext/README.md deleted file mode 100644 index 1904ec05..00000000 --- a/dist/ext/README.md +++ /dev/null @@ -1,9 +0,0 @@ -# Why Are These Files Here? - -These are legacy extensions for htmx 1.x and are **NOT** actively maintained or guaranteed to work with htmx 2.x. -They are here because we unfortunately linked to unversioned unpkg URLs in the installation guides for them -in 1.x, so we need to keep them here to preserve those URLs and not break existing users functionality. - -If you are looking for extensions for htmx 2.x, please see the [htmx 2.0 extensions site](https://extensions.htmx.org), -which has links to the new extensions repos (They have all been moved to their own NPM projects and URLs, like -they should have been from the start!) diff --git a/dist/ext/_WARNING_DEPRECATED_FILES_.txt b/dist/ext/_WARNING_DEPRECATED_FILES_.txt deleted file mode 100644 index 6dff4c27..00000000 --- a/dist/ext/_WARNING_DEPRECATED_FILES_.txt +++ /dev/null @@ -1,5 +0,0 @@ -!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!! THESE FILES ARE DEPRECATED AND UNSUPPORTED !! -!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -SEE README.md FOR MORE DETAILS diff --git a/dist/ext/ajax-header.js b/dist/ext/ajax-header.js deleted file mode 100644 index be4758d5..00000000 --- a/dist/ext/ajax-header.js +++ /dev/null @@ -1,11 +0,0 @@ -if (htmx.version && !htmx.version.startsWith("1.")) { - console.warn("WARNING: You are using an htmx 1 extension with htmx " + htmx.version + - ". It is recommended that you move to the version of this extension found on https://extensions.htmx.org") -} -htmx.defineExtension('ajax-header', { - onEvent: function (name, evt) { - if (name === "htmx:configRequest") { - evt.detail.headers['X-Requested-With'] = 'XMLHttpRequest'; - } - } -}); diff --git a/dist/ext/alpine-morph.js b/dist/ext/alpine-morph.js deleted file mode 100644 index fcf4b2b4..00000000 --- a/dist/ext/alpine-morph.js +++ /dev/null @@ -1,20 +0,0 @@ -if (htmx.version && !htmx.version.startsWith("1.")) { - console.warn("WARNING: You are using an htmx 1 extension with htmx " + htmx.version + - ". It is recommended that you move to the version of this extension found on https://extensions.htmx.org") -} -htmx.defineExtension('alpine-morph', { - isInlineSwap: function (swapStyle) { - return swapStyle === 'morph'; - }, - handleSwap: function (swapStyle, target, fragment) { - if (swapStyle === 'morph') { - if (fragment.nodeType === Node.DOCUMENT_FRAGMENT_NODE) { - Alpine.morph(target, fragment.firstElementChild); - return [target]; - } else { - Alpine.morph(target, fragment.outerHTML); - return [target]; - } - } - } -}); diff --git a/dist/ext/class-tools.js b/dist/ext/class-tools.js deleted file mode 100644 index 7d4bfa87..00000000 --- a/dist/ext/class-tools.js +++ /dev/null @@ -1,97 +0,0 @@ -(function () { - - if (htmx.version && !htmx.version.startsWith("1.")) { - console.warn("WARNING: You are using an htmx 1 extension with htmx " + htmx.version + - ". It is recommended that you move to the version of this extension found on https://extensions.htmx.org") - } - - function splitOnWhitespace(trigger) { - return trigger.split(/\s+/); - } - - function parseClassOperation(trimmedValue) { - var split = splitOnWhitespace(trimmedValue); - if (split.length > 1) { - var operation = split[0]; - var classDef = split[1].trim(); - var cssClass; - var delay; - if (classDef.indexOf(":") > 0) { - var splitCssClass = classDef.split(':'); - cssClass = splitCssClass[0]; - delay = htmx.parseInterval(splitCssClass[1]); - } else { - cssClass = classDef; - delay = 100; - } - return { - operation: operation, - cssClass: cssClass, - delay: delay - } - } else { - return null; - } - } - - function performOperation(elt, classOperation, classList, currentRunTime) { - setTimeout(function () { - elt.classList[classOperation.operation].call(elt.classList, classOperation.cssClass); - }, currentRunTime) - } - - function toggleOperation(elt, classOperation, classList, currentRunTime) { - setTimeout(function () { - setInterval(function () { - elt.classList[classOperation.operation].call(elt.classList, classOperation.cssClass); - }, classOperation.delay); - }, currentRunTime) - } - - function processClassList(elt, classList) { - var runs = classList.split("&"); - for (var i = 0; i < runs.length; i++) { - var run = runs[i]; - var currentRunTime = 0; - var classOperations = run.split(","); - for (var j = 0; j < classOperations.length; j++) { - var value = classOperations[j]; - var trimmedValue = value.trim(); - var classOperation = parseClassOperation(trimmedValue); - if (classOperation) { - if (classOperation.operation === "toggle") { - toggleOperation(elt, classOperation, classList, currentRunTime); - currentRunTime = currentRunTime + classOperation.delay; - } else { - currentRunTime = currentRunTime + classOperation.delay; - performOperation(elt, classOperation, classList, currentRunTime); - } - } - } - } - } - - function maybeProcessClasses(elt) { - if (elt.getAttribute) { - var classList = elt.getAttribute("classes") || elt.getAttribute("data-classes"); - if (classList) { - processClassList(elt, classList); - } - } - } - - htmx.defineExtension('class-tools', { - onEvent: function (name, evt) { - if (name === "htmx:afterProcessNode") { - var elt = evt.detail.elt; - maybeProcessClasses(elt); - if (elt.querySelectorAll) { - var children = elt.querySelectorAll("[classes], [data-classes]"); - for (var i = 0; i < children.length; i++) { - maybeProcessClasses(children[i]); - } - } - } - } - }); -})(); diff --git a/dist/ext/client-side-templates.js b/dist/ext/client-side-templates.js deleted file mode 100644 index a8e24ddf..00000000 --- a/dist/ext/client-side-templates.js +++ /dev/null @@ -1,100 +0,0 @@ -if (htmx.version && !htmx.version.startsWith("1.")) { - console.warn("WARNING: You are using an htmx 1 extension with htmx " + htmx.version + - ". It is recommended that you move to the version of this extension found on https://extensions.htmx.org") -} -htmx.defineExtension('client-side-templates', { - transformResponse : function(text, xhr, elt) { - - var mustacheTemplate = htmx.closest(elt, "[mustache-template]"); - if (mustacheTemplate) { - var data = JSON.parse(text); - var templateId = mustacheTemplate.getAttribute('mustache-template'); - var template = htmx.find("#" + templateId); - if (template) { - return Mustache.render(template.innerHTML, data); - } else { - throw "Unknown mustache template: " + templateId; - } - } - - var mustacheArrayTemplate = htmx.closest(elt, "[mustache-array-template]"); - if (mustacheArrayTemplate) { - var data = JSON.parse(text); - var templateId = mustacheArrayTemplate.getAttribute('mustache-array-template'); - var template = htmx.find("#" + templateId); - if (template) { - return Mustache.render(template.innerHTML, {"data": data }); - } else { - throw "Unknown mustache template: " + templateId; - } - } - - var handlebarsTemplate = htmx.closest(elt, "[handlebars-template]"); - if (handlebarsTemplate) { - var data = JSON.parse(text); - var templateId = handlebarsTemplate.getAttribute('handlebars-template'); - var templateElement = htmx.find('#' + templateId).innerHTML; - var renderTemplate = Handlebars.compile(templateElement); - if (renderTemplate) { - return renderTemplate(data); - } else { - throw "Unknown handlebars template: " + templateId; - } - } - - var handlebarsArrayTemplate = htmx.closest(elt, "[handlebars-array-template]"); - if (handlebarsArrayTemplate) { - var data = JSON.parse(text); - var templateId = handlebarsArrayTemplate.getAttribute('handlebars-array-template'); - var templateElement = htmx.find('#' + templateId).innerHTML; - var renderTemplate = Handlebars.compile(templateElement); - if (renderTemplate) { - return renderTemplate(data); - } else { - throw "Unknown handlebars template: " + templateId; - } - } - - var nunjucksTemplate = htmx.closest(elt, "[nunjucks-template]"); - if (nunjucksTemplate) { - var data = JSON.parse(text); - var templateName = nunjucksTemplate.getAttribute('nunjucks-template'); - var template = htmx.find('#' + templateName); - if (template) { - return nunjucks.renderString(template.innerHTML, data); - } else { - return nunjucks.render(templateName, data); - } - } - - var xsltTemplate = htmx.closest(elt, "[xslt-template]"); - if (xsltTemplate) { - var templateId = xsltTemplate.getAttribute('xslt-template'); - var template = htmx.find("#" + templateId); - if (template) { - var content = template.innerHTML ? new DOMParser().parseFromString(template.innerHTML, 'application/xml') - : template.contentDocument; - var processor = new XSLTProcessor(); - processor.importStylesheet(content); - var data = new DOMParser().parseFromString(text, "application/xml"); - var frag = processor.transformToFragment(data, document); - return new XMLSerializer().serializeToString(frag); - } else { - throw "Unknown XSLT template: " + templateId; - } - } - - var nunjucksArrayTemplate = htmx.closest(elt, "[nunjucks-array-template]"); - if (nunjucksArrayTemplate) { - var data = JSON.parse(text); - var templateName = nunjucksArrayTemplate.getAttribute('nunjucks-array-template'); - var template = htmx.find('#' + templateName); - if (template) { - return nunjucks.renderString(template.innerHTML, {"data": data}); - } else { - return nunjucks.render(templateName, {"data": data}); - } - } - return text; - } -}); diff --git a/dist/ext/debug.js b/dist/ext/debug.js deleted file mode 100644 index b8a59a17..00000000 --- a/dist/ext/debug.js +++ /dev/null @@ -1,15 +0,0 @@ -if (htmx.version && !htmx.version.startsWith("1.")) { - console.warn("WARNING: You are using an htmx 1 extension with htmx " + htmx.version + - ". It is recommended that you move to the version of this extension found on https://extensions.htmx.org") -} -htmx.defineExtension('debug', { - onEvent: function (name, evt) { - if (console.debug) { - console.debug(name, evt); - } else if (console) { - console.log("DEBUG:", name, evt); - } else { - throw "NO CONSOLE SUPPORTED" - } - } -}); diff --git a/dist/ext/disable-element.js b/dist/ext/disable-element.js deleted file mode 100644 index b9e25935..00000000 --- a/dist/ext/disable-element.js +++ /dev/null @@ -1,20 +0,0 @@ -if (htmx.version && !htmx.version.startsWith("1.")) { - console.warn("WARNING: You are using an htmx 1 extension with htmx " + htmx.version + - ". It is recommended that you move to the version of this extension found on https://extensions.htmx.org") -} -// Disable Submit Button -htmx.defineExtension('disable-element', { - onEvent: function (name, evt) { - let elt = evt.detail.elt; - let target = elt.getAttribute("hx-disable-element"); - let targetElements = (target == "self") ? [ elt ] : document.querySelectorAll(target); - - for (var i = 0; i < targetElements.length; i++) { - if (name === "htmx:beforeRequest" && targetElements[i]) { - targetElements[i].disabled = true; - } else if (name == "htmx:afterRequest" && targetElements[i]) { - targetElements[i].disabled = false; - } - } - } -}); diff --git a/dist/ext/event-header.js b/dist/ext/event-header.js deleted file mode 100644 index bcc5567c..00000000 --- a/dist/ext/event-header.js +++ /dev/null @@ -1,41 +0,0 @@ -(function(){ - if (htmx.version && !htmx.version.startsWith("1.")) { - console.warn("WARNING: You are using an htmx 1 extension with htmx " + htmx.version + - ". It is recommended that you move to the version of this extension found on https://extensions.htmx.org") - } - function stringifyEvent(event) { - var obj = {}; - for (var key in event) { - obj[key] = event[key]; - } - return JSON.stringify(obj, function(key, value){ - if(value instanceof Node){ - var nodeRep = value.tagName; - if (nodeRep) { - nodeRep = nodeRep.toLowerCase(); - if(value.id){ - nodeRep += "#" + value.id; - } - if(value.classList && value.classList.length){ - nodeRep += "." + value.classList.toString().replace(" ", ".") - } - return nodeRep; - } else { - return "Node" - } - } - if (value instanceof Window) return 'Window'; - return value; - }); - } - - htmx.defineExtension('event-header', { - onEvent: function (name, evt) { - if (name === "htmx:configRequest") { - if (evt.detail.triggeringEvent) { - evt.detail.headers['Triggering-Event'] = stringifyEvent(evt.detail.triggeringEvent); - } - } - } - }); -})(); diff --git a/dist/ext/head-support.js b/dist/ext/head-support.js deleted file mode 100644 index 906ca233..00000000 --- a/dist/ext/head-support.js +++ /dev/null @@ -1,146 +0,0 @@ -//========================================================== -// head-support.js -// -// An extension to htmx 1.0 to add head tag merging. -//========================================================== -(function(){ - - if (htmx.version && !htmx.version.startsWith("1.")) { - console.warn("WARNING: You are using an htmx 1 extension with htmx " + htmx.version + - ". It is recommended that you move to the version of this extension found on https://extensions.htmx.org") - } - - var api = null; - - function log() { - //console.log(arguments); - } - - function mergeHead(newContent, defaultMergeStrategy) { - - if (newContent && newContent.indexOf(' -1) { - const htmlDoc = document.createElement("html"); - // remove svgs to avoid conflicts - var contentWithSvgsRemoved = newContent.replace(/]*>|>)([\s\S]*?)<\/svg>/gim, ''); - // extract head tag - var headTag = contentWithSvgsRemoved.match(/(]*>|>)([\s\S]*?)<\/head>)/im); - - // if the head tag exists... - if (headTag) { - - var added = [] - var removed = [] - var preserved = [] - var nodesToAppend = [] - - htmlDoc.innerHTML = headTag; - var newHeadTag = htmlDoc.querySelector("head"); - var currentHead = document.head; - - if (newHeadTag == null) { - return; - } else { - // put all new head elements into a Map, by their outerHTML - var srcToNewHeadNodes = new Map(); - for (const newHeadChild of newHeadTag.children) { - srcToNewHeadNodes.set(newHeadChild.outerHTML, newHeadChild); - } - } - - - - // determine merge strategy - var mergeStrategy = api.getAttributeValue(newHeadTag, "hx-head") || defaultMergeStrategy; - - // get the current head - for (const currentHeadElt of currentHead.children) { - - // If the current head element is in the map - var inNewContent = srcToNewHeadNodes.has(currentHeadElt.outerHTML); - var isReAppended = currentHeadElt.getAttribute("hx-head") === "re-eval"; - var isPreserved = api.getAttributeValue(currentHeadElt, "hx-preserve") === "true"; - if (inNewContent || isPreserved) { - if (isReAppended) { - // remove the current version and let the new version replace it and re-execute - removed.push(currentHeadElt); - } else { - // this element already exists and should not be re-appended, so remove it from - // the new content map, preserving it in the DOM - srcToNewHeadNodes.delete(currentHeadElt.outerHTML); - preserved.push(currentHeadElt); - } - } else { - if (mergeStrategy === "append") { - // we are appending and this existing element is not new content - // so if and only if it is marked for re-append do we do anything - if (isReAppended) { - removed.push(currentHeadElt); - nodesToAppend.push(currentHeadElt); - } - } else { - // if this is a merge, we remove this content since it is not in the new head - if (api.triggerEvent(document.body, "htmx:removingHeadElement", {headElement: currentHeadElt}) !== false) { - removed.push(currentHeadElt); - } - } - } - } - - // Push the tremaining new head elements in the Map into the - // nodes to append to the head tag - nodesToAppend.push(...srcToNewHeadNodes.values()); - log("to append: ", nodesToAppend); - - for (const newNode of nodesToAppend) { - log("adding: ", newNode); - var newElt = document.createRange().createContextualFragment(newNode.outerHTML); - log(newElt); - if (api.triggerEvent(document.body, "htmx:addingHeadElement", {headElement: newElt}) !== false) { - currentHead.appendChild(newElt); - added.push(newElt); - } - } - - // remove all removed elements, after we have appended the new elements to avoid - // additional network requests for things like style sheets - for (const removedElement of removed) { - if (api.triggerEvent(document.body, "htmx:removingHeadElement", {headElement: removedElement}) !== false) { - currentHead.removeChild(removedElement); - } - } - - api.triggerEvent(document.body, "htmx:afterHeadMerge", {added: added, kept: preserved, removed: removed}); - } - } - } - - htmx.defineExtension("head-support", { - init: function(apiRef) { - // store a reference to the internal API. - api = apiRef; - - htmx.on('htmx:afterSwap', function(evt){ - var serverResponse = evt.detail.xhr.response; - if (api.triggerEvent(document.body, "htmx:beforeHeadMerge", evt.detail)) { - mergeHead(serverResponse, evt.detail.boosted ? "merge" : "append"); - } - }) - - htmx.on('htmx:historyRestore', function(evt){ - if (api.triggerEvent(document.body, "htmx:beforeHeadMerge", evt.detail)) { - if (evt.detail.cacheMiss) { - mergeHead(evt.detail.serverResponse, "merge"); - } else { - mergeHead(evt.detail.item.head, "merge"); - } - } - }) - - htmx.on('htmx:historyItemCreated', function(evt){ - var historyItem = evt.detail.item; - historyItem.head = document.head.outerHTML; - }) - } - }); - -})() diff --git a/dist/ext/include-vals.js b/dist/ext/include-vals.js deleted file mode 100644 index 52ec67fb..00000000 --- a/dist/ext/include-vals.js +++ /dev/null @@ -1,28 +0,0 @@ -(function(){ - if (htmx.version && !htmx.version.startsWith("1.")) { - console.warn("WARNING: You are using an htmx 1 extension with htmx " + htmx.version + - ". It is recommended that you move to the version of this extension found on https://extensions.htmx.org") - } - - function mergeObjects(obj1, obj2) { - for (var key in obj2) { - if (obj2.hasOwnProperty(key)) { - obj1[key] = obj2[key]; - } - } - return obj1; - } - - htmx.defineExtension('include-vals', { - onEvent: function (name, evt) { - if (name === "htmx:configRequest") { - var includeValsElt = htmx.closest(evt.detail.elt, "[include-vals],[data-include-vals]"); - if (includeValsElt) { - var includeVals = includeValsElt.getAttribute("include-vals") || includeValsElt.getAttribute("data-include-vals"); - var valuesToInclude = eval("({" + includeVals + "})"); - mergeObjects(evt.detail.parameters, valuesToInclude); - } - } - } - }); -})(); diff --git a/dist/ext/json-enc.js b/dist/ext/json-enc.js deleted file mode 100644 index 02b1792f..00000000 --- a/dist/ext/json-enc.js +++ /dev/null @@ -1,16 +0,0 @@ -if (htmx.version && !htmx.version.startsWith("1.")) { - console.warn("WARNING: You are using an htmx 1 extension with htmx " + htmx.version + - ". It is recommended that you move to the version of this extension found on https://extensions.htmx.org") -} -htmx.defineExtension('json-enc', { - onEvent: function (name, evt) { - if (name === "htmx:configRequest") { - evt.detail.headers['Content-Type'] = "application/json"; - } - }, - - encodeParameters : function(xhr, parameters, elt) { - xhr.overrideMimeType('text/json'); - return (JSON.stringify(parameters)); - } -}); diff --git a/dist/ext/loading-states.js b/dist/ext/loading-states.js deleted file mode 100644 index b5dfcf0e..00000000 --- a/dist/ext/loading-states.js +++ /dev/null @@ -1,189 +0,0 @@ -;(function () { - - if (htmx.version && !htmx.version.startsWith("1.")) { - console.warn("WARNING: You are using an htmx 1 extension with htmx " + htmx.version + - ". It is recommended that you move to the version of this extension found on https://extensions.htmx.org") - } - - let loadingStatesUndoQueue = [] - - function loadingStateContainer(target) { - return htmx.closest(target, '[data-loading-states]') || document.body - } - - function mayProcessUndoCallback(target, callback) { - if (document.body.contains(target)) { - callback() - } - } - - function mayProcessLoadingStateByPath(elt, requestPath) { - const pathElt = htmx.closest(elt, '[data-loading-path]') - if (!pathElt) { - return true - } - - return pathElt.getAttribute('data-loading-path') === requestPath - } - - function queueLoadingState(sourceElt, targetElt, doCallback, undoCallback) { - const delayElt = htmx.closest(sourceElt, '[data-loading-delay]') - if (delayElt) { - const delayInMilliseconds = - delayElt.getAttribute('data-loading-delay') || 200 - const timeout = setTimeout(function () { - doCallback() - - loadingStatesUndoQueue.push(function () { - mayProcessUndoCallback(targetElt, undoCallback) - }) - }, delayInMilliseconds) - - loadingStatesUndoQueue.push(function () { - mayProcessUndoCallback(targetElt, function () { clearTimeout(timeout) }) - }) - } else { - doCallback() - loadingStatesUndoQueue.push(function () { - mayProcessUndoCallback(targetElt, undoCallback) - }) - } - } - - function getLoadingStateElts(loadingScope, type, path) { - return Array.from(htmx.findAll(loadingScope, "[" + type + "]")).filter( - function (elt) { return mayProcessLoadingStateByPath(elt, path) } - ) - } - - function getLoadingTarget(elt) { - if (elt.getAttribute('data-loading-target')) { - return Array.from( - htmx.findAll(elt.getAttribute('data-loading-target')) - ) - } - return [elt] - } - - htmx.defineExtension('loading-states', { - onEvent: function (name, evt) { - if (name === 'htmx:beforeRequest') { - const container = loadingStateContainer(evt.target) - - const loadingStateTypes = [ - 'data-loading', - 'data-loading-class', - 'data-loading-class-remove', - 'data-loading-disable', - 'data-loading-aria-busy', - ] - - let loadingStateEltsByType = {} - - loadingStateTypes.forEach(function (type) { - loadingStateEltsByType[type] = getLoadingStateElts( - container, - type, - evt.detail.pathInfo.requestPath - ) - }) - - loadingStateEltsByType['data-loading'].forEach(function (sourceElt) { - getLoadingTarget(sourceElt).forEach(function (targetElt) { - queueLoadingState( - sourceElt, - targetElt, - function () { - targetElt.style.display = - sourceElt.getAttribute('data-loading') || - 'inline-block' }, - function () { targetElt.style.display = 'none' } - ) - }) - }) - - loadingStateEltsByType['data-loading-class'].forEach( - function (sourceElt) { - const classNames = sourceElt - .getAttribute('data-loading-class') - .split(' ') - - getLoadingTarget(sourceElt).forEach(function (targetElt) { - queueLoadingState( - sourceElt, - targetElt, - function () { - classNames.forEach(function (className) { - targetElt.classList.add(className) - }) - }, - function() { - classNames.forEach(function (className) { - targetElt.classList.remove(className) - }) - } - ) - }) - } - ) - - loadingStateEltsByType['data-loading-class-remove'].forEach( - function (sourceElt) { - const classNames = sourceElt - .getAttribute('data-loading-class-remove') - .split(' ') - - getLoadingTarget(sourceElt).forEach(function (targetElt) { - queueLoadingState( - sourceElt, - targetElt, - function () { - classNames.forEach(function (className) { - targetElt.classList.remove(className) - }) - }, - function() { - classNames.forEach(function (className) { - targetElt.classList.add(className) - }) - } - ) - }) - } - ) - - loadingStateEltsByType['data-loading-disable'].forEach( - function (sourceElt) { - getLoadingTarget(sourceElt).forEach(function (targetElt) { - queueLoadingState( - sourceElt, - targetElt, - function() { targetElt.disabled = true }, - function() { targetElt.disabled = false } - ) - }) - } - ) - - loadingStateEltsByType['data-loading-aria-busy'].forEach( - function (sourceElt) { - getLoadingTarget(sourceElt).forEach(function (targetElt) { - queueLoadingState( - sourceElt, - targetElt, - function () { targetElt.setAttribute("aria-busy", "true") }, - function () { targetElt.removeAttribute("aria-busy") } - ) - }) - } - ) - } - - if (name === 'htmx:beforeOnLoad') { - while (loadingStatesUndoQueue.length > 0) { - loadingStatesUndoQueue.shift()() - } - } - }, - }) -})() diff --git a/dist/ext/method-override.js b/dist/ext/method-override.js deleted file mode 100644 index cd84d6e5..00000000 --- a/dist/ext/method-override.js +++ /dev/null @@ -1,15 +0,0 @@ -if (htmx.version && !htmx.version.startsWith("1.")) { - console.warn("WARNING: You are using an htmx 1 extension with htmx " + htmx.version + - ". It is recommended that you move to the version of this extension found on https://extensions.htmx.org") -} -htmx.defineExtension('method-override', { - onEvent: function (name, evt) { - if (name === "htmx:configRequest") { - var method = evt.detail.verb; - if (method !== "get" || method !== "post") { - evt.detail.headers['X-HTTP-Method-Override'] = method.toUpperCase(); - evt.detail.verb = "post"; - } - } - } -}); diff --git a/dist/ext/morphdom-swap.js b/dist/ext/morphdom-swap.js deleted file mode 100644 index 13d58adf..00000000 --- a/dist/ext/morphdom-swap.js +++ /dev/null @@ -1,21 +0,0 @@ -if (htmx.version && !htmx.version.startsWith("1.")) { - console.warn("WARNING: You are using an htmx 1 extension with htmx " + htmx.version + - ". It is recommended that you move to the version of this extension found on https://extensions.htmx.org") -} -htmx.defineExtension('morphdom-swap', { - isInlineSwap: function(swapStyle) { - return swapStyle === 'morphdom'; - }, - handleSwap: function (swapStyle, target, fragment) { - if (swapStyle === 'morphdom') { - if (fragment.nodeType === Node.DOCUMENT_FRAGMENT_NODE) { - // IE11 doesn't support DocumentFragment.firstElementChild - morphdom(target, fragment.firstElementChild || fragment.firstChild); - return [target]; - } else { - morphdom(target, fragment.outerHTML); - return [target]; - } - } - } -}); diff --git a/dist/ext/multi-swap.js b/dist/ext/multi-swap.js deleted file mode 100644 index a9435323..00000000 --- a/dist/ext/multi-swap.js +++ /dev/null @@ -1,50 +0,0 @@ -(function () { - - if (htmx.version && !htmx.version.startsWith("1.")) { - console.warn("WARNING: You are using an htmx 1 extension with htmx " + htmx.version + - ". It is recommended that you move to the version of this extension found on https://extensions.htmx.org") - } - - /** @type {import("../htmx").HtmxInternalApi} */ - var api; - - htmx.defineExtension('multi-swap', { - init: function (apiRef) { - api = apiRef; - }, - isInlineSwap: function (swapStyle) { - return swapStyle.indexOf('multi:') === 0; - }, - handleSwap: function (swapStyle, target, fragment, settleInfo) { - if (swapStyle.indexOf('multi:') === 0) { - var selectorToSwapStyle = {}; - var elements = swapStyle.replace(/^multi\s*:\s*/, '').split(/\s*,\s*/); - - elements.map(function (element) { - var split = element.split(/\s*:\s*/); - var elementSelector = split[0]; - var elementSwapStyle = typeof (split[1]) !== "undefined" ? split[1] : "innerHTML"; - - if (elementSelector.charAt(0) !== '#') { - console.error("HTMX multi-swap: unsupported selector '" + elementSelector + "'. Only ID selectors starting with '#' are supported."); - return; - } - - selectorToSwapStyle[elementSelector] = elementSwapStyle; - }); - - for (var selector in selectorToSwapStyle) { - var swapStyle = selectorToSwapStyle[selector]; - var elementToSwap = fragment.querySelector(selector); - if (elementToSwap) { - api.oobSwap(swapStyle, elementToSwap, settleInfo); - } else { - console.warn("HTMX multi-swap: selector '" + selector + "' not found in source content."); - } - } - - return true; - } - } - }); -})(); diff --git a/dist/ext/path-deps.js b/dist/ext/path-deps.js deleted file mode 100644 index 19e8541c..00000000 --- a/dist/ext/path-deps.js +++ /dev/null @@ -1,63 +0,0 @@ -(function(undefined){ - 'use strict'; - if (htmx.version && !htmx.version.startsWith("1.")) { - console.warn("WARNING: You are using an htmx 1 extension with htmx " + htmx.version + - ". It is recommended that you move to the version of this extension found on https://extensions.htmx.org") - } - // Save a reference to the global object (window in the browser) - var _root = this; - - function dependsOn(pathSpec, url) { - if (pathSpec === "ignore") { - return false; - } - var dependencyPath = pathSpec.split("/"); - var urlPath = url.split("/"); - for (var i = 0; i < urlPath.length; i++) { - var dependencyElement = dependencyPath.shift(); - var pathElement = urlPath[i]; - if (dependencyElement !== pathElement && dependencyElement !== "*") { - return false; - } - if (dependencyPath.length === 0 || (dependencyPath.length === 1 && dependencyPath[0] === "")) { - return true; - } - } - return false; - } - - function refreshPath(path) { - var eltsWithDeps = htmx.findAll("[path-deps]"); - for (var i = 0; i < eltsWithDeps.length; i++) { - var elt = eltsWithDeps[i]; - if (dependsOn(elt.getAttribute('path-deps'), path)) { - htmx.trigger(elt, "path-deps"); - } - } - } - - htmx.defineExtension('path-deps', { - onEvent: function (name, evt) { - if (name === "htmx:beforeOnLoad") { - var config = evt.detail.requestConfig; - // mutating call - if (config.verb !== "get" && evt.target.getAttribute('path-deps') !== 'ignore') { - refreshPath(config.path); - } - } - } - }); - - /** - * ******************** - * Expose functionality - * ******************** - */ - - _root.PathDeps = { - refresh: function(path) { - refreshPath(path); - } - }; - -}).call(this); diff --git a/dist/ext/path-params.js b/dist/ext/path-params.js deleted file mode 100644 index 173696e0..00000000 --- a/dist/ext/path-params.js +++ /dev/null @@ -1,15 +0,0 @@ -if (htmx.version && !htmx.version.startsWith("1.")) { - console.warn("WARNING: You are using an htmx 1 extension with htmx " + htmx.version + - ". It is recommended that you move to the version of this extension found on https://extensions.htmx.org") -} -htmx.defineExtension('path-params', { - onEvent: function(name, evt) { - if (name === "htmx:configRequest") { - evt.detail.path = evt.detail.path.replace(/{([^}]+)}/g, function (_, param) { - var val = evt.detail.parameters[param]; - delete evt.detail.parameters[param]; - return val === undefined ? "{" + param + "}" : encodeURIComponent(val); - }) - } - } -}); diff --git a/dist/ext/preload.js b/dist/ext/preload.js deleted file mode 100644 index 74c5a3f7..00000000 --- a/dist/ext/preload.js +++ /dev/null @@ -1,151 +0,0 @@ -if (htmx.version && !htmx.version.startsWith("1.")) { - console.warn("WARNING: You are using an htmx 1 extension with htmx " + htmx.version + - ". It is recommended that you move to the version of this extension found on https://extensions.htmx.org") -} -// This adds the "preload" extension to htmx. By default, this will -// preload the targets of any tags with `href` or `hx-get` attributes -// if they also have a `preload` attribute as well. See documentation -// for more details -htmx.defineExtension("preload", { - - onEvent: function(name, event) { - - // Only take actions on "htmx:afterProcessNode" - if (name !== "htmx:afterProcessNode") { - return; - } - - // SOME HELPER FUNCTIONS WE'LL NEED ALONG THE WAY - - // attr gets the closest non-empty value from the attribute. - var attr = function(node, property) { - if (node == undefined) {return undefined;} - return node.getAttribute(property) || node.getAttribute("data-" + property) || attr(node.parentElement, property) - } - - // load handles the actual HTTP fetch, and uses htmx.ajax in cases where we're - // preloading an htmx resource (this sends the same HTTP headers as a regular htmx request) - var load = function(node) { - - // Called after a successful AJAX request, to mark the - // content as loaded (and prevent additional AJAX calls.) - var done = function(html) { - if (!node.preloadAlways) { - node.preloadState = "DONE" - } - - if (attr(node, "preload-images") == "true") { - document.createElement("div").innerHTML = html // create and populate a node to load linked resources, too. - } - } - - return function() { - - // If this value has already been loaded, then do not try again. - if (node.preloadState !== "READY") { - return; - } - - // Special handling for HX-GET - use built-in htmx.ajax function - // so that headers match other htmx requests, then set - // node.preloadState = TRUE so that requests are not duplicated - // in the future - var hxGet = node.getAttribute("hx-get") || node.getAttribute("data-hx-get") - if (hxGet) { - htmx.ajax("GET", hxGet, { - source: node, - handler:function(elt, info) { - done(info.xhr.responseText); - } - }); - return; - } - - // Otherwise, perform a standard xhr request, then set - // node.preloadState = TRUE so that requests are not duplicated - // in the future. - if (node.getAttribute("href")) { - var r = new XMLHttpRequest(); - r.open("GET", node.getAttribute("href")); - r.onload = function() {done(r.responseText);}; - r.send(); - return; - } - } - } - - // This function processes a specific node and sets up event handlers. - // We'll search for nodes and use it below. - var init = function(node) { - - // If this node DOES NOT include a "GET" transaction, then there's nothing to do here. - if (node.getAttribute("href") + node.getAttribute("hx-get") + node.getAttribute("data-hx-get") == "") { - return; - } - - // Guarantee that we only initialize each node once. - if (node.preloadState !== undefined) { - return; - } - - // Get event name from config. - var on = attr(node, "preload") || "mousedown" - const always = on.indexOf("always") !== -1 - if (always) { - on = on.replace('always', '').trim() - } - - // FALL THROUGH to here means we need to add an EventListener - - // Apply the listener to the node - node.addEventListener(on, function(evt) { - if (node.preloadState === "PAUSE") { // Only add one event listener - node.preloadState = "READY"; // Required for the `load` function to trigger - - // Special handling for "mouseover" events. Wait 100ms before triggering load. - if (on === "mouseover") { - window.setTimeout(load(node), 100); - } else { - load(node)() // all other events trigger immediately. - } - } - }) - - // Special handling for certain built-in event handlers - switch (on) { - - case "mouseover": - // Mirror `touchstart` events (fires immediately) - node.addEventListener("touchstart", load(node)); - - // WHhen the mouse leaves, immediately disable the preload - node.addEventListener("mouseout", function(evt) { - if ((evt.target === node) && (node.preloadState === "READY")) { - node.preloadState = "PAUSE"; - } - }) - break; - - case "mousedown": - // Mirror `touchstart` events (fires immediately) - node.addEventListener("touchstart", load(node)); - break; - } - - // Mark the node as ready to run. - node.preloadState = "PAUSE"; - node.preloadAlways = always; - htmx.trigger(node, "preload:init") // This event can be used to load content immediately. - } - - // Search for all child nodes that have a "preload" attribute - event.target.querySelectorAll("[preload]").forEach(function(node) { - - // Initialize the node with the "preload" attribute - init(node) - - // Initialize all child elements that are anchors or have `hx-get` (use with care) - node.querySelectorAll("a,[hx-get],[data-hx-get]").forEach(init) - }) - } -}) diff --git a/dist/ext/rails-method.js b/dist/ext/rails-method.js deleted file mode 100644 index 4843a346..00000000 --- a/dist/ext/rails-method.js +++ /dev/null @@ -1,14 +0,0 @@ -if (htmx.version && !htmx.version.startsWith("1.")) { - console.warn("WARNING: You are using an htmx 1 extension with htmx " + htmx.version + - ". It is recommended that you move to the version of this extension found on https://extensions.htmx.org") -} -htmx.defineExtension('rails-method', { - onEvent: function (name, evt) { - if (name === "configRequest.htmx") { - var methodOverride = evt.detail.headers['X-HTTP-Method-Override']; - if (methodOverride) { - evt.detail.parameters['_method'] = methodOverride; - } - } - } -}); diff --git a/dist/ext/remove-me.js b/dist/ext/remove-me.js deleted file mode 100644 index 47faf736..00000000 --- a/dist/ext/remove-me.js +++ /dev/null @@ -1,31 +0,0 @@ -(function(){ - if (htmx.version && !htmx.version.startsWith("1.")) { - console.warn("WARNING: You are using an htmx 1 extension with htmx " + htmx.version + - ". It is recommended that you move to the version of this extension found on https://extensions.htmx.org") - } - function maybeRemoveMe(elt) { - var timing = elt.getAttribute("remove-me") || elt.getAttribute("data-remove-me"); - if (timing) { - setTimeout(function () { - elt.parentElement.removeChild(elt); - }, htmx.parseInterval(timing)); - } - } - - htmx.defineExtension('remove-me', { - onEvent: function (name, evt) { - if (name === "htmx:afterProcessNode") { - var elt = evt.detail.elt; - if (elt.getAttribute) { - maybeRemoveMe(elt); - if (elt.querySelectorAll) { - var children = elt.querySelectorAll("[remove-me], [data-remove-me]"); - for (var i = 0; i < children.length; i++) { - maybeRemoveMe(children[i]); - } - } - } - } - } - }); -})(); diff --git a/dist/ext/response-targets.js b/dist/ext/response-targets.js deleted file mode 100644 index a23c1aed..00000000 --- a/dist/ext/response-targets.js +++ /dev/null @@ -1,135 +0,0 @@ -(function(){ - - if (htmx.version && !htmx.version.startsWith("1.")) { - console.warn("WARNING: You are using an htmx 1 extension with htmx " + htmx.version + - ". It is recommended that you move to the version of this extension found on https://extensions.htmx.org") - } - - /** @type {import("../htmx").HtmxInternalApi} */ - var api; - - var attrPrefix = 'hx-target-'; - - // IE11 doesn't support string.startsWith - function startsWith(str, prefix) { - return str.substring(0, prefix.length) === prefix - } - - /** - * @param {HTMLElement} elt - * @param {number} respCode - * @returns {HTMLElement | null} - */ - function getRespCodeTarget(elt, respCodeNumber) { - if (!elt || !respCodeNumber) return null; - - var respCode = respCodeNumber.toString(); - - // '*' is the original syntax, as the obvious character for a wildcard. - // The 'x' alternative was added for maximum compatibility with HTML - // templating engines, due to ambiguity around which characters are - // supported in HTML attributes. - // - // Start with the most specific possible attribute and generalize from - // there. - var attrPossibilities = [ - respCode, - - respCode.substr(0, 2) + '*', - respCode.substr(0, 2) + 'x', - - respCode.substr(0, 1) + '*', - respCode.substr(0, 1) + 'x', - respCode.substr(0, 1) + '**', - respCode.substr(0, 1) + 'xx', - - '*', - 'x', - '***', - 'xxx', - ]; - if (startsWith(respCode, '4') || startsWith(respCode, '5')) { - attrPossibilities.push('error'); - } - - for (var i = 0; i < attrPossibilities.length; i++) { - var attr = attrPrefix + attrPossibilities[i]; - var attrValue = api.getClosestAttributeValue(elt, attr); - if (attrValue) { - if (attrValue === "this") { - return api.findThisElement(elt, attr); - } else { - return api.querySelectorExt(elt, attrValue); - } - } - } - - return null; - } - - /** @param {Event} evt */ - function handleErrorFlag(evt) { - if (evt.detail.isError) { - if (htmx.config.responseTargetUnsetsError) { - evt.detail.isError = false; - } - } else if (htmx.config.responseTargetSetsError) { - evt.detail.isError = true; - } - } - - htmx.defineExtension('response-targets', { - - /** @param {import("../htmx").HtmxInternalApi} apiRef */ - init: function (apiRef) { - api = apiRef; - - if (htmx.config.responseTargetUnsetsError === undefined) { - htmx.config.responseTargetUnsetsError = true; - } - if (htmx.config.responseTargetSetsError === undefined) { - htmx.config.responseTargetSetsError = false; - } - if (htmx.config.responseTargetPrefersExisting === undefined) { - htmx.config.responseTargetPrefersExisting = false; - } - if (htmx.config.responseTargetPrefersRetargetHeader === undefined) { - htmx.config.responseTargetPrefersRetargetHeader = true; - } - }, - - /** - * @param {string} name - * @param {Event} evt - */ - onEvent: function (name, evt) { - if (name === "htmx:beforeSwap" && - evt.detail.xhr && - evt.detail.xhr.status !== 200) { - if (evt.detail.target) { - if (htmx.config.responseTargetPrefersExisting) { - evt.detail.shouldSwap = true; - handleErrorFlag(evt); - return true; - } - if (htmx.config.responseTargetPrefersRetargetHeader && - evt.detail.xhr.getAllResponseHeaders().match(/HX-Retarget:/i)) { - evt.detail.shouldSwap = true; - handleErrorFlag(evt); - return true; - } - } - if (!evt.detail.requestConfig) { - return true; - } - var target = getRespCodeTarget(evt.detail.requestConfig.elt, evt.detail.xhr.status); - if (target) { - handleErrorFlag(evt); - evt.detail.shouldSwap = true; - evt.detail.target = target; - } - return true; - } - } - }); -})(); diff --git a/dist/ext/restored.js b/dist/ext/restored.js deleted file mode 100644 index 13daa343..00000000 --- a/dist/ext/restored.js +++ /dev/null @@ -1,19 +0,0 @@ -if (htmx.version && !htmx.version.startsWith("1.")) { - console.warn("WARNING: You are using an htmx 1 extension with htmx " + htmx.version + - ". It is recommended that you move to the version of this extension found on https://extensions.htmx.org") -} -htmx.defineExtension('restored', { - onEvent : function(name, evt) { - if (name === 'htmx:restored'){ - var restoredElts = evt.detail.document.querySelectorAll( - "[hx-trigger='restored'],[data-hx-trigger='restored']" - ); - // need a better way to do this, would prefer to just trigger from evt.detail.elt - var foundElt = Array.from(restoredElts).find( - (x) => (x.outerHTML === evt.detail.elt.outerHTML) - ); - var restoredEvent = evt.detail.triggerEvent(foundElt, 'restored'); - } - return; - } -}) diff --git a/dist/ext/sse.js b/dist/ext/sse.js deleted file mode 100644 index 5fecef65..00000000 --- a/dist/ext/sse.js +++ /dev/null @@ -1,374 +0,0 @@ -/* -Server Sent Events Extension -============================ -This extension adds support for Server Sent Events to htmx. See /www/extensions/sse.md for usage instructions. - -*/ - -(function() { - - if (htmx.version && !htmx.version.startsWith("1.")) { - console.warn("WARNING: You are using an htmx 1 extension with htmx " + htmx.version + - ". It is recommended that you move to the version of this extension found on https://extensions.htmx.org") - } - - /** @type {import("../htmx").HtmxInternalApi} */ - var api; - - htmx.defineExtension("sse", { - - /** - * Init saves the provided reference to the internal HTMX API. - * - * @param {import("../htmx").HtmxInternalApi} api - * @returns void - */ - init: function(apiRef) { - // store a reference to the internal API. - api = apiRef; - - // set a function in the public API for creating new EventSource objects - if (htmx.createEventSource == undefined) { - htmx.createEventSource = createEventSource; - } - }, - - /** - * onEvent handles all events passed to this extension. - * - * @param {string} name - * @param {Event} evt - * @returns void - */ - onEvent: function(name, evt) { - - var parent = evt.target || evt.detail.elt; - switch (name) { - - case "htmx:beforeCleanupElement": - var internalData = api.getInternalData(parent) - // Try to remove remove an EventSource when elements are removed - if (internalData.sseEventSource) { - internalData.sseEventSource.close(); - } - - return; - - // Try to create EventSources when elements are processed - case "htmx:afterProcessNode": - ensureEventSourceOnElement(parent); - } - } - }); - - /////////////////////////////////////////////// - // HELPER FUNCTIONS - /////////////////////////////////////////////// - - - /** - * createEventSource is the default method for creating new EventSource objects. - * it is hoisted into htmx.config.createEventSource to be overridden by the user, if needed. - * - * @param {string} url - * @returns EventSource - */ - function createEventSource(url) { - return new EventSource(url, { withCredentials: true }); - } - - function splitOnWhitespace(trigger) { - return trigger.trim().split(/\s+/); - } - - function getLegacySSEURL(elt) { - var legacySSEValue = api.getAttributeValue(elt, "hx-sse"); - if (legacySSEValue) { - var values = splitOnWhitespace(legacySSEValue); - for (var i = 0; i < values.length; i++) { - var value = values[i].split(/:(.+)/); - if (value[0] === "connect") { - return value[1]; - } - } - } - } - - function getLegacySSESwaps(elt) { - var legacySSEValue = api.getAttributeValue(elt, "hx-sse"); - var returnArr = []; - if (legacySSEValue != null) { - var values = splitOnWhitespace(legacySSEValue); - for (var i = 0; i < values.length; i++) { - var value = values[i].split(/:(.+)/); - if (value[0] === "swap") { - returnArr.push(value[1]); - } - } - } - return returnArr; - } - - /** - * registerSSE looks for attributes that can contain sse events, right - * now hx-trigger and sse-swap and adds listeners based on these attributes too - * the closest event source - * - * @param {HTMLElement} elt - */ - function registerSSE(elt) { - // Add message handlers for every `sse-swap` attribute - queryAttributeOnThisOrChildren(elt, "sse-swap").forEach(function (child) { - // Find closest existing event source - var sourceElement = api.getClosestMatch(child, hasEventSource); - if (sourceElement == null) { - // api.triggerErrorEvent(elt, "htmx:noSSESourceError") - return null; // no eventsource in parentage, orphaned element - } - - // Set internalData and source - var internalData = api.getInternalData(sourceElement); - var source = internalData.sseEventSource; - - var sseSwapAttr = api.getAttributeValue(child, "sse-swap"); - if (sseSwapAttr) { - var sseEventNames = sseSwapAttr.split(","); - } else { - var sseEventNames = getLegacySSESwaps(child); - } - - for (var i = 0; i < sseEventNames.length; i++) { - var sseEventName = sseEventNames[i].trim(); - var listener = function(event) { - - // If the source is missing then close SSE - if (maybeCloseSSESource(sourceElement)) { - return; - } - - // If the body no longer contains the element, remove the listener - if (!api.bodyContains(child)) { - source.removeEventListener(sseEventName, listener); - return; - } - - // swap the response into the DOM and trigger a notification - if(!api.triggerEvent(elt, "htmx:sseBeforeMessage", event)) { - return; - } - swap(child, event.data); - api.triggerEvent(elt, "htmx:sseMessage", event); - }; - - // Register the new listener - api.getInternalData(child).sseEventListener = listener; - source.addEventListener(sseEventName, listener); - } - }); - - // Add message handlers for every `hx-trigger="sse:*"` attribute - queryAttributeOnThisOrChildren(elt, "hx-trigger").forEach(function(child) { - // Find closest existing event source - var sourceElement = api.getClosestMatch(child, hasEventSource); - if (sourceElement == null) { - // api.triggerErrorEvent(elt, "htmx:noSSESourceError") - return null; // no eventsource in parentage, orphaned element - } - - // Set internalData and source - var internalData = api.getInternalData(sourceElement); - var source = internalData.sseEventSource; - - var sseEventName = api.getAttributeValue(child, "hx-trigger"); - if (sseEventName == null) { - return; - } - - // Only process hx-triggers for events with the "sse:" prefix - if (sseEventName.slice(0, 4) != "sse:") { - return; - } - - // remove the sse: prefix from here on out - sseEventName = sseEventName.substr(4); - - var listener = function() { - if (maybeCloseSSESource(sourceElement)) { - return - } - - if (!api.bodyContains(child)) { - source.removeEventListener(sseEventName, listener); - } - } - }); - } - - /** - * ensureEventSourceOnElement creates a new EventSource connection on the provided element. - * If a usable EventSource already exists, then it is returned. If not, then a new EventSource - * is created and stored in the element's internalData. - * @param {HTMLElement} elt - * @param {number} retryCount - * @returns {EventSource | null} - */ - function ensureEventSourceOnElement(elt, retryCount) { - - if (elt == null) { - return null; - } - - // handle extension source creation attribute - queryAttributeOnThisOrChildren(elt, "sse-connect").forEach(function(child) { - var sseURL = api.getAttributeValue(child, "sse-connect"); - if (sseURL == null) { - return; - } - - ensureEventSource(child, sseURL, retryCount); - }); - - // handle legacy sse, remove for HTMX2 - queryAttributeOnThisOrChildren(elt, "hx-sse").forEach(function(child) { - var sseURL = getLegacySSEURL(child); - if (sseURL == null) { - return; - } - - ensureEventSource(child, sseURL, retryCount); - }); - - registerSSE(elt); - } - - function ensureEventSource(elt, url, retryCount) { - var source = htmx.createEventSource(url); - - source.onerror = function(err) { - - // Log an error event - api.triggerErrorEvent(elt, "htmx:sseError", { error: err, source: source }); - - // If parent no longer exists in the document, then clean up this EventSource - if (maybeCloseSSESource(elt)) { - return; - } - - // Otherwise, try to reconnect the EventSource - if (source.readyState === EventSource.CLOSED) { - retryCount = retryCount || 0; - var timeout = Math.random() * (2 ^ retryCount) * 500; - window.setTimeout(function() { - ensureEventSourceOnElement(elt, Math.min(7, retryCount + 1)); - }, timeout); - } - }; - - source.onopen = function(evt) { - api.triggerEvent(elt, "htmx:sseOpen", { source: source }); - } - - api.getInternalData(elt).sseEventSource = source; - } - - /** - * maybeCloseSSESource confirms that the parent element still exists. - * If not, then any associated SSE source is closed and the function returns true. - * - * @param {HTMLElement} elt - * @returns boolean - */ - function maybeCloseSSESource(elt) { - if (!api.bodyContains(elt)) { - var source = api.getInternalData(elt).sseEventSource; - if (source != undefined) { - source.close(); - // source = null - return true; - } - } - return false; - } - - /** - * queryAttributeOnThisOrChildren returns all nodes that contain the requested attributeName, INCLUDING THE PROVIDED ROOT ELEMENT. - * - * @param {HTMLElement} elt - * @param {string} attributeName - */ - function queryAttributeOnThisOrChildren(elt, attributeName) { - - var result = []; - - // If the parent element also contains the requested attribute, then add it to the results too. - if (api.hasAttribute(elt, attributeName)) { - result.push(elt); - } - - // Search all child nodes that match the requested attribute - elt.querySelectorAll("[" + attributeName + "], [data-" + attributeName + "]").forEach(function(node) { - result.push(node); - }); - - return result; - } - - /** - * @param {HTMLElement} elt - * @param {string} content - */ - function swap(elt, content) { - - api.withExtensions(elt, function(extension) { - content = extension.transformResponse(content, null, elt); - }); - - var swapSpec = api.getSwapSpecification(elt); - var target = api.getTarget(elt); - var settleInfo = api.makeSettleInfo(elt); - - api.selectAndSwap(swapSpec.swapStyle, target, elt, content, settleInfo); - - settleInfo.elts.forEach(function(elt) { - if (elt.classList) { - elt.classList.add(htmx.config.settlingClass); - } - api.triggerEvent(elt, 'htmx:beforeSettle'); - }); - - // Handle settle tasks (with delay if requested) - if (swapSpec.settleDelay > 0) { - setTimeout(doSettle(settleInfo), swapSpec.settleDelay); - } else { - doSettle(settleInfo)(); - } - } - - /** - * doSettle mirrors much of the functionality in htmx that - * settles elements after their content has been swapped. - * TODO: this should be published by htmx, and not duplicated here - * @param {import("../htmx").HtmxSettleInfo} settleInfo - * @returns () => void - */ - function doSettle(settleInfo) { - - return function() { - settleInfo.tasks.forEach(function(task) { - task.call(); - }); - - settleInfo.elts.forEach(function(elt) { - if (elt.classList) { - elt.classList.remove(htmx.config.settlingClass); - } - api.triggerEvent(elt, 'htmx:afterSettle'); - }); - } - } - - function hasEventSource(node) { - return api.getInternalData(node).sseEventSource != null; - } - -})(); diff --git a/dist/ext/ws.js b/dist/ext/ws.js deleted file mode 100644 index 8488b18b..00000000 --- a/dist/ext/ws.js +++ /dev/null @@ -1,481 +0,0 @@ -/* -WebSockets Extension -============================ -This extension adds support for WebSockets to htmx. See /www/extensions/ws.md for usage instructions. -*/ - -(function () { - - if (htmx.version && !htmx.version.startsWith("1.")) { - console.warn("WARNING: You are using an htmx 1 extension with htmx " + htmx.version + - ". It is recommended that you move to the version of this extension found on https://extensions.htmx.org") - } - - /** @type {import("../htmx").HtmxInternalApi} */ - var api; - - htmx.defineExtension("ws", { - - /** - * init is called once, when this extension is first registered. - * @param {import("../htmx").HtmxInternalApi} apiRef - */ - init: function (apiRef) { - - // Store reference to internal API - api = apiRef; - - // Default function for creating new EventSource objects - if (!htmx.createWebSocket) { - htmx.createWebSocket = createWebSocket; - } - - // Default setting for reconnect delay - if (!htmx.config.wsReconnectDelay) { - htmx.config.wsReconnectDelay = "full-jitter"; - } - }, - - /** - * onEvent handles all events passed to this extension. - * - * @param {string} name - * @param {Event} evt - */ - onEvent: function (name, evt) { - var parent = evt.target || evt.detail.elt; - - switch (name) { - - // Try to close the socket when elements are removed - case "htmx:beforeCleanupElement": - - var internalData = api.getInternalData(parent) - - if (internalData.webSocket) { - internalData.webSocket.close(); - } - return; - - // Try to create websockets when elements are processed - case "htmx:beforeProcessNode": - forEach(queryAttributeOnThisOrChildren(parent, "ws-connect"), function (child) { - ensureWebSocket(child) - }); - forEach(queryAttributeOnThisOrChildren(parent, "ws-send"), function (child) { - ensureWebSocketSend(child) - }); - } - } - }); - - function splitOnWhitespace(trigger) { - return trigger.trim().split(/\s+/); - } - - function getLegacyWebsocketURL(elt) { - var legacySSEValue = api.getAttributeValue(elt, "hx-ws"); - if (legacySSEValue) { - var values = splitOnWhitespace(legacySSEValue); - for (var i = 0; i < values.length; i++) { - var value = values[i].split(/:(.+)/); - if (value[0] === "connect") { - return value[1]; - } - } - } - } - - /** - * ensureWebSocket creates a new WebSocket on the designated element, using - * the element's "ws-connect" attribute. - * @param {HTMLElement} socketElt - * @returns - */ - function ensureWebSocket(socketElt) { - - // If the element containing the WebSocket connection no longer exists, then - // do not connect/reconnect the WebSocket. - if (!api.bodyContains(socketElt)) { - return; - } - - // Get the source straight from the element's value - var wssSource = api.getAttributeValue(socketElt, "ws-connect") - - if (wssSource == null || wssSource === "") { - var legacySource = getLegacyWebsocketURL(socketElt); - if (legacySource == null) { - return; - } else { - wssSource = legacySource; - } - } - - // Guarantee that the wssSource value is a fully qualified URL - if (wssSource.indexOf("/") === 0) { - var base_part = location.hostname + (location.port ? ':' + location.port : ''); - if (location.protocol === 'https:') { - wssSource = "wss://" + base_part + wssSource; - } else if (location.protocol === 'http:') { - wssSource = "ws://" + base_part + wssSource; - } - } - - var socketWrapper = createWebsocketWrapper(socketElt, function () { - return htmx.createWebSocket(wssSource) - }); - - socketWrapper.addEventListener('message', function (event) { - if (maybeCloseWebSocketSource(socketElt)) { - return; - } - - var response = event.data; - if (!api.triggerEvent(socketElt, "htmx:wsBeforeMessage", { - message: response, - socketWrapper: socketWrapper.publicInterface - })) { - return; - } - - api.withExtensions(socketElt, function (extension) { - response = extension.transformResponse(response, null, socketElt); - }); - - var settleInfo = api.makeSettleInfo(socketElt); - var fragment = api.makeFragment(response); - - if (fragment.children.length) { - var children = Array.from(fragment.children); - for (var i = 0; i < children.length; i++) { - api.oobSwap(api.getAttributeValue(children[i], "hx-swap-oob") || "true", children[i], settleInfo); - } - } - - api.settleImmediately(settleInfo.tasks); - api.triggerEvent(socketElt, "htmx:wsAfterMessage", { message: response, socketWrapper: socketWrapper.publicInterface }) - }); - - // Put the WebSocket into the HTML Element's custom data. - api.getInternalData(socketElt).webSocket = socketWrapper; - } - - /** - * @typedef {Object} WebSocketWrapper - * @property {WebSocket} socket - * @property {Array<{message: string, sendElt: Element}>} messageQueue - * @property {number} retryCount - * @property {(message: string, sendElt: Element) => void} sendImmediately sendImmediately sends message regardless of websocket connection state - * @property {(message: string, sendElt: Element) => void} send - * @property {(event: string, handler: Function) => void} addEventListener - * @property {() => void} handleQueuedMessages - * @property {() => void} init - * @property {() => void} close - */ - /** - * - * @param socketElt - * @param socketFunc - * @returns {WebSocketWrapper} - */ - function createWebsocketWrapper(socketElt, socketFunc) { - var wrapper = { - socket: null, - messageQueue: [], - retryCount: 0, - - /** @type {Object} */ - events: {}, - - addEventListener: function (event, handler) { - if (this.socket) { - this.socket.addEventListener(event, handler); - } - - if (!this.events[event]) { - this.events[event] = []; - } - - this.events[event].push(handler); - }, - - sendImmediately: function (message, sendElt) { - if (!this.socket) { - api.triggerErrorEvent() - } - if (!sendElt || api.triggerEvent(sendElt, 'htmx:wsBeforeSend', { - message: message, - socketWrapper: this.publicInterface - })) { - this.socket.send(message); - sendElt && api.triggerEvent(sendElt, 'htmx:wsAfterSend', { - message: message, - socketWrapper: this.publicInterface - }) - } - }, - - send: function (message, sendElt) { - if (this.socket.readyState !== this.socket.OPEN) { - this.messageQueue.push({ message: message, sendElt: sendElt }); - } else { - this.sendImmediately(message, sendElt); - } - }, - - handleQueuedMessages: function () { - while (this.messageQueue.length > 0) { - var queuedItem = this.messageQueue[0] - if (this.socket.readyState === this.socket.OPEN) { - this.sendImmediately(queuedItem.message, queuedItem.sendElt); - this.messageQueue.shift(); - } else { - break; - } - } - }, - - init: function () { - if (this.socket && this.socket.readyState === this.socket.OPEN) { - // Close discarded socket - this.socket.close() - } - - // Create a new WebSocket and event handlers - /** @type {WebSocket} */ - var socket = socketFunc(); - - // The event.type detail is added for interface conformance with the - // other two lifecycle events (open and close) so a single handler method - // can handle them polymorphically, if required. - api.triggerEvent(socketElt, "htmx:wsConnecting", { event: { type: 'connecting' } }); - - this.socket = socket; - - socket.onopen = function (e) { - wrapper.retryCount = 0; - api.triggerEvent(socketElt, "htmx:wsOpen", { event: e, socketWrapper: wrapper.publicInterface }); - wrapper.handleQueuedMessages(); - } - - socket.onclose = function (e) { - // If socket should not be connected, stop further attempts to establish connection - // If Abnormal Closure/Service Restart/Try Again Later, then set a timer to reconnect after a pause. - if (!maybeCloseWebSocketSource(socketElt) && [1006, 1012, 1013].indexOf(e.code) >= 0) { - var delay = getWebSocketReconnectDelay(wrapper.retryCount); - setTimeout(function () { - wrapper.retryCount += 1; - wrapper.init(); - }, delay); - } - - // Notify client code that connection has been closed. Client code can inspect `event` field - // to determine whether closure has been valid or abnormal - api.triggerEvent(socketElt, "htmx:wsClose", { event: e, socketWrapper: wrapper.publicInterface }) - }; - - socket.onerror = function (e) { - api.triggerErrorEvent(socketElt, "htmx:wsError", { error: e, socketWrapper: wrapper }); - maybeCloseWebSocketSource(socketElt); - }; - - var events = this.events; - Object.keys(events).forEach(function (k) { - events[k].forEach(function (e) { - socket.addEventListener(k, e); - }) - }); - }, - - close: function () { - this.socket.close() - } - } - - wrapper.init(); - - wrapper.publicInterface = { - send: wrapper.send.bind(wrapper), - sendImmediately: wrapper.sendImmediately.bind(wrapper), - queue: wrapper.messageQueue - }; - - return wrapper; - } - - /** - * ensureWebSocketSend attaches trigger handles to elements with - * "ws-send" attribute - * @param {HTMLElement} elt - */ - function ensureWebSocketSend(elt) { - var legacyAttribute = api.getAttributeValue(elt, "hx-ws"); - if (legacyAttribute && legacyAttribute !== 'send') { - return; - } - - var webSocketParent = api.getClosestMatch(elt, hasWebSocket) - processWebSocketSend(webSocketParent, elt); - } - - /** - * hasWebSocket function checks if a node has webSocket instance attached - * @param {HTMLElement} node - * @returns {boolean} - */ - function hasWebSocket(node) { - return api.getInternalData(node).webSocket != null; - } - - /** - * processWebSocketSend adds event listeners to the
element so that - * messages can be sent to the WebSocket server when the form is submitted. - * @param {HTMLElement} socketElt - * @param {HTMLElement} sendElt - */ - function processWebSocketSend(socketElt, sendElt) { - var nodeData = api.getInternalData(sendElt); - var triggerSpecs = api.getTriggerSpecs(sendElt); - triggerSpecs.forEach(function (ts) { - api.addTriggerHandler(sendElt, ts, nodeData, function (elt, evt) { - if (maybeCloseWebSocketSource(socketElt)) { - return; - } - - /** @type {WebSocketWrapper} */ - var socketWrapper = api.getInternalData(socketElt).webSocket; - var headers = api.getHeaders(sendElt, api.getTarget(sendElt)); - var results = api.getInputValues(sendElt, 'post'); - var errors = results.errors; - var rawParameters = results.values; - var expressionVars = api.getExpressionVars(sendElt); - var allParameters = api.mergeObjects(rawParameters, expressionVars); - var filteredParameters = api.filterValues(allParameters, sendElt); - - var sendConfig = { - parameters: filteredParameters, - unfilteredParameters: allParameters, - headers: headers, - errors: errors, - - triggeringEvent: evt, - messageBody: undefined, - socketWrapper: socketWrapper.publicInterface - }; - - if (!api.triggerEvent(elt, 'htmx:wsConfigSend', sendConfig)) { - return; - } - - if (errors && errors.length > 0) { - api.triggerEvent(elt, 'htmx:validation:halted', errors); - return; - } - - var body = sendConfig.messageBody; - if (body === undefined) { - var toSend = Object.assign({}, sendConfig.parameters); - if (sendConfig.headers) - toSend['HEADERS'] = headers; - body = JSON.stringify(toSend); - } - - socketWrapper.send(body, elt); - - if (evt && api.shouldCancel(evt, elt)) { - evt.preventDefault(); - } - }); - }); - } - - /** - * getWebSocketReconnectDelay is the default easing function for WebSocket reconnects. - * @param {number} retryCount // The number of retries that have already taken place - * @returns {number} - */ - function getWebSocketReconnectDelay(retryCount) { - - /** @type {"full-jitter" | ((retryCount:number) => number)} */ - var delay = htmx.config.wsReconnectDelay; - if (typeof delay === 'function') { - return delay(retryCount); - } - if (delay === 'full-jitter') { - var exp = Math.min(retryCount, 6); - var maxDelay = 1000 * Math.pow(2, exp); - return maxDelay * Math.random(); - } - - logError('htmx.config.wsReconnectDelay must either be a function or the string "full-jitter"'); - } - - /** - * maybeCloseWebSocketSource checks to the if the element that created the WebSocket - * still exists in the DOM. If NOT, then the WebSocket is closed and this function - * returns TRUE. If the element DOES EXIST, then no action is taken, and this function - * returns FALSE. - * - * @param {*} elt - * @returns - */ - function maybeCloseWebSocketSource(elt) { - if (!api.bodyContains(elt)) { - api.getInternalData(elt).webSocket.close(); - return true; - } - return false; - } - - /** - * createWebSocket is the default method for creating new WebSocket objects. - * it is hoisted into htmx.createWebSocket to be overridden by the user, if needed. - * - * @param {string} url - * @returns WebSocket - */ - function createWebSocket(url) { - var sock = new WebSocket(url, []); - sock.binaryType = htmx.config.wsBinaryType; - return sock; - } - - /** - * queryAttributeOnThisOrChildren returns all nodes that contain the requested attributeName, INCLUDING THE PROVIDED ROOT ELEMENT. - * - * @param {HTMLElement} elt - * @param {string} attributeName - */ - function queryAttributeOnThisOrChildren(elt, attributeName) { - - var result = [] - - // If the parent element also contains the requested attribute, then add it to the results too. - if (api.hasAttribute(elt, attributeName) || api.hasAttribute(elt, "hx-ws")) { - result.push(elt); - } - - // Search all child nodes that match the requested attribute - elt.querySelectorAll("[" + attributeName + "], [data-" + attributeName + "], [data-hx-ws], [hx-ws]").forEach(function (node) { - result.push(node) - }) - - return result - } - - /** - * @template T - * @param {T[]} arr - * @param {(T) => void} func - */ - function forEach(arr, func) { - if (arr) { - for (var i = 0; i < arr.length; i++) { - func(arr[i]); - } - } - } - -})(); - diff --git a/dist/htmx.amd.js b/dist/htmx.amd.js index ccc3a16b..750a5556 100644 --- a/dist/htmx.amd.js +++ b/dist/htmx.amd.js @@ -3737,7 +3737,7 @@ var htmx = (function() { * @returns {FormData} */ function getExpressionVars(elt) { - return formDataFromObject(mergeObjects(getHXVarsForElement(elt), getHXValsForElement(elt))) + return mergeObjects(getHXVarsForElement(elt), getHXValsForElement(elt)) } /** @@ -4169,7 +4169,7 @@ var htmx = (function() { if (etc.values) { overrideFormData(rawFormData, formDataFromObject(etc.values)) } - const expressionVars = getExpressionVars(elt) + const expressionVars = formDataFromObject(getExpressionVars(elt)) const allFormData = overrideFormData(rawFormData, expressionVars) let filteredFormData = filterValues(allFormData, elt) diff --git a/dist/htmx.cjs.js b/dist/htmx.cjs.js index 81cd8773..53f03986 100644 --- a/dist/htmx.cjs.js +++ b/dist/htmx.cjs.js @@ -3736,7 +3736,7 @@ var htmx = (function() { * @returns {FormData} */ function getExpressionVars(elt) { - return formDataFromObject(mergeObjects(getHXVarsForElement(elt), getHXValsForElement(elt))) + return mergeObjects(getHXVarsForElement(elt), getHXValsForElement(elt)) } /** @@ -4168,7 +4168,7 @@ var htmx = (function() { if (etc.values) { overrideFormData(rawFormData, formDataFromObject(etc.values)) } - const expressionVars = getExpressionVars(elt) + const expressionVars = formDataFromObject(getExpressionVars(elt)) const allFormData = overrideFormData(rawFormData, expressionVars) let filteredFormData = filterValues(allFormData, elt) diff --git a/dist/htmx.esm.js b/dist/htmx.esm.js index c72452eb..ac5b23db 100644 --- a/dist/htmx.esm.js +++ b/dist/htmx.esm.js @@ -3736,7 +3736,7 @@ var htmx = (function() { * @returns {FormData} */ function getExpressionVars(elt) { - return formDataFromObject(mergeObjects(getHXVarsForElement(elt), getHXValsForElement(elt))) + return mergeObjects(getHXVarsForElement(elt), getHXValsForElement(elt)) } /** @@ -4168,7 +4168,7 @@ var htmx = (function() { if (etc.values) { overrideFormData(rawFormData, formDataFromObject(etc.values)) } - const expressionVars = getExpressionVars(elt) + const expressionVars = formDataFromObject(getExpressionVars(elt)) const allFormData = overrideFormData(rawFormData, expressionVars) let filteredFormData = filterValues(allFormData, elt) diff --git a/dist/htmx.js b/dist/htmx.js index b5b4f24e..a24926aa 100644 --- a/dist/htmx.js +++ b/dist/htmx.js @@ -3736,7 +3736,7 @@ var htmx = (function() { * @returns {FormData} */ function getExpressionVars(elt) { - return formDataFromObject(mergeObjects(getHXVarsForElement(elt), getHXValsForElement(elt))) + return mergeObjects(getHXVarsForElement(elt), getHXValsForElement(elt)) } /** @@ -4168,7 +4168,7 @@ var htmx = (function() { if (etc.values) { overrideFormData(rawFormData, formDataFromObject(etc.values)) } - const expressionVars = getExpressionVars(elt) + const expressionVars = formDataFromObject(getExpressionVars(elt)) const allFormData = overrideFormData(rawFormData, expressionVars) let filteredFormData = filterValues(allFormData, elt) diff --git a/dist/htmx.min.js b/dist/htmx.min.js index 61cbf1b5..d01b6f11 100644 --- a/dist/htmx.min.js +++ b/dist/htmx.min.js @@ -1 +1 @@ -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=sn(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:"",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},parseInterval:null,_:null,version:"2.0a"};Q.onLoad=z;Q.process=It;Q.on=be;Q.off=we;Q.trigger=he;Q.ajax=Cn;Q.find=r;Q.findAll=p;Q.closest=g;Q.remove=K;Q.addClass=W;Q.removeClass=o;Q.toggleClass=Y;Q.takeClass=ge;Q.swap=$e;Q.defineExtension=Mn;Q.removeExtension=Xn;Q.logAll=$;Q.logNone=J;Q.parseInterval=d;Q._=_;const n={addTriggerHandler:St,bodyContains:le,canAccessLocalStorage:V,findThisElement:Ee,filterValues:fn,swap:$e,hasAttribute:s,getAttributeValue:te,getClosestAttributeValue:re,getClosestMatch:T,getExpressionVars:vn,getHeaders:cn,getInputValues:sn,getInternalData:ie,getSwapSpecification:hn,getTriggerSpecs:lt,getTarget:Ce,makeFragment:D,mergeObjects:ue,makeSettleInfo:pn,oobSwap:Te,querySelectorExt:fe,settleImmediately:$t,shouldCancel:ht,triggerEvent:he,triggerErrorEvent:ae,withExtensions:Mt};const v=["get","post","put","delete","patch"];const R=v.map(function(e){return"[hx-"+e+"], [data-hx-"+e+"]"}).join(", ");const O=e("head");function e(e,t=false){return new RegExp(`<${e}(\\s[^>]*>|>)([\\s\\S]*?)<\\/${e}>`,t?"gim":"im")}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 te(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 ne(){return document}function H(e,t){return e.getRootNode?e.getRootNode({composed:t}):ne()}function T(e,t){while(e&&!t(e)){e=u(e)}return e||null}function q(e,t,n){const r=te(t,n);const o=te(t,"hx-disinherit");var i=te(t,"hx-inherit");if(e!==t){if(Q.config.disableInheritance){if(i&&(i==="*"||i.split(" ").indexOf(n)>=0)){return r}else{return null}}if(o&&(o==="*"||o.split(" ").indexOf(n)>=0)){return"unset"}}return r}function re(t,n){let r=null;T(t,function(e){return!!(r=q(t,ce(e),n))});if(r!=="unset"){return r}}function a(e,t){const n=e instanceof Element&&(e.matches||e.matchesSelector||e.msMatchesSelector||e.mozMatchesSelector||e.webkitMatchesSelector||e.oMatchesSelector);return!!n&&n.call(e,t)}function L(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 A(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 I(e){const t=ne().createElement("script");se(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 P(e){return e.matches("script")&&(e.type==="text/javascript"||e.type==="module"||e.type==="")}function k(e){Array.from(e.querySelectorAll("script")).forEach(e=>{if(P(e)){const t=I(e);const n=e.parentNode;try{n.insertBefore(t,e)}catch(e){w(e)}finally{e.remove()}}})}function D(e){const t=e.replace(O,"");const n=L(t);let r;if(n==="html"){r=new DocumentFragment;const i=A(e);N(r,i.body);r.title=i.title}else if(n==="body"){r=new DocumentFragment;const i=A(t);N(r,i.body);r.title=i.title}else{const i=A('");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){k(r)}else{r.querySelectorAll("script").forEach(e=>e.remove())}}return r}function oe(e){if(e){e()}}function t(e,t){return Object.prototype.toString.call(e)==="[object "+t+"]"}function M(e){return typeof e==="function"}function X(e){return t(e,"Object")}function ie(e){const t="htmx-internal-data";let n=e[t];if(!n){n=e[t]={}}return n}function F(t){const n=[];if(t){for(let e=0;e=0}function le(e){const t=e.getRootNode&&e.getRootNode();if(t&&t instanceof window.ShadowRoot){return ne().body.contains(t.host)}else{return ne().body.contains(e)}}function B(e){return e.trim().split(/\s+/)}function ue(e,t){for(const n in t){if(t.hasOwnProperty(n)){e[n]=t[n]}}return e}function S(e){try{return JSON.parse(e)}catch(e){w(e);return null}}function V(){const e="htmx:localStorageTest";try{localStorage.setItem(e,e);localStorage.removeItem(e);return true}catch(e){return false}}function j(t){try{const e=new URL(t);if(e){t=e.pathname+e.search}if(!/^\/$/.test(t)){t=t.replace(/\/+$/,"")}return t}catch(e){return t}}function _(e){return yn(ne().body,function(){return eval(e)})}function z(t){const e=Q.on("htmx:load",function(e){t(e.detail.elt)});return e}function $(){Q.logger=function(e,t,n){if(console){console.log(t,e,n)}}}function J(){Q.logger=null}function r(e,t){if(typeof e!=="string"){return e.querySelector(t)}else{return r(ne(),e)}}function p(e,t){if(typeof e!=="string"){return e.querySelectorAll(t)}else{return p(ne(),e)}}function E(){return window}function K(e,t){e=x(e);if(t){E().setTimeout(function(){K(e);e=null},t)}else{u(e).removeChild(e)}}function ce(e){return e instanceof Element?e:null}function G(e){return e instanceof HTMLElement?e:null}function Z(e){return typeof e==="string"?e:null}function h(e){return e instanceof Element||e instanceof Document||e instanceof DocumentFragment?e:null}function W(e,t,n){e=ce(x(e));if(!e){return}if(n){E().setTimeout(function(){W(e,t);e=null},n)}else{e.classList&&e.classList.add(t)}}function o(e,t,n){let r=ce(x(e));if(!r){return}if(n){E().setTimeout(function(){o(r,t);r=null},n)}else{if(r.classList){r.classList.remove(t);if(r.classList.length===0){r.removeAttribute("class")}}}}function Y(e,t){e=x(e);e.classList.toggle(t)}function ge(e,t){e=x(e);se(e.parentElement.children,function(e){o(e,t)});W(ce(e),t)}function g(e,t){e=ce(x(e));if(e&&e.closest){return e.closest(t)}else{do{if(e==null||a(e,t)){return e}}while(e=e&&ce(u(e)));return null}}function l(e,t){return e.substring(0,t.length)===t}function pe(e,t){return e.substring(e.length-t.length)===t}function i(e){const t=e.trim();if(l(t,"<")&&pe(t,"/>")){return t.substring(1,t.length-2)}else{return t}}function m(e,t,n){e=x(e);if(t.indexOf("closest ")===0){return[g(ce(e),i(t.substr(8)))]}else if(t.indexOf("find ")===0){return[r(h(e),i(t.substr(5)))]}else if(t==="next"){return[ce(e).nextElementSibling]}else if(t.indexOf("next ")===0){return[me(e,i(t.substr(5)),!!n)]}else if(t==="previous"){return[ce(e).previousElementSibling]}else if(t.indexOf("previous ")===0){return[xe(e,i(t.substr(9)),!!n)]}else if(t==="document"){return[document]}else if(t==="window"){return[window]}else if(t==="body"){return[document.body]}else if(t==="root"){return[H(e,!!n)]}else if(t.indexOf("global ")===0){return m(e,t.slice(7),true)}else{return F(h(H(e,!!n)).querySelectorAll(i(t)))}}var me=function(t,e,n){const r=h(H(t,n)).querySelectorAll(e);for(let e=0;e=0;e--){const o=r[e];if(o.compareDocumentPosition(t)===Node.DOCUMENT_POSITION_FOLLOWING){return o}}};function fe(e,t){if(typeof e!=="string"){return m(e,t)[0]}else{return m(ne().body,e)[0]}}function x(e,t){if(typeof e==="string"){return r(h(t)||document,e)}else{return e}}function ye(e,t,n){if(M(t)){return{target:ne().body,event:Z(e),listener:t}}else{return{target:x(e),event:Z(t),listener:n}}}function be(t,n,r){Bn(function(){const e=ye(t,n,r);e.target.addEventListener(e.event,e.listener)});const e=M(n);return e?n:r}function we(t,n,r){Bn(function(){const e=ye(t,n,r);e.target.removeEventListener(e.event,e.listener)});return M(n)?n:r}const ve=ne().createElement("output");function Se(e,t){const n=re(e,t);if(n){if(n==="this"){return[Ee(e,t)]}else{const r=m(e,n);if(r.length===0){w('The selector "'+n+'" on '+t+" returned no matches!");return[ve]}else{return r}}}}function Ee(e,t){return ce(T(e,function(e){return te(ce(e),t)!=null}))}function Ce(e){const t=re(e,"hx-target");if(t){if(t==="this"){return Ee(e,"hx-target")}else{return fe(e,t)}}else{const n=ie(e);if(n.boosted){return ne().body}else{return e}}}function Re(t){const n=Q.config.attributesToSettle;for(let e=0;e0){s=e.substr(0,e.indexOf(":"));t=e.substr(e.indexOf(":")+1,e.length)}else{s=e}const n=ne().querySelectorAll(t);if(n){se(n,function(e){let t;const n=o.cloneNode(true);t=ne().createDocumentFragment();t.appendChild(n);if(!He(s,e)){t=h(n)}const r={shouldSwap:true,target:e,fragment:t};if(!he(e,"htmx:oobBeforeSwap",r))return;e=r.target;if(r.shouldSwap){_e(s,e,e,t,i)}se(i.elts,function(e){he(e,"htmx:oobAfterSwap",r)})});o.parentNode.removeChild(o)}else{o.parentNode.removeChild(o);ae(ne().body,"htmx:oobErrorNoTarget",{content:o})}return e}function qe(e){se(p(e,"[hx-preserve], [data-hx-preserve]"),function(e){const t=te(e,"id");const n=ne().getElementById(t);if(n!=null){e.parentNode.replaceChild(n,e)}})}function Le(l,e,u){se(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=h(l);const i=e&&e.querySelector(o+"[id='"+r+"']");if(i&&i!==e){const s=t.cloneNode();Oe(t,i);u.tasks.push(function(){Oe(t,s)})}}})}function Ae(e){return function(){o(e,Q.config.addedClass);It(ce(e));Ne(h(e));he(e,"htmx:load")}}function Ne(e){const t="[autofocus]";const n=G(a(e,t)?e:e.querySelector(t));if(n!=null){n.focus()}}function c(e,t,n,r){Le(e,n,r);while(n.childNodes.length>0){const o=n.firstChild;W(ce(o),Q.config.addedClass);e.insertBefore(o,t);if(o.nodeType!==Node.TEXT_NODE&&o.nodeType!==Node.COMMENT_NODE){r.tasks.push(Ae(o))}}}function Ie(e,t){let n=0;while(n0){E().setTimeout(l,r.settleDelay)}else{l()}}function Je(e,t,n){const r=e.getResponseHeader(t);if(r.indexOf("{")===0){const o=S(r);for(const i in o){if(o.hasOwnProperty(i)){let e=o[i];if(!X(e)){e={value:e}}he(n,i,e)}}}else{const s=r.split(",");for(let e=0;e0){const s=o[0];if(s==="]"){e--;if(e===0){if(n===null){t=t+"true"}o.shift();t+=")})";try{const l=yn(r,function(){return Function(t)()},function(){return true});l.source=t;return l}catch(e){ae(ne().body,"htmx:syntax:error",{error:e,source:t});return null}}}else if(s==="["){e++}if(nt(s,n,i)){t+="(("+i+"."+s+") ? ("+i+"."+s+") : (window."+s+"))"}else{t=t+s}n=o.shift()}}}function b(e,t){let n="";while(e.length>0&&!t.test(e[0])){n+=e.shift()}return n}function ot(e){let t;if(e.length>0&&Qe.test(e[0])){e.shift();t=b(e,et).trim();e.shift()}else{t=b(e,y)}return t}const it="input, textarea, select";function st(e,t,n){const r=[];const o=tt(t);do{b(o,Ye);const l=o.length;const u=b(o,/[,\[\s]/);if(u!==""){if(u==="every"){const c={trigger:"every"};b(o,Ye);c.pollInterval=d(b(o,/[,\[\s]/));b(o,Ye);var i=rt(e,o,"event");if(i){c.eventFilter=i}r.push(c)}else{const f={trigger:u};var i=rt(e,o,"event");if(i){f.eventFilter=i}while(o.length>0&&o[0]!==","){b(o,Ye);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(b(o,y))}else if(a==="from"&&o[0]===":"){o.shift();if(Qe.test(o[0])){var s=ot(o)}else{var s=b(o,y);if(s==="closest"||s==="find"||s==="next"||s==="previous"){o.shift();const h=ot(o);if(h.length>0){s+=" "+h}}}f.from=s}else if(a==="target"&&o[0]===":"){o.shift();f.target=ot(o)}else if(a==="throttle"&&o[0]===":"){o.shift();f.throttle=d(b(o,y))}else if(a==="queue"&&o[0]===":"){o.shift();f.queue=b(o,y)}else if(a==="root"&&o[0]===":"){o.shift();f[a]=ot(o)}else if(a==="threshold"&&o[0]===":"){o.shift();f[a]=b(o,y)}else{ae(e,"htmx:syntax:error",{token:o.shift()})}}r.push(f)}}if(o.length===l){ae(e,"htmx:syntax:error",{token:o.shift()})}b(o,Ye)}while(o[0]===","&&o.shift());if(n){n[t]=r}return r}function lt(e){const t=te(e,"hx-trigger");let n=[];if(t){const r=Q.config.triggerSpecsCache;n=r&&r[t]||st(e,t,r)}if(n.length>0){return n}else if(a(e,"form")){return[{trigger:"submit"}]}else if(a(e,'input[type="button"], input[type="submit"]')){return[{trigger:"click"}]}else if(a(e,it)){return[{trigger:"change"}]}else{return[{trigger:"click"}]}}function ut(e){ie(e).cancelled=true}function ct(e,t,n){const r=ie(e);r.timeout=E().setTimeout(function(){if(le(e)&&r.cancelled!==true){if(!gt(n,e,kt("hx:poll:trigger",{triggerSpec:n,target:e}))){t(e)}ct(e,t,n)}},n.pollInterval)}function ft(e){return location.hostname===e.hostname&&ee(e,"href")&&ee(e,"href").indexOf("#")!==0}function at(t,n,e){if(t instanceof HTMLAnchorElement&&ft(t)&&(t.target===""||t.target==="_self")||t.tagName==="FORM"){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";if(r==="get"){}o=ee(t,"action")}e.forEach(function(e){pt(t,function(e,t){const n=ce(e);if(g(n,Q.config.disableSelector)){f(n);return}de(r,o,n,t)},n,e,true)})}}function ht(e,t){const n=ce(t);if(!n){return false}if(e.type==="submit"||e.type==="click"){if(n.tagName==="FORM"){return true}if(a(n,'input[type="submit"], button')&&g(n,"form")!==null){return true}if(n instanceof HTMLAnchorElement&&n.href&&(n.getAttribute("href")==="#"||n.getAttribute("href").indexOf("#")!==0)){return true}}return false}function dt(e,t){return ie(e).boosted&&e instanceof HTMLAnchorElement&&t.type==="click"&&(t.ctrlKey||t.metaKey)}function gt(e,t,n){const r=e.eventFilter;if(r){try{return r.call(t,n)!==true}catch(e){const o=r.source;ae(ne().body,"htmx:eventFilter:error",{error:e,source:o});return true}}return false}function pt(s,l,e,u,c){const f=ie(s);let t;if(u.from){t=m(s,u.from)}else{t=[s]}if(u.changed){t.forEach(function(e){const t=ie(e);t.lastValue=e.value})}se(t,function(o){const i=function(e){if(!le(s)){o.removeEventListener(u.trigger,i);return}if(dt(s,e)){return}if(c||ht(e,s)){e.preventDefault()}if(gt(u,s,e)){return}const t=ie(e);t.triggerSpec=u;if(t.handledFor==null){t.handledFor=[]}if(t.handledFor.indexOf(s)<0){t.handledFor.push(s);if(u.consume){e.stopPropagation()}if(u.target&&e.target){if(!a(ce(e.target),u.target)){return}}if(u.once){if(f.triggeredOnce){return}else{f.triggeredOnce=true}}if(u.changed){const n=ie(o);const r=o.value;if(n.lastValue===r){return}n.lastValue=r}if(f.delayed){clearTimeout(f.delayed)}if(f.throttle){return}if(u.throttle>0){if(!f.throttle){l(s,e);f.throttle=E().setTimeout(function(){f.throttle=null},u.throttle)}}else if(u.delay>0){f.delayed=E().setTimeout(function(){l(s,e)},u.delay)}else{he(s,"htmx:trigger");l(s,e)}}};if(e.listenerInfos==null){e.listenerInfos=[]}e.listenerInfos.push({trigger:u.trigger,listener:i,on:o});o.addEventListener(u.trigger,i)})}let mt=false;let xt=null;function yt(){if(!xt){xt=function(){mt=true};window.addEventListener("scroll",xt);setInterval(function(){if(mt){mt=false;se(ne().querySelectorAll("[hx-trigger*='revealed'],[data-hx-trigger*='revealed']"),function(e){bt(e)})}},200)}}function bt(e){if(!s(e,"data-hx-revealed")&&U(e)){e.setAttribute("data-hx-revealed","true");const t=ie(e);if(t.initHash){he(e,"revealed")}else{e.addEventListener("htmx:afterProcessNode",function(){he(e,"revealed")},{once:true})}}}function wt(e,t,n,r){const o=function(){if(!n.loaded){n.loaded=true;t(e)}};if(r>0){E().setTimeout(o,r)}else{o()}}function vt(t,n,e){let i=false;se(v,function(r){if(s(t,"hx-"+r)){const o=te(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(g(n,Q.config.disableSelector)){f(n);return}de(r,o,n,t)})})}});return i}function St(r,e,t,n){if(e.trigger==="revealed"){yt();pt(r,n,t,e);bt(ce(r))}else if(e.trigger==="intersect"){const o={};if(e.root){o.root=fe(r,e.root)}if(e.threshold){o.threshold=parseFloat(e.threshold)}const i=new IntersectionObserver(function(t){for(let e=0;e0){t.polling=true;ct(ce(r),n,e)}else{pt(r,n,t,e)}}function Et(e){const t=ce(e);if(!t){return false}const n=t.attributes;for(let e=0;eQ.config.historyCacheSize){i.shift()}while(i.length>0){try{localStorage.setItem("htmx-history-cache",JSON.stringify(i));break}catch(e){ae(ne().body,"htmx:historyCacheError",{cause:e,cache:i});i.shift()}}}function Bt(t){if(!V()){return null}t=j(t);const n=S(localStorage.getItem("htmx-history-cache"))||[];for(let e=0;e=200&&this.status<400){he(ne().body,"htmx:historyCacheMissLoad",i);const e=D(this.response);const t=e.querySelector("[hx-history-elt],[data-hx-history-elt]")||e;const n=Ft();const r=pn(n);In(e.title);je(n,t,r);$t(r.tasks);Xt=o;he(ne().body,"htmx:historyRestore",{path:o,cacheMiss:true,serverResponse:this.response})}else{ae(ne().body,"htmx:historyCacheMissLoadError",i)}};e.send()}function Kt(e){jt();e=e||location.pathname+location.search;const t=Bt(e);if(t){const n=D(t.content);const r=Ft();const o=pn(r);In(n.title);je(r,n,o);$t(o.tasks);E().setTimeout(function(){window.scrollTo(0,t.scroll)},0);Xt=e;he(ne().body,"htmx:historyRestore",{path:e,item:t})}else{if(Q.config.refreshOnHistoryMiss){window.location.reload(true)}else{Jt(e)}}}function Gt(e){let t=Se(e,"hx-indicator");if(t==null){t=[e]}se(t,function(e){const t=ie(e);t.requestCount=(t.requestCount||0)+1;e.classList.add.call(e.classList,Q.config.requestClass)});return t}function Zt(e){let t=Se(e,"hx-disabled-elt");if(t==null){t=[]}se(t,function(e){const t=ie(e);t.requestCount=(t.requestCount||0)+1;e.setAttribute("disabled","")});return t}function Wt(e,t){se(e,function(e){const t=ie(e);t.requestCount=(t.requestCount||0)-1;if(t.requestCount===0){e.classList.remove.call(e.classList,Q.config.requestClass)}});se(t,function(e){const t=ie(e);t.requestCount=(t.requestCount||0)-1;if(t.requestCount===0){e.removeAttribute("disabled")}})}function Yt(t,n){for(let e=0;en.indexOf(e)<0)}else{e=e.filter(e=>e!==n)}r.delete(t);se(e,e=>r.append(t,e))}}function nn(t,n,r,o,i){if(o==null||Yt(t,o)){return}else{t.push(o)}if(Qt(o)){const s=ee(o,"name");let e=o.value;if(o instanceof HTMLSelectElement&&o.multiple){e=F(o.querySelectorAll("option:checked")).map(function(e){return e.value})}if(o instanceof HTMLInputElement&&o.files){e=F(o.files)}en(s,e,n);if(i){rn(o,r)}}if(o instanceof HTMLFormElement){se(o.elements,function(e){if(t.indexOf(e)>=0){tn(e.name,e.value,n)}else{t.push(e)}if(i){rn(e,r)}});new FormData(o).forEach(function(e,t){en(t,e,n)})}}function rn(e,t){const n=e;if(n.willValidate){he(n,"htmx:validation:validate");if(!n.checkValidity()){t.push({elt:n,message:n.validationMessage,validity:n.validity});he(n,"htmx:validation:failed",{message:n.validationMessage,validity:n.validity})}}}function on(t,e){for(const n of e.keys()){t.delete(n);e.getAll(n).forEach(function(e){t.append(n,e)})}return t}function sn(e,t){const n=[];const r=new FormData;const o=new FormData;const i=[];const s=ie(e);if(s.lastButtonClicked&&!le(s.lastButtonClicked)){s.lastButtonClicked=null}let l=e instanceof HTMLFormElement&&e.noValidate!==true||te(e,"hx-validate")==="true";if(s.lastButtonClicked){l=l&&s.lastButtonClicked.formNoValidate!==true}if(t!=="get"){nn(n,o,i,g(e,"form"),l)}nn(n,r,i,e,l);if(s.lastButtonClicked||e.tagName==="BUTTON"||e.tagName==="INPUT"&&ee(e,"type")==="submit"){const c=s.lastButtonClicked||e;const f=ee(c,"name");en(f,c.value,o)}const u=Se(e,"hx-include");se(u,function(e){nn(n,r,i,ce(e),l);if(!a(e,"form")){se(h(e).querySelectorAll(it),function(e){nn(n,r,i,e,l)})}});on(r,o);return{errors:i,formData:r,values:qn(r)}}function ln(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 un(e){e=Hn(e);let n="";e.forEach(function(e,t){n=ln(n,t,e)});return n}function cn(e,t,n){const r={"HX-Request":"true","HX-Trigger":ee(e,"id"),"HX-Trigger-Name":ee(e,"name"),"HX-Target":te(t,"id"),"HX-Current-URL":ne().location.href};xn(e,"hx-headers",false,r);if(n!==undefined){r["HX-Prompt"]=n}if(ie(e).boosted){r["HX-Boosted"]="true"}return r}function fn(n,e){const t=re(e,"hx-params");if(t){if(t==="none"){return new FormData}else if(t==="*"){return n}else if(t.indexOf("not ")===0){se(t.substr(4).split(","),function(e){e=e.trim();n.delete(e)});return n}else{const r=new FormData;se(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 an(e){return!!ee(e,"href")&&ee(e,"href").indexOf("#")>=0}function hn(e,t){const n=t||re(e,"hx-swap");const r={swapStyle:ie(e).boosted?"innerHTML":Q.config.defaultSwapStyle,swapDelay:Q.config.defaultSwapDelay,settleDelay:Q.config.defaultSettleDelay};if(Q.config.scrollIntoViewOnBoost&&ie(e).boosted&&!an(e)){r.show="top"}if(n){const s=B(n);if(s.length>0){for(let e=0;e0?o.join(":"):null;r.scroll=c;r.scrollTarget=i}else if(l.indexOf("show:")===0){const f=l.substr(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.substr("focus-scroll:".length);r.focusScroll=h=="true"}else if(e==0){r.swapStyle=l}else{w("Unknown modifier in hx-swap: "+l)}}}}return r}function dn(e){return re(e,"hx-encoding")==="multipart/form-data"||a(e,"form")&&ee(e,"enctype")==="multipart/form-data"}function gn(t,n,r){let o=null;Mt(n,function(e){if(o==null){o=e.encodeParameters(t,r,n)}});if(o!=null){return o}else{if(dn(n)){return Hn(r)}else{return un(r)}}}function pn(e){return{tasks:[],elts:[e]}}function mn(e,t){const n=e[0];const r=e[e.length-1];if(t.scroll){var o=null;if(t.scrollTarget){o=ce(fe(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(t.show){var o=null;if(t.showTarget){let e=t.showTarget;if(t.showTarget==="window"){e="body"}o=ce(fe(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 xn(r,e,o,i){if(i==null){i={}}if(r==null){return i}const s=te(r,e);if(s){let e=s.trim();let t=o;if(e==="unset"){return null}if(e.indexOf("javascript:")===0){e=e.substr(11);t=true}else if(e.indexOf("js:")===0){e=e.substr(3);t=true}if(e.indexOf("{")!==0){e="{"+e+"}"}let n;if(t){n=yn(r,function(){return Function("return ("+e+")")()},{})}else{n=S(e)}for(const l in n){if(n.hasOwnProperty(l)){if(i[l]==null){i[l]=n[l]}}}}return xn(ce(u(r)),e,o,i)}function yn(e,t,n){if(Q.config.allowEval){return t()}else{ae(e,"htmx:evalDisallowedError");return n}}function bn(e,t){return xn(e,"hx-vars",true,t)}function wn(e,t){return xn(e,"hx-vals",false,t)}function vn(e){return Hn(ue(bn(e),wn(e)))}function Sn(t,n,r){if(r!==null){try{t.setRequestHeader(n,r)}catch(e){t.setRequestHeader(n,encodeURIComponent(r));t.setRequestHeader(n+"-URI-AutoEncoded","true")}}}function En(t){if(t.responseURL&&typeof URL!=="undefined"){try{const e=new URL(t.responseURL);return e.pathname+e.search}catch(e){ae(ne().body,"htmx:badResponseUrl",{url:t.responseURL})}}}function C(e,t){return t.test(e.getAllResponseHeaders())}function Cn(e,t,n){e=e.toLowerCase();if(n){if(n instanceof Element||typeof n==="string"){return de(e,t,null,null,{targetOverride:x(n),returnPromise:true})}else{return de(e,t,x(n.source),n.event,{handler:n.handler,headers:n.headers,values:n.values,targetOverride:x(n.target),swapOverride:n.swap,select:n.select,returnPromise:true})}}else{return de(e,t,null,null,{returnPromise:true})}}function Rn(e){const t=[];while(e){t.push(e);e=e.parentElement}return t}function On(e,t,n){let r;let o;if(typeof URL==="function"){o=new URL(t,document.location.href);const i=document.location.origin;r=i===o.origin}else{o=t;r=l(t,document.location.origin)}if(Q.config.selfRequestsOnly){if(!r){return false}}return he(e,"htmx:validateUrl",ue({url:o,sameHost:r},n))}function Hn(e){if(e instanceof FormData)return e;const t=new FormData;for(const n in e){if(e.hasOwnProperty(n)){if(typeof e[n].forEach==="function"){e[n].forEach(function(e){t.append(n,e)})}else if(typeof e[n]==="object"){t.append(n,JSON.stringify(e[n]))}else{t.append(n,e[n])}}}return t}function Tn(r,o,e){return new Proxy(e,{get:function(t,e){if(typeof e==="number")return t[e];if(e==="length")return t.length;if(e==="push"){return function(e){t.push(e);r.append(o,e)}}if(typeof t[e]==="function"){return function(){t[e].apply(t,arguments);r.delete(o);t.forEach(function(e){r.append(o,e)})}}if(t[e]&&t[e].length===1){return t[e][0]}else{return t[e]}},set:function(e,t,n){e[t]=n;r.delete(o);e.forEach(function(e){r.append(o,e)});return true}})}function qn(r){return new Proxy(r,{get:function(e,t){if(typeof t==="symbol"){return Reflect.get(e,t)}if(t==="toJSON"){return()=>Object.fromEntries(r)}if(t in e){if(typeof e[t]==="function"){return function(){return r[t].apply(r,arguments)}}else{return e[t]}}const n=r.getAll(t);if(n.length===0){return undefined}else if(n.length===1){return n[0]}else{return Tn(e,t,n)}},set:function(t,n,e){if(typeof n!=="string"){return false}t.delete(n);if(typeof e.forEach==="function"){e.forEach(function(e){t.append(n,e)})}else{t.append(n,e)}return true},deleteProperty:function(e,t){if(typeof t==="string"){e.delete(t)}return true},ownKeys:function(e){return Reflect.ownKeys(Object.fromEntries(e))},getOwnPropertyDescriptor:function(e,t){return Reflect.getOwnPropertyDescriptor(Object.fromEntries(e),t)}})}function de(t,n,r,o,i,D){let s=null;let l=null;i=i!=null?i:{};if(i.returnPromise&&typeof Promise!=="undefined"){var e=new Promise(function(e,t){s=e;l=t})}if(r==null){r=ne().body}const M=i.handler||Pn;const X=i.select||null;if(!le(r)){oe(s);return e}const u=i.targetOverride||ce(Ce(r));if(u==null||u==ve){ae(r,"htmx:targetError",{target:te(r,"hx-target")});oe(l);return e}let c=ie(r);const f=c.lastButtonClicked;if(f){const L=ee(f,"formaction");if(L!=null){n=L}const A=ee(f,"formmethod");if(A!=null){if(A.toLowerCase()!=="dialog"){t=A}}}const a=re(r,"hx-confirm");if(D===undefined){const K=function(e){return de(t,n,r,o,i,!!e)};const G={target:u,elt:r,path:n,verb:t,triggeringEvent:o,etc:i,issueRequest:K,question:a};if(he(r,"htmx:confirm",G)===false){oe(s);return e}}let h=r;let d=re(r,"hx-sync");let g=null;let F=false;if(d){const N=d.split(":");const I=N[0].trim();if(I==="this"){h=Ee(r,"hx-sync")}else{h=ce(fe(r,I))}d=(N[1]||"drop").trim();c=ie(h);if(d==="drop"&&c.xhr&&c.abortable!==true){oe(s);return e}else if(d==="abort"){if(c.xhr){oe(s);return e}else{F=true}}else if(d==="replace"){he(h,"htmx:abort")}else if(d.indexOf("queue")===0){const Z=d.split(" ");g=(Z[1]||"last").trim()}}if(c.xhr){if(c.abortable){he(h,"htmx:abort")}else{if(g==null){if(o){const P=ie(o);if(P&&P.triggerSpec&&P.triggerSpec.queue){g=P.triggerSpec.queue}}if(g==null){g="last"}}if(c.queuedRequests==null){c.queuedRequests=[]}if(g==="first"&&c.queuedRequests.length===0){c.queuedRequests.push(function(){de(t,n,r,o,i)})}else if(g==="all"){c.queuedRequests.push(function(){de(t,n,r,o,i)})}else if(g==="last"){c.queuedRequests=[];c.queuedRequests.push(function(){de(t,n,r,o,i)})}oe(s);return e}}const p=new XMLHttpRequest;c.xhr=p;c.abortable=F;const m=function(){c.xhr=null;c.abortable=false;if(c.queuedRequests!=null&&c.queuedRequests.length>0){const e=c.queuedRequests.shift();e()}};const U=re(r,"hx-prompt");if(U){var x=prompt(U);if(x===null||!he(r,"htmx:prompt",{prompt:x,target:u})){oe(s);m();return e}}if(a&&!D){if(!confirm(a)){oe(s);m();return e}}let y=cn(r,u,x);if(t!=="get"&&!dn(r)){y["Content-Type"]="application/x-www-form-urlencoded"}if(i.headers){y=ue(y,i.headers)}const B=sn(r,t);let b=B.errors;const V=B.formData;if(i.values){on(V,Hn(i.values))}const j=vn(r);const w=on(V,j);let v=fn(w,r);if(Q.config.getCacheBusterParam&&t==="get"){v.set("org.htmx.cache-buster",ee(u,"id")||"true")}if(n==null||n===""){n=ne().location.href}const S=xn(r,"hx-request");const _=ie(r).boosted;let E=Q.config.methodsThatUseUrlParams.indexOf(t)>=0;const C={boosted:_,useUrlParams:E,formData:v,parameters:qn(v),unfilteredFormData:w,unfilteredParameters:qn(w),headers:y,target:u,verb:t,errors:b,withCredentials:i.credentials||S.credentials||Q.config.withCredentials,timeout:i.timeout||S.timeout||Q.config.timeout,path:n,triggeringEvent:o};if(!he(r,"htmx:configRequest",C)){oe(s);m();return e}n=C.path;t=C.verb;y=C.headers;v=Hn(C.parameters);b=C.errors;E=C.useUrlParams;if(b&&b.length>0){he(r,"htmx:validation:halted",C);oe(s);m();return e}const z=n.split("#");const $=z[0];const R=z[1];let O=n;if(E){O=$;const W=!v.keys().next().done;if(W){if(O.indexOf("?")<0){O+="?"}else{O+="&"}O+=un(v);if(R){O+="#"+R}}}if(!On(r,O,C)){ae(r,"htmx:invalidPath",C);oe(l);return e}p.open(t.toUpperCase(),O,true);p.overrideMimeType("text/html");p.withCredentials=C.withCredentials;p.timeout=C.timeout;if(S.noHeaders){}else{for(const k in y){if(y.hasOwnProperty(k)){const Y=y[k];Sn(p,k,Y)}}}const H={xhr:p,target:u,requestConfig:C,etc:i,boosted:_,select:X,pathInfo:{requestPath:n,finalRequestPath:O,responsePath:null,anchor:R}};p.onload=function(){try{const t=Rn(r);H.pathInfo.responsePath=En(p);M(r,H);Wt(T,q);he(r,"htmx:afterRequest",H);he(r,"htmx:afterOnLoad",H);if(!le(r)){let e=null;while(t.length>0&&e==null){const n=t.shift();if(le(n)){e=n}}if(e){he(e,"htmx:afterRequest",H);he(e,"htmx:afterOnLoad",H)}}oe(s);m()}catch(e){ae(r,"htmx:onLoadError",ue({error:e},H));throw e}};p.onerror=function(){Wt(T,q);ae(r,"htmx:afterRequest",H);ae(r,"htmx:sendError",H);oe(l);m()};p.onabort=function(){Wt(T,q);ae(r,"htmx:afterRequest",H);ae(r,"htmx:sendAbort",H);oe(l);m()};p.ontimeout=function(){Wt(T,q);ae(r,"htmx:afterRequest",H);ae(r,"htmx:timeout",H);oe(l);m()};if(!he(r,"htmx:beforeRequest",H)){oe(s);m();return e}var T=Gt(r);var q=Zt(r);se(["loadstart","loadend","progress","abort"],function(t){se([p,p.upload],function(e){e.addEventListener(t,function(e){he(r,"htmx:xhr:"+t,{lengthComputable:e.lengthComputable,loaded:e.loaded,total:e.total})})})});he(r,"htmx:beforeSend",H);const J=E?null:gn(p,r,v);p.send(J);return e}function Ln(e,t){const n=t.xhr;let r=null;let o=null;if(C(n,/HX-Push:/i)){r=n.getResponseHeader("HX-Push");o="push"}else if(C(n,/HX-Push-Url:/i)){r=n.getResponseHeader("HX-Push-Url");o="push"}else if(C(n,/HX-Replace-Url:/i)){r=n.getResponseHeader("HX-Replace-Url");o="replace"}if(r){if(r==="false"){return{}}else{return{type:o,path:r}}}const i=t.pathInfo.finalRequestPath;const s=t.pathInfo.responsePath;const l=re(e,"hx-push-url");const u=re(e,"hx-replace-url");const c=ie(e).boosted;let f=null;let a=null;if(l){f="push";a=l}else if(u){f="replace";a=u}else if(c){f="push";a=s||i}if(a){if(a==="false"){return{}}if(a==="true"){a=s||i}if(t.pathInfo.anchor&&a.indexOf("#")===-1){a=a+"#"+t.pathInfo.anchor}return{type:f,path:a}}else{return{}}}function An(e,t){var n=new RegExp(e.code);return n.test(t.toString(10))}function Nn(e){for(var t=0;t0){E().setTimeout(e,x.swapDelay)}else{e()}}if(a){ae(o,"htmx:responseError",ue({error:"Response Status Error Code "+s.status+" from "+i.pathInfo.requestPath},i))}}const kn={};function Dn(){return{init:function(e){return null},onEvent:function(e,t){return true},transformResponse:function(e,t,n){return e},isInlineSwap:function(e){return false},handleSwap:function(e,t,n,r){return false},encodeParameters:function(e,t,n){return null}}}function Mn(e,t){if(t.init){t.init(n)}kn[e]=ue(Dn(),t)}function Xn(e){delete kn[e]}function Fn(e,n,r){if(n==undefined){n=[]}if(e==undefined){return n}if(r==undefined){r=[]}const t=te(e,"hx-ext");if(t){se(t.split(","),function(e){e=e.replace(/ /g,"");if(e.slice(0,7)=="ignore:"){r.push(e.slice(7));return}if(r.indexOf(e)<0){const t=kn[e];if(t&&n.indexOf(t)<0){n.push(t)}}})}return Fn(ce(u(e)),n,r)}var Un=false;ne().addEventListener("DOMContentLoaded",function(){Un=true});function Bn(e){if(Un||ne().readyState==="complete"){e()}else{ne().addEventListener("DOMContentLoaded",e)}}function Vn(){if(Q.config.includeIndicatorStyles!==false){ne().head.insertAdjacentHTML("beforeend","")}}function jn(){const e=ne().querySelector('meta[name="htmx-config"]');if(e){return S(e.content)}else{return null}}function _n(){const e=jn();if(e){Q.config=ue(Q.config,e)}}Bn(function(){_n();Vn();let e=ne().body;It(e);const t=ne().querySelectorAll("[hx-trigger='restored'],[data-hx-trigger='restored']");e.addEventListener("htmx:abort",function(e){const t=e.target;const n=ie(t);if(n&&n.xhr){n.xhr.abort()}});const n=window.onpopstate?window.onpopstate.bind(window):null;window.onpopstate=function(e){if(e.state&&e.state.htmx){Kt();se(t,function(e){he(e,"htmx:restored",{document:ne(),triggerEvent:he})})}else{if(n){n(e)}}};E().setTimeout(function(){he(e,"htmx:load",{});e=null},0)});return Q}(); \ No newline at end of file +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=sn(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:"",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},parseInterval:null,_:null,version:"2.0a"};Q.onLoad=z;Q.process=It;Q.on=be;Q.off=we;Q.trigger=he;Q.ajax=Cn;Q.find=r;Q.findAll=p;Q.closest=g;Q.remove=K;Q.addClass=W;Q.removeClass=o;Q.toggleClass=Y;Q.takeClass=ge;Q.swap=$e;Q.defineExtension=Mn;Q.removeExtension=Xn;Q.logAll=$;Q.logNone=J;Q.parseInterval=d;Q._=_;const n={addTriggerHandler:St,bodyContains:le,canAccessLocalStorage:V,findThisElement:Ee,filterValues:fn,swap:$e,hasAttribute:s,getAttributeValue:te,getClosestAttributeValue:re,getClosestMatch:T,getExpressionVars:vn,getHeaders:cn,getInputValues:sn,getInternalData:ie,getSwapSpecification:hn,getTriggerSpecs:lt,getTarget:Ce,makeFragment:D,mergeObjects:ue,makeSettleInfo:pn,oobSwap:Te,querySelectorExt:fe,settleImmediately:$t,shouldCancel:ht,triggerEvent:he,triggerErrorEvent:ae,withExtensions:Mt};const v=["get","post","put","delete","patch"];const R=v.map(function(e){return"[hx-"+e+"], [data-hx-"+e+"]"}).join(", ");const O=e("head");function e(e,t=false){return new RegExp(`<${e}(\\s[^>]*>|>)([\\s\\S]*?)<\\/${e}>`,t?"gim":"im")}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 te(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 ne(){return document}function H(e,t){return e.getRootNode?e.getRootNode({composed:t}):ne()}function T(e,t){while(e&&!t(e)){e=u(e)}return e||null}function q(e,t,n){const r=te(t,n);const o=te(t,"hx-disinherit");var i=te(t,"hx-inherit");if(e!==t){if(Q.config.disableInheritance){if(i&&(i==="*"||i.split(" ").indexOf(n)>=0)){return r}else{return null}}if(o&&(o==="*"||o.split(" ").indexOf(n)>=0)){return"unset"}}return r}function re(t,n){let r=null;T(t,function(e){return!!(r=q(t,ce(e),n))});if(r!=="unset"){return r}}function a(e,t){const n=e instanceof Element&&(e.matches||e.matchesSelector||e.msMatchesSelector||e.mozMatchesSelector||e.webkitMatchesSelector||e.oMatchesSelector);return!!n&&n.call(e,t)}function L(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 A(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 I(e){const t=ne().createElement("script");se(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 P(e){return e.matches("script")&&(e.type==="text/javascript"||e.type==="module"||e.type==="")}function k(e){Array.from(e.querySelectorAll("script")).forEach(e=>{if(P(e)){const t=I(e);const n=e.parentNode;try{n.insertBefore(t,e)}catch(e){w(e)}finally{e.remove()}}})}function D(e){const t=e.replace(O,"");const n=L(t);let r;if(n==="html"){r=new DocumentFragment;const i=A(e);N(r,i.body);r.title=i.title}else if(n==="body"){r=new DocumentFragment;const i=A(t);N(r,i.body);r.title=i.title}else{const i=A('");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){k(r)}else{r.querySelectorAll("script").forEach(e=>e.remove())}}return r}function oe(e){if(e){e()}}function t(e,t){return Object.prototype.toString.call(e)==="[object "+t+"]"}function M(e){return typeof e==="function"}function X(e){return t(e,"Object")}function ie(e){const t="htmx-internal-data";let n=e[t];if(!n){n=e[t]={}}return n}function F(t){const n=[];if(t){for(let e=0;e=0}function le(e){const t=e.getRootNode&&e.getRootNode();if(t&&t instanceof window.ShadowRoot){return ne().body.contains(t.host)}else{return ne().body.contains(e)}}function B(e){return e.trim().split(/\s+/)}function ue(e,t){for(const n in t){if(t.hasOwnProperty(n)){e[n]=t[n]}}return e}function S(e){try{return JSON.parse(e)}catch(e){w(e);return null}}function V(){const e="htmx:localStorageTest";try{localStorage.setItem(e,e);localStorage.removeItem(e);return true}catch(e){return false}}function j(t){try{const e=new URL(t);if(e){t=e.pathname+e.search}if(!/^\/$/.test(t)){t=t.replace(/\/+$/,"")}return t}catch(e){return t}}function _(e){return yn(ne().body,function(){return eval(e)})}function z(t){const e=Q.on("htmx:load",function(e){t(e.detail.elt)});return e}function $(){Q.logger=function(e,t,n){if(console){console.log(t,e,n)}}}function J(){Q.logger=null}function r(e,t){if(typeof e!=="string"){return e.querySelector(t)}else{return r(ne(),e)}}function p(e,t){if(typeof e!=="string"){return e.querySelectorAll(t)}else{return p(ne(),e)}}function E(){return window}function K(e,t){e=x(e);if(t){E().setTimeout(function(){K(e);e=null},t)}else{u(e).removeChild(e)}}function ce(e){return e instanceof Element?e:null}function G(e){return e instanceof HTMLElement?e:null}function Z(e){return typeof e==="string"?e:null}function h(e){return e instanceof Element||e instanceof Document||e instanceof DocumentFragment?e:null}function W(e,t,n){e=ce(x(e));if(!e){return}if(n){E().setTimeout(function(){W(e,t);e=null},n)}else{e.classList&&e.classList.add(t)}}function o(e,t,n){let r=ce(x(e));if(!r){return}if(n){E().setTimeout(function(){o(r,t);r=null},n)}else{if(r.classList){r.classList.remove(t);if(r.classList.length===0){r.removeAttribute("class")}}}}function Y(e,t){e=x(e);e.classList.toggle(t)}function ge(e,t){e=x(e);se(e.parentElement.children,function(e){o(e,t)});W(ce(e),t)}function g(e,t){e=ce(x(e));if(e&&e.closest){return e.closest(t)}else{do{if(e==null||a(e,t)){return e}}while(e=e&&ce(u(e)));return null}}function l(e,t){return e.substring(0,t.length)===t}function pe(e,t){return e.substring(e.length-t.length)===t}function i(e){const t=e.trim();if(l(t,"<")&&pe(t,"/>")){return t.substring(1,t.length-2)}else{return t}}function m(e,t,n){e=x(e);if(t.indexOf("closest ")===0){return[g(ce(e),i(t.substr(8)))]}else if(t.indexOf("find ")===0){return[r(h(e),i(t.substr(5)))]}else if(t==="next"){return[ce(e).nextElementSibling]}else if(t.indexOf("next ")===0){return[me(e,i(t.substr(5)),!!n)]}else if(t==="previous"){return[ce(e).previousElementSibling]}else if(t.indexOf("previous ")===0){return[xe(e,i(t.substr(9)),!!n)]}else if(t==="document"){return[document]}else if(t==="window"){return[window]}else if(t==="body"){return[document.body]}else if(t==="root"){return[H(e,!!n)]}else if(t.indexOf("global ")===0){return m(e,t.slice(7),true)}else{return F(h(H(e,!!n)).querySelectorAll(i(t)))}}var me=function(t,e,n){const r=h(H(t,n)).querySelectorAll(e);for(let e=0;e=0;e--){const o=r[e];if(o.compareDocumentPosition(t)===Node.DOCUMENT_POSITION_FOLLOWING){return o}}};function fe(e,t){if(typeof e!=="string"){return m(e,t)[0]}else{return m(ne().body,e)[0]}}function x(e,t){if(typeof e==="string"){return r(h(t)||document,e)}else{return e}}function ye(e,t,n){if(M(t)){return{target:ne().body,event:Z(e),listener:t}}else{return{target:x(e),event:Z(t),listener:n}}}function be(t,n,r){Bn(function(){const e=ye(t,n,r);e.target.addEventListener(e.event,e.listener)});const e=M(n);return e?n:r}function we(t,n,r){Bn(function(){const e=ye(t,n,r);e.target.removeEventListener(e.event,e.listener)});return M(n)?n:r}const ve=ne().createElement("output");function Se(e,t){const n=re(e,t);if(n){if(n==="this"){return[Ee(e,t)]}else{const r=m(e,n);if(r.length===0){w('The selector "'+n+'" on '+t+" returned no matches!");return[ve]}else{return r}}}}function Ee(e,t){return ce(T(e,function(e){return te(ce(e),t)!=null}))}function Ce(e){const t=re(e,"hx-target");if(t){if(t==="this"){return Ee(e,"hx-target")}else{return fe(e,t)}}else{const n=ie(e);if(n.boosted){return ne().body}else{return e}}}function Re(t){const n=Q.config.attributesToSettle;for(let e=0;e0){s=e.substr(0,e.indexOf(":"));t=e.substr(e.indexOf(":")+1,e.length)}else{s=e}const n=ne().querySelectorAll(t);if(n){se(n,function(e){let t;const n=o.cloneNode(true);t=ne().createDocumentFragment();t.appendChild(n);if(!He(s,e)){t=h(n)}const r={shouldSwap:true,target:e,fragment:t};if(!he(e,"htmx:oobBeforeSwap",r))return;e=r.target;if(r.shouldSwap){_e(s,e,e,t,i)}se(i.elts,function(e){he(e,"htmx:oobAfterSwap",r)})});o.parentNode.removeChild(o)}else{o.parentNode.removeChild(o);ae(ne().body,"htmx:oobErrorNoTarget",{content:o})}return e}function qe(e){se(p(e,"[hx-preserve], [data-hx-preserve]"),function(e){const t=te(e,"id");const n=ne().getElementById(t);if(n!=null){e.parentNode.replaceChild(n,e)}})}function Le(l,e,u){se(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=h(l);const i=e&&e.querySelector(o+"[id='"+r+"']");if(i&&i!==e){const s=t.cloneNode();Oe(t,i);u.tasks.push(function(){Oe(t,s)})}}})}function Ae(e){return function(){o(e,Q.config.addedClass);It(ce(e));Ne(h(e));he(e,"htmx:load")}}function Ne(e){const t="[autofocus]";const n=G(a(e,t)?e:e.querySelector(t));if(n!=null){n.focus()}}function c(e,t,n,r){Le(e,n,r);while(n.childNodes.length>0){const o=n.firstChild;W(ce(o),Q.config.addedClass);e.insertBefore(o,t);if(o.nodeType!==Node.TEXT_NODE&&o.nodeType!==Node.COMMENT_NODE){r.tasks.push(Ae(o))}}}function Ie(e,t){let n=0;while(n0){E().setTimeout(l,r.settleDelay)}else{l()}}function Je(e,t,n){const r=e.getResponseHeader(t);if(r.indexOf("{")===0){const o=S(r);for(const i in o){if(o.hasOwnProperty(i)){let e=o[i];if(!X(e)){e={value:e}}he(n,i,e)}}}else{const s=r.split(",");for(let e=0;e0){const s=o[0];if(s==="]"){e--;if(e===0){if(n===null){t=t+"true"}o.shift();t+=")})";try{const l=yn(r,function(){return Function(t)()},function(){return true});l.source=t;return l}catch(e){ae(ne().body,"htmx:syntax:error",{error:e,source:t});return null}}}else if(s==="["){e++}if(nt(s,n,i)){t+="(("+i+"."+s+") ? ("+i+"."+s+") : (window."+s+"))"}else{t=t+s}n=o.shift()}}}function b(e,t){let n="";while(e.length>0&&!t.test(e[0])){n+=e.shift()}return n}function ot(e){let t;if(e.length>0&&Qe.test(e[0])){e.shift();t=b(e,et).trim();e.shift()}else{t=b(e,y)}return t}const it="input, textarea, select";function st(e,t,n){const r=[];const o=tt(t);do{b(o,Ye);const l=o.length;const u=b(o,/[,\[\s]/);if(u!==""){if(u==="every"){const c={trigger:"every"};b(o,Ye);c.pollInterval=d(b(o,/[,\[\s]/));b(o,Ye);var i=rt(e,o,"event");if(i){c.eventFilter=i}r.push(c)}else{const f={trigger:u};var i=rt(e,o,"event");if(i){f.eventFilter=i}while(o.length>0&&o[0]!==","){b(o,Ye);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(b(o,y))}else if(a==="from"&&o[0]===":"){o.shift();if(Qe.test(o[0])){var s=ot(o)}else{var s=b(o,y);if(s==="closest"||s==="find"||s==="next"||s==="previous"){o.shift();const h=ot(o);if(h.length>0){s+=" "+h}}}f.from=s}else if(a==="target"&&o[0]===":"){o.shift();f.target=ot(o)}else if(a==="throttle"&&o[0]===":"){o.shift();f.throttle=d(b(o,y))}else if(a==="queue"&&o[0]===":"){o.shift();f.queue=b(o,y)}else if(a==="root"&&o[0]===":"){o.shift();f[a]=ot(o)}else if(a==="threshold"&&o[0]===":"){o.shift();f[a]=b(o,y)}else{ae(e,"htmx:syntax:error",{token:o.shift()})}}r.push(f)}}if(o.length===l){ae(e,"htmx:syntax:error",{token:o.shift()})}b(o,Ye)}while(o[0]===","&&o.shift());if(n){n[t]=r}return r}function lt(e){const t=te(e,"hx-trigger");let n=[];if(t){const r=Q.config.triggerSpecsCache;n=r&&r[t]||st(e,t,r)}if(n.length>0){return n}else if(a(e,"form")){return[{trigger:"submit"}]}else if(a(e,'input[type="button"], input[type="submit"]')){return[{trigger:"click"}]}else if(a(e,it)){return[{trigger:"change"}]}else{return[{trigger:"click"}]}}function ut(e){ie(e).cancelled=true}function ct(e,t,n){const r=ie(e);r.timeout=E().setTimeout(function(){if(le(e)&&r.cancelled!==true){if(!gt(n,e,kt("hx:poll:trigger",{triggerSpec:n,target:e}))){t(e)}ct(e,t,n)}},n.pollInterval)}function ft(e){return location.hostname===e.hostname&&ee(e,"href")&&ee(e,"href").indexOf("#")!==0}function at(t,n,e){if(t instanceof HTMLAnchorElement&&ft(t)&&(t.target===""||t.target==="_self")||t.tagName==="FORM"){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";if(r==="get"){}o=ee(t,"action")}e.forEach(function(e){pt(t,function(e,t){const n=ce(e);if(g(n,Q.config.disableSelector)){f(n);return}de(r,o,n,t)},n,e,true)})}}function ht(e,t){const n=ce(t);if(!n){return false}if(e.type==="submit"||e.type==="click"){if(n.tagName==="FORM"){return true}if(a(n,'input[type="submit"], button')&&g(n,"form")!==null){return true}if(n instanceof HTMLAnchorElement&&n.href&&(n.getAttribute("href")==="#"||n.getAttribute("href").indexOf("#")!==0)){return true}}return false}function dt(e,t){return ie(e).boosted&&e instanceof HTMLAnchorElement&&t.type==="click"&&(t.ctrlKey||t.metaKey)}function gt(e,t,n){const r=e.eventFilter;if(r){try{return r.call(t,n)!==true}catch(e){const o=r.source;ae(ne().body,"htmx:eventFilter:error",{error:e,source:o});return true}}return false}function pt(s,l,e,u,c){const f=ie(s);let t;if(u.from){t=m(s,u.from)}else{t=[s]}if(u.changed){t.forEach(function(e){const t=ie(e);t.lastValue=e.value})}se(t,function(o){const i=function(e){if(!le(s)){o.removeEventListener(u.trigger,i);return}if(dt(s,e)){return}if(c||ht(e,s)){e.preventDefault()}if(gt(u,s,e)){return}const t=ie(e);t.triggerSpec=u;if(t.handledFor==null){t.handledFor=[]}if(t.handledFor.indexOf(s)<0){t.handledFor.push(s);if(u.consume){e.stopPropagation()}if(u.target&&e.target){if(!a(ce(e.target),u.target)){return}}if(u.once){if(f.triggeredOnce){return}else{f.triggeredOnce=true}}if(u.changed){const n=ie(o);const r=o.value;if(n.lastValue===r){return}n.lastValue=r}if(f.delayed){clearTimeout(f.delayed)}if(f.throttle){return}if(u.throttle>0){if(!f.throttle){l(s,e);f.throttle=E().setTimeout(function(){f.throttle=null},u.throttle)}}else if(u.delay>0){f.delayed=E().setTimeout(function(){l(s,e)},u.delay)}else{he(s,"htmx:trigger");l(s,e)}}};if(e.listenerInfos==null){e.listenerInfos=[]}e.listenerInfos.push({trigger:u.trigger,listener:i,on:o});o.addEventListener(u.trigger,i)})}let mt=false;let xt=null;function yt(){if(!xt){xt=function(){mt=true};window.addEventListener("scroll",xt);setInterval(function(){if(mt){mt=false;se(ne().querySelectorAll("[hx-trigger*='revealed'],[data-hx-trigger*='revealed']"),function(e){bt(e)})}},200)}}function bt(e){if(!s(e,"data-hx-revealed")&&U(e)){e.setAttribute("data-hx-revealed","true");const t=ie(e);if(t.initHash){he(e,"revealed")}else{e.addEventListener("htmx:afterProcessNode",function(){he(e,"revealed")},{once:true})}}}function wt(e,t,n,r){const o=function(){if(!n.loaded){n.loaded=true;t(e)}};if(r>0){E().setTimeout(o,r)}else{o()}}function vt(t,n,e){let i=false;se(v,function(r){if(s(t,"hx-"+r)){const o=te(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(g(n,Q.config.disableSelector)){f(n);return}de(r,o,n,t)})})}});return i}function St(r,e,t,n){if(e.trigger==="revealed"){yt();pt(r,n,t,e);bt(ce(r))}else if(e.trigger==="intersect"){const o={};if(e.root){o.root=fe(r,e.root)}if(e.threshold){o.threshold=parseFloat(e.threshold)}const i=new IntersectionObserver(function(t){for(let e=0;e0){t.polling=true;ct(ce(r),n,e)}else{pt(r,n,t,e)}}function Et(e){const t=ce(e);if(!t){return false}const n=t.attributes;for(let e=0;eQ.config.historyCacheSize){i.shift()}while(i.length>0){try{localStorage.setItem("htmx-history-cache",JSON.stringify(i));break}catch(e){ae(ne().body,"htmx:historyCacheError",{cause:e,cache:i});i.shift()}}}function Bt(t){if(!V()){return null}t=j(t);const n=S(localStorage.getItem("htmx-history-cache"))||[];for(let e=0;e=200&&this.status<400){he(ne().body,"htmx:historyCacheMissLoad",i);const e=D(this.response);const t=e.querySelector("[hx-history-elt],[data-hx-history-elt]")||e;const n=Ft();const r=pn(n);In(e.title);je(n,t,r);$t(r.tasks);Xt=o;he(ne().body,"htmx:historyRestore",{path:o,cacheMiss:true,serverResponse:this.response})}else{ae(ne().body,"htmx:historyCacheMissLoadError",i)}};e.send()}function Kt(e){jt();e=e||location.pathname+location.search;const t=Bt(e);if(t){const n=D(t.content);const r=Ft();const o=pn(r);In(n.title);je(r,n,o);$t(o.tasks);E().setTimeout(function(){window.scrollTo(0,t.scroll)},0);Xt=e;he(ne().body,"htmx:historyRestore",{path:e,item:t})}else{if(Q.config.refreshOnHistoryMiss){window.location.reload(true)}else{Jt(e)}}}function Gt(e){let t=Se(e,"hx-indicator");if(t==null){t=[e]}se(t,function(e){const t=ie(e);t.requestCount=(t.requestCount||0)+1;e.classList.add.call(e.classList,Q.config.requestClass)});return t}function Zt(e){let t=Se(e,"hx-disabled-elt");if(t==null){t=[]}se(t,function(e){const t=ie(e);t.requestCount=(t.requestCount||0)+1;e.setAttribute("disabled","")});return t}function Wt(e,t){se(e,function(e){const t=ie(e);t.requestCount=(t.requestCount||0)-1;if(t.requestCount===0){e.classList.remove.call(e.classList,Q.config.requestClass)}});se(t,function(e){const t=ie(e);t.requestCount=(t.requestCount||0)-1;if(t.requestCount===0){e.removeAttribute("disabled")}})}function Yt(t,n){for(let e=0;en.indexOf(e)<0)}else{e=e.filter(e=>e!==n)}r.delete(t);se(e,e=>r.append(t,e))}}function nn(t,n,r,o,i){if(o==null||Yt(t,o)){return}else{t.push(o)}if(Qt(o)){const s=ee(o,"name");let e=o.value;if(o instanceof HTMLSelectElement&&o.multiple){e=F(o.querySelectorAll("option:checked")).map(function(e){return e.value})}if(o instanceof HTMLInputElement&&o.files){e=F(o.files)}en(s,e,n);if(i){rn(o,r)}}if(o instanceof HTMLFormElement){se(o.elements,function(e){if(t.indexOf(e)>=0){tn(e.name,e.value,n)}else{t.push(e)}if(i){rn(e,r)}});new FormData(o).forEach(function(e,t){en(t,e,n)})}}function rn(e,t){const n=e;if(n.willValidate){he(n,"htmx:validation:validate");if(!n.checkValidity()){t.push({elt:n,message:n.validationMessage,validity:n.validity});he(n,"htmx:validation:failed",{message:n.validationMessage,validity:n.validity})}}}function on(t,e){for(const n of e.keys()){t.delete(n);e.getAll(n).forEach(function(e){t.append(n,e)})}return t}function sn(e,t){const n=[];const r=new FormData;const o=new FormData;const i=[];const s=ie(e);if(s.lastButtonClicked&&!le(s.lastButtonClicked)){s.lastButtonClicked=null}let l=e instanceof HTMLFormElement&&e.noValidate!==true||te(e,"hx-validate")==="true";if(s.lastButtonClicked){l=l&&s.lastButtonClicked.formNoValidate!==true}if(t!=="get"){nn(n,o,i,g(e,"form"),l)}nn(n,r,i,e,l);if(s.lastButtonClicked||e.tagName==="BUTTON"||e.tagName==="INPUT"&&ee(e,"type")==="submit"){const c=s.lastButtonClicked||e;const f=ee(c,"name");en(f,c.value,o)}const u=Se(e,"hx-include");se(u,function(e){nn(n,r,i,ce(e),l);if(!a(e,"form")){se(h(e).querySelectorAll(it),function(e){nn(n,r,i,e,l)})}});on(r,o);return{errors:i,formData:r,values:qn(r)}}function ln(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 un(e){e=Hn(e);let n="";e.forEach(function(e,t){n=ln(n,t,e)});return n}function cn(e,t,n){const r={"HX-Request":"true","HX-Trigger":ee(e,"id"),"HX-Trigger-Name":ee(e,"name"),"HX-Target":te(t,"id"),"HX-Current-URL":ne().location.href};xn(e,"hx-headers",false,r);if(n!==undefined){r["HX-Prompt"]=n}if(ie(e).boosted){r["HX-Boosted"]="true"}return r}function fn(n,e){const t=re(e,"hx-params");if(t){if(t==="none"){return new FormData}else if(t==="*"){return n}else if(t.indexOf("not ")===0){se(t.substr(4).split(","),function(e){e=e.trim();n.delete(e)});return n}else{const r=new FormData;se(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 an(e){return!!ee(e,"href")&&ee(e,"href").indexOf("#")>=0}function hn(e,t){const n=t||re(e,"hx-swap");const r={swapStyle:ie(e).boosted?"innerHTML":Q.config.defaultSwapStyle,swapDelay:Q.config.defaultSwapDelay,settleDelay:Q.config.defaultSettleDelay};if(Q.config.scrollIntoViewOnBoost&&ie(e).boosted&&!an(e)){r.show="top"}if(n){const s=B(n);if(s.length>0){for(let e=0;e0?o.join(":"):null;r.scroll=c;r.scrollTarget=i}else if(l.indexOf("show:")===0){const f=l.substr(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.substr("focus-scroll:".length);r.focusScroll=h=="true"}else if(e==0){r.swapStyle=l}else{w("Unknown modifier in hx-swap: "+l)}}}}return r}function dn(e){return re(e,"hx-encoding")==="multipart/form-data"||a(e,"form")&&ee(e,"enctype")==="multipart/form-data"}function gn(t,n,r){let o=null;Mt(n,function(e){if(o==null){o=e.encodeParameters(t,r,n)}});if(o!=null){return o}else{if(dn(n)){return Hn(r)}else{return un(r)}}}function pn(e){return{tasks:[],elts:[e]}}function mn(e,t){const n=e[0];const r=e[e.length-1];if(t.scroll){var o=null;if(t.scrollTarget){o=ce(fe(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(t.show){var o=null;if(t.showTarget){let e=t.showTarget;if(t.showTarget==="window"){e="body"}o=ce(fe(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 xn(r,e,o,i){if(i==null){i={}}if(r==null){return i}const s=te(r,e);if(s){let e=s.trim();let t=o;if(e==="unset"){return null}if(e.indexOf("javascript:")===0){e=e.substr(11);t=true}else if(e.indexOf("js:")===0){e=e.substr(3);t=true}if(e.indexOf("{")!==0){e="{"+e+"}"}let n;if(t){n=yn(r,function(){return Function("return ("+e+")")()},{})}else{n=S(e)}for(const l in n){if(n.hasOwnProperty(l)){if(i[l]==null){i[l]=n[l]}}}}return xn(ce(u(r)),e,o,i)}function yn(e,t,n){if(Q.config.allowEval){return t()}else{ae(e,"htmx:evalDisallowedError");return n}}function bn(e,t){return xn(e,"hx-vars",true,t)}function wn(e,t){return xn(e,"hx-vals",false,t)}function vn(e){return ue(bn(e),wn(e))}function Sn(t,n,r){if(r!==null){try{t.setRequestHeader(n,r)}catch(e){t.setRequestHeader(n,encodeURIComponent(r));t.setRequestHeader(n+"-URI-AutoEncoded","true")}}}function En(t){if(t.responseURL&&typeof URL!=="undefined"){try{const e=new URL(t.responseURL);return e.pathname+e.search}catch(e){ae(ne().body,"htmx:badResponseUrl",{url:t.responseURL})}}}function C(e,t){return t.test(e.getAllResponseHeaders())}function Cn(e,t,n){e=e.toLowerCase();if(n){if(n instanceof Element||typeof n==="string"){return de(e,t,null,null,{targetOverride:x(n),returnPromise:true})}else{return de(e,t,x(n.source),n.event,{handler:n.handler,headers:n.headers,values:n.values,targetOverride:x(n.target),swapOverride:n.swap,select:n.select,returnPromise:true})}}else{return de(e,t,null,null,{returnPromise:true})}}function Rn(e){const t=[];while(e){t.push(e);e=e.parentElement}return t}function On(e,t,n){let r;let o;if(typeof URL==="function"){o=new URL(t,document.location.href);const i=document.location.origin;r=i===o.origin}else{o=t;r=l(t,document.location.origin)}if(Q.config.selfRequestsOnly){if(!r){return false}}return he(e,"htmx:validateUrl",ue({url:o,sameHost:r},n))}function Hn(e){if(e instanceof FormData)return e;const t=new FormData;for(const n in e){if(e.hasOwnProperty(n)){if(typeof e[n].forEach==="function"){e[n].forEach(function(e){t.append(n,e)})}else if(typeof e[n]==="object"){t.append(n,JSON.stringify(e[n]))}else{t.append(n,e[n])}}}return t}function Tn(r,o,e){return new Proxy(e,{get:function(t,e){if(typeof e==="number")return t[e];if(e==="length")return t.length;if(e==="push"){return function(e){t.push(e);r.append(o,e)}}if(typeof t[e]==="function"){return function(){t[e].apply(t,arguments);r.delete(o);t.forEach(function(e){r.append(o,e)})}}if(t[e]&&t[e].length===1){return t[e][0]}else{return t[e]}},set:function(e,t,n){e[t]=n;r.delete(o);e.forEach(function(e){r.append(o,e)});return true}})}function qn(r){return new Proxy(r,{get:function(e,t){if(typeof t==="symbol"){return Reflect.get(e,t)}if(t==="toJSON"){return()=>Object.fromEntries(r)}if(t in e){if(typeof e[t]==="function"){return function(){return r[t].apply(r,arguments)}}else{return e[t]}}const n=r.getAll(t);if(n.length===0){return undefined}else if(n.length===1){return n[0]}else{return Tn(e,t,n)}},set:function(t,n,e){if(typeof n!=="string"){return false}t.delete(n);if(typeof e.forEach==="function"){e.forEach(function(e){t.append(n,e)})}else{t.append(n,e)}return true},deleteProperty:function(e,t){if(typeof t==="string"){e.delete(t)}return true},ownKeys:function(e){return Reflect.ownKeys(Object.fromEntries(e))},getOwnPropertyDescriptor:function(e,t){return Reflect.getOwnPropertyDescriptor(Object.fromEntries(e),t)}})}function de(t,n,r,o,i,D){let s=null;let l=null;i=i!=null?i:{};if(i.returnPromise&&typeof Promise!=="undefined"){var e=new Promise(function(e,t){s=e;l=t})}if(r==null){r=ne().body}const M=i.handler||Pn;const X=i.select||null;if(!le(r)){oe(s);return e}const u=i.targetOverride||ce(Ce(r));if(u==null||u==ve){ae(r,"htmx:targetError",{target:te(r,"hx-target")});oe(l);return e}let c=ie(r);const f=c.lastButtonClicked;if(f){const L=ee(f,"formaction");if(L!=null){n=L}const A=ee(f,"formmethod");if(A!=null){if(A.toLowerCase()!=="dialog"){t=A}}}const a=re(r,"hx-confirm");if(D===undefined){const K=function(e){return de(t,n,r,o,i,!!e)};const G={target:u,elt:r,path:n,verb:t,triggeringEvent:o,etc:i,issueRequest:K,question:a};if(he(r,"htmx:confirm",G)===false){oe(s);return e}}let h=r;let d=re(r,"hx-sync");let g=null;let F=false;if(d){const N=d.split(":");const I=N[0].trim();if(I==="this"){h=Ee(r,"hx-sync")}else{h=ce(fe(r,I))}d=(N[1]||"drop").trim();c=ie(h);if(d==="drop"&&c.xhr&&c.abortable!==true){oe(s);return e}else if(d==="abort"){if(c.xhr){oe(s);return e}else{F=true}}else if(d==="replace"){he(h,"htmx:abort")}else if(d.indexOf("queue")===0){const Z=d.split(" ");g=(Z[1]||"last").trim()}}if(c.xhr){if(c.abortable){he(h,"htmx:abort")}else{if(g==null){if(o){const P=ie(o);if(P&&P.triggerSpec&&P.triggerSpec.queue){g=P.triggerSpec.queue}}if(g==null){g="last"}}if(c.queuedRequests==null){c.queuedRequests=[]}if(g==="first"&&c.queuedRequests.length===0){c.queuedRequests.push(function(){de(t,n,r,o,i)})}else if(g==="all"){c.queuedRequests.push(function(){de(t,n,r,o,i)})}else if(g==="last"){c.queuedRequests=[];c.queuedRequests.push(function(){de(t,n,r,o,i)})}oe(s);return e}}const p=new XMLHttpRequest;c.xhr=p;c.abortable=F;const m=function(){c.xhr=null;c.abortable=false;if(c.queuedRequests!=null&&c.queuedRequests.length>0){const e=c.queuedRequests.shift();e()}};const U=re(r,"hx-prompt");if(U){var x=prompt(U);if(x===null||!he(r,"htmx:prompt",{prompt:x,target:u})){oe(s);m();return e}}if(a&&!D){if(!confirm(a)){oe(s);m();return e}}let y=cn(r,u,x);if(t!=="get"&&!dn(r)){y["Content-Type"]="application/x-www-form-urlencoded"}if(i.headers){y=ue(y,i.headers)}const B=sn(r,t);let b=B.errors;const V=B.formData;if(i.values){on(V,Hn(i.values))}const j=Hn(vn(r));const w=on(V,j);let v=fn(w,r);if(Q.config.getCacheBusterParam&&t==="get"){v.set("org.htmx.cache-buster",ee(u,"id")||"true")}if(n==null||n===""){n=ne().location.href}const S=xn(r,"hx-request");const _=ie(r).boosted;let E=Q.config.methodsThatUseUrlParams.indexOf(t)>=0;const C={boosted:_,useUrlParams:E,formData:v,parameters:qn(v),unfilteredFormData:w,unfilteredParameters:qn(w),headers:y,target:u,verb:t,errors:b,withCredentials:i.credentials||S.credentials||Q.config.withCredentials,timeout:i.timeout||S.timeout||Q.config.timeout,path:n,triggeringEvent:o};if(!he(r,"htmx:configRequest",C)){oe(s);m();return e}n=C.path;t=C.verb;y=C.headers;v=Hn(C.parameters);b=C.errors;E=C.useUrlParams;if(b&&b.length>0){he(r,"htmx:validation:halted",C);oe(s);m();return e}const z=n.split("#");const $=z[0];const R=z[1];let O=n;if(E){O=$;const W=!v.keys().next().done;if(W){if(O.indexOf("?")<0){O+="?"}else{O+="&"}O+=un(v);if(R){O+="#"+R}}}if(!On(r,O,C)){ae(r,"htmx:invalidPath",C);oe(l);return e}p.open(t.toUpperCase(),O,true);p.overrideMimeType("text/html");p.withCredentials=C.withCredentials;p.timeout=C.timeout;if(S.noHeaders){}else{for(const k in y){if(y.hasOwnProperty(k)){const Y=y[k];Sn(p,k,Y)}}}const H={xhr:p,target:u,requestConfig:C,etc:i,boosted:_,select:X,pathInfo:{requestPath:n,finalRequestPath:O,responsePath:null,anchor:R}};p.onload=function(){try{const t=Rn(r);H.pathInfo.responsePath=En(p);M(r,H);Wt(T,q);he(r,"htmx:afterRequest",H);he(r,"htmx:afterOnLoad",H);if(!le(r)){let e=null;while(t.length>0&&e==null){const n=t.shift();if(le(n)){e=n}}if(e){he(e,"htmx:afterRequest",H);he(e,"htmx:afterOnLoad",H)}}oe(s);m()}catch(e){ae(r,"htmx:onLoadError",ue({error:e},H));throw e}};p.onerror=function(){Wt(T,q);ae(r,"htmx:afterRequest",H);ae(r,"htmx:sendError",H);oe(l);m()};p.onabort=function(){Wt(T,q);ae(r,"htmx:afterRequest",H);ae(r,"htmx:sendAbort",H);oe(l);m()};p.ontimeout=function(){Wt(T,q);ae(r,"htmx:afterRequest",H);ae(r,"htmx:timeout",H);oe(l);m()};if(!he(r,"htmx:beforeRequest",H)){oe(s);m();return e}var T=Gt(r);var q=Zt(r);se(["loadstart","loadend","progress","abort"],function(t){se([p,p.upload],function(e){e.addEventListener(t,function(e){he(r,"htmx:xhr:"+t,{lengthComputable:e.lengthComputable,loaded:e.loaded,total:e.total})})})});he(r,"htmx:beforeSend",H);const J=E?null:gn(p,r,v);p.send(J);return e}function Ln(e,t){const n=t.xhr;let r=null;let o=null;if(C(n,/HX-Push:/i)){r=n.getResponseHeader("HX-Push");o="push"}else if(C(n,/HX-Push-Url:/i)){r=n.getResponseHeader("HX-Push-Url");o="push"}else if(C(n,/HX-Replace-Url:/i)){r=n.getResponseHeader("HX-Replace-Url");o="replace"}if(r){if(r==="false"){return{}}else{return{type:o,path:r}}}const i=t.pathInfo.finalRequestPath;const s=t.pathInfo.responsePath;const l=re(e,"hx-push-url");const u=re(e,"hx-replace-url");const c=ie(e).boosted;let f=null;let a=null;if(l){f="push";a=l}else if(u){f="replace";a=u}else if(c){f="push";a=s||i}if(a){if(a==="false"){return{}}if(a==="true"){a=s||i}if(t.pathInfo.anchor&&a.indexOf("#")===-1){a=a+"#"+t.pathInfo.anchor}return{type:f,path:a}}else{return{}}}function An(e,t){var n=new RegExp(e.code);return n.test(t.toString(10))}function Nn(e){for(var t=0;t0){E().setTimeout(e,x.swapDelay)}else{e()}}if(a){ae(o,"htmx:responseError",ue({error:"Response Status Error Code "+s.status+" from "+i.pathInfo.requestPath},i))}}const kn={};function Dn(){return{init:function(e){return null},onEvent:function(e,t){return true},transformResponse:function(e,t,n){return e},isInlineSwap:function(e){return false},handleSwap:function(e,t,n,r){return false},encodeParameters:function(e,t,n){return null}}}function Mn(e,t){if(t.init){t.init(n)}kn[e]=ue(Dn(),t)}function Xn(e){delete kn[e]}function Fn(e,n,r){if(n==undefined){n=[]}if(e==undefined){return n}if(r==undefined){r=[]}const t=te(e,"hx-ext");if(t){se(t.split(","),function(e){e=e.replace(/ /g,"");if(e.slice(0,7)=="ignore:"){r.push(e.slice(7));return}if(r.indexOf(e)<0){const t=kn[e];if(t&&n.indexOf(t)<0){n.push(t)}}})}return Fn(ce(u(e)),n,r)}var Un=false;ne().addEventListener("DOMContentLoaded",function(){Un=true});function Bn(e){if(Un||ne().readyState==="complete"){e()}else{ne().addEventListener("DOMContentLoaded",e)}}function Vn(){if(Q.config.includeIndicatorStyles!==false){ne().head.insertAdjacentHTML("beforeend","")}}function jn(){const e=ne().querySelector('meta[name="htmx-config"]');if(e){return S(e.content)}else{return null}}function _n(){const e=jn();if(e){Q.config=ue(Q.config,e)}}Bn(function(){_n();Vn();let e=ne().body;It(e);const t=ne().querySelectorAll("[hx-trigger='restored'],[data-hx-trigger='restored']");e.addEventListener("htmx:abort",function(e){const t=e.target;const n=ie(t);if(n&&n.xhr){n.xhr.abort()}});const n=window.onpopstate?window.onpopstate.bind(window):null;window.onpopstate=function(e){if(e.state&&e.state.htmx){Kt();se(t,function(e){he(e,"htmx:restored",{document:ne(),triggerEvent:he})})}else{if(n){n(e)}}};E().setTimeout(function(){he(e,"htmx:load",{});e=null},0)});return Q}(); \ No newline at end of file diff --git a/dist/htmx.min.js.gz b/dist/htmx.min.js.gz index 62835452277cdb4df9bc617430f42fda2d6ab8c7..8b79eef39bcc0726e4c4ef459297a977441f2582 100644 GIT binary patch delta 4132 zcmV+<5ZmwAdDwXeABzYG53c;N2i`1yUx@x0nWSA2Y2`Wa_%hDQx=oX{T3fw|1)ZTl zXMqkj54~Bs%5Fr!7VT}mT&QxFYB`Ux;B6LZ*buAb18&M1Cc^J#u-MMmIsMAcgsS7A z&ijmG&a#QoJASN+C}G;!veA|7e}B8(=7!Yi+$bhdgTwBPjJ)aiVGKvA!Y z?0RNtqD=rX-=j}Hv@&W+jpEu9X@@@&cM}B zYPaAj(VQ)&@Gm2kkStZHllCC2uL06EHbW9clyEGjp^4VoJ>ISXd-LwDvnpwmy)>4O@0q&4+RImuKc_1d4P*(7+ZCNtx7e%H9Ht zH>?_#wr_3tN*|sL3m==KYL)8&gWq_d*ti&VJW%YtKz1Te4QJn2eLw4eUQw}?Y`7*V z@RWXL+b`b`mSNG@Y6o1anCz}64~C9O%$JBj_ySYAzCjafjN0PAJJ)(@O)f6Z(3IXZ ztXW{nW1`jN8K&9fBdAC1hd_d3V8tP2Vq#)*@7PmgdD}0FU?FUvxPigLnJ2)ku~jYU zDe>~SR}52XF%0$$t-;NIfNk2CN>3dAh4kjrb@T+n3dI@2=EKGG(zy&qA|5i5Fp`Du ztVABbtxc>No7i|Sk7()o=Hjd@+zK9wDWX2SN!a4hJ}OosxY>gJIDM|)fxtKzyAr@q z)P0V}q}++IV648rWrm5w;L^NvmA7*t;>8A6*7mreES2Gtw1!20(-*ltVzO&5Wpg8s zr3+V7hi5{Dr$Tl;Y{=NmR~~t*au>3AFs5iE`T&w}j|NqJ1q{rnh0_j)t(8~udvQ|_ zJJhKLW^|E$2V5X+nBZ0HaOZ2mOa$;h;n3QU*jcN)8+yymI~o(=6xhjYzAbC!K3T)X zjA)uO>;EDjvOjo#J_s&yOBL$xCS{0BEz^X$KtqpEr(#s#Lm(limO49o2Ico@ZpfS4 z+YeG-O+P^@lO({rYQ`B=dg%O9Qji*}=rDq{d=Sz;x3|EQ?63zo2Y_TXKK!_3lC(0> zHmIJl(AMF*l+gap_7TB&1U(mC&$ygp)I(Yii)lJ;>%*{r_o<RJo%{4-T7B^{vf}@4x50HaSao!)|mK7cH5ol085HleE9jVg4s@o+BGTmEdMZZB8gaW<^q)@!)z^ z;h*fRtQ1-z*(h|485@*NwW%~mFQ67WOE2H(h&@4nRc){wk&VO5`08nNc*t9{=tvM)cE9h zmhtjD?MS8}*$&QA9KH{j-i92~+cYmaPmkj9+s zj%9bTt3}!>VuFy;Qx|$LA07IbvwoNW?IYiL*C{8$H>O^v=3ZIzP?oNjEcwUq+60AM ztn3AbSimhDM&?6@KxPd!%Ijx$ltv_Wla7&pn^`2+=20284uMuCk}k@dlSsdrvWc(s zpb8s_%$zyZt?SLJtE)}YGyq#EwA_f_($L}sXd?x-^CodAdW&DBHTJF;x1Oc1*h$g2 z`uqS1#&&{<3zkp7bY%aB1o%{&Vp{waEfg+kYRK_0@so#5ol&YCI;pm7IwZgdrFd@$U5?b1_wOIqm;zd5k+%i8wfN0 z&rBN_bu7(d*Lg_son9Z$GWC&!U^M#LqFRMYYu(gNy40-Dr~X;G>t=;LoI#ggAdB z9X!}b;V0j?2W+_ne-;QpSnZHY{3Y5rToIyLJ3xp(ptbeL=v>lVKftn@Ir`M{oE?i4 zP^=$;fzuQ#G{Y`NkgW;#_ps%Eh_Cwe3e*;~4R;>oHy{Xhp^*Y*OsL--^9v_%G?3+6 zgV1y+Lo4h0f}A@`t}oV@_viHH6A1Idn3Z)2ZH({VxEQxeLH zQ!m1Y(j@6WZ8-NrXlrkdP8q(V*)<%|J)G6bp0Yp_VMbp{&u_^^F96Q}Evi{&Re6PX zEv+wQ`3r1TD!XT;ygc-OhtfU0H75hdMU4}U^CugBNn~?J=|K7@~Fw{;oL6 zUvN@*b&hC8Zw*@iF5P{B=U{k_Xr)Rn5zCS1+;?$@A?LfM)f&>t99Y}2w$9FAr!SK& zv~dIyez=7%l;Cr{?WdO_T_(by4=kp({DR-cCR}(AX$Q;Q*VZ93oDXTvE6ObzW_87p zl})T~c9piqCxP65bctfDVaWtUW$|{7Pvjbe*u=Oa_X2n)(zI`oI7?5Q_=1LMMCXbGhte z4LX>Rt>n$0FP!!DtogzrzSESY*#;5_t@0~>6Q;ZgS-3xczLNK)2603U90li4obO)G z>B+*0@L~aw`WI;lZD9Rm+t-8b^J~d)$zx0WuA}EDrvVM6j!-vv?~!}Hv+Ri?jn7N6 z_|*=@UVH|lb0VwJp;qg;AV*d^=h+Gam4kMLk&7s24NFrkx6!VkR@canT?&8UKA<;F z?!6gnaYJE$1*6uFIUfK`GIDZLrbrAzF9Vciu2VRu`Wag~$~7HjZOF~X_&W+;?3sNh z>=b1RzthYUm;Ti~QB~h@`b~w1uL?D4naZ$4MUhF%Na)i#GB0w|*J?-hi50}ys_{V0 z&D&nh4R8M<^Q_{55_|niAHmN58Sc!JFUe$b+G{G0A8RdXj#w7MKL)d{ML*gFi-ND zsN7+e_?FZ&&GcC7lgSDJfVM_(Y&66?_?#r0zFhd&hO+`XiXIbng^KjT;J7*b3`Yfb z;Ke|XYc#{(9! z^FQL{f}TTqkAbd(w?@bbBa<}>Zp|a=5<1 zJNi&v2e$6BRdMHYui@jd-phd=LCSQ>1Zb0R63hY9G$!{=gCB}B0>T?4sY=$jP>z0o z6q|F;nz`2Jw!s#A>-)8cIv?lc%}30kj_WWSBj|d&WiqBqC+-RifrZ2b?P7K7 zCN>1uG3xE#?`=dAe9+8YjjSHwX_+V2$x^TL>VmKbTX%cg{%7ttXUyA4FxE~RyMw9Kun>>$C&`M|db zzOUPzGK-S10Y;;cdGjGG+Vm%XxvO*iaH6zhBv{7bta&&54eZly0NM7JV1-92e z(P%YEPsLmwh6c43*D^3Ha7ham;!cE|#mg zkYxXeF%}42tr#`Avab$P{y$=$Xs^P+7M4|{*^l_ROHWILWpv1RGzD^h&i8M$UA~B8 zS|%b0K1!`gC9KyD*8Te6y;d5&BiUB)Xb4o+5AM21g@&p9D0L9c3hwY53V_D%gI>&W z^U%`D*!VxV>mcar4;srmCV<_=_e_K%^6#qGtc?hDgE}232{fU4Ir$ZKNGjy5`w^o_ zmN7o7vFh_4{ToCZUKhH5ZK88FqGdVH#u!v#d(|%NN8kZ$@t}5|jC!8)VoxXco^Een z)IE{aVl$VculDu7-qo`$UXdV3^RM#$u&a;pg|rijv%}#hc|;h)P`_iZ0rQCDIUK($ zbn^{E=YRG)#NKr?X0C`a%x{8~S0QtcH4thvA!zUU(ViE%Ri$5le>(^t2cmdhT~7!3 znNfEHe9y9_Ga{1+MKpdKay;u~Gedva9->d~d#0=w50!FW&he@eFIp*sGf2@fskMh@ zt4#B)H5PB-Ta)~Q^yl&NdlcNXLQ8pC7_%5anVL(V-1Uv_mhZQjSjAp2G<<}CqnX_k ilFjQxzss^hu@7GpoZFtc@IO~D#{UOh-4dwGy#N4WSRShY delta 4132 zcmV+<5ZmwAdDwXeABzYGnIZDA2i`1y2TZsS{WG#kyCUk!D|zJ0IVkIhGmtsUCPw%8u_~g3?T7rPLxivs?3;;tqxs~Y(|cEcr}Gg- zy)LrrsilcF1H`bW^q+nL>EKdSRX!2JYiK&*!pLgowe_#_uTtF%6xOcaaUyjH^(8w5 zS3{{?gR4Yyx0u4ejATNxWTj5pgRuSvNZZ&9NmNn7@tB4tVr%z!y9VsdySt9_SdopW zb2^As?1Z|g7Y@VecE}J9WbhP!ui`um?$x?#xHv;| zdeg9GgDH;*SC?lPXOoYh9366mkiIj7t?F!G8l%XJv1)8$4fYQwxX3M4sK1+(Au_g16Y2sDT|%9TQGt(vgxp%{Z0#A8->11D zZ*FftNPRW^1gT7t00XO;XH@H<15inUYOJ!u2-osKNc-I00%NknUf>)Al2!Tea*k0KX}v6_>A0H*%~EFwWf>c%#Ega2R%;#(p|! zi#_+!{V>M=p7-M9EZq&e(V<+lbf!x700m6a{yvBLpTK#JY!Fp~n;Eq^p&*$RNp8l2 z>sf_=va_;MXpLke(KTjlP&(D7(j38nTIejje50d(_5@Y6(Q-s~4m0Dg$L+b2PD;Ts zBm+_HFK+32uyp5X{}-Mz9tAsPqAK+0=$D=1on4b7XX>Ec8b5!~F@_-R!}|IMKOR%# zlVe)O%k#7&nTBLLI8S-NdZ1KdV#s#;yhk&g13R6w6<1X&+QhI-a5uLyn{Uba2hAss zsf(3rmEeELS8vkTvdn+tM)2(PR?vduvn zld?OO-NmmKX{(3{L`u(H=)rt+=wr@0Vgj^}eCJ)KoCx2TdYzhkWz9obx?Zy6AH!=C z7;>?)7Z_pzw{RGp51j&;HPk4tpWRU!k=RXtI!110kzAXHW!ORlTA4_?C~r<8{cg%8 zzSM(iY$P&s=2W+?H?OX)Hc8t6Y^Bh0BYsaqix;4c6xhz2#HHvhewEhPyJFmWmcC*~ zMdR-C10)#x2_`OBJ^|B_{T~wGQ*DZA@z?ZHx|{SWrGme5`&NRXjY-pS~srq#T#J@)AD;<*#BZT)MG;z-q2=Z4z^qU|^FSs0$zkR7O3_(XrTk-QFIB zpLVv5YKacY3f1*5tZIL{khq*;=!q5~Vc(ApD1~$DVY1VGdStpovdWQyA2`F&4gAov zA6=rc3>Gk}6OYayTSNCQ{Pec~M{u^je&*pCZ#1{)qx5&DBRhnTC;V>1K}u?Y-FSJBJ~D4bq-&Sjf{$KegFll}64LyU5X*tP$6rJg zcJN>$g`a%e9s)d{Q%2q=IB$(b9O9J zK&^fR=1o(p&aLF`<5U%rBh4(Lk1O z4KmZA46U5&3v%r&jk{^exxQFq-k;N(lP{;EBiWxPUy`5QJ0EY;B|2Em-FdOr@(72+ z9Zl)F)2qd;KM_ci>-JJt`M@v^ba+-AdPxU~k%)5%l(_N(F+f3?oZ{W99`>7DGBAp zsTbixX_EAxHk^AQw6!-!rwrfG>>7^f9?oiIPg$UaFrzP}=eOjd7Xa7)7F8^>s=UH` zme!ZD`~@~EmEE&aULN{?L+PI0nv;R!qQ;57`IC*mB$BzKadRU6{pNKG&Bhyemt9f4 zCOYvhQcuU}w-l5BfB%;LLcakOoKUbet&XPOq%w|xd^!h+t>Gv01*d`O8P=R9^TA?{ zRZbg@l&$bRs`)0k89$!lXhS7S22<3xEr{qG8iNFvlyHng%%LBDi7HiA3{kTLe^(sk zFE}Z@I!834w+5|$m+rp6b1*zdv{EIPh~>z0?z_0dkn>&BY7J>*4y^6iT4!gl)0fE> z+BgFFKHS0=O7OYf_R~v|E)!wU2NqFVUcql;6E3`mw1egDYwM7i&4)DS73CHUqq^eA z$|lw~yGmQ*lR##Fx1I73YvF>K1XX|r%UAq*pnXrHxm@6)_ma*-)YLyYy$~|R{52`2~*yLEZiS|U%~rQgE*oFj)HS2&Udfp z^km^gc(DLT^^3HGHn4uO?d!ny`L$%YN*=Sc#t7qiLE``5vAJ7{o z_uh=PxS_CrLQ(6-oDYB|89A9LQzQnVmjTK$*C`xS{fsRg<(iJNHst1G{2hfa_RPK$ zc8W5E-)ZKFOaJPgsH*Qc{iZ_1SA`n2Ol4S_qR6CWB=l(=nHRa~YqcZ$#0p|;)p($0 z=!D>|!q3XLf3}(xGv-5f&BY<3v&LOmiV8KHK3o%jle|KLkER`Pkm=nmavhA!w7%YS z0rq2?ORvd}Y&Qr^p3)%5+V`%Wji}oba_06$8ZD7C-z?-TldrdiE_Mdx{o054Dsw5(_4qL>^Jerv`Lm?wEn zRPHcKd`s$?W_qmU$z+89KwBd?HX33cd`^E;ii11NO8_GmO%IvlwHfvgx8o*GQgqF>q_4_n0pP*vY5= z`5*CeLC+z*$3WM?TO;Izk;xhbH)fPT0M?0l8gxwVy^JLP-16%jms<`vH*YNRJ@8v*`AZ0pb0<=ju3Fd%l8k75`!4Jh5;ouFDR3+^6Wa`G8xmQ6L$rMz(QhzcCos3 z6B~l-7}fUg_co#lK4|8yMplpTw9J$1WU1GAa(jE0*oUu&H;H|Tc9KjoHjV>T1 z_qjsLG!kAgRL&O+0_g%4zIKK_ON_MHWlzG-i|7!F-NqqolhV37TBcT3c93A?eBfII z-`DLSgBrkBG0^94K zXtbK7r(!M-LxWmtYZ(|ZNUf621R*afl*;j`t{~xhWv{zwZ3(G3f>_>durKcsrGCE{DngKa~=leI>E?>kk zEfWz0AEnl!64q-6>wbOkUMmdWk!&k?Gz2Q^2X|ehLc`R4lsbrJ1$X!j1wiBXK`-XG zd1z&2Z2TYGbr5v*2aV+&6Tt4`dnUpW`FGW8);@%~L7fhi1e#F2ocszqBo*@3{fN;d z%NU>4SoL|2{tcoHuM6FOHqkj7(XyOpV+^XWy=oWsBk%yWcu+e}Mm^7Yv8R)JPq()( z>Ym7Iv6;)!SNr;3@9NnWuSgK2`B!;=*wx4QLfQ$%+2Qb$JR*!?sNb>IfO$mn9FE@= zy7`8o^FR9?V(+>cGgrhI<~PC0tB|?J8VEI-5VZIFXwQq>s?x82za4~+15rG$uBU_i z%&0p8zGv0a8IehZA{svqIi7X0m!Usw3(+U{JyTYThe|mw=Xh0#7p;`R8Kmf#)Y?O{ zRi^pY8jH8^tx5ht`tx}CJqm7Gp`|=6j9CnzOwFZF?)pY|%lF$%tYR-18a~3n(ai1% i$>w#U-(^{$*oQ9@&TY?B_@65n 1) { - var operation = split[0]; - var classDef = split[1].trim(); - var cssClass; - var delay; - if (classDef.indexOf(":") > 0) { - var splitCssClass = classDef.split(':'); - cssClass = splitCssClass[0]; - delay = htmx.parseInterval(splitCssClass[1]); - } else { - cssClass = classDef; - delay = 100; - } - return { - operation: operation, - cssClass: cssClass, - delay: delay - } - } else { - return null; - } - } - - function performOperation(elt, classOperation, classList, currentRunTime) { - setTimeout(function () { - elt.classList[classOperation.operation].call(elt.classList, classOperation.cssClass); - }, currentRunTime) - } - - function toggleOperation(elt, classOperation, classList, currentRunTime) { - setTimeout(function () { - setInterval(function () { - elt.classList[classOperation.operation].call(elt.classList, classOperation.cssClass); - }, classOperation.delay); - }, currentRunTime) - } - - function processClassList(elt, classList) { - var runs = classList.split("&"); - for (var i = 0; i < runs.length; i++) { - var run = runs[i]; - var currentRunTime = 0; - var classOperations = run.split(","); - for (var j = 0; j < classOperations.length; j++) { - var value = classOperations[j]; - var trimmedValue = value.trim(); - var classOperation = parseClassOperation(trimmedValue); - if (classOperation) { - if (classOperation.operation === "toggle") { - toggleOperation(elt, classOperation, classList, currentRunTime); - currentRunTime = currentRunTime + classOperation.delay; - } else { - currentRunTime = currentRunTime + classOperation.delay; - performOperation(elt, classOperation, classList, currentRunTime); - } - } - } - } - } - - function maybeProcessClasses(elt) { - if (elt.getAttribute) { - var classList = elt.getAttribute("classes") || elt.getAttribute("data-classes"); - if (classList) { - processClassList(elt, classList); - } - } - } - - htmx.defineExtension('class-tools', { - onEvent: function (name, evt) { - if (name === "htmx:afterProcessNode") { - var elt = evt.detail.elt; - maybeProcessClasses(elt); - if (elt.querySelectorAll) { - var children = elt.querySelectorAll("[classes], [data-classes]"); - for (var i = 0; i < children.length; i++) { - maybeProcessClasses(children[i]); - } - } - } - } - }); -})(); \ No newline at end of file diff --git a/www/static/src/ext/client-side-templates.js b/www/static/src/ext/client-side-templates.js deleted file mode 100644 index 2bace419..00000000 --- a/www/static/src/ext/client-side-templates.js +++ /dev/null @@ -1,96 +0,0 @@ -htmx.defineExtension('client-side-templates', { - transformResponse : function(text, xhr, elt) { - - var mustacheTemplate = htmx.closest(elt, "[mustache-template]"); - if (mustacheTemplate) { - var data = JSON.parse(text); - var templateId = mustacheTemplate.getAttribute('mustache-template'); - var template = htmx.find("#" + templateId); - if (template) { - return Mustache.render(template.innerHTML, data); - } else { - throw "Unknown mustache template: " + templateId; - } - } - - var mustacheArrayTemplate = htmx.closest(elt, "[mustache-array-template]"); - if (mustacheArrayTemplate) { - var data = JSON.parse(text); - var templateId = mustacheArrayTemplate.getAttribute('mustache-array-template'); - var template = htmx.find("#" + templateId); - if (template) { - return Mustache.render(template.innerHTML, {"data": data }); - } else { - throw "Unknown mustache template: " + templateId; - } - } - - var handlebarsTemplate = htmx.closest(elt, "[handlebars-template]"); - if (handlebarsTemplate) { - var data = JSON.parse(text); - var templateId = handlebarsTemplate.getAttribute('handlebars-template'); - var templateElement = htmx.find('#' + templateId).innerHTML; - var renderTemplate = Handlebars.compile(templateElement); - if (renderTemplate) { - return renderTemplate(data); - } else { - throw "Unknown handlebars template: " + templateId; - } - } - - var handlebarsArrayTemplate = htmx.closest(elt, "[handlebars-array-template]"); - if (handlebarsArrayTemplate) { - var data = JSON.parse(text); - var templateId = handlebarsArrayTemplate.getAttribute('handlebars-array-template'); - var templateElement = htmx.find('#' + templateId).innerHTML; - var renderTemplate = Handlebars.compile(templateElement); - if (renderTemplate) { - return renderTemplate(data); - } else { - throw "Unknown handlebars template: " + templateId; - } - } - - var nunjucksTemplate = htmx.closest(elt, "[nunjucks-template]"); - if (nunjucksTemplate) { - var data = JSON.parse(text); - var templateName = nunjucksTemplate.getAttribute('nunjucks-template'); - var template = htmx.find('#' + templateName); - if (template) { - return nunjucks.renderString(template.innerHTML, data); - } else { - return nunjucks.render(templateName, data); - } - } - - var xsltTemplate = htmx.closest(elt, "[xslt-template]"); - if (xsltTemplate) { - var templateId = xsltTemplate.getAttribute('xslt-template'); - var template = htmx.find("#" + templateId); - if (template) { - var content = template.innerHTML ? new DOMParser().parseFromString(template.innerHTML, 'application/xml') - : template.contentDocument; - var processor = new XSLTProcessor(); - processor.importStylesheet(content); - var data = new DOMParser().parseFromString(text, "application/xml"); - var frag = processor.transformToFragment(data, document); - return new XMLSerializer().serializeToString(frag); - } else { - throw "Unknown XSLT template: " + templateId; - } - } - - var nunjucksArrayTemplate = htmx.closest(elt, "[nunjucks-array-template]"); - if (nunjucksArrayTemplate) { - var data = JSON.parse(text); - var templateName = nunjucksArrayTemplate.getAttribute('nunjucks-array-template'); - var template = htmx.find('#' + templateName); - if (template) { - return nunjucks.renderString(template.innerHTML, {"data": data}); - } else { - return nunjucks.render(templateName, {"data": data}); - } - } - return text; - } -}); diff --git a/www/static/src/ext/debug.js b/www/static/src/ext/debug.js deleted file mode 100644 index 861ee743..00000000 --- a/www/static/src/ext/debug.js +++ /dev/null @@ -1,11 +0,0 @@ -htmx.defineExtension('debug', { - onEvent: function (name, evt) { - if (console.debug) { - console.debug(name, evt); - } else if (console) { - console.log("DEBUG:", name, evt); - } else { - throw "NO CONSOLE SUPPORTED" - } - } -}); diff --git a/www/static/src/ext/disable-element.js b/www/static/src/ext/disable-element.js deleted file mode 100644 index 07bef62d..00000000 --- a/www/static/src/ext/disable-element.js +++ /dev/null @@ -1,18 +0,0 @@ -"use strict"; - -// Disable Submit Button -htmx.defineExtension('disable-element', { - onEvent: function (name, evt) { - let elt = evt.detail.elt; - let target = elt.getAttribute("hx-disable-element"); - let targetElements = (target == "self") ? [ elt ] : document.querySelectorAll(target); - - for (var i = 0; i < targetElements.length; i++) { - if (name === "htmx:beforeRequest" && targetElements[i]) { - targetElements[i].disabled = true; - } else if (name == "htmx:afterRequest" && targetElements[i]) { - targetElements[i].disabled = false; - } - } - } -}); \ No newline at end of file diff --git a/www/static/src/ext/event-header.js b/www/static/src/ext/event-header.js deleted file mode 100644 index c7d29334..00000000 --- a/www/static/src/ext/event-header.js +++ /dev/null @@ -1,37 +0,0 @@ -(function(){ - function stringifyEvent(event) { - var obj = {}; - for (var key in event) { - obj[key] = event[key]; - } - return JSON.stringify(obj, function(key, value){ - if(value instanceof Node){ - var nodeRep = value.tagName; - if (nodeRep) { - nodeRep = nodeRep.toLowerCase(); - if(value.id){ - nodeRep += "#" + value.id; - } - if(value.classList && value.classList.length){ - nodeRep += "." + value.classList.toString().replace(" ", ".") - } - return nodeRep; - } else { - return "Node" - } - } - if (value instanceof Window) return 'Window'; - return value; - }); - } - - htmx.defineExtension('event-header', { - onEvent: function (name, evt) { - if (name === "htmx:configRequest") { - if (evt.detail.triggeringEvent) { - evt.detail.headers['Triggering-Event'] = stringifyEvent(evt.detail.triggeringEvent); - } - } - } - }); -})(); diff --git a/www/static/src/ext/head-support.js b/www/static/src/ext/head-support.js deleted file mode 100644 index 87f4d186..00000000 --- a/www/static/src/ext/head-support.js +++ /dev/null @@ -1,141 +0,0 @@ -//========================================================== -// head-support.js -// -// An extension to htmx 1.0 to add head tag merging. -//========================================================== -(function(){ - - var api = null; - - function log() { - //console.log(arguments); - } - - function mergeHead(newContent, defaultMergeStrategy) { - - if (newContent && newContent.indexOf(' -1) { - const htmlDoc = document.createElement("html"); - // remove svgs to avoid conflicts - var contentWithSvgsRemoved = newContent.replace(/]*>|>)([\s\S]*?)<\/svg>/gim, ''); - // extract head tag - var headTag = contentWithSvgsRemoved.match(/(]*>|>)([\s\S]*?)<\/head>)/im); - - // if the head tag exists... - if (headTag) { - - var added = [] - var removed = [] - var preserved = [] - var nodesToAppend = [] - - htmlDoc.innerHTML = headTag; - var newHeadTag = htmlDoc.querySelector("head"); - var currentHead = document.head; - - if (newHeadTag == null) { - return; - } else { - // put all new head elements into a Map, by their outerHTML - var srcToNewHeadNodes = new Map(); - for (const newHeadChild of newHeadTag.children) { - srcToNewHeadNodes.set(newHeadChild.outerHTML, newHeadChild); - } - } - - - - // determine merge strategy - var mergeStrategy = api.getAttributeValue(newHeadTag, "hx-head") || defaultMergeStrategy; - - // get the current head - for (const currentHeadElt of currentHead.children) { - - // If the current head element is in the map - var inNewContent = srcToNewHeadNodes.has(currentHeadElt.outerHTML); - var isReAppended = currentHeadElt.getAttribute("hx-head") === "re-eval"; - var isPreserved = api.getAttributeValue(currentHeadElt, "hx-preserve") === "true"; - if (inNewContent || isPreserved) { - if (isReAppended) { - // remove the current version and let the new version replace it and re-execute - removed.push(currentHeadElt); - } else { - // this element already exists and should not be re-appended, so remove it from - // the new content map, preserving it in the DOM - srcToNewHeadNodes.delete(currentHeadElt.outerHTML); - preserved.push(currentHeadElt); - } - } else { - if (mergeStrategy === "append") { - // we are appending and this existing element is not new content - // so if and only if it is marked for re-append do we do anything - if (isReAppended) { - removed.push(currentHeadElt); - nodesToAppend.push(currentHeadElt); - } - } else { - // if this is a merge, we remove this content since it is not in the new head - if (api.triggerEvent(document.body, "htmx:removingHeadElement", {headElement: currentHeadElt}) !== false) { - removed.push(currentHeadElt); - } - } - } - } - - // Push the tremaining new head elements in the Map into the - // nodes to append to the head tag - nodesToAppend.push(...srcToNewHeadNodes.values()); - log("to append: ", nodesToAppend); - - for (const newNode of nodesToAppend) { - log("adding: ", newNode); - var newElt = document.createRange().createContextualFragment(newNode.outerHTML); - log(newElt); - if (api.triggerEvent(document.body, "htmx:addingHeadElement", {headElement: newElt}) !== false) { - currentHead.appendChild(newElt); - added.push(newElt); - } - } - - // remove all removed elements, after we have appended the new elements to avoid - // additional network requests for things like style sheets - for (const removedElement of removed) { - if (api.triggerEvent(document.body, "htmx:removingHeadElement", {headElement: removedElement}) !== false) { - currentHead.removeChild(removedElement); - } - } - - api.triggerEvent(document.body, "htmx:afterHeadMerge", {added: added, kept: preserved, removed: removed}); - } - } - } - - htmx.defineExtension("head-support", { - init: function(apiRef) { - // store a reference to the internal API. - api = apiRef; - - htmx.on('htmx:afterSwap', function(evt){ - var serverResponse = evt.detail.xhr.response; - if (api.triggerEvent(document.body, "htmx:beforeHeadMerge", evt.detail)) { - mergeHead(serverResponse, evt.detail.boosted ? "merge" : "append"); - } - }) - - htmx.on('htmx:historyRestore', function(evt){ - if (api.triggerEvent(document.body, "htmx:beforeHeadMerge", evt.detail)) { - if (evt.detail.cacheMiss) { - mergeHead(evt.detail.serverResponse, "merge"); - } else { - mergeHead(evt.detail.item.head, "merge"); - } - } - }) - - htmx.on('htmx:historyItemCreated', function(evt){ - var historyItem = evt.detail.item; - historyItem.head = document.head.outerHTML; - }) - } - }); - -})() diff --git a/www/static/src/ext/include-vals.js b/www/static/src/ext/include-vals.js deleted file mode 100644 index d8f5ce4f..00000000 --- a/www/static/src/ext/include-vals.js +++ /dev/null @@ -1,24 +0,0 @@ -(function(){ - - function mergeObjects(obj1, obj2) { - for (var key in obj2) { - if (obj2.hasOwnProperty(key)) { - obj1[key] = obj2[key]; - } - } - return obj1; - } - - htmx.defineExtension('include-vals', { - onEvent: function (name, evt) { - if (name === "htmx:configRequest") { - var includeValsElt = htmx.closest(evt.detail.elt, "[include-vals],[data-include-vals]"); - if (includeValsElt) { - var includeVals = includeValsElt.getAttribute("include-vals") || includeValsElt.getAttribute("data-include-vals"); - var valuesToInclude = eval("({" + includeVals + "})"); - mergeObjects(evt.detail.parameters, valuesToInclude); - } - } - } - }); -})(); diff --git a/www/static/src/ext/json-enc.js b/www/static/src/ext/json-enc.js deleted file mode 100644 index db0aa36f..00000000 --- a/www/static/src/ext/json-enc.js +++ /dev/null @@ -1,12 +0,0 @@ -htmx.defineExtension('json-enc', { - onEvent: function (name, evt) { - if (name === "htmx:configRequest") { - evt.detail.headers['Content-Type'] = "application/json"; - } - }, - - encodeParameters : function(xhr, parameters, elt) { - xhr.overrideMimeType('text/json'); - return (JSON.stringify(parameters)); - } -}); \ No newline at end of file diff --git a/www/static/src/ext/loading-states.js b/www/static/src/ext/loading-states.js deleted file mode 100644 index c8ab51da..00000000 --- a/www/static/src/ext/loading-states.js +++ /dev/null @@ -1,183 +0,0 @@ -;(function () { - let loadingStatesUndoQueue = [] - - function loadingStateContainer(target) { - return htmx.closest(target, '[data-loading-states]') || document.body - } - - function mayProcessUndoCallback(target, callback) { - if (document.body.contains(target)) { - callback() - } - } - - function mayProcessLoadingStateByPath(elt, requestPath) { - const pathElt = htmx.closest(elt, '[data-loading-path]') - if (!pathElt) { - return true - } - - return pathElt.getAttribute('data-loading-path') === requestPath - } - - function queueLoadingState(sourceElt, targetElt, doCallback, undoCallback) { - const delayElt = htmx.closest(sourceElt, '[data-loading-delay]') - if (delayElt) { - const delayInMilliseconds = - delayElt.getAttribute('data-loading-delay') || 200 - const timeout = setTimeout(function () { - doCallback() - - loadingStatesUndoQueue.push(function () { - mayProcessUndoCallback(targetElt, undoCallback) - }) - }, delayInMilliseconds) - - loadingStatesUndoQueue.push(function () { - mayProcessUndoCallback(targetElt, function () { clearTimeout(timeout) }) - }) - } else { - doCallback() - loadingStatesUndoQueue.push(function () { - mayProcessUndoCallback(targetElt, undoCallback) - }) - } - } - - function getLoadingStateElts(loadingScope, type, path) { - return Array.from(htmx.findAll(loadingScope, "[" + type + "]")).filter( - function (elt) { return mayProcessLoadingStateByPath(elt, path) } - ) - } - - function getLoadingTarget(elt) { - if (elt.getAttribute('data-loading-target')) { - return Array.from( - htmx.findAll(elt.getAttribute('data-loading-target')) - ) - } - return [elt] - } - - htmx.defineExtension('loading-states', { - onEvent: function (name, evt) { - if (name === 'htmx:beforeRequest') { - const container = loadingStateContainer(evt.target) - - const loadingStateTypes = [ - 'data-loading', - 'data-loading-class', - 'data-loading-class-remove', - 'data-loading-disable', - 'data-loading-aria-busy', - ] - - let loadingStateEltsByType = {} - - loadingStateTypes.forEach(function (type) { - loadingStateEltsByType[type] = getLoadingStateElts( - container, - type, - evt.detail.pathInfo.requestPath - ) - }) - - loadingStateEltsByType['data-loading'].forEach(function (sourceElt) { - getLoadingTarget(sourceElt).forEach(function (targetElt) { - queueLoadingState( - sourceElt, - targetElt, - function () { - targetElt.style.display = - sourceElt.getAttribute('data-loading') || - 'inline-block' }, - function () { targetElt.style.display = 'none' } - ) - }) - }) - - loadingStateEltsByType['data-loading-class'].forEach( - function (sourceElt) { - const classNames = sourceElt - .getAttribute('data-loading-class') - .split(' ') - - getLoadingTarget(sourceElt).forEach(function (targetElt) { - queueLoadingState( - sourceElt, - targetElt, - function () { - classNames.forEach(function (className) { - targetElt.classList.add(className) - }) - }, - function() { - classNames.forEach(function (className) { - targetElt.classList.remove(className) - }) - } - ) - }) - } - ) - - loadingStateEltsByType['data-loading-class-remove'].forEach( - function (sourceElt) { - const classNames = sourceElt - .getAttribute('data-loading-class-remove') - .split(' ') - - getLoadingTarget(sourceElt).forEach(function (targetElt) { - queueLoadingState( - sourceElt, - targetElt, - function () { - classNames.forEach(function (className) { - targetElt.classList.remove(className) - }) - }, - function() { - classNames.forEach(function (className) { - targetElt.classList.add(className) - }) - } - ) - }) - } - ) - - loadingStateEltsByType['data-loading-disable'].forEach( - function (sourceElt) { - getLoadingTarget(sourceElt).forEach(function (targetElt) { - queueLoadingState( - sourceElt, - targetElt, - function() { targetElt.disabled = true }, - function() { targetElt.disabled = false } - ) - }) - } - ) - - loadingStateEltsByType['data-loading-aria-busy'].forEach( - function (sourceElt) { - getLoadingTarget(sourceElt).forEach(function (targetElt) { - queueLoadingState( - sourceElt, - targetElt, - function () { targetElt.setAttribute("aria-busy", "true") }, - function () { targetElt.removeAttribute("aria-busy") } - ) - }) - } - ) - } - - if (name === 'htmx:beforeOnLoad') { - while (loadingStatesUndoQueue.length > 0) { - loadingStatesUndoQueue.shift()() - } - } - }, - }) -})() diff --git a/www/static/src/ext/method-override.js b/www/static/src/ext/method-override.js deleted file mode 100644 index 2e3504cb..00000000 --- a/www/static/src/ext/method-override.js +++ /dev/null @@ -1,11 +0,0 @@ -htmx.defineExtension('method-override', { - onEvent: function (name, evt) { - if (name === "htmx:configRequest") { - var method = evt.detail.verb; - if (method !== "get" || method !== "post") { - evt.detail.headers['X-HTTP-Method-Override'] = method.toUpperCase(); - evt.detail.verb = "post"; - } - } - } -}); diff --git a/www/static/src/ext/morphdom-swap.js b/www/static/src/ext/morphdom-swap.js deleted file mode 100644 index a1e53ce9..00000000 --- a/www/static/src/ext/morphdom-swap.js +++ /dev/null @@ -1,17 +0,0 @@ -htmx.defineExtension('morphdom-swap', { - isInlineSwap: function(swapStyle) { - return swapStyle === 'morphdom'; - }, - handleSwap: function (swapStyle, target, fragment) { - if (swapStyle === 'morphdom') { - if (fragment.nodeType === Node.DOCUMENT_FRAGMENT_NODE) { - // IE11 doesn't support DocumentFragment.firstElementChild - morphdom(target, fragment.firstElementChild || fragment.firstChild); - return [target]; - } else { - morphdom(target, fragment.outerHTML); - return [target]; - } - } - } -}); diff --git a/www/static/src/ext/multi-swap.js b/www/static/src/ext/multi-swap.js deleted file mode 100644 index f38f5b06..00000000 --- a/www/static/src/ext/multi-swap.js +++ /dev/null @@ -1,45 +0,0 @@ -(function () { - - /** @type {import("../htmx").HtmxInternalApi} */ - var api; - - htmx.defineExtension('multi-swap', { - init: function (apiRef) { - api = apiRef; - }, - isInlineSwap: function (swapStyle) { - return swapStyle.indexOf('multi:') === 0; - }, - handleSwap: function (swapStyle, target, fragment, settleInfo) { - if (swapStyle.indexOf('multi:') === 0) { - var selectorToSwapStyle = {}; - var elements = swapStyle.replace(/^multi\s*:\s*/, '').split(/\s*,\s*/); - - elements.map(function (element) { - var split = element.split(/\s*:\s*/); - var elementSelector = split[0]; - var elementSwapStyle = typeof (split[1]) !== "undefined" ? split[1] : "innerHTML"; - - if (elementSelector.charAt(0) !== '#') { - console.error("HTMX multi-swap: unsupported selector '" + elementSelector + "'. Only ID selectors starting with '#' are supported."); - return; - } - - selectorToSwapStyle[elementSelector] = elementSwapStyle; - }); - - for (var selector in selectorToSwapStyle) { - var swapStyle = selectorToSwapStyle[selector]; - var elementToSwap = fragment.querySelector(selector); - if (elementToSwap) { - api.oobSwap(swapStyle, elementToSwap, settleInfo); - } else { - console.warn("HTMX multi-swap: selector '" + selector + "' not found in source content."); - } - } - - return true; - } - } - }); -})(); \ No newline at end of file diff --git a/www/static/src/ext/path-deps.js b/www/static/src/ext/path-deps.js deleted file mode 100644 index 4987e50e..00000000 --- a/www/static/src/ext/path-deps.js +++ /dev/null @@ -1,60 +0,0 @@ -(function(undefined){ - 'use strict'; - - // Save a reference to the global object (window in the browser) - var _root = this; - - function dependsOn(pathSpec, url) { - if (pathSpec === "ignore") { - return false; - } - var dependencyPath = pathSpec.split("/"); - var urlPath = url.split("/"); - for (var i = 0; i < urlPath.length; i++) { - var dependencyElement = dependencyPath.shift(); - var pathElement = urlPath[i]; - if (dependencyElement !== pathElement && dependencyElement !== "*") { - return false; - } - if (dependencyPath.length === 0 || (dependencyPath.length === 1 && dependencyPath[0] === "")) { - return true; - } - } - return false; - } - - function refreshPath(path) { - var eltsWithDeps = htmx.findAll("[path-deps]"); - for (var i = 0; i < eltsWithDeps.length; i++) { - var elt = eltsWithDeps[i]; - if (dependsOn(elt.getAttribute('path-deps'), path)) { - htmx.trigger(elt, "path-deps"); - } - } - } - - htmx.defineExtension('path-deps', { - onEvent: function (name, evt) { - if (name === "htmx:beforeOnLoad") { - var config = evt.detail.requestConfig; - // mutating call - if (config.verb !== "get" && evt.target.getAttribute('path-deps') !== 'ignore') { - refreshPath(config.path); - } - } - } - }); - - /** - * ******************** - * Expose functionality - * ******************** - */ - - _root.PathDeps = { - refresh: function(path) { - refreshPath(path); - } - }; - -}).call(this); diff --git a/www/static/src/ext/path-params.js b/www/static/src/ext/path-params.js deleted file mode 100644 index e251b892..00000000 --- a/www/static/src/ext/path-params.js +++ /dev/null @@ -1,11 +0,0 @@ -htmx.defineExtension('path-params', { - onEvent: function(name, evt) { - if (name === "htmx:configRequest") { - evt.detail.path = evt.detail.path.replace(/{([^}]+)}/g, function (_, param) { - var val = evt.detail.parameters[param]; - delete evt.detail.parameters[param]; - return val === undefined ? "{" + param + "}" : encodeURIComponent(val); - }) - } - } -}); \ No newline at end of file diff --git a/www/static/src/ext/remove-me.js b/www/static/src/ext/remove-me.js deleted file mode 100644 index 42be9932..00000000 --- a/www/static/src/ext/remove-me.js +++ /dev/null @@ -1,27 +0,0 @@ -(function(){ - function maybeRemoveMe(elt) { - var timing = elt.getAttribute("remove-me") || elt.getAttribute("data-remove-me"); - if (timing) { - setTimeout(function () { - elt.parentElement.removeChild(elt); - }, htmx.parseInterval(timing)); - } - } - - htmx.defineExtension('remove-me', { - onEvent: function (name, evt) { - if (name === "htmx:afterProcessNode") { - var elt = evt.detail.elt; - if (elt.getAttribute) { - maybeRemoveMe(elt); - if (elt.querySelectorAll) { - var children = elt.querySelectorAll("[remove-me], [data-remove-me]"); - for (var i = 0; i < children.length; i++) { - maybeRemoveMe(children[i]); - } - } - } - } - } - }); -})(); diff --git a/www/static/src/ext/response-targets.js b/www/static/src/ext/response-targets.js deleted file mode 100644 index dd6fd418..00000000 --- a/www/static/src/ext/response-targets.js +++ /dev/null @@ -1,130 +0,0 @@ -(function(){ - - /** @type {import("../htmx").HtmxInternalApi} */ - var api; - - var attrPrefix = 'hx-target-'; - - // IE11 doesn't support string.startsWith - function startsWith(str, prefix) { - return str.substring(0, prefix.length) === prefix - } - - /** - * @param {HTMLElement} elt - * @param {number} respCode - * @returns {HTMLElement | null} - */ - function getRespCodeTarget(elt, respCodeNumber) { - if (!elt || !respCodeNumber) return null; - - var respCode = respCodeNumber.toString(); - - // '*' is the original syntax, as the obvious character for a wildcard. - // The 'x' alternative was added for maximum compatibility with HTML - // templating engines, due to ambiguity around which characters are - // supported in HTML attributes. - // - // Start with the most specific possible attribute and generalize from - // there. - var attrPossibilities = [ - respCode, - - respCode.substr(0, 2) + '*', - respCode.substr(0, 2) + 'x', - - respCode.substr(0, 1) + '*', - respCode.substr(0, 1) + 'x', - respCode.substr(0, 1) + '**', - respCode.substr(0, 1) + 'xx', - - '*', - 'x', - '***', - 'xxx', - ]; - if (startsWith(respCode, '4') || startsWith(respCode, '5')) { - attrPossibilities.push('error'); - } - - for (var i = 0; i < attrPossibilities.length; i++) { - var attr = attrPrefix + attrPossibilities[i]; - var attrValue = api.getClosestAttributeValue(elt, attr); - if (attrValue) { - if (attrValue === "this") { - return api.findThisElement(elt, attr); - } else { - return api.querySelectorExt(elt, attrValue); - } - } - } - - return null; - } - - /** @param {Event} evt */ - function handleErrorFlag(evt) { - if (evt.detail.isError) { - if (htmx.config.responseTargetUnsetsError) { - evt.detail.isError = false; - } - } else if (htmx.config.responseTargetSetsError) { - evt.detail.isError = true; - } - } - - htmx.defineExtension('response-targets', { - - /** @param {import("../htmx").HtmxInternalApi} apiRef */ - init: function (apiRef) { - api = apiRef; - - if (htmx.config.responseTargetUnsetsError === undefined) { - htmx.config.responseTargetUnsetsError = true; - } - if (htmx.config.responseTargetSetsError === undefined) { - htmx.config.responseTargetSetsError = false; - } - if (htmx.config.responseTargetPrefersExisting === undefined) { - htmx.config.responseTargetPrefersExisting = false; - } - if (htmx.config.responseTargetPrefersRetargetHeader === undefined) { - htmx.config.responseTargetPrefersRetargetHeader = true; - } - }, - - /** - * @param {string} name - * @param {Event} evt - */ - onEvent: function (name, evt) { - if (name === "htmx:beforeSwap" && - evt.detail.xhr && - evt.detail.xhr.status !== 200) { - if (evt.detail.target) { - if (htmx.config.responseTargetPrefersExisting) { - evt.detail.shouldSwap = true; - handleErrorFlag(evt); - return true; - } - if (htmx.config.responseTargetPrefersRetargetHeader && - evt.detail.xhr.getAllResponseHeaders().match(/HX-Retarget:/i)) { - evt.detail.shouldSwap = true; - handleErrorFlag(evt); - return true; - } - } - if (!evt.detail.requestConfig) { - return true; - } - var target = getRespCodeTarget(evt.detail.requestConfig.elt, evt.detail.xhr.status); - if (target) { - handleErrorFlag(evt); - evt.detail.shouldSwap = true; - evt.detail.target = target; - } - return true; - } - } - }); -})(); diff --git a/www/static/src/ext/sse.js b/www/static/src/ext/sse.js deleted file mode 100644 index feae3b88..00000000 --- a/www/static/src/ext/sse.js +++ /dev/null @@ -1,313 +0,0 @@ -/* -Server Sent Events Extension -============================ -This extension adds support for Server Sent Events to htmx. See /www/extensions/sse.md for usage instructions. - -*/ - -(function() { - - /** @type {import("../htmx").HtmxInternalApi} */ - var api; - - htmx.defineExtension("sse", { - - /** - * Init saves the provided reference to the internal HTMX API. - * - * @param {import("../htmx").HtmxInternalApi} api - * @returns void - */ - init: function(apiRef) { - // store a reference to the internal API. - api = apiRef; - - // set a function in the public API for creating new EventSource objects - if (htmx.createEventSource == undefined) { - htmx.createEventSource = createEventSource; - } - }, - - /** - * onEvent handles all events passed to this extension. - * - * @param {string} name - * @param {Event} evt - * @returns void - */ - onEvent: function(name, evt) { - - switch (name) { - - case "htmx:beforeCleanupElement": - var internalData = api.getInternalData(evt.target) - // Try to remove remove an EventSource when elements are removed - if (internalData.sseEventSource) { - internalData.sseEventSource.close(); - } - - return; - - // Try to create EventSources when elements are processed - case "htmx:afterProcessNode": - ensureEventSourceOnElement(evt.target); - registerSSE(evt.target); - } - } - }); - - /////////////////////////////////////////////// - // HELPER FUNCTIONS - /////////////////////////////////////////////// - - - /** - * createEventSource is the default method for creating new EventSource objects. - * it is hoisted into htmx.config.createEventSource to be overridden by the user, if needed. - * - * @param {string} url - * @returns EventSource - */ - function createEventSource(url) { - return new EventSource(url, { withCredentials: true }); - } - - /** - * registerSSE looks for attributes that can contain sse events, right - * now hx-trigger and sse-swap and adds listeners based on these attributes too - * the closest event source - * - * @param {HTMLElement} elt - */ - function registerSSE(elt) { - // Find closest existing event source - var sourceElement = api.getClosestMatch(elt, hasEventSource); - if (sourceElement == null) { - // api.triggerErrorEvent(elt, "htmx:noSSESourceError") - return null; // no eventsource in parentage, orphaned element - } - - // Set internalData and source - var internalData = api.getInternalData(sourceElement); - var source = internalData.sseEventSource; - - // Add message handlers for every `sse-swap` attribute - queryAttributeOnThisOrChildren(elt, "sse-swap").forEach(function(child) { - - var sseSwapAttr = api.getAttributeValue(child, "sse-swap"); - var sseEventNames = sseSwapAttr.split(","); - - for (var i = 0; i < sseEventNames.length; i++) { - var sseEventName = sseEventNames[i].trim(); - var listener = function(event) { - - // If the source is missing then close SSE - if (maybeCloseSSESource(sourceElement)) { - return; - } - - // If the body no longer contains the element, remove the listener - if (!api.bodyContains(child)) { - source.removeEventListener(sseEventName, listener); - } - - // swap the response into the DOM and trigger a notification - swap(child, event.data); - api.triggerEvent(elt, "htmx:sseMessage", event); - }; - - // Register the new listener - api.getInternalData(child).sseEventListener = listener; - source.addEventListener(sseEventName, listener); - } - }); - - // Add message handlers for every `hx-trigger="sse:*"` attribute - queryAttributeOnThisOrChildren(elt, "hx-trigger").forEach(function(child) { - - var sseEventName = api.getAttributeValue(child, "hx-trigger"); - if (sseEventName == null) { - return; - } - - // Only process hx-triggers for events with the "sse:" prefix - if (sseEventName.slice(0, 4) != "sse:") { - return; - } - - var listener = function(event) { - if (maybeCloseSSESource(sourceElement)) { - return - } - - if (!api.bodyContains(child)) { - source.removeEventListener(sseEventName, listener); - } - - // Trigger events to be handled by the rest of htmx - htmx.trigger(child, sseEventName, event); - htmx.trigger(child, "htmx:sseMessage", event); - } - - // Register the new listener - api.getInternalData(elt).sseEventListener = listener; - source.addEventListener(sseEventName.slice(4), listener); - }); - } - - /** - * ensureEventSourceOnElement creates a new EventSource connection on the provided element. - * If a usable EventSource already exists, then it is returned. If not, then a new EventSource - * is created and stored in the element's internalData. - * @param {HTMLElement} elt - * @param {number} retryCount - * @returns {EventSource | null} - */ - function ensureEventSourceOnElement(elt, retryCount) { - - if (elt == null) { - return null; - } - - // handle extension source creation attribute - queryAttributeOnThisOrChildren(elt, "sse-connect").forEach(function(child) { - var sseURL = api.getAttributeValue(child, "sse-connect"); - if (sseURL == null) { - return; - } - - ensureEventSource(child, sseURL, retryCount); - }); - } - - function ensureEventSource(elt, url, retryCount) { - var source = htmx.createEventSource(url); - - source.onerror = function(err) { - - // Log an error event - api.triggerErrorEvent(elt, "htmx:sseError", { error: err, source: source }); - - // If parent no longer exists in the document, then clean up this EventSource - if (maybeCloseSSESource(elt)) { - return; - } - - // Otherwise, try to reconnect the EventSource - if (source.readyState === EventSource.CLOSED) { - retryCount = retryCount || 0; - var timeout = Math.random() * (2 ^ retryCount) * 500; - window.setTimeout(function() { - ensureEventSourceOnElement(elt, Math.min(7, retryCount + 1)); - }, timeout); - } - }; - - source.onopen = function(evt) { - api.triggerEvent(elt, "htmx:sseOpen", { source: source }); - } - - api.getInternalData(elt).sseEventSource = source; - } - - /** - * maybeCloseSSESource confirms that the parent element still exists. - * If not, then any associated SSE source is closed and the function returns true. - * - * @param {HTMLElement} elt - * @returns boolean - */ - function maybeCloseSSESource(elt) { - if (!api.bodyContains(elt)) { - var source = api.getInternalData(elt).sseEventSource; - if (source != undefined) { - source.close(); - // source = null - return true; - } - } - return false; - } - - /** - * queryAttributeOnThisOrChildren returns all nodes that contain the requested attributeName, INCLUDING THE PROVIDED ROOT ELEMENT. - * - * @param {HTMLElement} elt - * @param {string} attributeName - */ - function queryAttributeOnThisOrChildren(elt, attributeName) { - - var result = []; - - // If the parent element also contains the requested attribute, then add it to the results too. - if (api.hasAttribute(elt, attributeName)) { - result.push(elt); - } - - // Search all child nodes that match the requested attribute - elt.querySelectorAll("[" + attributeName + "], [data-" + attributeName + "]").forEach(function(node) { - result.push(node); - }); - - return result; - } - - /** - * @param {HTMLElement} elt - * @param {string} content - */ - function swap(elt, content) { - - api.withExtensions(elt, function(extension) { - content = extension.transformResponse(content, null, elt); - }); - - var swapSpec = api.getSwapSpecification(elt); - var target = api.getTarget(elt); - var settleInfo = api.makeSettleInfo(elt); - - api.selectAndSwap(swapSpec.swapStyle, target, elt, content, settleInfo); - - settleInfo.elts.forEach(function(elt) { - if (elt.classList) { - elt.classList.add(htmx.config.settlingClass); - } - api.triggerEvent(elt, 'htmx:beforeSettle'); - }); - - // Handle settle tasks (with delay if requested) - if (swapSpec.settleDelay > 0) { - setTimeout(doSettle(settleInfo), swapSpec.settleDelay); - } else { - doSettle(settleInfo)(); - } - } - - /** - * doSettle mirrors much of the functionality in htmx that - * settles elements after their content has been swapped. - * TODO: this should be published by htmx, and not duplicated here - * @param {import("../htmx").HtmxSettleInfo} settleInfo - * @returns () => void - */ - function doSettle(settleInfo) { - - return function() { - settleInfo.tasks.forEach(function(task) { - task.call(); - }); - - settleInfo.elts.forEach(function(elt) { - if (elt.classList) { - elt.classList.remove(htmx.config.settlingClass); - } - api.triggerEvent(elt, 'htmx:afterSettle'); - }); - } - } - - function hasEventSource(node) { - return api.getInternalData(node).sseEventSource != null; - } - -})(); diff --git a/www/static/src/ext/ws.js b/www/static/src/ext/ws.js deleted file mode 100644 index c1e29620..00000000 --- a/www/static/src/ext/ws.js +++ /dev/null @@ -1,476 +0,0 @@ -/* -WebSockets Extension -============================ -This extension adds support for WebSockets to htmx. See /www/extensions/ws.md for usage instructions. -*/ - -(function () { - - /** @type {import("../htmx").HtmxInternalApi} */ - var api; - - htmx.defineExtension("ws", { - - /** - * init is called once, when this extension is first registered. - * @param {import("../htmx").HtmxInternalApi} apiRef - */ - init: function (apiRef) { - - // Store reference to internal API - api = apiRef; - - // Default function for creating new EventSource objects - if (!htmx.createWebSocket) { - htmx.createWebSocket = createWebSocket; - } - - // Default setting for reconnect delay - if (!htmx.config.wsReconnectDelay) { - htmx.config.wsReconnectDelay = "full-jitter"; - } - }, - - /** - * onEvent handles all events passed to this extension. - * - * @param {string} name - * @param {Event} evt - */ - onEvent: function (name, evt) { - var parent = evt.target || evt.detail.elt; - - switch (name) { - - // Try to close the socket when elements are removed - case "htmx:beforeCleanupElement": - - var internalData = api.getInternalData(parent) - - if (internalData.webSocket) { - internalData.webSocket.close(); - } - return; - - // Try to create websockets when elements are processed - case "htmx:beforeProcessNode": - forEach(queryAttributeOnThisOrChildren(parent, "ws-connect"), function (child) { - ensureWebSocket(child) - }); - forEach(queryAttributeOnThisOrChildren(parent, "ws-send"), function (child) { - ensureWebSocketSend(child) - }); - } - } - }); - - function splitOnWhitespace(trigger) { - return trigger.trim().split(/\s+/); - } - - function getLegacyWebsocketURL(elt) { - var legacySSEValue = api.getAttributeValue(elt, "hx-ws"); - if (legacySSEValue) { - var values = splitOnWhitespace(legacySSEValue); - for (var i = 0; i < values.length; i++) { - var value = values[i].split(/:(.+)/); - if (value[0] === "connect") { - return value[1]; - } - } - } - } - - /** - * ensureWebSocket creates a new WebSocket on the designated element, using - * the element's "ws-connect" attribute. - * @param {HTMLElement} socketElt - * @returns - */ - function ensureWebSocket(socketElt) { - - // If the element containing the WebSocket connection no longer exists, then - // do not connect/reconnect the WebSocket. - if (!api.bodyContains(socketElt)) { - return; - } - - // Get the source straight from the element's value - var wssSource = api.getAttributeValue(socketElt, "ws-connect") - - if (wssSource == null || wssSource === "") { - var legacySource = getLegacyWebsocketURL(socketElt); - if (legacySource == null) { - return; - } else { - wssSource = legacySource; - } - } - - // Guarantee that the wssSource value is a fully qualified URL - if (wssSource.indexOf("/") === 0) { - var base_part = location.hostname + (location.port ? ':' + location.port : ''); - if (location.protocol === 'https:') { - wssSource = "wss://" + base_part + wssSource; - } else if (location.protocol === 'http:') { - wssSource = "ws://" + base_part + wssSource; - } - } - - var socketWrapper = createWebsocketWrapper(socketElt, function () { - return htmx.createWebSocket(wssSource) - }); - - socketWrapper.addEventListener('message', function (event) { - if (maybeCloseWebSocketSource(socketElt)) { - return; - } - - var response = event.data; - if (!api.triggerEvent(socketElt, "htmx:wsBeforeMessage", { - message: response, - socketWrapper: socketWrapper.publicInterface - })) { - return; - } - - api.withExtensions(socketElt, function (extension) { - response = extension.transformResponse(response, null, socketElt); - }); - - var settleInfo = api.makeSettleInfo(socketElt); - var fragment = api.makeFragment(response); - - if (fragment.children.length) { - var children = Array.from(fragment.children); - for (var i = 0; i < children.length; i++) { - api.oobSwap(api.getAttributeValue(children[i], "hx-swap-oob") || "true", children[i], settleInfo); - } - } - - api.settleImmediately(settleInfo.tasks); - api.triggerEvent(socketElt, "htmx:wsAfterMessage", { message: response, socketWrapper: socketWrapper.publicInterface }) - }); - - // Put the WebSocket into the HTML Element's custom data. - api.getInternalData(socketElt).webSocket = socketWrapper; - } - - /** - * @typedef {Object} WebSocketWrapper - * @property {WebSocket} socket - * @property {Array<{message: string, sendElt: Element}>} messageQueue - * @property {number} retryCount - * @property {(message: string, sendElt: Element) => void} sendImmediately sendImmediately sends message regardless of websocket connection state - * @property {(message: string, sendElt: Element) => void} send - * @property {(event: string, handler: Function) => void} addEventListener - * @property {() => void} handleQueuedMessages - * @property {() => void} init - * @property {() => void} close - */ - /** - * - * @param socketElt - * @param socketFunc - * @returns {WebSocketWrapper} - */ - function createWebsocketWrapper(socketElt, socketFunc) { - var wrapper = { - socket: null, - messageQueue: [], - retryCount: 0, - - /** @type {Object} */ - events: {}, - - addEventListener: function (event, handler) { - if (this.socket) { - this.socket.addEventListener(event, handler); - } - - if (!this.events[event]) { - this.events[event] = []; - } - - this.events[event].push(handler); - }, - - sendImmediately: function (message, sendElt) { - if (!this.socket) { - api.triggerErrorEvent() - } - if (!sendElt || api.triggerEvent(sendElt, 'htmx:wsBeforeSend', { - message: message, - socketWrapper: this.publicInterface - })) { - this.socket.send(message); - sendElt && api.triggerEvent(sendElt, 'htmx:wsAfterSend', { - message: message, - socketWrapper: this.publicInterface - }) - } - }, - - send: function (message, sendElt) { - if (this.socket.readyState !== this.socket.OPEN) { - this.messageQueue.push({ message: message, sendElt: sendElt }); - } else { - this.sendImmediately(message, sendElt); - } - }, - - handleQueuedMessages: function () { - while (this.messageQueue.length > 0) { - var queuedItem = this.messageQueue[0] - if (this.socket.readyState === this.socket.OPEN) { - this.sendImmediately(queuedItem.message, queuedItem.sendElt); - this.messageQueue.shift(); - } else { - break; - } - } - }, - - init: function () { - if (this.socket && this.socket.readyState === this.socket.OPEN) { - // Close discarded socket - this.socket.close() - } - - // Create a new WebSocket and event handlers - /** @type {WebSocket} */ - var socket = socketFunc(); - - // The event.type detail is added for interface conformance with the - // other two lifecycle events (open and close) so a single handler method - // can handle them polymorphically, if required. - api.triggerEvent(socketElt, "htmx:wsConnecting", { event: { type: 'connecting' } }); - - this.socket = socket; - - socket.onopen = function (e) { - wrapper.retryCount = 0; - api.triggerEvent(socketElt, "htmx:wsOpen", { event: e, socketWrapper: wrapper.publicInterface }); - wrapper.handleQueuedMessages(); - } - - socket.onclose = function (e) { - // If socket should not be connected, stop further attempts to establish connection - // If Abnormal Closure/Service Restart/Try Again Later, then set a timer to reconnect after a pause. - if (!maybeCloseWebSocketSource(socketElt) && [1006, 1012, 1013].indexOf(e.code) >= 0) { - var delay = getWebSocketReconnectDelay(wrapper.retryCount); - setTimeout(function () { - wrapper.retryCount += 1; - wrapper.init(); - }, delay); - } - - // Notify client code that connection has been closed. Client code can inspect `event` field - // to determine whether closure has been valid or abnormal - api.triggerEvent(socketElt, "htmx:wsClose", { event: e, socketWrapper: wrapper.publicInterface }) - }; - - socket.onerror = function (e) { - api.triggerErrorEvent(socketElt, "htmx:wsError", { error: e, socketWrapper: wrapper }); - maybeCloseWebSocketSource(socketElt); - }; - - var events = this.events; - Object.keys(events).forEach(function (k) { - events[k].forEach(function (e) { - socket.addEventListener(k, e); - }) - }); - }, - - close: function () { - this.socket.close() - } - } - - wrapper.init(); - - wrapper.publicInterface = { - send: wrapper.send.bind(wrapper), - sendImmediately: wrapper.sendImmediately.bind(wrapper), - queue: wrapper.messageQueue - }; - - return wrapper; - } - - /** - * ensureWebSocketSend attaches trigger handles to elements with - * "ws-send" attribute - * @param {HTMLElement} elt - */ - function ensureWebSocketSend(elt) { - var legacyAttribute = api.getAttributeValue(elt, "hx-ws"); - if (legacyAttribute && legacyAttribute !== 'send') { - return; - } - - var webSocketParent = api.getClosestMatch(elt, hasWebSocket) - processWebSocketSend(webSocketParent, elt); - } - - /** - * hasWebSocket function checks if a node has webSocket instance attached - * @param {HTMLElement} node - * @returns {boolean} - */ - function hasWebSocket(node) { - return api.getInternalData(node).webSocket != null; - } - - /** - * processWebSocketSend adds event listeners to the element so that - * messages can be sent to the WebSocket server when the form is submitted. - * @param {HTMLElement} socketElt - * @param {HTMLElement} sendElt - */ - function processWebSocketSend(socketElt, sendElt) { - var nodeData = api.getInternalData(sendElt); - var triggerSpecs = api.getTriggerSpecs(sendElt); - triggerSpecs.forEach(function (ts) { - api.addTriggerHandler(sendElt, ts, nodeData, function (elt, evt) { - if (maybeCloseWebSocketSource(socketElt)) { - return; - } - - /** @type {WebSocketWrapper} */ - var socketWrapper = api.getInternalData(socketElt).webSocket; - var headers = api.getHeaders(sendElt, api.getTarget(sendElt)); - var results = api.getInputValues(sendElt, 'post'); - var errors = results.errors; - var rawParameters = results.values; - var expressionVars = api.getExpressionVars(sendElt); - var allParameters = api.mergeObjects(rawParameters, expressionVars); - var filteredParameters = api.filterValues(allParameters, sendElt); - - var sendConfig = { - parameters: filteredParameters, - unfilteredParameters: allParameters, - headers: headers, - errors: errors, - - triggeringEvent: evt, - messageBody: undefined, - socketWrapper: socketWrapper.publicInterface - }; - - if (!api.triggerEvent(elt, 'htmx:wsConfigSend', sendConfig)) { - return; - } - - if (errors && errors.length > 0) { - api.triggerEvent(elt, 'htmx:validation:halted', errors); - return; - } - - var body = sendConfig.messageBody; - if (body === undefined) { - var toSend = Object.assign({}, sendConfig.parameters); - if (sendConfig.headers) - toSend['HEADERS'] = headers; - body = JSON.stringify(toSend); - } - - socketWrapper.send(body, elt); - - if (evt && api.shouldCancel(evt, elt)) { - evt.preventDefault(); - } - }); - }); - } - - /** - * getWebSocketReconnectDelay is the default easing function for WebSocket reconnects. - * @param {number} retryCount // The number of retries that have already taken place - * @returns {number} - */ - function getWebSocketReconnectDelay(retryCount) { - - /** @type {"full-jitter" | ((retryCount:number) => number)} */ - var delay = htmx.config.wsReconnectDelay; - if (typeof delay === 'function') { - return delay(retryCount); - } - if (delay === 'full-jitter') { - var exp = Math.min(retryCount, 6); - var maxDelay = 1000 * Math.pow(2, exp); - return maxDelay * Math.random(); - } - - logError('htmx.config.wsReconnectDelay must either be a function or the string "full-jitter"'); - } - - /** - * maybeCloseWebSocketSource checks to the if the element that created the WebSocket - * still exists in the DOM. If NOT, then the WebSocket is closed and this function - * returns TRUE. If the element DOES EXIST, then no action is taken, and this function - * returns FALSE. - * - * @param {*} elt - * @returns - */ - function maybeCloseWebSocketSource(elt) { - if (!api.bodyContains(elt)) { - api.getInternalData(elt).webSocket.close(); - return true; - } - return false; - } - - /** - * createWebSocket is the default method for creating new WebSocket objects. - * it is hoisted into htmx.createWebSocket to be overridden by the user, if needed. - * - * @param {string} url - * @returns WebSocket - */ - function createWebSocket(url) { - var sock = new WebSocket(url, []); - sock.binaryType = htmx.config.wsBinaryType; - return sock; - } - - /** - * queryAttributeOnThisOrChildren returns all nodes that contain the requested attributeName, INCLUDING THE PROVIDED ROOT ELEMENT. - * - * @param {HTMLElement} elt - * @param {string} attributeName - */ - function queryAttributeOnThisOrChildren(elt, attributeName) { - - var result = [] - - // If the parent element also contains the requested attribute, then add it to the results too. - if (api.hasAttribute(elt, attributeName) || api.hasAttribute(elt, "hx-ws")) { - result.push(elt); - } - - // Search all child nodes that match the requested attribute - elt.querySelectorAll("[" + attributeName + "], [data-" + attributeName + "], [data-hx-ws], [hx-ws]").forEach(function (node) { - result.push(node) - }) - - return result - } - - /** - * @template T - * @param {T[]} arr - * @param {(T) => void} func - */ - function forEach(arr, func) { - if (arr) { - for (var i = 0; i < arr.length; i++) { - func(arr[i]); - } - } - } - -})(); - diff --git a/www/static/src/htmx.js b/www/static/src/htmx.js index b5b4f24e..a24926aa 100644 --- a/www/static/src/htmx.js +++ b/www/static/src/htmx.js @@ -3736,7 +3736,7 @@ var htmx = (function() { * @returns {FormData} */ function getExpressionVars(elt) { - return formDataFromObject(mergeObjects(getHXVarsForElement(elt), getHXValsForElement(elt))) + return mergeObjects(getHXVarsForElement(elt), getHXValsForElement(elt)) } /** @@ -4168,7 +4168,7 @@ var htmx = (function() { if (etc.values) { overrideFormData(rawFormData, formDataFromObject(etc.values)) } - const expressionVars = getExpressionVars(elt) + const expressionVars = formDataFromObject(getExpressionVars(elt)) const allFormData = overrideFormData(rawFormData, expressionVars) let filteredFormData = filterValues(allFormData, elt) diff --git a/www/themes/htmx-theme/static/js/htmx.js b/www/themes/htmx-theme/static/js/htmx.js index b5b4f24e..a24926aa 100644 --- a/www/themes/htmx-theme/static/js/htmx.js +++ b/www/themes/htmx-theme/static/js/htmx.js @@ -3736,7 +3736,7 @@ var htmx = (function() { * @returns {FormData} */ function getExpressionVars(elt) { - return formDataFromObject(mergeObjects(getHXVarsForElement(elt), getHXValsForElement(elt))) + return mergeObjects(getHXVarsForElement(elt), getHXValsForElement(elt)) } /** @@ -4168,7 +4168,7 @@ var htmx = (function() { if (etc.values) { overrideFormData(rawFormData, formDataFromObject(etc.values)) } - const expressionVars = getExpressionVars(elt) + const expressionVars = formDataFromObject(getExpressionVars(elt)) const allFormData = overrideFormData(rawFormData, expressionVars) let filteredFormData = filterValues(allFormData, elt)