mukulhase / WebWhatsapp-Wrapper

An API for sending and receiving messages over web.whatsapp [Working as of 18th May 2018]
https://webwhatsapi.readthedocs.io/en/latest/
MIT License
2.03k stars 797 forks source link

Project WebInstramWrapper #865

Closed 3dluis closed 4 years ago

3dluis commented 4 years ago

We can work a project for instagram (since direct messenger influenced the web recently), making a code injection in script to create an API, such as this project.

window.mqtt.sendTextMessage() window.mqtt.sendLike() window.__mqtt.sendMediaShare()

sendTextMessage(t, s, T) { return this.$DirectMQTT14({ action: 'send_item', item_type: r(d[13]).ThreadItemType.TEXT, mutation_token: T, text: s, thread_id: t }) } sendMediaShare(t, s) { return this.$DirectMQTT14({ action: 'send_item', item_type: r(d[13]).ThreadItemType.MEDIA_SHARE, media_id: s, thread_id: t }) } sendLike(t, s) { return this.$DirectMQTT14({ action: 'send_item', item_type: r(d[13]).ThreadItemType.LIKE, mutation_token: s, thread_id: t }) }

image

3dluis commented 4 years ago

Example https://github.com/instagrambot/instabot, but it is not inject script on web. It is a project based on device emulation and it is very easy to detect that it is an unofficial code.

__d(function(g, r, i, a, m, e, d) { "use strict"; Object.defineProperty(e, '__esModule', { value: !0 }); const t = 20; e.DirectMQTT = class { constructor(s, T) { this.$DirectMQTT11 = (s => { const T = i(d[0])(this.$DirectMQTT2); let c; try { c = JSON.parse(s) } catch (t) { return void this.$DirectMQTT1.logError(Could not parse ${s}, t) } Array.isArray(c) ? i(d[1])(i(d[2])(c, t), t => { r(d[3]).batch(() => { for (const s of t) { const { data: t, event: c, mutation_token: n, seq_id: h } = s; if (this.$DirectMQTT1.debugTrace('parsed_message', { event: c, mutation_token: n }), 'patch' !== c) return void this.$DirectMQTT1.debugTrace('skipped_message', { event: c }); if (!Array.isArray(t)) return void this.$DirectMQTT1.debugTrace('parsed_message_bad_operations', typeof t); for (const s of t) T.handleDelta(s, n); if (h) { const t = this.$DirectMQTT3.subscription_type; this.$DirectMQTT1.debugTrace('seq_id', { seq_id: h, subscriptionType: t }), 'message' === t && T.onSeqIdUpdated(h) } } }) }) : this.$DirectMQTT1.debugTrace('parsed_message_not_array', typeof c) }), this.$DirectMQTT12 = (t => { try { const s = JSON.parse(t); 'ok' === s.status ? this.$DirectMQTT1.logDirectEvent('send_message_response_success', s) : this.$DirectMQTT1.logError('send_message_response_failed', s) } catch (t) { this.$DirectMQTT1.logError('send_message_response_parse_failed', t) } }), this.$DirectMQTT13 = (t => { this.$DirectMQTT1.debugTrace('state_changed', t); const s = i(d[0])(this.$DirectMQTT2); if ('Connected' === t) { const t = i(d[0])(this.$DirectMQTT5); t.subscribe('/ig_message_sync', this.$DirectMQTT11), t.subscribe('/ig_send_message_response', this.$DirectMQTT12), this.$DirectMQTT4 || (this.$DirectMQTT4 = new(r(d[4]).DirectIrisSubscription)(s, this.$DirectMQTT3, t, this.$DirectMQTT1.getDebugId())), this.$DirectMQTT4.subscribe(), 'message' === this.$DirectMQTT3.subscription_type ? (this.$DirectMQTT6 || (this.$DirectMQTT6 = new(r(d[5]).DirectSkywalkerSubscription)(s, t, this.$DirectMQTT1.getDebugId())), this.$DirectMQTT6.subscribe(), this.$DirectMQTT7 || (this.$DirectMQTT7 = new(r(d[6]).DirectGraphQLSubscription)(s, t, this.$DirectMQTT1.getDebugId()), this.$DirectMQTT7.subscribe())) : (this.$DirectMQTT1.debugTrace('skip_skywalker', this.$DirectMQTT3), this.$DirectMQTT1.debugTrace('skip_graphql', this.$DirectMQTT3)) } else if ('Disconnected' === t) { this.$DirectMQTT4 && (this.$DirectMQTT4.unsubscribe(), this.$DirectMQTT4 = null), this.$DirectMQTT6 && (this.$DirectMQTT6.unsubscribe(), this.$DirectMQTT6 = null), this.$DirectMQTT7 && (this.$DirectMQTT7.unsubscribe(), this.$DirectMQTT7 = null); const t = this.$DirectMQTT5; t && (t.unsubscribe('/ig_message_sync'), t.unsubscribe('/ig_send_message_response')) } s.onMqttConnectivityChanged(t) }), this.$DirectMQTT14 = (t => (this.$DirectMQTT1.logDirectEvent('send_attempt', { action: t.action, type: t.item_type || '' }), i(d[0])(this.$DirectMQTT5).publish('/ig_send_message', JSON.stringify({ client_context: i(d[7])(), device_id: this.$DirectMQTT10(), ...t })).catch(t => { throw this.$DirectMQTT1.logError('send_message_failed', t), t }))), this.$DirectMQTT1 = new(i(d[8]))('DirectMQTT', T), this.$DirectMQTT1.debugTrace('ctor', s), this.$DirectMQTT2 = null, this.$DirectMQTT3 = s, this.$DirectMQTT4 = null, this.$DirectMQTT5 = null, this.$DirectMQTT6 = null, this.$DirectMQTT7 = null } $DirectMQTT8() { return parseInt(i(d[0])(r(d[9]).getViewerId()), 10) } $DirectMQTT9() { return parseInt(r(d[9]).getIGAppID(), 10) } $DirectMQTT10() { return r(d[10]).isIgLite() ? r(d[11]).getGUID() : r(d[12]).getDeviceOrMachineId() } sendTextMessage(t, s, T) { return this.$DirectMQTT14({ action: 'send_item', item_type: r(d[13]).ThreadItemType.TEXT, mutation_token: T, text: s, thread_id: t }) } sendMediaShare(t, s) { return this.$DirectMQTT14({ action: 'send_item', item_type: r(d[13]).ThreadItemType.MEDIA_SHARE, media_id: s, thread_id: t }) } sendLike(t, s) { return this.$DirectMQTT14({ action: 'send_item', item_type: r(d[13]).ThreadItemType.LIKE, mutation_token: s, thread_id: t }) } indicateTypingActivity(t, s) { return this.$DirectMQTT14({ action: 'indicate_activity', thread_id: s, activity_status: t }) } markVisualItemSeen(t, s) { return this.$DirectMQTT14({ action: 'mark_visual_item_seen', target_item_type: 'voice_media', thread_id: s, item_ids: JSON.stringify([t]) }) } modifyLikeReaction(t, s, T, c) { return this.$DirectMQTT14({ action: 'send_item', item_id: t, item_type: 'reaction', node_type: 'item', reaction_status: c, reaction_type: 'like', target_item_type: s, thread_id: T }) } disconnect() { this.$DirectMQTT1.debugTrace('disconnect_start'), this.$DirectMQTT4 ? (this.$DirectMQTT1.debugTrace('unsubscribe_iris'), i(d[0])(this.$DirectMQTT4).unsubscribe(), this.$DirectMQTT4 = null) : this.$DirectMQTT1.debugTrace('no_iris'), this.$DirectMQTT6 ? (this.$DirectMQTT1.debugTrace('unsubscribe_skywalker'), i(d[0])(this.$DirectMQTT6).unsubscribe(), this.$DirectMQTT6 = null) : this.$DirectMQTT1.debugTrace('no_skywalker'), this.$DirectMQTT7 ? (this.$DirectMQTT1.debugTrace('unsubscribe_graphql'), i(d[0])(this.$DirectMQTT7).unsubscribe(), this.$DirectMQTT7 = null) : this.$DirectMQTT1.debugTrace('no_graphql'), this.$DirectMQTT5 ? (this.$DirectMQTT1.debugTrace('shutdown_channel'), i(d[0])(this.$DirectMQTT5).shutdown(), this.$DirectMQTT5 = null) : this.$DirectMQTT1.debugTrace('no_channel'), this.$DirectMQTT2 && (this.$DirectMQTT2 = null), this.$DirectMQTT1.debugTrace('disconnect_end') } connect(t) { this.$DirectMQTT1.debugTrace('connect_start'), this.disconnect(), this.$DirectMQTT2 = new(i(d[14]))(t, this.$DirectMQTT1.getDebugId()); const s = { onMQTTStateChanged: this.$DirectMQTT13, onJSError: t => { this.$DirectMQTT1.logError("mqtt_js_error", t) } }, T = { deviceId: this.$DirectMQTT10() }; i(d[15]).initialize(); const c = { endpoint: r(d[13]).PROD_MQTT_GATEWAY, userFbid: this.$DirectMQTT8(), appId: this.$DirectMQTT9(), initialSubscribedTopics: [], igSpecificOptions: T, observer: s, debugId: this.$DirectMQTT1.getDebugId(), capabilities: 0, clientCapabilities: 1, chatVisibility: !0 }; this.$DirectMQTT5 = new(i(d[16]))(c), this.$DirectMQTT1.debugTrace('connect_end') } getLogger() { return this.$DirectMQTT1 } } }, 16056320, [9568334, 16056321, 16056322, 5, 16056323, 16056324, 16056325, 10158085, 9895938, 9699336, 9699358, 9961751, 9961762, 9895953, 16056326, 16056327, 16056328]); __d(function(g, r, i, a, m, e, d) { "use strict"; Object.defineProperty(e, '__esModule', { value: !0 }), e.default = function(t, n) { return new Promise((u, c) => { function o() { try { n(t[l]) } catch (t) { return void c(t) }++l >= t.length ? u() : i(d[0])(o) } let l = 0; 0 !== t.length ? o() : u() }) } }, 16056321, [16056329]); __d(function(g, r, i, a, m, e, d) { "use strict"; Object.defineProperty(e, '__esModule', { value: !0 }); let t; var o = t = process && 'function' == typeof process.nextTick ? t => { process.nextTick(t) } : 'function' == typeof setImmediate ? t => { setImmediate(t) } : 'function' == typeof setTimeout ? t => { setTimeout(t, 0) } : t => { t() }; e.default = o }, 16056329, []); __d(function(g, r, i, a, m, e, d) { "use strict"; Object.defineProperty(e, '__esModule', { value: !0 }), e.default = function(t, n) { const u = []; for (let c = 0; c < t.length; c += n) u.push(t.slice(c, c + n)); return u } }, 16056322, []); __d(function(g, r, i, a, m, e, d) { "use strict"; Object.defineProperty(e, '__esModule', { value: !0 }); const s = 1, t = 2, c = 1e3, n = 64e3; e.DirectIrisSubscription = class { constructor(o, u, b, p) { this.$DirectIrisSubscription6 = (() => { this.$DirectIrisSubscription1.logDirectClientEvent('ig_direct_iris_subscription', r(d[0]).DIRECT_CONTAINER_MODULES.ig_direct_realtime, { ...this.$DirectIrisSubscription3, action: 'attempt', attempt_reason: 'mqtt-connected' }), this.$DirectIrisSubscription2.onIrisConnectivityChanged('Subscribing'); const s = JSON.stringify(this.$DirectIrisSubscription3); this.$DirectIrisSubscription4.publish('/ig_sub_iris', s).catch(s => { this.$DirectIrisSubscription1.logDirectClientEvent('ig_direct_iris_subscription', r(d[0]).DIRECT_CONTAINER_MODULES.ig_direct_realtime, { ...this.$DirectIrisSubscription3, action: 'error', error: JSON.stringify(s) }), this.$DirectIrisSubscription2.onIrisConnectivityChanged('Unsubscribed') }) }), this.$DirectIrisSubscription7 = (c => { let o; if (i(d[1])(c)) try { o = JSON.parse(c) } catch (s) { const t = "Could not parse sub iris response $(response)"; this.$DirectIrisSubscription1.logError(t, s), i(d[2])(t), o = s } else i(d[3])(c) ? o = c : (i(d[2])("Unknown sub iris response $(response)"), o = { succeeded: !1 }); if (!0 === o.succeeded) this.$DirectIrisSubscription1.logDirectClientEvent('ig_direct_iris_subscription', r(d[0]).DIRECT_CONTAINER_MODULES.ig_direct_realtime, { ...this.$DirectIrisSubscription3, action: 'success' }), this.$DirectIrisSubscription2.onIrisConnectivityChanged('Subscribed', this.$DirectIrisSubscription3.subscription_type); else if (this.$DirectIrisSubscription1.logDirectClientEvent('ig_direct_iris_subscription', r(d[0]).DIRECT_CONTAINER_MODULES.ig_direct_realtime, { ...this.$DirectIrisSubscription3, ...o, action: 'error' }), this.$DirectIrisSubscription2.onIrisConnectivityChanged('Unsubscribed'), o.error_type === s) this.$DirectIrisSubscription2.onResnapshotRequested(this.$DirectIrisSubscription3); else if (o.error_type === t) { const s = this.$DirectIrisSubscription5 + Math.floor(1e3 * Math.random()); setTimeout(this.$DirectIrisSubscription6, s), this.$DirectIrisSubscription5 = Math.min(2 * this.$DirectIrisSubscription5, n) } }), this.$DirectIrisSubscription1 = new(i(d[0]))('DirectIrisSubscription', p), this.$DirectIrisSubscription1.debugTrace('ctor', u), this.$DirectIrisSubscription2 = o, this.$DirectIrisSubscription3 = u, this.$DirectIrisSubscription4 = b, this.$DirectIrisSubscription5 = c } subscribe() { this.$DirectIrisSubscription1.debugTrace('subscribe_start'), this.unsubscribe(), this.$DirectIrisSubscription4.subscribe('/ig_sub_iris_response', this.$DirectIrisSubscription7), this.$DirectIrisSubscription6(), this.$DirectIrisSubscription1.debugTrace('subscribe_end') } unsubscribe() { this.$DirectIrisSubscription1.debugTrace('unsubscribe_start'), this.$DirectIrisSubscription8 && (clearTimeout(this.$DirectIrisSubscription8), this.$DirectIrisSubscription8 = null), this.$DirectIrisSubscription4.unsubscribe('/ig_sub_iris_response'), this.$DirectIrisSubscription2.onIrisConnectivityChanged('Unsubscribed'), this.$DirectIrisSubscription1.debugTrace('unsubscribe_end') } } }, 16056323, [9895938, 16056330, 9699388, 12648589]); __d(function(g, r, i, a, m, e, d) { var t = '[object String]'; m.exports = function(n) { return 'string' == typeof n || !r(d[0])(n) && r(d[1])(n) && r(d[2])(n) == t } }, 16056330, [16056331, 9961499, 12058667]); __d(function(g, r, i, a, m, e, d) { "use strict"; Object.defineProperty(e, '__esModule', { value: !0 }); const s = '/pubsub'; e.DirectSkywalkerSubscription = class extends r(d[3]).DirectBaseSubscription { constructor(t, c, n) { const o = new(i(d[0]))('DirectSkywalkerSubscription', n); super(s,ig/u/v1/${i(d[1])(r(d[2]).getViewerId())}, c, o), this.$DirectSkywalkerSubscription1 = o, this.$DirectSkywalkerSubscription2 = t } parsePayload(s) { return -1 === s.indexOf('/activity_indicator_id/') ? (this.$DirectSkywalkerSubscription1.debugTrace('not_activity_indicator_message'), null) : super.parsePayload(s) } processMessage(s) { const { data: t, event: c } = s; if ('patch' === c) if (Array.isArray(t)) { for (const s of t) this.$DirectSkywalkerSubscription2.handleDelta(s, ''); super.processMessage(s) } else this.$DirectSkywalkerSubscription1.debugTrace('parsed_message_bad_data', typeof t); else this.$DirectSkywalkerSubscription1.debugTrace('skipped_message', { event: c }) } } }, 16056324, [9895938, 9568334, 9699336, 16056332]); __d(function(g, r, i, a, m, e, d) { "use strict"; Object.defineProperty(e, '__esModule', { value: !0 }); e.DirectBaseSubscription = class { constructor(s, t, c, u) { this.$DirectBaseSubscription5 = (s => { if (this.$DirectBaseSubscription4.debugTrace('message_received'), null == this.parsePayload(s)) return; let t; if (0 === s.length) return void this.$DirectBaseSubscription4.logError('empty_message'); '\0' === s[s.length - 1] ? (t = s.substring(0, s.length - 1), this.$DirectBaseSubscription4.debugTrace('trimmed_null_char')) : t = s; let c = {}; try { c = JSON.parse(t) } catch (t) { return void this.$DirectBaseSubscription4.logError(Cannot parse message ${s}`, t) } this.processMessage(c) }), this.$DirectBaseSubscription1 = s, this.$DirectBaseSubscription2 = t, this.$DirectBaseSubscription3 = c, this.$DirectBaseSubscription4 = u, this.$DirectBaseSubscription4.debugTrace('ctor') } parsePayload(s) { return s } processMessage(s) {} $DirectBaseSubscription6(s) { return JSON.stringify({

        })
    }
    subscribe() {
        this.$DirectBaseSubscription4.debugTrace('subscribe_start'), this.unsubscribe(), this.$DirectBaseSubscription3.subscribe(this.$DirectBaseSubscription1, this.$DirectBaseSubscription5), this.$DirectBaseSubscription3.publish(this.$DirectBaseSubscription1, this.$DirectBaseSubscription6('sub')), this.$DirectBaseSubscription4.debugTrace('subscribe_end')
    }
    unsubscribe() {
        this.$DirectBaseSubscription4.debugTrace('unsubscribe_start'), this.$DirectBaseSubscription3.publish(this.$DirectBaseSubscription1, this.$DirectBaseSubscription6('unsub')), this.$DirectBaseSubscription3.unsubscribe(this.$DirectBaseSubscription1), this.$DirectBaseSubscription4.debugTrace('unsubscribe_end')
    }
}

}, 16056332, []); d(function(g, r, i, a, m, e, d) { "use strict"; Object.defineProperty(e, 'esModule', { value: !0 }); const s = '/ig_realtime_sub'; e.DirectGraphQLSubscription = class extends r(d[2]).DirectBaseSubscription { constructor(t, c, n) { const p = new(i(d[0]))('DirectGraphQLSubscription', n), o = "1/graphqlsubscriptions/17846944882223835/" + JSON.stringify({ input_data: { client_subscription_id: i(d[1])() } }); super(s, o, c, p), this.$DirectGraphQLSubscription1 = p, this.$DirectGraphQLSubscription2 = t } processMessage(s) { const { presence_event: t } = s; null != t ? (this.$DirectGraphQLSubscription2.onPresenceUpdated(t), super.processMessage(s)) : this.$DirectGraphQLSubscription1.debugTrace('parsed_message_bad_data') } } }, 16056325, [9895938, 10158085, 16056332]); d(function(g, r, i, a, m, e, d) { 'use strict'; const t = { initialize() { r(d[0]).Env.initialize(null, r(d[1]).isLoggedIn, null, i(d[2]), () => i(d[3]).getInstance(), null, null, null, null, (t, n) => { const l = i(d[4]).getLocalStorage(); if (l) { const n = l.getItem("mqtt:" + t); if (null != n) return n } return n }, (t, n) => { const l = i(d[4]).getLocalStorage(); l && (null == n ? l.removeItem("mqtt:" + t) : l.setItem("mqtt:" + t, n)) }) } }; m.exports = t }, 16056327, [16056333, 9699336, 16056334, 16056335, 9961752]); d(function(g, r, i, a, m, e, d) { 'use strict'; const t = Object.freeze({ mqtt_ep_with_sid: 0, mqtt_waterfall_log_client_sampling: 1, messenger_uses_mqtt_rollout: 2, mqtt_ws_polling_enabled: 3, mqtt_ws_forced_polling_only: 4, mqtt_send_unload_event: 6, mqtt_ws_reconnect_reset: 7, mqtt_lp_use_fetch: 9, mqtt_fast_lp: 11 }); class n { static getInstance() { return new n } setAppId(t) {} eventLogConnect({ sessionID: t, connectionStatus: n, duration: s, hostname: l, attemptNumber: o, failTotal: u, successTotal: h, subscribedTopics: v, publishes: E, errorCode: $, errorMessage: c }) {} eventLogPull({ pullEventName: t, sessionID: n, status: s, duration: l, hostname: o, errorMessage: u }) {} eventLogDisconnect({ sessionID: t, errorCode: n, errorMessage: s, duration: l }) {} eventLogPublish({ sessionID: t, topic: n, connectionStatus: s, publishStatus: l }) {} eventLogMiscellaneousError({ errorMessage: t }) {} logError(t, n) {} logErrorWarn(t, n) {} logWarn(t, n) {} debugTrace(t, n) {} bumpCounter(t) {} } m.exports = { Env: new class { random() { return null != this.$Env1 ? this.$Env1() : Math.random() } isUserLoggedInNow() { return null == this.$Env2 || this.$Env2() } clearTimeout(t) { null == this.$Env3 ? clearTimeout(t) : this.$Env3(t) } setTimeout(t, n, ...s) { return null != this.$Env4 ? this.$Env4.apply(null, arguments) : setTimeout.apply(null, arguments) } getLoggerInstance() { return null != this.$Env5 ? this.$Env5() : n.getInstance() } genGk(t) { return null != this.$Env6 && this.$Env6(t) } createSocket(t, n) { return null != this.$Env7 ? this.$Env7(t, n) : new WebSocket(t) } scheduleCallback(t) { return null != this.$Env8 ? this.$Env8(t) : t() } scheduleLoggingCallback(t) { return null != this.$Env9 ? this.$Env9(t) : t() } configRead(t, n) { return null != this.$Env10 ? this.$Env10(t, n) : n } configWrite(t, n) { null != this.$Env11 && this.$Env11(t, n) } constructor() { this.$Env1 = null, this.$Env2 = null, this.$Env3 = null, this.$Env4 = null, this.$Env5 = null, this.$Env6 = null, this.$Env7 = null, this.$Env8 = null, this.$Env9 = null, this.$Env10 = null, this.$Env11 = null } initialize(t, n, s, l, o, u, h, v, E, $, c) { this.$Env1 = t, this.$Env2 = n, this.$Env3 = s, this.$Env4 = l, this.$Env5 = o, this.$Env6 = u, this.$Env7 = h, this.$Env8 = v, this.$Env9 = E, this.$Env10 = $, this.$Env11 = c } }, MqttGkNames: t } }, 16056333, []); d(function(g, r, i, a, m, e, d) { 'use strict'; let t = null; const o = new(i(d[0]))('mqtt_client', r(d[1]).getID()), n = { CONNECT: 'mqtt_client_connect', DISCONNECT: 'mqtt_client_disconnect', PUBLISH: 'mqtt_client_publish', CLIENT_ERROR: 'mqtt_clienterror' }; class s { static getInstance() { return t || (t = new s), t } constructor() { this.$MqttLogger1 = 0, this.$MqttLogger2 = Date.now(), this.$MqttLogger3 = r(d[1]).getID() } setAppId(t) { 0 === this.$MqttLogger1 && (this.$MqttLogger1 = t) } eventLogConnect({ sessionID: t, connectionStatus: o, duration: s, hostname: c, attemptNumber: l, failTotal: , successTotal: u, subscribedTopics: h, publishes: L, errorCode: q, errorMessage: w }) { o ? i(d[2]).incr('web.mqtt.mqtt_client_connect.success') : i(d[2]).incr('web.mqtt.mqtt_client_connect.failed'); const M = { device_id: this.$MqttLogger3, session_id: t, logged_in: r(d[3]).Env.isUserLoggedInNow(), href: window.location.hostname, connection_status: o, duration: s, hostname: c, attempt_number: l, subscribed_topics: h, publishes: L, error_code: q, errormessage: w }; this.$MqttLogger4(n.CONNECT, M) } eventLogPull({ pullEventName: t, sessionID: o, status: n, duration: s, hostname: c, errorMessage: l }) { const = { device_id: this.$MqttLogger3, session_id: o, logged_in: r(d[3]).Env.isUserLoggedInNow(), href: window.location.hostname, connection_status: n, duration: s, hostname: c, errormessage: l }; this.$MqttLogger4(t, ) } eventLogDisconnect({ sessionID: t, errorCode: o, errorMessage: s, duration: c }) { i(d[2]).incr('web.mqtt.mqtt_client_disconnect'); const l = { device_id: this.$MqttLogger3, session_id: t, href: window.location.hostname, duration: c, error_code: o, error_message: s }; this.$MqttLogger4(n.DISCONNECT, l) } eventLogPublish({ sessionID: t, topic: o, connectionStatus: s, publishStatus: c }) { i(d[2]).incr('web.mqtt.mqtt_client_publish'); const l = { device_id: this.$MqttLogger3, href: window.location.hostname, session_id: t, topic: o, connection_status: s, publish_status: c }; this.$MqttLogger4(n.PUBLISH, l) } logError(t, n) { r(d[3]).Env.scheduleLoggingCallback(() => { o.logError(n, t) }) } eventLogMiscellaneousError({ errorMessage: t }) { const o = { device_id: this.$MqttLogger3, logged_in: r(d[3]).Env.isUserLoggedInNow(), href: window.location.hostname, error_message: t, time_passed: Date.now() - this.$MqttLogger2 }; this.$MqttLogger4(n.CLIENT_ERROR, o) } logErrorWarn(t, n) { r(d[3]).Env.scheduleLoggingCallback(() => { o.logError(n, t) }) } logWarn(t, o) {} debugTrace(t, n) { r(d[3]).Env.scheduleLoggingCallback(() => { o.debugTrace(t, n) }) } bumpCounter(t) {} $MqttLogger4(t, n) { r(d[3]).Env.scheduleLoggingCallback(() => { n.event_type = t, n.app_id = this.$MqttLogger1, n.online = this.$MqttLogger5(), o.logDirectEvent(t, n) }) } $MqttLogger5() { return !(!window.navigator || void 0 === window.navigator.onLine) && window.navigator.onLine } } m.exports = s }, 16056335, [9895938, 16056336, 9961577, 16056333]); d(function(g, r, i, a, m, e, d) { 'use strict'; const t = r(d[0])(), s = { getID: () => t }; m.exports = s }, 16056336, [10158085]); d(function(g, r, i, a, m, e, d) { 'use strict'; const t = 6e4; m.exports = class { constructor({ appId: t, capabilities: n, chatVisibility: s = !0, clientCapabilities: h, debugId: l, endpoint: o, igSpecificOptions: q, initialSubscribedTopics: C, observer: c, userFbid: M }) { this.$MqttChannel1 = r(d[0]).Env.getLoggerInstance(), this.$MqttChannel1.setAppId(t), this.$MqttChannel2 = new(r(d[1]))(M, n, h, r(d[2]).getID(), t, s, q), this.$MqttChannel3 = o, this.$MqttChannel4 = 'Disconnected', this.$MqttChannel5 = [c], this.$MqttChannel6 = new Set, this.$MqttChannel7 = new Map, this.$MqttChannel8 = new(r(d[3]))(q, l), q && q.deviceId ? this.$MqttChannel9 = q.deviceId : this.$MqttChannel9 = r(d[4])(), this.$MqttChannel10 = new(r(d[5])), this.$MqttChannel8.addHook(this.$MqttChannel10), this.$MqttChannel8.addHook(new(r(d[6]))(() => this.$MqttChannel6.size > 0)), this.$MqttChannel11 = !1, this.$MqttChannel12 = new Map, this.$MqttChannel13 = [], this.$MqttChannel14(C) } $MqttChannel14(t) { if (this.$MqttChannel8.isRunning()) this.$MqttChannel15('run', 'Connection started calling run again'); else { if (r(d[0]).Env.genGk(r(d[0]).MqttGkNames.mqtt_ws_polling_enabled)) { if (r(d[0]).Env.genGk(r(d[0]).MqttGkNames.mqtt_ws_forced_polling_only)) return void this.$MqttChannel15('MqttChannel', 'Websocket disabled, will do long polling only'); if (!r(d[7]).hasWSSupport()) return this.$MqttChannel15('MqttChannel', 'Websocket Unavailable, will do long polling only'), void i(d[8]).incr('web.mqtt.ws_unavailable_polling') } this.$MqttChannel8.run({ onStateChange: t => { this.$MqttChannel16(t) }, onJSError: t => { this.$MqttChannel17(t) }, onMessageReceived: (t, n) => { this.$MqttChannel18(t, n) }, endpoint: this.$MqttChannel3, mqttUserName: this.$MqttChannel2, subscribedTopics: t, extraConnectMessageProvider: () => this.$MqttChannel19() }) } } shutdown() { this.$MqttChannel8 && this.$MqttChannel8.shutdown() } publish(t, n, s = { qos: 1, skipBuffer: !1 }) { return 0 === s.qos ? this.$MqttChannel20(t, n) : this.$MqttChannel21(t, n, s) } $MqttChannel20(t, n) { return this.$MqttChannel8.publish(t, n, 0) } $MqttChannel21(t, n, s) { const h = { resolve: () => {}, reject: t => {} }, l = new Promise((t, n) => { h.resolve = t, h.reject = n }), o = r(d[0]).Env.random(), q = { topic: t, payload: n, options: s, ack: h, publishToken: o, timeoutId: null }; return s.skipBuffer ? 'Connecting' === this.$MqttChannel8.connectionState() ? this.$MqttChannel13.push(q) : this.$MqttChannel22(q) : (q.timeoutId = this.$MqttChannel23(o), this.$MqttChannel12.set(o, q), this.$MqttChannel24(q)), l } $MqttChannel22(t) { r(d[7]).promiseDone(this.$MqttChannel8.publish(t.topic, t.payload, t.options.qos), () => { t.ack.resolve() }, n => { t.ack.reject(n) }) } $MqttChannel24(t) { r(d[7]).promiseDone(this.$MqttChannel8.publish(t.topic, t.payload, t.options.qos), () => this.$MqttChannel25(t), t => {}) } subscribe(t, n) { this.$MqttChannel8.subscribe(t); let s = this.$MqttChannel7.get(t); s ? s.push(n) : (s = [n], this.$MqttChannel7.set(t, s)) } subscribeChannelEvents(t) { this.$MqttChannel5.push(t) } registerExtraConnectPayloadProvider(t) { this.$MqttChannel6.add(t), this.$MqttChannel8.isRunning() && t.getPublishMessages().forEach(t => { this.publish(t.topic, t.payload, { qos: t.qos, skipBuffer: !0 }) }) } unregisterExtraConnectPayloadProvider(t) { this.$MqttChannel6.delete(t) } unsubscribe(t) { this.$MqttChannel8.unsubscribe(t), this.$MqttChannel7.delete(t) } getConnectionState() { return this.$MqttChannel4 } getEndpoint() { return this.$MqttChannel3 } addHook(t) { this.$MqttChannel8.addHook(t) } removeHook(t) { this.$MqttChannel8.removeHook(t) } testOnlyMessageReceived(t, n) { this.$MqttChannel18(t, n) } $MqttChannel26(t) { const n = this.$MqttChannel12.get(t); null != n && null != n.timeoutId && r(d[0]).Env.clearTimeout(n.timeoutId), this.$MqttChannel12.delete(t) } $MqttChannel23(n) { return r(d[0]).Env.setTimeout(t => { const n = this.$MqttChannel12.get(t); if (!n) return; const s = n.topic; i(d[8]).incr('web.mqtt.publish_timeout'), this.$MqttChannel1.debugTrace('publish_timeout', Timeout publishing topic: ${s} publishToken: ${t}), this.$MqttChannel26(t), n.ack.reject(new Error('Publish Timed Out')) }, t, n) } $MqttChannel25(t) { const n = t.publishToken; this.$MqttChannel12.get(n) && (this.$MqttChannel26(n), t.ack.resolve(), this.$MqttChannel1.debugTrace('publish_success', Topic: ${t.topic} publishToken: ${t.publishToken}), i(d[8]).incr('web.mqtt.publish_success')) } $MqttChannel18(t, n) { const s = this.$MqttChannel7.get(t); if (s) for (const t of s) try { t(n) } catch (t) { this.$MqttChannel1.logError(t, 'Listener exception'), i(d[8]).incr('web.mqtt.listener_error') } else this.$MqttChannel1.debugTrace('_onMessageReceived', ${t} being dropped, no listeners) } $MqttChannel17(t) { r(d[0]).Env.genGk(r(d[0]).MqttGkNames.mqtt_ws_polling_enabled) ? t.isRecoverable ? i(d[8]).incr('web.mqtt.recoverable_error_skipped') : i(d[8]).incr('web.mqtt.unrecoverable_error_skipped') : (t.isRecoverable ? i(d[8]).incr('web.mqtt.recoverable_error_not_skipped') : i(d[8]).incr('web.mqtt.unrecoverable_error_not_skipped'), t.isRecoverable || (this.$MqttChannel11 = !0), this.$MqttChannel27(t)) } $MqttChannel28(t) { this.$MqttChannel27(t) } $MqttChannel27(t) { for (const n of this.$MqttChannel5) n.onJSError && n.onJSError(t) } $MqttChannel16(t) { 'Connecting' === t ? (this.$MqttChannel13.forEach(t => { t.ack.reject(new Error('Client Reconnecting')) }), this.$MqttChannel13 = []) : 'TransportConnected' === t && (this.$MqttChannel13.forEach(t => { this.$MqttChannel22(t) }), this.$MqttChannel13 = [], this.$MqttChannel12.forEach((t, n, s) => { this.$MqttChannel24(t) })), this.$MqttChannel4 = this.$MqttChannel29(t), this.$MqttChannel15('_changeState', Connection state = ${t}), this.$MqttChannel30() } $MqttChannel29(t) { switch (t) { case 'Connecting': case 'TransportConnected': return 'Connecting'; case 'Connected': return 'Connected'; case 'Disconnected': return 'Disconnected' } throw new Error('Unknown state ' + t) } $MqttChannel30() { for (const t of this.$MqttChannel5) t.onMQTTStateChanged(this.$MqttChannel4) } $MqttChannel19() { const t = []; return this.$MqttChannel6.forEach(n => { try { const s = n.getPublishMessages(); Array.prototype.push.apply(t, s) } catch (t) { this.$MqttChannel1.logError(t, 'ConnectPayload provider exception'), i(d[8]).incr('web.mqtt.connectPayloadProvider_error') } }), t } $MqttChannel15(t, n) { this.$MqttChannel1.debugTrace(t, Mqtt channel: ${n}) } setForegroundState(t) { this.$MqttChannel2 && this.$MqttChannel2.setForegroundState(t) } setChatVisibility(t) { this.$MqttChannel2 && this.$MqttChannel2.setChatVisibility(t) } } }, 16056328, [16056333, 16056337, 16056336, 16056338, 10158085, 16056339, 16056340, 16056341, 9961577]); __d(function(g, r, i, a, m, e, d) { 'use strict'; m.exports = class { constructor(t, s, h, o, c, q, N) { this.$MqttUserName1 = t, this.$MqttUserName2 = s, this.$MqttUserName3 = h, this.$MqttUserName4 = o, this.$MqttUserName5 = c, this.$MqttUserName6 = q, this.$MqttUserName7 = N, this.$MqttUserName8 = 'object' == typeof document && document && document.hasFocus() } gen(t, s, h) { const o = { u: this.$MqttUserName1, s: t, cp: this.$MqttUserName3, ecp: this.$MqttUserName2, chat_on: this.$MqttUserName6, fg: this.$MqttUserName8, d: this.$MqttUserName4, ct: 'cookie_auth', mqtt_sid: '', aid: this.$MqttUserName5, st: s, pm: h, dc: '', no_auto_fg: !0, asi: void 0, a: navigator.userAgent }; return this.$MqttUserName7 && this.$MqttUserName7.appSpecificInfo && (o.asi = this.$MqttUserName7.appSpecificInfo), JSON.stringify(o) } setForegroundState(t) { this.$MqttUserName8 = t } setChatVisibility(t) { this.$MqttUserName6 = t } } }, 16056337, []); d(function(g, r, i, a, m, e, d) { 'use strict'; const { ConnectFailure: t, MqttChannelError: n, MqttError: o } = r(d[0]), c = 10, s = 'publish', q = 'subscribe', h = 'unsubscribe', C = t => {}, M = 18e4, $ = 5e3, u = 15, l = 21; m.exports = class { constructor(t, n) { this.$MqttConnection41 = (t => { const n = new Set(t); n.forEach(t => { this.$MqttConnection4.has(t) || this.unsubscribe(t) }), new Set(this.$MqttConnection4).forEach(t => { n.has(t) || this.subscribe(t) }) }), this.$MqttConnection38 = ((t, n) => { try { i(d[1]).incr('web.mqtt.js_error_in_init'); const o = t ? t.message : 'error'; this.$MqttConnection2.debugTrace('onError', n + ': ' + o), this.$MqttConnection15(t) } catch (t) { i(d[1]).incr('web.mqtt.js_error_in_error_logging'), this.$MqttConnection2.logError(t, 'JS error while trying to log previous error') } }), this.$MqttConnection1 = !1, this.$MqttConnection2 = r(d[2]).Env.getLoggerInstance(), this.$MqttConnection3 = 'Disconnected', this.$MqttConnection4 = new Set, this.$MqttConnection5 = new Map, this.$MqttConnection6 = 0, this.$MqttConnection7 = 0, this.$MqttConnection8 = 0, this.$MqttConnection9 = 0, this.$MqttConnection1 = !1, this.$MqttConnection10 = '', this.$MqttConnection11 = new(r(d[3]))(0, 0, 1, '', 0, !0), this.$MqttConnection12 = 0, this.$MqttConnection13 = null; const o = () => {}; this.$MqttConnection14 = o, this.$MqttConnection15 = o, this.$MqttConnection16 = o, this.$MqttConnection17 = new(r(d[4])), this.$MqttConnection18 = (() => []), this.$MqttConnection19 = t } run({ onStateChange: t, onJSError: n, onMessageReceived: o, endpoint: c, mqttUserName: s, subscribedTopics: q, extraConnectMessageProvider: h }) { this.$MqttConnection1 ? this.$MqttConnection2.debugTrace('run', 'Run called while in running state.') : (this.$MqttConnection14 = t, this.$MqttConnection16 = o, this.$MqttConnection10 = c, this.$MqttConnection11 = s, this.$MqttConnection1 = !0, this.$MqttConnection8 = 0, this.$MqttConnection15 = n || C, q && q.forEach(t => this.$MqttConnection4.add(t)), this.$MqttConnection18 = h, this.$MqttConnection20(), this.$MqttConnection21()) } shutdown() { this.$MqttConnection22(), this.$MqttConnection23('shutdown'), this.$MqttConnection1 = !1, this.$MqttConnection2.debugTrace('shutdown', "Shutdown") } subscribe(t) { return this.$MqttConnection4.add(t), this.ensureConnected(q) && this.$MqttConnection24(t), !0 } publish(t, n, o) { const c = { resolve: () => {}, reject: t => {} }, q = new Promise((t, n) => { c.resolve = t, c.reject = n }), h = this.ensureConnected(s); let C = 'connection_unknown'; return h ? C = !0 === this.$MqttConnection25(t, n, o, c) ? 'connection_published' : 'connection_failed' : (C = 'connection_not_connected', c.reject(new Error('Client disconnected'))), this.$MqttConnection2.eventLogPublish({ sessionID: this.$MqttConnection12, topic: t, connectionStatus: h, publishStatus: C }), q } unsubscribe(t) { return this.$MqttConnection4.delete(t), this.ensureConnected(h) && this.$MqttConnection26(t), !0 } addHook(t) { this.$MqttConnection17.addHook(t) } removeHook(t) { this.$MqttConnection17.removeHook(t) } isRunning() { return this.$MqttConnection1 } getSessionId() { return this.$MqttConnection12 } ensureConnected(t) { return this.$MqttConnection1 ? null == this.$MqttConnection13 ? (this.$MqttConnection2.debugTrace('ensureConnected', Mqtt connection: ${t} called when not connected, ignored), !1) : !!this.$MqttConnection13.isConnected() || (this.$MqttConnection2.debugTrace('ensureConnected', Mqtt connection: ${t} called with client not connected), !1) : (this.$MqttConnection2.debugTrace('ensureConnected', Mqtt connection: ${t} called when not running), !1) } connectionState() { return this.$MqttConnection3 } testOnlyGetSubscribedTopics() { return this.$MqttConnection4 } $MqttConnection20() { r(d[2]).Env.genGk(r(d[2]).MqttGkNames.mqtt_send_unload_event) && 'undefined' != typeof window && window.addEventListener('unload', t => this.$MqttConnection27(t)) } $MqttConnection27(t) { this.publish('/browser_close', '{}', 0) } $MqttConnection22() { this.$MqttConnection1 && null != this.$MqttConnection13 && (this.$MqttConnection28('Disconnected'), null != this.$MqttConnection13 && this.$MqttConnection13.disconnect(), this.$MqttConnection13 = null) } $MqttConnection28(t) { t !== this.$MqttConnection3 && (this.$MqttConnection3 = t, this.$MqttConnection14(t)) } $MqttConnection21() { if (!this.$MqttConnection1) return; this.$MqttConnection28('Connecting'); const t = Date.now(); this.$MqttConnection12 = r(d[5]).generateSessionId(); const o = Array.from(this.$MqttConnection4), s = r(d[5]).endpointWithSessionId(this.$MqttConnection10, this.$MqttConnection12); try { this.$MqttConnection13 = new(r(d[6]))(s); const q = this.$MqttConnection29(), h = q.map(t => t.topic), C = this.$MqttConnection11.gen(this.$MqttConnection12, o, q); null != this.$MqttConnection13 && (this.$MqttConnection13.connect({ userName: C, mqttVersion: 3, keepAliveInterval: c, ignoreSubProtocol: !0, onConnectFailure: n => this.$MqttConnection30(n, t, o, h), onConnectSuccess: () => this.$MqttConnection31(t, o, h), onConnection: () => this.$MqttConnection32(q, o), onConnectionError: t => this.$MqttConnection33(t), onConnectionLost: t => this.$MqttConnection34(t), onMessageArrived: (t, n) => this.$MqttConnection35(t, n), onMessageDelivered: (t, n) => this.$MqttConnection36(t, n) }), i(d[1]).incr('web.mqtt.protocol.connectattempt'), this.$MqttConnection17.onConnectAttempt()) } catch (c) { i(d[1]).incr('web.mqtt.js_error_in_init_exception'), this.$MqttConnection28('Disconnected'), this.$MqttConnection37(!1, t, o, [], 14, c.message), c && this.$MqttConnection2.logErrorWarn(c, 'ws_js_error'), this.$MqttConnection17.onWSFatal(), this.$MqttConnection38(new n(!1, 'ws_js_error', c), 'client_init') } } $MqttConnection29() { let t = 65536; return this.$MqttConnection18().map(n => (n.messageId = t--, n)) } $MqttConnection24(t) { try { if (null != this.$MqttConnection13) return this.$MqttConnection13.subscribe(t), this.$MqttConnection2.debugTrace('_doSubscribe', Subscribing to ${t}), this.$MqttConnection17.onSubscribe(t), i(d[1]).incr('web.mqtt.protocol.subscribe'), !0 } catch (t) { this.$MqttConnection2.logError(t, 'Exception subscribing'), i(d[1]).incr('web.mqtt.subscribe_exception'), i(d[1]).incr('web.mqtt.protocol.subscribe.error') } return !1 } $MqttConnection26(t) { try { if (null != this.$MqttConnection13) return this.$MqttConnection13.unsubscribe(t), this.$MqttConnection2.debugTrace('_doUnsubscribe', Unsubscribing to ${t}), this.$MqttConnection17.onUnsubscribe(t), i(d[1]).incr('web.mqtt.protocol.unsubscribe'), !0 } catch (t) { this.$MqttConnection2.logError(t, 'Exception unsubscribing'), i(d[1]).incr('web.mqtt.unsubscribe_exception'), i(d[1]).incr('web.mqtt.protocol.unsubscribe.error') } return !1 } $MqttConnection25(t, n, o, c) { if (null == this.$MqttConnection13) return !1; try { const s = this.$MqttConnection13.publish(t, n, o); i(d[1]).incr('web.mqtt.protocol.publish'); const q = null != s ? s : 'null'; return this.$MqttConnection2.debugTrace('_doPublish', publish ${t} with messageId:${q} qos:${o}), this.$MqttConnection17.onPublish(t), null != s ? this.$MqttConnection5.set(s, c) : c.resolve(), !0 } catch (t) { return this.$MqttConnection2.logError(t, 'Exception publishing'), i(d[1]).incr('web.mqtt.publish_exception'), c.reject(t), i(d[1]).incr('web.mqtt.protocol.publish.error'), !1 } } $MqttConnection39(t = null) { if (!this.$MqttConnection1) return; this.$MqttConnection22(), this.$MqttConnection23('reconnect'), this.$MqttConnection40(), this.$MqttConnection12 = -1, this.$MqttConnection9 = 0; const n = null != t ? t : Math.pow(2, Math.min(this.$MqttConnection8, 6)) (1e3 + 200 r(d[2]).Env.random()); this.$MqttConnection2.debugTrace('_scheduleReconnect', Reconnect in ${n} ms), r(d[2]).Env.setTimeout(() => { this.$MqttConnection21() }, n), this.$MqttConnection8 += 1 } $MqttConnection40() { if (!r(d[2]).Env.genGk(r(d[2]).MqttGkNames.mqtt_ws_reconnect_reset)) return; const t = Date.now() - this.$MqttConnection9, n = 0 !== this.$MqttConnection9 && t > $, o = this.$MqttConnection8 > u; (n || o) && (this.$MqttConnection8 = 0), 0 !== this.$MqttConnection9 && t <= $ && i(d[1]).incr('web.mqtt.short_lived_session'), o && i(d[1]).incr('web.mqtt.connection_attempt_limit') } $MqttConnection37(t, n, o, c, s, q) { !0 === t ? this.$MqttConnection7++ : this.$MqttConnection6++, this.$MqttConnection2.eventLogConnect({ sessionID: this.$MqttConnection12, connectionStatus: t, duration: Date.now() - n, hostname: this.$MqttConnection10, attemptNumber: this.$MqttConnection8, failTotal: this.$MqttConnection6, successTotal: this.$MqttConnection7, subscribedTopics: o, publishes: c, errorCode: s, errorMessage: q }) } $MqttConnection30(t, n, o, c) { const s = t.mqttError, q = s.errorMessage; this.$MqttConnection2.debugTrace('connect', Connect failed ${q}), i(d[1]).incr('web.mqtt.protocol.onconnectfailure'), this.$MqttConnection17.onConnectFailure(), this.$MqttConnection37(!1, n, o, c, s.errorCode, q), null == t.connAck || (i(d[1]).incr('web.mqtt.protocol.connect_failure'), t.connAck !== l) ? this.$MqttConnection39() : this.$MqttConnection39(M) } $MqttConnection32(t, n) { i(d[1]).incr('web.mqtt.protocol.onconnection'), this.$MqttConnection2.debugTrace('Connect', 'Socket established'), this.$MqttConnection17.onConnected(), n.forEach(t => { this.$MqttConnection17.onSubscribe(t) }), t.forEach(t => { this.$MqttConnection17.onPublish(t.topic) }), this.$MqttConnection28('TransportConnected') } $MqttConnection31(t, n, o) { i(d[1]).incr('web.mqtt.protocol.onconnectsuccess'), this.$MqttConnection2.debugTrace('connect', 'Connect success'), this.$MqttConnection17.onConnectSuccess(), this.$MqttConnection37(!0, t, n, o), this.$MqttConnection28('Connected'), this.$MqttConnection41(n), r(d[2]).Env.genGk(r(d[2]).MqttGkNames.mqtt_ws_reconnect_reset) || (this.$MqttConnection8 = 0), this.$MqttConnection9 = Date.now() } $MqttConnection34(t) { i(d[1]).incr('web.mqtt.protocol.onconnectionlost'), t.errorCode && this.$MqttConnection2.eventLogDisconnect({ sessionID: this.$MqttConnection12, errorCode: t.errorCode, errorMessage: t.errorMessage, duration: Date.now() - this.$MqttConnection9 }), this.$MqttConnection2.debugTrace('connect', 'connection lost'), this.$MqttConnection17.onConnectionLost(), this.$MqttConnection39() } $MqttConnection33(t) {} $MqttConnection35(t, n) { i(d[1]).incr('web.mqtt.protocol.onmessagearrived'), this.$MqttConnection2.debugTrace('onMessageArrived', Message received on ${t}), this.$MqttConnection17.onMessage(t); try { this.$MqttConnection16(t, n) } catch (t) { this.$MqttConnection2.logError(t, 'Listener threw error'), i(d[1]).incr('web.mqtt.listener_error') } } $MqttConnection36(t, n) { i(d[1]).incr('web.mqtt.protocol.onmessagedelivered'); const o = null != n ? n : 'null'; if (this.$MqttConnection2.debugTrace('onMessageDelivered', Delivered Message {ID: ${o}}), null == n) return; const c = this.$MqttConnection5.get(n); null != c && (this.$MqttConnection5.delete(n), c.resolve()) } $MqttConnection23(t) { this.$MqttConnection5.forEach((n, o, c) => { n.reject(new Error(t)) }), this.$MqttConnection5.clear() } } }, 16056338, [16056342, 9961577, 16056333, 16056337, 16056343, 16056341, 16056344]); d(function(g, r, i, a, m, e, d) { 'use strict'; m.exports = { MqttError: class { constructor(t, s) { this.errorCode = t, this.errorMessage = s } }, MqttChannelError: class extends Error { constructor(t, s, o = null) { super(s), this.isRecoverable = t, this.originalError = o } }, ConnectFailure: class { constructor(t, s) { this.mqttError = t, this.connAck = s } } } }, 16056342, []); d(function(g, r, i, a, m, e, d) { 'use strict'; m.exports = class { constructor() { this.$MqttConnectionHookCollection1 = new Set } addHook(o) { this.$MqttConnectionHookCollection1.add(o) } removeHook(o) { this.$MqttConnectionHookCollection1.delete(o) } onConnectAttempt() { this.$MqttConnectionHookCollection1.forEach(o => { o.onConnectAttempt() }) } onConnectFailure() { this.$MqttConnectionHookCollection1.forEach(o => { o.onConnectFailure() }) } onConnected() { this.$MqttConnectionHookCollection1.forEach(o => { o.onConnected() }) } onConnectSuccess() { this.$MqttConnectionHookCollection1.forEach(o => { o.onConnectSuccess() }) } onConnectionLost() { this.$MqttConnectionHookCollection1.forEach(o => { o.onConnectionLost() }) } onSubscribe(o) { this.$MqttConnectionHookCollection1.forEach(n => { n.onSubscribe(o) }) } onUnsubscribe(o) { this.$MqttConnectionHookCollection1.forEach(n => { n.onUnsubscribe(o) }) } onPublish(o) { this.$MqttConnectionHookCollection1.forEach(n => { n.onPublish(o) }) } onMessage(o) { this.$MqttConnectionHookCollection1.forEach(n => { n.onMessage(o) }) } onWSFatal() { this.$MqttConnectionHookCollection1.forEach(o => { o.onWSFatal() }) } } }, 16056343, []); d(function(g, r, i, a, m, e, d) { 'use strict'; const t = { endpointWithSessionId: function(t, n) { return r(d[0]).Env.genGk(r(d[0]).MqttGkNames.mqtt_ep_with_sid) ? this.endpointWithExtraParameter(t, 'sid', n.toString()) : t }, endpointWithExtraParameters: function(t, n) { let o = t; return n.forEach((t, n, s) => { o = this.endpointWithExtraParameter(o, n, t) }), o }, endpointWithExtraParameter: function(t, n, o) { return t.indexOf('?') > 0 ? ${t}&${n}=${o} : ${t}?${n}=${o} }, generateSessionId: () => Math.floor(r(d[0]).Env.random() * Number.MAX_SAFE_INTEGER), promiseDone(t, n, o) { (arguments.length > 1 ? t.then(n, o) : t).then(null, function(t) { r(d[0]).Env.setTimeout(function() { throw t instanceof Error ? t : new Error('promiseDone') }, 0) }) }, sprintf(t, ...n) { let o = 0; return t.replace(/%s/g, () => String(n[o++])) }, hasWSSupport: () => 'WebSocket' in g && null !== g.WebSocket }; m.exports = t }, 16056341, [16056333]); d(function(g, r, i, a, m, e, d) { 'use strict'; const t = 6e4, { MESSAGE_TYPE: o, WireMessage: n, createMessageWithString: l, decodeByteMessages: c } = r(d[0]), { MqttError: s, ConnectFailure: C } = r(d[1]), { concatBuffers: h, Pinger: P } = r(d[2]), M = { SOCKET_ERROR: new s(1, 'Socket error'), SOCKET_MESSAGE: new s(2, 'Unable to parse invalid socket message'), INVALID_DATA_TYPE: new s(3, 'Received non-arraybuffer from socket.'), CONNECT_TIMEOUT: new s(4, 'Connect timed out'), CONNACK_FAILURE: new s(5, 'Connection failure due to connack'), PING_TIMEOUT: new s(6, 'Ping timeout'), APP_DISCONNECT: new s(7, 'Disconnect initiated by app'), SERVER_DISCONNECT: new s(8, 'Disconnect message sent my server'), SOCKET_CLOSE: new s(9, 'Socket connection closed') }; m.exports = class { constructor(t) { this.handleMessage = (t => { switch (t.messageType) { case o.CONNACK: if (null != this.$MqttProtocolClient7 && (r(d[3]).Env.clearTimeout(this.$MqttProtocolClient7), this.$MqttProtocolClient7 = null), t instanceof n.ConnAck) { const o = t; if (0 !== o.returnCode) return this.$MqttProtocolClient6.bumpCounter('protocol.error.connack.invalidreturncode'), this.setConnected(!1), void this.$MqttProtocolClient8(M.CONNACK_FAILURE, o.returnCode); r(d[3]).Env.scheduleCallback(() => { this.$MqttProtocolClient2.onConnectSuccess() }), null != this.$MqttProtocolClient12 && this.$MqttProtocolClient12.reset() } break; case o.PUBLISH: if (t instanceof n.Publish) { const o = t; r(d[3]).Env.scheduleCallback(() => { this.$MqttProtocolClient2.onMessageArrived(o.topic, o.payloadMessage.payloadString) }); const l = o.messageIdentifier; if (this.$MqttProtocolClient6.bumpCounter('protocol.publish.received'), 1 === o.qos && null != l) { const t = new n.PubAckUnsubAck('PUBACK', l); this.$MqttProtocolClient10(t) } } break; case o.PUBACK: if (t instanceof n.PubAckUnsubAck) { const o = t.messageIdentifier; this.$MqttProtocolClient6.bumpCounter('protocol.puback.received'), r(d[3]).Env.scheduleCallback(() => { this.$MqttProtocolClient2.onMessageDelivered('', o) }) } break; case o.PINGRESP: null != this.$MqttProtocolClient12 && this.$MqttProtocolClient12.reset(); break; case o.DISCONNECT: this.$MqttProtocolClient8(M.SERVER_DISCONNECT); break; case o.SUBACK: this.$MqttProtocolClient6.bumpCounter('protocol.suback.received'); break; case o.UNSUBACK: this.$MqttProtocolClient6.bumpCounter('protocol.unsuback.received'); break; default: this.$MqttProtocolClient6.logError(new Error('MqttProtocolClient: Received unhandled message type: ' + t.messageType), 'Received unhandled message type'), this.$MqttProtocolClient6.bumpCounter('protocol.error.handlemessage.unsupportedtype') } }), this.$MqttProtocolClient1 = t, this.$MqttProtocolClient2 = { userName: '', mqttVersion: 3, keepAliveInterval: 10, ignoreSubProtocol: !1, onConnectSuccess: () => {}, onConnectFailure: t => {}, onConnection: () => {}, onConnectionError: t => {}, onConnectionLost: t => {}, onMessageArrived: (t, o) => {}, onMessageDelivered: (t, o) => {} }, this.$MqttProtocolClient3 = 'mqttwsclient', this.$MqttProtocolClient4 = 0, this.$MqttProtocolClient5 = !1, this.$MqttProtocolClient6 = r(d[3]).Env.getLoggerInstance() } connect(t) { if (this.$MqttProtocolClient5) throw new Error('Invalid state: connect - already connected'); this.$MqttProtocolClient2 = t, this.setConnected(!1), null != this.$MqttProtocolClient7 && (r(d[3]).Env.clearTimeout(this.$MqttProtocolClient7), this.$MqttProtocolClient7 = null), this.$MqttProtocolClient7 = r(d[3]).Env.setTimeout(() => { this.$MqttProtocolClient6.bumpCounter('protocol.error.connect.timeout'), this.$MqttProtocolClient8(M.CONNECT_TIMEOUT) }, 3e4), this.$MqttProtocolClient9 = r(d[3]).Env.createSocket(this.$MqttProtocolClient1), this.$MqttProtocolClient9.binaryType = 'arraybuffer', this.$MqttProtocolClient9.onopen = (() => { this.setConnected(!0), this.$MqttProtocolClient10(new n.Connect(this.$MqttProtocolClient3, t)), t.onConnection() }), this.$MqttProtocolClient9.onmessage = (t => { const o = t.data; if (!(o instanceof ArrayBuffer)) return this.$MqttProtocolClient6.bumpCounter('protocol.error.onmessage.type'), void this.$MqttProtocolClient8(M.INVALID_DATA_TYPE); try { let t = new Uint8Array(o); null != this.$MqttProtocolClient11 && (t = h(this.$MqttProtocolClient11, t), this.$MqttProtocolClient6.bumpCounter('protocol.debug.usingMessagesBuffer'), delete this.$MqttProtocolClient11, this.$MqttProtocolClient11 = null); const n = c(t), l = n.messages; this.$MqttProtocolClient11 = n.remaining; for (let t = 0; t < l.length; t++) this.handleMessage(l[t]) } catch (t) { this.$MqttProtocolClient11 = null, this.$MqttProtocolClient6.logError(t, M.SOCKET_MESSAGE.errorMessage), this.$MqttProtocolClient6.bumpCounter('protocol.error.onmessage.parse'), this.$MqttProtocolClient8(M.SOCKET_MESSAGE) } }), this.$MqttProtocolClient9.onerror = (t => { this.$MqttProtocolClient6.bumpCounter('protocol.error.socket'), this.$MqttProtocolClient8(M.SOCKET_ERROR) }), this.$MqttProtocolClient9.onclose = (t => { this.$MqttProtocolClient6.bumpCounter('protocol.socket.close'), this.$MqttProtocolClient8(M.SOCKET_CLOSE) }), null != this.$MqttProtocolClient12 && this.$MqttProtocolClient12.cancel(), this.$MqttProtocolClient12 = new P(t.keepAliveInterval, this.$MqttProtocolClient10.bind(this, new n.Ping('PINGREQ')), this.$MqttProtocolClient8.bind(this, M.PING_TIMEOUT)) } $MqttProtocolClient13() { this.setConnected(!1), null != this.$MqttProtocolClient12 && this.$MqttProtocolClient12.cancel(), null != this.$MqttProtocolClient7 && (r(d[3]).Env.clearTimeout(this.$MqttProtocolClient7), this.$MqttProtocolClient7 = null), null != this.$MqttProtocolClient9 && (this.$MqttProtocolClient9.onopen = (t => {}), this.$MqttProtocolClient9.onmessage = (t => {}), this.$MqttProtocolClient9.onerror = (t => {}), this.$MqttProtocolClient9.onclose = (t => {}), this.$MqttProtocolClient9.readyState === this.$MqttProtocolClient9.OPEN && this.$MqttProtocolClient9.close(), delete this.$MqttProtocolClient9, this.$MqttProtocolClient9 = null), this.$MqttProtocolClient2.onConnectSuccess = (() => {}), this.$MqttProtocolClient2.onConnectFailure = (t => {}), this.$MqttProtocolClient2.onConnection = (() => {}), this.$MqttProtocolClient2.onConnectionError = (t => {}), this.$MqttProtocolClient2.onConnectionLost = (t => {}), this.$MqttProtocolClient2.onMessageArrived = ((t, o) => {}), this.$MqttProtocolClient2.onMessageDelivered = ((t, o) => {}) } disconnect() { null != this.$MqttProtocolClient9 && this.$MqttProtocolClient9.readyState === this.$MqttProtocolClient9.OPEN && this.$MqttProtocolClient5 ? (this.$MqttProtocolClient10(new n.Disconnect), this.$MqttProtocolClient6.bumpCounter('protocol.debug.disconnect'), this.$MqttProtocolClient8(M.APP_DISCONNECT)) : this.$MqttProtocolClient13() } isConnected() { return this.$MqttProtocolClient5 } setConnected(t) { this.$MqttProtocolClient5 = t } subscribe(t) { if (!this.$MqttProtocolClient5) throw this.$MqttProtocolClient6.bumpCounter('protocol.error.subscribe.notconnected'), new Error('Invalid state: subscribe - not connected'); this.$MqttProtocolClient6.bumpCounter('protocol.subscribe.' + t); const o = new n.Subscription('SUBSCRIBE', t, 0, this.$MqttProtocolClient14()); this.$MqttProtocolClient10(o) } unsubscribe(t) { if (!this.$MqttProtocolClient5) throw this.$MqttProtocolClient6.bumpCounter('protocol.error.unsubscribe.notconnected'), new Error('Invalid state: unsubscribe - not connected'); this.$MqttProtocolClient6.bumpCounter('protocol.unsubscribe.' + t); const o = new n.Subscription('UNSUBSCRIBE', t, 0, this.$MqttProtocolClient14()); this.$MqttProtocolClient10(o) } publish(t, o, c) { this.$MqttProtocolClient5 || this.$MqttProtocolClient6.bumpCounter('protocol.error.publish.notconnected'), this.$MqttProtocolClient6.bumpCounter('protocol.publish.' + t); const s = this.$MqttProtocolClient14(), C = new n.Publish(t, l(o), c, s); return this.$MqttProtocolClient10(C), s } $MqttProtocolClient14() { return ++this.$MqttProtocolClient4 === t && (this.$MqttProtocolClient4 = 1), this.$MqttProtocolClient4 } $MqttProtocolClient8(t, o) { const n = this.$MqttProtocolClient5, { onConnectionLost: l, onConnectFailure: c } = this.$MqttProtocolClient2; this.setConnected(!1), n ? r(d[3]).Env.scheduleCallback(() => { l(t) }) : r(d[3]).Env.scheduleCallback(() => { c(new C(t, null != o ? o : -1)) }), this.$MqttProtocolClient13() } $MqttProtocolClient10(t) { const o = this.$MqttProtocolClient9; null != o && o.readyState === o.OPEN && o.send(t.encode()) } } }, 16056344, [16056345, 16056342, 16056346, 16056333]); d(function(g, r, i, a, m, e, d) { function t(t, s) { let n = s; const l = n, u = t[n], p = u >> 4, I = c(t, n += 1); if (null == I) return { wireMessage: null, position: l }; const N = (n = I.offset) + I.value; if (N > t.length) return { wireMessage: null, position: l }; let T; switch (p) { case f.CONNACK: { const s = !!(1 & t[n++]), o = t[n++]; T = new A(s, o); break } case f.PUBLISH: { const s = 15 & u, c = s >> 1 & 3, l = h(t, n), p = o(t, n += 2, l); n += l; let y = null; 1 === c && (y = h(t, n), n += 2); const f = C.createWithBytes(t.subarray(n, N)); T = new S(p, f, c, y, 1 == (1 & s), 8 == (8 & s)); break } case f.PINGREQ: T = new w('PINGREQ'); break; case f.PINGRESP: T = new w('PINGRESP'); break; case f.PUBACK: case f.UNSUBACK: { const s = h(t, n); T = new U(p === f.PUBACK ? 'PUBACK' : 'UNSUBACK', s); break } case f.SUBACK: { const s = h(t, n); n += 2; T = new class extends B { constructor(t, s) { super('SUBACK'), this.messageIdentifier = t, this.returnCode = s } }(s, t.subarray(n, N)); break } default: throw new Error(y('Invalid MQTT message type %s.', p)) } return { wireMessage: T, position: N } } const { UTF8Length: s, convertStringToUTF8: n, convertUTF8ToString: o, decodeMultiByteInt: c, encodeMultiByteInt: l, readUInt16BE: h, writeString: u, writeUInt16BE: p } = r(d[0]), { sprintf: y } = r(d[1]), f = Object.freeze({ CONNECT: 1, CONNACK: 2, PUBLISH: 3, PUBACK: 4, SUBSCRIBE: 8, SUBACK: 9, UNSUBSCRIBE: 10, UNSUBACK: 11, PINGREQ: 12, PINGRESP: 13, DISCONNECT: 14 }), I = [0, 6, 77, 81, 73, 115, 100, 112, 3]; class B { constructor(t) { this.messageType = f[t] } encode() { throw new TypeError('Cannot abstract class WireMessage') } } class w extends B { constructor(t) { super(t) } encode() { const t = new ArrayBuffer(2); return new Uint8Array(t)[0] = (15 & this.messageType) << 4, t } } class A extends B { constructor(t, s) { super('CONNACK'), this.sessionPresent = t, this.returnCode = s } } class U extends B { constructor(t, s) { super(t), this.messageIdentifier = s } encode() { const t = (15 & this.messageType) << 4, s = l(2); let n = s.length + 1; const o = new ArrayBuffer(2 + n), c = new Uint8Array(o); return c[0] = t, c.set(s, 1), n = p(this.messageIdentifier, c, n), o } } class C { constructor(t, s) { this.payloadString = t, this.payloadBytes = s } static createWithString(t) { const o = new Uint8Array(new ArrayBuffer(s(t))); return n(t, o, 0), new C(t, o) } static createWithBytes(t) { let s = 0, n = t.length; for (; s < t.length && 123 !== ts && 91 !== ts;) s++, n--; const c = o(t, s, n), l = t.subarray(s, n); return new C(c, l) } string() { return this.payloadString } bytes() { return this.payloadBytes } } class S extends B { constructor(t, s, n, o, c, l) { if (super('PUBLISH'), this.topic = t, this.payloadMessage = s, this.qos = n, this.messageIdentifier = o, this.retained = null != c && c, this.duplicate = null != l && l, 1 === this.qos && null == this.messageIdentifier) throw new TypeError('Argument Invalid. messageIdentifier: null and qos: 1') } encode() { let t = (15 & this.messageType) << 4; this.duplicate && (t |= 8), t = t |= this.qos << 1, this.retained && (t |= 1); const n = s(this.topic); let o = n + 2; o += null == this.messageIdentifier ? 0 : 2; const c = this.payloadMessage.bytes(); o += c.byteLength; const h = l(o), y = new ArrayBuffer(1 + h.length + o), f = new Uint8Array(y); f[0] = t, f.set(h, 1); let I = 1 + h.length; return I = u(this.topic, n, f, I), null != this.messageIdentifier && (I = p(this.messageIdentifier, f, I)), f.set(c, I), y } } m.exports = { MESSAGE_TYPE: f, WireMessage: { Base: B, PubAckUnsubAck: U, Ping: w, ConnAck: A, Connect: class extends B { constructor(t, s) { super('CONNECT'), this.clientId = t, this.connectOptions = s } encode() { const t = (15 & this.messageType) << 4; let n = I.length + 3; n += s(this.clientId) + 2, n += s(this.connectOptions.userName) + 2; const o = l(n), c = new ArrayBuffer(1 + o.length + n), h = new Uint8Array(c); h[0] = t; let y = 1; return h.set(o, 1), y += o.length, h.set(I, y), y += I.length, h[y++] = 130, y = p(this.connectOptions.keepAliveInterval, h, y), y = u(this.clientId, s(this.clientId), h, y), y = u(this.connectOptions.userName, s(this.connectOptions.userName), h, y), c } }, Disconnect: class extends B { constructor() { super('DISCONNECT') } encode() { const t = (15 & this.messageType) << 4, s = new ArrayBuffer(2), n = new Uint8Array(s); return n[0] = t, n.set(l(0), 1), s } }, Subscription: class extends B { constructor(t, s, n, o) { if (super(t), this.topic = s, n < 0 && n > 1 || 1 === n && null == o) throw new TypeError(y('Argument Invalid. qos: %s messageType: %s.', n, t)); this.qos = n, this.messageIdentifier = o } encode() { let t = (15 & this.messageType) << 4; t |= 2; const n = s(this.topic); let o = 2 + n + 2; this.messageType === f.SUBSCRIBE && (o += 1); const c = l(o), h = new ArrayBuffer(1 + c.length + o), y = new Uint8Array(h); y[0] = t; let I = 1; return y.set(c, 1), I += c.length, null != this.messageIdentifier && (I = p(this.messageIdentifier, y, I)), I = u(this.topic, n, y, I), this.messageType === f.SUBSCRIBE && null != this.qos && (y[I++] = this.qos), h } }, Publish: S }, createMessageWithString: C.createWithString, decodeMessage: t, decodeByteMessages: function(s) { const n = []; let o = 0; for (; o < s.length;) { const c = t(s, o), l = c.wireMessage; if (o = c.position, !l) break; n.push(l) } let c = null; return o < s.length && (c = s.subarray(o)), { messages: n, remaining: c } } } }, 16056345, [16056346, 16056341]); d(function(g, r, i, a, m, e, d) { function t(t, n, o) { let s = o; return n[s++] = t >> 8, n[s++] = t % 256, s }

function n(t, n, o) {
    let s = o;
    for (let o = 0, h = t.length; o < h; o++) {
        let h = t.charCodeAt(o);
        h < 128 ? n[s++] = h : h < 2048 ? (n[s++] = 192 | h >> 6, n[s++] = 128 | 63 & h) : h < 55296 || h >= 57344 ? (n[s++] = 224 | h >> 12, n[s++] = 128 | h >> 6 & 63, n[s++] = 128 | 63 & h) : (h = 65536 + ((1023 & h) << 10 | 1023 & t.charCodeAt(++o)), n[s++] = 240 | h >> 18, n[s++] = 128 | h >> 12 & 63, n[s++] = 128 | h >> 6 & 63, n[s++] = 128 | 63 & h)
    }
}
m.exports = {
    UTF8Length: function(t) {
        let n = 0;
        for (let o = 0, s = t.length; o < s; o++) {
            const s = t.charCodeAt(o);
            s < 128 ? n += 1 : s < 2048 ? n += 2 : s >= 55296 && s <= 56319 ? (n += 4, o++) : n += 3
        }
        return n
    },
    convertStringToUTF8: n,
    concatBuffers: function(t, n) {
        if (null == t) return n;
        const o = new Uint8Array(t.length + n.length);
        return o.set(t), o.set(n, t.length), o
    },
    decodeMultiByteInt: function(t, n) {
        let o, s = n,
            h = 0,
            c = 1;
        do {
            if (s === t.length) return null;
            h += (127 & (o = t[s++])) * c, c *= 128
        } while (0 != (128 & o));
        return {
            value: h,
            offset: s
        }
    },
    convertUTF8ToString: function(t, n, o) {
        const s = [];
        let h = n,
            c = 0;
        for (; h < n + o;) {
            const n = t[h++];
            if (n < 128) s[c++] = String.fromCharCode(n);
            else if (n > 191 && n < 224) {
                const o = t[h++];
                s[c++] = String.fromCharCode((31 & n) << 6 | 63 & o)
            } else if (n > 239 && n < 365) {
                const o = ((7 & n) << 18 | (63 & t[h++]) << 12 | (63 & t[h++]) << 6 | 63 & t[h++]) - 65536;
                s[c++] = String.fromCharCode(55296 + (o >> 10)), s[c++] = String.fromCharCode(56320 + (1023 & o))
            } else {
                const o = t[h++],
                    l = t[h++];
                s[c++] = String.fromCharCode((15 & n) << 12 | (63 & o) << 6 | 63 & l)
            }
        }
        return s.join('')
    },
    encodeMultiByteInt: function(t) {
        let n = t;
        const o = new Array(1);
        for (let t = 0; t < 4; t++) {
            const s = n % 128;
            if (!((n >>= 7) > 0)) {
                o[t] = s;
                break
            }
            o[t] = 128 | s
        }
        return o
    },
    writeUInt16BE: t,
    readUInt16BE: function(t, n) {
        return 256 * t[n] + t[n + 1]
    },
    writeString: function(o, s, h, c) {
        const l = t(s, h, c);
        return n(o, h, l), l + s
    },
    Pinger: class {
        constructor(t, n, o) {
            this.$Pinger1 = 1e3 * t, this.$Pinger2 = n, this.$Pinger3 = o, this.$Pinger4 = !1
        }
        $Pinger5() {
            this.$Pinger4 ? (this.$Pinger4 = !1, this.$Pinger2(), this.$Pinger6 = r(d[0]).Env.setTimeout(() => {
                this.$Pinger5()
            }, this.$Pinger1)) : this.$Pinger3()
        }
        reset() {
            this.$Pinger4 = !0, this.$Pinger6 && (r(d[0]).Env.clearTimeout(this.$Pinger6), this.$Pinger6 = null), this.$Pinger1 > 0 && (this.$Pinger6 = r(d[0]).Env.setTimeout(() => {
                this.$Pinger5()
            }, this.$Pinger1))
        }
        cancel() {
            this.$Pinger6 && (r(d[0]).Env.clearTimeout(this.$Pinger6), this.$Pinger6 = null)
        }
    }
}

}, 16056346, [16056333]); d(function(g, r, i, a, m, e, d) { 'use strict'; m.exports = class { constructor() { this.$MqttAnalyticsHook1 = r(d[0]).Env.getLoggerInstance(), this.$MqttAnalyticsHook2 = 0, this.$MqttAnalyticsHook3 = 0, this.$MqttAnalyticsHook4 = 0, this.$MqttAnalyticsHook5 = 0, i(d[1]).incr('web.mqtt.session_start'), r(d[0]).Env.isUserLoggedInNow() || i(d[1]).incr('web.mqtt.session_start.logout') } onConnectAttempt() { i(d[1]).incr('web.mqtt.ws_connect_attempt') } onConnectFailure() { this.$MqttAnalyticsHook3++, i(d[1]).incr('web.mqtt.ws_connect_failure') } onConnected() { i(d[1]).incr('web.mqtt.ws_connect_connected') } onConnectSuccess() { 0 === this.$MqttAnalyticsHook2 && i(d[1]).incr('web.mqtt.ws_connect_first_success'), this.$MqttAnalyticsHook2++, i(d[1]).incr('web.mqtt.ws_connect_success') } onConnectionLost() { i(d[1]).incr('web.mqtt.ws_disconnect') } onSubscribe(t) {} onUnsubscribe(t) {} onPublish(t) { i(d[1]).incr('web.mqtt.ws_publish') } onMessage(t) { i(d[1]).incr('web.mqtt.message_arrived') } onWSFatal() { i(d[1]).incr('web.mqtt.ws_fatal') } onPollRequestSent() { i(d[1]).incr('web.mqtt.polling_request_send') } onPollRequestSuccess() { i(d[1]).incr('web.mqtt.polling_request_succeed'), 0 === this.$MqttAnalyticsHook4 && i(d[1]).incr('web.mqtt.polling_first_success'), this.$MqttAnalyticsHook4++ } onPollResponse(t) { i(d[1]).incr('web.mqtt.lp.message_arrived') } onPollFinish() {} onPollRequestFailed(t) { i(d[1]).incr('web.mqtt.polling_request_failed'), this.$MqttAnalyticsHook5++ } } }, 16056339, [16056333, 9961577]); d(function(g, r, i, a, m, e, d) { 'use strict'; m.exports = class { constructor(s) { if (this.$IrisSubscribeChecker1 = r(d[0]).Env.getLoggerInstance(), this.$IrisSubscribeChecker2 = null, this.$IrisSubscribeChecker3 = !1, this.$IrisSubscribeChecker4 = !1, this.$IrisSubscribeChecker5 = !1, this.$IrisSubscribeChecker6 = !0, this.$IrisSubscribeChecker7 = 0, this.$IrisSubscribeChecker8 = s, 'undefined' != typeof window) { const s = window.location.hostname; 'm.facebook.com' !== s && 'mobile.facebook.com' !== s && 'mtouch.facebook.com' !== s || (this.$IrisSubscribeChecker6 = !1) } r(d[0]).Env.genGk(r(d[0]).MqttGkNames.messenger_uses_mqtt_rollout) || (this.$IrisSubscribeChecker6 = !1) } start() { this.$IrisSubscribeChecker6 = !0 } stop() { this.$IrisSubscribeChecker6 = !1, this.$IrisSubscribeChecker9() } onConnectAttempt() {} onConnectFailure() { this.$IrisSubscribeChecker9() } onConnected() { this.$IrisSubscribeChecker7++, this.$IrisSubscribeChecker9(), this.$IrisSubscribeChecker3 = !1, this.$IrisSubscribeChecker4 = !1, this.$IrisSubscribeChecker5 = !1, this.$IrisSubscribeChecker6 && (this.$IrisSubscribeChecker2 = r(d[0]).Env.setTimeout(() => { this.$IrisSubscribeChecker10() }, 8e3)) } onConnectSuccess() {} onConnectionLost() { this.$IrisSubscribeChecker9() } onSubscribe(s) { '/t_ms' === s && (this.$IrisSubscribeChecker3 = !0) } onUnsubscribe(s) {} onPublish(s) { '/messenger_sync_get_diffs' !== s && '/messenger_sync_create_queue' !== s || (this.$IrisSubscribeChecker4 = !0, this.$IrisSubscribeChecker3 && (this.$IrisSubscribeChecker5 = !0, this.$IrisSubscribeChecker9())) } onMessage(s) {} onWSFatal() {} $IrisSubscribeChecker9() { this.$IrisSubscribeChecker2 && (r(d[0]).Env.clearTimeout(this.$IrisSubscribeChecker2), this.$IrisSubscribeChecker2 = null) } $IrisSubscribeChecker10() { if (!1 === this.$IrisSubscribeChecker4) { const s = 1 === this.$IrisSubscribeChecker7 ? 'no_iris_session_initialConnect' : 'no_iris_session'; this.$IrisSubscribeChecker1.bumpCounter(s), this.$IrisSubscribeChecker1.eventLogMiscellaneousError({ errorMessage: s }), this.$IrisSubscribeChecker8() ? this.$IrisSubscribeChecker1.bumpCounter(s + '.withProvider') : this.$IrisSubscribeChecker1.bumpCounter(s + '.withoutProvider'), !0 === this.$IrisSubscribeChecker3 ? this.$IrisSubscribeChecker1.bumpCounter(s + '.withTopicSubscribe') : this.$IrisSubscribeChecker1.bumpCounter(s + '.withoutTopicSubscribe') }!1 === this.$IrisSubscribeChecker3 && this.$IrisSubscribeChecker1.bumpCounter('no_iris_topic_subscribe'), !0 === this.$IrisSubscribeChecker3 && !0 === this.$IrisSubscribeChecker4 && !1 === this.$IrisSubscribeChecker5 && this.$IrisSubscribeChecker1.bumpCounter('session_before_topic_subscribe') } } }, 16056340, [16056333]);`