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