Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cdn.min.js « dist « morph « packages « alpinejs - github.com/gohugoio/hugo-mod-jslibs-dist.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: dff89d4b77abd54d712bd0bcde6ee53d8853685d (plain)
1
2
(()=>{var C=()=>{},E=()=>{},_,f;function d(e){if(!!K)return E((e||"").replace(`
`,"\\n"),_,f),new Promise(t=>C=()=>t())}async function y(e,t,n){return H(n),_=e,f=L(t),window.Alpine&&!e._x_dataStack&&(f._x_dataStack=window.Alpine.closestDataStack(e),f._x_dataStack&&window.Alpine.clone(e,f)),await d(),await B(e,f),_=void 0,f=void 0,e}y.step=()=>C();y.log=e=>{E=e};var O,M,V,b,A,N,v,g,K,w=()=>{};function H(e={}){let t=n=>n.getAttribute("key");V=e.updating||w,b=e.updated||w,A=e.removing||w,N=e.removed||w,v=e.adding||w,g=e.added||w,O=e.key||t,M=e.lookahead||!1,K=e.debug||!1}function L(e){return document.createRange().createContextualFragment(e).firstElementChild}async function B(e,t){if($(e,t)){let u=q(e,t);return await d("Swap elements"),u}let n=!1;if(!x(V,e,t,()=>n=!0)){if(window.Alpine&&P(e,t,()=>n=!0),j(t)){await z(e,t),b(e,t);return}n||await G(e,t),b(e,t),await I(e,t)}}function $(e,t){return e.nodeType!=t.nodeType||e.nodeName!=t.nodeName||m(e)!=m(t)}function j(e){return e.nodeType===3||e.nodeType===8}function q(e,t){if(x(A,e))return;let n=t.cloneNode(!0);x(v,n)||(a(e).replace(n),N(e),g(n))}async function z(e,t){let n=t.nodeValue;e.nodeValue!==n&&(e.nodeValue=n,await d("Change text node to: "+n))}async function G(e,t){if(e._x_isShown&&!t._x_isShown||!e._x_isShown&&t._x_isShown)return;let n=Array.from(e.attributes),u=Array.from(t.attributes);for(let p=n.length-1;p>=0;p--){let s=n[p].name;t.hasAttribute(s)||(e.removeAttribute(s),await d("Remove attribute"))}for(let p=u.length-1;p>=0;p--){let s=u[p].name,r=u[p].value;e.getAttribute(s)!==r&&(e.setAttribute(s,r),await d(`Set [${s}] attribute to: "${r}"`))}}async function I(e,t){let n=e.childNodes,u=t.childNodes,p=F(u),s=F(n),r=a(t).nodes().first(),i=a(e).nodes().first(),h={};for(;r;){let l=m(r),c=m(i);if(!i)if(l&&h[l]){let o=h[l];a(e).append(o),i=o,await d("Add element (from key)")}else{let o=J(r,e)||{};await d("Add element: "+o.outerHTML||o.nodeValue),r=a(r).nodes().next();continue}if(M){let o=a(r).next(),S=!1;for(;!S&&o;)i.isEqualNode(o)&&(S=!0,i=T(r,i),c=m(i),await d("Move element (lookahead)")),o=a(o).next()}if(l!==c){if(!l&&c){h[c]=i,i=T(r,i),h[c].remove(),i=a(i).nodes().next(),r=a(r).nodes().next(),await d('No "to" key');continue}if(l&&!c&&s[l]&&(i=a(i).replace(s[l]),await d('No "from" key')),l&&c){h[c]=i;let o=s[l];if(o)i=a(i).replace(o),await d('Move "from" key');else{h[c]=i,i=T(r,i),h[c].remove(),i=a(i).next(),r=a(r).next(),await d("I dont even know what this does");continue}}}await B(i,r),r=r&&a(r).nodes().next(),i=i&&a(i).nodes().next()}let k=[];for(;i;)x(A,i)||k.push(i),i=a(i).nodes().next();for(;k.length;){let l=k.pop();l.remove(),await d("remove el"),N(l)}}function m(e){return e&&e.nodeType===1&&O(e)}function F(e){let t={};return e.forEach(n=>{let u=m(n);u&&(t[u]=n)}),t}function x(e,...t){let n=!1;return e(...t,()=>n=!0),n}function J(e,t){if(!x(v,e)){let n=e.cloneNode(!0);return a(t).append(n),g(n),n}return null}function T(e,t){if(!x(v,e)){let n=e.cloneNode(!0);return a(t).before(n),g(n),n}return t}function P(e,t,n){e.nodeType===1&&e._x_dataStack&&window.Alpine.clone(e,t)}function a(e){return new R(e)}var R=class{el=void 0;constructor(t){this.el=t}traversals={first:"firstElementChild",next:"nextElementSibling",parent:"parentElement"};nodes(){return this.traversals={first:"firstChild",next:"nextSibling",parent:"parentNode"},this}first(){return this.teleportTo(this.el[this.traversals.first])}next(){return this.teleportTo(this.teleportBack(this.el[this.traversals.next]))}before(t){return this.el[this.traversals.parent].insertBefore(t,this.el),t}replace(t){return this.el[this.traversals.parent].replaceChild(t,this.el),t}append(t){return this.el.appendChild(t),t}teleportTo(t){return t&&(t._x_teleport?t._x_teleport:t)}teleportBack(t){return t&&(t._x_teleportBack?t._x_teleportBack:t)}};function D(e){e.morph=y}document.addEventListener("alpine:init",()=>{window.Alpine.plugin(D)});})();