acc[n.name] = acc[n.name] || { ...n, qty: 0 }
PHP doesn’t support the Base64URL standard, but you can use built-in functions to normalize values. The only thing you have to change is to replace 62-63 index characters. More exactly, you should use “-” instead of “+” and “_” instead of “/”.
const n = [12].reduce((acc, i) => i + 1)
вернет константу 12 или, после исправления - 13.