module.exports=[193695,(e,t,r)=>{t.exports=e.x("next/dist/shared/lib/no-fallback-error.external.js",()=>require("next/dist/shared/lib/no-fallback-error.external.js"))},918622,(e,t,r)=>{t.exports=e.x("next/dist/compiled/next-server/app-page-turbo.runtime.prod.js",()=>require("next/dist/compiled/next-server/app-page-turbo.runtime.prod.js"))},556704,(e,t,r)=>{t.exports=e.x("next/dist/server/app-render/work-async-storage.external.js",()=>require("next/dist/server/app-render/work-async-storage.external.js"))},832319,(e,t,r)=>{t.exports=e.x("next/dist/server/app-render/work-unit-async-storage.external.js",()=>require("next/dist/server/app-render/work-unit-async-storage.external.js"))},324725,(e,t,r)=>{t.exports=e.x("next/dist/server/app-render/after-task-async-storage.external.js",()=>require("next/dist/server/app-render/after-task-async-storage.external.js"))},270406,(e,t,r)=>{t.exports=e.x("next/dist/compiled/@opentelemetry/api",()=>require("next/dist/compiled/@opentelemetry/api"))},425747,e=>{"use strict";e.i(684843),e.s([])},869789,e=>{"use strict";e.i(425747),e.s([])},697793,e=>{"use strict";var t=e.i(747909),r=e.i(174017),a=e.i(996250),s=e.i(759756),o=e.i(561916),n=e.i(174677),i=e.i(869741),l=e.i(316795),d=e.i(487718),u=e.i(995169),p=e.i(47587),c=e.i(666012),h=e.i(570101),v=e.i(626937),m=e.i(10372),x=e.i(193695);e.i(820232);var f=e.i(600220),y=e.i(89171);e.i(869789);var R=e.i(826882);let w=`
export default {
  async fetch(request, env, ctx) {
    const target = request.headers.get("x-relay-target");
    const relayPath = request.headers.get("x-relay-path") || "/";
    
    if (!target) {
      return new Response(JSON.stringify({ error: "Missing x-relay-target header" }), {
        status: 400,
        headers: { "content-type": "application/json" },
      });
    }

    const targetUrl = target.replace(/\\/$/, "") + relayPath;
    const newRequestInit = {
      method: request.method,
      headers: new Headers(request.headers),
    };

    if (request.method !== "GET" && request.method !== "HEAD") {
      newRequestInit.body = request.body;
      newRequestInit.duplex = "half";
    }

    newRequestInit.headers.delete("x-relay-target");
    newRequestInit.headers.delete("x-relay-path");
    newRequestInit.headers.delete("host");

    try {
      const response = await fetch(targetUrl, newRequestInit);
      return new Response(response.body, {
        status: response.status,
        headers: response.headers,
      });
    } catch (error) {
      return new Response(JSON.stringify({ error: error.message }), {
        status: 502,
        headers: { "content-type": "application/json" },
      });
    }
  },
};
`;async function g(e){try{let t=await e.json(),r=t.accountId?.trim(),a=t.apiToken?.trim(),s=t.projectName?.trim()||`relay-${Date.now().toString(36)}`;if(!r||!a)return y.NextResponse.json({error:"Cloudflare Account ID and API Token are required"},{status:400});let o=`https://api.cloudflare.com/client/v4/accounts/${r}/workers/scripts/${s}`,n=new FormData;n.append("index.js",new Blob([w],{type:"application/javascript+module"}),"index.js"),n.append("metadata",new Blob([JSON.stringify({main_module:"index.js",compatibility_date:"2024-03-20",observability:{enabled:!0}})],{type:"application/json"}),"metadata.json");let i=await fetch(o,{method:"PUT",headers:{Authorization:`Bearer ${a}`},body:n});if(!i.ok){let e=await i.json().catch(()=>({}));return console.error("Cloudflare upload error:",e),y.NextResponse.json({error:e.errors?.[0]?.message||"Failed to upload Worker to Cloudflare"},{status:i.status})}let l=await fetch(`${o}/subdomain`,{method:"POST",headers:{Authorization:`Bearer ${a}`,"Content-Type":"application/json"},body:JSON.stringify({enabled:!0})});if(!l.ok){let e=await l.json().catch(()=>({}));console.error("Cloudflare subdomain enable error:",e)}let d="",u=await fetch(`https://api.cloudflare.com/client/v4/accounts/${r}/workers/subdomain`,{method:"GET",headers:{Authorization:`Bearer ${a}`,"Content-Type":"application/json"}});if(u.ok){let e=await u.json();e.result&&e.result.subdomain&&(d=`https://${s}.${e.result.subdomain}.workers.dev`)}if(!d)return y.NextResponse.json({error:"Worker deployed but failed to retrieve workers.dev subdomain. Make sure you have setup a workers.dev subdomain in Cloudflare Dashboard."},{status:400});let p=await (0,R.createProxyPool)({name:s,proxyUrl:d,type:"cloudflare",noProxy:"",isActive:!0,strictProxy:!1});return y.NextResponse.json({proxyPool:p,deployUrl:d},{status:201})}catch(e){return console.log("Error deploying Cloudflare relay:",e),y.NextResponse.json({error:e.message||"Deploy failed"},{status:500})}}e.s(["POST",0,g],702141);var b=e.i(702141);let _=new t.AppRouteRouteModule({definition:{kind:r.RouteKind.APP_ROUTE,page:"/api/proxy-pools/cloudflare-deploy/route",pathname:"/api/proxy-pools/cloudflare-deploy",filename:"route",bundlePath:""},distDir:".next",relativeProjectDir:"",resolvedPagePath:"[project]/src/app/api/proxy-pools/cloudflare-deploy/route.js",nextConfigOutput:"standalone",userland:b,...{}}),{workAsyncStorage:P,workUnitAsyncStorage:j,serverHooks:C}=_;async function E(e,t,a){a.requestMeta&&(0,s.setRequestMeta)(e,a.requestMeta),_.isDev&&(0,s.addRequestMeta)(e,"devRequestTimingInternalsEnd",process.hrtime.bigint());let y="/api/proxy-pools/cloudflare-deploy/route";y=y.replace(/\/index$/,"")||"/";let R=await _.prepare(e,t,{srcPage:y,multiZoneDraftMode:!1});if(!R)return t.statusCode=400,t.end("Bad Request"),null==a.waitUntil||a.waitUntil.call(a,Promise.resolve()),null;let{buildId:w,deploymentId:g,params:b,nextConfig:P,parsedUrl:j,isDraftMode:C,prerenderManifest:E,routerServerContext:k,isOnDemandRevalidate:q,revalidateOnlyGenerated:A,resolvedPathname:N,clientReferenceManifest:T,serverActionsManifest:S}=R,O=(0,i.normalizeAppPath)(y),I=!!(E.dynamicRoutes[O]||E.routes[N]),U=async()=>((null==k?void 0:k.render404)?await k.render404(e,t,j,!1):t.end("This page could not be found"),null);if(I&&!C){let e=!!E.routes[N],t=E.dynamicRoutes[O];if(t&&!1===t.fallback&&!e){if(P.adapterPath)return await U();throw new x.NoFallbackError}}let $=null;!I||_.isDev||C||($="/index"===($=N)?"/":$);let D=!0===_.isDev||!I,H=I&&!D;S&&T&&(0,n.setManifestsSingleton)({page:y,clientReferenceManifest:T,serverActionsManifest:S});let M=e.method||"GET",B=(0,o.getTracer)(),F=B.getActiveScopeSpan(),K=!!(null==k?void 0:k.isWrappedByNextServer),z=!!(0,s.getRequestMeta)(e,"minimalMode"),G=(0,s.getRequestMeta)(e,"incrementalCache")||await _.getIncrementalCache(e,P,E,z);null==G||G.resetRequestCache(),globalThis.__incrementalCache=G;let L={params:b,previewProps:E.preview,renderOpts:{experimental:{authInterrupts:!!P.experimental.authInterrupts},cacheComponents:!!P.cacheComponents,supportsDynamicResponse:D,incrementalCache:G,cacheLifeProfiles:P.cacheLife,waitUntil:a.waitUntil,onClose:e=>{t.on("close",e)},onAfterTaskError:void 0,onInstrumentationRequestError:(t,r,a,s)=>_.onRequestError(e,t,a,s,k)},sharedContext:{buildId:w,deploymentId:g}},W=new l.NodeNextRequest(e),J=new l.NodeNextResponse(t),V=d.NextRequestAdapter.fromNodeNextRequest(W,(0,d.signalFromNodeResponse)(t));try{let s,n=async e=>_.handle(V,L).finally(()=>{if(!e)return;e.setAttributes({"http.status_code":t.statusCode,"next.rsc":!1});let r=B.getRootSpanAttributes();if(!r)return;if(r.get("next.span_type")!==u.BaseServerSpan.handleRequest)return void console.warn(`Unexpected root span type '${r.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let a=r.get("next.route");if(a){let t=`${M} ${a}`;e.setAttributes({"next.route":a,"http.route":a,"next.span_name":t}),e.updateName(t),s&&s!==e&&(s.setAttribute("http.route",a),s.updateName(t))}else e.updateName(`${M} ${y}`)}),i=async s=>{var o,i;let l=async({previousCacheEntry:r})=>{try{if(!z&&q&&A&&!r)return t.statusCode=404,t.setHeader("x-nextjs-cache","REVALIDATED"),t.end("This page could not be found"),null;let o=await n(s);e.fetchMetrics=L.renderOpts.fetchMetrics;let i=L.renderOpts.pendingWaitUntil;i&&a.waitUntil&&(a.waitUntil(i),i=void 0);let l=L.renderOpts.collectedTags;if(!I)return await (0,c.sendResponse)(W,J,o,L.renderOpts.pendingWaitUntil),null;{let e=await o.blob(),t=(0,h.toNodeOutgoingHttpHeaders)(o.headers);l&&(t[m.NEXT_CACHE_TAGS_HEADER]=l),!t["content-type"]&&e.type&&(t["content-type"]=e.type);let r=void 0!==L.renderOpts.collectedRevalidate&&!(L.renderOpts.collectedRevalidate>=m.INFINITE_CACHE)&&L.renderOpts.collectedRevalidate,a=void 0===L.renderOpts.collectedExpire||L.renderOpts.collectedExpire>=m.INFINITE_CACHE?void 0:L.renderOpts.collectedExpire;return{value:{kind:f.CachedRouteKind.APP_ROUTE,status:o.status,body:Buffer.from(await e.arrayBuffer()),headers:t},cacheControl:{revalidate:r,expire:a}}}}catch(t){throw(null==r?void 0:r.isStale)&&await _.onRequestError(e,t,{routerKind:"App Router",routePath:y,routeType:"route",revalidateReason:(0,p.getRevalidateReason)({isStaticGeneration:H,isOnDemandRevalidate:q})},!1,k),t}},d=await _.handleResponse({req:e,nextConfig:P,cacheKey:$,routeKind:r.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:E,isRoutePPREnabled:!1,isOnDemandRevalidate:q,revalidateOnlyGenerated:A,responseGenerator:l,waitUntil:a.waitUntil,isMinimalMode:z});if(!I)return null;if((null==d||null==(o=d.value)?void 0:o.kind)!==f.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==d||null==(i=d.value)?void 0:i.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});z||t.setHeader("x-nextjs-cache",q?"REVALIDATED":d.isMiss?"MISS":d.isStale?"STALE":"HIT"),C&&t.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let u=(0,h.fromNodeOutgoingHttpHeaders)(d.value.headers);return z&&I||u.delete(m.NEXT_CACHE_TAGS_HEADER),!d.cacheControl||t.getHeader("Cache-Control")||u.get("Cache-Control")||u.set("Cache-Control",(0,v.getCacheControlHeader)(d.cacheControl)),await (0,c.sendResponse)(W,J,new Response(d.value.body,{headers:u,status:d.value.status||200})),null};K&&F?await i(F):(s=B.getActiveScopeSpan(),await B.withPropagatedContext(e.headers,()=>B.trace(u.BaseServerSpan.handleRequest,{spanName:`${M} ${y}`,kind:o.SpanKind.SERVER,attributes:{"http.method":M,"http.target":e.url}},i),void 0,!K))}catch(t){if(t instanceof x.NoFallbackError||await _.onRequestError(e,t,{routerKind:"App Router",routePath:O,routeType:"route",revalidateReason:(0,p.getRevalidateReason)({isStaticGeneration:H,isOnDemandRevalidate:q})},!1,k),I)throw t;return await (0,c.sendResponse)(W,J,new Response(null,{status:500})),null}}e.s(["handler",0,E,"patchFetch",0,function(){return(0,a.patchFetch)({workAsyncStorage:P,workUnitAsyncStorage:j})},"routeModule",0,_,"serverHooks",0,C,"workAsyncStorage",0,P,"workUnitAsyncStorage",0,j],697793)},603283,e=>{e.v(t=>Promise.all(["server/chunks/[root-of-the-server]__01t5og.._.js"].map(t=>e.l(t))).then(()=>t(227359)))},255840,e=>{e.v(t=>Promise.all(["server/chunks/[root-of-the-server]__0slucb~._.js"].map(t=>e.l(t))).then(()=>t(317026)))},654059,e=>{e.v(t=>Promise.all(["server/chunks/src_lib_db_0q087i2._.js"].map(t=>e.l(t))).then(()=>t(72167)))},287292,e=>{e.v(t=>Promise.all(["server/chunks/[root-of-the-server]__0~p~am2._.js"].map(t=>e.l(t))).then(()=>t(344805)))},149047,e=>{e.v(t=>Promise.all(["server/chunks/src_lib_db_03zbn-s._.js"].map(t=>e.l(t))).then(()=>t(177498)))},936498,e=>{e.v(t=>Promise.all(["server/chunks/[root-of-the-server]__0kaoh2i._.js"].map(t=>e.l(t))).then(()=>t(321297)))},866510,e=>{e.v(t=>Promise.all(["server/chunks/src_shared_constants_pricing_0oa_fz9.js"].map(t=>e.l(t))).then(()=>t(722503)))},555812,e=>{e.v(e=>Promise.resolve().then(()=>e(284904)))},552465,e=>{e.v(e=>Promise.resolve().then(()=>e(278199)))},43476,e=>{e.v(e=>Promise.resolve().then(()=>e(739080)))},224847,e=>{e.v(e=>Promise.resolve().then(()=>e(866951)))},378161,e=>{e.v(e=>Promise.resolve().then(()=>e(192561)))}];

//# sourceMappingURL=%5Broot-of-the-server%5D__0_lu~zw._.js.map