aptechka 0.77.0 → 0.77.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- "use strict";var me=Object.defineProperty,fe=Object.defineProperties;var pe=Object.getOwnPropertyDescriptors;var Qt=Object.getOwnPropertySymbols;var ge=Object.prototype.hasOwnProperty,Ee=Object.prototype.propertyIsEnumerable;var Zt=(h,e)=>(e=Symbol[h])?e:Symbol.for("Symbol."+h),te=h=>{throw TypeError(h)};var _t=(h,e,s)=>e in h?me(h,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):h[e]=s,Rt=(h,e)=>{for(var s in e||(e={}))ge.call(e,s)&&_t(h,s,e[s]);if(Qt)for(var s of Qt(e))Ee.call(e,s)&&_t(h,s,e[s]);return h},qt=(h,e)=>fe(h,pe(e));var Dt=(h,e,s)=>e.has(h)||te("Cannot "+s);var t=(h,e,s)=>(Dt(h,e,"read from private field"),s?s.call(h):e.get(h)),l=(h,e,s)=>e.has(h)?te("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(h):e.set(h,s),o=(h,e,s,i)=>(Dt(h,e,"write to private field"),i?i.call(h,s):e.set(h,s),s),E=(h,e,s)=>(Dt(h,e,"access private method"),s);var G=(h,e,s)=>new Promise((i,n)=>{var S=c=>{try{g(s.next(c))}catch(v){n(v)}},p=c=>{try{g(s.throw(c))}catch(v){n(v)}},g=c=>c.done?i(c.value):Promise.resolve(c.value).then(S,p);g((s=s.apply(h,e)).next())});var ee=(h,e,s)=>(e=h[Zt("asyncIterator")])?e.call(h):(h=h[Zt("iterator")](),e={},s=(i,n)=>(n=h[i])&&(e[i]=S=>new Promise((p,g,c)=>(S=n.call(h,S),c=S.done,Promise.resolve(S.value).then(v=>p({value:v,done:c}),g)))),s("next"),s("return"),e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ae=require("../index-DekP7OZe.cjs"),z=require("../events-KVanG9sR.cjs"),se=require("../scroll-CIdNtj3G.cjs");require("construct-style-sheets-polyfill");const dt=require("../url-Dns-01WU.cjs"),ve=require("../css-value-parser/index.cjs"),Le=require("../string-DUXXtU8v.cjs");class ne extends HTMLElement{connectedCallback(){const e={"aria-live":"assertive","aria-atomic":"true",style:"position: absolute; left: 0; top: 0; clip: rect(0 0 0 0); clip-path: inset(50%); overflow: hidden; white-space: nowrap; width: 1px; height: 1px"};for(const[s,i]of Object.entries(e))this.setAttribute(s,i)}}ae.isBrowser&&!customElements.get("morph-announcer")&&customElements.define("morph-announcer",ne);var C,a,M,st,Ht,ft,it;class zt{constructor(e,s){l(this,M);l(this,C);l(this,a);l(this,ft,e=>{var i;if(e.preventDefault(),document.documentElement.classList.contains("click-disabled"))return;if(t(this,a).hasAttribute("data-back")&&t(this,C).previousURL)history.back();else{const n=t(this,a).getAttribute("data-history-action")||"push",S=t(this,a).hasAttribute("data-center-scroll"),p=getComputedStyle(t(this,a)).getPropertyValue("--offset-scroll").trim(),g=p?ve.cssValueParser.parse(p):void 0,c=t(this,a).hasAttribute("data-revalidate")||t(this,a).hasAttribute("data-pagination-more-link")||t(this,a).hasAttribute("data-pagination-set-link"),v=t(this,a).hasAttribute("data-keep-search-parameters"),D=t(this,a).hasAttribute("data-keep-scroll-position")||t(this,a).hasAttribute("data-pagination-more-link"),ut=t(this,a).getAttribute("data-scroll-behaviour"),et=E(this,M,Ht).call(this,t(this,a).getAttribute("data-pagination-set-link")||t(this,a).getAttribute("data-pagination-more-link"));et&&(t(this,a).hasAttribute("data-pagination-set-link")?t(this,C).links.forEach(x=>{x.updatePagination(parseInt(t(this,a).getAttribute("data-value")||"1"),et.selector)}):t(this,a).hasAttribute("data-pagination-more-link")&&t(this,C).links.forEach(x=>{x.updatePagination(et.currentPage+1,et.selector)}));const oe=((i=t(this,a).getAttribute("data-submorph"))==null?void 0:i.split(",").map(x=>x.trim()))||t(this,a).hasAttribute("data-pagination-more-link")&&[t(this,a).getAttribute("data-pagination-more-link")]||t(this,a).hasAttribute("data-pagination-set-link")&&[t(this,a).getAttribute("data-pagination-set-link")]||void 0,Pt=t(this,a).hasAttribute("data-clear-state");let u=t(this,M,st);if(t(this,a).hasAttribute("data-toggle-params")){const[x,wt]=t(this,M,st).split("?"),j=new URLSearchParams(wt),O=new URLSearchParams(location.search),k=new URLSearchParams;for(const[A]of j)(!O.has(A)||O.has(A)&&O.get(A)!==j.get(A))&&k.append(A,j.get(A));if(t(this,a).hasAttribute("data-merge-params"))for(const[A]of O)j.has(A)||k.append(A,O.get(A));u=`${x}?${k.toString()}`}t(this,C).navigate(u,{historyAction:n,centerScroll:S,offsetScroll:g,revalidate:c,keepSearchParameters:v,submorph:oe,clearState:Pt,keepScrollPosition:D,scrollBehaviour:ut,submorphAppend:t(this,a).hasAttribute("data-pagination-more-link"),mergeParams:t(this,a).hasAttribute("data-merge-params")&&!t(this,a).hasAttribute("data-toggle-params")})}});l(this,it,()=>{const e=t(this,a).hasAttribute("data-revalidate");t(this,C).prefetch(t(this,M,st),e),t(this,a).removeEventListener("pointerenter",t(this,it))});o(this,C,s),o(this,a,e),t(this,a).addEventListener("click",t(this,ft)),this.checkCurrent(location.href.replace(location.origin,""));const i=E(this,M,Ht).call(this,t(this,a).getAttribute("data-pagination-set-link")||t(this,a).getAttribute("data-pagination-more-link"));i&&this.updatePagination(i.currentPage,i.selector),t(this,a).hasAttribute("data-prefetch")&&t(this,a).addEventListener("pointerenter",t(this,it))}get element(){return t(this,a)}checkCurrent(e){var v;const s=t(this,C).normalizePath(e),i=t(this,C).normalizePath(t(this,M,st));t(this,a).hasAttribute("data-include")&&s.pathname.includes(i.pathname)?t(this,a).classList.add("current"):i.pathname===s.pathname?t(this,a).classList.add("current"):(v=t(this,a).getAttribute("data-associated-paths"))!=null&&v.split(",").find(D=>s.pathname.includes(D))?t(this,a).classList.add("current"):t(this,a).classList.remove("current"),s.path===i.path?t(this,a).classList.add("exact"):t(this,a).classList.remove("exact");const[n,S]=t(this,M,st).split("?"),p=new URLSearchParams(S),g=new URLSearchParams(location.search);let c=0;for(const[D]of g)p.has(D)&&g.get(D)===p.get(D)&&c++;c?(t(this,a).classList.toggle("all-params-matched",g.size===c),t(this,a).classList.toggle("some-params-matched",g.size!==c)):!g.size&&t(this,a).hasAttribute("data-match-no-params")?t(this,a).classList.add("all-params-matched"):(t(this,a).classList.remove("all-params-matched"),t(this,a).classList.remove("some-params-matched"))}updatePagination(e,s){const i=E(this,M,Ht).call(this,s);if(i)if(i.element.setAttribute("data-current-page",e.toString()),t(this,a).hasAttribute("data-pagination-more-link"))if(e<i.totalPages){t(this,a).style.display="";const n=t(this,a).querySelector("[data-pagination-more-link-counter]");n&&(n.textContent=(i.totalPages-e).toString());const S=t(this,a).getAttribute("href"),p=new URL(S,window.location.origin);p.searchParams.set("page",(e+1).toString());const g=p.href.replace(p.origin,"").toString();t(this,a).setAttribute("href",g),this.checkCurrent(g)}else t(this,a).style.display="none";else t(this,a).hasAttribute("data-pagination-set-link")&&(t(this,a).getAttribute("data-value")===e.toString()?t(this,a).classList.add("pagination-current"):t(this,a).classList.remove("pagination-current"))}destroy(){t(this,a).removeEventListener("click",t(this,ft)),t(this,a).removeEventListener("pointerenter",t(this,it)),t(this,a).classList.remove("current","exact","pagination-current")}}C=new WeakMap,a=new WeakMap,M=new WeakSet,st=function(){const e=new URL(t(this,a).href);return t(this,C).normalizePath(e.pathname+e.search+e.hash).path},Ht=function(e){if(!e)return;const s=document.querySelector(e);if(s){const i=parseInt(s.getAttribute("data-current-page")||"1"),n=parseInt(s.getAttribute("data-total-pages")||"1");return{element:s,currentPage:i,totalPages:n,selector:e}}},ft=new WeakMap,it=new WeakMap;const Se=new DOMParser;var I,J,R,V,Q,B,at,Z,X,pt;class ie{constructor(e,s){l(this,I);l(this,J);l(this,R,{x:0,y:0});l(this,V,null);l(this,Q,null);l(this,B,null);l(this,at,null);l(this,Z,null);l(this,X,null);l(this,pt);o(this,I,e),o(this,J,s)}get pathname(){return t(this,J)}get scrollState(){return t(this,R)}get document(){return t(this,B)}setHeaders(e){o(this,pt,e)}setInitialDocument(e){o(this,V,e.cloneNode(!0))}abort(){var e;return(e=t(this,Z))==null?void 0:e.abort(`[${t(this,J)}] page loading cancelled`)}fetch(e,s,i){return G(this,null,function*(){var n;if(!i){const g=((n=t(this,V))==null?void 0:n.documentElement.getAttribute("data-cache"))&&s!==e,c=t(this,V)&&t(this,I).isPopstateNavigation;if(t(this,X)||g||c)return t(this,X)}return o(this,X,new Promise(S=>G(this,null,function*(){try{o(this,Z,new AbortController);const g=yield(yield fetch(e,{signal:t(this,Z).signal,headers:Rt({"X-MORPH":"true","X-MORPH-CURRENT-PATH":encodeURIComponent(s),"X-MORPH-NEW-PATH":encodeURIComponent(e)},t(this,pt))})).text(),c=Se.parseFromString(g,"text/html");this.setInitialDocument(c)}catch(p){console.warn(p)}finally{o(this,Z,null),o(this,X,null),S()}}))),t(this,X)})}cloneDocument(){o(this,B,(t(this,Q)||t(this,V)).cloneNode(!0))}get title(){let e="";if(t(this,B).title)e=t(this,B).title;else{const s=t(this,B).querySelector("h1");e=(s==null?void 0:s.innerText)||(s==null?void 0:s.textContent)||t(this,J)}return e}clearScrollState(){t(this,R).x=0,t(this,R).y=0}clearDocumentState(){o(this,Q,null)}saveScrollState(){t(this,V).documentElement.hasAttribute("data-no-scroll-restoration")?(t(this,R).x=0,t(this,R).y=0):(t(this,R).x=t(this,I).scrollValue.left,t(this,R).y=t(this,I).scrollValue.top)}restoreScrollPosition(){t(this,I).scrollElement.scroll({top:t(this,R).y,left:t(this,R).x,behavior:"instant"})}saveDocumentState(){t(this,V).documentElement.hasAttribute("data-no-page-restoration")?o(this,Q,null):o(this,Q,document.cloneNode(!0))}renewScrollPosition(){t(this,I).scrollElement.scroll({top:0,left:0,behavior:"instant"})}saveState(e){o(this,at,e)}clearState(){const e=t(this,at);return o(this,at,null),e}}I=new WeakMap,J=new WeakMap,R=new WeakMap,V=new WeakMap,Q=new WeakMap,B=new WeakMap,at=new WeakMap,Z=new WeakMap,X=new WeakMap,pt=new WeakMap;var H,nt,gt,It,Et;class ye{constructor(e){l(this,gt);l(this,H);l(this,nt,[]);l(this,Et,()=>{E(this,gt,It).call(this)});o(this,H,e);for(const s in t(this,H).dataset){const i=Le.camelToKebab(s);if(i.startsWith("param-")){const n=i.split("param-")[1],S=t(this,H).dataset[s];t(this,nt).push({name:n,value:S})}}document.addEventListener("morphURLParametersChange",t(this,Et)),E(this,gt,It).call(this)}destroy(){document.removeEventListener("morphURLParametersChange",t(this,Et))}}H=new WeakMap,nt=new WeakMap,gt=new WeakSet,It=function(){const e=new URLSearchParams(location.search);let s=!!t(this,nt).find(n=>e.has(n.name)&&(e.get(n.name)===n.value||n.value==="*"||n.value==="all"||n.value==="any"||n.value==="vse"||e.get(n.name)==="*"||e.get(n.name)==="all"||e.get(n.name)==="any"||e.get(n.name)==="vse"));!s&&t(this,H).hasAttribute("data-match-no-params")&&(s=!t(this,nt).filter(n=>e.has(n.name)).length);const i=t(this,H).getAttribute("data-hide-class");s?i?t(this,H).classList.remove(i):t(this,H).style.display="":i?t(this,H).classList.add(i):t(this,H).style.display="none"},Et=new WeakMap;var q,rt,b,K,f,_,Y,$,U,vt,W,Lt,tt,ot,ht,St,lt,yt,m,Wt,bt,Mt,Ot,re,Ft,Bt,Xt,Kt,Tt,ct;const mt=class mt{constructor(e){l(this,m);l(this,q,null);l(this,rt,null);l(this,b,[]);l(this,K);l(this,f,null);l(this,_);l(this,Y,[]);l(this,$,!1);l(this,U,null);l(this,vt,!1);l(this,W,new Map);l(this,Lt,[]);l(this,tt,null);l(this,ot,0);l(this,ht,0);l(this,St);l(this,lt);l(this,yt);l(this,bt,e=>{var s,i;return(((s=e.getAttribute("href"))==null?void 0:s.startsWith("/"))||((i=e.getAttribute("href"))==null?void 0:i.startsWith("?")))&&!e.hasAttribute("download")&&!e.hasAttribute("data-morph-skip")&&!e.closest("[data-morph-skip]")&&e.getAttribute("target")!=="_blank"});l(this,Tt,e=>G(this,null,function*(){e.preventDefault(),o(this,$,!0),yield this.navigate(location.href.replace(location.origin,""),{historyAction:"none",submorph:t(this,lt)?void 0:t(this,St),revalidate:t(this,lt),keepScrollPosition:t(this,yt)}),o(this,$,!1)}));l(this,ct,()=>{const{left:e,top:s}=this.scrollValue,i=s-t(this,ht),n=e-t(this,ot);o(this,ht,s),o(this,ot,e),document.documentElement.classList.toggle("scroll-y",s>0),document.documentElement.classList.toggle("scroll-x",e>0),document.documentElement.classList.toggle("scroll-y-forward",i>0),document.documentElement.classList.toggle("scroll-y-backward",i<0),document.documentElement.classList.toggle("scroll-x-forward",n>0),document.documentElement.classList.toggle("scroll-x-backward",n<0),z.dispatchEvent(document,"morphScroll",{detail:{left:e,top:s}})});if(ae.isBrowser&&!mt.instance){mt.instance=this,o(this,q,{base:dt.normalizeBase(e==null?void 0:e.base),waitForHeadToLoad:(e==null?void 0:e.waitForHeadToLoad)!==!1,trailingSlash:(e==null?void 0:e.trailingSlash)||!1,scrollSelector:e==null?void 0:e.scrollSelector,morphInsideScrollContainer:(e==null?void 0:e.morphInsideScrollContainer)||!1}),o(this,rt,E(this,m,Ot).call(this,document.body));const s=this.normalizePath(location.pathname+location.search+location.hash);o(this,f,s);const i=new ie(this,t(this,f).pathname);i.setInitialDocument(document),t(this,W).set(t(this,f).pathname,i),document.documentElement.setAttribute("data-current-pathname",t(this,f).pathname),document.documentElement.setAttribute("data-current-leaf",s.leaf),this.findLinks(),this.findParamsDependent(),history.scrollRestoration="manual",addEventListener("popstate",t(this,Tt)),dt.changeHistory({action:"replace",pathname:s.pathname,searchParameters:s.parameters,hash:s.hash}),o(this,tt,new ne),E(this,m,Xt).call(this,document)}}get currentURL(){return t(this,f)}get previousURL(){return t(this,_)}get links(){return t(this,b)}get scrollElement(){return t(this,U)}get isPopstateNavigation(){return t(this,$)}get scrollValue(){let e=0,s=0;return t(this,vt)?(e=window.scrollY,s=window.scrollX):(e=t(this,U).scrollTop,s=t(this,U).scrollLeft),{top:e,left:s}}saveState(e){const s=t(this,W).get(t(this,f).path);s&&s.saveState(e)}getState(){const e=t(this,W).get(t(this,f).path);return e==null?void 0:e.clearState()}normalizePath(e,s){return dt.splitPath(e,{base:t(this,q).base,trailingSlash:t(this,q).trailingSlash,mergeParams:s!=null&&s.mergeParams?location.search:""})}prefetch(e,s){return G(this,null,function*(){var n;if(t(this,Y).length)return;e=((n=this.pathnameModifier)==null?void 0:n.call(this,e))||e;const i=E(this,m,Mt).call(this,e);i==null||i.fetch(e,t(this,f).path,s)})}excludeHeadChild(e){return!1}setHeaders(e){}navigate(oe){return G(this,arguments,function*(e,{historyAction:s="push",centerScroll:i,offsetScroll:n,scrollBehaviour:S,revalidate:p,keepSearchParameters:g,submorph:c,submorphAppend:v,clearState:D,keepScrollPosition:ut,mergeParams:et}={}){var x,wt,j,O;if(t(this,Y).length)return;o(this,St,c),o(this,lt,p),o(this,yt,ut);const Pt=((x=this.pathnameModifier)==null?void 0:x.call(this,e))||e,u=this.normalizePath(Pt,{mergeParams:et});if(!p&&(((wt=t(this,K))==null?void 0:wt.pathname)===u.pathname||t(this,f).pathname===u.pathname)){ut||E(this,m,Kt).call(this,u.hash||0,{centerScroll:i,offsetScroll:n,behavior:"smooth"}),z.dispatchEvent(document,"morphSamePath",{custom:!0}),((j=t(this,f))==null?void 0:j.parameters)!==u.parameters&&(o(this,_,t(this,f)),o(this,f,u),dt.changeHistory({action:((O=t(this,f))==null?void 0:O.hash)!==u.hash?"replace":s,pathname:u.pathname,searchParameters:u.parameters,hash:u.hash}),z.dispatchEvent(document,"morphURLParametersChange",{detail:{newURL:t(this,f),previousURL:t(this,_)}})),t(this,b).forEach(k=>{k.checkCurrent(u.path)});return}else t(this,b).forEach(k=>{k.checkCurrent(u.path)});o(this,K,u);try{let k=!0;if(this.preprocessor)try{yield new Promise((r,P)=>{var T;(T=this.preprocessor)==null||T.call(this,{url:u,resolve:r,reject:P,submorph:c})})}catch(r){r?console.error(r):console.log("Route change canceled"),k=!1}if(!k||t(this,K).pathname!==u.pathname){t(this,b).forEach(r=>{r.checkCurrent(t(this,f).path)});return}const A={url:u,submorph:c};c?v||c.forEach(r=>{document.querySelectorAll(r).forEach(P=>{P.classList.add("out"),P.setAttribute("data-morph-out","")})}):t(this,rt).forEach(r=>{var P,T;(P=r.firstElementChild)==null||P.classList.add("out"),(T=r.firstElementChild)==null||T.setAttribute("data-morph-out","")}),z.dispatchEvent(document,"morphNavigation",{detail:A});const Ut=E(this,m,Mt).call(this,t(this,f).pathname),y=E(this,m,Mt).call(this,u.pathname);if(t(this,W).forEach(r=>{r.pathname!==u.pathname&&r.abort()}),yield y==null?void 0:y.fetch(Pt,t(this,f).path,p),t(this,K).pathname!==u.pathname){t(this,b).forEach(r=>{r.checkCurrent(t(this,f).path)});return}Ut.clearState(),Ut.saveScrollState(),Ut.saveDocumentState(),(!t(this,$)||p)&&(y.clearScrollState(),y.clearDocumentState()),D&&y.clearState(),y.cloneDocument(),t(this,tt).textContent=y.title,document.body.appendChild(t(this,tt));const At=qt(Rt({},A),{document:y.document});v||At.document.querySelectorAll("[data-morph-out]").forEach(r=>{r.classList.remove("out")}),z.dispatchEvent(document,"morphStart",{detail:At});const Yt=Array.from(document.head.children),$t=Array.from(y.document.head.children),jt=E(this,m,re).call(this,Yt,$t),he=E(this,m,Ft).call(this,Yt,jt),kt=E(this,m,Ft).call(this,$t,jt).filter(r=>!this.excludeHeadChild(r));kt.forEach((r,P)=>{r.tagName==="SCRIPT"&&(kt[P]=E(this,m,Wt).call(this,r))}),kt.forEach(r=>{document.head.appendChild(r)});const xt=kt.filter(r=>{if(r.hasAttribute("data-no-waiting"))return!1;if(E(this,m,Bt).call(this,r))return!0});t(this,q).waitForHeadToLoad&&xt.length&&(yield new Promise(r=>G(this,null,function*(){let P=0;try{for(var T=ee(xt),ce,F,N;ce=!(F=yield T.next()).done;ce=!1){const Ct=F.value;Ct.onload=()=>{P++,P===xt.length&&r()}}}catch(F){N=[F]}finally{try{ce&&(F=T.return)&&(yield F.call(T))}finally{if(N)throw N[0]}}}))),yield se.wait(10);const Gt=[];v||he.forEach(r=>{r.hasAttribute("data-permanent")||(E(this,m,Bt).call(this,r)?Gt.push(r):r.remove())});const le=E(this,m,Ot).call(this,y.document.body);!t(this,q).morphInsideScrollContainer&&!c&&E(this,m,Xt).call(this,y.document),document.documentElement.setAttribute("data-current-pathname",u.pathname),document.documentElement.setAttribute("data-current-leaf",u.leaf),dt.changeHistory({action:s,pathname:u.pathname,searchParameters:u.parameters||(g?location.search:""),hash:u.hash}),t(this,tt).remove(),o(this,_,t(this,f)),o(this,f,u);const Nt=[];t(this,rt).forEach((r,P)=>{const T=le[P],ce=getComputedStyle(r).getPropertyValue("--morph-duration");let F=[],N=[];c?(c.forEach(d=>{const L=r.querySelector(d),w=T.querySelector(d);L&&w&&(N.push(L),F.push(w))}),N.forEach(d=>{d.parentElement&&Nt.push(d.parentElement)})):(F.push(...T.childNodes),N.push(...r.childNodes),Nt.push(r));const Ct=[];v||N.forEach(d=>{d instanceof HTMLElement&&(this.destroyOldLinks(d),d.classList.add("old"),d.querySelectorAll("[data-morph-transfer]").forEach(w=>{const de=w.getAttribute("data-morph-transfer");Ct.push({element:w,selector:de})}))}),F.forEach(d=>{d instanceof HTMLElement&&(this.findNewLinks(d),d.classList.add("new"),Ct.forEach(L=>{const w=d.querySelector(L.selector);w&&w.replaceWith(L.element)}))}),c?v?F.forEach((d,L)=>{N[L]instanceof HTMLElement&&N[L].append(...d.childNodes)}):F.forEach((d,L)=>{var w;(w=N[L].parentElement)==null||w.insertBefore(d,N[L])}):r.prepend(...F),setTimeout(()=>{v||N.forEach(d=>{d instanceof HTMLElement&&d.classList.add("old-idle")}),F.forEach(d=>{var L;d instanceof HTMLElement&&((L=d.parentElement)==null||L.style.setProperty("--new-content-height",d.offsetHeight+"px"),d.classList.add("new-idle"))})},0);const Jt=qt(Rt({},At),{morphElement:r});z.dispatchEvent(document,"morphNewChildrenAdded",{detail:Jt});const ue=new Promise(d=>{setTimeout(()=>{v||N.forEach(L=>{L.remove()}),F.forEach(L=>{var w;L instanceof HTMLElement&&((w=L.parentElement)==null||w.style.removeProperty("--new-content-height"),L.classList.remove("new-idle","new"))}),v||z.dispatchEvent(document,"morphOldChildrenRemoved",{detail:Jt}),d()},(parseFloat(ce)||0)*1e3+10)});t(this,Y).push(ue)}),this.isPopstateNavigation?document.documentElement.style.setProperty("--new-document-scroll-position",(this.scrollValue.top-y.scrollState.y)*1+"px"):document.documentElement.style.setProperty("--new-document-scroll-position",this.scrollValue.top+"px"),z.dispatchEvent(document,"morphBeforeNavigationScroll",{detail:y.scrollState}),u.hash?(y.clearScrollState(),E(this,m,Kt).call(this,u.hash,{centerScroll:i,offsetScroll:n,behavior:S})):t(this,$)?y.restoreScrollPosition():ut||y.renewScrollPosition(),yield Promise.all(t(this,Y)),v||Gt.forEach(r=>r.remove()),o(this,Y,[]),Nt.forEach(r=>{r.querySelectorAll("script").forEach(T=>{T.replaceWith(E(this,m,Wt).call(this,T))})}),t(this,b).forEach(r=>{r.checkCurrent(t(this,f).path)}),this.findParamsDependent(),z.dispatchEvent(document,"morphComplete",{detail:At}),document.documentElement.style.removeProperty("--new-document-scroll-position"),window.dispatchEvent(new Event("resize"))}catch(k){console.error(k)}o(this,K,void 0)})}addLink(e){t(this,b).push(new zt(e,this))}addLinks(e){e.forEach(s=>{this.addLink(s)})}removeLink(e){o(this,b,t(this,b).filter(s=>s.element===e?(s.destroy(),!1):!0))}destroyOldLinks(e){o(this,b,t(this,b).filter(s=>e.contains(s.element)?(s.destroy(),!1):!0))}findNewLinks(e){const s=[...e.querySelectorAll("a")].filter(t(this,bt));t(this,b).push(...s.map(i=>new zt(i,this)))}findLinks(){const e=[...document.documentElement.querySelectorAll("a")].filter(t(this,bt));t(this,b).forEach(s=>s.destroy()),o(this,b,e.map(s=>new zt(s,this)))}findParamsDependent(){const e=[...document.documentElement.querySelectorAll("[data-morph-params-dependent]")];t(this,Lt).forEach(s=>s.destroy()),o(this,Lt,e.map(s=>new ye(s)))}};q=new WeakMap,rt=new WeakMap,b=new WeakMap,K=new WeakMap,f=new WeakMap,_=new WeakMap,Y=new WeakMap,$=new WeakMap,U=new WeakMap,vt=new WeakMap,W=new WeakMap,Lt=new WeakMap,tt=new WeakMap,ot=new WeakMap,ht=new WeakMap,St=new WeakMap,lt=new WeakMap,yt=new WeakMap,m=new WeakSet,Wt=function(e){const s=document.createElement("script");for(let i=0;i<e.attributes.length;i++){const n=e.attributes[i];s.setAttribute(n.name,n.value)}return e.hasAttribute("src")||(s.innerHTML=e.innerHTML),s},bt=new WeakMap,Mt=function(e){const s=this.normalizePath(e);let i=t(this,W).get(s.pathname);return i||(i=new ie(this,s.pathname),t(this,W).set(s.pathname,i)),i},Ot=function(e){const s=[...e.querySelectorAll("[data-morph]")];return s.length?s:[e]},re=function(e,s){return e.filter(i=>s.find(n=>n.outerHTML===i.outerHTML))},Ft=function(e,s){return e.filter(i=>!s.find(n=>n.outerHTML===i.outerHTML))},Bt=function(e){return e.tagName==="SCRIPT"||e.tagName==="STYLE"||e.tagName==="LINK"&&e.getAttribute("rel")==="stylesheet"},Xt=function(e){var s,i;(s=t(this,U))==null||s.removeEventListener("scroll",t(this,ct)),o(this,ht,0),o(this,ot,0),o(this,U,t(this,q).scrollSelector&&e.querySelector(t(this,q).scrollSelector)||window),o(this,vt,t(this,U)===window),(i=t(this,U))==null||i.addEventListener("scroll",t(this,ct)),t(this,ct).call(this)},Kt=function(e,s){const i=typeof e=="string"?document.getElementById(e):e;(typeof i=="number"||i)&&se.scrollToElement(i,{scrollElement:t(this,U),behavior:(s==null?void 0:s.behavior)||"instant",center:s==null?void 0:s.centerScroll,offset:s==null?void 0:s.offsetScroll})},Tt=new WeakMap,ct=new WeakMap,mt.instance=null;let Vt=mt;exports.Morph=Vt;
1
+ "use strict";var me=Object.defineProperty,fe=Object.defineProperties;var pe=Object.getOwnPropertyDescriptors;var Qt=Object.getOwnPropertySymbols;var ge=Object.prototype.hasOwnProperty,Ee=Object.prototype.propertyIsEnumerable;var Zt=(h,e)=>(e=Symbol[h])?e:Symbol.for("Symbol."+h),te=h=>{throw TypeError(h)};var _t=(h,e,s)=>e in h?me(h,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):h[e]=s,Rt=(h,e)=>{for(var s in e||(e={}))ge.call(e,s)&&_t(h,s,e[s]);if(Qt)for(var s of Qt(e))Ee.call(e,s)&&_t(h,s,e[s]);return h},qt=(h,e)=>fe(h,pe(e));var Dt=(h,e,s)=>e.has(h)||te("Cannot "+s);var t=(h,e,s)=>(Dt(h,e,"read from private field"),s?s.call(h):e.get(h)),l=(h,e,s)=>e.has(h)?te("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(h):e.set(h,s),o=(h,e,s,i)=>(Dt(h,e,"write to private field"),i?i.call(h,s):e.set(h,s),s),E=(h,e,s)=>(Dt(h,e,"access private method"),s);var G=(h,e,s)=>new Promise((i,n)=>{var S=c=>{try{g(s.next(c))}catch(v){n(v)}},p=c=>{try{g(s.throw(c))}catch(v){n(v)}},g=c=>c.done?i(c.value):Promise.resolve(c.value).then(S,p);g((s=s.apply(h,e)).next())});var ee=(h,e,s)=>(e=h[Zt("asyncIterator")])?e.call(h):(h=h[Zt("iterator")](),e={},s=(i,n)=>(n=h[i])&&(e[i]=S=>new Promise((p,g,c)=>(S=n.call(h,S),c=S.done,Promise.resolve(S.value).then(v=>p({value:v,done:c}),g)))),s("next"),s("return"),e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ae=require("../index-DekP7OZe.cjs"),z=require("../events-KVanG9sR.cjs"),se=require("../scroll-CIdNtj3G.cjs");require("construct-style-sheets-polyfill");const dt=require("../url-Dns-01WU.cjs"),ve=require("../css-value-parser/index.cjs"),Le=require("../string-DUXXtU8v.cjs");class ne extends HTMLElement{connectedCallback(){const e={"aria-live":"assertive","aria-atomic":"true",style:"position: absolute; left: 0; top: 0; clip: rect(0 0 0 0); clip-path: inset(50%); overflow: hidden; white-space: nowrap; width: 1px; height: 1px"};for(const[s,i]of Object.entries(e))this.setAttribute(s,i)}}ae.isBrowser&&!customElements.get("morph-announcer")&&customElements.define("morph-announcer",ne);var C,a,M,st,Ht,ft,it;class zt{constructor(e,s){l(this,M);l(this,C);l(this,a);l(this,ft,e=>{var i;if(e.preventDefault(),document.documentElement.classList.contains("click-disabled"))return;if(t(this,a).hasAttribute("data-back")&&t(this,C).previousURL)history.back();else{const n=t(this,a).getAttribute("data-history-action")||"push",S=t(this,a).hasAttribute("data-center-scroll"),p=getComputedStyle(t(this,a)).getPropertyValue("--offset-scroll").trim(),g=p?ve.cssValueParser.parse(p):void 0,c=t(this,a).hasAttribute("data-revalidate")||t(this,a).hasAttribute("data-pagination-more-link")||t(this,a).hasAttribute("data-pagination-set-link"),v=t(this,a).hasAttribute("data-keep-search-parameters"),D=t(this,a).hasAttribute("data-keep-scroll-position")||t(this,a).hasAttribute("data-pagination-more-link"),ut=t(this,a).getAttribute("data-scroll-behaviour"),et=E(this,M,Ht).call(this,t(this,a).getAttribute("data-pagination-set-link")||t(this,a).getAttribute("data-pagination-more-link"));et&&(t(this,a).hasAttribute("data-pagination-set-link")?t(this,C).links.forEach(x=>{x.updatePagination(parseInt(t(this,a).getAttribute("data-value")||"1"),et.selector)}):t(this,a).hasAttribute("data-pagination-more-link")&&t(this,C).links.forEach(x=>{x.updatePagination(et.currentPage+1,et.selector)}));const oe=((i=t(this,a).getAttribute("data-submorph"))==null?void 0:i.split(",").map(x=>x.trim()))||t(this,a).hasAttribute("data-pagination-more-link")&&[t(this,a).getAttribute("data-pagination-more-link")]||t(this,a).hasAttribute("data-pagination-set-link")&&[t(this,a).getAttribute("data-pagination-set-link")]||void 0,Pt=t(this,a).hasAttribute("data-clear-state");let u=t(this,M,st);if(t(this,a).hasAttribute("data-toggle-params")){const[x,wt]=t(this,M,st).split("?"),j=new URLSearchParams(wt),O=new URLSearchParams(location.search),k=new URLSearchParams;for(const[A]of j)(!O.has(A)||O.has(A)&&O.get(A)!==j.get(A))&&k.append(A,j.get(A));if(t(this,a).hasAttribute("data-merge-params"))for(const[A]of O)j.has(A)||k.append(A,O.get(A));u=`${x}?${k.toString()}`}t(this,C).navigate(u,{historyAction:n,centerScroll:S,offsetScroll:g,revalidate:c,keepSearchParameters:v,submorph:oe,clearState:Pt,keepScrollPosition:D,scrollBehaviour:ut,submorphAppend:t(this,a).hasAttribute("data-pagination-more-link"),mergeParams:t(this,a).hasAttribute("data-merge-params")&&!t(this,a).hasAttribute("data-toggle-params")})}});l(this,it,()=>{const e=t(this,a).hasAttribute("data-revalidate");t(this,C).prefetch(t(this,M,st),e),t(this,a).removeEventListener("pointerenter",t(this,it))});o(this,C,s),o(this,a,e),t(this,a).addEventListener("click",t(this,ft)),this.checkCurrent(location.href.replace(location.origin,""));const i=E(this,M,Ht).call(this,t(this,a).getAttribute("data-pagination-set-link")||t(this,a).getAttribute("data-pagination-more-link"));i&&this.updatePagination(i.currentPage,i.selector),t(this,a).hasAttribute("data-prefetch")&&t(this,a).addEventListener("pointerenter",t(this,it))}get element(){return t(this,a)}checkCurrent(e){var v;const s=t(this,C).normalizePath(e),i=t(this,C).normalizePath(t(this,M,st));t(this,a).hasAttribute("data-include")&&s.pathname.includes(i.pathname)?t(this,a).classList.add("current"):i.pathname===s.pathname?t(this,a).classList.add("current"):(v=t(this,a).getAttribute("data-associated-paths"))!=null&&v.split(",").find(D=>s.pathname.includes(D))?t(this,a).classList.add("current"):t(this,a).classList.remove("current"),s.path===i.path?t(this,a).classList.add("exact"):t(this,a).classList.remove("exact");const[n,S]=t(this,M,st).split("?"),p=new URLSearchParams(S),g=new URLSearchParams(location.search);let c=0;for(const[D]of g)p.has(D)&&g.get(D)===p.get(D)&&c++;c?(t(this,a).classList.toggle("all-params-matched",g.size===c),t(this,a).classList.toggle("some-params-matched",g.size!==c)):!g.size&&t(this,a).hasAttribute("data-match-no-params")?t(this,a).classList.add("all-params-matched"):(t(this,a).classList.remove("all-params-matched"),t(this,a).classList.remove("some-params-matched"))}updatePagination(e,s){const i=E(this,M,Ht).call(this,s);if(i)if(i.element.setAttribute("data-current-page",e.toString()),t(this,a).hasAttribute("data-pagination-more-link"))if(e<i.totalPages){t(this,a).style.display="";const n=t(this,a).querySelector("[data-pagination-more-link-counter]");n&&(n.textContent=(i.totalPages-e).toString());const S=t(this,a).getAttribute("href"),p=new URL(S,window.location.origin);p.searchParams.set("page",(e+1).toString());const g=p.href.replace(p.origin,"").toString();t(this,a).setAttribute("href",g),this.checkCurrent(g)}else t(this,a).style.display="none";else t(this,a).hasAttribute("data-pagination-set-link")&&(t(this,a).getAttribute("data-value")===e.toString()?t(this,a).classList.add("pagination-current"):t(this,a).classList.remove("pagination-current"))}destroy(){t(this,a).removeEventListener("click",t(this,ft)),t(this,a).removeEventListener("pointerenter",t(this,it)),t(this,a).classList.remove("current","exact","pagination-current")}}C=new WeakMap,a=new WeakMap,M=new WeakSet,st=function(){const e=new URL(t(this,a).href);return t(this,C).normalizePath(e.pathname+e.search+e.hash).path},Ht=function(e){if(!e)return;const s=document.querySelector(e);if(s){const i=parseInt(s.getAttribute("data-current-page")||"1"),n=parseInt(s.getAttribute("data-total-pages")||"1");return{element:s,currentPage:i,totalPages:n,selector:e}}},ft=new WeakMap,it=new WeakMap;const Se=new DOMParser;var I,J,R,V,Q,B,at,Z,X,pt;class ie{constructor(e,s){l(this,I);l(this,J);l(this,R,{x:0,y:0});l(this,V,null);l(this,Q,null);l(this,B,null);l(this,at,null);l(this,Z,null);l(this,X,null);l(this,pt);o(this,I,e),o(this,J,s)}get pathname(){return t(this,J)}get scrollState(){return t(this,R)}get document(){return t(this,B)}setHeaders(e){o(this,pt,e)}setInitialDocument(e){o(this,V,e.cloneNode(!0))}abort(){var e;return(e=t(this,Z))==null?void 0:e.abort(`[${t(this,J)}] page loading cancelled`)}fetch(e,s,i){return G(this,null,function*(){var n;if(!i){const g=((n=t(this,V))==null?void 0:n.documentElement.getAttribute("data-cache"))&&s!==e,c=t(this,V)&&t(this,I).isPopstateNavigation;if(t(this,X)||g||c)return t(this,X)}return o(this,X,new Promise(S=>G(this,null,function*(){try{o(this,Z,new AbortController);const g=yield(yield fetch(e,{signal:t(this,Z).signal,headers:Rt({"X-MORPH":"true","X-MORPH-CURRENT-PATH":encodeURIComponent(s),"X-MORPH-NEW-PATH":encodeURIComponent(e)},t(this,pt))})).text(),c=Se.parseFromString(g,"text/html");this.setInitialDocument(c)}catch(p){console.warn(p)}finally{o(this,Z,null),o(this,X,null),S()}}))),t(this,X)})}cloneDocument(){o(this,B,(t(this,Q)||t(this,V)).cloneNode(!0))}get title(){let e="";if(t(this,B).title)e=t(this,B).title;else{const s=t(this,B).querySelector("h1");e=(s==null?void 0:s.innerText)||(s==null?void 0:s.textContent)||t(this,J)}return e}clearScrollState(){t(this,R).x=0,t(this,R).y=0}clearDocumentState(){o(this,Q,null)}saveScrollState(){t(this,V).documentElement.hasAttribute("data-no-scroll-restoration")?(t(this,R).x=0,t(this,R).y=0):(t(this,R).x=t(this,I).scrollValue.left,t(this,R).y=t(this,I).scrollValue.top)}restoreScrollPosition(){t(this,I).scrollElement.scroll({top:t(this,R).y,left:t(this,R).x,behavior:"instant"})}saveDocumentState(){t(this,V).documentElement.hasAttribute("data-no-page-restoration")?o(this,Q,null):o(this,Q,document.cloneNode(!0))}renewScrollPosition(){t(this,I).scrollElement.scroll({top:0,left:0,behavior:"instant"})}saveState(e){o(this,at,e)}clearState(){const e=t(this,at);return o(this,at,null),e}}I=new WeakMap,J=new WeakMap,R=new WeakMap,V=new WeakMap,Q=new WeakMap,B=new WeakMap,at=new WeakMap,Z=new WeakMap,X=new WeakMap,pt=new WeakMap;var H,nt,gt,It,Et;class ye{constructor(e){l(this,gt);l(this,H);l(this,nt,[]);l(this,Et,()=>{E(this,gt,It).call(this)});o(this,H,e);for(const s in t(this,H).dataset){const i=Le.camelToKebab(s);if(i.startsWith("param-")){const n=i.split("param-")[1],S=t(this,H).dataset[s];t(this,nt).push({name:n,value:S})}}document.addEventListener("morphURLParametersChange",t(this,Et)),E(this,gt,It).call(this)}destroy(){document.removeEventListener("morphURLParametersChange",t(this,Et))}}H=new WeakMap,nt=new WeakMap,gt=new WeakSet,It=function(){const e=new URLSearchParams(location.search);let s=!!t(this,nt).find(n=>e.has(n.name)&&(e.get(n.name)===n.value||n.value==="*"||n.value==="all"||n.value==="any"||n.value==="vse"||e.get(n.name)==="*"||e.get(n.name)==="all"||e.get(n.name)==="any"||e.get(n.name)==="vse"));!s&&t(this,H).hasAttribute("data-match-no-params")&&(s=!t(this,nt).filter(n=>e.has(n.name)).length);const i=t(this,H).getAttribute("data-hide-class");s?i?t(this,H).classList.remove(i):t(this,H).style.display="":i?t(this,H).classList.add(i):t(this,H).style.display="none"},Et=new WeakMap;var q,rt,b,K,f,_,Y,$,U,vt,W,Lt,tt,ot,ht,St,lt,yt,m,Wt,bt,Mt,Ot,re,Ft,Bt,Xt,Kt,Tt,ct;const mt=class mt{constructor(e){l(this,m);l(this,q,null);l(this,rt,null);l(this,b,[]);l(this,K);l(this,f,null);l(this,_);l(this,Y,[]);l(this,$,!1);l(this,U,null);l(this,vt,!1);l(this,W,new Map);l(this,Lt,[]);l(this,tt,null);l(this,ot,0);l(this,ht,0);l(this,St);l(this,lt);l(this,yt);l(this,bt,e=>{var s,i;return(((s=e.getAttribute("href"))==null?void 0:s.startsWith("/"))||((i=e.getAttribute("href"))==null?void 0:i.startsWith("?")))&&!e.hasAttribute("download")&&!e.hasAttribute("data-morph-skip")&&!e.closest("[data-morph-skip]")&&e.getAttribute("target")!=="_blank"});l(this,Tt,e=>G(this,null,function*(){e.preventDefault(),o(this,$,!0),yield this.navigate(location.href.replace(location.origin,""),{historyAction:"none",submorph:t(this,lt)?void 0:t(this,St),revalidate:t(this,lt),keepScrollPosition:t(this,yt)}),o(this,$,!1)}));l(this,ct,()=>{const{left:e,top:s}=this.scrollValue,i=s-t(this,ht),n=e-t(this,ot);o(this,ht,s),o(this,ot,e),document.documentElement.classList.toggle("scroll-y",s>0),document.documentElement.classList.toggle("scroll-x",e>0),document.documentElement.classList.toggle("scroll-y-forward",i>0),document.documentElement.classList.toggle("scroll-y-backward",i<0),document.documentElement.classList.toggle("scroll-x-forward",n>0),document.documentElement.classList.toggle("scroll-x-backward",n<0),z.dispatchEvent(document,"morphScroll",{detail:{left:e,top:s}})});if(ae.isBrowser&&!mt.instance){mt.instance=this,o(this,q,{base:dt.normalizeBase(e==null?void 0:e.base),waitForHeadToLoad:(e==null?void 0:e.waitForHeadToLoad)!==!1,trailingSlash:(e==null?void 0:e.trailingSlash)||!1,scrollSelector:e==null?void 0:e.scrollSelector,morphInsideScrollContainer:(e==null?void 0:e.morphInsideScrollContainer)||!1}),o(this,rt,E(this,m,Ot).call(this,document.body));const s=this.normalizePath(location.pathname+location.search+location.hash);o(this,f,s);const i=new ie(this,t(this,f).pathname);i.setInitialDocument(document),t(this,W).set(t(this,f).pathname,i),document.documentElement.setAttribute("data-current-pathname",t(this,f).pathname),document.documentElement.setAttribute("data-current-leaf",s.leaf),this.findLinks(),this.findParamsDependent(),history.scrollRestoration="manual",addEventListener("popstate",t(this,Tt)),dt.changeHistory({action:"replace",pathname:s.pathname,searchParameters:s.parameters,hash:s.hash}),o(this,tt,new ne),E(this,m,Xt).call(this,document)}}get currentURL(){return t(this,f)}get previousURL(){return t(this,_)}get links(){return t(this,b)}get scrollElement(){return t(this,U)}get isPopstateNavigation(){return t(this,$)}get scrollValue(){let e=0,s=0;return t(this,vt)?(e=window.scrollY,s=window.scrollX):(e=t(this,U).scrollTop,s=t(this,U).scrollLeft),{top:e,left:s}}saveState(e){const s=t(this,W).get(t(this,f).path);s&&s.saveState(e)}getState(){const e=t(this,W).get(t(this,f).path);return e==null?void 0:e.clearState()}normalizePath(e,s){return dt.splitPath(e,{base:t(this,q).base,trailingSlash:t(this,q).trailingSlash,mergeParams:s!=null&&s.mergeParams?location.search:""})}prefetch(e,s){return G(this,null,function*(){var n;if(t(this,Y).length)return;e=((n=this.pathnameModifier)==null?void 0:n.call(this,e))||e;const i=E(this,m,Mt).call(this,e);i==null||i.fetch(e,t(this,f).path,s)})}excludeHeadChild(e){return!1}setHeaders(e){}navigate(oe){return G(this,arguments,function*(e,{historyAction:s="push",centerScroll:i,offsetScroll:n,scrollBehaviour:S,revalidate:p,keepSearchParameters:g,submorph:c,submorphAppend:v,clearState:D,keepScrollPosition:ut,mergeParams:et}={}){var x,wt,j,O;if(t(this,Y).length)return;o(this,St,c),o(this,lt,p),o(this,yt,ut);const Pt=((x=this.pathnameModifier)==null?void 0:x.call(this,e))||e,u=this.normalizePath(Pt,{mergeParams:et});if(!p&&(((wt=t(this,K))==null?void 0:wt.pathname)===u.pathname||t(this,f).pathname===u.pathname)){ut||E(this,m,Kt).call(this,u.hash||0,{centerScroll:i,offsetScroll:n,behavior:"smooth"}),z.dispatchEvent(document,"morphSamePath",{custom:!0}),((j=t(this,f))==null?void 0:j.parameters)!==u.parameters&&(o(this,_,t(this,f)),o(this,f,u),dt.changeHistory({action:((O=t(this,f))==null?void 0:O.hash)!==u.hash?"replace":s,pathname:u.pathname,searchParameters:u.parameters,hash:u.hash}),z.dispatchEvent(document,"morphURLParametersChange",{detail:{newURL:t(this,f),previousURL:t(this,_)}})),t(this,b).forEach(k=>{k.checkCurrent(u.path)});return}else t(this,b).forEach(k=>{k.checkCurrent(u.path)});o(this,K,u);try{let k=!0;if(this.preprocessor)try{yield new Promise((r,P)=>{var T;(T=this.preprocessor)==null||T.call(this,{url:u,resolve:r,reject:P,submorph:c})})}catch(r){r?console.error(r):console.log("Route change canceled"),k=!1}if(!k||t(this,K).pathname!==u.pathname){t(this,b).forEach(r=>{r.checkCurrent(t(this,f).path)});return}const A={url:u,submorph:c};c?v||c.forEach(r=>{document.querySelectorAll(r).forEach(P=>{P.classList.add("out"),P.setAttribute("data-morph-out","")})}):t(this,rt).forEach(r=>{var P,T;(P=r.firstElementChild)==null||P.classList.add("out"),(T=r.firstElementChild)==null||T.setAttribute("data-morph-out","")}),z.dispatchEvent(document,"morphNavigation",{detail:A});const Ut=E(this,m,Mt).call(this,t(this,f).pathname),y=E(this,m,Mt).call(this,u.pathname);if(t(this,W).forEach(r=>{r.pathname!==u.pathname&&r.abort()}),yield y==null?void 0:y.fetch(Pt,t(this,f).path,p),t(this,K).pathname!==u.pathname){t(this,b).forEach(r=>{r.checkCurrent(t(this,f).path)});return}Ut.clearState(),Ut.saveScrollState(),Ut.saveDocumentState(),(!t(this,$)||p)&&(y.clearScrollState(),y.clearDocumentState()),D&&y.clearState(),y.cloneDocument(),t(this,tt).textContent=y.title,document.body.appendChild(t(this,tt));const At=qt(Rt({},A),{document:y.document});v||At.document.querySelectorAll("[data-morph-out]").forEach(r=>{r.classList.remove("out")}),z.dispatchEvent(document,"morphStart",{detail:At});const Yt=Array.from(document.head.children),$t=Array.from(y.document.head.children),jt=E(this,m,re).call(this,Yt,$t),he=E(this,m,Ft).call(this,Yt,jt),kt=E(this,m,Ft).call(this,$t,jt).filter(r=>!this.excludeHeadChild(r));kt.forEach((r,P)=>{r.tagName==="SCRIPT"&&(kt[P]=E(this,m,Wt).call(this,r))}),kt.forEach(r=>{document.head.appendChild(r)});const xt=kt.filter(r=>{if(r.hasAttribute("data-no-waiting"))return!1;if(E(this,m,Bt).call(this,r))return!0});t(this,q).waitForHeadToLoad&&xt.length&&(yield new Promise(r=>G(this,null,function*(){let P=0;try{for(var T=ee(xt),ce,F,N;ce=!(F=yield T.next()).done;ce=!1){const Ct=F.value;Ct.onload=()=>{P++,P===xt.length&&r()}}}catch(F){N=[F]}finally{try{ce&&(F=T.return)&&(yield F.call(T))}finally{if(N)throw N[0]}}}))),yield se.wait(10);const Gt=[];v||he.forEach(r=>{r.hasAttribute("data-permanent")||(E(this,m,Bt).call(this,r)?Gt.push(r):r.remove())});const le=E(this,m,Ot).call(this,y.document.body);!t(this,q).morphInsideScrollContainer&&!c&&E(this,m,Xt).call(this,y.document),document.documentElement.setAttribute("data-current-pathname",u.pathname),document.documentElement.setAttribute("data-current-leaf",u.leaf),dt.changeHistory({action:s,pathname:u.pathname,searchParameters:u.parameters||(g?location.search:""),hash:u.hash}),t(this,tt).remove(),o(this,_,t(this,f)),o(this,f,u);const Nt=[];t(this,rt).forEach((r,P)=>{const T=le[P],ce=getComputedStyle(r).getPropertyValue("--morph-duration");let F=[],N=[];c?(c.forEach(d=>{const L=r.querySelector(d),w=T.querySelector(d);L&&w&&(N.push(L),F.push(w))}),N.forEach(d=>{d.parentElement&&Nt.push(d.parentElement)})):(F.push(...T.childNodes),N.push(...r.childNodes),Nt.push(r));const Ct=[];v||N.forEach(d=>{d instanceof HTMLElement&&(this.destroyOldLinks(d),d.classList.add("old"),d.querySelectorAll("[data-morph-transfer]").forEach(w=>{const de=w.getAttribute("data-morph-transfer");Ct.push({element:w,selector:de})}))}),F.forEach(d=>{d instanceof HTMLElement&&(Ct.forEach(L=>{const w=d.querySelector(L.selector);w&&w.replaceWith(L.element)}),this.findNewLinks(d),d.classList.add("new"))}),c?v?F.forEach((d,L)=>{N[L]instanceof HTMLElement&&N[L].append(...d.childNodes)}):F.forEach((d,L)=>{var w;(w=N[L].parentElement)==null||w.insertBefore(d,N[L])}):r.prepend(...F),setTimeout(()=>{v||N.forEach(d=>{d instanceof HTMLElement&&d.classList.add("old-idle")}),F.forEach(d=>{var L;d instanceof HTMLElement&&((L=d.parentElement)==null||L.style.setProperty("--new-content-height",d.offsetHeight+"px"),d.classList.add("new-idle"))})},0);const Jt=qt(Rt({},At),{morphElement:r});z.dispatchEvent(document,"morphNewChildrenAdded",{detail:Jt});const ue=new Promise(d=>{setTimeout(()=>{v||N.forEach(L=>{L.remove()}),F.forEach(L=>{var w;L instanceof HTMLElement&&((w=L.parentElement)==null||w.style.removeProperty("--new-content-height"),L.classList.remove("new-idle","new"))}),v||z.dispatchEvent(document,"morphOldChildrenRemoved",{detail:Jt}),d()},(parseFloat(ce)||0)*1e3+10)});t(this,Y).push(ue)}),this.isPopstateNavigation?document.documentElement.style.setProperty("--new-document-scroll-position",(this.scrollValue.top-y.scrollState.y)*1+"px"):document.documentElement.style.setProperty("--new-document-scroll-position",this.scrollValue.top+"px"),z.dispatchEvent(document,"morphBeforeNavigationScroll",{detail:y.scrollState}),u.hash?(y.clearScrollState(),E(this,m,Kt).call(this,u.hash,{centerScroll:i,offsetScroll:n,behavior:S})):t(this,$)?y.restoreScrollPosition():ut||y.renewScrollPosition(),yield Promise.all(t(this,Y)),v||Gt.forEach(r=>r.remove()),o(this,Y,[]),Nt.forEach(r=>{r.querySelectorAll("script").forEach(T=>{T.replaceWith(E(this,m,Wt).call(this,T))})}),t(this,b).forEach(r=>{r.checkCurrent(t(this,f).path)}),this.findParamsDependent(),z.dispatchEvent(document,"morphComplete",{detail:At}),document.documentElement.style.removeProperty("--new-document-scroll-position"),window.dispatchEvent(new Event("resize"))}catch(k){console.error(k)}o(this,K,void 0)})}addLink(e){t(this,b).push(new zt(e,this))}addLinks(e){e.forEach(s=>{this.addLink(s)})}removeLink(e){o(this,b,t(this,b).filter(s=>s.element===e?(s.destroy(),!1):!0))}destroyOldLinks(e){o(this,b,t(this,b).filter(s=>e.contains(s.element)?(s.destroy(),!1):!0))}findNewLinks(e){const s=[...e.querySelectorAll("a")].filter(t(this,bt));t(this,b).push(...s.map(i=>new zt(i,this)))}findLinks(){const e=[...document.documentElement.querySelectorAll("a")].filter(t(this,bt));t(this,b).forEach(s=>s.destroy()),o(this,b,e.map(s=>new zt(s,this)))}findParamsDependent(){const e=[...document.documentElement.querySelectorAll("[data-morph-params-dependent]")];t(this,Lt).forEach(s=>s.destroy()),o(this,Lt,e.map(s=>new ye(s)))}};q=new WeakMap,rt=new WeakMap,b=new WeakMap,K=new WeakMap,f=new WeakMap,_=new WeakMap,Y=new WeakMap,$=new WeakMap,U=new WeakMap,vt=new WeakMap,W=new WeakMap,Lt=new WeakMap,tt=new WeakMap,ot=new WeakMap,ht=new WeakMap,St=new WeakMap,lt=new WeakMap,yt=new WeakMap,m=new WeakSet,Wt=function(e){const s=document.createElement("script");for(let i=0;i<e.attributes.length;i++){const n=e.attributes[i];s.setAttribute(n.name,n.value)}return e.hasAttribute("src")||(s.innerHTML=e.innerHTML),s},bt=new WeakMap,Mt=function(e){const s=this.normalizePath(e);let i=t(this,W).get(s.pathname);return i||(i=new ie(this,s.pathname),t(this,W).set(s.pathname,i)),i},Ot=function(e){const s=[...e.querySelectorAll("[data-morph]")];return s.length?s:[e]},re=function(e,s){return e.filter(i=>s.find(n=>n.outerHTML===i.outerHTML))},Ft=function(e,s){return e.filter(i=>!s.find(n=>n.outerHTML===i.outerHTML))},Bt=function(e){return e.tagName==="SCRIPT"||e.tagName==="STYLE"||e.tagName==="LINK"&&e.getAttribute("rel")==="stylesheet"},Xt=function(e){var s,i;(s=t(this,U))==null||s.removeEventListener("scroll",t(this,ct)),o(this,ht,0),o(this,ot,0),o(this,U,t(this,q).scrollSelector&&e.querySelector(t(this,q).scrollSelector)||window),o(this,vt,t(this,U)===window),(i=t(this,U))==null||i.addEventListener("scroll",t(this,ct)),t(this,ct).call(this)},Kt=function(e,s){const i=typeof e=="string"?document.getElementById(e):e;(typeof i=="number"||i)&&se.scrollToElement(i,{scrollElement:t(this,U),behavior:(s==null?void 0:s.behavior)||"instant",center:s==null?void 0:s.centerScroll,offset:s==null?void 0:s.offsetScroll})},Tt=new WeakMap,ct=new WeakMap,mt.instance=null;let Vt=mt;exports.Morph=Vt;
@@ -649,10 +649,10 @@ const dt = class dt {
649
649
  });
650
650
  }));
651
651
  }), O.forEach((d) => {
652
- d instanceof HTMLElement && (this.findNewLinks(d), d.classList.add("new"), kt.forEach((S) => {
652
+ d instanceof HTMLElement && (kt.forEach((S) => {
653
653
  const w = d.querySelector(S.selector);
654
654
  w && w.replaceWith(S.element);
655
- }));
655
+ }), this.findNewLinks(d), d.classList.add("new"));
656
656
  }), c ? L ? O.forEach((d, S) => {
657
657
  N[S] instanceof HTMLElement && N[S].append(...d.childNodes);
658
658
  }) : O.forEach((d, S) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aptechka",
3
- "version": "0.77.0",
3
+ "version": "0.77.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/denisavitski/aptechka.git"