@acrobits/ipc-sdk 0.0.14 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
- var ys=Object.defineProperty;var bs=(x,$,j)=>$ in x?ys(x,$,{enumerable:!0,configurable:!0,writable:!0,value:j}):x[$]=j;var le=(x,$,j)=>(bs(x,typeof $!="symbol"?$+"":$,j),j),ws=(x,$,j)=>{if(!$.has(x))throw TypeError("Cannot "+j)};var yr=(x,$,j)=>{if($.has(x))throw TypeError("Cannot add the same private member more than once");$ instanceof WeakSet?$.add(x):$.set(x,j)};var vt=(x,$,j)=>(ws(x,$,"access private method"),j);(function(x,$){typeof exports=="object"&&typeof module<"u"?$(exports):typeof define=="function"&&define.amd?define(["exports"],$):(x=typeof globalThis<"u"?globalThis:x||self,$(x["@acrobits/ipc-sdk"]={}))})(this,function(x){var me,gt;"use strict";var $=(r=>(r.BadgeQuery="BADGE QUERY",r.HostInForeground="HOST IN FOREGROUND",r))($||{}),j=Object.defineProperty,br=(r,e,t)=>e in r?j(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,z=(r,e,t)=>(br(r,typeof e!="symbol"?e+"":e,t),t),Ge={exports:{}};const wr="2.0.0",mt=256,Rr=Number.MAX_SAFE_INTEGER||9007199254740991,Ir=16,Sr=mt-6;var ye={MAX_LENGTH:mt,MAX_SAFE_COMPONENT_LENGTH:Ir,MAX_SAFE_BUILD_LENGTH:Sr,MAX_SAFE_INTEGER:Rr,RELEASE_TYPES:["major","premajor","minor","preminor","patch","prepatch","prerelease"],SEMVER_SPEC_VERSION:wr,FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2},be=typeof process=="object"&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...r)=>console.error("SEMVER",...r):()=>{};(function(r,e){const{MAX_SAFE_COMPONENT_LENGTH:t,MAX_SAFE_BUILD_LENGTH:n,MAX_LENGTH:i}=ye,s=be;e=r.exports={};const a=e.re=[],c=e.safeRe=[],o=e.src=[],l=e.t={};let u=0;const p="[a-zA-Z0-9-]",w=[["\\s",1],["\\d",i],[p,n]],f=I=>{for(const[G,te]of w)I=I.split(`${G}*`).join(`${G}{0,${te}}`).split(`${G}+`).join(`${G}{1,${te}}`);return I},g=(I,G,te)=>{const M=f(G),re=u++;s(I,re,G),l[I]=re,o[re]=G,a[re]=new RegExp(G,te?"g":void 0),c[re]=new RegExp(M,te?"g":void 0)};g("NUMERICIDENTIFIER","0|[1-9]\\d*"),g("NUMERICIDENTIFIERLOOSE","\\d+"),g("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${p}*`),g("MAINVERSION",`(${o[l.NUMERICIDENTIFIER]})\\.(${o[l.NUMERICIDENTIFIER]})\\.(${o[l.NUMERICIDENTIFIER]})`),g("MAINVERSIONLOOSE",`(${o[l.NUMERICIDENTIFIERLOOSE]})\\.(${o[l.NUMERICIDENTIFIERLOOSE]})\\.(${o[l.NUMERICIDENTIFIERLOOSE]})`),g("PRERELEASEIDENTIFIER",`(?:${o[l.NUMERICIDENTIFIER]}|${o[l.NONNUMERICIDENTIFIER]})`),g("PRERELEASEIDENTIFIERLOOSE",`(?:${o[l.NUMERICIDENTIFIERLOOSE]}|${o[l.NONNUMERICIDENTIFIER]})`),g("PRERELEASE",`(?:-(${o[l.PRERELEASEIDENTIFIER]}(?:\\.${o[l.PRERELEASEIDENTIFIER]})*))`),g("PRERELEASELOOSE",`(?:-?(${o[l.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${o[l.PRERELEASEIDENTIFIERLOOSE]})*))`),g("BUILDIDENTIFIER",`${p}+`),g("BUILD",`(?:\\+(${o[l.BUILDIDENTIFIER]}(?:\\.${o[l.BUILDIDENTIFIER]})*))`),g("FULLPLAIN",`v?${o[l.MAINVERSION]}${o[l.PRERELEASE]}?${o[l.BUILD]}?`),g("FULL",`^${o[l.FULLPLAIN]}$`),g("LOOSEPLAIN",`[v=\\s]*${o[l.MAINVERSIONLOOSE]}${o[l.PRERELEASELOOSE]}?${o[l.BUILD]}?`),g("LOOSE",`^${o[l.LOOSEPLAIN]}$`),g("GTLT","((?:<|>)?=?)"),g("XRANGEIDENTIFIERLOOSE",`${o[l.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),g("XRANGEIDENTIFIER",`${o[l.NUMERICIDENTIFIER]}|x|X|\\*`),g("XRANGEPLAIN",`[v=\\s]*(${o[l.XRANGEIDENTIFIER]})(?:\\.(${o[l.XRANGEIDENTIFIER]})(?:\\.(${o[l.XRANGEIDENTIFIER]})(?:${o[l.PRERELEASE]})?${o[l.BUILD]}?)?)?`),g("XRANGEPLAINLOOSE",`[v=\\s]*(${o[l.XRANGEIDENTIFIERLOOSE]})(?:\\.(${o[l.XRANGEIDENTIFIERLOOSE]})(?:\\.(${o[l.XRANGEIDENTIFIERLOOSE]})(?:${o[l.PRERELEASELOOSE]})?${o[l.BUILD]}?)?)?`),g("XRANGE",`^${o[l.GTLT]}\\s*${o[l.XRANGEPLAIN]}$`),g("XRANGELOOSE",`^${o[l.GTLT]}\\s*${o[l.XRANGEPLAINLOOSE]}$`),g("COERCE",`(^|[^\\d])(\\d{1,${t}})(?:\\.(\\d{1,${t}}))?(?:\\.(\\d{1,${t}}))?(?:$|[^\\d])`),g("COERCERTL",o[l.COERCE],!0),g("LONETILDE","(?:~>?)"),g("TILDETRIM",`(\\s*)${o[l.LONETILDE]}\\s+`,!0),e.tildeTrimReplace="$1~",g("TILDE",`^${o[l.LONETILDE]}${o[l.XRANGEPLAIN]}$`),g("TILDELOOSE",`^${o[l.LONETILDE]}${o[l.XRANGEPLAINLOOSE]}$`),g("LONECARET","(?:\\^)"),g("CARETTRIM",`(\\s*)${o[l.LONECARET]}\\s+`,!0),e.caretTrimReplace="$1^",g("CARET",`^${o[l.LONECARET]}${o[l.XRANGEPLAIN]}$`),g("CARETLOOSE",`^${o[l.LONECARET]}${o[l.XRANGEPLAINLOOSE]}$`),g("COMPARATORLOOSE",`^${o[l.GTLT]}\\s*(${o[l.LOOSEPLAIN]})$|^$`),g("COMPARATOR",`^${o[l.GTLT]}\\s*(${o[l.FULLPLAIN]})$|^$`),g("COMPARATORTRIM",`(\\s*)${o[l.GTLT]}\\s*(${o[l.LOOSEPLAIN]}|${o[l.XRANGEPLAIN]})`,!0),e.comparatorTrimReplace="$1$2$3",g("HYPHENRANGE",`^\\s*(${o[l.XRANGEPLAIN]})\\s+-\\s+(${o[l.XRANGEPLAIN]})\\s*$`),g("HYPHENRANGELOOSE",`^\\s*(${o[l.XRANGEPLAINLOOSE]})\\s+-\\s+(${o[l.XRANGEPLAINLOOSE]})\\s*$`),g("STAR","(<|>)?=?\\s*\\*"),g("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$"),g("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")})(Ge,Ge.exports);var ce=Ge.exports;const $r=Object.freeze({loose:!0}),Or=Object.freeze({});var ke=r=>r?typeof r!="object"?$r:r:Or;const Et=/^[0-9]+$/,yt=(r,e)=>{const t=Et.test(r),n=Et.test(e);return t&&n&&(r=+r,e=+e),r===e?0:t&&!n?-1:n&&!t?1:r<e?-1:1};var bt={compareIdentifiers:yt,rcompareIdentifiers:(r,e)=>yt(e,r)};const we=be,{MAX_LENGTH:wt,MAX_SAFE_INTEGER:Re}=ye,{safeRe:Rt,t:It}=ce,Ar=ke,{compareIdentifiers:ne}=bt;var D=class X{constructor(e,t){if(t=Ar(t),e instanceof X){if(e.loose===!!t.loose&&e.includePrerelease===!!t.includePrerelease)return e;e=e.version}else if(typeof e!="string")throw new TypeError(`Invalid version. Must be a string. Got type "${typeof e}".`);if(e.length>wt)throw new TypeError(`version is longer than ${wt} characters`);we("SemVer",e,t),this.options=t,this.loose=!!t.loose,this.includePrerelease=!!t.includePrerelease;const n=e.trim().match(t.loose?Rt[It.LOOSE]:Rt[It.FULL]);if(!n)throw new TypeError(`Invalid Version: ${e}`);if(this.raw=e,this.major=+n[1],this.minor=+n[2],this.patch=+n[3],this.major>Re||this.major<0)throw new TypeError("Invalid major version");if(this.minor>Re||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>Re||this.patch<0)throw new TypeError("Invalid patch version");n[4]?this.prerelease=n[4].split(".").map(i=>{if(/^[0-9]+$/.test(i)){const s=+i;if(s>=0&&s<Re)return s}return i}):this.prerelease=[],this.build=n[5]?n[5].split("."):[],this.format()}format(){return this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length&&(this.version+=`-${this.prerelease.join(".")}`),this.version}toString(){return this.version}compare(e){if(we("SemVer.compare",this.version,this.options,e),!(e instanceof X)){if(typeof e=="string"&&e===this.version)return 0;e=new X(e,this.options)}return e.version===this.version?0:this.compareMain(e)||this.comparePre(e)}compareMain(e){return e instanceof X||(e=new X(e,this.options)),ne(this.major,e.major)||ne(this.minor,e.minor)||ne(this.patch,e.patch)}comparePre(e){if(e instanceof X||(e=new X(e,this.options)),this.prerelease.length&&!e.prerelease.length)return-1;if(!this.prerelease.length&&e.prerelease.length)return 1;if(!this.prerelease.length&&!e.prerelease.length)return 0;let t=0;do{const n=this.prerelease[t],i=e.prerelease[t];if(we("prerelease compare",t,n,i),n===void 0&&i===void 0)return 0;if(i===void 0)return 1;if(n===void 0)return-1;if(n!==i)return ne(n,i)}while(++t)}compareBuild(e){e instanceof X||(e=new X(e,this.options));let t=0;do{const n=this.build[t],i=e.build[t];if(we("prerelease compare",t,n,i),n===void 0&&i===void 0)return 0;if(i===void 0)return 1;if(n===void 0)return-1;if(n!==i)return ne(n,i)}while(++t)}inc(e,t,n){switch(e){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",t,n);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",t,n);break;case"prepatch":this.prerelease.length=0,this.inc("patch",t,n),this.inc("pre",t,n);break;case"prerelease":this.prerelease.length===0&&this.inc("patch",t,n),this.inc("pre",t,n);break;case"major":(this.minor!==0||this.patch!==0||this.prerelease.length===0)&&this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":(this.patch!==0||this.prerelease.length===0)&&this.minor++,this.patch=0,this.prerelease=[];break;case"patch":this.prerelease.length===0&&this.patch++,this.prerelease=[];break;case"pre":{const i=Number(n)?1:0;if(!t&&n===!1)throw new Error("invalid increment argument: identifier is empty");if(this.prerelease.length===0)this.prerelease=[i];else{let s=this.prerelease.length;for(;--s>=0;)typeof this.prerelease[s]=="number"&&(this.prerelease[s]++,s=-2);if(s===-1){if(t===this.prerelease.join(".")&&n===!1)throw new Error("invalid increment argument: identifier already exists");this.prerelease.push(i)}}if(t){let s=[t,i];n===!1&&(s=[t]),ne(this.prerelease[0],t)===0?isNaN(this.prerelease[1])&&(this.prerelease=s):this.prerelease=s}break}default:throw new Error(`invalid increment argument: ${e}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(".")}`),this}};const St=D;var ie=(r,e,t=!1)=>{if(r instanceof St)return r;try{return new St(r,e)}catch(n){if(!t)return null;throw n}};const Tr=ie;var Cr=(r,e)=>{const t=Tr(r,e);return t?t.version:null};const xr=ie;var Nr=(r,e)=>{const t=xr(r.trim().replace(/^[=v]+/,""),e);return t?t.version:null};const $t=D;var Lr=(r,e,t,n,i)=>{typeof t=="string"&&(i=n,n=t,t=void 0);try{return new $t(r instanceof $t?r.version:r,t).inc(e,n,i).version}catch{return null}};const Ot=ie;var Pr=(r,e)=>{const t=Ot(r,null,!0),n=Ot(e,null,!0),i=t.compare(n);if(i===0)return null;const s=i>0,a=s?t:n,c=s?n:t,o=!!a.prerelease.length;if(c.prerelease.length&&!o)return!c.patch&&!c.minor?"major":a.patch?"patch":a.minor?"minor":"major";const l=o?"pre":"";return t.major!==n.major?l+"major":t.minor!==n.minor?l+"minor":t.patch!==n.patch?l+"patch":"prerelease"};const Mr=D;var _r=(r,e)=>new Mr(r,e).major;const Dr=D;var Ur=(r,e)=>new Dr(r,e).minor;const jr=D;var Fr=(r,e)=>new jr(r,e).patch;const Gr=ie;var kr=(r,e)=>{const t=Gr(r,e);return t&&t.prerelease.length?t.prerelease:null};const At=D;var k=(r,e,t)=>new At(r,t).compare(new At(e,t));const Vr=k;var Hr=(r,e,t)=>Vr(e,r,t);const Xr=k;var Br=(r,e)=>Xr(r,e,!0);const Tt=D;var Ve=(r,e,t)=>{const n=new Tt(r,t),i=new Tt(e,t);return n.compare(i)||n.compareBuild(i)};const qr=Ve;var Yr=(r,e)=>r.sort((t,n)=>qr(t,n,e));const zr=Ve;var Qr=(r,e)=>r.sort((t,n)=>zr(n,t,e));const Wr=k;var Ie=(r,e,t)=>Wr(r,e,t)>0;const Kr=k;var He=(r,e,t)=>Kr(r,e,t)<0;const Jr=k;var Ct=(r,e,t)=>Jr(r,e,t)===0;const Zr=k;var xt=(r,e,t)=>Zr(r,e,t)!==0;const en=k;var Xe=(r,e,t)=>en(r,e,t)>=0;const tn=k;var Be=(r,e,t)=>tn(r,e,t)<=0;const rn=Ct,nn=xt,sn=Ie,on=Xe,an=He,ln=Be;var Nt=(r,e,t,n)=>{switch(e){case"===":return typeof r=="object"&&(r=r.version),typeof t=="object"&&(t=t.version),r===t;case"!==":return typeof r=="object"&&(r=r.version),typeof t=="object"&&(t=t.version),r!==t;case"":case"=":case"==":return rn(r,t,n);case"!=":return nn(r,t,n);case">":return sn(r,t,n);case">=":return on(r,t,n);case"<":return an(r,t,n);case"<=":return ln(r,t,n);default:throw new TypeError(`Invalid operator: ${e}`)}};const cn=D,un=ie,{safeRe:Se,t:$e}=ce;var hn=(r,e)=>{if(r instanceof cn)return r;if(typeof r=="number"&&(r=String(r)),typeof r!="string")return null;e=e||{};let t=null;if(!e.rtl)t=r.match(Se[$e.COERCE]);else{let n;for(;(n=Se[$e.COERCERTL].exec(r))&&(!t||t.index+t[0].length!==r.length);)(!t||n.index+n[0].length!==t.index+t[0].length)&&(t=n),Se[$e.COERCERTL].lastIndex=n.index+n[1].length+n[2].length;Se[$e.COERCERTL].lastIndex=-1}return t===null?null:un(`${t[2]}.${t[3]||"0"}.${t[4]||"0"}`,e)},Lt,Pt;function pn(){return Pt||(Pt=1,Lt=function(r){r.prototype[Symbol.iterator]=function*(){for(let e=this.head;e;e=e.next)yield e.value}}),Lt}var fn=R;R.Node=K,R.create=R;function R(r){var e=this;if(e instanceof R||(e=new R),e.tail=null,e.head=null,e.length=0,r&&typeof r.forEach=="function")r.forEach(function(i){e.push(i)});else if(arguments.length>0)for(var t=0,n=arguments.length;t<n;t++)e.push(arguments[t]);return e}R.prototype.removeNode=function(r){if(r.list!==this)throw new Error("removing node which does not belong to this list");var e=r.next,t=r.prev;return e&&(e.prev=t),t&&(t.next=e),r===this.head&&(this.head=e),r===this.tail&&(this.tail=t),r.list.length--,r.next=null,r.prev=null,r.list=null,e},R.prototype.unshiftNode=function(r){if(r!==this.head){r.list&&r.list.removeNode(r);var e=this.head;r.list=this,r.next=e,e&&(e.prev=r),this.head=r,this.tail||(this.tail=r),this.length++}},R.prototype.pushNode=function(r){if(r!==this.tail){r.list&&r.list.removeNode(r);var e=this.tail;r.list=this,r.prev=e,e&&(e.next=r),this.tail=r,this.head||(this.head=r),this.length++}},R.prototype.push=function(){for(var r=0,e=arguments.length;r<e;r++)vn(this,arguments[r]);return this.length},R.prototype.unshift=function(){for(var r=0,e=arguments.length;r<e;r++)gn(this,arguments[r]);return this.length},R.prototype.pop=function(){if(this.tail){var r=this.tail.value;return this.tail=this.tail.prev,this.tail?this.tail.next=null:this.head=null,this.length--,r}},R.prototype.shift=function(){if(this.head){var r=this.head.value;return this.head=this.head.next,this.head?this.head.prev=null:this.tail=null,this.length--,r}},R.prototype.forEach=function(r,e){e=e||this;for(var t=this.head,n=0;t!==null;n++)r.call(e,t.value,n,this),t=t.next},R.prototype.forEachReverse=function(r,e){e=e||this;for(var t=this.tail,n=this.length-1;t!==null;n--)r.call(e,t.value,n,this),t=t.prev},R.prototype.get=function(r){for(var e=0,t=this.head;t!==null&&e<r;e++)t=t.next;if(e===r&&t!==null)return t.value},R.prototype.getReverse=function(r){for(var e=0,t=this.tail;t!==null&&e<r;e++)t=t.prev;if(e===r&&t!==null)return t.value},R.prototype.map=function(r,e){e=e||this;for(var t=new R,n=this.head;n!==null;)t.push(r.call(e,n.value,this)),n=n.next;return t},R.prototype.mapReverse=function(r,e){e=e||this;for(var t=new R,n=this.tail;n!==null;)t.push(r.call(e,n.value,this)),n=n.prev;return t},R.prototype.reduce=function(r,e){var t,n=this.head;if(arguments.length>1)t=e;else if(this.head)n=this.head.next,t=this.head.value;else throw new TypeError("Reduce of empty list with no initial value");for(var i=0;n!==null;i++)t=r(t,n.value,i),n=n.next;return t},R.prototype.reduceReverse=function(r,e){var t,n=this.tail;if(arguments.length>1)t=e;else if(this.tail)n=this.tail.prev,t=this.tail.value;else throw new TypeError("Reduce of empty list with no initial value");for(var i=this.length-1;n!==null;i--)t=r(t,n.value,i),n=n.prev;return t},R.prototype.toArray=function(){for(var r=new Array(this.length),e=0,t=this.head;t!==null;e++)r[e]=t.value,t=t.next;return r},R.prototype.toArrayReverse=function(){for(var r=new Array(this.length),e=0,t=this.tail;t!==null;e++)r[e]=t.value,t=t.prev;return r},R.prototype.slice=function(r,e){e=e||this.length,e<0&&(e+=this.length),r=r||0,r<0&&(r+=this.length);var t=new R;if(e<r||e<0)return t;r<0&&(r=0),e>this.length&&(e=this.length);for(var n=0,i=this.head;i!==null&&n<r;n++)i=i.next;for(;i!==null&&n<e;n++,i=i.next)t.push(i.value);return t},R.prototype.sliceReverse=function(r,e){e=e||this.length,e<0&&(e+=this.length),r=r||0,r<0&&(r+=this.length);var t=new R;if(e<r||e<0)return t;r<0&&(r=0),e>this.length&&(e=this.length);for(var n=this.length,i=this.tail;i!==null&&n>e;n--)i=i.prev;for(;i!==null&&n>r;n--,i=i.prev)t.push(i.value);return t},R.prototype.splice=function(r,e,...t){r>this.length&&(r=this.length-1),r<0&&(r=this.length+r);for(var n=0,i=this.head;i!==null&&n<r;n++)i=i.next;for(var s=[],n=0;i&&n<e;n++)s.push(i.value),i=this.removeNode(i);i===null&&(i=this.tail),i!==this.head&&i!==this.tail&&(i=i.prev);for(var n=0;n<t.length;n++)i=dn(this,i,t[n]);return s},R.prototype.reverse=function(){for(var r=this.head,e=this.tail,t=r;t!==null;t=t.prev){var n=t.prev;t.prev=t.next,t.next=n}return this.head=e,this.tail=r,this};function dn(r,e,t){var n=e===r.head?new K(t,null,e,r):new K(t,e,e.next,r);return n.next===null&&(r.tail=n),n.prev===null&&(r.head=n),r.length++,n}function vn(r,e){r.tail=new K(e,r.tail,null,r),r.head||(r.head=r.tail),r.length++}function gn(r,e){r.head=new K(e,null,r.head,r),r.tail||(r.tail=r.head),r.length++}function K(r,e,t,n){if(!(this instanceof K))return new K(r,e,t,n);this.list=n,this.value=r,e?(e.next=this,this.prev=e):this.prev=null,t?(t.prev=this,this.next=t):this.next=null}try{pn()(R)}catch{}const mn=fn,J=Symbol("max"),B=Symbol("length"),se=Symbol("lengthCalculator"),ue=Symbol("allowStale"),Z=Symbol("maxAge"),q=Symbol("dispose"),Mt=Symbol("noDisposeOnSet"),P=Symbol("lruList"),V=Symbol("cache"),_t=Symbol("updateAgeOnGet"),qe=()=>1;class En{constructor(e){if(typeof e=="number"&&(e={max:e}),e||(e={}),e.max&&(typeof e.max!="number"||e.max<0))throw new TypeError("max must be a non-negative number");this[J]=e.max||1/0;const t=e.length||qe;if(this[se]=typeof t!="function"?qe:t,this[ue]=e.stale||!1,e.maxAge&&typeof e.maxAge!="number")throw new TypeError("maxAge must be a number");this[Z]=e.maxAge||0,this[q]=e.dispose,this[Mt]=e.noDisposeOnSet||!1,this[_t]=e.updateAgeOnGet||!1,this.reset()}set max(e){if(typeof e!="number"||e<0)throw new TypeError("max must be a non-negative number");this[J]=e||1/0,he(this)}get max(){return this[J]}set allowStale(e){this[ue]=!!e}get allowStale(){return this[ue]}set maxAge(e){if(typeof e!="number")throw new TypeError("maxAge must be a non-negative number");this[Z]=e,he(this)}get maxAge(){return this[Z]}set lengthCalculator(e){typeof e!="function"&&(e=qe),e!==this[se]&&(this[se]=e,this[B]=0,this[P].forEach(t=>{t.length=this[se](t.value,t.key),this[B]+=t.length})),he(this)}get lengthCalculator(){return this[se]}get length(){return this[B]}get itemCount(){return this[P].length}rforEach(e,t){t=t||this;for(let n=this[P].tail;n!==null;){const i=n.prev;Dt(this,e,n,t),n=i}}forEach(e,t){t=t||this;for(let n=this[P].head;n!==null;){const i=n.next;Dt(this,e,n,t),n=i}}keys(){return this[P].toArray().map(e=>e.key)}values(){return this[P].toArray().map(e=>e.value)}reset(){this[q]&&this[P]&&this[P].length&&this[P].forEach(e=>this[q](e.key,e.value)),this[V]=new Map,this[P]=new mn,this[B]=0}dump(){return this[P].map(e=>Oe(this,e)?!1:{k:e.key,v:e.value,e:e.now+(e.maxAge||0)}).toArray().filter(e=>e)}dumpLru(){return this[P]}set(e,t,n){if(n=n||this[Z],n&&typeof n!="number")throw new TypeError("maxAge must be a number");const i=n?Date.now():0,s=this[se](t,e);if(this[V].has(e)){if(s>this[J])return oe(this,this[V].get(e)),!1;const c=this[V].get(e).value;return this[q]&&(this[Mt]||this[q](e,c.value)),c.now=i,c.maxAge=n,c.value=t,this[B]+=s-c.length,c.length=s,this.get(e),he(this),!0}const a=new yn(e,t,s,i,n);return a.length>this[J]?(this[q]&&this[q](e,t),!1):(this[B]+=a.length,this[P].unshift(a),this[V].set(e,this[P].head),he(this),!0)}has(e){if(!this[V].has(e))return!1;const t=this[V].get(e).value;return!Oe(this,t)}get(e){return Ye(this,e,!0)}peek(e){return Ye(this,e,!1)}pop(){const e=this[P].tail;return e?(oe(this,e),e.value):null}del(e){oe(this,this[V].get(e))}load(e){this.reset();const t=Date.now();for(let n=e.length-1;n>=0;n--){const i=e[n],s=i.e||0;if(s===0)this.set(i.k,i.v);else{const a=s-t;a>0&&this.set(i.k,i.v,a)}}}prune(){this[V].forEach((e,t)=>Ye(this,t,!1))}}const Ye=(r,e,t)=>{const n=r[V].get(e);if(n){const i=n.value;if(Oe(r,i)){if(oe(r,n),!r[ue])return}else t&&(r[_t]&&(n.value.now=Date.now()),r[P].unshiftNode(n));return i.value}},Oe=(r,e)=>{if(!e||!e.maxAge&&!r[Z])return!1;const t=Date.now()-e.now;return e.maxAge?t>e.maxAge:r[Z]&&t>r[Z]},he=r=>{if(r[B]>r[J])for(let e=r[P].tail;r[B]>r[J]&&e!==null;){const t=e.prev;oe(r,e),e=t}},oe=(r,e)=>{if(e){const t=e.value;r[q]&&r[q](t.key,t.value),r[B]-=t.length,r[V].delete(t.key),r[P].removeNode(e)}};class yn{constructor(e,t,n,i,s){this.key=e,this.value=t,this.length=n,this.now=i,this.maxAge=s||0}}const Dt=(r,e,t,n)=>{let i=t.value;Oe(r,i)&&(oe(r,t),r[ue]||(i=void 0)),i&&e.call(n,i.value,i.key,r)};var bn=En,ze,Ut;function H(){if(Ut)return ze;Ut=1;class r{constructor(h,y){if(y=n(y),h instanceof r)return h.loose===!!y.loose&&h.includePrerelease===!!y.includePrerelease?h:new r(h.raw,y);if(h instanceof i)return this.raw=h.value,this.set=[[h]],this.format(),this;if(this.options=y,this.loose=!!y.loose,this.includePrerelease=!!y.includePrerelease,this.raw=h.trim().split(/\s+/).join(" "),this.set=this.raw.split("||").map(m=>this.parseRange(m.trim())).filter(m=>m.length),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){const m=this.set[0];if(this.set=this.set.filter(E=>!g(E[0])),this.set.length===0)this.set=[m];else if(this.set.length>1){for(const E of this.set)if(E.length===1&&I(E[0])){this.set=[E];break}}}this.format()}format(){return this.range=this.set.map(h=>h.join(" ").trim()).join("||").trim(),this.range}toString(){return this.range}parseRange(h){const y=((this.options.includePrerelease&&w)|(this.options.loose&&f))+":"+h,m=t.get(y);if(m)return m;const E=this.options.loose,v=E?c[o.HYPHENRANGELOOSE]:c[o.HYPHENRANGE];h=h.replace(v,ms(this.options.includePrerelease)),s("hyphen replace",h),h=h.replace(c[o.COMPARATORTRIM],l),s("comparator trim",h),h=h.replace(c[o.TILDETRIM],u),s("tilde trim",h),h=h.replace(c[o.CARETTRIM],p),s("caret trim",h);let b=h.split(" ").map(T=>te(T,this.options)).join(" ").split(/\s+/).map(T=>gs(T,this.options));E&&(b=b.filter(T=>(s("loose invalid filter",T,this.options),!!T.match(c[o.COMPARATORLOOSE])))),s("range list",b);const O=new Map,S=b.map(T=>new i(T,this.options));for(const T of S){if(g(T))return[T];O.set(T.value,T)}O.size>1&&O.has("")&&O.delete("");const A=[...O.values()];return t.set(y,A),A}intersects(h,y){if(!(h instanceof r))throw new TypeError("a Range is required");return this.set.some(m=>G(m,y)&&h.set.some(E=>G(E,y)&&m.every(v=>E.every(b=>v.intersects(b,y)))))}test(h){if(!h)return!1;if(typeof h=="string")try{h=new a(h,this.options)}catch{return!1}for(let y=0;y<this.set.length;y++)if(Es(this.set[y],h,this.options))return!0;return!1}}ze=r;const e=bn,t=new e({max:1e3}),n=ke,i=Ae(),s=be,a=D,{safeRe:c,t:o,comparatorTrimReplace:l,tildeTrimReplace:u,caretTrimReplace:p}=ce,{FLAG_INCLUDE_PRERELEASE:w,FLAG_LOOSE:f}=ye,g=d=>d.value==="<0.0.0-0",I=d=>d.value==="",G=(d,h)=>{let y=!0;const m=d.slice();let E=m.pop();for(;y&&m.length;)y=m.every(v=>E.intersects(v,h)),E=m.pop();return y},te=(d,h)=>(s("comp",d,h),d=hs(d,h),s("caret",d),d=re(d,h),s("tildes",d),d=fs(d,h),s("xrange",d),d=vs(d,h),s("stars",d),d),M=d=>!d||d.toLowerCase()==="x"||d==="*",re=(d,h)=>d.trim().split(/\s+/).map(y=>us(y,h)).join(" "),us=(d,h)=>{const y=h.loose?c[o.TILDELOOSE]:c[o.TILDE];return d.replace(y,(m,E,v,b,O)=>{s("tilde",d,m,E,v,b,O);let S;return M(E)?S="":M(v)?S=`>=${E}.0.0 <${+E+1}.0.0-0`:M(b)?S=`>=${E}.${v}.0 <${E}.${+v+1}.0-0`:O?(s("replaceTilde pr",O),S=`>=${E}.${v}.${b}-${O} <${E}.${+v+1}.0-0`):S=`>=${E}.${v}.${b} <${E}.${+v+1}.0-0`,s("tilde return",S),S})},hs=(d,h)=>d.trim().split(/\s+/).map(y=>ps(y,h)).join(" "),ps=(d,h)=>{s("caret",d,h);const y=h.loose?c[o.CARETLOOSE]:c[o.CARET],m=h.includePrerelease?"-0":"";return d.replace(y,(E,v,b,O,S)=>{s("caret",d,E,v,b,O,S);let A;return M(v)?A="":M(b)?A=`>=${v}.0.0${m} <${+v+1}.0.0-0`:M(O)?v==="0"?A=`>=${v}.${b}.0${m} <${v}.${+b+1}.0-0`:A=`>=${v}.${b}.0${m} <${+v+1}.0.0-0`:S?(s("replaceCaret pr",S),v==="0"?b==="0"?A=`>=${v}.${b}.${O}-${S} <${v}.${b}.${+O+1}-0`:A=`>=${v}.${b}.${O}-${S} <${v}.${+b+1}.0-0`:A=`>=${v}.${b}.${O}-${S} <${+v+1}.0.0-0`):(s("no pr"),v==="0"?b==="0"?A=`>=${v}.${b}.${O}${m} <${v}.${b}.${+O+1}-0`:A=`>=${v}.${b}.${O}${m} <${v}.${+b+1}.0-0`:A=`>=${v}.${b}.${O} <${+v+1}.0.0-0`),s("caret return",A),A})},fs=(d,h)=>(s("replaceXRanges",d,h),d.split(/\s+/).map(y=>ds(y,h)).join(" ")),ds=(d,h)=>{d=d.trim();const y=h.loose?c[o.XRANGELOOSE]:c[o.XRANGE];return d.replace(y,(m,E,v,b,O,S)=>{s("xRange",d,m,E,v,b,O,S);const A=M(v),T=A||M(b),ae=T||M(O),Ee=ae;return E==="="&&Ee&&(E=""),S=h.includePrerelease?"-0":"",A?E===">"||E==="<"?m="<0.0.0-0":m="*":E&&Ee?(T&&(b=0),O=0,E===">"?(E=">=",T?(v=+v+1,b=0,O=0):(b=+b+1,O=0)):E==="<="&&(E="<",T?v=+v+1:b=+b+1),E==="<"&&(S="-0"),m=`${E+v}.${b}.${O}${S}`):T?m=`>=${v}.0.0${S} <${+v+1}.0.0-0`:ae&&(m=`>=${v}.${b}.0${S} <${v}.${+b+1}.0-0`),s("xRange return",m),m})},vs=(d,h)=>(s("replaceStars",d,h),d.trim().replace(c[o.STAR],"")),gs=(d,h)=>(s("replaceGTE0",d,h),d.trim().replace(c[h.includePrerelease?o.GTE0PRE:o.GTE0],"")),ms=d=>(h,y,m,E,v,b,O,S,A,T,ae,Ee,yo)=>(M(m)?y="":M(E)?y=`>=${m}.0.0${d?"-0":""}`:M(v)?y=`>=${m}.${E}.0${d?"-0":""}`:b?y=`>=${y}`:y=`>=${y}${d?"-0":""}`,M(A)?S="":M(T)?S=`<${+A+1}.0.0-0`:M(ae)?S=`<${A}.${+T+1}.0-0`:Ee?S=`<=${A}.${T}.${ae}-${Ee}`:d?S=`<${A}.${T}.${+ae+1}-0`:S=`<=${S}`,`${y} ${S}`.trim()),Es=(d,h,y)=>{for(let m=0;m<d.length;m++)if(!d[m].test(h))return!1;if(h.prerelease.length&&!y.includePrerelease){for(let m=0;m<d.length;m++)if(s(d[m].semver),d[m].semver!==i.ANY&&d[m].semver.prerelease.length>0){const E=d[m].semver;if(E.major===h.major&&E.minor===h.minor&&E.patch===h.patch)return!0}return!1}return!0};return ze}var Qe,jt;function Ae(){if(jt)return Qe;jt=1;const r=Symbol("SemVer ANY");class e{static get ANY(){return r}constructor(u,p){if(p=t(p),u instanceof e){if(u.loose===!!p.loose)return u;u=u.value}u=u.trim().split(/\s+/).join(" "),a("comparator",u,p),this.options=p,this.loose=!!p.loose,this.parse(u),this.semver===r?this.value="":this.value=this.operator+this.semver.version,a("comp",this)}parse(u){const p=this.options.loose?n[i.COMPARATORLOOSE]:n[i.COMPARATOR],w=u.match(p);if(!w)throw new TypeError(`Invalid comparator: ${u}`);this.operator=w[1]!==void 0?w[1]:"",this.operator==="="&&(this.operator=""),w[2]?this.semver=new c(w[2],this.options.loose):this.semver=r}toString(){return this.value}test(u){if(a("Comparator.test",u,this.options.loose),this.semver===r||u===r)return!0;if(typeof u=="string")try{u=new c(u,this.options)}catch{return!1}return s(u,this.operator,this.semver,this.options)}intersects(u,p){if(!(u instanceof e))throw new TypeError("a Comparator is required");return this.operator===""?this.value===""?!0:new o(u.value,p).test(this.value):u.operator===""?u.value===""?!0:new o(this.value,p).test(u.semver):(p=t(p),p.includePrerelease&&(this.value==="<0.0.0-0"||u.value==="<0.0.0-0")||!p.includePrerelease&&(this.value.startsWith("<0.0.0")||u.value.startsWith("<0.0.0"))?!1:!!(this.operator.startsWith(">")&&u.operator.startsWith(">")||this.operator.startsWith("<")&&u.operator.startsWith("<")||this.semver.version===u.semver.version&&this.operator.includes("=")&&u.operator.includes("=")||s(this.semver,"<",u.semver,p)&&this.operator.startsWith(">")&&u.operator.startsWith("<")||s(this.semver,">",u.semver,p)&&this.operator.startsWith("<")&&u.operator.startsWith(">")))}}Qe=e;const t=ke,{safeRe:n,t:i}=ce,s=Nt,a=be,c=D,o=H();return Qe}const wn=H();var Te=(r,e,t)=>{try{e=new wn(e,t)}catch{return!1}return e.test(r)};const Rn=H();var In=(r,e)=>new Rn(r,e).set.map(t=>t.map(n=>n.value).join(" ").trim().split(" "));const Sn=D,$n=H();var On=(r,e,t)=>{let n=null,i=null,s=null;try{s=new $n(e,t)}catch{return null}return r.forEach(a=>{s.test(a)&&(!n||i.compare(a)===-1)&&(n=a,i=new Sn(n,t))}),n};const An=D,Tn=H();var Cn=(r,e,t)=>{let n=null,i=null,s=null;try{s=new Tn(e,t)}catch{return null}return r.forEach(a=>{s.test(a)&&(!n||i.compare(a)===1)&&(n=a,i=new An(n,t))}),n};const We=D,xn=H(),Ft=Ie;var Nn=(r,e)=>{r=new xn(r,e);let t=new We("0.0.0");if(r.test(t)||(t=new We("0.0.0-0"),r.test(t)))return t;t=null;for(let n=0;n<r.set.length;++n){const i=r.set[n];let s=null;i.forEach(a=>{const c=new We(a.semver.version);switch(a.operator){case">":c.prerelease.length===0?c.patch++:c.prerelease.push(0),c.raw=c.format();case"":case">=":(!s||Ft(c,s))&&(s=c);break;case"<":case"<=":break;default:throw new Error(`Unexpected operation: ${a.operator}`)}}),s&&(!t||Ft(t,s))&&(t=s)}return t&&r.test(t)?t:null};const Ln=H();var Pn=(r,e)=>{try{return new Ln(r,e).range||"*"}catch{return null}};const Mn=D,Gt=Ae(),{ANY:_n}=Gt,Dn=H(),Un=Te,kt=Ie,Vt=He,jn=Be,Fn=Xe;var Ke=(r,e,t,n)=>{r=new Mn(r,n),e=new Dn(e,n);let i,s,a,c,o;switch(t){case">":i=kt,s=jn,a=Vt,c=">",o=">=";break;case"<":i=Vt,s=Fn,a=kt,c="<",o="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"')}if(Un(r,e,n))return!1;for(let l=0;l<e.set.length;++l){const u=e.set[l];let p=null,w=null;if(u.forEach(f=>{f.semver===_n&&(f=new Gt(">=0.0.0")),p=p||f,w=w||f,i(f.semver,p.semver,n)?p=f:a(f.semver,w.semver,n)&&(w=f)}),p.operator===c||p.operator===o||(!w.operator||w.operator===c)&&s(r,w.semver)||w.operator===o&&a(r,w.semver))return!1}return!0};const Gn=Ke;var kn=(r,e,t)=>Gn(r,e,">",t);const Vn=Ke;var Hn=(r,e,t)=>Vn(r,e,"<",t);const Ht=H();var Xn=(r,e,t)=>(r=new Ht(r,t),e=new Ht(e,t),r.intersects(e,t));const Bn=Te,qn=k;var Yn=(r,e,t)=>{const n=[];let i=null,s=null;const a=r.sort((u,p)=>qn(u,p,t));for(const u of a)Bn(u,e,t)?(s=u,i||(i=u)):(s&&n.push([i,s]),s=null,i=null);i&&n.push([i,null]);const c=[];for(const[u,p]of n)u===p?c.push(u):!p&&u===a[0]?c.push("*"):p?u===a[0]?c.push(`<=${p}`):c.push(`${u} - ${p}`):c.push(`>=${u}`);const o=c.join(" || "),l=typeof e.raw=="string"?e.raw:String(e);return o.length<l.length?o:e};const Xt=H(),Je=Ae(),{ANY:Ze}=Je,pe=Te,et=k,zn=(r,e,t={})=>{if(r===e)return!0;r=new Xt(r,t),e=new Xt(e,t);let n=!1;e:for(const i of r.set){for(const s of e.set){const a=Wn(i,s,t);if(n=n||a!==null,a)continue e}if(n)return!1}return!0},Qn=[new Je(">=0.0.0-0")],Bt=[new Je(">=0.0.0")],Wn=(r,e,t)=>{if(r===e)return!0;if(r.length===1&&r[0].semver===Ze){if(e.length===1&&e[0].semver===Ze)return!0;t.includePrerelease?r=Qn:r=Bt}if(e.length===1&&e[0].semver===Ze){if(t.includePrerelease)return!0;e=Bt}const n=new Set;let i,s;for(const f of r)f.operator===">"||f.operator===">="?i=qt(i,f,t):f.operator==="<"||f.operator==="<="?s=Yt(s,f,t):n.add(f.semver);if(n.size>1)return null;let a;if(i&&s&&(a=et(i.semver,s.semver,t),a>0||a===0&&(i.operator!==">="||s.operator!=="<=")))return null;for(const f of n){if(i&&!pe(f,String(i),t)||s&&!pe(f,String(s),t))return null;for(const g of e)if(!pe(f,String(g),t))return!1;return!0}let c,o,l,u,p=s&&!t.includePrerelease&&s.semver.prerelease.length?s.semver:!1,w=i&&!t.includePrerelease&&i.semver.prerelease.length?i.semver:!1;p&&p.prerelease.length===1&&s.operator==="<"&&p.prerelease[0]===0&&(p=!1);for(const f of e){if(u=u||f.operator===">"||f.operator===">=",l=l||f.operator==="<"||f.operator==="<=",i){if(w&&f.semver.prerelease&&f.semver.prerelease.length&&f.semver.major===w.major&&f.semver.minor===w.minor&&f.semver.patch===w.patch&&(w=!1),f.operator===">"||f.operator===">="){if(c=qt(i,f,t),c===f&&c!==i)return!1}else if(i.operator===">="&&!pe(i.semver,String(f),t))return!1}if(s){if(p&&f.semver.prerelease&&f.semver.prerelease.length&&f.semver.major===p.major&&f.semver.minor===p.minor&&f.semver.patch===p.patch&&(p=!1),f.operator==="<"||f.operator==="<="){if(o=Yt(s,f,t),o===f&&o!==s)return!1}else if(s.operator==="<="&&!pe(s.semver,String(f),t))return!1}if(!f.operator&&(s||i)&&a!==0)return!1}return!(i&&l&&!s&&a!==0||s&&u&&!i&&a!==0||w||p)},qt=(r,e,t)=>{if(!r)return e;const n=et(r.semver,e.semver,t);return n>0?r:n<0||e.operator===">"&&r.operator===">="?e:r},Yt=(r,e,t)=>{if(!r)return e;const n=et(r.semver,e.semver,t);return n<0?r:n>0||e.operator==="<"&&r.operator==="<="?e:r};var Kn=zn;const tt=ce,zt=ye,Jn=D,Qt=bt,Zn=ie,ei=Cr,ti=Nr,ri=Lr,ni=Pr,ii=_r,si=Ur,oi=Fr,ai=kr,li=k,ci=Hr,ui=Br,hi=Ve,pi=Yr,fi=Qr,di=Ie,vi=He,gi=Ct,mi=xt,Ei=Xe,yi=Be,bi=Nt,wi=hn,Ri=Ae(),Ii=H();var N={parse:Zn,valid:ei,clean:ti,inc:ri,diff:ni,major:ii,minor:si,patch:oi,prerelease:ai,compare:li,rcompare:ci,compareLoose:ui,compareBuild:hi,sort:pi,rsort:fi,gt:di,lt:vi,eq:gi,neq:mi,gte:Ei,lte:yi,cmp:bi,coerce:wi,Comparator:Ri,Range:Ii,satisfies:Te,toComparators:In,maxSatisfying:On,minSatisfying:Cn,minVersion:Nn,validRange:Pn,outside:Ke,gtr:kn,ltr:Hn,intersects:Xn,simplifyRange:Yn,subset:Kn,SemVer:Jn,re:tt.re,src:tt.src,tokens:tt.t,SEMVER_SPEC_VERSION:zt.SEMVER_SPEC_VERSION,RELEASE_TYPES:zt.RELEASE_TYPES,compareIdentifiers:Qt.compareIdentifiers,rcompareIdentifiers:Qt.rcompareIdentifiers};class L extends Error{constructor(e){super(`Incorrect context (${e}). Cannot perform the requested operation.`),z(this,"context"),this.context=e}}class Ce extends Error{constructor(e,t,n){super(`Invalid parameter (${e}). ${n}`),this.param=e,this.value=t,this.reason=n}}class Si extends Error{constructor(e,t){super(`'streamId' value of "${e}" is different from what we expected ("${t}")`),this.streamId=e,this.expectedStreamId=t}}class Wt extends Error{constructor(e){super(`${e} needs to be initialized before it can be used.`)}}class Kt extends Error{constructor(e,t){let n=`Unsupported Protocol ${Array.isArray(e)?"versions":"version"}: (${e}).`;t&&(n+=` Minimum version supported is ${t}.`),super(n),this.version=e}}var rt=function(r,e){return rt=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])},rt(r,e)};function Q(r,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");rt(r,e);function t(){this.constructor=r}r.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function nt(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function fe(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var n=t.call(r),i,s=[],a;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(c){a={error:c}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(a)throw a.error}}return s}function de(r,e,t){if(t||arguments.length===2)for(var n=0,i=e.length,s;n<i;n++)(s||!(n in e))&&(s||(s=Array.prototype.slice.call(e,0,n)),s[n]=e[n]);return r.concat(s||Array.prototype.slice.call(e))}function F(r){return typeof r=="function"}function Jt(r){var e=function(n){Error.call(n),n.stack=new Error().stack},t=r(e);return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}var it=Jt(function(r){return function(e){r(this),this.message=e?e.length+` errors occurred during unsubscription:
2
- `+e.map(function(t,n){return n+1+") "+t.toString()}).join(`
3
- `):"",this.name="UnsubscriptionError",this.errors=e}});function xe(r,e){if(r){var t=r.indexOf(e);0<=t&&r.splice(t,1)}}var ve=function(){function r(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}return r.prototype.unsubscribe=function(){var e,t,n,i,s;if(!this.closed){this.closed=!0;var a=this._parentage;if(a)if(this._parentage=null,Array.isArray(a))try{for(var c=nt(a),o=c.next();!o.done;o=c.next()){var l=o.value;l.remove(this)}}catch(I){e={error:I}}finally{try{o&&!o.done&&(t=c.return)&&t.call(c)}finally{if(e)throw e.error}}else a.remove(this);var u=this.initialTeardown;if(F(u))try{u()}catch(I){s=I instanceof it?I.errors:[I]}var p=this._finalizers;if(p){this._finalizers=null;try{for(var w=nt(p),f=w.next();!f.done;f=w.next()){var g=f.value;try{tr(g)}catch(I){s=s??[],I instanceof it?s=de(de([],fe(s)),fe(I.errors)):s.push(I)}}}catch(I){n={error:I}}finally{try{f&&!f.done&&(i=w.return)&&i.call(w)}finally{if(n)throw n.error}}}if(s)throw new it(s)}},r.prototype.add=function(e){var t;if(e&&e!==this)if(this.closed)tr(e);else{if(e instanceof r){if(e.closed||e._hasParent(this))return;e._addParent(this)}(this._finalizers=(t=this._finalizers)!==null&&t!==void 0?t:[]).push(e)}},r.prototype._hasParent=function(e){var t=this._parentage;return t===e||Array.isArray(t)&&t.includes(e)},r.prototype._addParent=function(e){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e},r.prototype._removeParent=function(e){var t=this._parentage;t===e?this._parentage=null:Array.isArray(t)&&xe(t,e)},r.prototype.remove=function(e){var t=this._finalizers;t&&xe(t,e),e instanceof r&&e._removeParent(this)},r.EMPTY=function(){var e=new r;return e.closed=!0,e}(),r}(),Zt=ve.EMPTY;function er(r){return r instanceof ve||r&&"closed"in r&&F(r.remove)&&F(r.add)&&F(r.unsubscribe)}function tr(r){F(r)?r():r.unsubscribe()}var rr={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},$i={setTimeout:function(r,e){for(var t=[],n=2;n<arguments.length;n++)t[n-2]=arguments[n];return setTimeout.apply(void 0,de([r,e],fe(t)))},clearTimeout:function(r){return clearTimeout(r)},delegate:void 0};function Oi(r){$i.setTimeout(function(){throw r})}function nr(){}function Ne(r){r()}var st=function(r){Q(e,r);function e(t){var n=r.call(this)||this;return n.isStopped=!1,t?(n.destination=t,er(t)&&t.add(n)):n.destination=xi,n}return e.create=function(t,n,i){return new at(t,n,i)},e.prototype.next=function(t){this.isStopped||this._next(t)},e.prototype.error=function(t){this.isStopped||(this.isStopped=!0,this._error(t))},e.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},e.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,r.prototype.unsubscribe.call(this),this.destination=null)},e.prototype._next=function(t){this.destination.next(t)},e.prototype._error=function(t){try{this.destination.error(t)}finally{this.unsubscribe()}},e.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},e}(ve),Ai=Function.prototype.bind;function ot(r,e){return Ai.call(r,e)}var Ti=function(){function r(e){this.partialObserver=e}return r.prototype.next=function(e){var t=this.partialObserver;if(t.next)try{t.next(e)}catch(n){Le(n)}},r.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(n){Le(n)}else Le(e)},r.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(t){Le(t)}},r}(),at=function(r){Q(e,r);function e(t,n,i){var s=r.call(this)||this,a;if(F(t)||!t)a={next:t??void 0,error:n??void 0,complete:i??void 0};else{var c;s&&rr.useDeprecatedNextContext?(c=Object.create(t),c.unsubscribe=function(){return s.unsubscribe()},a={next:t.next&&ot(t.next,c),error:t.error&&ot(t.error,c),complete:t.complete&&ot(t.complete,c)}):a=t}return s.destination=new Ti(a),s}return e}(st);function Le(r){Oi(r)}function Ci(r){throw r}var xi={closed:!0,next:nr,error:Ci,complete:nr},Ni=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function ir(r){return r}function Li(r){return r.length===0?ir:r.length===1?r[0]:function(e){return r.reduce(function(t,n){return n(t)},e)}}var Pe=function(){function r(e){e&&(this._subscribe=e)}return r.prototype.lift=function(e){var t=new r;return t.source=this,t.operator=e,t},r.prototype.subscribe=function(e,t,n){var i=this,s=Mi(e)?e:new at(e,t,n);return Ne(function(){var a=i,c=a.operator,o=a.source;s.add(c?c.call(s,o):o?i._subscribe(s):i._trySubscribe(s))}),s},r.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){e.error(t)}},r.prototype.forEach=function(e,t){var n=this;return t=sr(t),new t(function(i,s){var a=new at({next:function(c){try{e(c)}catch(o){s(o),a.unsubscribe()}},error:s,complete:i});n.subscribe(a)})},r.prototype._subscribe=function(e){var t;return(t=this.source)===null||t===void 0?void 0:t.subscribe(e)},r.prototype[Ni]=function(){return this},r.prototype.pipe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Li(e)(this)},r.prototype.toPromise=function(e){var t=this;return e=sr(e),new e(function(n,i){var s;t.subscribe(function(a){return s=a},function(a){return i(a)},function(){return n(s)})})},r.create=function(e){return new r(e)},r}();function sr(r){var e;return(e=r??rr.Promise)!==null&&e!==void 0?e:Promise}function Pi(r){return r&&F(r.next)&&F(r.error)&&F(r.complete)}function Mi(r){return r&&r instanceof st||Pi(r)&&er(r)}function _i(r){return F(r==null?void 0:r.lift)}function Me(r){return function(e){if(_i(e))return e.lift(function(t){try{return r(t,this)}catch(n){this.error(n)}});throw new TypeError("Unable to lift unknown Observable type")}}function _e(r,e,t,n,i){return new Di(r,e,t,n,i)}var Di=function(r){Q(e,r);function e(t,n,i,s,a,c){var o=r.call(this,t)||this;return o.onFinalize=a,o.shouldUnsubscribe=c,o._next=n?function(l){try{n(l)}catch(u){t.error(u)}}:r.prototype._next,o._error=s?function(l){try{s(l)}catch(u){t.error(u)}finally{this.unsubscribe()}}:r.prototype._error,o._complete=i?function(){try{i()}catch(l){t.error(l)}finally{this.unsubscribe()}}:r.prototype._complete,o}return e.prototype.unsubscribe=function(){var t;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var n=this.closed;r.prototype.unsubscribe.call(this),!n&&((t=this.onFinalize)===null||t===void 0||t.call(this))}},e}(st),Ui=Jt(function(r){return function(){r(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),or=function(r){Q(e,r);function e(){var t=r.call(this)||this;return t.closed=!1,t.currentObservers=null,t.observers=[],t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}return e.prototype.lift=function(t){var n=new ar(this,this);return n.operator=t,n},e.prototype._throwIfClosed=function(){if(this.closed)throw new Ui},e.prototype.next=function(t){var n=this;Ne(function(){var i,s;if(n._throwIfClosed(),!n.isStopped){n.currentObservers||(n.currentObservers=Array.from(n.observers));try{for(var a=nt(n.currentObservers),c=a.next();!c.done;c=a.next()){var o=c.value;o.next(t)}}catch(l){i={error:l}}finally{try{c&&!c.done&&(s=a.return)&&s.call(a)}finally{if(i)throw i.error}}}})},e.prototype.error=function(t){var n=this;Ne(function(){if(n._throwIfClosed(),!n.isStopped){n.hasError=n.isStopped=!0,n.thrownError=t;for(var i=n.observers;i.length;)i.shift().error(t)}})},e.prototype.complete=function(){var t=this;Ne(function(){if(t._throwIfClosed(),!t.isStopped){t.isStopped=!0;for(var n=t.observers;n.length;)n.shift().complete()}})},e.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(e.prototype,"observed",{get:function(){var t;return((t=this.observers)===null||t===void 0?void 0:t.length)>0},enumerable:!1,configurable:!0}),e.prototype._trySubscribe=function(t){return this._throwIfClosed(),r.prototype._trySubscribe.call(this,t)},e.prototype._subscribe=function(t){return this._throwIfClosed(),this._checkFinalizedStatuses(t),this._innerSubscribe(t)},e.prototype._innerSubscribe=function(t){var n=this,i=this,s=i.hasError,a=i.isStopped,c=i.observers;return s||a?Zt:(this.currentObservers=null,c.push(t),new ve(function(){n.currentObservers=null,xe(c,t)}))},e.prototype._checkFinalizedStatuses=function(t){var n=this,i=n.hasError,s=n.thrownError,a=n.isStopped;i?t.error(s):a&&t.complete()},e.prototype.asObservable=function(){var t=new Pe;return t.source=this,t},e.create=function(t,n){return new ar(t,n)},e}(Pe),ar=function(r){Q(e,r);function e(t,n){var i=r.call(this)||this;return i.destination=t,i.source=n,i}return e.prototype.next=function(t){var n,i;(i=(n=this.destination)===null||n===void 0?void 0:n.next)===null||i===void 0||i.call(n,t)},e.prototype.error=function(t){var n,i;(i=(n=this.destination)===null||n===void 0?void 0:n.error)===null||i===void 0||i.call(n,t)},e.prototype.complete=function(){var t,n;(n=(t=this.destination)===null||t===void 0?void 0:t.complete)===null||n===void 0||n.call(t)},e.prototype._subscribe=function(t){var n,i;return(i=(n=this.source)===null||n===void 0?void 0:n.subscribe(t))!==null&&i!==void 0?i:Zt},e}(or),ji={now:function(){return Date.now()},delegate:void 0},Fi=function(r){Q(e,r);function e(t,n){return r.call(this)||this}return e.prototype.schedule=function(t,n){return this},e}(ve),lt={setInterval:function(r,e){for(var t=[],n=2;n<arguments.length;n++)t[n-2]=arguments[n];var i=lt.delegate;return i!=null&&i.setInterval?i.setInterval.apply(i,de([r,e],fe(t))):setInterval.apply(void 0,de([r,e],fe(t)))},clearInterval:function(r){return clearInterval(r)},delegate:void 0},Gi=function(r){Q(e,r);function e(t,n){var i=r.call(this,t,n)||this;return i.scheduler=t,i.work=n,i.pending=!1,i}return e.prototype.schedule=function(t,n){var i;if(n===void 0&&(n=0),this.closed)return this;this.state=t;var s=this.id,a=this.scheduler;return s!=null&&(this.id=this.recycleAsyncId(a,s,n)),this.pending=!0,this.delay=n,this.id=(i=this.id)!==null&&i!==void 0?i:this.requestAsyncId(a,this.id,n),this},e.prototype.requestAsyncId=function(t,n,i){return i===void 0&&(i=0),lt.setInterval(t.flush.bind(t,this),i)},e.prototype.recycleAsyncId=function(t,n,i){if(i===void 0&&(i=0),i!=null&&this.delay===i&&this.pending===!1)return n;n!=null&&lt.clearInterval(n)},e.prototype.execute=function(t,n){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var i=this._execute(t,n);if(i)return i;this.pending===!1&&this.id!=null&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},e.prototype._execute=function(t,n){var i=!1,s;try{this.work(t)}catch(a){i=!0,s=a||new Error("Scheduled action threw falsy error")}if(i)return this.unsubscribe(),s},e.prototype.unsubscribe=function(){if(!this.closed){var t=this,n=t.id,i=t.scheduler,s=i.actions;this.work=this.state=this.scheduler=null,this.pending=!1,xe(s,this),n!=null&&(this.id=this.recycleAsyncId(i,n,null)),this.delay=null,r.prototype.unsubscribe.call(this)}},e}(Fi),lr=function(){function r(e,t){t===void 0&&(t=r.now),this.schedulerActionCtor=e,this.now=t}return r.prototype.schedule=function(e,t,n){return t===void 0&&(t=0),new this.schedulerActionCtor(this,e).schedule(n,t)},r.now=ji.now,r}(),ki=function(r){Q(e,r);function e(t,n){n===void 0&&(n=lr.now);var i=r.call(this,t,n)||this;return i.actions=[],i._active=!1,i}return e.prototype.flush=function(t){var n=this.actions;if(this._active){n.push(t);return}var i;this._active=!0;do if(i=t.execute(t.state,t.delay))break;while(t=n.shift());if(this._active=!1,i){for(;t=n.shift();)t.unsubscribe();throw i}},e}(lr),Vi=new ki(Gi),Hi=Vi,Xi=new Pe(function(r){return r.complete()});function Bi(r){return r&&F(r.schedule)}function qi(r){return r instanceof Date&&!isNaN(r)}function C(r,e){return Me(function(t,n){var i=0;t.subscribe(_e(n,function(s){n.next(r.call(e,s,i++))}))})}function Yi(r,e,t){r===void 0&&(r=0),t===void 0&&(t=Hi);var n=-1;return e!=null&&(Bi(e)?t=e:n=e),new Pe(function(i){var s=qi(r)?+r-t.now():r;s<0&&(s=0);var a=0;return t.schedule(function(){i.closed||(i.next(a++),0<=n?this.schedule(void 0,n):i.complete())},s)})}function U(r,e){return Me(function(t,n){var i=0;t.subscribe(_e(n,function(s){return r.call(e,s,i++)&&n.next(s)}))})}function Y(r){return r<=0?function(){return Xi}:Me(function(e,t){var n=0;e.subscribe(_e(t,function(i){++n<=r&&(t.next(i),r<=n&&t.complete())}))})}function _(r,e,t){var n=F(r)||e||t?{next:r,error:e,complete:t}:r;return n?Me(function(i,s){var a;(a=n.subscribe)===null||a===void 0||a.call(n);var c=!0;i.subscribe(_e(s,function(o){var l;(l=n.next)===null||l===void 0||l.call(n,o),s.next(o)},function(){var o;c=!1,(o=n.complete)===null||o===void 0||o.call(n),s.complete()},function(o){var l;c=!1,(l=n.error)===null||l===void 0||l.call(n,o),s.error(o)},function(){var o,l;c&&((o=n.unsubscribe)===null||o===void 0||o.call(n)),(l=n.finalize)===null||l===void 0||l.call(n)}))}):ir}class ee{static gte(e,t){return t===void 0?n=>ee.gte(n,e)?n:!1:N.gte(N.coerce(e),N.coerce(t))}static lte(e,t){return t===void 0?n=>ee.lte(n,e)?n:!1:N.lte(N.coerce(e),N.coerce(t))}static gt(e,t){return t===void 0?n=>ee.gt(n,e)?n:!1:N.gt(N.coerce(e),N.coerce(t))}static lt(e,t){return t===void 0?n=>ee.lt(n,e)?n:!1:N.lt(N.coerce(e),N.coerce(t))}static eq(e,t){return N.eq(N.coerce(e),N.coerce(t))}static neq(e,t){return N.neq(N.coerce(e),N.coerce(t))}static compare(e,t){return N.compare(N.coerce(e),N.coerce(t))}}const cr="1.0";class zi{constructor(e,t){if(z(this,"negotiatedProtocolVersion"),z(this,"currentContext"),z(this,"incomingMessages$"),z(this,"inIframe",!1),z(this,"embeddedResult"),z(this,"iframePort1"),z(this,"iframePort2"),this.supportedVersions=e,this.logService=t,this.incomingMessages$=new or,this.supportedVersions=e.filter(ee.gte(cr)),!this.supportedVersions.length)throw new Kt(e,cr);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 e,t;return this.inIframe?this.iframePort1:(t=(e=window.Acrobits)==null?void 0:e.messageChannel)==null?void 0:t.port1}get port2(){var e,t,n,i;if(this.inIframe){if(!this.iframePort2)throw new Wt("port2");return this.iframePort2}else{if(!((t=(e=window.Acrobits)==null?void 0:e.messageChannel)!=null&&t.port2))throw new Wt("port2");return(i=(n=window.Acrobits)==null?void 0:n.messageChannel)==null?void 0:i.port2}}determineContext(){return Yi(1e3).pipe(C(()=>(this.isEmbedded()?this.currentContext="user":this.currentContext="guest",this.currentContext)),Y(1))}openBridge(){if(!this.isEmbedded())throw new L(this.currentContext);const e="HELLO",t=this.createMessage(e);t.protocolVersions=this.supportedVersions,this.logCreated(e,t);const n=this.incomingMessages$.pipe(U(i=>i.type===e&&i.replyTo===t.id),C(i=>i),_(this.logReceived(e)),C(i=>{if(this.supportedVersions.some(ee.gt(i.protocolVersion)))throw new Kt(i.protocolVersion,this.supportedVersions[0]);return i}),_(i=>{this.negotiatedProtocolVersion=i.protocolVersion,this.logService.info(`[IPC] Negotiated IPC Protocol Version: ${this.negotiatedProtocolVersion}`)}),Y(1));return this.logService.debug(`Created ${e} Reply handler`),this.inIframe?this.createIframeChannel().then(()=>this.finishIpcSetup(t)):this.finishIpcSetup(t),n}requestSSOToken(){if(!this.isEmbedded())throw new L(this.currentContext);const e="TOKEN",t=this.createMessage(e);this.logCreated(e,t);const n=this.incomingMessages$.pipe(U(i=>i.type===e&&i.replyTo===t.id),C(i=>i),_(this.logReceived(e)),Y(1));return this.logService.debug(`Created ${e} Reply handler`),this.port2.postMessage(t),this.logSent(e,t),n}sendJoiningRoomMessage(e){if(!this.isEmbedded())throw new L(this.currentContext);const{roomName:t,roomInvite:n,displayName:i,jwtToken:s,serverUrl:a,region:c,joinMicMuted:o,joinWithoutCamera:l}=e,u="JOINING ROOM",p=this.createMessage(u,!1);p.roomName=t,p.jwtToken=s,p.serverUrl=a,p.region=c,p.roomInvite=n,p.joinMicMuted=o??!1,p.joinWithoutCamera=l??!1,p.displayName=i,this.logCreated(u,p),this.port2.postMessage(p),this.logSent(u,p)}sendLeavingRoomMessage(e){if(!this.isEmbedded())throw new L(this.currentContext);const t="LEAVING ROOM",n=this.createMessage(t,!1);n.roomName=e,this.logCreated(t,n),this.port2.postMessage(n),this.logSent(t,n)}onJoinRoomMessage(){if(!this.isEmbedded())throw new L(this.currentContext);const e="JOIN ROOM";return this.incomingMessages$.pipe(U(t=>t.type===e&&t.target==="client"),C(t=>t),_(this.logReceived(e)),C(t=>t))}onLeaveRoomMessage(){if(!this.isEmbedded())throw new L(this.currentContext);const e="LEAVE ROOM";return this.incomingMessages$.pipe(U(t=>t.type===e&&t.target==="client"),C(t=>t),_(this.logReceived(e)),C(t=>t))}onConfigMessage(){if(!this.isEmbedded())throw new L(this.currentContext);const e="CONFIG";return this.incomingMessages$.pipe(U(t=>t.type===e&&t.target==="client"),C(t=>t),_(this.logReceived(e)),C(t=>({preferredCameraType:t.preferredCameraType,preferredMicType:t.preferredMicType,preferredOutputType:t.preferredOutputType,preferredCameraDeviceLabel:t.preferredCameraDeviceLabel,preferredMicDeviceLabel:t.preferredMicDeviceLabel,preferredOutputDeviceLabel:t.preferredOutputDeviceLabel,performanceProfile:t.performanceProfile,cloudUsername:t.cloudUsername,configuredOAuthProviders:t.configuredOAuthProviders,locales:t.locales?[...t.locales]:[]})))}sendScreenshareSourceMessage(e){if(!this.isEmbedded())throw new L(this.currentContext);const t="SCREENSHARE SOURCE",n=this.createMessage(t);n.sourceTypes=e,this.logCreated(t,n);const i=this.incomingMessages$.pipe(U(s=>s.type===t&&s.replyTo===n.id),C(s=>s),_(this.logReceived(t)),C(s=>s),Y(1));return this.logService.debug(`Created ${t} Reply handler`),this.port2.postMessage(n),this.logSent(t,n),i}layoutChange(e,t,n){if(!this.isEmbedded())throw new L(this.currentContext);const i="LAYOUT CHANGE";let s,a;if(t&&n?(s=this.createMessage(i,!1,n),s.result=t):(s=this.createMessage(i),a=this.incomingMessages$.pipe(U(c=>c.type===i&&c.replyTo===s.id),C(c=>c),_(this.logReceived(i)),C(c=>c),Y(1)),this.logService.debug(`Created ${i} Reply handler`)),s.layout=e,this.logCreated(i,s),this.port2.postMessage(s),this.logSent(i,s),a)return a}onLayoutChangeMessage(){if(!this.isEmbedded())throw new L(this.currentContext);const e="LAYOUT CHANGE";return this.incomingMessages$.pipe(U(t=>t.type===e&&t.target==="client"&&t.replyTo===null),C(t=>t),_(this.logReceived(e)),C(t=>t))}requestOAuthToken(e){if(!this.isEmbedded())throw new L(this.currentContext);Array.isArray(e)||(e=[e]);const t="OAUTH TOKEN",n=this.createMessage(t);n.providerTypes=e,this.logCreated(t,n);const i=this.incomingMessages$.pipe(U(s=>s.type===t&&s.replyTo===n.id),C(s=>s),_(this.logReceived(t)),Y(1));return this.logService.debug(`Created ${t} Reply handler`),this.port2.postMessage(n),this.logSent(t,n),i}openUrl(e,t){if(!this.isEmbedded())throw new L(this.currentContext);const n="OPEN URL",i=this.createMessage(n,!1);i.url=e,i.data=t,this.logCreated(n,i),this.port2.postMessage(i),this.logSent(n,i)}selectContacts(e,t,n){if(!this.isEmbedded())throw new L(this.currentContext);if(t==="group"&&n===void 0)throw new Ce("currentContacts",n,"currentContacts is required for group streams");if(t==="direct"&&n!==void 0)throw new Ce("currentContacts",n,"currentContacts should not be passed for direct streams");const i="SELECT CONTACTS",s=this.createMessage(i,!0);s.streamType=t,s.streamId=e,s.currentContacts=n,this.logCreated(i,s);const a=this.incomingMessages$.pipe(U(c=>c.type===i&&c.replyTo===s.id),_(this.logReceived(i)),C(c=>{const o=c;if(o.streamId!==e)throw new Si(o.streamId,e);return t==="direct"&&o.contacts.length>1&&(o.contacts=[o.contacts[0]]),o}),Y(1));return this.logService.debug(`Created ${i} Reply handler`),this.port2.postMessage(s),this.logSent(i,s),a}matchContacts(e){if(!this.isEmbedded())throw new L(this.currentContext);if(!e.length)throw new Ce("contacts",e,"At least one contact is required");const t="MATCH CONTACTS",n=this.createMessage(t);n.contacts=[...e],this.logCreated(t,n);const i=this.incomingMessages$.pipe(U(s=>s.type===t&&s.replyTo===n.id),_(this.logReceived(t)),C(s=>s),Y(1));return this.logService.debug(`Created ${t} Reply handler`),this.port2.postMessage(n),this.logSent(t,n),i}onPushMessageMessage(){if(!this.isEmbedded())throw new L(this.currentContext);const e="PUSH MESSAGE";return this.incomingMessages$.pipe(U(t=>t.type===e&&t.target==="client"),C(t=>t),_(this.logReceived(e)))}requestPushToken(){if(!this.isEmbedded())throw new L(this.currentContext);const e="PUSH TOKEN",t=this.createMessage(e);this.logCreated(e,t);const n=this.incomingMessages$.pipe(U(i=>i.type===e&&i.replyTo===t.id),_(this.logReceived(e)),C(i=>i),Y(1));return this.logService.debug(`Created ${e} Reply handler`),this.port2.postMessage(t),this.logSent(e,t),n}onBadgeQueryMessage(){if(!this.isEmbedded())throw new L(this.currentContext);const e="BADGE QUERY";return this.incomingMessages$.pipe(U(t=>t.type===e&&t.target==="client"),C(t=>t),_(this.logReceived(e)))}sendBadgeUpdateMessage(e,t){if(!this.isEmbedded())throw new L(this.currentContext);const n="BADGE UPDATE",i=this.createMessage(n,!1,t);i.count=e,this.logCreated(n,i),this.port2.postMessage(i),this.logSent(n,i)}onHostInForegroundMessage(){if(!this.isEmbedded())throw new L(this.currentContext);const e="HOST IN FOREGROUND";return this.incomingMessages$.pipe(U(t=>t.type===e&&t.target==="client"),C(t=>t),_(this.logReceived(e)))}isEmbedded(){if(this.embeddedResult!==null)return this.embeddedResult;let e=!1;return this.logService.debug("Checking if running in iframe..."),e=!!this.frameElement,e||(e=this.self!==this.parent),e?(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..."),!e&&(e=!!window.Acrobits,e)?(this.logService.debug("In native app"),this.embeddedResult=!0,e):(this.logService.debug("Not running in native app"),this.embeddedResult=!1,this.embeddedResult))}logReceived(e,t){const n=i=>this.logService.debug(`[IPC] Received ${e} message`,i);return t&&n(t),n}logSent(e,t){this.logService.debug(`[IPC] Sent ${e} message`,t)}logCreated(e,t){this.logService.debug(`[IPC] Created ${e} message`,t)}async createIframeChannel(){return new Promise(e=>{const t=n=>{n.data==="message channel port"&&(this.iframePort2=n.ports[0],this.self.removeEventListener("message",t),e())};this.self.addEventListener("message",t),this.parent.postMessage("get channel","*")})}finishIpcSetup(e){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(e),this.logSent("HELLO",e)}handleIpcMessage(e){const{data:t}=e;!t.id||t.target!=="client"||this.incomingMessages$.next(t)}createMessage(e,t=!0,n){return{type:e,id:this.generateId(),target:"host",expectReply:t,replyTo:n??null}}generateId(e=8,t=!1){let n="1234567890qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM";const i=[];t&&(n=n.substr(0,n.indexOf("Q")));for(let s=0;s<e;s++)i.push(n[Math.floor(Math.random()*n.length)]);return i.join("")}}var ct=function(r,e){return ct=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])},ct(r,e)};function ut(r,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");ct(r,e);function t(){this.constructor=r}r.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function ur(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],n=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function De(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var n=t.call(r),i,s=[],a;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(c){a={error:c}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(a)throw a.error}}return s}function Ue(r,e,t){if(t||arguments.length===2)for(var n=0,i=e.length,s;n<i;n++)(s||!(n in e))&&(s||(s=Array.prototype.slice.call(e,0,n)),s[n]=e[n]);return r.concat(s||Array.prototype.slice.call(e))}function W(r){return typeof r=="function"}function hr(r){var e=function(n){Error.call(n),n.stack=new Error().stack},t=r(e);return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}var ht=hr(function(r){return function(t){r(this),this.message=t?t.length+` errors occurred during unsubscription:
4
- `+t.map(function(n,i){return i+1+") "+n.toString()}).join(`
5
- `):"",this.name="UnsubscriptionError",this.errors=t}});function pr(r,e){if(r){var t=r.indexOf(e);0<=t&&r.splice(t,1)}}var pt=function(){function r(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}return r.prototype.unsubscribe=function(){var e,t,n,i,s;if(!this.closed){this.closed=!0;var a=this._parentage;if(a)if(this._parentage=null,Array.isArray(a))try{for(var c=ur(a),o=c.next();!o.done;o=c.next()){var l=o.value;l.remove(this)}}catch(I){e={error:I}}finally{try{o&&!o.done&&(t=c.return)&&t.call(c)}finally{if(e)throw e.error}}else a.remove(this);var u=this.initialTeardown;if(W(u))try{u()}catch(I){s=I instanceof ht?I.errors:[I]}var p=this._finalizers;if(p){this._finalizers=null;try{for(var w=ur(p),f=w.next();!f.done;f=w.next()){var g=f.value;try{fr(g)}catch(I){s=s??[],I instanceof ht?s=Ue(Ue([],De(s)),De(I.errors)):s.push(I)}}}catch(I){n={error:I}}finally{try{f&&!f.done&&(i=w.return)&&i.call(w)}finally{if(n)throw n.error}}}if(s)throw new ht(s)}},r.prototype.add=function(e){var t;if(e&&e!==this)if(this.closed)fr(e);else{if(e instanceof r){if(e.closed||e._hasParent(this))return;e._addParent(this)}(this._finalizers=(t=this._finalizers)!==null&&t!==void 0?t:[]).push(e)}},r.prototype._hasParent=function(e){var t=this._parentage;return t===e||Array.isArray(t)&&t.includes(e)},r.prototype._addParent=function(e){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e},r.prototype._removeParent=function(e){var t=this._parentage;t===e?this._parentage=null:Array.isArray(t)&&pr(t,e)},r.prototype.remove=function(e){var t=this._finalizers;t&&pr(t,e),e instanceof r&&e._removeParent(this)},r.EMPTY=function(){var e=new r;return e.closed=!0,e}(),r}();pt.EMPTY;function Qi(r){return r instanceof pt||r&&"closed"in r&&W(r.remove)&&W(r.add)&&W(r.unsubscribe)}function fr(r){W(r)?r():r.unsubscribe()}var Wi={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},ft={setTimeout:function(r,e){for(var t=[],n=2;n<arguments.length;n++)t[n-2]=arguments[n];var i=ft.delegate;return i!=null&&i.setTimeout?i.setTimeout.apply(i,Ue([r,e],De(t))):setTimeout.apply(void 0,Ue([r,e],De(t)))},clearTimeout:function(r){var e=ft.delegate;return((e==null?void 0:e.clearTimeout)||clearTimeout)(r)},delegate:void 0};function Ki(r){ft.setTimeout(function(){throw r})}function dr(){}var vr=function(r){ut(e,r);function e(t){var n=r.call(this)||this;return n.isStopped=!1,t?(n.destination=t,Qi(t)&&t.add(n)):n.destination=ts,n}return e.create=function(t,n,i){return new gr(t,n,i)},e.prototype.next=function(t){this.isStopped||this._next(t)},e.prototype.error=function(t){this.isStopped||(this.isStopped=!0,this._error(t))},e.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},e.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,r.prototype.unsubscribe.call(this),this.destination=null)},e.prototype._next=function(t){this.destination.next(t)},e.prototype._error=function(t){try{this.destination.error(t)}finally{this.unsubscribe()}},e.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},e}(pt),Ji=Function.prototype.bind;function dt(r,e){return Ji.call(r,e)}var Zi=function(){function r(e){this.partialObserver=e}return r.prototype.next=function(e){var t=this.partialObserver;if(t.next)try{t.next(e)}catch(n){je(n)}},r.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(n){je(n)}else je(e)},r.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(t){je(t)}},r}(),gr=function(r){ut(e,r);function e(t,n,i){var s=r.call(this)||this,a;if(W(t)||!t)a={next:t??void 0,error:n??void 0,complete:i??void 0};else{var c;s&&Wi.useDeprecatedNextContext?(c=Object.create(t),c.unsubscribe=function(){return s.unsubscribe()},a={next:t.next&&dt(t.next,c),error:t.error&&dt(t.error,c),complete:t.complete&&dt(t.complete,c)}):a=t}return s.destination=new Zi(a),s}return e}(vr);function je(r){Ki(r)}function es(r){throw r}var ts={closed:!0,next:dr,error:es,complete:dr};function rs(r){return r}function ns(r){return W(r==null?void 0:r.lift)}function mr(r){return function(e){if(ns(e))return e.lift(function(t){try{return r(t,this)}catch(n){this.error(n)}});throw new TypeError("Unable to lift unknown Observable type")}}function Er(r,e,t,n,i){return new is(r,e,t,n,i)}var is=function(r){ut(e,r);function e(t,n,i,s,a,c){var o=r.call(this,t)||this;return o.onFinalize=a,o.shouldUnsubscribe=c,o._next=n?function(l){try{n(l)}catch(u){t.error(u)}}:r.prototype._next,o._error=s?function(l){try{s(l)}catch(u){t.error(u)}finally{this.unsubscribe()}}:r.prototype._error,o._complete=i?function(){try{i()}catch(l){t.error(l)}finally{this.unsubscribe()}}:r.prototype._complete,o}return e.prototype.unsubscribe=function(){var t;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var n=this.closed;r.prototype.unsubscribe.call(this),!n&&((t=this.onFinalize)===null||t===void 0||t.call(this))}},e}(vr),ss=hr(function(r){return function(){r(this),this.name="EmptyError",this.message="no elements in sequence"}});function ge(r,e){var t=typeof e=="object";return new Promise(function(n,i){var s=new gr({next:function(a){n(a),s.unsubscribe()},error:i,complete:function(){t?n(e.defaultValue):i(new ss)}});r.subscribe(s)})}function Fe(r,e){return mr(function(t,n){var i=0;t.subscribe(Er(n,function(s){n.next(r.call(e,s,i++))}))})}function os(r,e,t){var n=W(r)||e||t?{next:r,error:e,complete:t}:r;return n?mr(function(i,s){var a;(a=n.subscribe)===null||a===void 0||a.call(n);var c=!0;i.subscribe(Er(s,function(o){var l;(l=n.next)===null||l===void 0||l.call(n,o),s.next(o)},function(){var o;c=!1,(o=n.complete)===null||o===void 0||o.call(n),s.complete()},function(o){var l;c=!1,(l=n.error)===null||l===void 0||l.call(n,o),s.error(o)},function(){var o,l;c&&((o=n.unsubscribe)===null||o===void 0||o.call(n)),(l=n.finalize)===null||l===void 0||l.call(n)}))}):rs}function as(){try{return import("@acrobits/log-helper").then(r=>r.LogHelper.getLogger("IpcSDK"))}catch{return Promise.resolve(console)}}const ls=["1.0"];class cs{constructor(e){yr(this,me);le(this,"host");le(this,"cloudId");le(this,"logger");le(this,"helper");le(this,"listeners");e?this.logger=e:(this.logger=console,as().then(t=>{this.logger=t})),this.helper=new zi(ls,this.logger),this.listeners=new Map,this.listeners.set($.BadgeQuery,new Set),this.listeners.set($.HostInForeground,new Set)}get context(){return vt(this,me,gt).call(this,this.helper.currentContext)}get isConnected(){return!!(this.helper.currentContext==="user"&&this.host&&this.cloudId)}get negotiatedVersion(){return this.helper.negotiatedProtocolVersion}async determineContext(){const e=await ge(this.helper.determineContext(),{defaultValue:"guest"});return vt(this,me,gt).call(this,e)}initiateConnection(){return ge(this.helper.openBridge().pipe(os(e=>{this.helper.onBadgeQueryMessage().subscribe(t=>{var n;this.logger.debug("Received Badge Query: ",t);for(const i of((n=this.listeners.get($.BadgeQuery))==null?void 0:n.values())??[])i()}),this.helper.onHostInForegroundMessage().subscribe(t=>{var n;this.logger.debug("Received Host In Foreground: ",t);for(const i of((n=this.listeners.get($.HostInForeground))==null?void 0:n.values())??[])i()}),this.cloudId=e.cloudId,this.host=e.host}),Fe(()=>{})))}selectContacts(e,t,n){this.logger.debug("Selecting Contacts: ",...arguments);let i;if(t==="multi"){if(!n)throw new Ce("currentContacts",n,"currentContacts is required for group streams");i=this.helper.selectContacts(e.toString(),"group",n)}else i=this.helper.selectContacts(e.toString(),"direct");return ge(i.pipe(Fe(s=>s.contacts)))}matchContacts(e){return this.logger.debug("Match Contacts: ",e),ge(this.helper.matchContacts(e).pipe(Fe(t=>t.contacts)))}requestPushToken(){return this.logger.debug("Requesting Push Token"),ge(this.helper.requestPushToken().pipe(Fe(e=>e.pushToken)))}badgeUpdate(e){this.logger.debug("Sending Badge Update: ",e),this.helper.sendBadgeUpdateMessage(e)}onBadgeQueryRequest(e){var t;return this.logger.debug("Registering for Badge Query"),(t=this.listeners.get($.BadgeQuery))==null||t.add(e),()=>{var n;return(n=this.listeners.get($.BadgeQuery))==null?void 0:n.delete(e)}}onHostInForeground(e){var t;return this.logger.debug("Registering for Host In Foreground"),(t=this.listeners.get($.HostInForeground))==null||t.add(e),()=>{var n;return(n=this.listeners.get($.HostInForeground))==null?void 0:n.delete(e)}}}me=new WeakSet,gt=function(e){if(e==="user")return"host";if(e==="guest")return"standalone"},x.IPCEvents=$,x.IPCManager=cs,Object.defineProperty(x,Symbol.toStringTag,{value:"Module"})});
1
+ var Tt=Object.defineProperty;var At=(p,l,y)=>l in p?Tt(p,l,{enumerable:!0,configurable:!0,writable:!0,value:y}):p[l]=y;var P=(p,l,y)=>(At(p,typeof l!="symbol"?l+"":l,y),y),Rt=(p,l,y)=>{if(!l.has(p))throw TypeError("Cannot "+y)};var $e=(p,l,y)=>{if(l.has(p))throw TypeError("Cannot add the same private member more than once");l instanceof WeakSet?l.add(p):l.set(p,y)};var se=(p,l,y)=>(Rt(p,l,"access private method"),y);(function(p,l){typeof exports=="object"&&typeof module<"u"?l(exports):typeof define=="function"&&define.amd?define(["exports"],l):(p=typeof globalThis<"u"?globalThis:p||self,l(p["@acrobits/ipc-sdk"]={}))})(this,function(p){var R,ue;"use strict";var l=(n=>(n.BadgeQuery="BADGE QUERY",n.HostInForeground="HOST IN FOREGROUND",n))(l||{}),y=function(n,t){return y=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])},y(n,t)};function _(n,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");y(n,t);function e(){this.constructor=n}n.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}function N(n){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&n[t],r=0;if(e)return e.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&r>=n.length&&(n=void 0),{value:n&&n[r++],done:!n}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function I(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var r=e.call(n),i,o=[],s;try{for(;(t===void 0||t-- >0)&&!(i=r.next()).done;)o.push(i.value)}catch(c){s={error:c}}finally{try{i&&!i.done&&(e=r.return)&&e.call(r)}finally{if(s)throw s.error}}return o}function O(n,t,e){if(e||arguments.length===2)for(var r=0,i=t.length,o;r<i;r++)(o||!(r in t))&&(o||(o=Array.prototype.slice.call(t,0,r)),o[r]=t[r]);return n.concat(o||Array.prototype.slice.call(t))}function w(n){return typeof n=="function"}function q(n){var t=function(r){Error.call(r),r.stack=new Error().stack},e=n(t);return e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,e}var z=q(function(n){return function(e){n(this),this.message=e?e.length+` errors occurred during unsubscription:
2
+ `+e.map(function(r,i){return i+1+") "+r.toString()}).join(`
3
+ `):"",this.name="UnsubscriptionError",this.errors=e}});function U(n,t){if(n){var e=n.indexOf(t);0<=e&&n.splice(e,1)}}var T=function(){function n(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}return n.prototype.unsubscribe=function(){var t,e,r,i,o;if(!this.closed){this.closed=!0;var s=this._parentage;if(s)if(this._parentage=null,Array.isArray(s))try{for(var c=N(s),u=c.next();!u.done;u=c.next()){var a=u.value;a.remove(this)}}catch(d){t={error:d}}finally{try{u&&!u.done&&(e=c.return)&&e.call(c)}finally{if(t)throw t.error}}else s.remove(this);var v=this.initialTeardown;if(w(v))try{v()}catch(d){o=d instanceof z?d.errors:[d]}var g=this._finalizers;if(g){this._finalizers=null;try{for(var x=N(g),C=x.next();!C.done;C=x.next()){var oe=C.value;try{le(oe)}catch(d){o=o??[],d instanceof z?o=O(O([],I(o)),I(d.errors)):o.push(d)}}}catch(d){r={error:d}}finally{try{C&&!C.done&&(i=x.return)&&i.call(x)}finally{if(r)throw r.error}}}if(o)throw new z(o)}},n.prototype.add=function(t){var e;if(t&&t!==this)if(this.closed)le(t);else{if(t instanceof n){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=(e=this._finalizers)!==null&&e!==void 0?e:[]).push(t)}},n.prototype._hasParent=function(t){var e=this._parentage;return e===t||Array.isArray(e)&&e.includes(t)},n.prototype._addParent=function(t){var e=this._parentage;this._parentage=Array.isArray(e)?(e.push(t),e):e?[e,t]:t},n.prototype._removeParent=function(t){var e=this._parentage;e===t?this._parentage=null:Array.isArray(e)&&U(e,t)},n.prototype.remove=function(t){var e=this._finalizers;e&&U(e,t),t instanceof n&&t._removeParent(this)},n.EMPTY=function(){var t=new n;return t.closed=!0,t}(),n}(),ce=T.EMPTY;function ae(n){return n instanceof T||n&&"closed"in n&&w(n.remove)&&w(n.add)&&w(n.unsubscribe)}function le(n){w(n)?n():n.unsubscribe()}var he={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},Q={setTimeout:function(n,t){for(var e=[],r=2;r<arguments.length;r++)e[r-2]=arguments[r];var i=Q.delegate;return i!=null&&i.setTimeout?i.setTimeout.apply(i,O([n,t],I(e))):setTimeout.apply(void 0,O([n,t],I(e)))},clearTimeout:function(n){var t=Q.delegate;return((t==null?void 0:t.clearTimeout)||clearTimeout)(n)},delegate:void 0};function je(n){Q.setTimeout(function(){throw n})}function de(){}function $(n){n()}var G=function(n){_(t,n);function t(e){var r=n.call(this)||this;return r.isStopped=!1,e?(r.destination=e,ae(e)&&e.add(r)):r.destination=De,r}return t.create=function(e,r,i){return new j(e,r,i)},t.prototype.next=function(e){this.isStopped||this._next(e)},t.prototype.error=function(e){this.isStopped||(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,n.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(e){this.destination.next(e)},t.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t}(T),Ve=Function.prototype.bind;function Y(n,t){return Ve.call(n,t)}var Fe=function(){function n(t){this.partialObserver=t}return n.prototype.next=function(t){var e=this.partialObserver;if(e.next)try{e.next(t)}catch(r){V(r)}},n.prototype.error=function(t){var e=this.partialObserver;if(e.error)try{e.error(t)}catch(r){V(r)}else V(t)},n.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(e){V(e)}},n}(),j=function(n){_(t,n);function t(e,r,i){var o=n.call(this)||this,s;if(w(e)||!e)s={next:e??void 0,error:r??void 0,complete:i??void 0};else{var c;o&&he.useDeprecatedNextContext?(c=Object.create(e),c.unsubscribe=function(){return o.unsubscribe()},s={next:e.next&&Y(e.next,c),error:e.error&&Y(e.error,c),complete:e.complete&&Y(e.complete,c)}):s=e}return o.destination=new Fe(s),o}return t}(G);function V(n){je(n)}function He(n){throw n}var De={closed:!0,next:de,error:He,complete:de},Le=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function pe(n){return n}function ke(n){return n.length===0?pe:n.length===1?n[0]:function(e){return n.reduce(function(r,i){return i(r)},e)}}var J=function(){function n(t){t&&(this._subscribe=t)}return n.prototype.lift=function(t){var e=new n;return e.source=this,e.operator=t,e},n.prototype.subscribe=function(t,e,r){var i=this,o=Ne(t)?t:new j(t,e,r);return $(function(){var s=i,c=s.operator,u=s.source;o.add(c?c.call(o,u):u?i._subscribe(o):i._trySubscribe(o))}),o},n.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(e){t.error(e)}},n.prototype.forEach=function(t,e){var r=this;return e=fe(e),new e(function(i,o){var s=new j({next:function(c){try{t(c)}catch(u){o(u),s.unsubscribe()}},error:o,complete:i});r.subscribe(s)})},n.prototype._subscribe=function(t){var e;return(e=this.source)===null||e===void 0?void 0:e.subscribe(t)},n.prototype[Le]=function(){return this},n.prototype.pipe=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return ke(t)(this)},n.prototype.toPromise=function(t){var e=this;return t=fe(t),new t(function(r,i){var o;e.subscribe(function(s){return o=s},function(s){return i(s)},function(){return r(o)})})},n.create=function(t){return new n(t)},n}();function fe(n){var t;return(t=n??he.Promise)!==null&&t!==void 0?t:Promise}function Be(n){return n&&w(n.next)&&w(n.error)&&w(n.complete)}function Ne(n){return n&&n instanceof G||Be(n)&&ae(n)}function qe(n){return w(n==null?void 0:n.lift)}function ve(n){return function(t){if(qe(t))return t.lift(function(e){try{return n(e,this)}catch(r){this.error(r)}});throw new TypeError("Unable to lift unknown Observable type")}}function ge(n,t,e,r,i){return new ze(n,t,e,r,i)}var ze=function(n){_(t,n);function t(e,r,i,o,s,c){var u=n.call(this,e)||this;return u.onFinalize=s,u.shouldUnsubscribe=c,u._next=r?function(a){try{r(a)}catch(v){e.error(v)}}:n.prototype._next,u._error=o?function(a){try{o(a)}catch(v){e.error(v)}finally{this.unsubscribe()}}:n.prototype._error,u._complete=i?function(){try{i()}catch(a){e.error(a)}finally{this.unsubscribe()}}:n.prototype._complete,u}return t.prototype.unsubscribe=function(){var e;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var r=this.closed;n.prototype.unsubscribe.call(this),!r&&((e=this.onFinalize)===null||e===void 0||e.call(this))}},t}(G),Qe=q(function(n){return function(){n(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),be=function(n){_(t,n);function t(){var e=n.call(this)||this;return e.closed=!1,e.currentObservers=null,e.observers=[],e.isStopped=!1,e.hasError=!1,e.thrownError=null,e}return t.prototype.lift=function(e){var r=new ye(this,this);return r.operator=e,r},t.prototype._throwIfClosed=function(){if(this.closed)throw new Qe},t.prototype.next=function(e){var r=this;$(function(){var i,o;if(r._throwIfClosed(),!r.isStopped){r.currentObservers||(r.currentObservers=Array.from(r.observers));try{for(var s=N(r.currentObservers),c=s.next();!c.done;c=s.next()){var u=c.value;u.next(e)}}catch(a){i={error:a}}finally{try{c&&!c.done&&(o=s.return)&&o.call(s)}finally{if(i)throw i.error}}}})},t.prototype.error=function(e){var r=this;$(function(){if(r._throwIfClosed(),!r.isStopped){r.hasError=r.isStopped=!0,r.thrownError=e;for(var i=r.observers;i.length;)i.shift().error(e)}})},t.prototype.complete=function(){var e=this;$(function(){if(e._throwIfClosed(),!e.isStopped){e.isStopped=!0;for(var r=e.observers;r.length;)r.shift().complete()}})},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var e;return((e=this.observers)===null||e===void 0?void 0:e.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(e){return this._throwIfClosed(),n.prototype._trySubscribe.call(this,e)},t.prototype._subscribe=function(e){return this._throwIfClosed(),this._checkFinalizedStatuses(e),this._innerSubscribe(e)},t.prototype._innerSubscribe=function(e){var r=this,i=this,o=i.hasError,s=i.isStopped,c=i.observers;return o||s?ce:(this.currentObservers=null,c.push(e),new T(function(){r.currentObservers=null,U(c,e)}))},t.prototype._checkFinalizedStatuses=function(e){var r=this,i=r.hasError,o=r.thrownError,s=r.isStopped;i?e.error(o):s&&e.complete()},t.prototype.asObservable=function(){var e=new J;return e.source=this,e},t.create=function(e,r){return new ye(e,r)},t}(J),ye=function(n){_(t,n);function t(e,r){var i=n.call(this)||this;return i.destination=e,i.source=r,i}return t.prototype.next=function(e){var r,i;(i=(r=this.destination)===null||r===void 0?void 0:r.next)===null||i===void 0||i.call(r,e)},t.prototype.error=function(e){var r,i;(i=(r=this.destination)===null||r===void 0?void 0:r.error)===null||i===void 0||i.call(r,e)},t.prototype.complete=function(){var e,r;(r=(e=this.destination)===null||e===void 0?void 0:e.complete)===null||r===void 0||r.call(e)},t.prototype._subscribe=function(e){var r,i;return(i=(r=this.source)===null||r===void 0?void 0:r.subscribe(e))!==null&&i!==void 0?i:ce},t}(be),me={now:function(){return(me.delegate||Date).now()},delegate:void 0},Ge=function(n){_(t,n);function t(e,r){return n.call(this)||this}return t.prototype.schedule=function(e,r){return this},t}(T),F={setInterval:function(n,t){for(var e=[],r=2;r<arguments.length;r++)e[r-2]=arguments[r];var i=F.delegate;return i!=null&&i.setInterval?i.setInterval.apply(i,O([n,t],I(e))):setInterval.apply(void 0,O([n,t],I(e)))},clearInterval:function(n){var t=F.delegate;return((t==null?void 0:t.clearInterval)||clearInterval)(n)},delegate:void 0},Ye=function(n){_(t,n);function t(e,r){var i=n.call(this,e,r)||this;return i.scheduler=e,i.work=r,i.pending=!1,i}return t.prototype.schedule=function(e,r){var i;if(r===void 0&&(r=0),this.closed)return this;this.state=e;var o=this.id,s=this.scheduler;return o!=null&&(this.id=this.recycleAsyncId(s,o,r)),this.pending=!0,this.delay=r,this.id=(i=this.id)!==null&&i!==void 0?i:this.requestAsyncId(s,this.id,r),this},t.prototype.requestAsyncId=function(e,r,i){return i===void 0&&(i=0),F.setInterval(e.flush.bind(e,this),i)},t.prototype.recycleAsyncId=function(e,r,i){if(i===void 0&&(i=0),i!=null&&this.delay===i&&this.pending===!1)return r;r!=null&&F.clearInterval(r)},t.prototype.execute=function(e,r){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var i=this._execute(e,r);if(i)return i;this.pending===!1&&this.id!=null&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},t.prototype._execute=function(e,r){var i=!1,o;try{this.work(e)}catch(s){i=!0,o=s||new Error("Scheduled action threw falsy error")}if(i)return this.unsubscribe(),o},t.prototype.unsubscribe=function(){if(!this.closed){var e=this,r=e.id,i=e.scheduler,o=i.actions;this.work=this.state=this.scheduler=null,this.pending=!1,U(o,this),r!=null&&(this.id=this.recycleAsyncId(i,r,null)),this.delay=null,n.prototype.unsubscribe.call(this)}},t}(Ge),we=function(){function n(t,e){e===void 0&&(e=n.now),this.schedulerActionCtor=t,this.now=e}return n.prototype.schedule=function(t,e,r){return e===void 0&&(e=0),new this.schedulerActionCtor(this,t).schedule(r,e)},n.now=me.now,n}(),Je=function(n){_(t,n);function t(e,r){r===void 0&&(r=we.now);var i=n.call(this,e,r)||this;return i.actions=[],i._active=!1,i}return t.prototype.flush=function(e){var r=this.actions;if(this._active){r.push(e);return}var i;this._active=!0;do if(i=e.execute(e.state,e.delay))break;while(e=r.shift());if(this._active=!1,i){for(;e=r.shift();)e.unsubscribe();throw i}},t}(we),Ke=new Je(Ye),We=Ke;function Xe(n){return n&&w(n.schedule)}var Ze=q(function(n){return function(){n(this),this.name="EmptyError",this.message="no elements in sequence"}});function A(n,t){var e=typeof t=="object";return new Promise(function(r,i){var o=new j({next:function(s){r(s),o.unsubscribe()},error:i,complete:function(){e?r(t.defaultValue):i(new Ze)}});n.subscribe(o)})}function et(n){return n instanceof Date&&!isNaN(n)}function H(n,t){return ve(function(e,r){var i=0;e.subscribe(ge(r,function(o){r.next(n.call(t,o,i++))}))})}function tt(n,t,e){n===void 0&&(n=0),e===void 0&&(e=We);var r=-1;return t!=null&&(Xe(t)?e=t:r=t),new J(function(i){var o=et(n)?+n-e.now():n;o<0&&(o=0);var s=0;return e.schedule(function(){i.closed||(i.next(s++),0<=r?this.schedule(void 0,r):i.complete())},o)})}function rt(n,t,e){var r=w(n)||t||e?{next:n,error:t,complete:e}:n;return r?ve(function(i,o){var s;(s=r.subscribe)===null||s===void 0||s.call(r);var c=!0;i.subscribe(ge(o,function(u){var a;(a=r.next)===null||a===void 0||a.call(r,u),o.next(u)},function(){var u;c=!1,(u=r.complete)===null||u===void 0||u.call(r),o.complete()},function(u){var a;c=!1,(a=r.error)===null||a===void 0||a.call(r,u),o.error(u)},function(){var u,a;c&&((u=r.unsubscribe)===null||u===void 0||u.call(r)),(a=r.finalize)===null||a===void 0||a.call(r)}))}):pe}var nt=Object.defineProperty,it=(n,t,e)=>t in n?nt(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,M=(n,t,e)=>(it(n,typeof t!="symbol"?t+"":t,e),e);class f extends Error{constructor(t){super(`Incorrect context (${t}). Cannot perform the requested operation.`),M(this,"context"),this.context=t}}class D extends Error{constructor(t,e,r){super(`Invalid parameter (${t}). ${r}`),this.param=t,this.value=e,this.reason=r}}class ot extends Error{constructor(t,e){super(`'streamId' value of "${t}" is different from what we expected ("${e}")`),this.streamId=t,this.expectedStreamId=e}}class st extends Error{constructor(t){super(`Invalid version format: ${t}`)}}class Se extends Error{constructor(t){super(`${t} needs to be initialized before it can be used.`)}}class Ce extends Error{constructor(t,e){let r=`Unsupported Protocol ${Array.isArray(t)?"versions":"version"}: (${t}).`;e&&(r+=` Minimum version supported is ${e}.`),super(r),this.version=t}}function S(n){return typeof n=="function"}function ut(n){return S(n==null?void 0:n.lift)}function L(n){return function(t){if(ut(t))return t.lift(function(e){try{return n(e,this)}catch(r){this.error(r)}});throw new TypeError("Unable to lift unknown Observable type")}}var K=function(n,t){return K=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])},K(n,t)};function W(n,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");K(n,t);function e(){this.constructor=n}n.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}function Ee(n){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&n[t],r=0;if(e)return e.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&r>=n.length&&(n=void 0),{value:n&&n[r++],done:!n}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function X(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var r=e.call(n),i,o=[],s;try{for(;(t===void 0||t-- >0)&&!(i=r.next()).done;)o.push(i.value)}catch(c){s={error:c}}finally{try{i&&!i.done&&(e=r.return)&&e.call(r)}finally{if(s)throw s.error}}return o}function Z(n,t,e){if(e||arguments.length===2)for(var r=0,i=t.length,o;r<i;r++)(o||!(r in t))&&(o||(o=Array.prototype.slice.call(t,0,r)),o[r]=t[r]);return n.concat(o||Array.prototype.slice.call(t))}function ct(n){var t=function(r){Error.call(r),r.stack=new Error().stack},e=n(t);return e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,e}var ee=ct(function(n){return function(t){n(this),this.message=t?t.length+` errors occurred during unsubscription:
4
+ `+t.map(function(e,r){return r+1+") "+e.toString()}).join(`
5
+ `):"",this.name="UnsubscriptionError",this.errors=t}});function xe(n,t){if(n){var e=n.indexOf(t);0<=e&&n.splice(e,1)}}var te=function(){function n(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}return n.prototype.unsubscribe=function(){var t,e,r,i,o;if(!this.closed){this.closed=!0;var s=this._parentage;if(s)if(this._parentage=null,Array.isArray(s))try{for(var c=Ee(s),u=c.next();!u.done;u=c.next()){var a=u.value;a.remove(this)}}catch(d){t={error:d}}finally{try{u&&!u.done&&(e=c.return)&&e.call(c)}finally{if(t)throw t.error}}else s.remove(this);var v=this.initialTeardown;if(S(v))try{v()}catch(d){o=d instanceof ee?d.errors:[d]}var g=this._finalizers;if(g){this._finalizers=null;try{for(var x=Ee(g),C=x.next();!C.done;C=x.next()){var oe=C.value;try{Me(oe)}catch(d){o=o??[],d instanceof ee?o=Z(Z([],X(o)),X(d.errors)):o.push(d)}}}catch(d){r={error:d}}finally{try{C&&!C.done&&(i=x.return)&&i.call(x)}finally{if(r)throw r.error}}}if(o)throw new ee(o)}},n.prototype.add=function(t){var e;if(t&&t!==this)if(this.closed)Me(t);else{if(t instanceof n){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=(e=this._finalizers)!==null&&e!==void 0?e:[]).push(t)}},n.prototype._hasParent=function(t){var e=this._parentage;return e===t||Array.isArray(e)&&e.includes(t)},n.prototype._addParent=function(t){var e=this._parentage;this._parentage=Array.isArray(e)?(e.push(t),e):e?[e,t]:t},n.prototype._removeParent=function(t){var e=this._parentage;e===t?this._parentage=null:Array.isArray(e)&&xe(e,t)},n.prototype.remove=function(t){var e=this._finalizers;e&&xe(e,t),t instanceof n&&t._removeParent(this)},n.EMPTY=function(){var t=new n;return t.closed=!0,t}(),n}();te.EMPTY;function _e(n){return n instanceof te||n&&"closed"in n&&S(n.remove)&&S(n.add)&&S(n.unsubscribe)}function Me(n){S(n)?n():n.unsubscribe()}var Ie={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},at={setTimeout:function(n,t){for(var e=[],r=2;r<arguments.length;r++)e[r-2]=arguments[r];return setTimeout.apply(void 0,Z([n,t],X(e)))},clearTimeout:function(n){return clearTimeout(n)},delegate:void 0};function lt(n){at.setTimeout(function(){throw n})}function Oe(){}function ht(n){n()}var re=function(n){W(t,n);function t(e){var r=n.call(this)||this;return r.isStopped=!1,e?(r.destination=e,_e(e)&&e.add(r)):r.destination=vt,r}return t.create=function(e,r,i){return new ie(e,r,i)},t.prototype.next=function(e){this.isStopped||this._next(e)},t.prototype.error=function(e){this.isStopped||(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,n.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(e){this.destination.next(e)},t.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t}(te),dt=Function.prototype.bind;function ne(n,t){return dt.call(n,t)}var pt=function(){function n(t){this.partialObserver=t}return n.prototype.next=function(t){var e=this.partialObserver;if(e.next)try{e.next(t)}catch(r){k(r)}},n.prototype.error=function(t){var e=this.partialObserver;if(e.error)try{e.error(t)}catch(r){k(r)}else k(t)},n.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(e){k(e)}},n}(),ie=function(n){W(t,n);function t(e,r,i){var o=n.call(this)||this,s;if(S(e)||!e)s={next:e??void 0,error:r??void 0,complete:i??void 0};else{var c;o&&Ie.useDeprecatedNextContext?(c=Object.create(e),c.unsubscribe=function(){return o.unsubscribe()},s={next:e.next&&ne(e.next,c),error:e.error&&ne(e.error,c),complete:e.complete&&ne(e.complete,c)}):s=e}return o.destination=new pt(s),o}return t}(re);function k(n){lt(n)}function ft(n){throw n}var vt={closed:!0,next:Oe,error:ft,complete:Oe},gt=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function Pe(n){return n}function bt(n){return n.length===0?Pe:n.length===1?n[0]:function(t){return n.reduce(function(e,r){return r(e)},t)}}var yt=function(){function n(t){t&&(this._subscribe=t)}return n.prototype.lift=function(t){var e=new n;return e.source=this,e.operator=t,e},n.prototype.subscribe=function(t,e,r){var i=this,o=wt(t)?t:new ie(t,e,r);return ht(function(){var s=i,c=s.operator,u=s.source;o.add(c?c.call(o,u):u?i._subscribe(o):i._trySubscribe(o))}),o},n.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(e){t.error(e)}},n.prototype.forEach=function(t,e){var r=this;return e=Te(e),new e(function(i,o){var s=new ie({next:function(c){try{t(c)}catch(u){o(u),s.unsubscribe()}},error:o,complete:i});r.subscribe(s)})},n.prototype._subscribe=function(t){var e;return(e=this.source)===null||e===void 0?void 0:e.subscribe(t)},n.prototype[gt]=function(){return this},n.prototype.pipe=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return bt(t)(this)},n.prototype.toPromise=function(t){var e=this;return t=Te(t),new t(function(r,i){var o;e.subscribe(function(s){return o=s},function(s){return i(s)},function(){return r(o)})})},n.create=function(t){return new n(t)},n}();function Te(n){var t;return(t=n??Ie.Promise)!==null&&t!==void 0?t:Promise}function mt(n){return n&&S(n.next)&&S(n.error)&&S(n.complete)}function wt(n){return n&&n instanceof re||mt(n)&&_e(n)}function B(n,t,e,r,i){return new St(n,t,e,r,i)}var St=function(n){W(t,n);function t(e,r,i,o,s,c){var u=n.call(this,e)||this;return u.onFinalize=s,u.shouldUnsubscribe=c,u._next=r?function(a){try{r(a)}catch(v){e.error(v)}}:n.prototype._next,u._error=o?function(a){try{o(a)}catch(v){e.error(v)}finally{this.unsubscribe()}}:n.prototype._error,u._complete=i?function(){try{i()}catch(a){e.error(a)}finally{this.unsubscribe()}}:n.prototype._complete,u}return t.prototype.unsubscribe=function(){var e;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var r=this.closed;n.prototype.unsubscribe.call(this),!r&&((e=this.onFinalize)===null||e===void 0||e.call(this))}},t}(re);function h(n,t){return L(function(e,r){var i=0;e.subscribe(B(r,function(o){r.next(n.call(t,o,i++))}))})}var Ct=new yt(function(n){return n.complete()});function E(n){return n<=0?function(){return Ct}:L(function(t,e){var r=0;t.subscribe(B(e,function(i){++r<=n&&(e.next(i),n<=r&&e.complete())}))})}function m(n,t){return L(function(e,r){var i=0;e.subscribe(B(r,function(o){return n.call(t,o,i++)&&r.next(o)}))})}function b(n,t,e){var r=S(n)||t||e?{next:n,error:t,complete:e}:n;return r?L(function(i,o){var s;(s=r.subscribe)===null||s===void 0||s.call(r);var c=!0;i.subscribe(B(o,function(u){var a;(a=r.next)===null||a===void 0||a.call(r,u),o.next(u)},function(){var u;c=!1,(u=r.complete)===null||u===void 0||u.call(r),o.complete()},function(u){var a;c=!1,(a=r.error)===null||a===void 0||a.call(r,u),o.error(u)},function(){var u,a;c&&((u=r.unsubscribe)===null||u===void 0||u.call(r)),(a=r.finalize)===null||a===void 0||a.call(r)}))}):Pe}const Et=/^(\d+)\.(\d+)$/;function xt(n){if(typeof n=="string"){const t=n.match(Et);if(t)return`${t[1]}.${t[2]}`}throw new st(n)}function Ae(n){const t=xt(n),[e,r]=t.split("."),[i,o]=[parseInt(e),parseInt(r)];return[i,o]}function Re(n,t){const[e,r]=Ae(n),[i,o]=Ae(t);return e<i?-1:e>i?1:r<o?-1:r>o?1:0}function _t(n,t){return Re(n,t)===1}function Mt(n,t){return Re(n,t)>=0}const Ue="2.0";class It{constructor(t,e){if(M(this,"negotiatedProtocolVersion"),M(this,"currentContext"),M(this,"incomingMessages$"),M(this,"inIframe",!1),M(this,"embeddedResult"),M(this,"iframePort1"),M(this,"iframePort2"),this.supportedVersions=t,this.logService=e,this.incomingMessages$=new be,this.supportedVersions=t.filter(r=>Mt(r,Ue)),!this.supportedVersions.length)throw new Ce(t,Ue);this.negotiatedProtocolVersion=this.supportedVersions[0],this.embeddedResult=null,this.iframePort2=null}get parent(){return window.parent}get self(){return window.self}get frameElement(){return window.frameElement}get port1(){var t,e;return this.inIframe?this.iframePort1:(e=(t=window.Acrobits)==null?void 0:t.messageChannel)==null?void 0:e.port1}get port2(){var t,e,r,i;if(this.inIframe){if(!this.iframePort2)throw new Se("port2");return this.iframePort2}else{if(!((e=(t=window.Acrobits)==null?void 0:t.messageChannel)!=null&&e.port2))throw new Se("port2");return(i=(r=window.Acrobits)==null?void 0:r.messageChannel)==null?void 0:i.port2}}determineContext(){return tt(1e3).pipe(h(()=>(this.isEmbedded()?this.currentContext="user":this.currentContext="guest",this.currentContext)),E(1))}openBridge(){if(!this.isEmbedded())throw new f(this.currentContext);const t="HELLO",e=this.createMessage(t);e.protocolVersions=this.supportedVersions,this.logCreated(t,e);const r=this.incomingMessages$.pipe(m(i=>i.type===t&&i.replyTo===e.id),h(i=>i),b(this.logReceived(t)),h(i=>{if(this.supportedVersions.some(o=>_t(o,i.protocolVersion)))throw new Ce(i.protocolVersion,this.supportedVersions[0]);return i}),b(i=>{this.negotiatedProtocolVersion=i.protocolVersion,this.logService.info(`[IPC] Negotiated IPC Protocol Version: ${this.negotiatedProtocolVersion}`)}),E(1));return this.logService.debug(`Created ${t} Reply handler`),this.inIframe?this.createIframeChannel().then(()=>this.finishIpcSetup(e)):this.finishIpcSetup(e),r}requestSSOToken(){if(!this.isEmbedded())throw new f(this.currentContext);const t="TOKEN",e=this.createMessage(t);this.logCreated(t,e);const r=this.incomingMessages$.pipe(m(i=>i.type===t&&i.replyTo===e.id),h(i=>i),b(this.logReceived(t)),E(1));return this.logService.debug(`Created ${t} Reply handler`),this.port2.postMessage(e),this.logSent(t,e),r}sendJoiningRoomMessage(t){if(!this.isEmbedded())throw new f(this.currentContext);const{roomName:e,roomInvite:r,displayName:i,jwtToken:o,serverUrl:s,region:c,joinMicMuted:u,joinWithoutCamera:a}=t,v="JOINING ROOM",g=this.createMessage(v,!1);g.roomName=e,g.jwtToken=o,g.serverUrl=s,g.region=c,g.roomInvite=r,g.joinMicMuted=u??!1,g.joinWithoutCamera=a??!1,g.displayName=i,this.logCreated(v,g),this.port2.postMessage(g),this.logSent(v,g)}sendLeavingRoomMessage(t){if(!this.isEmbedded())throw new f(this.currentContext);const e="LEAVING ROOM",r=this.createMessage(e,!1);r.roomName=t,this.logCreated(e,r),this.port2.postMessage(r),this.logSent(e,r)}onJoinRoomMessage(){if(!this.isEmbedded())throw new f(this.currentContext);const t="JOIN ROOM";return this.incomingMessages$.pipe(m(e=>e.type===t&&e.target==="client"),h(e=>e),b(this.logReceived(t)),h(e=>e))}onLeaveRoomMessage(){if(!this.isEmbedded())throw new f(this.currentContext);const t="LEAVE ROOM";return this.incomingMessages$.pipe(m(e=>e.type===t&&e.target==="client"),h(e=>e),b(this.logReceived(t)),h(e=>e))}onConfigMessage(){if(!this.isEmbedded())throw new f(this.currentContext);const t="CONFIG";return this.incomingMessages$.pipe(m(e=>e.type===t&&e.target==="client"),h(e=>e),b(this.logReceived(t)),h(e=>({preferredCameraType:e.preferredCameraType,preferredMicType:e.preferredMicType,preferredOutputType:e.preferredOutputType,preferredCameraDeviceLabel:e.preferredCameraDeviceLabel,preferredMicDeviceLabel:e.preferredMicDeviceLabel,preferredOutputDeviceLabel:e.preferredOutputDeviceLabel,performanceProfile:e.performanceProfile,cloudUsername:e.cloudUsername,configuredOAuthProviders:e.configuredOAuthProviders,locales:e.locales?[...e.locales]:[]})))}sendScreenshareSourceMessage(t){if(!this.isEmbedded())throw new f(this.currentContext);const e="SCREENSHARE SOURCE",r=this.createMessage(e);r.sourceTypes=t,this.logCreated(e,r);const i=this.incomingMessages$.pipe(m(o=>o.type===e&&o.replyTo===r.id),h(o=>o),b(this.logReceived(e)),h(o=>o),E(1));return this.logService.debug(`Created ${e} Reply handler`),this.port2.postMessage(r),this.logSent(e,r),i}layoutChange(t,e,r){if(!this.isEmbedded())throw new f(this.currentContext);const i="LAYOUT CHANGE";let o,s;if(e&&r?(o=this.createMessage(i,!1,r),o.result=e):(o=this.createMessage(i),s=this.incomingMessages$.pipe(m(c=>c.type===i&&c.replyTo===o.id),h(c=>c),b(this.logReceived(i)),h(c=>c),E(1)),this.logService.debug(`Created ${i} Reply handler`)),o.layout=t,this.logCreated(i,o),this.port2.postMessage(o),this.logSent(i,o),s)return s}onLayoutChangeMessage(){if(!this.isEmbedded())throw new f(this.currentContext);const t="LAYOUT CHANGE";return this.incomingMessages$.pipe(m(e=>e.type===t&&e.target==="client"&&e.replyTo===null),h(e=>e),b(this.logReceived(t)),h(e=>e))}requestOAuthToken(t){if(!this.isEmbedded())throw new f(this.currentContext);Array.isArray(t)||(t=[t]);const e="OAUTH TOKEN",r=this.createMessage(e);r.providerTypes=t,this.logCreated(e,r);const i=this.incomingMessages$.pipe(m(o=>o.type===e&&o.replyTo===r.id),h(o=>o),b(this.logReceived(e)),E(1));return this.logService.debug(`Created ${e} Reply handler`),this.port2.postMessage(r),this.logSent(e,r),i}openUrl(t,e){if(!this.isEmbedded())throw new f(this.currentContext);const r="OPEN URL",i=this.createMessage(r,!1);i.url=t,i.data=e,this.logCreated(r,i),this.port2.postMessage(i),this.logSent(r,i)}selectContacts(t,e,r){if(!this.isEmbedded())throw new f(this.currentContext);if(e==="group"&&r===void 0)throw new D("currentContacts",r,"currentContacts is required for group streams");if(e==="direct"&&r!==void 0)throw new D("currentContacts",r,"currentContacts should not be passed for direct streams");const i="SELECT CONTACTS",o=this.createMessage(i,!0);o.streamType=e,o.streamId=t,o.currentContacts=r,this.logCreated(i,o);const s=this.incomingMessages$.pipe(m(c=>c.type===i&&c.replyTo===o.id),b(this.logReceived(i)),h(c=>{const u=c;if(u.streamId!==t)throw new ot(u.streamId,t);return e==="direct"&&u.contacts.length>1&&(u.contacts=[u.contacts[0]]),u}),E(1));return this.logService.debug(`Created ${i} Reply handler`),this.port2.postMessage(o),this.logSent(i,o),s}matchContacts(t){if(!this.isEmbedded())throw new f(this.currentContext);if(!t.length)throw new D("contacts",t,"At least one contact is required");const e="MATCH CONTACTS",r=this.createMessage(e);r.contacts=[...t],this.logCreated(e,r);const i=this.incomingMessages$.pipe(m(o=>o.type===e&&o.replyTo===r.id),b(this.logReceived(e)),h(o=>o),E(1));return this.logService.debug(`Created ${e} Reply handler`),this.port2.postMessage(r),this.logSent(e,r),i}onPushMessageMessage(){if(!this.isEmbedded())throw new f(this.currentContext);const t="PUSH MESSAGE";return this.incomingMessages$.pipe(m(e=>e.type===t&&e.target==="client"),h(e=>e),b(this.logReceived(t)))}requestPushToken(){if(!this.isEmbedded())throw new f(this.currentContext);const t="PUSH TOKEN",e=this.createMessage(t);this.logCreated(t,e);const r=this.incomingMessages$.pipe(m(i=>i.type===t&&i.replyTo===e.id),b(this.logReceived(t)),h(i=>i),E(1));return this.logService.debug(`Created ${t} Reply handler`),this.port2.postMessage(e),this.logSent(t,e),r}onBadgeQueryMessage(){if(!this.isEmbedded())throw new f(this.currentContext);const t="BADGE QUERY";return this.incomingMessages$.pipe(m(e=>e.type===t&&e.target==="client"),h(e=>e),b(this.logReceived(t)))}sendBadgeUpdateMessage(t,e){if(!this.isEmbedded())throw new f(this.currentContext);const r="BADGE UPDATE",i=this.createMessage(r,!1,e);i.count=t,this.logCreated(r,i),this.port2.postMessage(i),this.logSent(r,i)}onHostInForegroundMessage(){if(!this.isEmbedded())throw new f(this.currentContext);const t="HOST IN FOREGROUND";return this.incomingMessages$.pipe(m(e=>e.type===t&&e.target==="client"),h(e=>e),b(this.logReceived(t)))}isEmbedded(){if(this.embeddedResult!==null)return this.embeddedResult;let t=!1;return this.logService.debug("Checking if running in iframe..."),t=!!this.frameElement,t||(t=this.self!==this.parent),t?(this.logService.debug("In iframe"),this.inIframe=!0,this.embeddedResult=!0,!0):(this.logService.debug("Not in iframe"),this.logService.debug("Checking if running in native app..."),!t&&(t=!!window.Acrobits,t)?(this.logService.debug("In native app"),this.embeddedResult=!0,t):(this.logService.debug("Not running in native app"),this.embeddedResult=!1,this.embeddedResult))}logReceived(t,e){const r=i=>this.logService.debug(`[IPC] Received ${t} message`,i);return e&&r(e),r}logSent(t,e){this.logService.debug(`[IPC] Sent ${t} message`,e)}logCreated(t,e){this.logService.debug(`[IPC] Created ${t} message`,e)}async createIframeChannel(){return new Promise(t=>{const e=r=>{r.data==="message channel port"&&(this.iframePort2=r.ports[0],this.self.removeEventListener("message",e),t())};this.self.addEventListener("message",e),this.parent.postMessage("get channel","*")})}finishIpcSetup(t){this.logService.debug("Registering listener on port2..."),this.port2.addEventListener("message",this.handleIpcMessage.bind(this)),this.port2.start(),this.logService.debug("Started listening on port2"),this.port2.postMessage(t),this.logSent("HELLO",t)}handleIpcMessage(t){const{data:e}=t;!e.id||e.target!=="client"||this.incomingMessages$.next(e)}createMessage(t,e=!0,r){return{type:t,id:this.generateId(),target:"host",expectReply:e,replyTo:r??null}}generateId(t=8,e=!1){let r="1234567890qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM";const i=[];e&&(r=r.substr(0,r.indexOf("Q")));for(let o=0;o<t;o++)i.push(r[Math.floor(Math.random()*r.length)]);return i.join("")}}const Ot=["2.0"];class Pt{constructor(t){$e(this,R);P(this,"host");P(this,"cloudId");P(this,"logger");P(this,"helper");P(this,"listeners");this.logger=t??console,this.helper=new It(Ot,this.logger),this.listeners=new Map,this.listeners.set(l.BadgeQuery,new Set),this.listeners.set(l.HostInForeground,new Set)}get context(){return se(this,R,ue).call(this,this.helper.currentContext)}get isConnected(){return!!(this.helper.currentContext==="user"&&this.host&&this.cloudId)}get negotiatedVersion(){return this.helper.negotiatedProtocolVersion}async determineContext(){const t=await A(this.helper.determineContext(),{defaultValue:"guest"});return se(this,R,ue).call(this,t)}initiateConnection(){return A(this.helper.openBridge().pipe(rt(t=>{this.helper.onBadgeQueryMessage().subscribe(e=>{var r;this.logger.debug("Received Badge Query: ",e);for(const i of((r=this.listeners.get(l.BadgeQuery))==null?void 0:r.values())??[])i()}),this.helper.onHostInForegroundMessage().subscribe(e=>{var r;this.logger.debug("Received Host In Foreground: ",e);for(const i of((r=this.listeners.get(l.HostInForeground))==null?void 0:r.values())??[])i()}),this.cloudId=t.cloudId,this.host=t.host}),H(()=>{})))}selectContacts(t,e,r){this.logger.debug("Selecting Contacts: ",...arguments);let i;if(e==="multi"){if(!r)throw new D("currentContacts",r,"currentContacts is required for group streams");i=this.helper.selectContacts(t.toString(),"group",r)}else i=this.helper.selectContacts(t.toString(),"direct");return A(i.pipe(H(o=>o.contacts)))}matchContacts(t){return this.logger.debug("Match Contacts: ",t),A(this.helper.matchContacts(t).pipe(H(e=>e.contacts)))}requestPushToken(){return this.logger.debug("Requesting Push Token"),A(this.helper.requestPushToken().pipe(H(t=>t.pushToken)))}badgeUpdate(t){this.logger.debug("Sending Badge Update: ",t),this.helper.sendBadgeUpdateMessage(t)}onBadgeQueryRequest(t){var e;return this.logger.debug("Registering for Badge Query"),(e=this.listeners.get(l.BadgeQuery))==null||e.add(t),()=>{var r;return(r=this.listeners.get(l.BadgeQuery))==null?void 0:r.delete(t)}}onHostInForeground(t){var e;return this.logger.debug("Registering for Host In Foreground"),(e=this.listeners.get(l.HostInForeground))==null||e.add(t),()=>{var r;return(r=this.listeners.get(l.HostInForeground))==null?void 0:r.delete(t)}}}R=new WeakSet,ue=function(t){if(t==="user")return"host";if(t==="guest")return"standalone"},p.IPCEvents=l,p.IPCManager=Pt,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})});