"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 pages_router_exports = {};
__export(pages_router_exports, {
  argsPattern: () => argsPattern,
  config: () => config
});
module.exports = __toCommonJS(pages_router_exports);
var import_ts_pattern = require("ts-pattern");
var import_node_request_response = require("../../../api-handler/node-request-response");
var import_pages_router_redirect_preview = require("../handlers/pages-router-redirect-preview");
var import_preview = require("../preview");
var import_base = require("./base");
const argsPattern = [import_ts_pattern.P.any, import_ts_pattern.P.any];
async function config({
  req,
  res,
  client
}) {
  return {
    req: (0, import_node_request_response.toApiRequest)(req),
    route: (0, import_base.validateApiRoute)(await apiRequestParams(req)),
    previewCookieNames: [import_preview.PRERENDER_BYPASS_COOKIE, import_preview.PREVIEW_DATA_COOKIE],
    sendResponse: (apiResponse) => (0, import_node_request_response.pipeResponseTo)(apiResponse, res),
    revalidationHandler: async (path) => {
      if (path != null) {
        res.revalidate(path);
      } else {
      }
    },
    customRoutes: async (route) => {
      if (route === "/redirect-preview") {
        return { res: await (0, import_pages_router_redirect_preview.pagesRouterRedirectPreviewHandler)(req, res, client) };
      }
      return null;
    }
  };
}
function apiRequestParams(request) {
  return Promise.resolve(request.query);
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  argsPattern,
  config
});
//# sourceMappingURL=pages-router.js.map