app/assets/builds/@turbo-boost/streams.js
var ue=Object.defineProperty,fe=Object.defineProperties;var de=Object.getOwnPropertyDescriptors;var W=Object.getOwnPropertySymbols;var ce=Object.prototype.hasOwnProperty,he=Object.prototype.propertyIsEnumerable;var $=(l,o,u)=>o in l?ue(l,o,{enumerable:!0,configurable:!0,writable:!0,value:u}):l[o]=u,y=(l,o)=>{for(var u in o||(o={}))ce.call(o,u)&&$(l,u,o[u]);if(W)for(var u of W(o))he.call(o,u)&&$(l,u,o[u]);return l},O=(l,o)=>fe(l,de(o));var z="0.1.11";var me={turboPermanentAttribute:"data-turbo-permanent"},R=y({},me);var J=function(){"use strict";let l=new Set,o={morphStyle:"outerHTML",callbacks:{beforeNodeAdded:A,afterNodeAdded:A,beforeNodeMorphed:A,afterNodeMorphed:A,beforeNodeRemoved:A,afterNodeRemoved:A,beforeAttributeUpdated:A},head:{style:"merge",shouldPreserve:function(e){return e.getAttribute("im-preserve")==="true"},shouldReAppend:function(e){return e.getAttribute("im-re-append")==="true"},shouldRemove:A,afterHeadMorphed:A}};function u(e,t,r={}){e instanceof Document&&(e=e.documentElement),typeof t=="string"&&(t=ee(t));let n=te(t),i=Q(e,n,r);return c(e,n,i)}function c(e,t,r){if(r.head.block){let n=e.querySelector("head"),i=t.querySelector("head");if(n&&i){let a=I(i,n,r);Promise.all(a).then(function(){c(e,t,Object.assign(r,{head:{block:!1,ignore:!0}}))});return}}if(r.morphStyle==="innerHTML")return b(t,e,r),e.children;if(r.morphStyle==="outerHTML"||r.morphStyle==null){let n=ne(t,e,r),i=n==null?void 0:n.previousSibling,a=n==null?void 0:n.nextSibling,s=f(e,n,r);return n?re(i,s,a):[]}else throw"Do not understand how to morph style "+r.morphStyle}function d(e,t){return t.ignoreActiveValue&&e===document.activeElement&&e!==document.body}function f(e,t,r){if(!(r.ignoreActive&&e===document.activeElement))return t==null?r.callbacks.beforeNodeRemoved(e)===!1?e:(e.remove(),r.callbacks.afterNodeRemoved(e),null):V(e,t)?(r.callbacks.beforeNodeMorphed(e,t)===!1||(e instanceof HTMLHeadElement&&r.head.ignore||(e instanceof HTMLHeadElement&&r.head.style!=="morph"?I(t,e,r):(g(t,e,r),d(e,r)||b(t,e,r))),r.callbacks.afterNodeMorphed(e,t)),e):r.callbacks.beforeNodeRemoved(e)===!1||r.callbacks.beforeNodeAdded(t)===!1?e:(e.parentElement.replaceChild(t,e),r.callbacks.afterNodeAdded(t),r.callbacks.afterNodeRemoved(e),t)}function b(e,t,r){let n=e.firstChild,i=t.firstChild,a;for(;n;){if(a=n,n=a.nextSibling,i==null){if(r.callbacks.beforeNodeAdded(a)===!1)return;t.appendChild(a),r.callbacks.afterNodeAdded(a),S(r,a);continue}if(F(a,i,r)){f(i,a,r),i=i.nextSibling,S(r,a);continue}let s=Z(e,t,a,i,r);if(s){i=q(i,s,r),f(s,a,r),S(r,a);continue}let p=x(e,t,a,i,r);if(p){i=q(i,p,r),f(p,a,r),S(r,a);continue}if(r.callbacks.beforeNodeAdded(a)===!1)return;t.insertBefore(a,i),r.callbacks.afterNodeAdded(a),S(r,a)}for(;i!==null;){let s=i;i=i.nextSibling,_(s,r)}}function h(e,t,r,n){return e==="value"&&n.ignoreActiveValue&&t===document.activeElement?!0:n.callbacks.beforeAttributeUpdated(e,t,r)===!1}function g(e,t,r){let n=e.nodeType;if(n===1){let i=e.attributes,a=t.attributes;for(let s of i)h(s.name,t,"update",r)||t.getAttribute(s.name)!==s.value&&t.setAttribute(s.name,s.value);for(let s=a.length-1;0<=s;s--){let p=a[s];h(p.name,t,"remove",r)||e.hasAttribute(p.name)||t.removeAttribute(p.name)}}(n===8||n===3)&&t.nodeValue!==e.nodeValue&&(t.nodeValue=e.nodeValue),d(t,r)||T(e,t,r)}function v(e,t,r,n){if(e[r]!==t[r]){let i=h(r,t,"update",n);i||(t[r]=e[r]),e[r]?i||t.setAttribute(r,e[r]):h(r,t,"remove",n)||t.removeAttribute(r)}}function T(e,t,r){if(e instanceof HTMLInputElement&&t instanceof HTMLInputElement&&e.type!=="file"){let n=e.value,i=t.value;v(e,t,"checked",r),v(e,t,"disabled",r),e.hasAttribute("value")?n!==i&&(h("value",t,"update",r)||(t.setAttribute("value",n),t.value=n)):h("value",t,"remove",r)||(t.value="",t.removeAttribute("value"))}else if(e instanceof HTMLOptionElement)v(e,t,"selected",r);else if(e instanceof HTMLTextAreaElement&&t instanceof HTMLTextAreaElement){let n=e.value,i=t.value;if(h("value",t,"update",r))return;n!==i&&(t.value=n),t.firstChild&&t.firstChild.nodeValue!==n&&(t.firstChild.nodeValue=n)}}function I(e,t,r){let n=[],i=[],a=[],s=[],p=r.head.style,k=new Map;for(let m of e.children)k.set(m.outerHTML,m);for(let m of t.children){let E=k.has(m.outerHTML),H=r.head.shouldReAppend(m),C=r.head.shouldPreserve(m);E||C?H?i.push(m):(k.delete(m.outerHTML),a.push(m)):p==="append"?H&&(i.push(m),s.push(m)):r.head.shouldRemove(m)!==!1&&i.push(m)}s.push(...k.values());let U=[];for(let m of s){let E=document.createRange().createContextualFragment(m.outerHTML).firstChild;if(r.callbacks.beforeNodeAdded(E)!==!1){if(E.href||E.src){let H=null,C=new Promise(function(se){H=se});E.addEventListener("load",function(){H()}),U.push(C)}t.appendChild(E),r.callbacks.afterNodeAdded(E),n.push(E)}}for(let m of i)r.callbacks.beforeNodeRemoved(m)!==!1&&(t.removeChild(m),r.callbacks.afterNodeRemoved(m));return r.head.afterHeadMorphed(t,{added:n,kept:a,removed:i}),U}function Me(){}function A(){}function K(e){let t={};return Object.assign(t,o),Object.assign(t,e),t.callbacks={},Object.assign(t.callbacks,o.callbacks),Object.assign(t.callbacks,e.callbacks),t.head={},Object.assign(t.head,o.head),Object.assign(t.head,e.head),t}function Q(e,t,r){return r=K(r),{target:e,newContent:t,config:r,morphStyle:r.morphStyle,ignoreActive:r.ignoreActive,ignoreActiveValue:r.ignoreActiveValue,idMap:oe(e,t),deadIds:new Set,callbacks:r.callbacks,head:r.head}}function F(e,t,r){return e==null||t==null?!1:e.nodeType===t.nodeType&&e.tagName===t.tagName?e.id!==""&&e.id===t.id?!0:w(r,e,t)>0:!1}function V(e,t){return e==null||t==null?!1:e.nodeType===t.nodeType&&e.tagName===t.tagName}function q(e,t,r){for(;e!==t;){let n=e;e=e.nextSibling,_(n,r)}return S(r,t),t.nextSibling}function Z(e,t,r,n,i){let a=w(i,r,t),s=null;if(a>0){let p=n,k=0;for(;p!=null;){if(F(r,p,i))return p;if(k+=w(i,p,e),k>a)return null;p=p.nextSibling}}return s}function x(e,t,r,n,i){let a=n,s=r.nextSibling,p=0;for(;a!=null;){if(w(i,a,e)>0)return null;if(V(r,a))return a;if(V(s,a)&&(p++,s=s.nextSibling,p>=2))return null;a=a.nextSibling}return a}function ee(e){let t=new DOMParser,r=e.replace(/<svg(\s[^>]*>|>)([\s\S]*?)<\/svg>/gim,"");if(r.match(/<\/html>/)||r.match(/<\/head>/)||r.match(/<\/body>/)){let n=t.parseFromString(e,"text/html");if(r.match(/<\/html>/))return n.generatedByIdiomorph=!0,n;{let i=n.firstChild;return i?(i.generatedByIdiomorph=!0,i):null}}else{let i=t.parseFromString("<body><template>"+e+"</template></body>","text/html").body.querySelector("template").content;return i.generatedByIdiomorph=!0,i}}function te(e){if(e==null)return document.createElement("div");if(e.generatedByIdiomorph)return e;if(e instanceof Node){let t=document.createElement("div");return t.append(e),t}else{let t=document.createElement("div");for(let r of[...e])t.append(r);return t}}function re(e,t,r){let n=[],i=[];for(;e!=null;)n.push(e),e=e.previousSibling;for(;n.length>0;){let a=n.pop();i.push(a),t.parentElement.insertBefore(a,t)}for(i.push(t);r!=null;)n.push(r),i.push(r),r=r.nextSibling;for(;n.length>0;)t.parentElement.insertBefore(n.pop(),t.nextSibling);return i}function ne(e,t,r){let n;n=e.firstChild;let i=n,a=0;for(;n;){let s=ie(n,t,r);s>a&&(i=n,a=s),n=n.nextSibling}return i}function ie(e,t,r){return V(e,t)?.5+w(r,e,t):0}function _(e,t){S(t,e),t.callbacks.beforeNodeRemoved(e)!==!1&&(e.remove(),t.callbacks.afterNodeRemoved(e))}function le(e,t){return!e.deadIds.has(t)}function ae(e,t,r){return(e.idMap.get(r)||l).has(t)}function S(e,t){let r=e.idMap.get(t)||l;for(let n of r)e.deadIds.add(n)}function w(e,t,r){let n=e.idMap.get(t)||l,i=0;for(let a of n)le(e,a)&&ae(e,a,r)&&++i;return i}function N(e,t){let r=e.parentElement,n=e.querySelectorAll("[id]");for(let i of n){let a=i;for(;a!==r&&a!=null;){let s=t.get(a);s==null&&(s=new Set,t.set(a,s)),s.add(i.id),a=a.parentElement}}}function oe(e,t){let r=new Map;return N(e,r),N(t,r),r}return{morph:u,defaults:o}}();var P,j=30,pe=/TRIX-EDITOR/i;function Y(l){return l.nodeType===Node.ELEMENT_NODE}function be(l){return Y(l)?l.hasAttribute(R.turboPermanentAttribute)&&l.getAttribute(R.turboPermanentAttribute)!=="false":!1}function ve(l){return Y(l)?l===document.activeElement:!1}function ge(l){return!(be(l)||ve(l)&&l.tagName.match(pe))}var X={callbacks:{beforeNodeMorphed:(l,o)=>ge(l)},morphStyle:"outerHTML",ignoreActiveValue:!0,head:{style:"merge"}};function Ee(l,o,u={}){let c=y(y({},X.callbacks),u.callbacks);return u=O(y(y({},X),u),{callbacks:c}),new Promise(d=>{setTimeout(()=>{J.morph(l,o,u),d()},j)})}P=Ee;var L={get delay(){return j},set delay(l){j=l},get method(){return P},set method(l){P=l}};var M={before:"turbo-boost:stream:before-invoke",after:"turbo-boost:stream:after-invoke",finish:"turbo-boost:stream:finish-invoke"};function B(l,o,u){let{object:c,target:d}=l;o=o||{},o=O(y({},o),{object:l.object});let f={detail:o,bubbles:!0};d.dispatchEvent(new CustomEvent(M.before,f));let{delay:b}=o.invoke||{};b=b||0;let h=()=>{let g=u(c);f.detail.result=g,d.dispatchEvent(new CustomEvent(M.after,f));let v;g instanceof Animation&&(v=g.finished),g instanceof Promise&&(v=g),v?v.then(()=>{f.detail.promise="fulfilled",d.dispatchEvent(new CustomEvent(M.finish,f))}).catch(T=>{f.detail.promise="rejected",f.detail.error=T,d.dispatchEvent(new CustomEvent(M.finish,f))}):d.dispatchEvent(new CustomEvent(M.finish,f))};b>0?setTimeout(h,b):h()}function Ae(l,o,u){let c=o[0],d=o[1],f={method:l,eventName:c,eventOptions:d};u.forEach(b=>B(b,f,h=>h.dispatchEvent(new CustomEvent(c,d))))}function ye(l,o,u){let c=o[0],d={method:l,html:c};u.forEach(f=>B(f,d,b=>L.method(b,c)))}function Se(l,o,u){let c=l.slice(0,-1).trim(),d=o[0],f={method:l,property:c,value:d};u.forEach(b=>B(b,f,h=>h[c]=d))}function ke(l,o,u){let c={method:l,args:o};u.forEach(d=>B(d,c,f=>f[l].apply(f,o)))}function G(l,o,u){return l.match(/^dispatch(Event)?$/)?Ae(l,o,u):l.match(/^morph|mutate$/)?ye(l,o,u):l.endsWith("=")?Se(l,o,u):ke(l,o,u)}function D(){let l=JSON.parse(this.templateContent.textContent),{id:o,selector:u,receiver:c,method:d,args:f,delay:b}=l,h=[{object:self,target:self}];u&&(h=Array.from(document.querySelectorAll(u)).map(g=>({object:g,target:g}))),c&&(h=h.map(g=>{let{object:v,target:T}=g,I=c.split(".");for(;I.length>0;)v=v[I.shift()],v.dispatchEvent&&(T=v);return{object:v,target:T}})),b>0?setTimeout(()=>G(d,f,h),b):G(d,f,h)}if(!self.Turbo)throw new Error("`Turbo` is not defined! Be sure to import `@turbo-boost/streams` after `@hotwired/turbo` or `@hotwired/turbo-rails`.");if(!Turbo.StreamActions)throw new Error("`Turbo.StreamActions` is not defined! Verify that you are running >= `7.2.0` of `@hotwired/turbo`.");Turbo.StreamActions.invoke=D;self.TurboBoost=self.TurboBoost||{};self.TurboBoost.Streams={invoke:D,invokeEvents:M,morph:L,schema:R,VERSION:z};console.info("@turbo-boost/streams has initialized and registered new stream actions with Turbo.");var Ne=self.TurboBoost.Streams;export{Ne as default};
//# sourceMappingURL=streams.js.map