import{_ as __}from"./wordpress.chunk.BVds2GcU.js";import{p as e,r as n}from"./router.chunk.YsRm4bSN.js";import{m as o}from"./main.chunk.N-eZ2ybB.js";const t=({isDirty:t})=>{const{openDialog:r}=o(),a=e(({currentLocation:e,nextLocation:n})=>!!t&&e.pathname!==n.pathname);n.useEffect(()=>{"blocked"===a.state&&r({title:__("Unsaved Changes","growfund"),content:__("You have unsaved changes. Are you sure you want to leave without saving?","growfund"),confirmText:__("Leave anyway","growfund"),confirmButtonVariant:"destructive",declineText:__("Stay","growfund"),onConfirm:e=>{a.proceed(),e()},onDecline:()=>{a.reset()}})},[a,r]),n.useEffect(()=>{const e=e=>{if(t)return e.preventDefault(),__("You have unsaved changes. Are you sure you want to leave?","growfund")};return window.addEventListener("beforeunload",e),()=>{window.removeEventListener("beforeunload",e)}},[t])};export{t as u};
