@acrobits/ipc-sdk 0.1.0 → 0.1.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
- var Tt=Object.defineProperty;var At=(p,l,y)=>l in p?Tt(p,l,{enumerable:!0,configurable:!0,writable:!0,value:y}):p[l]=y;var P=(p,l,y)=>(At(p,typeof l!="symbol"?l+"":l,y),y),Rt=(p,l,y)=>{if(!l.has(p))throw TypeError("Cannot "+y)};var $e=(p,l,y)=>{if(l.has(p))throw TypeError("Cannot add the same private member more than once");l instanceof WeakSet?l.add(p):l.set(p,y)};var se=(p,l,y)=>(Rt(p,l,"access private method"),y);(function(p,l){typeof exports=="object"&&typeof module<"u"?l(exports):typeof define=="function"&&define.amd?define(["exports"],l):(p=typeof globalThis<"u"?globalThis:p||self,l(p["@acrobits/ipc-sdk"]={}))})(this,function(p){var R,ue;"use strict";var l=(n=>(n.BadgeQuery="BADGE QUERY",n.HostInForeground="HOST IN FOREGROUND",n))(l||{}),y=function(n,t){return y=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])},y(n,t)};function _(n,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");y(n,t);function e(){this.constructor=n}n.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}function N(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 I(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var r=e.call(n),i,o=[],s;try{for(;(t===void 0||t-- >0)&&!(i=r.next()).done;)o.push(i.value)}catch(c){s={error:c}}finally{try{i&&!i.done&&(e=r.return)&&e.call(r)}finally{if(s)throw s.error}}return o}function O(n,t,e){if(e||arguments.length===2)for(var r=0,i=t.length,o;r<i;r++)(o||!(r in t))&&(o||(o=Array.prototype.slice.call(t,0,r)),o[r]=t[r]);return n.concat(o||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 z=q(function(n){return function(e){n(this),this.message=e?e.length+` errors occurred during unsubscription:
1
+ (function(y,d){typeof exports=="object"&&typeof module<"u"?d(exports):typeof define=="function"&&define.amd?define(["exports"],d):(y=typeof globalThis<"u"?globalThis:y||self,d(y["@acrobits/ipc-sdk"]={}))})(this,function(y){"use strict";var Mt=Object.defineProperty;var It=(y,d,C)=>d in y?Mt(y,d,{enumerable:!0,configurable:!0,writable:!0,value:C}):y[d]=C;var P=(y,d,C)=>(It(y,typeof d!="symbol"?d+"":d,C),C);var d=(n=>(n.BadgeQuery="BADGE QUERY",n.HostInForeground="HOST IN FOREGROUND",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 _(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 I(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var r=e.call(n),i,o=[],s;try{for(;(t===void 0||t-- >0)&&!(i=r.next()).done;)o.push(i.value)}catch(c){s={error:c}}finally{try{i&&!i.done&&(e=r.return)&&e.call(r)}finally{if(s)throw s.error}}return o}function O(n,t,e){if(e||arguments.length===2)for(var r=0,i=t.length,o;r<i;r++)(o||!(r in t))&&(o||(o=Array.prototype.slice.call(t,0,r)),o[r]=t[r]);return n.concat(o||Array.prototype.slice.call(t))}function m(n){return typeof n=="function"}function N(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 q=N(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 U(n,t){if(n){var e=n.indexOf(t);0<=e&&n.splice(e,1)}}var T=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,o;if(!this.closed){this.closed=!0;var s=this._parentage;if(s)if(this._parentage=null,Array.isArray(s))try{for(var c=N(s),u=c.next();!u.done;u=c.next()){var a=u.value;a.remove(this)}}catch(d){t={error:d}}finally{try{u&&!u.done&&(e=c.return)&&e.call(c)}finally{if(t)throw t.error}}else s.remove(this);var v=this.initialTeardown;if(w(v))try{v()}catch(d){o=d instanceof z?d.errors:[d]}var g=this._finalizers;if(g){this._finalizers=null;try{for(var x=N(g),C=x.next();!C.done;C=x.next()){var oe=C.value;try{le(oe)}catch(d){o=o??[],d instanceof z?o=O(O([],I(o)),I(d.errors)):o.push(d)}}}catch(d){r={error:d}}finally{try{C&&!C.done&&(i=x.return)&&i.call(x)}finally{if(r)throw r.error}}}if(o)throw new z(o)}},n.prototype.add=function(t){var e;if(t&&t!==this)if(this.closed)le(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)&&U(e,t)},n.prototype.remove=function(t){var e=this._finalizers;e&&U(e,t),t instanceof n&&t._removeParent(this)},n.EMPTY=function(){var t=new n;return t.closed=!0,t}(),n}(),ce=T.EMPTY;function ae(n){return n instanceof T||n&&"closed"in n&&w(n.remove)&&w(n.add)&&w(n.unsubscribe)}function le(n){w(n)?n():n.unsubscribe()}var he={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},Q={setTimeout:function(n,t){for(var e=[],r=2;r<arguments.length;r++)e[r-2]=arguments[r];var i=Q.delegate;return i!=null&&i.setTimeout?i.setTimeout.apply(i,O([n,t],I(e))):setTimeout.apply(void 0,O([n,t],I(e)))},clearTimeout:function(n){var t=Q.delegate;return((t==null?void 0:t.clearTimeout)||clearTimeout)(n)},delegate:void 0};function je(n){Q.setTimeout(function(){throw n})}function de(){}function $(n){n()}var G=function(n){_(t,n);function t(e){var r=n.call(this)||this;return r.isStopped=!1,e?(r.destination=e,ae(e)&&e.add(r)):r.destination=De,r}return t.create=function(e,r,i){return new j(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}(T),Ve=Function.prototype.bind;function Y(n,t){return Ve.call(n,t)}var Fe=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}(),j=function(n){_(t,n);function t(e,r,i){var o=n.call(this)||this,s;if(w(e)||!e)s={next:e??void 0,error:r??void 0,complete:i??void 0};else{var c;o&&he.useDeprecatedNextContext?(c=Object.create(e),c.unsubscribe=function(){return o.unsubscribe()},s={next:e.next&&Y(e.next,c),error:e.error&&Y(e.error,c),complete:e.complete&&Y(e.complete,c)}):s=e}return o.destination=new Fe(s),o}return t}(G);function V(n){je(n)}function He(n){throw n}var De={closed:!0,next:de,error:He,complete:de},Le=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function pe(n){return n}function ke(n){return n.length===0?pe:n.length===1?n[0]:function(e){return n.reduce(function(r,i){return i(r)},e)}}var J=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,o=Ne(t)?t:new j(t,e,r);return $(function(){var s=i,c=s.operator,u=s.source;o.add(c?c.call(o,u):u?i._subscribe(o):i._trySubscribe(o))}),o},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=fe(e),new e(function(i,o){var s=new j({next:function(c){try{t(c)}catch(u){o(u),s.unsubscribe()}},error:o,complete:i});r.subscribe(s)})},n.prototype._subscribe=function(t){var e;return(e=this.source)===null||e===void 0?void 0:e.subscribe(t)},n.prototype[Le]=function(){return this},n.prototype.pipe=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return ke(t)(this)},n.prototype.toPromise=function(t){var e=this;return t=fe(t),new t(function(r,i){var o;e.subscribe(function(s){return o=s},function(s){return i(s)},function(){return r(o)})})},n.create=function(t){return new n(t)},n}();function fe(n){var t;return(t=n??he.Promise)!==null&&t!==void 0?t:Promise}function Be(n){return n&&w(n.next)&&w(n.error)&&w(n.complete)}function Ne(n){return n&&n instanceof G||Be(n)&&ae(n)}function qe(n){return w(n==null?void 0:n.lift)}function ve(n){return function(t){if(qe(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 ge(n,t,e,r,i){return new ze(n,t,e,r,i)}var ze=function(n){_(t,n);function t(e,r,i,o,s,c){var u=n.call(this,e)||this;return u.onFinalize=s,u.shouldUnsubscribe=c,u._next=r?function(a){try{r(a)}catch(v){e.error(v)}}:n.prototype._next,u._error=o?function(a){try{o(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}(G),Qe=q(function(n){return function(){n(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),be=function(n){_(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 ye(this,this);return r.operator=e,r},t.prototype._throwIfClosed=function(){if(this.closed)throw new Qe},t.prototype.next=function(e){var r=this;$(function(){var i,o;if(r._throwIfClosed(),!r.isStopped){r.currentObservers||(r.currentObservers=Array.from(r.observers));try{for(var s=N(r.currentObservers),c=s.next();!c.done;c=s.next()){var u=c.value;u.next(e)}}catch(a){i={error:a}}finally{try{c&&!c.done&&(o=s.return)&&o.call(s)}finally{if(i)throw i.error}}}})},t.prototype.error=function(e){var r=this;$(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;$(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,o=i.hasError,s=i.isStopped,c=i.observers;return o||s?ce:(this.currentObservers=null,c.push(e),new T(function(){r.currentObservers=null,U(c,e)}))},t.prototype._checkFinalizedStatuses=function(e){var r=this,i=r.hasError,o=r.thrownError,s=r.isStopped;i?e.error(o):s&&e.complete()},t.prototype.asObservable=function(){var e=new J;return e.source=this,e},t.create=function(e,r){return new ye(e,r)},t}(J),ye=function(n){_(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:ce},t}(be),me={now:function(){return(me.delegate||Date).now()},delegate:void 0},Ge=function(n){_(t,n);function t(e,r){return n.call(this)||this}return t.prototype.schedule=function(e,r){return this},t}(T),F={setInterval:function(n,t){for(var e=[],r=2;r<arguments.length;r++)e[r-2]=arguments[r];var i=F.delegate;return i!=null&&i.setInterval?i.setInterval.apply(i,O([n,t],I(e))):setInterval.apply(void 0,O([n,t],I(e)))},clearInterval:function(n){var t=F.delegate;return((t==null?void 0:t.clearInterval)||clearInterval)(n)},delegate:void 0},Ye=function(n){_(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 o=this.id,s=this.scheduler;return o!=null&&(this.id=this.recycleAsyncId(s,o,r)),this.pending=!0,this.delay=r,this.id=(i=this.id)!==null&&i!==void 0?i:this.requestAsyncId(s,this.id,r),this},t.prototype.requestAsyncId=function(e,r,i){return i===void 0&&(i=0),F.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&&F.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,o;try{this.work(e)}catch(s){i=!0,o=s||new Error("Scheduled action threw falsy error")}if(i)return this.unsubscribe(),o},t.prototype.unsubscribe=function(){if(!this.closed){var e=this,r=e.id,i=e.scheduler,o=i.actions;this.work=this.state=this.scheduler=null,this.pending=!1,U(o,this),r!=null&&(this.id=this.recycleAsyncId(i,r,null)),this.delay=null,n.prototype.unsubscribe.call(this)}},t}(Ge),we=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=me.now,n}(),Je=function(n){_(t,n);function t(e,r){r===void 0&&(r=we.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}(we),Ke=new Je(Ye),We=Ke;function Xe(n){return n&&w(n.schedule)}var Ze=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 o=new j({next:function(s){r(s),o.unsubscribe()},error:i,complete:function(){e?r(t.defaultValue):i(new Ze)}});n.subscribe(o)})}function et(n){return n instanceof Date&&!isNaN(n)}function H(n,t){return ve(function(e,r){var i=0;e.subscribe(ge(r,function(o){r.next(n.call(t,o,i++))}))})}function tt(n,t,e){n===void 0&&(n=0),e===void 0&&(e=We);var r=-1;return t!=null&&(Xe(t)?e=t:r=t),new J(function(i){var o=et(n)?+n-e.now():n;o<0&&(o=0);var s=0;return e.schedule(function(){i.closed||(i.next(s++),0<=r?this.schedule(void 0,r):i.complete())},o)})}function rt(n,t,e){var r=w(n)||t||e?{next:n,error:t,complete:e}:n;return r?ve(function(i,o){var s;(s=r.subscribe)===null||s===void 0||s.call(r);var c=!0;i.subscribe(ge(o,function(u){var a;(a=r.next)===null||a===void 0||a.call(r,u),o.next(u)},function(){var u;c=!1,(u=r.complete)===null||u===void 0||u.call(r),o.complete()},function(u){var a;c=!1,(a=r.error)===null||a===void 0||a.call(r,u),o.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)}))}):pe}var nt=Object.defineProperty,it=(n,t,e)=>t in n?nt(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,M=(n,t,e)=>(it(n,typeof t!="symbol"?t+"":t,e),e);class f extends Error{constructor(t){super(`Incorrect context (${t}). Cannot perform the requested operation.`),M(this,"context"),this.context=t}}class D extends Error{constructor(t,e,r){super(`Invalid parameter (${t}). ${r}`),this.param=t,this.value=e,this.reason=r}}class ot extends Error{constructor(t,e){super(`'streamId' value of "${t}" is different from what we expected ("${e}")`),this.streamId=t,this.expectedStreamId=e}}class st extends Error{constructor(t){super(`Invalid version format: ${t}`)}}class Se extends Error{constructor(t){super(`${t} needs to be initialized before it can be used.`)}}class Ce 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 ut(n){return S(n==null?void 0:n.lift)}function L(n){return function(t){if(ut(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 K=function(n,t){return K=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])},K(n,t)};function W(n,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");K(n,t);function e(){this.constructor=n}n.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}function Ee(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 X(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var r=e.call(n),i,o=[],s;try{for(;(t===void 0||t-- >0)&&!(i=r.next()).done;)o.push(i.value)}catch(c){s={error:c}}finally{try{i&&!i.done&&(e=r.return)&&e.call(r)}finally{if(s)throw s.error}}return o}function Z(n,t,e){if(e||arguments.length===2)for(var r=0,i=t.length,o;r<i;r++)(o||!(r in t))&&(o||(o=Array.prototype.slice.call(t,0,r)),o[r]=t[r]);return n.concat(o||Array.prototype.slice.call(t))}function ct(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 ee=ct(function(n){return function(t){n(this),this.message=t?t.length+` errors occurred during unsubscription:
3
+ `):"",this.name="UnsubscriptionError",this.errors=e}});function R(n,t){if(n){var e=n.indexOf(t);0<=e&&n.splice(e,1)}}var T=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,o;if(!this.closed){this.closed=!0;var s=this._parentage;if(s)if(this._parentage=null,Array.isArray(s))try{for(var c=B(s),u=c.next();!u.done;u=c.next()){var a=u.value;a.remove(this)}}catch(h){t={error:h}}finally{try{u&&!u.done&&(e=c.return)&&e.call(c)}finally{if(t)throw t.error}}else s.remove(this);var f=this.initialTeardown;if(m(f))try{f()}catch(h){o=h instanceof q?h.errors:[h]}var v=this._finalizers;if(v){this._finalizers=null;try{for(var x=B(v),S=x.next();!S.done;S=x.next()){var ie=S.value;try{ue(ie)}catch(h){o=o??[],h instanceof q?o=O(O([],I(o)),I(h.errors)):o.push(h)}}}catch(h){r={error:h}}finally{try{S&&!S.done&&(i=x.return)&&i.call(x)}finally{if(r)throw r.error}}}if(o)throw new q(o)}},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)&&R(e,t)},n.prototype.remove=function(t){var e=this._finalizers;e&&R(e,t),t instanceof n&&t._removeParent(this)},n.EMPTY=function(){var t=new n;return t.closed=!0,t}(),n}(),oe=T.EMPTY;function se(n){return n instanceof T||n&&"closed"in n&&m(n.remove)&&m(n.add)&&m(n.unsubscribe)}function ue(n){m(n)?n():n.unsubscribe()}var ce={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,O([n,t],I(e))):setTimeout.apply(void 0,O([n,t],I(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 ae(){}function U(n){n()}var Q=function(n){_(t,n);function t(e){var r=n.call(this)||this;return r.isStopped=!1,e?(r.destination=e,se(e)&&e.add(r)):r.destination=je,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}(T),Re=Function.prototype.bind;function G(n,t){return Re.call(n,t)}var Ue=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){j(r)}},n.prototype.error=function(t){var e=this.partialObserver;if(e.error)try{e.error(t)}catch(r){j(r)}else j(t)},n.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(e){j(e)}},n}(),$=function(n){_(t,n);function t(e,r,i){var o=n.call(this)||this,s;if(m(e)||!e)s={next:e??void 0,error:r??void 0,complete:i??void 0};else{var c;o&&ce.useDeprecatedNextContext?(c=Object.create(e),c.unsubscribe=function(){return o.unsubscribe()},s={next:e.next&&G(e.next,c),error:e.error&&G(e.error,c),complete:e.complete&&G(e.complete,c)}):s=e}return o.destination=new Ue(s),o}return t}(Q);function j(n){Ae(n)}function $e(n){throw n}var je={closed:!0,next:ae,error:$e,complete:ae},Ve=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function le(n){return n}function Fe(n){return n.length===0?le:n.length===1?n[0]:function(e){return n.reduce(function(r,i){return i(r)},e)}}var Y=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,o=De(t)?t:new $(t,e,r);return U(function(){var s=i,c=s.operator,u=s.source;o.add(c?c.call(o,u):u?i._subscribe(o):i._trySubscribe(o))}),o},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=he(e),new e(function(i,o){var s=new $({next:function(c){try{t(c)}catch(u){o(u),s.unsubscribe()}},error:o,complete:i});r.subscribe(s)})},n.prototype._subscribe=function(t){var e;return(e=this.source)===null||e===void 0?void 0:e.subscribe(t)},n.prototype[Ve]=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=he(t),new t(function(r,i){var o;e.subscribe(function(s){return o=s},function(s){return i(s)},function(){return r(o)})})},n.create=function(t){return new n(t)},n}();function he(n){var t;return(t=n??ce.Promise)!==null&&t!==void 0?t:Promise}function He(n){return n&&m(n.next)&&m(n.error)&&m(n.complete)}function De(n){return n&&n instanceof Q||He(n)&&se(n)}function Le(n){return m(n==null?void 0:n.lift)}function de(n){return function(t){if(Le(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 pe(n,t,e,r,i){return new ke(n,t,e,r,i)}var ke=function(n){_(t,n);function t(e,r,i,o,s,c){var u=n.call(this,e)||this;return u.onFinalize=s,u.shouldUnsubscribe=c,u._next=r?function(a){try{r(a)}catch(f){e.error(f)}}:n.prototype._next,u._error=o?function(a){try{o(a)}catch(f){e.error(f)}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=N(function(n){return function(){n(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),fe=function(n){_(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;U(function(){var i,o;if(r._throwIfClosed(),!r.isStopped){r.currentObservers||(r.currentObservers=Array.from(r.observers));try{for(var s=B(r.currentObservers),c=s.next();!c.done;c=s.next()){var u=c.value;u.next(e)}}catch(a){i={error:a}}finally{try{c&&!c.done&&(o=s.return)&&o.call(s)}finally{if(i)throw i.error}}}})},t.prototype.error=function(e){var r=this;U(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;U(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,o=i.hasError,s=i.isStopped,c=i.observers;return o||s?oe:(this.currentObservers=null,c.push(e),new T(function(){r.currentObservers=null,R(c,e)}))},t.prototype._checkFinalizedStatuses=function(e){var r=this,i=r.hasError,o=r.thrownError,s=r.isStopped;i?e.error(o):s&&e.complete()},t.prototype.asObservable=function(){var e=new Y;return e.source=this,e},t.create=function(e,r){return new ve(e,r)},t}(Y),ve=function(n){_(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}(fe),ge={now:function(){return(ge.delegate||Date).now()},delegate:void 0},Ne=function(n){_(t,n);function t(e,r){return n.call(this)||this}return t.prototype.schedule=function(e,r){return this},t}(T),V={setInterval:function(n,t){for(var e=[],r=2;r<arguments.length;r++)e[r-2]=arguments[r];var i=V.delegate;return i!=null&&i.setInterval?i.setInterval.apply(i,O([n,t],I(e))):setInterval.apply(void 0,O([n,t],I(e)))},clearInterval:function(n){var t=V.delegate;return((t==null?void 0:t.clearInterval)||clearInterval)(n)},delegate:void 0},qe=function(n){_(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 o=this.id,s=this.scheduler;return o!=null&&(this.id=this.recycleAsyncId(s,o,r)),this.pending=!0,this.delay=r,this.id=(i=this.id)!==null&&i!==void 0?i:this.requestAsyncId(s,this.id,r),this},t.prototype.requestAsyncId=function(e,r,i){return i===void 0&&(i=0),V.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&&V.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,o;try{this.work(e)}catch(s){i=!0,o=s||new Error("Scheduled action threw falsy error")}if(i)return this.unsubscribe(),o},t.prototype.unsubscribe=function(){if(!this.closed){var e=this,r=e.id,i=e.scheduler,o=i.actions;this.work=this.state=this.scheduler=null,this.pending=!1,R(o,this),r!=null&&(this.id=this.recycleAsyncId(i,r,null)),this.delay=null,n.prototype.unsubscribe.call(this)}},t}(Ne),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=ge.now,n}(),ze=function(n){_(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(qe),Ge=Qe;function Ye(n){return n&&m(n.schedule)}var Je=N(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 o=new $({next:function(s){r(s),o.unsubscribe()},error:i,complete:function(){e?r(t.defaultValue):i(new Je)}});n.subscribe(o)})}function Ke(n){return n instanceof Date&&!isNaN(n)}function F(n,t){return de(function(e,r){var i=0;e.subscribe(pe(r,function(o){r.next(n.call(t,o,i++))}))})}function We(n,t,e){n===void 0&&(n=0),e===void 0&&(e=Ge);var r=-1;return t!=null&&(Ye(t)?e=t:r=t),new Y(function(i){var o=Ke(n)?+n-e.now():n;o<0&&(o=0);var s=0;return e.schedule(function(){i.closed||(i.next(s++),0<=r?this.schedule(void 0,r):i.complete())},o)})}function Xe(n,t,e){var r=m(n)||t||e?{next:n,error:t,complete:e}:n;return r?de(function(i,o){var s;(s=r.subscribe)===null||s===void 0||s.call(r);var c=!0;i.subscribe(pe(o,function(u){var a;(a=r.next)===null||a===void 0||a.call(r,u),o.next(u)},function(){var u;c=!1,(u=r.complete)===null||u===void 0||u.call(r),o.complete()},function(u){var a;c=!1,(a=r.error)===null||a===void 0||a.call(r,u),o.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)}))}):le}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,M=(n,t,e)=>(et(n,typeof t!="symbol"?t+"":t,e),e);class p extends Error{constructor(t){super(`Incorrect context (${t}). Cannot perform the requested operation.`),M(this,"context"),this.context=t}}class H 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 ye extends Error{constructor(t){super(`${t} needs to be initialized before it can be used.`)}}class me 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 w(n){return typeof n=="function"}function nt(n){return w(n==null?void 0:n.lift)}function D(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 we(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,o=[],s;try{for(;(t===void 0||t-- >0)&&!(i=r.next()).done;)o.push(i.value)}catch(c){s={error:c}}finally{try{i&&!i.done&&(e=r.return)&&e.call(r)}finally{if(s)throw s.error}}return o}function X(n,t,e){if(e||arguments.length===2)for(var r=0,i=t.length,o;r<i;r++)(o||!(r in t))&&(o||(o=Array.prototype.slice.call(t,0,r)),o[r]=t[r]);return n.concat(o||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 xe(n,t){if(n){var e=n.indexOf(t);0<=e&&n.splice(e,1)}}var te=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,o;if(!this.closed){this.closed=!0;var s=this._parentage;if(s)if(this._parentage=null,Array.isArray(s))try{for(var c=Ee(s),u=c.next();!u.done;u=c.next()){var a=u.value;a.remove(this)}}catch(d){t={error:d}}finally{try{u&&!u.done&&(e=c.return)&&e.call(c)}finally{if(t)throw t.error}}else s.remove(this);var v=this.initialTeardown;if(S(v))try{v()}catch(d){o=d instanceof ee?d.errors:[d]}var g=this._finalizers;if(g){this._finalizers=null;try{for(var x=Ee(g),C=x.next();!C.done;C=x.next()){var oe=C.value;try{Me(oe)}catch(d){o=o??[],d instanceof ee?o=Z(Z([],X(o)),X(d.errors)):o.push(d)}}}catch(d){r={error:d}}finally{try{C&&!C.done&&(i=x.return)&&i.call(x)}finally{if(r)throw r.error}}}if(o)throw new ee(o)}},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)&&xe(e,t)},n.prototype.remove=function(t){var e=this._finalizers;e&&xe(e,t),t instanceof n&&t._removeParent(this)},n.EMPTY=function(){var t=new n;return t.closed=!0,t}(),n}();te.EMPTY;function _e(n){return n instanceof te||n&&"closed"in n&&S(n.remove)&&S(n.add)&&S(n.unsubscribe)}function Me(n){S(n)?n():n.unsubscribe()}var Ie={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},at={setTimeout:function(n,t){for(var e=[],r=2;r<arguments.length;r++)e[r-2]=arguments[r];return setTimeout.apply(void 0,Z([n,t],X(e)))},clearTimeout:function(n){return clearTimeout(n)},delegate:void 0};function lt(n){at.setTimeout(function(){throw n})}function Oe(){}function ht(n){n()}var re=function(n){W(t,n);function t(e){var r=n.call(this)||this;return r.isStopped=!1,e?(r.destination=e,_e(e)&&e.add(r)):r.destination=vt,r}return t.create=function(e,r,i){return new ie(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}(te),dt=Function.prototype.bind;function ne(n,t){return dt.call(n,t)}var pt=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){k(r)}},n.prototype.error=function(t){var e=this.partialObserver;if(e.error)try{e.error(t)}catch(r){k(r)}else k(t)},n.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(e){k(e)}},n}(),ie=function(n){W(t,n);function t(e,r,i){var o=n.call(this)||this,s;if(S(e)||!e)s={next:e??void 0,error:r??void 0,complete:i??void 0};else{var c;o&&Ie.useDeprecatedNextContext?(c=Object.create(e),c.unsubscribe=function(){return o.unsubscribe()},s={next:e.next&&ne(e.next,c),error:e.error&&ne(e.error,c),complete:e.complete&&ne(e.complete,c)}):s=e}return o.destination=new pt(s),o}return t}(re);function k(n){lt(n)}function ft(n){throw n}var vt={closed:!0,next:Oe,error:ft,complete:Oe},gt=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function Pe(n){return n}function bt(n){return n.length===0?Pe:n.length===1?n[0]:function(t){return n.reduce(function(e,r){return r(e)},t)}}var yt=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,o=wt(t)?t:new ie(t,e,r);return ht(function(){var s=i,c=s.operator,u=s.source;o.add(c?c.call(o,u):u?i._subscribe(o):i._trySubscribe(o))}),o},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=Te(e),new e(function(i,o){var s=new ie({next:function(c){try{t(c)}catch(u){o(u),s.unsubscribe()}},error:o,complete:i});r.subscribe(s)})},n.prototype._subscribe=function(t){var e;return(e=this.source)===null||e===void 0?void 0:e.subscribe(t)},n.prototype[gt]=function(){return this},n.prototype.pipe=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return bt(t)(this)},n.prototype.toPromise=function(t){var e=this;return t=Te(t),new t(function(r,i){var o;e.subscribe(function(s){return o=s},function(s){return i(s)},function(){return r(o)})})},n.create=function(t){return new n(t)},n}();function Te(n){var t;return(t=n??Ie.Promise)!==null&&t!==void 0?t:Promise}function mt(n){return n&&S(n.next)&&S(n.error)&&S(n.complete)}function wt(n){return n&&n instanceof re||mt(n)&&_e(n)}function B(n,t,e,r,i){return new St(n,t,e,r,i)}var St=function(n){W(t,n);function t(e,r,i,o,s,c){var u=n.call(this,e)||this;return u.onFinalize=s,u.shouldUnsubscribe=c,u._next=r?function(a){try{r(a)}catch(v){e.error(v)}}:n.prototype._next,u._error=o?function(a){try{o(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}(re);function h(n,t){return L(function(e,r){var i=0;e.subscribe(B(r,function(o){r.next(n.call(t,o,i++))}))})}var Ct=new yt(function(n){return n.complete()});function E(n){return n<=0?function(){return Ct}:L(function(t,e){var r=0;t.subscribe(B(e,function(i){++r<=n&&(e.next(i),n<=r&&e.complete())}))})}function m(n,t){return L(function(e,r){var i=0;e.subscribe(B(r,function(o){return n.call(t,o,i++)&&r.next(o)}))})}function b(n,t,e){var r=S(n)||t||e?{next:n,error:t,complete:e}:n;return r?L(function(i,o){var s;(s=r.subscribe)===null||s===void 0||s.call(r);var c=!0;i.subscribe(B(o,function(u){var a;(a=r.next)===null||a===void 0||a.call(r,u),o.next(u)},function(){var u;c=!1,(u=r.complete)===null||u===void 0||u.call(r),o.complete()},function(u){var a;c=!1,(a=r.error)===null||a===void 0||a.call(r,u),o.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)}))}):Pe}const Et=/^(\d+)\.(\d+)$/;function xt(n){if(typeof n=="string"){const t=n.match(Et);if(t)return`${t[1]}.${t[2]}`}throw new st(n)}function Ae(n){const t=xt(n),[e,r]=t.split("."),[i,o]=[parseInt(e),parseInt(r)];return[i,o]}function Re(n,t){const[e,r]=Ae(n),[i,o]=Ae(t);return e<i?-1:e>i?1:r<o?-1:r>o?1:0}function _t(n,t){return Re(n,t)===1}function Mt(n,t){return Re(n,t)>=0}const Ue="2.0";class It{constructor(t,e){if(M(this,"negotiatedProtocolVersion"),M(this,"currentContext"),M(this,"incomingMessages$"),M(this,"inIframe",!1),M(this,"embeddedResult"),M(this,"iframePort1"),M(this,"iframePort2"),this.supportedVersions=t,this.logService=e,this.incomingMessages$=new be,this.supportedVersions=t.filter(r=>Mt(r,Ue)),!this.supportedVersions.length)throw new Ce(t,Ue);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 Se("port2");return this.iframePort2}else{if(!((e=(t=window.Acrobits)==null?void 0:t.messageChannel)!=null&&e.port2))throw new Se("port2");return(i=(r=window.Acrobits)==null?void 0:r.messageChannel)==null?void 0:i.port2}}determineContext(){return tt(1e3).pipe(h(()=>(this.isEmbedded()?this.currentContext="user":this.currentContext="guest",this.currentContext)),E(1))}openBridge(){if(!this.isEmbedded())throw new f(this.currentContext);const t="HELLO",e=this.createMessage(t);e.protocolVersions=this.supportedVersions,this.logCreated(t,e);const r=this.incomingMessages$.pipe(m(i=>i.type===t&&i.replyTo===e.id),h(i=>i),b(this.logReceived(t)),h(i=>{if(this.supportedVersions.some(o=>_t(o,i.protocolVersion)))throw new Ce(i.protocolVersion,this.supportedVersions[0]);return i}),b(i=>{this.negotiatedProtocolVersion=i.protocolVersion,this.logService.info(`[IPC] Negotiated IPC Protocol Version: ${this.negotiatedProtocolVersion}`)}),E(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 f(this.currentContext);const t="TOKEN",e=this.createMessage(t);this.logCreated(t,e);const r=this.incomingMessages$.pipe(m(i=>i.type===t&&i.replyTo===e.id),h(i=>i),b(this.logReceived(t)),E(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 f(this.currentContext);const{roomName:e,roomInvite:r,displayName:i,jwtToken:o,serverUrl:s,region:c,joinMicMuted:u,joinWithoutCamera:a}=t,v="JOINING ROOM",g=this.createMessage(v,!1);g.roomName=e,g.jwtToken=o,g.serverUrl=s,g.region=c,g.roomInvite=r,g.joinMicMuted=u??!1,g.joinWithoutCamera=a??!1,g.displayName=i,this.logCreated(v,g),this.port2.postMessage(g),this.logSent(v,g)}sendLeavingRoomMessage(t){if(!this.isEmbedded())throw new f(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 f(this.currentContext);const t="JOIN ROOM";return this.incomingMessages$.pipe(m(e=>e.type===t&&e.target==="client"),h(e=>e),b(this.logReceived(t)),h(e=>e))}onLeaveRoomMessage(){if(!this.isEmbedded())throw new f(this.currentContext);const t="LEAVE ROOM";return this.incomingMessages$.pipe(m(e=>e.type===t&&e.target==="client"),h(e=>e),b(this.logReceived(t)),h(e=>e))}onConfigMessage(){if(!this.isEmbedded())throw new f(this.currentContext);const t="CONFIG";return this.incomingMessages$.pipe(m(e=>e.type===t&&e.target==="client"),h(e=>e),b(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 f(this.currentContext);const e="SCREENSHARE SOURCE",r=this.createMessage(e);r.sourceTypes=t,this.logCreated(e,r);const i=this.incomingMessages$.pipe(m(o=>o.type===e&&o.replyTo===r.id),h(o=>o),b(this.logReceived(e)),h(o=>o),E(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 f(this.currentContext);const i="LAYOUT CHANGE";let o,s;if(e&&r?(o=this.createMessage(i,!1,r),o.result=e):(o=this.createMessage(i),s=this.incomingMessages$.pipe(m(c=>c.type===i&&c.replyTo===o.id),h(c=>c),b(this.logReceived(i)),h(c=>c),E(1)),this.logService.debug(`Created ${i} Reply handler`)),o.layout=t,this.logCreated(i,o),this.port2.postMessage(o),this.logSent(i,o),s)return s}onLayoutChangeMessage(){if(!this.isEmbedded())throw new f(this.currentContext);const t="LAYOUT CHANGE";return this.incomingMessages$.pipe(m(e=>e.type===t&&e.target==="client"&&e.replyTo===null),h(e=>e),b(this.logReceived(t)),h(e=>e))}requestOAuthToken(t){if(!this.isEmbedded())throw new f(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(m(o=>o.type===e&&o.replyTo===r.id),h(o=>o),b(this.logReceived(e)),E(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 f(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){if(!this.isEmbedded())throw new f(this.currentContext);if(e==="group"&&r===void 0)throw new D("currentContacts",r,"currentContacts is required for group streams");if(e==="direct"&&r!==void 0)throw new D("currentContacts",r,"currentContacts should not be passed for direct streams");const i="SELECT CONTACTS",o=this.createMessage(i,!0);o.streamType=e,o.streamId=t,o.currentContacts=r,this.logCreated(i,o);const s=this.incomingMessages$.pipe(m(c=>c.type===i&&c.replyTo===o.id),b(this.logReceived(i)),h(c=>{const u=c;if(u.streamId!==t)throw new ot(u.streamId,t);return e==="direct"&&u.contacts.length>1&&(u.contacts=[u.contacts[0]]),u}),E(1));return this.logService.debug(`Created ${i} Reply handler`),this.port2.postMessage(o),this.logSent(i,o),s}matchContacts(t){if(!this.isEmbedded())throw new f(this.currentContext);if(!t.length)throw new D("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(m(o=>o.type===e&&o.replyTo===r.id),b(this.logReceived(e)),h(o=>o),E(1));return this.logService.debug(`Created ${e} Reply handler`),this.port2.postMessage(r),this.logSent(e,r),i}onPushMessageMessage(){if(!this.isEmbedded())throw new f(this.currentContext);const t="PUSH MESSAGE";return this.incomingMessages$.pipe(m(e=>e.type===t&&e.target==="client"),h(e=>e),b(this.logReceived(t)))}requestPushToken(){if(!this.isEmbedded())throw new f(this.currentContext);const t="PUSH TOKEN",e=this.createMessage(t);this.logCreated(t,e);const r=this.incomingMessages$.pipe(m(i=>i.type===t&&i.replyTo===e.id),b(this.logReceived(t)),h(i=>i),E(1));return this.logService.debug(`Created ${t} Reply handler`),this.port2.postMessage(e),this.logSent(t,e),r}onBadgeQueryMessage(){if(!this.isEmbedded())throw new f(this.currentContext);const t="BADGE QUERY";return this.incomingMessages$.pipe(m(e=>e.type===t&&e.target==="client"),h(e=>e),b(this.logReceived(t)))}sendBadgeUpdateMessage(t,e){if(!this.isEmbedded())throw new f(this.currentContext);const r="BADGE UPDATE",i=this.createMessage(r,!1,e);i.count=t,this.logCreated(r,i),this.port2.postMessage(i),this.logSent(r,i)}onHostInForegroundMessage(){if(!this.isEmbedded())throw new f(this.currentContext);const t="HOST IN FOREGROUND";return this.incomingMessages$.pipe(m(e=>e.type===t&&e.target==="client"),h(e=>e),b(this.logReceived(t)))}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))}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 o=0;o<t;o++)i.push(r[Math.floor(Math.random()*r.length)]);return i.join("")}}const Ot=["2.0"];class Pt{constructor(t){$e(this,R);P(this,"host");P(this,"cloudId");P(this,"logger");P(this,"helper");P(this,"listeners");this.logger=t??console,this.helper=new It(Ot,this.logger),this.listeners=new Map,this.listeners.set(l.BadgeQuery,new Set),this.listeners.set(l.HostInForeground,new Set)}get context(){return se(this,R,ue).call(this,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 se(this,R,ue).call(this,t)}initiateConnection(){return A(this.helper.openBridge().pipe(rt(t=>{this.helper.onBadgeQueryMessage().subscribe(e=>{var r;this.logger.debug("Received Badge Query: ",e);for(const i of((r=this.listeners.get(l.BadgeQuery))==null?void 0:r.values())??[])i()}),this.helper.onHostInForegroundMessage().subscribe(e=>{var r;this.logger.debug("Received Host In Foreground: ",e);for(const i of((r=this.listeners.get(l.HostInForeground))==null?void 0:r.values())??[])i()}),this.cloudId=t.cloudId,this.host=t.host}),H(()=>{})))}selectContacts(t,e,r){this.logger.debug("Selecting Contacts: ",...arguments);let i;if(e==="multi"){if(!r)throw new D("currentContacts",r,"currentContacts is required for group streams");i=this.helper.selectContacts(t.toString(),"group",r)}else i=this.helper.selectContacts(t.toString(),"direct");return A(i.pipe(H(o=>o.contacts)))}matchContacts(t){return this.logger.debug("Match Contacts: ",t),A(this.helper.matchContacts(t).pipe(H(e=>e.contacts)))}requestPushToken(){return this.logger.debug("Requesting Push Token"),A(this.helper.requestPushToken().pipe(H(t=>t.pushToken)))}badgeUpdate(t){this.logger.debug("Sending Badge Update: ",t),this.helper.sendBadgeUpdateMessage(t)}onBadgeQueryRequest(t){var e;return this.logger.debug("Registering for Badge Query"),(e=this.listeners.get(l.BadgeQuery))==null||e.add(t),()=>{var r;return(r=this.listeners.get(l.BadgeQuery))==null?void 0:r.delete(t)}}onHostInForeground(t){var e;return this.logger.debug("Registering for Host In Foreground"),(e=this.listeners.get(l.HostInForeground))==null||e.add(t),()=>{var r;return(r=this.listeners.get(l.HostInForeground))==null?void 0:r.delete(t)}}}R=new WeakSet,ue=function(t){if(t==="user")return"host";if(t==="guest")return"standalone"},p.IPCEvents=l,p.IPCManager=Pt,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})});
5
+ `):"",this.name="UnsubscriptionError",this.errors=t}});function Se(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,o;if(!this.closed){this.closed=!0;var s=this._parentage;if(s)if(this._parentage=null,Array.isArray(s))try{for(var c=we(s),u=c.next();!u.done;u=c.next()){var a=u.value;a.remove(this)}}catch(h){t={error:h}}finally{try{u&&!u.done&&(e=c.return)&&e.call(c)}finally{if(t)throw t.error}}else s.remove(this);var f=this.initialTeardown;if(w(f))try{f()}catch(h){o=h instanceof Z?h.errors:[h]}var v=this._finalizers;if(v){this._finalizers=null;try{for(var x=we(v),S=x.next();!S.done;S=x.next()){var ie=S.value;try{Ee(ie)}catch(h){o=o??[],h instanceof Z?o=X(X([],W(o)),W(h.errors)):o.push(h)}}}catch(h){r={error:h}}finally{try{S&&!S.done&&(i=x.return)&&i.call(x)}finally{if(r)throw r.error}}}if(o)throw new Z(o)}},n.prototype.add=function(t){var e;if(t&&t!==this)if(this.closed)Ee(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)&&Se(e,t)},n.prototype.remove=function(t){var e=this._finalizers;e&&Se(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&&w(n.remove)&&w(n.add)&&w(n.unsubscribe)}function Ee(n){w(n)?n():n.unsubscribe()}var xe={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},ot={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 st(n){ot.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){L(r)}},n.prototype.error=function(t){var e=this.partialObserver;if(e.error)try{e.error(t)}catch(r){L(r)}else L(t)},n.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(e){L(e)}},n}(),ne=function(n){K(t,n);function t(e,r,i){var o=n.call(this)||this,s;if(w(e)||!e)s={next:e??void 0,error:r??void 0,complete:i??void 0};else{var c;o&&xe.useDeprecatedNextContext?(c=Object.create(e),c.unsubscribe=function(){return o.unsubscribe()},s={next:e.next&&re(e.next,c),error:e.error&&re(e.error,c),complete:e.complete&&re(e.complete,c)}):s=e}return o.destination=new at(s),o}return t}(te);function L(n){st(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 Me(n){return n}function pt(n){return n.length===0?Me: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,o=gt(t)?t:new ne(t,e,r);return ut(function(){var s=i,c=s.operator,u=s.source;o.add(c?c.call(o,u):u?i._subscribe(o):i._trySubscribe(o))}),o},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=Ie(e),new e(function(i,o){var s=new ne({next:function(c){try{t(c)}catch(u){o(u),s.unsubscribe()}},error:o,complete:i});r.subscribe(s)})},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=Ie(t),new t(function(r,i){var o;e.subscribe(function(s){return o=s},function(s){return i(s)},function(){return r(o)})})},n.create=function(t){return new n(t)},n}();function Ie(n){var t;return(t=n??xe.Promise)!==null&&t!==void 0?t:Promise}function vt(n){return n&&w(n.next)&&w(n.error)&&w(n.complete)}function gt(n){return n&&n instanceof te||vt(n)&&Ce(n)}function k(n,t,e,r,i){return new bt(n,t,e,r,i)}var bt=function(n){K(t,n);function t(e,r,i,o,s,c){var u=n.call(this,e)||this;return u.onFinalize=s,u.shouldUnsubscribe=c,u._next=r?function(a){try{r(a)}catch(f){e.error(f)}}:n.prototype._next,u._error=o?function(a){try{o(a)}catch(f){e.error(f)}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 l(n,t){return D(function(e,r){var i=0;e.subscribe(k(r,function(o){r.next(n.call(t,o,i++))}))})}var yt=new ft(function(n){return n.complete()});function E(n){return n<=0?function(){return yt}:D(function(t,e){var r=0;t.subscribe(k(e,function(i){++r<=n&&(e.next(i),n<=r&&e.complete())}))})}function b(n,t){return D(function(e,r){var i=0;e.subscribe(k(r,function(o){return n.call(t,o,i++)&&r.next(o)}))})}function g(n,t,e){var r=w(n)||t||e?{next:n,error:t,complete:e}:n;return r?D(function(i,o){var s;(s=r.subscribe)===null||s===void 0||s.call(r);var c=!0;i.subscribe(k(o,function(u){var a;(a=r.next)===null||a===void 0||a.call(r,u),o.next(u)},function(){var u;c=!1,(u=r.complete)===null||u===void 0||u.call(r),o.complete()},function(u){var a;c=!1,(a=r.error)===null||a===void 0||a.call(r,u),o.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)}))}):Me}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 Oe(n){const t=wt(n),[e,r]=t.split("."),[i,o]=[parseInt(e),parseInt(r)];return[i,o]}function Pe(n,t){const[e,r]=Oe(n),[i,o]=Oe(t);return e<i?-1:e>i?1:r<o?-1:r>o?1:0}function St(n,t){return Pe(n,t)===1}function Ct(n,t){return Pe(n,t)>=0}const Te="2.0";class Et{constructor(t,e){if(M(this,"negotiatedProtocolVersion"),M(this,"currentContext"),M(this,"incomingMessages$"),M(this,"inIframe",!1),M(this,"embeddedResult"),M(this,"iframePort1"),M(this,"iframePort2"),this.supportedVersions=t,this.logService=e,this.incomingMessages$=new fe,this.supportedVersions=t.filter(r=>Ct(r,Te)),!this.supportedVersions.length)throw new me(t,Te);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 ye("port2");return this.iframePort2}else{if(!((e=(t=window.Acrobits)==null?void 0:t.messageChannel)!=null&&e.port2))throw new ye("port2");return(i=(r=window.Acrobits)==null?void 0:r.messageChannel)==null?void 0:i.port2}}determineContext(){return We(1e3).pipe(l(()=>(this.isEmbedded()?this.currentContext="user":this.currentContext="guest",this.currentContext)),E(1))}openBridge(){if(!this.isEmbedded())throw new p(this.currentContext);const t="HELLO",e=this.createMessage(t);e.protocolVersions=this.supportedVersions,this.logCreated(t,e);const r=this.incomingMessages$.pipe(b(i=>i.type===t&&i.replyTo===e.id),l(i=>i),g(this.logReceived(t)),l(i=>{if(this.supportedVersions.some(o=>St(o,i.protocolVersion)))throw new me(i.protocolVersion,this.supportedVersions[0]);return i}),g(i=>{this.negotiatedProtocolVersion=i.protocolVersion,this.logService.info(`[IPC] Negotiated IPC Protocol Version: ${this.negotiatedProtocolVersion}`)}),E(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 p(this.currentContext);const t="TOKEN",e=this.createMessage(t);this.logCreated(t,e);const r=this.incomingMessages$.pipe(b(i=>i.type===t&&i.replyTo===e.id),l(i=>i),g(this.logReceived(t)),E(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 p(this.currentContext);const{roomName:e,roomInvite:r,displayName:i,jwtToken:o,serverUrl:s,region:c,joinMicMuted:u,joinWithoutCamera:a}=t,f="JOINING ROOM",v=this.createMessage(f,!1);v.roomName=e,v.jwtToken=o,v.serverUrl=s,v.region=c,v.roomInvite=r,v.joinMicMuted=u??!1,v.joinWithoutCamera=a??!1,v.displayName=i,this.logCreated(f,v),this.port2.postMessage(v),this.logSent(f,v)}sendLeavingRoomMessage(t){if(!this.isEmbedded())throw new p(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 p(this.currentContext);const t="JOIN ROOM";return this.incomingMessages$.pipe(b(e=>e.type===t&&e.target==="client"),l(e=>e),g(this.logReceived(t)),l(e=>e))}onLeaveRoomMessage(){if(!this.isEmbedded())throw new p(this.currentContext);const t="LEAVE ROOM";return this.incomingMessages$.pipe(b(e=>e.type===t&&e.target==="client"),l(e=>e),g(this.logReceived(t)),l(e=>e))}onConfigMessage(){if(!this.isEmbedded())throw new p(this.currentContext);const t="CONFIG";return this.incomingMessages$.pipe(b(e=>e.type===t&&e.target==="client"),l(e=>e),g(this.logReceived(t)),l(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 p(this.currentContext);const e="SCREENSHARE SOURCE",r=this.createMessage(e);r.sourceTypes=t,this.logCreated(e,r);const i=this.incomingMessages$.pipe(b(o=>o.type===e&&o.replyTo===r.id),l(o=>o),g(this.logReceived(e)),l(o=>o),E(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 p(this.currentContext);const i="LAYOUT CHANGE";let o,s;if(e&&r?(o=this.createMessage(i,!1,r),o.result=e):(o=this.createMessage(i),s=this.incomingMessages$.pipe(b(c=>c.type===i&&c.replyTo===o.id),l(c=>c),g(this.logReceived(i)),l(c=>c),E(1)),this.logService.debug(`Created ${i} Reply handler`)),o.layout=t,this.logCreated(i,o),this.port2.postMessage(o),this.logSent(i,o),s)return s}onLayoutChangeMessage(){if(!this.isEmbedded())throw new p(this.currentContext);const t="LAYOUT CHANGE";return this.incomingMessages$.pipe(b(e=>e.type===t&&e.target==="client"&&e.replyTo===null),l(e=>e),g(this.logReceived(t)),l(e=>e))}requestOAuthToken(t){if(!this.isEmbedded())throw new p(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(b(o=>o.type===e&&o.replyTo===r.id),l(o=>o),g(this.logReceived(e)),E(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 p(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){if(!this.isEmbedded())throw new p(this.currentContext);if(e==="group"&&r===void 0)throw new H("currentContacts",r,"currentContacts is required for group streams");if(e==="direct"&&r!==void 0)throw new H("currentContacts",r,"currentContacts should not be passed for direct streams");const i="SELECT CONTACTS",o=this.createMessage(i,!0);o.streamType=e,o.streamId=t,o.currentContacts=r,this.logCreated(i,o);const s=this.incomingMessages$.pipe(b(c=>c.type===i&&c.replyTo===o.id),g(this.logReceived(i)),l(c=>{const u=c;if(u.streamId!==t)throw new tt(u.streamId,t);return e==="direct"&&u.contacts.length>1&&(u.contacts=[u.contacts[0]]),u}),E(1));return this.logService.debug(`Created ${i} Reply handler`),this.port2.postMessage(o),this.logSent(i,o),s}matchContacts(t){if(!this.isEmbedded())throw new p(this.currentContext);if(!t.length)throw new H("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(b(o=>o.type===e&&o.replyTo===r.id),g(this.logReceived(e)),l(o=>o),E(1));return this.logService.debug(`Created ${e} Reply handler`),this.port2.postMessage(r),this.logSent(e,r),i}onPushMessageMessage(){if(!this.isEmbedded())throw new p(this.currentContext);const t="PUSH MESSAGE";return this.incomingMessages$.pipe(b(e=>e.type===t&&e.target==="client"),l(e=>e),g(this.logReceived(t)))}requestPushToken(){if(!this.isEmbedded())throw new p(this.currentContext);const t="PUSH TOKEN",e=this.createMessage(t);this.logCreated(t,e);const r=this.incomingMessages$.pipe(b(i=>i.type===t&&i.replyTo===e.id),g(this.logReceived(t)),l(i=>i),E(1));return this.logService.debug(`Created ${t} Reply handler`),this.port2.postMessage(e),this.logSent(t,e),r}onBadgeQueryMessage(){if(!this.isEmbedded())throw new p(this.currentContext);const t="BADGE QUERY";return this.incomingMessages$.pipe(b(e=>e.type===t&&e.target==="client"),l(e=>e),g(this.logReceived(t)))}sendBadgeUpdateMessage(t,e){if(!this.isEmbedded())throw new p(this.currentContext);const r="BADGE UPDATE",i=this.createMessage(r,!1,e);i.count=t,this.logCreated(r,i),this.port2.postMessage(i),this.logSent(r,i)}onHostInForegroundMessage(){if(!this.isEmbedded())throw new p(this.currentContext);const t="HOST IN FOREGROUND";return this.incomingMessages$.pipe(b(e=>e.type===t&&e.target==="client"),l(e=>e),g(this.logReceived(t)))}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))}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 o=0;o<t;o++)i.push(r[Math.floor(Math.random()*r.length)]);return i.join("")}}const xt=["2.0"];class _t{constructor(t){P(this,"host");P(this,"cloudId");P(this,"logger");P(this,"helper");P(this,"listeners");this.logger=t??console,this.helper=new Et(xt,this.logger),this.listeners=new Map,this.listeners.set(d.BadgeQuery,new Set),this.listeners.set(d.HostInForeground,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.onHostInForegroundMessage().subscribe(e=>{var r;this.logger.debug("Received Host In Foreground: ",e);for(const i of((r=this.listeners.get(d.HostInForeground))==null?void 0:r.values())??[])i()}),this.cloudId=t.cloudId,this.host=t.host}),F(()=>{})))}selectContacts(t,e,r){this.logger.debug("Selecting Contacts: ",...arguments);let i;if(e==="multi"){if(!r)throw new H("currentContacts",r,"currentContacts is required for group streams");i=this.helper.selectContacts(t.toString(),"group",r)}else i=this.helper.selectContacts(t.toString(),"direct");return A(i.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){this.logger.debug("Sending Badge Update: ",t),this.helper.sendBadgeUpdateMessage(t)}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)}}onHostInForeground(t){var e;return this.logger.debug("Registering for Host In Foreground"),(e=this.listeners.get(d.HostInForeground))==null||e.add(t),()=>{var r;return(r=this.listeners.get(d.HostInForeground))==null?void 0:r.delete(t)}}evaluateContext(t){if(t==="user")return"host";if(t==="guest")return"standalone"}}y.IPCEvents=d,y.IPCManager=_t,Object.defineProperty(y,Symbol.toStringTag,{value:"Module"})});