aptechka 0.72.0 → 0.72.2

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.
@@ -36,6 +36,7 @@ export interface MorphNavigateOptions {
36
36
  keepSearchParameters?: boolean;
37
37
  submorph?: Array<string>;
38
38
  clearState?: boolean;
39
+ keepScrollPosition?: boolean;
39
40
  }
40
41
  export interface MorphScrollDetail {
41
42
  left: number;
@@ -95,7 +96,7 @@ export declare class Morph {
95
96
  prefetch(path: string, revalidate?: boolean): Promise<void>;
96
97
  excludeHeadChild(child: Node): boolean;
97
98
  setHeaders(path: string): void;
98
- navigate(path: string, { historyAction, centerScroll, offsetScroll, revalidate, keepSearchParameters, submorph, clearState, }?: MorphNavigateOptions): Promise<void>;
99
+ navigate(path: string, { historyAction, centerScroll, offsetScroll, revalidate, keepSearchParameters, submorph, clearState, keepScrollPosition, }?: MorphNavigateOptions): Promise<void>;
99
100
  addLink(element: HTMLAnchorElement): void;
100
101
  addLinks(elements: Array<HTMLAnchorElement>): void;
101
102
  removeLink(element: HTMLAnchorElement): void;
@@ -1 +1 @@
1
- "use strict";var Qt=Object.defineProperty,Zt=Object.defineProperties;var _t=Object.getOwnPropertyDescriptors;var zt=Object.getOwnPropertySymbols;var te=Object.prototype.hasOwnProperty,ee=Object.prototype.propertyIsEnumerable;var It=(r,t)=>(t=Symbol[r])?t:Symbol.for("Symbol."+r),Ot=r=>{throw TypeError(r)};var Vt=(r,t,s)=>t in r?Qt(r,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):r[t]=s,dt=(r,t)=>{for(var s in t||(t={}))te.call(t,s)&&Vt(r,s,t[s]);if(zt)for(var s of zt(t))ee.call(t,s)&&Vt(r,s,t[s]);return r},St=(r,t)=>Zt(r,_t(t));var wt=(r,t,s)=>t.has(r)||Ot("Cannot "+s);var e=(r,t,s)=>(wt(r,t,"read from private field"),s?s.call(r):t.get(r)),o=(r,t,s)=>t.has(r)?Ot("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(r):t.set(r,s),n=(r,t,s,i)=>(wt(r,t,"write to private field"),i?i.call(r,s):t.set(r,s),s),E=(r,t,s)=>(wt(r,t,"access private method"),s);var B=(r,t,s)=>new Promise((i,h)=>{var v=S=>{try{f(s.next(S))}catch(O){h(O)}},b=S=>{try{f(s.throw(S))}catch(O){h(O)}},f=S=>S.done?i(S.value):Promise.resolve(S.value).then(v,b);f((s=s.apply(r,t)).next())});var Ft=(r,t,s)=>(t=r[It("asyncIterator")])?t.call(r):(r=r[It("iterator")](),t={},s=(i,h)=>(h=r[i])&&(t[i]=v=>new Promise((b,f,S)=>(v=h.call(r,v),S=v.done,Promise.resolve(v.value).then(O=>b({value:O,done:S}),f)))),s("next"),s("return"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Xt=require("../index-DekP7OZe.cjs"),C=require("../events-KVanG9sR.cjs"),se=require("../polyfills-Df4r-ETT.cjs"),Bt=require("../scroll-CIdNtj3G.cjs");require("construct-style-sheets-polyfill");const et=require("../url-YEESIcRn.cjs"),ie=require("../css-value-parser/index.cjs");class Yt extends HTMLElement{connectedCallback(){const t={"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(t))this.setAttribute(s,i)}}Xt.isBrowser&&!customElements.get("morph-announcer")&&customElements.define("morph-announcer",Yt);var H,l,q,it,G;class Lt{constructor(t,s){o(this,H);o(this,l);o(this,q);o(this,it,t=>{var i;if(t.preventDefault(),document.documentElement.classList.contains("click-disabled"))return;if(e(this,l).hasAttribute("data-back")&&e(this,H).previousURL)history.back();else{n(this,q,e(this,l).getAttribute("href")||"/");const h=e(this,l).getAttribute("data-history-action")||"push",v=e(this,l).hasAttribute("data-center-scroll"),b=getComputedStyle(e(this,l)).getPropertyValue("--offset-scroll").trim(),f=b?ie.cssValueParser.parse(b):void 0,S=e(this,l).hasAttribute("data-revalidate"),O=e(this,l).hasAttribute("data-keep-search-parameters"),lt=(i=e(this,l).getAttribute("data-submorph"))==null?void 0:i.split(",").map(ht=>ht.trim()),c=e(this,l).hasAttribute("data-clear-state");e(this,H).navigate(e(this,q),{historyAction:h,centerScroll:v,offsetScroll:f,revalidate:S,keepSearchParameters:O,submorph:lt,clearState:c})}});o(this,G,()=>{const t=e(this,l).hasAttribute("data-revalidate");e(this,H).prefetch(e(this,q),t),e(this,l).removeEventListener("pointerenter",e(this,G))});n(this,H,s),n(this,l,t),n(this,q,e(this,l).getAttribute("href")||"/"),e(this,l).addEventListener("click",e(this,it)),this.checkCurrent(location.pathname),e(this,l).hasAttribute("data-prefetch")&&e(this,l).addEventListener("pointerenter",e(this,G))}get element(){return e(this,l)}checkCurrent(t){var h;const s=e(this,H).normalizePath(t),i=e(this,H).normalizePath(e(this,q));e(this,l).hasAttribute("data-include")&&s.pathname.includes(i.pathname)?e(this,l).classList.add("current"):i.pathname===s.pathname?e(this,l).classList.add("current"):(h=e(this,l).getAttribute("data-associated-paths"))!=null&&h.split(",").find(v=>s.pathname.includes(v))?e(this,l).classList.add("current"):e(this,l).classList.remove("current")}destroy(){e(this,l).removeEventListener("click",e(this,it)),e(this,l).removeEventListener("pointerenter",e(this,G)),e(this,l).classList.remove("current")}}H=new WeakMap,l=new WeakMap,q=new WeakMap,it=new WeakMap,G=new WeakMap;const ne=new DOMParser;var M,W,L,P,X,D,J,Y,U,Q,nt;class Wt{constructor(t,s){o(this,M);o(this,W);o(this,L,{x:0,y:0});o(this,P,null);o(this,X,null);o(this,D,null);o(this,J,null);o(this,Y,null);o(this,U,null);o(this,Q);o(this,nt);n(this,M,t),n(this,W,s),n(this,Q,s)}get pathname(){return e(this,W)}get scrollState(){return e(this,L)}get document(){return e(this,D)}setHeaders(t){n(this,nt,t)}setInitialDocument(t){n(this,P,t.cloneNode(!0))}abort(){var t;return(t=e(this,Y))==null?void 0:t.abort(`[${e(this,W)}] page loading cancelled`)}fetch(t,s,i){return B(this,null,function*(){return e(this,U)||e(this,P)&&e(this,P).documentElement.hasAttribute("data-cache")&&(!i||e(this,Q)!==t)||e(this,P)&&e(this,M).isPopstateNavigation?e(this,U):(n(this,Q,t),n(this,U,new Promise(h=>B(this,null,function*(){try{n(this,Y,new AbortController);const b=yield(yield fetch(t,{signal:e(this,Y).signal,headers:dt({"X-MORPH":"true","X-MORPH-CURRENT-PATH":s,"X-MORPH-NEW-PATH":t},e(this,nt))})).text(),f=ne.parseFromString(b,"text/html");this.setInitialDocument(f)}catch(v){console.warn(v)}finally{n(this,Y,null),n(this,U,null),h()}}))),e(this,U))})}cloneDocument(){n(this,D,(e(this,X)||e(this,P)).cloneNode(!0))}get title(){let t="";if(e(this,D).title)t=e(this,D).title;else{const s=e(this,D).querySelector("h1");t=(s==null?void 0:s.innerText)||(s==null?void 0:s.textContent)||e(this,W)}return t}clearScrollState(){e(this,L).x=0,e(this,L).y=0}clearDocumentState(){n(this,X,null)}saveScrollState(){e(this,P).documentElement.hasAttribute("data-no-scroll-restoration")?(e(this,L).x=0,e(this,L).y=0):(e(this,L).x=e(this,M).scrollValue.left,e(this,L).y=e(this,M).scrollValue.top)}restoreScrollPosition(){e(this,M).scrollElement.scroll({top:e(this,L).y,left:e(this,L).x,behavior:"instant"})}saveDocumentState(){e(this,P).documentElement.hasAttribute("data-no-page-restoration")?n(this,X,null):n(this,X,document.cloneNode(!0))}renewScrollPosition(){e(this,M).scrollElement.scroll({top:0,left:0,behavior:"instant"})}saveState(t){n(this,J,t)}clearState(){const t=e(this,J);return n(this,J,null),t}}M=new WeakMap,W=new WeakMap,L=new WeakMap,P=new WeakMap,X=new WeakMap,D=new WeakMap,J=new WeakMap,Y=new WeakMap,U=new WeakMap,Q=new WeakMap,nt=new WeakMap;var A,rt,g,z,m,j,I,V,y,at,R,K,Z,_,u,bt,ot,mt,Pt,jt,At,kt,Ct,Ht,ft,tt;const st=class st{constructor(t){o(this,u);o(this,A,null);o(this,rt,null);o(this,g,[]);o(this,z);o(this,m,null);o(this,j);o(this,I,[]);o(this,V,!1);o(this,y,null);o(this,at,!1);o(this,R,new Map);o(this,K,null);o(this,Z,0);o(this,_,0);o(this,ot,t=>{var s;return((s=t.getAttribute("href"))==null?void 0:s.startsWith("/"))&&!t.hasAttribute("download")&&!t.hasAttribute("data-morph-skip")&&!t.closest("[data-morph-skip]")&&t.getAttribute("target")!=="_blank"});o(this,ft,t=>B(this,null,function*(){t.preventDefault(),n(this,V,!0),yield this.navigate(location.href.replace(location.origin,""),{historyAction:"none",submorph:t.state.submorph}),n(this,V,!1)}));o(this,tt,()=>{const{left:t,top:s}=this.scrollValue,i=s-e(this,_),h=t-e(this,Z);n(this,_,s),n(this,Z,t),document.documentElement.classList.toggle("scroll-y",s>0),document.documentElement.classList.toggle("scroll-x",t>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",h>0),document.documentElement.classList.toggle("scroll-x-backward",h<0),C.dispatchEvent(document,"morphScroll",{detail:{left:t,top:s}})});if(Xt.isBrowser&&!st.instance){st.instance=this,n(this,A,{base:et.normalizeBase(t==null?void 0:t.base),waitForHeadToLoad:(t==null?void 0:t.waitForHeadToLoad)!==!1,trailingSlash:(t==null?void 0:t.trailingSlash)||!1,scrollSelector:t==null?void 0:t.scrollSelector,morphInsideScrollContainer:(t==null?void 0:t.morphInsideScrollContainer)||!1}),n(this,rt,E(this,u,Pt).call(this,document.body));const s=this.normalizePath(location.pathname+location.hash+location.search);n(this,m,s);const i=new Wt(this,e(this,m).pathname);i.setInitialDocument(document),e(this,R).set(e(this,m).pathname,i),document.documentElement.setAttribute("data-current-pathname",e(this,m).pathname),document.documentElement.setAttribute("data-current-leaf",s.leaf),this.findLinks(),history.scrollRestoration="manual",addEventListener("popstate",e(this,ft)),et.changeHistory({action:"replace",pathname:s.pathname,searchParameters:s.parameters,hash:s.hash}),n(this,K,new Yt),E(this,u,Ct).call(this,document)}}get currentURL(){return e(this,m)}get previousURL(){return e(this,j)}get links(){return e(this,g)}get scrollElement(){return e(this,y)}get isPopstateNavigation(){return e(this,V)}get scrollValue(){let t=0,s=0;return e(this,at)?(t=window.scrollY,s=window.scrollX):(t=e(this,y).scrollTop,s=e(this,y).scrollLeft),{top:t,left:s}}saveState(t){const s=e(this,R).get(e(this,m).path);s&&s.saveState(t)}getState(){const t=e(this,R).get(e(this,m).path);return t==null?void 0:t.clearState()}normalizePath(t){return et.splitPath(t,{base:e(this,A).base,trailingSlash:e(this,A).trailingSlash})}prefetch(t,s){return B(this,null,function*(){var h;if(e(this,I).length)return;t=((h=this.pathnameModifier)==null?void 0:h.call(this,t))||t;const i=E(this,u,mt).call(this,t);i==null||i.fetch(t,e(this,m).path,s)})}excludeHeadChild(t){return!1}setHeaders(t){}navigate(O){return B(this,arguments,function*(t,{historyAction:s="push",centerScroll:i,offsetScroll:h,revalidate:v,keepSearchParameters:b,submorph:f,clearState:S}={}){var ht,Mt,Rt,Tt;if(e(this,I).length)return;const lt=((ht=this.pathnameModifier)==null?void 0:ht.call(this,t))||t,c=this.normalizePath(lt);if(((Mt=e(this,z))==null?void 0:Mt.pathname)===c.pathname||e(this,m).pathname===c.pathname){E(this,u,Ht).call(this,c.hash||0,{centerScroll:i,offsetScroll:h,behavior:"smooth"}),C.dispatchEvent(document,"morphSamePath",{custom:!0}),((Rt=e(this,m))==null?void 0:Rt.parameters)!==c.parameters&&(n(this,j,e(this,m)),n(this,m,c),et.changeHistory({action:((Tt=e(this,m))==null?void 0:Tt.hash)!==c.hash?"replace":s,pathname:c.pathname,searchParameters:c.parameters,hash:c.hash,state:{submorph:f}}),C.dispatchEvent(document,"morphURLParametersChange",{detail:{newURL:e(this,m),previousURL:e(this,j)}}));return}n(this,z,c),e(this,g).forEach($=>{$.checkCurrent(c.pathname)});try{let $=!0;if(this.preprocessor)try{yield new Promise((a,k)=>{var T;(T=this.preprocessor)==null||T.call(this,{url:c,resolve:a,reject:k,submorph:f})})}catch(a){a?console.error(a):console.log("Route change canceled"),$=!1}if(!$||e(this,z).pathname!==c.pathname){e(this,g).forEach(a=>{a.checkCurrent(e(this,m).pathname)});return}const xt={url:c,submorph:f};C.dispatchEvent(document,"morphNavigation",{detail:xt});const pt=E(this,u,mt).call(this,e(this,m).pathname),p=E(this,u,mt).call(this,c.pathname);if(e(this,R).forEach(a=>{a.pathname!==c.pathname&&a.abort()}),yield p==null?void 0:p.fetch(lt,e(this,m).path,v),e(this,z).pathname!==c.pathname){e(this,g).forEach(a=>{a.checkCurrent(e(this,m).path)});return}pt.clearState(),pt.saveScrollState(),pt.saveDocumentState(),e(this,V)||(p.clearScrollState(),p.clearDocumentState()),S&&p.clearState(),p.cloneDocument(),e(this,K).textContent=p.title,document.body.appendChild(e(this,K));const Et=St(dt({},xt),{document:p.document});C.dispatchEvent(document,"morphStart",{detail:Et});const Nt=Array.from(document.head.children),qt=Array.from(p.document.head.children),Dt=E(this,u,jt).call(this,Nt,qt),Kt=E(this,u,At).call(this,Nt,Dt),ct=E(this,u,At).call(this,qt,Dt).filter(a=>!this.excludeHeadChild(a));ct.forEach((a,k)=>{a.tagName==="SCRIPT"&&(ct[k]=E(this,u,bt).call(this,a))}),ct.forEach(a=>{document.head.appendChild(a)});const gt=ct.filter(a=>{if(a.hasAttribute("data-no-waiting"))return!1;if(E(this,u,kt).call(this,a))return!0});e(this,A).waitForHeadToLoad&&gt.length&&(yield new Promise(a=>B(this,null,function*(){let k=0;try{for(var T=Ft(gt),Gt,F,x;Gt=!(F=yield T.next()).done;Gt=!1){const ut=F.value;ut.onload=()=>{k++,k===gt.length&&a()}}}catch(F){x=[F]}finally{try{Gt&&(F=T.return)&&(yield F.call(T))}finally{if(x)throw x[0]}}}))),yield Bt.wait(10);const Ut=[];Kt.forEach(a=>{a.hasAttribute("data-permanent")||(E(this,u,kt).call(this,a)?Ut.push(a):a.remove())});const $t=E(this,u,Pt).call(this,p.document.body);!e(this,A).morphInsideScrollContainer&&!f&&E(this,u,Ct).call(this,p.document),document.documentElement.setAttribute("data-current-pathname",c.pathname),document.documentElement.setAttribute("data-current-leaf",c.leaf),et.changeHistory({action:s,pathname:c.pathname,searchParameters:c.parameters||(b?location.search:""),hash:c.hash,state:{submorph:f}}),e(this,K).remove(),n(this,j,e(this,m)),n(this,m,c);const vt=[];e(this,rt).forEach((a,k)=>{const T=$t[k],Gt=getComputedStyle(a).getPropertyValue("--morph-duration");let F=[],x=[];f?(f.forEach(d=>{const w=a.querySelector(d),N=T.querySelector(d);w&&N&&(x.push(w),F.push(N))}),x.forEach(d=>{d.parentElement&&vt.push(d.parentElement)})):(F.push(...T.childNodes),x.push(...a.childNodes),vt.push(a)),x.forEach(d=>{d instanceof HTMLElement&&(this.destroyOldLinks(d),d.classList.add("old"))}),F.forEach(d=>{d instanceof HTMLElement&&(this.findNewLinks(d),d.classList.add("new"))}),f?F.forEach((d,w)=>{var N;(N=x[w].parentElement)==null||N.insertBefore(d,x[w])}):a.prepend(...F),se.requestIdleCallback(()=>{x.forEach(d=>{d instanceof HTMLElement&&d.classList.add("old-idle")}),F.forEach(d=>{var w;d instanceof HTMLElement&&((w=d.parentElement)==null||w.style.setProperty("--new-content-height",d.offsetHeight+"px"),d.classList.add("new-idle"))})});const ut=St(dt({},Et),{morphElement:a});C.dispatchEvent(document,"morphNewChildrenAdded",{detail:ut});const Jt=new Promise(d=>{setTimeout(()=>{x.forEach(w=>w.remove()),F.forEach(w=>{var N;w instanceof HTMLElement&&((N=w.parentElement)==null||N.style.removeProperty("--new-content-height"),w.classList.remove("new-idle","new"))}),C.dispatchEvent(document,"morphOldChildrenRemoved",{detail:ut}),d()},(parseFloat(Gt)||0)*1e3+10)});e(this,I).push(Jt)}),this.isPopstateNavigation?document.documentElement.style.setProperty("--new-document-scroll-position",(this.scrollValue.top-p.scrollState.y)*1+"px"):document.documentElement.style.setProperty("--new-document-scroll-position",this.scrollValue.top+"px"),C.dispatchEvent(document,"morphBeforeNavigationScroll",{detail:p.scrollState}),c.hash?(p.clearScrollState(),E(this,u,Ht).call(this,c.hash,{centerScroll:i,offsetScroll:h})):e(this,V)?p.restoreScrollPosition():p.renewScrollPosition(),yield Promise.all(e(this,I)),Ut.forEach(a=>a.remove()),n(this,I,[]),vt.forEach(a=>{a.querySelectorAll("script").forEach(T=>{T.replaceWith(E(this,u,bt).call(this,T))})}),e(this,g).forEach(a=>{a.checkCurrent(e(this,m).path)}),C.dispatchEvent(document,"morphComplete",{detail:Et}),document.documentElement.style.removeProperty("--new-document-scroll-position"),window.dispatchEvent(new Event("resize"))}catch($){console.error($)}n(this,z,void 0)})}addLink(t){e(this,g).push(new Lt(t,this))}addLinks(t){t.forEach(s=>{this.addLink(s)})}removeLink(t){n(this,g,e(this,g).filter(s=>s.element===t?(s.destroy(),!1):!0))}destroyOldLinks(t){n(this,g,e(this,g).filter(s=>t.contains(s.element)?(s.destroy(),!1):!0))}findNewLinks(t){const s=[...t.querySelectorAll("a")].filter(e(this,ot));e(this,g).push(...s.map(i=>new Lt(i,this)))}findLinks(){const t=[...document.documentElement.querySelectorAll("a")].filter(e(this,ot));e(this,g).forEach(s=>s.destroy()),n(this,g,t.map(s=>new Lt(s,this)))}};A=new WeakMap,rt=new WeakMap,g=new WeakMap,z=new WeakMap,m=new WeakMap,j=new WeakMap,I=new WeakMap,V=new WeakMap,y=new WeakMap,at=new WeakMap,R=new WeakMap,K=new WeakMap,Z=new WeakMap,_=new WeakMap,u=new WeakSet,bt=function(t){const s=document.createElement("script");for(let i=0;i<t.attributes.length;i++){const h=t.attributes[i];s.setAttribute(h.name,h.value)}return t.hasAttribute("src")||(s.innerHTML=t.innerHTML),s},ot=new WeakMap,mt=function(t){const s=this.normalizePath(t);let i=e(this,R).get(s.pathname);return i||(i=new Wt(this,s.pathname),e(this,R).set(s.pathname,i)),i},Pt=function(t){const s=[...t.querySelectorAll("[data-morph]")];return s.length?s:[t]},jt=function(t,s){return t.filter(i=>s.find(h=>h.outerHTML===i.outerHTML))},At=function(t,s){return t.filter(i=>!s.find(h=>h.outerHTML===i.outerHTML))},kt=function(t){return t.tagName==="SCRIPT"||t.tagName==="STYLE"||t.tagName==="LINK"&&t.getAttribute("rel")==="stylesheet"},Ct=function(t){var s,i;(s=e(this,y))==null||s.removeEventListener("scroll",e(this,tt)),n(this,_,0),n(this,Z,0),n(this,y,e(this,A).scrollSelector&&t.querySelector(e(this,A).scrollSelector)||window),n(this,at,e(this,y)===window),(i=e(this,y))==null||i.addEventListener("scroll",e(this,tt)),e(this,tt).call(this)},Ht=function(t,s){const i=typeof t=="string"?document.getElementById(t):t;(typeof i=="number"||i)&&Bt.scrollToElement(i,{scrollElement:e(this,y),behavior:(s==null?void 0:s.behavior)||"instant",center:s==null?void 0:s.centerScroll,offset:s==null?void 0:s.offsetScroll})},ft=new WeakMap,tt=new WeakMap,st.instance=null;let yt=st;exports.Morph=yt;
1
+ "use strict";var _t=Object.defineProperty,te=Object.defineProperties;var ee=Object.getOwnPropertyDescriptors;var It=Object.getOwnPropertySymbols;var se=Object.prototype.hasOwnProperty,ie=Object.prototype.propertyIsEnumerable;var Vt=(a,t)=>(t=Symbol[a])?t:Symbol.for("Symbol."+a),Ft=a=>{throw TypeError(a)};var Ot=(a,t,s)=>t in a?_t(a,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[t]=s,ft=(a,t)=>{for(var s in t||(t={}))se.call(t,s)&&Ot(a,s,t[s]);if(It)for(var s of It(t))ie.call(t,s)&&Ot(a,s,t[s]);return a},Lt=(a,t)=>te(a,ee(t));var wt=(a,t,s)=>t.has(a)||Ft("Cannot "+s);var e=(a,t,s)=>(wt(a,t,"read from private field"),s?s.call(a):t.get(a)),o=(a,t,s)=>t.has(a)?Ft("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(a):t.set(a,s),n=(a,t,s,i)=>(wt(a,t,"write to private field"),i?i.call(a,s):t.set(a,s),s),E=(a,t,s)=>(wt(a,t,"access private method"),s);var B=(a,t,s)=>new Promise((i,h)=>{var v=L=>{try{f(s.next(L))}catch(H){h(H)}},A=L=>{try{f(s.throw(L))}catch(H){h(H)}},f=L=>L.done?i(L.value):Promise.resolve(L.value).then(v,A);f((s=s.apply(a,t)).next())});var Bt=(a,t,s)=>(t=a[Vt("asyncIterator")])?t.call(a):(a=a[Vt("iterator")](),t={},s=(i,h)=>(h=a[i])&&(t[i]=v=>new Promise((A,f,L)=>(v=h.call(a,v),L=v.done,Promise.resolve(v.value).then(H=>A({value:H,done:L}),f)))),s("next"),s("return"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Yt=require("../index-DekP7OZe.cjs"),M=require("../events-KVanG9sR.cjs"),re=require("../polyfills-Df4r-ETT.cjs"),Wt=require("../scroll-CIdNtj3G.cjs");require("construct-style-sheets-polyfill");const st=require("../url-YEESIcRn.cjs"),ne=require("../css-value-parser/index.cjs");class jt extends HTMLElement{connectedCallback(){const t={"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(t))this.setAttribute(s,i)}}Yt.isBrowser&&!customElements.get("morph-announcer")&&customElements.define("morph-announcer",jt);var R,l,D,rt,G;class yt{constructor(t,s){o(this,R);o(this,l);o(this,D);o(this,rt,t=>{var i;if(t.preventDefault(),document.documentElement.classList.contains("click-disabled"))return;if(e(this,l).hasAttribute("data-back")&&e(this,R).previousURL)history.back();else{n(this,D,e(this,l).getAttribute("href")||"/");const h=e(this,l).getAttribute("data-history-action")||"push",v=e(this,l).hasAttribute("data-center-scroll"),A=getComputedStyle(e(this,l)).getPropertyValue("--offset-scroll").trim(),f=A?ne.cssValueParser.parse(A):void 0,L=e(this,l).hasAttribute("data-revalidate"),H=e(this,l).hasAttribute("data-keep-search-parameters"),$t=e(this,l).hasAttribute("data-keep-scroll-position"),ht=(i=e(this,l).getAttribute("data-submorph"))==null?void 0:i.split(",").map(ct=>ct.trim()),c=e(this,l).hasAttribute("data-clear-state");e(this,R).navigate(e(this,D),{historyAction:h,centerScroll:v,offsetScroll:f,revalidate:L,keepSearchParameters:H,submorph:ht,clearState:c,keepScrollPosition:$t})}});o(this,G,()=>{const t=e(this,l).hasAttribute("data-revalidate");e(this,R).prefetch(e(this,D),t),e(this,l).removeEventListener("pointerenter",e(this,G))});n(this,R,s),n(this,l,t),n(this,D,e(this,l).getAttribute("href")||"/"),e(this,l).addEventListener("click",e(this,rt)),this.checkCurrent(location.pathname),e(this,l).hasAttribute("data-prefetch")&&e(this,l).addEventListener("pointerenter",e(this,G))}get element(){return e(this,l)}checkCurrent(t){var h;const s=e(this,R).normalizePath(t),i=e(this,R).normalizePath(e(this,D));e(this,l).hasAttribute("data-include")&&s.pathname.includes(i.pathname)?e(this,l).classList.add("current"):i.pathname===s.pathname?e(this,l).classList.add("current"):(h=e(this,l).getAttribute("data-associated-paths"))!=null&&h.split(",").find(v=>s.pathname.includes(v))?e(this,l).classList.add("current"):e(this,l).classList.remove("current")}destroy(){e(this,l).removeEventListener("click",e(this,rt)),e(this,l).removeEventListener("pointerenter",e(this,G)),e(this,l).classList.remove("current")}}R=new WeakMap,l=new WeakMap,D=new WeakMap,rt=new WeakMap,G=new WeakMap;const ae=new DOMParser;var T,W,y,k,X,U,J,Y,z,Q,nt;class Xt{constructor(t,s){o(this,T);o(this,W);o(this,y,{x:0,y:0});o(this,k,null);o(this,X,null);o(this,U,null);o(this,J,null);o(this,Y,null);o(this,z,null);o(this,Q);o(this,nt);n(this,T,t),n(this,W,s),n(this,Q,s)}get pathname(){return e(this,W)}get scrollState(){return e(this,y)}get document(){return e(this,U)}setHeaders(t){n(this,nt,t)}setInitialDocument(t){n(this,k,t.cloneNode(!0))}abort(){var t;return(t=e(this,Y))==null?void 0:t.abort(`[${e(this,W)}] page loading cancelled`)}fetch(t,s,i){return B(this,null,function*(){return e(this,z)||e(this,k)&&e(this,k).documentElement.hasAttribute("data-cache")&&(!i||e(this,Q)!==t)||e(this,k)&&e(this,T).isPopstateNavigation?e(this,z):(n(this,Q,t),n(this,z,new Promise(h=>B(this,null,function*(){try{n(this,Y,new AbortController);const A=yield(yield fetch(t,{signal:e(this,Y).signal,headers:ft({"X-MORPH":"true","X-MORPH-CURRENT-PATH":s,"X-MORPH-NEW-PATH":t},e(this,nt))})).text(),f=ae.parseFromString(A,"text/html");this.setInitialDocument(f)}catch(v){console.warn(v)}finally{n(this,Y,null),n(this,z,null),h()}}))),e(this,z))})}cloneDocument(){n(this,U,(e(this,X)||e(this,k)).cloneNode(!0))}get title(){let t="";if(e(this,U).title)t=e(this,U).title;else{const s=e(this,U).querySelector("h1");t=(s==null?void 0:s.innerText)||(s==null?void 0:s.textContent)||e(this,W)}return t}clearScrollState(){e(this,y).x=0,e(this,y).y=0}clearDocumentState(){n(this,X,null)}saveScrollState(){e(this,k).documentElement.hasAttribute("data-no-scroll-restoration")?(e(this,y).x=0,e(this,y).y=0):(e(this,y).x=e(this,T).scrollValue.left,e(this,y).y=e(this,T).scrollValue.top)}restoreScrollPosition(){e(this,T).scrollElement.scroll({top:e(this,y).y,left:e(this,y).x,behavior:"instant"})}saveDocumentState(){e(this,k).documentElement.hasAttribute("data-no-page-restoration")?n(this,X,null):n(this,X,document.cloneNode(!0))}renewScrollPosition(){e(this,T).scrollElement.scroll({top:0,left:0,behavior:"instant"})}saveState(t){n(this,J,t)}clearState(){const t=e(this,J);return n(this,J,null),t}}T=new WeakMap,W=new WeakMap,y=new WeakMap,k=new WeakMap,X=new WeakMap,U=new WeakMap,J=new WeakMap,Y=new WeakMap,z=new WeakMap,Q=new WeakMap,nt=new WeakMap;var C,Z,g,I,m,j,V,O,P,at,x,K,_,tt,ot,u,Pt,lt,pt,At,Kt,kt,Ct,Ht,Mt,Et,et;const it=class it{constructor(t){o(this,u);o(this,C,null);o(this,Z,null);o(this,g,[]);o(this,I);o(this,m,null);o(this,j);o(this,V,[]);o(this,O,!1);o(this,P,null);o(this,at,!1);o(this,x,new Map);o(this,K,null);o(this,_,0);o(this,tt,0);o(this,ot,null);o(this,lt,t=>{var s;return((s=t.getAttribute("href"))==null?void 0:s.startsWith("/"))&&!t.hasAttribute("download")&&!t.hasAttribute("data-morph-skip")&&!t.closest("[data-morph-skip]")&&t.getAttribute("target")!=="_blank"});o(this,Et,t=>B(this,null,function*(){t.preventDefault(),n(this,O,!0),yield this.navigate(location.href.replace(location.origin,""),{historyAction:"none",submorph:e(this,ot)||void 0}),n(this,O,!1)}));o(this,et,()=>{const{left:t,top:s}=this.scrollValue,i=s-e(this,tt),h=t-e(this,_);n(this,tt,s),n(this,_,t),document.documentElement.classList.toggle("scroll-y",s>0),document.documentElement.classList.toggle("scroll-x",t>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",h>0),document.documentElement.classList.toggle("scroll-x-backward",h<0),M.dispatchEvent(document,"morphScroll",{detail:{left:t,top:s}})});if(Yt.isBrowser&&!it.instance){it.instance=this,n(this,C,{base:st.normalizeBase(t==null?void 0:t.base),waitForHeadToLoad:(t==null?void 0:t.waitForHeadToLoad)!==!1,trailingSlash:(t==null?void 0:t.trailingSlash)||!1,scrollSelector:t==null?void 0:t.scrollSelector,morphInsideScrollContainer:(t==null?void 0:t.morphInsideScrollContainer)||!1}),n(this,Z,E(this,u,At).call(this,document.body));const s=this.normalizePath(location.pathname+location.hash+location.search);n(this,m,s);const i=new Xt(this,e(this,m).pathname);i.setInitialDocument(document),e(this,x).set(e(this,m).pathname,i),document.documentElement.setAttribute("data-current-pathname",e(this,m).pathname),document.documentElement.setAttribute("data-current-leaf",s.leaf),this.findLinks(),history.scrollRestoration="manual",addEventListener("popstate",e(this,Et)),st.changeHistory({action:"replace",pathname:s.pathname,searchParameters:s.parameters,hash:s.hash}),n(this,K,new jt),E(this,u,Ht).call(this,document)}}get currentURL(){return e(this,m)}get previousURL(){return e(this,j)}get links(){return e(this,g)}get scrollElement(){return e(this,P)}get isPopstateNavigation(){return e(this,O)}get scrollValue(){let t=0,s=0;return e(this,at)?(t=window.scrollY,s=window.scrollX):(t=e(this,P).scrollTop,s=e(this,P).scrollLeft),{top:t,left:s}}saveState(t){const s=e(this,x).get(e(this,m).path);s&&s.saveState(t)}getState(){const t=e(this,x).get(e(this,m).path);return t==null?void 0:t.clearState()}normalizePath(t){return st.splitPath(t,{base:e(this,C).base,trailingSlash:e(this,C).trailingSlash})}prefetch(t,s){return B(this,null,function*(){var h;if(e(this,V).length)return;t=((h=this.pathnameModifier)==null?void 0:h.call(this,t))||t;const i=E(this,u,pt).call(this,t);i==null||i.fetch(t,e(this,m).path,s)})}excludeHeadChild(t){return!1}setHeaders(t){}navigate($t){return B(this,arguments,function*(t,{historyAction:s="push",centerScroll:i,offsetScroll:h,revalidate:v,keepSearchParameters:A,submorph:f,clearState:L,keepScrollPosition:H}={}){var ct,Rt,Tt,xt;if(e(this,V).length)return;n(this,ot,f||null);const ht=((ct=this.pathnameModifier)==null?void 0:ct.call(this,t))||t,c=this.normalizePath(ht);if(((Rt=e(this,I))==null?void 0:Rt.pathname)===c.pathname||e(this,m).pathname===c.pathname){E(this,u,Mt).call(this,c.hash||0,{centerScroll:i,offsetScroll:h,behavior:"smooth"}),M.dispatchEvent(document,"morphSamePath",{custom:!0}),((Tt=e(this,m))==null?void 0:Tt.parameters)!==c.parameters&&(n(this,j,e(this,m)),n(this,m,c),st.changeHistory({action:((xt=e(this,m))==null?void 0:xt.hash)!==c.hash?"replace":s,pathname:c.pathname,searchParameters:c.parameters,hash:c.hash}),M.dispatchEvent(document,"morphURLParametersChange",{detail:{newURL:e(this,m),previousURL:e(this,j)}}));return}n(this,I,c),e(this,g).forEach($=>{$.checkCurrent(c.pathname)});try{let $=!0;if(this.preprocessor)try{yield new Promise((r,S)=>{var b;(b=this.preprocessor)==null||b.call(this,{url:c,resolve:r,reject:S,submorph:f})})}catch(r){r?console.error(r):console.log("Route change canceled"),$=!1}if(!$||e(this,I).pathname!==c.pathname){e(this,g).forEach(r=>{r.checkCurrent(e(this,m).pathname)});return}const Nt={url:c,submorph:f};f?f.forEach(r=>{document.querySelectorAll(r).forEach(S=>{S.classList.add("out"),S.setAttribute("data-morph-out","")})}):e(this,Z).forEach(r=>{var S,b;(S=r.firstElementChild)==null||S.classList.add("out"),(b=r.firstElementChild)==null||b.setAttribute("data-morph-out","")}),M.dispatchEvent(document,"morphNavigation",{detail:Nt});const gt=E(this,u,pt).call(this,e(this,m).pathname),p=E(this,u,pt).call(this,c.pathname);if(e(this,x).forEach(r=>{r.pathname!==c.pathname&&r.abort()}),yield p==null?void 0:p.fetch(ht,e(this,m).path,v),e(this,I).pathname!==c.pathname){e(this,g).forEach(r=>{r.checkCurrent(e(this,m).path)});return}gt.clearState(),gt.saveScrollState(),gt.saveDocumentState(),e(this,O)||(p.clearScrollState(),p.clearDocumentState()),L&&p.clearState(),p.cloneDocument(),e(this,K).textContent=p.title,document.body.appendChild(e(this,K));const ut=Lt(ft({},Nt),{document:p.document});ut.document.querySelectorAll("[data-morph-out]").forEach(r=>{r.classList.remove("out")}),M.dispatchEvent(document,"morphStart",{detail:ut});const qt=Array.from(document.head.children),Dt=Array.from(p.document.head.children),Ut=E(this,u,Kt).call(this,qt,Dt),Gt=E(this,u,kt).call(this,qt,Ut),dt=E(this,u,kt).call(this,Dt,Ut).filter(r=>!this.excludeHeadChild(r));dt.forEach((r,S)=>{r.tagName==="SCRIPT"&&(dt[S]=E(this,u,Pt).call(this,r))}),dt.forEach(r=>{document.head.appendChild(r)});const vt=dt.filter(r=>{if(r.hasAttribute("data-no-waiting"))return!1;if(E(this,u,Ct).call(this,r))return!0});e(this,C).waitForHeadToLoad&&vt.length&&(yield new Promise(r=>B(this,null,function*(){let S=0;try{for(var b=Bt(vt),Qt,F,N;Qt=!(F=yield b.next()).done;Qt=!1){const mt=F.value;mt.onload=()=>{S++,S===vt.length&&r()}}}catch(F){N=[F]}finally{try{Qt&&(F=b.return)&&(yield F.call(b))}finally{if(N)throw N[0]}}}))),yield Wt.wait(10);const zt=[];Gt.forEach(r=>{r.hasAttribute("data-permanent")||(E(this,u,Ct).call(this,r)?zt.push(r):r.remove())});const Jt=E(this,u,At).call(this,p.document.body);!e(this,C).morphInsideScrollContainer&&!f&&E(this,u,Ht).call(this,p.document),document.documentElement.setAttribute("data-current-pathname",c.pathname),document.documentElement.setAttribute("data-current-leaf",c.leaf),st.changeHistory({action:s,pathname:c.pathname,searchParameters:c.parameters||(A?location.search:""),hash:c.hash}),e(this,K).remove(),n(this,j,e(this,m)),n(this,m,c);const St=[];e(this,Z).forEach((r,S)=>{const b=Jt[S],Qt=getComputedStyle(r).getPropertyValue("--morph-duration");let F=[],N=[];f?(f.forEach(d=>{const w=r.querySelector(d),q=b.querySelector(d);w&&q&&(N.push(w),F.push(q))}),N.forEach(d=>{d.parentElement&&St.push(d.parentElement)})):(F.push(...b.childNodes),N.push(...r.childNodes),St.push(r)),N.forEach(d=>{d instanceof HTMLElement&&(this.destroyOldLinks(d),d.classList.add("old"))}),F.forEach(d=>{d instanceof HTMLElement&&(this.findNewLinks(d),d.classList.add("new"))}),f?F.forEach((d,w)=>{var q;(q=N[w].parentElement)==null||q.insertBefore(d,N[w])}):r.prepend(...F),re.requestIdleCallback(()=>{N.forEach(d=>{d instanceof HTMLElement&&d.classList.add("old-idle")}),F.forEach(d=>{var w;d instanceof HTMLElement&&((w=d.parentElement)==null||w.style.setProperty("--new-content-height",d.offsetHeight+"px"),d.classList.add("new-idle"))})});const mt=Lt(ft({},ut),{morphElement:r});M.dispatchEvent(document,"morphNewChildrenAdded",{detail:mt});const Zt=new Promise(d=>{setTimeout(()=>{N.forEach(w=>w.remove()),F.forEach(w=>{var q;w instanceof HTMLElement&&((q=w.parentElement)==null||q.style.removeProperty("--new-content-height"),w.classList.remove("new-idle","new"))}),M.dispatchEvent(document,"morphOldChildrenRemoved",{detail:mt}),d()},(parseFloat(Qt)||0)*1e3+10)});e(this,V).push(Zt)}),this.isPopstateNavigation?document.documentElement.style.setProperty("--new-document-scroll-position",(this.scrollValue.top-p.scrollState.y)*1+"px"):document.documentElement.style.setProperty("--new-document-scroll-position",this.scrollValue.top+"px"),M.dispatchEvent(document,"morphBeforeNavigationScroll",{detail:p.scrollState}),c.hash?(p.clearScrollState(),E(this,u,Mt).call(this,c.hash,{centerScroll:i,offsetScroll:h})):e(this,O)?p.restoreScrollPosition():H||p.renewScrollPosition(),yield Promise.all(e(this,V)),zt.forEach(r=>r.remove()),n(this,V,[]),St.forEach(r=>{r.querySelectorAll("script").forEach(b=>{b.replaceWith(E(this,u,Pt).call(this,b))})}),e(this,g).forEach(r=>{r.checkCurrent(e(this,m).path)}),M.dispatchEvent(document,"morphComplete",{detail:ut}),document.documentElement.style.removeProperty("--new-document-scroll-position"),window.dispatchEvent(new Event("resize"))}catch($){console.error($)}n(this,I,void 0)})}addLink(t){e(this,g).push(new yt(t,this))}addLinks(t){t.forEach(s=>{this.addLink(s)})}removeLink(t){n(this,g,e(this,g).filter(s=>s.element===t?(s.destroy(),!1):!0))}destroyOldLinks(t){n(this,g,e(this,g).filter(s=>t.contains(s.element)?(s.destroy(),!1):!0))}findNewLinks(t){const s=[...t.querySelectorAll("a")].filter(e(this,lt));e(this,g).push(...s.map(i=>new yt(i,this)))}findLinks(){const t=[...document.documentElement.querySelectorAll("a")].filter(e(this,lt));e(this,g).forEach(s=>s.destroy()),n(this,g,t.map(s=>new yt(s,this)))}};C=new WeakMap,Z=new WeakMap,g=new WeakMap,I=new WeakMap,m=new WeakMap,j=new WeakMap,V=new WeakMap,O=new WeakMap,P=new WeakMap,at=new WeakMap,x=new WeakMap,K=new WeakMap,_=new WeakMap,tt=new WeakMap,ot=new WeakMap,u=new WeakSet,Pt=function(t){const s=document.createElement("script");for(let i=0;i<t.attributes.length;i++){const h=t.attributes[i];s.setAttribute(h.name,h.value)}return t.hasAttribute("src")||(s.innerHTML=t.innerHTML),s},lt=new WeakMap,pt=function(t){const s=this.normalizePath(t);let i=e(this,x).get(s.pathname);return i||(i=new Xt(this,s.pathname),e(this,x).set(s.pathname,i)),i},At=function(t){const s=[...t.querySelectorAll("[data-morph]")];return s.length?s:[t]},Kt=function(t,s){return t.filter(i=>s.find(h=>h.outerHTML===i.outerHTML))},kt=function(t,s){return t.filter(i=>!s.find(h=>h.outerHTML===i.outerHTML))},Ct=function(t){return t.tagName==="SCRIPT"||t.tagName==="STYLE"||t.tagName==="LINK"&&t.getAttribute("rel")==="stylesheet"},Ht=function(t){var s,i;(s=e(this,P))==null||s.removeEventListener("scroll",e(this,et)),n(this,tt,0),n(this,_,0),n(this,P,e(this,C).scrollSelector&&t.querySelector(e(this,C).scrollSelector)||window),n(this,at,e(this,P)===window),(i=e(this,P))==null||i.addEventListener("scroll",e(this,et)),e(this,et).call(this)},Mt=function(t,s){const i=typeof t=="string"?document.getElementById(t):t;(typeof i=="number"||i)&&Wt.scrollToElement(i,{scrollElement:e(this,P),behavior:(s==null?void 0:s.behavior)||"instant",center:s==null?void 0:s.centerScroll,offset:s==null?void 0:s.offsetScroll})},Et=new WeakMap,et=new WeakMap,it.instance=null;let bt=it;exports.Morph=bt;
@@ -1,45 +1,45 @@
1
- var Jt = Object.defineProperty, Qt = Object.defineProperties;
2
- var Zt = Object.getOwnPropertyDescriptors;
1
+ var Zt = Object.defineProperty, _t = Object.defineProperties;
2
+ var te = Object.getOwnPropertyDescriptors;
3
3
  var zt = Object.getOwnPropertySymbols;
4
- var _t = Object.prototype.hasOwnProperty, te = Object.prototype.propertyIsEnumerable;
5
- var It = (r, t) => (t = Symbol[r]) ? t : Symbol.for("Symbol." + r), qt = (r) => {
6
- throw TypeError(r);
4
+ var ee = Object.prototype.hasOwnProperty, se = Object.prototype.propertyIsEnumerable;
5
+ var It = (a, t) => (t = Symbol[a]) ? t : Symbol.for("Symbol." + a), Ot = (a) => {
6
+ throw TypeError(a);
7
7
  };
8
- var Vt = (r, t, s) => t in r ? Jt(r, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : r[t] = s, ut = (r, t) => {
8
+ var Vt = (a, t, s) => t in a ? Zt(a, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : a[t] = s, mt = (a, t) => {
9
9
  for (var s in t || (t = {}))
10
- _t.call(t, s) && Vt(r, s, t[s]);
10
+ ee.call(t, s) && Vt(a, s, t[s]);
11
11
  if (zt)
12
12
  for (var s of zt(t))
13
- te.call(t, s) && Vt(r, s, t[s]);
14
- return r;
15
- }, St = (r, t) => Qt(r, Zt(t));
16
- var wt = (r, t, s) => t.has(r) || qt("Cannot " + s);
17
- var e = (r, t, s) => (wt(r, t, "read from private field"), s ? s.call(r) : t.get(r)), o = (r, t, s) => t.has(r) ? qt("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(r) : t.set(r, s), n = (r, t, s, i) => (wt(r, t, "write to private field"), i ? i.call(r, s) : t.set(r, s), s), E = (r, t, s) => (wt(r, t, "access private method"), s);
18
- var W = (r, t, s) => new Promise((i, h) => {
13
+ se.call(t, s) && Vt(a, s, t[s]);
14
+ return a;
15
+ }, Lt = (a, t) => _t(a, te(t));
16
+ var wt = (a, t, s) => t.has(a) || Ot("Cannot " + s);
17
+ var e = (a, t, s) => (wt(a, t, "read from private field"), s ? s.call(a) : t.get(a)), o = (a, t, s) => t.has(a) ? Ot("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(a) : t.set(a, s), n = (a, t, s, i) => (wt(a, t, "write to private field"), i ? i.call(a, s) : t.set(a, s), s), E = (a, t, s) => (wt(a, t, "access private method"), s);
18
+ var W = (a, t, s) => new Promise((i, h) => {
19
19
  var S = (w) => {
20
20
  try {
21
21
  f(s.next(w));
22
- } catch (O) {
23
- h(O);
22
+ } catch (H) {
23
+ h(H);
24
24
  }
25
- }, b = (w) => {
25
+ }, P = (w) => {
26
26
  try {
27
27
  f(s.throw(w));
28
- } catch (O) {
29
- h(O);
28
+ } catch (H) {
29
+ h(H);
30
30
  }
31
- }, f = (w) => w.done ? i(w.value) : Promise.resolve(w.value).then(S, b);
32
- f((s = s.apply(r, t)).next());
31
+ }, f = (w) => w.done ? i(w.value) : Promise.resolve(w.value).then(S, P);
32
+ f((s = s.apply(a, t)).next());
33
33
  });
34
- var Ot = (r, t, s) => (t = r[It("asyncIterator")]) ? t.call(r) : (r = r[It("iterator")](), t = {}, s = (i, h) => (h = r[i]) && (t[i] = (S) => new Promise((b, f, w) => (S = h.call(r, S), w = S.done, Promise.resolve(S.value).then((O) => b({ value: O, done: w }), f)))), s("next"), s("return"), t);
35
- import { i as Xt } from "../index-Bv9zgfdb.js";
36
- import { d as C } from "../events-CsVF98U6.js";
37
- import { r as ee } from "../polyfills-DJrTJQky.js";
38
- import { w as se, s as ie } from "../scroll-DPkCFTxg.js";
34
+ var Ft = (a, t, s) => (t = a[It("asyncIterator")]) ? t.call(a) : (a = a[It("iterator")](), t = {}, s = (i, h) => (h = a[i]) && (t[i] = (S) => new Promise((P, f, w) => (S = h.call(a, S), w = S.done, Promise.resolve(S.value).then((H) => P({ value: H, done: w }), f)))), s("next"), s("return"), t);
35
+ import { i as Bt } from "../index-Bv9zgfdb.js";
36
+ import { d as R } from "../events-CsVF98U6.js";
37
+ import { r as ie } from "../polyfills-DJrTJQky.js";
38
+ import { w as re, s as ne } from "../scroll-DPkCFTxg.js";
39
39
  import "construct-style-sheets-polyfill";
40
- import { n as ne, c as Lt, s as re } from "../url-UL9zSCHb.js";
41
- import { cssValueParser as ae } from "../css-value-parser/index.js";
42
- class Bt extends HTMLElement {
40
+ import { n as ae, c as vt, s as oe } from "../url-UL9zSCHb.js";
41
+ import { cssValueParser as le } from "../css-value-parser/index.js";
42
+ class Yt extends HTMLElement {
43
43
  connectedCallback() {
44
44
  const t = {
45
45
  "aria-live": "assertive",
@@ -50,87 +50,90 @@ class Bt extends HTMLElement {
50
50
  this.setAttribute(s, i);
51
51
  }
52
52
  }
53
- Xt && !customElements.get("morph-announcer") && customElements.define("morph-announcer", Bt);
54
- var H, l, D, st, G;
55
- class vt {
53
+ Bt && !customElements.get("morph-announcer") && customElements.define("morph-announcer", Yt);
54
+ var M, l, U, it, G;
55
+ class yt {
56
56
  constructor(t, s) {
57
- o(this, H);
57
+ o(this, M);
58
58
  o(this, l);
59
- o(this, D);
60
- o(this, st, (t) => {
59
+ o(this, U);
60
+ o(this, it, (t) => {
61
61
  var i;
62
62
  if (t.preventDefault(), document.documentElement.classList.contains("click-disabled"))
63
63
  return;
64
- if (e(this, l).hasAttribute("data-back") && e(this, H).previousURL)
64
+ if (e(this, l).hasAttribute("data-back") && e(this, M).previousURL)
65
65
  history.back();
66
66
  else {
67
- n(this, D, e(this, l).getAttribute("href") || "/");
67
+ n(this, U, e(this, l).getAttribute("href") || "/");
68
68
  const h = e(this, l).getAttribute(
69
69
  "data-history-action"
70
- ) || "push", S = e(this, l).hasAttribute("data-center-scroll"), b = getComputedStyle(e(this, l)).getPropertyValue("--offset-scroll").trim(), f = b ? ae.parse(b) : void 0, w = e(this, l).hasAttribute("data-revalidate"), O = e(this, l).hasAttribute(
70
+ ) || "push", S = e(this, l).hasAttribute("data-center-scroll"), P = getComputedStyle(e(this, l)).getPropertyValue("--offset-scroll").trim(), f = P ? le.parse(P) : void 0, w = e(this, l).hasAttribute("data-revalidate"), H = e(this, l).hasAttribute(
71
71
  "data-keep-search-parameters"
72
- ), ot = (i = e(this, l).getAttribute("data-submorph")) == null ? void 0 : i.split(",").map((lt) => lt.trim()), c = e(this, l).hasAttribute("data-clear-state");
73
- e(this, H).navigate(e(this, D), {
72
+ ), Kt = e(this, l).hasAttribute(
73
+ "data-keep-scroll-position"
74
+ ), lt = (i = e(this, l).getAttribute("data-submorph")) == null ? void 0 : i.split(",").map((ht) => ht.trim()), c = e(this, l).hasAttribute("data-clear-state");
75
+ e(this, M).navigate(e(this, U), {
74
76
  historyAction: h,
75
77
  centerScroll: S,
76
78
  offsetScroll: f,
77
79
  revalidate: w,
78
- keepSearchParameters: O,
79
- submorph: ot,
80
- clearState: c
80
+ keepSearchParameters: H,
81
+ submorph: lt,
82
+ clearState: c,
83
+ keepScrollPosition: Kt
81
84
  });
82
85
  }
83
86
  });
84
87
  o(this, G, () => {
85
88
  const t = e(this, l).hasAttribute("data-revalidate");
86
- e(this, H).prefetch(e(this, D), t), e(this, l).removeEventListener("pointerenter", e(this, G));
89
+ e(this, M).prefetch(e(this, U), t), e(this, l).removeEventListener("pointerenter", e(this, G));
87
90
  });
88
- n(this, H, s), n(this, l, t), n(this, D, e(this, l).getAttribute("href") || "/"), e(this, l).addEventListener("click", e(this, st)), this.checkCurrent(location.pathname), e(this, l).hasAttribute("data-prefetch") && e(this, l).addEventListener("pointerenter", e(this, G));
91
+ n(this, M, s), n(this, l, t), n(this, U, e(this, l).getAttribute("href") || "/"), e(this, l).addEventListener("click", e(this, it)), this.checkCurrent(location.pathname), e(this, l).hasAttribute("data-prefetch") && e(this, l).addEventListener("pointerenter", e(this, G));
89
92
  }
90
93
  get element() {
91
94
  return e(this, l);
92
95
  }
93
96
  checkCurrent(t) {
94
97
  var h;
95
- const s = e(this, H).normalizePath(t), i = e(this, H).normalizePath(e(this, D));
98
+ const s = e(this, M).normalizePath(t), i = e(this, M).normalizePath(e(this, U));
96
99
  e(this, l).hasAttribute("data-include") && s.pathname.includes(i.pathname) ? e(this, l).classList.add("current") : i.pathname === s.pathname ? e(this, l).classList.add("current") : (h = e(this, l).getAttribute("data-associated-paths")) != null && h.split(",").find((S) => s.pathname.includes(S)) ? e(this, l).classList.add("current") : e(this, l).classList.remove("current");
97
100
  }
98
101
  destroy() {
99
- e(this, l).removeEventListener("click", e(this, st)), e(this, l).removeEventListener("pointerenter", e(this, G)), e(this, l).classList.remove("current");
102
+ e(this, l).removeEventListener("click", e(this, it)), e(this, l).removeEventListener("pointerenter", e(this, G)), e(this, l).classList.remove("current");
100
103
  }
101
104
  }
102
- H = new WeakMap(), l = new WeakMap(), D = new WeakMap(), st = new WeakMap(), G = new WeakMap();
103
- const oe = new DOMParser();
104
- var R, X, v, P, B, U, J, Y, z, Q, it;
105
- class Ft {
105
+ M = new WeakMap(), l = new WeakMap(), U = new WeakMap(), it = new WeakMap(), G = new WeakMap();
106
+ const he = new DOMParser();
107
+ var T, X, y, k, B, q, J, Y, z, Q, rt;
108
+ class Wt {
106
109
  constructor(t, s) {
107
- o(this, R);
110
+ o(this, T);
108
111
  o(this, X);
109
- o(this, v, { x: 0, y: 0 });
110
- o(this, P, null);
112
+ o(this, y, { x: 0, y: 0 });
113
+ o(this, k, null);
111
114
  o(this, B, null);
112
- o(this, U, null);
115
+ o(this, q, null);
113
116
  o(this, J, null);
114
117
  o(this, Y, null);
115
118
  o(this, z, null);
116
119
  o(this, Q);
117
- o(this, it);
118
- n(this, R, t), n(this, X, s), n(this, Q, s);
120
+ o(this, rt);
121
+ n(this, T, t), n(this, X, s), n(this, Q, s);
119
122
  }
120
123
  get pathname() {
121
124
  return e(this, X);
122
125
  }
123
126
  get scrollState() {
124
- return e(this, v);
127
+ return e(this, y);
125
128
  }
126
129
  get document() {
127
- return e(this, U);
130
+ return e(this, q);
128
131
  }
129
132
  setHeaders(t) {
130
- n(this, it, t);
133
+ n(this, rt, t);
131
134
  }
132
135
  setInitialDocument(t) {
133
- n(this, P, t.cloneNode(!0));
136
+ n(this, k, t.cloneNode(!0));
134
137
  }
135
138
  abort() {
136
139
  var t;
@@ -140,17 +143,17 @@ class Ft {
140
143
  }
141
144
  fetch(t, s, i) {
142
145
  return W(this, null, function* () {
143
- return e(this, z) || e(this, P) && e(this, P).documentElement.hasAttribute("data-cache") && (!i || e(this, Q) !== t) || e(this, P) && e(this, R).isPopstateNavigation ? e(this, z) : (n(this, Q, t), n(this, z, new Promise((h) => W(this, null, function* () {
146
+ return e(this, z) || e(this, k) && e(this, k).documentElement.hasAttribute("data-cache") && (!i || e(this, Q) !== t) || e(this, k) && e(this, T).isPopstateNavigation ? e(this, z) : (n(this, Q, t), n(this, z, new Promise((h) => W(this, null, function* () {
144
147
  try {
145
148
  n(this, Y, new AbortController());
146
- const b = yield (yield fetch(t, {
149
+ const P = yield (yield fetch(t, {
147
150
  signal: e(this, Y).signal,
148
- headers: ut({
151
+ headers: mt({
149
152
  "X-MORPH": "true",
150
153
  "X-MORPH-CURRENT-PATH": s,
151
154
  "X-MORPH-NEW-PATH": t
152
- }, e(this, it))
153
- })).text(), f = oe.parseFromString(b, "text/html");
155
+ }, e(this, rt))
156
+ })).text(), f = he.parseFromString(P, "text/html");
154
157
  this.setInitialDocument(f);
155
158
  } catch (S) {
156
159
  console.warn(S);
@@ -161,43 +164,43 @@ class Ft {
161
164
  });
162
165
  }
163
166
  cloneDocument() {
164
- n(this, U, (e(this, B) || e(this, P)).cloneNode(!0));
167
+ n(this, q, (e(this, B) || e(this, k)).cloneNode(!0));
165
168
  }
166
169
  get title() {
167
170
  let t = "";
168
- if (e(this, U).title)
169
- t = e(this, U).title;
171
+ if (e(this, q).title)
172
+ t = e(this, q).title;
170
173
  else {
171
- const s = e(this, U).querySelector("h1");
174
+ const s = e(this, q).querySelector("h1");
172
175
  t = (s == null ? void 0 : s.innerText) || (s == null ? void 0 : s.textContent) || e(this, X);
173
176
  }
174
177
  return t;
175
178
  }
176
179
  clearScrollState() {
177
- e(this, v).x = 0, e(this, v).y = 0;
180
+ e(this, y).x = 0, e(this, y).y = 0;
178
181
  }
179
182
  clearDocumentState() {
180
183
  n(this, B, null);
181
184
  }
182
185
  saveScrollState() {
183
- e(this, P).documentElement.hasAttribute(
186
+ e(this, k).documentElement.hasAttribute(
184
187
  "data-no-scroll-restoration"
185
- ) ? (e(this, v).x = 0, e(this, v).y = 0) : (e(this, v).x = e(this, R).scrollValue.left, e(this, v).y = e(this, R).scrollValue.top);
188
+ ) ? (e(this, y).x = 0, e(this, y).y = 0) : (e(this, y).x = e(this, T).scrollValue.left, e(this, y).y = e(this, T).scrollValue.top);
186
189
  }
187
190
  restoreScrollPosition() {
188
- e(this, R).scrollElement.scroll({
189
- top: e(this, v).y,
190
- left: e(this, v).x,
191
+ e(this, T).scrollElement.scroll({
192
+ top: e(this, y).y,
193
+ left: e(this, y).x,
191
194
  behavior: "instant"
192
195
  });
193
196
  }
194
197
  saveDocumentState() {
195
- e(this, P).documentElement.hasAttribute(
198
+ e(this, k).documentElement.hasAttribute(
196
199
  "data-no-page-restoration"
197
200
  ) ? n(this, B, null) : n(this, B, document.cloneNode(!0));
198
201
  }
199
202
  renewScrollPosition() {
200
- e(this, R).scrollElement.scroll({
203
+ e(this, T).scrollElement.scroll({
201
204
  top: 0,
202
205
  left: 0,
203
206
  behavior: "instant"
@@ -211,38 +214,39 @@ class Ft {
211
214
  return n(this, J, null), t;
212
215
  }
213
216
  }
214
- R = new WeakMap(), X = new WeakMap(), v = new WeakMap(), P = new WeakMap(), B = new WeakMap(), U = new WeakMap(), J = new WeakMap(), Y = new WeakMap(), z = new WeakMap(), Q = new WeakMap(), it = new WeakMap();
215
- var A, nt, g, I, m, j, V, q, y, rt, M, K, Z, _, u, yt, at, dt, bt, Yt, Pt, At, kt, Ct, mt, tt;
216
- const et = class et {
217
+ T = new WeakMap(), X = new WeakMap(), y = new WeakMap(), k = new WeakMap(), B = new WeakMap(), q = new WeakMap(), J = new WeakMap(), Y = new WeakMap(), z = new WeakMap(), Q = new WeakMap(), rt = new WeakMap();
218
+ var C, Z, g, I, m, j, V, O, A, nt, x, K, _, tt, at, u, bt, ot, ft, At, jt, Pt, kt, Ct, Ht, pt, et;
219
+ const st = class st {
217
220
  constructor(t) {
218
221
  o(this, u);
219
- o(this, A, null);
220
- o(this, nt, null);
222
+ o(this, C, null);
223
+ o(this, Z, null);
221
224
  o(this, g, []);
222
225
  o(this, I);
223
226
  o(this, m, null);
224
227
  o(this, j);
225
228
  o(this, V, []);
226
- o(this, q, !1);
227
- o(this, y, null);
228
- o(this, rt, !1);
229
- o(this, M, /* @__PURE__ */ new Map());
229
+ o(this, O, !1);
230
+ o(this, A, null);
231
+ o(this, nt, !1);
232
+ o(this, x, /* @__PURE__ */ new Map());
230
233
  o(this, K, null);
231
- o(this, Z, 0);
232
234
  o(this, _, 0);
233
- o(this, at, (t) => {
235
+ o(this, tt, 0);
236
+ o(this, at, null);
237
+ o(this, ot, (t) => {
234
238
  var s;
235
239
  return ((s = t.getAttribute("href")) == null ? void 0 : s.startsWith("/")) && !t.hasAttribute("download") && !t.hasAttribute("data-morph-skip") && !t.closest("[data-morph-skip]") && t.getAttribute("target") !== "_blank";
236
240
  });
237
- o(this, mt, (t) => W(this, null, function* () {
238
- t.preventDefault(), n(this, q, !0), yield this.navigate(location.href.replace(location.origin, ""), {
241
+ o(this, pt, (t) => W(this, null, function* () {
242
+ t.preventDefault(), n(this, O, !0), yield this.navigate(location.href.replace(location.origin, ""), {
239
243
  historyAction: "none",
240
- submorph: t.state.submorph
241
- }), n(this, q, !1);
244
+ submorph: e(this, at) || void 0
245
+ }), n(this, O, !1);
242
246
  }));
243
- o(this, tt, () => {
244
- const { left: t, top: s } = this.scrollValue, i = s - e(this, _), h = t - e(this, Z);
245
- n(this, _, s), n(this, Z, t), document.documentElement.classList.toggle("scroll-y", s > 0), document.documentElement.classList.toggle("scroll-x", t > 0), document.documentElement.classList.toggle(
247
+ o(this, et, () => {
248
+ const { left: t, top: s } = this.scrollValue, i = s - e(this, tt), h = t - e(this, _);
249
+ n(this, tt, s), n(this, _, t), document.documentElement.classList.toggle("scroll-y", s > 0), document.documentElement.classList.toggle("scroll-x", t > 0), document.documentElement.classList.toggle(
246
250
  "scroll-y-forward",
247
251
  i > 0
248
252
  ), document.documentElement.classList.toggle(
@@ -254,38 +258,38 @@ const et = class et {
254
258
  ), document.documentElement.classList.toggle(
255
259
  "scroll-x-backward",
256
260
  h < 0
257
- ), C(document, "morphScroll", {
261
+ ), R(document, "morphScroll", {
258
262
  detail: {
259
263
  left: t,
260
264
  top: s
261
265
  }
262
266
  });
263
267
  });
264
- if (Xt && !et.instance) {
265
- et.instance = this, n(this, A, {
266
- base: ne(t == null ? void 0 : t.base),
268
+ if (Bt && !st.instance) {
269
+ st.instance = this, n(this, C, {
270
+ base: ae(t == null ? void 0 : t.base),
267
271
  waitForHeadToLoad: (t == null ? void 0 : t.waitForHeadToLoad) !== !1,
268
272
  trailingSlash: (t == null ? void 0 : t.trailingSlash) || !1,
269
273
  scrollSelector: t == null ? void 0 : t.scrollSelector,
270
274
  morphInsideScrollContainer: (t == null ? void 0 : t.morphInsideScrollContainer) || !1
271
- }), n(this, nt, E(this, u, bt).call(this, document.body));
275
+ }), n(this, Z, E(this, u, At).call(this, document.body));
272
276
  const s = this.normalizePath(
273
277
  location.pathname + location.hash + location.search
274
278
  );
275
279
  n(this, m, s);
276
- const i = new Ft(this, e(this, m).pathname);
277
- i.setInitialDocument(document), e(this, M).set(e(this, m).pathname, i), document.documentElement.setAttribute(
280
+ const i = new Wt(this, e(this, m).pathname);
281
+ i.setInitialDocument(document), e(this, x).set(e(this, m).pathname, i), document.documentElement.setAttribute(
278
282
  "data-current-pathname",
279
283
  e(this, m).pathname
280
284
  ), document.documentElement.setAttribute(
281
285
  "data-current-leaf",
282
286
  s.leaf
283
- ), this.findLinks(), history.scrollRestoration = "manual", addEventListener("popstate", e(this, mt)), Lt({
287
+ ), this.findLinks(), history.scrollRestoration = "manual", addEventListener("popstate", e(this, pt)), vt({
284
288
  action: "replace",
285
289
  pathname: s.pathname,
286
290
  searchParameters: s.parameters,
287
291
  hash: s.hash
288
- }), n(this, K, new Bt()), E(this, u, kt).call(this, document);
292
+ }), n(this, K, new Yt()), E(this, u, Ct).call(this, document);
289
293
  }
290
294
  }
291
295
  get currentURL() {
@@ -298,27 +302,27 @@ const et = class et {
298
302
  return e(this, g);
299
303
  }
300
304
  get scrollElement() {
301
- return e(this, y);
305
+ return e(this, A);
302
306
  }
303
307
  get isPopstateNavigation() {
304
- return e(this, q);
308
+ return e(this, O);
305
309
  }
306
310
  get scrollValue() {
307
311
  let t = 0, s = 0;
308
- return e(this, rt) ? (t = window.scrollY, s = window.scrollX) : (t = e(this, y).scrollTop, s = e(this, y).scrollLeft), { top: t, left: s };
312
+ return e(this, nt) ? (t = window.scrollY, s = window.scrollX) : (t = e(this, A).scrollTop, s = e(this, A).scrollLeft), { top: t, left: s };
309
313
  }
310
314
  saveState(t) {
311
- const s = e(this, M).get(e(this, m).path);
315
+ const s = e(this, x).get(e(this, m).path);
312
316
  s && s.saveState(t);
313
317
  }
314
318
  getState() {
315
- const t = e(this, M).get(e(this, m).path);
319
+ const t = e(this, x).get(e(this, m).path);
316
320
  return t == null ? void 0 : t.clearState();
317
321
  }
318
322
  normalizePath(t) {
319
- return re(t, {
320
- base: e(this, A).base,
321
- trailingSlash: e(this, A).trailingSlash
323
+ return oe(t, {
324
+ base: e(this, C).base,
325
+ trailingSlash: e(this, C).trailingSlash
322
326
  });
323
327
  }
324
328
  prefetch(t, s) {
@@ -327,7 +331,7 @@ const et = class et {
327
331
  if (e(this, V).length)
328
332
  return;
329
333
  t = ((h = this.pathnameModifier) == null ? void 0 : h.call(this, t)) || t;
330
- const i = E(this, u, dt).call(this, t);
334
+ const i = E(this, u, ft).call(this, t);
331
335
  i == null || i.fetch(t, e(this, m).path, s);
332
336
  });
333
337
  }
@@ -336,36 +340,35 @@ const et = class et {
336
340
  }
337
341
  setHeaders(t) {
338
342
  }
339
- navigate(O) {
343
+ navigate(Kt) {
340
344
  return W(this, arguments, function* (t, {
341
345
  historyAction: s = "push",
342
346
  centerScroll: i,
343
347
  offsetScroll: h,
344
348
  revalidate: S,
345
- keepSearchParameters: b,
349
+ keepSearchParameters: P,
346
350
  submorph: f,
347
- clearState: w
351
+ clearState: w,
352
+ keepScrollPosition: H
348
353
  } = {}) {
349
- var lt, Ht, Rt, Mt;
354
+ var ht, Rt, Mt, Tt;
350
355
  if (e(this, V).length)
351
356
  return;
352
- const ot = ((lt = this.pathnameModifier) == null ? void 0 : lt.call(this, t)) || t, c = this.normalizePath(ot);
353
- if (((Ht = e(this, I)) == null ? void 0 : Ht.pathname) === c.pathname || e(this, m).pathname === c.pathname) {
354
- E(this, u, Ct).call(this, c.hash || 0, {
357
+ n(this, at, f || null);
358
+ const lt = ((ht = this.pathnameModifier) == null ? void 0 : ht.call(this, t)) || t, c = this.normalizePath(lt);
359
+ if (((Rt = e(this, I)) == null ? void 0 : Rt.pathname) === c.pathname || e(this, m).pathname === c.pathname) {
360
+ E(this, u, Ht).call(this, c.hash || 0, {
355
361
  centerScroll: i,
356
362
  offsetScroll: h,
357
363
  behavior: "smooth"
358
- }), C(document, "morphSamePath", {
364
+ }), R(document, "morphSamePath", {
359
365
  custom: !0
360
- }), ((Rt = e(this, m)) == null ? void 0 : Rt.parameters) !== c.parameters && (n(this, j, e(this, m)), n(this, m, c), Lt({
361
- action: ((Mt = e(this, m)) == null ? void 0 : Mt.hash) !== c.hash ? "replace" : s,
366
+ }), ((Mt = e(this, m)) == null ? void 0 : Mt.parameters) !== c.parameters && (n(this, j, e(this, m)), n(this, m, c), vt({
367
+ action: ((Tt = e(this, m)) == null ? void 0 : Tt.hash) !== c.hash ? "replace" : s,
362
368
  pathname: c.pathname,
363
369
  searchParameters: c.parameters,
364
- hash: c.hash,
365
- state: {
366
- submorph: f
367
- }
368
- }), C(document, "morphURLParametersChange", {
370
+ hash: c.hash
371
+ }), R(document, "morphURLParametersChange", {
369
372
  detail: {
370
373
  newURL: e(this, m),
371
374
  previousURL: e(this, j)
@@ -380,167 +383,173 @@ const et = class et {
380
383
  let $ = !0;
381
384
  if (this.preprocessor)
382
385
  try {
383
- yield new Promise((a, k) => {
384
- var T;
385
- (T = this.preprocessor) == null || T.call(this, {
386
+ yield new Promise((r, L) => {
387
+ var b;
388
+ (b = this.preprocessor) == null || b.call(this, {
386
389
  url: c,
387
- resolve: a,
388
- reject: k,
390
+ resolve: r,
391
+ reject: L,
389
392
  submorph: f
390
393
  });
391
394
  });
392
- } catch (a) {
393
- a ? console.error(a) : console.log("Route change canceled"), $ = !1;
395
+ } catch (r) {
396
+ r ? console.error(r) : console.log("Route change canceled"), $ = !1;
394
397
  }
395
398
  if (!$ || e(this, I).pathname !== c.pathname) {
396
- e(this, g).forEach((a) => {
397
- a.checkCurrent(e(this, m).pathname);
399
+ e(this, g).forEach((r) => {
400
+ r.checkCurrent(e(this, m).pathname);
398
401
  });
399
402
  return;
400
403
  }
401
- const Tt = {
404
+ const xt = {
402
405
  url: c,
403
406
  submorph: f
404
407
  };
405
- C(document, "morphNavigation", {
406
- detail: Tt
408
+ f ? f.forEach((r) => {
409
+ document.querySelectorAll(r).forEach((L) => {
410
+ L.classList.add("out"), L.setAttribute("data-morph-out", "");
411
+ });
412
+ }) : e(this, Z).forEach((r) => {
413
+ var L, b;
414
+ (L = r.firstElementChild) == null || L.classList.add("out"), (b = r.firstElementChild) == null || b.setAttribute("data-morph-out", "");
415
+ }), R(document, "morphNavigation", {
416
+ detail: xt
407
417
  });
408
- const ft = E(this, u, dt).call(this, e(this, m).pathname), p = E(this, u, dt).call(this, c.pathname);
409
- if (e(this, M).forEach((a) => {
410
- a.pathname !== c.pathname && a.abort();
411
- }), yield p == null ? void 0 : p.fetch(ot, e(this, m).path, S), e(this, I).pathname !== c.pathname) {
412
- e(this, g).forEach((a) => {
413
- a.checkCurrent(e(this, m).path);
418
+ const Et = E(this, u, ft).call(this, e(this, m).pathname), p = E(this, u, ft).call(this, c.pathname);
419
+ if (e(this, x).forEach((r) => {
420
+ r.pathname !== c.pathname && r.abort();
421
+ }), yield p == null ? void 0 : p.fetch(lt, e(this, m).path, S), e(this, I).pathname !== c.pathname) {
422
+ e(this, g).forEach((r) => {
423
+ r.checkCurrent(e(this, m).path);
414
424
  });
415
425
  return;
416
426
  }
417
- ft.clearState(), ft.saveScrollState(), ft.saveDocumentState(), e(this, q) || (p.clearScrollState(), p.clearDocumentState()), w && p.clearState(), p.cloneDocument(), e(this, K).textContent = p.title, document.body.appendChild(e(this, K));
418
- const pt = St(ut({}, Tt), {
427
+ Et.clearState(), Et.saveScrollState(), Et.saveDocumentState(), e(this, O) || (p.clearScrollState(), p.clearDocumentState()), w && p.clearState(), p.cloneDocument(), e(this, K).textContent = p.title, document.body.appendChild(e(this, K));
428
+ const ct = Lt(mt({}, xt), {
419
429
  document: p.document
420
430
  });
421
- C(document, "morphStart", {
422
- detail: pt
431
+ ct.document.querySelectorAll("[data-morph-out]").forEach((r) => {
432
+ r.classList.remove("out");
433
+ }), R(document, "morphStart", {
434
+ detail: ct
423
435
  });
424
- const xt = Array.from(document.head.children), Nt = Array.from(p.document.head.children), Dt = E(this, u, Yt).call(this, xt, Nt), jt = E(this, u, Pt).call(this, xt, Dt), ht = E(this, u, Pt).call(this, Nt, Dt).filter((a) => !this.excludeHeadChild(a));
425
- ht.forEach((a, k) => {
426
- a.tagName === "SCRIPT" && (ht[k] = E(this, u, yt).call(this, a));
427
- }), ht.forEach((a) => {
428
- document.head.appendChild(a);
436
+ const Nt = Array.from(document.head.children), Dt = Array.from(p.document.head.children), Ut = E(this, u, jt).call(this, Nt, Dt), $t = E(this, u, Pt).call(this, Nt, Ut), ut = E(this, u, Pt).call(this, Dt, Ut).filter((r) => !this.excludeHeadChild(r));
437
+ ut.forEach((r, L) => {
438
+ r.tagName === "SCRIPT" && (ut[L] = E(this, u, bt).call(this, r));
439
+ }), ut.forEach((r) => {
440
+ document.head.appendChild(r);
429
441
  });
430
- const Et = ht.filter((a) => {
431
- if (a.hasAttribute("data-no-waiting"))
442
+ const gt = ut.filter((r) => {
443
+ if (r.hasAttribute("data-no-waiting"))
432
444
  return !1;
433
- if (E(this, u, At).call(this, a))
445
+ if (E(this, u, kt).call(this, r))
434
446
  return !0;
435
447
  });
436
- e(this, A).waitForHeadToLoad && Et.length && (yield new Promise((a) => W(this, null, function* () {
437
- let k = 0;
448
+ e(this, C).waitForHeadToLoad && gt.length && (yield new Promise((r) => W(this, null, function* () {
449
+ let L = 0;
438
450
  try {
439
- for (var T = Ot(Et), $t, F, x; $t = !(F = yield T.next()).done; $t = !1) {
440
- const ct = F.value;
441
- ct.onload = () => {
442
- k++, k === Et.length && a();
451
+ for (var b = Ft(gt), Jt, F, N; Jt = !(F = yield b.next()).done; Jt = !1) {
452
+ const dt = F.value;
453
+ dt.onload = () => {
454
+ L++, L === gt.length && r();
443
455
  };
444
456
  }
445
457
  } catch (F) {
446
- x = [F];
458
+ N = [F];
447
459
  } finally {
448
460
  try {
449
- $t && (F = T.return) && (yield F.call(T));
461
+ Jt && (F = b.return) && (yield F.call(b));
450
462
  } finally {
451
- if (x)
452
- throw x[0];
463
+ if (N)
464
+ throw N[0];
453
465
  }
454
466
  }
455
- }))), yield se(10);
456
- const Ut = [];
457
- jt.forEach((a) => {
458
- a.hasAttribute("data-permanent") || (E(this, u, At).call(this, a) ? Ut.push(a) : a.remove());
467
+ }))), yield re(10);
468
+ const qt = [];
469
+ $t.forEach((r) => {
470
+ r.hasAttribute("data-permanent") || (E(this, u, kt).call(this, r) ? qt.push(r) : r.remove());
459
471
  });
460
- const Kt = E(this, u, bt).call(this, p.document.body);
461
- !e(this, A).morphInsideScrollContainer && !f && E(this, u, kt).call(this, p.document), document.documentElement.setAttribute(
472
+ const Gt = E(this, u, At).call(this, p.document.body);
473
+ !e(this, C).morphInsideScrollContainer && !f && E(this, u, Ct).call(this, p.document), document.documentElement.setAttribute(
462
474
  "data-current-pathname",
463
475
  c.pathname
464
476
  ), document.documentElement.setAttribute(
465
477
  "data-current-leaf",
466
478
  c.leaf
467
- ), Lt({
479
+ ), vt({
468
480
  action: s,
469
481
  pathname: c.pathname,
470
- searchParameters: c.parameters || (b ? location.search : ""),
471
- hash: c.hash,
472
- state: {
473
- submorph: f
474
- }
482
+ searchParameters: c.parameters || (P ? location.search : ""),
483
+ hash: c.hash
475
484
  }), e(this, K).remove(), n(this, j, e(this, m)), n(this, m, c);
476
- const gt = [];
477
- e(this, nt).forEach((a, k) => {
478
- const T = Kt[k], $t = getComputedStyle(a).getPropertyValue("--morph-duration");
479
- let F = [], x = [];
485
+ const St = [];
486
+ e(this, Z).forEach((r, L) => {
487
+ const b = Gt[L], Jt = getComputedStyle(r).getPropertyValue("--morph-duration");
488
+ let F = [], N = [];
480
489
  f ? (f.forEach((d) => {
481
- const L = a.querySelector(d), N = T.querySelector(d);
482
- L && N && (x.push(L), F.push(N));
483
- }), x.forEach((d) => {
484
- d.parentElement && gt.push(d.parentElement);
485
- })) : (F.push(...T.childNodes), x.push(...a.childNodes), gt.push(a)), x.forEach((d) => {
490
+ const v = r.querySelector(d), D = b.querySelector(d);
491
+ v && D && (N.push(v), F.push(D));
492
+ }), N.forEach((d) => {
493
+ d.parentElement && St.push(d.parentElement);
494
+ })) : (F.push(...b.childNodes), N.push(...r.childNodes), St.push(r)), N.forEach((d) => {
486
495
  d instanceof HTMLElement && (this.destroyOldLinks(d), d.classList.add("old"));
487
496
  }), F.forEach((d) => {
488
497
  d instanceof HTMLElement && (this.findNewLinks(d), d.classList.add("new"));
489
- }), f ? F.forEach((d, L) => {
490
- var N;
491
- (N = x[L].parentElement) == null || N.insertBefore(
498
+ }), f ? F.forEach((d, v) => {
499
+ var D;
500
+ (D = N[v].parentElement) == null || D.insertBefore(
492
501
  d,
493
- x[L]
502
+ N[v]
494
503
  );
495
- }) : a.prepend(...F), ee(() => {
496
- x.forEach((d) => {
504
+ }) : r.prepend(...F), ie(() => {
505
+ N.forEach((d) => {
497
506
  d instanceof HTMLElement && d.classList.add("old-idle");
498
507
  }), F.forEach((d) => {
499
- var L;
500
- d instanceof HTMLElement && ((L = d.parentElement) == null || L.style.setProperty(
508
+ var v;
509
+ d instanceof HTMLElement && ((v = d.parentElement) == null || v.style.setProperty(
501
510
  "--new-content-height",
502
511
  d.offsetHeight + "px"
503
512
  ), d.classList.add("new-idle"));
504
513
  });
505
514
  });
506
- const ct = St(ut({}, pt), {
507
- morphElement: a
515
+ const dt = Lt(mt({}, ct), {
516
+ morphElement: r
508
517
  });
509
- C(document, "morphNewChildrenAdded", {
510
- detail: ct
518
+ R(document, "morphNewChildrenAdded", {
519
+ detail: dt
511
520
  });
512
- const Gt = new Promise((d) => {
521
+ const Qt = new Promise((d) => {
513
522
  setTimeout(() => {
514
- x.forEach((L) => L.remove()), F.forEach((L) => {
515
- var N;
516
- L instanceof HTMLElement && ((N = L.parentElement) == null || N.style.removeProperty(
523
+ N.forEach((v) => v.remove()), F.forEach((v) => {
524
+ var D;
525
+ v instanceof HTMLElement && ((D = v.parentElement) == null || D.style.removeProperty(
517
526
  "--new-content-height"
518
- ), L.classList.remove("new-idle", "new"));
519
- }), C(document, "morphOldChildrenRemoved", {
520
- detail: ct
527
+ ), v.classList.remove("new-idle", "new"));
528
+ }), R(document, "morphOldChildrenRemoved", {
529
+ detail: dt
521
530
  }), d();
522
- }, (parseFloat($t) || 0) * 1e3 + 10);
531
+ }, (parseFloat(Jt) || 0) * 1e3 + 10);
523
532
  });
524
- e(this, V).push(Gt);
533
+ e(this, V).push(Qt);
525
534
  }), this.isPopstateNavigation ? document.documentElement.style.setProperty(
526
535
  "--new-document-scroll-position",
527
536
  (this.scrollValue.top - p.scrollState.y) * 1 + "px"
528
537
  ) : document.documentElement.style.setProperty(
529
538
  "--new-document-scroll-position",
530
539
  this.scrollValue.top + "px"
531
- ), C(document, "morphBeforeNavigationScroll", {
540
+ ), R(document, "morphBeforeNavigationScroll", {
532
541
  detail: p.scrollState
533
- }), c.hash ? (p.clearScrollState(), E(this, u, Ct).call(this, c.hash, {
542
+ }), c.hash ? (p.clearScrollState(), E(this, u, Ht).call(this, c.hash, {
534
543
  centerScroll: i,
535
544
  offsetScroll: h
536
- })) : e(this, q) ? p.restoreScrollPosition() : p.renewScrollPosition(), yield Promise.all(e(this, V)), Ut.forEach((a) => a.remove()), n(this, V, []), gt.forEach((a) => {
537
- a.querySelectorAll("script").forEach((T) => {
538
- T.replaceWith(E(this, u, yt).call(this, T));
545
+ })) : e(this, O) ? p.restoreScrollPosition() : H || p.renewScrollPosition(), yield Promise.all(e(this, V)), qt.forEach((r) => r.remove()), n(this, V, []), St.forEach((r) => {
546
+ r.querySelectorAll("script").forEach((b) => {
547
+ b.replaceWith(E(this, u, bt).call(this, b));
539
548
  });
540
- }), e(this, g).forEach((a) => {
541
- a.checkCurrent(e(this, m).path);
542
- }), C(document, "morphComplete", {
543
- detail: pt
549
+ }), e(this, g).forEach((r) => {
550
+ r.checkCurrent(e(this, m).path);
551
+ }), R(document, "morphComplete", {
552
+ detail: ct
544
553
  }), document.documentElement.style.removeProperty(
545
554
  "--new-document-scroll-position"
546
555
  ), window.dispatchEvent(new Event("resize"));
@@ -551,7 +560,7 @@ const et = class et {
551
560
  });
552
561
  }
553
562
  addLink(t) {
554
- e(this, g).push(new vt(t, this));
563
+ e(this, g).push(new yt(t, this));
555
564
  }
556
565
  addLinks(t) {
557
566
  t.forEach((s) => {
@@ -566,34 +575,34 @@ const et = class et {
566
575
  }
567
576
  findNewLinks(t) {
568
577
  const s = [...t.querySelectorAll("a")].filter(
569
- e(this, at)
578
+ e(this, ot)
570
579
  );
571
580
  e(this, g).push(
572
- ...s.map((i) => new vt(i, this))
581
+ ...s.map((i) => new yt(i, this))
573
582
  );
574
583
  }
575
584
  findLinks() {
576
585
  const t = [
577
586
  ...document.documentElement.querySelectorAll("a")
578
- ].filter(e(this, at));
579
- e(this, g).forEach((s) => s.destroy()), n(this, g, t.map((s) => new vt(s, this)));
587
+ ].filter(e(this, ot));
588
+ e(this, g).forEach((s) => s.destroy()), n(this, g, t.map((s) => new yt(s, this)));
580
589
  }
581
590
  };
582
- A = new WeakMap(), nt = new WeakMap(), g = new WeakMap(), I = new WeakMap(), m = new WeakMap(), j = new WeakMap(), V = new WeakMap(), q = new WeakMap(), y = new WeakMap(), rt = new WeakMap(), M = new WeakMap(), K = new WeakMap(), Z = new WeakMap(), _ = new WeakMap(), u = new WeakSet(), yt = function(t) {
591
+ C = new WeakMap(), Z = new WeakMap(), g = new WeakMap(), I = new WeakMap(), m = new WeakMap(), j = new WeakMap(), V = new WeakMap(), O = new WeakMap(), A = new WeakMap(), nt = new WeakMap(), x = new WeakMap(), K = new WeakMap(), _ = new WeakMap(), tt = new WeakMap(), at = new WeakMap(), u = new WeakSet(), bt = function(t) {
583
592
  const s = document.createElement("script");
584
593
  for (let i = 0; i < t.attributes.length; i++) {
585
594
  const h = t.attributes[i];
586
595
  s.setAttribute(h.name, h.value);
587
596
  }
588
597
  return t.hasAttribute("src") || (s.innerHTML = t.innerHTML), s;
589
- }, at = new WeakMap(), dt = function(t) {
598
+ }, ot = new WeakMap(), ft = function(t) {
590
599
  const s = this.normalizePath(t);
591
- let i = e(this, M).get(s.pathname);
592
- return i || (i = new Ft(this, s.pathname), e(this, M).set(s.pathname, i)), i;
593
- }, bt = function(t) {
600
+ let i = e(this, x).get(s.pathname);
601
+ return i || (i = new Wt(this, s.pathname), e(this, x).set(s.pathname, i)), i;
602
+ }, At = function(t) {
594
603
  const s = [...t.querySelectorAll("[data-morph]")];
595
604
  return s.length ? s : [t];
596
- }, Yt = function(t, s) {
605
+ }, jt = function(t, s) {
597
606
  return t.filter(
598
607
  (i) => s.find(
599
608
  (h) => h.outerHTML === i.outerHTML
@@ -605,24 +614,24 @@ A = new WeakMap(), nt = new WeakMap(), g = new WeakMap(), I = new WeakMap(), m =
605
614
  (h) => h.outerHTML === i.outerHTML
606
615
  )
607
616
  );
608
- }, At = function(t) {
609
- return t.tagName === "SCRIPT" || t.tagName === "STYLE" || t.tagName === "LINK" && t.getAttribute("rel") === "stylesheet";
610
617
  }, kt = function(t) {
618
+ return t.tagName === "SCRIPT" || t.tagName === "STYLE" || t.tagName === "LINK" && t.getAttribute("rel") === "stylesheet";
619
+ }, Ct = function(t) {
611
620
  var s, i;
612
- (s = e(this, y)) == null || s.removeEventListener(
621
+ (s = e(this, A)) == null || s.removeEventListener(
613
622
  "scroll",
614
- e(this, tt)
615
- ), n(this, _, 0), n(this, Z, 0), n(this, y, e(this, A).scrollSelector && t.querySelector(e(this, A).scrollSelector) || window), n(this, rt, e(this, y) === window), (i = e(this, y)) == null || i.addEventListener("scroll", e(this, tt)), e(this, tt).call(this);
616
- }, Ct = function(t, s) {
623
+ e(this, et)
624
+ ), n(this, tt, 0), n(this, _, 0), n(this, A, e(this, C).scrollSelector && t.querySelector(e(this, C).scrollSelector) || window), n(this, nt, e(this, A) === window), (i = e(this, A)) == null || i.addEventListener("scroll", e(this, et)), e(this, et).call(this);
625
+ }, Ht = function(t, s) {
617
626
  const i = typeof t == "string" ? document.getElementById(t) : t;
618
- (typeof i == "number" || i) && ie(i, {
619
- scrollElement: e(this, y),
627
+ (typeof i == "number" || i) && ne(i, {
628
+ scrollElement: e(this, A),
620
629
  behavior: (s == null ? void 0 : s.behavior) || "instant",
621
630
  center: s == null ? void 0 : s.centerScroll,
622
631
  offset: s == null ? void 0 : s.offsetScroll
623
632
  });
624
- }, mt = new WeakMap(), tt = new WeakMap(), et.instance = null;
625
- let Wt = et;
633
+ }, pt = new WeakMap(), et = new WeakMap(), st.instance = null;
634
+ let Xt = st;
626
635
  export {
627
- Wt as Morph
636
+ Xt as Morph
628
637
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aptechka",
3
- "version": "0.72.0",
3
+ "version": "0.72.2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/denisavitski/aptechka.git"