aptechka 0.70.17 → 0.70.19

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