!function(){let e;function t(){}function r(e){let t=document.createElement(e.tagName);for(const r of e.attributes)t.setAttribute(r.name,r.value);return t.textContent=e.textContent,"LINK"===e.tagName&&"stylesheet"===e.rel?new Promise(e=>{t.onload=e,t.onerror=e,document.head.appendChild(t)}):"SCRIPT"!==e.tagName||!e.src||e.async||e.defer?(document.head.appendChild(t),e._preloadHint&&t.addEventListener("load",()=>e._preloadHint.remove(),{once:!0}),null):new Promise((e,r)=>{t.onload=e,t.onerror=r,document.head.appendChild(t)})}async function d(d,o){if(d&&d.indexOf("-1){const a=document.createElement("html");let n=d.replace(/]*>|>)([\s\S]*?)<\/svg>/gim,"").match(/(]*>|>)([\s\S]*?)<\/head>)/im);if(n){let d=[],h=[],s=[],m=[],l=[];a.innerHTML=n;let i=a.querySelector("head"),u=document.head;if(null==i)return[];let c=new Map;for(const e of i.children)c.set(e.outerHTML,e);let p=e.attributeValue(i,"hx-head")||o;for(const t of u.children){let r=c.has(t.outerHTML),d="re-eval"===t.getAttribute("hx-head"),o="true"===e.attributeValue(t,"hx-preserve");r||o?d?h.push(t):(c.delete(t.outerHTML),s.push(t)):"append"===p?d&&(h.push(t),m.push(t)):!1!==htmx.trigger(document.body,"htmx:before:head:remove",{headElement:t})&&h.push(t)}m.push(...c.values());for(const e of m)if("SCRIPT"===e.tagName&&e.defer){if(l.push(e),e.src){let t=document.createElement("link");t.rel="module"===e.type?"modulepreload":"preload",t.as="script",t.href=e.src,document.head.appendChild(t),e._preloadHint=t}}else t(),!1!==htmx.trigger(document.body,"htmx:before:head:add",{headElement:e})&&(await r(e),d.push(e));for(const e of h)!1!==htmx.trigger(document.body,"htmx:before:head:remove",{headElement:e})&&u.removeChild(e);return htmx.trigger(document.body,"htmx:after:head:merge",{added:d,kept:s,removed:h}),l}}return[]}htmx.registerExtension("hx-head",{init:t=>{e=t},htmx_before_response:(e,t)=>{let r=t.ctx,o=r.target===document.body?"merge":"append";if(htmx.trigger(document.body,"htmx:before:head:merge",t)){let e=r.response.raw.text.bind(r.response.raw);r.response.raw.text=async()=>{let t=await e();return r._deferredHeadScripts=await d(t,o),t}}},htmx_after_swap:(e,t)=>{for(const e of t.ctx._deferredHeadScripts||[])r(e)},htmx_history_cache_before_restore:(e,t)=>{t.head&&(t.ready=d(t.head,"merge").then(e=>{t._deferredHeadScripts=e}))}})}();