@streamlayer/sdk-web 0.31.1 → 0.31.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +6 -6
- package/lib/es/index.js +1237 -1228
- package/package.json +10 -10
package/lib/cjs/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const re=require("@streamlayer/sl-eslib/interactive/interactive.common_pb");require("@streamlayer/sl-eslib/interactive/feed/interactive.feed_pb");const Te=require("@streamlayer/sl-eslib/sdkSettings/sdkSettings.common_pb"),Fe=require("nanostores");require("@nanostores/logger");require("microdiff");const
|
|
2
|
-
`+i)};addListener=(e,r)=>this.listeners.has(e)?(this.addStateLog(`listener '${e}' not added, already exists`),!1):(this.listeners.set(e,r),this.addStateLog(`listener '${e}' added`),!0);removeListener=e=>{this.listeners.delete(e),this.addStateLog(`listener '${e}' removed`)};connect=()=>{this.updateState(fe.Connecting),this.streamCancel&&(this.addStateLog("disconnect prev connection"),this.streamCancel.abort(),this.streamCancel=void 0);const e="get"in this.params&&typeof this.params.get=="function"?this.params.get():this.params;(async()=>{this.streamCancel=new AbortController;try{const i={headers:this.headers.getValues(),signal:this.streamCancel.signal},s=this.method(e,i);for await(const u of s)this.attempt=0,this.onData(u)}catch(i){i instanceof Ye.ConnectError&&i.code!=Ye.Code.Canceled&&this.onStreamError(i)}})(),this.updateState(fe.Connected)};disconnect=()=>{this.streamCancel&&this.streamCancel.abort(),this.listeners.clear(),this.paramsListener?.(),clearTimeout(this.reconnectTimeout),this.reconnectTimeout=void 0,this.updateState(fe.Disconnected)};reconnect=()=>{if(this.reconnectTimeout)this.addStateLog("already reconnecting");else if(this.attempt<this.options.reconnectMaxAttempts){this.updateState(fe.Reconnect);const e=Math.min(this.options.reconnectMaxDelay,Math.pow(2,this.attempt)*this.options.reconnectDelay),r=Math.round(e*(1+Math.random())/2);this.reconnectTimeout=setTimeout(()=>{this.attempt++,this.updateState(fe.Reconnecting),this.addStateLog(`reconnect attempt ${this.attempt} after ${r}ms`),this.connect(),this.reconnectTimeout=void 0},r)}else this.addStateLog("max reconnect attempts reached"),this.disconnect()};getStore=()=>this.store?.getStore();onData=e=>{try{this.addStateLog(`received data => ${JSON.stringify(e)}`),this.store&&this.store.setValue(e);for(const[,r]of this.listeners)r(e);this.addStateLog(`data routed to ${this.listeners.size} listeners`)}catch(r){this.addStateLog(`error process data => ${r}`)}};onStreamError=e=>{if(this.addStateLog(`error => ${e?JSON.stringify(e):"undefined"}}`),e!==void 0){if(e instanceof Ye.ConnectError&&e.code!==Ye.Code.Canceled){this.updateState(fe.Failed),this.state.setValue("error",e),this.reconnect();return}this.disconnect()}}}class fi{toJsonOptions={emitDefaultValues:!1,enumAsInteger:!0,useProtoFieldName:!1};transport;streamTransport;nanoquery;host;interceptors=[];$headers;clients;callbackClients;subscriptions;constructor(e){this.host=e,this.$headers=new rt(Oe({"sl-device-id":L?.env?.NX_DEVICE_ID||"sdk-web-dev"}),"transport:headers"),this.initInterceptors(),this.clients=new Map,this.callbackClients=new Map,this.subscriptions=new Map;const[r,i,s]=kr.nanoquery();this.nanoquery={createFetcherStore:r,createMutatorStore:i,utils:s},this.transport=xr.createGrpcWebTransport({baseUrl:e,defaultTimeoutMs:3e4,interceptors:this.interceptors,useBinaryFormat:!0}),this.streamTransport=xr.createGrpcWebTransport({baseUrl:e,interceptors:this.interceptors,useBinaryFormat:!0})}addSubscription=(e,r,i)=>{const s=this.subscriptions.get(r);if(s)return s;const u=new li(this.$headers,e,r,i);return this.subscriptions.set(r,u),u};removeSubscription=e=>{e.disconnect(),this.subscriptions.delete(e.params)};disconnect=()=>{for(const[s,u]of this.subscriptions)u.disconnect(),this.subscriptions.delete(s);this.clients.clear(),this.callbackClients.clear(),this.subscriptions.clear();const[e,r,i]=kr.nanoquery();this.nanoquery={createFetcherStore:e,createMutatorStore:r,utils:i}};registerInterceptor=e=>{this.interceptors.push(e)};removeInterceptor=e=>{this.interceptors=this.interceptors.filter(r=>r!==e)};getClient=e=>{const r=e.typeName;if(this.clients.has(r))return this.clients.get(r);const i=Ye.createPromiseClient(e,this.transport);return this.clients.set(r,i),i};getStreamClient=e=>{const r=`stream-${e.typeName}`;if(this.clients.has(r))return this.clients.get(r);const i=Ye.createPromiseClient(e,this.streamTransport);return this.clients.set(r,i),i};createPromiseClient=(e,{params:r=[],method:i})=>{const s=this.getClient(e),u=e.methods[i].name,c=[e.typeName,u.charAt(0).toLowerCase()+u.slice(1),...Array.isArray(r)?r:[r]],h=[e.typeName,u.charAt(0).toLowerCase()+u.slice(1)];return{client:s,queryKey:c,queryKeyStr:h.join("")}};createStreamClient=e=>({client:this.getStreamClient(e)});setSdkKey=e=>{this.$headers.setValue("sdk",e)};setAuth=(e,r)=>{this.$headers.setValue("authorization",e),this.$headers.setValue("sl-user-id",r)};setHeader=(e,r)=>this.$headers.setValue(e,r);getHeader=e=>this.$headers.getValue(e);getHeaders=()=>this.$headers.getValues();initInterceptors=()=>{if(this.interceptors.length!==0)return;const e=r=>i=>{const s=this.$headers.getValues();for(const u in s)i.header.set(u,s[u]);return r(i)};this.interceptors.push(e),this.interceptors.push(ci())}}const di=(t,e)=>{const{client:r,queryKey:i}=e.createPromiseClient(Xn.Events,{method:"retrieveEventId",params:[t]});return e.nanoquery.createFetcherStore(i,{fetcher:async(s,u,c)=>{if(!c||typeof c!="string")return"";try{return(await r.retrieveEventId({id:c})).data?.id||""}catch{return""}}})},hi=(t,e)=>{const{client:r,queryKey:i}=e.createPromiseClient(yt.Client,{method:"getStream",params:[t]});return e.nanoquery.createFetcherStore(i,{fetcher:async(s,u,c)=>c?(await r.getStream({id:c})).data?.attributes:void 0})},pi=(t,e)=>{const{queryKey:r,client:i}=e.createPromiseClient(dr.Users,{method:"me",params:[t]});return e.nanoquery.createFetcherStore(r,{fetcher:()=>i.me({})})},yi=t=>{const{client:e}=t.createPromiseClient(dr.Users,{method:"bypassAuth"});return async({userKey:r,schema:i,init:s,inviterKey:u})=>{const c=await e.bypassAuth({userKey:r,schema:i,init:s});return c.meta&&(c.meta.inviterKey=u),c}},gi=(t,e)=>{const{client:r,queryKey:i}=e.createPromiseClient(yt.Client,{method:"get",params:[t]});return e.nanoquery.createFetcherStore(i,{fetcher:async()=>(await r.get({})).data?.attributes})},mi=(t,e)=>{const{client:r,queryKey:i}=e.createPromiseClient(yt.Client,{method:"getOrganization",params:[t]});return e.nanoquery.createFetcherStore(i,{fetcher:async()=>{const s=await r.getOrganization({});return s.data?{...s.data.attributes,id:s.data.id}:void 0}})},wi=(t,e)=>{const{client:r,queryKey:i}=e.createPromiseClient(yt.Client,{method:"getOrganizationAdvertising",params:[t]});return e.nanoquery.createFetcherStore(i,{fetcher:async()=>(await r.getOrganizationAdvertising({})).data?.attributes})},bi=(t,e,r)=>{t.transport=new fi(e.host),t.sdk.host=t.transport.host,t.transport.setSdkKey(e.sdkKey),t.transport.setHeader("sl-sdk-version",e.version||"-"),r()};class Bt{delimiter=":";prefix;storage;constructor(e="main",r=window.localStorage){this.prefix=`sl-sdk${this.delimiter}${e}`,this.storage=r}clear=()=>{for(const e in window.localStorage)e.startsWith(this.prefix)&&this.storage.removeItem(e)};generateKey=e=>`${this.prefix}${this.delimiter}${e.join(this.delimiter)}`;write=(...e)=>{const r=e.pop()||"";this.storage.setItem(this.generateKey(e),r)};read=(...e)=>{const r=this.storage.getItem(this.generateKey(e));return r===null?void 0:r};remove=(...e)=>{this.storage.removeItem(this.generateKey(e))}}var Ae;(function(t){t.SCHEMA="schema",t.EXTERNAL_TOKEN="eToken",t.TOKEN="token"})(Ae||(Ae={}));class Xe extends Bt{constructor(){super("user")}setSchema=e=>{this.write(Ae.SCHEMA,e)};getSchema=()=>this.read(Ae.SCHEMA);setToken=e=>{this.write(Ae.TOKEN,e)};getToken=()=>this.read(Ae.TOKEN);setExternalToken=e=>{this.write(Ae.EXTERNAL_TOKEN,e)};getExternalToken=()=>this.read(Ae.EXTERNAL_TOKEN);removeToken=()=>{this.remove(Ae.TOKEN)}}var Ie;(function(t){t.DISABLED="disabled",t.INITIALIZATION="initialization",t.READY="ready",t.FAILED="failed",t.SUSPENDED="suspended"})(Ie||(Ie={}));const vi=t=>{const e=new Xe,r=new ae(ne(e.getExternalToken()),"userKey"),i=new ae(ne(e.getToken()),"userToken"),s=new de(pi(i.getStore(),t),"user",({data:c,error:h,loading:p},m)=>{if(!h)return c?.data?.id?c.data.id:p===!1?void 0:m}),u=new de(gi(i.getStore(),t),"userSettings");return{userKey:r,userToken:i,user:s,userSettings:u}},Si=t=>{const e=new ae(ne(void 0),"providerStreamId"),r=new de(di(e.getStore(),t),"slStreamId",s=>s?.data),i=new de(hi(r.getAtomStore(),t),"streamSettings");return r.getAtomStore().listen(s=>{(s===""||s===void 0)&&i.getStore().mutate(void 0)}),{providerStreamId:e,slStreamId:r,streamSettings:i}},Ai=t=>{const e=new ae(ne(void 0),"enabled"),r=new ae(ne(Ie.DISABLED),"status"),i=new de(mi(e.getStore(),t),"organizationSettings",h=>h?.data?.id),s=new de(wi(i.getAtomStore(),t),"organizationAdvertising"),u=vi(t),c=Si(t);return{enabled:e,status:r,providerStreamId:c.providerStreamId,slStreamId:c.slStreamId,streamSettings:c.streamSettings,user:u.user,userKey:u.userKey,userToken:u.userToken,userSettings:u.userSettings,organizationSettings:i,organizationAdvertising:s}};class Ei extends kt{stores;constructor(e){const r=Ai(e),i=si(r);super(i,"core"),this.stores=r}getValue(){throw new Error("Not implemented")}getValues(){return this.stores}setValue(){throw new Error("Not implemented")}subscribe=e=>{let r;for(r in this.stores){const i=e[r];r in e&&i!==void 0&&this.stores[r].subscribe(e[r])}};unsubscribe=()=>this.getStore().off()}class Ii extends Bt{get=this.read;set=this.write;del=this.remove;constructor(){super("deep-link-context",window.sessionStorage)}}const Br="sldl",hr="sldl_uid",ln="sldl_eid",fn="sldl_e_eid",Ti=new Set([hr,ln,fn]),Lr=t=>{const e={};for(const[r,i]of t)Ti.has(r)&&(e[r]=i);return e},_i=({hash:t,search:e})=>{if(t&&t.includes(Br)){const r=new URLSearchParams(t.substr(1));return Lr(r)}if(e&&e.includes(Br)){const r=new URLSearchParams(e);return Lr(r)}return null},Oi=t=>{const{hash:e,search:r,processed:i}=t.getValues();if(console.log("get deep link data from",{hash:e,search:r,processed:i}),!i){const s=_i({hash:e,search:r});console.log("parse deep link result",s),s&&t.setValue("data",s);return}},Fi=(t,e,r)=>{const i=new Ii,s=i.get("sl-deep-link-store");let u={processed:!1};if(s)try{u=JSON.parse(s)}catch(h){console.log(h)}t.deepLink={$store:new rt(Oe(u),"deep-link-context"),getDeepLinkData:()=>{const{data:h,processed:p}=t.deepLink.$store.getValues();return p?void 0:h},deepLinkUsed:h=>{t.deepLink.$store.setValue("processed",!0),i.set("sl-inviter-id",h),i.del("sl-location")},onDeepLinkHandlers:new Set},t.deepLink.$store.subscribe(h=>i.set("sl-deep-link-store",JSON.stringify(h))),t.sdk.getInviterId=()=>i.get("sl-inviter-id"),t.sdk.onDeepLinkHandled=h=>{t.deepLink.onDeepLinkHandlers.add(h)},t.sdk.deepLinkHandled=()=>{i.del("sl-inviter-id"),t.deepLink.$store.setValue("processed",!0);const{data:h}=t.deepLink.$store.getValues();for(const p of t.deepLink.onDeepLinkHandlers)try{p(h)}catch(m){console.error(m)}};let c=i.get("sl-session-id");if(c){const h=i.get("sl-location");if(h){const p=JSON.parse(h);t.deepLink.$store.getStore().set({sessionId:c,hash:p.hash,search:p.search,processed:!1})}}else{const{hash:h,search:p}=window.location;c=Date.now().toString(),i.set("sl-session-id",c),i.set("sl-location",JSON.stringify({hash:h,search:p})),t.deepLink.$store.getStore().set({sessionId:c,hash:h,search:p,processed:!1})}Oi(t.deepLink.$store),r()};class Ci extends oi{$coreStore;deepLink;transport;bypassLogin;constructor(e,r,i){super(),this.$coreStore=e,this.deepLink=i,this.transport=r,this.bypassLogin=yi(this.transport),this.connect()}me=async()=>(this.$coreStore.getValues().user.invalidate(),(await this.$coreStore.getValues().user.getValue())?.data);login=async(e,r)=>{this.$coreStore.getValues().userKey.setValue(r);const i=this.deepLink.getDeepLinkData()?.[hr];console.log("inviterKey",i);const s=await this.bypassLogin({schema:e,userKey:r,inviterKey:i,init:!1}),u=s.meta?.jwt,c=s.data?.id;if(!u||!c)throw new Error("internal: token missing");return console.log("user",s),s.meta?.inviterKey&&this.deepLink.deepLinkUsed(s.meta.inviterKey),this.$coreStore.getValues().user.getStore().mutate(s),this.saveUser(u,c),u};isAuthenticated=()=>this.me();logout=()=>{this.$coreStore.getValues().user.setValue(),this.$coreStore.getValues().userKey.setValue(),this.$coreStore.getValues().userToken.setValue(),this.transport.setAuth("",""),new Xe().clear()};softLogout=()=>{const e=new Xe;this.transport.setAuth("",""),e.setToken(""),this.reLogin()};reLogin=()=>{const e=new Xe,r=e.getToken(),i=e.getExternalToken();if(this.$coreStore.getValues().userKey.setValue(i),r)return this.saveUser(r,""),this.me().then(s=>{if(s?.id){const u=s.id;this.saveUser(r,u)}});if(i&&!r){const s=e.getSchema();s&&i&&this.login(s,i).catch(()=>{this.logout()})}};saveUser=(e,r)=>{this.transport.setAuth(e,r),this.$coreStore.getValues().userToken.setValue(e),new Xe().setToken(e)};connect=()=>{this.transport.registerInterceptor(e=>async r=>{try{return await e(r)}catch(i){throw i.code&&(i.code===7||i.code===16)&&this.transport.getHeader("authorization")&&this.softLogout(),i}})}}const dt=new Xe,xi=(t,e,r)=>{t.auth=new Ci(t.store,t.transport,t.deepLink),t.stores.status.listen(i=>{i===Ie.READY&&t.auth.reLogin()}),t.sdk.userId=t.stores.user.getAtomStore,t.sdk.authorizationBypass=async(i,s)=>{if(!(dt.getSchema()===i&&dt.getExternalToken()===s&&t.transport.getHeader("authorization")))try{await t.auth.login(i,s),dt.setSchema(i),dt.setExternalToken(s)}catch{t.sdk.logout()}},t.sdk.logout=()=>{t.auth.logout(),dt.clear()},t.sdk.getUserStore=()=>t.stores.user.getStore(),t.sdk.isUserAuthorized=()=>t.auth.isAuthenticated(),r()},ki=(t,e,r)=>{t.store=new Ei(t.transport),t.stores=t.store.getValues(),t.sdk.enabled=t.stores.enabled.getStore(),t.sdk.status=t.stores.status.getStore(),t.sdk.sdkStore=Object.fromEntries(Object.entries(t.stores).map(([i,s])=>[i,s.getStore()])),t.sdk.organizationStore=()=>t.stores.organizationSettings.getStore(),t.sdk.streamStore=()=>t.stores.streamSettings.getStore(),t.storeUnsubscribe=()=>{t.store.unsubscribe()},r()},Bi=(t,e,r)=>{t.sdk=Object.create(null),t.sdk.initializeApp=async i=>{if(t.contextConfig=i,t.stores.enabled.get()==="on")return{enabled:!0};t.storeSubscribe(),t.stores.enabled.setValue("on"),t.stores.status.setValue(Ie.INITIALIZATION);try{const s=await t.stores.organizationSettings.getValue();return s?(t.stores.status.setValue(Ie.READY),{enabled:!!s}):(t.stores.status.setValue(Ie.FAILED),{err:"failed"})}catch(s){return t.stores.enabled.setValue(),t.stores.status.setValue(Ie.FAILED),{err:`${s}`}}},t.sdk.disableApp=()=>{t.stores.enabled.get()==="on"&&(t.stores.enabled.setValue(),t.stores.status.setValue(Ie.DISABLED),t.stores.slStreamId.setValue(),t.stores.providerStreamId.setValue(),t.sdk.closeFeature(!0),t.storeUnsubscribe(),t.transport.disconnect())},t.sdk.createEventSession=i=>{t.stores.providerStreamId.setValue(i)},r()},Li=Zn.pino({level:"trace",enabled:!1,browser:{write:t=>{console.log(t)}}}),dn=(t,e)=>Li.child({name:t},e),Pi=(t,e,r)=>{const{client:i,queryKey:s}=r.createPromiseClient(nn.Leaderboard,{method:"summary",params:[t,e]});return r.nanoquery.createFetcherStore(s,{fetcher:async(u,c,h,p)=>(await i.summary({eventId:h,userId:p})).data?.attributes})},Ri=t=>{const{client:e}=t.createPromiseClient(nn.Leaderboard,{method:"list"});return r=>e.list(r)},Ni=(t,e)=>{const{client:r,queryKey:i}=e.createPromiseClient(dr.Users,{method:"getFriends",params:[t]});return e.nanoquery.createFetcherStore(i,{fetcher:async(s,u,c)=>c?(await r.getFriends({})).data:[]})},Di=(t,e)=>{const{client:r,queryKey:i}=e.createPromiseClient(Ce.Feed,{method:"get",params:[t]});return e.nanoquery.createFetcherStore(i,{fetcher:async(s,u,c)=>(await r.get({eventId:c})).data?.attributes})},$i=(t,e)=>{const{client:r,queryKey:i}=e.createPromiseClient(Ce.Feed,{method:"syncQuestion",params:[t]});return e.nanoquery.createFetcherStore(i,{fetcher:async(s,u,c)=>c?(await r.syncQuestion({filter:{eventId:c}})).data?.attributes:void 0})},Ui=(t,e)=>{const{client:r}=e.createStreamClient(Ce.Feed),i=Fe.atom({eventId:t.get()||"",feedId:""});return t.subscribe((u="")=>{i.set({eventId:u,feedId:""})}),e.addSubscription(r.subscription,i,{name:"feedSubscription"})},ji=(t,e)=>{const{client:r}=e.createStreamClient(Ce.Feed);return e.addSubscription(r.questionSubscription,{questionId:t},{name:"questionSubscription"})},hn=async(t,e)=>{const{client:r}=e.createPromiseClient(Ce.Feed,{method:"questionByUser",params:[t]});return(await r.questionByUser({questionId:t})).data?.attributes?.question},Mi=(t,e,r)=>{const{client:i,queryKey:s}=r.createPromiseClient(Ce.Feed,{method:"list",params:[t,e]});return r.nanoquery.createFetcherStore(s,{fetcher:async(u,c,h,p)=>h?(await i.list({eventId:h,filter:{types:p===Ve.ALLOWED?[]:[re.QuestionType.FACTOID,re.QuestionType.PROMOTION,re.QuestionType.TWEET],statuses:[re.QuestionStatus.ACTIVE,re.QuestionStatus.RESOLVED]}})).data:[]})};var pn={},Lt={};Lt.byteLength=Qi;Lt.toByteArray=zi;Lt.fromByteArray=Hi;var me=[],oe=[],Vi=typeof Uint8Array<"u"?Uint8Array:Array,Ut="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var Ke=0,qi=Ut.length;Ke<qi;++Ke)me[Ke]=Ut[Ke],oe[Ut.charCodeAt(Ke)]=Ke;oe[45]=62;oe[95]=63;function yn(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");r===-1&&(r=e);var i=r===e?0:4-r%4;return[r,i]}function Qi(t){var e=yn(t),r=e[0],i=e[1];return(r+i)*3/4-i}function Gi(t,e,r){return(e+r)*3/4-r}function zi(t){var e,r=yn(t),i=r[0],s=r[1],u=new Vi(Gi(t,i,s)),c=0,h=s>0?i-4:i,p;for(p=0;p<h;p+=4)e=oe[t.charCodeAt(p)]<<18|oe[t.charCodeAt(p+1)]<<12|oe[t.charCodeAt(p+2)]<<6|oe[t.charCodeAt(p+3)],u[c++]=e>>16&255,u[c++]=e>>8&255,u[c++]=e&255;return s===2&&(e=oe[t.charCodeAt(p)]<<2|oe[t.charCodeAt(p+1)]>>4,u[c++]=e&255),s===1&&(e=oe[t.charCodeAt(p)]<<10|oe[t.charCodeAt(p+1)]<<4|oe[t.charCodeAt(p+2)]>>2,u[c++]=e>>8&255,u[c++]=e&255),u}function Ki(t){return me[t>>18&63]+me[t>>12&63]+me[t>>6&63]+me[t&63]}function Wi(t,e,r){for(var i,s=[],u=e;u<r;u+=3)i=(t[u]<<16&16711680)+(t[u+1]<<8&65280)+(t[u+2]&255),s.push(Ki(i));return s.join("")}function Hi(t){for(var e,r=t.length,i=r%3,s=[],u=16383,c=0,h=r-i;c<h;c+=u)s.push(Wi(t,c,c+u>h?h:c+u));return i===1?(e=t[r-1],s.push(me[e>>2]+me[e<<4&63]+"==")):i===2&&(e=(t[r-2]<<8)+t[r-1],s.push(me[e>>10]+me[e>>4&63]+me[e<<2&63]+"=")),s.join("")}var pr={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */pr.read=function(t,e,r,i,s){var u,c,h=s*8-i-1,p=(1<<h)-1,m=p>>1,f=-7,w=r?s-1:0,E=r?-1:1,T=t[e+w];for(w+=E,u=T&(1<<-f)-1,T>>=-f,f+=h;f>0;u=u*256+t[e+w],w+=E,f-=8);for(c=u&(1<<-f)-1,u>>=-f,f+=i;f>0;c=c*256+t[e+w],w+=E,f-=8);if(u===0)u=1-m;else{if(u===p)return c?NaN:(T?-1:1)*(1/0);c=c+Math.pow(2,i),u=u-m}return(T?-1:1)*c*Math.pow(2,u-i)};pr.write=function(t,e,r,i,s,u){var c,h,p,m=u*8-s-1,f=(1<<m)-1,w=f>>1,E=s===23?Math.pow(2,-24)-Math.pow(2,-77):0,T=i?0:u-1,F=i?1:-1,x=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(h=isNaN(e)?1:0,c=f):(c=Math.floor(Math.log(e)/Math.LN2),e*(p=Math.pow(2,-c))<1&&(c--,p*=2),c+w>=1?e+=E/p:e+=E*Math.pow(2,1-w),e*p>=2&&(c++,p/=2),c+w>=f?(h=0,c=f):c+w>=1?(h=(e*p-1)*Math.pow(2,s),c=c+w):(h=e*Math.pow(2,w-1)*Math.pow(2,s),c=0));s>=8;t[r+T]=h&255,T+=F,h/=256,s-=8);for(c=c<<s|h,m+=s;m>0;t[r+T]=c&255,T+=F,c/=256,m-=8);t[r+T-F]|=x*128};/*!
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const re=require("@streamlayer/sl-eslib/interactive/interactive.common_pb");require("@streamlayer/sl-eslib/interactive/feed/interactive.feed_pb");const Te=require("@streamlayer/sl-eslib/sdkSettings/sdkSettings.common_pb"),Fe=require("nanostores");require("@nanostores/logger");require("microdiff");const Xe=require("@connectrpc/connect"),Br=require("@connectrpc/connect-web"),Lr=require("@nanostores/query"),ei=require("@streamlayer/sl-eslib/sports/events/events_connect"),gt=require("@streamlayer/sl-eslib/sdkSettings/client/client_connect"),pr=require("@streamlayer/sl-eslib/users/users_connect"),ti=require("pino"),Ce=require("@streamlayer/sl-eslib/interactive/feed/interactive.feed_connect"),an=require("@streamlayer/sl-eslib/interactive/leaderboard/interactive.leaderboard_connect");require("@streamlayer/sl-eslib/interactive/leaderboard/interactive.leaderboard_pb");const ri=require("@streamlayer/sl-eslib/shortLinks/linksClient_connect");function ni(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var un={exports:{}},Y=un.exports={},ye,ge;function rr(){throw new Error("setTimeout has not been defined")}function nr(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?ye=setTimeout:ye=rr}catch{ye=rr}try{typeof clearTimeout=="function"?ge=clearTimeout:ge=nr}catch{ge=nr}})();function cn(t){if(ye===setTimeout)return setTimeout(t,0);if((ye===rr||!ye)&&setTimeout)return ye=setTimeout,setTimeout(t,0);try{return ye(t,0)}catch{try{return ye.call(null,t,0)}catch{return ye.call(this,t,0)}}}function ii(t){if(ge===clearTimeout)return clearTimeout(t);if((ge===nr||!ge)&&clearTimeout)return ge=clearTimeout,clearTimeout(t);try{return ge(t)}catch{try{return ge.call(null,t)}catch{return ge.call(this,t)}}}var _e=[],rt=!1,je,vt=-1;function oi(){!rt||!je||(rt=!1,je.length?_e=je.concat(_e):vt=-1,_e.length&&ln())}function ln(){if(!rt){var t=cn(oi);rt=!0;for(var e=_e.length;e;){for(je=_e,_e=[];++vt<e;)je&&je[vt].run();vt=-1,e=_e.length}je=null,rt=!1,ii(t)}}Y.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)e[r-1]=arguments[r];_e.push(new fn(t,e)),_e.length===1&&!rt&&cn(ln)};function fn(t,e){this.fun=t,this.array=e}fn.prototype.run=function(){this.fun.apply(null,this.array)};Y.title="browser";Y.browser=!0;Y.env={};Y.argv=[];Y.version="";Y.versions={};function xe(){}Y.on=xe;Y.addListener=xe;Y.once=xe;Y.off=xe;Y.removeListener=xe;Y.removeAllListeners=xe;Y.emit=xe;Y.prependListener=xe;Y.prependOnceListener=xe;Y.listeners=function(t){return[]};Y.binding=function(t){throw new Error("process.binding is not supported")};Y.cwd=function(){return"/"};Y.chdir=function(t){throw new Error("process.chdir is not supported")};Y.umask=function(){return 0};var si=un.exports;const L=ni(si);class ai{}window.slStore=Object.create(null);class Bt{store;name;constructor(e,r){this.store=e,this.name=r}getStore(){return this.store}}const ui=t=>{const e=Object.keys(t);return Fe.computed(e.map(r=>t[r].getStore()),(...r)=>Object.fromEntries(e.map((i,s)=>[i,r[s]])))};class nt extends Bt{getValues=()=>this.getStore().get();getValue=e=>this.getStore().get()[e];setValue=(e,r)=>this.getStore().setKey(e,r);subscribe=(...e)=>this.getStore().subscribe(...e);unsubscribe=()=>this.getStore().off()}const Oe=t=>Fe.map(t);var Ee;(function(t){t.ORGANIZATION="ORGANIZATION",t.STREAM="STREAM"})(Ee||(Ee={}));const ci={[Te.SdkOverlayType.BETTING]:"betting",[Te.SdkOverlayType.GAMES]:"games",[Te.SdkOverlayType.PUBLIC_CHAT]:"publicChat",[Te.SdkOverlayType.TWITTER]:"twitter"};var it;(function(t){t.Ready="ready",t.Suspended="suspended"})(it||(it={}));class dn{status;source;config;settings;listeners=new Set;settingsKey;constructor({settings:e,...r},i){this.settingsKey=ci[r.type],this.status=Fe.atom(it.Suspended),this.config=new nt(Oe(r),`feature:config:${this.settingsKey}`),this.settingsKey!==void 0&&e?.overlaySettings.case===this.settingsKey?this.settings=new nt(Oe(e.overlaySettings.value),`feature:settings:${this.settingsKey}`):this.settings=new nt(Oe({}),`feature:settings:${this.settingsKey}`),this.source=i}get featureConfig(){return this.config.getStore()}get featureSettings(){return this.settings.getStore()}registerEventListener(e){this.listeners.add(e)}enable=()=>{this.status.set(it.Ready)};disable=()=>{this.status.set(it.Suspended)};setFeatureConfig=({settings:e,...r})=>{let i;for(i in r)this.config.setValue(i,r[i]);if(e?.overlaySettings?.case!==void 0&&e?.overlaySettings.case===this.settingsKey){const s=e.overlaySettings.value;if(s!==void 0){let u;for(u in s)s[u]!==0&&s[u]!==""&&this.settings.setValue(u,s[u])}}};update=(e,r)=>{this.source===Ee.STREAM&&r===Ee.ORGANIZATION||(this.setFeatureConfig(e),this.source=r)};fireEvent(e){for(const r of this.listeners.values())try{r.onEvent(e)}catch(i){console.error(i)}}}class ae extends Bt{getValue=()=>this.getStore().get();getValues(){throw new Error("not implemented")}setValue=e=>this.getStore().set(e);subscribe=e=>this.getStore().subscribe(e);unsubscribe=()=>this.getStore().off();listen(e){return this.getStore().listen(e)}get(){return this.getStore().get()}}const ne=t=>Fe.atom(t);class de extends Bt{atomStore;constructor(e,r,i){super(e,`api:${r}`),this.atomStore=Fe.atom(),i&&e.subscribe(s=>{const u=this.atomStore.get(),c=i(s,u);u!==c&&this.atomStore.set(c)})}getAtomStore=()=>this.atomStore;getValue=async()=>{const e=this.getStore();if(e.value===void 0)throw new Error("no store");return await e.value.promise,e.get().data};getValues=()=>this.getStore().get();setValue=e=>this.getStore().set({loading:!1,data:e?.data});subscribe=e=>this.getStore().subscribe(e);unsubscribe=()=>{throw new Error("not implemented")};invalidate=()=>{this.store.invalidate()};listen=e=>this.getStore().listen(e);get(){throw new Error("not implemented")}key=()=>this.getStore().key;off=()=>this.getStore().off()}async function*li(t,e){for await(const r of e){t.response.message=r,t.received_at=Date.now();const i={type:"__GRPC_DEVTOOLS_EXTENSION__",data:t};window.postMessage(i),yield r}}const fi=()=>t=>async e=>{const r={name:e.url,stream:e.stream,sent_at:Date.now(),request:{header:Object.fromEntries(e.header.entries())},response:{}};try{const i=await t(e);if(r.received_at=Date.now(),r.response.header=Object.fromEntries(i.header.entries()),r.response.trailer=Object.fromEntries(i.trailer.entries()),e.stream){r.request.message=e.message;const s={type:"__GRPC_DEVTOOLS_EXTENSION__",data:{...r,stream:!1}};return window.postMessage(s),{...i,message:li(r,i.message)}}else{r.request.message=e.message,r.response.message=i.message,r.latency=r.received_at-r.sent_at;const s={type:"__GRPC_DEVTOOLS_EXTENSION__",data:r};window.postMessage(s)}return i}catch(i){r.received_at=Date.now(),r.request.message=e.message,r.response.trailer={"grpc-status":i.code,"grpc-message":i.rawMessage},r.response.message=i.rawMessage,r.latency=r.received_at-r.sent_at;const s={type:"__GRPC_DEVTOOLS_EXTENSION__",data:r};throw window.postMessage(s),i}};window.dispatchEvent(new CustomEvent("grpc_devtools_loaded"));var fe;(function(t){t.Init="init",t.Ready="ready",t.Connecting="connecting",t.Connected="connected",t.Disconnected="disconnected",t.Failed="failed",t.Reconnect="reconnect",t.Reconnecting="reconnecting"})(fe||(fe={}));class di{params;streamCancel;method;options;headers;listeners;state;store;paramsListener;reconnectTimeout;attempt=0;constructor(e,r,i,s){const u={status:fe.Init,ts:new Date,log:[]};this.state=new nt(Oe(u),`subscription:${s.name}:state`),this.options={...s,reconnectDelay:s.reconnectDelay??1e3,reconnectMaxDelay:s.reconnectMaxDelay??3e4,reconnectMaxAttempts:s.reconnectMaxAttempts??10,withStore:s.withStore??!1},this.headers=e,this.listeners=new Map,this.params=i,this.method=r,s.withStore&&(this.store=new ae(ne(null),`subscription:${s.name}:store`)),"subscribe"in i&&typeof i.subscribe=="function"&&(this.paramsListener=i.subscribe(c=>{this.state.getValue("status")===fe.Connected&&(this.addStateLog(`params updated, reconnect => ${JSON.stringify(c)}`),this.reconnect())})),this.updateState(fe.Ready)}updateState=e=>{this.state.setValue("status",e),this.state.setValue("ts",new Date),this.addStateLog(`status => ${e}`)};addStateLog=e=>{const r=this.state.getStore().get().log,i=`${this.options.name} ${new Date().toISOString()}: ${e}`;r.push(i),this.state.setValue("log",r),window.sessionStorage.setItem("slstreamlogs",window.sessionStorage.getItem("slstreamlogs")+`
|
|
2
|
+
`+i)};addListener=(e,r)=>this.listeners.has(e)?(this.addStateLog(`listener '${e}' not added, already exists`),!1):(this.listeners.set(e,r),this.addStateLog(`listener '${e}' added`),!0);removeListener=e=>{this.listeners.delete(e),this.addStateLog(`listener '${e}' removed`)};connect=()=>{this.updateState(fe.Connecting),this.streamCancel&&(this.addStateLog("disconnect prev connection"),this.streamCancel.abort(),this.streamCancel=void 0);const e="get"in this.params&&typeof this.params.get=="function"?this.params.get():this.params;(async()=>{this.streamCancel=new AbortController;try{const i={headers:this.headers.getValues(),signal:this.streamCancel.signal},s=this.method(e,i);for await(const u of s)this.attempt=0,this.onData(u)}catch(i){i instanceof Xe.ConnectError&&i.code!=Xe.Code.Canceled&&this.onStreamError(i)}})(),this.updateState(fe.Connected)};disconnect=()=>{this.streamCancel&&this.streamCancel.abort(),this.listeners.clear(),this.paramsListener?.(),clearTimeout(this.reconnectTimeout),this.reconnectTimeout=void 0,this.updateState(fe.Disconnected)};reconnect=()=>{if(this.reconnectTimeout)this.addStateLog("already reconnecting");else if(this.attempt<this.options.reconnectMaxAttempts){this.updateState(fe.Reconnect);const e=Math.min(this.options.reconnectMaxDelay,Math.pow(2,this.attempt)*this.options.reconnectDelay),r=Math.round(e*(1+Math.random())/2);this.reconnectTimeout=setTimeout(()=>{this.attempt++,this.updateState(fe.Reconnecting),this.addStateLog(`reconnect attempt ${this.attempt} after ${r}ms`),this.connect(),this.reconnectTimeout=void 0},r)}else this.addStateLog("max reconnect attempts reached"),this.disconnect()};getStore=()=>this.store?.getStore();onData=e=>{try{this.addStateLog(`received data => ${JSON.stringify(e)}`),this.store&&this.store.setValue(e);for(const[,r]of this.listeners)r(e);this.addStateLog(`data routed to ${this.listeners.size} listeners`)}catch(r){this.addStateLog(`error process data => ${r}`)}};onStreamError=e=>{if(this.addStateLog(`error => ${e?JSON.stringify(e):"undefined"}}`),e!==void 0){if(e instanceof Xe.ConnectError&&e.code!==Xe.Code.Canceled){this.updateState(fe.Failed),this.state.setValue("error",e),this.reconnect();return}this.disconnect()}}}class hi{toJsonOptions={emitDefaultValues:!1,enumAsInteger:!0,useProtoFieldName:!1};transport;streamTransport;nanoquery;host;interceptors=[];$headers;clients;callbackClients;subscriptions;constructor(e){this.host=e,this.$headers=new nt(Oe({"sl-device-id":L?.env?.NX_DEVICE_ID||"sdk-web-dev"}),"transport:headers"),this.initInterceptors(),this.clients=new Map,this.callbackClients=new Map,this.subscriptions=new Map;const[r,i,s]=Lr.nanoquery();this.nanoquery={createFetcherStore:r,createMutatorStore:i,utils:s},this.transport=Br.createGrpcWebTransport({baseUrl:e,defaultTimeoutMs:3e4,interceptors:this.interceptors,useBinaryFormat:!0}),this.streamTransport=Br.createGrpcWebTransport({baseUrl:e,interceptors:this.interceptors,useBinaryFormat:!0})}addSubscription=(e,r,i)=>{const s=this.subscriptions.get(r);if(s)return s;const u=new di(this.$headers,e,r,i);return this.subscriptions.set(r,u),u};removeSubscription=e=>{e.disconnect(),this.subscriptions.delete(e.params)};disconnect=()=>{for(const[s,u]of this.subscriptions)u.disconnect(),this.subscriptions.delete(s);this.clients.clear(),this.callbackClients.clear(),this.subscriptions.clear();const[e,r,i]=Lr.nanoquery();this.nanoquery={createFetcherStore:e,createMutatorStore:r,utils:i}};registerInterceptor=e=>{this.interceptors.push(e)};removeInterceptor=e=>{this.interceptors=this.interceptors.filter(r=>r!==e)};getClient=e=>{const r=e.typeName;if(this.clients.has(r))return this.clients.get(r);const i=Xe.createPromiseClient(e,this.transport);return this.clients.set(r,i),i};getStreamClient=e=>{const r=`stream-${e.typeName}`;if(this.clients.has(r))return this.clients.get(r);const i=Xe.createPromiseClient(e,this.streamTransport);return this.clients.set(r,i),i};createPromiseClient=(e,{params:r=[],method:i})=>{const s=this.getClient(e),u=e.methods[i].name,c=[e.typeName,u.charAt(0).toLowerCase()+u.slice(1),...Array.isArray(r)?r:[r]],h=[e.typeName,u.charAt(0).toLowerCase()+u.slice(1)];return{client:s,queryKey:c,queryKeyStr:h.join("")}};createStreamClient=e=>({client:this.getStreamClient(e)});setSdkKey=e=>{this.$headers.setValue("sdk",e)};setAuth=(e,r)=>{this.$headers.setValue("authorization",e),this.$headers.setValue("sl-user-id",r)};setHeader=(e,r)=>this.$headers.setValue(e,r);getHeader=e=>this.$headers.getValue(e);getHeaders=()=>this.$headers.getValues();initInterceptors=()=>{if(this.interceptors.length!==0)return;const e=r=>i=>{const s=this.$headers.getValues();for(const u in s)i.header.set(u,s[u]);return r(i)};this.interceptors.push(e),this.interceptors.push(fi())}}const pi=(t,e)=>{const{client:r,queryKey:i}=e.createPromiseClient(ei.Events,{method:"retrieveEventId",params:[t]});return e.nanoquery.createFetcherStore(i,{fetcher:async(s,u,c)=>{if(!c||typeof c!="string")return"";try{return(await r.retrieveEventId({id:c})).data?.id||""}catch{return""}}})},yi=(t,e)=>{const{client:r,queryKey:i}=e.createPromiseClient(gt.Client,{method:"getStream",params:[t]});return e.nanoquery.createFetcherStore(i,{fetcher:async(s,u,c)=>c?(await r.getStream({id:c})).data?.attributes:void 0})},gi=(t,e)=>{const{queryKey:r,client:i}=e.createPromiseClient(pr.Users,{method:"me",params:[t]});return e.nanoquery.createFetcherStore(r,{fetcher:()=>i.me({})})},mi=t=>{const{client:e}=t.createPromiseClient(pr.Users,{method:"bypassAuth"});return async({userKey:r,schema:i,init:s,inviterKey:u})=>{const c=await e.bypassAuth({userKey:r,schema:i,init:s});return c.meta&&(c.meta.inviterKey=u),c}},wi=(t,e)=>{const{client:r,queryKey:i}=e.createPromiseClient(gt.Client,{method:"get",params:[t]});return e.nanoquery.createFetcherStore(i,{fetcher:async()=>(await r.get({})).data?.attributes})},bi=(t,e)=>{const{client:r,queryKey:i}=e.createPromiseClient(gt.Client,{method:"getOrganization",params:[t]});return e.nanoquery.createFetcherStore(i,{fetcher:async()=>{const s=await r.getOrganization({});return s.data?{...s.data.attributes,id:s.data.id}:void 0}})},vi=(t,e)=>{const{client:r,queryKey:i}=e.createPromiseClient(gt.Client,{method:"getOrganizationAdvertising",params:[t]});return e.nanoquery.createFetcherStore(i,{fetcher:async()=>(await r.getOrganizationAdvertising({})).data?.attributes})},Si=(t,e,r)=>{t.transport=new hi(e.host),t.sdk.host=t.transport.host,t.transport.setSdkKey(e.sdkKey),t.transport.setHeader("sl-sdk-version",e.version||"-"),r()};class Lt{delimiter=":";prefix;storage;constructor(e="main",r=window.localStorage){this.prefix=`sl-sdk${this.delimiter}${e}`,this.storage=r}clear=()=>{for(const e in window.localStorage)e.startsWith(this.prefix)&&this.storage.removeItem(e)};generateKey=e=>`${this.prefix}${this.delimiter}${e.join(this.delimiter)}`;write=(...e)=>{const r=e.pop()||"";this.storage.setItem(this.generateKey(e),r)};read=(...e)=>{const r=this.storage.getItem(this.generateKey(e));return r===null?void 0:r};remove=(...e)=>{this.storage.removeItem(this.generateKey(e))}}var Ae;(function(t){t.SCHEMA="schema",t.EXTERNAL_TOKEN="eToken",t.TOKEN="token"})(Ae||(Ae={}));class Ze extends Lt{constructor(){super("user")}setSchema=e=>{this.write(Ae.SCHEMA,e)};getSchema=()=>this.read(Ae.SCHEMA);setToken=e=>{this.write(Ae.TOKEN,e)};getToken=()=>this.read(Ae.TOKEN);setExternalToken=e=>{this.write(Ae.EXTERNAL_TOKEN,e)};getExternalToken=()=>this.read(Ae.EXTERNAL_TOKEN);removeToken=()=>{this.remove(Ae.TOKEN)}}var Ie;(function(t){t.DISABLED="disabled",t.INITIALIZATION="initialization",t.READY="ready",t.FAILED="failed",t.SUSPENDED="suspended"})(Ie||(Ie={}));const Ai=t=>{const e=new Ze,r=new ae(ne(e.getExternalToken()),"userKey"),i=new ae(ne(e.getToken()),"userToken"),s=new de(gi(i.getStore(),t),"user",({data:c,error:h,loading:p},m)=>{if(!h)return c?.data?.id?c.data.id:p===!1?void 0:m}),u=new de(wi(i.getStore(),t),"userSettings");return{userKey:r,userToken:i,user:s,userSettings:u}},Ei=t=>{const e=new ae(ne(void 0),"providerStreamId"),r=new de(pi(e.getStore(),t),"slStreamId",s=>s?.data),i=new de(yi(r.getAtomStore(),t),"streamSettings");return r.getAtomStore().listen(s=>{(s===""||s===void 0)&&i.getStore().mutate(void 0)}),{providerStreamId:e,slStreamId:r,streamSettings:i}},Ii=t=>{const e=new ae(ne(void 0),"enabled"),r=new ae(ne(Ie.DISABLED),"status"),i=new de(bi(e.getStore(),t),"organizationSettings",h=>h?.data?.id),s=new de(vi(i.getAtomStore(),t),"organizationAdvertising"),u=Ai(t),c=Ei(t);return{enabled:e,status:r,providerStreamId:c.providerStreamId,slStreamId:c.slStreamId,streamSettings:c.streamSettings,user:u.user,userKey:u.userKey,userToken:u.userToken,userSettings:u.userSettings,organizationSettings:i,organizationAdvertising:s}};class Ti extends Bt{stores;constructor(e){const r=Ii(e),i=ui(r);super(i,"core"),this.stores=r}getValue(){throw new Error("Not implemented")}getValues(){return this.stores}setValue(){throw new Error("Not implemented")}subscribe=e=>{let r;for(r in this.stores){const i=e[r];r in e&&i!==void 0&&this.stores[r].subscribe(e[r])}};unsubscribe=()=>this.getStore().off()}const _i=ti.pino({level:"trace",enabled:!!window.localStorage.getItem("SL_DEBUG"),browser:{write:t=>{console.log(t)}}}),Pt=(t,e)=>_i.child({name:t},e);class Oi extends Lt{get=this.read;set=this.write;del=this.remove;constructor(){super("deep-link-context",window.sessionStorage)}}const Pr="sldl",yr="sldl_uid",hn="sldl_eid",pn="sldl_e_eid",Fi=new Set([yr,hn,pn]),Rr=t=>{const e={},r={};for(const[i,s]of t)Fi.has(i)?e[i]=s:r[i]=s;return{result:e,remain:r}},Ci=({hash:t,search:e})=>{if(t&&t.includes(Pr)){const r=new URLSearchParams(t.substr(1));return{hash:Rr(r)}}if(e&&e.includes(Pr)){const r=new URLSearchParams(e);return{search:Rr(r)}}return null},Me=Pt("deep_link"),xi=(t,e)=>{const{hash:r,search:i}=window.location;if(Me.debug({hash:r,search:i},"get deep link data from"),r||i){const s=Ci({hash:r,search:i});if(Me.debug(s,"parse deep link result"),s){const{hash:u,search:c}=s,{result:h,remain:p}=u||c;if(Object.keys(h).length!==0){t.setValue("data",h);const m=Object.keys(p).length!==0;if(u)if(m){const l=`#${new URLSearchParams(p).toString()}`;Me.debug({updatedHash:l},"update hash"),window.location.hash=l}else window.location.hash="";if(c)if(m){const l=`?${new URLSearchParams(p).toString()}`;Me.debug({updatedSearch:l},"update search"),window.location.search=l}else window.location.search="";e(h)}}}t.setValue("parsed",!0)},ki=(t,e,r)=>{const i=new Oi,s=i.get("sl-deep-link-store");let u={};if(s)try{u=JSON.parse(s)}catch(h){Me.debug(h)}t.deepLink={$store:new nt(Oe(u),"deep-link-context"),getDeepLinkData:()=>{const{data:h,used:p}=t.deepLink.$store.getValues();return{data:h,used:p}},deepLinkUsed:h=>{Me.debug(`logged in with inviterId: ${h}`),t.deepLink.$store.setValue("used",!0)},onDeepLinkHandlers:new Set},t.deepLink.$store.subscribe(h=>i.set("sl-deep-link-store",JSON.stringify(h))),t.sdk.onDeepLinkHandled=h=>{t.deepLink.onDeepLinkHandlers.add(h)};const c=h=>{t.deepLink.$store.setValue("handled",!0);for(const p of t.deepLink.onDeepLinkHandlers)try{Me.debug("called handler"),p(h)}catch(m){console.error(m)}};xi(t.deepLink.$store,c),r()},Nr=Pt("bypass");class Bi extends ai{$coreStore;deepLink;transport;bypassLogin;constructor(e,r,i){super(),this.$coreStore=e,this.deepLink=i,this.transport=r,this.bypassLogin=mi(this.transport),this.connect()}me=async()=>(this.$coreStore.getValues().user.invalidate(),(await this.$coreStore.getValues().user.getValue())?.data);login=async(e,r)=>{this.$coreStore.getValues().userKey.setValue(r);const{used:i,data:s}=this.deepLink.getDeepLinkData(),u=i?"":s?.[yr];Nr.debug("inviterKey",u);const c=await this.bypassLogin({schema:e,userKey:r,inviterKey:u,init:!1}),h=c.meta?.jwt,p=c.data?.id;if(!h||!p)throw new Error("internal: token missing");return Nr.debug("user",c),c.meta?.inviterKey&&this.deepLink.deepLinkUsed(c.meta.inviterKey),this.$coreStore.getValues().user.getStore().mutate(c),this.saveUser(h,p),h};isAuthenticated=()=>this.me();logout=()=>{this.$coreStore.getValues().user.setValue(),this.$coreStore.getValues().userKey.setValue(),this.$coreStore.getValues().userToken.setValue(),this.transport.setAuth("",""),new Ze().clear()};softLogout=()=>{const e=new Ze;this.transport.setAuth("",""),e.setToken(""),this.reLogin()};reLogin=()=>{const e=new Ze,r=e.getToken(),i=e.getExternalToken();if(this.$coreStore.getValues().userKey.setValue(i),r)return this.saveUser(r,""),this.me().then(s=>{if(s?.id){const u=s.id;this.saveUser(r,u)}});if(i&&!r){const s=e.getSchema();s&&i&&this.login(s,i).catch(()=>{this.logout()})}};saveUser=(e,r)=>{this.transport.setAuth(e,r),this.$coreStore.getValues().userToken.setValue(e),new Ze().setToken(e)};connect=()=>{this.transport.registerInterceptor(e=>async r=>{try{return await e(r)}catch(i){throw i.code&&(i.code===7||i.code===16)&&this.transport.getHeader("authorization")&&this.softLogout(),i}})}}const ht=new Ze,Li=(t,e,r)=>{t.auth=new Bi(t.store,t.transport,t.deepLink),t.stores.status.listen(i=>{i===Ie.READY&&t.auth.reLogin()}),t.sdk.userId=t.stores.user.getAtomStore,t.sdk.authorizationBypass=async(i,s)=>{if(!(ht.getSchema()===i&&ht.getExternalToken()===s&&t.transport.getHeader("authorization")))try{await t.auth.login(i,s),ht.setSchema(i),ht.setExternalToken(s)}catch{t.sdk.logout()}},t.sdk.logout=()=>{t.auth.logout(),ht.clear()},t.sdk.getUserStore=()=>t.stores.user.getStore(),t.sdk.isUserAuthorized=()=>t.auth.isAuthenticated(),r()},Pi=(t,e,r)=>{t.store=new Ti(t.transport),t.stores=t.store.getValues(),t.sdk.enabled=t.stores.enabled.getStore(),t.sdk.status=t.stores.status.getStore(),t.sdk.sdkStore=Object.fromEntries(Object.entries(t.stores).map(([i,s])=>[i,s.getStore()])),t.sdk.organizationStore=()=>t.stores.organizationSettings.getStore(),t.sdk.streamStore=()=>t.stores.streamSettings.getStore(),t.storeUnsubscribe=()=>{t.store.unsubscribe()},r()},Ri=(t,e,r)=>{t.sdk=Object.create(null),t.sdk.initializeApp=async i=>{if(t.contextConfig=i,t.stores.enabled.get()==="on")return{enabled:!0};t.storeSubscribe(),t.stores.enabled.setValue("on"),t.stores.status.setValue(Ie.INITIALIZATION);try{const s=await t.stores.organizationSettings.getValue();return s?(t.stores.status.setValue(Ie.READY),{enabled:!!s}):(t.stores.status.setValue(Ie.FAILED),{err:"failed"})}catch(s){return t.stores.enabled.setValue(),t.stores.status.setValue(Ie.FAILED),{err:`${s}`}}},t.sdk.disableApp=()=>{t.stores.enabled.get()==="on"&&(t.stores.enabled.setValue(),t.stores.status.setValue(Ie.DISABLED),t.stores.slStreamId.setValue(),t.stores.providerStreamId.setValue(),t.sdk.closeFeature(!0),t.storeUnsubscribe(),t.transport.disconnect())},t.sdk.createEventSession=i=>{t.stores.providerStreamId.setValue(i)},r()},Ni=(t,e,r)=>{const{client:i,queryKey:s}=r.createPromiseClient(an.Leaderboard,{method:"summary",params:[t,e]});return r.nanoquery.createFetcherStore(s,{fetcher:async(u,c,h,p)=>(await i.summary({eventId:h,userId:p})).data?.attributes})},Di=t=>{const{client:e}=t.createPromiseClient(an.Leaderboard,{method:"list"});return r=>e.list(r)},$i=(t,e)=>{const{client:r,queryKey:i}=e.createPromiseClient(pr.Users,{method:"getFriends",params:[t]});return e.nanoquery.createFetcherStore(i,{fetcher:async(s,u,c)=>c?(await r.getFriends({})).data:[]})},Ui=(t,e)=>{const{client:r,queryKey:i}=e.createPromiseClient(Ce.Feed,{method:"get",params:[t]});return e.nanoquery.createFetcherStore(i,{fetcher:async(s,u,c)=>(await r.get({eventId:c})).data?.attributes})},ji=(t,e)=>{const{client:r,queryKey:i}=e.createPromiseClient(Ce.Feed,{method:"syncQuestion",params:[t]});return e.nanoquery.createFetcherStore(i,{fetcher:async(s,u,c)=>c?(await r.syncQuestion({filter:{eventId:c}})).data?.attributes:void 0})},Mi=(t,e)=>{const{client:r}=e.createStreamClient(Ce.Feed),i=Fe.atom({eventId:t.get()||"",feedId:""});return t.subscribe((u="")=>{i.set({eventId:u,feedId:""})}),e.addSubscription(r.subscription,i,{name:"feedSubscription"})},Vi=(t,e)=>{const{client:r}=e.createStreamClient(Ce.Feed);return e.addSubscription(r.questionSubscription,{questionId:t},{name:"questionSubscription"})},yn=async(t,e)=>{const{client:r}=e.createPromiseClient(Ce.Feed,{method:"questionByUser",params:[t]});return(await r.questionByUser({questionId:t})).data?.attributes?.question},qi=(t,e,r)=>{const{client:i,queryKey:s}=r.createPromiseClient(Ce.Feed,{method:"list",params:[t,e]});return r.nanoquery.createFetcherStore(s,{fetcher:async(u,c,h,p)=>h?(await i.list({eventId:h,filter:{types:p===qe.ALLOWED?[]:[re.QuestionType.FACTOID,re.QuestionType.PROMOTION,re.QuestionType.TWEET],statuses:[re.QuestionStatus.ACTIVE,re.QuestionStatus.RESOLVED]}})).data:[]})};var gn={},Rt={};Rt.byteLength=zi;Rt.toByteArray=Wi;Rt.fromByteArray=Yi;var me=[],oe=[],Qi=typeof Uint8Array<"u"?Uint8Array:Array,Mt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var We=0,Gi=Mt.length;We<Gi;++We)me[We]=Mt[We],oe[Mt.charCodeAt(We)]=We;oe[45]=62;oe[95]=63;function mn(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");r===-1&&(r=e);var i=r===e?0:4-r%4;return[r,i]}function zi(t){var e=mn(t),r=e[0],i=e[1];return(r+i)*3/4-i}function Ki(t,e,r){return(e+r)*3/4-r}function Wi(t){var e,r=mn(t),i=r[0],s=r[1],u=new Qi(Ki(t,i,s)),c=0,h=s>0?i-4:i,p;for(p=0;p<h;p+=4)e=oe[t.charCodeAt(p)]<<18|oe[t.charCodeAt(p+1)]<<12|oe[t.charCodeAt(p+2)]<<6|oe[t.charCodeAt(p+3)],u[c++]=e>>16&255,u[c++]=e>>8&255,u[c++]=e&255;return s===2&&(e=oe[t.charCodeAt(p)]<<2|oe[t.charCodeAt(p+1)]>>4,u[c++]=e&255),s===1&&(e=oe[t.charCodeAt(p)]<<10|oe[t.charCodeAt(p+1)]<<4|oe[t.charCodeAt(p+2)]>>2,u[c++]=e>>8&255,u[c++]=e&255),u}function Hi(t){return me[t>>18&63]+me[t>>12&63]+me[t>>6&63]+me[t&63]}function Ji(t,e,r){for(var i,s=[],u=e;u<r;u+=3)i=(t[u]<<16&16711680)+(t[u+1]<<8&65280)+(t[u+2]&255),s.push(Hi(i));return s.join("")}function Yi(t){for(var e,r=t.length,i=r%3,s=[],u=16383,c=0,h=r-i;c<h;c+=u)s.push(Ji(t,c,c+u>h?h:c+u));return i===1?(e=t[r-1],s.push(me[e>>2]+me[e<<4&63]+"==")):i===2&&(e=(t[r-2]<<8)+t[r-1],s.push(me[e>>10]+me[e>>4&63]+me[e<<2&63]+"=")),s.join("")}var gr={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */gr.read=function(t,e,r,i,s){var u,c,h=s*8-i-1,p=(1<<h)-1,m=p>>1,l=-7,w=r?s-1:0,E=r?-1:1,T=t[e+w];for(w+=E,u=T&(1<<-l)-1,T>>=-l,l+=h;l>0;u=u*256+t[e+w],w+=E,l-=8);for(c=u&(1<<-l)-1,u>>=-l,l+=i;l>0;c=c*256+t[e+w],w+=E,l-=8);if(u===0)u=1-m;else{if(u===p)return c?NaN:(T?-1:1)*(1/0);c=c+Math.pow(2,i),u=u-m}return(T?-1:1)*c*Math.pow(2,u-i)};gr.write=function(t,e,r,i,s,u){var c,h,p,m=u*8-s-1,l=(1<<m)-1,w=l>>1,E=s===23?Math.pow(2,-24)-Math.pow(2,-77):0,T=i?0:u-1,F=i?1:-1,x=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(h=isNaN(e)?1:0,c=l):(c=Math.floor(Math.log(e)/Math.LN2),e*(p=Math.pow(2,-c))<1&&(c--,p*=2),c+w>=1?e+=E/p:e+=E*Math.pow(2,1-w),e*p>=2&&(c++,p/=2),c+w>=l?(h=0,c=l):c+w>=1?(h=(e*p-1)*Math.pow(2,s),c=c+w):(h=e*Math.pow(2,w-1)*Math.pow(2,s),c=0));s>=8;t[r+T]=h&255,T+=F,h/=256,s-=8);for(c=c<<s|h,m+=s;m>0;t[r+T]=c&255,T+=F,c/=256,m-=8);t[r+T-F]|=x*128};/*!
|
|
3
3
|
* The buffer module from node.js, for the browser.
|
|
4
4
|
*
|
|
5
5
|
* @author Feross Aboukhadijeh <https://feross.org>
|
|
6
6
|
* @license MIT
|
|
7
|
-
*/(function(t){const e=Lt,r=pr,i=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=f,t.SlowBuffer=C,t.INSPECT_MAX_BYTES=50;const s=2147483647;t.kMaxLength=s;const{Uint8Array:u,ArrayBuffer:c,SharedArrayBuffer:h}=globalThis;f.TYPED_ARRAY_SUPPORT=p(),!f.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function p(){try{const a=new u(1),n={foo:function(){return 42}};return Object.setPrototypeOf(n,u.prototype),Object.setPrototypeOf(a,n),a.foo()===42}catch{return!1}}Object.defineProperty(f.prototype,"parent",{enumerable:!0,get:function(){if(f.isBuffer(this))return this.buffer}}),Object.defineProperty(f.prototype,"offset",{enumerable:!0,get:function(){if(f.isBuffer(this))return this.byteOffset}});function m(a){if(a>s)throw new RangeError('The value "'+a+'" is invalid for option "size"');const n=new u(a);return Object.setPrototypeOf(n,f.prototype),n}function f(a,n,o){if(typeof a=="number"){if(typeof n=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return F(a)}return w(a,n,o)}f.poolSize=8192;function w(a,n,o){if(typeof a=="string")return x(a,n);if(c.isView(a))return I(a);if(a==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof a);if(pe(a,c)||a&&pe(a.buffer,c)||typeof h<"u"&&(pe(a,h)||a&&pe(a.buffer,h)))return O(a,n,o);if(typeof a=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const l=a.valueOf&&a.valueOf();if(l!=null&&l!==a)return f.from(l,n,o);const d=j(a);if(d)return d;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof a[Symbol.toPrimitive]=="function")return f.from(a[Symbol.toPrimitive]("string"),n,o);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof a)}f.from=function(a,n,o){return w(a,n,o)},Object.setPrototypeOf(f.prototype,u.prototype),Object.setPrototypeOf(f,u);function E(a){if(typeof a!="number")throw new TypeError('"size" argument must be of type number');if(a<0)throw new RangeError('The value "'+a+'" is invalid for option "size"')}function T(a,n,o){return E(a),a<=0?m(a):n!==void 0?typeof o=="string"?m(a).fill(n,o):m(a).fill(n):m(a)}f.alloc=function(a,n,o){return T(a,n,o)};function F(a){return E(a),m(a<0?0:P(a)|0)}f.allocUnsafe=function(a){return F(a)},f.allocUnsafeSlow=function(a){return F(a)};function x(a,n){if((typeof n!="string"||n==="")&&(n="utf8"),!f.isEncoding(n))throw new TypeError("Unknown encoding: "+n);const o=k(a,n)|0;let l=m(o);const d=l.write(a,n);return d!==o&&(l=l.slice(0,d)),l}function N(a){const n=a.length<0?0:P(a.length)|0,o=m(n);for(let l=0;l<n;l+=1)o[l]=a[l]&255;return o}function I(a){if(pe(a,u)){const n=new u(a);return O(n.buffer,n.byteOffset,n.byteLength)}return N(a)}function O(a,n,o){if(n<0||a.byteLength<n)throw new RangeError('"offset" is outside of buffer bounds');if(a.byteLength<n+(o||0))throw new RangeError('"length" is outside of buffer bounds');let l;return n===void 0&&o===void 0?l=new u(a):o===void 0?l=new u(a,n):l=new u(a,n,o),Object.setPrototypeOf(l,f.prototype),l}function j(a){if(f.isBuffer(a)){const n=P(a.length)|0,o=m(n);return o.length===0||a.copy(o,0,0,n),o}if(a.length!==void 0)return typeof a.length!="number"||$t(a.length)?m(0):N(a);if(a.type==="Buffer"&&Array.isArray(a.data))return N(a.data)}function P(a){if(a>=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return a|0}function C(a){return+a!=a&&(a=0),f.alloc(+a)}f.isBuffer=function(n){return n!=null&&n._isBuffer===!0&&n!==f.prototype},f.compare=function(n,o){if(pe(n,u)&&(n=f.from(n,n.offset,n.byteLength)),pe(o,u)&&(o=f.from(o,o.offset,o.byteLength)),!f.isBuffer(n)||!f.isBuffer(o))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(n===o)return 0;let l=n.length,d=o.length;for(let y=0,b=Math.min(l,d);y<b;++y)if(n[y]!==o[y]){l=n[y],d=o[y];break}return l<d?-1:d<l?1:0},f.isEncoding=function(n){switch(String(n).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},f.concat=function(n,o){if(!Array.isArray(n))throw new TypeError('"list" argument must be an Array of Buffers');if(n.length===0)return f.alloc(0);let l;if(o===void 0)for(o=0,l=0;l<n.length;++l)o+=n[l].length;const d=f.allocUnsafe(o);let y=0;for(l=0;l<n.length;++l){let b=n[l];if(pe(b,u))y+b.length>d.length?(f.isBuffer(b)||(b=f.from(b)),b.copy(d,y)):u.prototype.set.call(d,b,y);else if(f.isBuffer(b))b.copy(d,y);else throw new TypeError('"list" argument must be an Array of Buffers');y+=b.length}return d};function k(a,n){if(f.isBuffer(a))return a.length;if(c.isView(a)||pe(a,c))return a.byteLength;if(typeof a!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof a);const o=a.length,l=arguments.length>2&&arguments[2]===!0;if(!l&&o===0)return 0;let d=!1;for(;;)switch(n){case"ascii":case"latin1":case"binary":return o;case"utf8":case"utf-8":return ft(a).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return o*2;case"hex":return o>>>1;case"base64":return Cr(a).length;default:if(d)return l?-1:ft(a).length;n=(""+n).toLowerCase(),d=!0}}f.byteLength=k;function B(a,n,o){let l=!1;if((n===void 0||n<0)&&(n=0),n>this.length||((o===void 0||o>this.length)&&(o=this.length),o<=0)||(o>>>=0,n>>>=0,o<=n))return"";for(a||(a="utf8");;)switch(a){case"hex":return g(this,n,o);case"utf8":case"utf-8":return Ge(this,n,o);case"ascii":return Be(this,n,o);case"latin1":case"binary":return ze(this,n,o);case"base64":return ke(this,n,o);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return v(this,n,o);default:if(l)throw new TypeError("Unknown encoding: "+a);a=(a+"").toLowerCase(),l=!0}}f.prototype._isBuffer=!0;function q(a,n,o){const l=a[n];a[n]=a[o],a[o]=l}f.prototype.swap16=function(){const n=this.length;if(n%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let o=0;o<n;o+=2)q(this,o,o+1);return this},f.prototype.swap32=function(){const n=this.length;if(n%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let o=0;o<n;o+=4)q(this,o,o+3),q(this,o+1,o+2);return this},f.prototype.swap64=function(){const n=this.length;if(n%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let o=0;o<n;o+=8)q(this,o,o+7),q(this,o+1,o+6),q(this,o+2,o+5),q(this,o+3,o+4);return this},f.prototype.toString=function(){const n=this.length;return n===0?"":arguments.length===0?Ge(this,0,n):B.apply(this,arguments)},f.prototype.toLocaleString=f.prototype.toString,f.prototype.equals=function(n){if(!f.isBuffer(n))throw new TypeError("Argument must be a Buffer");return this===n?!0:f.compare(this,n)===0},f.prototype.inspect=function(){let n="";const o=t.INSPECT_MAX_BYTES;return n=this.toString("hex",0,o).replace(/(.{2})/g,"$1 ").trim(),this.length>o&&(n+=" ... "),"<Buffer "+n+">"},i&&(f.prototype[i]=f.prototype.inspect),f.prototype.compare=function(n,o,l,d,y){if(pe(n,u)&&(n=f.from(n,n.offset,n.byteLength)),!f.isBuffer(n))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof n);if(o===void 0&&(o=0),l===void 0&&(l=n?n.length:0),d===void 0&&(d=0),y===void 0&&(y=this.length),o<0||l>n.length||d<0||y>this.length)throw new RangeError("out of range index");if(d>=y&&o>=l)return 0;if(d>=y)return-1;if(o>=l)return 1;if(o>>>=0,l>>>=0,d>>>=0,y>>>=0,this===n)return 0;let b=y-d,D=l-o;const W=Math.min(b,D),K=this.slice(d,y),H=n.slice(o,l);for(let z=0;z<W;++z)if(K[z]!==H[z]){b=K[z],D=H[z];break}return b<D?-1:D<b?1:0};function ie(a,n,o,l,d){if(a.length===0)return-1;if(typeof o=="string"?(l=o,o=0):o>2147483647?o=2147483647:o<-2147483648&&(o=-2147483648),o=+o,$t(o)&&(o=d?0:a.length-1),o<0&&(o=a.length+o),o>=a.length){if(d)return-1;o=a.length-1}else if(o<0)if(d)o=0;else return-1;if(typeof n=="string"&&(n=f.from(n,l)),f.isBuffer(n))return n.length===0?-1:we(a,n,o,l,d);if(typeof n=="number")return n=n&255,typeof u.prototype.indexOf=="function"?d?u.prototype.indexOf.call(a,n,o):u.prototype.lastIndexOf.call(a,n,o):we(a,[n],o,l,d);throw new TypeError("val must be string, number or Buffer")}function we(a,n,o,l,d){let y=1,b=a.length,D=n.length;if(l!==void 0&&(l=String(l).toLowerCase(),l==="ucs2"||l==="ucs-2"||l==="utf16le"||l==="utf-16le")){if(a.length<2||n.length<2)return-1;y=2,b/=2,D/=2,o/=2}function W(H,z){return y===1?H[z]:H.readUInt16BE(z*y)}let K;if(d){let H=-1;for(K=o;K<b;K++)if(W(a,K)===W(n,H===-1?0:K-H)){if(H===-1&&(H=K),K-H+1===D)return H*y}else H!==-1&&(K-=K-H),H=-1}else for(o+D>b&&(o=b-D),K=o;K>=0;K--){let H=!0;for(let z=0;z<D;z++)if(W(a,K+z)!==W(n,z)){H=!1;break}if(H)return K}return-1}f.prototype.includes=function(n,o,l){return this.indexOf(n,o,l)!==-1},f.prototype.indexOf=function(n,o,l){return ie(this,n,o,l,!0)},f.prototype.lastIndexOf=function(n,o,l){return ie(this,n,o,l,!1)};function be(a,n,o,l){o=Number(o)||0;const d=a.length-o;l?(l=Number(l),l>d&&(l=d)):l=d;const y=n.length;l>y/2&&(l=y/2);let b;for(b=0;b<l;++b){const D=parseInt(n.substr(b*2,2),16);if($t(D))return b;a[o+b]=D}return b}function ue(a,n,o,l){return mt(ft(n,a.length-o),a,o,l)}function lt(a,n,o,l){return mt(Fr(n),a,o,l)}function he(a,n,o,l){return mt(Cr(n),a,o,l)}function Re(a,n,o,l){return mt(Hn(n,a.length-o),a,o,l)}f.prototype.write=function(n,o,l,d){if(o===void 0)d="utf8",l=this.length,o=0;else if(l===void 0&&typeof o=="string")d=o,l=this.length,o=0;else if(isFinite(o))o=o>>>0,isFinite(l)?(l=l>>>0,d===void 0&&(d="utf8")):(d=l,l=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const y=this.length-o;if((l===void 0||l>y)&&(l=y),n.length>0&&(l<0||o<0)||o>this.length)throw new RangeError("Attempt to write outside buffer bounds");d||(d="utf8");let b=!1;for(;;)switch(d){case"hex":return be(this,n,o,l);case"utf8":case"utf-8":return ue(this,n,o,l);case"ascii":case"latin1":case"binary":return lt(this,n,o,l);case"base64":return he(this,n,o,l);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Re(this,n,o,l);default:if(b)throw new TypeError("Unknown encoding: "+d);d=(""+d).toLowerCase(),b=!0}},f.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function ke(a,n,o){return n===0&&o===a.length?e.fromByteArray(a):e.fromByteArray(a.slice(n,o))}function Ge(a,n,o){o=Math.min(a.length,o);const l=[];let d=n;for(;d<o;){const y=a[d];let b=null,D=y>239?4:y>223?3:y>191?2:1;if(d+D<=o){let W,K,H,z;switch(D){case 1:y<128&&(b=y);break;case 2:W=a[d+1],(W&192)===128&&(z=(y&31)<<6|W&63,z>127&&(b=z));break;case 3:W=a[d+1],K=a[d+2],(W&192)===128&&(K&192)===128&&(z=(y&15)<<12|(W&63)<<6|K&63,z>2047&&(z<55296||z>57343)&&(b=z));break;case 4:W=a[d+1],K=a[d+2],H=a[d+3],(W&192)===128&&(K&192)===128&&(H&192)===128&&(z=(y&15)<<18|(W&63)<<12|(K&63)<<6|H&63,z>65535&&z<1114112&&(b=z))}}b===null?(b=65533,D=1):b>65535&&(b-=65536,l.push(b>>>10&1023|55296),b=56320|b&1023),l.push(b),d+=D}return ce(l)}const ve=4096;function ce(a){const n=a.length;if(n<=ve)return String.fromCharCode.apply(String,a);let o="",l=0;for(;l<n;)o+=String.fromCharCode.apply(String,a.slice(l,l+=ve));return o}function Be(a,n,o){let l="";o=Math.min(a.length,o);for(let d=n;d<o;++d)l+=String.fromCharCode(a[d]&127);return l}function ze(a,n,o){let l="";o=Math.min(a.length,o);for(let d=n;d<o;++d)l+=String.fromCharCode(a[d]);return l}function g(a,n,o){const l=a.length;(!n||n<0)&&(n=0),(!o||o<0||o>l)&&(o=l);let d="";for(let y=n;y<o;++y)d+=Jn[a[y]];return d}function v(a,n,o){const l=a.slice(n,o);let d="";for(let y=0;y<l.length-1;y+=2)d+=String.fromCharCode(l[y]+l[y+1]*256);return d}f.prototype.slice=function(n,o){const l=this.length;n=~~n,o=o===void 0?l:~~o,n<0?(n+=l,n<0&&(n=0)):n>l&&(n=l),o<0?(o+=l,o<0&&(o=0)):o>l&&(o=l),o<n&&(o=n);const d=this.subarray(n,o);return Object.setPrototypeOf(d,f.prototype),d};function S(a,n,o){if(a%1!==0||a<0)throw new RangeError("offset is not uint");if(a+n>o)throw new RangeError("Trying to access beyond buffer length")}f.prototype.readUintLE=f.prototype.readUIntLE=function(n,o,l){n=n>>>0,o=o>>>0,l||S(n,o,this.length);let d=this[n],y=1,b=0;for(;++b<o&&(y*=256);)d+=this[n+b]*y;return d},f.prototype.readUintBE=f.prototype.readUIntBE=function(n,o,l){n=n>>>0,o=o>>>0,l||S(n,o,this.length);let d=this[n+--o],y=1;for(;o>0&&(y*=256);)d+=this[n+--o]*y;return d},f.prototype.readUint8=f.prototype.readUInt8=function(n,o){return n=n>>>0,o||S(n,1,this.length),this[n]},f.prototype.readUint16LE=f.prototype.readUInt16LE=function(n,o){return n=n>>>0,o||S(n,2,this.length),this[n]|this[n+1]<<8},f.prototype.readUint16BE=f.prototype.readUInt16BE=function(n,o){return n=n>>>0,o||S(n,2,this.length),this[n]<<8|this[n+1]},f.prototype.readUint32LE=f.prototype.readUInt32LE=function(n,o){return n=n>>>0,o||S(n,4,this.length),(this[n]|this[n+1]<<8|this[n+2]<<16)+this[n+3]*16777216},f.prototype.readUint32BE=f.prototype.readUInt32BE=function(n,o){return n=n>>>0,o||S(n,4,this.length),this[n]*16777216+(this[n+1]<<16|this[n+2]<<8|this[n+3])},f.prototype.readBigUInt64LE=Pe(function(n){n=n>>>0,Se(n,"offset");const o=this[n],l=this[n+7];(o===void 0||l===void 0)&&$e(n,this.length-8);const d=o+this[++n]*2**8+this[++n]*2**16+this[++n]*2**24,y=this[++n]+this[++n]*2**8+this[++n]*2**16+l*2**24;return BigInt(d)+(BigInt(y)<<BigInt(32))}),f.prototype.readBigUInt64BE=Pe(function(n){n=n>>>0,Se(n,"offset");const o=this[n],l=this[n+7];(o===void 0||l===void 0)&&$e(n,this.length-8);const d=o*2**24+this[++n]*2**16+this[++n]*2**8+this[++n],y=this[++n]*2**24+this[++n]*2**16+this[++n]*2**8+l;return(BigInt(d)<<BigInt(32))+BigInt(y)}),f.prototype.readIntLE=function(n,o,l){n=n>>>0,o=o>>>0,l||S(n,o,this.length);let d=this[n],y=1,b=0;for(;++b<o&&(y*=256);)d+=this[n+b]*y;return y*=128,d>=y&&(d-=Math.pow(2,8*o)),d},f.prototype.readIntBE=function(n,o,l){n=n>>>0,o=o>>>0,l||S(n,o,this.length);let d=o,y=1,b=this[n+--d];for(;d>0&&(y*=256);)b+=this[n+--d]*y;return y*=128,b>=y&&(b-=Math.pow(2,8*o)),b},f.prototype.readInt8=function(n,o){return n=n>>>0,o||S(n,1,this.length),this[n]&128?(255-this[n]+1)*-1:this[n]},f.prototype.readInt16LE=function(n,o){n=n>>>0,o||S(n,2,this.length);const l=this[n]|this[n+1]<<8;return l&32768?l|4294901760:l},f.prototype.readInt16BE=function(n,o){n=n>>>0,o||S(n,2,this.length);const l=this[n+1]|this[n]<<8;return l&32768?l|4294901760:l},f.prototype.readInt32LE=function(n,o){return n=n>>>0,o||S(n,4,this.length),this[n]|this[n+1]<<8|this[n+2]<<16|this[n+3]<<24},f.prototype.readInt32BE=function(n,o){return n=n>>>0,o||S(n,4,this.length),this[n]<<24|this[n+1]<<16|this[n+2]<<8|this[n+3]},f.prototype.readBigInt64LE=Pe(function(n){n=n>>>0,Se(n,"offset");const o=this[n],l=this[n+7];(o===void 0||l===void 0)&&$e(n,this.length-8);const d=this[n+4]+this[n+5]*2**8+this[n+6]*2**16+(l<<24);return(BigInt(d)<<BigInt(32))+BigInt(o+this[++n]*2**8+this[++n]*2**16+this[++n]*2**24)}),f.prototype.readBigInt64BE=Pe(function(n){n=n>>>0,Se(n,"offset");const o=this[n],l=this[n+7];(o===void 0||l===void 0)&&$e(n,this.length-8);const d=(o<<24)+this[++n]*2**16+this[++n]*2**8+this[++n];return(BigInt(d)<<BigInt(32))+BigInt(this[++n]*2**24+this[++n]*2**16+this[++n]*2**8+l)}),f.prototype.readFloatLE=function(n,o){return n=n>>>0,o||S(n,4,this.length),r.read(this,n,!0,23,4)},f.prototype.readFloatBE=function(n,o){return n=n>>>0,o||S(n,4,this.length),r.read(this,n,!1,23,4)},f.prototype.readDoubleLE=function(n,o){return n=n>>>0,o||S(n,8,this.length),r.read(this,n,!0,52,8)},f.prototype.readDoubleBE=function(n,o){return n=n>>>0,o||S(n,8,this.length),r.read(this,n,!1,52,8)};function _(a,n,o,l,d,y){if(!f.isBuffer(a))throw new TypeError('"buffer" argument must be a Buffer instance');if(n>d||n<y)throw new RangeError('"value" argument is out of bounds');if(o+l>a.length)throw new RangeError("Index out of range")}f.prototype.writeUintLE=f.prototype.writeUIntLE=function(n,o,l,d){if(n=+n,o=o>>>0,l=l>>>0,!d){const D=Math.pow(2,8*l)-1;_(this,n,o,l,D,0)}let y=1,b=0;for(this[o]=n&255;++b<l&&(y*=256);)this[o+b]=n/y&255;return o+l},f.prototype.writeUintBE=f.prototype.writeUIntBE=function(n,o,l,d){if(n=+n,o=o>>>0,l=l>>>0,!d){const D=Math.pow(2,8*l)-1;_(this,n,o,l,D,0)}let y=l-1,b=1;for(this[o+y]=n&255;--y>=0&&(b*=256);)this[o+y]=n/b&255;return o+l},f.prototype.writeUint8=f.prototype.writeUInt8=function(n,o,l){return n=+n,o=o>>>0,l||_(this,n,o,1,255,0),this[o]=n&255,o+1},f.prototype.writeUint16LE=f.prototype.writeUInt16LE=function(n,o,l){return n=+n,o=o>>>0,l||_(this,n,o,2,65535,0),this[o]=n&255,this[o+1]=n>>>8,o+2},f.prototype.writeUint16BE=f.prototype.writeUInt16BE=function(n,o,l){return n=+n,o=o>>>0,l||_(this,n,o,2,65535,0),this[o]=n>>>8,this[o+1]=n&255,o+2},f.prototype.writeUint32LE=f.prototype.writeUInt32LE=function(n,o,l){return n=+n,o=o>>>0,l||_(this,n,o,4,4294967295,0),this[o+3]=n>>>24,this[o+2]=n>>>16,this[o+1]=n>>>8,this[o]=n&255,o+4},f.prototype.writeUint32BE=f.prototype.writeUInt32BE=function(n,o,l){return n=+n,o=o>>>0,l||_(this,n,o,4,4294967295,0),this[o]=n>>>24,this[o+1]=n>>>16,this[o+2]=n>>>8,this[o+3]=n&255,o+4};function M(a,n,o,l,d){De(n,l,d,a,o,7);let y=Number(n&BigInt(4294967295));a[o++]=y,y=y>>8,a[o++]=y,y=y>>8,a[o++]=y,y=y>>8,a[o++]=y;let b=Number(n>>BigInt(32)&BigInt(4294967295));return a[o++]=b,b=b>>8,a[o++]=b,b=b>>8,a[o++]=b,b=b>>8,a[o++]=b,o}function V(a,n,o,l,d){De(n,l,d,a,o,7);let y=Number(n&BigInt(4294967295));a[o+7]=y,y=y>>8,a[o+6]=y,y=y>>8,a[o+5]=y,y=y>>8,a[o+4]=y;let b=Number(n>>BigInt(32)&BigInt(4294967295));return a[o+3]=b,b=b>>8,a[o+2]=b,b=b>>8,a[o+1]=b,b=b>>8,a[o]=b,o+8}f.prototype.writeBigUInt64LE=Pe(function(n,o=0){return M(this,n,o,BigInt(0),BigInt("0xffffffffffffffff"))}),f.prototype.writeBigUInt64BE=Pe(function(n,o=0){return V(this,n,o,BigInt(0),BigInt("0xffffffffffffffff"))}),f.prototype.writeIntLE=function(n,o,l,d){if(n=+n,o=o>>>0,!d){const W=Math.pow(2,8*l-1);_(this,n,o,l,W-1,-W)}let y=0,b=1,D=0;for(this[o]=n&255;++y<l&&(b*=256);)n<0&&D===0&&this[o+y-1]!==0&&(D=1),this[o+y]=(n/b>>0)-D&255;return o+l},f.prototype.writeIntBE=function(n,o,l,d){if(n=+n,o=o>>>0,!d){const W=Math.pow(2,8*l-1);_(this,n,o,l,W-1,-W)}let y=l-1,b=1,D=0;for(this[o+y]=n&255;--y>=0&&(b*=256);)n<0&&D===0&&this[o+y+1]!==0&&(D=1),this[o+y]=(n/b>>0)-D&255;return o+l},f.prototype.writeInt8=function(n,o,l){return n=+n,o=o>>>0,l||_(this,n,o,1,127,-128),n<0&&(n=255+n+1),this[o]=n&255,o+1},f.prototype.writeInt16LE=function(n,o,l){return n=+n,o=o>>>0,l||_(this,n,o,2,32767,-32768),this[o]=n&255,this[o+1]=n>>>8,o+2},f.prototype.writeInt16BE=function(n,o,l){return n=+n,o=o>>>0,l||_(this,n,o,2,32767,-32768),this[o]=n>>>8,this[o+1]=n&255,o+2},f.prototype.writeInt32LE=function(n,o,l){return n=+n,o=o>>>0,l||_(this,n,o,4,2147483647,-2147483648),this[o]=n&255,this[o+1]=n>>>8,this[o+2]=n>>>16,this[o+3]=n>>>24,o+4},f.prototype.writeInt32BE=function(n,o,l){return n=+n,o=o>>>0,l||_(this,n,o,4,2147483647,-2147483648),n<0&&(n=4294967295+n+1),this[o]=n>>>24,this[o+1]=n>>>16,this[o+2]=n>>>8,this[o+3]=n&255,o+4},f.prototype.writeBigInt64LE=Pe(function(n,o=0){return M(this,n,o,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),f.prototype.writeBigInt64BE=Pe(function(n,o=0){return V(this,n,o,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function R(a,n,o,l,d,y){if(o+l>a.length)throw new RangeError("Index out of range");if(o<0)throw new RangeError("Index out of range")}function $(a,n,o,l,d){return n=+n,o=o>>>0,d||R(a,n,o,4),r.write(a,n,o,l,23,4),o+4}f.prototype.writeFloatLE=function(n,o,l){return $(this,n,o,!0,l)},f.prototype.writeFloatBE=function(n,o,l){return $(this,n,o,!1,l)};function Q(a,n,o,l,d){return n=+n,o=o>>>0,d||R(a,n,o,8),r.write(a,n,o,l,52,8),o+8}f.prototype.writeDoubleLE=function(n,o,l){return Q(this,n,o,!0,l)},f.prototype.writeDoubleBE=function(n,o,l){return Q(this,n,o,!1,l)},f.prototype.copy=function(n,o,l,d){if(!f.isBuffer(n))throw new TypeError("argument should be a Buffer");if(l||(l=0),!d&&d!==0&&(d=this.length),o>=n.length&&(o=n.length),o||(o=0),d>0&&d<l&&(d=l),d===l||n.length===0||this.length===0)return 0;if(o<0)throw new RangeError("targetStart out of bounds");if(l<0||l>=this.length)throw new RangeError("Index out of range");if(d<0)throw new RangeError("sourceEnd out of bounds");d>this.length&&(d=this.length),n.length-o<d-l&&(d=n.length-o+l);const y=d-l;return this===n&&typeof u.prototype.copyWithin=="function"?this.copyWithin(o,l,d):u.prototype.set.call(n,this.subarray(l,d),o),y},f.prototype.fill=function(n,o,l,d){if(typeof n=="string"){if(typeof o=="string"?(d=o,o=0,l=this.length):typeof l=="string"&&(d=l,l=this.length),d!==void 0&&typeof d!="string")throw new TypeError("encoding must be a string");if(typeof d=="string"&&!f.isEncoding(d))throw new TypeError("Unknown encoding: "+d);if(n.length===1){const b=n.charCodeAt(0);(d==="utf8"&&b<128||d==="latin1")&&(n=b)}}else typeof n=="number"?n=n&255:typeof n=="boolean"&&(n=Number(n));if(o<0||this.length<o||this.length<l)throw new RangeError("Out of range index");if(l<=o)return this;o=o>>>0,l=l===void 0?this.length:l>>>0,n||(n=0);let y;if(typeof n=="number")for(y=o;y<l;++y)this[y]=n;else{const b=f.isBuffer(n)?n:f.from(n,d),D=b.length;if(D===0)throw new TypeError('The value "'+n+'" is invalid for argument "value"');for(y=0;y<l-o;++y)this[y+o]=b[y%D]}return this};const J={};function le(a,n,o){J[a]=class extends o{constructor(){super(),Object.defineProperty(this,"message",{value:n.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${a}]`,this.stack,delete this.name}get code(){return a}set code(d){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:d,writable:!0})}toString(){return`${this.name} [${a}]: ${this.message}`}}}le("ERR_BUFFER_OUT_OF_BOUNDS",function(a){return a?`${a} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),le("ERR_INVALID_ARG_TYPE",function(a,n){return`The "${a}" argument must be of type number. Received type ${typeof n}`},TypeError),le("ERR_OUT_OF_RANGE",function(a,n,o){let l=`The value of "${a}" is out of range.`,d=o;return Number.isInteger(o)&&Math.abs(o)>2**32?d=Ne(String(o)):typeof o=="bigint"&&(d=String(o),(o>BigInt(2)**BigInt(32)||o<-(BigInt(2)**BigInt(32)))&&(d=Ne(d)),d+="n"),l+=` It must be ${n}. Received ${d}`,l},RangeError);function Ne(a){let n="",o=a.length;const l=a[0]==="-"?1:0;for(;o>=l+4;o-=3)n=`_${a.slice(o-3,o)}${n}`;return`${a.slice(0,o)}${n}`}function Le(a,n,o){Se(n,"offset"),(a[n]===void 0||a[n+o]===void 0)&&$e(n,a.length-(o+1))}function De(a,n,o,l,d,y){if(a>o||a<n){const b=typeof n=="bigint"?"n":"";let D;throw y>3?n===0||n===BigInt(0)?D=`>= 0${b} and < 2${b} ** ${(y+1)*8}${b}`:D=`>= -(2${b} ** ${(y+1)*8-1}${b}) and < 2 ** ${(y+1)*8-1}${b}`:D=`>= ${n}${b} and <= ${o}${b}`,new J.ERR_OUT_OF_RANGE("value",D,a)}Le(l,d,y)}function Se(a,n){if(typeof a!="number")throw new J.ERR_INVALID_ARG_TYPE(n,"number",a)}function $e(a,n,o){throw Math.floor(a)!==a?(Se(a,o),new J.ERR_OUT_OF_RANGE(o||"offset","an integer",a)):n<0?new J.ERR_BUFFER_OUT_OF_BOUNDS:new J.ERR_OUT_OF_RANGE(o||"offset",`>= ${o?1:0} and <= ${n}`,a)}const Dt=/[^+/0-9A-Za-z-_]/g;function A(a){if(a=a.split("=")[0],a=a.trim().replace(Dt,""),a.length<2)return"";for(;a.length%4!==0;)a=a+"=";return a}function ft(a,n){n=n||1/0;let o;const l=a.length;let d=null;const y=[];for(let b=0;b<l;++b){if(o=a.charCodeAt(b),o>55295&&o<57344){if(!d){if(o>56319){(n-=3)>-1&&y.push(239,191,189);continue}else if(b+1===l){(n-=3)>-1&&y.push(239,191,189);continue}d=o;continue}if(o<56320){(n-=3)>-1&&y.push(239,191,189),d=o;continue}o=(d-55296<<10|o-56320)+65536}else d&&(n-=3)>-1&&y.push(239,191,189);if(d=null,o<128){if((n-=1)<0)break;y.push(o)}else if(o<2048){if((n-=2)<0)break;y.push(o>>6|192,o&63|128)}else if(o<65536){if((n-=3)<0)break;y.push(o>>12|224,o>>6&63|128,o&63|128)}else if(o<1114112){if((n-=4)<0)break;y.push(o>>18|240,o>>12&63|128,o>>6&63|128,o&63|128)}else throw new Error("Invalid code point")}return y}function Fr(a){const n=[];for(let o=0;o<a.length;++o)n.push(a.charCodeAt(o)&255);return n}function Hn(a,n){let o,l,d;const y=[];for(let b=0;b<a.length&&!((n-=2)<0);++b)o=a.charCodeAt(b),l=o>>8,d=o%256,y.push(d),y.push(l);return y}function Cr(a){return e.toByteArray(A(a))}function mt(a,n,o,l){let d;for(d=0;d<l&&!(d+o>=n.length||d>=a.length);++d)n[d+o]=a[d];return d}function pe(a,n){return a instanceof n||a!=null&&a.constructor!=null&&a.constructor.name!=null&&a.constructor.name===n.name}function $t(a){return a!==a}const Jn=function(){const a="0123456789abcdef",n=new Array(256);for(let o=0;o<16;++o){const l=o*16;for(let d=0;d<16;++d)n[l+d]=a[o]+a[d]}return n}();function Pe(a){return typeof BigInt>"u"?Yn:a}function Yn(){throw new Error("BigInt not supported")}})(pn);const Pr=pn.Buffer;var gn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ji(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var yr={exports:{}};const Yi=Object.getPrototypeOf({});function gr(t){function e(I){return I!=="constructor"&&I!=="prototype"&&I!=="__proto__"}function r(I){let O=0;const j=I.length,P=new Array(j);for(O=0;O<j;++O)P[O]=T(I[O]);return P}function i(I){const O={};if(p&&Object.getPrototypeOf(I)!==Yi)return p(I);const j=h(I);let P,C,k;for(P=0,C=j.length;P<C;++P)e(k=j[P])&&(O[k]=T(I[k]));return O}function s(I,O){const j=I.length,P=O.length;let C=0;const k=new Array(j+P);for(C=0;C<j;++C)k[C]=T(I[C]);for(C=0;C<P;++C)k[C+j]=T(O[C]);return k}const u=Object.prototype.propertyIsEnumerable;function c(I){const O=Object.keys(I),j=Object.getOwnPropertySymbols(I);for(let P=0,C=j.length;P<C;++P)u.call(I,j[P])&&O.push(j[P]);return O}const h=t&&t.symbols?c:Object.keys,p=typeof t?.cloneProtoObject=="function"?t.cloneProtoObject:void 0;function m(I){return typeof I=="object"&&I!==null&&!(I instanceof RegExp)&&!(I instanceof Date)}function f(I){return typeof I!="object"||I===null}const w=typeof Pr<"u"?I=>typeof I!="object"||I===null||I instanceof RegExp||I instanceof Date||I instanceof Pr:I=>typeof I!="object"||I===null||I instanceof RegExp||I instanceof Date,E=t&&typeof t.mergeArray=="function"?t.mergeArray({clone:T,deepmerge:x,getKeys:h,isMergeableObject:m}):s;function T(I){return m(I)?Array.isArray(I)?r(I):i(I):I}function F(I,O){const j={},P=h(I),C=h(O);let k,B,q;for(k=0,B=P.length;k<B;++k)e(q=P[k])&&C.indexOf(q)===-1&&(j[q]=T(I[q]));for(k=0,B=C.length;k<B;++k)e(q=C[k])&&(q in I&&(P.indexOf(q)!==-1&&(j[q]=x(I[q],O[q])),!0)||(j[q]=T(O[q])));return j}function x(I,O){const j=Array.isArray(O),P=Array.isArray(I);return f(O)?O:w(I)?T(O):j&&P?E(I,O):j!==P?T(O):F(I,O)}function N(){switch(arguments.length){case 0:return{};case 1:return T(arguments[0]);case 2:return x(arguments[0],arguments[1])}let I;for(let O=0,j=arguments.length;O<j;++O)I=x(I,arguments[O]);return I}return t&&t.all?N:x}yr.exports=gr;yr.exports.default=gr;var Xi=yr.exports.deepmerge=gr;const Zi=t=>(e,r)=>{let i=0;const s=e.length,u=r.length,c=Math.max(s,u),h=new Array(c);for(i=0;i<c;++i)i<u?h[i]=t.deepmerge(e[i],r[i]):h[i]=t.clone(e[i]);return h},eo=Xi({mergeArray:Zi}),to=(t,e,r)=>{const i=Fe.computed([e,r],(c,h)=>{if(c){const p=h.data?.find(m=>m.id===c);if(p)return p;console.error("Feed list is not loaded yet. Issue with the opened question.")}}),s=Oe({data:void 0,loading:void 0,error:void 0});return i.subscribe(async c=>{if(c&&c.type==="question"){s.setKey("loading",!0);const h=await hn(c.id,t);s.set({data:h,loading:!1});return}s.set({data:void 0,loading:!1})}),{$store:i,$extendedStore:s,updateExtendedQuestion:c=>{const h=s.get().data;if(h&&c?.answers)for(const p of c.answers)p.youVoted!==!0&&delete p.youVoted;s.set({data:eo(h,c)})}}};var Ve;(function(t){t.ALLOWED="allowed",t.DISALLOWED="disallowed"})(Ve||(Ve={}));class ro{slStreamId;organizationId;userId;interactiveAllowed;openedQuestionId;openedQuestion;activeQuestionId;feedList;moderationId;moderation;feedSubscription;questionSubscription;notifications;log;constructor(e){this.log=dn("gamification-background"),this.slStreamId=e.stores.slStreamId.getAtomStore(),this.organizationId=e.stores.organizationSettings.getAtomStore(),this.userId=e.stores.user.getAtomStore(),this.moderationId=new ae(ne(void 0),"moderationId").getStore(),this.interactiveAllowed=new ae(ne(Ve.DISALLOWED),"interactiveAllowed").getStore(),this.openedQuestionId=new ae(ne(void 0),"openedQuestionId").getStore(),this.notifications=e.notifications,this.moderation=new de(Di(this.slStreamId,e.transport),"gamification:moderation"),this.feedList=new de(Mi(this.slStreamId,this.interactiveAllowed,e.transport),"gamification:feedList"),this.activeQuestionId=new de($i(this.slStreamId,e.transport),"gamification:activeQuestionId"),this.openedQuestion=to(e.transport,this.openedQuestionId,this.feedList.getStore()),this.openedQuestionId.listen(r=>{this.log.debug({questionId:r},"received question"),r?(this.questionSubscription=ji(r,e.transport),this.questionSubscription.addListener("feed-subscription-opened-question",i=>{window.requestAnimationFrame(()=>{this.openedQuestion.updateExtendedQuestion(i.data?.attributes?.question)})}),this.questionSubscription.connect()):(this.log.info("cleanup on close question"),this.questionSubscription!==void 0&&(e.transport.removeSubscription(this.questionSubscription),this.questionSubscription=void 0))}),this.feedSubscription=Ui(this.slStreamId,e.transport),this.feedSubscription.addListener("feed-subscription-active-question",r=>{const i=this.activeQuestionId.getStore();i&&i.mutate(r.data?.attributes)}),this.feedSubscription.addListener("moderation update",r=>{window.requestAnimationFrame(()=>{r.data?.attributes?.question===void 0&&r.data?.attributes?.moderation&&this.moderation.invalidate()})}),this.feedSubscription.connect(),this.interactiveAllowed.listen(()=>{window.requestAnimationFrame(()=>{this.activeQuestionId.invalidate()})})}getCurrentSessionId=e=>{const r=e.eventId||this.slStreamId.get()||"",i=e.userId||this.userId.get()||"",s=e.organizationId||this.organizationId.get()||"",u=e.entity||"",c=e.prefix||"";return[s,r,i,c,u].join(":")};disconnect=()=>{this.feedSubscription?.disconnect()};openQuestion=e=>{this.openedQuestionId.set(e),this.notifications.markAsViewed(this.getCurrentSessionId({prefix:"notification",entity:e}))};closeQuestion=e=>{this.openedQuestionId.set(void 0),e&&this.notifications.markAsViewed(this.getCurrentSessionId({prefix:"notification",entity:e}))}}class no{notificationsList;notifications;store;timeouts;waitingQueue;activeQueue;options;logger;constructor(e){this.options=e,this.logger=dn("notifications"),this.store=new Map,this.timeouts=new Map,this.waitingQueue=new Set,this.activeQueue=new Set,this.notifications=new ae(ne(new Map),"notifications-queue"),this.notificationsList=this.notifications.getStore()}addToQueue=e=>{if(this.store.has(e.id)){this.logger.debug({notification:e},"skip existed notification: %o");return}const r=e.close,i=e.action;if(this.store.set(e.id,{...e,close:(...s)=>{r&&r(...s),this.closeNotification(e.id)},action:(...s)=>{i&&i(...s),this.closeNotification(e.id)}}),this.waitingQueue.add(e.id),this.activeQueue.size===this.options.concurrency){const[s]=this.activeQueue;if(this.store.get(s)?.persistent!==!0)this.closeNotification(s);else{const[c]=this.waitingQueue;this.waitingQueue.size>1&&this.closeNotification(c),this.tickWaitingQueue()}}else this.tickWaitingQueue()};tickWaitingQueue=()=>{if(this.activeQueue.size<this.options.concurrency){const[e]=this.waitingQueue;if(!e)return;this.activeQueue.add(e),this.waitingQueue.delete(e),this.logger.debug({job:e},"waiting queue tick"),this.tickActiveQueue(e)}else this.logger.debug({queueSize:this.activeQueue.size,concurrency:this.options.concurrency},"waiting queue tick skipped")};tickActiveQueue=e=>{if(!e)return;const r=this.store.get(e);if(!r){this.logger.debug({notificationId:e},"active queue tick skipped, notification not exist");return}const i=setTimeout(()=>{const s=e,u=new Map(this.notifications.getValue());u.set(r.id,r),this.notifications.setValue(u);const c=setTimeout(()=>{this.logger.debug({notificationId:s,delay:r.autoHideDuration||5e3},"notification hiding by autoHideDuration"),this.closeNotification(s)},r.autoHideDuration||5e3);this.timeouts.set(s,c),this.logger.debug({notificationId:s,queue:[...u.values()]},"notification displayed")},r.delay||0);this.timeouts.set(e,i),this.logger.debug({notificationId:e},"active queue tick completed"),this.tickWaitingQueue()};closeNotification=e=>{const r=new Map(this.notifications.getValue()),i=r.get(e);if(i){i.hiding=!(this.waitingQueue.size>=this.options.concurrency),this.notifications.setValue(r);const s=setTimeout(()=>{const u=new Map(this.notifications.getValue());u.delete(e),this.notifications.setValue(u);const c=this.timeouts.get(e);c!==void 0&&(clearTimeout(c),this.timeouts.delete(e)),this.logger.debug({notificationId:e},"notification hidden")},this.options.animationDelay||0);this.timeouts.set(e,s)}this.store.delete(e),this.activeQueue.delete(e),this.waitingQueue.delete(e),this.tickWaitingQueue(),this.logger.debug({notificationId:e},"notification hiding")}}var Tt;(function(t){t.OPENED="opened"})(Tt||(Tt={}));class io extends Bt{constructor(){super("notification")}setOpened=e=>{this.write(Tt.OPENED,e,"true")};isOpened=e=>this.read(Tt.OPENED,e);clearNotification=()=>{this.clear()}}var Me;(function(t){t[t.ONBOARDING=1]="ONBOARDING",t[t.QUESTION=2]="QUESTION",t[t.QUESTION_RESOLVED=3]="QUESTION_RESOLVED"})(Me||(Me={}));class oo{queue;storage;constructor(e={}){this.storage=new io,this.queue=new no({concurrency:1,animationDelay:1600,...e})}add=e=>{this.storage.isOpened(e.id)||this.queue.addToQueue(e)};close=(e,r=!0)=>{this.queue.closeNotification(e),r&&this.markAsViewed(e)};getQueueStore=()=>this.queue.notificationsList;markAsViewed=e=>{this.storage.setOpened(e)}}const so=(t,e,r)=>{t.notifications=new oo,t.addNotification=t.notifications.add,t.sdk.getNotificationsStore=()=>t.notifications.getQueueStore(),r()},ao=(t,e)=>{const{client:r}=t.createPromiseClient(Ce.Feed,{method:"submitAnswer"});return r.submitAnswer({data:e})},uo=(t,e)=>{const{client:r}=t.createPromiseClient(Ce.Feed,{method:"submitInplay"});return r.submitInplay({data:{eventId:+e}})},co=(t,e)=>{const{client:r}=t.createPromiseClient(Ce.Feed,{method:"skipQuestion"});return r.skipQuestion({data:{id:e}})};var Ze;(function(t){t.ONBOARDING="onboarding",t.ONBOARDING_IO="onboarding_io"})(Ze||(Ze={}));class mn extends Bt{constructor(){super("gamification")}saveOnboardingStatus=({userId:e,eventId:r,organizationId:i},s)=>{this.write(Ze.ONBOARDING,i,e,r,s)};getOnboardingStatus=({userId:e,eventId:r,organizationId:i})=>this.read(Ze.ONBOARDING,i,e,r);setOnboardingInstantOpen=({userId:e,eventId:r,organizationId:i})=>{const s=this.generateKey([Ze.ONBOARDING_IO,i,e,r]);window.sessionStorage.setItem(s,"1")};getOnboardingInstantOpen=({userId:e,eventId:r,organizationId:i})=>{const s=this.generateKey([Ze.ONBOARDING_IO,i,e,r]);return window.sessionStorage.getItem(s)}}const Rr={pageSize:10},lo=(t,e,r,i,s)=>{let u=0;const c=ne({pageSize:s?.pageSize||Rr.pageSize,page:0}),h=Oe({data:[],key:Date.now(),hasMore:!0,loading:void 0,error:void 0}),p=Ri(t),m=async()=>{const E=e.get(),T=i.getStore().get().data?.map(F=>F.slId)||[];if(E&&T?.length){const F=r.get();F&&T.push(F),h.setKey("loading",!0),h.setKey("data",[]);const x={eventId:E,usersIds:T,pagination:{page:0,pageSize:s?.pageSize||Rr.pageSize}},N=await p(x);h.set({data:N.data.map(I=>I.attributes),hasMore:!0,key:Date.now(),loading:!1}),N.meta&&(u=Math.round(N.meta.count/N.meta.pageSize)),c.set(x.pagination)}},f=()=>{m()},w=E=>{const T=c.get(),F=E||T.page+1;F<=u&&c.set({...T,page:F})};return Fe.onMount(h,()=>{const E=e.listen(m),T=i.listen(m),F=c.listen(async x=>{const N=e.get();if(x.page>0&&N)if(x.page<u){h.setKey("loading",!0);const O=await p({eventId:N,pagination:x}),j=h.get().data||[];h.set({data:[...j,...O.data.map(P=>P.attributes)],key:h.get().key,loading:!1,hasMore:!0})}else h.setKey("hasMore",!1)});return()=>{E(),T(),F()}}),{$store:h,fetchMore:w,invalidate:f}},fo=(t,e)=>{const{client:r,queryKey:i}=t.createPromiseClient(yt.Client,{method:"generateDeepLink",params:e});return t.nanoquery.createFetcherStore(i,{fetcher:async(s,u,c,h)=>c?(await r.generateDeepLink({data:{gamification:!0,externalEventId:h,eventId:c}})).data?.attributes:{}})},ho=(t,{web:e,mobile:r})=>{const{client:i}=t.createPromiseClient(ei.LinksClient,{method:"generate"});return i.generate({web:e,mobile:r})},Nr=(t,e)=>{const r=new URLSearchParams(t);for(const[i,s]of Object.entries(e))r.append(i,s);return r.toString()},po=(t,e,r,i)=>{const s=Oe({});return Fe.onMount(s,()=>fo(t,[e,r]).subscribe(async({data:h,error:p,loading:m})=>{const f=p?"https://masters.com":h?.url,w=i.get()||"",E=e.get()||"",T=r.get()||"",F={[hr]:w,[ln]:E,[fn]:T};if(!m&&f){s.setKey("loading",!0);let x=window.location.search,N=window.location.hash;x&&N||N?x=`?${Nr(x,F)}`:N=`#${Nr("",F)}`;const I=window.location.origin+window.location.pathname+x+N,O=await ho(t,{web:I,mobile:f});s.set({data:O.data?.link,loading:!1})}else s.setKey("loading",!0)})),{$store:s,fetch}};var ee;(function(t){t.Unset="unset",t.Required="required",t.Optional="optional",t.Completed="completed",t.Disabled="disabled",t.Unavailable="unavailable"})(ee||(ee={}));const yo=(t,e,r,i)=>{const{inplayGame:s}=t.featureSettings.get(),u=e.getCurrentSessionId({prefix:"onboarding"});s&&r.add({type:Me.ONBOARDING,id:u,action:t.openFeature,persistent:!0,autoHideDuration:1e6,data:{questionType:re.QuestionType.UNSET,onboarding:{...s,instantOpen:!i.getOnboardingInstantOpen({userId:e.userId.get()||"",organizationId:e.organizationId.get()||"",eventId:e.slStreamId.get()||""})}}})},wt=(t,e,r,i,s,u)=>{try{const c=e.userId.get();if(!c)return;if(s.getOnboardingStatus({userId:c,organizationId:e.organizationId.get()||"",eventId:e.slStreamId.get()||""})===ee.Completed){t.set(ee.Completed);for(const E of u)E();return}const p=e.moderation.getStore().value?.data,m=r.featureSettings.get().inplayGame;if(p===void 0||m===void 0)return;const f=p?.options?.onboardingEnabled,w=m?.titleCard?.optIn;f?w?t.set(ee.Required):t.set(ee.Optional):(w?t.set(ee.Unavailable):t.set(ee.Disabled),i.close(e.getCurrentSessionId({prefix:"onboarding"}),!1))}catch(c){console.error(c)}},go=(t,e,r,i)=>{let s=!1;const u=new mn,c=ne(ee.Unset);c.subscribe(m=>{m!==ee.Unset&&((m===ee.Optional||m===ee.Required)&&s===!1&&(yo(t,e,i,u),s=!0),m===ee.Completed&&e.activeQuestionId.invalidate(),u.setOnboardingInstantOpen({userId:e.userId.get()||"",organizationId:e.organizationId.get()||"",eventId:e.slStreamId.get()||""}))});const h=[];return wt(c,e,t,i,u,h),c.get()!==ee.Completed&&(h.push(e.userId.listen(m=>{m&&wt(c,e,t,i,u,h)})),h.push(e.moderation.listen(m=>{m.data&&wt(c,e,t,i,u,h)})),h.push(t.featureSettings.listen(m=>{m&&wt(c,e,t,i,u,h)}))),{$store:c,submitInplay:async()=>{const m=e.slStreamId.get();if(m){await uo(r,m),c.set(ee.Completed),u.saveOnboardingStatus({organizationId:e.organizationId.get()||"",userId:e.userId.get()||"",eventId:m},ee.Completed);const f=e.getCurrentSessionId({prefix:"onboarding"});i.close(f)}}}},mo=new Set([re.QuestionType.POLL,re.QuestionType.PREDICTION,re.QuestionType.TRIVIA]);class wo extends cn{userSummary;feedList;friends;leaderboardId;leaderboardList;deepLink;onboardingStatus;openedQuestion;currentUserId;openedUser;closeFeature;openFeature;notifications;transport;background;storage;constructor(e,r,i){super(e,r),this.background=new ro(i),this.storage=new mn,this.userSummary=new de(Pi(this.background.slStreamId,this.background.userId,i.transport),"gamification:userSummary"),this.feedList=this.background.feedList,this.friends=new de(Ni(this.background.userId,i.transport),"gamification:friends"),this.currentUserId=this.background.userId,this.openedUser=ne(void 0),this.leaderboardId=new ae(ne(this.settings.getValue("pinnedLeaderboardId")),"pinnedLeaderboardId").getStore(),this.onboardingStatus=go(this,this.background,i.transport,i.notifications),this.notifications=i.notifications,this.transport=i.transport,this.closeFeature=()=>i.sdk.closeFeature(!0),this.openFeature=()=>i.sdk.openFeature(Te.SdkOverlayType.GAMES),this.openedQuestion=this.background.openedQuestion,this.deepLink=po(this.transport,this.background.slStreamId,i.stores.providerStreamId.getStore(),this.background.userId),this.leaderboardList=lo(this.transport,this.background.slStreamId,this.background.userId,this.friends),this.status.subscribe(s=>{s===nt.Ready?this.connect(i.transport):this.disconnect()}),this.userSummary.listen(s=>{this.leaderboardList.$store.lc!==0&&s?.data?.summary&&window.requestAnimationFrame(()=>{this.leaderboardList.invalidate()})}),this.background.activeQuestionId.listen(this.showInApp),this.onboardingStatus.$store.listen(this.checkInteractiveFlag),this.background.moderation.getStore().listen(this.checkInteractiveFlag),this.settings.subscribe(this.checkInteractiveFlag)}get isInteractiveAllowed(){return this.background.interactiveAllowed.get()===Ve.ALLOWED}checkInteractiveFlag=()=>{const e=this.onboardingStatus.$store.get(),r=this.background.moderation.getStore().value?.data?.options?.onboardingEnabled,i=this.settings.getValues().inplayGame?.titleCard?.optIn,s=e===ee.Completed,u=!r||s||i!==!0;this.background.interactiveAllowed.set(u?Ve.ALLOWED:Ve.DISALLOWED)};connect=e=>{this.userSummary.invalidate(),this.leaderboardList.invalidate(),this.feedList.invalidate(),this.friends.invalidate(),this.background.feedSubscription.addListener("feed-subscription-prediction-close",r=>{this.isInteractiveAllowed&&window.requestAnimationFrame(async()=>{const i=r.data?.attributes?.question;if(!i)return;const{status:s,type:u,id:c}=i;if(s===re.QuestionStatus.RESOLVED&&u===re.QuestionType.PREDICTION){const h=this.background.getCurrentSessionId({prefix:`notification-id:${c}`}),p=await hn(c,e),m=p?.answers.find(({correct:w})=>w),f=p?.answers.find(({youVoted:w})=>w);if(!f)return;this.notifications.add({type:Me.QUESTION_RESOLVED,action:()=>this.openQuestion(c),close:()=>this.closeQuestion(c),autoHideDuration:m?.youVoted?15e3:12e3,id:h,data:{questionType:re.QuestionType.PREDICTION,question:{title:m?.youVoted?`Congratulations! You answered correctly! You won ${m.points} pts!`:`Better luck next time! Correct: ${m?.text}!`,votedAnswer:{title:f?.text,points:f?.points},correctAnswerTitle:m?.text,correct:m?.youVoted,predictionResult:s===re.QuestionStatus.RESOLVED,questionTitle:p?.subject}}}),this.userSummary.invalidate()}})}),this.background.feedSubscription.addListener("feed-subscription-questions-list",()=>{window.requestAnimationFrame(()=>{this.feedList?.invalidate()})})};disconnect=()=>{this.background.feedSubscription.removeListener("feed-subscription-questions-list")};submitAnswer=async(e,r)=>{await ao(this.transport,{questionId:e,answerId:r}),this.feedList.invalidate(),this.userSummary.invalidate()};skipQuestion=async e=>{await co(this.transport,e),this.feedList.invalidate(),this.userSummary.invalidate()};openQuestion=e=>(this.openFeature(),this.notifications.close(this.background.getCurrentSessionId({prefix:"notification",entity:e})),this.background.openQuestion(e));closeQuestion=e=>this.background.closeQuestion(e);openUser=e=>{const r=this.leaderboardList.$store.get().data?.find(i=>i.userId===e);this.openedUser.set(r)};closeUser=()=>{this.openedUser.set(void 0)};showInApp=e=>{const r=this.onboardingStatus.$store.get();if(e&&e.data&&r&&r!==ee.Unset&&e.data.question?.id!==void 0&&e.data.question.notification!==void 0&&e.data.question?.bypassNotifications?.inAppSilence!==re.SilenceSetting.ON&&e.data.question.status===re.QuestionStatus.ACTIVE){if(mo.has(e.data.question.type))this.isInteractiveAllowed&&this.notifications.add({type:Me.QUESTION,action:()=>e.data?.question&&this.openQuestion(e.data.question.id),close:()=>e.data?.question&&this.closeQuestion(e.data.question.id),autoHideDuration:1e3*60,id:this.background.getCurrentSessionId({prefix:"notification",entity:e.data.question.id}),data:{questionType:e.data.question.type,question:{title:e.data.question.notification.title}}});else if(e.data.question.type===re.QuestionType.FACTOID){const i=e.data.question.options?.options.value,s={heading:e.data.question.notification.title,body:e.data.question.notification.body,imageMode:e.data.question.notification.imageMode,image:i?.image,video:{id:i?.video?.id||"",url:i?.video?.url||"",thumbnailUrl:i?.video?.thumbnailUrl||""},webLink:{label:"",url:""}};this.notifications.add({type:Me.QUESTION,action:()=>e.data?.question&&this.openQuestion(e.data.question.id),close:()=>e.data?.question&&this.closeQuestion(e.data.question.id),autoHideDuration:1e3*120,id:this.background.getCurrentSessionId({prefix:"notification",entity:e.data.question.id}),data:{questionType:e.data.question.type,insight:s}})}else if(e.data.question.type===re.QuestionType.TWEET){const i=e.data.question.options?.options.value,s={title:e.data.question.notification?.title,body:e.data.question.notification?.body,image:e.data.question.notification?.image,account:i?.tweetMeta?.account||"",accountVerified:!!i?.tweetMeta?.accountVerified,tweet:i?.tweetMeta?.tweet};this.notifications.add({type:Me.QUESTION,action:()=>e.data?.question&&this.openQuestion(e.data.question.id),close:()=>e.data?.question&&this.closeQuestion(e.data.question.id),autoHideDuration:1e3*120,id:this.background.getCurrentSessionId({prefix:"notification",entity:e.data.question.id}),data:{questionType:e.data.question.type,tweet:s}})}}}}const bo={[Te.SdkOverlayType.GAMES]:!0};class vo extends cn{constructor(e,r){super(e,r)}}const So=(t,e,r)=>t.type===Te.SdkOverlayType.GAMES?new wo(t,e,r):new vo(t,e),Ao=(t,e,r)=>{t.features=new Map,t.activeFeature=new ae(ne(Te.SdkOverlayType.UNSET),"activeFeature"),t.sdk.getFeatures=()=>t.features,t.sdk.getFeature=i=>t.features.get(i),t.sdk.getActiveFeature=()=>t.activeFeature.getStore(),t.sdk.openFeature=i=>{t.activeFeature.setValue(i)},t.sdk.closeFeature=(i=!1)=>{const s=t.activeFeature.getValue();t.activeFeature.setValue(Te.SdkOverlayType.UNSET),i&&s&&t.features.delete(s)},t.initFeature=(i,s=Ee.ORGANIZATION)=>{if(i.type in bo&&!t.features.has(i.type)){const u=So(i,s,t);t.features.set(i.type,u)}},t.updateFeature=(i,s)=>{t.features.get(i.type)?.update(i,s)},t.destroyFeature=i=>{t.features.delete(i.type)},t.reinitializeFeatures=async()=>{const i=await t.stores.organizationSettings.getValue();t.features.clear();for(const s of i?.overlays||[])t.initFeature(s,Ee.ORGANIZATION)},t.stores.providerStreamId.listen(i=>{i||t.reinitializeFeatures()}),t.storeSubscribe=()=>{const i=(u,c)=>{if(c?.overlays&&!(t.contextConfig?.skipOrganizationSettings&&u===Ee.ORGANIZATION))for(const h of c.overlays)h.sdkEnable===!0&&(t.features.has(h.type)?t.updateFeature(h,u):t.initFeature(h,u))},s={organizationSettings:u=>{if(u.data)try{i(Ee.ORGANIZATION,u.data)}catch(c){console.log(c)}},streamSettings:u=>{if(u.data)try{i(Ee.STREAM,u.data)}catch(c){console.log(c)}}};t.store.subscribe(s)},r()};var mr={exports:{}},wr={exports:{}};function Eo(t){var e=new t,r=e;function i(){var u=e;return u.next?e=u.next:(e=new t,r=e),u.next=null,u}function s(u){r.next=u,r=u}return{get:i,release:s}}var Io=Eo,To=Io;function wn(t,e,r){if(typeof t=="function"&&(r=e,e=t,t=null),r<1)throw new Error("fastqueue concurrency must be greater than 1");var i=To(_o),s=null,u=null,c=0,h=null,p={push:x,drain:se,saturated:se,pause:f,paused:!1,concurrency:r,running:m,resume:T,idle:F,length:w,getQueue:E,unshift:N,empty:se,kill:O,killAndDrain:j,error:P};return p;function m(){return c}function f(){p.paused=!0}function w(){for(var C=s,k=0;C;)C=C.next,k++;return k}function E(){for(var C=s,k=[];C;)k.push(C.value),C=C.next;return k}function T(){if(p.paused){p.paused=!1;for(var C=0;C<p.concurrency;C++)c++,I()}}function F(){return c===0&&p.length()===0}function x(C,k){var B=i.get();B.context=t,B.release=I,B.value=C,B.callback=k||se,B.errorHandler=h,c===p.concurrency||p.paused?u?(u.next=B,u=B):(s=B,u=B,p.saturated()):(c++,e.call(t,B.value,B.worked))}function N(C,k){var B=i.get();B.context=t,B.release=I,B.value=C,B.callback=k||se,B.errorHandler=h,c===p.concurrency||p.paused?s?(B.next=s,s=B):(s=B,u=B,p.saturated()):(c++,e.call(t,B.value,B.worked))}function I(C){C&&i.release(C);var k=s;k?p.paused?c--:(u===s&&(u=null),s=k.next,k.next=null,e.call(t,k.value,k.worked),u===null&&p.empty()):--c===0&&p.drain()}function O(){s=null,u=null,p.drain=se}function j(){s=null,u=null,p.drain(),p.drain=se}function P(C){h=C}}function se(){}function _o(){this.value=null,this.callback=se,this.next=null,this.release=se,this.context=null,this.errorHandler=null;var t=this;this.worked=function(r,i){var s=t.callback,u=t.errorHandler,c=t.value;t.value=null,t.callback=se,t.errorHandler&&u(r,c),s.call(t.context,r,i),t.release(t)}}function Oo(t,e,r){typeof t=="function"&&(r=e,e=t,t=null);function i(f,w){e.call(this,f).then(function(E){w(null,E)},w)}var s=wn(t,i,r),u=s.push,c=s.unshift;return s.push=h,s.unshift=p,s.drained=m,s;function h(f){var w=new Promise(function(E,T){u(f,function(F,x){if(F){T(F);return}E(x)})});return w.catch(se),w}function p(f){var w=new Promise(function(E,T){c(f,function(F,x){if(F){T(F);return}E(x)})});return w.catch(se),w}function m(){if(s.idle())return new Promise(function(E){E()});var f=s.drain,w=new Promise(function(E){s.drain=function(){f(),E()}});return w}}wr.exports=wn;wr.exports.promise=Oo;var bn=wr.exports,br={exports:{}},it=typeof Reflect=="object"?Reflect:null,Dr=it&&typeof it.apply=="function"?it.apply:function(e,r,i){return Function.prototype.apply.call(e,r,i)},vt;it&&typeof it.ownKeys=="function"?vt=it.ownKeys:Object.getOwnPropertySymbols?vt=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:vt=function(e){return Object.getOwnPropertyNames(e)};function Fo(t){console&&console.warn&&console.warn(t)}var vn=Number.isNaN||function(e){return e!==e};function G(){G.init.call(this)}br.exports=G;br.exports.once=Bo;G.EventEmitter=G;G.prototype._events=void 0;G.prototype._eventsCount=0;G.prototype._maxListeners=void 0;var $r=10;function Pt(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(G,"defaultMaxListeners",{enumerable:!0,get:function(){return $r},set:function(t){if(typeof t!="number"||t<0||vn(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");$r=t}});G.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};G.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||vn(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function Sn(t){return t._maxListeners===void 0?G.defaultMaxListeners:t._maxListeners}G.prototype.getMaxListeners=function(){return Sn(this)};G.prototype.emit=function(e){for(var r=[],i=1;i<arguments.length;i++)r.push(arguments[i]);var s=e==="error",u=this._events;if(u!==void 0)s=s&&u.error===void 0;else if(!s)return!1;if(s){var c;if(r.length>0&&(c=r[0]),c instanceof Error)throw c;var h=new Error("Unhandled error."+(c?" ("+c.message+")":""));throw h.context=c,h}var p=u[e];if(p===void 0)return!1;if(typeof p=="function")Dr(p,this,r);else for(var m=p.length,f=_n(p,m),i=0;i<m;++i)Dr(f[i],this,r);return!0};function An(t,e,r,i){var s,u,c;if(Pt(r),u=t._events,u===void 0?(u=t._events=Object.create(null),t._eventsCount=0):(u.newListener!==void 0&&(t.emit("newListener",e,r.listener?r.listener:r),u=t._events),c=u[e]),c===void 0)c=u[e]=r,++t._eventsCount;else if(typeof c=="function"?c=u[e]=i?[r,c]:[c,r]:i?c.unshift(r):c.push(r),s=Sn(t),s>0&&c.length>s&&!c.warned){c.warned=!0;var h=new Error("Possible EventEmitter memory leak detected. "+c.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");h.name="MaxListenersExceededWarning",h.emitter=t,h.type=e,h.count=c.length,Fo(h)}return t}G.prototype.addListener=function(e,r){return An(this,e,r,!1)};G.prototype.on=G.prototype.addListener;G.prototype.prependListener=function(e,r){return An(this,e,r,!0)};function Co(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function En(t,e,r){var i={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},s=Co.bind(i);return s.listener=r,i.wrapFn=s,s}G.prototype.once=function(e,r){return Pt(r),this.on(e,En(this,e,r)),this};G.prototype.prependOnceListener=function(e,r){return Pt(r),this.prependListener(e,En(this,e,r)),this};G.prototype.removeListener=function(e,r){var i,s,u,c,h;if(Pt(r),s=this._events,s===void 0)return this;if(i=s[e],i===void 0)return this;if(i===r||i.listener===r)--this._eventsCount===0?this._events=Object.create(null):(delete s[e],s.removeListener&&this.emit("removeListener",e,i.listener||r));else if(typeof i!="function"){for(u=-1,c=i.length-1;c>=0;c--)if(i[c]===r||i[c].listener===r){h=i[c].listener,u=c;break}if(u<0)return this;u===0?i.shift():xo(i,u),i.length===1&&(s[e]=i[0]),s.removeListener!==void 0&&this.emit("removeListener",e,h||r)}return this};G.prototype.off=G.prototype.removeListener;G.prototype.removeAllListeners=function(e){var r,i,s;if(i=this._events,i===void 0)return this;if(i.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):i[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete i[e]),this;if(arguments.length===0){var u=Object.keys(i),c;for(s=0;s<u.length;++s)c=u[s],c!=="removeListener"&&this.removeAllListeners(c);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(r=i[e],typeof r=="function")this.removeListener(e,r);else if(r!==void 0)for(s=r.length-1;s>=0;s--)this.removeListener(e,r[s]);return this};function In(t,e,r){var i=t._events;if(i===void 0)return[];var s=i[e];return s===void 0?[]:typeof s=="function"?r?[s.listener||s]:[s]:r?ko(s):_n(s,s.length)}G.prototype.listeners=function(e){return In(this,e,!0)};G.prototype.rawListeners=function(e){return In(this,e,!1)};G.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):Tn.call(t,e)};G.prototype.listenerCount=Tn;function Tn(t){var e=this._events;if(e!==void 0){var r=e[t];if(typeof r=="function")return 1;if(r!==void 0)return r.length}return 0}G.prototype.eventNames=function(){return this._eventsCount>0?vt(this._events):[]};function _n(t,e){for(var r=new Array(e),i=0;i<e;++i)r[i]=t[i];return r}function xo(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function ko(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}function Bo(t,e){return new Promise(function(r,i){function s(c){t.removeListener(e,u),i(c)}function u(){typeof t.removeListener=="function"&&t.removeListener("error",s),r([].slice.call(arguments))}On(t,e,u,{once:!0}),e!=="error"&&Lo(t,s,{once:!0})})}function Lo(t,e,r){typeof t.on=="function"&&On(t,"error",e,r)}function On(t,e,r,i){if(typeof t.on=="function")i.once?t.once(e,r):t.on(e,r);else if(typeof t.addEventListener=="function")t.addEventListener(e,function s(u){i.once&&t.removeEventListener(e,s),r(u)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t)}var Fn=br.exports,Rt={},Cn={},xn=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var e={},r=Symbol("test"),i=Object(r);if(typeof r=="string"||Object.prototype.toString.call(r)!=="[object Symbol]"||Object.prototype.toString.call(i)!=="[object Symbol]")return!1;var s=42;e[r]=s;for(r in e)return!1;if(typeof Object.keys=="function"&&Object.keys(e).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(e).length!==0)return!1;var u=Object.getOwnPropertySymbols(e);if(u.length!==1||u[0]!==r||!Object.prototype.propertyIsEnumerable.call(e,r))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var c=Object.getOwnPropertyDescriptor(e,r);if(c.value!==s||c.enumerable!==!0)return!1}return!0},Po=xn,vr=function(){return Po()&&!!Symbol.toStringTag},Ur=typeof Symbol<"u"&&Symbol,Ro=xn,No=function(){return typeof Ur!="function"||typeof Symbol!="function"||typeof Ur("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:Ro()},jr={foo:{}},Do=Object,$o=function(){return{__proto__:jr}.foo===jr.foo&&!({__proto__:null}instanceof Do)},Uo="Function.prototype.bind called on incompatible ",jo=Object.prototype.toString,Mo=Math.max,Vo="[object Function]",Mr=function(e,r){for(var i=[],s=0;s<e.length;s+=1)i[s]=e[s];for(var u=0;u<r.length;u+=1)i[u+e.length]=r[u];return i},qo=function(e,r){for(var i=[],s=r||0,u=0;s<e.length;s+=1,u+=1)i[u]=e[s];return i},Qo=function(t,e){for(var r="",i=0;i<t.length;i+=1)r+=t[i],i+1<t.length&&(r+=e);return r},Go=function(e){var r=this;if(typeof r!="function"||jo.apply(r)!==Vo)throw new TypeError(Uo+r);for(var i=qo(arguments,1),s,u=function(){if(this instanceof s){var f=r.apply(this,Mr(i,arguments));return Object(f)===f?f:this}return r.apply(e,Mr(i,arguments))},c=Mo(0,r.length-i.length),h=[],p=0;p<c;p++)h[p]="$"+p;if(s=Function("binder","return function ("+Qo(h,",")+"){ return binder.apply(this,arguments); }")(u),r.prototype){var m=function(){};m.prototype=r.prototype,s.prototype=new m,m.prototype=null}return s},zo=Go,Sr=Function.prototype.bind||zo,Ko=Function.prototype.call,Wo=Object.prototype.hasOwnProperty,Ho=Sr,Jo=Ho.call(Ko,Wo),U,st=SyntaxError,kn=Function,ot=TypeError,jt=function(t){try{return kn('"use strict"; return ('+t+").constructor;")()}catch{}},qe=Object.getOwnPropertyDescriptor;if(qe)try{qe({},"")}catch{qe=null}var Mt=function(){throw new ot},Yo=qe?function(){try{return arguments.callee,Mt}catch{try{return qe(arguments,"callee").get}catch{return Mt}}}():Mt,We=No(),Xo=$o(),X=Object.getPrototypeOf||(Xo?function(t){return t.__proto__}:null),Je={},Zo=typeof Uint8Array>"u"||!X?U:X(Uint8Array),Qe={"%AggregateError%":typeof AggregateError>"u"?U:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?U:ArrayBuffer,"%ArrayIteratorPrototype%":We&&X?X([][Symbol.iterator]()):U,"%AsyncFromSyncIteratorPrototype%":U,"%AsyncFunction%":Je,"%AsyncGenerator%":Je,"%AsyncGeneratorFunction%":Je,"%AsyncIteratorPrototype%":Je,"%Atomics%":typeof Atomics>"u"?U:Atomics,"%BigInt%":typeof BigInt>"u"?U:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?U:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?U:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?U:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Error,"%eval%":eval,"%EvalError%":EvalError,"%Float32Array%":typeof Float32Array>"u"?U:Float32Array,"%Float64Array%":typeof Float64Array>"u"?U:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?U:FinalizationRegistry,"%Function%":kn,"%GeneratorFunction%":Je,"%Int8Array%":typeof Int8Array>"u"?U:Int8Array,"%Int16Array%":typeof Int16Array>"u"?U:Int16Array,"%Int32Array%":typeof Int32Array>"u"?U:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":We&&X?X(X([][Symbol.iterator]())):U,"%JSON%":typeof JSON=="object"?JSON:U,"%Map%":typeof Map>"u"?U:Map,"%MapIteratorPrototype%":typeof Map>"u"||!We||!X?U:X(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?U:Promise,"%Proxy%":typeof Proxy>"u"?U:Proxy,"%RangeError%":RangeError,"%ReferenceError%":ReferenceError,"%Reflect%":typeof Reflect>"u"?U:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?U:Set,"%SetIteratorPrototype%":typeof Set>"u"||!We||!X?U:X(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?U:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":We&&X?X(""[Symbol.iterator]()):U,"%Symbol%":We?Symbol:U,"%SyntaxError%":st,"%ThrowTypeError%":Yo,"%TypedArray%":Zo,"%TypeError%":ot,"%Uint8Array%":typeof Uint8Array>"u"?U:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?U:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?U:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?U:Uint32Array,"%URIError%":URIError,"%WeakMap%":typeof WeakMap>"u"?U:WeakMap,"%WeakRef%":typeof WeakRef>"u"?U:WeakRef,"%WeakSet%":typeof WeakSet>"u"?U:WeakSet};if(X)try{null.error}catch(t){var es=X(X(t));Qe["%Error.prototype%"]=es}var ts=function t(e){var r;if(e==="%AsyncFunction%")r=jt("async function () {}");else if(e==="%GeneratorFunction%")r=jt("function* () {}");else if(e==="%AsyncGeneratorFunction%")r=jt("async function* () {}");else if(e==="%AsyncGenerator%"){var i=t("%AsyncGeneratorFunction%");i&&(r=i.prototype)}else if(e==="%AsyncIteratorPrototype%"){var s=t("%AsyncGenerator%");s&&X&&(r=X(s.prototype))}return Qe[e]=r,r},Vr={"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},gt=Sr,_t=Jo,rs=gt.call(Function.call,Array.prototype.concat),ns=gt.call(Function.apply,Array.prototype.splice),qr=gt.call(Function.call,String.prototype.replace),Ot=gt.call(Function.call,String.prototype.slice),is=gt.call(Function.call,RegExp.prototype.exec),os=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,ss=/\\(\\)?/g,as=function(e){var r=Ot(e,0,1),i=Ot(e,-1);if(r==="%"&&i!=="%")throw new st("invalid intrinsic syntax, expected closing `%`");if(i==="%"&&r!=="%")throw new st("invalid intrinsic syntax, expected opening `%`");var s=[];return qr(e,os,function(u,c,h,p){s[s.length]=h?qr(p,ss,"$1"):c||u}),s},us=function(e,r){var i=e,s;if(_t(Vr,i)&&(s=Vr[i],i="%"+s[0]+"%"),_t(Qe,i)){var u=Qe[i];if(u===Je&&(u=ts(i)),typeof u>"u"&&!r)throw new ot("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:s,name:i,value:u}}throw new st("intrinsic "+e+" does not exist!")},ut=function(e,r){if(typeof e!="string"||e.length===0)throw new ot("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof r!="boolean")throw new ot('"allowMissing" argument must be a boolean');if(is(/^%?[^%]*%?$/,e)===null)throw new st("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var i=as(e),s=i.length>0?i[0]:"",u=us("%"+s+"%",r),c=u.name,h=u.value,p=!1,m=u.alias;m&&(s=m[0],ns(i,rs([0,1],m)));for(var f=1,w=!0;f<i.length;f+=1){var E=i[f],T=Ot(E,0,1),F=Ot(E,-1);if((T==='"'||T==="'"||T==="`"||F==='"'||F==="'"||F==="`")&&T!==F)throw new st("property names with quotes must have matching quotes");if((E==="constructor"||!w)&&(p=!0),s+="."+E,c="%"+s+"%",_t(Qe,c))h=Qe[c];else if(h!=null){if(!(E in h)){if(!r)throw new ot("base intrinsic for "+e+" exists, but the property is not available.");return}if(qe&&f+1>=i.length){var x=qe(h,E);w=!!x,w&&"get"in x&&!("originalValue"in x.get)?h=x.get:h=h[E]}else w=_t(h,E),h=h[E];w&&!p&&(Qe[c]=h)}}return h},Bn={exports:{}},cs=ut,rr=cs("%Object.defineProperty%",!0),nr=function(){if(rr)try{return rr({},"a",{value:1}),!0}catch{return!1}return!1};nr.hasArrayLengthDefineBug=function(){if(!nr())return null;try{return rr([],"length",{value:1}).length!==1}catch{return!0}};var Ln=nr,ls=ut,St=ls("%Object.getOwnPropertyDescriptor%",!0);if(St)try{St([],"length")}catch{St=null}var Ar=St,fs=Ln(),Er=ut,ht=fs&&Er("%Object.defineProperty%",!0);if(ht)try{ht({},"a",{value:1})}catch{ht=!1}var ds=Er("%SyntaxError%"),He=Er("%TypeError%"),Qr=Ar,hs=function(e,r,i){if(!e||typeof e!="object"&&typeof e!="function")throw new He("`obj` must be an object or a function`");if(typeof r!="string"&&typeof r!="symbol")throw new He("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new He("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new He("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new He("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new He("`loose`, if provided, must be a boolean");var s=arguments.length>3?arguments[3]:null,u=arguments.length>4?arguments[4]:null,c=arguments.length>5?arguments[5]:null,h=arguments.length>6?arguments[6]:!1,p=!!Qr&&Qr(e,r);if(ht)ht(e,r,{configurable:c===null&&p?p.configurable:!c,enumerable:s===null&&p?p.enumerable:!s,value:i,writable:u===null&&p?p.writable:!u});else if(h||!s&&!u&&!c)e[r]=i;else throw new ds("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},Pn=ut,Gr=hs,ps=Ln(),zr=Ar,Kr=Pn("%TypeError%"),ys=Pn("%Math.floor%"),gs=function(e,r){if(typeof e!="function")throw new Kr("`fn` is not a function");if(typeof r!="number"||r<0||r>4294967295||ys(r)!==r)throw new Kr("`length` must be a positive 32-bit integer");var i=arguments.length>2&&!!arguments[2],s=!0,u=!0;if("length"in e&&zr){var c=zr(e,"length");c&&!c.configurable&&(s=!1),c&&!c.writable&&(u=!1)}return(s||u||!i)&&(ps?Gr(e,"length",r,!0,!0):Gr(e,"length",r)),e};(function(t){var e=Sr,r=ut,i=gs,s=r("%TypeError%"),u=r("%Function.prototype.apply%"),c=r("%Function.prototype.call%"),h=r("%Reflect.apply%",!0)||e.call(c,u),p=r("%Object.defineProperty%",!0),m=r("%Math.max%");if(p)try{p({},"a",{value:1})}catch{p=null}t.exports=function(E){if(typeof E!="function")throw new s("a function is required");var T=h(e,c,arguments);return i(T,1+m(0,E.length-(arguments.length-1)),!0)};var f=function(){return h(e,u,arguments)};p?p(t.exports,"apply",{value:f}):t.exports.apply=f})(Bn);var Rn=Bn.exports,Nn=ut,Dn=Rn,ms=Dn(Nn("String.prototype.indexOf")),$n=function(e,r){var i=Nn(e,!!r);return typeof i=="function"&&ms(e,".prototype.")>-1?Dn(i):i},ws=vr(),bs=$n,ir=bs("Object.prototype.toString"),Nt=function(e){return ws&&e&&typeof e=="object"&&Symbol.toStringTag in e?!1:ir(e)==="[object Arguments]"},Un=function(e){return Nt(e)?!0:e!==null&&typeof e=="object"&&typeof e.length=="number"&&e.length>=0&&ir(e)!=="[object Array]"&&ir(e.callee)==="[object Function]"},vs=function(){return Nt(arguments)}();Nt.isLegacyArguments=Un;var Ss=vs?Nt:Un,As=Object.prototype.toString,Es=Function.prototype.toString,Is=/^\s*(?:function)?\*/,jn=vr(),Vt=Object.getPrototypeOf,Ts=function(){if(!jn)return!1;try{return Function("return function*() {}")()}catch{}},qt,_s=function(e){if(typeof e!="function")return!1;if(Is.test(Es.call(e)))return!0;if(!jn){var r=As.call(e);return r==="[object GeneratorFunction]"}if(!Vt)return!1;if(typeof qt>"u"){var i=Ts();qt=i?Vt(i):!1}return Vt(e)===qt},Mn=Function.prototype.toString,et=typeof Reflect=="object"&&Reflect!==null&&Reflect.apply,or,At;if(typeof et=="function"&&typeof Object.defineProperty=="function")try{or=Object.defineProperty({},"length",{get:function(){throw At}}),At={},et(function(){throw 42},null,or)}catch(t){t!==At&&(et=null)}else et=null;var Os=/^\s*class\b/,sr=function(e){try{var r=Mn.call(e);return Os.test(r)}catch{return!1}},Qt=function(e){try{return sr(e)?!1:(Mn.call(e),!0)}catch{return!1}},Et=Object.prototype.toString,Fs="[object Object]",Cs="[object Function]",xs="[object GeneratorFunction]",ks="[object HTMLAllCollection]",Bs="[object HTML document.all class]",Ls="[object HTMLCollection]",Ps=typeof Symbol=="function"&&!!Symbol.toStringTag,Rs=!(0 in[,]),ar=function(){return!1};if(typeof document=="object"){var Ns=document.all;Et.call(Ns)===Et.call(document.all)&&(ar=function(e){if((Rs||!e)&&(typeof e>"u"||typeof e=="object"))try{var r=Et.call(e);return(r===ks||r===Bs||r===Ls||r===Fs)&&e("")==null}catch{}return!1})}var Ds=et?function(e){if(ar(e))return!0;if(!e||typeof e!="function"&&typeof e!="object")return!1;try{et(e,null,or)}catch(r){if(r!==At)return!1}return!sr(e)&&Qt(e)}:function(e){if(ar(e))return!0;if(!e||typeof e!="function"&&typeof e!="object")return!1;if(Ps)return Qt(e);if(sr(e))return!1;var r=Et.call(e);return r!==Cs&&r!==xs&&!/^\[object HTML/.test(r)?!1:Qt(e)},$s=Ds,Us=Object.prototype.toString,Vn=Object.prototype.hasOwnProperty,js=function(e,r,i){for(var s=0,u=e.length;s<u;s++)Vn.call(e,s)&&(i==null?r(e[s],s,e):r.call(i,e[s],s,e))},Ms=function(e,r,i){for(var s=0,u=e.length;s<u;s++)i==null?r(e.charAt(s),s,e):r.call(i,e.charAt(s),s,e)},Vs=function(e,r,i){for(var s in e)Vn.call(e,s)&&(i==null?r(e[s],s,e):r.call(i,e[s],s,e))},qs=function(e,r,i){if(!$s(r))throw new TypeError("iterator must be a function");var s;arguments.length>=3&&(s=i),Us.call(e)==="[object Array]"?js(e,r,s):typeof e=="string"?Ms(e,r,s):Vs(e,r,s)},Qs=qs,Gt=["BigInt64Array","BigUint64Array","Float32Array","Float64Array","Int16Array","Int32Array","Int8Array","Uint16Array","Uint32Array","Uint8Array","Uint8ClampedArray"],Gs=typeof globalThis>"u"?gn:globalThis,zs=function(){for(var e=[],r=0;r<Gt.length;r++)typeof Gs[Gt[r]]=="function"&&(e[e.length]=Gt[r]);return e},Ft=Qs,Ks=zs,Wr=Rn,Ir=$n,It=Ar,Ws=Ir("Object.prototype.toString"),qn=vr(),Hr=typeof globalThis>"u"?gn:globalThis,ur=Ks(),Tr=Ir("String.prototype.slice"),zt=Object.getPrototypeOf,Hs=Ir("Array.prototype.indexOf",!0)||function(e,r){for(var i=0;i<e.length;i+=1)if(e[i]===r)return i;return-1},Ct={__proto__:null};qn&&It&&zt?Ft(ur,function(t){var e=new Hr[t];if(Symbol.toStringTag in e){var r=zt(e),i=It(r,Symbol.toStringTag);if(!i){var s=zt(r);i=It(s,Symbol.toStringTag)}Ct["$"+t]=Wr(i.get)}}):Ft(ur,function(t){var e=new Hr[t],r=e.slice||e.set;r&&(Ct["$"+t]=Wr(r))});var Js=function(e){var r=!1;return Ft(Ct,function(i,s){if(!r)try{"$"+i(e)===s&&(r=Tr(s,1))}catch{}}),r},Ys=function(e){var r=!1;return Ft(Ct,function(i,s){if(!r)try{i(e),r=Tr(s,1)}catch{}}),r},Qn=function(e){if(!e||typeof e!="object")return!1;if(!qn){var r=Tr(Ws(e),8,-1);return Hs(ur,r)>-1?r:r!=="Object"?!1:Ys(e)}return It?Js(e):null},Xs=Qn,Zs=function(e){return!!Xs(e)};(function(t){var e=Ss,r=_s,i=Qn,s=Zs;function u(A){return A.call.bind(A)}var c=typeof BigInt<"u",h=typeof Symbol<"u",p=u(Object.prototype.toString),m=u(Number.prototype.valueOf),f=u(String.prototype.valueOf),w=u(Boolean.prototype.valueOf);if(c)var E=u(BigInt.prototype.valueOf);if(h)var T=u(Symbol.prototype.valueOf);function F(A,ft){if(typeof A!="object")return!1;try{return ft(A),!0}catch{return!1}}t.isArgumentsObject=e,t.isGeneratorFunction=r,t.isTypedArray=s;function x(A){return typeof Promise<"u"&&A instanceof Promise||A!==null&&typeof A=="object"&&typeof A.then=="function"&&typeof A.catch=="function"}t.isPromise=x;function N(A){return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?ArrayBuffer.isView(A):s(A)||v(A)}t.isArrayBufferView=N;function I(A){return i(A)==="Uint8Array"}t.isUint8Array=I;function O(A){return i(A)==="Uint8ClampedArray"}t.isUint8ClampedArray=O;function j(A){return i(A)==="Uint16Array"}t.isUint16Array=j;function P(A){return i(A)==="Uint32Array"}t.isUint32Array=P;function C(A){return i(A)==="Int8Array"}t.isInt8Array=C;function k(A){return i(A)==="Int16Array"}t.isInt16Array=k;function B(A){return i(A)==="Int32Array"}t.isInt32Array=B;function q(A){return i(A)==="Float32Array"}t.isFloat32Array=q;function ie(A){return i(A)==="Float64Array"}t.isFloat64Array=ie;function we(A){return i(A)==="BigInt64Array"}t.isBigInt64Array=we;function be(A){return i(A)==="BigUint64Array"}t.isBigUint64Array=be;function ue(A){return p(A)==="[object Map]"}ue.working=typeof Map<"u"&&ue(new Map);function lt(A){return typeof Map>"u"?!1:ue.working?ue(A):A instanceof Map}t.isMap=lt;function he(A){return p(A)==="[object Set]"}he.working=typeof Set<"u"&&he(new Set);function Re(A){return typeof Set>"u"?!1:he.working?he(A):A instanceof Set}t.isSet=Re;function ke(A){return p(A)==="[object WeakMap]"}ke.working=typeof WeakMap<"u"&&ke(new WeakMap);function Ge(A){return typeof WeakMap>"u"?!1:ke.working?ke(A):A instanceof WeakMap}t.isWeakMap=Ge;function ve(A){return p(A)==="[object WeakSet]"}ve.working=typeof WeakSet<"u"&&ve(new WeakSet);function ce(A){return ve(A)}t.isWeakSet=ce;function Be(A){return p(A)==="[object ArrayBuffer]"}Be.working=typeof ArrayBuffer<"u"&&Be(new ArrayBuffer);function ze(A){return typeof ArrayBuffer>"u"?!1:Be.working?Be(A):A instanceof ArrayBuffer}t.isArrayBuffer=ze;function g(A){return p(A)==="[object DataView]"}g.working=typeof ArrayBuffer<"u"&&typeof DataView<"u"&&g(new DataView(new ArrayBuffer(1),0,1));function v(A){return typeof DataView>"u"?!1:g.working?g(A):A instanceof DataView}t.isDataView=v;var S=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:void 0;function _(A){return p(A)==="[object SharedArrayBuffer]"}function M(A){return typeof S>"u"?!1:(typeof _.working>"u"&&(_.working=_(new S)),_.working?_(A):A instanceof S)}t.isSharedArrayBuffer=M;function V(A){return p(A)==="[object AsyncFunction]"}t.isAsyncFunction=V;function R(A){return p(A)==="[object Map Iterator]"}t.isMapIterator=R;function $(A){return p(A)==="[object Set Iterator]"}t.isSetIterator=$;function Q(A){return p(A)==="[object Generator]"}t.isGeneratorObject=Q;function J(A){return p(A)==="[object WebAssembly.Module]"}t.isWebAssemblyCompiledModule=J;function le(A){return F(A,m)}t.isNumberObject=le;function Ne(A){return F(A,f)}t.isStringObject=Ne;function Le(A){return F(A,w)}t.isBooleanObject=Le;function De(A){return c&&F(A,E)}t.isBigIntObject=De;function Se(A){return h&&F(A,T)}t.isSymbolObject=Se;function $e(A){return le(A)||Ne(A)||Le(A)||De(A)||Se(A)}t.isBoxedPrimitive=$e;function Dt(A){return typeof Uint8Array<"u"&&(ze(A)||M(A))}t.isAnyArrayBuffer=Dt,["isProxy","isExternal","isModuleNamespaceObject"].forEach(function(A){Object.defineProperty(t,A,{enumerable:!1,value:function(){throw new Error(A+" is not supported in userland")}})})})(Cn);var ea=function(e){return e&&typeof e=="object"&&typeof e.copy=="function"&&typeof e.fill=="function"&&typeof e.readUInt8=="function"},cr={exports:{}};typeof Object.create=="function"?cr.exports=function(e,r){r&&(e.super_=r,e.prototype=Object.create(r.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:cr.exports=function(e,r){if(r){e.super_=r;var i=function(){};i.prototype=r.prototype,e.prototype=new i,e.prototype.constructor=e}};var ta=cr.exports;(function(t){var e=Object.getOwnPropertyDescriptors||function(v){for(var S=Object.keys(v),_={},M=0;M<S.length;M++)_[S[M]]=Object.getOwnPropertyDescriptor(v,S[M]);return _},r=/%[sdj%]/g;t.format=function(g){if(!C(g)){for(var v=[],S=0;S<arguments.length;S++)v.push(c(arguments[S]));return v.join(" ")}for(var S=1,_=arguments,M=_.length,V=String(g).replace(r,function($){if($==="%%")return"%";if(S>=M)return $;switch($){case"%s":return String(_[S++]);case"%d":return Number(_[S++]);case"%j":try{return JSON.stringify(_[S++])}catch{return"[Circular]"}default:return $}}),R=_[S];S<M;R=_[++S])O(R)||!ie(R)?V+=" "+R:V+=" "+c(R);return V},t.deprecate=function(g,v){if(typeof L<"u"&&L.noDeprecation===!0)return g;if(typeof L>"u")return function(){return t.deprecate(g,v).apply(this,arguments)};var S=!1;function _(){if(!S){if(L.throwDeprecation)throw new Error(v);L.traceDeprecation?console.trace(v):console.error(v),S=!0}return g.apply(this,arguments)}return _};var i={},s=/^$/;if(L.env.NODE_DEBUG){var u=L.env.NODE_DEBUG;u=u.replace(/[|\\{}()[\]^$+?.]/g,"\\$&").replace(/\*/g,".*").replace(/,/g,"$|^").toUpperCase(),s=new RegExp("^"+u+"$","i")}t.debuglog=function(g){if(g=g.toUpperCase(),!i[g])if(s.test(g)){var v=L.pid;i[g]=function(){var S=t.format.apply(t,arguments);console.error("%s %d: %s",g,v,S)}}else i[g]=function(){};return i[g]};function c(g,v){var S={seen:[],stylize:p};return arguments.length>=3&&(S.depth=arguments[2]),arguments.length>=4&&(S.colors=arguments[3]),I(v)?S.showHidden=v:v&&t._extend(S,v),B(S.showHidden)&&(S.showHidden=!1),B(S.depth)&&(S.depth=2),B(S.colors)&&(S.colors=!1),B(S.customInspect)&&(S.customInspect=!0),S.colors&&(S.stylize=h),f(S,g,S.depth)}t.inspect=c,c.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},c.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"};function h(g,v){var S=c.styles[v];return S?"\x1B["+c.colors[S][0]+"m"+g+"\x1B["+c.colors[S][1]+"m":g}function p(g,v){return g}function m(g){var v={};return g.forEach(function(S,_){v[S]=!0}),v}function f(g,v,S){if(g.customInspect&&v&&ue(v.inspect)&&v.inspect!==t.inspect&&!(v.constructor&&v.constructor.prototype===v)){var _=v.inspect(S,g);return C(_)||(_=f(g,_,S)),_}var M=w(g,v);if(M)return M;var V=Object.keys(v),R=m(V);if(g.showHidden&&(V=Object.getOwnPropertyNames(v)),be(v)&&(V.indexOf("message")>=0||V.indexOf("description")>=0))return E(v);if(V.length===0){if(ue(v)){var $=v.name?": "+v.name:"";return g.stylize("[Function"+$+"]","special")}if(q(v))return g.stylize(RegExp.prototype.toString.call(v),"regexp");if(we(v))return g.stylize(Date.prototype.toString.call(v),"date");if(be(v))return E(v)}var Q="",J=!1,le=["{","}"];if(N(v)&&(J=!0,le=["[","]"]),ue(v)){var Ne=v.name?": "+v.name:"";Q=" [Function"+Ne+"]"}if(q(v)&&(Q=" "+RegExp.prototype.toString.call(v)),we(v)&&(Q=" "+Date.prototype.toUTCString.call(v)),be(v)&&(Q=" "+E(v)),V.length===0&&(!J||v.length==0))return le[0]+Q+le[1];if(S<0)return q(v)?g.stylize(RegExp.prototype.toString.call(v),"regexp"):g.stylize("[Object]","special");g.seen.push(v);var Le;return J?Le=T(g,v,S,R,V):Le=V.map(function(De){return F(g,v,S,R,De,J)}),g.seen.pop(),x(Le,Q,le)}function w(g,v){if(B(v))return g.stylize("undefined","undefined");if(C(v)){var S="'"+JSON.stringify(v).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return g.stylize(S,"string")}if(P(v))return g.stylize(""+v,"number");if(I(v))return g.stylize(""+v,"boolean");if(O(v))return g.stylize("null","null")}function E(g){return"["+Error.prototype.toString.call(g)+"]"}function T(g,v,S,_,M){for(var V=[],R=0,$=v.length;R<$;++R)ve(v,String(R))?V.push(F(g,v,S,_,String(R),!0)):V.push("");return M.forEach(function(Q){Q.match(/^\d+$/)||V.push(F(g,v,S,_,Q,!0))}),V}function F(g,v,S,_,M,V){var R,$,Q;if(Q=Object.getOwnPropertyDescriptor(v,M)||{value:v[M]},Q.get?Q.set?$=g.stylize("[Getter/Setter]","special"):$=g.stylize("[Getter]","special"):Q.set&&($=g.stylize("[Setter]","special")),ve(_,M)||(R="["+M+"]"),$||(g.seen.indexOf(Q.value)<0?(O(S)?$=f(g,Q.value,null):$=f(g,Q.value,S-1),$.indexOf(`
|
|
7
|
+
*/(function(t){const e=Rt,r=gr,i=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=l,t.SlowBuffer=C,t.INSPECT_MAX_BYTES=50;const s=2147483647;t.kMaxLength=s;const{Uint8Array:u,ArrayBuffer:c,SharedArrayBuffer:h}=globalThis;l.TYPED_ARRAY_SUPPORT=p(),!l.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function p(){try{const a=new u(1),n={foo:function(){return 42}};return Object.setPrototypeOf(n,u.prototype),Object.setPrototypeOf(a,n),a.foo()===42}catch{return!1}}Object.defineProperty(l.prototype,"parent",{enumerable:!0,get:function(){if(l.isBuffer(this))return this.buffer}}),Object.defineProperty(l.prototype,"offset",{enumerable:!0,get:function(){if(l.isBuffer(this))return this.byteOffset}});function m(a){if(a>s)throw new RangeError('The value "'+a+'" is invalid for option "size"');const n=new u(a);return Object.setPrototypeOf(n,l.prototype),n}function l(a,n,o){if(typeof a=="number"){if(typeof n=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return F(a)}return w(a,n,o)}l.poolSize=8192;function w(a,n,o){if(typeof a=="string")return x(a,n);if(c.isView(a))return I(a);if(a==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof a);if(pe(a,c)||a&&pe(a.buffer,c)||typeof h<"u"&&(pe(a,h)||a&&pe(a.buffer,h)))return O(a,n,o);if(typeof a=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const f=a.valueOf&&a.valueOf();if(f!=null&&f!==a)return l.from(f,n,o);const d=j(a);if(d)return d;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof a[Symbol.toPrimitive]=="function")return l.from(a[Symbol.toPrimitive]("string"),n,o);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof a)}l.from=function(a,n,o){return w(a,n,o)},Object.setPrototypeOf(l.prototype,u.prototype),Object.setPrototypeOf(l,u);function E(a){if(typeof a!="number")throw new TypeError('"size" argument must be of type number');if(a<0)throw new RangeError('The value "'+a+'" is invalid for option "size"')}function T(a,n,o){return E(a),a<=0?m(a):n!==void 0?typeof o=="string"?m(a).fill(n,o):m(a).fill(n):m(a)}l.alloc=function(a,n,o){return T(a,n,o)};function F(a){return E(a),m(a<0?0:P(a)|0)}l.allocUnsafe=function(a){return F(a)},l.allocUnsafeSlow=function(a){return F(a)};function x(a,n){if((typeof n!="string"||n==="")&&(n="utf8"),!l.isEncoding(n))throw new TypeError("Unknown encoding: "+n);const o=k(a,n)|0;let f=m(o);const d=f.write(a,n);return d!==o&&(f=f.slice(0,d)),f}function N(a){const n=a.length<0?0:P(a.length)|0,o=m(n);for(let f=0;f<n;f+=1)o[f]=a[f]&255;return o}function I(a){if(pe(a,u)){const n=new u(a);return O(n.buffer,n.byteOffset,n.byteLength)}return N(a)}function O(a,n,o){if(n<0||a.byteLength<n)throw new RangeError('"offset" is outside of buffer bounds');if(a.byteLength<n+(o||0))throw new RangeError('"length" is outside of buffer bounds');let f;return n===void 0&&o===void 0?f=new u(a):o===void 0?f=new u(a,n):f=new u(a,n,o),Object.setPrototypeOf(f,l.prototype),f}function j(a){if(l.isBuffer(a)){const n=P(a.length)|0,o=m(n);return o.length===0||a.copy(o,0,0,n),o}if(a.length!==void 0)return typeof a.length!="number"||jt(a.length)?m(0):N(a);if(a.type==="Buffer"&&Array.isArray(a.data))return N(a.data)}function P(a){if(a>=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return a|0}function C(a){return+a!=a&&(a=0),l.alloc(+a)}l.isBuffer=function(n){return n!=null&&n._isBuffer===!0&&n!==l.prototype},l.compare=function(n,o){if(pe(n,u)&&(n=l.from(n,n.offset,n.byteLength)),pe(o,u)&&(o=l.from(o,o.offset,o.byteLength)),!l.isBuffer(n)||!l.isBuffer(o))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(n===o)return 0;let f=n.length,d=o.length;for(let y=0,b=Math.min(f,d);y<b;++y)if(n[y]!==o[y]){f=n[y],d=o[y];break}return f<d?-1:d<f?1:0},l.isEncoding=function(n){switch(String(n).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},l.concat=function(n,o){if(!Array.isArray(n))throw new TypeError('"list" argument must be an Array of Buffers');if(n.length===0)return l.alloc(0);let f;if(o===void 0)for(o=0,f=0;f<n.length;++f)o+=n[f].length;const d=l.allocUnsafe(o);let y=0;for(f=0;f<n.length;++f){let b=n[f];if(pe(b,u))y+b.length>d.length?(l.isBuffer(b)||(b=l.from(b)),b.copy(d,y)):u.prototype.set.call(d,b,y);else if(l.isBuffer(b))b.copy(d,y);else throw new TypeError('"list" argument must be an Array of Buffers');y+=b.length}return d};function k(a,n){if(l.isBuffer(a))return a.length;if(c.isView(a)||pe(a,c))return a.byteLength;if(typeof a!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof a);const o=a.length,f=arguments.length>2&&arguments[2]===!0;if(!f&&o===0)return 0;let d=!1;for(;;)switch(n){case"ascii":case"latin1":case"binary":return o;case"utf8":case"utf-8":return dt(a).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return o*2;case"hex":return o>>>1;case"base64":return kr(a).length;default:if(d)return f?-1:dt(a).length;n=(""+n).toLowerCase(),d=!0}}l.byteLength=k;function B(a,n,o){let f=!1;if((n===void 0||n<0)&&(n=0),n>this.length||((o===void 0||o>this.length)&&(o=this.length),o<=0)||(o>>>=0,n>>>=0,o<=n))return"";for(a||(a="utf8");;)switch(a){case"hex":return g(this,n,o);case"utf8":case"utf-8":return ze(this,n,o);case"ascii":return Be(this,n,o);case"latin1":case"binary":return Ke(this,n,o);case"base64":return ke(this,n,o);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return v(this,n,o);default:if(f)throw new TypeError("Unknown encoding: "+a);a=(a+"").toLowerCase(),f=!0}}l.prototype._isBuffer=!0;function q(a,n,o){const f=a[n];a[n]=a[o],a[o]=f}l.prototype.swap16=function(){const n=this.length;if(n%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let o=0;o<n;o+=2)q(this,o,o+1);return this},l.prototype.swap32=function(){const n=this.length;if(n%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let o=0;o<n;o+=4)q(this,o,o+3),q(this,o+1,o+2);return this},l.prototype.swap64=function(){const n=this.length;if(n%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let o=0;o<n;o+=8)q(this,o,o+7),q(this,o+1,o+6),q(this,o+2,o+5),q(this,o+3,o+4);return this},l.prototype.toString=function(){const n=this.length;return n===0?"":arguments.length===0?ze(this,0,n):B.apply(this,arguments)},l.prototype.toLocaleString=l.prototype.toString,l.prototype.equals=function(n){if(!l.isBuffer(n))throw new TypeError("Argument must be a Buffer");return this===n?!0:l.compare(this,n)===0},l.prototype.inspect=function(){let n="";const o=t.INSPECT_MAX_BYTES;return n=this.toString("hex",0,o).replace(/(.{2})/g,"$1 ").trim(),this.length>o&&(n+=" ... "),"<Buffer "+n+">"},i&&(l.prototype[i]=l.prototype.inspect),l.prototype.compare=function(n,o,f,d,y){if(pe(n,u)&&(n=l.from(n,n.offset,n.byteLength)),!l.isBuffer(n))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof n);if(o===void 0&&(o=0),f===void 0&&(f=n?n.length:0),d===void 0&&(d=0),y===void 0&&(y=this.length),o<0||f>n.length||d<0||y>this.length)throw new RangeError("out of range index");if(d>=y&&o>=f)return 0;if(d>=y)return-1;if(o>=f)return 1;if(o>>>=0,f>>>=0,d>>>=0,y>>>=0,this===n)return 0;let b=y-d,D=f-o;const W=Math.min(b,D),K=this.slice(d,y),H=n.slice(o,f);for(let z=0;z<W;++z)if(K[z]!==H[z]){b=K[z],D=H[z];break}return b<D?-1:D<b?1:0};function ie(a,n,o,f,d){if(a.length===0)return-1;if(typeof o=="string"?(f=o,o=0):o>2147483647?o=2147483647:o<-2147483648&&(o=-2147483648),o=+o,jt(o)&&(o=d?0:a.length-1),o<0&&(o=a.length+o),o>=a.length){if(d)return-1;o=a.length-1}else if(o<0)if(d)o=0;else return-1;if(typeof n=="string"&&(n=l.from(n,f)),l.isBuffer(n))return n.length===0?-1:we(a,n,o,f,d);if(typeof n=="number")return n=n&255,typeof u.prototype.indexOf=="function"?d?u.prototype.indexOf.call(a,n,o):u.prototype.lastIndexOf.call(a,n,o):we(a,[n],o,f,d);throw new TypeError("val must be string, number or Buffer")}function we(a,n,o,f,d){let y=1,b=a.length,D=n.length;if(f!==void 0&&(f=String(f).toLowerCase(),f==="ucs2"||f==="ucs-2"||f==="utf16le"||f==="utf-16le")){if(a.length<2||n.length<2)return-1;y=2,b/=2,D/=2,o/=2}function W(H,z){return y===1?H[z]:H.readUInt16BE(z*y)}let K;if(d){let H=-1;for(K=o;K<b;K++)if(W(a,K)===W(n,H===-1?0:K-H)){if(H===-1&&(H=K),K-H+1===D)return H*y}else H!==-1&&(K-=K-H),H=-1}else for(o+D>b&&(o=b-D),K=o;K>=0;K--){let H=!0;for(let z=0;z<D;z++)if(W(a,K+z)!==W(n,z)){H=!1;break}if(H)return K}return-1}l.prototype.includes=function(n,o,f){return this.indexOf(n,o,f)!==-1},l.prototype.indexOf=function(n,o,f){return ie(this,n,o,f,!0)},l.prototype.lastIndexOf=function(n,o,f){return ie(this,n,o,f,!1)};function be(a,n,o,f){o=Number(o)||0;const d=a.length-o;f?(f=Number(f),f>d&&(f=d)):f=d;const y=n.length;f>y/2&&(f=y/2);let b;for(b=0;b<f;++b){const D=parseInt(n.substr(b*2,2),16);if(jt(D))return b;a[o+b]=D}return b}function ue(a,n,o,f){return wt(dt(n,a.length-o),a,o,f)}function ft(a,n,o,f){return wt(xr(n),a,o,f)}function he(a,n,o,f){return wt(kr(n),a,o,f)}function Re(a,n,o,f){return wt(Yn(n,a.length-o),a,o,f)}l.prototype.write=function(n,o,f,d){if(o===void 0)d="utf8",f=this.length,o=0;else if(f===void 0&&typeof o=="string")d=o,f=this.length,o=0;else if(isFinite(o))o=o>>>0,isFinite(f)?(f=f>>>0,d===void 0&&(d="utf8")):(d=f,f=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const y=this.length-o;if((f===void 0||f>y)&&(f=y),n.length>0&&(f<0||o<0)||o>this.length)throw new RangeError("Attempt to write outside buffer bounds");d||(d="utf8");let b=!1;for(;;)switch(d){case"hex":return be(this,n,o,f);case"utf8":case"utf-8":return ue(this,n,o,f);case"ascii":case"latin1":case"binary":return ft(this,n,o,f);case"base64":return he(this,n,o,f);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Re(this,n,o,f);default:if(b)throw new TypeError("Unknown encoding: "+d);d=(""+d).toLowerCase(),b=!0}},l.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function ke(a,n,o){return n===0&&o===a.length?e.fromByteArray(a):e.fromByteArray(a.slice(n,o))}function ze(a,n,o){o=Math.min(a.length,o);const f=[];let d=n;for(;d<o;){const y=a[d];let b=null,D=y>239?4:y>223?3:y>191?2:1;if(d+D<=o){let W,K,H,z;switch(D){case 1:y<128&&(b=y);break;case 2:W=a[d+1],(W&192)===128&&(z=(y&31)<<6|W&63,z>127&&(b=z));break;case 3:W=a[d+1],K=a[d+2],(W&192)===128&&(K&192)===128&&(z=(y&15)<<12|(W&63)<<6|K&63,z>2047&&(z<55296||z>57343)&&(b=z));break;case 4:W=a[d+1],K=a[d+2],H=a[d+3],(W&192)===128&&(K&192)===128&&(H&192)===128&&(z=(y&15)<<18|(W&63)<<12|(K&63)<<6|H&63,z>65535&&z<1114112&&(b=z))}}b===null?(b=65533,D=1):b>65535&&(b-=65536,f.push(b>>>10&1023|55296),b=56320|b&1023),f.push(b),d+=D}return ce(f)}const ve=4096;function ce(a){const n=a.length;if(n<=ve)return String.fromCharCode.apply(String,a);let o="",f=0;for(;f<n;)o+=String.fromCharCode.apply(String,a.slice(f,f+=ve));return o}function Be(a,n,o){let f="";o=Math.min(a.length,o);for(let d=n;d<o;++d)f+=String.fromCharCode(a[d]&127);return f}function Ke(a,n,o){let f="";o=Math.min(a.length,o);for(let d=n;d<o;++d)f+=String.fromCharCode(a[d]);return f}function g(a,n,o){const f=a.length;(!n||n<0)&&(n=0),(!o||o<0||o>f)&&(o=f);let d="";for(let y=n;y<o;++y)d+=Xn[a[y]];return d}function v(a,n,o){const f=a.slice(n,o);let d="";for(let y=0;y<f.length-1;y+=2)d+=String.fromCharCode(f[y]+f[y+1]*256);return d}l.prototype.slice=function(n,o){const f=this.length;n=~~n,o=o===void 0?f:~~o,n<0?(n+=f,n<0&&(n=0)):n>f&&(n=f),o<0?(o+=f,o<0&&(o=0)):o>f&&(o=f),o<n&&(o=n);const d=this.subarray(n,o);return Object.setPrototypeOf(d,l.prototype),d};function S(a,n,o){if(a%1!==0||a<0)throw new RangeError("offset is not uint");if(a+n>o)throw new RangeError("Trying to access beyond buffer length")}l.prototype.readUintLE=l.prototype.readUIntLE=function(n,o,f){n=n>>>0,o=o>>>0,f||S(n,o,this.length);let d=this[n],y=1,b=0;for(;++b<o&&(y*=256);)d+=this[n+b]*y;return d},l.prototype.readUintBE=l.prototype.readUIntBE=function(n,o,f){n=n>>>0,o=o>>>0,f||S(n,o,this.length);let d=this[n+--o],y=1;for(;o>0&&(y*=256);)d+=this[n+--o]*y;return d},l.prototype.readUint8=l.prototype.readUInt8=function(n,o){return n=n>>>0,o||S(n,1,this.length),this[n]},l.prototype.readUint16LE=l.prototype.readUInt16LE=function(n,o){return n=n>>>0,o||S(n,2,this.length),this[n]|this[n+1]<<8},l.prototype.readUint16BE=l.prototype.readUInt16BE=function(n,o){return n=n>>>0,o||S(n,2,this.length),this[n]<<8|this[n+1]},l.prototype.readUint32LE=l.prototype.readUInt32LE=function(n,o){return n=n>>>0,o||S(n,4,this.length),(this[n]|this[n+1]<<8|this[n+2]<<16)+this[n+3]*16777216},l.prototype.readUint32BE=l.prototype.readUInt32BE=function(n,o){return n=n>>>0,o||S(n,4,this.length),this[n]*16777216+(this[n+1]<<16|this[n+2]<<8|this[n+3])},l.prototype.readBigUInt64LE=Pe(function(n){n=n>>>0,Se(n,"offset");const o=this[n],f=this[n+7];(o===void 0||f===void 0)&&$e(n,this.length-8);const d=o+this[++n]*2**8+this[++n]*2**16+this[++n]*2**24,y=this[++n]+this[++n]*2**8+this[++n]*2**16+f*2**24;return BigInt(d)+(BigInt(y)<<BigInt(32))}),l.prototype.readBigUInt64BE=Pe(function(n){n=n>>>0,Se(n,"offset");const o=this[n],f=this[n+7];(o===void 0||f===void 0)&&$e(n,this.length-8);const d=o*2**24+this[++n]*2**16+this[++n]*2**8+this[++n],y=this[++n]*2**24+this[++n]*2**16+this[++n]*2**8+f;return(BigInt(d)<<BigInt(32))+BigInt(y)}),l.prototype.readIntLE=function(n,o,f){n=n>>>0,o=o>>>0,f||S(n,o,this.length);let d=this[n],y=1,b=0;for(;++b<o&&(y*=256);)d+=this[n+b]*y;return y*=128,d>=y&&(d-=Math.pow(2,8*o)),d},l.prototype.readIntBE=function(n,o,f){n=n>>>0,o=o>>>0,f||S(n,o,this.length);let d=o,y=1,b=this[n+--d];for(;d>0&&(y*=256);)b+=this[n+--d]*y;return y*=128,b>=y&&(b-=Math.pow(2,8*o)),b},l.prototype.readInt8=function(n,o){return n=n>>>0,o||S(n,1,this.length),this[n]&128?(255-this[n]+1)*-1:this[n]},l.prototype.readInt16LE=function(n,o){n=n>>>0,o||S(n,2,this.length);const f=this[n]|this[n+1]<<8;return f&32768?f|4294901760:f},l.prototype.readInt16BE=function(n,o){n=n>>>0,o||S(n,2,this.length);const f=this[n+1]|this[n]<<8;return f&32768?f|4294901760:f},l.prototype.readInt32LE=function(n,o){return n=n>>>0,o||S(n,4,this.length),this[n]|this[n+1]<<8|this[n+2]<<16|this[n+3]<<24},l.prototype.readInt32BE=function(n,o){return n=n>>>0,o||S(n,4,this.length),this[n]<<24|this[n+1]<<16|this[n+2]<<8|this[n+3]},l.prototype.readBigInt64LE=Pe(function(n){n=n>>>0,Se(n,"offset");const o=this[n],f=this[n+7];(o===void 0||f===void 0)&&$e(n,this.length-8);const d=this[n+4]+this[n+5]*2**8+this[n+6]*2**16+(f<<24);return(BigInt(d)<<BigInt(32))+BigInt(o+this[++n]*2**8+this[++n]*2**16+this[++n]*2**24)}),l.prototype.readBigInt64BE=Pe(function(n){n=n>>>0,Se(n,"offset");const o=this[n],f=this[n+7];(o===void 0||f===void 0)&&$e(n,this.length-8);const d=(o<<24)+this[++n]*2**16+this[++n]*2**8+this[++n];return(BigInt(d)<<BigInt(32))+BigInt(this[++n]*2**24+this[++n]*2**16+this[++n]*2**8+f)}),l.prototype.readFloatLE=function(n,o){return n=n>>>0,o||S(n,4,this.length),r.read(this,n,!0,23,4)},l.prototype.readFloatBE=function(n,o){return n=n>>>0,o||S(n,4,this.length),r.read(this,n,!1,23,4)},l.prototype.readDoubleLE=function(n,o){return n=n>>>0,o||S(n,8,this.length),r.read(this,n,!0,52,8)},l.prototype.readDoubleBE=function(n,o){return n=n>>>0,o||S(n,8,this.length),r.read(this,n,!1,52,8)};function _(a,n,o,f,d,y){if(!l.isBuffer(a))throw new TypeError('"buffer" argument must be a Buffer instance');if(n>d||n<y)throw new RangeError('"value" argument is out of bounds');if(o+f>a.length)throw new RangeError("Index out of range")}l.prototype.writeUintLE=l.prototype.writeUIntLE=function(n,o,f,d){if(n=+n,o=o>>>0,f=f>>>0,!d){const D=Math.pow(2,8*f)-1;_(this,n,o,f,D,0)}let y=1,b=0;for(this[o]=n&255;++b<f&&(y*=256);)this[o+b]=n/y&255;return o+f},l.prototype.writeUintBE=l.prototype.writeUIntBE=function(n,o,f,d){if(n=+n,o=o>>>0,f=f>>>0,!d){const D=Math.pow(2,8*f)-1;_(this,n,o,f,D,0)}let y=f-1,b=1;for(this[o+y]=n&255;--y>=0&&(b*=256);)this[o+y]=n/b&255;return o+f},l.prototype.writeUint8=l.prototype.writeUInt8=function(n,o,f){return n=+n,o=o>>>0,f||_(this,n,o,1,255,0),this[o]=n&255,o+1},l.prototype.writeUint16LE=l.prototype.writeUInt16LE=function(n,o,f){return n=+n,o=o>>>0,f||_(this,n,o,2,65535,0),this[o]=n&255,this[o+1]=n>>>8,o+2},l.prototype.writeUint16BE=l.prototype.writeUInt16BE=function(n,o,f){return n=+n,o=o>>>0,f||_(this,n,o,2,65535,0),this[o]=n>>>8,this[o+1]=n&255,o+2},l.prototype.writeUint32LE=l.prototype.writeUInt32LE=function(n,o,f){return n=+n,o=o>>>0,f||_(this,n,o,4,4294967295,0),this[o+3]=n>>>24,this[o+2]=n>>>16,this[o+1]=n>>>8,this[o]=n&255,o+4},l.prototype.writeUint32BE=l.prototype.writeUInt32BE=function(n,o,f){return n=+n,o=o>>>0,f||_(this,n,o,4,4294967295,0),this[o]=n>>>24,this[o+1]=n>>>16,this[o+2]=n>>>8,this[o+3]=n&255,o+4};function M(a,n,o,f,d){De(n,f,d,a,o,7);let y=Number(n&BigInt(4294967295));a[o++]=y,y=y>>8,a[o++]=y,y=y>>8,a[o++]=y,y=y>>8,a[o++]=y;let b=Number(n>>BigInt(32)&BigInt(4294967295));return a[o++]=b,b=b>>8,a[o++]=b,b=b>>8,a[o++]=b,b=b>>8,a[o++]=b,o}function V(a,n,o,f,d){De(n,f,d,a,o,7);let y=Number(n&BigInt(4294967295));a[o+7]=y,y=y>>8,a[o+6]=y,y=y>>8,a[o+5]=y,y=y>>8,a[o+4]=y;let b=Number(n>>BigInt(32)&BigInt(4294967295));return a[o+3]=b,b=b>>8,a[o+2]=b,b=b>>8,a[o+1]=b,b=b>>8,a[o]=b,o+8}l.prototype.writeBigUInt64LE=Pe(function(n,o=0){return M(this,n,o,BigInt(0),BigInt("0xffffffffffffffff"))}),l.prototype.writeBigUInt64BE=Pe(function(n,o=0){return V(this,n,o,BigInt(0),BigInt("0xffffffffffffffff"))}),l.prototype.writeIntLE=function(n,o,f,d){if(n=+n,o=o>>>0,!d){const W=Math.pow(2,8*f-1);_(this,n,o,f,W-1,-W)}let y=0,b=1,D=0;for(this[o]=n&255;++y<f&&(b*=256);)n<0&&D===0&&this[o+y-1]!==0&&(D=1),this[o+y]=(n/b>>0)-D&255;return o+f},l.prototype.writeIntBE=function(n,o,f,d){if(n=+n,o=o>>>0,!d){const W=Math.pow(2,8*f-1);_(this,n,o,f,W-1,-W)}let y=f-1,b=1,D=0;for(this[o+y]=n&255;--y>=0&&(b*=256);)n<0&&D===0&&this[o+y+1]!==0&&(D=1),this[o+y]=(n/b>>0)-D&255;return o+f},l.prototype.writeInt8=function(n,o,f){return n=+n,o=o>>>0,f||_(this,n,o,1,127,-128),n<0&&(n=255+n+1),this[o]=n&255,o+1},l.prototype.writeInt16LE=function(n,o,f){return n=+n,o=o>>>0,f||_(this,n,o,2,32767,-32768),this[o]=n&255,this[o+1]=n>>>8,o+2},l.prototype.writeInt16BE=function(n,o,f){return n=+n,o=o>>>0,f||_(this,n,o,2,32767,-32768),this[o]=n>>>8,this[o+1]=n&255,o+2},l.prototype.writeInt32LE=function(n,o,f){return n=+n,o=o>>>0,f||_(this,n,o,4,2147483647,-2147483648),this[o]=n&255,this[o+1]=n>>>8,this[o+2]=n>>>16,this[o+3]=n>>>24,o+4},l.prototype.writeInt32BE=function(n,o,f){return n=+n,o=o>>>0,f||_(this,n,o,4,2147483647,-2147483648),n<0&&(n=4294967295+n+1),this[o]=n>>>24,this[o+1]=n>>>16,this[o+2]=n>>>8,this[o+3]=n&255,o+4},l.prototype.writeBigInt64LE=Pe(function(n,o=0){return M(this,n,o,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),l.prototype.writeBigInt64BE=Pe(function(n,o=0){return V(this,n,o,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function R(a,n,o,f,d,y){if(o+f>a.length)throw new RangeError("Index out of range");if(o<0)throw new RangeError("Index out of range")}function $(a,n,o,f,d){return n=+n,o=o>>>0,d||R(a,n,o,4),r.write(a,n,o,f,23,4),o+4}l.prototype.writeFloatLE=function(n,o,f){return $(this,n,o,!0,f)},l.prototype.writeFloatBE=function(n,o,f){return $(this,n,o,!1,f)};function Q(a,n,o,f,d){return n=+n,o=o>>>0,d||R(a,n,o,8),r.write(a,n,o,f,52,8),o+8}l.prototype.writeDoubleLE=function(n,o,f){return Q(this,n,o,!0,f)},l.prototype.writeDoubleBE=function(n,o,f){return Q(this,n,o,!1,f)},l.prototype.copy=function(n,o,f,d){if(!l.isBuffer(n))throw new TypeError("argument should be a Buffer");if(f||(f=0),!d&&d!==0&&(d=this.length),o>=n.length&&(o=n.length),o||(o=0),d>0&&d<f&&(d=f),d===f||n.length===0||this.length===0)return 0;if(o<0)throw new RangeError("targetStart out of bounds");if(f<0||f>=this.length)throw new RangeError("Index out of range");if(d<0)throw new RangeError("sourceEnd out of bounds");d>this.length&&(d=this.length),n.length-o<d-f&&(d=n.length-o+f);const y=d-f;return this===n&&typeof u.prototype.copyWithin=="function"?this.copyWithin(o,f,d):u.prototype.set.call(n,this.subarray(f,d),o),y},l.prototype.fill=function(n,o,f,d){if(typeof n=="string"){if(typeof o=="string"?(d=o,o=0,f=this.length):typeof f=="string"&&(d=f,f=this.length),d!==void 0&&typeof d!="string")throw new TypeError("encoding must be a string");if(typeof d=="string"&&!l.isEncoding(d))throw new TypeError("Unknown encoding: "+d);if(n.length===1){const b=n.charCodeAt(0);(d==="utf8"&&b<128||d==="latin1")&&(n=b)}}else typeof n=="number"?n=n&255:typeof n=="boolean"&&(n=Number(n));if(o<0||this.length<o||this.length<f)throw new RangeError("Out of range index");if(f<=o)return this;o=o>>>0,f=f===void 0?this.length:f>>>0,n||(n=0);let y;if(typeof n=="number")for(y=o;y<f;++y)this[y]=n;else{const b=l.isBuffer(n)?n:l.from(n,d),D=b.length;if(D===0)throw new TypeError('The value "'+n+'" is invalid for argument "value"');for(y=0;y<f-o;++y)this[y+o]=b[y%D]}return this};const J={};function le(a,n,o){J[a]=class extends o{constructor(){super(),Object.defineProperty(this,"message",{value:n.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${a}]`,this.stack,delete this.name}get code(){return a}set code(d){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:d,writable:!0})}toString(){return`${this.name} [${a}]: ${this.message}`}}}le("ERR_BUFFER_OUT_OF_BOUNDS",function(a){return a?`${a} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),le("ERR_INVALID_ARG_TYPE",function(a,n){return`The "${a}" argument must be of type number. Received type ${typeof n}`},TypeError),le("ERR_OUT_OF_RANGE",function(a,n,o){let f=`The value of "${a}" is out of range.`,d=o;return Number.isInteger(o)&&Math.abs(o)>2**32?d=Ne(String(o)):typeof o=="bigint"&&(d=String(o),(o>BigInt(2)**BigInt(32)||o<-(BigInt(2)**BigInt(32)))&&(d=Ne(d)),d+="n"),f+=` It must be ${n}. Received ${d}`,f},RangeError);function Ne(a){let n="",o=a.length;const f=a[0]==="-"?1:0;for(;o>=f+4;o-=3)n=`_${a.slice(o-3,o)}${n}`;return`${a.slice(0,o)}${n}`}function Le(a,n,o){Se(n,"offset"),(a[n]===void 0||a[n+o]===void 0)&&$e(n,a.length-(o+1))}function De(a,n,o,f,d,y){if(a>o||a<n){const b=typeof n=="bigint"?"n":"";let D;throw y>3?n===0||n===BigInt(0)?D=`>= 0${b} and < 2${b} ** ${(y+1)*8}${b}`:D=`>= -(2${b} ** ${(y+1)*8-1}${b}) and < 2 ** ${(y+1)*8-1}${b}`:D=`>= ${n}${b} and <= ${o}${b}`,new J.ERR_OUT_OF_RANGE("value",D,a)}Le(f,d,y)}function Se(a,n){if(typeof a!="number")throw new J.ERR_INVALID_ARG_TYPE(n,"number",a)}function $e(a,n,o){throw Math.floor(a)!==a?(Se(a,o),new J.ERR_OUT_OF_RANGE(o||"offset","an integer",a)):n<0?new J.ERR_BUFFER_OUT_OF_BOUNDS:new J.ERR_OUT_OF_RANGE(o||"offset",`>= ${o?1:0} and <= ${n}`,a)}const Ut=/[^+/0-9A-Za-z-_]/g;function A(a){if(a=a.split("=")[0],a=a.trim().replace(Ut,""),a.length<2)return"";for(;a.length%4!==0;)a=a+"=";return a}function dt(a,n){n=n||1/0;let o;const f=a.length;let d=null;const y=[];for(let b=0;b<f;++b){if(o=a.charCodeAt(b),o>55295&&o<57344){if(!d){if(o>56319){(n-=3)>-1&&y.push(239,191,189);continue}else if(b+1===f){(n-=3)>-1&&y.push(239,191,189);continue}d=o;continue}if(o<56320){(n-=3)>-1&&y.push(239,191,189),d=o;continue}o=(d-55296<<10|o-56320)+65536}else d&&(n-=3)>-1&&y.push(239,191,189);if(d=null,o<128){if((n-=1)<0)break;y.push(o)}else if(o<2048){if((n-=2)<0)break;y.push(o>>6|192,o&63|128)}else if(o<65536){if((n-=3)<0)break;y.push(o>>12|224,o>>6&63|128,o&63|128)}else if(o<1114112){if((n-=4)<0)break;y.push(o>>18|240,o>>12&63|128,o>>6&63|128,o&63|128)}else throw new Error("Invalid code point")}return y}function xr(a){const n=[];for(let o=0;o<a.length;++o)n.push(a.charCodeAt(o)&255);return n}function Yn(a,n){let o,f,d;const y=[];for(let b=0;b<a.length&&!((n-=2)<0);++b)o=a.charCodeAt(b),f=o>>8,d=o%256,y.push(d),y.push(f);return y}function kr(a){return e.toByteArray(A(a))}function wt(a,n,o,f){let d;for(d=0;d<f&&!(d+o>=n.length||d>=a.length);++d)n[d+o]=a[d];return d}function pe(a,n){return a instanceof n||a!=null&&a.constructor!=null&&a.constructor.name!=null&&a.constructor.name===n.name}function jt(a){return a!==a}const Xn=function(){const a="0123456789abcdef",n=new Array(256);for(let o=0;o<16;++o){const f=o*16;for(let d=0;d<16;++d)n[f+d]=a[o]+a[d]}return n}();function Pe(a){return typeof BigInt>"u"?Zn:a}function Zn(){throw new Error("BigInt not supported")}})(gn);const Dr=gn.Buffer;var wn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Xi(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var mr={exports:{}};const Zi=Object.getPrototypeOf({});function wr(t){function e(I){return I!=="constructor"&&I!=="prototype"&&I!=="__proto__"}function r(I){let O=0;const j=I.length,P=new Array(j);for(O=0;O<j;++O)P[O]=T(I[O]);return P}function i(I){const O={};if(p&&Object.getPrototypeOf(I)!==Zi)return p(I);const j=h(I);let P,C,k;for(P=0,C=j.length;P<C;++P)e(k=j[P])&&(O[k]=T(I[k]));return O}function s(I,O){const j=I.length,P=O.length;let C=0;const k=new Array(j+P);for(C=0;C<j;++C)k[C]=T(I[C]);for(C=0;C<P;++C)k[C+j]=T(O[C]);return k}const u=Object.prototype.propertyIsEnumerable;function c(I){const O=Object.keys(I),j=Object.getOwnPropertySymbols(I);for(let P=0,C=j.length;P<C;++P)u.call(I,j[P])&&O.push(j[P]);return O}const h=t&&t.symbols?c:Object.keys,p=typeof t?.cloneProtoObject=="function"?t.cloneProtoObject:void 0;function m(I){return typeof I=="object"&&I!==null&&!(I instanceof RegExp)&&!(I instanceof Date)}function l(I){return typeof I!="object"||I===null}const w=typeof Dr<"u"?I=>typeof I!="object"||I===null||I instanceof RegExp||I instanceof Date||I instanceof Dr:I=>typeof I!="object"||I===null||I instanceof RegExp||I instanceof Date,E=t&&typeof t.mergeArray=="function"?t.mergeArray({clone:T,deepmerge:x,getKeys:h,isMergeableObject:m}):s;function T(I){return m(I)?Array.isArray(I)?r(I):i(I):I}function F(I,O){const j={},P=h(I),C=h(O);let k,B,q;for(k=0,B=P.length;k<B;++k)e(q=P[k])&&C.indexOf(q)===-1&&(j[q]=T(I[q]));for(k=0,B=C.length;k<B;++k)e(q=C[k])&&(q in I&&(P.indexOf(q)!==-1&&(j[q]=x(I[q],O[q])),!0)||(j[q]=T(O[q])));return j}function x(I,O){const j=Array.isArray(O),P=Array.isArray(I);return l(O)?O:w(I)?T(O):j&&P?E(I,O):j!==P?T(O):F(I,O)}function N(){switch(arguments.length){case 0:return{};case 1:return T(arguments[0]);case 2:return x(arguments[0],arguments[1])}let I;for(let O=0,j=arguments.length;O<j;++O)I=x(I,arguments[O]);return I}return t&&t.all?N:x}mr.exports=wr;mr.exports.default=wr;var eo=mr.exports.deepmerge=wr;const to=t=>(e,r)=>{let i=0;const s=e.length,u=r.length,c=Math.max(s,u),h=new Array(c);for(i=0;i<c;++i)i<u?h[i]=t.deepmerge(e[i],r[i]):h[i]=t.clone(e[i]);return h},ro=eo({mergeArray:to}),no=(t,e,r)=>{const i=Fe.computed([e,r],(c,h)=>{if(c){const p=h.data?.find(m=>m.id===c);if(p)return p;console.error("Feed list is not loaded yet. Issue with the opened question.")}}),s=Oe({data:void 0,loading:void 0,error:void 0});return i.subscribe(async c=>{if(c&&c.type==="question"){s.setKey("loading",!0);const h=await yn(c.id,t);s.set({data:h,loading:!1});return}s.set({data:void 0,loading:!1})}),{$store:i,$extendedStore:s,updateExtendedQuestion:c=>{const h=s.get().data;if(h&&c?.answers)for(const p of c.answers)p.youVoted!==!0&&delete p.youVoted;s.set({data:ro(h,c)})}}};var qe;(function(t){t.ALLOWED="allowed",t.DISALLOWED="disallowed"})(qe||(qe={}));class io{slStreamId;organizationId;userId;interactiveAllowed;openedQuestionId;openedQuestion;activeQuestionId;feedList;moderationId;moderation;feedSubscription;questionSubscription;notifications;log;constructor(e){this.log=Pt("gamification-background"),this.slStreamId=e.stores.slStreamId.getAtomStore(),this.organizationId=e.stores.organizationSettings.getAtomStore(),this.userId=e.stores.user.getAtomStore(),this.moderationId=new ae(ne(void 0),"moderationId").getStore(),this.interactiveAllowed=new ae(ne(qe.DISALLOWED),"interactiveAllowed").getStore(),this.openedQuestionId=new ae(ne(void 0),"openedQuestionId").getStore(),this.notifications=e.notifications,this.moderation=new de(Ui(this.slStreamId,e.transport),"gamification:moderation"),this.feedList=new de(qi(this.slStreamId,this.interactiveAllowed,e.transport),"gamification:feedList"),this.activeQuestionId=new de(ji(this.slStreamId,e.transport),"gamification:activeQuestionId"),this.openedQuestion=no(e.transport,this.openedQuestionId,this.feedList.getStore()),this.openedQuestionId.listen(r=>{this.log.debug({questionId:r},"received question"),r?(this.questionSubscription=Vi(r,e.transport),this.questionSubscription.addListener("feed-subscription-opened-question",i=>{window.requestAnimationFrame(()=>{this.openedQuestion.updateExtendedQuestion(i.data?.attributes?.question)})}),this.questionSubscription.connect()):(this.log.info("cleanup on close question"),this.questionSubscription!==void 0&&(e.transport.removeSubscription(this.questionSubscription),this.questionSubscription=void 0))}),this.feedSubscription=Mi(this.slStreamId,e.transport),this.feedSubscription.addListener("feed-subscription-active-question",r=>{const i=this.activeQuestionId.getStore();i&&i.mutate(r.data?.attributes)}),this.feedSubscription.addListener("moderation update",r=>{window.requestAnimationFrame(()=>{r.data?.attributes?.question===void 0&&r.data?.attributes?.moderation&&this.moderation.invalidate()})}),this.feedSubscription.connect(),this.interactiveAllowed.listen(()=>{window.requestAnimationFrame(()=>{this.activeQuestionId.invalidate()})})}getCurrentSessionId=e=>{const r=e.eventId||this.slStreamId.get()||"",i=e.userId||this.userId.get()||"",s=e.organizationId||this.organizationId.get()||"",u=e.entity||"",c=e.prefix||"";return[s,r,i,c,u].join(":")};disconnect=()=>{this.feedSubscription?.disconnect()};openQuestion=e=>{this.openedQuestionId.set(e),this.notifications.markAsViewed(this.getCurrentSessionId({prefix:"notification",entity:e}))};closeQuestion=e=>{this.openedQuestionId.set(void 0),e&&this.notifications.markAsViewed(this.getCurrentSessionId({prefix:"notification",entity:e}))}}class oo{notificationsList;notifications;store;timeouts;waitingQueue;activeQueue;options;logger;constructor(e){this.options=e,this.logger=Pt("notifications"),this.store=new Map,this.timeouts=new Map,this.waitingQueue=new Set,this.activeQueue=new Set,this.notifications=new ae(ne(new Map),"notifications-queue"),this.notificationsList=this.notifications.getStore()}addToQueue=e=>{if(this.store.has(e.id)){this.logger.debug({notification:e},"skip existed notification: %o");return}const r=e.close,i=e.action;if(this.store.set(e.id,{...e,close:(...s)=>{r&&r(...s),this.closeNotification(e.id)},action:(...s)=>{i&&i(...s),this.closeNotification(e.id)}}),this.waitingQueue.add(e.id),this.activeQueue.size===this.options.concurrency){const[s]=this.activeQueue;if(this.store.get(s)?.persistent!==!0)this.closeNotification(s);else{const[c]=this.waitingQueue;this.waitingQueue.size>1&&this.closeNotification(c),this.tickWaitingQueue()}}else this.tickWaitingQueue()};tickWaitingQueue=()=>{if(this.activeQueue.size<this.options.concurrency){const[e]=this.waitingQueue;if(!e)return;this.activeQueue.add(e),this.waitingQueue.delete(e),this.logger.debug({job:e},"waiting queue tick"),this.tickActiveQueue(e)}else this.logger.debug({queueSize:this.activeQueue.size,concurrency:this.options.concurrency},"waiting queue tick skipped")};tickActiveQueue=e=>{if(!e)return;const r=this.store.get(e);if(!r){this.logger.debug({notificationId:e},"active queue tick skipped, notification not exist");return}const i=setTimeout(()=>{const s=e,u=new Map(this.notifications.getValue());u.set(r.id,r),this.notifications.setValue(u);const c=setTimeout(()=>{this.logger.debug({notificationId:s,delay:r.autoHideDuration||5e3},"notification hiding by autoHideDuration"),this.closeNotification(s)},r.autoHideDuration||5e3);this.timeouts.set(s,c),this.logger.debug({notificationId:s,queue:[...u.values()]},"notification displayed")},r.delay||0);this.timeouts.set(e,i),this.logger.debug({notificationId:e},"active queue tick completed"),this.tickWaitingQueue()};closeNotification=e=>{const r=new Map(this.notifications.getValue()),i=r.get(e);if(i){i.hiding=!(this.waitingQueue.size>=this.options.concurrency),this.notifications.setValue(r);const s=setTimeout(()=>{const u=new Map(this.notifications.getValue());u.delete(e),this.notifications.setValue(u);const c=this.timeouts.get(e);c!==void 0&&(clearTimeout(c),this.timeouts.delete(e)),this.logger.debug({notificationId:e},"notification hidden")},this.options.animationDelay||0);this.timeouts.set(e,s)}this.store.delete(e),this.activeQueue.delete(e),this.waitingQueue.delete(e),this.tickWaitingQueue(),this.logger.debug({notificationId:e},"notification hiding")}}var _t;(function(t){t.OPENED="opened"})(_t||(_t={}));class so extends Lt{constructor(){super("notification")}setOpened=e=>{this.write(_t.OPENED,e,"true")};isOpened=e=>this.read(_t.OPENED,e);clearNotification=()=>{this.clear()}}var Ve;(function(t){t[t.ONBOARDING=1]="ONBOARDING",t[t.QUESTION=2]="QUESTION",t[t.QUESTION_RESOLVED=3]="QUESTION_RESOLVED"})(Ve||(Ve={}));class ao{queue;storage;constructor(e={}){this.storage=new so,this.queue=new oo({concurrency:1,animationDelay:1600,...e})}add=e=>{this.storage.isOpened(e.id)||this.queue.addToQueue(e)};close=(e,r=!0)=>{this.queue.closeNotification(e),r&&this.markAsViewed(e)};getQueueStore=()=>this.queue.notificationsList;markAsViewed=e=>{this.storage.setOpened(e)}}const uo=(t,e,r)=>{t.notifications=new ao,t.addNotification=t.notifications.add,t.sdk.getNotificationsStore=()=>t.notifications.getQueueStore(),r()},co=(t,e)=>{const{client:r}=t.createPromiseClient(Ce.Feed,{method:"submitAnswer"});return r.submitAnswer({data:e})},lo=(t,e)=>{const{client:r}=t.createPromiseClient(Ce.Feed,{method:"submitInplay"});return r.submitInplay({data:{eventId:+e}})},fo=(t,e)=>{const{client:r}=t.createPromiseClient(Ce.Feed,{method:"skipQuestion"});return r.skipQuestion({data:{id:e}})};var et;(function(t){t.ONBOARDING="onboarding",t.ONBOARDING_IO="onboarding_io"})(et||(et={}));class bn extends Lt{constructor(){super("gamification")}saveOnboardingStatus=({userId:e,eventId:r,organizationId:i},s)=>{this.write(et.ONBOARDING,i,e,r,s)};getOnboardingStatus=({userId:e,eventId:r,organizationId:i})=>this.read(et.ONBOARDING,i,e,r);setOnboardingInstantOpen=({userId:e,eventId:r,organizationId:i})=>{const s=this.generateKey([et.ONBOARDING_IO,i,e,r]);window.sessionStorage.setItem(s,"1")};getOnboardingInstantOpen=({userId:e,eventId:r,organizationId:i})=>{const s=this.generateKey([et.ONBOARDING_IO,i,e,r]);return window.sessionStorage.getItem(s)}}const $r={pageSize:10},ho=(t,e,r,i,s)=>{let u=0;const c=ne({pageSize:s?.pageSize||$r.pageSize,page:0}),h=Oe({data:[],key:Date.now(),hasMore:!0,loading:void 0,error:void 0}),p=Di(t),m=async()=>{const E=e.get(),T=i.getStore().get().data?.map(F=>F.slId)||[];if(E&&T?.length){const F=r.get();F&&T.push(F),h.setKey("loading",!0),h.setKey("data",[]);const x={eventId:E,usersIds:T,pagination:{page:0,pageSize:s?.pageSize||$r.pageSize}},N=await p(x);h.set({data:N.data.map(I=>I.attributes),hasMore:!0,key:Date.now(),loading:!1}),N.meta&&(u=Math.round(N.meta.count/N.meta.pageSize)),c.set(x.pagination)}},l=()=>{m()},w=E=>{const T=c.get(),F=E||T.page+1;F<=u&&c.set({...T,page:F})};return Fe.onMount(h,()=>{const E=e.listen(m),T=i.listen(m),F=c.listen(async x=>{const N=e.get();if(x.page>0&&N)if(x.page<u){h.setKey("loading",!0);const O=await p({eventId:N,pagination:x}),j=h.get().data||[];h.set({data:[...j,...O.data.map(P=>P.attributes)],key:h.get().key,loading:!1,hasMore:!0})}else h.setKey("hasMore",!1)});return()=>{E(),T(),F()}}),{$store:h,fetchMore:w,invalidate:l}},po=(t,e)=>{const{client:r,queryKey:i}=t.createPromiseClient(gt.Client,{method:"generateDeepLink",params:e});return t.nanoquery.createFetcherStore(i,{fetcher:async(s,u,c,h)=>c?(await r.generateDeepLink({data:{gamification:!0,externalEventId:h,eventId:c}})).data?.attributes:{}})},yo=(t,{web:e,mobile:r})=>{const{client:i}=t.createPromiseClient(ri.LinksClient,{method:"generate"});return i.generate({web:e,mobile:r})},Ur=(t,e)=>{const r=new URLSearchParams(t);for(const[i,s]of Object.entries(e))r.append(i,s);return r.toString()},go=(t,e,r,i)=>{const s=Oe({});return Fe.onMount(s,()=>po(t,[e,r]).subscribe(async({data:h,error:p,loading:m})=>{const l=p?"https://masters.com":h?.url,w=i.get()||"",E=e.get()||"",T=r.get()||"",F={[yr]:w,[hn]:E,[pn]:T};if(!m&&l){s.setKey("loading",!0);let x=window.location.search,N=window.location.hash;x&&N||N?x=`?${Ur(x,F)}`:N=`#${Ur("",F)}`;const I=window.location.origin+window.location.pathname+x+N,O=await yo(t,{web:I,mobile:l});s.set({data:O.data?.link,loading:!1})}else s.setKey("loading",!0)})),{$store:s,fetch}};var ee;(function(t){t.Unset="unset",t.Required="required",t.Optional="optional",t.Completed="completed",t.Disabled="disabled",t.Unavailable="unavailable"})(ee||(ee={}));const mo=(t,e,r,i)=>{const{inplayGame:s}=t.featureSettings.get(),u=e.getCurrentSessionId({prefix:"onboarding"});s&&r.add({type:Ve.ONBOARDING,id:u,action:t.openFeature,persistent:!0,autoHideDuration:1e6,data:{questionType:re.QuestionType.UNSET,onboarding:{...s,instantOpen:!i.getOnboardingInstantOpen({userId:e.userId.get()||"",organizationId:e.organizationId.get()||"",eventId:e.slStreamId.get()||""})}}})},bt=(t,e,r,i,s,u)=>{try{const c=e.userId.get();if(!c)return;if(s.getOnboardingStatus({userId:c,organizationId:e.organizationId.get()||"",eventId:e.slStreamId.get()||""})===ee.Completed){t.set(ee.Completed);for(const E of u)E();return}const p=e.moderation.getStore().value?.data,m=r.featureSettings.get().inplayGame;if(p===void 0||m===void 0)return;const l=p?.options?.onboardingEnabled,w=m?.titleCard?.optIn;l?w?t.set(ee.Required):t.set(ee.Optional):(w?t.set(ee.Unavailable):t.set(ee.Disabled),i.close(e.getCurrentSessionId({prefix:"onboarding"}),!1))}catch(c){console.error(c)}},wo=(t,e,r,i)=>{let s=!1;const u=new bn,c=ne(ee.Unset);c.subscribe(m=>{m!==ee.Unset&&((m===ee.Optional||m===ee.Required)&&s===!1&&(mo(t,e,i,u),s=!0),m===ee.Completed&&e.activeQuestionId.invalidate(),u.setOnboardingInstantOpen({userId:e.userId.get()||"",organizationId:e.organizationId.get()||"",eventId:e.slStreamId.get()||""}))});const h=[];return bt(c,e,t,i,u,h),c.get()!==ee.Completed&&(h.push(e.userId.listen(m=>{m&&bt(c,e,t,i,u,h)})),h.push(e.moderation.listen(m=>{m.data&&bt(c,e,t,i,u,h)})),h.push(t.featureSettings.listen(m=>{m&&bt(c,e,t,i,u,h)}))),{$store:c,submitInplay:async()=>{const m=e.slStreamId.get();if(m){await lo(r,m),c.set(ee.Completed),u.saveOnboardingStatus({organizationId:e.organizationId.get()||"",userId:e.userId.get()||"",eventId:m},ee.Completed);const l=e.getCurrentSessionId({prefix:"onboarding"});i.close(l)}}}},bo=new Set([re.QuestionType.POLL,re.QuestionType.PREDICTION,re.QuestionType.TRIVIA]);class vo extends dn{userSummary;feedList;friends;leaderboardId;leaderboardList;deepLink;onboardingStatus;openedQuestion;currentUserId;openedUser;closeFeature;openFeature;notifications;transport;background;storage;constructor(e,r,i){super(e,r),this.background=new io(i),this.storage=new bn,this.userSummary=new de(Ni(this.background.slStreamId,this.background.userId,i.transport),"gamification:userSummary"),this.feedList=this.background.feedList,this.friends=new de($i(this.background.userId,i.transport),"gamification:friends"),this.currentUserId=this.background.userId,this.openedUser=ne(void 0),this.leaderboardId=new ae(ne(this.settings.getValue("pinnedLeaderboardId")),"pinnedLeaderboardId").getStore(),this.onboardingStatus=wo(this,this.background,i.transport,i.notifications),this.notifications=i.notifications,this.transport=i.transport,this.closeFeature=()=>i.sdk.closeFeature(!0),this.openFeature=()=>i.sdk.openFeature(Te.SdkOverlayType.GAMES),this.openedQuestion=this.background.openedQuestion,this.deepLink=go(this.transport,this.background.slStreamId,i.stores.providerStreamId.getStore(),this.background.userId),this.leaderboardList=ho(this.transport,this.background.slStreamId,this.background.userId,this.friends),this.status.subscribe(s=>{s===it.Ready?this.connect(i.transport):this.disconnect()}),this.userSummary.listen(s=>{this.leaderboardList.$store.lc!==0&&s?.data?.summary&&window.requestAnimationFrame(()=>{this.leaderboardList.invalidate()})}),this.background.activeQuestionId.listen(this.showInApp),this.onboardingStatus.$store.listen(this.checkInteractiveFlag),this.background.moderation.getStore().listen(this.checkInteractiveFlag),this.settings.subscribe(this.checkInteractiveFlag)}get isInteractiveAllowed(){return this.background.interactiveAllowed.get()===qe.ALLOWED}checkInteractiveFlag=()=>{const e=this.onboardingStatus.$store.get(),r=this.background.moderation.getStore().value?.data?.options?.onboardingEnabled,i=this.settings.getValues().inplayGame?.titleCard?.optIn,s=e===ee.Completed,u=!r||s||i!==!0;this.background.interactiveAllowed.set(u?qe.ALLOWED:qe.DISALLOWED)};connect=e=>{this.userSummary.invalidate(),this.leaderboardList.invalidate(),this.feedList.invalidate(),this.friends.invalidate(),this.background.feedSubscription.addListener("feed-subscription-prediction-close",r=>{this.isInteractiveAllowed&&window.requestAnimationFrame(async()=>{const i=r.data?.attributes?.question;if(!i)return;const{status:s,type:u,id:c}=i;if(s===re.QuestionStatus.RESOLVED&&u===re.QuestionType.PREDICTION){const h=this.background.getCurrentSessionId({prefix:`notification-id:${c}`}),p=await yn(c,e),m=p?.answers.find(({correct:w})=>w),l=p?.answers.find(({youVoted:w})=>w);if(!l)return;this.notifications.add({type:Ve.QUESTION_RESOLVED,action:()=>this.openQuestion(c),close:()=>this.closeQuestion(c),autoHideDuration:m?.youVoted?15e3:12e3,id:h,data:{questionType:re.QuestionType.PREDICTION,question:{title:m?.youVoted?`Congratulations! You answered correctly! You won ${m.points} pts!`:`Better luck next time! Correct: ${m?.text}!`,votedAnswer:{title:l?.text,points:l?.points},correctAnswerTitle:m?.text,correct:m?.youVoted,predictionResult:s===re.QuestionStatus.RESOLVED,questionTitle:p?.subject}}}),this.userSummary.invalidate()}})}),this.background.feedSubscription.addListener("feed-subscription-questions-list",()=>{window.requestAnimationFrame(()=>{this.feedList?.invalidate()})})};disconnect=()=>{this.background.feedSubscription.removeListener("feed-subscription-questions-list")};submitAnswer=async(e,r)=>{await co(this.transport,{questionId:e,answerId:r}),this.feedList.invalidate(),this.userSummary.invalidate()};skipQuestion=async e=>{await fo(this.transport,e),this.feedList.invalidate(),this.userSummary.invalidate()};openQuestion=e=>(this.openFeature(),this.notifications.close(this.background.getCurrentSessionId({prefix:"notification",entity:e})),this.background.openQuestion(e));closeQuestion=e=>this.background.closeQuestion(e);openUser=e=>{const r=this.leaderboardList.$store.get().data?.find(i=>i.userId===e);this.openedUser.set(r)};closeUser=()=>{this.openedUser.set(void 0)};showInApp=e=>{const r=this.onboardingStatus.$store.get();if(e&&e.data&&r&&r!==ee.Unset&&e.data.question?.id!==void 0&&e.data.question.notification!==void 0&&e.data.question?.bypassNotifications?.inAppSilence!==re.SilenceSetting.ON&&e.data.question.status===re.QuestionStatus.ACTIVE){if(bo.has(e.data.question.type))this.isInteractiveAllowed&&this.notifications.add({type:Ve.QUESTION,action:()=>e.data?.question&&this.openQuestion(e.data.question.id),close:()=>e.data?.question&&this.closeQuestion(e.data.question.id),autoHideDuration:1e3*60,id:this.background.getCurrentSessionId({prefix:"notification",entity:e.data.question.id}),data:{questionType:e.data.question.type,question:{title:e.data.question.notification.title}}});else if(e.data.question.type===re.QuestionType.FACTOID){const i=e.data.question.options?.options.value,s={heading:e.data.question.notification.title,body:e.data.question.notification.body,imageMode:e.data.question.notification.imageMode,image:i?.image,video:{id:i?.video?.id||"",url:i?.video?.url||"",thumbnailUrl:i?.video?.thumbnailUrl||""},webLink:{label:"",url:""}};this.notifications.add({type:Ve.QUESTION,action:()=>e.data?.question&&this.openQuestion(e.data.question.id),close:()=>e.data?.question&&this.closeQuestion(e.data.question.id),autoHideDuration:1e3*120,id:this.background.getCurrentSessionId({prefix:"notification",entity:e.data.question.id}),data:{questionType:e.data.question.type,insight:s}})}else if(e.data.question.type===re.QuestionType.TWEET){const i=e.data.question.options?.options.value,s={title:e.data.question.notification?.title,body:e.data.question.notification?.body,image:e.data.question.notification?.image,account:i?.tweetMeta?.account||"",accountVerified:!!i?.tweetMeta?.accountVerified,tweet:i?.tweetMeta?.tweet};this.notifications.add({type:Ve.QUESTION,action:()=>e.data?.question&&this.openQuestion(e.data.question.id),close:()=>e.data?.question&&this.closeQuestion(e.data.question.id),autoHideDuration:1e3*120,id:this.background.getCurrentSessionId({prefix:"notification",entity:e.data.question.id}),data:{questionType:e.data.question.type,tweet:s}})}}}}const So={[Te.SdkOverlayType.GAMES]:!0};class Ao extends dn{constructor(e,r){super(e,r)}}const Eo=(t,e,r)=>t.type===Te.SdkOverlayType.GAMES?new vo(t,e,r):new Ao(t,e),Io=(t,e,r)=>{t.features=new Map,t.activeFeature=new ae(ne(Te.SdkOverlayType.UNSET),"activeFeature"),t.sdk.getFeatures=()=>t.features,t.sdk.getFeature=i=>t.features.get(i),t.sdk.getActiveFeature=()=>t.activeFeature.getStore(),t.sdk.openFeature=i=>{t.activeFeature.setValue(i)},t.sdk.closeFeature=(i=!1)=>{const s=t.activeFeature.getValue();t.activeFeature.setValue(Te.SdkOverlayType.UNSET),i&&s&&t.features.delete(s)},t.initFeature=(i,s=Ee.ORGANIZATION)=>{if(i.type in So&&!t.features.has(i.type)){const u=Eo(i,s,t);t.features.set(i.type,u)}},t.updateFeature=(i,s)=>{t.features.get(i.type)?.update(i,s)},t.destroyFeature=i=>{t.features.delete(i.type)},t.reinitializeFeatures=async()=>{const i=await t.stores.organizationSettings.getValue();t.features.clear();for(const s of i?.overlays||[])t.initFeature(s,Ee.ORGANIZATION)},t.stores.providerStreamId.listen(i=>{i||t.reinitializeFeatures()}),t.storeSubscribe=()=>{const i=(u,c)=>{if(c?.overlays&&!(t.contextConfig?.skipOrganizationSettings&&u===Ee.ORGANIZATION))for(const h of c.overlays)h.sdkEnable===!0&&(t.features.has(h.type)?t.updateFeature(h,u):t.initFeature(h,u))},s={organizationSettings:u=>{if(u.data)try{i(Ee.ORGANIZATION,u.data)}catch(c){console.log(c)}},streamSettings:u=>{if(u.data)try{i(Ee.STREAM,u.data)}catch(c){console.log(c)}}};t.store.subscribe(s)},r()};var br={exports:{}},vr={exports:{}};function To(t){var e=new t,r=e;function i(){var u=e;return u.next?e=u.next:(e=new t,r=e),u.next=null,u}function s(u){r.next=u,r=u}return{get:i,release:s}}var _o=To,Oo=_o;function vn(t,e,r){if(typeof t=="function"&&(r=e,e=t,t=null),r<1)throw new Error("fastqueue concurrency must be greater than 1");var i=Oo(Fo),s=null,u=null,c=0,h=null,p={push:x,drain:se,saturated:se,pause:l,paused:!1,concurrency:r,running:m,resume:T,idle:F,length:w,getQueue:E,unshift:N,empty:se,kill:O,killAndDrain:j,error:P};return p;function m(){return c}function l(){p.paused=!0}function w(){for(var C=s,k=0;C;)C=C.next,k++;return k}function E(){for(var C=s,k=[];C;)k.push(C.value),C=C.next;return k}function T(){if(p.paused){p.paused=!1;for(var C=0;C<p.concurrency;C++)c++,I()}}function F(){return c===0&&p.length()===0}function x(C,k){var B=i.get();B.context=t,B.release=I,B.value=C,B.callback=k||se,B.errorHandler=h,c===p.concurrency||p.paused?u?(u.next=B,u=B):(s=B,u=B,p.saturated()):(c++,e.call(t,B.value,B.worked))}function N(C,k){var B=i.get();B.context=t,B.release=I,B.value=C,B.callback=k||se,B.errorHandler=h,c===p.concurrency||p.paused?s?(B.next=s,s=B):(s=B,u=B,p.saturated()):(c++,e.call(t,B.value,B.worked))}function I(C){C&&i.release(C);var k=s;k?p.paused?c--:(u===s&&(u=null),s=k.next,k.next=null,e.call(t,k.value,k.worked),u===null&&p.empty()):--c===0&&p.drain()}function O(){s=null,u=null,p.drain=se}function j(){s=null,u=null,p.drain(),p.drain=se}function P(C){h=C}}function se(){}function Fo(){this.value=null,this.callback=se,this.next=null,this.release=se,this.context=null,this.errorHandler=null;var t=this;this.worked=function(r,i){var s=t.callback,u=t.errorHandler,c=t.value;t.value=null,t.callback=se,t.errorHandler&&u(r,c),s.call(t.context,r,i),t.release(t)}}function Co(t,e,r){typeof t=="function"&&(r=e,e=t,t=null);function i(l,w){e.call(this,l).then(function(E){w(null,E)},w)}var s=vn(t,i,r),u=s.push,c=s.unshift;return s.push=h,s.unshift=p,s.drained=m,s;function h(l){var w=new Promise(function(E,T){u(l,function(F,x){if(F){T(F);return}E(x)})});return w.catch(se),w}function p(l){var w=new Promise(function(E,T){c(l,function(F,x){if(F){T(F);return}E(x)})});return w.catch(se),w}function m(){if(s.idle())return new Promise(function(E){E()});var l=s.drain,w=new Promise(function(E){s.drain=function(){l(),E()}});return w}}vr.exports=vn;vr.exports.promise=Co;var Sn=vr.exports,Sr={exports:{}},ot=typeof Reflect=="object"?Reflect:null,jr=ot&&typeof ot.apply=="function"?ot.apply:function(e,r,i){return Function.prototype.apply.call(e,r,i)},St;ot&&typeof ot.ownKeys=="function"?St=ot.ownKeys:Object.getOwnPropertySymbols?St=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:St=function(e){return Object.getOwnPropertyNames(e)};function xo(t){console&&console.warn&&console.warn(t)}var An=Number.isNaN||function(e){return e!==e};function G(){G.init.call(this)}Sr.exports=G;Sr.exports.once=Po;G.EventEmitter=G;G.prototype._events=void 0;G.prototype._eventsCount=0;G.prototype._maxListeners=void 0;var Mr=10;function Nt(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(G,"defaultMaxListeners",{enumerable:!0,get:function(){return Mr},set:function(t){if(typeof t!="number"||t<0||An(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");Mr=t}});G.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};G.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||An(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function En(t){return t._maxListeners===void 0?G.defaultMaxListeners:t._maxListeners}G.prototype.getMaxListeners=function(){return En(this)};G.prototype.emit=function(e){for(var r=[],i=1;i<arguments.length;i++)r.push(arguments[i]);var s=e==="error",u=this._events;if(u!==void 0)s=s&&u.error===void 0;else if(!s)return!1;if(s){var c;if(r.length>0&&(c=r[0]),c instanceof Error)throw c;var h=new Error("Unhandled error."+(c?" ("+c.message+")":""));throw h.context=c,h}var p=u[e];if(p===void 0)return!1;if(typeof p=="function")jr(p,this,r);else for(var m=p.length,l=Fn(p,m),i=0;i<m;++i)jr(l[i],this,r);return!0};function In(t,e,r,i){var s,u,c;if(Nt(r),u=t._events,u===void 0?(u=t._events=Object.create(null),t._eventsCount=0):(u.newListener!==void 0&&(t.emit("newListener",e,r.listener?r.listener:r),u=t._events),c=u[e]),c===void 0)c=u[e]=r,++t._eventsCount;else if(typeof c=="function"?c=u[e]=i?[r,c]:[c,r]:i?c.unshift(r):c.push(r),s=En(t),s>0&&c.length>s&&!c.warned){c.warned=!0;var h=new Error("Possible EventEmitter memory leak detected. "+c.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");h.name="MaxListenersExceededWarning",h.emitter=t,h.type=e,h.count=c.length,xo(h)}return t}G.prototype.addListener=function(e,r){return In(this,e,r,!1)};G.prototype.on=G.prototype.addListener;G.prototype.prependListener=function(e,r){return In(this,e,r,!0)};function ko(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function Tn(t,e,r){var i={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},s=ko.bind(i);return s.listener=r,i.wrapFn=s,s}G.prototype.once=function(e,r){return Nt(r),this.on(e,Tn(this,e,r)),this};G.prototype.prependOnceListener=function(e,r){return Nt(r),this.prependListener(e,Tn(this,e,r)),this};G.prototype.removeListener=function(e,r){var i,s,u,c,h;if(Nt(r),s=this._events,s===void 0)return this;if(i=s[e],i===void 0)return this;if(i===r||i.listener===r)--this._eventsCount===0?this._events=Object.create(null):(delete s[e],s.removeListener&&this.emit("removeListener",e,i.listener||r));else if(typeof i!="function"){for(u=-1,c=i.length-1;c>=0;c--)if(i[c]===r||i[c].listener===r){h=i[c].listener,u=c;break}if(u<0)return this;u===0?i.shift():Bo(i,u),i.length===1&&(s[e]=i[0]),s.removeListener!==void 0&&this.emit("removeListener",e,h||r)}return this};G.prototype.off=G.prototype.removeListener;G.prototype.removeAllListeners=function(e){var r,i,s;if(i=this._events,i===void 0)return this;if(i.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):i[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete i[e]),this;if(arguments.length===0){var u=Object.keys(i),c;for(s=0;s<u.length;++s)c=u[s],c!=="removeListener"&&this.removeAllListeners(c);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(r=i[e],typeof r=="function")this.removeListener(e,r);else if(r!==void 0)for(s=r.length-1;s>=0;s--)this.removeListener(e,r[s]);return this};function _n(t,e,r){var i=t._events;if(i===void 0)return[];var s=i[e];return s===void 0?[]:typeof s=="function"?r?[s.listener||s]:[s]:r?Lo(s):Fn(s,s.length)}G.prototype.listeners=function(e){return _n(this,e,!0)};G.prototype.rawListeners=function(e){return _n(this,e,!1)};G.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):On.call(t,e)};G.prototype.listenerCount=On;function On(t){var e=this._events;if(e!==void 0){var r=e[t];if(typeof r=="function")return 1;if(r!==void 0)return r.length}return 0}G.prototype.eventNames=function(){return this._eventsCount>0?St(this._events):[]};function Fn(t,e){for(var r=new Array(e),i=0;i<e;++i)r[i]=t[i];return r}function Bo(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function Lo(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}function Po(t,e){return new Promise(function(r,i){function s(c){t.removeListener(e,u),i(c)}function u(){typeof t.removeListener=="function"&&t.removeListener("error",s),r([].slice.call(arguments))}Cn(t,e,u,{once:!0}),e!=="error"&&Ro(t,s,{once:!0})})}function Ro(t,e,r){typeof t.on=="function"&&Cn(t,"error",e,r)}function Cn(t,e,r,i){if(typeof t.on=="function")i.once?t.once(e,r):t.on(e,r);else if(typeof t.addEventListener=="function")t.addEventListener(e,function s(u){i.once&&t.removeEventListener(e,s),r(u)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t)}var xn=Sr.exports,Dt={},kn={},Bn=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var e={},r=Symbol("test"),i=Object(r);if(typeof r=="string"||Object.prototype.toString.call(r)!=="[object Symbol]"||Object.prototype.toString.call(i)!=="[object Symbol]")return!1;var s=42;e[r]=s;for(r in e)return!1;if(typeof Object.keys=="function"&&Object.keys(e).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(e).length!==0)return!1;var u=Object.getOwnPropertySymbols(e);if(u.length!==1||u[0]!==r||!Object.prototype.propertyIsEnumerable.call(e,r))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var c=Object.getOwnPropertyDescriptor(e,r);if(c.value!==s||c.enumerable!==!0)return!1}return!0},No=Bn,Ar=function(){return No()&&!!Symbol.toStringTag},Vr=typeof Symbol<"u"&&Symbol,Do=Bn,$o=function(){return typeof Vr!="function"||typeof Symbol!="function"||typeof Vr("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:Do()},qr={foo:{}},Uo=Object,jo=function(){return{__proto__:qr}.foo===qr.foo&&!({__proto__:null}instanceof Uo)},Mo="Function.prototype.bind called on incompatible ",Vo=Object.prototype.toString,qo=Math.max,Qo="[object Function]",Qr=function(e,r){for(var i=[],s=0;s<e.length;s+=1)i[s]=e[s];for(var u=0;u<r.length;u+=1)i[u+e.length]=r[u];return i},Go=function(e,r){for(var i=[],s=r||0,u=0;s<e.length;s+=1,u+=1)i[u]=e[s];return i},zo=function(t,e){for(var r="",i=0;i<t.length;i+=1)r+=t[i],i+1<t.length&&(r+=e);return r},Ko=function(e){var r=this;if(typeof r!="function"||Vo.apply(r)!==Qo)throw new TypeError(Mo+r);for(var i=Go(arguments,1),s,u=function(){if(this instanceof s){var l=r.apply(this,Qr(i,arguments));return Object(l)===l?l:this}return r.apply(e,Qr(i,arguments))},c=qo(0,r.length-i.length),h=[],p=0;p<c;p++)h[p]="$"+p;if(s=Function("binder","return function ("+zo(h,",")+"){ return binder.apply(this,arguments); }")(u),r.prototype){var m=function(){};m.prototype=r.prototype,s.prototype=new m,m.prototype=null}return s},Wo=Ko,Er=Function.prototype.bind||Wo,Ho=Function.prototype.call,Jo=Object.prototype.hasOwnProperty,Yo=Er,Xo=Yo.call(Ho,Jo),U,at=SyntaxError,Ln=Function,st=TypeError,Vt=function(t){try{return Ln('"use strict"; return ('+t+").constructor;")()}catch{}},Qe=Object.getOwnPropertyDescriptor;if(Qe)try{Qe({},"")}catch{Qe=null}var qt=function(){throw new st},Zo=Qe?function(){try{return arguments.callee,qt}catch{try{return Qe(arguments,"callee").get}catch{return qt}}}():qt,He=$o(),es=jo(),X=Object.getPrototypeOf||(es?function(t){return t.__proto__}:null),Ye={},ts=typeof Uint8Array>"u"||!X?U:X(Uint8Array),Ge={"%AggregateError%":typeof AggregateError>"u"?U:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?U:ArrayBuffer,"%ArrayIteratorPrototype%":He&&X?X([][Symbol.iterator]()):U,"%AsyncFromSyncIteratorPrototype%":U,"%AsyncFunction%":Ye,"%AsyncGenerator%":Ye,"%AsyncGeneratorFunction%":Ye,"%AsyncIteratorPrototype%":Ye,"%Atomics%":typeof Atomics>"u"?U:Atomics,"%BigInt%":typeof BigInt>"u"?U:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?U:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?U:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?U:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Error,"%eval%":eval,"%EvalError%":EvalError,"%Float32Array%":typeof Float32Array>"u"?U:Float32Array,"%Float64Array%":typeof Float64Array>"u"?U:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?U:FinalizationRegistry,"%Function%":Ln,"%GeneratorFunction%":Ye,"%Int8Array%":typeof Int8Array>"u"?U:Int8Array,"%Int16Array%":typeof Int16Array>"u"?U:Int16Array,"%Int32Array%":typeof Int32Array>"u"?U:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":He&&X?X(X([][Symbol.iterator]())):U,"%JSON%":typeof JSON=="object"?JSON:U,"%Map%":typeof Map>"u"?U:Map,"%MapIteratorPrototype%":typeof Map>"u"||!He||!X?U:X(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?U:Promise,"%Proxy%":typeof Proxy>"u"?U:Proxy,"%RangeError%":RangeError,"%ReferenceError%":ReferenceError,"%Reflect%":typeof Reflect>"u"?U:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?U:Set,"%SetIteratorPrototype%":typeof Set>"u"||!He||!X?U:X(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?U:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":He&&X?X(""[Symbol.iterator]()):U,"%Symbol%":He?Symbol:U,"%SyntaxError%":at,"%ThrowTypeError%":Zo,"%TypedArray%":ts,"%TypeError%":st,"%Uint8Array%":typeof Uint8Array>"u"?U:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?U:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?U:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?U:Uint32Array,"%URIError%":URIError,"%WeakMap%":typeof WeakMap>"u"?U:WeakMap,"%WeakRef%":typeof WeakRef>"u"?U:WeakRef,"%WeakSet%":typeof WeakSet>"u"?U:WeakSet};if(X)try{null.error}catch(t){var rs=X(X(t));Ge["%Error.prototype%"]=rs}var ns=function t(e){var r;if(e==="%AsyncFunction%")r=Vt("async function () {}");else if(e==="%GeneratorFunction%")r=Vt("function* () {}");else if(e==="%AsyncGeneratorFunction%")r=Vt("async function* () {}");else if(e==="%AsyncGenerator%"){var i=t("%AsyncGeneratorFunction%");i&&(r=i.prototype)}else if(e==="%AsyncIteratorPrototype%"){var s=t("%AsyncGenerator%");s&&X&&(r=X(s.prototype))}return Ge[e]=r,r},Gr={"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},mt=Er,Ot=Xo,is=mt.call(Function.call,Array.prototype.concat),os=mt.call(Function.apply,Array.prototype.splice),zr=mt.call(Function.call,String.prototype.replace),Ft=mt.call(Function.call,String.prototype.slice),ss=mt.call(Function.call,RegExp.prototype.exec),as=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,us=/\\(\\)?/g,cs=function(e){var r=Ft(e,0,1),i=Ft(e,-1);if(r==="%"&&i!=="%")throw new at("invalid intrinsic syntax, expected closing `%`");if(i==="%"&&r!=="%")throw new at("invalid intrinsic syntax, expected opening `%`");var s=[];return zr(e,as,function(u,c,h,p){s[s.length]=h?zr(p,us,"$1"):c||u}),s},ls=function(e,r){var i=e,s;if(Ot(Gr,i)&&(s=Gr[i],i="%"+s[0]+"%"),Ot(Ge,i)){var u=Ge[i];if(u===Ye&&(u=ns(i)),typeof u>"u"&&!r)throw new st("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:s,name:i,value:u}}throw new at("intrinsic "+e+" does not exist!")},ct=function(e,r){if(typeof e!="string"||e.length===0)throw new st("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof r!="boolean")throw new st('"allowMissing" argument must be a boolean');if(ss(/^%?[^%]*%?$/,e)===null)throw new at("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var i=cs(e),s=i.length>0?i[0]:"",u=ls("%"+s+"%",r),c=u.name,h=u.value,p=!1,m=u.alias;m&&(s=m[0],os(i,is([0,1],m)));for(var l=1,w=!0;l<i.length;l+=1){var E=i[l],T=Ft(E,0,1),F=Ft(E,-1);if((T==='"'||T==="'"||T==="`"||F==='"'||F==="'"||F==="`")&&T!==F)throw new at("property names with quotes must have matching quotes");if((E==="constructor"||!w)&&(p=!0),s+="."+E,c="%"+s+"%",Ot(Ge,c))h=Ge[c];else if(h!=null){if(!(E in h)){if(!r)throw new st("base intrinsic for "+e+" exists, but the property is not available.");return}if(Qe&&l+1>=i.length){var x=Qe(h,E);w=!!x,w&&"get"in x&&!("originalValue"in x.get)?h=x.get:h=h[E]}else w=Ot(h,E),h=h[E];w&&!p&&(Ge[c]=h)}}return h},Pn={exports:{}},fs=ct,ir=fs("%Object.defineProperty%",!0),or=function(){if(ir)try{return ir({},"a",{value:1}),!0}catch{return!1}return!1};or.hasArrayLengthDefineBug=function(){if(!or())return null;try{return ir([],"length",{value:1}).length!==1}catch{return!0}};var Rn=or,ds=ct,At=ds("%Object.getOwnPropertyDescriptor%",!0);if(At)try{At([],"length")}catch{At=null}var Ir=At,hs=Rn(),Tr=ct,pt=hs&&Tr("%Object.defineProperty%",!0);if(pt)try{pt({},"a",{value:1})}catch{pt=!1}var ps=Tr("%SyntaxError%"),Je=Tr("%TypeError%"),Kr=Ir,ys=function(e,r,i){if(!e||typeof e!="object"&&typeof e!="function")throw new Je("`obj` must be an object or a function`");if(typeof r!="string"&&typeof r!="symbol")throw new Je("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new Je("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new Je("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new Je("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new Je("`loose`, if provided, must be a boolean");var s=arguments.length>3?arguments[3]:null,u=arguments.length>4?arguments[4]:null,c=arguments.length>5?arguments[5]:null,h=arguments.length>6?arguments[6]:!1,p=!!Kr&&Kr(e,r);if(pt)pt(e,r,{configurable:c===null&&p?p.configurable:!c,enumerable:s===null&&p?p.enumerable:!s,value:i,writable:u===null&&p?p.writable:!u});else if(h||!s&&!u&&!c)e[r]=i;else throw new ps("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},Nn=ct,Wr=ys,gs=Rn(),Hr=Ir,Jr=Nn("%TypeError%"),ms=Nn("%Math.floor%"),ws=function(e,r){if(typeof e!="function")throw new Jr("`fn` is not a function");if(typeof r!="number"||r<0||r>4294967295||ms(r)!==r)throw new Jr("`length` must be a positive 32-bit integer");var i=arguments.length>2&&!!arguments[2],s=!0,u=!0;if("length"in e&&Hr){var c=Hr(e,"length");c&&!c.configurable&&(s=!1),c&&!c.writable&&(u=!1)}return(s||u||!i)&&(gs?Wr(e,"length",r,!0,!0):Wr(e,"length",r)),e};(function(t){var e=Er,r=ct,i=ws,s=r("%TypeError%"),u=r("%Function.prototype.apply%"),c=r("%Function.prototype.call%"),h=r("%Reflect.apply%",!0)||e.call(c,u),p=r("%Object.defineProperty%",!0),m=r("%Math.max%");if(p)try{p({},"a",{value:1})}catch{p=null}t.exports=function(E){if(typeof E!="function")throw new s("a function is required");var T=h(e,c,arguments);return i(T,1+m(0,E.length-(arguments.length-1)),!0)};var l=function(){return h(e,u,arguments)};p?p(t.exports,"apply",{value:l}):t.exports.apply=l})(Pn);var Dn=Pn.exports,$n=ct,Un=Dn,bs=Un($n("String.prototype.indexOf")),jn=function(e,r){var i=$n(e,!!r);return typeof i=="function"&&bs(e,".prototype.")>-1?Un(i):i},vs=Ar(),Ss=jn,sr=Ss("Object.prototype.toString"),$t=function(e){return vs&&e&&typeof e=="object"&&Symbol.toStringTag in e?!1:sr(e)==="[object Arguments]"},Mn=function(e){return $t(e)?!0:e!==null&&typeof e=="object"&&typeof e.length=="number"&&e.length>=0&&sr(e)!=="[object Array]"&&sr(e.callee)==="[object Function]"},As=function(){return $t(arguments)}();$t.isLegacyArguments=Mn;var Es=As?$t:Mn,Is=Object.prototype.toString,Ts=Function.prototype.toString,_s=/^\s*(?:function)?\*/,Vn=Ar(),Qt=Object.getPrototypeOf,Os=function(){if(!Vn)return!1;try{return Function("return function*() {}")()}catch{}},Gt,Fs=function(e){if(typeof e!="function")return!1;if(_s.test(Ts.call(e)))return!0;if(!Vn){var r=Is.call(e);return r==="[object GeneratorFunction]"}if(!Qt)return!1;if(typeof Gt>"u"){var i=Os();Gt=i?Qt(i):!1}return Qt(e)===Gt},qn=Function.prototype.toString,tt=typeof Reflect=="object"&&Reflect!==null&&Reflect.apply,ar,Et;if(typeof tt=="function"&&typeof Object.defineProperty=="function")try{ar=Object.defineProperty({},"length",{get:function(){throw Et}}),Et={},tt(function(){throw 42},null,ar)}catch(t){t!==Et&&(tt=null)}else tt=null;var Cs=/^\s*class\b/,ur=function(e){try{var r=qn.call(e);return Cs.test(r)}catch{return!1}},zt=function(e){try{return ur(e)?!1:(qn.call(e),!0)}catch{return!1}},It=Object.prototype.toString,xs="[object Object]",ks="[object Function]",Bs="[object GeneratorFunction]",Ls="[object HTMLAllCollection]",Ps="[object HTML document.all class]",Rs="[object HTMLCollection]",Ns=typeof Symbol=="function"&&!!Symbol.toStringTag,Ds=!(0 in[,]),cr=function(){return!1};if(typeof document=="object"){var $s=document.all;It.call($s)===It.call(document.all)&&(cr=function(e){if((Ds||!e)&&(typeof e>"u"||typeof e=="object"))try{var r=It.call(e);return(r===Ls||r===Ps||r===Rs||r===xs)&&e("")==null}catch{}return!1})}var Us=tt?function(e){if(cr(e))return!0;if(!e||typeof e!="function"&&typeof e!="object")return!1;try{tt(e,null,ar)}catch(r){if(r!==Et)return!1}return!ur(e)&&zt(e)}:function(e){if(cr(e))return!0;if(!e||typeof e!="function"&&typeof e!="object")return!1;if(Ns)return zt(e);if(ur(e))return!1;var r=It.call(e);return r!==ks&&r!==Bs&&!/^\[object HTML/.test(r)?!1:zt(e)},js=Us,Ms=Object.prototype.toString,Qn=Object.prototype.hasOwnProperty,Vs=function(e,r,i){for(var s=0,u=e.length;s<u;s++)Qn.call(e,s)&&(i==null?r(e[s],s,e):r.call(i,e[s],s,e))},qs=function(e,r,i){for(var s=0,u=e.length;s<u;s++)i==null?r(e.charAt(s),s,e):r.call(i,e.charAt(s),s,e)},Qs=function(e,r,i){for(var s in e)Qn.call(e,s)&&(i==null?r(e[s],s,e):r.call(i,e[s],s,e))},Gs=function(e,r,i){if(!js(r))throw new TypeError("iterator must be a function");var s;arguments.length>=3&&(s=i),Ms.call(e)==="[object Array]"?Vs(e,r,s):typeof e=="string"?qs(e,r,s):Qs(e,r,s)},zs=Gs,Kt=["BigInt64Array","BigUint64Array","Float32Array","Float64Array","Int16Array","Int32Array","Int8Array","Uint16Array","Uint32Array","Uint8Array","Uint8ClampedArray"],Ks=typeof globalThis>"u"?wn:globalThis,Ws=function(){for(var e=[],r=0;r<Kt.length;r++)typeof Ks[Kt[r]]=="function"&&(e[e.length]=Kt[r]);return e},Ct=zs,Hs=Ws,Yr=Dn,_r=jn,Tt=Ir,Js=_r("Object.prototype.toString"),Gn=Ar(),Xr=typeof globalThis>"u"?wn:globalThis,lr=Hs(),Or=_r("String.prototype.slice"),Wt=Object.getPrototypeOf,Ys=_r("Array.prototype.indexOf",!0)||function(e,r){for(var i=0;i<e.length;i+=1)if(e[i]===r)return i;return-1},xt={__proto__:null};Gn&&Tt&&Wt?Ct(lr,function(t){var e=new Xr[t];if(Symbol.toStringTag in e){var r=Wt(e),i=Tt(r,Symbol.toStringTag);if(!i){var s=Wt(r);i=Tt(s,Symbol.toStringTag)}xt["$"+t]=Yr(i.get)}}):Ct(lr,function(t){var e=new Xr[t],r=e.slice||e.set;r&&(xt["$"+t]=Yr(r))});var Xs=function(e){var r=!1;return Ct(xt,function(i,s){if(!r)try{"$"+i(e)===s&&(r=Or(s,1))}catch{}}),r},Zs=function(e){var r=!1;return Ct(xt,function(i,s){if(!r)try{i(e),r=Or(s,1)}catch{}}),r},zn=function(e){if(!e||typeof e!="object")return!1;if(!Gn){var r=Or(Js(e),8,-1);return Ys(lr,r)>-1?r:r!=="Object"?!1:Zs(e)}return Tt?Xs(e):null},ea=zn,ta=function(e){return!!ea(e)};(function(t){var e=Es,r=Fs,i=zn,s=ta;function u(A){return A.call.bind(A)}var c=typeof BigInt<"u",h=typeof Symbol<"u",p=u(Object.prototype.toString),m=u(Number.prototype.valueOf),l=u(String.prototype.valueOf),w=u(Boolean.prototype.valueOf);if(c)var E=u(BigInt.prototype.valueOf);if(h)var T=u(Symbol.prototype.valueOf);function F(A,dt){if(typeof A!="object")return!1;try{return dt(A),!0}catch{return!1}}t.isArgumentsObject=e,t.isGeneratorFunction=r,t.isTypedArray=s;function x(A){return typeof Promise<"u"&&A instanceof Promise||A!==null&&typeof A=="object"&&typeof A.then=="function"&&typeof A.catch=="function"}t.isPromise=x;function N(A){return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?ArrayBuffer.isView(A):s(A)||v(A)}t.isArrayBufferView=N;function I(A){return i(A)==="Uint8Array"}t.isUint8Array=I;function O(A){return i(A)==="Uint8ClampedArray"}t.isUint8ClampedArray=O;function j(A){return i(A)==="Uint16Array"}t.isUint16Array=j;function P(A){return i(A)==="Uint32Array"}t.isUint32Array=P;function C(A){return i(A)==="Int8Array"}t.isInt8Array=C;function k(A){return i(A)==="Int16Array"}t.isInt16Array=k;function B(A){return i(A)==="Int32Array"}t.isInt32Array=B;function q(A){return i(A)==="Float32Array"}t.isFloat32Array=q;function ie(A){return i(A)==="Float64Array"}t.isFloat64Array=ie;function we(A){return i(A)==="BigInt64Array"}t.isBigInt64Array=we;function be(A){return i(A)==="BigUint64Array"}t.isBigUint64Array=be;function ue(A){return p(A)==="[object Map]"}ue.working=typeof Map<"u"&&ue(new Map);function ft(A){return typeof Map>"u"?!1:ue.working?ue(A):A instanceof Map}t.isMap=ft;function he(A){return p(A)==="[object Set]"}he.working=typeof Set<"u"&&he(new Set);function Re(A){return typeof Set>"u"?!1:he.working?he(A):A instanceof Set}t.isSet=Re;function ke(A){return p(A)==="[object WeakMap]"}ke.working=typeof WeakMap<"u"&&ke(new WeakMap);function ze(A){return typeof WeakMap>"u"?!1:ke.working?ke(A):A instanceof WeakMap}t.isWeakMap=ze;function ve(A){return p(A)==="[object WeakSet]"}ve.working=typeof WeakSet<"u"&&ve(new WeakSet);function ce(A){return ve(A)}t.isWeakSet=ce;function Be(A){return p(A)==="[object ArrayBuffer]"}Be.working=typeof ArrayBuffer<"u"&&Be(new ArrayBuffer);function Ke(A){return typeof ArrayBuffer>"u"?!1:Be.working?Be(A):A instanceof ArrayBuffer}t.isArrayBuffer=Ke;function g(A){return p(A)==="[object DataView]"}g.working=typeof ArrayBuffer<"u"&&typeof DataView<"u"&&g(new DataView(new ArrayBuffer(1),0,1));function v(A){return typeof DataView>"u"?!1:g.working?g(A):A instanceof DataView}t.isDataView=v;var S=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:void 0;function _(A){return p(A)==="[object SharedArrayBuffer]"}function M(A){return typeof S>"u"?!1:(typeof _.working>"u"&&(_.working=_(new S)),_.working?_(A):A instanceof S)}t.isSharedArrayBuffer=M;function V(A){return p(A)==="[object AsyncFunction]"}t.isAsyncFunction=V;function R(A){return p(A)==="[object Map Iterator]"}t.isMapIterator=R;function $(A){return p(A)==="[object Set Iterator]"}t.isSetIterator=$;function Q(A){return p(A)==="[object Generator]"}t.isGeneratorObject=Q;function J(A){return p(A)==="[object WebAssembly.Module]"}t.isWebAssemblyCompiledModule=J;function le(A){return F(A,m)}t.isNumberObject=le;function Ne(A){return F(A,l)}t.isStringObject=Ne;function Le(A){return F(A,w)}t.isBooleanObject=Le;function De(A){return c&&F(A,E)}t.isBigIntObject=De;function Se(A){return h&&F(A,T)}t.isSymbolObject=Se;function $e(A){return le(A)||Ne(A)||Le(A)||De(A)||Se(A)}t.isBoxedPrimitive=$e;function Ut(A){return typeof Uint8Array<"u"&&(Ke(A)||M(A))}t.isAnyArrayBuffer=Ut,["isProxy","isExternal","isModuleNamespaceObject"].forEach(function(A){Object.defineProperty(t,A,{enumerable:!1,value:function(){throw new Error(A+" is not supported in userland")}})})})(kn);var ra=function(e){return e&&typeof e=="object"&&typeof e.copy=="function"&&typeof e.fill=="function"&&typeof e.readUInt8=="function"},fr={exports:{}};typeof Object.create=="function"?fr.exports=function(e,r){r&&(e.super_=r,e.prototype=Object.create(r.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:fr.exports=function(e,r){if(r){e.super_=r;var i=function(){};i.prototype=r.prototype,e.prototype=new i,e.prototype.constructor=e}};var na=fr.exports;(function(t){var e=Object.getOwnPropertyDescriptors||function(v){for(var S=Object.keys(v),_={},M=0;M<S.length;M++)_[S[M]]=Object.getOwnPropertyDescriptor(v,S[M]);return _},r=/%[sdj%]/g;t.format=function(g){if(!C(g)){for(var v=[],S=0;S<arguments.length;S++)v.push(c(arguments[S]));return v.join(" ")}for(var S=1,_=arguments,M=_.length,V=String(g).replace(r,function($){if($==="%%")return"%";if(S>=M)return $;switch($){case"%s":return String(_[S++]);case"%d":return Number(_[S++]);case"%j":try{return JSON.stringify(_[S++])}catch{return"[Circular]"}default:return $}}),R=_[S];S<M;R=_[++S])O(R)||!ie(R)?V+=" "+R:V+=" "+c(R);return V},t.deprecate=function(g,v){if(typeof L<"u"&&L.noDeprecation===!0)return g;if(typeof L>"u")return function(){return t.deprecate(g,v).apply(this,arguments)};var S=!1;function _(){if(!S){if(L.throwDeprecation)throw new Error(v);L.traceDeprecation?console.trace(v):console.error(v),S=!0}return g.apply(this,arguments)}return _};var i={},s=/^$/;if(L.env.NODE_DEBUG){var u=L.env.NODE_DEBUG;u=u.replace(/[|\\{}()[\]^$+?.]/g,"\\$&").replace(/\*/g,".*").replace(/,/g,"$|^").toUpperCase(),s=new RegExp("^"+u+"$","i")}t.debuglog=function(g){if(g=g.toUpperCase(),!i[g])if(s.test(g)){var v=L.pid;i[g]=function(){var S=t.format.apply(t,arguments);console.error("%s %d: %s",g,v,S)}}else i[g]=function(){};return i[g]};function c(g,v){var S={seen:[],stylize:p};return arguments.length>=3&&(S.depth=arguments[2]),arguments.length>=4&&(S.colors=arguments[3]),I(v)?S.showHidden=v:v&&t._extend(S,v),B(S.showHidden)&&(S.showHidden=!1),B(S.depth)&&(S.depth=2),B(S.colors)&&(S.colors=!1),B(S.customInspect)&&(S.customInspect=!0),S.colors&&(S.stylize=h),l(S,g,S.depth)}t.inspect=c,c.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},c.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"};function h(g,v){var S=c.styles[v];return S?"\x1B["+c.colors[S][0]+"m"+g+"\x1B["+c.colors[S][1]+"m":g}function p(g,v){return g}function m(g){var v={};return g.forEach(function(S,_){v[S]=!0}),v}function l(g,v,S){if(g.customInspect&&v&&ue(v.inspect)&&v.inspect!==t.inspect&&!(v.constructor&&v.constructor.prototype===v)){var _=v.inspect(S,g);return C(_)||(_=l(g,_,S)),_}var M=w(g,v);if(M)return M;var V=Object.keys(v),R=m(V);if(g.showHidden&&(V=Object.getOwnPropertyNames(v)),be(v)&&(V.indexOf("message")>=0||V.indexOf("description")>=0))return E(v);if(V.length===0){if(ue(v)){var $=v.name?": "+v.name:"";return g.stylize("[Function"+$+"]","special")}if(q(v))return g.stylize(RegExp.prototype.toString.call(v),"regexp");if(we(v))return g.stylize(Date.prototype.toString.call(v),"date");if(be(v))return E(v)}var Q="",J=!1,le=["{","}"];if(N(v)&&(J=!0,le=["[","]"]),ue(v)){var Ne=v.name?": "+v.name:"";Q=" [Function"+Ne+"]"}if(q(v)&&(Q=" "+RegExp.prototype.toString.call(v)),we(v)&&(Q=" "+Date.prototype.toUTCString.call(v)),be(v)&&(Q=" "+E(v)),V.length===0&&(!J||v.length==0))return le[0]+Q+le[1];if(S<0)return q(v)?g.stylize(RegExp.prototype.toString.call(v),"regexp"):g.stylize("[Object]","special");g.seen.push(v);var Le;return J?Le=T(g,v,S,R,V):Le=V.map(function(De){return F(g,v,S,R,De,J)}),g.seen.pop(),x(Le,Q,le)}function w(g,v){if(B(v))return g.stylize("undefined","undefined");if(C(v)){var S="'"+JSON.stringify(v).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return g.stylize(S,"string")}if(P(v))return g.stylize(""+v,"number");if(I(v))return g.stylize(""+v,"boolean");if(O(v))return g.stylize("null","null")}function E(g){return"["+Error.prototype.toString.call(g)+"]"}function T(g,v,S,_,M){for(var V=[],R=0,$=v.length;R<$;++R)ve(v,String(R))?V.push(F(g,v,S,_,String(R),!0)):V.push("");return M.forEach(function(Q){Q.match(/^\d+$/)||V.push(F(g,v,S,_,Q,!0))}),V}function F(g,v,S,_,M,V){var R,$,Q;if(Q=Object.getOwnPropertyDescriptor(v,M)||{value:v[M]},Q.get?Q.set?$=g.stylize("[Getter/Setter]","special"):$=g.stylize("[Getter]","special"):Q.set&&($=g.stylize("[Setter]","special")),ve(_,M)||(R="["+M+"]"),$||(g.seen.indexOf(Q.value)<0?(O(S)?$=l(g,Q.value,null):$=l(g,Q.value,S-1),$.indexOf(`
|
|
8
8
|
`)>-1&&(V?$=$.split(`
|
|
9
9
|
`).map(function(J){return" "+J}).join(`
|
|
10
10
|
`).slice(2):$=`
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
`))):$=g.stylize("[Circular]","special")),B(R)){if(V&&M.match(/^\d+$/))return $;R=JSON.stringify(""+M),R.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(R=R.slice(1,-1),R=g.stylize(R,"name")):(R=R.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),R=g.stylize(R,"string"))}return R+": "+$}function x(g,v,S){var _=g.reduce(function(M,V){return V.indexOf(`
|
|
14
14
|
`)>=0,M+V.replace(/\u001b\[\d\d?m/g,"").length+1},0);return _>60?S[0]+(v===""?"":v+`
|
|
15
15
|
`)+" "+g.join(`,
|
|
16
|
-
`)+" "+S[1]:S[0]+v+" "+g.join(", ")+" "+S[1]}t.types=
|
|
16
|
+
`)+" "+S[1]:S[0]+v+" "+g.join(", ")+" "+S[1]}t.types=kn;function N(g){return Array.isArray(g)}t.isArray=N;function I(g){return typeof g=="boolean"}t.isBoolean=I;function O(g){return g===null}t.isNull=O;function j(g){return g==null}t.isNullOrUndefined=j;function P(g){return typeof g=="number"}t.isNumber=P;function C(g){return typeof g=="string"}t.isString=C;function k(g){return typeof g=="symbol"}t.isSymbol=k;function B(g){return g===void 0}t.isUndefined=B;function q(g){return ie(g)&&he(g)==="[object RegExp]"}t.isRegExp=q,t.types.isRegExp=q;function ie(g){return typeof g=="object"&&g!==null}t.isObject=ie;function we(g){return ie(g)&&he(g)==="[object Date]"}t.isDate=we,t.types.isDate=we;function be(g){return ie(g)&&(he(g)==="[object Error]"||g instanceof Error)}t.isError=be,t.types.isNativeError=be;function ue(g){return typeof g=="function"}t.isFunction=ue;function ft(g){return g===null||typeof g=="boolean"||typeof g=="number"||typeof g=="string"||typeof g=="symbol"||typeof g>"u"}t.isPrimitive=ft,t.isBuffer=ra;function he(g){return Object.prototype.toString.call(g)}function Re(g){return g<10?"0"+g.toString(10):g.toString(10)}var ke=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function ze(){var g=new Date,v=[Re(g.getHours()),Re(g.getMinutes()),Re(g.getSeconds())].join(":");return[g.getDate(),ke[g.getMonth()],v].join(" ")}t.log=function(){console.log("%s - %s",ze(),t.format.apply(t,arguments))},t.inherits=na,t._extend=function(g,v){if(!v||!ie(v))return g;for(var S=Object.keys(v),_=S.length;_--;)g[S[_]]=v[S[_]];return g};function ve(g,v){return Object.prototype.hasOwnProperty.call(g,v)}var ce=typeof Symbol<"u"?Symbol("util.promisify.custom"):void 0;t.promisify=function(v){if(typeof v!="function")throw new TypeError('The "original" argument must be of type Function');if(ce&&v[ce]){var S=v[ce];if(typeof S!="function")throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(S,ce,{value:S,enumerable:!1,writable:!1,configurable:!0}),S}function S(){for(var _,M,V=new Promise(function(Q,J){_=Q,M=J}),R=[],$=0;$<arguments.length;$++)R.push(arguments[$]);R.push(function(Q,J){Q?M(Q):_(J)});try{v.apply(this,R)}catch(Q){M(Q)}return V}return Object.setPrototypeOf(S,Object.getPrototypeOf(v)),ce&&Object.defineProperty(S,ce,{value:S,enumerable:!1,writable:!1,configurable:!0}),Object.defineProperties(S,e(v))},t.promisify.custom=ce;function Be(g,v){if(!g){var S=new Error("Promise was rejected with a falsy value");S.reason=g,g=S}return v(g)}function Ke(g){if(typeof g!="function")throw new TypeError('The "original" argument must be of type Function');function v(){for(var S=[],_=0;_<arguments.length;_++)S.push(arguments[_]);var M=S.pop();if(typeof M!="function")throw new TypeError("The last argument must be of type Function");var V=this,R=function(){return M.apply(V,arguments)};g.apply(this,S).then(function($){L.nextTick(R.bind(null,null,$))},function($){L.nextTick(Be.bind(null,$,R))})}return Object.setPrototypeOf(v,Object.getPrototypeOf(g)),Object.defineProperties(v,e(g)),v}t.callbackify=Ke})(Dt);const{inherits:ia,format:Ht}=Dt;function Ue(t,e,r=Error){if(!t)throw new Error("Avvio error code must not be empty");if(!e)throw new Error("Avvio base error message must not be empty");function i(s,u,c){if(!new.target)return new i(s,u,c);Error.captureStackTrace(this,i),this.code=t,this.message=e,this.name="AvvioError",s&&u&&c?this.message=Ht(e,s,u,c):s&&u?this.message=Ht(e,s,u):s?this.message=Ht(e,s):this.message=e}return i.prototype[Symbol.toStringTag]="Error",i.prototype.toString=function(){return`${this.name} [${this.code}]: ${this.message}`},ia(i,r),i}var Kn={createError:Ue,AVV_ERR_EXPOSE_ALREADY_DEFINED:Ue("AVV_ERR_EXPOSE_ALREADY_DEFINED","'%s' () is already defined, specify an expose option"),AVV_ERR_CALLBACK_NOT_FN:Ue("AVV_ERR_CALLBACK_NOT_FN","Callback for '%s' hook is not a function. Received: '%s'"),AVV_ERR_PLUGIN_NOT_VALID:Ue("AVV_ERR_PLUGIN_NOT_VALID","Plugin must be a function or a promise. Received: '%s'"),AVV_ERR_ROOT_PLG_BOOTED:Ue("AVV_ERR_PLUGIN_NOT_VALID","Root plugin has already booted"),AVV_ERR_PARENT_PLG_LOADED:Ue("AVV_ERR_PARENT_PLG_LOADED","Impossible to load '%s' plugin because the parent '%s' was already loaded"),AVV_ERR_READY_TIMEOUT:Ue("AVV_ERR_READY_TIMEOUT","Plugin did not start in time: '%s'. You may have forgotten to call 'done' function or to resolve a Promise")},oa=function t(e,r,i){r===void 0&&(r=""),i||(i={});var s=function(p){var m={"│":"|","└":"`","├":"+","─":"-","┬":"-"};return i.unicode===!1?m[p]:p};typeof e=="string"&&(e={label:e});var u=e.nodes||[],c=(e.label||"").split(`
|
|
17
17
|
`),h=`
|
|
18
18
|
`+r+(u.length?s("│"):" ")+" ";return r+c.join(h)+`
|
|
19
|
-
`+u.map(function(p,m){var
|
|
20
|
-
`).slice(0,2).map(r=>r.trim()).join(" -- ")}function ya(){const t={};return t.promise=new Promise((e,r)=>{t.resolve=e,t.reject=r}),t}function ct(t,e,r,i,s){this.started=!1,this.func=e,this.opts=r,this.onFinish=null,this.parent=t,this.timeout=s===void 0?t._timeout:s,this.name=pa(e,r),this.isAfter=i,this.q=la(t,ga,1),this.q.pause(),this._error=null,this.loaded=!1,this._promise=null}da(ct,fa);ct.prototype.exec=function(t,e){const r=this.func;let i=!1;const s=this.name;if(this.parent._error&&!this.isAfter){Z("skipping loading of plugin as parent errored and it is not an after",s),L.nextTick(e);return}if(this.isAfter)this.server=t;else try{this.server=this.parent.override(t,r,this.opts)}catch(p){return Z("override errored",s),e(p)}this.opts=typeof this.opts=="function"?this.opts(this.server):this.opts,Z("exec",s);let u;const c=p=>{if(i){Z("loading complete",s);return}this._error=p,Z(p?"exec errored":"exec completed",s),i=!0,u&&clearTimeout(u),e(p)};this.timeout>0&&(Z("setting up timeout",s,this.timeout),u=setTimeout(function(){Z("timed out",s),u=null;const p=new ha(s);p.fn=r,c(p)},this.timeout)),this.started=!0,this.emit("start",this.server?this.server.name:null,this.name,Date.now());const h=r(this.server,this.opts,c);h&&typeof h.then=="function"&&(Z("exec: resolving promise",s),h.then(()=>L.nextTick(c),p=>L.nextTick(c,p)))};ct.prototype.loadedSoFar=function(){if(this.loaded)return Promise.resolve();const t=()=>{this.server.after((r,i)=>{this._error=r,this.q.pause(),r?(Z("rejecting promise",this.name,r),this._promise.reject(r)):(Z("resolving promise",this.name),this._promise.resolve()),this._promise=null,L.nextTick(i,r)}),this.q.resume()};let e;return this._promise?e=Promise.resolve():(this._promise=ya(),e=this._promise.promise,this.server?t():this.on("start",t)),e};ct.prototype.enqueue=function(t,e){Z("enqueue",this.name,t.name),this.emit("enqueue",this.server?this.server.name:null,this.name,Date.now()),this.q.push(t,e)};ct.prototype.finish=function(t,e){Z("finish",this.name,t);const r=()=>{this.loaded||(Z("loaded",this.name),this.emit("loaded",this.server?this.server.name:null,this.name,Date.now()),this.loaded=!0,e(t))};if(t){this._promise&&(this._promise.reject(t),this._promise=null),r();return}const i=()=>{if(Z("check",this.name,this.q.length(),this.q.running(),this._promise),this.q.length()===0&&this.q.running()===0)if(this._promise){const s=()=>{Z("wrap"),queueMicrotask(i)};this._promise.resolve(),this._promise.promise.then(s,s),this._promise=null}else r();else Z("delayed",this.name),this.q.drain=()=>{Z("drain",this.name),this.q.drain=ma,queueMicrotask(i)}};queueMicrotask(i),this.q.resume()};function ga(t,e){const r=this;L.nextTick(Or.bind(r),t,e)}function Or(t,e){if(typeof t.func.then=="function"){t.func.then(i=>{typeof i.default=="function"&&(i=i.default),t.func=i,Or.call(this,t,e)},e);return}const r=this._current[0];this._current.unshift(t),t.exec(r&&r.server||this._server,i=>{t.finish(i,s=>{this._current.shift(),e(s)})})}function ma(){}_r.exports=ct;_r.exports.loadPlugin=Or;var wa=_r.exports;const tn=bn,ba=Fn.EventEmitter,va=Rt.inherits,{AVV_ERR_EXPOSE_ALREADY_DEFINED:Yt,AVV_ERR_CALLBACK_NOT_FN:pt,AVV_ERR_PLUGIN_NOT_VALID:Sa,AVV_ERR_ROOT_PLG_BOOTED:Aa,AVV_ERR_READY_TIMEOUT:Ea}=Gn,Ia=sa,fr=wa,at=zn("avvio"),xt=Symbol("kAvvio"),Xt=Symbol("kThenifyDoNotWrap");function Ta(t,e,r){const i=e.expose||{},s=i.use||"use",u=i.after||"after",c=i.ready||"ready",h=i.onClose||"onClose",p=i.close||"close";if(t[s])throw new Yt(s);if(t[u])throw new Yt(u);if(t[c])throw new Yt(c);t[s]=function(m,f){return r.use(m,f),this},Object.defineProperty(t,"then",{get:Kn.bind(r)}),t[xt]=!0,t[u]=function(m){return typeof m!="function"?r._loadRegistered():(r.after(Zt(m,this)),this)},t[c]=function(m){if(m&&typeof m!="function")throw new pt(c,typeof m);return r.ready(m?Zt(m,this):void 0)},t[h]=function(m){if(typeof m!="function")throw new pt(h,typeof m);return r.onClose(xa(m,this)),this},t[p]=function(m){if(m&&typeof m!="function")throw new pt(p,typeof m);return m?(r.close(Zt(m,this)),this):r.close()}}function te(t,e,r){if(typeof t=="function"&&arguments.length===1&&(r=t,e={},t=null),typeof e=="function"&&(r=e,e={}),e=e||{},!(this instanceof te)){const i=new te(t,e,r);return t&&Ta(t,e,i),i}e.autostart!==!1&&(e.autostart=!0),t=t||this,this._timeout=Number(e.timeout)||0,this._server=t,this._current=[],this._error=null,this._isOnCloseHandlerKey=Symbol("isOnCloseHandler"),this._lastUsed=null,this.setMaxListeners(0),r&&this.once("start",r),this.started=!1,this.booted=!1,this.pluginTree=new Ia,this._readyQ=tn(this,Wn,1),this._readyQ.pause(),this._readyQ.drain=()=>{this.emit("start"),this._readyQ.drain=rn},this._closeQ=tn(this,Ca,1),this._closeQ.pause(),this._closeQ.drain=()=>{this.emit("close"),this._closeQ.drain=rn},this._doStart=null,this._root=new fr(this,_a.bind(this),e,!1,0),this._root.once("start",(i,s,u)=>{const c=this.pluginTree.start(null,s,u);this._root.once("loaded",(h,p,m)=>{this.pluginTree.stop(c,m)})}),fr.loadPlugin.call(this,this._root,i=>{at("root plugin ready");try{this.emit("preReady"),this._root=null}catch(s){i=i||this._error||s}if(i){if(this._error=i,this._readyQ.length()===0)throw i}else this.booted=!0;this._readyQ.resume()})}function _a(t,e,r){this._doStart=r,e.autostart&&this.start()}va(te,ba);te.prototype.start=function(){return this.started=!0,L.nextTick(this._doStart),this};te.prototype.override=function(t,e,r){return t};function Oa(t){if(t&&typeof t=="object"&&typeof t.default=="function"&&(t=t.default),!(t&&(typeof t=="function"||typeof t.then=="function")))throw new Sa(typeof t);return t}te.prototype[xt]=!0;te.prototype.use=function(t,e){return this._lastUsed=this._addPlugin(t,e,!1),this};te.prototype._loadRegistered=function(){const t=this._current[0];return!this.started&&!this.booted&&L.nextTick(()=>this._root.q.resume()),t?t.loadedSoFar():Promise.resolve()};Object.defineProperty(te.prototype,"then",{get:Kn});te.prototype._addPlugin=function(t,e,r){if(t=Oa(t),e=e||{},this.booted)throw new Aa;const i=this._current[0],s=new fr(this,t,e,r);if(s.once("start",(u,c,h)=>{const p=this.pluginTree.start(i.name,c,h);s.once("loaded",(m,f,w)=>{this.pluginTree.stop(p,w)})}),i.loaded)throw new Error(s.name,i.name);return i.enqueue(s,u=>{u&&(this._error=u)}),s};te.prototype.after=function(t){if(!t)return this._loadRegistered();this._addPlugin(e.bind(this),{},!0);function e(r,i,s){Wn.call(this,t,s)}return this};te.prototype.onClose=function(t){if(typeof t!="function")throw new Error("not a function");t[this._isOnCloseHandlerKey]=!0,this._closeQ.unshift(t,e.bind(this));function e(r){r&&(this._error=r)}return this};te.prototype.close=function(t){let e;if(t){if(typeof t!="function")throw new pt("close",typeof t)}else e=new Promise(function(r,i){t=function(s){if(s)return i(s);r()}});return this.ready(()=>{this._error=null,this._closeQ.push(t),L.nextTick(this._closeQ.resume.bind(this._closeQ))}),e};te.prototype.ready=function(t){if(t){if(typeof t!="function")throw new pt("ready",typeof t);this._readyQ.push(t),queueMicrotask(this.start.bind(this));return}return new Promise((e,r)=>{this._readyQ.push(s),this.start();const i=this._current[0].server;function s(u,c,h){u?r(u):e(i),L.nextTick(h)}})};te.prototype.prettyPrint=function(){return this.pluginTree.prittyPrint()};te.prototype.toJSON=function(){return this.pluginTree.toJSON()};function rn(){}function Kn(){if(this.booted){at("thenify returning null because we are already booted");return}if(this[Xt]){this[Xt]=!1;return}return at("thenify"),(t,e)=>this._loadRegistered().then(()=>(this[Xt]=!0,t(this._server)),e)}function Wn(t,e){const r=this._server,i=this._error;let s;if(this._error=null,t.length===0)this._error=i,s=t(),s&&!s[xt]&&typeof s.then=="function"?s.then(()=>L.nextTick(e),u=>L.nextTick(e,u)):L.nextTick(e);else if(t.length===1)s=t(i),s&&!s[xt]&&typeof s.then=="function"?s.then(()=>L.nextTick(e),u=>L.nextTick(e,u)):L.nextTick(e);else if(this._timeout===0){const u=c=>{this._error=c,e(this._error)};t.length===2?t(i,u):t(i,r,u)}else Fa.call(this,t,i,r,e)}function Fa(t,e,r,i){const s=t.name;at("setting up ready timeout",s,this._timeout);let u=setTimeout(()=>{at("timed out",s),u=null;const h=new Ea(s);h.fn=t,this._error=h,i(h)},this._timeout);t.length===2?t(e,c.bind(this)):t(e,r,c.bind(this));function c(h){u&&(clearTimeout(u),this._error=h,i(this._error))}}function Ca(t,e){const r=this._server,i=t[this._isOnCloseHandlerKey];if(t.length===0||t.length===1){let s;i?s=t(r):s=t(this._error),s&&typeof s.then=="function"?(at("resolving close/onClose promise"),s.then(()=>L.nextTick(e),u=>L.nextTick(e,u))):L.nextTick(e)}else t.length===2?t(i?r:this._error,e):i?t(r,e):t(this._error,r,e)}function xa(t,e){return r.bind(e);function r(i,s){let u;t.length===0?(u=t(),u&&u.then?u.then(function(){L.nextTick(s)},s):L.nextTick(s)):t.length===1?(u=t(this),u&&u.then?u.then(function(){L.nextTick(s)},s):L.nextTick(s)):t(this,s)}}function Zt(t,e){return r.bind(e);function r(i,s){let u;t?t.length===0?(u=t(),u&&u.then?u.then(function(){L.nextTick(s,i)},s):L.nextTick(s,i)):t.length===1?(u=t(i),u&&u.then?u.then(function(){L.nextTick(s)},s):L.nextTick(s)):t.length===2?t(i,s):t(i,this,s):L.nextTick(s)}}mr.exports=te;mr.exports.express=function(t){return te(t,{expose:{use:"load"}})};var ka=mr.exports;const Ba=Ji(ka);(function(){if(window.requestAnimationFrame&&window.cancelAnimationFrame)return;const t=["webkit","moz","ms","o"];for(const e of t)window.requestAnimationFrame=window.requestAnimationFrame||window[`${e}RequestAnimationFrame`],window.cancelAnimationFrame=window.cancelAnimationFrame||window[`${e}CancelAnimationFrame`]||window[`${e}CancelRequestAnimationFrame`];if(/iP(ad|hone|od).*OS 6/.test(window.navigator.userAgent)||!window.requestAnimationFrame||!window.cancelAnimationFrame){let e=0;const r=!!(window.performance&&window.performance.now);window.requestAnimationFrame=function(i){const s=r?window.performance.now():new Date().getTime(),u=Math.max(0,16-(s-e)),c=window.setTimeout(function(){i(s+u)},u);return e=s+u,c},window.cancelAnimationFrame=clearTimeout}})();function La(t,e=!0,r=!0,i){const s=e?"https://grpc-sdk.streamlayer.io:443":"https://grpc-sdk.next.streamlayer.io:443",u=Ba(Object.create({}),{autostart:!1});return u.use(Bi),u.use(Fi),u.use(bi,{sdkKey:t,host:s,version:i?.version}),u.use(ki),u.use(xi),u.use(Ao),u.use(so),r&&u.after(async(c,h,p)=>{if(c)throw c;await h.sdk.initializeApp(),p()}),u.onClose(()=>{console.log("close")}),u}exports.StreamLayer=La;
|
|
19
|
+
`+u.map(function(p,m){var l=m===u.length-1,w=p.nodes&&p.nodes.length,E=r+(l?" ":s("│"))+" ";return r+s(l?"└":"├")+s("─")+s(w?"┬":"─")+" "+t(p,E,i).slice(r.length+2)}).join("")};const sa=oa,Zr=Symbol("avvio.TimeTree.untrackNode"),Jt=Symbol("avvio.TimeTree.trackNode"),en=Symbol("avvio.TimeTree.getParent"),tn=Symbol("avvio.TimeTree.getNode"),rn=Symbol("avvio.TimeTree.addNode");let aa=class{constructor(){this.root=null,this.tableId=new Map,this.tableLabel=new Map}[Jt](e){this.tableId.set(e.id,e),this.tableLabel.has(e.label)?this.tableLabel.get(e.label).push(e):this.tableLabel.set(e.label,[e])}[Zr](e){this.tableId.delete(e.id);const r=this.tableLabel.get(e.label);if(r.id){this.tableLabel.delete(e.label);return}r.pop(),r.length===0&&this.tableLabel.delete(e.label)}[en](e){if(e===null)return this.root;const r=this.tableLabel.get(e);return r.id?r:r[r.length-1]}[tn](e){return this.tableId.get(e)}[rn](e,r,i){if(e===null)return this.root={id:"root",label:r,start:i,nodes:[]},this[Jt](this.root),this.root.id;const u=this[en](e),c=`${r}-${Math.random()}`,h={id:c,parent:e,start:i,label:r,nodes:[]};return u.nodes.push(h),this[Jt](h),c}start(e,r,i=Date.now()){return this[rn](e,r,i)}stop(e,r=Date.now()){const i=this[tn](e);i&&(i.stop=r,i.diff=i.stop-i.start||0,this[Zr](i))}toJSON(){return Object.assign({},this.root)}prittyPrint(){const e=i=>(i.label=`${i.label} ${i.diff} ms`,i.nodes.length>0&&(i.nodes=i.nodes.map(s=>e(s))),i),r=e(this.toJSON());return sa(r)}};var ua=aa,Fr={exports:{}},dr={exports:{}},Yt,nn;function ca(){if(nn)return Yt;nn=1;var t=1e3,e=t*60,r=e*60,i=r*24,s=i*7,u=i*365.25;Yt=function(l,w){w=w||{};var E=typeof l;if(E==="string"&&l.length>0)return c(l);if(E==="number"&&isFinite(l))return w.long?p(l):h(l);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(l))};function c(l){if(l=String(l),!(l.length>100)){var w=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(l);if(w){var E=parseFloat(w[1]),T=(w[2]||"ms").toLowerCase();switch(T){case"years":case"year":case"yrs":case"yr":case"y":return E*u;case"weeks":case"week":case"w":return E*s;case"days":case"day":case"d":return E*i;case"hours":case"hour":case"hrs":case"hr":case"h":return E*r;case"minutes":case"minute":case"mins":case"min":case"m":return E*e;case"seconds":case"second":case"secs":case"sec":case"s":return E*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return E;default:return}}}}function h(l){var w=Math.abs(l);return w>=i?Math.round(l/i)+"d":w>=r?Math.round(l/r)+"h":w>=e?Math.round(l/e)+"m":w>=t?Math.round(l/t)+"s":l+"ms"}function p(l){var w=Math.abs(l);return w>=i?m(l,w,i,"day"):w>=r?m(l,w,r,"hour"):w>=e?m(l,w,e,"minute"):w>=t?m(l,w,t,"second"):l+" ms"}function m(l,w,E,T){var F=w>=E*1.5;return Math.round(l/E)+" "+T+(F?"s":"")}return Yt}function la(t){r.debug=r,r.default=r,r.coerce=p,r.disable=u,r.enable=s,r.enabled=c,r.humanize=ca(),r.destroy=m,Object.keys(t).forEach(l=>{r[l]=t[l]}),r.names=[],r.skips=[],r.formatters={};function e(l){let w=0;for(let E=0;E<l.length;E++)w=(w<<5)-w+l.charCodeAt(E),w|=0;return r.colors[Math.abs(w)%r.colors.length]}r.selectColor=e;function r(l){let w,E=null,T,F;function x(...N){if(!x.enabled)return;const I=x,O=Number(new Date),j=O-(w||O);I.diff=j,I.prev=w,I.curr=O,w=O,N[0]=r.coerce(N[0]),typeof N[0]!="string"&&N.unshift("%O");let P=0;N[0]=N[0].replace(/%([a-zA-Z%])/g,(k,B)=>{if(k==="%%")return"%";P++;const q=r.formatters[B];if(typeof q=="function"){const ie=N[P];k=q.call(I,ie),N.splice(P,1),P--}return k}),r.formatArgs.call(I,N),(I.log||r.log).apply(I,N)}return x.namespace=l,x.useColors=r.useColors(),x.color=r.selectColor(l),x.extend=i,x.destroy=r.destroy,Object.defineProperty(x,"enabled",{enumerable:!0,configurable:!1,get:()=>E!==null?E:(T!==r.namespaces&&(T=r.namespaces,F=r.enabled(l)),F),set:N=>{E=N}}),typeof r.init=="function"&&r.init(x),x}function i(l,w){const E=r(this.namespace+(typeof w>"u"?":":w)+l);return E.log=this.log,E}function s(l){r.save(l),r.namespaces=l,r.names=[],r.skips=[];let w;const E=(typeof l=="string"?l:"").split(/[\s,]+/),T=E.length;for(w=0;w<T;w++)E[w]&&(l=E[w].replace(/\*/g,".*?"),l[0]==="-"?r.skips.push(new RegExp("^"+l.slice(1)+"$")):r.names.push(new RegExp("^"+l+"$")))}function u(){const l=[...r.names.map(h),...r.skips.map(h).map(w=>"-"+w)].join(",");return r.enable(""),l}function c(l){if(l[l.length-1]==="*")return!0;let w,E;for(w=0,E=r.skips.length;w<E;w++)if(r.skips[w].test(l))return!1;for(w=0,E=r.names.length;w<E;w++)if(r.names[w].test(l))return!0;return!1}function h(l){return l.toString().substring(2,l.toString().length-2).replace(/\.\*\?$/,"*")}function p(l){return l instanceof Error?l.stack||l.message:l}function m(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return r.enable(r.load()),r}var fa=la;(function(t,e){e.formatArgs=i,e.save=s,e.load=u,e.useColors=r,e.storage=c(),e.destroy=(()=>{let p=!1;return()=>{p||(p=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),e.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function r(){return typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)?!1:typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function i(p){if(p[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+p[0]+(this.useColors?"%c ":" ")+"+"+t.exports.humanize(this.diff),!this.useColors)return;const m="color: "+this.color;p.splice(1,0,m,"color: inherit");let l=0,w=0;p[0].replace(/%[a-zA-Z%]/g,E=>{E!=="%%"&&(l++,E==="%c"&&(w=l))}),p.splice(w,0,m)}e.log=console.debug||console.log||(()=>{});function s(p){try{p?e.storage.setItem("debug",p):e.storage.removeItem("debug")}catch{}}function u(){let p;try{p=e.storage.getItem("debug")}catch{}return!p&&typeof L<"u"&&"env"in L&&(p=L.env.DEBUG),p}function c(){try{return localStorage}catch{}}t.exports=fa(e);const{formatters:h}=t.exports;h.j=function(p){try{return JSON.stringify(p)}catch(m){return"[UnexpectedJSONParseError]: "+m.message}}})(dr,dr.exports);var Wn=dr.exports;const da=Sn,ha=xn.EventEmitter,pa=Dt.inherits,Z=Wn("avvio"),{AVV_ERR_READY_TIMEOUT:ya}=Kn,Xt=Symbol.for("plugin-meta");function ga(t,e){return t[Xt]&&t[Xt].name?t[Xt].name:typeof e<"u"&&typeof e!="function"&&e.name?e.name:t.name?t.name:t.toString().split(`
|
|
20
|
+
`).slice(0,2).map(r=>r.trim()).join(" -- ")}function ma(){const t={};return t.promise=new Promise((e,r)=>{t.resolve=e,t.reject=r}),t}function lt(t,e,r,i,s){this.started=!1,this.func=e,this.opts=r,this.onFinish=null,this.parent=t,this.timeout=s===void 0?t._timeout:s,this.name=ga(e,r),this.isAfter=i,this.q=da(t,wa,1),this.q.pause(),this._error=null,this.loaded=!1,this._promise=null}pa(lt,ha);lt.prototype.exec=function(t,e){const r=this.func;let i=!1;const s=this.name;if(this.parent._error&&!this.isAfter){Z("skipping loading of plugin as parent errored and it is not an after",s),L.nextTick(e);return}if(this.isAfter)this.server=t;else try{this.server=this.parent.override(t,r,this.opts)}catch(p){return Z("override errored",s),e(p)}this.opts=typeof this.opts=="function"?this.opts(this.server):this.opts,Z("exec",s);let u;const c=p=>{if(i){Z("loading complete",s);return}this._error=p,Z(p?"exec errored":"exec completed",s),i=!0,u&&clearTimeout(u),e(p)};this.timeout>0&&(Z("setting up timeout",s,this.timeout),u=setTimeout(function(){Z("timed out",s),u=null;const p=new ya(s);p.fn=r,c(p)},this.timeout)),this.started=!0,this.emit("start",this.server?this.server.name:null,this.name,Date.now());const h=r(this.server,this.opts,c);h&&typeof h.then=="function"&&(Z("exec: resolving promise",s),h.then(()=>L.nextTick(c),p=>L.nextTick(c,p)))};lt.prototype.loadedSoFar=function(){if(this.loaded)return Promise.resolve();const t=()=>{this.server.after((r,i)=>{this._error=r,this.q.pause(),r?(Z("rejecting promise",this.name,r),this._promise.reject(r)):(Z("resolving promise",this.name),this._promise.resolve()),this._promise=null,L.nextTick(i,r)}),this.q.resume()};let e;return this._promise?e=Promise.resolve():(this._promise=ma(),e=this._promise.promise,this.server?t():this.on("start",t)),e};lt.prototype.enqueue=function(t,e){Z("enqueue",this.name,t.name),this.emit("enqueue",this.server?this.server.name:null,this.name,Date.now()),this.q.push(t,e)};lt.prototype.finish=function(t,e){Z("finish",this.name,t);const r=()=>{this.loaded||(Z("loaded",this.name),this.emit("loaded",this.server?this.server.name:null,this.name,Date.now()),this.loaded=!0,e(t))};if(t){this._promise&&(this._promise.reject(t),this._promise=null),r();return}const i=()=>{if(Z("check",this.name,this.q.length(),this.q.running(),this._promise),this.q.length()===0&&this.q.running()===0)if(this._promise){const s=()=>{Z("wrap"),queueMicrotask(i)};this._promise.resolve(),this._promise.promise.then(s,s),this._promise=null}else r();else Z("delayed",this.name),this.q.drain=()=>{Z("drain",this.name),this.q.drain=ba,queueMicrotask(i)}};queueMicrotask(i),this.q.resume()};function wa(t,e){const r=this;L.nextTick(Cr.bind(r),t,e)}function Cr(t,e){if(typeof t.func.then=="function"){t.func.then(i=>{typeof i.default=="function"&&(i=i.default),t.func=i,Cr.call(this,t,e)},e);return}const r=this._current[0];this._current.unshift(t),t.exec(r&&r.server||this._server,i=>{t.finish(i,s=>{this._current.shift(),e(s)})})}function ba(){}Fr.exports=lt;Fr.exports.loadPlugin=Cr;var va=Fr.exports;const on=Sn,Sa=xn.EventEmitter,Aa=Dt.inherits,{AVV_ERR_EXPOSE_ALREADY_DEFINED:Zt,AVV_ERR_CALLBACK_NOT_FN:yt,AVV_ERR_PLUGIN_NOT_VALID:Ea,AVV_ERR_ROOT_PLG_BOOTED:Ia,AVV_ERR_READY_TIMEOUT:Ta}=Kn,_a=ua,hr=va,ut=Wn("avvio"),kt=Symbol("kAvvio"),er=Symbol("kThenifyDoNotWrap");function Oa(t,e,r){const i=e.expose||{},s=i.use||"use",u=i.after||"after",c=i.ready||"ready",h=i.onClose||"onClose",p=i.close||"close";if(t[s])throw new Zt(s);if(t[u])throw new Zt(u);if(t[c])throw new Zt(c);t[s]=function(m,l){return r.use(m,l),this},Object.defineProperty(t,"then",{get:Hn.bind(r)}),t[kt]=!0,t[u]=function(m){return typeof m!="function"?r._loadRegistered():(r.after(tr(m,this)),this)},t[c]=function(m){if(m&&typeof m!="function")throw new yt(c,typeof m);return r.ready(m?tr(m,this):void 0)},t[h]=function(m){if(typeof m!="function")throw new yt(h,typeof m);return r.onClose(Ba(m,this)),this},t[p]=function(m){if(m&&typeof m!="function")throw new yt(p,typeof m);return m?(r.close(tr(m,this)),this):r.close()}}function te(t,e,r){if(typeof t=="function"&&arguments.length===1&&(r=t,e={},t=null),typeof e=="function"&&(r=e,e={}),e=e||{},!(this instanceof te)){const i=new te(t,e,r);return t&&Oa(t,e,i),i}e.autostart!==!1&&(e.autostart=!0),t=t||this,this._timeout=Number(e.timeout)||0,this._server=t,this._current=[],this._error=null,this._isOnCloseHandlerKey=Symbol("isOnCloseHandler"),this._lastUsed=null,this.setMaxListeners(0),r&&this.once("start",r),this.started=!1,this.booted=!1,this.pluginTree=new _a,this._readyQ=on(this,Jn,1),this._readyQ.pause(),this._readyQ.drain=()=>{this.emit("start"),this._readyQ.drain=sn},this._closeQ=on(this,ka,1),this._closeQ.pause(),this._closeQ.drain=()=>{this.emit("close"),this._closeQ.drain=sn},this._doStart=null,this._root=new hr(this,Fa.bind(this),e,!1,0),this._root.once("start",(i,s,u)=>{const c=this.pluginTree.start(null,s,u);this._root.once("loaded",(h,p,m)=>{this.pluginTree.stop(c,m)})}),hr.loadPlugin.call(this,this._root,i=>{ut("root plugin ready");try{this.emit("preReady"),this._root=null}catch(s){i=i||this._error||s}if(i){if(this._error=i,this._readyQ.length()===0)throw i}else this.booted=!0;this._readyQ.resume()})}function Fa(t,e,r){this._doStart=r,e.autostart&&this.start()}Aa(te,Sa);te.prototype.start=function(){return this.started=!0,L.nextTick(this._doStart),this};te.prototype.override=function(t,e,r){return t};function Ca(t){if(t&&typeof t=="object"&&typeof t.default=="function"&&(t=t.default),!(t&&(typeof t=="function"||typeof t.then=="function")))throw new Ea(typeof t);return t}te.prototype[kt]=!0;te.prototype.use=function(t,e){return this._lastUsed=this._addPlugin(t,e,!1),this};te.prototype._loadRegistered=function(){const t=this._current[0];return!this.started&&!this.booted&&L.nextTick(()=>this._root.q.resume()),t?t.loadedSoFar():Promise.resolve()};Object.defineProperty(te.prototype,"then",{get:Hn});te.prototype._addPlugin=function(t,e,r){if(t=Ca(t),e=e||{},this.booted)throw new Ia;const i=this._current[0],s=new hr(this,t,e,r);if(s.once("start",(u,c,h)=>{const p=this.pluginTree.start(i.name,c,h);s.once("loaded",(m,l,w)=>{this.pluginTree.stop(p,w)})}),i.loaded)throw new Error(s.name,i.name);return i.enqueue(s,u=>{u&&(this._error=u)}),s};te.prototype.after=function(t){if(!t)return this._loadRegistered();this._addPlugin(e.bind(this),{},!0);function e(r,i,s){Jn.call(this,t,s)}return this};te.prototype.onClose=function(t){if(typeof t!="function")throw new Error("not a function");t[this._isOnCloseHandlerKey]=!0,this._closeQ.unshift(t,e.bind(this));function e(r){r&&(this._error=r)}return this};te.prototype.close=function(t){let e;if(t){if(typeof t!="function")throw new yt("close",typeof t)}else e=new Promise(function(r,i){t=function(s){if(s)return i(s);r()}});return this.ready(()=>{this._error=null,this._closeQ.push(t),L.nextTick(this._closeQ.resume.bind(this._closeQ))}),e};te.prototype.ready=function(t){if(t){if(typeof t!="function")throw new yt("ready",typeof t);this._readyQ.push(t),queueMicrotask(this.start.bind(this));return}return new Promise((e,r)=>{this._readyQ.push(s),this.start();const i=this._current[0].server;function s(u,c,h){u?r(u):e(i),L.nextTick(h)}})};te.prototype.prettyPrint=function(){return this.pluginTree.prittyPrint()};te.prototype.toJSON=function(){return this.pluginTree.toJSON()};function sn(){}function Hn(){if(this.booted){ut("thenify returning null because we are already booted");return}if(this[er]){this[er]=!1;return}return ut("thenify"),(t,e)=>this._loadRegistered().then(()=>(this[er]=!0,t(this._server)),e)}function Jn(t,e){const r=this._server,i=this._error;let s;if(this._error=null,t.length===0)this._error=i,s=t(),s&&!s[kt]&&typeof s.then=="function"?s.then(()=>L.nextTick(e),u=>L.nextTick(e,u)):L.nextTick(e);else if(t.length===1)s=t(i),s&&!s[kt]&&typeof s.then=="function"?s.then(()=>L.nextTick(e),u=>L.nextTick(e,u)):L.nextTick(e);else if(this._timeout===0){const u=c=>{this._error=c,e(this._error)};t.length===2?t(i,u):t(i,r,u)}else xa.call(this,t,i,r,e)}function xa(t,e,r,i){const s=t.name;ut("setting up ready timeout",s,this._timeout);let u=setTimeout(()=>{ut("timed out",s),u=null;const h=new Ta(s);h.fn=t,this._error=h,i(h)},this._timeout);t.length===2?t(e,c.bind(this)):t(e,r,c.bind(this));function c(h){u&&(clearTimeout(u),this._error=h,i(this._error))}}function ka(t,e){const r=this._server,i=t[this._isOnCloseHandlerKey];if(t.length===0||t.length===1){let s;i?s=t(r):s=t(this._error),s&&typeof s.then=="function"?(ut("resolving close/onClose promise"),s.then(()=>L.nextTick(e),u=>L.nextTick(e,u))):L.nextTick(e)}else t.length===2?t(i?r:this._error,e):i?t(r,e):t(this._error,r,e)}function Ba(t,e){return r.bind(e);function r(i,s){let u;t.length===0?(u=t(),u&&u.then?u.then(function(){L.nextTick(s)},s):L.nextTick(s)):t.length===1?(u=t(this),u&&u.then?u.then(function(){L.nextTick(s)},s):L.nextTick(s)):t(this,s)}}function tr(t,e){return r.bind(e);function r(i,s){let u;t?t.length===0?(u=t(),u&&u.then?u.then(function(){L.nextTick(s,i)},s):L.nextTick(s,i)):t.length===1?(u=t(i),u&&u.then?u.then(function(){L.nextTick(s)},s):L.nextTick(s)):t.length===2?t(i,s):t(i,this,s):L.nextTick(s)}}br.exports=te;br.exports.express=function(t){return te(t,{expose:{use:"load"}})};var La=br.exports;const Pa=Xi(La);(function(){if(window.requestAnimationFrame&&window.cancelAnimationFrame)return;const t=["webkit","moz","ms","o"];for(const e of t)window.requestAnimationFrame=window.requestAnimationFrame||window[`${e}RequestAnimationFrame`],window.cancelAnimationFrame=window.cancelAnimationFrame||window[`${e}CancelAnimationFrame`]||window[`${e}CancelRequestAnimationFrame`];if(/iP(ad|hone|od).*OS 6/.test(window.navigator.userAgent)||!window.requestAnimationFrame||!window.cancelAnimationFrame){let e=0;const r=!!(window.performance&&window.performance.now);window.requestAnimationFrame=function(i){const s=r?window.performance.now():new Date().getTime(),u=Math.max(0,16-(s-e)),c=window.setTimeout(function(){i(s+u)},u);return e=s+u,c},window.cancelAnimationFrame=clearTimeout}})();function Ra(t,e=!0,r=!0,i){const s=e?"https://grpc-sdk.streamlayer.io:443":"https://grpc-sdk.next.streamlayer.io:443",u=Pa(Object.create({}),{autostart:!1});return u.use(Ri),u.use(ki),u.use(Si,{sdkKey:t,host:s,version:i?.version}),u.use(Pi),u.use(Li),u.use(Io),u.use(uo),r&&u.after(async(c,h,p)=>{if(c)throw c;await h.sdk.initializeApp(),p()}),u.onClose(()=>{console.log("close")}),u}exports.StreamLayer=Ra;
|