{"version":3,"file":"downloadFile.mjs","sources":["../../../../admin/src/future/utils/downloadFile.ts"],"sourcesContent":["/**\n * Fetch a file at `url` and trigger a browser download with the given filename.\n * Goes via a blob + temporary anchor so we honour the `download` attribute\n * even when the file is served same-origin without `Content-Disposition`.\n */\nexport const downloadFile = async (url: string, fileName: string) => {\n const response = await fetch(url);\n const blob = await response.blob();\n const objectUrl = window.URL.createObjectURL(blob);\n const anchor = document.createElement('a');\n anchor.href = objectUrl;\n anchor.setAttribute('download', fileName);\n anchor.click();\n window.URL.revokeObjectURL(objectUrl);\n};\n"],"names":["downloadFile","url","fileName","response","fetch","blob","objectUrl","window","URL","createObjectURL","anchor","document","createElement","href","setAttribute","click","revokeObjectURL"],"mappings":"AAAA;;;;AAIC,IACM,MAAMA,YAAAA,GAAe,OAAOC,GAAAA,EAAaC,QAAAA,GAAAA;IAC9C,MAAMC,QAAAA,GAAW,MAAMC,KAAAA,CAAMH,GAAAA,CAAAA;IAC7B,MAAMI,IAAAA,GAAO,MAAMF,QAAAA,CAASE,IAAI,EAAA;AAChC,IAAA,MAAMC,SAAAA,GAAYC,MAAAA,CAAOC,GAAG,CAACC,eAAe,CAACJ,IAAAA,CAAAA;IAC7C,MAAMK,MAAAA,GAASC,QAAAA,CAASC,aAAa,CAAC,GAAA,CAAA;AACtCF,IAAAA,MAAAA,CAAOG,IAAI,GAAGP,SAAAA;IACdI,MAAAA,CAAOI,YAAY,CAAC,UAAA,EAAYZ,QAAAA,CAAAA;AAChCQ,IAAAA,MAAAA,CAAOK,KAAK,EAAA;IACZR,MAAAA,CAAOC,GAAG,CAACQ,eAAe,CAACV,SAAAA,CAAAA;AAC7B;;;;"}