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K,EAAI,IAAI,KAC/B,EAAE,UAGf,EACA,UAAM,EAAO,aAAa,SAAE,KAC1B,MAAM,YAAE,SAAsB,QAAQ,UAAU,MAAK,WAAc,OAAoB,kBAAkB,QAAQ,yBAA2B,IACtI,EAAU,EAAQ,QAAQ,EAAQ,SAClC,EAAO,EAAQ,KACrB,EAAS,MAAK,MAAO,EAAK,KACxB,GAAmB,QAAf,EAAI,QAAoB,EAAY,EAAI,OAAS,EAGrD,aADM,EAAQ,EAAK,GACZ,CACL,MAAM,EACP,GAEL,EACA,OAAM,IACG,QAAQ,KACb,wIAGJ,OAAM,IACG,QAAQ,KACb,uIAGJ,eAAM,EAAY,aAAa,SAAE,KAC/B,MAAM,QAAa,EAAQ,SACrB,EAAO,EAAQ,KACrB,EAAS,MAAM,IACb,GAA2B,QAAvB,EAAI,QAAQ,QAAoB,IAAS,EAAI,IAAI,SAErD,OAAO,IAAI,SAAS,EAAM,CACxB,OAAQ,IACR,QAAS,CACP,eAAgB,cAElB,GAEN,EACA,gBAAM,EAAa,aAAa,OAAE,KAChC,MAAM,QAAa,EAAQ,SAC3B,EAAO,IAAI,MAAO,EAAQ,MAAM,CAAC,EAAM,KACrC,EAAI,UAAU,eAAgB,aAC9B,EAAI,IAAI,EAAK,GAEjB,EAEJ,IAIJ,QAAQ,kBAAoB,OAAO,kBACnC,QAAQ,eAAiB,eACzB,QAAQ,UAAY","file":"/npm/@graphql-ez/plugin-voyager@0.10.1/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/@graphql-ez/plugin-voyager@0.10.1/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","'use strict';\n\nObject.defineProperty(exports, '__esModule', { value: true });\n\nvar object = require('@graphql-ez/utils/object');\nvar promise = require('@graphql-ez/utils/promise');\nvar render = require('./render.js');\n\nfunction _interopNamespace(e) {\n  if (e && e.__esModule) return e;\n  var n = Object.create(null);\n  if (e) {\n    Object.keys(e).forEach(function (k) {\n      if (k !== 'default') {\n        var d = Object.getOwnPropertyDescriptor(e, k);\n        Object.defineProperty(n, k, d.get ? d : {\n          enumerable: true,\n          get: function () { return e[k]; }\n        });\n      }\n    });\n  }\n  n[\"default\"] = e;\n  return Object.freeze(n);\n}\n\nconst VoyagerDeps = promise.LazyPromise(async () => {\n  const { renderVoyagerPage } = await Promise.resolve().then(function () { return require('./render.js'); });\n  return { renderVoyagerPage };\n});\nfunction VoyagerHandler(options, extraConfig) {\n  var _a;\n  const { transformHtml, ...renderOptions } = object.getObjectValue(options) || {};\n  const html = VoyagerDeps.then(({ renderVoyagerPage }) => {\n    const content = renderVoyagerPage(renderOptions);\n    if (transformHtml)\n      return transformHtml(content);\n    return content;\n  });\n  const rawHttp = (_a = extraConfig == null ? void 0 : extraConfig.rawHttp) != null ? _a : true;\n  return async function(_req, res) {\n    const content = await html;\n    if (rawHttp) {\n      res.setHeader(\"content-type\", \"text/html\");\n      res.end(content);\n    }\n    return {\n      content\n    };\n  };\n}\nconst ezVoyager = (options = true) => {\n  return {\n    name: \"GraphQL Voyager\",\n    compatibilityList: {\n      fastify: true,\n      koa: true,\n      express: true,\n      hapi: true,\n      http: true,\n      nextjs: true,\n      sveltekit: true,\n      cloudflare: true\n    },\n    onRegister(ctx) {\n      if (!options)\n        return;\n      const objOptions = { ...object.getObjectValue(options) || {} };\n      const path = objOptions.path || (objOptions.path = \"/voyager\");\n      objOptions.endpoint || (objOptions.endpoint = ctx.options.path);\n      ctx.voyager = {\n        path,\n        handler: VoyagerHandler,\n        options: objOptions,\n        async render() {\n          var _a;\n          const { transformHtml, ...renderOptions } = object.getObjectValue((_a = ctx.voyager) == null ? void 0 : _a.options) || {};\n          const html = VoyagerDeps.then(({ renderVoyagerPage }) => {\n            const content = renderVoyagerPage(renderOptions);\n            if (transformHtml)\n              return transformHtml(content);\n            return content;\n          });\n          return html;\n        }\n      };\n    },\n    onIntegrationRegister(ctx) {\n      if (!ctx.voyager)\n        return;\n      const voyager = ctx.voyager;\n      return {\n        fastify({ integration }) {\n          const handler = voyager.handler(voyager.options);\n          integration.get(voyager.path, async (req, res) => {\n            res.hijack();\n            await handler(req.raw, res.raw);\n          });\n        },\n        express({ integration: { router } }) {\n          const handler = voyager.handler(voyager.options);\n          router.get(voyager.path, async (req, res) => {\n            await handler(req, res);\n          });\n        },\n        koa({ integration: { router } }) {\n          const handler = voyager.handler(voyager.options, {\n            rawHttp: false\n          });\n          router.get(voyager.path, async (ctx2) => {\n            const result = await handler(ctx2.req, ctx2.res);\n            ctx2.type = \"text/html\";\n            ctx2.body = result.content;\n          });\n        },\n        hapi({ integration: { server, ideRouteOptions } }) {\n          const ideHandler = voyager.handler(voyager.options);\n          server.route({\n            path: voyager.path,\n            method: \"GET\",\n            options: ideRouteOptions,\n            async handler(req, h) {\n              await ideHandler(req.raw.req, req.raw.res);\n              return h.abandon;\n            }\n          });\n        },\n        async http({ integration: { handlers } }) {\n          const { getPathname } = await Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('@graphql-ez/utils/url')); });\n          const handler = voyager.handler(voyager.options);\n          const path = voyager.path;\n          handlers.push(async (req, res) => {\n            if (req.method !== \"GET\" || getPathname(req.url) !== path)\n              return;\n            await handler(req, res);\n            return {\n              stop: true\n            };\n          });\n        },\n        nextjs() {\n          return console.warn(\n            `[graphql-ez] You don't need to add the Voyager plugin in your EZ App for Next.js, use \"VoyagerHandler\" directly in your API Routes.`\n          );\n        },\n        vercel() {\n          return console.warn(\n            `[graphql-ez] You don't need to add the Voyager plugin in your EZ App for Vercel, use \"VoyagerHandler\" directly in your API Routes.`\n          );\n        },\n        async sveltekit({ integration: { handlers } }) {\n          const html = await voyager.render();\n          const path = voyager.path;\n          handlers.push((req) => {\n            if (req.request.method !== \"GET\" || path !== req.url.pathname)\n              return;\n            return new Response(html, {\n              status: 200,\n              headers: {\n                \"content-type\": \"text/html\"\n              }\n            });\n          });\n        },\n        async cloudflare({ integration: { router } }) {\n          const html = await voyager.render();\n          router.add(\"GET\", voyager.path, (_req, res) => {\n            res.setHeader(\"content-type\", \"text/html\");\n            res.end(html);\n          });\n        }\n      };\n    }\n  };\n};\n\nexports.renderVoyagerPage = render.renderVoyagerPage;\nexports.VoyagerHandler = VoyagerHandler;\nexports.ezVoyager = ezVoyager;\n"]}