"use strict";(()=>{var e={};e.id=352,e.ids=[352],e.modules={20399:e=>{e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},30517:e=>{e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},12011:(e,o,t)=>{t.r(o),t.d(o,{originalPathname:()=>A,patchFetch:()=>E,requestAsyncStorage:()=>P,routeModule:()=>p,serverHooks:()=>h,staticGenerationAsyncStorage:()=>O});var r={};t.r(r),t.d(r,{GET:()=>u,OPTIONS:()=>d,POST:()=>N,dynamic:()=>l});var n=t(49303),s=t(88716),a=t(60670),c=t(87070);let l="force-dynamic",i="https://bsky.social";async function N(e){try{let o=(await e.json()).pdsEndpoint||i,t=o;o.includes("bsky.social")||(console.log("[NONCE API] Redirecting to bsky.social for OAuth on third-party PDS"),t=i);let r=`${t}/oauth/token`;console.log(`[NONCE API] Attempting to get nonce from: ${r}`);let n=null;try{console.log(`[NONCE API] Trying HEAD request to ${r}`),(n=(await fetch(r,{method:"HEAD",headers:{Accept:"*/*"}})).headers.get("DPoP-Nonce"))&&console.log(`[NONCE API] Got nonce via HEAD request: ${n}`)}catch(e){console.warn("[NONCE API] HEAD request failed:",e)}if(!n)try{console.log(`[NONCE API] Trying OPTIONS request to ${r}`),(n=(await fetch(r,{method:"OPTIONS",headers:{Accept:"*/*"}})).headers.get("DPoP-Nonce"))&&console.log(`[NONCE API] Got nonce via OPTIONS request: ${n}`)}catch(e){console.warn("[NONCE API] OPTIONS request failed:",e)}if(!n)try{console.log(`[NONCE API] Trying POST probe to ${r}`),(n=(await fetch(r,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({})})).headers.get("DPoP-Nonce"))&&console.log(`[NONCE API] Got nonce via POST probe: ${n}`)}catch(e){console.warn("[NONCE API] POST probe failed:",e)}if(n)return c.NextResponse.json({nonce:n});return console.log(`[NONCE API] All methods failed to get a nonce from ${r}`),c.NextResponse.json({error:"Could not retrieve nonce",endpoint:r},{status:404})}catch(e){return console.error("[NONCE API] Nonce retrieval error:",e),c.NextResponse.json({error:"Nonce retrieval error",message:e.message},{status:500})}}async function u(){try{let e=`${i}/oauth/token`;console.log(`[NONCE API] GET: Attempting to get nonce from: ${e}`);let o=null;try{console.log(`[NONCE API] GET: Trying HEAD request to ${e}`),(o=(await fetch(e,{method:"HEAD",headers:{Accept:"*/*"}})).headers.get("DPoP-Nonce"))&&console.log(`[NONCE API] GET: Got nonce via HEAD request: ${o}`)}catch(e){console.warn("[NONCE API] GET: HEAD request failed:",e)}if(!o)try{console.log(`[NONCE API] GET: Trying OPTIONS request to ${e}`),(o=(await fetch(e,{method:"OPTIONS",headers:{Accept:"*/*"}})).headers.get("DPoP-Nonce"))&&console.log(`[NONCE API] GET: Got nonce via OPTIONS request: ${o}`)}catch(e){console.warn("[NONCE API] GET: OPTIONS request failed:",e)}if(!o)try{console.log(`[NONCE API] GET: Trying POST probe to ${e}`),(o=(await fetch(e,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({})})).headers.get("DPoP-Nonce"))&&console.log(`[NONCE API] GET: Got nonce via POST probe: ${o}`)}catch(e){console.warn("[NONCE API] GET: POST probe failed:",e)}if(o)return c.NextResponse.json({nonce:o});return console.log(`[NONCE API] GET: All methods failed to get a nonce from ${e}`),c.NextResponse.json({error:"Could not retrieve nonce",endpoint:e},{status:404})}catch(e){return console.error("[NONCE API] GET: Nonce retrieval error:",e),c.NextResponse.json({error:"Nonce retrieval error",message:e.message},{status:500})}}async function d(){return new c.NextResponse(null,{status:200,headers:{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET, OPTIONS","Access-Control-Allow-Headers":"Content-Type"}})}let p=new n.AppRouteRouteModule({definition:{kind:s.x.APP_ROUTE,page:"/api/auth/nonce/route",pathname:"/api/auth/nonce",filename:"route",bundlePath:"app/api/auth/nonce/route"},resolvedPagePath:"/Users/dame/Library/Mobile Documents/com~apple~CloudDocs/Software/flushes/app/src/app/api/auth/nonce/route.ts",nextConfigOutput:"standalone",userland:r}),{requestAsyncStorage:P,staticGenerationAsyncStorage:O,serverHooks:h}=p,A="/api/auth/nonce/route";function E(){return(0,a.patchFetch)({serverHooks:h,staticGenerationAsyncStorage:O})}}};var o=require("../../../../webpack-runtime.js");o.C(e);var t=e=>o(o.s=e),r=o.X(0,[276,972],()=>t(12011));module.exports=r})();