function AddDevicesToAccount(){function r(){}function i(){return e}function s(){return n}function o(){showDebug==2&&console.log("add_devices_to_marge_after_rename: "+i);var r=funcObj.RenameDevices.get_devices_in_rename_screen();e=new Array,t=new Array;var i=funcObj.setupWizard.get_bose_accountID(),s=funcObj.setupWizard.get_bose_userAuthToken();for(var o=0;o<r.length;o++){var f=r[o].uID;i!=undefined?e.push(r[o]):n.push(f)}if(e.length>0){funcObj.setupWizard.set_adding_devices_to_marge(!0);var l="setMargeAccount",c=["<PairDeviceWithAccount><accountId>"+i+"</accountId><userAuthToken>"+s+"</userAuthToken></PairDeviceWithAccount>"],h,p=u,d=a,v=e,m=t,g=!1;funcObj.WebsocketController.do_obtrusive_websocket_action(l,c,h,p,d,v,m,g)}else funcObj.RenameDevices.redirect_away_from_name_devices()}function u(e,t,n,r,i){var s=funcObj.setupWizard.get_adding_devices_to_marge();if(s)switch($(r).find("error").attr("value")){case"1038":default:funcObj.setupWizard.set_popup("cant_associate_devices")}}function a(e,t,n,r){var i=funcObj.setupWizard.get_adding_devices_to_marge();i&&(funcObj.setupWizard.device_arrays_match(e,t)?h():n.length>0||r.length>0&&h())}function f(){funcObj.setupWizard.set_adding_saved_devices_to_marge(!0);if(n.length>0){e=new Array;for(var r=0;r<n.length;r++){var i=n[r],s=funcObj.devCon.getDevice(i);e.push(s)}t=new Array;var o=funcObj.setupWizard.get_bose_accountID(),u=funcObj.setupWizard.get_bose_userAuthToken(),a="setMargeAccount",f=["<PairDeviceWithAccount><accountId>"+o+"</accountId><userAuthToken>"+u+"</userAuthToken></PairDeviceWithAccount>"],p,d=l,v=c,m=e,g=t,y=!1;funcObj.WebsocketController.do_obtrusive_websocket_action(a,f,p,d,v,m,g,y)}else h()}function l(e,t,n,r,i){var s=funcObj.setupWizard.get_adding_saved_devices_to_marge();if(s)switch($(r).find("error").attr("value")){case"1038":default:funcObj.setupWizard.set_popup("cant_associate_devices")}}function c(e,t,n,r){var i=funcObj.setupWizard.get_adding_saved_devices_to_marge();i&&(funcObj.setupWizard.device_arrays_match(e,t)?h():n.length>0||r.length>0&&h())}function h(){showDebug==2&&console.log("add_devices_done"),n=new Array;var e=funcObj.setupWizard.get_adding_devices_to_marge(),t=funcObj.setupWizard.get_adding_saved_devices_to_marge();if(e)funcObj.setupWizard.set_adding_devices_to_marge(!1),funcObj.setupWizard.retrieveDeviceList(),funcObj.RenameDevices.redirect_away_from_name_devices();else if(t){funcObj.setupWizard.set_adding_saved_devices_to_marge(!1),funcObj.setupWizard.retrieveDeviceList();var r=funcObj.setupWizard.get_most_recent_page_name(["bose_sign_in","create_bose_account","bose_account_sign_in_temp"]),i=funcObj.setupWizard.get_show_discovery_issue_success_popup(),s=funcObj.setupWizard.get_discovery_network_error();switch(r){case"bose_sign_in":case"bose_account_sign_in_temp":i?s?funcObj.setupWizard.set_popup("app_block_ip_success"):funcObj.setupWizard.set_popup("no_block_ip_success"):funcObj.MargeComm.exit_sign_in_workflow();break;case"create_bose_account":i?s?funcObj.setupWizard.set_popup("app_block_ip_success"):funcObj.setupWizard.set_popup("no_block_ip_success"):funcObj.MargeComm.exit_create_account_workflow();break;case"":showDebug==2&&console.log("add_devices_done: no previous page found")}}}function p(){funcObj.setupWizard.exit_setup()}var e=new Array,t=new Array,n=new Array;this.add_devices_to_marge_after_rename=o,this.add_saved_devices_to_marge=f,this.add_devices_cant_associate=p,this.get_devices_being_added=i,this.get_devices_to_add_to_marge=s,r()};