{"version":3,"file":"format-resizing-response.cjs","sources":["../../src/images/format-resizing-response.ts"],"sourcesContent":["import { applyHeaders, createMutableResponse } from '@/router/http';\n\nimport type { ImagesConfig } from './types';\n\n/**\n * Formats the given response to match the images configuration spec from the build output\n * config.\n *\n * Applies headers for `Content-Security-Policy` and `Content-Disposition`, if defined in the config.\n *\n * https://vercel.com/docs/build-output-api/v3/configuration#images\n *\n * @param resp Response to format.\n * @param imageUrl Image URL that was resized.\n * @param config Images configuration from the build output.\n * @returns Formatted response.\n */\nexport const formatResizingResponse = (\n\tresp: Response,\n\timageUrl: URL,\n\tconfig?: ImagesConfig,\n): Response => {\n\tconst newHeaders = new Headers();\n\n\tif (config?.contentSecurityPolicy) {\n\t\tnewHeaders.set('Content-Security-Policy', config.contentSecurityPolicy);\n\t}\n\n\tif (config?.contentDispositionType) {\n\t\tconst fileName = imageUrl.pathname.split('/').pop();\n\t\tconst contentDisposition = fileName\n\t\t\t? `${config.contentDispositionType}; filename=\"${fileName}\"`\n\t\t\t: config.contentDispositionType;\n\n\t\tnewHeaders.set('Content-Disposition', contentDisposition);\n\t}\n\n\tif (!resp.headers.has('Cache-Control')) {\n\t\t// Fall back to the minimumCacheTTL value if there is no Cache-Control header.\n\t\t// https://vercel.com/docs/concepts/image-optimization#caching\n\t\tnewHeaders.set('Cache-Control', `public, max-age=${config?.minimumCacheTTL ?? 60}`);\n\t}\n\n\tconst mutableResponse = createMutableResponse(resp);\n\tapplyHeaders(mutableResponse.headers, newHeaders);\n\n\treturn mutableResponse;\n};\n"],"names":["formatResizingResponse","resp","imageUrl","config","newHeaders","fileName","contentDisposition","mutableResponse","createMutableResponse","applyHeaders"],"mappings":"4LAiBaA,EAAyB,CACrCC,EACAC,EACAC,IACc,CACR,MAAAC,EAAa,IAAI,QAMvB,GAJID,GAAA,MAAAA,EAAQ,uBACAC,EAAA,IAAI,0BAA2BD,EAAO,qBAAqB,EAGnEA,GAAA,MAAAA,EAAQ,uBAAwB,CACnC,MAAME,EAAWH,EAAS,SAAS,MAAM,GAAG,EAAE,MACxCI,EAAqBD,EACxB,GAAGF,EAAO,sBAAsB,eAAeE,CAAQ,IACvDF,EAAO,uBAECC,EAAA,IAAI,sBAAuBE,CAAkB,CACzD,CAEKL,EAAK,QAAQ,IAAI,eAAe,GAGpCG,EAAW,IAAI,gBAAiB,oBAAmBD,GAAA,YAAAA,EAAQ,kBAAmB,EAAE,EAAE,EAG7E,MAAAI,EAAkBC,wBAAsBP,CAAI,EACrCQ,OAAAA,EAAAA,aAAAF,EAAgB,QAASH,CAAU,EAEzCG,CACR"}