import{__awaiter,__generator}from"tslib"; /*! * (C) Ionic http://ionicframework.com - MIT License */import{r as registerInstance,d as createEvent,h,f as getElement,H as Host}from"./index-73fa3fe8.js";import{g as getTimeGivenProgression}from"./cubic-bezier-fe2083dc.js";import{o as assert,s as shallowEqualStringMap}from"./helpers-be245865.js";import{l as lifecycle,t as transition,s as setPageHidden,d as LIFECYCLE_WILL_UNLOAD,b as LIFECYCLE_WILL_LEAVE,c as LIFECYCLE_DID_LEAVE}from"./index-4feaf001.js";import{b as getIonMode,c as config}from"./ionic-global-d89a6ff6.js";import{a as attachComponent}from"./framework-delegate-ed4ba327.js";var VIEW_STATE_NEW=1;var VIEW_STATE_ATTACHED=2;var VIEW_STATE_DESTROYED=3;var ViewController=function(){function t(t,e){this.component=t;this.params=e;this.state=VIEW_STATE_NEW}t.prototype.init=function(t){return __awaiter(this,void 0,void 0,(function(){var e,i;return __generator(this,(function(n){switch(n.label){case 0:this.state=VIEW_STATE_ATTACHED;if(!!this.element)return[3,2];e=this.component;i=this;return[4,attachComponent(this.delegate,t,e,["ion-page","ion-page-invisible"],this.params)];case 1:i.element=n.sent();n.label=2;case 2:return[2]}}))}))};t.prototype._destroy=function(){assert(this.state!==VIEW_STATE_DESTROYED,"view state must be ATTACHED");var t=this.element;if(t){if(this.delegate){this.delegate.removeViewFromDom(t.parentElement,t)}else{t.remove()}}this.nav=undefined;this.state=VIEW_STATE_DESTROYED};return t}();var matches=function(t,e,i){if(!t){return false}if(t.component!==e){return false}return shallowEqualStringMap(t.params,i)};var convertToView=function(t,e){if(!t){return null}if(t instanceof ViewController){return t}return new ViewController(t,e)};var convertToViews=function(t){return t.map((function(t){if(t instanceof ViewController){return t}if("component"in t){return convertToView(t.component,t.componentProps===null?undefined:t.componentProps)}return convertToView(t,undefined)})).filter((function(t){return t!==null}))};var navCss=":host{left:0;right:0;top:0;bottom:0;position:absolute;contain:layout size style;z-index:0}";var IonNavStyle0=navCss;var Nav=function(){function t(t){registerInstance(this,t);this.ionNavWillLoad=createEvent(this,"ionNavWillLoad",7);this.ionNavWillChange=createEvent(this,"ionNavWillChange",3);this.ionNavDidChange=createEvent(this,"ionNavDidChange",3);this.transInstr=[];this.gestureOrAnimationInProgress=false;this.useRouter=false;this.isTransitioning=false;this.destroyed=false;this.views=[];this.didLoad=false;this.delegate=undefined;this.swipeGesture=undefined;this.animated=true;this.animation=undefined;this.rootParams=undefined;this.root=undefined}t.prototype.swipeGestureChanged=function(){if(this.gesture){this.gesture.enable(this.swipeGesture===true)}};t.prototype.rootChanged=function(){if(this.root===undefined){return}if(this.didLoad===false){return}if(!this.useRouter){if(this.root!==undefined){this.setRoot(this.root,this.rootParams)}}};t.prototype.componentWillLoad=function(){this.useRouter=document.querySelector("ion-router")!==null&&this.el.closest("[no-router]")===null;if(this.swipeGesture===undefined){var t=getIonMode(this);this.swipeGesture=config.getBoolean("swipeBackEnabled",t==="ios")}this.ionNavWillLoad.emit()};t.prototype.componentDidLoad=function(){return __awaiter(this,void 0,void 0,(function(){var t;return __generator(this,(function(e){switch(e.label){case 0:this.didLoad=true;this.rootChanged();t=this;return[4,import("./swipe-back-37a22d34.js")];case 1:t.gesture=e.sent().createSwipeBackGesture(this.el,this.canStart.bind(this),this.onStart.bind(this),this.onMove.bind(this),this.onEnd.bind(this));this.swipeGestureChanged();return[2]}}))}))};t.prototype.connectedCallback=function(){this.destroyed=false};t.prototype.disconnectedCallback=function(){for(var t=0,e=this.views;t0?e[i-1]:undefined};t.prototype.queueTrns=function(t,e){return __awaiter(this,void 0,void 0,(function(){var i,n,r,s,a;return __generator(this,(function(o){switch(o.label){case 0:if(this.isTransitioning&&((i=t.opts)===null||i===void 0?void 0:i.skipIfBusy)){return[2,false]}r=new Promise((function(e,i){t.resolve=e;t.reject=i}));t.done=e;if(!(t.opts&&t.opts.updateURL!==false&&this.useRouter))return[3,2];s=document.querySelector("ion-router");if(!s)return[3,2];return[4,s.canTransition()];case 1:a=o.sent();if(a===false){return[2,false]}if(typeof a==="string"){s.push(a,t.opts.direction||"back");return[2,false]}o.label=2;case 2:if(((n=t.insertViews)===null||n===void 0?void 0:n.length)===0){t.insertViews=undefined}this.transInstr.push(t);this.nextTrns();return[2,r]}}))}))};t.prototype.success=function(t,e){if(this.destroyed){this.fireError("nav controller was destroyed",e);return}if(e.done){e.done(t.hasCompleted,t.requiresTransition,t.enteringView,t.leavingView,t.direction)}e.resolve(t.hasCompleted);if(e.opts.updateURL!==false&&this.useRouter){var i=document.querySelector("ion-router");if(i){var n=t.direction==="back"?"back":"forward";i.navChanged(n)}}};t.prototype.failed=function(t,e){if(this.destroyed){this.fireError("nav controller was destroyed",e);return}this.transInstr.length=0;this.fireError(t,e)};t.prototype.fireError=function(t,e){if(e.done){e.done(false,false,t)}if(e.reject&&!this.destroyed){e.reject(t)}else{e.resolve(false)}};t.prototype.nextTrns=function(){if(this.isTransitioning){return false}var t=this.transInstr.shift();if(!t){return false}this.runTransition(t);return true};t.prototype.runTransition=function(t){return __awaiter(this,void 0,void 0,(function(){var e,i,n,r,s,a;return __generator(this,(function(o){switch(o.label){case 0:o.trys.push([0,6,,7]);this.ionNavWillChange.emit();this.isTransitioning=true;this.prepareTI(t);e=this.getActiveSync();i=this.getEnteringView(t,e);if(!e&&!i){throw new Error("no views in the stack to be removed")}if(!(i&&i.state===VIEW_STATE_NEW))return[3,2];return[4,i.init(this.el)];case 1:o.sent();o.label=2;case 2:this.postViewInit(i,e,t);n=(t.enteringRequiresTransition||t.leavingRequiresTransition)&&i!==e;if(n&&t.opts&&e){r=t.opts.direction==="back";if(r){t.opts.animationBuilder=t.opts.animationBuilder||(i===null||i===void 0?void 0:i.animationBuilder)}e.animationBuilder=t.opts.animationBuilder}s=void 0;if(!n)return[3,4];return[4,this.transition(i,e,t)];case 3:s=o.sent();return[3,5];case 4:s={hasCompleted:true,requiresTransition:false};o.label=5;case 5:this.success(s,t);this.ionNavDidChange.emit();return[3,7];case 6:a=o.sent();this.failed(a,t);return[3,7];case 7:this.isTransitioning=false;this.nextTrns();return[2]}}))}))};t.prototype.prepareTI=function(t){var e,i;var n;var r=this.views.length;(e=t.opts)!==null&&e!==void 0?e:t.opts={};(i=(n=t.opts).delegate)!==null&&i!==void 0?i:n.delegate=this.delegate;if(t.removeView!==undefined){assert(t.removeStart!==undefined,"removeView needs removeStart");assert(t.removeCount!==undefined,"removeView needs removeCount");var s=this.views.indexOf(t.removeView);if(s<0){throw new Error("removeView was not found")}t.removeStart+=s}if(t.removeStart!==undefined){if(t.removeStart<0){t.removeStart=r-1}if(t.removeCount<0){t.removeCount=r-t.removeStart}t.leavingRequiresTransition=t.removeCount>0&&t.removeStart+t.removeCount===r}if(t.insertViews){if(t.insertStart<0||t.insertStart>r){t.insertStart=r}t.enteringRequiresTransition=t.insertStart===r}var a=t.insertViews;if(!a){return}assert(a.length>0,"length can not be zero");var o=convertToViews(a);if(o.length===0){throw new Error("invalid views to insert")}for(var u=0,f=o;u=0;a--){var o=r[a];if((a=s)&&o!==e){return o}}}return undefined};t.prototype.postViewInit=function(t,e,i){var n,r,s;assert(e||t,"Both leavingView and enteringView are null");assert(i.resolve,"resolve must be valid");assert(i.reject,"reject must be valid");var a=i.opts;var o=i.insertViews,u=i.removeStart,f=i.removeCount;var h;if(u!==undefined&&f!==undefined){assert(u>=0,"removeStart can not be negative");assert(f>=0,"removeCount can not be negative");h=[];for(var c=u;c=0,"final balance can not be negative");if(d===0){console.warn("You can't remove all the pages in the navigation stack. nav.pop() is probably called too many times.",this,this.el);throw new Error("navigation stack needs at least one root page")}if(o){var l=i.insertStart;for(var _=0,m=o;_0){for(var E=0,w=h;E-1){assert(t.nav===this,"view is not part of the nav");i.splice(n,1);i.splice(e,0,t)}else{assert(!t.nav,"nav is used");t.nav=this;i.splice(e,0,t)}};t.prototype.removeView=function(t){assert(t.state===VIEW_STATE_ATTACHED||t.state===VIEW_STATE_DESTROYED,"view state should be loaded or destroyed");var e=this.views;var i=e.indexOf(t);assert(i>-1,"view must be part of the stack");if(i>=0){e.splice(i,1)}};t.prototype.destroyView=function(t){t._destroy();this.removeView(t)};t.prototype.unmountInactiveViews=function(t){if(this.destroyed){return}var e=this.views;var i=e.indexOf(t);for(var n=e.length-1;n>=0;n--){var r=e[n];var s=r.element;if(s){if(n>i){lifecycle(s,LIFECYCLE_WILL_UNLOAD);this.destroyView(r)}else if(n