'use client';
import { useRouter, useSearchParams } from 'next/navigation';
import { usePageTrackerStore } from '../stores/page-tracker/page-tracker-store';
export const PHXUseRouterBack = () => {
    const router = useRouter();
    const searchParams = useSearchParams();
    const referrer = usePageTrackerStore((state) => state.referrer);
    const isFirstPage = usePageTrackerStore((state) => state.isFirstPage);
    const routerBack = (backLink) => {
        const isFromNotification = (searchParams === null || searchParams === void 0 ? void 0 : searchParams.get('ref')) === 'notification';
        if (isFromNotification) {
            router.push(backLink);
        }
        else if (isFirstPage && referrer) {
            router.push(referrer);
        }
        else if (isFirstPage) {
            router.push(backLink);
        }
        else {
            router.back();
        }
    };
    return routerBack;
};
//# sourceMappingURL=use-router-back.js.map