swup 4.0.0-rc.27 → 4.0.0-rc.28

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.
package/dist/Swup.cjs CHANGED
@@ -1,2 +1,2 @@
1
- var t=require("delegate-it"),e=require("path-to-regexp");function n(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var r=/*#__PURE__*/n(t);const o=(t,e)=>String(t).toLowerCase().replace(/[\s/_.]+/g,"-").replace(/[^\w-]+/g,"").replace(/--+/g,"-").replace(/^-+|-+$/g,"")||e||"",i=function(t){let{hash:e}=void 0===t?{}:t;return location.pathname+location.search+(e?location.hash:"")},s=function(t,e){void 0===e&&(e={});const n={url:t=t||i({hash:!0}),random:Math.random(),source:"swup",...e};history.pushState(n,"",t)},a=function(t,e){void 0===t&&(t=null),void 0===e&&(e={}),t=t||i({hash:!0});const n={...history.state,url:t,random:Math.random(),source:"swup",...e};history.replaceState(n,"",t)},l=(t,e,n,o)=>{const i=new AbortController;return o={...o,signal:i.signal},r.default(t,e,n,o),{destroy:()=>i.abort()}};class c extends URL{constructor(t,e){void 0===e&&(e=document.baseURI),super(t.toString(),e)}get url(){return this.pathname+this.search}static fromElement(t){const e=t.getAttribute("href")||t.getAttribute("xlink:href")||"";return new c(e)}static fromUrl(t){return new c(t)}}class u{constructor(t){this.swup=void 0,this.pages=new Map,this.swup=t}get size(){return this.pages.size}get all(){return this.pages}has(t){return this.pages.has(this.resolve(t))}get(t){return this.pages.get(this.resolve(t))}set(t,e){t=this.resolve(t),e={...e,url:t},this.pages.set(t,e),this.swup.hooks.callSync("cache:set",{page:e})}update(t,e){t=this.resolve(t),e={...this.get(t),...e,url:t},this.pages.set(t,e)}delete(t){this.pages.delete(this.resolve(t))}clear(){this.pages.clear(),this.swup.hooks.callSync("cache:clear")}prune(t){this.pages.forEach((e,n)=>{t(n,e)&&this.delete(n)})}resolve(t){const{url:e}=c.fromUrl(t);return this.swup.resolveUrl(e)}}const h=function(t,e){return void 0===e&&(e=document),e.querySelector(t)},m=function(t,e){return void 0===e&&(e=document),Array.from(e.querySelectorAll(t))},d=()=>new Promise(t=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{t()})})});function p(t){return!!t&&("object"==typeof t||"function"==typeof t)&&"function"==typeof t.then}function f(t,e){return void 0===e&&(e=[]),new Promise((n,r)=>{const o=t(...e);p(o)?o.then(n,r):n(o)})}const v=t=>window.CSS&&window.CSS.escape?CSS.escape(t):t,g=t=>1e3*Number(t.slice(0,-1).replace(",","."));class w{constructor(t){this.swup=void 0,this.swupClasses=["to-","is-changing","is-rendering","is-popstate","is-animating"],this.swup=t}get selectors(){const{scope:t}=this.swup.visit.animation;return"containers"===t?this.swup.visit.containers:"html"===t?["html"]:Array.isArray(t)?t:[]}get selector(){return this.selectors.join(",")}get targets(){return this.selector.trim()?m(this.selector):[]}add(){this.targets.forEach(t=>t.classList.add(...[].slice.call(arguments)))}remove(){this.targets.forEach(t=>t.classList.remove(...[].slice.call(arguments)))}clear(){this.targets.forEach(t=>{const e=t.className.split(" ").filter(t=>this.isSwupClass(t));t.classList.remove(...e)})}isSwupClass(t){return this.swupClasses.some(e=>t.startsWith(e))}}function y(t){let{to:e,from:n=this.currentPageUrl,hash:r,animate:o=!0,animation:i,el:s,event:a,action:l="push",resetScroll:c=!0}=t;return{from:{url:n},to:{url:e},containers:this.options.containers,animation:{animate:o,wait:!1,name:i,scope:this.options.animationScope,selector:this.options.animationSelector},trigger:{el:s,event:a},history:{action:l,popstate:!1,direction:void 0},scroll:{reset:c,target:r}}}const P="undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";function k(t,e,n){if(!t.s){if(n instanceof S){if(!n.s)return void(n.o=k.bind(null,t,e));1&e&&(e=n.s),n=n.v}if(n&&n.then)return void n.then(k.bind(null,t,e),k.bind(null,t,2));t.s=e,t.v=n;const r=t.o;r&&r(t)}}const S=/*#__PURE__*/function(){function t(){}return t.prototype.then=function(e,n){const r=new t,o=this.s;if(o){const t=1&o?e:n;if(t){try{k(r,1,t(this.v))}catch(t){k(r,2,t)}return r}return this}return this.o=function(t){try{const o=t.v;1&t.s?k(r,1,e?e(o):o):n?k(r,1,n(o)):k(r,2,o)}catch(t){k(r,2,t)}},r},t}();function b(t){return t instanceof S&&1&t.s}class U{constructor(t){this.swup=void 0,this.registry=new Map,this.hooks=["animation:out:start","animation:out:await","animation:out:end","animation:in:start","animation:in:await","animation:in:end","animation:skip","cache:clear","cache:set","content:replace","content:scroll","enable","disable","fetch:request","fetch:error","history:popstate","link:click","link:self","link:anchor","link:newtab","page:request","page:load","page:view","scroll:top","scroll:anchor","visit:start","visit:end"],this.swup=t,this.init()}init(){this.hooks.forEach(t=>this.create(t))}create(t){this.registry.has(t)||this.registry.set(t,new Map)}exists(t){return this.registry.has(t)}get(t){const e=this.registry.get(t);if(e)return e;console.error(`Unknown hook '${t}'`)}clear(){this.registry.forEach(t=>t.clear())}on(t,e,n){void 0===n&&(n={});const r=this.get(t);if(!r)return console.warn(`Hook '${t}' not found.`),()=>{};const o=r.size+1,i={...n,id:o,hook:t,handler:e};return r.set(e,i),()=>this.off(t,e)}before(t,e,n){return void 0===n&&(n={}),this.on(t,e,{...n,before:!0})}replace(t,e,n){return void 0===n&&(n={}),this.on(t,e,{...n,replace:!0})}once(t,e,n){return void 0===n&&(n={}),this.on(t,e,{...n,once:!0})}off(t,e){const n=this.get(t);n&&e?n.delete(e)||console.warn(`Handler for hook '${t}' not found.`):n&&n.clear()}call(t,e,n){try{const r=this,{before:o,handler:i,after:s}=r.getHandlers(t,n);return Promise.resolve(r.run(o,e)).then(function(){return Promise.resolve(r.run(i,e)).then(function(n){let[o]=n;return Promise.resolve(r.run(s,e)).then(function(){return r.dispatchDomEvent(t,e),o})})})}catch(t){return Promise.reject(t)}}callSync(t,e,n){const{before:r,handler:o,after:i}=this.getHandlers(t,n);this.runSync(r,e);const[s]=this.runSync(o,e);return this.runSync(i,e),this.dispatchDomEvent(t,e),s}run(t,e){try{const n=this,r=[],o=function(t,e,n){if("function"==typeof t[P]){var r,o,i,s=t[P]();if(function t(n){try{for(;!(r=s.next()).done;)if((n=e(r.value))&&n.then){if(!b(n))return void n.then(t,i||(i=k.bind(null,o=new S,2)));n=n.v}o?k(o,1,n):o=n}catch(t){k(o||(o=new S),2,t)}}(),s.return){var a=function(t){try{r.done||s.return()}catch(t){}return t};if(o&&o.then)return o.then(a,function(t){throw a(t)});a()}return o}if(!("length"in t))throw new TypeError("Object is not iterable");for(var l=[],c=0;c<t.length;c++)l.push(t[c]);return function(t,e,n){var r,o,i=-1;return function n(s){try{for(;++i<t.length;)if((s=e(i))&&s.then){if(!b(s))return void s.then(n,o||(o=k.bind(null,r=new S,2)));s=s.v}r?k(r,1,s):r=s}catch(t){k(r||(r=new S),2,t)}}(),r}(l,function(t){return e(l[t])})}(t,function(t){let{hook:o,handler:i,defaultHandler:s,once:a}=t;return Promise.resolve(f(i,[n.swup.visit,e,s])).then(function(t){r.push(t),a&&n.off(o,i)})});return Promise.resolve(o&&o.then?o.then(function(){return r}):r)}catch(t){return Promise.reject(t)}}runSync(t,e){const n=[];for(const{hook:r,handler:o,defaultHandler:i,once:s}of t){const t=o(this.swup.visit,e,i);n.push(t),p(t)&&console.warn(`Promise returned from handler for synchronous hook '${r}'.Swup will not wait for it to resolve.`),s&&this.off(r,o)}return n}getHandlers(t,e){const n=this.get(t);if(!n)return{found:!1,before:[],handler:[],after:[],replaced:!1};const r=this.sortRegistrations,o=Array.from(n.values()),i=o.filter(t=>{let{before:e,replace:n}=t;return e&&!n}).sort(r),s=o.filter(t=>{let{replace:e}=t;return e}).sort(r),a=o.filter(t=>{let{before:e,replace:n}=t;return!e&&!n}).sort(r),l=s.length>0;let c=[];if(e&&(c=[{id:0,hook:t,handler:e}],l)){const n=s.length-1,r=t=>{const n=s[t-1];return n?(e,o)=>n.handler(e,o,r(t-1)):e};c=[{id:0,hook:t,handler:s[n].handler,defaultHandler:r(n)}]}return{found:!0,before:i,handler:c,after:a,replaced:l}}sortRegistrations(t,e){return(t.priority??0)-(e.priority??0)||t.id-e.id||0}dispatchDomEvent(t,e){document.dispatchEvent(new CustomEvent(`swup:${t}`,{detail:{hook:t,args:e,visit:this.swup.visit}}))}}const x=t=>{if(t&&"#"===t.charAt(0)&&(t=t.substring(1)),!t)return null;const e=decodeURIComponent(t);let n=document.getElementById(t)||document.getElementById(e)||h(`a[name='${v(t)}']`)||h(`a[name='${v(e)}']`);return n||"top"!==t||(n=document.body),n},E=function(t){let{elements:e,selector:n}=t;try{if(!1===n&&!e)return Promise.resolve();let t=[];if(e)t=Array.from(e);else if(n&&(t=m(n,document.body),!t.length))return console.warn(`[swup] No elements found matching animationSelector \`${n}\``),Promise.resolve();const r=t.map(t=>function(t){const{type:e,timeout:n,propCount:r}=function(t,e){const n=window.getComputedStyle(t),r=$(n,`${H}Delay`),o=$(n,`${H}Duration`),i=q(r,o),s=$(n,`${C}Delay`),a=$(n,`${C}Duration`),l=q(s,a);let c=null,u=0,h=0;return e===H?i>0&&(c=H,u=i,h=o.length):e===C?l>0&&(c=C,u=l,h=a.length):(u=Math.max(i,l),c=u>0?i>l?H:C:null,h=c?c===H?o.length:a.length:0),{type:c,timeout:u,propCount:h}}(t);return!(!e||!n)&&new Promise(o=>{const i=`${e}end`,s=performance.now();let a=0;const l=()=>{t.removeEventListener(i,c),o()},c=e=>{if(e.target===t){if(!function(t){return[`${H}end`,`${C}end`].includes(t.type)}(e))throw new Error("Not a transition or animation event.");(performance.now()-s)/1e3<e.elapsedTime||++a>=r&&l()}};setTimeout(()=>{a<r&&l()},n+1),t.addEventListener(i,c)})}(t));return r.filter(Boolean).length>0?Promise.resolve(Promise.all(r)).then(function(){}):(n&&console.warn(`[swup] No CSS animation duration defined on elements matching \`${n}\``),Promise.resolve())}catch(t){return Promise.reject(t)}},H="transition",C="animation";function $(t,e){return(t[e]||"").split(", ")}function q(t,e){for(;t.length<e.length;)t=t.concat(t);return Math.max(...e.map((e,n)=>g(e)+g(t[n])))}const A=function(t,e){void 0===e&&(e={});try{const n=this;if("string"!=typeof t)throw new Error("swup.navigate() requires a URL parameter");const{el:r}=n.visit.trigger;n.visit.to.url=c.fromUrl(t).url,e.referrer=e.referrer||n.currentPageUrl,!1===e.animate&&(n.visit.animation.animate=!1),n.visit.animation.animate||n.classes.clear();const o=e.history||(null==r?void 0:r.getAttribute("data-swup-history"))||void 0;o&&["push","replace"].includes(o)&&(n.visit.history.action=o);const l=e.animation||(null==r?void 0:r.getAttribute("data-swup-animation"))||void 0;return l&&(n.visit.animation.name=l),Promise.resolve(function(r,o){try{var l=Promise.resolve(n.hooks.call("visit:start")).then(function(){function r(){const t=n.animatePageOut();return Promise.resolve(Promise.all([o,t])).then(function(t){let[e]=t;return Promise.resolve(n.renderPage(n.visit.to.url,e)).then(function(){return Promise.resolve(n.animatePageIn()).then(function(){return Promise.resolve(n.hooks.call("visit:end",void 0,()=>n.classes.clear())).then(function(){})})})})}const o=n.hooks.call("page:request",{url:n.visit.to.url,options:e},function(t,e){let{options:r}=e;try{return Promise.resolve(n.fetchPage(t.to.url,r))}catch(t){return Promise.reject(t)}});if(!n.visit.history.popstate){const e=t+(n.visit.scroll.target||"");"replace"===n.visit.history.action?a(e):s(e,{index:n.currentHistoryIndex+1})}n.currentPageUrl=i();const l=function(){if(n.visit.animation.wait)return Promise.resolve(o).then(function(t){let{html:e}=t;n.visit.to.html=e})}();return l&&l.then?l.then(r):r()})}catch(t){return o(t)}return l&&l.then?l.then(void 0,o):l}(0,function(t){t&&(console.error(t),n.options.skipPopStateHandling=()=>(window.location.href=n.visit.to.url,!0),window.history.go(-1))}))}catch(t){return Promise.reject(t)}};function R(t,e,n){if(void 0===e&&(e={}),void 0===n&&(n={}),this.shouldIgnoreVisit(t))return void(window.location.href=t);const{url:r,hash:o}=c.fromUrl(t);this.visit=this.createVisit({...n,to:r,hash:o}),this.performNavigation(r,e)}const j=function(t,e){void 0===e&&(e={});try{let r;const o=this;function n(n){if(r)return n;const i={...o.options.requestHeaders,...e.headers};return e={...e,headers:i},Promise.resolve(o.hooks.call("fetch:request",{url:t,options:e},(t,e)=>{let{url:n,options:r}=e;return fetch(n,r)})).then(function(n){const{status:r,url:i}=n;return Promise.resolve(n.text()).then(function(s){if(500===r)throw o.hooks.call("fetch:error",{status:r,response:n,url:i}),new I(`Server error: ${i}`,{status:r,url:i});if(!s)throw new I(`Empty response: ${i}`,{status:r,url:i});const{url:a}=c.fromUrl(i),l={url:a,html:s};t===a&&o.cache.set(l.url,l);const u=function(){if(!1!==e.triggerHooks)return Promise.resolve(o.hooks.call("page:load",{page:l,cache:!1})).then(function(){})}();return u&&u.then?u.then(function(){return l}):l})})}t=c.fromUrl(t).url;const i=function(){if(o.cache.has(t)){function n(){return r=1,i}const i=o.cache.get(t),s=function(){if(!1!==e.triggerHooks)return Promise.resolve(o.hooks.call("page:load",{page:i,cache:!0})).then(function(){})}();return s&&s.then?s.then(n):n()}}();return Promise.resolve(i&&i.then?i.then(n):n(i))}catch(s){return Promise.reject(s)}};class I extends Error{constructor(t,e){super(t),this.url=void 0,this.status=void 0,this.name="FetchError",this.url=e.url,this.status=e.status}}const N=function(){try{let e;const n=this;function t(t){return e?t:Promise.resolve(n.hooks.call("animation:out:start",void 0,t=>{n.classes.add("is-changing","is-leaving","is-animating"),t.history.popstate&&n.classes.add("is-popstate"),t.animation.name&&n.classes.add(`to-${o(t.animation.name)}`)})).then(function(){return Promise.resolve(n.hooks.call("animation:out:await",{skip:!1},function(t,e){let{skip:r}=e;try{return r?Promise.resolve():Promise.resolve(n.awaitAnimations({selector:t.animation.selector})).then(function(){})}catch(t){return Promise.reject(t)}})).then(function(){return Promise.resolve(n.hooks.call("animation:out:end")).then(function(){})})})}const r=function(){if(!n.visit.animation.animate)return Promise.resolve(n.hooks.call("animation:skip")).then(function(){e=1})}();return Promise.resolve(r&&r.then?r.then(t):t(r))}catch(i){return Promise.reject(i)}},L=function(t,e){var n;let{html:r}=t,{containers:o}=void 0===e?this.options:e;const i=(new DOMParser).parseFromString(r,"text/html"),s=(null==(n=i.querySelector("title"))?void 0:n.innerText)||"";return document.title=s,o.map(t=>{const e=document.querySelector(t),n=i.querySelector(t);return e&&n?(e.replaceWith(n),!0):(e||console.warn(`[swup] Container missing in current document: ${t}`),n||console.warn(`[swup] Container missing in incoming document: ${t}`),!1)}).filter(Boolean).length===o.length},D=function(){const t={behavior:"auto"},{target:e,reset:n}=this.visit.scroll;let r=!1;return e&&(r=this.hooks.callSync("scroll:anchor",{hash:e,options:t},(t,e)=>{let{hash:n,options:r}=e;const o=this.getAnchorElement(n||"");return o&&o.scrollIntoView(r),!!o})),n&&!r&&(r=this.hooks.callSync("scroll:top",{options:t},(t,e)=>{let{options:n}=e;return window.scrollTo({top:0,left:0,...n}),!0})),r},V=function(){try{const t=this;if(!t.visit.animation.animate)return Promise.resolve();const e=t.hooks.call("animation:in:await",{skip:!1},function(e,n){let{skip:r}=n;try{return r?Promise.resolve():Promise.resolve(t.awaitAnimations({selector:e.animation.selector})).then(function(){})}catch(t){return Promise.reject(t)}});return Promise.resolve(d()).then(function(){return Promise.resolve(t.hooks.call("animation:in:start",void 0,()=>{t.classes.remove("is-animating")})).then(function(){return Promise.resolve(e).then(function(){return Promise.resolve(t.hooks.call("animation:in:end")).then(function(){})})})})}catch(t){return Promise.reject(t)}},M=function(t,e){try{const n=this,{url:r,html:s}=e;return n.classes.remove("is-leaving"),n.isSameResolvedUrl(i(),t)?(n.isSameResolvedUrl(i(),r)||(a(r),n.currentPageUrl=i(),n.visit.to.url=n.currentPageUrl),n.visit.animation.animate&&n.classes.add("is-rendering"),n.visit.to.html=s,Promise.resolve(n.hooks.call("content:replace",{page:e},(t,e)=>{let{page:r}=e;if(!n.replaceContent(r,{containers:t.containers}))throw new Error("[swup] Container mismatch, aborting");t.animation.animate&&(n.classes.add("is-animating","is-changing","is-rendering"),t.animation.name&&n.classes.add(`to-${o(t.animation.name)}`))})).then(function(){return Promise.resolve(n.hooks.call("content:scroll",void 0,()=>n.scrollToContent())).then(function(){return Promise.resolve(n.hooks.call("page:view",{url:n.currentPageUrl,title:document.title})).then(function(){n.options.cache||n.cache.clear()})})})):Promise.resolve()}catch(t){return Promise.reject(t)}},T=function(t){var e;if(null==(e=t)?void 0:e.isSwupPlugin){if(t.swup=this,!t._checkRequirements||t._checkRequirements())return t._beforeMount&&t._beforeMount(),t.mount(),this.plugins.push(t),this.plugins}else console.error("Not a swup plugin instance",t)};function W(t){const e=this.findPlugin(t);if(e)return e.unmount(),e._afterUnmount&&e._afterUnmount(),this.plugins=this.plugins.filter(t=>t!==e),this.plugins;console.error("No such plugin",e)}function _(t){return this.plugins.find(e=>e===t||e.name===t||e.name===`Swup${t}`)}exports.Location=c,exports.classify=o,exports.createHistoryRecord=s,exports.default=class{constructor(t){void 0===t&&(t={}),this.version="4.0.0-rc.27",this.options=void 0,this.plugins=[],this.visit=void 0,this.cache=void 0,this.hooks=void 0,this.classes=void 0,this.currentPageUrl=i(),this.currentHistoryIndex=1,this.clickDelegate=void 0,this.navigate=R,this.performNavigation=A,this.animatePageOut=N,this.renderPage=M,this.replaceContent=L,this.scrollToContent=D,this.animatePageIn=V,this.delegateEvent=l,this.fetchPage=j,this.awaitAnimations=E,this.getAnchorElement=x,this.use=T,this.unuse=W,this.findPlugin=_,this.getCurrentUrl=i,this.createVisit=y,this.log=()=>{},this.defaults={animateHistoryBrowsing:!1,animationSelector:'[class*="transition-"]',animationScope:"html",cache:!0,containers:["#swup"],ignoreVisit:function(t,e){let{el:n}=void 0===e?{}:e;return!(null==n||!n.closest("[data-no-swup]"))},linkSelector:"a[href]",plugins:[],resolveUrl:t=>t,requestHeaders:{"X-Requested-With":"swup",Accept:"text/html, application/xhtml+xml"},skipPopStateHandling:t=>{var e;return"swup"!==(null==(e=t.state)?void 0:e.source)}},this.options={...this.defaults,...t},this.linkClickHandler=this.linkClickHandler.bind(this),this.popStateHandler=this.popStateHandler.bind(this),this.cache=new u(this),this.classes=new w(this),this.hooks=new U(this),this.visit=this.createVisit({to:void 0}),this.checkRequirements()&&this.enable()}checkRequirements(){return"undefined"!=typeof Promise||(console.warn("Promise is not supported"),!1)}enable(){try{const t=this,{linkSelector:e}=t.options;return t.clickDelegate=t.delegateEvent(e,"click",t.linkClickHandler),window.addEventListener("popstate",t.popStateHandler),t.options.plugins.forEach(e=>t.use(e)),a(null,{index:1}),Promise.resolve(d()).then(function(){return Promise.resolve(t.hooks.call("enable",void 0,()=>{document.documentElement.classList.add("swup-enabled")})).then(function(){})})}catch(t){return Promise.reject(t)}}destroy(){try{const t=this;return t.clickDelegate.destroy(),window.removeEventListener("popstate",t.popStateHandler),t.cache.clear(),t.options.plugins.forEach(e=>t.unuse(e)),Promise.resolve(t.hooks.call("disable",void 0,()=>{document.documentElement.classList.remove("swup-enabled")})).then(function(){t.hooks.clear()})}catch(t){return Promise.reject(t)}}shouldIgnoreVisit(t,e){let{el:n,event:r}=void 0===e?{}:e;const{origin:o,url:i,hash:s}=c.fromUrl(t);return o!==window.location.origin||!(!n||!this.triggerWillOpenNewWindow(n))||!!this.options.ignoreVisit(i+s,{el:n,event:r})}linkClickHandler(t){const e=t.delegateTarget,{href:n,url:r,hash:o}=c.fromElement(e);this.shouldIgnoreVisit(n,{el:e,event:t})||(this.visit=this.createVisit({to:r,hash:o,el:e,event:t}),t.metaKey||t.ctrlKey||t.shiftKey||t.altKey?this.hooks.call("link:newtab",{href:n}):0===t.button&&this.hooks.callSync("link:click",{el:e,event:t},()=>{const e=this.visit.from.url??"";t.preventDefault(),r&&r!==e?this.isSameResolvedUrl(r,e)||this.performNavigation(r):o?this.hooks.callSync("link:anchor",{hash:o},()=>{a(r+o),this.scrollToContent()}):this.hooks.callSync("link:self",void 0,()=>{this.scrollToContent()})}))}triggerWillOpenNewWindow(t){return!!t.matches('[download], [target="_blank"]')}popStateHandler(t){var e,n;const r=(null==(e=t.state)?void 0:e.url)??location.href;if(this.options.skipPopStateHandling(t))return;if(this.isSameResolvedUrl(i(),this.currentPageUrl))return;if(this.shouldIgnoreVisit(r,{event:t}))return;const{url:o,hash:s}=c.fromUrl(r);this.visit=this.createVisit({to:o,hash:s,event:t,animate:this.options.animateHistoryBrowsing,resetScroll:this.options.animateHistoryBrowsing}),this.visit.history.popstate=!0;const a=Number(null==(n=t.state)?void 0:n.index);a&&(this.visit.history.direction=a-this.currentHistoryIndex>0?"forwards":"backwards"),this.hooks.callSync("history:popstate",{event:t},()=>{this.performNavigation(o)})}resolveUrl(t){if("function"!=typeof this.options.resolveUrl)return console.warn("[swup] options.resolveUrl expects a callback function."),t;const e=this.options.resolveUrl(t);return e&&"string"==typeof e?e.startsWith("//")||e.startsWith("http")?(console.warn("[swup] options.resolveUrl needs to return a relative url"),t):e:(console.warn("[swup] options.resolveUrl needs to return a url"),t)}isSameResolvedUrl(t,e){return this.resolveUrl(t)===this.resolveUrl(e)}},exports.delegateEvent=l,exports.escapeCssIdentifier=v,exports.forceReflow=function(t){var e;return null==(e=t=t||document.body)?void 0:e.offsetHeight},exports.getCurrentUrl=i,exports.isPromise=p,exports.matchPath=(t,n)=>{try{return e.match(t,n)}catch(e){throw new Error(`[swup] Error parsing path "${t}":\n${e}`)}},exports.nextTick=d,exports.query=h,exports.queryAll=m,exports.runAsPromise=f,exports.toMs=g,exports.updateHistoryRecord=a;
1
+ var t=require("delegate-it"),e=require("path-to-regexp");function n(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var r=/*#__PURE__*/n(t);const o=(t,e)=>String(t).toLowerCase().replace(/[\s/_.]+/g,"-").replace(/[^\w-]+/g,"").replace(/--+/g,"-").replace(/^-+|-+$/g,"")||e||"",i=function(t){let{hash:e}=void 0===t?{}:t;return location.pathname+location.search+(e?location.hash:"")},s=function(t,e){void 0===e&&(e={});const n={url:t=t||i({hash:!0}),random:Math.random(),source:"swup",...e};history.pushState(n,"",t)},a=function(t,e){void 0===t&&(t=null),void 0===e&&(e={}),t=t||i({hash:!0});const n={...history.state,url:t,random:Math.random(),source:"swup",...e};history.replaceState(n,"",t)},l=(t,e,n,o)=>{const i=new AbortController;return o={...o,signal:i.signal},r.default(t,e,n,o),{destroy:()=>i.abort()}};class c extends URL{constructor(t,e){void 0===e&&(e=document.baseURI),super(t.toString(),e)}get url(){return this.pathname+this.search}static fromElement(t){const e=t.getAttribute("href")||t.getAttribute("xlink:href")||"";return new c(e)}static fromUrl(t){return new c(t)}}class u{constructor(t){this.swup=void 0,this.pages=new Map,this.swup=t}get size(){return this.pages.size}get all(){return this.pages}has(t){return this.pages.has(this.resolve(t))}get(t){return this.pages.get(this.resolve(t))}set(t,e){t=this.resolve(t),e={...e,url:t},this.pages.set(t,e),this.swup.hooks.callSync("cache:set",{page:e})}update(t,e){t=this.resolve(t),e={...this.get(t),...e,url:t},this.pages.set(t,e)}delete(t){this.pages.delete(this.resolve(t))}clear(){this.pages.clear(),this.swup.hooks.callSync("cache:clear")}prune(t){this.pages.forEach((e,n)=>{t(n,e)&&this.delete(n)})}resolve(t){const{url:e}=c.fromUrl(t);return this.swup.resolveUrl(e)}}const h=function(t,e){return void 0===e&&(e=document),e.querySelector(t)},m=function(t,e){return void 0===e&&(e=document),Array.from(e.querySelectorAll(t))},p=()=>new Promise(t=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{t()})})});function d(t){return!!t&&("object"==typeof t||"function"==typeof t)&&"function"==typeof t.then}function f(t,e){return void 0===e&&(e=[]),new Promise((n,r)=>{const o=t(...e);d(o)?o.then(n,r):n(o)})}const v=t=>window.CSS&&window.CSS.escape?CSS.escape(t):t,g=t=>1e3*Number(t.slice(0,-1).replace(",","."));class w{constructor(t){this.swup=void 0,this.swupClasses=["to-","is-changing","is-rendering","is-popstate","is-animating"],this.swup=t}get selectors(){const{scope:t}=this.swup.visit.animation;return"containers"===t?this.swup.visit.containers:"html"===t?["html"]:Array.isArray(t)?t:[]}get selector(){return this.selectors.join(",")}get targets(){return this.selector.trim()?m(this.selector):[]}add(){this.targets.forEach(t=>t.classList.add(...[].slice.call(arguments)))}remove(){this.targets.forEach(t=>t.classList.remove(...[].slice.call(arguments)))}clear(){this.targets.forEach(t=>{const e=t.className.split(" ").filter(t=>this.isSwupClass(t));t.classList.remove(...e)})}isSwupClass(t){return this.swupClasses.some(e=>t.startsWith(e))}}function y(t){let{to:e,from:n=this.currentPageUrl,hash:r,animate:o=!0,animation:i,el:s,event:a,action:l="push",resetScroll:c=!0}=t;return{from:{url:n},to:{url:e},containers:this.options.containers,animation:{animate:o,wait:!1,name:i,scope:this.options.animationScope,selector:this.options.animationSelector},trigger:{el:s,event:a},history:{action:l,popstate:!1,direction:void 0},scroll:{reset:c,target:r}}}const P="undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";function k(t,e,n){if(!t.s){if(n instanceof S){if(!n.s)return void(n.o=k.bind(null,t,e));1&e&&(e=n.s),n=n.v}if(n&&n.then)return void n.then(k.bind(null,t,e),k.bind(null,t,2));t.s=e,t.v=n;const r=t.o;r&&r(t)}}const S=/*#__PURE__*/function(){function t(){}return t.prototype.then=function(e,n){const r=new t,o=this.s;if(o){const t=1&o?e:n;if(t){try{k(r,1,t(this.v))}catch(t){k(r,2,t)}return r}return this}return this.o=function(t){try{const o=t.v;1&t.s?k(r,1,e?e(o):o):n?k(r,1,n(o)):k(r,2,o)}catch(t){k(r,2,t)}},r},t}();function b(t){return t instanceof S&&1&t.s}class U{constructor(t){this.swup=void 0,this.registry=new Map,this.hooks=["animation:out:start","animation:out:await","animation:out:end","animation:in:start","animation:in:await","animation:in:end","animation:skip","cache:clear","cache:set","content:replace","content:scroll","enable","disable","fetch:request","fetch:error","history:popstate","link:click","link:self","link:anchor","link:newtab","page:load","page:view","scroll:top","scroll:anchor","visit:start","visit:end"],this.swup=t,this.init()}init(){this.hooks.forEach(t=>this.create(t))}create(t){this.registry.has(t)||this.registry.set(t,new Map)}exists(t){return this.registry.has(t)}get(t){const e=this.registry.get(t);if(e)return e;console.error(`Unknown hook '${t}'`)}clear(){this.registry.forEach(t=>t.clear())}on(t,e,n){void 0===n&&(n={});const r=this.get(t);if(!r)return console.warn(`Hook '${t}' not found.`),()=>{};const o=r.size+1,i={...n,id:o,hook:t,handler:e};return r.set(e,i),()=>this.off(t,e)}before(t,e,n){return void 0===n&&(n={}),this.on(t,e,{...n,before:!0})}replace(t,e,n){return void 0===n&&(n={}),this.on(t,e,{...n,replace:!0})}once(t,e,n){return void 0===n&&(n={}),this.on(t,e,{...n,once:!0})}off(t,e){const n=this.get(t);n&&e?n.delete(e)||console.warn(`Handler for hook '${t}' not found.`):n&&n.clear()}call(t,e,n){try{const r=this,{before:o,handler:i,after:s}=r.getHandlers(t,n);return Promise.resolve(r.run(o,e)).then(function(){return Promise.resolve(r.run(i,e)).then(function(n){let[o]=n;return Promise.resolve(r.run(s,e)).then(function(){return r.dispatchDomEvent(t,e),o})})})}catch(t){return Promise.reject(t)}}callSync(t,e,n){const{before:r,handler:o,after:i}=this.getHandlers(t,n);this.runSync(r,e);const[s]=this.runSync(o,e);return this.runSync(i,e),this.dispatchDomEvent(t,e),s}run(t,e){try{const n=this,r=[],o=function(t,e,n){if("function"==typeof t[P]){var r,o,i,s=t[P]();if(function t(n){try{for(;!(r=s.next()).done;)if((n=e(r.value))&&n.then){if(!b(n))return void n.then(t,i||(i=k.bind(null,o=new S,2)));n=n.v}o?k(o,1,n):o=n}catch(t){k(o||(o=new S),2,t)}}(),s.return){var a=function(t){try{r.done||s.return()}catch(t){}return t};if(o&&o.then)return o.then(a,function(t){throw a(t)});a()}return o}if(!("length"in t))throw new TypeError("Object is not iterable");for(var l=[],c=0;c<t.length;c++)l.push(t[c]);return function(t,e,n){var r,o,i=-1;return function n(s){try{for(;++i<t.length;)if((s=e(i))&&s.then){if(!b(s))return void s.then(n,o||(o=k.bind(null,r=new S,2)));s=s.v}r?k(r,1,s):r=s}catch(t){k(r||(r=new S),2,t)}}(),r}(l,function(t){return e(l[t])})}(t,function(t){let{hook:o,handler:i,defaultHandler:s,once:a}=t;return Promise.resolve(f(i,[n.swup.visit,e,s])).then(function(t){r.push(t),a&&n.off(o,i)})});return Promise.resolve(o&&o.then?o.then(function(){return r}):r)}catch(t){return Promise.reject(t)}}runSync(t,e){const n=[];for(const{hook:r,handler:o,defaultHandler:i,once:s}of t){const t=o(this.swup.visit,e,i);n.push(t),d(t)&&console.warn(`Promise returned from handler for synchronous hook '${r}'.Swup will not wait for it to resolve.`),s&&this.off(r,o)}return n}getHandlers(t,e){const n=this.get(t);if(!n)return{found:!1,before:[],handler:[],after:[],replaced:!1};const r=this.sortRegistrations,o=Array.from(n.values()),i=o.filter(t=>{let{before:e,replace:n}=t;return e&&!n}).sort(r),s=o.filter(t=>{let{replace:e}=t;return e}).sort(r),a=o.filter(t=>{let{before:e,replace:n}=t;return!e&&!n}).sort(r),l=s.length>0;let c=[];if(e&&(c=[{id:0,hook:t,handler:e}],l)){const n=s.length-1,r=t=>{const n=s[t-1];return n?(e,o)=>n.handler(e,o,r(t-1)):e};c=[{id:0,hook:t,handler:s[n].handler,defaultHandler:r(n)}]}return{found:!0,before:i,handler:c,after:a,replaced:l}}sortRegistrations(t,e){return(t.priority??0)-(e.priority??0)||t.id-e.id||0}dispatchDomEvent(t,e){document.dispatchEvent(new CustomEvent(`swup:${t}`,{detail:{hook:t,args:e,visit:this.swup.visit}}))}}const x=t=>{if(t&&"#"===t.charAt(0)&&(t=t.substring(1)),!t)return null;const e=decodeURIComponent(t);let n=document.getElementById(t)||document.getElementById(e)||h(`a[name='${v(t)}']`)||h(`a[name='${v(e)}']`);return n||"top"!==t||(n=document.body),n},E=function(t){let{elements:e,selector:n}=t;try{if(!1===n&&!e)return Promise.resolve();let t=[];if(e)t=Array.from(e);else if(n&&(t=m(n,document.body),!t.length))return console.warn(`[swup] No elements found matching animationSelector \`${n}\``),Promise.resolve();const r=t.map(t=>function(t){const{type:e,timeout:n,propCount:r}=function(t,e){const n=window.getComputedStyle(t),r=A(n,`${C}Delay`),o=A(n,`${C}Duration`),i=H(r,o),s=A(n,`${$}Delay`),a=A(n,`${$}Duration`),l=H(s,a);let c=null,u=0,h=0;return e===C?i>0&&(c=C,u=i,h=o.length):e===$?l>0&&(c=$,u=l,h=a.length):(u=Math.max(i,l),c=u>0?i>l?C:$:null,h=c?c===C?o.length:a.length:0),{type:c,timeout:u,propCount:h}}(t);return!(!e||!n)&&new Promise(o=>{const i=`${e}end`,s=performance.now();let a=0;const l=()=>{t.removeEventListener(i,c),o()},c=e=>{if(e.target===t){if(!function(t){return[`${C}end`,`${$}end`].includes(t.type)}(e))throw new Error("Not a transition or animation event.");(performance.now()-s)/1e3<e.elapsedTime||++a>=r&&l()}};setTimeout(()=>{a<r&&l()},n+1),t.addEventListener(i,c)})}(t));return r.filter(Boolean).length>0?Promise.resolve(Promise.all(r)).then(function(){}):(n&&console.warn(`[swup] No CSS animation duration defined on elements matching \`${n}\``),Promise.resolve())}catch(t){return Promise.reject(t)}},C="transition",$="animation";function A(t,e){return(t[e]||"").split(", ")}function H(t,e){for(;t.length<e.length;)t=t.concat(t);return Math.max(...e.map((e,n)=>g(e)+g(t[n])))}const q=function(t,e){void 0===e&&(e={});try{const n=this;if("string"!=typeof t)throw new Error("swup.navigate() requires a URL parameter");const{el:r}=n.visit.trigger;n.visit.to.url=c.fromUrl(t).url,e.referrer=e.referrer||n.currentPageUrl,!1===e.animate&&(n.visit.animation.animate=!1),n.visit.animation.animate||n.classes.clear();const o=e.history||r?.getAttribute("data-swup-history")||void 0;o&&["push","replace"].includes(o)&&(n.visit.history.action=o);const l=e.animation||r?.getAttribute("data-swup-animation")||void 0;return l&&(n.visit.animation.name=l),Promise.resolve(function(r,o){try{var l=Promise.resolve(n.hooks.call("visit:start")).then(function(){function r(){const t=n.animatePageOut();return Promise.resolve(Promise.all([o,t])).then(function(t){let[e]=t;return Promise.resolve(n.renderPage(n.visit.to.url,e)).then(function(){return Promise.resolve(n.animatePageIn()).then(function(){return Promise.resolve(n.hooks.call("visit:end",void 0,()=>n.classes.clear())).then(function(){})})})})}const o=n.hooks.call("page:load",{options:e},function(t,e){try{function r(t){return e.page=t,e.cache=!!o,e.page}const o=n.cache.get(t.to.url);return Promise.resolve(o?r(o):Promise.resolve(n.fetchPage(t.to.url,e.options)).then(r))}catch(i){return Promise.reject(i)}});if(!n.visit.history.popstate){const e=t+(n.visit.scroll.target||"");"replace"===n.visit.history.action?a(e):s(e,{index:n.currentHistoryIndex+1})}n.currentPageUrl=i();const l=function(){if(n.visit.animation.wait)return Promise.resolve(o).then(function(t){let{html:e}=t;n.visit.to.html=e})}();return l&&l.then?l.then(r):r()})}catch(t){return o(t)}return l&&l.then?l.then(void 0,o):l}(0,function(t){t&&(console.error(t),n.options.skipPopStateHandling=()=>(window.location.href=n.visit.to.url,!0),window.history.go(-1))}))}catch(t){return Promise.reject(t)}};function R(t,e,n){if(void 0===e&&(e={}),void 0===n&&(n={}),this.shouldIgnoreVisit(t,{el:n.el,event:n.event}))return void(window.location.href=t);const{url:r,hash:o}=c.fromUrl(t);this.visit=this.createVisit({...n,to:r,hash:o}),this.performNavigation(r,e)}const j=function(t,e){void 0===e&&(e={});try{const n=this;t=c.fromUrl(t).url;const r={...n.options.requestHeaders,...e.headers};return e={...e,headers:r},Promise.resolve(n.hooks.call("fetch:request",{url:t,options:e},(t,e)=>{let{url:n,options:r}=e;return fetch(n,r)})).then(function(e){const{status:r,url:o}=e;return Promise.resolve(e.text()).then(function(i){if(500===r)throw n.hooks.call("fetch:error",{status:r,response:e,url:o}),new L(`Server error: ${o}`,{status:r,url:o});if(!i)throw new L(`Empty response: ${o}`,{status:r,url:o});const{url:s}=c.fromUrl(o),a={url:s,html:i};return t===s&&n.cache.set(a.url,a),a})})}catch(t){return Promise.reject(t)}};class L extends Error{constructor(t,e){super(t),this.url=void 0,this.status=void 0,this.name="FetchError",this.url=e.url,this.status=e.status}}const I=function(){try{let e;const n=this;function t(t){return e?t:Promise.resolve(n.hooks.call("animation:out:start",void 0,t=>{n.classes.add("is-changing","is-leaving","is-animating"),t.history.popstate&&n.classes.add("is-popstate"),t.animation.name&&n.classes.add(`to-${o(t.animation.name)}`)})).then(function(){return Promise.resolve(n.hooks.call("animation:out:await",{skip:!1},function(t,e){let{skip:r}=e;try{return r?Promise.resolve():Promise.resolve(n.awaitAnimations({selector:t.animation.selector})).then(function(){})}catch(t){return Promise.reject(t)}})).then(function(){return Promise.resolve(n.hooks.call("animation:out:end")).then(function(){})})})}const r=function(){if(!n.visit.animation.animate)return Promise.resolve(n.hooks.call("animation:skip")).then(function(){e=1})}();return Promise.resolve(r&&r.then?r.then(t):t(r))}catch(i){return Promise.reject(i)}},N=function(t,e){let{html:n}=t,{containers:r}=void 0===e?this.options:e;const o=(new DOMParser).parseFromString(n,"text/html"),i=o.querySelector("title")?.innerText||"";return document.title=i,r.map(t=>{const e=document.querySelector(t),n=o.querySelector(t);return e&&n?(e.replaceWith(n),!0):(e||console.warn(`[swup] Container missing in current document: ${t}`),n||console.warn(`[swup] Container missing in incoming document: ${t}`),!1)}).filter(Boolean).length===r.length},D=function(){const t={behavior:"auto"},{target:e,reset:n}=this.visit.scroll;let r=!1;return e&&(r=this.hooks.callSync("scroll:anchor",{hash:e,options:t},(t,e)=>{let{hash:n,options:r}=e;const o=this.getAnchorElement(n||"");return o&&o.scrollIntoView(r),!!o})),n&&!r&&(r=this.hooks.callSync("scroll:top",{options:t},(t,e)=>{let{options:n}=e;return window.scrollTo({top:0,left:0,...n}),!0})),r},V=function(){try{const t=this;if(!t.visit.animation.animate)return Promise.resolve();const e=t.hooks.call("animation:in:await",{skip:!1},function(e,n){let{skip:r}=n;try{return r?Promise.resolve():Promise.resolve(t.awaitAnimations({selector:e.animation.selector})).then(function(){})}catch(t){return Promise.reject(t)}});return Promise.resolve(p()).then(function(){return Promise.resolve(t.hooks.call("animation:in:start",void 0,()=>{t.classes.remove("is-animating")})).then(function(){return Promise.resolve(e).then(function(){return Promise.resolve(t.hooks.call("animation:in:end")).then(function(){})})})})}catch(t){return Promise.reject(t)}},M=function(t,e){try{const n=this,{url:r,html:s}=e;return n.classes.remove("is-leaving"),n.isSameResolvedUrl(i(),t)?(n.isSameResolvedUrl(i(),r)||(a(r),n.currentPageUrl=i(),n.visit.to.url=n.currentPageUrl),n.visit.animation.animate&&n.classes.add("is-rendering"),n.visit.to.html=s,Promise.resolve(n.hooks.call("content:replace",{page:e},(t,e)=>{let{page:r}=e;if(!n.replaceContent(r,{containers:t.containers}))throw new Error("[swup] Container mismatch, aborting");t.animation.animate&&(n.classes.add("is-animating","is-changing","is-rendering"),t.animation.name&&n.classes.add(`to-${o(t.animation.name)}`))})).then(function(){return Promise.resolve(n.hooks.call("content:scroll",void 0,()=>n.scrollToContent())).then(function(){return Promise.resolve(n.hooks.call("page:view",{url:n.currentPageUrl,title:document.title})).then(function(){n.options.cache||n.cache.clear()})})})):Promise.resolve()}catch(t){return Promise.reject(t)}},T=function(t){var e;if(e=t,e?.isSwupPlugin){if(t.swup=this,!t._checkRequirements||t._checkRequirements())return t._beforeMount&&t._beforeMount(),t.mount(),this.plugins.push(t),this.plugins}else console.error("Not a swup plugin instance",t)};function W(t){const e=this.findPlugin(t);if(e)return e.unmount(),e._afterUnmount&&e._afterUnmount(),this.plugins=this.plugins.filter(t=>t!==e),this.plugins;console.error("No such plugin",e)}function _(t){return this.plugins.find(e=>e===t||e.name===t||e.name===`Swup${t}`)}function B(t){if("function"!=typeof this.options.resolveUrl)return console.warn("[swup] options.resolveUrl expects a callback function."),t;const e=this.options.resolveUrl(t);return e&&"string"==typeof e?e.startsWith("//")||e.startsWith("http")?(console.warn("[swup] options.resolveUrl needs to return a relative url"),t):e:(console.warn("[swup] options.resolveUrl needs to return a url"),t)}function O(t,e){return this.resolveUrl(t)===this.resolveUrl(e)}exports.Location=c,exports.classify=o,exports.createHistoryRecord=s,exports.default=class{constructor(t){void 0===t&&(t={}),this.version="4.0.0-rc.28",this.options=void 0,this.plugins=[],this.cache=void 0,this.hooks=void 0,this.visit=void 0,this.classes=void 0,this.currentPageUrl=i(),this.getCurrentUrl=i,this.use=T,this.unuse=W,this.findPlugin=_,this.log=()=>{},this.getAnchorElement=x,this.navigate=R,this.performNavigation=q,this.delegateEvent=l,this.fetchPage=j,this.awaitAnimations=E,this.renderPage=M,this.replaceContent=N,this.animatePageIn=V,this.animatePageOut=I,this.scrollToContent=D,this.createVisit=y,this.resolveUrl=B,this.isSameResolvedUrl=O,this.defaults={animateHistoryBrowsing:!1,animationSelector:'[class*="transition-"]',animationScope:"html",cache:!0,containers:["#swup"],ignoreVisit:function(t,e){let{el:n}=void 0===e?{}:e;return!!n?.closest("[data-no-swup]")},linkSelector:"a[href]",plugins:[],resolveUrl:t=>t,requestHeaders:{"X-Requested-With":"swup",Accept:"text/html, application/xhtml+xml"},skipPopStateHandling:t=>"swup"!==t.state?.source},this.currentHistoryIndex=1,this.clickDelegate=void 0,this.options={...this.defaults,...t},this.handleLinkClick=this.handleLinkClick.bind(this),this.handlePopState=this.handlePopState.bind(this),this.cache=new u(this),this.classes=new w(this),this.hooks=new U(this),this.visit=this.createVisit({to:void 0}),this.checkRequirements()&&this.enable()}checkRequirements(){return"undefined"!=typeof Promise||(console.warn("Promise is not supported"),!1)}enable(){try{const t=this,{linkSelector:e}=t.options;return t.clickDelegate=t.delegateEvent(e,"click",t.handleLinkClick),window.addEventListener("popstate",t.handlePopState),t.options.plugins.forEach(e=>t.use(e)),a(null,{index:1}),Promise.resolve(p()).then(function(){return Promise.resolve(t.hooks.call("enable",void 0,()=>{document.documentElement.classList.add("swup-enabled")})).then(function(){})})}catch(t){return Promise.reject(t)}}destroy(){try{const t=this;return t.clickDelegate.destroy(),window.removeEventListener("popstate",t.handlePopState),t.cache.clear(),t.options.plugins.forEach(e=>t.unuse(e)),Promise.resolve(t.hooks.call("disable",void 0,()=>{document.documentElement.classList.remove("swup-enabled")})).then(function(){t.hooks.clear()})}catch(t){return Promise.reject(t)}}shouldIgnoreVisit(t,e){let{el:n,event:r}=void 0===e?{}:e;const{origin:o,url:i,hash:s}=c.fromUrl(t);return o!==window.location.origin||!(!n||!this.triggerWillOpenNewWindow(n))||!!this.options.ignoreVisit(i+s,{el:n,event:r})}handleLinkClick(t){const e=t.delegateTarget,{href:n,url:r,hash:o}=c.fromElement(e);this.shouldIgnoreVisit(n,{el:e,event:t})||(this.visit=this.createVisit({to:r,hash:o,el:e,event:t}),t.metaKey||t.ctrlKey||t.shiftKey||t.altKey?this.hooks.call("link:newtab",{href:n}):0===t.button&&this.hooks.callSync("link:click",{el:e,event:t},()=>{const e=this.visit.from.url??"";t.preventDefault(),r&&r!==e?this.isSameResolvedUrl(r,e)||this.performNavigation(r):o?this.hooks.callSync("link:anchor",{hash:o},()=>{a(r+o),this.scrollToContent()}):this.hooks.callSync("link:self",void 0,()=>{this.scrollToContent()})}))}handlePopState(t){const e=t.state?.url??location.href;if(this.options.skipPopStateHandling(t))return;if(this.isSameResolvedUrl(i(),this.currentPageUrl))return;if(this.shouldIgnoreVisit(e,{event:t}))return;const{url:n,hash:r}=c.fromUrl(e);this.visit=this.createVisit({to:n,hash:r,event:t,animate:this.options.animateHistoryBrowsing,resetScroll:this.options.animateHistoryBrowsing}),this.visit.history.popstate=!0;const o=Number(t.state?.index);o&&(this.visit.history.direction=o-this.currentHistoryIndex>0?"forwards":"backwards"),this.hooks.callSync("history:popstate",{event:t},()=>{this.performNavigation(n)})}triggerWillOpenNewWindow(t){return!!t.matches('[download], [target="_blank"]')}},exports.delegateEvent=l,exports.escapeCssIdentifier=v,exports.forceReflow=function(t){return t=t||document.body,t?.offsetHeight},exports.getCurrentUrl=i,exports.isPromise=d,exports.matchPath=(t,n)=>{try{return e.match(t,n)}catch(e){throw new Error(`[swup] Error parsing path "${t}":\n${e}`)}},exports.nextTick=p,exports.query=h,exports.queryAll=m,exports.runAsPromise=f,exports.toMs=g,exports.updateHistoryRecord=a;
2
2
  //# sourceMappingURL=Swup.cjs.map
package/dist/Swup.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Swup.cjs","sources":["../src/helpers/classify.ts","../src/helpers/getCurrentUrl.ts","../src/helpers/createHistoryRecord.ts","../src/helpers/updateHistoryRecord.ts","../src/helpers/delegateEvent.ts","../src/helpers/Location.ts","../src/modules/Cache.ts","../src/utils/index.ts","../src/modules/Classes.ts","../src/modules/Visit.ts","../src/modules/Hooks.ts","../src/modules/getAnchorElement.ts","../src/modules/awaitAnimations.ts","../src/modules/navigate.ts","../src/modules/fetchPage.ts","../src/modules/animatePageOut.ts","../src/modules/replaceContent.ts","../src/modules/scrollToContent.ts","../src/modules/animatePageIn.ts","../src/modules/renderPage.ts","../src/modules/plugins.ts","../src/Swup.ts","../src/helpers/matchPath.ts"],"sourcesContent":["/** Turn a string into a slug by lowercasing and replacing whitespace. */\nexport const classify = (text: string, fallback?: string): string => {\n\tconst output = String(text)\n\t\t.toLowerCase()\n\t\t// .normalize('NFD') // split an accented letter in the base letter and the acent\n\t\t// .replace(/[\\u0300-\\u036f]/g, '') // remove all previously split accents\n\t\t.replace(/[\\s/_.]+/g, '-') // replace spaces and _./ with '-'\n\t\t.replace(/[^\\w-]+/g, '') // remove all non-word chars\n\t\t.replace(/--+/g, '-') // replace repeating '-' with single '-'\n\t\t.replace(/^-+|-+$/g, ''); // trim '-' from edges\n\treturn output || fallback || '';\n};\n","/** Get the current page URL: path name + query params. Optionally including hash. */\nexport const getCurrentUrl = ({ hash }: { hash?: boolean } = {}): string => {\n\treturn location.pathname + location.search + (hash ? location.hash : '');\n};\n","import { getCurrentUrl } from './getCurrentUrl.js';\n\n/** Create a new history record with a custom swup identifier. */\nexport const createHistoryRecord = (\n\turl: string,\n\tcustomData: Record<string, unknown> = {}\n): void => {\n\turl = url || getCurrentUrl({ hash: true });\n\tconst data = {\n\t\turl,\n\t\trandom: Math.random(),\n\t\tsource: 'swup',\n\t\t...customData\n\t};\n\thistory.pushState(data, '', url);\n};\n","import { getCurrentUrl } from './getCurrentUrl.js';\n\n/** Update the current history record with a custom swup identifier. */\nexport const updateHistoryRecord = (\n\turl: string | null = null,\n\tcustomData: Record<string, unknown> = {}\n): void => {\n\turl = url || getCurrentUrl({ hash: true });\n\tconst data = {\n\t\t...history.state,\n\t\turl,\n\t\trandom: Math.random(),\n\t\tsource: 'swup',\n\t\t...customData\n\t};\n\thistory.replaceState(data, '', url);\n};\n","import delegate, { DelegateEventHandler, DelegateOptions, EventType } from 'delegate-it';\nimport { ParseSelector } from 'typed-query-selector/parser.js';\n\nexport type DelegateEventUnsubscribe = {\n\tdestroy: () => void;\n};\n\n/** Register a delegated event listener. */\nexport const delegateEvent = <Selector extends string, TEvent extends EventType>(\n\tselector: Selector,\n\ttype: TEvent,\n\tcallback: DelegateEventHandler<GlobalEventHandlersEventMap[TEvent]>,\n\toptions?: DelegateOptions\n): DelegateEventUnsubscribe => {\n\tconst controller = new AbortController();\n\toptions = { ...options, signal: controller.signal };\n\tdelegate<string, ParseSelector<Selector, HTMLElement>, TEvent>(\n\t\tselector,\n\t\ttype,\n\t\tcallback,\n\t\toptions\n\t);\n\treturn { destroy: () => controller.abort() };\n};\n","/**\n * A helper for creating a Location from either an element\n * or a URL object/string\n *\n */\nexport class Location extends URL {\n\tconstructor(url: URL | string, base: string = document.baseURI) {\n\t\tsuper(url.toString(), base);\n\t}\n\n\t/**\n\t * The full local path including query params.\n\t */\n\tget url(): string {\n\t\treturn this.pathname + this.search;\n\t}\n\n\t/**\n\t * Instantiate a Location from an element's href attribute\n\t * @param el\n\t * @returns new Location instance\n\t */\n\tstatic fromElement(el: Element): Location {\n\t\tconst href = el.getAttribute('href') || el.getAttribute('xlink:href') || '';\n\t\treturn new Location(href!);\n\t}\n\n\t/**\n\t * Instantiate a Location from a URL object or string\n\t * @param url\n\t * @returns new Location instance\n\t */\n\tstatic fromUrl(url: URL | string): Location {\n\t\treturn new Location(url);\n\t}\n}\n","import Swup from '../Swup.js';\nimport { Location } from '../helpers.js';\nimport { PageData } from './fetchPage.js';\n\nexport interface CacheData extends PageData {}\n\n/**\n * In-memory page cache.\n */\nexport class Cache {\n\t/** Swup instance this cache belongs to */\n\tprivate swup: Swup;\n\n\t/** Cached pages, indexed by URL */\n\tprivate pages: Map<string, CacheData> = new Map();\n\n\tconstructor(swup: Swup) {\n\t\tthis.swup = swup;\n\t}\n\n\t/** Number of cached pages in memory. */\n\tget size(): number {\n\t\treturn this.pages.size;\n\t}\n\n\t/** All cached pages. */\n\tget all() {\n\t\treturn this.pages;\n\t}\n\n\t/** Check if the given URL has been cached. */\n\tpublic has(url: string): boolean {\n\t\treturn this.pages.has(this.resolve(url));\n\t}\n\n\t/** Return the cached page object if cached. */\n\tpublic get(url: string): CacheData | undefined {\n\t\treturn this.pages.get(this.resolve(url));\n\t}\n\n\t/** Create a cache record for the specified URL. */\n\tpublic set(url: string, page: CacheData) {\n\t\turl = this.resolve(url);\n\t\tpage = { ...page, url };\n\t\tthis.pages.set(url, page);\n\t\tthis.swup.hooks.callSync('cache:set', { page });\n\t}\n\n\t/** Update a cache record, overwriting or adding custom data. */\n\tpublic update(url: string, page: CacheData) {\n\t\turl = this.resolve(url);\n\t\tpage = { ...this.get(url), ...page, url };\n\t\tthis.pages.set(url, page);\n\t}\n\n\t/** Delete a cache record. */\n\tpublic delete(url: string): void {\n\t\tthis.pages.delete(this.resolve(url));\n\t}\n\n\t/** Empty the cache. */\n\tpublic clear(): void {\n\t\tthis.pages.clear();\n\t\tthis.swup.hooks.callSync('cache:clear');\n\t}\n\n\t/** Remove all cache entries that return true for a given predicate function. */\n\tpublic prune(predicate: (url: string, page: CacheData) => boolean): void {\n\t\tthis.pages.forEach((page, url) => {\n\t\t\tif (predicate(url, page)) {\n\t\t\t\tthis.delete(url);\n\t\t\t}\n\t\t});\n\t}\n\n\t/** Resolve URLs by making them local and letting swup resolve them. */\n\tprivate resolve(urlToResolve: string): string {\n\t\tconst { url } = Location.fromUrl(urlToResolve);\n\t\treturn this.swup.resolveUrl(url);\n\t}\n}\n","/** Find an element by selector. */\nexport const query = (selector: string, context: Document | Element = document) => {\n\treturn context.querySelector<HTMLElement>(selector);\n};\n\n/** Find a set of elements by selector. */\nexport const queryAll = (\n\tselector: string,\n\tcontext: Document | Element = document\n): HTMLElement[] => {\n\treturn Array.from(context.querySelectorAll(selector));\n};\n\n/** Return a Promise that resolves after the next event loop. */\nexport const nextTick = (): Promise<void> => {\n\treturn new Promise((resolve) => {\n\t\trequestAnimationFrame(() => {\n\t\t\trequestAnimationFrame(() => {\n\t\t\t\tresolve();\n\t\t\t});\n\t\t});\n\t});\n};\n\n/** Check if an object is a Promise or a Thenable */\nexport function isPromise<T>(obj: any): obj is PromiseLike<T> {\n\treturn (\n\t\t!!obj &&\n\t\t(typeof obj === 'object' || typeof obj === 'function') &&\n\t\ttypeof obj.then === 'function'\n\t);\n}\n\n/** Call a function as a Promise. Resolves with the returned Promsise or immediately. */\nexport function runAsPromise(func: Function, args: any[] = []): Promise<any> {\n\treturn new Promise((resolve, reject) => {\n\t\tconst result = func(...args);\n\t\tif (isPromise(result)) {\n\t\t\tresult.then(resolve, reject);\n\t\t} else {\n\t\t\tresolve(result);\n\t\t}\n\t});\n}\n\n/**\n * Force a layout reflow, e.g. after adding classnames\n * @returns The offset height, just here so it doesn't get optimized away by the JS engine\n * @see https://stackoverflow.com/a/21665117/3759615\n */\nexport function forceReflow(element?: HTMLElement) {\n\telement = element || document.body;\n\treturn element?.offsetHeight;\n}\n\n/** Escape a string with special chars to not break CSS selectors. */\nexport const escapeCssIdentifier = (ident: string) => {\n\t// @ts-ignore this is for support check, so it's correct that TS complains\n\tif (window.CSS && window.CSS.escape) {\n\t\treturn CSS.escape(ident);\n\t}\n\treturn ident;\n};\n\n/** Fix for Chrome below v61 formatting CSS floats with comma in some locales. */\nexport const toMs = (s: string) => {\n\treturn Number(s.slice(0, -1).replace(',', '.')) * 1000;\n};\n","import Swup from '../Swup.js';\nimport { queryAll } from '../utils.js';\n\nexport class Classes {\n\tpublic swup: Swup;\n\n\tswupClasses = ['to-', 'is-changing', 'is-rendering', 'is-popstate', 'is-animating'];\n\n\tconstructor(swup: Swup) {\n\t\tthis.swup = swup;\n\t}\n\n\tget selectors(): string[] {\n\t\tconst { scope } = this.swup.visit.animation;\n\t\tif (scope === 'containers') return this.swup.visit.containers;\n\t\tif (scope === 'html') return ['html'];\n\t\tif (Array.isArray(scope)) return scope;\n\t\treturn [];\n\t}\n\n\tget selector(): string {\n\t\treturn this.selectors.join(',');\n\t}\n\n\tget targets(): HTMLElement[] {\n\t\tif (!this.selector.trim()) return [];\n\t\treturn queryAll(this.selector) as HTMLElement[];\n\t}\n\n\tpublic add(...classes: string[]): void {\n\t\tthis.targets.forEach((target) => target.classList.add(...classes));\n\t}\n\n\tpublic remove(...classes: string[]): void {\n\t\tthis.targets.forEach((target) => target.classList.remove(...classes));\n\t}\n\n\tpublic clear(): void {\n\t\tthis.targets.forEach((target) => {\n\t\t\tconst remove = target.className.split(' ').filter((c) => this.isSwupClass(c));\n\t\t\ttarget.classList.remove(...remove);\n\t\t});\n\t}\n\n\tprivate isSwupClass(className: string): boolean {\n\t\treturn this.swupClasses.some((c) => className.startsWith(c));\n\t}\n}\n","import Swup, { Options } from '../Swup.js';\nimport { HistoryAction, HistoryDirection } from './navigate.js';\n\n/** An object holding details about the current visit. */\nexport interface Visit {\n\t/** The previous page, about to leave */\n\tfrom: VisitFrom;\n\t/** The next page, about to enter */\n\tto: VisitTo;\n\t/** The content containers, about to be replaced */\n\tcontainers: Options['containers'];\n\t/** Information about animated page transitions */\n\tanimation: VisitAnimation;\n\t/** What triggered this visit */\n\ttrigger: VisitTrigger;\n\t/** Browser history behavior on this visit */\n\thistory: VisitHistory;\n\t/** Scroll behavior on this visit */\n\tscroll: VisitScroll;\n}\n\nexport interface VisitFrom {\n\t/** The URL of the previous page */\n\turl: string;\n}\n\nexport interface VisitTo {\n\t/** The URL of the next page */\n\turl?: string;\n\t/** The HTML content of the next page */\n\thtml?: string;\n}\n\nexport interface VisitAnimation {\n\t/** Whether this visit is animated. Default: `true` */\n\tanimate: boolean;\n\t/** Whether to wait for the next page to load before starting the animation. Default: `false` */\n\twait: boolean;\n\t/** Name of a custom animation to run. */\n\tname?: string;\n\t/** Elements on which to add animation classes. Default: `html` element */\n\tscope: 'html' | 'containers' | string[];\n\t/** Selector for detecting animation timing. Default: `[class*=\"transition-\"]` */\n\tselector: Options['animationSelector'];\n}\n\nexport interface VisitScroll {\n\t/** Whether to reset the scroll position after the visit. Default: `true` */\n\treset: boolean;\n\t/** Anchor element to scroll to on the next page. */\n\ttarget?: string;\n}\n\nexport interface VisitTrigger {\n\t/** DOM element that triggered this visit. */\n\tel?: Element;\n\t/** DOM event that triggered this visit. */\n\tevent?: Event;\n}\n\nexport interface VisitHistory {\n\t/** History action to perform: `push` for creating a new history entry, `replace` for replacing the current entry. Default: `push` */\n\taction: HistoryAction;\n\t/** Whether this visit was triggered by a browser history navigation. */\n\tpopstate: boolean;\n\t/** The direction of travel in case of a browser history navigation: backward or forward. */\n\tdirection: HistoryDirection | undefined;\n}\n\nexport interface VisitInitOptions {\n\tto: string | undefined;\n\tfrom?: string;\n\thash?: string;\n\tanimate?: boolean;\n\tanimation?: string;\n\ttargets?: string[];\n\tel?: Element;\n\tevent?: Event;\n\taction?: HistoryAction;\n\tresetScroll?: boolean;\n}\n\n/** Create a new visit object. */\nexport function createVisit(\n\tthis: Swup,\n\t{\n\t\tto,\n\t\tfrom = this.currentPageUrl,\n\t\thash: target,\n\t\tanimate = true,\n\t\tanimation: name,\n\t\tel,\n\t\tevent,\n\t\taction = 'push',\n\t\tresetScroll: reset = true\n\t}: VisitInitOptions\n): Visit {\n\treturn {\n\t\tfrom: { url: from },\n\t\tto: { url: to },\n\t\tcontainers: this.options.containers,\n\t\tanimation: {\n\t\t\tanimate,\n\t\t\twait: false,\n\t\t\tname,\n\t\t\tscope: this.options.animationScope,\n\t\t\tselector: this.options.animationSelector\n\t\t},\n\t\ttrigger: {\n\t\t\tel,\n\t\t\tevent\n\t\t},\n\t\thistory: {\n\t\t\taction,\n\t\t\tpopstate: false,\n\t\t\tdirection: undefined\n\t\t},\n\t\tscroll: {\n\t\t\treset,\n\t\t\ttarget\n\t\t}\n\t};\n}\n","import { DelegateEvent } from 'delegate-it';\n\nimport Swup from '../Swup.js';\nimport { isPromise, runAsPromise } from '../utils.js';\nimport { Visit } from './Visit.js';\nimport { FetchOptions, PageData } from './fetchPage.js';\n\nexport interface HookDefinitions {\n\t'animation:out:start': undefined;\n\t'animation:out:await': { skip: boolean };\n\t'animation:out:end': undefined;\n\t'animation:in:start': undefined;\n\t'animation:in:await': { skip: boolean };\n\t'animation:in:end': undefined;\n\t'animation:skip': undefined;\n\t'cache:clear': undefined;\n\t'cache:set': { page: PageData };\n\t'content:replace': { page: PageData };\n\t'content:scroll': undefined;\n\t'enable': undefined;\n\t'disable': undefined;\n\t'fetch:request': { url: string; options: FetchOptions };\n\t'fetch:error': { url: string; status: number; response: Response };\n\t'history:popstate': { event: PopStateEvent };\n\t'link:click': { el: HTMLAnchorElement; event: DelegateEvent<MouseEvent> };\n\t'link:self': undefined;\n\t'link:anchor': { hash: string };\n\t'link:newtab': { href: string };\n\t'page:request': { url: string; options: FetchOptions };\n\t'page:load': { page: PageData; cache?: boolean };\n\t'page:view': { url: string; title: string };\n\t'scroll:top': { options: ScrollIntoViewOptions };\n\t'scroll:anchor': { hash: string; options: ScrollIntoViewOptions };\n\t'visit:start': undefined;\n\t'visit:end': undefined;\n}\n\nexport type HookArguments<T extends HookName> = HookDefinitions[T];\n\nexport type HookName = keyof HookDefinitions;\n\n/** A hook handler. */\nexport type Handler<T extends HookName> = (\n\t/** Context about the current visit. */\n\tvisit: Visit,\n\t/** Local arguments passed into the handler. */\n\targs: HookArguments<T>,\n\t/** Default handler to be executed. Available if replacing an internal hook handler. */\n\tdefaultHandler?: Handler<T>\n) => Promise<any> | any;\n\nexport type Handlers = {\n\t[K in HookName]: Handler<K>[];\n};\n\n/** Unregister a previously registered hook handler. */\nexport type HookUnregister = () => void;\n\n/** Define when and how a hook handler is executed. */\nexport type HookOptions = {\n\t/** Execute the hook once, then remove the handler */\n\tonce?: boolean;\n\t/** Execute the hook before the internal default handler */\n\tbefore?: boolean;\n\t/** Set a priority for when to execute this hook. Lower numbers execute first. Default: `0` */\n\tpriority?: number;\n\t/** Replace the internal default handler with this hook handler */\n\treplace?: boolean;\n};\n\nexport type HookRegistration<T extends HookName> = {\n\tid: number;\n\thook: T;\n\thandler: Handler<T>;\n\tdefaultHandler?: Handler<T>;\n} & HookOptions;\n\ntype HookLedger<T extends HookName> = Map<Handler<T>, HookRegistration<T>>;\n\ninterface HookRegistry extends Map<HookName, HookLedger<HookName>> {\n\tget<K extends HookName>(key: K): HookLedger<K> | undefined;\n\tset<K extends HookName>(key: K, value: HookLedger<K>): this;\n}\n\n/**\n * Hook registry.\n *\n * Create, trigger and handle hooks.\n *\n */\nexport class Hooks {\n\t/** Swup instance this registry belongs to */\n\tprotected swup: Swup;\n\n\t/** Map of all registered hook handlers. */\n\tprotected registry: HookRegistry = new Map();\n\n\t// Can we deduplicate this somehow? Or make it error when not in sync with HookDefinitions?\n\t// https://stackoverflow.com/questions/53387838/how-to-ensure-an-arrays-values-the-keys-of-a-typescript-interface/53395649\n\tprotected readonly hooks: HookName[] = [\n\t\t'animation:out:start',\n\t\t'animation:out:await',\n\t\t'animation:out:end',\n\t\t'animation:in:start',\n\t\t'animation:in:await',\n\t\t'animation:in:end',\n\t\t'animation:skip',\n\t\t'cache:clear',\n\t\t'cache:set',\n\t\t'content:replace',\n\t\t'content:scroll',\n\t\t'enable',\n\t\t'disable',\n\t\t'fetch:request',\n\t\t'fetch:error',\n\t\t'history:popstate',\n\t\t'link:click',\n\t\t'link:self',\n\t\t'link:anchor',\n\t\t'link:newtab',\n\t\t'page:request',\n\t\t'page:load',\n\t\t'page:view',\n\t\t'scroll:top',\n\t\t'scroll:anchor',\n\t\t'visit:start',\n\t\t'visit:end'\n\t];\n\n\tconstructor(swup: Swup) {\n\t\tthis.swup = swup;\n\t\tthis.init();\n\t}\n\n\t/**\n\t * Create ledgers for all core hooks.\n\t */\n\tprotected init() {\n\t\tthis.hooks.forEach((hook) => this.create(hook));\n\t}\n\n\t/**\n\t * Create a new hook type.\n\t */\n\tcreate(hook: string) {\n\t\tif (!this.registry.has(hook as HookName)) {\n\t\t\tthis.registry.set(hook as HookName, new Map());\n\t\t}\n\t}\n\n\t/**\n\t * Check if a hook type exists.\n\t */\n\texists(hook: HookName): boolean {\n\t\treturn this.registry.has(hook);\n\t}\n\n\t/**\n\t * Get the ledger with all registrations for a hook.\n\t */\n\tprotected get<T extends HookName>(hook: T): HookLedger<T> | undefined {\n\t\tconst ledger = this.registry.get(hook);\n\t\tif (ledger) {\n\t\t\treturn ledger;\n\t\t}\n\t\tconsole.error(`Unknown hook '${hook}'`);\n\t}\n\n\t/**\n\t * Remove all handlers of all hooks.\n\t */\n\tclear() {\n\t\tthis.registry.forEach((ledger) => ledger.clear());\n\t}\n\n\t/**\n\t * Register a new hook handler.\n\t * @param hook Name of the hook to listen for\n\t * @param handler The handler function to execute\n\t * @param options Object to specify how and when the handler is executed\n\t * Available options:\n\t * - `once`: Only execute the handler once\n\t * - `before`: Execute the handler before the default handler\n\t * - `priority`: Specify the order in which the handlers are executed\n\t * - `replace`: Replace the default handler with this handler\n\t * @returns A function to unregister the handler\n\t */\n\ton<T extends HookName>(hook: T, handler: Handler<T>): HookUnregister;\n\ton<T extends HookName>(hook: T, handler: Handler<T>, options: HookOptions): HookUnregister;\n\ton<T extends HookName>(\n\t\thook: T,\n\t\thandler: Handler<T>,\n\t\toptions: HookOptions = {}\n\t): HookUnregister {\n\t\tconst ledger = this.get(hook);\n\t\tif (!ledger) {\n\t\t\tconsole.warn(`Hook '${hook}' not found.`);\n\t\t\treturn () => {};\n\t\t}\n\n\t\tconst id = ledger.size + 1;\n\t\tconst registration: HookRegistration<T> = { ...options, id, hook, handler };\n\t\tledger.set(handler, registration);\n\n\t\treturn () => this.off(hook, handler);\n\t}\n\n\t/**\n\t * Register a new hook handler to run before the default handler.\n\t * Shortcut for `hooks.on(hook, handler, { before: true })`.\n\t * @param hook Name of the hook to listen for\n\t * @param handler The handler function to execute\n\t * @param options Any other event options (see `hooks.on()` for details)\n\t * @returns A function to unregister the handler\n\t * @see on\n\t */\n\tbefore<T extends HookName>(hook: T, handler: Handler<T>): HookUnregister;\n\tbefore<T extends HookName>(hook: T, handler: Handler<T>, options: HookOptions): HookUnregister;\n\tbefore<T extends HookName>(\n\t\thook: T,\n\t\thandler: Handler<T>,\n\t\toptions: HookOptions = {}\n\t): HookUnregister {\n\t\treturn this.on(hook, handler, { ...options, before: true });\n\t}\n\n\t/**\n\t * Register a new hook handler to replace the default handler.\n\t * Shortcut for `hooks.on(hook, handler, { replace: true })`.\n\t * @param hook Name of the hook to listen for\n\t * @param handler The handler function to execute instead of the default handler\n\t * @param options Any other event options (see `hooks.on()` for details)\n\t * @returns A function to unregister the handler\n\t * @see on\n\t */\n\treplace<T extends HookName>(hook: T, handler: Handler<T>): HookUnregister;\n\treplace<T extends HookName>(hook: T, handler: Handler<T>, options: HookOptions): HookUnregister;\n\treplace<T extends HookName>(\n\t\thook: T,\n\t\thandler: Handler<T>,\n\t\toptions: HookOptions = {}\n\t): HookUnregister {\n\t\treturn this.on(hook, handler, { ...options, replace: true });\n\t}\n\n\t/**\n\t * Register a new hook handler to run once.\n\t * Shortcut for `hooks.on(hook, handler, { once: true })`.\n\t * @param hook Name of the hook to listen for\n\t * @param handler The handler function to execute\n\t * @param options Any other event options (see `hooks.on()` for details)\n\t * @see on\n\t */\n\tonce<T extends HookName>(hook: T, handler: Handler<T>): HookUnregister;\n\tonce<T extends HookName>(hook: T, handler: Handler<T>, options: HookOptions): HookUnregister;\n\tonce<T extends HookName>(\n\t\thook: T,\n\t\thandler: Handler<T>,\n\t\toptions: HookOptions = {}\n\t): HookUnregister {\n\t\treturn this.on(hook, handler, { ...options, once: true });\n\t}\n\n\t/**\n\t * Unregister a hook handler.\n\t * @param hook Name of the hook the handler is registered for\n\t * @param handler The handler function that was registered.\n\t * If omitted, all handlers for the hook will be removed.\n\t */\n\toff<T extends HookName>(hook: T): void;\n\toff<T extends HookName>(hook: T, handler: Handler<T>): void;\n\toff<T extends HookName>(hook: T, handler?: Handler<T>): void {\n\t\tconst ledger = this.get(hook);\n\t\tif (ledger && handler) {\n\t\t\tconst deleted = ledger.delete(handler);\n\t\t\tif (!deleted) {\n\t\t\t\tconsole.warn(`Handler for hook '${hook}' not found.`);\n\t\t\t}\n\t\t} else if (ledger) {\n\t\t\tledger.clear();\n\t\t}\n\t}\n\n\t/**\n\t * Trigger a hook asynchronously, executing its default handler and all registered handlers.\n\t * Will execute all handlers in order and `await` any `Promise`s they return.\n\t * @param hook Name of the hook to trigger\n\t * @param args Arguments to pass to the handler\n\t * @param defaultHandler A default implementation of this hook to execute\n\t * @returns The resolved return value of the executed default handler\n\t */\n\tasync call<T extends HookName>(\n\t\thook: T,\n\t\targs?: HookArguments<T>,\n\t\tdefaultHandler?: Handler<T>\n\t): Promise<any> {\n\t\tconst { before, handler, after } = this.getHandlers(hook, defaultHandler);\n\t\tawait this.run(before, args);\n\t\tconst [result] = await this.run(handler, args);\n\t\tawait this.run(after, args);\n\t\tthis.dispatchDomEvent(hook, args);\n\t\treturn result;\n\t}\n\n\t/**\n\t * Trigger a hook synchronously, executing its default handler and all registered handlers.\n\t * Will execute all handlers in order, but will **not** `await` any `Promise`s they return.\n\t * @param hook Name of the hook to trigger\n\t * @param args Arguments to pass to the handler\n\t * @param defaultHandler A default implementation of this hook to execute\n\t * @returns The (possibly unresolved) return value of the executed default handler\n\t */\n\tcallSync<T extends HookName>(\n\t\thook: T,\n\t\targs?: HookArguments<T>,\n\t\tdefaultHandler?: Handler<T>\n\t): any {\n\t\tconst { before, handler, after } = this.getHandlers(hook, defaultHandler);\n\t\tthis.runSync(before, args);\n\t\tconst [result] = this.runSync(handler, args);\n\t\tthis.runSync(after, args);\n\t\tthis.dispatchDomEvent(hook, args);\n\t\treturn result;\n\t}\n\n\t/**\n\t * Execute the handlers for a hook, in order, as `Promise`s that will be `await`ed.\n\t * @param registrations The registrations (handler + options) to execute\n\t * @param args Arguments to pass to the handler\n\t */\n\tprivate async run<T extends HookName>(\n\t\tregistrations: HookRegistration<T>[],\n\t\targs?: HookArguments<T>\n\t): Promise<any> {\n\t\tconst results = [];\n\t\tfor (const { hook, handler, defaultHandler, once } of registrations) {\n\t\t\tconst result = await runAsPromise(handler, [this.swup.visit, args, defaultHandler]);\n\t\t\tresults.push(result);\n\t\t\tif (once) {\n\t\t\t\tthis.off(hook, handler);\n\t\t\t}\n\t\t}\n\t\treturn results;\n\t}\n\n\t/**\n\t * Execute the handlers for a hook, in order, without `await`ing any returned `Promise`s.\n\t * @param registrations The registrations (handler + options) to execute\n\t * @param args Arguments to pass to the handler\n\t */\n\tprivate runSync<T extends HookName>(\n\t\tregistrations: HookRegistration<T>[],\n\t\targs?: HookArguments<T>\n\t): any[] {\n\t\tconst results = [];\n\t\tfor (const { hook, handler, defaultHandler, once } of registrations) {\n\t\t\tconst result = handler(this.swup.visit, args as HookArguments<T>, defaultHandler);\n\t\t\tresults.push(result);\n\t\t\tif (isPromise(result)) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`Promise returned from handler for synchronous hook '${hook}'.` +\n\t\t\t\t\t\t`Swup will not wait for it to resolve.`\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (once) {\n\t\t\t\tthis.off(hook, handler);\n\t\t\t}\n\t\t}\n\t\treturn results;\n\t}\n\n\t/**\n\t * Get all registered handlers for a hook, sorted by priority and registration order.\n\t * @param hook Name of the hook\n\t * @param defaultHandler The optional default handler of this hook\n\t * @returns An object with the handlers sorted into `before` and `after` arrays,\n\t * as well as a flag indicating if the original handler was replaced\n\t */\n\tprivate getHandlers<T extends HookName>(hook: T, defaultHandler?: Handler<T>) {\n\t\tconst ledger = this.get(hook);\n\t\tif (!ledger) {\n\t\t\treturn { found: false, before: [], handler: [], after: [], replaced: false };\n\t\t}\n\n\t\tconst sort = this.sortRegistrations;\n\t\tconst registrations = Array.from(ledger.values());\n\n\t\t// Filter into before, after, and replace handlers\n\t\tconst before = registrations.filter(({ before, replace }) => before && !replace).sort(sort);\n\t\tconst replace = registrations.filter(({ replace }) => replace).sort(sort);\n\t\tconst after = registrations.filter(({ before, replace }) => !before && !replace).sort(sort);\n\t\tconst replaced = replace.length > 0;\n\n\t\t// Define main handler registration\n\t\t// This is an array to allow passing it into hooks.run() directly\n\t\tlet handler: HookRegistration<T>[] = [];\n\t\tif (defaultHandler) {\n\t\t\thandler = [{ id: 0, hook, handler: defaultHandler }];\n\t\t\tif (replaced) {\n\t\t\t\tconst index = replace.length - 1;\n\t\t\t\tconst replacingHandler = replace[index].handler;\n\t\t\t\tconst createDefaultHandler = (index: number): Handler<T> | undefined => {\n\t\t\t\t\tconst next = replace[index - 1];\n\t\t\t\t\tif (next) {\n\t\t\t\t\t\treturn (visit, args) =>\n\t\t\t\t\t\t\tnext.handler(visit, args, createDefaultHandler(index - 1));\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn defaultHandler;\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\tconst nestedDefaultHandler = createDefaultHandler(index);\n\t\t\t\thandler = [\n\t\t\t\t\t{ id: 0, hook, handler: replacingHandler, defaultHandler: nestedDefaultHandler }\n\t\t\t\t];\n\t\t\t}\n\t\t}\n\n\t\treturn { found: true, before, handler, after, replaced };\n\t}\n\n\t/**\n\t * Sort two hook registrations by priority and registration order.\n\t * @param a The registration object to compare\n\t * @param b The other registration object to compare with\n\t * @returns The sort direction\n\t */\n\tprivate sortRegistrations<T extends HookName>(\n\t\ta: HookRegistration<T>,\n\t\tb: HookRegistration<T>\n\t): number {\n\t\tconst priority = (a.priority ?? 0) - (b.priority ?? 0);\n\t\tconst id = a.id - b.id;\n\t\treturn priority || id || 0;\n\t}\n\n\t/**\n\t * Dispatch a custom event on the `document` for a hook. Prefixed with `swup:`\n\t * @param hook Name of the hook.\n\t */\n\tprivate dispatchDomEvent<T extends HookName>(hook: T, args?: HookArguments<T>): void {\n\t\tconst detail = { hook, args, visit: this.swup.visit };\n\t\tdocument.dispatchEvent(new CustomEvent(`swup:${hook}`, { detail }));\n\t}\n}\n","import { escapeCssIdentifier as escape, query } from '../utils.js';\n\n/**\n * Find the anchor element for a given hash.\n *\n * @param hash Hash with or without leading '#'\n * @returns The element, if found, or null.\n *\n * @see https://html.spec.whatwg.org/#find-a-potential-indicated-element\n */\nexport const getAnchorElement = (hash: string): Element | null => {\n\tif (hash && hash.charAt(0) === '#') {\n\t\thash = hash.substring(1);\n\t}\n\n\tif (!hash) {\n\t\treturn null;\n\t}\n\n\tconst decoded = decodeURIComponent(hash);\n\tlet element =\n\t\tdocument.getElementById(hash) ||\n\t\tdocument.getElementById(decoded) ||\n\t\tquery(`a[name='${escape(hash)}']`) ||\n\t\tquery(`a[name='${escape(decoded)}']`);\n\n\tif (!element && hash === 'top') {\n\t\telement = document.body;\n\t}\n\n\treturn element;\n};\n","import { queryAll, toMs } from '../utils.js';\nimport Swup, { Options } from '../Swup.js';\n\nconst TRANSITION = 'transition';\nconst ANIMATION = 'animation';\n\ntype AnimationTypes = typeof TRANSITION | typeof ANIMATION;\ntype AnimationProperties = 'Delay' | 'Duration';\ntype AnimationStyleKeys = `${AnimationTypes}${AnimationProperties}` | 'transitionProperty';\ntype AnimationStyleDeclarations = Pick<CSSStyleDeclaration, AnimationStyleKeys>;\n\nexport type AnimationDirection = 'in' | 'out';\n\n/**\n * Return a Promise that resolves when all CSS animations and transitions\n * are done on the page. Filters by selector or takes elements directly.\n */\nexport async function awaitAnimations(\n\tthis: Swup,\n\t{\n\t\telements,\n\t\tselector\n\t}: {\n\t\tselector: Options['animationSelector'];\n\t\telements?: NodeListOf<HTMLElement> | HTMLElement[];\n\t}\n): Promise<void> {\n\t// Allow usage of swup without animations: { animationSelector: false }\n\tif (selector === false && !elements) {\n\t\treturn;\n\t}\n\n\t// Allow passing in elements\n\tlet animatedElements: HTMLElement[] = [];\n\tif (elements) {\n\t\tanimatedElements = Array.from(elements);\n\t} else if (selector) {\n\t\tanimatedElements = queryAll(selector, document.body);\n\t\t// Warn if no elements match the selector, but keep things going\n\t\tif (!animatedElements.length) {\n\t\t\tconsole.warn(`[swup] No elements found matching animationSelector \\`${selector}\\``);\n\t\t\treturn;\n\t\t}\n\t}\n\n\tconst awaitedAnimations = animatedElements.map((el) => awaitAnimationsOnElement(el));\n\tconst hasAnimations = awaitedAnimations.filter(Boolean).length > 0;\n\tif (!hasAnimations) {\n\t\tif (selector) {\n\t\t\tconsole.warn(\n\t\t\t\t`[swup] No CSS animation duration defined on elements matching \\`${selector}\\``\n\t\t\t);\n\t\t}\n\t\treturn;\n\t}\n\n\tawait Promise.all(awaitedAnimations);\n}\n\nfunction awaitAnimationsOnElement(element: Element): Promise<void> | false {\n\tconst { type, timeout, propCount } = getTransitionInfo(element);\n\n\t// Resolve immediately if no transition defined\n\tif (!type || !timeout) {\n\t\treturn false;\n\t}\n\n\treturn new Promise((resolve) => {\n\t\tconst endEvent = `${type}end`;\n\t\tconst startTime = performance.now();\n\t\tlet propsTransitioned = 0;\n\n\t\tconst end = () => {\n\t\t\telement.removeEventListener(endEvent, onEnd);\n\t\t\tresolve();\n\t\t};\n\n\t\tconst onEnd: EventListener = (event) => {\n\t\t\t// Skip transitions on child elements\n\t\t\tif (event.target !== element) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (!isTransitionOrAnimationEvent(event)) {\n\t\t\t\tthrow new Error('Not a transition or animation event.');\n\t\t\t}\n\n\t\t\t// Skip transitions that happened before we started listening\n\t\t\tconst elapsedTime = (performance.now() - startTime) / 1000;\n\t\t\tif (elapsedTime < event.elapsedTime) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// End if all properties have transitioned\n\t\t\tif (++propsTransitioned >= propCount) {\n\t\t\t\tend();\n\t\t\t}\n\t\t};\n\n\t\tsetTimeout(() => {\n\t\t\tif (propsTransitioned < propCount) {\n\t\t\t\tend();\n\t\t\t}\n\t\t}, timeout + 1);\n\n\t\telement.addEventListener(endEvent, onEnd);\n\t});\n}\n\nexport function getTransitionInfo(element: Element, expectedType?: AnimationTypes) {\n\tconst styles = window.getComputedStyle(element) as AnimationStyleDeclarations;\n\n\tconst transitionDelays = getStyleProperties(styles, `${TRANSITION}Delay`);\n\tconst transitionDurations = getStyleProperties(styles, `${TRANSITION}Duration`);\n\tconst transitionTimeout = calculateTimeout(transitionDelays, transitionDurations);\n\tconst animationDelays = getStyleProperties(styles, `${ANIMATION}Delay`);\n\tconst animationDurations = getStyleProperties(styles, `${ANIMATION}Duration`);\n\tconst animationTimeout = calculateTimeout(animationDelays, animationDurations);\n\n\tlet type: AnimationTypes | null = null;\n\tlet timeout = 0;\n\tlet propCount = 0;\n\n\tif (expectedType === TRANSITION) {\n\t\tif (transitionTimeout > 0) {\n\t\t\ttype = TRANSITION;\n\t\t\ttimeout = transitionTimeout;\n\t\t\tpropCount = transitionDurations.length;\n\t\t}\n\t} else if (expectedType === ANIMATION) {\n\t\tif (animationTimeout > 0) {\n\t\t\ttype = ANIMATION;\n\t\t\ttimeout = animationTimeout;\n\t\t\tpropCount = animationDurations.length;\n\t\t}\n\t} else {\n\t\ttimeout = Math.max(transitionTimeout, animationTimeout);\n\t\ttype = timeout > 0 ? (transitionTimeout > animationTimeout ? TRANSITION : ANIMATION) : null;\n\t\tpropCount = type\n\t\t\t? type === TRANSITION\n\t\t\t\t? transitionDurations.length\n\t\t\t\t: animationDurations.length\n\t\t\t: 0;\n\t}\n\n\treturn {\n\t\ttype,\n\t\ttimeout,\n\t\tpropCount\n\t};\n}\n\nfunction isTransitionOrAnimationEvent(event: any): event is TransitionEvent | AnimationEvent {\n\treturn [`${TRANSITION}end`, `${ANIMATION}end`].includes(event.type);\n}\n\nfunction getStyleProperties(styles: AnimationStyleDeclarations, key: AnimationStyleKeys): string[] {\n\treturn (styles[key] || '').split(', ');\n}\n\nfunction calculateTimeout(delays: string[], durations: string[]): number {\n\twhile (delays.length < durations.length) {\n\t\tdelays = delays.concat(delays);\n\t}\n\n\treturn Math.max(...durations.map((duration, i) => toMs(duration) + toMs(delays[i])));\n}\n","import Swup from '../Swup.js';\nimport { createHistoryRecord, updateHistoryRecord, getCurrentUrl, Location } from '../helpers.js';\nimport { FetchOptions } from './fetchPage.js';\nimport { VisitInitOptions } from './Visit.js';\n\nexport type HistoryAction = 'push' | 'replace';\nexport type HistoryDirection = 'forwards' | 'backwards';\n\n/** Define how to navigate to a page. */\ntype NavigationOptions = {\n\t/** Whether this visit is animated. Default: `true` */\n\tanimate?: boolean;\n\t/** Name of a custom animation to run. */\n\tanimation?: string;\n\t/** History action to perform: `push` for creating a new history entry, `replace` for replacing the current entry. Default: `push` */\n\thistory?: HistoryAction;\n};\n\n/**\n * Navigate to a new URL.\n * @param url The URL to navigate to.\n * @param options Options for how to perform this visit.\n * @returns Promise<void>\n */\nexport function navigate(\n\tthis: Swup,\n\turl: string,\n\toptions: NavigationOptions & FetchOptions = {},\n\tinit: Omit<VisitInitOptions, 'to'> = {}\n) {\n\t// Check if the visit should be ignored\n\tif (this.shouldIgnoreVisit(url)) {\n\t\twindow.location.href = url;\n\t\treturn;\n\t}\n\n\tconst { url: to, hash } = Location.fromUrl(url);\n\tthis.visit = this.createVisit({ ...init, to, hash });\n\tthis.performNavigation(to, options);\n}\n\n/**\n * Start a visit to a new URL.\n *\n * Internal method that assumes the visit context has already been created.\n *\n * As a user, you should call `swup.navigate(url)` instead.\n *\n * @param url The URL to navigate to.\n * @param options Options for how to perform this visit.\n * @returns Promise<void>\n */\nexport async function performNavigation(\n\tthis: Swup,\n\turl: string,\n\toptions: NavigationOptions & FetchOptions = {}\n) {\n\tif (typeof url !== 'string') {\n\t\tthrow new Error(`swup.navigate() requires a URL parameter`);\n\t}\n\n\tconst { el } = this.visit.trigger;\n\tthis.visit.to.url = Location.fromUrl(url).url;\n\toptions.referrer = options.referrer || this.currentPageUrl;\n\n\tif (options.animate === false) {\n\t\tthis.visit.animation.animate = false;\n\t}\n\n\t// Clean up old animation classes\n\tif (!this.visit.animation.animate) {\n\t\tthis.classes.clear();\n\t}\n\n\t// Get history action from option or attribute on trigger element\n\tconst history = options.history || el?.getAttribute('data-swup-history') || undefined;\n\tif (history && ['push', 'replace'].includes(history)) {\n\t\tthis.visit.history.action = history as HistoryAction;\n\t}\n\n\t// Get custom animation name from option or attribute on trigger element\n\tconst animation = options.animation || el?.getAttribute('data-swup-animation') || undefined;\n\tif (animation) {\n\t\tthis.visit.animation.name = animation;\n\t}\n\n\ttry {\n\t\tawait this.hooks.call('visit:start');\n\n\t\t// Begin fetching page\n\t\tconst pagePromise = this.hooks.call(\n\t\t\t'page:request',\n\t\t\t{ url: this.visit.to.url, options },\n\t\t\tasync (visit, { options }) => await this.fetchPage(visit.to.url as string, options)\n\t\t);\n\n\t\t// Create history record if this is not a popstate call (with or without anchor)\n\t\tif (!this.visit.history.popstate) {\n\t\t\tconst newUrl = url + (this.visit.scroll.target || '');\n\t\t\tif (this.visit.history.action === 'replace') {\n\t\t\t\tupdateHistoryRecord(newUrl);\n\t\t\t} else {\n\t\t\t\tconst index = this.currentHistoryIndex + 1;\n\t\t\t\tcreateHistoryRecord(newUrl, { index });\n\t\t\t}\n\t\t}\n\n\t\tthis.currentPageUrl = getCurrentUrl();\n\n\t\t// Wait for page before starting to animate out?\n\t\tif (this.visit.animation.wait) {\n\t\t\tconst { html } = await pagePromise;\n\t\t\tthis.visit.to.html = html;\n\t\t}\n\n\t\t// Wait for page to load and leave animation to finish\n\t\tconst animationPromise = this.animatePageOut();\n\t\tconst [page] = await Promise.all([pagePromise, animationPromise]);\n\n\t\t// Render page: replace content and scroll to top/fragment\n\t\tawait this.renderPage(this.visit.to.url, page);\n\n\t\t// Wait for enter animation\n\t\tawait this.animatePageIn();\n\n\t\t// Finalize visit\n\t\tawait this.hooks.call('visit:end', undefined, () => this.classes.clear());\n\n\t\t// Reset visit info after finish?\n\t\t// if (this.visit.to && this.isSameResolvedUrl(this.visit.to.url, requestedUrl)) {\n\t\t// \tthis.createVisit({ to: undefined });\n\t\t// }\n\t} catch (error: unknown) {\n\t\t// Return early if error is undefined (probably aborted preload request)\n\t\tif (!error) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Log to console as we swallow almost all hook errors\n\t\tconsole.error(error);\n\n\t\t// Rewrite `skipPopStateHandling` to redirect manually when `history.go` is processed\n\t\tthis.options.skipPopStateHandling = () => {\n\t\t\twindow.location.href = this.visit.to.url as string;\n\t\t\treturn true;\n\t\t};\n\n\t\t// Go back to the actual page we're still at\n\t\twindow.history.go(-1);\n\t}\n}\n","import Swup from '../Swup.js';\nimport { Location } from '../helpers.js';\n\n/** A page object as used by swup and its cache. */\nexport interface PageData {\n\t/** The URL of the page */\n\turl: string;\n\t/** The complete HTML response received from the server */\n\thtml: string;\n}\n\n/** Define how a page is fetched. */\nexport interface FetchOptions extends RequestInit {\n\t/** The request method. */\n\tmethod?: 'GET' | 'POST';\n\t/** The body of the request: raw string, form data object or URL params. */\n\tbody?: string | FormData | URLSearchParams;\n\t/** The headers of the request: key/value object. */\n\theaders?: Record<string, string>;\n}\n\nexport class FetchError extends Error {\n\turl: string;\n\tstatus: number;\n\tconstructor(message: string, details: { url: string; status: number }) {\n\t\tsuper(message);\n\t\tthis.name = 'FetchError';\n\t\tthis.url = details.url;\n\t\tthis.status = details.status;\n\t}\n}\n\n/**\n * Fetch a page from the server, return it and cache it.\n */\nexport async function fetchPage(\n\tthis: Swup,\n\turl: URL | string,\n\toptions: FetchOptions & { triggerHooks?: boolean } = {}\n): Promise<PageData> {\n\turl = Location.fromUrl(url).url;\n\n\tif (this.cache.has(url)) {\n\t\tconst page = this.cache.get(url) as PageData;\n\t\tif (options.triggerHooks !== false) {\n\t\t\tawait this.hooks.call('page:load', { page, cache: true });\n\t\t}\n\t\treturn page;\n\t}\n\n\tconst headers = { ...this.options.requestHeaders, ...options.headers };\n\toptions = { ...options, headers };\n\n\t// Allow hooking before this and returning a custom response-like object (e.g. custom fetch implementation)\n\tconst response: Response = await this.hooks.call(\n\t\t'fetch:request',\n\t\t{ url, options },\n\t\t(visit, { url, options }) => fetch(url, options)\n\t);\n\n\tconst { status, url: responseUrl } = response;\n\tconst html = await response.text();\n\n\tif (status === 500) {\n\t\tthis.hooks.call('fetch:error', { status, response, url: responseUrl });\n\t\tthrow new FetchError(`Server error: ${responseUrl}`, { status, url: responseUrl });\n\t}\n\n\tif (!html) {\n\t\tthrow new FetchError(`Empty response: ${responseUrl}`, { status, url: responseUrl });\n\t}\n\n\t// Resolve real url after potential redirect\n\tconst { url: finalUrl } = Location.fromUrl(responseUrl);\n\tconst page = { url: finalUrl, html };\n\n\t// Only save cache entry for non-redirects\n\tif (url === finalUrl) {\n\t\tthis.cache.set(page.url, page);\n\t}\n\n\tif (options.triggerHooks !== false) {\n\t\tawait this.hooks.call('page:load', { page, cache: false });\n\t}\n\n\treturn page;\n}\n","import Swup from '../Swup.js';\nimport { classify } from '../helpers.js';\n\n/**\n * Perform the out/leave animation of the current page.\n * @returns Promise<void>\n */\nexport const animatePageOut = async function (this: Swup) {\n\tif (!this.visit.animation.animate) {\n\t\tawait this.hooks.call('animation:skip');\n\t\treturn;\n\t}\n\n\tawait this.hooks.call('animation:out:start', undefined, (visit) => {\n\t\tthis.classes.add('is-changing', 'is-leaving', 'is-animating');\n\t\tif (visit.history.popstate) {\n\t\t\tthis.classes.add('is-popstate');\n\t\t}\n\t\tif (visit.animation.name) {\n\t\t\tthis.classes.add(`to-${classify(visit.animation.name)}`);\n\t\t}\n\t});\n\n\tawait this.hooks.call('animation:out:await', { skip: false }, async (visit, { skip }) => {\n\t\tif (skip) return;\n\t\tawait this.awaitAnimations({ selector: visit.animation.selector });\n\t});\n\n\tawait this.hooks.call('animation:out:end');\n};\n","import Swup, { Options } from '../Swup.js';\nimport { PageData } from './fetchPage.js';\n\n/**\n * Perform the replacement of content after loading a page.\n *\n * It takes an object with the page data as returned from `fetchPage` and a list\n * of container selectors to replace.\n *\n * @returns Whether all containers were replaced.\n */\nexport const replaceContent = function (\n\tthis: Swup,\n\t{ html }: PageData,\n\t{ containers }: { containers: Options['containers'] } = this.options\n): boolean {\n\tconst incomingDocument = new DOMParser().parseFromString(html, 'text/html');\n\n\t// Update browser title\n\tconst title = incomingDocument.querySelector('title')?.innerText || '';\n\tdocument.title = title;\n\n\t// Update content containers\n\tconst replaced = containers\n\t\t.map((selector) => {\n\t\t\tconst currentEl = document.querySelector(selector);\n\t\t\tconst incomingEl = incomingDocument.querySelector(selector);\n\t\t\tif (currentEl && incomingEl) {\n\t\t\t\tcurrentEl.replaceWith(incomingEl);\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tif (!currentEl) {\n\t\t\t\tconsole.warn(`[swup] Container missing in current document: ${selector}`);\n\t\t\t}\n\t\t\tif (!incomingEl) {\n\t\t\t\tconsole.warn(`[swup] Container missing in incoming document: ${selector}`);\n\t\t\t}\n\t\t\treturn false;\n\t\t})\n\t\t.filter(Boolean);\n\n\treturn replaced.length === containers.length;\n};\n","import Swup from '../Swup.js';\n\n/**\n * Update the scroll position after page render.\n * @returns Promise<boolean>\n */\nexport const scrollToContent = function (this: Swup): boolean {\n\tconst options: ScrollIntoViewOptions = { behavior: 'auto' };\n\tconst { target, reset } = this.visit.scroll;\n\tlet scrolled = false;\n\n\tif (target) {\n\t\tscrolled = this.hooks.callSync(\n\t\t\t'scroll:anchor',\n\t\t\t{ hash: target, options },\n\t\t\t(visit, { hash, options }) => {\n\t\t\t\tconst anchor = this.getAnchorElement(hash || '');\n\t\t\t\tif (anchor) {\n\t\t\t\t\tanchor.scrollIntoView(options);\n\t\t\t\t}\n\t\t\t\treturn !!anchor;\n\t\t\t}\n\t\t);\n\t}\n\n\tif (reset && !scrolled) {\n\t\tscrolled = this.hooks.callSync('scroll:top', { options }, (visit, { options }) => {\n\t\t\twindow.scrollTo({ top: 0, left: 0, ...options });\n\t\t\treturn true;\n\t\t});\n\t}\n\n\treturn scrolled;\n};\n","import Swup from '../Swup.js';\nimport { nextTick } from '../utils.js';\n\n/**\n * Perform the in/enter animation of the next page.\n * @returns Promise<void>\n */\nexport const animatePageIn = async function (this: Swup) {\n\tif (!this.visit.animation.animate) {\n\t\treturn;\n\t}\n\n\tconst animation = this.hooks.call(\n\t\t'animation:in:await',\n\t\t{ skip: false },\n\t\tasync (visit, { skip }) => {\n\t\t\tif (skip) return;\n\t\t\tawait this.awaitAnimations({ selector: visit.animation.selector });\n\t\t}\n\t);\n\n\tawait nextTick();\n\n\tawait this.hooks.call('animation:in:start', undefined, () => {\n\t\tthis.classes.remove('is-animating');\n\t});\n\n\tawait animation;\n\n\tawait this.hooks.call('animation:in:end');\n};\n","import { updateHistoryRecord, getCurrentUrl, classify } from '../helpers.js';\nimport Swup from '../Swup.js';\nimport { PageData } from './fetchPage.js';\n\n/**\n * Render the next page: replace the content and update scroll position.\n * @returns Promise<void>\n */\nexport const renderPage = async function (this: Swup, requestedUrl: string, page: PageData) {\n\tconst { url, html } = page;\n\n\tthis.classes.remove('is-leaving');\n\n\t// do nothing if another page was requested in the meantime\n\tif (!this.isSameResolvedUrl(getCurrentUrl(), requestedUrl)) {\n\t\treturn;\n\t}\n\n\t// update state if the url was redirected\n\tif (!this.isSameResolvedUrl(getCurrentUrl(), url)) {\n\t\tupdateHistoryRecord(url);\n\t\tthis.currentPageUrl = getCurrentUrl();\n\t\tthis.visit.to.url = this.currentPageUrl;\n\t}\n\n\t// only add for animated page loads\n\tif (this.visit.animation.animate) {\n\t\tthis.classes.add('is-rendering');\n\t}\n\n\t// save html into visit context for easier retrieval\n\tthis.visit.to.html = html;\n\n\t// replace content: allow handlers and plugins to overwrite paga data and containers\n\tawait this.hooks.call('content:replace', { page }, (visit, { page }) => {\n\t\tconst success = this.replaceContent(page, { containers: visit.containers });\n\t\tif (!success) {\n\t\t\tthrow new Error('[swup] Container mismatch, aborting');\n\t\t}\n\t\tif (visit.animation.animate) {\n\t\t\t// Make sure to add these classes to new containers as well\n\t\t\tthis.classes.add('is-animating', 'is-changing', 'is-rendering');\n\t\t\tif (visit.animation.name) {\n\t\t\t\tthis.classes.add(`to-${classify(visit.animation.name)}`);\n\t\t\t}\n\t\t}\n\t});\n\n\t// scroll into view: either anchor or top of page\n\tawait this.hooks.call('content:scroll', undefined, () => {\n\t\treturn this.scrollToContent();\n\t});\n\n\tawait this.hooks.call('page:view', { url: this.currentPageUrl, title: document.title });\n\n\t// empty cache if it's disabled (in case preload plugin filled it)\n\tif (!this.options.cache) {\n\t\tthis.cache.clear();\n\t}\n};\n","import Swup from '../Swup.js';\n\nexport type Plugin = {\n\t/** Identify as a swup plugin */\n\tisSwupPlugin: true;\n\t/** Name of this plugin */\n\tname: string;\n\t/** Version of this plugin. Currently not in use, defined here for backward compatiblity. */\n\tversion?: string;\n\t/** The swup instance that mounted this plugin */\n\tswup?: Swup;\n\t/** Version requirements of this plugin. Example: `{ swup: '>=4' }` */\n\trequires?: Record<string, string | string[]>;\n\t/** Run on mount */\n\tmount: () => void;\n\t/** Run on unmount */\n\tunmount: () => void;\n\t_beforeMount?: () => void;\n\t_afterUnmount?: () => void;\n\t_checkRequirements?: () => boolean;\n};\n\nconst isSwupPlugin = (maybeInvalidPlugin: unknown): maybeInvalidPlugin is Plugin => {\n\t// @ts-ignore\n\treturn maybeInvalidPlugin?.isSwupPlugin;\n};\n\n/** Install a plugin. */\nexport const use = function (this: Swup, plugin: unknown) {\n\tif (!isSwupPlugin(plugin)) {\n\t\tconsole.error('Not a swup plugin instance', plugin);\n\t\treturn;\n\t}\n\n\tplugin.swup = this;\n\tif (plugin._checkRequirements) {\n\t\tif (!plugin._checkRequirements()) {\n\t\t\treturn;\n\t\t}\n\t}\n\tif (plugin._beforeMount) {\n\t\tplugin._beforeMount();\n\t}\n\tplugin.mount();\n\n\tthis.plugins.push(plugin);\n\n\treturn this.plugins;\n};\n\n/** Uninstall a plugin. */\nexport function unuse(this: Swup, pluginOrName: Plugin | string) {\n\tconst plugin = this.findPlugin(pluginOrName);\n\tif (!plugin) {\n\t\tconsole.error('No such plugin', plugin);\n\t\treturn;\n\t}\n\n\tplugin.unmount();\n\tif (plugin._afterUnmount) {\n\t\tplugin._afterUnmount();\n\t}\n\n\tthis.plugins = this.plugins.filter((p) => p !== plugin);\n\n\treturn this.plugins;\n}\n\n/** Find a plugin by name or reference. */\nexport function findPlugin(this: Swup, pluginOrName: Plugin | string) {\n\treturn this.plugins.find(\n\t\t(plugin) =>\n\t\t\tplugin === pluginOrName ||\n\t\t\tplugin.name === pluginOrName ||\n\t\t\tplugin.name === `Swup${pluginOrName}`\n\t);\n}\n","import { DelegateEvent } from 'delegate-it';\n\nimport version from './config/version.js';\n\nimport { delegateEvent, getCurrentUrl, Location, updateHistoryRecord } from './helpers.js';\nimport { DelegateEventUnsubscribe } from './helpers/delegateEvent.js';\n\nimport { Cache } from './modules/Cache.js';\nimport { Classes } from './modules/Classes.js';\nimport { Visit, createVisit } from './modules/Visit.js';\nimport { Hooks } from './modules/Hooks.js';\nimport { getAnchorElement } from './modules/getAnchorElement.js';\nimport { awaitAnimations } from './modules/awaitAnimations.js';\nimport { navigate, performNavigation } from './modules/navigate.js';\nimport { fetchPage } from './modules/fetchPage.js';\nimport { animatePageOut } from './modules/animatePageOut.js';\nimport { replaceContent } from './modules/replaceContent.js';\nimport { scrollToContent } from './modules/scrollToContent.js';\nimport { animatePageIn } from './modules/animatePageIn.js';\nimport { renderPage } from './modules/renderPage.js';\nimport { use, unuse, findPlugin, Plugin } from './modules/plugins.js';\nimport { nextTick } from './utils.js';\n\n/** Options for customizing swup's behavior. */\nexport type Options = {\n\t/** Whether history visits are animated. Default: `false` */\n\tanimateHistoryBrowsing: boolean;\n\t/** Selector for detecting animation timing. Default: `[class*=\"transition-\"]` */\n\tanimationSelector: string | false;\n\t/** Elements on which to add animation classes. Default: `html` element */\n\tanimationScope: 'html' | 'containers';\n\t/** Enable in-memory page cache. Default: `true` */\n\tcache: boolean;\n\t/** Content containers to be replaced on page visits. Default: `['#swup']` */\n\tcontainers: string[];\n\t/** Callback for ignoring visits. Receives the element and event that triggered the visit. */\n\tignoreVisit: (url: string, { el, event }: { el?: Element; event?: Event }) => boolean;\n\t/** Selector for links that trigger visits. Default: `'a[href]'` */\n\tlinkSelector: string;\n\t/** Plugins to register on startup. */\n\tplugins: Plugin[];\n\t/** Custom headers sent along with fetch requests. */\n\trequestHeaders: Record<string, string>;\n\t/** Rewrite URLs before loading them. */\n\tresolveUrl: (url: string) => string;\n\t/** Callback for telling swup to ignore certain popstate events. */\n\tskipPopStateHandling: (event: any) => boolean;\n};\n\n/** Swup page transition library. */\nexport default class Swup {\n\t/** Library version */\n\tversion: string = version;\n\t/** Options passed into the instance */\n\toptions: Options;\n\t/** Registered plugin instances */\n\tplugins: Plugin[] = [];\n\t/** Data about the current visit */\n\tvisit: Visit;\n\t/** Cache instance */\n\tcache: Cache;\n\t/** Hook registry */\n\thooks: Hooks;\n\t/** Animation class manager */\n\tclasses: Classes;\n\t/** URL of the currently visible page */\n\tcurrentPageUrl = getCurrentUrl();\n\t/** Index of the current history entry */\n\tcurrentHistoryIndex = 1;\n\t/** Delegated event subscription handle */\n\tprivate clickDelegate?: DelegateEventUnsubscribe;\n\n\tnavigate = navigate;\n\tperformNavigation = performNavigation;\n\tanimatePageOut = animatePageOut;\n\trenderPage = renderPage;\n\treplaceContent = replaceContent;\n\tscrollToContent = scrollToContent;\n\tanimatePageIn = animatePageIn;\n\tdelegateEvent = delegateEvent;\n\tfetchPage = fetchPage;\n\tawaitAnimations = awaitAnimations;\n\tgetAnchorElement = getAnchorElement;\n\tuse = use;\n\tunuse = unuse;\n\tfindPlugin = findPlugin;\n\tgetCurrentUrl = getCurrentUrl;\n\tcreateVisit = createVisit;\n\tlog: (message: string, context?: any) => void = () => {}; // here so it can be used by plugins\n\n\t/** Default options before merging user options */\n\tdefaults: Options = {\n\t\tanimateHistoryBrowsing: false,\n\t\tanimationSelector: '[class*=\"transition-\"]',\n\t\tanimationScope: 'html',\n\t\tcache: true,\n\t\tcontainers: ['#swup'],\n\t\tignoreVisit: (url, { el, event } = {}) => !!el?.closest('[data-no-swup]'),\n\t\tlinkSelector: 'a[href]',\n\t\tplugins: [],\n\t\tresolveUrl: (url) => url,\n\t\trequestHeaders: {\n\t\t\t'X-Requested-With': 'swup',\n\t\t\t'Accept': 'text/html, application/xhtml+xml'\n\t\t},\n\t\tskipPopStateHandling: (event) => event.state?.source !== 'swup'\n\t};\n\n\tconstructor(options: Partial<Options> = {}) {\n\t\t// Merge defaults and options\n\t\tthis.options = { ...this.defaults, ...options };\n\n\t\tthis.linkClickHandler = this.linkClickHandler.bind(this);\n\t\tthis.popStateHandler = this.popStateHandler.bind(this);\n\n\t\tthis.cache = new Cache(this);\n\t\tthis.classes = new Classes(this);\n\t\tthis.hooks = new Hooks(this);\n\t\tthis.visit = this.createVisit({ to: undefined });\n\n\t\tif (!this.checkRequirements()) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.enable();\n\t}\n\n\tcheckRequirements() {\n\t\tif (typeof Promise === 'undefined') {\n\t\t\tconsole.warn('Promise is not supported');\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t}\n\n\t/** Enable this instance, adding listeners and classnames. */\n\tasync enable() {\n\t\t// Add event listener\n\t\tconst { linkSelector } = this.options;\n\t\tthis.clickDelegate = this.delegateEvent(linkSelector, 'click', this.linkClickHandler);\n\n\t\twindow.addEventListener('popstate', this.popStateHandler);\n\n\t\t// Initial save to cache\n\t\tif (this.options.cache) {\n\t\t\t// Disabled to avoid caching modified dom state: logic moved to preload plugin\n\t\t\t// https://github.com/swup/swup/issues/475\n\t\t}\n\n\t\t// Mount plugins\n\t\tthis.options.plugins.forEach((plugin) => this.use(plugin));\n\n\t\t// Modify initial history record\n\t\tupdateHistoryRecord(null, { index: 1 });\n\n\t\t// Give consumers a chance to hook into enable\n\t\tawait nextTick();\n\n\t\t// Trigger enable hook\n\t\tawait this.hooks.call('enable', undefined, () => {\n\t\t\t// Add swup-enabled class to html tag\n\t\t\tdocument.documentElement.classList.add('swup-enabled');\n\t\t});\n\t}\n\n\t/** Disable this instance, removing listeners and classnames. */\n\tasync destroy() {\n\t\t// remove delegated listener\n\t\tthis.clickDelegate!.destroy();\n\n\t\t// remove popstate listener\n\t\twindow.removeEventListener('popstate', this.popStateHandler);\n\n\t\t// empty cache\n\t\tthis.cache.clear();\n\n\t\t// unmount plugins\n\t\tthis.options.plugins.forEach((plugin) => this.unuse(plugin));\n\n\t\t// trigger disable hook\n\t\tawait this.hooks.call('disable', undefined, () => {\n\t\t\t// remove swup-enabled class from html tag\n\t\t\tdocument.documentElement.classList.remove('swup-enabled');\n\t\t});\n\n\t\t// remove handlers\n\t\tthis.hooks.clear();\n\t}\n\n\t/** Determine if a visit should be ignored by swup, based on URL or trigger element. */\n\tshouldIgnoreVisit(href: string, { el, event }: { el?: Element; event?: Event } = {}) {\n\t\tconst { origin, url, hash } = Location.fromUrl(href);\n\n\t\t// Ignore if the new origin doesn't match the current one\n\t\tif (origin !== window.location.origin) {\n\t\t\treturn true;\n\t\t}\n\n\t\t// Ignore if the link/form would open a new window (or none at all)\n\t\tif (el && this.triggerWillOpenNewWindow(el)) {\n\t\t\treturn true;\n\t\t}\n\n\t\t// Ignore if the visit should be ignored as per user options\n\t\tif (this.options.ignoreVisit(url + hash, { el, event })) {\n\t\t\treturn true;\n\t\t}\n\n\t\t// Finally, allow the visit\n\t\treturn false;\n\t}\n\n\tlinkClickHandler(event: DelegateEvent<MouseEvent>) {\n\t\tconst el = event.delegateTarget as HTMLAnchorElement;\n\t\tconst { href, url, hash } = Location.fromElement(el);\n\n\t\t// Exit early if the link should be ignored\n\t\tif (this.shouldIgnoreVisit(href, { el, event })) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.visit = this.createVisit({ to: url, hash, el, event });\n\n\t\t// Exit early if control key pressed\n\t\tif (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) {\n\t\t\tthis.hooks.call('link:newtab', { href });\n\t\t\treturn;\n\t\t}\n\n\t\t// Exit early if other than left mouse button\n\t\tif (event.button !== 0) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.hooks.callSync('link:click', { el, event }, () => {\n\t\t\tconst from = this.visit.from.url ?? '';\n\n\t\t\tevent.preventDefault();\n\n\t\t\t// Handle links to the same page: with or without hash\n\t\t\tif (!url || url === from) {\n\t\t\t\tif (hash) {\n\t\t\t\t\tthis.hooks.callSync('link:anchor', { hash }, () => {\n\t\t\t\t\t\tupdateHistoryRecord(url + hash);\n\t\t\t\t\t\tthis.scrollToContent();\n\t\t\t\t\t});\n\t\t\t\t} else {\n\t\t\t\t\tthis.hooks.callSync('link:self', undefined, () => {\n\t\t\t\t\t\tthis.scrollToContent();\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Exit early if the resolved path hasn't changed\n\t\t\tif (this.isSameResolvedUrl(url, from)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Finally, proceed with loading the page\n\t\t\tthis.performNavigation(url);\n\t\t});\n\t}\n\n\t/** Determine whether an element will open a new tab when clicking/activating. */\n\ttriggerWillOpenNewWindow(triggerEl: Element) {\n\t\tif (triggerEl.matches('[download], [target=\"_blank\"]')) {\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\tpopStateHandler(event: PopStateEvent) {\n\t\tconst href = event.state?.url ?? location.href;\n\n\t\t// Exit early if this event should be ignored\n\t\tif (this.options.skipPopStateHandling(event)) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Exit early if the resolved path hasn't changed\n\t\tif (this.isSameResolvedUrl(getCurrentUrl(), this.currentPageUrl)) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Exit early if the link should be ignored\n\t\tif (this.shouldIgnoreVisit(href, { event })) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { url, hash } = Location.fromUrl(href);\n\t\tconst animate = this.options.animateHistoryBrowsing;\n\t\tconst resetScroll = this.options.animateHistoryBrowsing;\n\n\t\tthis.visit = this.createVisit({\n\t\t\tto: url,\n\t\t\thash,\n\t\t\tevent,\n\t\t\tanimate,\n\t\t\tresetScroll\n\t\t});\n\n\t\t// Mark as popstate visit\n\t\tthis.visit.history.popstate = true;\n\n\t\t// Determine direction of history visit\n\t\tconst index = Number(event.state?.index);\n\t\tif (index) {\n\t\t\tconst direction = index - this.currentHistoryIndex > 0 ? 'forwards' : 'backwards';\n\t\t\tthis.visit.history.direction = direction;\n\t\t}\n\n\t\t// Does this even do anything?\n\t\t// if (!hash) {\n\t\t// \tevent.preventDefault();\n\t\t// }\n\n\t\tthis.hooks.callSync('history:popstate', { event }, () => {\n\t\t\tthis.performNavigation(url);\n\t\t});\n\t}\n\n\t/**\n\t * Utility function to validate and run the global option 'resolveUrl'\n\t * @param {string} url\n\t * @returns {string} the resolved url\n\t */\n\tresolveUrl(url: string) {\n\t\tif (typeof this.options.resolveUrl !== 'function') {\n\t\t\tconsole.warn(`[swup] options.resolveUrl expects a callback function.`);\n\t\t\treturn url;\n\t\t}\n\t\tconst result = this.options.resolveUrl(url);\n\t\tif (!result || typeof result !== 'string') {\n\t\t\tconsole.warn(`[swup] options.resolveUrl needs to return a url`);\n\t\t\treturn url;\n\t\t}\n\t\tif (result.startsWith('//') || result.startsWith('http')) {\n\t\t\tconsole.warn(`[swup] options.resolveUrl needs to return a relative url`);\n\t\t\treturn url;\n\t\t}\n\t\treturn result;\n\t}\n\n\t/**\n\t * Compares the resolved version of two paths and returns true if they are the same\n\t * @param {string} url1\n\t * @param {string} url2\n\t * @returns {boolean}\n\t */\n\tisSameResolvedUrl(url1: string, url2: string) {\n\t\treturn this.resolveUrl(url1) === this.resolveUrl(url2);\n\t}\n}\n","import { match } from 'path-to-regexp';\n\nimport type {\n\tPath,\n\tParseOptions,\n\tTokensToRegexpOptions,\n\tRegexpToFunctionOptions,\n\tMatchFunction\n} from 'path-to-regexp';\n\nexport { Path };\n\n/** Create a match function from a path pattern that checks if a URLs matches it. */\nexport const matchPath = <P extends object = object>(\n\tpath: Path,\n\toptions?: ParseOptions & TokensToRegexpOptions & RegexpToFunctionOptions\n): MatchFunction<P> => {\n\ttry {\n\t\treturn match<P>(path, options);\n\t} catch (error) {\n\t\tthrow new Error(`[swup] Error parsing path \"${path}\":\\n${error}`);\n\t}\n};\n"],"names":["classify","text","fallback","String","toLowerCase","replace","getCurrentUrl","_temp","hash","location","pathname","search","createHistoryRecord","url","customData","data","random","Math","source","history","pushState","updateHistoryRecord","state","replaceState","delegateEvent","selector","type","callback","options","controller","AbortController","signal","delegate","destroy","abort","Location","URL","constructor","base","document","baseURI","super","toString","this","static","el","href","getAttribute","Cache","swup","pages","Map","size","all","has","resolve","get","set","page","hooks","callSync","update","delete","clear","prune","predicate","forEach","urlToResolve","fromUrl","resolveUrl","query","context","querySelector","queryAll","Array","from","querySelectorAll","nextTick","Promise","requestAnimationFrame","isPromise","obj","then","runAsPromise","func","args","reject","result","escapeCssIdentifier","ident","window","CSS","escape","toMs","s","Number","slice","Classes","swupClasses","selectors","scope","visit","animation","containers","isArray","join","targets","trim","add","target","classList","call","arguments","remove","className","split","filter","c","isSwupClass","some","startsWith","createVisit","_ref","to","currentPageUrl","animate","name","event","action","resetScroll","reset","wait","animationScope","animationSelector","trigger","popstate","direction","undefined","scroll","pact","value","_Pact","v","_settle","bind","o","observer","onFulfilled","onRejected","e","_this","thenable","Hooks","registry","init","hook","create","exists","ledger","console","error","on","handler","warn","id","registration","off","before","once","defaultHandler","after","getHandlers","run","dispatchDomEvent","runSync","registrations","_this2","results","body","check","_iteratorSymbol","step","iterator","_cycle","next","done","_isSettledPact","return","_fixup","TypeError","values","i","push","array","_forOf","_ref2","found","replaced","sort","sortRegistrations","_ref3","_ref4","_ref5","length","index","createDefaultHandler","a","b","priority","dispatchEvent","CustomEvent","detail","getAnchorElement","charAt","substring","decoded","decodeURIComponent","element","getElementById","awaitAnimations","elements","animatedElements","awaitedAnimations","map","timeout","propCount","expectedType","styles","getComputedStyle","transitionDelays","getStyleProperties","TRANSITION","transitionDurations","transitionTimeout","calculateTimeout","animationDelays","ANIMATION","animationDurations","animationTimeout","max","getTransitionInfo","endEvent","startTime","performance","now","propsTransitioned","end","removeEventListener","onEnd","includes","isTransitionOrAnimationEvent","Error","elapsedTime","setTimeout","addEventListener","awaitAnimationsOnElement","Boolean","key","delays","durations","concat","duration","performNavigation","referrer","classes","_temp2","animationPromise","animatePageOut","pagePromise","renderPage","animatePageIn","fetchPage","newUrl","currentHistoryIndex","html","_catch","skipPopStateHandling","go","navigate","shouldIgnoreVisit","_exit","_temp5","_result","headers","requestHeaders","fetch","response","status","responseUrl","FetchError","finalUrl","cache","_temp3","triggerHooks","_temp4","message","details","skip","replaceContent","_incomingDocument$que","incomingDocument","DOMParser","parseFromString","title","innerText","currentEl","incomingEl","replaceWith","scrollToContent","behavior","scrolled","anchor","scrollIntoView","scrollTo","top","left","requestedUrl","isSameResolvedUrl","use","plugin","maybeInvalidPlugin","isSwupPlugin","_checkRequirements","_beforeMount","mount","plugins","unuse","pluginOrName","findPlugin","unmount","_afterUnmount","p","find","version","clickDelegate","log","defaults","animateHistoryBrowsing","ignoreVisit","closest","linkSelector","Accept","_event$state","linkClickHandler","popStateHandler","checkRequirements","enable","documentElement","origin","triggerWillOpenNewWindow","delegateTarget","fromElement","metaKey","ctrlKey","shiftKey","altKey","button","preventDefault","triggerEl","matches","_event$state2","_event$state3","url1","url2","_element","offsetHeight","matchPath","path","match"],"mappings":"yJACa,MAAAA,EAAWA,CAACC,EAAcC,IACvBC,OAAOF,GACpBG,cAGAC,QAAQ,YAAa,KACrBA,QAAQ,WAAY,IACpBA,QAAQ,OAAQ,KAChBA,QAAQ,WAAY,KACLH,GAAY,GCTjBI,EAAgB,SAAAC,GAAC,IAAAC,KAAEA,QAA6B,IAAzBD,EAAyB,CAAE,EAAAA,EAC9D,OAAOE,SAASC,SAAWD,SAASE,QAAUH,EAAOC,SAASD,KAAO,GACtE,ECAaI,EAAsB,SAClCC,EACA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ACf,QAAQyC,WAEvB,OADA0F,QAAQI,KAAK,0DACNtJ,EAER,MAAM0E,EAAS5C,KAAKf,QAAQyC,WAAWxD,GACvC,OAAK0E,GAA4B,iBAAXA,EAIlBA,EAAOiC,WAAW,OAASjC,EAAOiC,WAAW,SAChDuC,QAAQI,KAAK,4DACNtJ,GAED0E,GAPNwE,QAAQI,KAAK,mDACNtJ,EAOT,CAQAgT,kBAAkB6C,EAAcC,GAC/B,OAAOhU,KAAK0B,WAAWqS,KAAU/T,KAAK0B,WAAWsS,EAClD,sFd9S2BlJ,GAAqB,IAAAmJ,EAEhD,OAAOA,OAAPA,EADAnJ,EAAUA,GAAWlL,SAAS2I,WACvB0L,EAAAA,EAASC,YACjB,gEexCyBC,CACxBC,EACAnV,KAEA,IACC,OAAOoV,EAAKA,MAAID,EAAMnV,EACtB,CAAC,MAAOoI,GACR,MAAM,IAAI2F,MAAM,8BAA8BoH,QAAW/M,IACzD"}
1
+ {"version":3,"file":"Swup.cjs","sources":["../src/helpers/classify.ts","../src/helpers/getCurrentUrl.ts","../src/helpers/createHistoryRecord.ts","../src/helpers/updateHistoryRecord.ts","../src/helpers/delegateEvent.ts","../src/helpers/Location.ts","../src/modules/Cache.ts","../src/utils/index.ts","../src/modules/Classes.ts","../src/modules/Visit.ts","../src/modules/Hooks.ts","../src/modules/getAnchorElement.ts","../src/modules/awaitAnimations.ts","../src/modules/navigate.ts","../src/modules/fetchPage.ts","../src/modules/animatePageOut.ts","../src/modules/replaceContent.ts","../src/modules/scrollToContent.ts","../src/modules/animatePageIn.ts","../src/modules/renderPage.ts","../src/modules/plugins.ts","../src/modules/resolveUrl.ts","../src/Swup.ts","../src/helpers/matchPath.ts"],"sourcesContent":["/** Turn a string into a slug by lowercasing and replacing whitespace. */\nexport const classify = (text: string, fallback?: string): string => {\n\tconst output = String(text)\n\t\t.toLowerCase()\n\t\t// .normalize('NFD') // split an accented letter in the base letter and the acent\n\t\t// .replace(/[\\u0300-\\u036f]/g, '') // remove all previously split accents\n\t\t.replace(/[\\s/_.]+/g, '-') // replace spaces and _./ with '-'\n\t\t.replace(/[^\\w-]+/g, '') // remove all non-word chars\n\t\t.replace(/--+/g, '-') // replace repeating '-' with single '-'\n\t\t.replace(/^-+|-+$/g, ''); // trim '-' from edges\n\treturn output || fallback || '';\n};\n","/** Get the current page URL: path name + query params. Optionally including hash. */\nexport const getCurrentUrl = ({ hash }: { hash?: boolean } = {}): string => {\n\treturn location.pathname + location.search + (hash ? location.hash : '');\n};\n","import { getCurrentUrl } from './getCurrentUrl.js';\n\n/** Create a new history record with a custom swup identifier. */\nexport const createHistoryRecord = (\n\turl: string,\n\tcustomData: Record<string, unknown> = {}\n): void => {\n\turl = url || getCurrentUrl({ hash: true });\n\tconst data = {\n\t\turl,\n\t\trandom: Math.random(),\n\t\tsource: 'swup',\n\t\t...customData\n\t};\n\thistory.pushState(data, '', url);\n};\n","import { getCurrentUrl } from './getCurrentUrl.js';\n\n/** Update the current history record with a custom swup identifier. */\nexport const updateHistoryRecord = (\n\turl: string | null = null,\n\tcustomData: Record<string, unknown> = {}\n): void => {\n\turl = url || getCurrentUrl({ hash: true });\n\tconst data = {\n\t\t...history.state,\n\t\turl,\n\t\trandom: Math.random(),\n\t\tsource: 'swup',\n\t\t...customData\n\t};\n\thistory.replaceState(data, '', url);\n};\n","import delegate, { DelegateEventHandler, DelegateOptions, EventType } from 'delegate-it';\nimport { ParseSelector } from 'typed-query-selector/parser.js';\n\nexport type DelegateEventUnsubscribe = {\n\tdestroy: () => void;\n};\n\n/** Register a delegated event listener. */\nexport const delegateEvent = <Selector extends string, TEvent extends EventType>(\n\tselector: Selector,\n\ttype: TEvent,\n\tcallback: DelegateEventHandler<GlobalEventHandlersEventMap[TEvent]>,\n\toptions?: DelegateOptions\n): DelegateEventUnsubscribe => {\n\tconst controller = new AbortController();\n\toptions = { ...options, signal: controller.signal };\n\tdelegate<string, ParseSelector<Selector, HTMLElement>, TEvent>(\n\t\tselector,\n\t\ttype,\n\t\tcallback,\n\t\toptions\n\t);\n\treturn { destroy: () => controller.abort() };\n};\n","/**\n * A helper for creating a Location from either an element\n * or a URL object/string\n *\n */\nexport class Location extends URL {\n\tconstructor(url: URL | string, base: string = document.baseURI) {\n\t\tsuper(url.toString(), base);\n\t}\n\n\t/**\n\t * The full local path including query params.\n\t */\n\tget url(): string {\n\t\treturn this.pathname + this.search;\n\t}\n\n\t/**\n\t * Instantiate a Location from an element's href attribute\n\t * @param el\n\t * @returns new Location instance\n\t */\n\tstatic fromElement(el: Element): Location {\n\t\tconst href = el.getAttribute('href') || el.getAttribute('xlink:href') || '';\n\t\treturn new Location(href!);\n\t}\n\n\t/**\n\t * Instantiate a Location from a URL object or string\n\t * @param url\n\t * @returns new Location instance\n\t */\n\tstatic fromUrl(url: URL | string): Location {\n\t\treturn new Location(url);\n\t}\n}\n","import Swup from '../Swup.js';\nimport { Location } from '../helpers.js';\nimport { PageData } from './fetchPage.js';\n\nexport interface CacheData extends PageData {}\n\n/**\n * In-memory page cache.\n */\nexport class Cache {\n\t/** Swup instance this cache belongs to */\n\tprivate swup: Swup;\n\n\t/** Cached pages, indexed by URL */\n\tprivate pages: Map<string, CacheData> = new Map();\n\n\tconstructor(swup: Swup) {\n\t\tthis.swup = swup;\n\t}\n\n\t/** Number of cached pages in memory. */\n\tget size(): number {\n\t\treturn this.pages.size;\n\t}\n\n\t/** All cached pages. */\n\tget all() {\n\t\treturn this.pages;\n\t}\n\n\t/** Check if the given URL has been cached. */\n\tpublic has(url: string): boolean {\n\t\treturn this.pages.has(this.resolve(url));\n\t}\n\n\t/** Return the cached page object if cached. */\n\tpublic get(url: string): CacheData | undefined {\n\t\treturn this.pages.get(this.resolve(url));\n\t}\n\n\t/** Create a cache record for the specified URL. */\n\tpublic set(url: string, page: CacheData) {\n\t\turl = this.resolve(url);\n\t\tpage = { ...page, url };\n\t\tthis.pages.set(url, page);\n\t\tthis.swup.hooks.callSync('cache:set', { page });\n\t}\n\n\t/** Update a cache record, overwriting or adding custom data. */\n\tpublic update(url: string, page: CacheData) {\n\t\turl = this.resolve(url);\n\t\tpage = { ...this.get(url), ...page, url };\n\t\tthis.pages.set(url, page);\n\t}\n\n\t/** Delete a cache record. */\n\tpublic delete(url: string): void {\n\t\tthis.pages.delete(this.resolve(url));\n\t}\n\n\t/** Empty the cache. */\n\tpublic clear(): void {\n\t\tthis.pages.clear();\n\t\tthis.swup.hooks.callSync('cache:clear');\n\t}\n\n\t/** Remove all cache entries that return true for a given predicate function. */\n\tpublic prune(predicate: (url: string, page: CacheData) => boolean): void {\n\t\tthis.pages.forEach((page, url) => {\n\t\t\tif (predicate(url, page)) {\n\t\t\t\tthis.delete(url);\n\t\t\t}\n\t\t});\n\t}\n\n\t/** Resolve URLs by making them local and letting swup resolve them. */\n\tprivate resolve(urlToResolve: string): string {\n\t\tconst { url } = Location.fromUrl(urlToResolve);\n\t\treturn this.swup.resolveUrl(url);\n\t}\n}\n","/** Find an element by selector. */\nexport const query = (selector: string, context: Document | Element = document) => {\n\treturn context.querySelector<HTMLElement>(selector);\n};\n\n/** Find a set of elements by selector. */\nexport const queryAll = (\n\tselector: string,\n\tcontext: Document | Element = document\n): HTMLElement[] => {\n\treturn Array.from(context.querySelectorAll(selector));\n};\n\n/** Return a Promise that resolves after the next event loop. */\nexport const nextTick = (): Promise<void> => {\n\treturn new Promise((resolve) => {\n\t\trequestAnimationFrame(() => {\n\t\t\trequestAnimationFrame(() => {\n\t\t\t\tresolve();\n\t\t\t});\n\t\t});\n\t});\n};\n\n/** Check if an object is a Promise or a Thenable */\nexport function isPromise<T>(obj: any): obj is PromiseLike<T> {\n\treturn (\n\t\t!!obj &&\n\t\t(typeof obj === 'object' || typeof obj === 'function') &&\n\t\ttypeof obj.then === 'function'\n\t);\n}\n\n/** Call a function as a Promise. Resolves with the returned Promsise or immediately. */\nexport function runAsPromise(func: Function, args: any[] = []): Promise<any> {\n\treturn new Promise((resolve, reject) => {\n\t\tconst result = func(...args);\n\t\tif (isPromise(result)) {\n\t\t\tresult.then(resolve, reject);\n\t\t} else {\n\t\t\tresolve(result);\n\t\t}\n\t});\n}\n\n/**\n * Force a layout reflow, e.g. after adding classnames\n * @returns The offset height, just here so it doesn't get optimized away by the JS engine\n * @see https://stackoverflow.com/a/21665117/3759615\n */\nexport function forceReflow(element?: HTMLElement) {\n\telement = element || document.body;\n\treturn element?.offsetHeight;\n}\n\n/** Escape a string with special chars to not break CSS selectors. */\nexport const escapeCssIdentifier = (ident: string) => {\n\t// @ts-ignore this is for support check, so it's correct that TS complains\n\tif (window.CSS && window.CSS.escape) {\n\t\treturn CSS.escape(ident);\n\t}\n\treturn ident;\n};\n\n/** Fix for Chrome below v61 formatting CSS floats with comma in some locales. */\nexport const toMs = (s: string) => {\n\treturn Number(s.slice(0, -1).replace(',', '.')) * 1000;\n};\n","import Swup from '../Swup.js';\nimport { queryAll } from '../utils.js';\n\nexport class Classes {\n\tpublic swup: Swup;\n\n\tswupClasses = ['to-', 'is-changing', 'is-rendering', 'is-popstate', 'is-animating'];\n\n\tconstructor(swup: Swup) {\n\t\tthis.swup = swup;\n\t}\n\n\tget selectors(): string[] {\n\t\tconst { scope } = this.swup.visit.animation;\n\t\tif (scope === 'containers') return this.swup.visit.containers;\n\t\tif (scope === 'html') return ['html'];\n\t\tif (Array.isArray(scope)) return scope;\n\t\treturn [];\n\t}\n\n\tget selector(): string {\n\t\treturn this.selectors.join(',');\n\t}\n\n\tget targets(): HTMLElement[] {\n\t\tif (!this.selector.trim()) return [];\n\t\treturn queryAll(this.selector) as HTMLElement[];\n\t}\n\n\tpublic add(...classes: string[]): void {\n\t\tthis.targets.forEach((target) => target.classList.add(...classes));\n\t}\n\n\tpublic remove(...classes: string[]): void {\n\t\tthis.targets.forEach((target) => target.classList.remove(...classes));\n\t}\n\n\tpublic clear(): void {\n\t\tthis.targets.forEach((target) => {\n\t\t\tconst remove = target.className.split(' ').filter((c) => this.isSwupClass(c));\n\t\t\ttarget.classList.remove(...remove);\n\t\t});\n\t}\n\n\tprivate isSwupClass(className: string): boolean {\n\t\treturn this.swupClasses.some((c) => className.startsWith(c));\n\t}\n}\n","import Swup, { Options } from '../Swup.js';\nimport { HistoryAction, HistoryDirection } from './navigate.js';\n\n/** An object holding details about the current visit. */\nexport interface Visit {\n\t/** The previous page, about to leave */\n\tfrom: VisitFrom;\n\t/** The next page, about to enter */\n\tto: VisitTo;\n\t/** The content containers, about to be replaced */\n\tcontainers: Options['containers'];\n\t/** Information about animated page transitions */\n\tanimation: VisitAnimation;\n\t/** What triggered this visit */\n\ttrigger: VisitTrigger;\n\t/** Browser history behavior on this visit */\n\thistory: VisitHistory;\n\t/** Scroll behavior on this visit */\n\tscroll: VisitScroll;\n}\n\nexport interface VisitFrom {\n\t/** The URL of the previous page */\n\turl: string;\n}\n\nexport interface VisitTo {\n\t/** The URL of the next page */\n\turl?: string;\n\t/** The HTML content of the next page */\n\thtml?: string;\n}\n\nexport interface VisitAnimation {\n\t/** Whether this visit is animated. Default: `true` */\n\tanimate: boolean;\n\t/** Whether to wait for the next page to load before starting the animation. Default: `false` */\n\twait: boolean;\n\t/** Name of a custom animation to run. */\n\tname?: string;\n\t/** Elements on which to add animation classes. Default: `html` element */\n\tscope: 'html' | 'containers' | string[];\n\t/** Selector for detecting animation timing. Default: `[class*=\"transition-\"]` */\n\tselector: Options['animationSelector'];\n}\n\nexport interface VisitScroll {\n\t/** Whether to reset the scroll position after the visit. Default: `true` */\n\treset: boolean;\n\t/** Anchor element to scroll to on the next page. */\n\ttarget?: string;\n}\n\nexport interface VisitTrigger {\n\t/** DOM element that triggered this visit. */\n\tel?: Element;\n\t/** DOM event that triggered this visit. */\n\tevent?: Event;\n}\n\nexport interface VisitHistory {\n\t/** History action to perform: `push` for creating a new history entry, `replace` for replacing the current entry. Default: `push` */\n\taction: HistoryAction;\n\t/** Whether this visit was triggered by a browser history navigation. */\n\tpopstate: boolean;\n\t/** The direction of travel in case of a browser history navigation: backward or forward. */\n\tdirection: HistoryDirection | undefined;\n}\n\nexport interface VisitInitOptions {\n\tto: string | undefined;\n\tfrom?: string;\n\thash?: string;\n\tanimate?: boolean;\n\tanimation?: string;\n\ttargets?: string[];\n\tel?: Element;\n\tevent?: Event;\n\taction?: HistoryAction;\n\tresetScroll?: boolean;\n}\n\n/** Create a new visit object. */\nexport function createVisit(\n\tthis: Swup,\n\t{\n\t\tto,\n\t\tfrom = this.currentPageUrl,\n\t\thash: target,\n\t\tanimate = true,\n\t\tanimation: name,\n\t\tel,\n\t\tevent,\n\t\taction = 'push',\n\t\tresetScroll: reset = true\n\t}: VisitInitOptions\n): Visit {\n\treturn {\n\t\tfrom: { url: from },\n\t\tto: { url: to },\n\t\tcontainers: this.options.containers,\n\t\tanimation: {\n\t\t\tanimate,\n\t\t\twait: false,\n\t\t\tname,\n\t\t\tscope: this.options.animationScope,\n\t\t\tselector: this.options.animationSelector\n\t\t},\n\t\ttrigger: {\n\t\t\tel,\n\t\t\tevent\n\t\t},\n\t\thistory: {\n\t\t\taction,\n\t\t\tpopstate: false,\n\t\t\tdirection: undefined\n\t\t},\n\t\tscroll: {\n\t\t\treset,\n\t\t\ttarget\n\t\t}\n\t};\n}\n","import { DelegateEvent } from 'delegate-it';\n\nimport Swup from '../Swup.js';\nimport { isPromise, runAsPromise } from '../utils.js';\nimport { Visit } from './Visit.js';\nimport { FetchOptions, PageData } from './fetchPage.js';\n\nexport interface HookDefinitions {\n\t'animation:out:start': undefined;\n\t'animation:out:await': { skip: boolean };\n\t'animation:out:end': undefined;\n\t'animation:in:start': undefined;\n\t'animation:in:await': { skip: boolean };\n\t'animation:in:end': undefined;\n\t'animation:skip': undefined;\n\t'cache:clear': undefined;\n\t'cache:set': { page: PageData };\n\t'content:replace': { page: PageData };\n\t'content:scroll': undefined;\n\t'enable': undefined;\n\t'disable': undefined;\n\t'fetch:request': { url: string; options: FetchOptions };\n\t'fetch:error': { url: string; status: number; response: Response };\n\t'history:popstate': { event: PopStateEvent };\n\t'link:click': { el: HTMLAnchorElement; event: DelegateEvent<MouseEvent> };\n\t'link:self': undefined;\n\t'link:anchor': { hash: string };\n\t'link:newtab': { href: string };\n\t'page:load': { page?: PageData; cache?: boolean; options: FetchOptions };\n\t'page:view': { url: string; title: string };\n\t'scroll:top': { options: ScrollIntoViewOptions };\n\t'scroll:anchor': { hash: string; options: ScrollIntoViewOptions };\n\t'visit:start': undefined;\n\t'visit:end': undefined;\n}\n\nexport type HookArguments<T extends HookName> = HookDefinitions[T];\n\nexport type HookName = keyof HookDefinitions;\n\n/** A hook handler. */\nexport type Handler<T extends HookName> = (\n\t/** Context about the current visit. */\n\tvisit: Visit,\n\t/** Local arguments passed into the handler. */\n\targs: HookArguments<T>,\n\t/** Default handler to be executed. Available if replacing an internal hook handler. */\n\tdefaultHandler?: Handler<T>\n) => Promise<any> | any;\n\nexport type Handlers = {\n\t[K in HookName]: Handler<K>[];\n};\n\n/** Unregister a previously registered hook handler. */\nexport type HookUnregister = () => void;\n\n/** Define when and how a hook handler is executed. */\nexport type HookOptions = {\n\t/** Execute the hook once, then remove the handler */\n\tonce?: boolean;\n\t/** Execute the hook before the internal default handler */\n\tbefore?: boolean;\n\t/** Set a priority for when to execute this hook. Lower numbers execute first. Default: `0` */\n\tpriority?: number;\n\t/** Replace the internal default handler with this hook handler */\n\treplace?: boolean;\n};\n\nexport type HookRegistration<T extends HookName> = {\n\tid: number;\n\thook: T;\n\thandler: Handler<T>;\n\tdefaultHandler?: Handler<T>;\n} & HookOptions;\n\ntype HookLedger<T extends HookName> = Map<Handler<T>, HookRegistration<T>>;\n\ninterface HookRegistry extends Map<HookName, HookLedger<HookName>> {\n\tget<K extends HookName>(key: K): HookLedger<K> | undefined;\n\tset<K extends HookName>(key: K, value: HookLedger<K>): this;\n}\n\n/**\n * Hook registry.\n *\n * Create, trigger and handle hooks.\n *\n */\nexport class Hooks {\n\t/** Swup instance this registry belongs to */\n\tprotected swup: Swup;\n\n\t/** Map of all registered hook handlers. */\n\tprotected registry: HookRegistry = new Map();\n\n\t// Can we deduplicate this somehow? Or make it error when not in sync with HookDefinitions?\n\t// https://stackoverflow.com/questions/53387838/how-to-ensure-an-arrays-values-the-keys-of-a-typescript-interface/53395649\n\tprotected readonly hooks: HookName[] = [\n\t\t'animation:out:start',\n\t\t'animation:out:await',\n\t\t'animation:out:end',\n\t\t'animation:in:start',\n\t\t'animation:in:await',\n\t\t'animation:in:end',\n\t\t'animation:skip',\n\t\t'cache:clear',\n\t\t'cache:set',\n\t\t'content:replace',\n\t\t'content:scroll',\n\t\t'enable',\n\t\t'disable',\n\t\t'fetch:request',\n\t\t'fetch:error',\n\t\t'history:popstate',\n\t\t'link:click',\n\t\t'link:self',\n\t\t'link:anchor',\n\t\t'link:newtab',\n\t\t'page:load',\n\t\t'page:view',\n\t\t'scroll:top',\n\t\t'scroll:anchor',\n\t\t'visit:start',\n\t\t'visit:end'\n\t];\n\n\tconstructor(swup: Swup) {\n\t\tthis.swup = swup;\n\t\tthis.init();\n\t}\n\n\t/**\n\t * Create ledgers for all core hooks.\n\t */\n\tprotected init() {\n\t\tthis.hooks.forEach((hook) => this.create(hook));\n\t}\n\n\t/**\n\t * Create a new hook type.\n\t */\n\tcreate(hook: string) {\n\t\tif (!this.registry.has(hook as HookName)) {\n\t\t\tthis.registry.set(hook as HookName, new Map());\n\t\t}\n\t}\n\n\t/**\n\t * Check if a hook type exists.\n\t */\n\texists(hook: HookName): boolean {\n\t\treturn this.registry.has(hook);\n\t}\n\n\t/**\n\t * Get the ledger with all registrations for a hook.\n\t */\n\tprotected get<T extends HookName>(hook: T): HookLedger<T> | undefined {\n\t\tconst ledger = this.registry.get(hook);\n\t\tif (ledger) {\n\t\t\treturn ledger;\n\t\t}\n\t\tconsole.error(`Unknown hook '${hook}'`);\n\t}\n\n\t/**\n\t * Remove all handlers of all hooks.\n\t */\n\tclear() {\n\t\tthis.registry.forEach((ledger) => ledger.clear());\n\t}\n\n\t/**\n\t * Register a new hook handler.\n\t * @param hook Name of the hook to listen for\n\t * @param handler The handler function to execute\n\t * @param options Object to specify how and when the handler is executed\n\t * Available options:\n\t * - `once`: Only execute the handler once\n\t * - `before`: Execute the handler before the default handler\n\t * - `priority`: Specify the order in which the handlers are executed\n\t * - `replace`: Replace the default handler with this handler\n\t * @returns A function to unregister the handler\n\t */\n\ton<T extends HookName>(hook: T, handler: Handler<T>): HookUnregister;\n\ton<T extends HookName>(hook: T, handler: Handler<T>, options: HookOptions): HookUnregister;\n\ton<T extends HookName>(\n\t\thook: T,\n\t\thandler: Handler<T>,\n\t\toptions: HookOptions = {}\n\t): HookUnregister {\n\t\tconst ledger = this.get(hook);\n\t\tif (!ledger) {\n\t\t\tconsole.warn(`Hook '${hook}' not found.`);\n\t\t\treturn () => {};\n\t\t}\n\n\t\tconst id = ledger.size + 1;\n\t\tconst registration: HookRegistration<T> = { ...options, id, hook, handler };\n\t\tledger.set(handler, registration);\n\n\t\treturn () => this.off(hook, handler);\n\t}\n\n\t/**\n\t * Register a new hook handler to run before the default handler.\n\t * Shortcut for `hooks.on(hook, handler, { before: true })`.\n\t * @param hook Name of the hook to listen for\n\t * @param handler The handler function to execute\n\t * @param options Any other event options (see `hooks.on()` for details)\n\t * @returns A function to unregister the handler\n\t * @see on\n\t */\n\tbefore<T extends HookName>(hook: T, handler: Handler<T>): HookUnregister;\n\tbefore<T extends HookName>(hook: T, handler: Handler<T>, options: HookOptions): HookUnregister;\n\tbefore<T extends HookName>(\n\t\thook: T,\n\t\thandler: Handler<T>,\n\t\toptions: HookOptions = {}\n\t): HookUnregister {\n\t\treturn this.on(hook, handler, { ...options, before: true });\n\t}\n\n\t/**\n\t * Register a new hook handler to replace the default handler.\n\t * Shortcut for `hooks.on(hook, handler, { replace: true })`.\n\t * @param hook Name of the hook to listen for\n\t * @param handler The handler function to execute instead of the default handler\n\t * @param options Any other event options (see `hooks.on()` for details)\n\t * @returns A function to unregister the handler\n\t * @see on\n\t */\n\treplace<T extends HookName>(hook: T, handler: Handler<T>): HookUnregister;\n\treplace<T extends HookName>(hook: T, handler: Handler<T>, options: HookOptions): HookUnregister;\n\treplace<T extends HookName>(\n\t\thook: T,\n\t\thandler: Handler<T>,\n\t\toptions: HookOptions = {}\n\t): HookUnregister {\n\t\treturn this.on(hook, handler, { ...options, replace: true });\n\t}\n\n\t/**\n\t * Register a new hook handler to run once.\n\t * Shortcut for `hooks.on(hook, handler, { once: true })`.\n\t * @param hook Name of the hook to listen for\n\t * @param handler The handler function to execute\n\t * @param options Any other event options (see `hooks.on()` for details)\n\t * @see on\n\t */\n\tonce<T extends HookName>(hook: T, handler: Handler<T>): HookUnregister;\n\tonce<T extends HookName>(hook: T, handler: Handler<T>, options: HookOptions): HookUnregister;\n\tonce<T extends HookName>(\n\t\thook: T,\n\t\thandler: Handler<T>,\n\t\toptions: HookOptions = {}\n\t): HookUnregister {\n\t\treturn this.on(hook, handler, { ...options, once: true });\n\t}\n\n\t/**\n\t * Unregister a hook handler.\n\t * @param hook Name of the hook the handler is registered for\n\t * @param handler The handler function that was registered.\n\t * If omitted, all handlers for the hook will be removed.\n\t */\n\toff<T extends HookName>(hook: T): void;\n\toff<T extends HookName>(hook: T, handler: Handler<T>): void;\n\toff<T extends HookName>(hook: T, handler?: Handler<T>): void {\n\t\tconst ledger = this.get(hook);\n\t\tif (ledger && handler) {\n\t\t\tconst deleted = ledger.delete(handler);\n\t\t\tif (!deleted) {\n\t\t\t\tconsole.warn(`Handler for hook '${hook}' not found.`);\n\t\t\t}\n\t\t} else if (ledger) {\n\t\t\tledger.clear();\n\t\t}\n\t}\n\n\t/**\n\t * Trigger a hook asynchronously, executing its default handler and all registered handlers.\n\t * Will execute all handlers in order and `await` any `Promise`s they return.\n\t * @param hook Name of the hook to trigger\n\t * @param args Arguments to pass to the handler\n\t * @param defaultHandler A default implementation of this hook to execute\n\t * @returns The resolved return value of the executed default handler\n\t */\n\tasync call<T extends HookName>(\n\t\thook: T,\n\t\targs?: HookArguments<T>,\n\t\tdefaultHandler?: Handler<T>\n\t): Promise<any> {\n\t\tconst { before, handler, after } = this.getHandlers(hook, defaultHandler);\n\t\tawait this.run(before, args);\n\t\tconst [result] = await this.run(handler, args);\n\t\tawait this.run(after, args);\n\t\tthis.dispatchDomEvent(hook, args);\n\t\treturn result;\n\t}\n\n\t/**\n\t * Trigger a hook synchronously, executing its default handler and all registered handlers.\n\t * Will execute all handlers in order, but will **not** `await` any `Promise`s they return.\n\t * @param hook Name of the hook to trigger\n\t * @param args Arguments to pass to the handler\n\t * @param defaultHandler A default implementation of this hook to execute\n\t * @returns The (possibly unresolved) return value of the executed default handler\n\t */\n\tcallSync<T extends HookName>(\n\t\thook: T,\n\t\targs?: HookArguments<T>,\n\t\tdefaultHandler?: Handler<T>\n\t): any {\n\t\tconst { before, handler, after } = this.getHandlers(hook, defaultHandler);\n\t\tthis.runSync(before, args);\n\t\tconst [result] = this.runSync(handler, args);\n\t\tthis.runSync(after, args);\n\t\tthis.dispatchDomEvent(hook, args);\n\t\treturn result;\n\t}\n\n\t/**\n\t * Execute the handlers for a hook, in order, as `Promise`s that will be `await`ed.\n\t * @param registrations The registrations (handler + options) to execute\n\t * @param args Arguments to pass to the handler\n\t */\n\tprivate async run<T extends HookName>(\n\t\tregistrations: HookRegistration<T>[],\n\t\targs?: HookArguments<T>\n\t): Promise<any> {\n\t\tconst results = [];\n\t\tfor (const { hook, handler, defaultHandler, once } of registrations) {\n\t\t\tconst result = await runAsPromise(handler, [this.swup.visit, args, defaultHandler]);\n\t\t\tresults.push(result);\n\t\t\tif (once) {\n\t\t\t\tthis.off(hook, handler);\n\t\t\t}\n\t\t}\n\t\treturn results;\n\t}\n\n\t/**\n\t * Execute the handlers for a hook, in order, without `await`ing any returned `Promise`s.\n\t * @param registrations The registrations (handler + options) to execute\n\t * @param args Arguments to pass to the handler\n\t */\n\tprivate runSync<T extends HookName>(\n\t\tregistrations: HookRegistration<T>[],\n\t\targs?: HookArguments<T>\n\t): any[] {\n\t\tconst results = [];\n\t\tfor (const { hook, handler, defaultHandler, once } of registrations) {\n\t\t\tconst result = handler(this.swup.visit, args as HookArguments<T>, defaultHandler);\n\t\t\tresults.push(result);\n\t\t\tif (isPromise(result)) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`Promise returned from handler for synchronous hook '${hook}'.` +\n\t\t\t\t\t\t`Swup will not wait for it to resolve.`\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (once) {\n\t\t\t\tthis.off(hook, handler);\n\t\t\t}\n\t\t}\n\t\treturn results;\n\t}\n\n\t/**\n\t * Get all registered handlers for a hook, sorted by priority and registration order.\n\t * @param hook Name of the hook\n\t * @param defaultHandler The optional default handler of this hook\n\t * @returns An object with the handlers sorted into `before` and `after` arrays,\n\t * as well as a flag indicating if the original handler was replaced\n\t */\n\tprivate getHandlers<T extends HookName>(hook: T, defaultHandler?: Handler<T>) {\n\t\tconst ledger = this.get(hook);\n\t\tif (!ledger) {\n\t\t\treturn { found: false, before: [], handler: [], after: [], replaced: false };\n\t\t}\n\n\t\tconst sort = this.sortRegistrations;\n\t\tconst registrations = Array.from(ledger.values());\n\n\t\t// Filter into before, after, and replace handlers\n\t\tconst before = registrations.filter(({ before, replace }) => before && !replace).sort(sort);\n\t\tconst replace = registrations.filter(({ replace }) => replace).sort(sort);\n\t\tconst after = registrations.filter(({ before, replace }) => !before && !replace).sort(sort);\n\t\tconst replaced = replace.length > 0;\n\n\t\t// Define main handler registration\n\t\t// This is an array to allow passing it into hooks.run() directly\n\t\tlet handler: HookRegistration<T>[] = [];\n\t\tif (defaultHandler) {\n\t\t\thandler = [{ id: 0, hook, handler: defaultHandler }];\n\t\t\tif (replaced) {\n\t\t\t\tconst index = replace.length - 1;\n\t\t\t\tconst replacingHandler = replace[index].handler;\n\t\t\t\tconst createDefaultHandler = (index: number): Handler<T> | undefined => {\n\t\t\t\t\tconst next = replace[index - 1];\n\t\t\t\t\tif (next) {\n\t\t\t\t\t\treturn (visit, args) =>\n\t\t\t\t\t\t\tnext.handler(visit, args, createDefaultHandler(index - 1));\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn defaultHandler;\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\tconst nestedDefaultHandler = createDefaultHandler(index);\n\t\t\t\thandler = [\n\t\t\t\t\t{ id: 0, hook, handler: replacingHandler, defaultHandler: nestedDefaultHandler }\n\t\t\t\t];\n\t\t\t}\n\t\t}\n\n\t\treturn { found: true, before, handler, after, replaced };\n\t}\n\n\t/**\n\t * Sort two hook registrations by priority and registration order.\n\t * @param a The registration object to compare\n\t * @param b The other registration object to compare with\n\t * @returns The sort direction\n\t */\n\tprivate sortRegistrations<T extends HookName>(\n\t\ta: HookRegistration<T>,\n\t\tb: HookRegistration<T>\n\t): number {\n\t\tconst priority = (a.priority ?? 0) - (b.priority ?? 0);\n\t\tconst id = a.id - b.id;\n\t\treturn priority || id || 0;\n\t}\n\n\t/**\n\t * Dispatch a custom event on the `document` for a hook. Prefixed with `swup:`\n\t * @param hook Name of the hook.\n\t */\n\tprivate dispatchDomEvent<T extends HookName>(hook: T, args?: HookArguments<T>): void {\n\t\tconst detail = { hook, args, visit: this.swup.visit };\n\t\tdocument.dispatchEvent(new CustomEvent(`swup:${hook}`, { detail }));\n\t}\n}\n","import { escapeCssIdentifier as escape, query } from '../utils.js';\n\n/**\n * Find the anchor element for a given hash.\n *\n * @param hash Hash with or without leading '#'\n * @returns The element, if found, or null.\n *\n * @see https://html.spec.whatwg.org/#find-a-potential-indicated-element\n */\nexport const getAnchorElement = (hash: string): Element | null => {\n\tif (hash && hash.charAt(0) === '#') {\n\t\thash = hash.substring(1);\n\t}\n\n\tif (!hash) {\n\t\treturn null;\n\t}\n\n\tconst decoded = decodeURIComponent(hash);\n\tlet element =\n\t\tdocument.getElementById(hash) ||\n\t\tdocument.getElementById(decoded) ||\n\t\tquery(`a[name='${escape(hash)}']`) ||\n\t\tquery(`a[name='${escape(decoded)}']`);\n\n\tif (!element && hash === 'top') {\n\t\telement = document.body;\n\t}\n\n\treturn element;\n};\n","import { queryAll, toMs } from '../utils.js';\nimport Swup, { Options } from '../Swup.js';\n\nconst TRANSITION = 'transition';\nconst ANIMATION = 'animation';\n\ntype AnimationTypes = typeof TRANSITION | typeof ANIMATION;\ntype AnimationProperties = 'Delay' | 'Duration';\ntype AnimationStyleKeys = `${AnimationTypes}${AnimationProperties}` | 'transitionProperty';\ntype AnimationStyleDeclarations = Pick<CSSStyleDeclaration, AnimationStyleKeys>;\n\nexport type AnimationDirection = 'in' | 'out';\n\n/**\n * Return a Promise that resolves when all CSS animations and transitions\n * are done on the page. Filters by selector or takes elements directly.\n */\nexport async function awaitAnimations(\n\tthis: Swup,\n\t{\n\t\telements,\n\t\tselector\n\t}: {\n\t\tselector: Options['animationSelector'];\n\t\telements?: NodeListOf<HTMLElement> | HTMLElement[];\n\t}\n): Promise<void> {\n\t// Allow usage of swup without animations: { animationSelector: false }\n\tif (selector === false && !elements) {\n\t\treturn;\n\t}\n\n\t// Allow passing in elements\n\tlet animatedElements: HTMLElement[] = [];\n\tif (elements) {\n\t\tanimatedElements = Array.from(elements);\n\t} else if (selector) {\n\t\tanimatedElements = queryAll(selector, document.body);\n\t\t// Warn if no elements match the selector, but keep things going\n\t\tif (!animatedElements.length) {\n\t\t\tconsole.warn(`[swup] No elements found matching animationSelector \\`${selector}\\``);\n\t\t\treturn;\n\t\t}\n\t}\n\n\tconst awaitedAnimations = animatedElements.map((el) => awaitAnimationsOnElement(el));\n\tconst hasAnimations = awaitedAnimations.filter(Boolean).length > 0;\n\tif (!hasAnimations) {\n\t\tif (selector) {\n\t\t\tconsole.warn(\n\t\t\t\t`[swup] No CSS animation duration defined on elements matching \\`${selector}\\``\n\t\t\t);\n\t\t}\n\t\treturn;\n\t}\n\n\tawait Promise.all(awaitedAnimations);\n}\n\nfunction awaitAnimationsOnElement(element: Element): Promise<void> | false {\n\tconst { type, timeout, propCount } = getTransitionInfo(element);\n\n\t// Resolve immediately if no transition defined\n\tif (!type || !timeout) {\n\t\treturn false;\n\t}\n\n\treturn new Promise((resolve) => {\n\t\tconst endEvent = `${type}end`;\n\t\tconst startTime = performance.now();\n\t\tlet propsTransitioned = 0;\n\n\t\tconst end = () => {\n\t\t\telement.removeEventListener(endEvent, onEnd);\n\t\t\tresolve();\n\t\t};\n\n\t\tconst onEnd: EventListener = (event) => {\n\t\t\t// Skip transitions on child elements\n\t\t\tif (event.target !== element) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (!isTransitionOrAnimationEvent(event)) {\n\t\t\t\tthrow new Error('Not a transition or animation event.');\n\t\t\t}\n\n\t\t\t// Skip transitions that happened before we started listening\n\t\t\tconst elapsedTime = (performance.now() - startTime) / 1000;\n\t\t\tif (elapsedTime < event.elapsedTime) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// End if all properties have transitioned\n\t\t\tif (++propsTransitioned >= propCount) {\n\t\t\t\tend();\n\t\t\t}\n\t\t};\n\n\t\tsetTimeout(() => {\n\t\t\tif (propsTransitioned < propCount) {\n\t\t\t\tend();\n\t\t\t}\n\t\t}, timeout + 1);\n\n\t\telement.addEventListener(endEvent, onEnd);\n\t});\n}\n\nexport function getTransitionInfo(element: Element, expectedType?: AnimationTypes) {\n\tconst styles = window.getComputedStyle(element) as AnimationStyleDeclarations;\n\n\tconst transitionDelays = getStyleProperties(styles, `${TRANSITION}Delay`);\n\tconst transitionDurations = getStyleProperties(styles, `${TRANSITION}Duration`);\n\tconst transitionTimeout = calculateTimeout(transitionDelays, transitionDurations);\n\tconst animationDelays = getStyleProperties(styles, `${ANIMATION}Delay`);\n\tconst animationDurations = getStyleProperties(styles, `${ANIMATION}Duration`);\n\tconst animationTimeout = calculateTimeout(animationDelays, animationDurations);\n\n\tlet type: AnimationTypes | null = null;\n\tlet timeout = 0;\n\tlet propCount = 0;\n\n\tif (expectedType === TRANSITION) {\n\t\tif (transitionTimeout > 0) {\n\t\t\ttype = TRANSITION;\n\t\t\ttimeout = transitionTimeout;\n\t\t\tpropCount = transitionDurations.length;\n\t\t}\n\t} else if (expectedType === ANIMATION) {\n\t\tif (animationTimeout > 0) {\n\t\t\ttype = ANIMATION;\n\t\t\ttimeout = animationTimeout;\n\t\t\tpropCount = animationDurations.length;\n\t\t}\n\t} else {\n\t\ttimeout = Math.max(transitionTimeout, animationTimeout);\n\t\ttype = timeout > 0 ? (transitionTimeout > animationTimeout ? TRANSITION : ANIMATION) : null;\n\t\tpropCount = type\n\t\t\t? type === TRANSITION\n\t\t\t\t? transitionDurations.length\n\t\t\t\t: animationDurations.length\n\t\t\t: 0;\n\t}\n\n\treturn {\n\t\ttype,\n\t\ttimeout,\n\t\tpropCount\n\t};\n}\n\nfunction isTransitionOrAnimationEvent(event: any): event is TransitionEvent | AnimationEvent {\n\treturn [`${TRANSITION}end`, `${ANIMATION}end`].includes(event.type);\n}\n\nfunction getStyleProperties(styles: AnimationStyleDeclarations, key: AnimationStyleKeys): string[] {\n\treturn (styles[key] || '').split(', ');\n}\n\nfunction calculateTimeout(delays: string[], durations: string[]): number {\n\twhile (delays.length < durations.length) {\n\t\tdelays = delays.concat(delays);\n\t}\n\n\treturn Math.max(...durations.map((duration, i) => toMs(duration) + toMs(delays[i])));\n}\n","import Swup from '../Swup.js';\nimport { createHistoryRecord, updateHistoryRecord, getCurrentUrl, Location } from '../helpers.js';\nimport { FetchOptions } from './fetchPage.js';\nimport { VisitInitOptions } from './Visit.js';\n\nexport type HistoryAction = 'push' | 'replace';\nexport type HistoryDirection = 'forwards' | 'backwards';\n\n/** Define how to navigate to a page. */\ntype NavigationOptions = {\n\t/** Whether this visit is animated. Default: `true` */\n\tanimate?: boolean;\n\t/** Name of a custom animation to run. */\n\tanimation?: string;\n\t/** History action to perform: `push` for creating a new history entry, `replace` for replacing the current entry. Default: `push` */\n\thistory?: HistoryAction;\n};\n\n/**\n * Navigate to a new URL.\n * @param url The URL to navigate to.\n * @param options Options for how to perform this visit.\n * @returns Promise<void>\n */\nexport function navigate(\n\tthis: Swup,\n\turl: string,\n\toptions: NavigationOptions & FetchOptions = {},\n\tinit: Omit<VisitInitOptions, 'to'> = {}\n) {\n\t// Check if the visit should be ignored\n\tif (this.shouldIgnoreVisit(url, { el: init.el, event: init.event })) {\n\t\twindow.location.href = url;\n\t\treturn;\n\t}\n\n\tconst { url: to, hash } = Location.fromUrl(url);\n\tthis.visit = this.createVisit({ ...init, to, hash });\n\tthis.performNavigation(to, options);\n}\n\n/**\n * Start a visit to a new URL.\n *\n * Internal method that assumes the visit context has already been created.\n *\n * As a user, you should call `swup.navigate(url)` instead.\n *\n * @param url The URL to navigate to.\n * @param options Options for how to perform this visit.\n * @returns Promise<void>\n */\nexport async function performNavigation(\n\tthis: Swup,\n\turl: string,\n\toptions: NavigationOptions & FetchOptions = {}\n) {\n\tif (typeof url !== 'string') {\n\t\tthrow new Error(`swup.navigate() requires a URL parameter`);\n\t}\n\n\tconst { el } = this.visit.trigger;\n\tthis.visit.to.url = Location.fromUrl(url).url;\n\toptions.referrer = options.referrer || this.currentPageUrl;\n\n\tif (options.animate === false) {\n\t\tthis.visit.animation.animate = false;\n\t}\n\n\t// Clean up old animation classes\n\tif (!this.visit.animation.animate) {\n\t\tthis.classes.clear();\n\t}\n\n\t// Get history action from option or attribute on trigger element\n\tconst history = options.history || el?.getAttribute('data-swup-history') || undefined;\n\tif (history && ['push', 'replace'].includes(history)) {\n\t\tthis.visit.history.action = history as HistoryAction;\n\t}\n\n\t// Get custom animation name from option or attribute on trigger element\n\tconst animation = options.animation || el?.getAttribute('data-swup-animation') || undefined;\n\tif (animation) {\n\t\tthis.visit.animation.name = animation;\n\t}\n\n\ttry {\n\t\tawait this.hooks.call('visit:start');\n\n\t\t// Begin loading page\n\t\tconst pagePromise = this.hooks.call('page:load', { options }, async (visit, args) => {\n\t\t\tconst cachedPage = this.cache.get(visit.to.url!);\n\t\t\targs.page = cachedPage || (await this.fetchPage(visit.to.url!, args.options));\n\t\t\targs.cache = !!cachedPage;\n\t\t\treturn args.page;\n\t\t});\n\n\t\t// Create history record if this is not a popstate call (with or without anchor)\n\t\tif (!this.visit.history.popstate) {\n\t\t\tconst newUrl = url + (this.visit.scroll.target || '');\n\t\t\tif (this.visit.history.action === 'replace') {\n\t\t\t\tupdateHistoryRecord(newUrl);\n\t\t\t} else {\n\t\t\t\tconst index = this.currentHistoryIndex + 1;\n\t\t\t\tcreateHistoryRecord(newUrl, { index });\n\t\t\t}\n\t\t}\n\n\t\tthis.currentPageUrl = getCurrentUrl();\n\n\t\t// Wait for page before starting to animate out?\n\t\tif (this.visit.animation.wait) {\n\t\t\tconst { html } = await pagePromise;\n\t\t\tthis.visit.to.html = html;\n\t\t}\n\n\t\t// Wait for page to load and leave animation to finish\n\t\tconst animationPromise = this.animatePageOut();\n\t\tconst [page] = await Promise.all([pagePromise, animationPromise]);\n\n\t\t// Render page: replace content and scroll to top/fragment\n\t\tawait this.renderPage(this.visit.to.url, page);\n\n\t\t// Wait for enter animation\n\t\tawait this.animatePageIn();\n\n\t\t// Finalize visit\n\t\tawait this.hooks.call('visit:end', undefined, () => this.classes.clear());\n\n\t\t// Reset visit info after finish?\n\t\t// if (this.visit.to && this.isSameResolvedUrl(this.visit.to.url, requestedUrl)) {\n\t\t// \tthis.createVisit({ to: undefined });\n\t\t// }\n\t} catch (error: unknown) {\n\t\t// Return early if error is undefined (probably aborted preload request)\n\t\tif (!error) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Log to console as we swallow almost all hook errors\n\t\tconsole.error(error);\n\n\t\t// Rewrite `skipPopStateHandling` to redirect manually when `history.go` is processed\n\t\tthis.options.skipPopStateHandling = () => {\n\t\t\twindow.location.href = this.visit.to.url as string;\n\t\t\treturn true;\n\t\t};\n\n\t\t// Go back to the actual page we're still at\n\t\twindow.history.go(-1);\n\t}\n}\n","import Swup from '../Swup.js';\nimport { Location } from '../helpers.js';\n\n/** A page object as used by swup and its cache. */\nexport interface PageData {\n\t/** The URL of the page */\n\turl: string;\n\t/** The complete HTML response received from the server */\n\thtml: string;\n}\n\n/** Define how a page is fetched. */\nexport interface FetchOptions extends RequestInit {\n\t/** The request method. */\n\tmethod?: 'GET' | 'POST';\n\t/** The body of the request: raw string, form data object or URL params. */\n\tbody?: string | FormData | URLSearchParams;\n\t/** The headers of the request: key/value object. */\n\theaders?: Record<string, string>;\n}\n\nexport class FetchError extends Error {\n\turl: string;\n\tstatus: number;\n\tconstructor(message: string, details: { url: string; status: number }) {\n\t\tsuper(message);\n\t\tthis.name = 'FetchError';\n\t\tthis.url = details.url;\n\t\tthis.status = details.status;\n\t}\n}\n\n/**\n * Fetch a page from the server, return it and cache it.\n */\nexport async function fetchPage(\n\tthis: Swup,\n\turl: URL | string,\n\toptions: FetchOptions = {}\n): Promise<PageData> {\n\turl = Location.fromUrl(url).url;\n\n\tconst headers = { ...this.options.requestHeaders, ...options.headers };\n\toptions = { ...options, headers };\n\n\t// Allow hooking before this and returning a custom response-like object (e.g. custom fetch implementation)\n\tconst response: Response = await this.hooks.call(\n\t\t'fetch:request',\n\t\t{ url, options },\n\t\t(visit, { url, options }) => fetch(url, options)\n\t);\n\n\tconst { status, url: responseUrl } = response;\n\tconst html = await response.text();\n\n\tif (status === 500) {\n\t\tthis.hooks.call('fetch:error', { status, response, url: responseUrl });\n\t\tthrow new FetchError(`Server error: ${responseUrl}`, { status, url: responseUrl });\n\t}\n\n\tif (!html) {\n\t\tthrow new FetchError(`Empty response: ${responseUrl}`, { status, url: responseUrl });\n\t}\n\n\t// Resolve real url after potential redirect\n\tconst { url: finalUrl } = Location.fromUrl(responseUrl);\n\tconst page = { url: finalUrl, html };\n\n\t// Only save cache entry for non-redirects\n\tif (url === finalUrl) {\n\t\tthis.cache.set(page.url, page);\n\t}\n\n\treturn page;\n}\n","import Swup from '../Swup.js';\nimport { classify } from '../helpers.js';\n\n/**\n * Perform the out/leave animation of the current page.\n * @returns Promise<void>\n */\nexport const animatePageOut = async function (this: Swup) {\n\tif (!this.visit.animation.animate) {\n\t\tawait this.hooks.call('animation:skip');\n\t\treturn;\n\t}\n\n\tawait this.hooks.call('animation:out:start', undefined, (visit) => {\n\t\tthis.classes.add('is-changing', 'is-leaving', 'is-animating');\n\t\tif (visit.history.popstate) {\n\t\t\tthis.classes.add('is-popstate');\n\t\t}\n\t\tif (visit.animation.name) {\n\t\t\tthis.classes.add(`to-${classify(visit.animation.name)}`);\n\t\t}\n\t});\n\n\tawait this.hooks.call('animation:out:await', { skip: false }, async (visit, { skip }) => {\n\t\tif (skip) return;\n\t\tawait this.awaitAnimations({ selector: visit.animation.selector });\n\t});\n\n\tawait this.hooks.call('animation:out:end');\n};\n","import Swup, { Options } from '../Swup.js';\nimport { PageData } from './fetchPage.js';\n\n/**\n * Perform the replacement of content after loading a page.\n *\n * It takes an object with the page data as returned from `fetchPage` and a list\n * of container selectors to replace.\n *\n * @returns Whether all containers were replaced.\n */\nexport const replaceContent = function (\n\tthis: Swup,\n\t{ html }: PageData,\n\t{ containers }: { containers: Options['containers'] } = this.options\n): boolean {\n\tconst incomingDocument = new DOMParser().parseFromString(html, 'text/html');\n\n\t// Update browser title\n\tconst title = incomingDocument.querySelector('title')?.innerText || '';\n\tdocument.title = title;\n\n\t// Update content containers\n\tconst replaced = containers\n\t\t.map((selector) => {\n\t\t\tconst currentEl = document.querySelector(selector);\n\t\t\tconst incomingEl = incomingDocument.querySelector(selector);\n\t\t\tif (currentEl && incomingEl) {\n\t\t\t\tcurrentEl.replaceWith(incomingEl);\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tif (!currentEl) {\n\t\t\t\tconsole.warn(`[swup] Container missing in current document: ${selector}`);\n\t\t\t}\n\t\t\tif (!incomingEl) {\n\t\t\t\tconsole.warn(`[swup] Container missing in incoming document: ${selector}`);\n\t\t\t}\n\t\t\treturn false;\n\t\t})\n\t\t.filter(Boolean);\n\n\treturn replaced.length === containers.length;\n};\n","import Swup from '../Swup.js';\n\n/**\n * Update the scroll position after page render.\n * @returns Promise<boolean>\n */\nexport const scrollToContent = function (this: Swup): boolean {\n\tconst options: ScrollIntoViewOptions = { behavior: 'auto' };\n\tconst { target, reset } = this.visit.scroll;\n\tlet scrolled = false;\n\n\tif (target) {\n\t\tscrolled = this.hooks.callSync(\n\t\t\t'scroll:anchor',\n\t\t\t{ hash: target, options },\n\t\t\t(visit, { hash, options }) => {\n\t\t\t\tconst anchor = this.getAnchorElement(hash || '');\n\t\t\t\tif (anchor) {\n\t\t\t\t\tanchor.scrollIntoView(options);\n\t\t\t\t}\n\t\t\t\treturn !!anchor;\n\t\t\t}\n\t\t);\n\t}\n\n\tif (reset && !scrolled) {\n\t\tscrolled = this.hooks.callSync('scroll:top', { options }, (visit, { options }) => {\n\t\t\twindow.scrollTo({ top: 0, left: 0, ...options });\n\t\t\treturn true;\n\t\t});\n\t}\n\n\treturn scrolled;\n};\n","import Swup from '../Swup.js';\nimport { nextTick } from '../utils.js';\n\n/**\n * Perform the in/enter animation of the next page.\n * @returns Promise<void>\n */\nexport const animatePageIn = async function (this: Swup) {\n\tif (!this.visit.animation.animate) {\n\t\treturn;\n\t}\n\n\tconst animation = this.hooks.call(\n\t\t'animation:in:await',\n\t\t{ skip: false },\n\t\tasync (visit, { skip }) => {\n\t\t\tif (skip) return;\n\t\t\tawait this.awaitAnimations({ selector: visit.animation.selector });\n\t\t}\n\t);\n\n\tawait nextTick();\n\n\tawait this.hooks.call('animation:in:start', undefined, () => {\n\t\tthis.classes.remove('is-animating');\n\t});\n\n\tawait animation;\n\n\tawait this.hooks.call('animation:in:end');\n};\n","import { updateHistoryRecord, getCurrentUrl, classify } from '../helpers.js';\nimport Swup from '../Swup.js';\nimport { PageData } from './fetchPage.js';\n\n/**\n * Render the next page: replace the content and update scroll position.\n * @returns Promise<void>\n */\nexport const renderPage = async function (this: Swup, requestedUrl: string, page: PageData) {\n\tconst { url, html } = page;\n\n\tthis.classes.remove('is-leaving');\n\n\t// do nothing if another page was requested in the meantime\n\tif (!this.isSameResolvedUrl(getCurrentUrl(), requestedUrl)) {\n\t\treturn;\n\t}\n\n\t// update state if the url was redirected\n\tif (!this.isSameResolvedUrl(getCurrentUrl(), url)) {\n\t\tupdateHistoryRecord(url);\n\t\tthis.currentPageUrl = getCurrentUrl();\n\t\tthis.visit.to.url = this.currentPageUrl;\n\t}\n\n\t// only add for animated page loads\n\tif (this.visit.animation.animate) {\n\t\tthis.classes.add('is-rendering');\n\t}\n\n\t// save html into visit context for easier retrieval\n\tthis.visit.to.html = html;\n\n\t// replace content: allow handlers and plugins to overwrite paga data and containers\n\tawait this.hooks.call('content:replace', { page }, (visit, { page }) => {\n\t\tconst success = this.replaceContent(page, { containers: visit.containers });\n\t\tif (!success) {\n\t\t\tthrow new Error('[swup] Container mismatch, aborting');\n\t\t}\n\t\tif (visit.animation.animate) {\n\t\t\t// Make sure to add these classes to new containers as well\n\t\t\tthis.classes.add('is-animating', 'is-changing', 'is-rendering');\n\t\t\tif (visit.animation.name) {\n\t\t\t\tthis.classes.add(`to-${classify(visit.animation.name)}`);\n\t\t\t}\n\t\t}\n\t});\n\n\t// scroll into view: either anchor or top of page\n\tawait this.hooks.call('content:scroll', undefined, () => {\n\t\treturn this.scrollToContent();\n\t});\n\n\tawait this.hooks.call('page:view', { url: this.currentPageUrl, title: document.title });\n\n\t// empty cache if it's disabled (in case preload plugin filled it)\n\tif (!this.options.cache) {\n\t\tthis.cache.clear();\n\t}\n};\n","import Swup from '../Swup.js';\n\nexport type Plugin = {\n\t/** Identify as a swup plugin */\n\tisSwupPlugin: true;\n\t/** Name of this plugin */\n\tname: string;\n\t/** Version of this plugin. Currently not in use, defined here for backward compatiblity. */\n\tversion?: string;\n\t/** The swup instance that mounted this plugin */\n\tswup?: Swup;\n\t/** Version requirements of this plugin. Example: `{ swup: '>=4' }` */\n\trequires?: Record<string, string | string[]>;\n\t/** Run on mount */\n\tmount: () => void;\n\t/** Run on unmount */\n\tunmount: () => void;\n\t_beforeMount?: () => void;\n\t_afterUnmount?: () => void;\n\t_checkRequirements?: () => boolean;\n};\n\nconst isSwupPlugin = (maybeInvalidPlugin: unknown): maybeInvalidPlugin is Plugin => {\n\t// @ts-ignore\n\treturn maybeInvalidPlugin?.isSwupPlugin;\n};\n\n/** Install a plugin. */\nexport const use = function (this: Swup, plugin: unknown) {\n\tif (!isSwupPlugin(plugin)) {\n\t\tconsole.error('Not a swup plugin instance', plugin);\n\t\treturn;\n\t}\n\n\tplugin.swup = this;\n\tif (plugin._checkRequirements) {\n\t\tif (!plugin._checkRequirements()) {\n\t\t\treturn;\n\t\t}\n\t}\n\tif (plugin._beforeMount) {\n\t\tplugin._beforeMount();\n\t}\n\tplugin.mount();\n\n\tthis.plugins.push(plugin);\n\n\treturn this.plugins;\n};\n\n/** Uninstall a plugin. */\nexport function unuse(this: Swup, pluginOrName: Plugin | string) {\n\tconst plugin = this.findPlugin(pluginOrName);\n\tif (!plugin) {\n\t\tconsole.error('No such plugin', plugin);\n\t\treturn;\n\t}\n\n\tplugin.unmount();\n\tif (plugin._afterUnmount) {\n\t\tplugin._afterUnmount();\n\t}\n\n\tthis.plugins = this.plugins.filter((p) => p !== plugin);\n\n\treturn this.plugins;\n}\n\n/** Find a plugin by name or reference. */\nexport function findPlugin(this: Swup, pluginOrName: Plugin | string) {\n\treturn this.plugins.find(\n\t\t(plugin) =>\n\t\t\tplugin === pluginOrName ||\n\t\t\tplugin.name === pluginOrName ||\n\t\t\tplugin.name === `Swup${pluginOrName}`\n\t);\n}\n","import Swup from '../Swup.js';\n\n/**\n * Utility function to validate and run the global option 'resolveUrl'\n * @param {string} url\n * @returns {string} the resolved url\n */\nexport function resolveUrl(this: Swup, url: string): string {\n\tif (typeof this.options.resolveUrl !== 'function') {\n\t\tconsole.warn(`[swup] options.resolveUrl expects a callback function.`);\n\t\treturn url;\n\t}\n\tconst result = this.options.resolveUrl(url);\n\tif (!result || typeof result !== 'string') {\n\t\tconsole.warn(`[swup] options.resolveUrl needs to return a url`);\n\t\treturn url;\n\t}\n\tif (result.startsWith('//') || result.startsWith('http')) {\n\t\tconsole.warn(`[swup] options.resolveUrl needs to return a relative url`);\n\t\treturn url;\n\t}\n\treturn result;\n}\n\n/**\n * Compares the resolved version of two paths and returns true if they are the same\n * @param {string} url1\n * @param {string} url2\n * @returns {boolean}\n */\nexport function isSameResolvedUrl(this: Swup, url1: string, url2: string): boolean {\n\treturn this.resolveUrl(url1) === this.resolveUrl(url2);\n}\n","import { DelegateEvent } from 'delegate-it';\n\nimport version from './config/version.js';\n\nimport { delegateEvent, getCurrentUrl, Location, updateHistoryRecord } from './helpers.js';\nimport { DelegateEventUnsubscribe } from './helpers/delegateEvent.js';\n\nimport { Cache } from './modules/Cache.js';\nimport { Classes } from './modules/Classes.js';\nimport { Visit, createVisit } from './modules/Visit.js';\nimport { Hooks } from './modules/Hooks.js';\nimport { getAnchorElement } from './modules/getAnchorElement.js';\nimport { awaitAnimations } from './modules/awaitAnimations.js';\nimport { navigate, performNavigation } from './modules/navigate.js';\nimport { fetchPage } from './modules/fetchPage.js';\nimport { animatePageOut } from './modules/animatePageOut.js';\nimport { replaceContent } from './modules/replaceContent.js';\nimport { scrollToContent } from './modules/scrollToContent.js';\nimport { animatePageIn } from './modules/animatePageIn.js';\nimport { renderPage } from './modules/renderPage.js';\nimport { use, unuse, findPlugin, Plugin } from './modules/plugins.js';\nimport { isSameResolvedUrl, resolveUrl } from './modules/resolveUrl.js';\nimport { nextTick } from './utils.js';\n\n/** Options for customizing swup's behavior. */\nexport type Options = {\n\t/** Whether history visits are animated. Default: `false` */\n\tanimateHistoryBrowsing: boolean;\n\t/** Selector for detecting animation timing. Default: `[class*=\"transition-\"]` */\n\tanimationSelector: string | false;\n\t/** Elements on which to add animation classes. Default: `html` element */\n\tanimationScope: 'html' | 'containers';\n\t/** Enable in-memory page cache. Default: `true` */\n\tcache: boolean;\n\t/** Content containers to be replaced on page visits. Default: `['#swup']` */\n\tcontainers: string[];\n\t/** Callback for ignoring visits. Receives the element and event that triggered the visit. */\n\tignoreVisit: (url: string, { el, event }: { el?: Element; event?: Event }) => boolean;\n\t/** Selector for links that trigger visits. Default: `'a[href]'` */\n\tlinkSelector: string;\n\t/** Plugins to register on startup. */\n\tplugins: Plugin[];\n\t/** Custom headers sent along with fetch requests. */\n\trequestHeaders: Record<string, string>;\n\t/** Rewrite URLs before loading them. */\n\tresolveUrl: (url: string) => string;\n\t/** Callback for telling swup to ignore certain popstate events. */\n\tskipPopStateHandling: (event: any) => boolean;\n};\n\n/** Interface for Swup page transition library. */\nexport interface SwupCore {\n\t/** Library version */\n\treadonly version: string;\n\t/** Options passed into the instance */\n\toptions: Options;\n\t/** Default options before merging user options */\n\treadonly defaults: Readonly<Options>;\n\t/** Registered plugin instances */\n\treadonly plugins: Plugin[];\n\t/** Data about the current visit */\n\treadonly visit: Visit;\n\t/** Cache instance */\n\treadonly cache: Cache;\n\t/** Hook registry */\n\treadonly hooks: Hooks;\n\t/** Animation class manager */\n\treadonly classes: Classes;\n\t/** URL of the currently visible page */\n\tcurrentPageUrl: string;\n\n\t/** Enable the instance */\n\tenable(): Promise<void>;\n\t/** Disable the instance and clean up */\n\tdestroy(): Promise<void>;\n\n\t/** Install a plugin */\n\tuse: typeof use;\n\t/** Uninstall a plugin */\n\tunuse: typeof unuse;\n\t/** Find a plugin by name or instance */\n\tfindPlugin: typeof findPlugin;\n\n\t/** Log a message. Has no effect unless debug plugin is installed */\n\tlog: (message: string, context?: any) => void;\n\n\t/** Navigate to a new URL */\n\tnavigate: typeof navigate;\n\t/** Replace the content after page load */\n\treplaceContent: typeof replaceContent;\n\t/** Register a delegated event listener */\n\tdelegateEvent: typeof delegateEvent;\n\t/** Fetch a page from the server */\n\tfetchPage: typeof fetchPage;\n\t/** Resolve when animations on the page finish */\n\tawaitAnimations: typeof awaitAnimations;\n\t/** Find the anchor element for a given hash */\n\tgetAnchorElement: typeof getAnchorElement;\n\n\t/** Get the current page URL */\n\tgetCurrentUrl: typeof getCurrentUrl;\n\t/** Resolve a URL to its final location */\n\tresolveUrl(url: string): string;\n}\n\n/** Swup page transition library. */\nexport default class Swup implements SwupCore {\n\tversion = version;\n\toptions: Options;\n\tplugins: Plugin[] = [];\n\tcache: Cache;\n\thooks: Hooks;\n\tvisit: Visit;\n\tclasses: Classes;\n\n\tcurrentPageUrl = getCurrentUrl();\n\tgetCurrentUrl = getCurrentUrl;\n\n\tuse = use;\n\tunuse = unuse;\n\tfindPlugin = findPlugin;\n\n\tlog = () => {};\n\n\tgetAnchorElement = getAnchorElement;\n\n\tnavigate = navigate;\n\tprotected performNavigation = performNavigation;\n\tdelegateEvent = delegateEvent;\n\tfetchPage = fetchPage;\n\tawaitAnimations = awaitAnimations;\n\tprotected renderPage = renderPage;\n\treplaceContent = replaceContent;\n\tprotected animatePageIn = animatePageIn;\n\tprotected animatePageOut = animatePageOut;\n\tprotected scrollToContent = scrollToContent;\n\n\tprotected createVisit = createVisit;\n\tresolveUrl = resolveUrl;\n\tprotected isSameResolvedUrl = isSameResolvedUrl;\n\n\treadonly defaults: Options = {\n\t\tanimateHistoryBrowsing: false,\n\t\tanimationSelector: '[class*=\"transition-\"]',\n\t\tanimationScope: 'html',\n\t\tcache: true,\n\t\tcontainers: ['#swup'],\n\t\tignoreVisit: (url, { el, event } = {}) => !!el?.closest('[data-no-swup]'),\n\t\tlinkSelector: 'a[href]',\n\t\tplugins: [],\n\t\tresolveUrl: (url) => url,\n\t\trequestHeaders: {\n\t\t\t'X-Requested-With': 'swup',\n\t\t\t'Accept': 'text/html, application/xhtml+xml'\n\t\t},\n\t\tskipPopStateHandling: (event) => event.state?.source !== 'swup'\n\t};\n\n\t/** Index of the current history entry */\n\tprotected currentHistoryIndex = 1;\n\n\t/** Delegated event subscription handle */\n\tprotected clickDelegate?: DelegateEventUnsubscribe;\n\n\tconstructor(options: Partial<Options> = {}) {\n\t\t// Merge defaults and options\n\t\tthis.options = { ...this.defaults, ...options };\n\n\t\tthis.handleLinkClick = this.handleLinkClick.bind(this);\n\t\tthis.handlePopState = this.handlePopState.bind(this);\n\n\t\tthis.cache = new Cache(this);\n\t\tthis.classes = new Classes(this);\n\t\tthis.hooks = new Hooks(this);\n\t\tthis.visit = this.createVisit({ to: undefined });\n\n\t\tif (!this.checkRequirements()) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.enable();\n\t}\n\n\tprotected checkRequirements() {\n\t\tif (typeof Promise === 'undefined') {\n\t\t\tconsole.warn('Promise is not supported');\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t}\n\n\t/** Enable this instance, adding listeners and classnames. */\n\tasync enable() {\n\t\t// Add event listener\n\t\tconst { linkSelector } = this.options;\n\t\tthis.clickDelegate = this.delegateEvent(linkSelector, 'click', this.handleLinkClick);\n\n\t\twindow.addEventListener('popstate', this.handlePopState);\n\n\t\t// Initial save to cache\n\t\tif (this.options.cache) {\n\t\t\t// Disabled to avoid caching modified dom state: logic moved to preload plugin\n\t\t\t// https://github.com/swup/swup/issues/475\n\t\t}\n\n\t\t// Mount plugins\n\t\tthis.options.plugins.forEach((plugin) => this.use(plugin));\n\n\t\t// Modify initial history record\n\t\tupdateHistoryRecord(null, { index: 1 });\n\n\t\t// Give consumers a chance to hook into enable\n\t\tawait nextTick();\n\n\t\t// Trigger enable hook\n\t\tawait this.hooks.call('enable', undefined, () => {\n\t\t\t// Add swup-enabled class to html tag\n\t\t\tdocument.documentElement.classList.add('swup-enabled');\n\t\t});\n\t}\n\n\t/** Disable this instance, removing listeners and classnames. */\n\tasync destroy() {\n\t\t// remove delegated listener\n\t\tthis.clickDelegate!.destroy();\n\n\t\t// remove popstate listener\n\t\twindow.removeEventListener('popstate', this.handlePopState);\n\n\t\t// empty cache\n\t\tthis.cache.clear();\n\n\t\t// unmount plugins\n\t\tthis.options.plugins.forEach((plugin) => this.unuse(plugin));\n\n\t\t// trigger disable hook\n\t\tawait this.hooks.call('disable', undefined, () => {\n\t\t\t// remove swup-enabled class from html tag\n\t\t\tdocument.documentElement.classList.remove('swup-enabled');\n\t\t});\n\n\t\t// remove handlers\n\t\tthis.hooks.clear();\n\t}\n\n\t/** Determine if a visit should be ignored by swup, based on URL or trigger element. */\n\tshouldIgnoreVisit(href: string, { el, event }: { el?: Element; event?: Event } = {}) {\n\t\tconst { origin, url, hash } = Location.fromUrl(href);\n\n\t\t// Ignore if the new origin doesn't match the current one\n\t\tif (origin !== window.location.origin) {\n\t\t\treturn true;\n\t\t}\n\n\t\t// Ignore if the link/form would open a new window (or none at all)\n\t\tif (el && this.triggerWillOpenNewWindow(el)) {\n\t\t\treturn true;\n\t\t}\n\n\t\t// Ignore if the visit should be ignored as per user options\n\t\tif (this.options.ignoreVisit(url + hash, { el, event })) {\n\t\t\treturn true;\n\t\t}\n\n\t\t// Finally, allow the visit\n\t\treturn false;\n\t}\n\n\tprotected handleLinkClick(event: DelegateEvent<MouseEvent>) {\n\t\tconst el = event.delegateTarget as HTMLAnchorElement;\n\t\tconst { href, url, hash } = Location.fromElement(el);\n\n\t\t// Exit early if the link should be ignored\n\t\tif (this.shouldIgnoreVisit(href, { el, event })) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.visit = this.createVisit({ to: url, hash, el, event });\n\n\t\t// Exit early if control key pressed\n\t\tif (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) {\n\t\t\tthis.hooks.call('link:newtab', { href });\n\t\t\treturn;\n\t\t}\n\n\t\t// Exit early if other than left mouse button\n\t\tif (event.button !== 0) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.hooks.callSync('link:click', { el, event }, () => {\n\t\t\tconst from = this.visit.from.url ?? '';\n\n\t\t\tevent.preventDefault();\n\n\t\t\t// Handle links to the same page: with or without hash\n\t\t\tif (!url || url === from) {\n\t\t\t\tif (hash) {\n\t\t\t\t\tthis.hooks.callSync('link:anchor', { hash }, () => {\n\t\t\t\t\t\tupdateHistoryRecord(url + hash);\n\t\t\t\t\t\tthis.scrollToContent();\n\t\t\t\t\t});\n\t\t\t\t} else {\n\t\t\t\t\tthis.hooks.callSync('link:self', undefined, () => {\n\t\t\t\t\t\tthis.scrollToContent();\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Exit early if the resolved path hasn't changed\n\t\t\tif (this.isSameResolvedUrl(url, from)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Finally, proceed with loading the page\n\t\t\tthis.performNavigation(url);\n\t\t});\n\t}\n\n\tprotected handlePopState(event: PopStateEvent) {\n\t\tconst href = event.state?.url ?? location.href;\n\n\t\t// Exit early if this event should be ignored\n\t\tif (this.options.skipPopStateHandling(event)) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Exit early if the resolved path hasn't changed\n\t\tif (this.isSameResolvedUrl(getCurrentUrl(), this.currentPageUrl)) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Exit early if the link should be ignored\n\t\tif (this.shouldIgnoreVisit(href, { event })) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { url, hash } = Location.fromUrl(href);\n\t\tconst animate = this.options.animateHistoryBrowsing;\n\t\tconst resetScroll = this.options.animateHistoryBrowsing;\n\n\t\tthis.visit = this.createVisit({\n\t\t\tto: url,\n\t\t\thash,\n\t\t\tevent,\n\t\t\tanimate,\n\t\t\tresetScroll\n\t\t});\n\n\t\t// Mark as popstate visit\n\t\tthis.visit.history.popstate = true;\n\n\t\t// Determine direction of history visit\n\t\tconst index = Number(event.state?.index);\n\t\tif (index) {\n\t\t\tconst direction = index - this.currentHistoryIndex > 0 ? 'forwards' : 'backwards';\n\t\t\tthis.visit.history.direction = direction;\n\t\t}\n\n\t\t// Does this even do anything?\n\t\t// if (!hash) {\n\t\t// \tevent.preventDefault();\n\t\t// }\n\n\t\tthis.hooks.callSync('history:popstate', { event }, () => {\n\t\t\tthis.performNavigation(url);\n\t\t});\n\t}\n\n\t/** Determine whether an element will open a new tab when clicking/activating. */\n\tprotected triggerWillOpenNewWindow(triggerEl: Element) {\n\t\tif (triggerEl.matches('[download], [target=\"_blank\"]')) {\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n}\n","import { match } from 'path-to-regexp';\n\nimport type {\n\tPath,\n\tParseOptions,\n\tTokensToRegexpOptions,\n\tRegexpToFunctionOptions,\n\tMatchFunction\n} from 'path-to-regexp';\n\nexport { Path };\n\n/** Create a match function from a path pattern that checks if a URLs matches it. */\nexport const matchPath = <P extends object = object>(\n\tpath: Path,\n\toptions?: ParseOptions & TokensToRegexpOptions & RegexpToFunctionOptions\n): MatchFunction<P> => {\n\ttry {\n\t\treturn match<P>(path, options);\n\t} catch (error) {\n\t\tthrow new Error(`[swup] Error parsing path \"${path}\":\\n${error}`);\n\t}\n};\n"],"names":["classify","text","fallback","String","toLowerCase","replace","getCurrentUrl","_temp","hash","location","pathname","search","createHistoryRecord","url","customData","data","random","Math","source","history","pushState","updateHistoryRecord","state","replaceState","delegateEvent","selector","type","callback","options","controller","AbortController","signal","delegate","destroy","abort","Location","URL","constructor","base","document","baseURI","super","toString","this","fromElement","el","href","getAttribute","fromUrl","Cache","swup","pages","Map","size","all","has","resolve","get","set","page","hooks","callSync","update","delete","clear","prune","predicate","forEach","urlToResolve","resolveUrl","query","context","querySelector","queryAll","Array","from","querySelectorAll","nextTick","Promise","requestAnimationFrame","isPromise","obj","then","runAsPromise","func","args","reject","result","escapeCssIdentifier","ident","window","CSS","escape","toMs","s","Number","slice","Classes","swupClasses","selectors","scope","visit","animation","containers","isArray","join","targets","trim","add","target","classList","call","arguments","remove","className","split","filter","c","isSwupClass","some","startsWith","createVisit","_ref","to","currentPageUrl","animate","name","event","action","resetScroll","reset","wait","animationScope","animationSelector","trigger","popstate","direction","undefined","scroll","pact","value","_Pact","o","_settle","bind","v","observer","onFulfilled","onRejected","e","_this","_isSettledPact","thenable","Hooks","registry","init","hook","create","exists","ledger","console","error","on","handler","warn","id","registration","off","before","once","defaultHandler","after","getHandlers","run","dispatchDomEvent","runSync","registrations","_this2","results","body","check","_iteratorSymbol","step","iterator","_cycle","next","done","return","_fixup","TypeError","values","i","length","push","array","_forTo","_forOf","_ref2","found","replaced","sort","sortRegistrations","_ref3","_ref4","_ref5","index","createDefaultHandler","a","b","priority","dispatchEvent","CustomEvent","detail","getAnchorElement","charAt","substring","decoded","decodeURIComponent","element","getElementById","awaitAnimations","elements","animatedElements","awaitedAnimations","map","timeout","propCount","expectedType","styles","getComputedStyle","transitionDelays","getStyleProperties","TRANSITION","transitionDurations","transitionTimeout","calculateTimeout","animationDelays","ANIMATION","animationDurations","animationTimeout","max","getTransitionInfo","endEvent","startTime","performance","now","propsTransitioned","end","removeEventListener","onEnd","includes","isTransitionOrAnimationEvent","Error","elapsedTime","setTimeout","addEventListener","awaitAnimationsOnElement","Boolean","key","delays","durations","concat","duration","performNavigation","referrer","classes","_temp2","animationPromise","animatePageOut","pagePromise","renderPage","animatePageIn","_temp3","_this$fetchPage","cache","cachedPage","fetchPage","newUrl","currentHistoryIndex","html","_catch","skipPopStateHandling","go","navigate","shouldIgnoreVisit","headers","requestHeaders","fetch","response","status","responseUrl","FetchError","finalUrl","message","details","_exit","_result","skip","replaceContent","incomingDocument","DOMParser","parseFromString","title","innerText","currentEl","incomingEl","replaceWith","scrollToContent","behavior","scrolled","anchor","scrollIntoView","scrollTo","top","left","requestedUrl","isSameResolvedUrl","use","plugin","maybeInvalidPlugin","isSwupPlugin","_checkRequirements","_beforeMount","mount","plugins","unuse","pluginOrName","findPlugin","unmount","_afterUnmount","p","find","url1","url2","version","log","defaults","animateHistoryBrowsing","ignoreVisit","closest","linkSelector","Accept","clickDelegate","handleLinkClick","handlePopState","checkRequirements","enable","documentElement","origin","triggerWillOpenNewWindow","delegateTarget","metaKey","ctrlKey","shiftKey","altKey","button","preventDefault","triggerEl","matches","offsetHeight","matchPath","path","match"],"mappings":"yJACa,MAAAA,EAAWA,CAACC,EAAcC,IACvBC,OAAOF,GACpBG,cAGAC,QAAQ,YAAa,KACrBA,QAAQ,WAAY,IACpBA,QAAQ,OAAQ,KAChBA,QAAQ,WAAY,KACLH,GAAY,GCTjBI,EAAgB,SAAAC,GAAC,IAAAC,KAAEA,QAA6B,IAAzBD,EAAyB,CAAE,EAAAA,EA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