export function openPdfBlob(blob: Blob, filename: string, targetWindow?: Window | null) { const url = URL.createObjectURL(blob); if (targetWindow && !targetWindow.closed) { targetWindow.location.href = url; setTimeout(() => URL.revokeObjectURL(url), 60_000); return true; } const opened = window.open(url, '_blank'); if (opened) { setTimeout(() => URL.revokeObjectURL(url), 60_000); return true; } const a = document.createElement('a'); a.href = url; a.download = filename; document.body.appendChild(a); a.click(); a.remove(); URL.revokeObjectURL(url); return false; }