@acrobits/ipc-sdk 0.5.1 → 0.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
- (function(b,d){typeof exports=="object"&&typeof module<"u"?d(exports):typeof define=="function"&&define.amd?define(["exports"],d):(b=typeof globalThis<"u"?globalThis:b||self,d(b["@acrobits/ipc-sdk"]={}))})(this,function(b){"use strict";var _t=Object.defineProperty;var Tt=(b,d,C)=>d in b?_t(b,d,{enumerable:!0,configurable:!0,writable:!0,value:C}):b[d]=C;var I=(b,d,C)=>(Tt(b,typeof d!="symbol"?d+"":d,C),C);var d=(n=>(n.BadgeQuery="BADGE QUERY",n.Lifecycle="LIFECYCLE",n.PushToken="PUSH TOKEN",n))(d||{}),C=function(n,t){return C=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])},C(n,t)};function x(n,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");C(n,t);function e(){this.constructor=n}n.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}function B(n){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&n[t],r=0;if(e)return e.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&r>=n.length&&(n=void 0),{value:n&&n[r++],done:!n}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function T(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var r=e.call(n),i,s=[],o;try{for(;(t===void 0||t-- >0)&&!(i=r.next()).done;)s.push(i.value)}catch(c){o={error:c}}finally{try{i&&!i.done&&(e=r.return)&&e.call(r)}finally{if(o)throw o.error}}return s}function P(n,t,e){if(e||arguments.length===2)for(var r=0,i=t.length,s;r<i;r++)(s||!(r in t))&&(s||(s=Array.prototype.slice.call(t,0,r)),s[r]=t[r]);return n.concat(s||Array.prototype.slice.call(t))}function m(n){return typeof n=="function"}function q(n){var t=function(r){Error.call(r),r.stack=new Error().stack},e=n(t);return e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,e}var H=q(function(n){return function(e){n(this),this.message=e?e.length+` errors occurred during unsubscription:
1
+ (function(m,d){typeof exports=="object"&&typeof module<"u"?d(exports):typeof define=="function"&&define.amd?define(["exports"],d):(m=typeof globalThis<"u"?globalThis:m||self,d(m["@acrobits/ipc-sdk"]={}))})(this,function(m){"use strict";var Tt=Object.defineProperty;var _t=(m,d,C)=>d in m?Tt(m,d,{enumerable:!0,configurable:!0,writable:!0,value:C}):m[d]=C;var R=(m,d,C)=>(_t(m,typeof d!="symbol"?d+"":d,C),C);var d=(n=>(n.BadgeQuery="BADGE QUERY",n.Lifecycle="LIFECYCLE",n.PushToken="PUSH TOKEN",n))(d||{}),C=function(n,t){return C=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])},C(n,t)};function x(n,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");C(n,t);function e(){this.constructor=n}n.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}function B(n){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&n[t],r=0;if(e)return e.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&r>=n.length&&(n=void 0),{value:n&&n[r++],done:!n}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function _(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var r=e.call(n),i,s=[],o;try{for(;(t===void 0||t-- >0)&&!(i=r.next()).done;)s.push(i.value)}catch(u){o={error:u}}finally{try{i&&!i.done&&(e=r.return)&&e.call(r)}finally{if(o)throw o.error}}return s}function P(n,t,e){if(e||arguments.length===2)for(var r=0,i=t.length,s;r<i;r++)(s||!(r in t))&&(s||(s=Array.prototype.slice.call(t,0,r)),s[r]=t[r]);return n.concat(s||Array.prototype.slice.call(t))}function w(n){return typeof n=="function"}function q(n){var t=function(r){Error.call(r),r.stack=new Error().stack},e=n(t);return e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,e}var H=q(function(n){return function(e){n(this),this.message=e?e.length+` errors occurred during unsubscription:
2
2
  `+e.map(function(r,i){return i+1+") "+r.toString()}).join(`
3
- `):"",this.name="UnsubscriptionError",this.errors=e}});function O(n,t){if(n){var e=n.indexOf(t);0<=e&&n.splice(e,1)}}var R=function(){function n(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}return n.prototype.unsubscribe=function(){var t,e,r,i,s;if(!this.closed){this.closed=!0;var o=this._parentage;if(o)if(this._parentage=null,Array.isArray(o))try{for(var c=B(o),u=c.next();!u.done;u=c.next()){var a=u.value;a.remove(this)}}catch(f){t={error:f}}finally{try{u&&!u.done&&(e=c.return)&&e.call(c)}finally{if(t)throw t.error}}else o.remove(this);var v=this.initialTeardown;if(m(v))try{v()}catch(f){s=f instanceof H?f.errors:[f]}var y=this._finalizers;if(y){this._finalizers=null;try{for(var M=B(y),E=M.next();!E.done;E=M.next()){var se=E.value;try{ce(se)}catch(f){s=s??[],f instanceof H?s=P(P([],T(s)),T(f.errors)):s.push(f)}}}catch(f){r={error:f}}finally{try{E&&!E.done&&(i=M.return)&&i.call(M)}finally{if(r)throw r.error}}}if(s)throw new H(s)}},n.prototype.add=function(t){var e;if(t&&t!==this)if(this.closed)ce(t);else{if(t instanceof n){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=(e=this._finalizers)!==null&&e!==void 0?e:[]).push(t)}},n.prototype._hasParent=function(t){var e=this._parentage;return e===t||Array.isArray(e)&&e.includes(t)},n.prototype._addParent=function(t){var e=this._parentage;this._parentage=Array.isArray(e)?(e.push(t),e):e?[e,t]:t},n.prototype._removeParent=function(t){var e=this._parentage;e===t?this._parentage=null:Array.isArray(e)&&O(e,t)},n.prototype.remove=function(t){var e=this._finalizers;e&&O(e,t),t instanceof n&&t._removeParent(this)},n.EMPTY=function(){var t=new n;return t.closed=!0,t}(),n}(),oe=R.EMPTY;function ue(n){return n instanceof R||n&&"closed"in n&&m(n.remove)&&m(n.add)&&m(n.unsubscribe)}function ce(n){m(n)?n():n.unsubscribe()}var ae={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},z={setTimeout:function(n,t){for(var e=[],r=2;r<arguments.length;r++)e[r-2]=arguments[r];var i=z.delegate;return i!=null&&i.setTimeout?i.setTimeout.apply(i,P([n,t],T(e))):setTimeout.apply(void 0,P([n,t],T(e)))},clearTimeout:function(n){var t=z.delegate;return((t==null?void 0:t.clearTimeout)||clearTimeout)(n)},delegate:void 0};function Ae(n){z.setTimeout(function(){throw n})}function le(){}function L(n){n()}var Q=function(n){x(t,n);function t(e){var r=n.call(this)||this;return r.isStopped=!1,e?(r.destination=e,ue(e)&&e.add(r)):r.destination=Ue,r}return t.create=function(e,r,i){return new $(e,r,i)},t.prototype.next=function(e){this.isStopped||this._next(e)},t.prototype.error=function(e){this.isStopped||(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,n.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(e){this.destination.next(e)},t.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t}(R),Oe=Function.prototype.bind;function Y(n,t){return Oe.call(n,t)}var Le=function(){function n(t){this.partialObserver=t}return n.prototype.next=function(t){var e=this.partialObserver;if(e.next)try{e.next(t)}catch(r){U(r)}},n.prototype.error=function(t){var e=this.partialObserver;if(e.error)try{e.error(t)}catch(r){U(r)}else U(t)},n.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(e){U(e)}},n}(),$=function(n){x(t,n);function t(e,r,i){var s=n.call(this)||this,o;if(m(e)||!e)o={next:e??void 0,error:r??void 0,complete:i??void 0};else{var c;s&&ae.useDeprecatedNextContext?(c=Object.create(e),c.unsubscribe=function(){return s.unsubscribe()},o={next:e.next&&Y(e.next,c),error:e.error&&Y(e.error,c),complete:e.complete&&Y(e.complete,c)}):o=e}return s.destination=new Le(o),s}return t}(Q);function U(n){Ae(n)}function $e(n){throw n}var Ue={closed:!0,next:le,error:$e,complete:le},ke=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function he(n){return n}function je(n){return n.length===0?he:n.length===1?n[0]:function(e){return n.reduce(function(r,i){return i(r)},e)}}var G=function(){function n(t){t&&(this._subscribe=t)}return n.prototype.lift=function(t){var e=new n;return e.source=this,e.operator=t,e},n.prototype.subscribe=function(t,e,r){var i=this,s=Fe(t)?t:new $(t,e,r);return L(function(){var o=i,c=o.operator,u=o.source;s.add(c?c.call(s,u):u?i._subscribe(s):i._trySubscribe(s))}),s},n.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(e){t.error(e)}},n.prototype.forEach=function(t,e){var r=this;return e=de(e),new e(function(i,s){var o=new $({next:function(c){try{t(c)}catch(u){s(u),o.unsubscribe()}},error:s,complete:i});r.subscribe(o)})},n.prototype._subscribe=function(t){var e;return(e=this.source)===null||e===void 0?void 0:e.subscribe(t)},n.prototype[ke]=function(){return this},n.prototype.pipe=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return je(t)(this)},n.prototype.toPromise=function(t){var e=this;return t=de(t),new t(function(r,i){var s;e.subscribe(function(o){return s=o},function(o){return i(o)},function(){return r(s)})})},n.create=function(t){return new n(t)},n}();function de(n){var t;return(t=n??ae.Promise)!==null&&t!==void 0?t:Promise}function Ve(n){return n&&m(n.next)&&m(n.error)&&m(n.complete)}function Fe(n){return n&&n instanceof Q||Ve(n)&&ue(n)}function Ne(n){return m(n==null?void 0:n.lift)}function pe(n){return function(t){if(Ne(t))return t.lift(function(e){try{return n(e,this)}catch(r){this.error(r)}});throw new TypeError("Unable to lift unknown Observable type")}}function fe(n,t,e,r,i){return new De(n,t,e,r,i)}var De=function(n){x(t,n);function t(e,r,i,s,o,c){var u=n.call(this,e)||this;return u.onFinalize=o,u.shouldUnsubscribe=c,u._next=r?function(a){try{r(a)}catch(v){e.error(v)}}:n.prototype._next,u._error=s?function(a){try{s(a)}catch(v){e.error(v)}finally{this.unsubscribe()}}:n.prototype._error,u._complete=i?function(){try{i()}catch(a){e.error(a)}finally{this.unsubscribe()}}:n.prototype._complete,u}return t.prototype.unsubscribe=function(){var e;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var r=this.closed;n.prototype.unsubscribe.call(this),!r&&((e=this.onFinalize)===null||e===void 0||e.call(this))}},t}(Q),Be=q(function(n){return function(){n(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),ge=function(n){x(t,n);function t(){var e=n.call(this)||this;return e.closed=!1,e.currentObservers=null,e.observers=[],e.isStopped=!1,e.hasError=!1,e.thrownError=null,e}return t.prototype.lift=function(e){var r=new ve(this,this);return r.operator=e,r},t.prototype._throwIfClosed=function(){if(this.closed)throw new Be},t.prototype.next=function(e){var r=this;L(function(){var i,s;if(r._throwIfClosed(),!r.isStopped){r.currentObservers||(r.currentObservers=Array.from(r.observers));try{for(var o=B(r.currentObservers),c=o.next();!c.done;c=o.next()){var u=c.value;u.next(e)}}catch(a){i={error:a}}finally{try{c&&!c.done&&(s=o.return)&&s.call(o)}finally{if(i)throw i.error}}}})},t.prototype.error=function(e){var r=this;L(function(){if(r._throwIfClosed(),!r.isStopped){r.hasError=r.isStopped=!0,r.thrownError=e;for(var i=r.observers;i.length;)i.shift().error(e)}})},t.prototype.complete=function(){var e=this;L(function(){if(e._throwIfClosed(),!e.isStopped){e.isStopped=!0;for(var r=e.observers;r.length;)r.shift().complete()}})},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var e;return((e=this.observers)===null||e===void 0?void 0:e.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(e){return this._throwIfClosed(),n.prototype._trySubscribe.call(this,e)},t.prototype._subscribe=function(e){return this._throwIfClosed(),this._checkFinalizedStatuses(e),this._innerSubscribe(e)},t.prototype._innerSubscribe=function(e){var r=this,i=this,s=i.hasError,o=i.isStopped,c=i.observers;return s||o?oe:(this.currentObservers=null,c.push(e),new R(function(){r.currentObservers=null,O(c,e)}))},t.prototype._checkFinalizedStatuses=function(e){var r=this,i=r.hasError,s=r.thrownError,o=r.isStopped;i?e.error(s):o&&e.complete()},t.prototype.asObservable=function(){var e=new G;return e.source=this,e},t.create=function(e,r){return new ve(e,r)},t}(G),ve=function(n){x(t,n);function t(e,r){var i=n.call(this)||this;return i.destination=e,i.source=r,i}return t.prototype.next=function(e){var r,i;(i=(r=this.destination)===null||r===void 0?void 0:r.next)===null||i===void 0||i.call(r,e)},t.prototype.error=function(e){var r,i;(i=(r=this.destination)===null||r===void 0?void 0:r.error)===null||i===void 0||i.call(r,e)},t.prototype.complete=function(){var e,r;(r=(e=this.destination)===null||e===void 0?void 0:e.complete)===null||r===void 0||r.call(e)},t.prototype._subscribe=function(e){var r,i;return(i=(r=this.source)===null||r===void 0?void 0:r.subscribe(e))!==null&&i!==void 0?i:oe},t}(ge),ye={now:function(){return(ye.delegate||Date).now()},delegate:void 0},qe=function(n){x(t,n);function t(e,r){return n.call(this)||this}return t.prototype.schedule=function(e,r){return this},t}(R),k={setInterval:function(n,t){for(var e=[],r=2;r<arguments.length;r++)e[r-2]=arguments[r];var i=k.delegate;return i!=null&&i.setInterval?i.setInterval.apply(i,P([n,t],T(e))):setInterval.apply(void 0,P([n,t],T(e)))},clearInterval:function(n){var t=k.delegate;return((t==null?void 0:t.clearInterval)||clearInterval)(n)},delegate:void 0},He=function(n){x(t,n);function t(e,r){var i=n.call(this,e,r)||this;return i.scheduler=e,i.work=r,i.pending=!1,i}return t.prototype.schedule=function(e,r){var i;if(r===void 0&&(r=0),this.closed)return this;this.state=e;var s=this.id,o=this.scheduler;return s!=null&&(this.id=this.recycleAsyncId(o,s,r)),this.pending=!0,this.delay=r,this.id=(i=this.id)!==null&&i!==void 0?i:this.requestAsyncId(o,this.id,r),this},t.prototype.requestAsyncId=function(e,r,i){return i===void 0&&(i=0),k.setInterval(e.flush.bind(e,this),i)},t.prototype.recycleAsyncId=function(e,r,i){if(i===void 0&&(i=0),i!=null&&this.delay===i&&this.pending===!1)return r;r!=null&&k.clearInterval(r)},t.prototype.execute=function(e,r){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var i=this._execute(e,r);if(i)return i;this.pending===!1&&this.id!=null&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},t.prototype._execute=function(e,r){var i=!1,s;try{this.work(e)}catch(o){i=!0,s=o||new Error("Scheduled action threw falsy error")}if(i)return this.unsubscribe(),s},t.prototype.unsubscribe=function(){if(!this.closed){var e=this,r=e.id,i=e.scheduler,s=i.actions;this.work=this.state=this.scheduler=null,this.pending=!1,O(s,this),r!=null&&(this.id=this.recycleAsyncId(i,r,null)),this.delay=null,n.prototype.unsubscribe.call(this)}},t}(qe),be=function(){function n(t,e){e===void 0&&(e=n.now),this.schedulerActionCtor=t,this.now=e}return n.prototype.schedule=function(t,e,r){return e===void 0&&(e=0),new this.schedulerActionCtor(this,t).schedule(r,e)},n.now=ye.now,n}(),ze=function(n){x(t,n);function t(e,r){r===void 0&&(r=be.now);var i=n.call(this,e,r)||this;return i.actions=[],i._active=!1,i}return t.prototype.flush=function(e){var r=this.actions;if(this._active){r.push(e);return}var i;this._active=!0;do if(i=e.execute(e.state,e.delay))break;while(e=r.shift());if(this._active=!1,i){for(;e=r.shift();)e.unsubscribe();throw i}},t}(be),Qe=new ze(He),Ye=Qe;function Ge(n){return n&&m(n.schedule)}var Je=q(function(n){return function(){n(this),this.name="EmptyError",this.message="no elements in sequence"}});function A(n,t){var e=typeof t=="object";return new Promise(function(r,i){var s=new $({next:function(o){r(o),s.unsubscribe()},error:i,complete:function(){e?r(t.defaultValue):i(new Je)}});n.subscribe(s)})}function Ke(n){return n instanceof Date&&!isNaN(n)}function j(n,t){return pe(function(e,r){var i=0;e.subscribe(fe(r,function(s){r.next(n.call(t,s,i++))}))})}function We(n,t,e){n===void 0&&(n=0),e===void 0&&(e=Ye);var r=-1;return t!=null&&(Ge(t)?e=t:r=t),new G(function(i){var s=Ke(n)?+n-e.now():n;s<0&&(s=0);var o=0;return e.schedule(function(){i.closed||(i.next(o++),0<=r?this.schedule(void 0,r):i.complete())},s)})}function Xe(n,t,e){var r=m(n)||t||e?{next:n,error:t,complete:e}:n;return r?pe(function(i,s){var o;(o=r.subscribe)===null||o===void 0||o.call(r);var c=!0;i.subscribe(fe(s,function(u){var a;(a=r.next)===null||a===void 0||a.call(r,u),s.next(u)},function(){var u;c=!1,(u=r.complete)===null||u===void 0||u.call(r),s.complete()},function(u){var a;c=!1,(a=r.error)===null||a===void 0||a.call(r,u),s.error(u)},function(){var u,a;c&&((u=r.unsubscribe)===null||u===void 0||u.call(r)),(a=r.finalize)===null||a===void 0||a.call(r)}))}):he}var Ze=Object.defineProperty,et=(n,t,e)=>t in n?Ze(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,_=(n,t,e)=>(et(n,typeof t!="symbol"?t+"":t,e),e);class l extends Error{constructor(t){super(`Incorrect context (${t}). Cannot perform the requested operation.`),_(this,"context"),this.context=t}}class V extends Error{constructor(t,e,r){super(`Invalid parameter (${t}). ${r}`),this.param=t,this.value=e,this.reason=r}}class tt extends Error{constructor(t,e){super(`'streamId' value of "${t}" is different from what we expected ("${e}")`),this.streamId=t,this.expectedStreamId=e}}class rt extends Error{constructor(t){super(`Invalid version format: ${t}`)}}class me extends Error{constructor(t){super(`${t} needs to be initialized before it can be used.`)}}class we extends Error{constructor(t,e){let r=`Unsupported Protocol ${Array.isArray(t)?"versions":"version"}: (${t}).`;e&&(r+=` Minimum version supported is ${e}.`),super(r),this.version=t}}function S(n){return typeof n=="function"}function nt(n){return S(n==null?void 0:n.lift)}function F(n){return function(t){if(nt(t))return t.lift(function(e){try{return n(e,this)}catch(r){this.error(r)}});throw new TypeError("Unable to lift unknown Observable type")}}var J=function(n,t){return J=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])},J(n,t)};function K(n,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");J(n,t);function e(){this.constructor=n}n.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}function Se(n){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&n[t],r=0;if(e)return e.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&r>=n.length&&(n=void 0),{value:n&&n[r++],done:!n}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function W(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var r=e.call(n),i,s=[],o;try{for(;(t===void 0||t-- >0)&&!(i=r.next()).done;)s.push(i.value)}catch(c){o={error:c}}finally{try{i&&!i.done&&(e=r.return)&&e.call(r)}finally{if(o)throw o.error}}return s}function X(n,t,e){if(e||arguments.length===2)for(var r=0,i=t.length,s;r<i;r++)(s||!(r in t))&&(s||(s=Array.prototype.slice.call(t,0,r)),s[r]=t[r]);return n.concat(s||Array.prototype.slice.call(t))}function it(n){var t=function(r){Error.call(r),r.stack=new Error().stack},e=n(t);return e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,e}var Z=it(function(n){return function(t){n(this),this.message=t?t.length+` errors occurred during unsubscription:
3
+ `):"",this.name="UnsubscriptionError",this.errors=e}});function O(n,t){if(n){var e=n.indexOf(t);0<=e&&n.splice(e,1)}}var I=function(){function n(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}return n.prototype.unsubscribe=function(){var t,e,r,i,s;if(!this.closed){this.closed=!0;var o=this._parentage;if(o)if(this._parentage=null,Array.isArray(o))try{for(var u=B(o),c=u.next();!c.done;c=u.next()){var a=c.value;a.remove(this)}}catch(g){t={error:g}}finally{try{c&&!c.done&&(e=u.return)&&e.call(u)}finally{if(t)throw t.error}}else o.remove(this);var v=this.initialTeardown;if(w(v))try{v()}catch(g){s=g instanceof H?g.errors:[g]}var y=this._finalizers;if(y){this._finalizers=null;try{for(var M=B(y),E=M.next();!E.done;E=M.next()){var se=E.value;try{ue(se)}catch(g){s=s??[],g instanceof H?s=P(P([],_(s)),_(g.errors)):s.push(g)}}}catch(g){r={error:g}}finally{try{E&&!E.done&&(i=M.return)&&i.call(M)}finally{if(r)throw r.error}}}if(s)throw new H(s)}},n.prototype.add=function(t){var e;if(t&&t!==this)if(this.closed)ue(t);else{if(t instanceof n){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=(e=this._finalizers)!==null&&e!==void 0?e:[]).push(t)}},n.prototype._hasParent=function(t){var e=this._parentage;return e===t||Array.isArray(e)&&e.includes(t)},n.prototype._addParent=function(t){var e=this._parentage;this._parentage=Array.isArray(e)?(e.push(t),e):e?[e,t]:t},n.prototype._removeParent=function(t){var e=this._parentage;e===t?this._parentage=null:Array.isArray(e)&&O(e,t)},n.prototype.remove=function(t){var e=this._finalizers;e&&O(e,t),t instanceof n&&t._removeParent(this)},n.EMPTY=function(){var t=new n;return t.closed=!0,t}(),n}(),oe=I.EMPTY;function ce(n){return n instanceof I||n&&"closed"in n&&w(n.remove)&&w(n.add)&&w(n.unsubscribe)}function ue(n){w(n)?n():n.unsubscribe()}var ae={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},z={setTimeout:function(n,t){for(var e=[],r=2;r<arguments.length;r++)e[r-2]=arguments[r];var i=z.delegate;return i!=null&&i.setTimeout?i.setTimeout.apply(i,P([n,t],_(e))):setTimeout.apply(void 0,P([n,t],_(e)))},clearTimeout:function(n){var t=z.delegate;return((t==null?void 0:t.clearTimeout)||clearTimeout)(n)},delegate:void 0};function Ae(n){z.setTimeout(function(){throw n})}function le(){}function L(n){n()}var Q=function(n){x(t,n);function t(e){var r=n.call(this)||this;return r.isStopped=!1,e?(r.destination=e,ce(e)&&e.add(r)):r.destination=Ue,r}return t.create=function(e,r,i){return new $(e,r,i)},t.prototype.next=function(e){this.isStopped||this._next(e)},t.prototype.error=function(e){this.isStopped||(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,n.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(e){this.destination.next(e)},t.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t}(I),Oe=Function.prototype.bind;function Y(n,t){return Oe.call(n,t)}var Le=function(){function n(t){this.partialObserver=t}return n.prototype.next=function(t){var e=this.partialObserver;if(e.next)try{e.next(t)}catch(r){U(r)}},n.prototype.error=function(t){var e=this.partialObserver;if(e.error)try{e.error(t)}catch(r){U(r)}else U(t)},n.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(e){U(e)}},n}(),$=function(n){x(t,n);function t(e,r,i){var s=n.call(this)||this,o;if(w(e)||!e)o={next:e??void 0,error:r??void 0,complete:i??void 0};else{var u;s&&ae.useDeprecatedNextContext?(u=Object.create(e),u.unsubscribe=function(){return s.unsubscribe()},o={next:e.next&&Y(e.next,u),error:e.error&&Y(e.error,u),complete:e.complete&&Y(e.complete,u)}):o=e}return s.destination=new Le(o),s}return t}(Q);function U(n){Ae(n)}function $e(n){throw n}var Ue={closed:!0,next:le,error:$e,complete:le},ke=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function he(n){return n}function Fe(n){return n.length===0?he:n.length===1?n[0]:function(e){return n.reduce(function(r,i){return i(r)},e)}}var G=function(){function n(t){t&&(this._subscribe=t)}return n.prototype.lift=function(t){var e=new n;return e.source=this,e.operator=t,e},n.prototype.subscribe=function(t,e,r){var i=this,s=Ne(t)?t:new $(t,e,r);return L(function(){var o=i,u=o.operator,c=o.source;s.add(u?u.call(s,c):c?i._subscribe(s):i._trySubscribe(s))}),s},n.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(e){t.error(e)}},n.prototype.forEach=function(t,e){var r=this;return e=de(e),new e(function(i,s){var o=new $({next:function(u){try{t(u)}catch(c){s(c),o.unsubscribe()}},error:s,complete:i});r.subscribe(o)})},n.prototype._subscribe=function(t){var e;return(e=this.source)===null||e===void 0?void 0:e.subscribe(t)},n.prototype[ke]=function(){return this},n.prototype.pipe=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return Fe(t)(this)},n.prototype.toPromise=function(t){var e=this;return t=de(t),new t(function(r,i){var s;e.subscribe(function(o){return s=o},function(o){return i(o)},function(){return r(s)})})},n.create=function(t){return new n(t)},n}();function de(n){var t;return(t=n??ae.Promise)!==null&&t!==void 0?t:Promise}function je(n){return n&&w(n.next)&&w(n.error)&&w(n.complete)}function Ne(n){return n&&n instanceof Q||je(n)&&ce(n)}function Ve(n){return w(n==null?void 0:n.lift)}function pe(n){return function(t){if(Ve(t))return t.lift(function(e){try{return n(e,this)}catch(r){this.error(r)}});throw new TypeError("Unable to lift unknown Observable type")}}function fe(n,t,e,r,i){return new De(n,t,e,r,i)}var De=function(n){x(t,n);function t(e,r,i,s,o,u){var c=n.call(this,e)||this;return c.onFinalize=o,c.shouldUnsubscribe=u,c._next=r?function(a){try{r(a)}catch(v){e.error(v)}}:n.prototype._next,c._error=s?function(a){try{s(a)}catch(v){e.error(v)}finally{this.unsubscribe()}}:n.prototype._error,c._complete=i?function(){try{i()}catch(a){e.error(a)}finally{this.unsubscribe()}}:n.prototype._complete,c}return t.prototype.unsubscribe=function(){var e;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var r=this.closed;n.prototype.unsubscribe.call(this),!r&&((e=this.onFinalize)===null||e===void 0||e.call(this))}},t}(Q),Be=q(function(n){return function(){n(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),ge=function(n){x(t,n);function t(){var e=n.call(this)||this;return e.closed=!1,e.currentObservers=null,e.observers=[],e.isStopped=!1,e.hasError=!1,e.thrownError=null,e}return t.prototype.lift=function(e){var r=new ve(this,this);return r.operator=e,r},t.prototype._throwIfClosed=function(){if(this.closed)throw new Be},t.prototype.next=function(e){var r=this;L(function(){var i,s;if(r._throwIfClosed(),!r.isStopped){r.currentObservers||(r.currentObservers=Array.from(r.observers));try{for(var o=B(r.currentObservers),u=o.next();!u.done;u=o.next()){var c=u.value;c.next(e)}}catch(a){i={error:a}}finally{try{u&&!u.done&&(s=o.return)&&s.call(o)}finally{if(i)throw i.error}}}})},t.prototype.error=function(e){var r=this;L(function(){if(r._throwIfClosed(),!r.isStopped){r.hasError=r.isStopped=!0,r.thrownError=e;for(var i=r.observers;i.length;)i.shift().error(e)}})},t.prototype.complete=function(){var e=this;L(function(){if(e._throwIfClosed(),!e.isStopped){e.isStopped=!0;for(var r=e.observers;r.length;)r.shift().complete()}})},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var e;return((e=this.observers)===null||e===void 0?void 0:e.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(e){return this._throwIfClosed(),n.prototype._trySubscribe.call(this,e)},t.prototype._subscribe=function(e){return this._throwIfClosed(),this._checkFinalizedStatuses(e),this._innerSubscribe(e)},t.prototype._innerSubscribe=function(e){var r=this,i=this,s=i.hasError,o=i.isStopped,u=i.observers;return s||o?oe:(this.currentObservers=null,u.push(e),new I(function(){r.currentObservers=null,O(u,e)}))},t.prototype._checkFinalizedStatuses=function(e){var r=this,i=r.hasError,s=r.thrownError,o=r.isStopped;i?e.error(s):o&&e.complete()},t.prototype.asObservable=function(){var e=new G;return e.source=this,e},t.create=function(e,r){return new ve(e,r)},t}(G),ve=function(n){x(t,n);function t(e,r){var i=n.call(this)||this;return i.destination=e,i.source=r,i}return t.prototype.next=function(e){var r,i;(i=(r=this.destination)===null||r===void 0?void 0:r.next)===null||i===void 0||i.call(r,e)},t.prototype.error=function(e){var r,i;(i=(r=this.destination)===null||r===void 0?void 0:r.error)===null||i===void 0||i.call(r,e)},t.prototype.complete=function(){var e,r;(r=(e=this.destination)===null||e===void 0?void 0:e.complete)===null||r===void 0||r.call(e)},t.prototype._subscribe=function(e){var r,i;return(i=(r=this.source)===null||r===void 0?void 0:r.subscribe(e))!==null&&i!==void 0?i:oe},t}(ge),ye={now:function(){return(ye.delegate||Date).now()},delegate:void 0},qe=function(n){x(t,n);function t(e,r){return n.call(this)||this}return t.prototype.schedule=function(e,r){return this},t}(I),k={setInterval:function(n,t){for(var e=[],r=2;r<arguments.length;r++)e[r-2]=arguments[r];var i=k.delegate;return i!=null&&i.setInterval?i.setInterval.apply(i,P([n,t],_(e))):setInterval.apply(void 0,P([n,t],_(e)))},clearInterval:function(n){var t=k.delegate;return((t==null?void 0:t.clearInterval)||clearInterval)(n)},delegate:void 0},He=function(n){x(t,n);function t(e,r){var i=n.call(this,e,r)||this;return i.scheduler=e,i.work=r,i.pending=!1,i}return t.prototype.schedule=function(e,r){var i;if(r===void 0&&(r=0),this.closed)return this;this.state=e;var s=this.id,o=this.scheduler;return s!=null&&(this.id=this.recycleAsyncId(o,s,r)),this.pending=!0,this.delay=r,this.id=(i=this.id)!==null&&i!==void 0?i:this.requestAsyncId(o,this.id,r),this},t.prototype.requestAsyncId=function(e,r,i){return i===void 0&&(i=0),k.setInterval(e.flush.bind(e,this),i)},t.prototype.recycleAsyncId=function(e,r,i){if(i===void 0&&(i=0),i!=null&&this.delay===i&&this.pending===!1)return r;r!=null&&k.clearInterval(r)},t.prototype.execute=function(e,r){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var i=this._execute(e,r);if(i)return i;this.pending===!1&&this.id!=null&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},t.prototype._execute=function(e,r){var i=!1,s;try{this.work(e)}catch(o){i=!0,s=o||new Error("Scheduled action threw falsy error")}if(i)return this.unsubscribe(),s},t.prototype.unsubscribe=function(){if(!this.closed){var e=this,r=e.id,i=e.scheduler,s=i.actions;this.work=this.state=this.scheduler=null,this.pending=!1,O(s,this),r!=null&&(this.id=this.recycleAsyncId(i,r,null)),this.delay=null,n.prototype.unsubscribe.call(this)}},t}(qe),be=function(){function n(t,e){e===void 0&&(e=n.now),this.schedulerActionCtor=t,this.now=e}return n.prototype.schedule=function(t,e,r){return e===void 0&&(e=0),new this.schedulerActionCtor(this,t).schedule(r,e)},n.now=ye.now,n}(),ze=function(n){x(t,n);function t(e,r){r===void 0&&(r=be.now);var i=n.call(this,e,r)||this;return i.actions=[],i._active=!1,i}return t.prototype.flush=function(e){var r=this.actions;if(this._active){r.push(e);return}var i;this._active=!0;do if(i=e.execute(e.state,e.delay))break;while(e=r.shift());if(this._active=!1,i){for(;e=r.shift();)e.unsubscribe();throw i}},t}(be),Qe=new ze(He),Ye=Qe;function Ge(n){return n&&w(n.schedule)}var Je=q(function(n){return function(){n(this),this.name="EmptyError",this.message="no elements in sequence"}});function A(n,t){var e=typeof t=="object";return new Promise(function(r,i){var s=new $({next:function(o){r(o),s.unsubscribe()},error:i,complete:function(){e?r(t.defaultValue):i(new Je)}});n.subscribe(s)})}function Ke(n){return n instanceof Date&&!isNaN(n)}function F(n,t){return pe(function(e,r){var i=0;e.subscribe(fe(r,function(s){r.next(n.call(t,s,i++))}))})}function We(n,t,e){n===void 0&&(n=0),e===void 0&&(e=Ye);var r=-1;return t!=null&&(Ge(t)?e=t:r=t),new G(function(i){var s=Ke(n)?+n-e.now():n;s<0&&(s=0);var o=0;return e.schedule(function(){i.closed||(i.next(o++),0<=r?this.schedule(void 0,r):i.complete())},s)})}function Xe(n,t,e){var r=w(n)||t||e?{next:n,error:t,complete:e}:n;return r?pe(function(i,s){var o;(o=r.subscribe)===null||o===void 0||o.call(r);var u=!0;i.subscribe(fe(s,function(c){var a;(a=r.next)===null||a===void 0||a.call(r,c),s.next(c)},function(){var c;u=!1,(c=r.complete)===null||c===void 0||c.call(r),s.complete()},function(c){var a;u=!1,(a=r.error)===null||a===void 0||a.call(r,c),s.error(c)},function(){var c,a;u&&((c=r.unsubscribe)===null||c===void 0||c.call(r)),(a=r.finalize)===null||a===void 0||a.call(r)}))}):he}var Ze=Object.defineProperty,et=(n,t,e)=>t in n?Ze(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,T=(n,t,e)=>(et(n,typeof t!="symbol"?t+"":t,e),e);class l extends Error{constructor(t){super(`Incorrect context (${t}). Cannot perform the requested operation.`),T(this,"context"),this.context=t}}class j extends Error{constructor(t,e,r){super(`Invalid parameter (${t}). ${r}`),this.param=t,this.value=e,this.reason=r}}class tt extends Error{constructor(t,e){super(`'streamId' value of "${t}" is different from what we expected ("${e}")`),this.streamId=t,this.expectedStreamId=e}}class rt extends Error{constructor(t){super(`Invalid version format: ${t}`)}}class me extends Error{constructor(t){super(`${t} needs to be initialized before it can be used.`)}}class we extends Error{constructor(t,e){let r=`Unsupported Protocol ${Array.isArray(t)?"versions":"version"}: (${t}).`;e&&(r+=` Minimum version supported is ${e}.`),super(r),this.version=t}}function S(n){return typeof n=="function"}function nt(n){return S(n==null?void 0:n.lift)}function N(n){return function(t){if(nt(t))return t.lift(function(e){try{return n(e,this)}catch(r){this.error(r)}});throw new TypeError("Unable to lift unknown Observable type")}}var J=function(n,t){return J=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])},J(n,t)};function K(n,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");J(n,t);function e(){this.constructor=n}n.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}function Se(n){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&n[t],r=0;if(e)return e.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&r>=n.length&&(n=void 0),{value:n&&n[r++],done:!n}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function W(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var r=e.call(n),i,s=[],o;try{for(;(t===void 0||t-- >0)&&!(i=r.next()).done;)s.push(i.value)}catch(u){o={error:u}}finally{try{i&&!i.done&&(e=r.return)&&e.call(r)}finally{if(o)throw o.error}}return s}function X(n,t,e){if(e||arguments.length===2)for(var r=0,i=t.length,s;r<i;r++)(s||!(r in t))&&(s||(s=Array.prototype.slice.call(t,0,r)),s[r]=t[r]);return n.concat(s||Array.prototype.slice.call(t))}function it(n){var t=function(r){Error.call(r),r.stack=new Error().stack},e=n(t);return e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,e}var Z=it(function(n){return function(t){n(this),this.message=t?t.length+` errors occurred during unsubscription:
4
4
  `+t.map(function(e,r){return r+1+") "+e.toString()}).join(`
5
- `):"",this.name="UnsubscriptionError",this.errors=t}});function Ee(n,t){if(n){var e=n.indexOf(t);0<=e&&n.splice(e,1)}}var ee=function(){function n(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}return n.prototype.unsubscribe=function(){var t,e,r,i,s;if(!this.closed){this.closed=!0;var o=this._parentage;if(o)if(this._parentage=null,Array.isArray(o))try{for(var c=Se(o),u=c.next();!u.done;u=c.next()){var a=u.value;a.remove(this)}}catch(f){t={error:f}}finally{try{u&&!u.done&&(e=c.return)&&e.call(c)}finally{if(t)throw t.error}}else o.remove(this);var v=this.initialTeardown;if(S(v))try{v()}catch(f){s=f instanceof Z?f.errors:[f]}var y=this._finalizers;if(y){this._finalizers=null;try{for(var M=Se(y),E=M.next();!E.done;E=M.next()){var se=E.value;try{Me(se)}catch(f){s=s??[],f instanceof Z?s=X(X([],W(s)),W(f.errors)):s.push(f)}}}catch(f){r={error:f}}finally{try{E&&!E.done&&(i=M.return)&&i.call(M)}finally{if(r)throw r.error}}}if(s)throw new Z(s)}},n.prototype.add=function(t){var e;if(t&&t!==this)if(this.closed)Me(t);else{if(t instanceof n){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=(e=this._finalizers)!==null&&e!==void 0?e:[]).push(t)}},n.prototype._hasParent=function(t){var e=this._parentage;return e===t||Array.isArray(e)&&e.includes(t)},n.prototype._addParent=function(t){var e=this._parentage;this._parentage=Array.isArray(e)?(e.push(t),e):e?[e,t]:t},n.prototype._removeParent=function(t){var e=this._parentage;e===t?this._parentage=null:Array.isArray(e)&&Ee(e,t)},n.prototype.remove=function(t){var e=this._finalizers;e&&Ee(e,t),t instanceof n&&t._removeParent(this)},n.EMPTY=function(){var t=new n;return t.closed=!0,t}(),n}();ee.EMPTY;function Ce(n){return n instanceof ee||n&&"closed"in n&&S(n.remove)&&S(n.add)&&S(n.unsubscribe)}function Me(n){S(n)?n():n.unsubscribe()}var xe={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},st={setTimeout:function(n,t){for(var e=[],r=2;r<arguments.length;r++)e[r-2]=arguments[r];return setTimeout.apply(void 0,X([n,t],W(e)))},clearTimeout:function(n){return clearTimeout(n)},delegate:void 0};function ot(n){st.setTimeout(function(){throw n})}function _e(){}function ut(n){n()}var te=function(n){K(t,n);function t(e){var r=n.call(this)||this;return r.isStopped=!1,e?(r.destination=e,Ce(e)&&e.add(r)):r.destination=ht,r}return t.create=function(e,r,i){return new ne(e,r,i)},t.prototype.next=function(e){this.isStopped||this._next(e)},t.prototype.error=function(e){this.isStopped||(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,n.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(e){this.destination.next(e)},t.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t}(ee),ct=Function.prototype.bind;function re(n,t){return ct.call(n,t)}var at=function(){function n(t){this.partialObserver=t}return n.prototype.next=function(t){var e=this.partialObserver;if(e.next)try{e.next(t)}catch(r){N(r)}},n.prototype.error=function(t){var e=this.partialObserver;if(e.error)try{e.error(t)}catch(r){N(r)}else N(t)},n.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(e){N(e)}},n}(),ne=function(n){K(t,n);function t(e,r,i){var s=n.call(this)||this,o;if(S(e)||!e)o={next:e??void 0,error:r??void 0,complete:i??void 0};else{var c;s&&xe.useDeprecatedNextContext?(c=Object.create(e),c.unsubscribe=function(){return s.unsubscribe()},o={next:e.next&&re(e.next,c),error:e.error&&re(e.error,c),complete:e.complete&&re(e.complete,c)}):o=e}return s.destination=new at(o),s}return t}(te);function N(n){ot(n)}function lt(n){throw n}var ht={closed:!0,next:_e,error:lt,complete:_e},dt=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function Te(n){return n}function pt(n){return n.length===0?Te:n.length===1?n[0]:function(t){return n.reduce(function(e,r){return r(e)},t)}}var ft=function(){function n(t){t&&(this._subscribe=t)}return n.prototype.lift=function(t){var e=new n;return e.source=this,e.operator=t,e},n.prototype.subscribe=function(t,e,r){var i=this,s=vt(t)?t:new ne(t,e,r);return ut(function(){var o=i,c=o.operator,u=o.source;s.add(c?c.call(s,u):u?i._subscribe(s):i._trySubscribe(s))}),s},n.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(e){t.error(e)}},n.prototype.forEach=function(t,e){var r=this;return e=Pe(e),new e(function(i,s){var o=new ne({next:function(c){try{t(c)}catch(u){s(u),o.unsubscribe()}},error:s,complete:i});r.subscribe(o)})},n.prototype._subscribe=function(t){var e;return(e=this.source)===null||e===void 0?void 0:e.subscribe(t)},n.prototype[dt]=function(){return this},n.prototype.pipe=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return pt(t)(this)},n.prototype.toPromise=function(t){var e=this;return t=Pe(t),new t(function(r,i){var s;e.subscribe(function(o){return s=o},function(o){return i(o)},function(){return r(s)})})},n.create=function(t){return new n(t)},n}();function Pe(n){var t;return(t=n??xe.Promise)!==null&&t!==void 0?t:Promise}function gt(n){return n&&S(n.next)&&S(n.error)&&S(n.complete)}function vt(n){return n&&n instanceof te||gt(n)&&Ce(n)}function D(n,t,e,r,i){return new yt(n,t,e,r,i)}var yt=function(n){K(t,n);function t(e,r,i,s,o,c){var u=n.call(this,e)||this;return u.onFinalize=o,u.shouldUnsubscribe=c,u._next=r?function(a){try{r(a)}catch(v){e.error(v)}}:n.prototype._next,u._error=s?function(a){try{s(a)}catch(v){e.error(v)}finally{this.unsubscribe()}}:n.prototype._error,u._complete=i?function(){try{i()}catch(a){e.error(a)}finally{this.unsubscribe()}}:n.prototype._complete,u}return t.prototype.unsubscribe=function(){var e;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var r=this.closed;n.prototype.unsubscribe.call(this),!r&&((e=this.onFinalize)===null||e===void 0||e.call(this))}},t}(te);function h(n,t){return F(function(e,r){var i=0;e.subscribe(D(r,function(s){r.next(n.call(t,s,i++))}))})}var bt=new ft(function(n){return n.complete()});function w(n){return n<=0?function(){return bt}:F(function(t,e){var r=0;t.subscribe(D(e,function(i){++r<=n&&(e.next(i),n<=r&&e.complete())}))})}function g(n,t){return F(function(e,r){var i=0;e.subscribe(D(r,function(s){return n.call(t,s,i++)&&r.next(s)}))})}function p(n,t,e){var r=S(n)||t||e?{next:n,error:t,complete:e}:n;return r?F(function(i,s){var o;(o=r.subscribe)===null||o===void 0||o.call(r);var c=!0;i.subscribe(D(s,function(u){var a;(a=r.next)===null||a===void 0||a.call(r,u),s.next(u)},function(){var u;c=!1,(u=r.complete)===null||u===void 0||u.call(r),s.complete()},function(u){var a;c=!1,(a=r.error)===null||a===void 0||a.call(r,u),s.error(u)},function(){var u,a;c&&((u=r.unsubscribe)===null||u===void 0||u.call(r)),(a=r.finalize)===null||a===void 0||a.call(r)}))}):Te}const mt=/^(\d+)\.(\d+)$/;function wt(n){if(typeof n=="string"){const t=n.match(mt);if(t)return`${t[1]}.${t[2]}`}throw new rt(n)}function Ie(n){const t=wt(n),[e,r]=t.split("."),[i,s]=[parseInt(e),parseInt(r)];return[i,s]}function ie(n,t){const[e,r]=Ie(n),[i,s]=Ie(t);return e<i?-1:e>i?1:r<s?-1:r>s?1:0}function St(n,t){return ie(n,t)===1}function Et(n,t){return ie(n,t)>=0}const Re="2.0";class Ct{constructor(t,e){if(_(this,"negotiatedProtocolVersion"),_(this,"currentContext"),_(this,"incomingMessages$"),_(this,"inIframe",!1),_(this,"embeddedResult"),_(this,"iframePort1"),_(this,"iframePort2"),this.supportedVersions=t,this.logService=e,this.incomingMessages$=new ge,this.supportedVersions=t.filter(r=>Et(r,Re)),!this.supportedVersions.length)throw new we(t,Re);this.negotiatedProtocolVersion=this.supportedVersions[0],this.embeddedResult=null,this.iframePort2=null}get parent(){return window.parent}get self(){return window.self}get frameElement(){return window.frameElement}get port1(){var t,e;return this.inIframe?this.iframePort1:(e=(t=window.Acrobits)==null?void 0:t.messageChannel)==null?void 0:e.port1}get port2(){var t,e,r,i;if(this.inIframe){if(!this.iframePort2)throw new me("port2");return this.iframePort2}else{if(!((e=(t=window.Acrobits)==null?void 0:t.messageChannel)!=null&&e.port2))throw new me("port2");return(i=(r=window.Acrobits)==null?void 0:r.messageChannel)==null?void 0:i.port2}}determineContext(){return We(1e3).pipe(h(()=>(this.isEmbedded()?this.currentContext="user":this.currentContext="guest",this.currentContext)),w(1))}openBridge(){if(!this.isEmbedded())throw new l(this.currentContext);const t="HELLO",e=this.createMessage(t);e.protocolVersions=this.supportedVersions,this.logCreated(t,e);const r=this.incomingMessages$.pipe(g(i=>i.type===t&&i.replyTo===e.id),h(i=>i),p(this.logReceived(t)),h(i=>{if(this.supportedVersions.some(s=>St(s,i.protocolVersion)))throw new we(i.protocolVersion,this.supportedVersions[0]);return i}),p(i=>{this.negotiatedProtocolVersion=i.protocolVersion,this.logService.info(`[IPC] Negotiated IPC Protocol Version: ${this.negotiatedProtocolVersion}`)}),w(1));return this.logService.debug(`Created ${t} Reply handler`),this.inIframe?this.createIframeChannel().then(()=>this.finishIpcSetup(e)):this.finishIpcSetup(e),r}requestSSOToken(){if(!this.isEmbedded())throw new l(this.currentContext);const t="TOKEN",e=this.createMessage(t);this.logCreated(t,e);const r=this.incomingMessages$.pipe(g(i=>i.type===t&&i.replyTo===e.id),h(i=>i),p(this.logReceived(t)),w(1));return this.logService.debug(`Created ${t} Reply handler`),this.port2.postMessage(e),this.logSent(t,e),r}sendJoiningRoomMessage(t){if(!this.isEmbedded())throw new l(this.currentContext);const{roomName:e,roomInvite:r,displayName:i,jwtToken:s,serverUrl:o,region:c,joinMicMuted:u,joinWithoutCamera:a}=t,v="JOINING ROOM",y=this.createMessage(v,!1);y.roomName=e,y.jwtToken=s,y.serverUrl=o,y.region=c,y.roomInvite=r,y.joinMicMuted=u??!1,y.joinWithoutCamera=a??!1,y.displayName=i,this.logCreated(v,y),this.port2.postMessage(y),this.logSent(v,y)}sendLeavingRoomMessage(t){if(!this.isEmbedded())throw new l(this.currentContext);const e="LEAVING ROOM",r=this.createMessage(e,!1);r.roomName=t,this.logCreated(e,r),this.port2.postMessage(r),this.logSent(e,r)}onJoinRoomMessage(){if(!this.isEmbedded())throw new l(this.currentContext);const t="JOIN ROOM";return this.incomingMessages$.pipe(g(e=>e.type===t&&e.target==="client"),h(e=>e),p(this.logReceived(t)),h(e=>e))}onLeaveRoomMessage(){if(!this.isEmbedded())throw new l(this.currentContext);const t="LEAVE ROOM";return this.incomingMessages$.pipe(g(e=>e.type===t&&e.target==="client"),h(e=>e),p(this.logReceived(t)),h(e=>e))}onConfigMessage(){if(!this.isEmbedded())throw new l(this.currentContext);const t="CONFIG";return this.incomingMessages$.pipe(g(e=>e.type===t&&e.target==="client"),h(e=>e),p(this.logReceived(t)),h(e=>({preferredCameraType:e.preferredCameraType,preferredMicType:e.preferredMicType,preferredOutputType:e.preferredOutputType,preferredCameraDeviceLabel:e.preferredCameraDeviceLabel,preferredMicDeviceLabel:e.preferredMicDeviceLabel,preferredOutputDeviceLabel:e.preferredOutputDeviceLabel,performanceProfile:e.performanceProfile,cloudUsername:e.cloudUsername,configuredOAuthProviders:e.configuredOAuthProviders,locales:e.locales?[...e.locales]:[]})))}sendScreenshareSourceMessage(t){if(!this.isEmbedded())throw new l(this.currentContext);const e="SCREENSHARE SOURCE",r=this.createMessage(e);r.sourceTypes=t,this.logCreated(e,r);const i=this.incomingMessages$.pipe(g(s=>s.type===e&&s.replyTo===r.id),h(s=>s),p(this.logReceived(e)),h(s=>s),w(1));return this.logService.debug(`Created ${e} Reply handler`),this.port2.postMessage(r),this.logSent(e,r),i}layoutChange(t,e,r){if(!this.isEmbedded())throw new l(this.currentContext);const i="LAYOUT CHANGE";let s,o;if(e&&r?(s=this.createMessage(i,!1,r),s.result=e):(s=this.createMessage(i),o=this.incomingMessages$.pipe(g(c=>c.type===i&&c.replyTo===s.id),h(c=>c),p(this.logReceived(i)),h(c=>c),w(1)),this.logService.debug(`Created ${i} Reply handler`)),s.layout=t,this.logCreated(i,s),this.port2.postMessage(s),this.logSent(i,s),o)return o}onLayoutChangeMessage(){if(!this.isEmbedded())throw new l(this.currentContext);const t="LAYOUT CHANGE";return this.incomingMessages$.pipe(g(e=>e.type===t&&e.target==="client"&&e.replyTo===null),h(e=>e),p(this.logReceived(t)),h(e=>e))}requestOAuthToken(t){if(!this.isEmbedded())throw new l(this.currentContext);Array.isArray(t)||(t=[t]);const e="OAUTH TOKEN",r=this.createMessage(e);r.providerTypes=t,this.logCreated(e,r);const i=this.incomingMessages$.pipe(g(s=>s.type===e&&s.replyTo===r.id),h(s=>s),p(this.logReceived(e)),w(1));return this.logService.debug(`Created ${e} Reply handler`),this.port2.postMessage(r),this.logSent(e,r),i}openUrl(t,e){if(!this.isEmbedded())throw new l(this.currentContext);const r="OPEN URL",i=this.createMessage(r,!1);i.url=t,i.data=e,this.logCreated(r,i),this.port2.postMessage(i),this.logSent(r,i)}selectContacts(t,e,r,i){if(!this.isEmbedded())throw new l(this.currentContext);if(e==="group"&&i===void 0)throw new V("currentContacts",i,"currentContacts is required for group streams");if(e==="direct"&&i!==void 0)throw new V("currentContacts",i,"currentContacts should not be passed for direct streams");const s="SELECT CONTACTS",o=this.createMessage(s,!0);o.streamType=e,o.streamId=t,o.contactType=r,o.currentContacts=i,this.logCreated(s,o);const c=this.incomingMessages$.pipe(g(u=>u.type===s&&u.replyTo===o.id),p(this.logReceived(s)),h(u=>{const a=u;if(a.streamId!==t)throw new tt(a.streamId,t);return e==="direct"&&a.contacts.length>1&&(a.contacts=[a.contacts[0]]),a}),w(1));return this.logService.debug(`Created ${s} Reply handler`),this.port2.postMessage(o),this.logSent(s,o),c}matchContacts(t){if(!this.isEmbedded())throw new l(this.currentContext);if(!t.length)throw new V("contacts",t,"At least one contact is required");const e="MATCH CONTACTS",r=this.createMessage(e);r.contacts=[...t],this.logCreated(e,r);const i=this.incomingMessages$.pipe(g(s=>s.type===e&&s.replyTo===r.id),p(this.logReceived(e)),h(s=>s),w(1));return this.logService.debug(`Created ${e} Reply handler`),this.port2.postMessage(r),this.logSent(e,r),i}onPushMessageMessage(){if(!this.isEmbedded())throw new l(this.currentContext);const t="PUSH MESSAGE";return this.incomingMessages$.pipe(g(e=>e.type===t&&e.target==="client"),h(e=>e),p(this.logReceived(t)))}requestPushToken(){if(!this.isEmbedded())throw new l(this.currentContext);const t="PUSH TOKEN",e=this.createMessage(t);this.logCreated(t,e);const r=this.incomingMessages$.pipe(g(i=>i.type===t&&i.replyTo===e.id),p(this.logReceived(t)),h(i=>i),w(1));return this.logService.debug(`Created ${t} Reply handler`),this.port2.postMessage(e),this.logSent(t,e),r}onPushTokenMessage(){if(!this.isEmbedded())throw new l(this.currentContext);const t="PUSH TOKEN";return this.incomingMessages$.pipe(g(e=>e.type===t&&e.target==="client"&&e.replyTo===null&&e.expectReply===!1),h(e=>{if(e.pushToken&&e.selector&&e.appId)return e;throw new Error("PushTokenMessage is missing required PushTokenPayload fields")}),p(e=>e.pushToken),p(this.logReceived(t)))}onBadgeQueryMessage(){if(!this.isEmbedded())throw new l(this.currentContext);const t="BADGE QUERY";return this.incomingMessages$.pipe(g(e=>e.type===t&&e.target==="client"),h(e=>e),p(this.logReceived(t)))}sendBadgeUpdateMessage(t,e,r){if(!this.isEmbedded())throw new l(this.currentContext);const i="BADGE UPDATE",s=this.createMessage(i,!1,r);s.count=t,s.activity=e??!1,this.logCreated(i,s),this.port2.postMessage(s),this.logSent(i,s)}sendLifecycleMessage(t,e){if(!this.isEmbedded())throw new l(this.currentContext);const r="LIFECYCLE",i=this.createMessage(r,!1);i.eventName=t,i.payload=e,this.logCreated(r,i),this.port2.postMessage(i),this.logSent(r,i)}onLifecycleMessage(){if(!this.isEmbedded())throw new l(this.currentContext);const t="LIFECYCLE";return this.incomingMessages$.pipe(g(e=>e.type===t&&e.target==="client"),h(e=>e),p(this.logReceived(t)))}sendLogMessage(t,e){if(!this.isEmbedded())throw new l(this.currentContext);const r="LOG",i=this.createMessage(r,!1);i.level=t,i.message=e,this.logCreated(r,i),this.port2.postMessage(i),this.logSent(r,i)}onRequestLogsMessage(){if(!this.isEmbedded())throw new l(this.currentContext);const t="REQUEST LOGS";return this.incomingMessages$.pipe(g(e=>e.type===t&&e.target==="client"),h(e=>e),p(this.logReceived(t)))}sendViewTransitionMessage(t,e){if(!this.isEmbedded())throw new l(this.currentContext);const r="VIEW TRANSITION",i=this.createMessage(r,!1);i.transitionType=t,i.targetView=e,this.logCreated(r,i),this.port2.postMessage(i),this.logSent(r,i)}fileTransfer(t){if(!this.isEmbedded())throw new l(this.currentContext);const e="FILE TRANSFER",r=this.createMessage(e,!1);r.mimeType=t.mimeType,r.fileName=t.fileName,r.fileSize=t.fileSize,r.fileHash=t.fileHash,r.dataType=t.dataType,r.fileId=t.fileId,r.data=t.data,this.logCreated(e,r),this.port2.postMessage(r),this.logSent(e,r)}onFileTransferMessage(){if(!this.isEmbedded())throw new l(this.currentContext);const t="FILE TRANSFER";return this.incomingMessages$.pipe(g(e=>e.type===t&&e.target==="client"),h(e=>e),p(this.logReceived(t)))}sendFileSelectionMessage(t,e){if(!this.isEmbedded())throw new l(this.currentContext);const r="FILE SELECTION",i=this.createMessage(r);i.maxCount=t,i.mimeTypes=e,this.logCreated(r,i);const s=this.incomingMessages$.pipe(g(o=>o.type===r&&o.replyTo===i.id),p(this.logReceived(r)),h(o=>o),w(1));return this.port2.postMessage(i),this.logSent(r,i),s}sendFileDownloadMessage(t,e,r,i){if(!this.isEmbedded())throw new l(this.currentContext);const s="FILE DOWNLOAD",o=this.createMessage(s);o.url=t,o.key=e,o.fileName=r,o.mimeType=i,this.logCreated(s,o);const c=this.incomingMessages$.pipe(g(u=>u.type===s&&u.replyTo===o.id),p(this.logReceived(s)),h(u=>u),w(1));return this.port2.postMessage(o),this.logSent(s,o),c}sendFileUploadMessage(){throw new Error("Not implemented")}sendFileOpenMessage(t,e,r,i,s,o){if(!this.isEmbedded())throw new l(this.currentContext);const c="FILE OPEN",u=this.createMessage(c,!1);u.hash=s,u.url=t,u.key=e,u.mimeType=r,u.name=i,u.fileId=o,this.logCreated(c,u),this.port2.postMessage(u),this.logSent(c,u)}sendFileReferenceMessage(t,e,r){if(!this.isEmbedded())throw new l(this.currentContext);const i="FILE REFERENCE",s=this.createMessage(i,!0);s.hash=t,s.mimeType=e,s.name=r,this.logCreated(i,s);const o=this.incomingMessages$.pipe(g(c=>c.type===i&&c.replyTo===s.id),p(this.logReceived(i)),h(c=>c),w(1));return this.port2.postMessage(s),this.logSent(i,s),o}sendAppResetMessage(){if(!this.isEmbedded())throw new l(this.currentContext);const t="APP RESET",e=this.createMessage(t,!1);this.logCreated(t,e),this.port2.postMessage(e),this.logSent(t,e)}isEmbedded(){if(this.embeddedResult!==null)return this.embeddedResult;let t=!1;return this.logService.debug("Checking if running in iframe..."),t=!!this.frameElement,t||(t=this.self!==this.parent),t?(this.logService.debug("In iframe"),this.inIframe=!0,this.embeddedResult=!0,!0):(this.logService.debug("Not in iframe"),this.logService.debug("Checking if running in native app..."),!t&&(t=!!window.Acrobits,t)?(this.logService.debug("In native app"),this.embeddedResult=!0,t):(this.logService.debug("Not running in native app"),this.embeddedResult=!1,this.embeddedResult))}compareVersion(t){return ie(this.negotiatedProtocolVersion,t)}logReceived(t,e){const r=i=>this.logService.debug(`[IPC] Received ${t} message`,i);return e&&r(e),r}logSent(t,e){this.logService.debug(`[IPC] Sent ${t} message`,e)}logCreated(t,e){this.logService.debug(`[IPC] Created ${t} message`,e)}async createIframeChannel(){return new Promise(t=>{const e=r=>{r.data==="message channel port"&&(this.iframePort2=r.ports[0],this.self.removeEventListener("message",e),t())};this.self.addEventListener("message",e),this.parent.postMessage("get channel","*")})}finishIpcSetup(t){this.logService.debug("Registering listener on port2..."),this.port2.addEventListener("message",this.handleIpcMessage.bind(this)),this.port2.start(),this.logService.debug("Started listening on port2"),this.port2.postMessage(t),this.logSent("HELLO",t)}handleIpcMessage(t){const{data:e}=t;!e.id||e.target!=="client"||this.incomingMessages$.next(e)}createMessage(t,e=!0,r){return{type:t,id:this.generateId(),target:"host",expectReply:e,replyTo:r??null}}generateId(t=8,e=!1){let r="1234567890qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM";const i=[];e&&(r=r.substr(0,r.indexOf("Q")));for(let s=0;s<t;s++)i.push(r[Math.floor(Math.random()*r.length)]);return i.join("")}}const Mt=["2.0"];class xt{constructor(t){I(this,"host");I(this,"cloudId");I(this,"logger");I(this,"helper");I(this,"listeners");this.logger=t??console,this.helper=new Ct(Mt,this.logger),this.listeners=new Map,this.listeners.set(d.BadgeQuery,new Set),this.listeners.set(d.Lifecycle,new Set),this.listeners.set(d.PushToken,new Set)}get context(){return this.evaluateContext(this.helper.currentContext)}get isConnected(){return!!(this.helper.currentContext==="user"&&this.host&&this.cloudId)}get negotiatedVersion(){return this.helper.negotiatedProtocolVersion}async determineContext(){const t=await A(this.helper.determineContext(),{defaultValue:"guest"});return this.evaluateContext(t)}initiateConnection(){return A(this.helper.openBridge().pipe(Xe(t=>{this.helper.onBadgeQueryMessage().subscribe(e=>{var r;this.logger.debug("Received Badge Query: ",e);for(const i of((r=this.listeners.get(d.BadgeQuery))==null?void 0:r.values())??[])i()}),this.helper.onLifecycleMessage().subscribe(e=>{var r;this.logger.debug("Received Lifecycle Event: ",e);for(const i of((r=this.listeners.get(d.Lifecycle))==null?void 0:r.values())??[])i(e.eventName,e.payload)}),this.helper.onPushTokenMessage().subscribe(e=>{var r;this.logger.debug("Received Push Token: ",e);for(const i of((r=this.listeners.get(d.PushToken))==null?void 0:r.values())??[])i(e.pushToken,e.appId,e.selector,e.expiry)}),this.cloudId=t.cloudId,this.host=t.host}),j(()=>{})))}selectContacts(t,e,r,i){this.logger.debug("Selecting Contacts: ",...arguments);let s;if(e==="multi"){if(!r||!Array.isArray(r))throw new V("currentContacts",r,"currentContacts is required for group streams");i||(i="cloudUsername"),s=this.helper.selectContacts(t.toString(),"group",i,r)}else r?i=r:i="cloudUsername",s=this.helper.selectContacts(t.toString(),"direct",i);return A(s.pipe(j(o=>o.contacts)))}matchContacts(t){return this.logger.debug("Match Contacts: ",t),A(this.helper.matchContacts(t).pipe(j(e=>e.contacts)))}requestPushToken(){return this.logger.debug("Requesting Push Token"),A(this.helper.requestPushToken().pipe(j(t=>t.pushToken)))}badgeUpdate(t,e=!1){this.logger.debug(`Sending Badge Update, count: ${t}, activity: ${e}`),this.helper.sendBadgeUpdateMessage(t,e)}requestAppReset(){this.logger.debug("Requesting App Reset"),this.helper.sendAppResetMessage()}onBadgeQueryRequest(t){var e;return this.logger.debug("Registering for Badge Query"),(e=this.listeners.get(d.BadgeQuery))==null||e.add(t),()=>{var r;return(r=this.listeners.get(d.BadgeQuery))==null?void 0:r.delete(t)}}onLifecycleEvent(t){var e;return this.logger.debug("Registering for Lifecycle Event"),(e=this.listeners.get(d.Lifecycle))==null||e.add(t),()=>{var r;return(r=this.listeners.get(d.Lifecycle))==null?void 0:r.delete(t)}}onPushToken(t){var e;return this.logger.debug("Registering for Push Token"),(e=this.listeners.get(d.PushToken))==null||e.add(t),()=>{var r;return(r=this.listeners.get(d.PushToken))==null?void 0:r.delete(t)}}evaluateContext(t){if(t==="user")return"host";if(t==="guest")return"standalone"}}b.IPCEvents=d,b.IPCManager=xt,Object.defineProperty(b,Symbol.toStringTag,{value:"Module"})});
5
+ `):"",this.name="UnsubscriptionError",this.errors=t}});function Ee(n,t){if(n){var e=n.indexOf(t);0<=e&&n.splice(e,1)}}var ee=function(){function n(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}return n.prototype.unsubscribe=function(){var t,e,r,i,s;if(!this.closed){this.closed=!0;var o=this._parentage;if(o)if(this._parentage=null,Array.isArray(o))try{for(var u=Se(o),c=u.next();!c.done;c=u.next()){var a=c.value;a.remove(this)}}catch(g){t={error:g}}finally{try{c&&!c.done&&(e=u.return)&&e.call(u)}finally{if(t)throw t.error}}else o.remove(this);var v=this.initialTeardown;if(S(v))try{v()}catch(g){s=g instanceof Z?g.errors:[g]}var y=this._finalizers;if(y){this._finalizers=null;try{for(var M=Se(y),E=M.next();!E.done;E=M.next()){var se=E.value;try{Me(se)}catch(g){s=s??[],g instanceof Z?s=X(X([],W(s)),W(g.errors)):s.push(g)}}}catch(g){r={error:g}}finally{try{E&&!E.done&&(i=M.return)&&i.call(M)}finally{if(r)throw r.error}}}if(s)throw new Z(s)}},n.prototype.add=function(t){var e;if(t&&t!==this)if(this.closed)Me(t);else{if(t instanceof n){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=(e=this._finalizers)!==null&&e!==void 0?e:[]).push(t)}},n.prototype._hasParent=function(t){var e=this._parentage;return e===t||Array.isArray(e)&&e.includes(t)},n.prototype._addParent=function(t){var e=this._parentage;this._parentage=Array.isArray(e)?(e.push(t),e):e?[e,t]:t},n.prototype._removeParent=function(t){var e=this._parentage;e===t?this._parentage=null:Array.isArray(e)&&Ee(e,t)},n.prototype.remove=function(t){var e=this._finalizers;e&&Ee(e,t),t instanceof n&&t._removeParent(this)},n.EMPTY=function(){var t=new n;return t.closed=!0,t}(),n}();ee.EMPTY;function Ce(n){return n instanceof ee||n&&"closed"in n&&S(n.remove)&&S(n.add)&&S(n.unsubscribe)}function Me(n){S(n)?n():n.unsubscribe()}var xe={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},st={setTimeout:function(n,t){for(var e=[],r=2;r<arguments.length;r++)e[r-2]=arguments[r];return setTimeout.apply(void 0,X([n,t],W(e)))},clearTimeout:function(n){return clearTimeout(n)},delegate:void 0};function ot(n){st.setTimeout(function(){throw n})}function Te(){}function ct(n){n()}var te=function(n){K(t,n);function t(e){var r=n.call(this)||this;return r.isStopped=!1,e?(r.destination=e,Ce(e)&&e.add(r)):r.destination=ht,r}return t.create=function(e,r,i){return new ne(e,r,i)},t.prototype.next=function(e){this.isStopped||this._next(e)},t.prototype.error=function(e){this.isStopped||(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,n.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(e){this.destination.next(e)},t.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t}(ee),ut=Function.prototype.bind;function re(n,t){return ut.call(n,t)}var at=function(){function n(t){this.partialObserver=t}return n.prototype.next=function(t){var e=this.partialObserver;if(e.next)try{e.next(t)}catch(r){V(r)}},n.prototype.error=function(t){var e=this.partialObserver;if(e.error)try{e.error(t)}catch(r){V(r)}else V(t)},n.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(e){V(e)}},n}(),ne=function(n){K(t,n);function t(e,r,i){var s=n.call(this)||this,o;if(S(e)||!e)o={next:e??void 0,error:r??void 0,complete:i??void 0};else{var u;s&&xe.useDeprecatedNextContext?(u=Object.create(e),u.unsubscribe=function(){return s.unsubscribe()},o={next:e.next&&re(e.next,u),error:e.error&&re(e.error,u),complete:e.complete&&re(e.complete,u)}):o=e}return s.destination=new at(o),s}return t}(te);function V(n){ot(n)}function lt(n){throw n}var ht={closed:!0,next:Te,error:lt,complete:Te},dt=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function _e(n){return n}function pt(n){return n.length===0?_e:n.length===1?n[0]:function(t){return n.reduce(function(e,r){return r(e)},t)}}var ft=function(){function n(t){t&&(this._subscribe=t)}return n.prototype.lift=function(t){var e=new n;return e.source=this,e.operator=t,e},n.prototype.subscribe=function(t,e,r){var i=this,s=vt(t)?t:new ne(t,e,r);return ct(function(){var o=i,u=o.operator,c=o.source;s.add(u?u.call(s,c):c?i._subscribe(s):i._trySubscribe(s))}),s},n.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(e){t.error(e)}},n.prototype.forEach=function(t,e){var r=this;return e=Pe(e),new e(function(i,s){var o=new ne({next:function(u){try{t(u)}catch(c){s(c),o.unsubscribe()}},error:s,complete:i});r.subscribe(o)})},n.prototype._subscribe=function(t){var e;return(e=this.source)===null||e===void 0?void 0:e.subscribe(t)},n.prototype[dt]=function(){return this},n.prototype.pipe=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return pt(t)(this)},n.prototype.toPromise=function(t){var e=this;return t=Pe(t),new t(function(r,i){var s;e.subscribe(function(o){return s=o},function(o){return i(o)},function(){return r(s)})})},n.create=function(t){return new n(t)},n}();function Pe(n){var t;return(t=n??xe.Promise)!==null&&t!==void 0?t:Promise}function gt(n){return n&&S(n.next)&&S(n.error)&&S(n.complete)}function vt(n){return n&&n instanceof te||gt(n)&&Ce(n)}function D(n,t,e,r,i){return new yt(n,t,e,r,i)}var yt=function(n){K(t,n);function t(e,r,i,s,o,u){var c=n.call(this,e)||this;return c.onFinalize=o,c.shouldUnsubscribe=u,c._next=r?function(a){try{r(a)}catch(v){e.error(v)}}:n.prototype._next,c._error=s?function(a){try{s(a)}catch(v){e.error(v)}finally{this.unsubscribe()}}:n.prototype._error,c._complete=i?function(){try{i()}catch(a){e.error(a)}finally{this.unsubscribe()}}:n.prototype._complete,c}return t.prototype.unsubscribe=function(){var e;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var r=this.closed;n.prototype.unsubscribe.call(this),!r&&((e=this.onFinalize)===null||e===void 0||e.call(this))}},t}(te);function h(n,t){return N(function(e,r){var i=0;e.subscribe(D(r,function(s){r.next(n.call(t,s,i++))}))})}var bt=new ft(function(n){return n.complete()});function b(n){return n<=0?function(){return bt}:N(function(t,e){var r=0;t.subscribe(D(e,function(i){++r<=n&&(e.next(i),n<=r&&e.complete())}))})}function f(n,t){return N(function(e,r){var i=0;e.subscribe(D(r,function(s){return n.call(t,s,i++)&&r.next(s)}))})}function p(n,t,e){var r=S(n)||t||e?{next:n,error:t,complete:e}:n;return r?N(function(i,s){var o;(o=r.subscribe)===null||o===void 0||o.call(r);var u=!0;i.subscribe(D(s,function(c){var a;(a=r.next)===null||a===void 0||a.call(r,c),s.next(c)},function(){var c;u=!1,(c=r.complete)===null||c===void 0||c.call(r),s.complete()},function(c){var a;u=!1,(a=r.error)===null||a===void 0||a.call(r,c),s.error(c)},function(){var c,a;u&&((c=r.unsubscribe)===null||c===void 0||c.call(r)),(a=r.finalize)===null||a===void 0||a.call(r)}))}):_e}const mt=/^(\d+)\.(\d+)$/;function wt(n){if(typeof n=="string"){const t=n.match(mt);if(t)return`${t[1]}.${t[2]}`}throw new rt(n)}function Re(n){const t=wt(n),[e,r]=t.split("."),[i,s]=[parseInt(e),parseInt(r)];return[i,s]}function ie(n,t){const[e,r]=Re(n),[i,s]=Re(t);return e<i?-1:e>i?1:r<s?-1:r>s?1:0}function St(n,t){return ie(n,t)===1}function Et(n,t){return ie(n,t)>=0}const Ie="2.0";class Ct{constructor(t,e){if(T(this,"negotiatedProtocolVersion"),T(this,"currentContext"),T(this,"incomingMessages$"),T(this,"inIframe",!1),T(this,"embeddedResult"),T(this,"iframePort1"),T(this,"iframePort2"),this.supportedVersions=t,this.logService=e,this.incomingMessages$=new ge,this.supportedVersions=t.filter(r=>Et(r,Ie)),!this.supportedVersions.length)throw new we(t,Ie);this.negotiatedProtocolVersion=this.supportedVersions[0],this.embeddedResult=null,this.iframePort2=null}get parent(){return window.parent}get self(){return window.self}get frameElement(){return window.frameElement}get port1(){var t,e;return this.inIframe?this.iframePort1:(e=(t=window.Acrobits)==null?void 0:t.messageChannel)==null?void 0:e.port1}get port2(){var t,e,r,i;if(this.inIframe){if(!this.iframePort2)throw new me("port2");return this.iframePort2}else{if(!((e=(t=window.Acrobits)==null?void 0:t.messageChannel)!=null&&e.port2))throw new me("port2");return(i=(r=window.Acrobits)==null?void 0:r.messageChannel)==null?void 0:i.port2}}determineContext(){return We(1e3).pipe(h(()=>(this.isEmbedded()?this.currentContext="user":this.currentContext="guest",this.currentContext)),b(1))}openBridge(){if(!this.isEmbedded())throw new l(this.currentContext);const t="HELLO",e=this.createMessage(t);e.protocolVersions=this.supportedVersions,this.logCreated(t,e);const r=this.incomingMessages$.pipe(f(i=>i.type===t&&i.replyTo===e.id),h(i=>i),p(this.logReceived(t)),h(i=>{if(this.supportedVersions.some(s=>St(s,i.protocolVersion)))throw new we(i.protocolVersion,this.supportedVersions[0]);return i}),p(i=>{this.negotiatedProtocolVersion=i.protocolVersion,this.logService.info(`[IPC] Negotiated IPC Protocol Version: ${this.negotiatedProtocolVersion}`)}),b(1));return this.logService.debug(`Created ${t} Reply handler`),this.inIframe?this.createIframeChannel().then(()=>this.finishIpcSetup(e)):this.finishIpcSetup(e),r}requestSSOToken(){if(!this.isEmbedded())throw new l(this.currentContext);const t="TOKEN",e=this.createMessage(t);this.logCreated(t,e);const r=this.incomingMessages$.pipe(f(i=>i.type===t&&i.replyTo===e.id),h(i=>i),p(this.logReceived(t)),b(1));return this.logService.debug(`Created ${t} Reply handler`),this.port2.postMessage(e),this.logSent(t,e),r}sendJoiningRoomMessage(t){if(!this.isEmbedded())throw new l(this.currentContext);const{roomName:e,roomInvite:r,displayName:i,jwtToken:s,serverUrl:o,region:u,joinMicMuted:c,joinWithoutCamera:a}=t,v="JOINING ROOM",y=this.createMessage(v,!1);y.roomName=e,y.jwtToken=s,y.serverUrl=o,y.region=u,y.roomInvite=r,y.joinMicMuted=c??!1,y.joinWithoutCamera=a??!1,y.displayName=i,this.logCreated(v,y),this.port2.postMessage(y),this.logSent(v,y)}sendLeavingRoomMessage(t){if(!this.isEmbedded())throw new l(this.currentContext);const e="LEAVING ROOM",r=this.createMessage(e,!1);r.roomName=t,this.logCreated(e,r),this.port2.postMessage(r),this.logSent(e,r)}onJoinRoomMessage(){if(!this.isEmbedded())throw new l(this.currentContext);const t="JOIN ROOM";return this.incomingMessages$.pipe(f(e=>e.type===t&&e.target==="client"),h(e=>e),p(this.logReceived(t)),h(e=>e))}onLeaveRoomMessage(){if(!this.isEmbedded())throw new l(this.currentContext);const t="LEAVE ROOM";return this.incomingMessages$.pipe(f(e=>e.type===t&&e.target==="client"),h(e=>e),p(this.logReceived(t)),h(e=>e))}onConfigMessage(){if(!this.isEmbedded())throw new l(this.currentContext);const t="CONFIG";return this.incomingMessages$.pipe(f(e=>e.type===t&&e.target==="client"),h(e=>e),p(this.logReceived(t)),h(e=>({preferredCameraType:e.preferredCameraType,preferredMicType:e.preferredMicType,preferredOutputType:e.preferredOutputType,preferredCameraDeviceLabel:e.preferredCameraDeviceLabel,preferredMicDeviceLabel:e.preferredMicDeviceLabel,preferredOutputDeviceLabel:e.preferredOutputDeviceLabel,performanceProfile:e.performanceProfile,cloudUsername:e.cloudUsername,configuredOAuthProviders:e.configuredOAuthProviders,locales:e.locales?[...e.locales]:[]})))}sendScreenshareSourceMessage(t){if(!this.isEmbedded())throw new l(this.currentContext);const e="SCREENSHARE SOURCE",r=this.createMessage(e);r.sourceTypes=t,this.logCreated(e,r);const i=this.incomingMessages$.pipe(f(s=>s.type===e&&s.replyTo===r.id),h(s=>s),p(this.logReceived(e)),h(s=>s),b(1));return this.logService.debug(`Created ${e} Reply handler`),this.port2.postMessage(r),this.logSent(e,r),i}layoutChange(t,e,r){if(!this.isEmbedded())throw new l(this.currentContext);const i="LAYOUT CHANGE";let s,o;if(e&&r?(s=this.createMessage(i,!1,r),s.result=e):(s=this.createMessage(i),o=this.incomingMessages$.pipe(f(u=>u.type===i&&u.replyTo===s.id),h(u=>u),p(this.logReceived(i)),h(u=>u),b(1)),this.logService.debug(`Created ${i} Reply handler`)),s.layout=t,this.logCreated(i,s),this.port2.postMessage(s),this.logSent(i,s),o)return o}onLayoutChangeMessage(){if(!this.isEmbedded())throw new l(this.currentContext);const t="LAYOUT CHANGE";return this.incomingMessages$.pipe(f(e=>e.type===t&&e.target==="client"&&e.replyTo===null),h(e=>e),p(this.logReceived(t)),h(e=>e))}requestOAuthToken(t){if(!this.isEmbedded())throw new l(this.currentContext);Array.isArray(t)||(t=[t]);const e="OAUTH TOKEN",r=this.createMessage(e);r.providerTypes=t,this.logCreated(e,r);const i=this.incomingMessages$.pipe(f(s=>s.type===e&&s.replyTo===r.id),h(s=>s),p(this.logReceived(e)),b(1));return this.logService.debug(`Created ${e} Reply handler`),this.port2.postMessage(r),this.logSent(e,r),i}openUrl(t,e){if(!this.isEmbedded())throw new l(this.currentContext);const r="OPEN URL",i=this.createMessage(r,!1);i.url=t,i.data=e,this.logCreated(r,i),this.port2.postMessage(i),this.logSent(r,i)}selectContacts(t,e,r,i){if(!this.isEmbedded())throw new l(this.currentContext);if(e==="group"&&i===void 0)throw new j("currentContacts",i,"currentContacts is required for group streams");if(e==="direct"&&i!==void 0)throw new j("currentContacts",i,"currentContacts should not be passed for direct streams");const s="SELECT CONTACTS",o=this.createMessage(s,!0);o.streamType=e,o.streamId=t,o.contactType=r,o.currentContacts=i,this.logCreated(s,o);const u=this.incomingMessages$.pipe(f(c=>c.type===s&&c.replyTo===o.id),p(this.logReceived(s)),h(c=>{const a=c;if(a.streamId!==t)throw new tt(a.streamId,t);return e==="direct"&&a.contacts.length>1&&(a.contacts=[a.contacts[0]]),a}),b(1));return this.logService.debug(`Created ${s} Reply handler`),this.port2.postMessage(o),this.logSent(s,o),u}matchContacts(t){if(!this.isEmbedded())throw new l(this.currentContext);if(!t.length)throw new j("contacts",t,"At least one contact is required");const e="MATCH CONTACTS",r=this.createMessage(e);r.contacts=[...t],this.logCreated(e,r);const i=this.incomingMessages$.pipe(f(s=>s.type===e&&s.replyTo===r.id),p(this.logReceived(e)),h(s=>s),b(1));return this.logService.debug(`Created ${e} Reply handler`),this.port2.postMessage(r),this.logSent(e,r),i}onPushMessageMessage(){if(!this.isEmbedded())throw new l(this.currentContext);const t="PUSH MESSAGE";return this.incomingMessages$.pipe(f(e=>e.type===t&&e.target==="client"),h(e=>e),p(this.logReceived(t)))}requestPushToken(){if(!this.isEmbedded())throw new l(this.currentContext);const t="PUSH TOKEN",e=this.createMessage(t);this.logCreated(t,e);const r=this.incomingMessages$.pipe(f(i=>i.type===t&&i.replyTo===e.id),p(this.logReceived(t)),h(i=>i),b(1));return this.logService.debug(`Created ${t} Reply handler`),this.port2.postMessage(e),this.logSent(t,e),r}onPushTokenMessage(){if(!this.isEmbedded())throw new l(this.currentContext);const t="PUSH TOKEN";return this.incomingMessages$.pipe(f(e=>e.type===t&&e.target==="client"&&e.replyTo===null&&e.expectReply===!1),h(e=>{if(e.pushToken&&e.selector&&e.appId)return e;throw new Error("PushTokenMessage is missing required PushTokenPayload fields")}),p(e=>e.pushToken),p(this.logReceived(t)))}onBadgeQueryMessage(){if(!this.isEmbedded())throw new l(this.currentContext);const t="BADGE QUERY";return this.incomingMessages$.pipe(f(e=>e.type===t&&e.target==="client"),h(e=>e),p(this.logReceived(t)))}sendBadgeUpdateMessage(t,e,r){if(!this.isEmbedded())throw new l(this.currentContext);const i="BADGE UPDATE",s=this.createMessage(i,!1,r);s.count=t,s.activity=e??!1,this.logCreated(i,s),this.port2.postMessage(s),this.logSent(i,s)}sendLifecycleMessage(t,e){if(!this.isEmbedded())throw new l(this.currentContext);const r="LIFECYCLE",i=this.createMessage(r,!1);i.eventName=t,i.payload=e,this.logCreated(r,i),this.port2.postMessage(i),this.logSent(r,i)}onLifecycleMessage(){if(!this.isEmbedded())throw new l(this.currentContext);const t="LIFECYCLE";return this.incomingMessages$.pipe(f(e=>e.type===t&&e.target==="client"),h(e=>e),p(this.logReceived(t)))}sendLogMessage(t,e){if(!this.isEmbedded())throw new l(this.currentContext);const r="LOG",i=this.createMessage(r,!1);i.level=t,i.message=e,this.logCreated(r,i),this.port2.postMessage(i),this.logSent(r,i)}onRequestLogsMessage(){if(!this.isEmbedded())throw new l(this.currentContext);const t="REQUEST LOGS";return this.incomingMessages$.pipe(f(e=>e.type===t&&e.target==="client"),h(e=>e),p(this.logReceived(t)))}sendViewTransitionMessage(t,e){if(!this.isEmbedded())throw new l(this.currentContext);const r="VIEW TRANSITION",i=this.createMessage(r,!1);i.transitionType=t,i.targetView=e,this.logCreated(r,i),this.port2.postMessage(i),this.logSent(r,i)}sendFileTransferMessage(t,e){if(!this.isEmbedded())throw new l(this.currentContext);const r="FILE TRANSFER",i=this.createMessage(r,!1);i.mimeType=t.mimeType,i.fileName=t.fileName,i.fileSize=t.fileSize,i.fileHash=t.fileHash,i.dataType=t.dataType,i.data=t.data,e&&(i.shouldOpen=e),this.logCreated(r,i);const s=this.incomingMessages$.pipe(f(o=>o.type===r&&o.replyTo===i.id),p(this.logReceived(r)),h(o=>o),b(1));return this.port2.postMessage(i),this.logSent(r,i),s}sendFileTransferMessageReply(t,e,r){if(!this.isEmbedded())throw new l(this.currentContext);const i="FILE TRANSFER",s=this.createMessage(i,!1,t);s.result=e,r&&e==="error"&&(s.errorMessage=r),this.logCreated(i,s),this.port2.postMessage(s),this.logSent(i,s)}onFileTransferMessage(){if(!this.isEmbedded())throw new l(this.currentContext);const t="FILE TRANSFER";return this.incomingMessages$.pipe(f(e=>e.type===t&&e.target==="client"&&e.replyTo===null),h(e=>e),p(this.logReceived(t)))}sendFileSelectionMessage(t,e){if(!this.isEmbedded())throw new l(this.currentContext);const r="FILE SELECTION",i=this.createMessage(r);i.maxCount=t,i.mimeTypes=e,this.logCreated(r,i);const s=this.incomingMessages$.pipe(f(o=>o.type===r&&o.replyTo===i.id),p(this.logReceived(r)),h(o=>o),b(1));return this.port2.postMessage(i),this.logSent(r,i),s}sendFileDownloadMessage(t,e,r,i){if(!this.isEmbedded())throw new l(this.currentContext);const s="FILE DOWNLOAD",o=this.createMessage(s);o.url=t,o.key=e,o.fileName=r,o.mimeType=i,this.logCreated(s,o);const u=this.incomingMessages$.pipe(f(c=>c.type===s&&c.replyTo===o.id),p(this.logReceived(s)),h(c=>c),b(1));return this.port2.postMessage(o),this.logSent(s,o),u}sendFileUploadMessage(){throw new Error("Not implemented")}sendFileOpenMessage(t){if(!this.isEmbedded())throw new l(this.currentContext);const e="FILE OPEN",r=this.createMessage(e,!0);r.hash=t,this.logCreated(e,r);const i=this.incomingMessages$.pipe(f(s=>s.type===e&&s.replyTo===r.id),p(this.logReceived(e)),h(s=>s),b(1));return this.port2.postMessage(r),this.logSent(e,r),i}sendFileReferenceMessage(t,e,r){if(!this.isEmbedded())throw new l(this.currentContext);const i="FILE REFERENCE",s=this.createMessage(i,!0);s.hash=t,s.mimeType=e,s.name=r,this.logCreated(i,s);const o=this.incomingMessages$.pipe(f(u=>u.type===i&&u.replyTo===s.id),p(this.logReceived(i)),h(u=>u),b(1));return this.port2.postMessage(s),this.logSent(i,s),o}sendAppResetMessage(){if(!this.isEmbedded())throw new l(this.currentContext);const t="APP RESET",e=this.createMessage(t,!1);this.logCreated(t,e),this.port2.postMessage(e),this.logSent(t,e)}isEmbedded(){if(this.embeddedResult!==null)return this.embeddedResult;let t=!1;return this.logService.debug("Checking if running in iframe..."),t=!!this.frameElement,t||(t=this.self!==this.parent),t?(this.logService.debug("In iframe"),this.inIframe=!0,this.embeddedResult=!0,!0):(this.logService.debug("Not in iframe"),this.logService.debug("Checking if running in native app..."),!t&&(t=!!window.Acrobits,t)?(this.logService.debug("In native app"),this.embeddedResult=!0,t):(this.logService.debug("Not running in native app"),this.embeddedResult=!1,this.embeddedResult))}compareVersion(t){return ie(this.negotiatedProtocolVersion,t)}logReceived(t,e){const r=i=>this.logService.debug(`[IPC] Received ${t} message`,i);return e&&r(e),r}logSent(t,e){this.logService.debug(`[IPC] Sent ${t} message`,e)}logCreated(t,e){this.logService.debug(`[IPC] Created ${t} message`,e)}async createIframeChannel(){return new Promise(t=>{const e=r=>{r.data==="message channel port"&&(this.iframePort2=r.ports[0],this.self.removeEventListener("message",e),t())};this.self.addEventListener("message",e),this.parent.postMessage("get channel","*")})}finishIpcSetup(t){this.logService.debug("Registering listener on port2..."),this.port2.addEventListener("message",this.handleIpcMessage.bind(this)),this.port2.start(),this.logService.debug("Started listening on port2"),this.port2.postMessage(t),this.logSent("HELLO",t)}handleIpcMessage(t){const{data:e}=t;!e.id||e.target!=="client"||this.incomingMessages$.next(e)}createMessage(t,e=!0,r){return{type:t,id:this.generateId(),target:"host",expectReply:e,replyTo:r??null}}generateId(t=8,e=!1){let r="1234567890qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM";const i=[];e&&(r=r.substr(0,r.indexOf("Q")));for(let s=0;s<t;s++)i.push(r[Math.floor(Math.random()*r.length)]);return i.join("")}}const Mt=["2.0"];class xt{constructor(t){R(this,"host");R(this,"cloudId");R(this,"logger");R(this,"helper");R(this,"listeners");this.logger=t??console,this.helper=new Ct(Mt,this.logger),this.listeners=new Map,this.listeners.set(d.BadgeQuery,new Set),this.listeners.set(d.Lifecycle,new Set),this.listeners.set(d.PushToken,new Set)}get context(){return this.evaluateContext(this.helper.currentContext)}get isConnected(){return!!(this.helper.currentContext==="user"&&this.host&&this.cloudId)}get negotiatedVersion(){return this.helper.negotiatedProtocolVersion}async determineContext(){const t=await A(this.helper.determineContext(),{defaultValue:"guest"});return this.evaluateContext(t)}initiateConnection(){return A(this.helper.openBridge().pipe(Xe(t=>{this.helper.onBadgeQueryMessage().subscribe(e=>{var r;this.logger.debug("Received Badge Query: ",e);for(const i of((r=this.listeners.get(d.BadgeQuery))==null?void 0:r.values())??[])i()}),this.helper.onLifecycleMessage().subscribe(e=>{var r;this.logger.debug("Received Lifecycle Event: ",e);for(const i of((r=this.listeners.get(d.Lifecycle))==null?void 0:r.values())??[])i(e.eventName,e.payload)}),this.helper.onPushTokenMessage().subscribe(e=>{var r;this.logger.debug("Received Push Token: ",e);for(const i of((r=this.listeners.get(d.PushToken))==null?void 0:r.values())??[])i(e.pushToken,e.appId,e.selector,e.expiry)}),this.cloudId=t.cloudId,this.host=t.host}),F(()=>{})))}selectContacts(t,e,r,i){this.logger.debug("Selecting Contacts: ",...arguments);let s;if(e==="multi"){if(!r||!Array.isArray(r))throw new j("currentContacts",r,"currentContacts is required for group streams");i||(i="cloudUsername"),s=this.helper.selectContacts(t.toString(),"group",i,r)}else r?i=r:i="cloudUsername",s=this.helper.selectContacts(t.toString(),"direct",i);return A(s.pipe(F(o=>o.contacts)))}matchContacts(t){return this.logger.debug("Match Contacts: ",t),A(this.helper.matchContacts(t).pipe(F(e=>e.contacts)))}requestPushToken(){return this.logger.debug("Requesting Push Token"),A(this.helper.requestPushToken().pipe(F(t=>t.pushToken)))}badgeUpdate(t,e=!1){this.logger.debug(`Sending Badge Update, count: ${t}, activity: ${e}`),this.helper.sendBadgeUpdateMessage(t,e)}requestAppReset(){this.logger.debug("Requesting App Reset"),this.helper.sendAppResetMessage()}onBadgeQueryRequest(t){var e;return this.logger.debug("Registering for Badge Query"),(e=this.listeners.get(d.BadgeQuery))==null||e.add(t),()=>{var r;return(r=this.listeners.get(d.BadgeQuery))==null?void 0:r.delete(t)}}onLifecycleEvent(t){var e;return this.logger.debug("Registering for Lifecycle Event"),(e=this.listeners.get(d.Lifecycle))==null||e.add(t),()=>{var r;return(r=this.listeners.get(d.Lifecycle))==null?void 0:r.delete(t)}}onPushToken(t){var e;return this.logger.debug("Registering for Push Token"),(e=this.listeners.get(d.PushToken))==null||e.add(t),()=>{var r;return(r=this.listeners.get(d.PushToken))==null?void 0:r.delete(t)}}evaluateContext(t){if(t==="user")return"host";if(t==="guest")return"standalone"}}m.IPCEvents=d,m.IPCManager=xt,Object.defineProperty(m,Symbol.toStringTag,{value:"Module"})});