Active line conditioner for bidirectional power flow between AC mains and indipendent producers