function AppComm(){function r(){i(),s()}function i(){}function s(){isAndroid&&$(window).on("online offline",function(e){l()})}function o(e,n){setTimeout(function(){a(e,n),e.id=t,++t,showDebug==2&&console.log("appSend: "+JSON.stringify(e));if(isBrowser&&e.method!="getNetStats"){typeof n=="function"&&n();return}f(e)},0)}function u(t){console.log("appRec payload: "),console.log(t);if(t.params!=undefined)if(t.method=="devices"&&t.params.length>0){var n="[";for(var r=0;r<t.params.length;r++)r>0&&(n+=", "),n+="("+t.params[r].uID+", "+t.params[r].ip+")";n+="]",showDebug==2&&console.log("appReceive: "+t.id+"(id) / "+t.method+" / "+n+"(devices) / "+t.result+"(result)")}else showDebug==2&&console.log("appReceive: "+t.id+"(id) / "+t.method+" / "+t.params.length+"(params length) / "+t.result+"(result)");else showDebug==2&&console.log("appReceive: "+t.id+"(id) / "+t.method+" / "+t.result+"(result)");setTimeout(function(){try{if(t.method)c("appReceive (method:"+t.method+")"),t.error!=null&&t.error!=""?funcObj.setupWizard.appcomm_error(t):funcObj.setupWizard.appcomm_receive(t);else{t.error!=null&&t.error!=""&&funcObj.setupWizard.appcomm_error(t);if(!e[t.id]){c("appReceive FAILED (callback index not found)");return}var n=t.id,r=t.result;c("appReceive (result:"+t.result+")");var i=e[t.id];i.callback.call(null,t.result),delete e[t.id]}}catch(s){c("appReceive MESSAGE ERROR: "+s)}},0)}function a(n,r){typeof r=="function"&&(e[t]={},e[t].payload=n,e[t].callback=r)}function f(e){showDebug==2&&(isQT?console.log("STOCKHOLM -> NATIVE - Payload: "+JSON.stringify(e)):console.log("STOCKHOLM -> NATIVE",e));if(isBrowser)return;if(isQT)showDebug==2&&console.log("Setup: Using qtSetupNativeObj to send AppComm\n"),qtSetupNativeObj.appSend(JSON.stringify(e));else if(isIOS)if(wkWebView)window.webkit.messageHandlers.jsHandler.postMessage(encodeURIComponent(JSON.stringify(e)));else{var t=document.createElement("IFRAME");t.setAttribute("src","appSend:"+encodeURIComponent(JSON.stringify(e))),document.documentElement.appendChild(t),t.parentNode.removeChild(t),t=null}else isAndroid&&Native.appSend(JSON.stringify(e))}function l(){if(typeof Native!="undefined"){var e=Native.runQueue();if(e!=null){var t=JSON.parse(e);t.messages!=null&&$.each(t.messages,function(e,t){u(t)})}}}function c(e){console.log(e)}var e={},t=0,n={};this.appSend=o,this.appReceive=u,r()};