import{store as t}from"../haxcms-site-store.js";import{HAXCMSI18NMixin as e}from"./HAXCMSI18NMixin.js";import{autorun as s,toJS as a}from"../../../../../mobx/dist/mobx.esm.js";import{localStorageGet as o,localStorageSet as i}from"../../../../utils/utils.js";const HAXCMSRememberRoute=function(n){return class extends(e(n)){constructor(){super();this.__evaluateRoute=!1,this.t.resumeMessage="Resume where you left off last session?",this.t.resume="Resume",s((e=>{if(t&&t.location&&t.location.pathname){const e=a(t.location.pathname);e&&this.__evaluateRoute&&i(`HAXCMSlastRoute-${t.manifest.metadata.site.name}`,e)}}))}firstUpdated(e){super.firstUpdated&&super.firstUpdated(e),setTimeout((()=>{if(t&&t.location&&t.location.pathname&&o(`HAXCMSlastRoute-${t.manifest.metadata.site.name}`)&&o(`HAXCMSlastRoute-${t.manifest.metadata.site.name}`)!=a(t.location.pathname)){let e=globalThis.document.createElement("a");e.setAttribute("href",o(`HAXCMSlastRoute-${t.manifest.metadata.site.name}`)),e.addEventListener("click",this.resumeLastRoute.bind(this)),e.innerHTML=`<button style="padding:4px;font-weight:bold;background-color: black; color: white; border: 4px solid black; border-radius:none;margin-left:4px;cursor: pointer;">${this.t.resume}</button>`;new URLSearchParams(globalThis.location.search).get("format")||t.toast(this.t.resumeMessage,5e3,{},"capsule",null,null,e)}this.__evaluateRoute=!0}),500)}resumeLastRoute(t){globalThis.dispatchEvent(new CustomEvent("haxcms-toast-hide",{bubbles:!0,composed:!0,cancelable:!1,detail:!1}))}}};export{HAXCMSRememberRoute};