import{u as e}from"./index.js";import{u as t}from"./global.js";var n=1,o=2,r=3,a=4,i=5,c=6,s=7,_=8,p=9,d=10,l=function(e,t){if("object"==typeof e&&"function"==typeof e.send){var c=this;this.transport=e,this.send=function(e){"string"!=typeof e&&(e=JSON.stringify(e)),c.transport.send(e)},this.transport.onmessage=function(e){var t=e.data;switch("string"==typeof t&&(t=JSON.parse(t)),t.type){case n:c.handleSignal(t);break;case d:c.handleResponse(t);break;case o:c.handlePropertyUpdate(t);break;default:console.error("invalid message received:",e.data)}},this.execCallbacks={},this.execId=0,this.exec=function(e,t){t?(c.execId===Number.MAX_VALUE&&(c.execId=Number.MIN_VALUE),e.hasOwnProperty("id")?console.error("Cannot exec message with property id: "+JSON.stringify(e)):(e.id=c.execId++,c.execCallbacks[e.id]=t,c.send(e))):c.send(e)},this.objects={},this.handleSignal=function(e){var t=c.objects[e.object];t?t.signalEmitted(e.signal,e.args):console.warn("Unhandled signal: "+e.object+"::"+e.signal)},this.handleResponse=function(e){e.hasOwnProperty("id")?(c.execCallbacks[e.id](e.data),delete c.execCallbacks[e.id]):console.error("Invalid response message received: ",JSON.stringify(e))},this.handlePropertyUpdate=function(e){for(var t in e.data){var n=e.data[t],o=c.objects[n.object];o?o.propertyUpdate(n.signals,n.properties):console.warn("Unhandled property update: "+n.object+"::"+n.signal)}c.exec({type:a})},this.debug=function(e){c.send({type:i,data:e})},c.exec({type:r},(function(e){for(var n in e)new f(n,e[n],c);for(const t in c.objects)c.objects[t].unwrapProperties();t&&t(c),c.exec({type:a})}))}else console.error("The QWebChannel expects a transport object with a send function and onmessage callback property. Given is: transport: "+typeof e+", transport.send: "+typeof e.send)};function f(e,t,n){this.__id__=e,n.objects[e]=this,this.__objectSignals__={},this.__propertyCache__={};var o=this;function r(e,t){var r=e[0],a=e[1];o[r]={connect:function(e){"function"==typeof e?(o.__objectSignals__[a]=o.__objectSignals__[a]||[],o.__objectSignals__[a].push(e),t||"destroyed"===r||n.exec({type:s,object:o.__id__,signal:a})):console.error("Bad callback given to connect to signal "+r)},disconnect:function(e){if("function"==typeof e){o.__objectSignals__[a]=o.__objectSignals__[a]||[];var i=o.__objectSignals__[a].indexOf(e);-1!==i?(o.__objectSignals__[a].splice(i,1),t||0!==o.__objectSignals__[a].length||n.exec({type:_,object:o.__id__,signal:a})):console.error("Cannot find connection of signal "+r+" to "+e.name)}else console.error("Bad callback given to disconnect from signal "+r)}}}function a(e,t){var n=o.__objectSignals__[e];n&&n.forEach((function(e){e.apply(e,t)}))}for(var i in this.unwrapQObject=function(e){if(e instanceof Array){for(var t=new Array(e.length),r=0;r<e.length;++r)t[r]=o.unwrapQObject(e[r]);return t}if(!e||!e["__QObject*__"]||void 0===e.id)return e;var a=e.id;if(n.objects[a])return n.objects[a];if(e.data){var i=new f(a,e.data,n);return i.destroyed.connect((function(){if(n.objects[a]===i){delete n.objects[a];var e=[];for(var t in i)e.push(t);for(var o in e)delete i[e[o]]}})),i.unwrapProperties(),i}console.error("Cannot unwrap unknown QObject "+a+" without data.")},this.unwrapProperties=function(){for(var e in o.__propertyCache__)o.__propertyCache__[e]=o.unwrapQObject(o.__propertyCache__[e])},this.propertyUpdate=function(e,t){for(var n in t){var r=t[n];o.__propertyCache__[n]=r}for(var i in e)a(i,e[i])},this.signalEmitted=function(e,t){a(e,t)},t.methods.forEach((function(e){var t=e[0],r=e[1];o[t]=function(){for(var e,t=[],a=0;a<arguments.length;++a)"function"==typeof arguments[a]?e=arguments[a]:t.push(arguments[a]);n.exec({type:c,object:o.__id__,method:r,args:t},(function(t){if(void 0!==t){var n=o.unwrapQObject(t);e&&e(n)}}))}})),t.properties.forEach((function(e){var t=e[0],a=e[1],i=e[2];o.__propertyCache__[t]=e[3],i&&(1===i[0]&&(i[0]=a+"Changed"),r(i,!0)),Object.defineProperty(o,a,{configurable:!0,get:function(){var e=o.__propertyCache__[t];return void 0===e&&console.warn('Undefined value in property cache for property "'+a+'" in object '+o.__id__),e},set:function(e){void 0!==e?(o.__propertyCache__[t]=e,n.exec({type:p,object:o.__id__,property:t,value:e})):console.warn("Property setter for "+a+" called with undefined value!")}})})),t.signals.forEach((function(e){r(e,!1)})),t.enums)o[i]=t.enums[i]}const u={__name:"index",setup(n){const o=e(),r=t();return new l(qt.webChannelTransport,(function(e){r.chatQWeb=e.objects.chatObject,r.updateActivityColor(r.chatQWeb.activeColor),r.updateTheme(r.chatQWeb.themeType),o.replace({name:"Chat"})})),(e,t)=>null}};export{u as default};
