import {
  InvalidRequest3
} from "../chunk-ZBT5SDIQ.js";
import "../chunk-V7TRGEV6.js";
import "../chunk-3AVBP57V.js";
import "../chunk-ZIHRRTTA.js";
import "../chunk-3JKQPIJ2.js";
import "../chunk-7NN7DVGK.js";
import "../chunk-63Q3RLAK.js";
import "../chunk-OCHPLE5N.js";
import "../chunk-GJFKL6XM.js";
import "../chunk-24XYHOWM.js";
import "../chunk-57WYIP4I.js";
import "../chunk-TDZTH7TL.js";
import "../chunk-RYIGWCGK.js";
import "../chunk-H4QJ5O4E.js";
import "../chunk-THUA35UY.js";

// src/lambda/origin-response.ts
function createOriginRequestHandler() {
  return async function handler2(event) {
    const request = event.Records[0]?.cf?.request;
    const response = event.Records[0]?.cf?.response;
    if (request == null || response == null) {
      throw new InvalidRequest3("invalid request");
    }
    const bundleUrl = request.headers["x-bundle"]?.[0]?.value;
    if (bundleUrl == null) {
      return response;
    }
    const deploymentId = response.headers["x-amz-meta-x-deployment-id"]?.[0]?.value;
    if (deploymentId != null) {
      response.headers["x-deployment-id"] = [
        {
          key: "X-Deployment-Id",
          value: deploymentId
        }
      ];
    }
    const deployedAt = response.headers["x-amz-meta-x-deployment-deployed-at"]?.[0]?.value;
    if (deployedAt != null) {
      response.headers["x-deployed-at"] = [
        {
          key: "X-Deployed-At",
          value: deployedAt
        }
      ];
    }
    return response;
  };
}
var handler = createOriginRequestHandler();
export {
  createOriginRequestHandler,
  handler
};
