// src/lib/cookie.ts
import { deleteCookie as honoDel, setCookie as honoSet } from "hono/cookie";
var isProduction = process.env.NODE_ENV === "production";
var getSessionKeyNamespace = (config) => {
  const p = config.prefix?.trim();
  return p && p.length > 0 ? p : "msb";
};
var getSessionCookieName = (config) => {
  const prefix = config.prefix?.trim() || "";
  const baseName = "session_token";
  if (prefix) {
    return `${prefix}_${baseName}`;
  }
  return isProduction ? "__Host-session_token" : baseName;
};
var setSessionCookie = (c, token, config, options) => {
  const cookieName = getSessionCookieName(config);
  const cookieOptions = {
    httpOnly: true,
    secure: isProduction,
    sameSite: "Lax",
    path: options.path || "/",
    expires: options.expires,
    ...isProduction && { domain: void 0 }
    // __Host- requires no domain
  };
  honoSet(c, cookieName, token, cookieOptions);
};
var deleteSessionCookie = (c, config) => {
  const cookieName = getSessionCookieName(config);
  honoDel(c, cookieName, {
    httpOnly: true,
    secure: isProduction,
    sameSite: "Lax",
    path: "/",
    expires: /* @__PURE__ */ new Date(0)
  });
};
export {
  deleteSessionCookie,
  getSessionCookieName,
  getSessionKeyNamespace,
  setSessionCookie
};
//# sourceMappingURL=cookie.js.map