define([
    'jquery',
    'mage/utils/wrapper',
    'Magento_Checkout/js/model/quote'
], function ($, wrapper, quote) {
    'use strict';

    return function (setPaymentInformationAction) {
        return wrapper.wrap(setPaymentInformationAction, function (originalAction) {
            var billingAddress = quote.billingAddress();

            if(billingAddress && typeof billingAddress['street'] == 'object' && billingAddress['street'].length > 2)
            {
            	//check if already combined
            	if(!billingAddress['street'][0].trim().endsWith(billingAddress['street'][2].trim()))
            	{
            		//combine street and "housenumber"
            		billingAddress['street'][0] = billingAddress['street'][0].trim() + ' ' + billingAddress['street'][2].trim();
            	}
            	billingAddress['street'].splice(2, 1);            	
            }

            // pass execution to original action ('Magento_Checkout/js/action/set-shipping-information')
            return originalAction();
        });
    };
});