// ../preview-next/src/constants.ts
var PREVIEW_COOKIE_NAME = "preview_token";
var PREVIEW_REFRESH_COOKIE_NAME = "preview_refresh_token";
var PREVIEW_COOKIE_MAX_AGE = 60 * 60 * 12;

// ../preview-next/src/cookies.ts
function getPreviewCookieOptions(options = {}) {
  const { maxAge = PREVIEW_COOKIE_MAX_AGE, secure } = options;
  const resolvedSecure = secure ?? process.env.NODE_ENV === "production";
  return {
    httpOnly: true,
    secure: resolvedSecure,
    sameSite: "lax",
    path: "/",
    maxAge
  };
}
function setPreviewCookie(res, token, options) {
  res.cookies.set(PREVIEW_COOKIE_NAME, token, getPreviewCookieOptions(options));
  return res;
}
function setPreviewRefreshCookie(res, token, options) {
  res.cookies.set(PREVIEW_REFRESH_COOKIE_NAME, token, getPreviewCookieOptions(options));
  return res;
}
function setPreviewAuthCookies(res, {
  accessToken,
  refreshToken
}, options) {
  if (accessToken) {
    setPreviewCookie(res, accessToken, options);
  }
  if (refreshToken) {
    setPreviewRefreshCookie(res, refreshToken, options);
  }
  return res;
}
function clearPreviewCookies(res) {
  res.cookies.delete(PREVIEW_COOKIE_NAME);
  res.cookies.delete(PREVIEW_REFRESH_COOKIE_NAME);
  return res;
}
export {
  clearPreviewCookies,
  setPreviewAuthCookies,
  setPreviewCookie,
  setPreviewRefreshCookie
};
