@react-motion-router/core
Version:
Declarative routing library for ReactJS ⚛ with animations baked in ⏮
2 lines • 108 kB
JavaScript
/*! For license information please see index.js.LICENSE.txt */
import*as t from"react";var e={837:(t,e,n)=>{var i=n(810),s=Symbol.for("react.element"),o=Symbol.for("react.fragment"),a=Object.prototype.hasOwnProperty,r=i.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,h={key:!0,ref:!0,__self:!0,__source:!0};function l(t,e,n){var i,o={},l=null,u=null;for(i in void 0!==n&&(l=""+n),void 0!==e.key&&(l=""+e.key),void 0!==e.ref&&(u=e.ref),e)a.call(e,i)&&!h.hasOwnProperty(i)&&(o[i]=e[i]);if(t&&t.defaultProps)for(i in e=t.defaultProps)void 0===o[i]&&(o[i]=e[i]);return{$$typeof:s,type:t,key:l,ref:u,props:o,_owner:r.current}}e.Fragment=o,e.jsx=l,e.jsxs=l},322:(t,e,n)=>{t.exports=n(837)},174:(t,e,n)=>{n.d(e,{Nu:()=>l,PV:()=>u,Po:()=>p,QN:()=>r,V_:()=>g,Vo:()=>m,cT:()=>o,dw:()=>y,e1:()=>h,fJ:()=>d,hR:()=>s,kI:()=>v,r2:()=>f,rL:()=>c,uZ:()=>a});var i=n(810);function s(t,e=[],n=!0){let i="";const s={};let o=0;for(let a in t)if(!e.includes(a)){if(o<t.length){const e=t[a];let n=t.getPropertyValue(e);if("visibility"===e)n="visible";i+=`${e}:${n};`}else{if(!n)break;let e=a,i=t[e];if("string"==typeof i&&"cssText"!==e&&!e.includes("webkit")&&!e.includes("grid")){switch(e){case"offset":e="cssOffset";break;case"float":e="cssFloat";break;case"visibility":i="visible"}s[e]=i}}o++}return[i,s]}function o(t,e=[]){const n={};for(const i in t)if(t[i]&&t[i].length&&"function"!=typeof t[i]){if(/^\d+$/.test(i))continue;if("offset"===i)continue;if(e.includes(i))continue;n[i]=t[i]}return n}function a(t,e,n){return t<e?e:n&&t>n?n:t}function r(t,e,n=window.location.origin){if(void 0===t||void 0===e)return t===e?{exact:!0,matchedPathname:e}:null;const i=new URLPattern(t,n),s=new URL(e,n),o=i.exec(s);let a="",r="";for(let t=0;t<i.pathname.length;t++){if(i.pathname[t]!==s.pathname[t]){r=s.pathname.substring(t);break}a+=i.pathname[t]}return o?{exact:t===e,matchedPathname:a,rest:r}:null}function h(t,e,n=window.location.origin){return e.some((e=>r(e,t,n)))}function l(t,e=window){return new Promise((n=>{queueMicrotask((()=>n(e.dispatchEvent(t))))}))}function u(t,e){return"string"==typeof e&&(e=new URL(e)),"string"!=typeof t&&(t=t.pathname),t=t.replace(/^\//,""),e.pathname.endsWith("/")||(e=new URL(e.href+"/")),new URL(t,e)}function c(t){const e=new URLSearchParams(decodeURI(t)).entries(),n={};for(const[t,i]of e){let e="";try{e=JSON.parse(i)}catch(t){console.warn("Non JSON serialisable value was passed as URL route param."),e=i}n[t]=e}return Object.keys(n).length?n:void 0}function d(t,e){return(e||c)(t)||{}}function p(t,e){try{return(e||function(t){return new URLSearchParams(t).toString()})(t)}catch(t){console.error(t),console.warn("Non JSON serialisable value was passed as route param to Anchor.")}return""}function m(t){const e=(0,i.lazy)(t);return e.preload=()=>{const n=t();return n.then((t=>e.preloaded=t.default)).catch(console.error),n},e}function v(t,e){let n=e;return new Promise(((s,o)=>{let a=!1;for(;n;){const h=n.routes;if(i.Children.forEach(h,(e=>{if(a)return;if(!(0,i.isValidElement)(e))return;r(e.props.path,t)&&(a=!0,queueMicrotask((async()=>{var t,n,i,r,h,l,u,c,d,p,m,v;const g=[];"preload"in e.props.component&&g.push(e.props.component.preload()),(null===(n=null===(t=e.props.config)||void 0===t?void 0:t.header)||void 0===n?void 0:n.component)&&"preload"in(null===(r=null===(i=e.props.config)||void 0===i?void 0:i.header)||void 0===r?void 0:r.component)&&g.push(null===(l=null===(h=e.props.config)||void 0===h?void 0:h.header)||void 0===l?void 0:l.component.preload()),(null===(c=null===(u=e.props.config)||void 0===u?void 0:u.footer)||void 0===c?void 0:c.component)&&"preload"in(null===(p=null===(d=e.props.config)||void 0===d?void 0:d.footer)||void 0===p?void 0:p.component)&&g.push(null===(v=null===(m=e.props.config)||void 0===m?void 0:m.footer)||void 0===v?void 0:v.component.preload());try{await Promise.all(g),s(a)}catch(t){o(t)}})))})),a)break;n=e.parentRouterData}a||s(!1)}))}function g(t,e=0){var n;const i=null===(n=null==t?void 0:t.effect)||void 0===n?void 0:n.getTiming().duration;return Number(i)||e}const f={in:{type:"none",duration:0},out:{type:"none",duration:0}},y=2147483647},623:function(t,e,n){var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const s=i(n(813));class o extends s.default{constructor(t){super("doubletap",t)}}e.default=o},813:(t,e)=>{var n;Object.defineProperty(e,"__esModule",{value:!0}),function(t){t[t.tap=0]="tap",t[t.longpress=1]="longpress",t[t.pinchstart=2]="pinchstart",t[t.pinch=3]="pinch",t[t.pinchend=4]="pinchend",t[t.rotatestart=5]="rotatestart",t[t.rotate=6]="rotate",t[t.rotateend=7]="rotateend",t[t.swipestart=8]="swipestart",t[t.swipe=9]="swipe",t[t.swipeend=10]="swipeend",t[t.panstart=11]="panstart",t[t.pan=12]="pan",t[t.panend=13]="panend",t[t.doubletap=14]="doubletap"}(n||(n={})),void 0===window.TouchEvent&&(window.TouchEvent=PointerEvent);class i extends TouchEvent{constructor(t,e){if(super(t,{touches:Array.from(e.touches),targetTouches:Array.from(e.targetTouches),changedTouches:Array.from(e.changedTouches),ctrlKey:e.ctrlKey,shiftKey:e.shiftKey,altKey:e.altKey,metaKey:e.metaKey,bubbles:!0,cancelable:!0}),t.includes("end")||e.type.includes("end"))return this.gestureTarget=e.changedTouches[0].target,this.x=e.changedTouches[0].clientX,void(this.y=e.changedTouches[0].clientY);this.gestureTarget=e.touches[0].target,this.x=e.touches[0].clientX,this.y=e.touches[0].clientY}}e.default=i},646:function(t,e,n){var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const s=i(n(813));class o extends s.default{constructor(t,e){super("longpress",t),this.duration=0,this.duration=e}}e.default=o},577:function(t,e,n){var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.PanEndEvent=e.PanStartEvent=void 0;const s=i(n(813));var o;!function(t){t[t.start=0]="start",t[t.end=1]="end"}(o||(o={}));class a extends s.default{constructor(t,e,n){let i;switch(n){case"start":i="panstart";break;case"end":i="panend";break;default:i="pan"}super(i,t),this.velocity=e.velocity,this.translation={x:e.translation.x,y:e.translation.y,magnitude:e.translation.magnitude,clientX:e.translation.clientX,clientY:e.translation.clientY,clientMagnitude:e.translation.clientMagnitude}}}e.default=class extends a{constructor(t,e){super(t,e)}};e.PanStartEvent=class extends a{constructor(t,e){super(t,e,"start")}};e.PanEndEvent=class extends a{constructor(t,e){super(t,e,"end")}}},630:function(t,e,n){var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.PinchEndEvent=e.PinchStartEvent=void 0;const s=i(n(813));var o;!function(t){t[t.start=0]="start",t[t.end=1]="end"}(o||(o={}));class a extends s.default{constructor(t,e,n){let i;switch(n){case"start":i="pinchstart";break;case"end":i="pinchend";break;default:i="pinch"}super(i,t),Object.defineProperty(this,"scale",{value:e.scale,writable:!1})}}e.default=class extends a{constructor(t,e){super(t,e)}};e.PinchStartEvent=class extends a{constructor(t,e){super(t,e,"start")}};e.PinchEndEvent=class extends a{constructor(t,e){super(t,e,"end")}}},859:function(t,e,n){var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.RotateEndEvent=e.RotateStartEvent=void 0;const s=i(n(813));var o;!function(t){t[t.start=0]="start",t[t.end=1]="end"}(o||(o={}));class a extends s.default{constructor(t,e,n){let i;switch(n){case"start":i="rotatestart";break;case"end":i="rotateend";break;default:i="rotate"}super(i,t),this.anchor={x:e.anchor.x,y:e.anchor.y,clientX:e.anchor.clientX,clientY:e.anchor.clientY},Object.defineProperty(this,"rotation",{value:e.rotation,writable:!1}),this.rotationDeg=e.rotationDeg}}e.default=class extends a{constructor(t,e){super(t,e)}};e.RotateStartEvent=class extends a{constructor(t,e){super(t,e,"start")}};e.RotateEndEvent=class extends a{constructor(t,e){super(t,e,"end")}}},224:function(t,e,n){var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.SwipeEndEvent=e.SwipeStartEvent=void 0;const s=i(n(813));var o;!function(t){t[t.start=0]="start",t[t.end=1]="end"}(o||(o={}));class a extends s.default{constructor(t,e,n){let i;switch(n){case"start":i="swipestart";break;case"end":i="swipeend";break;default:i="swipe"}super(i,t),this.velocity=e.velocity,this.direction=e.direction}}e.default=class extends a{constructor(t,e){super(t,e)}};e.SwipeStartEvent=class extends a{constructor(t,e){super(t,e,"start")}};e.SwipeEndEvent=class extends a{constructor(t,e){super(t,e,"end")}}},884:function(t,e,n){var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const s=i(n(813));class o extends s.default{constructor(t){super("tap",t)}}e.default=o},878:function(t,e,n){var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var s=Object.getOwnPropertyDescriptor(e,n);s&&!("get"in s?!e.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,s)}:function(t,e,n,i){void 0===i&&(i=n),t[i]=e[n]}),s=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),o=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&i(e,t,n);return s(e,t),e},a=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.RotateEndEvent=e.RotateEvent=e.RotateStartEvent=e.PinchEndEvent=e.PinchEvent=e.PinchStartEvent=e.PanEndEvent=e.PanEvent=e.PanStartEvent=e.SwipeEndEvent=e.SwipeEvent=e.SwipeStartEvent=e.DoubleTapEvent=e.LongPressEvent=e.GestureEvent=e.TapEvent=void 0;const r=a(n(813));e.GestureEvent=r.default;const h=a(n(646));e.LongPressEvent=h.default;const l=a(n(884));e.TapEvent=l.default;const u=a(n(623));e.DoubleTapEvent=u.default;const c=o(n(224));e.SwipeEvent=c.default,Object.defineProperty(e,"SwipeEndEvent",{enumerable:!0,get:function(){return c.SwipeEndEvent}}),Object.defineProperty(e,"SwipeStartEvent",{enumerable:!0,get:function(){return c.SwipeStartEvent}});const d=o(n(577));e.PanEvent=d.default,Object.defineProperty(e,"PanEndEvent",{enumerable:!0,get:function(){return d.PanEndEvent}}),Object.defineProperty(e,"PanStartEvent",{enumerable:!0,get:function(){return d.PanStartEvent}});const p=o(n(630));e.PinchEvent=p.default,Object.defineProperty(e,"PinchEndEvent",{enumerable:!0,get:function(){return p.PinchEndEvent}}),Object.defineProperty(e,"PinchStartEvent",{enumerable:!0,get:function(){return p.PinchStartEvent}});const m=o(n(859));e.RotateEvent=m.default,Object.defineProperty(e,"RotateEndEvent",{enumerable:!0,get:function(){return m.RotateEndEvent}}),Object.defineProperty(e,"RotateStartEvent",{enumerable:!0,get:function(){return m.RotateStartEvent}});const v=n(47);var g;!function(t){t[t.right=0]="right",t[t.up=1]="up",t[t.left=2]="left",t[t.down=3]="down"}(g||(g={}));class f{constructor(){this.touchStart=new TouchEvent("touchstart")||{},this.touchMove=new TouchEvent("touchmove")||{},this.touchEnd=new TouchEvent("touchend")||{},this.touchCancel=new TouchEvent("touchcancel")||{},this.velocity=0,this.dxDy=new v.Vec2(0,0),this.scale=1,this.rotation=0,this.rotationDeg=0,this.anchor=new v.Vec2(0,0),this.octant=0,this.isPanning=!1,this.isPinching=!1,this.isSwiping=!1,this.isRotating=!1,this.touchStartTime=0,this.touchEndTime=0,this.lastTouchTime=0,this.taps=0,this.scaleBase=0,this.touchMoved=!1,this.touchDown=!1,this.shouldFire=!1,this.pointers=0,this.isLongPress=!1,this.longPressTimeout=0,this.touchStartListener=this.onTouchStart.bind(this),this.touchMoveListener=this.onTouchMove.bind(this),this.touchEndListener=this.onTouchEnd.bind(this),this.touchCancelListener=this.onTouchCancel.bind(this),this.currentTarget=window,this.config={longPressDuration:500,tapDelay:500,minPointers:1,numberOfTaps:0},f.listening||(TouchEvent&&window.addEventListener("touchstart",this.touchStartListener,!0),f.listening=!0)}bind(t){this.unbind(this.currentTarget),t.addEventListener("touchmove",this.touchMoveListener,!0),t.addEventListener("touchend",this.touchEndListener,!0),t.addEventListener("touchcancel",this.touchCancelListener,!0),this.currentTarget=t}unbind(t){t.removeEventListener("touchmove",this.touchMoveListener),t.removeEventListener("touchend",this.touchEndListener),t.removeEventListener("touchcancel",this.touchCancelListener)}clean(){this.touchMoved=!1,this.touchStartTime=0,this.touchDown=!1,this.scaleBase=0,this.longPressTimeout&&!this.isLongPress&&(clearTimeout(this.longPressTimeout),this.longPressTimeout=0),this.isLongPress=!1}onPointerLeave(t){if(!t.touches.length){if(this.isSwiping){const e=new c.SwipeEndEvent(t,{velocity:this.velocity,direction:g[(0,v.closest)(this.octant,[0,1,2,3])]});this.dispatchEvent(e),this.isSwiping=!1}if(this.isPanning){const e=new d.PanEndEvent(t,{translation:this.dxDy,velocity:this.velocity});this.dispatchEvent(e),this.isPanning=!1}}if(1===t.touches.length){if(this.scaleBase=0,this.isPinching){const e=new p.PinchEndEvent(t,{scale:this.scale});this.dispatchEvent(e),this.isPinching=!1}if(this.isRotating){const e=new m.RotateEndEvent(t,{rotation:this.rotation,rotationDeg:this.rotationDeg,anchor:this.anchor});this.dispatchEvent(e),this.isRotating=!1}}}dispatchEvent(t){queueMicrotask((()=>{this.currentTarget.dispatchEvent(t)}))}onTouchStart(t){this.currentTarget!==t.touches[0].target&&(this.clean(),this.unbind(this.currentTarget),this.pointers=this.touchEnd.touches.length,this.taps=0),this.touchStart=t;const e=parseInt(t.touches[0].target.dataset.minpointers||"0")||this.config.minPointers;if(this.touchStart.touches.length<e)return void(this.shouldFire=!1);this.shouldFire=!0,this.touchStartTime=t.timeStamp,this.touchDown=!0,this.pointers||this.bind(t.touches[0].target),this.pointers=this.touchStart.touches.length;const n=parseFloat(this.currentTarget.dataset.longpressduration||"0")||this.config.longPressDuration;if(this.longPressTimeout||(this.longPressTimeout=setTimeout((()=>{if(!this.touchMoved&&this.touchDown){const t=Date.now()-this.touchStartTime,e=new h.default(this.touchStart,t);this.dispatchEvent(e),this.isLongPress=!0,this.longPressTimeout=0}}),n)),this.touchStart.touches.length>1){const t=new v.Vec2(this.touchStart.touches[0].clientX,this.touchStart.touches[0].clientY),e=new v.Vec2(this.touchStart.touches[1].clientX,this.touchStart.touches[1].clientY);this.scaleBase=t.substract(e).magnitude}else this.scaleBase=0}onTouchMove(t){if(!this.shouldFire)return;if(this.touchMoved=!0,this.touchMove=t,t.touches.length>1&&this.touchStart.touches.length>1&&(t.touches[1].clientX!==this.touchStart.touches[1].clientX||t.touches[1].clientY!==this.touchStart.touches[1].clientY)){const e=new v.Vec2(this.touchMove.touches[0].clientX,this.touchMove.touches[0].clientY),n=new v.Vec2(this.touchMove.touches[1].clientX,this.touchMove.touches[1].clientY),i=new v.Vec2(this.touchStart.touches[0].clientX,this.touchStart.touches[0].clientY),s=e.substract(n);if(this.scaleBase&&Math.abs(this.scaleBase-s.magnitude)>10){const e=s.magnitude/this.scaleBase;if(this.scale=e,this.isPinching){const n=new p.default(t,{scale:e});this.dispatchEvent(n)}else{const n=new p.PinchStartEvent(t,{scale:e});this.dispatchEvent(n),this.isPinching=!0}}this.anchor=e;let o=Math.atan2(i.clientY-n.clientY,i.clientX-n.clientX);if(o<0?o+=1.5708:o-=1.5708,this.rotation=o,this.rotationDeg=180*o/Math.PI,this.anchor=this.anchor,this.isRotating){const e=new m.default(t,{anchor:this.anchor,rotation:this.rotation,rotationDeg:this.rotationDeg});this.dispatchEvent(e)}else{const e=new m.RotateStartEvent(t,{anchor:this.anchor,rotation:this.rotation,rotationDeg:this.rotationDeg});this.dispatchEvent(e),this.isRotating=!0}}const e=new v.Vec2(this.touchStart.touches[0].clientX,this.touchStart.touches[0].clientY),n=new v.Vec2(this.touchMove.touches[0].clientX,this.touchMove.touches[0].clientY).substract(e),i=n.magnitude,s={x:n.x/i,y:n.y/i},o=Math.atan2(s.y,s.x);this.octant=Math.round(4*o/(2*Math.PI)+4)%4;const a=(t.timeStamp-this.touchStart.timeStamp)/1e3,r=n.magnitude/a;if(this.isSwiping){const e=new c.default(t,{direction:g[(0,v.closest)(this.octant,[0,1,2,3])],velocity:r});this.dispatchEvent(e)}else{const e=new c.SwipeStartEvent(t,{direction:g[(0,v.closest)(this.octant,[0,1,2,3])],velocity:r});this.dispatchEvent(e),this.isSwiping=!0}if(this.dxDy=n,this.velocity=r,this.isPanning){const e=new d.default(t,{translation:n,velocity:r});this.dispatchEvent(e)}else{const e=new d.PanStartEvent(t,{translation:n,velocity:r});this.dispatchEvent(e),this.isPanning=!0}}onTouchEnd(t){const e=parseInt(this.currentTarget.dataset.numberoftaps||"0")||this.config.numberOfTaps;if(this.taps++,this.shouldFire=Boolean(this.taps>e),this.shouldFire){this.touchEnd=t,this.touchEndTime=t.timeStamp;const n=parseFloat(this.currentTarget.dataset.tapdelay||"0")||this.config.tapDelay;if(!this.touchMoved&&!this.isLongPress)if(1===this.taps||this.touchEndTime-this.lastTouchTime<n){if(this.taps%2===e){const e=new u.default(t);this.dispatchEvent(e),this.taps=0}const n=new l.default(t);this.dispatchEvent(n)}else this.taps=0}this.pointers=this.touchEnd.touches.length,this.lastTouchTime=this.touchEndTime,this.onPointerLeave(t),this.unbind(this.currentTarget),this.clean()}onTouchCancel(t){this.shouldFire&&(this.touchCancel=t,this.unbind(this.currentTarget),this.clean())}}function y(t){const e=t.type;t.composedPath().forEach((n=>{if(n instanceof HTMLElement){const i=n[_[e]];if("function"!=typeof i)return;i.apply(n,[t])}}))}f.listening=!1,e.default=f,window.GLOBAL_EVENT_DISPATCHER||(window.addEventListener("tap",y,{passive:!0}),window.addEventListener("longpress",y,{passive:!0}),window.addEventListener("doubletap",y,{passive:!0}),window.addEventListener("swipestart",y,{passive:!0}),window.addEventListener("swipe",y,{passive:!0}),window.addEventListener("swipeend",y,{passive:!0}),window.addEventListener("panstart",y,{passive:!0}),window.addEventListener("pan",y,{passive:!0}),window.addEventListener("panend",y,{passive:!0}),window.addEventListener("pinchstart",y,{passive:!0}),window.addEventListener("pinch",y,{passive:!0}),window.addEventListener("pinchend",y,{passive:!0}),window.addEventListener("rotatestart",y,{passive:!0}),window.addEventListener("rotate",y,{passive:!0}),window.addEventListener("rotateend",y,{passive:!0}));const _={tap:"ontap",doubletap:"ondoubletap",longpress:"onlongpress",swipestart:"onswipestart",swipe:"onswipe",swipeend:"onswipeend",panstart:"onpanstart",pan:"onpan",panend:"onpanend",pinchstart:"onpinchstart",pinch:"onpinch",pinchend:"onpinchend",rotatestart:"onrotatestart",rotate:"onrotate",rotateend:"onrotateend"};TouchEvent&&(window.gestureProvider=new f),window.GLOBAL_EVENT_DISPATCHER||(window.GLOBAL_EVENT_DISPATCHER=y)},47:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.closest=e.Vec2=e.assert=void 0,e.assert=function(t,e){if(!t)throw new Error(e)};e.Vec2=class{constructor(t,e){this._x=0,this._y=0,this._clientX=0,this._clientY=0,this._clientX=t,this._clientY=e,this._x=this.translateX(t),this._y=this.translateY(e)}translateY(t){return-(t-window.innerHeight/2)}translateX(t){return t-window.innerWidth/2}get x(){return this._x}get y(){return this._y}get clientX(){return this._clientX}get clientY(){return this._clientY}set x(t){this._clientX=t,this._x=this.translateX(t)}set y(t){this._clientY=t,this._y=this.translateY(t)}add(t){return this._x+=t.x,this._y+=t.y,this._clientX+=t.clientX,this._clientY+=t.clientY,this}substract(t){return this._x-=t.x,this._y-=t.y,this._clientX-=t.clientX,this._clientY-=t.clientY,this}dot(t){return this._x*t.x+this._y*t.y}get magnitude(){return Math.sqrt(Math.pow(this._x,2)+Math.pow(this._y,2))}get clientMagnitude(){return Math.sqrt(Math.pow(this._clientX,2)+Math.pow(this._clientY,2))}},e.closest=function(t,e){return e.reduce(((e,n)=>{let i=Math.abs(e-t),s=Math.abs(n-t);return i===s?e>n?e:n:s<i?n:e}))}},810:e=>{e.exports=t}},n={};function i(t){var s=n[t];if(void 0!==s)return s.exports;var o=n[t]={exports:{}};return e[t].call(o.exports,o,o.exports,i),o.exports}i.d=(t,e)=>{for(var n in e)i.o(e,n)&&!i.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var s={};(()=>{i.d(s,{ee:()=>z,r2:()=>h.r2,rN:()=>B,PM:()=>j,dw:()=>h.dw,y_:()=>d,DC:()=>a,GW:()=>g,sV:()=>e,RG:()=>C,GI:()=>W,rJ:()=>N,uZ:()=>h.uZ,PV:()=>h.PV,rL:()=>h.rL,Nu:()=>h.Nu,V_:()=>h.V_,hR:()=>h.hR,cT:()=>h.cT,e1:()=>h.e1,Ef:()=>L,Vo:()=>h.Vo,QN:()=>h.QN,kI:()=>h.kI,Po:()=>h.Po,fJ:()=>h.fJ,nc:()=>U,HJ:()=>M,JZ:()=>$,yj:()=>F});var t=i(810);class e{constructor(t,e){this._parentRouterData=null,this._childRouterData=null,this._dispatchEvent=null,this._addEventListener=null,this._removeEventListener=null,this._currentPath="",this._routesData=new Map,this._backNavigating=!1,this._gestureNavigating=!1,this._mountedScreen=null,this._animation=h.r2,this._ghostLayer=null,this.routerInstance=t,e&&(this.navigation=e)}destructor(){this.parentRouterData&&(this.parentRouterData.childRouterData=null)}prefetchRoute(t){return(0,h.kI)(t,this)}set parentRouterData(t){this._parentRouterData=t,this._parentRouterData&&(this._parentRouterData.childRouterData=this)}set childRouterData(t){var e;const n=null===(e=this._childRouterData)||void 0===e?void 0:e.deref();if(void 0!==n&&t&&t.routerId!==n.routerId)throw new Error("It looks like you have two navigators at the same level. Try simplifying your navigation structure by using a nested router instead.");this._childRouterData=t?new WeakRef(t):null}set dispatchEvent(t){this._dispatchEvent=t}set addEventListener(t){this._addEventListener=t}set removeEventListener(t){this._removeEventListener=t}set currentPath(t){this._currentPath=t}set routesData(t){this._routesData=t}set navigation(t){this._navigation=t}set animation(t){this._animation=t}set ghostLayer(t){this._ghostLayer=t}set backNavigating(t){this._backNavigating=t}set gestureNavigating(t){this._gestureNavigating=t}set paramsSerializer(t){this._paramsSerializer=t}set paramsDeserializer(t){this._paramsDeserializer=t}set mountedScreen(t){this._mountedScreen=t}get mountedScreen(){return this._mountedScreen}get routerId(){return this.routerInstance.id}get routes(){return this.routerInstance.props.children}get parentRouterData(){return this._parentRouterData}get childRouterData(){var t,e;return null!==(e=null===(t=this._childRouterData)||void 0===t?void 0:t.deref())&&void 0!==e?e:null}get dispatchEvent(){return this._dispatchEvent}get addEventListener(){return this._addEventListener}get removeEventListener(){return this._removeEventListener}get currentPath(){return this._currentPath}get routesData(){return this._routesData}get scrollRestorationData(){return e._scrollRestorationData}get navigation(){return this._navigation}get animation(){return this._animation}get ghostLayer(){return this._ghostLayer}get backNavigating(){return this._backNavigating}get gestureNavigating(){return this._gestureNavigating}get paramsSerializer(){return this._paramsSerializer}get paramsDeserializer(){return this._paramsDeserializer}}e._scrollRestorationData=new class{constructor(){this._map=new Map}set(t,e={x:0,y:0}){this._map.set(t,e)}get(t){return this._map.get(t)}};const n=(0,t.createContext)(null);class o{constructor(){this._map=new Map,this.mutationObserver=new MutationObserver(this.observeMutations.bind(this));const{head:t}=document;this.mutationObserver.observe(t,{childList:!0}),Array.from(t.querySelectorAll("meta")).forEach((t=>{this.mutationObserver.observe(t,{attributes:!0})})),Array.from(t.querySelectorAll("meta")).forEach(this.metaDataFromNode.bind(this))}get(t){const e=this.getMetaKey(t),n=this._map.get(e);if(!n)return;let i;return i=n.includes(",")&&n.includes("=")?n.split(/,\s*/).map((t=>t.split("="))):n,i}set(t,e){const n=this.getMetaKey(t),i=this.getMetaContent(e);this._map.set(n,i),this.updateMetaElement(n,i)}has(t){const e=this.getMetaKey(t);return this._map.has(e)}delete(t){var e;const n=this.getMetaKey(t);this._map.delete(n),null===(e=document.head.querySelector(`meta[${n}]`))||void 0===e||e.remove()}clear(){document.head.querySelectorAll("meta").forEach((t=>t.remove()))}entries(){return this._map.entries()}[Symbol.iterator](){return this.entries()}get size(){return this._map.size}observeMutations(t){for(const e of t){if("attributes"===e.type){const t=e.target;this.metaDataFromNode(t)}if("childList"!==e.type)return;e.removedNodes.forEach((t=>{if("META"===t.nodeName){const[e]=Array.from(t.attributes).filter((t=>"content"!==t.nodeName)),n=[e.nodeName,e.value].join("=");this._map.has(n)&&this._map.delete(n)}})),e.addedNodes.forEach((t=>{"META"===t.nodeName&&this.metaDataFromNode(t)}))}}metaDataFromNode(t){const[e]=Array.from(t.attributes).filter((t=>"content"!==t.nodeName)),[n]=Array.from(t.attributes).filter((t=>"content"===t.nodeName)),i=[e.nodeName,e.value].join("=");this._map.set(i,null==n?void 0:n.value)}getMetaKey(t){let e;return e="string"==typeof t?`name=${t}`:t.join("="),e}getMetaContent(t){if(!t)return;let e;return e="string"==typeof t?t:t.map((t=>t.join("="))).join(", "),e}updateMetaElement(t,e){const n=document.querySelector(`meta[${t}]`)||document.createElement("meta"),i=t.split("=");n.setAttribute(...i),e?n.setAttribute("content",e):n.removeAttribute("content"),n.parentElement||document.head.appendChild(n)}}class a{constructor(t,e,n=!1,i=null){var s;this._metaData=new o,this._currentParams={},this.popStateListener=t=>{var e;this._routerId,this.history.state.get("routerId");const n=null===(e=a.rootNavigatorRef)||void 0===e?void 0:e.deref(),i=(null==n?void 0:n.routerId)===this.routerId;(null===this.history.state.get("routerId")&&i||this.history.state.get("routerId")===this._routerId)&&this.onPopState(t)},this.routerData=e,this._disableBrowserRouting=n,this._routerId=t;const r=null===(s=a.rootNavigatorRef)||void 0===s?void 0:s.deref();r&&r.isInDocument||(a.rootNavigatorRef=new WeakRef(this)),window.addEventListener("popstate",this.popStateListener)}destructor(){var t;const e=null===(t=a.rootNavigatorRef)||void 0===t?void 0:t.deref();(null==e?void 0:e.routerId)===this.routerId&&(a.rootNavigatorRef=null),window.removeEventListener("popstate",this.popStateListener)}addEventListener(t,e,n){var i,s;return null===(s=(i=this.routerData).addEventListener)||void 0===s||s.call(i,t,e,n),()=>{var n,i;return null===(i=(n=this.routerData).removeEventListener)||void 0===i?void 0:i.call(n,t,e)}}removeEventListener(t,e,n){var i,s;return null===(s=(i=this.routerData).removeEventListener)||void 0===s?void 0:s.call(i,t,e,n)}get disableBrowserRouting(){return this._disableBrowserRouting}get routerId(){return this._routerId}canGoBack(){return this.history.canGoBack()}getNavigatorById(t,e){var n;const i=null!=e?e:null===(n=a.rootNavigatorRef)||void 0===n?void 0:n.deref();return i.routerId===t?i:i.routerData.childRouterData?void this.getNavigatorById(t,i.routerData.childRouterData.navigation):null}prefetchRoute(t){return this.routerData.prefetchRoute(t)}get dispatchEvent(){return this.routerData.dispatchEvent}get paramsDeserializer(){return this.routerData.paramsDeserializer}get paramsSerializer(){return this.routerData.paramsSerializer}get history(){return this._history}get metaData(){return this._metaData}get isInDocument(){return Boolean(document.getElementById(`${this.routerId}`))}}a.rootNavigatorRef=null;var r=i(322),h=i(174);class l{constructor(){this._play=!0,this._isPlaying=!1,this._isStarted=!1,this._currentScreen=null,this._nextScreen=null,this._progressUpdateID=0,this._pseudoElementInAnimation=null,this._pseudoElementOutAnimation=null,this._inAnimation=null,this._outAnimation=null,this._playbackRate=1,this._gestureNavigating=!1,this._backNavigating=!1,this._onEnd=null,this._onProgress=null,this._shouldAnimate=!0,this._dispatchEvent=null,this._addEventListener=null}updateProgress(){var t,e,n,i;if(this._gestureNavigating&&!this._play)return void window.cancelAnimationFrame(this._progressUpdateID);(()=>{this._onProgress&&this._onProgress(this.progress)})(),this._progressUpdateID=window.requestAnimationFrame(this.updateProgress.bind(this));const s=()=>{window.cancelAnimationFrame(this._progressUpdateID);const t=this._gestureNavigating?0:100;this.progress!==t&&this._onProgress&&this._onProgress(t)};Promise.all([null===(t=this._inAnimation)||void 0===t?void 0:t.finished,null===(e=this._outAnimation)||void 0===e?void 0:e.finished,null===(n=this._pseudoElementInAnimation)||void 0===n?void 0:n.finished,null===(i=this._pseudoElementOutAnimation)||void 0===i?void 0:i.finished]).then(s).catch(s)}reset(){this._onEnd=null,this._playbackRate=1,this._play=!0,this._gestureNavigating=!1}finish(){var t,e,n,i;null===(t=this._inAnimation)||void 0===t||t.finish(),null===(e=this._outAnimation)||void 0===e||e.finish(),null===(n=this._pseudoElementInAnimation)||void 0===n||n.finish(),null===(i=this._pseudoElementOutAnimation)||void 0===i||i.finish()}cancel(){var t,e,n,i,s;null===(t=this._inAnimation)||void 0===t||t.cancel(),null===(e=this._outAnimation)||void 0===e||e.cancel(),null===(n=this._pseudoElementInAnimation)||void 0===n||n.cancel(),null===(i=this._pseudoElementOutAnimation)||void 0===i||i.cancel(),this.reset();const o=new CustomEvent("page-animation-cancel",{bubbles:!0});null===(s=this.dispatchEvent)||void 0===s||s.call(this,o)}cleanUpAnimation(t){t&&(t.commitStyles(),t.cancel())}async animate(){var t,e,n,i,s,o,a,r,l,u;if(this._isPlaying&&(this.cancel(),this._onEnd&&this._onEnd(),this.reset()),this._currentScreen&&this._nextScreen&&this._shouldAnimate){if(this._gestureNavigating&&await this._currentScreen.mounted(!0),this._backNavigating?(this._currentScreen.zIndex=1,this._nextScreen.zIndex=0):(this._currentScreen.zIndex=0,this._nextScreen.zIndex=1),this._onProgress&&this._onProgress(this.progress),this._onExit&&this._shouldAnimate&&this._onExit(),await this._nextScreen.mounted(!0),this._outAnimation=this._currentScreen.animation,this._pseudoElementOutAnimation=this._currentScreen.pseudoElementAnimation,this._inAnimation=this._nextScreen.animation,this._pseudoElementInAnimation=this._nextScreen.pseudoElementAnimation,this._isPlaying=!0,this._inAnimation&&this._outAnimation){if(!this._shouldAnimate)return this.finish(),this._isPlaying=!1,void(this._shouldAnimate=!0);if(this._inAnimation.playbackRate=this._playbackRate,this._outAnimation.playbackRate=this._playbackRate,this._pseudoElementInAnimation&&(this._pseudoElementInAnimation.playbackRate=this._playbackRate),this._pseudoElementOutAnimation&&(this._pseudoElementOutAnimation.playbackRate=this._playbackRate),this._gestureNavigating){const t=(0,h.V_)(this._inAnimation,this.duration),e=(0,h.V_)(this._outAnimation,this.duration);if(this._inAnimation.currentTime=t,this._outAnimation.currentTime=e,this._pseudoElementInAnimation){const t=(0,h.V_)(this._pseudoElementInAnimation,this.duration);this._pseudoElementInAnimation.currentTime=t}if(this._pseudoElementOutAnimation){const t=(0,h.V_)(this._pseudoElementOutAnimation,this.duration);this._pseudoElementOutAnimation.currentTime=t}}await Promise.all([this._inAnimation.ready,this._outAnimation.ready,null===(t=this._pseudoElementInAnimation)||void 0===t?void 0:t.ready,null===(e=this._pseudoElementOutAnimation)||void 0===e?void 0:e.ready]),this._play?(this._outAnimation.play(),this._inAnimation.play(),null===(s=this._pseudoElementInAnimation)||void 0===s||s.play(),null===(o=this._pseudoElementOutAnimation)||void 0===o||o.play()):(this._inAnimation.pause(),this._outAnimation.pause(),null===(n=this._pseudoElementInAnimation)||void 0===n||n.pause(),null===(i=this._pseudoElementOutAnimation)||void 0===i||i.pause(),this._isPlaying=!1),this._isStarted=!0;const c=new CustomEvent("page-animation-start",{bubbles:!0});null===(a=this.dispatchEvent)||void 0===a||a.call(this,c),this.updateProgress(),await Promise.all([this._outAnimation.finished,this._inAnimation.finished,null===(r=this._pseudoElementInAnimation)||void 0===r?void 0:r.finished,null===(l=this._pseudoElementOutAnimation)||void 0===l?void 0:l.finished]),this.cleanUpAnimation(this._inAnimation),this.cleanUpAnimation(this._outAnimation),this._inAnimation=null,this._outAnimation=null,this._isPlaying=!1;const d=new CustomEvent("page-animation-end",{bubbles:!0});null===(u=this.dispatchEvent)||void 0===u||u.call(this,d),this._gestureNavigating&&.5!==this._playbackRate?(this._nextScreen.zIndex=0,this._currentScreen.zIndex=1,await this._nextScreen.mounted(!1)):(this._currentScreen.zIndex=0,this._nextScreen.zIndex=1,this._currentScreen.mounted(!1)),this._onEnd&&this._onEnd(),this._isStarted=!1}}else this._shouldAnimate=!0}set onProgress(t){this._onProgress=t}set onEnd(t){this._onEnd=t}set shouldAnimate(t){this._shouldAnimate=t}set playbackRate(t){this._playbackRate=t,this._inAnimation&&this._outAnimation&&(this._inAnimation.playbackRate=this._playbackRate,this._outAnimation.playbackRate=this._playbackRate),this._pseudoElementInAnimation&&(this._pseudoElementInAnimation.playbackRate=this._playbackRate),this._pseudoElementOutAnimation&&(this._pseudoElementOutAnimation.playbackRate=this._playbackRate)}set gestureNavigating(t){this._gestureNavigating=t}set backNavigating(t){this._backNavigating=t}set play(t){var e,n,i,s,o,a,r,h;this._play!==t&&(this._play=t,this._play&&this._gestureNavigating&&this.updateProgress(),t?(null===(e=this._inAnimation)||void 0===e||e.play(),null===(n=this._outAnimation)||void 0===n||n.play(),null===(i=this._pseudoElementInAnimation)||void 0===i||i.play(),null===(s=this._pseudoElementOutAnimation)||void 0===s||s.play()):(null===(o=this._inAnimation)||void 0===o||o.pause(),null===(a=this._outAnimation)||void 0===a||a.pause(),null===(r=this._pseudoElementInAnimation)||void 0===r||r.pause(),null===(h=this._pseudoElementOutAnimation)||void 0===h||h.pause()))}set progress(t){this._onProgress&&this._onProgress(t);{let e=(0,h.V_)(this._inAnimation,this.duration);const n=t/100*Number(e);let i=(0,h.V_)(this._outAnimation,this.duration);const s=t/100*Number(i);this._inAnimation&&this._outAnimation&&(this._inAnimation.currentTime=n,this._outAnimation.currentTime=s)}{let e=(0,h.V_)(this._pseudoElementInAnimation,this.duration);const n=t/100*Number(e);let i=(0,h.V_)(this._pseudoElementOutAnimation,this.duration);const s=t/100*Number(i);this._pseudoElementInAnimation&&(this._pseudoElementInAnimation.currentTime=n),this._pseudoElementOutAnimation&&(this._pseudoElementOutAnimation.currentTime=s)}}set currentScreen(t){this._currentScreen=t}set nextScreen(t){this._nextScreen=t,this._currentScreen||(t.mounted(!0,!1),this._nextScreen=null)}set onExit(t){this._onExit=t}set addEventListener(t){this._addEventListener=t}set dispatchEvent(t){this._dispatchEvent=t}get addEventListener(){return this._addEventListener}get dispatchEvent(){return this._dispatchEvent}get duration(){var t,e,n,i;const s=null===(t=this._currentScreen)||void 0===t?void 0:t.duration,o=null===(e=this._nextScreen)||void 0===e?void 0:e.duration,a=null===(n=this._currentScreen)||void 0===n?void 0:n.pseudoElementDuration,r=null===(i=this._nextScreen)||void 0===i?void 0:i.pseudoElementDuration;return Math.max(Number(s),Number(o),Number(a),Number(r))||0}get progress(){var t,e,n,i,s,o,a,r,h,l,u,c,d,p,m,v;const g=null===(e=null===(t=this._outAnimation)||void 0===t?void 0:t.effect)||void 0===e?void 0:e.getComputedTiming().duration,f=null===(i=null===(n=this._inAnimation)||void 0===n?void 0:n.effect)||void 0===i?void 0:i.getComputedTiming().duration,y=null===(o=null===(s=this._pseudoElementOutAnimation)||void 0===s?void 0:s.effect)||void 0===o?void 0:o.getComputedTiming().duration,_=null===(r=null===(a=this._pseudoElementInAnimation)||void 0===a?void 0:a.effect)||void 0===r?void 0:r.getComputedTiming().duration,E=[Number(g),Number(f),Number(_),Number(y)],w=Math.max(...E.filter((t=>!isNaN(t))));let b;return w===Number(g)?b=null===(l=null===(h=this._outAnimation)||void 0===h?void 0:h.effect)||void 0===l?void 0:l.getComputedTiming().progress:w===Number(f)?b=null===(c=null===(u=this._inAnimation)||void 0===u?void 0:u.effect)||void 0===c?void 0:c.getComputedTiming().progress:w===Number(_)?b=null===(p=null===(d=this._pseudoElementInAnimation)||void 0===d?void 0:d.effect)||void 0===p?void 0:p.getComputedTiming().progress:w===Number(y)&&(b=null===(v=null===(m=this._pseudoElementOutAnimation)||void 0===m?void 0:m.effect)||void 0===v?void 0:v.getComputedTiming().progress),100*(Number(b)||0)}get gestureNavigating(){return this._gestureNavigating}get backNavigating(){return this._backNavigating}get isPlaying(){return this._isPlaying}get ready(){return new Promise((async(t,e)=>{var n,i,s,o;try{await Promise.all([null===(n=this._outAnimation)||void 0===n?void 0:n.ready,null===(i=this._inAnimation)||void 0===i?void 0:i.ready,null===(s=this._pseudoElementInAnimation)||void 0===s?void 0:s.ready,null===(o=this._pseudoElementOutAnimation)||void 0===o?void 0:o.ready]),t()}catch(t){e(t)}}))}get finished(){return new Promise((async(t,e)=>{var n,i,s,o;try{await this.started,await Promise.all([null===(n=this._outAnimation)||void 0===n?void 0:n.finished,null===(i=this._inAnimation)||void 0===i?void 0:i.finished,null===(s=this._pseudoElementInAnimation)||void 0===s?void 0:s.finished,null===(o=this._pseudoElementOutAnimation)||void 0===o?void 0:o.finished]),t()}catch(t){e(t)}}))}get started(){return this._isStarted?Promise.resolve():new Promise((async t=>{var e;null===(e=this.addEventListener)||void 0===e||e.call(this,"page-animation-start",(()=>{t()}),{once:!0})}))}}const u=(0,t.createContext)(new l);var c=function(t,e){var n={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(n[i]=t[i]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var s=0;for(i=Object.getOwnPropertySymbols(t);s<i.length;s++)e.indexOf(i[s])<0&&Object.prototype.propertyIsEnumerable.call(t,i[s])&&(n[i[s]]=t[i[s]])}return n};const d=(0,t.createContext)(0);function p(e,n,i,s){const{paths:o}=n;let a,r,l,u,c,d=!1,p=!1,m=null;n.paths.length&&(!(0,h.e1)(s,o)&&n.paths.includes(void 0)&&(s=void 0),null!==i&&!(0,h.e1)(i,o)&&n.paths.includes(void 0)&&(i=void 0));const v=[];let g;if(t.Children.forEach(n.children,(o=>{var a,r,l;if(null===i)return;if(!(0,t.isValidElement)(o))return;let u;if((0,h.QN)(o.props.resolvedPathname,s)&&(e.backNavigating||n.gestureNavigating)&&(null===(a=o.props.config)||void 0===a?void 0:a.keepAlive)&&(g=o.key||void 0),e.children===n.children?(null===(r=o.props.config)||void 0===r?void 0:r.keepAlive)&&(u=(0,h.QN)(o.props.path,i)):u=(0,h.QN)(o.props.resolvedPathname,i),u&&!p){let e={out:!0,in:!1};n.gestureNavigating&&(e={in:!0,out:!1}),p=!0,v.push((0,t.cloneElement)(o,Object.assign(Object.assign({},e),{resolvedPathname:u.matchedPathname,key:null!==(l=o.key)&&void 0!==l?l:Math.random()})))}})),t.Children.forEach(e.children,(e=>{if(!(0,t.isValidElement)(e))return;n.paths.length||o.push(e.props.path);const i=(0,h.QN)(e.props.path,s);if(i&&!d){d=!0;const{config:s}=e.props;a=null==s?void 0:s.swipeDirection,r=null==s?void 0:s.swipeAreaWidth,u=null==s?void 0:s.hysteresis,c=null==s?void 0:s.disableDiscovery,l=null==s?void 0:s.minFlingVelocity,m=e.props.name||null;let o={in:!0,out:!1};n.gestureNavigating&&(o={out:!0,in:!1});const h=g||Math.random();v.push((0,t.cloneElement)(e,Object.assign(Object.assign({},o),{resolvedPathname:i.matchedPathname,key:h})))}})),!v.some((t=>t.props.in))){return{children:t.Children.map(e.children,(e=>{var n;if((0,t.isValidElement)(e)&&(0,h.QN)(e.props.path,void 0)){const{config:i}=e.props;return a=null==i?void 0:i.swipeDirection,r=null==i?void 0:i.swipeAreaWidth,u=null==i?void 0:i.hysteresis,c=null==i?void 0:i.disableDiscovery,l=null==i?void 0:i.minFlingVelocity,m=null!==(n=e.props.name)&&void 0!==n?n:null,(0,t.cloneElement)(e,{in:!0,out:!1})}})),name:m,currentPath:e.currentPath,swipeDirection:a||e.swipeDirection,swipeAreaWidth:r||e.swipeAreaWidth,hysteresis:u||e.hysteresis,disableDiscovery:void 0===c?e.disableDiscovery:c,minFlingVelocity:l||e.minFlingVelocity}}return{paths:o,children:v,name:m,currentPath:e.currentPath,swipeDirection:a||e.swipeDirection,swipeAreaWidth:r||e.swipeAreaWidth,hysteresis:u||e.hysteresis,disableDiscovery:void 0===c?e.disableDiscovery:c,minFlingVelocity:l||e.minFlingVelocity}}class m extends t.Component{constructor(){super(...arguments),this.onSwipeStartListener=this.onSwipeStart.bind(this),this.onSwipeListener=this.onSwipe.bind(this),this.onSwipeEndListener=this.onSwipeEnd.bind(this),this.ref=null,this.state={currentPath:this.props.lastPath,children:this.props.children,progress:100,shouldPlay:!0,gestureNavigating:!1,shouldAnimate:!0,startX:0,startY:0,paths:[],swipeDirection:this.props.swipeDirection,swipeAreaWidth:this.props.swipeAreaWidth,minFlingVelocity:this.props.minFlingVelocity,hysteresis:this.props.hysteresis,disableDiscovery:!1},this.setRef=t=>{this.ref&&this.ref.removeEventListener("swipestart",this.onSwipeStartListener),this.ref=t,t&&t.addEventListener("swipestart",this.onSwipeStartListener)}}static getDerivedStateFromProps(t,e){if(t.currentPath!==e.currentPath){if(!e.shouldAnimate)return{currentPath:t.currentPath,shouldAnimate:!0};let n=t.currentPath;const i=p(t,e,e.currentPath,t.currentPath),{name:s}=i,o=c(i,["name"]);return o.children.sort(((t,e)=>(0,h.QN)(t.props.path,n)?1:-1)),t.onDocumentTitleChange(s),o}return null}componentDidMount(){this.context.onProgress=t=>{const e=this.props.backNavigating&&!this.state.gestureNavigating?99-t:t,n=(0,h.uZ)(e,0,100);this.setState({progress:n});const i=new CustomEvent("motion-progress",{detail:{progress:n}});this.props.dispatchEvent&&this.props.dispatchEvent(i)}}componentDidUpdate(t,e){t.currentPath!==this.state.currentPath&&(this.context.backNavigating=this.props.backNavigating,!this.state.gestureNavigating&&e.shouldAnimate&&(this.context.play=!0,this.context.animate()))}onGestureSuccess(t,e){this.props.onDocumentTitleChange(e),this.setState(t)}onSwipeStart(t){if(t.touches.length>1)return;if(this.state.disableDiscovery)return;if(this.context.isPlaying)return;if(0===this.context.duration)return;let e;switch(this.state.swipeDirection){case"left":case"right":e=t.x;break;case"up":case"down":e=t.y}if(t.direction===this.state.swipeDirection&&e<this.state.swipeAreaWidth){if(!this.props.lastPath)return;t.stopPropagation();for(let e of t.composedPath().reverse())if("classList"in e&&e.classList.length){if(e.classList.contains("gesture-region")&&"true"===e.dataset.disabled)return;if(e===t.gestureTarget)break}const e=p(this.props,Object.assign(Object.assign({},this.state),{gestureNavigating:!0}),this.props.currentPath,this.props.lastPath),{children:n,currentPath:i,paths:s,name:o}=e,a=c(e,["children","currentPath","paths","name"]);this.onGestureSuccess=this.onGestureSuccess.bind(this,a,o),this.props.navigation.addEventListener("go-back",this.onGestureSuccess,{once:!0}),this.props.onGestureNavigationStart(),this.setState({shouldPlay:!1,gestureNavigating:!0,children:n.sort((t=>(0,h.QN)(t.props.path,i)?-1:1)),startX:t.x,startY:t.y},(()=>{var t,e;const n=new CustomEvent("motion-progress-start");this.context.gestureNavigating=!0,this.context.playbackRate=-1,this.context.play=!1,this.context.backNavigating=this.props.backNavigating,this.context.animate(),this.props.dispatchEvent&&this.props.dispatchEvent(n),null===(t=this.ref)||void 0===t||t.addEventListener("swipe",this.onSwipeListener),null===(e=this.ref)||void 0===e||e.addEventListener("swipeend",this.onSwipeEndListener)}))}}onSwipe(t){if(this.state.shouldPlay)return;let e;switch(this.state.swipeDirection){case"left":case"right":{const n=window.innerWidth;e=-((0,h.uZ)(t.x-this.state.startX,10)-n)/n*100,"left"===this.state.swipeDirection&&(e=100-e);break}case"up":case"down":{const n=window.innerHeight;e=-((0,h.uZ)(t.y-this.state.startY,10)-n)/n*100,"up"===this.state.swipeDirection&&(e=100-e);break}}this.context.progress=(0,h.uZ)(e,.1,100)}onSwipeEnd(t){var e,n;if(this.state.shouldPlay)return;let i=null;const s=new CustomEvent("motion-progress-end");100-this.state.progress>this.state.hysteresis||t.velocity>this.state.minFlingVelocity?(t.velocity>=this.state.minFlingVelocity?this.context.playbackRate=-5:this.context.playbackRate=-1,i=()=>{this.context.reset(),this.props.onGestureNavigationEnd(),this.setState({gestureNavigating:!1}),this.props.dispatchEvent&&this.props.dispatchEvent(s)},this.setState({shouldPlay:!0,shouldAnimate:!1})):(this.context.playbackRate=.5,i=()=>{this.props.navigation.removeEventListener("go-back",this.onGestureSuccess),this.context.reset(),this.props.dispatchEvent&&this.props.dispatchEvent(s)},this.setState({shouldPlay:!0,gestureNavigating:!1})),this.setState({startX:0,startY:0}),this.context.onEnd=i,this.context.play=!0,null===(e=this.ref)||void 0===e||e.removeEventListener("swipe",this.onSwipeListener),null===(n=this.ref)||void 0===n||n.removeEventListener("swipeend",this.onSwipeEndListener)}render(){return(0,r.jsx)("div",Object.assign({className:"animation-layer",ref:this.setRef,style:{width:"100%",height:"100%",display:"grid",[`--${this.props.navigation.routerId}-motion-progress`]:this.state.progress}},{children:(0,r.jsx)(d.Provider,Object.assign({value:this.state.progress},{children:this.state.children}))}))}}m.contextType=u;class v extends t.Component{constructor(){super(...arguments),this.ref=null,this._currentScene=null,this._nextScene=null,this.onProgressStartListener=this.onProgressStart.bind(this),this.onProgressListener=this.onProgress.bind(this),this.onProgressEndListener=this.onProgressEnd.bind(this),this.state={transitioning:!1,playing:!0}}set currentScene(t){this._currentScene=t}set nextScene(t){this._nextScene=t,!this._currentScene||this._currentScene.isEmpty()||this._nextScene.isEmpty()?(this._currentScene=null,this._nextScene=null):this.sharedElementTransition(this._currentScene,this._nextScene)}finish(){var t;const e=(null===(t=this.ref)||void 0===t?void 0:t.getAnimations({subtree:!0}))||[];for(const t of e)t.finish()}sharedElementTransition(t,e){if(0===this.context.duration)return;if(this.state.transitioning)return void this.finish();const n=()=>{this.setState({transitioning:!1}),this._nextScene=null,this._currentScene=null},i=()=>{var t;const e=(null===(t=this.ref)||void 0===t?void 0:t.getAnimations({subtree:!0}))||[];for(const t of e)t.cancel();n()},s=queueMicrotask.bind(null,(async()=>{var s,o,a,r,l,u,c,d,p,m,v,g,f,y,_,E,w,b,x,S,P,A,L,R,D,k,O,N,I,C,T,j,$,M,U,F,V,z,Y,X,B,H,W,G,K,q,J;null===(s=this.ref)||void 0===s||s.showModal();for(const[n,i]of t.nodes)if(e.nodes.has(n)){const s=e.nodes.get(n).instance,Q=i.instance,Z=s.transitionType||Q.transitionType||"morph",tt=i.instance.node,et=e.nodes.get(n).instance.node;if(!tt||!et)continue;const nt=tt.firstElementChild,it=et.firstElementChild;if(!nt||!it)continue;const st=Q.clientRect,ot=s.clientRect;let at,rt,ht={},lt={};"morph"===Z?([at,ht]=Q.CSSData,[rt,lt]=s.CSSData):(at=Q.CSSText,rt=s.CSSText),nt.style.cssText=at,"morph"!==Z&&(it.style.cssText=rt,et.style.position="absolute",it.style.position="absolute",et.style.zIndex=it.style.zIndex,et.style.top="0",et.style.left="0"),tt.style.position="absolute",nt.style.position="absolute",tt.style.zIndex=nt.style.zIndex,tt.style.top="0",tt.style.left="0";const ut={id:Q.id,start:{x:{node:tt,delay:null!==(u=null!==(r=null===(a=null===(o=Q.props.config)||void 0===o?void 0:o.x)||void 0===a?void 0:a.delay)&&void 0!==r?r:null===(l=s.props.config)||void 0===l?void 0:l.delay)&&void 0!==u?u:0,duration:(null===(d=null===(c=Q.props.config)||void 0===c?void 0:c.x)||void 0===d?void 0:d.duration)||(null===(p=s.props.config)||void 0===p?void 0:p.duration)||this.context.duration,easingFunction:(null===(v=null===(m=Q.props.config)||void 0===m?void 0:m.x)||void 0===v?void 0:v.easingFunction)||(null===(g=Q.props.config)||void 0===g?void 0:g.easingFunction)||"ease",position:st.x-(this.state.playing?0:t.x)},y:{node:nt,delay:null!==(w=null!==(_=null===(y=null===(f=Q.props.config)||void 0===f?void 0:f.y)||void 0===y?void 0:y.delay)&&void 0!==_?_:null===(E=s.props.config)||void 0===E?void 0:E.delay)&&void 0!==w?w:0,duration:(null===(x=null===(b=Q.props.config)||void 0===b?void 0:b.y)||void 0===x?void 0:x.duration)||(null===(S=s.props.config)||void 0===S?void 0:S.duration)||this.context.duration,easingFunction:(null===(A=null===(P=Q.props.config)||void 0===P?void 0:P.y)||void 0===A?void 0:A.easingFunction)||(null===(L=Q.props.config)||void 0===L?void 0:L.easingFunction)||"ease",position:st.y-(this.state.playing?0:t.y)}},end:{x:{node:et,delay:null!==(N=null!==(k=null===(D=null===(R=s.props.config)||void 0===R?void 0:R.x)||void 0===D?void 0:D.delay)&&void 0!==k?k:null===(O=s.props.config)||void 0===O?void 0:O.delay)&&void 0!==N?N:0,duration:(null===(C=null===(I=s.props.config)||void 0===I?void 0:I.x)||void 0===C?void 0:C.duration)||(null===(T=s.props.config)||void 0===T?void 0:T.duration)||this.context.duration,easingFunction:(null===($=null===(j=s.props.config)||void 0===j?void 0:j.x)||void 0===$?void 0:$.easingFunction)||(null===(M=s.props.config)||void 0===M?void 0:M.easingFunction)||"ease",position:ot.x-(this.state.playing?e.x:0)},y:{node:it,delay:null!==(Y=null!==(V=null===(F=null===(U=s.props.config)||void 0===U?void 0:U.y)||void 0===F?void 0:F.delay)&&void 0!==V?V:null===(z=s.props.config)||void 0===z?void 0:z.delay)&&void 0!==Y?Y:0,duration:(null===(B=null===(X=s.props.config)||void 0===X?void 0:X.y)||void 0===B?void 0:B.duration)||(null===(H=s.props.config)||void 0===H?void 0:H.duration)||this.context.duration,easingFunction:(null===(G=null===(W=s.props.config)||void 0===W?void 0:W.x)||void 0===G?void 0:G.easingFunction)||(null===(K=s.props.config)||void 0===K?void 0:K.easingFunction)||"ease",position:ot.y-(this.state.playing