@acrobits/ipc-sdk 0.8.1-alpha.11 → 0.8.1-alpha.13
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.
- package/lib/ipc-sdk.js +29 -27
- package/lib/ipc-sdk.js.map +1 -1
- package/lib/ipc-sdk.umd.cjs +3 -3
- package/lib/ipc-sdk.umd.cjs.map +1 -1
- package/package.json +2 -2
package/lib/ipc-sdk.umd.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(E,v){typeof exports=="object"&&typeof module<"u"?v(exports):typeof define=="function"&&define.amd?define(["exports"],v):(E=typeof globalThis<"u"?globalThis:E||self,v(E["@acrobits/ipc-sdk"]={}))})(this,function(E){"use strict";var Rt=Object.defineProperty;var Pt=(E,v,M)=>v in E?Rt(E,v,{enumerable:!0,configurable:!0,writable:!0,value:M}):E[v]=M;var R=(E,v,M)=>(Pt(E,typeof v!="symbol"?v+"":v,M),M);var v=(n=>(n.BadgeQuery="BADGE QUERY",n.Lifecycle="LIFECYCLE",n.PushToken="PUSH TOKEN",n))(v||{}),M=function(n,t){return M=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])},M(n,t)};function x(n,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");M(n,t);function e(){this.constructor=n}n.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}function j(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 L(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var r=e.call(n),s,i=[],o;try{for(;(t===void 0||t-- >0)&&!(s=r.next()).done;)i.push(s.value)}catch(a){o={error:a}}finally{try{s&&!s.done&&(e=r.return)&&e.call(r)}finally{if(o)throw o.error}}return i}function U(n,t,e){if(e||arguments.length===2)for(var r=0,s=t.length,i;r<s;r++)(i||!(r in t))&&(i||(i=Array.prototype.slice.call(t,0,r)),i[r]=t[r]);return n.concat(i||Array.prototype.slice.call(t))}function S(n){return typeof n=="function"}function V(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=V(function(n){return function(e){n(this),this.message=e?e.length+` errors occurred during unsubscription:
|
|
2
2
|
`+e.map(function(r,s){return s+1+") "+r.toString()}).join(`
|
|
3
|
-
`):"",this.name="UnsubscriptionError",this.errors=e}});function $(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,s,i;if(!this.closed){this.closed=!0;var o=this._parentage;if(o)if(this._parentage=null,Array.isArray(o))try{for(var a=j(o),c=a.next();!c.done;c=a.next()){var u=c.value;u.remove(this)}}catch(y){t={error:y}}finally{try{c&&!c.done&&(e=a.return)&&e.call(a)}finally{if(t)throw t.error}}else o.remove(this);var l=this.initialTeardown;if(E(l))try{l()}catch(y){i=y instanceof Q?y.errors:[y]}var d=this._finalizers;if(d){this._finalizers=null;try{for(var b=j(d),m=b.next();!m.done;m=b.next()){var se=m.value;try{ae(se)}catch(y){i=i??[],y instanceof Q?i=U(U([],L(i)),L(y.errors)):i.push(y)}}}catch(y){r={error:y}}finally{try{m&&!m.done&&(s=b.return)&&s.call(b)}finally{if(r)throw r.error}}}if(i)throw new Q(i)}},n.prototype.add=function(t){var e;if(t&&t!==this)if(this.closed)ae(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)&&$(e,t)},n.prototype.remove=function(t){var e=this._finalizers;e&&$(e,t),t instanceof n&&t._removeParent(this)},n.EMPTY=function(){var t=new n;return t.closed=!0,t}(),n}(),ie=P.EMPTY;function oe(n){return n instanceof P||n&&"closed"in n&&E(n.remove)&&E(n.add)&&E(n.unsubscribe)}function ae(n){E(n)?n():n.unsubscribe()}var ce={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},ue={setTimeout:function(n,t){for(var e=[],r=2;r<arguments.length;r++)e[r-2]=arguments[r];return setTimeout.apply(void 0,U([n,t],L(e)))},clearTimeout:function(n){var t=ue.delegate;return((t==null?void 0:t.clearTimeout)||clearTimeout)(n)},delegate:void 0};function _e(n){ue.setTimeout(function(){throw n})}function le(){}function F(n){n()}var q=function(n){x(t,n);function t(e){var r=n.call(this)||this;return r.isStopped=!1,e?(r.destination=e,oe(e)&&e.add(r)):r.destination=Ue,r}return t.create=function(e,r,s){return new D(e,r,s)},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 B(n,t){return Ae.call(n,t)}var Oe=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}(),D=function(n){x(t,n);function t(e,r,s){var i=n.call(this)||this,o;if(E(e)||!e)o={next:e??void 0,error:r??void 0,complete:s??void 0};else{var a;i&&ce.useDeprecatedNextContext?(a=Object.create(e),a.unsubscribe=function(){return i.unsubscribe()},o={next:e.next&&B(e.next,a),error:e.error&&B(e.error,a),complete:e.complete&&B(e.complete,a)}):o=e}return i.destination=new Oe(o),i}return t}(q);function k(n){_e(n)}function Le(n){throw n}var Ue={closed:!0,next:le,error:Le,complete:le},$e=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function he(n){return n}function Fe(n){return n.length===0?he:n.length===1?n[0]:function(e){return n.reduce(function(r,s){return s(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 s=this,i=ke(t)?t:new D(t,e,r);return F(function(){var o=s,a=o.operator,c=o.source;i.add(a?a.call(i,c):c?s._subscribe(i):s._trySubscribe(i))}),i},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(s,i){var o=new D({next:function(a){try{t(a)}catch(c){i(c),o.unsubscribe()}},error:i,complete:s});r.subscribe(o)})},n.prototype._subscribe=function(t){var e;return(e=this.source)===null||e===void 0?void 0:e.subscribe(t)},n.prototype[$e]=function(){return this},n.prototype.pipe=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return Fe(t)(this)},n.prototype.toPromise=function(t){var e=this;return t=de(t),new t(function(r,s){var i;e.subscribe(function(o){return i=o},function(o){return s(o)},function(){return r(i)})})},n.create=function(t){return new n(t)},n}();function de(n){var t;return(t=n??ce.Promise)!==null&&t!==void 0?t:Promise}function De(n){return n&&E(n.next)&&E(n.error)&&E(n.complete)}function ke(n){return n&&n instanceof q||De(n)&&oe(n)}function He(n){return E(n==null?void 0:n.lift)}function pe(n){return function(t){if(He(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,s){return new Ne(n,t,e,r,s)}var Ne=function(n){x(t,n);function t(e,r,s,i,o,a){var c=n.call(this,e)||this;return c.onFinalize=o,c.shouldUnsubscribe=a,c._next=r?function(u){try{r(u)}catch(l){e.error(l)}}:n.prototype._next,c._error=i?function(u){try{i(u)}catch(l){e.error(l)}finally{this.unsubscribe()}}:n.prototype._error,c._complete=s?function(){try{s()}catch(u){e.error(u)}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),je=V(function(n){return function(){n(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),ge=function(n){x(t,n);function t(){var e=n.call(this)||this;return e.closed=!1,e.currentObservers=null,e.observers=[],e.isStopped=!1,e.hasError=!1,e.thrownError=null,e}return t.prototype.lift=function(e){var r=new ve(this,this);return r.operator=e,r},t.prototype._throwIfClosed=function(){if(this.closed)throw new je},t.prototype.next=function(e){var r=this;F(function(){var s,i;if(r._throwIfClosed(),!r.isStopped){r.currentObservers||(r.currentObservers=Array.from(r.observers));try{for(var o=j(r.currentObservers),a=o.next();!a.done;a=o.next()){var c=a.value;c.next(e)}}catch(u){s={error:u}}finally{try{a&&!a.done&&(i=o.return)&&i.call(o)}finally{if(s)throw s.error}}}})},t.prototype.error=function(e){var r=this;F(function(){if(r._throwIfClosed(),!r.isStopped){r.hasError=r.isStopped=!0,r.thrownError=e;for(var s=r.observers;s.length;)s.shift().error(e)}})},t.prototype.complete=function(){var e=this;F(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,s=this,i=s.hasError,o=s.isStopped,a=s.observers;return i||o?ie:(this.currentObservers=null,a.push(e),new P(function(){r.currentObservers=null,$(a,e)}))},t.prototype._checkFinalizedStatuses=function(e){var r=this,s=r.hasError,i=r.thrownError,o=r.isStopped;s?e.error(i):o&&e.complete()},t.prototype.asObservable=function(){var e=new G;return e.source=this,e},t.create=function(e,r){return new ve(e,r)},t}(G),ve=function(n){x(t,n);function t(e,r){var s=n.call(this)||this;return s.destination=e,s.source=r,s}return t.prototype.next=function(e){var r,s;(s=(r=this.destination)===null||r===void 0?void 0:r.next)===null||s===void 0||s.call(r,e)},t.prototype.error=function(e){var r,s;(s=(r=this.destination)===null||r===void 0?void 0:r.error)===null||s===void 0||s.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,s;return(s=(r=this.source)===null||r===void 0?void 0:r.subscribe(e))!==null&&s!==void 0?s:ie},t}(ge),Ve={now:function(){return Date.now()},delegate:void 0},Qe=function(n){x(t,n);function t(e,r){return n.call(this)||this}return t.prototype.schedule=function(e,r){return this},t}(P),Y={setInterval:function(n,t){for(var e=[],r=2;r<arguments.length;r++)e[r-2]=arguments[r];return setInterval.apply(void 0,U([n,t],L(e)))},clearInterval:function(n){var t=Y.delegate;return((t==null?void 0:t.clearInterval)||clearInterval)(n)},delegate:void 0},qe=function(n){x(t,n);function t(e,r){var s=n.call(this,e,r)||this;return s.scheduler=e,s.work=r,s.pending=!1,s}return t.prototype.schedule=function(e,r){var s;if(r===void 0&&(r=0),this.closed)return this;this.state=e;var i=this.id,o=this.scheduler;return i!=null&&(this.id=this.recycleAsyncId(o,i,r)),this.pending=!0,this.delay=r,this.id=(s=this.id)!==null&&s!==void 0?s:this.requestAsyncId(o,this.id,r),this},t.prototype.requestAsyncId=function(e,r,s){return s===void 0&&(s=0),Y.setInterval(e.flush.bind(e,this),s)},t.prototype.recycleAsyncId=function(e,r,s){if(s===void 0&&(s=0),s!=null&&this.delay===s&&this.pending===!1)return r;r!=null&&Y.clearInterval(r)},t.prototype.execute=function(e,r){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var s=this._execute(e,r);if(s)return s;this.pending===!1&&this.id!=null&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},t.prototype._execute=function(e,r){var s=!1,i;try{this.work(e)}catch(o){s=!0,i=o||new Error("Scheduled action threw falsy error")}if(s)return this.unsubscribe(),i},t.prototype.unsubscribe=function(){if(!this.closed){var e=this,r=e.id,s=e.scheduler,i=s.actions;this.work=this.state=this.scheduler=null,this.pending=!1,$(i,this),r!=null&&(this.id=this.recycleAsyncId(s,r,null)),this.delay=null,n.prototype.unsubscribe.call(this)}},t}(Qe),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=Ve.now,n}(),Be=function(n){x(t,n);function t(e,r){r===void 0&&(r=ye.now);var s=n.call(this,e,r)||this;return s.actions=[],s._active=!1,s}return t.prototype.flush=function(e){var r=this.actions;if(this._active){r.push(e);return}var s;this._active=!0;do if(s=e.execute(e.state,e.delay))break;while(e=r.shift());if(this._active=!1,s){for(;e=r.shift();)e.unsubscribe();throw s}},t}(ye),Ge=new Be(qe),Ye=Ge;function ze(n){return n&&E(n.schedule)}var We=V(function(n){return function(){n(this),this.name="EmptyError",this.message="no elements in sequence"}});function _(n,t){var e=typeof t=="object";return new Promise(function(r,s){var i=new D({next:function(o){r(o),i.unsubscribe()},error:s,complete:function(){e?r(t.defaultValue):s(new We)}});n.subscribe(i)})}function Ke(n){return n instanceof Date&&!isNaN(n)}function H(n,t){return pe(function(e,r){var s=0;e.subscribe(fe(r,function(i){r.next(n.call(t,i,s++))}))})}function Je(n,t,e){n===void 0&&(n=0),e===void 0&&(e=Ye);var r=-1;return t!=null&&(ze(t)?e=t:r=t),new G(function(s){var i=Ke(n)?+n-e.now():n;i<0&&(i=0);var o=0;return e.schedule(function(){s.closed||(s.next(o++),0<=r?this.schedule(void 0,r):s.complete())},i)})}function Xe(n,t,e){var r=E(n)||t||e?{next:n,error:t,complete:e}:n;return r?pe(function(s,i){var o;(o=r.subscribe)===null||o===void 0||o.call(r);var a=!0;s.subscribe(fe(i,function(c){var u;(u=r.next)===null||u===void 0||u.call(r,c),i.next(c)},function(){var c;a=!1,(c=r.complete)===null||c===void 0||c.call(r),i.complete()},function(c){var u;a=!1,(u=r.error)===null||u===void 0||u.call(r,c),i.error(c)},function(){var c,u;a&&((c=r.unsubscribe)===null||c===void 0||c.call(r)),(u=r.finalize)===null||u===void 0||u.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,I=(n,t,e)=>(et(n,typeof t!="symbol"?t+"":t,e),e);class h extends Error{constructor(t){super(`Incorrect context (${t}). Cannot perform the requested operation.`),I(this,"context"),this.context=t}}class T 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 be 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 C(n){return typeof n=="function"}function nt(n){return C(n==null?void 0:n.lift)}function A(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 z=function(n,t){return z=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])},z(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");z(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 K(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var r=e.call(n),s,i=[],o;try{for(;(t===void 0||t-- >0)&&!(s=r.next()).done;)i.push(s.value)}catch(a){o={error:a}}finally{try{s&&!s.done&&(e=r.return)&&e.call(r)}finally{if(o)throw o.error}}return i}function J(n,t,e){if(e||arguments.length===2)for(var r=0,s=t.length,i;r<s;r++)(i||!(r in t))&&(i||(i=Array.prototype.slice.call(t,0,r)),i[r]=t[r]);return n.concat(i||Array.prototype.slice.call(t))}function st(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 X=st(function(n){return function(t){n(this),this.message=t?t.length+` errors occurred during unsubscription:
|
|
3
|
+
`):"",this.name="UnsubscriptionError",this.errors=e}});function $(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,s,i;if(!this.closed){this.closed=!0;var o=this._parentage;if(o)if(this._parentage=null,Array.isArray(o))try{for(var a=j(o),c=a.next();!c.done;c=a.next()){var u=c.value;u.remove(this)}}catch(y){t={error:y}}finally{try{c&&!c.done&&(e=a.return)&&e.call(a)}finally{if(t)throw t.error}}else o.remove(this);var l=this.initialTeardown;if(S(l))try{l()}catch(y){i=y instanceof Q?y.errors:[y]}var d=this._finalizers;if(d){this._finalizers=null;try{for(var b=j(d),m=b.next();!m.done;m=b.next()){var se=m.value;try{ae(se)}catch(y){i=i??[],y instanceof Q?i=U(U([],L(i)),L(y.errors)):i.push(y)}}}catch(y){r={error:y}}finally{try{m&&!m.done&&(s=b.return)&&s.call(b)}finally{if(r)throw r.error}}}if(i)throw new Q(i)}},n.prototype.add=function(t){var e;if(t&&t!==this)if(this.closed)ae(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)&&$(e,t)},n.prototype.remove=function(t){var e=this._finalizers;e&&$(e,t),t instanceof n&&t._removeParent(this)},n.EMPTY=function(){var t=new n;return t.closed=!0,t}(),n}(),ie=P.EMPTY;function oe(n){return n instanceof P||n&&"closed"in n&&S(n.remove)&&S(n.add)&&S(n.unsubscribe)}function ae(n){S(n)?n():n.unsubscribe()}var ce={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},ue={setTimeout:function(n,t){for(var e=[],r=2;r<arguments.length;r++)e[r-2]=arguments[r];return setTimeout.apply(void 0,U([n,t],L(e)))},clearTimeout:function(n){var t=ue.delegate;return((t==null?void 0:t.clearTimeout)||clearTimeout)(n)},delegate:void 0};function _e(n){ue.setTimeout(function(){throw n})}function le(){}function D(n){n()}var q=function(n){x(t,n);function t(e){var r=n.call(this)||this;return r.isStopped=!1,e?(r.destination=e,oe(e)&&e.add(r)):r.destination=Ue,r}return t.create=function(e,r,s){return new F(e,r,s)},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 G(n,t){return Ae.call(n,t)}var Oe=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}(),F=function(n){x(t,n);function t(e,r,s){var i=n.call(this)||this,o;if(S(e)||!e)o={next:e??void 0,error:r??void 0,complete:s??void 0};else{var a;i&&ce.useDeprecatedNextContext?(a=Object.create(e),a.unsubscribe=function(){return i.unsubscribe()},o={next:e.next&&G(e.next,a),error:e.error&&G(e.error,a),complete:e.complete&&G(e.complete,a)}):o=e}return i.destination=new Oe(o),i}return t}(q);function k(n){_e(n)}function Le(n){throw n}var Ue={closed:!0,next:le,error:Le,complete:le},$e=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function he(n){return n}function De(n){return n.length===0?he:n.length===1?n[0]:function(e){return n.reduce(function(r,s){return s(r)},e)}}var B=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 s=this,i=ke(t)?t:new F(t,e,r);return D(function(){var o=s,a=o.operator,c=o.source;i.add(a?a.call(i,c):c?s._subscribe(i):s._trySubscribe(i))}),i},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(s,i){var o=new F({next:function(a){try{t(a)}catch(c){i(c),o.unsubscribe()}},error:i,complete:s});r.subscribe(o)})},n.prototype._subscribe=function(t){var e;return(e=this.source)===null||e===void 0?void 0:e.subscribe(t)},n.prototype[$e]=function(){return this},n.prototype.pipe=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return De(t)(this)},n.prototype.toPromise=function(t){var e=this;return t=de(t),new t(function(r,s){var i;e.subscribe(function(o){return i=o},function(o){return s(o)},function(){return r(i)})})},n.create=function(t){return new n(t)},n}();function de(n){var t;return(t=n??ce.Promise)!==null&&t!==void 0?t:Promise}function Fe(n){return n&&S(n.next)&&S(n.error)&&S(n.complete)}function ke(n){return n&&n instanceof q||Fe(n)&&oe(n)}function He(n){return S(n==null?void 0:n.lift)}function pe(n){return function(t){if(He(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,s){return new Ne(n,t,e,r,s)}var Ne=function(n){x(t,n);function t(e,r,s,i,o,a){var c=n.call(this,e)||this;return c.onFinalize=o,c.shouldUnsubscribe=a,c._next=r?function(u){try{r(u)}catch(l){e.error(l)}}:n.prototype._next,c._error=i?function(u){try{i(u)}catch(l){e.error(l)}finally{this.unsubscribe()}}:n.prototype._error,c._complete=s?function(){try{s()}catch(u){e.error(u)}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),je=V(function(n){return function(){n(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),ge=function(n){x(t,n);function t(){var e=n.call(this)||this;return e.closed=!1,e.currentObservers=null,e.observers=[],e.isStopped=!1,e.hasError=!1,e.thrownError=null,e}return t.prototype.lift=function(e){var r=new ve(this,this);return r.operator=e,r},t.prototype._throwIfClosed=function(){if(this.closed)throw new je},t.prototype.next=function(e){var r=this;D(function(){var s,i;if(r._throwIfClosed(),!r.isStopped){r.currentObservers||(r.currentObservers=Array.from(r.observers));try{for(var o=j(r.currentObservers),a=o.next();!a.done;a=o.next()){var c=a.value;c.next(e)}}catch(u){s={error:u}}finally{try{a&&!a.done&&(i=o.return)&&i.call(o)}finally{if(s)throw s.error}}}})},t.prototype.error=function(e){var r=this;D(function(){if(r._throwIfClosed(),!r.isStopped){r.hasError=r.isStopped=!0,r.thrownError=e;for(var s=r.observers;s.length;)s.shift().error(e)}})},t.prototype.complete=function(){var e=this;D(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,s=this,i=s.hasError,o=s.isStopped,a=s.observers;return i||o?ie:(this.currentObservers=null,a.push(e),new P(function(){r.currentObservers=null,$(a,e)}))},t.prototype._checkFinalizedStatuses=function(e){var r=this,s=r.hasError,i=r.thrownError,o=r.isStopped;s?e.error(i):o&&e.complete()},t.prototype.asObservable=function(){var e=new B;return e.source=this,e},t.create=function(e,r){return new ve(e,r)},t}(B),ve=function(n){x(t,n);function t(e,r){var s=n.call(this)||this;return s.destination=e,s.source=r,s}return t.prototype.next=function(e){var r,s;(s=(r=this.destination)===null||r===void 0?void 0:r.next)===null||s===void 0||s.call(r,e)},t.prototype.error=function(e){var r,s;(s=(r=this.destination)===null||r===void 0?void 0:r.error)===null||s===void 0||s.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,s;return(s=(r=this.source)===null||r===void 0?void 0:r.subscribe(e))!==null&&s!==void 0?s:ie},t}(ge),Ve={now:function(){return Date.now()},delegate:void 0},Qe=function(n){x(t,n);function t(e,r){return n.call(this)||this}return t.prototype.schedule=function(e,r){return this},t}(P),Y={setInterval:function(n,t){for(var e=[],r=2;r<arguments.length;r++)e[r-2]=arguments[r];return setInterval.apply(void 0,U([n,t],L(e)))},clearInterval:function(n){var t=Y.delegate;return((t==null?void 0:t.clearInterval)||clearInterval)(n)},delegate:void 0},qe=function(n){x(t,n);function t(e,r){var s=n.call(this,e,r)||this;return s.scheduler=e,s.work=r,s.pending=!1,s}return t.prototype.schedule=function(e,r){var s;if(r===void 0&&(r=0),this.closed)return this;this.state=e;var i=this.id,o=this.scheduler;return i!=null&&(this.id=this.recycleAsyncId(o,i,r)),this.pending=!0,this.delay=r,this.id=(s=this.id)!==null&&s!==void 0?s:this.requestAsyncId(o,this.id,r),this},t.prototype.requestAsyncId=function(e,r,s){return s===void 0&&(s=0),Y.setInterval(e.flush.bind(e,this),s)},t.prototype.recycleAsyncId=function(e,r,s){if(s===void 0&&(s=0),s!=null&&this.delay===s&&this.pending===!1)return r;r!=null&&Y.clearInterval(r)},t.prototype.execute=function(e,r){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var s=this._execute(e,r);if(s)return s;this.pending===!1&&this.id!=null&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},t.prototype._execute=function(e,r){var s=!1,i;try{this.work(e)}catch(o){s=!0,i=o||new Error("Scheduled action threw falsy error")}if(s)return this.unsubscribe(),i},t.prototype.unsubscribe=function(){if(!this.closed){var e=this,r=e.id,s=e.scheduler,i=s.actions;this.work=this.state=this.scheduler=null,this.pending=!1,$(i,this),r!=null&&(this.id=this.recycleAsyncId(s,r,null)),this.delay=null,n.prototype.unsubscribe.call(this)}},t}(Qe),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=Ve.now,n}(),Ge=function(n){x(t,n);function t(e,r){r===void 0&&(r=ye.now);var s=n.call(this,e,r)||this;return s.actions=[],s._active=!1,s}return t.prototype.flush=function(e){var r=this.actions;if(this._active){r.push(e);return}var s;this._active=!0;do if(s=e.execute(e.state,e.delay))break;while(e=r.shift());if(this._active=!1,s){for(;e=r.shift();)e.unsubscribe();throw s}},t}(ye),Be=new Ge(qe),Ye=Be;function ze(n){return n&&S(n.schedule)}var We=V(function(n){return function(){n(this),this.name="EmptyError",this.message="no elements in sequence"}});function _(n,t){var e=typeof t=="object";return new Promise(function(r,s){var i=new F({next:function(o){r(o),i.unsubscribe()},error:s,complete:function(){e?r(t.defaultValue):s(new We)}});n.subscribe(i)})}function Ke(n){return n instanceof Date&&!isNaN(n)}function H(n,t){return pe(function(e,r){var s=0;e.subscribe(fe(r,function(i){r.next(n.call(t,i,s++))}))})}function Je(n,t,e){n===void 0&&(n=0),e===void 0&&(e=Ye);var r=-1;return t!=null&&(ze(t)?e=t:r=t),new B(function(s){var i=Ke(n)?+n-e.now():n;i<0&&(i=0);var o=0;return e.schedule(function(){s.closed||(s.next(o++),0<=r?this.schedule(void 0,r):s.complete())},i)})}function Xe(n,t,e){var r=S(n)||t||e?{next:n,error:t,complete:e}:n;return r?pe(function(s,i){var o;(o=r.subscribe)===null||o===void 0||o.call(r);var a=!0;s.subscribe(fe(i,function(c){var u;(u=r.next)===null||u===void 0||u.call(r,c),i.next(c)},function(){var c;a=!1,(c=r.complete)===null||c===void 0||c.call(r),i.complete()},function(c){var u;a=!1,(u=r.error)===null||u===void 0||u.call(r,c),i.error(c)},function(){var c,u;a&&((c=r.unsubscribe)===null||c===void 0||c.call(r)),(u=r.finalize)===null||u===void 0||u.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,I=(n,t,e)=>(et(n,typeof t!="symbol"?t+"":t,e),e);class h extends Error{constructor(t){super(`Incorrect context (${t}). Cannot perform the requested operation.`),I(this,"context"),this.context=t}}class T 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 be 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 C(n){return typeof n=="function"}function nt(n){return C(n==null?void 0:n.lift)}function A(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 z=function(n,t){return z=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])},z(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");z(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 K(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var r=e.call(n),s,i=[],o;try{for(;(t===void 0||t-- >0)&&!(s=r.next()).done;)i.push(s.value)}catch(a){o={error:a}}finally{try{s&&!s.done&&(e=r.return)&&e.call(r)}finally{if(o)throw o.error}}return i}function J(n,t,e){if(e||arguments.length===2)for(var r=0,s=t.length,i;r<s;r++)(i||!(r in t))&&(i||(i=Array.prototype.slice.call(t,0,r)),i[r]=t[r]);return n.concat(i||Array.prototype.slice.call(t))}function st(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 X=st(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 Se(n,t){if(n){var e=n.indexOf(t);0<=e&&n.splice(e,1)}}var Z=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,s,i;if(!this.closed){this.closed=!0;var o=this._parentage;if(o)if(this._parentage=null,Array.isArray(o))try{for(var a=we(o),c=a.next();!c.done;c=a.next()){var u=c.value;u.remove(this)}}catch(y){t={error:y}}finally{try{c&&!c.done&&(e=a.return)&&e.call(a)}finally{if(t)throw t.error}}else o.remove(this);var l=this.initialTeardown;if(C(l))try{l()}catch(y){i=y instanceof X?y.errors:[y]}var d=this._finalizers;if(d){this._finalizers=null;try{for(var b=we(d),m=b.next();!m.done;m=b.next()){var se=m.value;try{Ce(se)}catch(y){i=i??[],y instanceof X?i=J(J([],K(i)),K(y.errors)):i.push(y)}}}catch(y){r={error:y}}finally{try{m&&!m.done&&(s=b.return)&&s.call(b)}finally{if(r)throw r.error}}}if(i)throw new X(i)}},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)&&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}();Z.EMPTY;function Ee(n){return n instanceof Z||n&&"closed"in n&&C(n.remove)&&C(n.add)&&C(n.unsubscribe)}function Ce(n){C(n)?n():n.unsubscribe()}var Me={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},it={setTimeout:function(n,t){for(var e=[],r=2;r<arguments.length;r++)e[r-2]=arguments[r];return setTimeout.apply(void 0,J([n,t],K(e)))},clearTimeout:function(n){return clearTimeout(n)},delegate:void 0};function ot(n){it.setTimeout(function(){throw n})}function xe(){}function at(n){n()}var ee=function(n){W(t,n);function t(e){var r=n.call(this)||this;return r.isStopped=!1,e?(r.destination=e,Ee(e)&&e.add(r)):r.destination=ht,r}return t.create=function(e,r,s){return new re(e,r,s)},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}(Z),ct=Function.prototype.bind;function te(n,t){return ct.call(n,t)}var ut=function(){function n(t){this.partialObserver=t}return n.prototype.next=function(t){var e=this.partialObserver;if(e.next)try{e.next(t)}catch(r){N(r)}},n.prototype.error=function(t){var e=this.partialObserver;if(e.error)try{e.error(t)}catch(r){N(r)}else N(t)},n.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(e){N(e)}},n}(),re=function(n){W(t,n);function t(e,r,s){var i=n.call(this)||this,o;if(C(e)||!e)o={next:e??void 0,error:r??void 0,complete:s??void 0};else{var a;i&&Me.useDeprecatedNextContext?(a=Object.create(e),a.unsubscribe=function(){return i.unsubscribe()},o={next:e.next&&te(e.next,a),error:e.error&&te(e.error,a),complete:e.complete&&te(e.complete,a)}):o=e}return i.destination=new ut(o),i}return t}(ee);function N(n){ot(n)}function lt(n){throw n}var ht={closed:!0,next:xe,error:lt,complete:xe},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 s=this,i=vt(t)?t:new re(t,e,r);return at(function(){var o=s,a=o.operator,c=o.source;i.add(a?a.call(i,c):c?s._subscribe(i):s._trySubscribe(i))}),i},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(s,i){var o=new re({next:function(a){try{t(a)}catch(c){i(c),o.unsubscribe()}},error:i,complete:s});r.subscribe(o)})},n.prototype._subscribe=function(t){var e;return(e=this.source)===null||e===void 0?void 0:e.subscribe(t)},n.prototype[dt]=function(){return this},n.prototype.pipe=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return pt(t)(this)},n.prototype.toPromise=function(t){var e=this;return t=Te(t),new t(function(r,s){var i;e.subscribe(function(o){return i=o},function(o){return s(o)},function(){return r(i)})})},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&&C(n.next)&&C(n.error)&&C(n.complete)}function vt(n){return n&&n instanceof ee||gt(n)&&Ee(n)}function O(n,t,e,r,s){return new yt(n,t,e,r,s)}var yt=function(n){W(t,n);function t(e,r,s,i,o,a){var c=n.call(this,e)||this;return c.onFinalize=o,c.shouldUnsubscribe=a,c._next=r?function(u){try{r(u)}catch(l){e.error(l)}}:n.prototype._next,c._error=i?function(u){try{i(u)}catch(l){e.error(l)}finally{this.unsubscribe()}}:n.prototype._error,c._complete=s?function(){try{s()}catch(u){e.error(u)}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}(ee);function p(n,t){return A(function(e,r){var s=0;e.subscribe(O(r,function(i){r.next(n.call(t,i,s++))}))})}var bt=new ft(function(n){return n.complete()});function w(n){return n<=0?function(){return bt}:A(function(t,e){var r=0;t.subscribe(O(e,function(s){++r<=n&&(e.next(s),n<=r&&e.complete())}))})}function g(n,t){return A(function(e,r){var s=0;e.subscribe(O(r,function(i){return n.call(t,i,s++)&&r.next(i)}))})}function mt(n,t){return t===void 0&&(t=!1),A(function(e,r){var s=0;e.subscribe(O(r,function(i){var o=n(i,s++);(o||t)&&r.next(i),!o&&r.complete()}))})}function f(n,t,e){var r=C(n)||t||e?{next:n,error:t,complete:e}:n;return r?A(function(s,i){var o;(o=r.subscribe)===null||o===void 0||o.call(r);var a=!0;s.subscribe(O(i,function(c){var u;(u=r.next)===null||u===void 0||u.call(r,c),i.next(c)},function(){var c;a=!1,(c=r.complete)===null||c===void 0||c.call(r),i.complete()},function(c){var u;a=!1,(u=r.error)===null||u===void 0||u.call(r,c),i.error(c)},function(){var c,u;a&&((c=r.unsubscribe)===null||c===void 0||c.call(r)),(u=r.finalize)===null||u===void 0||u.call(r)}))}):Ie}const wt=/^(\d+)\.(\d+)$/;function St(n){if(typeof n=="string"){const t=n.match(wt);if(t)return`${t[1]}.${t[2]}`}throw new rt(n)}function Re(n){const t=St(n),[e,r]=t.split("."),[s,i]=[parseInt(e),parseInt(r)];return[s,i]}function ne(n,t){const[e,r]=Re(n),[s,i]=Re(t);return e<s?-1:e>s?1:r<i?-1:r>i?1:0}function Et(n,t){return ne(n,t)===1}function Ct(n,t){return ne(n,t)>=0}const Pe="2.0";class Mt{constructor(t,e){if(I(this,"negotiatedProtocolVersion"),I(this,"currentContext"),I(this,"incomingMessages$"),I(this,"inIframe",!1),I(this,"embeddedResult"),I(this,"iframePort1"),I(this,"iframePort2"),this.supportedVersions=t,this.logService=e,this.incomingMessages$=new ge,this.supportedVersions=t.filter(r=>Ct(r,Pe)),!this.supportedVersions.length)throw new me(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,s;if(this.inIframe){if(!this.iframePort2)throw new be("port2");return this.iframePort2}else{if(!((e=(t=window.Acrobits)==null?void 0:t.messageChannel)!=null&&e.port2))throw new be("port2");return(s=(r=window.Acrobits)==null?void 0:r.messageChannel)==null?void 0:s.port2}}determineContext(){return Je(1e3).pipe(p(()=>(this.isEmbedded()?this.currentContext="user":this.currentContext="guest",this.currentContext)),w(1))}openBridge(){if(!this.isEmbedded())throw new h(this.currentContext);const t="HELLO",e=this.createMessage(t);e.protocolVersions=this.supportedVersions,this.logCreated(t,e);const r=this.incomingMessages$.pipe(g(s=>s.type===t&&s.replyTo===e.id),p(s=>s),f(this.logReceived(t)),p(s=>{if(this.supportedVersions.some(i=>Et(i,s.protocolVersion)))throw new me(s.protocolVersion,this.supportedVersions[0]);return s}),f(s=>{this.negotiatedProtocolVersion=s.protocolVersion,this.logService.info(`[IPC] Negotiated IPC Protocol Version: ${this.negotiatedProtocolVersion}`)}),w(1));return this.logService.debug(`Created ${t} Reply handler`),this.inIframe?this.createIframeChannel().then(()=>this.finishIpcSetup(e)):this.finishIpcSetup(e),r}requestSSOToken(){if(!this.isEmbedded())throw new h(this.currentContext);const t="TOKEN",e=this.createMessage(t);this.logCreated(t,e);const r=this.incomingMessages$.pipe(g(s=>s.type===t&&s.replyTo===e.id),p(s=>s),f(this.logReceived(t)),w(1));return this.logService.debug(`Created ${t} Reply handler`),this.port2.postMessage(e),this.logSent(t,e),r}sendJoiningRoomMessage(t){if(!this.isEmbedded())throw new h(this.currentContext);const{roomName:e,roomInvite:r,displayName:s,jwtToken:i,serverUrl:o,region:a,joinMicMuted:c,joinWithoutCamera:u}=t,l="JOINING ROOM",d=this.createMessage(l,!1);d.roomName=e,d.jwtToken=i,d.serverUrl=o,d.region=a,d.roomInvite=r,d.joinMicMuted=c??!1,d.joinWithoutCamera=u??!1,d.displayName=s,this.logCreated(l,d),this.port2.postMessage(d),this.logSent(l,d)}sendLeavingRoomMessage(t){if(!this.isEmbedded())throw new h(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 h(this.currentContext);const t="JOIN ROOM";return this.incomingMessages$.pipe(g(e=>e.type===t&&e.target==="client"),p(e=>e),f(this.logReceived(t)),p(e=>e))}onLeaveRoomMessage(){if(!this.isEmbedded())throw new h(this.currentContext);const t="LEAVE ROOM";return this.incomingMessages$.pipe(g(e=>e.type===t&&e.target==="client"),p(e=>e),f(this.logReceived(t)),p(e=>e))}onConfigMessage(){if(!this.isEmbedded())throw new h(this.currentContext);const t="CONFIG";return this.incomingMessages$.pipe(g(e=>e.type===t&&e.target==="client"),p(e=>e),f(this.logReceived(t)),p(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 h(this.currentContext);const e="SCREENSHARE SOURCE",r=this.createMessage(e);r.sourceTypes=t,this.logCreated(e,r);const s=this.incomingMessages$.pipe(g(i=>i.type===e&&i.replyTo===r.id),p(i=>i),f(this.logReceived(e)),p(i=>i),w(1));return this.logService.debug(`Created ${e} Reply handler`),this.port2.postMessage(r),this.logSent(e,r),s}layoutChange(t,e,r){if(!this.isEmbedded())throw new h(this.currentContext);const s="LAYOUT CHANGE";let i,o;if(e&&r?(i=this.createMessage(s,!1,r),i.result=e):(i=this.createMessage(s),o=this.incomingMessages$.pipe(g(a=>a.type===s&&a.replyTo===i.id),p(a=>a),f(this.logReceived(s)),p(a=>a),w(1)),this.logService.debug(`Created ${s} Reply handler`)),i.layout=t,this.logCreated(s,i),this.port2.postMessage(i),this.logSent(s,i),o)return o}onLayoutChangeMessage(){if(!this.isEmbedded())throw new h(this.currentContext);const t="LAYOUT CHANGE";return this.incomingMessages$.pipe(g(e=>e.type===t&&e.target==="client"&&e.replyTo===null),p(e=>e),f(this.logReceived(t)),p(e=>e))}requestOAuthToken(t){if(!this.isEmbedded())throw new h(this.currentContext);Array.isArray(t)||(t=[t]);const e="OAUTH TOKEN",r=this.createMessage(e);r.providerTypes=t,this.logCreated(e,r);const s=this.incomingMessages$.pipe(g(i=>i.type===e&&i.replyTo===r.id),p(i=>i),f(this.logReceived(e)),w(1));return this.logService.debug(`Created ${e} Reply handler`),this.port2.postMessage(r),this.logSent(e,r),s}openUrl(t,e){if(!this.isEmbedded())throw new h(this.currentContext);const r="OPEN URL",s=this.createMessage(r,!1);s.url=t,s.data=e,this.logCreated(r,s),this.port2.postMessage(s),this.logSent(r,s)}selectContacts(t,e,r,s){if(!this.isEmbedded())throw new h(this.currentContext);if(e==="group"&&s===void 0)throw new T("currentContacts",s,"currentContacts is required for group streams");if(e==="direct"&&s!==void 0)throw new T("currentContacts",s,"currentContacts should not be passed for direct streams");const i="SELECT CONTACTS",o=this.createMessage(i,!0);o.streamType=e,o.streamId=t,o.contactType=r,o.currentContacts=s,this.logCreated(i,o);const a=this.incomingMessages$.pipe(g(c=>c.type===i&&c.replyTo===o.id),f(this.logReceived(i)),p(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}),w(1));return this.logService.debug(`Created ${i} Reply handler`),this.port2.postMessage(o),this.logSent(i,o),a}matchContacts(t){if(!this.isEmbedded())throw new h(this.currentContext);if(!t.length)throw new T("contacts",t,"At least one contact is required");const e="MATCH CONTACTS",r=this.createMessage(e);r.contacts=[...t],this.logCreated(e,r);const s=this.incomingMessages$.pipe(g(i=>i.type===e&&i.replyTo===r.id),f(this.logReceived(e)),p(i=>i),w(1));return this.logService.debug(`Created ${e} Reply handler`),this.port2.postMessage(r),this.logSent(e,r),s}onPushMessageMessage(){if(!this.isEmbedded())throw new h(this.currentContext);const t="PUSH MESSAGE";return this.incomingMessages$.pipe(g(e=>e.type===t&&e.target==="client"),p(e=>e),f(this.logReceived(t)))}requestPushToken(){if(!this.isEmbedded())throw new h(this.currentContext);const t="PUSH TOKEN",e=this.createMessage(t);this.logCreated(t,e);const r=this.incomingMessages$.pipe(g(s=>s.type===t&&s.replyTo===e.id),f(this.logReceived(t)),p(s=>s),w(1));return this.logService.debug(`Created ${t} Reply handler`),this.port2.postMessage(e),this.logSent(t,e),r}onPushTokenMessage(){if(!this.isEmbedded())throw new h(this.currentContext);const t="PUSH TOKEN";return this.incomingMessages$.pipe(g(e=>e.type===t&&e.target==="client"&&e.replyTo===null&&e.expectReply===!1),p(e=>{if(e.pushToken&&e.selector&&e.appId)return e;throw new Error("PushTokenMessage is missing required PushTokenPayload fields")}),f(e=>e.pushToken),f(this.logReceived(t)))}onBadgeQueryMessage(){if(!this.isEmbedded())throw new h(this.currentContext);const t="BADGE QUERY";return this.incomingMessages$.pipe(g(e=>e.type===t&&e.target==="client"),p(e=>e),f(this.logReceived(t)))}sendBadgeUpdateMessage(t,e,r){if(!this.isEmbedded())throw new h(this.currentContext);const s="BADGE UPDATE",i=this.createMessage(s,!1,r);i.count=t,i.activity=e??!1,this.logCreated(s,i),this.port2.postMessage(i),this.logSent(s,i)}sendLifecycleMessage(t,e){if(!this.isEmbedded())throw new h(this.currentContext);const r="LIFECYCLE",s=this.createMessage(r,!1);s.eventName=t,s.payload=e,this.logCreated(r,s),this.port2.postMessage(s),this.logSent(r,s)}onLifecycleMessage(){if(!this.isEmbedded())throw new h(this.currentContext);const t="LIFECYCLE";return this.incomingMessages$.pipe(g(e=>e.type===t&&e.target==="client"),p(e=>e),f(this.logReceived(t)))}sendLogMessage(t,e){if(!this.isEmbedded())throw new h(this.currentContext);const r="LOG",s=this.createMessage(r,!1);s.level=t,s.message=e,this.logCreated(r,s),this.port2.postMessage(s),this.logSent(r,s)}onRequestLogsMessage(){if(!this.isEmbedded())throw new h(this.currentContext);const t="REQUEST LOGS";return this.incomingMessages$.pipe(g(e=>e.type===t&&e.target==="client"),p(e=>e),f(this.logReceived(t)))}sendViewTransitionMessage(t,e){if(!this.isEmbedded())throw new h(this.currentContext);const r="VIEW TRANSITION",s=this.createMessage(r,!1);s.transitionType=t,s.targetView=e,this.logCreated(r,s),this.port2.postMessage(s),this.logSent(r,s)}sendFileRequestMessage(t,e,r,s,i){if(!this.isEmbedded())throw new h(this.currentContext);const o="FILE REQUEST",a=this.createMessage(o);if(a.fileId=t,a.fileHash=e.toLowerCase(),a.intent=r,a.maxChunkSizeInBytes=i,r==="attachment"){if(!s)throw new T("streamId",s,"streamId is required for attachment intent");a.streamId=s}this.logCreated(o,a);let c=0;const u=this.incomingMessages$.pipe(g(l=>l.type===o&&l.replyTo===a.id),f(this.logReceived(o)),f(()=>c++),p(l=>(l.result==="success"&&(l.chunkHash=l.chunkHash.toLowerCase(),l.fileHash=l.fileHash.toLowerCase()),l)),mt(l=>l.result==="success"&&c<l.totalChunks,!0));return this.port2.postMessage(a),this.logSent(o,a),u}sendFileRequestMessageReply(t,e){if(!this.isEmbedded())throw new h(this.currentContext);const r="FILE REQUEST",s=Object.assign(e,this.createMessage(r,!1,t.id));this.logCreated(r,s),this.port2.postMessage(s),this.logSent(r,s)}onFileRequestMessage(){if(!this.isEmbedded())throw new h(this.currentContext);const t="FILE REQUEST";return this.incomingMessages$.pipe(g(e=>e.type===t&&e.target==="client"&&e.replyTo===null),p(e=>(e.fileHash=e.fileHash.toLowerCase(),e)),f(this.logReceived(t)))}sendFileSelectionMessage(t="attachment",e,r,s,i,o){if(!this.isEmbedded())throw new h(this.currentContext);const a="FILE SELECTION",c=this.createMessage(a);if(c.intent=t,c.maxCount=s,c.maxFileSizeInBytes=i,c.mimeTypes=o,t==="attachment"){if(!e)throw new T("streamId",e,"streamId is required for attachment intent");if(!r)throw new T("correlationId",r,"correlationId is required for attachment intent");c.streamId=e,c.correlationId=r}this.logCreated(a,c);const u=this.incomingMessages$.pipe(g(l=>l.type===a&&l.replyTo===c.id),p(l=>{var d;return l.files=(d=l.files)==null?void 0:d.map(b=>(b.original.fileHash=b.original.fileHash.toLowerCase(),b.preview&&(b.preview.fileHash=b.preview.fileHash.toLowerCase()),b)),l}),f(this.logReceived(a)),w(1));return this.port2.postMessage(c),this.logSent(a,c),u}sendFileDownloadMessage(t,e,r,s){if(!this.isEmbedded())throw new h(this.currentContext);const i="FILE DOWNLOAD",o=this.createMessage(i);o.url=t,o.key=e,o.fileName=r,o.mimeType=s,this.logCreated(i,o);const a=this.incomingMessages$.pipe(g(c=>c.type===i&&c.replyTo===o.id),f(this.logReceived(i)),p(c=>c),w(1));return this.port2.postMessage(o),this.logSent(i,o),a}sendFileDownloadProgressQueryMessage(t,e,r){if(!this.isEmbedded())throw new h(this.currentContext);const s="FILE DOWNLOAD PROGRESS QUERY",i=this.createMessage(s,!0);i.correlationId=t,i.fileHash=e.toLowerCase(),i.url=r,this.logCreated(s,i);const o=this.incomingMessages$.pipe(g(a=>a.type===s&&a.replyTo===i.id),f(this.logReceived(s)),p(a=>(a.fileHash&&(a.fileHash=a.fileHash.toLowerCase()),a)),w(1));return this.port2.postMessage(i),this.logSent(s,i),o}onFileDownloadProgressUpdateMessage(){if(!this.isEmbedded())throw new h(this.currentContext);const t="FILE DOWNLOAD PROGRESS UPDATE";return this.incomingMessages$.pipe(g(e=>e.type===t&&e.target==="client"&&e.replyTo===null),p(e=>(e.fileHash&&(e.fileHash=e.fileHash.toLowerCase()),e)),f(this.logReceived(t)))}sendFileUploadProgressQueryMessage(t,e,r){if(!this.isEmbedded())throw new h(this.currentContext);const s="FILE UPLOAD PROGRESS QUERY",i=this.createMessage(s,!0);i.correlationId=t,i.fileHash=e.toLowerCase(),i.fileId=r,this.logCreated(s,i);const o=this.incomingMessages$.pipe(g(a=>a.type===s&&a.replyTo===i.id),f(this.logReceived(s)),p(a=>(a.fileHash&&(a.fileHash=a.fileHash.toLowerCase()),a)),w(1));return this.port2.postMessage(i),this.logSent(s,i),o}onFileUploadProgressUpdateMessage(){if(!this.isEmbedded())throw new h(this.currentContext);const t="FILE UPLOAD PROGRESS UPDATE";return this.incomingMessages$.pipe(g(e=>e.type===t&&e.target==="client"&&e.replyTo===null),p(e=>(e.fileHash&&(e.fileHash=e.fileHash.toLowerCase()),e)),f(this.logReceived(t)))}sendFileOpenMessage(t,e,r,s,i,o,a){if(!this.isEmbedded())throw new h(this.currentContext);const c="FILE OPEN",u=this.createMessage(c,!0);u.fileHash=t.toLowerCase(),u.fileName=e,u.streamId=r,u.url=s,u.correlationId=i,u.key=o,u.sender=a,this.logCreated(c,u);const l=this.incomingMessages$.pipe(g(d=>d.type===c&&d.replyTo===u.id),f(this.logReceived(c)),p(d=>d),w(1));return this.port2.postMessage(u),this.logSent(c,u),l}sendCancelFileOpenMessage(t,e,r){if(!this.isEmbedded())throw new h(this.currentContext);const s="CANCEL FILE OPEN",i=this.createMessage(s,!1);i.correlationId=t,i.fileHash=e.toLowerCase(),i.url=r,this.logCreated(s,i),this.port2.postMessage(i),this.logSent(s,i)}sendFileRemoveMessage(t,e){if(!this.isEmbedded())throw new h(this.currentContext);const r="FILE REMOVE",s=this.createMessage(r,!0);s.hash=t.toLowerCase(),s.streamId=e,this.logCreated(r,s);const i=this.incomingMessages$.pipe(g(o=>o.type===r&&o.replyTo===s.id),f(this.logReceived(r)),p(o=>o),w(1));return this.port2.postMessage(s),this.logSent(r,s),i}sendAppResetMessage(){if(!this.isEmbedded())throw new h(this.currentContext);const t="APP RESET",e=this.createMessage(t,!1);this.logCreated(t,e),this.port2.postMessage(e),this.logSent(t,e)}sendMessageSentMessage(t,e){if(!this.isEmbedded())throw new h(this.currentContext);const r="MESSAGE SENT",s=this.createMessage(r,!1);s.streamId=t,s.correlationId=e,this.logCreated(r,s),this.port2.postMessage(s),this.logSent(r,s)}sendSendMessageMessage(t,e,r,s="TEXT",i,o,a,c=!0,u){if(!this.isEmbedded())throw new h(this.currentContext);const l="SEND MESSAGE",d=this.createMessage(l,!0);d.streamId=t,d.correlationId=e,d.body=r,d.messageType=s,d.mentions=i??[],d.attachments=(o==null?void 0:o.map(m=>m.toLowerCase()))??[],d.relatedMessageId=a,d.setCursors=c,d.threadId=u,this.logCreated(l,d);const b=this.incomingMessages$.pipe(g(m=>m.type===l&&m.replyTo===d.id),f(this.logReceived(l)),p(m=>m),w(1));return this.port2.postMessage(d),this.logSent(l,d),b}sendCancelSendMessageMessage(t,e){if(!this.isEmbedded())throw new h(this.currentContext);const r="CANCEL SEND MESSAGE",s=this.createMessage(r,!1);s.streamId=t,s.correlationId=e,this.logCreated(r,s),this.port2.postMessage(s),this.logSent(r,s)}sendMessageDeletedMessage(t,e){if(!this.isEmbedded())throw new h(this.currentContext);const r="MESSAGE DELETED",s=this.createMessage(r,!1);s.correlationId=t,s.streamId=e,this.logCreated(r,s),this.port2.postMessage(s),this.logSent(r,s)}sendSendMessageStatusQueryMessage(t,e){if(!this.isEmbedded())throw new h(this.currentContext);const r="SEND MESSAGE STATUS QUERY",s=this.createMessage(r,!0);s.correlationId=t,s.streamId=e,this.logCreated(r,s);const i=this.incomingMessages$.pipe(g(o=>o.type===r&&o.replyTo===s.id),f(this.logReceived(r)),p(o=>o),w(1));return this.port2.postMessage(s),this.logSent(r,s),i}onSendMessageStatusUpdateMessage(){if(!this.isEmbedded())throw new h(this.currentContext);const t="SEND MESSAGE STATUS UPDATE";return this.incomingMessages$.pipe(g(e=>e.type===t&&e.target==="client"&&e.replyTo===null),p(e=>e),f(this.logReceived(t)))}sendSipCallMessage(t){if(!this.isEmbedded())throw new h(this.currentContext);const e="SIP CALL",r=this.createMessage(e,!1);r.contact=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 ne(this.negotiatedProtocolVersion,t)}logReceived(t,e){e&&xt(e)&&(e={...e,data:"..."});const r=s=>this.logService.debug(`[IPC] Received ${t} message`,s);return e&&r(e),r}logSent(t,e){e.type==="FILE REQUEST"&&e.result==="success"&&(e={...e,data:"..."}),this.logService.debug(`[IPC] Sent ${t} message`,e)}logCreated(t,e){e.type==="FILE REQUEST"&&e.result==="success"&&(e={...e,data:"..."}),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 s=[];e&&(r=r.substr(0,r.indexOf("Q")));for(let i=0;i<t;i++)s.push(r[Math.floor(Math.random()*r.length)]);return s.join("")}}function xt(n){return n.type==="FILE REQUEST"&&n.replyTo!==null}const It=["2.0"];class Tt{constructor(t){R(this,"host");R(this,"cloudId");R(this,"cloudUsername");R(this,"logger");R(this,"helper");R(this,"listeners");this.logger=t??console,this.helper=new Mt(It,this.logger),this.listeners=new Map,this.listeners.set(v.BadgeQuery,new Set),this.listeners.set(v.Lifecycle,new Set),this.listeners.set(v.PushToken,new Set)}get context(){return this.evaluateContext(this.helper.currentContext)}get isConnected(){return!!(this.helper.currentContext==="user"&&this.host&&this.cloudId)}get negotiatedVersion(){return this.helper.negotiatedProtocolVersion}async determineContext(){const t=await _(this.helper.determineContext(),{defaultValue:"guest"});return this.evaluateContext(t)}initiateConnection(){return _(this.helper.openBridge().pipe(Xe(t=>{this.helper.onBadgeQueryMessage().subscribe(e=>{var r;this.logger.debug("Received Badge Query: ",e);for(const s of((r=this.listeners.get(v.BadgeQuery))==null?void 0:r.values())??[])s()}),this.helper.onLifecycleMessage().subscribe(e=>{var r;this.logger.debug("Received Lifecycle Event: ",e);for(const s of((r=this.listeners.get(v.Lifecycle))==null?void 0:r.values())??[])s(e.eventName,e.payload)}),this.helper.onPushTokenMessage().subscribe(e=>{var r;this.logger.debug("Received Push Token: ",e);for(const s of((r=this.listeners.get(v.PushToken))==null?void 0:r.values())??[])s(e.pushToken,e.appId,e.selector)}),this.cloudId=t.cloudId,this.cloudUsername=t.cloudUsername,this.host=t.host}),H(()=>{})))}selectContacts(t,e,r,s){this.logger.debug("Selecting Contacts: ",...arguments);let i;if(e==="multi"){if(!r||!Array.isArray(r))throw new T("currentContacts",r,"currentContacts is required for group streams");s||(s="cloudUsername"),i=this.helper.selectContacts(t.toString(),"group",s,r)}else r?s=r:s="cloudUsername",i=this.helper.selectContacts(t.toString(),"direct",s);return _(i.pipe(H(o=>o.contacts)))}matchContacts(t){return this.logger.debug("Match Contacts: ",t),_(this.helper.matchContacts(t).pipe(H(e=>e.contacts)))}requestPushToken(){return this.logger.debug("Requesting Push Token"),_(this.helper.requestPushToken().pipe(H(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()}openUrl(t,e){this.logger.debug("Opening URL: ",t),this.helper.openUrl(t,e)}sipCall(t){this.logger.debug("Initiating SIP Call: ",t),this.helper.sendSipCallMessage(t)}onBadgeQueryRequest(t){var e;return this.logger.debug("Registering for Badge Query"),(e=this.listeners.get(v.BadgeQuery))==null||e.add(t),()=>{var r;return(r=this.listeners.get(v.BadgeQuery))==null?void 0:r.delete(t)}}onLifecycleEvent(t){var e;return this.logger.debug("Registering for Lifecycle Event"),(e=this.listeners.get(v.Lifecycle))==null||e.add(t),()=>{var r;return(r=this.listeners.get(v.Lifecycle))==null?void 0:r.delete(t)}}onPushToken(t){var e;return this.logger.debug("Registering for Push Token"),(e=this.listeners.get(v.PushToken))==null||e.add(t),()=>{var r;return(r=this.listeners.get(v.PushToken))==null?void 0:r.delete(t)}}evaluateContext(t){if(t==="user")return"host";if(t==="guest")return"standalone"}}S.IPCEvents=v,S.IPCManager=Tt,Object.defineProperty(S,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 Z=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,s,i;if(!this.closed){this.closed=!0;var o=this._parentage;if(o)if(this._parentage=null,Array.isArray(o))try{for(var a=we(o),c=a.next();!c.done;c=a.next()){var u=c.value;u.remove(this)}}catch(y){t={error:y}}finally{try{c&&!c.done&&(e=a.return)&&e.call(a)}finally{if(t)throw t.error}}else o.remove(this);var l=this.initialTeardown;if(C(l))try{l()}catch(y){i=y instanceof X?y.errors:[y]}var d=this._finalizers;if(d){this._finalizers=null;try{for(var b=we(d),m=b.next();!m.done;m=b.next()){var se=m.value;try{Ce(se)}catch(y){i=i??[],y instanceof X?i=J(J([],K(i)),K(y.errors)):i.push(y)}}}catch(y){r={error:y}}finally{try{m&&!m.done&&(s=b.return)&&s.call(b)}finally{if(r)throw r.error}}}if(i)throw new X(i)}},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)&&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}();Z.EMPTY;function Se(n){return n instanceof Z||n&&"closed"in n&&C(n.remove)&&C(n.add)&&C(n.unsubscribe)}function Ce(n){C(n)?n():n.unsubscribe()}var Me={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},it={setTimeout:function(n,t){for(var e=[],r=2;r<arguments.length;r++)e[r-2]=arguments[r];return setTimeout.apply(void 0,J([n,t],K(e)))},clearTimeout:function(n){return clearTimeout(n)},delegate:void 0};function ot(n){it.setTimeout(function(){throw n})}function xe(){}function at(n){n()}var ee=function(n){W(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=ht,r}return t.create=function(e,r,s){return new re(e,r,s)},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}(Z),ct=Function.prototype.bind;function te(n,t){return ct.call(n,t)}var ut=function(){function n(t){this.partialObserver=t}return n.prototype.next=function(t){var e=this.partialObserver;if(e.next)try{e.next(t)}catch(r){N(r)}},n.prototype.error=function(t){var e=this.partialObserver;if(e.error)try{e.error(t)}catch(r){N(r)}else N(t)},n.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(e){N(e)}},n}(),re=function(n){W(t,n);function t(e,r,s){var i=n.call(this)||this,o;if(C(e)||!e)o={next:e??void 0,error:r??void 0,complete:s??void 0};else{var a;i&&Me.useDeprecatedNextContext?(a=Object.create(e),a.unsubscribe=function(){return i.unsubscribe()},o={next:e.next&&te(e.next,a),error:e.error&&te(e.error,a),complete:e.complete&&te(e.complete,a)}):o=e}return i.destination=new ut(o),i}return t}(ee);function N(n){ot(n)}function lt(n){throw n}var ht={closed:!0,next:xe,error:lt,complete:xe},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 s=this,i=vt(t)?t:new re(t,e,r);return at(function(){var o=s,a=o.operator,c=o.source;i.add(a?a.call(i,c):c?s._subscribe(i):s._trySubscribe(i))}),i},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(s,i){var o=new re({next:function(a){try{t(a)}catch(c){i(c),o.unsubscribe()}},error:i,complete:s});r.subscribe(o)})},n.prototype._subscribe=function(t){var e;return(e=this.source)===null||e===void 0?void 0:e.subscribe(t)},n.prototype[dt]=function(){return this},n.prototype.pipe=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return pt(t)(this)},n.prototype.toPromise=function(t){var e=this;return t=Te(t),new t(function(r,s){var i;e.subscribe(function(o){return i=o},function(o){return s(o)},function(){return r(i)})})},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&&C(n.next)&&C(n.error)&&C(n.complete)}function vt(n){return n&&n instanceof ee||gt(n)&&Se(n)}function O(n,t,e,r,s){return new yt(n,t,e,r,s)}var yt=function(n){W(t,n);function t(e,r,s,i,o,a){var c=n.call(this,e)||this;return c.onFinalize=o,c.shouldUnsubscribe=a,c._next=r?function(u){try{r(u)}catch(l){e.error(l)}}:n.prototype._next,c._error=i?function(u){try{i(u)}catch(l){e.error(l)}finally{this.unsubscribe()}}:n.prototype._error,c._complete=s?function(){try{s()}catch(u){e.error(u)}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}(ee);function p(n,t){return A(function(e,r){var s=0;e.subscribe(O(r,function(i){r.next(n.call(t,i,s++))}))})}var bt=new ft(function(n){return n.complete()});function w(n){return n<=0?function(){return bt}:A(function(t,e){var r=0;t.subscribe(O(e,function(s){++r<=n&&(e.next(s),n<=r&&e.complete())}))})}function g(n,t){return A(function(e,r){var s=0;e.subscribe(O(r,function(i){return n.call(t,i,s++)&&r.next(i)}))})}function mt(n,t){return t===void 0&&(t=!1),A(function(e,r){var s=0;e.subscribe(O(r,function(i){var o=n(i,s++);(o||t)&&r.next(i),!o&&r.complete()}))})}function f(n,t,e){var r=C(n)||t||e?{next:n,error:t,complete:e}:n;return r?A(function(s,i){var o;(o=r.subscribe)===null||o===void 0||o.call(r);var a=!0;s.subscribe(O(i,function(c){var u;(u=r.next)===null||u===void 0||u.call(r,c),i.next(c)},function(){var c;a=!1,(c=r.complete)===null||c===void 0||c.call(r),i.complete()},function(c){var u;a=!1,(u=r.error)===null||u===void 0||u.call(r,c),i.error(c)},function(){var c,u;a&&((c=r.unsubscribe)===null||c===void 0||c.call(r)),(u=r.finalize)===null||u===void 0||u.call(r)}))}):Ie}const wt=/^(\d+)\.(\d+)$/;function Et(n){if(typeof n=="string"){const t=n.match(wt);if(t)return`${t[1]}.${t[2]}`}throw new rt(n)}function Re(n){const t=Et(n),[e,r]=t.split("."),[s,i]=[parseInt(e),parseInt(r)];return[s,i]}function ne(n,t){const[e,r]=Re(n),[s,i]=Re(t);return e<s?-1:e>s?1:r<i?-1:r>i?1:0}function St(n,t){return ne(n,t)===1}function Ct(n,t){return ne(n,t)>=0}const Pe="2.0";class Mt{constructor(t,e){if(I(this,"negotiatedProtocolVersion"),I(this,"currentContext"),I(this,"incomingMessages$"),I(this,"inIframe",!1),I(this,"embeddedResult"),I(this,"iframePort1"),I(this,"iframePort2"),this.supportedVersions=t,this.logService=e,this.incomingMessages$=new ge,this.supportedVersions=t.filter(r=>Ct(r,Pe)),!this.supportedVersions.length)throw new me(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,s;if(this.inIframe){if(!this.iframePort2)throw new be("port2");return this.iframePort2}else{if(!((e=(t=window.Acrobits)==null?void 0:t.messageChannel)!=null&&e.port2))throw new be("port2");return(s=(r=window.Acrobits)==null?void 0:r.messageChannel)==null?void 0:s.port2}}determineContext(){return Je(1e3).pipe(p(()=>(this.isEmbedded()?this.currentContext="user":this.currentContext="guest",this.currentContext)),w(1))}openBridge(){if(!this.isEmbedded())throw new h(this.currentContext);const t="HELLO",e=this.createMessage(t);e.protocolVersions=this.supportedVersions,this.logCreated(t,e);const r=this.incomingMessages$.pipe(g(s=>s.type===t&&s.replyTo===e.id),p(s=>s),f(this.logReceived(t)),p(s=>{if(this.supportedVersions.some(i=>St(i,s.protocolVersion)))throw new me(s.protocolVersion,this.supportedVersions[0]);return s}),f(s=>{this.negotiatedProtocolVersion=s.protocolVersion,this.logService.info(`[IPC] Negotiated IPC Protocol Version: ${this.negotiatedProtocolVersion}`)}),w(1));return this.logService.debug(`Created ${t} Reply handler`),this.inIframe?this.createIframeChannel().then(()=>this.finishIpcSetup(e)):this.finishIpcSetup(e),r}requestSSOToken(){if(!this.isEmbedded())throw new h(this.currentContext);const t="TOKEN",e=this.createMessage(t);this.logCreated(t,e);const r=this.incomingMessages$.pipe(g(s=>s.type===t&&s.replyTo===e.id),p(s=>s),f(this.logReceived(t)),w(1));return this.logService.debug(`Created ${t} Reply handler`),this.port2.postMessage(e),this.logSent(t,e),r}sendJoiningRoomMessage(t){if(!this.isEmbedded())throw new h(this.currentContext);const{roomName:e,roomInvite:r,displayName:s,jwtToken:i,serverUrl:o,region:a,joinMicMuted:c,joinWithoutCamera:u}=t,l="JOINING ROOM",d=this.createMessage(l,!1);d.roomName=e,d.jwtToken=i,d.serverUrl=o,d.region=a,d.roomInvite=r,d.joinMicMuted=c??!1,d.joinWithoutCamera=u??!1,d.displayName=s,this.logCreated(l,d),this.port2.postMessage(d),this.logSent(l,d)}sendLeavingRoomMessage(t){if(!this.isEmbedded())throw new h(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 h(this.currentContext);const t="JOIN ROOM";return this.incomingMessages$.pipe(g(e=>e.type===t&&e.target==="client"),p(e=>e),f(this.logReceived(t)),p(e=>e))}onLeaveRoomMessage(){if(!this.isEmbedded())throw new h(this.currentContext);const t="LEAVE ROOM";return this.incomingMessages$.pipe(g(e=>e.type===t&&e.target==="client"),p(e=>e),f(this.logReceived(t)),p(e=>e))}onConfigMessage(){if(!this.isEmbedded())throw new h(this.currentContext);const t="CONFIG";return this.incomingMessages$.pipe(g(e=>e.type===t&&e.target==="client"),p(e=>e),f(this.logReceived(t)),p(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 h(this.currentContext);const e="SCREENSHARE SOURCE",r=this.createMessage(e);r.sourceTypes=t,this.logCreated(e,r);const s=this.incomingMessages$.pipe(g(i=>i.type===e&&i.replyTo===r.id),p(i=>i),f(this.logReceived(e)),p(i=>i),w(1));return this.logService.debug(`Created ${e} Reply handler`),this.port2.postMessage(r),this.logSent(e,r),s}layoutChange(t,e,r){if(!this.isEmbedded())throw new h(this.currentContext);const s="LAYOUT CHANGE";let i,o;if(e&&r?(i=this.createMessage(s,!1,r),i.result=e):(i=this.createMessage(s),o=this.incomingMessages$.pipe(g(a=>a.type===s&&a.replyTo===i.id),p(a=>a),f(this.logReceived(s)),p(a=>a),w(1)),this.logService.debug(`Created ${s} Reply handler`)),i.layout=t,this.logCreated(s,i),this.port2.postMessage(i),this.logSent(s,i),o)return o}onLayoutChangeMessage(){if(!this.isEmbedded())throw new h(this.currentContext);const t="LAYOUT CHANGE";return this.incomingMessages$.pipe(g(e=>e.type===t&&e.target==="client"&&e.replyTo===null),p(e=>e),f(this.logReceived(t)),p(e=>e))}requestOAuthToken(t){if(!this.isEmbedded())throw new h(this.currentContext);Array.isArray(t)||(t=[t]);const e="OAUTH TOKEN",r=this.createMessage(e);r.providerTypes=t,this.logCreated(e,r);const s=this.incomingMessages$.pipe(g(i=>i.type===e&&i.replyTo===r.id),p(i=>i),f(this.logReceived(e)),w(1));return this.logService.debug(`Created ${e} Reply handler`),this.port2.postMessage(r),this.logSent(e,r),s}openUrl(t,e){if(!this.isEmbedded())throw new h(this.currentContext);const r="OPEN URL",s=this.createMessage(r,!1);s.url=t,s.data=e,this.logCreated(r,s),this.port2.postMessage(s),this.logSent(r,s)}selectContacts(t,e,r,s){if(!this.isEmbedded())throw new h(this.currentContext);if(e==="group"&&s===void 0)throw new T("currentContacts",s,"currentContacts is required for group streams");if(e==="direct"&&s!==void 0)throw new T("currentContacts",s,"currentContacts should not be passed for direct streams");const i="SELECT CONTACTS",o=this.createMessage(i,!0);o.streamType=e,o.streamId=t,o.contactType=r,o.currentContacts=s,this.logCreated(i,o);const a=this.incomingMessages$.pipe(g(c=>c.type===i&&c.replyTo===o.id),f(this.logReceived(i)),p(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}),w(1));return this.logService.debug(`Created ${i} Reply handler`),this.port2.postMessage(o),this.logSent(i,o),a}matchContacts(t){if(!this.isEmbedded())throw new h(this.currentContext);if(!t.length)throw new T("contacts",t,"At least one contact is required");const e="MATCH CONTACTS",r=this.createMessage(e);r.contacts=[...t],this.logCreated(e,r);const s=this.incomingMessages$.pipe(g(i=>i.type===e&&i.replyTo===r.id),f(this.logReceived(e)),p(i=>i),w(1));return this.logService.debug(`Created ${e} Reply handler`),this.port2.postMessage(r),this.logSent(e,r),s}onPushMessageMessage(){if(!this.isEmbedded())throw new h(this.currentContext);const t="PUSH MESSAGE";return this.incomingMessages$.pipe(g(e=>e.type===t&&e.target==="client"),p(e=>e),f(this.logReceived(t)))}requestPushToken(){if(!this.isEmbedded())throw new h(this.currentContext);const t="PUSH TOKEN",e=this.createMessage(t);this.logCreated(t,e);const r=this.incomingMessages$.pipe(g(s=>s.type===t&&s.replyTo===e.id),f(this.logReceived(t)),p(s=>s),w(1));return this.logService.debug(`Created ${t} Reply handler`),this.port2.postMessage(e),this.logSent(t,e),r}onPushTokenMessage(){if(!this.isEmbedded())throw new h(this.currentContext);const t="PUSH TOKEN";return this.incomingMessages$.pipe(g(e=>e.type===t&&e.target==="client"&&e.replyTo===null&&e.expectReply===!1),p(e=>{if(e.pushToken&&e.selector&&e.appId)return e;throw new Error("PushTokenMessage is missing required PushTokenPayload fields")}),f(e=>e.pushToken),f(this.logReceived(t)))}onBadgeQueryMessage(){if(!this.isEmbedded())throw new h(this.currentContext);const t="BADGE QUERY";return this.incomingMessages$.pipe(g(e=>e.type===t&&e.target==="client"),p(e=>e),f(this.logReceived(t)))}sendBadgeUpdateMessage(t,e,r){if(!this.isEmbedded())throw new h(this.currentContext);const s="BADGE UPDATE",i=this.createMessage(s,!1,r);i.count=t,i.activity=e??!1,this.logCreated(s,i),this.port2.postMessage(i),this.logSent(s,i)}sendLifecycleMessage(t,e){if(!this.isEmbedded())throw new h(this.currentContext);const r="LIFECYCLE",s=this.createMessage(r,!1);s.eventName=t,s.payload=e,this.logCreated(r,s),this.port2.postMessage(s),this.logSent(r,s)}onLifecycleMessage(){if(!this.isEmbedded())throw new h(this.currentContext);const t="LIFECYCLE";return this.incomingMessages$.pipe(g(e=>e.type===t&&e.target==="client"),p(e=>e),f(this.logReceived(t)))}sendLogMessage(t,e){if(!this.isEmbedded())throw new h(this.currentContext);const r="LOG",s=this.createMessage(r,!1);s.level=t,s.message=e,this.logCreated(r,s),this.port2.postMessage(s),this.logSent(r,s)}onRequestLogsMessage(){if(!this.isEmbedded())throw new h(this.currentContext);const t="REQUEST LOGS";return this.incomingMessages$.pipe(g(e=>e.type===t&&e.target==="client"),p(e=>e),f(this.logReceived(t)))}sendViewTransitionMessage(t,e){if(!this.isEmbedded())throw new h(this.currentContext);const r="VIEW TRANSITION",s=this.createMessage(r,!1);s.transitionType=t,s.targetView=e,this.logCreated(r,s),this.port2.postMessage(s),this.logSent(r,s)}sendFileRequestMessage(t,e,r,s,i){if(!this.isEmbedded())throw new h(this.currentContext);const o="FILE REQUEST",a=this.createMessage(o);if(a.fileId=t,a.fileHash=e.toLowerCase(),a.intent=r,a.maxChunkSizeInBytes=i,r==="attachment"){if(!s)throw new T("streamId",s,"streamId is required for attachment intent");a.streamId=s}this.logCreated(o,a);let c=0;const u=this.incomingMessages$.pipe(g(l=>l.type===o&&l.replyTo===a.id),f(this.logReceived(o)),f(()=>c++),p(l=>(l.result==="success"&&(l.chunkHash=l.chunkHash.toLowerCase(),l.fileHash=l.fileHash.toLowerCase()),l)),mt(l=>l.result==="success"&&c<l.totalChunks,!0));return this.port2.postMessage(a),this.logSent(o,a),u}sendFileRequestMessageReply(t,e){if(!this.isEmbedded())throw new h(this.currentContext);const r="FILE REQUEST",s=Object.assign(e,this.createMessage(r,!1,t.id));this.logCreated(r,s),this.port2.postMessage(s),this.logSent(r,s)}onFileRequestMessage(){if(!this.isEmbedded())throw new h(this.currentContext);const t="FILE REQUEST";return this.incomingMessages$.pipe(g(e=>e.type===t&&e.target==="client"&&e.replyTo===null),p(e=>(e.fileHash=e.fileHash.toLowerCase(),e)),f(this.logReceived(t)))}sendFileSelectionMessage(t="attachment",e,r,s,i,o){if(!this.isEmbedded())throw new h(this.currentContext);const a="FILE SELECTION",c=this.createMessage(a);if(c.intent=t,c.maxCount=s,c.maxFileSizeInBytes=i,c.mimeTypes=o,t==="attachment"){if(!e)throw new T("streamId",e,"streamId is required for attachment intent");if(!r)throw new T("correlationId",r,"correlationId is required for attachment intent");c.streamId=e,c.correlationId=r}this.logCreated(a,c);const u=this.incomingMessages$.pipe(g(l=>l.type===a&&l.replyTo===c.id),p(l=>{var d;return l.files=(d=l.files)==null?void 0:d.map(b=>(b.original.fileHash=b.original.fileHash.toLowerCase(),b.preview&&(b.preview.fileHash=b.preview.fileHash.toLowerCase()),b)),l}),f(this.logReceived(a)),w(1));return this.port2.postMessage(c),this.logSent(a,c),u}sendFileDownloadMessage(t,e,r,s){if(!this.isEmbedded())throw new h(this.currentContext);const i="FILE DOWNLOAD",o=this.createMessage(i);o.url=t,o.key=e,o.fileName=r,o.mimeType=s,this.logCreated(i,o);const a=this.incomingMessages$.pipe(g(c=>c.type===i&&c.replyTo===o.id),f(this.logReceived(i)),p(c=>c),w(1));return this.port2.postMessage(o),this.logSent(i,o),a}sendFileDownloadProgressQueryMessage(t,e,r){if(!this.isEmbedded())throw new h(this.currentContext);const s="FILE DOWNLOAD PROGRESS QUERY",i=this.createMessage(s,!0);i.correlationId=t,i.fileHash=e.toLowerCase(),i.url=r,this.logCreated(s,i);const o=this.incomingMessages$.pipe(g(a=>a.type==="FILE DOWNLOAD PROGRESS UPDATE"&&a.replyTo===i.id),f(this.logReceived(s)),p(a=>(a.fileHash&&(a.fileHash=a.fileHash.toLowerCase()),a)),w(1));return this.port2.postMessage(i),this.logSent(s,i),o}onFileDownloadProgressUpdateMessage(){if(!this.isEmbedded())throw new h(this.currentContext);const t="FILE DOWNLOAD PROGRESS UPDATE";return this.incomingMessages$.pipe(g(e=>e.type===t&&e.target==="client"&&e.replyTo===null),p(e=>(e.fileHash&&(e.fileHash=e.fileHash.toLowerCase()),e)),f(this.logReceived(t)))}sendFileUploadProgressQueryMessage(t,e,r){if(!this.isEmbedded())throw new h(this.currentContext);const s="FILE UPLOAD PROGRESS QUERY",i=this.createMessage(s,!0);i.correlationId=t,i.fileHash=e.toLowerCase(),i.fileId=r,this.logCreated(s,i);const o=this.incomingMessages$.pipe(g(a=>a.type==="FILE UPLOAD PROGRESS UPDATE"&&a.replyTo===i.id),f(this.logReceived(s)),p(a=>(a.fileHash&&(a.fileHash=a.fileHash.toLowerCase()),a)),w(1));return this.port2.postMessage(i),this.logSent(s,i),o}onFileUploadProgressUpdateMessage(){if(!this.isEmbedded())throw new h(this.currentContext);const t="FILE UPLOAD PROGRESS UPDATE";return this.incomingMessages$.pipe(g(e=>e.type===t&&e.target==="client"&&e.replyTo===null),p(e=>(e.fileHash&&(e.fileHash=e.fileHash.toLowerCase()),e)),f(this.logReceived(t)))}sendFileOpenMessage(t,e,r,s,i,o,a){if(!this.isEmbedded())throw new h(this.currentContext);const c="FILE OPEN",u=this.createMessage(c,!0);u.fileHash=t.toLowerCase(),u.fileName=e,u.streamId=r,u.url=s,u.correlationId=i,u.key=o,u.sender=a,this.logCreated(c,u);const l=this.incomingMessages$.pipe(g(d=>d.type===c&&d.replyTo===u.id),f(this.logReceived(c)),p(d=>d),w(1));return this.port2.postMessage(u),this.logSent(c,u),l}sendCancelFileOpenMessage(t,e,r){if(!this.isEmbedded())throw new h(this.currentContext);const s="CANCEL FILE OPEN",i=this.createMessage(s,!1);i.correlationId=t,i.fileHash=e.toLowerCase(),i.url=r,this.logCreated(s,i),this.port2.postMessage(i),this.logSent(s,i)}sendFileRemoveMessage(t,e){if(!this.isEmbedded())throw new h(this.currentContext);const r="FILE REMOVE",s=this.createMessage(r,!0);s.hash=t.toLowerCase(),s.streamId=e,this.logCreated(r,s);const i=this.incomingMessages$.pipe(g(o=>o.type===r&&o.replyTo===s.id),f(this.logReceived(r)),p(o=>o),w(1));return this.port2.postMessage(s),this.logSent(r,s),i}sendAppResetMessage(){if(!this.isEmbedded())throw new h(this.currentContext);const t="APP RESET",e=this.createMessage(t,!1);this.logCreated(t,e),this.port2.postMessage(e),this.logSent(t,e)}sendMessageSentMessage(t,e){if(!this.isEmbedded())throw new h(this.currentContext);const r="MESSAGE SENT",s=this.createMessage(r,!1);s.streamId=t,s.correlationId=e,this.logCreated(r,s),this.port2.postMessage(s),this.logSent(r,s)}sendSendMessageMessage(t,e,r,s="TEXT",i,o,a,c=!0,u){if(!this.isEmbedded())throw new h(this.currentContext);const l="SEND MESSAGE",d=this.createMessage(l,!0);d.streamId=t,d.correlationId=e,d.body=r,d.messageType=s,d.mentions=i??[],d.attachments=(o==null?void 0:o.map(m=>m.toLowerCase()))??[],d.relatedMessageId=a,d.setCursors=c,d.threadId=u,this.logCreated(l,d);const b=this.incomingMessages$.pipe(g(m=>m.type===l&&m.replyTo===d.id),f(this.logReceived(l)),p(m=>m),w(1));return this.port2.postMessage(d),this.logSent(l,d),b}sendCancelSendMessageMessage(t,e){if(!this.isEmbedded())throw new h(this.currentContext);const r="CANCEL SEND MESSAGE",s=this.createMessage(r,!1);s.streamId=t,s.correlationId=e,this.logCreated(r,s),this.port2.postMessage(s),this.logSent(r,s)}sendMessageDeletedMessage(t,e){if(!this.isEmbedded())throw new h(this.currentContext);const r="MESSAGE DELETED",s=this.createMessage(r,!1);s.correlationId=t,s.streamId=e,this.logCreated(r,s),this.port2.postMessage(s),this.logSent(r,s)}sendSendMessageStatusQueryMessage(t,e){if(!this.isEmbedded())throw new h(this.currentContext);const r="SEND MESSAGE STATUS QUERY",s=this.createMessage(r,!0);s.correlationId=t,s.streamId=e,this.logCreated(r,s);const i=this.incomingMessages$.pipe(g(o=>o.type==="SEND MESSAGE STATUS UPDATE"&&o.replyTo===s.id),f(this.logReceived(r)),p(o=>o),w(1));return this.port2.postMessage(s),this.logSent(r,s),i}onSendMessageStatusUpdateMessage(){if(!this.isEmbedded())throw new h(this.currentContext);const t="SEND MESSAGE STATUS UPDATE";return this.incomingMessages$.pipe(g(e=>e.type===t&&e.target==="client"&&e.replyTo===null),p(e=>e),f(this.logReceived(t)))}sendSipCallMessage(t){if(!this.isEmbedded())throw new h(this.currentContext);const e="SIP CALL",r=this.createMessage(e,!1);r.contact=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 ne(this.negotiatedProtocolVersion,t)}logReceived(t,e){e&&xt(e)&&(e={...e,data:"..."});const r=s=>this.logService.debug(`[IPC] Received ${t} message`,s);return e&&r(e),r}logSent(t,e){e.type==="FILE REQUEST"&&e.result==="success"&&(e={...e,data:"..."}),this.logService.debug(`[IPC] Sent ${t} message`,e)}logCreated(t,e){e.type==="FILE REQUEST"&&e.result==="success"&&(e={...e,data:"..."}),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 s=[];e&&(r=r.substr(0,r.indexOf("Q")));for(let i=0;i<t;i++)s.push(r[Math.floor(Math.random()*r.length)]);return s.join("")}}function xt(n){return n.type==="FILE REQUEST"&&n.replyTo!==null}const It=["2.0"];class Tt{constructor(t){R(this,"host");R(this,"cloudId");R(this,"cloudUsername");R(this,"logger");R(this,"helper");R(this,"listeners");this.logger=t??console,this.helper=new Mt(It,this.logger),this.listeners=new Map,this.listeners.set(v.BadgeQuery,new Set),this.listeners.set(v.Lifecycle,new Set),this.listeners.set(v.PushToken,new Set)}get context(){return this.evaluateContext(this.helper.currentContext)}get isConnected(){return!!(this.helper.currentContext==="user"&&this.host&&this.cloudId)}get negotiatedVersion(){return this.helper.negotiatedProtocolVersion}async determineContext(){const t=await _(this.helper.determineContext(),{defaultValue:"guest"});return this.evaluateContext(t)}initiateConnection(){return _(this.helper.openBridge().pipe(Xe(t=>{this.helper.onBadgeQueryMessage().subscribe(e=>{var r;this.logger.debug("Received Badge Query: ",e);for(const s of((r=this.listeners.get(v.BadgeQuery))==null?void 0:r.values())??[])s()}),this.helper.onLifecycleMessage().subscribe(e=>{var r;this.logger.debug("Received Lifecycle Event: ",e);for(const s of((r=this.listeners.get(v.Lifecycle))==null?void 0:r.values())??[])s(e.eventName,e.payload)}),this.helper.onPushTokenMessage().subscribe(e=>{var r;this.logger.debug("Received Push Token: ",e);for(const s of((r=this.listeners.get(v.PushToken))==null?void 0:r.values())??[])s(e.pushToken,e.appId,e.selector)}),this.cloudId=t.cloudId,this.cloudUsername=t.cloudUsername,this.host=t.host}),H(()=>{})))}selectContacts(t,e,r,s){this.logger.debug("Selecting Contacts: ",...arguments);let i;if(e==="multi"){if(!r||!Array.isArray(r))throw new T("currentContacts",r,"currentContacts is required for group streams");s||(s="cloudUsername"),i=this.helper.selectContacts(t.toString(),"group",s,r)}else r?s=r:s="cloudUsername",i=this.helper.selectContacts(t.toString(),"direct",s);return _(i.pipe(H(o=>o.contacts)))}matchContacts(t){return this.logger.debug("Match Contacts: ",t),_(this.helper.matchContacts(t).pipe(H(e=>e.contacts)))}requestPushToken(){return this.logger.debug("Requesting Push Token"),_(this.helper.requestPushToken().pipe(H(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()}openUrl(t,e){this.logger.debug("Opening URL: ",t),this.helper.openUrl(t,e)}sipCall(t){this.logger.debug("Initiating SIP Call: ",t),this.helper.sendSipCallMessage(t)}onBadgeQueryRequest(t){var e;return this.logger.debug("Registering for Badge Query"),(e=this.listeners.get(v.BadgeQuery))==null||e.add(t),()=>{var r;return(r=this.listeners.get(v.BadgeQuery))==null?void 0:r.delete(t)}}onLifecycleEvent(t){var e;return this.logger.debug("Registering for Lifecycle Event"),(e=this.listeners.get(v.Lifecycle))==null||e.add(t),()=>{var r;return(r=this.listeners.get(v.Lifecycle))==null?void 0:r.delete(t)}}onPushToken(t){var e;return this.logger.debug("Registering for Push Token"),(e=this.listeners.get(v.PushToken))==null||e.add(t),()=>{var r;return(r=this.listeners.get(v.PushToken))==null?void 0:r.delete(t)}}evaluateContext(t){if(t==="user")return"host";if(t==="guest")return"standalone"}}E.IPCEvents=v,E.IPCManager=Tt,Object.defineProperty(E,Symbol.toStringTag,{value:"Module"})});
|