"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/preview-next/cookies.ts
var cookies_exports = {};
__export(cookies_exports, {
  clearPreviewCookies: () => clearPreviewCookies,
  setPreviewAuthCookies: () => setPreviewAuthCookies,
  setPreviewCookie: () => setPreviewCookie,
  setPreviewRefreshCookie: () => setPreviewRefreshCookie
});
module.exports = __toCommonJS(cookies_exports);

// ../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;
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  clearPreviewCookies,
  setPreviewAuthCookies,
  setPreviewCookie,
  setPreviewRefreshCookie
});
//# sourceMappingURL=cookies.js.map