// saveFileFromBlob.ts
const saveFileFromBlob = (blob, filename) => {
    if (!blob || !(blob instanceof Blob)) {
        console.error('Invalid Blob object');
        throw new Error('Invalid Blob object');
    }
    const navigatorWithMsSaveBlob = window.navigator;
    if (navigatorWithMsSaveBlob.msSaveOrOpenBlob) {
        const saveBlob = navigatorWithMsSaveBlob.msSaveOrOpenBlob;
        if (saveBlob) {
            saveBlob(blob, filename);
        }
    }
    else {
        // For modern browsers
        const anchorElement = document.createElement('a');
        document.body.appendChild(anchorElement);
        const objectURL = window.URL.createObjectURL(blob);
        anchorElement.href = objectURL;
        anchorElement.download = filename;
        anchorElement.click();
        setTimeout(() => {
            window.URL.revokeObjectURL(objectURL);
            document.body.removeChild(anchorElement);
        }, 0);
    }
};

export { saveFileFromBlob };
//# sourceMappingURL=saveFileFromBlob.js.map
