"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);
var cors_exports = {};
__export(cors_exports, {
  applyCorsHeaders: () => applyCorsHeaders
});
module.exports = __toCommonJS(cors_exports);
function applyCorsHeaders(headers, options) {
  const {
    origin = "*",
    methods = ["GET", "HEAD", "PUT", "POST", "DELETE", "PATCH", "OPTIONS"],
    allowedHeaders = ["Content-Type"],
    exposedHeaders,
    credentials,
    maxAge
  } = options;
  headers.append("Access-Control-Allow-Origin", origin);
  headers.append("Access-Control-Allow-Methods", methods.join(", ").toUpperCase());
  if (allowedHeaders)
    headers.append("Access-Control-Allow-Headers", allowedHeaders.join(", "));
  if (exposedHeaders)
    headers.append("Access-Control-Expose-Headers", exposedHeaders.join(", "));
  if (credentials)
    headers.append("Access-Control-Allow-Credentials", "true");
  if (maxAge != null)
    headers.append("Access-Control-Max-Age", `${maxAge}`);
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  applyCorsHeaders
});
//# sourceMappingURL=cors.js.map