aptechka 0.62.4 → 0.63.0

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.
@@ -57,6 +57,8 @@ export declare class Morph {
57
57
  get links(): MorphLink[];
58
58
  get scrollElement(): HTMLElement;
59
59
  get isPopstateNavigation(): boolean;
60
+ saveState(state: any): void;
61
+ getState(): any;
60
62
  normalizePath(path: string): {
61
63
  leaf: string;
62
64
  pathname: string;
@@ -7,6 +7,7 @@ export interface MorphRouteSaveState {
7
7
  scroll?: MorphRouteScrollState | undefined;
8
8
  document?: Document | undefined;
9
9
  }
10
+ export type MorpRouteSaveParametersArg = string | object | URLSearchParams;
10
11
  export declare class MorphRoute {
11
12
  #private;
12
13
  constructor(morph: Morph, pathname: string, initialDocument: Document);
@@ -18,7 +19,9 @@ export declare class MorphRoute {
18
19
  clearScrollState(): void;
19
20
  clearDocumentState(): void;
20
21
  saveScrollState(): void;
21
- saveDocumentState(): void;
22
22
  restoreScrollPosition(): void;
23
+ saveDocumentState(): void;
23
24
  renewScrollPosition(): void;
25
+ saveState(state: any): void;
26
+ clearState(): any;
24
27
  }
@@ -1 +1 @@
1
- "use strict";var Pt=(n,t)=>(t=Symbol[n])?t:Symbol.for("Symbol."+n),At=n=>{throw TypeError(n)};var ct=(n,t,s)=>t.has(n)||At("Cannot "+s);var e=(n,t,s)=>(ct(n,t,"read from private field"),s?s.call(n):t.get(n)),o=(n,t,s)=>t.has(n)?At("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(n):t.set(n,s),a=(n,t,s,i)=>(ct(n,t,"write to private field"),i?i.call(n,s):t.set(n,s),s),d=(n,t,s)=>(ct(n,t,"access private method"),s);var R=(n,t,s)=>new Promise((i,u)=>{var v=S=>{try{g(s.next(S))}catch(A){u(A)}},L=S=>{try{g(s.throw(S))}catch(A){u(A)}},g=S=>S.done?i(S.value):Promise.resolve(S.value).then(v,L);g((s=s.apply(n,t)).next())});var kt=(n,t,s)=>(t=n[Pt("asyncIterator")])?t.call(n):(n=n[Pt("iterator")](),t={},s=(i,u)=>(u=n[i])&&(t[i]=v=>new Promise((L,g,S)=>(v=u.call(n,v),S=v.done,Promise.resolve(v.value).then(A=>L({value:A,done:S}),g)))),s("next"),s("return"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Mt=require("../index-Cqw2NKev.cjs"),U=require("../events-KVanG9sR.cjs"),It=require("../polyfills-Df4r-ETT.cjs"),Ct=require("../scroll-DAhSpkhR.cjs"),it=require("../url-D1CgmwZ_.cjs"),Ot=require("../css-value-parser/index.cjs");class Ht 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)}}Mt.isBrowser&&!customElements.get("morph-announcer")&&customElements.define("morph-announcer",Ht);var C,l,z,Z,$;class ht{constructor(t,s){o(this,C);o(this,l);o(this,z);o(this,Z,t=>{var i;if(t.preventDefault(),e(this,l).hasAttribute("data-back")&&e(this,C).previousPathname)history.back();else{const u=e(this,l).getAttribute("data-history-action")||"push",v=e(this,l).hasAttribute("data-center-scroll"),L=getComputedStyle(e(this,l)).getPropertyValue("--offset-scroll").trim(),g=L?Ot.cssValueParser.parse(L):void 0,S=e(this,l).hasAttribute("data-revalidate"),A=e(this,l).hasAttribute("data-keep-search-parameters"),m=(i=e(this,l).getAttribute("data-submorph"))==null?void 0:i.split(",").map(V=>V.trim());e(this,C).navigate(e(this,z),{historyAction:u,centerScroll:v,offsetScroll:g,revalidate:S,keepSearchParameters:A,submorph:m})}});o(this,$,()=>{const t=e(this,l).hasAttribute("data-revalidate");e(this,C).prefetch(e(this,z),t),e(this,l).removeEventListener("pointerenter",e(this,$))});a(this,C,s),a(this,l,t),a(this,z,e(this,l).getAttribute("href")||"/"),e(this,l).addEventListener("click",e(this,Z)),this.checkCurrent(location.pathname),e(this,l).hasAttribute("data-prefetch")&&e(this,l).addEventListener("pointerenter",e(this,$))}get element(){return e(this,l)}checkCurrent(t){const s=e(this,C).normalizePath(t),i=e(this,C).normalizePath(e(this,z));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"):e(this,l).classList.remove("current")}destroy(){e(this,l).removeEventListener("click",e(this,Z)),e(this,l).removeEventListener("pointerenter",e(this,$)),e(this,l).classList.remove("current")}}C=new WeakMap,l=new WeakMap,z=new WeakMap,Z=new WeakMap,$=new WeakMap;var x,K,w,I,O,N;class Tt{constructor(t,s,i){o(this,x);o(this,K);o(this,w,{x:0,y:0});o(this,I);o(this,O,null);o(this,N,null);a(this,x,t),a(this,K,s),a(this,I,i.cloneNode(!0))}get pathname(){return e(this,K)}get scrollState(){return e(this,w)}get document(){return e(this,N)}cloneDocument(){a(this,N,(e(this,O)||e(this,I)).cloneNode(!0))}get title(){let t="";if(e(this,N).title)t=e(this,N).title;else{const s=e(this,N).querySelector("h1");t=(s==null?void 0:s.innerText)||(s==null?void 0:s.textContent)||e(this,K)}return t}clearScrollState(){e(this,w).x=0,e(this,w).y=0}clearDocumentState(){a(this,O,null)}saveScrollState(){e(this,I).documentElement.hasAttribute("data-no-scroll-restoration")?(e(this,w).x=0,e(this,w).y=0):(e(this,w).x=e(this,x).scrollElement.scrollLeft,e(this,w).y=e(this,x).scrollElement.scrollTop)}saveDocumentState(){e(this,I).documentElement.hasAttribute("data-no-page-restoration")?a(this,O,null):a(this,O,document.cloneNode(!0))}restoreScrollPosition(){e(this,x).scrollElement.scroll({top:e(this,w).y,left:e(this,w).x,behavior:"instant"})}renewScrollPosition(){e(this,x).scrollElement.scroll({top:0,left:0,behavior:"instant"})}}x=new WeakMap,K=new WeakMap,w=new WeakMap,I=new WeakMap,O=new WeakMap,N=new WeakMap;var T,Y,f,nt,q,p,_,B,M,P,G,F,tt,c,rt,xt,dt,Nt,mt,ft,pt,Et,ot,J;const X=class X{constructor(t){o(this,c);o(this,T,null);o(this,Y,null);o(this,f,[]);o(this,nt,new DOMParser);o(this,q);o(this,p,null);o(this,_);o(this,B,[]);o(this,M,!1);o(this,P,null);o(this,G,new Map);o(this,F,null);o(this,tt,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,ot,t=>R(this,null,function*(){var s;(s=t.state)!=null&&s.path&&(t.preventDefault(),a(this,M,!0),yield this.navigate(t.state.path,{historyAction:"none"}),a(this,M,!1))}));o(this,J,()=>{const t=e(this,P).scrollTop,s=e(this,P).scrollLeft;document.documentElement.classList.toggle("top-scrolled",t>0),document.documentElement.classList.toggle("left-scrolled",s>0),U.dispatchEvent(document,"morphScroll",{detail:{left:s,top:t}})});if(Mt.isBrowser&&!X.instance){X.instance=this,a(this,T,{base:it.normalizeBase(t==null?void 0:t.base),waitForHeadToLoad:(t==null?void 0:t.waitForHeadToLoad)!==!1,cachePages:(t==null?void 0:t.cachePages)!==!1,trailingSlash:(t==null?void 0:t.trailingSlash)||!1,scrollSelector:(t==null?void 0:t.scrollSelector)||"body",morphInsideScrollContainer:(t==null?void 0:t.morphInsideScrollContainer)||!1}),a(this,Y,d(this,c,dt).call(this,document.body));const s=this.normalizePath(location.pathname+location.hash);a(this,p,s.pathname),e(this,G).set(e(this,p),new Tt(this,e(this,p),document)),document.documentElement.setAttribute("data-current-pathname",e(this,p)),document.documentElement.setAttribute("data-current-leaf",s.leaf),this.findLinks(),addEventListener("popstate",e(this,ot)),it.changeHistory({action:"replace",pathname:e(this,p),searchParameters:s.parameters||location.search,hash:s.hash}),a(this,F,new Ht),d(this,c,pt).call(this,document)}}get currentPathname(){return e(this,p)}get previousPathname(){return e(this,_)}get links(){return e(this,f)}get scrollElement(){return e(this,P)}get isPopstateNavigation(){return e(this,M)}normalizePath(t){return it.splitPath(t,{base:e(this,T).base,trailingSlash:e(this,T).trailingSlash})}prefetch(t,s){return R(this,null,function*(){const i=this.normalizePath(t);d(this,c,rt).call(this,i.pathname,{searchParameters:i.parameters,revalidate:s})})}navigate(S){return R(this,arguments,function*(t,{historyAction:s="push",centerScroll:i,offsetScroll:u,revalidate:v,keepSearchParameters:L,submorph:g}={}){var vt;if(e(this,B).length)return;const A=this.normalizePath(((vt=this.pathnameModifier)==null?void 0:vt.call(this,t))||t);let{pathname:m,hash:V,parameters:gt,leaf:qt}=A;if(e(this,q)===m||e(this,p)===m){e(this,M)||d(this,c,Et).call(this,V||0,{centerScroll:i,offsetScroll:u,behavior:"smooth"});return}a(this,q,m),e(this,f).forEach(W=>{W.checkCurrent(m)});try{let W=!0;if(this.preprocessor)try{yield new Promise((r,k)=>{var y;(y=this.preprocessor)==null||y.call(this,{pathname:m,resolve:r,reject:k,submorph:g})})}catch(r){r?console.error(r):console.log("Route change canceled"),W=!1}if(!W||e(this,q)!==m){e(this,f).forEach(r=>{r.checkCurrent(e(this,p))});return}const at={pathname:m,submorph:g};U.dispatchEvent(document,"morphNavigation",{detail:at});const St=yield d(this,c,rt).call(this,e(this,p)),b=yield d(this,c,rt).call(this,m,{searchParameters:gt,revalidate:v});if(e(this,q)!==m){e(this,f).forEach(r=>{r.checkCurrent(e(this,p))});return}St.saveScrollState(),St.saveDocumentState(),e(this,M)||(b.clearScrollState(),b.clearDocumentState()),b.cloneDocument(),e(this,F).textContent=b.title,document.body.appendChild(e(this,F)),U.dispatchEvent(document,"morphStart",{detail:at});const yt=Array.from(document.head.children),wt=Array.from(b.document.head.children),Lt=d(this,c,Nt).call(this,yt,wt),Dt=d(this,c,mt).call(this,yt,Lt),et=d(this,c,mt).call(this,wt,Lt);et.forEach((r,k)=>{if(r.tagName==="SCRIPT"&&r.getAttribute("src")){const y=document.createElement("script");y.type="module",y.src=r.getAttribute("src"),et[k]=y}}),et.forEach(r=>{document.head.appendChild(r)});const lt=et.filter(r=>{if(r.hasAttribute("data-no-waiting"))return!1;if(d(this,c,ft).call(this,r))return!0});e(this,T).waitForHeadToLoad&&lt.length&&(yield new Promise(r=>R(this,null,function*(){let k=0;try{for(var y=kt(lt),Q,D,j;Q=!(D=yield y.next()).done;Q=!1){const st=D.value;st.onload=()=>{k++,k===lt.length&&r()}}}catch(D){j=[D]}finally{try{Q&&(D=y.return)&&(yield D.call(y))}finally{if(j)throw j[0]}}}))),yield Ct.wait(10);const bt=[];Dt.forEach(r=>{r.hasAttribute("data-permanent")||(d(this,c,ft).call(this,r)?bt.push(r):r.remove())});const Rt=d(this,c,dt).call(this,b.document.body);e(this,T).morphInsideScrollContainer||d(this,c,pt).call(this,b.document),document.documentElement.setAttribute("data-current-pathname",m),document.documentElement.setAttribute("data-current-leaf",qt),it.changeHistory({action:s,pathname:m,searchParameters:gt||(L?location.search:""),hash:V}),e(this,F).remove(),a(this,_,e(this,p)),a(this,p,m),e(this,Y).forEach((r,k)=>{const y=Rt[k],Q=getComputedStyle(r).getPropertyValue("--morph-duration");let D=[],j=[];g?g.forEach(h=>{const E=r.querySelector(h),H=y.querySelector(h);E&&H&&(j.push(E),D.push(H))}):(D.push(...y.childNodes),j.push(...r.childNodes)),j.forEach(h=>{h instanceof HTMLElement&&(this.destroyOldLinks(h),h.classList.add("old"))}),D.forEach(h=>{h instanceof HTMLElement&&(this.findNewLinks(h),h.classList.add("new"))}),g?D.forEach((h,E)=>{var H;(H=j[E].parentElement)==null||H.insertBefore(h,j[E])}):r.prepend(...D),It.requestIdleCallback(()=>{D.forEach(h=>{var E;h instanceof HTMLElement&&((E=h.parentElement)==null||E.style.setProperty("--new-content-height",h.offsetHeight+"px"),h.classList.add("in"))})});const st={morphElement:r,pathname:m};U.dispatchEvent(document,"morphNewChildrenAdded",{detail:st});const zt=new Promise(h=>{setTimeout(()=>{j.forEach(E=>E.remove()),D.forEach(E=>{var H;E instanceof HTMLElement&&((H=E.parentElement)==null||H.style.removeProperty("--new-content-height"),E.classList.remove("in","new"))}),U.dispatchEvent(document,"morphOldChildrenRemoved",{detail:st}),h()},(parseFloat(Q)||0)*1e3+10)});e(this,B).push(zt)}),V?(b.clearScrollState(),d(this,c,Et).call(this,V,{centerScroll:i,offsetScroll:u})):e(this,M)?b.restoreScrollPosition():b.renewScrollPosition(),yield Promise.all(e(this,B)),bt.forEach(r=>r.remove()),a(this,B,[]),e(this,Y).forEach(r=>{r.querySelectorAll("script").forEach(y=>{const Q=document.createElement("script");Q.type="module",Q.src=y.getAttribute("src"),y.replaceWith(Q)})}),U.dispatchEvent(document,"morphComplete",{detail:at}),window.dispatchEvent(new Event("resize"))}catch(W){console.error(W)}a(this,q,void 0)})}addLink(t){e(this,f).push(new ht(t,this))}addLinks(t){t.forEach(s=>{this.addLink(s)})}removeLink(t){a(this,f,e(this,f).filter(s=>s.element===t?(s.destroy(),!1):!0))}destroyOldLinks(t){a(this,f,e(this,f).filter(s=>t.contains(s.element)?(s.destroy(),!1):!0))}findNewLinks(t){const s=[...t.querySelectorAll("a")].filter(e(this,tt));e(this,f).push(...s.map(i=>new ht(i,this)))}findLinks(){const t=[...document.documentElement.querySelectorAll("a")].filter(e(this,tt));e(this,f).forEach(s=>s.destroy()),a(this,f,t.map(s=>new ht(s,this)))}};T=new WeakMap,Y=new WeakMap,f=new WeakMap,nt=new WeakMap,q=new WeakMap,p=new WeakMap,_=new WeakMap,B=new WeakMap,M=new WeakMap,P=new WeakMap,G=new WeakMap,F=new WeakMap,tt=new WeakMap,c=new WeakSet,rt=function(t,s){return R(this,null,function*(){let i=e(this,G).get(t);return(!i||s!=null&&s.revalidate)&&(i=yield d(this,c,xt).call(this,t,s==null?void 0:s.searchParameters)),i})},xt=function(t,s){return R(this,null,function*(){const u=yield(yield fetch(`${t}${s?"?"+s:""}`)).text(),v=e(this,nt).parseFromString(u,"text/html"),L=new Tt(this,t,v);return e(this,G).set(t,L),L})},dt=function(t){const s=[...t.querySelectorAll("[data-morph]")];return s.length?s:[t]},Nt=function(t,s){return t.filter(i=>s.find(u=>u.outerHTML===i.outerHTML))},mt=function(t,s){return t.filter(i=>!s.find(u=>u.outerHTML===i.outerHTML))},ft=function(t){return t.tagName==="SCRIPT"||t.tagName==="STYLE"||t.tagName==="LINK"&&t.getAttribute("rel")==="stylesheet"},pt=function(t){var s,i;(s=e(this,P))==null||s.removeEventListener("scroll",e(this,J)),a(this,P,t.querySelector(e(this,T).scrollSelector)||t.documentElement),(i=e(this,P))==null||i.addEventListener("scroll",e(this,J)),e(this,J).call(this)},Et=function(t,s){const i=typeof t=="string"?document.getElementById(t):t;(typeof i=="number"||i)&&Ct.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})},ot=new WeakMap,J=new WeakMap,X.instance=null;let ut=X;exports.Morph=ut;
1
+ "use strict";var At=(n,t)=>(t=Symbol[n])?t:Symbol.for("Symbol."+n),kt=n=>{throw TypeError(n)};var ut=(n,t,s)=>t.has(n)||kt("Cannot "+s);var e=(n,t,s)=>(ut(n,t,"read from private field"),s?s.call(n):t.get(n)),a=(n,t,s)=>t.has(n)?kt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(n):t.set(n,s),o=(n,t,s,i)=>(ut(n,t,"write to private field"),i?i.call(n,s):t.set(n,s),s),m=(n,t,s)=>(ut(n,t,"access private method"),s);var z=(n,t,s)=>new Promise((i,d)=>{var v=S=>{try{g(s.next(S))}catch(A){d(A)}},L=S=>{try{g(s.throw(S))}catch(A){d(A)}},g=S=>S.done?i(S.value):Promise.resolve(S.value).then(v,L);g((s=s.apply(n,t)).next())});var Ct=(n,t,s)=>(t=n[At("asyncIterator")])?t.call(n):(n=n[At("iterator")](),t={},s=(i,d)=>(d=n[i])&&(t[i]=v=>new Promise((L,g,S)=>(v=d.call(n,v),S=v.done,Promise.resolve(v.value).then(A=>L({value:A,done:S}),g)))),s("next"),s("return"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Ht=require("../index-Cqw2NKev.cjs"),$=require("../events-KVanG9sR.cjs"),Ot=require("../polyfills-Df4r-ETT.cjs"),Tt=require("../scroll-DAhSpkhR.cjs"),rt=require("../url-D1CgmwZ_.cjs"),Bt=require("../css-value-parser/index.cjs");class xt 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)}}Ht.isBrowser&&!customElements.get("morph-announcer")&&customElements.define("morph-announcer",xt);var C,l,I,_,K;class dt{constructor(t,s){a(this,C);a(this,l);a(this,I);a(this,_,t=>{var i;if(t.preventDefault(),e(this,l).hasAttribute("data-back")&&e(this,C).previousPathname)history.back();else{const d=e(this,l).getAttribute("data-history-action")||"push",v=e(this,l).hasAttribute("data-center-scroll"),L=getComputedStyle(e(this,l)).getPropertyValue("--offset-scroll").trim(),g=L?Bt.cssValueParser.parse(L):void 0,S=e(this,l).hasAttribute("data-revalidate"),A=e(this,l).hasAttribute("data-keep-search-parameters"),f=(i=e(this,l).getAttribute("data-submorph"))==null?void 0:i.split(",").map(W=>W.trim());e(this,C).navigate(e(this,I),{historyAction:d,centerScroll:v,offsetScroll:g,revalidate:S,keepSearchParameters:A,submorph:f})}});a(this,K,()=>{const t=e(this,l).hasAttribute("data-revalidate");e(this,C).prefetch(e(this,I),t),e(this,l).removeEventListener("pointerenter",e(this,K))});o(this,C,s),o(this,l,t),o(this,I,e(this,l).getAttribute("href")||"/"),e(this,l).addEventListener("click",e(this,_)),this.checkCurrent(location.pathname),e(this,l).hasAttribute("data-prefetch")&&e(this,l).addEventListener("pointerenter",e(this,K))}get element(){return e(this,l)}checkCurrent(t){const s=e(this,C).normalizePath(t),i=e(this,C).normalizePath(e(this,I));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"):e(this,l).classList.remove("current")}destroy(){e(this,l).removeEventListener("click",e(this,_)),e(this,l).removeEventListener("pointerenter",e(this,K)),e(this,l).classList.remove("current")}}C=new WeakMap,l=new WeakMap,I=new WeakMap,_=new WeakMap,K=new WeakMap;var x,Y,w,O,B,N,G;class Mt{constructor(t,s,i){a(this,x);a(this,Y);a(this,w,{x:0,y:0});a(this,O);a(this,B,null);a(this,N,null);a(this,G,null);o(this,x,t),o(this,Y,s),o(this,O,i.cloneNode(!0))}get pathname(){return e(this,Y)}get scrollState(){return e(this,w)}get document(){return e(this,N)}cloneDocument(){o(this,N,(e(this,B)||e(this,O)).cloneNode(!0))}get title(){let t="";if(e(this,N).title)t=e(this,N).title;else{const s=e(this,N).querySelector("h1");t=(s==null?void 0:s.innerText)||(s==null?void 0:s.textContent)||e(this,Y)}return t}clearScrollState(){e(this,w).x=0,e(this,w).y=0}clearDocumentState(){o(this,B,null)}saveScrollState(){e(this,O).documentElement.hasAttribute("data-no-scroll-restoration")?(e(this,w).x=0,e(this,w).y=0):(e(this,w).x=e(this,x).scrollElement.scrollLeft,e(this,w).y=e(this,x).scrollElement.scrollTop)}restoreScrollPosition(){e(this,x).scrollElement.scroll({top:e(this,w).y,left:e(this,w).x,behavior:"instant"})}saveDocumentState(){e(this,O).documentElement.hasAttribute("data-no-page-restoration")?o(this,B,null):o(this,B,document.cloneNode(!0))}renewScrollPosition(){e(this,x).scrollElement.scroll({top:0,left:0,behavior:"instant"})}saveState(t){o(this,G,t)}clearState(){const t=e(this,G);return o(this,G,null),t}}x=new WeakMap,Y=new WeakMap,w=new WeakMap,O=new WeakMap,B=new WeakMap,N=new WeakMap,G=new WeakMap;var T,J,p,at,q,u,tt,F,M,P,D,V,et,c,nt,Nt,ft,qt,pt,Et,gt,vt,ot,Q;const Z=class Z{constructor(t){a(this,c);a(this,T,null);a(this,J,null);a(this,p,[]);a(this,at,new DOMParser);a(this,q);a(this,u,null);a(this,tt);a(this,F,[]);a(this,M,!1);a(this,P,null);a(this,D,new Map);a(this,V,null);a(this,et,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"});a(this,ot,t=>z(this,null,function*(){var s;(s=t.state)!=null&&s.path&&(t.preventDefault(),o(this,M,!0),yield this.navigate(t.state.path,{historyAction:"none"}),o(this,M,!1))}));a(this,Q,()=>{const t=e(this,P).scrollTop,s=e(this,P).scrollLeft;document.documentElement.classList.toggle("top-scrolled",t>0),document.documentElement.classList.toggle("left-scrolled",s>0),$.dispatchEvent(document,"morphScroll",{detail:{left:s,top:t}})});if(Ht.isBrowser&&!Z.instance){Z.instance=this,o(this,T,{base:rt.normalizeBase(t==null?void 0:t.base),waitForHeadToLoad:(t==null?void 0:t.waitForHeadToLoad)!==!1,cachePages:(t==null?void 0:t.cachePages)!==!1,trailingSlash:(t==null?void 0:t.trailingSlash)||!1,scrollSelector:(t==null?void 0:t.scrollSelector)||"body",morphInsideScrollContainer:(t==null?void 0:t.morphInsideScrollContainer)||!1}),o(this,J,m(this,c,ft).call(this,document.body));const s=this.normalizePath(location.pathname+location.hash);o(this,u,s.pathname),e(this,D).set(e(this,u),new Mt(this,e(this,u),document)),document.documentElement.setAttribute("data-current-pathname",e(this,u)),document.documentElement.setAttribute("data-current-leaf",s.leaf),this.findLinks(),addEventListener("popstate",e(this,ot)),rt.changeHistory({action:"replace",pathname:e(this,u),searchParameters:s.parameters||location.search,hash:s.hash}),o(this,V,new xt),m(this,c,gt).call(this,document)}}get currentPathname(){return e(this,u)}get previousPathname(){return e(this,tt)}get links(){return e(this,p)}get scrollElement(){return e(this,P)}get isPopstateNavigation(){return e(this,M)}saveState(t){const s=e(this,D).get(e(this,u));s&&s.saveState(t)}getState(){const t=e(this,D).get(e(this,u));return t==null?void 0:t.clearState()}normalizePath(t){return rt.splitPath(t,{base:e(this,T).base,trailingSlash:e(this,T).trailingSlash})}prefetch(t,s){return z(this,null,function*(){const i=this.normalizePath(t);m(this,c,nt).call(this,i.pathname,{searchParameters:i.parameters,revalidate:s})})}navigate(S){return z(this,arguments,function*(t,{historyAction:s="push",centerScroll:i,offsetScroll:d,revalidate:v,keepSearchParameters:L,submorph:g}={}){var yt;if(e(this,F).length)return;const A=this.normalizePath(((yt=this.pathnameModifier)==null?void 0:yt.call(this,t))||t);let{pathname:f,hash:W,parameters:St,leaf:Dt}=A;if(e(this,q)===f||e(this,u)===f){e(this,M)||m(this,c,vt).call(this,W||0,{centerScroll:i,offsetScroll:d,behavior:"smooth"});return}o(this,q,f),e(this,p).forEach(j=>{j.checkCurrent(f)});try{let j=!0;if(this.preprocessor)try{yield new Promise((r,k)=>{var y;(y=this.preprocessor)==null||y.call(this,{pathname:f,resolve:r,reject:k,submorph:g})})}catch(r){r?console.error(r):console.log("Route change canceled"),j=!1}if(!j||e(this,q)!==f){e(this,p).forEach(r=>{r.checkCurrent(e(this,u))});return}const lt={pathname:f,submorph:g};$.dispatchEvent(document,"morphNavigation",{detail:lt});const ct=yield m(this,c,nt).call(this,e(this,u)),b=yield m(this,c,nt).call(this,f,{searchParameters:St,revalidate:v});if(e(this,q)!==f){e(this,p).forEach(r=>{r.checkCurrent(e(this,u))});return}ct.clearState(),ct.saveScrollState(),ct.saveDocumentState(),e(this,M)||(b.clearScrollState(),b.clearDocumentState()),b.cloneDocument(),e(this,V).textContent=b.title,document.body.appendChild(e(this,V)),$.dispatchEvent(document,"morphStart",{detail:lt});const wt=Array.from(document.head.children),Lt=Array.from(b.document.head.children),bt=m(this,c,qt).call(this,wt,Lt),Rt=m(this,c,pt).call(this,wt,bt),st=m(this,c,pt).call(this,Lt,bt);st.forEach((r,k)=>{if(r.tagName==="SCRIPT"&&r.getAttribute("src")){const y=document.createElement("script");y.type="module",y.src=r.getAttribute("src"),st[k]=y}}),st.forEach(r=>{document.head.appendChild(r)});const ht=st.filter(r=>{if(r.hasAttribute("data-no-waiting"))return!1;if(m(this,c,Et).call(this,r))return!0});e(this,T).waitForHeadToLoad&&ht.length&&(yield new Promise(r=>z(this,null,function*(){let k=0;try{for(var y=Ct(ht),X,R,U;X=!(R=yield y.next()).done;X=!1){const it=R.value;it.onload=()=>{k++,k===ht.length&&r()}}}catch(R){U=[R]}finally{try{X&&(R=y.return)&&(yield R.call(y))}finally{if(U)throw U[0]}}}))),yield Tt.wait(10);const Pt=[];Rt.forEach(r=>{r.hasAttribute("data-permanent")||(m(this,c,Et).call(this,r)?Pt.push(r):r.remove())});const zt=m(this,c,ft).call(this,b.document.body);e(this,T).morphInsideScrollContainer||m(this,c,gt).call(this,b.document),document.documentElement.setAttribute("data-current-pathname",f),document.documentElement.setAttribute("data-current-leaf",Dt),rt.changeHistory({action:s,pathname:f,searchParameters:St||(L?location.search:""),hash:W}),e(this,V).remove(),o(this,tt,e(this,u)),o(this,u,f),e(this,J).forEach((r,k)=>{const y=zt[k],X=getComputedStyle(r).getPropertyValue("--morph-duration");let R=[],U=[];g?g.forEach(h=>{const E=r.querySelector(h),H=y.querySelector(h);E&&H&&(U.push(E),R.push(H))}):(R.push(...y.childNodes),U.push(...r.childNodes)),U.forEach(h=>{h instanceof HTMLElement&&(this.destroyOldLinks(h),h.classList.add("old"))}),R.forEach(h=>{h instanceof HTMLElement&&(this.findNewLinks(h),h.classList.add("new"))}),g?R.forEach((h,E)=>{var H;(H=U[E].parentElement)==null||H.insertBefore(h,U[E])}):r.prepend(...R),Ot.requestIdleCallback(()=>{R.forEach(h=>{var E;h instanceof HTMLElement&&((E=h.parentElement)==null||E.style.setProperty("--new-content-height",h.offsetHeight+"px"),h.classList.add("in"))})});const it={morphElement:r,pathname:f};$.dispatchEvent(document,"morphNewChildrenAdded",{detail:it});const It=new Promise(h=>{setTimeout(()=>{U.forEach(E=>E.remove()),R.forEach(E=>{var H;E instanceof HTMLElement&&((H=E.parentElement)==null||H.style.removeProperty("--new-content-height"),E.classList.remove("in","new"))}),$.dispatchEvent(document,"morphOldChildrenRemoved",{detail:it}),h()},(parseFloat(X)||0)*1e3+10)});e(this,F).push(It)}),W?(b.clearScrollState(),m(this,c,vt).call(this,W,{centerScroll:i,offsetScroll:d})):e(this,M)?b.restoreScrollPosition():b.renewScrollPosition(),yield Promise.all(e(this,F)),Pt.forEach(r=>r.remove()),o(this,F,[]),e(this,J).forEach(r=>{r.querySelectorAll("script").forEach(y=>{const X=document.createElement("script");X.type="module",X.src=y.getAttribute("src"),y.replaceWith(X)})}),$.dispatchEvent(document,"morphComplete",{detail:lt}),window.dispatchEvent(new Event("resize"))}catch(j){console.error(j)}o(this,q,void 0)})}addLink(t){e(this,p).push(new dt(t,this))}addLinks(t){t.forEach(s=>{this.addLink(s)})}removeLink(t){o(this,p,e(this,p).filter(s=>s.element===t?(s.destroy(),!1):!0))}destroyOldLinks(t){o(this,p,e(this,p).filter(s=>t.contains(s.element)?(s.destroy(),!1):!0))}findNewLinks(t){const s=[...t.querySelectorAll("a")].filter(e(this,et));e(this,p).push(...s.map(i=>new dt(i,this)))}findLinks(){const t=[...document.documentElement.querySelectorAll("a")].filter(e(this,et));e(this,p).forEach(s=>s.destroy()),o(this,p,t.map(s=>new dt(s,this)))}};T=new WeakMap,J=new WeakMap,p=new WeakMap,at=new WeakMap,q=new WeakMap,u=new WeakMap,tt=new WeakMap,F=new WeakMap,M=new WeakMap,P=new WeakMap,D=new WeakMap,V=new WeakMap,et=new WeakMap,c=new WeakSet,nt=function(t,s){return z(this,null,function*(){let i=e(this,D).get(t);return(!i||s!=null&&s.revalidate)&&(i=yield m(this,c,Nt).call(this,t,s==null?void 0:s.searchParameters)),i})},Nt=function(t,s){return z(this,null,function*(){const d=yield(yield fetch(`${t}${s?"?"+s:""}`)).text(),v=e(this,at).parseFromString(d,"text/html"),L=new Mt(this,t,v);return e(this,D).set(t,L),L})},ft=function(t){const s=[...t.querySelectorAll("[data-morph]")];return s.length?s:[t]},qt=function(t,s){return t.filter(i=>s.find(d=>d.outerHTML===i.outerHTML))},pt=function(t,s){return t.filter(i=>!s.find(d=>d.outerHTML===i.outerHTML))},Et=function(t){return t.tagName==="SCRIPT"||t.tagName==="STYLE"||t.tagName==="LINK"&&t.getAttribute("rel")==="stylesheet"},gt=function(t){var s,i;(s=e(this,P))==null||s.removeEventListener("scroll",e(this,Q)),o(this,P,t.querySelector(e(this,T).scrollSelector)||t.documentElement),(i=e(this,P))==null||i.addEventListener("scroll",e(this,Q)),e(this,Q).call(this)},vt=function(t,s){const i=typeof t=="string"?document.getElementById(t):t;(typeof i=="number"||i)&&Tt.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})},ot=new WeakMap,Q=new WeakMap,Z.instance=null;let mt=Z;exports.Morph=mt;
@@ -1,32 +1,32 @@
1
- var Lt = (n, t) => (t = Symbol[n]) ? t : Symbol.for("Symbol." + n), bt = (n) => {
1
+ var bt = (n, t) => (t = Symbol[n]) ? t : Symbol.for("Symbol." + n), Pt = (n) => {
2
2
  throw TypeError(n);
3
3
  };
4
- var lt = (n, t, s) => t.has(n) || bt("Cannot " + s);
5
- var e = (n, t, s) => (lt(n, t, "read from private field"), s ? s.call(n) : t.get(n)), a = (n, t, s) => t.has(n) ? bt("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(n) : t.set(n, s), o = (n, t, s, i) => (lt(n, t, "write to private field"), i ? i.call(n, s) : t.set(n, s), s), d = (n, t, s) => (lt(n, t, "access private method"), s);
6
- var q = (n, t, s) => new Promise((i, u) => {
7
- var v = (S) => {
4
+ var ct = (n, t, s) => t.has(n) || Pt("Cannot " + s);
5
+ var e = (n, t, s) => (ct(n, t, "read from private field"), s ? s.call(n) : t.get(n)), a = (n, t, s) => t.has(n) ? Pt("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(n) : t.set(n, s), o = (n, t, s, i) => (ct(n, t, "write to private field"), i ? i.call(n, s) : t.set(n, s), s), m = (n, t, s) => (ct(n, t, "access private method"), s);
6
+ var z = (n, t, s) => new Promise((i, d) => {
7
+ var S = (v) => {
8
8
  try {
9
- g(s.next(S));
9
+ g(s.next(v));
10
10
  } catch (A) {
11
- u(A);
11
+ d(A);
12
12
  }
13
- }, L = (S) => {
13
+ }, L = (v) => {
14
14
  try {
15
- g(s.throw(S));
15
+ g(s.throw(v));
16
16
  } catch (A) {
17
- u(A);
17
+ d(A);
18
18
  }
19
- }, g = (S) => S.done ? i(S.value) : Promise.resolve(S.value).then(v, L);
19
+ }, g = (v) => v.done ? i(v.value) : Promise.resolve(v.value).then(S, L);
20
20
  g((s = s.apply(n, t)).next());
21
21
  });
22
- var Pt = (n, t, s) => (t = n[Lt("asyncIterator")]) ? t.call(n) : (n = n[Lt("iterator")](), t = {}, s = (i, u) => (u = n[i]) && (t[i] = (v) => new Promise((L, g, S) => (v = u.call(n, v), S = v.done, Promise.resolve(v.value).then((A) => L({ value: A, done: S }), g)))), s("next"), s("return"), t);
23
- import { i as Tt } from "../index-euf5anj6.js";
24
- import { d as $ } from "../events-CsVF98U6.js";
25
- import { r as zt } from "../polyfills-DJrTJQky.js";
26
- import { w as It, s as Ft } from "../scroll-Benkuq-t.js";
27
- import { n as Ot, c as At, s as Bt } from "../url-B6BNcw6_.js";
28
- import { cssValueParser as Vt } from "../css-value-parser/index.js";
29
- class Mt extends HTMLElement {
22
+ var At = (n, t, s) => (t = n[bt("asyncIterator")]) ? t.call(n) : (n = n[bt("iterator")](), t = {}, s = (i, d) => (d = n[i]) && (t[i] = (S) => new Promise((L, g, v) => (S = d.call(n, S), v = S.done, Promise.resolve(S.value).then((A) => L({ value: A, done: v }), g)))), s("next"), s("return"), t);
23
+ import { i as Mt } from "../index-euf5anj6.js";
24
+ import { d as j } from "../events-CsVF98U6.js";
25
+ import { r as It } from "../polyfills-DJrTJQky.js";
26
+ import { w as Ft, s as Ot } from "../scroll-Benkuq-t.js";
27
+ import { n as Bt, c as kt, s as Vt } from "../url-B6BNcw6_.js";
28
+ import { cssValueParser as Wt } from "../css-value-parser/index.js";
29
+ class Ht extends HTMLElement {
30
30
  connectedCallback() {
31
31
  const t = {
32
32
  "aria-live": "assertive",
@@ -37,64 +37,65 @@ class Mt extends HTMLElement {
37
37
  this.setAttribute(s, i);
38
38
  }
39
39
  }
40
- Tt && !customElements.get("morph-announcer") && customElements.define("morph-announcer", Mt);
41
- var C, l, z, Z, j;
42
- class ht {
40
+ Mt && !customElements.get("morph-announcer") && customElements.define("morph-announcer", Ht);
41
+ var C, l, I, _, K;
42
+ class ut {
43
43
  constructor(t, s) {
44
44
  a(this, C);
45
45
  a(this, l);
46
- a(this, z);
47
- a(this, Z, (t) => {
46
+ a(this, I);
47
+ a(this, _, (t) => {
48
48
  var i;
49
49
  if (t.preventDefault(), e(this, l).hasAttribute("data-back") && e(this, C).previousPathname)
50
50
  history.back();
51
51
  else {
52
- const u = e(this, l).getAttribute(
52
+ const d = e(this, l).getAttribute(
53
53
  "data-history-action"
54
- ) || "push", v = e(this, l).hasAttribute("data-center-scroll"), L = getComputedStyle(e(this, l)).getPropertyValue("--offset-scroll").trim(), g = L ? Vt.parse(L) : void 0, S = e(this, l).hasAttribute("data-revalidate"), A = e(this, l).hasAttribute(
54
+ ) || "push", S = e(this, l).hasAttribute("data-center-scroll"), L = getComputedStyle(e(this, l)).getPropertyValue("--offset-scroll").trim(), g = L ? Wt.parse(L) : void 0, v = e(this, l).hasAttribute("data-revalidate"), A = e(this, l).hasAttribute(
55
55
  "data-keep-search-parameters"
56
- ), m = (i = e(this, l).getAttribute("data-submorph")) == null ? void 0 : i.split(",").map((V) => V.trim());
57
- e(this, C).navigate(e(this, z), {
58
- historyAction: u,
59
- centerScroll: v,
56
+ ), f = (i = e(this, l).getAttribute("data-submorph")) == null ? void 0 : i.split(",").map((W) => W.trim());
57
+ e(this, C).navigate(e(this, I), {
58
+ historyAction: d,
59
+ centerScroll: S,
60
60
  offsetScroll: g,
61
- revalidate: S,
61
+ revalidate: v,
62
62
  keepSearchParameters: A,
63
- submorph: m
63
+ submorph: f
64
64
  });
65
65
  }
66
66
  });
67
- a(this, j, () => {
67
+ a(this, K, () => {
68
68
  const t = e(this, l).hasAttribute("data-revalidate");
69
- e(this, C).prefetch(e(this, z), t), e(this, l).removeEventListener("pointerenter", e(this, j));
69
+ e(this, C).prefetch(e(this, I), t), e(this, l).removeEventListener("pointerenter", e(this, K));
70
70
  });
71
- o(this, C, s), o(this, l, t), o(this, z, e(this, l).getAttribute("href") || "/"), e(this, l).addEventListener("click", e(this, Z)), this.checkCurrent(location.pathname), e(this, l).hasAttribute("data-prefetch") && e(this, l).addEventListener("pointerenter", e(this, j));
71
+ o(this, C, s), o(this, l, t), o(this, I, e(this, l).getAttribute("href") || "/"), e(this, l).addEventListener("click", e(this, _)), this.checkCurrent(location.pathname), e(this, l).hasAttribute("data-prefetch") && e(this, l).addEventListener("pointerenter", e(this, K));
72
72
  }
73
73
  get element() {
74
74
  return e(this, l);
75
75
  }
76
76
  checkCurrent(t) {
77
- const s = e(this, C).normalizePath(t), i = e(this, C).normalizePath(e(this, z));
77
+ const s = e(this, C).normalizePath(t), i = e(this, C).normalizePath(e(this, I));
78
78
  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") : e(this, l).classList.remove("current");
79
79
  }
80
80
  destroy() {
81
- e(this, l).removeEventListener("click", e(this, Z)), e(this, l).removeEventListener("pointerenter", e(this, j)), e(this, l).classList.remove("current");
81
+ e(this, l).removeEventListener("click", e(this, _)), e(this, l).removeEventListener("pointerenter", e(this, K)), e(this, l).classList.remove("current");
82
82
  }
83
83
  }
84
- C = new WeakMap(), l = new WeakMap(), z = new WeakMap(), Z = new WeakMap(), j = new WeakMap();
85
- var N, K, w, I, F, x;
86
- class kt {
84
+ C = new WeakMap(), l = new WeakMap(), I = new WeakMap(), _ = new WeakMap(), K = new WeakMap();
85
+ var N, Y, w, F, O, x, G;
86
+ class Ct {
87
87
  constructor(t, s, i) {
88
88
  a(this, N);
89
- a(this, K);
89
+ a(this, Y);
90
90
  a(this, w, { x: 0, y: 0 });
91
- a(this, I);
92
- a(this, F, null);
91
+ a(this, F);
92
+ a(this, O, null);
93
93
  a(this, x, null);
94
- o(this, N, t), o(this, K, s), o(this, I, i.cloneNode(!0));
94
+ a(this, G, null);
95
+ o(this, N, t), o(this, Y, s), o(this, F, i.cloneNode(!0));
95
96
  }
96
97
  get pathname() {
97
- return e(this, K);
98
+ return e(this, Y);
98
99
  }
99
100
  get scrollState() {
100
101
  return e(this, w);
@@ -103,7 +104,7 @@ class kt {
103
104
  return e(this, x);
104
105
  }
105
106
  cloneDocument() {
106
- o(this, x, (e(this, F) || e(this, I)).cloneNode(!0));
107
+ o(this, x, (e(this, O) || e(this, F)).cloneNode(!0));
107
108
  }
108
109
  get title() {
109
110
  let t = "";
@@ -111,7 +112,7 @@ class kt {
111
112
  t = e(this, x).title;
112
113
  else {
113
114
  const s = e(this, x).querySelector("h1");
114
- t = (s == null ? void 0 : s.innerText) || (s == null ? void 0 : s.textContent) || e(this, K);
115
+ t = (s == null ? void 0 : s.innerText) || (s == null ? void 0 : s.textContent) || e(this, Y);
115
116
  }
116
117
  return t;
117
118
  }
@@ -119,18 +120,13 @@ class kt {
119
120
  e(this, w).x = 0, e(this, w).y = 0;
120
121
  }
121
122
  clearDocumentState() {
122
- o(this, F, null);
123
+ o(this, O, null);
123
124
  }
124
125
  saveScrollState() {
125
- e(this, I).documentElement.hasAttribute(
126
+ e(this, F).documentElement.hasAttribute(
126
127
  "data-no-scroll-restoration"
127
128
  ) ? (e(this, w).x = 0, e(this, w).y = 0) : (e(this, w).x = e(this, N).scrollElement.scrollLeft, e(this, w).y = e(this, N).scrollElement.scrollTop);
128
129
  }
129
- saveDocumentState() {
130
- e(this, I).documentElement.hasAttribute(
131
- "data-no-page-restoration"
132
- ) ? o(this, F, null) : o(this, F, document.cloneNode(!0));
133
- }
134
130
  restoreScrollPosition() {
135
131
  e(this, N).scrollElement.scroll({
136
132
  top: e(this, w).y,
@@ -138,6 +134,11 @@ class kt {
138
134
  behavior: "instant"
139
135
  });
140
136
  }
137
+ saveDocumentState() {
138
+ e(this, F).documentElement.hasAttribute(
139
+ "data-no-page-restoration"
140
+ ) ? o(this, O, null) : o(this, O, document.cloneNode(!0));
141
+ }
141
142
  renewScrollPosition() {
142
143
  e(this, N).scrollElement.scroll({
143
144
  top: 0,
@@ -145,78 +146,85 @@ class kt {
145
146
  behavior: "instant"
146
147
  });
147
148
  }
149
+ saveState(t) {
150
+ o(this, G, t);
151
+ }
152
+ clearState() {
153
+ const t = e(this, G);
154
+ return o(this, G, null), t;
155
+ }
148
156
  }
149
- N = new WeakMap(), K = new WeakMap(), w = new WeakMap(), I = new WeakMap(), F = new WeakMap(), x = new WeakMap();
150
- var T, Y, f, rt, D, p, _, O, M, P, G, B, tt, h, it, Ht, ct, Nt, ut, dt, mt, ft, nt, J;
151
- const X = class X {
157
+ N = new WeakMap(), Y = new WeakMap(), w = new WeakMap(), F = new WeakMap(), O = new WeakMap(), x = new WeakMap(), G = new WeakMap();
158
+ var T, J, p, nt, D, u, tt, B, M, P, R, V, et, h, rt, Nt, dt, xt, mt, ft, pt, Et, at, Q;
159
+ const Z = class Z {
152
160
  constructor(t) {
153
161
  a(this, h);
154
162
  a(this, T, null);
155
- a(this, Y, null);
156
- a(this, f, []);
157
- a(this, rt, new DOMParser());
163
+ a(this, J, null);
164
+ a(this, p, []);
165
+ a(this, nt, new DOMParser());
158
166
  a(this, D);
159
- a(this, p, null);
160
- a(this, _);
161
- a(this, O, []);
167
+ a(this, u, null);
168
+ a(this, tt);
169
+ a(this, B, []);
162
170
  a(this, M, !1);
163
171
  a(this, P, null);
164
- a(this, G, /* @__PURE__ */ new Map());
165
- a(this, B, null);
166
- a(this, tt, (t) => {
172
+ a(this, R, /* @__PURE__ */ new Map());
173
+ a(this, V, null);
174
+ a(this, et, (t) => {
167
175
  var s;
168
176
  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";
169
177
  });
170
- a(this, nt, (t) => q(this, null, function* () {
178
+ a(this, at, (t) => z(this, null, function* () {
171
179
  var s;
172
180
  (s = t.state) != null && s.path && (t.preventDefault(), o(this, M, !0), yield this.navigate(t.state.path, { historyAction: "none" }), o(this, M, !1));
173
181
  }));
174
- a(this, J, () => {
182
+ a(this, Q, () => {
175
183
  const t = e(this, P).scrollTop, s = e(this, P).scrollLeft;
176
- document.documentElement.classList.toggle("top-scrolled", t > 0), document.documentElement.classList.toggle("left-scrolled", s > 0), $(document, "morphScroll", {
184
+ document.documentElement.classList.toggle("top-scrolled", t > 0), document.documentElement.classList.toggle("left-scrolled", s > 0), j(document, "morphScroll", {
177
185
  detail: {
178
186
  left: s,
179
187
  top: t
180
188
  }
181
189
  });
182
190
  });
183
- if (Tt && !X.instance) {
184
- X.instance = this, o(this, T, {
185
- base: Ot(t == null ? void 0 : t.base),
191
+ if (Mt && !Z.instance) {
192
+ Z.instance = this, o(this, T, {
193
+ base: Bt(t == null ? void 0 : t.base),
186
194
  waitForHeadToLoad: (t == null ? void 0 : t.waitForHeadToLoad) !== !1,
187
195
  cachePages: (t == null ? void 0 : t.cachePages) !== !1,
188
196
  trailingSlash: (t == null ? void 0 : t.trailingSlash) || !1,
189
197
  scrollSelector: (t == null ? void 0 : t.scrollSelector) || "body",
190
198
  morphInsideScrollContainer: (t == null ? void 0 : t.morphInsideScrollContainer) || !1
191
- }), o(this, Y, d(this, h, ct).call(this, document.body));
199
+ }), o(this, J, m(this, h, dt).call(this, document.body));
192
200
  const s = this.normalizePath(
193
201
  location.pathname + location.hash
194
202
  );
195
- o(this, p, s.pathname), e(this, G).set(
196
- e(this, p),
197
- new kt(this, e(this, p), document)
203
+ o(this, u, s.pathname), e(this, R).set(
204
+ e(this, u),
205
+ new Ct(this, e(this, u), document)
198
206
  ), document.documentElement.setAttribute(
199
207
  "data-current-pathname",
200
- e(this, p)
208
+ e(this, u)
201
209
  ), document.documentElement.setAttribute(
202
210
  "data-current-leaf",
203
211
  s.leaf
204
- ), this.findLinks(), addEventListener("popstate", e(this, nt)), At({
212
+ ), this.findLinks(), addEventListener("popstate", e(this, at)), kt({
205
213
  action: "replace",
206
- pathname: e(this, p),
214
+ pathname: e(this, u),
207
215
  searchParameters: s.parameters || location.search,
208
216
  hash: s.hash
209
- }), o(this, B, new Mt()), d(this, h, mt).call(this, document);
217
+ }), o(this, V, new Ht()), m(this, h, pt).call(this, document);
210
218
  }
211
219
  }
212
220
  get currentPathname() {
213
- return e(this, p);
221
+ return e(this, u);
214
222
  }
215
223
  get previousPathname() {
216
- return e(this, _);
224
+ return e(this, tt);
217
225
  }
218
226
  get links() {
219
- return e(this, f);
227
+ return e(this, p);
220
228
  }
221
229
  get scrollElement() {
222
230
  return e(this, P);
@@ -224,151 +232,159 @@ const X = class X {
224
232
  get isPopstateNavigation() {
225
233
  return e(this, M);
226
234
  }
235
+ saveState(t) {
236
+ const s = e(this, R).get(e(this, u));
237
+ s && s.saveState(t);
238
+ }
239
+ getState() {
240
+ const t = e(this, R).get(e(this, u));
241
+ return t == null ? void 0 : t.clearState();
242
+ }
227
243
  normalizePath(t) {
228
- return Bt(t, {
244
+ return Vt(t, {
229
245
  base: e(this, T).base,
230
246
  trailingSlash: e(this, T).trailingSlash
231
247
  });
232
248
  }
233
249
  prefetch(t, s) {
234
- return q(this, null, function* () {
250
+ return z(this, null, function* () {
235
251
  const i = this.normalizePath(t);
236
- d(this, h, it).call(this, i.pathname, {
252
+ m(this, h, rt).call(this, i.pathname, {
237
253
  searchParameters: i.parameters,
238
254
  revalidate: s
239
255
  });
240
256
  });
241
257
  }
242
- navigate(S) {
243
- return q(this, arguments, function* (t, {
258
+ navigate(v) {
259
+ return z(this, arguments, function* (t, {
244
260
  historyAction: s = "push",
245
261
  centerScroll: i,
246
- offsetScroll: u,
247
- revalidate: v,
262
+ offsetScroll: d,
263
+ revalidate: S,
248
264
  keepSearchParameters: L,
249
265
  submorph: g
250
266
  } = {}) {
251
- var Et;
252
- if (e(this, O).length)
267
+ var St;
268
+ if (e(this, B).length)
253
269
  return;
254
- const A = this.normalizePath(((Et = this.pathnameModifier) == null ? void 0 : Et.call(this, t)) || t);
255
- let { pathname: m, hash: V, parameters: pt, leaf: xt } = A;
256
- if (e(this, D) === m || e(this, p) === m) {
257
- e(this, M) || d(this, h, ft).call(this, V || 0, {
270
+ const A = this.normalizePath(((St = this.pathnameModifier) == null ? void 0 : St.call(this, t)) || t);
271
+ let { pathname: f, hash: W, parameters: gt, leaf: Dt } = A;
272
+ if (e(this, D) === f || e(this, u) === f) {
273
+ e(this, M) || m(this, h, Et).call(this, W || 0, {
258
274
  centerScroll: i,
259
- offsetScroll: u,
275
+ offsetScroll: d,
260
276
  behavior: "smooth"
261
277
  });
262
278
  return;
263
279
  }
264
- o(this, D, m), e(this, f).forEach((W) => {
265
- W.checkCurrent(m);
280
+ o(this, D, f), e(this, p).forEach((U) => {
281
+ U.checkCurrent(f);
266
282
  });
267
283
  try {
268
- let W = !0;
284
+ let U = !0;
269
285
  if (this.preprocessor)
270
286
  try {
271
287
  yield new Promise((r, k) => {
272
288
  var y;
273
289
  (y = this.preprocessor) == null || y.call(this, {
274
- pathname: m,
290
+ pathname: f,
275
291
  resolve: r,
276
292
  reject: k,
277
293
  submorph: g
278
294
  });
279
295
  });
280
296
  } catch (r) {
281
- r ? console.error(r) : console.log("Route change canceled"), W = !1;
297
+ r ? console.error(r) : console.log("Route change canceled"), U = !1;
282
298
  }
283
- if (!W || e(this, D) !== m) {
284
- e(this, f).forEach((r) => {
285
- r.checkCurrent(e(this, p));
299
+ if (!U || e(this, D) !== f) {
300
+ e(this, p).forEach((r) => {
301
+ r.checkCurrent(e(this, u));
286
302
  });
287
303
  return;
288
304
  }
289
- const at = {
290
- pathname: m,
305
+ const ot = {
306
+ pathname: f,
291
307
  submorph: g
292
308
  };
293
- $(document, "morphNavigation", {
294
- detail: at
309
+ j(document, "morphNavigation", {
310
+ detail: ot
295
311
  });
296
- const gt = yield d(this, h, it).call(this, e(this, p)), b = yield d(this, h, it).call(this, m, {
297
- searchParameters: pt,
298
- revalidate: v
312
+ const lt = yield m(this, h, rt).call(this, e(this, u)), b = yield m(this, h, rt).call(this, f, {
313
+ searchParameters: gt,
314
+ revalidate: S
299
315
  });
300
- if (e(this, D) !== m) {
301
- e(this, f).forEach((r) => {
302
- r.checkCurrent(e(this, p));
316
+ if (e(this, D) !== f) {
317
+ e(this, p).forEach((r) => {
318
+ r.checkCurrent(e(this, u));
303
319
  });
304
320
  return;
305
321
  }
306
- gt.saveScrollState(), gt.saveDocumentState(), e(this, M) || (b.clearScrollState(), b.clearDocumentState()), b.cloneDocument(), e(this, B).textContent = b.title, document.body.appendChild(e(this, B)), $(document, "morphStart", {
307
- detail: at
322
+ lt.clearState(), lt.saveScrollState(), lt.saveDocumentState(), e(this, M) || (b.clearScrollState(), b.clearDocumentState()), b.cloneDocument(), e(this, V).textContent = b.title, document.body.appendChild(e(this, V)), j(document, "morphStart", {
323
+ detail: ot
308
324
  });
309
- const vt = Array.from(document.head.children), St = Array.from(b.document.head.children), yt = d(this, h, Nt).call(this, vt, St), Dt = d(this, h, ut).call(this, vt, yt), et = d(this, h, ut).call(this, St, yt);
310
- et.forEach((r, k) => {
325
+ const vt = Array.from(document.head.children), yt = Array.from(b.document.head.children), wt = m(this, h, xt).call(this, vt, yt), Rt = m(this, h, mt).call(this, vt, wt), st = m(this, h, mt).call(this, yt, wt);
326
+ st.forEach((r, k) => {
311
327
  if (r.tagName === "SCRIPT" && r.getAttribute("src")) {
312
328
  const y = document.createElement("script");
313
- y.type = "module", y.src = r.getAttribute("src"), et[k] = y;
329
+ y.type = "module", y.src = r.getAttribute("src"), st[k] = y;
314
330
  }
315
- }), et.forEach((r) => {
331
+ }), st.forEach((r) => {
316
332
  document.head.appendChild(r);
317
333
  });
318
- const ot = et.filter((r) => {
334
+ const ht = st.filter((r) => {
319
335
  if (r.hasAttribute("data-no-waiting"))
320
336
  return !1;
321
- if (d(this, h, dt).call(this, r))
337
+ if (m(this, h, ft).call(this, r))
322
338
  return !0;
323
339
  });
324
- e(this, T).waitForHeadToLoad && ot.length && (yield new Promise((r) => q(this, null, function* () {
340
+ e(this, T).waitForHeadToLoad && ht.length && (yield new Promise((r) => z(this, null, function* () {
325
341
  let k = 0;
326
342
  try {
327
- for (var y = Pt(ot), Q, R, U; Q = !(R = yield y.next()).done; Q = !1) {
328
- const st = R.value;
329
- st.onload = () => {
330
- k++, k === ot.length && r();
343
+ for (var y = At(ht), X, q, $; X = !(q = yield y.next()).done; X = !1) {
344
+ const it = q.value;
345
+ it.onload = () => {
346
+ k++, k === ht.length && r();
331
347
  };
332
348
  }
333
- } catch (R) {
334
- U = [R];
349
+ } catch (q) {
350
+ $ = [q];
335
351
  } finally {
336
352
  try {
337
- Q && (R = y.return) && (yield R.call(y));
353
+ X && (q = y.return) && (yield q.call(y));
338
354
  } finally {
339
- if (U)
340
- throw U[0];
355
+ if ($)
356
+ throw $[0];
341
357
  }
342
358
  }
343
- }))), yield It(10);
344
- const wt = [];
345
- Dt.forEach((r) => {
346
- r.hasAttribute("data-permanent") || (d(this, h, dt).call(this, r) ? wt.push(r) : r.remove());
359
+ }))), yield Ft(10);
360
+ const Lt = [];
361
+ Rt.forEach((r) => {
362
+ r.hasAttribute("data-permanent") || (m(this, h, ft).call(this, r) ? Lt.push(r) : r.remove());
347
363
  });
348
- const Rt = d(this, h, ct).call(this, b.document.body);
349
- e(this, T).morphInsideScrollContainer || d(this, h, mt).call(this, b.document), document.documentElement.setAttribute("data-current-pathname", m), document.documentElement.setAttribute("data-current-leaf", xt), At({
364
+ const qt = m(this, h, dt).call(this, b.document.body);
365
+ e(this, T).morphInsideScrollContainer || m(this, h, pt).call(this, b.document), document.documentElement.setAttribute("data-current-pathname", f), document.documentElement.setAttribute("data-current-leaf", Dt), kt({
350
366
  action: s,
351
- pathname: m,
352
- searchParameters: pt || (L ? location.search : ""),
353
- hash: V
354
- }), e(this, B).remove(), o(this, _, e(this, p)), o(this, p, m), e(this, Y).forEach((r, k) => {
355
- const y = Rt[k], Q = getComputedStyle(r).getPropertyValue("--morph-duration");
356
- let R = [], U = [];
367
+ pathname: f,
368
+ searchParameters: gt || (L ? location.search : ""),
369
+ hash: W
370
+ }), e(this, V).remove(), o(this, tt, e(this, u)), o(this, u, f), e(this, J).forEach((r, k) => {
371
+ const y = qt[k], X = getComputedStyle(r).getPropertyValue("--morph-duration");
372
+ let q = [], $ = [];
357
373
  g ? g.forEach((c) => {
358
374
  const E = r.querySelector(c), H = y.querySelector(c);
359
- E && H && (U.push(E), R.push(H));
360
- }) : (R.push(...y.childNodes), U.push(...r.childNodes)), U.forEach((c) => {
375
+ E && H && ($.push(E), q.push(H));
376
+ }) : (q.push(...y.childNodes), $.push(...r.childNodes)), $.forEach((c) => {
361
377
  c instanceof HTMLElement && (this.destroyOldLinks(c), c.classList.add("old"));
362
- }), R.forEach((c) => {
378
+ }), q.forEach((c) => {
363
379
  c instanceof HTMLElement && (this.findNewLinks(c), c.classList.add("new"));
364
- }), g ? R.forEach((c, E) => {
380
+ }), g ? q.forEach((c, E) => {
365
381
  var H;
366
- (H = U[E].parentElement) == null || H.insertBefore(
382
+ (H = $[E].parentElement) == null || H.insertBefore(
367
383
  c,
368
- U[E]
384
+ $[E]
369
385
  );
370
- }) : r.prepend(...R), zt(() => {
371
- R.forEach((c) => {
386
+ }) : r.prepend(...q), It(() => {
387
+ q.forEach((c) => {
372
388
  var E;
373
389
  c instanceof HTMLElement && ((E = c.parentElement) == null || E.style.setProperty(
374
390
  "--new-content-height",
@@ -376,42 +392,42 @@ const X = class X {
376
392
  ), c.classList.add("in"));
377
393
  });
378
394
  });
379
- const st = {
395
+ const it = {
380
396
  morphElement: r,
381
- pathname: m
397
+ pathname: f
382
398
  };
383
- $(document, "morphNewChildrenAdded", {
384
- detail: st
399
+ j(document, "morphNewChildrenAdded", {
400
+ detail: it
385
401
  });
386
- const qt = new Promise((c) => {
402
+ const zt = new Promise((c) => {
387
403
  setTimeout(() => {
388
- U.forEach((E) => E.remove()), R.forEach((E) => {
404
+ $.forEach((E) => E.remove()), q.forEach((E) => {
389
405
  var H;
390
406
  E instanceof HTMLElement && ((H = E.parentElement) == null || H.style.removeProperty(
391
407
  "--new-content-height"
392
408
  ), E.classList.remove("in", "new"));
393
- }), $(document, "morphOldChildrenRemoved", {
394
- detail: st
409
+ }), j(document, "morphOldChildrenRemoved", {
410
+ detail: it
395
411
  }), c();
396
- }, (parseFloat(Q) || 0) * 1e3 + 10);
412
+ }, (parseFloat(X) || 0) * 1e3 + 10);
397
413
  });
398
- e(this, O).push(qt);
399
- }), V ? (b.clearScrollState(), d(this, h, ft).call(this, V, { centerScroll: i, offsetScroll: u })) : e(this, M) ? b.restoreScrollPosition() : b.renewScrollPosition(), yield Promise.all(e(this, O)), wt.forEach((r) => r.remove()), o(this, O, []), e(this, Y).forEach((r) => {
414
+ e(this, B).push(zt);
415
+ }), W ? (b.clearScrollState(), m(this, h, Et).call(this, W, { centerScroll: i, offsetScroll: d })) : e(this, M) ? b.restoreScrollPosition() : b.renewScrollPosition(), yield Promise.all(e(this, B)), Lt.forEach((r) => r.remove()), o(this, B, []), e(this, J).forEach((r) => {
400
416
  r.querySelectorAll("script").forEach((y) => {
401
- const Q = document.createElement("script");
402
- Q.type = "module", Q.src = y.getAttribute("src"), y.replaceWith(Q);
417
+ const X = document.createElement("script");
418
+ X.type = "module", X.src = y.getAttribute("src"), y.replaceWith(X);
403
419
  });
404
- }), $(document, "morphComplete", {
405
- detail: at
420
+ }), j(document, "morphComplete", {
421
+ detail: ot
406
422
  }), window.dispatchEvent(new Event("resize"));
407
- } catch (W) {
408
- console.error(W);
423
+ } catch (U) {
424
+ console.error(U);
409
425
  }
410
426
  o(this, D, void 0);
411
427
  });
412
428
  }
413
429
  addLink(t) {
414
- e(this, f).push(new ht(t, this));
430
+ e(this, p).push(new ut(t, this));
415
431
  }
416
432
  addLinks(t) {
417
433
  t.forEach((s) => {
@@ -419,71 +435,71 @@ const X = class X {
419
435
  });
420
436
  }
421
437
  removeLink(t) {
422
- o(this, f, e(this, f).filter((s) => s.element === t ? (s.destroy(), !1) : !0));
438
+ o(this, p, e(this, p).filter((s) => s.element === t ? (s.destroy(), !1) : !0));
423
439
  }
424
440
  destroyOldLinks(t) {
425
- o(this, f, e(this, f).filter((s) => t.contains(s.element) ? (s.destroy(), !1) : !0));
441
+ o(this, p, e(this, p).filter((s) => t.contains(s.element) ? (s.destroy(), !1) : !0));
426
442
  }
427
443
  findNewLinks(t) {
428
444
  const s = [...t.querySelectorAll("a")].filter(
429
- e(this, tt)
445
+ e(this, et)
430
446
  );
431
- e(this, f).push(
432
- ...s.map((i) => new ht(i, this))
447
+ e(this, p).push(
448
+ ...s.map((i) => new ut(i, this))
433
449
  );
434
450
  }
435
451
  findLinks() {
436
452
  const t = [
437
453
  ...document.documentElement.querySelectorAll("a")
438
- ].filter(e(this, tt));
439
- e(this, f).forEach((s) => s.destroy()), o(this, f, t.map((s) => new ht(s, this)));
454
+ ].filter(e(this, et));
455
+ e(this, p).forEach((s) => s.destroy()), o(this, p, t.map((s) => new ut(s, this)));
440
456
  }
441
457
  };
442
- T = new WeakMap(), Y = new WeakMap(), f = new WeakMap(), rt = new WeakMap(), D = new WeakMap(), p = new WeakMap(), _ = new WeakMap(), O = new WeakMap(), M = new WeakMap(), P = new WeakMap(), G = new WeakMap(), B = new WeakMap(), tt = new WeakMap(), h = new WeakSet(), it = function(t, s) {
443
- return q(this, null, function* () {
444
- let i = e(this, G).get(t);
445
- return (!i || s != null && s.revalidate) && (i = yield d(this, h, Ht).call(this, t, s == null ? void 0 : s.searchParameters)), i;
458
+ T = new WeakMap(), J = new WeakMap(), p = new WeakMap(), nt = new WeakMap(), D = new WeakMap(), u = new WeakMap(), tt = new WeakMap(), B = new WeakMap(), M = new WeakMap(), P = new WeakMap(), R = new WeakMap(), V = new WeakMap(), et = new WeakMap(), h = new WeakSet(), rt = function(t, s) {
459
+ return z(this, null, function* () {
460
+ let i = e(this, R).get(t);
461
+ return (!i || s != null && s.revalidate) && (i = yield m(this, h, Nt).call(this, t, s == null ? void 0 : s.searchParameters)), i;
446
462
  });
447
- }, Ht = function(t, s) {
448
- return q(this, null, function* () {
449
- const u = yield (yield fetch(
463
+ }, Nt = function(t, s) {
464
+ return z(this, null, function* () {
465
+ const d = yield (yield fetch(
450
466
  `${t}${s ? "?" + s : ""}`
451
- )).text(), v = e(this, rt).parseFromString(u, "text/html"), L = new kt(this, t, v);
452
- return e(this, G).set(t, L), L;
467
+ )).text(), S = e(this, nt).parseFromString(d, "text/html"), L = new Ct(this, t, S);
468
+ return e(this, R).set(t, L), L;
453
469
  });
454
- }, ct = function(t) {
470
+ }, dt = function(t) {
455
471
  const s = [...t.querySelectorAll("[data-morph]")];
456
472
  return s.length ? s : [t];
457
- }, Nt = function(t, s) {
473
+ }, xt = function(t, s) {
458
474
  return t.filter(
459
475
  (i) => s.find(
460
- (u) => u.outerHTML === i.outerHTML
476
+ (d) => d.outerHTML === i.outerHTML
461
477
  )
462
478
  );
463
- }, ut = function(t, s) {
479
+ }, mt = function(t, s) {
464
480
  return t.filter(
465
481
  (i) => !s.find(
466
- (u) => u.outerHTML === i.outerHTML
482
+ (d) => d.outerHTML === i.outerHTML
467
483
  )
468
484
  );
469
- }, dt = function(t) {
485
+ }, ft = function(t) {
470
486
  return t.tagName === "SCRIPT" || t.tagName === "STYLE" || t.tagName === "LINK" && t.getAttribute("rel") === "stylesheet";
471
- }, mt = function(t) {
487
+ }, pt = function(t) {
472
488
  var s, i;
473
489
  (s = e(this, P)) == null || s.removeEventListener(
474
490
  "scroll",
475
- e(this, J)
476
- ), o(this, P, t.querySelector(e(this, T).scrollSelector) || t.documentElement), (i = e(this, P)) == null || i.addEventListener("scroll", e(this, J)), e(this, J).call(this);
477
- }, ft = function(t, s) {
491
+ e(this, Q)
492
+ ), o(this, P, t.querySelector(e(this, T).scrollSelector) || t.documentElement), (i = e(this, P)) == null || i.addEventListener("scroll", e(this, Q)), e(this, Q).call(this);
493
+ }, Et = function(t, s) {
478
494
  const i = typeof t == "string" ? document.getElementById(t) : t;
479
- (typeof i == "number" || i) && Ft(i, {
495
+ (typeof i == "number" || i) && Ot(i, {
480
496
  scrollElement: e(this, P),
481
497
  behavior: (s == null ? void 0 : s.behavior) || "instant",
482
498
  center: s == null ? void 0 : s.centerScroll,
483
499
  offset: s == null ? void 0 : s.offsetScroll
484
500
  });
485
- }, nt = new WeakMap(), J = new WeakMap(), X.instance = null;
486
- let Ct = X;
501
+ }, at = new WeakMap(), Q = new WeakMap(), Z.instance = null;
502
+ let Tt = Z;
487
503
  export {
488
- Ct as Morph
504
+ Tt as Morph
489
505
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aptechka",
3
- "version": "0.62.4",
3
+ "version": "0.63.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/denisavitski/aptechka.git"