import{n as e}from"./Platform-BxNC0BGj.js";import{l as t}from"./dom-BXiDqs7-.js";var n=()=>!0;function r(e){return typeof e==`string`&&e!==``&&e!==`/`&&e!==`#/`}function i(e){return e.startsWith(`#`)&&(e=e.slice(1)),e.startsWith(`/`)||(e=`/`+e),e.endsWith(`/`)&&(e=e.slice(0,-1)),`#`+e}function a(e){if(e.backButtonExit===!1)return()=>!1;if(e.backButtonExit===`*`)return n;let t=[`#/`];return Array.isArray(e.backButtonExit)&&t.push(...e.backButtonExit.filter(r).map(i)),()=>t.includes(window.location.hash)}var o={__history:[],add:t,remove:t,install({$q:t}){if(this.__installed)return;let{cordova:r,capacitor:i}=e.is;if(!r&&!i)return;let o=t.config[r?`cordova`:`capacitor`];if(o?.backButton===!1||i&&(window.Capacitor===void 0||window.Capacitor.Plugins.App===void 0))return;this.add=e=>{e.condition===void 0&&(e.condition=n),this.__history.push(e)},this.remove=e=>{let t=this.__history.indexOf(e);t!==-1&&this.__history.splice(t,1)};let s=a({backButtonExit:!0,...o}),c=()=>{if(this.__history.length!==0){let e=this.__history.at(-1);e.condition()&&(this.__history.pop(),e.handler())}else s()?navigator.app.exitApp():window.history.back()};r?document.addEventListener(`deviceready`,()=>{document.addEventListener(`backbutton`,c,!1)}):window.Capacitor.Plugins.App.addListener(`backButton`,c)}};export{o as t};