(()=>{let e;function t(e){if(e.optimisticDiv){e.optimisticDiv.remove();for(let t of e.optHidden)t.style.display=""}}htmx.registerExtension("hx-optimistic",{init:t=>{e=t},htmx_config_request:(e,t)=>{let i=t.ctx.request.body;i?.entries&&(t.ctx.optimisticBody=i)},htmx_before_request:(t,i)=>{!function(t){if(t.optimistic=e.attributeValue(t.sourceElement,"hx-optimistic"),!t.optimistic)return;let i=document.querySelector(t.optimistic);if(!i)return;let n=t.target;if("string"==typeof n&&(n=document.querySelector(n)),!n)return;let r=document.createElement("div");if(r.style.cssText="all: initial",r.classList.add("hx-optimistic"),r.innerHTML=i.innerHTML,t.optimisticBody){let e=new Set(t.optimisticBody.keys());for(let i of e){let e=t.optimisticBody.getAll(i).filter(e=>"string"==typeof e);if(!e.length)continue;let n=1===e.length?e[0]:JSON.stringify(e);try{r.dataset[i]=n}catch(e){try{r.setAttribute("data-"+i,n)}catch(e){}}}}let o="before"===(s=t.swap)?"beforebegin":"after"===s?"afterend":"prepend"===s?"afterbegin":"append"===s?"beforeend":s;var s;if(t.optHidden=[],"innerHTML"===o){for(let e of n.children)e.style.display="none",t.optHidden.push(e);n.appendChild(r)}else["beforebegin","afterbegin","beforeend","afterend"].includes(o)?n.insertAdjacentElement(o,r):(n.style.display="none",t.optHidden.push(n),n.after(r));t.optimisticDiv=r,htmx.process(r)}(i.ctx)},htmx_error:(e,i)=>{t(i.ctx)},htmx_before_swap:(e,i)=>{t(i.ctx)}})})();