0

JavaScript, 449 bytes
x=>{for([...x].reduce((_,b)=>"({[<".includes(b)?(y.unshift([b,--i+"#"]),y[1].push(y[0])):(b==")"&&y[0].length>2&&j.push(y[0][1]),x=y.shift()).push(b=="}"&&x.length==2?b+(j.pop()||"-0#"):b),y=[[]],i=0,j=[]),y=y[0].reduce(g=(a,b)=>b.length>3?a+b[0]+b[1]+b.slice(2,-1).reduce(g,""...