import type { NzSafeAny } from 'ng-zorro-antd/core/types' ; export function urlBase64Decode ( str ) { let output = str . replace ( /-/g , '+' ) . replace ( /_/g , '/' ) ; switch ( output . length % 4 ) { case 0 : { break ; } case 2 : { output += '==' ; break ; } case 3 : { output += '=' ; break ; } default : { throw new Error ( `'atob' failed: The string to be decoded is not correctly encoded.` ) ; } } return b64DecodeUnicode ( output ) ; } function b64decode ( str ) { const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=' ; let output = '' ; str = String ( str ) . replace ( /=+$/ , '' ) ; for ( let bc = 0 , bs , buffer , idx = 0 ; ( buffer = str . charAt ( idx ++ ) ) ; ~ buffer && ( ( bs = bc % 4 ? bs * 64 + buffer : buffer ) , bc ++ % 4 ) ? ( output += String . fromCharCode ( 255 & ( bs >> ( ( - 2 * bc ) & 6 ) ) ) ) : 0 ) { buffer = chars . indexOf ( buffer ) ; } return output ; } function b64DecodeUnicode ( str ) { return decodeURIComponent ( Array . prototype . map . call ( b64decode ( str ) , ( c ) => { return `%${ `00${ c . charCodeAt ( 0 ) . toString ( 16 ) }` . slice ( - 2 ) }` ; } ) . join ( '' ) ) ; }