From f5e90f0aef2a3701682bdd23c528b0dccb09aaab Mon Sep 17 00:00:00 2001 From: Okiki Ojo Date: Wed, 26 May 2021 13:11:45 -0400 Subject: [PATCH] chore(@okikio/native): :package: update build files from @okikio/animate change --- packages/native/lib/api.cjs.js | 4 ++-- packages/native/lib/api.es.js | 4 ++-- packages/native/lib/api.js | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/native/lib/api.cjs.js b/packages/native/lib/api.cjs.js index 5827a75..b91ba42 100644 --- a/packages/native/lib/api.cjs.js +++ b/packages/native/lib/api.cjs.js @@ -1,2 +1,2 @@ -var We=Object.create,Q=Object.defineProperty;var Be=Object.getOwnPropertyDescriptor;var Ze=Object.getOwnPropertyNames;var Je=Object.getPrototypeOf,Qe=Object.prototype.hasOwnProperty;var Se=i=>Q(i,"__esModule",{value:!0});var et=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports),tt=(i,e)=>{for(var t in e)Q(i,t,{get:e[t],enumerable:!0})},it=(i,e,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Ze(e))!Qe.call(i,r)&&r!=="default"&&Q(i,r,{get:()=>e[r],enumerable:!(t=Be(e,r))||t.enumerable});return i},we=i=>it(Se(Q(i!=null?We(Je(i)):{},"default",i&&i.__esModule&&"default"in i?{get:()=>i.default,enumerable:!0}:{value:i,enumerable:!0})),i);var ve=et(I=>{"use strict";Object.defineProperty(I,"__esModule",{value:!0});I.pathToRegexp=I.tokensToRegexp=I.regexpToFunction=I.match=I.tokensToFunction=I.compile=I.parse=void 0;function ot(i){for(var e=[],t=0;t=48&&a<=57||a>=65&&a<=90||a>=97&&a<=122||a===95){n+=i[s++];continue}break}if(!n)throw new TypeError("Missing parameter name at "+t);e.push({type:"NAME",index:t,value:n}),t=s;continue}if(r==="("){var l=1,o="",s=t+1;if(i[s]==="?")throw new TypeError('Pattern cannot start with "?" at '+s);for(;s)?(?!\?)/g,r=0,n=t.exec(i.source);n;)e.push({name:n[1]||r++,prefix:"",suffix:"",modifier:"",pattern:""}),n=t.exec(i.source);return i}function ut(i,e,t){var r=i.map(function(n){return Ae(n,e,t).source});return new RegExp("(?:"+r.join("|")+")",Ee(t))}function mt(i,e,t){return Fe(Te(i,t),e,t)}function Fe(i,e,t){t===void 0&&(t={});for(var r=t.strict,n=r===void 0?!1:r,s=t.start,a=s===void 0?!0:s,l=t.end,o=l===void 0?!0:l,p=t.encode,c=p===void 0?function(v){return v}:p,u="["+j(t.endsWith||"")+"]|$",f="["+j(t.delimiter||"/#?")+"]",m=a?"^":"",y=0,g=i;y-1:d===void 0;n||(m+="(?:"+f+"(?="+u+"))?"),x||(m+="(?="+f+"|"+u+")")}return new RegExp(m,Ee(t))}I.tokensToRegexp=Fe;function Ae(i,e,t){return i instanceof RegExp?ct(i,e):Array.isArray(i)?ut(i,e,t):mt(i,e,t)}I.pathToRegexp=Ae});Se(exports);tt(exports,{AdvancedManager:()=>z,Animate:()=>B,App:()=>Ge,CONFIG_DEFAULTS:()=>Ne,CSSArrValue:()=>D,CSSValue:()=>X,DefaultAnimationOptions:()=>Me,EASINGS:()=>fe,EFFECTS:()=>nt,EasingKeys:()=>Le,Event:()=>F,EventEmitter:()=>U,GetEase:()=>ge,HistoryManager:()=>_e,KeyframeParse:()=>le,Manager:()=>w,ManagerItem:()=>V,PARSER:()=>Ve,PJAX:()=>qe,Page:()=>ae,PageManager:()=>ze,ParseTransformableCSSKeyframes:()=>me,ParseTransformableCSSProperties:()=>ue,Replace:()=>Ie,Router:()=>Xe,Service:()=>O,ServiceManager:()=>se,TransformFunctionNames:()=>pe,TransitionManager:()=>je,UnitDEG:()=>ie,UnitDEGCSSValue:()=>P,UnitLess:()=>$,UnitLessCSSValue:()=>M,UnitPX:()=>te,UnitPXCSSValue:()=>L,addCSSUnit:()=>ee,animate:()=>st,asyncMethodCall:()=>rt,changeState:()=>He,clean:()=>be,computeOption:()=>Ce,createTransformProperty:()=>ce,equal:()=>Z,flatten:()=>Oe,getElements:()=>Re,getHash:()=>at,getHashedPath:()=>k,getTargets:()=>ne,hashAction:()=>xe,ignoreURLs:()=>G,isValid:()=>C,mapAnimationOptions:()=>he,mapObject:()=>Y,methodCall:()=>H,newConfig:()=>de,newCoords:()=>_,newListener:()=>oe,newState:()=>J,newURL:()=>E,omit:()=>W,parseOffset:()=>q,parseOptions:()=>ke,toArr:()=>re,toAttr:()=>N,transpose:()=>Pe});var w=class{constructor(e){this.map=new Map(e)}getMap(){return this.map}get(e){return this.map.get(e)}keys(){return Array.from(this.map.keys())}values(){return Array.from(this.map.values())}set(e,t){return this.map.set(e,t),this}add(e){let r=this.size;return this.set(r,e),this}get size(){return this.map.size}get length(){return this.map.size}last(e=1){let t=this.keys()[this.size-e];return this.get(t)}delete(e){return this.map.delete(e)}remove(e){return this.map.delete(e),this}clear(){return this.map.clear(),this}has(e){return this.map.has(e)}entries(){return this.map.entries()}forEach(e,t){return this.map.forEach(e,t),this}[Symbol.iterator](){return this.entries()}},H=(i,e,...t)=>{i.forEach(r=>{r[e](...t)})},rt=async(i,e,...t)=>{for(let[,r]of i)await r[e](...t)};var oe=({callback:i=()=>{},scope:e=null,name:t="event"})=>({callback:i,scope:e,name:t}),F=class extends w{constructor(e="event"){super();this.name=e}},U=class extends w{constructor(){super()}getEvent(e){let t=this.get(e);return t instanceof F?t:(this.set(e,new F(e)),this.get(e))}newListener(e,t,r){let n=this.getEvent(e);return n.add(oe({name:e,callback:t,scope:r})),n}on(e,t,r){if(typeof e=="undefined"||e==null)return this;typeof e=="string"&&(e=e.trim().split(/\s/g));let n,s,a=typeof e=="object"&&!Array.isArray(e),l=a?t:r;return a||(s=t),Object.keys(e).forEach(o=>{n=a?o:e[o],a&&(s=e[o]),this.newListener(n,s,l)},this),this}removeListener(e,t,r){let n=this.get(e);if(n instanceof F&&t){let s=oe({name:e,callback:t,scope:r});n.forEach((a,l)=>{if(a.callback===s.callback&&a.scope===s.scope)return n.remove(l)})}return n}off(e,t,r){if(typeof e=="undefined"||e==null)return this;typeof e=="string"&&(e=e.trim().split(/\s/g));let n,s,a=typeof e=="object"&&!Array.isArray(e),l=a?t:r;return a||(s=t),Object.keys(e).forEach(o=>{n=a?o:e[o],a&&(s=e[o]),typeof s=="function"?this.removeListener(n,s,l):this.remove(n)},this),this}once(e,t,r){if(typeof e=="undefined"||e==null)return this;typeof e=="string"&&(e=e.trim().split(/\s/g));let n=typeof e=="object"&&!Array.isArray(e);return Object.keys(e).forEach(s=>{let a=n?s:e[s],l=n?e[s]:t,o=n?t:r,p=(...c)=>{l.apply(o,c),this.removeListener(a,p,o)};this.newListener(a,p,o)},this),this}emit(e,...t){return typeof e=="undefined"||e==null?this:(typeof e=="string"&&(e=e.trim().split(/\s/g)),e.forEach(r=>{let n=this.get(r);n instanceof F&&n.forEach(s=>{let{callback:a,scope:l}=s;a.apply(l,t)})},this),this)}clear(){return H(this,"clear"),super.clear(),this}};var q=i=>typeof i=="string"?i.includes("%")?parseFloat(i)/100:i=="from"?0:i=="to"?1:parseFloat(i):i,le=i=>{let e=new Set,t=Object.keys(i),r=t.length;for(let n=0;nn.offset-s.offset)},nt={};var ee=(i="")=>e=>typeof e=="string"?e:`${e}${i}`,$=ee(),te=ee("px"),ie=ee("deg"),re=i=>Array.isArray(i)||typeof i=="string"?(typeof i=="string"&&(i=i.split(",")),i):[i],C=i=>Array.isArray(i)||typeof i=="string"?Boolean(i.length):i!=null&&i!=null,X=i=>e=>C(e)?re(e).map(t=>{if(typeof t!="number"&&typeof t!="string")return t;let r=Number(t),n=Number.isNaN(r)?typeof t=="string"?t.trim():t:r;return i(n)}):[],Pe=(...i)=>{let e=0;i=i.map(n=>{let s=re(n),a=s.length;return a>e&&(e=a),s});let t=[],r=i.length;for(let n=0;nre(i).map(X(e)),pe=["translate","translate3d","translateX","translateY","translateZ","rotate","rotate3d","rotateX","rotateY","rotateZ","scale","scale3d","scaleX","scaleY","scaleZ","skew","skewX","skewY","perspective"],ce=i=>{let e="",t=pe.length;for(let r=0;r{let{perspective:e,rotate:t,rotate3d:r,rotateX:n,rotateY:s,rotateZ:a,translate:l,translate3d:o,translateX:p,translateY:c,translateZ:u,scale:f,scale3d:m,scaleX:y,scaleY:g,scaleZ:h,skew:b,skewX:T,skewY:A,...d}=i;l=D(l,te),o=D(o,te),p=L(p),c=L(c),u=L(u),t=D(t,ie),r=D(r,$),n=P(n),s=P(s),a=P(a),f=D(f,$),m=D(m,$),y=M(y),g=M(g),h=M(h),b=D(b,ie),T=P(T),A=P(A),e=L(e);let x=Pe(l,o,p,c,u,t,r,n,s,a,f,m,y,g,h,b,T,A,e).map(ce);return d=Y(d,v=>[].concat(v).map(S=>""+S)),Object.assign({},C(x)?{transform:x}:null,d)},me=i=>i.map(e=>{let{translate:t,translate3d:r,translateX:n,translateY:s,translateZ:a,rotate:l,rotate3d:o,rotateX:p,rotateY:c,rotateZ:u,scale:f,scale3d:m,scaleX:y,scaleY:g,scaleZ:h,skew:b,skewX:T,skewY:A,perspective:d,easing:x,iterations:v,offset:S,...R}=e;return t=L(t),r=L(r),n=L(n)[0],s=L(s)[0],a=L(a)[0],l=P(l),o=M(o),p=P(p)[0],c=P(c)[0],u=P(u)[0],f=M(f),m=M(m),y=M(y)[0],g=M(g)[0],h=M(h)[0],b=P(b),T=P(T)[0],A=P(A)[0],d=L(d)[0],[R,t,r,n,s,a,l,o,p,c,u,f,m,y,g,h,b,T,A,d]}).map(([e,...t])=>{let r=ce(t);return Object.assign({},C(r)?{transform:r}:null,e)});var Re=i=>typeof i=="string"?Array.from(document.querySelectorAll(i)):[i],Oe=i=>[].concat(...i),ne=i=>Array.isArray(i)?Oe(i.map(ne)):typeof i=="string"||i instanceof Node?Re(i):i instanceof NodeList||i instanceof HTMLCollection?Array.from(i):[],Ce=(i,e,t)=>typeof i=="function"?i.apply(t,e):i,Y=(i,e)=>{let t=Object.keys(i),r,n,s={};for(let a=0,l=t.length;aY(i,r=>Ce(r,e,t)),fe={in:"ease-in",out:"ease-out","in-out":"ease-in-out","in-sine":"cubic-bezier(0.47, 0, 0.745, 0.715)","out-sine":"cubic-bezier(0.39, 0.575, 0.565, 1)","in-out-sine":"cubic-bezier(0.445, 0.05, 0.55, 0.95)","in-quad":"cubic-bezier(0.55, 0.085, 0.68, 0.53)","out-quad":"cubic-bezier(0.25, 0.46, 0.45, 0.94)","in-out-quad":"cubic-bezier(0.455, 0.03, 0.515, 0.955)","in-cubic":"cubic-bezier(0.55, 0.055, 0.675, 0.19)","out-cubic":"cubic-bezier(0.215, 0.61, 0.355, 1)","in-out-cubic":"cubic-bezier(0.645, 0.045, 0.355, 1)","in-quart":"cubic-bezier(0.895, 0.03, 0.685, 0.22)","out-quart":"cubic-bezier(0.165, 0.84, 0.44, 1)","in-out-quart":"cubic-bezier(0.77, 0, 0.175, 1)","in-quint":"cubic-bezier(0.755, 0.05, 0.855, 0.06)","out-quint":"cubic-bezier(0.23, 1, 0.32, 1)","in-out-quint":"cubic-bezier(0.86, 0, 0.07, 1)","in-expo":"cubic-bezier(0.95, 0.05, 0.795, 0.035)","out-expo":"cubic-bezier(0.19, 1, 0.22, 1)","in-out-expo":"cubic-bezier(1, 0, 0, 1)","in-circ":"cubic-bezier(0.6, 0.04, 0.98, 0.335)","out-circ":"cubic-bezier(0.075, 0.82, 0.165, 1)","in-out-circ":"cubic-bezier(0.785, 0.135, 0.15, 0.86)","in-back":"cubic-bezier(0.6, -0.28, 0.735, 0.045)","out-back":"cubic-bezier(0.175, 0.885, 0.32, 1.275)","in-out-back":"cubic-bezier(0.68, -0.55, 0.265, 1.55)"},Le=Object.keys(fe),ge=i=>{let e=i.replace(/^ease-/,"");return Le.includes(e)?fe[e]:i},Me={keyframes:[],offset:[],loop:1,delay:0,speed:1,endDelay:0,easing:"ease",timelineOffset:0,autoplay:!0,duration:1e3,fillMode:"none",direction:"normal",padEndDelay:!1,extend:{}},ke=i=>{let{options:e,...t}=i,r=e instanceof B?e.options:Array.isArray(e)?e?.[0]?.options:e;return Object.assign({},r,t)},W=(i,e)=>{let t={...e};for(;i.length;){let{[i.pop()]:r,...n}=t;t=n}return t},ye=class{constructor(e){this.options={};this.properties={};this.totalDuration=0;this.emitter=new U;this.targets=new w;this.targetIndexes=new WeakMap;this.keyframeEffects=new WeakMap;this.computedOptions=new WeakMap;this.animations=new WeakMap;this.computedKeyframes=new WeakMap;this.loop=this.loop.bind(this),this.onVisibilityChange=this.onVisibilityChange.bind(this),this.on("error",t=>console.error(t)),this.updateOptions(e),this.visibilityPlayState=this.getPlayState(),ye.pauseOnPageHidden&&document.addEventListener("visibilitychange",this.onVisibilityChange,!1),this.newPromise()}onVisibilityChange(){document.hidden?(this.visibilityPlayState=this.getPlayState(),this.is("running")&&(this.loop(),this.pause())):this.visibilityPlayState=="running"&&this.is("paused")&&this.play()}newPromise(){return this.promise=new Promise((e,t)=>{this?.emitter?.once?.("finish",()=>e([this])),this?.emitter?.once?.("error",r=>t(r))}),this.promise}then(e,t){return e=e?.bind(this),t=t?.bind(this),this?.promise?.then?.(e,t),this}catch(e){return e=e?.bind(this),this.promise?.catch?.(e),this}finally(e){return e=e?.bind(this),this.promise?.finally?.(e),this}loop(){this.stopLoop(),this.animationFrame=window.requestAnimationFrame(this.loop),this.emit("update",this.getProgress(),this)}stopLoop(){window.cancelAnimationFrame(this.animationFrame)}allAnimations(e){return this.targets.forEach(t=>{let r=this.keyframeEffects.get(t),n=this.animations.get(r);return e(n,t)}),this}all(e){return this.mainAnimation&&e(this.mainAnimation,this.mainElement),this.allAnimations(e),this}beginEvent(){this.getProgress()==0&&this.emit("begin",this)}play(){let e=this.getPlayState();return this.beginEvent(),this.all(t=>t.play()),this.emit("play",e,this),this.is(e)||this.emit("playstate-change",e,this),this.loop(),this}pause(){let e=this.getPlayState();return this.all(t=>t.pause()),this.emit("pause",e,this),this.is(e)||this.emit("playstate-change",e,this),this.stopLoop(),this}reverse(){return this.all(e=>e.reverse()),this}reset(){return this.setProgress(0),this.options.autoplay?this.play():this.pause(),this}cancel(){return this.all(e=>e.cancel()),this}finish(){return this.all(e=>e.finish()),this}stop(){this.cancel(),this.stopLoop(),document.removeEventListener("visibilitychange",this.onVisibilityChange,!1),this.targets.forEach(e=>this.removeTarget(e)),this.emit("stop"),this.emitter.clear(),this.mainkeyframeEffect=null,this.mainAnimation=null,this.mainElement=null,this.promise=null,this.computedOptions=null,this.animations=null,this.keyframeEffects=null,this.emitter=null,this.targets=null,this.options=null,this.properties=null}getAnimation(e){let t=this.keyframeEffects.get(e);return this.animations.get(t)}getTiming(e){let t=this.computedOptions.get(e)??{},r=this.keyframeEffects.get(e).getTiming?.()??{};return{...t,...r}}getCurrentTime(){return this.mainAnimation.currentTime}getProgress(){return this.getCurrentTime()/this.totalDuration*100}getSpeed(){return this.mainAnimation.playbackRate}getPlayState(){return this.mainAnimation.playState}is(e){return this.getPlayState()==e}setCurrentTime(e){return this.all(t=>t.currentTime=e),this.emit("update",this.getProgress()),this}setProgress(e){let t=e/100*this.totalDuration;return this.setCurrentTime(t),this}setSpeed(e=1){return this.maxSpeed=e,this.all(t=>{t.updatePlaybackRate?t.updatePlaybackRate(e):t.playbackRate=e}),this}createArrayOfComputedOptions(e,t){let r=[];return this.targets.forEach((n,s)=>{let a=this.computedOptions.get(n)??{},l=T=>{let A=T;return T=="loop"&&(A="iterations"),T=="fillMode"&&(A="fill"),e[T]??a[A]??this.options[T]},o=Object.assign({easing:l("easing"),iterations:l("loop"),direction:l("direction"),endDelay:l("endDelay"),duration:l("duration"),speed:l("speed"),delay:l("delay"),timelineOffset:l("timelineOffset"),keyframes:l("keyframes")},l("extend")??{}),p=he(o,[s,t,n],this);typeof p.easing=="string"&&(p.easing=ge(p.easing)),p.iterations===!0&&(p.iterations=Infinity),p.fill=l("fillMode");let{timelineOffset:c,speed:u,endDelay:f,delay:m,duration:y,iterations:g,...h}=p;g=Number(g),y=Number(y),f=Number(f),u=Number(u),m=Number(m)+Number(c);let b=m+y*g+f;this.totalDuration{let{speed:c,keyframes:u,tempDurations:f,...m}=r[p];n&&m.endDelay==0&&Math.abs(m.iterations)!=Math.abs(Infinity)&&(m.endDelay=this.totalDuration-f);let y,g,h=u;typeof h=="object"&&(h=le(h));let b=this.computedKeyframes.get(o)??{},T=Object.assign({},s,b),A=Y(T,(v,S)=>this.properties[S]??v);if(g=C(h)?h:A,Array.isArray(g))y=g.map(v=>{let{easing:S,offset:R,...K}=W(["speed","loop"],v);return Object.assign({},K,typeof S=="string"?{easing:ge(S)}:null,typeof R=="string"||typeof R=="number"?{offset:q(R)}:null)}),y=me(y);else{let v=W(["keyframes"],g),{offset:S,...R}=he(v,[p,t,o],this);R=ue(R);let K=S;y=Object.assign({},R,C(K)?{offset:K.map(q)}:null)}let d,x;this.keyframeEffects.has(o)?(x=this.keyframeEffects.get(o),d=this.animations.get(x),x?.setKeyframes?.(y),x?.updateTiming?.(m)):(x=new KeyframeEffect(o,y,m),d=new Animation(x,m.timeline),this.keyframeEffects.set(o,x),this.animations.set(x,d)),d.playbackRate=c,d.onfinish=()=>{typeof a=="function"&&a.call(this,o,p,t,d)},d.oncancel=()=>{typeof l=="function"&&l.call(this,o,p,t,d)},this.computedOptions.set(o,m),this.computedKeyframes.set(o,y)})}updateOptions(e={}){try{let t=ke(e);this.options=Object.assign({},Me,this.options,t);let r=["easing","loop","endDelay","duration","speed","delay","timelineOffset","direction","extend","fillMode","offset"],{padEndDelay:n,onfinish:s,oncancel:a,autoplay:l,target:o,targets:p,...c}=W(r,this.options);this.properties=W([...r,"keyframes","padEndDelay","onfinish","oncancel","autoplay","target","targets"],t);let u=this.targets.values(),f=[...new Set([...u,...ne(p),...ne(o)])];this.targets.clear(),f.forEach((g,h)=>{this.targets.set(h,g),this.targetIndexes.set(g,h)});let m=this.targets.size,y=this.createArrayOfComputedOptions(t,m);if(this.createAnimations({arrOfComputedOptions:y,padEndDelay:n,oldCSSProperties:c,onfinish:s,oncancel:a},m),this.maxSpeed=this.maxSpeed??this.options.speed,this.minDelay=this.minDelay??this.options.delay,this.totalDuration=this.totalDuration??this.options.duration,this.mainAnimation?(this.mainkeyframeEffect?.updateTiming?.({duration:this.totalDuration}),(!this.mainkeyframeEffect.setKeyframes||!this.mainkeyframeEffect.updateTiming)&&console.warn("@okikio/animate - `KeyframeEffect.setKeyframes` and/or `KeyframeEffect.updateTiming` are not supported in this browser.")):(this.mainkeyframeEffect=new KeyframeEffect(this.mainElement,[{opacity:"0"},{opacity:"1"}],{duration:this.totalDuration,easing:"linear"}),this.mainAnimation=new Animation(this.mainkeyframeEffect,this.options.timeline)),this.mainAnimation.playbackRate=this.maxSpeed,this.mainAnimation.onfinish=()=>{if(this.emit("finish",this),this.mainAnimation){let g=this.getPlayState();this.is(g)||this.emit("playstate-change",g,this),this.stopLoop()}},this.mainAnimation.oncancel=()=>{if(this.emit("cancel",this),this.mainAnimation){let g=this.getPlayState();this.is(g)||this.emit("playstate-change",g,this),this.stopLoop()}},l){let g=window.setTimeout(()=>{this.emit("begin",this),g=window.clearTimeout(g)},0);this.play()}else this.pause()}catch(t){this.emit("error",t)}}add(e){let t=this.getProgress(),r=this.is("running"),n=this.is("paused");this.updateOptions({target:e}),this.setProgress(t),r?this.play():n&&this.pause()}removeTarget(e){let t=this.keyframeEffects.get(e);this.animations.delete(t),t=null,this.computedKeyframes.delete(e),this.computedOptions.delete(e),this.keyframeEffects.delete(e);let r=this.targetIndexes.get(e);this.targets.delete(r),this.targetIndexes.delete(e)}remove(e){this.removeTarget(e);let t=new Set([].concat(this.targets.values()));this.options.target=[...t],this.options.targets=[],t.clear(),t=null;let r=this.getProgress(),n=this.is("running"),s=this.is("paused");this.updateOptions(),n?this.play():s&&this.pause(),this.setProgress(r)}on(e,t,r){return this?.emitter?.on(e,t,r??this),this}off(e,t,r){return this?.emitter?.off(e,t,r??this),this}emit(e,...t){return this?.emitter?.emit(e,...t),this}toJSON(){return this.options}get[Symbol.toStringTag](){return"Animate"}},B=ye;B.pauseOnPageHidden=!0;var st=(i={})=>new B(i);var Ne={wrapperAttr:"wrapper",headers:[],preventSelfAttr:'prevent="self"',preventAllAttr:'prevent="all"',transitionAttr:"transition",timeout:2e3,maxPages:5,resizeDelay:100,onTransitionPreventClick:!0,cacheIgnore:!1,prefetchIgnore:!1,preventURLs:[],stickyScroll:!1,forceOnError:!0,ignoreHashAction:!1,transitions:[]},de=i=>Object.assign({...Ne},i),N=(i,e,t=!0)=>{let{prefix:r}=i,n=i[e],s=`data${r?"-"+r:""}-${n}`;return t?`[${s}]`:s};var V=class{constructor(){}install(){}register(e,t){return this.manager=e,this.app=e.app,this.config=e.config,this.emitter=e.emitter,this.key=t,this.install(),this}uninstall(){}unregister(){this.uninstall(),this.manager.remove(this.key),this.key=null,this.manager=null,this.app=null,this.config=null,this.emitter=null}},z=class extends w{constructor(e){super();this.app=e,this.config=e.config,this.emitter=e.emitter}set(e,t){return super.set(e,t),t.register(this,e),this}};var E=(i=window.location.href)=>i instanceof URL?i:new URL(i,window.location.origin),k=i=>{let e=E(i);return`${e.pathname}${e.hash}`},at=i=>E(i).hash.slice(1),be=i=>E(i).toString().replace(/(\/#.*|\/|#.*)$/,""),Z=(i,e)=>be(i)===be(e);var O=class extends V{init(){}boot(){this.initEvents()}initEvents(){}stopEvents(){}stop(){this.stopEvents(),this.unregister()}},se=class extends z{constructor(e){super(e)}init(){return H(this,"init"),this}boot(){return H(this,"boot"),this}stop(){return H(this,"stop"),this}};var _=(i=window.scrollX,e=window.scrollY)=>({x:i,y:e}),J=(i={url:k(E()),index:0,transition:"default",data:{scroll:_(),trigger:"HistoryManager"}})=>i,_e=class extends O{constructor(){super(...arguments);this.pointer=-1}init(){this.states=[];let e=J();this.add(e,"replace")}get(e){return this.states[e]}add(e,t="push"){let r=J(e),n=this.length;this.states.push({...r}),this.pointer=n;let s={index:this.pointer,states:[...this.states]};return He(t,r,s),this}remove(e){return e?this.states.splice(e,1):this.states.pop(),this.pointer--,this}replace(e){return this.states=e,this}set(e,t){return this.states[e]=t}get current(){return this.get(this.pointer)}get last(){return this.get(this.length-1)}get previous(){return this.pointer<1?null:this.get(this.pointer-1)}get length(){return this.states.length}},He=(i,e,t)=>{let r=k(e.url),n=[t,"",r];if(window.history)switch(i){case"push":window.history.pushState.apply(window.history,n);break;case"replace":window.history.replaceState.apply(window.history,n);break}};var Ue=we(ve()),Ve=new DOMParser,ae=class extends V{constructor(e=E(),t=document){super();this.url=E(e),typeof t=="string"?this.data=t:this.dom=t||document}async build(){if(this.dom instanceof Node||(this.dom=Ve.parseFromString(this.data,"text/html")),!(this.body instanceof Node)){let{title:e,head:t,body:r}=this.dom;this.title=e,this.head=t,this.body=r,this.wrapper=this.body.querySelector(this.wrapperAttr)}}install(){this.wrapperAttr=N(this.config,"wrapperAttr")}uninstall(){this.url=null,this.title=null,this.head=null,this.body=null,this.dom=null,this.wrapper=null,this.data=null,this.wrapperAttr=null}},ze=class extends O{constructor(){super();this.loading=new w}install(){this.pages=new z(this.app),this.cacheIgnore=this.config.cacheIgnore;let e=E().pathname;this.set(e,new ae),e=null}get(e){return this.pages.get(e)}add(e){return this.pages.add(e),this}set(e,t){return this.pages.set(e,t),this}remove(e){return this.pages.remove(e),this}has(e){return this.pages.has(e)}clear(){return this.pages.clear(),this}get size(){return this.pages.size}keys(){return this.pages.keys()}async load(e=E()){let t=E(e),r=t.pathname,n,s;if(this.has(r)&&!G(r,this.cacheIgnore))return n=this.get(r),Promise.resolve(n);this.loading.has(r)?s=this.loading.get(r):(s=this.request(r),this.loading.set(r,s));let a=await s;if(this.loading.remove(r),n=new ae(t,a),this.set(r,n),this.size>this.config.maxPages){let l=E(),o=this.keys(),p=Z(l,o[0])?o[1]:o[0],c=this.get(p);c.unregister(),c=null,o=null,l=null,p=null}return n}async request(e){let t=new Headers(this.config.headers),r=window.setTimeout(()=>{window.clearTimeout(r);let n=new Error("Request Timed Out!");throw this.emitter.emit("TIMEOUT_ERROR",n),n},this.config.timeout);try{let n=await fetch(e,{mode:"same-origin",method:"GET",headers:t,cache:"default",credentials:"same-origin"});if(window.clearTimeout(r),n.status>=200&&n.status<300)return await n.text();let s=new Error(n.statusText||""+n.status);throw this.emitter.emit("REQUEST_ERROR",s),s}catch(n){throw window.clearTimeout(r),n}}},G=(i,e)=>{if(typeof e=="boolean")return e;let t=[];return!e.every(r=>(0,Ue.pathToRegexp)(r,t,{start:!1,end:!1}).exec(i)==null)};var xe=(i,e=window.location.hash)=>{try{let t=e[0]=="#"?e:E(e).hash;if(t.length>1){let r=document.getElementById(t.slice(1));if(r){let{left:n,top:s}=r.getBoundingClientRect(),a=window.scrollX,l=window.scrollY,o=n+a,p=s+l;return _(o,p)}}}catch(t){console.warn("[hashAction] error",t)}return i??_(0,0)},Ie={name:"replace"},je=class extends O{constructor(e){super();this._arg=e}install(){super.install();let e=this._arg&&this._arg.length?this._arg:this.config.transitions;this.transitions=new w([["default",Ie],["replace",Ie]].concat(e))}get(e){return this.transitions.get(e)}set(e,t){return this.transitions.set(e,t),this}add(e){return this.transitions.add(e),this}has(e){return this.transitions.has(e)}async start(e,t){let r=this.transitions.get(e),{oldPage:n,newPage:s,ignoreHashAction:a,trigger:l}=t;if(this.emitter.emit("TRANSITION_START",{transitionName:e,...t}),!("wrapper"in n)||!("wrapper"in s))throw`[TransitionManager] either oldPage or newPage aren't instances of the Page Class. - ${{newPage:s,oldPage:n}}`;document.title=""+s.title;let o=n.wrapper,p=s.wrapper;if(!(o instanceof Node)||!(p instanceof Node))throw`[TransitionManager] the wrapper from the ${p instanceof Node?"current":"next"} page cannot be found. The wrapper must be an element that has the attribute ${N(this.config,"wrapperAttr")}.`;return r.init&&r?.init(t),this.emitter.emit("BEFORE_TRANSITION_OUT",t),r.out&&await new Promise(c=>{r.out.call(r,{...t,from:n,done:c})?.then(c)}),this.emitter.emit("AFTER_TRANSITION_OUT",t),await new Promise(c=>{o.insertAdjacentElement("beforebegin",p),this.emitter.emit("CONTENT_INSERT",t),c()}),await new Promise(c=>{o.remove(),o=null,p=null,this.emitter.emit("CONTENT_REPLACED",t),!a&&!/back|popstate|forward/.test(l)&&(t.scroll=xe(t.scroll)),c()}),this.emitter.emit("BEFORE_TRANSITION_IN",t),r.in&&await new Promise(c=>{r.in.call(r,{...t,from:n,to:s,done:c})?.then(c)}),this.emitter.emit("AFTER_TRANSITION_IN",t),r.manualScroll||(!a&&!/back|popstate|forward/.test(l)&&(t.scroll=xe(t.scroll)),window.scroll(t.scroll.x,t.scroll.y)),this.emitter.emit("TRANSITION_END",{transitionName:e,...t}),t}};var Ge=class{constructor(e={}){this.canResize=!0;this.canScroll=!0;this._resize=this._resize.bind(this),this._scroll=this._scroll.bind(this),this._ready=this._ready.bind(this),this.register(e)}register(e={}){return this.config=de(e),this.emitter=new U,this.services=new se(this),this}_ready(){document.removeEventListener("DOMContentLoaded",this._ready),window.removeEventListener("load",this._ready),this.emitter.emit("READY ready")}_resize(){if(this.canResize){let e,t;this.canResize=!1,t=window.requestAnimationFrame(()=>{this.emitter.emit("RESIZE resize"),e=window.setTimeout(()=>{this.canResize=!0,e=window.clearTimeout(e),t=window.cancelAnimationFrame(t)},this.config.resizeDelay)})}}_scroll(){if(this.canScroll){let e;this.canScroll=!1,e=requestAnimationFrame(()=>{this.emitter.emit("SCROLL scroll"),this.canScroll=!0,e=window.cancelAnimationFrame(e)})}}get(e){return this.services.get(e)}set(e,t){return this.services.set(e,t),this}add(e){return this.services.add(e),this}boot(){return document.addEventListener("DOMContentLoaded",this._ready),window.addEventListener("load",this._ready),window.addEventListener("resize",this._resize,{passive:!0}),window.addEventListener("scroll",this._scroll,{passive:!0}),this.services.init(),this.services.boot(),this}stop(){return window.removeEventListener("resize",this._resize),window.removeEventListener("scroll",this._scroll),this.services.stop(),this.emitter.clear(),this}on(e,t){return this.emitter.on(e,t,this),this}off(e,t){return this.emitter.off(e,t,this),this}emit(e,...t){return this.emitter.emit(e,...t),this}};var qe=class extends O{install(){super.install(),this.preventURLs=this.config.preventURLs,this.prefetchIgnore=this.config.prefetchIgnore,this.onTransitionPreventClick=this.config.onTransitionPreventClick,this.stickyScroll=this.config.stickyScroll,this.forceOnError=this.config.forceOnError,this.ignoreHashAction=this.config.ignoreHashAction}transitionStart(){this.isTransitioning=!0}transitionStop(){this.isTransitioning=!1}init(){this.onHover=this.onHover.bind(this),this.onClick=this.onClick.bind(this),this.onStateChange=this.onStateChange.bind(this)}boot(){super.boot()}getTransitionName(e){if(!e||!e.getAttribute)return null;let t=e.getAttribute(N(this.config,"transitionAttr",!1));return typeof t=="string"?t:null}validLink(e,t,r){let n=!window.history.pushState,s=!e||!r,a=t.metaKey||t.ctrlKey||t.shiftKey||t.altKey,l=e.hasAttribute("target")&&e.target==="_blank",o=e.protocol!==location.protocol||e.hostname!==location.hostname,p=typeof e.getAttribute("download")=="string",c=e.matches(N(this.config,"preventSelfAttr")),u=Boolean(e.closest(N(this.config,"preventAllAttr"))),f=G(E(r).pathname,this.preventURLs),m=k(E())===k(E(r));return!(s||n||a||l||o||p||c||u||f||m)}getHref(e){return e&&e.tagName&&e.tagName.toLowerCase()==="a"&&typeof e.href=="string"?e.href:null}getLink(e){let t=e.target,r=this.getHref(t);for(;t&&!r;)t=t.parentNode,r=this.getHref(t);if(!(!t||!this.validLink(t,e,r)))return t}onClick(e){let t=this.getLink(e);if(!t)return;if(this.isTransitioning&&this.onTransitionPreventClick){e.preventDefault(),e.stopPropagation();return}let r=this.getHref(t);this.emitter.emit("ANCHOR_CLICK CLICK",e),this.go({href:r,trigger:t,event:e})}getDirection(e){return Math.abs(e)>1?e>0?"forward":"back":e===0?"popstate":e>0?"back":"forward"}force(e){window.location.assign(e)}go({href:e,trigger:t="HistoryManager",event:r}){if(this.isTransitioning&&!this.onTransitionPreventClick||!(this.manager.has("TransitionManager")&&this.manager.has("HistoryManager")&&this.manager.has("PageManager"))){this.force(e);return}let n=this.manager.get("HistoryManager"),s=_(0,0),a=n.current,l=a.url;if(Z(l,e))return;let o;if(r&&r.state){this.emitter.emit("POPSTATE",r);let{state:p}=r,{index:c}=p,f=a.index-c;n.replace(p.states),n.pointer=c;let m=n.get(c);o=m.transition,s=m.data.scroll,t=this.getDirection(f),this.emitter.emit(t==="back"?"POPSTATE_BACK":"POPSTATE_FORWARD",r)}else{o=this.getTransitionName(t),s=_();let p=J({url:e,transition:o,data:{scroll:s}});!this.stickyScroll&&(s=_(0,0)),n.add(p),this.emitter.emit("HISTORY_NEW_ITEM",r)}return r&&(r.stopPropagation(),r.preventDefault()),this.emitter.emit("GO",r),this.load({oldHref:l,href:e,trigger:t,transitionName:o,scroll:s})}async load({oldHref:e,href:t,trigger:r,transitionName:n="default",scroll:s={x:0,y:0}}){try{let a=this.manager.get("TransitionManager"),l=this.manager.get("PageManager"),o=this.ignoreHashAction,p,c;this.emitter.emit("NAVIGATION_START",{oldHref:e,href:t,trigger:r,transitionName:n,scroll:s}),a.has(n)||(console.log(`[PJAX] transition name "${n}" doesn't exist, switching to the "default" transition`),n="default");try{this.transitionStart(),this.emitter.emit("PAGE_LOADING",{href:t,oldHref:e,trigger:r,scroll:s}),c=await l.load(e),p=await l.load(t),this.emitter.emit("PAGE_LOAD_COMPLETE",{newPage:p,oldPage:c,trigger:r,scroll:s}),c.dom instanceof Element||c.build(),p.build()}catch(u){console.warn("[PJAX] Page load error",u)}try{s=(await a.start(n,{oldPage:c,newPage:p,trigger:r,scroll:s,ignoreHashAction:o})).scroll}catch(u){console.warn("[PJAX] Transition error",u)}this.emitter.emit("NAVIGATION_END",{oldPage:c,newPage:p,trigger:r,transitionName:n,scroll:s})}catch(a){this.forceOnError?this.force(t):console.warn(a)}finally{this.transitionStop()}}onHover(e){let t=this.getLink(e);if(!t||!this.manager.has("PageManager"))return;let r=this.manager.get("PageManager"),n=E(this.getHref(t)),s=n.pathname;if(this.emitter.emit("ANCHOR_HOVER HOVER",e),!G(n.pathname,this.prefetchIgnore)&&!(r.has(s)&&!G(s,r.cacheIgnore)))try{r.load(n),this.emitter.emit("PREFETCH",e)}catch(a){console.warn("[PJAX] Prefetch error",a)}}onStateChange(e){this.go({href:window.location.href,trigger:"popstate",event:e})}initEvents(){this.prefetchIgnore!==!0&&(document.addEventListener("mouseover",this.onHover),document.addEventListener("touchstart",this.onHover)),document.addEventListener("click",this.onClick),window.addEventListener("popstate",this.onStateChange)}stopEvents(){this.prefetchIgnore!==!0&&(document.removeEventListener("mouseover",this.onHover),document.removeEventListener("touchstart",this.onHover)),document.removeEventListener("click",this.onClick),window.removeEventListener("popstate",this.onStateChange)}};var $e=we(ve()),Xe=class extends O{constructor(e=[]){super();this.routes=new w;for(let t of e)this.add(t)}add({path:e,method:t}){let r=this.parse(e);return this.routes.set(r,t),this}parsePath(e){if(typeof e=="string"||e instanceof RegExp||Array.isArray(e))return(0,$e.pathToRegexp)(e,[],{start:!1,end:!1});if(typeof e=="boolean")return e&&/.*/;throw"[Router] only regular expressions, strings, booleans and arrays of regular expressions and strings are accepted as paths."}isPath(e){return typeof e=="string"||e instanceof RegExp||typeof e=="boolean"||Array.isArray(e)}parse(e){let t=e,r={from:/.*/,to:/.*/};if(this.isPath(e))r={from:!0,to:e};else if(this.isPath(t.from)&&this.isPath(t.to))r=Object.assign({},r,t);else throw"[Router] path is neither a string, regular expression, or a { from, to } object.";let{from:n,to:s}=r;return{from:this.parsePath(n),to:this.parsePath(s)}}route(){if(this.manager.has("HistoryManager")){let e=this.manager.get("HistoryManager"),t=k(E((e.length>1?e.previous:e.current).url)),r=k(E());this.routes.forEach((n,s)=>{let a=s.from,l=s.to;if(typeof a=="boolean"&&typeof l=="boolean")throw`[Router] path ({ from: ${a}, to: ${l} }) is not valid, remember paths can only be strings, regular expressions, or a boolean; however, both the from and to paths cannot be both booleans.`;let o=a,p=l;a instanceof RegExp&&a.test(t)&&(o=a.exec(t)),l instanceof RegExp&&l.test(r)&&(p=l.exec(r)),(Array.isArray(p)&&Array.isArray(o)||Array.isArray(p)&&o==!1&&!l.test(t)||Array.isArray(o)&&p==!1&&!a.test(r))&&n({from:o,to:p,path:{from:t,to:r}})})}else console.warn("[Route] HistoryManager is missing.")}initEvents(){this.emitter.on("READY",this.route,this),this.emitter.on("CONTENT_REPLACED",this.route,this)}stopEvents(){this.emitter.off("READY",this.route,this),this.emitter.off("CONTENT_REPLACED",this.route,this)}};0&&(module.exports={AdvancedManager,Animate,App,CONFIG_DEFAULTS,CSSArrValue,CSSValue,DefaultAnimationOptions,EASINGS,EFFECTS,EasingKeys,Event,EventEmitter,GetEase,HistoryManager,KeyframeParse,Manager,ManagerItem,PARSER,PJAX,Page,PageManager,ParseTransformableCSSKeyframes,ParseTransformableCSSProperties,Replace,Router,Service,ServiceManager,TransformFunctionNames,TransitionManager,UnitDEG,UnitDEGCSSValue,UnitLess,UnitLessCSSValue,UnitPX,UnitPXCSSValue,addCSSUnit,animate,asyncMethodCall,changeState,clean,computeOption,createTransformProperty,equal,flatten,getElements,getHash,getHashedPath,getTargets,hashAction,ignoreURLs,isValid,mapAnimationOptions,mapObject,methodCall,newConfig,newCoords,newListener,newState,newURL,omit,parseOffset,parseOptions,toArr,toAttr,transpose}); +var We=Object.create,ee=Object.defineProperty;var Be=Object.getOwnPropertyDescriptor;var Ze=Object.getOwnPropertyNames;var Je=Object.getPrototypeOf,Qe=Object.prototype.hasOwnProperty;var we=i=>ee(i,"__esModule",{value:!0});var et=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports),tt=(i,e)=>{for(var t in e)ee(i,t,{get:e[t],enumerable:!0})},it=(i,e,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Ze(e))!Qe.call(i,r)&&r!=="default"&&ee(i,r,{get:()=>e[r],enumerable:!(t=Be(e,r))||t.enumerable});return i},Pe=i=>it(we(ee(i!=null?We(Je(i)):{},"default",i&&i.__esModule&&"default"in i?{get:()=>i.default,enumerable:!0}:{value:i,enumerable:!0})),i);var xe=et(I=>{"use strict";Object.defineProperty(I,"__esModule",{value:!0});I.pathToRegexp=I.tokensToRegexp=I.regexpToFunction=I.match=I.tokensToFunction=I.compile=I.parse=void 0;function ot(i){for(var e=[],t=0;t=48&&a<=57||a>=65&&a<=90||a>=97&&a<=122||a===95){n+=i[s++];continue}break}if(!n)throw new TypeError("Missing parameter name at "+t);e.push({type:"NAME",index:t,value:n}),t=s;continue}if(r==="("){var l=1,p="",s=t+1;if(i[s]==="?")throw new TypeError('Pattern cannot start with "?" at '+s);for(;s)?(?!\?)/g,r=0,n=t.exec(i.source);n;)e.push({name:n[1]||r++,prefix:"",suffix:"",modifier:"",pattern:""}),n=t.exec(i.source);return i}function ut(i,e,t){var r=i.map(function(n){return ve(n,e,t).source});return new RegExp("(?:"+r.join("|")+")",Ae(t))}function mt(i,e,t){return Ue(Ee(i,t),e,t)}function Ue(i,e,t){t===void 0&&(t={});for(var r=t.strict,n=r===void 0?!1:r,s=t.start,a=s===void 0?!0:s,l=t.end,p=l===void 0?!0:l,o=t.encode,c=o===void 0?function(E){return E}:o,u="["+G(t.endsWith||"")+"]|$",f="["+G(t.delimiter||"/#?")+"]",h=a?"^":"",g=0,y=i;g-1:v===void 0;n||(h+="(?:"+f+"(?="+u+"))?"),x||(h+="(?="+f+"|"+u+")")}return new RegExp(h,Ae(t))}I.tokensToRegexp=Ue;function ve(i,e,t){return i instanceof RegExp?ct(i,e):Array.isArray(i)?ut(i,e,t):mt(i,e,t)}I.pathToRegexp=ve});we(exports);tt(exports,{AdvancedManager:()=>j,Animate:()=>Z,App:()=>qe,CONFIG_DEFAULTS:()=>_e,CSSArrValue:()=>K,CSSValue:()=>Y,DefaultAnimationOptions:()=>ke,EASINGS:()=>ge,EFFECTS:()=>nt,EasingKeys:()=>Me,Event:()=>U,EventEmitter:()=>V,GetEase:()=>ye,HistoryManager:()=>He,KeyframeParse:()=>pe,Manager:()=>S,ManagerItem:()=>z,PARSER:()=>ze,PJAX:()=>$e,Page:()=>oe,PageManager:()=>je,ParseTransformableCSSKeyframes:()=>he,ParseTransformableCSSProperties:()=>me,Replace:()=>Se,Router:()=>Ye,Service:()=>O,ServiceManager:()=>ae,TransformFunctionNames:()=>ce,TransitionManager:()=>Ge,UnitDEG:()=>re,UnitDEGCSSValue:()=>P,UnitLess:()=>X,UnitLessCSSValue:()=>M,UnitPX:()=>ie,UnitPXCSSValue:()=>L,addCSSUnit:()=>te,animate:()=>st,asyncMethodCall:()=>rt,changeState:()=>De,clean:()=>Te,computeOption:()=>Le,createTransformProperty:()=>ue,equal:()=>J,flatten:()=>Ce,getElements:()=>Oe,getHash:()=>at,getHashedPath:()=>k,getTargets:()=>se,hashAction:()=>Ie,ignoreURLs:()=>q,isValid:()=>R,mapAnimationOptions:()=>fe,mapObject:()=>W,methodCall:()=>D,newConfig:()=>be,newCoords:()=>H,newListener:()=>le,newState:()=>Q,newURL:()=>T,omit:()=>B,parseOffset:()=>$,parseOptions:()=>Ne,toArr:()=>ne,toAttr:()=>_,transpose:()=>Re});var S=class{constructor(e){this.map=new Map(e)}getMap(){return this.map}get(e){return this.map.get(e)}keys(){return Array.from(this.map.keys())}values(){return Array.from(this.map.values())}set(e,t){return this.map.set(e,t),this}add(e){let r=this.size;return this.set(r,e),this}get size(){return this.map.size}get length(){return this.map.size}last(e=1){let t=this.keys()[this.size-e];return this.get(t)}delete(e){return this.map.delete(e)}remove(e){return this.map.delete(e),this}clear(){return this.map.clear(),this}has(e){return this.map.has(e)}entries(){return this.map.entries()}forEach(e,t){return this.map.forEach(e,t),this}[Symbol.iterator](){return this.entries()}},D=(i,e,...t)=>{i.forEach(r=>{r[e](...t)})},rt=async(i,e,...t)=>{for(let[,r]of i)await r[e](...t)};var le=({callback:i=()=>{},scope:e=null,name:t="event"})=>({callback:i,scope:e,name:t}),U=class extends S{constructor(e="event"){super();this.name=e}},V=class extends S{constructor(){super()}getEvent(e){let t=this.get(e);return t instanceof U?t:(this.set(e,new U(e)),this.get(e))}newListener(e,t,r){let n=this.getEvent(e);return n.add(le({name:e,callback:t,scope:r})),n}on(e,t,r){if(typeof e=="undefined"||e==null)return this;typeof e=="string"&&(e=e.trim().split(/\s/g));let n,s,a=typeof e=="object"&&!Array.isArray(e),l=a?t:r;return a||(s=t),Object.keys(e).forEach(p=>{n=a?p:e[p],a&&(s=e[p]),this.newListener(n,s,l)},this),this}removeListener(e,t,r){let n=this.get(e);if(n instanceof U&&t){let s=le({name:e,callback:t,scope:r});n.forEach((a,l)=>{if(a.callback===s.callback&&a.scope===s.scope)return n.remove(l)})}return n}off(e,t,r){if(typeof e=="undefined"||e==null)return this;typeof e=="string"&&(e=e.trim().split(/\s/g));let n,s,a=typeof e=="object"&&!Array.isArray(e),l=a?t:r;return a||(s=t),Object.keys(e).forEach(p=>{n=a?p:e[p],a&&(s=e[p]),typeof s=="function"?this.removeListener(n,s,l):this.remove(n)},this),this}once(e,t,r){if(typeof e=="undefined"||e==null)return this;typeof e=="string"&&(e=e.trim().split(/\s/g));let n=typeof e=="object"&&!Array.isArray(e);return Object.keys(e).forEach(s=>{let a=n?s:e[s],l=n?e[s]:t,p=n?t:r,o=(...c)=>{l.apply(p,c),this.removeListener(a,o,p)};this.newListener(a,o,p)},this),this}emit(e,...t){return typeof e=="undefined"||e==null?this:(typeof e=="string"&&(e=e.trim().split(/\s/g)),e.forEach(r=>{let n=this.get(r);n instanceof U&&n.forEach(s=>{let{callback:a,scope:l}=s;a.apply(l,t)})},this),this)}clear(){return D(this,"clear"),super.clear(),this}};var $=i=>typeof i=="string"?i.includes("%")?parseFloat(i)/100:i=="from"?0:i=="to"?1:parseFloat(i):i,pe=i=>{let e=new Set,t=Object.keys(i),r=t.length;for(let n=0;nn.offset-s.offset)},nt={};var te=(i="")=>e=>typeof e=="string"?e:`${e}${i}`,X=te(),ie=te("px"),re=te("deg"),ne=i=>Array.isArray(i)||typeof i=="string"?(typeof i=="string"&&(i=i.split(",")),i):[i],R=i=>Array.isArray(i)||typeof i=="string"?Boolean(i.length):i!=null&&i!=null,Y=i=>e=>R(e)?ne(e).map(t=>{if(typeof t!="number"&&typeof t!="string")return t;let r=Number(t),n=Number.isNaN(r)?typeof t=="string"?t.trim():t:r;return i(n)}):[],Re=(...i)=>{let e=0;i=i.map(n=>{let s=ne(n),a=s.length;return a>e&&(e=a),s});let t=[],r=i.length;for(let n=0;nne(i).map(Y(e)),ce=["translate","translate3d","translateX","translateY","translateZ","rotate","rotate3d","rotateX","rotateY","rotateZ","scale","scale3d","scaleX","scaleY","scaleZ","skew","skewX","skewY","perspective"],ue=i=>{let e="",t=ce.length;for(let r=0;r{let{perspective:e,rotate:t,rotate3d:r,rotateX:n,rotateY:s,rotateZ:a,translate:l,translate3d:p,translateX:o,translateY:c,translateZ:u,scale:f,scale3d:h,scaleX:g,scaleY:y,scaleZ:m,skew:d,skewX:b,skewY:A,...v}=i;l=K(l,ie),p=K(p,ie),o=L(o),c=L(c),u=L(u),t=K(t,re),r=K(r,X),n=P(n),s=P(s),a=P(a),f=K(f,X),h=K(h,X),g=M(g),y=M(y),m=M(m),d=K(d,re),b=P(b),A=P(A),e=L(e);let x=Re(l,p,o,c,u,t,r,n,s,a,f,h,g,y,m,d,b,A,e).filter(R).map(ue);return v=W(v,E=>[].concat(E).map(w=>""+w)),Object.assign({},R(x)?{transform:x}:null,v)},he=i=>i.map(e=>{let{translate:t,translate3d:r,translateX:n,translateY:s,translateZ:a,rotate:l,rotate3d:p,rotateX:o,rotateY:c,rotateZ:u,scale:f,scale3d:h,scaleX:g,scaleY:y,scaleZ:m,skew:d,skewX:b,skewY:A,perspective:v,easing:x,iterations:E,offset:w,...C}=e;return t=L(t),r=L(r),n=L(n)[0],s=L(s)[0],a=L(a)[0],l=P(l),p=M(p),o=P(o)[0],c=P(c)[0],u=P(u)[0],f=M(f),h=M(h),g=M(g)[0],y=M(y)[0],m=M(m)[0],d=P(d),b=P(b)[0],A=P(A)[0],v=L(v)[0],[C,t,r,n,s,a,l,p,o,c,u,f,h,g,y,m,d,b,A,v]}).map(([e,...t])=>{let r=ue(t);return Object.assign({},R(r)?{transform:r}:null,e)});var Oe=i=>typeof i=="string"?Array.from(document.querySelectorAll(i)):[i],Ce=i=>[].concat(...i),se=i=>Array.isArray(i)?Ce(i.map(se)):typeof i=="string"||i instanceof Node?Oe(i):i instanceof NodeList||i instanceof HTMLCollection?Array.from(i):[],Le=(i,e,t)=>typeof i=="function"?i.apply(t,e):i,W=(i,e)=>{let t=Object.keys(i),r,n,s={};for(let a=0,l=t.length;aW(i,r=>Le(r,e,t)),ge={in:"ease-in",out:"ease-out","in-out":"ease-in-out","in-sine":"cubic-bezier(0.47, 0, 0.745, 0.715)","out-sine":"cubic-bezier(0.39, 0.575, 0.565, 1)","in-out-sine":"cubic-bezier(0.445, 0.05, 0.55, 0.95)","in-quad":"cubic-bezier(0.55, 0.085, 0.68, 0.53)","out-quad":"cubic-bezier(0.25, 0.46, 0.45, 0.94)","in-out-quad":"cubic-bezier(0.455, 0.03, 0.515, 0.955)","in-cubic":"cubic-bezier(0.55, 0.055, 0.675, 0.19)","out-cubic":"cubic-bezier(0.215, 0.61, 0.355, 1)","in-out-cubic":"cubic-bezier(0.645, 0.045, 0.355, 1)","in-quart":"cubic-bezier(0.895, 0.03, 0.685, 0.22)","out-quart":"cubic-bezier(0.165, 0.84, 0.44, 1)","in-out-quart":"cubic-bezier(0.77, 0, 0.175, 1)","in-quint":"cubic-bezier(0.755, 0.05, 0.855, 0.06)","out-quint":"cubic-bezier(0.23, 1, 0.32, 1)","in-out-quint":"cubic-bezier(0.86, 0, 0.07, 1)","in-expo":"cubic-bezier(0.95, 0.05, 0.795, 0.035)","out-expo":"cubic-bezier(0.19, 1, 0.22, 1)","in-out-expo":"cubic-bezier(1, 0, 0, 1)","in-circ":"cubic-bezier(0.6, 0.04, 0.98, 0.335)","out-circ":"cubic-bezier(0.075, 0.82, 0.165, 1)","in-out-circ":"cubic-bezier(0.785, 0.135, 0.15, 0.86)","in-back":"cubic-bezier(0.6, -0.28, 0.735, 0.045)","out-back":"cubic-bezier(0.175, 0.885, 0.32, 1.275)","in-out-back":"cubic-bezier(0.68, -0.55, 0.265, 1.55)"},Me=Object.keys(ge),ye=i=>{let e=i.replace(/^ease-/,"");return Me.includes(e)?ge[e]:i},ke={keyframes:[],offset:[],loop:1,delay:0,speed:1,endDelay:0,easing:"ease",timelineOffset:0,autoplay:!0,duration:1e3,fillMode:"none",direction:"normal",padEndDelay:!1,timeline:document.timeline,extend:{}},Ne=i=>{let{options:e,...t}=i,r=e instanceof Z?e.options:Array.isArray(e)?e?.[0]?.options:e;return Object.assign({},r,t)},B=(i,e)=>{let t={...e};for(;i.length;){let{[i.pop()]:r,...n}=t;t=n}return t},de=class{constructor(e){this.options={};this.properties={};this.totalDuration=0;this.emitter=new V;this.targets=new S;this.targetIndexes=new WeakMap;this.keyframeEffects=new WeakMap;this.computedOptions=new WeakMap;this.animations=new WeakMap;this.computedKeyframes=new WeakMap;this.loop=this.loop.bind(this),this.onVisibilityChange=this.onVisibilityChange.bind(this),this.on("error",console.error),this.updateOptions(e),this.mainAnimation&&(this.visibilityPlayState=this.getPlayState(),de.pauseOnPageHidden&&document.addEventListener("visibilitychange",this.onVisibilityChange,!1)),this.newPromise()}onVisibilityChange(){document.hidden?(this.visibilityPlayState=this.getPlayState(),this.is("running")&&(this.loop(),this.pause())):this.visibilityPlayState=="running"&&this.is("paused")&&this.play()}newPromise(){return this.promise=new Promise((e,t)=>{this?.emitter?.once?.("finish",()=>e([this])),this?.emitter?.once?.("error",r=>t(r))}),this.promise}then(e,t){return e=e?.bind(this),t=t?.bind(this),this?.promise?.then?.(e,t),this}catch(e){return e=e?.bind(this),this.promise?.catch?.(e),this}finally(e){return e=e?.bind(this),this.promise?.finally?.(e),this}loop(){this.stopLoop(),this.animationFrame=window.requestAnimationFrame(this.loop),this.emit("update",this.getProgress(),this)}stopLoop(){window.cancelAnimationFrame(this.animationFrame)}allAnimations(e){return this.targets.forEach(t=>{let r=this.keyframeEffects.get(t),n=this.animations.get(r);return e(n,t)}),this}all(e){return this.mainAnimation&&e(this.mainAnimation,this.mainElement),this.allAnimations(e),this}beginEvent(){this.getProgress()==0&&this.emit("begin",this)}play(){let e=this.getPlayState();return this.beginEvent(),this.all(t=>t.play()),this.emit("play",e,this),this.is(e)||this.emit("playstate-change",e,this),this.loop(),this}pause(){let e=this.getPlayState();return this.all(t=>t.pause()),this.emit("pause",e,this),this.is(e)||this.emit("playstate-change",e,this),this.stopLoop(),this}reverse(){return this.all(e=>e.reverse()),this}reset(){return this.setProgress(0),this.options.autoplay?this.play():this.pause(),this}cancel(){return this.all(e=>e.cancel()),this}finish(){return this.all(e=>e.finish()),this}stop(){this.cancel(),this.stopLoop(),document.removeEventListener("visibilitychange",this.onVisibilityChange,!1),this.targets.forEach(e=>this.removeTarget(e)),this.emit("stop"),this.emitter.clear(),this.mainkeyframeEffect=null,this.mainAnimation=null,this.mainElement=null,this.promise=null,this.computedOptions=null,this.animations=null,this.keyframeEffects=null,this.emitter=null,this.targets=null,this.options=null,this.properties=null}getAnimation(e){let t=this.keyframeEffects.get(e);return this.animations.get(t)}getTiming(e){let t=this.computedOptions.get(e)??{},r=this.keyframeEffects.get(e).getTiming?.()??{};return{...t,...r}}getCurrentTime(){return this.mainAnimation.currentTime}getProgress(){return this.getCurrentTime()/this.totalDuration*100}getSpeed(){return this.mainAnimation.playbackRate}getPlayState(){return this.mainAnimation.playState}is(e){return this.getPlayState()==e}setCurrentTime(e){return this.all(t=>t.currentTime=e),this.emit("update",this.getProgress()),this}setProgress(e){let t=e/100*this.totalDuration;return this.setCurrentTime(t),this}setSpeed(e=1){return this.maxSpeed=e,this.all(t=>{t.updatePlaybackRate?t.updatePlaybackRate(e):t.playbackRate=e}),this}createArrayOfComputedOptions(e,t){let r=[];return this.targets.forEach((n,s)=>{let a=this.computedOptions.get(n)??{},l=b=>{let A=b;return b=="loop"&&(A="iterations"),b=="fillMode"&&(A="fill"),e[b]??a[A]??this.options[b]},p=Object.assign({easing:l("easing"),iterations:l("loop"),direction:l("direction"),endDelay:l("endDelay"),duration:l("duration"),speed:l("speed"),delay:l("delay"),timelineOffset:l("timelineOffset"),keyframes:l("keyframes")},l("extend")??{}),o=fe(p,[s,t,n],this);typeof o.easing=="string"&&(o.easing=ye(o.easing)),o.iterations===!0&&(o.iterations=Infinity),o.fill=l("fillMode");let{timelineOffset:c,speed:u,endDelay:f,delay:h,duration:g,iterations:y,...m}=o;y=Number(y),g=Number(g),f=Number(f),u=Number(u),h=Number(h)+Number(c);let d=h+g*y+f;this.totalDuration{let{speed:u,keyframes:f,tempDurations:h,...g}=r[c];n&&g.endDelay==0&&Math.abs(g.iterations)!=Math.abs(Infinity)&&(g.endDelay=this.totalDuration-h);let y,m,d=f;typeof d=="object"&&(d=pe(d));let b=this.computedKeyframes.get(o)??{},A=Object.assign({},s,b),v=W(A,(w,C)=>this.properties[C]??w);if(m=R(d)?d:v,Array.isArray(m))y=m.map(w=>{let{easing:C,offset:N,...F}=B(["speed","loop"],w);return Object.assign({},F,typeof C=="string"?{easing:ye(C)}:null,typeof N=="string"||typeof N=="number"?{offset:$(N)}:null)}),y=he(y);else{let w=B(["keyframes"],m),{offset:C,...N}=fe(w,[c,t,o],this);N=me(N);let F=C;y=Object.assign({},N,R(F)?{offset:F.map($)}:null)}let x,E;this.keyframeEffects.has(o)?(E=this.keyframeEffects.get(o),x=this.animations.get(E),E?.setKeyframes?.(y),E?.updateTiming?.(g)):(E=new KeyframeEffect(o,y,g),x=new Animation(E,p),this.keyframeEffects.set(o,E),this.animations.set(E,x)),x.playbackRate=u,x.onfinish=()=>{typeof a=="function"&&a.call(this,o,c,t,x)},x.oncancel=()=>{typeof l=="function"&&l.call(this,o,c,t,x)},this.computedOptions.set(o,g),this.computedKeyframes.set(o,y)})}updateOptions(e={}){try{let t=Ne(e);this.options=Object.assign({},ke,this.options,t);let r=["easing","loop","endDelay","duration","speed","delay","timelineOffset","direction","extend","fillMode","offset"],{padEndDelay:n,autoplay:s,target:a,targets:l,timeline:p,onfinish:o,oncancel:c,...u}=B(r,this.options);this.properties=B([...r,"keyframes","padEndDelay","onfinish","oncancel","autoplay","target","targets","timeline"],t);let f=this.targets.values(),h=[...new Set([...f,...se(l),...se(a)])];this.targets.clear(),h.forEach((m,d)=>{this.targets.set(d,m),this.targetIndexes.set(m,d)});let g=this.targets.size,y=this.createArrayOfComputedOptions(t,g);if(this.createAnimations({arrOfComputedOptions:y,padEndDelay:n,oldCSSProperties:u,onfinish:o,oncancel:c,timeline:p},g),this.maxSpeed=this.maxSpeed??this.options.speed,this.minDelay=this.minDelay??this.options.delay,this.totalDuration=this.totalDuration??this.options.duration,this.mainAnimation?(this.mainkeyframeEffect?.updateTiming?.({duration:this.totalDuration}),(!this.mainkeyframeEffect.setKeyframes||!this.mainkeyframeEffect.updateTiming)&&console.warn("@okikio/animate - `KeyframeEffect.setKeyframes` and/or `KeyframeEffect.updateTiming` are not supported in this browser.")):(this.mainkeyframeEffect=new KeyframeEffect(this.mainElement,[{opacity:"0"},{opacity:"1"}],{duration:this.totalDuration,easing:"linear"}),this.mainAnimation=new Animation(this.mainkeyframeEffect,p)),this.mainAnimation.playbackRate=this.maxSpeed,this.mainAnimation.onfinish=()=>{if(this.emit("finish",this),this.mainAnimation){let m=this.getPlayState();this.is(m)||this.emit("playstate-change",m,this),this.stopLoop()}},this.mainAnimation.oncancel=()=>{if(this.emit("cancel",this),this.mainAnimation){let m=this.getPlayState();this.is(m)||this.emit("playstate-change",m,this),this.stopLoop()}},s){let m=window.setTimeout(()=>{this.emit("begin",this),m=window.clearTimeout(m)},0);this.play()}else this.pause()}catch(t){this.emit("error",t)}}add(e){let t=this.getProgress(),r=this.is("running"),n=this.is("paused");this.updateOptions({target:e}),this.setProgress(t),r?this.play():n&&this.pause()}removeTarget(e){let t=this.keyframeEffects.get(e);this.animations.delete(t),t=null,this.computedKeyframes.delete(e),this.computedOptions.delete(e),this.keyframeEffects.delete(e);let r=this.targetIndexes.get(e);this.targets.delete(r),this.targetIndexes.delete(e)}remove(e){this.removeTarget(e);let t=new Set([].concat(this.targets.values()));this.options.target=[...t],this.options.targets=[],t.clear(),t=null;let r=this.getProgress(),n=this.is("running"),s=this.is("paused");this.updateOptions(),n?this.play():s&&this.pause(),this.setProgress(r)}on(e,t,r){return this?.emitter?.on(e,t,r??this),this}off(e,t,r){return this?.emitter?.off(e,t,r??this),this}emit(e,...t){return this?.emitter?.emit(e,...t),this}toJSON(){return this.options}get[Symbol.toStringTag](){return"Animate"}},Z=de;Z.pauseOnPageHidden=!0;var st=(i={})=>new Z(i);var _e={wrapperAttr:"wrapper",headers:[],preventSelfAttr:'prevent="self"',preventAllAttr:'prevent="all"',transitionAttr:"transition",timeout:2e3,maxPages:5,resizeDelay:100,onTransitionPreventClick:!0,cacheIgnore:!1,prefetchIgnore:!1,preventURLs:[],stickyScroll:!1,forceOnError:!0,ignoreHashAction:!1,transitions:[]},be=i=>Object.assign({..._e},i),_=(i,e,t=!0)=>{let{prefix:r}=i,n=i[e],s=`data${r?"-"+r:""}-${n}`;return t?`[${s}]`:s};var z=class{constructor(){}install(){}register(e,t){return this.manager=e,this.app=e.app,this.config=e.config,this.emitter=e.emitter,this.key=t,this.install(),this}uninstall(){}unregister(){this.uninstall(),this.manager.remove(this.key),this.key=null,this.manager=null,this.app=null,this.config=null,this.emitter=null}},j=class extends S{constructor(e){super();this.app=e,this.config=e.config,this.emitter=e.emitter}set(e,t){return super.set(e,t),t.register(this,e),this}};var T=(i=window.location.href)=>i instanceof URL?i:new URL(i,window.location.origin),k=i=>{let e=T(i);return`${e.pathname}${e.hash}`},at=i=>T(i).hash.slice(1),Te=i=>T(i).toString().replace(/(\/#.*|\/|#.*)$/,""),J=(i,e)=>Te(i)===Te(e);var O=class extends z{init(){}boot(){this.initEvents()}initEvents(){}stopEvents(){}stop(){this.stopEvents(),this.unregister()}},ae=class extends j{constructor(e){super(e)}init(){return D(this,"init"),this}boot(){return D(this,"boot"),this}stop(){return D(this,"stop"),this}};var H=(i=window.scrollX,e=window.scrollY)=>({x:i,y:e}),Q=(i={url:k(T()),index:0,transition:"default",data:{scroll:H(),trigger:"HistoryManager"}})=>i,He=class extends O{constructor(){super(...arguments);this.pointer=-1}init(){this.states=[];let e=Q();this.add(e,"replace")}get(e){return this.states[e]}add(e,t="push"){let r=Q(e),n=this.length;this.states.push({...r}),this.pointer=n;let s={index:this.pointer,states:[...this.states]};return De(t,r,s),this}remove(e){return e?this.states.splice(e,1):this.states.pop(),this.pointer--,this}replace(e){return this.states=e,this}set(e,t){return this.states[e]=t}get current(){return this.get(this.pointer)}get last(){return this.get(this.length-1)}get previous(){return this.pointer<1?null:this.get(this.pointer-1)}get length(){return this.states.length}},De=(i,e,t)=>{let r=k(e.url),n=[t,"",r];if(window.history)switch(i){case"push":window.history.pushState.apply(window.history,n);break;case"replace":window.history.replaceState.apply(window.history,n);break}};var Ve=Pe(xe()),ze=new DOMParser,oe=class extends z{constructor(e=T(),t=document){super();this.url=T(e),typeof t=="string"?this.data=t:this.dom=t||document}async build(){if(this.dom instanceof Node||(this.dom=ze.parseFromString(this.data,"text/html")),!(this.body instanceof Node)){let{title:e,head:t,body:r}=this.dom;this.title=e,this.head=t,this.body=r,this.wrapper=this.body.querySelector(this.wrapperAttr)}}install(){this.wrapperAttr=_(this.config,"wrapperAttr")}uninstall(){this.url=null,this.title=null,this.head=null,this.body=null,this.dom=null,this.wrapper=null,this.data=null,this.wrapperAttr=null}},je=class extends O{constructor(){super();this.loading=new S}install(){this.pages=new j(this.app),this.cacheIgnore=this.config.cacheIgnore;let e=T().pathname;this.set(e,new oe),e=null}get(e){return this.pages.get(e)}add(e){return this.pages.add(e),this}set(e,t){return this.pages.set(e,t),this}remove(e){return this.pages.remove(e),this}has(e){return this.pages.has(e)}clear(){return this.pages.clear(),this}get size(){return this.pages.size}keys(){return this.pages.keys()}async load(e=T()){let t=T(e),r=t.pathname,n,s;if(this.has(r)&&!q(r,this.cacheIgnore))return n=this.get(r),Promise.resolve(n);this.loading.has(r)?s=this.loading.get(r):(s=this.request(r),this.loading.set(r,s));let a=await s;if(this.loading.remove(r),n=new oe(t,a),this.set(r,n),this.size>this.config.maxPages){let l=T(),p=this.keys(),o=J(l,p[0])?p[1]:p[0],c=this.get(o);c.unregister(),c=null,p=null,l=null,o=null}return n}async request(e){let t=new Headers(this.config.headers),r=window.setTimeout(()=>{window.clearTimeout(r);let n=new Error("Request Timed Out!");throw this.emitter.emit("TIMEOUT_ERROR",n),n},this.config.timeout);try{let n=await fetch(e,{mode:"same-origin",method:"GET",headers:t,cache:"default",credentials:"same-origin"});if(window.clearTimeout(r),n.status>=200&&n.status<300)return await n.text();let s=new Error(n.statusText||""+n.status);throw this.emitter.emit("REQUEST_ERROR",s),s}catch(n){throw window.clearTimeout(r),n}}},q=(i,e)=>{if(typeof e=="boolean")return e;let t=[];return!e.every(r=>(0,Ve.pathToRegexp)(r,t,{start:!1,end:!1}).exec(i)==null)};var Ie=(i,e=window.location.hash)=>{try{let t=e[0]=="#"?e:T(e).hash;if(t.length>1){let r=document.getElementById(t.slice(1));if(r){let{left:n,top:s}=r.getBoundingClientRect(),a=window.scrollX,l=window.scrollY,p=n+a,o=s+l;return H(p,o)}}}catch(t){console.warn("[hashAction] error",t)}return i??H(0,0)},Se={name:"replace"},Ge=class extends O{constructor(e){super();this._arg=e}install(){super.install();let e=this._arg&&this._arg.length?this._arg:this.config.transitions;this.transitions=new S([["default",Se],["replace",Se]].concat(e))}get(e){return this.transitions.get(e)}set(e,t){return this.transitions.set(e,t),this}add(e){return this.transitions.add(e),this}has(e){return this.transitions.has(e)}async start(e,t){let r=this.transitions.get(e),{oldPage:n,newPage:s,ignoreHashAction:a,trigger:l}=t;if(this.emitter.emit("TRANSITION_START",{transitionName:e,...t}),!("wrapper"in n)||!("wrapper"in s))throw`[TransitionManager] either oldPage or newPage aren't instances of the Page Class. + ${{newPage:s,oldPage:n}}`;document.title=""+s.title;let p=n.wrapper,o=s.wrapper;if(!(p instanceof Node)||!(o instanceof Node))throw`[TransitionManager] the wrapper from the ${o instanceof Node?"current":"next"} page cannot be found. The wrapper must be an element that has the attribute ${_(this.config,"wrapperAttr")}.`;return r.init&&r?.init(t),this.emitter.emit("BEFORE_TRANSITION_OUT",t),r.out&&await new Promise(c=>{r.out.call(r,{...t,from:n,done:c})?.then(c)}),this.emitter.emit("AFTER_TRANSITION_OUT",t),await new Promise(c=>{p.insertAdjacentElement("beforebegin",o),this.emitter.emit("CONTENT_INSERT",t),c()}),await new Promise(c=>{p.remove(),p=null,o=null,this.emitter.emit("CONTENT_REPLACED",t),!a&&!/back|popstate|forward/.test(l)&&(t.scroll=Ie(t.scroll)),c()}),this.emitter.emit("BEFORE_TRANSITION_IN",t),r.in&&await new Promise(c=>{r.in.call(r,{...t,from:n,to:s,done:c})?.then(c)}),this.emitter.emit("AFTER_TRANSITION_IN",t),r.manualScroll||(!a&&!/back|popstate|forward/.test(l)&&(t.scroll=Ie(t.scroll)),window.scroll(t.scroll.x,t.scroll.y)),this.emitter.emit("TRANSITION_END",{transitionName:e,...t}),t}};var qe=class{constructor(e={}){this.canResize=!0;this.canScroll=!0;this._resize=this._resize.bind(this),this._scroll=this._scroll.bind(this),this._ready=this._ready.bind(this),this.register(e)}register(e={}){return this.config=be(e),this.emitter=new V,this.services=new ae(this),this}_ready(){document.removeEventListener("DOMContentLoaded",this._ready),window.removeEventListener("load",this._ready),this.emitter.emit("READY ready")}_resize(){if(this.canResize){let e,t;this.canResize=!1,t=window.requestAnimationFrame(()=>{this.emitter.emit("RESIZE resize"),e=window.setTimeout(()=>{this.canResize=!0,e=window.clearTimeout(e),t=window.cancelAnimationFrame(t)},this.config.resizeDelay)})}}_scroll(){if(this.canScroll){let e;this.canScroll=!1,e=requestAnimationFrame(()=>{this.emitter.emit("SCROLL scroll"),this.canScroll=!0,e=window.cancelAnimationFrame(e)})}}get(e){return this.services.get(e)}set(e,t){return this.services.set(e,t),this}add(e){return this.services.add(e),this}boot(){return document.addEventListener("DOMContentLoaded",this._ready),window.addEventListener("load",this._ready),window.addEventListener("resize",this._resize,{passive:!0}),window.addEventListener("scroll",this._scroll,{passive:!0}),this.services.init(),this.services.boot(),this}stop(){return window.removeEventListener("resize",this._resize),window.removeEventListener("scroll",this._scroll),this.services.stop(),this.emitter.clear(),this}on(e,t){return this.emitter.on(e,t,this),this}off(e,t){return this.emitter.off(e,t,this),this}emit(e,...t){return this.emitter.emit(e,...t),this}};var $e=class extends O{install(){super.install(),this.preventURLs=this.config.preventURLs,this.prefetchIgnore=this.config.prefetchIgnore,this.onTransitionPreventClick=this.config.onTransitionPreventClick,this.stickyScroll=this.config.stickyScroll,this.forceOnError=this.config.forceOnError,this.ignoreHashAction=this.config.ignoreHashAction}transitionStart(){this.isTransitioning=!0}transitionStop(){this.isTransitioning=!1}init(){this.onHover=this.onHover.bind(this),this.onClick=this.onClick.bind(this),this.onStateChange=this.onStateChange.bind(this)}boot(){super.boot()}getTransitionName(e){if(!e||!e.getAttribute)return null;let t=e.getAttribute(_(this.config,"transitionAttr",!1));return typeof t=="string"?t:null}validLink(e,t,r){let n=!window.history.pushState,s=!e||!r,a=t.metaKey||t.ctrlKey||t.shiftKey||t.altKey,l=e.hasAttribute("target")&&e.target==="_blank",p=e.protocol!==location.protocol||e.hostname!==location.hostname,o=typeof e.getAttribute("download")=="string",c=e.matches(_(this.config,"preventSelfAttr")),u=Boolean(e.closest(_(this.config,"preventAllAttr"))),f=q(T(r).pathname,this.preventURLs),h=k(T())===k(T(r));return!(s||n||a||l||p||o||c||u||f||h)}getHref(e){return e&&e.tagName&&e.tagName.toLowerCase()==="a"&&typeof e.href=="string"?e.href:null}getLink(e){let t=e.target,r=this.getHref(t);for(;t&&!r;)t=t.parentNode,r=this.getHref(t);if(!(!t||!this.validLink(t,e,r)))return t}onClick(e){let t=this.getLink(e);if(!t)return;if(this.isTransitioning&&this.onTransitionPreventClick){e.preventDefault(),e.stopPropagation();return}let r=this.getHref(t);this.emitter.emit("ANCHOR_CLICK CLICK",e),this.go({href:r,trigger:t,event:e})}getDirection(e){return Math.abs(e)>1?e>0?"forward":"back":e===0?"popstate":e>0?"back":"forward"}force(e){window.location.assign(e)}go({href:e,trigger:t="HistoryManager",event:r}){if(this.isTransitioning&&!this.onTransitionPreventClick||!(this.manager.has("TransitionManager")&&this.manager.has("HistoryManager")&&this.manager.has("PageManager"))){this.force(e);return}let n=this.manager.get("HistoryManager"),s=H(0,0),a=n.current,l=a.url;if(J(l,e))return;let p;if(r&&r.state){this.emitter.emit("POPSTATE",r);let{state:o}=r,{index:c}=o,f=a.index-c;n.replace(o.states),n.pointer=c;let h=n.get(c);p=h.transition,s=h.data.scroll,t=this.getDirection(f),this.emitter.emit(t==="back"?"POPSTATE_BACK":"POPSTATE_FORWARD",r)}else{p=this.getTransitionName(t),s=H();let o=Q({url:e,transition:p,data:{scroll:s}});!this.stickyScroll&&(s=H(0,0)),n.add(o),this.emitter.emit("HISTORY_NEW_ITEM",r)}return r&&(r.stopPropagation(),r.preventDefault()),this.emitter.emit("GO",r),this.load({oldHref:l,href:e,trigger:t,transitionName:p,scroll:s})}async load({oldHref:e,href:t,trigger:r,transitionName:n="default",scroll:s={x:0,y:0}}){try{let a=this.manager.get("TransitionManager"),l=this.manager.get("PageManager"),p=this.ignoreHashAction,o,c;this.emitter.emit("NAVIGATION_START",{oldHref:e,href:t,trigger:r,transitionName:n,scroll:s}),a.has(n)||(console.log(`[PJAX] transition name "${n}" doesn't exist, switching to the "default" transition`),n="default");try{this.transitionStart(),this.emitter.emit("PAGE_LOADING",{href:t,oldHref:e,trigger:r,scroll:s}),c=await l.load(e),o=await l.load(t),this.emitter.emit("PAGE_LOAD_COMPLETE",{newPage:o,oldPage:c,trigger:r,scroll:s}),c.dom instanceof Element||c.build(),o.build()}catch(u){console.warn("[PJAX] Page load error",u)}try{s=(await a.start(n,{oldPage:c,newPage:o,trigger:r,scroll:s,ignoreHashAction:p})).scroll}catch(u){console.warn("[PJAX] Transition error",u)}this.emitter.emit("NAVIGATION_END",{oldPage:c,newPage:o,trigger:r,transitionName:n,scroll:s})}catch(a){this.forceOnError?this.force(t):console.warn(a)}finally{this.transitionStop()}}onHover(e){let t=this.getLink(e);if(!t||!this.manager.has("PageManager"))return;let r=this.manager.get("PageManager"),n=T(this.getHref(t)),s=n.pathname;if(this.emitter.emit("ANCHOR_HOVER HOVER",e),!q(n.pathname,this.prefetchIgnore)&&!(r.has(s)&&!q(s,r.cacheIgnore)))try{r.load(n),this.emitter.emit("PREFETCH",e)}catch(a){console.warn("[PJAX] Prefetch error",a)}}onStateChange(e){this.go({href:window.location.href,trigger:"popstate",event:e})}initEvents(){this.prefetchIgnore!==!0&&(document.addEventListener("mouseover",this.onHover),document.addEventListener("touchstart",this.onHover)),document.addEventListener("click",this.onClick),window.addEventListener("popstate",this.onStateChange)}stopEvents(){this.prefetchIgnore!==!0&&(document.removeEventListener("mouseover",this.onHover),document.removeEventListener("touchstart",this.onHover)),document.removeEventListener("click",this.onClick),window.removeEventListener("popstate",this.onStateChange)}};var Xe=Pe(xe()),Ye=class extends O{constructor(e=[]){super();this.routes=new S;for(let t of e)this.add(t)}add({path:e,method:t}){let r=this.parse(e);return this.routes.set(r,t),this}parsePath(e){if(typeof e=="string"||e instanceof RegExp||Array.isArray(e))return(0,Xe.pathToRegexp)(e,[],{start:!1,end:!1});if(typeof e=="boolean")return e&&/.*/;throw"[Router] only regular expressions, strings, booleans and arrays of regular expressions and strings are accepted as paths."}isPath(e){return typeof e=="string"||e instanceof RegExp||typeof e=="boolean"||Array.isArray(e)}parse(e){let t=e,r={from:/.*/,to:/.*/};if(this.isPath(e))r={from:!0,to:e};else if(this.isPath(t.from)&&this.isPath(t.to))r=Object.assign({},r,t);else throw"[Router] path is neither a string, regular expression, or a { from, to } object.";let{from:n,to:s}=r;return{from:this.parsePath(n),to:this.parsePath(s)}}route(){if(this.manager.has("HistoryManager")){let e=this.manager.get("HistoryManager"),t=k(T((e.length>1?e.previous:e.current).url)),r=k(T());this.routes.forEach((n,s)=>{let a=s.from,l=s.to;if(typeof a=="boolean"&&typeof l=="boolean")throw`[Router] path ({ from: ${a}, to: ${l} }) is not valid, remember paths can only be strings, regular expressions, or a boolean; however, both the from and to paths cannot be both booleans.`;let p=a,o=l;a instanceof RegExp&&a.test(t)&&(p=a.exec(t)),l instanceof RegExp&&l.test(r)&&(o=l.exec(r)),(Array.isArray(o)&&Array.isArray(p)||Array.isArray(o)&&p==!1&&!l.test(t)||Array.isArray(p)&&o==!1&&!a.test(r))&&n({from:p,to:o,path:{from:t,to:r}})})}else console.warn("[Route] HistoryManager is missing.")}initEvents(){this.emitter.on("READY",this.route,this),this.emitter.on("CONTENT_REPLACED",this.route,this)}stopEvents(){this.emitter.off("READY",this.route,this),this.emitter.off("CONTENT_REPLACED",this.route,this)}};0&&(module.exports={AdvancedManager,Animate,App,CONFIG_DEFAULTS,CSSArrValue,CSSValue,DefaultAnimationOptions,EASINGS,EFFECTS,EasingKeys,Event,EventEmitter,GetEase,HistoryManager,KeyframeParse,Manager,ManagerItem,PARSER,PJAX,Page,PageManager,ParseTransformableCSSKeyframes,ParseTransformableCSSProperties,Replace,Router,Service,ServiceManager,TransformFunctionNames,TransitionManager,UnitDEG,UnitDEGCSSValue,UnitLess,UnitLessCSSValue,UnitPX,UnitPXCSSValue,addCSSUnit,animate,asyncMethodCall,changeState,clean,computeOption,createTransformProperty,equal,flatten,getElements,getHash,getHashedPath,getTargets,hashAction,ignoreURLs,isValid,mapAnimationOptions,mapObject,methodCall,newConfig,newCoords,newListener,newState,newURL,omit,parseOffset,parseOptions,toArr,toAttr,transpose}); diff --git a/packages/native/lib/api.es.js b/packages/native/lib/api.es.js index 5285fe5..e5da628 100644 --- a/packages/native/lib/api.es.js +++ b/packages/native/lib/api.es.js @@ -1,2 +1,2 @@ -var S=class{constructor(e){this.map=new Map(e)}getMap(){return this.map}get(e){return this.map.get(e)}keys(){return Array.from(this.map.keys())}values(){return Array.from(this.map.values())}set(e,t){return this.map.set(e,t),this}add(e){let i=this.size;return this.set(i,e),this}get size(){return this.map.size}get length(){return this.map.size}last(e=1){let t=this.keys()[this.size-e];return this.get(t)}delete(e){return this.map.delete(e)}remove(e){return this.map.delete(e),this}clear(){return this.map.clear(),this}has(e){return this.map.has(e)}entries(){return this.map.entries()}forEach(e,t){return this.map.forEach(e,t),this}[Symbol.iterator](){return this.entries()}},_=(r,e,...t)=>{r.forEach(i=>{i[e](...t)})},Ge=async(r,e,...t)=>{for(let[,i]of r)await i[e](...t)};var oe=({callback:r=()=>{},scope:e=null,name:t="event"})=>({callback:r,scope:e,name:t}),U=class extends S{constructor(e="event"){super();this.name=e}},F=class extends S{constructor(){super()}getEvent(e){let t=this.get(e);return t instanceof U?t:(this.set(e,new U(e)),this.get(e))}newListener(e,t,i){let n=this.getEvent(e);return n.add(oe({name:e,callback:t,scope:i})),n}on(e,t,i){if(typeof e=="undefined"||e==null)return this;typeof e=="string"&&(e=e.trim().split(/\s/g));let n,s,a=typeof e=="object"&&!Array.isArray(e),l=a?t:i;return a||(s=t),Object.keys(e).forEach(o=>{n=a?o:e[o],a&&(s=e[o]),this.newListener(n,s,l)},this),this}removeListener(e,t,i){let n=this.get(e);if(n instanceof U&&t){let s=oe({name:e,callback:t,scope:i});n.forEach((a,l)=>{if(a.callback===s.callback&&a.scope===s.scope)return n.remove(l)})}return n}off(e,t,i){if(typeof e=="undefined"||e==null)return this;typeof e=="string"&&(e=e.trim().split(/\s/g));let n,s,a=typeof e=="object"&&!Array.isArray(e),l=a?t:i;return a||(s=t),Object.keys(e).forEach(o=>{n=a?o:e[o],a&&(s=e[o]),typeof s=="function"?this.removeListener(n,s,l):this.remove(n)},this),this}once(e,t,i){if(typeof e=="undefined"||e==null)return this;typeof e=="string"&&(e=e.trim().split(/\s/g));let n=typeof e=="object"&&!Array.isArray(e);return Object.keys(e).forEach(s=>{let a=n?s:e[s],l=n?e[s]:t,o=n?t:i,p=(...c)=>{l.apply(o,c),this.removeListener(a,p,o)};this.newListener(a,p,o)},this),this}emit(e,...t){return typeof e=="undefined"||e==null?this:(typeof e=="string"&&(e=e.trim().split(/\s/g)),e.forEach(i=>{let n=this.get(i);n instanceof U&&n.forEach(s=>{let{callback:a,scope:l}=s;a.apply(l,t)})},this),this)}clear(){return _(this,"clear"),super.clear(),this}};var q=r=>typeof r=="string"?r.includes("%")?parseFloat(r)/100:r=="from"?0:r=="to"?1:parseFloat(r):r,le=r=>{let e=new Set,t=Object.keys(r),i=t.length;for(let n=0;nn.offset-s.offset)},Ye={};var Q=(r="")=>e=>typeof e=="string"?e:`${e}${r}`,$=Q(),ee=Q("px"),te=Q("deg"),ie=r=>Array.isArray(r)||typeof r=="string"?(typeof r=="string"&&(r=r.split(",")),r):[r],O=r=>Array.isArray(r)||typeof r=="string"?Boolean(r.length):r!=null&&r!=null,X=r=>e=>O(e)?ie(e).map(t=>{if(typeof t!="number"&&typeof t!="string")return t;let i=Number(t),n=Number.isNaN(i)?typeof t=="string"?t.trim():t:i;return r(n)}):[],ve=(...r)=>{let e=0;r=r.map(n=>{let s=ie(n),a=s.length;return a>e&&(e=a),s});let t=[],i=r.length;for(let n=0;nie(r).map(X(e)),pe=["translate","translate3d","translateX","translateY","translateZ","rotate","rotate3d","rotateX","rotateY","rotateZ","scale","scale3d","scaleX","scaleY","scaleZ","skew","skewX","skewY","perspective"],ce=r=>{let e="",t=pe.length;for(let i=0;i{let{perspective:e,rotate:t,rotate3d:i,rotateX:n,rotateY:s,rotateZ:a,translate:l,translate3d:o,translateX:p,translateY:c,translateZ:f,scale:y,scale3d:u,scaleX:g,scaleY:h,scaleZ:m,skew:E,skewX:b,skewY:A,...d}=r;l=H(l,ee),o=H(o,ee),p=C(p),c=C(c),f=C(f),t=H(t,te),i=H(i,$),n=P(n),s=P(s),a=P(a),y=H(y,$),u=H(u,$),g=L(g),h=L(h),m=L(m),E=H(E,te),b=P(b),A=P(A),e=C(e);let x=ve(l,o,p,c,f,t,i,n,s,a,y,u,g,h,m,E,b,A,e).map(ce);return d=Y(d,v=>[].concat(v).map(I=>""+I)),Object.assign({},O(x)?{transform:x}:null,d)},me=r=>r.map(e=>{let{translate:t,translate3d:i,translateX:n,translateY:s,translateZ:a,rotate:l,rotate3d:o,rotateX:p,rotateY:c,rotateZ:f,scale:y,scale3d:u,scaleX:g,scaleY:h,scaleZ:m,skew:E,skewX:b,skewY:A,perspective:d,easing:x,iterations:v,offset:I,...w}=e;return t=C(t),i=C(i),n=C(n)[0],s=C(s)[0],a=C(a)[0],l=P(l),o=L(o),p=P(p)[0],c=P(c)[0],f=P(f)[0],y=L(y),u=L(u),g=L(g)[0],h=L(h)[0],m=L(m)[0],E=P(E),b=P(b)[0],A=P(A)[0],d=C(d)[0],[w,t,i,n,s,a,l,o,p,c,f,y,u,g,h,m,E,b,A,d]}).map(([e,...t])=>{let i=ce(t);return Object.assign({},O(i)?{transform:i}:null,e)});var xe=r=>typeof r=="string"?Array.from(document.querySelectorAll(r)):[r],Ie=r=>[].concat(...r),re=r=>Array.isArray(r)?Ie(r.map(re)):typeof r=="string"||r instanceof Node?xe(r):r instanceof NodeList||r instanceof HTMLCollection?Array.from(r):[],Se=(r,e,t)=>typeof r=="function"?r.apply(t,e):r,Y=(r,e)=>{let t=Object.keys(r),i,n,s={};for(let a=0,l=t.length;aY(r,i=>Se(i,e,t)),fe={in:"ease-in",out:"ease-out","in-out":"ease-in-out","in-sine":"cubic-bezier(0.47, 0, 0.745, 0.715)","out-sine":"cubic-bezier(0.39, 0.575, 0.565, 1)","in-out-sine":"cubic-bezier(0.445, 0.05, 0.55, 0.95)","in-quad":"cubic-bezier(0.55, 0.085, 0.68, 0.53)","out-quad":"cubic-bezier(0.25, 0.46, 0.45, 0.94)","in-out-quad":"cubic-bezier(0.455, 0.03, 0.515, 0.955)","in-cubic":"cubic-bezier(0.55, 0.055, 0.675, 0.19)","out-cubic":"cubic-bezier(0.215, 0.61, 0.355, 1)","in-out-cubic":"cubic-bezier(0.645, 0.045, 0.355, 1)","in-quart":"cubic-bezier(0.895, 0.03, 0.685, 0.22)","out-quart":"cubic-bezier(0.165, 0.84, 0.44, 1)","in-out-quart":"cubic-bezier(0.77, 0, 0.175, 1)","in-quint":"cubic-bezier(0.755, 0.05, 0.855, 0.06)","out-quint":"cubic-bezier(0.23, 1, 0.32, 1)","in-out-quint":"cubic-bezier(0.86, 0, 0.07, 1)","in-expo":"cubic-bezier(0.95, 0.05, 0.795, 0.035)","out-expo":"cubic-bezier(0.19, 1, 0.22, 1)","in-out-expo":"cubic-bezier(1, 0, 0, 1)","in-circ":"cubic-bezier(0.6, 0.04, 0.98, 0.335)","out-circ":"cubic-bezier(0.075, 0.82, 0.165, 1)","in-out-circ":"cubic-bezier(0.785, 0.135, 0.15, 0.86)","in-back":"cubic-bezier(0.6, -0.28, 0.735, 0.045)","out-back":"cubic-bezier(0.175, 0.885, 0.32, 1.275)","in-out-back":"cubic-bezier(0.68, -0.55, 0.265, 1.55)"},we=Object.keys(fe),ge=r=>{let e=r.replace(/^ease-/,"");return we.includes(e)?fe[e]:r},Pe={keyframes:[],offset:[],loop:1,delay:0,speed:1,endDelay:0,easing:"ease",timelineOffset:0,autoplay:!0,duration:1e3,fillMode:"none",direction:"normal",padEndDelay:!1,extend:{}},Re=r=>{let{options:e,...t}=r,i=e instanceof B?e.options:Array.isArray(e)?e?.[0]?.options:e;return Object.assign({},i,t)},W=(r,e)=>{let t={...e};for(;r.length;){let{[r.pop()]:i,...n}=t;t=n}return t},ne=class{constructor(e){this.options={};this.properties={};this.totalDuration=0;this.emitter=new F;this.targets=new S;this.targetIndexes=new WeakMap;this.keyframeEffects=new WeakMap;this.computedOptions=new WeakMap;this.animations=new WeakMap;this.computedKeyframes=new WeakMap;this.loop=this.loop.bind(this),this.onVisibilityChange=this.onVisibilityChange.bind(this),this.on("error",t=>console.error(t)),this.updateOptions(e),this.visibilityPlayState=this.getPlayState(),ne.pauseOnPageHidden&&document.addEventListener("visibilitychange",this.onVisibilityChange,!1),this.newPromise()}onVisibilityChange(){document.hidden?(this.visibilityPlayState=this.getPlayState(),this.is("running")&&(this.loop(),this.pause())):this.visibilityPlayState=="running"&&this.is("paused")&&this.play()}newPromise(){return this.promise=new Promise((e,t)=>{this?.emitter?.once?.("finish",()=>e([this])),this?.emitter?.once?.("error",i=>t(i))}),this.promise}then(e,t){return e=e?.bind(this),t=t?.bind(this),this?.promise?.then?.(e,t),this}catch(e){return e=e?.bind(this),this.promise?.catch?.(e),this}finally(e){return e=e?.bind(this),this.promise?.finally?.(e),this}loop(){this.stopLoop(),this.animationFrame=window.requestAnimationFrame(this.loop),this.emit("update",this.getProgress(),this)}stopLoop(){window.cancelAnimationFrame(this.animationFrame)}allAnimations(e){return this.targets.forEach(t=>{let i=this.keyframeEffects.get(t),n=this.animations.get(i);return e(n,t)}),this}all(e){return this.mainAnimation&&e(this.mainAnimation,this.mainElement),this.allAnimations(e),this}beginEvent(){this.getProgress()==0&&this.emit("begin",this)}play(){let e=this.getPlayState();return this.beginEvent(),this.all(t=>t.play()),this.emit("play",e,this),this.is(e)||this.emit("playstate-change",e,this),this.loop(),this}pause(){let e=this.getPlayState();return this.all(t=>t.pause()),this.emit("pause",e,this),this.is(e)||this.emit("playstate-change",e,this),this.stopLoop(),this}reverse(){return this.all(e=>e.reverse()),this}reset(){return this.setProgress(0),this.options.autoplay?this.play():this.pause(),this}cancel(){return this.all(e=>e.cancel()),this}finish(){return this.all(e=>e.finish()),this}stop(){this.cancel(),this.stopLoop(),document.removeEventListener("visibilitychange",this.onVisibilityChange,!1),this.targets.forEach(e=>this.removeTarget(e)),this.emit("stop"),this.emitter.clear(),this.mainkeyframeEffect=null,this.mainAnimation=null,this.mainElement=null,this.promise=null,this.computedOptions=null,this.animations=null,this.keyframeEffects=null,this.emitter=null,this.targets=null,this.options=null,this.properties=null}getAnimation(e){let t=this.keyframeEffects.get(e);return this.animations.get(t)}getTiming(e){let t=this.computedOptions.get(e)??{},i=this.keyframeEffects.get(e).getTiming?.()??{};return{...t,...i}}getCurrentTime(){return this.mainAnimation.currentTime}getProgress(){return this.getCurrentTime()/this.totalDuration*100}getSpeed(){return this.mainAnimation.playbackRate}getPlayState(){return this.mainAnimation.playState}is(e){return this.getPlayState()==e}setCurrentTime(e){return this.all(t=>t.currentTime=e),this.emit("update",this.getProgress()),this}setProgress(e){let t=e/100*this.totalDuration;return this.setCurrentTime(t),this}setSpeed(e=1){return this.maxSpeed=e,this.all(t=>{t.updatePlaybackRate?t.updatePlaybackRate(e):t.playbackRate=e}),this}createArrayOfComputedOptions(e,t){let i=[];return this.targets.forEach((n,s)=>{let a=this.computedOptions.get(n)??{},l=b=>{let A=b;return b=="loop"&&(A="iterations"),b=="fillMode"&&(A="fill"),e[b]??a[A]??this.options[b]},o=Object.assign({easing:l("easing"),iterations:l("loop"),direction:l("direction"),endDelay:l("endDelay"),duration:l("duration"),speed:l("speed"),delay:l("delay"),timelineOffset:l("timelineOffset"),keyframes:l("keyframes")},l("extend")??{}),p=he(o,[s,t,n],this);typeof p.easing=="string"&&(p.easing=ge(p.easing)),p.iterations===!0&&(p.iterations=Infinity),p.fill=l("fillMode");let{timelineOffset:c,speed:f,endDelay:y,delay:u,duration:g,iterations:h,...m}=p;h=Number(h),g=Number(g),y=Number(y),f=Number(f),u=Number(u)+Number(c);let E=u+g*h+y;this.totalDuration{let{speed:c,keyframes:f,tempDurations:y,...u}=i[p];n&&u.endDelay==0&&Math.abs(u.iterations)!=Math.abs(Infinity)&&(u.endDelay=this.totalDuration-y);let g,h,m=f;typeof m=="object"&&(m=le(m));let E=this.computedKeyframes.get(o)??{},b=Object.assign({},s,E),A=Y(b,(v,I)=>this.properties[I]??v);if(h=O(m)?m:A,Array.isArray(h))g=h.map(v=>{let{easing:I,offset:w,...D}=W(["speed","loop"],v);return Object.assign({},D,typeof I=="string"?{easing:ge(I)}:null,typeof w=="string"||typeof w=="number"?{offset:q(w)}:null)}),g=me(g);else{let v=W(["keyframes"],h),{offset:I,...w}=he(v,[p,t,o],this);w=ue(w);let D=I;g=Object.assign({},w,O(D)?{offset:D.map(q)}:null)}let d,x;this.keyframeEffects.has(o)?(x=this.keyframeEffects.get(o),d=this.animations.get(x),x?.setKeyframes?.(g),x?.updateTiming?.(u)):(x=new KeyframeEffect(o,g,u),d=new Animation(x,u.timeline),this.keyframeEffects.set(o,x),this.animations.set(x,d)),d.playbackRate=c,d.onfinish=()=>{typeof a=="function"&&a.call(this,o,p,t,d)},d.oncancel=()=>{typeof l=="function"&&l.call(this,o,p,t,d)},this.computedOptions.set(o,u),this.computedKeyframes.set(o,g)})}updateOptions(e={}){try{let t=Re(e);this.options=Object.assign({},Pe,this.options,t);let i=["easing","loop","endDelay","duration","speed","delay","timelineOffset","direction","extend","fillMode","offset"],{padEndDelay:n,onfinish:s,oncancel:a,autoplay:l,target:o,targets:p,...c}=W(i,this.options);this.properties=W([...i,"keyframes","padEndDelay","onfinish","oncancel","autoplay","target","targets"],t);let f=this.targets.values(),y=[...new Set([...f,...re(p),...re(o)])];this.targets.clear(),y.forEach((h,m)=>{this.targets.set(m,h),this.targetIndexes.set(h,m)});let u=this.targets.size,g=this.createArrayOfComputedOptions(t,u);if(this.createAnimations({arrOfComputedOptions:g,padEndDelay:n,oldCSSProperties:c,onfinish:s,oncancel:a},u),this.maxSpeed=this.maxSpeed??this.options.speed,this.minDelay=this.minDelay??this.options.delay,this.totalDuration=this.totalDuration??this.options.duration,this.mainAnimation?(this.mainkeyframeEffect?.updateTiming?.({duration:this.totalDuration}),(!this.mainkeyframeEffect.setKeyframes||!this.mainkeyframeEffect.updateTiming)&&console.warn("@okikio/animate - `KeyframeEffect.setKeyframes` and/or `KeyframeEffect.updateTiming` are not supported in this browser.")):(this.mainkeyframeEffect=new KeyframeEffect(this.mainElement,[{opacity:"0"},{opacity:"1"}],{duration:this.totalDuration,easing:"linear"}),this.mainAnimation=new Animation(this.mainkeyframeEffect,this.options.timeline)),this.mainAnimation.playbackRate=this.maxSpeed,this.mainAnimation.onfinish=()=>{if(this.emit("finish",this),this.mainAnimation){let h=this.getPlayState();this.is(h)||this.emit("playstate-change",h,this),this.stopLoop()}},this.mainAnimation.oncancel=()=>{if(this.emit("cancel",this),this.mainAnimation){let h=this.getPlayState();this.is(h)||this.emit("playstate-change",h,this),this.stopLoop()}},l){let h=window.setTimeout(()=>{this.emit("begin",this),h=window.clearTimeout(h)},0);this.play()}else this.pause()}catch(t){this.emit("error",t)}}add(e){let t=this.getProgress(),i=this.is("running"),n=this.is("paused");this.updateOptions({target:e}),this.setProgress(t),i?this.play():n&&this.pause()}removeTarget(e){let t=this.keyframeEffects.get(e);this.animations.delete(t),t=null,this.computedKeyframes.delete(e),this.computedOptions.delete(e),this.keyframeEffects.delete(e);let i=this.targetIndexes.get(e);this.targets.delete(i),this.targetIndexes.delete(e)}remove(e){this.removeTarget(e);let t=new Set([].concat(this.targets.values()));this.options.target=[...t],this.options.targets=[],t.clear(),t=null;let i=this.getProgress(),n=this.is("running"),s=this.is("paused");this.updateOptions(),n?this.play():s&&this.pause(),this.setProgress(i)}on(e,t,i){return this?.emitter?.on(e,t,i??this),this}off(e,t,i){return this?.emitter?.off(e,t,i??this),this}emit(e,...t){return this?.emitter?.emit(e,...t),this}toJSON(){return this.options}get[Symbol.toStringTag](){return"Animate"}},B=ne;B.pauseOnPageHidden=!0;var nt=(r={})=>new B(r);var Oe={wrapperAttr:"wrapper",headers:[],preventSelfAttr:'prevent="self"',preventAllAttr:'prevent="all"',transitionAttr:"transition",timeout:2e3,maxPages:5,resizeDelay:100,onTransitionPreventClick:!0,cacheIgnore:!1,prefetchIgnore:!1,preventURLs:[],stickyScroll:!1,forceOnError:!0,ignoreHashAction:!1,transitions:[]},ye=r=>Object.assign({...Oe},r),k=(r,e,t=!0)=>{let{prefix:i}=r,n=r[e],s=`data${i?"-"+i:""}-${n}`;return t?`[${s}]`:s};var V=class{constructor(){}install(){}register(e,t){return this.manager=e,this.app=e.app,this.config=e.config,this.emitter=e.emitter,this.key=t,this.install(),this}uninstall(){}unregister(){this.uninstall(),this.manager.remove(this.key),this.key=null,this.manager=null,this.app=null,this.config=null,this.emitter=null}},z=class extends S{constructor(e){super();this.app=e,this.config=e.config,this.emitter=e.emitter}set(e,t){return super.set(e,t),t.register(this,e),this}};var T=(r=window.location.href)=>r instanceof URL?r:new URL(r,window.location.origin),M=r=>{let e=T(r);return`${e.pathname}${e.hash}`},mt=r=>T(r).hash.slice(1),de=r=>T(r).toString().replace(/(\/#.*|\/|#.*)$/,""),Z=(r,e)=>de(r)===de(e);var R=class extends V{init(){}boot(){this.initEvents()}initEvents(){}stopEvents(){}stop(){this.stopEvents(),this.unregister()}},se=class extends z{constructor(e){super(e)}init(){return _(this,"init"),this}boot(){return _(this,"boot"),this}stop(){return _(this,"stop"),this}};var N=(r=window.scrollX,e=window.scrollY)=>({x:r,y:e}),J=(r={url:M(T()),index:0,transition:"default",data:{scroll:N(),trigger:"HistoryManager"}})=>r,Ce=class extends R{constructor(){super(...arguments);this.pointer=-1}init(){this.states=[];let e=J();this.add(e,"replace")}get(e){return this.states[e]}add(e,t="push"){let i=J(e),n=this.length;this.states.push({...i}),this.pointer=n;let s={index:this.pointer,states:[...this.states]};return Le(t,i,s),this}remove(e){return e?this.states.splice(e,1):this.states.pop(),this.pointer--,this}replace(e){return this.states=e,this}set(e,t){return this.states[e]=t}get current(){return this.get(this.pointer)}get last(){return this.get(this.length-1)}get previous(){return this.pointer<1?null:this.get(this.pointer-1)}get length(){return this.states.length}},Le=(r,e,t)=>{let i=M(e.url),n=[t,"",i];if(window.history)switch(r){case"push":window.history.pushState.apply(window.history,n);break;case"replace":window.history.replaceState.apply(window.history,n);break}};function Me(r){for(var e=[],t=0;t=48&&a<=57||a>=65&&a<=90||a>=97&&a<=122||a===95){n+=r[s++];continue}break}if(!n)throw new TypeError("Missing parameter name at "+t);e.push({type:"NAME",index:t,value:n}),t=s;continue}if(i==="("){var l=1,o="",s=t+1;if(r[s]==="?")throw new TypeError('Pattern cannot start with "?" at '+s);for(;s)?(?!\?)/g,i=0,n=t.exec(r.source);n;)e.push({name:n[1]||i++,prefix:"",suffix:"",modifier:"",pattern:""}),n=t.exec(r.source);return r}function _e(r,e,t){var i=r.map(function(n){return j(n,e,t).source});return new RegExp("(?:"+i.join("|")+")",be(t))}function He(r,e,t){return De(ke(r,t),e,t)}function De(r,e,t){t===void 0&&(t={});for(var i=t.strict,n=i===void 0?!1:i,s=t.start,a=s===void 0?!0:s,l=t.end,o=l===void 0?!0:l,p=t.encode,c=p===void 0?function(v){return v}:p,f="["+K(t.endsWith||"")+"]|$",y="["+K(t.delimiter||"/#?")+"]",u=a?"^":"",g=0,h=r;g-1:d===void 0;n||(u+="(?:"+y+"(?="+f+"))?"),x||(u+="(?="+y+"|"+f+")")}return new RegExp(u,be(t))}function j(r,e,t){return r instanceof RegExp?Ne(r,e):Array.isArray(r)?_e(r,e,t):He(r,e,t)}var Ke=new DOMParser,ae=class extends V{constructor(e=T(),t=document){super();this.url=T(e),typeof t=="string"?this.data=t:this.dom=t||document}async build(){if(this.dom instanceof Node||(this.dom=Ke.parseFromString(this.data,"text/html")),!(this.body instanceof Node)){let{title:e,head:t,body:i}=this.dom;this.title=e,this.head=t,this.body=i,this.wrapper=this.body.querySelector(this.wrapperAttr)}}install(){this.wrapperAttr=k(this.config,"wrapperAttr")}uninstall(){this.url=null,this.title=null,this.head=null,this.body=null,this.dom=null,this.wrapper=null,this.data=null,this.wrapperAttr=null}},Ue=class extends R{constructor(){super();this.loading=new S}install(){this.pages=new z(this.app),this.cacheIgnore=this.config.cacheIgnore;let e=T().pathname;this.set(e,new ae),e=null}get(e){return this.pages.get(e)}add(e){return this.pages.add(e),this}set(e,t){return this.pages.set(e,t),this}remove(e){return this.pages.remove(e),this}has(e){return this.pages.has(e)}clear(){return this.pages.clear(),this}get size(){return this.pages.size}keys(){return this.pages.keys()}async load(e=T()){let t=T(e),i=t.pathname,n,s;if(this.has(i)&&!G(i,this.cacheIgnore))return n=this.get(i),Promise.resolve(n);this.loading.has(i)?s=this.loading.get(i):(s=this.request(i),this.loading.set(i,s));let a=await s;if(this.loading.remove(i),n=new ae(t,a),this.set(i,n),this.size>this.config.maxPages){let l=T(),o=this.keys(),p=Z(l,o[0])?o[1]:o[0],c=this.get(p);c.unregister(),c=null,o=null,l=null,p=null}return n}async request(e){let t=new Headers(this.config.headers),i=window.setTimeout(()=>{window.clearTimeout(i);let n=new Error("Request Timed Out!");throw this.emitter.emit("TIMEOUT_ERROR",n),n},this.config.timeout);try{let n=await fetch(e,{mode:"same-origin",method:"GET",headers:t,cache:"default",credentials:"same-origin"});if(window.clearTimeout(i),n.status>=200&&n.status<300)return await n.text();let s=new Error(n.statusText||""+n.status);throw this.emitter.emit("REQUEST_ERROR",s),s}catch(n){throw window.clearTimeout(i),n}}},G=(r,e)=>{if(typeof e=="boolean")return e;let t=[];return!e.every(i=>j(i,t,{start:!1,end:!1}).exec(r)==null)};var Ee=(r,e=window.location.hash)=>{try{let t=e[0]=="#"?e:T(e).hash;if(t.length>1){let i=document.getElementById(t.slice(1));if(i){let{left:n,top:s}=i.getBoundingClientRect(),a=window.scrollX,l=window.scrollY,o=n+a,p=s+l;return N(o,p)}}}catch(t){console.warn("[hashAction] error",t)}return r??N(0,0)},Te={name:"replace"},Fe=class extends R{constructor(e){super();this._arg=e}install(){super.install();let e=this._arg&&this._arg.length?this._arg:this.config.transitions;this.transitions=new S([["default",Te],["replace",Te]].concat(e))}get(e){return this.transitions.get(e)}set(e,t){return this.transitions.set(e,t),this}add(e){return this.transitions.add(e),this}has(e){return this.transitions.has(e)}async start(e,t){let i=this.transitions.get(e),{oldPage:n,newPage:s,ignoreHashAction:a,trigger:l}=t;if(this.emitter.emit("TRANSITION_START",{transitionName:e,...t}),!("wrapper"in n)||!("wrapper"in s))throw`[TransitionManager] either oldPage or newPage aren't instances of the Page Class. - ${{newPage:s,oldPage:n}}`;document.title=""+s.title;let o=n.wrapper,p=s.wrapper;if(!(o instanceof Node)||!(p instanceof Node))throw`[TransitionManager] the wrapper from the ${p instanceof Node?"current":"next"} page cannot be found. The wrapper must be an element that has the attribute ${k(this.config,"wrapperAttr")}.`;return i.init&&i?.init(t),this.emitter.emit("BEFORE_TRANSITION_OUT",t),i.out&&await new Promise(c=>{i.out.call(i,{...t,from:n,done:c})?.then(c)}),this.emitter.emit("AFTER_TRANSITION_OUT",t),await new Promise(c=>{o.insertAdjacentElement("beforebegin",p),this.emitter.emit("CONTENT_INSERT",t),c()}),await new Promise(c=>{o.remove(),o=null,p=null,this.emitter.emit("CONTENT_REPLACED",t),!a&&!/back|popstate|forward/.test(l)&&(t.scroll=Ee(t.scroll)),c()}),this.emitter.emit("BEFORE_TRANSITION_IN",t),i.in&&await new Promise(c=>{i.in.call(i,{...t,from:n,to:s,done:c})?.then(c)}),this.emitter.emit("AFTER_TRANSITION_IN",t),i.manualScroll||(!a&&!/back|popstate|forward/.test(l)&&(t.scroll=Ee(t.scroll)),window.scroll(t.scroll.x,t.scroll.y)),this.emitter.emit("TRANSITION_END",{transitionName:e,...t}),t}};var Ve=class{constructor(e={}){this.canResize=!0;this.canScroll=!0;this._resize=this._resize.bind(this),this._scroll=this._scroll.bind(this),this._ready=this._ready.bind(this),this.register(e)}register(e={}){return this.config=ye(e),this.emitter=new F,this.services=new se(this),this}_ready(){document.removeEventListener("DOMContentLoaded",this._ready),window.removeEventListener("load",this._ready),this.emitter.emit("READY ready")}_resize(){if(this.canResize){let e,t;this.canResize=!1,t=window.requestAnimationFrame(()=>{this.emitter.emit("RESIZE resize"),e=window.setTimeout(()=>{this.canResize=!0,e=window.clearTimeout(e),t=window.cancelAnimationFrame(t)},this.config.resizeDelay)})}}_scroll(){if(this.canScroll){let e;this.canScroll=!1,e=requestAnimationFrame(()=>{this.emitter.emit("SCROLL scroll"),this.canScroll=!0,e=window.cancelAnimationFrame(e)})}}get(e){return this.services.get(e)}set(e,t){return this.services.set(e,t),this}add(e){return this.services.add(e),this}boot(){return document.addEventListener("DOMContentLoaded",this._ready),window.addEventListener("load",this._ready),window.addEventListener("resize",this._resize,{passive:!0}),window.addEventListener("scroll",this._scroll,{passive:!0}),this.services.init(),this.services.boot(),this}stop(){return window.removeEventListener("resize",this._resize),window.removeEventListener("scroll",this._scroll),this.services.stop(),this.emitter.clear(),this}on(e,t){return this.emitter.on(e,t,this),this}off(e,t){return this.emitter.off(e,t,this),this}emit(e,...t){return this.emitter.emit(e,...t),this}};var ze=class extends R{install(){super.install(),this.preventURLs=this.config.preventURLs,this.prefetchIgnore=this.config.prefetchIgnore,this.onTransitionPreventClick=this.config.onTransitionPreventClick,this.stickyScroll=this.config.stickyScroll,this.forceOnError=this.config.forceOnError,this.ignoreHashAction=this.config.ignoreHashAction}transitionStart(){this.isTransitioning=!0}transitionStop(){this.isTransitioning=!1}init(){this.onHover=this.onHover.bind(this),this.onClick=this.onClick.bind(this),this.onStateChange=this.onStateChange.bind(this)}boot(){super.boot()}getTransitionName(e){if(!e||!e.getAttribute)return null;let t=e.getAttribute(k(this.config,"transitionAttr",!1));return typeof t=="string"?t:null}validLink(e,t,i){let n=!window.history.pushState,s=!e||!i,a=t.metaKey||t.ctrlKey||t.shiftKey||t.altKey,l=e.hasAttribute("target")&&e.target==="_blank",o=e.protocol!==location.protocol||e.hostname!==location.hostname,p=typeof e.getAttribute("download")=="string",c=e.matches(k(this.config,"preventSelfAttr")),f=Boolean(e.closest(k(this.config,"preventAllAttr"))),y=G(T(i).pathname,this.preventURLs),u=M(T())===M(T(i));return!(s||n||a||l||o||p||c||f||y||u)}getHref(e){return e&&e.tagName&&e.tagName.toLowerCase()==="a"&&typeof e.href=="string"?e.href:null}getLink(e){let t=e.target,i=this.getHref(t);for(;t&&!i;)t=t.parentNode,i=this.getHref(t);if(!(!t||!this.validLink(t,e,i)))return t}onClick(e){let t=this.getLink(e);if(!t)return;if(this.isTransitioning&&this.onTransitionPreventClick){e.preventDefault(),e.stopPropagation();return}let i=this.getHref(t);this.emitter.emit("ANCHOR_CLICK CLICK",e),this.go({href:i,trigger:t,event:e})}getDirection(e){return Math.abs(e)>1?e>0?"forward":"back":e===0?"popstate":e>0?"back":"forward"}force(e){window.location.assign(e)}go({href:e,trigger:t="HistoryManager",event:i}){if(this.isTransitioning&&!this.onTransitionPreventClick||!(this.manager.has("TransitionManager")&&this.manager.has("HistoryManager")&&this.manager.has("PageManager"))){this.force(e);return}let n=this.manager.get("HistoryManager"),s=N(0,0),a=n.current,l=a.url;if(Z(l,e))return;let o;if(i&&i.state){this.emitter.emit("POPSTATE",i);let{state:p}=i,{index:c}=p,y=a.index-c;n.replace(p.states),n.pointer=c;let u=n.get(c);o=u.transition,s=u.data.scroll,t=this.getDirection(y),this.emitter.emit(t==="back"?"POPSTATE_BACK":"POPSTATE_FORWARD",i)}else{o=this.getTransitionName(t),s=N();let p=J({url:e,transition:o,data:{scroll:s}});!this.stickyScroll&&(s=N(0,0)),n.add(p),this.emitter.emit("HISTORY_NEW_ITEM",i)}return i&&(i.stopPropagation(),i.preventDefault()),this.emitter.emit("GO",i),this.load({oldHref:l,href:e,trigger:t,transitionName:o,scroll:s})}async load({oldHref:e,href:t,trigger:i,transitionName:n="default",scroll:s={x:0,y:0}}){try{let a=this.manager.get("TransitionManager"),l=this.manager.get("PageManager"),o=this.ignoreHashAction,p,c;this.emitter.emit("NAVIGATION_START",{oldHref:e,href:t,trigger:i,transitionName:n,scroll:s}),a.has(n)||(console.log(`[PJAX] transition name "${n}" doesn't exist, switching to the "default" transition`),n="default");try{this.transitionStart(),this.emitter.emit("PAGE_LOADING",{href:t,oldHref:e,trigger:i,scroll:s}),c=await l.load(e),p=await l.load(t),this.emitter.emit("PAGE_LOAD_COMPLETE",{newPage:p,oldPage:c,trigger:i,scroll:s}),c.dom instanceof Element||c.build(),p.build()}catch(f){console.warn("[PJAX] Page load error",f)}try{s=(await a.start(n,{oldPage:c,newPage:p,trigger:i,scroll:s,ignoreHashAction:o})).scroll}catch(f){console.warn("[PJAX] Transition error",f)}this.emitter.emit("NAVIGATION_END",{oldPage:c,newPage:p,trigger:i,transitionName:n,scroll:s})}catch(a){this.forceOnError?this.force(t):console.warn(a)}finally{this.transitionStop()}}onHover(e){let t=this.getLink(e);if(!t||!this.manager.has("PageManager"))return;let i=this.manager.get("PageManager"),n=T(this.getHref(t)),s=n.pathname;if(this.emitter.emit("ANCHOR_HOVER HOVER",e),!G(n.pathname,this.prefetchIgnore)&&!(i.has(s)&&!G(s,i.cacheIgnore)))try{i.load(n),this.emitter.emit("PREFETCH",e)}catch(a){console.warn("[PJAX] Prefetch error",a)}}onStateChange(e){this.go({href:window.location.href,trigger:"popstate",event:e})}initEvents(){this.prefetchIgnore!==!0&&(document.addEventListener("mouseover",this.onHover),document.addEventListener("touchstart",this.onHover)),document.addEventListener("click",this.onClick),window.addEventListener("popstate",this.onStateChange)}stopEvents(){this.prefetchIgnore!==!0&&(document.removeEventListener("mouseover",this.onHover),document.removeEventListener("touchstart",this.onHover)),document.removeEventListener("click",this.onClick),window.removeEventListener("popstate",this.onStateChange)}};var je=class extends R{constructor(e=[]){super();this.routes=new S;for(let t of e)this.add(t)}add({path:e,method:t}){let i=this.parse(e);return this.routes.set(i,t),this}parsePath(e){if(typeof e=="string"||e instanceof RegExp||Array.isArray(e))return j(e,[],{start:!1,end:!1});if(typeof e=="boolean")return e&&/.*/;throw"[Router] only regular expressions, strings, booleans and arrays of regular expressions and strings are accepted as paths."}isPath(e){return typeof e=="string"||e instanceof RegExp||typeof e=="boolean"||Array.isArray(e)}parse(e){let t=e,i={from:/.*/,to:/.*/};if(this.isPath(e))i={from:!0,to:e};else if(this.isPath(t.from)&&this.isPath(t.to))i=Object.assign({},i,t);else throw"[Router] path is neither a string, regular expression, or a { from, to } object.";let{from:n,to:s}=i;return{from:this.parsePath(n),to:this.parsePath(s)}}route(){if(this.manager.has("HistoryManager")){let e=this.manager.get("HistoryManager"),t=M(T((e.length>1?e.previous:e.current).url)),i=M(T());this.routes.forEach((n,s)=>{let a=s.from,l=s.to;if(typeof a=="boolean"&&typeof l=="boolean")throw`[Router] path ({ from: ${a}, to: ${l} }) is not valid, remember paths can only be strings, regular expressions, or a boolean; however, both the from and to paths cannot be both booleans.`;let o=a,p=l;a instanceof RegExp&&a.test(t)&&(o=a.exec(t)),l instanceof RegExp&&l.test(i)&&(p=l.exec(i)),(Array.isArray(p)&&Array.isArray(o)||Array.isArray(p)&&o==!1&&!l.test(t)||Array.isArray(o)&&p==!1&&!a.test(i))&&n({from:o,to:p,path:{from:t,to:i}})})}else console.warn("[Route] HistoryManager is missing.")}initEvents(){this.emitter.on("READY",this.route,this),this.emitter.on("CONTENT_REPLACED",this.route,this)}stopEvents(){this.emitter.off("READY",this.route,this),this.emitter.off("CONTENT_REPLACED",this.route,this)}};export{z as AdvancedManager,B as Animate,Ve as App,Oe as CONFIG_DEFAULTS,H as CSSArrValue,X as CSSValue,Pe as DefaultAnimationOptions,fe as EASINGS,Ye as EFFECTS,we as EasingKeys,U as Event,F as EventEmitter,ge as GetEase,Ce as HistoryManager,le as KeyframeParse,S as Manager,V as ManagerItem,Ke as PARSER,ze as PJAX,ae as Page,Ue as PageManager,me as ParseTransformableCSSKeyframes,ue as ParseTransformableCSSProperties,Te as Replace,je as Router,R as Service,se as ServiceManager,pe as TransformFunctionNames,Fe as TransitionManager,te as UnitDEG,P as UnitDEGCSSValue,$ as UnitLess,L as UnitLessCSSValue,ee as UnitPX,C as UnitPXCSSValue,Q as addCSSUnit,nt as animate,Ge as asyncMethodCall,Le as changeState,de as clean,Se as computeOption,ce as createTransformProperty,Z as equal,Ie as flatten,xe as getElements,mt as getHash,M as getHashedPath,re as getTargets,Ee as hashAction,G as ignoreURLs,O as isValid,he as mapAnimationOptions,Y as mapObject,_ as methodCall,ye as newConfig,N as newCoords,oe as newListener,J as newState,T as newURL,W as omit,q as parseOffset,Re as parseOptions,ie as toArr,k as toAttr,ve as transpose}; +var S=class{constructor(e){this.map=new Map(e)}getMap(){return this.map}get(e){return this.map.get(e)}keys(){return Array.from(this.map.keys())}values(){return Array.from(this.map.values())}set(e,t){return this.map.set(e,t),this}add(e){let i=this.size;return this.set(i,e),this}get size(){return this.map.size}get length(){return this.map.size}last(e=1){let t=this.keys()[this.size-e];return this.get(t)}delete(e){return this.map.delete(e)}remove(e){return this.map.delete(e),this}clear(){return this.map.clear(),this}has(e){return this.map.has(e)}entries(){return this.map.entries()}forEach(e,t){return this.map.forEach(e,t),this}[Symbol.iterator](){return this.entries()}},H=(r,e,...t)=>{r.forEach(i=>{i[e](...t)})},Ge=async(r,e,...t)=>{for(let[,i]of r)await i[e](...t)};var le=({callback:r=()=>{},scope:e=null,name:t="event"})=>({callback:r,scope:e,name:t}),F=class extends S{constructor(e="event"){super();this.name=e}},V=class extends S{constructor(){super()}getEvent(e){let t=this.get(e);return t instanceof F?t:(this.set(e,new F(e)),this.get(e))}newListener(e,t,i){let n=this.getEvent(e);return n.add(le({name:e,callback:t,scope:i})),n}on(e,t,i){if(typeof e=="undefined"||e==null)return this;typeof e=="string"&&(e=e.trim().split(/\s/g));let n,s,a=typeof e=="object"&&!Array.isArray(e),l=a?t:i;return a||(s=t),Object.keys(e).forEach(p=>{n=a?p:e[p],a&&(s=e[p]),this.newListener(n,s,l)},this),this}removeListener(e,t,i){let n=this.get(e);if(n instanceof F&&t){let s=le({name:e,callback:t,scope:i});n.forEach((a,l)=>{if(a.callback===s.callback&&a.scope===s.scope)return n.remove(l)})}return n}off(e,t,i){if(typeof e=="undefined"||e==null)return this;typeof e=="string"&&(e=e.trim().split(/\s/g));let n,s,a=typeof e=="object"&&!Array.isArray(e),l=a?t:i;return a||(s=t),Object.keys(e).forEach(p=>{n=a?p:e[p],a&&(s=e[p]),typeof s=="function"?this.removeListener(n,s,l):this.remove(n)},this),this}once(e,t,i){if(typeof e=="undefined"||e==null)return this;typeof e=="string"&&(e=e.trim().split(/\s/g));let n=typeof e=="object"&&!Array.isArray(e);return Object.keys(e).forEach(s=>{let a=n?s:e[s],l=n?e[s]:t,p=n?t:i,o=(...c)=>{l.apply(p,c),this.removeListener(a,o,p)};this.newListener(a,o,p)},this),this}emit(e,...t){return typeof e=="undefined"||e==null?this:(typeof e=="string"&&(e=e.trim().split(/\s/g)),e.forEach(i=>{let n=this.get(i);n instanceof F&&n.forEach(s=>{let{callback:a,scope:l}=s;a.apply(l,t)})},this),this)}clear(){return H(this,"clear"),super.clear(),this}};var $=r=>typeof r=="string"?r.includes("%")?parseFloat(r)/100:r=="from"?0:r=="to"?1:parseFloat(r):r,pe=r=>{let e=new Set,t=Object.keys(r),i=t.length;for(let n=0;nn.offset-s.offset)},Ye={};var ee=(r="")=>e=>typeof e=="string"?e:`${e}${r}`,X=ee(),te=ee("px"),ie=ee("deg"),re=r=>Array.isArray(r)||typeof r=="string"?(typeof r=="string"&&(r=r.split(",")),r):[r],R=r=>Array.isArray(r)||typeof r=="string"?Boolean(r.length):r!=null&&r!=null,Y=r=>e=>R(e)?re(e).map(t=>{if(typeof t!="number"&&typeof t!="string")return t;let i=Number(t),n=Number.isNaN(i)?typeof t=="string"?t.trim():t:i;return r(n)}):[],ve=(...r)=>{let e=0;r=r.map(n=>{let s=re(n),a=s.length;return a>e&&(e=a),s});let t=[],i=r.length;for(let n=0;nre(r).map(Y(e)),ce=["translate","translate3d","translateX","translateY","translateZ","rotate","rotate3d","rotateX","rotateY","rotateZ","scale","scale3d","scaleX","scaleY","scaleZ","skew","skewX","skewY","perspective"],ue=r=>{let e="",t=ce.length;for(let i=0;i{let{perspective:e,rotate:t,rotate3d:i,rotateX:n,rotateY:s,rotateZ:a,translate:l,translate3d:p,translateX:o,translateY:c,translateZ:h,scale:y,scale3d:m,scaleX:f,scaleY:d,scaleZ:u,skew:g,skewX:b,skewY:A,...v}=r;l=D(l,te),p=D(p,te),o=C(o),c=C(c),h=C(h),t=D(t,ie),i=D(i,X),n=w(n),s=w(s),a=w(a),y=D(y,X),m=D(m,X),f=M(f),d=M(d),u=M(u),g=D(g,ie),b=w(b),A=w(A),e=C(e);let x=ve(l,p,o,c,h,t,i,n,s,a,y,m,f,d,u,g,b,A,e).filter(R).map(ue);return v=W(v,T=>[].concat(T).map(I=>""+I)),Object.assign({},R(x)?{transform:x}:null,v)},he=r=>r.map(e=>{let{translate:t,translate3d:i,translateX:n,translateY:s,translateZ:a,rotate:l,rotate3d:p,rotateX:o,rotateY:c,rotateZ:h,scale:y,scale3d:m,scaleX:f,scaleY:d,scaleZ:u,skew:g,skewX:b,skewY:A,perspective:v,easing:x,iterations:T,offset:I,...P}=e;return t=C(t),i=C(i),n=C(n)[0],s=C(s)[0],a=C(a)[0],l=w(l),p=M(p),o=w(o)[0],c=w(c)[0],h=w(h)[0],y=M(y),m=M(m),f=M(f)[0],d=M(d)[0],u=M(u)[0],g=w(g),b=w(b)[0],A=w(A)[0],v=C(v)[0],[P,t,i,n,s,a,l,p,o,c,h,y,m,f,d,u,g,b,A,v]}).map(([e,...t])=>{let i=ue(t);return Object.assign({},R(i)?{transform:i}:null,e)});var xe=r=>typeof r=="string"?Array.from(document.querySelectorAll(r)):[r],Ie=r=>[].concat(...r),ne=r=>Array.isArray(r)?Ie(r.map(ne)):typeof r=="string"||r instanceof Node?xe(r):r instanceof NodeList||r instanceof HTMLCollection?Array.from(r):[],Se=(r,e,t)=>typeof r=="function"?r.apply(t,e):r,W=(r,e)=>{let t=Object.keys(r),i,n,s={};for(let a=0,l=t.length;aW(r,i=>Se(i,e,t)),ge={in:"ease-in",out:"ease-out","in-out":"ease-in-out","in-sine":"cubic-bezier(0.47, 0, 0.745, 0.715)","out-sine":"cubic-bezier(0.39, 0.575, 0.565, 1)","in-out-sine":"cubic-bezier(0.445, 0.05, 0.55, 0.95)","in-quad":"cubic-bezier(0.55, 0.085, 0.68, 0.53)","out-quad":"cubic-bezier(0.25, 0.46, 0.45, 0.94)","in-out-quad":"cubic-bezier(0.455, 0.03, 0.515, 0.955)","in-cubic":"cubic-bezier(0.55, 0.055, 0.675, 0.19)","out-cubic":"cubic-bezier(0.215, 0.61, 0.355, 1)","in-out-cubic":"cubic-bezier(0.645, 0.045, 0.355, 1)","in-quart":"cubic-bezier(0.895, 0.03, 0.685, 0.22)","out-quart":"cubic-bezier(0.165, 0.84, 0.44, 1)","in-out-quart":"cubic-bezier(0.77, 0, 0.175, 1)","in-quint":"cubic-bezier(0.755, 0.05, 0.855, 0.06)","out-quint":"cubic-bezier(0.23, 1, 0.32, 1)","in-out-quint":"cubic-bezier(0.86, 0, 0.07, 1)","in-expo":"cubic-bezier(0.95, 0.05, 0.795, 0.035)","out-expo":"cubic-bezier(0.19, 1, 0.22, 1)","in-out-expo":"cubic-bezier(1, 0, 0, 1)","in-circ":"cubic-bezier(0.6, 0.04, 0.98, 0.335)","out-circ":"cubic-bezier(0.075, 0.82, 0.165, 1)","in-out-circ":"cubic-bezier(0.785, 0.135, 0.15, 0.86)","in-back":"cubic-bezier(0.6, -0.28, 0.735, 0.045)","out-back":"cubic-bezier(0.175, 0.885, 0.32, 1.275)","in-out-back":"cubic-bezier(0.68, -0.55, 0.265, 1.55)"},we=Object.keys(ge),ye=r=>{let e=r.replace(/^ease-/,"");return we.includes(e)?ge[e]:r},Pe={keyframes:[],offset:[],loop:1,delay:0,speed:1,endDelay:0,easing:"ease",timelineOffset:0,autoplay:!0,duration:1e3,fillMode:"none",direction:"normal",padEndDelay:!1,timeline:document.timeline,extend:{}},Re=r=>{let{options:e,...t}=r,i=e instanceof Z?e.options:Array.isArray(e)?e?.[0]?.options:e;return Object.assign({},i,t)},B=(r,e)=>{let t={...e};for(;r.length;){let{[r.pop()]:i,...n}=t;t=n}return t},se=class{constructor(e){this.options={};this.properties={};this.totalDuration=0;this.emitter=new V;this.targets=new S;this.targetIndexes=new WeakMap;this.keyframeEffects=new WeakMap;this.computedOptions=new WeakMap;this.animations=new WeakMap;this.computedKeyframes=new WeakMap;this.loop=this.loop.bind(this),this.onVisibilityChange=this.onVisibilityChange.bind(this),this.on("error",console.error),this.updateOptions(e),this.mainAnimation&&(this.visibilityPlayState=this.getPlayState(),se.pauseOnPageHidden&&document.addEventListener("visibilitychange",this.onVisibilityChange,!1)),this.newPromise()}onVisibilityChange(){document.hidden?(this.visibilityPlayState=this.getPlayState(),this.is("running")&&(this.loop(),this.pause())):this.visibilityPlayState=="running"&&this.is("paused")&&this.play()}newPromise(){return this.promise=new Promise((e,t)=>{this?.emitter?.once?.("finish",()=>e([this])),this?.emitter?.once?.("error",i=>t(i))}),this.promise}then(e,t){return e=e?.bind(this),t=t?.bind(this),this?.promise?.then?.(e,t),this}catch(e){return e=e?.bind(this),this.promise?.catch?.(e),this}finally(e){return e=e?.bind(this),this.promise?.finally?.(e),this}loop(){this.stopLoop(),this.animationFrame=window.requestAnimationFrame(this.loop),this.emit("update",this.getProgress(),this)}stopLoop(){window.cancelAnimationFrame(this.animationFrame)}allAnimations(e){return this.targets.forEach(t=>{let i=this.keyframeEffects.get(t),n=this.animations.get(i);return e(n,t)}),this}all(e){return this.mainAnimation&&e(this.mainAnimation,this.mainElement),this.allAnimations(e),this}beginEvent(){this.getProgress()==0&&this.emit("begin",this)}play(){let e=this.getPlayState();return this.beginEvent(),this.all(t=>t.play()),this.emit("play",e,this),this.is(e)||this.emit("playstate-change",e,this),this.loop(),this}pause(){let e=this.getPlayState();return this.all(t=>t.pause()),this.emit("pause",e,this),this.is(e)||this.emit("playstate-change",e,this),this.stopLoop(),this}reverse(){return this.all(e=>e.reverse()),this}reset(){return this.setProgress(0),this.options.autoplay?this.play():this.pause(),this}cancel(){return this.all(e=>e.cancel()),this}finish(){return this.all(e=>e.finish()),this}stop(){this.cancel(),this.stopLoop(),document.removeEventListener("visibilitychange",this.onVisibilityChange,!1),this.targets.forEach(e=>this.removeTarget(e)),this.emit("stop"),this.emitter.clear(),this.mainkeyframeEffect=null,this.mainAnimation=null,this.mainElement=null,this.promise=null,this.computedOptions=null,this.animations=null,this.keyframeEffects=null,this.emitter=null,this.targets=null,this.options=null,this.properties=null}getAnimation(e){let t=this.keyframeEffects.get(e);return this.animations.get(t)}getTiming(e){let t=this.computedOptions.get(e)??{},i=this.keyframeEffects.get(e).getTiming?.()??{};return{...t,...i}}getCurrentTime(){return this.mainAnimation.currentTime}getProgress(){return this.getCurrentTime()/this.totalDuration*100}getSpeed(){return this.mainAnimation.playbackRate}getPlayState(){return this.mainAnimation.playState}is(e){return this.getPlayState()==e}setCurrentTime(e){return this.all(t=>t.currentTime=e),this.emit("update",this.getProgress()),this}setProgress(e){let t=e/100*this.totalDuration;return this.setCurrentTime(t),this}setSpeed(e=1){return this.maxSpeed=e,this.all(t=>{t.updatePlaybackRate?t.updatePlaybackRate(e):t.playbackRate=e}),this}createArrayOfComputedOptions(e,t){let i=[];return this.targets.forEach((n,s)=>{let a=this.computedOptions.get(n)??{},l=b=>{let A=b;return b=="loop"&&(A="iterations"),b=="fillMode"&&(A="fill"),e[b]??a[A]??this.options[b]},p=Object.assign({easing:l("easing"),iterations:l("loop"),direction:l("direction"),endDelay:l("endDelay"),duration:l("duration"),speed:l("speed"),delay:l("delay"),timelineOffset:l("timelineOffset"),keyframes:l("keyframes")},l("extend")??{}),o=fe(p,[s,t,n],this);typeof o.easing=="string"&&(o.easing=ye(o.easing)),o.iterations===!0&&(o.iterations=Infinity),o.fill=l("fillMode");let{timelineOffset:c,speed:h,endDelay:y,delay:m,duration:f,iterations:d,...u}=o;d=Number(d),f=Number(f),y=Number(y),h=Number(h),m=Number(m)+Number(c);let g=m+f*d+y;this.totalDuration{let{speed:h,keyframes:y,tempDurations:m,...f}=i[c];n&&f.endDelay==0&&Math.abs(f.iterations)!=Math.abs(Infinity)&&(f.endDelay=this.totalDuration-m);let d,u,g=y;typeof g=="object"&&(g=pe(g));let b=this.computedKeyframes.get(o)??{},A=Object.assign({},s,b),v=W(A,(I,P)=>this.properties[P]??I);if(u=R(g)?g:v,Array.isArray(u))d=u.map(I=>{let{easing:P,offset:L,...K}=B(["speed","loop"],I);return Object.assign({},K,typeof P=="string"?{easing:ye(P)}:null,typeof L=="string"||typeof L=="number"?{offset:$(L)}:null)}),d=he(d);else{let I=B(["keyframes"],u),{offset:P,...L}=fe(I,[c,t,o],this);L=me(L);let K=P;d=Object.assign({},L,R(K)?{offset:K.map($)}:null)}let x,T;this.keyframeEffects.has(o)?(T=this.keyframeEffects.get(o),x=this.animations.get(T),T?.setKeyframes?.(d),T?.updateTiming?.(f)):(T=new KeyframeEffect(o,d,f),x=new Animation(T,p),this.keyframeEffects.set(o,T),this.animations.set(T,x)),x.playbackRate=h,x.onfinish=()=>{typeof a=="function"&&a.call(this,o,c,t,x)},x.oncancel=()=>{typeof l=="function"&&l.call(this,o,c,t,x)},this.computedOptions.set(o,f),this.computedKeyframes.set(o,d)})}updateOptions(e={}){try{let t=Re(e);this.options=Object.assign({},Pe,this.options,t);let i=["easing","loop","endDelay","duration","speed","delay","timelineOffset","direction","extend","fillMode","offset"],{padEndDelay:n,autoplay:s,target:a,targets:l,timeline:p,onfinish:o,oncancel:c,...h}=B(i,this.options);this.properties=B([...i,"keyframes","padEndDelay","onfinish","oncancel","autoplay","target","targets","timeline"],t);let y=this.targets.values(),m=[...new Set([...y,...ne(l),...ne(a)])];this.targets.clear(),m.forEach((u,g)=>{this.targets.set(g,u),this.targetIndexes.set(u,g)});let f=this.targets.size,d=this.createArrayOfComputedOptions(t,f);if(this.createAnimations({arrOfComputedOptions:d,padEndDelay:n,oldCSSProperties:h,onfinish:o,oncancel:c,timeline:p},f),this.maxSpeed=this.maxSpeed??this.options.speed,this.minDelay=this.minDelay??this.options.delay,this.totalDuration=this.totalDuration??this.options.duration,this.mainAnimation?(this.mainkeyframeEffect?.updateTiming?.({duration:this.totalDuration}),(!this.mainkeyframeEffect.setKeyframes||!this.mainkeyframeEffect.updateTiming)&&console.warn("@okikio/animate - `KeyframeEffect.setKeyframes` and/or `KeyframeEffect.updateTiming` are not supported in this browser.")):(this.mainkeyframeEffect=new KeyframeEffect(this.mainElement,[{opacity:"0"},{opacity:"1"}],{duration:this.totalDuration,easing:"linear"}),this.mainAnimation=new Animation(this.mainkeyframeEffect,p)),this.mainAnimation.playbackRate=this.maxSpeed,this.mainAnimation.onfinish=()=>{if(this.emit("finish",this),this.mainAnimation){let u=this.getPlayState();this.is(u)||this.emit("playstate-change",u,this),this.stopLoop()}},this.mainAnimation.oncancel=()=>{if(this.emit("cancel",this),this.mainAnimation){let u=this.getPlayState();this.is(u)||this.emit("playstate-change",u,this),this.stopLoop()}},s){let u=window.setTimeout(()=>{this.emit("begin",this),u=window.clearTimeout(u)},0);this.play()}else this.pause()}catch(t){this.emit("error",t)}}add(e){let t=this.getProgress(),i=this.is("running"),n=this.is("paused");this.updateOptions({target:e}),this.setProgress(t),i?this.play():n&&this.pause()}removeTarget(e){let t=this.keyframeEffects.get(e);this.animations.delete(t),t=null,this.computedKeyframes.delete(e),this.computedOptions.delete(e),this.keyframeEffects.delete(e);let i=this.targetIndexes.get(e);this.targets.delete(i),this.targetIndexes.delete(e)}remove(e){this.removeTarget(e);let t=new Set([].concat(this.targets.values()));this.options.target=[...t],this.options.targets=[],t.clear(),t=null;let i=this.getProgress(),n=this.is("running"),s=this.is("paused");this.updateOptions(),n?this.play():s&&this.pause(),this.setProgress(i)}on(e,t,i){return this?.emitter?.on(e,t,i??this),this}off(e,t,i){return this?.emitter?.off(e,t,i??this),this}emit(e,...t){return this?.emitter?.emit(e,...t),this}toJSON(){return this.options}get[Symbol.toStringTag](){return"Animate"}},Z=se;Z.pauseOnPageHidden=!0;var nt=(r={})=>new Z(r);var Oe={wrapperAttr:"wrapper",headers:[],preventSelfAttr:'prevent="self"',preventAllAttr:'prevent="all"',transitionAttr:"transition",timeout:2e3,maxPages:5,resizeDelay:100,onTransitionPreventClick:!0,cacheIgnore:!1,prefetchIgnore:!1,preventURLs:[],stickyScroll:!1,forceOnError:!0,ignoreHashAction:!1,transitions:[]},de=r=>Object.assign({...Oe},r),N=(r,e,t=!0)=>{let{prefix:i}=r,n=r[e],s=`data${i?"-"+i:""}-${n}`;return t?`[${s}]`:s};var z=class{constructor(){}install(){}register(e,t){return this.manager=e,this.app=e.app,this.config=e.config,this.emitter=e.emitter,this.key=t,this.install(),this}uninstall(){}unregister(){this.uninstall(),this.manager.remove(this.key),this.key=null,this.manager=null,this.app=null,this.config=null,this.emitter=null}},j=class extends S{constructor(e){super();this.app=e,this.config=e.config,this.emitter=e.emitter}set(e,t){return super.set(e,t),t.register(this,e),this}};var E=(r=window.location.href)=>r instanceof URL?r:new URL(r,window.location.origin),k=r=>{let e=E(r);return`${e.pathname}${e.hash}`},mt=r=>E(r).hash.slice(1),be=r=>E(r).toString().replace(/(\/#.*|\/|#.*)$/,""),J=(r,e)=>be(r)===be(e);var O=class extends z{init(){}boot(){this.initEvents()}initEvents(){}stopEvents(){}stop(){this.stopEvents(),this.unregister()}},ae=class extends j{constructor(e){super(e)}init(){return H(this,"init"),this}boot(){return H(this,"boot"),this}stop(){return H(this,"stop"),this}};var _=(r=window.scrollX,e=window.scrollY)=>({x:r,y:e}),Q=(r={url:k(E()),index:0,transition:"default",data:{scroll:_(),trigger:"HistoryManager"}})=>r,Ce=class extends O{constructor(){super(...arguments);this.pointer=-1}init(){this.states=[];let e=Q();this.add(e,"replace")}get(e){return this.states[e]}add(e,t="push"){let i=Q(e),n=this.length;this.states.push({...i}),this.pointer=n;let s={index:this.pointer,states:[...this.states]};return Le(t,i,s),this}remove(e){return e?this.states.splice(e,1):this.states.pop(),this.pointer--,this}replace(e){return this.states=e,this}set(e,t){return this.states[e]=t}get current(){return this.get(this.pointer)}get last(){return this.get(this.length-1)}get previous(){return this.pointer<1?null:this.get(this.pointer-1)}get length(){return this.states.length}},Le=(r,e,t)=>{let i=k(e.url),n=[t,"",i];if(window.history)switch(r){case"push":window.history.pushState.apply(window.history,n);break;case"replace":window.history.replaceState.apply(window.history,n);break}};function Me(r){for(var e=[],t=0;t=48&&a<=57||a>=65&&a<=90||a>=97&&a<=122||a===95){n+=r[s++];continue}break}if(!n)throw new TypeError("Missing parameter name at "+t);e.push({type:"NAME",index:t,value:n}),t=s;continue}if(i==="("){var l=1,p="",s=t+1;if(r[s]==="?")throw new TypeError('Pattern cannot start with "?" at '+s);for(;s)?(?!\?)/g,i=0,n=t.exec(r.source);n;)e.push({name:n[1]||i++,prefix:"",suffix:"",modifier:"",pattern:""}),n=t.exec(r.source);return r}function _e(r,e,t){var i=r.map(function(n){return G(n,e,t).source});return new RegExp("(?:"+i.join("|")+")",Ee(t))}function He(r,e,t){return De(ke(r,t),e,t)}function De(r,e,t){t===void 0&&(t={});for(var i=t.strict,n=i===void 0?!1:i,s=t.start,a=s===void 0?!0:s,l=t.end,p=l===void 0?!0:l,o=t.encode,c=o===void 0?function(T){return T}:o,h="["+U(t.endsWith||"")+"]|$",y="["+U(t.delimiter||"/#?")+"]",m=a?"^":"",f=0,d=r;f-1:v===void 0;n||(m+="(?:"+y+"(?="+h+"))?"),x||(m+="(?="+y+"|"+h+")")}return new RegExp(m,Ee(t))}function G(r,e,t){return r instanceof RegExp?Ne(r,e):Array.isArray(r)?_e(r,e,t):He(r,e,t)}var Ke=new DOMParser,oe=class extends z{constructor(e=E(),t=document){super();this.url=E(e),typeof t=="string"?this.data=t:this.dom=t||document}async build(){if(this.dom instanceof Node||(this.dom=Ke.parseFromString(this.data,"text/html")),!(this.body instanceof Node)){let{title:e,head:t,body:i}=this.dom;this.title=e,this.head=t,this.body=i,this.wrapper=this.body.querySelector(this.wrapperAttr)}}install(){this.wrapperAttr=N(this.config,"wrapperAttr")}uninstall(){this.url=null,this.title=null,this.head=null,this.body=null,this.dom=null,this.wrapper=null,this.data=null,this.wrapperAttr=null}},Ue=class extends O{constructor(){super();this.loading=new S}install(){this.pages=new j(this.app),this.cacheIgnore=this.config.cacheIgnore;let e=E().pathname;this.set(e,new oe),e=null}get(e){return this.pages.get(e)}add(e){return this.pages.add(e),this}set(e,t){return this.pages.set(e,t),this}remove(e){return this.pages.remove(e),this}has(e){return this.pages.has(e)}clear(){return this.pages.clear(),this}get size(){return this.pages.size}keys(){return this.pages.keys()}async load(e=E()){let t=E(e),i=t.pathname,n,s;if(this.has(i)&&!q(i,this.cacheIgnore))return n=this.get(i),Promise.resolve(n);this.loading.has(i)?s=this.loading.get(i):(s=this.request(i),this.loading.set(i,s));let a=await s;if(this.loading.remove(i),n=new oe(t,a),this.set(i,n),this.size>this.config.maxPages){let l=E(),p=this.keys(),o=J(l,p[0])?p[1]:p[0],c=this.get(o);c.unregister(),c=null,p=null,l=null,o=null}return n}async request(e){let t=new Headers(this.config.headers),i=window.setTimeout(()=>{window.clearTimeout(i);let n=new Error("Request Timed Out!");throw this.emitter.emit("TIMEOUT_ERROR",n),n},this.config.timeout);try{let n=await fetch(e,{mode:"same-origin",method:"GET",headers:t,cache:"default",credentials:"same-origin"});if(window.clearTimeout(i),n.status>=200&&n.status<300)return await n.text();let s=new Error(n.statusText||""+n.status);throw this.emitter.emit("REQUEST_ERROR",s),s}catch(n){throw window.clearTimeout(i),n}}},q=(r,e)=>{if(typeof e=="boolean")return e;let t=[];return!e.every(i=>G(i,t,{start:!1,end:!1}).exec(r)==null)};var Te=(r,e=window.location.hash)=>{try{let t=e[0]=="#"?e:E(e).hash;if(t.length>1){let i=document.getElementById(t.slice(1));if(i){let{left:n,top:s}=i.getBoundingClientRect(),a=window.scrollX,l=window.scrollY,p=n+a,o=s+l;return _(p,o)}}}catch(t){console.warn("[hashAction] error",t)}return r??_(0,0)},Ae={name:"replace"},Fe=class extends O{constructor(e){super();this._arg=e}install(){super.install();let e=this._arg&&this._arg.length?this._arg:this.config.transitions;this.transitions=new S([["default",Ae],["replace",Ae]].concat(e))}get(e){return this.transitions.get(e)}set(e,t){return this.transitions.set(e,t),this}add(e){return this.transitions.add(e),this}has(e){return this.transitions.has(e)}async start(e,t){let i=this.transitions.get(e),{oldPage:n,newPage:s,ignoreHashAction:a,trigger:l}=t;if(this.emitter.emit("TRANSITION_START",{transitionName:e,...t}),!("wrapper"in n)||!("wrapper"in s))throw`[TransitionManager] either oldPage or newPage aren't instances of the Page Class. + ${{newPage:s,oldPage:n}}`;document.title=""+s.title;let p=n.wrapper,o=s.wrapper;if(!(p instanceof Node)||!(o instanceof Node))throw`[TransitionManager] the wrapper from the ${o instanceof Node?"current":"next"} page cannot be found. The wrapper must be an element that has the attribute ${N(this.config,"wrapperAttr")}.`;return i.init&&i?.init(t),this.emitter.emit("BEFORE_TRANSITION_OUT",t),i.out&&await new Promise(c=>{i.out.call(i,{...t,from:n,done:c})?.then(c)}),this.emitter.emit("AFTER_TRANSITION_OUT",t),await new Promise(c=>{p.insertAdjacentElement("beforebegin",o),this.emitter.emit("CONTENT_INSERT",t),c()}),await new Promise(c=>{p.remove(),p=null,o=null,this.emitter.emit("CONTENT_REPLACED",t),!a&&!/back|popstate|forward/.test(l)&&(t.scroll=Te(t.scroll)),c()}),this.emitter.emit("BEFORE_TRANSITION_IN",t),i.in&&await new Promise(c=>{i.in.call(i,{...t,from:n,to:s,done:c})?.then(c)}),this.emitter.emit("AFTER_TRANSITION_IN",t),i.manualScroll||(!a&&!/back|popstate|forward/.test(l)&&(t.scroll=Te(t.scroll)),window.scroll(t.scroll.x,t.scroll.y)),this.emitter.emit("TRANSITION_END",{transitionName:e,...t}),t}};var Ve=class{constructor(e={}){this.canResize=!0;this.canScroll=!0;this._resize=this._resize.bind(this),this._scroll=this._scroll.bind(this),this._ready=this._ready.bind(this),this.register(e)}register(e={}){return this.config=de(e),this.emitter=new V,this.services=new ae(this),this}_ready(){document.removeEventListener("DOMContentLoaded",this._ready),window.removeEventListener("load",this._ready),this.emitter.emit("READY ready")}_resize(){if(this.canResize){let e,t;this.canResize=!1,t=window.requestAnimationFrame(()=>{this.emitter.emit("RESIZE resize"),e=window.setTimeout(()=>{this.canResize=!0,e=window.clearTimeout(e),t=window.cancelAnimationFrame(t)},this.config.resizeDelay)})}}_scroll(){if(this.canScroll){let e;this.canScroll=!1,e=requestAnimationFrame(()=>{this.emitter.emit("SCROLL scroll"),this.canScroll=!0,e=window.cancelAnimationFrame(e)})}}get(e){return this.services.get(e)}set(e,t){return this.services.set(e,t),this}add(e){return this.services.add(e),this}boot(){return document.addEventListener("DOMContentLoaded",this._ready),window.addEventListener("load",this._ready),window.addEventListener("resize",this._resize,{passive:!0}),window.addEventListener("scroll",this._scroll,{passive:!0}),this.services.init(),this.services.boot(),this}stop(){return window.removeEventListener("resize",this._resize),window.removeEventListener("scroll",this._scroll),this.services.stop(),this.emitter.clear(),this}on(e,t){return this.emitter.on(e,t,this),this}off(e,t){return this.emitter.off(e,t,this),this}emit(e,...t){return this.emitter.emit(e,...t),this}};var ze=class extends O{install(){super.install(),this.preventURLs=this.config.preventURLs,this.prefetchIgnore=this.config.prefetchIgnore,this.onTransitionPreventClick=this.config.onTransitionPreventClick,this.stickyScroll=this.config.stickyScroll,this.forceOnError=this.config.forceOnError,this.ignoreHashAction=this.config.ignoreHashAction}transitionStart(){this.isTransitioning=!0}transitionStop(){this.isTransitioning=!1}init(){this.onHover=this.onHover.bind(this),this.onClick=this.onClick.bind(this),this.onStateChange=this.onStateChange.bind(this)}boot(){super.boot()}getTransitionName(e){if(!e||!e.getAttribute)return null;let t=e.getAttribute(N(this.config,"transitionAttr",!1));return typeof t=="string"?t:null}validLink(e,t,i){let n=!window.history.pushState,s=!e||!i,a=t.metaKey||t.ctrlKey||t.shiftKey||t.altKey,l=e.hasAttribute("target")&&e.target==="_blank",p=e.protocol!==location.protocol||e.hostname!==location.hostname,o=typeof e.getAttribute("download")=="string",c=e.matches(N(this.config,"preventSelfAttr")),h=Boolean(e.closest(N(this.config,"preventAllAttr"))),y=q(E(i).pathname,this.preventURLs),m=k(E())===k(E(i));return!(s||n||a||l||p||o||c||h||y||m)}getHref(e){return e&&e.tagName&&e.tagName.toLowerCase()==="a"&&typeof e.href=="string"?e.href:null}getLink(e){let t=e.target,i=this.getHref(t);for(;t&&!i;)t=t.parentNode,i=this.getHref(t);if(!(!t||!this.validLink(t,e,i)))return t}onClick(e){let t=this.getLink(e);if(!t)return;if(this.isTransitioning&&this.onTransitionPreventClick){e.preventDefault(),e.stopPropagation();return}let i=this.getHref(t);this.emitter.emit("ANCHOR_CLICK CLICK",e),this.go({href:i,trigger:t,event:e})}getDirection(e){return Math.abs(e)>1?e>0?"forward":"back":e===0?"popstate":e>0?"back":"forward"}force(e){window.location.assign(e)}go({href:e,trigger:t="HistoryManager",event:i}){if(this.isTransitioning&&!this.onTransitionPreventClick||!(this.manager.has("TransitionManager")&&this.manager.has("HistoryManager")&&this.manager.has("PageManager"))){this.force(e);return}let n=this.manager.get("HistoryManager"),s=_(0,0),a=n.current,l=a.url;if(J(l,e))return;let p;if(i&&i.state){this.emitter.emit("POPSTATE",i);let{state:o}=i,{index:c}=o,y=a.index-c;n.replace(o.states),n.pointer=c;let m=n.get(c);p=m.transition,s=m.data.scroll,t=this.getDirection(y),this.emitter.emit(t==="back"?"POPSTATE_BACK":"POPSTATE_FORWARD",i)}else{p=this.getTransitionName(t),s=_();let o=Q({url:e,transition:p,data:{scroll:s}});!this.stickyScroll&&(s=_(0,0)),n.add(o),this.emitter.emit("HISTORY_NEW_ITEM",i)}return i&&(i.stopPropagation(),i.preventDefault()),this.emitter.emit("GO",i),this.load({oldHref:l,href:e,trigger:t,transitionName:p,scroll:s})}async load({oldHref:e,href:t,trigger:i,transitionName:n="default",scroll:s={x:0,y:0}}){try{let a=this.manager.get("TransitionManager"),l=this.manager.get("PageManager"),p=this.ignoreHashAction,o,c;this.emitter.emit("NAVIGATION_START",{oldHref:e,href:t,trigger:i,transitionName:n,scroll:s}),a.has(n)||(console.log(`[PJAX] transition name "${n}" doesn't exist, switching to the "default" transition`),n="default");try{this.transitionStart(),this.emitter.emit("PAGE_LOADING",{href:t,oldHref:e,trigger:i,scroll:s}),c=await l.load(e),o=await l.load(t),this.emitter.emit("PAGE_LOAD_COMPLETE",{newPage:o,oldPage:c,trigger:i,scroll:s}),c.dom instanceof Element||c.build(),o.build()}catch(h){console.warn("[PJAX] Page load error",h)}try{s=(await a.start(n,{oldPage:c,newPage:o,trigger:i,scroll:s,ignoreHashAction:p})).scroll}catch(h){console.warn("[PJAX] Transition error",h)}this.emitter.emit("NAVIGATION_END",{oldPage:c,newPage:o,trigger:i,transitionName:n,scroll:s})}catch(a){this.forceOnError?this.force(t):console.warn(a)}finally{this.transitionStop()}}onHover(e){let t=this.getLink(e);if(!t||!this.manager.has("PageManager"))return;let i=this.manager.get("PageManager"),n=E(this.getHref(t)),s=n.pathname;if(this.emitter.emit("ANCHOR_HOVER HOVER",e),!q(n.pathname,this.prefetchIgnore)&&!(i.has(s)&&!q(s,i.cacheIgnore)))try{i.load(n),this.emitter.emit("PREFETCH",e)}catch(a){console.warn("[PJAX] Prefetch error",a)}}onStateChange(e){this.go({href:window.location.href,trigger:"popstate",event:e})}initEvents(){this.prefetchIgnore!==!0&&(document.addEventListener("mouseover",this.onHover),document.addEventListener("touchstart",this.onHover)),document.addEventListener("click",this.onClick),window.addEventListener("popstate",this.onStateChange)}stopEvents(){this.prefetchIgnore!==!0&&(document.removeEventListener("mouseover",this.onHover),document.removeEventListener("touchstart",this.onHover)),document.removeEventListener("click",this.onClick),window.removeEventListener("popstate",this.onStateChange)}};var je=class extends O{constructor(e=[]){super();this.routes=new S;for(let t of e)this.add(t)}add({path:e,method:t}){let i=this.parse(e);return this.routes.set(i,t),this}parsePath(e){if(typeof e=="string"||e instanceof RegExp||Array.isArray(e))return G(e,[],{start:!1,end:!1});if(typeof e=="boolean")return e&&/.*/;throw"[Router] only regular expressions, strings, booleans and arrays of regular expressions and strings are accepted as paths."}isPath(e){return typeof e=="string"||e instanceof RegExp||typeof e=="boolean"||Array.isArray(e)}parse(e){let t=e,i={from:/.*/,to:/.*/};if(this.isPath(e))i={from:!0,to:e};else if(this.isPath(t.from)&&this.isPath(t.to))i=Object.assign({},i,t);else throw"[Router] path is neither a string, regular expression, or a { from, to } object.";let{from:n,to:s}=i;return{from:this.parsePath(n),to:this.parsePath(s)}}route(){if(this.manager.has("HistoryManager")){let e=this.manager.get("HistoryManager"),t=k(E((e.length>1?e.previous:e.current).url)),i=k(E());this.routes.forEach((n,s)=>{let a=s.from,l=s.to;if(typeof a=="boolean"&&typeof l=="boolean")throw`[Router] path ({ from: ${a}, to: ${l} }) is not valid, remember paths can only be strings, regular expressions, or a boolean; however, both the from and to paths cannot be both booleans.`;let p=a,o=l;a instanceof RegExp&&a.test(t)&&(p=a.exec(t)),l instanceof RegExp&&l.test(i)&&(o=l.exec(i)),(Array.isArray(o)&&Array.isArray(p)||Array.isArray(o)&&p==!1&&!l.test(t)||Array.isArray(p)&&o==!1&&!a.test(i))&&n({from:p,to:o,path:{from:t,to:i}})})}else console.warn("[Route] HistoryManager is missing.")}initEvents(){this.emitter.on("READY",this.route,this),this.emitter.on("CONTENT_REPLACED",this.route,this)}stopEvents(){this.emitter.off("READY",this.route,this),this.emitter.off("CONTENT_REPLACED",this.route,this)}};export{j as AdvancedManager,Z as Animate,Ve as App,Oe as CONFIG_DEFAULTS,D as CSSArrValue,Y as CSSValue,Pe as DefaultAnimationOptions,ge as EASINGS,Ye as EFFECTS,we as EasingKeys,F as Event,V as EventEmitter,ye as GetEase,Ce as HistoryManager,pe as KeyframeParse,S as Manager,z as ManagerItem,Ke as PARSER,ze as PJAX,oe as Page,Ue as PageManager,he as ParseTransformableCSSKeyframes,me as ParseTransformableCSSProperties,Ae as Replace,je as Router,O as Service,ae as ServiceManager,ce as TransformFunctionNames,Fe as TransitionManager,ie as UnitDEG,w as UnitDEGCSSValue,X as UnitLess,M as UnitLessCSSValue,te as UnitPX,C as UnitPXCSSValue,ee as addCSSUnit,nt as animate,Ge as asyncMethodCall,Le as changeState,be as clean,Se as computeOption,ue as createTransformProperty,J as equal,Ie as flatten,xe as getElements,mt as getHash,k as getHashedPath,ne as getTargets,Te as hashAction,q as ignoreURLs,R as isValid,fe as mapAnimationOptions,W as mapObject,H as methodCall,de as newConfig,_ as newCoords,le as newListener,Q as newState,E as newURL,B as omit,$ as parseOffset,Re as parseOptions,re as toArr,N as toAttr,ve as transpose}; diff --git a/packages/native/lib/api.js b/packages/native/lib/api.js index 5200b82..41985e0 100644 --- a/packages/native/lib/api.js +++ b/packages/native/lib/api.js @@ -1,2 +1,2 @@ -var native=(()=>{var Ke=Object.defineProperty;var Ue=(r,e)=>{for(var t in e)Ke(r,t,{get:e[t],enumerable:!0})};var Be={};Ue(Be,{AdvancedManager:()=>V,Animate:()=>W,App:()=>Ne,CONFIG_DEFAULTS:()=>Pe,CSSArrValue:()=>H,CSSValue:()=>$,DefaultAnimationOptions:()=>Se,EASINGS:()=>he,EFFECTS:()=>Ve,EasingKeys:()=>Ie,Event:()=>K,EventEmitter:()=>U,GetEase:()=>fe,HistoryManager:()=>Re,KeyframeParse:()=>oe,Manager:()=>S,ManagerItem:()=>F,PARSER:()=>Le,PJAX:()=>_e,Page:()=>se,PageManager:()=>Me,ParseTransformableCSSKeyframes:()=>ue,ParseTransformableCSSProperties:()=>ce,Replace:()=>Ee,Router:()=>He,Service:()=>R,ServiceManager:()=>ne,TransformFunctionNames:()=>le,TransitionManager:()=>ke,UnitDEG:()=>te,UnitDEGCSSValue:()=>w,UnitLess:()=>q,UnitLessCSSValue:()=>L,UnitPX:()=>ee,UnitPXCSSValue:()=>C,addCSSUnit:()=>Q,animate:()=>ze,asyncMethodCall:()=>Fe,changeState:()=>Oe,clean:()=>de,computeOption:()=>xe,createTransformProperty:()=>pe,equal:()=>B,flatten:()=>ve,getElements:()=>Ae,getHash:()=>je,getHashedPath:()=>M,getTargets:()=>re,hashAction:()=>be,ignoreURLs:()=>j,isValid:()=>O,mapAnimationOptions:()=>me,mapObject:()=>X,methodCall:()=>_,newConfig:()=>ye,newCoords:()=>N,newListener:()=>ae,newState:()=>Z,newURL:()=>E,omit:()=>Y,parseOffset:()=>G,parseOptions:()=>we,toArr:()=>ie,toAttr:()=>k,transpose:()=>Te});var S=class{constructor(e){this.map=new Map(e)}getMap(){return this.map}get(e){return this.map.get(e)}keys(){return Array.from(this.map.keys())}values(){return Array.from(this.map.values())}set(e,t){return this.map.set(e,t),this}add(e){let i=this.size;return this.set(i,e),this}get size(){return this.map.size}get length(){return this.map.size}last(e=1){let t=this.keys()[this.size-e];return this.get(t)}delete(e){return this.map.delete(e)}remove(e){return this.map.delete(e),this}clear(){return this.map.clear(),this}has(e){return this.map.has(e)}entries(){return this.map.entries()}forEach(e,t){return this.map.forEach(e,t),this}[Symbol.iterator](){return this.entries()}},_=(r,e,...t)=>{r.forEach(i=>{i[e](...t)})},Fe=async(r,e,...t)=>{for(let[,i]of r)await i[e](...t)};var ae=({callback:r=()=>{},scope:e=null,name:t="event"})=>({callback:r,scope:e,name:t}),K=class extends S{constructor(e="event"){super();this.name=e}},U=class extends S{constructor(){super()}getEvent(e){let t=this.get(e);return t instanceof K?t:(this.set(e,new K(e)),this.get(e))}newListener(e,t,i){let n=this.getEvent(e);return n.add(ae({name:e,callback:t,scope:i})),n}on(e,t,i){if(typeof e=="undefined"||e==null)return this;typeof e=="string"&&(e=e.trim().split(/\s/g));let n,s,a=typeof e=="object"&&!Array.isArray(e),l=a?t:i;return a||(s=t),Object.keys(e).forEach(o=>{n=a?o:e[o],a&&(s=e[o]),this.newListener(n,s,l)},this),this}removeListener(e,t,i){let n=this.get(e);if(n instanceof K&&t){let s=ae({name:e,callback:t,scope:i});n.forEach((a,l)=>{if(a.callback===s.callback&&a.scope===s.scope)return n.remove(l)})}return n}off(e,t,i){if(typeof e=="undefined"||e==null)return this;typeof e=="string"&&(e=e.trim().split(/\s/g));let n,s,a=typeof e=="object"&&!Array.isArray(e),l=a?t:i;return a||(s=t),Object.keys(e).forEach(o=>{n=a?o:e[o],a&&(s=e[o]),typeof s=="function"?this.removeListener(n,s,l):this.remove(n)},this),this}once(e,t,i){if(typeof e=="undefined"||e==null)return this;typeof e=="string"&&(e=e.trim().split(/\s/g));let n=typeof e=="object"&&!Array.isArray(e);return Object.keys(e).forEach(s=>{let a=n?s:e[s],l=n?e[s]:t,o=n?t:i,p=(...c)=>{l.apply(o,c),this.removeListener(a,p,o)};this.newListener(a,p,o)},this),this}emit(e,...t){return typeof e=="undefined"||e==null?this:(typeof e=="string"&&(e=e.trim().split(/\s/g)),e.forEach(i=>{let n=this.get(i);n instanceof K&&n.forEach(s=>{let{callback:a,scope:l}=s;a.apply(l,t)})},this),this)}clear(){return _(this,"clear"),super.clear(),this}};var G=r=>typeof r=="string"?r.includes("%")?parseFloat(r)/100:r=="from"?0:r=="to"?1:parseFloat(r):r,oe=r=>{let e=new Set,t=Object.keys(r),i=t.length;for(let n=0;nn.offset-s.offset)},Ve={};var Q=(r="")=>e=>typeof e=="string"?e:`${e}${r}`,q=Q(),ee=Q("px"),te=Q("deg"),ie=r=>Array.isArray(r)||typeof r=="string"?(typeof r=="string"&&(r=r.split(",")),r):[r],O=r=>Array.isArray(r)||typeof r=="string"?Boolean(r.length):r!=null&&r!=null,$=r=>e=>O(e)?ie(e).map(t=>{if(typeof t!="number"&&typeof t!="string")return t;let i=Number(t),n=Number.isNaN(i)?typeof t=="string"?t.trim():t:i;return r(n)}):[],Te=(...r)=>{let e=0;r=r.map(n=>{let s=ie(n),a=s.length;return a>e&&(e=a),s});let t=[],i=r.length;for(let n=0;nie(r).map($(e)),le=["translate","translate3d","translateX","translateY","translateZ","rotate","rotate3d","rotateX","rotateY","rotateZ","scale","scale3d","scaleX","scaleY","scaleZ","skew","skewX","skewY","perspective"],pe=r=>{let e="",t=le.length;for(let i=0;i{let{perspective:e,rotate:t,rotate3d:i,rotateX:n,rotateY:s,rotateZ:a,translate:l,translate3d:o,translateX:p,translateY:c,translateZ:f,scale:y,scale3d:u,scaleX:g,scaleY:h,scaleZ:m,skew:T,skewX:b,skewY:A,...d}=r;l=H(l,ee),o=H(o,ee),p=C(p),c=C(c),f=C(f),t=H(t,te),i=H(i,q),n=w(n),s=w(s),a=w(a),y=H(y,q),u=H(u,q),g=L(g),h=L(h),m=L(m),T=H(T,te),b=w(b),A=w(A),e=C(e);let x=Te(l,o,p,c,f,t,i,n,s,a,y,u,g,h,m,T,b,A,e).map(pe);return d=X(d,v=>[].concat(v).map(I=>""+I)),Object.assign({},O(x)?{transform:x}:null,d)},ue=r=>r.map(e=>{let{translate:t,translate3d:i,translateX:n,translateY:s,translateZ:a,rotate:l,rotate3d:o,rotateX:p,rotateY:c,rotateZ:f,scale:y,scale3d:u,scaleX:g,scaleY:h,scaleZ:m,skew:T,skewX:b,skewY:A,perspective:d,easing:x,iterations:v,offset:I,...P}=e;return t=C(t),i=C(i),n=C(n)[0],s=C(s)[0],a=C(a)[0],l=w(l),o=L(o),p=w(p)[0],c=w(c)[0],f=w(f)[0],y=L(y),u=L(u),g=L(g)[0],h=L(h)[0],m=L(m)[0],T=w(T),b=w(b)[0],A=w(A)[0],d=C(d)[0],[P,t,i,n,s,a,l,o,p,c,f,y,u,g,h,m,T,b,A,d]}).map(([e,...t])=>{let i=pe(t);return Object.assign({},O(i)?{transform:i}:null,e)});var Ae=r=>typeof r=="string"?Array.from(document.querySelectorAll(r)):[r],ve=r=>[].concat(...r),re=r=>Array.isArray(r)?ve(r.map(re)):typeof r=="string"||r instanceof Node?Ae(r):r instanceof NodeList||r instanceof HTMLCollection?Array.from(r):[],xe=(r,e,t)=>typeof r=="function"?r.apply(t,e):r,X=(r,e)=>{let t=Object.keys(r),i,n,s={};for(let a=0,l=t.length;aX(r,i=>xe(i,e,t)),he={in:"ease-in",out:"ease-out","in-out":"ease-in-out","in-sine":"cubic-bezier(0.47, 0, 0.745, 0.715)","out-sine":"cubic-bezier(0.39, 0.575, 0.565, 1)","in-out-sine":"cubic-bezier(0.445, 0.05, 0.55, 0.95)","in-quad":"cubic-bezier(0.55, 0.085, 0.68, 0.53)","out-quad":"cubic-bezier(0.25, 0.46, 0.45, 0.94)","in-out-quad":"cubic-bezier(0.455, 0.03, 0.515, 0.955)","in-cubic":"cubic-bezier(0.55, 0.055, 0.675, 0.19)","out-cubic":"cubic-bezier(0.215, 0.61, 0.355, 1)","in-out-cubic":"cubic-bezier(0.645, 0.045, 0.355, 1)","in-quart":"cubic-bezier(0.895, 0.03, 0.685, 0.22)","out-quart":"cubic-bezier(0.165, 0.84, 0.44, 1)","in-out-quart":"cubic-bezier(0.77, 0, 0.175, 1)","in-quint":"cubic-bezier(0.755, 0.05, 0.855, 0.06)","out-quint":"cubic-bezier(0.23, 1, 0.32, 1)","in-out-quint":"cubic-bezier(0.86, 0, 0.07, 1)","in-expo":"cubic-bezier(0.95, 0.05, 0.795, 0.035)","out-expo":"cubic-bezier(0.19, 1, 0.22, 1)","in-out-expo":"cubic-bezier(1, 0, 0, 1)","in-circ":"cubic-bezier(0.6, 0.04, 0.98, 0.335)","out-circ":"cubic-bezier(0.075, 0.82, 0.165, 1)","in-out-circ":"cubic-bezier(0.785, 0.135, 0.15, 0.86)","in-back":"cubic-bezier(0.6, -0.28, 0.735, 0.045)","out-back":"cubic-bezier(0.175, 0.885, 0.32, 1.275)","in-out-back":"cubic-bezier(0.68, -0.55, 0.265, 1.55)"},Ie=Object.keys(he),fe=r=>{let e=r.replace(/^ease-/,"");return Ie.includes(e)?he[e]:r},Se={keyframes:[],offset:[],loop:1,delay:0,speed:1,endDelay:0,easing:"ease",timelineOffset:0,autoplay:!0,duration:1e3,fillMode:"none",direction:"normal",padEndDelay:!1,extend:{}},we=r=>{let{options:e,...t}=r,i=e instanceof W?e.options:Array.isArray(e)?e?.[0]?.options:e;return Object.assign({},i,t)},Y=(r,e)=>{let t={...e};for(;r.length;){let{[r.pop()]:i,...n}=t;t=n}return t},ge=class{constructor(e){this.options={};this.properties={};this.totalDuration=0;this.emitter=new U;this.targets=new S;this.targetIndexes=new WeakMap;this.keyframeEffects=new WeakMap;this.computedOptions=new WeakMap;this.animations=new WeakMap;this.computedKeyframes=new WeakMap;this.loop=this.loop.bind(this),this.onVisibilityChange=this.onVisibilityChange.bind(this),this.on("error",t=>console.error(t)),this.updateOptions(e),this.visibilityPlayState=this.getPlayState(),ge.pauseOnPageHidden&&document.addEventListener("visibilitychange",this.onVisibilityChange,!1),this.newPromise()}onVisibilityChange(){document.hidden?(this.visibilityPlayState=this.getPlayState(),this.is("running")&&(this.loop(),this.pause())):this.visibilityPlayState=="running"&&this.is("paused")&&this.play()}newPromise(){return this.promise=new Promise((e,t)=>{this?.emitter?.once?.("finish",()=>e([this])),this?.emitter?.once?.("error",i=>t(i))}),this.promise}then(e,t){return e=e?.bind(this),t=t?.bind(this),this?.promise?.then?.(e,t),this}catch(e){return e=e?.bind(this),this.promise?.catch?.(e),this}finally(e){return e=e?.bind(this),this.promise?.finally?.(e),this}loop(){this.stopLoop(),this.animationFrame=window.requestAnimationFrame(this.loop),this.emit("update",this.getProgress(),this)}stopLoop(){window.cancelAnimationFrame(this.animationFrame)}allAnimations(e){return this.targets.forEach(t=>{let i=this.keyframeEffects.get(t),n=this.animations.get(i);return e(n,t)}),this}all(e){return this.mainAnimation&&e(this.mainAnimation,this.mainElement),this.allAnimations(e),this}beginEvent(){this.getProgress()==0&&this.emit("begin",this)}play(){let e=this.getPlayState();return this.beginEvent(),this.all(t=>t.play()),this.emit("play",e,this),this.is(e)||this.emit("playstate-change",e,this),this.loop(),this}pause(){let e=this.getPlayState();return this.all(t=>t.pause()),this.emit("pause",e,this),this.is(e)||this.emit("playstate-change",e,this),this.stopLoop(),this}reverse(){return this.all(e=>e.reverse()),this}reset(){return this.setProgress(0),this.options.autoplay?this.play():this.pause(),this}cancel(){return this.all(e=>e.cancel()),this}finish(){return this.all(e=>e.finish()),this}stop(){this.cancel(),this.stopLoop(),document.removeEventListener("visibilitychange",this.onVisibilityChange,!1),this.targets.forEach(e=>this.removeTarget(e)),this.emit("stop"),this.emitter.clear(),this.mainkeyframeEffect=null,this.mainAnimation=null,this.mainElement=null,this.promise=null,this.computedOptions=null,this.animations=null,this.keyframeEffects=null,this.emitter=null,this.targets=null,this.options=null,this.properties=null}getAnimation(e){let t=this.keyframeEffects.get(e);return this.animations.get(t)}getTiming(e){let t=this.computedOptions.get(e)??{},i=this.keyframeEffects.get(e).getTiming?.()??{};return{...t,...i}}getCurrentTime(){return this.mainAnimation.currentTime}getProgress(){return this.getCurrentTime()/this.totalDuration*100}getSpeed(){return this.mainAnimation.playbackRate}getPlayState(){return this.mainAnimation.playState}is(e){return this.getPlayState()==e}setCurrentTime(e){return this.all(t=>t.currentTime=e),this.emit("update",this.getProgress()),this}setProgress(e){let t=e/100*this.totalDuration;return this.setCurrentTime(t),this}setSpeed(e=1){return this.maxSpeed=e,this.all(t=>{t.updatePlaybackRate?t.updatePlaybackRate(e):t.playbackRate=e}),this}createArrayOfComputedOptions(e,t){let i=[];return this.targets.forEach((n,s)=>{let a=this.computedOptions.get(n)??{},l=b=>{let A=b;return b=="loop"&&(A="iterations"),b=="fillMode"&&(A="fill"),e[b]??a[A]??this.options[b]},o=Object.assign({easing:l("easing"),iterations:l("loop"),direction:l("direction"),endDelay:l("endDelay"),duration:l("duration"),speed:l("speed"),delay:l("delay"),timelineOffset:l("timelineOffset"),keyframes:l("keyframes")},l("extend")??{}),p=me(o,[s,t,n],this);typeof p.easing=="string"&&(p.easing=fe(p.easing)),p.iterations===!0&&(p.iterations=Infinity),p.fill=l("fillMode");let{timelineOffset:c,speed:f,endDelay:y,delay:u,duration:g,iterations:h,...m}=p;h=Number(h),g=Number(g),y=Number(y),f=Number(f),u=Number(u)+Number(c);let T=u+g*h+y;this.totalDuration{let{speed:c,keyframes:f,tempDurations:y,...u}=i[p];n&&u.endDelay==0&&Math.abs(u.iterations)!=Math.abs(Infinity)&&(u.endDelay=this.totalDuration-y);let g,h,m=f;typeof m=="object"&&(m=oe(m));let T=this.computedKeyframes.get(o)??{},b=Object.assign({},s,T),A=X(b,(v,I)=>this.properties[I]??v);if(h=O(m)?m:A,Array.isArray(h))g=h.map(v=>{let{easing:I,offset:P,...D}=Y(["speed","loop"],v);return Object.assign({},D,typeof I=="string"?{easing:fe(I)}:null,typeof P=="string"||typeof P=="number"?{offset:G(P)}:null)}),g=ue(g);else{let v=Y(["keyframes"],h),{offset:I,...P}=me(v,[p,t,o],this);P=ce(P);let D=I;g=Object.assign({},P,O(D)?{offset:D.map(G)}:null)}let d,x;this.keyframeEffects.has(o)?(x=this.keyframeEffects.get(o),d=this.animations.get(x),x?.setKeyframes?.(g),x?.updateTiming?.(u)):(x=new KeyframeEffect(o,g,u),d=new Animation(x,u.timeline),this.keyframeEffects.set(o,x),this.animations.set(x,d)),d.playbackRate=c,d.onfinish=()=>{typeof a=="function"&&a.call(this,o,p,t,d)},d.oncancel=()=>{typeof l=="function"&&l.call(this,o,p,t,d)},this.computedOptions.set(o,u),this.computedKeyframes.set(o,g)})}updateOptions(e={}){try{let t=we(e);this.options=Object.assign({},Se,this.options,t);let i=["easing","loop","endDelay","duration","speed","delay","timelineOffset","direction","extend","fillMode","offset"],{padEndDelay:n,onfinish:s,oncancel:a,autoplay:l,target:o,targets:p,...c}=Y(i,this.options);this.properties=Y([...i,"keyframes","padEndDelay","onfinish","oncancel","autoplay","target","targets"],t);let f=this.targets.values(),y=[...new Set([...f,...re(p),...re(o)])];this.targets.clear(),y.forEach((h,m)=>{this.targets.set(m,h),this.targetIndexes.set(h,m)});let u=this.targets.size,g=this.createArrayOfComputedOptions(t,u);if(this.createAnimations({arrOfComputedOptions:g,padEndDelay:n,oldCSSProperties:c,onfinish:s,oncancel:a},u),this.maxSpeed=this.maxSpeed??this.options.speed,this.minDelay=this.minDelay??this.options.delay,this.totalDuration=this.totalDuration??this.options.duration,this.mainAnimation?(this.mainkeyframeEffect?.updateTiming?.({duration:this.totalDuration}),(!this.mainkeyframeEffect.setKeyframes||!this.mainkeyframeEffect.updateTiming)&&console.warn("@okikio/animate - `KeyframeEffect.setKeyframes` and/or `KeyframeEffect.updateTiming` are not supported in this browser.")):(this.mainkeyframeEffect=new KeyframeEffect(this.mainElement,[{opacity:"0"},{opacity:"1"}],{duration:this.totalDuration,easing:"linear"}),this.mainAnimation=new Animation(this.mainkeyframeEffect,this.options.timeline)),this.mainAnimation.playbackRate=this.maxSpeed,this.mainAnimation.onfinish=()=>{if(this.emit("finish",this),this.mainAnimation){let h=this.getPlayState();this.is(h)||this.emit("playstate-change",h,this),this.stopLoop()}},this.mainAnimation.oncancel=()=>{if(this.emit("cancel",this),this.mainAnimation){let h=this.getPlayState();this.is(h)||this.emit("playstate-change",h,this),this.stopLoop()}},l){let h=window.setTimeout(()=>{this.emit("begin",this),h=window.clearTimeout(h)},0);this.play()}else this.pause()}catch(t){this.emit("error",t)}}add(e){let t=this.getProgress(),i=this.is("running"),n=this.is("paused");this.updateOptions({target:e}),this.setProgress(t),i?this.play():n&&this.pause()}removeTarget(e){let t=this.keyframeEffects.get(e);this.animations.delete(t),t=null,this.computedKeyframes.delete(e),this.computedOptions.delete(e),this.keyframeEffects.delete(e);let i=this.targetIndexes.get(e);this.targets.delete(i),this.targetIndexes.delete(e)}remove(e){this.removeTarget(e);let t=new Set([].concat(this.targets.values()));this.options.target=[...t],this.options.targets=[],t.clear(),t=null;let i=this.getProgress(),n=this.is("running"),s=this.is("paused");this.updateOptions(),n?this.play():s&&this.pause(),this.setProgress(i)}on(e,t,i){return this?.emitter?.on(e,t,i??this),this}off(e,t,i){return this?.emitter?.off(e,t,i??this),this}emit(e,...t){return this?.emitter?.emit(e,...t),this}toJSON(){return this.options}get[Symbol.toStringTag](){return"Animate"}},W=ge;W.pauseOnPageHidden=!0;var ze=(r={})=>new W(r);var Pe={wrapperAttr:"wrapper",headers:[],preventSelfAttr:'prevent="self"',preventAllAttr:'prevent="all"',transitionAttr:"transition",timeout:2e3,maxPages:5,resizeDelay:100,onTransitionPreventClick:!0,cacheIgnore:!1,prefetchIgnore:!1,preventURLs:[],stickyScroll:!1,forceOnError:!0,ignoreHashAction:!1,transitions:[]},ye=r=>Object.assign({...Pe},r),k=(r,e,t=!0)=>{let{prefix:i}=r,n=r[e],s=`data${i?"-"+i:""}-${n}`;return t?`[${s}]`:s};var F=class{constructor(){}install(){}register(e,t){return this.manager=e,this.app=e.app,this.config=e.config,this.emitter=e.emitter,this.key=t,this.install(),this}uninstall(){}unregister(){this.uninstall(),this.manager.remove(this.key),this.key=null,this.manager=null,this.app=null,this.config=null,this.emitter=null}},V=class extends S{constructor(e){super();this.app=e,this.config=e.config,this.emitter=e.emitter}set(e,t){return super.set(e,t),t.register(this,e),this}};var E=(r=window.location.href)=>r instanceof URL?r:new URL(r,window.location.origin),M=r=>{let e=E(r);return`${e.pathname}${e.hash}`},je=r=>E(r).hash.slice(1),de=r=>E(r).toString().replace(/(\/#.*|\/|#.*)$/,""),B=(r,e)=>de(r)===de(e);var R=class extends F{init(){}boot(){this.initEvents()}initEvents(){}stopEvents(){}stop(){this.stopEvents(),this.unregister()}},ne=class extends V{constructor(e){super(e)}init(){return _(this,"init"),this}boot(){return _(this,"boot"),this}stop(){return _(this,"stop"),this}};var N=(r=window.scrollX,e=window.scrollY)=>({x:r,y:e}),Z=(r={url:M(E()),index:0,transition:"default",data:{scroll:N(),trigger:"HistoryManager"}})=>r,Re=class extends R{constructor(){super(...arguments);this.pointer=-1}init(){this.states=[];let e=Z();this.add(e,"replace")}get(e){return this.states[e]}add(e,t="push"){let i=Z(e),n=this.length;this.states.push({...i}),this.pointer=n;let s={index:this.pointer,states:[...this.states]};return Oe(t,i,s),this}remove(e){return e?this.states.splice(e,1):this.states.pop(),this.pointer--,this}replace(e){return this.states=e,this}set(e,t){return this.states[e]=t}get current(){return this.get(this.pointer)}get last(){return this.get(this.length-1)}get previous(){return this.pointer<1?null:this.get(this.pointer-1)}get length(){return this.states.length}},Oe=(r,e,t)=>{let i=M(e.url),n=[t,"",i];if(window.history)switch(r){case"push":window.history.pushState.apply(window.history,n);break;case"replace":window.history.replaceState.apply(window.history,n);break}};function Ge(r){for(var e=[],t=0;t=48&&a<=57||a>=65&&a<=90||a>=97&&a<=122||a===95){n+=r[s++];continue}break}if(!n)throw new TypeError("Missing parameter name at "+t);e.push({type:"NAME",index:t,value:n}),t=s;continue}if(i==="("){var l=1,o="",s=t+1;if(r[s]==="?")throw new TypeError('Pattern cannot start with "?" at '+s);for(;s)?(?!\?)/g,i=0,n=t.exec(r.source);n;)e.push({name:n[1]||i++,prefix:"",suffix:"",modifier:"",pattern:""}),n=t.exec(r.source);return r}function Xe(r,e,t){var i=r.map(function(n){return J(n,e,t).source});return new RegExp("(?:"+i.join("|")+")",Ce(t))}function Ye(r,e,t){return We(qe(r,t),e,t)}function We(r,e,t){t===void 0&&(t={});for(var i=t.strict,n=i===void 0?!1:i,s=t.start,a=s===void 0?!0:s,l=t.end,o=l===void 0?!0:l,p=t.encode,c=p===void 0?function(v){return v}:p,f="["+z(t.endsWith||"")+"]|$",y="["+z(t.delimiter||"/#?")+"]",u=a?"^":"",g=0,h=r;g-1:d===void 0;n||(u+="(?:"+y+"(?="+f+"))?"),x||(u+="(?="+y+"|"+f+")")}return new RegExp(u,Ce(t))}function J(r,e,t){return r instanceof RegExp?$e(r,e):Array.isArray(r)?Xe(r,e,t):Ye(r,e,t)}var Le=new DOMParser,se=class extends F{constructor(e=E(),t=document){super();this.url=E(e),typeof t=="string"?this.data=t:this.dom=t||document}async build(){if(this.dom instanceof Node||(this.dom=Le.parseFromString(this.data,"text/html")),!(this.body instanceof Node)){let{title:e,head:t,body:i}=this.dom;this.title=e,this.head=t,this.body=i,this.wrapper=this.body.querySelector(this.wrapperAttr)}}install(){this.wrapperAttr=k(this.config,"wrapperAttr")}uninstall(){this.url=null,this.title=null,this.head=null,this.body=null,this.dom=null,this.wrapper=null,this.data=null,this.wrapperAttr=null}},Me=class extends R{constructor(){super();this.loading=new S}install(){this.pages=new V(this.app),this.cacheIgnore=this.config.cacheIgnore;let e=E().pathname;this.set(e,new se),e=null}get(e){return this.pages.get(e)}add(e){return this.pages.add(e),this}set(e,t){return this.pages.set(e,t),this}remove(e){return this.pages.remove(e),this}has(e){return this.pages.has(e)}clear(){return this.pages.clear(),this}get size(){return this.pages.size}keys(){return this.pages.keys()}async load(e=E()){let t=E(e),i=t.pathname,n,s;if(this.has(i)&&!j(i,this.cacheIgnore))return n=this.get(i),Promise.resolve(n);this.loading.has(i)?s=this.loading.get(i):(s=this.request(i),this.loading.set(i,s));let a=await s;if(this.loading.remove(i),n=new se(t,a),this.set(i,n),this.size>this.config.maxPages){let l=E(),o=this.keys(),p=B(l,o[0])?o[1]:o[0],c=this.get(p);c.unregister(),c=null,o=null,l=null,p=null}return n}async request(e){let t=new Headers(this.config.headers),i=window.setTimeout(()=>{window.clearTimeout(i);let n=new Error("Request Timed Out!");throw this.emitter.emit("TIMEOUT_ERROR",n),n},this.config.timeout);try{let n=await fetch(e,{mode:"same-origin",method:"GET",headers:t,cache:"default",credentials:"same-origin"});if(window.clearTimeout(i),n.status>=200&&n.status<300)return await n.text();let s=new Error(n.statusText||""+n.status);throw this.emitter.emit("REQUEST_ERROR",s),s}catch(n){throw window.clearTimeout(i),n}}},j=(r,e)=>{if(typeof e=="boolean")return e;let t=[];return!e.every(i=>J(i,t,{start:!1,end:!1}).exec(r)==null)};var be=(r,e=window.location.hash)=>{try{let t=e[0]=="#"?e:E(e).hash;if(t.length>1){let i=document.getElementById(t.slice(1));if(i){let{left:n,top:s}=i.getBoundingClientRect(),a=window.scrollX,l=window.scrollY,o=n+a,p=s+l;return N(o,p)}}}catch(t){console.warn("[hashAction] error",t)}return r??N(0,0)},Ee={name:"replace"},ke=class extends R{constructor(e){super();this._arg=e}install(){super.install();let e=this._arg&&this._arg.length?this._arg:this.config.transitions;this.transitions=new S([["default",Ee],["replace",Ee]].concat(e))}get(e){return this.transitions.get(e)}set(e,t){return this.transitions.set(e,t),this}add(e){return this.transitions.add(e),this}has(e){return this.transitions.has(e)}async start(e,t){let i=this.transitions.get(e),{oldPage:n,newPage:s,ignoreHashAction:a,trigger:l}=t;if(this.emitter.emit("TRANSITION_START",{transitionName:e,...t}),!("wrapper"in n)||!("wrapper"in s))throw`[TransitionManager] either oldPage or newPage aren't instances of the Page Class. - ${{newPage:s,oldPage:n}}`;document.title=""+s.title;let o=n.wrapper,p=s.wrapper;if(!(o instanceof Node)||!(p instanceof Node))throw`[TransitionManager] the wrapper from the ${p instanceof Node?"current":"next"} page cannot be found. The wrapper must be an element that has the attribute ${k(this.config,"wrapperAttr")}.`;return i.init&&i?.init(t),this.emitter.emit("BEFORE_TRANSITION_OUT",t),i.out&&await new Promise(c=>{i.out.call(i,{...t,from:n,done:c})?.then(c)}),this.emitter.emit("AFTER_TRANSITION_OUT",t),await new Promise(c=>{o.insertAdjacentElement("beforebegin",p),this.emitter.emit("CONTENT_INSERT",t),c()}),await new Promise(c=>{o.remove(),o=null,p=null,this.emitter.emit("CONTENT_REPLACED",t),!a&&!/back|popstate|forward/.test(l)&&(t.scroll=be(t.scroll)),c()}),this.emitter.emit("BEFORE_TRANSITION_IN",t),i.in&&await new Promise(c=>{i.in.call(i,{...t,from:n,to:s,done:c})?.then(c)}),this.emitter.emit("AFTER_TRANSITION_IN",t),i.manualScroll||(!a&&!/back|popstate|forward/.test(l)&&(t.scroll=be(t.scroll)),window.scroll(t.scroll.x,t.scroll.y)),this.emitter.emit("TRANSITION_END",{transitionName:e,...t}),t}};var Ne=class{constructor(e={}){this.canResize=!0;this.canScroll=!0;this._resize=this._resize.bind(this),this._scroll=this._scroll.bind(this),this._ready=this._ready.bind(this),this.register(e)}register(e={}){return this.config=ye(e),this.emitter=new U,this.services=new ne(this),this}_ready(){document.removeEventListener("DOMContentLoaded",this._ready),window.removeEventListener("load",this._ready),this.emitter.emit("READY ready")}_resize(){if(this.canResize){let e,t;this.canResize=!1,t=window.requestAnimationFrame(()=>{this.emitter.emit("RESIZE resize"),e=window.setTimeout(()=>{this.canResize=!0,e=window.clearTimeout(e),t=window.cancelAnimationFrame(t)},this.config.resizeDelay)})}}_scroll(){if(this.canScroll){let e;this.canScroll=!1,e=requestAnimationFrame(()=>{this.emitter.emit("SCROLL scroll"),this.canScroll=!0,e=window.cancelAnimationFrame(e)})}}get(e){return this.services.get(e)}set(e,t){return this.services.set(e,t),this}add(e){return this.services.add(e),this}boot(){return document.addEventListener("DOMContentLoaded",this._ready),window.addEventListener("load",this._ready),window.addEventListener("resize",this._resize,{passive:!0}),window.addEventListener("scroll",this._scroll,{passive:!0}),this.services.init(),this.services.boot(),this}stop(){return window.removeEventListener("resize",this._resize),window.removeEventListener("scroll",this._scroll),this.services.stop(),this.emitter.clear(),this}on(e,t){return this.emitter.on(e,t,this),this}off(e,t){return this.emitter.off(e,t,this),this}emit(e,...t){return this.emitter.emit(e,...t),this}};var _e=class extends R{install(){super.install(),this.preventURLs=this.config.preventURLs,this.prefetchIgnore=this.config.prefetchIgnore,this.onTransitionPreventClick=this.config.onTransitionPreventClick,this.stickyScroll=this.config.stickyScroll,this.forceOnError=this.config.forceOnError,this.ignoreHashAction=this.config.ignoreHashAction}transitionStart(){this.isTransitioning=!0}transitionStop(){this.isTransitioning=!1}init(){this.onHover=this.onHover.bind(this),this.onClick=this.onClick.bind(this),this.onStateChange=this.onStateChange.bind(this)}boot(){super.boot()}getTransitionName(e){if(!e||!e.getAttribute)return null;let t=e.getAttribute(k(this.config,"transitionAttr",!1));return typeof t=="string"?t:null}validLink(e,t,i){let n=!window.history.pushState,s=!e||!i,a=t.metaKey||t.ctrlKey||t.shiftKey||t.altKey,l=e.hasAttribute("target")&&e.target==="_blank",o=e.protocol!==location.protocol||e.hostname!==location.hostname,p=typeof e.getAttribute("download")=="string",c=e.matches(k(this.config,"preventSelfAttr")),f=Boolean(e.closest(k(this.config,"preventAllAttr"))),y=j(E(i).pathname,this.preventURLs),u=M(E())===M(E(i));return!(s||n||a||l||o||p||c||f||y||u)}getHref(e){return e&&e.tagName&&e.tagName.toLowerCase()==="a"&&typeof e.href=="string"?e.href:null}getLink(e){let t=e.target,i=this.getHref(t);for(;t&&!i;)t=t.parentNode,i=this.getHref(t);if(!(!t||!this.validLink(t,e,i)))return t}onClick(e){let t=this.getLink(e);if(!t)return;if(this.isTransitioning&&this.onTransitionPreventClick){e.preventDefault(),e.stopPropagation();return}let i=this.getHref(t);this.emitter.emit("ANCHOR_CLICK CLICK",e),this.go({href:i,trigger:t,event:e})}getDirection(e){return Math.abs(e)>1?e>0?"forward":"back":e===0?"popstate":e>0?"back":"forward"}force(e){window.location.assign(e)}go({href:e,trigger:t="HistoryManager",event:i}){if(this.isTransitioning&&!this.onTransitionPreventClick||!(this.manager.has("TransitionManager")&&this.manager.has("HistoryManager")&&this.manager.has("PageManager"))){this.force(e);return}let n=this.manager.get("HistoryManager"),s=N(0,0),a=n.current,l=a.url;if(B(l,e))return;let o;if(i&&i.state){this.emitter.emit("POPSTATE",i);let{state:p}=i,{index:c}=p,y=a.index-c;n.replace(p.states),n.pointer=c;let u=n.get(c);o=u.transition,s=u.data.scroll,t=this.getDirection(y),this.emitter.emit(t==="back"?"POPSTATE_BACK":"POPSTATE_FORWARD",i)}else{o=this.getTransitionName(t),s=N();let p=Z({url:e,transition:o,data:{scroll:s}});!this.stickyScroll&&(s=N(0,0)),n.add(p),this.emitter.emit("HISTORY_NEW_ITEM",i)}return i&&(i.stopPropagation(),i.preventDefault()),this.emitter.emit("GO",i),this.load({oldHref:l,href:e,trigger:t,transitionName:o,scroll:s})}async load({oldHref:e,href:t,trigger:i,transitionName:n="default",scroll:s={x:0,y:0}}){try{let a=this.manager.get("TransitionManager"),l=this.manager.get("PageManager"),o=this.ignoreHashAction,p,c;this.emitter.emit("NAVIGATION_START",{oldHref:e,href:t,trigger:i,transitionName:n,scroll:s}),a.has(n)||(console.log(`[PJAX] transition name "${n}" doesn't exist, switching to the "default" transition`),n="default");try{this.transitionStart(),this.emitter.emit("PAGE_LOADING",{href:t,oldHref:e,trigger:i,scroll:s}),c=await l.load(e),p=await l.load(t),this.emitter.emit("PAGE_LOAD_COMPLETE",{newPage:p,oldPage:c,trigger:i,scroll:s}),c.dom instanceof Element||c.build(),p.build()}catch(f){console.warn("[PJAX] Page load error",f)}try{s=(await a.start(n,{oldPage:c,newPage:p,trigger:i,scroll:s,ignoreHashAction:o})).scroll}catch(f){console.warn("[PJAX] Transition error",f)}this.emitter.emit("NAVIGATION_END",{oldPage:c,newPage:p,trigger:i,transitionName:n,scroll:s})}catch(a){this.forceOnError?this.force(t):console.warn(a)}finally{this.transitionStop()}}onHover(e){let t=this.getLink(e);if(!t||!this.manager.has("PageManager"))return;let i=this.manager.get("PageManager"),n=E(this.getHref(t)),s=n.pathname;if(this.emitter.emit("ANCHOR_HOVER HOVER",e),!j(n.pathname,this.prefetchIgnore)&&!(i.has(s)&&!j(s,i.cacheIgnore)))try{i.load(n),this.emitter.emit("PREFETCH",e)}catch(a){console.warn("[PJAX] Prefetch error",a)}}onStateChange(e){this.go({href:window.location.href,trigger:"popstate",event:e})}initEvents(){this.prefetchIgnore!==!0&&(document.addEventListener("mouseover",this.onHover),document.addEventListener("touchstart",this.onHover)),document.addEventListener("click",this.onClick),window.addEventListener("popstate",this.onStateChange)}stopEvents(){this.prefetchIgnore!==!0&&(document.removeEventListener("mouseover",this.onHover),document.removeEventListener("touchstart",this.onHover)),document.removeEventListener("click",this.onClick),window.removeEventListener("popstate",this.onStateChange)}};var He=class extends R{constructor(e=[]){super();this.routes=new S;for(let t of e)this.add(t)}add({path:e,method:t}){let i=this.parse(e);return this.routes.set(i,t),this}parsePath(e){if(typeof e=="string"||e instanceof RegExp||Array.isArray(e))return J(e,[],{start:!1,end:!1});if(typeof e=="boolean")return e&&/.*/;throw"[Router] only regular expressions, strings, booleans and arrays of regular expressions and strings are accepted as paths."}isPath(e){return typeof e=="string"||e instanceof RegExp||typeof e=="boolean"||Array.isArray(e)}parse(e){let t=e,i={from:/.*/,to:/.*/};if(this.isPath(e))i={from:!0,to:e};else if(this.isPath(t.from)&&this.isPath(t.to))i=Object.assign({},i,t);else throw"[Router] path is neither a string, regular expression, or a { from, to } object.";let{from:n,to:s}=i;return{from:this.parsePath(n),to:this.parsePath(s)}}route(){if(this.manager.has("HistoryManager")){let e=this.manager.get("HistoryManager"),t=M(E((e.length>1?e.previous:e.current).url)),i=M(E());this.routes.forEach((n,s)=>{let a=s.from,l=s.to;if(typeof a=="boolean"&&typeof l=="boolean")throw`[Router] path ({ from: ${a}, to: ${l} }) is not valid, remember paths can only be strings, regular expressions, or a boolean; however, both the from and to paths cannot be both booleans.`;let o=a,p=l;a instanceof RegExp&&a.test(t)&&(o=a.exec(t)),l instanceof RegExp&&l.test(i)&&(p=l.exec(i)),(Array.isArray(p)&&Array.isArray(o)||Array.isArray(p)&&o==!1&&!l.test(t)||Array.isArray(o)&&p==!1&&!a.test(i))&&n({from:o,to:p,path:{from:t,to:i}})})}else console.warn("[Route] HistoryManager is missing.")}initEvents(){this.emitter.on("READY",this.route,this),this.emitter.on("CONTENT_REPLACED",this.route,this)}stopEvents(){this.emitter.off("READY",this.route,this),this.emitter.off("CONTENT_REPLACED",this.route,this)}};return Be;})(); +var native=(()=>{var Ke=Object.defineProperty;var Ue=(r,e)=>{for(var t in e)Ke(r,t,{get:e[t],enumerable:!0})};var Be={};Ue(Be,{AdvancedManager:()=>z,Animate:()=>B,App:()=>_e,CONFIG_DEFAULTS:()=>Re,CSSArrValue:()=>D,CSSValue:()=>X,DefaultAnimationOptions:()=>we,EASINGS:()=>fe,EFFECTS:()=>Ve,EasingKeys:()=>Se,Event:()=>U,EventEmitter:()=>F,GetEase:()=>ge,HistoryManager:()=>Oe,KeyframeParse:()=>le,Manager:()=>I,ManagerItem:()=>V,PARSER:()=>Me,PJAX:()=>He,Page:()=>ae,PageManager:()=>ke,ParseTransformableCSSKeyframes:()=>me,ParseTransformableCSSProperties:()=>ue,Replace:()=>Te,Router:()=>De,Service:()=>R,ServiceManager:()=>se,TransformFunctionNames:()=>pe,TransitionManager:()=>Ne,UnitDEG:()=>ie,UnitDEGCSSValue:()=>w,UnitLess:()=>$,UnitLessCSSValue:()=>L,UnitPX:()=>te,UnitPXCSSValue:()=>C,addCSSUnit:()=>ee,animate:()=>ze,asyncMethodCall:()=>Fe,changeState:()=>Ce,clean:()=>be,computeOption:()=>Ie,createTransformProperty:()=>ce,equal:()=>Z,flatten:()=>xe,getElements:()=>ve,getHash:()=>je,getHashedPath:()=>M,getTargets:()=>ne,hashAction:()=>Ee,ignoreURLs:()=>G,isValid:()=>P,mapAnimationOptions:()=>he,mapObject:()=>Y,methodCall:()=>H,newConfig:()=>de,newCoords:()=>_,newListener:()=>oe,newState:()=>J,newURL:()=>E,omit:()=>W,parseOffset:()=>q,parseOptions:()=>Pe,toArr:()=>re,toAttr:()=>N,transpose:()=>Ae});var I=class{constructor(e){this.map=new Map(e)}getMap(){return this.map}get(e){return this.map.get(e)}keys(){return Array.from(this.map.keys())}values(){return Array.from(this.map.values())}set(e,t){return this.map.set(e,t),this}add(e){let i=this.size;return this.set(i,e),this}get size(){return this.map.size}get length(){return this.map.size}last(e=1){let t=this.keys()[this.size-e];return this.get(t)}delete(e){return this.map.delete(e)}remove(e){return this.map.delete(e),this}clear(){return this.map.clear(),this}has(e){return this.map.has(e)}entries(){return this.map.entries()}forEach(e,t){return this.map.forEach(e,t),this}[Symbol.iterator](){return this.entries()}},H=(r,e,...t)=>{r.forEach(i=>{i[e](...t)})},Fe=async(r,e,...t)=>{for(let[,i]of r)await i[e](...t)};var oe=({callback:r=()=>{},scope:e=null,name:t="event"})=>({callback:r,scope:e,name:t}),U=class extends I{constructor(e="event"){super();this.name=e}},F=class extends I{constructor(){super()}getEvent(e){let t=this.get(e);return t instanceof U?t:(this.set(e,new U(e)),this.get(e))}newListener(e,t,i){let n=this.getEvent(e);return n.add(oe({name:e,callback:t,scope:i})),n}on(e,t,i){if(typeof e=="undefined"||e==null)return this;typeof e=="string"&&(e=e.trim().split(/\s/g));let n,s,a=typeof e=="object"&&!Array.isArray(e),l=a?t:i;return a||(s=t),Object.keys(e).forEach(p=>{n=a?p:e[p],a&&(s=e[p]),this.newListener(n,s,l)},this),this}removeListener(e,t,i){let n=this.get(e);if(n instanceof U&&t){let s=oe({name:e,callback:t,scope:i});n.forEach((a,l)=>{if(a.callback===s.callback&&a.scope===s.scope)return n.remove(l)})}return n}off(e,t,i){if(typeof e=="undefined"||e==null)return this;typeof e=="string"&&(e=e.trim().split(/\s/g));let n,s,a=typeof e=="object"&&!Array.isArray(e),l=a?t:i;return a||(s=t),Object.keys(e).forEach(p=>{n=a?p:e[p],a&&(s=e[p]),typeof s=="function"?this.removeListener(n,s,l):this.remove(n)},this),this}once(e,t,i){if(typeof e=="undefined"||e==null)return this;typeof e=="string"&&(e=e.trim().split(/\s/g));let n=typeof e=="object"&&!Array.isArray(e);return Object.keys(e).forEach(s=>{let a=n?s:e[s],l=n?e[s]:t,p=n?t:i,o=(...c)=>{l.apply(p,c),this.removeListener(a,o,p)};this.newListener(a,o,p)},this),this}emit(e,...t){return typeof e=="undefined"||e==null?this:(typeof e=="string"&&(e=e.trim().split(/\s/g)),e.forEach(i=>{let n=this.get(i);n instanceof U&&n.forEach(s=>{let{callback:a,scope:l}=s;a.apply(l,t)})},this),this)}clear(){return H(this,"clear"),super.clear(),this}};var q=r=>typeof r=="string"?r.includes("%")?parseFloat(r)/100:r=="from"?0:r=="to"?1:parseFloat(r):r,le=r=>{let e=new Set,t=Object.keys(r),i=t.length;for(let n=0;nn.offset-s.offset)},Ve={};var ee=(r="")=>e=>typeof e=="string"?e:`${e}${r}`,$=ee(),te=ee("px"),ie=ee("deg"),re=r=>Array.isArray(r)||typeof r=="string"?(typeof r=="string"&&(r=r.split(",")),r):[r],P=r=>Array.isArray(r)||typeof r=="string"?Boolean(r.length):r!=null&&r!=null,X=r=>e=>P(e)?re(e).map(t=>{if(typeof t!="number"&&typeof t!="string")return t;let i=Number(t),n=Number.isNaN(i)?typeof t=="string"?t.trim():t:i;return r(n)}):[],Ae=(...r)=>{let e=0;r=r.map(n=>{let s=re(n),a=s.length;return a>e&&(e=a),s});let t=[],i=r.length;for(let n=0;nre(r).map(X(e)),pe=["translate","translate3d","translateX","translateY","translateZ","rotate","rotate3d","rotateX","rotateY","rotateZ","scale","scale3d","scaleX","scaleY","scaleZ","skew","skewX","skewY","perspective"],ce=r=>{let e="",t=pe.length;for(let i=0;i{let{perspective:e,rotate:t,rotate3d:i,rotateX:n,rotateY:s,rotateZ:a,translate:l,translate3d:p,translateX:o,translateY:c,translateZ:h,scale:y,scale3d:m,scaleX:f,scaleY:d,scaleZ:u,skew:g,skewX:b,skewY:A,...v}=r;l=D(l,te),p=D(p,te),o=C(o),c=C(c),h=C(h),t=D(t,ie),i=D(i,$),n=w(n),s=w(s),a=w(a),y=D(y,$),m=D(m,$),f=L(f),d=L(d),u=L(u),g=D(g,ie),b=w(b),A=w(A),e=C(e);let x=Ae(l,p,o,c,h,t,i,n,s,a,y,m,f,d,u,g,b,A,e).filter(P).map(ce);return v=Y(v,T=>[].concat(T).map(S=>""+S)),Object.assign({},P(x)?{transform:x}:null,v)},me=r=>r.map(e=>{let{translate:t,translate3d:i,translateX:n,translateY:s,translateZ:a,rotate:l,rotate3d:p,rotateX:o,rotateY:c,rotateZ:h,scale:y,scale3d:m,scaleX:f,scaleY:d,scaleZ:u,skew:g,skewX:b,skewY:A,perspective:v,easing:x,iterations:T,offset:S,...O}=e;return t=C(t),i=C(i),n=C(n)[0],s=C(s)[0],a=C(a)[0],l=w(l),p=L(p),o=w(o)[0],c=w(c)[0],h=w(h)[0],y=L(y),m=L(m),f=L(f)[0],d=L(d)[0],u=L(u)[0],g=w(g),b=w(b)[0],A=w(A)[0],v=C(v)[0],[O,t,i,n,s,a,l,p,o,c,h,y,m,f,d,u,g,b,A,v]}).map(([e,...t])=>{let i=ce(t);return Object.assign({},P(i)?{transform:i}:null,e)});var ve=r=>typeof r=="string"?Array.from(document.querySelectorAll(r)):[r],xe=r=>[].concat(...r),ne=r=>Array.isArray(r)?xe(r.map(ne)):typeof r=="string"||r instanceof Node?ve(r):r instanceof NodeList||r instanceof HTMLCollection?Array.from(r):[],Ie=(r,e,t)=>typeof r=="function"?r.apply(t,e):r,Y=(r,e)=>{let t=Object.keys(r),i,n,s={};for(let a=0,l=t.length;aY(r,i=>Ie(i,e,t)),fe={in:"ease-in",out:"ease-out","in-out":"ease-in-out","in-sine":"cubic-bezier(0.47, 0, 0.745, 0.715)","out-sine":"cubic-bezier(0.39, 0.575, 0.565, 1)","in-out-sine":"cubic-bezier(0.445, 0.05, 0.55, 0.95)","in-quad":"cubic-bezier(0.55, 0.085, 0.68, 0.53)","out-quad":"cubic-bezier(0.25, 0.46, 0.45, 0.94)","in-out-quad":"cubic-bezier(0.455, 0.03, 0.515, 0.955)","in-cubic":"cubic-bezier(0.55, 0.055, 0.675, 0.19)","out-cubic":"cubic-bezier(0.215, 0.61, 0.355, 1)","in-out-cubic":"cubic-bezier(0.645, 0.045, 0.355, 1)","in-quart":"cubic-bezier(0.895, 0.03, 0.685, 0.22)","out-quart":"cubic-bezier(0.165, 0.84, 0.44, 1)","in-out-quart":"cubic-bezier(0.77, 0, 0.175, 1)","in-quint":"cubic-bezier(0.755, 0.05, 0.855, 0.06)","out-quint":"cubic-bezier(0.23, 1, 0.32, 1)","in-out-quint":"cubic-bezier(0.86, 0, 0.07, 1)","in-expo":"cubic-bezier(0.95, 0.05, 0.795, 0.035)","out-expo":"cubic-bezier(0.19, 1, 0.22, 1)","in-out-expo":"cubic-bezier(1, 0, 0, 1)","in-circ":"cubic-bezier(0.6, 0.04, 0.98, 0.335)","out-circ":"cubic-bezier(0.075, 0.82, 0.165, 1)","in-out-circ":"cubic-bezier(0.785, 0.135, 0.15, 0.86)","in-back":"cubic-bezier(0.6, -0.28, 0.735, 0.045)","out-back":"cubic-bezier(0.175, 0.885, 0.32, 1.275)","in-out-back":"cubic-bezier(0.68, -0.55, 0.265, 1.55)"},Se=Object.keys(fe),ge=r=>{let e=r.replace(/^ease-/,"");return Se.includes(e)?fe[e]:r},we={keyframes:[],offset:[],loop:1,delay:0,speed:1,endDelay:0,easing:"ease",timelineOffset:0,autoplay:!0,duration:1e3,fillMode:"none",direction:"normal",padEndDelay:!1,timeline:document.timeline,extend:{}},Pe=r=>{let{options:e,...t}=r,i=e instanceof B?e.options:Array.isArray(e)?e?.[0]?.options:e;return Object.assign({},i,t)},W=(r,e)=>{let t={...e};for(;r.length;){let{[r.pop()]:i,...n}=t;t=n}return t},ye=class{constructor(e){this.options={};this.properties={};this.totalDuration=0;this.emitter=new F;this.targets=new I;this.targetIndexes=new WeakMap;this.keyframeEffects=new WeakMap;this.computedOptions=new WeakMap;this.animations=new WeakMap;this.computedKeyframes=new WeakMap;this.loop=this.loop.bind(this),this.onVisibilityChange=this.onVisibilityChange.bind(this),this.on("error",console.error),this.updateOptions(e),this.mainAnimation&&(this.visibilityPlayState=this.getPlayState(),ye.pauseOnPageHidden&&document.addEventListener("visibilitychange",this.onVisibilityChange,!1)),this.newPromise()}onVisibilityChange(){document.hidden?(this.visibilityPlayState=this.getPlayState(),this.is("running")&&(this.loop(),this.pause())):this.visibilityPlayState=="running"&&this.is("paused")&&this.play()}newPromise(){return this.promise=new Promise((e,t)=>{this?.emitter?.once?.("finish",()=>e([this])),this?.emitter?.once?.("error",i=>t(i))}),this.promise}then(e,t){return e=e?.bind(this),t=t?.bind(this),this?.promise?.then?.(e,t),this}catch(e){return e=e?.bind(this),this.promise?.catch?.(e),this}finally(e){return e=e?.bind(this),this.promise?.finally?.(e),this}loop(){this.stopLoop(),this.animationFrame=window.requestAnimationFrame(this.loop),this.emit("update",this.getProgress(),this)}stopLoop(){window.cancelAnimationFrame(this.animationFrame)}allAnimations(e){return this.targets.forEach(t=>{let i=this.keyframeEffects.get(t),n=this.animations.get(i);return e(n,t)}),this}all(e){return this.mainAnimation&&e(this.mainAnimation,this.mainElement),this.allAnimations(e),this}beginEvent(){this.getProgress()==0&&this.emit("begin",this)}play(){let e=this.getPlayState();return this.beginEvent(),this.all(t=>t.play()),this.emit("play",e,this),this.is(e)||this.emit("playstate-change",e,this),this.loop(),this}pause(){let e=this.getPlayState();return this.all(t=>t.pause()),this.emit("pause",e,this),this.is(e)||this.emit("playstate-change",e,this),this.stopLoop(),this}reverse(){return this.all(e=>e.reverse()),this}reset(){return this.setProgress(0),this.options.autoplay?this.play():this.pause(),this}cancel(){return this.all(e=>e.cancel()),this}finish(){return this.all(e=>e.finish()),this}stop(){this.cancel(),this.stopLoop(),document.removeEventListener("visibilitychange",this.onVisibilityChange,!1),this.targets.forEach(e=>this.removeTarget(e)),this.emit("stop"),this.emitter.clear(),this.mainkeyframeEffect=null,this.mainAnimation=null,this.mainElement=null,this.promise=null,this.computedOptions=null,this.animations=null,this.keyframeEffects=null,this.emitter=null,this.targets=null,this.options=null,this.properties=null}getAnimation(e){let t=this.keyframeEffects.get(e);return this.animations.get(t)}getTiming(e){let t=this.computedOptions.get(e)??{},i=this.keyframeEffects.get(e).getTiming?.()??{};return{...t,...i}}getCurrentTime(){return this.mainAnimation.currentTime}getProgress(){return this.getCurrentTime()/this.totalDuration*100}getSpeed(){return this.mainAnimation.playbackRate}getPlayState(){return this.mainAnimation.playState}is(e){return this.getPlayState()==e}setCurrentTime(e){return this.all(t=>t.currentTime=e),this.emit("update",this.getProgress()),this}setProgress(e){let t=e/100*this.totalDuration;return this.setCurrentTime(t),this}setSpeed(e=1){return this.maxSpeed=e,this.all(t=>{t.updatePlaybackRate?t.updatePlaybackRate(e):t.playbackRate=e}),this}createArrayOfComputedOptions(e,t){let i=[];return this.targets.forEach((n,s)=>{let a=this.computedOptions.get(n)??{},l=b=>{let A=b;return b=="loop"&&(A="iterations"),b=="fillMode"&&(A="fill"),e[b]??a[A]??this.options[b]},p=Object.assign({easing:l("easing"),iterations:l("loop"),direction:l("direction"),endDelay:l("endDelay"),duration:l("duration"),speed:l("speed"),delay:l("delay"),timelineOffset:l("timelineOffset"),keyframes:l("keyframes")},l("extend")??{}),o=he(p,[s,t,n],this);typeof o.easing=="string"&&(o.easing=ge(o.easing)),o.iterations===!0&&(o.iterations=Infinity),o.fill=l("fillMode");let{timelineOffset:c,speed:h,endDelay:y,delay:m,duration:f,iterations:d,...u}=o;d=Number(d),f=Number(f),y=Number(y),h=Number(h),m=Number(m)+Number(c);let g=m+f*d+y;this.totalDuration{let{speed:h,keyframes:y,tempDurations:m,...f}=i[c];n&&f.endDelay==0&&Math.abs(f.iterations)!=Math.abs(Infinity)&&(f.endDelay=this.totalDuration-m);let d,u,g=y;typeof g=="object"&&(g=le(g));let b=this.computedKeyframes.get(o)??{},A=Object.assign({},s,b),v=Y(A,(S,O)=>this.properties[O]??S);if(u=P(g)?g:v,Array.isArray(u))d=u.map(S=>{let{easing:O,offset:k,...K}=W(["speed","loop"],S);return Object.assign({},K,typeof O=="string"?{easing:ge(O)}:null,typeof k=="string"||typeof k=="number"?{offset:q(k)}:null)}),d=me(d);else{let S=W(["keyframes"],u),{offset:O,...k}=he(S,[c,t,o],this);k=ue(k);let K=O;d=Object.assign({},k,P(K)?{offset:K.map(q)}:null)}let x,T;this.keyframeEffects.has(o)?(T=this.keyframeEffects.get(o),x=this.animations.get(T),T?.setKeyframes?.(d),T?.updateTiming?.(f)):(T=new KeyframeEffect(o,d,f),x=new Animation(T,p),this.keyframeEffects.set(o,T),this.animations.set(T,x)),x.playbackRate=h,x.onfinish=()=>{typeof a=="function"&&a.call(this,o,c,t,x)},x.oncancel=()=>{typeof l=="function"&&l.call(this,o,c,t,x)},this.computedOptions.set(o,f),this.computedKeyframes.set(o,d)})}updateOptions(e={}){try{let t=Pe(e);this.options=Object.assign({},we,this.options,t);let i=["easing","loop","endDelay","duration","speed","delay","timelineOffset","direction","extend","fillMode","offset"],{padEndDelay:n,autoplay:s,target:a,targets:l,timeline:p,onfinish:o,oncancel:c,...h}=W(i,this.options);this.properties=W([...i,"keyframes","padEndDelay","onfinish","oncancel","autoplay","target","targets","timeline"],t);let y=this.targets.values(),m=[...new Set([...y,...ne(l),...ne(a)])];this.targets.clear(),m.forEach((u,g)=>{this.targets.set(g,u),this.targetIndexes.set(u,g)});let f=this.targets.size,d=this.createArrayOfComputedOptions(t,f);if(this.createAnimations({arrOfComputedOptions:d,padEndDelay:n,oldCSSProperties:h,onfinish:o,oncancel:c,timeline:p},f),this.maxSpeed=this.maxSpeed??this.options.speed,this.minDelay=this.minDelay??this.options.delay,this.totalDuration=this.totalDuration??this.options.duration,this.mainAnimation?(this.mainkeyframeEffect?.updateTiming?.({duration:this.totalDuration}),(!this.mainkeyframeEffect.setKeyframes||!this.mainkeyframeEffect.updateTiming)&&console.warn("@okikio/animate - `KeyframeEffect.setKeyframes` and/or `KeyframeEffect.updateTiming` are not supported in this browser.")):(this.mainkeyframeEffect=new KeyframeEffect(this.mainElement,[{opacity:"0"},{opacity:"1"}],{duration:this.totalDuration,easing:"linear"}),this.mainAnimation=new Animation(this.mainkeyframeEffect,p)),this.mainAnimation.playbackRate=this.maxSpeed,this.mainAnimation.onfinish=()=>{if(this.emit("finish",this),this.mainAnimation){let u=this.getPlayState();this.is(u)||this.emit("playstate-change",u,this),this.stopLoop()}},this.mainAnimation.oncancel=()=>{if(this.emit("cancel",this),this.mainAnimation){let u=this.getPlayState();this.is(u)||this.emit("playstate-change",u,this),this.stopLoop()}},s){let u=window.setTimeout(()=>{this.emit("begin",this),u=window.clearTimeout(u)},0);this.play()}else this.pause()}catch(t){this.emit("error",t)}}add(e){let t=this.getProgress(),i=this.is("running"),n=this.is("paused");this.updateOptions({target:e}),this.setProgress(t),i?this.play():n&&this.pause()}removeTarget(e){let t=this.keyframeEffects.get(e);this.animations.delete(t),t=null,this.computedKeyframes.delete(e),this.computedOptions.delete(e),this.keyframeEffects.delete(e);let i=this.targetIndexes.get(e);this.targets.delete(i),this.targetIndexes.delete(e)}remove(e){this.removeTarget(e);let t=new Set([].concat(this.targets.values()));this.options.target=[...t],this.options.targets=[],t.clear(),t=null;let i=this.getProgress(),n=this.is("running"),s=this.is("paused");this.updateOptions(),n?this.play():s&&this.pause(),this.setProgress(i)}on(e,t,i){return this?.emitter?.on(e,t,i??this),this}off(e,t,i){return this?.emitter?.off(e,t,i??this),this}emit(e,...t){return this?.emitter?.emit(e,...t),this}toJSON(){return this.options}get[Symbol.toStringTag](){return"Animate"}},B=ye;B.pauseOnPageHidden=!0;var ze=(r={})=>new B(r);var Re={wrapperAttr:"wrapper",headers:[],preventSelfAttr:'prevent="self"',preventAllAttr:'prevent="all"',transitionAttr:"transition",timeout:2e3,maxPages:5,resizeDelay:100,onTransitionPreventClick:!0,cacheIgnore:!1,prefetchIgnore:!1,preventURLs:[],stickyScroll:!1,forceOnError:!0,ignoreHashAction:!1,transitions:[]},de=r=>Object.assign({...Re},r),N=(r,e,t=!0)=>{let{prefix:i}=r,n=r[e],s=`data${i?"-"+i:""}-${n}`;return t?`[${s}]`:s};var V=class{constructor(){}install(){}register(e,t){return this.manager=e,this.app=e.app,this.config=e.config,this.emitter=e.emitter,this.key=t,this.install(),this}uninstall(){}unregister(){this.uninstall(),this.manager.remove(this.key),this.key=null,this.manager=null,this.app=null,this.config=null,this.emitter=null}},z=class extends I{constructor(e){super();this.app=e,this.config=e.config,this.emitter=e.emitter}set(e,t){return super.set(e,t),t.register(this,e),this}};var E=(r=window.location.href)=>r instanceof URL?r:new URL(r,window.location.origin),M=r=>{let e=E(r);return`${e.pathname}${e.hash}`},je=r=>E(r).hash.slice(1),be=r=>E(r).toString().replace(/(\/#.*|\/|#.*)$/,""),Z=(r,e)=>be(r)===be(e);var R=class extends V{init(){}boot(){this.initEvents()}initEvents(){}stopEvents(){}stop(){this.stopEvents(),this.unregister()}},se=class extends z{constructor(e){super(e)}init(){return H(this,"init"),this}boot(){return H(this,"boot"),this}stop(){return H(this,"stop"),this}};var _=(r=window.scrollX,e=window.scrollY)=>({x:r,y:e}),J=(r={url:M(E()),index:0,transition:"default",data:{scroll:_(),trigger:"HistoryManager"}})=>r,Oe=class extends R{constructor(){super(...arguments);this.pointer=-1}init(){this.states=[];let e=J();this.add(e,"replace")}get(e){return this.states[e]}add(e,t="push"){let i=J(e),n=this.length;this.states.push({...i}),this.pointer=n;let s={index:this.pointer,states:[...this.states]};return Ce(t,i,s),this}remove(e){return e?this.states.splice(e,1):this.states.pop(),this.pointer--,this}replace(e){return this.states=e,this}set(e,t){return this.states[e]=t}get current(){return this.get(this.pointer)}get last(){return this.get(this.length-1)}get previous(){return this.pointer<1?null:this.get(this.pointer-1)}get length(){return this.states.length}},Ce=(r,e,t)=>{let i=M(e.url),n=[t,"",i];if(window.history)switch(r){case"push":window.history.pushState.apply(window.history,n);break;case"replace":window.history.replaceState.apply(window.history,n);break}};function Ge(r){for(var e=[],t=0;t=48&&a<=57||a>=65&&a<=90||a>=97&&a<=122||a===95){n+=r[s++];continue}break}if(!n)throw new TypeError("Missing parameter name at "+t);e.push({type:"NAME",index:t,value:n}),t=s;continue}if(i==="("){var l=1,p="",s=t+1;if(r[s]==="?")throw new TypeError('Pattern cannot start with "?" at '+s);for(;s)?(?!\?)/g,i=0,n=t.exec(r.source);n;)e.push({name:n[1]||i++,prefix:"",suffix:"",modifier:"",pattern:""}),n=t.exec(r.source);return r}function Xe(r,e,t){var i=r.map(function(n){return Q(n,e,t).source});return new RegExp("(?:"+i.join("|")+")",Le(t))}function Ye(r,e,t){return We(qe(r,t),e,t)}function We(r,e,t){t===void 0&&(t={});for(var i=t.strict,n=i===void 0?!1:i,s=t.start,a=s===void 0?!0:s,l=t.end,p=l===void 0?!0:l,o=t.encode,c=o===void 0?function(T){return T}:o,h="["+j(t.endsWith||"")+"]|$",y="["+j(t.delimiter||"/#?")+"]",m=a?"^":"",f=0,d=r;f-1:v===void 0;n||(m+="(?:"+y+"(?="+h+"))?"),x||(m+="(?="+y+"|"+h+")")}return new RegExp(m,Le(t))}function Q(r,e,t){return r instanceof RegExp?$e(r,e):Array.isArray(r)?Xe(r,e,t):Ye(r,e,t)}var Me=new DOMParser,ae=class extends V{constructor(e=E(),t=document){super();this.url=E(e),typeof t=="string"?this.data=t:this.dom=t||document}async build(){if(this.dom instanceof Node||(this.dom=Me.parseFromString(this.data,"text/html")),!(this.body instanceof Node)){let{title:e,head:t,body:i}=this.dom;this.title=e,this.head=t,this.body=i,this.wrapper=this.body.querySelector(this.wrapperAttr)}}install(){this.wrapperAttr=N(this.config,"wrapperAttr")}uninstall(){this.url=null,this.title=null,this.head=null,this.body=null,this.dom=null,this.wrapper=null,this.data=null,this.wrapperAttr=null}},ke=class extends R{constructor(){super();this.loading=new I}install(){this.pages=new z(this.app),this.cacheIgnore=this.config.cacheIgnore;let e=E().pathname;this.set(e,new ae),e=null}get(e){return this.pages.get(e)}add(e){return this.pages.add(e),this}set(e,t){return this.pages.set(e,t),this}remove(e){return this.pages.remove(e),this}has(e){return this.pages.has(e)}clear(){return this.pages.clear(),this}get size(){return this.pages.size}keys(){return this.pages.keys()}async load(e=E()){let t=E(e),i=t.pathname,n,s;if(this.has(i)&&!G(i,this.cacheIgnore))return n=this.get(i),Promise.resolve(n);this.loading.has(i)?s=this.loading.get(i):(s=this.request(i),this.loading.set(i,s));let a=await s;if(this.loading.remove(i),n=new ae(t,a),this.set(i,n),this.size>this.config.maxPages){let l=E(),p=this.keys(),o=Z(l,p[0])?p[1]:p[0],c=this.get(o);c.unregister(),c=null,p=null,l=null,o=null}return n}async request(e){let t=new Headers(this.config.headers),i=window.setTimeout(()=>{window.clearTimeout(i);let n=new Error("Request Timed Out!");throw this.emitter.emit("TIMEOUT_ERROR",n),n},this.config.timeout);try{let n=await fetch(e,{mode:"same-origin",method:"GET",headers:t,cache:"default",credentials:"same-origin"});if(window.clearTimeout(i),n.status>=200&&n.status<300)return await n.text();let s=new Error(n.statusText||""+n.status);throw this.emitter.emit("REQUEST_ERROR",s),s}catch(n){throw window.clearTimeout(i),n}}},G=(r,e)=>{if(typeof e=="boolean")return e;let t=[];return!e.every(i=>Q(i,t,{start:!1,end:!1}).exec(r)==null)};var Ee=(r,e=window.location.hash)=>{try{let t=e[0]=="#"?e:E(e).hash;if(t.length>1){let i=document.getElementById(t.slice(1));if(i){let{left:n,top:s}=i.getBoundingClientRect(),a=window.scrollX,l=window.scrollY,p=n+a,o=s+l;return _(p,o)}}}catch(t){console.warn("[hashAction] error",t)}return r??_(0,0)},Te={name:"replace"},Ne=class extends R{constructor(e){super();this._arg=e}install(){super.install();let e=this._arg&&this._arg.length?this._arg:this.config.transitions;this.transitions=new I([["default",Te],["replace",Te]].concat(e))}get(e){return this.transitions.get(e)}set(e,t){return this.transitions.set(e,t),this}add(e){return this.transitions.add(e),this}has(e){return this.transitions.has(e)}async start(e,t){let i=this.transitions.get(e),{oldPage:n,newPage:s,ignoreHashAction:a,trigger:l}=t;if(this.emitter.emit("TRANSITION_START",{transitionName:e,...t}),!("wrapper"in n)||!("wrapper"in s))throw`[TransitionManager] either oldPage or newPage aren't instances of the Page Class. + ${{newPage:s,oldPage:n}}`;document.title=""+s.title;let p=n.wrapper,o=s.wrapper;if(!(p instanceof Node)||!(o instanceof Node))throw`[TransitionManager] the wrapper from the ${o instanceof Node?"current":"next"} page cannot be found. The wrapper must be an element that has the attribute ${N(this.config,"wrapperAttr")}.`;return i.init&&i?.init(t),this.emitter.emit("BEFORE_TRANSITION_OUT",t),i.out&&await new Promise(c=>{i.out.call(i,{...t,from:n,done:c})?.then(c)}),this.emitter.emit("AFTER_TRANSITION_OUT",t),await new Promise(c=>{p.insertAdjacentElement("beforebegin",o),this.emitter.emit("CONTENT_INSERT",t),c()}),await new Promise(c=>{p.remove(),p=null,o=null,this.emitter.emit("CONTENT_REPLACED",t),!a&&!/back|popstate|forward/.test(l)&&(t.scroll=Ee(t.scroll)),c()}),this.emitter.emit("BEFORE_TRANSITION_IN",t),i.in&&await new Promise(c=>{i.in.call(i,{...t,from:n,to:s,done:c})?.then(c)}),this.emitter.emit("AFTER_TRANSITION_IN",t),i.manualScroll||(!a&&!/back|popstate|forward/.test(l)&&(t.scroll=Ee(t.scroll)),window.scroll(t.scroll.x,t.scroll.y)),this.emitter.emit("TRANSITION_END",{transitionName:e,...t}),t}};var _e=class{constructor(e={}){this.canResize=!0;this.canScroll=!0;this._resize=this._resize.bind(this),this._scroll=this._scroll.bind(this),this._ready=this._ready.bind(this),this.register(e)}register(e={}){return this.config=de(e),this.emitter=new F,this.services=new se(this),this}_ready(){document.removeEventListener("DOMContentLoaded",this._ready),window.removeEventListener("load",this._ready),this.emitter.emit("READY ready")}_resize(){if(this.canResize){let e,t;this.canResize=!1,t=window.requestAnimationFrame(()=>{this.emitter.emit("RESIZE resize"),e=window.setTimeout(()=>{this.canResize=!0,e=window.clearTimeout(e),t=window.cancelAnimationFrame(t)},this.config.resizeDelay)})}}_scroll(){if(this.canScroll){let e;this.canScroll=!1,e=requestAnimationFrame(()=>{this.emitter.emit("SCROLL scroll"),this.canScroll=!0,e=window.cancelAnimationFrame(e)})}}get(e){return this.services.get(e)}set(e,t){return this.services.set(e,t),this}add(e){return this.services.add(e),this}boot(){return document.addEventListener("DOMContentLoaded",this._ready),window.addEventListener("load",this._ready),window.addEventListener("resize",this._resize,{passive:!0}),window.addEventListener("scroll",this._scroll,{passive:!0}),this.services.init(),this.services.boot(),this}stop(){return window.removeEventListener("resize",this._resize),window.removeEventListener("scroll",this._scroll),this.services.stop(),this.emitter.clear(),this}on(e,t){return this.emitter.on(e,t,this),this}off(e,t){return this.emitter.off(e,t,this),this}emit(e,...t){return this.emitter.emit(e,...t),this}};var He=class extends R{install(){super.install(),this.preventURLs=this.config.preventURLs,this.prefetchIgnore=this.config.prefetchIgnore,this.onTransitionPreventClick=this.config.onTransitionPreventClick,this.stickyScroll=this.config.stickyScroll,this.forceOnError=this.config.forceOnError,this.ignoreHashAction=this.config.ignoreHashAction}transitionStart(){this.isTransitioning=!0}transitionStop(){this.isTransitioning=!1}init(){this.onHover=this.onHover.bind(this),this.onClick=this.onClick.bind(this),this.onStateChange=this.onStateChange.bind(this)}boot(){super.boot()}getTransitionName(e){if(!e||!e.getAttribute)return null;let t=e.getAttribute(N(this.config,"transitionAttr",!1));return typeof t=="string"?t:null}validLink(e,t,i){let n=!window.history.pushState,s=!e||!i,a=t.metaKey||t.ctrlKey||t.shiftKey||t.altKey,l=e.hasAttribute("target")&&e.target==="_blank",p=e.protocol!==location.protocol||e.hostname!==location.hostname,o=typeof e.getAttribute("download")=="string",c=e.matches(N(this.config,"preventSelfAttr")),h=Boolean(e.closest(N(this.config,"preventAllAttr"))),y=G(E(i).pathname,this.preventURLs),m=M(E())===M(E(i));return!(s||n||a||l||p||o||c||h||y||m)}getHref(e){return e&&e.tagName&&e.tagName.toLowerCase()==="a"&&typeof e.href=="string"?e.href:null}getLink(e){let t=e.target,i=this.getHref(t);for(;t&&!i;)t=t.parentNode,i=this.getHref(t);if(!(!t||!this.validLink(t,e,i)))return t}onClick(e){let t=this.getLink(e);if(!t)return;if(this.isTransitioning&&this.onTransitionPreventClick){e.preventDefault(),e.stopPropagation();return}let i=this.getHref(t);this.emitter.emit("ANCHOR_CLICK CLICK",e),this.go({href:i,trigger:t,event:e})}getDirection(e){return Math.abs(e)>1?e>0?"forward":"back":e===0?"popstate":e>0?"back":"forward"}force(e){window.location.assign(e)}go({href:e,trigger:t="HistoryManager",event:i}){if(this.isTransitioning&&!this.onTransitionPreventClick||!(this.manager.has("TransitionManager")&&this.manager.has("HistoryManager")&&this.manager.has("PageManager"))){this.force(e);return}let n=this.manager.get("HistoryManager"),s=_(0,0),a=n.current,l=a.url;if(Z(l,e))return;let p;if(i&&i.state){this.emitter.emit("POPSTATE",i);let{state:o}=i,{index:c}=o,y=a.index-c;n.replace(o.states),n.pointer=c;let m=n.get(c);p=m.transition,s=m.data.scroll,t=this.getDirection(y),this.emitter.emit(t==="back"?"POPSTATE_BACK":"POPSTATE_FORWARD",i)}else{p=this.getTransitionName(t),s=_();let o=J({url:e,transition:p,data:{scroll:s}});!this.stickyScroll&&(s=_(0,0)),n.add(o),this.emitter.emit("HISTORY_NEW_ITEM",i)}return i&&(i.stopPropagation(),i.preventDefault()),this.emitter.emit("GO",i),this.load({oldHref:l,href:e,trigger:t,transitionName:p,scroll:s})}async load({oldHref:e,href:t,trigger:i,transitionName:n="default",scroll:s={x:0,y:0}}){try{let a=this.manager.get("TransitionManager"),l=this.manager.get("PageManager"),p=this.ignoreHashAction,o,c;this.emitter.emit("NAVIGATION_START",{oldHref:e,href:t,trigger:i,transitionName:n,scroll:s}),a.has(n)||(console.log(`[PJAX] transition name "${n}" doesn't exist, switching to the "default" transition`),n="default");try{this.transitionStart(),this.emitter.emit("PAGE_LOADING",{href:t,oldHref:e,trigger:i,scroll:s}),c=await l.load(e),o=await l.load(t),this.emitter.emit("PAGE_LOAD_COMPLETE",{newPage:o,oldPage:c,trigger:i,scroll:s}),c.dom instanceof Element||c.build(),o.build()}catch(h){console.warn("[PJAX] Page load error",h)}try{s=(await a.start(n,{oldPage:c,newPage:o,trigger:i,scroll:s,ignoreHashAction:p})).scroll}catch(h){console.warn("[PJAX] Transition error",h)}this.emitter.emit("NAVIGATION_END",{oldPage:c,newPage:o,trigger:i,transitionName:n,scroll:s})}catch(a){this.forceOnError?this.force(t):console.warn(a)}finally{this.transitionStop()}}onHover(e){let t=this.getLink(e);if(!t||!this.manager.has("PageManager"))return;let i=this.manager.get("PageManager"),n=E(this.getHref(t)),s=n.pathname;if(this.emitter.emit("ANCHOR_HOVER HOVER",e),!G(n.pathname,this.prefetchIgnore)&&!(i.has(s)&&!G(s,i.cacheIgnore)))try{i.load(n),this.emitter.emit("PREFETCH",e)}catch(a){console.warn("[PJAX] Prefetch error",a)}}onStateChange(e){this.go({href:window.location.href,trigger:"popstate",event:e})}initEvents(){this.prefetchIgnore!==!0&&(document.addEventListener("mouseover",this.onHover),document.addEventListener("touchstart",this.onHover)),document.addEventListener("click",this.onClick),window.addEventListener("popstate",this.onStateChange)}stopEvents(){this.prefetchIgnore!==!0&&(document.removeEventListener("mouseover",this.onHover),document.removeEventListener("touchstart",this.onHover)),document.removeEventListener("click",this.onClick),window.removeEventListener("popstate",this.onStateChange)}};var De=class extends R{constructor(e=[]){super();this.routes=new I;for(let t of e)this.add(t)}add({path:e,method:t}){let i=this.parse(e);return this.routes.set(i,t),this}parsePath(e){if(typeof e=="string"||e instanceof RegExp||Array.isArray(e))return Q(e,[],{start:!1,end:!1});if(typeof e=="boolean")return e&&/.*/;throw"[Router] only regular expressions, strings, booleans and arrays of regular expressions and strings are accepted as paths."}isPath(e){return typeof e=="string"||e instanceof RegExp||typeof e=="boolean"||Array.isArray(e)}parse(e){let t=e,i={from:/.*/,to:/.*/};if(this.isPath(e))i={from:!0,to:e};else if(this.isPath(t.from)&&this.isPath(t.to))i=Object.assign({},i,t);else throw"[Router] path is neither a string, regular expression, or a { from, to } object.";let{from:n,to:s}=i;return{from:this.parsePath(n),to:this.parsePath(s)}}route(){if(this.manager.has("HistoryManager")){let e=this.manager.get("HistoryManager"),t=M(E((e.length>1?e.previous:e.current).url)),i=M(E());this.routes.forEach((n,s)=>{let a=s.from,l=s.to;if(typeof a=="boolean"&&typeof l=="boolean")throw`[Router] path ({ from: ${a}, to: ${l} }) is not valid, remember paths can only be strings, regular expressions, or a boolean; however, both the from and to paths cannot be both booleans.`;let p=a,o=l;a instanceof RegExp&&a.test(t)&&(p=a.exec(t)),l instanceof RegExp&&l.test(i)&&(o=l.exec(i)),(Array.isArray(o)&&Array.isArray(p)||Array.isArray(o)&&p==!1&&!l.test(t)||Array.isArray(p)&&o==!1&&!a.test(i))&&n({from:p,to:o,path:{from:t,to:i}})})}else console.warn("[Route] HistoryManager is missing.")}initEvents(){this.emitter.on("READY",this.route,this),this.emitter.on("CONTENT_REPLACED",this.route,this)}stopEvents(){this.emitter.off("READY",this.route,this),this.emitter.off("CONTENT_REPLACED",this.route,this)}};return Be;})(); -- knotmirror 0.0.1