'use client';

import { c as _c } from "react/compiler-runtime";
import { jsx as _jsx } from "react/jsx-runtime";
import { useRouter } from 'next/navigation.js';
import { formatAdminURL } from 'payload/shared';
import React, { useCallback } from 'react';
import { useAuth } from '../../providers/Auth/index.js';
import { useConfig } from '../../providers/Config/index.js';
import { useRouteTransition } from '../../providers/RouteTransition/index.js';
import { useTranslation } from '../../providers/Translation/index.js';
import { ConfirmationModal } from '../ConfirmationModal/index.js';
export const stayLoggedInModalSlug = 'stay-logged-in';
export const StayLoggedInModal = () => {
  const $ = _c(12);
  const {
    refreshCookie
  } = useAuth();
  const router = useRouter();
  const {
    config
  } = useConfig();
  const {
    admin: t0,
    routes: t1,
    serverURL
  } = config;
  const {
    routes: t2
  } = t0;
  const {
    logout: logoutRoute
  } = t2;
  const {
    admin: adminRoute
  } = t1;
  const {
    t
  } = useTranslation();
  const {
    startRouteTransition
  } = useRouteTransition();
  let t3;
  if ($[0] !== adminRoute || $[1] !== logoutRoute || $[2] !== router || $[3] !== serverURL || $[4] !== startRouteTransition) {
    t3 = () => startRouteTransition(() => router.push(formatAdminURL({
      adminRoute,
      path: logoutRoute,
      serverURL
    })));
    $[0] = adminRoute;
    $[1] = logoutRoute;
    $[2] = router;
    $[3] = serverURL;
    $[4] = startRouteTransition;
    $[5] = t3;
  } else {
    t3 = $[5];
  }
  const onConfirm = t3;
  let t4;
  if ($[6] !== refreshCookie) {
    t4 = () => {
      refreshCookie();
    };
    $[6] = refreshCookie;
    $[7] = t4;
  } else {
    t4 = $[7];
  }
  const onCancel = t4;
  let t5;
  if ($[8] !== onCancel || $[9] !== onConfirm || $[10] !== t) {
    t5 = _jsx(ConfirmationModal, {
      body: t("authentication:youAreInactive"),
      cancelLabel: t("authentication:stayLoggedIn"),
      confirmLabel: t("authentication:logOut"),
      heading: t("authentication:stayLoggedIn"),
      modalSlug: stayLoggedInModalSlug,
      onCancel,
      onConfirm
    });
    $[8] = onCancel;
    $[9] = onConfirm;
    $[10] = t;
    $[11] = t5;
  } else {
    t5 = $[11];
  }
  return t5;
};
//# sourceMappingURL=index.js.map