@acrobits/ipc-sdk 0.3.0 → 0.4.1

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(y,p){typeof exports=="object"&&typeof module<"u"?p(exports):typeof define=="function"&&define.amd?define(["exports"],p):(y=typeof globalThis<"u"?globalThis:y||self,p(y["@acrobits/ipc-sdk"]={}))})(this,function(y){"use strict";var _t=Object.defineProperty;var It=(y,p,C)=>p in y?_t(y,p,{enumerable:!0,configurable:!0,writable:!0,value:C}):y[p]=C;var O=(y,p,C)=>(It(y,typeof p!="symbol"?p+"":p,C),C);var p=(n=>(n.BadgeQuery="BADGE QUERY",n.HostInForeground="HOST IN FOREGROUND",n))(p||{}),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 M(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 k(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 T(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 B(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=B(function(n){return function(e){n(this),this.message=e?e.length+` errors occurred during unsubscription:
1
+ (function(b,p){typeof exports=="object"&&typeof module<"u"?p(exports):typeof define=="function"&&define.amd?define(["exports"],p):(b=typeof globalThis<"u"?globalThis:b||self,p(b["@acrobits/ipc-sdk"]={}))})(this,function(b){"use strict";var _t=Object.defineProperty;var It=(b,p,C)=>p in b?_t(b,p,{enumerable:!0,configurable:!0,writable:!0,value:C}):b[p]=C;var A=(b,p,C)=>(It(b,typeof p!="symbol"?p+"":p,C),C);var p=(n=>(n.BadgeQuery="BADGE QUERY",n.Lifecycle="LIFECYCLE",n))(p||{}),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 M(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(u){s={error:u}}finally{try{i&&!i.done&&(e=r.return)&&e.call(r)}finally{if(s)throw s.error}}return o}function T(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 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:
2
2
  `+e.map(function(r,i){return i+1+") "+r.toString()}).join(`
3
- `):"",this.name="UnsubscriptionError",this.errors=e}});function A(n,t){if(n){var e=n.indexOf(t);0<=e&&n.splice(e,1)}}var P=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=k(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(m(v))try{v()}catch(d){o=d instanceof q?d.errors:[d]}var b=this._finalizers;if(b){this._finalizers=null;try{for(var x=k(b),E=x.next();!E.done;E=x.next()){var oe=E.value;try{ce(oe)}catch(d){o=o??[],d instanceof q?o=T(T([],I(o)),I(d.errors)):o.push(d)}}}catch(d){r={error:d}}finally{try{E&&!E.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)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)&&A(e,t)},n.prototype.remove=function(t){var e=this._finalizers;e&&A(e,t),t instanceof n&&t._removeParent(this)},n.EMPTY=function(){var t=new n;return t.closed=!0,t}(),n}(),se=P.EMPTY;function ue(n){return n instanceof P||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,T([n,t],I(e))):setTimeout.apply(void 0,T([n,t],I(e)))},clearTimeout:function(n){var t=z.delegate;return((t==null?void 0:t.clearTimeout)||clearTimeout)(n)},delegate:void 0};function Re(n){z.setTimeout(function(){throw n})}function le(){}function $(n){n()}var G=function(n){M(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=Le,r}return t.create=function(e,r,i){return new U(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}(P),Ae=Function.prototype.bind;function Q(n,t){return Ae.call(n,t)}var $e=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}(),U=function(n){M(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&&ae.useDeprecatedNextContext?(c=Object.create(e),c.unsubscribe=function(){return o.unsubscribe()},s={next:e.next&&Q(e.next,c),error:e.error&&Q(e.error,c),complete:e.complete&&Q(e.complete,c)}):s=e}return o.destination=new $e(s),o}return t}(G);function L(n){Re(n)}function Ue(n){throw n}var Le={closed:!0,next:le,error:Ue,complete:le},Fe=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 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=Ne(t)?t:new U(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=de(e),new e(function(i,o){var s=new U({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[Fe]=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 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 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 Ne(n){return n&&n instanceof G||Ve(n)&&ue(n)}function De(n){return m(n==null?void 0:n.lift)}function pe(n){return function(t){if(De(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 He(n,t,e,r,i)}var He=function(n){M(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),ke=B(function(n){return function(){n(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),ge=function(n){M(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 ke},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=k(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?se:(this.currentObservers=null,c.push(e),new P(function(){r.currentObservers=null,A(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){M(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:se},t}(ge),be={now:function(){return(be.delegate||Date).now()},delegate:void 0},Be=function(n){M(t,n);function t(e,r){return n.call(this)||this}return t.prototype.schedule=function(e,r){return this},t}(P),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,T([n,t],I(e))):setInterval.apply(void 0,T([n,t],I(e)))},clearInterval:function(n){var t=F.delegate;return((t==null?void 0:t.clearInterval)||clearInterval)(n)},delegate:void 0},qe=function(n){M(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,A(o,this),r!=null&&(this.id=this.recycleAsyncId(i,r,null)),this.delay=null,n.prototype.unsubscribe.call(this)}},t}(Be),ye=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=be.now,n}(),ze=function(n){M(t,n);function t(e,r){r===void 0&&(r=ye.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}(ye),Ge=new ze(qe),Qe=Ge;function Ye(n){return n&&m(n.schedule)}var Je=B(function(n){return function(){n(this),this.name="EmptyError",this.message="no elements in sequence"}});function R(n,t){var e=typeof t=="object";return new Promise(function(r,i){var o=new U({next:function(s){r(s),o.unsubscribe()},error:i,complete:function(){e?r(t.defaultValue):i(new Je)}});n.subscribe(o)})}function We(n){return n instanceof Date&&!isNaN(n)}function j(n,t){return pe(function(e,r){var i=0;e.subscribe(fe(r,function(o){r.next(n.call(t,o,i++))}))})}function Ke(n,t,e){n===void 0&&(n=0),e===void 0&&(e=Qe);var r=-1;return t!=null&&(Ye(t)?e=t:r=t),new Y(function(i){var o=We(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?pe(function(i,o){var s;(s=r.subscribe)===null||s===void 0||s.call(r);var c=!0;i.subscribe(fe(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)}))}):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 w(n){return typeof n=="function"}function nt(n){return w(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 W(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 K(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:
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 P=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 u=B(s),c=u.next();!c.done;c=u.next()){var a=c.value;a.remove(this)}}catch(d){t={error:d}}finally{try{c&&!c.done&&(e=u.return)&&e.call(u)}finally{if(t)throw t.error}}else s.remove(this);var v=this.initialTeardown;if(m(v))try{v()}catch(d){o=d instanceof z?d.errors:[d]}var y=this._finalizers;if(y){this._finalizers=null;try{for(var x=B(y),E=x.next();!E.done;E=x.next()){var oe=E.value;try{ue(oe)}catch(d){o=o??[],d instanceof z?o=T(T([],I(o)),I(d.errors)):o.push(d)}}}catch(d){r={error:d}}finally{try{E&&!E.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)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}(),se=P.EMPTY;function ce(n){return n instanceof P||n&&"closed"in n&&m(n.remove)&&m(n.add)&&m(n.unsubscribe)}function ue(n){m(n)?n():n.unsubscribe()}var ae={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},H={setTimeout:function(n,t){for(var e=[],r=2;r<arguments.length;r++)e[r-2]=arguments[r];var i=H.delegate;return i!=null&&i.setTimeout?i.setTimeout.apply(i,T([n,t],I(e))):setTimeout.apply(void 0,T([n,t],I(e)))},clearTimeout:function(n){var t=H.delegate;return((t==null?void 0:t.clearTimeout)||clearTimeout)(n)},delegate:void 0};function Re(n){H.setTimeout(function(){throw n})}function le(){}function L(n){n()}var Q=function(n){M(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}(P),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){M(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 u;o&&ae.useDeprecatedNextContext?(u=Object.create(e),u.unsubscribe=function(){return o.unsubscribe()},s={next:e.next&&Y(e.next,u),error:e.error&&Y(e.error,u),complete:e.complete&&Y(e.complete,u)}):s=e}return o.destination=new Le(s),o}return t}(Q);function U(n){Re(n)}function $e(n){throw n}var Ue={closed:!0,next:le,error:$e,complete:le},je=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function he(n){return n}function Ve(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,o=Ne(t)?t:new $(t,e,r);return L(function(){var s=i,u=s.operator,c=s.source;o.add(u?u.call(o,c):c?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=de(e),new e(function(i,o){var s=new $({next:function(u){try{t(u)}catch(c){o(c),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[je]=function(){return this},n.prototype.pipe=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return Ve(t)(this)},n.prototype.toPromise=function(t){var e=this;return t=de(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 de(n){var t;return(t=n??ae.Promise)!==null&&t!==void 0?t:Promise}function Fe(n){return n&&m(n.next)&&m(n.error)&&m(n.complete)}function Ne(n){return n&&n instanceof Q||Fe(n)&&ce(n)}function De(n){return m(n==null?void 0:n.lift)}function pe(n){return function(t){if(De(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 ke(n,t,e,r,i)}var ke=function(n){M(t,n);function t(e,r,i,o,s,u){var c=n.call(this,e)||this;return c.onFinalize=s,c.shouldUnsubscribe=u,c._next=r?function(a){try{r(a)}catch(v){e.error(v)}}:n.prototype._next,c._error=o?function(a){try{o(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){M(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,o;if(r._throwIfClosed(),!r.isStopped){r.currentObservers||(r.currentObservers=Array.from(r.observers));try{for(var s=B(r.currentObservers),u=s.next();!u.done;u=s.next()){var c=u.value;c.next(e)}}catch(a){i={error:a}}finally{try{u&&!u.done&&(o=s.return)&&o.call(s)}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,o=i.hasError,s=i.isStopped,u=i.observers;return o||s?se:(this.currentObservers=null,u.push(e),new P(function(){r.currentObservers=null,O(u,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 G;return e.source=this,e},t.create=function(e,r){return new ve(e,r)},t}(G),ve=function(n){M(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:se},t}(ge),ye={now:function(){return(ye.delegate||Date).now()},delegate:void 0},qe=function(n){M(t,n);function t(e,r){return n.call(this)||this}return t.prototype.schedule=function(e,r){return this},t}(P),j={setInterval:function(n,t){for(var e=[],r=2;r<arguments.length;r++)e[r-2]=arguments[r];var i=j.delegate;return i!=null&&i.setInterval?i.setInterval.apply(i,T([n,t],I(e))):setInterval.apply(void 0,T([n,t],I(e)))},clearInterval:function(n){var t=j.delegate;return((t==null?void 0:t.clearInterval)||clearInterval)(n)},delegate:void 0},ze=function(n){M(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),j.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&&j.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,O(o,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}(),He=function(n){M(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 He(ze),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 R(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 We(n){return n instanceof Date&&!isNaN(n)}function V(n,t){return pe(function(e,r){var i=0;e.subscribe(fe(r,function(o){r.next(n.call(t,o,i++))}))})}function Ke(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 o=We(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?pe(function(i,o){var s;(s=r.subscribe)===null||s===void 0||s.call(r);var u=!0;i.subscribe(fe(o,function(c){var a;(a=r.next)===null||a===void 0||a.call(r,c),o.next(c)},function(){var c;u=!1,(c=r.complete)===null||c===void 0||c.call(r),o.complete()},function(c){var a;u=!1,(a=r.error)===null||a===void 0||a.call(r,c),o.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,_=(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 F 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 w(n){return typeof n=="function"}function nt(n){return w(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 W(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 K(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(u){s={error:u}}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 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,o;if(!this.closed){this.closed=!0;var s=this._parentage;if(s)if(this._parentage=null,Array.isArray(s))try{for(var c=Se(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 b=this._finalizers;if(b){this._finalizers=null;try{for(var x=Se(b),E=x.next();!E.done;E=x.next()){var oe=E.value;try{xe(oe)}catch(d){o=o??[],d instanceof Z?o=X(X([],K(o)),K(d.errors)):o.push(d)}}}catch(d){r={error:d}}finally{try{E&&!E.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)xe(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&&w(n.remove)&&w(n.add)&&w(n.unsubscribe)}function xe(n){w(n)?n():n.unsubscribe()}var Me={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],K(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){W(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){D(r)}},n.prototype.error=function(t){var e=this.partialObserver;if(e.error)try{e.error(t)}catch(r){D(r)}else D(t)},n.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(e){D(e)}},n}(),ne=function(n){W(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&&Me.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 D(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 Ie(n){return n}function pt(n){return n.length===0?Ie: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=vt(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=Te(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=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??Me.Promise)!==null&&t!==void 0?t:Promise}function gt(n){return n&&w(n.next)&&w(n.error)&&w(n.complete)}function vt(n){return n&&n instanceof te||gt(n)&&Ce(n)}function H(n,t,e,r,i){return new bt(n,t,e,r,i)}var bt=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}(te);function h(n,t){return N(function(e,r){var i=0;e.subscribe(H(r,function(o){r.next(n.call(t,o,i++))}))})}var yt=new ft(function(n){return n.complete()});function S(n){return n<=0?function(){return yt}:N(function(t,e){var r=0;t.subscribe(H(e,function(i){++r<=n&&(e.next(i),n<=r&&e.complete())}))})}function g(n,t){return N(function(e,r){var i=0;e.subscribe(H(r,function(o){return n.call(t,o,i++)&&r.next(o)}))})}function f(n,t,e){var r=w(n)||t||e?{next:n,error:t,complete:e}:n;return r?N(function(i,o){var s;(s=r.subscribe)===null||s===void 0||s.call(r);var c=!0;i.subscribe(H(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)}))}):Ie}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 ie(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 ie(n,t)===1}function Et(n,t){return ie(n,t)>=0}const Pe="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,Pe)),!this.supportedVersions.length)throw new we(t,Pe);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 Ke(1e3).pipe(h(()=>(this.isEmbedded()?this.currentContext="user":this.currentContext="guest",this.currentContext)),S(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),f(this.logReceived(t)),h(i=>{if(this.supportedVersions.some(o=>St(o,i.protocolVersion)))throw new we(i.protocolVersion,this.supportedVersions[0]);return i}),f(i=>{this.negotiatedProtocolVersion=i.protocolVersion,this.logService.info(`[IPC] Negotiated IPC Protocol Version: ${this.negotiatedProtocolVersion}`)}),S(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),f(this.logReceived(t)),S(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:o,serverUrl:s,region:c,joinMicMuted:u,joinWithoutCamera:a}=t,v="JOINING ROOM",b=this.createMessage(v,!1);b.roomName=e,b.jwtToken=o,b.serverUrl=s,b.region=c,b.roomInvite=r,b.joinMicMuted=u??!1,b.joinWithoutCamera=a??!1,b.displayName=i,this.logCreated(v,b),this.port2.postMessage(b),this.logSent(v,b)}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),f(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),f(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),f(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(o=>o.type===e&&o.replyTo===r.id),h(o=>o),f(this.logReceived(e)),h(o=>o),S(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 o,s;if(e&&r?(o=this.createMessage(i,!1,r),o.result=e):(o=this.createMessage(i),s=this.incomingMessages$.pipe(g(c=>c.type===i&&c.replyTo===o.id),h(c=>c),f(this.logReceived(i)),h(c=>c),S(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 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),f(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(o=>o.type===e&&o.replyTo===r.id),h(o=>o),f(this.logReceived(e)),S(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 o="SELECT CONTACTS",s=this.createMessage(o,!0);s.streamType=e,s.streamId=t,s.contactType=r,s.currentContacts=i,this.logCreated(o,s);const c=this.incomingMessages$.pipe(g(u=>u.type===o&&u.replyTo===s.id),f(this.logReceived(o)),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}),S(1));return this.logService.debug(`Created ${o} Reply handler`),this.port2.postMessage(s),this.logSent(o,s),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(o=>o.type===e&&o.replyTo===r.id),f(this.logReceived(e)),h(o=>o),S(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),f(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),f(this.logReceived(t)),h(i=>i),S(1));return this.logService.debug(`Created ${t} Reply handler`),this.port2.postMessage(e),this.logSent(t,e),r}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),f(this.logReceived(t)))}sendBadgeUpdateMessage(t,e,r){if(!this.isEmbedded())throw new l(this.currentContext);const i="BADGE UPDATE",o=this.createMessage(i,!1,r);o.count=t,o.activity=e??!1,this.logCreated(i,o),this.port2.postMessage(o),this.logSent(i,o)}onHostInForegroundMessage(){if(!this.isEmbedded())throw new l(this.currentContext);const t="HOST IN FOREGROUND";return this.incomingMessages$.pipe(g(e=>e.type===t&&e.target==="client"),h(e=>e),f(this.logReceived(t)))}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),f(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),f(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),f(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 o=this.incomingMessages$.pipe(g(s=>s.type===r&&s.replyTo===i.id),f(this.logReceived(r)),h(s=>s),S(1));return this.port2.postMessage(i),this.logSent(r,i),o}sendFileDownloadMessage(t,e,r,i){if(!this.isEmbedded())throw new l(this.currentContext);const o="FILE DOWNLOAD",s=this.createMessage(o);s.url=t,s.key=e,s.fileName=r,s.mimeType=i,this.logCreated(o,s);const c=this.incomingMessages$.pipe(g(u=>u.type===o&&u.replyTo===s.id),f(this.logReceived(o)),h(u=>u),S(1));return this.port2.postMessage(s),this.logSent(o,s),c}sendFileUploadMessage(){throw new Error("Not implemented")}sendFileOpenMessage(t){if(!this.isEmbedded())throw new l(this.currentContext);const e="FILE OPEN",r=this.createMessage(e,!1);r.fileId=t,this.logCreated(e,r),this.port2.postMessage(r),this.logSent(e,r)}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 o=0;o<t;o++)i.push(r[Math.floor(Math.random()*r.length)]);return i.join("")}}const xt=["2.0"];class Mt{constructor(t){O(this,"host");O(this,"cloudId");O(this,"logger");O(this,"helper");O(this,"listeners");this.logger=t??console,this.helper=new Ct(xt,this.logger),this.listeners=new Map,this.listeners.set(p.BadgeQuery,new Set),this.listeners.set(p.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 R(this.helper.determineContext(),{defaultValue:"guest"});return this.evaluateContext(t)}initiateConnection(){return R(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(p.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(p.HostInForeground))==null?void 0:r.values())??[])i()}),this.cloudId=t.cloudId,this.host=t.host}),j(()=>{})))}selectContacts(t,e,r,i){this.logger.debug("Selecting Contacts: ",...arguments);let o;if(e==="multi"){if(!r||!Array.isArray(r))throw new V("currentContacts",r,"currentContacts is required for group streams");i||(i="cloudUsername"),o=this.helper.selectContacts(t.toString(),"group",i,r)}else r?i=r:i="cloudUsername",o=this.helper.selectContacts(t.toString(),"direct",i);return R(o.pipe(j(s=>s.contacts)))}matchContacts(t){return this.logger.debug("Match Contacts: ",t),R(this.helper.matchContacts(t).pipe(j(e=>e.contacts)))}requestPushToken(){return this.logger.debug("Requesting Push Token"),R(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)}onBadgeQueryRequest(t){var e;return this.logger.debug("Registering for Badge Query"),(e=this.listeners.get(p.BadgeQuery))==null||e.add(t),()=>{var r;return(r=this.listeners.get(p.BadgeQuery))==null?void 0:r.delete(t)}}onHostInForeground(t){var e;return this.logger.debug("Registering for Host In Foreground"),(e=this.listeners.get(p.HostInForeground))==null||e.add(t),()=>{var r;return(r=this.listeners.get(p.HostInForeground))==null?void 0:r.delete(t)}}evaluateContext(t){if(t==="user")return"host";if(t==="guest")return"standalone"}}y.IPCEvents=p,y.IPCManager=Mt,Object.defineProperty(y,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,o;if(!this.closed){this.closed=!0;var s=this._parentage;if(s)if(this._parentage=null,Array.isArray(s))try{for(var u=Se(s),c=u.next();!c.done;c=u.next()){var a=c.value;a.remove(this)}}catch(d){t={error:d}}finally{try{c&&!c.done&&(e=u.return)&&e.call(u)}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 y=this._finalizers;if(y){this._finalizers=null;try{for(var x=Se(y),E=x.next();!E.done;E=x.next()){var oe=E.value;try{xe(oe)}catch(d){o=o??[],d instanceof Z?o=X(X([],K(o)),K(d.errors)):o.push(d)}}}catch(d){r={error:d}}finally{try{E&&!E.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)xe(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&&w(n.remove)&&w(n.add)&&w(n.unsubscribe)}function xe(n){w(n)?n():n.unsubscribe()}var Me={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],K(e)))},clearTimeout:function(n){return clearTimeout(n)},delegate:void 0};function st(n){ot.setTimeout(function(){throw n})}function _e(){}function ct(n){n()}var te=function(n){W(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){D(r)}},n.prototype.error=function(t){var e=this.partialObserver;if(e.error)try{e.error(t)}catch(r){D(r)}else D(t)},n.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(e){D(e)}},n}(),ne=function(n){W(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 u;o&&Me.useDeprecatedNextContext?(u=Object.create(e),u.unsubscribe=function(){return o.unsubscribe()},s={next:e.next&&re(e.next,u),error:e.error&&re(e.error,u),complete:e.complete&&re(e.complete,u)}):s=e}return o.destination=new at(s),o}return t}(te);function D(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 Ie(n){return n}function pt(n){return n.length===0?Ie: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=vt(t)?t:new ne(t,e,r);return ct(function(){var s=i,u=s.operator,c=s.source;o.add(u?u.call(o,c):c?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 ne({next:function(u){try{t(u)}catch(c){o(c),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=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??Me.Promise)!==null&&t!==void 0?t:Promise}function gt(n){return n&&w(n.next)&&w(n.error)&&w(n.complete)}function vt(n){return n&&n instanceof te||gt(n)&&Ce(n)}function k(n,t,e,r,i){return new yt(n,t,e,r,i)}var yt=function(n){W(t,n);function t(e,r,i,o,s,u){var c=n.call(this,e)||this;return c.onFinalize=s,c.shouldUnsubscribe=u,c._next=r?function(a){try{r(a)}catch(v){e.error(v)}}:n.prototype._next,c._error=o?function(a){try{o(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(k(r,function(o){r.next(n.call(t,o,i++))}))})}var bt=new ft(function(n){return n.complete()});function S(n){return n<=0?function(){return bt}:N(function(t,e){var r=0;t.subscribe(k(e,function(i){++r<=n&&(e.next(i),n<=r&&e.complete())}))})}function g(n,t){return N(function(e,r){var i=0;e.subscribe(k(r,function(o){return n.call(t,o,i++)&&r.next(o)}))})}function f(n,t,e){var r=w(n)||t||e?{next:n,error:t,complete:e}:n;return r?N(function(i,o){var s;(s=r.subscribe)===null||s===void 0||s.call(r);var u=!0;i.subscribe(k(o,function(c){var a;(a=r.next)===null||a===void 0||a.call(r,c),o.next(c)},function(){var c;u=!1,(c=r.complete)===null||c===void 0||c.call(r),o.complete()},function(c){var a;u=!1,(a=r.error)===null||a===void 0||a.call(r,c),o.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)}))}):Ie}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 Ae(n){const t=wt(n),[e,r]=t.split("."),[i,o]=[parseInt(e),parseInt(r)];return[i,o]}function ie(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 St(n,t){return ie(n,t)===1}function Et(n,t){return ie(n,t)>=0}const Pe="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,Pe)),!this.supportedVersions.length)throw new we(t,Pe);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 Ke(1e3).pipe(h(()=>(this.isEmbedded()?this.currentContext="user":this.currentContext="guest",this.currentContext)),S(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),f(this.logReceived(t)),h(i=>{if(this.supportedVersions.some(o=>St(o,i.protocolVersion)))throw new we(i.protocolVersion,this.supportedVersions[0]);return i}),f(i=>{this.negotiatedProtocolVersion=i.protocolVersion,this.logService.info(`[IPC] Negotiated IPC Protocol Version: ${this.negotiatedProtocolVersion}`)}),S(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),f(this.logReceived(t)),S(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:o,serverUrl:s,region:u,joinMicMuted:c,joinWithoutCamera:a}=t,v="JOINING ROOM",y=this.createMessage(v,!1);y.roomName=e,y.jwtToken=o,y.serverUrl=s,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(g(e=>e.type===t&&e.target==="client"),h(e=>e),f(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),f(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),f(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(o=>o.type===e&&o.replyTo===r.id),h(o=>o),f(this.logReceived(e)),h(o=>o),S(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 o,s;if(e&&r?(o=this.createMessage(i,!1,r),o.result=e):(o=this.createMessage(i),s=this.incomingMessages$.pipe(g(u=>u.type===i&&u.replyTo===o.id),h(u=>u),f(this.logReceived(i)),h(u=>u),S(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 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),f(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(o=>o.type===e&&o.replyTo===r.id),h(o=>o),f(this.logReceived(e)),S(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 F("currentContacts",i,"currentContacts is required for group streams");if(e==="direct"&&i!==void 0)throw new F("currentContacts",i,"currentContacts should not be passed for direct streams");const o="SELECT CONTACTS",s=this.createMessage(o,!0);s.streamType=e,s.streamId=t,s.contactType=r,s.currentContacts=i,this.logCreated(o,s);const u=this.incomingMessages$.pipe(g(c=>c.type===o&&c.replyTo===s.id),f(this.logReceived(o)),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}),S(1));return this.logService.debug(`Created ${o} Reply handler`),this.port2.postMessage(s),this.logSent(o,s),u}matchContacts(t){if(!this.isEmbedded())throw new l(this.currentContext);if(!t.length)throw new F("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(o=>o.type===e&&o.replyTo===r.id),f(this.logReceived(e)),h(o=>o),S(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),f(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),f(this.logReceived(t)),h(i=>i),S(1));return this.logService.debug(`Created ${t} Reply handler`),this.port2.postMessage(e),this.logSent(t,e),r}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),f(this.logReceived(t)))}sendBadgeUpdateMessage(t,e,r){if(!this.isEmbedded())throw new l(this.currentContext);const i="BADGE UPDATE",o=this.createMessage(i,!1,r);o.count=t,o.activity=e??!1,this.logCreated(i,o),this.port2.postMessage(o),this.logSent(i,o)}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),f(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),f(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),f(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 o=this.incomingMessages$.pipe(g(s=>s.type===r&&s.replyTo===i.id),f(this.logReceived(r)),h(s=>s),S(1));return this.port2.postMessage(i),this.logSent(r,i),o}sendFileDownloadMessage(t,e,r,i){if(!this.isEmbedded())throw new l(this.currentContext);const o="FILE DOWNLOAD",s=this.createMessage(o);s.url=t,s.key=e,s.fileName=r,s.mimeType=i,this.logCreated(o,s);const u=this.incomingMessages$.pipe(g(c=>c.type===o&&c.replyTo===s.id),f(this.logReceived(o)),h(c=>c),S(1));return this.port2.postMessage(s),this.logSent(o,s),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,!1);r.fileId=t,this.logCreated(e,r),this.port2.postMessage(r),this.logSent(e,r)}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 o=0;o<t;o++)i.push(r[Math.floor(Math.random()*r.length)]);return i.join("")}}const xt=["2.0"];class Mt{constructor(t){A(this,"host");A(this,"cloudId");A(this,"logger");A(this,"helper");A(this,"listeners");this.logger=t??console,this.helper=new Ct(xt,this.logger),this.listeners=new Map,this.listeners.set(p.BadgeQuery,new Set),this.listeners.set(p.Lifecycle,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 R(this.helper.determineContext(),{defaultValue:"guest"});return this.evaluateContext(t)}initiateConnection(){return R(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(p.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(p.Lifecycle))==null?void 0:r.values())??[])i(e.eventName,e.payload)}),this.cloudId=t.cloudId,this.host=t.host}),V(()=>{})))}selectContacts(t,e,r,i){this.logger.debug("Selecting Contacts: ",...arguments);let o;if(e==="multi"){if(!r||!Array.isArray(r))throw new F("currentContacts",r,"currentContacts is required for group streams");i||(i="cloudUsername"),o=this.helper.selectContacts(t.toString(),"group",i,r)}else r?i=r:i="cloudUsername",o=this.helper.selectContacts(t.toString(),"direct",i);return R(o.pipe(V(s=>s.contacts)))}matchContacts(t){return this.logger.debug("Match Contacts: ",t),R(this.helper.matchContacts(t).pipe(V(e=>e.contacts)))}requestPushToken(){return this.logger.debug("Requesting Push Token"),R(this.helper.requestPushToken().pipe(V(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(p.BadgeQuery))==null||e.add(t),()=>{var r;return(r=this.listeners.get(p.BadgeQuery))==null?void 0:r.delete(t)}}onLifecycleEvent(t){var e;return this.logger.debug("Registering for Lifecycle Event"),(e=this.listeners.get(p.Lifecycle))==null||e.add(t),()=>{var r;return(r=this.listeners.get(p.Lifecycle))==null?void 0:r.delete(t)}}evaluateContext(t){if(t==="user")return"host";if(t==="guest")return"standalone"}}b.IPCEvents=p,b.IPCManager=Mt,Object.defineProperty(b,Symbol.toStringTag,{value:"Module"})});